import axios from "axios";
import { mergeProps, useSSRContext, resolveComponent, withCtx, createTextVNode, toDisplayString, reactive } from "vue";
import { useHead } from "@vueuse/head";
import { R as RequestOffer, M as Modules } from "./chunk-KgNpQYeb.js";
import { ssrRenderAttrs, ssrInterpolate, ssrRenderList, ssrRenderAttr, ssrRenderClass, ssrRenderComponent } from "vue/server-renderer";
import { _ as _export_sfc } from "../entries/pages.mjs";
import { P as Partners } from "./chunk-CTcGLgUu.js";
import { T as Testimonials } from "./chunk-CCuwbXH_.js";
import "@vue/server-renderer";
import "vue-router";
import "vike/server";
/* empty css               */
/* empty css               */
import "pinia";
import "vue-i18n";
/* empty css               */
/*! src/components/Advantages.vue [vike:pluginModuleBanner] */
const _sfc_main$2 = {
  props: ["advantages", "advantageDesc"]
};
function _sfc_ssrRender$2(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  _push(`<div${ssrRenderAttrs(mergeProps({ class: "text-center" }, _attrs))}><p class="font-bold md:text-4xl text-3xl text-liberty-blue">${ssrInterpolate(_ctx.$t("Advantages"))}</p><p class="sm:my-10 my-6 md:text-xl text-rainmaker lg:w-3/4 m-auto">${$props.advantageDesc[`title_${_ctx.$i18n.locale}`] ?? ""}</p><div class="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-4"><!--[-->`);
  ssrRenderList($props.advantages, (advantage, index) => {
    _push(`<div class="ltr:text-left rtl:text-right"><img${ssrRenderAttr("src", advantage.image)} class="block xl:w-16 xl:h-16 md:w-14 md:h-14 w-10 h-10"${ssrRenderAttr("alt", advantage[`slug_${_ctx.$i18n.locale}`])}><p class="my-2 font-semibold xl:text-2xl text-xl text-liberty-blue">${ssrInterpolate(advantage[`title_${_ctx.$i18n.locale}`])}</p><p class="text-rainmaker xl:text-lg text-justify">${(advantage[`content_${_ctx.$i18n.locale}`] ? advantage[`content_${_ctx.$i18n.locale}`].replace(/\t/g, "    ").replace(/\r?\n/g, "<br>") : "") ?? ""}</p></div>`);
  });
  _push(`<!--]--></div></div>`);
}
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("src/components/Advantages.vue");
  return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
};
const Advantages = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["ssrRender", _sfc_ssrRender$2]]);
/*! src/components/SectorServices.vue [vike:pluginModuleBanner] */
const _sfc_main$1 = {
  props: ["sectorsServices"]
};
function _sfc_ssrRender$1(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  _push(`<div${ssrRenderAttrs(_attrs)}><p class="font-bold text-legal-eagle text-3xl text-center sm:mb-10 mb-6">${ssrInterpolate(_ctx.$t("Sectors we serve"))}</p><div class="grid xl:grid-cols-5 lg:grid-cols-4 md:grid-cols-3 grid-cols-2 sm:gap-2 gap-1"><!--[-->`);
  ssrRenderList($props.sectorsServices, (item, index) => {
    _push(`<div><div class="relative rounded overflow-hidden md:h-[230px] h-[200px]"><img${ssrRenderAttr("src", item.image)} class="bg-cover w-full h-full"${ssrRenderAttr("alt", item[`name_${_ctx.$i18n.locale}`])}><div class="absolute inset-0 bg-[rgba(41,45,50,0.6)]"></div><p class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 flex items-center justify-center text-white text-center font-medium sm:p-2 p-1 w-full h-full md:text-lg">${(item[`name_${_ctx.$i18n.locale}`] ? item[`name_${_ctx.$i18n.locale}`].replace(/\t/g, "    ").replace(/\r?\n/g, "<br>") : "") ?? ""}</p></div></div>`);
  });
  _push(`<!--]--></div></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("src/components/SectorServices.vue");
  return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const SectorServices = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["ssrRender", _sfc_ssrRender$1]]);
/*! src/views/NewSectorsPage.vue?vue&type=style&index=0&lang.scss [vike:pluginModuleBanner] */
/*! src/views/NewSectorsPage.vue [vike:pluginModuleBanner] */
const _sfc_main = {
  data() {
    return {
      sector: {},
      tabs: [],
      partners: [],
      sectorsServices: [],
      customersOpinions: [],
      modules: [],
      advantageDesc: {},
      advantages: [],
      contactInfo: {},
      description: {},
      customerOpinionDesc: {},
      loading: false,
      sectorsList: []
    };
  },
  setup() {
    const seoState = reactive({
      title: "",
      meta: []
    });
    useHead(seoState);
    return { seoState };
  },
  watch: {
    "$route.params.slug"(val) {
      if (![this.sector.slug_en, this.sector.slug_ar].includes(val)) {
        this.loadSector();
      }
    },
    async "$i18n.locale"() {
      await this.$router.push({
        name: "sectors-details",
        // 👈 route name
        params: {
          slug: this.sector[`slug_${this.$i18n.locale}`]
        }
      }).catch(() => {
      });
      this.applySeoFromSector();
    }
  },
  methods: {
    applySeoFromSector() {
      var _a, _b, _c, _d, _e;
      const locale = this.$i18n.locale;
      const titleValue = ((_a = this.sector) == null ? void 0 : _a[`meta_title_${locale}`]) || ((_b = this.sector) == null ? void 0 : _b[`name_${locale}`]) || "";
      const descriptionSource = ((_c = this.sector) == null ? void 0 : _c[`meta_description_${locale}`]) || ((_d = this.sector) == null ? void 0 : _d[`content_${locale}`]) || "";
      const description = descriptionSource.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim().slice(0, 160);
      const image = ((_e = this.sector) == null ? void 0 : _e.image) || "";
      const title = titleValue ? `${titleValue} | ValuePlus` : "ValuePlus";
      if (!titleValue && !description && !image) return;
      this.seoState.title = title;
      this.seoState.meta = [
        { name: "description", content: description, key: "description" },
        { itemprop: "name", content: title, key: "itemprop:name" },
        { itemprop: "description", content: description, key: "itemprop:description" },
        { itemprop: "image", content: image, key: "itemprop:image" },
        { property: "og:title", content: title, key: "og:title" },
        { property: "og:description", content: description, key: "og:description" },
        { property: "og:image", content: image, key: "og:image" },
        { name: "twitter:title", content: title, key: "twitter:title" },
        { name: "twitter:description", content: description, key: "twitter:description" },
        { name: "twitter:image", content: image, key: "twitter:image" }
      ];
    },
    async loadSector() {
      this.loading = true;
      try {
        const response = await axios.get("https://admin.valueerp.net/api/sectorsModules");
        this.sectorsList = response.data.data.data;
        this.sector = this.sectorsList.find((element) => [element.slug_en, element.slug_ar].includes(this.$route.params.slug));
        this.applySeoFromSector();
        await this.loadSectorDetails();
      } catch (error) {
      } finally {
      }
    },
    async loadSectorDetails() {
      try {
        const response = await axios.get(`https://admin.valueerp.net/api/sectorSubcategories?category_id=${this.sector.slug_en}`);
        this.tabs = response.data.data.data;
        this.partners = response.data.data.partners;
        this.customersOpinions = response.data.data.sectors_customers_opinions;
        this.modules = response.data.data.sectors_content;
        this.advantageDesc = response.data.data.advantage_desc;
        this.advantages = response.data.data.sectors_advantages;
        this.contactInfo = response.data.data.contact_us_information;
        this.description = response.data.data.request_offer_desc;
        this.customerOpinionDesc = response.data.data.customer_opinion_desc;
        this.sectorsServices = response.data.data.sectors_serves;
        if (typeof window !== "undefined" && window.location.hash) {
          setTimeout(() => {
            this.scrollToSection(window.location.hash);
          }, 500);
        } else {
          this.loading = false;
        }
      } catch (error) {
      } finally {
        this.loading = false;
      }
    },
    scrollToModuleDetails(id) {
      if (typeof document === "undefined") return;
      const element = document.getElementById(id);
      if (element) {
        element.scrollIntoView({
          behavior: "smooth",
          block: "start"
        });
      }
    },
    scrollToSection(hash) {
      if (typeof document === "undefined") return;
      const element = document.querySelector(hash);
      if (element) {
        element.scrollIntoView({
          behavior: "smooth",
          block: "start"
        });
      }
    }
  },
  components: {
    Modules,
    Advantages,
    Partners,
    Testimonials,
    RequestOffer,
    SectorServices
  },
  async serverPrefetch() {
    await this.loadSector();
  },
  created() {
    if (typeof window !== "undefined") {
      this.loadSector();
    }
  }
};
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  var _a, _b, _c;
  const _component_router_link = resolveComponent("router-link");
  const _component_modules = resolveComponent("modules");
  const _component_advantages = resolveComponent("advantages");
  const _component_partners = resolveComponent("partners");
  const _component_testimonials = resolveComponent("testimonials");
  const _component_sector_services = resolveComponent("sector-services");
  const _component_request_offer = resolveComponent("request-offer");
  _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 module-cover pt-48 pb-24 mb-14"><div class="max-w-screen-2xl mx-auto xl:px-20 lg:px-16 md:px-12 sm:px-8 px-6"><div class="text-white text-center"><h1 class="font-bold lg:text-4xl sm:text-3xl text-2xl">${ssrInterpolate($data.sector[`name_${_ctx.$i18n.locale}`])}</h1></div></div></div><div class="bg-white sticky z-[2] top-0 mt-5"><div class="max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6"><div class="flex flex-wrap justify-center py-3"><!--[-->`);
  ssrRenderList($data.sectorsList, (sector, index) => {
    _push(`<div class="${ssrRenderClass(`p-3 cursor-pointer border-solid ${[sector.slug_en, sector.slug_ar].includes(_ctx.$route.params.slug) ? "border-b-2 border-[#122340] text-[#122340]" : "border-b border-[#82828250] text-[#828282]"}`)}">`);
    _push(ssrRenderComponent(_component_router_link, {
      to: `/${_ctx.$i18n.locale}/sectors/${sector["slug_" + _ctx.$i18n.locale]}`
    }, {
      default: withCtx((_, _push2, _parent2, _scopeId) => {
        if (_push2) {
          _push2(`${ssrInterpolate(sector[`name_${_ctx.$i18n.locale}`])}`);
        } else {
          return [
            createTextVNode(
              toDisplayString(sector[`name_${_ctx.$i18n.locale}`]),
              1
              /* TEXT */
            )
          ];
        }
      }),
      _: 2
      /* DYNAMIC */
    }, _parent));
    _push(`<!-- <router-link :to="{ path: \`/\${$i18n.locale}/sectors/\${sector['slug_' + $i18n.locale]}\` }">{{ sector[\`name_\${$i18n.locale}\`] }}</router-link> --></div>`);
  });
  _push(`<!--]--></div></div></div><!-- Sector brief --><div class="mt-10 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6"><div class="grid md:grid-cols-3 grid-cols-1 items-center gap-4"><div class="md:col-span-2 col-span-1 md:order-1 order-2 text-legal-eagle">${((_a = $data.sectorsList.find((sector) => [sector.slug_en, sector.slug_ar].includes(_ctx.$route.params.slug))) == null ? void 0 : _a[`content_${_ctx.$i18n.locale}`]) ?? ""}</div><img class="md:order-2 order-1"${ssrRenderAttr("src", (_b = $data.sectorsList.find((sector) => [sector.slug_en, sector.slug_ar].includes(_ctx.$route.params.slug))) == null ? void 0 : _b.image)}${ssrRenderAttr("alt", (_c = $data.sectorsList.find((sector) => [sector.slug_en, sector.slug_ar].includes(_ctx.$route.params.slug))) == null ? void 0 : _c[`name_${_ctx.$i18n.locale}`])}></div></div><!-- Links --><div class="mt-16 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6"><div class="flex flex-col gap-2"><!--[-->`);
  ssrRenderList($data.tabs, (tab, index) => {
    _push(`<div><a${ssrRenderAttr("href", `#module_${tab.id}`)} class="${ssrRenderClass(`w-full md:text-lg cursor-pointer underline hover:text-[#122340]`)}">${ssrInterpolate(tab[`name_${_ctx.$i18n.locale}`])}</a></div>`);
  });
  _push(`<!--]--></div></div>`);
  if ($data.modules.length > 0) {
    _push(`<div><!--[-->`);
    ssrRenderList($data.modules, (item, index) => {
      _push(`<div>`);
      _push(ssrRenderComponent(_component_modules, {
        id: `module_${item.subCategory_id}`,
        modules: [item],
        class: "pt-20 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6"
      }, null, _parent));
      _push(`</div>`);
    });
    _push(`<!--]--></div>`);
  } else {
    _push(`<!---->`);
  }
  if ($data.advantages.length > 0) {
    _push(ssrRenderComponent(_component_advantages, {
      advantageDesc: $data.advantageDesc,
      advantages: $data.advantages,
      class: "mt-24 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6 overflow-x-hidden"
    }, null, _parent));
  } else {
    _push(`<!---->`);
  }
  if ($data.partners.length > 0) {
    _push(ssrRenderComponent(_component_partners, {
      list: $data.partners,
      title: "Partners of Success",
      class: "mt-24 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6"
    }, null, _parent));
  } else {
    _push(`<!---->`);
  }
  if ($data.customersOpinions.length > 0) {
    _push(ssrRenderComponent(_component_testimonials, {
      customerOpinionDesc: $data.customerOpinionDesc,
      customersOpinions: $data.customersOpinions,
      class: "mt-24 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6"
    }, null, _parent));
  } else {
    _push(`<!---->`);
  }
  if ($data.sectorsServices.length > 0) {
    _push(ssrRenderComponent(_component_sector_services, {
      sectorsServices: $data.sectorsServices,
      class: "mt-24 max-w-screen-2xl mx-auto xl:px-32 lg:px-16 md:px-12 sm:px-8 px-6"
    }, null, _parent));
  } else {
    _push(`<!---->`);
  }
  _push(ssrRenderComponent(_component_request_offer, {
    id: "request-offer",
    description: $data.description,
    contactInfo: $data.contactInfo,
    sectorID: $data.sector.id,
    class: "mt-24"
  }, null, _parent));
  _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/NewSectorsPage.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const NewSectorsPage = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);
export {
  NewSectorsPage as default
};
