@grafana/scenes 4.26.3--canary.765.9399849393.0 → 4.27.0--canary.766.9367073867.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. package/CHANGELOG.md +0 -29
  2. package/README.md +0 -2
  3. package/dist/esm/components/EmbeddedScene.js +5 -0
  4. package/dist/esm/components/EmbeddedScene.js.map +1 -1
  5. package/dist/esm/components/SceneApp/SceneAppPage.js +5 -0
  6. package/dist/esm/components/SceneApp/SceneAppPage.js.map +1 -1
  7. package/dist/esm/components/SceneApp/SceneAppPageView.js +1 -3
  8. package/dist/esm/components/SceneApp/SceneAppPageView.js.map +1 -1
  9. package/dist/esm/components/SceneTimeRangeCompare.js +1 -55
  10. package/dist/esm/components/SceneTimeRangeCompare.js.map +1 -1
  11. package/dist/esm/components/VizPanel/VizPanel.js +0 -3
  12. package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
  13. package/dist/esm/core/sceneGraph/sceneGraph.js +1 -1
  14. package/dist/esm/core/types.js.map +1 -1
  15. package/dist/esm/index.js +1 -6
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/querying/SceneQueryRunner.js +88 -85
  18. package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
  19. package/dist/esm/querying/timeShiftQueryResponseOperator.js +60 -0
  20. package/dist/esm/querying/timeShiftQueryResponseOperator.js.map +1 -0
  21. package/dist/esm/services/UniqueUrlKeyMapper.js +16 -24
  22. package/dist/esm/services/UniqueUrlKeyMapper.js.map +1 -1
  23. package/dist/esm/services/UrlSyncManager.js +34 -27
  24. package/dist/esm/services/UrlSyncManager.js.map +1 -1
  25. package/dist/esm/services/utils.js +4 -10
  26. package/dist/esm/services/utils.js.map +1 -1
  27. package/dist/esm/utils/writeSceneLog.js +1 -5
  28. package/dist/esm/utils/writeSceneLog.js.map +1 -1
  29. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js +40 -3
  30. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js.map +1 -1
  31. package/dist/esm/variables/interpolation/sceneInterpolator.js +3 -3
  32. package/dist/esm/variables/interpolation/sceneInterpolator.js.map +1 -1
  33. package/dist/esm/variables/utils.js.map +1 -1
  34. package/dist/esm/variables/variants/query/QueryVariable.js.map +1 -1
  35. package/dist/index.d.ts +159 -275
  36. package/dist/index.js +1672 -1884
  37. package/dist/index.js.map +1 -1
  38. package/package.json +7 -4
  39. package/dist/esm/core/PanelBuilders/VizConfigBuilder.js +0 -78
  40. package/dist/esm/core/PanelBuilders/VizConfigBuilder.js.map +0 -1
  41. package/dist/esm/core/PanelBuilders/VizConfigBuilders.js +0 -114
  42. package/dist/esm/core/PanelBuilders/VizConfigBuilders.js.map +0 -1
  43. package/dist/esm/querying/ExtraQueryProvider.js +0 -6
  44. package/dist/esm/querying/ExtraQueryProvider.js.map +0 -1
  45. package/dist/esm/querying/extraQueryProcessingOperator.js +0 -46
  46. package/dist/esm/querying/extraQueryProcessingOperator.js.map +0 -1
  47. package/dist/esm/services/UrlSyncContextProvider.js +0 -12
  48. package/dist/esm/services/UrlSyncContextProvider.js.map +0 -1
  49. package/dist/esm/services/useUrlSync.js +0 -27
  50. package/dist/esm/services/useUrlSync.js.map +0 -1
package/dist/index.js CHANGED
@@ -11,8 +11,8 @@ var uuid = require('uuid');
11
11
  var lodash = require('lodash');
12
12
  var schema = require('@grafana/schema');
13
13
  var ui = require('@grafana/ui');
14
- var e2eSelectors = require('@grafana/e2e-selectors');
15
14
  var css = require('@emotion/css');
15
+ var e2eSelectors = require('@grafana/e2e-selectors');
16
16
  var uFuzzy = require('@leeoniya/ufuzzy');
17
17
  var reactUse = require('react-use');
18
18
  var operators = require('rxjs/operators');
@@ -77,8 +77,8 @@ function renderSceneComponentWithRouteProps(sceneObject, routeProps) {
77
77
  }
78
78
 
79
79
  var __defProp$J = Object.defineProperty;
80
- var __defProps$t = Object.defineProperties;
81
- var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
80
+ var __defProps$s = Object.defineProperties;
81
+ var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
82
82
  var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
83
83
  var __hasOwnProp$J = Object.prototype.hasOwnProperty;
84
84
  var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
@@ -94,13 +94,13 @@ var __spreadValues$J = (a, b) => {
94
94
  }
95
95
  return a;
96
96
  };
97
- var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
97
+ var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(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$t(__spreadValues$J({}, plugin.meta), {
103
+ plugin.meta = __spreadProps$s(__spreadValues$J({}, plugin.meta), {
104
104
  id: pluginId,
105
105
  name: pluginId,
106
106
  module: "runtime plugin",
@@ -129,8 +129,8 @@ function loadPanelPluginSync(pluginId) {
129
129
  }
130
130
 
131
131
  var __defProp$I = Object.defineProperty;
132
- var __defProps$s = Object.defineProperties;
133
- var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
132
+ var __defProps$r = Object.defineProperties;
133
+ var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
134
134
  var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
135
135
  var __hasOwnProp$I = Object.prototype.hasOwnProperty;
136
136
  var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
@@ -146,7 +146,7 @@ var __spreadValues$I = (a, b) => {
146
146
  }
147
147
  return a;
148
148
  };
149
- var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
149
+ var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
150
150
  var __objRest$4 = (source, exclude) => {
151
151
  var target = {};
152
152
  for (var prop in source)
@@ -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$s(__spreadValues$I({}, otherProps), {
175
+ return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$r(__spreadValues$I({}, otherProps), {
176
176
  model
177
177
  }));
178
178
  }
@@ -586,22 +586,103 @@ function registerRuntimeDataSource({ dataSource }) {
586
586
  runtimeDataSources.set(dataSource.uid, dataSource);
587
587
  }
588
588
 
589
- function lookupVariable(name, sceneObject) {
590
- const variables = sceneObject.state.$variables;
591
- if (!variables) {
592
- if (sceneObject.parent) {
593
- return lookupVariable(name, sceneObject.parent);
594
- } else {
595
- return null;
589
+ class UniqueUrlKeyMapper {
590
+ constructor() {
591
+ this.index = /* @__PURE__ */ new Map();
592
+ }
593
+ getUniqueKey(key, obj) {
594
+ const objectsWithKey = this.index.get(key);
595
+ if (!objectsWithKey) {
596
+ throw new Error("Cannot find any scene object that uses the key '" + key + "'");
597
+ }
598
+ const address = objectsWithKey.findIndex((o) => o.sceneObject === obj);
599
+ if (address > 0) {
600
+ return `${key}-${address + 1}`;
596
601
  }
602
+ return key;
597
603
  }
598
- const found = variables.getByName(name);
599
- if (found) {
600
- return found;
601
- } else if (sceneObject.parent) {
602
- return lookupVariable(name, sceneObject.parent);
604
+ rebuildIndex(root) {
605
+ this.index.clear();
606
+ this.buildIndex(root, 0);
607
+ }
608
+ buildIndex(sceneObject, depth) {
609
+ if (sceneObject.urlSync) {
610
+ for (const key of sceneObject.urlSync.getKeys()) {
611
+ const hit = this.index.get(key);
612
+ if (hit) {
613
+ hit.push({ sceneObject, depth });
614
+ hit.sort((a, b) => a.depth - b.depth);
615
+ } else {
616
+ this.index.set(key, [{ sceneObject, depth }]);
617
+ }
618
+ }
619
+ }
620
+ sceneObject.forEachChild((child) => this.buildIndex(child, depth + 1));
603
621
  }
604
- return null;
622
+ }
623
+
624
+ function getUrlState(root) {
625
+ const urlKeyMapper = new UniqueUrlKeyMapper();
626
+ urlKeyMapper.rebuildIndex(root);
627
+ const result = {};
628
+ const visitNode = (obj) => {
629
+ if (obj.urlSync) {
630
+ const newUrlState = obj.urlSync.getUrlState();
631
+ for (const [key, value] of Object.entries(newUrlState)) {
632
+ if (value != null) {
633
+ const uniqueKey = urlKeyMapper.getUniqueKey(key, obj);
634
+ result[uniqueKey] = value;
635
+ }
636
+ }
637
+ }
638
+ obj.forEachChild(visitNode);
639
+ };
640
+ visitNode(root);
641
+ return result;
642
+ }
643
+ function syncStateFromSearchParams(root, urlParams) {
644
+ const urlKeyMapper = new UniqueUrlKeyMapper();
645
+ urlKeyMapper.rebuildIndex(root);
646
+ syncStateFromUrl(root, urlParams, urlKeyMapper);
647
+ }
648
+ function syncStateFromUrl(sceneObject, urlParams, urlKeyMapper) {
649
+ if (sceneObject.urlSync) {
650
+ const urlState = {};
651
+ const currentState = sceneObject.urlSync.getUrlState();
652
+ for (const key of sceneObject.urlSync.getKeys()) {
653
+ const uniqueKey = urlKeyMapper.getUniqueKey(key, sceneObject);
654
+ const newValue = urlParams.getAll(uniqueKey);
655
+ const currentValue = currentState[key];
656
+ if (isUrlValueEqual(newValue, currentValue)) {
657
+ continue;
658
+ }
659
+ if (newValue.length > 0) {
660
+ if (Array.isArray(currentValue)) {
661
+ urlState[key] = newValue;
662
+ } else {
663
+ urlState[key] = newValue[0];
664
+ }
665
+ } else {
666
+ urlState[key] = null;
667
+ }
668
+ }
669
+ if (Object.keys(urlState).length > 0) {
670
+ sceneObject.urlSync.updateFromUrl(urlState);
671
+ }
672
+ }
673
+ sceneObject.forEachChild((child) => syncStateFromUrl(child, urlParams, urlKeyMapper));
674
+ }
675
+ function isUrlValueEqual(currentUrlValue, newUrlValue) {
676
+ if (currentUrlValue.length === 0 && newUrlValue == null) {
677
+ return true;
678
+ }
679
+ if (!Array.isArray(newUrlValue) && (currentUrlValue == null ? void 0 : currentUrlValue.length) === 1) {
680
+ return newUrlValue === currentUrlValue[0];
681
+ }
682
+ if ((newUrlValue == null ? void 0 : newUrlValue.length) === 0 && currentUrlValue === null) {
683
+ return true;
684
+ }
685
+ return lodash.isEqual(currentUrlValue, newUrlValue);
605
686
  }
606
687
 
607
688
  var __defProp$F = Object.defineProperty;
@@ -1233,712 +1314,730 @@ function sqlStringFormatter(value) {
1233
1314
  })}'`;
1234
1315
  }
1235
1316
 
1236
- class SkipFormattingValue {
1237
- constructor(_value) {
1238
- this._value = _value;
1317
+ function lookupVariable(name, sceneObject) {
1318
+ const variables = sceneObject.state.$variables;
1319
+ if (!variables) {
1320
+ if (sceneObject.parent) {
1321
+ return lookupVariable(name, sceneObject.parent);
1322
+ } else {
1323
+ return null;
1324
+ }
1239
1325
  }
1240
- formatter() {
1241
- return this._value;
1326
+ const found = variables.getByName(name);
1327
+ if (found) {
1328
+ return found;
1329
+ } else if (sceneObject.parent) {
1330
+ return lookupVariable(name, sceneObject.parent);
1242
1331
  }
1332
+ return null;
1243
1333
  }
1244
1334
 
1245
- class UrlTimeRangeMacro {
1246
- constructor(name, sceneObject) {
1247
- this.state = { name, type: "url_variable" };
1248
- this._sceneObject = sceneObject;
1249
- }
1250
- getValue() {
1251
- var _a;
1252
- const timeRange = getTimeRange(this._sceneObject);
1253
- const urlState = (_a = timeRange.urlSync) == null ? void 0 : _a.getUrlState();
1254
- return new SkipFormattingValue(data.urlUtil.toUrlParams(urlState));
1255
- }
1256
- getValueText() {
1257
- return "";
1335
+ function sceneInterpolator(sceneObject, target, scopedVars, format, interpolations) {
1336
+ if (!target) {
1337
+ return target != null ? target : "";
1258
1338
  }
1339
+ VARIABLE_REGEX.lastIndex = 0;
1340
+ return target.replace(VARIABLE_REGEX, (match, var1, var2, fmt2, var3, fieldPath, fmt3) => {
1341
+ const variableName = var1 || var2 || var3;
1342
+ const fmt = fmt2 || fmt3 || format;
1343
+ const variable = lookupFormatVariable(variableName, match, scopedVars, sceneObject);
1344
+ if (!variable) {
1345
+ if (interpolations) {
1346
+ interpolations.push({ match, variableName, fieldPath, format: fmt, value: match, found: false });
1347
+ }
1348
+ return match;
1349
+ }
1350
+ const value = formatValue(variable, variable.getValue(fieldPath), fmt);
1351
+ if (interpolations) {
1352
+ interpolations.push({ match, variableName, fieldPath, format: fmt, value, found: value !== match });
1353
+ }
1354
+ return value;
1355
+ });
1259
1356
  }
1260
- class TimeFromAndToMacro {
1261
- constructor(name, sceneObject) {
1262
- this.state = { name, type: "time_macro" };
1263
- this._sceneObject = sceneObject;
1357
+ function lookupFormatVariable(name, match, scopedVars, sceneObject) {
1358
+ const scopedVar = scopedVars == null ? void 0 : scopedVars[name];
1359
+ if (scopedVar) {
1360
+ return getSceneVariableForScopedVar(name, scopedVar);
1264
1361
  }
1265
- getValue() {
1266
- const timeRange = getTimeRange(this._sceneObject);
1267
- if (this.state.name === "__from") {
1268
- return timeRange.state.value.from.valueOf();
1269
- } else {
1270
- return timeRange.state.value.to.valueOf();
1271
- }
1362
+ const variable = lookupVariable(name, sceneObject);
1363
+ if (variable) {
1364
+ return variable;
1272
1365
  }
1273
- getValueText() {
1274
- const timeRange = getTimeRange(this._sceneObject);
1275
- if (this.state.name === "__from") {
1276
- return data.dateTimeFormat(timeRange.state.value.from, { timeZone: timeRange.getTimeZone() });
1277
- } else {
1278
- return data.dateTimeFormat(timeRange.state.value.to, { timeZone: timeRange.getTimeZone() });
1279
- }
1366
+ if (macrosIndex[name]) {
1367
+ return new macrosIndex[name](name, sceneObject, match, scopedVars);
1280
1368
  }
1369
+ return null;
1281
1370
  }
1282
- class TimezoneMacro {
1283
- constructor(name, sceneObject) {
1284
- this.state = { name, type: "time_macro" };
1285
- this._sceneObject = sceneObject;
1371
+ function formatValue(variable, value, formatNameOrFn) {
1372
+ if (value === null || value === void 0) {
1373
+ return "";
1286
1374
  }
1287
- getValue() {
1288
- const timeRange = getTimeRange(this._sceneObject);
1289
- const timeZone = timeRange.getTimeZone();
1290
- if (timeZone === "browser") {
1291
- return Intl.DateTimeFormat().resolvedOptions().timeZone;
1292
- }
1293
- return timeZone;
1375
+ if (isCustomVariableValue(value)) {
1376
+ return value.formatter(formatNameOrFn);
1294
1377
  }
1295
- getValueText() {
1296
- return this.getValue();
1378
+ if (!Array.isArray(value) && typeof value === "object") {
1379
+ value = `${value}`;
1297
1380
  }
1298
- }
1299
- class IntervalMacro {
1300
- constructor(name, sceneObject, match) {
1301
- this.state = { name, type: "time_macro", match };
1302
- this._sceneObject = sceneObject;
1381
+ if (typeof formatNameOrFn === "function") {
1382
+ return formatNameOrFn(value, {
1383
+ name: variable.state.name,
1384
+ type: variable.state.type,
1385
+ multi: variable.state.isMulti,
1386
+ includeAll: variable.state.includeAll
1387
+ });
1303
1388
  }
1304
- getValue() {
1305
- var _a;
1306
- const data = getData(this._sceneObject);
1307
- if (data) {
1308
- const request = (_a = data.state.data) == null ? void 0 : _a.request;
1309
- if (!request) {
1310
- return this.state.match;
1311
- }
1312
- if (this.state.name === "__interval_ms") {
1313
- return request.intervalMs;
1314
- }
1315
- return request.interval;
1389
+ let args = [];
1390
+ if (!formatNameOrFn) {
1391
+ formatNameOrFn = schema.VariableFormatID.Glob;
1392
+ } else {
1393
+ args = formatNameOrFn.split(":");
1394
+ if (args.length > 1) {
1395
+ formatNameOrFn = args[0];
1396
+ args = args.slice(1);
1397
+ } else {
1398
+ args = [];
1316
1399
  }
1317
- return this.state.match;
1318
1400
  }
1401
+ let formatter = formatRegistry.getIfExists(formatNameOrFn);
1402
+ if (!formatter) {
1403
+ console.error(`Variable format ${formatNameOrFn} not found. Using glob format as fallback.`);
1404
+ formatter = formatRegistry.get(schema.VariableFormatID.Glob);
1405
+ }
1406
+ return formatter.formatter(value, args, variable);
1319
1407
  }
1320
1408
 
1321
- class AllVariablesMacro {
1322
- constructor(name, sceneObject) {
1323
- this.state = { name, type: "url_variable" };
1324
- this._sceneObject = sceneObject;
1325
- }
1326
- getValue() {
1327
- const allVars = collectAllVariables(this._sceneObject);
1328
- const format = formatRegistry.get(schema.VariableFormatID.QueryParam);
1329
- const params = [];
1330
- for (const name of Object.keys(allVars)) {
1331
- const variable = allVars[name];
1332
- const value = variable.getValue();
1333
- if (!value) {
1334
- continue;
1335
- }
1336
- if (isCustomVariableValue(value)) {
1337
- params.push(value.formatter(schema.VariableFormatID.QueryParam));
1338
- } else {
1339
- params.push(format.formatter(value, [], variable));
1340
- }
1341
- }
1342
- return new SkipFormattingValue(params.join("&"));
1343
- }
1344
- getValueText() {
1345
- return "";
1346
- }
1409
+ function isSceneObject(obj) {
1410
+ return obj.useState !== void 0;
1347
1411
  }
1348
- function collectAllVariables(sceneObject, record = {}) {
1349
- if (sceneObject.state.$variables) {
1350
- for (const variable of sceneObject.state.$variables.state.variables) {
1351
- if (variable.state.skipUrlSync) {
1352
- continue;
1353
- }
1354
- if (!record[variable.state.name]) {
1355
- record[variable.state.name] = variable;
1356
- }
1357
- }
1358
- }
1359
- if (sceneObject.parent) {
1360
- collectAllVariables(sceneObject.parent, record);
1361
- }
1362
- return record;
1412
+ function isDataRequestEnricher(obj) {
1413
+ return "enrichDataRequest" in obj;
1414
+ }
1415
+ function isDataLayer(obj) {
1416
+ return "isDataLayer" in obj;
1363
1417
  }
1364
1418
 
1365
- var __defProp$D = Object.defineProperty;
1366
- var __defProps$r = Object.defineProperties;
1367
- var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
1368
- var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
1369
- var __hasOwnProp$D = Object.prototype.hasOwnProperty;
1370
- var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
1371
- var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1372
- var __spreadValues$D = (a, b) => {
1373
- for (var prop in b || (b = {}))
1374
- if (__hasOwnProp$D.call(b, prop))
1375
- __defNormalProp$D(a, prop, b[prop]);
1376
- if (__getOwnPropSymbols$D)
1377
- for (var prop of __getOwnPropSymbols$D(b)) {
1378
- if (__propIsEnum$D.call(b, prop))
1379
- __defNormalProp$D(a, prop, b[prop]);
1380
- }
1381
- return a;
1419
+ var __accessCheck = (obj, member, msg) => {
1420
+ if (!member.has(obj))
1421
+ throw TypeError("Cannot " + msg);
1382
1422
  };
1383
- var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
1384
- function getTemplateProxyForField(field, frame, frames) {
1385
- return new Proxy(
1386
- {},
1387
- {
1388
- get: (obj, key) => {
1389
- if (key === "name") {
1390
- return field.name;
1391
- }
1392
- if (key === "displayName") {
1393
- return data.getFieldDisplayName(field, frame, frames);
1394
- }
1395
- if (key === "labels" || key === "formattedLabels") {
1396
- if (!field.labels) {
1397
- return "";
1398
- }
1399
- return __spreadProps$r(__spreadValues$D({}, field.labels), {
1400
- __values: Object.values(field.labels).sort().join(", "),
1401
- toString: () => {
1402
- return data.formatLabels(field.labels, "", true);
1403
- }
1404
- });
1405
- }
1406
- return void 0;
1407
- }
1408
- }
1409
- );
1423
+ var __privateGet = (obj, member, getter) => {
1424
+ __accessCheck(obj, member, "read from private field");
1425
+ return getter ? getter.call(obj) : member.get(obj);
1426
+ };
1427
+ var __privateAdd = (obj, member, value) => {
1428
+ if (member.has(obj))
1429
+ throw TypeError("Cannot add the same private member more than once");
1430
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1431
+ };
1432
+ var _running;
1433
+ function isQueryController(s) {
1434
+ return "isQueryController" in s;
1410
1435
  }
1411
-
1412
- class ValueMacro {
1413
- constructor(name, sceneObject, _match, _scopedVars) {
1414
- this._match = _match;
1415
- this._scopedVars = _scopedVars;
1416
- this.state = { name, type: "__value" };
1436
+ class SceneQueryController extends SceneObjectBase {
1437
+ constructor() {
1438
+ super({ isRunning: false });
1439
+ this.isQueryController = true;
1440
+ __privateAdd(this, _running, /* @__PURE__ */ new Set());
1441
+ this.addActivationHandler(() => {
1442
+ return () => __privateGet(this, _running).clear();
1443
+ });
1417
1444
  }
1418
- getValue(fieldPath) {
1419
- var _a, _b;
1420
- const dataContext = (_a = this._scopedVars) == null ? void 0 : _a.__dataContext;
1421
- if (!dataContext) {
1422
- return this._match;
1423
- }
1424
- const { frame, rowIndex, field, calculatedValue } = dataContext.value;
1425
- if (calculatedValue) {
1426
- switch (fieldPath) {
1427
- case "numeric":
1428
- return calculatedValue.numeric;
1429
- case "raw":
1430
- return calculatedValue.numeric;
1431
- case "time":
1432
- return "";
1433
- case "text":
1434
- default:
1435
- return data.formattedValueToString(calculatedValue);
1436
- }
1437
- }
1438
- if (rowIndex == null) {
1439
- return this._match;
1440
- }
1441
- if (fieldPath === "time") {
1442
- const timeField = frame.fields.find((f) => f.type === data.FieldType.time);
1443
- return timeField ? timeField.values.get(rowIndex) : void 0;
1445
+ queryStarted(entry) {
1446
+ __privateGet(this, _running).add(entry);
1447
+ this.changeRunningQueryCount(1);
1448
+ if (!this.state.isRunning) {
1449
+ this.setState({ isRunning: true });
1444
1450
  }
1445
- if (!field) {
1446
- return this._match;
1451
+ }
1452
+ queryCompleted(entry) {
1453
+ if (!__privateGet(this, _running).has(entry)) {
1454
+ return;
1447
1455
  }
1448
- const value = field.values.get(rowIndex);
1449
- if (fieldPath === "raw") {
1450
- return value;
1456
+ __privateGet(this, _running).delete(entry);
1457
+ this.changeRunningQueryCount(-1);
1458
+ if (__privateGet(this, _running).size === 0) {
1459
+ this.setState({ isRunning: false });
1451
1460
  }
1452
- const displayProcessor = (_b = field.display) != null ? _b : fallbackDisplayProcessor;
1453
- const result = displayProcessor(value);
1454
- switch (fieldPath) {
1455
- case "numeric":
1456
- return result.numeric;
1457
- case "text":
1458
- default:
1459
- return data.formattedValueToString(result);
1461
+ }
1462
+ changeRunningQueryCount(dir) {
1463
+ var _a;
1464
+ window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
1465
+ }
1466
+ cancelAll() {
1467
+ var _a;
1468
+ for (const entry of __privateGet(this, _running).values()) {
1469
+ (_a = entry.cancel) == null ? void 0 : _a.call(entry);
1460
1470
  }
1461
1471
  }
1462
- getValueText() {
1472
+ }
1473
+ _running = new WeakMap();
1474
+
1475
+ function getVariables(sceneObject) {
1476
+ var _a;
1477
+ return (_a = getClosest(sceneObject, (s) => s.state.$variables)) != null ? _a : EmptyVariableSet;
1478
+ }
1479
+ function getData(sceneObject) {
1480
+ var _a;
1481
+ return (_a = getClosest(sceneObject, (s) => s.state.$data)) != null ? _a : EmptyDataNode;
1482
+ }
1483
+ function isSceneLayout(s) {
1484
+ return "isDraggable" in s;
1485
+ }
1486
+ function getLayout(scene) {
1487
+ const parent = getClosest(scene, (s) => isSceneLayout(s) ? s : void 0);
1488
+ if (parent) {
1489
+ return parent;
1490
+ }
1491
+ return null;
1492
+ }
1493
+ function interpolate(sceneObject, value, scopedVars, format, interpolations) {
1494
+ if (value === "" || value == null) {
1463
1495
  return "";
1464
1496
  }
1497
+ return sceneInterpolator(sceneObject, value, scopedVars, format, interpolations);
1465
1498
  }
1466
- const fallbackDisplayProcessor = data.getDisplayProcessor();
1467
- class DataMacro {
1468
- constructor(name, sceneObject, _match, _scopedVars) {
1469
- this._match = _match;
1470
- this._scopedVars = _scopedVars;
1471
- this.state = { name, type: "__data" };
1499
+ function hasVariableDependencyInLoadingState(sceneObject) {
1500
+ if (!sceneObject.variableDependency) {
1501
+ return false;
1472
1502
  }
1473
- getValue(fieldPath) {
1474
- var _a, _b;
1475
- const dataContext = (_a = this._scopedVars) == null ? void 0 : _a.__dataContext;
1476
- if (!dataContext || !fieldPath) {
1477
- return this._match;
1503
+ for (const name of sceneObject.variableDependency.getNames()) {
1504
+ const variable = lookupVariable(name, sceneObject);
1505
+ if (!variable) {
1506
+ continue;
1478
1507
  }
1479
- const { frame, rowIndex } = dataContext.value;
1480
- if (rowIndex === void 0 || fieldPath === void 0) {
1481
- return this._match;
1508
+ const set = variable.parent;
1509
+ if (set.isVariableLoadingOrWaitingToUpdate(variable)) {
1510
+ return true;
1482
1511
  }
1483
- const obj = {
1484
- name: frame.name,
1485
- refId: frame.refId,
1486
- fields: data.getFieldDisplayValuesProxy({ frame, rowIndex })
1487
- };
1488
- return (_b = getFieldAccessor(fieldPath)(obj)) != null ? _b : "";
1489
- }
1490
- getValueText() {
1491
- return "";
1492
1512
  }
1513
+ return false;
1493
1514
  }
1494
- class SeriesMacro {
1495
- constructor(name, sceneObject, _match, _scopedVars) {
1496
- this._match = _match;
1497
- this._scopedVars = _scopedVars;
1498
- this.state = { name, type: "__series" };
1515
+ function findObjectInternal(scene, check, alreadySearchedChild, shouldSearchUp) {
1516
+ if (check(scene)) {
1517
+ return scene;
1499
1518
  }
1500
- getValue(fieldPath) {
1501
- var _a;
1502
- const dataContext = (_a = this._scopedVars) == null ? void 0 : _a.__dataContext;
1503
- if (!dataContext || !fieldPath) {
1504
- return this._match;
1519
+ let found = null;
1520
+ scene.forEachChild((child) => {
1521
+ if (child === alreadySearchedChild) {
1522
+ return;
1505
1523
  }
1506
- if (fieldPath !== "name") {
1507
- return this._match;
1524
+ let maybe = findObjectInternal(child, check);
1525
+ if (maybe) {
1526
+ found = maybe;
1508
1527
  }
1509
- const { frame, frameIndex } = dataContext.value;
1510
- return data.getFrameDisplayName(frame, frameIndex);
1528
+ });
1529
+ if (found) {
1530
+ return found;
1511
1531
  }
1512
- getValueText() {
1513
- return "";
1532
+ if (shouldSearchUp && scene.parent) {
1533
+ return findObjectInternal(scene.parent, check, scene, true);
1514
1534
  }
1535
+ return null;
1515
1536
  }
1516
- class FieldMacro {
1517
- constructor(name, sceneObject, _match, _scopedVars) {
1518
- this._match = _match;
1519
- this._scopedVars = _scopedVars;
1520
- this.state = { name, type: "__field" };
1537
+ function findByKey(sceneObject, key) {
1538
+ const found = findObject(sceneObject, (sceneToCheck) => {
1539
+ return sceneToCheck.state.key === key;
1540
+ });
1541
+ if (!found) {
1542
+ throw new Error("Unable to find scene with key " + key);
1521
1543
  }
1522
- getValue(fieldPath) {
1523
- var _a, _b;
1524
- const dataContext = (_a = this._scopedVars) == null ? void 0 : _a.__dataContext;
1525
- if (!dataContext || !fieldPath) {
1526
- return this._match;
1527
- }
1528
- if (fieldPath === void 0 || fieldPath === "") {
1529
- return this._match;
1530
- }
1531
- const { frame, field, data } = dataContext.value;
1532
- const obj = getTemplateProxyForField(field, frame, data);
1533
- return (_b = getFieldAccessor(fieldPath)(obj)) != null ? _b : "";
1544
+ return found;
1545
+ }
1546
+ function findByKeyAndType(sceneObject, key, targetType) {
1547
+ const found = findObject(sceneObject, (sceneToCheck) => {
1548
+ return sceneToCheck.state.key === key;
1549
+ });
1550
+ if (!found) {
1551
+ throw new Error("Unable to find scene with key " + key);
1534
1552
  }
1535
- getValueText() {
1536
- return "";
1553
+ if (!(found instanceof targetType)) {
1554
+ throw new Error(`Found scene object with key ${key} does not match type ${targetType.name}`);
1537
1555
  }
1556
+ return found;
1538
1557
  }
1539
-
1540
- class UrlMacro {
1541
- constructor(name, _) {
1542
- this.state = { name, type: "url_macro" };
1543
- }
1544
- getValue(fieldPath) {
1545
- var _a;
1546
- const location = runtime.locationService.getLocation();
1547
- const subUrl = (_a = runtime.config.appSubUrl) != null ? _a : "";
1548
- switch (fieldPath != null ? fieldPath : "") {
1549
- case "params":
1550
- return new UrlStateFormatter(location.search);
1551
- case "path":
1552
- return subUrl + location.pathname;
1553
- case "":
1554
- default:
1555
- return subUrl + location.pathname + location.search;
1558
+ function findObject(scene, check) {
1559
+ return findObjectInternal(scene, check, void 0, true);
1560
+ }
1561
+ function findAllObjects(scene, check) {
1562
+ const found = [];
1563
+ scene.forEachChild((child) => {
1564
+ if (check(child)) {
1565
+ found.push(child);
1556
1566
  }
1557
- }
1558
- getValueText() {
1559
- return "";
1560
- }
1567
+ found.push(...findAllObjects(child, check));
1568
+ });
1569
+ return found;
1561
1570
  }
1562
- class UrlStateFormatter {
1563
- constructor(_urlQueryParams) {
1564
- this._urlQueryParams = _urlQueryParams;
1565
- }
1566
- formatter(options) {
1567
- if (!options) {
1568
- return this._urlQueryParams;
1571
+ function getDataLayers(sceneObject, localOnly = false) {
1572
+ let currentLevel = sceneObject;
1573
+ let collected = [];
1574
+ while (currentLevel) {
1575
+ const dataProvider = currentLevel.state.$data;
1576
+ if (!dataProvider) {
1577
+ currentLevel = currentLevel.parent;
1578
+ continue;
1569
1579
  }
1570
- const params = options.split(":");
1571
- if (params[0] === "exclude" && params.length > 1) {
1572
- const allParams = new URLSearchParams(this._urlQueryParams);
1573
- for (const param of params[1].split(",")) {
1574
- allParams.delete(param);
1580
+ if (isDataLayer(dataProvider)) {
1581
+ collected = collected.concat(dataProvider);
1582
+ } else {
1583
+ if (dataProvider.state.$data && isDataLayer(dataProvider.state.$data)) {
1584
+ collected = collected.concat(dataProvider.state.$data);
1575
1585
  }
1576
- return `?${allParams}`;
1577
1586
  }
1578
- if (params[0] === "include" && params.length > 1) {
1579
- const allParams = new URLSearchParams(this._urlQueryParams);
1580
- const includeOnly = params[1].split(",");
1581
- for (const param of allParams.keys()) {
1582
- if (!includeOnly.includes(param)) {
1583
- allParams.delete(param);
1587
+ if (localOnly && collected.length > 0) {
1588
+ break;
1589
+ }
1590
+ currentLevel = currentLevel.parent;
1591
+ }
1592
+ return collected;
1593
+ }
1594
+ function getAncestor(sceneObject, ancestorType) {
1595
+ let parent = sceneObject;
1596
+ while (parent) {
1597
+ if (parent instanceof ancestorType) {
1598
+ return parent;
1599
+ }
1600
+ parent = parent.parent;
1601
+ }
1602
+ if (!parent) {
1603
+ throw new Error("Unable to find parent of type " + ancestorType.name);
1604
+ }
1605
+ return parent;
1606
+ }
1607
+ function getQueryController(sceneObject) {
1608
+ let parent = sceneObject;
1609
+ while (parent) {
1610
+ if (parent.state.$behaviors) {
1611
+ for (const behavior of parent.state.$behaviors) {
1612
+ if (isQueryController(behavior)) {
1613
+ return behavior;
1584
1614
  }
1585
1615
  }
1586
- return `?${allParams}`;
1587
1616
  }
1588
- return this._urlQueryParams;
1617
+ parent = parent.parent;
1589
1618
  }
1619
+ return void 0;
1590
1620
  }
1591
1621
 
1592
- class UserMacro {
1593
- constructor(name, _) {
1594
- this.state = { name, type: "user_macro" };
1622
+ class SkipFormattingValue {
1623
+ constructor(_value) {
1624
+ this._value = _value;
1595
1625
  }
1596
- getValue(fieldPath) {
1597
- const user = runtime.config.bootData.user;
1598
- switch (fieldPath) {
1599
- case "login":
1600
- return user.login;
1601
- case "email":
1602
- return user.email;
1603
- case "id":
1604
- default:
1605
- return String(user.id);
1606
- }
1626
+ formatter() {
1627
+ return this._value;
1628
+ }
1629
+ }
1630
+
1631
+ class UrlTimeRangeMacro {
1632
+ constructor(name, sceneObject) {
1633
+ this.state = { name, type: "url_variable" };
1634
+ this._sceneObject = sceneObject;
1635
+ }
1636
+ getValue() {
1637
+ var _a;
1638
+ const timeRange = getTimeRange(this._sceneObject);
1639
+ const urlState = (_a = timeRange.urlSync) == null ? void 0 : _a.getUrlState();
1640
+ return new SkipFormattingValue(data.urlUtil.toUrlParams(urlState));
1607
1641
  }
1608
1642
  getValueText() {
1609
1643
  return "";
1610
1644
  }
1611
1645
  }
1612
- class OrgMacro {
1613
- constructor(name, _) {
1614
- this.state = { name, type: "org_macro" };
1646
+ class TimeFromAndToMacro {
1647
+ constructor(name, sceneObject) {
1648
+ this.state = { name, type: "time_macro" };
1649
+ this._sceneObject = sceneObject;
1615
1650
  }
1616
- getValue(fieldPath) {
1617
- const user = runtime.config.bootData.user;
1618
- switch (fieldPath) {
1619
- case "name":
1620
- return user.orgName;
1621
- case "id":
1622
- default:
1623
- return String(user.orgId);
1651
+ getValue() {
1652
+ const timeRange = getTimeRange(this._sceneObject);
1653
+ if (this.state.name === "__from") {
1654
+ return timeRange.state.value.from.valueOf();
1655
+ } else {
1656
+ return timeRange.state.value.to.valueOf();
1624
1657
  }
1625
1658
  }
1626
1659
  getValueText() {
1627
- return "";
1660
+ const timeRange = getTimeRange(this._sceneObject);
1661
+ if (this.state.name === "__from") {
1662
+ return data.dateTimeFormat(timeRange.state.value.from, { timeZone: timeRange.getTimeZone() });
1663
+ } else {
1664
+ return data.dateTimeFormat(timeRange.state.value.to, { timeZone: timeRange.getTimeZone() });
1665
+ }
1628
1666
  }
1629
1667
  }
1630
-
1631
- const macrosIndex = {
1632
- [data.DataLinkBuiltInVars.includeVars]: AllVariablesMacro,
1633
- [data.DataLinkBuiltInVars.keepTime]: UrlTimeRangeMacro,
1634
- ["__value"]: ValueMacro,
1635
- ["__data"]: DataMacro,
1636
- ["__series"]: SeriesMacro,
1637
- ["__field"]: FieldMacro,
1638
- ["__url"]: UrlMacro,
1639
- ["__from"]: TimeFromAndToMacro,
1640
- ["__to"]: TimeFromAndToMacro,
1641
- ["__timezone"]: TimezoneMacro,
1642
- ["__user"]: UserMacro,
1643
- ["__org"]: OrgMacro,
1644
- ["__interval"]: IntervalMacro,
1645
- ["__interval_ms"]: IntervalMacro
1646
- };
1647
- function registerVariableMacro(name, macro) {
1648
- if (macrosIndex[name]) {
1649
- throw new Error(`Macro already registered ${name}`);
1668
+ class TimezoneMacro {
1669
+ constructor(name, sceneObject) {
1670
+ this.state = { name, type: "time_macro" };
1671
+ this._sceneObject = sceneObject;
1672
+ }
1673
+ getValue() {
1674
+ const timeRange = getTimeRange(this._sceneObject);
1675
+ const timeZone = timeRange.getTimeZone();
1676
+ if (timeZone === "browser") {
1677
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
1678
+ }
1679
+ return timeZone;
1680
+ }
1681
+ getValueText() {
1682
+ return this.getValue();
1650
1683
  }
1651
- macrosIndex[name] = macro;
1652
- return () => {
1653
- delete macrosIndex[name];
1654
- };
1655
1684
  }
1656
-
1657
- function sceneInterpolator(sceneObject, target, scopedVars, format, interpolations) {
1658
- if (!target) {
1659
- return target != null ? target : "";
1685
+ class IntervalMacro {
1686
+ constructor(name, sceneObject, match) {
1687
+ this.state = { name, type: "time_macro", match };
1688
+ this._sceneObject = sceneObject;
1660
1689
  }
1661
- VARIABLE_REGEX.lastIndex = 0;
1662
- return target.replace(VARIABLE_REGEX, (match, var1, var2, fmt2, var3, fieldPath, fmt3) => {
1663
- const variableName = var1 || var2 || var3;
1664
- const fmt = fmt2 || fmt3 || format;
1665
- const variable = lookupFormatVariable(variableName, match, scopedVars, sceneObject);
1666
- if (!variable) {
1667
- if (interpolations) {
1668
- interpolations.push({ match, variableName, fieldPath, format: fmt, value: match, found: false });
1690
+ getValue() {
1691
+ var _a;
1692
+ const data = getData(this._sceneObject);
1693
+ if (data) {
1694
+ const request = (_a = data.state.data) == null ? void 0 : _a.request;
1695
+ if (!request) {
1696
+ return this.state.match;
1669
1697
  }
1670
- return match;
1671
- }
1672
- const value = formatValue(sceneObject, variable, variable.getValue(fieldPath), fmt);
1673
- if (interpolations) {
1674
- interpolations.push({ match, variableName, fieldPath, format: fmt, value, found: value !== match });
1698
+ if (this.state.name === "__interval_ms") {
1699
+ return request.intervalMs;
1700
+ }
1701
+ return request.interval;
1675
1702
  }
1676
- return value;
1677
- });
1678
- }
1679
- function lookupFormatVariable(name, match, scopedVars, sceneObject) {
1680
- const scopedVar = scopedVars == null ? void 0 : scopedVars[name];
1681
- if (scopedVar) {
1682
- return getSceneVariableForScopedVar(name, scopedVar);
1683
- }
1684
- const variable = lookupVariable(name, sceneObject);
1685
- if (variable) {
1686
- return variable;
1687
- }
1688
- if (macrosIndex[name]) {
1689
- return new macrosIndex[name](name, sceneObject, match, scopedVars);
1703
+ return this.state.match;
1690
1704
  }
1691
- return null;
1692
1705
  }
1693
- function formatValue(context, variable, value, formatNameOrFn) {
1694
- if (value === null || value === void 0) {
1695
- return "";
1696
- }
1697
- if (isCustomVariableValue(value)) {
1698
- return sceneInterpolator(context, value.formatter(formatNameOrFn));
1706
+
1707
+ class AllVariablesMacro {
1708
+ constructor(name, sceneObject) {
1709
+ this.state = { name, type: "url_variable" };
1710
+ this._sceneObject = sceneObject;
1699
1711
  }
1700
- if (!Array.isArray(value) && typeof value === "object") {
1701
- value = `${value}`;
1712
+ getValue() {
1713
+ const allVars = collectAllVariables(this._sceneObject);
1714
+ const format = formatRegistry.get(schema.VariableFormatID.QueryParam);
1715
+ const params = [];
1716
+ for (const name of Object.keys(allVars)) {
1717
+ const variable = allVars[name];
1718
+ const value = variable.getValue();
1719
+ if (!value) {
1720
+ continue;
1721
+ }
1722
+ if (isCustomVariableValue(value)) {
1723
+ params.push(value.formatter(schema.VariableFormatID.QueryParam));
1724
+ } else {
1725
+ params.push(format.formatter(value, [], variable));
1726
+ }
1727
+ }
1728
+ return new SkipFormattingValue(params.join("&"));
1702
1729
  }
1703
- if (typeof formatNameOrFn === "function") {
1704
- return formatNameOrFn(value, {
1705
- name: variable.state.name,
1706
- type: variable.state.type,
1707
- multi: variable.state.isMulti,
1708
- includeAll: variable.state.includeAll
1709
- });
1730
+ getValueText() {
1731
+ return "";
1710
1732
  }
1711
- let args = [];
1712
- if (!formatNameOrFn) {
1713
- formatNameOrFn = schema.VariableFormatID.Glob;
1714
- } else {
1715
- args = formatNameOrFn.split(":");
1716
- if (args.length > 1) {
1717
- formatNameOrFn = args[0];
1718
- args = args.slice(1);
1719
- } else {
1720
- args = [];
1733
+ }
1734
+ function collectAllVariables(sceneObject, record = {}) {
1735
+ if (sceneObject.state.$variables) {
1736
+ for (const variable of sceneObject.state.$variables.state.variables) {
1737
+ if (variable.state.skipUrlSync) {
1738
+ continue;
1739
+ }
1740
+ if (!record[variable.state.name]) {
1741
+ record[variable.state.name] = variable;
1742
+ }
1721
1743
  }
1722
1744
  }
1723
- let formatter = formatRegistry.getIfExists(formatNameOrFn);
1724
- if (!formatter) {
1725
- console.error(`Variable format ${formatNameOrFn} not found. Using glob format as fallback.`);
1726
- formatter = formatRegistry.get(schema.VariableFormatID.Glob);
1745
+ if (sceneObject.parent) {
1746
+ collectAllVariables(sceneObject.parent, record);
1727
1747
  }
1728
- return formatter.formatter(value, args, variable);
1729
- }
1730
-
1731
- function isSceneObject(obj) {
1732
- return obj.useState !== void 0;
1733
- }
1734
- function isDataRequestEnricher(obj) {
1735
- return "enrichDataRequest" in obj;
1736
- }
1737
- function isDataLayer(obj) {
1738
- return "isDataLayer" in obj;
1748
+ return record;
1739
1749
  }
1740
1750
 
1741
- var __accessCheck = (obj, member, msg) => {
1742
- if (!member.has(obj))
1743
- throw TypeError("Cannot " + msg);
1744
- };
1745
- var __privateGet = (obj, member, getter) => {
1746
- __accessCheck(obj, member, "read from private field");
1747
- return getter ? getter.call(obj) : member.get(obj);
1748
- };
1749
- var __privateAdd = (obj, member, value) => {
1750
- if (member.has(obj))
1751
- throw TypeError("Cannot add the same private member more than once");
1752
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1751
+ var __defProp$D = Object.defineProperty;
1752
+ var __defProps$q = Object.defineProperties;
1753
+ var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
1754
+ var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
1755
+ var __hasOwnProp$D = Object.prototype.hasOwnProperty;
1756
+ var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
1757
+ var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1758
+ var __spreadValues$D = (a, b) => {
1759
+ for (var prop in b || (b = {}))
1760
+ if (__hasOwnProp$D.call(b, prop))
1761
+ __defNormalProp$D(a, prop, b[prop]);
1762
+ if (__getOwnPropSymbols$D)
1763
+ for (var prop of __getOwnPropSymbols$D(b)) {
1764
+ if (__propIsEnum$D.call(b, prop))
1765
+ __defNormalProp$D(a, prop, b[prop]);
1766
+ }
1767
+ return a;
1753
1768
  };
1754
- var _running;
1755
- function isQueryController(s) {
1756
- return "isQueryController" in s;
1769
+ var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
1770
+ function getTemplateProxyForField(field, frame, frames) {
1771
+ return new Proxy(
1772
+ {},
1773
+ {
1774
+ get: (obj, key) => {
1775
+ if (key === "name") {
1776
+ return field.name;
1777
+ }
1778
+ if (key === "displayName") {
1779
+ return data.getFieldDisplayName(field, frame, frames);
1780
+ }
1781
+ if (key === "labels" || key === "formattedLabels") {
1782
+ if (!field.labels) {
1783
+ return "";
1784
+ }
1785
+ return __spreadProps$q(__spreadValues$D({}, field.labels), {
1786
+ __values: Object.values(field.labels).sort().join(", "),
1787
+ toString: () => {
1788
+ return data.formatLabels(field.labels, "", true);
1789
+ }
1790
+ });
1791
+ }
1792
+ return void 0;
1793
+ }
1794
+ }
1795
+ );
1757
1796
  }
1758
- class SceneQueryController extends SceneObjectBase {
1759
- constructor() {
1760
- super({ isRunning: false });
1761
- this.isQueryController = true;
1762
- __privateAdd(this, _running, /* @__PURE__ */ new Set());
1763
- this.addActivationHandler(() => {
1764
- return () => __privateGet(this, _running).clear();
1765
- });
1797
+
1798
+ class ValueMacro {
1799
+ constructor(name, sceneObject, _match, _scopedVars) {
1800
+ this._match = _match;
1801
+ this._scopedVars = _scopedVars;
1802
+ this.state = { name, type: "__value" };
1766
1803
  }
1767
- queryStarted(entry) {
1768
- __privateGet(this, _running).add(entry);
1769
- this.changeRunningQueryCount(1);
1770
- if (!this.state.isRunning) {
1771
- this.setState({ isRunning: true });
1804
+ getValue(fieldPath) {
1805
+ var _a, _b;
1806
+ const dataContext = (_a = this._scopedVars) == null ? void 0 : _a.__dataContext;
1807
+ if (!dataContext) {
1808
+ return this._match;
1809
+ }
1810
+ const { frame, rowIndex, field, calculatedValue } = dataContext.value;
1811
+ if (calculatedValue) {
1812
+ switch (fieldPath) {
1813
+ case "numeric":
1814
+ return calculatedValue.numeric;
1815
+ case "raw":
1816
+ return calculatedValue.numeric;
1817
+ case "time":
1818
+ return "";
1819
+ case "text":
1820
+ default:
1821
+ return data.formattedValueToString(calculatedValue);
1822
+ }
1772
1823
  }
1773
- }
1774
- queryCompleted(entry) {
1775
- if (!__privateGet(this, _running).has(entry)) {
1776
- return;
1824
+ if (rowIndex == null) {
1825
+ return this._match;
1777
1826
  }
1778
- __privateGet(this, _running).delete(entry);
1779
- this.changeRunningQueryCount(-1);
1780
- if (__privateGet(this, _running).size === 0) {
1781
- this.setState({ isRunning: false });
1827
+ if (fieldPath === "time") {
1828
+ const timeField = frame.fields.find((f) => f.type === data.FieldType.time);
1829
+ return timeField ? timeField.values.get(rowIndex) : void 0;
1782
1830
  }
1783
- }
1784
- changeRunningQueryCount(dir) {
1785
- var _a;
1786
- window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
1787
- }
1788
- cancelAll() {
1789
- var _a;
1790
- for (const entry of __privateGet(this, _running).values()) {
1791
- (_a = entry.cancel) == null ? void 0 : _a.call(entry);
1831
+ if (!field) {
1832
+ return this._match;
1833
+ }
1834
+ const value = field.values.get(rowIndex);
1835
+ if (fieldPath === "raw") {
1836
+ return value;
1837
+ }
1838
+ const displayProcessor = (_b = field.display) != null ? _b : fallbackDisplayProcessor;
1839
+ const result = displayProcessor(value);
1840
+ switch (fieldPath) {
1841
+ case "numeric":
1842
+ return result.numeric;
1843
+ case "text":
1844
+ default:
1845
+ return data.formattedValueToString(result);
1792
1846
  }
1793
1847
  }
1794
- }
1795
- _running = new WeakMap();
1796
-
1797
- function getVariables(sceneObject) {
1798
- var _a;
1799
- return (_a = getClosest(sceneObject, (s) => s.state.$variables)) != null ? _a : EmptyVariableSet;
1800
- }
1801
- function getData(sceneObject) {
1802
- var _a;
1803
- return (_a = getClosest(sceneObject, (s) => s.state.$data)) != null ? _a : EmptyDataNode;
1804
- }
1805
- function isSceneLayout(s) {
1806
- return "isDraggable" in s;
1807
- }
1808
- function getLayout(scene) {
1809
- const parent = getClosest(scene, (s) => isSceneLayout(s) ? s : void 0);
1810
- if (parent) {
1811
- return parent;
1812
- }
1813
- return null;
1814
- }
1815
- function interpolate(sceneObject, value, scopedVars, format, interpolations) {
1816
- if (value === "" || value == null) {
1848
+ getValueText() {
1817
1849
  return "";
1818
1850
  }
1819
- return sceneInterpolator(sceneObject, value, scopedVars, format, interpolations);
1820
1851
  }
1821
- function hasVariableDependencyInLoadingState(sceneObject) {
1822
- if (!sceneObject.variableDependency) {
1823
- return false;
1852
+ const fallbackDisplayProcessor = data.getDisplayProcessor();
1853
+ class DataMacro {
1854
+ constructor(name, sceneObject, _match, _scopedVars) {
1855
+ this._match = _match;
1856
+ this._scopedVars = _scopedVars;
1857
+ this.state = { name, type: "__data" };
1824
1858
  }
1825
- for (const name of sceneObject.variableDependency.getNames()) {
1826
- const variable = lookupVariable(name, sceneObject);
1827
- if (!variable) {
1828
- continue;
1859
+ getValue(fieldPath) {
1860
+ var _a, _b;
1861
+ const dataContext = (_a = this._scopedVars) == null ? void 0 : _a.__dataContext;
1862
+ if (!dataContext || !fieldPath) {
1863
+ return this._match;
1829
1864
  }
1830
- const set = variable.parent;
1831
- if (set.isVariableLoadingOrWaitingToUpdate(variable)) {
1832
- return true;
1865
+ const { frame, rowIndex } = dataContext.value;
1866
+ if (rowIndex === void 0 || fieldPath === void 0) {
1867
+ return this._match;
1833
1868
  }
1869
+ const obj = {
1870
+ name: frame.name,
1871
+ refId: frame.refId,
1872
+ fields: data.getFieldDisplayValuesProxy({ frame, rowIndex })
1873
+ };
1874
+ return (_b = getFieldAccessor(fieldPath)(obj)) != null ? _b : "";
1875
+ }
1876
+ getValueText() {
1877
+ return "";
1834
1878
  }
1835
- return false;
1836
1879
  }
1837
- function findObjectInternal(scene, check, alreadySearchedChild, shouldSearchUp) {
1838
- if (check(scene)) {
1839
- return scene;
1880
+ class SeriesMacro {
1881
+ constructor(name, sceneObject, _match, _scopedVars) {
1882
+ this._match = _match;
1883
+ this._scopedVars = _scopedVars;
1884
+ this.state = { name, type: "__series" };
1840
1885
  }
1841
- let found = null;
1842
- scene.forEachChild((child) => {
1843
- if (child === alreadySearchedChild) {
1844
- return;
1886
+ getValue(fieldPath) {
1887
+ var _a;
1888
+ const dataContext = (_a = this._scopedVars) == null ? void 0 : _a.__dataContext;
1889
+ if (!dataContext || !fieldPath) {
1890
+ return this._match;
1845
1891
  }
1846
- let maybe = findObjectInternal(child, check);
1847
- if (maybe) {
1848
- found = maybe;
1892
+ if (fieldPath !== "name") {
1893
+ return this._match;
1849
1894
  }
1850
- });
1851
- if (found) {
1852
- return found;
1895
+ const { frame, frameIndex } = dataContext.value;
1896
+ return data.getFrameDisplayName(frame, frameIndex);
1853
1897
  }
1854
- if (shouldSearchUp && scene.parent) {
1855
- return findObjectInternal(scene.parent, check, scene, true);
1898
+ getValueText() {
1899
+ return "";
1856
1900
  }
1857
- return null;
1858
1901
  }
1859
- function findByKey(sceneObject, key) {
1860
- const found = findObject(sceneObject, (sceneToCheck) => {
1861
- return sceneToCheck.state.key === key;
1862
- });
1863
- if (!found) {
1864
- throw new Error("Unable to find scene with key " + key);
1902
+ class FieldMacro {
1903
+ constructor(name, sceneObject, _match, _scopedVars) {
1904
+ this._match = _match;
1905
+ this._scopedVars = _scopedVars;
1906
+ this.state = { name, type: "__field" };
1865
1907
  }
1866
- return found;
1867
- }
1868
- function findByKeyAndType(sceneObject, key, targetType) {
1869
- const found = findObject(sceneObject, (sceneToCheck) => {
1870
- return sceneToCheck.state.key === key;
1871
- });
1872
- if (!found) {
1873
- throw new Error("Unable to find scene with key " + key);
1908
+ getValue(fieldPath) {
1909
+ var _a, _b;
1910
+ const dataContext = (_a = this._scopedVars) == null ? void 0 : _a.__dataContext;
1911
+ if (!dataContext || !fieldPath) {
1912
+ return this._match;
1913
+ }
1914
+ if (fieldPath === void 0 || fieldPath === "") {
1915
+ return this._match;
1916
+ }
1917
+ const { frame, field, data } = dataContext.value;
1918
+ const obj = getTemplateProxyForField(field, frame, data);
1919
+ return (_b = getFieldAccessor(fieldPath)(obj)) != null ? _b : "";
1874
1920
  }
1875
- if (!(found instanceof targetType)) {
1876
- throw new Error(`Found scene object with key ${key} does not match type ${targetType.name}`);
1921
+ getValueText() {
1922
+ return "";
1877
1923
  }
1878
- return found;
1879
1924
  }
1880
- function findObject(scene, check) {
1881
- return findObjectInternal(scene, check, void 0, true);
1882
- }
1883
- function findAllObjects(scene, check) {
1884
- const found = [];
1885
- scene.forEachChild((child) => {
1886
- if (check(child)) {
1887
- found.push(child);
1925
+
1926
+ class UrlMacro {
1927
+ constructor(name, _) {
1928
+ this.state = { name, type: "url_macro" };
1929
+ }
1930
+ getValue(fieldPath) {
1931
+ var _a;
1932
+ const location = runtime.locationService.getLocation();
1933
+ const subUrl = (_a = runtime.config.appSubUrl) != null ? _a : "";
1934
+ switch (fieldPath != null ? fieldPath : "") {
1935
+ case "params":
1936
+ return new UrlStateFormatter(location.search);
1937
+ case "path":
1938
+ return subUrl + location.pathname;
1939
+ case "":
1940
+ default:
1941
+ return subUrl + location.pathname + location.search;
1888
1942
  }
1889
- found.push(...findAllObjects(child, check));
1890
- });
1891
- return found;
1943
+ }
1944
+ getValueText() {
1945
+ return "";
1946
+ }
1892
1947
  }
1893
- function getDataLayers(sceneObject, localOnly = false) {
1894
- let currentLevel = sceneObject;
1895
- let collected = [];
1896
- while (currentLevel) {
1897
- const dataProvider = currentLevel.state.$data;
1898
- if (!dataProvider) {
1899
- currentLevel = currentLevel.parent;
1900
- continue;
1948
+ class UrlStateFormatter {
1949
+ constructor(_urlQueryParams) {
1950
+ this._urlQueryParams = _urlQueryParams;
1951
+ }
1952
+ formatter(options) {
1953
+ if (!options) {
1954
+ return this._urlQueryParams;
1901
1955
  }
1902
- if (isDataLayer(dataProvider)) {
1903
- collected = collected.concat(dataProvider);
1904
- } else {
1905
- if (dataProvider.state.$data && isDataLayer(dataProvider.state.$data)) {
1906
- collected = collected.concat(dataProvider.state.$data);
1956
+ const params = options.split(":");
1957
+ if (params[0] === "exclude" && params.length > 1) {
1958
+ const allParams = new URLSearchParams(this._urlQueryParams);
1959
+ for (const param of params[1].split(",")) {
1960
+ allParams.delete(param);
1907
1961
  }
1962
+ return `?${allParams}`;
1908
1963
  }
1909
- if (localOnly && collected.length > 0) {
1910
- break;
1964
+ if (params[0] === "include" && params.length > 1) {
1965
+ const allParams = new URLSearchParams(this._urlQueryParams);
1966
+ const includeOnly = params[1].split(",");
1967
+ for (const param of allParams.keys()) {
1968
+ if (!includeOnly.includes(param)) {
1969
+ allParams.delete(param);
1970
+ }
1971
+ }
1972
+ return `?${allParams}`;
1911
1973
  }
1912
- currentLevel = currentLevel.parent;
1974
+ return this._urlQueryParams;
1913
1975
  }
1914
- return collected;
1915
1976
  }
1916
- function getAncestor(sceneObject, ancestorType) {
1917
- let parent = sceneObject;
1918
- while (parent) {
1919
- if (parent instanceof ancestorType) {
1920
- return parent;
1977
+
1978
+ class UserMacro {
1979
+ constructor(name, _) {
1980
+ this.state = { name, type: "user_macro" };
1981
+ }
1982
+ getValue(fieldPath) {
1983
+ const user = runtime.config.bootData.user;
1984
+ switch (fieldPath) {
1985
+ case "login":
1986
+ return user.login;
1987
+ case "email":
1988
+ return user.email;
1989
+ case "id":
1990
+ default:
1991
+ return String(user.id);
1921
1992
  }
1922
- parent = parent.parent;
1923
1993
  }
1924
- if (!parent) {
1925
- throw new Error("Unable to find parent of type " + ancestorType.name);
1994
+ getValueText() {
1995
+ return "";
1926
1996
  }
1927
- return parent;
1928
1997
  }
1929
- function getQueryController(sceneObject) {
1930
- let parent = sceneObject;
1931
- while (parent) {
1932
- if (parent.state.$behaviors) {
1933
- for (const behavior of parent.state.$behaviors) {
1934
- if (isQueryController(behavior)) {
1935
- return behavior;
1936
- }
1937
- }
1998
+ class OrgMacro {
1999
+ constructor(name, _) {
2000
+ this.state = { name, type: "org_macro" };
2001
+ }
2002
+ getValue(fieldPath) {
2003
+ const user = runtime.config.bootData.user;
2004
+ switch (fieldPath) {
2005
+ case "name":
2006
+ return user.orgName;
2007
+ case "id":
2008
+ default:
2009
+ return String(user.orgId);
1938
2010
  }
1939
- parent = parent.parent;
1940
2011
  }
1941
- return void 0;
2012
+ getValueText() {
2013
+ return "";
2014
+ }
2015
+ }
2016
+
2017
+ const macrosIndex = {
2018
+ [data.DataLinkBuiltInVars.includeVars]: AllVariablesMacro,
2019
+ [data.DataLinkBuiltInVars.keepTime]: UrlTimeRangeMacro,
2020
+ ["__value"]: ValueMacro,
2021
+ ["__data"]: DataMacro,
2022
+ ["__series"]: SeriesMacro,
2023
+ ["__field"]: FieldMacro,
2024
+ ["__url"]: UrlMacro,
2025
+ ["__from"]: TimeFromAndToMacro,
2026
+ ["__to"]: TimeFromAndToMacro,
2027
+ ["__timezone"]: TimezoneMacro,
2028
+ ["__user"]: UserMacro,
2029
+ ["__org"]: OrgMacro,
2030
+ ["__interval"]: IntervalMacro,
2031
+ ["__interval_ms"]: IntervalMacro
2032
+ };
2033
+ function registerVariableMacro(name, macro) {
2034
+ if (macrosIndex[name]) {
2035
+ throw new Error(`Macro already registered ${name}`);
2036
+ }
2037
+ macrosIndex[name] = macro;
2038
+ return () => {
2039
+ delete macrosIndex[name];
2040
+ };
1942
2041
  }
1943
2042
 
1944
2043
  const sceneGraph = {
@@ -1958,117 +2057,6 @@ const sceneGraph = {
1958
2057
  getQueryController
1959
2058
  };
1960
2059
 
1961
- class UniqueUrlKeyMapper {
1962
- constructor() {
1963
- this.index = /* @__PURE__ */ new Map();
1964
- }
1965
- getUniqueKey(key, obj) {
1966
- const objectsWithKey = this.index.get(key);
1967
- if (!objectsWithKey) {
1968
- this.index.set(key, [obj]);
1969
- return key;
1970
- }
1971
- let address = objectsWithKey.findIndex((o) => o === obj);
1972
- if (address === -1) {
1973
- filterOutOrphanedObjects(objectsWithKey);
1974
- objectsWithKey.push(obj);
1975
- address = objectsWithKey.length - 1;
1976
- }
1977
- if (address > 0) {
1978
- return `${key}-${address + 1}`;
1979
- }
1980
- return key;
1981
- }
1982
- clear() {
1983
- this.index.clear();
1984
- }
1985
- }
1986
- function filterOutOrphanedObjects(sceneObjects) {
1987
- for (const obj of sceneObjects) {
1988
- if (isOrphanOrInActive(obj)) {
1989
- const index = sceneObjects.indexOf(obj);
1990
- sceneObjects.splice(index, 1);
1991
- }
1992
- }
1993
- }
1994
- function isOrphanOrInActive(obj) {
1995
- const root = obj.getRoot();
1996
- if (!sceneGraph.findObject(root, (child) => child === obj)) {
1997
- return true;
1998
- }
1999
- return false;
2000
- }
2001
-
2002
- function getUrlState(root) {
2003
- const urlKeyMapper = new UniqueUrlKeyMapper();
2004
- const result = {};
2005
- const visitNode = (obj) => {
2006
- if (obj.urlSync) {
2007
- const newUrlState = obj.urlSync.getUrlState();
2008
- for (const [key, value] of Object.entries(newUrlState)) {
2009
- if (value != null) {
2010
- const uniqueKey = urlKeyMapper.getUniqueKey(key, obj);
2011
- result[uniqueKey] = value;
2012
- }
2013
- }
2014
- }
2015
- obj.forEachChild(visitNode);
2016
- };
2017
- visitNode(root);
2018
- return result;
2019
- }
2020
- function syncStateFromSearchParams(root, urlParams) {
2021
- const urlKeyMapper = new UniqueUrlKeyMapper();
2022
- syncStateFromUrl(root, urlParams, urlKeyMapper);
2023
- }
2024
- function syncStateFromUrl(root, urlParams, urlKeyMapper) {
2025
- if (!root.parent) {
2026
- syncUrlStateToObject(root, urlParams, urlKeyMapper);
2027
- }
2028
- root.forEachChild((child) => {
2029
- syncUrlStateToObject(child, urlParams, urlKeyMapper);
2030
- });
2031
- root.forEachChild((child) => syncStateFromUrl(child, urlParams, urlKeyMapper));
2032
- }
2033
- function syncUrlStateToObject(sceneObject, urlParams, urlKeyMapper) {
2034
- if (sceneObject.urlSync) {
2035
- const urlState = {};
2036
- const currentState = sceneObject.urlSync.getUrlState();
2037
- for (const key of sceneObject.urlSync.getKeys()) {
2038
- const uniqueKey = urlKeyMapper.getUniqueKey(key, sceneObject);
2039
- const newValue = urlParams.getAll(uniqueKey);
2040
- const currentValue = currentState[key];
2041
- if (isUrlValueEqual(newValue, currentValue)) {
2042
- continue;
2043
- }
2044
- if (newValue.length > 0) {
2045
- if (Array.isArray(currentValue)) {
2046
- urlState[key] = newValue;
2047
- } else {
2048
- urlState[key] = newValue[0];
2049
- }
2050
- } else {
2051
- urlState[key] = null;
2052
- }
2053
- }
2054
- if (Object.keys(urlState).length > 0) {
2055
- sceneObject.urlSync.updateFromUrl(urlState);
2056
- }
2057
- }
2058
- }
2059
- function isUrlValueEqual(currentUrlValue, newUrlValue) {
2060
- if (currentUrlValue.length === 0 && newUrlValue == null) {
2061
- return true;
2062
- }
2063
- if (!Array.isArray(newUrlValue) && (currentUrlValue == null ? void 0 : currentUrlValue.length) === 1) {
2064
- return newUrlValue === currentUrlValue[0];
2065
- }
2066
- if ((newUrlValue == null ? void 0 : newUrlValue.length) === 0 && currentUrlValue === null) {
2067
- return true;
2068
- }
2069
- return lodash.isEqual(currentUrlValue, newUrlValue);
2070
- }
2071
-
2072
2060
  async function getDataSource(datasource, scopedVars) {
2073
2061
  if (datasource == null ? void 0 : datasource.uid) {
2074
2062
  const runtimeDataSource = runtimeDataSources.get(datasource.uid);
@@ -2083,11 +2071,7 @@ async function getDataSource(datasource, scopedVars) {
2083
2071
  }
2084
2072
 
2085
2073
  function writeSceneLog(logger, message, ...rest) {
2086
- let loggingEnabled = false;
2087
- if (typeof window !== "undefined") {
2088
- loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
2089
- }
2090
- if (loggingEnabled) {
2074
+ if (window.grafanaSceneLogging) {
2091
2075
  console.log(`${logger}: `, message, ...rest);
2092
2076
  }
2093
2077
  }
@@ -2267,55 +2251,186 @@ class VariableValueRecorder {
2267
2251
  }
2268
2252
  }
2269
2253
  }
2270
- return false;
2254
+ return false;
2255
+ }
2256
+ }
2257
+
2258
+ var __defProp$C = Object.defineProperty;
2259
+ var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
2260
+ var __hasOwnProp$C = Object.prototype.hasOwnProperty;
2261
+ var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
2262
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2263
+ var __spreadValues$C = (a, b) => {
2264
+ for (var prop in b || (b = {}))
2265
+ if (__hasOwnProp$C.call(b, prop))
2266
+ __defNormalProp$C(a, prop, b[prop]);
2267
+ if (__getOwnPropSymbols$C)
2268
+ for (var prop of __getOwnPropSymbols$C(b)) {
2269
+ if (__propIsEnum$C.call(b, prop))
2270
+ __defNormalProp$C(a, prop, b[prop]);
2271
+ }
2272
+ return a;
2273
+ };
2274
+ const PREVIOUS_PERIOD_VALUE = "__previousPeriod";
2275
+ const NO_PERIOD_VALUE = "__noPeriod";
2276
+ const PREVIOUS_PERIOD_COMPARE_OPTION = {
2277
+ label: "Previous period",
2278
+ value: PREVIOUS_PERIOD_VALUE
2279
+ };
2280
+ const NO_COMPARE_OPTION = {
2281
+ label: "No comparison",
2282
+ value: NO_PERIOD_VALUE
2283
+ };
2284
+ const DEFAULT_COMPARE_OPTIONS = [
2285
+ { label: "Day before", value: "24h" },
2286
+ { label: "Week before", value: "1w" },
2287
+ { label: "Month before", value: "1M" }
2288
+ ];
2289
+ class SceneTimeRangeCompare extends SceneObjectBase {
2290
+ constructor(state) {
2291
+ super(__spreadValues$C({ compareOptions: DEFAULT_COMPARE_OPTIONS }, state));
2292
+ this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["compareWith"] });
2293
+ this._onActivate = () => {
2294
+ const sceneTimeRange = sceneGraph.getTimeRange(this);
2295
+ this.setState({ compareOptions: this.getCompareOptions(sceneTimeRange.state.value) });
2296
+ this._subs.add(
2297
+ sceneTimeRange.subscribeToState((timeRange) => {
2298
+ const compareOptions = this.getCompareOptions(timeRange.value);
2299
+ const stateUpdate = { compareOptions };
2300
+ if (Boolean(this.state.compareWith) && !compareOptions.find(({ value }) => value === this.state.compareWith)) {
2301
+ stateUpdate.compareWith = PREVIOUS_PERIOD_VALUE;
2302
+ }
2303
+ this.setState(stateUpdate);
2304
+ })
2305
+ );
2306
+ };
2307
+ this.getCompareOptions = (timeRange) => {
2308
+ const diffDays = Math.ceil(timeRange.to.diff(timeRange.from));
2309
+ const matchIndex = DEFAULT_COMPARE_OPTIONS.findIndex(({ value }) => {
2310
+ const intervalInMs = data.rangeUtil.intervalToMs(value);
2311
+ return intervalInMs >= diffDays;
2312
+ });
2313
+ return [
2314
+ NO_COMPARE_OPTION,
2315
+ PREVIOUS_PERIOD_COMPARE_OPTION,
2316
+ ...DEFAULT_COMPARE_OPTIONS.slice(matchIndex).map(({ label, value }) => ({ label, value }))
2317
+ ];
2318
+ };
2319
+ this.onCompareWithChanged = (compareWith) => {
2320
+ if (compareWith === NO_PERIOD_VALUE) {
2321
+ this.onClearCompare();
2322
+ } else {
2323
+ this.setState({ compareWith });
2324
+ }
2325
+ };
2326
+ this.onClearCompare = () => {
2327
+ this.setState({ compareWith: void 0 });
2328
+ };
2329
+ this.addActivationHandler(this._onActivate);
2330
+ }
2331
+ getCompareTimeRange(timeRange) {
2332
+ let compareFrom;
2333
+ let compareTo;
2334
+ if (this.state.compareWith) {
2335
+ if (this.state.compareWith === PREVIOUS_PERIOD_VALUE) {
2336
+ const diffMs = timeRange.to.diff(timeRange.from);
2337
+ compareFrom = data.dateTime(timeRange.from).subtract(diffMs);
2338
+ compareTo = data.dateTime(timeRange.to).subtract(diffMs);
2339
+ } else {
2340
+ compareFrom = data.dateTime(timeRange.from).subtract(data.rangeUtil.intervalToMs(this.state.compareWith));
2341
+ compareTo = data.dateTime(timeRange.to).subtract(data.rangeUtil.intervalToMs(this.state.compareWith));
2342
+ }
2343
+ return {
2344
+ from: compareFrom,
2345
+ to: compareTo,
2346
+ raw: {
2347
+ from: compareFrom,
2348
+ to: compareTo
2349
+ }
2350
+ };
2351
+ }
2352
+ return void 0;
2353
+ }
2354
+ getUrlState() {
2355
+ return {
2356
+ compareWith: this.state.compareWith
2357
+ };
2358
+ }
2359
+ updateFromUrl(values) {
2360
+ if (!values.compareWith) {
2361
+ return;
2362
+ }
2363
+ const compareWith = parseUrlParam(values.compareWith);
2364
+ if (compareWith) {
2365
+ const compareOptions = this.getCompareOptions(sceneGraph.getTimeRange(this).state.value);
2366
+ if (compareOptions.find(({ value }) => value === compareWith)) {
2367
+ this.setState({
2368
+ compareWith
2369
+ });
2370
+ } else {
2371
+ this.setState({
2372
+ compareWith: "__previousPeriod"
2373
+ });
2374
+ }
2375
+ }
2271
2376
  }
2272
2377
  }
2273
-
2274
- function isExtraQueryProvider(obj) {
2275
- return typeof obj === "object" && "getExtraQueries" in obj;
2276
- }
2277
-
2278
- var __defProp$C = Object.defineProperty;
2279
- var __defProps$q = Object.defineProperties;
2280
- var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
2281
- var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
2282
- var __hasOwnProp$C = Object.prototype.hasOwnProperty;
2283
- var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
2284
- var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2285
- var __spreadValues$C = (a, b) => {
2286
- for (var prop in b || (b = {}))
2287
- if (__hasOwnProp$C.call(b, prop))
2288
- __defNormalProp$C(a, prop, b[prop]);
2289
- if (__getOwnPropSymbols$C)
2290
- for (var prop of __getOwnPropSymbols$C(b)) {
2291
- if (__propIsEnum$C.call(b, prop))
2292
- __defNormalProp$C(a, prop, b[prop]);
2378
+ SceneTimeRangeCompare.Component = SceneTimeRangeCompareRenderer;
2379
+ function SceneTimeRangeCompareRenderer({ model }) {
2380
+ var _a;
2381
+ const styles = ui.useStyles2(getStyles$9);
2382
+ const { compareWith, compareOptions } = model.useState();
2383
+ const [previousCompare, setPreviousCompare] = React__default["default"].useState(compareWith);
2384
+ const previousValue = (_a = compareOptions.find(({ value: value2 }) => value2 === previousCompare)) != null ? _a : PREVIOUS_PERIOD_COMPARE_OPTION;
2385
+ const value = compareOptions.find(({ value: value2 }) => value2 === compareWith);
2386
+ const enabled = Boolean(value);
2387
+ const onClick = () => {
2388
+ if (enabled) {
2389
+ setPreviousCompare(compareWith);
2390
+ model.onClearCompare();
2391
+ } else if (!enabled) {
2392
+ model.onCompareWithChanged(previousValue.value);
2293
2393
  }
2294
- return a;
2295
- };
2296
- var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
2297
- const passthroughProcessor = (_, secondary) => rxjs.of(secondary);
2298
- const extraQueryProcessingOperator = (processors) => (data) => {
2299
- return data.pipe(
2300
- rxjs.mergeMap(([primary, ...secondaries]) => {
2301
- const processedSecondaries = secondaries.flatMap((s) => {
2302
- var _a, _b;
2303
- return (_b = (_a = processors.get(s.request.requestId)) == null ? void 0 : _a(primary, s)) != null ? _b : rxjs.of(s);
2304
- });
2305
- return rxjs.forkJoin([rxjs.of(primary), ...processedSecondaries]);
2306
- }),
2307
- rxjs.map(([primary, ...processedSecondaries]) => {
2308
- var _a;
2309
- return __spreadProps$q(__spreadValues$C({}, primary), {
2310
- series: [...primary.series, ...processedSecondaries.flatMap((s) => s.series)],
2311
- annotations: [...(_a = primary.annotations) != null ? _a : [], ...processedSecondaries.flatMap((s) => {
2312
- var _a2;
2313
- return (_a2 = s.annotations) != null ? _a2 : [];
2314
- })]
2315
- });
2394
+ };
2395
+ return /* @__PURE__ */ React__default["default"].createElement(ui.ButtonGroup, null, /* @__PURE__ */ React__default["default"].createElement(ui.ToolbarButton, {
2396
+ variant: "canvas",
2397
+ tooltip: "Enable time frame comparison",
2398
+ onClick: (e) => {
2399
+ e.stopPropagation();
2400
+ e.preventDefault();
2401
+ onClick();
2402
+ }
2403
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Checkbox, {
2404
+ label: " ",
2405
+ value: enabled,
2406
+ onClick
2407
+ }), "Comparison"), enabled ? /* @__PURE__ */ React__default["default"].createElement(ui.ButtonSelect, {
2408
+ variant: "canvas",
2409
+ value,
2410
+ options: compareOptions,
2411
+ onChange: (v) => {
2412
+ model.onCompareWithChanged(v.value);
2413
+ }
2414
+ }) : /* @__PURE__ */ React__default["default"].createElement(ui.ToolbarButton, {
2415
+ className: styles.previewButton,
2416
+ disabled: true,
2417
+ variant: "canvas",
2418
+ isOpen: false
2419
+ }, previousValue.label));
2420
+ }
2421
+ function getStyles$9(theme) {
2422
+ return {
2423
+ previewButton: css.css({
2424
+ "&:disabled": {
2425
+ border: `1px solid ${theme.colors.secondary.border}`,
2426
+ color: theme.colors.text.disabled,
2427
+ opacity: 1
2428
+ }
2316
2429
  })
2317
- );
2318
- };
2430
+ };
2431
+ }
2432
+
2433
+ const getCompareSeriesRefId = (refId) => `${refId}-compare`;
2319
2434
 
2320
2435
  var __defProp$B = Object.defineProperty;
2321
2436
  var __defProps$p = Object.defineProperties;
@@ -2336,6 +2451,59 @@ var __spreadValues$B = (a, b) => {
2336
2451
  return a;
2337
2452
  };
2338
2453
  var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
2454
+ function timeShiftQueryResponseOperator(data$1) {
2455
+ return data$1.pipe(
2456
+ rxjs.map(([p, s]) => {
2457
+ const diff = s.timeRange.from.diff(p.timeRange.from);
2458
+ s.series.forEach((series) => {
2459
+ series.refId = getCompareSeriesRefId(series.refId || "");
2460
+ series.meta = __spreadProps$p(__spreadValues$B({}, series.meta), {
2461
+ timeCompare: {
2462
+ diffMs: diff,
2463
+ isTimeShiftQuery: true
2464
+ }
2465
+ });
2466
+ series.fields.forEach((field) => {
2467
+ if (field.type === data.FieldType.time) {
2468
+ field.values = field.values.map((v) => {
2469
+ return diff < 0 ? v - diff : v + diff;
2470
+ });
2471
+ }
2472
+ field.config = __spreadProps$p(__spreadValues$B({}, field.config), {
2473
+ color: {
2474
+ mode: "fixed",
2475
+ fixedColor: runtime.config.theme.palette.gray60
2476
+ }
2477
+ });
2478
+ return field;
2479
+ });
2480
+ });
2481
+ return __spreadProps$p(__spreadValues$B({}, p), {
2482
+ series: [...p.series, ...s.series]
2483
+ });
2484
+ })
2485
+ );
2486
+ }
2487
+
2488
+ var __defProp$A = Object.defineProperty;
2489
+ var __defProps$o = Object.defineProperties;
2490
+ var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
2491
+ var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
2492
+ var __hasOwnProp$A = Object.prototype.hasOwnProperty;
2493
+ var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
2494
+ var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2495
+ var __spreadValues$A = (a, b) => {
2496
+ for (var prop in b || (b = {}))
2497
+ if (__hasOwnProp$A.call(b, prop))
2498
+ __defNormalProp$A(a, prop, b[prop]);
2499
+ if (__getOwnPropSymbols$A)
2500
+ for (var prop of __getOwnPropSymbols$A(b)) {
2501
+ if (__propIsEnum$A.call(b, prop))
2502
+ __defNormalProp$A(a, prop, b[prop]);
2503
+ }
2504
+ return a;
2505
+ };
2506
+ var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
2339
2507
  function filterAnnotations(data, filters) {
2340
2508
  var _a;
2341
2509
  if (!Array.isArray(data) || data.length === 0) {
@@ -2386,11 +2554,11 @@ function filterAnnotations(data, filters) {
2386
2554
  continue;
2387
2555
  }
2388
2556
  }
2389
- fields.push(__spreadProps$p(__spreadValues$B({}, field), {
2557
+ fields.push(__spreadProps$o(__spreadValues$A({}, field), {
2390
2558
  values: buffer
2391
2559
  }));
2392
2560
  }
2393
- processed.push(__spreadProps$p(__spreadValues$B({}, frame), {
2561
+ processed.push(__spreadProps$o(__spreadValues$A({}, frame), {
2394
2562
  fields,
2395
2563
  length: frameLength
2396
2564
  }));
@@ -2822,33 +2990,33 @@ function getOptionSearcher(options, includeAll, value, text) {
2822
2990
  };
2823
2991
  }
2824
2992
 
2825
- var __defProp$A = Object.defineProperty;
2826
- var __defProps$o = Object.defineProperties;
2827
- var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
2828
- var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
2829
- var __hasOwnProp$A = Object.prototype.hasOwnProperty;
2830
- var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
2831
- var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2832
- var __spreadValues$A = (a, b) => {
2993
+ var __defProp$z = Object.defineProperty;
2994
+ var __defProps$n = Object.defineProperties;
2995
+ var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
2996
+ var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
2997
+ var __hasOwnProp$z = Object.prototype.hasOwnProperty;
2998
+ var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
2999
+ var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3000
+ var __spreadValues$z = (a, b) => {
2833
3001
  for (var prop in b || (b = {}))
2834
- if (__hasOwnProp$A.call(b, prop))
2835
- __defNormalProp$A(a, prop, b[prop]);
2836
- if (__getOwnPropSymbols$A)
2837
- for (var prop of __getOwnPropSymbols$A(b)) {
2838
- if (__propIsEnum$A.call(b, prop))
2839
- __defNormalProp$A(a, prop, b[prop]);
3002
+ if (__hasOwnProp$z.call(b, prop))
3003
+ __defNormalProp$z(a, prop, b[prop]);
3004
+ if (__getOwnPropSymbols$z)
3005
+ for (var prop of __getOwnPropSymbols$z(b)) {
3006
+ if (__propIsEnum$z.call(b, prop))
3007
+ __defNormalProp$z(a, prop, b[prop]);
2840
3008
  }
2841
3009
  return a;
2842
3010
  };
2843
- var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
3011
+ var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
2844
3012
  var __objRest$3 = (source, exclude) => {
2845
3013
  var target = {};
2846
3014
  for (var prop in source)
2847
- if (__hasOwnProp$A.call(source, prop) && exclude.indexOf(prop) < 0)
3015
+ if (__hasOwnProp$z.call(source, prop) && exclude.indexOf(prop) < 0)
2848
3016
  target[prop] = source[prop];
2849
- if (source != null && __getOwnPropSymbols$A)
2850
- for (var prop of __getOwnPropSymbols$A(source)) {
2851
- if (exclude.indexOf(prop) < 0 && __propIsEnum$A.call(source, prop))
3017
+ if (source != null && __getOwnPropSymbols$z)
3018
+ for (var prop of __getOwnPropSymbols$z(source)) {
3019
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$z.call(source, prop))
2852
3020
  target[prop] = source[prop];
2853
3021
  }
2854
3022
  return target;
@@ -2975,7 +3143,7 @@ const OptionWithCheckbox = ({
2975
3143
  const theme = ui.useTheme2();
2976
3144
  const selectStyles = ui.getSelectStyles(theme);
2977
3145
  const optionStyles = ui.useStyles2(getOptionStyles);
2978
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$o(__spreadValues$A({
3146
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$n(__spreadValues$z({
2979
3147
  ref: innerRef,
2980
3148
  className: css.cx(selectStyles.option, isFocused && selectStyles.optionFocused)
2981
3149
  }, rest), {
@@ -3069,28 +3237,28 @@ function fromUrlValues(urlValues) {
3069
3237
  );
3070
3238
  }
3071
3239
 
3072
- var __defProp$z = Object.defineProperty;
3073
- var __defProps$n = Object.defineProperties;
3074
- var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
3075
- var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
3076
- var __hasOwnProp$z = Object.prototype.hasOwnProperty;
3077
- var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
3078
- var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3079
- var __spreadValues$z = (a, b) => {
3240
+ var __defProp$y = Object.defineProperty;
3241
+ var __defProps$m = Object.defineProperties;
3242
+ var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
3243
+ var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
3244
+ var __hasOwnProp$y = Object.prototype.hasOwnProperty;
3245
+ var __propIsEnum$y = Object.prototype.propertyIsEnumerable;
3246
+ var __defNormalProp$y = (obj, key, value) => key in obj ? __defProp$y(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3247
+ var __spreadValues$y = (a, b) => {
3080
3248
  for (var prop in b || (b = {}))
3081
- if (__hasOwnProp$z.call(b, prop))
3082
- __defNormalProp$z(a, prop, b[prop]);
3083
- if (__getOwnPropSymbols$z)
3084
- for (var prop of __getOwnPropSymbols$z(b)) {
3085
- if (__propIsEnum$z.call(b, prop))
3086
- __defNormalProp$z(a, prop, b[prop]);
3249
+ if (__hasOwnProp$y.call(b, prop))
3250
+ __defNormalProp$y(a, prop, b[prop]);
3251
+ if (__getOwnPropSymbols$y)
3252
+ for (var prop of __getOwnPropSymbols$y(b)) {
3253
+ if (__propIsEnum$y.call(b, prop))
3254
+ __defNormalProp$y(a, prop, b[prop]);
3087
3255
  }
3088
3256
  return a;
3089
3257
  };
3090
- var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
3258
+ var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
3091
3259
  class GroupByVariable extends MultiValueVariable {
3092
3260
  constructor(initialState) {
3093
- super(__spreadProps$n(__spreadValues$z({
3261
+ super(__spreadProps$m(__spreadValues$y({
3094
3262
  isMulti: true,
3095
3263
  name: "",
3096
3264
  value: [],
@@ -3289,7 +3457,7 @@ function LoadingIndicator(props) {
3289
3457
  }
3290
3458
 
3291
3459
  function ControlsLabel(props) {
3292
- const styles = ui.useStyles2(getStyles$9);
3460
+ const styles = ui.useStyles2(getStyles$8);
3293
3461
  const theme = ui.useTheme2();
3294
3462
  const isVertical = props.layout === "vertical";
3295
3463
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -3352,7 +3520,7 @@ function ControlsLabel(props) {
3352
3520
  }
3353
3521
  return labelElement;
3354
3522
  }
3355
- const getStyles$9 = (theme) => ({
3523
+ const getStyles$8 = (theme) => ({
3356
3524
  horizontalLabel: css.css({
3357
3525
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
3358
3526
  display: `flex`,
@@ -3387,6 +3555,13 @@ const getStyles$9 = (theme) => ({
3387
3555
  })
3388
3556
  });
3389
3557
 
3558
+ function selectableValueToVariableValueOption(value) {
3559
+ var _a;
3560
+ return {
3561
+ label: (_a = value.label) != null ? _a : String(value.value),
3562
+ value: value.value
3563
+ };
3564
+ }
3390
3565
  function keyLabelToOption(key, label) {
3391
3566
  return key !== "" ? {
3392
3567
  value: key,
@@ -3395,16 +3570,33 @@ function keyLabelToOption(key, label) {
3395
3570
  }
3396
3571
  function AdHocFilterRenderer({ filter, model }) {
3397
3572
  var _a, _b;
3398
- const styles = ui.useStyles2(getStyles$8);
3573
+ const styles = ui.useStyles2(getStyles$7);
3399
3574
  const [keys, setKeys] = React.useState([]);
3400
3575
  const [values, setValues] = React.useState([]);
3401
3576
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
3402
3577
  const [isValuesLoading, setIsValuesLoading] = React.useState(false);
3403
3578
  const [isKeysOpen, setIsKeysOpen] = React.useState(false);
3404
3579
  const [isValuesOpen, setIsValuesOpen] = React.useState(false);
3580
+ const [valueInputValue, setValueInputValue] = React.useState("");
3581
+ const [valueHasCustomValue, setValueHasCustomValue] = React.useState(false);
3405
3582
  const keyValue = keyLabelToOption(filter.key, filter.keyLabel);
3406
3583
  const valueValue = keyLabelToOption(filter.value, filter.valueLabel);
3584
+ const optionSearcher = React.useMemo(
3585
+ () => {
3586
+ var _a2, _b2;
3587
+ return getOptionSearcher(values.map(selectableValueToVariableValueOption), void 0, (_a2 = valueValue == null ? void 0 : valueValue.value) != null ? _a2 : "", (_b2 = valueValue == null ? void 0 : valueValue.label) != null ? _b2 : "");
3588
+ },
3589
+ [values, valueValue == null ? void 0 : valueValue.value, valueValue == null ? void 0 : valueValue.label]
3590
+ );
3591
+ const onValueInputChange = (value, { action }) => {
3592
+ if (action === "input-change") {
3593
+ setValueInputValue(value);
3594
+ }
3595
+ return value;
3596
+ };
3597
+ const filteredValueOptions = optionSearcher(valueInputValue);
3407
3598
  const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, {
3599
+ virtualized: true,
3408
3600
  allowCustomValue: true,
3409
3601
  isValidNewOption: (inputValue) => inputValue.trim().length > 0,
3410
3602
  allowCreateWhileLoading: true,
@@ -3414,21 +3606,33 @@ function AdHocFilterRenderer({ filter, model }) {
3414
3606
  width: "auto",
3415
3607
  value: valueValue,
3416
3608
  placeholder: "Select value",
3417
- options: values,
3418
- onChange: (v) => model._updateFilter(filter, "value", v),
3609
+ options: filteredValueOptions,
3610
+ inputValue: valueInputValue,
3611
+ onInputChange: onValueInputChange,
3612
+ onChange: (v) => {
3613
+ model._updateFilter(filter, "value", v);
3614
+ if (valueHasCustomValue !== v.__isNew__) {
3615
+ setValueHasCustomValue(v.__isNew__);
3616
+ }
3617
+ },
3419
3618
  isOpen: isValuesOpen && !isValuesLoading,
3420
3619
  isLoading: isValuesLoading,
3421
3620
  autoFocus: filter.key !== "" && filter.value === "",
3422
3621
  openMenuOnFocus: true,
3423
3622
  onOpenMenu: async () => {
3623
+ var _a2;
3424
3624
  setIsValuesLoading(true);
3425
3625
  setIsValuesOpen(true);
3426
3626
  const values2 = await model._getValuesFor(filter);
3427
3627
  setIsValuesLoading(false);
3428
3628
  setValues(values2);
3629
+ if (valueHasCustomValue) {
3630
+ setValueInputValue((_a2 = valueValue == null ? void 0 : valueValue.label) != null ? _a2 : "");
3631
+ }
3429
3632
  },
3430
3633
  onCloseMenu: () => {
3431
3634
  setIsValuesOpen(false);
3635
+ setValueInputValue("");
3432
3636
  }
3433
3637
  });
3434
3638
  const keySelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, {
@@ -3500,7 +3704,7 @@ function AdHocFilterRenderer({ filter, model }) {
3500
3704
  onClick: () => model._removeFilter(filter)
3501
3705
  }));
3502
3706
  }
3503
- const getStyles$8 = (theme) => ({
3707
+ const getStyles$7 = (theme) => ({
3504
3708
  field: css.css({
3505
3709
  marginBottom: 0
3506
3710
  }),
@@ -3638,29 +3842,29 @@ function isFilter(filter) {
3638
3842
  return filter !== null && typeof filter.key === "string" && typeof filter.value === "string";
3639
3843
  }
3640
3844
 
3641
- var __defProp$y = Object.defineProperty;
3642
- var __defProps$m = Object.defineProperties;
3643
- var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
3644
- var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
3645
- var __hasOwnProp$y = Object.prototype.hasOwnProperty;
3646
- var __propIsEnum$y = Object.prototype.propertyIsEnumerable;
3647
- var __defNormalProp$y = (obj, key, value) => key in obj ? __defProp$y(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3648
- var __spreadValues$y = (a, b) => {
3845
+ var __defProp$x = Object.defineProperty;
3846
+ var __defProps$l = Object.defineProperties;
3847
+ var __getOwnPropDescs$l = Object.getOwnPropertyDescriptors;
3848
+ var __getOwnPropSymbols$x = Object.getOwnPropertySymbols;
3849
+ var __hasOwnProp$x = Object.prototype.hasOwnProperty;
3850
+ var __propIsEnum$x = Object.prototype.propertyIsEnumerable;
3851
+ var __defNormalProp$x = (obj, key, value) => key in obj ? __defProp$x(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3852
+ var __spreadValues$x = (a, b) => {
3649
3853
  for (var prop in b || (b = {}))
3650
- if (__hasOwnProp$y.call(b, prop))
3651
- __defNormalProp$y(a, prop, b[prop]);
3652
- if (__getOwnPropSymbols$y)
3653
- for (var prop of __getOwnPropSymbols$y(b)) {
3654
- if (__propIsEnum$y.call(b, prop))
3655
- __defNormalProp$y(a, prop, b[prop]);
3854
+ if (__hasOwnProp$x.call(b, prop))
3855
+ __defNormalProp$x(a, prop, b[prop]);
3856
+ if (__getOwnPropSymbols$x)
3857
+ for (var prop of __getOwnPropSymbols$x(b)) {
3858
+ if (__propIsEnum$x.call(b, prop))
3859
+ __defNormalProp$x(a, prop, b[prop]);
3656
3860
  }
3657
3861
  return a;
3658
3862
  };
3659
- var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
3863
+ var __spreadProps$l = (a, b) => __defProps$l(a, __getOwnPropDescs$l(b));
3660
3864
  class AdHocFiltersVariable extends SceneObjectBase {
3661
3865
  constructor(state) {
3662
3866
  var _a, _b;
3663
- super(__spreadValues$y({
3867
+ super(__spreadValues$x({
3664
3868
  type: "adhoc",
3665
3869
  name: (_a = state.name) != null ? _a : "Filters",
3666
3870
  filters: [],
@@ -3697,15 +3901,15 @@ class AdHocFiltersVariable extends SceneObjectBase {
3697
3901
  const propLabelKey = `${prop}Label`;
3698
3902
  if (filter === _wip) {
3699
3903
  if (prop === "value") {
3700
- this.setState({ filters: [...filters, __spreadProps$m(__spreadValues$y({}, _wip), { [prop]: value, [propLabelKey]: label })], _wip: void 0 });
3904
+ this.setState({ filters: [...filters, __spreadProps$l(__spreadValues$x({}, _wip), { [prop]: value, [propLabelKey]: label })], _wip: void 0 });
3701
3905
  } else {
3702
- this.setState({ _wip: __spreadProps$m(__spreadValues$y({}, filter), { [prop]: value, [propLabelKey]: label }) });
3906
+ this.setState({ _wip: __spreadProps$l(__spreadValues$x({}, filter), { [prop]: value, [propLabelKey]: label }) });
3703
3907
  }
3704
3908
  return;
3705
3909
  }
3706
3910
  const updatedFilters = this.state.filters.map((f) => {
3707
3911
  if (f === filter) {
3708
- const updatedFilter = __spreadProps$m(__spreadValues$y({}, f), { [prop]: value, [propLabelKey]: label });
3912
+ const updatedFilter = __spreadProps$l(__spreadValues$x({}, f), { [prop]: value, [propLabelKey]: label });
3709
3913
  if (prop === "key" && filter[prop] !== value) {
3710
3914
  updatedFilter.value = "";
3711
3915
  updatedFilter.valueLabel = "";
@@ -3786,7 +3990,7 @@ function renderExpression(builder, filters) {
3786
3990
  }
3787
3991
  function AdHocFiltersVariableRenderer({ model }) {
3788
3992
  const { filters, readOnly, addFilterButtonText } = model.useState();
3789
- const styles = ui.useStyles2(getStyles$7);
3993
+ const styles = ui.useStyles2(getStyles$6);
3790
3994
  return /* @__PURE__ */ React__default["default"].createElement("div", {
3791
3995
  className: styles.wrapper
3792
3996
  }, filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, {
@@ -3800,7 +4004,7 @@ function AdHocFiltersVariableRenderer({ model }) {
3800
4004
  addFilterButtonText
3801
4005
  }));
3802
4006
  }
3803
- const getStyles$7 = (theme) => ({
4007
+ const getStyles$6 = (theme) => ({
3804
4008
  wrapper: css.css({
3805
4009
  display: "flex",
3806
4010
  flexWrap: "wrap",
@@ -3884,25 +4088,25 @@ function areDifferentLayers(a, b) {
3884
4088
  return false;
3885
4089
  }
3886
4090
 
3887
- var __defProp$x = Object.defineProperty;
3888
- var __defProps$l = Object.defineProperties;
3889
- var __getOwnPropDescs$l = Object.getOwnPropertyDescriptors;
3890
- var __getOwnPropSymbols$x = Object.getOwnPropertySymbols;
3891
- var __hasOwnProp$x = Object.prototype.hasOwnProperty;
3892
- var __propIsEnum$x = Object.prototype.propertyIsEnumerable;
3893
- var __defNormalProp$x = (obj, key, value) => key in obj ? __defProp$x(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3894
- var __spreadValues$x = (a, b) => {
4091
+ var __defProp$w = Object.defineProperty;
4092
+ var __defProps$k = Object.defineProperties;
4093
+ var __getOwnPropDescs$k = Object.getOwnPropertyDescriptors;
4094
+ var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
4095
+ var __hasOwnProp$w = Object.prototype.hasOwnProperty;
4096
+ var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
4097
+ var __defNormalProp$w = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4098
+ var __spreadValues$w = (a, b) => {
3895
4099
  for (var prop in b || (b = {}))
3896
- if (__hasOwnProp$x.call(b, prop))
3897
- __defNormalProp$x(a, prop, b[prop]);
3898
- if (__getOwnPropSymbols$x)
3899
- for (var prop of __getOwnPropSymbols$x(b)) {
3900
- if (__propIsEnum$x.call(b, prop))
3901
- __defNormalProp$x(a, prop, b[prop]);
4100
+ if (__hasOwnProp$w.call(b, prop))
4101
+ __defNormalProp$w(a, prop, b[prop]);
4102
+ if (__getOwnPropSymbols$w)
4103
+ for (var prop of __getOwnPropSymbols$w(b)) {
4104
+ if (__propIsEnum$w.call(b, prop))
4105
+ __defNormalProp$w(a, prop, b[prop]);
3902
4106
  }
3903
4107
  return a;
3904
4108
  };
3905
- var __spreadProps$l = (a, b) => __defProps$l(a, __getOwnPropDescs$l(b));
4109
+ var __spreadProps$k = (a, b) => __defProps$k(a, __getOwnPropDescs$k(b));
3906
4110
  let counter$1 = 100;
3907
4111
  function getNextRequestId$1() {
3908
4112
  return "SQR" + counter$1++;
@@ -3919,6 +4123,70 @@ class SceneQueryRunner extends SceneObjectBase {
3919
4123
  onVariableUpdateCompleted: this.onVariableUpdatesCompleted.bind(this),
3920
4124
  onAnyVariableChanged: this.onAnyVariableChanged.bind(this)
3921
4125
  });
4126
+ this.prepareRequests = (timeRange, ds) => {
4127
+ const comparer = this.getTimeCompare();
4128
+ const { minInterval, queries } = this.state;
4129
+ let secondaryRequest;
4130
+ let request = __spreadValues$w({
4131
+ app: "scenes",
4132
+ requestId: getNextRequestId$1(),
4133
+ timezone: timeRange.getTimeZone(),
4134
+ panelId: 1,
4135
+ range: timeRange.state.value,
4136
+ interval: "1s",
4137
+ intervalMs: 1e3,
4138
+ targets: lodash.cloneDeep(queries),
4139
+ maxDataPoints: this.getMaxDataPoints(),
4140
+ scopedVars: this._scopedVars,
4141
+ startTime: Date.now(),
4142
+ liveStreaming: this.state.liveStreaming,
4143
+ rangeRaw: {
4144
+ from: timeRange.state.from,
4145
+ to: timeRange.state.to
4146
+ },
4147
+ cacheTimeout: this.state.cacheTimeout,
4148
+ queryCachingTTL: this.state.queryCachingTTL
4149
+ }, getEnrichedDataRequest(this));
4150
+ if (this._adhocFiltersVar) {
4151
+ request.filters = this._adhocFiltersVar.state.filters.filter(isFilterComplete);
4152
+ }
4153
+ if (this._groupByVar) {
4154
+ request.groupByKeys = this._groupByVar.state.value;
4155
+ }
4156
+ request.targets = request.targets.map((query) => {
4157
+ var _a;
4158
+ if (!query.datasource || query.datasource.uid !== ds.uid && !((_a = ds.meta) == null ? void 0 : _a.mixed) && runtime.isExpressionReference && !runtime.isExpressionReference(query.datasource)) {
4159
+ query.datasource = ds.getRef();
4160
+ }
4161
+ return query;
4162
+ });
4163
+ const lowerIntervalLimit = minInterval ? minInterval : ds.interval;
4164
+ const norm = data.rangeUtil.calculateInterval(timeRange.state.value, request.maxDataPoints, lowerIntervalLimit);
4165
+ request.scopedVars = Object.assign({}, request.scopedVars, {
4166
+ __interval: { text: norm.interval, value: norm.interval },
4167
+ __interval_ms: { text: norm.intervalMs.toString(), value: norm.intervalMs }
4168
+ });
4169
+ request.interval = norm.interval;
4170
+ request.intervalMs = norm.intervalMs;
4171
+ const primaryTimeRange = timeRange.state.value;
4172
+ if (comparer) {
4173
+ const secondaryTimeRange = comparer.getCompareTimeRange(primaryTimeRange);
4174
+ if (secondaryTimeRange) {
4175
+ const secondaryTargets = request.targets.filter((query) => query.timeRangeCompare !== false);
4176
+ if (secondaryTargets.length) {
4177
+ secondaryRequest = __spreadProps$k(__spreadValues$w({}, request), {
4178
+ targets: secondaryTargets,
4179
+ range: secondaryTimeRange,
4180
+ requestId: getNextRequestId$1()
4181
+ });
4182
+ }
4183
+ request = __spreadProps$k(__spreadValues$w({}, request), {
4184
+ range: primaryTimeRange
4185
+ });
4186
+ }
4187
+ }
4188
+ return [request, secondaryRequest];
4189
+ };
3922
4190
  this.onDataReceived = (data$1) => {
3923
4191
  const preProcessedData = data.preProcessPanelData(data$1, this.state.data);
3924
4192
  this._resultAnnotations = data$1.annotations;
@@ -3937,11 +4205,11 @@ class SceneQueryRunner extends SceneObjectBase {
3937
4205
  }
3938
4206
  _onActivate() {
3939
4207
  const timeRange = sceneGraph.getTimeRange(this);
3940
- const providers = this.getClosestExtraQueryProviders();
3941
- for (const provider of providers) {
4208
+ const comparer = this.getTimeCompare();
4209
+ if (comparer) {
3942
4210
  this._subs.add(
3943
- provider.subscribeToState((n, p) => {
3944
- if (provider.shouldRerun(p, n)) {
4211
+ comparer.subscribeToState((n, p) => {
4212
+ if (n.compareWith !== p.compareWith) {
3945
4213
  this.runQueries();
3946
4214
  }
3947
4215
  })
@@ -4000,9 +4268,9 @@ class SceneQueryRunner extends SceneObjectBase {
4000
4268
  return;
4001
4269
  }
4002
4270
  this._layerAnnotations = annotations;
4003
- const baseStateUpdate = this.state.data ? this.state.data : __spreadProps$l(__spreadValues$x({}, emptyPanelData), { timeRange: timeRange.state.value });
4271
+ const baseStateUpdate = this.state.data ? this.state.data : __spreadProps$k(__spreadValues$w({}, emptyPanelData), { timeRange: timeRange.state.value });
4004
4272
  this.setState({
4005
- data: __spreadProps$l(__spreadValues$x({}, baseStateUpdate), {
4273
+ data: __spreadProps$k(__spreadValues$w({}, baseStateUpdate), {
4006
4274
  annotations: [...(_d = this._resultAnnotations) != null ? _d : [], ...annotations],
4007
4275
  alertState: alertState != null ? alertState : (_e = this.state.data) == null ? void 0 : _e.alertState
4008
4276
  })
@@ -4121,7 +4389,7 @@ class SceneQueryRunner extends SceneObjectBase {
4121
4389
  this._dataLayersSub = void 0;
4122
4390
  }
4123
4391
  this.setState({
4124
- data: __spreadProps$l(__spreadValues$x({}, this.state.data), { state: schema.LoadingState.Done })
4392
+ data: __spreadProps$k(__spreadValues$w({}, this.state.data), { state: schema.LoadingState.Done })
4125
4393
  });
4126
4394
  }
4127
4395
  async runWithTimeRange(timeRange) {
@@ -4135,7 +4403,6 @@ class SceneQueryRunner extends SceneObjectBase {
4135
4403
  (_a = this._querySub) == null ? void 0 : _a.unsubscribe();
4136
4404
  if (this._variableDependency.hasDependencyInLoadingState()) {
4137
4405
  writeSceneLog("SceneQueryRunner", "Variable dependency is in loading state, skipping query execution");
4138
- this.setState({ data: __spreadProps$l(__spreadValues$x({}, this.state.data), { state: schema.LoadingState.Loading }) });
4139
4406
  return;
4140
4407
  }
4141
4408
  const { queries } = this.state;
@@ -4148,18 +4415,16 @@ class SceneQueryRunner extends SceneObjectBase {
4148
4415
  const ds = await getDataSource(datasource, this._scopedVars);
4149
4416
  this.findAndSubscribeToAdHocFilters(datasource == null ? void 0 : datasource.uid);
4150
4417
  const runRequest = runtime.getRunRequest();
4151
- const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);
4418
+ const [request, secondaryRequest] = this.prepareRequests(timeRange, ds);
4152
4419
  writeSceneLog("SceneQueryRunner", "Starting runRequest", this.state.key);
4153
- let stream = runRequest(ds, primary);
4154
- if (secondaries.length > 0) {
4155
- const secondaryStreams = secondaries.map((r) => runRequest(ds, r));
4156
- const op = extraQueryProcessingOperator(processors);
4157
- stream = rxjs.forkJoin([stream, ...secondaryStreams]).pipe(op);
4420
+ let stream = runRequest(ds, request);
4421
+ if (secondaryRequest) {
4422
+ stream = rxjs.forkJoin([stream, runRequest(ds, secondaryRequest)]).pipe(timeShiftQueryResponseOperator);
4158
4423
  }
4159
4424
  stream = stream.pipe(
4160
4425
  registerQueryWithController({
4161
4426
  type: "data",
4162
- request: primary,
4427
+ request,
4163
4428
  origin: this,
4164
4429
  cancel: () => this.cancelQuery()
4165
4430
  })
@@ -4167,7 +4432,7 @@ class SceneQueryRunner extends SceneObjectBase {
4167
4432
  this._querySub = stream.subscribe(this.onDataReceived);
4168
4433
  } catch (err) {
4169
4434
  console.error("PanelQueryRunner Error", err);
4170
- this.onDataReceived(__spreadProps$l(__spreadValues$x(__spreadValues$x({}, emptyPanelData), this.state.data), {
4435
+ this.onDataReceived(__spreadProps$k(__spreadValues$w(__spreadValues$w({}, emptyPanelData), this.state.data), {
4171
4436
  state: schema.LoadingState.Error,
4172
4437
  errors: [runtime.toDataQueryError(err)]
4173
4438
  }));
@@ -4177,73 +4442,16 @@ class SceneQueryRunner extends SceneObjectBase {
4177
4442
  var _a;
4178
4443
  const clone = super.clone(withState);
4179
4444
  if (this._resultAnnotations) {
4180
- clone["_resultAnnotations"] = this._resultAnnotations.map((frame) => __spreadValues$x({}, frame));
4445
+ clone["_resultAnnotations"] = this._resultAnnotations.map((frame) => __spreadValues$w({}, frame));
4181
4446
  }
4182
4447
  if (this._layerAnnotations) {
4183
- clone["_layerAnnotations"] = this._layerAnnotations.map((frame) => __spreadValues$x({}, frame));
4448
+ clone["_layerAnnotations"] = this._layerAnnotations.map((frame) => __spreadValues$w({}, frame));
4184
4449
  }
4185
4450
  clone["_variableValueRecorder"] = this._variableValueRecorder.cloneAndRecordCurrentValuesForSceneObject(this);
4186
4451
  clone["_containerWidth"] = this._containerWidth;
4187
4452
  clone["_results"].next({ origin: this, data: (_a = this.state.data) != null ? _a : emptyPanelData });
4188
4453
  return clone;
4189
4454
  }
4190
- prepareRequests(timeRange, ds) {
4191
- var _a;
4192
- const { minInterval, queries } = this.state;
4193
- let request = __spreadValues$x({
4194
- app: "scenes",
4195
- requestId: getNextRequestId$1(),
4196
- timezone: timeRange.getTimeZone(),
4197
- panelId: 1,
4198
- range: timeRange.state.value,
4199
- interval: "1s",
4200
- intervalMs: 1e3,
4201
- targets: lodash.cloneDeep(queries),
4202
- maxDataPoints: this.getMaxDataPoints(),
4203
- scopedVars: this._scopedVars,
4204
- startTime: Date.now(),
4205
- liveStreaming: this.state.liveStreaming,
4206
- rangeRaw: {
4207
- from: timeRange.state.from,
4208
- to: timeRange.state.to
4209
- },
4210
- cacheTimeout: this.state.cacheTimeout,
4211
- queryCachingTTL: this.state.queryCachingTTL
4212
- }, getEnrichedDataRequest(this));
4213
- if (this._adhocFiltersVar) {
4214
- request.filters = this._adhocFiltersVar.state.filters.filter(isFilterComplete);
4215
- }
4216
- if (this._groupByVar) {
4217
- request.groupByKeys = this._groupByVar.state.value;
4218
- }
4219
- request.targets = request.targets.map((query) => {
4220
- var _a2;
4221
- if (!query.datasource || query.datasource.uid !== ds.uid && !((_a2 = ds.meta) == null ? void 0 : _a2.mixed) && runtime.isExpressionReference && !runtime.isExpressionReference(query.datasource)) {
4222
- query.datasource = ds.getRef();
4223
- }
4224
- return query;
4225
- });
4226
- const lowerIntervalLimit = minInterval ? minInterval : ds.interval;
4227
- const norm = data.rangeUtil.calculateInterval(timeRange.state.value, request.maxDataPoints, lowerIntervalLimit);
4228
- request.scopedVars = Object.assign({}, request.scopedVars, {
4229
- __interval: { text: norm.interval, value: norm.interval },
4230
- __interval_ms: { text: norm.intervalMs.toString(), value: norm.intervalMs }
4231
- });
4232
- request.interval = norm.interval;
4233
- request.intervalMs = norm.intervalMs;
4234
- const primaryTimeRange = timeRange.state.value;
4235
- let secondaryRequests = [];
4236
- let secondaryProcessors = /* @__PURE__ */ new Map();
4237
- for (const provider of (_a = this.getClosestExtraQueryProviders()) != null ? _a : []) {
4238
- for (const { req, processor } of provider.getExtraQueries(request)) {
4239
- const requestId = getNextRequestId$1();
4240
- secondaryRequests.push(__spreadProps$l(__spreadValues$x({}, req), { requestId }));
4241
- secondaryProcessors.set(requestId, processor != null ? processor : passthroughProcessor);
4242
- }
4243
- }
4244
- request.range = primaryTimeRange;
4245
- return { primary: request, secondaries: secondaryRequests, processors: secondaryProcessors };
4246
- }
4247
4455
  _combineDataLayers(data) {
4248
4456
  if (this._layerAnnotations && this._layerAnnotations.length > 0) {
4249
4457
  data.annotations = (data.annotations || []).concat(this._layerAnnotations);
@@ -4258,23 +4466,22 @@ class SceneQueryRunner extends SceneObjectBase {
4258
4466
  this.setState({ data: emptyPanelData });
4259
4467
  }
4260
4468
  }
4261
- getClosestExtraQueryProviders() {
4262
- const found = /* @__PURE__ */ new Map();
4469
+ getTimeCompare() {
4263
4470
  if (!this.parent) {
4264
- return [];
4471
+ return null;
4265
4472
  }
4266
- getClosest(this.parent, (s) => {
4267
- if (isExtraQueryProvider(s) && !found.has(s.constructor)) {
4268
- found.set(s.constructor, s);
4473
+ return getClosest(this.parent, (s) => {
4474
+ let found = null;
4475
+ if (s instanceof SceneTimeRangeCompare) {
4476
+ return s;
4269
4477
  }
4270
4478
  s.forEachChild((child) => {
4271
- if (isExtraQueryProvider(child) && !found.has(child.constructor)) {
4272
- found.set(child.constructor, child);
4479
+ if (child instanceof SceneTimeRangeCompare) {
4480
+ found = child;
4273
4481
  }
4274
4482
  });
4275
- return null;
4483
+ return found;
4276
4484
  });
4277
- return Array.from(found.values());
4278
4485
  }
4279
4486
  findAndSubscribeToAdHocFilters(uid) {
4280
4487
  const filtersVar = findActiveAdHocFilterVariableByUid(uid);
@@ -4473,28 +4680,28 @@ class ActWhenVariableChanged extends SceneObjectBase {
4473
4680
  }
4474
4681
  }
4475
4682
 
4476
- var __defProp$w = Object.defineProperty;
4477
- var __defProps$k = Object.defineProperties;
4478
- var __getOwnPropDescs$k = Object.getOwnPropertyDescriptors;
4479
- var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
4480
- var __hasOwnProp$w = Object.prototype.hasOwnProperty;
4481
- var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
4482
- var __defNormalProp$w = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4483
- var __spreadValues$w = (a, b) => {
4683
+ var __defProp$v = Object.defineProperty;
4684
+ var __defProps$j = Object.defineProperties;
4685
+ var __getOwnPropDescs$j = Object.getOwnPropertyDescriptors;
4686
+ var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
4687
+ var __hasOwnProp$v = Object.prototype.hasOwnProperty;
4688
+ var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
4689
+ var __defNormalProp$v = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4690
+ var __spreadValues$v = (a, b) => {
4484
4691
  for (var prop in b || (b = {}))
4485
- if (__hasOwnProp$w.call(b, prop))
4486
- __defNormalProp$w(a, prop, b[prop]);
4487
- if (__getOwnPropSymbols$w)
4488
- for (var prop of __getOwnPropSymbols$w(b)) {
4489
- if (__propIsEnum$w.call(b, prop))
4490
- __defNormalProp$w(a, prop, b[prop]);
4692
+ if (__hasOwnProp$v.call(b, prop))
4693
+ __defNormalProp$v(a, prop, b[prop]);
4694
+ if (__getOwnPropSymbols$v)
4695
+ for (var prop of __getOwnPropSymbols$v(b)) {
4696
+ if (__propIsEnum$v.call(b, prop))
4697
+ __defNormalProp$v(a, prop, b[prop]);
4491
4698
  }
4492
4699
  return a;
4493
4700
  };
4494
- var __spreadProps$k = (a, b) => __defProps$k(a, __getOwnPropDescs$k(b));
4701
+ var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
4495
4702
  class CursorSync extends SceneObjectBase {
4496
4703
  constructor(state) {
4497
- super(__spreadProps$k(__spreadValues$w({}, state), {
4704
+ super(__spreadProps$j(__spreadValues$v({}, state), {
4498
4705
  sync: state.sync || schema.DashboardCursorSync.Off
4499
4706
  }));
4500
4707
  this.getEventsBus = (panel) => {
@@ -4758,25 +4965,25 @@ const getAlertStateStyles = (theme) => {
4758
4965
  };
4759
4966
  };
4760
4967
 
4761
- var __defProp$v = Object.defineProperty;
4762
- var __defProps$j = Object.defineProperties;
4763
- var __getOwnPropDescs$j = Object.getOwnPropertyDescriptors;
4764
- var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
4765
- var __hasOwnProp$v = Object.prototype.hasOwnProperty;
4766
- var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
4767
- var __defNormalProp$v = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4768
- var __spreadValues$v = (a, b) => {
4968
+ var __defProp$u = Object.defineProperty;
4969
+ var __defProps$i = Object.defineProperties;
4970
+ var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
4971
+ var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
4972
+ var __hasOwnProp$u = Object.prototype.hasOwnProperty;
4973
+ var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
4974
+ var __defNormalProp$u = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4975
+ var __spreadValues$u = (a, b) => {
4769
4976
  for (var prop in b || (b = {}))
4770
- if (__hasOwnProp$v.call(b, prop))
4771
- __defNormalProp$v(a, prop, b[prop]);
4772
- if (__getOwnPropSymbols$v)
4773
- for (var prop of __getOwnPropSymbols$v(b)) {
4774
- if (__propIsEnum$v.call(b, prop))
4775
- __defNormalProp$v(a, prop, b[prop]);
4977
+ if (__hasOwnProp$u.call(b, prop))
4978
+ __defNormalProp$u(a, prop, b[prop]);
4979
+ if (__getOwnPropSymbols$u)
4980
+ for (var prop of __getOwnPropSymbols$u(b)) {
4981
+ if (__propIsEnum$u.call(b, prop))
4982
+ __defNormalProp$u(a, prop, b[prop]);
4776
4983
  }
4777
4984
  return a;
4778
4985
  };
4779
- var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
4986
+ var __spreadProps$i = (a, b) => __defProps$i(a, __getOwnPropDescs$i(b));
4780
4987
  const displayOverrideRef = "hideSeriesFrom";
4781
4988
  const isHideSeriesOverride = data.isSystemOverrideWithRef(displayOverrideRef);
4782
4989
  function seriesVisibilityConfigFactory(label, mode, fieldConfig, data) {
@@ -4786,13 +4993,13 @@ function seriesVisibilityConfigFactory(label, mode, fieldConfig, data) {
4786
4993
  if (currentIndex < 0) {
4787
4994
  if (mode === ui.SeriesVisibilityChangeMode.ToggleSelection) {
4788
4995
  const override3 = createOverride$1([displayName, ...getNamesOfHiddenFields(overrides, data)]);
4789
- return __spreadProps$j(__spreadValues$v({}, fieldConfig), {
4996
+ return __spreadProps$i(__spreadValues$u({}, fieldConfig), {
4790
4997
  overrides: [...fieldConfig.overrides, override3]
4791
4998
  });
4792
4999
  }
4793
5000
  const displayNames = getDisplayNames(data, displayName);
4794
5001
  const override2 = createOverride$1(displayNames);
4795
- return __spreadProps$j(__spreadValues$v({}, fieldConfig), {
5002
+ return __spreadProps$i(__spreadValues$u({}, fieldConfig), {
4796
5003
  overrides: [...fieldConfig.overrides, override2]
4797
5004
  });
4798
5005
  }
@@ -4805,22 +5012,22 @@ function seriesVisibilityConfigFactory(label, mode, fieldConfig, data) {
4805
5012
  existing = existing.filter((el) => nameOfHiddenFields.indexOf(el) < 0);
4806
5013
  }
4807
5014
  if (existing[0] === displayName && existing.length === 1) {
4808
- return __spreadProps$j(__spreadValues$v({}, fieldConfig), {
5015
+ return __spreadProps$i(__spreadValues$u({}, fieldConfig), {
4809
5016
  overrides: overridesCopy
4810
5017
  });
4811
5018
  }
4812
5019
  const override2 = createOverride$1([displayName, ...nameOfHiddenFields]);
4813
- return __spreadProps$j(__spreadValues$v({}, fieldConfig), {
5020
+ return __spreadProps$i(__spreadValues$u({}, fieldConfig), {
4814
5021
  overrides: [...overridesCopy, override2]
4815
5022
  });
4816
5023
  }
4817
5024
  const override = createExtendedOverride(current, displayName);
4818
5025
  if (allFieldsAreExcluded(override, data)) {
4819
- return __spreadProps$j(__spreadValues$v({}, fieldConfig), {
5026
+ return __spreadProps$i(__spreadValues$u({}, fieldConfig), {
4820
5027
  overrides: overridesCopy
4821
5028
  });
4822
5029
  }
4823
- return __spreadProps$j(__spreadValues$v({}, fieldConfig), {
5030
+ return __spreadProps$i(__spreadValues$u({}, fieldConfig), {
4824
5031
  overrides: [...overridesCopy, override]
4825
5032
  });
4826
5033
  }
@@ -4845,7 +5052,7 @@ function createOverride$1(names, mode = data.ByNamesMatcherMode.exclude, propert
4845
5052
  }
4846
5053
  },
4847
5054
  properties: [
4848
- __spreadProps$j(__spreadValues$v({}, property), {
5055
+ __spreadProps$i(__spreadValues$u({}, property), {
4849
5056
  value: {
4850
5057
  viz: true,
4851
5058
  legend: false,
@@ -4917,32 +5124,32 @@ const getNamesOfHiddenFields = (overrides, data$1) => {
4917
5124
  return names;
4918
5125
  };
4919
5126
 
4920
- var __defProp$u = Object.defineProperty;
4921
- var __defProps$i = Object.defineProperties;
4922
- var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
4923
- var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
4924
- var __hasOwnProp$u = Object.prototype.hasOwnProperty;
4925
- var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
4926
- var __defNormalProp$u = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4927
- var __spreadValues$u = (a, b) => {
5127
+ var __defProp$t = Object.defineProperty;
5128
+ var __defProps$h = Object.defineProperties;
5129
+ var __getOwnPropDescs$h = Object.getOwnPropertyDescriptors;
5130
+ var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
5131
+ var __hasOwnProp$t = Object.prototype.hasOwnProperty;
5132
+ var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
5133
+ var __defNormalProp$t = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5134
+ var __spreadValues$t = (a, b) => {
4928
5135
  for (var prop in b || (b = {}))
4929
- if (__hasOwnProp$u.call(b, prop))
4930
- __defNormalProp$u(a, prop, b[prop]);
4931
- if (__getOwnPropSymbols$u)
4932
- for (var prop of __getOwnPropSymbols$u(b)) {
4933
- if (__propIsEnum$u.call(b, prop))
4934
- __defNormalProp$u(a, prop, b[prop]);
5136
+ if (__hasOwnProp$t.call(b, prop))
5137
+ __defNormalProp$t(a, prop, b[prop]);
5138
+ if (__getOwnPropSymbols$t)
5139
+ for (var prop of __getOwnPropSymbols$t(b)) {
5140
+ if (__propIsEnum$t.call(b, prop))
5141
+ __defNormalProp$t(a, prop, b[prop]);
4935
5142
  }
4936
5143
  return a;
4937
5144
  };
4938
- var __spreadProps$i = (a, b) => __defProps$i(a, __getOwnPropDescs$i(b));
5145
+ var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
4939
5146
  const changeSeriesColorConfigFactory = (label, color, fieldConfig) => {
4940
5147
  const { overrides } = fieldConfig;
4941
5148
  const currentIndex = fieldConfig.overrides.findIndex((override) => {
4942
5149
  return override.matcher.id === data.FieldMatcherID.byName && override.matcher.options === label;
4943
5150
  });
4944
5151
  if (currentIndex < 0) {
4945
- return __spreadProps$i(__spreadValues$u({}, fieldConfig), {
5152
+ return __spreadProps$h(__spreadValues$t({}, fieldConfig), {
4946
5153
  overrides: [...fieldConfig.overrides, createOverride(label, color)]
4947
5154
  });
4948
5155
  }
@@ -4950,19 +5157,19 @@ const changeSeriesColorConfigFactory = (label, color, fieldConfig) => {
4950
5157
  const existing = overridesCopy[currentIndex];
4951
5158
  const propertyIndex = existing.properties.findIndex((p) => p.id === "color");
4952
5159
  if (propertyIndex < 0) {
4953
- overridesCopy[currentIndex] = __spreadProps$i(__spreadValues$u({}, existing), {
5160
+ overridesCopy[currentIndex] = __spreadProps$h(__spreadValues$t({}, existing), {
4954
5161
  properties: [...existing.properties, createProperty(color)]
4955
5162
  });
4956
- return __spreadProps$i(__spreadValues$u({}, fieldConfig), {
5163
+ return __spreadProps$h(__spreadValues$t({}, fieldConfig), {
4957
5164
  overrides: overridesCopy
4958
5165
  });
4959
5166
  }
4960
5167
  const propertiesCopy = Array.from(existing.properties);
4961
5168
  propertiesCopy[propertyIndex] = createProperty(color);
4962
- overridesCopy[currentIndex] = __spreadProps$i(__spreadValues$u({}, existing), {
5169
+ overridesCopy[currentIndex] = __spreadProps$h(__spreadValues$t({}, existing), {
4963
5170
  properties: propertiesCopy
4964
5171
  });
4965
- return __spreadProps$i(__spreadValues$u({}, fieldConfig), {
5172
+ return __spreadProps$h(__spreadValues$t({}, fieldConfig), {
4966
5173
  overrides: overridesCopy
4967
5174
  });
4968
5175
  };
@@ -4985,29 +5192,29 @@ const createProperty = (color) => {
4985
5192
  };
4986
5193
  };
4987
5194
 
4988
- var __defProp$t = Object.defineProperty;
4989
- var __defProps$h = Object.defineProperties;
4990
- var __getOwnPropDescs$h = Object.getOwnPropertyDescriptors;
4991
- var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
4992
- var __hasOwnProp$t = Object.prototype.hasOwnProperty;
4993
- var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
4994
- var __defNormalProp$t = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4995
- var __spreadValues$t = (a, b) => {
5195
+ var __defProp$s = Object.defineProperty;
5196
+ var __defProps$g = Object.defineProperties;
5197
+ var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
5198
+ var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
5199
+ var __hasOwnProp$s = Object.prototype.hasOwnProperty;
5200
+ var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
5201
+ var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5202
+ var __spreadValues$s = (a, b) => {
4996
5203
  for (var prop in b || (b = {}))
4997
- if (__hasOwnProp$t.call(b, prop))
4998
- __defNormalProp$t(a, prop, b[prop]);
4999
- if (__getOwnPropSymbols$t)
5000
- for (var prop of __getOwnPropSymbols$t(b)) {
5001
- if (__propIsEnum$t.call(b, prop))
5002
- __defNormalProp$t(a, prop, b[prop]);
5204
+ if (__hasOwnProp$s.call(b, prop))
5205
+ __defNormalProp$s(a, prop, b[prop]);
5206
+ if (__getOwnPropSymbols$s)
5207
+ for (var prop of __getOwnPropSymbols$s(b)) {
5208
+ if (__propIsEnum$s.call(b, prop))
5209
+ __defNormalProp$s(a, prop, b[prop]);
5003
5210
  }
5004
5211
  return a;
5005
5212
  };
5006
- var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
5213
+ var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
5007
5214
  class VizPanel extends SceneObjectBase {
5008
5215
  constructor(state) {
5009
5216
  var _a;
5010
- super(__spreadValues$t({
5217
+ super(__spreadValues$s({
5011
5218
  options: {},
5012
5219
  fieldConfig: { defaults: {}, overrides: [] },
5013
5220
  title: "Title",
@@ -5120,7 +5327,7 @@ class VizPanel extends SceneObjectBase {
5120
5327
  };
5121
5328
  this._onInstanceStateChange = (state) => {
5122
5329
  if (this._panelContext) {
5123
- this._panelContext = __spreadProps$h(__spreadValues$t({}, this._panelContext), {
5330
+ this._panelContext = __spreadProps$g(__spreadValues$s({}, this._panelContext), {
5124
5331
  instanceState: state
5125
5332
  });
5126
5333
  }
@@ -5144,8 +5351,8 @@ class VizPanel extends SceneObjectBase {
5144
5351
  sortBy = sortKey;
5145
5352
  }
5146
5353
  this.onOptionsChange(
5147
- __spreadProps$h(__spreadValues$t({}, this.state.options), {
5148
- legend: __spreadProps$h(__spreadValues$t({}, legendOptions), { sortBy, sortDesc })
5354
+ __spreadProps$g(__spreadValues$s({}, this.state.options), {
5355
+ legend: __spreadProps$g(__spreadValues$s({}, legendOptions), { sortBy, sortDesc })
5149
5356
  }),
5150
5357
  true
5151
5358
  );
@@ -5229,9 +5436,6 @@ class VizPanel extends SceneObjectBase {
5229
5436
  (_a = this._panelContext) != null ? _a : this._panelContext = this.buildPanelContext();
5230
5437
  return this._panelContext;
5231
5438
  }
5232
- clearFieldConfigCache() {
5233
- this._dataWithFieldConfig = void 0;
5234
- }
5235
5439
  applyFieldConfig(rawData) {
5236
5440
  var _a, _b, _c, _d;
5237
5441
  const plugin = this._plugin;
@@ -5255,7 +5459,7 @@ class VizPanel extends SceneObjectBase {
5255
5459
  if (!data.compareArrayValues(newFrames, prevFrames, data.compareDataFrameStructures)) {
5256
5460
  this._structureRev++;
5257
5461
  }
5258
- this._dataWithFieldConfig = __spreadProps$h(__spreadValues$t({}, rawData), {
5462
+ this._dataWithFieldConfig = __spreadProps$g(__spreadValues$s({}, rawData), {
5259
5463
  structureRev: this._structureRev,
5260
5464
  series: newFrames
5261
5465
  });
@@ -5398,25 +5602,25 @@ function getMessageFromError(err) {
5398
5602
  return JSON.stringify(err);
5399
5603
  }
5400
5604
 
5401
- var __defProp$s = Object.defineProperty;
5402
- var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
5403
- var __hasOwnProp$s = Object.prototype.hasOwnProperty;
5404
- var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
5405
- var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5406
- var __spreadValues$s = (a, b) => {
5605
+ var __defProp$r = Object.defineProperty;
5606
+ var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
5607
+ var __hasOwnProp$r = Object.prototype.hasOwnProperty;
5608
+ var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
5609
+ var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5610
+ var __spreadValues$r = (a, b) => {
5407
5611
  for (var prop in b || (b = {}))
5408
- if (__hasOwnProp$s.call(b, prop))
5409
- __defNormalProp$s(a, prop, b[prop]);
5410
- if (__getOwnPropSymbols$s)
5411
- for (var prop of __getOwnPropSymbols$s(b)) {
5412
- if (__propIsEnum$s.call(b, prop))
5413
- __defNormalProp$s(a, prop, b[prop]);
5612
+ if (__hasOwnProp$r.call(b, prop))
5613
+ __defNormalProp$r(a, prop, b[prop]);
5614
+ if (__getOwnPropSymbols$r)
5615
+ for (var prop of __getOwnPropSymbols$r(b)) {
5616
+ if (__propIsEnum$r.call(b, prop))
5617
+ __defNormalProp$r(a, prop, b[prop]);
5414
5618
  }
5415
5619
  return a;
5416
5620
  };
5417
5621
  class SceneDataLayerBase extends SceneObjectBase {
5418
5622
  constructor(initialState, variableDependencyStatePaths = []) {
5419
- super(__spreadValues$s({
5623
+ super(__spreadValues$r({
5420
5624
  isEnabled: true
5421
5625
  }, initialState));
5422
5626
  this._results = new rxjs.ReplaySubject(1);
@@ -5538,33 +5742,33 @@ function DataLayerControlSwitch({ layer }) {
5538
5742
  }
5539
5743
  const containerStyle$1 = css.css({ display: "flex" });
5540
5744
 
5541
- var __defProp$r = Object.defineProperty;
5542
- var __defProps$g = Object.defineProperties;
5543
- var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
5544
- var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
5545
- var __hasOwnProp$r = Object.prototype.hasOwnProperty;
5546
- var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
5547
- var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5548
- var __spreadValues$r = (a, b) => {
5745
+ var __defProp$q = Object.defineProperty;
5746
+ var __defProps$f = Object.defineProperties;
5747
+ var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
5748
+ var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
5749
+ var __hasOwnProp$q = Object.prototype.hasOwnProperty;
5750
+ var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
5751
+ var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5752
+ var __spreadValues$q = (a, b) => {
5549
5753
  for (var prop in b || (b = {}))
5550
- if (__hasOwnProp$r.call(b, prop))
5551
- __defNormalProp$r(a, prop, b[prop]);
5552
- if (__getOwnPropSymbols$r)
5553
- for (var prop of __getOwnPropSymbols$r(b)) {
5554
- if (__propIsEnum$r.call(b, prop))
5555
- __defNormalProp$r(a, prop, b[prop]);
5754
+ if (__hasOwnProp$q.call(b, prop))
5755
+ __defNormalProp$q(a, prop, b[prop]);
5756
+ if (__getOwnPropSymbols$q)
5757
+ for (var prop of __getOwnPropSymbols$q(b)) {
5758
+ if (__propIsEnum$q.call(b, prop))
5759
+ __defNormalProp$q(a, prop, b[prop]);
5556
5760
  }
5557
5761
  return a;
5558
5762
  };
5559
- var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
5763
+ var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
5560
5764
  var __objRest$2 = (source, exclude) => {
5561
5765
  var target = {};
5562
5766
  for (var prop in source)
5563
- if (__hasOwnProp$r.call(source, prop) && exclude.indexOf(prop) < 0)
5767
+ if (__hasOwnProp$q.call(source, prop) && exclude.indexOf(prop) < 0)
5564
5768
  target[prop] = source[prop];
5565
- if (source != null && __getOwnPropSymbols$r)
5566
- for (var prop of __getOwnPropSymbols$r(source)) {
5567
- if (exclude.indexOf(prop) < 0 && __propIsEnum$r.call(source, prop))
5769
+ if (source != null && __getOwnPropSymbols$q)
5770
+ for (var prop of __getOwnPropSymbols$q(source)) {
5771
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$q.call(source, prop))
5568
5772
  target[prop] = source[prop];
5569
5773
  }
5570
5774
  return target;
@@ -5573,7 +5777,7 @@ const standardAnnotationSupport = {
5573
5777
  prepareAnnotation: (json) => {
5574
5778
  if (lodash.isString(json == null ? void 0 : json.query)) {
5575
5779
  const _a = json, { query } = _a, rest = __objRest$2(_a, ["query"]);
5576
- return __spreadProps$g(__spreadValues$r({}, rest), {
5780
+ return __spreadProps$f(__spreadValues$q({}, rest), {
5577
5781
  target: {
5578
5782
  refId: "annotation_query",
5579
5783
  query
@@ -5741,25 +5945,25 @@ function shouldUseLegacyRunner(datasource) {
5741
5945
  return !datasource.annotations || legacyRunner.includes(type);
5742
5946
  }
5743
5947
 
5744
- var __defProp$q = Object.defineProperty;
5745
- var __defProps$f = Object.defineProperties;
5746
- var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
5747
- var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
5748
- var __hasOwnProp$q = Object.prototype.hasOwnProperty;
5749
- var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
5750
- var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5751
- var __spreadValues$q = (a, b) => {
5948
+ var __defProp$p = Object.defineProperty;
5949
+ var __defProps$e = Object.defineProperties;
5950
+ var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
5951
+ var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
5952
+ var __hasOwnProp$p = Object.prototype.hasOwnProperty;
5953
+ var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
5954
+ var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5955
+ var __spreadValues$p = (a, b) => {
5752
5956
  for (var prop in b || (b = {}))
5753
- if (__hasOwnProp$q.call(b, prop))
5754
- __defNormalProp$q(a, prop, b[prop]);
5755
- if (__getOwnPropSymbols$q)
5756
- for (var prop of __getOwnPropSymbols$q(b)) {
5757
- if (__propIsEnum$q.call(b, prop))
5758
- __defNormalProp$q(a, prop, b[prop]);
5957
+ if (__hasOwnProp$p.call(b, prop))
5958
+ __defNormalProp$p(a, prop, b[prop]);
5959
+ if (__getOwnPropSymbols$p)
5960
+ for (var prop of __getOwnPropSymbols$p(b)) {
5961
+ if (__propIsEnum$p.call(b, prop))
5962
+ __defNormalProp$p(a, prop, b[prop]);
5759
5963
  }
5760
5964
  return a;
5761
5965
  };
5762
- var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
5966
+ var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
5763
5967
  let counter = 100;
5764
5968
  function getNextRequestId() {
5765
5969
  return "AQ" + counter++;
@@ -5782,8 +5986,8 @@ function executeAnnotationQuery(datasource, timeRange, query, layer) {
5782
5986
  }))
5783
5987
  );
5784
5988
  }
5785
- const processor = __spreadValues$q(__spreadValues$q({}, standardAnnotationSupport), datasource.annotations);
5786
- const annotationWithDefaults = __spreadValues$q(__spreadValues$q({}, (_a = processor.getDefaultQuery) == null ? void 0 : _a.call(processor)), query);
5989
+ const processor = __spreadValues$p(__spreadValues$p({}, standardAnnotationSupport), datasource.annotations);
5990
+ const annotationWithDefaults = __spreadValues$p(__spreadValues$p({}, (_a = processor.getDefaultQuery) == null ? void 0 : _a.call(processor)), query);
5787
5991
  const annotation = processor.prepareAnnotation(annotationWithDefaults);
5788
5992
  if (!annotation) {
5789
5993
  return rxjs.of({
@@ -5806,7 +6010,7 @@ function executeAnnotationQuery(datasource, timeRange, query, layer) {
5806
6010
  __annotation: { text: annotation.name, value: annotation },
5807
6011
  __sceneObject: { text: "__sceneObject", value: layer }
5808
6012
  };
5809
- const queryRequest = __spreadValues$q(__spreadProps$f(__spreadValues$q({
6013
+ const queryRequest = __spreadValues$p(__spreadProps$e(__spreadValues$p({
5810
6014
  startTime: Date.now(),
5811
6015
  requestId: getNextRequestId(),
5812
6016
  range: timeRange.state.value,
@@ -5816,7 +6020,7 @@ function executeAnnotationQuery(datasource, timeRange, query, layer) {
5816
6020
  app: data.CoreApp.Dashboard,
5817
6021
  timezone: timeRange.getTimeZone(),
5818
6022
  targets: [
5819
- __spreadProps$f(__spreadValues$q({}, processedQuery), {
6023
+ __spreadProps$e(__spreadValues$p({}, processedQuery), {
5820
6024
  refId: "Anno"
5821
6025
  })
5822
6026
  ]
@@ -5834,7 +6038,7 @@ function executeAnnotationQuery(datasource, timeRange, query, layer) {
5834
6038
  data$1.forEach((frame) => {
5835
6039
  var _a2;
5836
6040
  if (!((_a2 = frame.meta) == null ? void 0 : _a2.dataTopic)) {
5837
- frame.meta = __spreadProps$f(__spreadValues$q({}, frame.meta || {}), { dataTopic: data.DataTopic.Annotations });
6041
+ frame.meta = __spreadProps$e(__spreadValues$p({}, frame.meta || {}), { dataTopic: data.DataTopic.Annotations });
5838
6042
  }
5839
6043
  });
5840
6044
  return processor.processEvents(annotation, data$1).pipe(
@@ -5849,19 +6053,19 @@ function executeAnnotationQuery(datasource, timeRange, query, layer) {
5849
6053
  );
5850
6054
  }
5851
6055
 
5852
- var __defProp$p = Object.defineProperty;
5853
- var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
5854
- var __hasOwnProp$p = Object.prototype.hasOwnProperty;
5855
- var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
5856
- var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5857
- var __spreadValues$p = (a, b) => {
6056
+ var __defProp$o = Object.defineProperty;
6057
+ var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
6058
+ var __hasOwnProp$o = Object.prototype.hasOwnProperty;
6059
+ var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
6060
+ var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6061
+ var __spreadValues$o = (a, b) => {
5858
6062
  for (var prop in b || (b = {}))
5859
- if (__hasOwnProp$p.call(b, prop))
5860
- __defNormalProp$p(a, prop, b[prop]);
5861
- if (__getOwnPropSymbols$p)
5862
- for (var prop of __getOwnPropSymbols$p(b)) {
5863
- if (__propIsEnum$p.call(b, prop))
5864
- __defNormalProp$p(a, prop, b[prop]);
6063
+ if (__hasOwnProp$o.call(b, prop))
6064
+ __defNormalProp$o(a, prop, b[prop]);
6065
+ if (__getOwnPropSymbols$o)
6066
+ for (var prop of __getOwnPropSymbols$o(b)) {
6067
+ if (__propIsEnum$o.call(b, prop))
6068
+ __defNormalProp$o(a, prop, b[prop]);
5865
6069
  }
5866
6070
  return a;
5867
6071
  };
@@ -5872,7 +6076,7 @@ function postProcessQueryResult(annotation, results) {
5872
6076
  }
5873
6077
  const processed = results.map((item) => {
5874
6078
  var _a;
5875
- const processedItem = __spreadValues$p({}, item);
6079
+ const processedItem = __spreadValues$o({}, item);
5876
6080
  processedItem.source = annotation;
5877
6081
  processedItem.color = runtime.config.theme2.visualization.getColorByName(annotation.iconColor);
5878
6082
  processedItem.type = annotation.name;
@@ -5921,29 +6125,29 @@ function isPanelAlert(event) {
5921
6125
  return event.eventType === "panel-alert";
5922
6126
  }
5923
6127
 
5924
- var __defProp$o = Object.defineProperty;
5925
- var __defProps$e = Object.defineProperties;
5926
- var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
5927
- var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
5928
- var __hasOwnProp$o = Object.prototype.hasOwnProperty;
5929
- var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
5930
- var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5931
- var __spreadValues$o = (a, b) => {
6128
+ var __defProp$n = Object.defineProperty;
6129
+ var __defProps$d = Object.defineProperties;
6130
+ var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
6131
+ var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
6132
+ var __hasOwnProp$n = Object.prototype.hasOwnProperty;
6133
+ var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
6134
+ var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6135
+ var __spreadValues$n = (a, b) => {
5932
6136
  for (var prop in b || (b = {}))
5933
- if (__hasOwnProp$o.call(b, prop))
5934
- __defNormalProp$o(a, prop, b[prop]);
5935
- if (__getOwnPropSymbols$o)
5936
- for (var prop of __getOwnPropSymbols$o(b)) {
5937
- if (__propIsEnum$o.call(b, prop))
5938
- __defNormalProp$o(a, prop, b[prop]);
6137
+ if (__hasOwnProp$n.call(b, prop))
6138
+ __defNormalProp$n(a, prop, b[prop]);
6139
+ if (__getOwnPropSymbols$n)
6140
+ for (var prop of __getOwnPropSymbols$n(b)) {
6141
+ if (__propIsEnum$n.call(b, prop))
6142
+ __defNormalProp$n(a, prop, b[prop]);
5939
6143
  }
5940
6144
  return a;
5941
6145
  };
5942
- var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
6146
+ var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
5943
6147
  class AnnotationsDataLayer extends SceneDataLayerBase {
5944
6148
  constructor(initialState) {
5945
6149
  super(
5946
- __spreadValues$o({
6150
+ __spreadValues$n({
5947
6151
  isEnabled: true
5948
6152
  }, initialState),
5949
6153
  ["query"]
@@ -5991,7 +6195,7 @@ class AnnotationsDataLayer extends SceneDataLayerBase {
5991
6195
  this.publishResults(stateUpdate);
5992
6196
  });
5993
6197
  } catch (e) {
5994
- this.publishResults(__spreadProps$e(__spreadValues$o({}, emptyPanelData), {
6198
+ this.publishResults(__spreadProps$d(__spreadValues$n({}, emptyPanelData), {
5995
6199
  state: schema.LoadingState.Error,
5996
6200
  errors: [
5997
6201
  {
@@ -6008,9 +6212,9 @@ class AnnotationsDataLayer extends SceneDataLayerBase {
6008
6212
  processEvents(query, events) {
6009
6213
  let processedEvents = postProcessQueryResult(query, events.events || []);
6010
6214
  processedEvents = dedupAnnotations(processedEvents);
6011
- const stateUpdate = __spreadProps$e(__spreadValues$o({}, emptyPanelData), { state: events.state });
6215
+ const stateUpdate = __spreadProps$d(__spreadValues$n({}, emptyPanelData), { state: events.state });
6012
6216
  const df = data.arrayToDataFrame(processedEvents);
6013
- df.meta = __spreadProps$e(__spreadValues$o({}, df.meta), {
6217
+ df.meta = __spreadProps$d(__spreadValues$n({}, df.meta), {
6014
6218
  dataTopic: data.DataTopic.Annotations
6015
6219
  });
6016
6220
  stateUpdate.series = [df];
@@ -6063,28 +6267,28 @@ class SceneTimeRangeTransformerBase extends SceneObjectBase {
6063
6267
  }
6064
6268
  }
6065
6269
 
6066
- var __defProp$n = Object.defineProperty;
6067
- var __defProps$d = Object.defineProperties;
6068
- var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
6069
- var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
6070
- var __hasOwnProp$n = Object.prototype.hasOwnProperty;
6071
- var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
6072
- var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6073
- var __spreadValues$n = (a, b) => {
6270
+ var __defProp$m = Object.defineProperty;
6271
+ var __defProps$c = Object.defineProperties;
6272
+ var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
6273
+ var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
6274
+ var __hasOwnProp$m = Object.prototype.hasOwnProperty;
6275
+ var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
6276
+ var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6277
+ var __spreadValues$m = (a, b) => {
6074
6278
  for (var prop in b || (b = {}))
6075
- if (__hasOwnProp$n.call(b, prop))
6076
- __defNormalProp$n(a, prop, b[prop]);
6077
- if (__getOwnPropSymbols$n)
6078
- for (var prop of __getOwnPropSymbols$n(b)) {
6079
- if (__propIsEnum$n.call(b, prop))
6080
- __defNormalProp$n(a, prop, b[prop]);
6279
+ if (__hasOwnProp$m.call(b, prop))
6280
+ __defNormalProp$m(a, prop, b[prop]);
6281
+ if (__getOwnPropSymbols$m)
6282
+ for (var prop of __getOwnPropSymbols$m(b)) {
6283
+ if (__propIsEnum$m.call(b, prop))
6284
+ __defNormalProp$m(a, prop, b[prop]);
6081
6285
  }
6082
6286
  return a;
6083
6287
  };
6084
- var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
6288
+ var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
6085
6289
  class SceneTimeZoneOverride extends SceneTimeRangeTransformerBase {
6086
6290
  constructor(state) {
6087
- super(__spreadProps$d(__spreadValues$n({}, state), {
6291
+ super(__spreadProps$c(__spreadValues$m({}, state), {
6088
6292
  timeZone: state.timeZone,
6089
6293
  from: "now-6h",
6090
6294
  to: "now",
@@ -6092,7 +6296,7 @@ class SceneTimeZoneOverride extends SceneTimeRangeTransformerBase {
6092
6296
  }));
6093
6297
  }
6094
6298
  ancestorTimeRangeChanged(timeRange) {
6095
- this.setState(__spreadProps$d(__spreadValues$n({}, timeRange), {
6299
+ this.setState(__spreadProps$c(__spreadValues$m({}, timeRange), {
6096
6300
  timeZone: this.state.timeZone,
6097
6301
  value: evaluateTimeRange(
6098
6302
  timeRange.from,
@@ -6120,25 +6324,25 @@ class SceneTimeZoneOverride extends SceneTimeRangeTransformerBase {
6120
6324
  }
6121
6325
  }
6122
6326
 
6123
- var __defProp$m = Object.defineProperty;
6124
- var __defProps$c = Object.defineProperties;
6125
- var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
6126
- var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
6127
- var __hasOwnProp$m = Object.prototype.hasOwnProperty;
6128
- var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
6129
- var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6130
- var __spreadValues$m = (a, b) => {
6327
+ var __defProp$l = Object.defineProperty;
6328
+ var __defProps$b = Object.defineProperties;
6329
+ var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
6330
+ var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
6331
+ var __hasOwnProp$l = Object.prototype.hasOwnProperty;
6332
+ var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
6333
+ var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6334
+ var __spreadValues$l = (a, b) => {
6131
6335
  for (var prop in b || (b = {}))
6132
- if (__hasOwnProp$m.call(b, prop))
6133
- __defNormalProp$m(a, prop, b[prop]);
6134
- if (__getOwnPropSymbols$m)
6135
- for (var prop of __getOwnPropSymbols$m(b)) {
6136
- if (__propIsEnum$m.call(b, prop))
6137
- __defNormalProp$m(a, prop, b[prop]);
6336
+ if (__hasOwnProp$l.call(b, prop))
6337
+ __defNormalProp$l(a, prop, b[prop]);
6338
+ if (__getOwnPropSymbols$l)
6339
+ for (var prop of __getOwnPropSymbols$l(b)) {
6340
+ if (__propIsEnum$l.call(b, prop))
6341
+ __defNormalProp$l(a, prop, b[prop]);
6138
6342
  }
6139
6343
  return a;
6140
6344
  };
6141
- var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
6345
+ var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
6142
6346
  class SceneDataLayerSetBase extends SceneObjectBase {
6143
6347
  constructor() {
6144
6348
  super(...arguments);
@@ -6162,7 +6366,7 @@ class SceneDataLayerSetBase extends SceneObjectBase {
6162
6366
  series = series.concat(result.data.series);
6163
6367
  }
6164
6368
  }
6165
- const combinedData = __spreadProps$c(__spreadValues$m({}, emptyPanelData), { series });
6369
+ const combinedData = __spreadProps$b(__spreadValues$l({}, emptyPanelData), { series });
6166
6370
  this._results.next({ origin: this, data: combinedData });
6167
6371
  this.setStateHelper({ data: combinedData });
6168
6372
  }
@@ -6211,25 +6415,25 @@ SceneDataLayerSet.Component = ({ model }) => {
6211
6415
  })));
6212
6416
  };
6213
6417
 
6214
- var __defProp$l = Object.defineProperty;
6215
- var __defProps$b = Object.defineProperties;
6216
- var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
6217
- var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
6218
- var __hasOwnProp$l = Object.prototype.hasOwnProperty;
6219
- var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
6220
- var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6221
- var __spreadValues$l = (a, b) => {
6418
+ var __defProp$k = Object.defineProperty;
6419
+ var __defProps$a = Object.defineProperties;
6420
+ var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
6421
+ var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
6422
+ var __hasOwnProp$k = Object.prototype.hasOwnProperty;
6423
+ var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
6424
+ var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6425
+ var __spreadValues$k = (a, b) => {
6222
6426
  for (var prop in b || (b = {}))
6223
- if (__hasOwnProp$l.call(b, prop))
6224
- __defNormalProp$l(a, prop, b[prop]);
6225
- if (__getOwnPropSymbols$l)
6226
- for (var prop of __getOwnPropSymbols$l(b)) {
6227
- if (__propIsEnum$l.call(b, prop))
6228
- __defNormalProp$l(a, prop, b[prop]);
6427
+ if (__hasOwnProp$k.call(b, prop))
6428
+ __defNormalProp$k(a, prop, b[prop]);
6429
+ if (__getOwnPropSymbols$k)
6430
+ for (var prop of __getOwnPropSymbols$k(b)) {
6431
+ if (__propIsEnum$k.call(b, prop))
6432
+ __defNormalProp$k(a, prop, b[prop]);
6229
6433
  }
6230
6434
  return a;
6231
6435
  };
6232
- var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
6436
+ var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
6233
6437
  class SceneDataTransformer extends SceneObjectBase {
6234
6438
  constructor(state) {
6235
6439
  super(state);
@@ -6306,7 +6510,7 @@ class SceneDataTransformer extends SceneObjectBase {
6306
6510
  const { series, annotations } = this._prevDataFromSource;
6307
6511
  if (data.series === series && data.annotations === annotations) {
6308
6512
  if (this.state.data && data.state !== this.state.data.state) {
6309
- this.setState({ data: __spreadProps$b(__spreadValues$l({}, this.state.data), { state: data.state }) });
6513
+ this.setState({ data: __spreadProps$a(__spreadValues$k({}, this.state.data), { state: data.state }) });
6310
6514
  }
6311
6515
  return true;
6312
6516
  }
@@ -6354,7 +6558,7 @@ class SceneDataTransformer extends SceneObjectBase {
6354
6558
  rxjs.map((values) => {
6355
6559
  const transformedSeries = values[0];
6356
6560
  const transformedAnnotations = values[1];
6357
- return __spreadProps$b(__spreadValues$l({}, data$1), {
6561
+ return __spreadProps$a(__spreadValues$k({}, data$1), {
6358
6562
  series: transformedSeries,
6359
6563
  annotations: transformedAnnotations != null ? transformedAnnotations : data$1.annotations
6360
6564
  });
@@ -6365,7 +6569,7 @@ class SceneDataTransformer extends SceneObjectBase {
6365
6569
  const sourceErr = ((_a2 = this.getSourceData().state.data) == null ? void 0 : _a2.errors) || [];
6366
6570
  const transformationError = runtime.toDataQueryError(err);
6367
6571
  transformationError.message = `Error transforming data: ${transformationError.message}`;
6368
- const result = __spreadProps$b(__spreadValues$l({}, data$1), {
6572
+ const result = __spreadProps$a(__spreadValues$k({}, data$1), {
6369
6573
  state: data.LoadingState.Error,
6370
6574
  errors: [...sourceErr, transformationError]
6371
6575
  });
@@ -6698,28 +6902,28 @@ class SceneVariableSetVariableDependencyHandler {
6698
6902
  }
6699
6903
  }
6700
6904
 
6701
- var __defProp$k = Object.defineProperty;
6702
- var __defProps$a = Object.defineProperties;
6703
- var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
6704
- var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
6705
- var __hasOwnProp$k = Object.prototype.hasOwnProperty;
6706
- var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
6707
- var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6708
- var __spreadValues$k = (a, b) => {
6905
+ var __defProp$j = Object.defineProperty;
6906
+ var __defProps$9 = Object.defineProperties;
6907
+ var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
6908
+ var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
6909
+ var __hasOwnProp$j = Object.prototype.hasOwnProperty;
6910
+ var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
6911
+ var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6912
+ var __spreadValues$j = (a, b) => {
6709
6913
  for (var prop in b || (b = {}))
6710
- if (__hasOwnProp$k.call(b, prop))
6711
- __defNormalProp$k(a, prop, b[prop]);
6712
- if (__getOwnPropSymbols$k)
6713
- for (var prop of __getOwnPropSymbols$k(b)) {
6714
- if (__propIsEnum$k.call(b, prop))
6715
- __defNormalProp$k(a, prop, b[prop]);
6914
+ if (__hasOwnProp$j.call(b, prop))
6915
+ __defNormalProp$j(a, prop, b[prop]);
6916
+ if (__getOwnPropSymbols$j)
6917
+ for (var prop of __getOwnPropSymbols$j(b)) {
6918
+ if (__propIsEnum$j.call(b, prop))
6919
+ __defNormalProp$j(a, prop, b[prop]);
6716
6920
  }
6717
6921
  return a;
6718
6922
  };
6719
- var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
6923
+ var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
6720
6924
  class ConstantVariable extends SceneObjectBase {
6721
6925
  constructor(initialState) {
6722
- super(__spreadProps$a(__spreadValues$k({
6926
+ super(__spreadProps$9(__spreadValues$j({
6723
6927
  type: "constant",
6724
6928
  value: "",
6725
6929
  name: ""
@@ -6732,25 +6936,25 @@ class ConstantVariable extends SceneObjectBase {
6732
6936
  }
6733
6937
  }
6734
6938
 
6735
- var __defProp$j = Object.defineProperty;
6736
- var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
6737
- var __hasOwnProp$j = Object.prototype.hasOwnProperty;
6738
- var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
6739
- var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6740
- var __spreadValues$j = (a, b) => {
6939
+ var __defProp$i = Object.defineProperty;
6940
+ var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
6941
+ var __hasOwnProp$i = Object.prototype.hasOwnProperty;
6942
+ var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
6943
+ var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6944
+ var __spreadValues$i = (a, b) => {
6741
6945
  for (var prop in b || (b = {}))
6742
- if (__hasOwnProp$j.call(b, prop))
6743
- __defNormalProp$j(a, prop, b[prop]);
6744
- if (__getOwnPropSymbols$j)
6745
- for (var prop of __getOwnPropSymbols$j(b)) {
6746
- if (__propIsEnum$j.call(b, prop))
6747
- __defNormalProp$j(a, prop, b[prop]);
6946
+ if (__hasOwnProp$i.call(b, prop))
6947
+ __defNormalProp$i(a, prop, b[prop]);
6948
+ if (__getOwnPropSymbols$i)
6949
+ for (var prop of __getOwnPropSymbols$i(b)) {
6950
+ if (__propIsEnum$i.call(b, prop))
6951
+ __defNormalProp$i(a, prop, b[prop]);
6748
6952
  }
6749
6953
  return a;
6750
6954
  };
6751
6955
  class CustomVariable extends MultiValueVariable {
6752
6956
  constructor(initialState) {
6753
- super(__spreadValues$j({
6957
+ super(__spreadValues$i({
6754
6958
  type: "custom",
6755
6959
  query: "",
6756
6960
  value: "",
@@ -6784,25 +6988,25 @@ CustomVariable.Component = ({ model }) => {
6784
6988
  return renderSelectForVariable(model);
6785
6989
  };
6786
6990
 
6787
- var __defProp$i = Object.defineProperty;
6788
- var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
6789
- var __hasOwnProp$i = Object.prototype.hasOwnProperty;
6790
- var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
6791
- var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6792
- var __spreadValues$i = (a, b) => {
6991
+ var __defProp$h = Object.defineProperty;
6992
+ var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
6993
+ var __hasOwnProp$h = Object.prototype.hasOwnProperty;
6994
+ var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
6995
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6996
+ var __spreadValues$h = (a, b) => {
6793
6997
  for (var prop in b || (b = {}))
6794
- if (__hasOwnProp$i.call(b, prop))
6795
- __defNormalProp$i(a, prop, b[prop]);
6796
- if (__getOwnPropSymbols$i)
6797
- for (var prop of __getOwnPropSymbols$i(b)) {
6798
- if (__propIsEnum$i.call(b, prop))
6799
- __defNormalProp$i(a, prop, b[prop]);
6998
+ if (__hasOwnProp$h.call(b, prop))
6999
+ __defNormalProp$h(a, prop, b[prop]);
7000
+ if (__getOwnPropSymbols$h)
7001
+ for (var prop of __getOwnPropSymbols$h(b)) {
7002
+ if (__propIsEnum$h.call(b, prop))
7003
+ __defNormalProp$h(a, prop, b[prop]);
6800
7004
  }
6801
7005
  return a;
6802
7006
  };
6803
7007
  class DataSourceVariable extends MultiValueVariable {
6804
7008
  constructor(initialState) {
6805
- super(__spreadValues$i({
7009
+ super(__spreadValues$h({
6806
7010
  type: "datasource",
6807
7011
  value: "",
6808
7012
  text: "",
@@ -6886,25 +7090,25 @@ const hasCustomVariableSupport = (datasource) => {
6886
7090
  return "query" in variableSupport && "editor" in variableSupport && Boolean(variableSupport.query) && Boolean(variableSupport.editor);
6887
7091
  };
6888
7092
 
6889
- var __defProp$h = Object.defineProperty;
6890
- var __defProps$9 = Object.defineProperties;
6891
- var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
6892
- var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
6893
- var __hasOwnProp$h = Object.prototype.hasOwnProperty;
6894
- var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
6895
- var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6896
- var __spreadValues$h = (a, b) => {
7093
+ var __defProp$g = Object.defineProperty;
7094
+ var __defProps$8 = Object.defineProperties;
7095
+ var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
7096
+ var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
7097
+ var __hasOwnProp$g = Object.prototype.hasOwnProperty;
7098
+ var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
7099
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7100
+ var __spreadValues$g = (a, b) => {
6897
7101
  for (var prop in b || (b = {}))
6898
- if (__hasOwnProp$h.call(b, prop))
6899
- __defNormalProp$h(a, prop, b[prop]);
6900
- if (__getOwnPropSymbols$h)
6901
- for (var prop of __getOwnPropSymbols$h(b)) {
6902
- if (__propIsEnum$h.call(b, prop))
6903
- __defNormalProp$h(a, prop, b[prop]);
7102
+ if (__hasOwnProp$g.call(b, prop))
7103
+ __defNormalProp$g(a, prop, b[prop]);
7104
+ if (__getOwnPropSymbols$g)
7105
+ for (var prop of __getOwnPropSymbols$g(b)) {
7106
+ if (__propIsEnum$g.call(b, prop))
7107
+ __defNormalProp$g(a, prop, b[prop]);
6904
7108
  }
6905
7109
  return a;
6906
7110
  };
6907
- var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
7111
+ var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
6908
7112
  class StandardQueryRunner {
6909
7113
  constructor(datasource, _runRequest = runtime.getRunRequest()) {
6910
7114
  this.datasource = datasource;
@@ -6941,7 +7145,7 @@ class LegacyQueryRunner {
6941
7145
  return getEmptyMetricFindValueObservable();
6942
7146
  }
6943
7147
  return rxjs.from(
6944
- this.datasource.metricFindQuery(variable.state.query, __spreadProps$9(__spreadValues$h({}, request), {
7148
+ this.datasource.metricFindQuery(variable.state.query, __spreadProps$8(__spreadValues$g({}, request), {
6945
7149
  variable: {
6946
7150
  name: variable.state.name,
6947
7151
  type: variable.state.type
@@ -7003,7 +7207,7 @@ function ensureVariableQueryModelIsADataQuery(variable) {
7003
7207
  return { query, refId: `variable-${variable.state.name}` };
7004
7208
  }
7005
7209
  if (query.refId == null) {
7006
- return __spreadProps$9(__spreadValues$h({}, query), { refId: `variable-${variable.state.name}` });
7210
+ return __spreadProps$8(__spreadValues$g({}, query), { refId: `variable-${variable.state.name}` });
7007
7211
  }
7008
7212
  return variable.state.query;
7009
7213
  }
@@ -7218,25 +7422,25 @@ function areMetricFindValues(data$1) {
7218
7422
  return false;
7219
7423
  }
7220
7424
 
7221
- var __defProp$g = Object.defineProperty;
7222
- var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
7223
- var __hasOwnProp$g = Object.prototype.hasOwnProperty;
7224
- var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
7225
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7226
- var __spreadValues$g = (a, b) => {
7425
+ var __defProp$f = Object.defineProperty;
7426
+ var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
7427
+ var __hasOwnProp$f = Object.prototype.hasOwnProperty;
7428
+ var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
7429
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7430
+ var __spreadValues$f = (a, b) => {
7227
7431
  for (var prop in b || (b = {}))
7228
- if (__hasOwnProp$g.call(b, prop))
7229
- __defNormalProp$g(a, prop, b[prop]);
7230
- if (__getOwnPropSymbols$g)
7231
- for (var prop of __getOwnPropSymbols$g(b)) {
7232
- if (__propIsEnum$g.call(b, prop))
7233
- __defNormalProp$g(a, prop, b[prop]);
7432
+ if (__hasOwnProp$f.call(b, prop))
7433
+ __defNormalProp$f(a, prop, b[prop]);
7434
+ if (__getOwnPropSymbols$f)
7435
+ for (var prop of __getOwnPropSymbols$f(b)) {
7436
+ if (__propIsEnum$f.call(b, prop))
7437
+ __defNormalProp$f(a, prop, b[prop]);
7234
7438
  }
7235
7439
  return a;
7236
7440
  };
7237
7441
  class QueryVariable extends MultiValueVariable {
7238
7442
  constructor(initialState) {
7239
- super(__spreadValues$g({
7443
+ super(__spreadValues$f({
7240
7444
  type: "query",
7241
7445
  name: "",
7242
7446
  value: "",
@@ -7389,25 +7593,25 @@ function queryMetricTree(query) {
7389
7593
  return queryTree(children, query.split("."), 0);
7390
7594
  }
7391
7595
 
7392
- var __defProp$f = Object.defineProperty;
7393
- var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
7394
- var __hasOwnProp$f = Object.prototype.hasOwnProperty;
7395
- var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
7396
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7397
- var __spreadValues$f = (a, b) => {
7596
+ var __defProp$e = Object.defineProperty;
7597
+ var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
7598
+ var __hasOwnProp$e = Object.prototype.hasOwnProperty;
7599
+ var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
7600
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7601
+ var __spreadValues$e = (a, b) => {
7398
7602
  for (var prop in b || (b = {}))
7399
- if (__hasOwnProp$f.call(b, prop))
7400
- __defNormalProp$f(a, prop, b[prop]);
7401
- if (__getOwnPropSymbols$f)
7402
- for (var prop of __getOwnPropSymbols$f(b)) {
7403
- if (__propIsEnum$f.call(b, prop))
7404
- __defNormalProp$f(a, prop, b[prop]);
7603
+ if (__hasOwnProp$e.call(b, prop))
7604
+ __defNormalProp$e(a, prop, b[prop]);
7605
+ if (__getOwnPropSymbols$e)
7606
+ for (var prop of __getOwnPropSymbols$e(b)) {
7607
+ if (__propIsEnum$e.call(b, prop))
7608
+ __defNormalProp$e(a, prop, b[prop]);
7405
7609
  }
7406
7610
  return a;
7407
7611
  };
7408
7612
  class TestVariable extends MultiValueVariable {
7409
7613
  constructor(initialState, isLazy = false) {
7410
- super(__spreadValues$f({
7614
+ super(__spreadValues$e({
7411
7615
  type: "custom",
7412
7616
  name: "Test",
7413
7617
  value: "Value",
@@ -7516,25 +7720,25 @@ function VariableValueInput({ model }) {
7516
7720
  });
7517
7721
  }
7518
7722
 
7519
- var __defProp$e = Object.defineProperty;
7520
- var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
7521
- var __hasOwnProp$e = Object.prototype.hasOwnProperty;
7522
- var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
7523
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7524
- var __spreadValues$e = (a, b) => {
7723
+ var __defProp$d = Object.defineProperty;
7724
+ var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
7725
+ var __hasOwnProp$d = Object.prototype.hasOwnProperty;
7726
+ var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
7727
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7728
+ var __spreadValues$d = (a, b) => {
7525
7729
  for (var prop in b || (b = {}))
7526
- if (__hasOwnProp$e.call(b, prop))
7527
- __defNormalProp$e(a, prop, b[prop]);
7528
- if (__getOwnPropSymbols$e)
7529
- for (var prop of __getOwnPropSymbols$e(b)) {
7530
- if (__propIsEnum$e.call(b, prop))
7531
- __defNormalProp$e(a, prop, b[prop]);
7730
+ if (__hasOwnProp$d.call(b, prop))
7731
+ __defNormalProp$d(a, prop, b[prop]);
7732
+ if (__getOwnPropSymbols$d)
7733
+ for (var prop of __getOwnPropSymbols$d(b)) {
7734
+ if (__propIsEnum$d.call(b, prop))
7735
+ __defNormalProp$d(a, prop, b[prop]);
7532
7736
  }
7533
7737
  return a;
7534
7738
  };
7535
7739
  class TextBoxVariable extends SceneObjectBase {
7536
7740
  constructor(initialState) {
7537
- super(__spreadValues$e({
7741
+ super(__spreadValues$d({
7538
7742
  type: "textbox",
7539
7743
  value: "",
7540
7744
  name: ""
@@ -7571,28 +7775,28 @@ TextBoxVariable.Component = ({ model }) => {
7571
7775
  });
7572
7776
  };
7573
7777
 
7574
- var __defProp$d = Object.defineProperty;
7575
- var __defProps$8 = Object.defineProperties;
7576
- var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
7577
- var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
7578
- var __hasOwnProp$d = Object.prototype.hasOwnProperty;
7579
- var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
7580
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7581
- var __spreadValues$d = (a, b) => {
7778
+ var __defProp$c = Object.defineProperty;
7779
+ var __defProps$7 = Object.defineProperties;
7780
+ var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
7781
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
7782
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
7783
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
7784
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7785
+ var __spreadValues$c = (a, b) => {
7582
7786
  for (var prop in b || (b = {}))
7583
- if (__hasOwnProp$d.call(b, prop))
7584
- __defNormalProp$d(a, prop, b[prop]);
7585
- if (__getOwnPropSymbols$d)
7586
- for (var prop of __getOwnPropSymbols$d(b)) {
7587
- if (__propIsEnum$d.call(b, prop))
7588
- __defNormalProp$d(a, prop, b[prop]);
7787
+ if (__hasOwnProp$c.call(b, prop))
7788
+ __defNormalProp$c(a, prop, b[prop]);
7789
+ if (__getOwnPropSymbols$c)
7790
+ for (var prop of __getOwnPropSymbols$c(b)) {
7791
+ if (__propIsEnum$c.call(b, prop))
7792
+ __defNormalProp$c(a, prop, b[prop]);
7589
7793
  }
7590
7794
  return a;
7591
7795
  };
7592
- var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
7796
+ var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
7593
7797
  class LocalValueVariable extends SceneObjectBase {
7594
7798
  constructor(initialState) {
7595
- super(__spreadProps$8(__spreadValues$d({
7799
+ super(__spreadProps$7(__spreadValues$c({
7596
7800
  type: "system",
7597
7801
  value: "",
7598
7802
  text: "",
@@ -7624,25 +7828,25 @@ class LocalValueVariable extends SceneObjectBase {
7624
7828
  }
7625
7829
  }
7626
7830
 
7627
- var __defProp$c = Object.defineProperty;
7628
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
7629
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
7630
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
7631
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7632
- var __spreadValues$c = (a, b) => {
7831
+ var __defProp$b = Object.defineProperty;
7832
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
7833
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
7834
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
7835
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7836
+ var __spreadValues$b = (a, b) => {
7633
7837
  for (var prop in b || (b = {}))
7634
- if (__hasOwnProp$c.call(b, prop))
7635
- __defNormalProp$c(a, prop, b[prop]);
7636
- if (__getOwnPropSymbols$c)
7637
- for (var prop of __getOwnPropSymbols$c(b)) {
7638
- if (__propIsEnum$c.call(b, prop))
7639
- __defNormalProp$c(a, prop, b[prop]);
7838
+ if (__hasOwnProp$b.call(b, prop))
7839
+ __defNormalProp$b(a, prop, b[prop]);
7840
+ if (__getOwnPropSymbols$b)
7841
+ for (var prop of __getOwnPropSymbols$b(b)) {
7842
+ if (__propIsEnum$b.call(b, prop))
7843
+ __defNormalProp$b(a, prop, b[prop]);
7640
7844
  }
7641
7845
  return a;
7642
7846
  };
7643
7847
  class IntervalVariable extends SceneObjectBase {
7644
7848
  constructor(initialState) {
7645
- super(__spreadValues$c({
7849
+ super(__spreadValues$b({
7646
7850
  type: "interval",
7647
7851
  value: "",
7648
7852
  intervals: ["1m", "10m", "30m", "1h", "6h", "12h", "1d", "7d", "14d", "30d"],
@@ -7732,12 +7936,28 @@ class UrlSyncManager {
7732
7936
  constructor() {
7733
7937
  this._urlKeyMapper = new UniqueUrlKeyMapper();
7734
7938
  this._stateSub = null;
7939
+ this._locationSub = null;
7940
+ this._ignoreNextLocationUpdate = false;
7941
+ this._onLocationUpdate = (location) => {
7942
+ if (this._ignoreNextLocationUpdate) {
7943
+ this._ignoreNextLocationUpdate = false;
7944
+ return;
7945
+ }
7946
+ if (this._lastPath !== location.pathname) {
7947
+ return;
7948
+ }
7949
+ const urlParams = new URLSearchParams(location.search);
7950
+ this._urlKeyMapper.rebuildIndex(this._sceneRoot);
7951
+ syncStateFromUrl(this._sceneRoot, urlParams, this._urlKeyMapper);
7952
+ this._lastPath = location.pathname;
7953
+ };
7735
7954
  this._onStateChanged = ({ payload }) => {
7736
7955
  const changedObject = payload.changedObject;
7737
7956
  if (changedObject.urlSync) {
7738
7957
  const newUrlState = changedObject.urlSync.getUrlState();
7739
7958
  const searchParams = runtime.locationService.getSearch();
7740
7959
  const mappedUpdated = {};
7960
+ this._urlKeyMapper.rebuildIndex(this._sceneRoot);
7741
7961
  for (const [key, newUrlValue] of Object.entries(newUrlState)) {
7742
7962
  const uniqueKey = this._urlKeyMapper.getUniqueKey(key, changedObject);
7743
7963
  const currentUrlValue = searchParams.getAll(uniqueKey);
@@ -7746,33 +7966,36 @@ class UrlSyncManager {
7746
7966
  }
7747
7967
  }
7748
7968
  if (Object.keys(mappedUpdated).length > 0) {
7749
- writeSceneLog("UrlSyncManager", "onStateChange updating URL");
7969
+ this._ignoreNextLocationUpdate = true;
7750
7970
  runtime.locationService.partial(mappedUpdated, true);
7751
- this._lastLocation = runtime.locationService.getLocation();
7752
- this._urlParams = new URLSearchParams(this._lastLocation.search);
7753
7971
  }
7754
7972
  }
7755
7973
  };
7756
7974
  }
7757
7975
  initSync(root) {
7758
- var _a;
7976
+ if (!this._locationSub) {
7977
+ writeSceneLog("UrlSyncManager", "New location listen");
7978
+ this._locationSub = runtime.locationService.getHistory().listen(this._onLocationUpdate);
7979
+ }
7759
7980
  if (this._stateSub) {
7760
- writeSceneLog("UrlSyncManager", "Unregister previous scene state subscription", (_a = this._sceneRoot) == null ? void 0 : _a.state.key);
7981
+ writeSceneLog("UrlSyncManager", "Unregister previous scene state subscription", this._sceneRoot.state.key);
7761
7982
  this._stateSub.unsubscribe();
7762
7983
  }
7763
- writeSceneLog("UrlSyncManager", "init", root.state.key);
7764
7984
  this._sceneRoot = root;
7985
+ this._lastPath = runtime.locationService.getLocation().pathname;
7765
7986
  this._stateSub = root.subscribeToEvent(SceneObjectStateChangedEvent, this._onStateChanged);
7766
- this._urlKeyMapper.clear();
7767
- this._lastLocation = runtime.locationService.getLocation();
7768
- this._urlParams = new URLSearchParams(this._lastLocation.search);
7769
- this.handleNewObject(this._sceneRoot);
7987
+ this.syncFrom(this._sceneRoot);
7770
7988
  }
7771
7989
  cleanUp(root) {
7772
7990
  if (this._sceneRoot !== root) {
7773
7991
  return;
7774
7992
  }
7775
7993
  writeSceneLog("UrlSyncManager", "Clean up");
7994
+ if (this._locationSub) {
7995
+ this._locationSub();
7996
+ writeSceneLog("UrlSyncManager", "Unregister history listen");
7997
+ this._locationSub = null;
7998
+ }
7776
7999
  if (this._stateSub) {
7777
8000
  this._stateSub.unsubscribe();
7778
8001
  this._stateSub = null;
@@ -7783,23 +8006,11 @@ class UrlSyncManager {
7783
8006
  this._sceneRoot.state.key === root.state.key
7784
8007
  );
7785
8008
  }
7786
- this._sceneRoot = void 0;
7787
- this._urlParams = void 0;
7788
8009
  }
7789
- handleNewLocation(location) {
7790
- if (!this._sceneRoot || this._lastLocation === location) {
7791
- return;
7792
- }
7793
- writeSceneLog("UrlSyncManager", "handleNewLocation");
7794
- this._urlParams = new URLSearchParams(location.search);
7795
- this._lastLocation = location;
7796
- syncStateFromUrl(this._sceneRoot, this._urlParams, this._urlKeyMapper);
7797
- }
7798
- handleNewObject(sceneObj) {
7799
- if (!this._sceneRoot || !this._urlParams) {
7800
- return;
7801
- }
7802
- syncStateFromUrl(sceneObj, this._urlParams, this._urlKeyMapper);
8010
+ syncFrom(sceneObj) {
8011
+ const urlParams = runtime.locationService.getSearch();
8012
+ this._urlKeyMapper.rebuildIndex(this._sceneRoot);
8013
+ syncStateFromUrl(sceneObj, urlParams, this._urlKeyMapper);
7803
8014
  }
7804
8015
  getUrlState(root) {
7805
8016
  return getUrlState(root);
@@ -7813,34 +8024,6 @@ function getUrlSyncManager() {
7813
8024
  return urlSyncManager;
7814
8025
  }
7815
8026
 
7816
- function useUrlSync(sceneRoot) {
7817
- const urlSyncManager = getUrlSyncManager();
7818
- const location = reactRouterDom.useLocation();
7819
- const [isInitialized, setIsInitialized] = React.useState(false);
7820
- React.useEffect(() => {
7821
- urlSyncManager.initSync(sceneRoot);
7822
- setIsInitialized(true);
7823
- return () => urlSyncManager.cleanUp(sceneRoot);
7824
- }, [sceneRoot, urlSyncManager]);
7825
- React.useEffect(() => {
7826
- const latestLocation = runtime.locationService.getLocation();
7827
- const locationToHandle = latestLocation !== location ? latestLocation : location;
7828
- if (latestLocation !== location) {
7829
- console.log("latestLocation different from location");
7830
- }
7831
- urlSyncManager.handleNewLocation(locationToHandle);
7832
- }, [sceneRoot, urlSyncManager, location]);
7833
- return isInitialized;
7834
- }
7835
-
7836
- function UrlSyncContextProvider({ children, scene }) {
7837
- const isInitialized = useUrlSync(scene);
7838
- if (!isInitialized) {
7839
- return null;
7840
- }
7841
- return children;
7842
- }
7843
-
7844
8027
  function setWindowGrafanaSceneContext(activeScene) {
7845
8028
  const prevScene = window.__grafanaSceneContext;
7846
8029
  writeSceneLog("setWindowGrafanaScene", "set window.__grafanaSceneContext", activeScene);
@@ -7860,14 +8043,18 @@ class EmbeddedScene extends SceneObjectBase {
7860
8043
  const unsetGlobalScene = setWindowGrafanaSceneContext(this);
7861
8044
  return () => {
7862
8045
  unsetGlobalScene();
8046
+ getUrlSyncManager().cleanUp(this);
7863
8047
  };
7864
8048
  });
7865
8049
  }
8050
+ initUrlSync() {
8051
+ getUrlSyncManager().initSync(this);
8052
+ }
7866
8053
  }
7867
8054
  EmbeddedScene.Component = EmbeddedSceneRenderer;
7868
8055
  function EmbeddedSceneRenderer({ model }) {
7869
8056
  const { body, controls } = model.useState();
7870
- const styles = ui.useStyles2(getStyles$6);
8057
+ const styles = ui.useStyles2(getStyles$5);
7871
8058
  return /* @__PURE__ */ React__default["default"].createElement("div", {
7872
8059
  className: styles.container
7873
8060
  }, controls && /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -7881,7 +8068,7 @@ function EmbeddedSceneRenderer({ model }) {
7881
8068
  model: body
7882
8069
  })));
7883
8070
  }
7884
- const getStyles$6 = (theme) => {
8071
+ const getStyles$5 = (theme) => {
7885
8072
  return {
7886
8073
  container: css.css({
7887
8074
  flexGrow: 1,
@@ -7984,30 +8171,30 @@ function isSceneGridLayout(child) {
7984
8171
  return child instanceof SceneGridLayout;
7985
8172
  }
7986
8173
 
7987
- var __defProp$b = Object.defineProperty;
7988
- var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
7989
- var __hasOwnProp$b = Object.prototype.hasOwnProperty;
7990
- var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
7991
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7992
- var __spreadValues$b = (a, b) => {
8174
+ var __defProp$a = Object.defineProperty;
8175
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
8176
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
8177
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
8178
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8179
+ var __spreadValues$a = (a, b) => {
7993
8180
  for (var prop in b || (b = {}))
7994
- if (__hasOwnProp$b.call(b, prop))
7995
- __defNormalProp$b(a, prop, b[prop]);
7996
- if (__getOwnPropSymbols$b)
7997
- for (var prop of __getOwnPropSymbols$b(b)) {
7998
- if (__propIsEnum$b.call(b, prop))
7999
- __defNormalProp$b(a, prop, b[prop]);
8181
+ if (__hasOwnProp$a.call(b, prop))
8182
+ __defNormalProp$a(a, prop, b[prop]);
8183
+ if (__getOwnPropSymbols$a)
8184
+ for (var prop of __getOwnPropSymbols$a(b)) {
8185
+ if (__propIsEnum$a.call(b, prop))
8186
+ __defNormalProp$a(a, prop, b[prop]);
8000
8187
  }
8001
8188
  return a;
8002
8189
  };
8003
8190
  var __objRest$1 = (source, exclude) => {
8004
8191
  var target = {};
8005
8192
  for (var prop in source)
8006
- if (__hasOwnProp$b.call(source, prop) && exclude.indexOf(prop) < 0)
8193
+ if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
8007
8194
  target[prop] = source[prop];
8008
- if (source != null && __getOwnPropSymbols$b)
8009
- for (var prop of __getOwnPropSymbols$b(source)) {
8010
- if (exclude.indexOf(prop) < 0 && __propIsEnum$b.call(source, prop))
8195
+ if (source != null && __getOwnPropSymbols$a)
8196
+ for (var prop of __getOwnPropSymbols$a(source)) {
8197
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
8011
8198
  target[prop] = source[prop];
8012
8199
  }
8013
8200
  return target;
@@ -8047,7 +8234,7 @@ const LazyLoader = React__default["default"].forwardRef(
8047
8234
  }
8048
8235
  };
8049
8236
  });
8050
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$b({
8237
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$a({
8051
8238
  id,
8052
8239
  ref: innerRef
8053
8240
  }, rest), loaded && (typeof children === "function" ? children({ isInView }) : children));
@@ -8065,33 +8252,33 @@ LazyLoader.observer = new IntersectionObserver(
8065
8252
  { rootMargin: "100px" }
8066
8253
  );
8067
8254
 
8068
- var __defProp$a = Object.defineProperty;
8069
- var __defProps$7 = Object.defineProperties;
8070
- var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
8071
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
8072
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
8073
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
8074
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8075
- var __spreadValues$a = (a, b) => {
8255
+ var __defProp$9 = Object.defineProperty;
8256
+ var __defProps$6 = Object.defineProperties;
8257
+ var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
8258
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
8259
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
8260
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
8261
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8262
+ var __spreadValues$9 = (a, b) => {
8076
8263
  for (var prop in b || (b = {}))
8077
- if (__hasOwnProp$a.call(b, prop))
8078
- __defNormalProp$a(a, prop, b[prop]);
8079
- if (__getOwnPropSymbols$a)
8080
- for (var prop of __getOwnPropSymbols$a(b)) {
8081
- if (__propIsEnum$a.call(b, prop))
8082
- __defNormalProp$a(a, prop, b[prop]);
8264
+ if (__hasOwnProp$9.call(b, prop))
8265
+ __defNormalProp$9(a, prop, b[prop]);
8266
+ if (__getOwnPropSymbols$9)
8267
+ for (var prop of __getOwnPropSymbols$9(b)) {
8268
+ if (__propIsEnum$9.call(b, prop))
8269
+ __defNormalProp$9(a, prop, b[prop]);
8083
8270
  }
8084
8271
  return a;
8085
8272
  };
8086
- var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
8273
+ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
8087
8274
  var __objRest = (source, exclude) => {
8088
8275
  var target = {};
8089
8276
  for (var prop in source)
8090
- if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
8277
+ if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
8091
8278
  target[prop] = source[prop];
8092
- if (source != null && __getOwnPropSymbols$a)
8093
- for (var prop of __getOwnPropSymbols$a(source)) {
8094
- if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
8279
+ if (source != null && __getOwnPropSymbols$9)
8280
+ for (var prop of __getOwnPropSymbols$9(source)) {
8281
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
8095
8282
  target[prop] = source[prop];
8096
8283
  }
8097
8284
  return target;
@@ -8150,7 +8337,7 @@ const GridItemWrapper = React__default["default"].forwardRef((props, ref) => {
8150
8337
  key: sceneChild.state.key
8151
8338
  });
8152
8339
  if (isLazy) {
8153
- return /* @__PURE__ */ React__default["default"].createElement(LazyLoader, __spreadProps$7(__spreadValues$a({}, divProps), {
8340
+ return /* @__PURE__ */ React__default["default"].createElement(LazyLoader, __spreadProps$6(__spreadValues$9({}, divProps), {
8154
8341
  key: sceneChild.state.key,
8155
8342
  "data-griditem-key": sceneChild.state.key,
8156
8343
  className: css.cx(className, props.className),
@@ -8158,7 +8345,7 @@ const GridItemWrapper = React__default["default"].forwardRef((props, ref) => {
8158
8345
  ref
8159
8346
  }), innerContent, children);
8160
8347
  }
8161
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$7(__spreadValues$a({}, divProps), {
8348
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$6(__spreadValues$9({}, divProps), {
8162
8349
  ref,
8163
8350
  key: sceneChild.state.key,
8164
8351
  "data-griditem-key": sceneChild.state.key,
@@ -8188,7 +8375,7 @@ function updateAnimationClass(ref, isDraggable, retry) {
8188
8375
  const ResizeHandle = React__default["default"].forwardRef((_a, ref) => {
8189
8376
  var _b = _a, divProps = __objRest(_b, ["handleAxis"]);
8190
8377
  const customCssClass = ui.useStyles2(getResizeHandleStyles);
8191
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$7(__spreadValues$a({
8378
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$6(__spreadValues$9({
8192
8379
  ref
8193
8380
  }, divProps), {
8194
8381
  className: `${customCssClass} scene-resize-handle`
@@ -8222,41 +8409,9 @@ function getResizeHandleStyles(theme) {
8222
8409
  svg: {
8223
8410
  display: "block"
8224
8411
  },
8225
- ".react-resizable-hide &": {
8226
- display: "none"
8227
- }
8228
- });
8229
- }
8230
-
8231
- var __defProp$9 = Object.defineProperty;
8232
- var __defProps$6 = Object.defineProperties;
8233
- var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
8234
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
8235
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
8236
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
8237
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8238
- var __spreadValues$9 = (a, b) => {
8239
- for (var prop in b || (b = {}))
8240
- if (__hasOwnProp$9.call(b, prop))
8241
- __defNormalProp$9(a, prop, b[prop]);
8242
- if (__getOwnPropSymbols$9)
8243
- for (var prop of __getOwnPropSymbols$9(b)) {
8244
- if (__propIsEnum$9.call(b, prop))
8245
- __defNormalProp$9(a, prop, b[prop]);
8246
- }
8247
- return a;
8248
- };
8249
- var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
8250
- function fitPanelsInHeight(cells, height) {
8251
- const visibleHeight = height - GRID_CELL_VMARGIN * 4;
8252
- const currentGridHeight = Math.max(...cells.map((cell) => cell.h + cell.y));
8253
- const visibleGridHeight = Math.floor(visibleHeight / (GRID_CELL_HEIGHT + GRID_CELL_VMARGIN));
8254
- const scaleFactor = currentGridHeight / visibleGridHeight;
8255
- return cells.map((cell) => {
8256
- return __spreadProps$6(__spreadValues$9({}, cell), {
8257
- y: Math.round(cell.y / scaleFactor) || 0,
8258
- h: Math.round(cell.h / scaleFactor) || 1
8259
- });
8412
+ ".react-resizable-hide &": {
8413
+ display: "none"
8414
+ }
8260
8415
  });
8261
8416
  }
8262
8417
 
@@ -8279,9 +8434,41 @@ var __spreadValues$8 = (a, b) => {
8279
8434
  return a;
8280
8435
  };
8281
8436
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
8437
+ function fitPanelsInHeight(cells, height) {
8438
+ const visibleHeight = height - GRID_CELL_VMARGIN * 4;
8439
+ const currentGridHeight = Math.max(...cells.map((cell) => cell.h + cell.y));
8440
+ const visibleGridHeight = Math.floor(visibleHeight / (GRID_CELL_HEIGHT + GRID_CELL_VMARGIN));
8441
+ const scaleFactor = currentGridHeight / visibleGridHeight;
8442
+ return cells.map((cell) => {
8443
+ return __spreadProps$5(__spreadValues$8({}, cell), {
8444
+ y: Math.round(cell.y / scaleFactor) || 0,
8445
+ h: Math.round(cell.h / scaleFactor) || 1
8446
+ });
8447
+ });
8448
+ }
8449
+
8450
+ var __defProp$7 = Object.defineProperty;
8451
+ var __defProps$4 = Object.defineProperties;
8452
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
8453
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
8454
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
8455
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
8456
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8457
+ var __spreadValues$7 = (a, b) => {
8458
+ for (var prop in b || (b = {}))
8459
+ if (__hasOwnProp$7.call(b, prop))
8460
+ __defNormalProp$7(a, prop, b[prop]);
8461
+ if (__getOwnPropSymbols$7)
8462
+ for (var prop of __getOwnPropSymbols$7(b)) {
8463
+ if (__propIsEnum$7.call(b, prop))
8464
+ __defNormalProp$7(a, prop, b[prop]);
8465
+ }
8466
+ return a;
8467
+ };
8468
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
8282
8469
  const _SceneGridLayout = class extends SceneObjectBase {
8283
8470
  constructor(state) {
8284
- super(__spreadProps$5(__spreadValues$8({}, state), {
8471
+ super(__spreadProps$4(__spreadValues$7({}, state), {
8285
8472
  children: sortChildrenByPosition(state.children)
8286
8473
  }));
8287
8474
  this._skipOnLayoutChange = false;
@@ -8305,7 +8492,7 @@ const _SceneGridLayout = class extends SceneObjectBase {
8305
8492
  height: item.h
8306
8493
  };
8307
8494
  if (!isItemSizeEqual(child.state, nextSize)) {
8308
- child.setState(__spreadValues$8({}, nextSize));
8495
+ child.setState(__spreadValues$7({}, nextSize));
8309
8496
  }
8310
8497
  }
8311
8498
  this.setState({ children: sortChildrenByPosition(this.state.children) });
@@ -8379,7 +8566,7 @@ const _SceneGridLayout = class extends SceneObjectBase {
8379
8566
  const yDiff = firstPanelYPos - (rowY + 1);
8380
8567
  let yMax = rowY;
8381
8568
  for (const panel of rowChildren) {
8382
- const newSize = __spreadValues$8({}, panel.state);
8569
+ const newSize = __spreadValues$7({}, panel.state);
8383
8570
  newSize.y = (_b = newSize.y) != null ? _b : rowY;
8384
8571
  newSize.y -= yDiff;
8385
8572
  if (newSize.y !== panel.state.y) {
@@ -8506,7 +8693,7 @@ const _SceneGridLayout = class extends SceneObjectBase {
8506
8693
  }
8507
8694
  if (width < 768) {
8508
8695
  this._skipOnLayoutChange = true;
8509
- return cells.map((cell) => __spreadProps$5(__spreadValues$8({}, cell), { w: 24 }));
8696
+ return cells.map((cell) => __spreadProps$4(__spreadValues$7({}, cell), { w: 24 }));
8510
8697
  }
8511
8698
  this._skipOnLayoutChange = false;
8512
8699
  return cells;
@@ -8531,28 +8718,28 @@ function sortGridLayout(layout) {
8531
8718
  return [...layout].sort((a, b) => a.y - b.y || a.x - b.x);
8532
8719
  }
8533
8720
 
8534
- var __defProp$7 = Object.defineProperty;
8535
- var __defProps$4 = Object.defineProperties;
8536
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
8537
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
8538
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
8539
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
8540
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8541
- var __spreadValues$7 = (a, b) => {
8721
+ var __defProp$6 = Object.defineProperty;
8722
+ var __defProps$3 = Object.defineProperties;
8723
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
8724
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8725
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8726
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8727
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8728
+ var __spreadValues$6 = (a, b) => {
8542
8729
  for (var prop in b || (b = {}))
8543
- if (__hasOwnProp$7.call(b, prop))
8544
- __defNormalProp$7(a, prop, b[prop]);
8545
- if (__getOwnPropSymbols$7)
8546
- for (var prop of __getOwnPropSymbols$7(b)) {
8547
- if (__propIsEnum$7.call(b, prop))
8548
- __defNormalProp$7(a, prop, b[prop]);
8730
+ if (__hasOwnProp$6.call(b, prop))
8731
+ __defNormalProp$6(a, prop, b[prop]);
8732
+ if (__getOwnPropSymbols$6)
8733
+ for (var prop of __getOwnPropSymbols$6(b)) {
8734
+ if (__propIsEnum$6.call(b, prop))
8735
+ __defNormalProp$6(a, prop, b[prop]);
8549
8736
  }
8550
8737
  return a;
8551
8738
  };
8552
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
8739
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
8553
8740
  class SceneGridRow extends SceneObjectBase {
8554
8741
  constructor(state) {
8555
- super(__spreadProps$4(__spreadValues$7({
8742
+ super(__spreadProps$3(__spreadValues$6({
8556
8743
  children: state.children || [],
8557
8744
  isCollapsible: state.isCollapsible || true,
8558
8745
  title: state.title || ""
@@ -8717,7 +8904,7 @@ NestedScene.Component = NestedSceneRenderer;
8717
8904
  function NestedSceneRenderer({ model }) {
8718
8905
  const { title, isCollapsed, canCollapse, canRemove, body, controls } = model.useState();
8719
8906
  const gridRow = ui.useStyles2(getSceneGridRowStyles);
8720
- const styles = ui.useStyles2(getStyles$5);
8907
+ const styles = ui.useStyles2(getStyles$4);
8721
8908
  const toolbarControls = (controls != null ? controls : []).map((action) => /* @__PURE__ */ React__default["default"].createElement(action.Component, {
8722
8909
  key: action.state.key,
8723
8910
  model: action
@@ -8752,7 +8939,7 @@ function NestedSceneRenderer({ model }) {
8752
8939
  model: body
8753
8940
  }));
8754
8941
  }
8755
- const getStyles$5 = (theme) => ({
8942
+ const getStyles$4 = (theme) => ({
8756
8943
  wrapper: css.css({
8757
8944
  display: "flex",
8758
8945
  flexDirection: "column",
@@ -8919,30 +9106,30 @@ function getShiftedTimeRange(dir, timeRange, upperLimit) {
8919
9106
  };
8920
9107
  }
8921
9108
 
8922
- var __defProp$6 = Object.defineProperty;
8923
- var __defProps$3 = Object.defineProperties;
8924
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
8925
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8926
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8927
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8928
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8929
- var __spreadValues$6 = (a, b) => {
9109
+ var __defProp$5 = Object.defineProperty;
9110
+ var __defProps$2 = Object.defineProperties;
9111
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
9112
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
9113
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
9114
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
9115
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9116
+ var __spreadValues$5 = (a, b) => {
8930
9117
  for (var prop in b || (b = {}))
8931
- if (__hasOwnProp$6.call(b, prop))
8932
- __defNormalProp$6(a, prop, b[prop]);
8933
- if (__getOwnPropSymbols$6)
8934
- for (var prop of __getOwnPropSymbols$6(b)) {
8935
- if (__propIsEnum$6.call(b, prop))
8936
- __defNormalProp$6(a, prop, b[prop]);
9118
+ if (__hasOwnProp$5.call(b, prop))
9119
+ __defNormalProp$5(a, prop, b[prop]);
9120
+ if (__getOwnPropSymbols$5)
9121
+ for (var prop of __getOwnPropSymbols$5(b)) {
9122
+ if (__propIsEnum$5.call(b, prop))
9123
+ __defNormalProp$5(a, prop, b[prop]);
8937
9124
  }
8938
9125
  return a;
8939
9126
  };
8940
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
9127
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
8941
9128
  const DEFAULT_INTERVALS = ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"];
8942
9129
  class SceneRefreshPicker extends SceneObjectBase {
8943
9130
  constructor(state) {
8944
9131
  var _a, _b, _c;
8945
- super(__spreadProps$3(__spreadValues$6({
9132
+ super(__spreadProps$2(__spreadValues$5({
8946
9133
  refresh: ""
8947
9134
  }, state), {
8948
9135
  autoValue: void 0,
@@ -9027,279 +9214,51 @@ class SceneRefreshPicker extends SceneObjectBase {
9027
9214
  };
9028
9215
  }
9029
9216
  updateFromUrl(values) {
9030
- const refresh = values.refresh;
9031
- if (refresh && typeof refresh === "string") {
9032
- this.setState({
9033
- refresh
9034
- });
9035
- }
9036
- }
9037
- }
9038
- SceneRefreshPicker.Component = SceneRefreshPickerRenderer;
9039
- function SceneRefreshPickerRenderer({ model }) {
9040
- var _a;
9041
- const { refresh, intervals, autoEnabled, autoValue, isOnCanvas, primary, withText } = model.useState();
9042
- const isRunning = useQueryControllerState(model);
9043
- let text = refresh === ((_a = ui.RefreshPicker.autoOption) == null ? void 0 : _a.value) ? autoValue : withText ? "Refresh" : void 0;
9044
- let tooltip;
9045
- let width;
9046
- if (isRunning) {
9047
- tooltip = "Cancel all queries";
9048
- if (withText) {
9049
- text = "Cancel";
9050
- }
9051
- }
9052
- if (withText) {
9053
- width = "96px";
9054
- }
9055
- return /* @__PURE__ */ React__default["default"].createElement(ui.RefreshPicker, {
9056
- showAutoInterval: autoEnabled,
9057
- value: refresh,
9058
- intervals,
9059
- tooltip,
9060
- width,
9061
- text,
9062
- onRefresh: model.onRefresh,
9063
- primary,
9064
- onIntervalChanged: model.onIntervalChanged,
9065
- isLoading: isRunning,
9066
- isOnCanvas: isOnCanvas != null ? isOnCanvas : true
9067
- });
9068
- }
9069
- function useQueryControllerState(model) {
9070
- const queryController = sceneGraph.getQueryController(model);
9071
- if (!queryController) {
9072
- return false;
9073
- }
9074
- return queryController.useState().isRunning;
9075
- }
9076
-
9077
- const getCompareSeriesRefId = (refId) => `${refId}-compare`;
9078
-
9079
- var __defProp$5 = Object.defineProperty;
9080
- var __defProps$2 = Object.defineProperties;
9081
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
9082
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
9083
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
9084
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
9085
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9086
- var __spreadValues$5 = (a, b) => {
9087
- for (var prop in b || (b = {}))
9088
- if (__hasOwnProp$5.call(b, prop))
9089
- __defNormalProp$5(a, prop, b[prop]);
9090
- if (__getOwnPropSymbols$5)
9091
- for (var prop of __getOwnPropSymbols$5(b)) {
9092
- if (__propIsEnum$5.call(b, prop))
9093
- __defNormalProp$5(a, prop, b[prop]);
9094
- }
9095
- return a;
9096
- };
9097
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
9098
- const PREVIOUS_PERIOD_VALUE = "__previousPeriod";
9099
- const NO_PERIOD_VALUE = "__noPeriod";
9100
- const PREVIOUS_PERIOD_COMPARE_OPTION = {
9101
- label: "Previous period",
9102
- value: PREVIOUS_PERIOD_VALUE
9103
- };
9104
- const NO_COMPARE_OPTION = {
9105
- label: "No comparison",
9106
- value: NO_PERIOD_VALUE
9107
- };
9108
- const DEFAULT_COMPARE_OPTIONS = [
9109
- { label: "Day before", value: "24h" },
9110
- { label: "Week before", value: "1w" },
9111
- { label: "Month before", value: "1M" }
9112
- ];
9113
- class SceneTimeRangeCompare extends SceneObjectBase {
9114
- constructor(state) {
9115
- super(__spreadValues$5({ compareOptions: DEFAULT_COMPARE_OPTIONS }, state));
9116
- this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["compareWith"] });
9117
- this._onActivate = () => {
9118
- const sceneTimeRange = sceneGraph.getTimeRange(this);
9119
- this.setState({ compareOptions: this.getCompareOptions(sceneTimeRange.state.value) });
9120
- this._subs.add(
9121
- sceneTimeRange.subscribeToState((timeRange) => {
9122
- const compareOptions = this.getCompareOptions(timeRange.value);
9123
- const stateUpdate = { compareOptions };
9124
- if (Boolean(this.state.compareWith) && !compareOptions.find(({ value }) => value === this.state.compareWith)) {
9125
- stateUpdate.compareWith = PREVIOUS_PERIOD_VALUE;
9126
- }
9127
- this.setState(stateUpdate);
9128
- })
9129
- );
9130
- };
9131
- this.getCompareOptions = (timeRange) => {
9132
- const diffDays = Math.ceil(timeRange.to.diff(timeRange.from));
9133
- const matchIndex = DEFAULT_COMPARE_OPTIONS.findIndex(({ value }) => {
9134
- const intervalInMs = data.rangeUtil.intervalToMs(value);
9135
- return intervalInMs >= diffDays;
9136
- });
9137
- return [
9138
- NO_COMPARE_OPTION,
9139
- PREVIOUS_PERIOD_COMPARE_OPTION,
9140
- ...DEFAULT_COMPARE_OPTIONS.slice(matchIndex).map(({ label, value }) => ({ label, value }))
9141
- ];
9142
- };
9143
- this.onCompareWithChanged = (compareWith) => {
9144
- if (compareWith === NO_PERIOD_VALUE) {
9145
- this.onClearCompare();
9146
- } else {
9147
- this.setState({ compareWith });
9148
- }
9149
- };
9150
- this.onClearCompare = () => {
9151
- this.setState({ compareWith: void 0 });
9152
- };
9153
- this.addActivationHandler(this._onActivate);
9154
- }
9155
- getExtraQueries(request) {
9156
- const extraQueries = [];
9157
- const compareRange = this.getCompareTimeRange(request.range);
9158
- if (!compareRange) {
9159
- return extraQueries;
9160
- }
9161
- const targets = request.targets.filter((query) => query.timeRangeCompare !== false);
9162
- if (targets.length) {
9163
- extraQueries.push({
9164
- req: __spreadProps$2(__spreadValues$5({}, request), {
9165
- targets,
9166
- range: compareRange
9167
- }),
9168
- processor: timeShiftAlignmentProcessor
9169
- });
9170
- }
9171
- return extraQueries;
9172
- }
9173
- shouldRerun(prev, next) {
9174
- return prev.compareWith !== next.compareWith;
9175
- }
9176
- getCompareTimeRange(timeRange) {
9177
- let compareFrom;
9178
- let compareTo;
9179
- if (this.state.compareWith) {
9180
- if (this.state.compareWith === PREVIOUS_PERIOD_VALUE) {
9181
- const diffMs = timeRange.to.diff(timeRange.from);
9182
- compareFrom = data.dateTime(timeRange.from).subtract(diffMs);
9183
- compareTo = data.dateTime(timeRange.to).subtract(diffMs);
9184
- } else {
9185
- compareFrom = data.dateTime(timeRange.from).subtract(data.rangeUtil.intervalToMs(this.state.compareWith));
9186
- compareTo = data.dateTime(timeRange.to).subtract(data.rangeUtil.intervalToMs(this.state.compareWith));
9187
- }
9188
- return {
9189
- from: compareFrom,
9190
- to: compareTo,
9191
- raw: {
9192
- from: compareFrom,
9193
- to: compareTo
9194
- }
9195
- };
9196
- }
9197
- return void 0;
9198
- }
9199
- getUrlState() {
9200
- return {
9201
- compareWith: this.state.compareWith
9202
- };
9203
- }
9204
- updateFromUrl(values) {
9205
- if (!values.compareWith) {
9206
- return;
9207
- }
9208
- const compareWith = parseUrlParam(values.compareWith);
9209
- if (compareWith) {
9210
- const compareOptions = this.getCompareOptions(sceneGraph.getTimeRange(this).state.value);
9211
- if (compareOptions.find(({ value }) => value === compareWith)) {
9212
- this.setState({
9213
- compareWith
9214
- });
9215
- } else {
9216
- this.setState({
9217
- compareWith: "__previousPeriod"
9218
- });
9219
- }
9217
+ const refresh = values.refresh;
9218
+ if (refresh && typeof refresh === "string") {
9219
+ this.setState({
9220
+ refresh
9221
+ });
9220
9222
  }
9221
9223
  }
9222
9224
  }
9223
- SceneTimeRangeCompare.Component = SceneTimeRangeCompareRenderer;
9224
- const timeShiftAlignmentProcessor = (primary, secondary) => {
9225
- const diff = secondary.timeRange.from.diff(primary.timeRange.from);
9226
- secondary.series.forEach((series) => {
9227
- series.refId = getCompareSeriesRefId(series.refId || "");
9228
- series.meta = __spreadProps$2(__spreadValues$5({}, series.meta), {
9229
- timeCompare: {
9230
- diffMs: diff,
9231
- isTimeShiftQuery: true
9232
- }
9233
- });
9234
- series.fields.forEach((field) => {
9235
- if (field.type === data.FieldType.time) {
9236
- field.values = field.values.map((v) => {
9237
- return diff < 0 ? v - diff : v + diff;
9238
- });
9239
- }
9240
- field.config = __spreadProps$2(__spreadValues$5({}, field.config), {
9241
- color: {
9242
- mode: "fixed",
9243
- fixedColor: runtime.config.theme.palette.gray60
9244
- }
9245
- });
9246
- return field;
9247
- });
9248
- });
9249
- return rxjs.of(secondary);
9250
- };
9251
- function SceneTimeRangeCompareRenderer({ model }) {
9225
+ SceneRefreshPicker.Component = SceneRefreshPickerRenderer;
9226
+ function SceneRefreshPickerRenderer({ model }) {
9252
9227
  var _a;
9253
- const styles = ui.useStyles2(getStyles$4);
9254
- const { compareWith, compareOptions } = model.useState();
9255
- const [previousCompare, setPreviousCompare] = React__default["default"].useState(compareWith);
9256
- const previousValue = (_a = compareOptions.find(({ value: value2 }) => value2 === previousCompare)) != null ? _a : PREVIOUS_PERIOD_COMPARE_OPTION;
9257
- const value = compareOptions.find(({ value: value2 }) => value2 === compareWith);
9258
- const enabled = Boolean(value);
9259
- const onClick = () => {
9260
- if (enabled) {
9261
- setPreviousCompare(compareWith);
9262
- model.onClearCompare();
9263
- } else if (!enabled) {
9264
- model.onCompareWithChanged(previousValue.value);
9265
- }
9266
- };
9267
- return /* @__PURE__ */ React__default["default"].createElement(ui.ButtonGroup, null, /* @__PURE__ */ React__default["default"].createElement(ui.ToolbarButton, {
9268
- variant: "canvas",
9269
- tooltip: "Enable time frame comparison",
9270
- onClick: (e) => {
9271
- e.stopPropagation();
9272
- e.preventDefault();
9273
- onClick();
9274
- }
9275
- }, /* @__PURE__ */ React__default["default"].createElement(ui.Checkbox, {
9276
- label: " ",
9277
- value: enabled,
9278
- onClick
9279
- }), "Comparison"), enabled ? /* @__PURE__ */ React__default["default"].createElement(ui.ButtonSelect, {
9280
- variant: "canvas",
9281
- value,
9282
- options: compareOptions,
9283
- onChange: (v) => {
9284
- model.onCompareWithChanged(v.value);
9228
+ const { refresh, intervals, autoEnabled, autoValue, isOnCanvas, primary, withText } = model.useState();
9229
+ const isRunning = useQueryControllerState(model);
9230
+ let text = refresh === ((_a = ui.RefreshPicker.autoOption) == null ? void 0 : _a.value) ? autoValue : withText ? "Refresh" : void 0;
9231
+ let tooltip;
9232
+ let width;
9233
+ if (isRunning) {
9234
+ tooltip = "Cancel all queries";
9235
+ if (withText) {
9236
+ text = "Cancel";
9285
9237
  }
9286
- }) : /* @__PURE__ */ React__default["default"].createElement(ui.ToolbarButton, {
9287
- className: styles.previewButton,
9288
- disabled: true,
9289
- variant: "canvas",
9290
- isOpen: false
9291
- }, previousValue.label));
9238
+ }
9239
+ if (withText) {
9240
+ width = "96px";
9241
+ }
9242
+ return /* @__PURE__ */ React__default["default"].createElement(ui.RefreshPicker, {
9243
+ showAutoInterval: autoEnabled,
9244
+ value: refresh,
9245
+ intervals,
9246
+ tooltip,
9247
+ width,
9248
+ text,
9249
+ onRefresh: model.onRefresh,
9250
+ primary,
9251
+ onIntervalChanged: model.onIntervalChanged,
9252
+ isLoading: isRunning,
9253
+ isOnCanvas: isOnCanvas != null ? isOnCanvas : true
9254
+ });
9292
9255
  }
9293
- function getStyles$4(theme) {
9294
- return {
9295
- previewButton: css.css({
9296
- "&:disabled": {
9297
- border: `1px solid ${theme.colors.secondary.border}`,
9298
- color: theme.colors.text.disabled,
9299
- opacity: 1
9300
- }
9301
- })
9302
- };
9256
+ function useQueryControllerState(model) {
9257
+ const queryController = sceneGraph.getQueryController(model);
9258
+ if (!queryController) {
9259
+ return false;
9260
+ }
9261
+ return queryController.useState().isRunning;
9303
9262
  }
9304
9263
 
9305
9264
  class SceneByFrameRepeater extends SceneObjectBase {
@@ -10335,8 +10294,7 @@ function SceneAppPageView({ page, routeProps }) {
10335
10294
  React.useEffect(() => {
10336
10295
  return () => containerPage.setState({ initializedScene: void 0 });
10337
10296
  }, [containerPage]);
10338
- const urlSyncInitialized = useUrlSync(containerPage);
10339
- if (!isInitialized && !urlSyncInitialized) {
10297
+ if (!isInitialized) {
10340
10298
  return null;
10341
10299
  }
10342
10300
  const pageNav = {
@@ -10409,9 +10367,13 @@ class SceneAppPage extends SceneObjectBase {
10409
10367
  super(state);
10410
10368
  this._sceneCache = /* @__PURE__ */ new Map();
10411
10369
  this._drilldownCache = /* @__PURE__ */ new Map();
10370
+ this.addActivationHandler(() => {
10371
+ return () => getUrlSyncManager().cleanUp(this);
10372
+ });
10412
10373
  }
10413
10374
  initializeScene(scene) {
10414
10375
  this.setState({ initializedScene: scene });
10376
+ getUrlSyncManager().initSync(this);
10415
10377
  }
10416
10378
  getScene(routeMatch) {
10417
10379
  let scene = this._sceneCache.get(routeMatch.url);
@@ -11163,174 +11125,6 @@ const PanelBuilders = {
11163
11125
  }
11164
11126
  };
11165
11127
 
11166
- class VizConfigBuilder {
11167
- constructor(pluginId, pluginVersion, defaultOptions, defaultFieldConfig) {
11168
- this._pluginId = pluginId;
11169
- this._pluginVersion = pluginVersion;
11170
- this._fieldConfigBuilder = new FieldConfigBuilder(defaultFieldConfig);
11171
- this._panelOptionsBuilder = new PanelOptionsBuilder(defaultOptions);
11172
- }
11173
- setColor(color) {
11174
- this._fieldConfigBuilder.setColor(color);
11175
- return this;
11176
- }
11177
- setDecimals(decimals) {
11178
- this._fieldConfigBuilder.setDecimals(decimals);
11179
- return this;
11180
- }
11181
- setDisplayName(displayName) {
11182
- this._fieldConfigBuilder.setDisplayName(displayName);
11183
- return this;
11184
- }
11185
- setFilterable(filterable) {
11186
- this._fieldConfigBuilder.setFilterable(filterable);
11187
- return this;
11188
- }
11189
- setLinks(links) {
11190
- this._fieldConfigBuilder.setLinks(links);
11191
- return this;
11192
- }
11193
- setMappings(mappings) {
11194
- this._fieldConfigBuilder.setMappings(mappings);
11195
- return this;
11196
- }
11197
- setMax(max) {
11198
- this._fieldConfigBuilder.setMax(max);
11199
- return this;
11200
- }
11201
- setMin(min) {
11202
- this._fieldConfigBuilder.setMin(min);
11203
- return this;
11204
- }
11205
- setNoValue(noValue) {
11206
- this._fieldConfigBuilder.setNoValue(noValue);
11207
- return this;
11208
- }
11209
- setThresholds(thresholds) {
11210
- this._fieldConfigBuilder.setThresholds(thresholds);
11211
- return this;
11212
- }
11213
- setUnit(unit) {
11214
- this._fieldConfigBuilder.setUnit(unit);
11215
- return this;
11216
- }
11217
- setCustomFieldConfig(id, value) {
11218
- this._fieldConfigBuilder.setCustomFieldConfig(id, value);
11219
- return this;
11220
- }
11221
- setOverrides(builder) {
11222
- this._fieldConfigBuilder.setOverrides(builder);
11223
- return this;
11224
- }
11225
- setOption(id, value) {
11226
- this._panelOptionsBuilder.setOption(id, value);
11227
- return this;
11228
- }
11229
- build() {
11230
- return {
11231
- pluginId: this._pluginId,
11232
- pluginVersion: this._pluginVersion,
11233
- options: this._panelOptionsBuilder.build(),
11234
- fieldConfig: this._fieldConfigBuilder.build()
11235
- };
11236
- }
11237
- }
11238
-
11239
- const VizConfigBuilders = {
11240
- barchart() {
11241
- return new VizConfigBuilder(
11242
- "barchart",
11243
- "10.0.0",
11244
- () => BarChartPanelCfg_types_gen.defaultOptions,
11245
- () => BarChartPanelCfg_types_gen.defaultFieldConfig
11246
- );
11247
- },
11248
- bargauge() {
11249
- return new VizConfigBuilder("bargauge", "10.0.0", () => BarGaugePanelCfg_types_gen.defaultOptions);
11250
- },
11251
- datagrid() {
11252
- return new VizConfigBuilder("datagrid", "10.0.0", () => DatagridPanelCfg_types_gen.defaultOptions);
11253
- },
11254
- flamegraph() {
11255
- return new VizConfigBuilder("flamegraph", "10.0.0");
11256
- },
11257
- gauge() {
11258
- return new VizConfigBuilder("gauge", "10.0.0", () => GaugePanelCfg_types_gen.defaultOptions);
11259
- },
11260
- geomap() {
11261
- return new VizConfigBuilder("geomap", "10.0.0", () => GeomapPanelCfg_types_gen.defaultOptions);
11262
- },
11263
- heatmap() {
11264
- return new VizConfigBuilder("heatmap", "10.0.0", () => HeatmapPanelCfg_types_gen.defaultOptions);
11265
- },
11266
- histogram() {
11267
- return new VizConfigBuilder(
11268
- "histogram",
11269
- "10.0.0",
11270
- () => HistogramPanelCfg_types_gen.defaultOptions,
11271
- () => HistogramPanelCfg_types_gen.defaultFieldConfig
11272
- );
11273
- },
11274
- logs() {
11275
- return new VizConfigBuilder("logs", "10.0.0");
11276
- },
11277
- news() {
11278
- return new VizConfigBuilder("news", "10.0.0", () => NewsPanelCfg_types_gen.defaultOptions);
11279
- },
11280
- nodegraph() {
11281
- return new VizConfigBuilder("nodeGraph", "10.0.0");
11282
- },
11283
- piechart() {
11284
- return new VizConfigBuilder(
11285
- "piechart",
11286
- "10.0.0",
11287
- () => PieChartPanelCfg_types_gen.defaultOptions
11288
- );
11289
- },
11290
- stat() {
11291
- return new VizConfigBuilder("stat", "10.0.0", () => StatPanelCfg_types_gen.defaultOptions);
11292
- },
11293
- statetimeline() {
11294
- return new VizConfigBuilder(
11295
- "state-timeline",
11296
- "10.0.0",
11297
- () => StateTimelinePanelCfg_types_gen.defaultOptions,
11298
- () => StateTimelinePanelCfg_types_gen.defaultFieldConfig
11299
- );
11300
- },
11301
- statushistory() {
11302
- return new VizConfigBuilder(
11303
- "status-history",
11304
- "10.0.0",
11305
- () => StatusHistoryPanelCfg_types_gen.defaultOptions,
11306
- () => StatusHistoryPanelCfg_types_gen.defaultFieldConfig
11307
- );
11308
- },
11309
- table() {
11310
- return new VizConfigBuilder("table", "10.0.0", () => TablePanelCfg_types_gen.defaultOptions);
11311
- },
11312
- text() {
11313
- return new VizConfigBuilder("text", "10.0.0", () => TextPanelCfg_types_gen.defaultOptions);
11314
- },
11315
- timeseries() {
11316
- return new VizConfigBuilder("timeseries", "10.0.0");
11317
- },
11318
- trend() {
11319
- return new VizConfigBuilder("trend", "10.0.0");
11320
- },
11321
- traces() {
11322
- return new VizConfigBuilder("traces", "10.0.0");
11323
- },
11324
- xychart() {
11325
- return new VizConfigBuilder(
11326
- "xychart",
11327
- "10.0.0",
11328
- () => XYChartPanelCfg_types_gen.defaultOptions,
11329
- () => XYChartPanelCfg_types_gen.defaultFieldConfig
11330
- );
11331
- }
11332
- };
11333
-
11334
11128
  const sceneUtils = {
11335
11129
  getUrlWithAppState,
11336
11130
  registerRuntimePanelPlugin,
@@ -11355,7 +11149,6 @@ exports.ConstantVariable = ConstantVariable;
11355
11149
  exports.CustomVariable = CustomVariable;
11356
11150
  exports.DataSourceVariable = DataSourceVariable;
11357
11151
  exports.EmbeddedScene = EmbeddedScene;
11358
- exports.FieldConfigBuilder = FieldConfigBuilder;
11359
11152
  exports.FieldConfigBuilders = FieldConfigBuilders;
11360
11153
  exports.FieldConfigOverridesBuilder = FieldConfigOverridesBuilder;
11361
11154
  exports.GroupByVariable = GroupByVariable;
@@ -11406,15 +11199,11 @@ exports.SceneVariableValueChangedEvent = SceneVariableValueChangedEvent;
11406
11199
  exports.SplitLayout = SplitLayout;
11407
11200
  exports.TestVariable = TestVariable;
11408
11201
  exports.TextBoxVariable = TextBoxVariable;
11409
- exports.UrlSyncContextProvider = UrlSyncContextProvider;
11410
11202
  exports.UrlSyncManager = UrlSyncManager;
11411
11203
  exports.UserActionEvent = UserActionEvent;
11412
11204
  exports.VariableDependencyConfig = VariableDependencyConfig;
11413
11205
  exports.VariableValueControl = VariableValueControl;
11414
- exports.VariableValueSelectWrapper = VariableValueSelectWrapper;
11415
11206
  exports.VariableValueSelectors = VariableValueSelectors;
11416
- exports.VizConfigBuilder = VizConfigBuilder;
11417
- exports.VizConfigBuilders = VizConfigBuilders;
11418
11207
  exports.VizPanel = VizPanel;
11419
11208
  exports.VizPanelBuilder = VizPanelBuilder;
11420
11209
  exports.VizPanelMenu = VizPanelMenu;
@@ -11432,5 +11221,4 @@ exports.sceneGraph = sceneGraph;
11432
11221
  exports.sceneUtils = sceneUtils;
11433
11222
  exports.useSceneApp = useSceneApp;
11434
11223
  exports.useSceneObjectState = useSceneObjectState;
11435
- exports.useUrlSync = useUrlSync;
11436
11224
  //# sourceMappingURL=index.js.map