import __nuxt_component_0$2 from './InternalHeaderSection-DIj5MLKD.mjs';
import { defineComponent, computed, ref, resolveComponent, mergeProps, unref, withCtx, createTextVNode, toDisplayString, createVNode, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderComponent, ssrRenderList, ssrIncludeBooleanAttr, ssrInterpolate } from 'vue/server-renderer';
import { d as useI18n, e as useSeoMeta, a as _export_sfc } from './server.mjs';
import { _ as _sfc_main$9, a as __nuxt_component_1 } from './TestimonialsCard-en9WoMcd.mjs';
import _sfc_main$3 from './EmptyState-CWK2sm1Q.mjs';
import { _ as __nuxt_component_5, a as __nuxt_component_4 } from './ArrowLeftIcon-Dfw2cv7V.mjs';
import { _ as _sfc_main$4 } from './index-m9AqQ9dr.mjs';
import __nuxt_component_6 from './Spacer-DtCydRp3.mjs';
import __nuxt_component_0$1 from './Contact-Ik5xD7tN.mjs';
import { u as useSocialIconsQuery, b as useCountriesQuery, a as useServicesQuery } from './contact-k0MTtZDV.mjs';
import { u as useGlobalTestimonialsQuery } from './testimonials-COgXn_Zu.mjs';
import { u as useBranches } from './useBranches-BHivqtZy.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 './Skeleton-CRkCoUmX.mjs';
import './CardTitle-CK392g0A.mjs';
import './CardDescription-SL_8-N0k.mjs';
import 'class-variance-authority';
import './SectionHeadline-0zkilFRp.mjs';
import './ContactIcon-CO7vyUaQ.mjs';
import './Form-BItdTITZ.mjs';
import './useUtmPayload-DlQ2OH8k.mjs';
import 'vee-validate';
import './index-Cce4iXMN.mjs';
import './index-B_IDLhd1.mjs';
import './FormLabel-PCaiHQXT.mjs';
import './PopoverTrigger-D3Tywx5m.mjs';
import './FlagComponent-tWUs0Zo0.mjs';
import './Textarea-D5DXsU7G.mjs';
import '@vee-validate/zod';
import 'base-vue-phone-input';
import 'zod';
import './useApi-Dv-cyvzn.mjs';
import 'axios';
import 'vue-sonner';
import './BrancheCard-DdXAv4Sd.mjs';
import './fetch-C0COJdJ7.mjs';
import '@vue/shared';
import './asyncData-t1m_EyLu.mjs';

const _sfc_main$2 = {};
function _sfc_ssrRender(_ctx, _push, _parent, _attrs) {
  const _component_InternalHeaderSection = __nuxt_component_0$2;
  _push(ssrRenderComponent(_component_InternalHeaderSection, mergeProps({
    pages: [{ name: _ctx.$t("testimonials") }],
    "video-url": "/videos/testimonials-hero.mp4"
  }, _attrs), {
    title: withCtx((_, _push2, _parent2, _scopeId) => {
      if (_push2) {
        _push2(`<h1${_scopeId}>${ssrInterpolate(_ctx.$t("testimonailsHero.title"))}</h1>`);
      } else {
        return [
          createVNode("h1", null, toDisplayString(_ctx.$t("testimonailsHero.title")), 1)
        ];
      }
    }),
    _: 1
  }, _parent));
}
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/testimonials/TestimonialHero.vue");
  return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
};
const __nuxt_component_0 = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["ssrRender", _sfc_ssrRender]]);
const pageSize = 9;
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "TestimonialSection",
  __ssrInlineRender: true,
  setup(__props) {
    const { state: testimonials } = useGlobalTestimonialsQuery();
    const { branches, isLoading } = useBranches();
    const { data: socialIcons } = useSocialIconsQuery();
    const { data: countries } = useCountriesQuery();
    const { data: services } = useServicesQuery();
    const currentPage = ref(1);
    const totalPages = computed(() => {
      if (!testimonials.value.data) return 1;
      return Math.ceil(testimonials.value.data.length / pageSize);
    });
    const paginatedTestimonials = computed(() => {
      if (!testimonials.value.data) return [];
      const start = (currentPage.value - 1) * pageSize;
      return testimonials.value.data.slice(start, start + pageSize);
    });
    function goToPage(page) {
      if (page >= 1 && page <= totalPages.value) {
        currentPage.value = page;
      }
      const testimonialsSection = (void 0).getElementById("testimonials-section");
      testimonialsSection == null ? void 0 : testimonialsSection.scrollIntoView({ behavior: "smooth" });
    }
    const playingId = ref(null);
    const cardResetTokens = ref({});
    const incResetToken = (id) => {
      const key = String(id);
      cardResetTokens.value[key] = (cardResetTokens.value[key] || 0) + 1;
    };
    const handlePlay = (id) => {
      if (playingId.value !== null && playingId.value !== id) {
        incResetToken(playingId.value);
      }
      playingId.value = id;
    };
    const handlePause = (id) => {
      if (playingId.value === id) {
        playingId.value = null;
      }
    };
    return (_ctx, _push, _parent, _attrs) => {
      const _component_SkeletonsTestimonialCardSkeleton = _sfc_main$9;
      const _component_EmptyState = _sfc_main$3;
      const _component_TestimonialsCard = __nuxt_component_1;
      const _component_SvgArrowRightIcon = __nuxt_component_5;
      const _component_Button = _sfc_main$4;
      const _component_SvgArrowLeftIcon = __nuxt_component_4;
      const _component_Spacer = __nuxt_component_6;
      const _component_SkeletonsContactSkeleton = resolveComponent("SkeletonsContactSkeleton");
      const _component_Contact = __nuxt_component_0$1;
      _push(`<section${ssrRenderAttrs(mergeProps({
        id: "testimonials-section",
        class: "bg-gradient-odd py-section"
      }, _attrs))}><div class="container mx-auto px-4">`);
      if (unref(testimonials).status === "pending") {
        _push(`<div class="grid grid-cols-1 gap-10 md:grid-cols-2 lg:grid-cols-3"><!--[-->`);
        ssrRenderList(6, (i) => {
          _push(ssrRenderComponent(_component_SkeletonsTestimonialCardSkeleton, { key: i }, null, _parent));
        });
        _push(`<!--]--></div>`);
      } else if (unref(testimonials).status === "error" || unref(testimonials).data.length === 0) {
        _push(`<div class="container mx-auto flex items-center justify-center">`);
        _push(ssrRenderComponent(_component_EmptyState, null, null, _parent));
        _push(`</div>`);
      } else {
        _push(`<div class="grid grid-cols-1 gap-10 md:grid-cols-2 lg:grid-cols-3"><!--[-->`);
        ssrRenderList(unref(paginatedTestimonials), (testimonial) => {
          _push(ssrRenderComponent(_component_TestimonialsCard, {
            id: testimonial.id,
            key: testimonial.id,
            "full-name": testimonial.full_name,
            "job-position": testimonial.job_position,
            image: testimonial.image,
            "audio-url": testimonial.audio_url,
            "video-url": testimonial.video_url,
            comment: testimonial.comment,
            "video-reset-token": unref(cardResetTokens)[String(testimonial.id)] || 0,
            "audio-reset-token": unref(cardResetTokens)[String(testimonial.id)] || 0,
            onPlay: ($event) => handlePlay(testimonial.id),
            onPause: ($event) => handlePause(testimonial.id)
          }, null, _parent));
        });
        _push(`<!--]--></div>`);
      }
      if (unref(totalPages) > 1) {
        _push(`<div class="mt-8 flex items-center justify-center gap-2"><button class="mx-2 cursor-pointer"${ssrIncludeBooleanAttr(unref(currentPage) === 1) ? " disabled" : ""}>`);
        _push(ssrRenderComponent(_component_SvgArrowRightIcon, { class: "h-5 w-5" }, null, _parent));
        _push(`</button><!--[-->`);
        ssrRenderList(unref(totalPages), (page) => {
          _push(ssrRenderComponent(_component_Button, {
            key: page,
            class: "cursor-pointer rounded px-3 py-1",
            variant: page === unref(currentPage) ? "wsGradient" : "link",
            size: "icon",
            onClick: ($event) => goToPage(page)
          }, {
            default: withCtx((_, _push2, _parent2, _scopeId) => {
              if (_push2) {
                _push2(`${ssrInterpolate(page)}`);
              } else {
                return [
                  createTextVNode(toDisplayString(page), 1)
                ];
              }
            }),
            _: 2
          }, _parent));
        });
        _push(`<!--]--><button class="mx-2 cursor-pointer"${ssrIncludeBooleanAttr(unref(currentPage) === unref(totalPages)) ? " disabled" : ""}>`);
        _push(ssrRenderComponent(_component_SvgArrowLeftIcon, { class: "h-5 w-5" }, null, _parent));
        _push(`</button></div>`);
      } else {
        _push(`<!---->`);
      }
      _push(ssrRenderComponent(_component_Spacer, null, null, _parent));
      _push(`<div>`);
      if (unref(isLoading) || !unref(socialIcons) || !unref(countries) || !unref(services)) {
        _push(ssrRenderComponent(_component_SkeletonsContactSkeleton, null, null, _parent));
      } else {
        _push(ssrRenderComponent(_component_Contact, {
          "social-icons": unref(socialIcons),
          branches: unref(branches),
          countries: unref(countries),
          services: unref(services),
          "form-title": _ctx.$t("contactSection.title")
        }, null, _parent));
      }
      _push(`</div></div></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/testimonials/TestimonialSection.vue");
  return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "testimonials",
  __ssrInlineRender: true,
  setup(__props) {
    const { t } = useI18n();
    useSeoMeta({
      title: computed(() => t("testimonialsSeo.title")),
      description: computed(() => t("testimonialsSeo.description")),
      ogTitle: computed(() => t("testimonialsSeo.ogTitle")),
      ogDescription: computed(() => t("testimonialsSeo.ogDescription")),
      keywords: computed(() => t("testimonialsSeo.keywords"))
    });
    return (_ctx, _push, _parent, _attrs) => {
      const _component_TestimonialsTestimonialHero = __nuxt_component_0;
      const _component_TestimonialsTestimonialSection = _sfc_main$1;
      _push(`<main${ssrRenderAttrs(_attrs)}>`);
      _push(ssrRenderComponent(_component_TestimonialsTestimonialHero, null, null, _parent));
      _push(ssrRenderComponent(_component_TestimonialsTestimonialSection, null, null, _parent));
      _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/testimonials.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
//# sourceMappingURL=testimonials-BYYceDTa.mjs.map
