/*!
 * 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 = 98);
/******/ })
/************************************************************************/
/******/ ({

/***/ 22:
/***/ (function(module, exports) {

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

/***/ }),

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

module.exports = require("lodash");

/***/ }),

/***/ 98:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _toConsumableArray = __webpack_require__(22);

var __rest = this && this.__rest || function (s, e) {
  var t = {};

  for (var p in s) {
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  }

  if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
    if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  }
  return t;
};

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.shouldEnableSearchZoom = exports.constructFieldsAndColumns = exports.toArrayForSeries = exports.isMultiSeriesData = exports.convertOverlayFields = exports.convertY2AxisOptions = exports.mapToValues = exports.truncateData = exports.getAnnotations = void 0;

var lodash_1 = __webpack_require__(3);
/**
 * Get formatted annotations
 * @method getAnnotations
 * @param {Object} options
 * @param {Array} options.annotationX
 * @param {Array} options.annotationColor
 * @param {Array} options.annotationLabel
 * @returns {Array}
 */


var getAnnotations = function getAnnotations(_ref) {
  var annotationX = _ref.annotationX,
      annotationColor = _ref.annotationColor,
      annotationLabel = _ref.annotationLabel;
  return annotationX && annotationX.length ? annotationX.map(function (timestamp, i) {
    return {
      color: annotationColor && annotationColor[i],
      label: annotationLabel && annotationLabel[i],
      time: timestamp
    };
  }) : [];
};

exports.getAnnotations = getAnnotations;
/**
 * Truncate the result set to given limit
 * @method truncateData
 * @param {Object} dataSet - dataSources.primary.data
 * @param {Number|String} truncationLimit - options['chart.resultTruncationLimit']
 * @returns {Object}
 */

var truncateData = function truncateData(dataSet, truncationLimit) {
  if (!dataSet) {
    return null;
  }

  var limit = parseInt(truncationLimit, 10);

  if (!limit || limit <= 0) {
    return dataSet;
  }

  var truncatedData = Object.assign({}, dataSet);
  truncatedData.columns = truncatedData.columns.map(function (columnData) {
    return columnData && Array.isArray(columnData) ? columnData.slice(0, limit) : columnData;
  });
  return truncatedData;
};

exports.truncateData = truncateData;
/**
 * Helper method to update the option values into the values that SC accepts
 * @method mapToValues
 * @param {Object} options
 * @returns {Object}
 */

var mapToValues = function mapToValues(optionValuesSCMapping) {
  return function (options) {
    var convertedOptions = Object.assign({}, options);
    Object.keys(optionValuesSCMapping).forEach(function (key) {
      if ((0, lodash_1.has)(options, key)) {
        var updatedValue = optionValuesSCMapping[key][options[key]];

        if (!(0, lodash_1.isUndefined)(updatedValue)) {
          convertedOptions[key] = updatedValue;
        }
      }
    });
    return convertedOptions;
  };
};

exports.mapToValues = mapToValues;
/**
 * Helper method to process options related to y2Fields
 * @method convertY2AxisOptions
 * @param {Object} originalOptions
 * @returns {Object}
 */

var convertY2AxisOptions = function convertY2AxisOptions(_a) {
  var y2Fields = _a.y2Fields,
      originalOptions = __rest(_a, ["y2Fields"]);

  var convertedOptions = Object.assign({}, originalOptions);

  if (y2Fields) {
    convertedOptions['axisY2.enabled'] = true;
    convertedOptions['axisY2.fields'] = (0, lodash_1.isArray)(y2Fields) ? y2Fields.filter(function (name) {
      return name;
    }).join(',') : y2Fields;
  }

  return convertedOptions;
};

exports.convertY2AxisOptions = convertY2AxisOptions;
/**
 * Helper method to format value for overlayFields
 * @method convertOverlayFields
 * @param {Object} originalOptions
 * @returns {Object}
 */

var convertOverlayFields = function convertOverlayFields(originalOptions) {
  var convertedOptions = Object.assign({}, originalOptions);
  var overlayFields = originalOptions.overlayFields;

  if (overlayFields) {
    convertedOptions.overlayFields = Array.isArray(overlayFields) ? overlayFields.filter(function (field) {
      return field;
    }).map(function (field) {
      return field.trim();
    }).join(',') : overlayFields;
  }

  return convertedOptions;
};

exports.convertOverlayFields = convertOverlayFields;
/**
 * checks whether data is multi series data
 * @param {array} data array
 * @return {Boolean}
 */

var isMultiSeriesData = function isMultiSeriesData(data) {
  return Array.isArray(data) && Array.isArray(data[0]);
};

exports.isMultiSeriesData = isMultiSeriesData;
/**
 * checks whether data is multi series data and returns value as array
 * @param {array} data array
 * @param {*} value to return as array
 * @return {array}
 */

var toArrayForSeries = function toArrayForSeries(data, value) {
  return (0, exports.isMultiSeriesData)(data) ? value : [value];
};

exports.toArrayForSeries = toArrayForSeries;

var constructFieldsAndColumns = function constructFieldsAndColumns(_ref2) {
  var _ref2$x = _ref2.x,
      x = _ref2$x === void 0 ? [] : _ref2$x,
      _ref2$y = _ref2.y,
      y = _ref2$y === void 0 ? [] : _ref2$y,
      xField = _ref2.xField,
      yFields = _ref2.yFields,
      y2 = _ref2.y2,
      y2Fields = _ref2.y2Fields;
  var columns = [x.map(String)].concat(_toConsumableArray((0, exports.toArrayForSeries)(y, y).map(function (series) {
    return series.map(String);
  })));
  var yFieldsArray = (0, exports.toArrayForSeries)(y, yFields);
  var fields = [{
    name: xField
  }].concat(_toConsumableArray(yFieldsArray.map(function (field) {
    return {
      name: field
    };
  }))); // splunk-charting requires y2 to be part of columns
  // when y & y2 options are configured with different (mutually exclusive) series
  // y2 columns need to be added to columns

  if (y2Fields) {
    var y2FieldsArray = (0, exports.toArrayForSeries)(y2, y2Fields);
    var y2AsArray = (0, exports.toArrayForSeries)(y2, y2).map(function (series) {
      return series === null || series === void 0 ? void 0 : series.map(String);
    });
    y2FieldsArray.forEach(function (y2Field, index) {
      if (yFieldsArray.indexOf(y2Field) === -1 && y2AsArray[index]) {
        fields.push({
          name: y2Field
        });
        columns.push(y2AsArray[index]);
      }
    });
  }

  return {
    columns: columns,
    fields: fields
  };
};

exports.constructFieldsAndColumns = constructFieldsAndColumns;

var shouldEnableSearchZoom = function shouldEnableSearchZoom() {
  var eventHandlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var xField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  var rangeSelectEventHandler = eventHandlers.find(function (eventHandler) {
    var _a;

    return (_a = eventHandler.options.events) === null || _a === void 0 ? void 0 : _a.includes('range.select');
  }); // Check if xField is _time. This is how splunk-charting distinguishes a time chart from categorical.
  // Note: search zoom will be buggy if the x axis uses timestamp values but is not _time

  var xAxisIsTime = xField === '_time';
  return !!rangeSelectEventHandler && xAxisIsTime;
};

exports.shouldEnableSearchZoom = shouldEnableSearchZoom;

/***/ })

/******/ });
//# sourceMappingURL=chartingUtils.js.map