// clerk.jsx — loads Clerk's hosted browser SDK (no build step) and exposes a // tiny session facade on window.MC_CLERK. Loaded before app.jsx. The // publishable key is fetched from /api/config at runtime, so it is never // hard-coded here. const CLERK_SRC = "https://cdn.jsdelivr.net/npm/@clerk/clerk-js@5/dist/clerk.browser.js"; let _clerkPromise = null; function _loadScript(src, publishableKey) { return new Promise((resolve, reject) => { const existing = document.querySelector("script[data-clerk-sdk]"); if (existing) { // If a prior load failed (e.g. missing key), drop the dead tag so the // retry can attach the attribute and re-run the SDK's auto-init. if (!window.Clerk) existing.remove(); else { resolve(); return; } } const s = document.createElement("script"); s.src = src; s.async = true; s.crossOrigin = "anonymous"; s.setAttribute("data-clerk-sdk", "1"); // clerk.browser.js auto-initialises on load and reads the publishable // key from this attribute on its own