"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__, {
    TemplateWithInputChangingValue: ()=>/* binding */ TemplateWithInputChangingValue,
    Labelled: ()=>/* binding */ Labelled,
    CustomLabelled: ()=>/* binding */ CustomLabelled,
    NoIcon: ()=>/* binding */ NoIcon,
    default: ()=>/* binding */ CopyButton_stories_rslib_entry_,
    Default: ()=>/* binding */ Default
});
const react_namespaceObject = require("@chakra-ui/react");
const test_namespaceObject = require("@storybook/test");
const external_react_namespaceObject = require("react");
const external_CopyButton_js_namespaceObject = require("./CopyButton.js");
var external_CopyButton_js_default = /*#__PURE__*/ __webpack_require__.n(external_CopyButton_js_namespaceObject);
const meta = {
    title: 'Components/CopyButton',
    component: external_CopyButton_js_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, test_namespaceObject.within)(canvasElement);
        await step('Check defaults', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('copy-button')).toBeVisible();
            (0, test_namespaceObject.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, external_react_namespaceObject.useState)(initialContent);
        return /*#__PURE__*/ React.createElement(react_namespaceObject.Box, null, /*#__PURE__*/ React.createElement(react_namespaceObject.Input, {
            "data-testid": "content-input",
            onChange: (event)=>setContent(event.target.value),
            placeholder: "Start typing"
        }), /*#__PURE__*/ React.createElement(external_CopyButton_js_default(), {
            content: content
        }), /*#__PURE__*/ React.createElement(react_namespaceObject.Text, null, "Current content: ", JSON.stringify(content, null, 4)));
    },
    play: async ({ canvasElement, step })=>{
        const user = test_namespaceObject.userEvent.setup({
            writeToClipboard: true
        });
        const canvas = (0, test_namespaceObject.within)(canvasElement);
        test_namespaceObject.fireEvent.change(canvas.getByTestId('content-input'), {
            target: {
                value: 'Original'
            }
        });
        await step('Check defaults', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('copy-button')).toBeVisible();
            (0, test_namespaceObject.expect)(canvas.getByTestId('copy-button')).toBeEnabled();
            (0, test_namespaceObject.expect)(canvas.getByTestId('content-input')).toHaveValue('Original');
        });
        // Copy "Original" to clipboard
        test_namespaceObject.fireEvent.click(canvas.getByTestId('copy-button'));
        test_namespaceObject.fireEvent.change(canvas.getByTestId('content-input'), {
            target: {
                value: ''
            }
        });
        await step('Check the clipboard data by pasting it', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByTestId('content-input')).toHaveValue('');
        });
        test_namespaceObject.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(react_namespaceObject.Tag, {
            size: "lg",
            bgColor: "gray.100",
            borderRadius: "6px"
        }, /*#__PURE__*/ React.createElement(react_namespaceObject.Text, {
            as: "samp",
            "data-testid": "redpanda-cidr"
        }, content), /*#__PURE__*/ React.createElement(external_CopyButton_js_default(), {
            ...args,
            content: content
        }));
    },
    play: async ({ canvasElement, step })=>{
        const canvas = (0, test_namespaceObject.within)(canvasElement);
        await step('Check defaults', async ()=>{
            (0, test_namespaceObject.expect)(canvas.getByText('Select')).toBeVisible();
            (0, test_namespaceObject.expect)(canvas.getByTestId('copy-button')).toBeVisible();
            (0, test_namespaceObject.expect)(canvas.getByTestId('copy-button')).toBeEnabled();
        });
        test_namespaceObject.fireEvent.click(canvas.getByTestId('copy-button'));
        await step('Check label changes upon copying', async ()=>{
            await (0, test_namespaceObject.waitFor)(()=>(0, test_namespaceObject.expect)(canvas.getByText('Copied')).toBeVisible());
        });
    }
};
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
});
