'use strict'; /* admin → questions section (the biggest — список + Q-modal + CSV) */ (function () { 'use strict'; let inited = false; let allQuestions = []; let editingQId = null; let openQId = null; let _topicMap = {}; let _currentType = 'single'; // window._matchPairs is exposed on window because HTML oninput uses bare `_matchPairs[i].left=this.value` window._matchPairs = window._matchPairs || []; let _opts = []; let _focusedInput = null; let _prevTimer = null; const OPT_LETTERS = 'АБВГДЕ'; function updateCharCounter(el, cntId, max) { const n = el.value.length; const cnt = document.getElementById(cntId); if (!cnt) return; cnt.textContent = `${n} / ${max}`; cnt.className = 'char-counter' + (n > max * 0.9 ? ' warn' : '') + (n >= max ? ' over' : ''); } async function onQSubjectChange() { const slug = document.getElementById('q-subject').value; const sel = document.getElementById('q-topic'); sel.innerHTML = ''; if (slug) { try { const topics = await LS.getTopics(slug); topics.forEach(t => sel.appendChild(new Option(t.name, t.id))); } catch {} } load(); } async function load() { const subject = document.getElementById('q-subject').value; const topic_id = document.getElementById('q-topic').value; const sort = document.getElementById('q-sort').value; const wrap = document.getElementById('q-list-wrap'); wrap.innerHTML = LS.skeleton(5); try { allQuestions = await LS.getQuestions(subject || null, topic_id || null, sort); renderQuestions(); } catch (e) { wrap.innerHTML = `