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