<commit_before>var settings_org = (function () {

var exports = {};

var meta = {
    loaded: false,
};

exports.reset = function () {
    meta.loaded = false;
};

var org_profile = {
    name: {
        type: 'text',
    },
    description: {
        type: 'text',
    },
};

var org_settings = {
    msg_editing: {
        allow_edit_history: {
            type: 'bool',
        },
        allow_community_topic_editing: {
            type: 'bool',
        },
    },
    msg_feed: {
        inline_image_preview: {
            type: 'bool',
        },
        inline_url_embed_preview: {
            type: 'bool',
        },
        mandatory_topics: {
            type: 'bool',
        },
    },
    video_chat: {
        video_chat_provider: {
            type: 'text',
        },
        google_hangouts_domain: {
            type: 'text',
        },
    },
    user_defaults: {
        default_language: {
            type: 'text',
        },
        default_twenty_four_hour_time: {
            type: 'bool',
        },
    },
    notifications: {
        send_welcome_emails: {
            type: 'bool',
        },
    },
};

var org_permissions = {
    user_identity: {
        name_changes_disabled: {
            type: 'bool',
        },
        email_changes_disabled: {
            type: 'bool',
        },
    },
    other_permissions: {
        bot_creation_policy: {
            type: 'integer',
        },
    },
};

function get_subsection_property_types(subsection) {
    if (_.has(org_settings, subsection)) {
        return org_settings[subsection];
    } else if (_.has(org_permissions, subsection)) {
        return org_permissions[subsection];
    } else if (subsection === 'org_profile') {
        return org_profile;
    }
    return;
}

exports.get_realm_time_limits_in_minutes = function (property) {
    var val = (page_params[property] / 60).toFixed(1);
    if (parseFloat(val, 10) === parseInt(val, 10)) {
        val = parseInt(val, 10);
    }
    return val.toString();
};

function get_property_value(property_name) {
    var value;
    if (property_name === 'realm_message_content_edit_limit_minutes') {
        return exports.get_realm_time_limits_in_minutes('realm_message_content_edit_limit_seconds');
    } else if (property_name === 'realm_message_content_delete_limit_minutes') {
        return exports.get_realm_time_limits_in_minutes('realm_message_content_delete_limit_seconds');
    } else if (property_name === 'realm_create_stream_permission') {
        if (page_params.realm_create_stream_by_admins_only) {
            return "by_admins_only";
        }
        if (page_params.realm_waiting_period_threshold === 0) {
            return "by_anyone";
        }
        if (page_params.realm_waiting_period_threshold === 3) {
            return "by_admin_user_with_three_days_old";
        }
        return "by_admin_user_with_custom_time";
    } else if (property_name === 'realm_add_emoji_by_admins_only') {
        if (page_params.realm_add_emoji_by_admins_only) {
            return "by_admins_only";
        }
        return "by_anyone";
    } else if (property_name === 'realm_msg_edit_limit_setting') {
        if (!page_params.realm_allow_message_editing) {
            return "never";
        }
        value = _.findKey(exports.msg_edit_limit_dropdown_values, function (elem) {
            return elem.seconds === page_params.realm_message_content_edit_limit_seconds;
        });
        if (value === undefined) {
            return "custom_limit";
        }
        return value;
    } else if (property_name === 'realm_msg_delete_limit_setting') {
        if (!page_params.realm_allow_message_deleting) {
            return "never";
        }
        value = _.findKey(exports.msg_delete_limit_dropdown_values, function (elem) {
            return elem.seconds === page_params.realm_message_content_delete_limit_seconds;
        });
        if (value === undefined) {
            return "custom_limit";
        }
        return value;
    } else if (property_name === 'realm_org_join_restrictions') {
        if (page_params.realm_restricted_to_domain) {
            return "only_selected_domain";
        }
        if (page_params.realm_disallow_disposable_email_addresses) {
            return "no_disposable_email";
        }
        return "no_restriction";
    } else if (property_name === 'realm_user_invite_restriction') {
        if (!page_params.realm_invite_required) {
            return "no_invite_required";
        }
        if (page_params.realm_invite_by_admins_only) {
            return "by_admins_only";
        }
        return "by_anyone";
    }
    return page_params[property_name];
}

exports.extract_property_name = function (elem) {
    return elem.attr('id').split('-').join('_').replace("id_", "");
};

function set_create_stream_permission_dropdown() {
    var value = get_property_value("realm_create_stream_permission");
    $("#id_realm_create_stream_permission").val(value);
    if (value === "by_admin_user_with_custom_time") {
        $("#id_realm_waiting_period_threshold").parent().show();
    } else {<commit_msg>settings_org: Refactor 'get_property_value' to be more readable.<commit_after>var settings_org = (function () {

var exports = {};

var meta = {
    loaded: false,
};

exports.reset = function () {
    meta.loaded = false;
};

var org_profile = {
    name: {
        type: 'text',
    },
    description: {
        type: 'text',
    },
};

var org_settings = {
    msg_editing: {
        allow_edit_history: {
            type: 'bool',
        },
        allow_community_topic_editing: {
            type: 'bool',
        },
    },
    msg_feed: {
        inline_image_preview: {
            type: 'bool',
        },
        inline_url_embed_preview: {
            type: 'bool',
        },
        mandatory_topics: {
            type: 'bool',
        },
    },
    video_chat: {
        video_chat_provider: {
            type: 'text',
        },
        google_hangouts_domain: {
            type: 'text',
        },
    },
    user_defaults: {
        default_language: {
            type: 'text',
        },
        default_twenty_four_hour_time: {
            type: 'bool',
        },
    },
    notifications: {
        send_welcome_emails: {
            type: 'bool',
        },
    },
};

var org_permissions = {
    user_identity: {
        name_changes_disabled: {
            type: 'bool',
        },
        email_changes_disabled: {
            type: 'bool',
        },
    },
    other_permissions: {
        bot_creation_policy: {
            type: 'integer',
        },
    },
};

function get_subsection_property_types(subsection) {
    if (_.has(org_settings, subsection)) {
        return org_settings[subsection];
    } else if (_.has(org_permissions, subsection)) {
        return org_permissions[subsection];
    } else if (subsection === 'org_profile') {
        return org_profile;
    }
    return;
}

exports.get_realm_time_limits_in_minutes = function (property) {
    var val = (page_params[property] / 60).toFixed(1);
    if (parseFloat(val, 10) === parseInt(val, 10)) {
        val = parseInt(val, 10);
    }
    return val.toString();
};

function get_property_value(property_name) {
    var value;

    if (property_name === 'realm_message_content_edit_limit_minutes') {
        return exports.get_realm_time_limits_in_minutes('realm_message_content_edit_limit_seconds');
    }

    if (property_name === 'realm_message_content_delete_limit_minutes') {
        return exports.get_realm_time_limits_in_minutes('realm_message_content_delete_limit_seconds');
    }

    if (property_name === 'realm_create_stream_permission') {
        if (page_params.realm_create_stream_by_admins_only) {
            return "by_admins_only";
        }
        if (page_params.realm_waiting_period_threshold === 0) {
            return "by_anyone";
        }
        if (page_params.realm_waiting_period_threshold === 3) {
            return "by_admin_user_with_three_days_old";
        }
        return "by_admin_user_with_custom_time";
    }

    if (property_name === 'realm_add_emoji_by_admins_only') {
        if (page_params.realm_add_emoji_by_admins_only) {
            return "by_admins_only";
        }
        return "by_anyone";
    }

    if (property_name === 'realm_msg_edit_limit_setting') {
        if (!page_params.realm_allow_message_editing) {
            return "never";
        }
        value = _.findKey(exports.msg_edit_limit_dropdown_values, function (elem) {
            return elem.seconds === page_params.realm_message_content_edit_limit_seconds;
        });
        if (value === undefined) {
            return "custom_limit";
        }
        return value;
    }

    if (property_name === 'realm_msg_delete_limit_setting') {
        if (!page_params.realm_allow_message_deleting) {
            return "never";
        }
        value = _.findKey(exports.msg_delete_limit_dropdown_values, function (elem) {
            return elem.seconds === page_params.realm_message_content_delete_limit_seconds;
        });
        if (value === undefined) {
            return "custom_limit";
        }
        return value;
    }

    if (property_name === 'realm_org_join_restrictions') {
        if (page_params.realm_restricted_to_domain) {
            return "only_selected_domain";
        }
        if (page_params.realm_disallow_disposable_email_addresses) {
            return "no_disposable_email";
        }
        return "no_restriction";
    }

    if (property_name === 'realm_user_invite_restriction') {
        if (!page_params.realm_invite_required) {
            return "no_invite_required";
        }
        if (page_params.realm_invite_by_admins_only) {
            return "by_admins_only";
        }
        return "by_anyone";
    }

    return page_params[property_name];
}

exports.extract_property_name = function (elem) {
    return elem.attr('id').split('-').join('_').replace("id_", "");
};

function set_create_stream_permission_dropdown() {
    var value = get_property_value("realm_create_stream_permission");
    $("#id_realm_create_stream_permission").val(value);
    if (value === "by_admin_user_with_custom_time") {
        $("#id_realm_waiting_period_threshold").parent().show();
    } else {
{'fraction_non_alphanumeric': 0.11466952204808722, 'fraction_numerical': 0.0021415360654141926, 'mean_word_length': 2.3773833004602234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4521868', 'n_tokens_mistral': 3262, 'n_tokens_neox': 3209, 'n_words': 485}