// Get CSRF token from meta tag or cookie
export const getCSRFToken = () => {
  // First try to get from meta tag
  const metaToken = document.querySelector('meta[name="_csrf"]')?.getAttribute('content');
  if (metaToken) {
    return metaToken;
  }

  // If meta tag token is not found, try to get from cookie
  const cookies = document.cookie.split(';');
  const xsrfCookie = cookies.find(cookie => cookie.trim().startsWith('XSRF-TOKEN='));
  if (xsrfCookie) {
    return xsrfCookie.split('=')[1].trim();
  }

  return null;
};
