<commit_before>(function(g, factory) {
	if (typeof define==='function' && define.amd) {
		define([], factory);
	}
	else if (typeof module==='object' && typeof require==='function') {
		module.exports = factory();
	}
	else {
		g.tagsInput = factory();
	}
}(this, function() {


	var COMMA = 188,
		LEFT = 37,
		RIGHT = 39,
		DELETE = 46,
		ENTER = 13,
		BACKSPACE = 8,
		TAB = 9

	function tagsInput(input) {
		function el(type, name, text) {
			var d = document.createElement(type);
			if(name) d.className = name;
			if(text) d.textContent = text;
			return d;
		}

		function $(s, a) {
			return base['querySelector'+(a?'All':'')](s);
		}

		function save() {
			input.value = [].map.call($('.tag', true), function(tag) {
				return tag.textContent;
			}).join(',');
			input.dispatchEvent(new Event('change'));
		}

		function add(text) {
			if (!(text=text.trim())) return false;
			if (!input.getAttribute('duplicates')) {
				var d = $('[data-tag="'+text+'"]');
				if (d) {
					d.classList.add('dupe');
					setTimeout(function(){ d.classList.remove('dupe'); }, 100);
					return false;
				}
			}
			base.insertBefore(el('span', 'tag', text), base.input).setAttribute('data-tag',text);
		}

		function select(el) {
			var sel = $('.selected');
			if (sel) sel.classList.remove('selected');
			if (el) el.classList.add('selected');
		}

		function width() {
			var last = [].pop.call($('.tag',true));
			if (!base.offsetWidth) return;
			base.input.style.width = Math.max(
				base.offsetWidth-(last?(last.offsetLeft+last.offsetWidth):5)-5,
				base.offsetWidth/4
			) + 'px';
		}

		var base = el('div', 'tags-input'),
			sib = input.nextSibling;

		input.parentNode[sib?'insertBefore':'appendChild'](base, sib);

		input.style.cssText = 'position:absolute;left:0;top:-99px;width:1px;height:1px;opacity:0.01;';
		input.tabIndex = -1;

		base.input = el('input');
		base.input.setAttribute('type', 'text');
		base.input.placeholder = input.placeholder;
		base.input.pattern = input.pattern;
		base.appendChild(base.input);

		delete input.pattern;
		input.onfocus = function() {
			base.input.focus();
		};

		base.input.onfocus = function() {
			base.classList.add('focus');
			select();
		};

		base.input.onblur = function() {
			base.classList.remove('focus');
			select();
		};

		base.input.onkeydown = function(e) {
			var key = e.keyCode || e.which,
				sel = $('.selected'),
				pos = this.selectionStart===this.selectionEnd && this.selectionStart,
				last = [].pop.call($('.tag',true));

			width();

			if (key===ENTER || key===COMMA || key===TAB) {
				if (!this.value && key!==COMMA) return;
				if (add(this.value)!==false) {
					save();
					this.value = '';
					width();
				}
			}
			else if (key===DELETE && sel) {
				if (sel.nextSibling!==base.input) select(sel.nextSibling);
				base.removeChild(sel);
				width();
				save();
			}
			else if (key===BACKSPACE) {
				if (sel) {
					select(sel.previousSibling);
					base.removeChild(sel);
					width();
					save();
				}
				else if (last && pos===0) {
					select(last);
				}
				else {
					return;
				}
			}
			else if (key===LEFT) {
				if (sel) {
					if (sel.previousSibling) {
						select(sel.previousSibling);
					}<commit_msg>Save partially entered text if the user uses the mouse to navigate elsewhere.<commit_after>(function(g, factory) {
	if (typeof define==='function' && define.amd) {
		define([], factory);
	}
	else if (typeof module==='object' && typeof require==='function') {
		module.exports = factory();
	}
	else {
		g.tagsInput = factory();
	}
}(this, function() {


	var COMMA = 188,
		LEFT = 37,
		RIGHT = 39,
		DELETE = 46,
		ENTER = 13,
		BACKSPACE = 8,
		TAB = 9

	function tagsInput(input) {
		function el(type, name, text) {
			var d = document.createElement(type);
			if(name) d.className = name;
			if(text) d.textContent = text;
			return d;
		}

		function $(s, a) {
			return base['querySelector'+(a?'All':'')](s);
		}

		function save() {
			input.value = [].map.call($('.tag', true), function(tag) {
				return tag.textContent;
			}).join(',');
			input.dispatchEvent(new Event('change'));
		}

		function add(text) {
			if (!(text=text.trim())) return false;
			if (!input.getAttribute('duplicates')) {
				var d = $('[data-tag="'+text+'"]');
				if (d) {
					d.classList.add('dupe');
					setTimeout(function(){ d.classList.remove('dupe'); }, 100);
					return false;
				}
			}
			base.insertBefore(el('span', 'tag', text), base.input).setAttribute('data-tag',text);
		}

		function select(el) {
			var sel = $('.selected');
			if (sel) sel.classList.remove('selected');
			if (el) el.classList.add('selected');
		}

		function width() {
			var last = [].pop.call($('.tag',true));
			if (!base.offsetWidth) return;
			base.input.style.width = Math.max(
				base.offsetWidth-(last?(last.offsetLeft+last.offsetWidth):5)-5,
				base.offsetWidth/4
			) + 'px';
		}

		function savePartialInput(input) {
			if (add(input.value)!==false) {
				save();
				input.value = '';
				width();
			}
		}

		var base = el('div', 'tags-input'),
			sib = input.nextSibling;

		input.parentNode[sib?'insertBefore':'appendChild'](base, sib);

		input.style.cssText = 'position:absolute;left:0;top:-99px;width:1px;height:1px;opacity:0.01;';
		input.tabIndex = -1;

		base.input = el('input');
		base.input.setAttribute('type', 'text');
		base.input.placeholder = input.placeholder;
		base.input.pattern = input.pattern;
		base.appendChild(base.input);

		delete input.pattern;
		input.onfocus = function() {
			base.input.focus();
		};

		base.input.onfocus = function() {
			base.classList.add('focus');
			select();
		};

		base.input.onblur = function() {
			base.classList.remove('focus');
			select();
			savePartialInput(this);
		};

		base.input.onkeydown = function(e) {
			var key = e.keyCode || e.which,
				sel = $('.selected'),
				pos = this.selectionStart===this.selectionEnd && this.selectionStart,
				last = [].pop.call($('.tag',true));

			width();

			if (key===ENTER || key===COMMA || key===TAB) {
				if (!this.value && key!==COMMA) return;
				savePartialInput(this);
			}
			else if (key===DELETE && sel) {
				if (sel.nextSibling!==base.input) select(sel.nextSibling);
				base.removeChild(sel);
				width();
				save();
			}
			else if (key===BACKSPACE) {
				if (sel) {
					select(sel.previousSibling);
					base.removeChild(sel);
					width();
					save();
				}
				else if (last && pos===0) {
					select(last);
				}
				else {
					return;
				}
			}
			else if (key===LEFT) {
				if (sel) {
					if (sel.previousSibling) {
						select(sel.previousSibling);
					}
{'fraction_non_alphanumeric': 0.1973046638400969, 'fraction_numerical': 0.008782556026650516, 'mean_word_length': 3.1777356103731815, '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': '5953065', 'n_tokens_mistral': 2831, 'n_tokens_neox': 2306, 'n_words': 438}