#include sound/seinfeld.js

Umi.Sound = (() => {
    const getLibrarySound = event => {
        if(!event || event === 'none')
            return;

        const minecraft = mami.settings.get('minecraft');

        if(event === 'join') {
            if(!mami.settings.get('soundEnableJoin'))
                return;

            if(mami.settings.get('seinfeld'))
                return Seinfeld.getRandom();

            if(minecraft === 'yes')
                return 'minecraft:door:open';

            if(minecraft === 'old')
                return 'minecraft:door:open-old';

            return mami.sound.pack.getEventSound('join');
        }

        if(event === 'leave') {
            if(!mami.settings.get('soundEnableLeave'))
                return;

            if(minecraft === 'yes')
                return 'minecraft:door:close';

            if(minecraft === 'old')
                return 'minecraft:door:close-old';

            return mami.sound.pack.getEventSound('leave');
        }

        if(event === 'error') {
            if(!mami.settings.get('soundEnableError'))
                return;

            return mami.sound.pack.getEventSound('error');
        }

        if(event === 'server') {
            if(!mami.settings.get('soundEnableServer'))
                return;

            return mami.sound.pack.getEventSound('server');
        }

        if(event === 'unban') {
            if(!mami.settings.get('soundEnableServer'))
                return;

            return mami.sound.pack.getEventSound(['unban', 'server']);
        }

        if(event === 'incoming') {
            if(!mami.settings.get('soundEnableIncoming'))
                return;

            if(mami.settings.get('windowsLiveMessenger'))
                return 'msn:incoming';

            return mami.sound.pack.getEventSound('incoming');
        }

        if(event === 'outgoing') {
            if(!mami.settings.get('soundEnableOutgoing'))
                return;

            return mami.sound.pack.getEventSound('outgoing');
        }

        if(event === 'private' || event === 'incoming-priv') {
            if(!mami.settings.get('soundEnablePrivate'))
                return;

            return mami.sound.pack.getEventSound(['incoming-priv', 'incoming']);
        }

        if(event === 'flood') {
            if(!mami.settings.get('soundEnableForceLeave'))
                return;

            return mami.sound.pack.getEventSound(['flood', 'kick', 'leave']);
        }

        if(event === 'timeout') {
            if(!mami.settings.get('soundEnableForceLeave'))
                return;

            return mami.sound.pack.getEventSound(['timeout', 'leave']);
        }

        if(event === 'kick' || event === 'forceLeave') {
            if(!mami.settings.get('soundEnableForceLeave'))
                return;

            return mami.sound.pack.getEventSound(['kick', 'leave']);
        }
    };

    return {
        Convert: getLibrarySound,
    };
})();
