'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

require('./_commonjsHelpers-06173234.js');
require('./_to-object-329a650b.js');
require('./es6.string.iterator-cc0bbaa4.js');
require('./core.get-iterator-method-f62321d4.js');
require('./web.dom.iterable-a0e279c1.js');
var React = require('react');
var React__default = _interopDefault(React);
var slicedToArray = require('./slicedToArray-8f385299.js');
var Button = _interopDefault(require('react-bootstrap/Button'));
var Form = _interopDefault(require('react-bootstrap/Form'));
var FormControl = _interopDefault(require('react-bootstrap/FormControl'));

var Search = function Search(props) {
  var _props$placeholder = props.placeholder,
      placeholder = _props$placeholder === undefined ? 'Search' : _props$placeholder,
      _props$btnText = props.btnText,
      btnText = _props$btnText === undefined ? 'Search' : _props$btnText,
      _props$device = props.device,
      device = _props$device === undefined ? 'desktop' : _props$device;

  var _useState = React.useState(''),
      _useState2 = slicedToArray._slicedToArray(_useState, 2),
      searchKey = _useState2[0],
      setSearchKey = _useState2[1];

  var submitSearch = function submitSearch(e) {
    e.preventDefault();
    window.location.href = '/search?searchTerm=' + searchKey;
  };

  return React__default.createElement(
    Form,
    { inline: true, onSubmit: function onSubmit(e) {
        return submitSearch(e);
      } },
    React__default.createElement(FormControl, {
      className: device === 'mobile' ? 'mobile-search mr-sm-2' : 'mr-sm-2',
      type: 'text',
      placeholder: placeholder,
      value: searchKey,
      onChange: function onChange(e) {
        return setSearchKey(e.target.value);
      }
    }),
    React__default.createElement(
      Button,
      { variant: 'secondary', onClick: function onClick(e) {
          return submitSearch(e);
        } },
      btnText
    ),
    React__default.createElement(
      'style',
      { jsx: 'true' },
      '\n        .mobile-search {\n          width: 75%;\n          margin-right: 15px;\n        }\n      '
    )
  );
};

module.exports = Search;
