@deck.gl/widgets 9.2.10 → 9.3.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/compass-widget.js +5 -5
  2. package/dist/compass-widget.js.map +1 -1
  3. package/dist/context-menu-widget.d.ts +23 -18
  4. package/dist/context-menu-widget.d.ts.map +1 -1
  5. package/dist/context-menu-widget.js +44 -48
  6. package/dist/context-menu-widget.js.map +1 -1
  7. package/dist/dist.dev.js +2533 -420
  8. package/dist/fullscreen-widget.js +1 -1
  9. package/dist/fullscreen-widget.js.map +1 -1
  10. package/dist/geocoder-widget.d.ts +2 -4
  11. package/dist/geocoder-widget.d.ts.map +1 -1
  12. package/dist/geocoder-widget.js +16 -20
  13. package/dist/geocoder-widget.js.map +1 -1
  14. package/dist/gimbal-widget.d.ts +0 -3
  15. package/dist/gimbal-widget.d.ts.map +1 -1
  16. package/dist/gimbal-widget.js +4 -22
  17. package/dist/gimbal-widget.js.map +1 -1
  18. package/dist/index.cjs +921 -370
  19. package/dist/index.cjs.map +4 -4
  20. package/dist/index.d.ts +5 -3
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +4 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/info-widget.d.ts +38 -17
  25. package/dist/info-widget.d.ts.map +1 -1
  26. package/dist/info-widget.js +40 -130
  27. package/dist/info-widget.js.map +1 -1
  28. package/dist/lib/components/dropdown-menu.d.ts +10 -4
  29. package/dist/lib/components/dropdown-menu.d.ts.map +1 -1
  30. package/dist/lib/components/dropdown-menu.js +12 -7
  31. package/dist/lib/components/dropdown-menu.js.map +1 -1
  32. package/dist/lib/components/icon-menu.d.ts.map +1 -1
  33. package/dist/lib/components/icon-menu.js +2 -3
  34. package/dist/lib/components/icon-menu.js.map +1 -1
  35. package/dist/lib/components/popover.d.ts +30 -0
  36. package/dist/lib/components/popover.d.ts.map +1 -0
  37. package/dist/lib/components/popover.js +93 -0
  38. package/dist/lib/components/popover.js.map +1 -0
  39. package/dist/lib/components/range-input.d.ts +26 -0
  40. package/dist/lib/components/range-input.d.ts.map +1 -0
  41. package/dist/lib/components/range-input.js +261 -0
  42. package/dist/lib/components/range-input.js.map +1 -0
  43. package/dist/lib/components/user-content.d.ts +8 -0
  44. package/dist/lib/components/user-content.d.ts.map +1 -0
  45. package/dist/lib/components/user-content.js +15 -0
  46. package/dist/lib/components/user-content.js.map +1 -0
  47. package/dist/popup-widget.d.ts +63 -0
  48. package/dist/popup-widget.d.ts.map +1 -0
  49. package/dist/popup-widget.js +70 -0
  50. package/dist/popup-widget.js.map +1 -0
  51. package/dist/reset-view-widget.d.ts +1 -1
  52. package/dist/reset-view-widget.d.ts.map +1 -1
  53. package/dist/reset-view-widget.js +12 -11
  54. package/dist/reset-view-widget.js.map +1 -1
  55. package/dist/scrollbar-widget.d.ts +68 -0
  56. package/dist/scrollbar-widget.d.ts.map +1 -0
  57. package/dist/scrollbar-widget.js +181 -0
  58. package/dist/scrollbar-widget.js.map +1 -0
  59. package/dist/stats-widget.d.ts +4 -0
  60. package/dist/stats-widget.d.ts.map +1 -1
  61. package/dist/stats-widget.js +3 -3
  62. package/dist/stats-widget.js.map +1 -1
  63. package/dist/stylesheet.css +244 -29
  64. package/dist/theme-widget.d.ts.map +1 -1
  65. package/dist/theme-widget.js +7 -5
  66. package/dist/theme-widget.js.map +1 -1
  67. package/dist/themes.d.ts +30 -0
  68. package/dist/themes.d.ts.map +1 -1
  69. package/dist/themes.js +28 -4
  70. package/dist/themes.js.map +1 -1
  71. package/dist/timeline-widget.d.ts +25 -6
  72. package/dist/timeline-widget.d.ts.map +1 -1
  73. package/dist/timeline-widget.js +46 -18
  74. package/dist/timeline-widget.js.map +1 -1
  75. package/dist/zoom-widget.d.ts +2 -8
  76. package/dist/zoom-widget.d.ts.map +1 -1
  77. package/dist/zoom-widget.js +23 -18
  78. package/dist/zoom-widget.js.map +1 -1
  79. package/dist.min.js +2 -2
  80. package/package.json +4 -3
  81. package/src/compass-widget.tsx +5 -5
  82. package/src/context-menu-widget.tsx +86 -76
  83. package/src/fullscreen-widget.tsx +1 -1
  84. package/src/geocoder-widget.tsx +17 -24
  85. package/src/gimbal-widget.tsx +4 -26
  86. package/src/index.ts +11 -6
  87. package/src/info-widget.tsx +93 -157
  88. package/src/lib/components/dropdown-menu.tsx +42 -20
  89. package/src/lib/components/icon-menu.tsx +3 -4
  90. package/src/lib/components/popover.tsx +167 -0
  91. package/src/lib/components/range-input.tsx +432 -0
  92. package/src/lib/components/user-content.tsx +30 -0
  93. package/src/popup-widget.tsx +163 -0
  94. package/src/reset-view-widget.tsx +12 -11
  95. package/src/scrollbar-widget.tsx +288 -0
  96. package/src/stats-widget.tsx +10 -4
  97. package/src/stylesheet.css +244 -29
  98. package/src/theme-widget.tsx +7 -5
  99. package/src/themes.ts +35 -4
  100. package/src/timeline-widget.tsx +96 -33
  101. package/src/zoom-widget.tsx +25 -21
  102. package/dist/lib/components/grouped-icon-button.d.ts +0 -10
  103. package/dist/lib/components/grouped-icon-button.d.ts.map +0 -1
  104. package/dist/lib/components/grouped-icon-button.js +0 -7
  105. package/dist/lib/components/grouped-icon-button.js.map +0 -1
  106. package/dist/lib/components/simple-menu.d.ts +0 -16
  107. package/dist/lib/components/simple-menu.d.ts.map +0 -1
  108. package/dist/lib/components/simple-menu.js +0 -30
  109. package/dist/lib/components/simple-menu.js.map +0 -1
  110. package/src/lib/components/grouped-icon-button.tsx +0 -27
  111. package/src/lib/components/simple-menu.tsx +0 -52
package/dist/dist.dev.js CHANGED
@@ -62,8 +62,10 @@ var __exports__ = (() => {
62
62
  GimbalWidget: () => GimbalWidget,
63
63
  LightGlassTheme: () => LightGlassTheme,
64
64
  LightTheme: () => LightTheme,
65
+ PopupWidget: () => PopupWidget,
65
66
  ResetViewWidget: () => ResetViewWidget,
66
67
  ScreenshotWidget: () => ScreenshotWidget,
68
+ ScrollbarWidget: () => ScrollbarWidget,
67
69
  ZoomWidget: () => ZoomWidget,
68
70
  _ButtonGroup: () => ButtonGroup,
69
71
  _ContextMenuWidget: () => ContextMenuWidget,
@@ -73,13 +75,13 @@ var __exports__ = (() => {
73
75
  _FpsWidget: () => FpsWidget,
74
76
  _GeocoderWidget: () => GeocoderWidget,
75
77
  _GoogleGeocoder: () => GoogleGeocoder,
76
- _GroupedIconButton: () => GroupedIconButton,
77
78
  _IconButton: () => IconButton,
78
79
  _IconMenu: () => IconMenu,
79
80
  _InfoWidget: () => InfoWidget,
80
81
  _LoadingWidget: () => LoadingWidget,
81
82
  _MapboxGeocoder: () => MapboxGeocoder,
82
83
  _OpenCageGeocoder: () => OpenCageGeocoder,
84
+ _RangeInput: () => RangeInput,
83
85
  _ScaleWidget: () => ScaleWidget,
84
86
  _SimpleMenu: () => SimpleMenu,
85
87
  _SplitterWidget: () => SplitterWidget,
@@ -177,9 +179,9 @@ var __exports__ = (() => {
177
179
  P.__r = 0;
178
180
  }
179
181
  function S(n2, l3, u4, t3, i4, o3, r3, f4, e3, c3, s3) {
180
- var a3, v3, y3, d3, w3, _2 = t3 && t3.__k || p, g2 = l3.length;
181
- for (u4.__d = e3, $(u4, l3, _2), e3 = u4.__d, a3 = 0; a3 < g2; a3++)
182
- null != (y3 = u4.__k[a3]) && "boolean" != typeof y3 && "function" != typeof y3 && (v3 = -1 === y3.__i ? h : _2[y3.__i] || h, y3.__i = a3, O(n2, y3, v3, i4, o3, r3, f4, e3, c3, s3), d3 = y3.__e, y3.ref && v3.ref != y3.ref && (v3.ref && N(v3.ref, null, y3), s3.push(y3.ref, y3.__c || d3, y3)), null == w3 && null != d3 && (w3 = d3), 65536 & y3.__u || v3.__k === y3.__k ? e3 = I(y3, e3, n2) : "function" == typeof y3.type && void 0 !== y3.__d ? e3 = y3.__d : d3 && (e3 = d3.nextSibling), y3.__d = void 0, y3.__u &= -196609);
182
+ var a3, v3, y3, d3, w3, _3 = t3 && t3.__k || p, g2 = l3.length;
183
+ for (u4.__d = e3, $(u4, l3, _3), e3 = u4.__d, a3 = 0; a3 < g2; a3++)
184
+ null != (y3 = u4.__k[a3]) && "boolean" != typeof y3 && "function" != typeof y3 && (v3 = -1 === y3.__i ? h : _3[y3.__i] || h, y3.__i = a3, O(n2, y3, v3, i4, o3, r3, f4, e3, c3, s3), d3 = y3.__e, y3.ref && v3.ref != y3.ref && (v3.ref && N(v3.ref, null, y3), s3.push(y3.ref, y3.__c || d3, y3)), null == w3 && null != d3 && (w3 = d3), 65536 & y3.__u || v3.__k === y3.__k ? e3 = I(y3, e3, n2) : "function" == typeof y3.type && void 0 !== y3.__d ? e3 = y3.__d : d3 && (e3 = d3.nextSibling), y3.__d = void 0, y3.__u &= -196609);
183
185
  u4.__d = e3, u4.__e = w3;
184
186
  }
185
187
  function $(n2, l3, u4) {
@@ -266,7 +268,7 @@ var __exports__ = (() => {
266
268
  };
267
269
  }
268
270
  function O(n2, u4, t3, i4, o3, r3, f4, e3, c3, s3) {
269
- var a3, h4, p3, v3, w3, _2, g2, m2, x2, C3, M2, P2, $2, I2, H, L2, T3 = u4.type;
271
+ var a3, h4, p3, v3, w3, _3, g2, m2, x2, C3, M2, P2, $2, I2, H, L2, T3 = u4.type;
270
272
  if (void 0 !== u4.constructor)
271
273
  return null;
272
274
  128 & t3.__u && (c3 = !!(32 & t3.__u), r3 = [e3 = u4.__e = t3.__e]), (a3 = l.__b) && a3(u4);
@@ -285,7 +287,7 @@ var __exports__ = (() => {
285
287
  break n;
286
288
  }
287
289
  null != h4.componentWillUpdate && h4.componentWillUpdate(m2, h4.__s, M2), x2 && null != h4.componentDidUpdate && h4.__h.push(function() {
288
- h4.componentDidUpdate(v3, w3, _2);
290
+ h4.componentDidUpdate(v3, w3, _3);
289
291
  });
290
292
  }
291
293
  if (h4.context = M2, h4.props = m2, h4.__P = n2, h4.__e = false, $2 = l.__r, I2 = 0, x2) {
@@ -296,7 +298,7 @@ var __exports__ = (() => {
296
298
  do {
297
299
  h4.__d = false, $2 && $2(u4), a3 = h4.render(h4.props, h4.state, h4.context), h4.state = h4.__s;
298
300
  } while (h4.__d && ++I2 < 25);
299
- h4.state = h4.__s, null != h4.getChildContext && (i4 = d(d({}, i4), h4.getChildContext())), x2 && !p3 && null != h4.getSnapshotBeforeUpdate && (_2 = h4.getSnapshotBeforeUpdate(v3, w3)), S(n2, y(L2 = null != a3 && a3.type === k && null == a3.key ? a3.props.children : a3) ? L2 : [L2], u4, t3, i4, o3, r3, f4, e3, c3, s3), h4.base = u4.__e, u4.__u &= -161, h4.__h.length && f4.push(h4), g2 && (h4.__E = h4.__ = null);
301
+ h4.state = h4.__s, null != h4.getChildContext && (i4 = d(d({}, i4), h4.getChildContext())), x2 && !p3 && null != h4.getSnapshotBeforeUpdate && (_3 = h4.getSnapshotBeforeUpdate(v3, w3)), S(n2, y(L2 = null != a3 && a3.type === k && null == a3.key ? a3.props.children : a3) ? L2 : [L2], u4, t3, i4, o3, r3, f4, e3, c3, s3), h4.base = u4.__e, u4.__u &= -161, h4.__h.length && f4.push(h4), g2 && (h4.__E = h4.__ = null);
300
302
  } catch (n3) {
301
303
  if (u4.__v = null, c3 || null != r3) {
302
304
  for (u4.__u |= c3 ? 160 : 32; e3 && 8 === e3.nodeType && e3.nextSibling; )
@@ -325,7 +327,7 @@ var __exports__ = (() => {
325
327
  });
326
328
  }
327
329
  function z(l3, u4, t3, i4, o3, r3, f4, e3, c3) {
328
- var s3, a3, p3, v3, d3, _2, g2, m2 = t3.props, k3 = u4.props, b2 = u4.type;
330
+ var s3, a3, p3, v3, d3, _3, g2, m2 = t3.props, k3 = u4.props, b2 = u4.type;
329
331
  if ("svg" === b2 ? o3 = "http://www.w3.org/2000/svg" : "math" === b2 ? o3 = "http://www.w3.org/1998/Math/MathML" : o3 || (o3 = "http://www.w3.org/1999/xhtml"), null != r3) {
330
332
  for (s3 = 0; s3 < r3.length; s3++)
331
333
  if ((d3 = r3[s3]) && "setAttribute" in d3 == !!b2 && (b2 ? d3.localName === b2 : 3 === d3.nodeType)) {
@@ -355,13 +357,13 @@ var __exports__ = (() => {
355
357
  A(l3, s3, null, d3, o3);
356
358
  }
357
359
  for (s3 in k3)
358
- d3 = k3[s3], "children" == s3 ? v3 = d3 : "dangerouslySetInnerHTML" == s3 ? a3 = d3 : "value" == s3 ? _2 = d3 : "checked" == s3 ? g2 = d3 : "key" === s3 || e3 && "function" != typeof d3 || m2[s3] === d3 || A(l3, s3, d3, m2[s3], o3);
360
+ d3 = k3[s3], "children" == s3 ? v3 = d3 : "dangerouslySetInnerHTML" == s3 ? a3 = d3 : "value" == s3 ? _3 = d3 : "checked" == s3 ? g2 = d3 : "key" === s3 || e3 && "function" != typeof d3 || m2[s3] === d3 || A(l3, s3, d3, m2[s3], o3);
359
361
  if (a3)
360
362
  e3 || p3 && (a3.__html === p3.__html || a3.__html === l3.innerHTML) || (l3.innerHTML = a3.__html), u4.__k = [];
361
363
  else if (p3 && (l3.innerHTML = ""), S(l3, y(v3) ? v3 : [v3], u4, t3, i4, "foreignObject" === b2 ? "http://www.w3.org/1999/xhtml" : o3, r3, f4, r3 ? r3[0] : t3.__k && x(t3, 0), e3, c3), null != r3)
362
364
  for (s3 = r3.length; s3--; )
363
365
  null != r3[s3] && w(r3[s3]);
364
- e3 || (s3 = "value", void 0 !== _2 && (_2 !== l3[s3] || "progress" === b2 && !_2 || "option" === b2 && _2 !== m2[s3]) && A(l3, s3, _2, m2[s3], o3), s3 = "checked", void 0 !== g2 && g2 !== l3[s3] && A(l3, s3, g2, m2[s3], o3));
366
+ e3 || (s3 = "value", void 0 !== _3 && (_3 !== l3[s3] || "progress" === b2 && !_3 || "option" === b2 && _3 !== m2[s3]) && A(l3, s3, _3, m2[s3], o3), s3 = "checked", void 0 !== g2 && g2 !== l3[s3] && A(l3, s3, g2, m2[s3], o3));
365
367
  }
366
368
  return l3;
367
369
  }
@@ -442,10 +444,10 @@ var __exports__ = (() => {
442
444
  return /* @__PURE__ */ u2("div", { className: `deck-widget-button-group ${orientation}`, children });
443
445
  };
444
446
 
445
- // src/lib/components/grouped-icon-button.tsx
446
- var GroupedIconButton = (props) => {
447
+ // src/lib/components/icon-button.tsx
448
+ var IconButton = (props) => {
447
449
  const { className = "", label, onClick, children } = props;
448
- return /* @__PURE__ */ u2(
450
+ return /* @__PURE__ */ u2("div", { className: "deck-widget-button", children: /* @__PURE__ */ u2(
449
451
  "button",
450
452
  {
451
453
  className: `deck-widget-icon-button ${className}`,
@@ -454,7 +456,7 @@ var __exports__ = (() => {
454
456
  title: label,
455
457
  children: children ? children : /* @__PURE__ */ u2("div", { className: "deck-widget-icon" })
456
458
  }
457
- );
459
+ ) });
458
460
  };
459
461
 
460
462
  // src/zoom-widget.tsx
@@ -463,7 +465,6 @@ var __exports__ = (() => {
463
465
  super(props);
464
466
  this.className = "deck-widget-zoom";
465
467
  this.placement = "top-left";
466
- this.viewports = {};
467
468
  this.setProps(this.props);
468
469
  }
469
470
  setProps(props) {
@@ -474,7 +475,7 @@ var __exports__ = (() => {
474
475
  onRenderHTML(rootElement) {
475
476
  const ui = /* @__PURE__ */ u2(ButtonGroup, { orientation: this.props.orientation, children: [
476
477
  /* @__PURE__ */ u2(
477
- GroupedIconButton,
478
+ IconButton,
478
479
  {
479
480
  onClick: () => this.handleZoomIn(),
480
481
  label: this.props.zoomInLabel,
@@ -482,7 +483,7 @@ var __exports__ = (() => {
482
483
  }
483
484
  ),
484
485
  /* @__PURE__ */ u2(
485
- GroupedIconButton,
486
+ IconButton,
486
487
  {
487
488
  onClick: () => this.handleZoomOut(),
488
489
  label: this.props.zoomOutLabel,
@@ -492,13 +493,19 @@ var __exports__ = (() => {
492
493
  ] });
493
494
  B(ui, rootElement);
494
495
  }
495
- onViewportChange(viewport) {
496
- this.viewports[viewport.id] = viewport;
497
- }
498
- handleZoom(viewport, nextZoom) {
499
- const viewId = this.viewId || viewport?.id || "default-view";
496
+ handleZoom(viewId, nextZoom) {
497
+ const viewState = this.getViewState(viewId);
498
+ if (viewState) {
499
+ const { minZoom, maxZoom } = viewState;
500
+ if (Number.isFinite(minZoom)) {
501
+ nextZoom = Math.max(minZoom, nextZoom);
502
+ }
503
+ if (Number.isFinite(maxZoom)) {
504
+ nextZoom = Math.min(maxZoom, nextZoom);
505
+ }
506
+ }
500
507
  const nextViewState = {
501
- ...viewport,
508
+ ...viewState,
502
509
  zoom: nextZoom
503
510
  };
504
511
  if (this.props.transitionDuration > 0) {
@@ -510,19 +517,19 @@ var __exports__ = (() => {
510
517
  this.setViewState(viewId, nextViewState);
511
518
  }
512
519
  handleZoomIn() {
513
- for (const viewport of Object.values(this.viewports)) {
514
- this.handleZoom(viewport, viewport.zoom + 1);
520
+ const viewIds = this.viewId ? [this.viewId] : this.deck?.getViews().map((v3) => v3.id) ?? [];
521
+ for (const viewId of viewIds) {
522
+ const viewState = this.getViewState(viewId);
523
+ this.handleZoom(viewId, viewState.zoom + 1);
515
524
  }
516
525
  }
517
526
  handleZoomOut() {
518
- for (const viewport of Object.values(this.viewports)) {
519
- this.handleZoom(viewport, viewport.zoom - 1);
527
+ const viewIds = this.viewId ? [this.viewId] : this.deck?.getViews().map((v3) => v3.id) ?? [];
528
+ for (const viewId of viewIds) {
529
+ const viewState = this.getViewState(viewId);
530
+ this.handleZoom(viewId, viewState.zoom - 1);
520
531
  }
521
532
  }
522
- /** @todo - move to deck or widget manager */
523
- setViewState(viewId, viewState) {
524
- this.deck._onViewStateChange({ viewId, viewState, interactionState: {} });
525
- }
526
533
  };
527
534
  ZoomWidget.defaultProps = {
528
535
  ...import_core2.Widget.defaultProps,
@@ -537,23 +544,6 @@ var __exports__ = (() => {
537
544
 
538
545
  // src/reset-view-widget.tsx
539
546
  var import_core3 = __toESM(require_core(), 1);
540
-
541
- // src/lib/components/icon-button.tsx
542
- var IconButton = (props) => {
543
- const { className = "", label, onClick, children } = props;
544
- return /* @__PURE__ */ u2("div", { className: "deck-widget-button", children: /* @__PURE__ */ u2(
545
- "button",
546
- {
547
- className: `deck-widget-icon-button ${className}`,
548
- type: "button",
549
- onClick,
550
- title: label,
551
- children: children ? children : /* @__PURE__ */ u2("div", { className: "deck-widget-icon" })
552
- }
553
- ) });
554
- };
555
-
556
- // src/reset-view-widget.tsx
557
547
  var ResetViewWidget = class extends import_core3.Widget {
558
548
  constructor(props = {}) {
559
549
  super(props);
@@ -581,17 +571,19 @@ var __exports__ = (() => {
581
571
  }
582
572
  handleClick() {
583
573
  const initialViewState = this.props.initialViewState || this.deck?.props.initialViewState;
584
- this.setViewState(initialViewState);
574
+ this.resetViewState(initialViewState);
585
575
  }
586
- setViewState(viewState) {
587
- const viewId = this.props.viewId || "default-view";
588
- const nextViewState = {
589
- ...viewId !== "default-view" ? viewState?.[viewId] : viewState
590
- // only works for geospatial?
591
- // transitionDuration: this.props.transitionDuration,
592
- // transitionInterpolator: new FlyToInterpolator()
593
- };
594
- this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
576
+ resetViewState(viewState) {
577
+ const viewIds = this.viewId ? [this.viewId] : this.deck?.getViews().map((v3) => v3.id) ?? [];
578
+ for (const viewId of viewIds) {
579
+ const nextViewState = {
580
+ ...viewState?.[viewId] ?? viewState
581
+ // only works for geospatial?
582
+ // transitionDuration: this.props.transitionDuration,
583
+ // transitionInterpolator: new FlyToInterpolator()
584
+ };
585
+ this.setViewState(viewId, nextViewState);
586
+ }
595
587
  }
596
588
  };
597
589
  ResetViewWidget.defaultProps = {
@@ -696,7 +688,7 @@ var __exports__ = (() => {
696
688
  this.updateHTML();
697
689
  }
698
690
  resetOrbitView(viewport) {
699
- const viewId = this.getViewId(viewport);
691
+ const viewId = this.viewId || viewport?.id || "OrbitView";
700
692
  const viewState = this.getViewState(viewId);
701
693
  if ("rotationOrbit" in viewState || "rotationX" in viewState) {
702
694
  const nextViewState = {
@@ -708,11 +700,12 @@ var __exports__ = (() => {
708
700
  transitionProps: ["rotationOrbit", "rotationX"]
709
701
  })
710
702
  };
711
- this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
703
+ this.setViewState(viewId, nextViewState);
712
704
  }
713
705
  }
714
706
  getNormalizedRotation(viewport) {
715
- const viewState = this.getViewState(this.getViewId(viewport));
707
+ const viewId = this.viewId || viewport?.id || "OrbitView";
708
+ const viewState = this.getViewState(viewId);
716
709
  const [rz, rx] = this.getRotation(viewState);
717
710
  const rotationOrbit = normalizeAndClampAngle(rz);
718
711
  const rotationX = normalizeAndClampAngle(rx);
@@ -724,23 +717,6 @@ var __exports__ = (() => {
724
717
  }
725
718
  return [0, 0];
726
719
  }
727
- // Move to Widget/WidgetManager?
728
- getViewId(viewport) {
729
- const viewId = this.viewId || viewport?.id || "OrbitView";
730
- return viewId;
731
- }
732
- getViewState(viewId) {
733
- const viewManager = this.getViewManager();
734
- const viewState = viewId && viewManager.getViewState(viewId) || viewManager.viewState;
735
- return viewState;
736
- }
737
- getViewManager() {
738
- const viewManager = this.deck?.viewManager;
739
- if (!viewManager) {
740
- throw new Error("wigdet must be added to a deck instance");
741
- }
742
- return viewManager;
743
- }
744
720
  };
745
721
  GimbalWidget.defaultProps = {
746
722
  ...import_core4.Widget.defaultProps,
@@ -781,7 +757,7 @@ var __exports__ = (() => {
781
757
  super.setProps(props);
782
758
  }
783
759
  onRenderHTML(rootElement) {
784
- const viewId = this.viewId || Object.values(this.viewports)[0]?.id || "default-view";
760
+ const viewId = this.viewId || Object.values(this.viewports)[0]?.id;
785
761
  const widgetViewport = this.viewports[viewId];
786
762
  const [rz, rx] = this.getRotation(widgetViewport);
787
763
  const ui = /* @__PURE__ */ u2("div", { className: "deck-widget-button", style: { perspective: 100 }, children: /* @__PURE__ */ u2(
@@ -830,16 +806,17 @@ var __exports__ = (() => {
830
806
  return [0, 0];
831
807
  }
832
808
  handleCompassReset(viewport) {
833
- const viewId = this.viewId || viewport.id || "default-view";
809
+ const viewId = this.viewId || viewport.id;
834
810
  if (viewport instanceof import_core5.WebMercatorViewport) {
811
+ const viewState = this.getViewState(viewId);
835
812
  const nextViewState = {
836
- ...viewport,
813
+ ...viewState,
837
814
  bearing: 0,
838
815
  ...this.getRotation(viewport)[0] === 0 ? { pitch: 0 } : {},
839
816
  transitionDuration: this.props.transitionDuration,
840
817
  transitionInterpolator: new import_core5.FlyToInterpolator()
841
818
  };
842
- this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
819
+ this.setViewState(viewId, nextViewState);
843
820
  }
844
821
  }
845
822
  };
@@ -1062,6 +1039,10 @@ var __exports__ = (() => {
1062
1039
  var i4 = d2(t2++, 3);
1063
1040
  !c2.__s && C2(i4.__H, u4) && (i4.__ = n2, i4.i = u4, r2.__H.__h.push(i4));
1064
1041
  }
1042
+ function _2(n2, u4) {
1043
+ var i4 = d2(t2++, 4);
1044
+ !c2.__s && C2(i4.__H, u4) && (i4.__ = n2, i4.i = u4, r2.__h.push(i4));
1045
+ }
1065
1046
  function A2(n2) {
1066
1047
  return o2 = 5, T2(function() {
1067
1048
  return { current: n2 };
@@ -1071,6 +1052,11 @@ var __exports__ = (() => {
1071
1052
  var u4 = d2(t2++, 7);
1072
1053
  return C2(u4.__H, r3) && (u4.__ = n2(), u4.__H = r3, u4.__h = n2), u4.__;
1073
1054
  }
1055
+ function q2(n2, t3) {
1056
+ return o2 = 8, T2(function() {
1057
+ return n2;
1058
+ }, t3);
1059
+ }
1074
1060
  function j2() {
1075
1061
  for (var n2; n2 = f3.shift(); )
1076
1062
  if (n2.__P && n2.__H)
@@ -1155,11 +1141,22 @@ var __exports__ = (() => {
1155
1141
  }
1156
1142
  var DropdownMenu = (props) => {
1157
1143
  const [isOpen, setIsOpen] = h2(false);
1144
+ return /* @__PURE__ */ u2(
1145
+ SimpleMenu,
1146
+ {
1147
+ ...props,
1148
+ style: { ...props.style, position: "absolute" },
1149
+ isOpen,
1150
+ onClose: () => setIsOpen(false),
1151
+ trigger: /* @__PURE__ */ u2("button", { className: "deck-widget-dropdown-button", onClick: () => setIsOpen(!isOpen), children: /* @__PURE__ */ u2("span", { className: `deck-widget-dropdown-icon ${isOpen ? "open" : ""}` }) })
1152
+ }
1153
+ );
1154
+ };
1155
+ var SimpleMenu = (props) => {
1158
1156
  const dropdownRef = A2(null);
1159
- const toggleDropdown = () => setIsOpen(!isOpen);
1160
1157
  const handleClickOutside = (event) => {
1161
1158
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
1162
- setIsOpen(false);
1159
+ props.onClose();
1163
1160
  }
1164
1161
  };
1165
1162
  y2(() => {
@@ -1168,22 +1165,25 @@ var __exports__ = (() => {
1168
1165
  document.removeEventListener("mousedown", handleClickOutside);
1169
1166
  };
1170
1167
  }, []);
1171
- const handleSelect = (item) => {
1172
- props.onSelect(getMenuItemValue(item));
1173
- setIsOpen(false);
1168
+ const handleSelect = (value) => {
1169
+ if (value) {
1170
+ props.onSelect(value);
1171
+ props.onClose();
1172
+ }
1174
1173
  };
1175
1174
  if (props.menuItems.length === 0) {
1176
1175
  return null;
1177
1176
  }
1178
- return /* @__PURE__ */ u2("div", { className: "deck-widget-dropdown-container", ref: dropdownRef, style: props.style, children: [
1179
- /* @__PURE__ */ u2("button", { className: "deck-widget-dropdown-button", onClick: toggleDropdown, children: /* @__PURE__ */ u2("span", { className: `deck-widget-dropdown-icon ${isOpen ? "open" : ""}` }) }),
1180
- isOpen && /* @__PURE__ */ u2("ul", { className: "deck-widget-dropdown-menu", children: props.menuItems.map((item) => {
1177
+ return /* @__PURE__ */ u2("div", { className: "deck-widget-dropdown-container", ref: dropdownRef, children: [
1178
+ props.trigger,
1179
+ props.isOpen && /* @__PURE__ */ u2("ul", { className: "deck-widget-dropdown-menu", style: props.style, children: props.menuItems.map((item, i4) => {
1180
+ const value = getMenuItemValue(item);
1181
1181
  const icon = getMenuItemIcon(item);
1182
1182
  return /* @__PURE__ */ u2(
1183
1183
  "li",
1184
1184
  {
1185
- className: "deck-widget-dropdown-item",
1186
- onClick: () => handleSelect(item),
1185
+ className: `deck-widget-dropdown-item ${value ? "" : "disabled"}`,
1186
+ onClick: () => handleSelect(value),
1187
1187
  children: [
1188
1188
  icon && /* @__PURE__ */ u2(
1189
1189
  "span",
@@ -1195,7 +1195,7 @@ var __exports__ = (() => {
1195
1195
  getMenuItemLabel(item)
1196
1196
  ]
1197
1197
  },
1198
- getMenuItemValue(item)
1198
+ i4
1199
1199
  );
1200
1200
  }) })
1201
1201
  ] });
@@ -1435,7 +1435,7 @@ var __exports__ = (() => {
1435
1435
  try {
1436
1436
  const coordinates = await CurrentLocationGeocoder.geocode();
1437
1437
  if (coordinates) {
1438
- this.setViewState(coordinates);
1438
+ this.flyTo(coordinates);
1439
1439
  }
1440
1440
  } catch (error) {
1441
1441
  this.geocodeHistory.errorText = error instanceof Error ? error.message : "Location error";
@@ -1457,10 +1457,9 @@ var __exports__ = (() => {
1457
1457
  this.updateHTML();
1458
1458
  }
1459
1459
  if (coordinates) {
1460
- this.setViewState(coordinates);
1460
+ this.flyTo(coordinates);
1461
1461
  }
1462
1462
  };
1463
- this.viewports = {};
1464
1463
  this.setProps(this.props);
1465
1464
  }
1466
1465
  setProps(props) {
@@ -1493,22 +1492,20 @@ var __exports__ = (() => {
1493
1492
  rootElement
1494
1493
  );
1495
1494
  }
1496
- // TODO - MOVE TO WIDGETIMPL?
1497
- setViewState(viewState) {
1498
- const viewId = this.props.viewId || viewState?.id || "default-view";
1499
- const viewport = this.viewports[viewId] || {};
1500
- const nextViewState = {
1501
- ...viewport,
1502
- ...viewState
1503
- };
1504
- if (this.props.transitionDuration > 0) {
1505
- nextViewState.transitionDuration = this.props.transitionDuration;
1506
- nextViewState.transitionInterpolator = "latitude" in nextViewState ? new import_core8.FlyToInterpolator() : new import_core8.LinearInterpolator();
1495
+ flyTo(viewState) {
1496
+ const viewIds = this.viewId ? [this.viewId] : this.deck?.getViews().map((v3) => v3.id) ?? [];
1497
+ for (const viewId of viewIds) {
1498
+ const currentViewState = this.getViewState(viewId);
1499
+ const nextViewState = {
1500
+ ...currentViewState,
1501
+ ...viewState
1502
+ };
1503
+ if (this.props.transitionDuration > 0) {
1504
+ nextViewState.transitionDuration = this.props.transitionDuration;
1505
+ nextViewState.transitionInterpolator = "latitude" in nextViewState ? new import_core8.FlyToInterpolator() : new import_core8.LinearInterpolator();
1506
+ }
1507
+ this.setViewState(viewId, nextViewState);
1507
1508
  }
1508
- this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
1509
- }
1510
- onViewportChange(viewport) {
1511
- this.viewports[viewport.id] = viewport;
1512
1509
  }
1513
1510
  };
1514
1511
  GeocoderWidget.defaultProps = {
@@ -1580,7 +1577,7 @@ var __exports__ = (() => {
1580
1577
  super.setProps(props);
1581
1578
  }
1582
1579
  getContainer() {
1583
- return this.props.container || this.deck?.getCanvas()?.parentElement;
1580
+ return this.props.container || this.deck?.props.parent || this.deck?.getCanvas()?.parentElement;
1584
1581
  }
1585
1582
  onFullscreenChange() {
1586
1583
  const prevFullscreen = this.fullscreen;
@@ -1783,7 +1780,7 @@ var __exports__ = (() => {
1783
1780
  return /* @__PURE__ */ u2("div", { style: { position: "relative", display: "inline-block" }, ref: containerRef, children: [
1784
1781
  /* @__PURE__ */ u2(IconButton, { className: props.className, label, onClick: handleButtonClick, children: icon }),
1785
1782
  menuOpen && /* @__PURE__ */ u2("div", { className: "deck-widget-icon-menu", children: /* @__PURE__ */ u2(ButtonGroup, { orientation: "vertical", children: props.menuItems.map((item) => /* @__PURE__ */ u2(
1786
- GroupedIconButton,
1783
+ IconButton,
1787
1784
  {
1788
1785
  label: item.label,
1789
1786
  onClick: () => handleSelectItem(item.value),
@@ -1915,345 +1912,2428 @@ var __exports__ = (() => {
1915
1912
  ];
1916
1913
 
1917
1914
  // src/info-widget.tsx
1918
- var import_core12 = __toESM(require_core(), 1);
1919
- var InfoWidget = class extends import_core12.Widget {
1920
- constructor(props) {
1921
- super(props);
1922
- this.className = "deck-widget-info";
1923
- this.placement = "fill";
1924
- this.setProps(this.props);
1925
- }
1926
- setProps(props) {
1927
- this.viewId = props.viewId ?? this.viewId;
1928
- super.setProps(props);
1915
+ var import_core13 = __toESM(require_core(), 1);
1916
+
1917
+ // ../../node_modules/@floating-ui/core/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
1918
+ var min = Math.min;
1919
+ var max = Math.max;
1920
+ var oppositeSideMap = {
1921
+ left: "right",
1922
+ right: "left",
1923
+ bottom: "top",
1924
+ top: "bottom"
1925
+ };
1926
+ var oppositeAlignmentMap = {
1927
+ start: "end",
1928
+ end: "start"
1929
+ };
1930
+ function clamp(start, value, end) {
1931
+ return max(start, min(value, end));
1932
+ }
1933
+ function evaluate(value, param) {
1934
+ return typeof value === "function" ? value(param) : value;
1935
+ }
1936
+ function getSide(placement) {
1937
+ return placement.split("-")[0];
1938
+ }
1939
+ function getAlignment(placement) {
1940
+ return placement.split("-")[1];
1941
+ }
1942
+ function getOppositeAxis(axis) {
1943
+ return axis === "x" ? "y" : "x";
1944
+ }
1945
+ function getAxisLength(axis) {
1946
+ return axis === "y" ? "height" : "width";
1947
+ }
1948
+ function getSideAxis(placement) {
1949
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
1950
+ }
1951
+ function getAlignmentAxis(placement) {
1952
+ return getOppositeAxis(getSideAxis(placement));
1953
+ }
1954
+ function getAlignmentSides(placement, rects, rtl) {
1955
+ if (rtl === void 0) {
1956
+ rtl = false;
1957
+ }
1958
+ const alignment = getAlignment(placement);
1959
+ const alignmentAxis = getAlignmentAxis(placement);
1960
+ const length = getAxisLength(alignmentAxis);
1961
+ let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
1962
+ if (rects.reference[length] > rects.floating[length]) {
1963
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1964
+ }
1965
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1966
+ }
1967
+ function getExpandedPlacements(placement) {
1968
+ const oppositePlacement = getOppositePlacement(placement);
1969
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1970
+ }
1971
+ function getOppositeAlignmentPlacement(placement) {
1972
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
1973
+ }
1974
+ function getSideList(side, isStart, rtl) {
1975
+ const lr = ["left", "right"];
1976
+ const rl = ["right", "left"];
1977
+ const tb = ["top", "bottom"];
1978
+ const bt = ["bottom", "top"];
1979
+ switch (side) {
1980
+ case "top":
1981
+ case "bottom":
1982
+ if (rtl)
1983
+ return isStart ? rl : lr;
1984
+ return isStart ? lr : rl;
1985
+ case "left":
1986
+ case "right":
1987
+ return isStart ? tb : bt;
1988
+ default:
1989
+ return [];
1929
1990
  }
1930
- onCreateRootElement() {
1931
- const element = super.onCreateRootElement();
1932
- const style = { margin: "0px", top: "0px", left: "0px", position: "absolute" };
1933
- Object.entries(style).forEach(([key, value]) => element.style.setProperty(key, value));
1934
- return element;
1991
+ }
1992
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1993
+ const alignment = getAlignment(placement);
1994
+ let list = getSideList(getSide(placement), direction === "start", rtl);
1995
+ if (alignment) {
1996
+ list = list.map((side) => side + "-" + alignment);
1997
+ if (flipAlignment) {
1998
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
1999
+ }
1935
2000
  }
1936
- onViewportChange(viewport) {
1937
- this.viewport = viewport;
1938
- this.updateHTML();
2001
+ return list;
2002
+ }
2003
+ function getOppositePlacement(placement) {
2004
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
2005
+ }
2006
+ function expandPaddingObject(padding) {
2007
+ return {
2008
+ top: 0,
2009
+ right: 0,
2010
+ bottom: 0,
2011
+ left: 0,
2012
+ ...padding
2013
+ };
2014
+ }
2015
+ function getPaddingObject(padding) {
2016
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
2017
+ top: padding,
2018
+ right: padding,
2019
+ bottom: padding,
2020
+ left: padding
2021
+ };
2022
+ }
2023
+ function rectToClientRect(rect) {
2024
+ const {
2025
+ x: x2,
2026
+ y: y3,
2027
+ width,
2028
+ height
2029
+ } = rect;
2030
+ return {
2031
+ width,
2032
+ height,
2033
+ top: y3,
2034
+ left: x2,
2035
+ right: x2 + width,
2036
+ bottom: y3 + height,
2037
+ x: x2,
2038
+ y: y3
2039
+ };
2040
+ }
2041
+
2042
+ // ../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs
2043
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
2044
+ let {
2045
+ reference,
2046
+ floating
2047
+ } = _ref;
2048
+ const sideAxis = getSideAxis(placement);
2049
+ const alignmentAxis = getAlignmentAxis(placement);
2050
+ const alignLength = getAxisLength(alignmentAxis);
2051
+ const side = getSide(placement);
2052
+ const isVertical = sideAxis === "y";
2053
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
2054
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
2055
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
2056
+ let coords;
2057
+ switch (side) {
2058
+ case "top":
2059
+ coords = {
2060
+ x: commonX,
2061
+ y: reference.y - floating.height
2062
+ };
2063
+ break;
2064
+ case "bottom":
2065
+ coords = {
2066
+ x: commonX,
2067
+ y: reference.y + reference.height
2068
+ };
2069
+ break;
2070
+ case "right":
2071
+ coords = {
2072
+ x: reference.x + reference.width,
2073
+ y: commonY
2074
+ };
2075
+ break;
2076
+ case "left":
2077
+ coords = {
2078
+ x: reference.x - floating.width,
2079
+ y: commonY
2080
+ };
2081
+ break;
2082
+ default:
2083
+ coords = {
2084
+ x: reference.x,
2085
+ y: reference.y
2086
+ };
1939
2087
  }
1940
- onHover(info) {
1941
- if (this.props.mode === "hover" && this.props.getTooltip) {
1942
- const tooltip = this.props.getTooltip(info, this);
1943
- this.setProps({
1944
- visible: tooltip !== null,
1945
- ...tooltip,
1946
- style: { zIndex: "1", ...tooltip?.style }
1947
- });
1948
- }
2088
+ switch (getAlignment(placement)) {
2089
+ case "start":
2090
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
2091
+ break;
2092
+ case "end":
2093
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
2094
+ break;
1949
2095
  }
1950
- onClick(info) {
1951
- if (this.props.mode === "click" && this.props.getTooltip) {
1952
- const tooltip = this.props.getTooltip(info, this);
1953
- this.setProps({
1954
- visible: tooltip !== null,
1955
- ...tooltip
1956
- });
1957
- return tooltip !== null;
2096
+ return coords;
2097
+ }
2098
+ var computePosition = async (reference, floating, config) => {
2099
+ const {
2100
+ placement = "bottom",
2101
+ strategy = "absolute",
2102
+ middleware = [],
2103
+ platform: platform2
2104
+ } = config;
2105
+ const validMiddleware = middleware.filter(Boolean);
2106
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
2107
+ let rects = await platform2.getElementRects({
2108
+ reference,
2109
+ floating,
2110
+ strategy
2111
+ });
2112
+ let {
2113
+ x: x2,
2114
+ y: y3
2115
+ } = computeCoordsFromPlacement(rects, placement, rtl);
2116
+ let statefulPlacement = placement;
2117
+ let middlewareData = {};
2118
+ let resetCount = 0;
2119
+ for (let i4 = 0; i4 < validMiddleware.length; i4++) {
2120
+ const {
2121
+ name,
2122
+ fn
2123
+ } = validMiddleware[i4];
2124
+ const {
2125
+ x: nextX,
2126
+ y: nextY,
2127
+ data,
2128
+ reset
2129
+ } = await fn({
2130
+ x: x2,
2131
+ y: y3,
2132
+ initialPlacement: placement,
2133
+ placement: statefulPlacement,
2134
+ strategy,
2135
+ middlewareData,
2136
+ rects,
2137
+ platform: platform2,
2138
+ elements: {
2139
+ reference,
2140
+ floating
2141
+ }
2142
+ });
2143
+ x2 = nextX != null ? nextX : x2;
2144
+ y3 = nextY != null ? nextY : y3;
2145
+ middlewareData = {
2146
+ ...middlewareData,
2147
+ [name]: {
2148
+ ...middlewareData[name],
2149
+ ...data
2150
+ }
2151
+ };
2152
+ if (reset && resetCount <= 50) {
2153
+ resetCount++;
2154
+ if (typeof reset === "object") {
2155
+ if (reset.placement) {
2156
+ statefulPlacement = reset.placement;
2157
+ }
2158
+ if (reset.rects) {
2159
+ rects = reset.rects === true ? await platform2.getElementRects({
2160
+ reference,
2161
+ floating,
2162
+ strategy
2163
+ }) : reset.rects;
2164
+ }
2165
+ ({
2166
+ x: x2,
2167
+ y: y3
2168
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
2169
+ }
2170
+ i4 = -1;
1958
2171
  }
1959
- return this.props.onClick?.(this, info) || false;
1960
2172
  }
1961
- onAdd({ deck, viewId }) {
1962
- this.deck = deck;
1963
- if (!viewId) {
1964
- this.viewport = deck.getViewports()[0];
1965
- } else {
1966
- this.viewport = deck.getViewports().find((viewport) => viewport.id === viewId);
2173
+ return {
2174
+ x: x2,
2175
+ y: y3,
2176
+ placement: statefulPlacement,
2177
+ strategy,
2178
+ middlewareData
2179
+ };
2180
+ };
2181
+ async function detectOverflow(state, options) {
2182
+ var _await$platform$isEle;
2183
+ if (options === void 0) {
2184
+ options = {};
2185
+ }
2186
+ const {
2187
+ x: x2,
2188
+ y: y3,
2189
+ platform: platform2,
2190
+ rects,
2191
+ elements,
2192
+ strategy
2193
+ } = state;
2194
+ const {
2195
+ boundary = "clippingAncestors",
2196
+ rootBoundary = "viewport",
2197
+ elementContext = "floating",
2198
+ altBoundary = false,
2199
+ padding = 0
2200
+ } = evaluate(options, state);
2201
+ const paddingObject = getPaddingObject(padding);
2202
+ const altContext = elementContext === "floating" ? "reference" : "floating";
2203
+ const element = elements[altBoundary ? altContext : elementContext];
2204
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
2205
+ element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
2206
+ boundary,
2207
+ rootBoundary,
2208
+ strategy
2209
+ }));
2210
+ const rect = elementContext === "floating" ? {
2211
+ x: x2,
2212
+ y: y3,
2213
+ width: rects.floating.width,
2214
+ height: rects.floating.height
2215
+ } : rects.reference;
2216
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
2217
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
2218
+ x: 1,
2219
+ y: 1
2220
+ } : {
2221
+ x: 1,
2222
+ y: 1
2223
+ };
2224
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
2225
+ elements,
2226
+ rect,
2227
+ offsetParent,
2228
+ strategy
2229
+ }) : rect);
2230
+ return {
2231
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
2232
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
2233
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
2234
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
2235
+ };
2236
+ }
2237
+ var arrow = (options) => ({
2238
+ name: "arrow",
2239
+ options,
2240
+ async fn(state) {
2241
+ const {
2242
+ x: x2,
2243
+ y: y3,
2244
+ placement,
2245
+ rects,
2246
+ platform: platform2,
2247
+ elements,
2248
+ middlewareData
2249
+ } = state;
2250
+ const {
2251
+ element,
2252
+ padding = 0
2253
+ } = evaluate(options, state) || {};
2254
+ if (element == null) {
2255
+ return {};
1967
2256
  }
1968
- }
1969
- onRenderHTML(rootElement) {
1970
- if (!this.viewport) {
1971
- return;
2257
+ const paddingObject = getPaddingObject(padding);
2258
+ const coords = {
2259
+ x: x2,
2260
+ y: y3
2261
+ };
2262
+ const axis = getAlignmentAxis(placement);
2263
+ const length = getAxisLength(axis);
2264
+ const arrowDimensions = await platform2.getDimensions(element);
2265
+ const isYAxis = axis === "y";
2266
+ const minProp = isYAxis ? "top" : "left";
2267
+ const maxProp = isYAxis ? "bottom" : "right";
2268
+ const clientProp = isYAxis ? "clientHeight" : "clientWidth";
2269
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
2270
+ const startDiff = coords[axis] - rects.reference[axis];
2271
+ const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
2272
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
2273
+ if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
2274
+ clientSize = elements.floating[clientProp] || rects.floating[length];
1972
2275
  }
1973
- const [longitude, latitude] = this.props.position;
1974
- const [x2, y3] = this.viewport.project([longitude, latitude]);
1975
- const minOffset = this.props.minOffset || 0;
1976
- const gap = 10;
1977
- const arrowHeight = 8;
1978
- const arrowWidth = 16;
1979
- const isAbove = y3 > this.viewport.height / 2;
1980
- const background = this.props.style && this.props.style.background || "rgba(255,255,255,0.9)";
1981
- const ui = this.props.visible ? /* @__PURE__ */ u2("div", { className: "popup-container", style: { position: "absolute", left: 0, top: 0 }, children: [
1982
- /* @__PURE__ */ u2(
1983
- "div",
1984
- {
1985
- className: "popup-content",
1986
- style: {
1987
- background,
1988
- padding: "10px",
1989
- position: "relative",
1990
- // Include any additional styles
1991
- ...this.props.style
1992
- },
1993
- children: this.props.text
2276
+ const centerToReference = endDiff / 2 - startDiff / 2;
2277
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
2278
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
2279
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
2280
+ const min$1 = minPadding;
2281
+ const max3 = clientSize - arrowDimensions[length] - maxPadding;
2282
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
2283
+ const offset3 = clamp(min$1, center, max3);
2284
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset3 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
2285
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max3 : 0;
2286
+ return {
2287
+ [axis]: coords[axis] + alignmentOffset,
2288
+ data: {
2289
+ [axis]: offset3,
2290
+ centerOffset: center - offset3 - alignmentOffset,
2291
+ ...shouldAddOffset && {
2292
+ alignmentOffset
1994
2293
  }
1995
- ),
1996
- /* @__PURE__ */ u2("div", { className: "popup-arrow", style: { position: "absolute", width: "0px", height: "0px" } })
1997
- ] }) : null;
1998
- B(ui, rootElement);
1999
- requestAnimationFrame(() => {
2000
- if (!this.props.visible || !rootElement.firstChild || !this.viewport)
2001
- return;
2002
- const container = rootElement.firstChild;
2003
- const contentEl = container.querySelector(".popup-content");
2004
- const arrowEl = container.querySelector(".popup-arrow");
2005
- if (!contentEl || !arrowEl)
2006
- return;
2007
- const contentRect = contentEl.getBoundingClientRect();
2008
- const popupWidth = contentRect.width;
2009
- const popupHeight = contentRect.height;
2010
- let computedLeft = x2 - popupWidth / 2;
2011
- let computedTop;
2012
- if (isAbove) {
2013
- computedTop = y3 - gap - arrowHeight - popupHeight;
2014
- } else {
2015
- computedTop = y3 + gap + arrowHeight;
2294
+ },
2295
+ reset: shouldAddOffset
2296
+ };
2297
+ }
2298
+ });
2299
+ var flip = function(options) {
2300
+ if (options === void 0) {
2301
+ options = {};
2302
+ }
2303
+ return {
2304
+ name: "flip",
2305
+ options,
2306
+ async fn(state) {
2307
+ var _middlewareData$arrow, _middlewareData$flip;
2308
+ const {
2309
+ placement,
2310
+ middlewareData,
2311
+ rects,
2312
+ initialPlacement,
2313
+ platform: platform2,
2314
+ elements
2315
+ } = state;
2316
+ const {
2317
+ mainAxis: checkMainAxis = true,
2318
+ crossAxis: checkCrossAxis = true,
2319
+ fallbackPlacements: specifiedFallbackPlacements,
2320
+ fallbackStrategy = "bestFit",
2321
+ fallbackAxisSideDirection = "none",
2322
+ flipAlignment = true,
2323
+ ...detectOverflowOptions
2324
+ } = evaluate(options, state);
2325
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2326
+ return {};
2016
2327
  }
2017
- if (computedLeft < minOffset) {
2018
- computedLeft = minOffset;
2328
+ const side = getSide(placement);
2329
+ const initialSideAxis = getSideAxis(initialPlacement);
2330
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
2331
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
2332
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
2333
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
2334
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
2335
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
2019
2336
  }
2020
- if (computedLeft + popupWidth > this.viewport.width - minOffset) {
2021
- computedLeft = this.viewport.width - minOffset - popupWidth;
2337
+ const placements2 = [initialPlacement, ...fallbackPlacements];
2338
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2339
+ const overflows = [];
2340
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
2341
+ if (checkMainAxis) {
2342
+ overflows.push(overflow[side]);
2022
2343
  }
2023
- if (isAbove) {
2024
- if (computedTop < minOffset) {
2025
- computedTop = minOffset;
2344
+ if (checkCrossAxis) {
2345
+ const sides2 = getAlignmentSides(placement, rects, rtl);
2346
+ overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
2347
+ }
2348
+ overflowsData = [...overflowsData, {
2349
+ placement,
2350
+ overflows
2351
+ }];
2352
+ if (!overflows.every((side2) => side2 <= 0)) {
2353
+ var _middlewareData$flip2, _overflowsData$filter;
2354
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
2355
+ const nextPlacement = placements2[nextIndex];
2356
+ if (nextPlacement) {
2357
+ return {
2358
+ data: {
2359
+ index: nextIndex,
2360
+ overflows: overflowsData
2361
+ },
2362
+ reset: {
2363
+ placement: nextPlacement
2364
+ }
2365
+ };
2366
+ }
2367
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter((d3) => d3.overflows[0] <= 0).sort((a3, b2) => a3.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
2368
+ if (!resetPlacement) {
2369
+ switch (fallbackStrategy) {
2370
+ case "bestFit": {
2371
+ var _overflowsData$filter2;
2372
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d3) => {
2373
+ if (hasFallbackAxisSideDirection) {
2374
+ const currentSideAxis = getSideAxis(d3.placement);
2375
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
2376
+ // reading directions favoring greater width.
2377
+ currentSideAxis === "y";
2378
+ }
2379
+ return true;
2380
+ }).map((d3) => [d3.placement, d3.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a3, b2) => a3[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
2381
+ if (placement2) {
2382
+ resetPlacement = placement2;
2383
+ }
2384
+ break;
2385
+ }
2386
+ case "initialPlacement":
2387
+ resetPlacement = initialPlacement;
2388
+ break;
2389
+ }
2390
+ }
2391
+ if (placement !== resetPlacement) {
2392
+ return {
2393
+ reset: {
2394
+ placement: resetPlacement
2395
+ }
2396
+ };
2026
2397
  }
2027
- } else if (computedTop + popupHeight + arrowHeight > this.viewport.height - minOffset) {
2028
- computedTop = this.viewport.height - minOffset - popupHeight - arrowHeight;
2029
- }
2030
- container.style.left = `${computedLeft}px`;
2031
- container.style.top = `${computedTop}px`;
2032
- container.style.transform = "";
2033
- let arrowLeft = x2 - computedLeft - arrowWidth / 2;
2034
- arrowLeft = Math.max(arrowLeft, 0);
2035
- arrowLeft = Math.min(arrowLeft, popupWidth - arrowWidth);
2036
- if (isAbove) {
2037
- arrowEl.style.left = `${arrowLeft}px`;
2038
- arrowEl.style.bottom = `-${arrowHeight}px`;
2039
- arrowEl.style.top = "";
2040
- arrowEl.style.borderLeft = `${arrowWidth / 2}px solid transparent`;
2041
- arrowEl.style.borderRight = `${arrowWidth / 2}px solid transparent`;
2042
- arrowEl.style.borderTop = `${arrowHeight}px solid ${background}`;
2043
- arrowEl.style.borderBottom = "";
2044
- } else {
2045
- arrowEl.style.left = `${arrowLeft}px`;
2046
- arrowEl.style.top = `-${arrowHeight}px`;
2047
- arrowEl.style.bottom = "";
2048
- arrowEl.style.borderLeft = `${arrowWidth / 2}px solid transparent`;
2049
- arrowEl.style.borderRight = `${arrowWidth / 2}px solid transparent`;
2050
- arrowEl.style.borderBottom = `${arrowHeight}px solid ${background}`;
2051
- arrowEl.style.borderTop = "";
2052
2398
  }
2053
- });
2054
- }
2055
- };
2056
- InfoWidget.defaultProps = {
2057
- ...import_core12.Widget.defaultProps,
2058
- id: "info",
2059
- position: [0, 0],
2060
- text: "",
2061
- visible: false,
2062
- minOffset: 0,
2063
- viewId: null,
2064
- mode: "hover",
2065
- getTooltip: void 0,
2066
- onClick: void 0
2399
+ return {};
2400
+ }
2401
+ };
2067
2402
  };
2068
-
2069
- // src/context-menu-widget.tsx
2070
- var import_core13 = __toESM(require_core(), 1);
2071
-
2072
- // src/lib/components/simple-menu.tsx
2073
- var MENU_STYLE = {
2074
- position: "absolute",
2075
- top: "100%",
2076
- left: 0,
2077
- background: "white",
2078
- border: "1px solid #ccc",
2079
- borderRadius: "4px",
2080
- marginTop: "var(--menu-gap, 4px)",
2081
- zIndex: 100
2082
- };
2083
- var MENU_ITEM_STYLE = {
2084
- background: "white",
2085
- border: "none",
2086
- padding: "4px",
2087
- cursor: "pointer",
2088
- pointerEvents: "auto"
2403
+ async function convertValueToCoords(state, options) {
2404
+ const {
2405
+ placement,
2406
+ platform: platform2,
2407
+ elements
2408
+ } = state;
2409
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
2410
+ const side = getSide(placement);
2411
+ const alignment = getAlignment(placement);
2412
+ const isVertical = getSideAxis(placement) === "y";
2413
+ const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
2414
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
2415
+ const rawValue = evaluate(options, state);
2416
+ let {
2417
+ mainAxis,
2418
+ crossAxis,
2419
+ alignmentAxis
2420
+ } = typeof rawValue === "number" ? {
2421
+ mainAxis: rawValue,
2422
+ crossAxis: 0,
2423
+ alignmentAxis: null
2424
+ } : {
2425
+ mainAxis: 0,
2426
+ crossAxis: 0,
2427
+ alignmentAxis: null,
2428
+ ...rawValue
2429
+ };
2430
+ if (alignment && typeof alignmentAxis === "number") {
2431
+ crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
2432
+ }
2433
+ return isVertical ? {
2434
+ x: crossAxis * crossAxisMulti,
2435
+ y: mainAxis * mainAxisMulti
2436
+ } : {
2437
+ x: mainAxis * mainAxisMulti,
2438
+ y: crossAxis * crossAxisMulti
2439
+ };
2440
+ }
2441
+ var offset = function(options) {
2442
+ if (options === void 0) {
2443
+ options = 0;
2444
+ }
2445
+ return {
2446
+ name: "offset",
2447
+ options,
2448
+ async fn(state) {
2449
+ var _middlewareData$offse, _middlewareData$arrow;
2450
+ const {
2451
+ x: x2,
2452
+ y: y3,
2453
+ placement,
2454
+ middlewareData
2455
+ } = state;
2456
+ const diffCoords = await convertValueToCoords(state, options);
2457
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2458
+ return {};
2459
+ }
2460
+ return {
2461
+ x: x2 + diffCoords.x,
2462
+ y: y3 + diffCoords.y,
2463
+ data: {
2464
+ ...diffCoords,
2465
+ placement
2466
+ }
2467
+ };
2468
+ }
2469
+ };
2089
2470
  };
2090
- var SimpleMenu = (props) => {
2091
- const { menuItems, onItemSelected, position, style } = props;
2092
- const styleOverride = {
2093
- ...MENU_STYLE,
2094
- ...style,
2095
- left: `${position.x}px`,
2096
- top: `${position.y}px`
2471
+ var shift = function(options) {
2472
+ if (options === void 0) {
2473
+ options = {};
2474
+ }
2475
+ return {
2476
+ name: "shift",
2477
+ options,
2478
+ async fn(state) {
2479
+ const {
2480
+ x: x2,
2481
+ y: y3,
2482
+ placement
2483
+ } = state;
2484
+ const {
2485
+ mainAxis: checkMainAxis = true,
2486
+ crossAxis: checkCrossAxis = false,
2487
+ limiter = {
2488
+ fn: (_ref) => {
2489
+ let {
2490
+ x: x3,
2491
+ y: y4
2492
+ } = _ref;
2493
+ return {
2494
+ x: x3,
2495
+ y: y4
2496
+ };
2497
+ }
2498
+ },
2499
+ ...detectOverflowOptions
2500
+ } = evaluate(options, state);
2501
+ const coords = {
2502
+ x: x2,
2503
+ y: y3
2504
+ };
2505
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2506
+ const crossAxis = getSideAxis(getSide(placement));
2507
+ const mainAxis = getOppositeAxis(crossAxis);
2508
+ let mainAxisCoord = coords[mainAxis];
2509
+ let crossAxisCoord = coords[crossAxis];
2510
+ if (checkMainAxis) {
2511
+ const minSide = mainAxis === "y" ? "top" : "left";
2512
+ const maxSide = mainAxis === "y" ? "bottom" : "right";
2513
+ const min3 = mainAxisCoord + overflow[minSide];
2514
+ const max3 = mainAxisCoord - overflow[maxSide];
2515
+ mainAxisCoord = clamp(min3, mainAxisCoord, max3);
2516
+ }
2517
+ if (checkCrossAxis) {
2518
+ const minSide = crossAxis === "y" ? "top" : "left";
2519
+ const maxSide = crossAxis === "y" ? "bottom" : "right";
2520
+ const min3 = crossAxisCoord + overflow[minSide];
2521
+ const max3 = crossAxisCoord - overflow[maxSide];
2522
+ crossAxisCoord = clamp(min3, crossAxisCoord, max3);
2523
+ }
2524
+ const limitedCoords = limiter.fn({
2525
+ ...state,
2526
+ [mainAxis]: mainAxisCoord,
2527
+ [crossAxis]: crossAxisCoord
2528
+ });
2529
+ return {
2530
+ ...limitedCoords,
2531
+ data: {
2532
+ x: limitedCoords.x - x2,
2533
+ y: limitedCoords.y - y3
2534
+ }
2535
+ };
2536
+ }
2097
2537
  };
2098
- return /* @__PURE__ */ u2("div", { style: styleOverride, children: menuItems.map(({ key, label }) => /* @__PURE__ */ u2(
2099
- "button",
2100
- {
2101
- style: { ...MENU_ITEM_STYLE, display: "block" },
2102
- onClick: (_2) => onItemSelected(key),
2103
- children: label
2104
- },
2105
- key
2106
- )) });
2107
2538
  };
2108
2539
 
2109
- // src/context-menu-widget.tsx
2110
- var MOUSE_BUTTON_RIGHT = 2;
2111
- var MOUSE_WHICH_RIGHT = 3;
2112
- var ContextMenuWidget = class extends import_core13.Widget {
2113
- constructor(props) {
2114
- super(props);
2115
- this.className = "deck-widget-context-menu";
2116
- this.placement = "fill";
2117
- this.pickInfo = null;
2118
- this.pickInfo = null;
2119
- this.setProps(this.props);
2540
+ // ../../node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2541
+ var min2 = Math.min;
2542
+ var max2 = Math.max;
2543
+ var round = Math.round;
2544
+ var floor = Math.floor;
2545
+ var createCoords = (v3) => ({
2546
+ x: v3,
2547
+ y: v3
2548
+ });
2549
+
2550
+ // ../../node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2551
+ function hasWindow() {
2552
+ return typeof window !== "undefined";
2553
+ }
2554
+ function getNodeName(node) {
2555
+ if (isNode(node)) {
2556
+ return (node.nodeName || "").toLowerCase();
2120
2557
  }
2121
- onAdd({ deck }) {
2122
- const element = document.createElement("div");
2123
- element.classList.add("deck-widget", "deck-widget-context-menu");
2124
- const style = {
2125
- margin: "0px",
2126
- top: "0px",
2127
- left: "0px",
2128
- position: "absolute",
2129
- pointerEvents: "auto"
2130
- };
2131
- Object.entries(style).forEach(([key, value]) => element.style.setProperty(key, value));
2132
- deck.getCanvas()?.addEventListener("click", () => this.hide());
2133
- deck.getCanvas()?.addEventListener("contextmenu", (event) => this.handleContextMenu(event));
2134
- return element;
2558
+ return "#document";
2559
+ }
2560
+ function getWindow(node) {
2561
+ var _node$ownerDocument;
2562
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2563
+ }
2564
+ function getDocumentElement(node) {
2565
+ var _ref;
2566
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2567
+ }
2568
+ function isNode(value) {
2569
+ if (!hasWindow()) {
2570
+ return false;
2135
2571
  }
2136
- onRenderHTML(rootElement) {
2137
- const { visible, position, menuItems } = this.props;
2138
- const ui = visible && menuItems.length ? /* @__PURE__ */ u2(
2139
- SimpleMenu,
2140
- {
2141
- menuItems,
2142
- onItemSelected: (key) => this.props.onMenuItemSelected(key, this.pickInfo),
2143
- position,
2144
- style: { pointerEvents: "auto" }
2145
- }
2146
- ) : null;
2147
- B(ui, rootElement);
2572
+ return value instanceof Node || value instanceof getWindow(value).Node;
2573
+ }
2574
+ function isElement(value) {
2575
+ if (!hasWindow()) {
2576
+ return false;
2148
2577
  }
2149
- handleContextMenu(srcEvent) {
2150
- if (srcEvent && (srcEvent.button === MOUSE_BUTTON_RIGHT || srcEvent.which === MOUSE_WHICH_RIGHT)) {
2151
- this.pickInfo = this.deck?.pickObject({
2152
- x: srcEvent.clientX,
2153
- y: srcEvent.clientY
2154
- }) || null;
2155
- const menuItems = this.pickInfo && this.props.getMenuItems?.(this.pickInfo, this) || [];
2156
- const visible = menuItems.length > 0;
2157
- this.setProps({
2158
- visible,
2159
- position: { x: srcEvent.clientX, y: srcEvent.clientY },
2160
- menuItems
2161
- });
2162
- this.updateHTML();
2163
- srcEvent.preventDefault();
2164
- return visible;
2165
- }
2578
+ return value instanceof Element || value instanceof getWindow(value).Element;
2579
+ }
2580
+ function isHTMLElement(value) {
2581
+ if (!hasWindow()) {
2166
2582
  return false;
2167
2583
  }
2168
- hide() {
2169
- this.setProps({ visible: false });
2584
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2585
+ }
2586
+ function isShadowRoot(value) {
2587
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
2588
+ return false;
2170
2589
  }
2171
- };
2172
- ContextMenuWidget.defaultProps = {
2173
- ...import_core13.Widget.defaultProps,
2174
- id: "context",
2175
- viewId: null,
2176
- visible: false,
2177
- position: { x: 0, y: 0 },
2178
- getMenuItems: void 0,
2179
- menuItems: [],
2180
- // eslint-disable-next-line no-console
2181
- onMenuItemSelected: (key, pickInfo) => console.log("Context menu item selected:", key, pickInfo)
2182
- };
2183
-
2184
- // src/timeline-widget.tsx
2185
- var import_core14 = __toESM(require_core(), 1);
2186
- var TimelineWidget = class extends import_core14.Widget {
2187
- constructor(props = {}) {
2188
- super(props);
2590
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2591
+ }
2592
+ function isOverflowElement(element) {
2593
+ const {
2594
+ overflow,
2595
+ overflowX,
2596
+ overflowY,
2597
+ display
2598
+ } = getComputedStyle(element);
2599
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
2600
+ }
2601
+ function isTableElement(element) {
2602
+ return ["table", "td", "th"].includes(getNodeName(element));
2603
+ }
2604
+ function isTopLayer(element) {
2605
+ return [":popover-open", ":modal"].some((selector) => {
2606
+ try {
2607
+ return element.matches(selector);
2608
+ } catch (e3) {
2609
+ return false;
2610
+ }
2611
+ });
2612
+ }
2613
+ function isContainingBlock(elementOrCss) {
2614
+ const webkit = isWebKit();
2615
+ const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
2616
+ return ["transform", "translate", "scale", "rotate", "perspective"].some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
2617
+ }
2618
+ function getContainingBlock(element) {
2619
+ let currentNode = getParentNode(element);
2620
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2621
+ if (isContainingBlock(currentNode)) {
2622
+ return currentNode;
2623
+ } else if (isTopLayer(currentNode)) {
2624
+ return null;
2625
+ }
2626
+ currentNode = getParentNode(currentNode);
2627
+ }
2628
+ return null;
2629
+ }
2630
+ function isWebKit() {
2631
+ if (typeof CSS === "undefined" || !CSS.supports)
2632
+ return false;
2633
+ return CSS.supports("-webkit-backdrop-filter", "none");
2634
+ }
2635
+ function isLastTraversableNode(node) {
2636
+ return ["html", "body", "#document"].includes(getNodeName(node));
2637
+ }
2638
+ function getComputedStyle(element) {
2639
+ return getWindow(element).getComputedStyle(element);
2640
+ }
2641
+ function getNodeScroll(element) {
2642
+ if (isElement(element)) {
2643
+ return {
2644
+ scrollLeft: element.scrollLeft,
2645
+ scrollTop: element.scrollTop
2646
+ };
2647
+ }
2648
+ return {
2649
+ scrollLeft: element.scrollX,
2650
+ scrollTop: element.scrollY
2651
+ };
2652
+ }
2653
+ function getParentNode(node) {
2654
+ if (getNodeName(node) === "html") {
2655
+ return node;
2656
+ }
2657
+ const result = (
2658
+ // Step into the shadow DOM of the parent of a slotted node.
2659
+ node.assignedSlot || // DOM Element detected.
2660
+ node.parentNode || // ShadowRoot detected.
2661
+ isShadowRoot(node) && node.host || // Fallback.
2662
+ getDocumentElement(node)
2663
+ );
2664
+ return isShadowRoot(result) ? result.host : result;
2665
+ }
2666
+ function getNearestOverflowAncestor(node) {
2667
+ const parentNode = getParentNode(node);
2668
+ if (isLastTraversableNode(parentNode)) {
2669
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
2670
+ }
2671
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2672
+ return parentNode;
2673
+ }
2674
+ return getNearestOverflowAncestor(parentNode);
2675
+ }
2676
+ function getOverflowAncestors(node, list, traverseIframes) {
2677
+ var _node$ownerDocument2;
2678
+ if (list === void 0) {
2679
+ list = [];
2680
+ }
2681
+ if (traverseIframes === void 0) {
2682
+ traverseIframes = true;
2683
+ }
2684
+ const scrollableAncestor = getNearestOverflowAncestor(node);
2685
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2686
+ const win = getWindow(scrollableAncestor);
2687
+ if (isBody) {
2688
+ const frameElement = getFrameElement(win);
2689
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2690
+ }
2691
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2692
+ }
2693
+ function getFrameElement(win) {
2694
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2695
+ }
2696
+
2697
+ // ../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
2698
+ function getCssDimensions(element) {
2699
+ const css = getComputedStyle(element);
2700
+ let width = parseFloat(css.width) || 0;
2701
+ let height = parseFloat(css.height) || 0;
2702
+ const hasOffset = isHTMLElement(element);
2703
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
2704
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
2705
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2706
+ if (shouldFallback) {
2707
+ width = offsetWidth;
2708
+ height = offsetHeight;
2709
+ }
2710
+ return {
2711
+ width,
2712
+ height,
2713
+ $: shouldFallback
2714
+ };
2715
+ }
2716
+ function unwrapElement(element) {
2717
+ return !isElement(element) ? element.contextElement : element;
2718
+ }
2719
+ function getScale(element) {
2720
+ const domElement = unwrapElement(element);
2721
+ if (!isHTMLElement(domElement)) {
2722
+ return createCoords(1);
2723
+ }
2724
+ const rect = domElement.getBoundingClientRect();
2725
+ const {
2726
+ width,
2727
+ height,
2728
+ $: $2
2729
+ } = getCssDimensions(domElement);
2730
+ let x2 = ($2 ? round(rect.width) : rect.width) / width;
2731
+ let y3 = ($2 ? round(rect.height) : rect.height) / height;
2732
+ if (!x2 || !Number.isFinite(x2)) {
2733
+ x2 = 1;
2734
+ }
2735
+ if (!y3 || !Number.isFinite(y3)) {
2736
+ y3 = 1;
2737
+ }
2738
+ return {
2739
+ x: x2,
2740
+ y: y3
2741
+ };
2742
+ }
2743
+ var noOffsets = /* @__PURE__ */ createCoords(0);
2744
+ function getVisualOffsets(element) {
2745
+ const win = getWindow(element);
2746
+ if (!isWebKit() || !win.visualViewport) {
2747
+ return noOffsets;
2748
+ }
2749
+ return {
2750
+ x: win.visualViewport.offsetLeft,
2751
+ y: win.visualViewport.offsetTop
2752
+ };
2753
+ }
2754
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2755
+ if (isFixed === void 0) {
2756
+ isFixed = false;
2757
+ }
2758
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2759
+ return false;
2760
+ }
2761
+ return isFixed;
2762
+ }
2763
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2764
+ if (includeScale === void 0) {
2765
+ includeScale = false;
2766
+ }
2767
+ if (isFixedStrategy === void 0) {
2768
+ isFixedStrategy = false;
2769
+ }
2770
+ const clientRect = element.getBoundingClientRect();
2771
+ const domElement = unwrapElement(element);
2772
+ let scale = createCoords(1);
2773
+ if (includeScale) {
2774
+ if (offsetParent) {
2775
+ if (isElement(offsetParent)) {
2776
+ scale = getScale(offsetParent);
2777
+ }
2778
+ } else {
2779
+ scale = getScale(element);
2780
+ }
2781
+ }
2782
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2783
+ let x2 = (clientRect.left + visualOffsets.x) / scale.x;
2784
+ let y3 = (clientRect.top + visualOffsets.y) / scale.y;
2785
+ let width = clientRect.width / scale.x;
2786
+ let height = clientRect.height / scale.y;
2787
+ if (domElement) {
2788
+ const win = getWindow(domElement);
2789
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2790
+ let currentWin = win;
2791
+ let currentIFrame = getFrameElement(currentWin);
2792
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
2793
+ const iframeScale = getScale(currentIFrame);
2794
+ const iframeRect = currentIFrame.getBoundingClientRect();
2795
+ const css = getComputedStyle(currentIFrame);
2796
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2797
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2798
+ x2 *= iframeScale.x;
2799
+ y3 *= iframeScale.y;
2800
+ width *= iframeScale.x;
2801
+ height *= iframeScale.y;
2802
+ x2 += left;
2803
+ y3 += top;
2804
+ currentWin = getWindow(currentIFrame);
2805
+ currentIFrame = getFrameElement(currentWin);
2806
+ }
2807
+ }
2808
+ return rectToClientRect({
2809
+ width,
2810
+ height,
2811
+ x: x2,
2812
+ y: y3
2813
+ });
2814
+ }
2815
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2816
+ let {
2817
+ elements,
2818
+ rect,
2819
+ offsetParent,
2820
+ strategy
2821
+ } = _ref;
2822
+ const isFixed = strategy === "fixed";
2823
+ const documentElement = getDocumentElement(offsetParent);
2824
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
2825
+ if (offsetParent === documentElement || topLayer && isFixed) {
2826
+ return rect;
2827
+ }
2828
+ let scroll = {
2829
+ scrollLeft: 0,
2830
+ scrollTop: 0
2831
+ };
2832
+ let scale = createCoords(1);
2833
+ const offsets = createCoords(0);
2834
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2835
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2836
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2837
+ scroll = getNodeScroll(offsetParent);
2838
+ }
2839
+ if (isHTMLElement(offsetParent)) {
2840
+ const offsetRect = getBoundingClientRect(offsetParent);
2841
+ scale = getScale(offsetParent);
2842
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2843
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2844
+ }
2845
+ }
2846
+ return {
2847
+ width: rect.width * scale.x,
2848
+ height: rect.height * scale.y,
2849
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
2850
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
2851
+ };
2852
+ }
2853
+ function getClientRects(element) {
2854
+ return Array.from(element.getClientRects());
2855
+ }
2856
+ function getWindowScrollBarX(element, rect) {
2857
+ const leftScroll = getNodeScroll(element).scrollLeft;
2858
+ if (!rect) {
2859
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
2860
+ }
2861
+ return rect.left + leftScroll;
2862
+ }
2863
+ function getDocumentRect(element) {
2864
+ const html = getDocumentElement(element);
2865
+ const scroll = getNodeScroll(element);
2866
+ const body = element.ownerDocument.body;
2867
+ const width = max2(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2868
+ const height = max2(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2869
+ let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
2870
+ const y3 = -scroll.scrollTop;
2871
+ if (getComputedStyle(body).direction === "rtl") {
2872
+ x2 += max2(html.clientWidth, body.clientWidth) - width;
2873
+ }
2874
+ return {
2875
+ width,
2876
+ height,
2877
+ x: x2,
2878
+ y: y3
2879
+ };
2880
+ }
2881
+ function getViewportRect(element, strategy) {
2882
+ const win = getWindow(element);
2883
+ const html = getDocumentElement(element);
2884
+ const visualViewport = win.visualViewport;
2885
+ let width = html.clientWidth;
2886
+ let height = html.clientHeight;
2887
+ let x2 = 0;
2888
+ let y3 = 0;
2889
+ if (visualViewport) {
2890
+ width = visualViewport.width;
2891
+ height = visualViewport.height;
2892
+ const visualViewportBased = isWebKit();
2893
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
2894
+ x2 = visualViewport.offsetLeft;
2895
+ y3 = visualViewport.offsetTop;
2896
+ }
2897
+ }
2898
+ return {
2899
+ width,
2900
+ height,
2901
+ x: x2,
2902
+ y: y3
2903
+ };
2904
+ }
2905
+ function getInnerBoundingClientRect(element, strategy) {
2906
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
2907
+ const top = clientRect.top + element.clientTop;
2908
+ const left = clientRect.left + element.clientLeft;
2909
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2910
+ const width = element.clientWidth * scale.x;
2911
+ const height = element.clientHeight * scale.y;
2912
+ const x2 = left * scale.x;
2913
+ const y3 = top * scale.y;
2914
+ return {
2915
+ width,
2916
+ height,
2917
+ x: x2,
2918
+ y: y3
2919
+ };
2920
+ }
2921
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2922
+ let rect;
2923
+ if (clippingAncestor === "viewport") {
2924
+ rect = getViewportRect(element, strategy);
2925
+ } else if (clippingAncestor === "document") {
2926
+ rect = getDocumentRect(getDocumentElement(element));
2927
+ } else if (isElement(clippingAncestor)) {
2928
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2929
+ } else {
2930
+ const visualOffsets = getVisualOffsets(element);
2931
+ rect = {
2932
+ ...clippingAncestor,
2933
+ x: clippingAncestor.x - visualOffsets.x,
2934
+ y: clippingAncestor.y - visualOffsets.y
2935
+ };
2936
+ }
2937
+ return rectToClientRect(rect);
2938
+ }
2939
+ function hasFixedPositionAncestor(element, stopNode) {
2940
+ const parentNode = getParentNode(element);
2941
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2942
+ return false;
2943
+ }
2944
+ return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
2945
+ }
2946
+ function getClippingElementAncestors(element, cache) {
2947
+ const cachedResult = cache.get(element);
2948
+ if (cachedResult) {
2949
+ return cachedResult;
2950
+ }
2951
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
2952
+ let currentContainingBlockComputedStyle = null;
2953
+ const elementIsFixed = getComputedStyle(element).position === "fixed";
2954
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
2955
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2956
+ const computedStyle = getComputedStyle(currentNode);
2957
+ const currentNodeIsContaining = isContainingBlock(currentNode);
2958
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
2959
+ currentContainingBlockComputedStyle = null;
2960
+ }
2961
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2962
+ if (shouldDropCurrentNode) {
2963
+ result = result.filter((ancestor) => ancestor !== currentNode);
2964
+ } else {
2965
+ currentContainingBlockComputedStyle = computedStyle;
2966
+ }
2967
+ currentNode = getParentNode(currentNode);
2968
+ }
2969
+ cache.set(element, result);
2970
+ return result;
2971
+ }
2972
+ function getClippingRect(_ref) {
2973
+ let {
2974
+ element,
2975
+ boundary,
2976
+ rootBoundary,
2977
+ strategy
2978
+ } = _ref;
2979
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2980
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2981
+ const firstClippingAncestor = clippingAncestors[0];
2982
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2983
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2984
+ accRect.top = max2(rect.top, accRect.top);
2985
+ accRect.right = min2(rect.right, accRect.right);
2986
+ accRect.bottom = min2(rect.bottom, accRect.bottom);
2987
+ accRect.left = max2(rect.left, accRect.left);
2988
+ return accRect;
2989
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2990
+ return {
2991
+ width: clippingRect.right - clippingRect.left,
2992
+ height: clippingRect.bottom - clippingRect.top,
2993
+ x: clippingRect.left,
2994
+ y: clippingRect.top
2995
+ };
2996
+ }
2997
+ function getDimensions(element) {
2998
+ const {
2999
+ width,
3000
+ height
3001
+ } = getCssDimensions(element);
3002
+ return {
3003
+ width,
3004
+ height
3005
+ };
3006
+ }
3007
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
3008
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
3009
+ const documentElement = getDocumentElement(offsetParent);
3010
+ const isFixed = strategy === "fixed";
3011
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
3012
+ let scroll = {
3013
+ scrollLeft: 0,
3014
+ scrollTop: 0
3015
+ };
3016
+ const offsets = createCoords(0);
3017
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
3018
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
3019
+ scroll = getNodeScroll(offsetParent);
3020
+ }
3021
+ if (isOffsetParentAnElement) {
3022
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
3023
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
3024
+ offsets.y = offsetRect.y + offsetParent.clientTop;
3025
+ } else if (documentElement) {
3026
+ offsets.x = getWindowScrollBarX(documentElement);
3027
+ }
3028
+ }
3029
+ let htmlX = 0;
3030
+ let htmlY = 0;
3031
+ if (documentElement && !isOffsetParentAnElement && !isFixed) {
3032
+ const htmlRect = documentElement.getBoundingClientRect();
3033
+ htmlY = htmlRect.top + scroll.scrollTop;
3034
+ htmlX = htmlRect.left + scroll.scrollLeft - // RTL <body> scrollbar.
3035
+ getWindowScrollBarX(documentElement, htmlRect);
3036
+ }
3037
+ const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlX;
3038
+ const y3 = rect.top + scroll.scrollTop - offsets.y - htmlY;
3039
+ return {
3040
+ x: x2,
3041
+ y: y3,
3042
+ width: rect.width,
3043
+ height: rect.height
3044
+ };
3045
+ }
3046
+ function isStaticPositioned(element) {
3047
+ return getComputedStyle(element).position === "static";
3048
+ }
3049
+ function getTrueOffsetParent(element, polyfill) {
3050
+ if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
3051
+ return null;
3052
+ }
3053
+ if (polyfill) {
3054
+ return polyfill(element);
3055
+ }
3056
+ let rawOffsetParent = element.offsetParent;
3057
+ if (getDocumentElement(element) === rawOffsetParent) {
3058
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
3059
+ }
3060
+ return rawOffsetParent;
3061
+ }
3062
+ function getOffsetParent(element, polyfill) {
3063
+ const win = getWindow(element);
3064
+ if (isTopLayer(element)) {
3065
+ return win;
3066
+ }
3067
+ if (!isHTMLElement(element)) {
3068
+ let svgOffsetParent = getParentNode(element);
3069
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
3070
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
3071
+ return svgOffsetParent;
3072
+ }
3073
+ svgOffsetParent = getParentNode(svgOffsetParent);
3074
+ }
3075
+ return win;
3076
+ }
3077
+ let offsetParent = getTrueOffsetParent(element, polyfill);
3078
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
3079
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
3080
+ }
3081
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
3082
+ return win;
3083
+ }
3084
+ return offsetParent || getContainingBlock(element) || win;
3085
+ }
3086
+ var getElementRects = async function(data) {
3087
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
3088
+ const getDimensionsFn = this.getDimensions;
3089
+ const floatingDimensions = await getDimensionsFn(data.floating);
3090
+ return {
3091
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
3092
+ floating: {
3093
+ x: 0,
3094
+ y: 0,
3095
+ width: floatingDimensions.width,
3096
+ height: floatingDimensions.height
3097
+ }
3098
+ };
3099
+ };
3100
+ function isRTL(element) {
3101
+ return getComputedStyle(element).direction === "rtl";
3102
+ }
3103
+ var platform = {
3104
+ convertOffsetParentRelativeRectToViewportRelativeRect,
3105
+ getDocumentElement,
3106
+ getClippingRect,
3107
+ getOffsetParent,
3108
+ getElementRects,
3109
+ getClientRects,
3110
+ getDimensions,
3111
+ getScale,
3112
+ isElement,
3113
+ isRTL
3114
+ };
3115
+ function observeMove(element, onMove) {
3116
+ let io = null;
3117
+ let timeoutId;
3118
+ const root = getDocumentElement(element);
3119
+ function cleanup() {
3120
+ var _io;
3121
+ clearTimeout(timeoutId);
3122
+ (_io = io) == null || _io.disconnect();
3123
+ io = null;
3124
+ }
3125
+ function refresh(skip, threshold) {
3126
+ if (skip === void 0) {
3127
+ skip = false;
3128
+ }
3129
+ if (threshold === void 0) {
3130
+ threshold = 1;
3131
+ }
3132
+ cleanup();
3133
+ const {
3134
+ left,
3135
+ top,
3136
+ width,
3137
+ height
3138
+ } = element.getBoundingClientRect();
3139
+ if (!skip) {
3140
+ onMove();
3141
+ }
3142
+ if (!width || !height) {
3143
+ return;
3144
+ }
3145
+ const insetTop = floor(top);
3146
+ const insetRight = floor(root.clientWidth - (left + width));
3147
+ const insetBottom = floor(root.clientHeight - (top + height));
3148
+ const insetLeft = floor(left);
3149
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
3150
+ const options = {
3151
+ rootMargin,
3152
+ threshold: max2(0, min2(1, threshold)) || 1
3153
+ };
3154
+ let isFirstUpdate = true;
3155
+ function handleObserve(entries) {
3156
+ const ratio = entries[0].intersectionRatio;
3157
+ if (ratio !== threshold) {
3158
+ if (!isFirstUpdate) {
3159
+ return refresh();
3160
+ }
3161
+ if (!ratio) {
3162
+ timeoutId = setTimeout(() => {
3163
+ refresh(false, 1e-7);
3164
+ }, 1e3);
3165
+ } else {
3166
+ refresh(false, ratio);
3167
+ }
3168
+ }
3169
+ isFirstUpdate = false;
3170
+ }
3171
+ try {
3172
+ io = new IntersectionObserver(handleObserve, {
3173
+ ...options,
3174
+ // Handle <iframe>s
3175
+ root: root.ownerDocument
3176
+ });
3177
+ } catch (e3) {
3178
+ io = new IntersectionObserver(handleObserve, options);
3179
+ }
3180
+ io.observe(element);
3181
+ }
3182
+ refresh(true);
3183
+ return cleanup;
3184
+ }
3185
+ function autoUpdate(reference, floating, update, options) {
3186
+ if (options === void 0) {
3187
+ options = {};
3188
+ }
3189
+ const {
3190
+ ancestorScroll = true,
3191
+ ancestorResize = true,
3192
+ elementResize = typeof ResizeObserver === "function",
3193
+ layoutShift = typeof IntersectionObserver === "function",
3194
+ animationFrame = false
3195
+ } = options;
3196
+ const referenceEl = unwrapElement(reference);
3197
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
3198
+ ancestors.forEach((ancestor) => {
3199
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
3200
+ passive: true
3201
+ });
3202
+ ancestorResize && ancestor.addEventListener("resize", update);
3203
+ });
3204
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
3205
+ let reobserveFrame = -1;
3206
+ let resizeObserver = null;
3207
+ if (elementResize) {
3208
+ resizeObserver = new ResizeObserver((_ref) => {
3209
+ let [firstEntry] = _ref;
3210
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
3211
+ resizeObserver.unobserve(floating);
3212
+ cancelAnimationFrame(reobserveFrame);
3213
+ reobserveFrame = requestAnimationFrame(() => {
3214
+ var _resizeObserver;
3215
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
3216
+ });
3217
+ }
3218
+ update();
3219
+ });
3220
+ if (referenceEl && !animationFrame) {
3221
+ resizeObserver.observe(referenceEl);
3222
+ }
3223
+ resizeObserver.observe(floating);
3224
+ }
3225
+ let frameId;
3226
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
3227
+ if (animationFrame) {
3228
+ frameLoop();
3229
+ }
3230
+ function frameLoop() {
3231
+ const nextRefRect = getBoundingClientRect(reference);
3232
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
3233
+ update();
3234
+ }
3235
+ prevRefRect = nextRefRect;
3236
+ frameId = requestAnimationFrame(frameLoop);
3237
+ }
3238
+ update();
3239
+ return () => {
3240
+ var _resizeObserver2;
3241
+ ancestors.forEach((ancestor) => {
3242
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
3243
+ ancestorResize && ancestor.removeEventListener("resize", update);
3244
+ });
3245
+ cleanupIo == null || cleanupIo();
3246
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
3247
+ resizeObserver = null;
3248
+ if (animationFrame) {
3249
+ cancelAnimationFrame(frameId);
3250
+ }
3251
+ };
3252
+ }
3253
+ var offset2 = offset;
3254
+ var shift2 = shift;
3255
+ var flip2 = flip;
3256
+ var arrow2 = arrow;
3257
+ var computePosition2 = (reference, floating, options) => {
3258
+ const cache = /* @__PURE__ */ new Map();
3259
+ const mergedOptions = {
3260
+ platform,
3261
+ ...options
3262
+ };
3263
+ const platformWithCache = {
3264
+ ...mergedOptions.platform,
3265
+ _c: cache
3266
+ };
3267
+ return computePosition(reference, floating, {
3268
+ ...mergedOptions,
3269
+ platform: platformWithCache
3270
+ });
3271
+ };
3272
+
3273
+ // src/lib/components/popover.tsx
3274
+ var Popover = ({
3275
+ x: x2,
3276
+ y: y3,
3277
+ placement = "right",
3278
+ offset: pixelOffset = 0,
3279
+ arrow: arrowSize = false,
3280
+ arrowColor = "white",
3281
+ children
3282
+ }) => {
3283
+ const anchorRef = A2(null);
3284
+ const contentRef = A2(null);
3285
+ const arrowRef = A2(null);
3286
+ const updaterRef = A2();
3287
+ updaterRef.current = () => {
3288
+ if (!anchorRef.current || !contentRef.current)
3289
+ return;
3290
+ const arrowWidth = Array.isArray(arrowSize) ? arrowSize[0] : arrowSize || 0;
3291
+ const arrowHeight = Array.isArray(arrowSize) ? arrowSize[1] : arrowSize || 0;
3292
+ const padding = pixelOffset + Math.max(arrowHeight, arrowWidth);
3293
+ const middleware = placement.includes("-") ? [offset2(padding), flip2(), shift2()] : [offset2(padding), shift2(), flip2()];
3294
+ if (arrowRef.current)
3295
+ middleware.push(arrow2({ element: arrowRef.current }));
3296
+ computePosition2(anchorRef.current, contentRef.current, {
3297
+ placement,
3298
+ strategy: "fixed",
3299
+ middleware
3300
+ }).then((popoverPos) => {
3301
+ if (contentRef.current) {
3302
+ Object.assign(contentRef.current.style, {
3303
+ left: `${popoverPos.x}px`,
3304
+ top: `${popoverPos.y}px`
3305
+ });
3306
+ }
3307
+ const arrowData = popoverPos.middlewareData.arrow;
3308
+ if (arrowData && arrowRef.current) {
3309
+ const arrowStyle = createArrow(arrowWidth, arrowHeight, arrowColor, popoverPos.placement);
3310
+ arrowStyle.transform = `translate(${arrowData.x || 0}px, ${arrowData.y || 0}px)`;
3311
+ Object.assign(arrowRef.current.style, arrowStyle);
3312
+ }
3313
+ });
3314
+ };
3315
+ T2(() => {
3316
+ updaterRef.current?.();
3317
+ }, [placement, arrowSize, pixelOffset]);
3318
+ y2(() => {
3319
+ if (contentRef.current) {
3320
+ contentRef.current.style.visibility = "visible";
3321
+ }
3322
+ const cleanup = autoUpdate(
3323
+ anchorRef.current,
3324
+ contentRef.current,
3325
+ () => updaterRef.current?.()
3326
+ );
3327
+ return () => {
3328
+ cleanup();
3329
+ };
3330
+ }, []);
3331
+ return /* @__PURE__ */ u2("div", { style: { position: "absolute", left: x2, top: y3 }, ref: anchorRef, children: /* @__PURE__ */ u2(
3332
+ "div",
3333
+ {
3334
+ className: "deck-widget deck-widget-popover",
3335
+ style: { position: "fixed", visibility: "hidden", pointerEvents: "none" },
3336
+ ref: contentRef,
3337
+ children: [
3338
+ Boolean(arrowSize) && /* @__PURE__ */ u2(
3339
+ "div",
3340
+ {
3341
+ className: "deck-widget-popover-arrow",
3342
+ style: { position: "absolute" },
3343
+ ref: arrowRef
3344
+ }
3345
+ ),
3346
+ children
3347
+ ]
3348
+ }
3349
+ ) });
3350
+ };
3351
+ function createArrow(width, height, color, placement) {
3352
+ const result = {
3353
+ width: 0,
3354
+ height: 0,
3355
+ top: "",
3356
+ bottom: "",
3357
+ left: "",
3358
+ right: ""
3359
+ };
3360
+ if (placement.startsWith("bottom")) {
3361
+ result.borderLeft = `${width / 2}px solid transparent`;
3362
+ result.borderRight = `${width / 2}px solid transparent`;
3363
+ result.borderBottom = `${height}px solid ${color}`;
3364
+ result.borderTop = "";
3365
+ result.top = `${-height}px`;
3366
+ } else if (placement.startsWith("top")) {
3367
+ result.borderLeft = `${width / 2}px solid transparent`;
3368
+ result.borderRight = `${width / 2}px solid transparent`;
3369
+ result.borderTop = `${height}px solid ${color}`;
3370
+ result.borderBottom = "";
3371
+ result.bottom = `${-height}px`;
3372
+ } else if (placement.startsWith("right")) {
3373
+ result.borderTop = `${width / 2}px solid transparent`;
3374
+ result.borderBottom = `${width / 2}px solid transparent`;
3375
+ result.borderRight = `${height}px solid ${color}`;
3376
+ result.borderLeft = "";
3377
+ result.left = `${-height}px`;
3378
+ } else if (placement.startsWith("left")) {
3379
+ result.borderTop = `${width / 2}px solid transparent`;
3380
+ result.borderBottom = `${width / 2}px solid transparent`;
3381
+ result.borderLeft = `${height}px solid ${color}`;
3382
+ result.borderRight = "";
3383
+ result.right = `${-height}px`;
3384
+ }
3385
+ return result;
3386
+ }
3387
+
3388
+ // src/lib/components/user-content.tsx
3389
+ var UserContent = ({ text, html, element, ...props }) => {
3390
+ const containerRef = A2(null);
3391
+ y2(() => {
3392
+ if (containerRef.current && element) {
3393
+ containerRef.current.append(element);
3394
+ }
3395
+ return () => {
3396
+ element?.remove();
3397
+ };
3398
+ }, [element]);
3399
+ return /* @__PURE__ */ u2("div", { ref: containerRef, ...props, dangerouslySetInnerHTML: html ? { __html: html } : void 0, children: text });
3400
+ };
3401
+
3402
+ // src/info-widget.tsx
3403
+ var InfoWidget = class extends import_core13.Widget {
3404
+ constructor(props) {
3405
+ super(props);
3406
+ this.className = "deck-widget-info";
3407
+ this.placement = "fill";
3408
+ this.tooltip = null;
3409
+ this.setProps(this.props);
3410
+ }
3411
+ setProps(props) {
3412
+ this.viewId = props.viewId ?? this.viewId;
3413
+ super.setProps(props);
3414
+ }
3415
+ onAdd({ deck }) {
3416
+ this.deck = deck;
3417
+ }
3418
+ onViewportChange(viewport) {
3419
+ this.viewport = viewport;
3420
+ this.updateHTML();
3421
+ }
3422
+ onHover(info) {
3423
+ if (this.props.mode === "hover") {
3424
+ this.tooltip = this._getTooltip(info);
3425
+ }
3426
+ }
3427
+ onClick(info) {
3428
+ if (this.props.mode === "click") {
3429
+ this.tooltip = this._getTooltip(info);
3430
+ }
3431
+ }
3432
+ _getTooltip(info) {
3433
+ if (!this.props.getTooltip)
3434
+ return null;
3435
+ const content = this.props.getTooltip(info, this) ?? null;
3436
+ if (content === null)
3437
+ return null;
3438
+ const normalizedTooltip = typeof content === "string" ? { text: content } : content;
3439
+ const position = normalizedTooltip.position || info.coordinate;
3440
+ if (!position)
3441
+ return null;
3442
+ return {
3443
+ position,
3444
+ text: "",
3445
+ html: "",
3446
+ element: null,
3447
+ className: "",
3448
+ style: {},
3449
+ ...normalizedTooltip
3450
+ };
3451
+ }
3452
+ onRenderHTML(rootElement) {
3453
+ if (!this.viewport || this.tooltip === null) {
3454
+ B(null, rootElement);
3455
+ return;
3456
+ }
3457
+ const style = {
3458
+ ...this.props.style,
3459
+ ...this.tooltip.style
3460
+ };
3461
+ const [x2, y3] = this.viewport.project(this.tooltip.position);
3462
+ const ui = /* @__PURE__ */ u2(
3463
+ Popover,
3464
+ {
3465
+ x: x2,
3466
+ y: y3,
3467
+ placement: this.props.placement,
3468
+ arrow: this.props.arrow,
3469
+ arrowColor: "var(--menu-background, #fff)",
3470
+ offset: this.props.offset,
3471
+ children: /* @__PURE__ */ u2(
3472
+ UserContent,
3473
+ {
3474
+ className: `deck-widget-popup-content ${this.tooltip.className} ${this.props.className}`,
3475
+ style,
3476
+ html: this.tooltip.html,
3477
+ text: this.tooltip.text,
3478
+ element: this.tooltip.element
3479
+ }
3480
+ )
3481
+ }
3482
+ );
3483
+ B(ui, rootElement);
3484
+ }
3485
+ };
3486
+ InfoWidget.defaultProps = {
3487
+ ...import_core13.Widget.defaultProps,
3488
+ id: "info",
3489
+ viewId: null,
3490
+ mode: "hover",
3491
+ getTooltip: void 0,
3492
+ placement: "right",
3493
+ offset: 10,
3494
+ arrow: 10
3495
+ };
3496
+
3497
+ // src/popup-widget.tsx
3498
+ var import_core14 = __toESM(require_core(), 1);
3499
+ var PopupWidget = class extends import_core14.Widget {
3500
+ constructor(props) {
3501
+ super(props);
3502
+ this.className = "deck-widget-popup";
3503
+ this.placement = "fill";
3504
+ this.setProps(this.props);
3505
+ this.isOpen = this.props.defaultIsOpen;
3506
+ }
3507
+ setProps(props) {
3508
+ this.viewId = props.viewId ?? this.viewId;
3509
+ super.setProps(props);
3510
+ }
3511
+ onAdd({ deck }) {
3512
+ this.deck = deck;
3513
+ }
3514
+ onViewportChange(viewport) {
3515
+ this.viewport = viewport;
3516
+ this.updateHTML();
3517
+ }
3518
+ onClick() {
3519
+ if (this.props.closeOnClickOutside) {
3520
+ this._setIsOpen(false);
3521
+ }
3522
+ }
3523
+ _setIsOpen(isOpen) {
3524
+ if (this.isOpen === isOpen)
3525
+ return;
3526
+ this.isOpen = isOpen;
3527
+ this.props.onOpenChange?.(isOpen);
3528
+ this.updateHTML();
3529
+ }
3530
+ onRenderHTML(rootElement) {
3531
+ if (!this.viewport) {
3532
+ B(null, rootElement);
3533
+ return;
3534
+ }
3535
+ const { marker, content, style } = this.props;
3536
+ const [x2, y3] = this.viewport.project(this.props.position);
3537
+ const ui = /* @__PURE__ */ u2("div", { children: [
3538
+ marker && /* @__PURE__ */ u2(
3539
+ "div",
3540
+ {
3541
+ style: { position: "absolute", left: x2, top: y3, pointerEvents: "all", cursor: "pointer" },
3542
+ children: /* @__PURE__ */ u2(UserContent, { ...marker, onClick: () => this._setIsOpen(true) })
3543
+ }
3544
+ ),
3545
+ this.isOpen && /* @__PURE__ */ u2(
3546
+ Popover,
3547
+ {
3548
+ x: x2,
3549
+ y: y3,
3550
+ placement: this.props.placement,
3551
+ arrow: this.props.arrow,
3552
+ arrowColor: "var(--menu-background, #fff)",
3553
+ offset: this.props.offset,
3554
+ children: /* @__PURE__ */ u2(
3555
+ "div",
3556
+ {
3557
+ className: `deck-widget-popup-content ${this.props.className}`,
3558
+ style,
3559
+ children: [
3560
+ this.props.closeButton && /* @__PURE__ */ u2(
3561
+ "div",
3562
+ {
3563
+ className: "deck-widget-popup-controls",
3564
+ style: { width: "100%", display: "flex", justifyContent: "end" },
3565
+ children: /* @__PURE__ */ u2(
3566
+ IconButton,
3567
+ {
3568
+ className: "deck-widget-popup-close-button",
3569
+ onClick: () => this._setIsOpen(false)
3570
+ }
3571
+ )
3572
+ }
3573
+ ),
3574
+ /* @__PURE__ */ u2(UserContent, { ...typeof content === "string" ? { text: content } : content })
3575
+ ]
3576
+ }
3577
+ )
3578
+ }
3579
+ )
3580
+ ] });
3581
+ B(ui, rootElement);
3582
+ }
3583
+ };
3584
+ PopupWidget.defaultProps = {
3585
+ ...import_core14.Widget.defaultProps,
3586
+ id: "info",
3587
+ viewId: null,
3588
+ position: [0, 0],
3589
+ marker: null,
3590
+ defaultIsOpen: true,
3591
+ content: "",
3592
+ placement: "right",
3593
+ offset: 10,
3594
+ arrow: 10,
3595
+ closeButton: true,
3596
+ closeOnClickOutside: false,
3597
+ onOpenChange: () => {
3598
+ }
3599
+ };
3600
+
3601
+ // src/context-menu-widget.tsx
3602
+ var import_core15 = __toESM(require_core(), 1);
3603
+ var ContextMenuWidget = class extends import_core15.Widget {
3604
+ constructor(props) {
3605
+ super(props);
3606
+ this.className = "deck-widget-context-menu";
3607
+ this.placement = "fill";
3608
+ this.menu = null;
3609
+ this.setProps(this.props);
3610
+ }
3611
+ onAdd({ deck }) {
3612
+ deck.getCanvas()?.addEventListener("contextmenu", (event) => this.handleContextMenu(event));
3613
+ }
3614
+ handleContextMenu(srcEvent) {
3615
+ const targetRect = srcEvent.target.getBoundingClientRect();
3616
+ const x2 = srcEvent.clientX - targetRect.x;
3617
+ const y3 = srcEvent.clientY - targetRect.y;
3618
+ const pickInfo = this.deck?.pickObject({ x: x2, y: y3 }) || {
3619
+ x: x2,
3620
+ y: y3,
3621
+ picked: false,
3622
+ layer: null,
3623
+ color: null,
3624
+ index: -1,
3625
+ pixelRatio: 1
3626
+ };
3627
+ const menuItems = this.props.getMenuItems(pickInfo, this) || [];
3628
+ this.menu = menuItems.length > 0 ? {
3629
+ items: menuItems,
3630
+ pickInfo
3631
+ } : null;
3632
+ srcEvent.preventDefault();
3633
+ this.updateHTML();
3634
+ }
3635
+ onRenderHTML(rootElement) {
3636
+ if (!this.menu) {
3637
+ B(null, rootElement);
3638
+ return;
3639
+ }
3640
+ const { items, pickInfo } = this.menu;
3641
+ const style = {
3642
+ pointerEvents: "auto",
3643
+ position: "static",
3644
+ ...this.props.style
3645
+ };
3646
+ const ui = /* @__PURE__ */ u2(
3647
+ Popover,
3648
+ {
3649
+ x: pickInfo.x,
3650
+ y: pickInfo.y,
3651
+ placement: this.props.placement,
3652
+ arrow: this.props.arrow,
3653
+ arrowColor: "var(--menu-background, #fff)",
3654
+ offset: this.props.offset,
3655
+ children: /* @__PURE__ */ u2(
3656
+ SimpleMenu,
3657
+ {
3658
+ menuItems: items,
3659
+ onSelect: (value) => this.props.onMenuItemSelected(value, pickInfo),
3660
+ style,
3661
+ isOpen: true,
3662
+ onClose: () => this.hide()
3663
+ }
3664
+ )
3665
+ }
3666
+ );
3667
+ B(ui, rootElement);
3668
+ }
3669
+ hide() {
3670
+ this.menu = null;
3671
+ this.updateHTML();
3672
+ }
3673
+ };
3674
+ ContextMenuWidget.defaultProps = {
3675
+ ...import_core15.Widget.defaultProps,
3676
+ id: "context",
3677
+ viewId: null,
3678
+ getMenuItems: void 0,
3679
+ onMenuItemSelected: () => {
3680
+ },
3681
+ placement: "bottom-start",
3682
+ offset: 10,
3683
+ arrow: false
3684
+ };
3685
+
3686
+ // src/scrollbar-widget.tsx
3687
+ var import_core16 = __toESM(require_core(), 1);
3688
+
3689
+ // src/lib/components/range-input.tsx
3690
+ var wheelListenerOptions = { passive: false };
3691
+ var clamp2 = (value, min3, max3) => {
3692
+ if (value < min3) {
3693
+ return min3;
3694
+ }
3695
+ if (value > max3) {
3696
+ return max3;
3697
+ }
3698
+ return value;
3699
+ };
3700
+ var getTrackDimension = (track, vertical) => {
3701
+ if (!track || !track.firstElementChild) {
3702
+ return [0, 0];
3703
+ }
3704
+ const rect = track.firstElementChild.getBoundingClientRect();
3705
+ if (vertical) {
3706
+ return [rect.top, rect.height];
3707
+ }
3708
+ return vertical ? [rect.top, rect.height] : [rect.left, rect.width];
3709
+ };
3710
+ var getEffectiveStep = (step, range) => {
3711
+ if (typeof step === "number" && !Number.isNaN(step) && step > 0) {
3712
+ return step;
3713
+ }
3714
+ return Math.max(1, range / 10 || 1);
3715
+ };
3716
+ var getEffectivePage = (pageSize, rangeSize) => {
3717
+ if (typeof pageSize === "number" && !Number.isNaN(pageSize) && pageSize > 0) {
3718
+ return pageSize;
3719
+ }
3720
+ return Math.max(1, rangeSize || 1);
3721
+ };
3722
+ function RangeInput(props) {
3723
+ const {
3724
+ className = "",
3725
+ min: min3,
3726
+ max: max3,
3727
+ step,
3728
+ value,
3729
+ orientation,
3730
+ pageSize,
3731
+ stepButtons = false,
3732
+ startButtonAriaLabel,
3733
+ endButtonAriaLabel,
3734
+ eventTarget,
3735
+ decorations = [],
3736
+ onChange
3737
+ } = props;
3738
+ const vertical = orientation !== "horizontal";
3739
+ const rootRef = A2(null);
3740
+ const trackRef = A2(null);
3741
+ const thumbRef = A2(null);
3742
+ const dragStateRef = A2(null);
3743
+ const [trackLength, setTrackLength] = h2(0);
3744
+ const range = max3 - min3;
3745
+ const rangeSize = Math.max(0, value[1] - value[0]);
3746
+ const maxStart = Math.max(0, range - rangeSize);
3747
+ const clampedStart = clamp2(value[0], min3, min3 + maxStart);
3748
+ const { thumbLength, thumbOffset } = T2(() => {
3749
+ if (trackLength <= 0 || range <= 0) {
3750
+ return { thumbLength: 0, thumbOffset: 0 };
3751
+ }
3752
+ if (range <= rangeSize) {
3753
+ return { thumbLength: 1, thumbOffset: 0 };
3754
+ }
3755
+ const nextThumbLength = rangeSize / range;
3756
+ const travel = Math.max(0, 1 - nextThumbLength);
3757
+ const ratio = maxStart <= 0 ? 0 : clamp2((clampedStart - min3) / maxStart, 0, 1);
3758
+ return {
3759
+ thumbLength: Math.max(0, Math.min(nextThumbLength, 1)),
3760
+ thumbOffset: travel * ratio
3761
+ };
3762
+ }, [trackLength, range, rangeSize, maxStart, clampedStart, min3]);
3763
+ const emitRange = q2(
3764
+ (nextStart) => {
3765
+ if (!onChange) {
3766
+ return;
3767
+ }
3768
+ const clamped = clamp2(nextStart, min3, min3 + maxStart);
3769
+ onChange([clamped, clamped + rangeSize]);
3770
+ },
3771
+ [onChange, min3, maxStart, rangeSize]
3772
+ );
3773
+ const handleStepNegative = q2(
3774
+ (event) => {
3775
+ event.stopPropagation();
3776
+ emitRange(clampedStart - getEffectiveStep(step, range));
3777
+ },
3778
+ [emitRange, clampedStart, step, range]
3779
+ );
3780
+ const handleStepPositive = q2(
3781
+ (event) => {
3782
+ event.stopPropagation();
3783
+ emitRange(clampedStart + getEffectiveStep(step, range));
3784
+ },
3785
+ [emitRange, clampedStart, step, range]
3786
+ );
3787
+ const handleTrackClick = q2(
3788
+ (event) => {
3789
+ if (event.button !== 0) {
3790
+ return;
3791
+ }
3792
+ const target = event.target;
3793
+ if (target?.dataset.scrollbarThumb === "true") {
3794
+ return;
3795
+ }
3796
+ const track = trackRef.current;
3797
+ if (!track) {
3798
+ return;
3799
+ }
3800
+ event.preventDefault();
3801
+ event.stopPropagation();
3802
+ const [trackStart] = getTrackDimension(track, vertical);
3803
+ const coordinate = vertical ? event.clientY - trackStart : event.clientX - trackStart;
3804
+ const span = Math.max(1, 1 - thumbLength) * trackLength;
3805
+ const thumbCenter = thumbLength / 2 * trackLength;
3806
+ const ratio = span <= 0 ? 0 : clamp2((coordinate - thumbCenter) / span, 0, 1);
3807
+ emitRange(min3 + ratio * maxStart);
3808
+ },
3809
+ [vertical, trackLength, thumbLength, emitRange, min3, maxStart]
3810
+ );
3811
+ const handleThumbPointerDown = (event) => {
3812
+ if (event.button !== 0) {
3813
+ return;
3814
+ }
3815
+ const track = trackRef.current;
3816
+ if (!track) {
3817
+ return;
3818
+ }
3819
+ dragStateRef.current = {
3820
+ pointerId: event.pointerId,
3821
+ startCoord: vertical ? event.clientY : event.clientX,
3822
+ startRatio: thumbOffset,
3823
+ min: min3,
3824
+ max: max3,
3825
+ maxStart
3826
+ };
3827
+ event.currentTarget.setPointerCapture(event.pointerId);
3828
+ event.preventDefault();
3829
+ event.stopPropagation();
3830
+ };
3831
+ const handleThumbPointerMove = q2(
3832
+ (event) => {
3833
+ const state = dragStateRef.current;
3834
+ if (!state || state.pointerId !== event.pointerId) {
3835
+ return;
3836
+ }
3837
+ const [trackStart, trackLength2] = getTrackDimension(trackRef.current, vertical);
3838
+ const coordinate = vertical ? event.clientY : event.clientX;
3839
+ const delta = coordinate - state.startCoord;
3840
+ const ratio = state.startRatio + delta / trackLength2;
3841
+ const nextStart = clamp2(ratio * (state.max - state.min), 0, state.maxStart) + state.min;
3842
+ emitRange(nextStart);
3843
+ event.preventDefault();
3844
+ },
3845
+ [emitRange, vertical]
3846
+ );
3847
+ const handleThumbPointerUp = q2((event) => {
3848
+ const state = dragStateRef.current;
3849
+ if (state && state.pointerId === event.pointerId) {
3850
+ dragStateRef.current = null;
3851
+ thumbRef.current?.releasePointerCapture(event.pointerId);
3852
+ event.preventDefault();
3853
+ }
3854
+ }, []);
3855
+ const handleKeyDown = q2(
3856
+ (event) => {
3857
+ switch (event.key) {
3858
+ case "ArrowUp":
3859
+ case "ArrowLeft":
3860
+ if (vertical && event.key === "ArrowUp" || !vertical && event.key === "ArrowLeft") {
3861
+ emitRange(clampedStart - getEffectiveStep(step, range));
3862
+ event.preventDefault();
3863
+ }
3864
+ break;
3865
+ case "ArrowDown":
3866
+ case "ArrowRight":
3867
+ if (vertical && event.key === "ArrowDown" || !vertical && event.key === "ArrowRight") {
3868
+ emitRange(clampedStart + getEffectiveStep(step, range));
3869
+ event.preventDefault();
3870
+ }
3871
+ break;
3872
+ case "PageUp":
3873
+ emitRange(clampedStart - getEffectivePage(pageSize, rangeSize));
3874
+ event.preventDefault();
3875
+ break;
3876
+ case "PageDown":
3877
+ emitRange(clampedStart + getEffectivePage(pageSize, rangeSize));
3878
+ event.preventDefault();
3879
+ break;
3880
+ case "Home":
3881
+ emitRange(min3);
3882
+ event.preventDefault();
3883
+ break;
3884
+ case "End":
3885
+ emitRange(min3 + maxStart);
3886
+ event.preventDefault();
3887
+ break;
3888
+ default:
3889
+ break;
3890
+ }
3891
+ },
3892
+ [vertical, emitRange, clampedStart, step, range, pageSize, rangeSize, min3, maxStart]
3893
+ );
3894
+ const handleWheel = q2(
3895
+ (event) => {
3896
+ event.preventDefault();
3897
+ event.stopPropagation();
3898
+ if (maxStart === 0) {
3899
+ return;
3900
+ }
3901
+ let delta = vertical ? event.deltaY : event.deltaX;
3902
+ if (!vertical && delta === 0) {
3903
+ delta = event.deltaY;
3904
+ }
3905
+ if (event.deltaMode === WheelEvent.DOM_DELTA_LINE) {
3906
+ delta *= getEffectiveStep(step, range);
3907
+ } else if (event.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
3908
+ delta *= getEffectivePage(pageSize, rangeSize);
3909
+ }
3910
+ if (delta === 0) {
3911
+ return;
3912
+ }
3913
+ emitRange(clampedStart + delta);
3914
+ },
3915
+ [emitRange, clampedStart, maxStart, vertical, step, range, pageSize, rangeSize]
3916
+ );
3917
+ _2(() => {
3918
+ setTrackLength(getTrackDimension(trackRef.current, vertical)[1]);
3919
+ }, [vertical]);
3920
+ _2(() => {
3921
+ const track = trackRef.current;
3922
+ if (!track) {
3923
+ return void 0;
3924
+ }
3925
+ const update = () => {
3926
+ setTrackLength(getTrackDimension(track, vertical)[1]);
3927
+ };
3928
+ update();
3929
+ if (typeof ResizeObserver !== "undefined") {
3930
+ const observer = new ResizeObserver(update);
3931
+ observer.observe(track);
3932
+ return () => observer.disconnect();
3933
+ }
3934
+ if (typeof window !== "undefined") {
3935
+ window.addEventListener("resize", update);
3936
+ return () => window.removeEventListener("resize", update);
3937
+ }
3938
+ return void 0;
3939
+ }, [vertical]);
3940
+ y2(() => {
3941
+ const eventRoot = eventTarget ?? rootRef.current;
3942
+ if (!eventRoot)
3943
+ return void 0;
3944
+ eventRoot.addEventListener("keydown", handleKeyDown);
3945
+ eventRoot.addEventListener("wheel", handleWheel, wheelListenerOptions);
3946
+ return () => {
3947
+ eventRoot.removeEventListener("keydown", handleKeyDown);
3948
+ eventRoot.removeEventListener("wheel", handleWheel, wheelListenerOptions);
3949
+ };
3950
+ }, [eventTarget, handleKeyDown, handleWheel]);
3951
+ const decorationElements = T2(() => {
3952
+ if (!decorations.length || range <= 0) {
3953
+ return [];
3954
+ }
3955
+ return decorations.map((decoration, index) => {
3956
+ const [start, end] = decoration.position;
3957
+ const startRatio = (start - min3) / range;
3958
+ const endRatio = (end - min3) / range;
3959
+ const offsetPct = Math.round(startRatio * 1e3) / 10;
3960
+ const sizePct = Math.max(0, Math.round((endRatio - startRatio) * 1e3) / 10);
3961
+ const style = vertical ? {
3962
+ left: "0",
3963
+ width: "100%",
3964
+ top: `${offsetPct}%`,
3965
+ height: `${sizePct}%`
3966
+ } : {
3967
+ top: "0",
3968
+ height: "100%",
3969
+ left: `${offsetPct}%`,
3970
+ width: `${sizePct}%`
3971
+ };
3972
+ return /* @__PURE__ */ u2("div", { className: "deck-widget-range__decoration", style, children: decoration.element }, `decoration-${index}`);
3973
+ });
3974
+ }, [decorations, range, min3, vertical]);
3975
+ return /* @__PURE__ */ u2(
3976
+ "div",
3977
+ {
3978
+ ref: rootRef,
3979
+ tabIndex: 0,
3980
+ role: "scrollbar",
3981
+ "aria-valuemin": min3,
3982
+ "aria-valuemax": min3 + maxStart,
3983
+ "aria-valuenow": clampedStart,
3984
+ "aria-orientation": orientation,
3985
+ className: `${className} deck-widget-range deck-widget-range--${orientation} ${maxStart === 0 ? "deck-widget-range--disabled" : ""}`,
3986
+ children: [
3987
+ stepButtons && /* @__PURE__ */ u2(
3988
+ "button",
3989
+ {
3990
+ type: "button",
3991
+ className: "deck-widget-range__button deck-widget-range__button--start",
3992
+ "aria-label": startButtonAriaLabel,
3993
+ disabled: clampedStart <= min3,
3994
+ onClick: handleStepNegative,
3995
+ children: /* @__PURE__ */ u2("span", { className: "deck-widget-icon" })
3996
+ }
3997
+ ),
3998
+ /* @__PURE__ */ u2("div", { className: "deck-widget-range__track", ref: trackRef, onClick: handleTrackClick, children: [
3999
+ /* @__PURE__ */ u2("div", { className: "deck-widget-range__decorations", children: decorationElements }),
4000
+ /* @__PURE__ */ u2(
4001
+ "div",
4002
+ {
4003
+ className: "deck-widget-range__thumb",
4004
+ "data-scrollbar-thumb": "true",
4005
+ ref: thumbRef,
4006
+ style: vertical ? { height: `${thumbLength * 100}%`, top: `${thumbOffset * 100}%` } : { width: `${thumbLength * 100}%`, left: `${thumbOffset * 100}%` },
4007
+ onPointerDown: handleThumbPointerDown,
4008
+ onPointerMove: handleThumbPointerMove,
4009
+ onPointerUp: handleThumbPointerUp,
4010
+ onPointerCancel: handleThumbPointerUp
4011
+ }
4012
+ )
4013
+ ] }),
4014
+ stepButtons && /* @__PURE__ */ u2(
4015
+ "button",
4016
+ {
4017
+ type: "button",
4018
+ className: "deck-widget-range__button deck-widget-range__button--end",
4019
+ "aria-label": endButtonAriaLabel,
4020
+ disabled: clampedStart >= min3 + maxStart,
4021
+ onClick: handleStepPositive,
4022
+ children: /* @__PURE__ */ u2("span", { className: "deck-widget-icon" })
4023
+ }
4024
+ )
4025
+ ]
4026
+ }
4027
+ );
4028
+ }
4029
+
4030
+ // src/scrollbar-widget.tsx
4031
+ var clamp3 = (value, min3, max3) => {
4032
+ if (value < min3) {
4033
+ return min3;
4034
+ }
4035
+ if (value > max3) {
4036
+ return max3;
4037
+ }
4038
+ return value;
4039
+ };
4040
+ var _ScrollbarWidget = class extends import_core16.Widget {
4041
+ constructor(props) {
4042
+ const resolved = {
4043
+ ..._ScrollbarWidget.defaultProps,
4044
+ ...props
4045
+ };
4046
+ super(resolved);
4047
+ this.className = "deck-widget-scrollbar";
4048
+ this.placement = "fill";
4049
+ this.contentSize = 0;
4050
+ this.viewportSize = 0;
4051
+ this.scrollOffset = 0;
4052
+ this.handleRangeChange = (nextValue) => {
4053
+ this.emitScroll(nextValue[0]);
4054
+ };
4055
+ this.viewId = resolved.viewId ?? null;
4056
+ }
4057
+ onViewportChange(viewport) {
4058
+ this.viewport = viewport;
4059
+ this.onRenderHTML();
4060
+ }
4061
+ onRenderHTML() {
4062
+ const element = this.rootElement;
4063
+ if (!element) {
4064
+ return;
4065
+ }
4066
+ element.dataset.placement = this.props.placement;
4067
+ const viewport = this.viewport;
4068
+ this.updateViewport(viewport);
4069
+ const clampedOffset = this.getClampedOffset();
4070
+ const wheelTarget = this.getWheelEventTarget(this.props.captureWheel ? "global" : "local");
4071
+ const decorations = this.getDecorations(viewport);
4072
+ const isVertical = this.isVertical();
4073
+ const startLabel = this.props.startButtonAriaLabel ?? (isVertical ? "Scroll up" : "Scroll left");
4074
+ const endLabel = this.props.endButtonAriaLabel ?? (isVertical ? "Scroll down" : "Scroll right");
4075
+ const ui = /* @__PURE__ */ u2(
4076
+ RangeInput,
4077
+ {
4078
+ min: 0,
4079
+ max: Math.max(0, this.contentSize),
4080
+ step: this.getEffectiveStep(),
4081
+ pageSize: this.getEffectivePage(),
4082
+ value: [clampedOffset, clampedOffset + this.viewportSize],
4083
+ orientation: this.props.orientation,
4084
+ stepButtons: true,
4085
+ startButtonAriaLabel: startLabel,
4086
+ endButtonAriaLabel: endLabel,
4087
+ eventTarget: wheelTarget,
4088
+ decorations,
4089
+ onChange: this.handleRangeChange
4090
+ }
4091
+ );
4092
+ B(ui, element);
4093
+ }
4094
+ onRemove() {
4095
+ if (this.rootElement) {
4096
+ B(null, this.rootElement);
4097
+ }
4098
+ super.onRemove();
4099
+ }
4100
+ updateViewport(viewport) {
4101
+ if (!viewport) {
4102
+ this.contentSize = 0;
4103
+ this.scrollOffset = 0;
4104
+ this.viewportSize = 0;
4105
+ return;
4106
+ }
4107
+ const { contentBounds } = this.props;
4108
+ const isVertical = this.isVertical();
4109
+ const projectedBounds = contentBounds ? projectBounds(contentBounds, viewport, isVertical) : [0, 0];
4110
+ this.contentSize = projectedBounds[1] - projectedBounds[0];
4111
+ this.scrollOffset = -projectedBounds[0];
4112
+ this.viewportSize = isVertical ? viewport.height : viewport.width;
4113
+ }
4114
+ getDecorations(viewport) {
4115
+ const { decorations = [], contentBounds } = this.props;
4116
+ if (!viewport || !contentBounds || decorations.length === 0) {
4117
+ return [];
4118
+ }
4119
+ const isVertical = this.isVertical();
4120
+ const [contentStart] = projectBounds(contentBounds, viewport, isVertical);
4121
+ return decorations.map((decoration) => {
4122
+ const [start, end] = projectBounds(decoration.contentBounds, viewport, isVertical);
4123
+ const onClick = decoration.onClick ? (e3) => {
4124
+ const handled = decoration.onClick?.(e3);
4125
+ if (handled) {
4126
+ e3.stopPropagation();
4127
+ e3.preventDefault();
4128
+ }
4129
+ } : void 0;
4130
+ return {
4131
+ position: [start - contentStart, end - contentStart],
4132
+ element: /* @__PURE__ */ u2(
4133
+ "div",
4134
+ {
4135
+ style: {
4136
+ pointerEvents: onClick ? "all" : "none",
4137
+ width: "100%",
4138
+ height: "100%",
4139
+ backgroundColor: decoration.color
4140
+ },
4141
+ title: decoration.title,
4142
+ onClick
4143
+ }
4144
+ )
4145
+ };
4146
+ });
4147
+ }
4148
+ getWheelEventTarget(mode) {
4149
+ if (mode === null)
4150
+ return null;
4151
+ if (mode === "local")
4152
+ return this.rootElement;
4153
+ return this.deck?.props.parent || this.deck?.getCanvas()?.parentElement || this.rootElement;
4154
+ }
4155
+ getMaxScroll() {
4156
+ return Math.max(0, this.contentSize - this.viewportSize);
4157
+ }
4158
+ getClampedOffset() {
4159
+ const maxScroll = this.getMaxScroll();
4160
+ return clamp3(this.scrollOffset, 0, maxScroll);
4161
+ }
4162
+ isVertical() {
4163
+ return this.props.orientation !== "horizontal";
4164
+ }
4165
+ getEffectiveStep() {
4166
+ if (typeof this.props.stepSize === "number" && !Number.isNaN(this.props.stepSize)) {
4167
+ return this.props.stepSize;
4168
+ }
4169
+ return Math.max(1, this.viewportSize / 10 || 1);
4170
+ }
4171
+ getEffectivePage() {
4172
+ if (typeof this.props.pageSize === "number" && !Number.isNaN(this.props.pageSize)) {
4173
+ return this.props.pageSize;
4174
+ }
4175
+ return this.viewportSize;
4176
+ }
4177
+ emitScroll(next) {
4178
+ const maxScroll = this.getMaxScroll();
4179
+ const target = clamp3(Math.round(next), 0, maxScroll);
4180
+ const viewport = this.viewport;
4181
+ if (viewport && target !== this.getClampedOffset()) {
4182
+ const pixel = viewport.project(viewport.position);
4183
+ if (this.isVertical()) {
4184
+ pixel[1] -= target - this.scrollOffset;
4185
+ } else {
4186
+ pixel[0] -= target - this.scrollOffset;
4187
+ }
4188
+ const { target: newTarget } = viewport.panByPosition(viewport.position, pixel);
4189
+ this.deck._onViewStateChange({
4190
+ viewId: viewport.id,
4191
+ viewState: {
4192
+ ...this.getViewState(viewport.id),
4193
+ target: newTarget
4194
+ },
4195
+ interactionState: {}
4196
+ });
4197
+ }
4198
+ }
4199
+ };
4200
+ var ScrollbarWidget = _ScrollbarWidget;
4201
+ ScrollbarWidget.defaultProps = {
4202
+ ...import_core16.Widget.defaultProps,
4203
+ contentBounds: null,
4204
+ placement: "top-right",
4205
+ viewId: null,
4206
+ orientation: "vertical",
4207
+ stepSize: null,
4208
+ pageSize: null,
4209
+ startButtonAriaLabel: "",
4210
+ endButtonAriaLabel: "",
4211
+ captureWheel: false,
4212
+ decorations: []
4213
+ };
4214
+ function projectBounds(bounds, viewport, isVertical) {
4215
+ return bounds.map(([x2, y3]) => viewport.project([x2, y3, 0])).reduce(
4216
+ (range, [x2, y3]) => {
4217
+ const value = isVertical ? y3 : x2;
4218
+ range[0] = Math.min(range[0], value);
4219
+ range[1] = Math.max(range[1], value);
4220
+ return range;
4221
+ },
4222
+ [Infinity, -Infinity]
4223
+ );
4224
+ }
4225
+
4226
+ // src/timeline-widget.tsx
4227
+ var import_core17 = __toESM(require_core(), 1);
4228
+ var TimelineWidget = class extends import_core17.Widget {
4229
+ constructor(props = {}) {
4230
+ super(props);
2189
4231
  this.id = "timeline";
2190
4232
  this.className = "deck-widget-timeline";
2191
- this.placement = "bottom-left";
4233
+ this.placement = "fill";
2192
4234
  this.playing = false;
2193
4235
  this.timerId = null;
2194
4236
  this.handlePlayPause = () => {
2195
4237
  if (this.playing) {
2196
4238
  this.stop();
2197
4239
  } else {
2198
- this.start();
4240
+ this.play();
2199
4241
  }
2200
4242
  };
2201
- this.handleSliderChange = (e3) => {
2202
- const input = e3.target;
2203
- const val = Number(input.value);
2204
- this.currentTime = val;
2205
- this.props.onTimeChange(val);
4243
+ this.handleTimeChange = ([value]) => {
4244
+ this.currentTime = value;
4245
+ this.props.timeline?.setTime(value);
4246
+ this.props.onTimeChange(value);
2206
4247
  this.updateHTML();
2207
4248
  };
2208
4249
  this.tick = () => {
2209
- const [min, max] = this.props.timeRange;
2210
- let next = this.currentTime + this.props.step;
2211
- if (next > max) {
2212
- next = min;
4250
+ const {
4251
+ timeRange: [min3, max3],
4252
+ step,
4253
+ loop
4254
+ } = this.props;
4255
+ if (step > 0) {
4256
+ let next = Math.floor(this.currentTime / step) * step + step;
4257
+ if (next > max3) {
4258
+ if (this.currentTime < max3) {
4259
+ next = max3;
4260
+ } else if (loop) {
4261
+ next = min3;
4262
+ } else {
4263
+ next = max3;
4264
+ this.playing = false;
4265
+ }
4266
+ }
4267
+ this.currentTime = next;
4268
+ this.props.onTimeChange(next);
4269
+ this.updateHTML();
2213
4270
  }
2214
- this.currentTime = next;
2215
- this.props.onTimeChange(next);
2216
- this.updateHTML();
2217
4271
  if (this.playing) {
2218
4272
  this.timerId = window.setTimeout(this.tick, this.props.playInterval);
4273
+ } else {
4274
+ this.timerId = null;
2219
4275
  }
2220
4276
  };
2221
4277
  this.currentTime = this.props.initialTime ?? this.props.timeRange[0];
4278
+ this.props.timeline?.setTime(this.currentTime);
2222
4279
  this.setProps(this.props);
2223
4280
  }
2224
4281
  setProps(props) {
2225
- this.placement = props.placement ?? this.placement;
2226
4282
  this.viewId = props.viewId ?? this.viewId;
2227
4283
  super.setProps(props);
2228
4284
  }
2229
4285
  onAdd() {
2230
4286
  this.playing = false;
2231
4287
  this.timerId = null;
4288
+ if (this.props.autoPlay)
4289
+ this.play();
2232
4290
  }
2233
4291
  onRemove() {
2234
4292
  this.stop();
2235
4293
  }
2236
4294
  onRenderHTML(rootElement) {
4295
+ const { timeRange, step, formatLabel } = this.props;
4296
+ const currentTime = this.currentTime;
4297
+ rootElement.dataset.placement = this.props.placement;
2237
4298
  B(
2238
- /* @__PURE__ */ u2("div", { style: { display: "flex", alignItems: "center", pointerEvents: "auto" }, children: [
2239
- /* @__PURE__ */ u2(IconButton, { label: this.playing ? "Pause" : "Play", onClick: this.handlePlayPause, children: /* @__PURE__ */ u2("div", { className: "text", children: this.playing ? "\u23F8" : "\u25B6" }) }),
4299
+ /* @__PURE__ */ u2("div", { className: "deck-widget-button-group", children: [
4300
+ this.playing ? /* @__PURE__ */ u2(
4301
+ IconButton,
4302
+ {
4303
+ label: "Pause",
4304
+ className: "deck-widget-timeline-pause",
4305
+ onClick: this.handlePlayPause
4306
+ }
4307
+ ) : /* @__PURE__ */ u2(
4308
+ IconButton,
4309
+ {
4310
+ label: "Play",
4311
+ className: "deck-widget-timeline-play",
4312
+ onClick: this.handlePlayPause
4313
+ }
4314
+ ),
2240
4315
  /* @__PURE__ */ u2(
2241
- "input",
4316
+ RangeInput,
2242
4317
  {
2243
- type: "range",
2244
- className: "timeline-slider",
2245
- min: this.props.timeRange[0],
2246
- max: this.props.timeRange[1],
2247
- step: this.props.step,
2248
- value: this.currentTime,
2249
- onInput: this.handleSliderChange
4318
+ min: timeRange[0],
4319
+ max: timeRange[1],
4320
+ orientation: "horizontal",
4321
+ step,
4322
+ value: [currentTime, currentTime],
4323
+ onChange: this.handleTimeChange,
4324
+ decorations: [
4325
+ {
4326
+ position: [currentTime, currentTime + step],
4327
+ element: /* @__PURE__ */ u2("div", { className: "deck-widget-timeline-label deck-widget-timeline-label--current", children: formatLabel(currentTime) })
4328
+ }
4329
+ ]
2250
4330
  }
2251
4331
  )
2252
4332
  ] }),
2253
4333
  rootElement
2254
4334
  );
2255
4335
  }
2256
- start() {
4336
+ play() {
2257
4337
  this.playing = true;
2258
4338
  this.updateHTML();
2259
4339
  this.tick();
@@ -2268,21 +4348,25 @@ var __exports__ = (() => {
2268
4348
  }
2269
4349
  };
2270
4350
  TimelineWidget.defaultProps = {
2271
- ...import_core14.Widget.defaultProps,
4351
+ ...import_core17.Widget.defaultProps,
2272
4352
  id: "timeline",
2273
4353
  placement: "bottom-left",
2274
4354
  viewId: null,
4355
+ timeline: null,
2275
4356
  timeRange: [0, 100],
2276
4357
  step: 1,
2277
4358
  initialTime: void 0,
2278
4359
  onTimeChange: () => {
2279
4360
  },
2280
- playInterval: 1e3
4361
+ autoPlay: false,
4362
+ loop: false,
4363
+ playInterval: 1e3,
4364
+ formatLabel: String
2281
4365
  };
2282
4366
 
2283
4367
  // src/screenshot-widget.tsx
2284
- var import_core15 = __toESM(require_core(), 1);
2285
- var ScreenshotWidget = class extends import_core15.Widget {
4368
+ var import_core18 = __toESM(require_core(), 1);
4369
+ var ScreenshotWidget = class extends import_core18.Widget {
2286
4370
  constructor(props = {}) {
2287
4371
  super(props);
2288
4372
  this.className = "deck-widget-screenshot";
@@ -2331,7 +4415,7 @@ var __exports__ = (() => {
2331
4415
  }
2332
4416
  };
2333
4417
  ScreenshotWidget.defaultProps = {
2334
- ...import_core15.Widget.defaultProps,
4418
+ ...import_core18.Widget.defaultProps,
2335
4419
  id: "screenshot",
2336
4420
  placement: "top-left",
2337
4421
  viewId: null,
@@ -2342,8 +4426,8 @@ var __exports__ = (() => {
2342
4426
  };
2343
4427
 
2344
4428
  // src/theme-widget.tsx
2345
- var import_core16 = __toESM(require_core(), 1);
2346
- var import_core17 = __toESM(require_core(), 1);
4429
+ var import_core19 = __toESM(require_core(), 1);
4430
+ var import_core20 = __toESM(require_core(), 1);
2347
4431
 
2348
4432
  // src/themes.ts
2349
4433
  var LightTheme = {
@@ -2366,7 +4450,13 @@ var __exports__ = (() => {
2366
4450
  "--menu-border": "unset",
2367
4451
  "--menu-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25)",
2368
4452
  "--menu-text": "rgb(24, 24, 26, 1)",
2369
- "--menu-item-hover": "rgba(0, 0, 0, 0.08)"
4453
+ "--menu-item-hover": "rgba(0, 0, 0, 0.08)",
4454
+ "--range-step-button-size": "24px",
4455
+ "--range-track-size": "16px",
4456
+ "--range-thumb-size": "10px",
4457
+ "--range-track-color": "#d8d8e5",
4458
+ "--range-thumb-color": "#616166",
4459
+ "--range-decoration-active-color": "#f8dd50"
2370
4460
  };
2371
4461
  var DarkTheme = {
2372
4462
  "--widget-margin": "12px",
@@ -2388,7 +4478,13 @@ var __exports__ = (() => {
2388
4478
  "--menu-border": "unset",
2389
4479
  "--menu-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25)",
2390
4480
  "--menu-text": "rgb(215, 214, 229, 1)",
2391
- "--menu-item-hover": "rgba(255, 255, 255, 0.1)"
4481
+ "--menu-item-hover": "rgba(255, 255, 255, 0.1)",
4482
+ "--range-step-button-size": "24px",
4483
+ "--range-track-size": "16px",
4484
+ "--range-thumb-size": "10px",
4485
+ "--range-track-color": "#2c2c30",
4486
+ "--range-thumb-color": "#9e9da8",
4487
+ "--range-decoration-active-color": "#dd7d2c"
2392
4488
  };
2393
4489
  var LightGlassTheme = {
2394
4490
  "--widget-margin": "12px",
@@ -2410,7 +4506,13 @@ var __exports__ = (() => {
2410
4506
  "--menu-border": "1px solid rgba(255, 255, 255, 0.6)",
2411
4507
  "--menu-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
2412
4508
  "--menu-text": "rgb(24, 24, 26, 1)",
2413
- "--menu-item-hover": "rgba(0, 0, 0, 0.08)"
4509
+ "--menu-item-hover": "rgba(0, 0, 0, 0.08)",
4510
+ "--range-step-button-size": "24px",
4511
+ "--range-track-size": "16px",
4512
+ "--range-thumb-size": "10px",
4513
+ "--range-track-color": "rgba(215, 214, 229, 0.3)",
4514
+ "--range-thumb-color": "rgba(97, 97, 102, 1)",
4515
+ "--range-decoration-active-color": "rgba(255, 215, 0, 0.6)"
2414
4516
  };
2415
4517
  var DarkGlassTheme = {
2416
4518
  "--widget-margin": "12px",
@@ -2432,11 +4534,17 @@ var __exports__ = (() => {
2432
4534
  "--menu-border": "1px solid rgba(18, 18, 20, 0.75)",
2433
4535
  "--menu-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
2434
4536
  "--menu-text": "rgb(215, 214, 229, 1)",
2435
- "--menu-item-hover": "rgba(255, 255, 255, 0.1)"
4537
+ "--menu-item-hover": "rgba(255, 255, 255, 0.1)",
4538
+ "--range-step-button-size": "24px",
4539
+ "--range-track-size": "16px",
4540
+ "--range-thumb-size": "10px",
4541
+ "--range-track-color": "rgba(24, 24, 26, 0.3)",
4542
+ "--range-thumb-color": "rgba(158, 157, 168, 1)",
4543
+ "--range-decoration-active-color": "rgba(255, 145, 0, 0.6)"
2436
4544
  };
2437
4545
 
2438
4546
  // src/theme-widget.tsx
2439
- var ThemeWidget = class extends import_core17.Widget {
4547
+ var ThemeWidget = class extends import_core20.Widget {
2440
4548
  constructor(props = {}) {
2441
4549
  super(props);
2442
4550
  this.className = "deck-widget-theme";
@@ -2453,17 +4561,17 @@ var __exports__ = (() => {
2453
4561
  super.setProps(props);
2454
4562
  switch (this.themeMode) {
2455
4563
  case "light":
2456
- if (props.lightModeTheme && !(0, import_core16._deepEqual)(props.lightModeTheme, lightModeTheme, 1)) {
4564
+ if (props.lightModeTheme && !(0, import_core19._deepEqual)(props.lightModeTheme, lightModeTheme, 1)) {
2457
4565
  this._setThemeMode("light");
2458
4566
  }
2459
4567
  break;
2460
4568
  case "dark":
2461
- if (props.darkModeTheme && !(0, import_core16._deepEqual)(props.darkModeTheme, darkModeTheme, 1)) {
4569
+ if (props.darkModeTheme && !(0, import_core19._deepEqual)(props.darkModeTheme, darkModeTheme, 1)) {
2462
4570
  this._setThemeMode("dark");
2463
4571
  }
2464
4572
  break;
2465
4573
  default:
2466
- import_core16.log.warn(`Invalid theme mode ${this.themeMode}`)();
4574
+ import_core19.log.warn(`Invalid theme mode ${this.themeMode}`)();
2467
4575
  }
2468
4576
  }
2469
4577
  onRenderHTML(rootElement) {
@@ -2492,20 +4600,26 @@ var __exports__ = (() => {
2492
4600
  const container = this.rootElement?.closest(".deck-widget-container");
2493
4601
  if (container) {
2494
4602
  const themeStyle = themeMode === "dark" ? this.props.darkModeTheme : this.props.lightModeTheme;
2495
- (0, import_core16._applyStyles)(container, themeStyle);
4603
+ (0, import_core19._applyStyles)(container, themeStyle);
2496
4604
  const label = this.themeMode === "dark" ? this.props.darkModeLabel : this.props.lightModeLabel;
2497
- import_core16.log.log(1, `Switched theme to ${label}`, themeStyle)();
4605
+ import_core19.log.log(1, `Switched theme to ${label}`, themeStyle)();
2498
4606
  this.updateHTML();
2499
4607
  }
2500
4608
  }
2501
4609
  /** Read browser preference */
2502
4610
  _getInitialThemeMode() {
2503
4611
  const { initialThemeMode } = this.props;
2504
- return initialThemeMode === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : initialThemeMode;
4612
+ if (initialThemeMode !== "auto") {
4613
+ return initialThemeMode;
4614
+ }
4615
+ if (typeof window === "undefined") {
4616
+ return "light";
4617
+ }
4618
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
2505
4619
  }
2506
4620
  };
2507
4621
  ThemeWidget.defaultProps = {
2508
- ...import_core17.Widget.defaultProps,
4622
+ ...import_core20.Widget.defaultProps,
2509
4623
  id: "theme",
2510
4624
  placement: "top-left",
2511
4625
  viewId: null,
@@ -2517,8 +4631,8 @@ var __exports__ = (() => {
2517
4631
  };
2518
4632
 
2519
4633
  // src/loading-widget.tsx
2520
- var import_core18 = __toESM(require_core(), 1);
2521
- var LoadingWidget = class extends import_core18.Widget {
4634
+ var import_core21 = __toESM(require_core(), 1);
4635
+ var LoadingWidget = class extends import_core21.Widget {
2522
4636
  constructor(props = {}) {
2523
4637
  super(props);
2524
4638
  this.className = "deck-widget-loading";
@@ -2557,7 +4671,7 @@ var __exports__ = (() => {
2557
4671
  }
2558
4672
  };
2559
4673
  LoadingWidget.defaultProps = {
2560
- ...import_core18.Widget.defaultProps,
4674
+ ...import_core21.Widget.defaultProps,
2561
4675
  id: "loading",
2562
4676
  placement: "top-left",
2563
4677
  viewId: null,
@@ -2565,8 +4679,8 @@ var __exports__ = (() => {
2565
4679
  };
2566
4680
 
2567
4681
  // src/fps-widget.tsx
2568
- var import_core19 = __toESM(require_core(), 1);
2569
- var FpsWidget = class extends import_core19.Widget {
4682
+ var import_core22 = __toESM(require_core(), 1);
4683
+ var FpsWidget = class extends import_core22.Widget {
2570
4684
  constructor(props = {}) {
2571
4685
  super(props);
2572
4686
  this.className = "deck-widget-fps";
@@ -2607,17 +4721,15 @@ var __exports__ = (() => {
2607
4721
  }
2608
4722
  };
2609
4723
  FpsWidget.defaultProps = {
2610
- ...import_core19.Widget.defaultProps,
4724
+ ...import_core22.Widget.defaultProps,
2611
4725
  id: "fps",
2612
4726
  placement: "top-left",
2613
4727
  viewId: null
2614
4728
  };
2615
4729
 
2616
4730
  // src/stats-widget.tsx
2617
- var import_core20 = __toESM(require_core(), 1);
2618
- var import_core21 = __toESM(require_core2(), 1);
2619
- var RIGHT_ARROW = "\u25B6";
2620
- var DOWN_ARROW = "\u2B07";
4731
+ var import_core23 = __toESM(require_core(), 1);
4732
+ var import_core24 = __toESM(require_core2(), 1);
2621
4733
  var DEFAULT_COUNT_FORMATTER = (stat) => `${stat.name}: ${stat.count}`;
2622
4734
  function formatTime(time) {
2623
4735
  return time < 1e3 ? `${time.toFixed(2)}ms` : `${(time / 1e3).toFixed(2)}s`;
@@ -2633,7 +4745,7 @@ var __exports__ = (() => {
2633
4745
  fps: (stat) => `${stat.name}: ${Math.round(stat.getHz())}fps`,
2634
4746
  memory: (stat) => `${stat.name}: ${formatMemory(stat.count)}`
2635
4747
  };
2636
- var StatsWidget = class extends import_core20.Widget {
4748
+ var StatsWidget = class extends import_core23.Widget {
2637
4749
  constructor(props = {}) {
2638
4750
  super(props);
2639
4751
  this.className = "deck-widget-stats";
@@ -2646,6 +4758,7 @@ var __exports__ = (() => {
2646
4758
  };
2647
4759
  this._formatters = { ...DEFAULT_FORMATTERS };
2648
4760
  this._resetOnUpdate = { ...this.props.resetOnUpdate };
4761
+ this.collapsed = !props.defaultIsExpanded;
2649
4762
  this.setProps(props);
2650
4763
  }
2651
4764
  setProps(props) {
@@ -2692,9 +4805,8 @@ var __exports__ = (() => {
2692
4805
  style: { cursor: "pointer", pointerEvents: "auto" },
2693
4806
  onClick: this._toggleCollapsed,
2694
4807
  children: [
2695
- collapsed ? RIGHT_ARROW : DOWN_ARROW,
2696
- " ",
2697
- title
4808
+ /* @__PURE__ */ u2("b", { children: title }),
4809
+ /* @__PURE__ */ u2("button", { className: "deck-widget-dropdown-button", children: /* @__PURE__ */ u2("span", { className: `deck-widget-dropdown-icon ${collapsed ? "" : "open"}` }) })
2698
4810
  ]
2699
4811
  }
2700
4812
  ),
@@ -2715,7 +4827,7 @@ var __exports__ = (() => {
2715
4827
  const metrics = this.deck?.metrics ?? {};
2716
4828
  return Object.entries(metrics);
2717
4829
  case "luma":
2718
- return Array.from(import_core21.luma.stats.stats.values())[0];
4830
+ return Array.from(import_core24.luma.stats.stats.values())[0];
2719
4831
  case "device":
2720
4832
  const device = this.deck?.device;
2721
4833
  const stats = device?.statsManager.stats.values();
@@ -2737,10 +4849,11 @@ var __exports__ = (() => {
2737
4849
  }
2738
4850
  };
2739
4851
  StatsWidget.defaultProps = {
2740
- ...import_core20.Widget.defaultProps,
4852
+ ...import_core23.Widget.defaultProps,
2741
4853
  type: "deck",
2742
4854
  placement: "top-left",
2743
4855
  viewId: null,
4856
+ defaultIsExpanded: false,
2744
4857
  stats: void 0,
2745
4858
  title: "Stats",
2746
4859
  framesPerUpdate: 1,