<commit_before>angular.module('auction').factory('AuctionUtils', [
    '$filter', '$timeout', '$log', '$window',
    function ($filter, $timeout, $log, $window) {
	// Format msg for timer
	'use strict';

	function pad(d) {
	    return (d < 10) ? '0' + d.toString() : d.toString();
	}

	function prepare_info_timer_data(current_time, auction, bidder_id, Rounds) {
	    var i;
	    if (auction.current_stage === -101) {
		return {
		    'countdown': false,
		    'start_time': true,
		    'msg': 'Auction has not started and will be rescheduled'
		};
	    }
	    if (auction.current_stage === -100) {
		return {
		    'countdown': false,
		    'start_time': true,
		    'msg': 'Tender cancelled'
		};
	    }
	    if (auction.current_stage === -1) {
		var until_seconds = (new Date(auction.stages[0].start) - current_time) / 1000;
		if (until_seconds > -120){
		    return {
			'countdown': (until_seconds) + Math.random(),
			'start_time': false,
			'msg': 'until the auction starts'
		    };
		}else{
		    return {
			'countdown': false,
			'start_time': true,
			'msg': 'Auction has not started and will be rescheduled'
		    };
		}

	    }
	    if ((auction.stages[auction.current_stage].type || '') == "pre-sealed") {
		var client_time = new Date();
		var ends_time = new Date(auction.stages[auction.current_stage].start);
		if (client_time < ends_time) {
		    ends_time = client_time;
		}
		return {
		    'countdown': false,
		    'start_time': ends_time,
		    'msg': 'Аuction was completed',
		    'msg_ending': 'Waiting for the disclosure of the participants\' names'
		};
	    }
	    if ((auction.stages[auction.current_stage].type || '') == "sealedbid") {
		var client_time = new Date();
		var ends_time = new Date(auction.stages[auction.current_stage - 1].start);
		if (client_time < ends_time) {
		    ends_time = client_time;
		}
		return {
		    'countdown': false,
		    'start_time': ends_time,
		    'msg': 'Аuction was completed'
		};
	    }

	    if ((auction.stages[auction.current_stage].type === 'pause')) {
		return {
		    'countdown': ((new Date(auction.stages[auction.current_stage + 1].start) - current_time) / 1000) + Math.random(),
		    'start_time': false,
		    'msg': 'until the round starts'
		};
	    }
	    if ((auction.stages[auction.current_stage].type.startsWith('dutch'))) {
		return {
			'countdown': ((new Date(auction.stages[auction.current_stage + 1].start) - current_time) / 1000) + Math.random(),
			'start_time': false,
			'msg': 'until the step ends'
		};
	    }
	    if ((auction.stages[auction.current_stage].type || '') == "pre_announcement") {
        var client_time = new Date();
        var ends_time = new Date(auction.stages[auction.current_stage].start);
        if (client_time < ends_time) {
          ends_time = client_time;
        }
        return {
          'countdown': false,
          'start_time': ends_time,
          'msg': 'Аuction was completed',
          'msg_ending': 'Waiting for the disclosure of the participants\' names'
        };
      }
      if ((auction.stages[auction.current_stage].type || '') == "announcement") {
        var client_time = new Date();
        var ends_time = new Date(auction.stages[auction.current_stage - 1].start);
        if (client_time < ends_time) {
          ends_time = client_time;
        }
        return {
          'countdown': false,
          'start_time': ends_time,
          'msg': 'Аuction was completed'
        };}

	}

	function prepare_progress_timer_data(current_time, auction) {

	    if ((((auction.stages[auction.current_stage] || {}).type || '').indexOf('announcement') != -1) || (auction.current_stage === -100) || (auction.current_stage === -101)) {
		return {
		    'countdown_seconds': false,
		    'rounds_seconds': 0,
		};
	    }
	    if (auction.current_stage === -1) {
		var until_seconds = (new Date(auction.stages[0].start) - current_time) / 1000;
		if (until_seconds > -120){
		    return {
			'countdown_seconds': until_seconds + Math.random(),
			'rounds_seconds': until_seconds,
		    };
		}else{
		    return {
			'countdown_seconds': false,
			'rounds_seconds': 0,
		    };
		}
	    }
	    return {
		'countdown_seconds': ((new Date(auction.stages[auction.current_stage + 1].start) - current_time) / 1000) + Math.random(),
		'rounds_seconds': ((new Date(auction.stages[auction.current_stage + 1].start) - new Date(auction.stages[auction.current_stage].start)) / 1000),
	    };

	}
	// characters 100 true
	function prepare_title_ending_data(auction, lang) {
	    var ending = auction.tenderID + " - " + $filter('characters')((auction['title_' + lang] || auction['title'] || auction['title_en'] || auction['title_ru'] || ""), 50, true);
	    ending += " - ";
	    ending += $filter('characters')(auction.procuringEntity['name_' + lang] || auction.procuringEntity['name'] || auction.procuringEntity['name_en'] || auction.procuringEntity['name_ru'] || "", 50, true);
	    return ending;
	}
	// Get bidder_id from query
	function get_bidder_id() {
	    var query = window.location.search.substring(1);
	    var vars = query.split('&');
	    for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split('=');<commit_msg>Fixed timer info on sealedbid<commit_after>angular.module('auction').factory('AuctionUtils', [
    '$filter', '$timeout', '$log', '$window',
    function ($filter, $timeout, $log, $window) {
	// Format msg for timer
	'use strict';

	function pad(d) {
	    return (d < 10) ? '0' + d.toString() : d.toString();
	}

	function prepare_info_timer_data(current_time, auction, bidder_id, Rounds) {
	    var i;
	    if (auction.current_stage === -101) {
		return {
		    'countdown': false,
		    'start_time': true,
		    'msg': 'Auction has not started and will be rescheduled'
		};
	    }
	    if (auction.current_stage === -100) {
		return {
		    'countdown': false,
		    'start_time': true,
		    'msg': 'Tender cancelled'
		};
	    }
	    if (auction.current_stage === -1) {
		var until_seconds = (new Date(auction.stages[0].start) - current_time) / 1000;
		if (until_seconds > -120){
		    return {
			'countdown': (until_seconds) + Math.random(),
			'start_time': false,
			'msg': 'until the auction starts'
		    };
		}else{
		    return {
			'countdown': false,
			'start_time': true,
			'msg': 'Auction has not started and will be rescheduled'
		    };
		}

	    }
	    if ((auction.stages[auction.current_stage].type || '') == "pre-sealedbid") {
		return {
		    'countdown': ((new Date(auction.stages[auction.current_stage + 1].start) - current_time) / 1000) + Math.random(),
		    'start_time': false,
		    'msg': 'until the round starts'
		};
	    }
	    if ((auction.stages[auction.current_stage].type || '') == "sealedbid") {
		return {
		    'countdown': ((new Date(auction.stages[auction.current_stage + 1].start) - current_time) / 1000) + Math.random(),
		    'start_time': false,
		    'msg': 'until the round ends'
		};
	    }

	    if ((auction.stages[auction.current_stage].type === 'pause')) {
		return {
		    'countdown': ((new Date(auction.stages[auction.current_stage + 1].start) - current_time) / 1000) + Math.random(),
		    'start_time': false,
		    'msg': 'until the round starts'
		};
	    }
	    if ((auction.stages[auction.current_stage].type.startsWith('dutch'))) {
		return {
			'countdown': ((new Date(auction.stages[auction.current_stage + 1].start) - current_time) / 1000) + Math.random(),
			'start_time': false,
			'msg': 'until the step ends'
		};
	    }
	    if ((auction.stages[auction.current_stage].type || '') == "pre_announcement") {
        var client_time = new Date();
        var ends_time = new Date(auction.stages[auction.current_stage].start);
        if (client_time < ends_time) {
          ends_time = client_time;
        }
        return {
          'countdown': false,
          'start_time': ends_time,
          'msg': 'Аuction was completed',
          'msg_ending': 'Waiting for the disclosure of the participants\' names'
        };
      }
      if ((auction.stages[auction.current_stage].type || '') == "announcement") {
        var client_time = new Date();
        var ends_time = new Date(auction.stages[auction.current_stage - 1].start);
        if (client_time < ends_time) {
          ends_time = client_time;
        }
        return {
          'countdown': false,
          'start_time': ends_time,
          'msg': 'Аuction was completed'
        };}

	}

	function prepare_progress_timer_data(current_time, auction) {

	    if ((((auction.stages[auction.current_stage] || {}).type || '').indexOf('announcement') != -1) || (auction.current_stage === -100) || (auction.current_stage === -101)) {
	    	return {
	    	    'countdown_seconds': false,
	    	    'rounds_seconds': 0,
	    	};
	    }
	    if (auction.current_stage === -1) {
		var until_seconds = (new Date(auction.stages[0].start) - current_time) / 1000;
		if (until_seconds > -120){
		    return {
			'countdown_seconds': until_seconds + Math.random(),
			'rounds_seconds': until_seconds,
		    };
		} else {
		    return {
			'countdown_seconds': false,
			'rounds_seconds': 0,
		    };
		}
	    }
	    if (auction.current_phase == 'pre-sealedbid'){
		var until_seconds = (new Date(auction.stages[auction.current_stage + 1].start) - current_time) / 1000;
		return {
		    'countdown_seconds': until_seconds + Math.random(),
		    'rounds_seconds': until_seconds
		}
		
	    } else {
		return {
		    'countdown_seconds': ((new Date(auction.stages[auction.current_stage + 1].start) - current_time) / 1000) + Math.random(),
		    'rounds_seconds': ((new Date(auction.stages[auction.current_stage + 1].start) - new Date(auction.stages[auction.current_stage].start)) / 1000),
		}
	    }
	}
	// characters 100 true
	function prepare_title_ending_data(auction, lang) {
	    var ending = auction.tenderID + " - " + $filter('characters')((auction['title_' + lang] || auction['title'] || auction['title_en'] || auction['title_ru'] || ""), 50, true);
	    ending += " - ";
	    ending += $filter('characters')(auction.procuringEntity['name_' + lang] || auction.procuringEntity['name'] || auction.procuringEntity['name_en'] || auction.procuringEntity['name_ru'] || "", 50, true);
	    return ending;
	}
	// Get bidder_id from query
	function get_bidder_id() {
	    var query = window.location.search.substring(1);
	    var vars = query.split('&');
	    for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split('=');
{'fraction_non_alphanumeric': 0.1637096000767239, 'fraction_numerical': 0.01419391963172533, 'mean_word_length': 2.975600457491422, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, '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': '7190603', 'n_tokens_mistral': 3886, 'n_tokens_neox': 3467, 'n_words': 710}