import { defineComponent as h, mergeModels as C, useModel as x, ref as r, computed as y, watch as V, onBeforeMount as A, createElementBlock as p, openBlock as s, createElementVNode as M, createVNode as k, toDisplayString as I, unref as u, withCtx as w, Fragment as B, renderList as L, createBlock as S } from "vue";
import { useI18n as N } from "vue-i18n";
import { T as E, a as U } from "./start-CE9SawgU.js";
import "pinia";
import "./header-Bn1EKnBE.js";
import { t as D } from "./TaxClasses-BZyo8A_n.js";
import "./dictionary-BmJHcR-F.js";
import { t as P } from "./TreeNodeValueController-Cy6eyeVx.js";
const z = { class: "text-h6 mb-4" }, F = /* @__PURE__ */ h({
  __name: "TaxClassToTreeConfiguration",
  props: /* @__PURE__ */ C({
    attributeMap: {},
    destinationAttribute: {},
    sourceAttributes: {},
    etlAttributeSetMapId: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(o) {
    const t = o, a = x(o, "modelValue"), { t: g } = N(), d = r([]), c = r([]), i = r(!0), l = r(!0), v = y(() => i.value || l.value);
    async function T() {
      if (t.destinationAttribute?.id)
        try {
          l.value = !0;
          const e = {
            attributeId: t.destinationAttribute.id,
            scopeId: 0,
            languageId: 0
          }, m = await P.getTree(e);
          c.value = m.data.tree.children || [];
        } catch (e) {
          console.error("Loading destination tree failed:", e);
        } finally {
          l.value = !1;
        }
    }
    async function _() {
      try {
        i.value = !0;
        const e = await D.getList();
        d.value = e.data;
      } catch (e) {
        console.error("Loading tax classes failed:", e);
      } finally {
        i.value = !1;
      }
    }
    return V(
      () => t.destinationAttribute?.id,
      (e) => {
        e && T();
      },
      { immediate: !0 }
    ), A(async () => {
      await _();
    }), (!a.value || !a.value.maps) && (a.value = { maps: {} }), (e, m) => (s(), p("div", null, [
      M("h4", z, I(u(g)("pim.etl.TaxClassToTreeConfiguration.header")), 1),
      k(u(E), {
        loading: v.value,
        type: "list-item@3"
      }, {
        default: w(() => [
          (s(!0), p(B, null, L(d.value, (n) => (s(), S(u(U), {
            key: n.id,
            modelValue: a.value.maps[n.id],
            "onUpdate:modelValue": (b) => a.value.maps[n.id] = b,
            class: "mb-4",
            items: c.value,
            label: n.name,
            "item-title": "name",
            "item-value": "id"
          }, null, 8, ["modelValue", "onUpdate:modelValue", "items", "label"]))), 128))
        ]),
        _: 1
      }, 8, ["loading"])
    ]));
  }
});
function f(o) {
  const t = o;
  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 den entsprechenden Baumstrukturen zuordnen" } }
            }
          }
        }
      }
    }
  });
}
typeof f == "function" && f(F);
export {
  F as default
};
