var barcodeReader = null;
var qrCodeReader = null;
if (typeof document !== "undefined" && typeof window !== "undefined") {
    barcodeReader = require("@zxing/library/esm5/browser/BrowserBarcodeReader");
    qrCodeReader = require("@zxing/library/esm5/browser/BrowserQRCodeReader");
}
/**
 * The scanner class provides functionality to scan
 * codes.
 *
 * @see {@link CodeReader}
 */
var Scanner = /** @class */ (function () {
    function Scanner() {
    }
    /**
     * Scan a QR code using the BrowserQRCodeReader
     * library.
     *
     * @param deviceId
     */
    Scanner.scanQRCodeFromDevice = function (deviceId) {
        if (qrCodeReader !== null) {
            var BrowserQRCodeReader = qrCodeReader.BrowserQRCodeReader;
            if (deviceId) {
                var codeReader = new BrowserQRCodeReader();
                return codeReader.decodeFromInputVideoDevice(deviceId);
            }
            console.error("Set video device before calling this function");
        }
        return null;
    };
    /**
     * Scan a barcode using the BrowserBarcodeReader
     * library.
     *
     * @param deviceId
     */
    Scanner.scanBarCodeFromDevice = function (deviceId) {
        if (barcodeReader !== null) {
            var BrowserBarcodeReader = barcodeReader.BrowserBarcodeReader;
            if (deviceId) {
                var codeReader = new BrowserBarcodeReader();
                return codeReader.decodeFromInputVideoDevice(deviceId);
            }
            console.error("Set video device before calling this function");
        }
        return null;
    };
    return Scanner;
}());
export { Scanner };
//# sourceMappingURL=Scanner.js.map