import { defineComponent as y, computed as p, ref as _, watch as d, createBlock as I, openBlock as h, withCtx as V, createElementVNode as U, createVNode as c, unref as a } from "vue";
import { useI18n as D } from "vue-i18n";
import { a as f, o as B } from "./start-CE9SawgU.js";
import "pinia";
import "./header-Bn1EKnBE.js";
import { _ as E } from "./DatahubDataComplexValue.vue_vue_type_script_setup_true_lang-CDA1jFcx.js";
const O = { class: "extension-config d-flex flex-wrap" }, v = /* @__PURE__ */ y({
  __name: "DatahubDataTypeSalesUnitValueEditor",
  props: {
    modelValue: {},
    readOnly: { type: Boolean },
    attribute: {},
    massEditing: { type: Boolean },
    label: {},
    fieldName: {},
    dataTypeInstance: {},
    loading: { type: Boolean },
    succeeded: { type: Boolean }
  },
  emits: ["validated", "update:model-value", "initialized"],
  setup(l, { emit: t }) {
    const s = l, g = t, { t: u } = D(), m = p(
      () => s.dataTypeInstance?.defaultConfiguration?.selectableDimensions ?? [{ units: [{ name: "name 1", id: 1 }] }]
    ), n = _({}), r = p(() => n.value?.dimensionId ? m.value.find(({ id: e }) => e === n.value.dimensionId)?.units ?? [] : []);
    return d(
      () => s.modelValue,
      (e) => {
        n.value = e ?? { dimensionId: null, unitId: null };
      },
      { deep: !0 }
    ), d(
      () => n.value.dimensionId,
      () => {
        n.value.unitId = null;
      },
      { deep: !0 }
    ), d(
      n,
      (e) => {
        g("update:model-value", e ?? { dimensionId: null, unitId: null });
      },
      { deep: !0 }
    ), (e, i) => (h(), I(E, { header: e.label }, {
      default: V(() => [
        U("div", O, [
          c(a(f), {
            modelValue: n.value.dimensionId,
            "onUpdate:modelValue": i[0] || (i[0] = (o) => n.value.dimensionId = o),
            items: m.value,
            label: a(u)("datahub-plugin.salesUnit.dimension"),
            readonly: e.attribute?.configuration?.readOnly || e.readOnly,
            loading: e.loading,
            "item-title": "name",
            "item-value": "id",
            class: "extension-config__input",
            "persistent-placeholder": ""
          }, null, 8, ["modelValue", "items", "label", "readonly", "loading"]),
          c(a(f), {
            modelValue: n.value.unitId,
            "onUpdate:modelValue": i[1] || (i[1] = (o) => n.value.unitId = o),
            items: r.value,
            label: a(u)("datahub-plugin.salesUnit.unit"),
            readonly: e.attribute?.configuration?.readOnly || e.readOnly,
            loading: e.loading,
            disabled: !r.value.length,
            "item-title": "name",
            "item-value": "id",
            class: "extension-config__input",
            "persistent-placeholder": ""
          }, null, 8, ["modelValue", "items", "label", "readonly", "loading", "disabled"])
        ])
      ]),
      _: 1
    }, 8, ["header"]));
  }
});
function b(l) {
  const t = l;
  t.__i18n = t.__i18n || [], t.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "datahub-plugin": {
          salesUnit: {
            dimension: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Dimension" } },
            unit: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Unit" } }
          }
        }
      },
      "de-DE": {
        "datahub-plugin": {
          salesUnit: {
            dimension: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Dimension" } },
            unit: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Einheit" } }
          }
        }
      }
    }
  });
}
typeof b == "function" && b(v);
const x = /* @__PURE__ */ B(v, [["__scopeId", "data-v-6cf51d82"]]);
export {
  x as default
};
