'use strict';

var tslib_es6 = require('./tslib.es6-2c2ed574.js');
var React = require('react');
var core = require('@mantine/core');
var index$1 = require('./index-a31ed3e1.js');
var index = require('./index-3643ff1b.js');
var miscTheme = require('./miscTheme.js');

function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

const Spoiler = (_a) => {
    var { children, line, lineHeight, trackingAttributes, maxHeight: _maxHeight, customExpandFn } = _a, rest = tslib_es6.__rest(_a, ["children", "line", "lineHeight", "trackingAttributes", "maxHeight", "customExpandFn"]);
    const { t } = index.useTranslations();
    const maxHeight = React.useMemo(() => {
        if (_maxHeight)
            return _maxHeight;
        if (line && lineHeight)
            return line * lineHeight;
        console.error('[HHG-Comp]:[Spoiler] Please provide maxHeight, or line with lineHeight');
        return 0;
    }, []);
    if (!children)
        console.error('[HHG-Comp]:[Spoiler] Please provide children');
    const gaAttributes = React.useMemo(() => {
        if (trackingAttributes) {
            return {
                'data-event-category': trackingAttributes.dataEventCategory,
                'data-event-action': trackingAttributes.dataEventAction,
                'data-event-label': trackingAttributes.dataEventLabel,
            };
        }
        else {
            return {};
        }
    }, [trackingAttributes]);
    return (React__default["default"].createElement(core.Spoiler, Object.assign({ showLabel: React__default["default"].createElement(index$1.Text, Object.assign({ size: "p3", color: miscTheme.theme.colors.primaryBase }, gaAttributes, { onClick: customExpandFn }), t('articlePage.readMore')), hideLabel: React__default["default"].createElement(index$1.Text, Object.assign({ size: "p3", color: miscTheme.theme.colors.primaryBase }, gaAttributes), t('articlePage.showLess')) }, rest, { maxHeight: maxHeight }), children));
};

exports.Spoiler = Spoiler;
