import { _ as __nuxt_component_0 } from './nuxt-link-CtTcnFKy.mjs';
import { _ as _export_sfc, d as defineNuxtComponent, r as ATitle, g as APagination, q as ASearch, t as AEntityDelete, I as ARealms, b as useAuthStore, s as storeToRefs$1, P as PermissionName } from '../server.mjs';
import { VCTimeago } from '@vuecs/timeago';
import { BTable } from 'bootstrap-vue-next';
import { i as isRealmResourceWritable } from './utils-CfT4uBfw.mjs';
import { useSSRContext, resolveComponent, mergeProps, withCtx, createVNode, openBlock, createBlock, withModifiers, createCommentVNode } from 'vue';
import { ssrRenderComponent } from 'vue/server-renderer';
import '../../nitro/node-server.mjs';
import 'node:http';
import 'node:https';
import 'fs';
import 'path';
import 'node:fs';
import 'node:url';
import 'unhead';
import '@unhead/shared';
import 'vue-router';
import '@ebec/http/core';
import 'hapic';
import '@hapic/oauth2';
import 'rapiq';
import '@hapic/vault';
import '@vuecs/navigation';
import 'change-case';
import '@vuecs/list-controls/core';
import 'smob';
import '@vuecs/list-controls';
import 'ilingo';
import '@vuelidate/validators';
import '@vuelidate/core';
import 'nanoid';
import '@vuecs/form-controls';
import '@vuecs/pagination';
import '@ucast/mongo2js';
import '@vuecs/preset-bootstrap-v5';
import '@vuecs/preset-font-awesome';
import '@vuecs/countdown';
import '@vuecs/form-controls/core';
import 'browser-storage-adapter';

const _sfc_main = defineNuxtComponent({
  components: {
    ATitle,
    APagination,
    ASearch,
    BTable,
    AEntityDelete,
    ARealms,
    VCTimeago
  },
  emits: ["deleted"],
  setup(props, { emit }) {
    const store = useAuthStore();
    const {
      realm,
      realmManagementId
    } = storeToRefs$1(store);
    const handleDeleted = (e) => {
      emit("deleted", e);
    };
    const isResourceWritable = (entity) => isRealmResourceWritable(realm.value, entity.id);
    const hasEditPermission = store.has(PermissionName.REALM_EDIT);
    const hasDropPermission = store.has(PermissionName.REALM_DROP);
    const fields = [
      {
        key: "id",
        label: "ID",
        thClass: "text-left",
        tdClass: "text-left"
      },
      {
        key: "name",
        label: "Name",
        thClass: "text-left",
        tdClass: "text-left"
      },
      {
        key: "updated_at",
        label: "Updated At",
        thClass: "text-center",
        tdClass: "text-center"
      },
      {
        key: "created_at",
        label: "Created At",
        thClass: "text-center",
        tdClass: "text-center"
      },
      { key: "options", label: "", tdClass: "text-left" }
    ];
    return {
      fields,
      isResourceWritable,
      hasEditPermission,
      hasDropPermission,
      handleDeleted,
      realmManagementId,
      setRealmManagement: store.setRealmManagement
    };
  }
}, "$5Pfr7dJVmY");
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  const _component_ARealms = resolveComponent("ARealms");
  const _component_ATitle = resolveComponent("ATitle");
  const _component_ASearch = resolveComponent("ASearch");
  const _component_APagination = resolveComponent("APagination");
  const _component_BTable = resolveComponent("BTable");
  const _component_VCTimeago = resolveComponent("VCTimeago");
  const _component_NuxtLink = __nuxt_component_0;
  const _component_AEntityDelete = resolveComponent("AEntityDelete");
  _push(ssrRenderComponent(_component_ARealms, mergeProps({ onDeleted: _ctx.handleDeleted }, _attrs), {
    header: withCtx((props, _push2, _parent2, _scopeId) => {
      if (_push2) {
        _push2(ssrRenderComponent(_component_ATitle, null, null, _parent2, _scopeId));
        _push2(ssrRenderComponent(_component_ASearch, {
          load: props.load,
          busy: props.busy
        }, null, _parent2, _scopeId));
      } else {
        return [
          createVNode(_component_ATitle),
          createVNode(_component_ASearch, {
            load: props.load,
            busy: props.busy
          }, null, 8, ["load", "busy"])
        ];
      }
    }),
    footer: withCtx((props, _push2, _parent2, _scopeId) => {
      if (_push2) {
        _push2(ssrRenderComponent(_component_APagination, {
          busy: props.busy,
          meta: props.meta,
          load: props.load
        }, null, _parent2, _scopeId));
      } else {
        return [
          createVNode(_component_APagination, {
            busy: props.busy,
            meta: props.meta,
            load: props.load
          }, null, 8, ["busy", "meta", "load"])
        ];
      }
    }),
    body: withCtx((props, _push2, _parent2, _scopeId) => {
      if (_push2) {
        _push2(ssrRenderComponent(_component_BTable, {
          items: props.data,
          fields: _ctx.fields,
          busy: props.busy,
          "head-variant": "'dark'",
          outlined: ""
        }, {
          "cell(created_at)": withCtx((data, _push3, _parent3, _scopeId2) => {
            if (_push3) {
              _push3(ssrRenderComponent(_component_VCTimeago, {
                datetime: data.item.created_at
              }, null, _parent3, _scopeId2));
            } else {
              return [
                createVNode(_component_VCTimeago, {
                  datetime: data.item.created_at
                }, null, 8, ["datetime"])
              ];
            }
          }),
          "cell(updated_at)": withCtx((data, _push3, _parent3, _scopeId2) => {
            if (_push3) {
              _push3(ssrRenderComponent(_component_VCTimeago, {
                datetime: data.item.created_at
              }, null, _parent3, _scopeId2));
            } else {
              return [
                createVNode(_component_VCTimeago, {
                  datetime: data.item.created_at
                }, null, 8, ["datetime"])
              ];
            }
          }),
          "cell(options)": withCtx((data, _push3, _parent3, _scopeId2) => {
            if (_push3) {
              if (_ctx.realmManagementId !== data.item.id) {
                _push3(`<button class="btn btn-xs btn-primary me-1"${_scopeId2}><i class="fa-solid fa-check"${_scopeId2}></i></button>`);
              } else {
                _push3(`<!---->`);
              }
              _push3(ssrRenderComponent(_component_NuxtLink, {
                to: "/admin/realms/" + data.item.id,
                class: "btn btn-xs btn-outline-primary me-1",
                disabled: !_ctx.hasEditPermission
              }, {
                default: withCtx((_, _push4, _parent4, _scopeId3) => {
                  if (_push4) {
                    _push4(`<i class="fa-solid fa-bars"${_scopeId3}></i>`);
                  } else {
                    return [
                      createVNode("i", { class: "fa-solid fa-bars" })
                    ];
                  }
                }),
                _: 2
              }, _parent3, _scopeId2));
              _push3(ssrRenderComponent(_component_AEntityDelete, {
                class: "btn btn-xs btn-outline-danger",
                "entity-id": data.item.id,
                "entity-type": "realm",
                "with-text": false,
                disabled: !data.item.built_in || !_ctx.hasDropPermission,
                onDeleted: props.deleted
              }, null, _parent3, _scopeId2));
            } else {
              return [
                _ctx.realmManagementId !== data.item.id ? (openBlock(), createBlock("button", {
                  key: 0,
                  class: "btn btn-xs btn-primary me-1",
                  onClick: withModifiers(($event) => _ctx.setRealmManagement(data.item), ["prevent"])
                }, [
                  createVNode("i", { class: "fa-solid fa-check" })
                ], 8, ["onClick"])) : createCommentVNode("", true),
                createVNode(_component_NuxtLink, {
                  to: "/admin/realms/" + data.item.id,
                  class: "btn btn-xs btn-outline-primary me-1",
                  disabled: !_ctx.hasEditPermission
                }, {
                  default: withCtx(() => [
                    createVNode("i", { class: "fa-solid fa-bars" })
                  ]),
                  _: 2
                }, 1032, ["to", "disabled"]),
                createVNode(_component_AEntityDelete, {
                  class: "btn btn-xs btn-outline-danger",
                  "entity-id": data.item.id,
                  "entity-type": "realm",
                  "with-text": false,
                  disabled: !data.item.built_in || !_ctx.hasDropPermission,
                  onDeleted: props.deleted
                }, null, 8, ["entity-id", "disabled", "onDeleted"])
              ];
            }
          }),
          _: 2
        }, _parent2, _scopeId));
      } else {
        return [
          createVNode(_component_BTable, {
            items: props.data,
            fields: _ctx.fields,
            busy: props.busy,
            "head-variant": "'dark'",
            outlined: ""
          }, {
            "cell(created_at)": withCtx((data) => [
              createVNode(_component_VCTimeago, {
                datetime: data.item.created_at
              }, null, 8, ["datetime"])
            ]),
            "cell(updated_at)": withCtx((data) => [
              createVNode(_component_VCTimeago, {
                datetime: data.item.created_at
              }, null, 8, ["datetime"])
            ]),
            "cell(options)": withCtx((data) => [
              _ctx.realmManagementId !== data.item.id ? (openBlock(), createBlock("button", {
                key: 0,
                class: "btn btn-xs btn-primary me-1",
                onClick: withModifiers(($event) => _ctx.setRealmManagement(data.item), ["prevent"])
              }, [
                createVNode("i", { class: "fa-solid fa-check" })
              ], 8, ["onClick"])) : createCommentVNode("", true),
              createVNode(_component_NuxtLink, {
                to: "/admin/realms/" + data.item.id,
                class: "btn btn-xs btn-outline-primary me-1",
                disabled: !_ctx.hasEditPermission
              }, {
                default: withCtx(() => [
                  createVNode("i", { class: "fa-solid fa-bars" })
                ]),
                _: 2
              }, 1032, ["to", "disabled"]),
              createVNode(_component_AEntityDelete, {
                class: "btn btn-xs btn-outline-danger",
                "entity-id": data.item.id,
                "entity-type": "realm",
                "with-text": false,
                disabled: !data.item.built_in || !_ctx.hasDropPermission,
                onDeleted: props.deleted
              }, null, 8, ["entity-id", "disabled", "onDeleted"])
            ]),
            _: 2
          }, 1032, ["items", "fields", "busy"])
        ];
      }
    }),
    _: 1
  }, _parent));
}
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/admin/realms/index/index.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);

export { index as default };
//# sourceMappingURL=index-k_QQoB5_.mjs.map
