import { _ as __nuxt_component_0 } from './DomainEntityNav-e802c1ca.mjs';
import { _ as _export_sfc, d as defineNuxtComponent, f as useRoute, n as navigateTo, c as createError, g as useAuthStore, s as storeToRefs, h as __nuxt_component_0$1 } from '../server.mjs';
import { executeAsync } from 'unctx';
import { useSSRContext, ref } from 'vue';
import { u as updateObjectProperties } from './object-80310ce0.mjs';
import { u as useAPI } from './api-29ff697c.mjs';
import { i as isRealmResourceWritable } from './utils-8f9455a3.mjs';
import { useToast } from 'bootstrap-vue-next';
import { ssrRenderAttrs, ssrInterpolate, ssrRenderComponent } from 'vue/server-renderer';
import './nuxt-link-8cb59051.mjs';
import 'ufo';
import 'ofetch';
import 'hookable';
import 'vue-router';
import 'h3';
import '@ebec/http';
import 'hapic';
import '@hapic/oauth2';
import 'rapiq';
import '@hapic/vault';
import '@vue-layout/navigation';
import 'destr';
import 'change-case';
import '@vue-layout/list-controls/core';
import '@vue-layout/form-controls';
import 'smob';
import '@vue-layout/list-controls';
import '@vue-layout/pagination';
import '@ucast/mongo2js';
import '@vuelidate/validators';
import 'ilingo';
import '@vuelidate/core';
import 'nanoid';
import '@unhead/ssr';
import 'unhead';
import '@unhead/shared';
import '@vue-layout/preset-bootstrap-v5';
import '@vue-layout/preset-font-awesome';
import '@vue-layout/countdown';
import '@vue-layout/timeago';
import 'browser-storage-adapter';
import 'cookie-es';
import 'ohash';
import 'defu';
import '../../nitro/node-server.mjs';
import 'node-fetch-native/polyfill';
import 'node:http';
import 'node:https';
import 'unenv/runtime/fetch/index';
import 'scule';
import 'klona';
import 'unstorage';
import 'radix3';
import 'node:fs';
import 'node:url';
import 'pathe';
import 'http-graceful-shutdown';

const _sfc_main = /* @__PURE__ */ defineNuxtComponent({
  async setup() {
    let __temp, __restore;
    const items = [
      {
        name: "General",
        icon: "fas fa-bars",
        urlSuffix: ""
      }
    ];
    const toast = useToast();
    const route = useRoute();
    const entity = ref(null);
    try {
      entity.value = ([__temp, __restore] = executeAsync(() => useAPI().realm.getOne(route.params.id)), __temp = await __temp, __restore(), __temp);
    } catch (e) {
      [__temp, __restore] = executeAsync(() => navigateTo({ path: "/admin/realms" })), await __temp, __restore();
      throw createError({});
    }
    const store = useAuthStore();
    const { realmManagement } = storeToRefs(store);
    if (!isRealmResourceWritable(realmManagement.value, entity.value.id)) {
      [__temp, __restore] = executeAsync(() => navigateTo({ path: "/admin/realms" })), await __temp, __restore();
      throw createError({});
    }
    const handleUpdated = (e) => {
      if (toast) {
        toast.success({ body: "The realm was successfully updated." });
      }
      updateObjectProperties(entity, e);
    };
    const handleFailed = (e) => {
      if (toast) {
        toast.warning({ body: e.message });
      }
    };
    return {
      entity,
      items,
      handleUpdated,
      handleFailed
    };
  }
}, "$PR2RFRhE3G");
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  const _component_DomainEntityNav = __nuxt_component_0;
  const _component_NuxtPage = __nuxt_component_0$1;
  _push(`<div${ssrRenderAttrs(_attrs)}><h1 class="title no-border mb-3"><i class="fa-solid fa-building me-1"></i> ${ssrInterpolate(_ctx.entity.name)} <span class="sub-title ms-1">Details</span></h1><div class="mb-2">`);
  _push(ssrRenderComponent(_component_DomainEntityNav, {
    path: "/admin/realms/" + _ctx.entity.id,
    items: _ctx.items,
    "prev-link": true
  }, null, _parent));
  _push(`</div><div>`);
  _push(ssrRenderComponent(_component_NuxtPage, {
    entity: _ctx.entity,
    onUpdated: _ctx.handleUpdated,
    onFailed: _ctx.handleFailed
  }, null, _parent));
  _push(`</div></div>`);
}
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/[id].vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const _id_ = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);

export { _id_ as default };
//# sourceMappingURL=_id_-7e5fbfd6.mjs.map
