import { defineComponent as w, shallowRef as z, computed as d, openBlock as r, createBlock as m, unref as e, withCtx as T, createElementBlock as f, normalizeClass as y, toDisplayString as x, createElementVNode as M, mergeProps as S } from "vue";
import { Input as V } from "@aplus-frontend/antdv";
import { omit as E, isNil as F } from "lodash-unified";
import "../../render/index.mjs";
import "../../config-provider/index.mjs";
import "../../hooks/index.mjs";
import { useDefaultPlaceholder as P } from "../hooks/use-default-placeholder.mjs";
import { useReadModeRender as U } from "../hooks/use-read-mode-render.mjs";
import j from "../style/index.mjs";
import { languageFormat as N } from "./utils.mjs";
import { useControllableValue as O } from "../../hooks/useControllableValue.mjs";
import { useNamespace as D } from "../../config-provider/hooks/use-namespace.mjs";
import K from "../../render/render.mjs";
const te = /* @__PURE__ */ w({
  name: "ApFieldTextArea",
  __name: "index",
  props: {
    mode: { default: "edit" },
    class: {},
    style: {},
    emptyText: { default: "--" },
    customReadMode: {},
    rows: {},
    autoSize: { type: [Boolean, Object] },
    onResize: {},
    onCompositionstart: {},
    onCompositionend: {},
    valueModifiers: {},
    size: {},
    value: {},
    name: {},
    type: { default: "text" },
    onFocus: {},
    onBlur: {},
    onChange: {},
    onInput: {},
    onKeydown: {},
    onKeyup: {},
    onMousedown: {},
    focused: { type: Boolean },
    hidden: { type: Boolean },
    disabled: { type: Boolean, default: void 0 },
    prefixCls: {},
    id: {},
    readonly: { type: Boolean },
    autofocus: { type: Boolean },
    variant: {},
    autocomplete: {},
    placeholder: {},
    lazy: { type: Boolean, default: !0 },
    maxlength: {},
    loading: { type: Boolean },
    bordered: { type: Boolean, default: !0 },
    showCount: { type: [Boolean, Object] },
    htmlSize: {},
    onPressEnter: {},
    onMouseUp: {},
    onRawInput: {},
    "onUpdate:value": {},
    status: {},
    defaultValue: {},
    inputElement: {},
    triggerFocus: {},
    handleReset: {},
    clearIcon: {},
    allowClear: { type: Boolean, default: !0 },
    beforeInput: {},
    code: { type: [Boolean, Object], default: !1 }
  },
  emits: ["update:value"],
  setup(l, { expose: g, emit: v }) {
    const a = z(), t = l, h = d(
      () => E(t, ["onUpdate:value", "value", "beforeInput", "emptyText"])
    ), B = v, { value: o, updateValue: b } = O(t, B), { renderer: C } = U(t, o), { b: I, m: p } = D("field-textarea"), u = j("field"), R = P("TextArea", t), A = d(() => {
      if (t.code)
        return t.code === !0 ? {
          language: "text"
        } : {
          language: t.code?.language ?? "text"
        };
    });
    function k(n) {
      const s = n.target.value || "", i = t.beforeInput ? t.beforeInput?.(s) : s, c = a.value?.$el?.querySelector("textarea");
      c && (c.value = i), b(i);
    }
    return g({
      focus: (n) => {
        a.value?.focus(n);
      },
      blur: () => {
        a.value?.blur();
      },
      resizableTextArea: d(() => a.value?.resizableTextArea)
    }), (n, s) => l.mode === "read" ? (r(), m(e(K), {
      key: 0,
      renderer: e(C)
    }, {
      default: T(() => [
        l.code ? (r(), f("pre", {
          key: 1,
          class: y([e(p)("code"), e(u)])
        }, [
          M("code", null, x(e(N)(e(o), A.value.language)), 1)
        ], 2)) : (r(), f("span", {
          key: 0,
          class: y([e(p)("read"), e(u)])
        }, x(e(F)(e(o)) || e(o) === "" ? l.emptyText : e(o)), 3))
      ]),
      _: 1
    }, 8, ["renderer"])) : (r(), m(e(V).TextArea, S({ key: 1 }, h.value, {
      ref_key: "textAreaRef",
      ref: a,
      placeholder: e(R),
      value: e(o),
      class: [e(I)(), e(u)],
      onInput: k
    }), null, 16, ["placeholder", "value", "class"]));
  }
});
export {
  te as default
};
