import * as __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__ from "@chakra-ui/react";
import * as __WEBPACK_EXTERNAL_MODULE__storybook_test__ from "@storybook/test";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__ from "./CopyButton.mjs";
const meta = {
    title: 'Components/CopyButton',
    component: __WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__["default"],
    argTypes: {
        content: {
            control: 'text'
        },
        showLabel: {
            control: 'boolean'
        },
        showIcon: {
            control: 'boolean'
        }
    },
    args: {
        showLabel: false,
        showIcon: true
    },
    parameters: {
        design: {
            type: 'figma',
            url: 'https://www.figma.com/file/bJcVrZNilxa06jYuVCGWYd/Redpanda-Design-System-2023?type=design&node-id=55-2242&mode=design'
        }
    }
};
/* ESM default export */ const CopyButton_stories_rslib_entry_ = meta;
const Default = {
    args: {
        content: 'asdf'
    },
    play: async ({ canvasElement, step })=>{
        const canvas = (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.within)(canvasElement);
        await step('Check defaults', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('copy-button')).toBeVisible();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('copy-button')).toBeEnabled();
        });
    }
};
const Labelled = {
    args: {
        showLabel: true
    }
};
const CustomLabelled = {
    args: {
        showLabel: true,
        customLabel: 'Custom Label'
    }
};
const TemplateWithInputChangingValue = {
    render: ()=>{
        const initialContent = 'Original';
        const [content, setContent] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialContent);
        return /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Box, null, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Input, {
            "data-testid": "content-input",
            onChange: (event)=>setContent(event.target.value),
            placeholder: "Start typing"
        }), /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__["default"], {
            content: content
        }), /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Text, null, "Current content: ", JSON.stringify(content, null, 4)));
    },
    play: async ({ canvasElement, step })=>{
        const user = __WEBPACK_EXTERNAL_MODULE__storybook_test__.userEvent.setup({
            writeToClipboard: true
        });
        const canvas = (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.within)(canvasElement);
        __WEBPACK_EXTERNAL_MODULE__storybook_test__.fireEvent.change(canvas.getByTestId('content-input'), {
            target: {
                value: 'Original'
            }
        });
        await step('Check defaults', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('copy-button')).toBeVisible();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('copy-button')).toBeEnabled();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('content-input')).toHaveValue('Original');
        });
        // Copy "Original" to clipboard
        __WEBPACK_EXTERNAL_MODULE__storybook_test__.fireEvent.click(canvas.getByTestId('copy-button'));
        __WEBPACK_EXTERNAL_MODULE__storybook_test__.fireEvent.change(canvas.getByTestId('content-input'), {
            target: {
                value: ''
            }
        });
        await step('Check the clipboard data by pasting it', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('content-input')).toHaveValue('');
        });
        __WEBPACK_EXTERNAL_MODULE__storybook_test__.fireEvent.change(canvas.getByTestId('content-input'), {
            target: {
                value: await user.paste('Original')
            }
        });
    // TODO: This cannot be tested by Storybook currently, it's impossible to mock properly, but it works if you try it manually
    // await step('Check the clipboard data by pasting it', async () => {
    //   expect(canvas.getByTestId('content-input')).toHaveValue('Original');
    // });
    }
};
const NoIcon = {
    args: {
        showLabel: true,
        showIcon: false,
        colorScheme: 'brand',
        customLabel: 'Select',
        variant: 'link'
    },
    render: (args)=>{
        const content = '10.0.0.0/16';
        return /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Tag, {
            size: "lg",
            bgColor: "gray.100",
            borderRadius: "6px"
        }, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Text, {
            as: "samp",
            "data-testid": "redpanda-cidr"
        }, content), /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__["default"], {
            ...args,
            content: content
        }));
    },
    play: async ({ canvasElement, step })=>{
        const canvas = (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.within)(canvasElement);
        await step('Check defaults', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByText('Select')).toBeVisible();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('copy-button')).toBeVisible();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('copy-button')).toBeEnabled();
        });
        __WEBPACK_EXTERNAL_MODULE__storybook_test__.fireEvent.click(canvas.getByTestId('copy-button'));
        await step('Check label changes upon copying', async ()=>{
            await (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.waitFor)(()=>(0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByText('Copied')).toBeVisible());
        });
    }
};
export { CustomLabelled, Default, Labelled, NoIcon, TemplateWithInputChangingValue, CopyButton_stories_rslib_entry_ as default };
