@grafana/scenes 5.25.1--canary.858.11930656504.0 → 5.25.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/CHANGELOG.md +22 -6
  2. package/dist/esm/behaviors/SceneQueryController.js +5 -60
  3. package/dist/esm/behaviors/SceneQueryController.js.map +1 -1
  4. package/dist/esm/components/SceneRefreshPicker.js +1 -6
  5. package/dist/esm/components/SceneRefreshPicker.js.map +1 -1
  6. package/dist/esm/components/VizPanel/VizPanel.js +6 -9
  7. package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
  8. package/dist/esm/core/SceneTimeRange.js +0 -3
  9. package/dist/esm/core/SceneTimeRange.js.map +1 -1
  10. package/dist/esm/core/sceneGraph/index.js +3 -3
  11. package/dist/esm/core/sceneGraph/index.js.map +1 -1
  12. package/dist/esm/core/sceneGraph/sceneGraph.js +26 -1
  13. package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
  14. package/dist/esm/index.js.map +1 -1
  15. package/dist/esm/querying/SceneQueryRunner.js +3 -1
  16. package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
  17. package/dist/esm/querying/layers/annotations/filterAnnotations.js +3 -2
  18. package/dist/esm/querying/layers/annotations/filterAnnotations.js.map +1 -1
  19. package/dist/esm/querying/registerQueryWithController.js +2 -18
  20. package/dist/esm/querying/registerQueryWithController.js.map +1 -1
  21. package/dist/esm/utils/getDataSource.js +1 -17
  22. package/dist/esm/utils/getDataSource.js.map +1 -1
  23. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js +8 -12
  24. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js.map +1 -1
  25. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +9 -48
  26. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js.map +1 -1
  27. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js +4 -1
  28. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js.map +1 -1
  29. package/dist/esm/variables/adhoc/getAdhocOptionSearcher.js +6 -38
  30. package/dist/esm/variables/adhoc/getAdhocOptionSearcher.js.map +1 -1
  31. package/dist/esm/variables/components/VariableValueSelect.js +0 -5
  32. package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
  33. package/dist/esm/variables/components/getOptionSearcher.js +5 -39
  34. package/dist/esm/variables/components/getOptionSearcher.js.map +1 -1
  35. package/dist/esm/variables/utils.js +23 -1
  36. package/dist/esm/variables/utils.js.map +1 -1
  37. package/dist/esm/variables/variants/TestVariable.js.map +1 -1
  38. package/dist/index.d.ts +32 -44
  39. package/dist/index.js +287 -620
  40. package/dist/index.js.map +1 -1
  41. package/package.json +3 -3
  42. package/dist/esm/behaviors/SceneRenderProfiler.js +0 -169
  43. package/dist/esm/behaviors/SceneRenderProfiler.js.map +0 -1
  44. package/dist/esm/core/sceneGraph/getQueryController.js +0 -19
  45. package/dist/esm/core/sceneGraph/getQueryController.js.map +0 -1
package/dist/index.js CHANGED
@@ -13,9 +13,9 @@ var schema = require('@grafana/schema');
13
13
  var ui = require('@grafana/ui');
14
14
  var e2eSelectors = require('@grafana/e2e-selectors');
15
15
  var css = require('@emotion/css');
16
- var uFuzzy = require('@leeoniya/ufuzzy');
17
16
  var react = require('@floating-ui/react');
18
17
  var reactVirtual = require('@tanstack/react-virtual');
18
+ var uFuzzy = require('@leeoniya/ufuzzy');
19
19
  var reactUse = require('react-use');
20
20
  var operators = require('rxjs/operators');
21
21
  var ReactGridLayout = require('react-grid-layout');
@@ -41,19 +41,19 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
41
41
  var uFuzzy__default = /*#__PURE__*/_interopDefaultLegacy(uFuzzy);
42
42
  var ReactGridLayout__default = /*#__PURE__*/_interopDefaultLegacy(ReactGridLayout);
43
43
 
44
- var __defProp$Q = Object.defineProperty;
45
- var __getOwnPropSymbols$Q = Object.getOwnPropertySymbols;
46
- var __hasOwnProp$Q = Object.prototype.hasOwnProperty;
47
- var __propIsEnum$Q = Object.prototype.propertyIsEnumerable;
48
- var __defNormalProp$Q = (obj, key, value) => key in obj ? __defProp$Q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
49
- var __spreadValues$Q = (a, b) => {
44
+ var __defProp$P = Object.defineProperty;
45
+ var __getOwnPropSymbols$P = Object.getOwnPropertySymbols;
46
+ var __hasOwnProp$P = Object.prototype.hasOwnProperty;
47
+ var __propIsEnum$P = Object.prototype.propertyIsEnumerable;
48
+ var __defNormalProp$P = (obj, key, value) => key in obj ? __defProp$P(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
49
+ var __spreadValues$P = (a, b) => {
50
50
  for (var prop in b || (b = {}))
51
- if (__hasOwnProp$Q.call(b, prop))
52
- __defNormalProp$Q(a, prop, b[prop]);
53
- if (__getOwnPropSymbols$Q)
54
- for (var prop of __getOwnPropSymbols$Q(b)) {
55
- if (__propIsEnum$Q.call(b, prop))
56
- __defNormalProp$Q(a, prop, b[prop]);
51
+ if (__hasOwnProp$P.call(b, prop))
52
+ __defNormalProp$P(a, prop, b[prop]);
53
+ if (__getOwnPropSymbols$P)
54
+ for (var prop of __getOwnPropSymbols$P(b)) {
55
+ if (__propIsEnum$P.call(b, prop))
56
+ __defNormalProp$P(a, prop, b[prop]);
57
57
  }
58
58
  return a;
59
59
  };
@@ -62,7 +62,7 @@ function useAppQueryParams() {
62
62
  return runtime.locationSearchToObject(location.search || "");
63
63
  }
64
64
  function getUrlWithAppState(path, searchObject, preserveParams) {
65
- const paramsCopy = __spreadValues$Q({}, searchObject);
65
+ const paramsCopy = __spreadValues$P({}, searchObject);
66
66
  if (preserveParams) {
67
67
  for (const key of Object.keys(paramsCopy)) {
68
68
  if (!preserveParams.includes(key)) {
@@ -76,31 +76,31 @@ function renderSceneComponentWithRouteProps(sceneObject, routeProps) {
76
76
  return React__default["default"].createElement(sceneObject.Component, { model: sceneObject, routeProps });
77
77
  }
78
78
 
79
- var __defProp$P = Object.defineProperty;
80
- var __defProps$x = Object.defineProperties;
81
- var __getOwnPropDescs$x = Object.getOwnPropertyDescriptors;
82
- var __getOwnPropSymbols$P = Object.getOwnPropertySymbols;
83
- var __hasOwnProp$P = Object.prototype.hasOwnProperty;
84
- var __propIsEnum$P = Object.prototype.propertyIsEnumerable;
85
- var __defNormalProp$P = (obj, key, value) => key in obj ? __defProp$P(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86
- var __spreadValues$P = (a, b) => {
79
+ var __defProp$O = Object.defineProperty;
80
+ var __defProps$w = Object.defineProperties;
81
+ var __getOwnPropDescs$w = Object.getOwnPropertyDescriptors;
82
+ var __getOwnPropSymbols$O = Object.getOwnPropertySymbols;
83
+ var __hasOwnProp$O = Object.prototype.hasOwnProperty;
84
+ var __propIsEnum$O = Object.prototype.propertyIsEnumerable;
85
+ var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86
+ var __spreadValues$O = (a, b) => {
87
87
  for (var prop in b || (b = {}))
88
- if (__hasOwnProp$P.call(b, prop))
89
- __defNormalProp$P(a, prop, b[prop]);
90
- if (__getOwnPropSymbols$P)
91
- for (var prop of __getOwnPropSymbols$P(b)) {
92
- if (__propIsEnum$P.call(b, prop))
93
- __defNormalProp$P(a, prop, b[prop]);
88
+ if (__hasOwnProp$O.call(b, prop))
89
+ __defNormalProp$O(a, prop, b[prop]);
90
+ if (__getOwnPropSymbols$O)
91
+ for (var prop of __getOwnPropSymbols$O(b)) {
92
+ if (__propIsEnum$O.call(b, prop))
93
+ __defNormalProp$O(a, prop, b[prop]);
94
94
  }
95
95
  return a;
96
96
  };
97
- var __spreadProps$x = (a, b) => __defProps$x(a, __getOwnPropDescs$x(b));
97
+ var __spreadProps$w = (a, b) => __defProps$w(a, __getOwnPropDescs$w(b));
98
98
  const runtimePanelPlugins = /* @__PURE__ */ new Map();
99
99
  function registerRuntimePanelPlugin({ pluginId, plugin }) {
100
100
  if (runtimePanelPlugins.has(pluginId)) {
101
101
  throw new Error(`A runtime panel plugin with id ${pluginId} has already been registered`);
102
102
  }
103
- plugin.meta = __spreadProps$x(__spreadValues$P({}, plugin.meta), {
103
+ plugin.meta = __spreadProps$w(__spreadValues$O({}, plugin.meta), {
104
104
  id: pluginId,
105
105
  name: pluginId,
106
106
  module: "runtime plugin",
@@ -128,33 +128,33 @@ function loadPanelPluginSync(pluginId) {
128
128
  return (_a = getPanelPluginFromCache(pluginId)) != null ? _a : runtimePanelPlugins.get(pluginId);
129
129
  }
130
130
 
131
- var __defProp$O = Object.defineProperty;
132
- var __defProps$w = Object.defineProperties;
133
- var __getOwnPropDescs$w = Object.getOwnPropertyDescriptors;
134
- var __getOwnPropSymbols$O = Object.getOwnPropertySymbols;
135
- var __hasOwnProp$O = Object.prototype.hasOwnProperty;
136
- var __propIsEnum$O = Object.prototype.propertyIsEnumerable;
137
- var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
138
- var __spreadValues$O = (a, b) => {
131
+ var __defProp$N = Object.defineProperty;
132
+ var __defProps$v = Object.defineProperties;
133
+ var __getOwnPropDescs$v = Object.getOwnPropertyDescriptors;
134
+ var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
135
+ var __hasOwnProp$N = Object.prototype.hasOwnProperty;
136
+ var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
137
+ var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
138
+ var __spreadValues$N = (a, b) => {
139
139
  for (var prop in b || (b = {}))
140
- if (__hasOwnProp$O.call(b, prop))
141
- __defNormalProp$O(a, prop, b[prop]);
142
- if (__getOwnPropSymbols$O)
143
- for (var prop of __getOwnPropSymbols$O(b)) {
144
- if (__propIsEnum$O.call(b, prop))
145
- __defNormalProp$O(a, prop, b[prop]);
140
+ if (__hasOwnProp$N.call(b, prop))
141
+ __defNormalProp$N(a, prop, b[prop]);
142
+ if (__getOwnPropSymbols$N)
143
+ for (var prop of __getOwnPropSymbols$N(b)) {
144
+ if (__propIsEnum$N.call(b, prop))
145
+ __defNormalProp$N(a, prop, b[prop]);
146
146
  }
147
147
  return a;
148
148
  };
149
- var __spreadProps$w = (a, b) => __defProps$w(a, __getOwnPropDescs$w(b));
149
+ var __spreadProps$v = (a, b) => __defProps$v(a, __getOwnPropDescs$v(b));
150
150
  var __objRest$5 = (source, exclude) => {
151
151
  var target = {};
152
152
  for (var prop in source)
153
- if (__hasOwnProp$O.call(source, prop) && exclude.indexOf(prop) < 0)
153
+ if (__hasOwnProp$N.call(source, prop) && exclude.indexOf(prop) < 0)
154
154
  target[prop] = source[prop];
155
- if (source != null && __getOwnPropSymbols$O)
156
- for (var prop of __getOwnPropSymbols$O(source)) {
157
- if (exclude.indexOf(prop) < 0 && __propIsEnum$O.call(source, prop))
155
+ if (source != null && __getOwnPropSymbols$N)
156
+ for (var prop of __getOwnPropSymbols$N(source)) {
157
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$N.call(source, prop))
158
158
  target[prop] = source[prop];
159
159
  }
160
160
  return target;
@@ -172,7 +172,7 @@ function SceneComponentWrapperWithoutMemo(_a) {
172
172
  if (!model.isActive) {
173
173
  return null;
174
174
  }
175
- return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$w(__spreadValues$O({}, otherProps), {
175
+ return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$v(__spreadValues$N({}, otherProps), {
176
176
  model
177
177
  }));
178
178
  }
@@ -188,49 +188,49 @@ class UserActionEvent extends data.BusEventWithPayload {
188
188
  }
189
189
  UserActionEvent.type = "scene-object-user-action";
190
190
 
191
- var __accessCheck$4 = (obj, member, msg) => {
191
+ var __accessCheck$3 = (obj, member, msg) => {
192
192
  if (!member.has(obj))
193
193
  throw TypeError("Cannot " + msg);
194
194
  };
195
- var __privateGet$4 = (obj, member, getter) => {
196
- __accessCheck$4(obj, member, "read from private field");
195
+ var __privateGet$3 = (obj, member, getter) => {
196
+ __accessCheck$3(obj, member, "read from private field");
197
197
  return getter ? getter.call(obj) : member.get(obj);
198
198
  };
199
- var __privateAdd$4 = (obj, member, value) => {
199
+ var __privateAdd$3 = (obj, member, value) => {
200
200
  if (member.has(obj))
201
201
  throw TypeError("Cannot add the same private member more than once");
202
202
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
203
203
  };
204
- var __privateSet$4 = (obj, member, value, setter) => {
205
- __accessCheck$4(obj, member, "write to private field");
204
+ var __privateSet$2 = (obj, member, value, setter) => {
205
+ __accessCheck$3(obj, member, "write to private field");
206
206
  setter ? setter.call(obj, value) : member.set(obj, value);
207
207
  return value;
208
208
  };
209
209
  var _ref;
210
210
  class SceneObjectRef {
211
211
  constructor(ref) {
212
- __privateAdd$4(this, _ref, void 0);
213
- __privateSet$4(this, _ref, ref);
212
+ __privateAdd$3(this, _ref, void 0);
213
+ __privateSet$2(this, _ref, ref);
214
214
  }
215
215
  resolve() {
216
- return __privateGet$4(this, _ref);
216
+ return __privateGet$3(this, _ref);
217
217
  }
218
218
  }
219
219
  _ref = new WeakMap();
220
220
 
221
- var __defProp$N = Object.defineProperty;
222
- var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
223
- var __hasOwnProp$N = Object.prototype.hasOwnProperty;
224
- var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
225
- var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
226
- var __spreadValues$N = (a, b) => {
221
+ var __defProp$M = Object.defineProperty;
222
+ var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
223
+ var __hasOwnProp$M = Object.prototype.hasOwnProperty;
224
+ var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
225
+ var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
226
+ var __spreadValues$M = (a, b) => {
227
227
  for (var prop in b || (b = {}))
228
- if (__hasOwnProp$N.call(b, prop))
229
- __defNormalProp$N(a, prop, b[prop]);
230
- if (__getOwnPropSymbols$N)
231
- for (var prop of __getOwnPropSymbols$N(b)) {
232
- if (__propIsEnum$N.call(b, prop))
233
- __defNormalProp$N(a, prop, b[prop]);
228
+ if (__hasOwnProp$M.call(b, prop))
229
+ __defNormalProp$M(a, prop, b[prop]);
230
+ if (__getOwnPropSymbols$M)
231
+ for (var prop of __getOwnPropSymbols$M(b)) {
232
+ if (__propIsEnum$M.call(b, prop))
233
+ __defNormalProp$M(a, prop, b[prop]);
234
234
  }
235
235
  return a;
236
236
  };
@@ -293,7 +293,7 @@ class SceneObjectBase {
293
293
  }
294
294
  setState(update) {
295
295
  const prevState = this._state;
296
- const newState = __spreadValues$N(__spreadValues$N({}, this._state), update);
296
+ const newState = __spreadValues$M(__spreadValues$M({}, this._state), update);
297
297
  this._state = Object.freeze(newState);
298
298
  this._setParent(update);
299
299
  this._handleActivationOfChangedStateProps(prevState, newState);
@@ -489,19 +489,19 @@ function forEachChild(state, callback) {
489
489
  }
490
490
  }
491
491
 
492
- var __defProp$M = Object.defineProperty;
493
- var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
494
- var __hasOwnProp$M = Object.prototype.hasOwnProperty;
495
- var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
496
- var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
497
- var __spreadValues$M = (a, b) => {
492
+ var __defProp$L = Object.defineProperty;
493
+ var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
494
+ var __hasOwnProp$L = Object.prototype.hasOwnProperty;
495
+ var __propIsEnum$L = Object.prototype.propertyIsEnumerable;
496
+ var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
497
+ var __spreadValues$L = (a, b) => {
498
498
  for (var prop in b || (b = {}))
499
- if (__hasOwnProp$M.call(b, prop))
500
- __defNormalProp$M(a, prop, b[prop]);
501
- if (__getOwnPropSymbols$M)
502
- for (var prop of __getOwnPropSymbols$M(b)) {
503
- if (__propIsEnum$M.call(b, prop))
504
- __defNormalProp$M(a, prop, b[prop]);
499
+ if (__hasOwnProp$L.call(b, prop))
500
+ __defNormalProp$L(a, prop, b[prop]);
501
+ if (__getOwnPropSymbols$L)
502
+ for (var prop of __getOwnPropSymbols$L(b)) {
503
+ if (__propIsEnum$L.call(b, prop))
504
+ __defNormalProp$L(a, prop, b[prop]);
505
505
  }
506
506
  return a;
507
507
  };
@@ -510,7 +510,7 @@ function cloneSceneObject(sceneObject, withState) {
510
510
  return new sceneObject.constructor(clonedState);
511
511
  }
512
512
  function cloneSceneObjectState(sceneState, withState) {
513
- const clonedState = __spreadValues$M({}, sceneState);
513
+ const clonedState = __spreadValues$L({}, sceneState);
514
514
  Object.assign(clonedState, withState);
515
515
  for (const key in clonedState) {
516
516
  if (withState && withState[key] !== void 0) {
@@ -592,322 +592,23 @@ function registerRuntimeDataSource({ dataSource }) {
592
592
  }
593
593
  runtimeDataSources.set(dataSource.uid, dataSource);
594
594
  }
595
-
596
- function lookupVariable(name, sceneObject) {
597
- const variables = sceneObject.state.$variables;
598
- if (!variables) {
599
- if (sceneObject.parent) {
600
- return lookupVariable(name, sceneObject.parent);
601
- } else {
602
- return null;
603
- }
604
- }
605
- const found = variables.getByName(name);
606
- if (found) {
607
- return found;
608
- } else if (sceneObject.parent) {
609
- return lookupVariable(name, sceneObject.parent);
610
- }
611
- return null;
612
- }
613
-
614
- function writeSceneLog(logger, message, ...rest) {
615
- let loggingEnabled = false;
616
- if (typeof window !== "undefined") {
617
- loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
618
- }
619
- if (loggingEnabled) {
620
- console.log(`${logger}: `, message, ...rest);
621
- }
622
- }
623
-
624
- var __accessCheck$3 = (obj, member, msg) => {
625
- if (!member.has(obj))
626
- throw TypeError("Cannot " + msg);
627
- };
628
- var __privateGet$3 = (obj, member, getter) => {
629
- __accessCheck$3(obj, member, "read from private field");
630
- return getter ? getter.call(obj) : member.get(obj);
631
- };
632
- var __privateAdd$3 = (obj, member, value) => {
633
- if (member.has(obj))
634
- throw TypeError("Cannot add the same private member more than once");
635
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
636
- };
637
- var __privateSet$3 = (obj, member, value, setter) => {
638
- __accessCheck$3(obj, member, "write to private field");
639
- setter ? setter.call(obj, value) : member.set(obj, value);
640
- return value;
641
- };
642
- var _profileInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans;
643
- const POST_STORM_WINDOW = 2e3;
644
- const SPAN_THRESHOLD = 30;
645
- class SceneRenderProfiler {
646
- constructor(queryController) {
647
- this.queryController = queryController;
648
- __privateAdd$3(this, _profileInProgress, null);
649
- __privateAdd$3(this, _profileStartTs, null);
650
- __privateAdd$3(this, _trailAnimationFrameId, null);
651
- __privateAdd$3(this, _recordedTrailingSpans, []);
652
- this.lastFrameTime = 0;
653
- this.measureTrailingFrames = (measurementStartTs, lastFrameTime, profileStartTs) => {
654
- const currentFrameTime = performance.now();
655
- const frameLength = currentFrameTime - lastFrameTime;
656
- __privateGet$3(this, _recordedTrailingSpans).push(frameLength);
657
- if (currentFrameTime - measurementStartTs < POST_STORM_WINDOW) {
658
- __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
659
- () => this.measureTrailingFrames(measurementStartTs, currentFrameTime, profileStartTs)
660
- ));
661
- } else {
662
- const slowFrames = processRecordedSpans(__privateGet$3(this, _recordedTrailingSpans));
663
- const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);
664
- writeSceneLog(
665
- this.constructor.name,
666
- "Profile tail recorded, slow frames duration:",
667
- slowFramesTime,
668
- slowFrames,
669
- __privateGet$3(this, _profileInProgress)
670
- );
671
- __privateSet$3(this, _recordedTrailingSpans, []);
672
- const profileDuration = measurementStartTs - profileStartTs;
673
- writeSceneLog(
674
- this.constructor.name,
675
- "Stoped recording, total measured time (network included):",
676
- profileDuration + slowFramesTime
677
- );
678
- __privateSet$3(this, _trailAnimationFrameId, null);
679
- const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
680
- performance.measure("DashboardInteraction", {
681
- start: profileStartTs,
682
- end: profileEndTs
683
- });
684
- const networkDuration = captureNetwork(profileStartTs, profileEndTs);
685
- if (this.queryController.state.onProfileComplete) {
686
- this.queryController.state.onProfileComplete({
687
- origin: __privateGet$3(this, _profileInProgress).origin,
688
- crumbs: __privateGet$3(this, _profileInProgress).crumbs,
689
- duration: profileDuration + slowFramesTime,
690
- networkDuration,
691
- jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
692
- usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,
693
- totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
694
- });
695
- }
696
- if (window.__runs) {
697
- window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
698
- `;
699
- } else {
700
- window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}
701
- `;
702
- }
703
- }
704
- };
705
- }
706
- startProfile(name) {
707
- if (__privateGet$3(this, _trailAnimationFrameId)) {
708
- cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
709
- __privateSet$3(this, _trailAnimationFrameId, null);
710
- writeSceneLog(this.constructor.name, "New profile: Stopped recording frames");
711
- }
712
- __privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
713
- __privateSet$3(this, _profileStartTs, performance.now());
714
- writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
715
- }
716
- recordProfileTail(measurementStartTime, profileStartTs) {
717
- __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
718
- () => this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)
719
- ));
720
- }
721
- tryCompletingProfile() {
722
- writeSceneLog(this.constructor.name, "Trying to complete profile", __privateGet$3(this, _profileInProgress));
723
- if (this.queryController.runningQueriesCount() === 0 && __privateGet$3(this, _profileInProgress)) {
724
- writeSceneLog(this.constructor.name, "All queries completed, stopping profile");
725
- this.recordProfileTail(performance.now(), __privateGet$3(this, _profileStartTs));
726
- }
727
- }
728
- isTailRecording() {
729
- return Boolean(__privateGet$3(this, _trailAnimationFrameId));
730
- }
731
- cancelTailRecording() {
732
- if (__privateGet$3(this, _trailAnimationFrameId)) {
733
- cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
734
- __privateSet$3(this, _trailAnimationFrameId, null);
735
- writeSceneLog(this.constructor.name, "Cancelled recording frames, new profile started");
736
- }
737
- }
738
- addCrumb(crumb) {
739
- if (__privateGet$3(this, _profileInProgress)) {
740
- __privateGet$3(this, _profileInProgress).crumbs.push(crumb);
741
- }
742
- }
743
- }
744
- _profileInProgress = new WeakMap();
745
- _profileStartTs = new WeakMap();
746
- _trailAnimationFrameId = new WeakMap();
747
- _recordedTrailingSpans = new WeakMap();
748
- function processRecordedSpans(spans) {
749
- for (let i = spans.length - 1; i >= 0; i--) {
750
- if (spans[i] > SPAN_THRESHOLD) {
751
- return spans.slice(0, i + 1);
752
- }
753
- }
754
- return [spans[0]];
755
- }
756
- function captureNetwork(startTs, endTs) {
757
- const entries = performance.getEntriesByType("resource");
758
- performance.clearResourceTimings();
759
- const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);
760
- for (const entry of networkEntries) {
761
- performance.measure("Network entry " + entry.name, {
762
- start: entry.startTime,
763
- end: entry.responseEnd
764
- });
765
- }
766
- return calculateNetworkTime(networkEntries);
767
- }
768
- function calculateNetworkTime(requests) {
769
- if (requests.length === 0) {
770
- return 0;
771
- }
772
- requests.sort((a, b) => a.startTime - b.startTime);
773
- let totalNetworkTime = 0;
774
- let currentStart = requests[0].startTime;
775
- let currentEnd = requests[0].responseEnd;
776
- for (let i = 1; i < requests.length; i++) {
777
- if (requests[i].startTime <= currentEnd) {
778
- currentEnd = Math.max(currentEnd, requests[i].responseEnd);
779
- } else {
780
- totalNetworkTime += currentEnd - currentStart;
781
- currentStart = requests[i].startTime;
782
- currentEnd = requests[i].responseEnd;
783
- }
784
- }
785
- totalNetworkTime += currentEnd - currentStart;
786
- return totalNetworkTime;
787
- }
788
-
789
- var __defProp$L = Object.defineProperty;
790
- var __defProps$v = Object.defineProperties;
791
- var __getOwnPropDescs$v = Object.getOwnPropertyDescriptors;
792
- var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
793
- var __hasOwnProp$L = Object.prototype.hasOwnProperty;
794
- var __propIsEnum$L = Object.prototype.propertyIsEnumerable;
795
- var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
796
- var __spreadValues$L = (a, b) => {
797
- for (var prop in b || (b = {}))
798
- if (__hasOwnProp$L.call(b, prop))
799
- __defNormalProp$L(a, prop, b[prop]);
800
- if (__getOwnPropSymbols$L)
801
- for (var prop of __getOwnPropSymbols$L(b)) {
802
- if (__propIsEnum$L.call(b, prop))
803
- __defNormalProp$L(a, prop, b[prop]);
804
- }
805
- return a;
806
- };
807
- var __spreadProps$v = (a, b) => __defProps$v(a, __getOwnPropDescs$v(b));
808
- var __accessCheck$2 = (obj, member, msg) => {
809
- if (!member.has(obj))
810
- throw TypeError("Cannot " + msg);
811
- };
812
- var __privateGet$2 = (obj, member, getter) => {
813
- __accessCheck$2(obj, member, "read from private field");
814
- return getter ? getter.call(obj) : member.get(obj);
815
- };
816
- var __privateAdd$2 = (obj, member, value) => {
817
- if (member.has(obj))
818
- throw TypeError("Cannot add the same private member more than once");
819
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
820
- };
821
- var __privateSet$2 = (obj, member, value, setter) => {
822
- __accessCheck$2(obj, member, "write to private field");
823
- setter ? setter.call(obj, value) : member.set(obj, value);
824
- return value;
825
- };
826
- var _running, _tryCompleteProfileFrameId;
827
- function isQueryController(s) {
828
- return "isQueryController" in s;
829
- }
830
- class SceneQueryController extends SceneObjectBase {
831
- constructor(state = {}) {
832
- super(__spreadProps$v(__spreadValues$L({}, state), { isRunning: false }));
833
- this.isQueryController = true;
834
- this.profiler = new SceneRenderProfiler(this);
835
- __privateAdd$2(this, _running, /* @__PURE__ */ new Set());
836
- __privateAdd$2(this, _tryCompleteProfileFrameId, null);
837
- this.runningQueriesCount = () => {
838
- return __privateGet$2(this, _running).size;
839
- };
840
- this.addActivationHandler(() => {
841
- return () => __privateGet$2(this, _running).clear();
842
- });
843
- }
844
- startProfile(source) {
845
- if (!this.state.enableProfiling) {
846
- return;
847
- }
848
- this.profiler.startProfile(source.constructor.name);
849
- }
850
- queryStarted(entry) {
851
- __privateGet$2(this, _running).add(entry);
852
- this.changeRunningQueryCount(1, entry);
853
- if (!this.state.isRunning) {
854
- this.setState({ isRunning: true });
855
- }
856
- }
857
- queryCompleted(entry) {
858
- if (!__privateGet$2(this, _running).has(entry)) {
859
- return;
860
- }
861
- __privateGet$2(this, _running).delete(entry);
862
- this.changeRunningQueryCount(-1);
863
- if (__privateGet$2(this, _running).size === 0) {
864
- this.setState({ isRunning: false });
865
- }
866
- }
867
- changeRunningQueryCount(dir, entry) {
868
- var _a;
869
- window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
870
- if (dir === 1 && this.state.enableProfiling) {
871
- if (entry) {
872
- this.profiler.addCrumb(`${entry.origin.constructor.name}/${entry.type}`);
873
- }
874
- if (this.profiler.isTailRecording()) {
875
- writeSceneLog(this.constructor.name, "New query started, cancelling tail recording");
876
- this.profiler.cancelTailRecording();
877
- }
878
- }
879
- if (this.state.enableProfiling) {
880
- if (__privateGet$2(this, _tryCompleteProfileFrameId)) {
881
- cancelAnimationFrame(__privateGet$2(this, _tryCompleteProfileFrameId));
882
- }
883
- __privateSet$2(this, _tryCompleteProfileFrameId, requestAnimationFrame(() => {
884
- this.profiler.tryCompletingProfile();
885
- }));
886
- }
887
- }
888
- cancelAll() {
889
- var _a;
890
- for (const entry of __privateGet$2(this, _running).values()) {
891
- (_a = entry.cancel) == null ? void 0 : _a.call(entry);
892
- }
893
- }
894
- }
895
- _running = new WeakMap();
896
- _tryCompleteProfileFrameId = new WeakMap();
897
-
898
- function getQueryController(sceneObject) {
899
- let parent = sceneObject;
900
- while (parent) {
901
- if (parent.state.$behaviors) {
902
- for (const behavior of parent.state.$behaviors) {
903
- if (isQueryController(behavior)) {
904
- return behavior;
905
- }
906
- }
595
+
596
+ function lookupVariable(name, sceneObject) {
597
+ const variables = sceneObject.state.$variables;
598
+ if (!variables) {
599
+ if (sceneObject.parent) {
600
+ return lookupVariable(name, sceneObject.parent);
601
+ } else {
602
+ return null;
907
603
  }
908
- parent = parent.parent;
909
604
  }
910
- return void 0;
605
+ const found = variables.getByName(name);
606
+ if (found) {
607
+ return found;
608
+ } else if (sceneObject.parent) {
609
+ return lookupVariable(name, sceneObject.parent);
610
+ }
611
+ return null;
911
612
  }
912
613
 
913
614
  var __defProp$K = Object.defineProperty;
@@ -1086,8 +787,6 @@ class SceneTimeRange extends SceneObjectBase {
1086
787
  this.state.UNSAFE_nowDelay
1087
788
  );
1088
789
  if (update.from !== this.state.from || update.to !== this.state.to) {
1089
- const queryController = getQueryController(this);
1090
- queryController == null ? void 0 : queryController.startProfile(this);
1091
790
  this._urlSync.performBrowserHistoryAction(() => {
1092
791
  this.setState(update);
1093
792
  });
@@ -2434,55 +2133,70 @@ function isDataLayer(obj) {
2434
2133
  return "isDataLayer" in obj;
2435
2134
  }
2436
2135
 
2437
- function registerQueryWithController(entry) {
2438
- return (queryStream) => {
2439
- const queryControler = sceneGraph.getQueryController(entry.origin);
2440
- if (!queryControler) {
2441
- return queryStream;
2442
- }
2443
- return new rxjs.Observable((observer) => {
2444
- if (!entry.cancel) {
2445
- entry.cancel = () => observer.complete();
2446
- }
2447
- queryControler.queryStarted(entry);
2448
- let markedAsCompleted = false;
2449
- const sub = queryStream.subscribe({
2450
- next: (v) => {
2451
- if (!markedAsCompleted && v.state !== schema.LoadingState.Loading) {
2452
- markedAsCompleted = true;
2453
- queryControler.queryCompleted(entry);
2454
- }
2455
- observer.next(v);
2456
- },
2457
- error: (e) => observer.error(e),
2458
- complete: () => {
2459
- observer.complete();
2460
- }
2461
- });
2462
- return () => {
2463
- sub.unsubscribe();
2464
- if (!markedAsCompleted) {
2465
- queryControler.queryCompleted(entry);
2466
- }
2467
- };
2468
- });
2469
- };
2136
+ var __accessCheck$2 = (obj, member, msg) => {
2137
+ if (!member.has(obj))
2138
+ throw TypeError("Cannot " + msg);
2139
+ };
2140
+ var __privateGet$2 = (obj, member, getter) => {
2141
+ __accessCheck$2(obj, member, "read from private field");
2142
+ return getter ? getter.call(obj) : member.get(obj);
2143
+ };
2144
+ var __privateAdd$2 = (obj, member, value) => {
2145
+ if (member.has(obj))
2146
+ throw TypeError("Cannot add the same private member more than once");
2147
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2148
+ };
2149
+ var _running;
2150
+ function isQueryController(s) {
2151
+ return "isQueryController" in s;
2470
2152
  }
2471
- function wrapPromiseInStateObservable(promise) {
2472
- return new rxjs.Observable((observer) => {
2473
- observer.next({ state: schema.LoadingState.Loading });
2474
- const promiseObservable = rxjs.from(promise);
2475
- promiseObservable.pipe(
2476
- rxjs.map(() => ({ state: schema.LoadingState.Done })),
2477
- rxjs.catchError(() => {
2478
- observer.next({ state: schema.LoadingState.Error });
2479
- return [];
2480
- })
2481
- ).subscribe({
2482
- next: (result) => observer.next(result),
2483
- complete: () => observer.complete()
2153
+ class SceneQueryController extends SceneObjectBase {
2154
+ constructor() {
2155
+ super({ isRunning: false });
2156
+ this.isQueryController = true;
2157
+ __privateAdd$2(this, _running, /* @__PURE__ */ new Set());
2158
+ this.addActivationHandler(() => {
2159
+ return () => __privateGet$2(this, _running).clear();
2484
2160
  });
2485
- });
2161
+ }
2162
+ queryStarted(entry) {
2163
+ __privateGet$2(this, _running).add(entry);
2164
+ this.changeRunningQueryCount(1);
2165
+ if (!this.state.isRunning) {
2166
+ this.setState({ isRunning: true });
2167
+ }
2168
+ }
2169
+ queryCompleted(entry) {
2170
+ if (!__privateGet$2(this, _running).has(entry)) {
2171
+ return;
2172
+ }
2173
+ __privateGet$2(this, _running).delete(entry);
2174
+ this.changeRunningQueryCount(-1);
2175
+ if (__privateGet$2(this, _running).size === 0) {
2176
+ this.setState({ isRunning: false });
2177
+ }
2178
+ }
2179
+ changeRunningQueryCount(dir) {
2180
+ var _a;
2181
+ window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
2182
+ }
2183
+ cancelAll() {
2184
+ var _a;
2185
+ for (const entry of __privateGet$2(this, _running).values()) {
2186
+ (_a = entry.cancel) == null ? void 0 : _a.call(entry);
2187
+ }
2188
+ }
2189
+ }
2190
+ _running = new WeakMap();
2191
+
2192
+ function writeSceneLog(logger, message, ...rest) {
2193
+ let loggingEnabled = false;
2194
+ if (typeof window !== "undefined") {
2195
+ loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
2196
+ }
2197
+ if (loggingEnabled) {
2198
+ console.log(`${logger}: `, message, ...rest);
2199
+ }
2486
2200
  }
2487
2201
 
2488
2202
  async function getDataSource(datasource, scopedVars) {
@@ -2495,21 +2209,7 @@ async function getDataSource(datasource, scopedVars) {
2495
2209
  if (datasource && datasource.query) {
2496
2210
  return datasource;
2497
2211
  }
2498
- const dsPromise = runtime.getDataSourceSrv().get(datasource, scopedVars);
2499
- if (scopedVars.__sceneObject && scopedVars.__sceneObject.value.valueOf()) {
2500
- const queryControler = sceneGraph.getQueryController(scopedVars.__sceneObject.value.valueOf());
2501
- if (queryControler && queryControler.state.enableProfiling) {
2502
- wrapPromiseInStateObservable(dsPromise).pipe(
2503
- registerQueryWithController({
2504
- type: "plugin",
2505
- origin: scopedVars.__sceneObject.value.valueOf()
2506
- })
2507
- ).subscribe(() => {
2508
- });
2509
- }
2510
- }
2511
- const result = await dsPromise;
2512
- return result;
2212
+ return await runtime.getDataSourceSrv().get(datasource, scopedVars);
2513
2213
  }
2514
2214
 
2515
2215
  class VariableValueRecorder {
@@ -2643,6 +2343,7 @@ var __spreadValues$G = (a, b) => {
2643
2343
  return a;
2644
2344
  };
2645
2345
  var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
2346
+ const GLOBAL_ANNOTATION_ID = 0;
2646
2347
  function filterAnnotations(data, filters) {
2647
2348
  var _a;
2648
2349
  if (!Array.isArray(data) || data.length === 0) {
@@ -2660,11 +2361,11 @@ function filterAnnotations(data, filters) {
2660
2361
  const sourceField = frame.fields.find((f) => f.name === "source");
2661
2362
  if (sourceField) {
2662
2363
  if (panelIdField && sourceField.values[index].type === "dashboard") {
2663
- matching = panelIdField.values[index] === filters.panelId;
2364
+ matching = [filters.panelId, GLOBAL_ANNOTATION_ID].includes(panelIdField.values[index]);
2664
2365
  }
2665
2366
  const sourceFilter = sourceField.values[index].filter;
2666
2367
  if (sourceFilter) {
2667
- const includes = ((_a = sourceFilter.ids) != null ? _a : []).includes(filters.panelId);
2368
+ const includes = [...(_a = sourceFilter.ids) != null ? _a : [], GLOBAL_ANNOTATION_ID].includes(filters.panelId);
2668
2369
  if (sourceFilter.exclude) {
2669
2370
  if (includes) {
2670
2371
  matching = false;
@@ -2757,6 +2458,41 @@ function findActiveAdHocFilterVariableByUid(dsUid) {
2757
2458
  return void 0;
2758
2459
  }
2759
2460
 
2461
+ function registerQueryWithController(entry) {
2462
+ return (queryStream) => {
2463
+ const queryControler = sceneGraph.getQueryController(entry.origin);
2464
+ if (!queryControler) {
2465
+ return queryStream;
2466
+ }
2467
+ return new rxjs.Observable((observer) => {
2468
+ if (!entry.cancel) {
2469
+ entry.cancel = () => observer.complete();
2470
+ }
2471
+ queryControler.queryStarted(entry);
2472
+ let markedAsCompleted = false;
2473
+ const sub = queryStream.subscribe({
2474
+ next: (v) => {
2475
+ if (!markedAsCompleted && v.state !== schema.LoadingState.Loading) {
2476
+ markedAsCompleted = true;
2477
+ queryControler.queryCompleted(entry);
2478
+ }
2479
+ observer.next(v);
2480
+ },
2481
+ error: (e) => observer.error(e),
2482
+ complete: () => {
2483
+ observer.complete();
2484
+ }
2485
+ });
2486
+ return () => {
2487
+ sub.unsubscribe();
2488
+ if (!markedAsCompleted) {
2489
+ queryControler.queryCompleted(entry);
2490
+ }
2491
+ };
2492
+ });
2493
+ };
2494
+ }
2495
+
2760
2496
  const allActiveGroupByVariables = /* @__PURE__ */ new Set();
2761
2497
  function findActiveGroupByVariablesByUid(dsUid) {
2762
2498
  var _a;
@@ -2768,48 +2504,14 @@ function findActiveGroupByVariablesByUid(dsUid) {
2768
2504
  return void 0;
2769
2505
  }
2770
2506
 
2771
- function getOptionSearcher(options, includeAll) {
2772
- const ufuzzy = new uFuzzy__default["default"]();
2507
+ function getOptionSearcher(options, includeAll = false) {
2773
2508
  let allOptions = options;
2774
- const haystack = [];
2775
- const limit = 1e4;
2776
2509
  if (includeAll) {
2777
2510
  allOptions = [{ value: ALL_VARIABLE_VALUE, label: ALL_VARIABLE_TEXT }, ...allOptions];
2778
2511
  }
2779
- return (search) => {
2780
- if (search === "") {
2781
- if (allOptions.length > limit) {
2782
- return allOptions.slice(0, limit);
2783
- } else {
2784
- return allOptions;
2785
- }
2786
- }
2787
- if (haystack.length === 0) {
2788
- for (let i = 0; i < allOptions.length; i++) {
2789
- haystack.push(allOptions[i].label);
2790
- }
2791
- }
2792
- const [idxs, info, order] = ufuzzy.search(haystack, search);
2793
- const filteredOptions = [];
2794
- if (idxs) {
2795
- for (let i = 0; i < idxs.length; i++) {
2796
- if (info && order) {
2797
- const idx = order[i];
2798
- filteredOptions.push(allOptions[idxs[idx]]);
2799
- } else {
2800
- filteredOptions.push(allOptions[idxs[i]]);
2801
- }
2802
- if (filteredOptions.length > limit) {
2803
- return filteredOptions;
2804
- }
2805
- }
2806
- return filteredOptions;
2807
- }
2808
- if (allOptions.length > limit) {
2809
- return allOptions.slice(0, limit);
2810
- }
2811
- return allOptions;
2812
- };
2512
+ const haystack = allOptions.map((o) => o.label);
2513
+ const fuzzySearch = getFuzzySearcher(haystack);
2514
+ return (search) => fuzzySearch(search).map((i) => allOptions[i]);
2813
2515
  }
2814
2516
 
2815
2517
  var __defProp$F = Object.defineProperty;
@@ -2865,7 +2567,6 @@ function VariableValueSelect({ model }) {
2865
2567
  const [inputValue, setInputValue] = React.useState("");
2866
2568
  const [hasCustomValue, setHasCustomValue] = React.useState(false);
2867
2569
  const selectValue = toSelectableValue$2(value, String(text));
2868
- const queryController = sceneGraph.getQueryController(model);
2869
2570
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2870
2571
  const onInputChange = (value2, { action }) => {
2871
2572
  if (action === "input-change") {
@@ -2905,7 +2606,6 @@ function VariableValueSelect({ model }) {
2905
2606
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
2906
2607
  onChange: (newValue) => {
2907
2608
  model.changeValueTo(newValue.value, newValue.label);
2908
- queryController == null ? void 0 : queryController.startProfile(model);
2909
2609
  if (hasCustomValue !== newValue.__isNew__) {
2910
2610
  setHasCustomValue(newValue.__isNew__);
2911
2611
  }
@@ -2917,7 +2617,6 @@ function VariableValueSelectMulti({ model }) {
2917
2617
  const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
2918
2618
  const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
2919
2619
  const [inputValue, setInputValue] = React.useState("");
2920
- const queryController = sceneGraph.getQueryController(model);
2921
2620
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2922
2621
  React.useEffect(() => {
2923
2622
  setUncommittedValue(arrayValue);
@@ -2963,7 +2662,6 @@ function VariableValueSelectMulti({ model }) {
2963
2662
  onInputChange,
2964
2663
  onBlur: () => {
2965
2664
  model.changeValueTo(uncommittedValue);
2966
- queryController == null ? void 0 : queryController.startProfile(model);
2967
2665
  },
2968
2666
  filterOption: filterNoOp$2,
2969
2667
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
@@ -3502,44 +3200,12 @@ const getStyles$f = (theme) => ({
3502
3200
  });
3503
3201
 
3504
3202
  function getAdhocOptionSearcher(options) {
3505
- const ufuzzy = new uFuzzy__default["default"]();
3506
- const haystack = [];
3507
- const limit = 1e4;
3508
- return (search) => {
3203
+ const haystack = options.map((o) => {
3509
3204
  var _a;
3510
- if (search === "") {
3511
- if (options.length > limit) {
3512
- return options.slice(0, limit);
3513
- } else {
3514
- return options;
3515
- }
3516
- }
3517
- if (haystack.length === 0) {
3518
- for (let i = 0; i < options.length; i++) {
3519
- haystack.push((_a = options[i].label) != null ? _a : String(options[i].value));
3520
- }
3521
- }
3522
- const [idxs, info, order] = ufuzzy.search(haystack, search);
3523
- const filteredOptions = [];
3524
- if (idxs) {
3525
- for (let i = 0; i < idxs.length; i++) {
3526
- if (info && order) {
3527
- const idx = order[i];
3528
- filteredOptions.push(options[idxs[idx]]);
3529
- } else {
3530
- filteredOptions.push(options[idxs[i]]);
3531
- }
3532
- if (filteredOptions.length > limit) {
3533
- return filteredOptions;
3534
- }
3535
- }
3536
- return filteredOptions;
3537
- }
3538
- if (options.length > limit) {
3539
- return options.slice(0, limit);
3540
- }
3541
- return options;
3542
- };
3205
+ return (_a = o.label) != null ? _a : String(o.value);
3206
+ });
3207
+ const fuzzySearch = getFuzzySearcher(haystack);
3208
+ return (search) => fuzzySearch(search).map((i) => options[i]);
3543
3209
  }
3544
3210
 
3545
3211
  var __defProp$D = Object.defineProperty;
@@ -3577,12 +3243,10 @@ function AdHocFilterRenderer({ filter, model }) {
3577
3243
  const [isOperatorOpen, setIsOperatorOpen] = React.useState(false);
3578
3244
  const [valueInputValue, setValueInputValue] = React.useState("");
3579
3245
  const [valueHasCustomValue, setValueHasCustomValue] = React.useState(false);
3580
- const [uncommittedValue, setUncommittedValue] = React.useState(
3581
- filter.values ? filter.values.map((value, index) => {
3582
- var _a2;
3583
- return keyLabelToOption(value, (_a2 = filter.valueLabels) == null ? void 0 : _a2[index]);
3584
- }) : []
3585
- );
3246
+ const [uncommittedValue, setUncommittedValue] = React.useState(filter.values ? filter.values.map((value, index) => {
3247
+ var _a2;
3248
+ return keyLabelToOption(value, (_a2 = filter.valueLabels) == null ? void 0 : _a2[index]);
3249
+ }) : []);
3586
3250
  const isMultiValue = isMultiValueOperator(filter.operator);
3587
3251
  const keyValue = keyLabelToOption(filter.key, filter.keyLabel);
3588
3252
  const valueValue = keyLabelToOption(filter.value, (_a = filter.valueLabels) == null ? void 0 : _a[0]);
@@ -3605,12 +3269,10 @@ function AdHocFilterRenderer({ filter, model }) {
3605
3269
  setUncommittedValue([]);
3606
3270
  } else if (!isMultiValueOperator(existingOperator) && isMultiValueOperator(newOperator) && filter.value) {
3607
3271
  update.values = [filter.value];
3608
- setUncommittedValue([
3609
- {
3610
- value: filter.value,
3611
- label: (_b2 = (_a2 = filter.valueLabels) == null ? void 0 : _a2[0]) != null ? _b2 : filter.value
3612
- }
3613
- ]);
3272
+ setUncommittedValue([{
3273
+ value: filter.value,
3274
+ label: (_b2 = (_a2 = filter.valueLabels) == null ? void 0 : _a2[0]) != null ? _b2 : filter.value
3275
+ }]);
3614
3276
  }
3615
3277
  model._updateFilter(filter, update);
3616
3278
  };
@@ -3889,7 +3551,10 @@ function deserializeUrlToFilters(value) {
3889
3551
  }
3890
3552
  function toArray(filter) {
3891
3553
  var _a;
3892
- const result = [toUrlCommaDelimitedString(filter.key, filter.keyLabel), filter.operator];
3554
+ const result = [
3555
+ toUrlCommaDelimitedString(filter.key, filter.keyLabel),
3556
+ filter.operator
3557
+ ];
3893
3558
  if (isMultiValueOperator(filter.operator)) {
3894
3559
  filter.values.forEach((value, index) => {
3895
3560
  var _a2;
@@ -4066,55 +3731,16 @@ const VIRTUAL_LIST_ITEM_HEIGHT = 38;
4066
3731
  const VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION = 60;
4067
3732
  const ERROR_STATE_DROPDOWN_WIDTH = 366;
4068
3733
  function fuzzySearchOptions(options) {
4069
- const ufuzzy = new uFuzzy__default["default"]();
4070
- const haystack = [];
4071
- const limit = 1e4;
4072
- return (search, filterInputType) => {
3734
+ const haystack = options.map((o) => {
4073
3735
  var _a;
4074
- if (search === "") {
4075
- if (options.length > limit) {
4076
- return options.slice(0, limit);
4077
- } else {
4078
- return options;
4079
- }
4080
- }
4081
- if (filterInputType === "operator") {
4082
- const filteredOperators = [];
4083
- for (let i = 0; i < options.length; i++) {
4084
- if ((_a = options[i].label || options[i].value) == null ? void 0 : _a.includes(search)) {
4085
- filteredOperators.push(options[i]);
4086
- if (filteredOperators.length > limit) {
4087
- return filteredOperators;
4088
- }
4089
- }
4090
- }
4091
- return filteredOperators;
4092
- }
4093
- if (haystack.length === 0) {
4094
- for (let i = 0; i < options.length; i++) {
4095
- haystack.push(options[i].label || options[i].value);
4096
- }
4097
- }
4098
- const [idxs, info, order] = ufuzzy.search(haystack, search);
4099
- const filteredOptions = [];
4100
- if (idxs) {
4101
- for (let i = 0; i < idxs.length; i++) {
4102
- if (info && order) {
4103
- const idx = order[i];
4104
- filteredOptions.push(options[idxs[idx]]);
4105
- } else {
4106
- filteredOptions.push(options[idxs[i]]);
4107
- }
4108
- if (filteredOptions.length > limit) {
4109
- return filteredOptions;
4110
- }
4111
- }
4112
- return filteredOptions;
4113
- }
4114
- if (options.length > limit) {
4115
- return options.slice(0, limit);
3736
+ return (_a = o.label) != null ? _a : o.value;
3737
+ });
3738
+ const fuzzySearch = getFuzzySearcher(haystack);
3739
+ return (search, filterInputType) => {
3740
+ if (filterInputType === "operator" && search !== "") {
3741
+ search = `"${search}"`;
4116
3742
  }
4117
- return options;
3743
+ return fuzzySearch(search).map((i) => options[i]);
4118
3744
  };
4119
3745
  }
4120
3746
  const flattenOptionGroups = (options) => options.flatMap((option) => option.options ? [option, ...option.options] : [option]);
@@ -5616,7 +5242,9 @@ class SceneQueryRunner extends SceneObjectBase {
5616
5242
  })
5617
5243
  );
5618
5244
  }
5619
- this.subscribeToTimeRangeChanges(timeRange);
5245
+ this.subscribeToTimeRangeChanges(
5246
+ timeRange
5247
+ );
5620
5248
  if (this.shouldRunQueriesOnActivate()) {
5621
5249
  this.runQueries();
5622
5250
  }
@@ -6135,6 +5763,27 @@ function handleOptionGroups(values) {
6135
5763
  }
6136
5764
  return result;
6137
5765
  }
5766
+ function getFuzzySearcher(haystack, limit = 1e4) {
5767
+ const ufuzzy = new uFuzzy__default["default"]();
5768
+ const FIRST = Array.from({ length: Math.min(limit, haystack.length) }, (_, i) => i);
5769
+ return (search) => {
5770
+ if (search === "") {
5771
+ return FIRST;
5772
+ }
5773
+ const [idxs, info, order] = ufuzzy.search(haystack, search);
5774
+ if (idxs) {
5775
+ if (info && order) {
5776
+ const outIdxs = Array(Math.min(order.length, limit));
5777
+ for (let i = 0; i < outIdxs.length; i++) {
5778
+ outIdxs[i] = info.idx[order[i]];
5779
+ }
5780
+ return outIdxs;
5781
+ }
5782
+ return idxs.slice(0, limit);
5783
+ }
5784
+ return [];
5785
+ };
5786
+ }
6138
5787
 
6139
5788
  var __defProp$w = Object.defineProperty;
6140
5789
  var __defProps$k = Object.defineProperties;
@@ -6930,6 +6579,30 @@ function findDescendents(scene, descendentType) {
6930
6579
  const targetScenes = findAllObjects(scene, isDescendentType);
6931
6580
  return targetScenes.filter(isDescendentType);
6932
6581
  }
6582
+ function getQueryController(sceneObject) {
6583
+ let parent = sceneObject;
6584
+ while (parent) {
6585
+ if (parent.state.$behaviors) {
6586
+ for (const behavior of parent.state.$behaviors) {
6587
+ if (isQueryController(behavior)) {
6588
+ return behavior;
6589
+ }
6590
+ }
6591
+ }
6592
+ parent = parent.parent;
6593
+ }
6594
+ return void 0;
6595
+ }
6596
+ function getUrlSyncManager(sceneObject) {
6597
+ let parent = sceneObject;
6598
+ while (parent) {
6599
+ if ("urlSyncManager" in parent.state) {
6600
+ return parent.state.urlSyncManager;
6601
+ }
6602
+ parent = parent.parent;
6603
+ }
6604
+ return void 0;
6605
+ }
6933
6606
 
6934
6607
  const sceneGraph = {
6935
6608
  getVariables,
@@ -6945,8 +6618,9 @@ const sceneGraph = {
6945
6618
  findObject,
6946
6619
  findAllObjects,
6947
6620
  getAncestor,
6621
+ findDescendents,
6948
6622
  getQueryController,
6949
- findDescendents
6623
+ getUrlSyncManager
6950
6624
  };
6951
6625
 
6952
6626
  class UniqueUrlKeyMapper {
@@ -7818,13 +7492,7 @@ class VizPanel extends SceneObjectBase {
7818
7492
  } else {
7819
7493
  const { importPanelPlugin } = runtime.getPluginImportUtils();
7820
7494
  try {
7821
- const panelPromise = importPanelPlugin(pluginId);
7822
- const queryControler = sceneGraph.getQueryController(this);
7823
- if (queryControler && queryControler.state.enableProfiling) {
7824
- wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: "plugin", origin: this })).subscribe(() => {
7825
- });
7826
- }
7827
- const result = await panelPromise;
7495
+ const result = await importPanelPlugin(pluginId);
7828
7496
  this._pluginLoaded(result, overwriteOptions, overwriteFieldConfig, isAfterPluginChange);
7829
7497
  } catch (err) {
7830
7498
  this._pluginLoaded(getPanelPluginNotFound(pluginId));
@@ -7893,7 +7561,11 @@ class VizPanel extends SceneObjectBase {
7893
7561
  }
7894
7562
  async changePluginType(pluginId, newOptions, newFieldConfig) {
7895
7563
  var _a, _b;
7896
- const { options: prevOptions, fieldConfig: prevFieldConfig, pluginId: prevPluginId } = this.state;
7564
+ const {
7565
+ options: prevOptions,
7566
+ fieldConfig: prevFieldConfig,
7567
+ pluginId: prevPluginId
7568
+ } = this.state;
7897
7569
  this._dataWithFieldConfig = void 0;
7898
7570
  const isAfterPluginChange = this.state.pluginId !== pluginId;
7899
7571
  await this._loadPlugin(pluginId, newOptions != null ? newOptions : {}, newFieldConfig, isAfterPluginChange);
@@ -11410,7 +11082,6 @@ class SceneRefreshPicker extends SceneObjectBase {
11410
11082
  this._autoRefreshBlocked = false;
11411
11083
  this.onRefresh = () => {
11412
11084
  const queryController = sceneGraph.getQueryController(this);
11413
- queryController == null ? void 0 : queryController.startProfile(this);
11414
11085
  if (queryController == null ? void 0 : queryController.state.isRunning) {
11415
11086
  queryController.cancelAll();
11416
11087
  return;
@@ -11466,8 +11137,6 @@ class SceneRefreshPicker extends SceneObjectBase {
11466
11137
  }
11467
11138
  this._intervalTimer = setInterval(() => {
11468
11139
  if (this.isTabVisible()) {
11469
- const queryController = sceneGraph.getQueryController(this);
11470
- queryController == null ? void 0 : queryController.startProfile(this);
11471
11140
  timeRange.onRefresh();
11472
11141
  } else {
11473
11142
  this._autoRefreshBlocked = true;
@@ -11541,9 +11210,7 @@ function SceneRefreshPickerRenderer({ model }) {
11541
11210
  tooltip,
11542
11211
  width,
11543
11212
  text,
11544
- onRefresh: () => {
11545
- model.onRefresh();
11546
- },
11213
+ onRefresh: model.onRefresh,
11547
11214
  primary,
11548
11215
  onIntervalChanged: model.onIntervalChanged,
11549
11216
  isLoading: isRunning,