import type { StaticImageItem, StaticImageSlot } from "@/lib/meshkee/types"; /** * Slot catalog for Meshkee dashboard import. * If UI image size/aspect changes during development, update these values. */ export const STATIC_IMAGE_SLOT_CATALOG = [ { key: "slider", label: "Homepage slider", kind: "list" as const, pageKey: "home", aspectRatio: "16:9", itemCount: null, recommendedWidth: 1440, }, { key: "categories-icon", label: "Quick category icons", kind: "list" as const, pageKey: "home", aspectRatio: "1:1", itemCount: 6, recommendedWidth: 192, }, { key: "special-sale-banner", label: "Special sale banner", kind: "single" as const, pageKey: "home", aspectRatio: "3:5", itemCount: 1, recommendedWidth: 520, }, { key: "product-features-image", label: "Product features sofa image", kind: "single" as const, pageKey: "home", aspectRatio: "2:1", itemCount: 1, recommendedWidth: 900, }, { key: "contactus-image", label: "Homepage contact guarantee image", kind: "single" as const, pageKey: "home", aspectRatio: "4:5", itemCount: 1, recommendedWidth: 720, }, { key: "two-banner-row", label: "Two banner row", kind: "list" as const, pageKey: "home", aspectRatio: "12:5", itemCount: 2, recommendedWidth: 1200, }, { key: "aboutus-image", label: "Homepage about image", kind: "single" as const, pageKey: "home", aspectRatio: "6:5", itemCount: 1, recommendedWidth: 720, }, { key: "three-banner-row", label: "Three banner row", kind: "list" as const, pageKey: "home", aspectRatio: "12:5", itemCount: 3, recommendedWidth: 1200, }, { key: "about-us-image", label: "About page images", kind: "list" as const, pageKey: "about", aspectRatio: "6:5", itemCount: 2, recommendedWidth: 720, }, ]; export function findSlot( slots: StaticImageSlot[], key: string, ): StaticImageSlot | undefined { return slots.find((slot) => slot.key === key); } export function slotImages( slots: StaticImageSlot[], key: string, ): StaticImageItem[] { const slot = findSlot(slots, key); if (!slot?.images?.length) return []; if (slot.kind === "single") { return slot.images[0]?.url ? [slot.images[0]] : []; } return slot.images.filter((image) => Boolean(image?.url)); } export function firstSlotImage( slots: StaticImageSlot[], key: string, ): StaticImageItem | null { return slotImages(slots, key)[0] ?? null; } export function imageTitleFa(image: StaticImageItem | null | undefined): string { return image?.titleFa?.trim() || image?.title?.trim() || ""; } export function imageTitleEn(image: StaticImageItem | null | undefined): string { return image?.titleEn?.trim() || ""; } export function imageSubtext(image: StaticImageItem | null | undefined): string { return image?.subtext?.trim() || ""; }