/* 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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
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);
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);

// src/components/PageLengthSelector/index.tsx
var PageLengthSelector_exports = {};
__export(PageLengthSelector_exports, {
  default: () => PageLengthSelector_default
});
module.exports = __toCommonJS(PageLengthSelector_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-ui/Button
var Button_exports = {};
__export(Button_exports, {
  default: () => Button_default
});
var defaultImport2 = __toESM(require("@splunk/react-ui/Button"));
__reExport(Button_exports, require("@splunk/react-ui/Button"));
var Button_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;

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

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

// esm-externals:@splunk/ui-utils/format
var format_exports = {};
__export(format_exports, {
  default: () => format_default
});
var defaultImport5 = __toESM(require("@splunk/ui-utils/format"));
__reExport(format_exports, require("@splunk/ui-utils/format"));
var format_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/ValueMenuItem/index.tsx
var ValueMenuItem = class extends react_default.PureComponent {
  constructor() {
    super(...arguments);
    /**
     * Handler for click events on this component. Call the onclick
     * prop with the DOM event triggering the click and the `value`
     * prop that was passed in by the parent component.
     * @param {MouseEvent} e DOM event
     */
    __publicField(this, "handleClick", (e) => {
      this.props.onClick(e, { value: this.props.value });
    });
  }
  render() {
    const _a = this.props, { value, onClick, children } = _a, otherProps = __objRest(_a, ["value", "onClick", "children"]);
    return /* @__PURE__ */ react_default.createElement(Menu_default.Item, __spreadValues({ key: value, onClick: this.handleClick }, otherProps), children);
  }
};

// src/styles.ts
var menu = {
  minWidth: "160px"
};

// src/components/PageLengthSelector/index.tsx
var perPageLabel = (pageLength) => (0, format_exports.sprintf)((0, i18n_exports._)("%(pageLength)d Per Page"), { pageLength });
var getPageLengthDropdownToggle = (pageLength) => /* @__PURE__ */ react_default.createElement(
  Button_default,
  {
    label: perPageLabel(pageLength),
    appearance: "subtle",
    isMenu: true,
    "data-test": "workflow-components:PageLengthSelector"
  }
);
var PageLengthSelector = ({ options = [10, 20, 50], pageLength, onChange }) => {
  return /* @__PURE__ */ react_default.createElement(Dropdown_default, { toggle: getPageLengthDropdownToggle(pageLength) }, /* @__PURE__ */ react_default.createElement(Menu_default, { style: menu, "data-test": "pagination-dropdown" }, [...options].sort((x, y) => x <= y ? -1 : 1).map((len) => /* @__PURE__ */ react_default.createElement(
    ValueMenuItem,
    {
      key: len,
      value: len,
      onClick: onChange,
      selected: len === pageLength,
      selectable: true
    },
    /* @__PURE__ */ react_default.createElement(react_default.Fragment, null, perPageLabel(len))
  ))));
};
var PageLengthSelector_default = PageLengthSelector;
//# sourceMappingURL=index.js.map
