import axios from "axios";
import { resolveComponent, withCtx, createVNode, createCommentVNode, toDisplayString, createTextVNode, useSSRContext } from "vue";
import { ssrRenderAttrs, ssrInterpolate, ssrRenderStyle, ssrRenderAttr, ssrRenderList, ssrRenderComponent, ssrRenderClass } from "vue/server-renderer";
/* empty css               */
import { _ as _export_sfc } from "../entries/pages.mjs";
import "@vue/server-renderer";
import "vue-router";
import "@vueuse/head";
import "vike/server";
/* empty css               */
/* empty css               */
import "pinia";
import "vue-i18n";
/*! src/views/UpdatesPage.vue [vike:pluginModuleBanner] */
const _sfc_main = {
  data() {
    return {
      allUpdates: {},
      updates: [],
      allData: [],
      loading: false,
      search: ""
    };
  },
  methods: {
    updateHref(updateItem) {
      if (!updateItem) return "#";
      return `/${this.$i18n.locale}/blogs/${updateItem[`slug_${this.$i18n.locale}`]}`;
    },
    async loadUdates(currentPage) {
      this.loading = true;
      try {
        const response = await axios.get(`https://admin.valueerp.net/api/updates?page=${currentPage}&q=${this.search}`);
        this.allUpdates = response.data.data.all_updates;
        this.allData = [...this.allData, ...this.allUpdates.data].flat();
        this.updates = response.data.data.data;
      } catch (error) {
      } finally {
        this.loading = false;
      }
    }
  },
  async serverPrefetch() {
    await this.loadUdates(1);
  },
  created() {
    if (typeof window !== "undefined") {
      this.loadUdates(1);
    }
  }
};
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  const _component_router_link = resolveComponent("router-link");
  _push(`<div${ssrRenderAttrs(_attrs)}><!-- Loading -->`);
  if ($data.loading) {
    _push(`<div class="fixed inset-0 h-dvh flex items-center justify-center bg-white bg-opacity-90 z-50"><div class="border-4 border-y-ambassador-blue border-x-inherit border-solid w-10 h-10 rounded-full animate-spin"></div></div>`);
  } else {
    _push(`<!---->`);
  }
  _push(`<div class="-mt-24 bg-no-repeat bg-cover updates-cover pt-40 pb-8"><div class="max-w-screen-2xl mx-auto xl:px-20 lg:px-16 md:px-12 sm:px-8 px-6"><h1 class="lg:text-7xl md:text-6xl sm:text-5xl text-3xl sm:ltr:text-left sm:rtl:text-right text-center font-bold text-white xl:leading-[115px] sm:leading-tight leading-normal">${ssrInterpolate(_ctx.$t("Improve Decision Making with Enterprise Resource Planning"))}</h1><div class="xl:w-1/4 sm:w-1/2 w-full xl:mt-8 mt-12 border border-solid md:p-3 p-2 rounded-full text-white flex items-center gap-3 bg-[#FFFFFF26]" style="${ssrRenderStyle({ "backdrop-filter": "blur(8px)" })}"><button class="bg-[#E58411] rounded-full w-8 h-8 flex items-center justify-center shrink-0"><span class="material-symbols-rounded text-xl">search</span></button><input type="text" name="search" id="search"${ssrRenderAttr("value", $data.search)}${ssrRenderAttr("placeholder", _ctx.$t("Search for articles"))} class="w-full bg-transparent outline-none"></div><div class="mt-10 flex items-center gap-2 text-white justify-end"><p class="md:text-lg">${ssrInterpolate(_ctx.$t("Explore More"))}</p><span class="material-symbols-rounded">south</span></div></div></div><!-- <div class="md:mt-28 mt-20 max-w-screen-2xl mx-auto xl:px-20 lg:px-16 md:px-12 sm:px-8 px-6">
      <div class="grid lg:grid-cols-2 grid-cols-1 gap-5">
        <div v-if="updates.length > 0" @click="goToupdateDetails(updates[0])" class="cursor-pointer">
          <img :src="updates[0].image" class="w-full h-[380px] object-cover" :alt="updates[0][\`title_\${$i18n.locale}\`]">
          <div class="xl:mt-5 mt-4">
            <p class="text-rainmaker text-sm font-light">{{ updates[0].created }}</p>
            <p class="lg:my-4 my-2 font-medium lg:text-xl text-lg">{{ updates[0][\`title_\${$i18n.locale}\`] }}</p>
            <p class="lg:text-base text-sm text-rainmaker ellipsis-4" v-html="updates[0][\`content_\${$i18n.locale}\`] ? updates[0][\`content_\${$i18n.locale}\`].replace(/\\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;').replace(/\\r?\\n/g, '<br>') : ''"></p>
          </div>
        </div>
        <div v-if="updates.slice(1).length > 0">
          <div v-for="(item, index) in updates.slice(1)" :key="index" class="flex flex-col lg:gap-5 gap-4">
            <div @click="goToupdateDetails(item)" class="cursor-pointer flex sm:items-start items-center xl:gap-6 gap-4">
              <div class="xl:w-1/3 lg:h-full sm:w-auto w-1/3">
                <img :src="item.image" class="w-full" :alt="item[\`title_\${$i18n.locale}\`]">
              </div>
              <div class="lg:w-2/3 sm:w-auto w-2/3 flex flex-col xl:gap-3 gap-2 lg:justify-between">
                <p class="text-rainmaker sm:text-sm text-xs font-light">{{ item.created }}</p>
                <p class="font-medium xl:text-lg md:text-base sm:text-sm text-xs overflow-hidden text-ellipsis" v-html="item[\`content_\${$i18n.locale}\`] ? item[\`content_\${$i18n.locale}\`].replace(/\\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;').replace(/\\r?\\n/g, '<br>') : ''" style="display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4;"></p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div> -->`);
  if ($data.allData.length > 0) {
    _push(`<div class="md:mt-28 mt-20 max-w-screen-2xl mx-auto xl:px-20 lg:px-16 md:px-12 sm:px-8 px-6"><div class="grid xl:grid-cols-3 lg:grid-cols-2 grid-cols-1 gap-6"><!--[-->`);
    ssrRenderList($data.allData, (item, index) => {
      _push(`<div>`);
      _push(ssrRenderComponent(_component_router_link, {
        to: $options.updateHref(item),
        class: "relative group block"
      }, {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(`<div class="${ssrRenderClass(`rounded-2xl border border-solid border-[#F1F3F7] overflow-hidden h-[260px] ${_ctx.$i18n.locale === "en" ? "rounded-tr-md" : "rounded-tl-md"}`)}"${_scopeId}><img${ssrRenderAttr("src", item.image)} class="object-cover w-full h-full"${ssrRenderAttr("alt", item[`title_${_ctx.$i18n.locale}`])}${_scopeId}></div><!-- Date --><div class="${ssrRenderClass(`absolute top-0 end-0 bg-[#F1F3F7] py-2 px-3 ${_ctx.$i18n.locale === "en" ? "rounded-tr-md rounded-bl-md" : "rounded-tl-md rounded-br-md"}`)}"${_scopeId}><p class="text-center"${_scopeId}><span class="block text-xl font-bold text-[#343434]"${_scopeId}>${ssrInterpolate(new Date(item.created).toLocaleDateString("en-GB", { day: "2-digit" }))}</span><span class="block text-[#737373]"${_scopeId}>${ssrInterpolate(new Date(item.created).toLocaleDateString("en-GB", { month: "short" }))}</span></p></div><!-- Card --><div class="sm:w-[90%] w-[95%] -mt-14 relative sm:p-6 p-4 bg-white mx-auto rounded-2xl border-b-[3px] border-solid border-transparent group-hover:border-ambassador-blue transition-colors duration-500 shadow-[0px_5px_60px_0px_#0000000d]"${_scopeId}><p class="sm:mb-4 mb-2 leading-6 font-medium md:text-xl text-lg text-ambassador-blue"${_scopeId}>${ssrInterpolate(item[`title_${_ctx.$i18n.locale}`])}</p><p class="md:text-base text-sm text-rainmaker ellipsis-5"${_scopeId}>${(item[`content_${_ctx.$i18n.locale}`] ? item[`content_${_ctx.$i18n.locale}`].replace(/\t/g, "    ").replace(/\r?\n/g, "<br>") : "") ?? ""}</p><span class="sm:mt-2 mt-1 text-sm flex items-center group-hover:text-blue-600 transition-colors duration-500"${_scopeId}>${ssrInterpolate(_ctx.$t("Read more"))} <span class="material-symbols-rounded text-base h-5"${_scopeId}>${ssrInterpolate(_ctx.$i18n.locale === "en" ? "arrow_right_alt" : "arrow_left_alt")}</span></span></div>`);
          } else {
            return [
              createVNode(
                "div",
                {
                  class: `rounded-2xl border border-solid border-[#F1F3F7] overflow-hidden h-[260px] ${_ctx.$i18n.locale === "en" ? "rounded-tr-md" : "rounded-tl-md"}`
                },
                [
                  createVNode("img", {
                    src: item.image,
                    class: "object-cover w-full h-full",
                    alt: item[`title_${_ctx.$i18n.locale}`]
                  }, null, 8, ["src", "alt"])
                ],
                2
                /* CLASS */
              ),
              createCommentVNode(" Date "),
              createVNode(
                "div",
                {
                  class: `absolute top-0 end-0 bg-[#F1F3F7] py-2 px-3 ${_ctx.$i18n.locale === "en" ? "rounded-tr-md rounded-bl-md" : "rounded-tl-md rounded-br-md"}`
                },
                [
                  createVNode("p", { class: "text-center" }, [
                    createVNode(
                      "span",
                      { class: "block text-xl font-bold text-[#343434]" },
                      toDisplayString(new Date(item.created).toLocaleDateString("en-GB", { day: "2-digit" })),
                      1
                      /* TEXT */
                    ),
                    createVNode(
                      "span",
                      { class: "block text-[#737373]" },
                      toDisplayString(new Date(item.created).toLocaleDateString("en-GB", { month: "short" })),
                      1
                      /* TEXT */
                    )
                  ])
                ],
                2
                /* CLASS */
              ),
              createCommentVNode(" Card "),
              createVNode("div", { class: "sm:w-[90%] w-[95%] -mt-14 relative sm:p-6 p-4 bg-white mx-auto rounded-2xl border-b-[3px] border-solid border-transparent group-hover:border-ambassador-blue transition-colors duration-500 shadow-[0px_5px_60px_0px_#0000000d]" }, [
                createVNode(
                  "p",
                  { class: "sm:mb-4 mb-2 leading-6 font-medium md:text-xl text-lg text-ambassador-blue" },
                  toDisplayString(item[`title_${_ctx.$i18n.locale}`]),
                  1
                  /* TEXT */
                ),
                createVNode("p", {
                  class: "md:text-base text-sm text-rainmaker ellipsis-5",
                  innerHTML: item[`content_${_ctx.$i18n.locale}`] ? item[`content_${_ctx.$i18n.locale}`].replace(/\t/g, "    ").replace(/\r?\n/g, "<br>") : ""
                }, null, 8, ["innerHTML"]),
                createVNode("span", { class: "sm:mt-2 mt-1 text-sm flex items-center group-hover:text-blue-600 transition-colors duration-500" }, [
                  createTextVNode(
                    toDisplayString(_ctx.$t("Read more")) + " ",
                    1
                    /* TEXT */
                  ),
                  createVNode(
                    "span",
                    { class: "material-symbols-rounded text-base h-5" },
                    toDisplayString(_ctx.$i18n.locale === "en" ? "arrow_right_alt" : "arrow_left_alt"),
                    1
                    /* TEXT */
                  )
                ])
              ])
            ];
          }
        }),
        _: 2
        /* DYNAMIC */
      }, _parent));
      _push(`</div>`);
    });
    _push(`<!--]--></div><!-- <div class="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 lg:gap-6 gap-4">
        <div v-for="(item, index) in allData" :key="index" class="border border-solid border-[#F1F3F7] rounded-lg" style="box-shadow: 0px 1px 4px 0px #19213D14;">
          <div @click="goToupdateDetails(item)" class="cursor-pointer">
            <img :src="item.image" class="rounded-tl-lg rounded-tr-lg w-full md:h-[270px] h-[200px] bg-cover" :alt="item[\`title_\${$i18n.locale}\`]">
            <div class="xl:p-6 p-4">
              <p class="text-liberty-blue font-medium lg:text-xl text-lg">{{ item[\`title_\${$i18n.locale}\`] }}</p>
              <p class="md:mb-4 mb-2 md:mt-2 text-rainmaker text-sm font-light">{{ item.created }}</p>
              <p class="lg:text-base text-sm text-rainmaker ellipsis-5" v-html="item[\`content_\${$i18n.locale}\`] ? item[\`content_\${$i18n.locale}\`].replace(/\\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;').replace(/\\r?\\n/g, '<br>') : ''"></p>
            </div>
          </div>
        </div>
      </div> -->`);
    if ($data.allUpdates.next_page_url) {
      _push(`<button class="flex items-center gap-2 m-auto mt-6"><span>${ssrInterpolate(_ctx.$t("Load More"))}</span><span class="material-symbols-rounded text-xl">south</span></button>`);
    } else {
      _push(`<!---->`);
    }
    _push(`</div>`);
  } else {
    _push(`<!---->`);
  }
  _push(`</div>`);
}
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/views/UpdatesPage.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const UpdatesPage = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);
export {
  UpdatesPage as default
};
