import { defineComponent as _, mergeModels as h, useModel as c, computed as s, watch as B, createElementBlock as k, openBlock as m, Fragment as b, renderList as w, createBlock as M, unref as x, mergeProps as D } from "vue";
import { useI18n as I } from "vue-i18n";
import { b as E } from "./start-BYfL32Oe.mjs";
import "pinia";
import "vue-router";
import "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
const H = /* @__PURE__ */ _({
  __name: "SettingGroupedInputs",
  props: /* @__PURE__ */ h({
    modelValue: {},
    data: {},
    options: {},
    settings: {},
    loading: { type: Boolean },
    readonly: { type: Boolean },
    isDefault: { type: Boolean }
  }, {
    modelValue: {},
    modelModifiers: {},
    valid: { type: Boolean, default: !0 },
    validModifiers: {}
  }),
  emits: ["update:modelValue", "update:valid"],
  setup(l) {
    const n = l, r = c(l, "modelValue"), p = c(l, "valid"), { t: f } = I(), v = (t) => {
      var o, e;
      return (e = (o = r.value) == null ? void 0 : o.find(({ key: a }) => a === t)) == null ? void 0 : e.value;
    }, d = s(
      () => {
        var t, o;
        return ((o = (t = n.options) == null ? void 0 : t.items) == null ? void 0 : o.map(({ key: e }) => v(e))) ?? [];
      }
    ), u = s(
      () => {
        var t, o;
        return ((o = (t = n.options) == null ? void 0 : t.items) == null ? void 0 : o.map(({ regex: e }, a) => {
          const i = d.value[a];
          return !n.isDefault && e && !new RegExp(e).test(i) ? f("setting-plugin.setting-grouped-input.regex", { pattern: e }) : void 0;
        })) ?? [];
      }
    ), y = s(
      () => {
        var t, o;
        return ((o = (t = n.options) == null ? void 0 : t.items) == null ? void 0 : o.map((e, a) => {
          var i;
          return {
            modelValue: d.value[a],
            id: e.key,
            label: e.label,
            hint: e.helperText,
            persistentHint: !!e.helperText,
            style: (i = n.options) != null && i.width ? { width: n.options.width } : "",
            error: !n.isDefault && (!p.value || !!u),
            readonly: n.readonly,
            loading: n.loading,
            errorMessages: u.value[a]
          };
        })) ?? [];
      }
    );
    function V(t, o) {
      const e = { key: t, value: o };
      if (!Array.isArray(r.value)) {
        r.value = [e];
        return;
      }
      r.value = r.value.filter((a) => a.key !== t).concat(e);
    }
    return B(
      () => u.value.some((t) => !t),
      (t) => {
        p.value = t;
      }
    ), (t, o) => (m(!0), k(b, null, w(y.value, (e) => (m(), M(x(E), D({
      key: e.id,
      ref_for: !0
    }, e, {
      "onUpdate:modelValue": (a) => V(e.id, a)
    }), null, 16, ["onUpdate:modelValue"]))), 128));
  }
});
function g(l) {
  const n = l;
  n.__i18n = n.__i18n || [], n.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "setting-plugin": {
          "setting-grouped-input": {
            regex: { t: 0, b: { t: 2, i: [{ t: 3, v: "Has to match " }, { t: 4, k: "pattern" }] } }
          }
        }
      },
      "de-DE": {
        "setting-plugin": {
          "setting-grouped-input": {
            regex: { t: 0, b: { t: 2, i: [{ t: 3, v: "Has to match " }, { t: 4, k: "pattern" }] } }
          }
        }
      }
    }
  });
}
typeof g == "function" && g(H);
export {
  H as default
};
