export declare const ANALYTICS_PROVIDER_SNIPPET_MINIMAL = "\nimport {createContext, useState} from 'react'\n\n// Used for the example theme switcher component\nexport const AnalyticsContext = createContext({})\n\n// Demo provider that adds the state for the example theme switcher component.\n// Delete this once you've played around with the theme switcher, and use your\n// own application's theming instead.\nexport const AnalyticsProvider = ({children}) => {\n  const [themeKey, setThemeKey] = useState('light')\n\n  return (\n    <AnalyticsContext.Provider value={{themeKey, setThemeKey}}>\n      {children}\n    </AnalyticsContext.Provider>\n  )\n}\n";
export declare const ANALYTICS_PROVIDER_SNIPPET_WITH_USER_SWITCHER = "\nimport {createContext, useCallback, useEffect, useState} from 'react'\n\nexport const BASE_SSO_API = 'http://localhost:4477'\n\n// Used for the example theme switcher and user switcher components\nexport const AnalyticsContext = createContext({})\n\nconst AUTH_SERVER_DOWN_MESSAGE = `\n  Auth server is down.\n  Please start the server with 'npm run start'\n`\n\n// Demo provider that adds the state for the example user and theme switcher component.\n// Delete this once you've implemented user authentication and theming in your application.\nexport const AnalyticsProvider = ({children}) => {\n  const [email, setEmail] = useState(null)\n  const [authError, setAuthError] = useState(null)\n  const [themeKey, setThemeKey] = useState('light')\n\n  const switchUser = useCallback(async (email) => {\n    localStorage.setItem('user-email', email)\n\n    try {\n      const res = await fetch(`${BASE_SSO_API}/switch-user`, {\n        method: 'POST',\n        body: JSON.stringify({email}),\n        headers: {'content-type': 'application/json'},\n        credentials: 'include'\n      })\n\n      if (!res.ok) {\n        setAuthError(await res.text())\n        return\n      }\n\n      setEmail(email)\n    } catch (error) {\n      const message = error instanceof Error ? error.message : error\n\n      if (message.includes('Failed to fetch')) {\n        setAuthError(AUTH_SERVER_DOWN_MESSAGE)\n        return\n      }\n\n      setAuthError(message)\n    }\n  }, [])\n\n  const context = {email, switchUser, authError, themeKey, setThemeKey}\n\n  useEffect(() => {\n    if (!email) {\n      switchUser(localStorage.getItem('user-email') || 'alice@example.com')\n    }\n  }, [email, switchUser])\n\n  if (authError) {\n    return (\n      <div className=\"analytics-auth-container\">\n        Login failed. Reason: {authError}\n      </div>\n    )\n  }\n\n  if (!email) {\n    return <div className=\"analytics-auth-container\">Logging In...</div>\n  }\n\n  return (\n    <AnalyticsContext.Provider value={context}>\n      {children}\n    </AnalyticsContext.Provider>\n  )\n}\n";
