import { _ as _defineProperty } from '../defineProperty-CEd-kZQW.js';
import { _ as _extends } from '../extends-C4cduGrv.js';
import { _ as _objectWithoutProperties } from '../objectWithoutProperties-TXwlfNxG.js';
import React__default from 'react';
import cx from 'classnames';

var _excluded = ["name", "state", "className", "style", "append", "prepend"];

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var STATES = {
  "default": "border-gray-200 focus:outline-blue",
  error: "border-red-600 outline-red",
  success: "border-green-600 outline-green"
};

function Pend(_ref) {
  var item = _ref.item,
      className = _ref.className;
  if (!item) return null;
  var classes = "text-gray-700 whitespace-pre flex items-center ".concat(className);
  return /*#__PURE__*/React__default.createElement("div", {
    className: classes
  }, item);
}

var Input = /*#__PURE__*/React__default.forwardRef(function (_ref2, ref) {
  var name = _ref2.name,
      _ref2$state = _ref2.state,
      state = _ref2$state === void 0 ? "default" : _ref2$state,
      className = _ref2.className,
      style = _ref2.style,
      append = _ref2.append,
      prepend = _ref2.prepend,
      props = _objectWithoutProperties(_ref2, _excluded);

  className = cx(className, "flex text-sm border rounded px-3 py-2 w-full", STATES[state]);

  if (props.type === "hidden") {
    return /*#__PURE__*/React__default.createElement("input", _extends({
      ref: ref,
      name: name
    }, props));
  }

  return /*#__PURE__*/React__default.createElement("div", {
    className: className
  }, /*#__PURE__*/React__default.createElement(Pend, {
    item: prepend,
    className: "pr-2"
  }), /*#__PURE__*/React__default.createElement("input", _extends({
    ref: ref,
    style: _objectSpread({
      lineHeight: "22px"
    }, style),
    className: "w-full focus:outline-none design-input",
    name: name
  }, props)), /*#__PURE__*/React__default.createElement(Pend, {
    item: append,
    className: "pl-2"
  }));
});

export { Input as default };
