/*!
 * Copyright © 2024 Splunk Inc.
 * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
 * in part without a valid written license from Splunk Inc. is PROHIBITED.
 */
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 104);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {

module.exports = require("react");

/***/ }),
/* 1 */
/***/ (function(module, exports) {

module.exports = require("prop-types");

/***/ }),
/* 2 */
/***/ (function(module, exports) {

module.exports = require("styled-components");

/***/ }),
/* 3 */
/***/ (function(module, exports) {

module.exports = require("lodash");

/***/ }),
/* 4 */
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/classCallCheck");

/***/ }),
/* 5 */
/***/ (function(module, exports) {

module.exports = require("@splunk/ui-utils/i18n");

/***/ }),
/* 6 */,
/* 7 */
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/createClass");

/***/ }),
/* 8 */
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/slicedToArray");

/***/ }),
/* 9 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualizations-shared/numberUtils");

/***/ }),
/* 10 */
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/defineProperty");

/***/ }),
/* 11 */,
/* 12 */,
/* 13 */,
/* 14 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _classCallCheck = __webpack_require__(4);

var _createClass = __webpack_require__(7);

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DefaultVizActionHandler = void 0;

var DefaultVizActionHandler = /*#__PURE__*/function () {
  function DefaultVizActionHandler() {
    _classCallCheck(this, DefaultVizActionHandler);
  }

  _createClass(DefaultVizActionHandler, [{
    key: "focus",
    value: function focus() {// noop
    }
  }, {
    key: "snapshot",
    value: function snapshot() {
      return null; // noop
    }
  }]);

  return DefaultVizActionHandler;
}();

exports.DefaultVizActionHandler = DefaultVizActionHandler;

/***/ }),
/* 15 */,
/* 16 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualizations-shared/colorUtils");

/***/ }),
/* 17 */,
/* 18 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.VizBehavior = void 0;
var VizBehavior;

(function (VizBehavior) {
  /**
   * Dynamic Options Behavior.
   * This allows visualization options to be powered by data
   *
   * **Example**
   *
   * sparklineValues: ">primary|seriesByIndex(0)"
   * would configure sparklineValues with an array of data points
   * coming from the first series in the primary datasource
   *
   */
  VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
  VizBehavior["EVENTS"] = "events";
  VizBehavior["DOWNSAMPLING"] = "downsampling";
  /**
   * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
   * missing.
   * @type {string}
   */

  VizBehavior["PLACEHOLDER"] = "placeholder";
  VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
  VizBehavior["TRELLIS"] = "trellis";
})(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));

/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.VizCategory = void 0;
var VizCategory;

(function (VizCategory) {
  VizCategory["SINGLE_VALUE"] = "Single Value";
  VizCategory["TRENDS"] = "Trends";
  VizCategory["COMPARISONS"] = "Comparisons";
  VizCategory["TABLE"] = "Table";
  VizCategory["GAUGE"] = "Gauge";
  VizCategory["DISTRIBUTIONS"] = "Distributions";
  VizCategory["CHOROPLETH"] = "Choropleth Maps";
  VizCategory["SHAPES"] = "Shapes";
  VizCategory["MISC"] = "misc";
  VizCategory["FLOW"] = "Flow";
  VizCategory["CORRELATION"] = "Correlation";
  VizCategory["SPATIAL"] = "Spatial";
})(VizCategory = exports.VizCategory || (exports.VizCategory = {}));

/***/ }),
/* 20 */,
/* 21 */,
/* 22 */
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/toConsumableArray");

/***/ }),
/* 23 */,
/* 24 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualizations-shared/Message");

/***/ }),
/* 25 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.downsampleDataSources = exports.calculateDownsamplingThreshold = exports.calculateThresholdOnRangeSelect = exports.isDownsamplingEnabledForViz = exports.convertToArrOfObjects = void 0;

var numberUtils_1 = __webpack_require__(9);

var interfaces_1 = __webpack_require__(32); // TODO: utilize this fn in ParallelCoordinates


var convertToArrOfObjects = function convertToArrOfObjects(columns, fields) {
  if (!columns || !columns[0] || !columns[0].length) return [];
  var data = [];

  var _loop = function _loop(i) {
    var newObj = {};
    fields.forEach(function (field, index) {
      var fieldName = typeof field === 'string' ? field : field.name;

      if (columns[index][i] === '') {
        newObj[fieldName] = null;
      } else {
        newObj[fieldName] = columns[index][i];
      }
    });
    data.push(newObj);
  };

  for (var i = 0; i < columns[0].length; i += 1) {
    _loop(i);
  }

  return data;
};

exports.convertToArrOfObjects = convertToArrOfObjects; // LTTB algorithm which can be used to downsample time series data while striving to maintain
// the spikes and overall shape of the chart
// Copied from https://github.com/sveinn-steinarsson/flot-downsample/blob/0815010016fc94b1bbc6a010afb8aad13ada6d0d/jquery.flot.downsample.js
// Modifications include:
// 1) Convert to modern JavaScript(use const, let, and use array.push to push to last element of array)
// 2) Convert to camel case
// 3) Convert to TS and also return the indices of the points that are in the downsampled result.
// 4) Add a new parameter preferredDownsampleIndices that correspond to the indices of points
// that should be used in case of a tie of the max area in a bucket

var largestTriangleThreeBuckets = function largestTriangleThreeBuckets(data, threshold, preferredDownsampleIndices) {
  var dataLength = data.length;
  var downsampledIndices = [];

  if (threshold >= dataLength || threshold === 0) {
    var allIndices = data.map(function (values, index) {
      return index;
    });
    return {
      downsampledData: data,
      downsampledIndices: allIndices
    }; // Nothing to do
  }

  var sampled = [];
  var sampledIndex = 0; // Bucket size. Leave room for start and end data points

  var every = (dataLength - 2) / (threshold - 2);
  var a = 0; // Initially a is the first point in the triangle

  var maxAreaPoint;
  var maxArea;
  var area;
  var nextA;
  sampled.push(data[a]); // Always add the first point

  downsampledIndices.push(0); // eslint-disable-next-line no-plusplus

  for (var i = 0; i < threshold - 2; i++) {
    // Calculate point average for next bucket (containing c)
    var avgX = 0;
    var avgY = 0;
    var avgRangeStart = Math.floor((i + 1) * every) + 1;
    var avgRangeEnd = Math.floor((i + 2) * every) + 1;
    avgRangeEnd = avgRangeEnd < dataLength ? avgRangeEnd : dataLength;
    var avgRangeLength = avgRangeEnd - avgRangeStart; // eslint-disable-next-line no-plusplus

    for (; avgRangeStart < avgRangeEnd; avgRangeStart++) {
      avgX += Number(data[avgRangeStart][0]); // * 1 enforces Number (value may be Date)

      avgY += data[avgRangeStart][1] * 1;
    }

    avgX /= avgRangeLength;
    avgY /= avgRangeLength; // Get the range for this bucket

    var rangeOffs = Math.floor((i + 0) * every) + 1;
    var rangeTo = Math.floor((i + 1) * every) + 1; // Point a

    var pointAX = Number(data[a][0]); // Enforce Number (value may be Date)

    var pointAY = data[a][1] * 1; // eslint-disable-next-line no-multi-assign

    maxArea = area = -1;
    var maxAreaIndex = rangeOffs; // eslint-disable-next-line no-plusplus

    for (; rangeOffs < rangeTo; rangeOffs++) {
      // Calculate triangle area over three buckets
      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
      // If all points in a bucket have the same area, prioritize the one with an x index
      // that also existed from another series so we don't add another point unnecessarily.
      // By default LTTB picks the leftmost point in the bucket

      if (area > maxArea || area === maxArea && preferredDownsampleIndices.has(rangeOffs)) {
        maxArea = area;
        maxAreaPoint = data[rangeOffs];
        nextA = rangeOffs; // Next a is this b
        // Modification: save the index of the point with the most area

        maxAreaIndex = rangeOffs;
      }
    } // eslint-disable-next-line no-plusplus


    sampled[sampledIndex++] = maxAreaPoint; // Pick this point from the bucket

    downsampledIndices.push(maxAreaIndex);
    a = nextA; // This a is the next a (chosen b)
  } // eslint-disable-next-line no-plusplus


  sampled[sampledIndex++] = data[dataLength - 1]; // Always add last

  downsampledIndices.push(dataLength - 1);
  return {
    downsampledData: sampled,
    downsampledIndices: downsampledIndices
  };
};
/**
 * Strictly coerces the entire column to numbers if it only consists of numeric strings or numbers. Also determines
 * if at least one of the values in the column can be loosely coerced to a number.
 * If the column cannot be strictly downsampled (if it contains nulls or non-numeric strings), returns an empty array and
 * returns that it cannot downsample the column.
 */


var strictlyCoerceYColumn = function strictlyCoerceYColumn(column) {
  // Splunk charting allows for numbers in formats such as negative hex that
  // Number() does not support and also allows loose coercion of hex numbers (but not other formats)
  // We want to identify columns which contain at least one value that can be loosely coerced
  var canLooselyCoerceSomeValues = column.findIndex(function (value) {
    return (0, numberUtils_1.startsWithNumber)("".concat(value));
  }) >= 0; // If not all values in column can be strictly coerced to a number, we do not downsample

  var coercedColumn = [];
  var canDownsampleColumn = !column.some(function (value) {
    var coercedValue = Number(value); // if it can't be parsed or isn't safe, fail

    if (Number.isNaN(coercedValue) || coercedValue <= Number.MIN_SAFE_INTEGER || coercedValue >= Number.MAX_SAFE_INTEGER || typeof value !== 'string' && typeof value !== 'number') {
      return true;
    } // save value and continue to next


    coercedColumn.push(coercedValue);
    return false;
  });
  return {
    canDownsampleColumn: canDownsampleColumn,
    canLooselyCoerceSomeValues: canLooselyCoerceSomeValues,
    coercedColumn: canDownsampleColumn ? coercedColumn : []
  };
};
/**
 * Tries to coerce the x-column to numbers or dates, if it is eligible for downsampling.
 * Only strictly increasing x-columns are eligible for downsampling.
 * If the column is not eligible for downsampling, returns an empty array.
 */


var strictlyCoerceXColumn = function strictlyCoerceXColumn(column, fieldType) {
  if (fieldType === 'number') {
    var coercedXColumn = column.map(function (xValue) {
      return Number(xValue);
    });

    if (isColumnStrictlyIncreasing(coercedXColumn, fieldType)) {
      return coercedXColumn;
    }
  } else if (fieldType === 'time') {
    var _coercedXColumn = column.map(function (xValue) {
      return new Date(xValue);
    });

    if (isColumnStrictlyIncreasing(_coercedXColumn, fieldType)) {
      return _coercedXColumn;
    }
  }

  return [];
};

var isDownsamplingEnabledForViz = function isDownsamplingEnabledForViz(_ref) {
  var vizConfig = _ref.vizConfig;

  var _a;

  return (_a = vizConfig.supports) === null || _a === void 0 ? void 0 : _a.includes(interfaces_1.VizBehavior.DOWNSAMPLING);
};

exports.isDownsamplingEnabledForViz = isDownsamplingEnabledForViz;

var calculateThresholdOnRangeSelect = function calculateThresholdOnRangeSelect(_ref2) {
  var firstIndex = _ref2.firstIndex,
      lastIndex = _ref2.lastIndex,
      dataSources = _ref2.dataSources,
      width = _ref2.width;

  var _a, _b, _c;

  var window = lastIndex - firstIndex + 1;
  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;
  return Math.round(ratio * Number(width));
};

exports.calculateThresholdOnRangeSelect = calculateThresholdOnRangeSelect;
/**
 * Calculates the downsampling threshold based on the range selection. If search zoom is enabled or there is no selection,
 * then returns the width of the visualization.
 *
 * Otherwise calculates the threshold based on the ratio of the window selected compared to the size of the non-downsampled
 * 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
 * in for a categorical chart.
 */

var calculateDownsamplingThreshold = function calculateDownsamplingThreshold(_ref3) {
  var enableSearchZoom = _ref3.enableSearchZoom,
      dataSources = _ref3.dataSources,
      selectChartEvent = _ref3.selectChartEvent,
      width = _ref3.width,
      xField = _ref3.xField,
      y2Fields = _ref3.y2Fields;

  var _a, _b, _c;

  if (enableSearchZoom || !selectChartEvent) {
    return Number(width);
  }

  var primaryDataSource = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary;

  if (!primaryDataSource) {
    return null;
  }

  var startXIndex = selectChartEvent.startXIndex,
      endXIndex = selectChartEvent.endXIndex,
      currentTarget = selectChartEvent.currentTarget;

  try {
    var xFieldIndex = (_a = primaryDataSource === null || primaryDataSource === void 0 ? void 0 : primaryDataSource.data) === null || _a === void 0 ? void 0 : _a.fields.findIndex(function (field) {
      return field.name === xField;
    });
    var downsampledXFieldIndex = (_b = currentTarget.dataSet) === null || _b === void 0 ? void 0 : _b.fields.findIndex(function (field) {
      return field === xField;
    });

    if (xFieldIndex === -1 || downsampledXFieldIndex === -1) {
      return null;
    }

    var fullSeries = (_c = primaryDataSource === null || primaryDataSource === void 0 ? void 0 : primaryDataSource.data) === null || _c === void 0 ? void 0 : _c.columns[xFieldIndex];
    var downsampledSeries = currentTarget.dataSet.seriesList[downsampledXFieldIndex];
    var firstIndex = fullSeries.findIndex(function (x) {
      return downsampledSeries[startXIndex] === x;
    });
    var lastIndex = fullSeries.findIndex(function (x) {
      return downsampledSeries[endXIndex] === x;
    }); // For charts with categorical x-axis (charts with an xField that isn't _time), do not support
    // re-calculating downsampling threshold if the chart is zoomed in until SPL-259458 is fixed
    // Also do not support re-calculating downsampling threshold for zoomed-in charts with y2
    // until SPL-259611 is fixed

    if (xField !== '_time' || (y2Fields === null || y2Fields === void 0 ? void 0 : y2Fields.length)) {
      return firstIndex === 0 && lastIndex === fullSeries.length - 1 ? width : null;
    }

    if (firstIndex >= 0 && lastIndex >= 0 && firstIndex <= lastIndex) {
      return (0, exports.calculateThresholdOnRangeSelect)({
        firstIndex: firstIndex,
        lastIndex: lastIndex,
        dataSources: dataSources,
        width: width
      });
    }
  } catch (e) {
    console.error('Error occurred while setting downsample threshold on range select event', e);
  }

  return null;
};

exports.calculateDownsamplingThreshold = calculateDownsamplingThreshold;

var isColumnStrictlyIncreasing = function isColumnStrictlyIncreasing(column, fieldType) {
  return column.every(function (value, index) {
    if (fieldType === 'number') {
      if (Number.isNaN(value)) {
        return false;
      }
    }

    if (fieldType === 'time') {
      if (Number.isNaN(value.getTime())) {
        return false;
      }
    }

    if (index === 0) {
      return true;
    }

    return value > column[index - 1];
  });
};
/**
 * Verifies that all of the columns that are displayed in a chart can be downsampled. Valid columns that can be
 * displayed are those that contain at least one number. We can only downsample columns that only consist of numbers.
 *
 * If all columns can be downsampled, returns the x column coerced to time/number and y columns coerced to numbers.
 * If not all columns can be downsampled, then returns empty arrays for both x and y
 */


var tryToCoerceAllDisplayedFields = function tryToCoerceAllDisplayedFields(ds, xField, yFields, fieldTypes) {
  var xColumn = [];
  var yColumns = [];
  var canDownsample = !ds.data.fields.some(function (field, index) {
    var _a, _b;

    var fieldName = (_a = field.name) !== null && _a !== void 0 ? _a : field;
    var fieldType = (_b = fieldTypes[index]) !== null && _b !== void 0 ? _b : 'unknown';
    var column = ds.data.columns[index];
    var hasDisplayedColumnThatCantBeDownsampled = false;

    if (fieldName === xField) {
      xColumn = strictlyCoerceXColumn(column, fieldType);
    } else if (yFields.has(fieldName)) {
      var _strictlyCoerceYColum = strictlyCoerceYColumn(ds.data.columns[index]),
          coercedColumn = _strictlyCoerceYColum.coercedColumn,
          canLooselyCoerceSomeValues = _strictlyCoerceYColum.canLooselyCoerceSomeValues,
          canDownsampleColumn = _strictlyCoerceYColum.canDownsampleColumn; // do not perform downsampling if a column can possibly be displayed but cannot
      // be downsampled using LTTB


      hasDisplayedColumnThatCantBeDownsampled = canLooselyCoerceSomeValues && !canDownsampleColumn;

      if (hasDisplayedColumnThatCantBeDownsampled) {
        return true;
      }

      if (canDownsampleColumn) {
        yColumns.push(coercedColumn);
      }
    }

    return false;
  });

  if (canDownsample) {
    return {
      xColumn: xColumn,
      yColumns: yColumns
    };
  }

  return {
    xColumn: [],
    yColumns: []
  };
};

var pickIndicesFromDataSource = function pickIndicesFromDataSource(ds, indices) {
  var sortedIndices = Array.from(indices).sort(function (a, b) {
    return a - b;
  });
  var slicedColumns = [];
  ds.data.columns.forEach(function (column) {
    var slicedColumn = [];
    sortedIndices.forEach(function (index) {
      slicedColumn.push(column[index]);
    });
    slicedColumns.push(slicedColumn);
  }); // update data columns with downsampled columns

  return Object.assign(Object.assign({}, ds), {
    data: Object.assign(Object.assign({}, ds.data), {
      columns: slicedColumns
    })
  });
};

var downsampleDataSources = function downsampleDataSources(_ref4) {
  var dataSources = _ref4.dataSources,
      threshold = _ref4.threshold,
      options = _ref4.options;

  var _a, _b, _c;

  var primaryDS = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary; // only downsample time series when number of data points are over threshold

  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;

  if (Number.isNaN(threshold) || numPoints <= threshold || threshold < 2) {
    return dataSources;
  }

  var xField = options.xField,
      yFields = options.yFields,
      fieldTypes = options.fieldTypes;

  if (!xField || !(yFields === null || yFields === void 0 ? void 0 : yFields.length) || !(fieldTypes === null || fieldTypes === void 0 ? void 0 : fieldTypes.length)) {
    return dataSources;
  }

  var nonInternalYFields = new Set(yFields.filter(function (yField) {
    return !yField.startsWith('_');
  }));
  var maxPointsInDownsample = Math.min(nonInternalYFields.size * threshold, numPoints); // Do not try to downsample if there are too many downsampled pts
  // At the worst case, each series has non-overlapping downsampled pts
  // which will mean that all points will be included in the downsampled result
  // This will just lead to additional overhead due to coercing each
  // x and y field to number

  if (maxPointsInDownsample >= numPoints) {
    return dataSources;
  }

  var _tryToCoerceAllDispla = tryToCoerceAllDisplayedFields(primaryDS, xField, nonInternalYFields, fieldTypes),
      xColumn = _tryToCoerceAllDispla.xColumn,
      yColumns = _tryToCoerceAllDispla.yColumns;

  if (!yColumns.length || !xColumn.length) {
    return dataSources;
  }

  var downsampledDataSources = Object.assign({}, dataSources);
  var downsampledIndices = new Set();
  yColumns.forEach(function (yColumn, columnIndex) {
    // perform LTTB downsampling for current series, LTTB takes an [x, y] pair
    var xyPair = yColumn.map(function (yValue, index) {
      return [xColumn[index], yValue];
    });

    try {
      var _largestTriangleThree = largestTriangleThreeBuckets(xyPair, threshold, downsampledIndices),
          downsampledIndicesForSeries = _largestTriangleThree.downsampledIndices;

      downsampledIndicesForSeries.forEach(function (downsampleIndex) {
        return downsampledIndices.add(downsampleIndex);
      });
    } catch (e) {
      console.error("Error occurred while downsampling column ".concat(columnIndex), e);
    }
  }); // update data columns with downsampled columns

  downsampledDataSources.primary = pickIndicesFromDataSource(primaryDS, downsampledIndices);
  return downsampledDataSources;
};

exports.downsampleDataSources = downsampleDataSources;

/***/ }),
/* 26 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.validOutputModes = exports.validSegmentationModes = exports.validSortDirs = void 0;
exports.validSortDirs = ['asc', 'desc', 'none'];
exports.validSegmentationModes = ['none', 'inner'];
exports.validOutputModes = ['json_cols', 'json'];

/***/ }),
/* 27 */,
/* 28 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualization-context/TimezoneContext");

/***/ }),
/* 29 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualizations-shared/style");

/***/ }),
/* 30 */,
/* 31 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var react_1 = __webpack_require__(0);

function usePrevious(value) {
  var ref = (0, react_1.useRef)();
  (0, react_1.useEffect)(function () {
    ref.current = value;
  });
  return ref.current;
}

exports.default = usePrevious;

/***/ }),
/* 32 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  if (k2 === undefined) k2 = k;
  var desc = Object.getOwnPropertyDescriptor(m, k);

  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
    desc = {
      enumerable: true,
      get: function get() {
        return m[k];
      }
    };
  }

  Object.defineProperty(o, k2, desc);
} : function (o, m, k, k2) {
  if (k2 === undefined) k2 = k;
  o[k2] = m[k];
});

var __exportStar = this && this.__exportStar || function (m, exports) {
  for (var p in m) {
    if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  }
};

Object.defineProperty(exports, "__esModule", {
  value: true
});

__exportStar(__webpack_require__(33), exports);

__exportStar(__webpack_require__(34), exports);

__exportStar(__webpack_require__(26), exports);

__exportStar(__webpack_require__(35), exports);

__exportStar(__webpack_require__(36), exports);

__exportStar(__webpack_require__(37), exports);

__exportStar(__webpack_require__(38), exports);

__exportStar(__webpack_require__(39), exports);

__exportStar(__webpack_require__(40), exports);

__exportStar(__webpack_require__(41), exports);

__exportStar(__webpack_require__(14), exports);

__exportStar(__webpack_require__(18), exports);

__exportStar(__webpack_require__(19), exports);

__exportStar(__webpack_require__(42), exports);

__exportStar(__webpack_require__(43), exports);

__exportStar(__webpack_require__(44), exports);

__exportStar(__webpack_require__(45), exports);

__exportStar(__webpack_require__(46), exports);

__exportStar(__webpack_require__(47), exports);

/***/ }),
/* 33 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 34 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/**
 *  A data structure used at runtime to wire up a visualization.
 */

Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 35 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 36 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 37 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 38 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 39 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 40 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 41 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 42 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 43 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 44 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 45 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 46 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 47 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

/***/ }),
/* 48 */,
/* 49 */,
/* 50 */,
/* 51 */,
/* 52 */,
/* 53 */,
/* 54 */,
/* 55 */,
/* 56 */,
/* 57 */,
/* 58 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _classCallCheck = __webpack_require__(4);

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.INITIAL_HEIGHT = exports.INITIAL_WIDTH = void 0;
/* eslint-disable react/no-unused-prop-types,react/prefer-stateless-function */

var T = __webpack_require__(1);

var lodash_1 = __webpack_require__(3);

var VizActionHandler_1 = __webpack_require__(14); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations


exports.INITIAL_WIDTH = 250;
exports.INITIAL_HEIGHT = 250;
/**
 * A Splunk visualization
 */

var SplunkVisualization = function SplunkVisualization() {
  _classCallCheck(this, SplunkVisualization);
};

SplunkVisualization.propTypes = {
  /**
   * display mode
   */
  mode: T.oneOf(['view', 'edit', 'export']).isRequired,

  /**
   * width in pixel or string, defaults to 100%
   */
  width: T.oneOfType([T.string, T.number]).isRequired,

  /**
   * height in pixel or string
   */
  height: T.oneOfType([T.string, T.number]).isRequired,

  /**
   * visualization context used for dynamic option evaluation
   */
  context: T.object,

  /**
   * visualization formatting options
   */
  options: T.object,

  /**
   * A callback to update formatting options
   */
  onOptionsChange: T.func,

  /**
   * datasource state which include data and request params, object key indicate the datasource type.
   */
  dataSources: T.objectOf(T.shape({
    /**
     * current request params
     */
    requestParams: T.object,

    /**
     * current dataset
     */
    data: T.shape({
      fields: T.array,
      columns: T.array
    }),

    /**
     * error
     */
    error: T.shape({
      level: T.string,
      message: T.string
    }),

    /**
     * meta data that came with the dataset
     */
    meta: T.object
  })),

  /**
   * A callback to trigger event
   */
  onEventTrigger: T.func,

  /**
   * Inform viz if there are handlers listening to events
   */
  hasEventHandlers: T.bool,

  /**
   * A callback to communicate computed props to a consumer
   */
  onComputedProps: T.func,

  /**
   * A callback to obtain visualization api
   */
  vizActionHandlerRef: T.func,
  loading: T.bool,
  theme: T.object,

  /**
   * A callback to request new data with updated request params
   */
  onRequestParamsChange: T.func
};
/**
 *
 */

SplunkVisualization.defaultProps = {
  // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
  width: '100%',
  height: exports.INITIAL_HEIGHT,
  dataSources: {},
  onEventTrigger: function onEventTrigger() {
    return {};
  },
  mode: 'view',
  hasEventHandlers: false,
  options: {},
  context: {},
  onOptionsChange: function onOptionsChange() {
    return {};
  },
  vizActionHandlerRef: function vizActionHandlerRef() {
    return new VizActionHandler_1.DefaultVizActionHandler();
  },
  onComputedProps: function onComputedProps() {
    return {};
  },
  loading: false,
  onRequestParamsChange: lodash_1.noop
};
exports.default = SplunkVisualization;

/***/ }),
/* 59 */
/***/ (function(module, exports) {

module.exports = require("@splunk/themes/variables");

/***/ }),
/* 60 */,
/* 61 */,
/* 62 */,
/* 63 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualization-encoding/Options");

/***/ }),
/* 64 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _slicedToArray = __webpack_require__(8);

Object.defineProperty(exports, "__esModule", {
  value: true
});

var React = __webpack_require__(0);

var styled_components_1 = __webpack_require__(2);

var style_1 = __webpack_require__(29);

var colorUtils_1 = __webpack_require__(16);

var SizeAwareWrapper_1 = __webpack_require__(117);

var Item = styled_components_1.default.div.attrs(function (_ref) {
  var width = _ref.width;
  return {
    style: {
      width: (0, style_1.toPx)(width)
    }
  };
}).withConfig({
  displayName: "FixedSizeContainer__Item",
  componentId: "sc-1yhgpod-0"
})(["position:relative;background-color:", "};"], function (props) {
  return (0, colorUtils_1.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
}); // Use `.attrs()` for highly dynamic styles. Ref: https://github.com/styled-components/styled-components/issues/134#issuecomment-312415291

var FixSizeItem = styled_components_1.default.div.attrs(function (_ref2) {
  var width = _ref2.width,
      height = _ref2.height;
  return {
    style: Object.assign(Object.assign({}, width && {
      width: (0, style_1.toPx)(width)
    }), height && {
      height: (0, style_1.toPx)(height)
    })
  };
}).withConfig({
  displayName: "FixedSizeContainer__FixSizeItem",
  componentId: "sc-1yhgpod-1"
})(["position:relative;flex-direction:column;flex:1;display:flex;background-color:", "};"], function (props) {
  return (0, colorUtils_1.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
});
var ItemContent = styled_components_1.default.div.withConfig({
  displayName: "FixedSizeContainer__ItemContent",
  componentId: "sc-1yhgpod-2"
})(["position:relative;min-height:100px;width:100%;"]);
var FixSizeItemContent = styled_components_1.default.div.withConfig({
  displayName: "FixedSizeContainer__FixSizeItemContent",
  componentId: "sc-1yhgpod-3"
})(["min-height:0px;flex:1;position:relative;box-sizing:border-box;"]);

var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
  var FixedSizeContainer = function FixedSizeContainer(props) {
    var width = props.width,
        height = props.height,
        backgroundColor = props.backgroundColor;
    var cachedHandleResize = React.useCallback(function (w, h) {
      setContainerWidth(w);
      setContainerHeight(h);
    }, []);

    var _React$useState = React.useState(Number(props.width)),
        _React$useState2 = _slicedToArray(_React$useState, 2),
        containerWidth = _React$useState2[0],
        setContainerWidth = _React$useState2[1];

    var _React$useState3 = React.useState(Number(props.height)),
        _React$useState4 = _slicedToArray(_React$useState3, 2),
        containerHeight = _React$useState4[0],
        setContainerHeight = _React$useState4[1];

    if (!height) {
      return React.createElement(Item, {
        "data-test": "item",
        width: width,
        backgroundColor: backgroundColor
      }, React.createElement(ItemContent, null, React.createElement(Viz, Object.assign({}, props))));
    }

    return React.createElement(FixSizeItem, {
      "data-test": "fix-size-item",
      "data-splunk-visualization-version": "26.2.2 - ee84d373d",
      width: width,
      height: height,
      backgroundColor: backgroundColor
    }, React.createElement(FixSizeItemContent, null, React.createElement(SizeAwareWrapper_1.default, {
      width: width,
      height: height,
      onResize: cachedHandleResize
    }), React.createElement(Viz, Object.assign({}, props, {
      width: containerWidth,
      height: containerHeight
    }))));
  };

  FixedSizeContainer.displayName = 'withFixedSizeContainer';
  return FixedSizeContainer;
};

exports.default = withFixedSizeContainer;

/***/ }),
/* 65 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.extendStaticWrapperProps = void 0;
/**
 * @method extendStaticWrapperProps
 * @param {Object} props
 * @param {DashboardVizType} props.Wrapper
 * @param {DashboardVizType} props.Visualization
 */

var extendStaticWrapperProps = function extendStaticWrapperProps(_ref) {
  var Wrapper = _ref.Wrapper,
      Visualization = _ref.Visualization;
  var extendProperties = ['propTypes', 'defaultProps', 'config'];
  extendProperties.forEach(function (prop) {
    if (Visualization[prop]) {
      // eslint-disable-next-line no-param-reassign
      Wrapper[prop] = Visualization[prop];
    }
  });
};

exports.extendStaticWrapperProps = extendStaticWrapperProps;

/***/ }),
/* 66 */,
/* 67 */,
/* 68 */,
/* 69 */,
/* 70 */,
/* 71 */,
/* 72 */,
/* 73 */,
/* 74 */,
/* 75 */,
/* 76 */,
/* 77 */,
/* 78 */,
/* 79 */,
/* 80 */,
/* 81 */,
/* 82 */,
/* 83 */,
/* 84 */,
/* 85 */,
/* 86 */,
/* 87 */,
/* 88 */,
/* 89 */,
/* 90 */,
/* 91 */,
/* 92 */,
/* 93 */,
/* 94 */,
/* 95 */,
/* 96 */,
/* 97 */,
/* 98 */,
/* 99 */,
/* 100 */,
/* 101 */,
/* 102 */,
/* 103 */,
/* 104 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _slicedToArray = __webpack_require__(8);

Object.defineProperty(exports, "__esModule", {
  value: true
});

var React = __webpack_require__(0);

var lodash_1 = __webpack_require__(3);

var getSettingsFromThemedProps_1 = __webpack_require__(105);

var Options_1 = __webpack_require__(63);

var SanitizeProps_1 = __webpack_require__(106);

var TimezoneContext_1 = __webpack_require__(28);

var moment_1 = __webpack_require__(107);

var FeatureFlagContext_1 = __webpack_require__(108);

var styled_components_1 = __webpack_require__(2);

var hocUtils_1 = __webpack_require__(109);

var JSONSchemaUtils_1 = __webpack_require__(110);

var async_dynamic_options_evaluator_1 = __webpack_require__(111);

var id_1 = __webpack_require__(112);

var SplunkVisualization_1 = __webpack_require__(58);

var VizBehavior_1 = __webpack_require__(18);

var getSorting_1 = __webpack_require__(113);

var getPagination_1 = __webpack_require__(114);

var useDeepMemo_1 = __webpack_require__(115);

var MissingPropsMessage_1 = __webpack_require__(116);

var withEditModeCover_1 = __webpack_require__(118);

var withPlaceholder_1 = __webpack_require__(119);

var useDownsampleDataSources_1 = __webpack_require__(121);

var dataUtils_1 = __webpack_require__(25);

var featureFlagUtils_1 = __webpack_require__(123);
/**
 * hoc that wraps a pure react visualization in a Dashboard visualization
 * @param {DashboardVizOpts} opts
 * @returns {HOC}
 */


var withDashboardViz = function withDashboardViz(opts) {
  var ReactViz = opts.ReactViz,
      vizConfig = opts.vizConfig,
      _opts$computeVizProps = opts.computeVizProps,
      computeVizProps = _opts$computeVizProps === void 0 ? function () {} : _opts$computeVizProps,
      disableEditModeCover = opts.disableEditModeCover,
      useIconPlaceholder = opts.useIconPlaceholder; // sanitizing props before sending them to reactviz.

  var SanitizedReactViz = (0, SanitizeProps_1.withSanitizedProps)(ReactViz);
  var defaultOptions = (0, JSONSchemaUtils_1.pickFieldFromJSONSchema)(vizConfig.optionsSchema, 'default');

  var DashboardViz = function DashboardViz(props) {
    var _a;

    var mode = props.mode,
        hasEventHandlers = props.hasEventHandlers,
        dataSources = props.dataSources,
        options = props.options,
        _props$context = props.context,
        context = _props$context === void 0 ? {} : _props$context,
        width = props.width,
        height = props.height,
        onComputedProps = props.onComputedProps,
        onEventTrigger = props.onEventTrigger,
        theme = props.theme,
        onRequestParamsChange = props.onRequestParamsChange;

    var _React$useContext = React.useContext(TimezoneContext_1.default),
        serializedTimezone = _React$useContext.serializedTimezone;

    if (serializedTimezone) {
      /*
          @splunk/moment currently does not allow us to customize the timezone on a per visualization basis.
          This ensures that if a timezone was provided via TimezoneContext @splunk/moment time formatting
           will use it.
           @TODO(pwied):
           - remove when we moved away from @splunk/moment
           - provide timezone context to dynamic option evaluation phase
      */
      if (!moment_1.default.getDefaultSplunkTimezone()) {
        moment_1.default.setDefaultSplunkTimezone(serializedTimezone);
      }
    }

    var themeFunc = function themeFunc(themeVar) {
      var _a, _b;

      return (_b = (_a = vizConfig.themes)[themeVar]) === null || _b === void 0 ? void 0 : _b.call(_a, props);
    };

    var bgColorFromTheme = themeFunc('defaultBackgroundColor');

    var _ref = (0, getSettingsFromThemedProps_1.default)({
      theme: theme
    }),
        currentThemeFamily = _ref.family,
        currentThemeColorScheme = _ref.colorScheme,
        currentThemeDensity = _ref.density;

    var evaluatedOptions = {}; // evaluatedOptions need to be initialized as an empty object

    var _React$useState = React.useState({}),
        _React$useState2 = _slicedToArray(_React$useState, 2),
        evaluatedOptionsAsync = _React$useState2[0],
        setEvaluatedOptionsAsync = _React$useState2[1]; // evaluatedOptions need to be initialized as an empty object


    var featureFlagContext = React.useContext(FeatureFlagContext_1.default);

    var _React$useState3 = React.useState("".concat(vizConfig.name, " - ").concat((0, id_1.createGUID)())),
        _React$useState4 = _slicedToArray(_React$useState3, 1),
        visualizationID = _React$useState4[0];

    var _React$useState5 = React.useState({}),
        _React$useState6 = _slicedToArray(_React$useState5, 2),
        dataSourcesInState = _React$useState6[0],
        setDataSourcesInState = _React$useState6[1];

    var _React$useState7 = React.useState(),
        _React$useState8 = _slicedToArray(_React$useState7, 2),
        dataFramesInState = _React$useState8[0],
        setDataFramesInState = _React$useState8[1];

    var _React$useState9 = React.useState(Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_useWebWorkersForDSL'))),
        _React$useState10 = _slicedToArray(_React$useState9, 2),
        useAsyncEvaluatedOptions = _React$useState10[0],
        setUseAsyncEvaluatedOptions = _React$useState10[1];

    var isDownsamplingEnabledByFeatureFlag = Boolean(featureFlagContext === null || featureFlagContext === void 0 ? void 0 : featureFlagContext.visualizations_enableDownsampling);
    var isMounted = React.useRef(true);
    var optionsToEvaluate = React.useMemo(function () {
      return {
        context: (0, lodash_1.defaultsDeep)({}, context, vizConfig.defaultContext),
        options: (0, hocUtils_1.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
      };
    }, [options, context]);

    var _React$useState11 = React.useState(Number(width)),
        _React$useState12 = _slicedToArray(_React$useState11, 2),
        threshold = _React$useState12[0],
        setThreshold = _React$useState12[1];

    var onDownsamplingThresholdChange = React.useCallback(function (newThreshold) {
      setThreshold(newThreshold);
    }, []);
    var isDownsamplingEnabled = React.useMemo(function () {
      return isDownsamplingEnabledByFeatureFlag && (0, dataUtils_1.isDownsamplingEnabledForViz)({
        vizConfig: vizConfig
      });
    }, [isDownsamplingEnabledByFeatureFlag]);
    var downsamplingProps = React.useMemo(function () {
      if (!isDownsamplingEnabled) {
        return {};
      }

      return {
        onDownsamplingThresholdChange: onDownsamplingThresholdChange,
        originalDataSources: dataSources
      };
    }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
    var downsampledDataSources = (0, useDownsampleDataSources_1.default)({
      options: optionsToEvaluate.options,
      context: optionsToEvaluate.context,
      dataSources: dataSources,
      threshold: threshold,
      isDownsamplingEnabled: isDownsamplingEnabled
    });
    evaluatedOptions = (0, useDeepMemo_1.useDeepMemo)(function () {
      try {
        if (useAsyncEvaluatedOptions) {
          var asyncDynamicOptionsEvaluatorParams = {
            visualizationID: visualizationID,
            props: props,
            options: optionsToEvaluate,
            dataSources: downsampledDataSources,
            theme: vizConfig.themes,
            bypassCloneDeepOptionScope: Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_bypassCloneDeepOptionScope')),
            lazyLoadingDataFrame: Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_lazyLoadingDataFrame'))
          };
          async_dynamic_options_evaluator_1.default.evaluate(asyncDynamicOptionsEvaluatorParams).then(function (results) {
            setEvaluatedOptionsAsync(results.results);
          }).catch(function () {
            if (isMounted.current) {
              setUseAsyncEvaluatedOptions(false);
            }
          });
        } else {
          var dataFrames = dataFramesInState;

          if (downsampledDataSources !== dataSourcesInState) {
            setDataSourcesInState(downsampledDataSources);
            dataFrames = Options_1.Options.dataFrameFromDataSource(downsampledDataSources, (0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_lazyLoadingDataFrame'));
            setDataFramesInState(dataFrames);
          }

          var result = Options_1.Options.evaluate(optionsToEvaluate, downsampledDataSources, themeFunc, dataFrames, (0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_bypassCloneDeepOptionScope'));
          return result;
        }
      } catch (e) {
        // eslint-disable-next-line no-console
        console.error("unexpected error evaluating options: ".concat(e.message));
        return {};
      }

      return {};
    }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, optionsToEvaluate, downsampledDataSources, serializedTimezone, useAsyncEvaluatedOptions]);
    var evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync; // trellis specific backgroundColor update for onComputedProps
    // 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
    // onComputedProps api should return back trellisBackgroundColor value for backgroundColor option to support coloring of sibling panels (for eg:- title/ description on UDF side)

    var isTrellisFeatureFlagOn = Boolean(featureFlagContext && featureFlagContext.visualizations_enableTrellis);
    var clonedEvaluatedOptions = evaluatedOptionsToUse;

    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) {
      clonedEvaluatedOptions = Object.assign(Object.assign({}, evaluatedOptionsToUse), {
        backgroundColor: clonedEvaluatedOptions === null || clonedEvaluatedOptions === void 0 ? void 0 : clonedEvaluatedOptions.trellisBackgroundColor
      });
    } // useEffect hook needs to be initialized before any early returns
    // this is in accordance with the order of hook calls being the same on each render https://reactjs.org/docs/hooks-rules.html#explanation


    React.useEffect(function () {
      onComputedProps(clonedEvaluatedOptions);
    });
    React.useEffect(function () {
      return function () {
        if (useAsyncEvaluatedOptions) {
          isMounted.current = false;
          async_dynamic_options_evaluator_1.default.reset(visualizationID);
        }
      }; // eslint-disable-next-line react-hooks/exhaustive-deps
    }, []); // present warning message if any required props are missing

    var _vizConfig$requiredPr = vizConfig.requiredProps,
        requiredProps = _vizConfig$requiredPr === void 0 ? [] : _vizConfig$requiredPr,
        supports = vizConfig.supports;
    var missing = (0, MissingPropsMessage_1.missingKeys)(requiredProps, evaluatedOptionsToUse);

    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
    ) {
        return React.createElement(MissingPropsMessage_1.default, {
          "data-test": "missing-props-message",
          width: width,
          height: height,
          missingProps: missing,
          backgroundColor: bgColorFromTheme
        });
      } // events


    var eventCallbackProps = {};

    if (hasEventHandlers && mode === 'view' && vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.EVENTS) > -1) {
      var supportedEvents = vizConfig.events;
      Object.keys(supportedEvents).forEach(function (eventName) {
        var _supportedEvents$even = supportedEvents[eventName],
            parentKeys = _supportedEvents$even.parentKeys,
            payloadKeys = _supportedEvents$even.payloadKeys;
        var eventCallbackPropName = (0, lodash_1.camelCase)("on.".concat(eventName)); // todo: refactor single value and single value icon to send payload from viz
        // then remove these lines

        var payload = {};

        if (Array.isArray(payloadKeys) && payloadKeys.length) {
          payloadKeys.forEach(function (p) {
            payload[p] = evaluatedOptionsToUse[p];
          });
        }

        eventCallbackProps[eventCallbackPropName] = function (ev) {
          if (ev && ev.payload) {
            payload = ev.payload;
          }

          return onEventTrigger({
            originalEvent: ev,
            payload: payload,
            type: eventName
          });
        };

        if (parentKeys) {
          for (var i = parentKeys.length - 1; i >= 0; i -= 1) {
            var newObject = {};
            newObject[parentKeys[i]] = eventCallbackProps[eventCallbackPropName];
            eventCallbackProps[eventCallbackPropName] = newObject;
          }
        }
      });
    } // compute pure viz props which are not from options


    var computedVizProps = computeVizProps(Object.assign(Object.assign(Object.assign(Object.assign({}, props), evaluatedOptionsToUse), eventCallbackProps), {
      themeFunc: themeFunc
    }));
    /**
     * PAGE_AND_SORT behavior
     *
     * Some visualizations, like table, requires metadata about the datasource,
     * like total number of results, current count, offset, and sort, for rendering
     * paginator and sorting direction. In this approach, the visualization
     * allow users to set 'paginateDataSourceKey' to select which datasource
     * should the visualization extract the metadata from. It defaults to 'primary' datasource.
     * The visualization config should set the PAGE_AND_SORT behavior to receive
     * 'requestParams', 'meta' and onRequestParams callback as props.
     *
     * In future, we could automatically detect which all datasources are being used
     * and bind those magically to pagination/sorting behavior.
     */

    var dataSourceMetadata = {};
    var OptionKey = 'paginateDataSourceKey';
    var paginateDataSourceKey = (0, lodash_1.has)(evaluatedOptionsToUse, OptionKey) && evaluatedOptionsToUse[OptionKey] || 'primary';

    if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.PAGE_AND_SORT) > -1 && (0, lodash_1.has)(dataSources, paginateDataSourceKey)) {
      var requestParams = (0, lodash_1.get)(dataSources, [paginateDataSourceKey, 'requestParams'], {});
      var meta = (0, lodash_1.get)(dataSources, [paginateDataSourceKey, 'meta'], {});

      var handleRequestParamsChange = function handleRequestParamsChange(payload) {
        return onRequestParamsChange(paginateDataSourceKey, payload);
      };

      var sortParams = (0, getSorting_1.getSortingParams)({
        requestParams: requestParams,
        meta: meta,
        onRequestParamsChange: handleRequestParamsChange
      });
      var paginatorParams = (0, getPagination_1.getPaginationParams)({
        requestParams: requestParams,
        meta: meta,
        onRequestParamsChange: handleRequestParamsChange
      });
      dataSourceMetadata = {
        sortParams: sortParams,
        paginatorParams: paginatorParams
      };
    } // if were using webworkers and this is the first render we dont want to show a viz with missing data so we return null


    if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
      return null;
    }

    return React.createElement(SanitizedReactViz, Object.assign({
      mode: mode,
      width: width,
      height: height
    }, downsamplingProps, evaluatedOptionsToUse, computedVizProps, eventCallbackProps, dataSourceMetadata));
  };

  DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
  DashboardViz.defaultProps = Object.assign(Object.assign(Object.assign({}, SplunkVisualization_1.default.defaultProps), ReactViz.defaultProps), {
    // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
    theme: {}
  }); // attach viz config

  DashboardViz.config = vizConfig; // @ts-ignore: TODO fix sc upgrade TS issues

  return (0, styled_components_1.withTheme)((0, withPlaceholder_1.default)((0, withEditModeCover_1.default)(DashboardViz, disableEditModeCover), useIconPlaceholder));
};

exports.default = withDashboardViz;

/***/ }),
/* 105 */
/***/ (function(module, exports) {

module.exports = require("@splunk/themes/getSettingsFromThemedProps");

/***/ }),
/* 106 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualizations-shared/SanitizeProps");

/***/ }),
/* 107 */
/***/ (function(module, exports) {

module.exports = require("@splunk/moment");

/***/ }),
/* 108 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualization-context/FeatureFlagContext");

/***/ }),
/* 109 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualizations-shared/hocUtils");

/***/ }),
/* 110 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualizations-shared/JSONSchemaUtils");

/***/ }),
/* 111 */
/***/ (function(module, exports) {

module.exports = require("@splunk/async-dynamic-options-evaluator");

/***/ }),
/* 112 */
/***/ (function(module, exports) {

module.exports = require("@splunk/ui-utils/id");

/***/ }),
/* 113 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _defineProperty = __webpack_require__(10);

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getSortingParams = exports.SortParamsPropTypes = void 0;

var T = __webpack_require__(1);

var lodash_1 = __webpack_require__(3);

var DataSource_1 = __webpack_require__(26);

exports.SortParamsPropTypes = T.shape({
  currentSortKey: T.string,
  currentSortDir: T.oneOf(DataSource_1.validSortDirs),
  onSort: T.func
});

var getSortingParams = function getSortingParams(_ref) {
  var requestParams = _ref.requestParams,
      onRequestParamsChange = _ref.onRequestParamsChange;
  var currentSortKey;
  var currentSortDir;
  var nextSortDirMap = {
    asc: 'desc',
    desc: 'asc',
    none: 'asc'
  };
  var onSort;

  if (typeof onRequestParamsChange === 'function') {
    if (requestParams && (0, lodash_1.has)(requestParams, 'sort')) {
      currentSortKey = Object.keys(requestParams.sort).shift();
      currentSortDir = requestParams.sort[currentSortKey];
    } // undid memoization since there is a dependency on requestParams, which is a deeply nested object


    onSort = function onSort(e, _ref2) {
      var sortKey = _ref2.sortKey,
          sortDir = _ref2.sortDir;

      if (typeof sortKey === 'string') {
        var nextSortDir = (0, lodash_1.has)(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : 'none';
        onRequestParamsChange(Object.assign(Object.assign({}, requestParams), {
          offset: 0,
          sort: _defineProperty({}, sortKey, nextSortDir)
        }));
      } else {
        onRequestParamsChange(requestParams);
      }
    };
  }

  return {
    currentSortKey: currentSortKey,
    currentSortDir: currentSortDir,
    onSort: onSort
  };
};

exports.getSortingParams = getSortingParams;

/***/ }),
/* 114 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getPaginationParams = exports.PaginatorParamsPropTypes = void 0;

var T = __webpack_require__(1);

var lodash_1 = __webpack_require__(3);

exports.PaginatorParamsPropTypes = T.shape({
  isPaging: T.bool,
  current: T.number,
  totalPages: T.number,
  onChange: T.func
});

var getPaginationParams = function getPaginationParams(_ref) {
  var requestParams = _ref.requestParams,
      meta = _ref.meta,
      onRequestParamsChange = _ref.onRequestParamsChange;
  var totalCount = meta && meta.totalCount || 0;
  var offset = requestParams && requestParams.offset || 0;
  var count = requestParams && requestParams.count;
  var totalPages = typeof count === 'number' && count > 0 ? Math.ceil(totalCount / count) : 0;
  var current = typeof count === 'number' && count > 0 ? Math.floor(offset / count) + 1 : 0;
  var isPaging = totalPages > 1 && typeof onRequestParamsChange === 'function';

  var onChangeHandler = function onChangeHandler(e, _ref2) {
    var page = _ref2.page,
        countArg = _ref2.count;
    var newParams = (0, lodash_1.cloneDeep)(requestParams);

    if (typeof countArg === 'number') {
      newParams.count = countArg;
      newParams.offset = 0;
    }

    var pageCount = typeof newParams.count === 'number' ? newParams.count : 10;

    if (typeof page === 'number' && page > 0) {
      newParams.count = pageCount;
      newParams.offset = (page - 1) * pageCount;
    }

    onRequestParamsChange(newParams);
  };

  return {
    isPaging: isPaging,
    current: current,
    totalPages: totalPages,
    onChange: typeof onRequestParamsChange === 'function' ? onChangeHandler : lodash_1.noop
  };
};

exports.getPaginationParams = getPaginationParams;

/***/ }),
/* 115 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useDeepMemo = void 0;

var react_1 = __webpack_require__(0);

var lodash_1 = __webpack_require__(3);
/**
 * This hook evaluates and stores the result of a passed function and only
 * re-evaluates the function when passed dependencies change.
 *
 * It is different from the internal React useMemo in the following aspects:
 * - it only stores the last evaluated result
 * - it uses a deep equality check to determine if dependencies have changed
 *
 * Inspired by apollo-client's useDeepMemo
 *
 * @param fn the function to be executed and
 * @param dependencies an array of dependencies
 */


var useDeepMemo = function useDeepMemo(fn, dependencies) {
  var ref = (0, react_1.useRef)();

  if (!ref.current || !(0, lodash_1.isEqual)(dependencies, ref.current.dependencies)) {
    ref.current = {
      dependencies: dependencies,
      value: fn()
    };
  }

  return ref.current.value;
};

exports.useDeepMemo = useDeepMemo;

/***/ }),
/* 116 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MissingPropsMessage = exports.missingKeys = exports.isMissing = void 0;

var React = __webpack_require__(0);

var T = __webpack_require__(1);

var i18n_1 = __webpack_require__(5);

var Message_1 = __webpack_require__(24);

var FixedSizeContainer_1 = __webpack_require__(64);
/**
 * @method isMissing
 * @param {any} v
 * @returns {boolean} true if the input value === null or undefined
 */


var isMissing = function isMissing(v) {
  return v === null || v === undefined;
};

exports.isMissing = isMissing;
/**
 * @method misskingKeys
 * @param {string[]} keys
 * @param {object} target
 * @returns {string[]} the keys of missing required props
 */

var missingKeys = function missingKeys(keys, target) {
  return keys.filter(function (k) {
    return (0, exports.isMissing)(target[k]);
  });
};

exports.missingKeys = missingKeys;
var propTypes = {
  width: T.oneOfType([T.string, T.number]),
  height: T.oneOfType([T.string, T.number]),
  // eslint-disable-next-line react/no-unused-prop-types
  backgroundColor: T.string,
  missingProps: T.arrayOf(T.string)
};
/**
 * @method MissingPropsMessage
 * @param {MissingPropsProps} props
 * @returns {React.ReactElement}
 */

var MissingPropsMessage = function MissingPropsMessage(props) {
  var width = props.width,
      height = props.height,
      missingProps = props.missingProps;
  return React.createElement(Message_1.default, {
    "data-test": "message",
    width: width,
    height: height,
    message: (0, i18n_1._)("Missing property: ".concat(missingProps.join(', ')))
  });
};

exports.MissingPropsMessage = MissingPropsMessage;
exports.MissingPropsMessage.propTypes = propTypes;
exports.MissingPropsMessage.defaultProps = {
  width: '100%',
  height: 250
};
exports.default = (0, FixedSizeContainer_1.default)(exports.MissingPropsMessage);

/***/ }),
/* 117 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");

/***/ }),
/* 118 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var React = __webpack_require__(0);

var styled_components_1 = __webpack_require__(2);

var hocUtils_1 = __webpack_require__(65);

var Cover = styled_components_1.default.div.withConfig({
  displayName: "withEditModeCover__Cover",
  componentId: "sc-1gsbnxb-0"
})(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
var Blocker = styled_components_1.default.div.attrs({
  'data-splunk-visualization-version': "26.2.2 - ee84d373d"
}).withConfig({
  displayName: "withEditModeCover__Blocker",
  componentId: "sc-1gsbnxb-1"
})(["position:relative;width:100%;height:100%;"]);
/**
 * HOC that renders a cover layer in edit mode
 * @method withEditModeCover
 * @param {ExtendedDashViz} Visualization
 * @returns {ExtendedDashViz} Wrapper
 */

var withEditModeCover = function withEditModeCover(Visualization, disableEditModeCover) {
  var Wrapper = function Wrapper(props) {
    var mode = props.mode;
    var showEditCover = mode === 'edit' && !disableEditModeCover;
    return React.createElement(Blocker, null, React.createElement(Visualization, Object.assign({}, props)), showEditCover && React.createElement(Cover, {
      "data-test": "edit-mode-cover"
    }));
  };

  (0, hocUtils_1.extendStaticWrapperProps)({
    Wrapper: Wrapper,
    Visualization: Visualization
  });
  return Wrapper;
};

exports.default = withEditModeCover;

/***/ }),
/* 119 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var React = __webpack_require__(0);

var colorUtils_1 = __webpack_require__(16);

var variables_1 = __webpack_require__(59);

var IconPlaceholder_1 = __webpack_require__(120);

var VizBehavior_1 = __webpack_require__(18);

var hocUtils_1 = __webpack_require__(65);

var withPlaceholder = function withPlaceholder(Visualization) {
  var useIconPlaceholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IconPlaceholder_1.shouldShowIconPlaceholder;
  var config = Visualization.config;
  var themes = config.themes;

  var Wrapper = function Wrapper(props) {
    var _a, _b;

    var dataSources = props.dataSources,
        loading = props.loading,
        options = props.options,
        height = props.height,
        width = props.width;
    var showPlaceholder = useIconPlaceholder(dataSources, loading, options);
    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);
    var icon = (_b = config.placeholderIcon) !== null && _b !== void 0 ? _b : config.icon;
    var iconColor = variables_1.default.contentColorActive(props);

    if (config.supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER) && showPlaceholder) {
      return React.createElement(IconPlaceholder_1.default, {
        "data-test": "icon-placeholder",
        icon: icon,
        width: width,
        height: height,
        backgroundColor: bgColorFromTheme,
        iconColor: iconColor
      });
    }

    return React.createElement(Visualization, Object.assign({}, props));
  };

  (0, hocUtils_1.extendStaticWrapperProps)({
    Wrapper: Wrapper,
    Visualization: Visualization
  });
  return Wrapper;
};

exports.default = withPlaceholder;

/***/ }),
/* 120 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.shouldShowIconPlaceholder = void 0;

var React = __webpack_require__(0);

var T = __webpack_require__(1);

var lodash_1 = __webpack_require__(3);

var i18n_1 = __webpack_require__(5);

var Message_1 = __webpack_require__(24);

var FixedSizeContainer_1 = __webpack_require__(64);
/**
 * @method shouldShowIconPlaceholder
 * @param {object} dataSources
 * @param {boolean} loading
 * @returns {boolean}
 */


var shouldShowIconPlaceholder = function shouldShowIconPlaceholder(dataSources) {
  var loading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  var data = (0, lodash_1.get)(dataSources, 'primary.data.columns[0]', undefined);
  var noData = data === undefined;
  var fields = (0, lodash_1.get)(dataSources, 'primary.data.fields[0]', undefined);
  var noFields = fields === undefined;
  return loading || noData || noFields;
};

exports.shouldShowIconPlaceholder = shouldShowIconPlaceholder;
var propTypes = {
  icon: T.func,
  width: T.oneOfType([T.string, T.number]),
  height: T.oneOfType([T.string, T.number]),
  // eslint-disable-next-line react/no-unused-prop-types
  backgroundColor: T.string,
  iconColor: T.string
};
/**
 * @method IconPlaceholder
 * @param {IconPlaceholderProps} props
 * @returns {React.ReactElement}
 */

var IconPlaceholder = function IconPlaceholder(props) {
  var width = props.width,
      height = props.height,
      icon = props.icon,
      iconColor = props.iconColor;

  if (icon) {
    return React.createElement(icon, {
      style: {
        left: '50%',
        top: '50%',
        color: iconColor,
        opacity: 0.15,
        position: 'absolute',
        transform: 'translate(-50%, -50%)'
      },
      width: '50%',
      height: '50%',
      'data-test': 'icon-placeholder'
    });
  }

  return React.createElement(Message_1.default, {
    width: width,
    height: height,
    level: "warning",
    message: (0, i18n_1._)('No DataSource Connected')
  });
};

IconPlaceholder.propTypes = propTypes;
IconPlaceholder.defaultProps = {
  width: '100%',
  height: 250
};
exports.default = (0, FixedSizeContainer_1.default)(IconPlaceholder);

/***/ }),
/* 121 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _slicedToArray = __webpack_require__(8);

Object.defineProperty(exports, "__esModule", {
  value: true
});

var react_1 = __webpack_require__(0);

var lodash_1 = __webpack_require__(3);

var dataUtils_1 = __webpack_require__(25);

var usePrevious_1 = __webpack_require__(31);

var useGetXAndYFields_1 = __webpack_require__(122);

var useDownsampleDataSources = function useDownsampleDataSources(_ref) {
  var dataSources = _ref.dataSources,
      options = _ref.options,
      context = _ref.context,
      threshold = _ref.threshold,
      isDownsamplingEnabled = _ref.isDownsamplingEnabled;
  var isFirstUseEffectCall = (0, react_1.useRef)(true);
  var xAndYFieldsWithTypes = (0, useGetXAndYFields_1.default)({
    shouldEvaluateDSL: isDownsamplingEnabled,
    options: options,
    context: context,
    dataSources: dataSources
  });
  var previousXAndYFieldsWithTypes = (0, usePrevious_1.default)(xAndYFieldsWithTypes);
  var previousDataSources = (0, usePrevious_1.default)(dataSources);
  var previousThreshold = (0, usePrevious_1.default)(threshold);

  var _ref2 = (0, react_1.useState)(function () {
    return isDownsamplingEnabled ? (0, dataUtils_1.downsampleDataSources)({
      dataSources: dataSources,
      threshold: threshold,
      options: xAndYFieldsWithTypes
    }) : dataSources;
  }),
      _ref3 = _slicedToArray(_ref2, 2),
      downsampledDataSources = _ref3[0],
      setDownsampledDataSources = _ref3[1];

  var debouncedDownsampleDataSources = (0, react_1.useMemo)(function () {
    return (0, lodash_1.debounce)(function (downsampleOptions) {
      var downsampledResult = (0, dataUtils_1.downsampleDataSources)(downsampleOptions);
      setDownsampledDataSources(downsampledResult);
    }, 100, {
      trailing: true
    });
  }, []);
  (0, react_1.useEffect)(function () {
    // don't downsample again on the use effect call that happened due to the initial render
    // this is since we already downsampled as part of the useState call
    if (isFirstUseEffectCall.current) {
      isFirstUseEffectCall.current = false;
      return;
    }

    if (!isDownsamplingEnabled) {
      setDownsampledDataSources(dataSources);
      return;
    }

    if ((0, lodash_1.isEqual)(previousXAndYFieldsWithTypes, xAndYFieldsWithTypes) && previousDataSources === dataSources && previousThreshold === threshold) {
      return;
    } // Debounce the downsampling so we don't have to downsample and execute DSL multiple times
    // while the viz is being resized


    debouncedDownsampleDataSources({
      dataSources: dataSources,
      options: xAndYFieldsWithTypes,
      threshold: threshold
    }); // need to detect if this runs as part of the initial render
  }, [dataSources, debouncedDownsampleDataSources, xAndYFieldsWithTypes, threshold, isDownsamplingEnabled, previousXAndYFieldsWithTypes, previousDataSources, previousThreshold]);
  return downsampledDataSources;
};

exports.default = useDownsampleDataSources;

/***/ }),
/* 122 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _toConsumableArray = __webpack_require__(22);

Object.defineProperty(exports, "__esModule", {
  value: true
});

var react_1 = __webpack_require__(0);

var Options_1 = __webpack_require__(63);
/**
 * Hook that evaluates the DSL for subset of a viz's options needed to determine
 * its x and y fields as well as the types of all its fields.
 */


var useGetXAndYFields = function useGetXAndYFields(_ref) {
  var shouldEvaluateDSL = _ref.shouldEvaluateDSL,
      options = _ref.options,
      context = _ref.context,
      dataSources = _ref.dataSources;

  var _ref2 = (0, react_1.useMemo)(function () {
    var _a, _b, _c;

    if (!shouldEvaluateDSL) {
      return {
        dataSourcesWithOnlyOnePoint: null,
        dataFrameWithOnlyOnePoint: null
      };
    }

    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)) {
      return {
        dataSourcesWithOnlyOnePoint: null,
        dataFrameWithOnlyOnePoint: null
      };
    }

    var primaryDS = dataSources.primary;
    var columnsWithOnlyOnePoint = primaryDS.data.columns.map(function (column) {
      return [column[0]];
    });
    var filteredDataSources = {
      primary: Object.assign(Object.assign({}, primaryDS), {
        data: Object.assign(Object.assign({}, primaryDS.data), {
          columns: columnsWithOnlyOnePoint
        })
      })
    };
    return {
      dataSourcesWithOnlyOnePoint: filteredDataSources,
      dataFrameWithOnlyOnePoint: Options_1.Options.dataFrameFromDataSource(filteredDataSources)
    };
  }, [dataSources, shouldEvaluateDSL]),
      dataSourcesWithOnlyOnePoint = _ref2.dataSourcesWithOnlyOnePoint,
      dataFrameWithOnlyOnePoint = _ref2.dataFrameWithOnlyOnePoint;

  var xAndYFieldsWithTypes = (0, react_1.useMemo)(function () {
    try {
      if (!dataSourcesWithOnlyOnePoint || !dataFrameWithOnlyOnePoint) {
        return options;
      }

      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)) {
        return options;
      }

      var optionsToEvaluate = {
        x: options.x,
        xField: '> x | getField()',
        y: options.y,
        yFields: options.y ? '> y | getField()' : undefined,
        y2: options.y2,
        y2Fields: options.y2 ? '> y2 | getField()' : undefined,
        fieldTypes: '> primary | getType()'
      };

      var _Options_1$Options$ev = Options_1.Options.evaluate({
        options: optionsToEvaluate,
        context: context
      }, dataSourcesWithOnlyOnePoint, function () {}, dataFrameWithOnlyOnePoint),
          _Options_1$Options$ev2 = _Options_1$Options$ev.xField,
          xField = _Options_1$Options$ev2 === void 0 ? '' : _Options_1$Options$ev2,
          _Options_1$Options$ev3 = _Options_1$Options$ev.yFields,
          yFields = _Options_1$Options$ev3 === void 0 ? [] : _Options_1$Options$ev3,
          _Options_1$Options$ev4 = _Options_1$Options$ev.y2Fields,
          y2Fields = _Options_1$Options$ev4 === void 0 ? [] : _Options_1$Options$ev4,
          fieldTypes = _Options_1$Options$ev.fieldTypes;

      return {
        xField: xField,
        yFields: [].concat(_toConsumableArray(yFields), _toConsumableArray(y2Fields)),
        fieldTypes: fieldTypes
      };
    } catch (e) {
      return {
        xField: undefined,
        yFields: [],
        fieldTypes: []
      };
    }
  }, [options, context, dataSourcesWithOnlyOnePoint, dataFrameWithOnlyOnePoint]);
  return xAndYFieldsWithTypes;
};

exports.default = useGetXAndYFields;

/***/ }),
/* 123 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getFeatureFlag = void 0;

var FeatureFlags_1 = __webpack_require__(124);

var getFeatureFlag = function getFeatureFlag(context, flagName) {
  // look for feature flag in context first
  if (context && Object.keys(context).find(function (key) {
    return key === flagName;
  })) {
    return context[flagName];
  } // fall back to defaults


  if (Object.keys(FeatureFlags_1.default).find(function (key) {
    return key === flagName;
  })) {
    return FeatureFlags_1.default[flagName];
  } // fall back to false


  return false;
};

exports.getFeatureFlag = getFeatureFlag;

/***/ }),
/* 124 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualization-context/FeatureFlags");

/***/ })
/******/ ]);
//# sourceMappingURL=withDashboardViz.js.map