"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get tourCardConfig () {
        return tourCardConfig;
    },
    get tourCardRoot () {
        return tourCardRoot;
    }
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _Icon = require("../../../_Icon");
const _classnames = /*#__PURE__*/ _interop_require_default(require("classnames"));
const _base = require("./variations/_view/base");
const _base1 = require("./variations/_size/base");
const _Cardstyles = require("./Card.styles");
const _Cardtokens = require("./Card.tokens");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const tourCardRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ view, size, image, title, description, orientation = 'horizontal', showPagination = true, stepCurrent = 0, stepLength = 0, actionButtons, skipButton, showClose = true, goToStep, onClose, style, className, ...rest }, outerRef)=>{
        // Если показан только текст, то к нему добавляется отступ снизу для компенсации.
        const onlyText = !showPagination && !actionButtons && !skipButton;
        const dotOnClick = (index)=>{
            if (goToStep) {
                goToStep(index);
            }
        };
        return /*#__PURE__*/ _react.default.createElement(Root, {
            ref: outerRef,
            view: view,
            size: size,
            ...rest
        }, /*#__PURE__*/ _react.default.createElement(_Cardstyles.TourCard, {
            className: (0, _classnames.default)(className, _Cardtokens.classes.card),
            style: style,
            orientation: orientation
        }, showClose && /*#__PURE__*/ _react.default.createElement(_Cardstyles.CloseButton, {
            onClick: onClose
        }, /*#__PURE__*/ _react.default.createElement(_Icon.IconClose, {
            size: "xs",
            color: "inherit"
        })), image && /*#__PURE__*/ _react.default.createElement(_Cardstyles.Img, {
            ...image,
            orientation: orientation
        }), /*#__PURE__*/ _react.default.createElement(_Cardstyles.CardBody, {
            orientation: orientation
        }, /*#__PURE__*/ _react.default.createElement(_Cardstyles.CardText, {
            onlyText: onlyText
        }, /*#__PURE__*/ _react.default.createElement(_Cardstyles.Title, {
            className: _Cardtokens.classes.title
        }, title), /*#__PURE__*/ _react.default.createElement(_Cardstyles.Description, {
            className: _Cardtokens.classes.description
        }, description)), /*#__PURE__*/ _react.default.createElement(_Cardstyles.Controls, {
            orientation: orientation
        }, showPagination && /*#__PURE__*/ _react.default.createElement(_Cardstyles.DotsContainer, {
            orientation: orientation,
            className: _Cardtokens.classes.pagination
        }, Array(stepLength).fill(null).map((_, index)=>/*#__PURE__*/ _react.default.createElement(_Cardstyles.Dot, {
                key: index,
                isActive: stepCurrent === index,
                onClick: ()=>dotOnClick(index)
            }))), actionButtons && /*#__PURE__*/ _react.default.createElement(_Cardstyles.ActionButtonsContainer, {
            orientation: orientation,
            className: _Cardtokens.classes.actionButtons
        }, actionButtons), skipButton && /*#__PURE__*/ _react.default.createElement(_Cardstyles.SkipButtonContainer, {
            orientation: orientation,
            className: _Cardtokens.classes.skipButton
        }, skipButton)))));
    });
const tourCardConfig = {
    name: 'Tour',
    tag: 'div',
    layout: tourCardRoot,
    base: '',
    variations: {
        view: {
            css: _base.base
        },
        size: {
            css: _base1.base
        }
    },
    defaults: {
        view: 'default',
        size: 's'
    }
};
