// $.ajaxSetup({
//   complete: function (xhr) {
//     try {
//       if(xhr?.responseText?.includes("Session expired")){
//         window.location.href = "../login.php?error=Timeout-logout";
//       }
//     } catch (e) {
//         console.log("exception",e);
//     }
//   },
// });

$.ajaxSetup({
  complete: function (xhr) {
    try {
      var response = JSON.parse(xhr.responseText);
      if (response?.status === 'error' && response?.redirect) {
        window.top.location.href = response.redirect;
      }
    } catch (e) {
      // console.log("exception",e);
      // console.warn("Non-JSON response or unexpected error:", xhr.responseText);
    }
  },
});