import { defineComponent as _, mergeModels as v, useModel as D, computed as b, watch as V, createBlock as B, openBlock as T, unref as t, withCtx as h, createElementVNode as P, createVNode as m } from "vue";
import { useI18n as w } from "vue-i18n";
import { storeToRefs as M } from "pinia";
import { u as U, a as c, d as A, o as N } from "./start-CE9SawgU.js";
import "./header-Bn1EKnBE.js";
import { V as k } from "./constants-CwfsvyFM.js";
import "@vuelidate/validators";
import "./TreeView.vue_vue_type_style_index_0_scoped_0bd14ef7_lang-CZieIjgg.js";
import "./DatahubDataTypeCompletenessRenderer.vue_vue_type_script_setup_true_lang-5buor0oX.js";
import "./topBarRoutes-CBd5qLxn.js";
import "./IsActiveStatusCell-xz7XnAYP.js";
import "./VariantToVariantExtension-DUC3WSrH.js";
import { _ as O } from "./DatahubDataComplexValue.vue_vue_type_script_setup_true_lang-CDA1jFcx.js";
import "./DatahubDataTypeVariantValueEditor-9WYNJneN.js";
import "./dataTypes-DocW2t0g.js";
import { u as x } from "./pimDataType-C9MfxZo5.js";
const C = { class: "base-price" }, I = /* @__PURE__ */ _({
  __name: "PIMDataTypeBasePriceValueEditor",
  props: /* @__PURE__ */ v({
    modelValue: {},
    readOnly: { type: Boolean },
    attribute: {},
    massEditing: { type: Boolean },
    label: {},
    fieldName: {},
    dataTypeInstance: {},
    loading: { type: Boolean },
    succeeded: { type: Boolean }
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: /* @__PURE__ */ v(["validated", "update:model-value", "initialized"], ["update:modelValue"]),
  setup(s) {
    const e = D(s, "modelValue"), { t: n } = w(), { root: g, dispatchEvent: y } = U(k), u = x(), { isDimensionsLoading: p, dimensions: d } = M(
      u
    );
    u.ensureDimensions();
    const E = b(
      () => e.value?.dimensionId ? d.value.find(({ id: i }) => i === e.value.dimensionId)?.units ?? [] : []
    ), l = b(() => ({
      unitId: e.value?.dimensionId && !e.value?.unitId ? n("pim-plugin.base-price.unitIdError") : void 0,
      amount: e.value?.dimensionId && Number(e.value?.amount) <= 0 ? n("pim-plugin.base-price.amountError") : void 0
    }));
    function r(i) {
      i.dimensionId && (i.unitId = d.value.find(
        ({ id: a }) => a === i.dimensionId
      )?.baseUnit?.id), e.value = { ...e.value, ...i };
    }
    return V(
      () => !l.value.unitId && !l.value.amount,
      (i) => y({ data: i })
    ), (i, a) => (T(), B(t(O), {
      ref_key: "root",
      ref: g,
      header: i.massEditing ? void 0 : i.label
    }, {
      default: h(() => [
        P("div", C, [
          m(t(c), {
            "model-value": e.value?.dimensionId,
            label: t(n)("pim-plugin.base-price.dimension"),
            disabled: i.readOnly,
            items: t(d),
            loading: t(p),
            "item-title": "name",
            "item-value": "id",
            "max-width": "280",
            search: "",
            "onUpdate:modelValue": a[0] || (a[0] = (o) => r({ dimensionId: o }))
          }, null, 8, ["model-value", "label", "disabled", "items", "loading"]),
          m(t(A), {
            "model-value": e.value?.amount,
            label: t(n)("pim-plugin.base-price.relevantAmount"),
            disabled: i.readOnly || !e.value?.dimensionId,
            "error-messages": l.value?.amount,
            type: "number",
            "max-width": "280",
            "onUpdate:modelValue": a[1] || (a[1] = (o) => r({ amount: o }))
          }, null, 8, ["model-value", "label", "disabled", "error-messages"]),
          m(t(c), {
            "model-value": e.value?.unitId,
            label: t(n)("pim-plugin.base-price.unit"),
            disabled: i.readOnly || !e.value?.dimensionId,
            items: E.value,
            loading: t(p),
            "error-messages": l.value?.unitId,
            "item-title": "name",
            "item-value": "id",
            "max-width": "280",
            search: "",
            "onUpdate:modelValue": a[2] || (a[2] = (o) => r({ unitId: o }))
          }, null, 8, ["model-value", "label", "disabled", "items", "loading", "error-messages"])
        ])
      ]),
      _: 1
    }, 8, ["header"]));
  }
});
function f(s) {
  const e = s;
  e.__i18n = e.__i18n || [], e.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "pim-plugin": {
          "base-price": {
            amountError: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Positive number expected" } },
            unitIdError: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Field is required" } },
            dimension: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Dimension" } },
            relevantAmount: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Relevant amount" } },
            unit: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Unit" } }
          }
        }
      },
      "de-DE": {
        "pim-plugin": {
          "base-price": {
            amountError: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Positive Zahl erwartet" } },
            unitIdError: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Das Feld ist erforderlich" } },
            dimension: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Dimension" } },
            relevantAmount: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Relevante Menge" } },
            unit: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Einheit" } }
          }
        }
      }
    }
  });
}
typeof f == "function" && f(I);
const Y = /* @__PURE__ */ N(I, [["__scopeId", "data-v-1d593c47"]]);
export {
  Y as default
};
