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

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

module.exports = require("react");

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

/***/ 83:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MajorTick", function() { return MajorTick; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "positionMajorTick", function() { return positionMajorTick; });
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(styled_components__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9);
/* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__);





var DEFAULT_NUM_OF_TICKS = 5;
var TICK_LENGTH_DELTA = 5;
var TICK_LABEL_PADDING_FACTOR = 3.2;
var MajorTickLine = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.line.withConfig({
  displayName: "GaugeMajorTicks__MajorTickLine",
  componentId: "mchiad-0"
})(["stroke:", ";stroke-width:2px;stroke-dasharray:", ";"], function (props) {
  return props.majorTickStrokeColor;
}, function (props) {
  return props.index === 0 ? 0 : 3;
});
var MajorTickLabel = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.text.withConfig({
  displayName: "GaugeMajorTicks__MajorTickLabel",
  componentId: "mchiad-1"
})(["font-size:12px;font-family:Splunk Platform Sans,sans-serif;line-height:19px;fill:", ";text-anchor:middle;text-align:center;"], function (props) {
  return props.majorTickFillColor;
});
var MajorTick = function MajorTick(_ref) {
  var index = _ref.index,
      x1 = _ref.x1,
      y1 = _ref.y1,
      x2 = _ref.x2,
      y2 = _ref.y2,
      showLabels = _ref.showLabels,
      label = _ref.label,
      labelX = _ref.labelX,
      labelY = _ref.labelY,
      majorTickStrokeColor = _ref.majorTickStrokeColor,
      majorTickFillColor = _ref.majorTickFillColor;
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("g", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTickLine, {
    "data-test": "major-tick-line",
    index: index,
    x1: x1,
    y1: y1,
    x2: x2,
    y2: y2,
    majorTickStrokeColor: majorTickStrokeColor
  }), showLabels && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTickLabel, {
    x: labelX,
    y: labelY,
    majorTickFillColor: majorTickFillColor,
    "data-test": "major-tick-label"
  }, Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__["isNumerial"])(label) ? Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__["formatNumber"])(label, 0, {
    useThousandSeparators: true,
    useTrendUnits: true
  }) : label));
};
MajorTick.propTypes = {
  index: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  x1: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  y1: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  x2: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  y2: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  showLabels: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
  label: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number]),
  labelX: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  labelY: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  majorTickStrokeColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
  majorTickFillColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string
};
/**
 * calculate position for each major tick
 * @method positionMajorTick
 * @param {Object} input
 * @param {Number} input.width
 * @param {Number} input.height
 * @param {Number} input.startX  start x for rendering the first major tick
 * @param {Number} input.startY  start y for rendering the first major tick
 * @param {String} input.orientation
 * @param {Number} input.numOfTicks  how many ticks need to render
 * @param {Number} input.i   index of major tick
 * @return {Object} MajorTick positions
 */

var positionMajorTick = function positionMajorTick(_ref2) {
  var width = _ref2.width,
      height = _ref2.height,
      startX = _ref2.startX,
      startY = _ref2.startY,
      orientation = _ref2.orientation,
      numOfTicks = _ref2.numOfTicks,
      i = _ref2.i;
  var x1 = startX;
  var y1 = startY;
  var x2 = startX;
  var y2 = startY;
  var labelX = startX;
  var labelY;

  if (orientation === 'vertical') {
    var y = height / numOfTicks * (numOfTicks - i) + startY;
    x1 -= TICK_LENGTH_DELTA;
    y1 = y;
    x2 += width + TICK_LENGTH_DELTA;
    y2 = y;
    labelX += width + TICK_LENGTH_DELTA * TICK_LABEL_PADDING_FACTOR;
    labelY = y;
  } else {
    var x = width / numOfTicks * i + startX;
    x1 = x;
    y1 -= TICK_LENGTH_DELTA;
    x2 = x;
    y2 += height + TICK_LENGTH_DELTA;
    labelX = x;
    labelY = y2 + 16;
  }

  return {
    x1: x1,
    y1: y1,
    x2: x2,
    y2: y2,
    labelX: labelX,
    labelY: labelY
  };
};

var MajorTicks = function MajorTicks(_ref3) {
  var props = _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, _ref3);

  var width = props.width,
      height = props.height,
      startX = props.startX,
      startY = props.startY,
      min = props.min,
      max = props.max,
      majorUnit = props.majorUnit,
      orientation = props.orientation,
      showLabels = props.showLabels,
      usePercentageRange = props.usePercentageRange,
      majorTickFillColor = props.majorTickFillColor,
      majorTickStrokeColor = props.majorTickStrokeColor;
  var range = max - min;
  var numOfTicks = majorUnit === 'auto' || Number.isNaN(Number(majorUnit)) || majorUnit <= 0 ? DEFAULT_NUM_OF_TICKS : range / majorUnit;
  var majorTicks = [];

  for (var i = 0; i <= numOfTicks; i += 1) {
    var _positionMajorTick = positionMajorTick({
      width: width,
      height: height,
      startX: startX,
      startY: startY,
      orientation: orientation,
      numOfTicks: numOfTicks,
      i: i
    }),
        x1 = _positionMajorTick.x1,
        y1 = _positionMajorTick.y1,
        x2 = _positionMajorTick.x2,
        y2 = _positionMajorTick.y2,
        labelX = _positionMajorTick.labelX,
        labelY = _positionMajorTick.labelY;

    var label = usePercentageRange ? "".concat(parseInt((i / numOfTicks - min / range) * 100, 10), "%") : parseInt(min + range / numOfTicks * i, 10);
    majorTicks.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTick, {
      key: i,
      index: i,
      x1: x1,
      y1: y1,
      x2: x2,
      y2: y2,
      showLabels: showLabels,
      label: label,
      labelX: labelX,
      labelY: labelY,
      majorTickFillColor: majorTickFillColor,
      majorTickStrokeColor: majorTickStrokeColor
    }));
  } // if the gauge is not divided evenly, put the last tick at the end of the gauge


  if (!Number.isInteger(numOfTicks)) {
    var extraNumOfTicks = Math.ceil(numOfTicks);

    var _positionMajorTick2 = positionMajorTick({
      width: width,
      height: height,
      startX: startX,
      startY: startY,
      orientation: orientation,
      numOfTicks: extraNumOfTicks,
      i: extraNumOfTicks
    }),
        _x = _positionMajorTick2.x1,
        _y = _positionMajorTick2.y1,
        _x2 = _positionMajorTick2.x2,
        _y2 = _positionMajorTick2.y2,
        _labelX = _positionMajorTick2.labelX,
        _labelY = _positionMajorTick2.labelY;

    majorTicks.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTick, {
      key: extraNumOfTicks,
      id: extraNumOfTicks,
      x1: _x,
      y1: _y,
      x2: _x2,
      y2: _y2,
      showLabels: showLabels,
      label: usePercentageRange ? '100%' : max,
      labelX: _labelX,
      labelY: _labelY,
      majorTickFillColor: majorTickFillColor,
      majorTickStrokeColor: majorTickStrokeColor
    }));
  }

  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("g", null, majorTicks);
};

MajorTicks.propTypes = {
  width: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  height: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  startX: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  startY: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  min: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  max: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
  majorUnit: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number]),
  orientation: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
  showLabels: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
  usePercentageRange: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
  majorTickFillColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
  majorTickStrokeColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string
};
MajorTicks.defaultProps = {
  min: 0,
  max: 100,
  majorUnit: 'auto',
  orientation: 'horizontal',
  showLabels: true,
  usePercentageRange: false
};
/* harmony default export */ __webpack_exports__["default"] = (MajorTicks);

/***/ }),

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

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

/***/ })

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