/** * Pure consent gate for the Google tag — no React, no DOM, safe on the server * and in the client bundle. uses it; export it to apply the same * rule to your own Google-dependent code. */ /** * Whether the Google tag may load now. Pure, so the consent rule is testable * without a DOM: 'basic' waits for an analytics or marketing grant, 'advanced' * relies on the Consent Mode default and loads as soon as `ready`. */ export function shouldLoadGoogle({ consentMode, ready, state, }: { consentMode: 'advanced' | 'basic' ready: boolean state: { analytics?: boolean; marketing?: boolean } }): boolean { if (!ready) {return false} return consentMode === 'advanced' || Boolean(state.analytics || state.marketing) }