interface EditorConfig { nonce: string; restBase: string; isPremium: boolean; upgradeUrl: string; } declare global { interface Window { accessmateEditorConfig?: EditorConfig; } } const cfg: EditorConfig = window.accessmateEditorConfig ?? { nonce: '', restBase: '/wp-json/accessmate/v1', isPremium: false, upgradeUrl: '', }; export const isPremium: boolean = !!cfg.isPremium; export const upgradeUrl: string = cfg.upgradeUrl; export interface AiProxyResult { text?: string; error?: string; upgrade_url?: string; } export async function aiProxy(task: string, params: Record): Promise { const res = await fetch(`${cfg.restBase}/ai/proxy`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': cfg.nonce, }, body: JSON.stringify({ task, params }), }); return res.json() as Promise; }