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

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

module.exports = require("@splunk/visualization-icons/placeholders");

/***/ }),

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

"use strict";


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

var i18n_1 = __webpack_require__(0);

var background = function background(_ref) {
  var label = _ref.label,
      themes = _ref.themes,
      labelPosition = _ref.labelPosition;
  return [{
    label: (0, i18n_1._)(label || 'Background'),
    option: 'backgroundColor',
    editor: 'editor.color',
    editorProps: {
      labelPosition: labelPosition || 'top',
      themes: themes
    }
  }];
};

exports.default = background;

/***/ }),

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

module.exports = require("@splunk/visualization-color-palettes");

/***/ }),

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

/***/ }),

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

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

/***/ }),

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

"use strict";


var _toConsumableArray = __webpack_require__(1);

var _defineProperty = __webpack_require__(7);

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.insertLayout = exports.isDynamicOption = exports.uncollapseEditorConfig = exports.generatePrecisionValues = exports.getInitialPreset = exports.enhanceOptionsSchemaWithDynamicOptions = exports.enhanceConfig = void 0;

var lodash_1 = __webpack_require__(6);

var schemaUtils_1 = __webpack_require__(3);

var VizBehavior_1 = __webpack_require__(2);

var dynamicOptionsDSLType = {
  type: 'string',
  pattern: schemaUtils_1.DYNAMIC_OPTIONS_DSL_PATTERN
};
/**
 * Helper function to extend an options schema with dynamic options DSL
 * @param optionsSchema a visualization's options schema
 * @returns an updated options schema that additionally allows strings starting with > for each option
 */

function enhanceOptionsSchemaWithDynamicOptions(optionsSchema) {
  var enhancedOptionsSchema = {};
  Object.keys(optionsSchema).forEach(function (key) {
    var _a = optionsSchema[key],
        title = _a.title,
        description = _a.description,
        readOnly = _a.readOnly,
        writeOnly = _a.writeOnly,
        examples = _a.examples,
        defaultValue = _a.default,
        type = _a.type,
        properties = _a.properties,
        patternProperties = _a.patternProperties,
        remainingSchemaEntry = __rest(_a, ["title", "description", "readOnly", "writeOnly", "examples", "default", "type", "properties", "patternProperties"]);

    var annotations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, title !== undefined && {
      title: title
    }), description !== undefined && {
      description: description
    }), readOnly !== undefined && {
      readOnly: readOnly
    }), writeOnly !== undefined && {
      writeOnly: writeOnly
    }), examples !== undefined && {
      examples: examples
    }), defaultValue !== undefined && {
      default: defaultValue
    });

    if (type === 'object') {
      enhancedOptionsSchema[key] = Object.assign(Object.assign(Object.assign(Object.assign({}, remainingSchemaEntry), annotations), {
        type: type
      }), properties && {
        properties: enhanceOptionsSchemaWithDynamicOptions(properties)
      });

      if (patternProperties) {
        var enhancedPatternProperties = {};
        Object.keys(patternProperties).forEach(function (opt) {
          enhancedPatternProperties = Object.assign(Object.assign({}, enhancedPatternProperties), enhanceOptionsSchemaWithDynamicOptions(_defineProperty({}, opt, patternProperties[opt])));
        });
        enhancedOptionsSchema[key].patternProperties = enhancedPatternProperties;
      }
    } else {
      enhancedOptionsSchema[key] = Object.assign(Object.assign({}, annotations), {
        anyOf: [Object.assign(Object.assign({}, type !== undefined && {
          type: type
        }), remainingSchemaEntry), dynamicOptionsDSLType]
      });
    }
  });
  return enhancedOptionsSchema;
}

exports.enhanceOptionsSchemaWithDynamicOptions = enhanceOptionsSchemaWithDynamicOptions;
/**
 * Helper function to enhance a Visualization Config as needed based on behaviors specified in supports block
 * this function also collapse all editor panels
 * @param vizConfig a Visualization Config
 * @returns an enhanced Visualization Config containing updated config entries based on behaviors it supports
 * and containing `open: false` for all editor panels in editorConfig
 */

function enhanceConfig(vizConfig) {
  var enhancedConfig = Object.assign({}, vizConfig);

  if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS) !== -1) {
    enhancedConfig.optionsSchema = enhanceOptionsSchemaWithDynamicOptions(vizConfig.optionsSchema);
  }

  enhancedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
    return Object.assign(Object.assign({}, config), {
      open: config.open || false
    });
  });
  return enhancedConfig;
}

exports.enhanceConfig = enhanceConfig;
/**
 * Helper function to uncollapse all editor panels by adding `open: true` to the editorConfig
 * Created for editor unit tests
 * @param vizConfig a Visualization Config
 * @returns a Visualization Config containing `open: true` for all editor panels in editorConfig
 */

function uncollapseEditorConfig(vizConfig) {
  var editorPanelUncollapsedConfig = Object.assign({}, vizConfig);
  editorPanelUncollapsedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
    return Object.assign(Object.assign({}, config), {
      open: true
    });
  });
  return editorPanelUncollapsedConfig;
}

exports.uncollapseEditorConfig = uncollapseEditorConfig;

function isDynamicOption(option) {
  return option && typeof option === 'string' && option.trim().startsWith('>') || false;
}

exports.isDynamicOption = isDynamicOption; // private helpers to improve readability of getInitialPreset
// this shouldn't be tested since this util isn't something that we expect to use outside of getInitialPreset

/**
 * this checks to make sure that all values within vizContext are compatible with the given preset's context to determine the initialPreset
 * 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
 * the inverse is true; if a preset has key is NOT undefined, it must also be NOT undefined in the corresponding vizContext
 * 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
 *
 * Since the presetConfigs have explicit undefined keys to override the existing config, we need to explicitly check the undefined values
 */

function hasCompatibleContexts(vizContext, presetContext) {
  var presetContextKeys = Object.keys(presetContext);
  return presetContextKeys.every(function (contextKey) {
    return presetContext[contextKey] === undefined && vizContext[contextKey] === undefined || presetContext[contextKey] !== undefined && vizContext[contextKey] !== undefined;
  });
}
/**
 * Checks to make sure that dynamic (non-dynamic) options in a given preset are also dynamic (non-dynamic) in the vizOptions
 */


function hasCompatibleOptions(vizOptions, presetOptions) {
  var presetOptionKeys = Object.keys(presetOptions);
  return presetOptionKeys.every(function (optionKey) {
    return isDynamicOption(presetOptions[optionKey]) === isDynamicOption(vizOptions[optionKey]);
  });
}
/**
 * Evaluates whether there is an initialPreset that fits the current state of vizContext + vizOptions
 * This function ignores extraneous vizOptions or vizContext keys, as they could be outside the scope of what the preset is intended to configure
 *
 * @param {Object} vizContext - the current vizContext definition
 * @param {Object} vizOptions - the current vizOptions definition
 * @param {PresetEntry[]} presets - the list of presets, one of which can be considered an initialPreset
 */


function getInitialPreset(vizContext, vizOptions, presets) {
  return presets.find(function (preset) {
    var presetContext = (0, lodash_1.get)(preset, ['value', 'context'], {});
    var presetOptions = (0, lodash_1.get)(preset, ['value', 'options'], {});
    var presetContextKeys = Object.keys(presetContext);
    var presetOptionKeys = Object.keys(presetOptions); // all presets have to explicitly specify which options to reset (i.e. need explicitly undefined keys)
    // if not, then the preset is invalid in config.ts

    if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
    return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
  });
}

exports.getInitialPreset = getInitialPreset;
/**
 * generates number precision values for a Select editor
 *
 * @param {Number} numPrecisionValues - number of integer precision values to generate
 * @returns {{ label: string; value; string  }[]} array of { label, value } tuples
 */

function generatePrecisionValues(numPrecisionValues) {
  return (0, lodash_1.range)(0, numPrecisionValues + 1).map(function (i) {
    return {
      label: "".concat(i, " (0").concat(i > 0 ? '.' : '').concat('0'.repeat(i), ")"),
      value: i
    };
  });
}

exports.generatePrecisionValues = generatePrecisionValues;
/**
 * insert layout in layout array, return a new layout array instead of updating the original
 *
 * @param {EditorLayoutConfig[][]} layout - editor layout
 * @param {Number} index - the index to insert layout item(s)
 * @param {EditorLayoutConfig[][]} layoutItems - the item(s) to insert
 * @returns {EditorLayoutConfig[][]} new editor layout with insertion
 */

var insertLayout = function insertLayout(layout, index) {
  for (var _len = arguments.length, layoutItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
    layoutItems[_key - 2] = arguments[_key];
  }

  return [].concat(_toConsumableArray(layout.slice(0, index)), layoutItems, _toConsumableArray(layout.slice(index)));
};

exports.insertLayout = insertLayout;

/***/ }),

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

module.exports = require("lodash");

/***/ }),

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

"use strict";


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

var ChartPie_1 = __webpack_require__(69);

var placeholders_1 = __webpack_require__(11);

var i18n_1 = __webpack_require__(0);

var schemaUtils_1 = __webpack_require__(3);

var visualization_color_palettes_1 = __webpack_require__(14);

var pick_1 = __webpack_require__(9);

var variables_1 = __webpack_require__(10);

var VizBehavior_1 = __webpack_require__(2);

var VizCategory_1 = __webpack_require__(8);

var configUtils_1 = __webpack_require__(4);

var BackgroundColor_1 = __webpack_require__(13);

var dataContract = {
  requiredDataSources: [{
    name: 'primary',
    description: 'DataSource that powers the visualization'
  }],
  optionalDataSources: [// Note: SCP-14090 disable ui for optional datasources. We may need to add it back later
    // {
    //     name: 'annotation',
    //     description: 'DataSource that populate event annotations',
    // },
  ],
  initialRequestParams: {
    primary: {
      offset: 0,
      count: 10000
    }
  }
};
var size = {
  initialWidth: 300,
  initialHeight: 300
};
var defaultContext = {};
var optionsSchema = {
  backgroundColor: {
    default: '> themes.defaultBackgroundColor',
    description: 'Specify the color for the background. You may use a dataSource to apply the color. The default for enterprise light is "#ffffff". The default for enterprise dark is "#000000". The default for prisma dark is "#0b0c0e".',
    pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA,
    type: 'string'
  },
  collapseLabel: {
    description: 'Specify the label for the consolidated slice.',
    type: 'string',
    default: 'other'
  },
  collapseThreshold: {
    description: 'Specify the size threshold as a number between 0 and 1 (inclusive), of the whole pie at which slices collapse into one consolidated slice.',
    type: 'number',
    default: 0.01
  },
  label: {
    description: 'List of string values to display the pie chart labels.',
    type: 'array',
    items: {
      type: 'string'
    },
    default: '> primary | seriesByIndex(0)'
  },
  labelField: {
    default: '> label | getField()',
    description: 'Specify the field that corresponds to the labels.',
    type: 'string'
  },
  labelDisplay: {
    description: 'Specify whether to display the labels and/or slice percentages.',
    type: 'string',
    pattern: (0, schemaUtils_1.getPattern)(['values', 'valuesAndPercentage', 'off']),
    default: 'values'
  },
  resultLimit: {
    default: 50000,
    description: 'Specify the number of data points rendered in a chart.',
    type: 'number'
  },
  seriesColors: {
    default: visualization_color_palettes_1.VIZ_CATEGORICAL,
    description: 'Specify the colors used for a series. For example, ["#FF0000", "#0000FF", "#008000"].',
    type: 'array',
    items: {
      type: 'string'
    }
  },
  seriesColorsByField: {
    description: 'Specify the colors used for specific pie slice labels. For example: {"April": "#008000", "May": "#FFA500"}.',
    type: 'object'
  },
  showDonutHole: {
    default: false,
    description: 'Specify whether the pie should be a donut.',
    type: 'boolean'
  },
  value: {
    description: 'List of numerical values to power the pie chart.',
    type: 'array',
    items: {
      type: 'number'
    },
    default: '> primary | seriesByIndex(1)'
  },
  valueField: {
    default: '> value | getField()',
    description: 'Specify the field that corresponds to the data powering values.',
    type: 'string'
  }
};
var themes = {
  defaultBackgroundColor: function defaultBackgroundColor(props) {
    return (0, pick_1.default)({
      enterprise: {
        dark: variables_1.default.black(props),
        light: variables_1.default.backgroundColor(props)
      },
      prisma: variables_1.default.backgroundColorSidebar(props)
    })(props);
  }
};
var editorConfig = [{
  label: (0, i18n_1._)('Data configurations'),
  layout: [[{
    label: (0, i18n_1._)('Label'),
    editor: 'editor.columnSelector',
    option: 'label',
    context: 'valuesContext',
    editorProps: {
      dataSourceKey: 'primary'
    }
  }], [{
    label: (0, i18n_1._)('Value'),
    editor: 'editor.columnSelector',
    option: 'value',
    context: 'valuesContext',
    editorProps: {
      dataSourceKey: 'primary'
    }
  }]]
}, {
  label: (0, i18n_1._)('Data display'),
  layout: [[{
    label: (0, i18n_1._)('Display type'),
    option: 'showDonutHole',
    editor: 'editor.radioBar',
    editorProps: {
      values: [{
        label: (0, i18n_1._)('Pie'),
        value: false
      }, {
        label: (0, i18n_1._)('Donut'),
        value: true
      }]
    }
  }], [{
    label: (0, i18n_1._)('Label display'),
    option: 'labelDisplay',
    editor: 'editor.select',
    editorProps: {
      values: [{
        label: (0, i18n_1._)('Values'),
        value: 'values'
      }, {
        label: (0, i18n_1._)('Values & Percent'),
        value: 'valuesAndPercentage'
      }, {
        label: (0, i18n_1._)('Off'),
        value: 'off'
      }]
    }
  }], [{
    label: (0, i18n_1._)('Collapse threshold'),
    option: 'collapseThreshold',
    editor: 'editor.number',
    editorProps: {
      min: 0,
      max: 1,
      step: 0.01
    }
  }], [{
    label: (0, i18n_1._)('Collapsed slice label'),
    option: 'collapseLabel',
    editor: 'editor.text'
  }]]
}, {
  label: (0, i18n_1._)('Color and style'),
  layout: [[{
    label: (0, i18n_1._)('Series colors'),
    option: 'seriesColors',
    editor: 'editor.seriesColors'
  }], (0, BackgroundColor_1.default)({
    themes: themes
  })]
}];
/**
 * visualization configuration
 */

var config = {
  /**
   * unique viz key
   */
  key: 'splunk.pie',

  /**
   * viz name
   */
  name: (0, i18n_1._)('Pie'),
  category: VizCategory_1.VizCategory.COMPARISONS,

  /**
   * viz icon
   */
  icon: ChartPie_1.default,
  placeholderIcon: placeholders_1.Pie,
  dataContract: dataContract,
  size: size,
  defaultContext: defaultContext,
  optionsSchema: optionsSchema,
  editorConfig: editorConfig,
  events: {
    'point.click': {
      description: 'triggered when user clicks on a point in the pie chart'
    }
  },
  supports: [VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS, VizBehavior_1.VizBehavior.PLACEHOLDER, VizBehavior_1.VizBehavior.EVENTS],
  themes: themes
};
exports.default = (0, configUtils_1.enhanceConfig)(config);

/***/ }),

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

module.exports = require("@splunk/react-icons/enterprise/ChartPie");

/***/ }),

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

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

/***/ }),

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

/***/ }),

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

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

/***/ })

/******/ });
//# sourceMappingURL=Pie.config.js.map