import { jsx, jsxs } from "react/jsx-runtime";
import Accordion from "@mui/material/Accordion";
import AccordionDetails from "@mui/material/AccordionDetails";
import AccordionSummary from "@mui/material/AccordionSummary";
import { styled } from "@mui/material/styles";
import apollo_core, { FontVariantToken, PadL } from "@uipath/apollo-core";
import { ChevronDown } from "../../../icons/index.js";
import { ApTypography } from "../ap-typography/index.js";
const StyledAccordion = styled(Accordion, {
    shouldForwardProp: (prop)=>'accordionPadding' !== prop
})(()=>({
        '&.MuiPaper-root': {
            boxShadow: 'unset'
        },
        position: 'relative',
        '&.Mui-expanded': {
            margin: 0
        },
        '&::before': {
            display: 'none'
        },
        '&:first-of-type .MuiAccordionSummary-root::before': {
            display: 'none'
        }
    }));
const StyledAccordionSummary = styled(AccordionSummary, {
    shouldForwardProp: (prop)=>'disableDivider' !== prop && 'accordionPadding' !== prop && 'dividerLeftPosition' !== prop && 'dividerRightPosition' !== prop && 'expandIconPosition' !== prop
})(({ disableDivider, dividerLeftPosition, dividerRightPosition, expandIconPosition })=>({
        '&:hover, &:focus': {
            backgroundColor: 'transparent'
        },
        '&:focus-visible': {
            zIndex: 1
        },
        flexDirection: 'end' !== expandIconPosition ? 'row-reverse' : 'row',
        padding: `${apollo_core.Padding.PadXl} ${apollo_core.Padding.PadXxxl}`,
        minHeight: apollo_core.Spacing.SpacingXxl,
        position: 'relative',
        '&::before': {
            content: '""',
            position: 'absolute',
            top: 0,
            left: dividerLeftPosition || apollo_core.Padding.PadXxxl,
            right: dividerRightPosition || apollo_core.Padding.PadXxxl,
            height: 1,
            backgroundColor: 'var(--color-border-de-emp)',
            display: disableDivider ? 'none' : 'block',
            pointerEvents: 'none'
        },
        '&.Mui-expanded': {
            minHeight: apollo_core.Spacing.SpacingXxl
        },
        '& .MuiAccordionSummary-content': {
            margin: '0px',
            '&.Mui-expanded': {
                margin: '0px'
            }
        }
    }));
function ApAccordion(props) {
    const { startIcon, label, defaultExpanded, children, expandIconPosition = 'end', labelFontSize, labelFontWeight, labelColor, disableDivider, summarySx, summaryProps, dividerLeftPosition, dividerRightPosition, detailsSx, detailsProps, ...accordionProps } = props;
    return /*#__PURE__*/ jsxs(StyledAccordion, {
        defaultExpanded: defaultExpanded,
        ...accordionProps,
        children: [
            /*#__PURE__*/ jsx(StyledAccordionSummary, {
                sx: summarySx,
                dividerLeftPosition: dividerLeftPosition,
                dividerRightPosition: dividerRightPosition,
                expandIcon: /*#__PURE__*/ jsx(ChevronDown, {
                    size: "20px",
                    style: {
                        marginTop: '-2px'
                    },
                    "aria-hidden": "true"
                }),
                expandIconPosition: expandIconPosition,
                disableDivider: disableDivider,
                ...summaryProps,
                children: /*#__PURE__*/ jsxs(ApTypography, {
                    variant: FontVariantToken.fontSizeM,
                    color: labelColor || 'var(--color-foreground-de-emp)',
                    style: {
                        ...labelFontSize && {
                            fontSize: labelFontSize
                        },
                        ...labelFontWeight && {
                            fontWeight: labelFontWeight
                        },
                        display: 'flex',
                        alignItems: 'center'
                    },
                    children: [
                        startIcon ? /*#__PURE__*/ jsx("span", {
                            style: {
                                display: 'flex',
                                marginRight: PadL
                            },
                            children: startIcon
                        }) : null,
                        label
                    ]
                })
            }),
            /*#__PURE__*/ jsx(AccordionDetails, {
                sx: {
                    padding: 'unset',
                    ...detailsSx
                },
                ...detailsProps,
                children: children
            })
        ]
    });
}
ApAccordion.displayName = 'ApAccordion';
export { ApAccordion };
