import { baseUniDriverFactory } from '../utils/test-utils/unidriver';
import { DATA_HOOKS } from './CodeSnippet.constants';
import { classes as blockClasses } from './CodeSnippet.st.css';
import { classes as inlineClasses } from './components/InlineVariant.st.css';
export const codeSnippetUniDriverFactory = (base, body) => {
    // Inline variant is portal'd by Tooltip, so we query from `body` rather
    // than `base` to reach it.
    const rootSelector = `.${blockClasses.root}, .${inlineClasses.root}`;
    const root = () => (body ?? base).$(rootSelector);
    const copyButton = () => root().$(`[data-hook="${DATA_HOOKS.copyButton}"]`);
    const code = () => root().$(`[data-hook="${DATA_HOOKS.code}"]`);
    return {
        ...baseUniDriverFactory(base),
        exists: () => root().exists(),
        getCode: () => code().text(),
        isCopyable: async () => {
            if (await copyButton().exists()) {
                return true;
            }
            return (await root().attr('role')) === 'button';
        },
        copyContent: async () => {
            if (await copyButton().exists()) {
                return copyButton().click();
            }
            return root().click();
        },
        getCopyButtonAriaLabel: () => copyButton().attr('aria-label'),
        getAriaLabel: async () => (await root().attr('aria-label')) ?? (await code().attr('aria-label')),
    };
};
//# sourceMappingURL=CodeSnippet.uni.driver.js.map