import { ValidationError } from "../core/index.js";
export class Bitset {
    values = new Set();
    static from(values) {
        const bitset = new Bitset();
        for (const value of values)
            bitset.add(value);
        return bitset;
    }
    add(value) {
        if (!Number.isSafeInteger(value) || value < 0)
            throw new ValidationError("BITSET_VALUE", "Bitset values must be non-negative safe integers.");
        this.values.add(value);
        return this;
    }
    delete(value) {
        return this.values.delete(value);
    }
    has(value) {
        return this.values.has(value);
    }
    containsAll(other) {
        for (const value of other.values) {
            if (!this.values.has(value))
                return false;
        }
        return true;
    }
    intersects(other) {
        for (const value of other.values) {
            if (this.values.has(value))
                return true;
        }
        return false;
    }
    toArray() {
        return [...this.values].sort((a, b) => a - b);
    }
    clone() {
        return Bitset.from(this.values);
    }
}
//# sourceMappingURL=Bitset.js.map