import { _ as __nuxt_component_0 } from './DomainEntityNav-BA21qIiW.mjs';
import { _ as _export_sfc, d as defineNuxtComponent, a as useRoute, e as executeAsync, n as navigateTo, c as createError, b as useAuthStore, s as storeToRefs$1, f as __nuxt_component_0$1 } from '../server.mjs';
import { useSSRContext, ref } from 'vue';
import { u as updateObjectProperties } from './object-H1g04ijM.mjs';
import { u as useAPI } from './api-g5C5HqP1.mjs';
import { u as useToast } from './toast-DFAP4gOT.mjs';
import { i as isRealmResourceWritable } from './utils-CfT4uBfw.mjs';
import { ssrRenderAttrs, ssrInterpolate, ssrRenderComponent } from 'vue/server-renderer';
import './nuxt-link-CtTcnFKy.mjs';
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 'bootstrap-vue-next';
import '@vuecs/preset-bootstrap-v5';
import '@vuecs/preset-font-awesome';
import '@vuecs/countdown';
import '@vuecs/timeago';
import '@vuecs/form-controls/core';
import 'browser-storage-adapter';

const _sfc_main = defineNuxtComponent({
  async setup() {
    let __temp, __restore;
    const items = [
      {
        name: "General",
        icon: "fas fa-bars",
        urlSuffix: ""
      },
      {
        name: "Permissions",
        icon: "fas fa-user-secret",
        urlSuffix: "permissions"
      },
      {
        name: "Roles",
        icon: "fa-solid fa-user-group",
        urlSuffix: "roles"
      }
    ];
    const toast = useToast();
    const route = useRoute();
    const entity = ref(null);
    try {
      entity.value = ([__temp, __restore] = executeAsync(() => useAPI().robot.getOne(route.params.id, { fields: ["+secret"] })), __temp = await __temp, __restore(), __temp);
    } catch (e) {
      [__temp, __restore] = executeAsync(() => navigateTo({ path: "/admin/robots" })), await __temp, __restore();
      createError({});
    }
    const store = useAuthStore();
    const { realmManagement } = storeToRefs$1(store);
    if (!isRealmResourceWritable(realmManagement.value, entity.value.realm_id)) {
      [__temp, __restore] = executeAsync(() => navigateTo({ path: "/admin/robots" })), await __temp, __restore();
      createError({});
    }
    const handleUpdated = (e) => {
      if (toast) {
        toast.show({ variant: "success", body: "The robot was successfully updated." });
      }
      updateObjectProperties(entity, e);
    };
    const handleFailed = (e) => {
      if (toast) {
        toast.show({ variant: "warning", body: e.message });
      }
    };
    return {
      entity,
      items,
      handleUpdated,
      handleFailed
    };
  }
}, "$m3bphLu3X1");
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-robot 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/robots/" + _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/robots/[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_-CgVaCTqC.mjs.map
