// scenario-create.js — создание и клонирование сценария async function createScenario() { showScenarioEditor(null); } async function cloneScenario(defId, origName) { const newName = prompt('Имя нового сценария (копия «' + origName + '»):', origName + '_copy'); if (!newName) return; try { const r = await fetch('/api/scenario/definitions/' + defId); const def = await r.json(); if (def.error) { alert(def.error); return; } const rr = await fetch('/api/scenario/definitions', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: newName, steps: def.steps }) }); const d = await rr.json(); if (d.error) { alert(d.error); return; } await loadScenarios(); } catch (e) { alert('Ошибка клонирования: ' + e.message); } }