<commit_before>import { KeeState } from "./KeeState";
import { SessionType } from "../common/SessionType";

export const connected = (state: KeeState) => state.connected;
export const showGeneratePasswordLink = (state: KeeState) => state.connected;
export const saveState = (state: KeeState) => state.saveState;
export const showMatchedLogins = (state: KeeState) => !!state.loginsFound;
export const showNotifications = (state: KeeState) => state.notifications && !!state.notifications.length;
export const databaseIsOpen = (state: KeeState) => state.connected && !!state.KeePassDatabases.length;
export const notifications = (state: KeeState) => state.notifications;
export const currentSearchTerm = (state: KeeState) => state.currentSearchTerm;
export const searchResults = (state: KeeState) => state.searchResults;
export const ActiveKeePassDatabaseIndex = (state: KeeState) => state.ActiveKeePassDatabaseIndex;
export const KeePassDatabases = (state: KeeState) => state.KeePassDatabases;
export const PasswordProfiles = (state: KeeState) => state.PasswordProfiles;
export const generatedPassword = (state: KeeState) => state.generatedPassword;

export const databaseName = (state: KeeState) => {
    if (state.KeePassDatabases && state.KeePassDatabases.length && state.ActiveKeePassDatabaseIndex >= 0) {
        const db = state.KeePassDatabases[state.ActiveKeePassDatabaseIndex];
        return db.name ? db.name : db.fileName.replace(/^.*[\\/]/, "");
    }
    return "";
};
export const connectionStatus = (state: KeeState, getters) => {
    if (state.connected) {
        if (state.KeePassDatabases.length > 1) {
            return $STRF("multiplePasswordSourcesEnabled", [state.KeePassDatabases.length.toString()]);
        } else if (state.KeePassDatabases.length == 1) {
            return getters.databaseName;
        } else {
            return $STR("notifyBarLoginToKeePassButton_tip");
        }
    } else {
        return $STR("notifyBarLaunchKeePassButton_tip");
    }
};
export const connectionStatusDetail = (state: KeeState, getters) => {
    if (state.connected) {
        if (state.KeePassDatabases.length > 1) {
            return $STRF("loggedInMultiple_tip", [state.KeePassDatabases.length.toString(), getters.databaseName]);
        } else if (state.KeePassDatabases.length == 1) {
            return $STRF("loggedIn_tip", getters.databaseName);
        } else {
            return $STR("notifyBarLaunchKeePass_label") + " " + $STR("notifyBarLoginToKeePassButton_tip");
        }
    } else {
        return $STR("notifyBarLaunchKeePass_label") + " " + $STR("notifyBarLaunchKeePassButton_tip");
    }
};
export const showOpenKeePassButton = (state: KeeState) => {
    if (state.connectedWebsocket) {
        const hasWebsocketDBs = state.KeePassDatabases.some(db => db.sessionType === SessionType.Websocket);
        const supportsWebsocketFocus = state.KeePassDatabases.some(db => db.sessionType === SessionType.Websocket &&
                db.sessionFeatures.indexOf("KPRPC_OPEN_AND_FOCUS_DATABASE") >= 0);
        if (!hasWebsocketDBs || supportsWebsocketFocus) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
};<commit_msg>Remove repeated text from connection status tooltip<commit_after>import { KeeState } from "./KeeState";
import { SessionType } from "../common/SessionType";

export const connected = (state: KeeState) => state.connected;
export const showGeneratePasswordLink = (state: KeeState) => state.connected;
export const saveState = (state: KeeState) => state.saveState;
export const showMatchedLogins = (state: KeeState) => !!state.loginsFound;
export const showNotifications = (state: KeeState) => state.notifications && !!state.notifications.length;
export const databaseIsOpen = (state: KeeState) => state.connected && !!state.KeePassDatabases.length;
export const notifications = (state: KeeState) => state.notifications;
export const currentSearchTerm = (state: KeeState) => state.currentSearchTerm;
export const searchResults = (state: KeeState) => state.searchResults;
export const ActiveKeePassDatabaseIndex = (state: KeeState) => state.ActiveKeePassDatabaseIndex;
export const KeePassDatabases = (state: KeeState) => state.KeePassDatabases;
export const PasswordProfiles = (state: KeeState) => state.PasswordProfiles;
export const generatedPassword = (state: KeeState) => state.generatedPassword;

export const databaseName = (state: KeeState) => {
    if (state.KeePassDatabases && state.KeePassDatabases.length && state.ActiveKeePassDatabaseIndex >= 0) {
        const db = state.KeePassDatabases[state.ActiveKeePassDatabaseIndex];
        return db.name ? db.name : db.fileName.replace(/^.*[\\/]/, "");
    }
    return "";
};
export const connectionStatus = (state: KeeState, getters) => {
    if (state.connected) {
        if (state.KeePassDatabases.length > 1) {
            return $STRF("multiplePasswordSourcesEnabled", [state.KeePassDatabases.length.toString()]);
        } else if (state.KeePassDatabases.length == 1) {
            return getters.databaseName;
        } else {
            return $STR("notifyBarLoginToKeePassButton_tip");
        }
    } else {
        return $STR("notifyBarLaunchKeePassButton_tip");
    }
};
export const connectionStatusDetail = (state: KeeState, getters) => {
    if (state.connected) {
        if (state.KeePassDatabases.length > 1) {
            return $STRF("loggedInMultiple_tip", [state.KeePassDatabases.length.toString(), getters.databaseName]);
        } else if (state.KeePassDatabases.length == 1) {
            return $STRF("loggedIn_tip", getters.databaseName);
        }
    }
    return $STR("notifyBarLaunchKeePass_label");
};
export const showOpenKeePassButton = (state: KeeState) => {
    if (state.connectedWebsocket) {
        const hasWebsocketDBs = state.KeePassDatabases.some(db => db.sessionType === SessionType.Websocket);
        const supportsWebsocketFocus = state.KeePassDatabases.some(db => db.sessionType === SessionType.Websocket &&
                db.sessionFeatures.indexOf("KPRPC_OPEN_AND_FOCUS_DATABASE") >= 0);
        if (!hasWebsocketDBs || supportsWebsocketFocus) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
};
{'fraction_non_alphanumeric': 0.12404822335025381, 'fraction_numerical': 0.0019035532994923859, 'mean_word_length': 3.8240244835501147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7344293', 'n_tokens_mistral': 1858, 'n_tokens_neox': 1857, 'n_words': 384}