import { useState as m, useEffect as z } from "react";
import { b9 as N, co as $, bf as j, bv as n, bB as L, dl as k, bO as _, be as T, eF as H, bb as i, cU as M, U as J, eU as f, V as r, bh as E, eT as G, eV as K, bD as P, P as b, bi as u, a0 as a, dm as Q, bj as d, bl as W, bo as c, dp as V, dq as F, bn as X, dr as Z } from "./684d2f28.js";
import { FormDataPropertyView as p } from "./00dac55d.js";
import { getStyle as ee, textInputChildren as te, textInputValidate as O, TextInputBasicSection as ae, TextInputInteractionSection as le, TextInputValidationSection as re, TextInputConfigs as U } from "./0c4ef413.js";
import { autoCompleteDate as ne, convertAutoCompleteData as ue, valueOrLabelOption as se, autoCompleteType as oe, autocompleteIconColor as me, componentSize as ie, itemsDataTooltip as ce, autoCompleteRefMethods as Ce } from "./0f54d801.js";
import "react-dom";
import "./d6402597.js";
const fe = N(Z)`
  ${(e) => {
  var s;
  return $`
    ${ee(e.$style)}
    input {
      padding: ${(s = e.style) == null ? void 0 : s.padding};
    }
    .ant-select-single {
      width: 100% !important;
    }
  `;
}}
`, be = {
  ...te,
  viewRef: j,
  allowClear: n.DEFAULT_TRUE,
  style: L(k),
  labelStyle: L(_),
  prefixIcon: T,
  suffixIcon: T,
  items: H(ue, ne),
  ignoreCase: n.DEFAULT_TRUE,
  searchFirstPY: n.DEFAULT_TRUE,
  searchCompletePY: n,
  searchLabelOnly: n.DEFAULT_TRUE,
  valueOrLabel: i(se, "label"),
  autoCompleteType: i(oe, "normal"),
  autocompleteIconColor: i(me, "blue"),
  componentSize: i(ie, "small"),
  valueInItems: M("valueInItems")
}, de = (e) => e.hasOwnProperty("validateStatus") && e.validateStatus === "error" ? "error" : "";
let y = function() {
  return new J(be, (e) => {
    const {
      items: s,
      onEvent: ye,
      placeholder: D,
      searchFirstPY: v,
      searchCompletePY: g,
      searchLabelOnly: R,
      ignoreCase: x,
      valueOrLabel: I,
      autoCompleteType: ve,
      autocompleteIconColor: ge,
      componentSize: A
    } = e, w = () => ({
      value: {
        value: e.value.value
      },
      required: e.required,
      minLength: (e == null ? void 0 : e.minLength) ?? 0,
      maxLength: (e == null ? void 0 : e.maxLength) ?? 0,
      validationType: e.validationType,
      regex: e.regex,
      customRule: e.customRule
    }), [B, Y] = m(!1), [q, C] = m(e.value.value), [h, S] = m({}), [o, xe] = m(f() === "zh-cn");
    return z(() => {
      C(e.value.value), B && S(O(w()));
    }, [e.value.value, e.required, e == null ? void 0 : e.minLength, e == null ? void 0 : e.maxLength, e.validationType, e.regex, e.customRule]), e.label({
      required: e.required,
      children: /* @__PURE__ */ r(E, {
        children: /* @__PURE__ */ r(G, {
          theme: {
            token: {
              colorBgContainer: e.style.background,
              colorBorder: e.style.border,
              borderRadius: parseInt(e.style.radius),
              colorText: e.style.text,
              colorPrimary: e.style.accent,
              controlHeight: A === "small" ? 30 : 38
            }
          },
          children: /* @__PURE__ */ r(K, {
            disabled: e.disabled,
            value: q,
            options: s,
            style: {
              width: "100%"
            },
            onChange: (l, t) => {
              e.valueInItems.onChange(!1), S(O(w())), C(l), e.value.onChange(l), e.onEvent("change");
            },
            onFocus: () => {
              Y(!0), e.onEvent("focus");
            },
            onBlur: () => e.onEvent("blur"),
            onSelect: (l, t) => {
              C(t[I]), e.valueInItems.onChange(!0), e.value.onChange(t[I]), e.onEvent("submit");
            },
            filterOption: (l, t) => {
              if (x) {
                if (t != null && t.label && (t == null ? void 0 : t.label.toUpperCase().indexOf(l.toUpperCase())) !== -1)
                  return !0;
              } else if (t != null && t.label && (t == null ? void 0 : t.label.indexOf(l)) !== -1)
                return !0;
              if (o && v && (t != null && t.label) && t.label.spell("first").toString().toLowerCase().indexOf(l.toLowerCase()) >= 0 || o && g && (t != null && t.label) && t.label.spell().toString().toLowerCase().indexOf(l.toLowerCase()) >= 0)
                return !0;
              if (!R) {
                if (x) {
                  if (t != null && t.value && (t == null ? void 0 : t.value.toUpperCase().indexOf(l.toUpperCase())) !== -1)
                    return !0;
                } else if (t != null && t.value && (t == null ? void 0 : t.value.indexOf(l)) !== -1)
                  return !0;
                if (o && v && (t != null && t.value) && t.value.spell("first").toString().toLowerCase().indexOf(l.toLowerCase()) >= 0 || o && g && (t != null && t.value) && t.value.spell().toString().toLowerCase().indexOf(l.toLowerCase()) >= 0)
                  return !0;
              }
              return !1;
            },
            children: /* @__PURE__ */ r(fe, {
              ref: e.viewRef,
              placeholder: D,
              allowClear: e.allowClear,
              $style: e.style,
              prefix: P(e.prefixIcon) && e.prefixIcon,
              suffix: P(e.suffixIcon) && e.suffixIcon,
              status: de(h),
              onPressEnter: void 0
            })
          })
        })
      }),
      style: e.style,
      labelStyle: e.labelStyle,
      ...h
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ b(E, {
    children: [/* @__PURE__ */ b(u, {
      children: [e.autoCompleteType.getView() === "normal" && e.prefixIcon.propertyView({
        label: a("button.prefixIcon")
      }), e.autoCompleteType.getView() === "normal" && e.suffixIcon.propertyView({
        label: a("button.suffixIcon")
      }), Q(e)]
    }), /* @__PURE__ */ b(u, {
      name: a("autoComplete.SectionDataName"),
      children: [e.items.propertyView({
        label: a("autoComplete.value"),
        tooltip: ce,
        placeholder: "[]"
      }), f() === "zh-cn" && e.searchFirstPY.propertyView({
        label: a("autoComplete.searchFirstPY")
      }), f() === "zh-cn" && e.searchCompletePY.propertyView({
        label: a("autoComplete.searchCompletePY")
      }), e.searchLabelOnly.propertyView({
        label: a("autoComplete.searchLabelOnly")
      }), e.ignoreCase.propertyView({
        label: a("autoComplete.ignoreCase")
      }), e.valueOrLabel.propertyView({
        label: a("autoComplete.checkedValueFrom"),
        radioButton: !0
      })]
    }), /* @__PURE__ */ r(ae, {
      ...e
    }), /* @__PURE__ */ r(p, {
      ...e
    }), e.label.getPropertyView(), /* @__PURE__ */ r(le, {
      ...e
    }), /* @__PURE__ */ r(re, {
      ...e
    }), /* @__PURE__ */ r(u, {
      name: d.layout,
      children: W(e)
    }), /* @__PURE__ */ r(u, {
      name: d.style,
      children: e.style.getPropertyView()
    }), /* @__PURE__ */ r(u, {
      name: d.labelStyle,
      children: e.labelStyle.getPropertyView()
    })]
  })).setExposeMethodConfigs(Ce).setExposeStateConfigs([new c("value", a("export.inputValueDesc")), new c("valueInItems", a("autoComplete.valueInItems")), V, F, ...U]).build();
}();
y = class extends y {
  autoHeight() {
    return !0;
  }
};
const Pe = X(y, [new c("value", a("export.inputValueDesc")), new c("valueInItems", a("autoComplete.valueInItems")), V, F, ...U]);
export {
  Pe as AutoCompleteComp
};
