"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.randomId = randomId;
exports.randomIdNotIn = randomIdNotIn;
exports.randomIdNotInSet = randomIdNotInSet;
exports.uuidIdNotInSet = uuidIdNotInSet;
exports.uuid = uuid;
exports.uuidNotIn = uuidNotIn;
function randomId() {
    return Math.random()
        .toString(36)
        .replace(/[^a-z]+/g, '')
        .substr(0, 9);
}
function randomIdNotIn(obj) {
    let id;
    do {
        id = randomId();
    } while (obj[id]);
    return id;
}
function randomIdNotInSet(obj) {
    let id;
    do {
        id = randomId();
    } while (obj.has(id));
    return id;
}
function uuidIdNotInSet(obj) {
    let id;
    do {
        id = uuid();
    } while (obj.has(id));
    return id;
}
function uuid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        const r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
        return v.toString(16);
    });
}
function uuidNotIn(obj) {
    let id;
    do {
        id = uuid();
    } while (obj[id]);
    return id;
}
//# sourceMappingURL=id.js.map