import __nuxt_component_0 from './GlobalLoader-CBULtKs6.mjs';
import __nuxt_component_0$1 from './InternalHeaderSection-DIj5MLKD.mjs';
import { _ as __nuxt_component_8 } from './Clock-D_ej_glW.mjs';
import { defineComponent, computed, watch, unref, mergeProps, withCtx, createVNode, toDisplayString, createTextVNode, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderComponent, ssrInterpolate, ssrRenderList } from 'vue/server-renderer';
import { k as useRoute, d as useI18n, q as useSetI18nParams, e as useSeoMeta, s as useHead, n as navigateTo, a as _export_sfc, _ as __nuxt_component_0$1$1 } from './server.mjs';
import { a as _sfc_main$1$1, _ as __nuxt_component_3 } from './SubscribeSection-D6lSAdXw.mjs';
import __nuxt_component_6 from './Spacer-DtCydRp3.mjs';
import { a as useBlogQuery, _ as __nuxt_component_2$1 } from './blogs-B7krQ5hx.mjs';
import './useBreadcrumbSchema-CZ-Fj_m_.mjs';
import './utils-H80jjgLf.mjs';
import 'clsx';
import 'tailwind-merge';
import 'reka-ui';
import 'lucide-vue-next';
import '@unhead/schema-org';
import '../_/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'nitropack/dist/runtime/plugin';
import 'packrup';
import 'consola';
import 'node:fs';
import 'node:url';
import '@iconify/utils';
import 'node:crypto';
import 'ipx';
import 'node:path';
import 'pinia';
import '@pinia/colada';
import 'vue-router';
import '@unhead/schema-org/vue';
import 'deep-pick-omit';
import '@iconify/vue';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/plugins';
import 'unhead/utils';
import './index-m9AqQ9dr.mjs';
import 'class-variance-authority';
import './useUtmPayload-DlQ2OH8k.mjs';
import 'vee-validate';
import './index-Cce4iXMN.mjs';
import './index-B_IDLhd1.mjs';
import 'zod';
import '@vee-validate/zod';
import './useApi-Dv-cyvzn.mjs';
import 'axios';
import 'vue-sonner';
import './CardTitle-CK392g0A.mjs';

const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  __name: "SingleBlogHero",
  __ssrInlineRender: true,
  props: {
    title: {},
    image: {},
    date: {}
  },
  setup(__props) {
    const props = __props;
    return (_ctx, _push, _parent, _attrs) => {
      const _component_InternalHeaderSection = __nuxt_component_0$1;
      const _component_SvgClock = __nuxt_component_8;
      _push(ssrRenderComponent(_component_InternalHeaderSection, mergeProps({
        pages: [{ name: _ctx.$t("blogs"), link: "/blogs" }, { name: props.title }],
        image: { Url: props.image, Alt: props.title }
      }, _attrs), {
        title: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(`<p class="mb-4 text-3xl font-bold"${_scopeId}>${ssrInterpolate(props.title)}</p><p class="text-primary flex items-center justify-center gap-1 text-sm font-normal"${_scopeId}>${ssrInterpolate(props.date)} `);
            _push2(ssrRenderComponent(_component_SvgClock, { class: "h-4 w-4" }, null, _parent2, _scopeId));
            _push2(`</p>`);
          } else {
            return [
              createVNode("p", { class: "mb-4 text-3xl font-bold" }, toDisplayString(props.title), 1),
              createVNode("p", { class: "text-primary flex items-center justify-center gap-1 text-sm font-normal" }, [
                createTextVNode(toDisplayString(props.date) + " ", 1),
                createVNode(_component_SvgClock, { class: "h-4 w-4" })
              ])
            ];
          }
        }),
        _: 1
      }, _parent));
    };
  }
});
const _sfc_setup$3 = _sfc_main$3.setup;
_sfc_main$3.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/blogs/SingleBlogHero.vue");
  return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
};
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  __name: "SingleBlogSection",
  __ssrInlineRender: true,
  props: {
    description: {
      type: String,
      required: true
    }
  },
  setup(__props) {
    return (_ctx, _push, _parent, _attrs) => {
      const _component_client_only = __nuxt_component_0$1$1;
      _push(`<section${ssrRenderAttrs(mergeProps({
        id: "single-blog",
        class: "bg-gradient-odd pt-section px-4 max-2xl:flex max-2xl:flex-col max-2xl:justify-center"
      }, _attrs))} data-v-e5e74394><div class="container mx-auto" data-v-e5e74394>`);
      _push(ssrRenderComponent(_component_client_only, null, {}, _parent));
      _push(`</div></section>`);
    };
  }
});
const _sfc_setup$2 = _sfc_main$2.setup;
_sfc_main$2.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/blogs/SingleBlogSection.vue");
  return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
};
const __nuxt_component_2 = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-e5e74394"]]);
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "RelatedBlogs",
  __ssrInlineRender: true,
  props: {
    relatedBlogs: {}
  },
  setup(__props) {
    const props = __props;
    return (_ctx, _push, _parent, _attrs) => {
      const _component_BlogsTitle = _sfc_main$1$1;
      const _component_Spacer = __nuxt_component_6;
      const _component_BlogsBlogCard = __nuxt_component_2$1;
      const _component_SubscribeSection = __nuxt_component_3;
      _push(`<section${ssrRenderAttrs(mergeProps({
        id: "related-blogs",
        class: "bg-gradient-even py-section px-4 max-2xl:flex max-2xl:flex-col max-2xl:justify-center"
      }, _attrs))}><div class="pb-section container mx-auto">`);
      _push(ssrRenderComponent(_component_BlogsTitle, {
        title: _ctx.$t("relatedBlogs.title"),
        "title-heading": "h3"
      }, null, _parent));
      _push(ssrRenderComponent(_component_Spacer, null, null, _parent));
      _push(`<div class="container mx-auto grid grid-cols-1 gap-10 md:grid-cols-2 lg:grid-cols-3"><!--[-->`);
      ssrRenderList(props.relatedBlogs, (blog) => {
        _push(ssrRenderComponent(_component_BlogsBlogCard, {
          id: blog.id,
          key: blog.id,
          slug: blog.slug,
          title: blog.title,
          tag: blog.tag,
          description: blog.description,
          image: blog.image
        }, null, _parent));
      });
      _push(`<!--]--></div></div>`);
      _push(ssrRenderComponent(_component_SubscribeSection, null, null, _parent));
      _push(`</section>`);
    };
  }
});
const _sfc_setup$1 = _sfc_main$1.setup;
_sfc_main$1.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/blogs/RelatedBlogs.vue");
  return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const baseUrl = "https://webstdy.com";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "[slug]",
  __ssrInlineRender: true,
  setup(__props) {
    var _a;
    const route = useRoute();
    const slug = route.params.slug;
    const { state: blog, isPending } = useBlogQuery(slug);
    const { locale } = useI18n();
    const setI18nParams = useSetI18nParams();
    const pageTitle = computed(
      () => {
        var _a2, _b, _c, _d, _e;
        return ((_c = (_b = (_a2 = blog.value.data) == null ? void 0 : _a2.blog) == null ? void 0 : _b.meta) == null ? void 0 : _c.title) || ((_e = (_d = blog.value.data) == null ? void 0 : _d.blog) == null ? void 0 : _e.title);
      }
    );
    const pageDescription = computed(
      () => {
        var _a2, _b, _c, _d, _e;
        return ((_c = (_b = (_a2 = blog.value.data) == null ? void 0 : _a2.blog) == null ? void 0 : _b.meta) == null ? void 0 : _c.meta_tag_description) || ((_e = (_d = blog.value.data) == null ? void 0 : _d.blog) == null ? void 0 : _e.description);
      }
    );
    const pageKeyword = computed(
      () => {
        var _a2, _b, _c;
        return (_c = (_b = (_a2 = blog.value.data) == null ? void 0 : _a2.blog) == null ? void 0 : _b.meta) == null ? void 0 : _c.meta_tag_keyword;
      }
    );
    const arUrl = computed(
      () => {
        var _a2, _b;
        return ((_b = (_a2 = blog.value.data) == null ? void 0 : _a2.blog) == null ? void 0 : _b.slug_ar) ? `${baseUrl}/blogs/${blog.value.data.blog.slug_ar}` : "";
      }
    );
    const enUrl = computed(
      () => {
        var _a2, _b;
        return ((_b = (_a2 = blog.value.data) == null ? void 0 : _a2.blog) == null ? void 0 : _b.slug_en) ? `${baseUrl}/en/blogs/${blog.value.data.blog.slug_en}` : "";
      }
    );
    const canonicalUrl = computed(
      () => locale.value === "ar" ? arUrl.value : enUrl.value
    );
    useSeoMeta({
      title: pageTitle,
      description: pageDescription,
      keywords: pageKeyword,
      ogTitle: pageTitle,
      ogDescription: pageDescription,
      ogImage: (_a = blog.value.data) == null ? void 0 : _a.blog.image
    });
    useHead(() => {
      var _a2;
      return {
        link: ((_a2 = blog.value.data) == null ? void 0 : _a2.blog) ? [
          { rel: "canonical", href: canonicalUrl.value },
          { rel: "alternate", hreflang: "x-default", href: arUrl.value },
          { rel: "alternate", hreflang: "ar", href: arUrl.value },
          { rel: "alternate", hreflang: "en", href: enUrl.value }
        ] : []
      };
    });
    watch(
      blog,
      (newblog) => {
        var _a2;
        if ((_a2 = newblog == null ? void 0 : newblog.data) == null ? void 0 : _a2.blog) {
          const currentSlug = route.params.slug;
          const targetSlug = locale.value === "ar" ? newblog.data.blog.slug_ar : newblog.data.blog.slug_en;
          if (currentSlug !== targetSlug) {
            navigateTo(
              {
                name: "blogs-slug",
                params: { slug: targetSlug }
              },
              {
                redirectCode: 301,
                external: true
              }
            );
          }
          setI18nParams({
            ar: { slug: newblog.data.blog.slug_ar },
            en: { slug: newblog.data.blog.slug_en }
          });
        }
      },
      { immediate: true }
    );
    return (_ctx, _push, _parent, _attrs) => {
      var _a3, _b2, _c2, _d2, _e2, _f2;
      var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
      const _component_GlobalLoader = __nuxt_component_0;
      const _component_BlogsSingleBlogHero = _sfc_main$3;
      const _component_BlogsSingleBlogSection = __nuxt_component_2;
      const _component_BlogsRelatedBlogs = _sfc_main$1;
      _push(`<main${ssrRenderAttrs(_attrs)}>`);
      if (unref(isPending)) {
        _push(ssrRenderComponent(_component_GlobalLoader, null, null, _parent));
      } else {
        _push(`<div>`);
        _push(ssrRenderComponent(_component_BlogsSingleBlogHero, {
          title: (_a3 = (_b = (_a2 = unref(blog)) == null ? void 0 : _a2.data) == null ? void 0 : _b.blog.title) != null ? _a3 : "Default Title",
          page: (_b2 = (_d = (_c = unref(blog)) == null ? void 0 : _c.data) == null ? void 0 : _d.blog.category) != null ? _b2 : "Default Category",
          image: (_c2 = (_f = (_e = unref(blog)) == null ? void 0 : _e.data) == null ? void 0 : _f.blog.image) != null ? _c2 : "/default-image.jpg",
          date: (_d2 = (_h = (_g = unref(blog)) == null ? void 0 : _g.data) == null ? void 0 : _h.blog.created_at) != null ? _d2 : (/* @__PURE__ */ new Date()).toISOString()
        }, null, _parent));
        _push(ssrRenderComponent(_component_BlogsSingleBlogSection, {
          description: (_e2 = (_k = (_j = (_i = unref(blog)) == null ? void 0 : _i.data) == null ? void 0 : _j.blog) == null ? void 0 : _k.description) != null ? _e2 : "Default Description"
        }, null, _parent));
        _push(ssrRenderComponent(_component_BlogsRelatedBlogs, {
          "related-blogs": (_f2 = (_m = (_l = unref(blog)) == null ? void 0 : _l.data) == null ? void 0 : _m.relatedBlogs) != null ? _f2 : []
        }, null, _parent));
        _push(`</div>`);
      }
      _push(`</main>`);
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/blogs/[slug].vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
//# sourceMappingURL=_slug_-BTIa8Pm1.mjs.map
