"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ojMessage = exports.OjMessage = void 0;
const __1 = require("../../");
const OjMessage_1 = require("./OjMessage");
Object.defineProperty(exports, "OjMessage", { enumerable: true, get: function () { return OjMessage_1.OjMessage; } });
/**
 * Retrieve an instance of [OjMessage](../classes/elements.OjMessage.html).
 * @example
 * ```javascript
 * import { ojMessage } from '@oracle/oraclejet-webdriver/elements';
 * const el = await ojMessage(driver, By.id('my-oj-message'));
 * ```
 * @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 ojMessage(driver, by) {
    const webEl = await driver.findElement(by);
    // Check that the element is of type OjMessage
    if (!(webEl instanceof OjMessage_1.OjMessage)) {
        const tagName = await webEl.getTagName();
        let supplemental = '';
        if (webEl.constructor.name === 'OjMessage') {
            supplemental = 'You likely have multiple installations of this package.';
        }
        throw Error(`ojMessage(${by}) created ${webEl.constructor.name} for <${tagName}>, but expected ${OjMessage_1.OjMessage.name}. ${supplemental}`);
    }
    return webEl;
}
exports.ojMessage = ojMessage;
(0, __1.register)('oj-message', OjMessage_1.OjMessage);
//# sourceMappingURL=index.js.map