import { defineComponent as B, mergeModels as c, useModel as D, ref as N, watch as b, createBlock as h, openBlock as k, unref as T } from "vue";
import { useI18n as I } from "vue-i18n";
import { u as O, b as A } from "./start-BYfL32Oe.mjs";
import "pinia";
import "vue-router";
import "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { V as F } from "./constants-CwfsvyFM.mjs";
import { u as $, b as g } from "./Numbers.json_vue_type_i18n_index_0_src_true_lang-BOEd2Oac.mjs";
const C = /* @__PURE__ */ B({
  __name: "DatahubDataTypeFloatValueEditor",
  props: /* @__PURE__ */ c({
    modelValue: {},
    readOnly: { type: Boolean },
    attribute: {},
    massEditing: { type: Boolean },
    label: {},
    fieldName: {},
    dataTypeInstance: {},
    loading: { type: Boolean }
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: /* @__PURE__ */ c(["validated", "update:model-value"], ["update:modelValue"]),
  setup(s, { emit: y }) {
    const a = s, v = y, l = D(s, "modelValue"), { t: V } = I(), { root: E, dispatchEvent: M } = O(F), n = N("");
    return b(
      () => a.modelValue,
      (e) => {
        var i, u, m, d, p;
        const o = typeof e == "string" ? parseFloat(e.replace(",", ".")) : e, { precision: r } = a.attribute.configuration;
        if (r && Number(e) === o && o % 1 !== 0) {
          const f = +`1e${a.attribute.configuration.precision}`;
          l.value = Math.round(o * f) / f;
        }
        const t = $(
          o,
          (i = a.attribute) == null ? void 0 : i.configuration
        );
        n.value = t ? V(t, {
          min: (m = (u = a.attribute) == null ? void 0 : u.configuration) == null ? void 0 : m.min,
          max: (p = (d = a.attribute) == null ? void 0 : d.configuration) == null ? void 0 : p.max
        }) : "";
      }
    ), b(
      () => !n.value,
      (e) => {
        M({ data: e }), v("validated", e);
      }
    ), (e, o) => {
      var r, t;
      return k(), h(T(A), {
        ref_key: "root",
        ref: E,
        modelValue: l.value,
        "onUpdate:modelValue": o[0] || (o[0] = (i) => l.value = i),
        modelModifiers: { number: !0 },
        readonly: ((t = (r = e.attribute) == null ? void 0 : r.configuration) == null ? void 0 : t.readOnly) || e.readOnly,
        loading: e.loading,
        label: e.massEditing ? void 0 : e.label,
        "error-messages": n.value,
        "persistent-placeholder": ""
      }, null, 8, ["modelValue", "readonly", "loading", "label", "error-messages"]);
    };
  }
});
typeof g == "function" && g(C);
export {
  C as default
};
