import { _ as _sfc_main$2, a as _sfc_main$3, b as _sfc_main$5, c as _sfc_main$6 } from "./CardTitle-CK392g0A.js";
import { defineComponent, mergeProps, unref, useSSRContext, withCtx, createVNode, createTextVNode, toDisplayString, computed } from "vue";
import { ssrRenderAttrs, ssrRenderSlot, ssrRenderComponent, ssrInterpolate } from "vue/server-renderer";
import { c as cn } from "./utils-H80jjgLf.js";
import { g as _sfc_main$4, f as __nuxt_component_0, a as _export_sfc, d as useI18n, j as createError } from "../server.mjs";
import { _ as _sfc_main$7 } from "./index-m9AqQ9dr.js";
import { useQuery } from "@pinia/colada";
import { u as useApi } from "./useApi-Dv-cyvzn.js";
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "CardFooter",
  __ssrInlineRender: true,
  props: {
    class: {}
  },
  setup(__props) {
    const props = __props;
    return (_ctx, _push, _parent, _attrs) => {
      _push(`<div${ssrRenderAttrs(mergeProps({
        "data-slot": "card-footer",
        class: unref(cn)("flex items-center px-6 [.border-t]:pt-6", props.class)
      }, _attrs))}>`);
      ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent);
      _push(`</div>`);
    };
  }
});
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/ui/card/CardFooter.vue");
  return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "BlogCard",
  __ssrInlineRender: true,
  props: {
    id: {},
    title: {},
    tag: {},
    description: {},
    image: {},
    slug: {},
    slug_ar: {},
    slug_en: {}
  },
  setup(__props) {
    const props = __props;
    return (_ctx, _push, _parent, _attrs) => {
      const _component_Card = _sfc_main$2;
      const _component_CardHeader = _sfc_main$3;
      const _component_NuxtImg = _sfc_main$4;
      const _component_CardContent = _sfc_main$5;
      const _component_CardTitle = _sfc_main$6;
      const _component_CardFooter = _sfc_main$1;
      const _component_NuxtLinkLocale = __nuxt_component_0;
      const _component_Button = _sfc_main$7;
      _push(ssrRenderComponent(_component_Card, mergeProps({ class: "card bg-surface-background border-surface-border flex h-full flex-col rounded-lg border pt-0 transition-all duration-550 ease-in-out" }, _attrs), {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(_component_CardHeader, { class: "px-0 py-0" }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(ssrRenderComponent(_component_NuxtImg, {
                    src: props.image,
                    alt: props.title,
                    class: "h-[150px] w-full rounded-t-lg object-cover sm:h-[180px] md:h-[200px] lg:h-[216px]"
                  }, null, _parent3, _scopeId2));
                } else {
                  return [
                    createVNode(_component_NuxtImg, {
                      src: props.image,
                      alt: props.title,
                      class: "h-[150px] w-full rounded-t-lg object-cover sm:h-[180px] md:h-[200px] lg:h-[216px]"
                    }, null, 8, ["src", "alt"])
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
            _push2(ssrRenderComponent(_component_CardContent, { class: "flex-1 space-y-3 p-4" }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(`<p class="text-accent text-base leading-6 font-normal sm:text-base md:text-lg" data-v-81fab03e${_scopeId2}>${ssrInterpolate(props.tag)}</p>`);
                  _push3(ssrRenderComponent(_component_CardTitle, { class: "line-clamp-2 text-lg leading-snug font-bold sm:text-xl md:text-2xl" }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`${ssrInterpolate(props.title)}`);
                      } else {
                        return [
                          createTextVNode(toDisplayString(props.title), 1)
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(`<div class="v-html-prose text-muted-foreground line-clamp-4 text-sm leading-relaxed font-normal sm:text-base md:text-lg" data-v-81fab03e${_scopeId2}>${props.description ?? ""}</div>`);
                } else {
                  return [
                    createVNode("p", { class: "text-accent text-base leading-6 font-normal sm:text-base md:text-lg" }, toDisplayString(props.tag), 1),
                    createVNode(_component_CardTitle, { class: "line-clamp-2 text-lg leading-snug font-bold sm:text-xl md:text-2xl" }, {
                      default: withCtx(() => [
                        createTextVNode(toDisplayString(props.title), 1)
                      ]),
                      _: 1
                    }),
                    createVNode("div", {
                      class: "v-html-prose text-muted-foreground line-clamp-4 text-sm leading-relaxed font-normal sm:text-base md:text-lg",
                      innerHTML: props.description
                    }, null, 8, ["innerHTML"])
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
            _push2(ssrRenderComponent(_component_CardFooter, { class: "p-4 pt-0" }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(ssrRenderComponent(_component_NuxtLinkLocale, {
                    to: { name: "blogs-slug", params: { slug: String(props.slug) } },
                    class: "w-full"
                  }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(ssrRenderComponent(_component_Button, {
                          variant: "wsGradient",
                          size: "wsDefault",
                          class: "w-full cursor-pointer text-base sm:text-base md:text-lg"
                        }, {
                          default: withCtx((_4, _push5, _parent5, _scopeId4) => {
                            if (_push5) {
                              _push5(`${ssrInterpolate(_ctx.$t("card.readMore"))}`);
                            } else {
                              return [
                                createTextVNode(toDisplayString(_ctx.$t("card.readMore")), 1)
                              ];
                            }
                          }),
                          _: 1
                        }, _parent4, _scopeId3));
                      } else {
                        return [
                          createVNode(_component_Button, {
                            variant: "wsGradient",
                            size: "wsDefault",
                            class: "w-full cursor-pointer text-base sm:text-base md:text-lg"
                          }, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(_ctx.$t("card.readMore")), 1)
                            ]),
                            _: 1
                          })
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                } else {
                  return [
                    createVNode(_component_NuxtLinkLocale, {
                      to: { name: "blogs-slug", params: { slug: String(props.slug) } },
                      class: "w-full"
                    }, {
                      default: withCtx(() => [
                        createVNode(_component_Button, {
                          variant: "wsGradient",
                          size: "wsDefault",
                          class: "w-full cursor-pointer text-base sm:text-base md:text-lg"
                        }, {
                          default: withCtx(() => [
                            createTextVNode(toDisplayString(_ctx.$t("card.readMore")), 1)
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    }, 8, ["to"])
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              createVNode(_component_CardHeader, { class: "px-0 py-0" }, {
                default: withCtx(() => [
                  createVNode(_component_NuxtImg, {
                    src: props.image,
                    alt: props.title,
                    class: "h-[150px] w-full rounded-t-lg object-cover sm:h-[180px] md:h-[200px] lg:h-[216px]"
                  }, null, 8, ["src", "alt"])
                ]),
                _: 1
              }),
              createVNode(_component_CardContent, { class: "flex-1 space-y-3 p-4" }, {
                default: withCtx(() => [
                  createVNode("p", { class: "text-accent text-base leading-6 font-normal sm:text-base md:text-lg" }, toDisplayString(props.tag), 1),
                  createVNode(_component_CardTitle, { class: "line-clamp-2 text-lg leading-snug font-bold sm:text-xl md:text-2xl" }, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(props.title), 1)
                    ]),
                    _: 1
                  }),
                  createVNode("div", {
                    class: "v-html-prose text-muted-foreground line-clamp-4 text-sm leading-relaxed font-normal sm:text-base md:text-lg",
                    innerHTML: props.description
                  }, null, 8, ["innerHTML"])
                ]),
                _: 1
              }),
              createVNode(_component_CardFooter, { class: "p-4 pt-0" }, {
                default: withCtx(() => [
                  createVNode(_component_NuxtLinkLocale, {
                    to: { name: "blogs-slug", params: { slug: String(props.slug) } },
                    class: "w-full"
                  }, {
                    default: withCtx(() => [
                      createVNode(_component_Button, {
                        variant: "wsGradient",
                        size: "wsDefault",
                        class: "w-full cursor-pointer text-base sm:text-base md:text-lg"
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("card.readMore")), 1)
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  }, 8, ["to"])
                ]),
                _: 1
              })
            ];
          }
        }),
        _: 1
      }, _parent));
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/blogs/BlogCard.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const __nuxt_component_2 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-81fab03e"]]);
function useBlogsQuery(page) {
  const { get } = useApi();
  const { locale } = useI18n();
  return useQuery({
    staleTime: 1e3 * 60 * 60,
    key: computed(() => ["blogs", locale.value, page.value]),
    query: async () => {
      try {
        const response = await get("blogs", {
          params: { page: page.value }
        });
        return response.data;
      } catch (error) {
        console.error(error.message);
        throw error;
      }
    }
  });
}
function useBlogQuery(slug) {
  const { get } = useApi();
  const { locale } = useI18n();
  return useQuery({
    staleTime: 1e3 * 60 * 60,
    key: computed(() => ["blog", slug, locale.value]),
    query: async () => {
      var _a;
      try {
        const response = await get(`blogs/${slug}`);
        return {
          blog: response.data.data,
          relatedBlogs: response.data.data.related_blogs
        };
      } catch (error) {
        throw createError({
          statusCode: ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.status) || 404,
          statusMessage: "Blog Not Found"
        });
      }
    }
  });
}
export {
  __nuxt_component_2 as _,
  useBlogQuery as a,
  useBlogsQuery as u
};
//# sourceMappingURL=blogs-B7krQ5hx.js.map
