"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.IndexLifecyclePhaseSelect = IndexLifecyclePhaseSelect;
var _react = _interopRequireDefault(require("react"));
var _eui = require("@elastic/eui");
var _i18n = require("@kbn/i18n");
var _reactRouterDom = require("react-router-dom");
var _storage_explorer_types = require("../../../../common/storage_explorer_types");
var urlHelpers = _interopRequireWildcard(require("../../shared/links/url_helpers"));
var _use_apm_params = require("../../../hooks/use_apm_params");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */

function IndexLifecyclePhaseSelect() {
  const history = (0, _reactRouterDom.useHistory)();
  const {
    query: {
      indexLifecyclePhase
    }
  } = (0, _use_apm_params.useApmParams)('/storage-explorer');
  const options = [{
    value: _storage_explorer_types.IndexLifecyclePhaseSelectOption.All,
    label: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.all.label', {
      defaultMessage: 'All'
    }),
    description: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.all.description', {
      defaultMessage: 'Search data in all lifecycle phases.'
    })
  }, {
    value: _storage_explorer_types.IndexLifecyclePhaseSelectOption.Hot,
    label: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.hot.label', {
      defaultMessage: 'Hot'
    }),
    description: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.hot.description', {
      defaultMessage: 'Holds your most-recent, most-frequently-searched data.'
    })
  }, {
    value: _storage_explorer_types.IndexLifecyclePhaseSelectOption.Warm,
    label: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.warm.label', {
      defaultMessage: 'Warm'
    }),
    description: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.warm.description', {
      defaultMessage: 'Holds data from recent weeks. Updates are still allowed, but likely infrequent.'
    })
  }, {
    value: _storage_explorer_types.IndexLifecyclePhaseSelectOption.Cold,
    label: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.cold.label', {
      defaultMessage: 'Cold'
    }),
    description: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.cold.description', {
      defaultMessage: 'While still searchable, this tier is typically optimized for lower storage costs rather than search speed.'
    })
  }, {
    value: _storage_explorer_types.IndexLifecyclePhaseSelectOption.Frozen,
    label: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.frozen.label', {
      defaultMessage: 'Frozen'
    }),
    description: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.frozen.description', {
      defaultMessage: 'Holds data that are no longer being queried, or being queried rarely.'
    })
  }].map(({
    value,
    label,
    description
  }) => ({
    value,
    inputDisplay: label,
    dropdownDisplay: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("strong", null, label), /*#__PURE__*/_react.default.createElement(_eui.EuiText, {
      size: "s",
      color: "subdued"
    }, /*#__PURE__*/_react.default.createElement("p", null, description)))
  }));
  return /*#__PURE__*/_react.default.createElement(_eui.EuiSuperSelect, {
    prepend: _i18n.i18n.translate('xpack.apm.storageExplorer.indexLifecyclePhase.label', {
      defaultMessage: 'Index lifecycle phase'
    }),
    options: options,
    valueOfSelected: indexLifecyclePhase,
    onChange: value => {
      urlHelpers.push(history, {
        query: {
          indexLifecyclePhase: value
        }
      });
    },
    hasDividers: true,
    style: {
      minWidth: 200
    },
    "data-test-subj": "storageExplorerLifecyclePhaseSelect"
  });
}