<commit_before>const SelectMatcher    = require('@binary-com/binary-style').select2Matcher;
const moment           = require('moment');
const BinaryPjax       = require('../../../../base/binary_pjax');
const Client           = require('../../../../base/client');
const Header           = require('../../../../base/header');
const BinarySocket     = require('../../../../base/socket');
const formatMoney      = require('../../../../common/currency').formatMoney;
const FormManager      = require('../../../../common/form_manager');
const Geocoder         = require('../../../../../_common/geocoder');
const CommonFunctions  = require('../../../../../_common/common_functions');
const localize         = require('../../../../../_common/localize').localize;
const State            = require('../../../../../_common/storage').State;
const getPropertyValue = require('../../../../../_common/utility').getPropertyValue;

const PersonalDetails = (() => {
    const form_id           = '#frmPersonalDetails';
    const real_acc_elements = '.RealAcc';

    let is_for_new_account = false;

    let editable_fields,
        is_jp_client,
        is_virtual,
        residence,
        get_settings_data,
        currency;

    const init = () => {
        editable_fields   = {};
        get_settings_data = {};
        is_virtual        = Client.get('is_virtual');
        residence         = Client.get('residence');
        is_jp_client      = residence === 'jp'; // we need to check with residence so we know which fields will be present in get_settings response
        if (is_jp_client && !is_virtual) {
            showHideTaxMessage();
        }
    };

    const showHideTaxMessage = () => {
        const $tax_info_declaration = $('#tax_information_declaration');
        const $tax_information_info = $('#tax_information_info');

        if (Client.shouldCompleteTax()) {
            $('#tax_information_note_toggle').off('click').on('click', (e) => {
                e.stopPropagation();
                $('#tax_information_note_toggle').toggleClass('open');
                $('#tax_information_note').slideToggle();
            });
        } else {
            $tax_information_info.setVisibility(0); // hide tax info
            $tax_info_declaration.setVisibility(0); // hide tax info declaration
        }
    };

    const showHideLabel = (get_settings) => {
        if (!is_jp_client) {
            ['place_of_birth', 'account_opening_reason', 'citizen'].forEach((id) => {
                if (Object.prototype.hasOwnProperty.call(get_settings, id)) {
                    if (get_settings[id]) {
                        // we have to show text here instead of relying on displayGetSettingsData()
                        // since it prioritizes showing data instead of label
                        const $label = $(`#lbl_${id}`);
                        $label.text(get_settings[id]);
                        $(`#row_${id}`).setVisibility(0);
                        $(`#row_lbl_${id}`).setVisibility(1);
                    } else {
                        $(`#row_lbl_${id}`).setVisibility(0);
                        $(`#row_${id}`).setVisibility(1);
                    }
                }
            });
        }
    };

    const showHideMissingDetails = () => {
        const validations = getValidations();
        const has_missing_field = validations.find((validation) => /req/.test(validation.validations) && $(validation.selector).val() === '');
        $('#missing_details_notice').setVisibility(!!has_missing_field);
    };

    const getDetailsResponse = (data, residence_list = State.getResponse('residence_list')) => {
        const get_settings         = $.extend({}, data);
        get_settings.date_of_birth = 'date_of_birth' in get_settings ? moment.utc(new Date(get_settings.date_of_birth * 1000)).format('YYYY-MM-DD') : '';
        const accounts             = Client.getAllLoginids();
        // for subaccounts, back-end sends loginid of the master account as name
        const hide_name            = accounts.some(loginid => new RegExp(loginid, 'i').test(get_settings.first_name)) || is_virtual;
        if (!hide_name) {
            get_settings.name = is_jp_client ? get_settings.last_name : `${(get_settings.salutation || '')} ${(get_settings.first_name || '')} ${(get_settings.last_name || '')}`;
        }

        if (get_settings.place_of_birth) {
            get_settings.place_of_birth =
                (residence_list.find(obj => obj.value === get_settings.place_of_birth) || {}).text ||
                get_settings.place_of_birth;
        }
<commit_msg>change citizen to country name<commit_after>const SelectMatcher    = require('@binary-com/binary-style').select2Matcher;
const moment           = require('moment');
const BinaryPjax       = require('../../../../base/binary_pjax');
const Client           = require('../../../../base/client');
const Header           = require('../../../../base/header');
const BinarySocket     = require('../../../../base/socket');
const formatMoney      = require('../../../../common/currency').formatMoney;
const FormManager      = require('../../../../common/form_manager');
const Geocoder         = require('../../../../../_common/geocoder');
const CommonFunctions  = require('../../../../../_common/common_functions');
const localize         = require('../../../../../_common/localize').localize;
const State            = require('../../../../../_common/storage').State;
const getPropertyValue = require('../../../../../_common/utility').getPropertyValue;

const PersonalDetails = (() => {
    const form_id           = '#frmPersonalDetails';
    const real_acc_elements = '.RealAcc';

    let is_for_new_account = false;

    let editable_fields,
        is_jp_client,
        is_virtual,
        residence,
        get_settings_data,
        currency;

    const init = () => {
        editable_fields   = {};
        get_settings_data = {};
        is_virtual        = Client.get('is_virtual');
        residence         = Client.get('residence');
        is_jp_client      = residence === 'jp'; // we need to check with residence so we know which fields will be present in get_settings response
        if (is_jp_client && !is_virtual) {
            showHideTaxMessage();
        }
    };

    const showHideTaxMessage = () => {
        const $tax_info_declaration = $('#tax_information_declaration');
        const $tax_information_info = $('#tax_information_info');

        if (Client.shouldCompleteTax()) {
            $('#tax_information_note_toggle').off('click').on('click', (e) => {
                e.stopPropagation();
                $('#tax_information_note_toggle').toggleClass('open');
                $('#tax_information_note').slideToggle();
            });
        } else {
            $tax_information_info.setVisibility(0); // hide tax info
            $tax_info_declaration.setVisibility(0); // hide tax info declaration
        }
    };

    const showHideLabel = (get_settings) => {
        if (!is_jp_client) {
            ['place_of_birth', 'account_opening_reason', 'citizen'].forEach((id) => {
                if (Object.prototype.hasOwnProperty.call(get_settings, id)) {
                    if (get_settings[id]) {
                        // we have to show text here instead of relying on displayGetSettingsData()
                        // since it prioritizes showing data instead of label
                        const $label = $(`#lbl_${id}`);
                        $label.text(get_settings[id]);
                        $(`#row_${id}`).setVisibility(0);
                        $(`#row_lbl_${id}`).setVisibility(1);
                    } else {
                        $(`#row_lbl_${id}`).setVisibility(0);
                        $(`#row_${id}`).setVisibility(1);
                    }
                }
            });
        }
    };

    const showHideMissingDetails = () => {
        const validations = getValidations();
        const has_missing_field = validations.find((validation) => /req/.test(validation.validations) && $(validation.selector).val() === '');
        $('#missing_details_notice').setVisibility(!!has_missing_field);
    };

    const getDetailsResponse = (data, residence_list = State.getResponse('residence_list')) => {
        const get_settings         = $.extend({}, data);
        get_settings.date_of_birth = 'date_of_birth' in get_settings ? moment.utc(new Date(get_settings.date_of_birth * 1000)).format('YYYY-MM-DD') : '';
        const accounts             = Client.getAllLoginids();
        // for subaccounts, back-end sends loginid of the master account as name
        const hide_name            = accounts.some(loginid => new RegExp(loginid, 'i').test(get_settings.first_name)) || is_virtual;
        if (!hide_name) {
            get_settings.name = is_jp_client ? get_settings.last_name : `${(get_settings.salutation || '')} ${(get_settings.first_name || '')} ${(get_settings.last_name || '')}`;
        }

        if (get_settings.place_of_birth) {
            get_settings.place_of_birth =
                (residence_list.find(obj => obj.value === get_settings.place_of_birth) || {}).text ||
                get_settings.place_of_birth;
        }

        if (get_settings.citizen) {
            get_settings.citizen =
                (residence_list.find(obj => obj.value === get_settings.citizen) || {}).text ||
                get_settings.citizen;
        }

{'fraction_non_alphanumeric': 0.16087325137770242, 'fraction_numerical': 0.0023314963967782957, 'mean_word_length': 2.073941368078176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, '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': '2015167', 'n_tokens_mistral': 2611, 'n_tokens_neox': 2537, 'n_words': 450}