import P from "../../@babel/runtime/helpers/esm/extends.mjs";
import h from "../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import v from "../../@babel/runtime/helpers/esm/defineProperty.mjs";
import ee from "../../@babel/runtime/helpers/esm/typeof.mjs";
import d from "../../classnames/index.mjs";
import r, { useRef as ne, cloneElement as W } from "react";
import { hasPrefixSuffix as _, hasAddon as s } from "./utils/commonUtils.mjs";
var ve = function(e) {
  var x, E, p = e.inputElement, i = e.prefixCls, k = e.prefix, N = e.suffix, B = e.addonBefore, $ = e.addonAfter, g = e.className, C = e.style, D = e.disabled, j = e.readOnly, S = e.focused, I = e.triggerFocus, o = e.allowClear, y = e.value, q = e.handleReset, w = e.hidden, a = e.classes, l = e.classNames, b = e.dataAttrs, t = e.styles, n = e.components, z = (n == null ? void 0 : n.affixWrapper) || "span", H = (n == null ? void 0 : n.groupWrapper) || "span", J = (n == null ? void 0 : n.wrapper) || "span", F = (n == null ? void 0 : n.groupAddon) || "span", G = ne(null), K = function(u) {
    var m;
    (m = G.current) !== null && m !== void 0 && m.contains(u.target) && (I == null || I());
  }, L = function() {
    var u;
    if (!o)
      return null;
    var m = !D && !j && y, R = "".concat(i, "-clear-icon"), Y = ee(o) === "object" && o !== null && o !== void 0 && o.clearIcon ? o.clearIcon : "✖";
    return /* @__PURE__ */ r.createElement("span", {
      onClick: q,
      onMouseDown: function(Z) {
        return Z.preventDefault();
      },
      className: d(R, (u = {}, v(u, "".concat(R, "-hidden"), !m), v(u, "".concat(R, "-has-suffix"), !!N), u)),
      role: "button",
      tabIndex: -1
    }, Y);
  }, A = /* @__PURE__ */ W(p, {
    value: y,
    hidden: w,
    className: d((x = p.props) === null || x === void 0 ? void 0 : x.className, !_(e) && !s(e) && g) || null,
    style: h(h({}, (E = p.props) === null || E === void 0 ? void 0 : E.style), !_(e) && !s(e) ? C : {})
  });
  if (_(e)) {
    var c, f = "".concat(i, "-affix-wrapper"), Q = d(f, (c = {}, v(c, "".concat(f, "-disabled"), D), v(c, "".concat(f, "-focused"), S), v(c, "".concat(f, "-readonly"), j), v(c, "".concat(f, "-input-with-clear-btn"), N && o && y), c), !s(e) && g, a == null ? void 0 : a.affixWrapper, l == null ? void 0 : l.affixWrapper), T = (N || o) && /* @__PURE__ */ r.createElement("span", {
      className: d("".concat(i, "-suffix"), l == null ? void 0 : l.suffix),
      style: t == null ? void 0 : t.suffix
    }, L(), N);
    A = /* @__PURE__ */ r.createElement(z, P({
      className: Q,
      style: h(h({}, s(e) ? void 0 : C), t == null ? void 0 : t.affixWrapper),
      hidden: !s(e) && w,
      onClick: K
    }, b == null ? void 0 : b.affixWrapper, {
      ref: G
    }), k && /* @__PURE__ */ r.createElement("span", {
      className: d("".concat(i, "-prefix"), l == null ? void 0 : l.prefix),
      style: t == null ? void 0 : t.prefix
    }, k), /* @__PURE__ */ W(p, {
      value: y,
      hidden: null
    }), T);
  }
  if (s(e)) {
    var M = "".concat(i, "-group"), O = "".concat(M, "-addon"), U = d("".concat(i, "-wrapper"), M, a == null ? void 0 : a.wrapper), V = d("".concat(i, "-group-wrapper"), g, a == null ? void 0 : a.group);
    return /* @__PURE__ */ r.createElement(H, {
      className: V,
      style: C,
      hidden: w
    }, /* @__PURE__ */ r.createElement(J, {
      className: U
    }, B && /* @__PURE__ */ r.createElement(F, {
      className: O
    }, B), /* @__PURE__ */ W(A, {
      hidden: null
    }), $ && /* @__PURE__ */ r.createElement(F, {
      className: O
    }, $)));
  }
  return A;
};
export {
  ve as default
};
