import { defineComponent as b, mergeModels as C, useModel as x, ref as r, computed as y, watch as V, onBeforeMount as A, createElementBlock as p, openBlock as u, createElementVNode as M, createVNode as k, toDisplayString as I, unref as d, withCtx as w, Fragment as B, renderList as L, createBlock as N } from "vue";
import { useI18n as S } from "vue-i18n";
import { R as E, h as U } from "./start-BYfL32Oe.mjs";
import "pinia";
import "vue-router";
import "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { t as z } from "./TaxClasses-BY8s9nMy.mjs";
import "./dictionary-TYJ-09MM.mjs";
import { t as D } from "./TreeNodeValueController-C5jYAiH7.mjs";
const P = { class: "text-h6 mb-4" }, F = /* @__PURE__ */ b({
  __name: "TaxClassToTreeConfiguration",
  props: /* @__PURE__ */ C({
    attributeMap: {},
    destinationAttribute: {},
    sourceAttributes: {},
    etlAttributeSetMapId: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(n) {
    const t = n, o = x(n, "modelValue"), { t: g } = S(), c = r([]), m = r([]), l = r(!0), s = r(!0), v = y(() => l.value || s.value);
    async function T() {
      var e;
      if ((e = t.destinationAttribute) != null && e.id)
        try {
          s.value = !0;
          const i = {
            attributeId: t.destinationAttribute.id,
            scopeId: 0,
            languageId: 0
          }, a = await D.getTree(i);
          m.value = a.data.tree.children || [];
        } catch (i) {
          console.error("Loading destination tree failed:", i);
        } finally {
          s.value = !1;
        }
    }
    async function h() {
      try {
        l.value = !0;
        const e = await z.getList();
        c.value = e.data;
      } catch (e) {
        console.error("Loading tax classes failed:", e);
      } finally {
        l.value = !1;
      }
    }
    return V(
      () => {
        var e;
        return (e = t.destinationAttribute) == null ? void 0 : e.id;
      },
      (e) => {
        e && T();
      },
      { immediate: !0 }
    ), A(async () => {
      await h();
    }), (!o.value || !o.value.maps) && (o.value = { maps: {} }), (e, i) => (u(), p("div", null, [
      M("h4", P, I(d(g)("pim.etl.TaxClassToTreeConfiguration.header")), 1),
      k(d(E), {
        loading: v.value,
        type: "list-item@3"
      }, {
        default: w(() => [
          (u(!0), p(B, null, L(c.value, (a) => (u(), N(d(U), {
            key: a.id,
            modelValue: o.value.maps[a.id],
            "onUpdate:modelValue": (_) => o.value.maps[a.id] = _,
            class: "mb-4",
            items: m.value,
            label: a.name,
            "item-title": "name",
            "item-value": "id"
          }, null, 8, ["modelValue", "onUpdate:modelValue", "items", "label"]))), 128))
        ]),
        _: 1
      }, 8, ["loading"])
    ]));
  }
});
function f(n) {
  const t = n;
  t.__i18n = t.__i18n || [], t.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        pim: {
          etl: {
            TaxClassToTreeConfiguration: {
              header: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Map PIM-tax-classes to corresponding Tree Nodes" } }
            }
          }
        }
      },
      "de-DE": {
        pim: {
          etl: {
            TaxClassToTreeConfiguration: {
              header: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "PIM-Steuerklassen zu entsprechenden Baumknoten zuordnen" } }
            }
          }
        }
      }
    }
  });
}
typeof f == "function" && f(F);
export {
  F as default
};
