"use strict";
// The require scope
var __webpack_require__ = {};
/************************************************************************/ // webpack/runtime/compat_get_default_export
(()=>{
    // getDefaultExport function for compatibility with non-ESM modules
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
// webpack/runtime/define_property_getters
(()=>{
    __webpack_require__.d = function(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/runtime/has_own_property
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
// webpack/runtime/make_namespace_object
(()=>{
    // define __esModule on exports
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
/************************************************************************/ var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
    WithFooterChildren: ()=>/* binding */ WithFooterChildren,
    GoBackConditionally: ()=>/* binding */ GoBackConditionally,
    default: ()=>/* binding */ Sidebar_stories_rslib_entry_,
    FooterItems: ()=>/* binding */ FooterItems,
    GoBackConditionallyGroup: ()=>/* binding */ GoBackConditionallyGroup,
    MultiHeadingNav: ()=>/* binding */ MultiHeadingNav,
    Default: ()=>/* binding */ Default
});
const external_Sidebar_js_namespaceObject = require("./Sidebar.js");
var external_Sidebar_js_default = /*#__PURE__*/ __webpack_require__.n(external_Sidebar_js_namespaceObject);
const md_namespaceObject = require("react-icons/md");
const sidebarDefaultItems = [
    {
        title: 'Internal 1',
        to: '/1',
        icon: md_namespaceObject.MdSearch
    },
    {
        title: 'Internal 2',
        to: '/2',
        icon: md_namespaceObject.MdHelpOutline
    },
    {
        title: 'Internal 3',
        to: '/3',
        icon: md_namespaceObject.MdFavoriteBorder
    },
    {
        title: 'External',
        to: 'https://redpanda.com',
        icon: md_namespaceObject.MdPayment,
        isExternal: true
    },
    {
        title: 'Disabled',
        to: '/4',
        icon: md_namespaceObject.MdPersonOutline,
        isDisabled: true,
        disabledText: 'Reason link is disabled'
    }
];
const sideBarDefaultFooterItems = [
    {
        title: 'Settings',
        to: '/settings',
        icon: md_namespaceObject.MdOutlineSettings
    },
    {
        title: 'Account',
        to: '/account',
        icon: md_namespaceObject.MdPersonOutline
    }
];
const sideBarMultiHeadingGroups = [
    {
        heading: 'Menu heading 1',
        items: [
            {
                title: 'Internal 1',
                to: '/1',
                icon: md_namespaceObject.MdSearch
            },
            {
                title: 'Internal 2',
                to: '/2',
                icon: md_namespaceObject.MdHelpOutline
            },
            {
                title: 'Internal 3',
                to: '/3',
                icon: md_namespaceObject.MdFavoriteBorder
            },
            {
                title: 'External 1',
                to: 'https://redpanda.com',
                icon: md_namespaceObject.MdPayment,
                isExternal: true
            }
        ]
    },
    {
        heading: 'Menu heading 2',
        items: [
            {
                title: 'Settings',
                to: '/settings',
                icon: md_namespaceObject.MdOutlineSettings
            },
            {
                title: 'Account',
                to: '/account',
                icon: md_namespaceObject.MdPersonOutline
            }
        ]
    }
];
const test_namespaceObject = require("@storybook/test");
const react_namespaceObject = require("@chakra-ui/react");
const external_react_router_dom_namespaceObject = require("react-router-dom");
const meta = {
    title: 'Components/Sidebar',
    component: external_Sidebar_js_default(),
    argTypes: {
        status: {
            options: [
                'success',
                'loading',
                'error'
            ],
            control: {
                type: 'select'
            }
        },
        items: {
            control: false
        },
        groups: {
            control: false
        },
        footerItems: {
            control: false
        },
        children: {
            control: false
        },
        isCollapsible: {
            control: false
        },
        isCollapsed: {
            control: false
        },
        logoOverrides: {
            control: false
        }
    },
    parameters: {
        design: {
            type: 'figma',
            url: 'https://www.figma.com/file/bJcVrZNilxa06jYuVCGWYd/Redpanda-Design-System-2023?type=design&node-id=23-479&mode=design'
        }
    }
};
/* ESM default export */ const Sidebar_stories_rslib_entry_ = meta;
const Default = {
    args: {
        items: sidebarDefaultItems
    }
};
const WithFooterChildren = {
    args: {
        items: sidebarDefaultItems,
        footerChildren: /*#__PURE__*/ React.createElement(react_namespaceObject.Box, {
            maxW: "161px",
            maxH: "161px",
            p: "18px",
            borderRadius: "6px",
            color: "white"
        }, /*#__PURE__*/ React.createElement(react_namespaceObject.Text, null, "Footer Child 1"), /*#__PURE__*/ React.createElement(react_namespaceObject.Text, null, "Footer Child 2"), /*#__PURE__*/ React.createElement(react_namespaceObject.Text, null, "Footer Child 3")),
        footerItems: sideBarDefaultFooterItems
    }
};
const GoBackConditionally = {
    args: {
        items: sidebarDefaultItems
    },
    render: (props)=>{
        const location = (0, external_react_router_dom_namespaceObject.useLocation)();
        const previousItem = {
            title: 'Go back',
            to: '/1',
            icon: md_namespaceObject.MdKeyboardBackspace
        };
        return /*#__PURE__*/ React.createElement(external_Sidebar_js_default(), {
            ...props,
            previousItem: '/2' === location.pathname ? previousItem : void 0
        });
    },
    play: async ({ canvasElement, step })=>{
        const canvas = (0, test_namespaceObject.within)(canvasElement);
        await step('Check there is no back button', async ()=>{
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-previous')).not.toBeInTheDocument();
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-icon-Go back')).not.toBeInTheDocument();
        });
        await step('Check link #2', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-Internal 2')).toHaveTextContent('Internal 2');
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-icon-Internal 2')).toBeVisible();
            await test_namespaceObject.userEvent.click(canvas.getByText('Internal 2'));
        });
        await step('Check the back button appears', async ()=>{
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-previous')).toHaveTextContent('Go back');
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-icon-Go back')).toBeVisible();
        });
        await step('Check the back button disappears upon redirect and the right link is active', async ()=>{
            await test_namespaceObject.userEvent.click(canvas.getByText('Go back'));
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-previous')).not.toBeInTheDocument();
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-icon-Go back')).not.toBeInTheDocument();
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-Internal 1').parentElement?.parentElement).toHaveAttribute('aria-current', 'page');
        });
    }
};
const GoBackConditionallyGroup = {
    args: {
        groups: sideBarMultiHeadingGroups
    },
    render: (props)=>{
        const location = (0, external_react_router_dom_namespaceObject.useLocation)();
        const previousItem = {
            title: 'Go back',
            to: '/1',
            icon: md_namespaceObject.MdKeyboardBackspace
        };
        return /*#__PURE__*/ React.createElement(external_Sidebar_js_default(), {
            ...props,
            previousItem: '/2' === location.pathname ? previousItem : void 0
        });
    }
};
const MultiHeadingNav = {
    args: {
        groups: sideBarMultiHeadingGroups
    },
    play: async ({ canvasElement, step })=>{
        const canvas = (0, test_namespaceObject.within)(canvasElement);
        await step('Check headings', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-heading-Menu heading 1')).toBeVisible();
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-heading-Menu heading 2')).toBeVisible();
        });
    }
};
const FooterItems = {
    args: {
        items: [
            {
                title: 'Internal 1',
                to: '/1',
                icon: md_namespaceObject.MdSearch
            },
            {
                title: 'Internal 2',
                to: '/2',
                icon: md_namespaceObject.MdHelpOutline
            },
            {
                title: 'Internal 3',
                to: '/3',
                icon: md_namespaceObject.MdFavoriteBorder
            },
            {
                title: 'External',
                to: 'https://redpanda.com',
                icon: md_namespaceObject.MdPayment,
                isExternal: true
            },
            {
                title: 'Disabled',
                to: '/4',
                icon: md_namespaceObject.MdPersonOutline,
                isDisabled: true,
                disabledText: 'Reason link is disabled'
            }
        ],
        footerItems: sideBarDefaultFooterItems
    },
    play: async ({ canvasElement, step })=>{
        const canvas = (0, test_namespaceObject.within)(canvasElement);
        await step('Check link #1', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-Internal 1')).toHaveTextContent('Internal 1');
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-icon-Internal 1')).toBeVisible();
            await test_namespaceObject.userEvent.click(canvas.getByText('Internal 1'));
        });
        await step('Check link #2', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-Internal 2')).toHaveTextContent('Internal 2');
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-icon-Internal 2')).toBeVisible();
            await test_namespaceObject.userEvent.click(canvas.getByText('Internal 2'));
        });
        await step('Check link #3', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-Internal 3')).toHaveTextContent('Internal 3');
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-icon-Internal 3')).toBeVisible();
            await test_namespaceObject.userEvent.click(canvas.getByText('Internal 3'));
        });
        await step('Check external', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-External')).toHaveTextContent('External');
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-icon-External')).toBeVisible();
        });
        await step('Check disabled', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-icon-Disabled')).toBeVisible();
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-Disabled')).toHaveTextContent('Disabled');
        });
        await step('Check "Settings"', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-Settings')).toHaveTextContent('Settings');
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-icon-Settings')).toBeVisible();
            await test_namespaceObject.userEvent.click(canvas.getByText('Settings'));
        });
        await step('Check "Account"', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-Account')).toHaveTextContent('Account');
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-icon-Account')).toBeVisible();
            await test_namespaceObject.userEvent.click(canvas.getByText('Account'));
        });
        await step('Collapse sidebar', async ()=>{
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-icon-Expand sidebar')).not.toBeInTheDocument();
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-icon-Collapse sidebar')).toBeVisible();
            await test_namespaceObject.userEvent.click(canvas.getByTestId('nav-link-icon-Collapse sidebar'));
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-Internal 1')).not.toBeInTheDocument();
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-Internal 2')).not.toBeInTheDocument();
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-Internal 3')).not.toBeInTheDocument();
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-External')).not.toBeInTheDocument();
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-Disabled')).not.toBeInTheDocument();
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-Settings')).not.toBeInTheDocument();
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-Account')).not.toBeInTheDocument();
        });
        await step('Expand sidebar', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('nav-link-icon-Expand sidebar')).toBeVisible();
            (0, test_namespaceObject.expect)(canvas.queryByTestId('nav-link-icon-Collapse sidebar')).not.toBeInTheDocument();
            await test_namespaceObject.userEvent.click(canvas.getByTestId('nav-link-icon-Expand sidebar'));
        });
    }
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
