"use strict";
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_uviewPro_components_uSearch_types = require("./types.js");
const uni_modules_uviewPro_libs_index = require("../../libs/index.js");
require("../../libs/util/logger.js");
require("../../libs/config/theme-tokens.js");
if (!Array) {
  const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  _easycom_u_icon2();
}
const _easycom_u_icon = () => "../u-icon/u-icon.js";
if (!Math) {
  _easycom_u_icon();
}
const __default__ = {
  name: "u-search",
  options: {
    addGlobalClass: true,
    virtualHost: true,
    styleIsolation: "shared"
  }
};
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  ...__default__,
  props: uni_modules_uviewPro_components_uSearch_types.SearchProps,
  emits: [
    "update:modelValue",
    "input",
    "change",
    "search",
    "custom",
    "clear",
    "focus",
    "blur",
    "click"
  ],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const keyword = common_vendor.ref(props.modelValue);
    common_vendor.ref(false);
    const show = common_vendor.ref(false);
    const focused = common_vendor.ref(props.focus);
    common_vendor.watch(
      () => props.modelValue,
      (nVal) => {
        keyword.value = nVal;
      }
    );
    common_vendor.watch(keyword, (nVal) => {
      emit("update:modelValue", nVal);
      emit("input", nVal);
      emit("change", nVal);
    });
    const showActionBtn = common_vendor.computed(() => {
      if (!props.animation && props.showAction)
        return true;
      else
        return false;
    });
    const borderStyle = common_vendor.computed(() => {
      if (props.borderColor)
        return `1px solid ${props.borderColor}`;
      else
        return "none";
    });
    function inputChange(e) {
      keyword.value = e.detail.value;
    }
    function clear() {
      keyword.value = "";
      common_vendor.nextTick$1(() => {
        emit("clear");
      });
    }
    function search(e) {
      emit("search", e.detail.value);
      try {
        common_vendor.index.hideKeyboard();
      } catch (e2) {
      }
    }
    function custom() {
      emit("custom", keyword.value);
      try {
        common_vendor.index.hideKeyboard();
      } catch (e) {
      }
    }
    function getFocus() {
      focused.value = true;
      if (props.animation && props.showAction)
        show.value = true;
      emit("focus", keyword.value);
    }
    function blur() {
      setTimeout(() => {
        focused.value = false;
      }, 100);
      show.value = false;
      emit("blur", keyword.value);
    }
    function clickHandler() {
      if (props.disabled)
        emit("click");
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.p({
          size: 30,
          name: _ctx.searchIcon,
          color: _ctx.searchIconColor ? _ctx.searchIconColor : _ctx.color
        }),
        b: common_vendor.o(blur, "3b"),
        c: _ctx.modelValue,
        d: common_vendor.o(search, "c7"),
        e: common_vendor.o(inputChange, "c6"),
        f: common_vendor.o(getFocus, "a0"),
        g: _ctx.focus,
        h: Number(_ctx.maxlength),
        i: _ctx.placeholder,
        j: `color: ${_ctx.placeholderColor}`,
        k: _ctx.adjustPosition,
        l: common_vendor.s({
          textAlign: _ctx.inputAlign,
          color: _ctx.color,
          backgroundColor: _ctx.bgColor,
          pointerEvents: _ctx.disabled ? "none" : "auto"
        }),
        m: common_vendor.s(_ctx.inputStyle),
        n: keyword.value && _ctx.clearabled && focused.value
      }, keyword.value && _ctx.clearabled && focused.value ? {
        o: common_vendor.p({
          name: "close-circle-fill",
          size: "34",
          color: "var(--u-light-color)"
        }),
        p: common_vendor.o(clear, "44")
      } : {}, {
        q: _ctx.bgColor,
        r: _ctx.shape == "round" ? "100rpx" : "10rpx",
        s: borderStyle.value,
        t: _ctx.height + "rpx",
        v: common_vendor.t(_ctx.actionText),
        w: common_vendor.s(_ctx.actionStyle),
        x: common_vendor.n(showActionBtn.value || show.value ? "u-action-active" : ""),
        y: common_vendor.o(custom, "38"),
        z: common_vendor.o(clickHandler, "a9"),
        A: common_vendor.n(_ctx.customClass),
        B: common_vendor.s(common_vendor.unref(uni_modules_uviewPro_libs_index.$u).toStyle({
          margin: _ctx.margin
        }, _ctx.customStyle))
      });
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-f0201178"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/components/u-search/u-search.js.map
