@vitessce/dev 3.7.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
- import { g as getDefaultExportFromCjs, aV as requireAssign, aW as require_export, aX as require_core, aY as require_fails, aZ as require_toObject, a_ as require_objectKeys, a$ as require_cof, b0 as require_wks, b1 as require_iterators, b2 as requireWeb_dom_iterable, b3 as requireEs6_string_iterator, b4 as require_anObject, b5 as require_hide, b6 as require_ctx, b7 as require_toLength, b8 as require_global, b9 as require_objectDp, ba as require_descriptors, bb as require_isObject, bc as require_objectCreate, bd as require_iterDefine, be as require_iterStep, bf as require_meta, bg as require_isArray, bh as require_iobject, bi as require_setToStringTag, bj as require_aFunction, bk as requireIterator, bl as require_propertyDesc, bm as require_root, bn as require_baseGetTag, bo as requireIsObjectLike, bp as requireIsObject, bq as requireEs6_symbol, br as requireDefineProperty, bs as require_toIobject, bt as require_objectGopd, bu as require_html, bv as require_domCreate, bw as require_library, bx as requireSymbol, by as require_objectPie, bz as require_has, bA as require_redefine, bB as require_objectAssign, bC as getAugmentedNamespace, bD as requirePropTypes, aI as jsxRuntimeExports } from "./index-DvN0sI8S.js";
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);
4
+ import { aH as getDefaultExportFromCjs, b2 as requireAssign, b3 as require_export, b4 as require_core, b5 as require_fails, b6 as require_toObject, b7 as require_objectKeys, b8 as require_cof, b9 as require_wks, ba as require_iterators, bb as requireWeb_dom_iterable, bc as requireEs6_string_iterator, bd as require_anObject, be as require_hide, bf as require_ctx, bg as require_toLength, bh as require_global, bi as require_objectDp, bj as require_descriptors, bk as require_isObject, bl as require_objectCreate, bm as require_iterDefine, bn as require_iterStep, bo as require_meta, bp as require_isArray, bq as require_iobject, br as require_setToStringTag, bs as require_aFunction, bt as requireIterator, bu as require_propertyDesc, bv as require_root, bw as require_baseGetTag, bx as requireIsObjectLike, by as requireIsObject, bz as requireEs6_symbol, bA as requireDefineProperty, bB as require_toIobject, bC as require_objectGopd, bD as require_html, bE as require_domCreate, bF as require_library, bG as requireSymbol, bH as require_objectPie, bI as require_has, bJ as require_redefine, bK as require_objectAssign, bL as diffCameraState, ao as jsxRuntimeExports } from "./index-C9I_zc0N.js";
2
5
  import React__default from "react";
3
- var lib = {};
4
6
  var assignExports = requireAssign();
5
7
  const _Object$assign = /* @__PURE__ */ getDefaultExportFromCjs(assignExports);
6
8
  var es6_object_keys = {};
@@ -887,7 +889,7 @@ function requireEs6_set() {
887
889
  var validate = require_validateCollection();
888
890
  var SET = "Set";
889
891
  es6_set = require_collection()(SET, function(get) {
890
- return function Set() {
892
+ return function Set2() {
891
893
  return get(this, arguments.length > 0 ? arguments[0] : void 0);
892
894
  };
893
895
  }, {
@@ -3104,8 +3106,8 @@ function serializeColor(x) {
3104
3106
  function srgbGammaExpand(value) {
3105
3107
  return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
3106
3108
  }
3107
- function getRelativeLuminance(color2) {
3108
- var _color = _slicedToArray(color2, 3);
3109
+ function getRelativeLuminance(color) {
3110
+ var _color = _slicedToArray(color, 3);
3109
3111
  const r = _color[0], g = _color[1], b = _color[2];
3110
3112
  return 0.2126 * srgbGammaExpand(r) + 0.7152 * srgbGammaExpand(g) + 0.0722 * srgbGammaExpand(b);
3111
3113
  }
@@ -3166,21 +3168,6 @@ class TrackableOptionalRGB extends WatchableValue {
3166
3168
  }
3167
3169
  }
3168
3170
  }
3169
- const color = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3170
- __proto__: null,
3171
- TrackableOptionalRGB,
3172
- TrackableRGB,
3173
- getRelativeLuminance,
3174
- packColor,
3175
- parseColorSerialization,
3176
- parseRGBAColorSpecification,
3177
- parseRGBColorSpecification,
3178
- serializeColor,
3179
- srgbGammaExpand,
3180
- unpackRGB,
3181
- unpackRGBA,
3182
- useWhiteBackground
3183
- }, Symbol.toStringTag, { value: "Module" }));
3184
3171
  /**
3185
3172
  * @license
3186
3173
  * Copyright 2016 Google Inc.
@@ -3501,73 +3488,10 @@ function stableStringify(x) {
3501
3488
  }
3502
3489
  return _JSON$stringify(x);
3503
3490
  }
3504
- function swapQuotes(x) {
3505
- return x.replace(/['"]/g, (s) => {
3506
- return s === '"' ? "'" : '"';
3507
- });
3508
- }
3509
- function urlSafeStringifyString(x) {
3510
- return swapQuotes(_JSON$stringify(swapQuotes(x)));
3511
- }
3512
- const URL_SAFE_COMMA = "_";
3513
- function urlSafeStringify(x) {
3514
- if (typeof x === "object") {
3515
- if (x === null) {
3516
- return "null";
3517
- }
3518
- let toJSON = x["toJSON"];
3519
- if (typeof toJSON === "function") {
3520
- return urlSafeStringify(toJSON.call(x));
3521
- }
3522
- if (Array.isArray(x)) {
3523
- let s2 = "[";
3524
- let size = x.length;
3525
- let i = 0;
3526
- if (i < size) {
3527
- s2 += urlSafeStringify(x[i]);
3528
- while (++i < size) {
3529
- s2 += URL_SAFE_COMMA;
3530
- s2 += urlSafeStringify(x[i]);
3531
- }
3532
- }
3533
- s2 += "]";
3534
- return s2;
3535
- }
3536
- let s = "{";
3537
- let keys2 = _Object$keys(x);
3538
- let first = true;
3539
- for (let key of keys2) {
3540
- let value = x[key];
3541
- if (value === void 0) {
3542
- continue;
3543
- }
3544
- let valueString = urlSafeStringify(value);
3545
- if (!valueString) {
3546
- continue;
3547
- }
3548
- if (!first) {
3549
- s += URL_SAFE_COMMA;
3550
- } else {
3551
- first = false;
3552
- }
3553
- s += urlSafeStringifyString(key);
3554
- s += ":";
3555
- s += valueString;
3556
- }
3557
- s += "}";
3558
- return s;
3559
- }
3560
- if (typeof x === "string") {
3561
- return urlSafeStringifyString(x);
3562
- }
3563
- return _JSON$stringify(x);
3564
- }
3565
3491
  const SINGLE_QUOTE_STRING_PATTERN = /('(?:[^'\\]|(?:\\.))*')/;
3566
3492
  const DOUBLE_QUOTE_STRING_PATTERN = /("(?:[^"\\]|(?:\\.))*")/;
3567
3493
  const SINGLE_OR_DOUBLE_QUOTE_STRING_PATTERN = new RegExp(`${SINGLE_QUOTE_STRING_PATTERN.source}|${DOUBLE_QUOTE_STRING_PATTERN.source}`);
3568
- const DOUBLE_OR_SINGLE_QUOTE_STRING_PATTERN = new RegExp(`${DOUBLE_QUOTE_STRING_PATTERN.source}|${SINGLE_QUOTE_STRING_PATTERN.source}`);
3569
3494
  const DOUBLE_QUOTE_PATTERN = /^((?:[^"'\\]|(?:\\[^']))*)("|\\')/;
3570
- const SINGLE_QUOTE_PATTERN = /^((?:[^"'\\]|(?:\\.))*)'/;
3571
3495
  function convertStringLiteral(x, quoteInitial, quoteReplace, quoteSearch) {
3572
3496
  if (x.length >= 2 && x.charAt(0) === quoteInitial && x.charAt(x.length - 1) === quoteInitial) {
3573
3497
  let inner = x.substr(1, x.length - 2);
@@ -3592,22 +3516,15 @@ function convertStringLiteral(x, quoteInitial, quoteReplace, quoteSearch) {
3592
3516
  }
3593
3517
  return x;
3594
3518
  }
3595
- function normalizeStringLiteral(x) {
3596
- return convertStringLiteral(x, "'", '"', DOUBLE_QUOTE_PATTERN);
3597
- }
3598
3519
  function convertJsonHelper(x, desiredCommaChar, desiredQuoteChar) {
3599
3520
  const commaSearch = /[&_,]/g;
3600
3521
  let quoteInitial;
3601
3522
  let quoteSearch;
3602
3523
  let stringLiteralPattern;
3603
- if (desiredQuoteChar === '"') {
3524
+ {
3604
3525
  quoteInitial = "'";
3605
3526
  quoteSearch = DOUBLE_QUOTE_PATTERN;
3606
3527
  stringLiteralPattern = SINGLE_OR_DOUBLE_QUOTE_STRING_PATTERN;
3607
- } else {
3608
- quoteInitial = '"';
3609
- quoteSearch = SINGLE_QUOTE_PATTERN;
3610
- stringLiteralPattern = DOUBLE_OR_SINGLE_QUOTE_STRING_PATTERN;
3611
3528
  }
3612
3529
  let s = "";
3613
3530
  while (x.length > 0) {
@@ -3636,40 +3553,9 @@ function convertJsonHelper(x, desiredCommaChar, desiredQuoteChar) {
3636
3553
  function urlSafeToJSON(x) {
3637
3554
  return convertJsonHelper(x, ",", '"');
3638
3555
  }
3639
- function jsonToUrlSafe(x) {
3640
- return convertJsonHelper(x, "_", "'");
3641
- }
3642
3556
  function urlSafeParse(x) {
3643
3557
  return JSON.parse(urlSafeToJSON(x));
3644
3558
  }
3645
- function pythonLiteralToJSON(x) {
3646
- let s = "";
3647
- while (x.length > 0) {
3648
- let m = x.match(SINGLE_OR_DOUBLE_QUOTE_STRING_PATTERN);
3649
- let before;
3650
- let replacement;
3651
- if (m === null) {
3652
- before = x;
3653
- x = "";
3654
- replacement = "";
3655
- } else {
3656
- before = x.substr(0, m.index);
3657
- x = x.substr(m.index + m[0].length);
3658
- let singleQuoteString = m[1];
3659
- if (singleQuoteString !== void 0) {
3660
- replacement = normalizeStringLiteral(singleQuoteString);
3661
- } else {
3662
- replacement = m[2];
3663
- }
3664
- }
3665
- s += before.replace(/\(/g, "[").replace(/\)/g, "]").replace("True", "true").replace("False", "false").replace(/,\s*([\}\]])/g, "$1");
3666
- s += replacement;
3667
- }
3668
- return s;
3669
- }
3670
- function pythonLiteralParse(x) {
3671
- return JSON.parse(pythonLiteralToJSON(x));
3672
- }
3673
3559
  function expectArray(x, length2) {
3674
3560
  if (!Array.isArray(x)) {
3675
3561
  throw new Error(`Expected array, but received: ${_JSON$stringify(x)}.`);
@@ -3741,29 +3627,6 @@ function verifyOptionalString(obj) {
3741
3627
  }
3742
3628
  return verifyString(obj);
3743
3629
  }
3744
- function verifyOptionalInt(obj) {
3745
- if (obj === void 0) {
3746
- return void 0;
3747
- }
3748
- return verifyInt(obj);
3749
- }
3750
- function verifyOptionalBoolean(obj) {
3751
- if (obj === void 0) {
3752
- return void 0;
3753
- }
3754
- if (typeof obj === "boolean") {
3755
- return obj;
3756
- } else if (obj === "true") {
3757
- return true;
3758
- } else if (obj === "false") {
3759
- return false;
3760
- } else {
3761
- throw new Error(`Expected string or boolean but received: ${_JSON$stringify(obj)}`);
3762
- }
3763
- }
3764
- function valueOr(value, defaultValue) {
3765
- return value === void 0 ? defaultValue : value;
3766
- }
3767
3630
  function verifyObjectProperty(obj, propertyName, validator) {
3768
3631
  let value = Object.prototype.hasOwnProperty.call(obj, propertyName) ? obj[propertyName] : void 0;
3769
3632
  try {
@@ -3833,12 +3696,6 @@ function verifyEnumString(obj, enumType) {
3833
3696
  function verify3dVec(obj) {
3834
3697
  return parseFixedLengthArray(create$3(), obj, verifyFiniteFloat);
3835
3698
  }
3836
- function verify3dScale(obj) {
3837
- return parseFixedLengthArray(create$3(), obj, verifyFinitePositiveFloat);
3838
- }
3839
- function verify3dDimensions(obj) {
3840
- return parseFixedLengthArray(create$3(), obj, verifyPositiveInt);
3841
- }
3842
3699
  function verifyStringArray(a) {
3843
3700
  if (!Array.isArray(a)) {
3844
3701
  throw new Error(`Expected array, received: ${_JSON$stringify(a)}.`);
@@ -3873,52 +3730,6 @@ function emptyToUndefined(x) {
3873
3730
  }
3874
3731
  return void 0;
3875
3732
  }
3876
- const json = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3877
- __proto__: null,
3878
- emptyToUndefined,
3879
- expectArray,
3880
- jsonToUrlSafe,
3881
- normalizeStringLiteral,
3882
- parseArray,
3883
- parseFiniteVec,
3884
- parseFixedLengthArray,
3885
- parseIntVec,
3886
- parseQueryStringParameters,
3887
- parseXYZ,
3888
- pythonLiteralParse,
3889
- pythonLiteralToJSON,
3890
- stableStringify,
3891
- unparseQueryStringParameters,
3892
- urlSafeParse,
3893
- urlSafeStringify,
3894
- urlSafeStringifyString,
3895
- urlSafeToJSON,
3896
- valueOr,
3897
- verify3dDimensions,
3898
- verify3dScale,
3899
- verify3dVec,
3900
- verifyBoolean,
3901
- verifyEnumString,
3902
- verifyFiniteFloat,
3903
- verifyFiniteNonNegativeFloat,
3904
- verifyFinitePositiveFloat,
3905
- verifyFloat,
3906
- verifyFloat01,
3907
- verifyInt,
3908
- verifyIntegerArray,
3909
- verifyMapKey,
3910
- verifyNonnegativeInt,
3911
- verifyObject,
3912
- verifyObjectAsMap,
3913
- verifyObjectProperty,
3914
- verifyOptionalBoolean,
3915
- verifyOptionalInt,
3916
- verifyOptionalObjectProperty,
3917
- verifyOptionalString,
3918
- verifyPositiveInt,
3919
- verifyString,
3920
- verifyStringArray
3921
- }, Symbol.toStringTag, { value: "Module" }));
3922
3733
  /**
3923
3734
  * @license
3924
3735
  * Copyright 2021 Google Inc.
@@ -4310,10 +4121,6 @@ class Uint64 {
4310
4121
  }
4311
4122
  Uint64.ZERO = new Uint64(0, 0);
4312
4123
  Uint64.ONE = new Uint64(1, 0);
4313
- const uint64 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4314
- __proto__: null,
4315
- Uint64
4316
- }, Symbol.toStringTag, { value: "Module" }));
4317
4124
  const defaultDataTypeRange = {
4318
4125
  [DataType.UINT8]: [0, 255],
4319
4126
  [DataType.INT8]: [-128, 127],
@@ -5958,20 +5765,20 @@ function coordinateSpaceToJson(coordinateSpace) {
5958
5765
  const rank = coordinateSpace.rank;
5959
5766
  if (rank === 0) return void 0;
5960
5767
  const names = coordinateSpace.names, units = coordinateSpace.units, scales = coordinateSpace.scales, coordinateArrays = coordinateSpace.coordinateArrays;
5961
- const json2 = {};
5768
+ const json = {};
5962
5769
  for (let i = 0; i < rank; ++i) {
5963
5770
  const name2 = names[i];
5964
5771
  const coordinateArray = coordinateArrays[i];
5965
5772
  if (coordinateArray === null || coordinateArray === void 0 ? void 0 : coordinateArray.explicit) {
5966
- json2[name2] = {
5773
+ json[name2] = {
5967
5774
  coordinates: _Array$from(coordinateArray.coordinates),
5968
5775
  labels: coordinateArray.labels
5969
5776
  };
5970
5777
  } else {
5971
- json2[name2] = [scales[i], units[i]];
5778
+ json[name2] = [scales[i], units[i]];
5972
5779
  }
5973
5780
  }
5974
- return json2;
5781
+ return json;
5975
5782
  }
5976
5783
  class TrackableCoordinateSpace extends WatchableValue {
5977
5784
  constructor() {
@@ -9996,7 +9803,7 @@ function shaderCodeWithLineDirective(code, sourceStringNumber = 1, line = 0) {
9996
9803
  * See the License for the specific language governing permissions and
9997
9804
  * limitations under the License.
9998
9805
  */
9999
- class Buffer {
9806
+ class Buffer2 {
10000
9807
  constructor(gl, bufferType = WebGL2RenderingContext.ARRAY_BUFFER) {
10001
9808
  this.gl = gl;
10002
9809
  this.bufferType = bufferType;
@@ -10027,14 +9834,14 @@ class Buffer {
10027
9834
  this.gl = void 0;
10028
9835
  }
10029
9836
  static fromData(gl, data, bufferType, usage) {
10030
- let buffer = new Buffer(gl, bufferType);
9837
+ let buffer = new Buffer2(gl, bufferType);
10031
9838
  buffer.setData(data, usage);
10032
9839
  return buffer;
10033
9840
  }
10034
9841
  }
10035
9842
  function getMemoizedBuffer(gl, bufferType, getter, ...args) {
10036
9843
  return gl.memoize.get(stableStringify({ id: "getMemoizedBuffer", getter: getObjectId(getter), args }), () => {
10037
- const result = new RefCountedValue(Buffer.fromData(gl, getter(...args), bufferType, WebGL2RenderingContext.STATIC_DRAW));
9844
+ const result = new RefCountedValue(Buffer2.fromData(gl, getter(...args), bufferType, WebGL2RenderingContext.STATIC_DRAW));
10038
9845
  result.registerDisposer(result.value);
10039
9846
  return result;
10040
9847
  });
@@ -13139,8 +12946,8 @@ if (ng_discardValue) {
13139
12946
  gl.uniform1ui(shader.uniform("uPickID"), context.basePickId);
13140
12947
  }
13141
12948
  if (renderContext.emitColor) {
13142
- const color2 = annotationLayer.state.displayState.color.value;
13143
- gl.uniform3f(shader.uniform("uColor"), color2[0], color2[1], color2[2]);
12949
+ const color = annotationLayer.state.displayState.color.value;
12950
+ gl.uniform3f(shader.uniform("uColor"), color[0], color[1], color[2]);
13144
12951
  gl.uniform1ui(shader.uniform("uSelectedIndex"), context.selectedIndex);
13145
12952
  }
13146
12953
  const binder = shader.vertexShaderInputBinders["properties"];
@@ -15651,12 +15458,12 @@ function requireThrottle() {
15651
15458
  }
15652
15459
  var throttleExports = requireThrottle();
15653
15460
  const throttle = /* @__PURE__ */ getDefaultExportFromCjs(throttleExports);
15654
- function parseDataSubsourceSpecificationFromJson(json2) {
15655
- if (typeof json2 === "boolean") {
15656
- return { enabled: json2 };
15461
+ function parseDataSubsourceSpecificationFromJson(json) {
15462
+ if (typeof json === "boolean") {
15463
+ return { enabled: json };
15657
15464
  }
15658
- verifyObject(json2);
15659
- return { enabled: verifyOptionalObjectProperty(json2, "enabled", verifyBoolean) };
15465
+ verifyObject(json);
15466
+ return { enabled: verifyOptionalObjectProperty(json, "enabled", verifyBoolean) };
15660
15467
  }
15661
15468
  function layerDataSourceSpecificationFromJson(obj, legacyTransform = void 0) {
15662
15469
  if (typeof obj === "string") {
@@ -16482,19 +16289,19 @@ class Position extends RefCounted {
16482
16289
  };
16483
16290
  }
16484
16291
  }
16485
- function restoreLinkedFromJson(link, value, json2) {
16486
- if (json2 === void 0 || _Object$keys(json2).length === 0) {
16292
+ function restoreLinkedFromJson(link, value, json) {
16293
+ if (json === void 0 || _Object$keys(json).length === 0) {
16487
16294
  link.value = NavigationLinkType.LINKED;
16488
16295
  return;
16489
16296
  }
16490
- verifyObject(json2);
16297
+ verifyObject(json);
16491
16298
  link.value = NavigationLinkType.UNLINKED;
16492
- verifyObjectProperty(json2, "value", (x) => {
16299
+ verifyObjectProperty(json, "value", (x) => {
16493
16300
  if (x !== void 0) {
16494
16301
  value.restoreState(x);
16495
16302
  }
16496
16303
  });
16497
- verifyObjectProperty(json2, "link", (x) => link.restoreState(x));
16304
+ verifyObjectProperty(json, "link", (x) => link.restoreState(x));
16498
16305
  }
16499
16306
  class LinkedBase {
16500
16307
  constructor(peer, link = new TrackableNavigationLink()) {
@@ -16679,7 +16486,7 @@ class TrackableRelativeDisplayScales extends RefCounted {
16679
16486
  this.changed.dispatch();
16680
16487
  }
16681
16488
  toJSON() {
16682
- const json2 = {};
16489
+ const json = {};
16683
16490
  let nonEmpty = false;
16684
16491
  const value = this.value;
16685
16492
  const factors = value.factors;
@@ -16688,19 +16495,19 @@ class TrackableRelativeDisplayScales extends RefCounted {
16688
16495
  for (let i = 0; i < rank; ++i) {
16689
16496
  const factor = factors[i];
16690
16497
  if (factor === 1) continue;
16691
- json2[names[i]] = factor;
16498
+ json[names[i]] = factor;
16692
16499
  nonEmpty = true;
16693
16500
  }
16694
- if (nonEmpty) return json2;
16501
+ if (nonEmpty) return json;
16695
16502
  return void 0;
16696
16503
  }
16697
- restoreState(json2) {
16504
+ restoreState(json) {
16698
16505
  const coordinateSpace = this.coordinateSpace.value;
16699
16506
  const names = coordinateSpace.names, rank = coordinateSpace.rank;
16700
16507
  const factors = new Float64Array(rank);
16701
16508
  factors.fill(-1);
16702
- if (json2 !== void 0) {
16703
- const obj = verifyObject(json2);
16509
+ if (json !== void 0) {
16510
+ const obj = verifyObject(json);
16704
16511
  for (let i = 0; i < rank; ++i) {
16705
16512
  factors[i] = verifyObjectProperty(obj, names[i], (x) => x === void 0 ? 1 : verifyFinitePositiveFloat(x));
16706
16513
  }
@@ -18772,8 +18579,8 @@ vec3 ${this.prefix}(uint64_t x) {
18772
18579
  }
18773
18580
  }
18774
18581
  let tempColor$1 = new Float32Array(3);
18775
- function getCssColor(color2) {
18776
- return `rgb(${color2[0] * 100}%,${color2[1] * 100}%,${color2[2] * 100}%)`;
18582
+ function getCssColor(color) {
18583
+ return `rgb(${color[0] * 100}%,${color[1] * 100}%,${color[2] * 100}%)`;
18777
18584
  }
18778
18585
  class SegmentColorHash {
18779
18586
  constructor(hashSeed = getRandomUint32()) {
@@ -20865,21 +20672,21 @@ class SegmentWidgetFactory {
20865
20672
  const unmappedIdIndex = template.unmappedIdIndex;
20866
20673
  if (unmappedIdIndex !== -1) {
20867
20674
  let unmappedIdString;
20868
- let color2;
20675
+ let color;
20869
20676
  if (displayState.baseSegmentColoring.value && (unmappedIdString = container.dataset.unmappedId) !== void 0) {
20870
20677
  const unmappedId = tempStatedColor;
20871
20678
  unmappedId.parseString(unmappedIdString);
20872
- color2 = getBaseObjectColor(this.displayState, unmappedId);
20679
+ color = getBaseObjectColor(this.displayState, unmappedId);
20873
20680
  } else {
20874
- color2 = kOneVec;
20681
+ color = kOneVec;
20875
20682
  }
20876
- setSegmentIdElementStyle(idContainer.children[unmappedIdIndex], color2);
20683
+ setSegmentIdElementStyle(idContainer.children[unmappedIdIndex], color);
20877
20684
  }
20878
20685
  }
20879
20686
  }
20880
- function setSegmentIdElementStyle(element, color2) {
20881
- element.style.backgroundColor = getCssColor(color2);
20882
- element.style.color = useWhiteBackground(color2) ? "white" : "black";
20687
+ function setSegmentIdElementStyle(element, color) {
20688
+ element.style.backgroundColor = getCssColor(color);
20689
+ element.style.color = useWhiteBackground(color) ? "white" : "black";
20883
20690
  }
20884
20691
  class SegmentWidgetWithExtraColumnsFactory extends SegmentWidgetFactory {
20885
20692
  constructor(displayState, parentElement, includeProperty) {
@@ -21003,33 +20810,33 @@ function registerRedrawWhenSegmentationDisplayState3DChanged(displayState, rende
21003
20810
  }
21004
20811
  const tempColor = create$2();
21005
20812
  const tempStatedColor = new Uint64();
21006
- function getBaseObjectColor(displayState, objectId, color2 = tempColor) {
20813
+ function getBaseObjectColor(displayState, objectId, color = tempColor) {
21007
20814
  if (displayState == null) {
21008
- color2.fill(1);
21009
- return color2;
20815
+ color.fill(1);
20816
+ return color;
21010
20817
  }
21011
20818
  const colorGroupState = displayState.segmentationColorGroupState.value;
21012
20819
  const segmentStatedColors = colorGroupState.segmentStatedColors;
21013
20820
  if (segmentStatedColors.size !== 0 && colorGroupState.segmentStatedColors.get(objectId, tempStatedColor)) {
21014
- color2[0] = (tempStatedColor.low & 255) / 255;
21015
- color2[1] = ((tempStatedColor.low & 65280) >>> 8) / 255;
21016
- color2[2] = ((tempStatedColor.low & 16711680) >>> 16) / 255;
21017
- return color2;
20821
+ color[0] = (tempStatedColor.low & 255) / 255;
20822
+ color[1] = ((tempStatedColor.low & 65280) >>> 8) / 255;
20823
+ color[2] = ((tempStatedColor.low & 16711680) >>> 16) / 255;
20824
+ return color;
21018
20825
  }
21019
20826
  const segmentDefaultColor = colorGroupState.segmentDefaultColor.value;
21020
20827
  if (segmentDefaultColor !== void 0) {
21021
- color2[0] = segmentDefaultColor[0];
21022
- color2[1] = segmentDefaultColor[1];
21023
- color2[2] = segmentDefaultColor[2];
21024
- return color2;
20828
+ color[0] = segmentDefaultColor[0];
20829
+ color[1] = segmentDefaultColor[1];
20830
+ color[2] = segmentDefaultColor[2];
20831
+ return color;
21025
20832
  }
21026
- colorGroupState.segmentColorHash.compute(color2, objectId);
21027
- return color2;
20833
+ colorGroupState.segmentColorHash.compute(color, objectId);
20834
+ return color;
21028
20835
  }
21029
20836
  function getObjectColor(displayState, objectId, alpha = 1) {
21030
- const color2 = tempColor;
21031
- color2[3] = alpha;
21032
- getBaseObjectColor(displayState, objectId, color2);
20837
+ const color = tempColor;
20838
+ color[3] = alpha;
20839
+ getBaseObjectColor(displayState, objectId, color);
21033
20840
  let saturation = displayState.saturation.value;
21034
20841
  if (displayState.segmentSelectionState.isSelected(objectId)) {
21035
20842
  if (saturation > 0.5) {
@@ -21039,12 +20846,12 @@ function getObjectColor(displayState, objectId, alpha = 1) {
21039
20846
  }
21040
20847
  }
21041
20848
  for (let i = 0; i < 3; ++i) {
21042
- color2[i] = color2[i] * saturation + (1 - saturation);
20849
+ color[i] = color[i] * saturation + (1 - saturation);
21043
20850
  }
21044
- color2[0] *= alpha;
21045
- color2[1] *= alpha;
21046
- color2[2] *= alpha;
21047
- return color2;
20851
+ color[0] *= alpha;
20852
+ color[1] *= alpha;
20853
+ color[2] *= alpha;
20854
+ return color;
21048
20855
  }
21049
20856
  function sendVisibleSegmentsState(state, options = {}) {
21050
20857
  for (const property of VISIBLE_SEGMENTS_STATE_PROPERTIES) {
@@ -21073,33 +20880,10 @@ function forEachVisibleSegmentToDraw(displayState, renderLayer, emitColor, pickI
21073
20880
  const baseSegmentColoring = displayState.baseSegmentColoring.value;
21074
20881
  forEachVisibleSegment(displayState.segmentationGroupState.value, (objectId, rootObjectId) => {
21075
20882
  let pickIndex = pickIDs === null || pickIDs === void 0 ? void 0 : pickIDs.registerUint64(renderLayer, objectId);
21076
- let color2 = emitColor ? getObjectColor(displayState, baseSegmentColoring ? objectId : rootObjectId, alpha) : void 0;
21077
- callback(objectId, color2, pickIndex, rootObjectId);
20883
+ let color = emitColor ? getObjectColor(displayState, baseSegmentColoring ? objectId : rootObjectId, alpha) : void 0;
20884
+ callback(objectId, color, pickIndex, rootObjectId);
21078
20885
  });
21079
20886
  }
21080
- const frontend = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
21081
- __proto__: null,
21082
- SegmentSelectionState,
21083
- SegmentWidgetFactory,
21084
- SegmentWidgetWithExtraColumnsFactory,
21085
- SegmentationLayerSharedObject,
21086
- Uint64MapEntry,
21087
- augmentSegmentId,
21088
- bindSegmentListWidth,
21089
- forEachVisibleSegmentToDraw,
21090
- getBaseObjectColor,
21091
- getObjectColor,
21092
- makeSegmentWidget,
21093
- maybeAugmentSegmentId,
21094
- registerCallbackWhenSegmentationDisplayStateChanged,
21095
- registerRedrawWhenSegmentationDisplayState3DChanged,
21096
- registerRedrawWhenSegmentationDisplayStateChanged,
21097
- registerRedrawWhenSegmentationDisplayStateWithAlphaChanged,
21098
- resetTemporaryVisibleSegmentsState,
21099
- segmentWidgetTemplateWithExtraColumns,
21100
- sendVisibleSegmentsState,
21101
- updateIdStringWidth
21102
- }, Symbol.toStringTag, { value: "Module" }));
21103
20887
  /**
21104
20888
  * @license
21105
20889
  * Copyright 2016 Google Inc.
@@ -21124,9 +20908,9 @@ var __decorate$5 = function(decorators, target, key, desc) {
21124
20908
  const tempMat4$5 = create$4();
21125
20909
  const tempMat3$1 = create$5();
21126
20910
  function copyMeshDataToGpu(gl, chunk) {
21127
- chunk.vertexBuffer = Buffer.fromData(gl, chunk.meshData.vertexPositions, gl.ARRAY_BUFFER, gl.STATIC_DRAW);
21128
- chunk.indexBuffer = Buffer.fromData(gl, chunk.meshData.indices, gl.ELEMENT_ARRAY_BUFFER, gl.STATIC_DRAW);
21129
- chunk.normalBuffer = Buffer.fromData(gl, chunk.meshData.vertexNormals, gl.ARRAY_BUFFER, gl.STATIC_DRAW);
20911
+ chunk.vertexBuffer = Buffer2.fromData(gl, chunk.meshData.vertexPositions, gl.ARRAY_BUFFER, gl.STATIC_DRAW);
20912
+ chunk.indexBuffer = Buffer2.fromData(gl, chunk.meshData.indices, gl.ELEMENT_ARRAY_BUFFER, gl.STATIC_DRAW);
20913
+ chunk.normalBuffer = Buffer2.fromData(gl, chunk.meshData.vertexNormals, gl.ARRAY_BUFFER, gl.STATIC_DRAW);
21130
20914
  }
21131
20915
  function freeGpuMeshData(chunk) {
21132
20916
  chunk.vertexBuffer.dispose();
@@ -21206,8 +20990,8 @@ class MeshShaderManager {
21206
20990
  gl.uniform1f(shader.uniform("uSilhouettePower"), silhouetteRendering);
21207
20991
  }
21208
20992
  }
21209
- setColor(gl, shader, color2) {
21210
- gl.uniform4fv(shader.uniform("uColor"), color2);
20993
+ setColor(gl, shader, color) {
20994
+ gl.uniform4fv(shader.uniform("uColor"), color);
21211
20995
  }
21212
20996
  setPickID(gl, shader, pickID) {
21213
20997
  gl.uniform1ui(shader.uniform("uPickID"), pickID);
@@ -21357,14 +21141,14 @@ class MeshLayer extends PerspectiveViewRenderLayer {
21357
21141
  let totalChunks = 0, presentChunks = 0;
21358
21142
  const renderScaleHistogram = this.displayState.renderScaleHistogram;
21359
21143
  const fragmentChunks = this.source.fragmentSource.chunks;
21360
- forEachVisibleSegmentToDraw(displayState, this, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color2, pickIndex) => {
21144
+ forEachVisibleSegmentToDraw(displayState, this, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color, pickIndex) => {
21361
21145
  const key = getObjectKey(objectId);
21362
21146
  const manifestChunk = manifestChunks.get(key);
21363
21147
  ++totalChunks;
21364
21148
  if (manifestChunk === void 0) return;
21365
21149
  ++presentChunks;
21366
21150
  if (renderContext.emitColor) {
21367
- meshShaderManager.setColor(gl, shader, color2);
21151
+ meshShaderManager.setColor(gl, shader, color);
21368
21152
  }
21369
21153
  if (renderContext.emitPickID) {
21370
21154
  meshShaderManager.setPickID(gl, shader, pickIndex);
@@ -21528,7 +21312,7 @@ class MultiscaleMeshLayer extends PerspectiveViewRenderLayer {
21528
21312
  meshShaderManager.beginModel(gl, shader, renderContext, modelMatrix);
21529
21313
  let totalManifestChunks = 0;
21530
21314
  let presentManifestChunks = 0;
21531
- forEachVisibleSegmentToDraw(displayState, this, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color2, pickIndex) => {
21315
+ forEachVisibleSegmentToDraw(displayState, this, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color, pickIndex) => {
21532
21316
  const key = getObjectKey(objectId);
21533
21317
  const manifestChunk = chunks.get(key);
21534
21318
  ++totalManifestChunks;
@@ -21537,7 +21321,7 @@ class MultiscaleMeshLayer extends PerspectiveViewRenderLayer {
21537
21321
  const manifest = manifestChunk.manifest;
21538
21322
  const octree = manifest.octree, chunkShape = manifest.chunkShape, chunkGridSpatialOrigin = manifest.chunkGridSpatialOrigin, vertexOffsets = manifest.vertexOffsets;
21539
21323
  if (renderContext.emitColor) {
21540
- meshShaderManager.setColor(gl, shader, color2);
21324
+ meshShaderManager.setColor(gl, shader, color);
21541
21325
  }
21542
21326
  if (renderContext.emitPickID) {
21543
21327
  meshShaderManager.setPickID(gl, shader, pickIndex);
@@ -22076,7 +21860,7 @@ int getVertexId () {
22076
21860
  class VertexIdHelper extends RefCounted {
22077
21861
  constructor(gl) {
22078
21862
  super();
22079
- this.buffer = new Buffer(gl);
21863
+ this.buffer = new Buffer2(gl);
22080
21864
  this.size = 0;
22081
21865
  }
22082
21866
  disposed() {
@@ -22255,8 +22039,8 @@ void emitDefault() {
22255
22039
  gl.uniformMatrix4fv(shader.uniform("uProjection"), false, mat);
22256
22040
  this.vertexIdHelper.enable();
22257
22041
  }
22258
- setColor(gl, shader, color2) {
22259
- gl.uniform4fv(shader.uniform("uColor"), color2);
22042
+ setColor(gl, shader, color) {
22043
+ gl.uniform4fv(shader.uniform("uColor"), color);
22260
22044
  }
22261
22045
  setPickID(gl, shader, pickID) {
22262
22046
  gl.uniform1ui(shader.uniform("uPickID"), pickID);
@@ -22423,17 +22207,17 @@ class SkeletonLayer extends RefCounted {
22423
22207
  gl.uniform1f(nodeShader.uniform("uNodeDiameter"), pointDiameter);
22424
22208
  setControlsInShader(gl, nodeShader, shaderControlState, nodeShaderParameters.parseResult.controls);
22425
22209
  const skeletons = source.chunks;
22426
- forEachVisibleSegmentToDraw(displayState, layer, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color2, pickIndex) => {
22210
+ forEachVisibleSegmentToDraw(displayState, layer, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color, pickIndex) => {
22427
22211
  const key = getObjectKey(objectId);
22428
22212
  const skeleton = skeletons.get(key);
22429
22213
  if (skeleton === void 0 || skeleton.state !== ChunkState.GPU_MEMORY) {
22430
22214
  return;
22431
22215
  }
22432
- if (color2 !== void 0) {
22216
+ if (color !== void 0) {
22433
22217
  edgeShader.bind();
22434
- renderHelper.setColor(gl, edgeShader, color2);
22218
+ renderHelper.setColor(gl, edgeShader, color);
22435
22219
  nodeShader.bind();
22436
- renderHelper.setColor(gl, nodeShader, color2);
22220
+ renderHelper.setColor(gl, nodeShader, color);
22437
22221
  }
22438
22222
  if (pickIndex !== void 0) {
22439
22223
  edgeShader.bind();
@@ -22553,7 +22337,7 @@ class SkeletonChunk extends Chunk {
22553
22337
  vertexAttributeTextures[i] = texture;
22554
22338
  }
22555
22339
  gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, null);
22556
- this.indexBuffer = Buffer.fromData(gl, this.indices, WebGL2RenderingContext.ARRAY_BUFFER, WebGL2RenderingContext.STATIC_DRAW);
22340
+ this.indexBuffer = Buffer2.fromData(gl, this.indices, WebGL2RenderingContext.ARRAY_BUFFER, WebGL2RenderingContext.STATIC_DRAW);
22557
22341
  }
22558
22342
  freeGPUMemory(gl) {
22559
22343
  super.freeGPUMemory(gl);
@@ -25798,19 +25582,19 @@ class ToolBinder extends RefCounted {
25798
25582
  }
25799
25583
  if (tool !== void 0) {
25800
25584
  const layerToolBinder = tool.layer.toolBinder;
25801
- const json2 = _JSON$stringify(tool.toJSON());
25802
- const existingKey = layerToolBinder.jsonToKey.get(json2);
25585
+ const json = _JSON$stringify(tool.toJSON());
25586
+ const existingKey = layerToolBinder.jsonToKey.get(json);
25803
25587
  if (existingKey !== void 0) {
25804
25588
  const existingTool2 = layerToolBinder.bindings.get(existingKey);
25805
25589
  existingTool2.keyBinding = void 0;
25806
25590
  bindings.delete(existingKey);
25807
25591
  layerToolBinder.bindings.delete(existingKey);
25808
- layerToolBinder.jsonToKey.delete(json2);
25592
+ layerToolBinder.jsonToKey.delete(json);
25809
25593
  this.destroyTool(existingTool2);
25810
25594
  }
25811
25595
  layerToolBinder.bindings.set(key, tool);
25812
25596
  tool.keyBinding = key;
25813
- layerToolBinder.jsonToKey.set(json2, key);
25597
+ layerToolBinder.jsonToKey.set(json, key);
25814
25598
  bindings.set(key, tool);
25815
25599
  layerToolBinder.changed.dispatch();
25816
25600
  }
@@ -26247,9 +26031,9 @@ class AxesLineHelper extends RefCounted {
26247
26031
  constructor(gl) {
26248
26032
  super();
26249
26033
  this.gl = gl;
26250
- 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));
26034
+ 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));
26251
26035
  let alpha = 0.5;
26252
- 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));
26036
+ 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));
26253
26037
  this.trivialColorShader = this.registerDisposer(trivialColorShader(gl));
26254
26038
  }
26255
26039
  static get(gl) {
@@ -45198,8 +44982,8 @@ class StateEditorDialog extends Overlay {
45198
44982
  this.debouncedValueUpdater = debounce(() => {
45199
44983
  const value = this.textEditor.getValue();
45200
44984
  try {
45201
- const json2 = JSON.parse(value);
45202
- this.parsedValue = json2;
44985
+ const json = JSON.parse(value);
44986
+ this.parsedValue = json;
45203
44987
  this.applyButton.disabled = false;
45204
44988
  this.textEditor.setOption("lint", void 0);
45205
44989
  } catch (parseError) {
@@ -45893,92 +45677,6 @@ function encodeFragment(fragment) {
45893
45677
  return "%" + c.charCodeAt(0).toString(16).toUpperCase();
45894
45678
  });
45895
45679
  }
45896
- class UrlHashBinding extends RefCounted {
45897
- constructor(root, credentialsManager, options = {}) {
45898
- super();
45899
- this.root = root;
45900
- this.credentialsManager = credentialsManager;
45901
- this.parseError = new WatchableValue(void 0);
45902
- var _options$updateDelayM = options.updateDelayMilliseconds;
45903
- const updateDelayMilliseconds = _options$updateDelayM === void 0 ? 200 : _options$updateDelayM;
45904
- var _options$defaultFragm = options.defaultFragment;
45905
- const defaultFragment = _options$defaultFragm === void 0 ? "{}" : _options$defaultFragm;
45906
- this.registerEventListener(window, "hashchange", () => this.updateFromUrlHash());
45907
- const throttledSetUrlHash = debounce(() => this.setUrlHash(), updateDelayMilliseconds);
45908
- this.registerDisposer(root.changed.add(throttledSetUrlHash));
45909
- this.registerDisposer(() => throttledSetUrlHash.cancel());
45910
- this.defaultFragment = defaultFragment;
45911
- }
45912
- /**
45913
- * Sets the URL hash to match the current state.
45914
- */
45915
- setUrlHash() {
45916
- const cacheState = getCachedJson(this.root);
45917
- const generation = cacheState.generation;
45918
- if (generation !== this.prevStateGeneration) {
45919
- this.prevStateGeneration = cacheState.generation;
45920
- let stateString = encodeFragment(_JSON$stringify(cacheState.value));
45921
- if (stateString !== this.prevStateString) {
45922
- this.prevStateString = stateString;
45923
- if (decodeURIComponent(stateString) === "{}") {
45924
- history.replaceState(null, "", "#");
45925
- } else {
45926
- history.replaceState(null, "", "#!" + stateString);
45927
- }
45928
- }
45929
- }
45930
- }
45931
- /**
45932
- * Sets the current state to match the URL hash. If it is desired to initialize the state based
45933
- * on the URL hash, then this should be called immediately after construction.
45934
- */
45935
- updateFromUrlHash() {
45936
- try {
45937
- let s = location.href.replace(/^[^#]+/, "");
45938
- if (s === "" || s === "#" || s === "#!") {
45939
- s = "#!" + this.defaultFragment;
45940
- }
45941
- if (s.match(/^#!([a-z][a-z\d+-.]*):\/\//)) {
45942
- const url = s.substring(2);
45943
- var _parseSpecialUrl = parseSpecialUrl(url, this.credentialsManager);
45944
- const parsedUrl = _parseSpecialUrl.url, credentialsProvider = _parseSpecialUrl.credentialsProvider;
45945
- StatusMessage.forPromise(cancellableFetchSpecialOk(credentialsProvider, parsedUrl, {}, responseJson).then((json2) => {
45946
- verifyObject(json2);
45947
- this.root.reset();
45948
- this.root.restoreState(json2);
45949
- }), { initialMessage: `Loading state from ${url}`, errorPrefix: `Error loading state:` });
45950
- } else if (s.startsWith("#!+")) {
45951
- s = s.slice(3);
45952
- s = decodeURIComponent(s);
45953
- let state = urlSafeParse(s);
45954
- verifyObject(state);
45955
- this.root.restoreState(state);
45956
- this.prevStateString = void 0;
45957
- } else if (s.startsWith("#!")) {
45958
- s = s.slice(2);
45959
- s = decodeURIComponent(s);
45960
- if (s === this.prevStateString) {
45961
- return;
45962
- }
45963
- this.prevStateString = s;
45964
- this.root.reset();
45965
- let state = urlSafeParse(s);
45966
- verifyObject(state);
45967
- this.root.restoreState(state);
45968
- } else {
45969
- throw new Error(`URL hash is expected to be of the form "#!{...}" or "#!+{...}".`);
45970
- }
45971
- this.parseError.value = void 0;
45972
- } catch (parseError) {
45973
- this.parseError.value = parseError;
45974
- }
45975
- }
45976
- }
45977
- const url_hash_binding = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
45978
- __proto__: null,
45979
- UrlHashBinding,
45980
- encodeFragment
45981
- }, Symbol.toStringTag, { value: "Module" }));
45982
45680
  class DataManagementContext extends RefCounted {
45983
45681
  constructor(gl, frameNumberCounter, bundleRoot = "") {
45984
45682
  super();
@@ -46623,11 +46321,11 @@ class UserLayer extends RefCounted {
46623
46321
  state.annotationId = void 0;
46624
46322
  state.value = void 0;
46625
46323
  }
46626
- selectionStateFromJson(state, json2) {
46324
+ selectionStateFromJson(state, json) {
46627
46325
  const localCoordinateSpace = state.localCoordinateSpace = this.localCoordinateSpace.value;
46628
46326
  const rank = localCoordinateSpace.rank;
46629
46327
  if (rank !== 0) {
46630
- const localPosition = verifyOptionalObjectProperty(json2, LOCAL_POSITION_JSON_KEY, (positionObj) => parseFixedLengthArray(new Float32Array(rank), positionObj, verifyFiniteFloat));
46328
+ const localPosition = verifyOptionalObjectProperty(json, LOCAL_POSITION_JSON_KEY, (positionObj) => parseFixedLengthArray(new Float32Array(rank), positionObj, verifyFiniteFloat));
46631
46329
  if (localPosition === void 0) {
46632
46330
  state.localPositionValid = false;
46633
46331
  } else {
@@ -46635,36 +46333,36 @@ class UserLayer extends RefCounted {
46635
46333
  state.localPosition = localPosition;
46636
46334
  }
46637
46335
  }
46638
- const annotationId = state.annotationId = verifyOptionalObjectProperty(json2, "annotationId", verifyString);
46336
+ const annotationId = state.annotationId = verifyOptionalObjectProperty(json, "annotationId", verifyString);
46639
46337
  if (annotationId !== void 0) {
46640
- state.annotationSourceIndex = verifyOptionalObjectProperty(json2, "annotationSource", verifyInt, 0);
46641
- state.annotationPartIndex = verifyOptionalObjectProperty(json2, "annotationPart", verifyInt);
46642
- state.annotationSubsource = verifyOptionalObjectProperty(json2, "annotationSubsource", verifyString);
46338
+ state.annotationSourceIndex = verifyOptionalObjectProperty(json, "annotationSource", verifyInt, 0);
46339
+ state.annotationPartIndex = verifyOptionalObjectProperty(json, "annotationPart", verifyInt);
46340
+ state.annotationSubsource = verifyOptionalObjectProperty(json, "annotationSubsource", verifyString);
46643
46341
  }
46644
- state.value = json2.value;
46342
+ state.value = json.value;
46645
46343
  }
46646
46344
  // Derived classes should override.
46647
46345
  displaySelectionState(state, parent, context) {
46648
46346
  return false;
46649
46347
  }
46650
46348
  selectionStateToJson(state, forPython) {
46651
- const json2 = {};
46349
+ const json = {};
46652
46350
  if (state.localPositionValid) {
46653
46351
  const localPosition = state.localPosition;
46654
46352
  if (localPosition.length > 0) {
46655
- json2.localPosition = _Array$from(localPosition);
46353
+ json.localPosition = _Array$from(localPosition);
46656
46354
  }
46657
46355
  }
46658
46356
  if (state.annotationId !== void 0) {
46659
- json2.annotationId = state.annotationId;
46660
- json2.annotationPart = state.annotationPartIndex;
46661
- json2.annotationSource = state.annotationSourceIndex;
46662
- json2.annotationSubsource = state.annotationSubsource;
46357
+ json.annotationId = state.annotationId;
46358
+ json.annotationPart = state.annotationPartIndex;
46359
+ json.annotationSource = state.annotationSourceIndex;
46360
+ json.annotationSubsource = state.annotationSubsource;
46663
46361
  }
46664
46362
  if (state.value != null) {
46665
- json2.value = state.value;
46363
+ json.value = state.value;
46666
46364
  }
46667
- return json2;
46365
+ return json;
46668
46366
  }
46669
46367
  captureSelectionState(state, mouseState) {
46670
46368
  state.localCoordinateSpace = this.localCoordinateSpace.value;
@@ -46866,8 +46564,8 @@ class UserLayer extends RefCounted {
46866
46564
  selectedValueToJson(value) {
46867
46565
  return value;
46868
46566
  }
46869
- selectedValueFromJson(json2) {
46870
- return json2;
46567
+ selectedValueFromJson(json) {
46568
+ return json;
46871
46569
  }
46872
46570
  setLayerPosition(modelTransform, layerPosition) {
46873
46571
  const globalPosition = this.manager.root.globalPosition;
@@ -47404,13 +47102,13 @@ class TrackableDataSelectionState extends RefCounted {
47404
47102
  if (value !== this.value_) {
47405
47103
  this.value_ = value;
47406
47104
  if (value !== void 0 && this.pin.value) {
47407
- const history2 = this.history;
47408
- history2.length = Math.min(history2.length, this.historyIndex + 1);
47409
- history2.push(value);
47410
- if (history2.length > maxSelectionHistorySize) {
47411
- history2.splice(0, history2.length - maxSelectionHistorySize);
47105
+ const history = this.history;
47106
+ history.length = Math.min(history.length, this.historyIndex + 1);
47107
+ history.push(value);
47108
+ if (history.length > maxSelectionHistorySize) {
47109
+ history.splice(0, history.length - maxSelectionHistorySize);
47412
47110
  }
47413
- this.historyIndex = history2.length - 1;
47111
+ this.historyIndex = history.length - 1;
47414
47112
  }
47415
47113
  this.changed.dispatch();
47416
47114
  }
@@ -50719,7 +50417,7 @@ void setBoundingBoxFillColor(vec4 color) {
50719
50417
  class PerspectiveViewRenderHelper extends RenderHelper$4 {
50720
50418
  constructor() {
50721
50419
  super(...arguments);
50722
- this.edgeBoxCornerOffsetsBuffer = this.registerDisposer(Buffer.fromData(this.gl, tile2dArray(
50420
+ this.edgeBoxCornerOffsetsBuffer = this.registerDisposer(Buffer2.fromData(this.gl, tile2dArray(
50723
50421
  edgeBoxCornerOffsetData,
50724
50422
  /*majorDimension=*/
50725
50423
  7,
@@ -50759,7 +50457,7 @@ ${this.setPartIndex(builder, "uint(aBoxCornerOffset2.w)")};
50759
50457
  emitAnnotation(vec4(vColor.rgb, getLineAlpha() * vClipCoefficient));
50760
50458
  `);
50761
50459
  });
50762
- this.boxCornerOffsetsBuffer = this.registerDisposer(Buffer.fromData(this.gl, tile2dArray(
50460
+ this.boxCornerOffsetsBuffer = this.registerDisposer(Buffer2.fromData(this.gl, tile2dArray(
50763
50461
  vertexBasePositions,
50764
50462
  /*majorDimension=*/
50765
50463
  3,
@@ -52255,7 +51953,7 @@ class AnnotationLayer extends RefCounted {
52255
51953
  if (this.generation !== generation) {
52256
51954
  let buffer = this.buffer;
52257
51955
  if (buffer === void 0) {
52258
- buffer = this.buffer = this.registerDisposer(new Buffer(this.chunkManager.gl));
51956
+ buffer = this.buffer = this.registerDisposer(new Buffer2(this.chunkManager.gl));
52259
51957
  }
52260
51958
  this.generation = generation;
52261
51959
  const serializedAnnotations = this.serializedAnnotations = serializeAnnotationSet(source, segmentationFilter(this.segmentationStates.value));
@@ -52382,7 +52080,7 @@ function AnnotationRenderLayer(Base2, renderHelperType) {
52382
52080
  if (!chunk.bufferValid) {
52383
52081
  let buffer = chunk.buffer;
52384
52082
  if (buffer === void 0) {
52385
- buffer = chunk.buffer = new Buffer(this.gl);
52083
+ buffer = chunk.buffer = new Buffer2(this.gl);
52386
52084
  }
52387
52085
  const serializedAnnotations = chunk.serializedAnnotations;
52388
52086
  buffer.setData(serializedAnnotations.data);
@@ -57844,8 +57542,8 @@ class SegmentationUserLayerColorGroupState extends RefCounted {
57844
57542
  let idStr = _ref2[0];
57845
57543
  let colorVec = _ref2[1];
57846
57544
  const id = Uint64.parseString(String(idStr));
57847
- const color2 = new Uint64(packColor(colorVec));
57848
- this.segmentStatedColors.set(id, color2);
57545
+ const color = new Uint64(packColor(colorVec));
57546
+ this.segmentStatedColors.set(id, color);
57849
57547
  }
57850
57548
  });
57851
57549
  }
@@ -58237,8 +57935,8 @@ class SegmentationUserLayer extends Base$2 {
58237
57935
  }
58238
57936
  }
58239
57937
  }
58240
- selectionStateFromJson(state, json2) {
58241
- super.selectionStateFromJson(state, json2);
57938
+ selectionStateFromJson(state, json) {
57939
+ super.selectionStateFromJson(state, json);
58242
57940
  const v = new Uint64();
58243
57941
  let value = state.value;
58244
57942
  if (typeof value === "number") value = value.toString();
@@ -58249,22 +57947,22 @@ class SegmentationUserLayer extends Base$2 {
58249
57947
  }
58250
57948
  }
58251
57949
  selectionStateToJson(state, forPython) {
58252
- const json2 = super.selectionStateToJson(state, forPython);
57950
+ const json = super.selectionStateToJson(state, forPython);
58253
57951
  let value = state.value;
58254
57952
  if (value instanceof Uint64MapEntry) {
58255
57953
  if (forPython) {
58256
- json2.value = {
57954
+ json.value = {
58257
57955
  key: value.key.toString(),
58258
57956
  value: value.value ? value.value.toString() : void 0,
58259
57957
  label: value.label
58260
57958
  };
58261
57959
  } else {
58262
- json2.value = (value.value || value.key).toString();
57960
+ json.value = (value.value || value.key).toString();
58263
57961
  }
58264
57962
  } else if (value instanceof Uint64) {
58265
- json2.value = value.toString();
57963
+ json.value = value.toString();
58266
57964
  }
58267
- return json2;
57965
+ return json;
58268
57966
  }
58269
57967
  displaySegmentationSelection(state, parent, context) {
58270
57968
  const value = state.value;
@@ -58396,14 +58094,6 @@ registerLayerShaderControlsTool(SegmentationUserLayer, (layer) => ({
58396
58094
  }), SKELETON_RENDERING_SHADER_CONTROL_TOOL_ID);
58397
58095
  registerSegmentSplitMergeTools();
58398
58096
  registerSegmentSelectTools();
58399
- const segmentation_user_layer = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
58400
- __proto__: null,
58401
- LAYER_CONTROLS: LAYER_CONTROLS$1,
58402
- SKELETON_RENDERING_SHADER_CONTROL_TOOL_ID,
58403
- SegmentationUserLayer,
58404
- SegmentationUserLayerColorGroupState,
58405
- SegmentationUserLayerGroupState
58406
- }, Symbol.toStringTag, { value: "Module" }));
58407
58097
  /**
58408
58098
  * @license
58409
58099
  * Copyright 2018 Google Inc.
@@ -58598,9 +58288,9 @@ class LinkedSegmentationLayers extends RefCounted {
58598
58288
  [FILTER_BY_SEGMENTATION_JSON_KEY]: filterBySegmentation.length === 0 ? void 0 : filterBySegmentation
58599
58289
  };
58600
58290
  }
58601
- restoreState(json2) {
58291
+ restoreState(json) {
58602
58292
  const isLoading = this.annotationStates.isLoading;
58603
- verifyOptionalObjectProperty(json2, LINKED_SEGMENTATION_LAYER_JSON_KEY, (linkedJson) => {
58293
+ verifyOptionalObjectProperty(json, LINKED_SEGMENTATION_LAYER_JSON_KEY, (linkedJson) => {
58604
58294
  if (typeof linkedJson === "string") {
58605
58295
  linkedJson = { "segments": linkedJson };
58606
58296
  }
@@ -58623,7 +58313,7 @@ class LinkedSegmentationLayers extends RefCounted {
58623
58313
  }
58624
58314
  }
58625
58315
  });
58626
- verifyOptionalObjectProperty(json2, FILTER_BY_SEGMENTATION_JSON_KEY, (filterJson) => {
58316
+ verifyOptionalObjectProperty(json, FILTER_BY_SEGMENTATION_JSON_KEY, (filterJson) => {
58627
58317
  if (typeof filterJson === "boolean") {
58628
58318
  filterJson = filterJson === true ? ["segments"] : [];
58629
58319
  }
@@ -58973,14 +58663,6 @@ registerLayerTypeDetector((subsource) => {
58973
58663
  registerLayerShaderControlsTool(AnnotationUserLayer, (layer) => ({
58974
58664
  shaderControlState: layer.annotationDisplayState.shaderControls
58975
58665
  }));
58976
- const user_layer = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
58977
- __proto__: null,
58978
- AnnotationUserLayer
58979
- }, Symbol.toStringTag, { value: "Module" }));
58980
- const require$$2 = /* @__PURE__ */ getAugmentedNamespace(user_layer);
58981
- const require$$3 = /* @__PURE__ */ getAugmentedNamespace(frontend);
58982
- const require$$4 = /* @__PURE__ */ getAugmentedNamespace(segmentation_user_layer);
58983
- const require$$5 = /* @__PURE__ */ getAugmentedNamespace(color);
58984
58666
  function bindDefaultCopyHandler(viewer) {
58985
58667
  viewer.registerEventListener(document, "copy", (event) => {
58986
58668
  if (isInputTextTarget(event.target)) {
@@ -60482,7 +60164,7 @@ async function getAnnotationChunkSource$1(options, sourceParameters, dataInstanc
60482
60164
  let multiscaleVolumeInfo = new MultiscaleVolumeInfo$1(dataInstanceInfo.volumeInfo);
60483
60165
  return getChunkSource(multiscaleVolumeInfo, sourceParameters);
60484
60166
  }
60485
- async function getAnnotationSource$1(options, sourceParameters, dataInstanceInfo, credentialsProvider) {
60167
+ async function getAnnotationSource$2(options, sourceParameters, dataInstanceInfo, credentialsProvider) {
60486
60168
  const box2 = {
60487
60169
  lowerBounds: new Float64Array(dataInstanceInfo.lowerVoxelBound),
60488
60170
  upperBounds: Float64Array.from(dataInstanceInfo.upperVoxelBound)
@@ -60608,7 +60290,7 @@ function getDataSource$1(options) {
60608
60290
  max: 1,
60609
60291
  step: 0.01
60610
60292
  }];
60611
- return getAnnotationSource$1(options, annotationSourceParameters, dataInstanceInfo, credentialsProvider);
60293
+ return getAnnotationSource$2(options, annotationSourceParameters, dataInstanceInfo, credentialsProvider);
60612
60294
  } else {
60613
60295
  if (!(dataInstanceInfo instanceof VolumeDataInstanceInfo)) {
60614
60296
  throw new Error(`Invalid data instance ${dataInstanceKey}.`);
@@ -61650,7 +61332,7 @@ async function getAnnotationChunkSource(options, sourceParameters, dataInfo, cre
61650
61332
  });
61651
61333
  return getChunkSource(dataInfo, sourceParameters);
61652
61334
  }
61653
- async function getAnnotationSource(options, sourceParameters, credentialsProvider) {
61335
+ async function getAnnotationSource$1(options, sourceParameters, credentialsProvider) {
61654
61336
  const dataInfo = await getAnnotationDataInfo(sourceParameters);
61655
61337
  const box2 = {
61656
61338
  lowerBounds: new Float64Array(dataInfo.lowerVoxelBound),
@@ -61762,7 +61444,7 @@ async function getDataSource(options, getCredentialsProvider) {
61762
61444
  step: 1
61763
61445
  }];
61764
61446
  const credentialsProvider = getCredentialsProvider(sourceParameters.authServer);
61765
- return getAnnotationSource(options, annotationSourceParameters, credentialsProvider);
61447
+ return getAnnotationSource$1(options, annotationSourceParameters, credentialsProvider);
61766
61448
  });
61767
61449
  }
61768
61450
  async function completeHttpPath$1(_1) {
@@ -64382,9 +64064,9 @@ class MultiscaleVolumeChunkSource4 extends MultiscaleVolumeChunkSource$3 {
64382
64064
  function getAttributes(chunkManager, credentialsProvider, url) {
64383
64065
  return chunkManager.memoize.getUncounted({ type: "zarr:.zattrs json", url, credentialsProvider: getObjectId(credentialsProvider) }, async () => {
64384
64066
  try {
64385
- const json2 = await cancellableFetchSpecialOk(credentialsProvider, url + "/.zattrs", {}, responseJson);
64386
- verifyObject(json2);
64387
- return json2;
64067
+ const json = await cancellableFetchSpecialOk(credentialsProvider, url + "/.zattrs", {}, responseJson);
64068
+ verifyObject(json);
64069
+ return json;
64388
64070
  } catch (e) {
64389
64071
  if (isNotFoundError(e)) return {};
64390
64072
  throw e;
@@ -64393,8 +64075,8 @@ function getAttributes(chunkManager, credentialsProvider, url) {
64393
64075
  }
64394
64076
  function getMetadata(chunkManager, credentialsProvider, url) {
64395
64077
  return chunkManager.memoize.getUncounted({ type: "zarr:.zarray json", url, credentialsProvider: getObjectId(credentialsProvider) }, async () => {
64396
- const json2 = await cancellableFetchSpecialOk(credentialsProvider, url + "/.zarray", {}, responseJson);
64397
- return parseZarrMetadata(json2);
64078
+ const json = await cancellableFetchSpecialOk(credentialsProvider, url + "/.zarray", {}, responseJson);
64079
+ return parseZarrMetadata(json);
64398
64080
  });
64399
64081
  }
64400
64082
  const supportedQueryParameters = [{
@@ -65376,860 +65058,613 @@ function setupDefaultViewer(options) {
65376
65058
  disableContextMenu(options.target);
65377
65059
  return viewer;
65378
65060
  }
65379
- class Neuroglancer {
65380
- version() {
65381
- return "0.0.1";
65382
- }
65383
- }
65384
- const main_module = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
65385
- __proto__: null,
65386
- default: Neuroglancer,
65387
- setupDefaultViewer
65388
- }, Symbol.toStringTag, { value: "Module" }));
65389
- const require$$6 = /* @__PURE__ */ getAugmentedNamespace(main_module);
65390
- const require$$7 = /* @__PURE__ */ getAugmentedNamespace(uint64);
65391
- const require$$8 = /* @__PURE__ */ getAugmentedNamespace(json);
65392
- const require$$9 = /* @__PURE__ */ getAugmentedNamespace(url_hash_binding);
65393
- var hasRequiredLib;
65394
- function requireLib() {
65395
- if (hasRequiredLib) return lib;
65396
- hasRequiredLib = 1;
65397
- (function(exports) {
65398
- function _typeof(obj) {
65399
- "@babel/helpers - typeof";
65400
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
65401
- _typeof = function _typeof2(obj2) {
65402
- return typeof obj2;
65403
- };
65404
- } else {
65405
- _typeof = function _typeof2(obj2) {
65406
- return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
65407
- };
65408
- }
65409
- return _typeof(obj);
65410
- }
65411
- Object.defineProperty(exports, "__esModule", {
65412
- value: true
65413
- });
65414
- exports.parseUrlHash = parseUrlHash;
65415
- exports.getNeuroglancerViewerState = getNeuroglancerViewerState;
65416
- exports.getNeuroglancerColor = getNeuroglancerColor;
65417
- exports.closeSelectionTab = closeSelectionTab;
65418
- exports.getLayerManager = getLayerManager;
65419
- exports.getManagedLayer = getManagedLayer;
65420
- exports.getAnnotationLayer = getAnnotationLayer;
65421
- exports.getAnnotationSource = getAnnotationSource2;
65422
- exports.addLayerSignalRemover = addLayerSignalRemover;
65423
- exports.unsubscribeLayersChangedSignals = unsubscribeLayersChangedSignals;
65424
- exports.configureLayersChangedSignals = configureLayersChangedSignals;
65425
- exports.configureAnnotationLayer = configureAnnotationLayer;
65426
- exports.configureAnnotationLayerChanged = configureAnnotationLayerChanged;
65427
- exports.getAnnotationSelectionHost = getAnnotationSelectionHost;
65428
- exports.getSelectedAnnotationId = getSelectedAnnotationId;
65429
- exports["default"] = void 0;
65430
- var _react = _interopRequireDefault(React__default);
65431
- var _propTypes = _interopRequireDefault(/* @__PURE__ */ requirePropTypes());
65432
- var _user_layer = require$$2;
65433
- var _frontend = require$$3;
65434
- var _segmentation_user_layer = require$$4;
65435
- var _color = require$$5;
65436
- var _neuroglancer = require$$6;
65437
- var _uint = require$$7;
65438
- var _json = require$$8;
65439
- var _url_hash_binding = require$$9;
65440
- function _interopRequireDefault(obj) {
65441
- return obj && obj.__esModule ? obj : { "default": obj };
65442
- }
65443
- function ownKeys(object, enumerableOnly) {
65444
- var keys2 = Object.keys(object);
65445
- if (Object.getOwnPropertySymbols) {
65446
- var symbols = Object.getOwnPropertySymbols(object);
65447
- if (enumerableOnly) symbols = symbols.filter(function(sym) {
65448
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65449
- });
65450
- keys2.push.apply(keys2, symbols);
65451
- }
65452
- return keys2;
65453
- }
65454
- function _objectSpread(target) {
65455
- for (var i = 1; i < arguments.length; i++) {
65456
- var source = arguments[i] != null ? arguments[i] : {};
65457
- if (i % 2) {
65458
- ownKeys(Object(source), true).forEach(function(key) {
65459
- _defineProperty(target, key, source[key]);
65460
- });
65461
- } else if (Object.getOwnPropertyDescriptors) {
65462
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
65463
- } else {
65464
- ownKeys(Object(source)).forEach(function(key) {
65465
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
65466
- });
65061
+ const GREY_HEX = "#323232";
65062
+ const viewersKeyed = {};
65063
+ let viewerNoKey;
65064
+ function parseUrlHash(url) {
65065
+ let state = null;
65066
+ let s = url.replace(/^[^#]+/, "");
65067
+ if (s === "" || s === "#" || s === "#!") {
65068
+ s = "#!{}";
65069
+ }
65070
+ if (s.startsWith("#!+")) {
65071
+ s = s.slice(3);
65072
+ s = decodeURIComponent(s);
65073
+ state = urlSafeParse(s);
65074
+ } else if (s.startsWith("#!")) {
65075
+ s = s.slice(2);
65076
+ s = decodeURIComponent(s);
65077
+ state = urlSafeParse(s);
65078
+ } else {
65079
+ throw new Error("URL hash is expected to be of the form '#!{...}' or '#!+{...}'.");
65080
+ }
65081
+ return state;
65082
+ }
65083
+ function getNeuroglancerViewerState(key) {
65084
+ const v = key ? viewersKeyed[key] : viewerNoKey;
65085
+ return v ? v.state.toJSON() : {};
65086
+ }
65087
+ function getNeuroglancerColor(idStr, key) {
65088
+ try {
65089
+ const id = Uint64.parseString(idStr);
65090
+ const v = key ? viewersKeyed[key] : viewerNoKey;
65091
+ if (v) {
65092
+ for (const layer of v.layerManager.managedLayers) {
65093
+ if (layer.layer instanceof SegmentationUserLayer) {
65094
+ const { displayState } = layer.layer;
65095
+ const colorVec = getObjectColor(displayState, id);
65096
+ if (displayState.segmentSelectionState.isSelected(id)) {
65097
+ for (let i = 0; i < 3; i += 1) {
65098
+ colorVec[i] = (colorVec[i] - 0.5) / 0.5;
65099
+ }
65100
+ }
65101
+ const colorStr = serializeColor(colorVec);
65102
+ return colorStr;
65467
65103
  }
65468
65104
  }
65469
- return target;
65470
65105
  }
65471
- function _classCallCheck(instance, Constructor) {
65472
- if (!(instance instanceof Constructor)) {
65473
- throw new TypeError("Cannot call a class as a function");
65474
- }
65106
+ } catch {
65107
+ }
65108
+ return "";
65109
+ }
65110
+ function closeSelectionTab(key) {
65111
+ const v = key ? viewersKeyed[key] : viewerNoKey;
65112
+ if (v && v.closeSelectionTab) {
65113
+ v.closeSelectionTab();
65114
+ }
65115
+ }
65116
+ function getLayerManager(key) {
65117
+ const v = key ? viewersKeyed[key] : viewerNoKey;
65118
+ if (v) {
65119
+ return v.layerManager;
65120
+ }
65121
+ return void 0;
65122
+ }
65123
+ function getManagedLayer(key, name2) {
65124
+ const layerManager = getLayerManager(key);
65125
+ if (layerManager) {
65126
+ return layerManager.managedLayers.filter((layer) => layer.name === name2)[0];
65127
+ }
65128
+ return void 0;
65129
+ }
65130
+ function getAnnotationLayer(key, name2) {
65131
+ const layer = getManagedLayer(key, name2);
65132
+ if (layer && layer.layer instanceof AnnotationUserLayer) {
65133
+ return layer.layer;
65134
+ }
65135
+ return void 0;
65136
+ }
65137
+ function getAnnotationSource(key, name2) {
65138
+ const layer = getAnnotationLayer(key, name2);
65139
+ if (layer && layer.dataSources && layer.dataSources[0].loadState_) {
65140
+ const { dataSource } = layer.dataSources[0].loadState_;
65141
+ if (dataSource) {
65142
+ return dataSource.subsources[0].subsource.annotation;
65475
65143
  }
65476
- function _defineProperties(target, props) {
65477
- for (var i = 0; i < props.length; i++) {
65478
- var descriptor = props[i];
65479
- descriptor.enumerable = descriptor.enumerable || false;
65480
- descriptor.configurable = true;
65481
- if ("value" in descriptor) descriptor.writable = true;
65482
- Object.defineProperty(target, descriptor.key, descriptor);
65483
- }
65144
+ }
65145
+ return void 0;
65146
+ }
65147
+ function addLayerSignalRemover(key, name2, remover) {
65148
+ const layerManager = getLayerManager(key);
65149
+ if (layerManager && name2 && remover) {
65150
+ if (!layerManager.customSignalHandlerRemovers) {
65151
+ layerManager.customSignalHandlerRemovers = {};
65484
65152
  }
65485
- function _createClass(Constructor, protoProps, staticProps) {
65486
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
65487
- return Constructor;
65153
+ if (!layerManager.customSignalHandlerRemovers[name2]) {
65154
+ layerManager.customSignalHandlerRemovers[name2] = [];
65488
65155
  }
65489
- function _inherits(subClass, superClass) {
65490
- if (typeof superClass !== "function" && superClass !== null) {
65491
- throw new TypeError("Super expression must either be null or a function");
65156
+ layerManager.customSignalHandlerRemovers[name2].push(remover);
65157
+ }
65158
+ }
65159
+ function unsubscribeLayersChangedSignals(layerManager, signalKey) {
65160
+ if (layerManager) {
65161
+ if (layerManager.customSignalHandlerRemovers) {
65162
+ if (layerManager.customSignalHandlerRemovers[signalKey]) {
65163
+ layerManager.customSignalHandlerRemovers[signalKey].forEach((remover) => {
65164
+ remover();
65165
+ });
65166
+ delete layerManager.customSignalHandlerRemovers[signalKey];
65492
65167
  }
65493
- subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
65494
- if (superClass) _setPrototypeOf(subClass, superClass);
65495
65168
  }
65496
- function _setPrototypeOf(o, p) {
65497
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
65498
- o2.__proto__ = p2;
65499
- return o2;
65500
- };
65501
- return _setPrototypeOf(o, p);
65502
- }
65503
- function _createSuper(Derived) {
65504
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
65505
- return function _createSuperInternal() {
65506
- var Super = _getPrototypeOf(Derived), result;
65507
- if (hasNativeReflectConstruct) {
65508
- var NewTarget = _getPrototypeOf(this).constructor;
65509
- result = Reflect.construct(Super, arguments, NewTarget);
65510
- } else {
65511
- result = Super.apply(this, arguments);
65169
+ }
65170
+ }
65171
+ function configureLayersChangedSignals(key, layerConfig) {
65172
+ const layerManager = getLayerManager(key);
65173
+ if (layerManager) {
65174
+ const { layerName } = layerConfig;
65175
+ unsubscribeLayersChangedSignals(layerManager, layerName);
65176
+ if (layerConfig.process) {
65177
+ const recordRemover = (remover) => addLayerSignalRemover(void 0, layerName, remover);
65178
+ recordRemover(layerManager.layersChanged.add(() => {
65179
+ const layer2 = getManagedLayer(void 0, layerName);
65180
+ if (layer2) {
65181
+ layerConfig.process(layer2);
65512
65182
  }
65513
- return _possibleConstructorReturn(this, result);
65514
- };
65515
- }
65516
- function _possibleConstructorReturn(self2, call) {
65517
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
65518
- return call;
65183
+ }));
65184
+ const layer = getManagedLayer(void 0, layerName);
65185
+ if (layer) {
65186
+ layerConfig.process(layer);
65519
65187
  }
65520
- return _assertThisInitialized(self2);
65188
+ return () => {
65189
+ if (layerConfig.cancel) {
65190
+ layerConfig.cancel();
65191
+ }
65192
+ unsubscribeLayersChangedSignals(layerManager, layerName);
65193
+ };
65521
65194
  }
65522
- function _assertThisInitialized(self2) {
65523
- if (self2 === void 0) {
65524
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
65525
- }
65526
- return self2;
65195
+ }
65196
+ return layerConfig.cancel;
65197
+ }
65198
+ function configureAnnotationSource(source, props, recordRemover) {
65199
+ if (source && !source.signalReady) {
65200
+ if (props.onAnnotationAdded) {
65201
+ recordRemover(source.childAdded.add((annotation) => {
65202
+ props.onAnnotationAdded(annotation);
65203
+ }));
65527
65204
  }
65528
- function _isNativeReflectConstruct() {
65529
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
65530
- if (Reflect.construct.sham) return false;
65531
- if (typeof Proxy === "function") return true;
65532
- try {
65533
- Date.prototype.toString.call(Reflect.construct(Date, [], function() {
65534
- }));
65535
- return true;
65536
- } catch (e) {
65537
- return false;
65538
- }
65205
+ if (props.onAnnotationDeleted) {
65206
+ recordRemover(source.childDeleted.add((id) => {
65207
+ props.onAnnotationDeleted(id);
65208
+ }));
65539
65209
  }
65540
- function _getPrototypeOf(o) {
65541
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
65542
- return o2.__proto__ || Object.getPrototypeOf(o2);
65543
- };
65544
- return _getPrototypeOf(o);
65210
+ if (props.onAnnotationUpdated) {
65211
+ recordRemover(source.childUpdated.add((annotation) => {
65212
+ props.onAnnotationUpdated(annotation);
65213
+ }));
65545
65214
  }
65546
- function _defineProperty(obj, key, value) {
65547
- if (key in obj) {
65548
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
65549
- } else {
65550
- obj[key] = value;
65551
- }
65552
- return obj;
65215
+ if (props.onAnnotationChanged && source.referencesChanged) {
65216
+ recordRemover(source.referencesChanged.add(props.onAnnotationChanged));
65553
65217
  }
65554
- function _createForOfIteratorHelper(o, allowArrayLike) {
65555
- var it;
65556
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
65557
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) {
65558
- if (it) o = it;
65559
- var i = 0;
65560
- var F = function F2() {
65561
- };
65562
- return { s: F, n: function n() {
65563
- if (i >= o.length) return { done: true };
65564
- return { done: false, value: o[i++] };
65565
- }, e: function e(_e) {
65566
- throw _e;
65567
- }, f: F };
65568
- }
65569
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
65570
- }
65571
- var normalCompletion = true, didErr = false, err;
65572
- return { s: function s() {
65573
- it = o[Symbol.iterator]();
65574
- }, n: function n() {
65575
- var step = it.next();
65576
- normalCompletion = step.done;
65577
- return step;
65578
- }, e: function e(_e2) {
65579
- didErr = true;
65580
- err = _e2;
65581
- }, f: function f() {
65582
- try {
65583
- if (!normalCompletion && it["return"] != null) it["return"]();
65584
- } finally {
65585
- if (didErr) throw err;
65586
- }
65587
- } };
65218
+ source.signalReady = true;
65219
+ recordRemover(() => {
65220
+ source.signalReady = false;
65221
+ });
65222
+ }
65223
+ }
65224
+ function getLoadedDataSource(layer) {
65225
+ if (layer.dataSources && layer.dataSources.length > 0 && layer.dataSources[0].loadState_ && layer.dataSources[0].loadState_.dataSource) {
65226
+ return layer.dataSources[0].loadState_.dataSource;
65227
+ }
65228
+ }
65229
+ function getAnnotationSourceFromLayer(layer) {
65230
+ const dataSource = getLoadedDataSource(layer);
65231
+ if (dataSource) {
65232
+ return dataSource.subsources[0].subsource.annotation;
65233
+ }
65234
+ }
65235
+ function configureAnnotationSourceChange(annotationLayer, props, recordRemover) {
65236
+ const configure = () => {
65237
+ const source = getAnnotationSourceFromLayer(annotationLayer);
65238
+ if (source) {
65239
+ configureAnnotationSource(source, props, recordRemover);
65588
65240
  }
65589
- function _unsupportedIterableToArray(o, minLen) {
65590
- if (!o) return;
65591
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
65592
- var n = Object.prototype.toString.call(o).slice(8, -1);
65593
- if (n === "Object" && o.constructor) n = o.constructor.name;
65594
- if (n === "Map" || n === "Set") return Array.from(o);
65595
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
65596
- }
65597
- function _arrayLikeToArray(arr, len2) {
65598
- if (len2 == null || len2 > arr.length) len2 = arr.length;
65599
- for (var i = 0, arr2 = new Array(len2); i < len2; i++) {
65600
- arr2[i] = arr[i];
65601
- }
65602
- return arr2;
65603
- }
65604
- var viewersKeyed = {};
65605
- var viewerNoKey;
65606
- function parseUrlHash(url) {
65607
- var state = null;
65608
- var s = url.replace(/^[^#]+/, "");
65609
- if (s === "" || s === "#" || s === "#!") {
65610
- s = "#!{}";
65611
- }
65612
- if (s.startsWith("#!+")) {
65613
- s = s.slice(3);
65614
- s = decodeURIComponent(s);
65615
- state = (0, _json.urlSafeParse)(s);
65616
- } else if (s.startsWith("#!")) {
65617
- s = s.slice(2);
65618
- s = decodeURIComponent(s);
65619
- state = (0, _json.urlSafeParse)(s);
65620
- } else {
65621
- throw new Error('URL hash is expected to be of the form "#!{...}" or "#!+{...}".');
65241
+ };
65242
+ const sourceChanged = annotationLayer.dataSourcesChanged;
65243
+ if (sourceChanged && !sourceChanged.signalReady) {
65244
+ recordRemover(sourceChanged.add(configure));
65245
+ sourceChanged.signalReady = true;
65246
+ recordRemover(() => {
65247
+ sourceChanged.signalReady = false;
65248
+ });
65249
+ configure();
65250
+ }
65251
+ }
65252
+ function configureAnnotationLayer(layer, props, recordRemover) {
65253
+ if (layer) {
65254
+ layer.expectingExternalTable = true;
65255
+ if (layer.selectedAnnotation && !layer.selectedAnnotation.changed.signalReady) {
65256
+ if (props.onAnnotationSelectionChanged) {
65257
+ recordRemover(layer.selectedAnnotation.changed.add(() => {
65258
+ props.onAnnotationSelectionChanged(layer.selectedAnnotation.value);
65259
+ }));
65260
+ recordRemover(() => {
65261
+ layer.selectedAnnotation.changed.signalReady = false;
65262
+ });
65263
+ layer.selectedAnnotation.changed.signalReady = true;
65622
65264
  }
65623
- return state;
65624
65265
  }
65625
- function getNeuroglancerViewerState(key) {
65626
- var v = key ? viewersKeyed[key] : viewerNoKey;
65627
- return v ? v.state.toJSON() : {};
65266
+ configureAnnotationSourceChange(layer, props, recordRemover);
65267
+ }
65268
+ }
65269
+ function configureAnnotationLayerChanged(layer, props, recordRemover) {
65270
+ if (!layer.layerChanged.signalReady) {
65271
+ const remover = layer.layerChanged.add(() => {
65272
+ configureAnnotationLayer(layer.layer, props, recordRemover);
65273
+ });
65274
+ layer.layerChanged.signalReady = true;
65275
+ recordRemover(remover);
65276
+ recordRemover(() => {
65277
+ layer.layerChanged.signalReady = false;
65278
+ });
65279
+ configureAnnotationLayer(layer.layer, props, recordRemover);
65280
+ }
65281
+ }
65282
+ function getAnnotationSelectionHost(key) {
65283
+ const viewer = key ? viewersKeyed[key] : viewerNoKey;
65284
+ if (viewer) {
65285
+ if (viewer.selectionDetailsState) {
65286
+ return "viewer";
65628
65287
  }
65629
- function getNeuroglancerColor(idStr, key) {
65630
- try {
65631
- var id = _uint.Uint64.parseString(idStr);
65632
- var v = key ? viewersKeyed[key] : viewerNoKey;
65633
- if (v) {
65634
- var _iterator = _createForOfIteratorHelper(v.layerManager.managedLayers), _step;
65635
- try {
65636
- for (_iterator.s(); !(_step = _iterator.n()).done; ) {
65637
- var layer = _step.value;
65638
- if (layer.layer instanceof _segmentation_user_layer.SegmentationUserLayer) {
65639
- var displayState = layer.layer.displayState;
65640
- var colorVec = (0, _frontend.getObjectColor)(displayState, id);
65641
- if (displayState.segmentSelectionState.isSelected(id)) {
65642
- for (var i = 0; i < 3; i += 1) {
65643
- colorVec[i] = (colorVec[i] - 0.5) / 0.5;
65644
- }
65645
- }
65646
- var colorStr = (0, _color.serializeColor)(colorVec);
65647
- return colorStr;
65648
- }
65649
- }
65650
- } catch (err) {
65651
- _iterator.e(err);
65652
- } finally {
65653
- _iterator.f();
65288
+ return "layer";
65289
+ }
65290
+ return null;
65291
+ }
65292
+ function getSelectedAnnotationId(key, layerName) {
65293
+ const viewer = key ? viewersKeyed[key] : viewerNoKey;
65294
+ if (viewer) {
65295
+ if (viewer.selectionDetailsState) {
65296
+ if (viewer.selectionDetailsState.value) {
65297
+ const { layers } = viewer.selectionDetailsState.value;
65298
+ if (layers) {
65299
+ const layer = layers.find((_layer) => _layer.layer.managedLayer.name === layerName);
65300
+ if (layer && layer.state) {
65301
+ return layer.state.annotationId;
65654
65302
  }
65655
65303
  }
65656
- } catch (_unused) {
65657
- }
65658
- return "";
65659
- }
65660
- function closeSelectionTab(key) {
65661
- var v = key ? viewersKeyed[key] : viewerNoKey;
65662
- if (v && v.closeSelectionTab) {
65663
- v.closeSelectionTab();
65664
65304
  }
65665
- }
65666
- function getLayerManager(key) {
65667
- var v = key ? viewersKeyed[key] : viewerNoKey;
65668
- if (v) {
65669
- return v.layerManager;
65670
- }
65671
- return void 0;
65672
- }
65673
- function getManagedLayer(key, name2) {
65674
- var layerManager = getLayerManager(key);
65675
- if (layerManager) {
65676
- return layerManager.managedLayers.filter(function(layer) {
65677
- return layer.name === name2;
65678
- })[0];
65679
- }
65680
- return void 0;
65681
- }
65682
- function getAnnotationLayer(key, name2) {
65683
- var layer = getManagedLayer(key, name2);
65684
- if (layer && layer.layer instanceof _user_layer.AnnotationUserLayer) {
65685
- return layer.layer;
65686
- }
65687
- return void 0;
65688
- }
65689
- function getAnnotationSource2(key, name2) {
65690
- var layer = getAnnotationLayer(key, name2);
65691
- if (layer && layer.dataSources && layer.dataSources[0].loadState_) {
65692
- var dataSource = layer.dataSources[0].loadState_.dataSource;
65693
- if (dataSource) {
65694
- return dataSource.subsources[0].subsource.annotation;
65695
- }
65305
+ } else {
65306
+ const layer = getAnnotationLayer(void 0, layerName);
65307
+ if (layer && layer.selectedAnnotation && layer.selectedAnnotation.value) {
65308
+ return layer.selectedAnnotation.value.id;
65696
65309
  }
65697
- return void 0;
65698
65310
  }
65699
- function addLayerSignalRemover(key, name2, remover) {
65700
- var layerManager = getLayerManager(key);
65701
- if (layerManager && name2 && remover) {
65702
- if (!layerManager.customSignalHandlerRemovers) {
65703
- layerManager.customSignalHandlerRemovers = {};
65704
- }
65705
- if (!layerManager.customSignalHandlerRemovers[name2]) {
65706
- layerManager.customSignalHandlerRemovers[name2] = [];
65707
- }
65708
- layerManager.customSignalHandlerRemovers[name2].push(remover);
65311
+ }
65312
+ return null;
65313
+ }
65314
+ class Neuroglancer extends React__default.Component {
65315
+ constructor(props) {
65316
+ super(props);
65317
+ __publicField(this, "minimalPoseSnapshot", () => {
65318
+ const v = this.viewer;
65319
+ const projScale = v.projectionScale?.value;
65320
+ const projQuat = v.projectionOrientation?.orientation;
65321
+ return {
65322
+ position: Array.from(v.position.value || []),
65323
+ projectionScale: projScale,
65324
+ projectionOrientation: Array.from(projQuat || [])
65325
+ };
65326
+ });
65327
+ // Coalesce many NG changes → one upstream update per frame.
65328
+ __publicField(this, "scheduleEmit", () => {
65329
+ let raf = null;
65330
+ return () => {
65331
+ if (this.muteViewerChanged)
65332
+ return;
65333
+ if (raf !== null)
65334
+ return;
65335
+ raf = requestAnimationFrame(() => {
65336
+ raf = null;
65337
+ this.props.onViewerStateChanged?.(this.minimalPoseSnapshot());
65338
+ });
65339
+ };
65340
+ });
65341
+ // Guard to mute outgoing emits we are programmatically making changes
65342
+ __publicField(this, "withoutEmitting", (fn) => {
65343
+ this.muteViewerChanged = true;
65344
+ try {
65345
+ fn();
65346
+ } finally {
65347
+ requestAnimationFrame(() => {
65348
+ this.muteViewerChanged = false;
65349
+ });
65709
65350
  }
65710
- }
65711
- function unsubscribeLayersChangedSignals(layerManager, signalKey) {
65712
- if (layerManager) {
65713
- if (layerManager.customSignalHandlerRemovers) {
65714
- if (layerManager.customSignalHandlerRemovers[signalKey]) {
65715
- layerManager.customSignalHandlerRemovers[signalKey].forEach(function(remover) {
65716
- remover();
65717
- });
65718
- delete layerManager.customSignalHandlerRemovers[signalKey];
65351
+ });
65352
+ // Only consider actual changes in camera settings, i.e., position/rotation/zoom
65353
+ __publicField(this, "didLayersChange", (prevVS, nextVS) => {
65354
+ const stripColors = (layers) => (layers || []).map((l) => {
65355
+ if (!l)
65356
+ return l;
65357
+ const { segmentColors, ...rest } = l;
65358
+ return rest;
65359
+ });
65360
+ const prevLayers = stripColors(prevVS?.layers);
65361
+ const nextLayers = stripColors(nextVS?.layers);
65362
+ return JSON.stringify(prevLayers) !== JSON.stringify(nextLayers);
65363
+ });
65364
+ /* To add colors to the segments, turning unselected to grey */
65365
+ __publicField(this, "applyColorsAndVisibility", (cellColorMapping) => {
65366
+ if (!this.viewer)
65367
+ return;
65368
+ const selected = { ...cellColorMapping || {} };
65369
+ for (const id of Object.keys(selected))
65370
+ this.allKnownIds.add(id);
65371
+ if (this.allKnownIds.size === 0) {
65372
+ const init = this.props.viewerState?.layers?.[0]?.segmentColors || {};
65373
+ for (const id of Object.keys(init))
65374
+ this.allKnownIds.add(id);
65375
+ }
65376
+ const fullSegmentColors = {};
65377
+ for (const id of this.allKnownIds) {
65378
+ fullSegmentColors[id] = selected[id] || GREY_HEX;
65379
+ }
65380
+ const baseLayers = this.props.viewerState?.layers ?? (this.viewer.state.toJSON().layers || []);
65381
+ const newLayers = baseLayers.map((layer, idx) => {
65382
+ if (idx === 0 || layer?.type === "segmentation") {
65383
+ return { ...layer, segmentColors: fullSegmentColors };
65384
+ }
65385
+ return layer;
65386
+ });
65387
+ this.withoutEmitting(() => {
65388
+ this.viewer.state.restoreState({ layers: newLayers });
65389
+ });
65390
+ });
65391
+ __publicField(this, "updateEventBindings", (eventBindingsToUpdate) => {
65392
+ const root = this.viewer.inputEventBindings;
65393
+ const traverse = (current) => {
65394
+ const replace = (eaMap, event0, event1) => {
65395
+ const action = eaMap.get(event0);
65396
+ if (action) {
65397
+ eaMap.delete(event0);
65398
+ if (event1) {
65399
+ eaMap.set(event1, action);
65400
+ }
65719
65401
  }
65402
+ };
65403
+ const eventActionMap = current.bindings;
65404
+ eventBindingsToUpdate.forEach((oldNewBinding) => {
65405
+ const eventOldBase = Array.isArray(oldNewBinding) ? oldNewBinding[0] : oldNewBinding;
65406
+ const eventOldA = `at:${eventOldBase}`;
65407
+ const eventNewA = oldNewBinding[1] ? `at:${oldNewBinding[1]}` : void 0;
65408
+ replace(eventActionMap, eventOldA, eventNewA);
65409
+ const eventOldB = `bubble:${eventOldBase}`;
65410
+ const eventNewB = oldNewBinding[1] ? `bubble:${oldNewBinding[1]}` : void 0;
65411
+ replace(eventActionMap, eventOldB, eventNewB);
65412
+ });
65413
+ current.parents.forEach((parent) => {
65414
+ traverse(parent);
65415
+ });
65416
+ };
65417
+ traverse(root.global);
65418
+ traverse(root.perspectiveView);
65419
+ traverse(root.sliceView);
65420
+ });
65421
+ __publicField(this, "selectionDetailsStateChanged", () => {
65422
+ if (this.viewer) {
65423
+ const { onSelectionDetailsStateChanged } = this.props;
65424
+ if (onSelectionDetailsStateChanged) {
65425
+ onSelectionDetailsStateChanged();
65720
65426
  }
65721
65427
  }
65722
- }
65723
- function configureLayersChangedSignals(key, layerConfig) {
65724
- var layerManager = getLayerManager(key);
65725
- if (layerManager) {
65726
- var layerName = layerConfig.layerName;
65727
- unsubscribeLayersChangedSignals(layerManager, layerName);
65728
- if (layerConfig.process) {
65729
- var recordRemover = function recordRemover2(remover) {
65730
- return addLayerSignalRemover(void 0, layerName, remover);
65731
- };
65732
- recordRemover(layerManager.layersChanged.add(function() {
65733
- var layer2 = getManagedLayer(void 0, layerName);
65734
- if (layer2) {
65735
- layerConfig.process(layer2);
65428
+ });
65429
+ __publicField(this, "layersChanged", () => {
65430
+ if (this.handlerRemovers) {
65431
+ this.handlerRemovers.forEach((remover) => remover());
65432
+ }
65433
+ if (this.viewer) {
65434
+ const { onSelectedChanged, onVisibleChanged } = this.props;
65435
+ if (onSelectedChanged || onVisibleChanged) {
65436
+ this.handlerRemovers = [];
65437
+ for (const layer of this.viewer.layerManager.managedLayers) {
65438
+ if (layer.layer instanceof SegmentationUserLayer) {
65439
+ const { segmentSelectionState } = layer.layer.displayState;
65440
+ const { visibleSegments } = layer.layer.displayState.segmentationGroupState.value;
65441
+ if (segmentSelectionState && onSelectedChanged) {
65442
+ const selectedChanged = this.selectedChanged.bind(void 0, layer);
65443
+ const remover = segmentSelectionState.changed.add(selectedChanged);
65444
+ this.handlerRemovers.push(remover);
65445
+ layer.registerDisposer(remover);
65446
+ }
65447
+ if (visibleSegments && onVisibleChanged) {
65448
+ const visibleChanged = this.visibleChanged.bind(void 0, layer);
65449
+ const remover = visibleSegments.changed.add(visibleChanged);
65450
+ this.handlerRemovers.push(remover);
65451
+ layer.registerDisposer(remover);
65452
+ }
65736
65453
  }
65737
- }));
65738
- var layer = getManagedLayer(void 0, layerName);
65739
- if (layer) {
65740
- layerConfig.process(layer);
65741
65454
  }
65742
- return function() {
65743
- if (layerConfig.cancel) {
65744
- layerConfig.cancel();
65745
- }
65746
- unsubscribeLayersChangedSignals(layerManager, layerName);
65747
- };
65748
65455
  }
65749
65456
  }
65750
- return layerConfig.cancel;
65751
- }
65752
- function configureAnnotationSource(source, props, recordRemover) {
65753
- if (source && !source.signalReady) {
65754
- if (props.onAnnotationAdded) {
65755
- recordRemover(source.childAdded.add(function(annotation) {
65756
- props.onAnnotationAdded(annotation);
65757
- }));
65758
- }
65759
- if (props.onAnnotationDeleted) {
65760
- recordRemover(source.childDeleted.add(function(id) {
65761
- props.onAnnotationDeleted(id);
65762
- }));
65763
- }
65764
- if (props.onAnnotationUpdated) {
65765
- recordRemover(source.childUpdated.add(function(annotation) {
65766
- props.onAnnotationUpdated(annotation);
65767
- }));
65457
+ });
65458
+ /* ** Vitessce Integration update start ** */
65459
+ __publicField(this, "selectedChanged", (layer) => {
65460
+ if (!this.viewer)
65461
+ return;
65462
+ const { onSelectedChanged } = this.props;
65463
+ if (onSelectedChanged) {
65464
+ const { segmentSelectionState } = layer.layer.displayState;
65465
+ if (!segmentSelectionState)
65466
+ return;
65467
+ const selected = segmentSelectionState.selectedSegment;
65468
+ if (selected) {
65469
+ onSelectedChanged(selected, layer);
65768
65470
  }
65769
- if (props.onAnnotationChanged && source.referencesChanged) {
65770
- recordRemover(source.referencesChanged.add(props.onAnnotationChanged));
65471
+ }
65472
+ });
65473
+ __publicField(this, "visibleChanged", (layer) => {
65474
+ if (this.viewer) {
65475
+ const { onVisibleChanged } = this.props;
65476
+ if (onVisibleChanged) {
65477
+ const { visibleSegments } = layer.layer.displayState.segmentationGroupState.value;
65478
+ if (visibleSegments) {
65479
+ onVisibleChanged(visibleSegments, layer);
65480
+ }
65771
65481
  }
65772
- source.signalReady = true;
65773
- recordRemover(function() {
65774
- source.signalReady = false;
65775
- });
65776
65482
  }
65483
+ });
65484
+ this.ngContainer = React__default.createRef();
65485
+ this.viewer = null;
65486
+ this.muteViewerChanged = false;
65487
+ this.prevVisibleIds = /* @__PURE__ */ new Set();
65488
+ this.prevColorMap = null;
65489
+ this.disposers = [];
65490
+ this.prevColorOverrides = /* @__PURE__ */ new Set();
65491
+ this.overrideColorsById = /* @__PURE__ */ Object.create(null);
65492
+ this.allKnownIds = /* @__PURE__ */ new Set();
65493
+ }
65494
+ componentDidMount() {
65495
+ const {
65496
+ viewerState,
65497
+ brainMapsClientId,
65498
+ eventBindingsToUpdate,
65499
+ callbacks,
65500
+ // ngServer,
65501
+ key,
65502
+ bundleRoot
65503
+ } = this.props;
65504
+ this.viewer = setupDefaultViewer({
65505
+ brainMapsClientId,
65506
+ target: this.ngContainer.current,
65507
+ bundleRoot
65508
+ });
65509
+ this.setCallbacks(callbacks);
65510
+ if (eventBindingsToUpdate) {
65511
+ this.updateEventBindings(eventBindingsToUpdate);
65512
+ }
65513
+ this.viewer.expectingExternalUI = true;
65514
+ if (this.viewer.selectionDetailsState) {
65515
+ this.viewer.selectionDetailsState.changed.add(this.selectionDetailsStateChanged);
65516
+ }
65517
+ this.viewer.layerManager.layersChanged.add(this.layersChanged);
65518
+ const emit = this.scheduleEmit();
65519
+ this.disposers.push(this.viewer.projectionScale.changed.add(emit));
65520
+ this.disposers.push(this.viewer.projectionOrientation.changed.add(emit));
65521
+ this.disposers.push(this.viewer.position.changed.add(emit));
65522
+ if (viewerState) {
65523
+ this.withoutEmitting(() => {
65524
+ this.viewer.state.restoreState(viewerState);
65525
+ });
65777
65526
  }
65778
- function getLoadedDataSource(layer) {
65779
- if (layer.dataSources && layer.dataSources.length > 0 && layer.dataSources[0].loadState_ && layer.dataSources[0].loadState_.dataSource) {
65780
- return layer.dataSources[0].loadState_.dataSource;
65781
- }
65527
+ if (key) {
65528
+ viewersKeyed[key] = this.viewer;
65529
+ } else {
65530
+ viewerNoKey = this.viewer;
65782
65531
  }
65783
- function getAnnotationSourceFromLayer(layer) {
65784
- var dataSource = getLoadedDataSource(layer);
65785
- if (dataSource) {
65786
- return dataSource.subsources[0].subsource.annotation;
65532
+ }
65533
+ componentDidUpdate(prevProps, prevState) {
65534
+ const { viewerState, cellColorMapping } = this.props;
65535
+ const selectedSegments = {};
65536
+ for (const layer of this.viewer.layerManager.managedLayers) {
65537
+ if (layer.layer instanceof SegmentationUserLayer) {
65538
+ const { segmentSelectionState } = layer.layer.displayState;
65539
+ selectedSegments[layer.name] = segmentSelectionState.selectedSegment;
65787
65540
  }
65788
65541
  }
65789
- function configureAnnotationSourceChange(annotationLayer, props, recordRemover) {
65790
- var configure = function configure2() {
65791
- var source = getAnnotationSourceFromLayer(annotationLayer);
65792
- if (source) {
65793
- configureAnnotationSource(source, props, recordRemover);
65794
- }
65795
- };
65796
- var sourceChanged = annotationLayer.dataSourcesChanged;
65797
- if (sourceChanged && !sourceChanged.signalReady) {
65798
- recordRemover(sourceChanged.add(configure));
65799
- sourceChanged.signalReady = true;
65800
- recordRemover(function() {
65801
- sourceChanged.signalReady = false;
65802
- });
65803
- configure();
65542
+ for (const layer of this.viewer.layerManager.managedLayers) {
65543
+ if (layer.layer instanceof SegmentationUserLayer) {
65544
+ const { segmentSelectionState } = layer.layer.displayState;
65545
+ segmentSelectionState.set(selectedSegments[layer.name]);
65804
65546
  }
65805
65547
  }
65806
- function configureAnnotationLayer(layer, props, recordRemover) {
65807
- if (layer) {
65808
- layer.expectingExternalTable = true;
65809
- if (layer.selectedAnnotation && !layer.selectedAnnotation.changed.signalReady) {
65810
- if (props.onAnnotationSelectionChanged) {
65811
- recordRemover(layer.selectedAnnotation.changed.add(function() {
65812
- props.onAnnotationSelectionChanged(layer.selectedAnnotation.value);
65813
- }));
65814
- recordRemover(function() {
65815
- layer.selectedAnnotation.changed.signalReady = false;
65816
- });
65817
- layer.selectedAnnotation.changed.signalReady = true;
65818
- }
65548
+ if (!viewerState)
65549
+ return;
65550
+ const prevVS = prevProps.viewerState;
65551
+ const camState = diffCameraState(prevVS, viewerState);
65552
+ if (camState.changed) {
65553
+ const patch = {};
65554
+ if (camState.scale) {
65555
+ patch.projectionScale = viewerState.projectionScale;
65556
+ if (Array.isArray(viewerState.position))
65557
+ patch.position = viewerState.position;
65558
+ } else if (camState.pos) {
65559
+ patch.position = viewerState.position;
65560
+ }
65561
+ if (camState.rot)
65562
+ patch.projectionOrientation = viewerState.projectionOrientation;
65563
+ this.withoutEmitting(() => this.viewer.state.restoreState(patch));
65564
+ }
65565
+ if (this.didLayersChange(prevVS, viewerState)) {
65566
+ this.withoutEmitting(() => {
65567
+ const layers = Array.isArray(viewerState.layers) ? viewerState.layers : [];
65568
+ this.viewer.state.restoreState({ layers });
65569
+ if (cellColorMapping && Object.keys(cellColorMapping).length) {
65570
+ this.applyColorsAndVisibility(cellColorMapping);
65819
65571
  }
65820
- configureAnnotationSourceChange(layer, props, recordRemover);
65821
- }
65572
+ });
65822
65573
  }
65823
- function configureAnnotationLayerChanged(layer, props, recordRemover) {
65824
- if (!layer.layerChanged.signalReady) {
65825
- var remover = layer.layerChanged.add(function() {
65826
- configureAnnotationLayer(layer.layer, props, recordRemover);
65827
- });
65828
- layer.layerChanged.signalReady = true;
65829
- recordRemover(remover);
65830
- recordRemover(function() {
65831
- layer.layerChanged.signalReady = false;
65832
- });
65833
- configureAnnotationLayer(layer.layer, props, recordRemover);
65834
- }
65574
+ const prevSize = prevProps.cellColorMapping ? Object.keys(prevProps.cellColorMapping).length : 0;
65575
+ const currSize = cellColorMapping ? Object.keys(cellColorMapping).length : 0;
65576
+ const mappingRefChanged = prevProps.cellColorMapping !== cellColorMapping;
65577
+ if (!this.didLayersChange(prevVS, viewerState) && (mappingRefChanged || prevSize !== currSize)) {
65578
+ this.withoutEmitting(() => {
65579
+ this.applyColorsAndVisibility(cellColorMapping);
65580
+ });
65835
65581
  }
65836
- function getAnnotationSelectionHost(key) {
65837
- var viewer = key ? viewersKeyed[key] : viewerNoKey;
65838
- if (viewer) {
65839
- if (viewer.selectionDetailsState) {
65840
- return "viewer";
65841
- }
65842
- return "layer";
65843
- }
65844
- return null;
65582
+ const stripSegFields = (layers) => (layers || []).map((l) => {
65583
+ if (!l)
65584
+ return l;
65585
+ const { segments, segmentColors, ...rest } = l;
65586
+ return rest;
65587
+ });
65588
+ const prevLayers = prevProps.viewerState?.layers;
65589
+ const nextLayers = viewerState?.layers;
65590
+ const prevCore = JSON.stringify(stripSegFields(prevLayers));
65591
+ const nextCore = JSON.stringify(stripSegFields(nextLayers));
65592
+ const sourcesChanged = prevCore !== nextCore;
65593
+ const prevSegCount = prevLayers && prevLayers[0] && Array.isArray(prevLayers[0].segments) ? prevLayers[0].segments.length : 0;
65594
+ const nextSegCount = nextLayers && nextLayers[0] && Array.isArray(nextLayers[0].segments) ? nextLayers[0].segments.length : 0;
65595
+ const initialSegmentsAdded = prevSegCount === 0 && nextSegCount > 0;
65596
+ if (sourcesChanged || initialSegmentsAdded) {
65597
+ this.withoutEmitting(() => {
65598
+ this.viewer.state.restoreState({ layers: nextLayers });
65599
+ });
65845
65600
  }
65846
- function getSelectedAnnotationId(key, layerName) {
65847
- var viewer = key ? viewersKeyed[key] : viewerNoKey;
65848
- if (viewer) {
65849
- if (viewer.selectionDetailsState) {
65850
- if (viewer.selectionDetailsState.value) {
65851
- var layers = viewer.selectionDetailsState.value.layers;
65852
- if (layers) {
65853
- var layer = layers.find(function(_layer) {
65854
- return _layer.layer.managedLayer.name === layerName;
65855
- });
65856
- if (layer && layer.state) {
65857
- return layer.state.annotationId;
65858
- }
65859
- }
65860
- }
65861
- } else {
65862
- var _layer2 = getAnnotationLayer(void 0, layerName);
65863
- if (_layer2 && _layer2.selectedAnnotation && _layer2.selectedAnnotation.value) {
65864
- return _layer2.selectedAnnotation.value.id;
65865
- }
65866
- }
65601
+ }
65602
+ componentWillUnmount() {
65603
+ this.disposers.forEach((off) => {
65604
+ try {
65605
+ off();
65606
+ } catch {
65867
65607
  }
65868
- return null;
65869
- }
65870
- var Neuroglancer2 = /* @__PURE__ */ function(_React$Component) {
65871
- _inherits(Neuroglancer3, _React$Component);
65872
- var _super = _createSuper(Neuroglancer3);
65873
- function Neuroglancer3(props) {
65874
- var _this;
65875
- _classCallCheck(this, Neuroglancer3);
65876
- _this = _super.call(this, props);
65877
- _defineProperty(_assertThisInitialized(_this), "updateEventBindings", function(eventBindingsToUpdate) {
65878
- var root = _this.viewer.inputEventBindings;
65879
- var traverse = function traverse2(current) {
65880
- var replace = function replace2(eaMap, event0, event1) {
65881
- var action = eaMap.get(event0);
65882
- if (action) {
65883
- eaMap["delete"](event0);
65884
- if (event1) {
65885
- eaMap.set(event1, action);
65886
- }
65887
- }
65888
- };
65889
- var eventActionMap = current.bindings;
65890
- eventBindingsToUpdate.forEach(function(oldNewBinding) {
65891
- var eventOldBase = Array.isArray(oldNewBinding) ? oldNewBinding[0] : oldNewBinding;
65892
- var eventOldA = "at:".concat(eventOldBase);
65893
- var eventNewA = oldNewBinding[1] ? "at:".concat(oldNewBinding[1]) : void 0;
65894
- replace(eventActionMap, eventOldA, eventNewA);
65895
- var eventOldB = "bubble:".concat(eventOldBase);
65896
- var eventNewB = oldNewBinding[1] ? "bubble:".concat(oldNewBinding[1]) : void 0;
65897
- replace(eventActionMap, eventOldB, eventNewB);
65898
- });
65899
- current.parents.forEach(function(parent) {
65900
- traverse2(parent);
65901
- });
65902
- };
65903
- traverse(root.global);
65904
- traverse(root.perspectiveView);
65905
- traverse(root.sliceView);
65906
- });
65907
- _defineProperty(_assertThisInitialized(_this), "selectionDetailsStateChanged", function() {
65908
- if (_this.viewer) {
65909
- var onSelectionDetailsStateChanged = _this.props.onSelectionDetailsStateChanged;
65910
- if (onSelectionDetailsStateChanged) {
65911
- onSelectionDetailsStateChanged();
65912
- }
65913
- }
65914
- });
65915
- _defineProperty(_assertThisInitialized(_this), "layersChanged", function() {
65916
- if (_this.handlerRemovers) {
65917
- _this.handlerRemovers.forEach(function(remover2) {
65918
- return remover2();
65919
- });
65920
- }
65921
- if (_this.viewer) {
65922
- var _this$props = _this.props, onSelectedChanged = _this$props.onSelectedChanged, onVisibleChanged = _this$props.onVisibleChanged;
65923
- if (onSelectedChanged || onVisibleChanged) {
65924
- _this.handlerRemovers = [];
65925
- var _iterator2 = _createForOfIteratorHelper(_this.viewer.layerManager.managedLayers), _step2;
65926
- try {
65927
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
65928
- var layer = _step2.value;
65929
- if (layer.layer instanceof _segmentation_user_layer.SegmentationUserLayer) {
65930
- var segmentSelectionState = layer.layer.displayState.segmentSelectionState;
65931
- var visibleSegments = layer.layer.displayState.segmentationGroupState.value.visibleSegments;
65932
- if (segmentSelectionState && onSelectedChanged) {
65933
- var selectedChanged = _this.selectedChanged.bind(void 0, layer);
65934
- var remover = segmentSelectionState.changed.add(selectedChanged);
65935
- _this.handlerRemovers.push(remover);
65936
- layer.registerDisposer(remover);
65937
- }
65938
- if (visibleSegments && onVisibleChanged) {
65939
- var visibleChanged = _this.visibleChanged.bind(void 0, layer);
65940
- var _remover = visibleSegments.changed.add(visibleChanged);
65941
- _this.handlerRemovers.push(_remover);
65942
- layer.registerDisposer(_remover);
65943
- }
65944
- }
65945
- }
65946
- } catch (err) {
65947
- _iterator2.e(err);
65948
- } finally {
65949
- _iterator2.f();
65950
- }
65951
- }
65952
- }
65953
- });
65954
- _defineProperty(_assertThisInitialized(_this), "selectedChanged", function(layer) {
65955
- if (_this.viewer) {
65956
- var onSelectedChanged = _this.props.onSelectedChanged;
65957
- if (onSelectedChanged) {
65958
- var segmentSelectionState = layer.layer.displayState.segmentSelectionState;
65959
- if (segmentSelectionState) {
65960
- var segment = segmentSelectionState.hasSelectedSegment ? segmentSelectionState.selectedSegment : null;
65961
- onSelectedChanged(segment, layer);
65962
- }
65963
- }
65964
- }
65965
- });
65966
- _defineProperty(_assertThisInitialized(_this), "visibleChanged", function(layer) {
65967
- if (_this.viewer) {
65968
- var onVisibleChanged = _this.props.onVisibleChanged;
65969
- if (onVisibleChanged) {
65970
- var visibleSegments = layer.layer.displayState.segmentationGroupState.value.visibleSegments;
65971
- if (visibleSegments) {
65972
- onVisibleChanged(visibleSegments, layer);
65973
- }
65974
- }
65975
- }
65976
- });
65977
- _this.ngContainer = /* @__PURE__ */ _react["default"].createRef();
65978
- _this.viewer = null;
65979
- return _this;
65980
- }
65981
- _createClass(Neuroglancer3, [{
65982
- key: "componentDidMount",
65983
- value: function componentDidMount() {
65984
- var _this2 = this;
65985
- 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;
65986
- this.viewer = (0, _neuroglancer.setupDefaultViewer)({
65987
- brainMapsClientId,
65988
- target: this.ngContainer.current,
65989
- bundleRoot: bundleRoot || "/"
65990
- });
65991
- this.setCallbacks(callbacks);
65992
- if (eventBindingsToUpdate) {
65993
- this.updateEventBindings(eventBindingsToUpdate);
65994
- }
65995
- this.viewer.expectingExternalUI = true;
65996
- if (ngServer) {
65997
- this.viewer.makeUrlFromState = function(state) {
65998
- var newState = _objectSpread({}, state);
65999
- if (state.layers) {
66000
- newState.layers = state.layers.filter(function(layer) {
66001
- if (layer.source) {
66002
- var sourceUrl = layer.source.url || layer.source;
66003
- if (typeof sourceUrl === "string") {
66004
- return !sourceUrl.startsWith("clio://");
66005
- }
66006
- }
66007
- return true;
66008
- });
66009
- }
66010
- return "".concat(ngServer, "/#!").concat((0, _url_hash_binding.encodeFragment)(JSON.stringify(newState)));
66011
- };
66012
- }
66013
- if (this.viewer.selectionDetailsState) {
66014
- this.viewer.selectionDetailsState.changed.add(this.selectionDetailsStateChanged);
66015
- }
66016
- this.viewer.layerManager.layersChanged.add(this.layersChanged);
66017
- if (viewerState) {
66018
- var newViewerState = viewerState;
66019
- if (newViewerState.projectionScale === null) {
66020
- delete newViewerState.projectionScale;
66021
- }
66022
- if (newViewerState.crossSectionScale === null) {
66023
- delete newViewerState.crossSectionScale;
66024
- }
66025
- if (newViewerState.projectionOrientation === null) {
66026
- delete newViewerState.projectionOrientation;
66027
- }
66028
- if (newViewerState.crossSectionOrientation === null) {
66029
- delete newViewerState.crossSectionOrientation;
66030
- }
66031
- this.viewer.state.restoreState(newViewerState);
66032
- } else {
66033
- this.viewer.state.restoreState({
66034
- layers: {
66035
- grayscale: {
66036
- type: "image",
66037
- source: "dvid://https://flyem.dvid.io/ab6e610d4fe140aba0e030645a1d7229/grayscalejpeg"
66038
- },
66039
- segmentation: {
66040
- type: "segmentation",
66041
- source: "dvid://https://flyem.dvid.io/d925633ed0974da78e2bb5cf38d01f4d/segmentation"
66042
- }
66043
- },
66044
- perspectiveZoom,
66045
- navigation: {
66046
- zoomFactor: 8
66047
- }
66048
- });
66049
- }
66050
- this.viewer.state.changed.add(function() {
66051
- if (onViewerStateChanged) {
66052
- try {
66053
- if (_this2.viewer.state.viewer.position) {
66054
- onViewerStateChanged(_this2.viewer.state.toJSON());
66055
- }
66056
- } catch (error) {
66057
- console.debug(error);
66058
- }
66059
- }
66060
- });
66061
- if (key) {
66062
- viewersKeyed[key] = this.viewer;
66063
- } else {
66064
- viewerNoKey = this.viewer;
66065
- }
66066
- window.viewer = this.viewer;
66067
- }
66068
- }, {
66069
- key: "componentDidUpdate",
66070
- value: function componentDidUpdate() {
66071
- var _this3 = this;
66072
- var selectedSegments = {};
66073
- var _iterator3 = _createForOfIteratorHelper(this.viewer.layerManager.managedLayers), _step3;
66074
- try {
66075
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
66076
- var layer = _step3.value;
66077
- if (layer.layer instanceof _segmentation_user_layer.SegmentationUserLayer) {
66078
- var segmentSelectionState = layer.layer.displayState.segmentSelectionState;
66079
- selectedSegments[layer.name] = segmentSelectionState.selectedSegment;
66080
- }
66081
- }
66082
- } catch (err) {
66083
- _iterator3.e(err);
66084
- } finally {
66085
- _iterator3.f();
66086
- }
66087
- var viewerState = this.props.viewerState;
66088
- if (viewerState) {
66089
- var newViewerState = _objectSpread({}, viewerState);
66090
- var restoreStates = [function() {
66091
- _this3.viewer.state.restoreState(newViewerState);
66092
- }];
66093
- if (viewerState.projectionScale === null) {
66094
- delete newViewerState.projectionScale;
66095
- restoreStates.push(function() {
66096
- _this3.viewer.projectionScale.reset();
66097
- });
66098
- }
66099
- if (viewerState.crossSectionScale === null) {
66100
- delete newViewerState.crossSectionScale;
66101
- }
66102
- restoreStates.forEach(function(restore) {
66103
- return restore();
66104
- });
66105
- }
66106
- var _iterator4 = _createForOfIteratorHelper(this.viewer.layerManager.managedLayers), _step4;
66107
- try {
66108
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done; ) {
66109
- var _layer3 = _step4.value;
66110
- if (_layer3.layer instanceof _segmentation_user_layer.SegmentationUserLayer) {
66111
- var _segmentSelectionState = _layer3.layer.displayState.segmentSelectionState;
66112
- _segmentSelectionState.set(selectedSegments[_layer3.name]);
66113
- }
66114
- }
66115
- } catch (err) {
66116
- _iterator4.e(err);
66117
- } finally {
66118
- _iterator4.f();
66119
- }
66120
- if ("position" in viewerState) {
66121
- if (Array.isArray(viewerState.position)) {
66122
- if (viewerState.position.length === 0) {
66123
- this.viewer.position.reset();
66124
- }
66125
- }
66126
- }
66127
- }
66128
- }, {
66129
- key: "componentWillUnmount",
66130
- value: function componentWillUnmount() {
66131
- var key = this.props.key;
66132
- if (key) {
66133
- delete viewersKeyed[key];
66134
- } else {
66135
- viewerNoKey = void 0;
66136
- }
66137
- }
66138
- /* setCallbacks allows us to set a callback on a neuroglancer event
66139
- * each callback created should be in the format:
66140
- * [
66141
- * {
66142
- * name: 'unique-name',
66143
- * event: 'the neuroglancer event to target, eg: click0, keyt',
66144
- * function: (slice) => { slice.whatever }
66145
- * },
66146
- * {...}
66147
- * ]
66148
- *
66149
- */
66150
- }, {
66151
- key: "setCallbacks",
66152
- value: function setCallbacks(callbacks) {
66153
- var _this4 = this;
66154
- callbacks.forEach(function(callback) {
66155
- _this4.viewer.bindCallback(callback.name, callback["function"]);
66156
- _this4.viewer.inputEventBindings.sliceView.set(callback.event, callback.name);
66157
- });
66158
- }
66159
- }, {
66160
- key: "render",
66161
- value: function render() {
66162
- var perspectiveZoom = this.props.perspectiveZoom;
66163
- return /* @__PURE__ */ _react["default"].createElement("div", {
66164
- className: "neuroglancer-container",
66165
- ref: this.ngContainer
66166
- }, /* @__PURE__ */ _react["default"].createElement("p", null, "Neuroglancer here with zoom ", perspectiveZoom));
66167
- }
66168
- }]);
66169
- return Neuroglancer3;
66170
- }(_react["default"].Component);
66171
- exports["default"] = Neuroglancer2;
66172
- Neuroglancer2.propTypes = {
66173
- perspectiveZoom: _propTypes["default"].number,
66174
- viewerState: _propTypes["default"].object,
66175
- brainMapsClientId: _propTypes["default"].string,
66176
- key: _propTypes["default"].string,
66177
- /**
66178
- * An array of event bindings to change in Neuroglancer. The array format is as follows:
66179
- * [[old-event1, new-event1], [old-event2], old-event3]
66180
- * Here, `old-event1`'s will be unbound and its action will be re-bound to `new-event1`.
66181
- * The bindings for `old-event2` and `old-event3` will be removed.
66182
- * Neuroglancer has its own syntax for event descriptors, and here are some examples:
66183
- * 'keya', 'shift+keyb' 'control+keyc', 'digit4', 'space', 'arrowleft', 'comma', 'period',
66184
- * 'minus', 'equal', 'bracketleft'.
66185
- */
66186
- eventBindingsToUpdate: _propTypes["default"].array,
66187
- /**
66188
- * A function of the form `(segment, layer) => {}`, called each time there is a change to
66189
- * the segment the user has "selected" (i.e., hovered over) in Neuroglancer.
66190
- * The `segment` argument will be a Neuroglancer `Uint64` with the ID of the now-selected
66191
- * segment, or `null` if no segment is now selected.
66192
- * The `layer` argument will be a Neuroglaner `ManagedUserLayer`, whose `layer` property
66193
- * will be a Neuroglancer `SegmentationUserLayer`.
66194
- */
66195
- onSelectedChanged: _propTypes["default"].func,
66196
- /**
66197
- * A function of the form `(segments, layer) => {}`, called each time there is a change to
66198
- * the segments the user has designated as "visible" (i.e., double-clicked on) in Neuroglancer.
66199
- * The `segments` argument will be a Neuroglancer `Uint64Set` whose elements are `Uint64`
66200
- * instances for the IDs of the now-visible segments.
66201
- * The `layer` argument will be a Neuroglaner `ManagedUserLayer`, whose `layer` property
66202
- * will be a Neuroglancer `SegmentationUserLayer`.
66203
- */
66204
- onVisibleChanged: _propTypes["default"].func,
66205
- /**
66206
- * A function of the form `() => {}` to respond to selection changes in the viewer.
66207
- */
66208
- onSelectionDetailsStateChanged: _propTypes["default"].func,
66209
- onViewerStateChanged: _propTypes["default"].func,
66210
- callbacks: _propTypes["default"].arrayOf(_propTypes["default"].object),
66211
- ngServer: _propTypes["default"].string
66212
- };
66213
- Neuroglancer2.defaultProps = {
66214
- perspectiveZoom: 20,
66215
- eventBindingsToUpdate: null,
66216
- brainMapsClientId: "NOT_A_VALID_ID",
66217
- viewerState: null,
66218
- onSelectedChanged: null,
66219
- onVisibleChanged: null,
66220
- onSelectionDetailsStateChanged: null,
66221
- onViewerStateChanged: null,
66222
- key: null,
66223
- callbacks: [],
66224
- ngServer: "https://neuroglancer-demo.appspot.com/"
66225
- };
66226
- })(lib);
66227
- return lib;
66228
- }
66229
- var libExports = requireLib();
66230
- const ReactNeuroglancer = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
66231
- const Component = typeof ReactNeuroglancer.default === "function" ? ReactNeuroglancer.default : ReactNeuroglancer;
66232
- const ReactNeuroglancerWrapper = React__default.forwardRef((props, ref) => jsxRuntimeExports.jsx(Component, { ref, ...props }));
65608
+ });
65609
+ this.disposers = [];
65610
+ const { key } = this.props;
65611
+ if (key) {
65612
+ delete viewersKeyed[key];
65613
+ } else {
65614
+ viewerNoKey = void 0;
65615
+ }
65616
+ }
65617
+ /* setCallbacks allows us to set a callback on a neuroglancer event
65618
+ * each callback created should be in the format:
65619
+ * [
65620
+ * {
65621
+ * name: 'unique-name',
65622
+ * event: 'the neuroglancer event to target, eg: click0, keyt',
65623
+ * function: (slice) => { slice.whatever }
65624
+ * },
65625
+ * {...}
65626
+ * ]
65627
+ *
65628
+ */
65629
+ setCallbacks(callbacks) {
65630
+ callbacks.forEach((callback) => {
65631
+ this.viewer.bindCallback(callback.name, callback.function);
65632
+ this.viewer.inputEventBindings.sliceView.set(callback.event, callback.name);
65633
+ });
65634
+ }
65635
+ render() {
65636
+ const { perspectiveZoom } = this.props;
65637
+ return jsxRuntimeExports.jsx("div", { className: "neuroglancer-container", ref: this.ngContainer, children: jsxRuntimeExports.jsxs("p", { children: ["Neuroglancer here with zoom ", perspectiveZoom] }) });
65638
+ }
65639
+ }
65640
+ __publicField(Neuroglancer, "defaultProps", {
65641
+ perspectiveZoom: 20,
65642
+ eventBindingsToUpdate: null,
65643
+ brainMapsClientId: "NOT_A_VALID_ID",
65644
+ viewerState: null,
65645
+ onSelectedChanged: null,
65646
+ onVisibleChanged: null,
65647
+ onSelectionDetailsStateChanged: null,
65648
+ onViewerStateChanged: null,
65649
+ key: null,
65650
+ callbacks: [],
65651
+ ngServer: "https://neuroglancer-demo.appspot.com/"
65652
+ });
66233
65653
  export {
66234
- ReactNeuroglancerWrapper as default
65654
+ addLayerSignalRemover,
65655
+ closeSelectionTab,
65656
+ configureAnnotationLayer,
65657
+ configureAnnotationLayerChanged,
65658
+ configureLayersChangedSignals,
65659
+ Neuroglancer as default,
65660
+ getAnnotationLayer,
65661
+ getAnnotationSelectionHost,
65662
+ getAnnotationSource,
65663
+ getLayerManager,
65664
+ getManagedLayer,
65665
+ getNeuroglancerColor,
65666
+ getNeuroglancerViewerState,
65667
+ getSelectedAnnotationId,
65668
+ parseUrlHash,
65669
+ unsubscribeLayersChangedSignals
66235
65670
  };