import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
import { u as useViewHandler } from './index-bbdfb97a.js';
import { observer } from 'mobx-react-lite';
import { useState, useEffect } from 'react';
import { useTranslation } from '@crystaldesign/diva-core';
import { jsxs, jsx } from 'react/jsx-runtime';
import 'react-dynamic-multi-render';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/regenerator';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@babel/runtime/helpers/toConsumableArray';
import '@crystaldesign/diva-utils';
import 'mobx';
import '@crystaldesign/web-planner-logic';
import 'classnames';
import 'qrcode.react';
import '@babel/runtime/helpers/typeof';
import 'flat';
import 'react-switch';
import 'react-countup';

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), !0).forEach(function (r) { _defineProperty(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 TabSearch = function TabSearch(_ref) {
  var props = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    search = _useState2[0],
    setSearch = _useState2[1];
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var viewHandler = useViewHandler();
  useEffect(function () {
    var searchGotResetted = !!viewHandler.tabGroupState.filterTabgroup && !search;
    viewHandler.tabGroupState.setFilterTabgroup(search && search !== '' ? search : undefined);
    if (searchGotResetted) {
      setTimeout(function () {
        return viewHandler.tabGroupState.scrollToCurTabgroup();
      }, 200);
    }
  }, [search]);
  useEffect(function () {
    if (viewHandler.tabGroupState.filterTabgroup === undefined && search) {
      setSearch('');
    }
  }, [viewHandler.tabGroupState.filterTabgroup]);
  return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({}, props), {}, {
    children: [/*#__PURE__*/jsx("input", {
      value: search,
      type: "text",
      onChange: function onChange(e) {
        return setSearch(e.target.value);
      },
      placeholder: t('filter.global')
    }), !!search && /*#__PURE__*/jsx("div", {
      onClick: function onClick() {
        return setSearch('');
      }
    })]
  }));
};
var TabSearch$1 = observer(TabSearch);

export { TabSearch$1 as default };
