// HAPUS blok kode mockRunner lama sepenuhnya! // GANTI menjadi wrapper Fetch API yang memanggil PHP const gs = { run: { withSuccessHandler: function(cb) { this._success = cb; return this; }, withFailureHandler: function(cb) { this._failure = cb; return this; }, apiHandler: async function(action, payload) { try { // Request ke API PHP di server yang sama const response = await fetch('api.php', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify({ action: action, payload: payload || {} }) }); if (!response.ok) throw new Error('Network response was not ok'); const res = await response.json(); // Panggil callback otomatis seperti di Google Apps Script if(this._success) this._success(res); } catch (err) { if(this._failure) { this._failure(err); } else { Swal.fire('Error System', 'Gagal memproses data dari Server API: ' + err.message, 'error'); } } }, login: function(u, p) { // Redirect panggilan login gs.run...login() menjadi format apiHandler standar const inst = this; inst.apiHandler('LOGIN', {username: u, password: p}).catch(err => { Swal.fire('Error Kredensial', String(err), 'error'); }); } } };