import { useState as m, useEffect as q } from "react";
import { a3 as N, aC as H, dD as _, dE as j, S as k, V as i, a5 as c, cf as M, cg as W, P as T, eM as G, aa as d, dx as J, dF as K, aG as Q, U as X, f0 as g, e_ as E, H as a, I as P, e$ as Z, f1 as p, c5 as V, ad as v, ae as u, a4 as l, eu as ee, dH as te, co as ae, dI as le, f2 as ne, af as s, ag as re, aj as y, dN as O, dO as U, dP as D, ah as ue, f3 as ie } from "./56c67d3b.js";
import { autoCompleteDate as se, convertAutoCompleteData as oe, itemsDataTooltip as me, autoCompleteRefMethods as ce, valueOrLabelOption as de, autoCompleteType as ye, autocompleteIconColor as Ce, componentSize as fe } from "./3fa53843.js";
import "react-dom";
const ge = N(ie)`
box-shadow: ${(e) => {
  var r, C;
  return `${(r = e.$style) == null ? void 0 : r.boxShadow} ${(C = e.$style) == null ? void 0 : C.boxShadowColor}`;
}};
  ${(e) => {
  var r;
  return H`
    ${_(e.$style)}
    input {
      padding: ${(r = e.style) == null ? void 0 : r.padding};
    }
    .ant-select-single {
      width: 100% !important;
    }
  `;
}}
`, ve = {
  ...j,
  viewRef: k,
  allowClear: i.DEFAULT_TRUE,
  style: c(M, "style"),
  labelStyle: c(W, "labelStyle"),
  prefixIcon: T,
  suffixIcon: T,
  items: G(oe, se),
  ignoreCase: i.DEFAULT_TRUE,
  searchFirstPY: i.DEFAULT_TRUE,
  searchCompletePY: i,
  searchLabelOnly: i.DEFAULT_TRUE,
  valueOrLabel: d(de, "label"),
  autoCompleteType: d(ye, "normal"),
  autocompleteIconColor: d(Ce, "blue"),
  componentSize: d(fe, "small"),
  valueInItems: J("valueInItems"),
  inputFieldStyle: c(K, "inputFieldStyle"),
  animationStyle: c(Q, "animationStyle")
}, Se = (e) => e.hasOwnProperty("validateStatus") && e.validateStatus === "error" ? "error" : "";
let S = function() {
  return new X(ve, (e) => {
    const {
      items: r,
      onEvent: C,
      placeholder: R,
      searchFirstPY: x,
      searchCompletePY: b,
      searchLabelOnly: $,
      ignoreCase: h,
      valueOrLabel: w,
      autoCompleteType: xe,
      autocompleteIconColor: be,
      componentSize: A
    } = e, I = () => ({
      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), [z, f] = m(e.value.value), [F, L] = m({}), [o, he] = m(g() === "zh-cn");
    return q(() => {
      f(e.value.value), B && L(E(I()));
    }, [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__ */ a(P, {
        children: /* @__PURE__ */ a(Z, {
          theme: {
            token: {
              colorBgContainer: e.inputFieldStyle.background,
              colorBorder: e.inputFieldStyle.border,
              borderRadius: parseInt(e.inputFieldStyle.radius),
              colorText: e.inputFieldStyle.text,
              colorPrimary: e.inputFieldStyle.accent,
              controlHeight: A === "small" ? 30 : 38
            }
          },
          children: /* @__PURE__ */ a(p, {
            disabled: e.disabled,
            value: z,
            options: r,
            style: {
              width: "100%"
            },
            onChange: (n, t) => {
              e.valueInItems.onChange(!1), L(E(I())), f(n), e.value.onChange(n), e.onEvent("change");
            },
            onFocus: () => {
              Y(!0), e.onEvent("focus");
            },
            onBlur: () => e.onEvent("blur"),
            onSelect: (n, t) => {
              f(t[w]), e.valueInItems.onChange(!0), e.value.onChange(t[w]), e.onEvent("submit");
            },
            filterOption: (n, t) => {
              if (h) {
                if (t != null && t.label && (t == null ? void 0 : t.label.toUpperCase().indexOf(n.toUpperCase())) !== -1)
                  return !0;
              } else if (t != null && t.label && (t == null ? void 0 : t.label.indexOf(n)) !== -1)
                return !0;
              if (o && x && (t != null && t.label) && t.label.spell("first").toString().toLowerCase().indexOf(n.toLowerCase()) >= 0 || o && b && (t != null && t.label) && t.label.spell().toString().toLowerCase().indexOf(n.toLowerCase()) >= 0)
                return !0;
              if (!$) {
                if (h) {
                  if (t != null && t.value && (t == null ? void 0 : t.value.toUpperCase().indexOf(n.toUpperCase())) !== -1)
                    return !0;
                } else if (t != null && t.value && (t == null ? void 0 : t.value.indexOf(n)) !== -1)
                  return !0;
                if (o && x && (t != null && t.value) && t.value.spell("first").toString().toLowerCase().indexOf(n.toLowerCase()) >= 0 || o && b && (t != null && t.value) && t.value.spell().toString().toLowerCase().indexOf(n.toLowerCase()) >= 0)
                  return !0;
              }
              return !1;
            },
            children: /* @__PURE__ */ a(ge, {
              ref: e.viewRef,
              placeholder: R,
              allowClear: e.allowClear,
              $style: e.inputFieldStyle,
              prefix: V(e.prefixIcon) && e.prefixIcon,
              suffix: V(e.suffixIcon) && e.suffixIcon,
              status: Se(F),
              onPressEnter: void 0
            })
          })
        })
      }),
      style: e.style,
      labelStyle: e.labelStyle,
      inputFieldStyle: e.inputFieldStyle,
      animationStyle: e.animationStyle,
      showValidationWhenEmpty: e.showValidationWhenEmpty,
      ...F
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ v(P, {
    children: [/* @__PURE__ */ v(u, {
      children: [e.autoCompleteType.getView() === "normal" && e.prefixIcon.propertyView({
        label: l("button.prefixIcon")
      }), e.autoCompleteType.getView() === "normal" && e.suffixIcon.propertyView({
        label: l("button.suffixIcon")
      }), ee(e)]
    }), /* @__PURE__ */ v(u, {
      name: l("autoComplete.SectionDataName"),
      children: [e.items.propertyView({
        label: l("autoComplete.value"),
        tooltip: me,
        placeholder: "[]"
      }), g() === "zh-cn" && e.searchFirstPY.propertyView({
        label: l("autoComplete.searchFirstPY")
      }), g() === "zh-cn" && e.searchCompletePY.propertyView({
        label: l("autoComplete.searchCompletePY")
      }), e.searchLabelOnly.propertyView({
        label: l("autoComplete.searchLabelOnly")
      }), e.ignoreCase.propertyView({
        label: l("autoComplete.ignoreCase")
      }), e.valueOrLabel.propertyView({
        label: l("autoComplete.checkedValueFrom"),
        radioButton: !0
      })]
    }), /* @__PURE__ */ a(te, {
      ...e
    }), /* @__PURE__ */ a(ae, {
      ...e
    }), e.label.getPropertyView(), /* @__PURE__ */ a(le, {
      ...e
    }), /* @__PURE__ */ a(ne, {
      ...e
    }), /* @__PURE__ */ a(u, {
      name: s.layout,
      children: re(e)
    }), /* @__PURE__ */ a(u, {
      name: s.style,
      children: e.style.getPropertyView()
    }), /* @__PURE__ */ a(u, {
      name: s.labelStyle,
      children: e.labelStyle.getPropertyView()
    }), /* @__PURE__ */ a(u, {
      name: s.inputFieldStyle,
      children: e.inputFieldStyle.getPropertyView()
    }), /* @__PURE__ */ a(u, {
      name: s.animationStyle,
      hasTooltip: !0,
      children: e.animationStyle.getPropertyView()
    })]
  })).setExposeMethodConfigs(ce).setExposeStateConfigs([new y("value", l("export.inputValueDesc")), new y("valueInItems", l("autoComplete.valueInItems")), O, U, ...D]).build();
}();
S = class extends S {
  autoHeight() {
    return !0;
  }
};
const Te = ue(S, [new y("value", l("export.inputValueDesc")), new y("valueInItems", l("autoComplete.valueInItems")), O, U, ...D]);
export {
  Te as AutoCompleteComp
};
