"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ojDialog = exports.OjDialog = void 0;
const __1 = require("../../");
const OjDialog_1 = require("./OjDialog");
Object.defineProperty(exports, "OjDialog", { enumerable: true, get: function () { return OjDialog_1.OjDialog; } });
/**
 * Retrieve an instance of [OjDialog](../classes/elements.OjDialog.html).
 * @example
 * ```javascript
 * import { ojDialog } from '@oracle/oraclejet-webdriver/elements';
 * const el = await ojDialog(driver, By.id('my-oj-dialog'));
 * ```
 * @param driver A WebDriver/WebElement instance from where the element will be
 * searched. If WebDriver is passed, the element will be searched globally in the
 * document. If WebElement is passed, the search will be relative to this element.
 * @param by The locator with which to find the element
 */
async function ojDialog(driver, by) {
    const webEl = await driver.findElement(by);
    // Check that the element is of type OjDialog
    if (!(webEl instanceof OjDialog_1.OjDialog)) {
        const tagName = await webEl.getTagName();
        let supplemental = '';
        if (webEl.constructor.name === 'OjDialog') {
            supplemental = 'You likely have multiple installations of this package.';
        }
        throw Error(`ojDialog(${by}) created ${webEl.constructor.name} for <${tagName}>, but expected ${OjDialog_1.OjDialog.name}. ${supplemental}`);
    }
    return webEl;
}
exports.ojDialog = ojDialog;
(0, __1.register)('oj-dialog', OjDialog_1.OjDialog);
//# sourceMappingURL=index.js.map