import { ref, h } from 'vue';
import { u as updateObjectProperties } from './object-80310ce0.mjs';
import { u as useAPI } from './api-115b4897.mjs';
import { i as isRealmResourceWritable } from './utils-e4eb8c9d.mjs';
import { d as defineNuxtComponent, u as useAuthStore, b as storeToRefs } from './auth-2d06b6ac.mjs';
import { u as useToast } from './server.mjs';
import { u as useRoute, b as navigateTo } from './nuxt-link-5ac46069.mjs';
import { b as buildDomainEntityNav } from './enity-nav-ddb4f4ff.mjs';
import { N as NuxtPage } from './page-011b4897.mjs';
import 'h3';
import './composables-31566dd1.mjs';
import '@ucast/mongo2js';
import 'change-case';
import '@ebec/http';
import 'hapic';
import '@hapic/oauth2';
import 'ofetch';
import 'destr';
import '@unhead/vue';
import '@unhead/dom';
import '@unhead/ssr';
import 'unctx';
import 'vue-router';
import 'ufo';
import 'rapiq';
import '@vue-layout/basic';
import '@vuelidate/validators';
import 'ilingo';
import 'nanoid';
import '@vue-layout/hyperscript';
import 'smob';
import 'browser-storage-adapter';
import 'cookie-es';
import 'ohash';
import 'vue/server-renderer';
import './_plugin-vue_export-helper-cc2b3d55.mjs';
import './config.mjs';
import 'scule';
import 'hookable';
import 'defu';

const _id_ = defineNuxtComponent({
  async setup() {
    const items = [
      {
        name: "General",
        icon: "fas fa-bars",
        urlSuffix: ""
      }
    ];
    const toast = useToast();
    const route = useRoute();
    const entity = ref(null);
    try {
      entity.value = await useAPI().realm.getOne(route.params.id);
    } catch (e) {
      return navigateTo({ path: "/admin/realms" });
    }
    const store = useAuthStore();
    const { realmManagement } = storeToRefs(store);
    if (!isRealmResourceWritable(realmManagement.value, entity.value.id)) {
      return navigateTo({ path: "/admin/realms" });
    }
    const handleUpdated = (e) => {
      toast.success("The realm was successfully updated.");
      updateObjectProperties(entity, e);
    };
    const handleFailed = (e) => {
      toast.warning(e.message);
    };
    return () => h("div", [
      h("h1", { class: "title no-border mb-3" }, [
        h("i", { class: "fa fa-university me-1" }),
        entity.value.name,
        h("span", { class: "sub-title ms-1" }, [
          "Details"
        ])
      ]),
      h("div", { class: "mb-2" }, [
        buildDomainEntityNav(`/admin/realms/${entity.value.id}`, items, { prevLink: true })
      ]),
      h("div", [
        h(NuxtPage, {
          onUpdated: handleUpdated,
          onFailed: handleFailed,
          entity: entity.value
        })
      ])
    ]);
  }
});

export { _id_ as default };
//# sourceMappingURL=_id_-1f7f6e3c.mjs.map
