"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const components_1 = require("../../components/index.js");
const locationContext_1 = require("../../gravity-blocks/context/locationContext/index.js");
const theme_1 = require("../../gravity-blocks/context/theme/index.js");
const grid_1 = require("../../gravity-blocks/grid/index.js");
const hooks_1 = require("../../gravity-blocks/hooks/index.js");
const utils_1 = require("../../utils/index.js");
const b = (0, utils_1.block)('icons-block');
const getItemContent = (item) => ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Image, { className: b('image'), src: item.src }), (0, jsx_runtime_1.jsx)("p", { className: b('text'), children: item.text })] }));
const Icons = ({ title, description, size = 's', colSizes = { all: 12 }, items }) => {
    const { hostname } = React.useContext(locationContext_1.LocationContext);
    const handleAnalytics = (0, hooks_1.useAnalytics)();
    const theme = (0, theme_1.useTheme)();
    const onClick = React.useCallback(({ analyticsEvents, url }) => {
        handleAnalytics(analyticsEvents, { url });
    }, [handleAnalytics]);
    return ((0, jsx_runtime_1.jsx)(grid_1.Grid, { children: (0, jsx_runtime_1.jsxs)("div", { className: b({ size }), children: [(title || description) && ((0, jsx_runtime_1.jsx)(components_1.Title, { className: b('header'), title: title, subtitle: description, colSizes: colSizes })), items &&
                    items.map((item) => {
                        const themedSrc = (0, utils_1.getThemedValue)(item.src, theme);
                        const itemContent = getItemContent({ ...item, src: themedSrc });
                        const { url, text } = item;
                        return url ? ((0, jsx_runtime_1.jsx)("a", { className: b('item'), href: url, "aria-label": text, title: text, ...(0, utils_1.getLinkProps)(url, hostname), onClick: () => onClick(item), children: itemContent }, url)) : ((0, jsx_runtime_1.jsx)("div", { className: b('item'), children: itemContent }, text));
                    })] }) }));
};
exports.default = Icons;
//# sourceMappingURL=Icons.js.map
