const MAX_USER_ATTRIBUTE_QUERY_TAGS = 20;
const MAX_QUERY_TAG_KEY_LENGTH = 60;
const MAX_QUERY_TAG_VALUE_LENGTH = 60;
const USER_ATTRIBUTE_QUERY_TAG_PREFIX = 'user_attribute_';
const sanitizeQueryTagString = (value, fallback, maxLength) => value
    .trim()
    .toLowerCase()
    .replace(/[^a-z0-9_-]/g, '_')
    .substring(0, maxLength) || fallback;
export const sanitizeQueryTagKey = (key) => sanitizeQueryTagString(key, 'empty_key', MAX_QUERY_TAG_KEY_LENGTH);
export const sanitizeQueryTagValue = (value) => sanitizeQueryTagString(value, 'empty_value', MAX_QUERY_TAG_VALUE_LENGTH);
export const getUserAttributeQueryTags = (userAttributes) => Object.fromEntries(Object.entries(userAttributes).reduce((acc, [name, values]) => {
    if (acc.length >= MAX_USER_ATTRIBUTE_QUERY_TAGS) {
        return acc;
    }
    const tagName = sanitizeQueryTagKey(`${USER_ATTRIBUTE_QUERY_TAG_PREFIX}${name}`);
    const value = values
        .map((attribute) => attribute.trim())
        .filter(Boolean)
        .join(',')
        .trim();
    if (value) {
        acc.push([
            tagName,
            sanitizeQueryTagValue(value),
        ]);
    }
    return acc;
}, []));
export var TimeIntervalUnit;
(function (TimeIntervalUnit) {
    TimeIntervalUnit["SECOND"] = "SECOND";
    TimeIntervalUnit["MINUTE"] = "MINUTE";
    TimeIntervalUnit["HOUR"] = "HOUR";
    TimeIntervalUnit["DAY"] = "DAY";
    TimeIntervalUnit["WEEK"] = "WEEK";
    TimeIntervalUnit["MONTH"] = "MONTH";
    TimeIntervalUnit["YEAR"] = "YEAR";
})(TimeIntervalUnit || (TimeIntervalUnit = {}));
export var PartitionType;
(function (PartitionType) {
    PartitionType["DATE"] = "DATE";
    PartitionType["RANGE"] = "RANGE";
})(PartitionType || (PartitionType = {}));
//# sourceMappingURL=warehouse.js.map