/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
'use strict';

var wrappers_pb = require('./wrappers_pb-DCb8h8QZ.js');

function requestUnary(caller) {
    return new Promise((resolve, reject) => {
        caller((err, res) => {
            if (err != null) {
                reject(err);
            }
            else if (res != null) {
                resolve(res);
            }
            else {
                reject(new Error('Invalid gRPC response. Error and result are empty.'));
            }
        });
    });
}
async function* requestPaged(fetch, next) {
    let cursor = undefined;
    do {
        const res = await requestUnary(fetch(cursor));
        yield res;
        cursor = next(res);
    } while (cursor != null);
}
async function createMetadata(jwtProvider, deviceId) {
    const jwt = await jwtProvider();
    const meta = new wrappers_pb.grpcWebClient_umdExports.grpc.Metadata({
        'jwt-context': JSON.stringify({
            jwt,
            metadata: { 'x-device-id': deviceId || '' },
        }),
    });
    return meta;
}

exports.createMetadata = createMetadata;
exports.requestPaged = requestPaged;
exports.requestUnary = requestUnary;
//# sourceMappingURL=grpc-BsWFEUrc.js.map

//# sourceMappingURL=grpc-BsWFEUrc.js.map