/* Copyright © 2020 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. */
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/ConfigurationPanel/TableFormatter.tsx
var TableFormatter_exports = {};
__export(TableFormatter_exports, {
  default: () => TableFormatter_default
});
module.exports = __toCommonJS(TableFormatter_exports);

// esm-externals:react
var react_exports = {};
__export(react_exports, {
  default: () => react_default
});
var defaultImport = __toESM(require("react"));
__reExport(react_exports, require("react"));
var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;

// esm-externals:@splunk/react-icons/enterprise/Paintbrush
var Paintbrush_exports = {};
__export(Paintbrush_exports, {
  default: () => Paintbrush_default
});
var defaultImport2 = __toESM(require("@splunk/react-icons/enterprise/Paintbrush"));
__reExport(Paintbrush_exports, require("@splunk/react-icons/enterprise/Paintbrush"));
var Paintbrush_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;

// esm-externals:@splunk/react-ui/Button
var Button_exports = {};
__export(Button_exports, {
  default: () => Button_default
});
var defaultImport3 = __toESM(require("@splunk/react-ui/Button"));
__reExport(Button_exports, require("@splunk/react-ui/Button"));
var Button_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;

// esm-externals:@splunk/react-ui/Dropdown
var Dropdown_exports = {};
__export(Dropdown_exports, {
  default: () => Dropdown_default
});
var defaultImport4 = __toESM(require("@splunk/react-ui/Dropdown"));
__reExport(Dropdown_exports, require("@splunk/react-ui/Dropdown"));
var Dropdown_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;

// esm-externals:@splunk/react-ui/Menu
var Menu_exports = {};
__export(Menu_exports, {
  default: () => Menu_default
});
var defaultImport5 = __toESM(require("@splunk/react-ui/Menu"));
__reExport(Menu_exports, require("@splunk/react-ui/Menu"));
var Menu_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;

// esm-externals:@splunk/ui-utils/i18n
var i18n_exports = {};
__export(i18n_exports, {
  default: () => i18n_default
});
var defaultImport6 = __toESM(require("@splunk/ui-utils/i18n"));
__reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
var i18n_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;

// src/components/ConfigurationPanel/TableFormatter.tsx
var FormattingOption = ({ name, label, selected, onOptionsChange }) => {
  const key = name;
  return /* @__PURE__ */ react_default.createElement(
    Menu_default.Item,
    {
      "data-test": key,
      value: key,
      onClick: () => onOptionsChange({ [key]: !selected }),
      selected,
      selectable: true
    },
    label
  );
};
var TableFormatter = ({
  tableStyle,
  formattingOptions,
  formattingValues,
  onOptionsChange
}) => {
  const toggle = /* @__PURE__ */ react_default.createElement(
    Button_default,
    {
      icon: /* @__PURE__ */ react_default.createElement(Paintbrush_default, { screenReaderText: "" }),
      label: (0, i18n_exports._)("Format"),
      appearance: "subtle",
      "data-test": "table-formatter-button",
      isMenu: true
    }
  );
  const availableOptions = formattingOptions.reduce((agg, option) => {
    const found = tableStyle.formattingOptions.find(({ key }) => key === option);
    if (found) {
      agg.push(found);
    }
    return agg;
  }, []);
  if (availableOptions.length === 0) {
    return null;
  }
  return /* @__PURE__ */ react_default.createElement(Dropdown_default, { toggle }, /* @__PURE__ */ react_default.createElement(Menu_default, { "data-test": "table-format-menu" }, availableOptions.map(({ key, label }) => /* @__PURE__ */ react_default.createElement(
    FormattingOption,
    {
      key,
      name: key,
      label,
      selected: formattingValues[key],
      onOptionsChange
    }
  ))));
};
var TableFormatter_default = TableFormatter;
//# sourceMappingURL=TableFormatter.js.map
