<script setup lang="ts">
import { SplideSlide } from '@splidejs/vue-splide'
import {
  hasComponentGroup,
  getComponentGroup,
  getComponentGroupAry,
} from '#layers/utils/dataUtil'

interface Props {
  components: Record<string, any>
  pageVerTmplSeq: string
}

const props = defineProps<Props>()
</script>

<template>
  <section class="relative h-[640px] md:h-[1000px]">
    <BlocksSlideFade
      v-if="props.components?.group_sets"
      :arrows="true"
      :pagination="true"
      class="h-full"
    >
      <SplideSlide
        v-for="(item, index) in props.components.group_sets"
        :key="index"
      >
        <WidgetsBackground
          v-if="hasComponentGroup(item, 'background')"
          :resources-data="getComponentGroup(item, 'background')"
        />
        <div
          class="relative h-full flex flex-col items-center justify-center gap-[14px] text-center md:gap-5"
        >
          <WidgetsSubTitle
            v-if="hasComponentGroup(item, 'subTitle')"
            :resources-data="getComponentGroup(item, 'subTitle')"
            class="line-clamp-2 text-[16px] font-[500] leading-[24px] md:line-clamp-1 md:text-[24px] md:leading-[34px]"
          />
          <WidgetsMainTitle
            v-if="hasComponentGroup(item, 'mainTitle')"
            :resources-data="getComponentGroup(item, 'mainTitle')"
            class="line-clamp-3 text-[24px] font-[700] leading-[34px] md:text-[50px] md:leading-[70px]"
          />
          <WidgetsDescription
            v-if="hasComponentGroup(item, 'description')"
            :resources-data="getComponentGroup(item, 'description')"
            class="line-clamp-3 text-[15px] font-[400] leading-[24px] md:text-[20px] md:leading-[30px]"
          />
          <WidgetsButtonList
            v-if="hasComponentGroup(item, 'buttonList')"
            :groups-data="getComponentGroupAry(item, 'buttonList')"
          />
        </div>
      </SplideSlide>
    </BlocksSlideFade>
  </section>
</template>
