import { defineComponent as L, computed as c, watch as U, createBlock as v, openBlock as y, unref as e, withCtx as u, createCommentVNode as $, createVNode as D, createTextVNode as N, toDisplayString as _, mergeProps as x } from "vue";
import { useI18n as S } from "vue-i18n";
import { storeToRefs as k } from "pinia";
import { aa as V, ac as F, E as I, a7 as d, V as G, W as H, a3 as M, a9 as Y } from "./start-BYfL32Oe.mjs";
import { useRouter as j } from "vue-router";
import "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { c as W, j as m, R as O, I as z, T as E } from "./topBarRoutes-0VuQ_i6D.mjs";
import { k as R } from "./DatahubDataTypeEditor.vue_vue_type_script_setup_true_lang-WxvRaHzL.mjs";
import { _ as q } from "./EditBasicView.vue_vue_type_script_setup_true_lang-QSOZn7cj.mjs";
const J = /* @__PURE__ */ L({
  __name: "EditView",
  props: {
    id: {},
    pluginName: {}
  },
  setup(t) {
    const l = t, { locale: o, t: A } = S(), T = j(), h = W(l.pluginName), { languages: g, selectedDeletedAttribute: n } = k(
      h
    ), { isLoading: b, showError: f, onAddRow: r, onDeleteRows: p } = V({
      addApi: m.recoverDeletedAttributes,
      deleteApi: m.delete
    }), a = c(
      () => g.value.find(({ key: i }) => i === o.value) ?? {
        key: o.value,
        id: 0
      }
    ), s = c(
      () => `${A("datahub-ui.deletedAttributes.deletedAttribute")}: ${n.value ? R(n.value.name, a.value) : ""}`
    );
    function w() {
      T.push({ name: O.DELETED_ATTRIBUTES });
    }
    async function B() {
      await r([Number(l.id)]), f.value || w();
    }
    async function P() {
      await p([Number(l.id)]), f.value || w();
    }
    return U(
      () => l.id,
      async (i) => {
        i && await h.fetchDeletedAttribute(i);
      },
      { immediate: !0 }
    ), (i, Q) => (y(), v(e(F), null, {
      "toolbar-title": u(() => [
        N(_(s.value), 1)
      ]),
      "toolbar-actions": u(() => [
        D(e(I), {
          text: i.$t("datahub-ui.shared.deletePermanently"),
          disabled: e(b),
          "prepend-icon": "delete",
          color: "alert",
          onClick: P
        }, null, 8, ["text", "disabled"]),
        D(e(I), {
          text: i.$t("datahub-ui.deletedAttributes.recover"),
          disabled: e(b),
          variant: "elevated",
          color: "primary",
          onClick: B
        }, null, 8, ["text", "disabled"])
      ]),
      default: u(() => {
        var C;
        return [
          ((C = e(n)) == null ? void 0 : C.id) === Number(i.id) ? (y(), v(q, {
            key: 0,
            id: Number(i.id),
            attribute: e(n),
            "plugin-name": i.pluginName,
            readonly: ""
          }, null, 8, ["id", "attribute", "plugin-name"])) : $("", !0)
        ];
      }),
      _: 1
    }));
  }
}), K = {
  data: m.getList,
  gridId: "datahub-deleted-attributes",
  rowSelection: H.MULTI,
  hideGlobalSearch: !1,
  hideFilters: !1,
  hideColumnCustomization: !1,
  hidePagination: !1,
  sortType: G.SINGLE,
  routableId: "deletedAttributeId",
  routable: O.DELETED_ATTRIBUTES,
  createActions: !1,
  exactRowCount: !1,
  tableActions: [
    {
      title: "datahub-ui.deletedAttributes.recover",
      variant: "elevated",
      color: "primary",
      event: E.RECOVER,
      prepareIsDisabled: ({ selectedRows: t }) => c(() => !t.value.length)
    },
    {
      icon: "delete",
      title: "datahub-ui.shared.deletePermanently",
      color: "alert",
      event: E.DELETE,
      prepareIsDisabled: ({ selectedRows: t }) => c(() => !t.value.length)
    }
  ],
  columns: [
    {
      id: "id",
      header: "common.id",
      isVisible: !1,
      minWidth: 200,
      filterable: d.NUMERIC,
      sortable: !0
    },
    {
      id: "active",
      header: "datahub-ui.dh-table.status",
      renderer: "IsActiveStatusCell",
      minWidth: 100,
      width: 150,
      ...z,
      sortable: !0
    },
    {
      id: "renderFriendlyName",
      header: "datahub-ui.dh-table.name",
      minWidth: 200,
      filterable: !1,
      sortable: !1
    },
    {
      id: "key",
      header: "datahub-ui.dh-table.key",
      minWidth: 200,
      filterable: d.STRING,
      sortable: !0
    },
    {
      id: "renderFriendlyDescription",
      header: "datahub-ui.dh-table.description",
      minWidth: 200,
      filterable: !1,
      sortable: !1
    },
    {
      id: "dataType",
      header: "datahub-ui.dh-table.dataType",
      minWidth: 200,
      accessor: ({ dataTypeInstance: t, dataType: l }) => (t == null ? void 0 : t.name) ?? l,
      filterable: d.STRING,
      sortable: !0
    },
    {
      id: "readOnly",
      header: "datahub-ui.dh-table.readOnly",
      renderer: "CheckboxCell",
      minWidth: 200,
      filterable: d.BOOLEAN,
      sortable: !0
    },
    {
      id: "multilanguage",
      header: "datahub-ui.dh-table.multiLanguage",
      renderer: "CheckboxCell",
      minWidth: 200,
      filterable: d.BOOLEAN,
      sortable: !0
    },
    {
      id: "ownerPluginName",
      header: "datahub-ui.dh-table.ownerPluginName",
      minWidth: 200,
      filterable: !1,
      sortable: !1
    },
    {
      id: "created",
      header: "datahub-ui.dh-table.created",
      minWidth: 200,
      filterable: d.DATE,
      sortable: !0
    },
    {
      id: "createdByUsername",
      header: "datahub-ui.dh-table.createdByUsername",
      minWidth: 200,
      isVisible: !1,
      filterable: !1,
      sortable: !1
    },
    {
      id: "modified",
      header: "datahub-ui.dh-table.modified",
      minWidth: 200,
      isVisible: !1,
      filterable: d.DATE,
      sortable: !0
    },
    {
      id: "modifiedByUsername",
      header: "datahub-ui.dh-table.modifiedByUsername",
      minWidth: 200,
      isVisible: !1,
      filterable: !1,
      sortable: !1
    }
  ]
}, ne = /* @__PURE__ */ L({
  __name: "DeletedAttributesView",
  props: {
    pluginName: {}
  },
  setup(t) {
    const l = t, { locale: o } = S(), { table: A, isLoading: T, onEditRow: h, onDeleteRows: g } = V({
      editApi: m.recoverDeletedAttributes,
      deleteApi: m.delete
    }), { languages: n } = k(W(l.pluginName)), b = c(
      () => n.value.find(({ key: r }) => r === o.value) ?? {
        key: o.value,
        id: 0
      }
    );
    async function f(r, p, a) {
      const s = Y(p);
      switch (r) {
        case E.DELETE:
          await g(s);
          break;
        case E.RECOVER:
          h(s);
          break;
      }
      a && a();
    }
    return (r, p) => (y(), v(e(M), x({
      ref_key: "table",
      ref: A,
      key: e(o),
      "disable-actions": e(T)
    }, e(K), { onAction: f }), {
      "cell-renderFriendlyName": u(({ cellValue: a }) => [
        N(_(e(R)(a, b.value)), 1)
      ]),
      "cell-renderFriendlyDescription": u(({ cellValue: a }) => [
        N(_(e(R)(a, b.value)), 1)
      ]),
      details: u(({ rowId: a, close: s }) => [
        D(J, {
          id: Number(a),
          "plugin-name": r.pluginName,
          onClose: s
        }, null, 8, ["id", "plugin-name", "onClose"])
      ]),
      _: 1
    }, 16, ["disable-actions"]));
  }
});
export {
  ne as default
};
