import e from "../PlTooltip/PlTooltip.js";
import "../PlTooltip/index.js";
import { getErrorMessage as t } from "../../helpers/error.js";
import n from "../PlSvg/PlSvg.js";
import "../PlSvg/index.js";
import r from "../../utils/DoubleContour.js";
import { useLabelNotch as i } from "../../utils/useLabelNotch.js";
import a from "../../assets/images/required.js";
import './pl-textarea.css';/* empty css            */
import { useValidation as o } from "../../utils/useValidation.js";
import { computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createVNode as f, defineComponent as p, normalizeClass as m, onMounted as h, openBlock as g, ref as _, renderSlot as v, toDisplayString as y, unref as b, useSlots as x, vModelText as S, withCtx as C, withDirectives as w } from "vue";
var T = { class: "ui-text-area__envelope" }, E = {
	key: 0,
	ref: "label"
}, D = [
	"readonly",
	"rows",
	"disabled",
	"placeholder"
], O = { class: "ui-text-area__append" }, k = {
	key: 0,
	class: "ui-text-area__error"
}, A = {
	key: 1,
	class: "ui-text-area__helper"
}, j = /* @__PURE__ */ p({
	name: "PlTextArea",
	props: {
		modelValue: {},
		label: {},
		required: { type: Boolean },
		error: {},
		helper: {},
		placeholder: {},
		disabled: { type: Boolean },
		readonly: { type: Boolean },
		dashed: { type: Boolean },
		rows: {},
		autogrow: { type: Boolean },
		rules: {}
	},
	emits: ["update:modelValue"],
	setup(p, { emit: j }) {
		let M = x(), N = j, P = p, F = _(), I = _(), L = s({
			get() {
				return P.modelValue ?? "";
			},
			set(e) {
				N("update:modelValue", e);
			}
		}), R = s(() => !!P.modelValue), z = o(L, P.rules || []);
		i(F);
		let B = s(() => {
			let e = [], n = t(P.error);
			return n && e.push(n), e.push(...z.value.errors), e;
		}), V = s(() => B.value.length > 0), H = () => {
			if (!P.autogrow) return;
			let e = I.value;
			e && (e.style.height = "auto", e.style.height = `${e.scrollHeight}px`);
		};
		return h(() => {
			H();
		}), (t, i) => (g(), u("div", T, [d("div", {
			ref_key: "root",
			ref: F,
			class: m(["ui-text-area", {
				error: V.value,
				disabled: p.disabled,
				dashed: p.dashed,
				nonEmpty: R.value
			}])
		}, [
			p.label ? (g(), u("label", E, [
				p.required ? (g(), c(b(n), {
					key: 0,
					uri: b(a)
				}, null, 8, ["uri"])) : l("", !0),
				d("span", null, y(p.label), 1),
				b(M).tooltip ? (g(), c(b(e), {
					key: 1,
					class: "info",
					position: "top"
				}, {
					tooltip: C(() => [v(t.$slots, "tooltip")]),
					_: 3
				})) : l("", !0)
			], 512)) : l("", !0),
			w(d("textarea", {
				ref_key: "input",
				ref: I,
				"onUpdate:modelValue": i[0] ||= (e) => L.value = e,
				readonly: p.readonly,
				rows: p.rows,
				disabled: p.disabled,
				placeholder: p.placeholder ?? "...",
				spellcheck: "false",
				onInput: H
			}, null, 40, D), [[S, L.value]]),
			d("div", O, [v(t.$slots, "append")]),
			f(r, { class: "ui-text-area__contour" })
		], 2), V.value ? (g(), u("div", k, y(B.value.join(" ")), 1)) : p.helper ? (g(), u("div", A, y(p.helper), 1)) : l("", !0)]));
	}
});
export { j as default };

//# sourceMappingURL=PlTextArea.vue2.js.map