import { validationMessageValidator as l } from "../../common/validators/index.js";
import { getValidationState as g, filterFormattedMessages as m, getUniqueString as u } from "../../common/utils/index.js";
import { createElementBlock as t, createCommentVNode as c, openBlock as i, Fragment as _, renderList as p, normalizeClass as M, createElementVNode as f } from "vue";
import { _ as v } from "../../_plugin-vue_export-helper-CHgC5LLL.js";
const y = {
  compatConfig: { MODE: 3 },
  name: "DtValidationMessages",
  props: {
    /**
     * The id of the validation message
     */
    id: {
      type: String,
      default() {
        return u();
      }
    },
    /**
     * Array of validation messages. Each message has the following structure:
     * `{ message: "Some informative message", type: "error|warning|success"}`
     */
    validationMessages: {
      type: Array,
      default: () => [],
      validator: (e) => l(e)
    },
    /**
     * Show Validation messages
     * @values true, false
     */
    showMessages: {
      type: Boolean,
      default: !0
    }
  },
  computed: {
    isFilteredValidationMessagesEmpty() {
      return this.filteredValidationMessages.length === 0;
    },
    filteredValidationMessages() {
      return m(this.validationMessages);
    },
    validationState() {
      return g(this.validationMessages);
    }
  },
  methods: {
    getMessageKey(e, a) {
      return `validation-message-${e}-${a}-${this.id}`;
    },
    messageTypeClass(e) {
      return {
        error: "base-input__message--error d-validation-message--error",
        warning: "base-input__message--warning d-validation-message--warning",
        success: "base-input__message--success d-validation-message--success"
      }[e];
    }
  }
}, h = {
  key: 0,
  class: "base-input__messages d-validation-message__container",
  "data-qa": "validation-messages-container"
}, V = ["innerHTML"];
function C(e, a, n, T, b, s) {
  return n.showMessages && !s.isFilteredValidationMessagesEmpty ? (i(), t("div", h, [
    (i(!0), t(_, null, p(s.filteredValidationMessages, ({ message: o, type: r }, d) => (i(), t("div", {
      key: s.getMessageKey(r, d),
      role: "status",
      "aria-live": "polite",
      "data-qa": "validation-message",
      class: M([
        "base-input__message",
        "d-validation-message",
        s.messageTypeClass(r)
      ])
    }, [
      f("p", { innerHTML: o }, null, 8, V)
    ], 2))), 128))
  ])) : c("", !0);
}
const S = /* @__PURE__ */ v(y, [["render", C]]);
export {
  S as default
};
//# sourceMappingURL=validation-messages.js.map
