var __assign = this && this.__assign || function () {
  __assign = Object.assign || function (t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];

      for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
      }
    }

    return t;
  };

  return __assign.apply(this, arguments);
};

import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import { DateUnitKeys, DynamincType } from "./constant";
import Select from "../../select";
import { InputNumber } from "../../input";
import { prefixCls } from "../DateFilter";
import Checkbox from "../../checkbox";

var DynamicSelect = function DynamicSelect(_a) {
  var _b;

  var type = _a.type,
      unit = _a.unit,
      locale = _a.locale,
      onTypeChange = _a.onTypeChange,
      dynamicVal = _a.dynamicVal,
      onNumChange = _a.onNumChange,
      onUnitChange = _a.onUnitChange,
      getPopupContainer = _a.getPopupContainer,
      nature = _a.nature,
      onNatureChange = _a.onNatureChange;
  var fLocale = locale.filterLocale,
      dLocale = locale.dateUnitLocale;
  var typeOptions = [DynamincType.after, DynamincType.before].map(function (t) {
    return {
      label: fLocale[t],
      key: t,
      value: t
    };
  });
  var natureTitle = (_b = {}, _b[DateUnitKeys.years] = dLocale.yearsInclude, _b[DateUnitKeys.quarter] = dLocale.quarterInclude, _b[DateUnitKeys.month] = dLocale.monthInclude, _b[DateUnitKeys.week] = dLocale.weekInclude, _b);
  var unitOptions = [DateUnitKeys.years, DateUnitKeys.quarter, DateUnitKeys.month, DateUnitKeys.week, DateUnitKeys.day, DateUnitKeys.hour, DateUnitKeys.minute // DateUnitKeys.second,
  ].map(function (t) {
    return {
      label: dLocale[t],
      value: t,
      key: t
    };
  });
  return _jsxs("div", __assign({
    className: prefixCls + "-dynamic"
  }, {
    children: [_jsxs("div", __assign({
      className: prefixCls + "-dynamic-label"
    }, {
      children: [fLocale.labelDynamic, "\uFF1A"]
    }), void 0), _jsx(Select, {
      size: "mini",
      type: "menu-bg",
      value: type,
      options: typeOptions,
      onChange: onTypeChange,
      getPopupContainer: getPopupContainer
    }, void 0), _jsx(InputNumber, {
      size: "compact",
      type: "menu-bg",
      value: dynamicVal,
      onChange: onNumChange,
      style: {
        width: 89
      },
      visibilityHandler: true,
      placeholder: fLocale.placeholder,
      className: prefixCls + "-dynamic-input"
    }, void 0), _jsx(Select, {
      size: "mini",
      type: "menu-bg",
      value: unit,
      options: unitOptions,
      onChange: onUnitChange,
      getPopupContainer: getPopupContainer
    }, void 0), natureTitle[unit] && _jsx(Checkbox, {
      className: prefixCls + "-dynamic-checkbox",
      title: natureTitle[unit],
      checked: nature,
      onChange: onNatureChange
    }, void 0)]
  }), void 0);
};

DynamicSelect.displayName = 'DynamicSelect';
export default DynamicSelect;
var DynamicSelectMemo = /*#__PURE__*/React.memo(DynamicSelect);
DynamicSelectMemo.displayName = 'DynamicSelectMemo';
export { DynamicSelectMemo };

