/* @oracle/oraclejet-preact: undefined */
import { jsx, jsxs, Fragment } from 'preact/jsx-runtime';
import { render, screen, fireEvent } from '@testing-library/preact';
import { expect } from 'chai';
import '../../Menu-a5bf756f.js';
import { l as MenuItem } from '../../MenuItem-54015ca3.js';
import 'preact/hooks';
import 'preact';
import '../../logger-c92f309c.js';
import '../../LayerHost-e6402730.js';
import { R as RootEnvironmentProvider } from '../../EnvironmentProvider-bada8909.js';
import './../../TooltipContentStyles.styles.css';
import './../../hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentBaseTheme.styles.css';
import '../../hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js';
import '../../tooltipUtils-768450a7.js';
import './../../IconStyle.styles.css';
import '../../SelectMenuGroupContext-b56cf5d4.js';
import '../../UNSAFE_Separator/themes/SeparatorStyles.css.js';
import './../../MenuSeparatorStyles.styles.css';
import './../../UNSAFE_Menu/themes/redwood/MenuSeparatorBaseTheme.styles.css';
import '../../UNSAFE_Menu/themes/redwood/MenuSeparatorVariants.css.js';
import 'preact/compat';
import userEvent from '@testing-library/user-event';
import { g as getMenuItemByRole, a as getAllMenuItemsByRole, b as getLabel } from '../../menuTestsUtils-c74ce3da.js';
import { m as matchTranslationBundle } from '../../matchTranslationBundle-d9e64706.js';
import { P as PieChart } from '../../PieChart-87a2913f.js';
import '../../Dropdown-60833900.js';
import '../../Floating-f02677ba.js';
import '../../useFloating-953362cf.js';
import '../../useUser-1cd223a9.js';
import '../../positionUtils-f26caad9.js';
import '../../refUtils-b9d8d91a.js';
import '../../useOutsideClick-fd9ad806.js';
import '../../arrayUtils-35a58161.js';
import '../../Layer-446bf21e.js';
import '../../classNames-4e12b00d.js';
import '../../UNSAFE_Layer/themes/LayerStyles.css.js';
import './../../LayerStyles.styles.css';
import '../../useThemeInterpolations-8dd8029f.js';
import '../../useColorScheme-c4e237ad.js';
import '../../useScale-83881775.js';
import '../../theme-63551f30.js';
import '../../Theme-e6dec6db.js';
import '../../mergeInterpolations-e2db2a66.js';
import '../../mergeDeepWithKey-08531060.js';
import '../../_curry3-0b4222d7.js';
import '../../_curry1-25297e59.js';
import '../../_curry2-34316bcf.js';
import '../../_isObject-1fab0f5b.js';
import '../../useDensity-c17603b2.js';
import '../../useModal-953082f2.js';
import '../../useComponentTheme-d2f9e47f.js';
import '../../utils-a4102e03.js';
import '../../Common/themes/themeContract.css.js';
import '../../colorUtils-16eb823f.js';
import '../../UNSAFE_Floating/themes/redwood/FloatingTheme.js';
import '../../UNSAFE_Floating/themes/FloatingStyles.css.js';
import './../../FloatingStyles.styles.css';
import '../../UNSAFE_Floating/themes/redwood/FloatingBaseTheme.css.js';
import './../../UNSAFE_Floating/themes/redwood/FloatingBaseTheme.styles.css';
import '../../UNSAFE_Floating/themes/redwood/FloatingVariants.css.js';
import '../../vanilla-extract-recipes-createRuntimeFn.esm-2aaf8c98.js';
import '../../vanilla-extract-dynamic.esm-2955d60a.js';
import '../../UNSAFE_Floating/themes/FloatingContract.css.js';
import '../../keyboardUtils-38854729.js';
import '../../clientHints-f850225e.js';
import '../../tabbableUtils-6ceb767f.js';
import '../../head-6f17c50c.js';
import '../../_arity-be492b9e.js';
import '../../_isArray-694cc52d.js';
import '../../_isString-675f1de9.js';
import '../../usePopupAnimation-f017bc43.js';
import '../../useAnimationStatus-a9337dd8.js';
import '../../useAnimation-a5eb7604.js';
import '../../popupAnimationUtils-175151d9.js';
import '../../CollectionInteractionContext-7cf19abc.js';
import '../../UNSAFE_Dropdown/themes/dropdownStyles.css.js';
import './../../dropdownStyles.styles.css';
import '../../useOutsideMousedown-7307de8b.js';
import '../../animationUtils-e6081007.js';
import '../../mergeProps-88ea8306.js';
import '../../UNSAFE_Menu/themes/MenuStyles.css.js';
import './../../MenuStyles.styles.css';
import '../../useTestId-9b504481.js';
import '../../UNSAFE_Menu/themes/DropdownMenuStyles.css.js';
import './../../DropdownMenuStyles.styles.css';
import '../../Sheet-da412baf.js';
import '../../Modal-24a0bf4b.js';
import '../../UNSAFE_Modal/themes/ModalStyles.css.js';
import './../../ModalStyles.styles.css';
import '../../popupUtils-58411a98.js';
import '../../WindowOverlay-a07b2e24.js';
import '../../UNSAFE_WindowOverlay/themes/WindowOverlayStyles.css.js';
import './../../WindowOverlayStyles.styles.css';
import '../../UNSAFE_WindowOverlay/themes/WindowOverlayContract.css.js';
import '../../UNSAFE_WindowOverlay/themes/redwood/WindowOverlayTheme.js';
import '../../UNSAFE_WindowOverlay/themes/redwood/WindowOverlayBaseTheme.css.js';
import './../../UNSAFE_WindowOverlay/themes/redwood/WindowOverlayBaseTheme.styles.css';
import '../../UNSAFE_WindowOverlay/themes/redwood/WindowOverlayVariants.css.js';
import '../../UNSAFE_Sheet/themes/SheetStyles.css.js';
import './../../SheetStyles.styles.css';
import '../../UNSAFE_Menu/themes/SheetMenuStyles.css.js';
import './../../SheetMenuStyles.styles.css';
import '../../Text-f8d4ff78.js';
import '../../UNSAFE_Text/themes/TextStyles.css.js';
import './../../TextStyles.styles.css';
import '../../useId-03dbfdf0.js';
import '../../usePress-051f5adb.js';
import '../../flexitem-7b7f7920.js';
import './../../flexitem.styles.css';
import '../../vanilla-extract-sprinkles-createRuntimeSprinkles.esm-2d655d37.js';
import '../../useInteractionStyle-52222fdd.js';
import '../../useHover-19340c22.js';
import '../../useToggle-8b7fcefe.js';
import '../../useActive-fb6d4d52.js';
import '../../UNSAFE_Menu/themes/redwood/MenuItemTheme.js';
import '../../UNSAFE_Menu/themes/MenuItemStyles.css.js';
import './../../MenuItemStyles.styles.css';
import '../../UNSAFE_Menu/themes/redwood/MenuItemBaseTheme.css.js';
import './../../UNSAFE_Menu/themes/redwood/MenuItemBaseTheme.styles.css';
import '../../UNSAFE_Menu/themes/redwood/MenuItemVariants.css.js';
import './../../MenuItemVariants.styles.css';
import '../../Common/themes/redwood/theme.js';
import '../../UNSAFE_Layer/themes/LayerHostStyles.css.js';
import './../../LayerHostStyles.styles.css';
import '../../LayerManager-fa745cec.js';
import './../../TooltipContentVariants.styles.css';
import './../../SeparatorStyles.styles.css';
import '../themes/PieChartStyles.css.js';
import './../../PieChartStyles.styles.css';
import '../../TrackResizeContainer-04a2c642.js';
import '../../useSize-9eea84eb.js';
import '../../useResizeObserver-838164c1.js';
import '../../useVisAddBusyState-994e0324.js';
import '../../VisBusyStateContext-9ae84b1d.js';
import '../../useVisBusyStateContext-a1df0764.js';
import '../../size-18139a3a.js';
import '../../pathUtils-1a478322.js';
import '../../layoutUtils-5d62f2b4.js';
import '../../scale-3b7850b9.js';
import '../../labelUtils-ec7f939f.js';
import '../../textUtils-3ed25dd1.js';
import '../../accUtils-ce2d6588.js';
import '../../utils-d451497b.js';
import '../../datatipUtils-13ab34b7.js';
import '../../clientUtils-0df8cb15.js';
import '../../dimensionUtils-6d5dac30.js';
import '../../getLocale-1c41e86a.js';
import '../../stringUtils-16f617bc.js';
import '../../usePieChartNav-166e78ce.js';
import '../../layoutUtils-d7613d0c.js';
import '../../eventsUtils-e5fc62d5.js';
import '../../useVisHover-d7a0b2f3.js';
import '../../useDatatip-9635bc2f.js';
import '../../hooks/PRIVATE_useDatatip/themes/useDatatip.css.js';
import './../../useDatatip.styles.css';
import '../../VisTabularDatatip-59629377.js';
import '../../PRIVATE_VisTabularDatatip/themes/VisTabularDatatipStyles.css.js';
import './../../VisTabularDatatipStyles.styles.css';
import '../../colorUtils-35e3dd2b.js';
import '../../useVisTouchResponse-a59ab166.js';
import '../../useContextMenu-3c62d9eb.js';
import '../../useContextMenuGesture-9b95a1bb.js';
import '../../textSelectionUtils-a6554a42.js';

function __variableDynamicImportRuntime0__(path) {
  switch (path) {
    case '../../resources/nls/ar/bundle.ts': return import('../../resources/nls/ar/bundle.js');
    case '../../resources/nls/ar-XB/bundle.ts': return import('../../resources/nls/ar-XB/bundle.js');
    case '../../resources/nls/bg/bundle.ts': return import('../../resources/nls/bg/bundle.js');
    case '../../resources/nls/bs/bundle.ts': return import('../../resources/nls/bs/bundle.js');
    case '../../resources/nls/bs-Cyrl/bundle.ts': return import('../../resources/nls/bs-Cyrl/bundle.js');
    case '../../resources/nls/cs/bundle.ts': return import('../../resources/nls/cs/bundle.js');
    case '../../resources/nls/da/bundle.ts': return import('../../resources/nls/da/bundle.js');
    case '../../resources/nls/de/bundle.ts': return import('../../resources/nls/de/bundle.js');
    case '../../resources/nls/el/bundle.ts': return import('../../resources/nls/el/bundle.js');
    case '../../resources/nls/en/bundle.ts': return import('../../resources/nls/en/bundle.js');
    case '../../resources/nls/en-XA/bundle.ts': return import('../../resources/nls/en-XA/bundle.js');
    case '../../resources/nls/en-XC/bundle.ts': return import('../../resources/nls/en-XC/bundle.js');
    case '../../resources/nls/es/bundle.ts': return import('../../resources/nls/es/bundle.js');
    case '../../resources/nls/et/bundle.ts': return import('../../resources/nls/et/bundle.js');
    case '../../resources/nls/fi/bundle.ts': return import('../../resources/nls/fi/bundle.js');
    case '../../resources/nls/fr/bundle.ts': return import('../../resources/nls/fr/bundle.js');
    case '../../resources/nls/fr-CA/bundle.ts': return import('../../resources/nls/fr-CA/bundle.js');
    case '../../resources/nls/he/bundle.ts': return import('../../resources/nls/he/bundle.js');
    case '../../resources/nls/hr/bundle.ts': return import('../../resources/nls/hr/bundle.js');
    case '../../resources/nls/hu/bundle.ts': return import('../../resources/nls/hu/bundle.js');
    case '../../resources/nls/is/bundle.ts': return import('../../resources/nls/is/bundle.js');
    case '../../resources/nls/it/bundle.ts': return import('../../resources/nls/it/bundle.js');
    case '../../resources/nls/ja/bundle.ts': return import('../../resources/nls/ja/bundle.js');
    case '../../resources/nls/ko/bundle.ts': return import('../../resources/nls/ko/bundle.js');
    case '../../resources/nls/lt/bundle.ts': return import('../../resources/nls/lt/bundle.js');
    case '../../resources/nls/lv/bundle.ts': return import('../../resources/nls/lv/bundle.js');
    case '../../resources/nls/ms/bundle.ts': return import('../../resources/nls/ms/bundle.js');
    case '../../resources/nls/nl/bundle.ts': return import('../../resources/nls/nl/bundle.js');
    case '../../resources/nls/no/bundle.ts': return import('../../resources/nls/no/bundle.js');
    case '../../resources/nls/pl/bundle.ts': return import('../../resources/nls/pl/bundle.js');
    case '../../resources/nls/pt/bundle.ts': return import('../../resources/nls/pt/bundle.js');
    case '../../resources/nls/pt-PT/bundle.ts': return import('../../resources/nls/pt-PT/bundle.js');
    case '../../resources/nls/ro/bundle.ts': return import('../../resources/nls/ro/bundle.js');
    case '../../resources/nls/ru/bundle.ts': return import('../../resources/nls/ru/bundle.js');
    case '../../resources/nls/sk/bundle.ts': return import('../../resources/nls/sk/bundle.js');
    case '../../resources/nls/sl/bundle.ts': return import('../../resources/nls/sl/bundle.js');
    case '../../resources/nls/sr/bundle.ts': return import('../../resources/nls/sr/bundle.js');
    case '../../resources/nls/sr-Latn/bundle.ts': return import('../../resources/nls/sr-Latn/bundle.js');
    case '../../resources/nls/sv/bundle.ts': return import('../../resources/nls/sv/bundle.js');
    case '../../resources/nls/th/bundle.ts': return import('../../resources/nls/th/bundle.js');
    case '../../resources/nls/tr/bundle.ts': return import('../../resources/nls/tr/bundle.js');
    case '../../resources/nls/uk/bundle.ts': return import('../../resources/nls/uk/bundle.js');
    case '../../resources/nls/vi/bundle.ts': return import('../../resources/nls/vi/bundle.js');
    case '../../resources/nls/zh-Hans/bundle.ts': return import('../../resources/nls/zh-Hans/bundle.js');
    case '../../resources/nls/zh-Hant/bundle.ts': return import('../../resources/nls/zh-Hant/bundle.js');
    default: return new Promise(function(resolve, reject) {
      (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(
        reject.bind(null, new Error("Unknown variable dynamic import: " + path))
      );
    })
   }
 }
const pieData = [
    { id: 1, value: 5 },
    { id: 2, value: 4 },
    { id: 3, value: 4 }
];
describe('Test PieChart component', () => {
    it('render', async function () {
        render(jsx(PieChart, { data: pieData, width: '400px', height: '400px', "aria-label": "pie chart label" }));
        const ariaText = screen.getAllByLabelText('pie chart label');
        expect(ariaText).not.null;
        const ariaRole = screen.getByRole('application');
        expect(ariaRole).not.null;
    });
    if (typeof jest === 'undefined') {
        it('trigger context menu on right click', async () => {
            const config = {
                // The menu items returned by itemsRenderer must be valid children for the Menu component
                itemsRenderer: () => {
                    return (jsxs(Fragment, { children: [jsx(MenuItem, { label: `MenuItem1` }), jsx(MenuItem, { label: `MenuItem2` })] }));
                }
            };
            const { container } = await setupPieChart(config);
            const root = 
            // eslint-disable-next-line
            container.firstElementChild?.firstElementChild?.firstElementChild?.firstElementChild;
            const firstElement = root;
            //We do the necessary to have firstItem as current item
            fireEvent.contextMenu(firstElement, {
                clientX: 50,
                clientY: 50,
                currentTarget: root
            });
            const menu = getMenuItemByRole('menu');
            const menuItems = getAllMenuItemsByRole('menuitem');
            //With this we check context menu context was set correctly
            const menuItemGotByLabel = getLabel('MenuItem1');
            expect(menu).not.null;
            expect(menuItems.length).equals(2);
            expect(menuItemGotByLabel).not.null;
        });
        it('trigger context menu from Keyboard (shift + f10) ', async () => {
            const config = {
                // The menu items returned by itemsRenderer must be valid children for the Menu component
                itemsRenderer: () => {
                    return (jsxs(Fragment, { children: [jsx(MenuItem, { label: `MenuItem1` }), jsx(MenuItem, { label: `MenuItem2` })] }));
                }
            };
            const { container } = await setupPieChart(config);
            // eslint-disable-next-line
            const root = // eslint-disable-next-line
             container.firstElementChild?.firstElementChild?.firstElementChild;
            await userEvent.tab();
            await userEvent.keyboard('[ENTER]');
            fireEvent.keyDown(root, { key: 'F10', shiftKey: true });
            const menu = getMenuItemByRole('menu');
            const menuItems = getAllMenuItemsByRole('menuitem');
            //With this we check context menu context was set correctly
            const menuItemGotByLabel = getLabel('MenuItem1');
            expect(menu).not.null;
            expect(menuItems.length).equals(2);
            expect(menuItemGotByLabel).not.null;
        });
        it('should not trigger context menu when there is no data ', async () => {
            const config = {
                // The menu items returned by itemsRenderer must be valid children for the Menu component
                itemsRenderer: () => {
                    return (jsxs(Fragment, { children: [jsx(MenuItem, { label: `MenuItem1` }), jsx(MenuItem, { label: `MenuItem2` })] }));
                }
            };
            const { container } = await setupPieChart(config, []);
            // eslint-disable-next-line
            const root = // eslint-disable-next-line
             container.firstElementChild;
            await userEvent.tab();
            await userEvent.keyboard('[ENTER]');
            fireEvent.keyDown(root, { key: 'F10', shiftKey: true });
            const menu = screen.queryByRole('menu');
            expect(menu).null;
        });
    }
});
const setupPieChart = async (contextMenuConfig, data = pieData) => {
    const locale = matchTranslationBundle(['en'], new Set(['en-US', 'en']));
    const { default: translations } = await __variableDynamicImportRuntime0__(`../../resources/nls/${locale}/bundle.ts`);
    const env = {
        translations: { '@oracle/oraclejet-preact': translations }
    };
    return render(jsx(RootEnvironmentProvider, { environment: env, children: jsx(PieChart, { contextMenuConfig: contextMenuConfig, data: data, width: '400px', height: '400px', "aria-label": "pie chart label" }) }));
};
//# sourceMappingURL=PieChart.spec.js.map
