@grafana/scenes 5.11.0 → 5.11.1--canary.830.10618954979.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -14,6 +14,9 @@ var ui = require('@grafana/ui');
14
14
  var e2eSelectors = require('@grafana/e2e-selectors');
15
15
  var css = require('@emotion/css');
16
16
  var uFuzzy = require('@leeoniya/ufuzzy');
17
+ var reactDom = require('react-dom');
18
+ var react = require('@floating-ui/react');
19
+ var reactVirtual = require('@tanstack/react-virtual');
17
20
  var reactUse = require('react-use');
18
21
  var operators = require('rxjs/operators');
19
22
  var ReactGridLayout = require('react-grid-layout');
@@ -39,19 +42,19 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
39
42
  var uFuzzy__default = /*#__PURE__*/_interopDefaultLegacy(uFuzzy);
40
43
  var ReactGridLayout__default = /*#__PURE__*/_interopDefaultLegacy(ReactGridLayout);
41
44
 
42
- var __defProp$L = Object.defineProperty;
43
- var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
44
- var __hasOwnProp$L = Object.prototype.hasOwnProperty;
45
- var __propIsEnum$L = Object.prototype.propertyIsEnumerable;
46
- var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
47
- var __spreadValues$L = (a, b) => {
45
+ var __defProp$O = Object.defineProperty;
46
+ var __getOwnPropSymbols$O = Object.getOwnPropertySymbols;
47
+ var __hasOwnProp$O = Object.prototype.hasOwnProperty;
48
+ var __propIsEnum$O = Object.prototype.propertyIsEnumerable;
49
+ var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
50
+ var __spreadValues$O = (a, b) => {
48
51
  for (var prop in b || (b = {}))
49
- if (__hasOwnProp$L.call(b, prop))
50
- __defNormalProp$L(a, prop, b[prop]);
51
- if (__getOwnPropSymbols$L)
52
- for (var prop of __getOwnPropSymbols$L(b)) {
53
- if (__propIsEnum$L.call(b, prop))
54
- __defNormalProp$L(a, prop, b[prop]);
52
+ if (__hasOwnProp$O.call(b, prop))
53
+ __defNormalProp$O(a, prop, b[prop]);
54
+ if (__getOwnPropSymbols$O)
55
+ for (var prop of __getOwnPropSymbols$O(b)) {
56
+ if (__propIsEnum$O.call(b, prop))
57
+ __defNormalProp$O(a, prop, b[prop]);
55
58
  }
56
59
  return a;
57
60
  };
@@ -60,7 +63,7 @@ function useAppQueryParams() {
60
63
  return runtime.locationSearchToObject(location.search || "");
61
64
  }
62
65
  function getUrlWithAppState(path, preserveParams) {
63
- const paramsCopy = __spreadValues$L({}, runtime.locationService.getSearchObject());
66
+ const paramsCopy = __spreadValues$O({}, runtime.locationService.getSearchObject());
64
67
  if (preserveParams) {
65
68
  for (const key of Object.keys(paramsCopy)) {
66
69
  if (!preserveParams.includes(key)) {
@@ -74,31 +77,31 @@ function renderSceneComponentWithRouteProps(sceneObject, routeProps) {
74
77
  return React__default["default"].createElement(sceneObject.Component, { model: sceneObject, routeProps });
75
78
  }
76
79
 
77
- var __defProp$K = Object.defineProperty;
78
- var __defProps$s = Object.defineProperties;
79
- var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
80
- var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
81
- var __hasOwnProp$K = Object.prototype.hasOwnProperty;
82
- var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
83
- var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
84
- var __spreadValues$K = (a, b) => {
80
+ var __defProp$N = Object.defineProperty;
81
+ var __defProps$u = Object.defineProperties;
82
+ var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
83
+ var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
84
+ var __hasOwnProp$N = Object.prototype.hasOwnProperty;
85
+ var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
86
+ var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
87
+ var __spreadValues$N = (a, b) => {
85
88
  for (var prop in b || (b = {}))
86
- if (__hasOwnProp$K.call(b, prop))
87
- __defNormalProp$K(a, prop, b[prop]);
88
- if (__getOwnPropSymbols$K)
89
- for (var prop of __getOwnPropSymbols$K(b)) {
90
- if (__propIsEnum$K.call(b, prop))
91
- __defNormalProp$K(a, prop, b[prop]);
89
+ if (__hasOwnProp$N.call(b, prop))
90
+ __defNormalProp$N(a, prop, b[prop]);
91
+ if (__getOwnPropSymbols$N)
92
+ for (var prop of __getOwnPropSymbols$N(b)) {
93
+ if (__propIsEnum$N.call(b, prop))
94
+ __defNormalProp$N(a, prop, b[prop]);
92
95
  }
93
96
  return a;
94
97
  };
95
- var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
98
+ var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
96
99
  const runtimePanelPlugins = /* @__PURE__ */ new Map();
97
100
  function registerRuntimePanelPlugin({ pluginId, plugin }) {
98
101
  if (runtimePanelPlugins.has(pluginId)) {
99
102
  throw new Error(`A runtime panel plugin with id ${pluginId} has already been registered`);
100
103
  }
101
- plugin.meta = __spreadProps$s(__spreadValues$K({}, plugin.meta), {
104
+ plugin.meta = __spreadProps$u(__spreadValues$N({}, plugin.meta), {
102
105
  id: pluginId,
103
106
  name: pluginId,
104
107
  module: "runtime plugin",
@@ -126,39 +129,39 @@ function loadPanelPluginSync(pluginId) {
126
129
  return (_a = getPanelPluginFromCache(pluginId)) != null ? _a : runtimePanelPlugins.get(pluginId);
127
130
  }
128
131
 
129
- var __defProp$J = Object.defineProperty;
130
- var __defProps$r = Object.defineProperties;
131
- var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
132
- var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
133
- var __hasOwnProp$J = Object.prototype.hasOwnProperty;
134
- var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
135
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
136
- var __spreadValues$J = (a, b) => {
132
+ var __defProp$M = Object.defineProperty;
133
+ var __defProps$t = Object.defineProperties;
134
+ var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
135
+ var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
136
+ var __hasOwnProp$M = Object.prototype.hasOwnProperty;
137
+ var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
138
+ var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
139
+ var __spreadValues$M = (a, b) => {
137
140
  for (var prop in b || (b = {}))
138
- if (__hasOwnProp$J.call(b, prop))
139
- __defNormalProp$J(a, prop, b[prop]);
140
- if (__getOwnPropSymbols$J)
141
- for (var prop of __getOwnPropSymbols$J(b)) {
142
- if (__propIsEnum$J.call(b, prop))
143
- __defNormalProp$J(a, prop, b[prop]);
141
+ if (__hasOwnProp$M.call(b, prop))
142
+ __defNormalProp$M(a, prop, b[prop]);
143
+ if (__getOwnPropSymbols$M)
144
+ for (var prop of __getOwnPropSymbols$M(b)) {
145
+ if (__propIsEnum$M.call(b, prop))
146
+ __defNormalProp$M(a, prop, b[prop]);
144
147
  }
145
148
  return a;
146
149
  };
147
- var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
148
- var __objRest$4 = (source, exclude) => {
150
+ var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
151
+ var __objRest$5 = (source, exclude) => {
149
152
  var target = {};
150
153
  for (var prop in source)
151
- if (__hasOwnProp$J.call(source, prop) && exclude.indexOf(prop) < 0)
154
+ if (__hasOwnProp$M.call(source, prop) && exclude.indexOf(prop) < 0)
152
155
  target[prop] = source[prop];
153
- if (source != null && __getOwnPropSymbols$J)
154
- for (var prop of __getOwnPropSymbols$J(source)) {
155
- if (exclude.indexOf(prop) < 0 && __propIsEnum$J.call(source, prop))
156
+ if (source != null && __getOwnPropSymbols$M)
157
+ for (var prop of __getOwnPropSymbols$M(source)) {
158
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$M.call(source, prop))
156
159
  target[prop] = source[prop];
157
160
  }
158
161
  return target;
159
162
  };
160
163
  function SceneComponentWrapperWithoutMemo(_a) {
161
- var _b = _a, { model } = _b, otherProps = __objRest$4(_b, ["model"]);
164
+ var _b = _a, { model } = _b, otherProps = __objRest$5(_b, ["model"]);
162
165
  var _a2;
163
166
  const Component = (_a2 = model.constructor["Component"]) != null ? _a2 : EmptyRenderer;
164
167
  const [_, setValue] = React.useState(0);
@@ -170,7 +173,7 @@ function SceneComponentWrapperWithoutMemo(_a) {
170
173
  if (!model.isActive) {
171
174
  return null;
172
175
  }
173
- return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$r(__spreadValues$J({}, otherProps), {
176
+ return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$t(__spreadValues$M({}, otherProps), {
174
177
  model
175
178
  }));
176
179
  }
@@ -216,19 +219,19 @@ class SceneObjectRef {
216
219
  }
217
220
  _ref = new WeakMap();
218
221
 
219
- var __defProp$I = Object.defineProperty;
220
- var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
221
- var __hasOwnProp$I = Object.prototype.hasOwnProperty;
222
- var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
223
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
224
- var __spreadValues$I = (a, b) => {
222
+ var __defProp$L = Object.defineProperty;
223
+ var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
224
+ var __hasOwnProp$L = Object.prototype.hasOwnProperty;
225
+ var __propIsEnum$L = Object.prototype.propertyIsEnumerable;
226
+ var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
227
+ var __spreadValues$L = (a, b) => {
225
228
  for (var prop in b || (b = {}))
226
- if (__hasOwnProp$I.call(b, prop))
227
- __defNormalProp$I(a, prop, b[prop]);
228
- if (__getOwnPropSymbols$I)
229
- for (var prop of __getOwnPropSymbols$I(b)) {
230
- if (__propIsEnum$I.call(b, prop))
231
- __defNormalProp$I(a, prop, b[prop]);
229
+ if (__hasOwnProp$L.call(b, prop))
230
+ __defNormalProp$L(a, prop, b[prop]);
231
+ if (__getOwnPropSymbols$L)
232
+ for (var prop of __getOwnPropSymbols$L(b)) {
233
+ if (__propIsEnum$L.call(b, prop))
234
+ __defNormalProp$L(a, prop, b[prop]);
232
235
  }
233
236
  return a;
234
237
  };
@@ -288,7 +291,7 @@ class SceneObjectBase {
288
291
  }
289
292
  setState(update) {
290
293
  const prevState = this._state;
291
- const newState = __spreadValues$I(__spreadValues$I({}, this._state), update);
294
+ const newState = __spreadValues$L(__spreadValues$L({}, this._state), update);
292
295
  this._state = Object.freeze(newState);
293
296
  this._setParent(update);
294
297
  this._handleActivationOfChangedStateProps(prevState, newState);
@@ -484,19 +487,19 @@ function forEachChild(state, callback) {
484
487
  }
485
488
  }
486
489
 
487
- var __defProp$H = Object.defineProperty;
488
- var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
489
- var __hasOwnProp$H = Object.prototype.hasOwnProperty;
490
- var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
491
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
492
- var __spreadValues$H = (a, b) => {
490
+ var __defProp$K = Object.defineProperty;
491
+ var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
492
+ var __hasOwnProp$K = Object.prototype.hasOwnProperty;
493
+ var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
494
+ var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
495
+ var __spreadValues$K = (a, b) => {
493
496
  for (var prop in b || (b = {}))
494
- if (__hasOwnProp$H.call(b, prop))
495
- __defNormalProp$H(a, prop, b[prop]);
496
- if (__getOwnPropSymbols$H)
497
- for (var prop of __getOwnPropSymbols$H(b)) {
498
- if (__propIsEnum$H.call(b, prop))
499
- __defNormalProp$H(a, prop, b[prop]);
497
+ if (__hasOwnProp$K.call(b, prop))
498
+ __defNormalProp$K(a, prop, b[prop]);
499
+ if (__getOwnPropSymbols$K)
500
+ for (var prop of __getOwnPropSymbols$K(b)) {
501
+ if (__propIsEnum$K.call(b, prop))
502
+ __defNormalProp$K(a, prop, b[prop]);
500
503
  }
501
504
  return a;
502
505
  };
@@ -505,7 +508,7 @@ function cloneSceneObject(sceneObject, withState) {
505
508
  return new sceneObject.constructor(clonedState);
506
509
  }
507
510
  function cloneSceneObjectState(sceneState, withState) {
508
- const clonedState = __spreadValues$H({}, sceneState);
511
+ const clonedState = __spreadValues$K({}, sceneState);
509
512
  for (const key in clonedState) {
510
513
  const propValue = clonedState[key];
511
514
  if (propValue instanceof SceneObjectBase) {
@@ -602,25 +605,25 @@ function lookupVariable(name, sceneObject) {
602
605
  return null;
603
606
  }
604
607
 
605
- var __defProp$G = Object.defineProperty;
606
- var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
607
- var __hasOwnProp$G = Object.prototype.hasOwnProperty;
608
- var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
609
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
610
- var __spreadValues$G = (a, b) => {
608
+ var __defProp$J = Object.defineProperty;
609
+ var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
610
+ var __hasOwnProp$J = Object.prototype.hasOwnProperty;
611
+ var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
612
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
613
+ var __spreadValues$J = (a, b) => {
611
614
  for (var prop in b || (b = {}))
612
- if (__hasOwnProp$G.call(b, prop))
613
- __defNormalProp$G(a, prop, b[prop]);
614
- if (__getOwnPropSymbols$G)
615
- for (var prop of __getOwnPropSymbols$G(b)) {
616
- if (__propIsEnum$G.call(b, prop))
617
- __defNormalProp$G(a, prop, b[prop]);
615
+ if (__hasOwnProp$J.call(b, prop))
616
+ __defNormalProp$J(a, prop, b[prop]);
617
+ if (__getOwnPropSymbols$J)
618
+ for (var prop of __getOwnPropSymbols$J(b)) {
619
+ if (__propIsEnum$J.call(b, prop))
620
+ __defNormalProp$J(a, prop, b[prop]);
618
621
  }
619
622
  return a;
620
623
  };
621
624
  class SceneDataNode extends SceneObjectBase {
622
625
  constructor(state) {
623
- super(__spreadValues$G({
626
+ super(__spreadValues$J({
624
627
  data: emptyPanelData
625
628
  }, state));
626
629
  }
@@ -701,19 +704,19 @@ function evaluateTimeRange(from, to, timeZone, fiscalYearStartMonth, delay) {
701
704
  };
702
705
  }
703
706
 
704
- var __defProp$F = Object.defineProperty;
705
- var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
706
- var __hasOwnProp$F = Object.prototype.hasOwnProperty;
707
- var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
708
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
709
- var __spreadValues$F = (a, b) => {
707
+ var __defProp$I = Object.defineProperty;
708
+ var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
709
+ var __hasOwnProp$I = Object.prototype.hasOwnProperty;
710
+ var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
711
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
712
+ var __spreadValues$I = (a, b) => {
710
713
  for (var prop in b || (b = {}))
711
- if (__hasOwnProp$F.call(b, prop))
712
- __defNormalProp$F(a, prop, b[prop]);
713
- if (__getOwnPropSymbols$F)
714
- for (var prop of __getOwnPropSymbols$F(b)) {
715
- if (__propIsEnum$F.call(b, prop))
716
- __defNormalProp$F(a, prop, b[prop]);
714
+ if (__hasOwnProp$I.call(b, prop))
715
+ __defNormalProp$I(a, prop, b[prop]);
716
+ if (__getOwnPropSymbols$I)
717
+ for (var prop of __getOwnPropSymbols$I(b)) {
718
+ if (__propIsEnum$I.call(b, prop))
719
+ __defNormalProp$I(a, prop, b[prop]);
717
720
  }
718
721
  return a;
719
722
  };
@@ -731,7 +734,7 @@ class SceneTimeRange extends SceneObjectBase {
731
734
  state.UNSAFE_nowDelay
732
735
  );
733
736
  const refreshOnActivate = (_c = state.refreshOnActivate) != null ? _c : { percent: 10 };
734
- super(__spreadValues$F({ from, to, timeZone, value, refreshOnActivate }, state));
737
+ super(__spreadValues$I({ from, to, timeZone, value, refreshOnActivate }, state));
735
738
  this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["from", "to", "timezone"] });
736
739
  this.onTimeRangeChange = (timeRange) => {
737
740
  const update = {};
@@ -1398,25 +1401,25 @@ function collectAllVariables(sceneObject, record = {}) {
1398
1401
  return record;
1399
1402
  }
1400
1403
 
1401
- var __defProp$E = Object.defineProperty;
1402
- var __defProps$q = Object.defineProperties;
1403
- var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
1404
- var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
1405
- var __hasOwnProp$E = Object.prototype.hasOwnProperty;
1406
- var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
1407
- var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1408
- var __spreadValues$E = (a, b) => {
1404
+ var __defProp$H = Object.defineProperty;
1405
+ var __defProps$s = Object.defineProperties;
1406
+ var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
1407
+ var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
1408
+ var __hasOwnProp$H = Object.prototype.hasOwnProperty;
1409
+ var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
1410
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1411
+ var __spreadValues$H = (a, b) => {
1409
1412
  for (var prop in b || (b = {}))
1410
- if (__hasOwnProp$E.call(b, prop))
1411
- __defNormalProp$E(a, prop, b[prop]);
1412
- if (__getOwnPropSymbols$E)
1413
- for (var prop of __getOwnPropSymbols$E(b)) {
1414
- if (__propIsEnum$E.call(b, prop))
1415
- __defNormalProp$E(a, prop, b[prop]);
1413
+ if (__hasOwnProp$H.call(b, prop))
1414
+ __defNormalProp$H(a, prop, b[prop]);
1415
+ if (__getOwnPropSymbols$H)
1416
+ for (var prop of __getOwnPropSymbols$H(b)) {
1417
+ if (__propIsEnum$H.call(b, prop))
1418
+ __defNormalProp$H(a, prop, b[prop]);
1416
1419
  }
1417
1420
  return a;
1418
1421
  };
1419
- var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
1422
+ var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
1420
1423
  function getTemplateProxyForField(field, frame, frames) {
1421
1424
  return new Proxy(
1422
1425
  {},
@@ -1432,7 +1435,7 @@ function getTemplateProxyForField(field, frame, frames) {
1432
1435
  if (!field.labels) {
1433
1436
  return "";
1434
1437
  }
1435
- return __spreadProps$q(__spreadValues$E({}, field.labels), {
1438
+ return __spreadProps$s(__spreadValues$H({}, field.labels), {
1436
1439
  __values: Object.values(field.labels).sort().join(", "),
1437
1440
  toString: () => {
1438
1441
  return data.formatLabels(field.labels, "", true);
@@ -1929,25 +1932,25 @@ function isExtraQueryProvider(obj) {
1929
1932
  return typeof obj === "object" && "getExtraQueries" in obj;
1930
1933
  }
1931
1934
 
1932
- var __defProp$D = Object.defineProperty;
1933
- var __defProps$p = Object.defineProperties;
1934
- var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
1935
- var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
1936
- var __hasOwnProp$D = Object.prototype.hasOwnProperty;
1937
- var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
1938
- var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1939
- var __spreadValues$D = (a, b) => {
1935
+ var __defProp$G = Object.defineProperty;
1936
+ var __defProps$r = Object.defineProperties;
1937
+ var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
1938
+ var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
1939
+ var __hasOwnProp$G = Object.prototype.hasOwnProperty;
1940
+ var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
1941
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1942
+ var __spreadValues$G = (a, b) => {
1940
1943
  for (var prop in b || (b = {}))
1941
- if (__hasOwnProp$D.call(b, prop))
1942
- __defNormalProp$D(a, prop, b[prop]);
1943
- if (__getOwnPropSymbols$D)
1944
- for (var prop of __getOwnPropSymbols$D(b)) {
1945
- if (__propIsEnum$D.call(b, prop))
1946
- __defNormalProp$D(a, prop, b[prop]);
1944
+ if (__hasOwnProp$G.call(b, prop))
1945
+ __defNormalProp$G(a, prop, b[prop]);
1946
+ if (__getOwnPropSymbols$G)
1947
+ for (var prop of __getOwnPropSymbols$G(b)) {
1948
+ if (__propIsEnum$G.call(b, prop))
1949
+ __defNormalProp$G(a, prop, b[prop]);
1947
1950
  }
1948
1951
  return a;
1949
1952
  };
1950
- var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
1953
+ var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
1951
1954
  const passthroughProcessor = (_, secondary) => rxjs.of(secondary);
1952
1955
  const extraQueryProcessingOperator = (processors) => (data) => {
1953
1956
  return data.pipe(
@@ -1960,7 +1963,7 @@ const extraQueryProcessingOperator = (processors) => (data) => {
1960
1963
  }),
1961
1964
  rxjs.map(([primary, ...processedSecondaries]) => {
1962
1965
  var _a;
1963
- return __spreadProps$p(__spreadValues$D({}, primary), {
1966
+ return __spreadProps$r(__spreadValues$G({}, primary), {
1964
1967
  series: [...primary.series, ...processedSecondaries.flatMap((s) => s.series)],
1965
1968
  annotations: [...(_a = primary.annotations) != null ? _a : [], ...processedSecondaries.flatMap((s) => {
1966
1969
  var _a2;
@@ -1971,25 +1974,25 @@ const extraQueryProcessingOperator = (processors) => (data) => {
1971
1974
  );
1972
1975
  };
1973
1976
 
1974
- var __defProp$C = Object.defineProperty;
1975
- var __defProps$o = Object.defineProperties;
1976
- var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
1977
- var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
1978
- var __hasOwnProp$C = Object.prototype.hasOwnProperty;
1979
- var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
1980
- var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1981
- var __spreadValues$C = (a, b) => {
1977
+ var __defProp$F = Object.defineProperty;
1978
+ var __defProps$q = Object.defineProperties;
1979
+ var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
1980
+ var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
1981
+ var __hasOwnProp$F = Object.prototype.hasOwnProperty;
1982
+ var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
1983
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1984
+ var __spreadValues$F = (a, b) => {
1982
1985
  for (var prop in b || (b = {}))
1983
- if (__hasOwnProp$C.call(b, prop))
1984
- __defNormalProp$C(a, prop, b[prop]);
1985
- if (__getOwnPropSymbols$C)
1986
- for (var prop of __getOwnPropSymbols$C(b)) {
1987
- if (__propIsEnum$C.call(b, prop))
1988
- __defNormalProp$C(a, prop, b[prop]);
1986
+ if (__hasOwnProp$F.call(b, prop))
1987
+ __defNormalProp$F(a, prop, b[prop]);
1988
+ if (__getOwnPropSymbols$F)
1989
+ for (var prop of __getOwnPropSymbols$F(b)) {
1990
+ if (__propIsEnum$F.call(b, prop))
1991
+ __defNormalProp$F(a, prop, b[prop]);
1989
1992
  }
1990
1993
  return a;
1991
1994
  };
1992
- var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
1995
+ var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
1993
1996
  function filterAnnotations(data, filters) {
1994
1997
  var _a;
1995
1998
  if (!Array.isArray(data) || data.length === 0) {
@@ -2040,11 +2043,11 @@ function filterAnnotations(data, filters) {
2040
2043
  continue;
2041
2044
  }
2042
2045
  }
2043
- fields.push(__spreadProps$o(__spreadValues$C({}, field), {
2046
+ fields.push(__spreadProps$q(__spreadValues$F({}, field), {
2044
2047
  values: buffer
2045
2048
  }));
2046
2049
  }
2047
- processed.push(__spreadProps$o(__spreadValues$C({}, frame), {
2050
+ processed.push(__spreadProps$q(__spreadValues$F({}, frame), {
2048
2051
  fields,
2049
2052
  length: frameLength
2050
2053
  }));
@@ -2475,33 +2478,33 @@ function getOptionSearcher(options, includeAll) {
2475
2478
  };
2476
2479
  }
2477
2480
 
2478
- var __defProp$B = Object.defineProperty;
2479
- var __defProps$n = Object.defineProperties;
2480
- var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
2481
- var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
2482
- var __hasOwnProp$B = Object.prototype.hasOwnProperty;
2483
- var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
2484
- var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2485
- var __spreadValues$B = (a, b) => {
2481
+ var __defProp$E = Object.defineProperty;
2482
+ var __defProps$p = Object.defineProperties;
2483
+ var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
2484
+ var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
2485
+ var __hasOwnProp$E = Object.prototype.hasOwnProperty;
2486
+ var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
2487
+ var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2488
+ var __spreadValues$E = (a, b) => {
2486
2489
  for (var prop in b || (b = {}))
2487
- if (__hasOwnProp$B.call(b, prop))
2488
- __defNormalProp$B(a, prop, b[prop]);
2489
- if (__getOwnPropSymbols$B)
2490
- for (var prop of __getOwnPropSymbols$B(b)) {
2491
- if (__propIsEnum$B.call(b, prop))
2492
- __defNormalProp$B(a, prop, b[prop]);
2493
- }
2494
- return a;
2495
- };
2496
- var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
2497
- var __objRest$3 = (source, exclude) => {
2490
+ if (__hasOwnProp$E.call(b, prop))
2491
+ __defNormalProp$E(a, prop, b[prop]);
2492
+ if (__getOwnPropSymbols$E)
2493
+ for (var prop of __getOwnPropSymbols$E(b)) {
2494
+ if (__propIsEnum$E.call(b, prop))
2495
+ __defNormalProp$E(a, prop, b[prop]);
2496
+ }
2497
+ return a;
2498
+ };
2499
+ var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
2500
+ var __objRest$4 = (source, exclude) => {
2498
2501
  var target = {};
2499
2502
  for (var prop in source)
2500
- if (__hasOwnProp$B.call(source, prop) && exclude.indexOf(prop) < 0)
2503
+ if (__hasOwnProp$E.call(source, prop) && exclude.indexOf(prop) < 0)
2501
2504
  target[prop] = source[prop];
2502
- if (source != null && __getOwnPropSymbols$B)
2503
- for (var prop of __getOwnPropSymbols$B(source)) {
2504
- if (exclude.indexOf(prop) < 0 && __propIsEnum$B.call(source, prop))
2505
+ if (source != null && __getOwnPropSymbols$E)
2506
+ for (var prop of __getOwnPropSymbols$E(source)) {
2507
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$E.call(source, prop))
2505
2508
  target[prop] = source[prop];
2506
2509
  }
2507
2510
  return target;
@@ -2629,11 +2632,11 @@ const OptionWithCheckbox = ({
2629
2632
  renderOptionLabel
2630
2633
  }) => {
2631
2634
  var _b;
2632
- const _a = innerProps, rest = __objRest$3(_a, ["onMouseMove", "onMouseOver"]);
2635
+ const _a = innerProps, rest = __objRest$4(_a, ["onMouseMove", "onMouseOver"]);
2633
2636
  const theme = ui.useTheme2();
2634
2637
  const selectStyles = ui.getSelectStyles(theme);
2635
2638
  const optionStyles = ui.useStyles2(getOptionStyles);
2636
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$n(__spreadValues$B({
2639
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$p(__spreadValues$E({
2637
2640
  ref: innerRef,
2638
2641
  className: css.cx(selectStyles.option, isFocused && selectStyles.optionFocused)
2639
2642
  }, rest), {
@@ -2797,28 +2800,28 @@ function wrapInSafeSerializableSceneObject(sceneObject) {
2797
2800
  return { value: sceneObject, text: "__sceneObject" };
2798
2801
  }
2799
2802
 
2800
- var __defProp$A = Object.defineProperty;
2801
- var __defProps$m = Object.defineProperties;
2802
- var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
2803
- var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
2804
- var __hasOwnProp$A = Object.prototype.hasOwnProperty;
2805
- var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
2806
- var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2807
- var __spreadValues$A = (a, b) => {
2803
+ var __defProp$D = Object.defineProperty;
2804
+ var __defProps$o = Object.defineProperties;
2805
+ var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
2806
+ var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
2807
+ var __hasOwnProp$D = Object.prototype.hasOwnProperty;
2808
+ var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
2809
+ var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2810
+ var __spreadValues$D = (a, b) => {
2808
2811
  for (var prop in b || (b = {}))
2809
- if (__hasOwnProp$A.call(b, prop))
2810
- __defNormalProp$A(a, prop, b[prop]);
2811
- if (__getOwnPropSymbols$A)
2812
- for (var prop of __getOwnPropSymbols$A(b)) {
2813
- if (__propIsEnum$A.call(b, prop))
2814
- __defNormalProp$A(a, prop, b[prop]);
2812
+ if (__hasOwnProp$D.call(b, prop))
2813
+ __defNormalProp$D(a, prop, b[prop]);
2814
+ if (__getOwnPropSymbols$D)
2815
+ for (var prop of __getOwnPropSymbols$D(b)) {
2816
+ if (__propIsEnum$D.call(b, prop))
2817
+ __defNormalProp$D(a, prop, b[prop]);
2815
2818
  }
2816
2819
  return a;
2817
2820
  };
2818
- var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
2821
+ var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
2819
2822
  class GroupByVariable extends MultiValueVariable {
2820
2823
  constructor(initialState) {
2821
- super(__spreadProps$m(__spreadValues$A({
2824
+ super(__spreadProps$o(__spreadValues$D({
2822
2825
  isMulti: true,
2823
2826
  name: "",
2824
2827
  value: [],
@@ -2849,7 +2852,7 @@ class GroupByVariable extends MultiValueVariable {
2849
2852
  const queries = getQueriesForVariables(this);
2850
2853
  const otherFilters = this.state.baseFilters || [];
2851
2854
  const timeRange = sceneGraph.getTimeRange(this).state.value;
2852
- const response = await ds.getTagKeys(__spreadValues$A({
2855
+ const response = await ds.getTagKeys(__spreadValues$D({
2853
2856
  filters: otherFilters,
2854
2857
  queries,
2855
2858
  timeRange
@@ -3044,7 +3047,7 @@ function LoadingIndicator(props) {
3044
3047
  }
3045
3048
 
3046
3049
  function ControlsLabel(props) {
3047
- const styles = ui.useStyles2(getStyles$a);
3050
+ const styles = ui.useStyles2(getStyles$e);
3048
3051
  const theme = ui.useTheme2();
3049
3052
  const isVertical = props.layout === "vertical";
3050
3053
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -3107,7 +3110,7 @@ function ControlsLabel(props) {
3107
3110
  }
3108
3111
  return labelElement;
3109
3112
  }
3110
- const getStyles$a = (theme) => ({
3113
+ const getStyles$e = (theme) => ({
3111
3114
  horizontalLabel: css.css({
3112
3115
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
3113
3116
  display: `flex`,
@@ -3178,19 +3181,19 @@ function getAdhocOptionSearcher(options) {
3178
3181
  };
3179
3182
  }
3180
3183
 
3181
- var __defProp$z = Object.defineProperty;
3182
- var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
3183
- var __hasOwnProp$z = Object.prototype.hasOwnProperty;
3184
- var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
3185
- var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3186
- var __spreadValues$z = (a, b) => {
3184
+ var __defProp$C = Object.defineProperty;
3185
+ var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
3186
+ var __hasOwnProp$C = Object.prototype.hasOwnProperty;
3187
+ var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
3188
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3189
+ var __spreadValues$C = (a, b) => {
3187
3190
  for (var prop in b || (b = {}))
3188
- if (__hasOwnProp$z.call(b, prop))
3189
- __defNormalProp$z(a, prop, b[prop]);
3190
- if (__getOwnPropSymbols$z)
3191
- for (var prop of __getOwnPropSymbols$z(b)) {
3192
- if (__propIsEnum$z.call(b, prop))
3193
- __defNormalProp$z(a, prop, b[prop]);
3191
+ if (__hasOwnProp$C.call(b, prop))
3192
+ __defNormalProp$C(a, prop, b[prop]);
3193
+ if (__getOwnPropSymbols$C)
3194
+ for (var prop of __getOwnPropSymbols$C(b)) {
3195
+ if (__propIsEnum$C.call(b, prop))
3196
+ __defNormalProp$C(a, prop, b[prop]);
3194
3197
  }
3195
3198
  return a;
3196
3199
  };
@@ -3203,7 +3206,7 @@ function keyLabelToOption(key, label) {
3203
3206
  const filterNoOp = () => true;
3204
3207
  function AdHocFilterRenderer({ filter, model }) {
3205
3208
  var _a, _b, _c;
3206
- const styles = ui.useStyles2(getStyles$9);
3209
+ const styles = ui.useStyles2(getStyles$d);
3207
3210
  const [keys, setKeys] = React.useState([]);
3208
3211
  const [values, setValues] = React.useState([]);
3209
3212
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
@@ -3274,7 +3277,7 @@ function AdHocFilterRenderer({ filter, model }) {
3274
3277
  });
3275
3278
  }
3276
3279
  };
3277
- const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, __spreadValues$z({
3280
+ const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, __spreadValues$C({
3278
3281
  virtualized: true,
3279
3282
  allowCustomValue: true,
3280
3283
  isValidNewOption: (inputValue) => inputValue.trim().length > 0,
@@ -3406,7 +3409,7 @@ function AdHocFilterRenderer({ filter, model }) {
3406
3409
  onClick: () => model._removeFilter(filter)
3407
3410
  }));
3408
3411
  }
3409
- const getStyles$9 = (theme) => ({
3412
+ const getStyles$d = (theme) => ({
3410
3413
  field: css.css({
3411
3414
  marginBottom: 0
3412
3415
  }),
@@ -3558,6 +3561,812 @@ function isFilter(filter) {
3558
3561
  return filter !== null && typeof filter.key === "string" && typeof filter.value === "string";
3559
3562
  }
3560
3563
 
3564
+ var __defProp$B = Object.defineProperty;
3565
+ var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
3566
+ var __hasOwnProp$B = Object.prototype.hasOwnProperty;
3567
+ var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
3568
+ var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3569
+ var __spreadValues$B = (a, b) => {
3570
+ for (var prop in b || (b = {}))
3571
+ if (__hasOwnProp$B.call(b, prop))
3572
+ __defNormalProp$B(a, prop, b[prop]);
3573
+ if (__getOwnPropSymbols$B)
3574
+ for (var prop of __getOwnPropSymbols$B(b)) {
3575
+ if (__propIsEnum$B.call(b, prop))
3576
+ __defNormalProp$B(a, prop, b[prop]);
3577
+ }
3578
+ return a;
3579
+ };
3580
+ var __objRest$3 = (source, exclude) => {
3581
+ var target = {};
3582
+ for (var prop in source)
3583
+ if (__hasOwnProp$B.call(source, prop) && exclude.indexOf(prop) < 0)
3584
+ target[prop] = source[prop];
3585
+ if (source != null && __getOwnPropSymbols$B)
3586
+ for (var prop of __getOwnPropSymbols$B(source)) {
3587
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$B.call(source, prop))
3588
+ target[prop] = source[prop];
3589
+ }
3590
+ return target;
3591
+ };
3592
+ const DropdownItem = React.forwardRef(
3593
+ function DropdownItem2(_a, ref) {
3594
+ var _b = _a, { children, active, addGroupBottomBorder } = _b, rest = __objRest$3(_b, ["children", "active", "addGroupBottomBorder"]);
3595
+ const styles = ui.useStyles2(getStyles$c);
3596
+ const id = React.useId();
3597
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$B({
3598
+ ref,
3599
+ role: "option",
3600
+ id,
3601
+ "aria-selected": active,
3602
+ className: css.cx(styles.option, active && styles.optionFocused, addGroupBottomBorder && styles.groupBottomBorder)
3603
+ }, rest), /* @__PURE__ */ React__default["default"].createElement("div", {
3604
+ className: styles.optionBody,
3605
+ "data-testid": `data-testid ad hoc filter option value ${children}`
3606
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, children)));
3607
+ }
3608
+ );
3609
+ const getStyles$c = (theme) => ({
3610
+ option: css.css({
3611
+ label: "grafana-select-option",
3612
+ top: 0,
3613
+ left: 0,
3614
+ width: "100%",
3615
+ position: "absolute",
3616
+ padding: theme.spacing(1),
3617
+ display: "flex",
3618
+ alignItems: "center",
3619
+ flexDirection: "row",
3620
+ flexShrink: 0,
3621
+ whiteSpace: "nowrap",
3622
+ cursor: "pointer",
3623
+ "&:hover": {
3624
+ background: theme.colors.action.hover,
3625
+ "@media (forced-colors: active), (prefers-contrast: more)": {
3626
+ border: `1px solid ${theme.colors.primary.border}`
3627
+ }
3628
+ }
3629
+ }),
3630
+ optionFocused: css.css({
3631
+ label: "grafana-select-option-focused",
3632
+ background: theme.colors.action.focus,
3633
+ "@media (forced-colors: active), (prefers-contrast: more)": {
3634
+ border: `1px solid ${theme.colors.primary.border}`
3635
+ }
3636
+ }),
3637
+ optionBody: css.css({
3638
+ label: "grafana-select-option-body",
3639
+ display: "flex",
3640
+ fontWeight: theme.typography.fontWeightMedium,
3641
+ flexDirection: "column",
3642
+ flexGrow: 1
3643
+ }),
3644
+ groupBottomBorder: css.css({
3645
+ borderBottom: `1px solid ${theme.colors.border.weak}`
3646
+ })
3647
+ });
3648
+ const LoadingOptionsPlaceholder = () => {
3649
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, null, "Loading options...");
3650
+ };
3651
+ const NoOptionsPlaceholder = () => {
3652
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, null, "No options found");
3653
+ };
3654
+ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
3655
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
3656
+ onClick: handleFetchOptions
3657
+ }, "An error has occurred fetching labels. Click to retry");
3658
+ };
3659
+
3660
+ const VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER = 8;
3661
+ const VIRTUAL_LIST_PADDING = 8;
3662
+ const VIRTUAL_LIST_OVERSCAN = 5;
3663
+ const VIRTUAL_LIST_ITEM_HEIGHT = 38;
3664
+ const ERROR_STATE_DROPDOWN_WIDTH = 366;
3665
+ function fuzzySearchOptions(options) {
3666
+ const ufuzzy = new uFuzzy__default["default"]();
3667
+ const haystack = [];
3668
+ const limit = 1e4;
3669
+ return (search, filterInputType) => {
3670
+ var _a;
3671
+ if (search === "") {
3672
+ if (options.length > limit) {
3673
+ return options.slice(0, limit);
3674
+ } else {
3675
+ return options;
3676
+ }
3677
+ }
3678
+ if (filterInputType === "operator") {
3679
+ const filteredOperators = [];
3680
+ for (let i = 0; i < options.length; i++) {
3681
+ if ((_a = options[i].label || options[i].value) == null ? void 0 : _a.includes(search)) {
3682
+ filteredOperators.push(options[i]);
3683
+ if (filteredOperators.length > limit) {
3684
+ return filteredOperators;
3685
+ }
3686
+ }
3687
+ }
3688
+ return filteredOperators;
3689
+ }
3690
+ if (haystack.length === 0) {
3691
+ for (let i = 0; i < options.length; i++) {
3692
+ haystack.push(options[i].label || options[i].value);
3693
+ }
3694
+ }
3695
+ const idxs = ufuzzy.filter(haystack, search);
3696
+ const filteredOptions = [];
3697
+ if (idxs) {
3698
+ for (let i = 0; i < idxs.length; i++) {
3699
+ filteredOptions.push(options[idxs[i]]);
3700
+ if (filteredOptions.length > limit) {
3701
+ return filteredOptions;
3702
+ }
3703
+ }
3704
+ return filteredOptions;
3705
+ }
3706
+ if (options.length > limit) {
3707
+ return options.slice(0, limit);
3708
+ }
3709
+ return options;
3710
+ };
3711
+ }
3712
+ const flattenOptionGroups = (options) => options.flatMap((option) => option.options ? [option, ...option.options] : [option]);
3713
+ const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
3714
+ var _a, _b, _c;
3715
+ let maxOptionWidth = 182;
3716
+ const listRefArr = [];
3717
+ const disabledIndices = [];
3718
+ for (let i = 0; i < options.length; i++) {
3719
+ listRefArr.push(null);
3720
+ if ((_a = options[i]) == null ? void 0 : _a.options) {
3721
+ disabledIndices.push(i);
3722
+ }
3723
+ let label = (_c = (_b = options[i].label) != null ? _b : options[i].value) != null ? _c : "";
3724
+ const widthEstimate = (options[i].isCustom ? label.length + 18 : label.length) * VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER + VIRTUAL_LIST_PADDING * 2;
3725
+ if (widthEstimate > maxOptionWidth) {
3726
+ maxOptionWidth = widthEstimate;
3727
+ }
3728
+ }
3729
+ listRef.current = [...listRefArr];
3730
+ disabledIndicesRef.current = [...disabledIndices];
3731
+ return maxOptionWidth;
3732
+ };
3733
+ const nextInputTypeMap = {
3734
+ key: "operator",
3735
+ operator: "value",
3736
+ value: "key"
3737
+ };
3738
+ const switchToNextInputType = (filterInputType, setInputType, handleChangeViewMode, element) => switchInputType(
3739
+ nextInputTypeMap[filterInputType],
3740
+ setInputType,
3741
+ filterInputType === "value" ? handleChangeViewMode : void 0,
3742
+ element
3743
+ );
3744
+ const switchInputType = (filterInputType, setInputType, handleChangeViewMode, element) => {
3745
+ setInputType(filterInputType);
3746
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3747
+ setTimeout(() => element == null ? void 0 : element.focus());
3748
+ };
3749
+ const generateFilterUpdatePayload = (filterInputType, item) => {
3750
+ if (filterInputType === "key") {
3751
+ return {
3752
+ key: item.value,
3753
+ keyLabel: item.label ? item.label : item.value
3754
+ };
3755
+ }
3756
+ if (filterInputType === "value") {
3757
+ return {
3758
+ value: item.value,
3759
+ valueLabels: [item.label ? item.label : item.value]
3760
+ };
3761
+ }
3762
+ return {
3763
+ [filterInputType]: item.value
3764
+ };
3765
+ };
3766
+
3767
+ const MAX_MENU_HEIGHT = 300;
3768
+ const useFloatingInteractions = ({
3769
+ open,
3770
+ onOpenChange,
3771
+ activeIndex,
3772
+ setActiveIndex,
3773
+ operatorIdentifier,
3774
+ listRef,
3775
+ disabledIndicesRef
3776
+ }) => {
3777
+ const { refs, floatingStyles, context } = react.useFloating({
3778
+ whileElementsMounted: react.autoUpdate,
3779
+ open,
3780
+ onOpenChange,
3781
+ placement: "bottom-start",
3782
+ middleware: [
3783
+ react.offset(10),
3784
+ react.flip({ padding: 10 }),
3785
+ react.size({
3786
+ apply({ availableHeight, availableWidth, elements }) {
3787
+ elements.floating.style.maxHeight = `${Math.min(MAX_MENU_HEIGHT, availableHeight)}px`;
3788
+ elements.floating.style.maxWidth = `${availableWidth}px`;
3789
+ },
3790
+ padding: 10
3791
+ })
3792
+ ]
3793
+ });
3794
+ const role = react.useRole(context, { role: "listbox" });
3795
+ const dismiss = react.useDismiss(context, {
3796
+ outsidePress: (event) => {
3797
+ if (event.currentTarget instanceof HTMLElement && event.currentTarget.id === operatorIdentifier) {
3798
+ return false;
3799
+ }
3800
+ return true;
3801
+ }
3802
+ });
3803
+ const listNav = react.useListNavigation(context, {
3804
+ listRef,
3805
+ activeIndex,
3806
+ onNavigate: setActiveIndex,
3807
+ virtual: true,
3808
+ loop: true,
3809
+ disabledIndices: disabledIndicesRef.current
3810
+ });
3811
+ const { getReferenceProps, getFloatingProps, getItemProps } = react.useInteractions([role, dismiss, listNav]);
3812
+ return {
3813
+ refs,
3814
+ floatingStyles,
3815
+ context,
3816
+ getReferenceProps,
3817
+ getFloatingProps,
3818
+ getItemProps
3819
+ };
3820
+ };
3821
+
3822
+ var __defProp$A = Object.defineProperty;
3823
+ var __defProps$n = Object.defineProperties;
3824
+ var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
3825
+ var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
3826
+ var __hasOwnProp$A = Object.prototype.hasOwnProperty;
3827
+ var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
3828
+ var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3829
+ var __spreadValues$A = (a, b) => {
3830
+ for (var prop in b || (b = {}))
3831
+ if (__hasOwnProp$A.call(b, prop))
3832
+ __defNormalProp$A(a, prop, b[prop]);
3833
+ if (__getOwnPropSymbols$A)
3834
+ for (var prop of __getOwnPropSymbols$A(b)) {
3835
+ if (__propIsEnum$A.call(b, prop))
3836
+ __defNormalProp$A(a, prop, b[prop]);
3837
+ }
3838
+ return a;
3839
+ };
3840
+ var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
3841
+ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode }, parentRef) {
3842
+ var _a, _b, _c;
3843
+ const [open, setOpen] = React.useState(false);
3844
+ const [options, setOptions] = React.useState([]);
3845
+ const [optionsLoading, setOptionsLoading] = React.useState(false);
3846
+ const [optionsError, setOptionsError] = React.useState(false);
3847
+ const [inputValue, setInputValue] = React.useState("");
3848
+ const [activeIndex, setActiveIndex] = React.useState(null);
3849
+ const [filterInputType, setInputType] = React.useState(!isAlwaysWip ? "value" : "key");
3850
+ const styles = ui.useStyles2(getStyles$b);
3851
+ const operatorIdentifier = React.useId();
3852
+ const listRef = React.useRef([]);
3853
+ const disabledIndicesRef = React.useRef([]);
3854
+ const optionsSearcher = React.useMemo(() => fuzzySearchOptions(options), [options]);
3855
+ const handleResetWip = React.useCallback(() => {
3856
+ if (isAlwaysWip) {
3857
+ model._addWip();
3858
+ setInputType("key");
3859
+ setInputValue("");
3860
+ }
3861
+ }, [model, isAlwaysWip]);
3862
+ const onOpenChange = React.useCallback(
3863
+ (nextOpen, _, reason) => {
3864
+ setOpen(nextOpen);
3865
+ if (reason && ["outside-press", "escape-key"].includes(reason)) {
3866
+ handleResetWip();
3867
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3868
+ }
3869
+ },
3870
+ [handleChangeViewMode, handleResetWip]
3871
+ );
3872
+ const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
3873
+ open,
3874
+ onOpenChange,
3875
+ activeIndex,
3876
+ setActiveIndex,
3877
+ operatorIdentifier,
3878
+ listRef,
3879
+ disabledIndicesRef
3880
+ });
3881
+ React.useImperativeHandle(parentRef, () => () => {
3882
+ var _a2;
3883
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3884
+ }, [refs.domReference]);
3885
+ function onChange(event) {
3886
+ const value = event.target.value;
3887
+ setInputValue(value);
3888
+ setActiveIndex(0);
3889
+ }
3890
+ const filteredDropDownItems = flattenOptionGroups(handleOptionGroups(optionsSearcher(inputValue, filterInputType)));
3891
+ if (filterInputType !== "operator" && inputValue) {
3892
+ filteredDropDownItems.push({
3893
+ value: inputValue.trim(),
3894
+ label: inputValue.trim(),
3895
+ isCustom: true
3896
+ });
3897
+ }
3898
+ const maxOptionWidth = setupDropdownAccessibility(filteredDropDownItems, listRef, disabledIndicesRef);
3899
+ const handleFetchOptions = React.useCallback(
3900
+ async (inputType) => {
3901
+ var _a2;
3902
+ setOptionsError(false);
3903
+ setOptionsLoading(true);
3904
+ setOptions([]);
3905
+ let options2 = [];
3906
+ try {
3907
+ if (inputType === "key") {
3908
+ options2 = await model._getKeys(null);
3909
+ } else if (inputType === "operator") {
3910
+ options2 = model._getOperators();
3911
+ } else if (inputType === "value") {
3912
+ options2 = await model._getValuesFor(filter);
3913
+ }
3914
+ setOptions(options2);
3915
+ if ((_a2 = options2[0]) == null ? void 0 : _a2.group) {
3916
+ setActiveIndex(1);
3917
+ }
3918
+ } catch (e) {
3919
+ setOptionsError(true);
3920
+ }
3921
+ setOptionsLoading(false);
3922
+ },
3923
+ [filter, model]
3924
+ );
3925
+ const rowVirtualizer = reactVirtual.useVirtualizer({
3926
+ count: filteredDropDownItems.length,
3927
+ getScrollElement: () => refs.floating.current,
3928
+ estimateSize: () => VIRTUAL_LIST_ITEM_HEIGHT,
3929
+ overscan: VIRTUAL_LIST_OVERSCAN
3930
+ });
3931
+ const handleBackspaceInput = React.useCallback(
3932
+ (event) => {
3933
+ if (event.key === "Backspace" && !inputValue && filterInputType === "key") {
3934
+ model._removeLastFilter();
3935
+ handleFetchOptions(filterInputType);
3936
+ }
3937
+ },
3938
+ [inputValue, filterInputType]
3939
+ );
3940
+ const handleTabInput = React.useCallback((event) => {
3941
+ if (event.key === "Tab" && !event.shiftKey) {
3942
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3943
+ handleResetWip();
3944
+ }
3945
+ }, []);
3946
+ const handleShiftTabInput = React.useCallback((event) => {
3947
+ if (event.key === "Tab" && event.shiftKey) {
3948
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3949
+ handleResetWip();
3950
+ }
3951
+ }, []);
3952
+ const handleEnterInput = React.useCallback(
3953
+ (event) => {
3954
+ if (event.key === "Enter" && activeIndex != null) {
3955
+ if (!filteredDropDownItems[activeIndex]) {
3956
+ return;
3957
+ }
3958
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, filteredDropDownItems[activeIndex]));
3959
+ setInputValue("");
3960
+ setActiveIndex(0);
3961
+ switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
3962
+ }
3963
+ },
3964
+ [activeIndex, filter, filterInputType, filteredDropDownItems, model]
3965
+ );
3966
+ React.useEffect(() => {
3967
+ if (open) {
3968
+ handleFetchOptions(filterInputType);
3969
+ }
3970
+ }, [open, filterInputType]);
3971
+ React.useEffect(() => {
3972
+ var _a2;
3973
+ if (!isAlwaysWip) {
3974
+ setInputType("value");
3975
+ setInputValue("");
3976
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3977
+ }
3978
+ }, []);
3979
+ React.useLayoutEffect(() => {
3980
+ var _a2, _b2;
3981
+ if (activeIndex !== null && rowVirtualizer.range && (activeIndex > ((_a2 = rowVirtualizer.range) == null ? void 0 : _a2.endIndex) || activeIndex < ((_b2 = rowVirtualizer.range) == null ? void 0 : _b2.startIndex))) {
3982
+ rowVirtualizer.scrollToIndex(activeIndex);
3983
+ }
3984
+ }, [activeIndex, rowVirtualizer]);
3985
+ const keyLabel = (_a = filter == null ? void 0 : filter.keyLabel) != null ? _a : filter == null ? void 0 : filter.key;
3986
+ const valueLabel = (_c = (_b = filter == null ? void 0 : filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter == null ? void 0 : filter.value;
3987
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
3988
+ className: styles.comboboxWrapper
3989
+ }, filter ? /* @__PURE__ */ React__default["default"].createElement("div", {
3990
+ className: styles.pillWrapper
3991
+ }, (filter == null ? void 0 : filter.key) ? /* @__PURE__ */ React__default["default"].createElement("div", {
3992
+ className: css.cx(styles.basePill, styles.keyPill)
3993
+ }, keyLabel) : null, (filter == null ? void 0 : filter.key) && (filter == null ? void 0 : filter.operator) && filterInputType !== "operator" ? /* @__PURE__ */ React__default["default"].createElement("div", {
3994
+ id: operatorIdentifier,
3995
+ className: css.cx(styles.basePill, styles.operatorPill, operatorIdentifier),
3996
+ role: "button",
3997
+ "aria-label": "Edit filter operator",
3998
+ tabIndex: 0,
3999
+ onClick: (event) => {
4000
+ event.stopPropagation();
4001
+ switchInputType("operator", setInputType, void 0, refs.domReference.current);
4002
+ },
4003
+ onKeyDown: (event) => {
4004
+ handleShiftTabInput(event);
4005
+ if (event.key === "Enter") {
4006
+ switchInputType("operator", setInputType, void 0, refs.domReference.current);
4007
+ }
4008
+ }
4009
+ }, filter.operator) : null, (filter == null ? void 0 : filter.key) && (filter == null ? void 0 : filter.operator) && (filter == null ? void 0 : filter.value) && !["operator", "value"].includes(filterInputType) ? /* @__PURE__ */ React__default["default"].createElement("div", {
4010
+ className: css.cx(styles.basePill, styles.valuePill)
4011
+ }, valueLabel) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$n(__spreadValues$A({}, getReferenceProps({
4012
+ ref: refs.setReference,
4013
+ onChange,
4014
+ value: inputValue,
4015
+ placeholder: !isAlwaysWip ? filterInputType === "operator" ? `${filter[filterInputType]} ${valueLabel}` : filter[filterInputType] : "Filter by label values",
4016
+ "aria-autocomplete": "list",
4017
+ onKeyDown(event) {
4018
+ if (!open) {
4019
+ setOpen(true);
4020
+ return;
4021
+ }
4022
+ if (filterInputType === "operator") {
4023
+ handleShiftTabInput(event);
4024
+ }
4025
+ handleBackspaceInput(event);
4026
+ handleTabInput(event);
4027
+ handleEnterInput(event);
4028
+ }
4029
+ })), {
4030
+ className: css.cx(styles.inputStyle, { [styles.loadingInputPadding]: !optionsLoading }),
4031
+ onClick: (event) => {
4032
+ event.stopPropagation();
4033
+ setOpen(true);
4034
+ },
4035
+ onFocus: () => {
4036
+ setActiveIndex(0);
4037
+ setOpen(true);
4038
+ }
4039
+ })), optionsLoading ? /* @__PURE__ */ React__default["default"].createElement(ui.Spinner, {
4040
+ className: styles.loadingIndicator,
4041
+ inline: true
4042
+ }) : null, /* @__PURE__ */ React__default["default"].createElement(react.FloatingPortal, null, open && /* @__PURE__ */ React__default["default"].createElement(react.FloatingFocusManager, {
4043
+ context,
4044
+ initialFocus: -1,
4045
+ visuallyHiddenDismiss: true,
4046
+ modal: false
4047
+ }, /* @__PURE__ */ React__default["default"].createElement("div", {
4048
+ style: __spreadProps$n(__spreadValues$A({}, floatingStyles), {
4049
+ width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`
4050
+ }),
4051
+ ref: refs.setFloating,
4052
+ className: styles.dropdownWrapper,
4053
+ tabIndex: -1
4054
+ }, /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$n(__spreadValues$A({
4055
+ style: {
4056
+ height: `${rowVirtualizer.getTotalSize() || VIRTUAL_LIST_ITEM_HEIGHT}px`
4057
+ }
4058
+ }, getFloatingProps()), {
4059
+ tabIndex: -1
4060
+ }), optionsLoading ? /* @__PURE__ */ React__default["default"].createElement(LoadingOptionsPlaceholder, null) : optionsError ? /* @__PURE__ */ React__default["default"].createElement(OptionsErrorPlaceholder, {
4061
+ handleFetchOptions: () => handleFetchOptions(filterInputType)
4062
+ }) : !filteredDropDownItems.length && (filterInputType === "operator" || !inputValue) ? /* @__PURE__ */ React__default["default"].createElement(NoOptionsPlaceholder, null) : rowVirtualizer.getVirtualItems().map((virtualItem) => {
4063
+ var _a2;
4064
+ const item = filteredDropDownItems[virtualItem.index];
4065
+ const index = virtualItem.index;
4066
+ if (item.options) {
4067
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4068
+ key: `${item.label}+${index}`,
4069
+ className: css.cx(styles.optionGroupLabel, styles.groupTopBorder),
4070
+ style: {
4071
+ height: `${virtualItem.size}px`,
4072
+ transform: `translateY(${virtualItem.start}px)`
4073
+ }
4074
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Text, {
4075
+ weight: "bold",
4076
+ variant: "bodySmall",
4077
+ color: "secondary"
4078
+ }, item.label));
4079
+ }
4080
+ const nextItem = filteredDropDownItems[virtualItem.index + 1];
4081
+ const shouldAddBottomBorder = nextItem && !nextItem.group && !nextItem.options && item.group;
4082
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, __spreadProps$n(__spreadValues$A({}, getItemProps({
4083
+ key: `${item.value}-${index}`,
4084
+ ref(node) {
4085
+ listRef.current[index] = node;
4086
+ },
4087
+ onClick(event) {
4088
+ if (filterInputType !== "value") {
4089
+ event.stopPropagation();
4090
+ }
4091
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
4092
+ setInputValue("");
4093
+ switchToNextInputType(
4094
+ filterInputType,
4095
+ setInputType,
4096
+ handleChangeViewMode,
4097
+ refs.domReference.current
4098
+ );
4099
+ }
4100
+ })), {
4101
+ active: activeIndex === index,
4102
+ addGroupBottomBorder: shouldAddBottomBorder,
4103
+ style: {
4104
+ height: `${virtualItem.size}px`,
4105
+ transform: `translateY(${virtualItem.start}px)`
4106
+ },
4107
+ "aria-setsize": filteredDropDownItems.length,
4108
+ "aria-posinset": virtualItem.index + 1
4109
+ }), item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value);
4110
+ }))))));
4111
+ });
4112
+ const getStyles$b = (theme) => ({
4113
+ comboboxWrapper: css.css({
4114
+ display: "flex",
4115
+ flexWrap: "nowrap"
4116
+ }),
4117
+ pillWrapper: css.css({
4118
+ display: "flex",
4119
+ alignItems: "center",
4120
+ whiteSpace: "nowrap"
4121
+ }),
4122
+ basePill: css.css(__spreadProps$n(__spreadValues$A({
4123
+ display: "flex",
4124
+ alignItems: "center",
4125
+ background: theme.colors.action.disabledBackground,
4126
+ border: `1px solid ${theme.colors.border.weak}`,
4127
+ padding: theme.spacing(0.125, 1, 0.125, 1),
4128
+ color: theme.colors.text.primary,
4129
+ overflow: "hidden",
4130
+ whiteSpace: "nowrap",
4131
+ minHeight: theme.spacing(2.75)
4132
+ }, theme.typography.bodySmall), {
4133
+ cursor: "pointer"
4134
+ })),
4135
+ keyPill: css.css({
4136
+ fontWeight: theme.typography.fontWeightBold,
4137
+ cursor: "default"
4138
+ }),
4139
+ operatorPill: css.css({
4140
+ "&:hover": {
4141
+ background: theme.colors.action.hover
4142
+ }
4143
+ }),
4144
+ valuePill: css.css({
4145
+ background: theme.colors.action.selected
4146
+ }),
4147
+ dropdownWrapper: css.css({
4148
+ backgroundColor: theme.colors.background.primary,
4149
+ color: theme.colors.text.primary,
4150
+ boxShadow: theme.shadows.z2,
4151
+ overflowY: "auto",
4152
+ zIndex: theme.zIndex.dropdown
4153
+ }),
4154
+ inputStyle: css.css({
4155
+ paddingBlock: 0,
4156
+ "&:focus": {
4157
+ outline: "none"
4158
+ }
4159
+ }),
4160
+ loadingIndicator: css.css({
4161
+ color: theme.colors.text.secondary,
4162
+ marginLeft: theme.spacing(0.5)
4163
+ }),
4164
+ loadingInputPadding: css.css({
4165
+ paddingRight: theme.spacing(2.5)
4166
+ }),
4167
+ optionGroupLabel: css.css({
4168
+ padding: theme.spacing(1),
4169
+ position: "absolute",
4170
+ top: 0,
4171
+ left: 0,
4172
+ width: "100%"
4173
+ }),
4174
+ groupTopBorder: css.css({
4175
+ "&:not(:first-child)": {
4176
+ borderTop: `1px solid ${theme.colors.border.weak}`
4177
+ }
4178
+ })
4179
+ });
4180
+
4181
+ var __defProp$z = Object.defineProperty;
4182
+ var __defProps$m = Object.defineProperties;
4183
+ var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
4184
+ var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
4185
+ var __hasOwnProp$z = Object.prototype.hasOwnProperty;
4186
+ var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
4187
+ var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4188
+ var __spreadValues$z = (a, b) => {
4189
+ for (var prop in b || (b = {}))
4190
+ if (__hasOwnProp$z.call(b, prop))
4191
+ __defNormalProp$z(a, prop, b[prop]);
4192
+ if (__getOwnPropSymbols$z)
4193
+ for (var prop of __getOwnPropSymbols$z(b)) {
4194
+ if (__propIsEnum$z.call(b, prop))
4195
+ __defNormalProp$z(a, prop, b[prop]);
4196
+ }
4197
+ return a;
4198
+ };
4199
+ var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
4200
+ function AdHocFilterPill({ filter, model, readOnly }) {
4201
+ var _a, _b, _c;
4202
+ const styles = ui.useStyles2(getStyles$a);
4203
+ const [viewMode, setViewMode] = React.useState(true);
4204
+ const pillWrapperRef = React.useRef(null);
4205
+ const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
4206
+ const valueLabel = (_c = (_b = filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter.value;
4207
+ const handleChangeViewMode = React.useCallback(
4208
+ (event) => {
4209
+ var _a2;
4210
+ event == null ? void 0 : event.stopPropagation();
4211
+ if (readOnly) {
4212
+ return;
4213
+ }
4214
+ let viewMode2 = false;
4215
+ reactDom.flushSync(() => {
4216
+ setViewMode((mode) => {
4217
+ viewMode2 = mode;
4218
+ return !mode;
4219
+ });
4220
+ });
4221
+ if (!viewMode2) {
4222
+ (_a2 = pillWrapperRef.current) == null ? void 0 : _a2.focus();
4223
+ }
4224
+ },
4225
+ [readOnly]
4226
+ );
4227
+ if (viewMode) {
4228
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4229
+ className: css.cx(styles.combinedFilterPill, { [styles.readOnlyCombinedFilter]: readOnly }),
4230
+ onClick: handleChangeViewMode,
4231
+ onKeyDown: (e) => {
4232
+ if (e.key === "Enter") {
4233
+ handleChangeViewMode();
4234
+ }
4235
+ },
4236
+ role: "button",
4237
+ "aria-label": `Edit filter with key ${keyLabel}`,
4238
+ tabIndex: 0,
4239
+ ref: pillWrapperRef
4240
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
4241
+ onClick: (e) => {
4242
+ e.stopPropagation();
4243
+ model._removeFilter(filter);
4244
+ },
4245
+ onKeyDownCapture: (e) => {
4246
+ if (e.key === "Enter") {
4247
+ e.preventDefault();
4248
+ e.stopPropagation();
4249
+ model._removeFilter(filter);
4250
+ }
4251
+ },
4252
+ name: "times",
4253
+ size: "md",
4254
+ className: styles.removeButton,
4255
+ tooltip: `Remove filter with key ${keyLabel}`
4256
+ }) : null);
4257
+ }
4258
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
4259
+ filter,
4260
+ model,
4261
+ handleChangeViewMode
4262
+ });
4263
+ }
4264
+ const getStyles$a = (theme) => ({
4265
+ combinedFilterPill: css.css(__spreadProps$m(__spreadValues$z({
4266
+ display: "flex",
4267
+ alignItems: "center",
4268
+ background: theme.colors.action.selected,
4269
+ borderRadius: theme.shape.radius.default,
4270
+ border: `1px solid ${theme.colors.border.weak}`,
4271
+ padding: theme.spacing(0.125, 0, 0.125, 1),
4272
+ color: theme.colors.text.primary,
4273
+ overflow: "hidden",
4274
+ whiteSpace: "nowrap",
4275
+ minHeight: theme.spacing(2.75)
4276
+ }, theme.typography.bodySmall), {
4277
+ fontWeight: theme.typography.fontWeightBold,
4278
+ cursor: "pointer",
4279
+ "&:hover": {
4280
+ background: theme.colors.action.hover
4281
+ }
4282
+ })),
4283
+ readOnlyCombinedFilter: css.css({
4284
+ paddingRight: theme.spacing(1),
4285
+ cursor: "text",
4286
+ "&:hover": {
4287
+ background: theme.colors.action.selected
4288
+ }
4289
+ }),
4290
+ removeButton: css.css({
4291
+ marginInline: theme.spacing(0.5),
4292
+ cursor: "pointer",
4293
+ "&:hover": {
4294
+ color: theme.colors.text.primary
4295
+ }
4296
+ })
4297
+ });
4298
+
4299
+ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwaysWipCombobox2({ model }, parentRef) {
4300
+ const { _wip } = model.useState();
4301
+ React.useLayoutEffect(() => {
4302
+ if (!_wip) {
4303
+ model._addWip();
4304
+ }
4305
+ }, [_wip]);
4306
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
4307
+ model,
4308
+ filter: _wip,
4309
+ isAlwaysWip: true,
4310
+ ref: parentRef
4311
+ });
4312
+ });
4313
+
4314
+ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ model }) {
4315
+ const { filters, readOnly } = model.useState();
4316
+ const styles = ui.useStyles2(getStyles$9);
4317
+ const focusOnInputRef = React.useRef();
4318
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4319
+ className: css.cx(styles.comboboxWrapper, { [styles.comboboxFocusOutline]: !readOnly }),
4320
+ onClick: () => {
4321
+ var _a;
4322
+ (_a = focusOnInputRef.current) == null ? void 0 : _a.call(focusOnInputRef);
4323
+ }
4324
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
4325
+ name: "filter",
4326
+ className: styles.filterIcon,
4327
+ size: "lg"
4328
+ }), filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(AdHocFilterPill, {
4329
+ key: index,
4330
+ filter,
4331
+ model,
4332
+ readOnly
4333
+ })), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersAlwaysWipCombobox, {
4334
+ model,
4335
+ ref: focusOnInputRef
4336
+ }) : null);
4337
+ });
4338
+ const getStyles$9 = (theme) => ({
4339
+ comboboxWrapper: css.css({
4340
+ display: "flex",
4341
+ flexWrap: "wrap",
4342
+ alignItems: "center",
4343
+ columnGap: theme.spacing(1),
4344
+ rowGap: theme.spacing(0.5),
4345
+ minHeight: theme.spacing(4),
4346
+ backgroundColor: theme.components.input.background,
4347
+ border: `1px solid ${theme.colors.border.strong}`,
4348
+ borderRadius: theme.shape.radius.default,
4349
+ paddingInline: theme.spacing(1),
4350
+ paddingBlock: theme.spacing(0.5),
4351
+ flexGrow: 1
4352
+ }),
4353
+ comboboxFocusOutline: css.css({
4354
+ "&:focus-within": {
4355
+ outline: "2px dotted transparent",
4356
+ outlineOffset: "2px",
4357
+ boxShadow: `0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main}`,
4358
+ transitionTimingFunction: `cubic-bezier(0.19, 1, 0.22, 1)`,
4359
+ transitionDuration: "0.2s",
4360
+ transitionProperty: "outline, outline-offset, box-shadow",
4361
+ zIndex: 2
4362
+ }
4363
+ }),
4364
+ filterIcon: css.css({
4365
+ color: theme.colors.text.secondary,
4366
+ alignSelf: "center"
4367
+ })
4368
+ });
4369
+
3561
4370
  var __defProp$y = Object.defineProperty;
3562
4371
  var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
3563
4372
  var __hasOwnProp$y = Object.prototype.hasOwnProperty;
@@ -3574,29 +4383,38 @@ var __spreadValues$y = (a, b) => {
3574
4383
  }
3575
4384
  return a;
3576
4385
  };
3577
- const OPERATORS = [{
3578
- value: "="
3579
- }, {
3580
- value: "!="
3581
- }, {
3582
- value: "=|",
3583
- description: "Is one of. Use to filter on multiple values.",
3584
- isMulti: true
3585
- }, {
3586
- value: "!=|",
3587
- description: "Is not one of. Use to exclude multiple values.",
3588
- isMulti: true
3589
- }, {
3590
- value: "=~",
3591
- description: "Matches regex"
3592
- }, {
3593
- value: "!~",
3594
- description: "Does not match regex"
3595
- }, {
3596
- value: "<"
3597
- }, {
3598
- value: ">"
3599
- }];
4386
+ const OPERATORS = [
4387
+ {
4388
+ value: "="
4389
+ },
4390
+ {
4391
+ value: "!="
4392
+ },
4393
+ {
4394
+ value: "=|",
4395
+ description: "Is one of. Use to filter on multiple values.",
4396
+ isMulti: true
4397
+ },
4398
+ {
4399
+ value: "!=|",
4400
+ description: "Is not one of. Use to exclude multiple values.",
4401
+ isMulti: true
4402
+ },
4403
+ {
4404
+ value: "=~",
4405
+ description: "Matches regex"
4406
+ },
4407
+ {
4408
+ value: "!~",
4409
+ description: "Does not match regex"
4410
+ },
4411
+ {
4412
+ value: "<"
4413
+ },
4414
+ {
4415
+ value: ">"
4416
+ }
4417
+ ];
3600
4418
  class AdHocFiltersVariable extends SceneObjectBase {
3601
4419
  constructor(state) {
3602
4420
  var _a, _b;
@@ -3651,6 +4469,12 @@ class AdHocFiltersVariable extends SceneObjectBase {
3651
4469
  }
3652
4470
  this.setState({ filters: this.state.filters.filter((f) => f !== filter) });
3653
4471
  }
4472
+ _removeLastFilter() {
4473
+ const filterToRemove = this.state.filters.at(-1);
4474
+ if (filterToRemove) {
4475
+ this._removeFilter(filterToRemove);
4476
+ }
4477
+ }
3654
4478
  async _getKeys(currentKey) {
3655
4479
  var _a, _b, _c;
3656
4480
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
@@ -3734,6 +4558,11 @@ function renderExpression(builder, filters) {
3734
4558
  function AdHocFiltersVariableRenderer({ model }) {
3735
4559
  const { filters, readOnly, addFilterButtonText } = model.useState();
3736
4560
  const styles = ui.useStyles2(getStyles$8);
4561
+ if (!model.state.supportsMultiValueOperators && model.state.layout === "combobox") {
4562
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxRenderer, {
4563
+ model
4564
+ });
4565
+ }
3737
4566
  return /* @__PURE__ */ React__default["default"].createElement("div", {
3738
4567
  className: styles.wrapper
3739
4568
  }, filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, {
@@ -3754,10 +4583,6 @@ const getStyles$8 = (theme) => ({
3754
4583
  alignItems: "flex-end",
3755
4584
  columnGap: theme.spacing(2),
3756
4585
  rowGap: theme.spacing(1)
3757
- }),
3758
- filterIcon: css.css({
3759
- color: theme.colors.text.secondary,
3760
- paddingRight: theme.spacing(0.5)
3761
4586
  })
3762
4587
  });
3763
4588
  function toSelectableValue(input) {