import { ref as v, defineComponent as M, mergeModels as k, useModel as D, watch as g, createElementBlock as p, openBlock as m, createVNode as c, renderSlot as C, unref as a, Fragment as b, createCommentVNode as w, renderList as N, createBlock as E } from "vue";
import { useI18n as U } from "vue-i18n";
import { o as L, c as V, h as _ } from "./start-BYfL32Oe.mjs";
import "pinia";
import "vue-router";
import "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { B } from "./base-CZBAM3Up.mjs";
const z = `${B}VariantToVariant.`, $ = {
  /** Return variant sets in source and destination set */
  async listDestinationAndSourceSets(r) {
    return L.post(`${z}listDestinationAndSourceSets`, {
      etlAttributeSetMapId: r
    });
  }
}, S = {}, T = () => {
  const r = v([]), l = v([]), t = v(!1);
  async function o(s) {
    if (s) {
      if (S[s]) {
        const { sourceVariantSets: i = [], destinationVariantSets: u = [] } = await S[s];
        return this.sourceVariantSets = i, this.destinationVariantSets = u, { sourceVariantSets: i, destinationVariantSets: u };
      }
      try {
        t.value = !0, S[s] = $.listDestinationAndSourceSets(s);
        const { sourceVariantSets: i = [], destinationVariantSets: u = [] } = await S[s];
        return this.sourceVariantSets = i, this.destinationVariantSets = u, { sourceVariantSets: i, destinationVariantSets: u };
      } catch (i) {
        console.log(i.message);
      } finally {
        t.value = !1;
      }
    }
  }
  return {
    sourceVariantSets: r,
    destinationVariantSets: l,
    isVariantSetsLoading: t,
    fetchVariantSet: o
  };
}, x = /* @__PURE__ */ M({
  __name: "VariantToVariantExtension",
  props: /* @__PURE__ */ k({
    attributeMap: {},
    destinationAttribute: {},
    sourceAttributes: {},
    etlAttributeSetMapId: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(r) {
    const l = r, t = D(r, "modelValue"), { t: o } = U(), {
      sourceVariantSets: s,
      destinationVariantSets: i,
      isVariantSetsLoading: u,
      fetchVariantSet: h
    } = T();
    return g(
      t,
      (d) => {
        d || (t.value = {});
      },
      { immediate: !0 }
    ), g(
      () => l.etlAttributeSetMapId,
      async (d) => {
        t.value = {
          ...t.value,
          autocreateChildren: t.value.autocreateChildren ?? !0,
          automapVariantSets: t.value.automapVariantSets ?? !0,
          autocreateVariantSet: t.value.autocreateVariantSet ?? !0,
          addNotMappedDefiningAttributesAndAutomap: t.value.addNotMappedDefiningAttributesAndAutomap ?? !0,
          autosyncVariantSet: t.value.autosyncVariantSet ?? !0,
          variantSetMapping: t.value.variantSetMapping ?? []
        }, d && await h(d);
      },
      { immediate: !0 }
    ), (d, n) => (m(), p("div", null, [
      c(a(V), {
        modelValue: t.value.autocreateChildren,
        "onUpdate:modelValue": n[0] || (n[0] = (e) => t.value.autocreateChildren = e),
        label: a(o)("datahub-plugin.etl.variant-to-variant.AutocreateChildren"),
        class: "mb-2"
      }, null, 8, ["modelValue", "label"]),
      c(a(V), {
        modelValue: t.value.automapVariantSets,
        "onUpdate:modelValue": n[1] || (n[1] = (e) => t.value.automapVariantSets = e),
        label: a(o)("datahub-plugin.etl.variant-to-variant.automapVariantSets"),
        class: "mb-2"
      }, null, 8, ["modelValue", "label"]),
      t.value.automapVariantSets ? (m(), p(b, { key: 0 }, [
        c(a(V), {
          modelValue: t.value.autocreateVariantSet,
          "onUpdate:modelValue": n[2] || (n[2] = (e) => t.value.autocreateVariantSet = e),
          label: a(o)("datahub-plugin.etl.variant-to-variant.autocreateVariantSet"),
          class: "mb-2"
        }, null, 8, ["modelValue", "label"]),
        c(a(V), {
          modelValue: t.value.addNotMappedDefiningAttributesAndAutomap,
          "onUpdate:modelValue": n[3] || (n[3] = (e) => t.value.addNotMappedDefiningAttributesAndAutomap = e),
          label: a(o)(
            "datahub-plugin.etl.variant-to-variant.addNotMappedDefiningAttributesAndAutomap"
          ),
          class: "mb-2"
        }, null, 8, ["modelValue", "label"])
      ], 64)) : (m(), p(b, { key: 1 }, [
        c(a(V), {
          modelValue: t.value.autosyncVariantSet,
          "onUpdate:modelValue": n[4] || (n[4] = (e) => t.value.autosyncVariantSet = e),
          label: a(o)("datahub-plugin.etl.variant-to-variant.autosyncVariantSet"),
          class: "mb-2"
        }, null, 8, ["modelValue", "label"]),
        t.value.variantSetMapping ? (m(!0), p(b, { key: 0 }, N(a(s), (e, f) => (m(), E(a(_), {
          key: e.id,
          modelValue: t.value.variantSetMapping[f],
          "onUpdate:modelValue": (y) => t.value.variantSetMapping[f] = y,
          items: a(i),
          loading: a(u),
          label: a(o)("datahub-plugin.etl.variant-to-variant.SourceVariantSetLabel", {
            name: e.name
          }),
          "item-title": "name",
          "item-value": "id",
          "persistent-placeholder": "",
          class: "mb-2"
        }, null, 8, ["modelValue", "onUpdate:modelValue", "items", "loading", "label"]))), 128)) : w("", !0)
      ], 64)),
      C(d.$slots, "default")
    ]));
  }
});
function A(r) {
  const l = r;
  l.__i18n = l.__i18n || [], l.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "datahub-plugin": {
          etl: {
            "variant-to-variant": {
              AutocreateChildren: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Automatically generate all child entities when main entity is created" } },
              automapVariantSets: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Automatically map variant sets" } },
              autocreateVariantSet: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Automatically create variant set if no suiting variant set can be found" } },
              addNotMappedDefiningAttributesAndAutomap: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Automatically add not mapped defining attributes to destination set when creating variant set" } },
              autosyncVariantSet: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Sync variant set in case they do not match to each other" } },
              SourceVariantSetLabel: { t: 0, b: { t: 2, i: [{ t: 3, v: "Source variant sets " }, { t: 4, k: "name" }] } }
            }
          }
        }
      },
      "de-DE": {
        "datahub-plugin": {
          etl: {
            "variant-to-variant": {
              AutocreateChildren: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Erzeuge automatisch alle Kind-Entitäten, wenn die Hauptentität erstellt wird" } },
              automapVariantSets: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Varianten-Sets automatisch abbilden" } },
              autocreateVariantSet: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Automatisch ein Variantenset erstellen, wenn kein passendes Variantenset gefunden werden kann" } },
              addNotMappedDefiningAttributesAndAutomap: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Nicht zugeordnete definierende Attribute bei der Erstellung eines Variantensets automatisch zum Zielset hinzufügen" } },
              autosyncVariantSet: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "VariantSet synchronisieren, falls sie nicht zueinander passen" } },
              SourceVariantSetLabel: { t: 0, b: { t: 2, i: [{ t: 3, v: "Quellvarianten-Sets " }, { t: 4, k: "name" }] } }
            }
          }
        }
      }
    }
  });
}
typeof A == "function" && A(x);
export {
  x as default
};
