'use strict';
const fs = require('fs');
const path = require('path');
const targetFile = path.join(__dirname, '../../frontend/lab.html');
let src = fs.readFileSync(targetFile, 'utf-8');
// --- 1. Add «Интерференция» tab button after Призма ---
const tabPrism = '';
const tabInterf = '\n ';
if (src.indexOf('ob-tab-interf') < 0) {
if (src.indexOf(tabPrism) >= 0) {
src = src.replace(tabPrism, tabPrism + tabInterf);
console.log('Added Интерференция tab button');
} else {
console.log('WARN: Prizm tab not found');
}
} else {
console.log('Интерференция tab already present');
}
// --- 2. Add ob-ctrl-interf control panel after ob-ctrl-freebuild ---
// Find end of ob-ctrl-freebuild div (find the closing tag)
const ctrlFreeEnd = '
Тащи линзы или предмет по оси мышью
\n ';
const ctrlFreeEndCR = ' Тащи линзы или предмет по оси мышью
\r\n ';
const ctrlInterfHTML = `
Эксперимент
`;
if (src.indexOf('ob-ctrl-interf') < 0) {
let replaced = false;
if (src.indexOf(ctrlFreeEnd) >= 0) {
src = src.replace(ctrlFreeEnd, ctrlFreeEnd + ctrlInterfHTML);
replaced = true;
} else if (src.indexOf(ctrlFreeEndCR) >= 0) {
src = src.replace(ctrlFreeEndCR, ctrlFreeEndCR + ctrlInterfHTML);
replaced = true;
}
if (replaced) {
console.log('Added ob-ctrl-interf panel');
} else {
console.log('WARN: freebuild ctrl end not found, trying alternate pattern');
// Try finding the shared canvas area comment
const canvasAreaMarker = '