(function() { 'use strict'; let toastId = 0; const container = document.createElement('div'); container.className = 'toast-container'; container.id = 'toastContainer'; document.body.appendChild(container); function escapeHtml(text) { const d = document.createElement('div'); d.textContent = text || ''; return d.innerHTML; } window.Notify = { toast: function(message, type, title) { if (!message) return; type = type || 'info'; const icons = { success: '✓', error: '✕', info: 'ℹ', warning: '⚠' }; const titles = { success: title || 'Успешно', error: title || 'Ошибка', info: title || 'Информация', warning: title || 'Внимание' }; const icon = icons[type] || 'ℹ'; const t = titles[type]; const id = ++toastId; const el = document.createElement('div'); el.className = 'toast toast-' + type; el.id = 'toast-' + id; el.innerHTML = '
' + icon + '
' + '
' + '
' + escapeHtml(t) + '
' + '
' + escapeHtml(message) + '
' + '
' + ''; container.appendChild(el); const timeout = setTimeout(function() { Notify.dismiss(id); }, 4000); el._timeout = timeout; el._id = id; return id; }, success: function(message) { return this.toast(message, 'success'); }, error: function(message) { return this.toast(message, 'error'); }, info: function(message) { return this.toast(message, 'info'); }, warning: function(message) { return this.toast(message, 'warning'); }, dismiss: function(id) { var el = document.getElementById('toast-' + id); if (!el) return; if (el._timeout) clearTimeout(el._timeout); if (el.classList.contains('toast-removing')) return; el.classList.add('toast-removing'); setTimeout(function() { if (el.parentNode) el.parentNode.removeChild(el); }, 250); }, confirm: function(message, title, callback) { if (typeof title === 'function') { callback = title; title = 'Подтверждение'; } title = title || 'Подтверждение'; var overlay = document.createElement('div'); overlay.className = 'confirm-overlay'; overlay.innerHTML = '
' + '
' + '
' + '
' + escapeHtml(title) + '
' + '
' + '
' + escapeHtml(message) + '
' + '
' + '' + '' + '
' + '
'; document.body.appendChild(overlay); var result = false; function close() { if (overlay.parentNode) overlay.parentNode.removeChild(overlay); if (callback) callback(result); } overlay.querySelector('.confirm-cancel').addEventListener('click', function() { result = false; close(); }); overlay.querySelector('.confirm-ok').addEventListener('click', function() { result = true; close(); }); overlay.addEventListener('click', function(e) { if (e.target === overlay) { result = false; close(); } }); document.addEventListener('keydown', function handler(e) { if (e.key === 'Escape') { result = false; close(); document.removeEventListener('keydown', handler); } }); return overlay; } }; })();