/**
* CSA Advisory - Advanced Consent Manager (Google v2 + Audit)
* * ARCHITECTURE:
* 1. Default: All Google Tags are blocked (Denied).
* 2. Interaction: User accepts via Banner.
* 3. Action A (Marketing): Calls gtag('update', 'granted') -> Fires GA4/Ads.
* 4. Action B (Legal): Sends Audit Log to Compliance API (Port 5007).
*/
const CONSENT_API = "http://localhost:5007/api/v1/audit/consent";
const COOKIE_NAME = "csa_consent_v2";
const CookieManager = {
init: function() {
// Check LocalStorage
const saved = localStorage.getItem(COOKIE_NAME);
if (!saved) {
this.showBanner();
} else {
const consent = JSON.parse(saved);
// Re-apply consent on every page load to ensure GTM catches it
this.updateGoogle(consent.status);
}
},
showBanner: function() {
if(document.getElementById('csa-cookie-banner')) return;
const banner = document.createElement('div');
banner.id = 'csa-cookie-banner';
banner.className = 'fixed-bottom bg-white border-top shadow-lg p-4 animate__animated animate__slideInUp';
banner.style.zIndex = '99999';
banner.innerHTML = `
Privacy Settings
We use cookies to analyze traffic and personalize content (Google Ads/GA4).
By clicking "Accept All", you consent to the use of all cookies and the transfer of data to Google.
We log your consent for legal compliance.
Read Policy.