import cx from "classnames"; import React from "react"; import { CLASS_ACCORDION, CLASS_ACCORDION_BODY, CLASS_ACCORDION_BUTTON, CLASS_ACCORDION_HEADER, CLASS_ACCORDION_ICON, CLASS_ACCORDION_ITEM, CLASS_ACCORDION_TITLE, CLASS_CAPTION, CLASS_CARD, CLASS_CONTAINER, CLASS_GRID, CLASS_HIDE_LG_UP, CLASS_HIDE_MD_DOWN, CLASS_MAIN, CLASS_MOBILE_BODY, CLASS_MOBILE_CTA, CLASS_MOBILE_HEADER, CLASS_NAV, CLASS_NAV_BUTTON, CLASS_NAV_BUTTON_INDICATOR, CLASS_NAV_CART_ICON, CLASS_NAV_DROPDOWN, CLASS_NAV_ICON, CLASS_NAV_ICON_CTA, CLASS_NAV_ITEM, CLASS_NAV_ITEM_LEAD, CLASS_NAV_ITEM_MAIN, CLASS_NAV_ITEM_PUSH, CLASS_NAV_LINK, CLASS_NAV_LINK_CTA, CLASS_NAV_LINK_LOCALE, CLASS_NAV_LOCALE, CLASS_NAV_MOBILE_LOCALE, CLASS_NAV_SELECT, CLASS_NAV_SELECT_WRAPPER, CLASS_NAV_SPACE_SMALL, CLASS_NAV_VERTICAL, CLASS_OVERLAY, CLASS_ROOT, CLASS_SPACER, CLASS_SUBNAV, CLASS_SUBNAV_ITEM, CLASS_TAG, CLASS_TAG_ORANGE, CLASS_TAG_SMALL, CLASS_TEXT_LARGE, CLASS_TILE, CLASS_TILE_BODY, CLASS_TILE_CONTENT, CLASS_TILE_LABEL, CLASS_TILES, CLASS_TOP, CLASS_TOP_CONTENT, } from "./constants"; import type { MegamenuTile, MenuItem, MenuSection } from "./data"; import { megamenuTiles, menuSections } from "./data"; import { getMegamenuIds } from "./ids"; import { MegamenuIcon } from "./MegaMenuIcon"; import { MegamenuSearchContent } from "./MegamenuSearchContent"; import { MyOrangeMobilePanel } from "./MyOrangeMobilePanel"; import { getMegamenuSearchState, MegamenuCloseButton, MegamenuLogoLink, MegamenuMobilePanel, MegamenuSearchDropdown, } from "./shared"; export type MegamenuProps = { className?: string; title?: string; notSticky?: boolean; searchEmpty?: boolean; searchFilled?: boolean; compactLogoOnly?: boolean; isB2B?: boolean; /** Controls whether My Orange panel shows logged-in or logged-out content. */ isLoggedIn?: boolean; /** Number of items displayed on the cart badge. Empty cart when omitted or zero. */ cartItems?: number; /** Shows an orange dot for a non-empty cart when item count is unavailable. */ cartHasItems?: boolean; /** Tiles displayed below every desktop and mobile menu section. */ tiles?: MegamenuTile[]; }; const renderMenuItems = (items: MenuItem[]) => ( <> {items.map((item) => (
  • {item.label} {item.tag ? ( {item.tag} ) : null}
  • ))} ); const renderMenuTiles = (tiles: MegamenuTile[]) => (
    {tiles.map((tile, index) => { const isActive = tile.isActive ?? index === 0; return (
    ); })}
    ); const renderMenuSectionGrid = ( section: MenuSection, idPrefix: string, captionClass: string, mergeColumnsToSingleCard = false, tiles: MegamenuTile[] = megamenuTiles, tilesBeforeGrid = false, ) => { const featuredHeadingId = `${idPrefix}-${section.id}-${section.featured.id}`; return ( <>
    {tilesBeforeGrid ? renderMenuTiles(tiles) : null}

    {section.featured.heading}

    {mergeColumnsToSingleCard ? (
    {section.columns.flat().map((group) => { const headingId = `${idPrefix}-${section.id}-${group.id}-heading`; return (

    {group.heading}

      {renderMenuItems(group.items)}
    ); })}
    ) : ( section.columns.map((groups, columnIndex) => (
    {groups.map((group) => { const headingId = `${idPrefix}-${section.id}-${group.id}-heading`; return (

    {group.heading}

      {renderMenuItems(group.items)}
    ); })}
    )) )}
    {!tilesBeforeGrid ? renderMenuTiles(tiles) : null} ); }; export const Megamenu = ({ className, title = "Človek", notSticky = false, searchEmpty, searchFilled, compactLogoOnly = false, isB2B = false, isLoggedIn = true, cartItems, cartHasItems = false, tiles = megamenuTiles, }: MegamenuProps) => { const ids = getMegamenuIds("main"); const { hasSearchEmpty, hasSearchFilled, showSearchState, searchValue } = getMegamenuSearchState(searchEmpty, searchFilled); const hasCartItems = cartItems !== undefined && cartItems > 0; const showCartDot = cartHasItems && !hasCartItems; return (
    ); };