import { factories } from "@strapi/strapi";

const POPULATE = {
  hero: { populate: { mobileVideoUrl_9x16: true, desktopVideoUrl_16x9: true } },
  about: { populate: { paragraphs: true } },
  rides: {
    populate: {
      categories: { populate: { rides: { populate: { image_3x4: true, video_3x4: true } } } },
    },
  },
  events: { populate: { events: { populate: { image_6x5: true } } } },
  restaurants: { populate: { restaurants: { populate: { image_6x5: true } } } },
  stats: { populate: { stats: { populate: { vector_9x8: true } } } },
};

export default factories.createCoreController("api::entertainment.entertainment", () => ({
  async find(ctx) {
    const data = await strapi
      .documents("api::entertainment.entertainment")!
      .findFirst({ populate: POPULATE });
    return this.transformResponse(data);
  },
}));
