@vitessce/image-utils 4.2.0 → 4.2.2

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.
@@ -20758,16 +20758,16 @@ class Stats {
20758
20758
  }
20759
20759
  }
20760
20760
  getTable() {
20761
- const table = {};
20761
+ const table2 = {};
20762
20762
  this.forEach((stat) => {
20763
- table[stat.name] = {
20763
+ table2[stat.name] = {
20764
20764
  time: stat.time || 0,
20765
20765
  count: stat.count || 0,
20766
20766
  average: stat.getAverageTime() || 0,
20767
20767
  hz: stat.getHz() || 0
20768
20768
  };
20769
20769
  });
20770
- return table;
20770
+ return table2;
20771
20771
  }
20772
20772
  _initializeStats() {
20773
20773
  let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
@@ -21425,10 +21425,10 @@ class Log {
21425
21425
  }
21426
21426
  return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
21427
21427
  }
21428
- table(logLevel, table, columns) {
21429
- if (table) {
21430
- return this._getLogFunction(logLevel, table, console.table || noop$4, columns && [columns], {
21431
- tag: getTableHeader(table)
21428
+ table(logLevel, table2, columns) {
21429
+ if (table2) {
21430
+ return this._getLogFunction(logLevel, table2, console.table || noop$4, columns && [columns], {
21431
+ tag: getTableHeader(table2)
21432
21432
  });
21433
21433
  }
21434
21434
  return noop$4;
@@ -21628,9 +21628,9 @@ function logImageInBrowser(_ref3) {
21628
21628
  }
21629
21629
  return noop$4;
21630
21630
  }
21631
- function getTableHeader(table) {
21632
- for (const key in table) {
21633
- for (const title in table[key]) {
21631
+ function getTableHeader(table2) {
21632
+ for (const key in table2) {
21633
+ for (const title in table2[key]) {
21634
21634
  return title || "untitled";
21635
21635
  }
21636
21636
  }
@@ -29074,13 +29074,13 @@ function getDebugTableForUniforms(_ref) {
29074
29074
  const SHADER_MODULE_UNIFORM_REGEXP = ".*_.*";
29075
29075
  const PROJECT_MODULE_UNIFORM_REGEXP = ".*Matrix";
29076
29076
  const uniformLocations = program._uniformSetters;
29077
- const table = {};
29077
+ const table2 = {};
29078
29078
  const uniformNames = Object.keys(uniformLocations).sort();
29079
29079
  let count2 = 0;
29080
29080
  for (const uniformName of uniformNames) {
29081
29081
  if (!uniformName.match(SHADER_MODULE_UNIFORM_REGEXP) && !uniformName.match(PROJECT_MODULE_UNIFORM_REGEXP)) {
29082
29082
  if (addUniformToTable({
29083
- table,
29083
+ table: table2,
29084
29084
  header,
29085
29085
  uniforms,
29086
29086
  uniformName,
@@ -29093,7 +29093,7 @@ function getDebugTableForUniforms(_ref) {
29093
29093
  for (const uniformName of uniformNames) {
29094
29094
  if (uniformName.match(PROJECT_MODULE_UNIFORM_REGEXP)) {
29095
29095
  if (addUniformToTable({
29096
- table,
29096
+ table: table2,
29097
29097
  header,
29098
29098
  uniforms,
29099
29099
  uniformName,
@@ -29104,9 +29104,9 @@ function getDebugTableForUniforms(_ref) {
29104
29104
  }
29105
29105
  }
29106
29106
  for (const uniformName of uniformNames) {
29107
- if (!table[uniformName]) {
29107
+ if (!table2[uniformName]) {
29108
29108
  if (addUniformToTable({
29109
- table,
29109
+ table: table2,
29110
29110
  header,
29111
29111
  uniforms,
29112
29112
  uniformName,
@@ -29121,7 +29121,7 @@ function getDebugTableForUniforms(_ref) {
29121
29121
  if (!undefinedOnly) {
29122
29122
  for (const uniformName in uniforms) {
29123
29123
  const uniform = uniforms[uniformName];
29124
- if (!table[uniformName]) {
29124
+ if (!table2[uniformName]) {
29125
29125
  unusedCount++;
29126
29126
  unusedTable[uniformName] = {
29127
29127
  Type: "NOT USED: ".concat(uniform),
@@ -29131,7 +29131,7 @@ function getDebugTableForUniforms(_ref) {
29131
29131
  }
29132
29132
  }
29133
29133
  return {
29134
- table,
29134
+ table: table2,
29135
29135
  count: count2,
29136
29136
  unusedTable,
29137
29137
  unusedCount
@@ -29139,7 +29139,7 @@ function getDebugTableForUniforms(_ref) {
29139
29139
  }
29140
29140
  function addUniformToTable(_ref2) {
29141
29141
  let {
29142
- table,
29142
+ table: table2,
29143
29143
  header,
29144
29144
  uniforms,
29145
29145
  uniformName,
@@ -29148,7 +29148,7 @@ function addUniformToTable(_ref2) {
29148
29148
  const value = uniforms[uniformName];
29149
29149
  const isDefined = isUniformDefined(value);
29150
29150
  if (!undefinedOnly || !isDefined) {
29151
- table[uniformName] = {
29151
+ table2[uniformName] = {
29152
29152
  [header]: isDefined ? formatValue(value) : "N/A",
29153
29153
  "Uniform Type": isDefined ? value : "NOT PROVIDED"
29154
29154
  };
@@ -29167,9 +29167,9 @@ function getDebugTableForVertexArray(_ref) {
29167
29167
  if (!vertexArray.configuration) {
29168
29168
  return {};
29169
29169
  }
29170
- const table = {};
29170
+ const table2 = {};
29171
29171
  if (vertexArray.elements) {
29172
- table.ELEMENT_ARRAY_BUFFER = getDebugTableRow(vertexArray, vertexArray.elements, null, header);
29172
+ table2.ELEMENT_ARRAY_BUFFER = getDebugTableRow(vertexArray, vertexArray.elements, null, header);
29173
29173
  }
29174
29174
  const attributes = vertexArray.values;
29175
29175
  for (const attributeLocation in attributes) {
@@ -29180,10 +29180,10 @@ function getDebugTableForVertexArray(_ref) {
29180
29180
  if (accessor) {
29181
29181
  rowHeader = "".concat(attributeLocation, ": ").concat(getGLSLDeclaration$1(info.name, accessor));
29182
29182
  }
29183
- table[rowHeader] = getDebugTableRow(vertexArray, attributes[attributeLocation], accessor, header);
29183
+ table2[rowHeader] = getDebugTableRow(vertexArray, attributes[attributeLocation], accessor, header);
29184
29184
  }
29185
29185
  }
29186
- return table;
29186
+ return table2;
29187
29187
  }
29188
29188
  function getDebugTableRow(vertexArray, attribute, accessor, header) {
29189
29189
  const {
@@ -29255,12 +29255,12 @@ function getGLSLDeclaration$1(name2, accessor) {
29255
29255
  return typeAndName ? "".concat(name2, " (").concat(typeAndName.name, ")") : name2;
29256
29256
  }
29257
29257
  function getDebugTableForProgramConfiguration(config3) {
29258
- const table = {};
29258
+ const table2 = {};
29259
29259
  const header = "Accessors for ".concat(config3.id);
29260
29260
  for (const attributeInfo of config3.attributeInfos) {
29261
29261
  if (attributeInfo) {
29262
29262
  const glslDeclaration = getGLSLDeclaration(attributeInfo);
29263
- table["in ".concat(glslDeclaration)] = {
29263
+ table2["in ".concat(glslDeclaration)] = {
29264
29264
  [header]: JSON.stringify(attributeInfo.accessor)
29265
29265
  };
29266
29266
  }
@@ -29268,12 +29268,12 @@ function getDebugTableForProgramConfiguration(config3) {
29268
29268
  for (const varyingInfo of config3.varyingInfos) {
29269
29269
  if (varyingInfo) {
29270
29270
  const glslDeclaration = getGLSLDeclaration(varyingInfo);
29271
- table["out ".concat(glslDeclaration)] = {
29271
+ table2["out ".concat(glslDeclaration)] = {
29272
29272
  [header]: JSON.stringify(varyingInfo.accessor)
29273
29273
  };
29274
29274
  }
29275
29275
  }
29276
- return table;
29276
+ return table2;
29277
29277
  }
29278
29278
  function getGLSLDeclaration(attributeInfo) {
29279
29279
  const {
@@ -98342,7 +98342,7 @@ function requireBignumber() {
98342
98342
  suffix: ""
98343
98343
  }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
98344
98344
  function BigNumber3(v, b) {
98345
- var alphabet, c, caseChanged, e2, i2, isNum, len2, str, x = this;
98345
+ var alphabet2, c, caseChanged, e2, i2, isNum, len2, str, x = this;
98346
98346
  if (!(x instanceof BigNumber3)) return new BigNumber3(v, b);
98347
98347
  if (b == null) {
98348
98348
  if (v && v._isBigNumber === true) {
@@ -98398,10 +98398,10 @@ function requireBignumber() {
98398
98398
  } else {
98399
98399
  x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
98400
98400
  }
98401
- alphabet = ALPHABET.slice(0, b);
98401
+ alphabet2 = ALPHABET.slice(0, b);
98402
98402
  e2 = i2 = 0;
98403
98403
  for (len2 = str.length; i2 < len2; i2++) {
98404
- if (alphabet.indexOf(c = str.charAt(i2)) < 0) {
98404
+ if (alphabet2.indexOf(c = str.charAt(i2)) < 0) {
98405
98405
  if (c == ".") {
98406
98406
  if (i2 > e2) {
98407
98407
  e2 = len2;
@@ -98672,11 +98672,11 @@ function requireBignumber() {
98672
98672
  };
98673
98673
  convertBase2 = /* @__PURE__ */ function() {
98674
98674
  var decimal = "0123456789";
98675
- function toBaseOut(str, baseIn, baseOut, alphabet) {
98675
+ function toBaseOut(str, baseIn, baseOut, alphabet2) {
98676
98676
  var j, arr = [0], arrL, i2 = 0, len2 = str.length;
98677
98677
  for (; i2 < len2; ) {
98678
98678
  for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) ;
98679
- arr[0] += alphabet.indexOf(str.charAt(i2++));
98679
+ arr[0] += alphabet2.indexOf(str.charAt(i2++));
98680
98680
  for (j = 0; j < arr.length; j++) {
98681
98681
  if (arr[j] > baseOut - 1) {
98682
98682
  if (arr[j + 1] == null) arr[j + 1] = 0;
@@ -98688,7 +98688,7 @@ function requireBignumber() {
98688
98688
  return arr.reverse();
98689
98689
  }
98690
98690
  return function(str, baseIn, baseOut, sign2, callerIsToString) {
98691
- var alphabet, d, e2, k, r2, x, xc, y, i2 = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
98691
+ var alphabet2, d, e2, k, r2, x, xc, y, i2 = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
98692
98692
  if (i2 >= 0) {
98693
98693
  k = POW_PRECISION;
98694
98694
  POW_PRECISION = 0;
@@ -98704,10 +98704,10 @@ function requireBignumber() {
98704
98704
  );
98705
98705
  y.e = y.c.length;
98706
98706
  }
98707
- xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
98707
+ xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet2 = ALPHABET, decimal) : (alphabet2 = decimal, ALPHABET));
98708
98708
  e2 = k = xc.length;
98709
98709
  for (; xc[--k] == 0; xc.pop()) ;
98710
- if (!xc[0]) return alphabet.charAt(0);
98710
+ if (!xc[0]) return alphabet2.charAt(0);
98711
98711
  if (i2 < 0) {
98712
98712
  --e2;
98713
98713
  } else {
@@ -98725,7 +98725,7 @@ function requireBignumber() {
98725
98725
  r2 = r2 || d < 0 || xc[d + 1] != null;
98726
98726
  r2 = rm < 4 ? (i2 != null || r2) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : i2 > k || i2 == k && (rm == 4 || r2 || rm == 6 && xc[d - 1] & 1 || rm == (x.s < 0 ? 8 : 7));
98727
98727
  if (d < 1 || !xc[0]) {
98728
- str = r2 ? toFixedPoint2(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
98728
+ str = r2 ? toFixedPoint2(alphabet2.charAt(1), -dp, alphabet2.charAt(0)) : alphabet2.charAt(0);
98729
98729
  } else {
98730
98730
  xc.length = d;
98731
98731
  if (r2) {
@@ -98738,8 +98738,8 @@ function requireBignumber() {
98738
98738
  }
98739
98739
  }
98740
98740
  for (k = xc.length; !xc[--k]; ) ;
98741
- for (i2 = 0, str = ""; i2 <= k; str += alphabet.charAt(xc[i2++])) ;
98742
- str = toFixedPoint2(str, e2, alphabet.charAt(0));
98741
+ for (i2 = 0, str = ""; i2 <= k; str += alphabet2.charAt(xc[i2++])) ;
98742
+ str = toFixedPoint2(str, e2, alphabet2.charAt(0));
98743
98743
  }
98744
98744
  return str;
98745
98745
  };
@@ -118749,22 +118749,22 @@ function addDecoder(cases, importFn) {
118749
118749
  }
118750
118750
  cases.forEach((c) => registry$1.set(c, importFn));
118751
118751
  }
118752
- addDecoder([void 0, 1], () => import("./raw-B0kbUXDM.js").then((m) => m.default));
118753
- addDecoder(5, () => import("./lzw-Ca5-Jlut.js").then((m) => m.default));
118752
+ addDecoder([void 0, 1], () => import("./raw-AHorMHu9.js").then((m) => m.default));
118753
+ addDecoder(5, () => import("./lzw-C1lHheLz.js").then((m) => m.default));
118754
118754
  addDecoder(6, () => {
118755
118755
  throw new Error("old style JPEG compression is not supported.");
118756
118756
  });
118757
- addDecoder(7, () => import("./jpeg-BLlwFnws.js").then((m) => m.default));
118758
- addDecoder([8, 32946], () => import("./deflate-D12Fo657.js").then((m) => m.default));
118759
- addDecoder(32773, () => import("./packbits-C7_1Qn0w.js").then((m) => m.default));
118757
+ addDecoder(7, () => import("./jpeg-CiAcfEp0.js").then((m) => m.default));
118758
+ addDecoder([8, 32946], () => import("./deflate-BPvXkmfx.js").then((m) => m.default));
118759
+ addDecoder(32773, () => import("./packbits-BIqxBlB6.js").then((m) => m.default));
118760
118760
  addDecoder(
118761
118761
  34887,
118762
- () => import("./lerc-wUMkb2Sa.js").then(async (m) => {
118762
+ () => import("./lerc-FqfyUvxo.js").then(async (m) => {
118763
118763
  await m.zstd.init();
118764
118764
  return m;
118765
118765
  }).then((m) => m.default)
118766
118766
  );
118767
- addDecoder(50001, () => import("./webimage-Nqf6355R.js").then((m) => m.default));
118767
+ addDecoder(50001, () => import("./webimage-BtmRTVwm.js").then((m) => m.default));
118768
118768
  function decodeRowAcc(row, stride) {
118769
118769
  let length2 = row.length - stride;
118770
118770
  let offset2 = 0;
@@ -123352,15 +123352,15 @@ const adler32 = (adler, buf, len2, pos) => {
123352
123352
  };
123353
123353
  var adler32_1 = adler32;
123354
123354
  const makeTable = () => {
123355
- let c, table = [];
123355
+ let c, table2 = [];
123356
123356
  for (var n3 = 0; n3 < 256; n3++) {
123357
123357
  c = n3;
123358
123358
  for (var k = 0; k < 8; k++) {
123359
123359
  c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
123360
123360
  }
123361
- table[n3] = c;
123361
+ table2[n3] = c;
123362
123362
  }
123363
- return table;
123363
+ return table2;
123364
123364
  };
123365
123365
  const crcTable = new Uint32Array(makeTable());
123366
123366
  const crc32 = (crc, buf, len2, pos) => {
@@ -125168,7 +125168,7 @@ const dext = new Uint8Array([
125168
125168
  64,
125169
125169
  64
125170
125170
  ]);
125171
- const inflate_table = (type, lens2, lens_index, codes, table, table_index, work, opts) => {
125171
+ const inflate_table = (type, lens2, lens_index, codes, table2, table_index, work, opts) => {
125172
125172
  const bits = opts.bits;
125173
125173
  let len2 = 0;
125174
125174
  let sym = 0;
@@ -125208,8 +125208,8 @@ const inflate_table = (type, lens2, lens_index, codes, table, table_index, work,
125208
125208
  root2 = max2;
125209
125209
  }
125210
125210
  if (max2 === 0) {
125211
- table[table_index++] = 1 << 24 | 64 << 16 | 0;
125212
- table[table_index++] = 1 << 24 | 64 << 16 | 0;
125211
+ table2[table_index++] = 1 << 24 | 64 << 16 | 0;
125212
+ table2[table_index++] = 1 << 24 | 64 << 16 | 0;
125213
125213
  opts.bits = 1;
125214
125214
  return 0;
125215
125215
  }
@@ -125284,7 +125284,7 @@ const inflate_table = (type, lens2, lens_index, codes, table, table_index, work,
125284
125284
  min2 = fill;
125285
125285
  do {
125286
125286
  fill -= incr;
125287
- table[next2 + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
125287
+ table2[next2 + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
125288
125288
  } while (fill !== 0);
125289
125289
  incr = 1 << len2 - 1;
125290
125290
  while (huff & incr) {
@@ -125323,11 +125323,11 @@ const inflate_table = (type, lens2, lens_index, codes, table, table_index, work,
125323
125323
  return 1;
125324
125324
  }
125325
125325
  low = huff & mask;
125326
- table[low] = root2 << 24 | curr << 16 | next2 - table_index | 0;
125326
+ table2[low] = root2 << 24 | curr << 16 | next2 - table_index | 0;
125327
125327
  }
125328
125328
  }
125329
125329
  if (huff !== 0) {
125330
- table[next2 + huff] = len2 - drop << 24 | 64 << 16 | 0;
125330
+ table2[next2 + huff] = len2 - drop << 24 | 64 << 16 | 0;
125331
125331
  }
125332
125332
  opts.bits = root2;
125333
125333
  return 0;
@@ -127714,13 +127714,13 @@ var blosc_codec = function() {
127714
127714
  }();
127715
127715
  var __isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
127716
127716
  var __toBinary = __isNode ? (base64) => new Uint8Array(Buffer.from(base64, "base64")) : /* @__PURE__ */ (() => {
127717
- var table = new Uint8Array(128);
127718
- for (var i2 = 0; i2 < 64; i2++) table[i2 < 26 ? i2 + 65 : i2 < 52 ? i2 + 71 : i2 < 62 ? i2 - 4 : i2 * 4 - 205] = i2;
127717
+ var table2 = new Uint8Array(128);
127718
+ for (var i2 = 0; i2 < 64; i2++) table2[i2 < 26 ? i2 + 65 : i2 < 52 ? i2 + 71 : i2 < 62 ? i2 - 4 : i2 * 4 - 205] = i2;
127719
127719
  return (base64) => {
127720
127720
  var n3 = base64.length, bytes = new Uint8Array((n3 - (base64[n3 - 1] == "=") - (base64[n3 - 2] == "=")) * 3 / 4 | 0);
127721
127721
  for (var i3 = 0, j = 0; i3 < n3; ) {
127722
- var c0 = table[base64.charCodeAt(i3++)], c1 = table[base64.charCodeAt(i3++)];
127723
- var c2 = table[base64.charCodeAt(i3++)], c3 = table[base64.charCodeAt(i3++)];
127722
+ var c0 = table2[base64.charCodeAt(i3++)], c1 = table2[base64.charCodeAt(i3++)];
127723
+ var c2 = table2[base64.charCodeAt(i3++)], c3 = table2[base64.charCodeAt(i3++)];
127724
127724
  bytes[j++] = c0 << 2 | c1 >> 4;
127725
127725
  bytes[j++] = c1 << 4 | c2 >> 2;
127726
127726
  bytes[j++] = c2 << 6 | c3;
@@ -132829,7 +132829,7 @@ function clone$1(configObject) {
132829
132829
  suffix: ""
132830
132830
  }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
132831
132831
  function BigNumber2(v, b) {
132832
- var alphabet, c, caseChanged, e2, i2, isNum, len2, str, x = this;
132832
+ var alphabet2, c, caseChanged, e2, i2, isNum, len2, str, x = this;
132833
132833
  if (!(x instanceof BigNumber2)) return new BigNumber2(v, b);
132834
132834
  if (b == null) {
132835
132835
  if (v && v._isBigNumber === true) {
@@ -132885,10 +132885,10 @@ function clone$1(configObject) {
132885
132885
  } else {
132886
132886
  x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
132887
132887
  }
132888
- alphabet = ALPHABET.slice(0, b);
132888
+ alphabet2 = ALPHABET.slice(0, b);
132889
132889
  e2 = i2 = 0;
132890
132890
  for (len2 = str.length; i2 < len2; i2++) {
132891
- if (alphabet.indexOf(c = str.charAt(i2)) < 0) {
132891
+ if (alphabet2.indexOf(c = str.charAt(i2)) < 0) {
132892
132892
  if (c == ".") {
132893
132893
  if (i2 > e2) {
132894
132894
  e2 = len2;
@@ -133159,11 +133159,11 @@ function clone$1(configObject) {
133159
133159
  };
133160
133160
  convertBase2 = /* @__PURE__ */ function() {
133161
133161
  var decimal = "0123456789";
133162
- function toBaseOut(str, baseIn, baseOut, alphabet) {
133162
+ function toBaseOut(str, baseIn, baseOut, alphabet2) {
133163
133163
  var j, arr = [0], arrL, i2 = 0, len2 = str.length;
133164
133164
  for (; i2 < len2; ) {
133165
133165
  for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) ;
133166
- arr[0] += alphabet.indexOf(str.charAt(i2++));
133166
+ arr[0] += alphabet2.indexOf(str.charAt(i2++));
133167
133167
  for (j = 0; j < arr.length; j++) {
133168
133168
  if (arr[j] > baseOut - 1) {
133169
133169
  if (arr[j + 1] == null) arr[j + 1] = 0;
@@ -133175,7 +133175,7 @@ function clone$1(configObject) {
133175
133175
  return arr.reverse();
133176
133176
  }
133177
133177
  return function(str, baseIn, baseOut, sign2, callerIsToString) {
133178
- var alphabet, d, e2, k, r2, x, xc, y, i2 = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
133178
+ var alphabet2, d, e2, k, r2, x, xc, y, i2 = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
133179
133179
  if (i2 >= 0) {
133180
133180
  k = POW_PRECISION;
133181
133181
  POW_PRECISION = 0;
@@ -133191,10 +133191,10 @@ function clone$1(configObject) {
133191
133191
  );
133192
133192
  y.e = y.c.length;
133193
133193
  }
133194
- xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
133194
+ xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet2 = ALPHABET, decimal) : (alphabet2 = decimal, ALPHABET));
133195
133195
  e2 = k = xc.length;
133196
133196
  for (; xc[--k] == 0; xc.pop()) ;
133197
- if (!xc[0]) return alphabet.charAt(0);
133197
+ if (!xc[0]) return alphabet2.charAt(0);
133198
133198
  if (i2 < 0) {
133199
133199
  --e2;
133200
133200
  } else {
@@ -133212,7 +133212,7 @@ function clone$1(configObject) {
133212
133212
  r2 = r2 || d < 0 || xc[d + 1] != null;
133213
133213
  r2 = rm < 4 ? (i2 != null || r2) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : i2 > k || i2 == k && (rm == 4 || r2 || rm == 6 && xc[d - 1] & 1 || rm == (x.s < 0 ? 8 : 7));
133214
133214
  if (d < 1 || !xc[0]) {
133215
- str = r2 ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
133215
+ str = r2 ? toFixedPoint(alphabet2.charAt(1), -dp, alphabet2.charAt(0)) : alphabet2.charAt(0);
133216
133216
  } else {
133217
133217
  xc.length = d;
133218
133218
  if (r2) {
@@ -133225,8 +133225,8 @@ function clone$1(configObject) {
133225
133225
  }
133226
133226
  }
133227
133227
  for (k = xc.length; !xc[--k]; ) ;
133228
- for (i2 = 0, str = ""; i2 <= k; str += alphabet.charAt(xc[i2++])) ;
133229
- str = toFixedPoint(str, e2, alphabet.charAt(0));
133228
+ for (i2 = 0, str = ""; i2 <= k; str += alphabet2.charAt(xc[i2++])) ;
133229
+ str = toFixedPoint(str, e2, alphabet2.charAt(0));
133230
133230
  }
133231
133231
  return str;
133232
133232
  };
@@ -143034,13 +143034,13 @@ const parseAddition = (str) => {
143034
143034
  if (!Number.isNaN(+str)) {
143035
143035
  return +str;
143036
143036
  }
143037
- const numbers = str.match(/\d*\.?\d+/g);
143038
- if (!numbers) {
143037
+ const numbers2 = str.match(/\d*\.?\d+/g);
143038
+ if (!numbers2) {
143039
143039
  return 0;
143040
143040
  }
143041
143041
  let sum2 = 0;
143042
- for (let i2 = 0; i2 < numbers.length; i2 += 1) {
143043
- sum2 += +numbers[i2];
143042
+ for (let i2 = 0; i2 < numbers2.length; i2 += 1) {
143043
+ sum2 += +numbers2[i2];
143044
143044
  }
143045
143045
  return sum2;
143046
143046
  };
@@ -146929,6 +146929,13 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
146929
146929
  }
146930
146930
  return result;
146931
146931
  }
146932
+ function getDatasetScale(dataset) {
146933
+ const scales = normalizeCoordinateTransformations(dataset?.coordinateTransformations, null).filter((transform2) => transform2?.type === "scale" && Array.isArray(transform2.scale)).map((transform2) => transform2.scale);
146934
+ if (scales.length === 0) {
146935
+ return void 0;
146936
+ }
146937
+ return scales.reduce((product2, scale2) => product2.map((factor, axis) => factor * scale2[axis]));
146938
+ }
146932
146939
  function coordinateTransformationsToMatrixForSpatialData(ngffMetadata, targetCoordinateSystem) {
146933
146940
  const { datasets, coordinateTransformations, axes } = ngffMetadata;
146934
146941
  const normAxes = normalizeAxes(axes);
@@ -146950,6 +146957,354 @@ function coordinateTransformationsToMatrixForSpatialData(ngffMetadata, targetCoo
146950
146957
  const normalizedTransformations = normalizeCoordinateTransformations(filteredTransformations, datasets);
146951
146958
  return coordinateTransformationsToMatrix(normalizedTransformations, normAxes);
146952
146959
  }
146960
+ const alphabet = "abcdefghijklmnopqrstuvwxyz";
146961
+ const numbers = "01234569789";
146962
+ const expr = "()*/+-";
146963
+ const space = " ";
146964
+ new Set(
146965
+ alphabet + alphabet.toUpperCase() + numbers + expr + space
146966
+ );
146967
+ (() => {
146968
+ var table2 = new Uint8Array(128);
146969
+ for (var i2 = 0; i2 < 64; i2++) {
146970
+ table2[i2 < 26 ? i2 + 65 : i2 < 52 ? i2 + 71 : i2 < 62 ? i2 - 4 : i2 * 4 - 205] = i2;
146971
+ }
146972
+ return (base64) => {
146973
+ var n3 = base64.length;
146974
+ var bytes = new Uint8Array(
146975
+ // @ts-expect-error
146976
+ (n3 - (base64[n3 - 1] == "=") - (base64[n3 - 2] == "=")) * 3 / 4 | 0
146977
+ );
146978
+ for (var i22 = 0, j = 0; i22 < n3; ) {
146979
+ var c0 = table2[base64.charCodeAt(i22++)], c1 = table2[base64.charCodeAt(i22++)];
146980
+ var c2 = table2[base64.charCodeAt(i22++)], c3 = table2[base64.charCodeAt(i22++)];
146981
+ bytes[j++] = c0 << 2 | c1 >> 4;
146982
+ bytes[j++] = c1 << 4 | c2 >> 2;
146983
+ bytes[j++] = c2 << 6 | c3;
146984
+ }
146985
+ return bytes;
146986
+ };
146987
+ })();
146988
+ new TextEncoder();
146989
+ function _structure_size(structure) {
146990
+ const fmt = "<" + Array.from(structure.values()).join("");
146991
+ return struct.calcsize(fmt);
146992
+ }
146993
+ function isBigEndian() {
146994
+ const array = new Uint8Array(4);
146995
+ const view = new Uint32Array(array.buffer);
146996
+ return !((view[0] = 1) & array[0]);
146997
+ }
146998
+ function decodeFloat16(low, high) {
146999
+ const sign2 = (high & 128) >> 7;
147000
+ const exponent = (high & 124) >> 2;
147001
+ const fraction2 = ((high & 3) << 8) + low;
147002
+ let magnitude;
147003
+ if (exponent === 31) {
147004
+ magnitude = fraction2 === 0 ? Infinity : NaN;
147005
+ } else if (exponent === 0) {
147006
+ magnitude = 2 ** -14 * (fraction2 / 1024);
147007
+ } else {
147008
+ magnitude = 2 ** (exponent - 15) * (1 + fraction2 / 1024);
147009
+ }
147010
+ return sign2 ? -magnitude : magnitude;
147011
+ }
147012
+ class DataView64 extends DataView {
147013
+ getFloat16(byteOffset, littleEndian) {
147014
+ const bytes = [this.getUint8(byteOffset), this.getUint8(byteOffset + 1)];
147015
+ if (!littleEndian)
147016
+ bytes.reverse();
147017
+ return decodeFloat16(bytes[0], bytes[1]);
147018
+ }
147019
+ getUint64(byteOffset, littleEndian) {
147020
+ const left = BigInt(this.getUint32(byteOffset, littleEndian));
147021
+ const right = BigInt(this.getUint32(byteOffset + 4, littleEndian));
147022
+ const combined = littleEndian ? left + (right << 32n) : (left << 32n) + right;
147023
+ return Number(combined);
147024
+ }
147025
+ getInt64(byteOffset, littleEndian) {
147026
+ let low, high;
147027
+ if (littleEndian) {
147028
+ low = this.getUint32(byteOffset, true);
147029
+ high = this.getInt32(byteOffset + 4, true);
147030
+ } else {
147031
+ high = this.getInt32(byteOffset, false);
147032
+ low = this.getUint32(byteOffset + 4, false);
147033
+ }
147034
+ const combined = BigInt(low) + (BigInt(high) << 32n);
147035
+ return Number(combined);
147036
+ }
147037
+ getString(byteOffset, _littleEndian, length2) {
147038
+ const str_buffer = this.buffer.slice(byteOffset, byteOffset + length2);
147039
+ return new TextDecoder().decode(str_buffer);
147040
+ }
147041
+ getVLENStruct(byteOffset, littleEndian, _length) {
147042
+ const item_size = this.getUint32(byteOffset, littleEndian);
147043
+ const collection_address = this.getUint64(byteOffset + 4, littleEndian);
147044
+ const object_index = this.getUint32(byteOffset + 12, littleEndian);
147045
+ return [item_size, collection_address, object_index];
147046
+ }
147047
+ }
147048
+ class Struct {
147049
+ big_endian;
147050
+ getters;
147051
+ byte_lengths;
147052
+ fmt_size_regex;
147053
+ constructor() {
147054
+ this.big_endian = isBigEndian();
147055
+ this.getters = {
147056
+ s: "getUint8",
147057
+ b: "getInt8",
147058
+ B: "getUint8",
147059
+ h: "getInt16",
147060
+ H: "getUint16",
147061
+ i: "getInt32",
147062
+ I: "getUint32",
147063
+ l: "getInt32",
147064
+ L: "getUint32",
147065
+ q: "getInt64",
147066
+ Q: "getUint64",
147067
+ e: "getFloat16",
147068
+ f: "getFloat32",
147069
+ d: "getFloat64"
147070
+ };
147071
+ this.byte_lengths = {
147072
+ s: 1,
147073
+ b: 1,
147074
+ B: 1,
147075
+ h: 2,
147076
+ H: 2,
147077
+ i: 4,
147078
+ I: 4,
147079
+ l: 4,
147080
+ L: 4,
147081
+ q: 8,
147082
+ Q: 8,
147083
+ e: 2,
147084
+ f: 4,
147085
+ d: 8
147086
+ };
147087
+ const all_formats = Object.keys(this.byte_lengths).join("");
147088
+ this.fmt_size_regex = "(\\d*)([" + all_formats + "])";
147089
+ }
147090
+ calcsize(fmt) {
147091
+ let size2 = 0;
147092
+ const regex = new RegExp(this.fmt_size_regex, "g");
147093
+ let match2;
147094
+ while ((match2 = regex.exec(fmt)) !== null) {
147095
+ const n3 = parseInt(match2[1] || "1", 10);
147096
+ const f2 = match2[2];
147097
+ size2 += n3 * this.byte_lengths[f2];
147098
+ }
147099
+ return size2;
147100
+ }
147101
+ _is_big_endian(fmt) {
147102
+ if (/^</.test(fmt))
147103
+ return false;
147104
+ if (/^(!|>)/.test(fmt))
147105
+ return true;
147106
+ return this.big_endian;
147107
+ }
147108
+ unpack_from(fmt, buffer, offset2) {
147109
+ offset2 = Number(offset2 || 0);
147110
+ const view = new DataView64(buffer, 0);
147111
+ const output = [];
147112
+ const big_endian = this._is_big_endian(fmt);
147113
+ const regex = new RegExp(this.fmt_size_regex, "g");
147114
+ let match2;
147115
+ while ((match2 = regex.exec(fmt)) !== null) {
147116
+ const n3 = parseInt(match2[1] || "1", 10);
147117
+ const f2 = match2[2];
147118
+ const getter = this.getters[f2];
147119
+ const size2 = this.byte_lengths[f2];
147120
+ if (f2 === "s") {
147121
+ output.push(new TextDecoder().decode(buffer.slice(offset2, offset2 + n3)));
147122
+ offset2 += n3;
147123
+ } else {
147124
+ for (let i2 = 0; i2 < n3; i2++) {
147125
+ output.push(view[getter](offset2, !big_endian));
147126
+ offset2 += size2;
147127
+ }
147128
+ }
147129
+ }
147130
+ return output;
147131
+ }
147132
+ }
147133
+ const struct = new Struct();
147134
+ const DATATYPE_MSG = /* @__PURE__ */ new Map([
147135
+ ["class_and_version", "B"],
147136
+ ["class_bit_field_0", "B"],
147137
+ ["class_bit_field_1", "B"],
147138
+ ["class_bit_field_2", "B"],
147139
+ ["size", "I"]
147140
+ ]);
147141
+ _structure_size(DATATYPE_MSG);
147142
+ const B_LINK_NODE_V1 = /* @__PURE__ */ new Map([
147143
+ ["signature", "4s"],
147144
+ ["node_type", "B"],
147145
+ ["node_level", "B"],
147146
+ ["entries_used", "H"],
147147
+ ["left_sibling", "Q"],
147148
+ ["right_sibling", "Q"]
147149
+ ]);
147150
+ _structure_size(B_LINK_NODE_V1);
147151
+ const B_LINK_NODE_V2 = /* @__PURE__ */ new Map([
147152
+ ["signature", "4s"],
147153
+ ["version", "B"],
147154
+ ["node_type", "B"]
147155
+ ]);
147156
+ _structure_size(B_LINK_NODE_V2);
147157
+ struct.unpack_from("8s", new Uint8Array([137, 72, 68, 70, 13, 10, 26, 10]).buffer)[0];
147158
+ struct.unpack_from("<Q", new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255]).buffer)[0];
147159
+ const SUPERBLOCK_V0 = /* @__PURE__ */ new Map([
147160
+ ["format_signature", "8s"],
147161
+ ["superblock_version", "B"],
147162
+ ["free_storage_version", "B"],
147163
+ ["root_group_version", "B"],
147164
+ ["reserved_0", "B"],
147165
+ ["shared_header_version", "B"],
147166
+ ["offset_size", "B"],
147167
+ ["length_size", "B"],
147168
+ ["reserved_1", "B"],
147169
+ ["group_leaf_node_k", "H"],
147170
+ ["group_internal_node_k", "H"],
147171
+ ["file_consistency_flags", "L"],
147172
+ ["base_address_lower", "Q"],
147173
+ ["free_space_address", "Q"],
147174
+ ["end_of_file_address", "Q"],
147175
+ ["driver_information_address", "Q"]
147176
+ ]);
147177
+ _structure_size(SUPERBLOCK_V0);
147178
+ const SUPERBLOCK_V2_V3 = /* @__PURE__ */ new Map([
147179
+ ["format_signature", "8s"],
147180
+ ["superblock_version", "B"],
147181
+ ["offset_size", "B"],
147182
+ ["length_size", "B"],
147183
+ ["file_consistency_flags", "B"],
147184
+ ["base_address", "Q"],
147185
+ ["superblock_extension_address", "Q"],
147186
+ ["end_of_file_address", "Q"],
147187
+ ["root_group_address", "Q"],
147188
+ ["superblock_checksum", "I"]
147189
+ ]);
147190
+ _structure_size(SUPERBLOCK_V2_V3);
147191
+ const SYMBOL_TABLE_ENTRY = /* @__PURE__ */ new Map([
147192
+ ["link_name_offset", "Q"],
147193
+ ["object_header_address", "Q"],
147194
+ ["cache_type", "I"],
147195
+ ["reserved", "I"],
147196
+ ["scratch", "16s"]
147197
+ ]);
147198
+ _structure_size(SYMBOL_TABLE_ENTRY);
147199
+ const SYMBOL_TABLE_NODE = /* @__PURE__ */ new Map([
147200
+ ["signature", "4s"],
147201
+ ["version", "B"],
147202
+ ["reserved_0", "B"],
147203
+ ["symbols", "H"]
147204
+ ]);
147205
+ _structure_size(SYMBOL_TABLE_NODE);
147206
+ const GLOBAL_HEAP_HEADER = /* @__PURE__ */ new Map([
147207
+ ["signature", "4s"],
147208
+ ["version", "B"],
147209
+ ["reserved", "3s"],
147210
+ ["collection_size", "Q"]
147211
+ ]);
147212
+ _structure_size(GLOBAL_HEAP_HEADER);
147213
+ const GLOBAL_HEAP_OBJECT = /* @__PURE__ */ new Map([
147214
+ ["object_index", "H"],
147215
+ ["reference_count", "H"],
147216
+ ["reserved", "I"],
147217
+ ["object_size", "Q"]
147218
+ ]);
147219
+ _structure_size(GLOBAL_HEAP_OBJECT);
147220
+ const OBJECT_HEADER_V1 = /* @__PURE__ */ new Map([
147221
+ ["version", "B"],
147222
+ ["reserved", "B"],
147223
+ ["total_header_messages", "H"],
147224
+ ["object_reference_count", "I"],
147225
+ ["object_header_size", "I"],
147226
+ ["padding", "I"]
147227
+ ]);
147228
+ _structure_size(OBJECT_HEADER_V1);
147229
+ const OBJECT_HEADER_V2 = /* @__PURE__ */ new Map([
147230
+ ["signature", "4s"],
147231
+ ["version", "B"],
147232
+ ["flags", "B"]
147233
+ ]);
147234
+ _structure_size(OBJECT_HEADER_V2);
147235
+ const HEADER_MSG_INFO_V1 = /* @__PURE__ */ new Map([
147236
+ ["type", "H"],
147237
+ ["size", "H"],
147238
+ ["flags", "B"],
147239
+ ["reserved", "3s"]
147240
+ ]);
147241
+ _structure_size(HEADER_MSG_INFO_V1);
147242
+ const HEADER_MSG_INFO_V2 = /* @__PURE__ */ new Map([
147243
+ ["type", "B"],
147244
+ ["size", "H"],
147245
+ ["flags", "B"]
147246
+ ]);
147247
+ _structure_size(HEADER_MSG_INFO_V2);
147248
+ const ATTR_MSG_HEADER_V1 = /* @__PURE__ */ new Map([
147249
+ ["version", "B"],
147250
+ ["reserved", "B"],
147251
+ ["name_size", "H"],
147252
+ ["datatype_size", "H"],
147253
+ ["dataspace_size", "H"]
147254
+ ]);
147255
+ _structure_size(ATTR_MSG_HEADER_V1);
147256
+ const ATTR_MSG_HEADER_V3 = /* @__PURE__ */ new Map([
147257
+ ["version", "B"],
147258
+ ["flags", "B"],
147259
+ ["name_size", "H"],
147260
+ ["datatype_size", "H"],
147261
+ ["dataspace_size", "H"],
147262
+ ["character_set_encoding", "B"]
147263
+ ]);
147264
+ _structure_size(ATTR_MSG_HEADER_V3);
147265
+ const DATASPACE_MSG_HEADER_V1 = /* @__PURE__ */ new Map([
147266
+ ["version", "B"],
147267
+ ["dimensionality", "B"],
147268
+ ["flags", "B"],
147269
+ ["reserved_0", "B"],
147270
+ ["reserved_1", "I"]
147271
+ ]);
147272
+ _structure_size(DATASPACE_MSG_HEADER_V1);
147273
+ const DATASPACE_MSG_HEADER_V2 = /* @__PURE__ */ new Map([
147274
+ ["version", "B"],
147275
+ ["dimensionality", "B"],
147276
+ ["flags", "B"],
147277
+ ["type", "B"]
147278
+ ]);
147279
+ _structure_size(DATASPACE_MSG_HEADER_V2);
147280
+ const FILLVAL_MSG_V1V2 = /* @__PURE__ */ new Map([
147281
+ ["version", "B"],
147282
+ ["space_allocation_time", "B"],
147283
+ ["fillvalue_write_time", "B"],
147284
+ ["fillvalue_defined", "B"]
147285
+ ]);
147286
+ _structure_size(FILLVAL_MSG_V1V2);
147287
+ const FILLVAL_MSG_V3 = /* @__PURE__ */ new Map([
147288
+ ["version", "B"],
147289
+ ["flags", "B"]
147290
+ ]);
147291
+ _structure_size(FILLVAL_MSG_V3);
147292
+ const FILTER_PIPELINE_DESCR_V1 = /* @__PURE__ */ new Map([
147293
+ ["filter_id", "H"],
147294
+ ["name_length", "H"],
147295
+ ["flags", "H"],
147296
+ ["client_data_values", "H"]
147297
+ ]);
147298
+ _structure_size(FILTER_PIPELINE_DESCR_V1);
147299
+ const GLOBAL_HEAP_ID = /* @__PURE__ */ new Map([
147300
+ ["collection_address", "Q"],
147301
+ ["object_index", "I"]
147302
+ ]);
147303
+ _structure_size(GLOBAL_HEAP_ID);
147304
+ let table = new Uint8Array(128);
147305
+ for (let i2 = 0; i2 < 64; i2++) {
147306
+ table[i2 < 26 ? i2 + 65 : i2 < 52 ? i2 + 71 : i2 < 62 ? i2 - 4 : i2 * 4 - 205] = i2;
147307
+ }
146953
147308
  function getDomains() {
146954
147309
  const domains = {};
146955
147310
  const needMin = ["Int8", "Int16", "Int32"];
@@ -146961,6 +147316,36 @@ function getDomains() {
146961
147316
  return domains;
146962
147317
  }
146963
147318
  getDomains();
147319
+ function getFirstPlaneSelection(labels) {
147320
+ return Object.fromEntries(labels.filter((axis) => axis !== "y" && axis !== "x").map((axis) => [axis, 0]));
147321
+ }
147322
+ async function readTiffTileShape(pixelSource) {
147323
+ const image = await pixelSource._indexer(getFirstPlaneSelection(pixelSource.labels));
147324
+ return [image.getTileHeight(), image.getTileWidth()];
147325
+ }
147326
+ async function readTiffSampleRange(pixelSource) {
147327
+ try {
147328
+ const image = await pixelSource._indexer(getFirstPlaneSelection(pixelSource.labels));
147329
+ const directory = image?.fileDirectory ?? {};
147330
+ const fromTag = (value, reduce) => value === void 0 || typeof value === "number" ? value : reduce(...Array.from(value));
147331
+ let min2 = fromTag(directory.SMinSampleValue, Math.min);
147332
+ let max2 = fromTag(directory.SMaxSampleValue, Math.max);
147333
+ const description = directory.ImageDescription;
147334
+ if (!(Number.isFinite(min2) && Number.isFinite(max2)) && typeof description === "string") {
147335
+ const fromXml = (key) => Number(description.match(new RegExp(`<Key>${key}</Key>\\s*<Value>([^<]*)</Value>`))?.[1]);
147336
+ min2 = fromXml("SMinSampleValue");
147337
+ max2 = fromXml("SMaxSampleValue");
147338
+ }
147339
+ return Number.isFinite(min2) && Number.isFinite(max2) && max2 > min2 ? [min2, max2] : null;
147340
+ } catch (error2) {
147341
+ return null;
147342
+ }
147343
+ }
147344
+ function getOmeroWindow(window2) {
147345
+ const start = window2?.start ?? window2?.min;
147346
+ const end = window2?.end ?? window2?.max;
147347
+ return Number.isFinite(start) && Number.isFinite(end) && end > start ? [start, end] : void 0;
147348
+ }
146964
147349
  class ImageWrapper {
146965
147350
  vivLoader;
146966
147351
  options;
@@ -147240,7 +147625,7 @@ class ImageWrapper {
147240
147625
  return channels2.map((channel, i2) => ({
147241
147626
  name: channel.label || `Channel ${i2}`,
147242
147627
  defaultColor: channel.color ? hexToRgb(channel.color) : void 0,
147243
- defaultWindow: channel.window ? [channel.window.start, channel.window.end] : void 0,
147628
+ defaultWindow: getOmeroWindow(channel.window),
147244
147629
  autoDefaultColor: VIEWER_PALETTE[i2 % VIEWER_PALETTE.length]
147245
147630
  }));
147246
147631
  }
@@ -147407,9 +147792,17 @@ class ImageWrapper {
147407
147792
  ];
147408
147793
  return [xSlice, ySlice, zSlice];
147409
147794
  }
147795
+ /**
147796
+ * Whether the last dimension holds interleaved RGB(A) samples.
147797
+ * viv labels it '_c' (OME-TIFF). When the last label is 'x',
147798
+ * the image is not interleaved, even if it is 3 or 4 pixels wide.
147799
+ */
147410
147800
  isInterleaved() {
147411
147801
  const loader = this.vivLoader;
147412
- const { shape: shape2 } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
147802
+ const { shape: shape2, labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
147803
+ if (labels?.length === shape2.length && labels.at(-1) === "x") {
147804
+ return false;
147805
+ }
147413
147806
  return isInterleaved(shape2);
147414
147807
  }
147415
147808
  getPhotometricInterpretation() {
@@ -147441,25 +147834,106 @@ class ImageWrapper {
147441
147834
  return "BlackIsZero";
147442
147835
  }
147443
147836
  /**
147444
- * Meters per 3D scene unit, i.e. the unit of getModelMatrix().
147445
- * OME-TIFF: physicalSizeToMatrix divides by 1 um, so the scene is in µm
147446
- * (only when physical sizes exist; otherwise pixels, unit unknown → null).
147447
- * OME-Zarr: the model matrix is in the units of the NGFF axes.
147837
+ * The unit of the 3D scene, i.e. of getModelMatrix() and getVoxelSpacing().
147838
+ * OME-TIFF: physicalSizeToMatrix divides by 1 µm, so the scene is in µm,
147839
+ * whatever PhysicalSizeXUnit is (only when physical sizes exist;
147840
+ * otherwise pixels, unit unknown → null).
147841
+ * OME-Zarr: the model matrix is in the units of the NGFF axes, as spelled
147842
+ * there (e.g. 'micrometer').
147448
147843
  */
147449
- getSceneMetersPerUnit() {
147844
+ getSpatialUnit() {
147450
147845
  const { metadata } = this.vivLoader;
147451
147846
  if (!metadata) return null;
147452
147847
  if ("Pixels" in metadata) {
147453
- return this.hasPhysicalSize() ? 1e-6 : null;
147848
+ return this.hasPhysicalSize() ? "µm" : null;
147454
147849
  }
147455
147850
  if ("multiscales" in metadata) {
147456
147851
  const axes = metadata.multiscales?.[0]?.axes ?? [];
147457
147852
  const xAxis = axes.find((a2) => (typeof a2 === "string" ? a2 : a2?.name) === "x");
147458
- const unit2 = typeof xAxis === "object" ? xAxis?.unit : null;
147459
- return unit2 ? UNIT_TO_METERS[unit2.normalize("NFKC")] ?? null : null;
147853
+ return (typeof xAxis === "object" ? xAxis?.unit : null) || null;
147460
147854
  }
147461
147855
  return null;
147462
147856
  }
147857
+ /**
147858
+ * Meters per 3D scene unit, i.e. the unit of getModelMatrix().
147859
+ * Null when the unit is unknown.
147860
+ */
147861
+ getSceneMetersPerUnit() {
147862
+ const unit2 = this.getSpatialUnit();
147863
+ return unit2 ? UNIT_TO_METERS[unit2.normalize("NFKC")] ?? null : null;
147864
+ }
147865
+ /**
147866
+ * Level-0 voxel size, ZYX, in units of getSpatialUnit(): the scale of each
147867
+ * axis of getModelMatrix() (including transforms from the file options),
147868
+ * times the scale of the non-standard root-level coordinateTransformations
147869
+ * that some converted OME-Zarr datasets (e.g. kingsnake, f8ii, melanoma) use
147870
+ * for their physical spacing. getModelMatrix() itself ignores the latter.
147871
+ */
147872
+ getVoxelSpacing() {
147873
+ const modelMatrix2 = this.getModelMatrix();
147874
+ const spacing = [8, 4, 0].map((i2) => Math.hypot(
147875
+ modelMatrix2[i2],
147876
+ modelMatrix2[i2 + 1],
147877
+ modelMatrix2[i2 + 2]
147878
+ ) || 1);
147879
+ const { metadata } = this.vivLoader;
147880
+ const rootScale = metadata?.coordinateTransformations?.find((t) => t?.type === "scale")?.scale;
147881
+ if (Array.isArray(rootScale) && rootScale.length >= 3) {
147882
+ rootScale.slice(-3).forEach((value, axis) => {
147883
+ if (Number.isFinite(value) && value > 0) spacing[axis] *= value;
147884
+ });
147885
+ }
147886
+ return spacing;
147887
+ }
147888
+ /**
147889
+ * Every resolution level as stored, finest first, with its chunk shape
147890
+ * and, for OME-Zarr, the scale of its multiscales dataset.
147891
+ * For OME-TIFF, the chunk is each level's own TIFF tile, read from its TIFF
147892
+ * directory (viv's tileSize is level 0's for every level).
147893
+ */
147894
+ async getResolutionLevels() {
147895
+ const { data, metadata } = this.vivLoader;
147896
+ const pixelSources = Array.isArray(data) ? data : [data];
147897
+ if ("Pixels" in metadata) {
147898
+ return Promise.all(pixelSources.map(async (pixelSource) => {
147899
+ const { shape: shape2, labels, dtype } = pixelSource;
147900
+ const [tileHeight, tileWidth] = await readTiffTileShape(pixelSource);
147901
+ const tileShape = { y: tileHeight, x: tileWidth };
147902
+ return {
147903
+ shape: shape2,
147904
+ labels,
147905
+ dtype,
147906
+ chunks: labels.map((axis) => tileShape[axis] ?? 1),
147907
+ data: pixelSource
147908
+ };
147909
+ }));
147910
+ }
147911
+ const datasets = metadata.multiscales?.[0]?.datasets ?? [];
147912
+ return pixelSources.map((pixelSource, i2) => ({
147913
+ shape: pixelSource.shape,
147914
+ labels: pixelSource.labels,
147915
+ dtype: pixelSource.dtype,
147916
+ chunks: pixelSource._data.chunks,
147917
+ scale: getDatasetScale(datasets[i2]),
147918
+ data: pixelSource._data
147919
+ }));
147920
+ }
147921
+ /**
147922
+ * Value range of each channel from the image metadata, in the order of
147923
+ * getChannelObjects(): its defaultWindow, or for OME-TIFF the sample range
147924
+ * the writer recorded in the TIFF (see readTiffSampleRange), which needs a
147925
+ * read of the first TIFF directory. Undefined for channels without either.
147926
+ */
147927
+ async getChannelWindows() {
147928
+ const windows = this.getChannelObjects().map((channel) => channel.defaultWindow);
147929
+ const { data, metadata } = this.vivLoader;
147930
+ if (!("Pixels" in metadata)) {
147931
+ return windows;
147932
+ }
147933
+ const pixelSource = Array.isArray(data) ? data[0] : data;
147934
+ const sampleRange = await readTiffSampleRange(pixelSource);
147935
+ return sampleRange ? windows.map((window2) => window2 ?? sampleRange) : windows;
147936
+ }
147463
147937
  }
147464
147938
  export {
147465
147939
  BaseDecoder as B,