"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
            t[p[i]] = s[p[i]];
    return t;
};
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importStar(require("react"));
const Box_1 = require("../../Box");
const Flex_1 = require("../../Flex");
const Heading_1 = require("../../Heading");
const Paragraph_1 = require("../../Paragraph");
const icons_1 = require("../../../assets/images/icons");
const Context_1 = require("../../RadioGroup/Context");
const sc = __importStar(require("./styles"));
exports.CardRadio = props => {
    const { heading, description, Asset, checked: checkedProp, name: nameProp } = props, otherProps = __rest(props, ["heading", "description", "Asset", "checked", "name"]);
    const radioGroup = react_1.useContext(Context_1.Context);
    let inputProps;
    let checked = checkedProp;
    let name = nameProp;
    if (radioGroup) {
        const { value, name: radioGroupName } = radioGroup, radioGroupOtherProps = __rest(radioGroup, ["value", "name"]);
        if (typeof checked === 'undefined') {
            checked = radioGroup.value === props.value;
        }
        if (typeof name === 'undefined') {
            name = radioGroupName;
        }
        inputProps = radioGroupOtherProps;
    }
    return (react_1.default.createElement("label", null,
        react_1.default.createElement(sc.Input, Object.assign({ type: "radio", checked: checked, name: name }, inputProps, otherProps)),
        react_1.default.createElement(sc.Card, { boxShadow: 1, p: 0, rounded: true },
            react_1.default.createElement(Flex_1.Flex, { p: "m", alignItems: "flex-start" },
                react_1.default.createElement(sc.RadioIcon, { Asset: icons_1.SvgCheckmark, scale: 0.9, width: 20, height: 20, color: "white", checked: checked }),
                react_1.default.createElement(Box_1.Box, { ml: "m", mr: "auto" },
                    react_1.default.createElement(Heading_1.Heading, { variant: "h5", mb: 0, mt: -1 }, heading),
                    react_1.default.createElement(Paragraph_1.Paragraph, { fontSize: 1 }, description)),
                react_1.default.createElement(sc.Media, { Asset: Asset, color: checked ? 'brandMain' : 'gray.2', bg: checked ? 'brandLightest' : 'gray.1', width: 48, height: 48, scale: 0.7 })))));
};
//# sourceMappingURL=CardRadio.js.map