import { defineComponent as b, createElementBlock as h, openBlock as _, createVNode as l, renderSlot as A, unref as o, createCommentVNode as L, Fragment as N, createElementVNode as f, toDisplayString as w, mergeModels as B, useModel as D, ref as s, computed as M, watch as C, withCtx as d } from "vue";
import { useI18n as O } from "vue-i18n";
import { p as g, c as m, e as v } from "./start-CE9SawgU.js";
import "pinia";
import "./header-Bn1EKnBE.js";
import { t as F } from "./TreeNodeValueController-Cy6eyeVx.js";
import { c as R, a as q, m as z, g as G } from "./DatahubDataTypeEditor.vue_vue_type_script_setup_true_lang-Blx83HK-.js";
import { T as K } from "./TreeView-1HXwLCV9.js";
const Y = { class: "d-flex align-center my-2" }, j = /* @__PURE__ */ b({
  __name: "TreeItemLoading",
  setup(u) {
    return (n, r) => (_(), h("div", Y, [
      l(o(g), {
        type: "icon",
        width: "24",
        height: "24",
        class: "mr-3"
      }),
      l(o(g), {
        width: "380",
        height: "60",
        class: "mr-3"
      }),
      l(o(g), {
        type: "icon",
        width: "24",
        height: "24"
      }),
      A(n.$slots, "default")
    ]));
  }
}), H = { class: "text-truncate" }, J = { class: "text-truncate" }, P = /* @__PURE__ */ b({
  __name: "TreeItemTitle",
  props: {
    node: {},
    active: { type: Boolean }
  },
  setup(u) {
    return (n, r) => n.node ? (_(), h(N, { key: 0 }, [
      f("div", H, [
        f("b", null, w(n.node.title || n.node.name), 1)
      ]),
      f("div", J, w(n.node.key), 1)
    ], 64)) : L("", !0);
  }
}), y = "datahub_translatable_title", Q = [
  {
    scopable: !1,
    multilanguage: !0,
    key: y,
    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"
      }
    }
  }
], W = /* @__PURE__ */ b({
  __name: "DatahubDataTypeTreeNodeValueConfiguration",
  props: /* @__PURE__ */ B({
    attribute: {},
    dataTypeInstance: {},
    remoteScopes: {},
    remoteLanguages: {},
    remoteAttributes: {},
    readonly: { type: Boolean }
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(u) {
    const n = u, r = D(u, "modelValue"), { t: V, locale: E } = O(), i = s([]), c = s(!1), p = s(!1), T = s([]), I = M(() => {
      const e = E.value.replace("-", "_");
      return {
        0: {
          // scopeId
          0: {
            // languageId
            created: q(i.value, e, y),
            modified: R(i.value, e, y),
            deleted: T.value
          }
        }
      };
    });
    function U(e) {
      p.value = !0;
      const a = {
        id: G(i.value),
        title: "",
        children: [],
        name: "",
        active: !0
      };
      return e.push(a), a;
    }
    function $({ id: e }) {
      p.value = !0, T.value.push({ id: e });
    }
    return C(
      () => n.attribute?.id,
      async (e) => {
        if (e)
          try {
            c.value = !0;
            const { children: t } = await F.getCategoryTree({
              attributeId: e,
              languageId: 0,
              scopeId: 0,
              serializeTranslations: !0
            });
            i.value = t.map(z);
          } catch (t) {
            console.log(t.message);
          } finally {
            c.value = !1;
          }
      },
      { immediate: !0 }
    ), C(I, (e) => {
      r.value.tree = e;
    }), (e, t) => (_(), h(N, null, [
      l(o(m), null, {
        default: d(() => [
          l(o(v), {
            modelValue: r.value.readOnly,
            "onUpdate:modelValue": t[0] || (t[0] = (a) => r.value.readOnly = a),
            label: e.$t("datahub-ui.dh-table.readOnly"),
            readonly: e.readonly
          }, null, 8, ["modelValue", "label", "readonly"])
        ]),
        _: 1
      }),
      l(o(m), null, {
        default: d(() => [
          l(o(v), {
            modelValue: r.value.multiSelect,
            "onUpdate:modelValue": t[1] || (t[1] = (a) => r.value.multiSelect = a),
            label: o(V)("datahub-plugin.treeView.multiSelect"),
            readonly: e.readonly
          }, null, 8, ["modelValue", "label", "readonly"])
        ]),
        _: 1
      }),
      l(o(m), null, {
        default: d(() => [
          l(o(v), {
            modelValue: r.value.flat,
            "onUpdate:modelValue": t[2] || (t[2] = (a) => r.value.flat = a),
            label: o(V)("datahub-plugin.treeView.flat"),
            readonly: e.readonly
          }, null, 8, ["modelValue", "label", "readonly"])
        ]),
        _: 1
      }),
      l(o(m), { class: "pa-0" }, {
        default: d(() => [
          l(K, {
            modelValue: i.value,
            "onUpdate:modelValue": t[3] || (t[3] = (a) => i.value = a),
            "remote-scopes": e.remoteScopes,
            "remote-languages": e.remoteLanguages,
            "remote-attributes": o(Q),
            "max-level": r.value.flat ? 1 : 1 / 0,
            loading: c.value,
            "create-item": U,
            readonly: e.readonly,
            class: "group-tree-view",
            onUpdated: t[4] || (t[4] = (a) => p.value = !0),
            onDelete: $
          }, {
            "item-loading": d(() => [
              l(j)
            ]),
            "item-title": d(({ node: a, active: k }) => [
              l(P, {
                node: a,
                active: k
              }, null, 8, ["node", "active"])
            ]),
            _: 1
          }, 8, ["modelValue", "remote-scopes", "remote-languages", "remote-attributes", "max-level", "loading", "readonly"])
        ]),
        _: 1
      })
    ], 64));
  }
});
function S(u) {
  const n = u;
  n.__i18n = n.__i18n || [], n.__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 S == "function" && S(W);
export {
  W as default
};
