'use strict';

var _ConfigProvider = require('antd/lib/config-provider');
var _TreeSelect = require('antd/lib/tree-select');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var classnames = require('classnames');
var Down = require('@bigbinary/neeto-icons/Down');
var reactI18next = require('react-i18next');
var index = require('./index-CNZKW5X0.js');
var constants = require('./constants.js');
var Label = require('./Label.js');
var jsxRuntime = require('react/jsx-runtime');
require('@babel/runtime/helpers/slicedToArray');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('@bigbinary/neeto-cist');
require('qs');
require('ramda');
require('./en-B1i-pQJm.js');
require('./index-BgzkP01c.js');
require('@babel/runtime/helpers/toConsumableArray');
require('dayjs');
require('dayjs/plugin/localeData');
require('dayjs/plugin/utc');
require('dayjs/plugin/weekday');
require('dayjs/plugin/weekOfYear');
require('i18next');
require('antd/locale/de_DE');
require('antd/locale/en_US');
require('antd/locale/es_ES');
require('antd/locale/fr_FR');
require('antd/locale/nl_NL');
require('antd/locale/pl_PL');
require('antd/locale/pt_PT');
require('@bigbinary/neeto-icons/Help');
require('./Button.js');
require('react-router-dom');
require('./Spinner.js');
require('./Tooltip.js');
require('@tippyjs/react');
require('tippy.js');
require('@bigbinary/neeto-hotkeys');
require('./overlayManager.js');
require('./usePrefersReducedMotion-D2Ck84HM.js');
require('./Popover.js');
require('./Typography.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var _ConfigProvider__default = /*#__PURE__*/_interopDefault(_ConfigProvider);
var _TreeSelect__default = /*#__PURE__*/_interopDefault(_TreeSelect);
var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
var Down__default = /*#__PURE__*/_interopDefault(Down);

var _excluded = ["allowClear", "className", "disabled", "error", "fieldNames", "label", "onChange", "placeholder", "required", "showSearch", "size", "suffixIcon", "switcherIcon", "treeData", "treeDataSimpleMode", "value", "popupClassName"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var TreeSelect = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
  var _fieldNames$label;
  var allowClear = _ref.allowClear,
    className = _ref.className,
    _ref$disabled = _ref.disabled,
    disabled = _ref$disabled === void 0 ? false : _ref$disabled,
    error = _ref.error,
    fieldNames = _ref.fieldNames,
    _ref$label = _ref.label,
    label = _ref$label === void 0 ? "" : _ref$label,
    onChange = _ref.onChange,
    _ref$placeholder = _ref.placeholder,
    placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
    _ref$required = _ref.required,
    required = _ref$required === void 0 ? false : _ref$required,
    _ref$showSearch = _ref.showSearch,
    showSearch = _ref$showSearch === void 0 ? false : _ref$showSearch,
    _ref$size = _ref.size,
    size = _ref$size === void 0 ? "middle" : _ref$size,
    suffixIcon = _ref.suffixIcon,
    switcherIcon = _ref.switcherIcon,
    treeData = _ref.treeData,
    _ref$treeDataSimpleMo = _ref.treeDataSimpleMode,
    treeDataSimpleMode = _ref$treeDataSimpleMo === void 0 ? true : _ref$treeDataSimpleMo,
    value = _ref.value,
    popupClassName = _ref.popupClassName,
    otherProps = _objectWithoutProperties__default.default(_ref, _excluded);
  var _useTranslation = reactI18next.useTranslation(),
    t = _useTranslation.t,
    i18n = _useTranslation.i18n;
  var SuffixIcon = suffixIcon !== null && suffixIcon !== void 0 ? suffixIcon : Down__default.default;
  var SwitcherIcon = switcherIcon !== null && switcherIcon !== void 0 ? switcherIcon : Down__default.default;
  return /*#__PURE__*/jsxRuntime.jsx(_ConfigProvider__default.default, {
    locale: constants.ANTD_LOCALE[i18n.language || "en"],
    theme: {
      token: _objectSpread({}, index.ANT_DESIGN_GLOBAL_TOKEN_OVERRIDES),
      components: {
        TreeSelect: {
          nodeHoverBg: "rgb(var(--neeto-ui-gray-100))",
          nodeSelectedBg: "rgb(var(--neeto-ui-primary-500))",
          // Global overrides
          colorBgElevated: "rgb(var(--neeto-ui-white))"
        }
      }
    },
    children: /*#__PURE__*/jsxRuntime.jsxs("div", {
      className: "neeto-ui-input__wrapper",
      children: [label && /*#__PURE__*/jsxRuntime.jsx(Label, {
        required: required,
        "data-testid": "treeselect-label",
        children: label
      }), /*#__PURE__*/jsxRuntime.jsx(_TreeSelect__default.default, _objectSpread({
        allowClear: allowClear,
        disabled: disabled,
        fieldNames: fieldNames,
        onChange: onChange,
        placeholder: placeholder,
        ref: ref,
        showSearch: showSearch,
        size: size,
        treeData: treeData,
        treeDataSimpleMode: treeDataSimpleMode,
        "data-testid": "neeto-ui-tree-select-wrapper",
        dropdownStyle: {
          zIndex: 100000
        },
        suffixIcon: /*#__PURE__*/jsxRuntime.jsx(SuffixIcon, {}),
        treeNodeFilterProp: (_fieldNames$label = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) !== null && _fieldNames$label !== void 0 ? _fieldNames$label : "label",
        value: value || undefined,
        className: classnames__default.default("neeto-ui-tree-select__wrapper", className, {
          "neeto-ui-tree-select__error": error
        }),
        notFoundContent:
        /*#__PURE__*/
        // eslint-disable-next-line @bigbinary/neeto/hard-coded-strings-should-be-localized
        jsxRuntime.jsx("div", {
          className: "neeto-ui-text-center neeto-ui-p-1",
          children: index.getLocale(i18n, t, "neetoui.treeSelect.noOptions")
        }),
        popupClassName: classnames__default.default("neeto-ui-tree-select-dropdown", popupClassName),
        switcherIcon: function switcherIcon(_ref2) {
          var className = _ref2.className,
            style = _ref2.style,
            onMouseMove = _ref2.onMouseMove,
            id = _ref2.id,
            title = _ref2.title;
          return /*#__PURE__*/jsxRuntime.jsx("div", {
            className: className,
            id: id,
            onMouseMove: onMouseMove,
            style: style,
            title: title,
            children: /*#__PURE__*/jsxRuntime.jsx(SwitcherIcon, {})
          });
        }
      }, otherProps)), error && /*#__PURE__*/jsxRuntime.jsx("p", {
        className: "neeto-ui-input__error",
        "data-testid": "treeselect-error",
        children: error
      })]
    })
  });
});
TreeSelect.displayName = "TreeSelect";

module.exports = TreeSelect;
//# sourceMappingURL=TreeSelect.js.map
