﻿file = r'app\Http\Controllers\TestSessionController.php'
with open(file, 'r', encoding='utf-8') as f:
    c = f.read()

# Hapus semua debug code
import re
c = re.sub(r'\n\s+// DEBUG AWAL\n\s+\\\\Log::info\(\'SUBMIT CALLED\'.*?\);\n\s+\\\\Log::error\(\'SUBMIT HIT.*?\);\n', '\n', c)
c = re.sub(r'\n\s+// DEBUG LOG\n\s+\\\\Log::info\(\'SESSION SUBMIT\'.*?\n\s+\]\);\n', '\n', c)
c = re.sub(r'\n\s+file_put_contents\(storage_path.*?\);\n', '\n', c)

# Kembalikan onsubmit validateForm
with open(file, 'w', encoding='utf-8') as f:
    f.write(c)
print("Debug removed from controller")

# Fix fill.blade.php - kembalikan validateForm
file2 = r'resources\views\test-sessions\fill.blade.php'
with open(file2, 'r', encoding='utf-8') as f:
    c2 = f.read()

c2 = c2.replace('onsubmit="return true"', 'onsubmit="return validateForm()"')

with open(file2, 'w', encoding='utf-8') as f:
    f.write(c2)
print("validateForm restored")
