import { h as A, defineComponent as f, mergeModels as h, useModel as C, computed as b, createBlock as E, createCommentVNode as D, openBlock as g, unref as v, mergeProps as M } from "vue";
import { D as u } from "./constants-CwfsvyFM.mjs";
import { useI18n as _ } from "vue-i18n";
import { h as $ } from "./moment-h96o7c8I.mjs";
import { z as P, C as F } from "./start-BYfL32Oe.mjs";
import "pinia";
import "vue-router";
import { N as V, S as N } from "./header-Droxy2Kd.mjs";
function x(e) {
  var t;
  return e.sourceType !== N.EMPTY ? ((t = e.sourceAttribute) == null ? void 0 : t.name) ?? e.sourceNativeField : e.sourceDataTypeInstance ? _().t("datahub-ui.etl.constValueDataType", {
    value: e.sourceDataTypeInstance.name
  }) : "";
}
function W(e) {
  var t, o;
  return !e.sourceLanguage && !e.sourceScope ? "" : ` ( ${[(t = e.sourceLanguage) == null ? void 0 : t.description, (o = e.sourceScope) == null ? void 0 : o.name].filter(Boolean).join(" / ")} )`;
}
function q(e) {
  return !(e != null && e.destinationLanguage) && !(e != null && e.destinationScope) ? "" : ` ( ${[e.destinationLanguage.description, e.destinationScope.name].filter(Boolean).join(" / ")} )`;
}
const w = (e) => `${e.sourceEntityType.name} (${e.sourceEntityFriendlyIdentifier}) -> ${e.destinationEntityType.name} (${e.destinationEntityFriendlyIdentifier})`, H = (e) => e.etlAttributeMap.sourcePorts ? e.etlAttributeMap.sourcePorts.map(({ sourceType: t, sourceAttribute: o, sourceNativeField: r }) => {
  switch (t) {
    case 0:
      return o.name;
    case 2:
      return _().t("datahub-ui.shared.constantValue");
    default:
      return r;
  }
}).join(", ") : "", z = (e) => {
  switch (e.etlAttributeMap.destinationType) {
    case 0:
      return e.etlAttributeMap.destinationAttribute.name;
    case 1:
      return e.etlAttributeMap.destinationNativeField;
    default:
      return "";
  }
}, O = (e, t) => {
  var o;
  return {
    ...e,
    title: e.title || e.name,
    children: (o = e.children) == null ? void 0 : o.map(O),
    sortOrder: t
  };
}, K = (e) => Math.min(
  0,
  ...e.flatMap(({ id: t, children: o = [] }) => [
    t,
    ...o.map((r) => r.id)
  ])
) - 1, d = (e, t) => (o, r) => {
  var i;
  return {
    ...o,
    title: o[t],
    name: o[t],
    parent_id: e,
    active: !0,
    sortOrder: r,
    children: (i = o.children) == null ? void 0 : i.map(d(o.id, t))
  };
}, J = (e, t = "de-DE", o = V) => {
  const r = `_${o}__${t}`;
  return e.reduce((i, n, s) => {
    var m, c;
    if (Number(n.id) < 0) {
      const a = d(n.id, r), l = {
        ...n,
        title: n[r],
        name: n[r],
        sortOrder: s,
        children: (m = n.children) == null ? void 0 : m.map(a)
      };
      i.push(l);
    } else (c = n.children) != null && c.length && n.children.forEach((a, l) => {
      if (Number(a.id) < 0) {
        const p = {
          ...a,
          title: a[r],
          name: a[r],
          parent_id: n.id,
          active: !0,
          sortOrder: l
        };
        i.push(p);
      }
    });
    return i;
  }, []);
}, Q = (e, t = "de-DE", o = V) => {
  const r = `_${o}__${t}`;
  return e.reduce((i, n, s) => {
    var m, c;
    if (Number(n.id) < 0)
      return i;
    if (n.updated || s !== n.sortOrder) {
      const a = d(Number(n.id), r), l = {
        ...n,
        title: n[r],
        name: n[r],
        sortOrder: s,
        children: (m = n.children) == null ? void 0 : m.map(a)
      };
      i.push(l);
    } else (c = n.children) != null && c.length && n.children.forEach((a, l) => {
      if (Number(a.id) >= 0 && (a.updated || l !== a.sortOrder)) {
        const p = {
          ...a,
          title: a[r],
          name: a[r],
          id: a.id,
          parent_id: n.id,
          sortOrder: l,
          active: !0
        };
        i.push(p);
      }
    });
    return i;
  }, []);
}, y = (e, t) => {
  var o, r, i, n;
  if (!e)
    return null;
  if (e.vueComponents)
    switch (t) {
      case u.CONFIG:
        return {
          name: e.vueComponents.configurationComponent,
          url: e.vueComponents.configurationImportPath
        };
      case u.VALUE:
        return {
          name: e.vueComponents.editComponent,
          url: e.vueComponents.editImportPath
        };
      case u.ETL_CONFIG:
        return {
          name: e.vueComponents.etlComponent,
          url: e.vueComponents.etlImportPath
        };
      case u.RENDER:
      default:
        return {
          name: e.vueComponents.renderComponent,
          url: e.vueComponents.renderImportPath
        };
    }
  switch (console.error(
    "==> FAILED in getExternalComponentConfig",
    t,
    e
  ), t) {
    case u.CONFIG:
      return {
        name: e.configurationWebComponent,
        url: e.configurationImport
      };
    case u.VALUE:
      return {
        name: e.valueEditWebComponent,
        url: e.valueEditHtmlImport
      };
    case u.ETL_CONFIG:
      return {
        name: (o = e.vueComponents) == null ? void 0 : o.etlComponent,
        url: (r = e.vueComponents) == null ? void 0 : r.etlImportPath
      };
    case u.RENDER:
    default:
      return {
        name: (i = e.render) == null ? void 0 : i.component,
        url: (n = e.render) == null ? void 0 : n.importPath
      };
  }
}, U = (e) => e.name ? F(e) : A(P, { error: e.url, name: e.name }), X = (e, t) => e ? e[t.key] ?? e[t.id] ?? Object.values(e)[0] : "", Z = (e) => e ? e[0].toUpperCase() : "", ee = (e) => `child-group-${e}`, S = (e) => e.endsWith(".") ? e : `${e}.`, te = (e, t) => `${S(e)}${t}`, ne = (e, t = "YYYY-MM-DD hh:mm:ss") => e ? $.unix(e).format(t) : null, B = /* @__PURE__ */ f({
  __name: "DatahubExternalComponent",
  props: /* @__PURE__ */ h({
    dataTypeInstance: {},
    type: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(e) {
    const t = e, o = C(e, "modelValue"), r = b(
      () => t.dataTypeInstance ? U(
        y(t.dataTypeInstance, t.type)
      ) : null
    );
    return (i, n) => r.value ? (g(), E(v(r), {
      key: 0,
      modelValue: o.value,
      "onUpdate:modelValue": n[0] || (n[0] = (s) => o.value = s),
      "data-type-instance": i.dataTypeInstance
    }, null, 8, ["modelValue", "data-type-instance"])) : D("", !0);
  }
}), oe = /* @__PURE__ */ f({
  __name: "DatahubDataTypeEditor",
  props: /* @__PURE__ */ h({
    modelValue: {},
    readOnly: { type: Boolean },
    attribute: {},
    massEditing: { type: Boolean },
    label: {},
    fieldName: {},
    dataTypeInstance: {},
    loading: { type: Boolean }
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(e) {
    const t = e, o = C(e, "modelValue");
    return (r, i) => (g(), E(B, M({
      modelValue: o.value,
      "onUpdate:modelValue": i[0] || (i[0] = (n) => o.value = n),
      type: v(u).VALUE
    }, t), null, 16, ["modelValue", "type"]));
  }
});
export {
  oe as _,
  J as a,
  Z as b,
  Q as c,
  ee as d,
  te as e,
  B as f,
  K as g,
  w as h,
  ne as i,
  y as j,
  X as k,
  U as l,
  O as m,
  x as n,
  W as o,
  q as p,
  H as s,
  z as t
};
