deck.gl 9.2.0-beta.1 → 9.2.0-beta.3

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.
package/dist/dist.dev.js CHANGED
@@ -1907,7 +1907,7 @@ or create a device with the 'debug: true' prop.`;
1907
1907
  VERSION = (
1908
1908
  // Version detection using build plugin
1909
1909
  // @ts-expect-error no-undef
1910
- true ? "9.2.0-alpha.5" : "running from source"
1910
+ true ? "9.2.0" : "running from source"
1911
1911
  );
1912
1912
  spector;
1913
1913
  preregisteredAdapters = /* @__PURE__ */ new Map();
@@ -2253,6 +2253,13 @@ or create a device with the 'debug: true' prop.`;
2253
2253
  destroy() {
2254
2254
  this.destroyed = true;
2255
2255
  }
2256
+ setProps(props) {
2257
+ if ("useDevicePixels" in props) {
2258
+ this.props.useDevicePixels = props.useDevicePixels || false;
2259
+ this._updateDrawingBufferSize();
2260
+ }
2261
+ return this;
2262
+ }
2256
2263
  // SIZE METHODS
2257
2264
  /**
2258
2265
  * Returns the size covered by the canvas in CSS pixels
@@ -2370,6 +2377,10 @@ or create a device with the 'debug: true' prop.`;
2370
2377
  const [maxDevicePixelWidth, maxDevicePixelHeight] = this.getMaxDrawingBufferSize();
2371
2378
  this.devicePixelWidth = Math.max(1, Math.min(devicePixelWidth, maxDevicePixelWidth));
2372
2379
  this.devicePixelHeight = Math.max(1, Math.min(devicePixelHeight, maxDevicePixelHeight));
2380
+ this._updateDrawingBufferSize();
2381
+ this.device.props.onResize(this, { oldPixelSize });
2382
+ }
2383
+ _updateDrawingBufferSize() {
2373
2384
  if (this.props.autoResize) {
2374
2385
  if (typeof this.props.useDevicePixels === "number") {
2375
2386
  const dpr = this.props.useDevicePixels;
@@ -2384,7 +2395,6 @@ or create a device with the 'debug: true' prop.`;
2384
2395
  this._initializedResolvers.resolve();
2385
2396
  this.isInitialized = true;
2386
2397
  this.updatePosition();
2387
- this.device.props.onResize(this, { oldPixelSize });
2388
2398
  }
2389
2399
  /** Monitor DPR changes */
2390
2400
  _observeDevicePixelRatio() {
@@ -26703,20 +26713,20 @@ void main() {
26703
26713
  return a6[0] * b4[0] + a6[1] * b4[1] + a6[2] * b4[2] + a6[3] * b4[3];
26704
26714
  }
26705
26715
  function cross3(out, u6, v5, w5) {
26706
- const A4 = v5[0] * w5[1] - v5[1] * w5[0];
26707
- const B4 = v5[0] * w5[2] - v5[2] * w5[0];
26708
- const C4 = v5[0] * w5[3] - v5[3] * w5[0];
26709
- const D3 = v5[1] * w5[2] - v5[2] * w5[1];
26710
- const E2 = v5[1] * w5[3] - v5[3] * w5[1];
26711
- const F3 = v5[2] * w5[3] - v5[3] * w5[2];
26712
- const G2 = u6[0];
26716
+ const A5 = v5[0] * w5[1] - v5[1] * w5[0];
26717
+ const B5 = v5[0] * w5[2] - v5[2] * w5[0];
26718
+ const C5 = v5[0] * w5[3] - v5[3] * w5[0];
26719
+ const D4 = v5[1] * w5[2] - v5[2] * w5[1];
26720
+ const E3 = v5[1] * w5[3] - v5[3] * w5[1];
26721
+ const F4 = v5[2] * w5[3] - v5[3] * w5[2];
26722
+ const G3 = u6[0];
26713
26723
  const H2 = u6[1];
26714
26724
  const I3 = u6[2];
26715
26725
  const J2 = u6[3];
26716
- out[0] = H2 * F3 - I3 * E2 + J2 * D3;
26717
- out[1] = -(G2 * F3) + I3 * C4 - J2 * B4;
26718
- out[2] = G2 * E2 - H2 * C4 + J2 * A4;
26719
- out[3] = -(G2 * D3) + H2 * B4 - I3 * A4;
26726
+ out[0] = H2 * F4 - I3 * E3 + J2 * D4;
26727
+ out[1] = -(G3 * F4) + I3 * C5 - J2 * B5;
26728
+ out[2] = G3 * E3 - H2 * C5 + J2 * A5;
26729
+ out[3] = -(G3 * D4) + H2 * B5 - I3 * A5;
26720
26730
  return out;
26721
26731
  }
26722
26732
  function lerp4(out, a6, b4, t5) {
@@ -35714,9 +35724,9 @@ ${fragment}
35714
35724
  }
35715
35725
  function getEclipticLongitude(meanAnomaly) {
35716
35726
  const M3 = meanAnomaly;
35717
- const C4 = DEGREES_TO_RADIANS5 * (1.9148 * Math.sin(M3) + 0.02 * Math.sin(2 * M3) + 3e-4 * Math.sin(3 * M3));
35727
+ const C5 = DEGREES_TO_RADIANS5 * (1.9148 * Math.sin(M3) + 0.02 * Math.sin(2 * M3) + 3e-4 * Math.sin(3 * M3));
35718
35728
  const P3 = DEGREES_TO_RADIANS5 * 102.9372;
35719
- return M3 + C4 + P3 + Math.PI;
35729
+ return M3 + C5 + P3 + Math.PI;
35720
35730
  }
35721
35731
  function getSunCoords(dates) {
35722
35732
  const M3 = getSolarMeanAnomaly(dates);
@@ -43321,7 +43331,7 @@ void main() {
43321
43331
  this.eventManager?.destroy();
43322
43332
  this.canvas = null;
43323
43333
  }
43324
- log_default.log(`recreating animation loop for new device! id=${props.device.id}`);
43334
+ log_default.log(`recreating animation loop for new device! id=${props.device.id}`)();
43325
43335
  this.animationLoop = this._createAnimationLoop(props.device, props);
43326
43336
  this.animationLoop.start();
43327
43337
  }
@@ -47962,17 +47972,17 @@ void main(void) {
47962
47972
  const lambda = lng * DEGREES_TO_RADIANS6;
47963
47973
  const phi = lat * DEGREES_TO_RADIANS6;
47964
47974
  const cosPhi = Math.cos(phi);
47965
- const D3 = (Z2 / EARTH_RADIUS + 1) * GLOBE_RADIUS;
47966
- return [Math.sin(lambda) * cosPhi * D3, -Math.cos(lambda) * cosPhi * D3, Math.sin(phi) * D3];
47975
+ const D4 = (Z2 / EARTH_RADIUS + 1) * GLOBE_RADIUS;
47976
+ return [Math.sin(lambda) * cosPhi * D4, -Math.cos(lambda) * cosPhi * D4, Math.sin(phi) * D4];
47967
47977
  }
47968
47978
  unprojectPosition(xyz) {
47969
47979
  const [x4, y5, z4] = xyz;
47970
- const D3 = vec3_exports.len(xyz);
47971
- const phi = Math.asin(z4 / D3);
47980
+ const D4 = vec3_exports.len(xyz);
47981
+ const phi = Math.asin(z4 / D4);
47972
47982
  const lambda = Math.atan2(x4, -y5);
47973
47983
  const lng = lambda * RADIANS_TO_DEGREES3;
47974
47984
  const lat = phi * RADIANS_TO_DEGREES3;
47975
- const Z2 = (D3 / GLOBE_RADIUS - 1) * EARTH_RADIUS;
47985
+ const Z2 = (D4 / GLOBE_RADIUS - 1) * EARTH_RADIUS;
47976
47986
  return [lng, lat, Z2];
47977
47987
  }
47978
47988
  projectFlat(xyz) {
@@ -56806,12 +56816,12 @@ void main(void) {
56806
56816
  function frob2(a22) {
56807
56817
  return Math.hypot(a22[0], a22[1], a22[2], a22[3]);
56808
56818
  }
56809
- function LDU(L22, D3, U2, a22) {
56819
+ function LDU(L22, D22, U2, a22) {
56810
56820
  L22[2] = a22[2] / a22[0];
56811
56821
  U2[0] = a22[0];
56812
56822
  U2[1] = a22[1];
56813
56823
  U2[3] = a22[3] - L22[2] * U2[1];
56814
- return [L22, D3, U2];
56824
+ return [L22, D22, U2];
56815
56825
  }
56816
56826
  function add7(out, a22, b22) {
56817
56827
  out[0] = a22[0] + b22[0];
@@ -58005,7 +58015,6 @@ void main(void) {
58005
58015
  var PentagonShape = class _PentagonShape {
58006
58016
  constructor(vertices) {
58007
58017
  this.vertices = vertices;
58008
- this.id = { i: 0, j: 0, k: 0, resolution: 1 };
58009
58018
  if (!this.isWindingCorrect()) {
58010
58019
  this.vertices.reverse();
58011
58020
  }
@@ -58076,36 +58085,36 @@ void main(void) {
58076
58085
  return newPentagon;
58077
58086
  }
58078
58087
  getCenter() {
58079
- return this.vertices.reduce(
58080
- (sum2, v22) => [sum2[0] + v22[0] / 5, sum2[1] + v22[1] / 5],
58081
- [0, 0]
58082
- );
58088
+ const n4 = this.vertices.length;
58089
+ const sum2 = this.vertices.reduce((sum22, v22) => [sum22[0] + v22[0] / n4, sum22[1] + v22[1] / n4], [0, 0]);
58090
+ return sum2;
58083
58091
  }
58084
58092
  /**
58085
58093
  * Tests if a point is inside the pentagon by checking if it's on the correct side of all edges.
58086
58094
  * Assumes consistent winding order (counter-clockwise).
58087
58095
  * @param point The point to test
58088
- * @returns -1 if point is inside, otherwise a value proportional to the distance from the point to the edge
58096
+ * @returns 1 if point is inside, otherwise a negative value proportional to the distance from the point to the edge
58089
58097
  */
58090
58098
  containsPoint(point) {
58091
58099
  if (!this.isWindingCorrect()) {
58092
58100
  throw new Error("Pentagon is not counter-clockwise");
58093
58101
  }
58094
58102
  const N3 = this.vertices.length;
58103
+ let dMax = 1;
58095
58104
  for (let i7 = 0; i7 < N3; i7++) {
58096
58105
  const v1 = this.vertices[i7];
58097
58106
  const v22 = this.vertices[(i7 + 1) % N3];
58098
- const dx = v22[0] - v1[0];
58099
- const dy = v22[1] - v1[1];
58107
+ const dx = v1[0] - v22[0];
58108
+ const dy = v1[1] - v22[1];
58100
58109
  const px = point[0] - v1[0];
58101
58110
  const py = point[1] - v1[1];
58102
58111
  const crossProduct = dx * py - dy * px;
58103
- if (crossProduct > 0) {
58112
+ if (crossProduct < 0) {
58104
58113
  const pLength = Math.sqrt(px * px + py * py);
58105
- return crossProduct / pLength;
58114
+ dMax = Math.min(dMax, crossProduct / pLength);
58106
58115
  }
58107
58116
  }
58108
- return -1;
58117
+ return dMax;
58109
58118
  }
58110
58119
  /**
58111
58120
  * Splits each edge of the pentagon into the specified number of segments
@@ -58179,16 +58188,16 @@ void main(void) {
58179
58188
  * @param C Array of coefficients
58180
58189
  * @returns Transformed angle in radians
58181
58190
  */
58182
- applyCoefficients(phi, C4) {
58191
+ applyCoefficients(phi, C22) {
58183
58192
  const sinPhi = Math.sin(phi);
58184
58193
  const cosPhi = Math.cos(phi);
58185
58194
  const X2 = 2 * (cosPhi - sinPhi) * (cosPhi + sinPhi);
58186
58195
  let u0, u1;
58187
- u0 = X2 * C4[5] + C4[4];
58188
- u1 = X2 * u0 + C4[3];
58189
- u0 = X2 * u1 - u0 + C4[2];
58190
- u1 = X2 * u0 - u1 + C4[1];
58191
- u0 = X2 * u1 - u0 + C4[0];
58196
+ u0 = X2 * C22[5] + C22[4];
58197
+ u1 = X2 * u0 + C22[3];
58198
+ u0 = X2 * u1 - u0 + C22[2];
58199
+ u1 = X2 * u0 - u1 + C22[1];
58200
+ u0 = X2 * u1 - u0 + C22[0];
58192
58201
  return phi + 2 * sinPhi * cosPhi * u0;
58193
58202
  }
58194
58203
  /**
@@ -58270,12 +58279,6 @@ void main(void) {
58270
58279
  const latitude = radToDeg(geodeticLat);
58271
58280
  return [longitude, latitude];
58272
58281
  }
58273
- function quatFromSpherical(axis) {
58274
- const cartesian = toCartesian(axis);
58275
- const Q2 = quat_exports.create();
58276
- quat_exports.rotationTo(Q2, [0, 0, 1], cartesian);
58277
- return Q2;
58278
- }
58279
58282
  function normalizeLongitudes(contour) {
58280
58283
  const points = contour.map((lonLat) => toCartesian(fromLonLat(lonLat)));
58281
58284
  const center2 = vec3_exports2.create();
@@ -58298,6 +58301,53 @@ void main(void) {
58298
58301
  });
58299
58302
  }
58300
58303
  common_exports2.setMatrixArrayType(Float64Array);
58304
+ var SQRT5 = Math.sqrt(5);
58305
+ var INV_SQRT5 = Math.sqrt(0.2);
58306
+ var sinAlpha = Math.sqrt((1 - INV_SQRT5) / 2);
58307
+ var cosAlpha = Math.sqrt((1 + INV_SQRT5) / 2);
58308
+ var A2 = 0.5;
58309
+ var B2 = Math.sqrt((2.5 - SQRT5) / 10);
58310
+ var C2 = Math.sqrt((2.5 + SQRT5) / 10);
58311
+ var D2 = Math.sqrt((1 + INV_SQRT5) / 8);
58312
+ var E2 = Math.sqrt((1 - INV_SQRT5) / 8);
58313
+ var F2 = Math.sqrt((3 - SQRT5) / 8);
58314
+ var G2 = Math.sqrt((3 + SQRT5) / 8);
58315
+ var faceCenters = [
58316
+ [0, 0],
58317
+ // Doesn't actually matter as rotation is 0
58318
+ // First ring: five vertices, CCW, multiplied by sinAlpha
58319
+ [sinAlpha, 0],
58320
+ // [cos0, sin0]
58321
+ [B2, A2],
58322
+ // [cos72, sin72]
58323
+ [-D2, F2],
58324
+ // [-cos36, sin36]
58325
+ [-D2, -F2],
58326
+ // [-cos36, -sin36]
58327
+ [B2, -A2],
58328
+ // [cos72, -sin72]
58329
+ // Second ring: the same five vertices but negated (180deg rotation), multiplied by cosAlpha
58330
+ [-cosAlpha, 0],
58331
+ // [-cos0, -sin0]
58332
+ [-E2, -G2],
58333
+ // [-cos72, -sin72]
58334
+ [C2, -A2],
58335
+ // [cos36, -sin36]
58336
+ [C2, A2],
58337
+ // [cos36, sin36]
58338
+ [-E2, G2],
58339
+ // [-cos72, sin72]
58340
+ [0, 0]
58341
+ ];
58342
+ var axes = faceCenters.map(([x4, y5]) => [-y5, x4]);
58343
+ var quaternions = axes.map((axis, i7) => {
58344
+ if (i7 === 0)
58345
+ return [0, 0, 0, 1];
58346
+ if (i7 === 11)
58347
+ return [0, -1, 0, 0];
58348
+ return [...axis, 0, i7 < 6 ? cosAlpha : sinAlpha];
58349
+ });
58350
+ common_exports2.setMatrixArrayType(Float64Array);
58301
58351
  var clockwiseFan = ["vu", "uw", "vw", "vw", "vw"];
58302
58352
  var clockwiseStep = ["wu", "uw", "vw", "vu", "uw"];
58303
58353
  var counterStep = ["wu", "uv", "wv", "wu", "uw"];
@@ -58332,24 +58382,27 @@ void main(void) {
58332
58382
  var ORIGIN_ORDER = [0, 1, 2, 4, 3, 5, 7, 8, 6, 11, 10, 9];
58333
58383
  var origins = [];
58334
58384
  function generateOrigins() {
58335
- addOrigin([0, 0], 0);
58385
+ addOrigin([0, 0], 0, quaternions[0]);
58336
58386
  for (let i7 = 0; i7 < 5; i7++) {
58337
58387
  const alpha = i7 * TWO_PI_OVER_5;
58338
58388
  const alpha2 = alpha + PI_OVER_5;
58339
- addOrigin([alpha, interhedralAngle], PI_OVER_5);
58340
- addOrigin([alpha2, Math.PI - interhedralAngle], PI_OVER_5);
58389
+ addOrigin([alpha, interhedralAngle], PI_OVER_5, quaternions[i7 + 1]);
58390
+ addOrigin([alpha2, Math.PI - interhedralAngle], PI_OVER_5, quaternions[(i7 + 3) % 5 + 6]);
58341
58391
  }
58342
- addOrigin([0, Math.PI], 0);
58392
+ addOrigin([0, Math.PI], 0, quaternions[11]);
58343
58393
  }
58344
58394
  var originId = 0;
58345
- function addOrigin(axis, angle32) {
58395
+ function addOrigin(axis, angle32, quaternion) {
58346
58396
  if (originId > 11) {
58347
58397
  throw new Error(`Too many origins: ${originId}`);
58348
58398
  }
58399
+ const inverseQuat = quat_exports.create();
58400
+ quat_exports.conjugate(inverseQuat, quaternion);
58349
58401
  const origin = {
58350
58402
  id: originId,
58351
58403
  axis,
58352
- quat: quatFromSpherical(axis),
58404
+ quat: quaternion,
58405
+ inverseQuat,
58353
58406
  angle: angle32,
58354
58407
  orientation: QUINTANT_ORIENTATIONS[originId],
58355
58408
  firstQuintant: QUINTANT_FIRST[originId]
@@ -58390,39 +58443,39 @@ void main(void) {
58390
58443
  var crossCD = vec3_exports2.create();
58391
58444
  var scaledA = vec3_exports2.create();
58392
58445
  var scaledB = vec3_exports2.create();
58393
- function vectorDifference(A4, B4) {
58394
- vec3_exports2.lerp(midpointAB, A4, B4, 0.5);
58446
+ function vectorDifference(A22, B22) {
58447
+ vec3_exports2.lerp(midpointAB, A22, B22, 0.5);
58395
58448
  vec3_exports2.normalize(midpointAB, midpointAB);
58396
- vec3_exports2.cross(midpointAB, A4, midpointAB);
58397
- const D3 = vec3_exports2.length(midpointAB);
58398
- if (D3 < 1e-8) {
58399
- const AB = vec3_exports2.subtract(vec3_exports2.create(), A4, B4);
58449
+ vec3_exports2.cross(midpointAB, A22, midpointAB);
58450
+ const D22 = vec3_exports2.length(midpointAB);
58451
+ if (D22 < 1e-8) {
58452
+ const AB = vec3_exports2.subtract(vec3_exports2.create(), A22, B22);
58400
58453
  const halfDistance = 0.5 * vec3_exports2.length(AB);
58401
58454
  return halfDistance;
58402
58455
  }
58403
- return D3;
58456
+ return D22;
58404
58457
  }
58405
- function tripleProduct(A4, B4, C4) {
58406
- vec3_exports2.cross(crossCD, B4, C4);
58407
- return vec3_exports2.dot(A4, crossCD);
58458
+ function tripleProduct(A22, B22, C22) {
58459
+ vec3_exports2.cross(crossCD, B22, C22);
58460
+ return vec3_exports2.dot(A22, crossCD);
58408
58461
  }
58409
- function quadrupleProduct(out, A4, B4, C4, D3) {
58410
- vec3_exports2.cross(crossCD, C4, D3);
58411
- const tripleProductACD = vec3_exports2.dot(A4, crossCD);
58412
- const tripleProductBCD = vec3_exports2.dot(B4, crossCD);
58413
- vec3_exports2.scale(scaledA, A4, tripleProductBCD);
58414
- vec3_exports2.scale(scaledB, B4, tripleProductACD);
58462
+ function quadrupleProduct(out, A22, B22, C22, D22) {
58463
+ vec3_exports2.cross(crossCD, C22, D22);
58464
+ const tripleProductACD = vec3_exports2.dot(A22, crossCD);
58465
+ const tripleProductBCD = vec3_exports2.dot(B22, crossCD);
58466
+ vec3_exports2.scale(scaledA, A22, tripleProductBCD);
58467
+ vec3_exports2.scale(scaledB, B22, tripleProductACD);
58415
58468
  return vec3_exports2.sub(out, scaledB, scaledA);
58416
58469
  }
58417
- function slerp22(out, A4, B4, t5) {
58418
- const gamma = vec3_exports2.angle(A4, B4);
58470
+ function slerp22(out, A22, B22, t5) {
58471
+ const gamma = vec3_exports2.angle(A22, B22);
58419
58472
  if (gamma < 1e-12) {
58420
- return vec3_exports2.lerp(out, A4, B4, t5);
58473
+ return vec3_exports2.lerp(out, A22, B22, t5);
58421
58474
  }
58422
58475
  const weightA = Math.sin((1 - t5) * gamma) / Math.sin(gamma);
58423
58476
  const weightB = Math.sin(t5 * gamma) / Math.sin(gamma);
58424
- const scaledA2 = vec3_exports2.scale(vec3_exports2.create(), A4, weightA);
58425
- const scaledB2 = vec3_exports2.scale(vec3_exports2.create(), B4, weightB);
58477
+ const scaledA2 = vec3_exports2.scale(vec3_exports2.create(), A22, weightA);
58478
+ const scaledB2 = vec3_exports2.scale(vec3_exports2.create(), B22, weightB);
58426
58479
  return vec3_exports2.add(out, scaledA2, scaledB2);
58427
58480
  }
58428
58481
  common_exports2.setMatrixArrayType(Float64Array);
@@ -58589,19 +58642,19 @@ void main(void) {
58589
58642
  * @returns The face coordinates
58590
58643
  */
58591
58644
  forward(v22, sphericalTriangle, faceTriangle) {
58592
- const [A4, B4, C4] = sphericalTriangle;
58593
- const triangleShape = new SphericalTriangleShape([A4, B4, C4]);
58594
- const Z2 = vec3_exports2.subtract(vec3_exports2.create(), v22, A4);
58645
+ const [A22, B22, C22] = sphericalTriangle;
58646
+ const triangleShape = new SphericalTriangleShape([A22, B22, C22]);
58647
+ const Z2 = vec3_exports2.subtract(vec3_exports2.create(), v22, A22);
58595
58648
  vec3_exports2.normalize(Z2, Z2);
58596
- const p5 = quadrupleProduct(vec3_exports2.create(), A4, Z2, B4, C4);
58649
+ const p5 = quadrupleProduct(vec3_exports2.create(), A22, Z2, B22, C22);
58597
58650
  vec3_exports2.normalize(p5, p5);
58598
- const h5 = vectorDifference(A4, v22) / vectorDifference(A4, p5);
58651
+ const h5 = vectorDifference(A22, v22) / vectorDifference(A22, p5);
58599
58652
  const Area_ABC = triangleShape.getArea();
58600
58653
  const scaledArea = h5 / Area_ABC;
58601
58654
  const b22 = [
58602
58655
  1 - h5,
58603
- scaledArea * new SphericalTriangleShape([A4, p5, C4]).getArea(),
58604
- scaledArea * new SphericalTriangleShape([A4, B4, p5]).getArea()
58656
+ scaledArea * new SphericalTriangleShape([A22, p5, C22]).getArea(),
58657
+ scaledArea * new SphericalTriangleShape([A22, B22, p5]).getArea()
58605
58658
  ];
58606
58659
  return barycentricToFace(b22, faceTriangle);
58607
58660
  }
@@ -58613,18 +58666,18 @@ void main(void) {
58613
58666
  * @returns The spherical coordinates
58614
58667
  */
58615
58668
  inverse(facePoint, faceTriangle, sphericalTriangle) {
58616
- const [A4, B4, C4] = sphericalTriangle;
58617
- const triangleShape = new SphericalTriangleShape([A4, B4, C4]);
58669
+ const [A22, B22, C22] = sphericalTriangle;
58670
+ const triangleShape = new SphericalTriangleShape([A22, B22, C22]);
58618
58671
  const b22 = faceToBarycentric(facePoint, faceTriangle);
58619
58672
  const threshold2 = 1 - 1e-14;
58620
58673
  if (b22[0] > threshold2)
58621
- return A4;
58674
+ return A22;
58622
58675
  if (b22[1] > threshold2)
58623
- return B4;
58676
+ return B22;
58624
58677
  if (b22[2] > threshold2)
58625
- return C4;
58678
+ return C22;
58626
58679
  const c1 = vec3_exports2.create();
58627
- vec3_exports2.cross(c1, B4, C4);
58680
+ vec3_exports2.cross(c1, B22, C22);
58628
58681
  const Area_ABC = triangleShape.getArea();
58629
58682
  const h5 = 1 - b22[0];
58630
58683
  const R2 = b22[2] / h5;
@@ -58632,18 +58685,18 @@ void main(void) {
58632
58685
  const S3 = Math.sin(alpha);
58633
58686
  const halfC = Math.sin(alpha / 2);
58634
58687
  const CC = 2 * halfC * halfC;
58635
- const c01 = vec3_exports2.dot(A4, B4);
58636
- const c12 = vec3_exports2.dot(B4, C4);
58637
- const c20 = vec3_exports2.dot(C4, A4);
58688
+ const c01 = vec3_exports2.dot(A22, B22);
58689
+ const c12 = vec3_exports2.dot(B22, C22);
58690
+ const c20 = vec3_exports2.dot(C22, A22);
58638
58691
  const s12 = vec3_exports2.length(c1);
58639
- const V22 = vec3_exports2.dot(A4, c1);
58692
+ const V22 = vec3_exports2.dot(A22, c1);
58640
58693
  const f6 = S3 * V22 + CC * (c01 * c12 - c20);
58641
58694
  const g3 = CC * s12 * (1 + c01);
58642
58695
  const q3 = 2 / Math.acos(c12) * Math.atan2(g3, f6);
58643
- const P3 = slerp22(vec3_exports2.create(), B4, C4, q3);
58644
- const K2 = vectorDifference(A4, P3);
58696
+ const P3 = slerp22(vec3_exports2.create(), B22, C22, q3);
58697
+ const K2 = vectorDifference(A22, P3);
58645
58698
  const t5 = this.safeAcos(h5 * K2) / this.safeAcos(K2);
58646
- const out = slerp22([0, 0, 0], A4, P3, t5);
58699
+ const out = slerp22([0, 0, 0], A22, P3, t5);
58647
58700
  return out;
58648
58701
  }
58649
58702
  /**
@@ -58715,10 +58768,10 @@ void main(void) {
58715
58768
  return;
58716
58769
  const parentK = digits[i7] || 0;
58717
58770
  const childK = digits[i7 - 1];
58718
- const F3 = flips[0] + flips[1];
58771
+ const F22 = flips[0] + flips[1];
58719
58772
  let needsShift = true;
58720
58773
  let first = true;
58721
- if (invertJ !== (F3 === 0)) {
58774
+ if (invertJ !== (F22 === 0)) {
58722
58775
  needsShift = parentK === 1 || parentK === 2;
58723
58776
  first = parentK === 1;
58724
58777
  } else {
@@ -58800,11 +58853,11 @@ void main(void) {
58800
58853
  pentagon.rotate180();
58801
58854
  }
58802
58855
  const { k: k4 } = anchor;
58803
- const F3 = anchor.flips[0] + anchor.flips[1];
58856
+ const F22 = anchor.flips[0] + anchor.flips[1];
58804
58857
  if (
58805
58858
  // Orient last two pentagons when both or neither flips are YES
58806
- (F3 === -2 || F3 === 2) && k4 > 1 || // Orient first & last pentagons when only one of flips is YES
58807
- F3 === 0 && (k4 === 0 || k4 === 3)
58859
+ (F22 === -2 || F22 === 2) && k4 > 1 || // Orient first & last pentagons when only one of flips is YES
58860
+ F22 === 0 && (k4 === 0 || k4 === 3)
58808
58861
  ) {
58809
58862
  pentagon.reflectY();
58810
58863
  }
@@ -58911,16 +58964,15 @@ void main(void) {
58911
58964
  forward(spherical, originId2) {
58912
58965
  const origin = origins[originId2];
58913
58966
  const unprojected = toCartesian(spherical);
58914
- const inverseQuat = quat_exports.create();
58915
- quat_exports.invert(inverseQuat, origin.quat);
58916
58967
  const out = vec3_exports2.create();
58917
- vec3_exports2.transformQuat(out, unprojected, inverseQuat);
58968
+ vec3_exports2.transformQuat(out, unprojected, origin.inverseQuat);
58918
58969
  const projectedSpherical = toSpherical(out);
58919
58970
  const polar = this.gnomonic.forward(projectedSpherical);
58920
58971
  polar[1] = polar[1] - origin.angle;
58921
58972
  const faceTriangleIndex = this.getFaceTriangleIndex(polar);
58922
- let faceTriangle = this.getFaceTriangle(faceTriangleIndex);
58923
- let sphericalTriangle = this.getSphericalTriangle(faceTriangleIndex, originId2, false);
58973
+ const reflect = this.shouldReflect(polar);
58974
+ let faceTriangle = this.getFaceTriangle(faceTriangleIndex, reflect, false);
58975
+ let sphericalTriangle = this.getSphericalTriangle(faceTriangleIndex, originId2, reflect);
58924
58976
  return this.polyhedral.forward(unprojected, sphericalTriangle, faceTriangle);
58925
58977
  }
58926
58978
  /**
@@ -58932,14 +58984,26 @@ void main(void) {
58932
58984
  inverse(face, originId2) {
58933
58985
  const polar = toPolar(face);
58934
58986
  const faceTriangleIndex = this.getFaceTriangleIndex(polar);
58935
- const [rho, gamma] = polar;
58936
- const D3 = toFace([rho, this.normalizeGamma(gamma)])[0];
58937
- const reflect = D3 > distanceToEdge;
58987
+ const reflect = this.shouldReflect(polar);
58938
58988
  const faceTriangle = this.getFaceTriangle(faceTriangleIndex, reflect, false);
58939
- let sphericalTriangle = this.getSphericalTriangle(faceTriangleIndex, originId2, reflect);
58989
+ const sphericalTriangle = this.getSphericalTriangle(faceTriangleIndex, originId2, reflect);
58940
58990
  const unprojected = this.polyhedral.inverse(face, faceTriangle, sphericalTriangle);
58941
58991
  return toSpherical(unprojected);
58942
58992
  }
58993
+ /**
58994
+ * Detects when point is beyond the edge of the dodecahedron face
58995
+ * In the standard case (reflect = false), the face and spherical triangle can be
58996
+ * used directly.
58997
+ * In the reflected case (reflect = true), the point is beyond the edge of the dodecahedron face,
58998
+ * and so the face triangle is squashed to unproject correctly onto the neighboring dodecahedron face.
58999
+ * @param polar Polar coordinates
59000
+ * @returns True if point is beyond the edge of the dodecahedron face
59001
+ */
59002
+ shouldReflect(polar) {
59003
+ const [rho, gamma] = polar;
59004
+ const D22 = toFace([rho, this.normalizeGamma(gamma)])[0];
59005
+ return D22 > distanceToEdge;
59006
+ }
58943
59007
  /**
58944
59008
  * Given a polar coordinate, returns the index of the face triangle it belongs to
58945
59009
  * @param polar Polar coordinates
@@ -58974,12 +59038,12 @@ void main(void) {
58974
59038
  return even ? [vCenter, vEdgeMidpoint, vCorner1] : [vCenter, vCorner2, vEdgeMidpoint];
58975
59039
  }
58976
59040
  _getReflectedFaceTriangle(faceTriangleIndex, squashed = false) {
58977
- let [A4, B4, C4] = this._getFaceTriangle(faceTriangleIndex).map((face) => vec2_exports2.clone(face));
59041
+ let [A22, B22, C22] = this._getFaceTriangle(faceTriangleIndex).map((face) => vec2_exports2.clone(face));
58978
59042
  const even = faceTriangleIndex % 2 === 0;
58979
- vec2_exports2.negate(A4, A4);
58980
- const midpoint = even ? B4 : C4;
58981
- vec2_exports2.scaleAndAdd(A4, A4, midpoint, squashed ? 1 + 1 / Math.cos(interhedralAngle) : 2);
58982
- return [A4, C4, B4];
59043
+ vec2_exports2.negate(A22, A22);
59044
+ const midpoint = even ? B22 : C22;
59045
+ vec2_exports2.scaleAndAdd(A22, A22, midpoint, squashed ? 1 + 1 / Math.cos(interhedralAngle) : 2);
59046
+ return [A22, C22, B22];
58983
59047
  }
58984
59048
  /**
58985
59049
  * Gets the spherical triangle for a given face triangle index and origin
@@ -59097,7 +59161,7 @@ void main(void) {
59097
59161
  normalizedBoundary.reverse();
59098
59162
  return normalizedBoundary;
59099
59163
  }
59100
- function hexToBigInt(hex) {
59164
+ function hexToU64(hex) {
59101
59165
  return BigInt(`0x${hex}`);
59102
59166
  }
59103
59167
  var AUTHALIC_RADIUS = 63710072e-1;
@@ -59166,7 +59230,7 @@ void main(void) {
59166
59230
  getPolygon: (x4, objectInfo) => {
59167
59231
  const pentagon = getPentagon(x4, objectInfo);
59168
59232
  const boundary = cellToBoundary(
59169
- typeof pentagon === "string" ? hexToBigInt(pentagon) : pentagon,
59233
+ typeof pentagon === "string" ? hexToU64(pentagon) : pentagon,
59170
59234
  { closedRing: true, segments: "auto" }
59171
59235
  );
59172
59236
  return flattenPolygon(boundary);
@@ -61944,7 +62008,7 @@ void main(void) {
61944
62008
  return this._frameNumber;
61945
62009
  }
61946
62010
  // eslint-disable-next-line complexity
61947
- isTileVisible(tile, cullRect) {
62011
+ isTileVisible(tile, cullRect, modelMatrix2) {
61948
62012
  if (!tile.isVisible) {
61949
62013
  return false;
61950
62014
  }
@@ -61954,12 +62018,19 @@ void main(void) {
61954
62018
  z: this._zRange,
61955
62019
  cullRect
61956
62020
  });
61957
- const { bbox } = tile;
62021
+ let { bbox } = tile;
61958
62022
  for (const [minX, minY, maxX, maxY] of boundsArr) {
61959
62023
  let overlaps;
61960
62024
  if ("west" in bbox) {
61961
62025
  overlaps = bbox.west < maxX && bbox.east > minX && bbox.south < maxY && bbox.north > minY;
61962
62026
  } else {
62027
+ if (modelMatrix2 && !Matrix4.IDENTITY.equals(modelMatrix2)) {
62028
+ const [left, top, right, bottom] = transformBox(
62029
+ [bbox.left, bbox.top, bbox.right, bbox.bottom],
62030
+ modelMatrix2
62031
+ );
62032
+ bbox = { left, top, right, bottom };
62033
+ }
61963
62034
  const y0 = Math.min(bbox.top, bbox.bottom);
61964
62035
  const y1 = Math.max(bbox.top, bbox.bottom);
61965
62036
  overlaps = bbox.left < maxX && bbox.right > minX && y0 < maxY && y1 > minY;
@@ -62389,7 +62460,12 @@ void main(void) {
62389
62460
  }
62390
62461
  filterSubLayer({ layer, cullRect }) {
62391
62462
  const { tile } = layer.props;
62392
- return this.state.tileset.isTileVisible(tile, cullRect);
62463
+ const { modelMatrix: modelMatrix2 } = this.props;
62464
+ return this.state.tileset.isTileVisible(
62465
+ tile,
62466
+ cullRect,
62467
+ modelMatrix2 ? new Matrix4(modelMatrix2) : null
62468
+ );
62393
62469
  }
62394
62470
  };
62395
62471
  TileLayer.defaultProps = defaultProps24;
@@ -89182,16 +89258,16 @@ void main(void) {
89182
89258
  const region = getS2Region(s2cell);
89183
89259
  const W3 = region.west;
89184
89260
  const S3 = region.south;
89185
- const E2 = region.east;
89261
+ const E3 = region.east;
89186
89262
  const N3 = region.north;
89187
89263
  const points = [];
89188
89264
  points.push(new Vector37(W3, N3, min7));
89189
- points.push(new Vector37(E2, N3, min7));
89190
- points.push(new Vector37(E2, S3, min7));
89265
+ points.push(new Vector37(E3, N3, min7));
89266
+ points.push(new Vector37(E3, S3, min7));
89191
89267
  points.push(new Vector37(W3, S3, min7));
89192
89268
  points.push(new Vector37(W3, N3, max7));
89193
- points.push(new Vector37(E2, N3, max7));
89194
- points.push(new Vector37(E2, S3, max7));
89269
+ points.push(new Vector37(E3, N3, max7));
89270
+ points.push(new Vector37(E3, S3, max7));
89195
89271
  points.push(new Vector37(W3, S3, max7));
89196
89272
  return points;
89197
89273
  }
@@ -94114,7 +94190,9 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
94114
94190
  return { ...parameters2, depthCompare: "always" };
94115
94191
  }
94116
94192
  getShaderModuleProps(layer, effects, otherShaderModuleProps) {
94193
+ const base = super.getShaderModuleProps(layer, effects, otherShaderModuleProps);
94117
94194
  return {
94195
+ ...base,
94118
94196
  terrain: {
94119
94197
  project: otherShaderModuleProps.project
94120
94198
  }
@@ -100947,6 +101025,10 @@ void main() {
100947
101025
  if (changeFlags.dataChanged || changeFlags.boundsChanged) {
100948
101026
  clearTimeout(this.state.updateTimer);
100949
101027
  this.setState({ isWeightMapDirty: true });
101028
+ if (changeFlags.dataChanged) {
101029
+ const weightsTransformShaders = this.getShaders({ vs: weights_vs_glsl_default, fs: weights_fs_glsl_default });
101030
+ this._createWeightsTransform(weightsTransformShaders);
101031
+ }
100950
101032
  } else if (changeFlags.viewportZoomChanged) {
100951
101033
  this._debouncedUpdateWeightmap();
100952
101034
  }
@@ -101204,17 +101286,13 @@ void main() {
101204
101286
  const { colorRange } = opts.props;
101205
101287
  let { colorTexture } = this.state;
101206
101288
  const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
101207
- if (colorTexture && colorTexture?.width === colorRange.length) {
101208
- colorTexture.setTexture2DData({ data: colors });
101209
- } else {
101210
- colorTexture?.destroy();
101211
- colorTexture = this.context.device.createTexture({
101212
- ...TEXTURE_PROPS,
101213
- data: colors,
101214
- width: colorRange.length,
101215
- height: 1
101216
- });
101217
- }
101289
+ colorTexture?.destroy();
101290
+ colorTexture = this.context.device.createTexture({
101291
+ ...TEXTURE_PROPS,
101292
+ data: colors,
101293
+ width: colorRange.length,
101294
+ height: 1
101295
+ });
101218
101296
  this.setState({ colorTexture });
101219
101297
  }
101220
101298
  _updateWeightmap() {
@@ -102104,6 +102182,12 @@ void main() {
102104
102182
  constructor(props) {
102105
102183
  this._handleStyleChange = () => {
102106
102184
  resolveLayers(this._map, this._deck, this._props.layers, this._props.layers);
102185
+ if (!this._map)
102186
+ return;
102187
+ const projection = getProjection(this._map);
102188
+ if (projection && !this._props.views) {
102189
+ this._deck?.setProps({ views: getDefaultView(this._map) });
102190
+ }
102107
102191
  };
102108
102192
  this._updateContainerSize = () => {
102109
102193
  if (this._map && this._container) {
@@ -102383,7 +102467,7 @@ void main() {
102383
102467
  return u6.__e;
102384
102468
  return "function" == typeof n4.type ? x3(n4) : null;
102385
102469
  }
102386
- function C2(n4) {
102470
+ function C3(n4) {
102387
102471
  var l5, u6;
102388
102472
  if (null != (n4 = n4.__) && null != n4.__c) {
102389
102473
  for (n4.__e = n4.__c.base = null, l5 = 0; l5 < n4.__k.length; l5++)
@@ -102391,7 +102475,7 @@ void main() {
102391
102475
  n4.__e = n4.__c.base = u6.__e;
102392
102476
  break;
102393
102477
  }
102394
- return C2(n4);
102478
+ return C3(n4);
102395
102479
  }
102396
102480
  }
102397
102481
  function M2(n4) {
@@ -102400,7 +102484,7 @@ void main() {
102400
102484
  function P2() {
102401
102485
  var n4, u6, t5, o5, r5, e6, c5, s5;
102402
102486
  for (i4.sort(f3); n4 = i4.shift(); )
102403
- n4.__d && (u6 = i4.length, o5 = void 0, e6 = (r5 = (t5 = n4).__v).__e, c5 = [], s5 = [], t5.__P && ((o5 = d3({}, r5)).__v = r5.__v + 1, l3.vnode && l3.vnode(o5), O2(t5.__P, o5, r5, t5.__n, t5.__P.namespaceURI, 32 & r5.__u ? [e6] : null, c5, null == e6 ? x3(r5) : e6, !!(32 & r5.__u), s5), o5.__v = r5.__v, o5.__.__k[o5.__i] = o5, j2(c5, o5, s5), o5.__e != e6 && C2(o5)), i4.length > u6 && i4.sort(f3));
102487
+ n4.__d && (u6 = i4.length, o5 = void 0, e6 = (r5 = (t5 = n4).__v).__e, c5 = [], s5 = [], t5.__P && ((o5 = d3({}, r5)).__v = r5.__v + 1, l3.vnode && l3.vnode(o5), O2(t5.__P, o5, r5, t5.__n, t5.__P.namespaceURI, 32 & r5.__u ? [e6] : null, c5, null == e6 ? x3(r5) : e6, !!(32 & r5.__u), s5), o5.__v = r5.__v, o5.__.__k[o5.__i] = o5, j2(c5, o5, s5), o5.__e != e6 && C3(o5)), i4.length > u6 && i4.sort(f3));
102404
102488
  P2.__r = 0;
102405
102489
  }
102406
102490
  function S2(n4, l5, u6, t5, i7, o5, r5, f6, e6, c5, s5) {
@@ -102452,7 +102536,7 @@ void main() {
102452
102536
  function T2(n4, l5, u6) {
102453
102537
  "-" === l5[0] ? n4.setProperty(l5, null == u6 ? "" : u6) : n4[l5] = null == u6 ? "" : "number" != typeof u6 || v3.test(l5) ? u6 : u6 + "px";
102454
102538
  }
102455
- function A2(n4, l5, u6, t5, i7) {
102539
+ function A3(n4, l5, u6, t5, i7) {
102456
102540
  var o5;
102457
102541
  n:
102458
102542
  if ("style" === l5)
@@ -102480,7 +102564,7 @@ void main() {
102480
102564
  "function" == typeof u6 || (null == u6 || false === u6 && "-" !== l5[4] ? n4.removeAttribute(l5) : n4.setAttribute(l5, "popover" == l5 && 1 == u6 ? "" : u6));
102481
102565
  }
102482
102566
  }
102483
- function F2(n4) {
102567
+ function F3(n4) {
102484
102568
  return function(u6) {
102485
102569
  if (this.l) {
102486
102570
  var t5 = this.l[u6.type + n4];
@@ -102493,14 +102577,14 @@ void main() {
102493
102577
  };
102494
102578
  }
102495
102579
  function O2(n4, u6, t5, i7, o5, r5, f6, e6, c5, s5) {
102496
- var a6, h5, p5, v5, w5, _3, g3, m3, x4, C4, M3, P3, $3, I3, H2, L4, T4 = u6.type;
102580
+ var a6, h5, p5, v5, w5, _3, g3, m3, x4, C5, M3, P3, $3, I3, H2, L4, T4 = u6.type;
102497
102581
  if (void 0 !== u6.constructor)
102498
102582
  return null;
102499
102583
  128 & t5.__u && (c5 = !!(32 & t5.__u), r5 = [e6 = u6.__e = t5.__e]), (a6 = l3.__b) && a6(u6);
102500
102584
  n:
102501
102585
  if ("function" == typeof T4)
102502
102586
  try {
102503
- if (m3 = u6.props, x4 = "prototype" in T4 && T4.prototype.render, C4 = (a6 = T4.contextType) && i7[a6.__c], M3 = a6 ? C4 ? C4.props.value : a6.__ : i7, t5.__c ? g3 = (h5 = u6.__c = t5.__c).__ = h5.__E : (x4 ? u6.__c = h5 = new T4(m3, M3) : (u6.__c = h5 = new b3(m3, M3), h5.constructor = T4, h5.render = q2), C4 && C4.sub(h5), h5.props = m3, h5.state || (h5.state = {}), h5.context = M3, h5.__n = i7, p5 = h5.__d = true, h5.__h = [], h5._sb = []), x4 && null == h5.__s && (h5.__s = h5.state), x4 && null != T4.getDerivedStateFromProps && (h5.__s == h5.state && (h5.__s = d3({}, h5.__s)), d3(h5.__s, T4.getDerivedStateFromProps(m3, h5.__s))), v5 = h5.props, w5 = h5.state, h5.__v = u6, p5)
102587
+ if (m3 = u6.props, x4 = "prototype" in T4 && T4.prototype.render, C5 = (a6 = T4.contextType) && i7[a6.__c], M3 = a6 ? C5 ? C5.props.value : a6.__ : i7, t5.__c ? g3 = (h5 = u6.__c = t5.__c).__ = h5.__E : (x4 ? u6.__c = h5 = new T4(m3, M3) : (u6.__c = h5 = new b3(m3, M3), h5.constructor = T4, h5.render = q2), C5 && C5.sub(h5), h5.props = m3, h5.state || (h5.state = {}), h5.context = M3, h5.__n = i7, p5 = h5.__d = true, h5.__h = [], h5._sb = []), x4 && null == h5.__s && (h5.__s = h5.state), x4 && null != T4.getDerivedStateFromProps && (h5.__s == h5.state && (h5.__s = d3({}, h5.__s)), d3(h5.__s, T4.getDerivedStateFromProps(m3, h5.__s))), v5 = h5.props, w5 = h5.state, h5.__v = u6, p5)
102504
102588
  x4 && null == T4.getDerivedStateFromProps && null != h5.componentWillMount && h5.componentWillMount(), x4 && null != h5.componentDidMount && h5.__h.push(h5.componentDidMount);
102505
102589
  else {
102506
102590
  if (x4 && null == T4.getDerivedStateFromProps && m3 !== v5 && null != h5.componentWillReceiveProps && h5.componentWillReceiveProps(m3, M3), !h5.__e && (null != h5.shouldComponentUpdate && false === h5.shouldComponentUpdate(m3, h5.__s, M3) || u6.__v === t5.__v)) {
@@ -102579,16 +102663,16 @@ void main() {
102579
102663
  else if ("key" !== s5 && !(s5 in k4)) {
102580
102664
  if ("value" == s5 && "defaultValue" in k4 || "checked" == s5 && "defaultChecked" in k4)
102581
102665
  continue;
102582
- A2(l5, s5, null, d5, o5);
102666
+ A3(l5, s5, null, d5, o5);
102583
102667
  }
102584
102668
  for (s5 in k4)
102585
- d5 = k4[s5], "children" == s5 ? v5 = d5 : "dangerouslySetInnerHTML" == s5 ? a6 = d5 : "value" == s5 ? _3 = d5 : "checked" == s5 ? g3 = d5 : "key" === s5 || e6 && "function" != typeof d5 || m3[s5] === d5 || A2(l5, s5, d5, m3[s5], o5);
102669
+ d5 = k4[s5], "children" == s5 ? v5 = d5 : "dangerouslySetInnerHTML" == s5 ? a6 = d5 : "value" == s5 ? _3 = d5 : "checked" == s5 ? g3 = d5 : "key" === s5 || e6 && "function" != typeof d5 || m3[s5] === d5 || A3(l5, s5, d5, m3[s5], o5);
102586
102670
  if (a6)
102587
102671
  e6 || p5 && (a6.__html === p5.__html || a6.__html === l5.innerHTML) || (l5.innerHTML = a6.__html), u6.__k = [];
102588
102672
  else if (p5 && (l5.innerHTML = ""), S2(l5, y3(v5) ? v5 : [v5], u6, t5, i7, "foreignObject" === b4 ? "http://www.w3.org/1999/xhtml" : o5, r5, f6, r5 ? r5[0] : t5.__k && x3(t5, 0), e6, c5), null != r5)
102589
102673
  for (s5 = r5.length; s5--; )
102590
102674
  null != r5[s5] && w3(r5[s5]);
102591
- e6 || (s5 = "value", void 0 !== _3 && (_3 !== l5[s5] || "progress" === b4 && !_3 || "option" === b4 && _3 !== m3[s5]) && A2(l5, s5, _3, m3[s5], o5), s5 = "checked", void 0 !== g3 && g3 !== l5[s5] && A2(l5, s5, g3, m3[s5], o5));
102675
+ e6 || (s5 = "value", void 0 !== _3 && (_3 !== l5[s5] || "progress" === b4 && !_3 || "option" === b4 && _3 !== m3[s5]) && A3(l5, s5, _3, m3[s5], o5), s5 = "checked", void 0 !== g3 && g3 !== l5[s5] && A3(l5, s5, g3, m3[s5], o5));
102592
102676
  }
102593
102677
  return l5;
102594
102678
  }
@@ -102622,7 +102706,7 @@ void main() {
102622
102706
  function q2(n4, l5, u6) {
102623
102707
  return this.constructor(n4, u6);
102624
102708
  }
102625
- function B2(u6, t5, i7) {
102709
+ function B3(u6, t5, i7) {
102626
102710
  var o5, r5, f6, e6;
102627
102711
  l3.__ && l3.__(u6, t5), r5 = (o5 = "function" == typeof i7) ? null : i7 && i7.__k || t5.__k, f6 = [], e6 = [], O2(t5, u6 = (!o5 && i7 || t5).__k = _2(k2, null, [u6]), r5 || h2, h2, t5.namespaceURI, !o5 && i7 ? [i7] : r5 ? null : t5.firstChild ? n3.call(t5.childNodes) : null, f6, !o5 && i7 ? i7 : r5 ? r5.__e : t5.firstChild, o5, e6), j2(f6, u6, e6);
102628
102712
  }
@@ -102645,7 +102729,7 @@ void main() {
102645
102729
  this.__v && (this.__e = true, n4 && this.__h.push(n4), M2(this));
102646
102730
  }, b3.prototype.render = k2, i4 = [], r3 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, f3 = function(n4, l5) {
102647
102731
  return n4.__v.__b - l5.__v.__b;
102648
- }, P2.__r = 0, e4 = 0, c3 = F2(false), s3 = F2(true), a4 = 0;
102732
+ }, P2.__r = 0, e4 = 0, c3 = F3(false), s3 = F3(true), a4 = 0;
102649
102733
 
102650
102734
  // ../../node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
102651
102735
  var f4 = 0;
@@ -102665,21 +102749,21 @@ void main() {
102665
102749
 
102666
102750
  // ../widgets/src/lib/components/button-group.tsx
102667
102751
  var ButtonGroup = (props) => {
102668
- const { children, orientation } = props;
102752
+ const { children, orientation = "horizontal" } = props;
102669
102753
  return /* @__PURE__ */ u4("div", { className: `deck-widget-button-group ${orientation}`, children });
102670
102754
  };
102671
102755
 
102672
102756
  // ../widgets/src/lib/components/grouped-icon-button.tsx
102673
102757
  var GroupedIconButton = (props) => {
102674
- const { className, label, onClick } = props;
102758
+ const { className = "", label, onClick, children } = props;
102675
102759
  return /* @__PURE__ */ u4(
102676
102760
  "button",
102677
102761
  {
102678
- className: `deck-widget-icon-button ${className || ""}`,
102762
+ className: `deck-widget-icon-button ${className}`,
102679
102763
  type: "button",
102680
102764
  onClick,
102681
102765
  title: label,
102682
- children: /* @__PURE__ */ u4("div", { className: "deck-widget-icon" })
102766
+ children: children ? children : /* @__PURE__ */ u4("div", { className: "deck-widget-icon" })
102683
102767
  }
102684
102768
  );
102685
102769
  };
@@ -102690,10 +102774,8 @@ void main() {
102690
102774
  super(props, _ZoomWidget.defaultProps);
102691
102775
  this.className = "deck-widget-zoom";
102692
102776
  this.placement = "top-left";
102693
- this.viewId = null;
102694
102777
  this.viewports = {};
102695
- this.viewId = props.viewId ?? this.viewId;
102696
- this.placement = props.placement ?? this.placement;
102778
+ this.setProps(this.props);
102697
102779
  }
102698
102780
  setProps(props) {
102699
102781
  this.placement = props.placement ?? this.placement;
@@ -102719,7 +102801,7 @@ void main() {
102719
102801
  }
102720
102802
  )
102721
102803
  ] });
102722
- B2(ui, rootElement);
102804
+ B3(ui, rootElement);
102723
102805
  }
102724
102806
  onViewportChange(viewport) {
102725
102807
  this.viewports[viewport.id] = viewport;
@@ -102732,7 +102814,9 @@ void main() {
102732
102814
  };
102733
102815
  if (this.props.transitionDuration > 0) {
102734
102816
  nextViewState.transitionDuration = this.props.transitionDuration;
102735
- nextViewState.transitionInterpolator = "latitude" in nextViewState ? new FlyToInterpolator() : new LinearInterpolator();
102817
+ nextViewState.transitionInterpolator = "latitude" in nextViewState ? new FlyToInterpolator() : new LinearInterpolator({
102818
+ transitionProps: ["zoom"]
102819
+ });
102736
102820
  }
102737
102821
  this.setViewState(viewId, nextViewState);
102738
102822
  }
@@ -102760,12 +102844,12 @@ void main() {
102760
102844
  transitionDuration: 200,
102761
102845
  zoomInLabel: "Zoom In",
102762
102846
  zoomOutLabel: "Zoom Out",
102763
- viewId: void 0
102847
+ viewId: null
102764
102848
  };
102765
102849
 
102766
102850
  // ../widgets/src/lib/components/icon-button.tsx
102767
102851
  var IconButton = (props) => {
102768
- const { className, label, onClick, children } = props;
102852
+ const { className = "", label, onClick, children } = props;
102769
102853
  return /* @__PURE__ */ u4("div", { className: "deck-widget-button", children: /* @__PURE__ */ u4(
102770
102854
  "button",
102771
102855
  {
@@ -102784,14 +102868,15 @@ void main() {
102784
102868
  super(props, _ResetViewWidget.defaultProps);
102785
102869
  this.className = "deck-widget-reset-view";
102786
102870
  this.placement = "top-left";
102787
- this.placement = props.placement ?? this.placement;
102871
+ this.setProps(this.props);
102788
102872
  }
102789
102873
  setProps(props) {
102790
102874
  this.placement = props.placement ?? this.placement;
102875
+ this.viewId = props.viewId ?? this.viewId;
102791
102876
  super.setProps(props);
102792
102877
  }
102793
102878
  onRenderHTML(rootElement) {
102794
- B2(
102879
+ B3(
102795
102880
  /* @__PURE__ */ u4(
102796
102881
  IconButton,
102797
102882
  {
@@ -102808,9 +102893,9 @@ void main() {
102808
102893
  this.setViewState(initialViewState);
102809
102894
  }
102810
102895
  setViewState(viewState) {
102811
- const viewId = this.props.viewId || viewState?.id || "default-view";
102896
+ const viewId = this.props.viewId || "default-view";
102812
102897
  const nextViewState = {
102813
- ...viewState
102898
+ ...viewId !== "default-view" ? viewState?.[viewId] : viewState
102814
102899
  // only works for geospatial?
102815
102900
  // transitionDuration: this.props.transitionDuration,
102816
102901
  // transitionInterpolator: new FlyToInterpolator()
@@ -102825,95 +102910,7 @@ void main() {
102825
102910
  placement: "top-left",
102826
102911
  label: "Reset View",
102827
102912
  initialViewState: void 0,
102828
- viewId: void 0
102829
- };
102830
-
102831
- // ../widgets/src/compass-widget.tsx
102832
- var _CompassWidget = class extends Widget {
102833
- constructor(props = {}) {
102834
- super(props, _CompassWidget.defaultProps);
102835
- this.className = "deck-widget-compass";
102836
- this.placement = "top-left";
102837
- this.viewId = null;
102838
- this.viewports = {};
102839
- this.setProps(this.props);
102840
- }
102841
- setProps(props) {
102842
- this.placement = props.placement ?? this.placement;
102843
- this.viewId = props.viewId ?? this.viewId;
102844
- super.setProps(props);
102845
- }
102846
- onRenderHTML(rootElement) {
102847
- const viewId = this.viewId || Object.values(this.viewports)[0]?.id || "default-view";
102848
- const widgetViewport = this.viewports[viewId];
102849
- const [rz, rx] = this.getRotation(widgetViewport);
102850
- const ui = /* @__PURE__ */ u4("div", { className: "deck-widget-button", style: { perspective: 100 }, children: /* @__PURE__ */ u4(
102851
- "button",
102852
- {
102853
- type: "button",
102854
- onClick: () => {
102855
- for (const viewport of Object.values(this.viewports)) {
102856
- this.handleCompassReset(viewport);
102857
- }
102858
- },
102859
- title: this.props.label,
102860
- style: { transform: `rotateX(${rx}deg)` },
102861
- children: /* @__PURE__ */ u4("svg", { fill: "none", width: "100%", height: "100%", viewBox: "0 0 26 26", children: /* @__PURE__ */ u4("g", { transform: `rotate(${rz},13,13)`, children: [
102862
- /* @__PURE__ */ u4(
102863
- "path",
102864
- {
102865
- d: "M10 13.0001L12.9999 5L15.9997 13.0001H10Z",
102866
- fill: "var(--icon-compass-north-color, rgb(240, 92, 68))"
102867
- }
102868
- ),
102869
- /* @__PURE__ */ u4(
102870
- "path",
102871
- {
102872
- d: "M16.0002 12.9999L13.0004 21L10.0005 12.9999H16.0002Z",
102873
- fill: "var(--icon-compass-south-color, rgb(204, 204, 204))"
102874
- }
102875
- )
102876
- ] }) })
102877
- }
102878
- ) });
102879
- B2(ui, rootElement);
102880
- }
102881
- onViewportChange(viewport) {
102882
- if (!viewport.equals(this.viewports[viewport.id])) {
102883
- this.viewports[viewport.id] = viewport;
102884
- this.updateHTML();
102885
- }
102886
- }
102887
- getRotation(viewport) {
102888
- if (viewport instanceof WebMercatorViewport2) {
102889
- return [-viewport.bearing, viewport.pitch];
102890
- } else if (viewport instanceof GlobeViewport) {
102891
- return [0, Math.max(-80, Math.min(80, viewport.latitude))];
102892
- }
102893
- return [0, 0];
102894
- }
102895
- handleCompassReset(viewport) {
102896
- const viewId = this.viewId || viewport.id || "default-view";
102897
- if (viewport instanceof WebMercatorViewport2) {
102898
- const nextViewState = {
102899
- ...viewport,
102900
- bearing: 0,
102901
- ...this.getRotation(viewport)[0] === 0 ? { pitch: 0 } : {},
102902
- transitionDuration: this.props.transitionDuration,
102903
- transitionInterpolator: new FlyToInterpolator()
102904
- };
102905
- this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
102906
- }
102907
- }
102908
- };
102909
- var CompassWidget = _CompassWidget;
102910
- CompassWidget.defaultProps = {
102911
- ...Widget.defaultProps,
102912
- id: "compass",
102913
- placement: "top-left",
102914
- viewId: null,
102915
- label: "Reset Compass",
102916
- transitionDuration: 200
102913
+ viewId: null
102917
102914
  };
102918
102915
 
102919
102916
  // ../widgets/src/gimbal-widget.tsx
@@ -102922,7 +102919,7 @@ void main() {
102922
102919
  super(props, _GimbalWidget.defaultProps);
102923
102920
  this.className = "deck-widget-gimbal";
102924
102921
  this.placement = "top-left";
102925
- this.viewId = null;
102922
+ this.viewports = {};
102926
102923
  this.setProps(this.props);
102927
102924
  }
102928
102925
  setProps(props) {
@@ -102931,13 +102928,17 @@ void main() {
102931
102928
  super.setProps(props);
102932
102929
  }
102933
102930
  onRenderHTML(rootElement) {
102934
- const { rotationOrbit, rotationX } = this.getNormalizedRotation();
102931
+ const viewId = this.viewId || Object.values(this.viewports)[0]?.id || "default-view";
102932
+ const widgetViewport = this.viewports[viewId];
102933
+ const { rotationOrbit, rotationX } = this.getNormalizedRotation(widgetViewport);
102935
102934
  const ui = /* @__PURE__ */ u4("div", { className: "deck-widget-button", style: { perspective: 100, pointerEvents: "auto" }, children: /* @__PURE__ */ u4(
102936
102935
  "button",
102937
102936
  {
102938
102937
  type: "button",
102939
102938
  onClick: () => {
102940
- this.resetOrbitView();
102939
+ for (const viewport of Object.values(this.viewports)) {
102940
+ this.resetOrbitView(viewport);
102941
+ }
102941
102942
  },
102942
102943
  title: this.props.label,
102943
102944
  style: { position: "relative", width: 26, height: 26 },
@@ -102997,13 +102998,14 @@ void main() {
102997
102998
  ]
102998
102999
  }
102999
103000
  ) });
103000
- B2(ui, rootElement);
103001
+ B3(ui, rootElement);
103001
103002
  }
103002
103003
  onViewportChange(viewport) {
103004
+ this.viewports[viewport.id] = viewport;
103003
103005
  this.updateHTML();
103004
103006
  }
103005
- resetOrbitView() {
103006
- const viewId = this.getViewId();
103007
+ resetOrbitView(viewport) {
103008
+ const viewId = this.getViewId(viewport);
103007
103009
  const viewState = this.getViewState(viewId);
103008
103010
  if ("rotationOrbit" in viewState || "rotationX" in viewState) {
103009
103011
  const nextViewState = {
@@ -103018,8 +103020,8 @@ void main() {
103018
103020
  this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
103019
103021
  }
103020
103022
  }
103021
- getNormalizedRotation() {
103022
- const viewState = this.getViewState(this.getViewId());
103023
+ getNormalizedRotation(viewport) {
103024
+ const viewState = this.getViewState(this.getViewId(viewport));
103023
103025
  const [rz, rx] = this.getRotation(viewState);
103024
103026
  const rotationOrbit = normalizeAndClampAngle(rz);
103025
103027
  const rotationX = normalizeAndClampAngle(rx);
@@ -103032,8 +103034,8 @@ void main() {
103032
103034
  return [0, 0];
103033
103035
  }
103034
103036
  // Move to Widget/WidgetManager?
103035
- getViewId() {
103036
- const viewId = this.viewId || "OrbitView";
103037
+ getViewId(viewport) {
103038
+ const viewId = this.viewId || viewport?.id || "OrbitView";
103037
103039
  return viewId;
103038
103040
  }
103039
103041
  getViewState(viewId) {
@@ -103054,7 +103056,7 @@ void main() {
103054
103056
  ...Widget.defaultProps,
103055
103057
  id: "gimbal",
103056
103058
  placement: "top-left",
103057
- viewId: void 0,
103059
+ viewId: null,
103058
103060
  label: "Gimbal",
103059
103061
  strokeWidth: 1.5,
103060
103062
  transitionDuration: 200
@@ -103073,6 +103075,93 @@ void main() {
103073
103075
  return normalized;
103074
103076
  }
103075
103077
 
103078
+ // ../widgets/src/compass-widget.tsx
103079
+ var _CompassWidget = class extends Widget {
103080
+ constructor(props = {}) {
103081
+ super(props, _CompassWidget.defaultProps);
103082
+ this.className = "deck-widget-compass";
103083
+ this.placement = "top-left";
103084
+ this.viewports = {};
103085
+ this.setProps(this.props);
103086
+ }
103087
+ setProps(props) {
103088
+ this.placement = props.placement ?? this.placement;
103089
+ this.viewId = props.viewId ?? this.viewId;
103090
+ super.setProps(props);
103091
+ }
103092
+ onRenderHTML(rootElement) {
103093
+ const viewId = this.viewId || Object.values(this.viewports)[0]?.id || "default-view";
103094
+ const widgetViewport = this.viewports[viewId];
103095
+ const [rz, rx] = this.getRotation(widgetViewport);
103096
+ const ui = /* @__PURE__ */ u4("div", { className: "deck-widget-button", style: { perspective: 100 }, children: /* @__PURE__ */ u4(
103097
+ "button",
103098
+ {
103099
+ type: "button",
103100
+ onClick: () => {
103101
+ for (const viewport of Object.values(this.viewports)) {
103102
+ this.handleCompassReset(viewport);
103103
+ }
103104
+ },
103105
+ title: this.props.label,
103106
+ style: { transform: `rotateX(${rx}deg)` },
103107
+ children: /* @__PURE__ */ u4("svg", { fill: "none", width: "100%", height: "100%", viewBox: "0 0 26 26", children: /* @__PURE__ */ u4("g", { transform: `rotate(${rz},13,13)`, children: [
103108
+ /* @__PURE__ */ u4(
103109
+ "path",
103110
+ {
103111
+ d: "M10 13.0001L12.9999 5L15.9997 13.0001H10Z",
103112
+ fill: "var(--icon-compass-north-color, rgb(240, 92, 68))"
103113
+ }
103114
+ ),
103115
+ /* @__PURE__ */ u4(
103116
+ "path",
103117
+ {
103118
+ d: "M16.0002 12.9999L13.0004 21L10.0005 12.9999H16.0002Z",
103119
+ fill: "var(--icon-compass-south-color, rgb(204, 204, 204))"
103120
+ }
103121
+ )
103122
+ ] }) })
103123
+ }
103124
+ ) });
103125
+ B3(ui, rootElement);
103126
+ }
103127
+ onViewportChange(viewport) {
103128
+ if (!viewport.equals(this.viewports[viewport.id])) {
103129
+ this.viewports[viewport.id] = viewport;
103130
+ this.updateHTML();
103131
+ }
103132
+ }
103133
+ getRotation(viewport) {
103134
+ if (viewport instanceof WebMercatorViewport2) {
103135
+ return [-viewport.bearing, viewport.pitch];
103136
+ } else if (viewport instanceof GlobeViewport) {
103137
+ return [0, Math.max(-80, Math.min(80, viewport.latitude))];
103138
+ }
103139
+ return [0, 0];
103140
+ }
103141
+ handleCompassReset(viewport) {
103142
+ const viewId = this.viewId || viewport.id || "default-view";
103143
+ if (viewport instanceof WebMercatorViewport2) {
103144
+ const nextViewState = {
103145
+ ...viewport,
103146
+ bearing: 0,
103147
+ ...this.getRotation(viewport)[0] === 0 ? { pitch: 0 } : {},
103148
+ transitionDuration: this.props.transitionDuration,
103149
+ transitionInterpolator: new FlyToInterpolator()
103150
+ };
103151
+ this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
103152
+ }
103153
+ }
103154
+ };
103155
+ var CompassWidget = _CompassWidget;
103156
+ CompassWidget.defaultProps = {
103157
+ ...Widget.defaultProps,
103158
+ id: "compass",
103159
+ placement: "top-left",
103160
+ viewId: null,
103161
+ label: "Reset Compass",
103162
+ transitionDuration: 200
103163
+ };
103164
+
103076
103165
  // ../widgets/src/scale-widget.tsx
103077
103166
  var _ScaleWidget = class extends Widget {
103078
103167
  constructor(props = {}) {
@@ -103085,17 +103174,18 @@ void main() {
103085
103174
  this.scaleValue = 0;
103086
103175
  // The formatted distance label (e.g. "200 m" or "1.0 km")
103087
103176
  this.scaleText = "";
103088
- this.placement = props.placement ?? this.placement;
103177
+ this.setProps(this.props);
103089
103178
  }
103090
103179
  setProps(props) {
103091
103180
  this.placement = props.placement ?? this.placement;
103181
+ this.viewId = props.viewId ?? this.viewId;
103092
103182
  super.setProps(props);
103093
103183
  }
103094
103184
  onRenderHTML(rootElement) {
103095
103185
  const lineOffsetX = 50;
103096
103186
  const svgWidth = lineOffsetX + this.scaleWidth;
103097
103187
  const tickHeight = 10;
103098
- B2(
103188
+ B3(
103099
103189
  /* @__PURE__ */ u4(
103100
103190
  "svg",
103101
103191
  {
@@ -103179,7 +103269,7 @@ void main() {
103179
103269
  id: "scale",
103180
103270
  placement: "bottom-left",
103181
103271
  label: "Scale",
103182
- onCapture: void 0
103272
+ viewId: null
103183
103273
  };
103184
103274
  function getMetersPerPixel(latitude, zoom) {
103185
103275
  const earthCircumference = 40075016686e-3;
@@ -103236,11 +103326,11 @@ void main() {
103236
103326
  return n4 >= u6.__.length && u6.__.push({}), u6.__[n4];
103237
103327
  }
103238
103328
  function h3(n4) {
103239
- return o4 = 1, p4(D2, n4);
103329
+ return o4 = 1, p4(D3, n4);
103240
103330
  }
103241
103331
  function p4(n4, u6, i7) {
103242
103332
  var o5 = d4(t4++, 2);
103243
- if (o5.t = n4, !o5.__c && (o5.__ = [i7 ? i7(u6) : D2(void 0, u6), function(n5) {
103333
+ if (o5.t = n4, !o5.__c && (o5.__ = [i7 ? i7(u6) : D3(void 0, u6), function(n5) {
103244
103334
  var t5 = o5.__N ? o5.__N[0] : o5.__[0], r5 = o5.t(t5, n5);
103245
103335
  t5 !== r5 && (o5.__N = [r5, o5.__[1]], o5.__c.setState({}));
103246
103336
  }], o5.__c = r4, !r4.u)) {
@@ -103276,22 +103366,22 @@ void main() {
103276
103366
  }
103277
103367
  function y4(n4, u6) {
103278
103368
  var i7 = d4(t4++, 3);
103279
- !c4.__s && C3(i7.__H, u6) && (i7.__ = n4, i7.i = u6, r4.__H.__h.push(i7));
103369
+ !c4.__s && C4(i7.__H, u6) && (i7.__ = n4, i7.i = u6, r4.__H.__h.push(i7));
103280
103370
  }
103281
- function A3(n4) {
103371
+ function A4(n4) {
103282
103372
  return o4 = 5, T3(function() {
103283
103373
  return { current: n4 };
103284
103374
  }, []);
103285
103375
  }
103286
103376
  function T3(n4, r5) {
103287
103377
  var u6 = d4(t4++, 7);
103288
- return C3(u6.__H, r5) && (u6.__ = n4(), u6.__H = r5, u6.__h = n4), u6.__;
103378
+ return C4(u6.__H, r5) && (u6.__ = n4(), u6.__H = r5, u6.__h = n4), u6.__;
103289
103379
  }
103290
103380
  function j3() {
103291
103381
  for (var n4; n4 = f5.shift(); )
103292
103382
  if (n4.__P && n4.__H)
103293
103383
  try {
103294
- n4.__H.__h.forEach(z3), n4.__H.__h.forEach(B3), n4.__H.__h = [];
103384
+ n4.__H.__h.forEach(z3), n4.__H.__h.forEach(B4), n4.__H.__h = [];
103295
103385
  } catch (t5) {
103296
103386
  n4.__H.__h = [], c4.__e(t5, n4.__v);
103297
103387
  }
@@ -103305,7 +103395,7 @@ void main() {
103305
103395
  var i7 = (r4 = n4.__c).__H;
103306
103396
  i7 && (u5 === r4 ? (i7.__h = [], r4.__h = [], i7.__.forEach(function(n5) {
103307
103397
  n5.__N && (n5.__ = n5.__N), n5.i = n5.__N = void 0;
103308
- })) : (i7.__h.forEach(z3), i7.__h.forEach(B3), i7.__h = [], t4 = 0)), u5 = r4;
103398
+ })) : (i7.__h.forEach(z3), i7.__h.forEach(B4), i7.__h = [], t4 = 0)), u5 = r4;
103309
103399
  }, c4.diffed = function(n4) {
103310
103400
  v4 && v4(n4);
103311
103401
  var t5 = n4.__c;
@@ -103316,7 +103406,7 @@ void main() {
103316
103406
  t5.some(function(n5) {
103317
103407
  try {
103318
103408
  n5.__h.forEach(z3), n5.__h = n5.__h.filter(function(n6) {
103319
- return !n6.__ || B3(n6);
103409
+ return !n6.__ || B4(n6);
103320
103410
  });
103321
103411
  } catch (r5) {
103322
103412
  t5.some(function(n6) {
@@ -103346,23 +103436,23 @@ void main() {
103346
103436
  var t5 = r4, u6 = n4.__c;
103347
103437
  "function" == typeof u6 && (n4.__c = void 0, u6()), r4 = t5;
103348
103438
  }
103349
- function B3(n4) {
103439
+ function B4(n4) {
103350
103440
  var t5 = r4;
103351
103441
  n4.__c = n4.__(), r4 = t5;
103352
103442
  }
103353
- function C3(n4, t5) {
103443
+ function C4(n4, t5) {
103354
103444
  return !n4 || n4.length !== t5.length || t5.some(function(t6, r5) {
103355
103445
  return t6 !== n4[r5];
103356
103446
  });
103357
103447
  }
103358
- function D2(n4, t5) {
103448
+ function D3(n4, t5) {
103359
103449
  return "function" == typeof t5 ? t5(n4) : t5;
103360
103450
  }
103361
103451
 
103362
103452
  // ../widgets/src/lib/components/dropdown-menu.tsx
103363
103453
  var DropdownMenu = (props) => {
103364
103454
  const [isOpen, setIsOpen] = h3(false);
103365
- const dropdownRef = A3(null);
103455
+ const dropdownRef = A4(null);
103366
103456
  const toggleDropdown = () => setIsOpen(!isOpen);
103367
103457
  const handleClickOutside = (event) => {
103368
103458
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
@@ -103673,21 +103763,20 @@ void main() {
103673
103763
  }
103674
103764
  };
103675
103765
  this.viewports = {};
103676
- this.placement = this.props.placement ?? this.placement;
103677
103766
  this.setProps(this.props);
103678
- this.geocoder = getGeocoder(this.props);
103679
103767
  }
103680
103768
  setProps(props) {
103681
- super.setProps(props);
103682
103769
  this.placement = props.placement ?? this.placement;
103770
+ this.viewId = props.viewId ?? this.viewId;
103683
103771
  this.geocoder = getGeocoder(this.props);
103684
103772
  if (this.geocoder.requiresApiKey && !this.props.apiKey) {
103685
103773
  throw new Error(`API key is required for the ${this.geocoder.name} geocoder`);
103686
103774
  }
103775
+ super.setProps(props);
103687
103776
  }
103688
103777
  onRenderHTML(rootElement) {
103689
103778
  const menuItems = this.props._geolocation ? [CURRENT_LOCATION2, ...this.geocodeHistory.addressHistory] : [...this.geocodeHistory.addressHistory];
103690
- B2(
103779
+ B3(
103691
103780
  /* @__PURE__ */ u4(
103692
103781
  "div",
103693
103782
  {
@@ -103757,10 +103846,10 @@ void main() {
103757
103846
  var GeocoderWidget = _GeocoderWidget;
103758
103847
  GeocoderWidget.defaultProps = {
103759
103848
  ...Widget.defaultProps,
103760
- id: "geolocate",
103761
- viewId: void 0,
103849
+ id: "geocoder",
103850
+ viewId: null,
103762
103851
  placement: "top-left",
103763
- label: "Geolocate",
103852
+ label: "Geocoder",
103764
103853
  transitionDuration: 200,
103765
103854
  geocoder: "coordinates",
103766
103855
  customGeocoder: CoordinatesGeocoder,
@@ -103794,7 +103883,7 @@ void main() {
103794
103883
  this.className = "deck-widget-fullscreen";
103795
103884
  this.placement = "top-left";
103796
103885
  this.fullscreen = false;
103797
- this.placement = props.placement ?? this.placement;
103886
+ this.setProps(this.props);
103798
103887
  }
103799
103888
  onAdd() {
103800
103889
  document.addEventListener("fullscreenchange", this.onFullscreenChange.bind(this));
@@ -103803,11 +103892,13 @@ void main() {
103803
103892
  document.removeEventListener("fullscreenchange", this.onFullscreenChange.bind(this));
103804
103893
  }
103805
103894
  onRenderHTML(rootElement) {
103806
- B2(
103895
+ B3(
103807
103896
  /* @__PURE__ */ u4(
103808
103897
  IconButton,
103809
103898
  {
103810
- onClick: this.handleClick.bind(this),
103899
+ onClick: () => {
103900
+ this.handleClick().catch((err) => log_default.error(err)());
103901
+ },
103811
103902
  label: this.fullscreen ? this.props.exitLabel : this.props.enterLabel,
103812
103903
  className: this.fullscreen ? "deck-widget-fullscreen-exit" : "deck-widget-fullscreen-enter"
103813
103904
  }
@@ -103817,6 +103908,7 @@ void main() {
103817
103908
  }
103818
103909
  setProps(props) {
103819
103910
  this.placement = props.placement ?? this.placement;
103911
+ this.viewId = props.viewId ?? this.viewId;
103820
103912
  super.setProps(props);
103821
103913
  }
103822
103914
  getContainer() {
@@ -103862,297 +103954,296 @@ void main() {
103862
103954
  ...Widget.defaultProps,
103863
103955
  id: "fullscreen",
103864
103956
  placement: "top-left",
103957
+ viewId: null,
103865
103958
  enterLabel: "Enter Fullscreen",
103866
103959
  exitLabel: "Exit Fullscreen",
103867
103960
  container: void 0
103868
103961
  };
103869
103962
 
103870
- // ../widgets/src/screenshot-widget.tsx
103871
- var _ScreenshotWidget = class extends Widget {
103872
- constructor(props = {}) {
103873
- super(props, _ScreenshotWidget.defaultProps);
103874
- this.className = "deck-widget-screenshot";
103875
- this.placement = "top-left";
103876
- this.placement = props.placement ?? this.placement;
103963
+ // ../widgets/src/splitter-widget.tsx
103964
+ var _SplitterWidget = class extends Widget {
103965
+ constructor(props) {
103966
+ super(props, _SplitterWidget.defaultProps);
103967
+ this.className = "deck-widget-splitter";
103968
+ this.placement = "fill";
103877
103969
  }
103878
103970
  setProps(props) {
103879
- this.placement = props.placement ?? this.placement;
103880
103971
  super.setProps(props);
103881
103972
  }
103882
103973
  onRenderHTML(rootElement) {
103883
- B2(
103974
+ rootElement.style.position = "absolute";
103975
+ rootElement.style.top = "0";
103976
+ rootElement.style.left = "0";
103977
+ rootElement.style.width = "100%";
103978
+ rootElement.style.height = "100%";
103979
+ rootElement.style.margin = "0px";
103980
+ B3(
103884
103981
  /* @__PURE__ */ u4(
103885
- IconButton,
103982
+ Splitter,
103886
103983
  {
103887
- className: "deck-widget-camera",
103888
- label: this.props.label,
103889
- onClick: this.handleClick.bind(this)
103984
+ orientation: this.props.orientation,
103985
+ initialSplit: this.props.initialSplit,
103986
+ onChange: this.props.onChange,
103987
+ onDragStart: this.props.onDragStart,
103988
+ onDragEnd: this.props.onDragEnd
103890
103989
  }
103891
103990
  ),
103892
103991
  rootElement
103893
103992
  );
103894
103993
  }
103895
- handleClick() {
103896
- if (this.props.onCapture) {
103897
- this.props.onCapture(this);
103898
- return;
103899
- }
103900
- const dataURL = this.captureScreenToDataURL(this.props.imageFormat);
103901
- if (dataURL) {
103902
- this.downloadDataURL(dataURL, this.props.filename);
103903
- }
103904
- }
103905
- /** @note only captures canvas contents, not HTML DOM or CSS styles */
103906
- captureScreenToDataURL(imageFormat) {
103907
- const canvas2 = this.deck?.getCanvas();
103908
- return canvas2?.toDataURL(imageFormat);
103909
- }
103910
- /** Download a data URL */
103911
- downloadDataURL(dataURL, filename2) {
103912
- const link = document.createElement("a");
103913
- link.href = dataURL;
103914
- link.download = filename2;
103915
- link.click();
103916
- }
103917
103994
  };
103918
- var ScreenshotWidget = _ScreenshotWidget;
103919
- ScreenshotWidget.defaultProps = {
103995
+ var SplitterWidget = _SplitterWidget;
103996
+ SplitterWidget.defaultProps = {
103920
103997
  ...Widget.defaultProps,
103921
- id: "screenshot",
103922
- placement: "top-left",
103923
- label: "Screenshot",
103924
- filename: "screenshot.png",
103925
- imageFormat: "image/png",
103926
- onCapture: void 0
103998
+ id: "splitter-widget",
103999
+ viewId1: "",
104000
+ viewId2: "",
104001
+ orientation: "vertical",
104002
+ initialSplit: 0.5,
104003
+ onChange: () => {
104004
+ },
104005
+ onDragStart: () => {
104006
+ },
104007
+ onDragEnd: () => {
104008
+ }
103927
104009
  };
104010
+ function Splitter({
104011
+ orientation,
104012
+ initialSplit,
104013
+ onChange,
104014
+ onDragStart,
104015
+ onDragEnd
104016
+ }) {
104017
+ const [split, setSplit] = h3(initialSplit);
104018
+ const dragging = A4(false);
104019
+ const containerRef = A4(null);
104020
+ const handleDragStart = (event) => {
104021
+ dragging.current = true;
104022
+ onDragStart?.();
104023
+ document.addEventListener("mousemove", handleDragging);
104024
+ document.addEventListener("mouseup", handleDragEnd);
104025
+ event.preventDefault();
104026
+ };
104027
+ const handleDragging = (event) => {
104028
+ if (!dragging.current || !containerRef.current)
104029
+ return;
104030
+ const rect = containerRef.current.getBoundingClientRect();
104031
+ let newSplit;
104032
+ if (orientation === "vertical") {
104033
+ newSplit = (event.clientX - rect.left) / rect.width;
104034
+ } else {
104035
+ newSplit = (event.clientY - rect.top) / rect.height;
104036
+ }
104037
+ newSplit = Math.min(Math.max(newSplit, 0.05), 0.95);
104038
+ setSplit(newSplit);
104039
+ onChange?.(newSplit);
104040
+ };
104041
+ const handleDragEnd = (event) => {
104042
+ if (!dragging.current)
104043
+ return;
104044
+ dragging.current = false;
104045
+ onDragEnd?.();
104046
+ document.removeEventListener("mousemove", handleDragging);
104047
+ document.removeEventListener("mouseup", handleDragEnd);
104048
+ };
104049
+ const splitterStyle = orientation === "vertical" ? {
104050
+ position: "absolute",
104051
+ top: 0,
104052
+ bottom: 0,
104053
+ left: `${split * 100}%`,
104054
+ width: "4px",
104055
+ cursor: "col-resize",
104056
+ background: "#ccc",
104057
+ zIndex: 10,
104058
+ pointerEvents: "auto",
104059
+ boxShadow: "inset -1px 0 0 white, inset 1px 0 0 white"
104060
+ } : {
104061
+ position: "absolute",
104062
+ left: 0,
104063
+ right: 0,
104064
+ top: `${split * 100}%`,
104065
+ height: "4px",
104066
+ cursor: "row-resize",
104067
+ background: "#ccc",
104068
+ zIndex: 10,
104069
+ pointerEvents: "auto",
104070
+ boxShadow: "inset -1px 0 0 white, inset 1px 0 0 white"
104071
+ };
104072
+ const containerStyle = {
104073
+ position: "absolute",
104074
+ top: 0,
104075
+ left: 0,
104076
+ right: 0,
104077
+ bottom: 0
104078
+ };
104079
+ return /* @__PURE__ */ u4("div", { ref: containerRef, style: containerStyle, children: /* @__PURE__ */ u4(
104080
+ "div",
104081
+ {
104082
+ style: splitterStyle,
104083
+ onMouseDown: handleDragStart
104084
+ }
104085
+ ) });
104086
+ }
103928
104087
 
103929
- // ../widgets/src/loading-widget.tsx
103930
- var _LoadingWidget = class extends Widget {
104088
+ // ../widgets/src/lib/components/icon-menu.tsx
104089
+ function IconMenu(props) {
104090
+ const [menuOpen, setMenuOpen] = h3(false);
104091
+ const containerRef = A4(null);
104092
+ const handleClickOutside = (event) => {
104093
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
104094
+ setMenuOpen(false);
104095
+ }
104096
+ };
104097
+ y4(() => {
104098
+ document.addEventListener("mousedown", handleClickOutside);
104099
+ return () => {
104100
+ document.removeEventListener("mousedown", handleClickOutside);
104101
+ };
104102
+ }, [containerRef]);
104103
+ const [selectedItem, setSelectedItem] = h3(props.initialItem);
104104
+ const handleSelectItem = (item) => {
104105
+ setSelectedItem(item);
104106
+ setMenuOpen(false);
104107
+ props.onItemSelected(item);
104108
+ };
104109
+ const handleButtonClick = () => setMenuOpen(!menuOpen);
104110
+ const selectedMenuItem = props.menuItems.find((item) => item.value === selectedItem);
104111
+ const label = props.label || selectedMenuItem?.label || "";
104112
+ const icon = props.icon || selectedMenuItem?.icon;
104113
+ return /* @__PURE__ */ u4("div", { style: { position: "relative", display: "inline-block" }, ref: containerRef, children: [
104114
+ /* @__PURE__ */ u4(IconButton, { className: props.className, label, onClick: handleButtonClick, children: icon }),
104115
+ menuOpen && /* @__PURE__ */ u4("div", { className: "deck-widget-icon-menu", children: /* @__PURE__ */ u4(ButtonGroup, { orientation: "vertical", children: props.menuItems.map((item) => /* @__PURE__ */ u4(
104116
+ GroupedIconButton,
104117
+ {
104118
+ label: item.label,
104119
+ onClick: () => handleSelectItem(item.value),
104120
+ children: item.icon
104121
+ },
104122
+ item.value
104123
+ )) }) })
104124
+ ] });
104125
+ }
104126
+
104127
+ // ../widgets/src/view-selector-widget.tsx
104128
+ var _ViewSelectorWidget = class extends Widget {
103931
104129
  constructor(props = {}) {
103932
- super(props, _LoadingWidget.defaultProps);
103933
- this.className = "deck-widget-loading";
104130
+ super(props, _ViewSelectorWidget.defaultProps);
104131
+ this.className = "deck-widget-view-selector";
103934
104132
  this.placement = "top-left";
103935
- this.loading = true;
103936
- this.placement = props.placement ?? this.placement;
104133
+ this.handleSelectMode = (viewMode) => {
104134
+ this.viewMode = viewMode;
104135
+ this.updateHTML();
104136
+ this.props.onViewModeChange(viewMode);
104137
+ };
104138
+ this.viewMode = this.props.initialViewMode;
104139
+ this.setProps(this.props);
103937
104140
  }
103938
104141
  setProps(props) {
103939
104142
  this.placement = props.placement ?? this.placement;
104143
+ this.viewId = props.viewId ?? this.viewId;
103940
104144
  super.setProps(props);
103941
104145
  }
103942
104146
  onRenderHTML(rootElement) {
103943
- B2(
103944
- // TODO(ibgreen) - this should not be a button, but styling is so nested that it is easier to reuse this component.
103945
- this.loading && /* @__PURE__ */ u4(
103946
- IconButton,
104147
+ B3(
104148
+ /* @__PURE__ */ u4(
104149
+ IconMenu,
103947
104150
  {
103948
- className: "deck-widget-spinner-icon",
103949
- label: this.props.label,
103950
- onClick: this.handleClick.bind(this)
104151
+ className: "deck-widget-view-selector",
104152
+ menuItems: MENU_ITEMS.map((item) => ({
104153
+ ...item,
104154
+ icon: item.icon()
104155
+ })),
104156
+ initialItem: this.props.initialViewMode,
104157
+ onItemSelected: this.handleSelectMode
103951
104158
  }
103952
104159
  ),
103953
104160
  rootElement
103954
104161
  );
103955
104162
  }
103956
- onRedraw({ layers }) {
103957
- const loading = !layers.some((layer) => !layer.isLoaded);
103958
- if (loading !== this.loading) {
103959
- this.loading = loading;
103960
- this.updateHTML();
103961
- }
103962
- }
103963
- // TODO(ibgreen) - this should not be a button, see above.
103964
- handleClick() {
103965
- }
103966
104163
  };
103967
- var LoadingWidget = _LoadingWidget;
103968
- LoadingWidget.defaultProps = {
104164
+ var ViewSelectorWidget = _ViewSelectorWidget;
104165
+ ViewSelectorWidget.defaultProps = {
103969
104166
  ...Widget.defaultProps,
103970
- id: "loading",
104167
+ id: "view-selector",
103971
104168
  placement: "top-left",
103972
- label: "Loading layer data"
103973
- };
103974
-
103975
- // ../widgets/src/fps-widget.tsx
103976
- var _FpsWidget = class extends Widget {
103977
- constructor(props = {}) {
103978
- super(props, _FpsWidget.defaultProps);
103979
- this.className = "deck-widget-fps";
103980
- this.placement = "top-left";
103981
- this._lastFps = -1;
103982
- this.placement = props.placement ?? this.placement;
103983
- }
103984
- setProps(props) {
103985
- if (props.placement) {
103986
- this.placement = props.placement;
103987
- }
103988
- super.setProps(props);
103989
- }
103990
- onAdd({}) {
103991
- this._lastFps = this._getFps();
103992
- this.updateHTML();
103993
- }
103994
- onRenderHTML(rootElement) {
103995
- const fps = this._getFps();
103996
- rootElement.innerText = `FPS:
103997
- ${fps}`;
103998
- rootElement.style.backgroundColor = "white";
103999
- rootElement.style.fontFamily = "monospace";
104000
- rootElement.style.fontSize = "8px";
104001
- rootElement.style.fontWeight = "700";
104002
- }
104003
- onRedraw({}) {
104004
- const fps = this._getFps();
104005
- if (fps !== this._lastFps) {
104006
- this._lastFps = fps;
104007
- this.updateHTML();
104008
- }
104009
- }
104010
- _getFps() {
104011
- return Math.round(this.deck.metrics.fps ?? 0);
104169
+ viewId: null,
104170
+ label: "Split View",
104171
+ initialViewMode: "single",
104172
+ onViewModeChange: () => {
104012
104173
  }
104013
104174
  };
104014
- var FpsWidget = _FpsWidget;
104015
- FpsWidget.defaultProps = {
104016
- ...Widget.defaultProps,
104017
- id: "fps",
104018
- placement: "top-left"
104019
- };
104020
-
104021
- // ../widgets/src/themes.ts
104022
- var LightTheme = {
104023
- "--widget-margin": "12px",
104024
- "--button-size": "28px",
104025
- "--button-corner-radius": "8px",
104026
- "--button-background": "#fff",
104027
- "--button-stroke": "rgba(255, 255, 255, 0.3)",
104028
- "--button-inner-stroke": "unset",
104029
- "--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25)",
104030
- "--button-backdrop-filter": "unset",
104031
- "--button-icon-idle": "rgba(97, 97, 102, 1)",
104032
- "--button-icon-hover": "rgba(24, 24, 26, 1)",
104033
- "--icon-compass-north-color": "rgb(240, 92, 68)",
104034
- "--icon-compass-south-color": "rgb(204, 204, 204)"
104035
- };
104036
- var DarkTheme = {
104037
- "--widget-margin": "12px",
104038
- "--button-size": "28px",
104039
- "--button-corner-radius": "8px",
104040
- "--button-background": "rgba(18, 18, 20, 1)",
104041
- "--button-stroke": "rgba(18, 18, 20, 0.30)",
104042
- "--button-inner-stroke": "unset",
104043
- "--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25)",
104044
- "--button-backdrop-filter": "unset",
104045
- "--button-icon-idle": "rgba(158, 157, 168, 1)",
104046
- "--button-icon-hover": "rgba(215, 214, 229, 1)",
104047
- "--icon-compass-north-color": "rgb(240, 92, 68)",
104048
- "--icon-compass-south-color": "rgb(200, 199, 209)"
104049
- };
104050
- var LightGlassTheme = {
104051
- "--widget-margin": "12px",
104052
- "--button-size": "28px",
104053
- "--button-corner-radius": "8px",
104054
- "--button-background": "rgba(255, 255, 255, 0.6)",
104055
- "--button-stroke": "rgba(255, 255, 255, 0.3)",
104056
- "--button-inner-stroke": "1px solid rgba(255, 255, 255, 0.6)",
104057
- "--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
104058
- "--button-backdrop-filter": "blur(4px)",
104059
- "--button-icon-idle": "rgba(97, 97, 102, 1)",
104060
- "--button-icon-hover": "rgba(24, 24, 26, 1)",
104061
- "--icon-compass-north-color": "rgb(240, 92, 68)",
104062
- "--icon-compass-south-color": "rgb(204, 204, 204)"
104063
- };
104064
- var DarkGlassTheme = {
104065
- "--widget-margin": "12px",
104066
- "--button-size": "28px",
104067
- "--button-corner-radius": "8px",
104068
- "--button-background": "rgba(18, 18, 20, 0.75)",
104069
- "--button-stroke": "rgba(18, 18, 20, 0.30)",
104070
- "--button-inner-stroke": "1px solid rgba(18, 18, 20, 0.75)",
104071
- "--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
104072
- "--button-backdrop-filter": "blur(4px)",
104073
- "--button-icon-idle": "rgba(158, 157, 168, 1)",
104074
- "--button-icon-hover": "rgba(215, 214, 229, 1)",
104075
- "--icon-compass-north-color": "rgb(240, 92, 68)",
104076
- "--icon-compass-south-color": "rgb(200, 199, 209)"
104077
- };
104078
-
104079
- // ../widgets/src/theme-widget.tsx
104080
- var _ThemeWidget = class extends Widget {
104081
- constructor(props = {}) {
104082
- super(props, _ThemeWidget.defaultProps);
104083
- this.className = "deck-widget-theme";
104084
- this.placement = "top-left";
104085
- this.themeMode = "dark";
104086
- this.placement = props.placement ?? this.placement;
104087
- this.themeMode = this._getInitialThemeMode();
104088
- }
104089
- // eslint-disable-next-line complexity
104090
- setProps(props) {
104091
- const { lightModeTheme, darkModeTheme } = this.props;
104092
- this.placement = props.placement ?? this.placement;
104093
- super.setProps(props);
104094
- switch (this.themeMode) {
104095
- case "light":
104096
- if (props.lightModeTheme && !deepEqual2(props.lightModeTheme, lightModeTheme, 1)) {
104097
- this._setThemeMode("light");
104098
- }
104099
- break;
104100
- case "dark":
104101
- if (props.darkModeTheme && !deepEqual2(props.darkModeTheme, darkModeTheme, 1)) {
104102
- this._setThemeMode("dark");
104103
- }
104104
- break;
104105
- }
104106
- }
104107
- onRenderHTML(rootElement) {
104108
- const { lightModeLabel, darkModeLabel } = this.props;
104109
- B2(
104110
- /* @__PURE__ */ u4(
104111
- IconButton,
104112
- {
104113
- onClick: this._handleClick.bind(this),
104114
- label: this.themeMode === "dark" ? darkModeLabel : lightModeLabel,
104115
- className: this.themeMode === "dark" ? "deck-widget-moon" : "deck-widget-sun"
104116
- }
104117
- ),
104118
- rootElement
104119
- );
104120
- }
104121
- onAdd() {
104122
- this._setThemeMode(this.themeMode);
104123
- }
104124
- _handleClick() {
104125
- const newThemeMode = this.themeMode === "dark" ? "light" : "dark";
104126
- this._setThemeMode(newThemeMode);
104127
- }
104128
- _setThemeMode(themeMode) {
104129
- this.themeMode = themeMode;
104130
- const container = this.rootElement?.closest(".deck-widget-container");
104131
- if (container) {
104132
- const themeStyle = themeMode === "dark" ? this.props.darkModeTheme : this.props.lightModeTheme;
104133
- applyStyles(container, themeStyle);
104134
- const label = this.themeMode === "dark" ? this.props.darkModeLabel : this.props.lightModeLabel;
104135
- log_default.log(1, `Switched theme to ${label}`, themeStyle);
104136
- this.updateHTML();
104137
- }
104138
- }
104139
- /** Read browser preference */
104140
- _getInitialThemeMode() {
104141
- const { initialThemeMode } = this.props;
104142
- return initialThemeMode === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : initialThemeMode;
104143
- }
104144
- };
104145
- var ThemeWidget = _ThemeWidget;
104146
- ThemeWidget.defaultProps = {
104147
- ...Widget.defaultProps,
104148
- id: "theme",
104149
- placement: "top-left",
104150
- lightModeLabel: "Light Mode",
104151
- lightModeTheme: LightGlassTheme,
104152
- darkModeLabel: "Dark Mode",
104153
- darkModeTheme: DarkGlassTheme,
104154
- initialThemeMode: "auto"
104175
+ var ICON_STYLE = { width: "24px", height: "24px" };
104176
+ var ICONS = {
104177
+ single: () => /* @__PURE__ */ u4("svg", { width: "24", height: "24", style: ICON_STYLE, children: /* @__PURE__ */ u4(
104178
+ "rect",
104179
+ {
104180
+ x: "4",
104181
+ y: "4",
104182
+ width: "16",
104183
+ height: "16",
104184
+ stroke: "var(--button-icon-hover, rgb(24, 24, 26))",
104185
+ fill: "none",
104186
+ strokeWidth: "2"
104187
+ }
104188
+ ) }),
104189
+ "split-horizontal": () => /* @__PURE__ */ u4("svg", { width: "24", height: "24", style: ICON_STYLE, children: [
104190
+ /* @__PURE__ */ u4(
104191
+ "rect",
104192
+ {
104193
+ x: "4",
104194
+ y: "4",
104195
+ width: "16",
104196
+ height: "7",
104197
+ stroke: "var(--button-icon-hover, rgb(24, 24, 26))",
104198
+ fill: "none",
104199
+ strokeWidth: "2"
104200
+ }
104201
+ ),
104202
+ /* @__PURE__ */ u4(
104203
+ "rect",
104204
+ {
104205
+ x: "4",
104206
+ y: "13",
104207
+ width: "16",
104208
+ height: "7",
104209
+ stroke: "var(--button-icon-hover, rgb(24, 24, 26))",
104210
+ fill: "none",
104211
+ strokeWidth: "2"
104212
+ }
104213
+ )
104214
+ ] }),
104215
+ "split-vertical": () => /* @__PURE__ */ u4("svg", { width: "24", height: "24", style: ICON_STYLE, children: [
104216
+ /* @__PURE__ */ u4(
104217
+ "rect",
104218
+ {
104219
+ x: "4",
104220
+ y: "4",
104221
+ width: "7",
104222
+ height: "16",
104223
+ stroke: "var(--button-icon-hover, rgb(24, 24, 26))",
104224
+ fill: "none",
104225
+ strokeWidth: "2"
104226
+ }
104227
+ ),
104228
+ /* @__PURE__ */ u4(
104229
+ "rect",
104230
+ {
104231
+ x: "13",
104232
+ y: "4",
104233
+ width: "7",
104234
+ height: "16",
104235
+ stroke: "var(--button-icon-hover, rgb(24, 24, 26))",
104236
+ fill: "none",
104237
+ strokeWidth: "2"
104238
+ }
104239
+ )
104240
+ ] })
104155
104241
  };
104242
+ var MENU_ITEMS = [
104243
+ { value: "single", icon: ICONS.single, label: "Single View" },
104244
+ { value: "split-horizontal", icon: ICONS["split-horizontal"], label: "Split Horizontal" },
104245
+ { value: "split-vertical", icon: ICONS["split-vertical"], label: "Split Vertical" }
104246
+ ];
104156
104247
 
104157
104248
  // ../widgets/src/info-widget.tsx
104158
104249
  var _InfoWidget = class extends Widget {
@@ -104160,13 +104251,10 @@ ${fps}`;
104160
104251
  super(props, _InfoWidget.defaultProps);
104161
104252
  this.className = "deck-widget-info";
104162
104253
  this.placement = "fill";
104163
- this.viewId = null;
104164
- props.position = props.position || [0, 0];
104165
- props.text = props.text || "";
104166
- props.visible = props.visible || false;
104167
- props.minOffset = props.minOffset ?? 0;
104254
+ this.setProps(this.props);
104168
104255
  }
104169
104256
  setProps(props) {
104257
+ this.viewId = props.viewId ?? this.viewId;
104170
104258
  super.setProps(props);
104171
104259
  }
104172
104260
  onCreateRootElement() {
@@ -104185,7 +104273,7 @@ ${fps}`;
104185
104273
  this.setProps({
104186
104274
  visible: tooltip !== null,
104187
104275
  ...tooltip,
104188
- style: { zIndex: 1, ...tooltip?.style }
104276
+ style: { zIndex: "1", ...tooltip?.style }
104189
104277
  });
104190
104278
  }
104191
104279
  }
@@ -104237,7 +104325,7 @@ ${fps}`;
104237
104325
  ),
104238
104326
  /* @__PURE__ */ u4("div", { className: "popup-arrow", style: { position: "absolute", width: "0px", height: "0px" } })
104239
104327
  ] }) : null;
104240
- B2(ui, rootElement);
104328
+ B3(ui, rootElement);
104241
104329
  requestAnimationFrame(() => {
104242
104330
  if (!this.props.visible || !rootElement.firstChild || !this.viewport)
104243
104331
  return;
@@ -104298,10 +104386,10 @@ ${fps}`;
104298
104386
  var InfoWidget = _InfoWidget;
104299
104387
  InfoWidget.defaultProps = {
104300
104388
  ...Widget.defaultProps,
104389
+ id: "info",
104301
104390
  position: [0, 0],
104302
104391
  text: "",
104303
104392
  visible: false,
104304
- // Set default minOffset if not provided
104305
104393
  minOffset: 0,
104306
104394
  viewId: null,
104307
104395
  mode: "hover",
@@ -104309,136 +104397,6 @@ ${fps}`;
104309
104397
  onClick: void 0
104310
104398
  };
104311
104399
 
104312
- // ../widgets/src/stats-widget.tsx
104313
- init_dist4();
104314
- var RIGHT_ARROW = "\u25B6";
104315
- var DOWN_ARROW = "\u2B07";
104316
- var DEFAULT_COUNT_FORMATTER = (stat) => `${stat.name}: ${stat.count}`;
104317
- function formatTime2(time) {
104318
- return time < 1e3 ? `${time.toFixed(2)}ms` : `${(time / 1e3).toFixed(2)}s`;
104319
- }
104320
- function formatMemory(bytes) {
104321
- const mb = bytes / 1e6;
104322
- return `${mb.toFixed(1)} MB`;
104323
- }
104324
- var DEFAULT_FORMATTERS = {
104325
- count: DEFAULT_COUNT_FORMATTER,
104326
- averageTime: (stat) => `${stat.name}: ${formatTime2(stat.getAverageTime())}`,
104327
- totalTime: (stat) => `${stat.name}: ${formatTime2(stat.time)}`,
104328
- fps: (stat) => `${stat.name}: ${Math.round(stat.getHz())}fps`,
104329
- memory: (stat) => `${stat.name}: ${formatMemory(stat.count)}`
104330
- };
104331
- var _StatsWidget = class extends Widget {
104332
- constructor(props = {}) {
104333
- super(props, _StatsWidget.defaultProps);
104334
- this.className = "deck-widget-stats";
104335
- this.placement = "top-left";
104336
- this._counter = 0;
104337
- this.collapsed = true;
104338
- this._toggleCollapsed = () => {
104339
- this.collapsed = !this.collapsed;
104340
- this.updateHTML();
104341
- };
104342
- this._formatters = { ...DEFAULT_FORMATTERS };
104343
- this.setProps(props);
104344
- this._resetOnUpdate = { ...this.props.resetOnUpdate };
104345
- this._stats = this.props.stats;
104346
- }
104347
- setProps(props) {
104348
- super.setProps(props);
104349
- this._stats = this._getStats();
104350
- if (props.formatters) {
104351
- for (const name13 in props.formatters) {
104352
- const f6 = props.formatters[name13];
104353
- this._formatters[name13] = typeof f6 === "string" ? DEFAULT_FORMATTERS[f6] || DEFAULT_COUNT_FORMATTER : f6;
104354
- }
104355
- }
104356
- if (props.resetOnUpdate) {
104357
- this._resetOnUpdate = { ...props.resetOnUpdate };
104358
- }
104359
- }
104360
- onAdd() {
104361
- this._stats = this._getStats();
104362
- this.updateHTML();
104363
- }
104364
- onRenderHTML(rootElement) {
104365
- const stats2 = this._stats;
104366
- const collapsed = this.collapsed;
104367
- const title = this.props.title || stats2?.id || "Stats";
104368
- const items = [];
104369
- if (!collapsed && stats2) {
104370
- stats2.forEach((stat) => {
104371
- const lines = this._getLines(stat);
104372
- if (this._resetOnUpdate && this._resetOnUpdate[stat.name]) {
104373
- stat.reset();
104374
- }
104375
- lines.forEach((line, i7) => {
104376
- items.push(
104377
- /* @__PURE__ */ u4("div", { style: { whiteSpace: "pre" }, children: line }, `${stat.name}-${i7}`)
104378
- );
104379
- });
104380
- });
104381
- }
104382
- B2(
104383
- /* @__PURE__ */ u4("div", { className: "deck-widget-stats-container", style: { cursor: "default" }, children: [
104384
- /* @__PURE__ */ u4(
104385
- "div",
104386
- {
104387
- className: "deck-widget-stats-header",
104388
- style: { cursor: "pointer", pointerEvents: "auto" },
104389
- onClick: this._toggleCollapsed,
104390
- children: [
104391
- collapsed ? RIGHT_ARROW : DOWN_ARROW,
104392
- " ",
104393
- title
104394
- ]
104395
- }
104396
- ),
104397
- !collapsed && /* @__PURE__ */ u4("div", { className: "deck-widget-stats-content deck-widget-common", children: items })
104398
- ] }),
104399
- rootElement
104400
- );
104401
- }
104402
- onRedraw() {
104403
- const framesPerUpdate = Math.max(1, this.props.framesPerUpdate || 1);
104404
- if (this._counter++ % framesPerUpdate === 0) {
104405
- console.log("Redrawing stats widget");
104406
- this.updateHTML();
104407
- }
104408
- }
104409
- _getStats() {
104410
- switch (this.props.type) {
104411
- case "deck":
104412
- return this.deck?.stats;
104413
- case "luma":
104414
- return Array.from(luma.stats.stats.values())[0];
104415
- case "device":
104416
- const device = this.deck?.device;
104417
- const stats2 = device?.statsManager.stats.values();
104418
- return stats2 ? Array.from(stats2)[0] : void 0;
104419
- case "custom":
104420
- return this.props.stats;
104421
- default:
104422
- throw new Error(`Unknown stats type: ${this.props.type}`);
104423
- }
104424
- }
104425
- _getLines(stat) {
104426
- const formatter = this._formatters[stat.name] || this._formatters[stat.type || ""] || DEFAULT_COUNT_FORMATTER;
104427
- return formatter(stat).split("\n");
104428
- }
104429
- };
104430
- var StatsWidget = _StatsWidget;
104431
- StatsWidget.defaultProps = {
104432
- ...Widget.defaultProps,
104433
- type: "deck",
104434
- stats: void 0,
104435
- title: "Stats",
104436
- framesPerUpdate: 1,
104437
- formatters: {},
104438
- resetOnUpdate: {},
104439
- id: "stats"
104440
- };
104441
-
104442
104400
  // ../widgets/src/lib/components/simple-menu.tsx
104443
104401
  var MENU_STYLE = {
104444
104402
  position: "absolute",
@@ -104447,7 +104405,7 @@ ${fps}`;
104447
104405
  background: "white",
104448
104406
  border: "1px solid #ccc",
104449
104407
  borderRadius: "4px",
104450
- marginTop: "4px",
104408
+ marginTop: "var(--menu-gap, 4px)",
104451
104409
  zIndex: 100
104452
104410
  };
104453
104411
  var MENU_ITEM_STYLE = {
@@ -104486,7 +104444,7 @@ ${fps}`;
104486
104444
  this.placement = "fill";
104487
104445
  this.pickInfo = null;
104488
104446
  this.pickInfo = null;
104489
- this.setProps(props);
104447
+ this.setProps(this.props);
104490
104448
  }
104491
104449
  onAdd({ deck }) {
104492
104450
  const element = document.createElement("div");
@@ -104514,7 +104472,7 @@ ${fps}`;
104514
104472
  style: { pointerEvents: "auto" }
104515
104473
  }
104516
104474
  ) : null;
104517
- B2(ui, rootElement);
104475
+ B3(ui, rootElement);
104518
104476
  }
104519
104477
  handleContextMenu(srcEvent) {
104520
104478
  if (srcEvent && (srcEvent.button === MOUSE_BUTTON_RIGHT || srcEvent.which === MOUSE_WHICH_RIGHT)) {
@@ -104542,6 +104500,7 @@ ${fps}`;
104542
104500
  var ContextMenuWidget = _ContextMenuWidget;
104543
104501
  ContextMenuWidget.defaultProps = {
104544
104502
  ...Widget.defaultProps,
104503
+ id: "context",
104545
104504
  viewId: null,
104546
104505
  visible: false,
104547
104506
  position: { x: 0, y: 0 },
@@ -104551,131 +104510,6 @@ ${fps}`;
104551
104510
  onMenuItemSelected: (key, pickInfo) => console.log("Context menu item selected:", key, pickInfo)
104552
104511
  };
104553
104512
 
104554
- // ../widgets/src/splitter-widget.tsx
104555
- var _SplitterWidget = class extends Widget {
104556
- constructor(props) {
104557
- super(props, _SplitterWidget.defaultProps);
104558
- this.className = "deck-widget-splitter";
104559
- this.placement = "fill";
104560
- }
104561
- setProps(props) {
104562
- super.setProps(props);
104563
- }
104564
- onRenderHTML(rootElement) {
104565
- rootElement.style.position = "absolute";
104566
- rootElement.style.top = "0";
104567
- rootElement.style.left = "0";
104568
- rootElement.style.width = "100%";
104569
- rootElement.style.height = "100%";
104570
- rootElement.style.margin = "0px";
104571
- B2(
104572
- /* @__PURE__ */ u4(
104573
- Splitter,
104574
- {
104575
- orientation: this.props.orientation,
104576
- initialSplit: this.props.initialSplit,
104577
- onChange: this.props.onChange,
104578
- onDragStart: this.props.onDragStart,
104579
- onDragEnd: this.props.onDragEnd
104580
- }
104581
- ),
104582
- rootElement
104583
- );
104584
- }
104585
- };
104586
- var SplitterWidget = _SplitterWidget;
104587
- SplitterWidget.defaultProps = {
104588
- ...Widget.defaultProps,
104589
- id: "splitter-widget",
104590
- viewId1: "",
104591
- viewId2: "",
104592
- orientation: "vertical",
104593
- initialSplit: 0.5,
104594
- onChange: () => {
104595
- },
104596
- onDragStart: () => {
104597
- },
104598
- onDragEnd: () => {
104599
- }
104600
- };
104601
- function Splitter({
104602
- orientation,
104603
- initialSplit,
104604
- onChange,
104605
- onDragStart,
104606
- onDragEnd
104607
- }) {
104608
- const [split, setSplit] = h3(initialSplit);
104609
- const dragging = A3(false);
104610
- const containerRef = A3(null);
104611
- const handleDragStart = (event) => {
104612
- dragging.current = true;
104613
- onDragStart?.();
104614
- document.addEventListener("mousemove", handleDragging);
104615
- document.addEventListener("mouseup", handleDragEnd);
104616
- event.preventDefault();
104617
- };
104618
- const handleDragging = (event) => {
104619
- if (!dragging.current || !containerRef.current)
104620
- return;
104621
- const rect = containerRef.current.getBoundingClientRect();
104622
- let newSplit;
104623
- if (orientation === "vertical") {
104624
- newSplit = (event.clientX - rect.left) / rect.width;
104625
- } else {
104626
- newSplit = (event.clientY - rect.top) / rect.height;
104627
- }
104628
- newSplit = Math.min(Math.max(newSplit, 0.05), 0.95);
104629
- setSplit(newSplit);
104630
- onChange?.(newSplit);
104631
- };
104632
- const handleDragEnd = (event) => {
104633
- if (!dragging.current)
104634
- return;
104635
- dragging.current = false;
104636
- onDragEnd?.();
104637
- document.removeEventListener("mousemove", handleDragging);
104638
- document.removeEventListener("mouseup", handleDragEnd);
104639
- };
104640
- const splitterStyle = orientation === "vertical" ? {
104641
- position: "absolute",
104642
- top: 0,
104643
- bottom: 0,
104644
- left: `${split * 100}%`,
104645
- width: "4px",
104646
- cursor: "col-resize",
104647
- background: "#ccc",
104648
- zIndex: 10,
104649
- pointerEvents: "auto",
104650
- boxShadow: "inset -1px 0 0 white, inset 1px 0 0 white"
104651
- } : {
104652
- position: "absolute",
104653
- left: 0,
104654
- right: 0,
104655
- top: `${split * 100}%`,
104656
- height: "4px",
104657
- cursor: "row-resize",
104658
- background: "#ccc",
104659
- zIndex: 10,
104660
- pointerEvents: "auto",
104661
- boxShadow: "inset -1px 0 0 white, inset 1px 0 0 white"
104662
- };
104663
- const containerStyle = {
104664
- position: "absolute",
104665
- top: 0,
104666
- left: 0,
104667
- right: 0,
104668
- bottom: 0
104669
- };
104670
- return /* @__PURE__ */ u4("div", { ref: containerRef, style: containerStyle, children: /* @__PURE__ */ u4(
104671
- "div",
104672
- {
104673
- style: splitterStyle,
104674
- onMouseDown: handleDragStart
104675
- }
104676
- ) });
104677
- }
104678
-
104679
104513
  // ../widgets/src/timeline-widget.tsx
104680
104514
  var _TimelineWidget = class extends Widget {
104681
104515
  constructor(props = {}) {
@@ -104713,9 +104547,11 @@ ${fps}`;
104713
104547
  }
104714
104548
  };
104715
104549
  this.currentTime = this.props.initialTime ?? this.props.timeRange[0];
104550
+ this.setProps(this.props);
104716
104551
  }
104717
104552
  setProps(props) {
104718
- this.placement = props.placement || this.placement;
104553
+ this.placement = props.placement ?? this.placement;
104554
+ this.viewId = props.viewId ?? this.viewId;
104719
104555
  super.setProps(props);
104720
104556
  }
104721
104557
  onAdd() {
@@ -104726,18 +104562,9 @@ ${fps}`;
104726
104562
  this.stop();
104727
104563
  }
104728
104564
  onRenderHTML(rootElement) {
104729
- B2(
104565
+ B3(
104730
104566
  /* @__PURE__ */ u4("div", { style: { display: "flex", alignItems: "center", pointerEvents: "auto" }, children: [
104731
- /* @__PURE__ */ u4(
104732
- "button",
104733
- {
104734
- type: "button",
104735
- className: "timeline-play-pause",
104736
- title: this.playing ? "Pause" : "Play",
104737
- onClick: this.handlePlayPause,
104738
- children: this.playing ? "\u23F8" : "\u25B6"
104739
- }
104740
- ),
104567
+ /* @__PURE__ */ u4(IconButton, { label: this.playing ? "Pause" : "Play", onClick: this.handlePlayPause, children: /* @__PURE__ */ u4("div", { className: "text", children: this.playing ? "\u23F8" : "\u25B6" }) }),
104741
104568
  /* @__PURE__ */ u4(
104742
104569
  "input",
104743
104570
  {
@@ -104773,6 +104600,7 @@ ${fps}`;
104773
104600
  ...Widget.defaultProps,
104774
104601
  id: "timeline",
104775
104602
  placement: "bottom-left",
104603
+ viewId: null,
104776
104604
  timeRange: [0, 100],
104777
104605
  step: 1,
104778
104606
  initialTime: void 0,
@@ -104781,123 +104609,445 @@ ${fps}`;
104781
104609
  playInterval: 1e3
104782
104610
  };
104783
104611
 
104784
- // ../widgets/src/lib/components/icon-menu.tsx
104785
- var MENU_STYLE2 = {
104786
- position: "absolute",
104787
- top: "100%",
104788
- left: 0,
104789
- background: "white",
104790
- border: "1px solid #ccc",
104791
- borderRadius: "4px",
104792
- marginTop: "4px",
104793
- zIndex: 100
104612
+ // ../widgets/src/screenshot-widget.tsx
104613
+ var _ScreenshotWidget = class extends Widget {
104614
+ constructor(props = {}) {
104615
+ super(props, _ScreenshotWidget.defaultProps);
104616
+ this.className = "deck-widget-screenshot";
104617
+ this.placement = "top-left";
104618
+ this.setProps(this.props);
104619
+ }
104620
+ setProps(props) {
104621
+ this.placement = props.placement ?? this.placement;
104622
+ this.viewId = props.viewId ?? this.viewId;
104623
+ super.setProps(props);
104624
+ }
104625
+ onRenderHTML(rootElement) {
104626
+ B3(
104627
+ /* @__PURE__ */ u4(
104628
+ IconButton,
104629
+ {
104630
+ className: "deck-widget-camera",
104631
+ label: this.props.label,
104632
+ onClick: this.handleClick.bind(this)
104633
+ }
104634
+ ),
104635
+ rootElement
104636
+ );
104637
+ }
104638
+ handleClick() {
104639
+ if (this.props.onCapture) {
104640
+ this.props.onCapture(this);
104641
+ return;
104642
+ }
104643
+ const dataURL = this.captureScreenToDataURL(this.props.imageFormat);
104644
+ if (dataURL) {
104645
+ this.downloadDataURL(dataURL, this.props.filename);
104646
+ }
104647
+ }
104648
+ /** @note only captures canvas contents, not HTML DOM or CSS styles */
104649
+ captureScreenToDataURL(imageFormat) {
104650
+ const canvas2 = this.deck?.getCanvas();
104651
+ return canvas2?.toDataURL(imageFormat);
104652
+ }
104653
+ /** Download a data URL */
104654
+ downloadDataURL(dataURL, filename2) {
104655
+ const link = document.createElement("a");
104656
+ link.href = dataURL;
104657
+ link.download = filename2;
104658
+ link.click();
104659
+ }
104794
104660
  };
104795
- var MENU_ITEM_STYLE2 = {
104796
- background: "white",
104797
- border: "none",
104798
- padding: "4px",
104799
- cursor: "pointer",
104800
- pointerEvents: "auto"
104661
+ var ScreenshotWidget = _ScreenshotWidget;
104662
+ ScreenshotWidget.defaultProps = {
104663
+ ...Widget.defaultProps,
104664
+ id: "screenshot",
104665
+ placement: "top-left",
104666
+ viewId: null,
104667
+ label: "Screenshot",
104668
+ filename: "screenshot.png",
104669
+ imageFormat: "image/png",
104670
+ onCapture: void 0
104801
104671
  };
104802
- function IconMenu(props) {
104803
- const [menuOpen, setMenuOpen] = h3(false);
104804
- const containerRef = A3(null);
104805
- const handleClickOutside = (event) => {
104806
- if (containerRef.current && !containerRef.current.contains(event.target)) {
104807
- setMenuOpen(false);
104808
- }
104809
- };
104810
- y4(() => {
104811
- document.addEventListener("mousedown", handleClickOutside);
104812
- return () => {
104813
- document.removeEventListener("mousedown", handleClickOutside);
104814
- };
104815
- }, [containerRef]);
104816
- const [selectedItem, setSelectedItem] = h3(props.initialItem);
104817
- const handleSelectItem = (item) => {
104818
- setSelectedItem(item);
104819
- setMenuOpen(false);
104820
- props.onItemSelected(item);
104821
- };
104822
- const handleButtonClick = () => setMenuOpen(!menuOpen);
104823
- const selectedMenuItem = props.menuItems.find((item) => item.value === selectedItem);
104824
- const label = props.label || selectedMenuItem?.label || "";
104825
- const Icon = props.icon || selectedMenuItem?.icon;
104826
- return /* @__PURE__ */ u4("div", { style: { position: "relative", display: "inline-block" }, ref: containerRef, children: [
104827
- /* @__PURE__ */ u4(IconButton, { className: props.className, label, onClick: handleButtonClick, children: /* @__PURE__ */ u4(Icon, {}) }),
104828
- menuOpen && /* @__PURE__ */ u4("div", { style: MENU_STYLE2, children: /* @__PURE__ */ u4("div", { style: { display: "flex", flexDirection: "column" }, children: props.menuItems.map((item) => /* @__PURE__ */ u4(
104829
- "button",
104830
- {
104831
- style: MENU_ITEM_STYLE2,
104832
- title: item.label,
104833
- onClick: () => handleSelectItem(item.value),
104834
- children: item.icon
104835
- },
104836
- item.value
104837
- )) }) })
104838
- ] });
104839
- }
104840
104672
 
104841
- // ../widgets/src/view-selector-widget.tsx
104842
- var _ViewSelectorWidget = class extends Widget {
104673
+ // ../widgets/src/themes.ts
104674
+ var LightTheme = {
104675
+ "--widget-margin": "12px",
104676
+ "--button-size": "28px",
104677
+ "--button-corner-radius": "8px",
104678
+ "--button-background": "#fff",
104679
+ "--button-stroke": "rgba(255, 255, 255, 0.3)",
104680
+ "--button-inner-stroke": "unset",
104681
+ "--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25)",
104682
+ "--button-backdrop-filter": "unset",
104683
+ "--button-icon-idle": "rgba(97, 97, 102, 1)",
104684
+ "--button-icon-hover": "rgba(24, 24, 26, 1)",
104685
+ "--button-text": "rgb(24, 24, 26, 1)",
104686
+ "--icon-compass-north-color": "rgb(240, 92, 68)",
104687
+ "--icon-compass-south-color": "rgb(204, 204, 204)",
104688
+ "--menu-gap": "4px"
104689
+ };
104690
+ var DarkTheme = {
104691
+ "--widget-margin": "12px",
104692
+ "--button-size": "28px",
104693
+ "--button-corner-radius": "8px",
104694
+ "--button-background": "rgba(18, 18, 20, 1)",
104695
+ "--button-stroke": "rgba(18, 18, 20, 0.30)",
104696
+ "--button-inner-stroke": "unset",
104697
+ "--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25)",
104698
+ "--button-backdrop-filter": "unset",
104699
+ "--button-icon-idle": "rgba(158, 157, 168, 1)",
104700
+ "--button-icon-hover": "rgba(215, 214, 229, 1)",
104701
+ "--button-text": "rgb(215, 214, 229, 1)",
104702
+ "--icon-compass-north-color": "rgb(240, 92, 68)",
104703
+ "--icon-compass-south-color": "rgb(200, 199, 209)",
104704
+ "--menu-gap": "4px"
104705
+ };
104706
+ var LightGlassTheme = {
104707
+ "--widget-margin": "12px",
104708
+ "--button-size": "28px",
104709
+ "--button-corner-radius": "8px",
104710
+ "--button-background": "rgba(255, 255, 255, 0.6)",
104711
+ "--button-stroke": "rgba(255, 255, 255, 0.3)",
104712
+ "--button-inner-stroke": "1px solid rgba(255, 255, 255, 0.6)",
104713
+ "--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
104714
+ "--button-backdrop-filter": "blur(4px)",
104715
+ "--button-icon-idle": "rgba(97, 97, 102, 1)",
104716
+ "--button-icon-hover": "rgba(24, 24, 26, 1)",
104717
+ "--button-text": "rgb(24, 24, 26, 1)",
104718
+ "--icon-compass-north-color": "rgb(240, 92, 68)",
104719
+ "--icon-compass-south-color": "rgb(204, 204, 204)",
104720
+ "--menu-gap": "4px"
104721
+ };
104722
+ var DarkGlassTheme = {
104723
+ "--widget-margin": "12px",
104724
+ "--button-size": "28px",
104725
+ "--button-corner-radius": "8px",
104726
+ "--button-background": "rgba(18, 18, 20, 0.75)",
104727
+ "--button-stroke": "rgba(18, 18, 20, 0.30)",
104728
+ "--button-inner-stroke": "1px solid rgba(18, 18, 20, 0.75)",
104729
+ "--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
104730
+ "--button-backdrop-filter": "blur(4px)",
104731
+ "--button-icon-idle": "rgba(158, 157, 168, 1)",
104732
+ "--button-icon-hover": "rgba(215, 214, 229, 1)",
104733
+ "--button-text": "rgb(215, 214, 229, 1)",
104734
+ "--icon-compass-north-color": "rgb(240, 92, 68)",
104735
+ "--icon-compass-south-color": "rgb(200, 199, 209)",
104736
+ "--menu-gap": "4px"
104737
+ };
104738
+
104739
+ // ../widgets/src/theme-widget.tsx
104740
+ var _ThemeWidget = class extends Widget {
104843
104741
  constructor(props = {}) {
104844
- super(props, _ViewSelectorWidget.defaultProps);
104845
- this.className = "deck-widget-view-selector";
104742
+ super(props, _ThemeWidget.defaultProps);
104743
+ this.className = "deck-widget-theme";
104846
104744
  this.placement = "top-left";
104847
- this.handleSelectMode = (viewMode) => {
104848
- this.viewMode = viewMode;
104849
- this.updateHTML();
104850
- };
104851
- this.placement = this.props.placement;
104852
- this.viewMode = this.props.initialViewMode;
104745
+ this.themeMode = "dark";
104746
+ this.themeMode = this._getInitialThemeMode();
104747
+ this.setProps(this.props);
104853
104748
  }
104749
+ // eslint-disable-next-line complexity
104854
104750
  setProps(props) {
104855
- super.setProps(props);
104751
+ const { lightModeTheme, darkModeTheme } = this.props;
104856
104752
  this.placement = props.placement ?? this.placement;
104753
+ this.viewId = props.viewId ?? this.viewId;
104754
+ super.setProps(props);
104755
+ switch (this.themeMode) {
104756
+ case "light":
104757
+ if (props.lightModeTheme && !deepEqual2(props.lightModeTheme, lightModeTheme, 1)) {
104758
+ this._setThemeMode("light");
104759
+ }
104760
+ break;
104761
+ case "dark":
104762
+ if (props.darkModeTheme && !deepEqual2(props.darkModeTheme, darkModeTheme, 1)) {
104763
+ this._setThemeMode("dark");
104764
+ }
104765
+ break;
104766
+ default:
104767
+ log_default.warn(`Invalid theme mode ${this.themeMode}`)();
104768
+ }
104857
104769
  }
104858
104770
  onRenderHTML(rootElement) {
104859
- B2(
104771
+ const { lightModeLabel, darkModeLabel } = this.props;
104772
+ B3(
104860
104773
  /* @__PURE__ */ u4(
104861
- IconMenu,
104774
+ IconButton,
104862
104775
  {
104863
- className: "deck-widget-view-selector",
104864
- menuItems: MENU_ITEMS,
104865
- initialItem: this.props.initialViewMode,
104866
- onItemSelected: this.handleSelectMode
104776
+ onClick: this._handleClick.bind(this),
104777
+ label: this.themeMode === "dark" ? darkModeLabel : lightModeLabel,
104778
+ className: this.themeMode === "dark" ? "deck-widget-moon" : "deck-widget-sun"
104867
104779
  }
104868
104780
  ),
104869
104781
  rootElement
104870
104782
  );
104871
104783
  }
104784
+ onAdd() {
104785
+ this._setThemeMode(this.themeMode);
104786
+ }
104787
+ _handleClick() {
104788
+ const newThemeMode = this.themeMode === "dark" ? "light" : "dark";
104789
+ this._setThemeMode(newThemeMode);
104790
+ }
104791
+ _setThemeMode(themeMode) {
104792
+ this.themeMode = themeMode;
104793
+ const container = this.rootElement?.closest(".deck-widget-container");
104794
+ if (container) {
104795
+ const themeStyle = themeMode === "dark" ? this.props.darkModeTheme : this.props.lightModeTheme;
104796
+ applyStyles(container, themeStyle);
104797
+ const label = this.themeMode === "dark" ? this.props.darkModeLabel : this.props.lightModeLabel;
104798
+ log_default.log(1, `Switched theme to ${label}`, themeStyle)();
104799
+ this.updateHTML();
104800
+ }
104801
+ }
104802
+ /** Read browser preference */
104803
+ _getInitialThemeMode() {
104804
+ const { initialThemeMode } = this.props;
104805
+ return initialThemeMode === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : initialThemeMode;
104806
+ }
104872
104807
  };
104873
- var ViewSelectorWidget = _ViewSelectorWidget;
104874
- ViewSelectorWidget.defaultProps = {
104808
+ var ThemeWidget = _ThemeWidget;
104809
+ ThemeWidget.defaultProps = {
104875
104810
  ...Widget.defaultProps,
104876
- id: "view-selector-widget",
104811
+ id: "theme",
104877
104812
  placement: "top-left",
104878
- label: "Split View",
104879
- initialViewMode: "single",
104880
- onViewModeChange: (viewMode) => {
104881
- console.log(viewMode);
104813
+ viewId: null,
104814
+ lightModeLabel: "Light Mode",
104815
+ lightModeTheme: LightGlassTheme,
104816
+ darkModeLabel: "Dark Mode",
104817
+ darkModeTheme: DarkGlassTheme,
104818
+ initialThemeMode: "auto"
104819
+ };
104820
+
104821
+ // ../widgets/src/loading-widget.tsx
104822
+ var _LoadingWidget = class extends Widget {
104823
+ constructor(props = {}) {
104824
+ super(props, _LoadingWidget.defaultProps);
104825
+ this.className = "deck-widget-loading";
104826
+ this.placement = "top-left";
104827
+ this.loading = true;
104828
+ this.setProps(this.props);
104829
+ }
104830
+ setProps(props) {
104831
+ this.placement = props.placement ?? this.placement;
104832
+ this.viewId = props.viewId ?? this.viewId;
104833
+ super.setProps(props);
104834
+ }
104835
+ onRenderHTML(rootElement) {
104836
+ B3(
104837
+ // TODO(ibgreen) - this should not be a button, but styling is so nested that it is easier to reuse this component.
104838
+ this.loading && /* @__PURE__ */ u4(
104839
+ IconButton,
104840
+ {
104841
+ className: "deck-widget-spinner",
104842
+ label: this.props.label,
104843
+ onClick: this.handleClick.bind(this)
104844
+ }
104845
+ ),
104846
+ rootElement
104847
+ );
104848
+ }
104849
+ onRedraw({ layers }) {
104850
+ const loading = layers.some((layer) => !layer.isLoaded);
104851
+ if (loading !== this.loading) {
104852
+ this.loading = loading;
104853
+ this.updateHTML();
104854
+ }
104855
+ }
104856
+ // TODO(ibgreen) - this should not be a button, see above.
104857
+ handleClick() {
104882
104858
  }
104883
104859
  };
104884
- var ICON_STYLE = { width: "24px", height: "24px" };
104885
- var ICONS = {
104886
- single: () => /* @__PURE__ */ u4("svg", { width: "24", height: "24", style: ICON_STYLE, children: /* @__PURE__ */ u4("rect", { x: "4", y: "4", width: "16", height: "16", stroke: "black", fill: "none", strokeWidth: "2" }) }),
104887
- "split-horizontal": () => /* @__PURE__ */ u4("svg", { width: "24", height: "24", style: ICON_STYLE, children: [
104888
- /* @__PURE__ */ u4("rect", { x: "4", y: "4", width: "16", height: "7", stroke: "black", fill: "none", strokeWidth: "2" }),
104889
- /* @__PURE__ */ u4("rect", { x: "4", y: "13", width: "16", height: "7", stroke: "black", fill: "none", strokeWidth: "2" })
104890
- ] }),
104891
- "split-vertical": () => /* @__PURE__ */ u4("svg", { width: "24", height: "24", style: ICON_STYLE, children: [
104892
- /* @__PURE__ */ u4("rect", { x: "4", y: "4", width: "7", height: "16", stroke: "black", fill: "none", strokeWidth: "2" }),
104893
- /* @__PURE__ */ u4("rect", { x: "13", y: "4", width: "7", height: "16", stroke: "black", fill: "none", strokeWidth: "2" })
104894
- ] })
104860
+ var LoadingWidget = _LoadingWidget;
104861
+ LoadingWidget.defaultProps = {
104862
+ ...Widget.defaultProps,
104863
+ id: "loading",
104864
+ placement: "top-left",
104865
+ viewId: null,
104866
+ label: "Loading layer data"
104867
+ };
104868
+
104869
+ // ../widgets/src/fps-widget.tsx
104870
+ var _FpsWidget = class extends Widget {
104871
+ constructor(props = {}) {
104872
+ super(props, _FpsWidget.defaultProps);
104873
+ this.className = "deck-widget-fps";
104874
+ this.placement = "top-left";
104875
+ this._lastFps = -1;
104876
+ this.setProps(this.props);
104877
+ }
104878
+ setProps(props) {
104879
+ this.placement = props.placement ?? this.placement;
104880
+ this.viewId = props.viewId ?? this.viewId;
104881
+ super.setProps(props);
104882
+ }
104883
+ onAdd({}) {
104884
+ this._lastFps = this._getFps();
104885
+ requestAnimationFrame(() => this._animate());
104886
+ }
104887
+ onRenderHTML(rootElement) {
104888
+ const fps = this._getFps();
104889
+ B3(
104890
+ /* @__PURE__ */ u4(IconButton, { children: /* @__PURE__ */ u4("div", { className: "text", children: [
104891
+ "FPS",
104892
+ /* @__PURE__ */ u4("br", {}),
104893
+ fps
104894
+ ] }) }),
104895
+ rootElement
104896
+ );
104897
+ }
104898
+ _animate() {
104899
+ const fps = this._getFps();
104900
+ if (this._lastFps !== fps) {
104901
+ this._lastFps = fps;
104902
+ this.updateHTML();
104903
+ }
104904
+ requestAnimationFrame(() => this._animate());
104905
+ }
104906
+ _getFps() {
104907
+ return Math.round(this.deck.metrics.fps ?? 0);
104908
+ }
104909
+ };
104910
+ var FpsWidget = _FpsWidget;
104911
+ FpsWidget.defaultProps = {
104912
+ ...Widget.defaultProps,
104913
+ id: "fps",
104914
+ placement: "top-left",
104915
+ viewId: null
104916
+ };
104917
+
104918
+ // ../widgets/src/stats-widget.tsx
104919
+ init_dist4();
104920
+ var RIGHT_ARROW = "\u25B6";
104921
+ var DOWN_ARROW = "\u2B07";
104922
+ var DEFAULT_COUNT_FORMATTER = (stat) => `${stat.name}: ${stat.count}`;
104923
+ function formatTime2(time) {
104924
+ return time < 1e3 ? `${time.toFixed(2)}ms` : `${(time / 1e3).toFixed(2)}s`;
104925
+ }
104926
+ function formatMemory(bytes) {
104927
+ const mb = bytes / 1e6;
104928
+ return `${mb.toFixed(1)} MB`;
104929
+ }
104930
+ var DEFAULT_FORMATTERS = {
104931
+ count: DEFAULT_COUNT_FORMATTER,
104932
+ averageTime: (stat) => `${stat.name}: ${formatTime2(stat.getAverageTime())}`,
104933
+ totalTime: (stat) => `${stat.name}: ${formatTime2(stat.time)}`,
104934
+ fps: (stat) => `${stat.name}: ${Math.round(stat.getHz())}fps`,
104935
+ memory: (stat) => `${stat.name}: ${formatMemory(stat.count)}`
104936
+ };
104937
+ var _StatsWidget = class extends Widget {
104938
+ constructor(props = {}) {
104939
+ super(props, _StatsWidget.defaultProps);
104940
+ this.className = "deck-widget-stats";
104941
+ this.placement = "top-left";
104942
+ this._counter = 0;
104943
+ this.collapsed = true;
104944
+ this._toggleCollapsed = () => {
104945
+ this.collapsed = !this.collapsed;
104946
+ this.updateHTML();
104947
+ };
104948
+ this._formatters = { ...DEFAULT_FORMATTERS };
104949
+ this._resetOnUpdate = { ...this.props.resetOnUpdate };
104950
+ this._stats = this.props.stats;
104951
+ this.setProps(props);
104952
+ }
104953
+ setProps(props) {
104954
+ this.placement = props.placement ?? this.placement;
104955
+ this.viewId = props.viewId ?? this.viewId;
104956
+ this._stats = this._getStats();
104957
+ if (props.formatters) {
104958
+ for (const name13 in props.formatters) {
104959
+ const f6 = props.formatters[name13];
104960
+ this._formatters[name13] = typeof f6 === "string" ? DEFAULT_FORMATTERS[f6] || DEFAULT_COUNT_FORMATTER : f6;
104961
+ }
104962
+ }
104963
+ if (props.resetOnUpdate) {
104964
+ this._resetOnUpdate = { ...props.resetOnUpdate };
104965
+ }
104966
+ super.setProps(props);
104967
+ }
104968
+ onAdd() {
104969
+ this._stats = this._getStats();
104970
+ this.updateHTML();
104971
+ }
104972
+ onRenderHTML(rootElement) {
104973
+ const stats2 = this._stats;
104974
+ const collapsed = this.collapsed;
104975
+ const title = this.props.title || stats2?.id || "Stats";
104976
+ const items = [];
104977
+ if (!collapsed && stats2) {
104978
+ stats2.forEach((stat) => {
104979
+ const lines = this._getLines(stat);
104980
+ if (this._resetOnUpdate && this._resetOnUpdate[stat.name]) {
104981
+ stat.reset();
104982
+ }
104983
+ lines.forEach((line, i7) => {
104984
+ items.push(
104985
+ /* @__PURE__ */ u4("div", { style: { whiteSpace: "pre" }, children: line }, `${stat.name}-${i7}`)
104986
+ );
104987
+ });
104988
+ });
104989
+ }
104990
+ B3(
104991
+ /* @__PURE__ */ u4("div", { className: "deck-widget-stats-container", style: { cursor: "default" }, children: [
104992
+ /* @__PURE__ */ u4(
104993
+ "div",
104994
+ {
104995
+ className: "deck-widget-stats-header",
104996
+ style: { cursor: "pointer", pointerEvents: "auto" },
104997
+ onClick: this._toggleCollapsed,
104998
+ children: [
104999
+ collapsed ? RIGHT_ARROW : DOWN_ARROW,
105000
+ " ",
105001
+ title
105002
+ ]
105003
+ }
105004
+ ),
105005
+ !collapsed && /* @__PURE__ */ u4("div", { className: "deck-widget-stats-content", children: items })
105006
+ ] }),
105007
+ rootElement
105008
+ );
105009
+ }
105010
+ onRedraw() {
105011
+ const framesPerUpdate = Math.max(1, this.props.framesPerUpdate || 1);
105012
+ if (this._counter++ % framesPerUpdate === 0) {
105013
+ this._stats = this._getStats();
105014
+ this.updateHTML();
105015
+ }
105016
+ }
105017
+ _getStats() {
105018
+ switch (this.props.type) {
105019
+ case "deck":
105020
+ return this.deck?.stats;
105021
+ case "luma":
105022
+ return Array.from(luma.stats.stats.values())[0];
105023
+ case "device":
105024
+ const device = this.deck?.device;
105025
+ const stats2 = device?.statsManager.stats.values();
105026
+ return stats2 ? Array.from(stats2)[0] : void 0;
105027
+ case "custom":
105028
+ return this.props.stats;
105029
+ default:
105030
+ throw new Error(`Unknown stats type: ${this.props.type}`);
105031
+ }
105032
+ }
105033
+ _getLines(stat) {
105034
+ const formatter = this._formatters[stat.name] || this._formatters[stat.type || ""] || DEFAULT_COUNT_FORMATTER;
105035
+ return formatter(stat).split("\n");
105036
+ }
105037
+ };
105038
+ var StatsWidget = _StatsWidget;
105039
+ StatsWidget.defaultProps = {
105040
+ ...Widget.defaultProps,
105041
+ type: "deck",
105042
+ placement: "top-left",
105043
+ viewId: null,
105044
+ stats: void 0,
105045
+ title: "Stats",
105046
+ framesPerUpdate: 1,
105047
+ formatters: {},
105048
+ resetOnUpdate: {},
105049
+ id: "stats"
104895
105050
  };
104896
- var MENU_ITEMS = [
104897
- { value: "single", icon: ICONS.single, label: "Single View" },
104898
- { value: "split-horizontal", icon: ICONS["split-horizontal"], label: "Split Horizontal" },
104899
- { value: "split-vertical", icon: ICONS["split-vertical"], label: "Split Vertical" }
104900
- ];
104901
105051
 
104902
105052
  // bundle.ts
104903
105053
  var h32 = __toESM(require_h3_js(), 1);