const DEFAULT_API_BASE = '/api/audit';
export async function emit_form_intent(event_name, payload, audit) {
    if (!audit)
        return;
    const api_base = audit.api_base ?? DEFAULT_API_BASE;
    try {
        await fetch(`${api_base}/intent`, {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({
                event_name,
                payload,
                subject_kind: audit.subjectKind,
                subject_id: audit.subjectId,
            }),
            keepalive: true,
        });
    }
    catch (err) {
        if (typeof console !== 'undefined') {
            console.warn('audit_intent_failed', event_name, err);
        }
    }
}
//# sourceMappingURL=intent_emitter.js.map