<commit_before>(function (context) {

	var __dialogs = {};
	var __count = 0;

	core.Module("savvy.Dialog", {
		create: function (settings) {
			var self = this;

			var id = 'dialog_' + __count;

			var parent = settings.parentNode ? settings.parentNode : document.body;

			var overlay = savvy.Dom.div({
				id: id,
				className: 'savvy-overlay ' + (settings.overlay ? 'fade' : '')
			});

			var dialog = savvy.Dom.div({
				className: 'savvy-dialog ' + (settings.className ? settings.className : ''),
				parentNode: overlay
			});

			var title = null;
			if (settings.title) {
				if (typeof(settings.title) === "string") {
					title = savvy.Dom.div({
						innerHTML: settings.title, 
						className: 'savvy-dialog_title', 
						parentNode: dialog
					});
				} else if (settings.title.appendChild) {
					title = settings.title;
					dialog.appendChild(title);
				}
			}

			var content = null;
			if (settings.content) {
				if (typeof(settings.content) === "string") {
					content = savvy.Dom.div({
						innerHTML: settings.content, 
						className: 'savvy-dialog_content', 
						parentNode: dialog
					});
				} else if (settings.content.appendChild) {
					content = settings.content;
					dialog.appendChild(content);
				}
			}

			var close = null;
			if (settings.close) {
				close = savvy.Button.create({
					className: 'close',
					parentNode: dialog,
					callback: function () {
						self.destroy(id);
					}
				});
			}

			var buttons = null, button, b;
			var makeUniqueButton = function (data) {
				var cb = null;
				if (data.callback) {
					cb = data.callback;
				}

				data.callback = function () {
					self.destroy(id, function () {
						cb ? cb() : null;
					});
				};

				savvy.Button.create(data);
			};

			var makeCustomButton = function (data) {
				savvy.Button.create(data);
			};

			var buttonContainer = null;
			if (settings.buttons) {
				buttonContainer = savvy.Dom.div({className: 'savvy-dialog_buttons', parentNode: dialog});
				buttons = settings.buttons;

				for (b in buttons) {

					button = buttons[b];
					button.parentNode = button.parentNode || buttonContainer;

					if (b === 'cancel' ||
						b === 'confirm') {
						makeUniqueButton(button);
						continue;
					}

					makeCustomButton(button);
				}
			}

			parent ? parent.appendChild(overlay) : null;

			setTimeout(function () {
				savvy.Dom.addClass(overlay, 'show');
			}, 0);

			__dialogs[id] = overlay;

			__count ++;
		},

		destroy: function (id, cb) {
			var overlay = __dialogs[id];

			if (!overlay) {
				return;<commit_msg>Dialogs have custom ids if needed.<commit_after>(function (context) {

	var __dialogs = {};
	var __count = 0;

	core.Module("savvy.Dialog", {
		create: function (settings) {
			var self = this;

			var id = settings.id || 'dialog_' + __count;

			var parent = settings.parentNode ? settings.parentNode : document.body;

			var overlay = savvy.Dom.div({
				id: id,
				className: 'savvy-overlay ' + (settings.overlay ? 'fade' : '')
			});

			var dialog = savvy.Dom.div({
				className: 'savvy-dialog ' + (settings.className ? settings.className : ''),
				parentNode: overlay
			});

			var title = null;
			if (settings.title) {
				if (typeof(settings.title) === "string") {
					title = savvy.Dom.div({
						innerHTML: settings.title, 
						className: 'savvy-dialog_title', 
						parentNode: dialog
					});
				} else if (settings.title.appendChild) {
					title = settings.title;
					dialog.appendChild(title);
				}
			}

			var content = null;
			if (settings.content) {
				if (typeof(settings.content) === "string") {
					content = savvy.Dom.div({
						innerHTML: settings.content, 
						className: 'savvy-dialog_content', 
						parentNode: dialog
					});
				} else if (settings.content.appendChild) {
					content = settings.content;
					dialog.appendChild(content);
				}
			}

			var close = null;
			if (settings.close) {
				close = savvy.Button.create({
					className: 'close',
					parentNode: dialog,
					callback: function () {
						self.destroy(id);
					}
				});
			}

			var buttons = null, button, b;
			var makeUniqueButton = function (data) {
				var cb = null;
				if (data.callback) {
					cb = data.callback;
				}

				data.callback = function () {
					self.destroy(id, function () {
						cb ? cb() : null;
					});
				};

				savvy.Button.create(data);
			};

			var makeCustomButton = function (data) {
				savvy.Button.create(data);
			};

			var buttonContainer = null;
			if (settings.buttons) {
				buttonContainer = savvy.Dom.div({className: 'savvy-dialog_buttons', parentNode: dialog});
				buttons = settings.buttons;

				for (b in buttons) {

					button = buttons[b];
					button.parentNode = button.parentNode || buttonContainer;

					if (b === 'cancel' ||
						b === 'confirm') {
						makeUniqueButton(button);
						continue;
					}

					makeCustomButton(button);
				}
			}

			parent ? parent.appendChild(overlay) : null;

			setTimeout(function () {
				savvy.Dom.addClass(overlay, 'show');
			}, 0);

			__dialogs[id] = overlay;

			__count ++;
		},

		get: function (id) {
			return __dialogs[id];
		},

		destroy: function (id, cb) {
			var overlay = __dialogs[id];

			if (!overlay) {
				return;
{'fraction_non_alphanumeric': 0.14576981707317074, 'fraction_numerical': 0.0007621951219512195, 'mean_word_length': 2.534680134680135, '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': '623927', 'n_tokens_mistral': 2259, 'n_tokens_neox': 1638, 'n_words': 364}