/*!
 * 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 = 87);
/******/ })
/************************************************************************/
/******/ ([
/* 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 */,
/* 4 */,
/* 5 */
/***/ (function(module, exports) {

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

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

module.exports = require("@splunk/react-ui/Heading");

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

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

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

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

/***/ }),
/* 11 */,
/* 12 */,
/* 13 */,
/* 14 */,
/* 15 */,
/* 16 */,
/* 17 */,
/* 18 */,
/* 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 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.convertToDashboardJSON = exports.extractDataFromReactCode = exports.formatCodeStringToObject = exports.extractDocItems = exports.getFormatterClassdesc = void 0;

var React = __webpack_require__(0);

var UtilPage_1 = __webpack_require__(21);

var sharedSelectors = ['getField', 'getType', 'min', 'max'];

var formatSidebarItemName = function formatSidebarItemName(name, className) {
  return sharedSelectors.find(function (sharedSelector) {
    return name === sharedSelector;
  }) ? "".concat(className, "#").concat(name) : name;
};

var removePrependedClassName = function removePrependedClassName() {
  var longname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  return longname.slice(longname.indexOf('#') + 1);
};

var formatDSLSelectorDocs = function formatDSLSelectorDocs(docs) {
  return docs.map(function (doc) {
    return Object.assign(Object.assign({}, doc), {
      longname: removePrependedClassName(doc.longname)
    });
  });
};

var getFormatterClassdesc = function getFormatterClassdesc(formatterDocs, name) {
  return {
    name: name,
    markdown: "# ".concat(name, "\n ").concat(formatterDocs.find(function (doc) {
      return doc.name === name && doc.kind === 'class';
    }).classdesc)
  };
};

exports.getFormatterClassdesc = getFormatterClassdesc;

var extractDocItems = function extractDocItems(docs, className) {
  var classHeaderDoc = docs[0];
  var fileDoc = docs[docs.length - 1];
  var filteredDocs = formatDSLSelectorDocs(docs).filter(function (_ref) {
    var access = _ref.access,
        comment = _ref.comment;
    return access === 'public' && comment;
  });
  return filteredDocs.map(function (doc) {
    return {
      name: formatSidebarItemName(doc.name, className),
      component: function UtilDoc() {
        // named function so linter doesnt raise react/display-name error
        return React.createElement(UtilPage_1.default, {
          title: "".concat(className, "#").concat(doc.name),
          status: 1,
          docs: [classHeaderDoc, doc, fileDoc]
        });
      }
    };
  }).sort(function (a, b) {
    return a.name.localeCompare(b.name);
  });
};

exports.extractDocItems = extractDocItems;

var formatCodeStringToObject = function formatCodeStringToObject(codeString, regexMatch) {
  var match = regexMatch.exec(codeString);
  if (!match) return null;
  var stringToParse = "{".concat(match[1], "}"); // remove trailing commas

  var removedCommas = stringToParse.replace(/,(?!\s*?[-{["'\w])/g, ''); // convert double quotes (which only occur inside strings) to back quotes

  var backQuotes = removedCommas.replace(/"/g, '`'); // replace single quotes with double quotes

  var doubleQuotes = backQuotes.replace(/'/g, '"'); // replace back quotes with single quotes

  var singleQuotes = doubleQuotes.replace(/`/g, "'"); // add quotes around keys

  var quotesAroundKeys = singleQuotes.replace(/\b(\w+)\s*:(?=\s)/g, '"$1":');
  var retval = null;

  try {
    retval = JSON.parse(quotesAroundKeys);
  } catch (e) {
    // eslint-disable-next-line no-console
    console.error(e);
  }

  return retval;
};

exports.formatCodeStringToObject = formatCodeStringToObject;

var extractDataFromReactCode = function extractDataFromReactCode(codeString) {
  var _a;

  var primaryRegex = /dataSources={{([\s\S]*?primary:[\s\S]*?)}}/;

  var _ref2 = (_a = (0, exports.formatCodeStringToObject)(codeString, primaryRegex)) !== null && _a !== void 0 ? _a : {},
      primary = _ref2.primary;

  var optionsRegex = /options={{([\s\S]*?)}}/;
  var options = (0, exports.formatCodeStringToObject)(codeString, optionsRegex);
  var contextRegex = /context={{([\s\S]*?)}}/;
  var context = (0, exports.formatCodeStringToObject)(codeString, contextRegex);
  return {
    primary: primary,
    options: options,
    context: context
  };
};

exports.extractDataFromReactCode = extractDataFromReactCode; // Takes a stringified react viz example and a viz type
// Returns a dashboard definition object.
// e.g. codeString: '<Area dataSources={{}} options={{}} />'
//      type: 'splunk.area'

var convertToDashboardJSON = function convertToDashboardJSON(codeString, type) {
  var _ref3 = (0, exports.extractDataFromReactCode)(codeString),
      options = _ref3.options,
      primary = _ref3.primary,
      context = _ref3.context;

  return Object.assign(Object.assign({
    visualizations: {
      test_viz: Object.assign(Object.assign(Object.assign({
        type: type
      }, options ? {
        options: options
      } : {}), primary ? {
        dataSources: {
          primary: 'primary'
        }
      } : {}), context ? {
        context: context
      } : {})
    }
  }, primary ? {
    dataSources: {
      primary: {
        type: 'ds.test',
        options: primary
      }
    }
  } : {}), {
    defaults: {
      dataSources: {
        global: {
          options: {
            queryParameters: {
              latest: '$global_time.latest$',
              earliest: '$global_time.earliest$'
            }
          }
        }
      }
    },
    inputs: {
      input_global_trp: {
        type: 'input.timerange',
        options: {
          token: 'global_time',
          defaultValue: '-24h@h,now'
        },
        title: 'Global Time Range'
      }
    },
    layout: {
      type: 'absolute',
      options: {},
      structure: [{
        item: 'test_viz',
        type: 'block',
        position: {
          x: 0,
          y: 0,
          w: 800,
          h: 500
        }
      }],
      globalInputs: ['input_global_trp']
    }
  });
};

exports.convertToDashboardJSON = convertToDashboardJSON;

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

module.exports = require("@splunk/react-docs/UtilPage");

/***/ }),
/* 22 */,
/* 23 */,
/* 24 */,
/* 25 */,
/* 26 */,
/* 27 */,
/* 28 */,
/* 29 */,
/* 30 */,
/* 31 */,
/* 32 */,
/* 33 */,
/* 34 */,
/* 35 */,
/* 36 */,
/* 37 */,
/* 38 */,
/* 39 */,
/* 40 */,
/* 41 */,
/* 42 */,
/* 43 */,
/* 44 */,
/* 45 */,
/* 46 */,
/* 47 */,
/* 48 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _slicedToArray = __webpack_require__(8);

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

var React = __webpack_require__(0);

var DocExample_1 = __webpack_require__(49);

var Button_1 = __webpack_require__(50);

var Code_1 = __webpack_require__(51);

var TransitionOpen_1 = __webpack_require__(52);

var SquaresLayered_1 = __webpack_require__(53);

var Checkmark_1 = __webpack_require__(54);

var EyeSlashed_1 = __webpack_require__(55);

var WindowChevronsSlash_1 = __webpack_require__(56);

var i18n_1 = __webpack_require__(5);

var T = __webpack_require__(1);

var docUtils_1 = __webpack_require__(20);

var DocExampleWithVizSandbox = function DocExampleWithVizSandbox(props) {
  var type = props.type,
      title = props.title,
      code = props.code,
      example = props.example,
      _props$hideSandbox = props.hideSandbox,
      hideSandbox = _props$hideSandbox === void 0 ? false : _props$hideSandbox,
      description = props.description;

  var _React$useState = React.useState(false),
      _React$useState2 = _slicedToArray(_React$useState, 2),
      isCopied = _React$useState2[0],
      setIsCopied = _React$useState2[1];

  var _React$useState3 = React.useState(false),
      _React$useState4 = _slicedToArray(_React$useState3, 2),
      showCode = _React$useState4[0],
      setShowCode = _React$useState4[1];

  var isMounted = React.useRef(true);
  var toggleShowCode = React.useCallback(function () {
    setShowCode(function (state) {
      return !state;
    });
  }, []);
  React.useEffect(function () {
    return function () {
      isMounted.current = false;
      setIsCopied(false);
    }; // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);
  if (hideSandbox) return React.createElement(DocExample_1.default, {
    title: title,
    code: code,
    example: example
  });
  var objDefn = (0, docUtils_1.convertToDashboardJSON)(code, type); // set spacing level to 4

  var prettyJson = JSON.stringify(objDefn, null, 4);

  var copyToClipBoard = function copyToClipBoard() {
    if ('clipboard' in navigator) {
      navigator.clipboard.writeText(prettyJson);
      setIsCopied(true);
    }

    setTimeout(function () {
      if (isMounted.current) {
        setIsCopied(false);
      }
    }, 5000);
  };

  var renderAdditionalActions = function renderAdditionalActions() {
    return [React.createElement(Button_1.default, {
      key: "show-dashboard-definition",
      appearance: "toggle",
      onClick: toggleShowCode,
      icon: showCode ? React.createElement(EyeSlashed_1.default, null) : React.createElement(WindowChevronsSlash_1.default, null),
      label: showCode ? (0, i18n_1._)('Hide dashboard definition') : (0, i18n_1._)('Show dashboard definition')
    })];
  };

  return React.createElement(DocExample_1.default, {
    renderAdditionalActions: renderAdditionalActions,
    title: title,
    code: code,
    example: example,
    description: description
  }, React.createElement(TransitionOpen_1.default, {
    animation: "slideFromTop",
    open: showCode,
    retainFocus: false,
    takeFocus: false,
    renderChildrenWhenCollapsed: false,
    animateOnMount: false
  }, React.createElement("div", {
    style: {
      display: 'flex',
      justifyContent: 'space-between'
    }
  }, React.createElement(Code_1.default, {
    value: prettyJson,
    language: "json"
  }), React.createElement(Button_1.default, {
    onClick: copyToClipBoard,
    icon: isCopied ? React.createElement(Checkmark_1.default, null) : React.createElement(SquaresLayered_1.default, null),
    label: isCopied ? (0, i18n_1._)('Copied') : (0, i18n_1._)('Copy to clipboard'),
    style: {
      height: '30px',
      maxWidth: '164px'
    }
  }))));
};

DocExampleWithVizSandbox.propTypes = {
  type: T.string,
  title: T.string,
  code: T.string,
  example: T.func,
  hideSandbox: T.bool
};
exports.default = DocExampleWithVizSandbox;

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

module.exports = require("@splunk/react-docs/DocExample");

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

module.exports = require("@splunk/react-ui/Button");

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

module.exports = require("@splunk/react-ui/Code");

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

module.exports = require("@splunk/react-ui/TransitionOpen");

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

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

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

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

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

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

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

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

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

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

/***/ }),
/* 58 */,
/* 59 */,
/* 60 */,
/* 61 */,
/* 62 */,
/* 63 */,
/* 64 */,
/* 65 */,
/* 66 */,
/* 67 */,
/* 68 */,
/* 69 */,
/* 70 */,
/* 71 */,
/* 72 */,
/* 73 */,
/* 74 */,
/* 75 */,
/* 76 */,
/* 77 */,
/* 78 */,
/* 79 */,
/* 80 */,
/* 81 */,
/* 82 */,
/* 83 */,
/* 84 */,
/* 85 */,
/* 86 */,
/* 87 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _taggedTemplateLiteral = __webpack_require__(57);

var _defineProperty = __webpack_require__(10);

var _chipType, _templateObject;

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

var React = __webpack_require__(0);

var T = __webpack_require__(1);

var styled_components_1 = __webpack_require__(2);

var Paragraph_1 = __webpack_require__(88);

var Heading_1 = __webpack_require__(6);

var List_1 = __webpack_require__(89);

var Chip_1 = __webpack_require__(90);

var ChartLine_1 = __webpack_require__(91);

var ChartBar_1 = __webpack_require__(92);

var ChartScatter_1 = __webpack_require__(93);

var ChoroplethMap_1 = __webpack_require__(94);

var SplitBy_1 = __webpack_require__(95);

var VizCategory_1 = __webpack_require__(19);

var DocExampleWithVizSandbox_1 = __webpack_require__(48);

var chipIconStyles = {
  color: 'white'
};
var chipType = (_chipType = {}, _defineProperty(_chipType, VizCategory_1.VizCategory.TRENDS, {
  backgroundColor: '#66AAF9',
  icon: React.createElement(ChartLine_1.default, {
    style: chipIconStyles
  })
}), _defineProperty(_chipType, VizCategory_1.VizCategory.COMPARISONS, {
  backgroundColor: '#45D4BA',
  icon: React.createElement(ChartBar_1.default, {
    style: chipIconStyles
  })
}), _defineProperty(_chipType, VizCategory_1.VizCategory.CORRELATION, {
  backgroundColor: '#FB865C',
  icon: React.createElement(ChartScatter_1.default, {
    style: chipIconStyles
  })
}), _defineProperty(_chipType, VizCategory_1.VizCategory.SPATIAL, {
  backgroundColor: '#E85B79',
  icon: React.createElement(ChoroplethMap_1.default, {
    style: chipIconStyles
  })
}), _defineProperty(_chipType, VizCategory_1.VizCategory.FLOW, {
  backgroundColor: '#9980FF',
  icon: React.createElement(SplitBy_1.default, {
    style: chipIconStyles
  })
}), _chipType);
var StyledChip = (0, styled_components_1.default)(Chip_1.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n    [data-test='label'] {\n        color: white;\n    }\n    margin-left: 10px;\n    margin-bottom: 10px;\n"])));

var Variations = function Variations(_ref) {
  var variations = _ref.variations,
      variationCode = _ref.variationCode,
      type = _ref.type;
  return React.createElement(React.Fragment, null, variations.map(function (v) {
    var _a;

    var variationObj = variationCode[v.key];
    return React.createElement(DocExampleWithVizSandbox_1.default, Object.assign({
      hideSandbox: (_a = v.hideSandbox) !== null && _a !== void 0 ? _a : false,
      type: type,
      key: v.key,
      code: variationObj.code,
      example: variationObj.example
    }, v));
  }));
};

Variations.propTypes = {
  variations: T.array,
  variationCode: T.object,
  type: T.string
};

var Tip = function Tip(_ref2) {
  var tip = _ref2.tip;
  return React.createElement(List_1.default.Item, null, tip);
};

Tip.propTypes = {
  tip: T.string
};

var Tips = function Tips(_ref3) {
  var tips = _ref3.tips;
  return React.createElement(React.Fragment, null, React.createElement(Heading_1.default, {
    level: 3
  }, "Tips"), React.createElement(List_1.default, null, tips.map(function (tip) {
    return React.createElement(Tip, {
      key: tip,
      tip: tip
    });
  })));
};

Tips.propTypes = {
  tips: T.array
};

var OverviewDoc = function OverviewDoc(props) {
  var _vizTypeDisplayNameMa;

  var _props$overview = props.overview,
      typeOfViz = _props$overview.typeOfViz,
      type = _props$overview.type,
      overview = _props$overview.overview,
      tips = _props$overview.tips,
      variations = _props$overview.variations;
  var variationCode = props.variationCode;
  var vizTypeDisplayNameMap = (_vizTypeDisplayNameMa = {}, _defineProperty(_vizTypeDisplayNameMa, VizCategory_1.VizCategory.TRENDS, 'Trend'), _defineProperty(_vizTypeDisplayNameMa, VizCategory_1.VizCategory.COMPARISONS, 'Comparison'), _vizTypeDisplayNameMa);
  var vizType = vizTypeDisplayNameMap[typeOfViz] || typeOfViz;
  return React.createElement(React.Fragment, null, vizType && React.createElement(React.Fragment, null, "Chart Type", React.createElement(StyledChip, {
    "data-test": "viz-type-chip",
    backgroundColor: chipType[typeOfViz].backgroundColor,
    icon: chipType[typeOfViz].icon
  }, vizType)), React.createElement(Paragraph_1.default, {
    "data-test": "overview-description"
  }, overview), React.createElement(Tips, {
    "data-test": "tips",
    tips: tips
  }), variationCode && React.createElement(Variations, {
    variations: variations,
    type: type,
    variationCode: variationCode
  }));
};

OverviewDoc.propTypes = {
  overview: T.object,
  variationCode: T.object
};
exports.default = OverviewDoc;

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

module.exports = require("@splunk/react-ui/Paragraph");

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

module.exports = require("@splunk/react-ui/List");

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

module.exports = require("@splunk/react-ui/Chip");

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

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

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

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

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

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

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

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

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

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

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