import { defineComponent as g, mergeModels as v, useModel as c, computed as _, watch as U, onBeforeMount as I, createElementBlock as D, openBlock as h, Fragment as $, createVNode as i, unref as n, withCtx as u } from "vue";
import { useI18n as S } from "vue-i18n";
import { storeToRefs as T } from "pinia";
import { c as d, a as p, e as B } from "./start-CE9SawgU.js";
import "./header-Bn1EKnBE.js";
import { u as C } from "./dataTypes-DocW2t0g.js";
const M = /* @__PURE__ */ g({
  __name: "DatahubDataTypeUnitValueConfiguration",
  props: /* @__PURE__ */ v({
    attribute: {},
    dataTypeInstance: {},
    remoteScopes: {},
    remoteLanguages: {},
    remoteAttributes: {},
    readonly: { type: Boolean }
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(o) {
    const e = c(o, "modelValue"), { t: s } = S(), m = C(), { dimensions: r, isDimensionsLoading: f } = T(m), y = _(() => {
      const a = r.value.find(
        ({ id: t }) => t === e.value.dimensionId
      );
      return a ? a.units.map(({ id: t, name: l, symbol: V }) => ({
        id: t,
        title: `${l} (${V})`
      })) : [];
    });
    return U(
      () => e.value.dimensionId,
      () => {
        e.value.defaultUnitId = void 0;
      },
      { immediate: !0 }
    ), I(m.ensureDimensions), (a, t) => (h(), D($, null, [
      i(n(d), null, {
        default: u(() => [
          i(n(p), {
            modelValue: e.value.dimensionId,
            "onUpdate:modelValue": t[0] || (t[0] = (l) => e.value.dimensionId = l),
            items: n(r),
            loading: n(f),
            label: n(s)("datahub-plugin.unitValue.dimension"),
            readonly: a.readonly,
            "item-title": "name",
            "item-value": "id"
          }, null, 8, ["modelValue", "items", "loading", "label", "readonly"])
        ]),
        _: 1
      }),
      i(n(d), null, {
        default: u(() => [
          i(n(p), {
            modelValue: e.value.defaultUnitId,
            "onUpdate:modelValue": t[1] || (t[1] = (l) => e.value.defaultUnitId = l),
            items: y.value,
            loading: n(f),
            disabled: !e.value.dimensionId,
            label: n(s)("datahub-plugin.unitValue.defaultUnit"),
            readonly: a.readonly,
            "item-value": "id"
          }, null, 8, ["modelValue", "items", "loading", "disabled", "label", "readonly"])
        ]),
        _: 1
      }),
      i(n(d), null, {
        default: u(() => [
          i(n(B), {
            modelValue: e.value.readOnly,
            "onUpdate:modelValue": t[2] || (t[2] = (l) => e.value.readOnly = l),
            label: a.$t("datahub-ui.dh-table.readOnly"),
            readonly: a.readonly
          }, null, 8, ["modelValue", "label", "readonly"])
        ]),
        _: 1
      })
    ], 64));
  }
});
function b(o) {
  const e = o;
  e.__i18n = e.__i18n || [], e.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "datahub-plugin": {
          unitValue: {
            dimension: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Dimension" } },
            defaultUnit: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Default unit" } }
          }
        }
      },
      "de-DE": {
        "datahub-plugin": {
          unitValue: {
            dimension: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Dimension" } },
            defaultUnit: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Standardeinheit" } }
          }
        }
      }
    }
  });
}
typeof b == "function" && b(M);
export {
  M as default
};
