"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const userAvatars_1 = require("./userAvatars");
describe('getUserAvatarGradient', () => {
    it('is deterministic for the same uuid', () => {
        const uuid = 'b264d83a-9000-426a-85ec-3f9c20f368ce';
        expect((0, userAvatars_1.getUserAvatarGradient)(uuid, null)).toBe((0, userAvatars_1.getUserAvatarGradient)(uuid, null));
    });
    it('always returns a valid gradient id', () => {
        const uuids = [
            'b264d83a-9000-426a-85ec-3f9c20f368ce',
            '00000000-0000-0000-0000-000000000000',
            'ffffffff-ffff-ffff-ffff-ffffffffffff',
        ];
        uuids.forEach((uuid) => {
            expect(userAvatars_1.USER_AVATAR_GRADIENT_IDS).toContain((0, userAvatars_1.getUserAvatarGradient)(uuid, null));
        });
    });
    it('returns the override when set', () => {
        expect((0, userAvatars_1.getUserAvatarGradient)('b264d83a-9000-426a-85ec-3f9c20f368ce', 'lilac')).toBe('lilac');
    });
    it('spreads different uuids across gradients', () => {
        const results = new Set(Array.from({ length: 64 }, (_, i) => (0, userAvatars_1.getUserAvatarGradient)(`0000000${i.toString(16)}-0000-0000-0000-00000000000${(i % 16).toString(16)}`, null)));
        expect(results.size).toBeGreaterThan(3);
    });
});
describe('isUserAvatarGradientId', () => {
    it('accepts known ids and rejects unknown strings', () => {
        expect((0, userAvatars_1.isUserAvatarGradientId)('lilac')).toBe(true);
        expect((0, userAvatars_1.isUserAvatarGradientId)('not-a-gradient')).toBe(false);
    });
});
describe('getUserAvatarUrl', () => {
    it('builds the versioned api path', () => {
        expect((0, userAvatars_1.getUserAvatarUrl)('some-uuid', 'abc123')).toBe('/api/v1/users/some-uuid/avatar/abc123');
    });
});
describe('isHexColorString', () => {
    it('accepts 6-digit hex colors and rejects everything else', () => {
        expect((0, userAvatars_1.isHexColorString)('#5e4cff')).toBe(true);
        expect((0, userAvatars_1.isHexColorString)('#5E4CFF')).toBe(true);
        expect((0, userAvatars_1.isHexColorString)('#fff')).toBe(false);
        expect((0, userAvatars_1.isHexColorString)('5e4cff')).toBe(false);
        expect((0, userAvatars_1.isHexColorString)('not-a-color')).toBe(false);
    });
});
describe('isUserAvatarColorValue', () => {
    it('accepts preset ids and hex colors, rejects everything else', () => {
        expect((0, userAvatars_1.isUserAvatarColorValue)('lilac')).toBe(true);
        expect((0, userAvatars_1.isUserAvatarColorValue)('#5e4cff')).toBe(true);
        expect((0, userAvatars_1.isUserAvatarColorValue)('mesh:2:#5e4cff')).toBe(true);
        expect((0, userAvatars_1.isUserAvatarColorValue)('not-a-color')).toBe(false);
    });
});
describe('isMeshColorString', () => {
    it('accepts mesh values for all vibes in both hex cases', () => {
        expect((0, userAvatars_1.isMeshColorString)('mesh:0:#5e4cff')).toBe(true);
        expect((0, userAvatars_1.isMeshColorString)('mesh:3:#5E4CFF')).toBe(true);
    });
    it('rejects invalid vibes and malformed values', () => {
        expect((0, userAvatars_1.isMeshColorString)('mesh:4:#5e4cff')).toBe(false);
        expect((0, userAvatars_1.isMeshColorString)('mesh:0:#fff')).toBe(false);
        expect((0, userAvatars_1.isMeshColorString)('mesh:0:5e4cff')).toBe(false);
        expect((0, userAvatars_1.isMeshColorString)('#5e4cff')).toBe(false);
        expect((0, userAvatars_1.isMeshColorString)('solid:#5e4cff')).toBe(false);
    });
});
describe('toMeshColor / parseMeshColor', () => {
    it('round-trips every vibe', () => {
        userAvatars_1.AVATAR_MESH_VIBES.forEach((vibe) => {
            const encoded = (0, userAvatars_1.toMeshColor)('#5e4cff', vibe);
            expect((0, userAvatars_1.isMeshColorString)(encoded)).toBe(true);
            expect((0, userAvatars_1.parseMeshColor)(encoded)).toEqual({
                vibe,
                hex: '#5e4cff',
            });
        });
    });
});
describe('hexToRgba', () => {
    it('converts a hex color to an rgba string with the given alpha', () => {
        expect((0, userAvatars_1.hexToRgba)('#5e4cff', 0.4)).toBe('rgba(94, 76, 255, 0.4)');
    });
});
describe('generateAvatarMeshBackgroundImage', () => {
    it('produces a layered background-image using the base hex color', () => {
        const result = (0, userAvatars_1.generateAvatarMeshBackgroundImage)('#5e4cff');
        expect(result).toContain('#5e4cff');
        expect(result).toContain('radial-gradient');
        expect(result).toContain('linear-gradient');
    });
    it('defaults to vibe 0 so bare hex values render unchanged', () => {
        expect((0, userAvatars_1.generateAvatarMeshBackgroundImage)('#5e4cff')).toBe((0, userAvatars_1.generateAvatarMeshBackgroundImage)('#5e4cff', 0));
    });
    it('produces a distinct layered recipe per vibe', () => {
        const results = userAvatars_1.AVATAR_MESH_VIBES.map((vibe) => (0, userAvatars_1.generateAvatarMeshBackgroundImage)('#5e4cff', vibe));
        expect(new Set(results).size).toBe(userAvatars_1.AVATAR_MESH_VIBES.length);
        results.forEach((result) => {
            expect(result).toContain('#5e4cff');
            expect(result).toContain('radial-gradient');
            expect(result).toContain('linear-gradient');
        });
    });
});
describe('generateAvatarMeshBorderColor', () => {
    it('returns an rgba border color derived from the base hex', () => {
        expect((0, userAvatars_1.generateAvatarMeshBorderColor)('#5e4cff')).toBe('rgba(94, 76, 255, 0.4)');
    });
});
describe('getAvatarMeshClassName', () => {
    it('derives a stable, lowercase class name from the hex color and vibe', () => {
        expect((0, userAvatars_1.getAvatarMeshClassName)('#5E4CFF')).toBe('avatar-mesh-0-5e4cff');
        expect((0, userAvatars_1.getAvatarMeshClassName)('#5E4CFF', 2)).toBe('avatar-mesh-2-5e4cff');
    });
});
describe('getContrastTextColor', () => {
    it('picks white text on dark backgrounds', () => {
        expect((0, userAvatars_1.getContrastTextColor)('#5e4cff')).toBe('white');
        expect((0, userAvatars_1.getContrastTextColor)('#0a0a0a')).toBe('white');
    });
    it('picks black text on light backgrounds', () => {
        expect((0, userAvatars_1.getContrastTextColor)('#f5f5f5')).toBe('black');
        expect((0, userAvatars_1.getContrastTextColor)('#ffe680')).toBe('black');
    });
});
//# sourceMappingURL=userAvatars.test.js.map