@splunk/visualizations 26.4.1 → 27.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/Area.config.js +1262 -1600
  2. package/Area.config.js.map +7 -1
  3. package/Area.js +3002 -4930
  4. package/Area.js.map +7 -1
  5. package/Bar.config.js +1247 -1574
  6. package/Bar.config.js.map +7 -1
  7. package/Bar.js +2921 -4843
  8. package/Bar.js.map +7 -1
  9. package/Bubble.config.js +896 -1213
  10. package/Bubble.config.js.map +7 -1
  11. package/Bubble.js +2517 -4483
  12. package/Bubble.js.map +7 -1
  13. package/ChoroplethSvg.config.js +282 -582
  14. package/ChoroplethSvg.config.js.map +7 -1
  15. package/ChoroplethSvg.js +2004 -3810
  16. package/ChoroplethSvg.js.map +7 -1
  17. package/Column.config.js +1208 -1541
  18. package/Column.config.js.map +7 -1
  19. package/Column.js +2930 -4886
  20. package/Column.js.map +7 -1
  21. package/Ellipse.config.js +443 -774
  22. package/Ellipse.config.js.map +7 -1
  23. package/Ellipse.js +1651 -3341
  24. package/Ellipse.js.map +7 -1
  25. package/Events.config.js +207 -492
  26. package/Events.config.js.map +7 -1
  27. package/Events.js +2615 -4649
  28. package/Events.js.map +7 -1
  29. package/FillerGauge.config.js +420 -775
  30. package/FillerGauge.config.js.map +7 -1
  31. package/FillerGauge.js +2137 -4578
  32. package/FillerGauge.js.map +7 -1
  33. package/Image.config.js +144 -411
  34. package/Image.config.js.map +7 -1
  35. package/Image.js +1395 -3048
  36. package/Image.js.map +7 -1
  37. package/Line.config.js +1278 -1625
  38. package/Line.config.js.map +7 -1
  39. package/Line.js +2954 -4926
  40. package/Line.js.map +7 -1
  41. package/LinkGraph.config.js +390 -632
  42. package/LinkGraph.config.js.map +7 -1
  43. package/LinkGraph.js +5243 -6190
  44. package/LinkGraph.js.map +7 -1
  45. package/MIGRATION.md +6 -0
  46. package/Map.config.js +501 -801
  47. package/Map.config.js.map +7 -1
  48. package/Map.js +3369 -5676
  49. package/Map.js.map +7 -1
  50. package/Markdown.config.js +232 -528
  51. package/Markdown.config.js.map +7 -1
  52. package/Markdown.js +1645 -3216
  53. package/Markdown.js.map +7 -1
  54. package/MarkerGauge.config.js +308 -613
  55. package/MarkerGauge.config.js.map +7 -1
  56. package/MarkerGauge.js +2189 -4535
  57. package/MarkerGauge.js.map +7 -1
  58. package/ParallelCoordinates.config.js +282 -581
  59. package/ParallelCoordinates.config.js.map +7 -1
  60. package/ParallelCoordinates.js +2023 -4720
  61. package/ParallelCoordinates.js.map +7 -1
  62. package/Pie.config.js +278 -547
  63. package/Pie.config.js.map +7 -1
  64. package/Pie.js +1996 -3990
  65. package/Pie.js.map +7 -1
  66. package/Punchcard.config.js +291 -578
  67. package/Punchcard.config.js.map +7 -1
  68. package/Punchcard.js +2709 -5042
  69. package/Punchcard.js.map +7 -1
  70. package/Rectangle.config.js +455 -770
  71. package/Rectangle.config.js.map +7 -1
  72. package/Rectangle.js +1638 -3262
  73. package/Rectangle.js.map +7 -1
  74. package/Sankey.config.js +291 -626
  75. package/Sankey.config.js.map +7 -1
  76. package/Sankey.js +2737 -4909
  77. package/Sankey.js.map +7 -1
  78. package/Scatter.config.js +876 -1194
  79. package/Scatter.config.js.map +7 -1
  80. package/Scatter.js +2529 -4477
  81. package/Scatter.js.map +7 -1
  82. package/SingleValue.config.js +819 -1251
  83. package/SingleValue.config.js.map +7 -1
  84. package/SingleValue.js +4203 -7413
  85. package/SingleValue.js.map +7 -1
  86. package/SingleValueBasic.js +382 -1527
  87. package/SingleValueBasic.js.map +7 -1
  88. package/SingleValueIcon.config.js +781 -1207
  89. package/SingleValueIcon.config.js.map +7 -1
  90. package/SingleValueIcon.js +3350 -6285
  91. package/SingleValueIcon.js.map +7 -1
  92. package/SingleValueRadial.config.js +708 -1119
  93. package/SingleValueRadial.config.js.map +7 -1
  94. package/SingleValueRadial.js +3808 -6965
  95. package/SingleValueRadial.js.map +7 -1
  96. package/SparkLine.js +439 -746
  97. package/SparkLine.js.map +7 -1
  98. package/Table.config.js +565 -879
  99. package/Table.config.js.map +7 -1
  100. package/Table.js +3277 -5381
  101. package/Table.js.map +7 -1
  102. package/common/Charting.js +481 -1468
  103. package/common/Charting.js.map +7 -1
  104. package/common/ChartingApi.js +46 -170
  105. package/common/ChartingApi.js.map +7 -1
  106. package/common/DocExampleWithVizSandbox.js +270 -473
  107. package/common/DocExampleWithVizSandbox.js.map +7 -1
  108. package/common/EventsDoc.js +172 -464
  109. package/common/EventsDoc.js.map +7 -1
  110. package/common/GaugeMajorTicks.js +249 -347
  111. package/common/GaugeMajorTicks.js.map +7 -1
  112. package/common/GaugeValueMarker.js +201 -311
  113. package/common/GaugeValueMarker.js.map +7 -1
  114. package/common/OptionsDoc.js +347 -912
  115. package/common/OptionsDoc.js.map +7 -1
  116. package/common/OverviewDoc.js +435 -769
  117. package/common/OverviewDoc.js.map +7 -1
  118. package/common/SplunkVisualization.js +116 -259
  119. package/common/SplunkVisualization.js.map +7 -1
  120. package/common/SplunkVisualizationApi.js +40 -156
  121. package/common/SplunkVisualizationApi.js.map +7 -1
  122. package/common/ThemesDoc.js +271 -420
  123. package/common/ThemesDoc.js.map +7 -1
  124. package/common/chartingUtils.js +140 -312
  125. package/common/chartingUtils.js.map +7 -1
  126. package/common/docUtils.js +148 -266
  127. package/common/docUtils.js.map +7 -1
  128. package/common/gaugeUtils.js +280 -808
  129. package/common/gaugeUtils.js.map +7 -1
  130. package/common/shapeUtils.js +106 -211
  131. package/common/shapeUtils.js.map +7 -1
  132. package/common/utils/configUtils.js +126 -252
  133. package/common/utils/configUtils.js.map +7 -1
  134. package/common/utils/dataUtils.js +217 -812
  135. package/common/utils/dataUtils.js.map +7 -1
  136. package/common/utils/featureFlagUtils.js +53 -133
  137. package/common/utils/featureFlagUtils.js.map +7 -1
  138. package/common/utils/hocUtils.js +32 -122
  139. package/common/utils/hocUtils.js.map +7 -1
  140. package/common/utils/mapUtils.js +502 -1337
  141. package/common/utils/mapUtils.js.map +7 -1
  142. package/common/utils/singleValueUtils.js +462 -1010
  143. package/common/utils/singleValueUtils.js.map +7 -1
  144. package/common/utils/testHelper.js +92 -146
  145. package/common/utils/testHelper.js.map +7 -1
  146. package/common/utils/trellisUtils.js +237 -489
  147. package/common/utils/trellisUtils.js.map +7 -1
  148. package/common/utils/urlUtils.js +28 -112
  149. package/common/utils/urlUtils.js.map +7 -1
  150. package/common/withDashboardViz.js +1168 -2438
  151. package/common/withDashboardViz.js.map +7 -1
  152. package/package.json +52 -43
package/Image.js CHANGED
@@ -1,3211 +1,1558 @@
1
- /*!
2
- * Copyright © 2024 Splunk Inc.
3
- * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
4
- * in part without a valid written license from Splunk Inc. is PROHIBITED.
5
- */
6
- module.exports =
7
- /******/ (function(modules) { // webpackBootstrap
8
- /******/ // The module cache
9
- /******/ var installedModules = {};
10
- /******/
11
- /******/ // The require function
12
- /******/ function __webpack_require__(moduleId) {
13
- /******/
14
- /******/ // Check if module is in cache
15
- /******/ if(installedModules[moduleId]) {
16
- /******/ return installedModules[moduleId].exports;
17
- /******/ }
18
- /******/ // Create a new module (and put it into the cache)
19
- /******/ var module = installedModules[moduleId] = {
20
- /******/ i: moduleId,
21
- /******/ l: false,
22
- /******/ exports: {}
23
- /******/ };
24
- /******/
25
- /******/ // Execute the module function
26
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
27
- /******/
28
- /******/ // Flag the module as loaded
29
- /******/ module.l = true;
30
- /******/
31
- /******/ // Return the exports of the module
32
- /******/ return module.exports;
33
- /******/ }
34
- /******/
35
- /******/
36
- /******/ // expose the modules object (__webpack_modules__)
37
- /******/ __webpack_require__.m = modules;
38
- /******/
39
- /******/ // expose the module cache
40
- /******/ __webpack_require__.c = installedModules;
41
- /******/
42
- /******/ // define getter function for harmony exports
43
- /******/ __webpack_require__.d = function(exports, name, getter) {
44
- /******/ if(!__webpack_require__.o(exports, name)) {
45
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
46
- /******/ }
47
- /******/ };
48
- /******/
49
- /******/ // define __esModule on exports
50
- /******/ __webpack_require__.r = function(exports) {
51
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
52
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
53
- /******/ }
54
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
55
- /******/ };
56
- /******/
57
- /******/ // create a fake namespace object
58
- /******/ // mode & 1: value is a module id, require it
59
- /******/ // mode & 2: merge all properties of value into the ns
60
- /******/ // mode & 4: return value when already ns object
61
- /******/ // mode & 8|1: behave like require
62
- /******/ __webpack_require__.t = function(value, mode) {
63
- /******/ if(mode & 1) value = __webpack_require__(value);
64
- /******/ if(mode & 8) return value;
65
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
66
- /******/ var ns = Object.create(null);
67
- /******/ __webpack_require__.r(ns);
68
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
69
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
70
- /******/ return ns;
71
- /******/ };
72
- /******/
73
- /******/ // getDefaultExport function for compatibility with non-harmony modules
74
- /******/ __webpack_require__.n = function(module) {
75
- /******/ var getter = module && module.__esModule ?
76
- /******/ function getDefault() { return module['default']; } :
77
- /******/ function getModuleExports() { return module; };
78
- /******/ __webpack_require__.d(getter, 'a', getter);
79
- /******/ return getter;
80
- /******/ };
81
- /******/
82
- /******/ // Object.prototype.hasOwnProperty.call
83
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
84
- /******/
85
- /******/ // __webpack_public_path__
86
- /******/ __webpack_require__.p = "";
87
- /******/
88
- /******/
89
- /******/ // Load entry module and return exports
90
- /******/ return __webpack_require__(__webpack_require__.s = 237);
91
- /******/ })
92
- /************************************************************************/
93
- /******/ ([
94
- /* 0 */
95
- /***/ (function(module, exports) {
96
-
97
- module.exports = require("prop-types");
98
-
99
- /***/ }),
100
- /* 1 */
101
- /***/ (function(module, exports) {
102
-
103
- module.exports = require("react");
104
-
105
- /***/ }),
106
- /* 2 */
107
- /***/ (function(module, exports) {
108
-
109
- module.exports = require("lodash");
110
-
111
- /***/ }),
112
- /* 3 */
113
- /***/ (function(module, exports) {
114
-
115
- module.exports = require("@splunk/ui-utils/i18n");
116
-
117
- /***/ }),
118
- /* 4 */
119
- /***/ (function(module, exports) {
120
-
121
- module.exports = require("styled-components");
122
-
123
- /***/ }),
124
- /* 5 */
125
- /***/ (function(module, exports) {
126
-
127
- module.exports = require("@babel/runtime/helpers/slicedToArray");
128
-
129
- /***/ }),
130
- /* 6 */
131
- /***/ (function(module, exports) {
132
-
133
- module.exports = require("@babel/runtime/helpers/toConsumableArray");
134
-
135
- /***/ }),
136
- /* 7 */
137
- /***/ (function(module, exports, __webpack_require__) {
138
-
139
- "use strict";
140
-
1
+ /* Copyright © 2020 Splunk Inc.
2
+ SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
3
+ in part without a valid written license from Splunk Inc. is PROHIBITED. */
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __defProps = Object.defineProperties;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11
+ var __getProtoOf = Object.getPrototypeOf;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ var __objRest = (source, exclude) => {
28
+ var target = {};
29
+ for (var prop in source)
30
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
31
+ target[prop] = source[prop];
32
+ if (source != null && __getOwnPropSymbols)
33
+ for (var prop of __getOwnPropSymbols(source)) {
34
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
35
+ target[prop] = source[prop];
36
+ }
37
+ return target;
38
+ };
39
+ var __export = (target, all) => {
40
+ for (var name in all)
41
+ __defProp(target, name, { get: all[name], enumerable: true });
42
+ };
43
+ var __copyProps = (to, from, except, desc) => {
44
+ if (from && typeof from === "object" || typeof from === "function") {
45
+ for (let key of __getOwnPropNames(from))
46
+ if (!__hasOwnProp.call(to, key) && key !== except)
47
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
48
+ }
49
+ return to;
50
+ };
51
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
52
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
53
+ // If the importer is in node compatibility mode or this is not an ESM
54
+ // file that has been converted to a CommonJS file using a Babel-
55
+ // compatible transform (i.e. "__esModule" has not been set), then set
56
+ // "default" to the CommonJS "module.exports" for node compatibility.
57
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
58
+ mod
59
+ ));
60
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
61
+
62
+ // src/Image/index.ts
63
+ var Image_exports = {};
64
+ __export(Image_exports, {
65
+ config: () => config_default,
66
+ default: () => Image_default,
67
+ shouldShowPlaceholder: () => shouldShowPlaceholder,
68
+ themes: () => themes2,
69
+ toImageDimensions: () => toImageDimensions
70
+ });
71
+ module.exports = __toCommonJS(Image_exports);
141
72
 
142
- Object.defineProperty(exports, "__esModule", {
143
- value: true
73
+ // esm-externals:lodash
74
+ var lodash_exports = {};
75
+ __export(lodash_exports, {
76
+ default: () => lodash_default
77
+ });
78
+ var defaultImport = __toESM(require("lodash"));
79
+ __reExport(lodash_exports, require("lodash"));
80
+ var lodash_default = "default" in defaultImport ? defaultImport.default : defaultImport;
81
+
82
+ // esm-externals:react
83
+ var react_exports = {};
84
+ __export(react_exports, {
85
+ default: () => react_default
86
+ });
87
+ var defaultImport2 = __toESM(require("react"));
88
+ __reExport(react_exports, require("react"));
89
+ var react_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
90
+
91
+ // esm-externals:@splunk/ui-utils/i18n
92
+ var i18n_exports = {};
93
+ __export(i18n_exports, {
94
+ default: () => i18n_default
95
+ });
96
+ var defaultImport3 = __toESM(require("@splunk/ui-utils/i18n"));
97
+ __reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
98
+ var i18n_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
99
+
100
+ // esm-externals:@splunk/visualizations-shared/style
101
+ var style_exports = {};
102
+ __export(style_exports, {
103
+ default: () => style_default
104
+ });
105
+ var defaultImport4 = __toESM(require("@splunk/visualizations-shared/style"));
106
+ __reExport(style_exports, require("@splunk/visualizations-shared/style"));
107
+ var style_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
108
+
109
+ // esm-externals:@splunk/visualizations-shared/RemoteImage
110
+ var RemoteImage_exports = {};
111
+ __export(RemoteImage_exports, {
112
+ default: () => RemoteImage_default
113
+ });
114
+ var defaultImport5 = __toESM(require("@splunk/visualizations-shared/RemoteImage"));
115
+ __reExport(RemoteImage_exports, require("@splunk/visualizations-shared/RemoteImage"));
116
+ var RemoteImage_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
117
+
118
+ // esm-externals:styled-components
119
+ var styled_components_exports = {};
120
+ __export(styled_components_exports, {
121
+ default: () => styled_components_default
122
+ });
123
+ var defaultImport6 = __toESM(require("styled-components"));
124
+ __reExport(styled_components_exports, require("styled-components"));
125
+ var styled_components_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;
126
+
127
+ // esm-externals:prop-types
128
+ var prop_types_exports = {};
129
+ __export(prop_types_exports, {
130
+ default: () => prop_types_default
131
+ });
132
+ var defaultImport7 = __toESM(require("prop-types"));
133
+ __reExport(prop_types_exports, require("prop-types"));
134
+ var prop_types_default = "default" in defaultImport7 ? defaultImport7.default : defaultImport7;
135
+
136
+ // esm-externals:@splunk/visualization-schemas
137
+ var visualization_schemas_exports = {};
138
+ __export(visualization_schemas_exports, {
139
+ default: () => visualization_schemas_default
144
140
  });
145
- exports.VizBehavior = void 0;
146
- var VizBehavior;
141
+ var defaultImport8 = __toESM(require("@splunk/visualization-schemas"));
142
+ __reExport(visualization_schemas_exports, require("@splunk/visualization-schemas"));
143
+ var visualization_schemas_default = "default" in defaultImport8 ? defaultImport8.default : defaultImport8;
144
+
145
+ // esm-externals:@splunk/visualization-icons
146
+ var visualization_icons_exports = {};
147
+ __export(visualization_icons_exports, {
148
+ default: () => visualization_icons_default
149
+ });
150
+ var defaultImport9 = __toESM(require("@splunk/visualization-icons"));
151
+ __reExport(visualization_icons_exports, require("@splunk/visualization-icons"));
152
+ var visualization_icons_default = "default" in defaultImport9 ? defaultImport9.default : defaultImport9;
153
+
154
+ // esm-externals:@splunk/visualizations-shared/configUtils
155
+ var configUtils_exports = {};
156
+ __export(configUtils_exports, {
157
+ default: () => configUtils_default
158
+ });
159
+ var defaultImport10 = __toESM(require("@splunk/visualizations-shared/configUtils"));
160
+ __reExport(configUtils_exports, require("@splunk/visualizations-shared/configUtils"));
161
+ var configUtils_default = "default" in defaultImport10 ? defaultImport10.default : defaultImport10;
162
+
163
+ // src/common/utils/configUtils.ts
164
+ function enhanceConfig(vizConfig) {
165
+ const enhancedConfig = __spreadValues({}, vizConfig);
166
+ enhancedConfig.editorConfig = vizConfig.editorConfig.map(
167
+ (config2) => {
168
+ return __spreadProps(__spreadValues({}, config2), { open: config2.open || false });
169
+ }
170
+ );
171
+ return enhancedConfig;
172
+ }
147
173
 
148
- (function (VizBehavior) {
174
+ // src/Image/config.ts
175
+ var dataContract = {
176
+ requiredDataSources: [],
177
+ optionalDataSources: [
178
+ // Note: SCP-14090 disable ui for optional datasources. We may need to add it back later
179
+ // {
180
+ // name: 'annotation',
181
+ // description: 'DataSource that populate event annotations',
182
+ // },
183
+ ],
184
+ initialRequestParams: {}
185
+ };
186
+ var size = {
187
+ initialWidth: 300,
188
+ initialHeight: 300
189
+ };
190
+ var defaultContext = {};
191
+ var editorConfig = [
192
+ {
193
+ label: (0, i18n_exports._)("Image content"),
194
+ layout: [
195
+ [
196
+ {
197
+ label: (0, i18n_exports._)("Image file"),
198
+ option: "src",
199
+ editor: "editor.image"
200
+ }
201
+ ],
202
+ [
203
+ {
204
+ label: (0, i18n_exports._)("Preserve aspect ratio"),
205
+ option: "preserveAspectRatio",
206
+ editor: "editor.checkbox",
207
+ showEditor: ({ options }) => !!options.src
208
+ }
209
+ ]
210
+ ]
211
+ }
212
+ ];
213
+ var themes = {};
214
+ var config = {
149
215
  /**
150
- * Dynamic Options Behavior.
151
- * This allows visualization options to be powered by data
152
- *
153
- * **Example**
154
- *
155
- * sparklineValues: ">primary|seriesByIndex(0)"
156
- * would configure sparklineValues with an array of data points
157
- * coming from the first series in the primary datasource
158
- *
216
+ * unique viz key
159
217
  */
160
- VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
161
- VizBehavior["EVENTS"] = "events";
162
- VizBehavior["DOWNSAMPLING"] = "downsampling";
218
+ key: "splunk.image",
163
219
  /**
164
- * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
165
- * missing.
166
- * @type {string}
220
+ * viz name
167
221
  */
222
+ name: (0, i18n_exports._)("Image"),
223
+ category: "misc" /* MISC */,
224
+ /**
225
+ * viz icon
226
+ */
227
+ icon: visualization_icons_exports.Image,
228
+ dataContract,
229
+ size,
230
+ defaultContext,
231
+ optionsSchema: visualization_schemas_exports.imageOptionsSchema,
232
+ editorConfig,
233
+ supports: ["dynamic-options" /* DYNAMIC_OPTIONS */, "placeholder" /* PLACEHOLDER */, "events" /* EVENTS */],
234
+ themes,
235
+ events: {
236
+ "image.click": {
237
+ description: "triggered when user clicks on the image"
238
+ }
239
+ }
240
+ };
241
+ var config_default = enhanceConfig(config);
168
242
 
169
- VizBehavior["PLACEHOLDER"] = "placeholder";
170
- VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
171
- VizBehavior["TRELLIS"] = "trellis";
172
- })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
173
-
174
- /***/ }),
175
- /* 8 */
176
- /***/ (function(module, exports) {
177
-
178
- module.exports = require("@babel/runtime/helpers/classCallCheck");
179
-
180
- /***/ }),
181
- /* 9 */
182
- /***/ (function(module, exports) {
183
-
184
- module.exports = require("@splunk/visualization-schemas");
185
-
186
- /***/ }),
187
- /* 10 */
188
- /***/ (function(module, exports) {
189
-
190
- module.exports = require("@splunk/visualizations-shared/numberUtils");
191
-
192
- /***/ }),
193
- /* 11 */
194
- /***/ (function(module, exports) {
195
-
196
- module.exports = require("@splunk/visualizations-shared/Message");
197
-
198
- /***/ }),
199
- /* 12 */
200
- /***/ (function(module, exports) {
201
-
202
- module.exports = require("@babel/runtime/helpers/defineProperty");
203
-
204
- /***/ }),
205
- /* 13 */
206
- /***/ (function(module, exports) {
207
-
208
- module.exports = require("@splunk/themes/variables");
209
-
210
- /***/ }),
211
- /* 14 */
212
- /***/ (function(module, exports, __webpack_require__) {
213
-
214
- "use strict";
215
-
216
-
217
- Object.defineProperty(exports, "__esModule", {
218
- value: true
243
+ // esm-externals:@splunk/themes/getSettingsFromThemedProps
244
+ var getSettingsFromThemedProps_exports = {};
245
+ __export(getSettingsFromThemedProps_exports, {
246
+ default: () => getSettingsFromThemedProps_default
219
247
  });
220
- exports.downsampleDataSources = exports.calculateDownsamplingThreshold = exports.calculateThresholdOnRangeSelect = exports.isDownsamplingEnabledForViz = exports.convertToArrOfObjects = void 0;
221
-
222
- var numberUtils_1 = __webpack_require__(10);
223
-
224
- var interfaces_1 = __webpack_require__(39); // TODO: utilize this fn in ParallelCoordinates
248
+ var defaultImport11 = __toESM(require("@splunk/themes/getSettingsFromThemedProps"));
249
+ __reExport(getSettingsFromThemedProps_exports, require("@splunk/themes/getSettingsFromThemedProps"));
250
+ var getSettingsFromThemedProps_default = "default" in defaultImport11 ? defaultImport11.default : defaultImport11;
251
+
252
+ // esm-externals:@splunk/visualization-encoding/Options
253
+ var Options_exports = {};
254
+ __export(Options_exports, {
255
+ default: () => Options_default
256
+ });
257
+ var defaultImport12 = __toESM(require("@splunk/visualization-encoding/Options"));
258
+ __reExport(Options_exports, require("@splunk/visualization-encoding/Options"));
259
+ var Options_default = "default" in defaultImport12 ? defaultImport12.default : defaultImport12;
260
+
261
+ // esm-externals:@splunk/visualizations-shared/SanitizeProps
262
+ var SanitizeProps_exports = {};
263
+ __export(SanitizeProps_exports, {
264
+ default: () => SanitizeProps_default
265
+ });
266
+ var defaultImport13 = __toESM(require("@splunk/visualizations-shared/SanitizeProps"));
267
+ __reExport(SanitizeProps_exports, require("@splunk/visualizations-shared/SanitizeProps"));
268
+ var SanitizeProps_default = "default" in defaultImport13 ? defaultImport13.default : defaultImport13;
269
+
270
+ // esm-externals:@splunk/visualization-context/TimezoneContext
271
+ var TimezoneContext_exports = {};
272
+ __export(TimezoneContext_exports, {
273
+ default: () => TimezoneContext_default
274
+ });
275
+ var defaultImport14 = __toESM(require("@splunk/visualization-context/TimezoneContext"));
276
+ __reExport(TimezoneContext_exports, require("@splunk/visualization-context/TimezoneContext"));
277
+ var TimezoneContext_default = "default" in defaultImport14 ? defaultImport14.default : defaultImport14;
278
+
279
+ // esm-externals:@splunk/moment
280
+ var moment_exports = {};
281
+ __export(moment_exports, {
282
+ default: () => moment_default
283
+ });
284
+ var defaultImport15 = __toESM(require("@splunk/moment"));
285
+ __reExport(moment_exports, require("@splunk/moment"));
286
+ var moment_default = "default" in defaultImport15 ? defaultImport15.default : defaultImport15;
287
+
288
+ // esm-externals:@splunk/visualization-context/FeatureFlagContext
289
+ var FeatureFlagContext_exports = {};
290
+ __export(FeatureFlagContext_exports, {
291
+ default: () => FeatureFlagContext_default
292
+ });
293
+ var defaultImport16 = __toESM(require("@splunk/visualization-context/FeatureFlagContext"));
294
+ __reExport(FeatureFlagContext_exports, require("@splunk/visualization-context/FeatureFlagContext"));
295
+ var FeatureFlagContext_default = "default" in defaultImport16 ? defaultImport16.default : defaultImport16;
296
+
297
+ // esm-externals:@splunk/visualizations-shared/hocUtils
298
+ var hocUtils_exports = {};
299
+ __export(hocUtils_exports, {
300
+ default: () => hocUtils_default
301
+ });
302
+ var defaultImport17 = __toESM(require("@splunk/visualizations-shared/hocUtils"));
303
+ __reExport(hocUtils_exports, require("@splunk/visualizations-shared/hocUtils"));
304
+ var hocUtils_default = "default" in defaultImport17 ? defaultImport17.default : defaultImport17;
305
+
306
+ // esm-externals:@splunk/visualizations-shared/JSONSchemaUtils
307
+ var JSONSchemaUtils_exports = {};
308
+ __export(JSONSchemaUtils_exports, {
309
+ default: () => JSONSchemaUtils_default
310
+ });
311
+ var defaultImport18 = __toESM(require("@splunk/visualizations-shared/JSONSchemaUtils"));
312
+ __reExport(JSONSchemaUtils_exports, require("@splunk/visualizations-shared/JSONSchemaUtils"));
313
+ var JSONSchemaUtils_default = "default" in defaultImport18 ? defaultImport18.default : defaultImport18;
314
+
315
+ // esm-externals:@splunk/async-dynamic-options-evaluator
316
+ var async_dynamic_options_evaluator_exports = {};
317
+ __export(async_dynamic_options_evaluator_exports, {
318
+ default: () => async_dynamic_options_evaluator_default
319
+ });
320
+ var defaultImport19 = __toESM(require("@splunk/async-dynamic-options-evaluator"));
321
+ __reExport(async_dynamic_options_evaluator_exports, require("@splunk/async-dynamic-options-evaluator"));
322
+ var async_dynamic_options_evaluator_default = "default" in defaultImport19 ? defaultImport19.default : defaultImport19;
323
+
324
+ // esm-externals:@splunk/ui-utils/id
325
+ var id_exports = {};
326
+ __export(id_exports, {
327
+ default: () => id_default
328
+ });
329
+ var defaultImport20 = __toESM(require("@splunk/ui-utils/id"));
330
+ __reExport(id_exports, require("@splunk/ui-utils/id"));
331
+ var id_default = "default" in defaultImport20 ? defaultImport20.default : defaultImport20;
225
332
 
333
+ // src/common/interfaces/VizActionHandler.ts
334
+ var DefaultVizActionHandler = class {
335
+ focus() {
336
+ }
337
+ snapshot() {
338
+ return null;
339
+ }
340
+ };
226
341
 
227
- var convertToArrOfObjects = function convertToArrOfObjects(columns, fields) {
228
- if (!columns || !columns[0] || !columns[0].length) return [];
229
- var data = [];
342
+ // src/common/SplunkVisualization.tsx
343
+ var INITIAL_HEIGHT = 250;
344
+ var SplunkVisualization = class {
345
+ };
346
+ SplunkVisualization.propTypes = {
347
+ /**
348
+ * display mode
349
+ */
350
+ mode: prop_types_exports.oneOf(["view", "edit", "export"]).isRequired,
351
+ /**
352
+ * width in pixel or string, defaults to 100%
353
+ */
354
+ width: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]).isRequired,
355
+ /**
356
+ * height in pixel or string
357
+ */
358
+ height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]).isRequired,
359
+ /**
360
+ * visualization context used for dynamic option evaluation
361
+ */
362
+ context: prop_types_exports.object,
363
+ /**
364
+ * visualization formatting options
365
+ */
366
+ options: prop_types_exports.object,
367
+ /**
368
+ * A callback to update formatting options
369
+ */
370
+ onOptionsChange: prop_types_exports.func,
371
+ /**
372
+ * datasource state which include data and request params, object key indicate the datasource type.
373
+ */
374
+ dataSources: prop_types_exports.objectOf(
375
+ prop_types_exports.shape({
376
+ /**
377
+ * current request params
378
+ */
379
+ requestParams: prop_types_exports.object,
380
+ /**
381
+ * current dataset
382
+ */
383
+ data: prop_types_exports.shape({
384
+ fields: prop_types_exports.array,
385
+ columns: prop_types_exports.array
386
+ }),
387
+ /**
388
+ * error
389
+ */
390
+ error: prop_types_exports.shape({
391
+ level: prop_types_exports.string,
392
+ message: prop_types_exports.string
393
+ }),
394
+ /**
395
+ * meta data that came with the dataset
396
+ */
397
+ meta: prop_types_exports.object
398
+ })
399
+ ),
400
+ /**
401
+ * A callback to trigger event
402
+ */
403
+ onEventTrigger: prop_types_exports.func,
404
+ /**
405
+ * Inform viz if there are handlers listening to events
406
+ */
407
+ hasEventHandlers: prop_types_exports.bool,
408
+ /**
409
+ * A callback to communicate computed props to a consumer
410
+ */
411
+ onComputedProps: prop_types_exports.func,
412
+ /**
413
+ * A callback to obtain visualization api
414
+ */
415
+ vizActionHandlerRef: prop_types_exports.func,
416
+ loading: prop_types_exports.bool,
417
+ theme: prop_types_exports.object,
418
+ /**
419
+ * A callback to request new data with updated request params
420
+ */
421
+ onRequestParamsChange: prop_types_exports.func
422
+ };
423
+ /**
424
+ *
425
+ */
426
+ SplunkVisualization.defaultProps = {
427
+ // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
428
+ width: "100%",
429
+ height: INITIAL_HEIGHT,
430
+ dataSources: {},
431
+ onEventTrigger: () => ({}),
432
+ mode: "view",
433
+ hasEventHandlers: false,
434
+ options: {},
435
+ context: {},
436
+ onOptionsChange: () => ({}),
437
+ vizActionHandlerRef: () => new DefaultVizActionHandler(),
438
+ onComputedProps: () => ({}),
439
+ loading: false,
440
+ onRequestParamsChange: lodash_exports.noop
441
+ };
442
+ var SplunkVisualization_default = SplunkVisualization;
230
443
 
231
- var _loop = function _loop(i) {
232
- var newObj = {};
233
- fields.forEach(function (field, index) {
234
- var fieldName = typeof field === 'string' ? field : field.name;
444
+ // src/common/interfaces/DataSource.ts
445
+ var validSortDirs = ["asc", "desc", "none"];
235
446
 
236
- if (columns[index][i] === '') {
237
- newObj[fieldName] = null;
447
+ // src/common/hooks/getSorting.ts
448
+ var SortParamsPropTypes = prop_types_exports.shape({
449
+ currentSortKey: prop_types_exports.string,
450
+ currentSortDir: prop_types_exports.oneOf(validSortDirs),
451
+ onSort: prop_types_exports.func
452
+ });
453
+ var getSortingParams = ({ requestParams, onRequestParamsChange }) => {
454
+ let currentSortKey;
455
+ let currentSortDir;
456
+ const nextSortDirMap = {
457
+ asc: "desc",
458
+ desc: "asc",
459
+ none: "asc"
460
+ };
461
+ let onSort;
462
+ if (typeof onRequestParamsChange === "function") {
463
+ if (requestParams && (0, lodash_exports.has)(requestParams, "sort")) {
464
+ currentSortKey = Object.keys(requestParams.sort).shift();
465
+ currentSortDir = requestParams.sort[currentSortKey];
466
+ }
467
+ onSort = (e, { sortKey, sortDir }) => {
468
+ if (typeof sortKey === "string") {
469
+ const nextSortDir = (0, lodash_exports.has)(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : "none";
470
+ onRequestParamsChange(__spreadValues(__spreadValues({}, requestParams), { offset: 0, sort: { [sortKey]: nextSortDir } }));
238
471
  } else {
239
- newObj[fieldName] = columns[index][i];
472
+ onRequestParamsChange(requestParams);
240
473
  }
241
- });
242
- data.push(newObj);
474
+ };
475
+ }
476
+ return {
477
+ currentSortKey,
478
+ currentSortDir,
479
+ onSort
480
+ };
481
+ };
482
+
483
+ // src/common/hooks/getPagination.ts
484
+ var PaginatorParamsPropTypes = prop_types_exports.shape({
485
+ isPaging: prop_types_exports.bool,
486
+ current: prop_types_exports.number,
487
+ totalPages: prop_types_exports.number,
488
+ onChange: prop_types_exports.func
489
+ });
490
+ var getPaginationParams = ({
491
+ requestParams,
492
+ meta,
493
+ onRequestParamsChange
494
+ }) => {
495
+ const totalCount = meta && meta.totalCount || 0;
496
+ const offset = requestParams && requestParams.offset || 0;
497
+ const count = requestParams && requestParams.count;
498
+ const totalPages = typeof count === "number" && count > 0 ? Math.ceil(totalCount / count) : 0;
499
+ const current = typeof count === "number" && count > 0 ? Math.floor(offset / count) + 1 : 0;
500
+ const isPaging = totalPages > 1 && typeof onRequestParamsChange === "function";
501
+ const onChangeHandler = (e, { page, count: countArg }) => {
502
+ const newParams = (0, lodash_exports.cloneDeep)(requestParams);
503
+ if (typeof countArg === "number") {
504
+ newParams.count = countArg;
505
+ newParams.offset = 0;
506
+ }
507
+ const pageCount = typeof newParams.count === "number" ? newParams.count : 10;
508
+ if (typeof page === "number" && page > 0) {
509
+ newParams.count = pageCount;
510
+ newParams.offset = (page - 1) * pageCount;
511
+ }
512
+ onRequestParamsChange(newParams);
513
+ };
514
+ return {
515
+ isPaging,
516
+ current,
517
+ totalPages,
518
+ onChange: typeof onRequestParamsChange === "function" ? onChangeHandler : lodash_exports.noop
243
519
  };
520
+ };
244
521
 
245
- for (var i = 0; i < columns[0].length; i += 1) {
246
- _loop(i);
522
+ // src/common/hooks/useDeepMemo.ts
523
+ var useDeepMemo = (fn, dependencies) => {
524
+ const ref = (0, react_exports.useRef)();
525
+ if (!ref.current || !(0, lodash_exports.isEqual)(dependencies, ref.current.dependencies)) {
526
+ ref.current = {
527
+ dependencies,
528
+ value: fn()
529
+ };
247
530
  }
531
+ return ref.current.value;
532
+ };
248
533
 
249
- return data;
534
+ // esm-externals:@splunk/visualizations-shared/Message
535
+ var Message_exports = {};
536
+ __export(Message_exports, {
537
+ default: () => Message_default
538
+ });
539
+ var defaultImport21 = __toESM(require("@splunk/visualizations-shared/Message"));
540
+ __reExport(Message_exports, require("@splunk/visualizations-shared/Message"));
541
+ var Message_default = "default" in defaultImport21 ? defaultImport21.default : defaultImport21;
542
+
543
+ // esm-externals:@splunk/visualizations-shared/colorUtils
544
+ var colorUtils_exports = {};
545
+ __export(colorUtils_exports, {
546
+ default: () => colorUtils_default
547
+ });
548
+ var defaultImport22 = __toESM(require("@splunk/visualizations-shared/colorUtils"));
549
+ __reExport(colorUtils_exports, require("@splunk/visualizations-shared/colorUtils"));
550
+ var colorUtils_default = "default" in defaultImport22 ? defaultImport22.default : defaultImport22;
551
+
552
+ // esm-externals:@splunk/visualizations-shared/SizeAwareWrapper
553
+ var SizeAwareWrapper_exports = {};
554
+ __export(SizeAwareWrapper_exports, {
555
+ default: () => SizeAwareWrapper_default
556
+ });
557
+ var defaultImport23 = __toESM(require("@splunk/visualizations-shared/SizeAwareWrapper"));
558
+ __reExport(SizeAwareWrapper_exports, require("@splunk/visualizations-shared/SizeAwareWrapper"));
559
+ var SizeAwareWrapper_default = "default" in defaultImport23 ? defaultImport23.default : defaultImport23;
560
+
561
+ // src/common/hocs/FixedSizeContainer.tsx
562
+ var Item = styled_components_default.div.attrs(({ width }) => ({
563
+ style: {
564
+ width: (0, style_exports.toPx)(width)
565
+ }
566
+ }))`
567
+ position: relative;
568
+ background-color: ${(props) => (0, colorUtils_exports.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor}};
569
+ `;
570
+ var FixSizeItem = styled_components_default.div.attrs(({ width, height }) => ({
571
+ style: __spreadValues(__spreadValues({}, width && { width: (0, style_exports.toPx)(width) }), height && { height: (0, style_exports.toPx)(height) })
572
+ }))`
573
+ position: relative;
574
+ flex-direction: column;
575
+ flex: 1;
576
+ display: flex;
577
+ background-color: ${(props) => (0, colorUtils_exports.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor}};
578
+ `;
579
+ var ItemContent = styled_components_default.div`
580
+ position: relative;
581
+ min-height: 100px;
582
+ width: 100%;
583
+ `;
584
+ var FixSizeItemContent = styled_components_default.div`
585
+ min-height: 0px;
586
+ flex: 1;
587
+ position: relative;
588
+ box-sizing: border-box;
589
+ `;
590
+ var withFixedSizeContainer = (Viz) => {
591
+ const FixedSizeContainer = (props) => {
592
+ const { width, height, backgroundColor } = props;
593
+ const cachedHandleResize = react_exports.useCallback((w, h) => {
594
+ setContainerWidth(w);
595
+ setContainerHeight(h);
596
+ }, []);
597
+ const [containerWidth, setContainerWidth] = react_exports.useState(Number(props.width));
598
+ const [containerHeight, setContainerHeight] = react_exports.useState(Number(props.height));
599
+ if (!height) {
600
+ return /* @__PURE__ */ react_exports.createElement(Item, { "data-test": "item", width, backgroundColor }, /* @__PURE__ */ react_exports.createElement(ItemContent, null, /* @__PURE__ */ react_exports.createElement(Viz, __spreadValues({}, props))));
601
+ }
602
+ return /* @__PURE__ */ react_exports.createElement(
603
+ FixSizeItem,
604
+ {
605
+ "data-test": "fix-size-item",
606
+ "data-splunk-visualization-version": "27.0.0 - 9bf093b7d",
607
+ width,
608
+ height,
609
+ backgroundColor
610
+ },
611
+ /* @__PURE__ */ react_exports.createElement(FixSizeItemContent, null, /* @__PURE__ */ react_exports.createElement(SizeAwareWrapper_default, { width, height, onResize: cachedHandleResize }), /* @__PURE__ */ react_exports.createElement(Viz, __spreadProps(__spreadValues({}, props), { width: containerWidth, height: containerHeight })))
612
+ );
613
+ };
614
+ FixedSizeContainer.displayName = "withFixedSizeContainer";
615
+ return FixedSizeContainer;
250
616
  };
617
+ var FixedSizeContainer_default = withFixedSizeContainer;
251
618
 
252
- exports.convertToArrOfObjects = convertToArrOfObjects; // LTTB algorithm which can be used to downsample time series data while striving to maintain
253
- // the spikes and overall shape of the chart
254
- // Copied from https://github.com/sveinn-steinarsson/flot-downsample/blob/0815010016fc94b1bbc6a010afb8aad13ada6d0d/jquery.flot.downsample.js
255
- // Modifications include:
256
- // 1) Convert to modern JavaScript(use const, let, and use array.push to push to last element of array)
257
- // 2) Convert to camel case
258
- // 3) Convert to TS and also return the indices of the points that are in the downsampled result.
259
- // 4) Add a new parameter preferredDownsampleIndices that correspond to the indices of points
260
- // that should be used in case of a tie of the max area in a bucket
619
+ // src/common/components/MissingPropsMessage.tsx
620
+ var isMissing = (v) => {
621
+ return v === null || v === void 0;
622
+ };
623
+ var missingKeys = (keys, target) => keys.filter((k) => isMissing(target[k]));
624
+ var propTypes = {
625
+ width: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
626
+ height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
627
+ // eslint-disable-next-line react/no-unused-prop-types
628
+ backgroundColor: prop_types_exports.string,
629
+ missingProps: prop_types_exports.arrayOf(prop_types_exports.string)
630
+ };
631
+ var MissingPropsMessage = (props) => {
632
+ const { width, height, missingProps } = props;
633
+ return /* @__PURE__ */ react_exports.createElement(
634
+ Message_default,
635
+ {
636
+ "data-test": "message",
637
+ width,
638
+ height,
639
+ message: (0, i18n_exports._)(`Missing property: ${missingProps.join(", ")}`)
640
+ }
641
+ );
642
+ };
643
+ MissingPropsMessage.propTypes = propTypes;
644
+ MissingPropsMessage.defaultProps = {
645
+ width: "100%",
646
+ height: 250
647
+ };
648
+ var MissingPropsMessage_default = FixedSizeContainer_default(MissingPropsMessage);
649
+
650
+ // src/common/utils/hocUtils.ts
651
+ var extendStaticWrapperProps = ({
652
+ Wrapper,
653
+ Visualization
654
+ }) => {
655
+ const extendProperties = ["propTypes", "defaultProps", "config"];
656
+ extendProperties.forEach((prop) => {
657
+ if (Visualization[prop]) {
658
+ Wrapper[prop] = Visualization[prop];
659
+ }
660
+ });
661
+ };
261
662
 
262
- var largestTriangleThreeBuckets = function largestTriangleThreeBuckets(data, threshold, preferredDownsampleIndices) {
263
- var dataLength = data.length;
264
- var downsampledIndices = [];
663
+ // src/common/hocs/withEditModeCover.tsx
664
+ var Cover = styled_components_default.div`
665
+ position: absolute;
666
+ left: 0;
667
+ right: 0;
668
+ top: 0;
669
+ bottom: 0;
670
+ `;
671
+ var Blocker = styled_components_default.div.attrs({
672
+ "data-splunk-visualization-version": "27.0.0 - 9bf093b7d"
673
+ })`
674
+ position: relative;
675
+ width: 100%;
676
+ height: 100%;
677
+ `;
678
+ var withEditModeCover = (Visualization, disableEditModeCover) => {
679
+ const Wrapper = (props) => {
680
+ const { mode } = props;
681
+ const showEditCover = mode === "edit" && !disableEditModeCover;
682
+ return /* @__PURE__ */ react_exports.createElement(Blocker, null, /* @__PURE__ */ react_exports.createElement(Visualization, __spreadValues({}, props)), showEditCover && /* @__PURE__ */ react_exports.createElement(Cover, { "data-test": "edit-mode-cover" }));
683
+ };
684
+ extendStaticWrapperProps({ Wrapper, Visualization });
685
+ return Wrapper;
686
+ };
687
+ var withEditModeCover_default = withEditModeCover;
265
688
 
266
- if (threshold >= dataLength || threshold === 0) {
267
- var allIndices = data.map(function (values, index) {
268
- return index;
689
+ // esm-externals:@splunk/themes/variables
690
+ var variables_exports = {};
691
+ __export(variables_exports, {
692
+ default: () => variables_default
693
+ });
694
+ var defaultImport24 = __toESM(require("@splunk/themes/variables"));
695
+ __reExport(variables_exports, require("@splunk/themes/variables"));
696
+ var variables_default = "default" in defaultImport24 ? defaultImport24.default : defaultImport24;
697
+
698
+ // src/common/components/IconPlaceholder.tsx
699
+ var shouldShowIconPlaceholder = (dataSources, loading = false) => {
700
+ const data = (0, lodash_exports.get)(dataSources, "primary.data.columns[0]", void 0);
701
+ const noData = data === void 0;
702
+ const fields = (0, lodash_exports.get)(dataSources, "primary.data.fields[0]", void 0);
703
+ const noFields = fields === void 0;
704
+ return loading || noData || noFields;
705
+ };
706
+ var propTypes2 = {
707
+ icon: prop_types_exports.func,
708
+ width: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
709
+ height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
710
+ // eslint-disable-next-line react/no-unused-prop-types
711
+ backgroundColor: prop_types_exports.string,
712
+ iconColor: prop_types_exports.string
713
+ };
714
+ var IconPlaceholder = (props) => {
715
+ const { width, height, icon, iconColor } = props;
716
+ if (icon) {
717
+ return react_exports.createElement(icon, {
718
+ style: {
719
+ left: "50%",
720
+ top: "50%",
721
+ color: iconColor,
722
+ opacity: 0.15,
723
+ position: "absolute",
724
+ transform: "translate(-50%, -50%)"
725
+ },
726
+ width: "50%",
727
+ height: "50%",
728
+ "data-test": "icon-placeholder"
269
729
  });
270
- return {
271
- downsampledData: data,
272
- downsampledIndices: allIndices
273
- }; // Nothing to do
274
730
  }
731
+ return /* @__PURE__ */ react_exports.createElement(Message_default, { width, height, level: "warning", message: (0, i18n_exports._)("No DataSource Connected") });
732
+ };
733
+ IconPlaceholder.propTypes = propTypes2;
734
+ IconPlaceholder.defaultProps = {
735
+ width: "100%",
736
+ height: 250
737
+ };
738
+ var IconPlaceholder_default = FixedSizeContainer_default(IconPlaceholder);
275
739
 
276
- var sampled = [];
277
- var sampledIndex = 0; // Bucket size. Leave room for start and end data points
278
-
279
- var every = (dataLength - 2) / (threshold - 2);
280
- var a = 0; // Initially a is the first point in the triangle
281
-
282
- var maxAreaPoint;
283
- var maxArea;
284
- var area;
285
- var nextA;
286
- sampled.push(data[a]); // Always add the first point
287
-
288
- downsampledIndices.push(0); // eslint-disable-next-line no-plusplus
740
+ // src/common/hocs/withPlaceholder.tsx
741
+ var withPlaceholder = (Visualization, useIconPlaceholder = shouldShowIconPlaceholder) => {
742
+ const { config: config2 } = Visualization;
743
+ const { themes: themes3 } = config2;
744
+ const Wrapper = (props) => {
745
+ var _a, _b;
746
+ const { dataSources, loading, options, height, width } = props;
747
+ const showPlaceholder = useIconPlaceholder(dataSources, loading, options);
748
+ const bgColorFromTheme = (0, colorUtils_exports.isColor)(options == null ? void 0 : options.backgroundColor) ? options == null ? void 0 : options.backgroundColor : (_a = themes3 == null ? void 0 : themes3.defaultBackgroundColor) == null ? void 0 : _a.call(themes3, props);
749
+ const icon = (_b = config2.placeholderIcon) != null ? _b : config2.icon;
750
+ const iconColor = variables_default.contentColorActive(props);
751
+ if (config2.supports.includes("placeholder" /* PLACEHOLDER */) && showPlaceholder) {
752
+ return /* @__PURE__ */ react_exports.createElement(
753
+ IconPlaceholder_default,
754
+ {
755
+ "data-test": "icon-placeholder",
756
+ icon,
757
+ width,
758
+ height,
759
+ backgroundColor: bgColorFromTheme,
760
+ iconColor
761
+ }
762
+ );
763
+ }
764
+ return /* @__PURE__ */ react_exports.createElement(Visualization, __spreadValues({}, props));
765
+ };
766
+ extendStaticWrapperProps({ Wrapper, Visualization });
767
+ return Wrapper;
768
+ };
769
+ var withPlaceholder_default = withPlaceholder;
289
770
 
290
- for (var i = 0; i < threshold - 2; i++) {
291
- // Calculate point average for next bucket (containing c)
292
- var avgX = 0;
293
- var avgY = 0;
294
- var avgRangeStart = Math.floor((i + 1) * every) + 1;
295
- var avgRangeEnd = Math.floor((i + 2) * every) + 1;
771
+ // esm-externals:@splunk/visualizations-shared/numberUtils
772
+ var numberUtils_exports = {};
773
+ __export(numberUtils_exports, {
774
+ default: () => numberUtils_default
775
+ });
776
+ var defaultImport25 = __toESM(require("@splunk/visualizations-shared/numberUtils"));
777
+ __reExport(numberUtils_exports, require("@splunk/visualizations-shared/numberUtils"));
778
+ var numberUtils_default = "default" in defaultImport25 ? defaultImport25.default : defaultImport25;
779
+
780
+ // src/common/utils/dataUtils.ts
781
+ var largestTriangleThreeBuckets = (data, threshold, preferredDownsampleIndices) => {
782
+ const dataLength = data.length;
783
+ const downsampledIndices = [];
784
+ if (threshold >= dataLength || threshold === 0) {
785
+ const allIndices = data.map((values, index) => index);
786
+ return { downsampledData: data, downsampledIndices: allIndices };
787
+ }
788
+ const sampled = [];
789
+ let sampledIndex = 0;
790
+ const every = (dataLength - 2) / (threshold - 2);
791
+ let a = 0;
792
+ let maxAreaPoint;
793
+ let maxArea;
794
+ let area;
795
+ let nextA;
796
+ sampled.push(data[a]);
797
+ downsampledIndices.push(0);
798
+ for (let i = 0; i < threshold - 2; i++) {
799
+ let avgX = 0;
800
+ let avgY = 0;
801
+ let avgRangeStart = Math.floor((i + 1) * every) + 1;
802
+ let avgRangeEnd = Math.floor((i + 2) * every) + 1;
296
803
  avgRangeEnd = avgRangeEnd < dataLength ? avgRangeEnd : dataLength;
297
- var avgRangeLength = avgRangeEnd - avgRangeStart; // eslint-disable-next-line no-plusplus
298
-
804
+ const avgRangeLength = avgRangeEnd - avgRangeStart;
299
805
  for (; avgRangeStart < avgRangeEnd; avgRangeStart++) {
300
- avgX += Number(data[avgRangeStart][0]); // * 1 enforces Number (value may be Date)
301
-
806
+ avgX += Number(data[avgRangeStart][0]);
302
807
  avgY += data[avgRangeStart][1] * 1;
303
808
  }
304
-
305
809
  avgX /= avgRangeLength;
306
- avgY /= avgRangeLength; // Get the range for this bucket
307
-
308
- var rangeOffs = Math.floor((i + 0) * every) + 1;
309
- var rangeTo = Math.floor((i + 1) * every) + 1; // Point a
310
-
311
- var pointAX = Number(data[a][0]); // Enforce Number (value may be Date)
312
-
313
- var pointAY = data[a][1] * 1; // eslint-disable-next-line no-multi-assign
314
-
810
+ avgY /= avgRangeLength;
811
+ let rangeOffs = Math.floor((i + 0) * every) + 1;
812
+ const rangeTo = Math.floor((i + 1) * every) + 1;
813
+ const pointAX = Number(data[a][0]);
814
+ const pointAY = data[a][1] * 1;
315
815
  maxArea = area = -1;
316
- var maxAreaIndex = rangeOffs; // eslint-disable-next-line no-plusplus
317
-
816
+ let maxAreaIndex = rangeOffs;
318
817
  for (; rangeOffs < rangeTo; rangeOffs++) {
319
- // Calculate triangle area over three buckets
320
- area = Math.abs((pointAX - avgX) * (data[rangeOffs][1] - pointAY) - (pointAX - Number(data[rangeOffs][0])) * (avgY - pointAY)) * 0.5; // Modification: try to downsample the least amount of points possible when there are multiple series
321
- // If all points in a bucket have the same area, prioritize the one with an x index
322
- // that also existed from another series so we don't add another point unnecessarily.
323
- // By default LTTB picks the leftmost point in the bucket
324
-
818
+ area = Math.abs(
819
+ (pointAX - avgX) * (data[rangeOffs][1] - pointAY) - (pointAX - Number(data[rangeOffs][0])) * (avgY - pointAY)
820
+ ) * 0.5;
325
821
  if (area > maxArea || area === maxArea && preferredDownsampleIndices.has(rangeOffs)) {
326
822
  maxArea = area;
327
823
  maxAreaPoint = data[rangeOffs];
328
- nextA = rangeOffs; // Next a is this b
329
- // Modification: save the index of the point with the most area
330
-
824
+ nextA = rangeOffs;
331
825
  maxAreaIndex = rangeOffs;
332
826
  }
333
- } // eslint-disable-next-line no-plusplus
334
-
335
-
336
- sampled[sampledIndex++] = maxAreaPoint; // Pick this point from the bucket
337
-
827
+ }
828
+ sampled[sampledIndex++] = maxAreaPoint;
338
829
  downsampledIndices.push(maxAreaIndex);
339
- a = nextA; // This a is the next a (chosen b)
340
- } // eslint-disable-next-line no-plusplus
341
-
342
-
343
- sampled[sampledIndex++] = data[dataLength - 1]; // Always add last
344
-
830
+ a = nextA;
831
+ }
832
+ sampled[sampledIndex++] = data[dataLength - 1];
345
833
  downsampledIndices.push(dataLength - 1);
346
- return {
347
- downsampledData: sampled,
348
- downsampledIndices: downsampledIndices
349
- };
834
+ return { downsampledData: sampled, downsampledIndices };
350
835
  };
351
- /**
352
- * Strictly coerces the entire column to numbers if it only consists of numeric strings or numbers. Also determines
353
- * if at least one of the values in the column can be loosely coerced to a number.
354
- * If the column cannot be strictly downsampled (if it contains nulls or non-numeric strings), returns an empty array and
355
- * returns that it cannot downsample the column.
356
- */
357
-
358
-
359
- var strictlyCoerceYColumn = function strictlyCoerceYColumn(column, options) {
360
- var isNullCoercionEnabled = options.nullValueDisplay === 'zero'; // Splunk charting allows for numbers in formats such as negative hex that
361
- // Number() does not support and also allows loose coercion of hex numbers (but not other formats)
362
- // We want to identify columns which contain at least one value that can be loosely coerced
363
-
364
- var canLooselyCoerceSomeValues = column.findIndex(function (value) {
365
- return (0, numberUtils_1.startsWithNumber)("".concat(value)) || isNullCoercionEnabled && value === null;
366
- }) >= 0; // If not all values in column can be strictly coerced to a number, we do not downsample
367
-
368
- var coercedColumn = [];
369
- var canDownsampleColumn = !column.some(function (value) {
370
- var coercedValue = Number(value);
371
- var coerceValueToZero = isNullCoercionEnabled && value === null; // if it can't be parsed or isn't safe, fail
372
-
373
- if (Number.isNaN(coercedValue) || coercedValue <= Number.MIN_SAFE_INTEGER || coercedValue >= Number.MAX_SAFE_INTEGER || typeof value !== 'string' && typeof value !== 'number' && !coerceValueToZero) {
836
+ var strictlyCoerceYColumn = (column, options) => {
837
+ const isNullCoercionEnabled = options.nullValueDisplay === "zero";
838
+ const canLooselyCoerceSomeValues = column.findIndex(
839
+ (value) => (0, numberUtils_exports.startsWithNumber)(`${value}`) || isNullCoercionEnabled && value === null
840
+ ) >= 0;
841
+ const coercedColumn = [];
842
+ const canDownsampleColumn = !column.some((value) => {
843
+ const coercedValue = Number(value);
844
+ const coerceValueToZero = isNullCoercionEnabled && value === null;
845
+ if (Number.isNaN(coercedValue) || coercedValue <= Number.MIN_SAFE_INTEGER || coercedValue >= Number.MAX_SAFE_INTEGER || typeof value !== "string" && typeof value !== "number" && !coerceValueToZero) {
374
846
  return true;
375
- } // save value and continue to next
376
-
377
-
847
+ }
378
848
  coercedColumn.push(coercedValue);
379
849
  return false;
380
850
  });
381
851
  return {
382
- canDownsampleColumn: canDownsampleColumn,
383
- canLooselyCoerceSomeValues: canLooselyCoerceSomeValues,
852
+ canDownsampleColumn,
853
+ canLooselyCoerceSomeValues,
384
854
  coercedColumn: canDownsampleColumn ? coercedColumn : []
385
855
  };
386
856
  };
387
- /**
388
- * Tries to coerce the x-column to numbers or dates, if it is eligible for downsampling.
389
- * Only strictly increasing x-columns are eligible for downsampling.
390
- * If the column is not eligible for downsampling, returns an empty array.
391
- */
392
-
393
-
394
- var strictlyCoerceXColumn = function strictlyCoerceXColumn(column, fieldType) {
395
- if (fieldType === 'number') {
396
- var coercedXColumn = column.map(function (xValue) {
397
- return Number(xValue);
398
- });
399
-
857
+ var strictlyCoerceXColumn = (column, fieldType) => {
858
+ if (fieldType === "number") {
859
+ const coercedXColumn = column.map((xValue) => Number(xValue));
400
860
  if (isColumnStrictlyIncreasing(coercedXColumn, fieldType)) {
401
861
  return coercedXColumn;
402
862
  }
403
- } else if (fieldType === 'time') {
404
- var _coercedXColumn = column.map(function (xValue) {
405
- return new Date(xValue);
406
- });
407
-
408
- if (isColumnStrictlyIncreasing(_coercedXColumn, fieldType)) {
409
- return _coercedXColumn;
863
+ } else if (fieldType === "time") {
864
+ const coercedXColumn = column.map((xValue) => new Date(xValue));
865
+ if (isColumnStrictlyIncreasing(coercedXColumn, fieldType)) {
866
+ return coercedXColumn;
410
867
  }
411
868
  }
412
-
413
869
  return [];
414
870
  };
415
-
416
- var isDownsamplingEnabledForViz = function isDownsamplingEnabledForViz(_ref) {
417
- var vizConfig = _ref.vizConfig;
418
-
871
+ var isDownsamplingEnabledForViz = ({ vizConfig }) => {
419
872
  var _a;
420
-
421
- return (_a = vizConfig.supports) === null || _a === void 0 ? void 0 : _a.includes(interfaces_1.VizBehavior.DOWNSAMPLING);
422
- };
423
-
424
- exports.isDownsamplingEnabledForViz = isDownsamplingEnabledForViz;
425
-
426
- var calculateThresholdOnRangeSelect = function calculateThresholdOnRangeSelect(_ref2) {
427
- var firstIndex = _ref2.firstIndex,
428
- lastIndex = _ref2.lastIndex,
429
- dataSources = _ref2.dataSources,
430
- width = _ref2.width;
431
-
432
- var _a, _b, _c;
433
-
434
- var window = lastIndex - firstIndex + 1;
435
- var ratio = Math.round(Number(((_c = (_b = (_a = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.columns[0]) === null || _c === void 0 ? void 0 : _c.length) / window) * 10) / 10;
436
- return Math.round(ratio * Number(width));
437
- };
438
-
439
- exports.calculateThresholdOnRangeSelect = calculateThresholdOnRangeSelect;
440
- /**
441
- * Calculates the downsampling threshold based on the range selection. If search zoom is enabled or there is no selection,
442
- * then returns the width of the visualization.
443
- *
444
- * Otherwise calculates the threshold based on the ratio of the window selected compared to the size of the non-downsampled
445
- * data sources. Returns null if the chart event's dataset does not match the passed in primary data source or if the chart is zoomed
446
- * in for a categorical chart.
447
- */
448
-
449
- var calculateDownsamplingThreshold = function calculateDownsamplingThreshold(_ref3) {
450
- var enableSearchZoom = _ref3.enableSearchZoom,
451
- dataSources = _ref3.dataSources,
452
- selectChartEvent = _ref3.selectChartEvent,
453
- width = _ref3.width,
454
- xField = _ref3.xField;
455
-
456
- var _a, _b, _c;
457
-
458
- if (enableSearchZoom || !selectChartEvent) {
459
- return Number(width);
460
- }
461
-
462
- var primaryDataSource = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary;
463
-
464
- if (!primaryDataSource) {
465
- return null;
466
- }
467
-
468
- var startXIndex = selectChartEvent.startXIndex,
469
- endXIndex = selectChartEvent.endXIndex,
470
- currentTarget = selectChartEvent.currentTarget;
471
-
472
- try {
473
- var xFieldIndex = (_a = primaryDataSource === null || primaryDataSource === void 0 ? void 0 : primaryDataSource.data) === null || _a === void 0 ? void 0 : _a.fields.findIndex(function (field) {
474
- return field.name === xField;
475
- });
476
- var downsampledXFieldIndex = (_b = currentTarget.dataSet) === null || _b === void 0 ? void 0 : _b.fields.findIndex(function (field) {
477
- return field === xField;
478
- });
479
-
480
- if (xFieldIndex === -1 || downsampledXFieldIndex === -1) {
481
- return null;
482
- }
483
-
484
- var fullSeries = (_c = primaryDataSource === null || primaryDataSource === void 0 ? void 0 : primaryDataSource.data) === null || _c === void 0 ? void 0 : _c.columns[xFieldIndex];
485
- var downsampledSeries = currentTarget.dataSet.seriesList[downsampledXFieldIndex];
486
- var firstIndex = fullSeries.findIndex(function (x) {
487
- return downsampledSeries[startXIndex] === x;
488
- });
489
- var lastIndex = fullSeries.findIndex(function (x) {
490
- return downsampledSeries[endXIndex] === x;
491
- });
492
-
493
- if (firstIndex >= 0 && lastIndex >= 0 && firstIndex <= lastIndex) {
494
- return (0, exports.calculateThresholdOnRangeSelect)({
495
- firstIndex: firstIndex,
496
- lastIndex: lastIndex,
497
- dataSources: dataSources,
498
- width: width
499
- });
500
- }
501
- } catch (e) {
502
- // eslint-disable-next-line no-console
503
- console.error('Error occurred while setting downsample threshold on range select event', e);
504
- }
505
-
506
- return null;
873
+ return (_a = vizConfig.supports) == null ? void 0 : _a.includes("downsampling" /* DOWNSAMPLING */);
507
874
  };
508
-
509
- exports.calculateDownsamplingThreshold = calculateDownsamplingThreshold;
510
-
511
- var isColumnStrictlyIncreasing = function isColumnStrictlyIncreasing(column, fieldType) {
512
- return column.every(function (value, index) {
513
- if (fieldType === 'number') {
875
+ var isColumnStrictlyIncreasing = (column, fieldType) => {
876
+ return column.every((value, index) => {
877
+ if (fieldType === "number") {
514
878
  if (Number.isNaN(value)) {
515
879
  return false;
516
880
  }
517
881
  }
518
-
519
- if (fieldType === 'time') {
882
+ if (fieldType === "time") {
520
883
  if (Number.isNaN(value.getTime())) {
521
884
  return false;
522
885
  }
523
886
  }
524
-
525
887
  if (index === 0) {
526
888
  return true;
527
889
  }
528
-
529
890
  return value > column[index - 1];
530
891
  });
531
892
  };
532
- /**
533
- * Verifies that all of the columns that are displayed in a chart can be downsampled. Valid columns that can be
534
- * displayed are those that contain at least one number. We can only downsample columns that only consist of numbers.
535
- *
536
- * If all columns can be downsampled, returns the x column coerced to time/number and y columns coerced to numbers.
537
- * If not all columns can be downsampled, then returns empty arrays for both x and y
538
- */
539
-
540
-
541
- var tryToCoerceAllDisplayedFields = function tryToCoerceAllDisplayedFields(ds, xField, yFields, fieldTypes, options) {
542
- var xColumn = [];
543
- var yColumns = [];
544
- var canDownsample = !ds.data.fields.some(function (field, index) {
893
+ var tryToCoerceAllDisplayedFields = (ds, xField, yFields, fieldTypes, options) => {
894
+ let xColumn = [];
895
+ const yColumns = [];
896
+ const canDownsample = !ds.data.fields.some((field, index) => {
545
897
  var _a, _b;
546
-
547
- var fieldName = (_a = field.name) !== null && _a !== void 0 ? _a : field;
548
- var fieldType = (_b = fieldTypes[index]) !== null && _b !== void 0 ? _b : 'unknown';
549
- var column = ds.data.columns[index];
550
- var hasDisplayedColumnThatCantBeDownsampled = false;
551
-
898
+ const fieldName = (_a = field.name) != null ? _a : field;
899
+ const fieldType = (_b = fieldTypes[index]) != null ? _b : "unknown";
900
+ const column = ds.data.columns[index];
901
+ let hasDisplayedColumnThatCantBeDownsampled = false;
552
902
  if (fieldName === xField) {
553
903
  xColumn = strictlyCoerceXColumn(column, fieldType);
554
904
  } else if (yFields.has(fieldName)) {
555
- var _strictlyCoerceYColum = strictlyCoerceYColumn(ds.data.columns[index], options),
556
- coercedColumn = _strictlyCoerceYColum.coercedColumn,
557
- canLooselyCoerceSomeValues = _strictlyCoerceYColum.canLooselyCoerceSomeValues,
558
- canDownsampleColumn = _strictlyCoerceYColum.canDownsampleColumn; // do not perform downsampling if a column can possibly be displayed but cannot
559
- // be downsampled using LTTB
560
-
561
-
905
+ const { coercedColumn, canLooselyCoerceSomeValues, canDownsampleColumn } = strictlyCoerceYColumn(
906
+ ds.data.columns[index],
907
+ options
908
+ );
562
909
  hasDisplayedColumnThatCantBeDownsampled = canLooselyCoerceSomeValues && !canDownsampleColumn;
563
-
564
910
  if (hasDisplayedColumnThatCantBeDownsampled) {
565
911
  return true;
566
912
  }
567
-
568
913
  if (canDownsampleColumn) {
569
914
  yColumns.push(coercedColumn);
570
915
  }
571
916
  }
572
-
573
917
  return false;
574
918
  });
575
-
576
919
  if (canDownsample) {
577
- return {
578
- xColumn: xColumn,
579
- yColumns: yColumns
580
- };
920
+ return { xColumn, yColumns };
581
921
  }
582
-
583
- return {
584
- xColumn: [],
585
- yColumns: []
586
- };
922
+ return { xColumn: [], yColumns: [] };
587
923
  };
588
-
589
- var pickIndicesFromDataSource = function pickIndicesFromDataSource(ds, indices) {
590
- var sortedIndices = Array.from(indices).sort(function (a, b) {
591
- return a - b;
592
- });
593
- var slicedColumns = [];
594
- ds.data.columns.forEach(function (column) {
595
- var slicedColumn = [];
596
- sortedIndices.forEach(function (index) {
924
+ var pickIndicesFromDataSource = (ds, indices) => {
925
+ const sortedIndices = Array.from(indices).sort((a, b) => a - b);
926
+ const slicedColumns = [];
927
+ ds.data.columns.forEach((column) => {
928
+ const slicedColumn = [];
929
+ sortedIndices.forEach((index) => {
597
930
  slicedColumn.push(column[index]);
598
931
  });
599
932
  slicedColumns.push(slicedColumn);
600
- }); // update data columns with downsampled columns
601
-
602
- return Object.assign(Object.assign({}, ds), {
603
- data: Object.assign(Object.assign({}, ds.data), {
933
+ });
934
+ return __spreadProps(__spreadValues({}, ds), {
935
+ data: __spreadProps(__spreadValues({}, ds.data), {
604
936
  columns: slicedColumns
605
937
  })
606
938
  });
607
939
  };
608
-
609
- var downsampleDataSources = function downsampleDataSources(_ref4) {
610
- var dataSources = _ref4.dataSources,
611
- threshold = _ref4.threshold,
612
- options = _ref4.options;
613
-
940
+ var downsampleDataSources = ({ dataSources, threshold, options }) => {
614
941
  var _a, _b, _c;
615
-
616
- var primaryDS = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary; // only downsample time series when number of data points are over threshold
617
-
618
- var numPoints = (_c = (_b = (_a = primaryDS === null || primaryDS === void 0 ? void 0 : primaryDS.data) === null || _a === void 0 ? void 0 : _a.columns[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
619
-
942
+ const primaryDS = dataSources == null ? void 0 : dataSources.primary;
943
+ const numPoints = (_c = (_b = (_a = primaryDS == null ? void 0 : primaryDS.data) == null ? void 0 : _a.columns[0]) == null ? void 0 : _b.length) != null ? _c : 0;
620
944
  if (Number.isNaN(threshold) || numPoints <= threshold || threshold < 2) {
621
945
  return dataSources;
622
946
  }
623
-
624
- var xField = options.xField,
625
- yFields = options.yFields,
626
- fieldTypes = options.fieldTypes;
627
-
628
- if (!xField || !(yFields === null || yFields === void 0 ? void 0 : yFields.length) || !(fieldTypes === null || fieldTypes === void 0 ? void 0 : fieldTypes.length)) {
947
+ const { xField, yFields, fieldTypes } = options;
948
+ if (!xField || !(yFields == null ? void 0 : yFields.length) || !(fieldTypes == null ? void 0 : fieldTypes.length)) {
629
949
  return dataSources;
630
950
  }
631
-
632
- var nonInternalYFields = new Set(yFields.filter(function (yField) {
633
- return !yField.startsWith('_');
634
- }));
635
- var maxPointsInDownsample = Math.min(nonInternalYFields.size * threshold, numPoints); // Do not try to downsample if there are too many downsampled pts
636
- // At the worst case, each series has non-overlapping downsampled pts
637
- // which will mean that all points will be included in the downsampled result
638
- // This will just lead to additional overhead due to coercing each
639
- // x and y field to number
640
-
951
+ const nonInternalYFields = new Set(yFields.filter((yField) => !yField.startsWith("_")));
952
+ const maxPointsInDownsample = Math.min(nonInternalYFields.size * threshold, numPoints);
641
953
  if (maxPointsInDownsample >= numPoints) {
642
954
  return dataSources;
643
955
  }
644
-
645
- var _tryToCoerceAllDispla = tryToCoerceAllDisplayedFields(primaryDS, xField, nonInternalYFields, fieldTypes, options),
646
- xColumn = _tryToCoerceAllDispla.xColumn,
647
- yColumns = _tryToCoerceAllDispla.yColumns;
648
-
956
+ const { xColumn, yColumns } = tryToCoerceAllDisplayedFields(
957
+ primaryDS,
958
+ xField,
959
+ nonInternalYFields,
960
+ fieldTypes,
961
+ options
962
+ );
649
963
  if (!yColumns.length || !xColumn.length) {
650
964
  return dataSources;
651
965
  }
652
-
653
- var downsampledDataSources = Object.assign({}, dataSources);
654
- var downsampledIndices = new Set();
655
- yColumns.forEach(function (yColumn, columnIndex) {
656
- // perform LTTB downsampling for current series, LTTB takes an [x, y] pair
657
- var xyPair = yColumn.map(function (yValue, index) {
966
+ const downsampledDataSources = __spreadValues({}, dataSources);
967
+ const downsampledIndices = /* @__PURE__ */ new Set();
968
+ yColumns.forEach((yColumn, columnIndex) => {
969
+ const xyPair = yColumn.map((yValue, index) => {
658
970
  return [xColumn[index], yValue];
659
971
  });
660
-
661
972
  try {
662
- var _largestTriangleThree = largestTriangleThreeBuckets(xyPair, threshold, downsampledIndices),
663
- downsampledIndicesForSeries = _largestTriangleThree.downsampledIndices;
664
-
665
- downsampledIndicesForSeries.forEach(function (downsampleIndex) {
666
- return downsampledIndices.add(downsampleIndex);
667
- });
973
+ const { downsampledIndices: downsampledIndicesForSeries } = largestTriangleThreeBuckets(
974
+ xyPair,
975
+ threshold,
976
+ downsampledIndices
977
+ );
978
+ downsampledIndicesForSeries.forEach((downsampleIndex) => downsampledIndices.add(downsampleIndex));
668
979
  } catch (e) {
669
- // eslint-disable-next-line no-console
670
- console.error("Error occurred while downsampling column ".concat(columnIndex), e);
980
+ console.error(`Error occurred while downsampling column ${columnIndex}`, e);
671
981
  }
672
- }); // update data columns with downsampled columns
673
-
982
+ });
674
983
  downsampledDataSources.primary = pickIndicesFromDataSource(primaryDS, downsampledIndices);
675
984
  return downsampledDataSources;
676
985
  };
677
986
 
678
- exports.downsampleDataSources = downsampleDataSources;
679
-
680
- /***/ }),
681
- /* 15 */
682
- /***/ (function(module, exports) {
683
-
684
- module.exports = require("@splunk/visualizations-shared/colorUtils");
685
-
686
- /***/ }),
687
- /* 16 */
688
- /***/ (function(module, exports) {
689
-
690
- module.exports = require("@splunk/visualization-encoding/Options");
691
-
692
- /***/ }),
693
- /* 17 */
694
- /***/ (function(module, exports, __webpack_require__) {
695
-
696
- "use strict";
697
-
698
-
699
- var _slicedToArray = __webpack_require__(5);
700
-
701
- Object.defineProperty(exports, "__esModule", {
702
- value: true
703
- });
704
-
705
- var React = __webpack_require__(1);
706
-
707
- var styled_components_1 = __webpack_require__(4);
708
-
709
- var style_1 = __webpack_require__(18);
710
-
711
- var colorUtils_1 = __webpack_require__(15);
712
-
713
- var SizeAwareWrapper_1 = __webpack_require__(25);
987
+ // src/common/hooks/usePrevious.ts
988
+ function usePrevious(value) {
989
+ const ref = (0, react_exports.useRef)();
990
+ (0, react_exports.useEffect)(() => {
991
+ ref.current = value;
992
+ });
993
+ return ref.current;
994
+ }
714
995
 
715
- var Item = styled_components_1.default.div.attrs(function (_ref) {
716
- var width = _ref.width;
717
- return {
718
- style: {
719
- width: (0, style_1.toPx)(width)
996
+ // src/common/hooks/useGetXAndYFields.tsx
997
+ var useGetXAndYFields = ({
998
+ shouldEvaluateDSL,
999
+ options,
1000
+ context,
1001
+ dataSources
1002
+ }) => {
1003
+ const { dataSourcesWithOnlyOnePoint, dataFrameWithOnlyOnePoint } = (0, react_exports.useMemo)(() => {
1004
+ var _a, _b, _c;
1005
+ if (!shouldEvaluateDSL) {
1006
+ return {
1007
+ dataSourcesWithOnlyOnePoint: null,
1008
+ dataFrameWithOnlyOnePoint: null
1009
+ };
720
1010
  }
721
- };
722
- }).withConfig({
723
- displayName: "FixedSizeContainer__Item",
724
- componentId: "sc-1yhgpod-0"
725
- })(["position:relative;background-color:", "};"], function (props) {
726
- return (0, colorUtils_1.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
727
- }); // Use `.attrs()` for highly dynamic styles. Ref: https://github.com/styled-components/styled-components/issues/134#issuecomment-312415291
728
-
729
- var FixSizeItem = styled_components_1.default.div.attrs(function (_ref2) {
730
- var width = _ref2.width,
731
- height = _ref2.height;
732
- return {
733
- style: Object.assign(Object.assign({}, width && {
734
- width: (0, style_1.toPx)(width)
735
- }), height && {
736
- height: (0, style_1.toPx)(height)
737
- })
738
- };
739
- }).withConfig({
740
- displayName: "FixedSizeContainer__FixSizeItem",
741
- componentId: "sc-1yhgpod-1"
742
- })(["position:relative;flex-direction:column;flex:1;display:flex;background-color:", "};"], function (props) {
743
- return (0, colorUtils_1.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
744
- });
745
- var ItemContent = styled_components_1.default.div.withConfig({
746
- displayName: "FixedSizeContainer__ItemContent",
747
- componentId: "sc-1yhgpod-2"
748
- })(["position:relative;min-height:100px;width:100%;"]);
749
- var FixSizeItemContent = styled_components_1.default.div.withConfig({
750
- displayName: "FixedSizeContainer__FixSizeItemContent",
751
- componentId: "sc-1yhgpod-3"
752
- })(["min-height:0px;flex:1;position:relative;box-sizing:border-box;"]);
753
-
754
- var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
755
- var FixedSizeContainer = function FixedSizeContainer(props) {
756
- var width = props.width,
757
- height = props.height,
758
- backgroundColor = props.backgroundColor;
759
- var cachedHandleResize = React.useCallback(function (w, h) {
760
- setContainerWidth(w);
761
- setContainerHeight(h);
762
- }, []);
763
-
764
- var _React$useState = React.useState(Number(props.width)),
765
- _React$useState2 = _slicedToArray(_React$useState, 2),
766
- containerWidth = _React$useState2[0],
767
- setContainerWidth = _React$useState2[1];
768
-
769
- var _React$useState3 = React.useState(Number(props.height)),
770
- _React$useState4 = _slicedToArray(_React$useState3, 2),
771
- containerHeight = _React$useState4[0],
772
- setContainerHeight = _React$useState4[1];
773
-
774
- if (!height) {
775
- return React.createElement(Item, {
776
- "data-test": "item",
777
- width: width,
778
- backgroundColor: backgroundColor
779
- }, React.createElement(ItemContent, null, React.createElement(Viz, Object.assign({}, props))));
1011
+ if (!((_c = (_b = (_a = dataSources == null ? void 0 : dataSources.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.columns) == null ? void 0 : _c.length)) {
1012
+ return {
1013
+ dataSourcesWithOnlyOnePoint: null,
1014
+ dataFrameWithOnlyOnePoint: null
1015
+ };
780
1016
  }
781
-
782
- return React.createElement(FixSizeItem, {
783
- "data-test": "fix-size-item",
784
- "data-splunk-visualization-version": "26.4.1 - 2b7482c08",
785
- width: width,
786
- height: height,
787
- backgroundColor: backgroundColor
788
- }, React.createElement(FixSizeItemContent, null, React.createElement(SizeAwareWrapper_1.default, {
789
- width: width,
790
- height: height,
791
- onResize: cachedHandleResize
792
- }), React.createElement(Viz, Object.assign({}, props, {
793
- width: containerWidth,
794
- height: containerHeight
795
- }))));
796
- };
797
-
798
- FixedSizeContainer.displayName = 'withFixedSizeContainer';
799
- return FixedSizeContainer;
1017
+ const { primary: primaryDS } = dataSources;
1018
+ const columnsWithOnlyOnePoint = primaryDS.data.columns.map((column) => {
1019
+ return [column[0]];
1020
+ });
1021
+ const filteredDataSources = {
1022
+ primary: __spreadProps(__spreadValues({}, primaryDS), {
1023
+ data: __spreadProps(__spreadValues({}, primaryDS.data), {
1024
+ columns: columnsWithOnlyOnePoint
1025
+ })
1026
+ })
1027
+ };
1028
+ return {
1029
+ dataSourcesWithOnlyOnePoint: filteredDataSources,
1030
+ dataFrameWithOnlyOnePoint: Options_exports.Options.dataFrameFromDataSource(filteredDataSources)
1031
+ };
1032
+ }, [dataSources, shouldEvaluateDSL]);
1033
+ const xAndYFieldsWithTypes = (0, react_exports.useMemo)(() => {
1034
+ try {
1035
+ if (!dataSourcesWithOnlyOnePoint || !dataFrameWithOnlyOnePoint) {
1036
+ return options;
1037
+ }
1038
+ if (!(options == null ? void 0 : options.x) || !(options == null ? void 0 : options.y) && !(options == null ? void 0 : options.y2)) {
1039
+ return options;
1040
+ }
1041
+ const optionsToEvaluate = {
1042
+ x: options.x,
1043
+ xField: "> x | getField()",
1044
+ y: options.y,
1045
+ yFields: options.y ? "> y | getField()" : void 0,
1046
+ y2: options.y2,
1047
+ y2Fields: options.y2 ? "> y2 | getField()" : void 0,
1048
+ fieldTypes: "> primary | getType()"
1049
+ };
1050
+ const { xField = "", yFields = [], y2Fields = [], fieldTypes } = Options_exports.Options.evaluate(
1051
+ { options: optionsToEvaluate, context },
1052
+ dataSourcesWithOnlyOnePoint,
1053
+ () => {
1054
+ },
1055
+ dataFrameWithOnlyOnePoint
1056
+ );
1057
+ return {
1058
+ xField,
1059
+ yFields: [...yFields, ...y2Fields],
1060
+ fieldTypes
1061
+ };
1062
+ } catch (e) {
1063
+ return {
1064
+ xField: void 0,
1065
+ yFields: [],
1066
+ fieldTypes: []
1067
+ };
1068
+ }
1069
+ }, [options, context, dataSourcesWithOnlyOnePoint, dataFrameWithOnlyOnePoint]);
1070
+ return xAndYFieldsWithTypes;
800
1071
  };
801
-
802
- exports.default = withFixedSizeContainer;
803
-
804
- /***/ }),
805
- /* 18 */
806
- /***/ (function(module, exports) {
807
-
808
- module.exports = require("@splunk/visualizations-shared/style");
809
-
810
- /***/ }),
811
- /* 19 */,
812
- /* 20 */
813
- /***/ (function(module, exports, __webpack_require__) {
814
-
815
- "use strict";
816
-
817
-
818
- Object.defineProperty(exports, "__esModule", {
819
- value: true
820
- });
821
- exports.validOutputModes = exports.validSortDirs = void 0;
822
- exports.validSortDirs = ['asc', 'desc', 'none'];
823
- exports.validOutputModes = ['json_cols', 'json'];
824
-
825
- /***/ }),
826
- /* 21 */
827
- /***/ (function(module, exports, __webpack_require__) {
828
-
829
- "use strict";
830
-
831
-
832
- var _classCallCheck = __webpack_require__(8);
833
-
834
- var _createClass = __webpack_require__(24);
835
-
836
- Object.defineProperty(exports, "__esModule", {
837
- value: true
838
- });
839
- exports.DefaultVizActionHandler = void 0;
840
-
841
- var DefaultVizActionHandler = /*#__PURE__*/function () {
842
- function DefaultVizActionHandler() {
843
- _classCallCheck(this, DefaultVizActionHandler);
844
- }
845
-
846
- _createClass(DefaultVizActionHandler, [{
847
- key: "focus",
848
- value: function focus() {// noop
1072
+ var useGetXAndYFields_default = useGetXAndYFields;
1073
+
1074
+ // src/common/hooks/useDownsampleDataSources.tsx
1075
+ var downsampleVizOptionProperties = ["nullValueDisplay"];
1076
+ var useDownsampleDataSources = ({
1077
+ dataSources,
1078
+ options,
1079
+ context,
1080
+ threshold,
1081
+ isDownsamplingEnabled
1082
+ }) => {
1083
+ const isFirstUseEffectCall = (0, react_exports.useRef)(true);
1084
+ const xAndYFieldsWithTypes = useGetXAndYFields_default({
1085
+ shouldEvaluateDSL: isDownsamplingEnabled,
1086
+ options,
1087
+ context,
1088
+ dataSources
1089
+ });
1090
+ const downsampleVizOptions = (0, react_exports.useMemo)(() => (0, lodash_exports.pick)(options, downsampleVizOptionProperties), [options]);
1091
+ const downsampleDSOptions = (0, react_exports.useMemo)(
1092
+ () => __spreadValues(__spreadValues({}, downsampleVizOptions), xAndYFieldsWithTypes),
1093
+ [xAndYFieldsWithTypes, downsampleVizOptions]
1094
+ );
1095
+ const previousDownsampleDSOptions = usePrevious(downsampleDSOptions);
1096
+ const previousDataSources = usePrevious(dataSources);
1097
+ const previousThreshold = usePrevious(threshold);
1098
+ const [downsampledDataSources, setDownsampledDataSources] = (0, react_exports.useState)(() => {
1099
+ return isDownsamplingEnabled ? downsampleDataSources({
1100
+ dataSources,
1101
+ threshold,
1102
+ options: downsampleDSOptions
1103
+ }) : dataSources;
1104
+ });
1105
+ const debouncedDownsampleDataSources = (0, react_exports.useMemo)(() => {
1106
+ return (0, lodash_exports.debounce)(
1107
+ (downsampleOptions) => {
1108
+ const downsampledResult = downsampleDataSources(downsampleOptions);
1109
+ setDownsampledDataSources(downsampledResult);
1110
+ },
1111
+ 100,
1112
+ { trailing: true }
1113
+ );
1114
+ }, []);
1115
+ (0, react_exports.useEffect)(() => {
1116
+ if (isFirstUseEffectCall.current) {
1117
+ isFirstUseEffectCall.current = false;
1118
+ return;
849
1119
  }
850
- }, {
851
- key: "snapshot",
852
- value: function snapshot() {
853
- return null; // noop
1120
+ if (!isDownsamplingEnabled) {
1121
+ setDownsampledDataSources(dataSources);
1122
+ return;
854
1123
  }
855
- }]);
856
-
857
- return DefaultVizActionHandler;
858
- }();
859
-
860
- exports.DefaultVizActionHandler = DefaultVizActionHandler;
861
-
862
- /***/ }),
863
- /* 22 */
864
- /***/ (function(module, exports, __webpack_require__) {
865
-
866
- "use strict";
867
-
868
-
869
- Object.defineProperty(exports, "__esModule", {
870
- value: true
871
- });
872
- exports.VizCategory = void 0;
873
- var VizCategory;
874
-
875
- (function (VizCategory) {
876
- VizCategory["SINGLE_VALUE"] = "Single Value";
877
- VizCategory["TRENDS"] = "Trends";
878
- VizCategory["COMPARISONS"] = "Comparisons";
879
- VizCategory["TABLE"] = "Table";
880
- VizCategory["GAUGE"] = "Gauge";
881
- VizCategory["DISTRIBUTIONS"] = "Distributions";
882
- VizCategory["CHOROPLETH"] = "Choropleth Maps";
883
- VizCategory["SHAPES"] = "Shapes";
884
- VizCategory["MISC"] = "misc";
885
- VizCategory["FLOW"] = "Flow";
886
- VizCategory["CORRELATION"] = "Correlation";
887
- VizCategory["SPATIAL"] = "Spatial";
888
- })(VizCategory = exports.VizCategory || (exports.VizCategory = {}));
889
-
890
- /***/ }),
891
- /* 23 */
892
- /***/ (function(module, exports, __webpack_require__) {
893
-
894
- "use strict";
895
-
896
-
897
- Object.defineProperty(exports, "__esModule", {
898
- value: true
899
- });
900
- exports.extendStaticWrapperProps = void 0;
901
- /**
902
- * @method extendStaticWrapperProps
903
- * @param {Object} props
904
- * @param {DashboardVizType} props.Wrapper
905
- * @param {DashboardVizType} props.Visualization
906
- */
907
-
908
- var extendStaticWrapperProps = function extendStaticWrapperProps(_ref) {
909
- var Wrapper = _ref.Wrapper,
910
- Visualization = _ref.Visualization;
911
- var extendProperties = ['propTypes', 'defaultProps', 'config'];
912
- extendProperties.forEach(function (prop) {
913
- if (Visualization[prop]) {
914
- // eslint-disable-next-line no-param-reassign
915
- Wrapper[prop] = Visualization[prop];
1124
+ if ((0, lodash_exports.isEqual)(previousDownsampleDSOptions, downsampleDSOptions) && previousDataSources === dataSources && previousThreshold === threshold) {
1125
+ return;
916
1126
  }
917
- });
1127
+ debouncedDownsampleDataSources({
1128
+ dataSources,
1129
+ options: downsampleDSOptions,
1130
+ // Dont want to re-downsample everytime the options change
1131
+ threshold
1132
+ });
1133
+ }, [
1134
+ dataSources,
1135
+ downsampleDSOptions,
1136
+ debouncedDownsampleDataSources,
1137
+ xAndYFieldsWithTypes,
1138
+ threshold,
1139
+ isDownsamplingEnabled,
1140
+ previousDataSources,
1141
+ previousThreshold,
1142
+ previousDownsampleDSOptions
1143
+ ]);
1144
+ return downsampledDataSources;
918
1145
  };
1146
+ var useDownsampleDataSources_default = useDownsampleDataSources;
919
1147
 
920
- exports.extendStaticWrapperProps = extendStaticWrapperProps;
921
-
922
- /***/ }),
923
- /* 24 */
924
- /***/ (function(module, exports) {
925
-
926
- module.exports = require("@babel/runtime/helpers/createClass");
927
-
928
- /***/ }),
929
- /* 25 */
930
- /***/ (function(module, exports) {
931
-
932
- module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");
933
-
934
- /***/ }),
935
- /* 26 */
936
- /***/ (function(module, exports, __webpack_require__) {
937
-
938
- "use strict";
939
-
940
-
941
- var _toConsumableArray = __webpack_require__(6);
942
-
943
- Object.defineProperty(exports, "__esModule", {
944
- value: true
1148
+ // esm-externals:@splunk/visualization-context/FeatureFlags
1149
+ var FeatureFlags_exports = {};
1150
+ __export(FeatureFlags_exports, {
1151
+ default: () => FeatureFlags_default
945
1152
  });
946
- exports.insertLayout = exports.isDynamicOption = exports.uncollapseEditorConfig = exports.generatePrecisionValues = exports.getInitialPreset = exports.enhanceConfig = exports.enhanceOptionsSchemaWithDynamicOptions = void 0;
947
-
948
- var lodash_1 = __webpack_require__(2); // included for backwards compatibility
1153
+ var defaultImport26 = __toESM(require("@splunk/visualization-context/FeatureFlags"));
1154
+ __reExport(FeatureFlags_exports, require("@splunk/visualization-context/FeatureFlags"));
1155
+ var FeatureFlags_default = "default" in defaultImport26 ? defaultImport26.default : defaultImport26;
949
1156
 
950
-
951
- var visualization_schemas_1 = __webpack_require__(9);
952
-
953
- Object.defineProperty(exports, "enhanceOptionsSchemaWithDynamicOptions", {
954
- enumerable: true,
955
- get: function get() {
956
- return visualization_schemas_1.enhanceOptionsSchemaWithDynamicOptions;
1157
+ // src/common/utils/featureFlagUtils.ts
1158
+ var getFeatureFlag = (context, flagName) => {
1159
+ if (context && Object.keys(context).find((key) => key === flagName)) {
1160
+ return context[flagName];
957
1161
  }
958
- });
959
- /**
960
- * Helper function to enhance a Visualization Config as needed based on behaviors specified in supports block
961
- * this function also collapse all editor panels
962
- * @param vizConfig a Visualization Config
963
- * @returns an enhanced Visualization Config containing updated config entries based on behaviors it supports
964
- * and containing `open: false` for all editor panels in editorConfig
965
- */
1162
+ if (Object.keys(FeatureFlags_default).find((key) => key === flagName)) {
1163
+ return FeatureFlags_default[flagName];
1164
+ }
1165
+ return false;
1166
+ };
966
1167
 
967
- function enhanceConfig(vizConfig) {
968
- var enhancedConfig = Object.assign({}, vizConfig);
969
- enhancedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
970
- return Object.assign(Object.assign({}, config), {
971
- open: config.open || false
972
- });
973
- });
974
- return enhancedConfig;
975
- }
976
-
977
- exports.enhanceConfig = enhanceConfig;
978
- /**
979
- * Helper function to uncollapse all editor panels by adding `open: true` to the editorConfig
980
- * Created for editor unit tests
981
- * @param vizConfig a Visualization Config
982
- * @returns a Visualization Config containing `open: true` for all editor panels in editorConfig
983
- */
984
-
985
- function uncollapseEditorConfig(vizConfig) {
986
- var editorPanelUncollapsedConfig = Object.assign({}, vizConfig);
987
- editorPanelUncollapsedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
988
- return Object.assign(Object.assign({}, config), {
989
- open: true
990
- });
991
- });
992
- return editorPanelUncollapsedConfig;
993
- }
994
-
995
- exports.uncollapseEditorConfig = uncollapseEditorConfig;
996
-
997
- function isDynamicOption(option) {
998
- return option && typeof option === 'string' && option.trim().startsWith('>') || false;
999
- }
1000
-
1001
- exports.isDynamicOption = isDynamicOption; // private helpers to improve readability of getInitialPreset
1002
- // this shouldn't be tested since this util isn't something that we expect to use outside of getInitialPreset
1003
-
1004
- /**
1005
- * this checks to make sure that all values within vizContext are compatible with the given preset's context to determine the initialPreset
1006
- * if a preset has explicitly specified a key as being undefined, the vizContext must also has that key as undefined, or else this CANNOT be the initialPreset
1007
- * the inverse is true; if a preset has key is NOT undefined, it must also be NOT undefined in the corresponding vizContext
1008
- * the internal config contents are irrelevant (as the user could customize them in source), just as long as the presence of `undefined`s match up
1009
- *
1010
- * Since the presetConfigs have explicit undefined keys to override the existing config, we need to explicitly check the undefined values
1011
- */
1012
-
1013
- function hasCompatibleContexts(vizContext, presetContext) {
1014
- var presetContextKeys = Object.keys(presetContext);
1015
- return presetContextKeys.every(function (contextKey) {
1016
- return presetContext[contextKey] === undefined && vizContext[contextKey] === undefined || presetContext[contextKey] !== undefined && vizContext[contextKey] !== undefined;
1017
- });
1018
- }
1019
- /**
1020
- * Checks to make sure that dynamic (non-dynamic) options in a given preset are also dynamic (non-dynamic) in the vizOptions
1021
- */
1022
-
1023
-
1024
- function hasCompatibleOptions(vizOptions, presetOptions) {
1025
- var presetOptionKeys = Object.keys(presetOptions);
1026
- return presetOptionKeys.every(function (optionKey) {
1027
- return isDynamicOption(presetOptions[optionKey]) === isDynamicOption(vizOptions[optionKey]);
1028
- });
1029
- }
1030
- /**
1031
- * Evaluates whether there is an initialPreset that fits the current state of vizContext + vizOptions
1032
- * This function ignores extraneous vizOptions or vizContext keys, as they could be outside the scope of what the preset is intended to configure
1033
- *
1034
- * @param {Object} vizContext - the current vizContext definition
1035
- * @param {Object} vizOptions - the current vizOptions definition
1036
- * @param {PresetEntry[]} presets - the list of presets, one of which can be considered an initialPreset
1037
- */
1038
-
1039
-
1040
- function getInitialPreset(vizContext, vizOptions, presets) {
1041
- return presets.find(function (preset) {
1042
- var presetContext = (0, lodash_1.get)(preset, ['value', 'context'], {});
1043
- var presetOptions = (0, lodash_1.get)(preset, ['value', 'options'], {});
1044
- var presetContextKeys = Object.keys(presetContext);
1045
- var presetOptionKeys = Object.keys(presetOptions); // all presets have to explicitly specify which options to reset (i.e. need explicitly undefined keys)
1046
- // if not, then the preset is invalid in config.ts
1047
-
1048
- if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
1049
- return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
1050
- });
1051
- }
1052
-
1053
- exports.getInitialPreset = getInitialPreset;
1054
- /**
1055
- * generates number precision values for a Select editor
1056
- *
1057
- * @param {Number} numPrecisionValues - number of integer precision values to generate
1058
- * @returns {{ label: string; value; string }[]} array of { label, value } tuples
1059
- */
1060
-
1061
- function generatePrecisionValues(numPrecisionValues) {
1062
- return (0, lodash_1.range)(0, numPrecisionValues + 1).map(function (i) {
1063
- return {
1064
- label: "".concat(i, " (0").concat(i > 0 ? '.' : '').concat('0'.repeat(i), ")"),
1065
- value: i
1066
- };
1067
- });
1068
- }
1069
-
1070
- exports.generatePrecisionValues = generatePrecisionValues;
1071
- /**
1072
- * insert layout in layout array, return a new layout array instead of updating the original
1073
- *
1074
- * @param {EditorLayoutConfig[][]} layout - editor layout
1075
- * @param {Number} index - the index to insert layout item(s)
1076
- * @param {EditorLayoutConfig[][]} layoutItems - the item(s) to insert
1077
- * @returns {EditorLayoutConfig[][]} new editor layout with insertion
1078
- */
1079
-
1080
- var insertLayout = function insertLayout(layout, index) {
1081
- for (var _len = arguments.length, layoutItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1082
- layoutItems[_key - 2] = arguments[_key];
1083
- }
1084
-
1085
- return [].concat(_toConsumableArray(layout.slice(0, index)), layoutItems, _toConsumableArray(layout.slice(index)));
1086
- };
1087
-
1088
- exports.insertLayout = insertLayout;
1089
-
1090
- /***/ }),
1091
- /* 27 */
1092
- /***/ (function(module, exports) {
1093
-
1094
- module.exports = require("@splunk/visualization-context/FeatureFlagContext");
1095
-
1096
- /***/ }),
1097
- /* 28 */,
1098
- /* 29 */,
1099
- /* 30 */
1100
- /***/ (function(module, exports) {
1101
-
1102
- module.exports = require("@splunk/ui-utils/id");
1103
-
1104
- /***/ }),
1105
- /* 31 */
1106
- /***/ (function(module, exports) {
1107
-
1108
- module.exports = require("@splunk/visualization-context/TimezoneContext");
1109
-
1110
- /***/ }),
1111
- /* 32 */
1112
- /***/ (function(module, exports, __webpack_require__) {
1113
-
1114
- "use strict";
1115
-
1116
-
1117
- Object.defineProperty(exports, "__esModule", {
1118
- value: true
1119
- });
1120
-
1121
- var react_1 = __webpack_require__(1);
1122
-
1123
- function usePrevious(value) {
1124
- var ref = (0, react_1.useRef)();
1125
- (0, react_1.useEffect)(function () {
1126
- ref.current = value;
1127
- });
1128
- return ref.current;
1129
- }
1130
-
1131
- exports.default = usePrevious;
1132
-
1133
- /***/ }),
1134
- /* 33 */
1135
- /***/ (function(module, exports) {
1136
-
1137
- module.exports = require("@splunk/visualizations-shared/hocUtils");
1138
-
1139
- /***/ }),
1140
- /* 34 */
1141
- /***/ (function(module, exports) {
1142
-
1143
- module.exports = require("@splunk/visualizations-shared/JSONSchemaUtils");
1144
-
1145
- /***/ }),
1146
- /* 35 */,
1147
- /* 36 */
1148
- /***/ (function(module, exports, __webpack_require__) {
1149
-
1150
- "use strict";
1151
-
1152
-
1153
- Object.defineProperty(exports, "__esModule", {
1154
- value: true
1155
- });
1156
- exports.shouldShowIconPlaceholder = void 0;
1157
-
1158
- var React = __webpack_require__(1);
1159
-
1160
- var T = __webpack_require__(0);
1161
-
1162
- var lodash_1 = __webpack_require__(2);
1163
-
1164
- var i18n_1 = __webpack_require__(3);
1165
-
1166
- var Message_1 = __webpack_require__(11);
1167
-
1168
- var FixedSizeContainer_1 = __webpack_require__(17);
1169
- /**
1170
- * @method shouldShowIconPlaceholder
1171
- * @param {object} dataSources
1172
- * @param {boolean} loading
1173
- * @returns {boolean}
1174
- */
1175
-
1176
-
1177
- var shouldShowIconPlaceholder = function shouldShowIconPlaceholder(dataSources) {
1178
- var loading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1179
- var data = (0, lodash_1.get)(dataSources, 'primary.data.columns[0]', undefined);
1180
- var noData = data === undefined;
1181
- var fields = (0, lodash_1.get)(dataSources, 'primary.data.fields[0]', undefined);
1182
- var noFields = fields === undefined;
1183
- return loading || noData || noFields;
1184
- };
1185
-
1186
- exports.shouldShowIconPlaceholder = shouldShowIconPlaceholder;
1187
- var propTypes = {
1188
- icon: T.func,
1189
- width: T.oneOfType([T.string, T.number]),
1190
- height: T.oneOfType([T.string, T.number]),
1191
- // eslint-disable-next-line react/no-unused-prop-types
1192
- backgroundColor: T.string,
1193
- iconColor: T.string
1194
- };
1195
- /**
1196
- * @method IconPlaceholder
1197
- * @param {IconPlaceholderProps} props
1198
- * @returns {React.ReactElement}
1199
- */
1200
-
1201
- var IconPlaceholder = function IconPlaceholder(props) {
1202
- var width = props.width,
1203
- height = props.height,
1204
- icon = props.icon,
1205
- iconColor = props.iconColor;
1206
-
1207
- if (icon) {
1208
- return React.createElement(icon, {
1209
- style: {
1210
- left: '50%',
1211
- top: '50%',
1212
- color: iconColor,
1213
- opacity: 0.15,
1214
- position: 'absolute',
1215
- transform: 'translate(-50%, -50%)'
1216
- },
1217
- width: '50%',
1218
- height: '50%',
1219
- 'data-test': 'icon-placeholder'
1220
- });
1221
- }
1222
-
1223
- return React.createElement(Message_1.default, {
1224
- width: width,
1225
- height: height,
1226
- level: "warning",
1227
- message: (0, i18n_1._)('No DataSource Connected')
1228
- });
1229
- };
1230
-
1231
- IconPlaceholder.propTypes = propTypes;
1232
- IconPlaceholder.defaultProps = {
1233
- width: '100%',
1234
- height: 250
1235
- };
1236
- exports.default = (0, FixedSizeContainer_1.default)(IconPlaceholder);
1237
-
1238
- /***/ }),
1239
- /* 37 */
1240
- /***/ (function(module, exports, __webpack_require__) {
1241
-
1242
- "use strict";
1243
-
1244
-
1245
- var _defineProperty = __webpack_require__(12);
1246
-
1247
- Object.defineProperty(exports, "__esModule", {
1248
- value: true
1249
- });
1250
- exports.getSortingParams = exports.SortParamsPropTypes = void 0;
1251
-
1252
- var T = __webpack_require__(0);
1253
-
1254
- var lodash_1 = __webpack_require__(2);
1255
-
1256
- var DataSource_1 = __webpack_require__(20);
1257
-
1258
- exports.SortParamsPropTypes = T.shape({
1259
- currentSortKey: T.string,
1260
- currentSortDir: T.oneOf(DataSource_1.validSortDirs),
1261
- onSort: T.func
1262
- });
1263
-
1264
- var getSortingParams = function getSortingParams(_ref) {
1265
- var requestParams = _ref.requestParams,
1266
- onRequestParamsChange = _ref.onRequestParamsChange;
1267
- var currentSortKey;
1268
- var currentSortDir;
1269
- var nextSortDirMap = {
1270
- asc: 'desc',
1271
- desc: 'asc',
1272
- none: 'asc'
1273
- };
1274
- var onSort;
1275
-
1276
- if (typeof onRequestParamsChange === 'function') {
1277
- if (requestParams && (0, lodash_1.has)(requestParams, 'sort')) {
1278
- currentSortKey = Object.keys(requestParams.sort).shift();
1279
- currentSortDir = requestParams.sort[currentSortKey];
1280
- } // undid memoization since there is a dependency on requestParams, which is a deeply nested object
1281
-
1282
-
1283
- onSort = function onSort(e, _ref2) {
1284
- var sortKey = _ref2.sortKey,
1285
- sortDir = _ref2.sortDir;
1286
-
1287
- if (typeof sortKey === 'string') {
1288
- var nextSortDir = (0, lodash_1.has)(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : 'none';
1289
- onRequestParamsChange(Object.assign(Object.assign({}, requestParams), {
1290
- offset: 0,
1291
- sort: _defineProperty({}, sortKey, nextSortDir)
1292
- }));
1293
- } else {
1294
- onRequestParamsChange(requestParams);
1295
- }
1296
- };
1297
- }
1298
-
1299
- return {
1300
- currentSortKey: currentSortKey,
1301
- currentSortDir: currentSortDir,
1302
- onSort: onSort
1303
- };
1304
- };
1305
-
1306
- exports.getSortingParams = getSortingParams;
1307
-
1308
- /***/ }),
1309
- /* 38 */
1310
- /***/ (function(module, exports, __webpack_require__) {
1311
-
1312
- "use strict";
1313
-
1314
-
1315
- Object.defineProperty(exports, "__esModule", {
1316
- value: true
1317
- });
1318
- exports.getPaginationParams = exports.PaginatorParamsPropTypes = void 0;
1319
-
1320
- var T = __webpack_require__(0);
1321
-
1322
- var lodash_1 = __webpack_require__(2);
1323
-
1324
- exports.PaginatorParamsPropTypes = T.shape({
1325
- isPaging: T.bool,
1326
- current: T.number,
1327
- totalPages: T.number,
1328
- onChange: T.func
1329
- });
1330
-
1331
- var getPaginationParams = function getPaginationParams(_ref) {
1332
- var requestParams = _ref.requestParams,
1333
- meta = _ref.meta,
1334
- onRequestParamsChange = _ref.onRequestParamsChange;
1335
- var totalCount = meta && meta.totalCount || 0;
1336
- var offset = requestParams && requestParams.offset || 0;
1337
- var count = requestParams && requestParams.count;
1338
- var totalPages = typeof count === 'number' && count > 0 ? Math.ceil(totalCount / count) : 0;
1339
- var current = typeof count === 'number' && count > 0 ? Math.floor(offset / count) + 1 : 0;
1340
- var isPaging = totalPages > 1 && typeof onRequestParamsChange === 'function';
1341
-
1342
- var onChangeHandler = function onChangeHandler(e, _ref2) {
1343
- var page = _ref2.page,
1344
- countArg = _ref2.count;
1345
- var newParams = (0, lodash_1.cloneDeep)(requestParams);
1346
-
1347
- if (typeof countArg === 'number') {
1348
- newParams.count = countArg;
1349
- newParams.offset = 0;
1350
- }
1351
-
1352
- var pageCount = typeof newParams.count === 'number' ? newParams.count : 10;
1353
-
1354
- if (typeof page === 'number' && page > 0) {
1355
- newParams.count = pageCount;
1356
- newParams.offset = (page - 1) * pageCount;
1357
- }
1358
-
1359
- onRequestParamsChange(newParams);
1360
- };
1361
-
1362
- return {
1363
- isPaging: isPaging,
1364
- current: current,
1365
- totalPages: totalPages,
1366
- onChange: typeof onRequestParamsChange === 'function' ? onChangeHandler : lodash_1.noop
1367
- };
1368
- };
1369
-
1370
- exports.getPaginationParams = getPaginationParams;
1371
-
1372
- /***/ }),
1373
- /* 39 */
1374
- /***/ (function(module, exports, __webpack_require__) {
1375
-
1376
- "use strict";
1377
-
1378
-
1379
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1380
- if (k2 === undefined) k2 = k;
1381
- var desc = Object.getOwnPropertyDescriptor(m, k);
1382
-
1383
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1384
- desc = {
1385
- enumerable: true,
1386
- get: function get() {
1387
- return m[k];
1388
- }
1389
- };
1390
- }
1391
-
1392
- Object.defineProperty(o, k2, desc);
1393
- } : function (o, m, k, k2) {
1394
- if (k2 === undefined) k2 = k;
1395
- o[k2] = m[k];
1396
- });
1397
-
1398
- var __exportStar = this && this.__exportStar || function (m, exports) {
1399
- for (var p in m) {
1400
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1401
- }
1402
- };
1403
-
1404
- Object.defineProperty(exports, "__esModule", {
1405
- value: true
1406
- });
1407
-
1408
- __exportStar(__webpack_require__(40), exports);
1409
-
1410
- __exportStar(__webpack_require__(41), exports);
1411
-
1412
- __exportStar(__webpack_require__(20), exports);
1413
-
1414
- __exportStar(__webpack_require__(42), exports);
1415
-
1416
- __exportStar(__webpack_require__(43), exports);
1417
-
1418
- __exportStar(__webpack_require__(44), exports);
1419
-
1420
- __exportStar(__webpack_require__(45), exports);
1421
-
1422
- __exportStar(__webpack_require__(46), exports);
1423
-
1424
- __exportStar(__webpack_require__(47), exports);
1425
-
1426
- __exportStar(__webpack_require__(21), exports);
1427
-
1428
- __exportStar(__webpack_require__(7), exports);
1429
-
1430
- __exportStar(__webpack_require__(22), exports);
1431
-
1432
- __exportStar(__webpack_require__(48), exports);
1433
-
1434
- __exportStar(__webpack_require__(49), exports);
1435
-
1436
- __exportStar(__webpack_require__(50), exports);
1437
-
1438
- __exportStar(__webpack_require__(51), exports);
1439
-
1440
- __exportStar(__webpack_require__(52), exports);
1441
-
1442
- __exportStar(__webpack_require__(53), exports);
1443
-
1444
- /***/ }),
1445
- /* 40 */
1446
- /***/ (function(module, exports, __webpack_require__) {
1447
-
1448
- "use strict";
1449
-
1450
-
1451
- Object.defineProperty(exports, "__esModule", {
1452
- value: true
1453
- });
1454
-
1455
- /***/ }),
1456
- /* 41 */
1457
- /***/ (function(module, exports, __webpack_require__) {
1458
-
1459
- "use strict";
1460
-
1461
- /**
1462
- * A data structure used at runtime to wire up a visualization.
1463
- */
1464
-
1465
- Object.defineProperty(exports, "__esModule", {
1466
- value: true
1467
- });
1468
-
1469
- /***/ }),
1470
- /* 42 */
1471
- /***/ (function(module, exports, __webpack_require__) {
1472
-
1473
- "use strict";
1474
-
1475
-
1476
- Object.defineProperty(exports, "__esModule", {
1477
- value: true
1478
- });
1479
-
1480
- /***/ }),
1481
- /* 43 */
1482
- /***/ (function(module, exports, __webpack_require__) {
1483
-
1484
- "use strict";
1485
-
1486
-
1487
- Object.defineProperty(exports, "__esModule", {
1488
- value: true
1489
- });
1490
-
1491
- /***/ }),
1492
- /* 44 */
1493
- /***/ (function(module, exports, __webpack_require__) {
1494
-
1495
- "use strict";
1496
-
1497
-
1498
- Object.defineProperty(exports, "__esModule", {
1499
- value: true
1500
- });
1501
-
1502
- /***/ }),
1503
- /* 45 */
1504
- /***/ (function(module, exports, __webpack_require__) {
1505
-
1506
- "use strict";
1507
-
1508
-
1509
- Object.defineProperty(exports, "__esModule", {
1510
- value: true
1511
- });
1512
-
1513
- /***/ }),
1514
- /* 46 */
1515
- /***/ (function(module, exports, __webpack_require__) {
1516
-
1517
- "use strict";
1518
-
1519
-
1520
- Object.defineProperty(exports, "__esModule", {
1521
- value: true
1522
- });
1523
-
1524
- /***/ }),
1525
- /* 47 */
1526
- /***/ (function(module, exports, __webpack_require__) {
1527
-
1528
- "use strict";
1529
-
1530
-
1531
- Object.defineProperty(exports, "__esModule", {
1532
- value: true
1533
- });
1534
-
1535
- /***/ }),
1536
- /* 48 */
1537
- /***/ (function(module, exports, __webpack_require__) {
1538
-
1539
- "use strict";
1540
-
1541
-
1542
- Object.defineProperty(exports, "__esModule", {
1543
- value: true
1544
- });
1545
-
1546
- /***/ }),
1547
- /* 49 */
1548
- /***/ (function(module, exports, __webpack_require__) {
1549
-
1550
- "use strict";
1551
-
1552
-
1553
- Object.defineProperty(exports, "__esModule", {
1554
- value: true
1555
- });
1556
-
1557
- /***/ }),
1558
- /* 50 */
1559
- /***/ (function(module, exports, __webpack_require__) {
1560
-
1561
- "use strict";
1562
-
1563
-
1564
- Object.defineProperty(exports, "__esModule", {
1565
- value: true
1566
- });
1567
-
1568
- /***/ }),
1569
- /* 51 */
1570
- /***/ (function(module, exports, __webpack_require__) {
1571
-
1572
- "use strict";
1573
-
1574
-
1575
- Object.defineProperty(exports, "__esModule", {
1576
- value: true
1577
- });
1578
-
1579
- /***/ }),
1580
- /* 52 */
1581
- /***/ (function(module, exports, __webpack_require__) {
1582
-
1583
- "use strict";
1584
-
1585
-
1586
- Object.defineProperty(exports, "__esModule", {
1587
- value: true
1588
- });
1589
-
1590
- /***/ }),
1591
- /* 53 */
1592
- /***/ (function(module, exports, __webpack_require__) {
1593
-
1594
- "use strict";
1595
-
1596
-
1597
- Object.defineProperty(exports, "__esModule", {
1598
- value: true
1599
- });
1600
-
1601
- /***/ }),
1602
- /* 54 */
1603
- /***/ (function(module, exports, __webpack_require__) {
1604
-
1605
- "use strict";
1606
-
1607
-
1608
- var _slicedToArray = __webpack_require__(5);
1609
-
1610
- Object.defineProperty(exports, "__esModule", {
1611
- value: true
1612
- });
1613
-
1614
- var React = __webpack_require__(1);
1615
-
1616
- var lodash_1 = __webpack_require__(2);
1617
-
1618
- var getSettingsFromThemedProps_1 = __webpack_require__(55);
1619
-
1620
- var Options_1 = __webpack_require__(16);
1621
-
1622
- var SanitizeProps_1 = __webpack_require__(56);
1623
-
1624
- var TimezoneContext_1 = __webpack_require__(31);
1625
-
1626
- var moment_1 = __webpack_require__(57);
1627
-
1628
- var FeatureFlagContext_1 = __webpack_require__(27);
1629
-
1630
- var styled_components_1 = __webpack_require__(4);
1631
-
1632
- var hocUtils_1 = __webpack_require__(33);
1633
-
1634
- var JSONSchemaUtils_1 = __webpack_require__(34);
1635
-
1636
- var async_dynamic_options_evaluator_1 = __webpack_require__(58);
1637
-
1638
- var id_1 = __webpack_require__(30);
1639
-
1640
- var SplunkVisualization_1 = __webpack_require__(59);
1641
-
1642
- var VizBehavior_1 = __webpack_require__(7);
1643
-
1644
- var getSorting_1 = __webpack_require__(37);
1645
-
1646
- var getPagination_1 = __webpack_require__(38);
1647
-
1648
- var useDeepMemo_1 = __webpack_require__(60);
1649
-
1650
- var MissingPropsMessage_1 = __webpack_require__(61);
1651
-
1652
- var withEditModeCover_1 = __webpack_require__(62);
1653
-
1654
- var withPlaceholder_1 = __webpack_require__(63);
1655
-
1656
- var useDownsampleDataSources_1 = __webpack_require__(64);
1657
-
1658
- var dataUtils_1 = __webpack_require__(14);
1659
-
1660
- var featureFlagUtils_1 = __webpack_require__(66);
1661
- /**
1662
- * hoc that wraps a pure react visualization in a Dashboard visualization
1663
- * @param {DashboardVizOpts} opts
1664
- * @returns {HOC}
1665
- */
1666
-
1667
-
1668
- var withDashboardViz = function withDashboardViz(opts) {
1669
- var ReactViz = opts.ReactViz,
1670
- vizConfig = opts.vizConfig,
1671
- _opts$computeVizProps = opts.computeVizProps,
1672
- computeVizProps = _opts$computeVizProps === void 0 ? function () {} : _opts$computeVizProps,
1673
- disableEditModeCover = opts.disableEditModeCover,
1674
- useIconPlaceholder = opts.useIconPlaceholder; // sanitizing props before sending them to reactviz.
1675
-
1676
- var SanitizedReactViz = (0, SanitizeProps_1.withSanitizedProps)(ReactViz);
1677
- var defaultOptions = (0, JSONSchemaUtils_1.pickFieldFromJSONSchema)(vizConfig.optionsSchema, 'default');
1678
-
1679
- var DashboardViz = function DashboardViz(props) {
1680
- var _a;
1681
-
1682
- var mode = props.mode,
1683
- hasEventHandlers = props.hasEventHandlers,
1684
- dataSources = props.dataSources,
1685
- options = props.options,
1686
- _props$context = props.context,
1687
- context = _props$context === void 0 ? {} : _props$context,
1688
- width = props.width,
1689
- height = props.height,
1690
- onComputedProps = props.onComputedProps,
1691
- onEventTrigger = props.onEventTrigger,
1692
- theme = props.theme,
1693
- onRequestParamsChange = props.onRequestParamsChange;
1694
-
1695
- var _React$useContext = React.useContext(TimezoneContext_1.default),
1696
- serializedTimezone = _React$useContext.serializedTimezone;
1697
-
1698
- if (serializedTimezone) {
1699
- /*
1700
- @splunk/moment currently does not allow us to customize the timezone on a per visualization basis.
1701
- This ensures that if a timezone was provided via TimezoneContext @splunk/moment time formatting
1702
- will use it.
1703
- @TODO(pwied):
1704
- - remove when we moved away from @splunk/moment
1705
- - provide timezone context to dynamic option evaluation phase
1706
- */
1707
- if (!moment_1.default.getDefaultSplunkTimezone()) {
1708
- moment_1.default.setDefaultSplunkTimezone(serializedTimezone);
1709
- }
1710
- }
1711
-
1712
- var themeFunc = function themeFunc(themeVar) {
1713
- var _a, _b;
1714
-
1715
- return (_b = (_a = vizConfig.themes)[themeVar]) === null || _b === void 0 ? void 0 : _b.call(_a, props);
1716
- };
1717
-
1718
- var bgColorFromTheme = themeFunc('defaultBackgroundColor');
1719
-
1720
- var _ref = (0, getSettingsFromThemedProps_1.default)({
1721
- theme: theme
1722
- }),
1723
- currentThemeFamily = _ref.family,
1724
- currentThemeColorScheme = _ref.colorScheme,
1725
- currentThemeDensity = _ref.density;
1726
-
1727
- var evaluatedOptions = {}; // evaluatedOptions need to be initialized as an empty object
1728
-
1729
- var _React$useState = React.useState({}),
1730
- _React$useState2 = _slicedToArray(_React$useState, 2),
1731
- evaluatedOptionsAsync = _React$useState2[0],
1732
- setEvaluatedOptionsAsync = _React$useState2[1]; // evaluatedOptions need to be initialized as an empty object
1733
-
1734
-
1735
- var featureFlagContext = React.useContext(FeatureFlagContext_1.default);
1736
-
1737
- var _React$useState3 = React.useState("".concat(vizConfig.name, " - ").concat((0, id_1.createGUID)())),
1738
- _React$useState4 = _slicedToArray(_React$useState3, 1),
1739
- visualizationID = _React$useState4[0];
1740
-
1741
- var _React$useState5 = React.useState({}),
1742
- _React$useState6 = _slicedToArray(_React$useState5, 2),
1743
- dataSourcesInState = _React$useState6[0],
1744
- setDataSourcesInState = _React$useState6[1];
1745
-
1746
- var _React$useState7 = React.useState(),
1747
- _React$useState8 = _slicedToArray(_React$useState7, 2),
1748
- dataFramesInState = _React$useState8[0],
1749
- setDataFramesInState = _React$useState8[1];
1750
-
1751
- var _React$useState9 = React.useState(Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_useWebWorkersForDSL'))),
1752
- _React$useState10 = _slicedToArray(_React$useState9, 2),
1753
- useAsyncEvaluatedOptions = _React$useState10[0],
1754
- setUseAsyncEvaluatedOptions = _React$useState10[1];
1755
-
1756
- var isDownsamplingEnabledByFeatureFlag = Boolean(featureFlagContext === null || featureFlagContext === void 0 ? void 0 : featureFlagContext.visualizations_enableDownsampling);
1757
- var isMounted = React.useRef(true);
1758
- var optionsToEvaluate = React.useMemo(function () {
1759
- return {
1760
- context: (0, lodash_1.defaultsDeep)({}, context, vizConfig.defaultContext),
1761
- options: (0, hocUtils_1.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
1762
- };
1763
- }, [options, context]);
1764
-
1765
- var _React$useState11 = React.useState(Number(width)),
1766
- _React$useState12 = _slicedToArray(_React$useState11, 2),
1767
- threshold = _React$useState12[0],
1768
- setThreshold = _React$useState12[1];
1769
-
1770
- var onDownsamplingThresholdChange = React.useCallback(function (newThreshold) {
1771
- setThreshold(newThreshold);
1772
- }, []);
1773
- var isDownsamplingEnabled = React.useMemo(function () {
1774
- return isDownsamplingEnabledByFeatureFlag && (0, dataUtils_1.isDownsamplingEnabledForViz)({
1775
- vizConfig: vizConfig
1776
- });
1777
- }, [isDownsamplingEnabledByFeatureFlag]);
1778
- var downsamplingProps = React.useMemo(function () {
1779
- if (!isDownsamplingEnabled) {
1780
- return {};
1781
- }
1782
-
1783
- return {
1784
- onDownsamplingThresholdChange: onDownsamplingThresholdChange,
1785
- originalDataSources: dataSources
1786
- };
1787
- }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
1788
- var downsampledDataSources = (0, useDownsampleDataSources_1.default)({
1789
- options: optionsToEvaluate.options,
1790
- context: optionsToEvaluate.context,
1791
- dataSources: dataSources,
1792
- threshold: threshold,
1793
- isDownsamplingEnabled: isDownsamplingEnabled
1794
- });
1795
- evaluatedOptions = (0, useDeepMemo_1.useDeepMemo)(function () {
1796
- try {
1797
- if (useAsyncEvaluatedOptions) {
1798
- var asyncDynamicOptionsEvaluatorParams = {
1799
- visualizationID: visualizationID,
1800
- props: props,
1801
- options: optionsToEvaluate,
1802
- dataSources: downsampledDataSources,
1803
- theme: vizConfig.themes,
1804
- bypassCloneDeepOptionScope: Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_bypassCloneDeepOptionScope')),
1805
- lazyLoadingDataFrame: Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_lazyLoadingDataFrame'))
1806
- };
1807
- async_dynamic_options_evaluator_1.default.evaluate(asyncDynamicOptionsEvaluatorParams).then(function (results) {
1808
- setEvaluatedOptionsAsync(results.results);
1809
- }).catch(function () {
1810
- if (isMounted.current) {
1811
- setUseAsyncEvaluatedOptions(false);
1812
- }
1813
- });
1814
- } else {
1815
- var dataFrames = dataFramesInState;
1816
-
1817
- if (downsampledDataSources !== dataSourcesInState) {
1818
- setDataSourcesInState(downsampledDataSources);
1819
- dataFrames = Options_1.Options.dataFrameFromDataSource(downsampledDataSources, (0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_lazyLoadingDataFrame'));
1820
- setDataFramesInState(dataFrames);
1821
- }
1822
-
1823
- var result = Options_1.Options.evaluate(optionsToEvaluate, downsampledDataSources, themeFunc, dataFrames, (0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_bypassCloneDeepOptionScope'));
1824
- return result;
1825
- }
1826
- } catch (e) {
1827
- // eslint-disable-next-line no-console
1828
- console.error("unexpected error evaluating options: ".concat(e.message));
1829
- return {};
1830
- }
1831
-
1832
- return {};
1833
- }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, optionsToEvaluate, downsampledDataSources, serializedTimezone, useAsyncEvaluatedOptions]);
1834
- var evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync; // trellis specific backgroundColor update for onComputedProps
1835
- // if trellis is enabled following these three criteria - 1) trellis feature flag is enabled 2) vizConfig supports array has 'trellis' 3) option 'splitByLayout' is set to 'trellis
1836
- // onComputedProps api should return back trellisBackgroundColor value for backgroundColor option to support coloring of sibling panels (for eg:- title/ description on UDF side)
1837
-
1838
- var isTrellisFeatureFlagOn = Boolean(featureFlagContext && featureFlagContext.visualizations_enableTrellis);
1839
- var clonedEvaluatedOptions = evaluatedOptionsToUse;
1840
-
1841
- if (isTrellisFeatureFlagOn && ((_a = vizConfig === null || vizConfig === void 0 ? void 0 : vizConfig.supports) === null || _a === void 0 ? void 0 : _a.includes(VizBehavior_1.VizBehavior.TRELLIS)) && (clonedEvaluatedOptions === null || clonedEvaluatedOptions === void 0 ? void 0 : clonedEvaluatedOptions.splitByLayout) === VizBehavior_1.VizBehavior.TRELLIS) {
1842
- clonedEvaluatedOptions = Object.assign(Object.assign({}, evaluatedOptionsToUse), {
1843
- backgroundColor: clonedEvaluatedOptions === null || clonedEvaluatedOptions === void 0 ? void 0 : clonedEvaluatedOptions.trellisBackgroundColor
1844
- });
1845
- } // useEffect hook needs to be initialized before any early returns
1846
- // this is in accordance with the order of hook calls being the same on each render https://reactjs.org/docs/hooks-rules.html#explanation
1847
-
1848
-
1849
- React.useEffect(function () {
1850
- onComputedProps(clonedEvaluatedOptions);
1851
- });
1852
- React.useEffect(function () {
1853
- return function () {
1854
- if (useAsyncEvaluatedOptions) {
1855
- isMounted.current = false;
1856
- async_dynamic_options_evaluator_1.default.reset(visualizationID);
1857
- }
1858
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
1859
- }, []); // present warning message if any required props are missing
1860
-
1861
- var _vizConfig$requiredPr = vizConfig.requiredProps,
1862
- requiredProps = _vizConfig$requiredPr === void 0 ? [] : _vizConfig$requiredPr,
1863
- supports = vizConfig.supports;
1864
- var missing = (0, MissingPropsMessage_1.missingKeys)(requiredProps, evaluatedOptionsToUse);
1865
-
1866
- if (missing.length > 0 && supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER) && vizConfig.key !== 'splunk.singlevalue' // For SV missing props msg is not displayed if required props majorValue is missing, instead this will be handled from the component, instead handled within component
1867
- ) {
1868
- return React.createElement(MissingPropsMessage_1.default, {
1869
- "data-test": "missing-props-message",
1870
- width: width,
1871
- height: height,
1872
- missingProps: missing,
1873
- backgroundColor: bgColorFromTheme
1874
- });
1875
- } // events
1876
-
1877
-
1878
- var eventCallbackProps = {};
1879
-
1880
- if (hasEventHandlers && mode === 'view' && vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.EVENTS) > -1) {
1881
- var supportedEvents = vizConfig.events;
1882
- Object.keys(supportedEvents).forEach(function (eventName) {
1883
- var _supportedEvents$even = supportedEvents[eventName],
1884
- parentKeys = _supportedEvents$even.parentKeys,
1885
- payloadKeys = _supportedEvents$even.payloadKeys;
1886
- var eventCallbackPropName = (0, lodash_1.camelCase)("on.".concat(eventName)); // todo: refactor single value and single value icon to send payload from viz
1887
- // then remove these lines
1888
-
1889
- var payload = {};
1890
-
1891
- if (Array.isArray(payloadKeys) && payloadKeys.length) {
1892
- payloadKeys.forEach(function (p) {
1893
- payload[p] = evaluatedOptionsToUse[p];
1894
- });
1895
- }
1896
-
1897
- eventCallbackProps[eventCallbackPropName] = function (ev) {
1898
- if (ev && ev.payload) {
1899
- payload = ev.payload;
1900
- }
1901
-
1902
- return onEventTrigger({
1903
- originalEvent: ev,
1904
- payload: payload,
1905
- type: eventName
1906
- });
1907
- };
1908
-
1909
- if (parentKeys) {
1910
- for (var i = parentKeys.length - 1; i >= 0; i -= 1) {
1911
- var newObject = {};
1912
- newObject[parentKeys[i]] = eventCallbackProps[eventCallbackPropName];
1913
- eventCallbackProps[eventCallbackPropName] = newObject;
1914
- }
1915
- }
1916
- });
1917
- } // compute pure viz props which are not from options
1918
-
1919
-
1920
- var computedVizProps = computeVizProps(Object.assign(Object.assign(Object.assign(Object.assign({}, props), evaluatedOptionsToUse), eventCallbackProps), {
1921
- themeFunc: themeFunc
1922
- }));
1923
- /**
1924
- * PAGE_AND_SORT behavior
1925
- *
1926
- * Some visualizations, like table, requires metadata about the datasource,
1927
- * like total number of results, current count, offset, and sort, for rendering
1928
- * paginator and sorting direction. In this approach, the visualization
1929
- * allow users to set 'paginateDataSourceKey' to select which datasource
1930
- * should the visualization extract the metadata from. It defaults to 'primary' datasource.
1931
- * The visualization config should set the PAGE_AND_SORT behavior to receive
1932
- * 'requestParams', 'meta' and onRequestParams callback as props.
1933
- *
1934
- * In future, we could automatically detect which all datasources are being used
1935
- * and bind those magically to pagination/sorting behavior.
1936
- */
1937
-
1938
- var dataSourceMetadata = {};
1939
- var OptionKey = 'paginateDataSourceKey';
1940
- var paginateDataSourceKey = (0, lodash_1.has)(evaluatedOptionsToUse, OptionKey) && evaluatedOptionsToUse[OptionKey] || 'primary';
1941
-
1942
- if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.PAGE_AND_SORT) > -1 && (0, lodash_1.has)(dataSources, paginateDataSourceKey)) {
1943
- var requestParams = (0, lodash_1.get)(dataSources, [paginateDataSourceKey, 'requestParams'], {});
1944
- var meta = (0, lodash_1.get)(dataSources, [paginateDataSourceKey, 'meta'], {});
1945
-
1946
- var handleRequestParamsChange = function handleRequestParamsChange(payload) {
1947
- return onRequestParamsChange(paginateDataSourceKey, payload);
1948
- };
1949
-
1950
- var sortParams = (0, getSorting_1.getSortingParams)({
1951
- requestParams: requestParams,
1952
- meta: meta,
1953
- onRequestParamsChange: handleRequestParamsChange
1954
- });
1955
- var paginatorParams = (0, getPagination_1.getPaginationParams)({
1956
- requestParams: requestParams,
1957
- meta: meta,
1958
- onRequestParamsChange: handleRequestParamsChange
1959
- });
1960
- dataSourceMetadata = {
1961
- sortParams: sortParams,
1962
- paginatorParams: paginatorParams
1963
- };
1964
- } // if were using webworkers and this is the first render we dont want to show a viz with missing data so we return null
1965
-
1966
-
1967
- if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
1968
- return null;
1969
- }
1970
-
1971
- return React.createElement(SanitizedReactViz, Object.assign({
1972
- mode: mode,
1973
- width: width,
1974
- height: height
1975
- }, downsamplingProps, evaluatedOptionsToUse, computedVizProps, eventCallbackProps, dataSourceMetadata));
1976
- };
1977
-
1978
- DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
1979
- DashboardViz.defaultProps = Object.assign(Object.assign(Object.assign({}, SplunkVisualization_1.default.defaultProps), ReactViz.defaultProps), {
1980
- // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
1981
- theme: {}
1982
- }); // attach viz config
1983
-
1984
- DashboardViz.config = vizConfig; // @ts-ignore: TODO fix sc upgrade TS issues
1985
-
1986
- return (0, styled_components_1.withTheme)((0, withPlaceholder_1.default)((0, withEditModeCover_1.default)(DashboardViz, disableEditModeCover), useIconPlaceholder));
1987
- };
1988
-
1989
- exports.default = withDashboardViz;
1990
-
1991
- /***/ }),
1992
- /* 55 */
1993
- /***/ (function(module, exports) {
1994
-
1995
- module.exports = require("@splunk/themes/getSettingsFromThemedProps");
1996
-
1997
- /***/ }),
1998
- /* 56 */
1999
- /***/ (function(module, exports) {
2000
-
2001
- module.exports = require("@splunk/visualizations-shared/SanitizeProps");
2002
-
2003
- /***/ }),
2004
- /* 57 */
2005
- /***/ (function(module, exports) {
2006
-
2007
- module.exports = require("@splunk/moment");
2008
-
2009
- /***/ }),
2010
- /* 58 */
2011
- /***/ (function(module, exports) {
2012
-
2013
- module.exports = require("@splunk/async-dynamic-options-evaluator");
2014
-
2015
- /***/ }),
2016
- /* 59 */
2017
- /***/ (function(module, exports, __webpack_require__) {
2018
-
2019
- "use strict";
2020
-
2021
-
2022
- var _classCallCheck = __webpack_require__(8);
2023
-
2024
- Object.defineProperty(exports, "__esModule", {
2025
- value: true
2026
- });
2027
- exports.INITIAL_HEIGHT = exports.INITIAL_WIDTH = void 0;
2028
- /* eslint-disable react/no-unused-prop-types,react/prefer-stateless-function */
2029
-
2030
- var T = __webpack_require__(0);
2031
-
2032
- var lodash_1 = __webpack_require__(2);
2033
-
2034
- var VizActionHandler_1 = __webpack_require__(21); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
2035
-
2036
-
2037
- exports.INITIAL_WIDTH = 250;
2038
- exports.INITIAL_HEIGHT = 250;
2039
- /**
2040
- * A Splunk visualization
2041
- */
2042
-
2043
- var SplunkVisualization = function SplunkVisualization() {
2044
- _classCallCheck(this, SplunkVisualization);
2045
- };
2046
-
2047
- SplunkVisualization.propTypes = {
2048
- /**
2049
- * display mode
2050
- */
2051
- mode: T.oneOf(['view', 'edit', 'export']).isRequired,
2052
-
2053
- /**
2054
- * width in pixel or string, defaults to 100%
2055
- */
2056
- width: T.oneOfType([T.string, T.number]).isRequired,
2057
-
2058
- /**
2059
- * height in pixel or string
2060
- */
2061
- height: T.oneOfType([T.string, T.number]).isRequired,
2062
-
2063
- /**
2064
- * visualization context used for dynamic option evaluation
2065
- */
2066
- context: T.object,
2067
-
2068
- /**
2069
- * visualization formatting options
2070
- */
2071
- options: T.object,
2072
-
2073
- /**
2074
- * A callback to update formatting options
2075
- */
2076
- onOptionsChange: T.func,
2077
-
2078
- /**
2079
- * datasource state which include data and request params, object key indicate the datasource type.
2080
- */
2081
- dataSources: T.objectOf(T.shape({
2082
- /**
2083
- * current request params
2084
- */
2085
- requestParams: T.object,
2086
-
2087
- /**
2088
- * current dataset
2089
- */
2090
- data: T.shape({
2091
- fields: T.array,
2092
- columns: T.array
2093
- }),
2094
-
2095
- /**
2096
- * error
2097
- */
2098
- error: T.shape({
2099
- level: T.string,
2100
- message: T.string
2101
- }),
2102
-
2103
- /**
2104
- * meta data that came with the dataset
2105
- */
2106
- meta: T.object
2107
- })),
2108
-
2109
- /**
2110
- * A callback to trigger event
2111
- */
2112
- onEventTrigger: T.func,
2113
-
2114
- /**
2115
- * Inform viz if there are handlers listening to events
2116
- */
2117
- hasEventHandlers: T.bool,
2118
-
2119
- /**
2120
- * A callback to communicate computed props to a consumer
2121
- */
2122
- onComputedProps: T.func,
2123
-
2124
- /**
2125
- * A callback to obtain visualization api
2126
- */
2127
- vizActionHandlerRef: T.func,
2128
- loading: T.bool,
2129
- theme: T.object,
2130
-
2131
- /**
2132
- * A callback to request new data with updated request params
2133
- */
2134
- onRequestParamsChange: T.func
2135
- };
2136
- /**
2137
- *
2138
- */
2139
-
2140
- SplunkVisualization.defaultProps = {
2141
- // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
2142
- width: '100%',
2143
- height: exports.INITIAL_HEIGHT,
2144
- dataSources: {},
2145
- onEventTrigger: function onEventTrigger() {
2146
- return {};
2147
- },
2148
- mode: 'view',
2149
- hasEventHandlers: false,
2150
- options: {},
2151
- context: {},
2152
- onOptionsChange: function onOptionsChange() {
2153
- return {};
2154
- },
2155
- vizActionHandlerRef: function vizActionHandlerRef() {
2156
- return new VizActionHandler_1.DefaultVizActionHandler();
2157
- },
2158
- onComputedProps: function onComputedProps() {
2159
- return {};
2160
- },
2161
- loading: false,
2162
- onRequestParamsChange: lodash_1.noop
2163
- };
2164
- exports.default = SplunkVisualization;
2165
-
2166
- /***/ }),
2167
- /* 60 */
2168
- /***/ (function(module, exports, __webpack_require__) {
2169
-
2170
- "use strict";
2171
-
2172
-
2173
- Object.defineProperty(exports, "__esModule", {
2174
- value: true
2175
- });
2176
- exports.useDeepMemo = void 0;
2177
-
2178
- var react_1 = __webpack_require__(1);
2179
-
2180
- var lodash_1 = __webpack_require__(2);
2181
- /**
2182
- * This hook evaluates and stores the result of a passed function and only
2183
- * re-evaluates the function when passed dependencies change.
2184
- *
2185
- * It is different from the internal React useMemo in the following aspects:
2186
- * - it only stores the last evaluated result
2187
- * - it uses a deep equality check to determine if dependencies have changed
2188
- *
2189
- * Inspired by apollo-client's useDeepMemo
2190
- *
2191
- * @param fn the function to be executed and
2192
- * @param dependencies an array of dependencies
2193
- */
2194
-
2195
-
2196
- var useDeepMemo = function useDeepMemo(fn, dependencies) {
2197
- var ref = (0, react_1.useRef)();
2198
-
2199
- if (!ref.current || !(0, lodash_1.isEqual)(dependencies, ref.current.dependencies)) {
2200
- ref.current = {
2201
- dependencies: dependencies,
2202
- value: fn()
2203
- };
2204
- }
2205
-
2206
- return ref.current.value;
2207
- };
2208
-
2209
- exports.useDeepMemo = useDeepMemo;
2210
-
2211
- /***/ }),
2212
- /* 61 */
2213
- /***/ (function(module, exports, __webpack_require__) {
2214
-
2215
- "use strict";
2216
-
2217
-
2218
- Object.defineProperty(exports, "__esModule", {
2219
- value: true
2220
- });
2221
- exports.MissingPropsMessage = exports.missingKeys = exports.isMissing = void 0;
2222
-
2223
- var React = __webpack_require__(1);
2224
-
2225
- var T = __webpack_require__(0);
2226
-
2227
- var i18n_1 = __webpack_require__(3);
2228
-
2229
- var Message_1 = __webpack_require__(11);
2230
-
2231
- var FixedSizeContainer_1 = __webpack_require__(17);
2232
- /**
2233
- * @method isMissing
2234
- * @param {any} v
2235
- * @returns {boolean} true if the input value === null or undefined
2236
- */
2237
-
2238
-
2239
- var isMissing = function isMissing(v) {
2240
- return v === null || v === undefined;
2241
- };
2242
-
2243
- exports.isMissing = isMissing;
2244
- /**
2245
- * @method misskingKeys
2246
- * @param {string[]} keys
2247
- * @param {object} target
2248
- * @returns {string[]} the keys of missing required props
2249
- */
2250
-
2251
- var missingKeys = function missingKeys(keys, target) {
2252
- return keys.filter(function (k) {
2253
- return (0, exports.isMissing)(target[k]);
2254
- });
2255
- };
2256
-
2257
- exports.missingKeys = missingKeys;
2258
- var propTypes = {
2259
- width: T.oneOfType([T.string, T.number]),
2260
- height: T.oneOfType([T.string, T.number]),
2261
- // eslint-disable-next-line react/no-unused-prop-types
2262
- backgroundColor: T.string,
2263
- missingProps: T.arrayOf(T.string)
2264
- };
2265
- /**
2266
- * @method MissingPropsMessage
2267
- * @param {MissingPropsProps} props
2268
- * @returns {React.ReactElement}
2269
- */
2270
-
2271
- var MissingPropsMessage = function MissingPropsMessage(props) {
2272
- var width = props.width,
2273
- height = props.height,
2274
- missingProps = props.missingProps;
2275
- return React.createElement(Message_1.default, {
2276
- "data-test": "message",
2277
- width: width,
2278
- height: height,
2279
- message: (0, i18n_1._)("Missing property: ".concat(missingProps.join(', ')))
2280
- });
2281
- };
2282
-
2283
- exports.MissingPropsMessage = MissingPropsMessage;
2284
- exports.MissingPropsMessage.propTypes = propTypes;
2285
- exports.MissingPropsMessage.defaultProps = {
2286
- width: '100%',
2287
- height: 250
2288
- };
2289
- exports.default = (0, FixedSizeContainer_1.default)(exports.MissingPropsMessage);
2290
-
2291
- /***/ }),
2292
- /* 62 */
2293
- /***/ (function(module, exports, __webpack_require__) {
2294
-
2295
- "use strict";
2296
-
2297
-
2298
- Object.defineProperty(exports, "__esModule", {
2299
- value: true
2300
- });
2301
-
2302
- var React = __webpack_require__(1);
2303
-
2304
- var styled_components_1 = __webpack_require__(4);
2305
-
2306
- var hocUtils_1 = __webpack_require__(23);
2307
-
2308
- var Cover = styled_components_1.default.div.withConfig({
2309
- displayName: "withEditModeCover__Cover",
2310
- componentId: "sc-1gsbnxb-0"
2311
- })(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
2312
- var Blocker = styled_components_1.default.div.attrs({
2313
- 'data-splunk-visualization-version': "26.4.1 - 2b7482c08"
2314
- }).withConfig({
2315
- displayName: "withEditModeCover__Blocker",
2316
- componentId: "sc-1gsbnxb-1"
2317
- })(["position:relative;width:100%;height:100%;"]);
2318
- /**
2319
- * HOC that renders a cover layer in edit mode
2320
- * @method withEditModeCover
2321
- * @param {ExtendedDashViz} Visualization
2322
- * @returns {ExtendedDashViz} Wrapper
2323
- */
2324
-
2325
- var withEditModeCover = function withEditModeCover(Visualization, disableEditModeCover) {
2326
- var Wrapper = function Wrapper(props) {
2327
- var mode = props.mode;
2328
- var showEditCover = mode === 'edit' && !disableEditModeCover;
2329
- return React.createElement(Blocker, null, React.createElement(Visualization, Object.assign({}, props)), showEditCover && React.createElement(Cover, {
2330
- "data-test": "edit-mode-cover"
2331
- }));
2332
- };
2333
-
2334
- (0, hocUtils_1.extendStaticWrapperProps)({
2335
- Wrapper: Wrapper,
2336
- Visualization: Visualization
2337
- });
2338
- return Wrapper;
2339
- };
2340
-
2341
- exports.default = withEditModeCover;
2342
-
2343
- /***/ }),
2344
- /* 63 */
2345
- /***/ (function(module, exports, __webpack_require__) {
2346
-
2347
- "use strict";
2348
-
2349
-
2350
- Object.defineProperty(exports, "__esModule", {
2351
- value: true
2352
- });
2353
-
2354
- var React = __webpack_require__(1);
2355
-
2356
- var colorUtils_1 = __webpack_require__(15);
2357
-
2358
- var variables_1 = __webpack_require__(13);
2359
-
2360
- var IconPlaceholder_1 = __webpack_require__(36);
2361
-
2362
- var VizBehavior_1 = __webpack_require__(7);
2363
-
2364
- var hocUtils_1 = __webpack_require__(23);
2365
-
2366
- var withPlaceholder = function withPlaceholder(Visualization) {
2367
- var useIconPlaceholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IconPlaceholder_1.shouldShowIconPlaceholder;
2368
- var config = Visualization.config;
2369
- var themes = config.themes;
2370
-
2371
- var Wrapper = function Wrapper(props) {
2372
- var _a, _b;
2373
-
2374
- var dataSources = props.dataSources,
2375
- loading = props.loading,
2376
- options = props.options,
2377
- height = props.height,
2378
- width = props.width;
2379
- var showPlaceholder = useIconPlaceholder(dataSources, loading, options);
2380
- var bgColorFromTheme = (0, colorUtils_1.isColor)(options === null || options === void 0 ? void 0 : options.backgroundColor) ? options === null || options === void 0 ? void 0 : options.backgroundColor : (_a = themes === null || themes === void 0 ? void 0 : themes.defaultBackgroundColor) === null || _a === void 0 ? void 0 : _a.call(themes, props);
2381
- var icon = (_b = config.placeholderIcon) !== null && _b !== void 0 ? _b : config.icon;
2382
- var iconColor = variables_1.default.contentColorActive(props);
2383
-
2384
- if (config.supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER) && showPlaceholder) {
2385
- return React.createElement(IconPlaceholder_1.default, {
2386
- "data-test": "icon-placeholder",
2387
- icon: icon,
2388
- width: width,
2389
- height: height,
2390
- backgroundColor: bgColorFromTheme,
2391
- iconColor: iconColor
2392
- });
2393
- }
2394
-
2395
- return React.createElement(Visualization, Object.assign({}, props));
2396
- };
2397
-
2398
- (0, hocUtils_1.extendStaticWrapperProps)({
2399
- Wrapper: Wrapper,
2400
- Visualization: Visualization
2401
- });
2402
- return Wrapper;
2403
- };
2404
-
2405
- exports.default = withPlaceholder;
2406
-
2407
- /***/ }),
2408
- /* 64 */
2409
- /***/ (function(module, exports, __webpack_require__) {
2410
-
2411
- "use strict";
2412
-
2413
-
2414
- var _slicedToArray = __webpack_require__(5);
2415
-
2416
- Object.defineProperty(exports, "__esModule", {
2417
- value: true
2418
- });
2419
-
2420
- var react_1 = __webpack_require__(1);
2421
-
2422
- var lodash_1 = __webpack_require__(2);
2423
-
2424
- var dataUtils_1 = __webpack_require__(14);
2425
-
2426
- var usePrevious_1 = __webpack_require__(32);
2427
-
2428
- var useGetXAndYFields_1 = __webpack_require__(65); // Options properties which impact/require re-downsample on change.
2429
-
2430
-
2431
- var downsampleVizOptionProperties = ['nullValueDisplay'];
2432
-
2433
- var useDownsampleDataSources = function useDownsampleDataSources(_ref) {
2434
- var dataSources = _ref.dataSources,
2435
- options = _ref.options,
2436
- context = _ref.context,
2437
- threshold = _ref.threshold,
2438
- isDownsamplingEnabled = _ref.isDownsamplingEnabled;
2439
- var isFirstUseEffectCall = (0, react_1.useRef)(true);
2440
- var xAndYFieldsWithTypes = (0, useGetXAndYFields_1.default)({
2441
- shouldEvaluateDSL: isDownsamplingEnabled,
2442
- options: options,
2443
- context: context,
2444
- dataSources: dataSources
2445
- }); // Extract viz options that impact downsampling.
2446
-
2447
- var downsampleVizOptions = (0, react_1.useMemo)(function () {
2448
- return (0, lodash_1.pick)(options, downsampleVizOptionProperties);
2449
- }, [options]);
2450
- var downsampleDSOptions = (0, react_1.useMemo)(function () {
2451
- return Object.assign(Object.assign({}, downsampleVizOptions), xAndYFieldsWithTypes);
2452
- }, [xAndYFieldsWithTypes, downsampleVizOptions]);
2453
- var previousDownsampleDSOptions = (0, usePrevious_1.default)(downsampleDSOptions);
2454
- var previousDataSources = (0, usePrevious_1.default)(dataSources);
2455
- var previousThreshold = (0, usePrevious_1.default)(threshold);
2456
-
2457
- var _ref2 = (0, react_1.useState)(function () {
2458
- return isDownsamplingEnabled ? (0, dataUtils_1.downsampleDataSources)({
2459
- dataSources: dataSources,
2460
- threshold: threshold,
2461
- options: downsampleDSOptions
2462
- }) : dataSources;
2463
- }),
2464
- _ref3 = _slicedToArray(_ref2, 2),
2465
- downsampledDataSources = _ref3[0],
2466
- setDownsampledDataSources = _ref3[1];
2467
-
2468
- var debouncedDownsampleDataSources = (0, react_1.useMemo)(function () {
2469
- return (0, lodash_1.debounce)(function (downsampleOptions) {
2470
- var downsampledResult = (0, dataUtils_1.downsampleDataSources)(downsampleOptions);
2471
- setDownsampledDataSources(downsampledResult);
2472
- }, 100, {
2473
- trailing: true
2474
- });
2475
- }, []);
2476
- (0, react_1.useEffect)(function () {
2477
- // don't downsample again on the use effect call that happened due to the initial render
2478
- // this is since we already downsampled as part of the useState call
2479
- if (isFirstUseEffectCall.current) {
2480
- isFirstUseEffectCall.current = false;
2481
- return;
2482
- }
2483
-
2484
- if (!isDownsamplingEnabled) {
2485
- setDownsampledDataSources(dataSources);
2486
- return;
2487
- }
2488
-
2489
- if ((0, lodash_1.isEqual)(previousDownsampleDSOptions, downsampleDSOptions) && previousDataSources === dataSources && previousThreshold === threshold) {
2490
- return;
2491
- } // Debounce the downsampling so we don't have to downsample and execute DSL multiple times
2492
- // while the viz is being resized
2493
-
2494
-
2495
- debouncedDownsampleDataSources({
2496
- dataSources: dataSources,
2497
- options: downsampleDSOptions,
2498
- threshold: threshold
2499
- }); // need to detect if this runs as part of the initial render
2500
- }, [dataSources, downsampleDSOptions, debouncedDownsampleDataSources, xAndYFieldsWithTypes, threshold, isDownsamplingEnabled, previousDataSources, previousThreshold, previousDownsampleDSOptions]);
2501
- return downsampledDataSources;
2502
- };
2503
-
2504
- exports.default = useDownsampleDataSources;
2505
-
2506
- /***/ }),
2507
- /* 65 */
2508
- /***/ (function(module, exports, __webpack_require__) {
2509
-
2510
- "use strict";
2511
-
2512
-
2513
- var _toConsumableArray = __webpack_require__(6);
2514
-
2515
- Object.defineProperty(exports, "__esModule", {
2516
- value: true
2517
- });
2518
-
2519
- var react_1 = __webpack_require__(1);
2520
-
2521
- var Options_1 = __webpack_require__(16);
2522
- /**
2523
- * Hook that evaluates the DSL for subset of a viz's options needed to determine
2524
- * its x and y fields as well as the types of all its fields.
2525
- */
2526
-
2527
-
2528
- var useGetXAndYFields = function useGetXAndYFields(_ref) {
2529
- var shouldEvaluateDSL = _ref.shouldEvaluateDSL,
2530
- options = _ref.options,
2531
- context = _ref.context,
2532
- dataSources = _ref.dataSources;
2533
-
2534
- var _ref2 = (0, react_1.useMemo)(function () {
2535
- var _a, _b, _c;
2536
-
2537
- if (!shouldEvaluateDSL) {
2538
- return {
2539
- dataSourcesWithOnlyOnePoint: null,
2540
- dataFrameWithOnlyOnePoint: null
2541
- };
2542
- }
2543
-
2544
- if (!((_c = (_b = (_a = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.columns) === null || _c === void 0 ? void 0 : _c.length)) {
2545
- return {
2546
- dataSourcesWithOnlyOnePoint: null,
2547
- dataFrameWithOnlyOnePoint: null
2548
- };
2549
- }
2550
-
2551
- var primaryDS = dataSources.primary;
2552
- var columnsWithOnlyOnePoint = primaryDS.data.columns.map(function (column) {
2553
- return [column[0]];
2554
- });
2555
- var filteredDataSources = {
2556
- primary: Object.assign(Object.assign({}, primaryDS), {
2557
- data: Object.assign(Object.assign({}, primaryDS.data), {
2558
- columns: columnsWithOnlyOnePoint
2559
- })
2560
- })
2561
- };
2562
- return {
2563
- dataSourcesWithOnlyOnePoint: filteredDataSources,
2564
- dataFrameWithOnlyOnePoint: Options_1.Options.dataFrameFromDataSource(filteredDataSources)
2565
- };
2566
- }, [dataSources, shouldEvaluateDSL]),
2567
- dataSourcesWithOnlyOnePoint = _ref2.dataSourcesWithOnlyOnePoint,
2568
- dataFrameWithOnlyOnePoint = _ref2.dataFrameWithOnlyOnePoint;
2569
-
2570
- var xAndYFieldsWithTypes = (0, react_1.useMemo)(function () {
2571
- try {
2572
- if (!dataSourcesWithOnlyOnePoint || !dataFrameWithOnlyOnePoint) {
2573
- return options;
1168
+ // src/common/withDashboardViz.tsx
1169
+ var withDashboardViz = (opts) => {
1170
+ const {
1171
+ ReactViz,
1172
+ vizConfig,
1173
+ computeVizProps: computeVizProps2 = () => {
1174
+ },
1175
+ disableEditModeCover,
1176
+ useIconPlaceholder
1177
+ } = opts;
1178
+ const SanitizedReactViz = (0, SanitizeProps_exports.withSanitizedProps)(ReactViz);
1179
+ const defaultOptions = (0, JSONSchemaUtils_exports.pickFieldFromJSONSchema)(vizConfig.optionsSchema, "default");
1180
+ const DashboardViz = (props) => {
1181
+ var _a;
1182
+ const {
1183
+ mode,
1184
+ hasEventHandlers,
1185
+ dataSources,
1186
+ // type of { [key: string]: DataSource }
1187
+ options,
1188
+ context = {},
1189
+ width,
1190
+ height,
1191
+ onComputedProps,
1192
+ onEventTrigger,
1193
+ theme,
1194
+ onRequestParamsChange
1195
+ } = props;
1196
+ const { serializedTimezone } = react_exports.useContext(TimezoneContext_default);
1197
+ if (serializedTimezone) {
1198
+ if (!moment_default.getDefaultSplunkTimezone()) {
1199
+ moment_default.setDefaultSplunkTimezone(serializedTimezone);
2574
1200
  }
2575
-
2576
- if (!(options === null || options === void 0 ? void 0 : options.x) || !(options === null || options === void 0 ? void 0 : options.y) && !(options === null || options === void 0 ? void 0 : options.y2)) {
2577
- return options;
1201
+ }
1202
+ const themeFunc = (themeVar) => {
1203
+ var _a2, _b;
1204
+ return (_b = (_a2 = vizConfig.themes)[themeVar]) == null ? void 0 : _b.call(_a2, props);
1205
+ };
1206
+ const bgColorFromTheme = themeFunc("defaultBackgroundColor");
1207
+ const {
1208
+ family: currentThemeFamily,
1209
+ colorScheme: currentThemeColorScheme,
1210
+ density: currentThemeDensity
1211
+ } = getSettingsFromThemedProps_default({ theme });
1212
+ let evaluatedOptions = {};
1213
+ const [evaluatedOptionsAsync, setEvaluatedOptionsAsync] = react_exports.useState({});
1214
+ const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
1215
+ const [visualizationID] = react_exports.useState(`${vizConfig.name} - ${(0, id_exports.createGUID)()}`);
1216
+ const [dataSourcesInState, setDataSourcesInState] = react_exports.useState({});
1217
+ const [dataFramesInState, setDataFramesInState] = react_exports.useState();
1218
+ const [useAsyncEvaluatedOptions, setUseAsyncEvaluatedOptions] = react_exports.useState(
1219
+ Boolean(getFeatureFlag(featureFlagContext, "visualizations_useWebWorkersForDSL"))
1220
+ );
1221
+ const isDownsamplingEnabledByFeatureFlag = Boolean(
1222
+ featureFlagContext == null ? void 0 : featureFlagContext.visualizations_enableDownsampling
1223
+ );
1224
+ const isMounted = react_exports.useRef(true);
1225
+ const optionsToEvaluate = react_exports.useMemo(
1226
+ () => ({
1227
+ context: (0, lodash_exports.defaultsDeep)({}, context, vizConfig.defaultContext),
1228
+ options: (0, hocUtils_exports.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
1229
+ }),
1230
+ [options, context]
1231
+ );
1232
+ const [threshold, setThreshold] = react_exports.useState(Number(width));
1233
+ const onDownsamplingThresholdChange = react_exports.useCallback((newThreshold) => {
1234
+ setThreshold(newThreshold);
1235
+ }, []);
1236
+ const isDownsamplingEnabled = react_exports.useMemo(() => {
1237
+ return isDownsamplingEnabledByFeatureFlag && isDownsamplingEnabledForViz({ vizConfig });
1238
+ }, [isDownsamplingEnabledByFeatureFlag]);
1239
+ const downsamplingProps = react_exports.useMemo(() => {
1240
+ if (!isDownsamplingEnabled) {
1241
+ return {};
2578
1242
  }
2579
-
2580
- var optionsToEvaluate = {
2581
- x: options.x,
2582
- xField: '> x | getField()',
2583
- y: options.y,
2584
- yFields: options.y ? '> y | getField()' : undefined,
2585
- y2: options.y2,
2586
- y2Fields: options.y2 ? '> y2 | getField()' : undefined,
2587
- fieldTypes: '> primary | getType()'
2588
- };
2589
-
2590
- var _Options_1$Options$ev = Options_1.Options.evaluate({
2591
- options: optionsToEvaluate,
2592
- context: context
2593
- }, dataSourcesWithOnlyOnePoint, function () {}, dataFrameWithOnlyOnePoint),
2594
- _Options_1$Options$ev2 = _Options_1$Options$ev.xField,
2595
- xField = _Options_1$Options$ev2 === void 0 ? '' : _Options_1$Options$ev2,
2596
- _Options_1$Options$ev3 = _Options_1$Options$ev.yFields,
2597
- yFields = _Options_1$Options$ev3 === void 0 ? [] : _Options_1$Options$ev3,
2598
- _Options_1$Options$ev4 = _Options_1$Options$ev.y2Fields,
2599
- y2Fields = _Options_1$Options$ev4 === void 0 ? [] : _Options_1$Options$ev4,
2600
- fieldTypes = _Options_1$Options$ev.fieldTypes;
2601
-
2602
1243
  return {
2603
- xField: xField,
2604
- yFields: [].concat(_toConsumableArray(yFields), _toConsumableArray(y2Fields)),
2605
- fieldTypes: fieldTypes
1244
+ onDownsamplingThresholdChange,
1245
+ originalDataSources: dataSources
2606
1246
  };
2607
- } catch (e) {
2608
- return {
2609
- xField: undefined,
2610
- yFields: [],
2611
- fieldTypes: []
1247
+ }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
1248
+ const downsampledDataSources = useDownsampleDataSources_default({
1249
+ options: optionsToEvaluate.options,
1250
+ context: optionsToEvaluate.context,
1251
+ dataSources,
1252
+ threshold,
1253
+ isDownsamplingEnabled
1254
+ });
1255
+ evaluatedOptions = useDeepMemo(() => {
1256
+ try {
1257
+ if (useAsyncEvaluatedOptions) {
1258
+ const asyncDynamicOptionsEvaluatorParams = {
1259
+ visualizationID,
1260
+ props,
1261
+ options: optionsToEvaluate,
1262
+ dataSources: downsampledDataSources,
1263
+ theme: vizConfig.themes,
1264
+ bypassCloneDeepOptionScope: Boolean(
1265
+ getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
1266
+ ),
1267
+ lazyLoadingDataFrame: Boolean(
1268
+ getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
1269
+ )
1270
+ };
1271
+ async_dynamic_options_evaluator_default.evaluate(asyncDynamicOptionsEvaluatorParams).then((results) => {
1272
+ setEvaluatedOptionsAsync(results.results);
1273
+ }).catch(() => {
1274
+ if (isMounted.current) {
1275
+ setUseAsyncEvaluatedOptions(false);
1276
+ }
1277
+ });
1278
+ } else {
1279
+ let dataFrames = dataFramesInState;
1280
+ if (downsampledDataSources !== dataSourcesInState) {
1281
+ setDataSourcesInState(downsampledDataSources);
1282
+ dataFrames = Options_exports.Options.dataFrameFromDataSource(
1283
+ downsampledDataSources,
1284
+ getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
1285
+ );
1286
+ setDataFramesInState(dataFrames);
1287
+ }
1288
+ const result = Options_exports.Options.evaluate(
1289
+ optionsToEvaluate,
1290
+ downsampledDataSources,
1291
+ themeFunc,
1292
+ dataFrames,
1293
+ getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
1294
+ );
1295
+ return result;
1296
+ }
1297
+ } catch (e) {
1298
+ console.error(`unexpected error evaluating options: ${e.message}`);
1299
+ return {};
1300
+ }
1301
+ return {};
1302
+ }, [
1303
+ currentThemeFamily,
1304
+ currentThemeColorScheme,
1305
+ currentThemeDensity,
1306
+ optionsToEvaluate,
1307
+ downsampledDataSources,
1308
+ serializedTimezone,
1309
+ useAsyncEvaluatedOptions
1310
+ ]);
1311
+ const evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync;
1312
+ const isTrellisFeatureFlagOn = Boolean(
1313
+ featureFlagContext && featureFlagContext.visualizations_enableTrellis
1314
+ );
1315
+ let clonedEvaluatedOptions = evaluatedOptionsToUse;
1316
+ if (isTrellisFeatureFlagOn && ((_a = vizConfig == null ? void 0 : vizConfig.supports) == null ? void 0 : _a.includes("trellis" /* TRELLIS */)) && (clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.splitByLayout) === "trellis" /* TRELLIS */) {
1317
+ clonedEvaluatedOptions = __spreadProps(__spreadValues({}, evaluatedOptionsToUse), {
1318
+ backgroundColor: clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.trellisBackgroundColor
1319
+ });
1320
+ }
1321
+ react_exports.useEffect(() => {
1322
+ onComputedProps(clonedEvaluatedOptions);
1323
+ });
1324
+ react_exports.useEffect(() => {
1325
+ return () => {
1326
+ if (useAsyncEvaluatedOptions) {
1327
+ isMounted.current = false;
1328
+ async_dynamic_options_evaluator_default.reset(visualizationID);
1329
+ }
2612
1330
  };
1331
+ }, []);
1332
+ const { requiredProps = [], supports } = vizConfig;
1333
+ const missing = missingKeys(requiredProps, evaluatedOptionsToUse);
1334
+ if (missing.length > 0 && supports.includes("placeholder" /* PLACEHOLDER */) && vizConfig.key !== "splunk.singlevalue") {
1335
+ return /* @__PURE__ */ react_exports.createElement(
1336
+ MissingPropsMessage_default,
1337
+ {
1338
+ "data-test": "missing-props-message",
1339
+ width,
1340
+ height,
1341
+ missingProps: missing,
1342
+ backgroundColor: bgColorFromTheme
1343
+ }
1344
+ );
2613
1345
  }
2614
- }, [options, context, dataSourcesWithOnlyOnePoint, dataFrameWithOnlyOnePoint]);
2615
- return xAndYFieldsWithTypes;
2616
- };
2617
-
2618
- exports.default = useGetXAndYFields;
2619
-
2620
- /***/ }),
2621
- /* 66 */
2622
- /***/ (function(module, exports, __webpack_require__) {
2623
-
2624
- "use strict";
2625
-
2626
-
2627
- Object.defineProperty(exports, "__esModule", {
2628
- value: true
2629
- });
2630
- exports.getFeatureFlag = void 0;
2631
-
2632
- var FeatureFlags_1 = __webpack_require__(67);
2633
-
2634
- var getFeatureFlag = function getFeatureFlag(context, flagName) {
2635
- // look for feature flag in context first
2636
- if (context && Object.keys(context).find(function (key) {
2637
- return key === flagName;
2638
- })) {
2639
- return context[flagName];
2640
- } // fall back to defaults
2641
-
2642
-
2643
- if (Object.keys(FeatureFlags_1.default).find(function (key) {
2644
- return key === flagName;
2645
- })) {
2646
- return FeatureFlags_1.default[flagName];
2647
- } // fall back to false
2648
-
2649
-
2650
- return false;
1346
+ const eventCallbackProps = {};
1347
+ if (hasEventHandlers && mode === "view" && vizConfig.supports.indexOf("events" /* EVENTS */) > -1) {
1348
+ const supportedEvents = vizConfig.events;
1349
+ Object.keys(supportedEvents).forEach((eventName) => {
1350
+ const { parentKeys, payloadKeys } = supportedEvents[eventName];
1351
+ const eventCallbackPropName = (0, lodash_exports.camelCase)(`on.${eventName}`);
1352
+ let payload = {};
1353
+ if (Array.isArray(payloadKeys) && payloadKeys.length) {
1354
+ payloadKeys.forEach((p) => {
1355
+ payload[p] = evaluatedOptionsToUse[p];
1356
+ });
1357
+ }
1358
+ eventCallbackProps[eventCallbackPropName] = (ev) => {
1359
+ if (ev && ev.payload) {
1360
+ payload = ev.payload;
1361
+ }
1362
+ return onEventTrigger({ originalEvent: ev, payload, type: eventName });
1363
+ };
1364
+ if (parentKeys) {
1365
+ for (let i = parentKeys.length - 1; i >= 0; i -= 1) {
1366
+ const newObject = {};
1367
+ newObject[parentKeys[i]] = eventCallbackProps[eventCallbackPropName];
1368
+ eventCallbackProps[eventCallbackPropName] = newObject;
1369
+ }
1370
+ }
1371
+ });
1372
+ }
1373
+ const computedVizProps = computeVizProps2(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, props), evaluatedOptionsToUse), eventCallbackProps), {
1374
+ themeFunc
1375
+ }));
1376
+ let dataSourceMetadata = {};
1377
+ const OptionKey = "paginateDataSourceKey";
1378
+ const paginateDataSourceKey = (0, lodash_exports.has)(evaluatedOptionsToUse, OptionKey) && evaluatedOptionsToUse[OptionKey] || "primary";
1379
+ if (vizConfig.supports.indexOf("page-and-sort" /* PAGE_AND_SORT */) > -1 && (0, lodash_exports.has)(dataSources, paginateDataSourceKey)) {
1380
+ const requestParams = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "requestParams"], {});
1381
+ const meta = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "meta"], {});
1382
+ const handleRequestParamsChange = (payload) => onRequestParamsChange(paginateDataSourceKey, payload);
1383
+ const sortParams = getSortingParams({
1384
+ requestParams,
1385
+ meta,
1386
+ onRequestParamsChange: handleRequestParamsChange
1387
+ });
1388
+ const paginatorParams = getPaginationParams({
1389
+ requestParams,
1390
+ meta,
1391
+ onRequestParamsChange: handleRequestParamsChange
1392
+ });
1393
+ dataSourceMetadata = {
1394
+ sortParams,
1395
+ paginatorParams
1396
+ };
1397
+ }
1398
+ if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
1399
+ return null;
1400
+ }
1401
+ return /* @__PURE__ */ react_exports.createElement(
1402
+ SanitizedReactViz,
1403
+ __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
1404
+ mode,
1405
+ width,
1406
+ height
1407
+ }, downsamplingProps), evaluatedOptionsToUse), computedVizProps), eventCallbackProps), dataSourceMetadata)
1408
+ );
1409
+ };
1410
+ DashboardViz.propTypes = __spreadValues(__spreadValues({}, SplunkVisualization_default.propTypes), ReactViz.propTypes);
1411
+ DashboardViz.defaultProps = __spreadProps(__spreadValues(__spreadValues({}, SplunkVisualization_default.defaultProps), ReactViz.defaultProps), {
1412
+ // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
1413
+ theme: {}
1414
+ });
1415
+ DashboardViz.config = vizConfig;
1416
+ return (0, styled_components_exports.withTheme)(
1417
+ withPlaceholder_default(withEditModeCover_default(DashboardViz, disableEditModeCover), useIconPlaceholder)
1418
+ );
2651
1419
  };
1420
+ var withDashboardViz_default = withDashboardViz;
2652
1421
 
2653
- exports.getFeatureFlag = getFeatureFlag;
2654
-
2655
- /***/ }),
2656
- /* 67 */
2657
- /***/ (function(module, exports) {
2658
-
2659
- module.exports = require("@splunk/visualization-context/FeatureFlags");
2660
-
2661
- /***/ }),
2662
- /* 68 */,
2663
- /* 69 */,
2664
- /* 70 */,
2665
- /* 71 */
2666
- /***/ (function(module, exports) {
2667
-
2668
- module.exports = require("@splunk/visualization-icons");
2669
-
2670
- /***/ }),
2671
- /* 72 */,
2672
- /* 73 */,
2673
- /* 74 */,
2674
- /* 75 */,
2675
- /* 76 */,
2676
- /* 77 */,
2677
- /* 78 */,
2678
- /* 79 */,
2679
- /* 80 */,
2680
- /* 81 */,
2681
- /* 82 */,
2682
- /* 83 */,
2683
- /* 84 */,
2684
- /* 85 */,
2685
- /* 86 */,
2686
- /* 87 */,
2687
- /* 88 */,
2688
- /* 89 */,
2689
- /* 90 */,
2690
- /* 91 */,
2691
- /* 92 */,
2692
- /* 93 */,
2693
- /* 94 */,
2694
- /* 95 */,
2695
- /* 96 */,
2696
- /* 97 */,
2697
- /* 98 */,
2698
- /* 99 */,
2699
- /* 100 */,
2700
- /* 101 */,
2701
- /* 102 */,
2702
- /* 103 */,
2703
- /* 104 */,
2704
- /* 105 */,
2705
- /* 106 */,
2706
- /* 107 */,
2707
- /* 108 */,
2708
- /* 109 */,
2709
- /* 110 */,
2710
- /* 111 */,
2711
- /* 112 */,
2712
- /* 113 */,
2713
- /* 114 */,
2714
- /* 115 */,
2715
- /* 116 */,
2716
- /* 117 */,
2717
- /* 118 */,
2718
- /* 119 */,
2719
- /* 120 */,
2720
- /* 121 */,
2721
- /* 122 */,
2722
- /* 123 */,
2723
- /* 124 */,
2724
- /* 125 */,
2725
- /* 126 */,
2726
- /* 127 */,
2727
- /* 128 */,
2728
- /* 129 */,
2729
- /* 130 */,
2730
- /* 131 */,
2731
- /* 132 */,
2732
- /* 133 */,
2733
- /* 134 */,
2734
- /* 135 */,
2735
- /* 136 */,
2736
- /* 137 */,
2737
- /* 138 */,
2738
- /* 139 */,
2739
- /* 140 */,
2740
- /* 141 */,
2741
- /* 142 */,
2742
- /* 143 */,
2743
- /* 144 */,
2744
- /* 145 */,
2745
- /* 146 */,
2746
- /* 147 */,
2747
- /* 148 */,
2748
- /* 149 */,
2749
- /* 150 */,
2750
- /* 151 */,
2751
- /* 152 */,
2752
- /* 153 */,
2753
- /* 154 */,
2754
- /* 155 */,
2755
- /* 156 */,
2756
- /* 157 */,
2757
- /* 158 */,
2758
- /* 159 */,
2759
- /* 160 */,
2760
- /* 161 */,
2761
- /* 162 */,
2762
- /* 163 */,
2763
- /* 164 */,
2764
- /* 165 */,
2765
- /* 166 */,
2766
- /* 167 */,
2767
- /* 168 */,
2768
- /* 169 */,
2769
- /* 170 */
2770
- /***/ (function(module, exports, __webpack_require__) {
2771
-
2772
- "use strict";
2773
-
2774
-
2775
- var __rest = this && this.__rest || function (s, e) {
2776
- var t = {};
2777
-
2778
- for (var p in s) {
2779
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
1422
+ // src/Image/ImageApi.ts
1423
+ var ImageApi = class {
1424
+ constructor(viz) {
1425
+ this.viz = viz;
2780
1426
  }
2781
-
2782
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2783
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
1427
+ /**
1428
+ * return snapshot of that includes inlined image
1429
+ */
1430
+ snapshot() {
1431
+ const srcFromOptions = (0, lodash_exports.get)(this.viz.options, "src", "");
1432
+ const isRemote = (0, RemoteImage_exports.isRemoteImage)(srcFromOptions);
1433
+ return {
1434
+ options: __spreadProps(__spreadValues({}, this.viz.options), {
1435
+ src: isRemote && this.viz.remoteImage ? (0, lodash_exports.get)(this.viz.remoteImage, ["current", "state", "imageDataURI"], "") : srcFromOptions
1436
+ })
1437
+ };
2784
1438
  }
2785
- return t;
2786
1439
  };
2787
-
2788
- Object.defineProperty(exports, "__esModule", {
2789
- value: true
2790
- });
2791
- exports.config = exports.themes = exports.toImageDimensions = exports.shouldShowPlaceholder = void 0;
2792
-
2793
- var lodash_1 = __webpack_require__(2);
2794
-
2795
- var React = __webpack_require__(1);
2796
-
2797
- var i18n_1 = __webpack_require__(3);
2798
-
2799
- var style_1 = __webpack_require__(18);
2800
-
2801
- var RemoteImage_1 = __webpack_require__(171);
2802
-
2803
- var styled_components_1 = __webpack_require__(4);
2804
-
2805
- var T = __webpack_require__(0);
2806
-
2807
- var config_1 = __webpack_require__(238);
2808
-
2809
- exports.config = config_1.default;
2810
-
2811
- var withDashboardViz_1 = __webpack_require__(54);
2812
-
2813
- var ImageApi_1 = __webpack_require__(239);
2814
-
2815
- var useEffect = React.useEffect,
2816
- useRef = React.useRef;
2817
- var validOptions = Object.keys(config_1.default.optionsSchema);
2818
- var Container = styled_components_1.default.div.attrs(function () {
2819
- return {
2820
- 'data-test': 'image-container'
2821
- };
2822
- }).withConfig({
2823
- displayName: "Image__Container",
2824
- componentId: "sc-kplb09-0"
2825
- })(["position:relative;box-sizing:border-box;display:flex;justify-content:center;align-items:center;cursor:", ";", ";"], function (props) {
2826
- return props.onClick ? 'pointer' : 'inherit';
2827
- }, function (props) {
2828
- return (0, style_1.toDimension)((0, lodash_1.pick)(props, ['width', 'height']));
2829
- });
2830
-
2831
- var shouldShowPlaceholder = function shouldShowPlaceholder(dataSources, loading, options) {
1440
+ var ImageApi_default = ImageApi;
1441
+
1442
+ // src/Image/Image.tsx
1443
+ var { useEffect: useEffect4, useRef: useRef5 } = react_exports;
1444
+ var validOptions = Object.keys(config_default.optionsSchema);
1445
+ var Container = styled_components_default.div.attrs(() => ({
1446
+ "data-test": "image-container"
1447
+ }))`
1448
+ position: relative;
1449
+ box-sizing: border-box;
1450
+ display: flex;
1451
+ justify-content: center;
1452
+ align-items: center;
1453
+ cursor: ${(props) => props.onClick ? "pointer" : "inherit"};
1454
+ ${(props) => (0, style_exports.toDimension)((0, lodash_exports.pick)(props, ["width", "height"]))};
1455
+ `;
1456
+ var shouldShowPlaceholder = (dataSources, loading, options) => {
2832
1457
  if (options.src) {
2833
1458
  return false;
2834
1459
  }
2835
-
2836
1460
  return true;
2837
1461
  };
2838
-
2839
- exports.shouldShowPlaceholder = shouldShowPlaceholder;
2840
-
2841
- var toImageDimensions = function toImageDimensions(props) {
1462
+ var toImageDimensions = (props) => {
2842
1463
  if (props.shouldPreserveAspectRatio) {
2843
- return "\n max-width: 100%;\n max-height: 100%;\n width: auto;\n height: auto;\n ";
1464
+ return `
1465
+ max-width: 100%;
1466
+ max-height: 100%;
1467
+ width: auto;
1468
+ height: auto;
1469
+ `;
2844
1470
  }
2845
-
2846
- return (0, style_1.toDimension)((0, lodash_1.pick)(props, ['width', 'height']));
1471
+ return (0, style_exports.toDimension)((0, lodash_exports.pick)(props, ["width", "height"]));
2847
1472
  };
2848
-
2849
- exports.toImageDimensions = toImageDimensions;
2850
- var StyledImage = styled_components_1.default.img.withConfig({
2851
- displayName: "Image__StyledImage",
2852
- componentId: "sc-kplb09-1"
2853
- })(["display:block;", ";"], function (props) {
2854
- return (0, exports.toImageDimensions)(props);
2855
- });
2856
-
2857
- var computeVizProps = function computeVizProps(_a) {
2858
- var visualizationApiRef = _a.visualizationApiRef,
2859
- title = _a.title,
2860
- otherOptions = __rest(_a, ["visualizationApiRef", "title"]);
2861
-
2862
- var options = (0, lodash_1.chain)(otherOptions).pick(validOptions).value();
2863
- return {
2864
- options: options,
2865
- title: title,
2866
- visualizationApiRef: visualizationApiRef
2867
- };
1473
+ var StyledImage = styled_components_default.img`
1474
+ display: block;
1475
+ ${(props) => toImageDimensions(props)};
1476
+ `;
1477
+ var computeVizProps = (_a) => {
1478
+ var _b = _a, {
1479
+ visualizationApiRef,
1480
+ title
1481
+ } = _b, otherOptions = __objRest(_b, [
1482
+ "visualizationApiRef",
1483
+ "title"
1484
+ ]);
1485
+ const options = (0, lodash_exports.chain)(otherOptions).pick(validOptions).value();
1486
+ return { options, title, visualizationApiRef };
2868
1487
  };
2869
-
2870
- var ImageVisualization = function ImageVisualization(_ref) {
2871
- var height = _ref.height,
2872
- width = _ref.width,
2873
- _ref$title = _ref.title,
2874
- title = _ref$title === void 0 ? '' : _ref$title,
2875
- visualizationApiRef = _ref.visualizationApiRef,
2876
- options = _ref.options,
2877
- onImageClick = _ref.onImageClick;
2878
- var src = options.src,
2879
- preserveAspectRatio = options.preserveAspectRatio;
2880
- var remoteImage = useRef(null);
2881
- var api = useRef(new ImageApi_1.default({
2882
- options: {
2883
- src: src,
2884
- preserveAspectRatio: preserveAspectRatio
2885
- },
2886
- remoteImage: remoteImage
2887
- }));
2888
- var isRemote = (0, RemoteImage_1.isRemoteImage)(src);
2889
- useEffect(function () {
1488
+ var ImageVisualization = ({
1489
+ height,
1490
+ width,
1491
+ title = "",
1492
+ visualizationApiRef,
1493
+ options,
1494
+ onImageClick
1495
+ }) => {
1496
+ const { src, preserveAspectRatio } = options;
1497
+ const remoteImage = useRef5(null);
1498
+ const api = useRef5(new ImageApi_default({ options: { src, preserveAspectRatio }, remoteImage }));
1499
+ const isRemote = (0, RemoteImage_exports.isRemoteImage)(src);
1500
+ useEffect4(() => {
2890
1501
  visualizationApiRef(api.current);
2891
- return function () {
1502
+ return () => {
2892
1503
  visualizationApiRef(null);
2893
1504
  };
2894
1505
  }, []);
2895
- return React.createElement(Container, {
2896
- width: width,
2897
- height: height,
2898
- onClick: onImageClick
2899
- }, isRemote ? React.createElement(RemoteImage_1.default, {
2900
- imageURL: src,
2901
- title: title,
2902
- preserveAspectRatio: preserveAspectRatio,
2903
- width: width,
2904
- height: height,
2905
- ref: remoteImage
2906
- }) : React.createElement(StyledImage, {
2907
- "data-test": "image",
2908
- src: src,
2909
- shouldPreserveAspectRatio: preserveAspectRatio,
2910
- width: width,
2911
- height: height,
2912
- alt: (0, i18n_1._)(title),
2913
- onError: function onError(e) {
2914
- e.target.alt = (0, i18n_1._)('Image not found');
2915
- },
2916
- referrerPolicy: "no-referrer"
2917
- }));
1506
+ return /* @__PURE__ */ react_exports.createElement(Container, { width, height, onClick: onImageClick }, isRemote ? /* @__PURE__ */ react_exports.createElement(
1507
+ RemoteImage_default,
1508
+ {
1509
+ imageURL: src,
1510
+ title,
1511
+ preserveAspectRatio,
1512
+ width,
1513
+ height,
1514
+ ref: remoteImage
1515
+ }
1516
+ ) : /* @__PURE__ */ react_exports.createElement(
1517
+ StyledImage,
1518
+ {
1519
+ "data-test": "image",
1520
+ src,
1521
+ shouldPreserveAspectRatio: preserveAspectRatio,
1522
+ width,
1523
+ height,
1524
+ alt: (0, i18n_exports._)(title),
1525
+ onError: (e) => {
1526
+ e.target.alt = (0, i18n_exports._)("Image not found");
1527
+ },
1528
+ referrerPolicy: "no-referrer"
1529
+ }
1530
+ ));
2918
1531
  };
2919
-
2920
- var propTypes = {
2921
- width: T.oneOfType([T.string, T.number]),
2922
- height: T.oneOfType([T.string, T.number]),
2923
- options: T.object,
2924
- title: T.string,
2925
- visualizationApiRef: T.func,
2926
- onImageClick: T.func
1532
+ var propTypes3 = {
1533
+ width: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
1534
+ height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
1535
+ options: prop_types_exports.object,
1536
+ title: prop_types_exports.string,
1537
+ visualizationApiRef: prop_types_exports.func,
1538
+ onImageClick: prop_types_exports.func
2927
1539
  };
2928
1540
  var defaultProps = {
2929
- width: '100%',
2930
- height: undefined,
1541
+ width: "100%",
1542
+ height: void 0,
2931
1543
  options: {},
2932
- title: '',
2933
- visualizationApiRef: lodash_1.noop,
2934
- onImageClick: lodash_1.noop
1544
+ title: "",
1545
+ visualizationApiRef: lodash_exports.noop,
1546
+ onImageClick: lodash_exports.noop
2935
1547
  };
2936
- ImageVisualization.propTypes = propTypes;
1548
+ ImageVisualization.propTypes = propTypes3;
2937
1549
  ImageVisualization.defaultProps = defaultProps;
2938
- var Image = (0, withDashboardViz_1.default)({
1550
+ var Image = withDashboardViz_default({
2939
1551
  ReactViz: ImageVisualization,
2940
- vizConfig: config_1.default,
2941
- useIconPlaceholder: exports.shouldShowPlaceholder,
2942
- computeVizProps: computeVizProps
2943
- });
2944
- var themes = null;
2945
- exports.themes = themes;
2946
- exports.default = Image;
2947
-
2948
- /***/ }),
2949
- /* 171 */
2950
- /***/ (function(module, exports) {
2951
-
2952
- module.exports = require("@splunk/visualizations-shared/RemoteImage");
2953
-
2954
- /***/ }),
2955
- /* 172 */,
2956
- /* 173 */,
2957
- /* 174 */,
2958
- /* 175 */,
2959
- /* 176 */,
2960
- /* 177 */,
2961
- /* 178 */,
2962
- /* 179 */,
2963
- /* 180 */,
2964
- /* 181 */,
2965
- /* 182 */,
2966
- /* 183 */,
2967
- /* 184 */,
2968
- /* 185 */,
2969
- /* 186 */,
2970
- /* 187 */,
2971
- /* 188 */,
2972
- /* 189 */,
2973
- /* 190 */,
2974
- /* 191 */,
2975
- /* 192 */,
2976
- /* 193 */,
2977
- /* 194 */,
2978
- /* 195 */,
2979
- /* 196 */,
2980
- /* 197 */,
2981
- /* 198 */,
2982
- /* 199 */,
2983
- /* 200 */,
2984
- /* 201 */,
2985
- /* 202 */,
2986
- /* 203 */,
2987
- /* 204 */,
2988
- /* 205 */,
2989
- /* 206 */,
2990
- /* 207 */,
2991
- /* 208 */,
2992
- /* 209 */,
2993
- /* 210 */,
2994
- /* 211 */,
2995
- /* 212 */,
2996
- /* 213 */,
2997
- /* 214 */,
2998
- /* 215 */,
2999
- /* 216 */,
3000
- /* 217 */,
3001
- /* 218 */,
3002
- /* 219 */,
3003
- /* 220 */,
3004
- /* 221 */,
3005
- /* 222 */,
3006
- /* 223 */,
3007
- /* 224 */,
3008
- /* 225 */,
3009
- /* 226 */,
3010
- /* 227 */,
3011
- /* 228 */,
3012
- /* 229 */,
3013
- /* 230 */,
3014
- /* 231 */,
3015
- /* 232 */,
3016
- /* 233 */,
3017
- /* 234 */,
3018
- /* 235 */,
3019
- /* 236 */,
3020
- /* 237 */
3021
- /***/ (function(module, exports, __webpack_require__) {
3022
-
3023
- "use strict";
3024
-
3025
-
3026
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
3027
- if (k2 === undefined) k2 = k;
3028
- var desc = Object.getOwnPropertyDescriptor(m, k);
3029
-
3030
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3031
- desc = {
3032
- enumerable: true,
3033
- get: function get() {
3034
- return m[k];
3035
- }
3036
- };
3037
- }
3038
-
3039
- Object.defineProperty(o, k2, desc);
3040
- } : function (o, m, k, k2) {
3041
- if (k2 === undefined) k2 = k;
3042
- o[k2] = m[k];
3043
- });
3044
-
3045
- var __exportStar = this && this.__exportStar || function (m, exports) {
3046
- for (var p in m) {
3047
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3048
- }
3049
- };
3050
-
3051
- Object.defineProperty(exports, "__esModule", {
3052
- value: true
3053
- });
3054
- exports.default = void 0;
3055
-
3056
- __exportStar(__webpack_require__(170), exports);
3057
-
3058
- var Image_1 = __webpack_require__(170);
3059
-
3060
- Object.defineProperty(exports, "default", {
3061
- enumerable: true,
3062
- get: function get() {
3063
- return Image_1.default;
3064
- }
3065
- });
3066
-
3067
- /***/ }),
3068
- /* 238 */
3069
- /***/ (function(module, exports, __webpack_require__) {
3070
-
3071
- "use strict";
3072
-
3073
-
3074
- Object.defineProperty(exports, "__esModule", {
3075
- value: true
3076
- });
3077
-
3078
- var i18n_1 = __webpack_require__(3);
3079
-
3080
- var visualization_schemas_1 = __webpack_require__(9);
3081
-
3082
- var visualization_icons_1 = __webpack_require__(71);
3083
-
3084
- var VizBehavior_1 = __webpack_require__(7);
3085
-
3086
- var VizCategory_1 = __webpack_require__(22);
3087
-
3088
- var configUtils_1 = __webpack_require__(26);
3089
-
3090
- var dataContract = {
3091
- requiredDataSources: [],
3092
- optionalDataSources: [// Note: SCP-14090 disable ui for optional datasources. We may need to add it back later
3093
- // {
3094
- // name: 'annotation',
3095
- // description: 'DataSource that populate event annotations',
3096
- // },
3097
- ],
3098
- initialRequestParams: {}
3099
- };
3100
- var size = {
3101
- initialWidth: 300,
3102
- initialHeight: 300
3103
- };
3104
- var defaultContext = {};
3105
- var editorConfig = [{
3106
- label: (0, i18n_1._)('Image content'),
3107
- layout: [[{
3108
- label: (0, i18n_1._)('Image file'),
3109
- option: 'src',
3110
- editor: 'editor.image'
3111
- }], [{
3112
- label: (0, i18n_1._)('Preserve aspect ratio'),
3113
- option: 'preserveAspectRatio',
3114
- editor: 'editor.checkbox',
3115
- showEditor: function showEditor(_ref) {
3116
- var options = _ref.options;
3117
- return !!options.src;
3118
- }
3119
- }]]
3120
- }];
3121
- var themes = {};
3122
- /**
3123
- * visualization configuration
3124
- */
3125
-
3126
- var config = {
3127
- /**
3128
- * unique viz key
3129
- */
3130
- key: 'splunk.image',
3131
-
3132
- /**
3133
- * viz name
3134
- */
3135
- name: (0, i18n_1._)('Image'),
3136
- category: VizCategory_1.VizCategory.MISC,
3137
-
3138
- /**
3139
- * viz icon
3140
- */
3141
- icon: visualization_icons_1.Image,
3142
- dataContract: dataContract,
3143
- size: size,
3144
- defaultContext: defaultContext,
3145
- optionsSchema: visualization_schemas_1.imageOptionsSchema,
3146
- editorConfig: editorConfig,
3147
- supports: [VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS, VizBehavior_1.VizBehavior.PLACEHOLDER, VizBehavior_1.VizBehavior.EVENTS],
3148
- themes: themes,
3149
- events: {
3150
- 'image.click': {
3151
- description: 'triggered when user clicks on the image'
3152
- }
3153
- }
3154
- };
3155
- exports.default = (0, configUtils_1.enhanceConfig)(config);
3156
-
3157
- /***/ }),
3158
- /* 239 */
3159
- /***/ (function(module, exports, __webpack_require__) {
3160
-
3161
- "use strict";
3162
-
3163
-
3164
- var _classCallCheck = __webpack_require__(8);
3165
-
3166
- var _createClass = __webpack_require__(24);
3167
-
3168
- Object.defineProperty(exports, "__esModule", {
3169
- value: true
1552
+ vizConfig: config_default,
1553
+ useIconPlaceholder: shouldShowPlaceholder,
1554
+ computeVizProps
3170
1555
  });
3171
-
3172
- var lodash_1 = __webpack_require__(2);
3173
-
3174
- var RemoteImage_1 = __webpack_require__(171);
3175
- /**
3176
- * Image Api
3177
- */
3178
-
3179
-
3180
- var ImageApi = /*#__PURE__*/function () {
3181
- function ImageApi(viz) {
3182
- _classCallCheck(this, ImageApi);
3183
-
3184
- this.viz = viz;
3185
- }
3186
- /**
3187
- * return snapshot of that includes inlined image
3188
- */
3189
-
3190
-
3191
- _createClass(ImageApi, [{
3192
- key: "snapshot",
3193
- value: function snapshot() {
3194
- var srcFromOptions = (0, lodash_1.get)(this.viz.options, 'src', '');
3195
- var isRemote = (0, RemoteImage_1.isRemoteImage)(srcFromOptions);
3196
- return {
3197
- options: Object.assign(Object.assign({}, this.viz.options), {
3198
- src: isRemote && this.viz.remoteImage ? (0, lodash_1.get)(this.viz.remoteImage, ['current', 'state', 'imageDataURI'], '') : srcFromOptions
3199
- })
3200
- };
3201
- }
3202
- }]);
3203
-
3204
- return ImageApi;
3205
- }();
3206
-
3207
- exports.default = ImageApi;
3208
-
3209
- /***/ })
3210
- /******/ ]);
3211
- //# sourceMappingURL=Image.js.map
1556
+ var themes2 = null;
1557
+ var Image_default = Image;
1558
+ //# sourceMappingURL=Image.js.map