import { defineComponent as T, createElementBlock as C, createCommentVNode as A, openBlock as N, Fragment as w, createElementVNode as f, toDisplayString as V, mergeModels as B, useModel as D, ref as s, computed as L, watch as _, createVNode as o, unref as n, withCtx as d } from "vue";
import { useI18n as M } from "vue-i18n";
import { a as m, c as g } from "./start-BYfL32Oe.mjs";
import "pinia";
import "vue-router";
import "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { t as $ } from "./TreeNodeValueController-C5jYAiH7.mjs";
import { c as O, a as F, m as R, g as q } from "./DatahubDataTypeEditor.vue_vue_type_script_setup_true_lang-WxvRaHzL.mjs";
import { T as z, _ as G } from "./TreeItemLoading.vue_vue_type_script_setup_true_lang-CjeeWuly.mjs";
const K = { class: "text-truncate" }, Y = { class: "text-truncate" }, j = /* @__PURE__ */ T({
  __name: "TreeItemTitle",
  props: {
    node: {},
    active: { type: Boolean }
  },
  setup(i) {
    return (l, u) => l.node ? (N(), C(w, { key: 0 }, [
      f("div", K, [
        f("b", null, V(l.node.title || l.node.name), 1)
      ]),
      f("div", Y, V(l.node.key), 1)
    ], 64)) : A("", !0);
  }
}), v = "datahub_translatable_title", H = [
  {
    scopable: !1,
    multilanguage: !0,
    key: v,
    name: "title",
    dataTypeInstance: {
      multilanguage: !0,
      scopable: !0,
      vueComponents: {
        configurationComponent: "datahub-data-type-configuration-string-value",
        editComponent: "datahub-data-type-string-value",
        renderComponent: "datahub-data-type-string-render"
      }
    }
  }
], J = /* @__PURE__ */ T({
  __name: "DatahubDataTypeTreeNodeValueConfiguration",
  props: /* @__PURE__ */ B({
    attribute: {},
    dataTypeInstance: {},
    remoteScopes: {},
    remoteLanguages: {},
    remoteAttributes: {},
    readonly: { type: Boolean }
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(i) {
    const l = i, u = D(i, "modelValue"), { t: y, locale: S } = M(), r = s([]), p = s(!1), c = s(!1), b = s([]), E = L(() => {
      const e = S.value.replace("-", "_");
      return {
        0: {
          // scopeId
          0: {
            // languageId
            created: F(r.value, e, v),
            modified: O(r.value, e, v),
            deleted: b.value
          }
        }
      };
    });
    function I(e) {
      c.value = !0;
      const a = {
        id: q(r.value),
        title: "",
        children: [],
        name: "",
        active: !0
      };
      return e.push(a), a;
    }
    function U({ id: e }) {
      c.value = !0, b.value.push({ id: e });
    }
    return _(
      () => {
        var e;
        return (e = l.attribute) == null ? void 0 : e.id;
      },
      async (e) => {
        if (e)
          try {
            p.value = !0;
            const { children: t } = await $.getCategoryTree({
              attributeId: e,
              languageId: 0,
              scopeId: 0,
              serializeTranslations: !0
            });
            r.value = t.map(R);
          } catch (t) {
            console.log(t.message);
          } finally {
            p.value = !1;
          }
      },
      { immediate: !0 }
    ), _(E, (e) => {
      u.value.tree = e;
    }), (e, t) => (N(), C(w, null, [
      o(n(m), null, {
        default: d(() => [
          o(n(g), {
            modelValue: u.value.readOnly,
            "onUpdate:modelValue": t[0] || (t[0] = (a) => u.value.readOnly = a),
            label: e.$t("datahub-ui.dh-table.readOnly"),
            readonly: e.readonly
          }, null, 8, ["modelValue", "label", "readonly"])
        ]),
        _: 1
      }),
      o(n(m), null, {
        default: d(() => [
          o(n(g), {
            modelValue: u.value.multiSelect,
            "onUpdate:modelValue": t[1] || (t[1] = (a) => u.value.multiSelect = a),
            label: n(y)("datahub-plugin.treeView.multiSelect"),
            readonly: e.readonly
          }, null, 8, ["modelValue", "label", "readonly"])
        ]),
        _: 1
      }),
      o(n(m), null, {
        default: d(() => [
          o(n(g), {
            modelValue: u.value.flat,
            "onUpdate:modelValue": t[2] || (t[2] = (a) => u.value.flat = a),
            label: n(y)("datahub-plugin.treeView.flat"),
            readonly: e.readonly
          }, null, 8, ["modelValue", "label", "readonly"])
        ]),
        _: 1
      }),
      o(n(m), { class: "pa-0" }, {
        default: d(() => [
          o(z, {
            modelValue: r.value,
            "onUpdate:modelValue": t[3] || (t[3] = (a) => r.value = a),
            "remote-scopes": e.remoteScopes,
            "remote-languages": e.remoteLanguages,
            "remote-attributes": n(H),
            "max-level": u.value.flat ? 1 : 1 / 0,
            loading: p.value,
            "create-item": I,
            readonly: e.readonly,
            class: "group-tree-view",
            onUpdated: t[4] || (t[4] = (a) => c.value = !0),
            onDelete: U
          }, {
            "item-loading": d(() => [
              o(G)
            ]),
            "item-title": d(({ node: a, active: k }) => [
              o(j, {
                node: a,
                active: k
              }, null, 8, ["node", "active"])
            ]),
            _: 1
          }, 8, ["modelValue", "remote-scopes", "remote-languages", "remote-attributes", "max-level", "loading", "readonly"])
        ]),
        _: 1
      })
    ], 64));
  }
});
function h(i) {
  const l = i;
  l.__i18n = l.__i18n || [], l.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "datahub-plugin": {
          treeView: {
            flat: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Flat" } },
            multiSelect: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Multi select" } }
          }
        }
      },
      "de-DE": {
        "datahub-plugin": {
          treeView: {
            flat: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Flach" } },
            multiSelect: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Mehrfachauswahl" } }
          }
        }
      }
    }
  });
}
typeof h == "function" && h(J);
export {
  J as default
};
