"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    FolderSwitcher: ()=>FolderSwitcher
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const AppsRounded_namespaceObject = require("@mui/icons-material/AppsRounded");
var AppsRounded_default = /*#__PURE__*/ __webpack_require__.n(AppsRounded_namespaceObject);
const FolderOutlined_namespaceObject = require("@mui/icons-material/FolderOutlined");
var FolderOutlined_default = /*#__PURE__*/ __webpack_require__.n(FolderOutlined_namespaceObject);
const KeyboardArrowDown_namespaceObject = require("@mui/icons-material/KeyboardArrowDown");
var KeyboardArrowDown_default = /*#__PURE__*/ __webpack_require__.n(KeyboardArrowDown_namespaceObject);
const Box_namespaceObject = require("@mui/material/Box");
var Box_default = /*#__PURE__*/ __webpack_require__.n(Box_namespaceObject);
const ButtonBase_namespaceObject = require("@mui/material/ButtonBase");
var ButtonBase_default = /*#__PURE__*/ __webpack_require__.n(ButtonBase_namespaceObject);
const ClickAwayListener_namespaceObject = require("@mui/material/ClickAwayListener");
var ClickAwayListener_default = /*#__PURE__*/ __webpack_require__.n(ClickAwayListener_namespaceObject);
const Divider_namespaceObject = require("@mui/material/Divider");
var Divider_default = /*#__PURE__*/ __webpack_require__.n(Divider_namespaceObject);
const MenuItem_namespaceObject = require("@mui/material/MenuItem");
var MenuItem_default = /*#__PURE__*/ __webpack_require__.n(MenuItem_namespaceObject);
const MenuList_namespaceObject = require("@mui/material/MenuList");
var MenuList_default = /*#__PURE__*/ __webpack_require__.n(MenuList_namespaceObject);
const Paper_namespaceObject = require("@mui/material/Paper");
var Paper_default = /*#__PURE__*/ __webpack_require__.n(Paper_namespaceObject);
const Popper_namespaceObject = require("@mui/material/Popper");
var Popper_default = /*#__PURE__*/ __webpack_require__.n(Popper_namespaceObject);
const apollo_core_namespaceObject = require("@uipath/apollo-core");
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const index_cjs_namespaceObject = require("../../../../i18n/index.cjs");
const FolderSwitcher = ({ folders, value, onChange, allFoldersLabel, showAllFolders = true })=>{
    const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
    const resolvedAllFoldersLabel = allFoldersLabel ?? _({
        id: 'modelPicker.folderSwitcher.allFolders',
        message: 'All folders'
    });
    const [anchorEl, setAnchorEl] = external_react_default().useState(null);
    const open = !!anchorEl;
    const current = folders.find((f)=>f.id === value);
    const isAll = null == value;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(ButtonBase_default(), {
                onClick: (e)=>setAnchorEl(open ? null : e.currentTarget),
                focusRipple: true,
                "aria-haspopup": "menu",
                "aria-expanded": open,
                sx: {
                    display: 'inline-flex',
                    alignItems: 'center',
                    gap: apollo_core_namespaceObject.PadM,
                    fontSize: 'var(--font-s-bold-size, 12px)',
                    fontWeight: 'var(--font-s-bold-weight, 600)',
                    lineHeight: 'var(--font-s-bold-line-height, 16px)',
                    color: `var(--color-primary, ${apollo_core_namespaceObject.Colors.ColorBlue500})`,
                    backgroundColor: `var(--color-background-raised, ${apollo_core_namespaceObject.Colors.ColorWhite})`,
                    border: '1px solid',
                    borderColor: `var(--color-border-de-emp, ${apollo_core_namespaceObject.Colors.ColorGray300})`,
                    borderRadius: `var(--border-radius-l, ${apollo_core_namespaceObject.BorderRadiusL})`,
                    px: apollo_core_namespaceObject.PadXl,
                    py: apollo_core_namespaceObject.PadM,
                    '&:hover': {
                        backgroundColor: `var(--color-background-hover, ${apollo_core_namespaceObject.Colors.ColorBackgroundHoverLight})`
                    }
                },
                children: [
                    isAll ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(AppsRounded_default(), {
                        sx: {
                            fontSize: apollo_core_namespaceObject.IconXs,
                            color: 'inherit'
                        }
                    }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FolderOutlined_default(), {
                        sx: {
                            fontSize: apollo_core_namespaceObject.IconXs,
                            color: 'inherit'
                        }
                    }),
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Box_default(), {
                        component: "span",
                        sx: {
                            whiteSpace: 'nowrap'
                        },
                        children: isAll ? resolvedAllFoldersLabel : current?.label ?? resolvedAllFoldersLabel
                    }),
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(KeyboardArrowDown_default(), {
                        sx: {
                            fontSize: apollo_core_namespaceObject.IconXs,
                            color: `var(--color-foreground-de-emp, ${apollo_core_namespaceObject.Colors.ColorGray550})`,
                            transition: 'transform 150ms',
                            transform: open ? 'rotate(180deg)' : 'rotate(0)'
                        }
                    })
                ]
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Popper_default(), {
                anchorEl: anchorEl,
                open: open,
                placement: "bottom-start",
                disablePortal: true,
                modifiers: [
                    {
                        name: 'offset',
                        options: {
                            offset: [
                                0,
                                4
                            ]
                        }
                    }
                ],
                style: {
                    zIndex: 10
                },
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ClickAwayListener_default(), {
                    onClickAway: ()=>setAnchorEl(null),
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Paper_default(), {
                        elevation: 8,
                        sx: {
                            minWidth: 200,
                            borderRadius: `var(--border-radius-l, ${apollo_core_namespaceObject.BorderRadiusL})`,
                            border: '1px solid',
                            borderColor: `var(--color-border-de-emp, ${apollo_core_namespaceObject.Colors.ColorGray300})`,
                            backgroundColor: `var(--color-background-raised, ${apollo_core_namespaceObject.Colors.ColorWhite})`,
                            boxShadow: `var(--shadow-menu-elevation, ${apollo_core_namespaceObject.ShadowMenuElevation})`
                        },
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(MenuList_default(), {
                            dense: true,
                            disablePadding: true,
                            sx: {
                                p: apollo_core_namespaceObject.PadS
                            },
                            children: [
                                showAllFolders && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
                                    children: [
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(MenuItem_default(), {
                                            selected: isAll,
                                            onClick: ()=>{
                                                onChange(null);
                                                setAnchorEl(null);
                                            },
                                            sx: {
                                                fontSize: 'var(--font-s-size, 12px)',
                                                gap: apollo_core_namespaceObject.SpacingXs,
                                                py: apollo_core_namespaceObject.PadM,
                                                borderRadius: `var(--border-radius-m, ${apollo_core_namespaceObject.BorderRadiusM})`,
                                                color: `var(--color-foreground, ${apollo_core_namespaceObject.Colors.ColorGray850})`
                                            },
                                            children: [
                                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(AppsRounded_default(), {
                                                    sx: {
                                                        fontSize: apollo_core_namespaceObject.IconXs,
                                                        color: `var(--color-foreground-de-emp, ${apollo_core_namespaceObject.Colors.ColorGray550})`
                                                    }
                                                }),
                                                resolvedAllFoldersLabel
                                            ]
                                        }, "__all"),
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Divider_default(), {
                                            sx: {
                                                my: apollo_core_namespaceObject.PadXs
                                            }
                                        })
                                    ]
                                }),
                                folders.map((f)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(MenuItem_default(), {
                                        selected: value === f.id,
                                        onClick: ()=>{
                                            onChange(f.id);
                                            setAnchorEl(null);
                                        },
                                        sx: {
                                            fontSize: 'var(--font-s-size, 12px)',
                                            gap: apollo_core_namespaceObject.SpacingXs,
                                            py: apollo_core_namespaceObject.PadM,
                                            borderRadius: `var(--border-radius-m, ${apollo_core_namespaceObject.BorderRadiusM})`,
                                            color: `var(--color-foreground, ${apollo_core_namespaceObject.Colors.ColorGray850})`
                                        },
                                        children: [
                                            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FolderOutlined_default(), {
                                                sx: {
                                                    fontSize: apollo_core_namespaceObject.IconXs,
                                                    color: `var(--color-foreground-de-emp, ${apollo_core_namespaceObject.Colors.ColorGray550})`
                                                }
                                            }),
                                            f.label
                                        ]
                                    }, f.id))
                            ]
                        })
                    })
                })
            })
        ]
    });
};
exports.FolderSwitcher = __webpack_exports__.FolderSwitcher;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "FolderSwitcher"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
