<script setup>
  import { ref, onMounted, computed } from "vue";

  import { useMenuStore } from '../../stores/MenuStore';
  const MenuStore = useMenuStore();
  MenuStore.get_today();


  import EventListingComplete from '../listings/EventListingComplete.vue';
  import MiniEventListing from '../listings/EventListing.vue';
  import Promo from '../listings/BlueskyLinks.vue';
  // import Promo from '../listings/Promo.vue';

  import { useEventsStore } from '../../stores/EventsStore';

  const props = defineProps({
        limit: {
            type: Number,
            require: false
        },
        
        cal: {
          type: String,
          require: true
        }
    })

  const store = useEventsStore();
  store.fetchEvents();
  store.fetchPromo();
  const events = computed(() => {
    return store.events;
  });
  const promo = computed(() => {
    return store.promo;
  });

  

</script>
        
<template>
  <div v-if="limit > 0" class="md:justify-center lg:justify-center z-0">
    <span class="self-stretch" v-for="(item, index) in events.slice(0,limit)">
      <Promo  v-if="(index % 6 == 0) && index != 0 && events.length > 12 && limit > 12" :item = promo[(index/6)-1] :index = "(index/6)-1"/>
      <MiniEventListing v-else-if="(index % 6 != 0)" :item = "item" :index = "index" />
    </span>
  </div>
</template>