/**
 * CMS ELEMENT: cross-selling
 * Shopware element type `cross-selling` — the cross-selling tabs/slider on a
 * product detail CMS layout. Reads resolved cross-selling groups from
 * `slot.data.crossSellings` and reuses the PDP cross-selling component.
 */

import ProductCrossSelling from '@/components/product/ProductCrossSelling';
import type { CrossSelling } from '@/lib/shopware-api';
import type { CmsSlot } from '@/components/cms/types';

export default function CmsElementCrossSelling({ slot }: { slot: CmsSlot }) {
  const raw = slot.data?.crossSellings;
  const crossSellings: CrossSelling[] = Array.isArray(raw) ? raw : raw?.elements ?? [];
  if (crossSellings.length === 0) return null;
  return <ProductCrossSelling crossSellings={crossSellings} />;
}
