"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "base64", {
    enumerable: true,
    get: function() {
        return base64;
    }
});
const _superstruct = require("superstruct");
const _assert = require("./assert");
const base64 = (struct, options = {})=>{
    const paddingRequired = options.paddingRequired ?? false;
    const characterSet = options.characterSet ?? 'base64';
    let letters;
    if (characterSet === 'base64') {
        letters = String.raw`[A-Za-z0-9+\/]`;
    } else {
        (0, _assert.assert)(characterSet === 'base64url');
        letters = String.raw`[-_A-Za-z0-9]`;
    }
    let re;
    if (paddingRequired) {
        re = new RegExp(`^(?:${letters}{4})*(?:${letters}{3}=|${letters}{2}==)?$`, 'u');
    } else {
        re = new RegExp(`^(?:${letters}{4})*(?:${letters}{2,3}|${letters}{3}=|${letters}{2}==)?$`, 'u');
    }
    return (0, _superstruct.pattern)(struct, re);
};

//# sourceMappingURL=base64.js.map