"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const styles_1 = require("@mui/material/styles");
const material_1 = require("@mui/material");
const system_1 = require("@mui/system");
const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
const PREFIX = 'SCConsentSolutionSwitch';
const classes = {
    root: `${PREFIX}-root`,
    thumb: `${PREFIX}-thumb`,
    thumbChecked: `${PREFIX}-thumb-checked`,
    thumbUnChecked: `${PREFIX}-thumb-unchecked`,
    thumbLoader: `${PREFIX}-thumb-loader`
};
const Root = (0, styles_1.styled)(material_1.Switch, {
    name: PREFIX,
    slot: 'Root',
    overridesResolver: (props, styles) => [styles.root]
})(({ theme }) => ({
    width: 64,
    height: 31,
    padding: 0,
    [`& .${classes.thumb}`]: {
        boxShadow: theme.shadows[1],
        backgroundColor: 'currentColor',
        width: 25,
        height: 25,
        borderRadius: '50%'
    },
    [`& .${classes.thumbChecked}`]: {
        position: 'relative',
        color: theme.palette.primary.main,
        fontSize: '1.2rem',
        top: 5,
        left: 5
    },
    [`& .${classes.thumbUnChecked}`]: {
        position: 'relative',
        color: theme.palette.grey[500],
        fontSize: '1.2rem',
        top: 4,
        left: 5
    },
    [`& .${classes.thumbLoader}`]: {
        position: 'relative',
        left: 5,
        top: 5,
        color: theme.palette.primary.main
    },
    '&:focus': {
        outlineWidth: '2px!important',
        outlineStyle: 'solid!important',
        outlineColor: `${theme.palette.info.main}!important`,
        outlineOffset: '2px!important',
        borderRadius: 32
    },
    '& .MuiSwitch-switchBase': {
        padding: 0,
        margin: 3,
        transitionDuration: '300ms',
        '& + .MuiSwitch-track': {
            backgroundColor: theme.palette.mode === 'dark' ? theme.palette.grey[700] : theme.palette.grey[300]
        },
        '&.Mui-checked': {
            transform: 'translateX(32px)',
            color: '#fff',
            '& + .MuiSwitch-track': {
                backgroundColor: theme.palette.primary.main,
                opacity: 1,
                border: 0
            },
            '&.Mui-disabled + .MuiSwitch-track': {
                opacity: 0.5
            }
        },
        '&.Mui-focusVisible .MuiSwitch-thumb': {
            color: theme.palette.primary.main,
            border: '6px solid #fff'
        },
        '&.Mui-disabled .MuiSwitch-thumb': {
            color: theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[600]
        },
        '&.Mui-disabled + .MuiSwitch-track': {
            opacity: theme.palette.mode === 'light' ? 0.7 : 0.3
        }
    },
    '& .MuiSwitch-thumb': {
        boxSizing: 'border-box',
        width: 26,
        height: 26,
        '&:before': {
            content: "''",
            position: 'absolute',
            width: '100%',
            height: '100%',
            left: 0,
            top: 0,
            backgroundRepeat: 'no-repeat',
            backgroundPosition: 'center'
        }
    },
    '& .MuiSwitch-track': {
        borderRadius: 32 / 2,
        backgroundColor: theme.palette.mode === 'dark' ? theme.palette.grey[700] : theme.palette.grey[300],
        opacity: 1,
        transition: theme.transitions.create(['background-color'], {
            duration: 500
        })
    }
}));
/**
 * > API documentation for the Community-JS ConsentSolutionSwitch component. Learn about the available props and the CSS API.

 #### Import

 ```jsx
 import {ConsentSolutionSwitch} from '@selfcommunity/react-ui';
 ```

 #### Component Name

 The name `SCConsentSolutionSwitch` can be used when providing style overrides in the theme.


 #### CSS

 |Rule Name|Global class|Description|
 |---|---|---|
 |root|.SCConsentSolutionSwitch-root|Styles applied to the root element.|
 |thumb|.SCConsentSolutionSwitch-thumb|Styles applied to the thumb element.|
 |thumbChecked|.SCConsentSolutionSwitch-thumb|Styles applied to the checked icon element.|
 |thumbUnChecked|.SCConsentSolutionSwitch-thumb-checked|Styles applied to the unchecked icon element.|
 |thumbLoading|.SCConsentSolutionSwitch-thumb-unchecked|Styles applied to the loading icon element.|

 * @param inProps
 */
function ConsentSolutionSwitch(inProps) {
    //PROPS
    const props = (0, system_1.useThemeProps)({
        props: inProps,
        name: PREFIX
    });
    const { loading } = props, rest = tslib_1.__rest(props, ["loading"]);
    // Icon loading state
    const IconLoading = () => ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: classes.thumb }, { children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 14, className: classes.thumbLoader }) })));
    // Icon checked state
    const IconChecked = () => ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: classes.thumb }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, Object.assign({ className: classes.thumbChecked }, { children: "check_outlined" })) })));
    // Icon unchecked state
    const IconUnChecked = () => ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: classes.thumb }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, Object.assign({ className: classes.thumbUnChecked }, { children: "close" })) })));
    return (0, jsx_runtime_1.jsx)(Root, Object.assign({}, rest, { checkedIcon: loading ? (0, jsx_runtime_1.jsx)(IconLoading, {}) : (0, jsx_runtime_1.jsx)(IconChecked, {}), icon: loading ? (0, jsx_runtime_1.jsx)(IconLoading, {}) : (0, jsx_runtime_1.jsx)(IconUnChecked, {}) }));
}
exports.default = ConsentSolutionSwitch;
