<commit_before>(function(angular) {
	// Just in case...
	if (!Array.prototype.indexOf) {
		Array.prototype.indexOf = function (searchElement, fromIndex) {
			if ( this === undefined || this === null ) {
				throw new TypeError( '"this" is null or not defined' );
			}

			var length = this.length >>> 0; // Hack to convert object.length to a UInt32

			fromIndex = +fromIndex || 0;

			if (Math.abs(fromIndex) === Infinity) {
				fromIndex = 0;
			}

			if (fromIndex < 0) {
				fromIndex += length;
				if (fromIndex < 0) {
					fromIndex = 0;
				}
			}

			for (;fromIndex < length; fromIndex++) {
				if (this[fromIndex] === searchElement) {
					return fromIndex;
				}
			}

			return -1;
		};
	}
	angular.module('mvdSixpack', ['ngCookies'])
		.provider('sixpack', function() {
			var $body
				, _tests = []
				, _choices = {}
				, _opts = {
					baseUrl: '',
					debug: false,
				}
				, sp = window.sixpack;

			this.setOptions = function (options) {
				angular.extend(_opts, options || {});
			}

			this.$get = ['$cookies','$timeout', '$log', function($cookies, $timeout, $log) {
				var _cookiePrefix = 'sixpack-'
					, _session
					, _clientId;

				var _getOrInitSession = function () {
					if (!_session) {
						if (_clientId = $cookies[_cookiePrefix + 'clientId']) {
							_session = new sp.Session({client_id:_clientId, base_url:_opts.baseUrl});
						} else {
							_session = new sp.Session({client_id:undefined, base_url:_opts.baseUrl});
							_session = new sp.Session({client_id:_opts.client_id, base_url:_opts.baseUrl});
							$cookies[_cookiePrefix + 'clientId'] = _clientId = _session.client_id;
						}
						if (_opts.debug) {
							$log.debug('[sixpack] Initialized session with clientId', _clientId, 'and base url', _opts.baseUrl);
						};
					};
					return _session;
				}

				var methods = {
					participate : function (testName, variations, callback) {
						if (_tests.indexOf(testName) < 0) {
							_tests.push(testName);
						} else if (angular.isDefined(_choices[testName])) {
							var res = _choices[testName];
							if (res === false) {
								// Still loading
								$timeout(function () {
									methods.participate(testName, variations, callback);
								}, 50);
								return;
							};
							if (_opts.debug) {
								$log.info('[sixpack] Using already chosen variation for test', testName, res);
							};
							$timeout(function () {
								callback(res.alternative.name, res);
							});
							return;
						}<commit_msg>don't create 2 sessions in sixpack<commit_after>(function(angular) {
	// Just in case...
	if (!Array.prototype.indexOf) {
		Array.prototype.indexOf = function (searchElement, fromIndex) {
			if ( this === undefined || this === null ) {
				throw new TypeError( '"this" is null or not defined' );
			}

			var length = this.length >>> 0; // Hack to convert object.length to a UInt32

			fromIndex = +fromIndex || 0;

			if (Math.abs(fromIndex) === Infinity) {
				fromIndex = 0;
			}

			if (fromIndex < 0) {
				fromIndex += length;
				if (fromIndex < 0) {
					fromIndex = 0;
				}
			}

			for (;fromIndex < length; fromIndex++) {
				if (this[fromIndex] === searchElement) {
					return fromIndex;
				}
			}

			return -1;
		};
	}
	angular.module('mvdSixpack', ['ngCookies'])
		.provider('sixpack', function() {
			var $body
				, _tests = []
				, _choices = {}
				, _opts = {
					baseUrl: '',
					debug: false,
				}
				, sp = window.sixpack;

			this.setOptions = function (options) {
				angular.extend(_opts, options || {});
			}

			this.$get = ['$cookies','$timeout', '$log', function($cookies, $timeout, $log) {
				var _cookiePrefix = 'sixpack-'
					, _session
					, _clientId;

				var _getOrInitSession = function () {
					if (!_session) {
						if (_clientId = $cookies[_cookiePrefix + 'clientId']) {
							_session = new sp.Session({client_id:_clientId, base_url:_opts.baseUrl});
						} else {
							_session = new sp.Session({client_id:_opts.client_id, base_url:_opts.baseUrl});
							$cookies[_cookiePrefix + 'clientId'] = _clientId = _session.client_id;
						}
						if (_opts.debug) {
							$log.debug('[sixpack] Initialized session with clientId', _clientId, 'and base url', _opts.baseUrl);
						};
					};
					return _session;
				}

				var methods = {
					participate : function (testName, variations, callback) {
						if (_tests.indexOf(testName) < 0) {
							_tests.push(testName);
						} else if (angular.isDefined(_choices[testName])) {
							var res = _choices[testName];
							if (res === false) {
								// Still loading
								$timeout(function () {
									methods.participate(testName, variations, callback);
								}, 50);
								return;
							};
							if (_opts.debug) {
								$log.info('[sixpack] Using already chosen variation for test', testName, res);
							};
							$timeout(function () {
								callback(res.alternative.name, res);
							});
							return;
						}
{'fraction_non_alphanumeric': 0.15048543689320387, 'fraction_numerical': 0.0050566343042071195, 'mean_word_length': 2.50709219858156, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '2882035', 'n_tokens_mistral': 2207, 'n_tokens_neox': 1561, 'n_words': 355}