<template>
  <section>
    <ModuleTitle :title="recommendTheme.themeName" />

    <div
      class="mt-[4px] mb-[6px] mr-[-12px] pr-[12px] flex gap-[8px] overflow-x-auto whitespace-nowrap scrollbar-none [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden">
      <div class="w-[128px] shrink-0 bg-white rounded-[20px]" v-for="(item, index) in recommendTheme.recommendPostsList"
        :key="index" @click="sendReply(item)">
        <div class="m-[4px] relative">
          <img class="w-[120px] h-[120px] object-cover rounded-[16px] relative z-10" :src="item.coverPhoto" />

          <div
            class="w-[96px] h-[96px] bg-ink-200 rounded-[16px] absolute bottom-[-4px] left-[50%] transform translate-x-[-50%] z-1">
          </div>
        </div>

        <div class="p-[4px_8px_8px]">
          <div class="text-[11px] text-ink-400 truncate">
            {{ item.topic }}
          </div>
        </div>
      </div>
    </div>
  </section>
</template>

<script setup>
import { defineProps } from "vue";
import { emitter } from '@/utils/events'
import { SEND_MESSAGE_CONTENT_TEXT, SEND_MESSAGE_COMMAND_TYPE } from "@/constants/constant";
import ModuleTitle from "@/components/ModuleTitle/index.vue";

const props = defineProps({
  recommendTheme: {
    type: Object,
    default: {},
  },
});

const sendReply = (item) => {
  if (item.userInputContentType && item.userInputContentType === '1') {
    const commonItem = { type: item.userInputContent, title: item.topic }
    emitter.emit(SEND_MESSAGE_COMMAND_TYPE, commonItem);
    return;
  }
  emitter.emit(SEND_MESSAGE_CONTENT_TEXT, item.userInputContent);
};
</script>
