@grafana/scenes 5.23.1--canary.858.11699916776.0 → 5.23.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 +18 -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 -4
  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/registerQueryWithController.js +2 -19
  18. package/dist/esm/querying/registerQueryWithController.js.map +1 -1
  19. package/dist/esm/utils/getDataSource.js +1 -17
  20. package/dist/esm/utils/getDataSource.js.map +1 -1
  21. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js +8 -12
  22. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js.map +1 -1
  23. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js +14 -2
  24. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
  25. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +46 -58
  26. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
  27. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/MultiValuePill.js +114 -0
  28. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/MultiValuePill.js.map +1 -0
  29. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +14 -1
  30. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js.map +1 -1
  31. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js +4 -1
  32. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js.map +1 -1
  33. package/dist/esm/variables/components/VariableValueSelect.js +0 -5
  34. package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
  35. package/dist/esm/variables/utils.js.map +1 -1
  36. package/dist/esm/variables/variants/MultiValueVariable.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 +471 -600
  40. package/dist/index.js.map +1 -1
  41. package/package.json +2 -2
  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
@@ -188,32 +188,32 @@ 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();
@@ -611,184 +611,7 @@ function lookupVariable(name, sceneObject) {
611
611
  return null;
612
612
  }
613
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
614
  var __defProp$K = Object.defineProperty;
790
- var __defProps$u = Object.defineProperties;
791
- var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
792
615
  var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
793
616
  var __hasOwnProp$K = Object.prototype.hasOwnProperty;
794
617
  var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
@@ -804,131 +627,9 @@ var __spreadValues$K = (a, b) => {
804
627
  }
805
628
  return a;
806
629
  };
807
- var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(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$u(__spreadValues$K({}, 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
- }
907
- }
908
- parent = parent.parent;
909
- }
910
- return void 0;
911
- }
912
-
913
- var __defProp$J = Object.defineProperty;
914
- var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
915
- var __hasOwnProp$J = Object.prototype.hasOwnProperty;
916
- var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
917
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
918
- var __spreadValues$J = (a, b) => {
919
- for (var prop in b || (b = {}))
920
- if (__hasOwnProp$J.call(b, prop))
921
- __defNormalProp$J(a, prop, b[prop]);
922
- if (__getOwnPropSymbols$J)
923
- for (var prop of __getOwnPropSymbols$J(b)) {
924
- if (__propIsEnum$J.call(b, prop))
925
- __defNormalProp$J(a, prop, b[prop]);
926
- }
927
- return a;
928
- };
929
630
  class SceneDataNode extends SceneObjectBase {
930
631
  constructor(state) {
931
- super(__spreadValues$J({
632
+ super(__spreadValues$K({
932
633
  data: emptyPanelData
933
634
  }, state));
934
635
  }
@@ -1034,19 +735,19 @@ function isValid$1(value, roundUp, timeZone) {
1034
735
  return parsed.isValid();
1035
736
  }
1036
737
 
1037
- var __defProp$I = Object.defineProperty;
1038
- var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
1039
- var __hasOwnProp$I = Object.prototype.hasOwnProperty;
1040
- var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
1041
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1042
- var __spreadValues$I = (a, b) => {
738
+ var __defProp$J = Object.defineProperty;
739
+ var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
740
+ var __hasOwnProp$J = Object.prototype.hasOwnProperty;
741
+ var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
742
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
743
+ var __spreadValues$J = (a, b) => {
1043
744
  for (var prop in b || (b = {}))
1044
- if (__hasOwnProp$I.call(b, prop))
1045
- __defNormalProp$I(a, prop, b[prop]);
1046
- if (__getOwnPropSymbols$I)
1047
- for (var prop of __getOwnPropSymbols$I(b)) {
1048
- if (__propIsEnum$I.call(b, prop))
1049
- __defNormalProp$I(a, prop, b[prop]);
745
+ if (__hasOwnProp$J.call(b, prop))
746
+ __defNormalProp$J(a, prop, b[prop]);
747
+ if (__getOwnPropSymbols$J)
748
+ for (var prop of __getOwnPropSymbols$J(b)) {
749
+ if (__propIsEnum$J.call(b, prop))
750
+ __defNormalProp$J(a, prop, b[prop]);
1050
751
  }
1051
752
  return a;
1052
753
  };
@@ -1064,7 +765,7 @@ class SceneTimeRange extends SceneObjectBase {
1064
765
  state.UNSAFE_nowDelay
1065
766
  );
1066
767
  const refreshOnActivate = (_a = state.refreshOnActivate) != null ? _a : { percent: 10 };
1067
- super(__spreadValues$I({ from, to, timeZone, value, refreshOnActivate }, state));
768
+ super(__spreadValues$J({ from, to, timeZone, value, refreshOnActivate }, state));
1068
769
  this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["from", "to", "timezone", "time", "time.window"] });
1069
770
  this.onTimeRangeChange = (timeRange) => {
1070
771
  const update = {};
@@ -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
  });
@@ -2050,25 +1749,25 @@ function collectAllVariables(sceneObject, record = {}) {
2050
1749
  return record;
2051
1750
  }
2052
1751
 
2053
- var __defProp$H = Object.defineProperty;
2054
- var __defProps$t = Object.defineProperties;
2055
- var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
2056
- var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
2057
- var __hasOwnProp$H = Object.prototype.hasOwnProperty;
2058
- var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
2059
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2060
- var __spreadValues$H = (a, b) => {
1752
+ var __defProp$I = Object.defineProperty;
1753
+ var __defProps$u = Object.defineProperties;
1754
+ var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
1755
+ var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
1756
+ var __hasOwnProp$I = Object.prototype.hasOwnProperty;
1757
+ var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
1758
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1759
+ var __spreadValues$I = (a, b) => {
2061
1760
  for (var prop in b || (b = {}))
2062
- if (__hasOwnProp$H.call(b, prop))
2063
- __defNormalProp$H(a, prop, b[prop]);
2064
- if (__getOwnPropSymbols$H)
2065
- for (var prop of __getOwnPropSymbols$H(b)) {
2066
- if (__propIsEnum$H.call(b, prop))
2067
- __defNormalProp$H(a, prop, b[prop]);
1761
+ if (__hasOwnProp$I.call(b, prop))
1762
+ __defNormalProp$I(a, prop, b[prop]);
1763
+ if (__getOwnPropSymbols$I)
1764
+ for (var prop of __getOwnPropSymbols$I(b)) {
1765
+ if (__propIsEnum$I.call(b, prop))
1766
+ __defNormalProp$I(a, prop, b[prop]);
2068
1767
  }
2069
1768
  return a;
2070
1769
  };
2071
- var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
1770
+ var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
2072
1771
  function getTemplateProxyForField(field, frame, frames) {
2073
1772
  return new Proxy(
2074
1773
  {},
@@ -2084,7 +1783,7 @@ function getTemplateProxyForField(field, frame, frames) {
2084
1783
  if (!field.labels) {
2085
1784
  return "";
2086
1785
  }
2087
- return __spreadProps$t(__spreadValues$H({}, field.labels), {
1786
+ return __spreadProps$u(__spreadValues$I({}, field.labels), {
2088
1787
  __values: Object.values(field.labels).sort().join(", "),
2089
1788
  toString: () => {
2090
1789
  return data.formatLabels(field.labels, "", true);
@@ -2432,56 +2131,70 @@ function isDataLayer(obj) {
2432
2131
  return "isDataLayer" in obj;
2433
2132
  }
2434
2133
 
2435
- function registerQueryWithController(entry) {
2436
- return (queryStream) => {
2437
- const queryControler = sceneGraph.getQueryController(entry.origin);
2438
- if (!queryControler) {
2439
- return queryStream;
2440
- }
2441
- return new rxjs.Observable((observer) => {
2442
- if (!entry.cancel) {
2443
- entry.cancel = () => observer.complete();
2444
- }
2445
- queryControler.queryStarted(entry);
2446
- let markedAsCompleted = false;
2447
- const sub = queryStream.subscribe({
2448
- next: (v) => {
2449
- if (!markedAsCompleted && v.state !== schema.LoadingState.Loading) {
2450
- markedAsCompleted = true;
2451
- queryControler.queryCompleted(entry);
2452
- }
2453
- observer.next(v);
2454
- },
2455
- error: (e) => observer.error(e),
2456
- complete: () => {
2457
- observer.complete();
2458
- }
2459
- });
2460
- return () => {
2461
- sub.unsubscribe();
2462
- if (!markedAsCompleted) {
2463
- queryControler.queryCompleted(entry);
2464
- }
2465
- };
2466
- });
2467
- };
2134
+ var __accessCheck$2 = (obj, member, msg) => {
2135
+ if (!member.has(obj))
2136
+ throw TypeError("Cannot " + msg);
2137
+ };
2138
+ var __privateGet$2 = (obj, member, getter) => {
2139
+ __accessCheck$2(obj, member, "read from private field");
2140
+ return getter ? getter.call(obj) : member.get(obj);
2141
+ };
2142
+ var __privateAdd$2 = (obj, member, value) => {
2143
+ if (member.has(obj))
2144
+ throw TypeError("Cannot add the same private member more than once");
2145
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2146
+ };
2147
+ var _running;
2148
+ function isQueryController(s) {
2149
+ return "isQueryController" in s;
2468
2150
  }
2469
- function wrapPromiseInStateObservable(promise) {
2470
- console.log("wrapPromiseInStateObservable", promise);
2471
- return new rxjs.Observable((observer) => {
2472
- observer.next({ state: schema.LoadingState.Loading });
2473
- const promiseObservable = rxjs.from(promise);
2474
- promiseObservable.pipe(
2475
- rxjs.map(() => ({ state: schema.LoadingState.Done })),
2476
- rxjs.catchError(() => {
2477
- observer.next({ state: schema.LoadingState.Error });
2478
- return [];
2479
- })
2480
- ).subscribe({
2481
- next: (result) => observer.next(result),
2482
- complete: () => observer.complete()
2151
+ class SceneQueryController extends SceneObjectBase {
2152
+ constructor() {
2153
+ super({ isRunning: false });
2154
+ this.isQueryController = true;
2155
+ __privateAdd$2(this, _running, /* @__PURE__ */ new Set());
2156
+ this.addActivationHandler(() => {
2157
+ return () => __privateGet$2(this, _running).clear();
2483
2158
  });
2484
- });
2159
+ }
2160
+ queryStarted(entry) {
2161
+ __privateGet$2(this, _running).add(entry);
2162
+ this.changeRunningQueryCount(1);
2163
+ if (!this.state.isRunning) {
2164
+ this.setState({ isRunning: true });
2165
+ }
2166
+ }
2167
+ queryCompleted(entry) {
2168
+ if (!__privateGet$2(this, _running).has(entry)) {
2169
+ return;
2170
+ }
2171
+ __privateGet$2(this, _running).delete(entry);
2172
+ this.changeRunningQueryCount(-1);
2173
+ if (__privateGet$2(this, _running).size === 0) {
2174
+ this.setState({ isRunning: false });
2175
+ }
2176
+ }
2177
+ changeRunningQueryCount(dir) {
2178
+ var _a;
2179
+ window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
2180
+ }
2181
+ cancelAll() {
2182
+ var _a;
2183
+ for (const entry of __privateGet$2(this, _running).values()) {
2184
+ (_a = entry.cancel) == null ? void 0 : _a.call(entry);
2185
+ }
2186
+ }
2187
+ }
2188
+ _running = new WeakMap();
2189
+
2190
+ function writeSceneLog(logger, message, ...rest) {
2191
+ let loggingEnabled = false;
2192
+ if (typeof window !== "undefined") {
2193
+ loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
2194
+ }
2195
+ if (loggingEnabled) {
2196
+ console.log(`${logger}: `, message, ...rest);
2197
+ }
2485
2198
  }
2486
2199
 
2487
2200
  async function getDataSource(datasource, scopedVars) {
@@ -2494,21 +2207,7 @@ async function getDataSource(datasource, scopedVars) {
2494
2207
  if (datasource && datasource.query) {
2495
2208
  return datasource;
2496
2209
  }
2497
- const dsPromise = runtime.getDataSourceSrv().get(datasource, scopedVars);
2498
- if (scopedVars.__sceneObject && scopedVars.__sceneObject.value.valueOf()) {
2499
- const queryControler = sceneGraph.getQueryController(scopedVars.__sceneObject.value.valueOf());
2500
- if (queryControler && queryControler.state.enableProfiling) {
2501
- wrapPromiseInStateObservable(dsPromise).pipe(
2502
- registerQueryWithController({
2503
- type: "plugin",
2504
- origin: scopedVars.__sceneObject.value.valueOf()
2505
- })
2506
- ).subscribe(() => {
2507
- });
2508
- }
2509
- }
2510
- const result = await dsPromise;
2511
- return result;
2210
+ return await runtime.getDataSourceSrv().get(datasource, scopedVars);
2512
2211
  }
2513
2212
 
2514
2213
  class VariableValueRecorder {
@@ -2581,25 +2280,25 @@ function isExtraQueryProvider(obj) {
2581
2280
  return typeof obj === "object" && "getExtraQueries" in obj;
2582
2281
  }
2583
2282
 
2584
- var __defProp$G = Object.defineProperty;
2585
- var __defProps$s = Object.defineProperties;
2586
- var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
2587
- var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
2588
- var __hasOwnProp$G = Object.prototype.hasOwnProperty;
2589
- var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
2590
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2591
- var __spreadValues$G = (a, b) => {
2283
+ var __defProp$H = Object.defineProperty;
2284
+ var __defProps$t = Object.defineProperties;
2285
+ var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
2286
+ var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
2287
+ var __hasOwnProp$H = Object.prototype.hasOwnProperty;
2288
+ var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
2289
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2290
+ var __spreadValues$H = (a, b) => {
2592
2291
  for (var prop in b || (b = {}))
2593
- if (__hasOwnProp$G.call(b, prop))
2594
- __defNormalProp$G(a, prop, b[prop]);
2595
- if (__getOwnPropSymbols$G)
2596
- for (var prop of __getOwnPropSymbols$G(b)) {
2597
- if (__propIsEnum$G.call(b, prop))
2598
- __defNormalProp$G(a, prop, b[prop]);
2292
+ if (__hasOwnProp$H.call(b, prop))
2293
+ __defNormalProp$H(a, prop, b[prop]);
2294
+ if (__getOwnPropSymbols$H)
2295
+ for (var prop of __getOwnPropSymbols$H(b)) {
2296
+ if (__propIsEnum$H.call(b, prop))
2297
+ __defNormalProp$H(a, prop, b[prop]);
2599
2298
  }
2600
2299
  return a;
2601
2300
  };
2602
- var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
2301
+ var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
2603
2302
  const passthroughProcessor = (_, secondary) => rxjs.of(secondary);
2604
2303
  const extraQueryProcessingOperator = (processors) => (data) => {
2605
2304
  return data.pipe(
@@ -2612,7 +2311,7 @@ const extraQueryProcessingOperator = (processors) => (data) => {
2612
2311
  }),
2613
2312
  rxjs.map(([primary, ...processedSecondaries]) => {
2614
2313
  var _a;
2615
- return __spreadProps$s(__spreadValues$G({}, primary), {
2314
+ return __spreadProps$t(__spreadValues$H({}, primary), {
2616
2315
  series: [...primary.series, ...processedSecondaries.flatMap((s) => s.series)],
2617
2316
  annotations: [...(_a = primary.annotations) != null ? _a : [], ...processedSecondaries.flatMap((s) => {
2618
2317
  var _a2;
@@ -2623,25 +2322,25 @@ const extraQueryProcessingOperator = (processors) => (data) => {
2623
2322
  );
2624
2323
  };
2625
2324
 
2626
- var __defProp$F = Object.defineProperty;
2627
- var __defProps$r = Object.defineProperties;
2628
- var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
2629
- var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
2630
- var __hasOwnProp$F = Object.prototype.hasOwnProperty;
2631
- var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
2632
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2633
- var __spreadValues$F = (a, b) => {
2325
+ var __defProp$G = Object.defineProperty;
2326
+ var __defProps$s = Object.defineProperties;
2327
+ var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
2328
+ var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
2329
+ var __hasOwnProp$G = Object.prototype.hasOwnProperty;
2330
+ var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
2331
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2332
+ var __spreadValues$G = (a, b) => {
2634
2333
  for (var prop in b || (b = {}))
2635
- if (__hasOwnProp$F.call(b, prop))
2636
- __defNormalProp$F(a, prop, b[prop]);
2637
- if (__getOwnPropSymbols$F)
2638
- for (var prop of __getOwnPropSymbols$F(b)) {
2639
- if (__propIsEnum$F.call(b, prop))
2640
- __defNormalProp$F(a, prop, b[prop]);
2334
+ if (__hasOwnProp$G.call(b, prop))
2335
+ __defNormalProp$G(a, prop, b[prop]);
2336
+ if (__getOwnPropSymbols$G)
2337
+ for (var prop of __getOwnPropSymbols$G(b)) {
2338
+ if (__propIsEnum$G.call(b, prop))
2339
+ __defNormalProp$G(a, prop, b[prop]);
2641
2340
  }
2642
2341
  return a;
2643
2342
  };
2644
- var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
2343
+ var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
2645
2344
  function filterAnnotations(data, filters) {
2646
2345
  var _a;
2647
2346
  if (!Array.isArray(data) || data.length === 0) {
@@ -2692,11 +2391,11 @@ function filterAnnotations(data, filters) {
2692
2391
  continue;
2693
2392
  }
2694
2393
  }
2695
- fields.push(__spreadProps$r(__spreadValues$F({}, field), {
2394
+ fields.push(__spreadProps$s(__spreadValues$G({}, field), {
2696
2395
  values: buffer
2697
2396
  }));
2698
2397
  }
2699
- processed.push(__spreadProps$r(__spreadValues$F({}, frame), {
2398
+ processed.push(__spreadProps$s(__spreadValues$G({}, frame), {
2700
2399
  fields,
2701
2400
  length: frameLength
2702
2401
  }));
@@ -2756,6 +2455,41 @@ function findActiveAdHocFilterVariableByUid(dsUid) {
2756
2455
  return void 0;
2757
2456
  }
2758
2457
 
2458
+ function registerQueryWithController(entry) {
2459
+ return (queryStream) => {
2460
+ const queryControler = sceneGraph.getQueryController(entry.origin);
2461
+ if (!queryControler) {
2462
+ return queryStream;
2463
+ }
2464
+ return new rxjs.Observable((observer) => {
2465
+ if (!entry.cancel) {
2466
+ entry.cancel = () => observer.complete();
2467
+ }
2468
+ queryControler.queryStarted(entry);
2469
+ let markedAsCompleted = false;
2470
+ const sub = queryStream.subscribe({
2471
+ next: (v) => {
2472
+ if (!markedAsCompleted && v.state !== schema.LoadingState.Loading) {
2473
+ markedAsCompleted = true;
2474
+ queryControler.queryCompleted(entry);
2475
+ }
2476
+ observer.next(v);
2477
+ },
2478
+ error: (e) => observer.error(e),
2479
+ complete: () => {
2480
+ observer.complete();
2481
+ }
2482
+ });
2483
+ return () => {
2484
+ sub.unsubscribe();
2485
+ if (!markedAsCompleted) {
2486
+ queryControler.queryCompleted(entry);
2487
+ }
2488
+ };
2489
+ });
2490
+ };
2491
+ }
2492
+
2759
2493
  const allActiveGroupByVariables = /* @__PURE__ */ new Set();
2760
2494
  function findActiveGroupByVariablesByUid(dsUid) {
2761
2495
  var _a;
@@ -2811,33 +2545,33 @@ function getOptionSearcher(options, includeAll) {
2811
2545
  };
2812
2546
  }
2813
2547
 
2814
- var __defProp$E = Object.defineProperty;
2815
- var __defProps$q = Object.defineProperties;
2816
- var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
2817
- var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
2818
- var __hasOwnProp$E = Object.prototype.hasOwnProperty;
2819
- var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
2820
- var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2821
- var __spreadValues$E = (a, b) => {
2548
+ var __defProp$F = Object.defineProperty;
2549
+ var __defProps$r = Object.defineProperties;
2550
+ var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
2551
+ var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
2552
+ var __hasOwnProp$F = Object.prototype.hasOwnProperty;
2553
+ var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
2554
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2555
+ var __spreadValues$F = (a, b) => {
2822
2556
  for (var prop in b || (b = {}))
2823
- if (__hasOwnProp$E.call(b, prop))
2824
- __defNormalProp$E(a, prop, b[prop]);
2825
- if (__getOwnPropSymbols$E)
2826
- for (var prop of __getOwnPropSymbols$E(b)) {
2827
- if (__propIsEnum$E.call(b, prop))
2828
- __defNormalProp$E(a, prop, b[prop]);
2557
+ if (__hasOwnProp$F.call(b, prop))
2558
+ __defNormalProp$F(a, prop, b[prop]);
2559
+ if (__getOwnPropSymbols$F)
2560
+ for (var prop of __getOwnPropSymbols$F(b)) {
2561
+ if (__propIsEnum$F.call(b, prop))
2562
+ __defNormalProp$F(a, prop, b[prop]);
2829
2563
  }
2830
2564
  return a;
2831
2565
  };
2832
- var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
2566
+ var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
2833
2567
  var __objRest$4 = (source, exclude) => {
2834
2568
  var target = {};
2835
2569
  for (var prop in source)
2836
- if (__hasOwnProp$E.call(source, prop) && exclude.indexOf(prop) < 0)
2570
+ if (__hasOwnProp$F.call(source, prop) && exclude.indexOf(prop) < 0)
2837
2571
  target[prop] = source[prop];
2838
- if (source != null && __getOwnPropSymbols$E)
2839
- for (var prop of __getOwnPropSymbols$E(source)) {
2840
- if (exclude.indexOf(prop) < 0 && __propIsEnum$E.call(source, prop))
2572
+ if (source != null && __getOwnPropSymbols$F)
2573
+ for (var prop of __getOwnPropSymbols$F(source)) {
2574
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$F.call(source, prop))
2841
2575
  target[prop] = source[prop];
2842
2576
  }
2843
2577
  return target;
@@ -2864,7 +2598,6 @@ function VariableValueSelect({ model }) {
2864
2598
  const [inputValue, setInputValue] = React.useState("");
2865
2599
  const [hasCustomValue, setHasCustomValue] = React.useState(false);
2866
2600
  const selectValue = toSelectableValue$2(value, String(text));
2867
- const queryController = sceneGraph.getQueryController(model);
2868
2601
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2869
2602
  const onInputChange = (value2, { action }) => {
2870
2603
  if (action === "input-change") {
@@ -2904,7 +2637,6 @@ function VariableValueSelect({ model }) {
2904
2637
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
2905
2638
  onChange: (newValue) => {
2906
2639
  model.changeValueTo(newValue.value, newValue.label);
2907
- queryController == null ? void 0 : queryController.startProfile(model);
2908
2640
  if (hasCustomValue !== newValue.__isNew__) {
2909
2641
  setHasCustomValue(newValue.__isNew__);
2910
2642
  }
@@ -2916,7 +2648,6 @@ function VariableValueSelectMulti({ model }) {
2916
2648
  const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
2917
2649
  const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
2918
2650
  const [inputValue, setInputValue] = React.useState("");
2919
- const queryController = sceneGraph.getQueryController(model);
2920
2651
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2921
2652
  React.useEffect(() => {
2922
2653
  setUncommittedValue(arrayValue);
@@ -2962,7 +2693,6 @@ function VariableValueSelectMulti({ model }) {
2962
2693
  onInputChange,
2963
2694
  onBlur: () => {
2964
2695
  model.changeValueTo(uncommittedValue);
2965
- queryController == null ? void 0 : queryController.startProfile(model);
2966
2696
  },
2967
2697
  filterOption: filterNoOp$2,
2968
2698
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
@@ -2989,7 +2719,7 @@ const OptionWithCheckbox = ({
2989
2719
  const theme = ui.useTheme2();
2990
2720
  const selectStyles = ui.getSelectStyles(theme);
2991
2721
  const optionStyles = ui.useStyles2(getOptionStyles);
2992
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$q(__spreadValues$E({
2722
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$r(__spreadValues$F({
2993
2723
  ref: innerRef,
2994
2724
  className: css.cx(selectStyles.option, isFocused && selectStyles.optionFocused)
2995
2725
  }, rest), {
@@ -3154,28 +2884,28 @@ function wrapInSafeSerializableSceneObject(sceneObject) {
3154
2884
  return { value: sceneObject, text: "__sceneObject" };
3155
2885
  }
3156
2886
 
3157
- var __defProp$D = Object.defineProperty;
3158
- var __defProps$p = Object.defineProperties;
3159
- var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
3160
- var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
3161
- var __hasOwnProp$D = Object.prototype.hasOwnProperty;
3162
- var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
3163
- var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3164
- var __spreadValues$D = (a, b) => {
3165
- for (var prop in b || (b = {}))
3166
- if (__hasOwnProp$D.call(b, prop))
3167
- __defNormalProp$D(a, prop, b[prop]);
3168
- if (__getOwnPropSymbols$D)
3169
- for (var prop of __getOwnPropSymbols$D(b)) {
3170
- if (__propIsEnum$D.call(b, prop))
3171
- __defNormalProp$D(a, prop, b[prop]);
2887
+ var __defProp$E = Object.defineProperty;
2888
+ var __defProps$q = Object.defineProperties;
2889
+ var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
2890
+ var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
2891
+ var __hasOwnProp$E = Object.prototype.hasOwnProperty;
2892
+ var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
2893
+ var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2894
+ var __spreadValues$E = (a, b) => {
2895
+ for (var prop in b || (b = {}))
2896
+ if (__hasOwnProp$E.call(b, prop))
2897
+ __defNormalProp$E(a, prop, b[prop]);
2898
+ if (__getOwnPropSymbols$E)
2899
+ for (var prop of __getOwnPropSymbols$E(b)) {
2900
+ if (__propIsEnum$E.call(b, prop))
2901
+ __defNormalProp$E(a, prop, b[prop]);
3172
2902
  }
3173
2903
  return a;
3174
2904
  };
3175
- var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
2905
+ var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
3176
2906
  class GroupByVariable extends MultiValueVariable {
3177
2907
  constructor(initialState) {
3178
- super(__spreadProps$p(__spreadValues$D({
2908
+ super(__spreadProps$q(__spreadValues$E({
3179
2909
  isMulti: true,
3180
2910
  name: "",
3181
2911
  value: [],
@@ -3206,7 +2936,7 @@ class GroupByVariable extends MultiValueVariable {
3206
2936
  const queries = getQueriesForVariables(this);
3207
2937
  const otherFilters = this.state.baseFilters || [];
3208
2938
  const timeRange = sceneGraph.getTimeRange(this).state.value;
3209
- const response = await ds.getTagKeys(__spreadValues$D({
2939
+ const response = await ds.getTagKeys(__spreadValues$E({
3210
2940
  filters: otherFilters,
3211
2941
  queries,
3212
2942
  timeRange
@@ -3401,7 +3131,7 @@ function LoadingIndicator(props) {
3401
3131
  }
3402
3132
 
3403
3133
  function ControlsLabel(props) {
3404
- const styles = ui.useStyles2(getStyles$e);
3134
+ const styles = ui.useStyles2(getStyles$f);
3405
3135
  const theme = ui.useTheme2();
3406
3136
  const isVertical = props.layout === "vertical";
3407
3137
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -3464,7 +3194,7 @@ function ControlsLabel(props) {
3464
3194
  }
3465
3195
  return labelElement;
3466
3196
  }
3467
- const getStyles$e = (theme) => ({
3197
+ const getStyles$f = (theme) => ({
3468
3198
  horizontalLabel: css.css({
3469
3199
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
3470
3200
  display: `flex`,
@@ -3540,19 +3270,19 @@ function getAdhocOptionSearcher(options) {
3540
3270
  };
3541
3271
  }
3542
3272
 
3543
- var __defProp$C = Object.defineProperty;
3544
- var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
3545
- var __hasOwnProp$C = Object.prototype.hasOwnProperty;
3546
- var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
3547
- var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3548
- var __spreadValues$C = (a, b) => {
3273
+ var __defProp$D = Object.defineProperty;
3274
+ var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
3275
+ var __hasOwnProp$D = Object.prototype.hasOwnProperty;
3276
+ var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
3277
+ var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3278
+ var __spreadValues$D = (a, b) => {
3549
3279
  for (var prop in b || (b = {}))
3550
- if (__hasOwnProp$C.call(b, prop))
3551
- __defNormalProp$C(a, prop, b[prop]);
3552
- if (__getOwnPropSymbols$C)
3553
- for (var prop of __getOwnPropSymbols$C(b)) {
3554
- if (__propIsEnum$C.call(b, prop))
3555
- __defNormalProp$C(a, prop, b[prop]);
3280
+ if (__hasOwnProp$D.call(b, prop))
3281
+ __defNormalProp$D(a, prop, b[prop]);
3282
+ if (__getOwnPropSymbols$D)
3283
+ for (var prop of __getOwnPropSymbols$D(b)) {
3284
+ if (__propIsEnum$D.call(b, prop))
3285
+ __defNormalProp$D(a, prop, b[prop]);
3556
3286
  }
3557
3287
  return a;
3558
3288
  };
@@ -3565,7 +3295,7 @@ function keyLabelToOption(key, label) {
3565
3295
  const filterNoOp = () => true;
3566
3296
  function AdHocFilterRenderer({ filter, model }) {
3567
3297
  var _a, _b, _c;
3568
- const styles = ui.useStyles2(getStyles$d);
3298
+ const styles = ui.useStyles2(getStyles$e);
3569
3299
  const [keys, setKeys] = React.useState([]);
3570
3300
  const [values, setValues] = React.useState([]);
3571
3301
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
@@ -3575,12 +3305,10 @@ function AdHocFilterRenderer({ filter, model }) {
3575
3305
  const [isOperatorOpen, setIsOperatorOpen] = React.useState(false);
3576
3306
  const [valueInputValue, setValueInputValue] = React.useState("");
3577
3307
  const [valueHasCustomValue, setValueHasCustomValue] = React.useState(false);
3578
- const [uncommittedValue, setUncommittedValue] = React.useState(
3579
- filter.values ? filter.values.map((value, index) => {
3580
- var _a2;
3581
- return keyLabelToOption(value, (_a2 = filter.valueLabels) == null ? void 0 : _a2[index]);
3582
- }) : []
3583
- );
3308
+ const [uncommittedValue, setUncommittedValue] = React.useState(filter.values ? filter.values.map((value, index) => {
3309
+ var _a2;
3310
+ return keyLabelToOption(value, (_a2 = filter.valueLabels) == null ? void 0 : _a2[index]);
3311
+ }) : []);
3584
3312
  const isMultiValue = isMultiValueOperator(filter.operator);
3585
3313
  const keyValue = keyLabelToOption(filter.key, filter.keyLabel);
3586
3314
  const valueValue = keyLabelToOption(filter.value, (_a = filter.valueLabels) == null ? void 0 : _a[0]);
@@ -3603,12 +3331,10 @@ function AdHocFilterRenderer({ filter, model }) {
3603
3331
  setUncommittedValue([]);
3604
3332
  } else if (!isMultiValueOperator(existingOperator) && isMultiValueOperator(newOperator) && filter.value) {
3605
3333
  update.values = [filter.value];
3606
- setUncommittedValue([
3607
- {
3608
- value: filter.value,
3609
- label: (_b2 = (_a2 = filter.valueLabels) == null ? void 0 : _a2[0]) != null ? _b2 : filter.value
3610
- }
3611
- ]);
3334
+ setUncommittedValue([{
3335
+ value: filter.value,
3336
+ label: (_b2 = (_a2 = filter.valueLabels) == null ? void 0 : _a2[0]) != null ? _b2 : filter.value
3337
+ }]);
3612
3338
  }
3613
3339
  model._updateFilter(filter, update);
3614
3340
  };
@@ -3640,7 +3366,7 @@ function AdHocFilterRenderer({ filter, model }) {
3640
3366
  });
3641
3367
  }
3642
3368
  };
3643
- const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, __spreadValues$C({
3369
+ const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, __spreadValues$D({
3644
3370
  virtualized: true,
3645
3371
  allowCustomValue: true,
3646
3372
  isValidNewOption: (inputValue) => inputValue.trim().length > 0,
@@ -3772,7 +3498,7 @@ function AdHocFilterRenderer({ filter, model }) {
3772
3498
  onClick: () => model._removeFilter(filter)
3773
3499
  }));
3774
3500
  }
3775
- const getStyles$d = (theme) => ({
3501
+ const getStyles$e = (theme) => ({
3776
3502
  field: css.css({
3777
3503
  marginBottom: 0
3778
3504
  }),
@@ -3887,7 +3613,10 @@ function deserializeUrlToFilters(value) {
3887
3613
  }
3888
3614
  function toArray(filter) {
3889
3615
  var _a;
3890
- const result = [toUrlCommaDelimitedString(filter.key, filter.keyLabel), filter.operator];
3616
+ const result = [
3617
+ toUrlCommaDelimitedString(filter.key, filter.keyLabel),
3618
+ filter.operator
3619
+ ];
3891
3620
  if (isMultiValueOperator(filter.operator)) {
3892
3621
  filter.values.forEach((value, index) => {
3893
3622
  var _a2;
@@ -3921,30 +3650,30 @@ function isFilter(filter) {
3921
3650
  return filter !== null && typeof filter.key === "string" && typeof filter.value === "string";
3922
3651
  }
3923
3652
 
3924
- var __defProp$B = Object.defineProperty;
3925
- var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
3926
- var __hasOwnProp$B = Object.prototype.hasOwnProperty;
3927
- var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
3928
- var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3929
- var __spreadValues$B = (a, b) => {
3653
+ var __defProp$C = Object.defineProperty;
3654
+ var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
3655
+ var __hasOwnProp$C = Object.prototype.hasOwnProperty;
3656
+ var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
3657
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3658
+ var __spreadValues$C = (a, b) => {
3930
3659
  for (var prop in b || (b = {}))
3931
- if (__hasOwnProp$B.call(b, prop))
3932
- __defNormalProp$B(a, prop, b[prop]);
3933
- if (__getOwnPropSymbols$B)
3934
- for (var prop of __getOwnPropSymbols$B(b)) {
3935
- if (__propIsEnum$B.call(b, prop))
3936
- __defNormalProp$B(a, prop, b[prop]);
3660
+ if (__hasOwnProp$C.call(b, prop))
3661
+ __defNormalProp$C(a, prop, b[prop]);
3662
+ if (__getOwnPropSymbols$C)
3663
+ for (var prop of __getOwnPropSymbols$C(b)) {
3664
+ if (__propIsEnum$C.call(b, prop))
3665
+ __defNormalProp$C(a, prop, b[prop]);
3937
3666
  }
3938
3667
  return a;
3939
3668
  };
3940
3669
  var __objRest$3 = (source, exclude) => {
3941
3670
  var target = {};
3942
3671
  for (var prop in source)
3943
- if (__hasOwnProp$B.call(source, prop) && exclude.indexOf(prop) < 0)
3672
+ if (__hasOwnProp$C.call(source, prop) && exclude.indexOf(prop) < 0)
3944
3673
  target[prop] = source[prop];
3945
- if (source != null && __getOwnPropSymbols$B)
3946
- for (var prop of __getOwnPropSymbols$B(source)) {
3947
- if (exclude.indexOf(prop) < 0 && __propIsEnum$B.call(source, prop))
3674
+ if (source != null && __getOwnPropSymbols$C)
3675
+ for (var prop of __getOwnPropSymbols$C(source)) {
3676
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$C.call(source, prop))
3948
3677
  target[prop] = source[prop];
3949
3678
  }
3950
3679
  return target;
@@ -3952,9 +3681,9 @@ var __objRest$3 = (source, exclude) => {
3952
3681
  const DropdownItem = React.forwardRef(
3953
3682
  function DropdownItem2(_a, ref) {
3954
3683
  var _b = _a, { children, active, addGroupBottomBorder, isMultiValueEdit, checked } = _b, rest = __objRest$3(_b, ["children", "active", "addGroupBottomBorder", "isMultiValueEdit", "checked"]);
3955
- const styles = ui.useStyles2(getStyles$c);
3684
+ const styles = ui.useStyles2(getStyles$d);
3956
3685
  const id = React.useId();
3957
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$B({
3686
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$C({
3958
3687
  ref,
3959
3688
  role: "option",
3960
3689
  id,
@@ -3970,7 +3699,7 @@ const DropdownItem = React.forwardRef(
3970
3699
  }) : null, children)));
3971
3700
  }
3972
3701
  );
3973
- const getStyles$c = (theme) => ({
3702
+ const getStyles$d = (theme) => ({
3974
3703
  option: css.css({
3975
3704
  label: "grafana-select-option",
3976
3705
  top: 0,
@@ -4041,7 +3770,7 @@ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
4041
3770
  }, "An error has occurred fetching labels. Click to retry");
4042
3771
  };
4043
3772
  const MultiValueApplyButton = ({ onApply, floatingElement, maxOptionWidth, menuHeight }) => {
4044
- const styles = ui.useStyles2(getStyles$c);
3773
+ const styles = ui.useStyles2(getStyles$d);
4045
3774
  const floatingElementRect = floatingElement == null ? void 0 : floatingElement.getBoundingClientRect();
4046
3775
  return /* @__PURE__ */ React__default["default"].createElement("div", {
4047
3776
  className: styles.multiValueApplyWrapper,
@@ -4222,6 +3951,19 @@ const generatePlaceholder = (filter, filterInputType, isMultiValueEdit, isAlways
4222
3951
  }
4223
3952
  return filter[filterInputType] && !isAlwaysWip ? `${filter[filterInputType]}` : INPUT_PLACEHOLDER;
4224
3953
  };
3954
+ const populateInputValueOnInputTypeSwitch = ({
3955
+ populateInputOnEdit,
3956
+ item,
3957
+ filterInputType,
3958
+ setInputValue,
3959
+ filter
3960
+ }) => {
3961
+ if (populateInputOnEdit && !isMultiValueOperator(item.value || "") && nextInputTypeMap[filterInputType] === "value") {
3962
+ setInputValue((filter == null ? void 0 : filter.value) || "");
3963
+ } else {
3964
+ setInputValue("");
3965
+ }
3966
+ };
4225
3967
 
4226
3968
  const MAX_MENU_HEIGHT = 300;
4227
3969
  const useFloatingInteractions = ({
@@ -4287,6 +4029,114 @@ const useFloatingInteractions = ({
4287
4029
  };
4288
4030
  };
4289
4031
 
4032
+ var __defProp$B = Object.defineProperty;
4033
+ var __defProps$p = Object.defineProperties;
4034
+ var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
4035
+ var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
4036
+ var __hasOwnProp$B = Object.prototype.hasOwnProperty;
4037
+ var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
4038
+ var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4039
+ var __spreadValues$B = (a, b) => {
4040
+ for (var prop in b || (b = {}))
4041
+ if (__hasOwnProp$B.call(b, prop))
4042
+ __defNormalProp$B(a, prop, b[prop]);
4043
+ if (__getOwnPropSymbols$B)
4044
+ for (var prop of __getOwnPropSymbols$B(b)) {
4045
+ if (__propIsEnum$B.call(b, prop))
4046
+ __defNormalProp$B(a, prop, b[prop]);
4047
+ }
4048
+ return a;
4049
+ };
4050
+ var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
4051
+ const MultiValuePill = ({
4052
+ item,
4053
+ handleRemoveMultiValue,
4054
+ index,
4055
+ handleEditMultiValuePill
4056
+ }) => {
4057
+ var _a, _b;
4058
+ const styles = ui.useStyles2(getStyles$c);
4059
+ const editMultiValuePill = React.useCallback(
4060
+ (e) => {
4061
+ e.stopPropagation();
4062
+ e.preventDefault();
4063
+ handleEditMultiValuePill(item);
4064
+ },
4065
+ [handleEditMultiValuePill, item]
4066
+ );
4067
+ const editMultiValuePillWithKeyboard = React.useCallback(
4068
+ (e) => {
4069
+ if (e.key === "Enter") {
4070
+ editMultiValuePill(e);
4071
+ }
4072
+ },
4073
+ [editMultiValuePill]
4074
+ );
4075
+ const removePillHandler = React.useCallback(
4076
+ (e) => {
4077
+ e.stopPropagation();
4078
+ e.preventDefault();
4079
+ handleRemoveMultiValue(item);
4080
+ },
4081
+ [handleRemoveMultiValue, item]
4082
+ );
4083
+ const removePillHandlerWithKeyboard = React.useCallback(
4084
+ (e) => {
4085
+ if (e.key === "Enter") {
4086
+ removePillHandler(e);
4087
+ }
4088
+ },
4089
+ [removePillHandler]
4090
+ );
4091
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4092
+ className: css.cx(styles.basePill, styles.valuePill),
4093
+ onClick: editMultiValuePill,
4094
+ onKeyDown: editMultiValuePillWithKeyboard,
4095
+ tabIndex: 0,
4096
+ id: `${item.value}-${index}`
4097
+ }, (_a = item.label) != null ? _a : item.value, /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
4098
+ onClick: removePillHandler,
4099
+ onKeyDownCapture: removePillHandlerWithKeyboard,
4100
+ fill: "text",
4101
+ size: "sm",
4102
+ variant: "secondary",
4103
+ className: styles.removeButton,
4104
+ tooltip: `Remove filter value - ${(_b = item.label) != null ? _b : item.value}`
4105
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
4106
+ name: "times",
4107
+ size: "md",
4108
+ id: `${item.value}-${index}-close-icon`
4109
+ })));
4110
+ };
4111
+ const getStyles$c = (theme) => ({
4112
+ basePill: css.css(__spreadProps$p(__spreadValues$B({
4113
+ display: "flex",
4114
+ alignItems: "center",
4115
+ background: theme.colors.action.disabledBackground,
4116
+ border: `1px solid ${theme.colors.border.weak}`,
4117
+ padding: theme.spacing(0.125, 1, 0.125, 1),
4118
+ color: theme.colors.text.primary,
4119
+ overflow: "hidden",
4120
+ whiteSpace: "nowrap",
4121
+ minHeight: theme.spacing(2.75)
4122
+ }, theme.typography.bodySmall), {
4123
+ cursor: "pointer"
4124
+ })),
4125
+ valuePill: css.css({
4126
+ background: theme.colors.action.selected,
4127
+ padding: theme.spacing(0.125, 0, 0.125, 1)
4128
+ }),
4129
+ removeButton: css.css({
4130
+ marginInline: theme.spacing(0.5),
4131
+ height: "100%",
4132
+ padding: 0,
4133
+ cursor: "pointer",
4134
+ "&:hover": {
4135
+ color: theme.colors.text.primary
4136
+ }
4137
+ })
4138
+ });
4139
+
4290
4140
  var __defProp$A = Object.defineProperty;
4291
4141
  var __defProps$o = Object.defineProperties;
4292
4142
  var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
@@ -4306,7 +4156,7 @@ var __spreadValues$A = (a, b) => {
4306
4156
  return a;
4307
4157
  };
4308
4158
  var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
4309
- const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode, focusOnWipInputRef }, parentRef) {
4159
+ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode, focusOnWipInputRef, populateInputOnEdit }, parentRef) {
4310
4160
  var _a, _b, _c;
4311
4161
  const [open, setOpen] = React.useState(false);
4312
4162
  const [options, setOptions] = React.useState([]);
@@ -4393,7 +4243,13 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4393
4243
  ]
4394
4244
  );
4395
4245
  const outsidePressIdsToIgnore = React.useMemo(() => {
4396
- return [operatorIdentifier, ...filterMultiValues.map((item, i) => `${item.value}-${i}`)];
4246
+ return [
4247
+ operatorIdentifier,
4248
+ ...filterMultiValues.reduce(
4249
+ (acc, item, i) => [...acc, `${item.value}-${i}`, `${item.value}-${i}-close-icon`],
4250
+ []
4251
+ )
4252
+ ];
4397
4253
  }, [operatorIdentifier, filterMultiValues]);
4398
4254
  const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
4399
4255
  open,
@@ -4546,6 +4402,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4546
4402
  const selectedItem = filteredDropDownItems[activeIndex];
4547
4403
  if (multiValueEdit) {
4548
4404
  handleLocalMultiValueChange(selectedItem);
4405
+ setInputValue("");
4549
4406
  } else {
4550
4407
  model._updateFilter(
4551
4408
  filter,
@@ -4556,6 +4413,13 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4556
4413
  setFilterMultiValues
4557
4414
  })
4558
4415
  );
4416
+ populateInputValueOnInputTypeSwitch({
4417
+ populateInputOnEdit,
4418
+ item: selectedItem,
4419
+ filterInputType,
4420
+ setInputValue,
4421
+ filter
4422
+ });
4559
4423
  switchToNextInputType(
4560
4424
  filterInputType,
4561
4425
  setInputType,
@@ -4568,7 +4432,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4568
4432
  focusOnWipInputRef == null ? void 0 : focusOnWipInputRef();
4569
4433
  }
4570
4434
  }
4571
- setInputValue("");
4572
4435
  }
4573
4436
  },
4574
4437
  [
@@ -4578,12 +4441,23 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4578
4441
  model,
4579
4442
  filter,
4580
4443
  filterInputType,
4444
+ populateInputOnEdit,
4581
4445
  handleChangeViewMode,
4582
4446
  refs.domReference,
4583
4447
  isLastFilter,
4584
4448
  focusOnWipInputRef
4585
4449
  ]
4586
4450
  );
4451
+ const handleEditMultiValuePill = React.useCallback(
4452
+ (value) => {
4453
+ var _a2;
4454
+ const valueLabel = value.label || value.value;
4455
+ setFilterMultiValues((prev) => prev.filter((item) => item.value !== value.value));
4456
+ setInputValue(valueLabel);
4457
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
4458
+ },
4459
+ [refs.domReference]
4460
+ );
4587
4461
  React.useEffect(() => {
4588
4462
  if (open) {
4589
4463
  handleFetchOptions(filterInputType);
@@ -4592,8 +4466,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4592
4466
  React.useEffect(() => {
4593
4467
  var _a2, _b2;
4594
4468
  if (!isAlwaysWip) {
4595
- setInputType("value");
4596
- setInputValue("");
4597
4469
  if (hasMultiValueOperator && ((_a2 = filter == null ? void 0 : filter.values) == null ? void 0 : _a2.length)) {
4598
4470
  const multiValueOptions = filter.values.reduce(
4599
4471
  (acc, value, i) => {
@@ -4610,6 +4482,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4610
4482
  );
4611
4483
  setFilterMultiValues(multiValueOptions);
4612
4484
  }
4485
+ if (!hasMultiValueOperator && populateInputOnEdit) {
4486
+ setInputValue((filter == null ? void 0 : filter.value) || "");
4487
+ }
4613
4488
  (_b2 = refs.domReference.current) == null ? void 0 : _b2.focus();
4614
4489
  }
4615
4490
  }, []);
@@ -4639,11 +4514,13 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4639
4514
  tabIndex: 0,
4640
4515
  onClick: (event) => {
4641
4516
  event.stopPropagation();
4517
+ setInputValue("");
4642
4518
  switchInputType("operator", setInputType, void 0, refs.domReference.current);
4643
4519
  },
4644
4520
  onKeyDown: (event) => {
4645
4521
  handleShiftTabInput(event, hasMultiValueOperator);
4646
4522
  if (event.key === "Enter") {
4523
+ setInputValue("");
4647
4524
  switchInputType("operator", setInputType, void 0, refs.domReference.current);
4648
4525
  }
4649
4526
  }
@@ -4653,7 +4530,8 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4653
4530
  key: `${item.value}-${i}`,
4654
4531
  item,
4655
4532
  index: i,
4656
- handleRemoveMultiValue
4533
+ handleRemoveMultiValue,
4534
+ handleEditMultiValuePill
4657
4535
  })) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$o(__spreadValues$A({}, getReferenceProps({
4658
4536
  ref: refs.setReference,
4659
4537
  onChange,
@@ -4740,6 +4618,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4740
4618
  event.preventDefault();
4741
4619
  event.stopPropagation();
4742
4620
  handleLocalMultiValueChange(item);
4621
+ setInputValue("");
4743
4622
  (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
4744
4623
  } else {
4745
4624
  model._updateFilter(
@@ -4751,7 +4630,13 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4751
4630
  setFilterMultiValues
4752
4631
  })
4753
4632
  );
4754
- setInputValue("");
4633
+ populateInputValueOnInputTypeSwitch({
4634
+ populateInputOnEdit,
4635
+ item,
4636
+ filterInputType,
4637
+ setInputValue,
4638
+ filter
4639
+ });
4755
4640
  switchToNextInputType(
4756
4641
  filterInputType,
4757
4642
  setInputType,
@@ -4784,35 +4669,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4784
4669
  menuHeight: Math.min(rowVirtualizer.getTotalSize(), MAX_MENU_HEIGHT)
4785
4670
  }) : null))));
4786
4671
  });
4787
- const MultiValuePill = ({ item, handleRemoveMultiValue, index }) => {
4788
- var _a, _b;
4789
- const styles = ui.useStyles2(getStyles$b);
4790
- return /* @__PURE__ */ React__default["default"].createElement("div", {
4791
- className: css.cx(styles.basePill, styles.valuePill)
4792
- }, /* @__PURE__ */ React__default["default"].createElement("span", null, " ", (_a = item.label) != null ? _a : item.value), /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
4793
- onClick: (e) => {
4794
- e.stopPropagation();
4795
- e.preventDefault();
4796
- handleRemoveMultiValue(item);
4797
- },
4798
- onKeyDownCapture: (e) => {
4799
- if (e.key === "Enter") {
4800
- e.preventDefault();
4801
- e.stopPropagation();
4802
- handleRemoveMultiValue(item);
4803
- }
4804
- },
4805
- fill: "text",
4806
- size: "sm",
4807
- variant: "secondary",
4808
- className: styles.removeButton,
4809
- tooltip: `Remove filter value - ${(_b = item.label) != null ? _b : item.value}`
4810
- }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
4811
- name: "times",
4812
- size: "md",
4813
- id: `${item.value}-${index}`
4814
- })));
4815
- };
4816
4672
  const getStyles$b = (theme) => ({
4817
4673
  comboboxWrapper: css.css({
4818
4674
  display: "flex",
@@ -4845,10 +4701,6 @@ const getStyles$b = (theme) => ({
4845
4701
  background: theme.colors.action.hover
4846
4702
  }
4847
4703
  }),
4848
- valuePill: css.css({
4849
- background: theme.colors.action.selected,
4850
- padding: theme.spacing(0.125, 0, 0.125, 1)
4851
- }),
4852
4704
  dropdownWrapper: css.css({
4853
4705
  backgroundColor: theme.colors.background.primary,
4854
4706
  color: theme.colors.text.primary,
@@ -4881,25 +4733,10 @@ const getStyles$b = (theme) => ({
4881
4733
  borderTop: `1px solid ${theme.colors.border.weak}`
4882
4734
  }
4883
4735
  }),
4884
- removeButton: css.css({
4885
- marginInline: theme.spacing(0.5),
4886
- height: "100%",
4887
- padding: 0,
4888
- cursor: "pointer",
4889
- "&:hover": {
4890
- color: theme.colors.text.primary
4891
- }
4892
- }),
4893
4736
  descriptionText: css.css(__spreadProps$o(__spreadValues$A({}, theme.typography.bodySmall), {
4894
4737
  color: theme.colors.text.secondary,
4895
4738
  paddingTop: theme.spacing(0.5)
4896
- })),
4897
- multiValueApply: css.css({
4898
- position: "absolute",
4899
- top: 0,
4900
- left: 0,
4901
- display: "flex"
4902
- })
4739
+ }))
4903
4740
  });
4904
4741
 
4905
4742
  var __defProp$z = Object.defineProperty;
@@ -4927,6 +4764,7 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
4927
4764
  const [viewMode, setViewMode] = React.useState(true);
4928
4765
  const [shouldFocusOnPillWrapper, setShouldFocusOnPillWrapper] = React.useState(false);
4929
4766
  const pillWrapperRef = React.useRef(null);
4767
+ const [populateInputOnEdit, setPopulateInputOnEdit] = React.useState(false);
4930
4768
  const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
4931
4769
  const valueLabel = ((_b = filter.valueLabels) == null ? void 0 : _b.join(", ")) || ((_c = filter.values) == null ? void 0 : _c.join(", ")) || filter.value;
4932
4770
  const handleChangeViewMode = React.useCallback(
@@ -4953,15 +4791,25 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
4953
4791
  model._updateFilter(filter, { forceEdit: void 0 });
4954
4792
  }
4955
4793
  }, [filter, model, viewMode]);
4794
+ React.useEffect(() => {
4795
+ if (viewMode) {
4796
+ setPopulateInputOnEdit((prevValue) => prevValue ? false : prevValue);
4797
+ }
4798
+ }, [viewMode]);
4956
4799
  if (viewMode) {
4957
4800
  const pillText = /* @__PURE__ */ React__default["default"].createElement("span", {
4958
4801
  className: styles.pillText
4959
4802
  }, keyLabel, " ", filter.operator, " ", valueLabel);
4960
4803
  return /* @__PURE__ */ React__default["default"].createElement("div", {
4961
4804
  className: css.cx(styles.combinedFilterPill, { [styles.readOnlyCombinedFilter]: readOnly }),
4962
- onClick: handleChangeViewMode,
4805
+ onClick: (e) => {
4806
+ e.stopPropagation();
4807
+ setPopulateInputOnEdit(true);
4808
+ handleChangeViewMode();
4809
+ },
4963
4810
  onKeyDown: (e) => {
4964
4811
  if (e.key === "Enter") {
4812
+ setPopulateInputOnEdit(true);
4965
4813
  handleChangeViewMode();
4966
4814
  }
4967
4815
  },
@@ -4998,7 +4846,8 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
4998
4846
  filter,
4999
4847
  model,
5000
4848
  handleChangeViewMode,
5001
- focusOnWipInputRef
4849
+ focusOnWipInputRef,
4850
+ populateInputOnEdit
5002
4851
  });
5003
4852
  }
5004
4853
  const getStyles$a = (theme) => ({
@@ -5494,7 +5343,9 @@ class SceneQueryRunner extends SceneObjectBase {
5494
5343
  })
5495
5344
  );
5496
5345
  }
5497
- this.subscribeToTimeRangeChanges(timeRange);
5346
+ this.subscribeToTimeRangeChanges(
5347
+ timeRange
5348
+ );
5498
5349
  if (this.shouldRunQueriesOnActivate()) {
5499
5350
  this.runQueries();
5500
5351
  }
@@ -6746,6 +6597,30 @@ function findDescendents(scene, descendentType) {
6746
6597
  const targetScenes = findAllObjects(scene, isDescendentType);
6747
6598
  return targetScenes.filter(isDescendentType);
6748
6599
  }
6600
+ function getQueryController(sceneObject) {
6601
+ let parent = sceneObject;
6602
+ while (parent) {
6603
+ if (parent.state.$behaviors) {
6604
+ for (const behavior of parent.state.$behaviors) {
6605
+ if (isQueryController(behavior)) {
6606
+ return behavior;
6607
+ }
6608
+ }
6609
+ }
6610
+ parent = parent.parent;
6611
+ }
6612
+ return void 0;
6613
+ }
6614
+ function getUrlSyncManager(sceneObject) {
6615
+ let parent = sceneObject;
6616
+ while (parent) {
6617
+ if ("urlSyncManager" in parent.state) {
6618
+ return parent.state.urlSyncManager;
6619
+ }
6620
+ parent = parent.parent;
6621
+ }
6622
+ return void 0;
6623
+ }
6749
6624
 
6750
6625
  const sceneGraph = {
6751
6626
  getVariables,
@@ -6761,8 +6636,9 @@ const sceneGraph = {
6761
6636
  findObject,
6762
6637
  findAllObjects,
6763
6638
  getAncestor,
6639
+ findDescendents,
6764
6640
  getQueryController,
6765
- findDescendents
6641
+ getUrlSyncManager
6766
6642
  };
6767
6643
 
6768
6644
  class UniqueUrlKeyMapper {
@@ -7634,13 +7510,7 @@ class VizPanel extends SceneObjectBase {
7634
7510
  } else {
7635
7511
  const { importPanelPlugin } = runtime.getPluginImportUtils();
7636
7512
  try {
7637
- const panelPromise = importPanelPlugin(pluginId);
7638
- const queryControler = sceneGraph.getQueryController(this);
7639
- if (queryControler && queryControler.state.enableProfiling) {
7640
- wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: "plugin", origin: this })).subscribe(() => {
7641
- });
7642
- }
7643
- const result = await panelPromise;
7513
+ const result = await importPanelPlugin(pluginId);
7644
7514
  this._pluginLoaded(result, overwriteOptions, overwriteFieldConfig, isAfterPluginChange);
7645
7515
  } catch (err) {
7646
7516
  this._pluginLoaded(getPanelPluginNotFound(pluginId));
@@ -7709,7 +7579,11 @@ class VizPanel extends SceneObjectBase {
7709
7579
  }
7710
7580
  async changePluginType(pluginId, newOptions, newFieldConfig) {
7711
7581
  var _a, _b;
7712
- const { options: prevOptions, fieldConfig: prevFieldConfig, pluginId: prevPluginId } = this.state;
7582
+ const {
7583
+ options: prevOptions,
7584
+ fieldConfig: prevFieldConfig,
7585
+ pluginId: prevPluginId
7586
+ } = this.state;
7713
7587
  this._dataWithFieldConfig = void 0;
7714
7588
  const isAfterPluginChange = this.state.pluginId !== pluginId;
7715
7589
  await this._loadPlugin(pluginId, newOptions != null ? newOptions : {}, newFieldConfig, isAfterPluginChange);
@@ -11183,7 +11057,6 @@ class SceneRefreshPicker extends SceneObjectBase {
11183
11057
  this._autoRefreshBlocked = false;
11184
11058
  this.onRefresh = () => {
11185
11059
  const queryController = sceneGraph.getQueryController(this);
11186
- queryController == null ? void 0 : queryController.startProfile(this);
11187
11060
  if (queryController == null ? void 0 : queryController.state.isRunning) {
11188
11061
  queryController.cancelAll();
11189
11062
  return;
@@ -11312,9 +11185,7 @@ function SceneRefreshPickerRenderer({ model }) {
11312
11185
  tooltip,
11313
11186
  width,
11314
11187
  text,
11315
- onRefresh: () => {
11316
- model.onRefresh();
11317
- },
11188
+ onRefresh: model.onRefresh,
11318
11189
  primary,
11319
11190
  onIntervalChanged: model.onIntervalChanged,
11320
11191
  isLoading: isRunning,