import React$1, { ReactNode, MutableRefObject } from 'react';
import { z } from 'zod';
import * as react_jsx_runtime from 'react/jsx-runtime';
import * as consola from 'consola';

/**
 * Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
 * * `email` - Email
 * * `phone` - Phone
 */
declare enum OTPRequestRequestChannel {
    EMAIL = "email",
    PHONE = "phone"
}

/**
 * Zod schema for OTPRequestRequest
 *
 * This schema provides runtime validation and type inference.
 *  * Serializer for OTP request.
 *  */

/**
 * Serializer for OTP request.
 */
declare const OTPRequestRequestSchema: z.ZodObject<{
    identifier: z.ZodString;
    channel: z.ZodOptional<z.ZodEnum<typeof OTPRequestRequestChannel>>;
    source_url: z.ZodOptional<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
}, z.core.$strip>;
/**
 * Infer TypeScript type from Zod schema
 */
type OTPRequestRequest = z.infer<typeof OTPRequestRequestSchema>;

/**
 * Zod schema for OTPRequestResponse
 *
 * This schema provides runtime validation and type inference.
 *  * OTP request response.
 *  */

/**
 * OTP request response.
 */
declare const OTPRequestResponseSchema: z.ZodObject<{
    message: z.ZodString;
}, z.core.$strip>;
/**
 * Infer TypeScript type from Zod schema
 */
type OTPRequestResponse = z.infer<typeof OTPRequestResponseSchema>;

/**
 * Zod schema for OTPVerifyRequest
 *
 * This schema provides runtime validation and type inference.
 *  * Serializer for OTP verification.
 *  */

/**
 * Serializer for OTP verification.
 */
declare const OTPVerifyRequestSchema: z.ZodObject<{
    identifier: z.ZodString;
    otp: z.ZodString;
    channel: z.ZodOptional<z.ZodEnum<typeof OTPRequestRequestChannel>>;
    source_url: z.ZodOptional<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
}, z.core.$strip>;
/**
 * Infer TypeScript type from Zod schema
 */
type OTPVerifyRequest = z.infer<typeof OTPVerifyRequestSchema>;

/**
 * Zod schema for OTPVerifyResponse
 *
 * This schema provides runtime validation and type inference.
 *  * OTP verification response.

When 2FA is required:
- requires_2fa: True
- session_id: UUID of 2FA verification session
- refresh/access/user: null

When 2FA is not required:
- requires_2fa: False
- session_id: null
- refresh/access/user: populated
 *  */

/**
 * OTP verification response.

When 2FA is required:
- requires_2fa: True
- session_id: UUID of 2FA verification session
- refresh/access/user: null

When 2FA is not required:
- requires_2fa: False
- session_id: null
- refresh/access/user: populated
 */
declare const OTPVerifyResponseSchema: z.ZodObject<{
    requires_2fa: z.ZodOptional<z.ZodBoolean>;
    session_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
    refresh: z.ZodOptional<z.ZodNullable<z.ZodString>>;
    access: z.ZodOptional<z.ZodNullable<z.ZodString>>;
    user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
        id: z.ZodInt;
        email: z.ZodEmail;
        first_name: z.ZodOptional<z.ZodString>;
        last_name: z.ZodOptional<z.ZodString>;
        full_name: z.ZodString;
        initials: z.ZodString;
        display_username: z.ZodString;
        company: z.ZodOptional<z.ZodString>;
        phone: z.ZodOptional<z.ZodString>;
        position: z.ZodOptional<z.ZodString>;
        avatar: z.ZodNullable<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
        is_staff: z.ZodBoolean;
        is_superuser: z.ZodBoolean;
        date_joined: z.ZodString;
        last_login: z.ZodNullable<z.ZodString>;
        unanswered_messages_count: z.ZodInt;
        centrifugo: z.ZodNullable<z.ZodObject<{
            token: z.ZodString;
            centrifugo_url: z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>;
            expires_at: z.ZodString;
            channels: z.ZodArray<z.ZodString>;
        }, z.core.$strip>>;
    }, z.core.$strip>>>;
    should_prompt_2fa: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>;
/**
 * Infer TypeScript type from Zod schema
 */
type OTPVerifyResponse = z.infer<typeof OTPVerifyResponseSchema>;

/**
 * Zod schema for PatchedUserProfileUpdateRequest
 *
 * This schema provides runtime validation and type inference.
 *  * Serializer for updating user profile.
 *  */

/**
 * Serializer for updating user profile.
 */
declare const PatchedUserProfileUpdateRequestSchema: z.ZodObject<{
    first_name: z.ZodOptional<z.ZodString>;
    last_name: z.ZodOptional<z.ZodString>;
    company: z.ZodOptional<z.ZodString>;
    phone: z.ZodOptional<z.ZodString>;
    position: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
/**
 * Infer TypeScript type from Zod schema
 */
type PatchedUserProfileUpdateRequest = z.infer<typeof PatchedUserProfileUpdateRequestSchema>;

/**
 * Zod schema for TokenRefresh
 *
 * This schema provides runtime validation and type inference.
 *  */

declare const TokenRefreshSchema: z.ZodObject<{
    access: z.ZodString;
    refresh: z.ZodString;
}, z.core.$strip>;
/**
 * Infer TypeScript type from Zod schema
 */
type TokenRefresh = z.infer<typeof TokenRefreshSchema>;

/**
 * Zod schema for User
 *
 * This schema provides runtime validation and type inference.
 *  * Serializer for user details.
 *  */

/**
 * Serializer for user details.
 */
declare const UserSchema: z.ZodObject<{
    id: z.ZodInt;
    email: z.ZodEmail;
    first_name: z.ZodOptional<z.ZodString>;
    last_name: z.ZodOptional<z.ZodString>;
    full_name: z.ZodString;
    initials: z.ZodString;
    display_username: z.ZodString;
    company: z.ZodOptional<z.ZodString>;
    phone: z.ZodOptional<z.ZodString>;
    position: z.ZodOptional<z.ZodString>;
    avatar: z.ZodNullable<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
    is_staff: z.ZodBoolean;
    is_superuser: z.ZodBoolean;
    date_joined: z.ZodString;
    last_login: z.ZodNullable<z.ZodString>;
    unanswered_messages_count: z.ZodInt;
    centrifugo: z.ZodNullable<z.ZodObject<{
        token: z.ZodString;
        centrifugo_url: z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>;
        expires_at: z.ZodString;
        channels: z.ZodArray<z.ZodString>;
    }, z.core.$strip>>;
}, z.core.$strip>;
/**
 * Infer TypeScript type from Zod schema
 */
type User = z.infer<typeof UserSchema>;

/**
 * Zod schema for UserProfileUpdateRequest
 *
 * This schema provides runtime validation and type inference.
 *  * Serializer for updating user profile.
 *  */

/**
 * Serializer for updating user profile.
 */
declare const UserProfileUpdateRequestSchema: z.ZodObject<{
    first_name: z.ZodOptional<z.ZodString>;
    last_name: z.ZodOptional<z.ZodString>;
    company: z.ZodOptional<z.ZodString>;
    phone: z.ZodOptional<z.ZodString>;
    position: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
/**
 * Infer TypeScript type from Zod schema
 */
type UserProfileUpdateRequest = z.infer<typeof UserProfileUpdateRequestSchema>;

type UserProfile = User;
interface AuthConfig {
    apiUrl?: string;
    routes?: {
        auth?: string;
        defaultCallback?: string;
        defaultAuthCallback?: string;
    };
    onLogout?: () => void;
    onConfirm?: (options: {
        title: string;
        description: string;
        confirmationButtonText: string;
        cancellationButtonText: string;
        color: string;
    }) => Promise<{
        confirmed: boolean;
    }>;
}
interface AuthContextType {
    user: UserProfile | null;
    isLoading: boolean;
    isAuthenticated: boolean;
    isAdminUser: boolean;
    loadCurrentProfile: (callerId?: string) => Promise<void>;
    checkAuthAndRedirect: () => Promise<void>;
    getToken: () => string | null;
    getRefreshToken: () => string | null;
    getSavedEmail: () => string | null;
    saveEmail: (email: string) => void;
    clearSavedEmail: () => void;
    getSavedPhone: () => string | null;
    savePhone: (phone: string) => void;
    clearSavedPhone: () => void;
    requestOTP: (identifier: string, channel?: 'email' | 'phone', sourceUrl?: string) => Promise<{
        success: boolean;
        message: string;
    }>;
    verifyOTP: (identifier: string, otpCode: string, channel?: 'email' | 'phone', sourceUrl?: string, redirectUrl?: string, skipRedirect?: boolean) => Promise<{
        success: boolean;
        message: string;
        user?: UserProfile;
        requires_2fa?: boolean;
        session_id?: string | null;
        should_prompt_2fa?: boolean;
    }>;
    refreshToken: () => Promise<{
        success: boolean;
        message: string;
    }>;
    logout: (options?: {
        skipConfirm?: boolean;
    }) => Promise<void>;
    saveRedirectUrl: (url: string) => void;
    getRedirectUrl: () => string;
    clearRedirectUrl: () => void;
    hasRedirectUrl: () => boolean;
    updateProfile: (data: {
        first_name?: string;
        last_name?: string;
        username?: string;
    }) => Promise<UserProfile>;
    uploadAvatar: (avatar: File | Blob) => Promise<UserProfile>;
}
interface AuthProviderProps {
    children: React$1.ReactNode;
    config?: AuthConfig;
}

declare const AuthProvider: React$1.FC<AuthProviderProps>;
/**
 * Hook to access auth context
 *
 * SSR-safe: Returns default unauthenticated state when called outside AuthProvider
 * (e.g., during static page generation or server-side rendering)
 */
declare const useAuth: () => AuthContextType;

interface AccountsContextValue {
    profile?: User;
    isLoadingProfile: boolean;
    profileError: Error | null;
    updateProfile: (data: UserProfileUpdateRequest) => Promise<User>;
    partialUpdateProfile: (data: PatchedUserProfileUpdateRequest) => Promise<User>;
    uploadAvatar: (avatar: File | Blob) => Promise<User>;
    refreshProfile: (options?: {
        callerId?: string;
        force?: boolean;
    }) => Promise<User | undefined>;
    requestOTP: (data: OTPRequestRequest) => Promise<OTPRequestResponse>;
    verifyOTP: (data: OTPVerifyRequest) => Promise<OTPVerifyResponse>;
    refreshToken: (refresh: string) => Promise<TokenRefresh>;
    logout: () => void;
}
interface AccountsProviderProps {
    children: ReactNode;
}
declare function AccountsProvider({ children }: AccountsProviderProps): react_jsx_runtime.JSX.Element;
declare function useAccountsContext(): AccountsContextValue;

/**
 * Universal Router Hook with BasePath Support
 *
 * Wrapper around Next.js useRouter that automatically handles basePath
 * for static builds served via iframe or subdirectory
 *
 * IMPORTANT: In Next.js 15 App Router, router.push() does NOT automatically
 * handle basePath (unlike Pages Router). This is a breaking change in App Router.
 *
 * This hook ensures basePath is always included when navigating, especially
 * important for static exports served via iframe where basePath is critical.
 *
 * @see https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration
 */
/**
 * Router with basePath support
 *
 * Automatically adds basePath to all navigation methods when basePath is configured.
 * In Next.js 15 App Router, router.push() doesn't handle basePath automatically,
 * so this hook uses window.location to ensure basePath is always included.
 *
 * @example
 * ```tsx
 * const router = useCfgRouter();
 *
 * // With basePath='/cfg/admin':
 * router.push('/dashboard');     // Client-side navigation to '/cfg/admin/dashboard'
 * router.replace('/auth');       // Client-side replace with '/cfg/admin/auth'
 * router.hardPush('/dashboard'); // Full page reload to '/cfg/admin/dashboard'
 * router.hardReplace('/auth');   // Full page replace with '/cfg/admin/auth'
 * ```
 */
declare function useCfgRouter(): {
    push: (href: string, options?: {
        scroll?: boolean;
    }) => void;
    replace: (href: string, options?: {
        scroll?: boolean;
    }) => void;
    hardPush: (href: string) => void;
    hardReplace: (href: string) => void;
    prefetch: (href: string) => void;
    back: () => void;
    forward: () => void;
    refresh: () => void;
};

/**
 * useQueryParams Hook
 *
 * Safe hook to access URL query parameters without requiring Suspense boundary.
 * Works on client-side only, returns empty URLSearchParams during SSR/prerendering.
 *
 * @example
 * ```tsx
 * const params = useQueryParams();
 * const flow = params.get('flow');
 * const hasFlow = params.has('flow');
 * const allTags = params.getAll('tags');
 * ```
 */
/**
 * Hook to safely access URL query parameters without useSearchParams()
 *
 * This hook reads query parameters directly from window.location.search,
 * avoiding the need for Suspense boundaries that useSearchParams() requires.
 *
 * Automatically updates when URL changes (navigation, back/forward, etc.)
 * Uses pathname from Next.js to detect route changes and polls for query param changes.
 *
 * Returns a URLSearchParams object with get(), getAll(), has(), etc.
 *
 * @returns URLSearchParams object (empty during SSR)
 */
declare function useQueryParams(): URLSearchParams;

/**
 * Auth Form Types
 *
 * Single source of truth for auth form state and handlers.
 * Used by both @djangocfg/api/auth hooks and @djangocfg/layouts/AuthLayout.
 */

type AuthChannel = 'email' | 'phone';
type AuthStep = 'identifier' | 'otp' | '2fa' | '2fa-setup' | 'success';
interface AuthFormState {
    /** Email or phone number */
    identifier: string;
    /** Current auth channel */
    channel: AuthChannel;
    /** OTP code input */
    otp: string;
    /** Loading state */
    isLoading: boolean;
    /** Terms acceptance state */
    acceptedTerms: boolean;
    /** Current form step */
    step: AuthStep;
    /** Error message */
    error: string;
    /** 2FA session ID from OTP/OAuth verification */
    twoFactorSessionId: string | null;
    /** Whether user should be prompted to enable 2FA */
    shouldPrompt2FA: boolean;
    /** 2FA code input */
    twoFactorCode: string;
    /** Using backup code instead of TOTP */
    useBackupCode: boolean;
}
interface AuthFormStateHandlers {
    setIdentifier: (identifier: string) => void;
    setChannel: (channel: AuthChannel) => void;
    setOtp: (otp: string) => void;
    setAcceptedTerms: (accepted: boolean) => void;
    setError: (error: string) => void;
    clearError: () => void;
    setStep: (step: AuthStep) => void;
    setIsLoading: (loading: boolean) => void;
    setTwoFactorSessionId: (sessionId: string | null) => void;
    setShouldPrompt2FA: (prompt: boolean) => void;
    setTwoFactorCode: (code: string) => void;
    setUseBackupCode: (useBackup: boolean) => void;
}
interface AuthFormSubmitHandlers {
    handleIdentifierSubmit: (e: React.FormEvent) => Promise<void>;
    handleOTPSubmit: (e: React.FormEvent) => Promise<void>;
    handleResendOTP: () => Promise<void>;
    handleBackToIdentifier: () => void;
    forceOTPStep: () => void;
    /** Handle 2FA TOTP/backup code verification */
    handle2FASubmit: (e: React.FormEvent) => Promise<void>;
    /** Switch to backup code input */
    handleUseBackupCode: () => void;
    /** Switch back to TOTP input */
    handleUseTOTP: () => void;
}
interface AuthFormValidation {
    /** Detect channel from identifier string */
    detectChannelFromIdentifier: (identifier: string) => AuthChannel | null;
    /** Validate identifier format */
    validateIdentifier: (identifier: string, channel?: AuthChannel) => boolean;
}
interface AuthFormAutoSubmit {
    /** Ref to track if auto-submit from URL is in progress */
    isAutoSubmittingFromUrl: MutableRefObject<boolean>;
}
interface AuthForm2FAState {
    /** Loading state for 2FA verification */
    is2FALoading: boolean;
    /** Warning message from 2FA (e.g., low backup codes) */
    twoFactorWarning: string | null;
}
interface AuthFormReturn extends AuthFormState, AuthFormStateHandlers, AuthFormSubmitHandlers, AuthFormValidation, AuthFormAutoSubmit, AuthForm2FAState {
}
interface UseAuthFormOptions {
    /** Callback when identifier step succeeds */
    onIdentifierSuccess?: (identifier: string, channel: AuthChannel) => void;
    /** Callback when OTP verification succeeds */
    onOTPSuccess?: () => void;
    /** Callback on any error */
    onError?: (message: string) => void;
    /** Source URL for tracking */
    sourceUrl: string;
    /** URL to redirect after successful OTP verification */
    redirectUrl?: string;
    /** If true, user must accept terms before submitting. Default: false */
    requireTermsAcceptance?: boolean;
    /** Path to auth page for auto-OTP detection. Default: '/auth' */
    authPath?: string;
    /**
     * Enable 2FA setup prompt after successful authentication.
     * When true (default), users without 2FA will see a setup prompt after login.
     * When false, users go directly to success without 2FA setup prompt.
     * @default true
     */
    enable2FASetup?: boolean;
}
interface AuthLayoutConfig {
    /** Support page URL */
    supportUrl?: string;
    /** Terms of service URL */
    termsUrl?: string;
    /** Privacy policy URL */
    privacyUrl?: string;
    /** Source URL for tracking */
    sourceUrl: string;
    /** Enable phone authentication tab */
    enablePhoneAuth?: boolean;
    /** Enable GitHub OAuth button */
    enableGithubAuth?: boolean;
    /** Logo URL for success screen (SVG recommended) */
    logoUrl?: string;
    /** URL to redirect after successful auth (default: /dashboard) */
    redirectUrl?: string;
    /**
     * Enable 2FA setup prompt after successful authentication.
     * When true (default), users without 2FA will see a setup prompt after login.
     * When false, users go directly to success without 2FA setup prompt.
     * Note: This only affects the setup prompt - existing 2FA verification still works.
     * @default true
     */
    enable2FASetup?: boolean;
}
interface AuthFormContextType extends AuthFormReturn, AuthLayoutConfig {
}
interface AuthLayoutProps extends AuthLayoutConfig {
    children?: React.ReactNode;
    className?: string;
    /** URL to redirect after successful auth (default: /dashboard) */
    redirectUrl?: string;
    /** Callback when identifier step succeeds */
    onIdentifierSuccess?: (identifier: string, channel: AuthChannel) => void;
    /** Callback when OTP verification succeeds */
    onOTPSuccess?: () => void;
    /** Callback when OAuth succeeds */
    onOAuthSuccess?: (user: any, isNewUser: boolean, provider: string) => void;
    /** Callback on any error */
    onError?: (message: string) => void;
}
interface AuthHelpProps {
    className?: string;
    variant?: 'default' | 'compact';
}

interface UseAuthFormStateReturn extends AuthFormState, AuthFormStateHandlers {
}
/**
 * Hook for auth form state management.
 * Pure state - no side effects, no API calls.
 */
declare const useAuthFormState: (initialIdentifier?: string, initialChannel?: AuthChannel) => UseAuthFormStateReturn;

/**
 * Hook for auth identifier validation.
 * Pure functions - no state, no side effects.
 */
declare const useAuthValidation: () => AuthFormValidation;
declare const detectChannelFromIdentifier: (id: string) => AuthChannel | null;
declare const validateIdentifier: (id: string, channelType?: AuthChannel) => boolean;

/**
 * Complete auth form hook.
 * Composes smaller hooks for state, validation, and submission.
 */
declare const useAuthForm: (options: UseAuthFormOptions) => AuthFormReturn;

interface UseAutoAuthOptions {
    onOTPDetected?: (otp: string) => void;
    cleanupUrl?: boolean;
    /** Paths where auto-auth should be active. Default: ['/auth'] */
    allowedPaths?: string[];
}
/**
 * Hook for automatic authentication from URL query parameters
 * Detects OTP from URL and triggers callback
 */
declare const useAutoAuth: (options?: UseAutoAuthOptions) => {
    isReady: boolean;
    hasOTP: boolean;
    isAllowedPath: boolean;
};

interface UseGithubAuthOptions {
    sourceUrl?: string;
    onSuccess?: (user: any, isNewUser: boolean) => void;
    onError?: (error: string) => void;
    /** Callback when 2FA is required */
    onRequires2FA?: (sessionId: string, shouldPrompt2FA: boolean) => void;
    redirectUrl?: string;
    /** Skip automatic redirect after success (caller handles navigation) */
    skipRedirect?: boolean;
}
interface UseGithubAuthReturn {
    isLoading: boolean;
    error: string | null;
    startGithubAuth: () => Promise<void>;
    handleGithubCallback: (code: string, state: string) => Promise<void>;
}
/**
 * Hook for GitHub OAuth authentication flow.
 *
 * Usage:
 * 1. Call startGithubAuth() to redirect user to GitHub
 * 2. After GitHub redirects back, call handleGithubCallback(code, state)
 *
 * @example
 * ```tsx
 * const { isLoading, error, startGithubAuth } = useGithubAuth({
 *   onSuccess: (user) => router.push('/dashboard'),
 *   onError: (error) => console.error(error),
 * });
 *
 * <Button onClick={startGithubAuth} disabled={isLoading}>
 *   Continue with GitHub
 * </Button>
 * ```
 */
declare const useGithubAuth: (options?: UseGithubAuthOptions) => UseGithubAuthReturn;

interface UseTwoFactorOptions {
    /** Callback on successful 2FA verification */
    onSuccess?: (user: any) => void;
    /** Callback on error */
    onError?: (error: string) => void;
    /** URL to redirect after successful verification */
    redirectUrl?: string;
    /** Skip automatic redirect after success (caller handles navigation) */
    skipRedirect?: boolean;
}
interface UseTwoFactorReturn {
    /** Loading state */
    isLoading: boolean;
    /** Error message */
    error: string | null;
    /** Warning message (e.g., low backup codes) */
    warning: string | null;
    /** Remaining backup codes (if backup code was used) */
    remainingBackupCodes: number | null;
    /** Verify TOTP code */
    verifyTOTP: (sessionId: string, code: string) => Promise<boolean>;
    /** Verify backup code */
    verifyBackupCode: (sessionId: string, backupCode: string) => Promise<boolean>;
    /** Clear error */
    clearError: () => void;
}
/**
 * Hook for 2FA verification during login.
 *
 * Usage:
 * 1. After OTP/OAuth verification returns requires_2fa=true and session_id
 * 2. Show 2FA form and collect TOTP code from user
 * 3. Call verifyTOTP(sessionId, code) to complete authentication
 *
 * @example
 * ```tsx
 * const { isLoading, error, verifyTOTP, verifyBackupCode } = useTwoFactor({
 *   onSuccess: (user) => console.log('Logged in:', user),
 *   onError: (error) => console.error(error),
 *   redirectUrl: '/dashboard',
 * });
 *
 * const handleSubmit = async (code: string) => {
 *   if (useBackupCode) {
 *     await verifyBackupCode(sessionId, code);
 *   } else {
 *     await verifyTOTP(sessionId, code);
 *   }
 * };
 * ```
 */
declare const useTwoFactor: (options?: UseTwoFactorOptions) => UseTwoFactorReturn;

interface TwoFactorSetupData {
    /** Device ID to use for confirmation */
    deviceId: string;
    /** Base32-encoded TOTP secret (for manual entry) */
    secret: string;
    /** otpauth:// URI for QR code generation */
    provisioningUri: string;
    /** Base64-encoded QR code image (data URI) */
    qrCodeBase64: string;
    /** Seconds until setup expires */
    expiresIn: number;
}
interface UseTwoFactorSetupOptions {
    /** Callback when setup is confirmed and backup codes are generated */
    onComplete?: (backupCodes: string[]) => void;
    /** Callback on error */
    onError?: (error: string) => void;
}
interface UseTwoFactorSetupReturn {
    /** Loading state */
    isLoading: boolean;
    /** Error message */
    error: string | null;
    /** Setup data (QR code, secret, etc.) */
    setupData: TwoFactorSetupData | null;
    /** Backup codes after confirmation */
    backupCodes: string[] | null;
    /** Warning message about backup codes */
    backupCodesWarning: string | null;
    /** Current setup step */
    setupStep: 'idle' | 'scanning' | 'confirming' | 'complete';
    /** Start 2FA setup - returns QR code data */
    startSetup: (deviceName?: string) => Promise<TwoFactorSetupData | null>;
    /** Confirm setup with TOTP code - returns backup codes */
    confirmSetup: (code: string) => Promise<string[] | null>;
    /** Reset setup state */
    resetSetup: () => void;
    /** Clear error */
    clearError: () => void;
}
/**
 * Hook for 2FA setup (enabling TOTP authentication).
 *
 * Flow:
 * 1. Call startSetup() to get QR code and provisioning URI
 * 2. User scans QR code with authenticator app
 * 3. Call confirmSetup(code) with the 6-digit code from app
 * 4. Show backup codes to user (they must save these!)
 *
 * @example
 * ```tsx
 * const {
 *   isLoading,
 *   error,
 *   setupData,
 *   backupCodes,
 *   setupStep,
 *   startSetup,
 *   confirmSetup,
 * } = useTwoFactorSetup({
 *   onComplete: (codes) => console.log('Backup codes:', codes),
 *   onError: (error) => console.error(error),
 * });
 *
 * // Start setup
 * const data = await startSetup('My iPhone');
 *
 * // Show QR code
 * <QRCodeSVG value={data.provisioningUri} />
 *
 * // Confirm with code from app
 * const codes = await confirmSetup('123456');
 * ```
 */
declare const useTwoFactorSetup: (options?: UseTwoFactorSetupOptions) => UseTwoFactorSetupReturn;

interface TwoFactorDevice {
    id: string;
    name: string;
    createdAt: string;
    lastUsedAt: string | null;
    isPrimary: boolean;
}
interface UseTwoFactorStatusReturn {
    /** Loading state */
    isLoading: boolean;
    /** Error message */
    error: string | null;
    /** Whether 2FA is enabled for user */
    has2FAEnabled: boolean | null;
    /** List of TOTP devices */
    devices: TwoFactorDevice[];
    /** Fetch 2FA status */
    fetchStatus: () => Promise<void>;
    /** Disable 2FA (requires TOTP code) */
    disable2FA: (code: string) => Promise<boolean>;
    /** Clear error */
    clearError: () => void;
}
/**
 * Hook for checking and managing 2FA status.
 *
 * @example
 * ```tsx
 * const { has2FAEnabled, devices, fetchStatus, disable2FA, isLoading } = useTwoFactorStatus();
 *
 * useEffect(() => {
 *   fetchStatus();
 * }, [fetchStatus]);
 *
 * if (has2FAEnabled) {
 *   // Show disable button
 * } else {
 *   // Show enable button
 * }
 * ```
 */
declare const useTwoFactorStatus: () => UseTwoFactorStatusReturn;

interface AuthRedirectOptions {
    fallbackUrl?: string;
    clearOnUse?: boolean;
}
declare const useAuthRedirectManager: (options?: AuthRedirectOptions) => {
    redirectUrl: string;
    setRedirect: (url: string) => void;
    getRedirect: () => string;
    clearRedirect: () => void;
    hasRedirect: () => boolean;
    getFinalRedirectUrl: () => string;
    useAndClearRedirect: () => string;
};

interface UseAuthGuardOptions {
    redirectTo?: string;
    requireAuth?: boolean;
    /** Whether to save current URL for redirect after auth (default: true) */
    saveRedirectUrl?: boolean;
}
declare const useAuthGuard: (options?: UseAuthGuardOptions) => {
    isAuthenticated: boolean;
    isLoading: boolean;
    isRedirecting: boolean;
};

/**
 * Simple sessionStorage hook with better error handling
 * @param key - Storage key
 * @param initialValue - Default value if key doesn't exist
 * @returns [value, setValue, removeValue] - Current value, setter function, and remove function
 */
declare function useSessionStorage<T>(key: string, initialValue: T): readonly [T, (value: T | ((val: T) => T)) => void, () => void];

/**
 * Simple localStorage hook with better error handling
 * @param key - Storage key
 * @param initialValue - Default value if key doesn't exist
 * @returns [value, setValue, removeValue] - Current value, setter function, and remove function
 */
declare function useLocalStorage<T>(key: string, initialValue: T): readonly [T, (value: T | ((val: T) => T)) => void, () => void];

/**
 * Encode string to base64
 * @param data - String data to encode
 * @returns Base64 encoded string (or original in dev mode)
 */
declare function encodeBase64(data: string): string;
/**
 * Decode base64 to string
 * @param encoded - Base64 encoded string
 * @returns Decoded string (or original in dev mode)
 */
declare function decodeBase64(encoded: string): string;
/**
 * Hook for base64 encoding/decoding
 * @returns Object with encode and decode functions
 */
declare function useBase64(): {
    encode: typeof encodeBase64;
    decode: typeof decodeBase64;
    isDev: boolean;
};

/**
 * Profile Cache Hook
 *
 * Provides localStorage-based caching for user profile with:
 * - TTL (Time To Live) - default 1 hour
 * - Version control for migrations
 * - Automatic invalidation on expiry
 */

interface ProfileCacheOptions {
    /** Time to live in milliseconds (default: 1 hour) */
    ttl?: number;
}
/**
 * Get cached profile from localStorage
 * @returns User profile if valid cache exists, null otherwise
 */
declare function getCachedProfile(): User | null;
/**
 * Save profile to localStorage cache
 * @param profile - User profile to cache
 * @param options - Cache options (TTL)
 */
declare function setCachedProfile(profile: User, options?: ProfileCacheOptions): void;
/**
 * Clear profile cache from localStorage
 */
declare function clearProfileCache(): void;
/**
 * Check if cached profile is valid (exists and not expired)
 */
declare function hasValidCache(): boolean;
/**
 * Get cache metadata (age, TTL, etc.)
 */
declare function getCacheMetadata(): {
    exists: boolean;
    age?: number;
    ttl?: number;
    expiresIn?: number;
} | null;

interface UseTokenRefreshOptions {
    /** Enable automatic token refresh (default: true) */
    enabled?: boolean;
    /** Callback when token is refreshed */
    onRefresh?: (newToken: string) => void;
    /** Callback when refresh fails */
    onRefreshError?: (error: Error) => void;
}
/**
 * Hook for automatic token refresh
 */
declare function useTokenRefresh(options?: UseTokenRefreshOptions): {
    refreshToken: () => Promise<boolean>;
    checkAndRefresh: () => Promise<void>;
};

interface DeleteAccountResult {
    success: boolean;
    message: string;
}
interface UseDeleteAccountReturn {
    /** Loading state */
    isLoading: boolean;
    /** Error message */
    error: string | null;
    /** Delete the account */
    deleteAccount: () => Promise<DeleteAccountResult>;
    /** Clear error */
    clearError: () => void;
}
/**
 * Hook for deleting user account.
 *
 * This performs a soft delete - deactivates the account and anonymizes personal data.
 * The account can be restored by an administrator if needed.
 *
 * @example
 * ```tsx
 * const { deleteAccount, isLoading, error } = useDeleteAccount();
 *
 * const handleDelete = async () => {
 *   const result = await deleteAccount();
 *   if (result.success) {
 *     // Account deleted, perform logout
 *     await logout();
 *   }
 * };
 * ```
 */
declare const useDeleteAccount: () => UseDeleteAccountReturn;

/**
 * Email validation utility
 */
declare const validateEmail: (email: string) => boolean;

/**
 * Format authentication error for display
 */
declare const formatAuthError: (error: any) => string;

declare const logger: consola.ConsolaInstance;
/**
 * Auth-specific logger
 */
declare const authLogger: consola.ConsolaInstance;

/**
 * Analytics stub for @djangocfg/api/auth
 * Provides minimal analytics interface without external dependencies
 *
 * If you need full analytics, install @djangocfg/layouts and use its Analytics module
 */
declare enum AnalyticsEvent {
    AUTH_OTP_REQUEST = "auth_otp_request",
    AUTH_LOGIN_SUCCESS = "auth_login_success",
    AUTH_OTP_VERIFY_FAIL = "auth_otp_verify_fail",
    AUTH_SESSION_EXPIRED = "auth_session_expired",
    AUTH_TOKEN_REFRESH = "auth_token_refresh",
    AUTH_TOKEN_REFRESH_FAIL = "auth_token_refresh_fail",
    AUTH_LOGOUT = "auth_logout",
    AUTH_OAUTH_START = "auth_oauth_start",
    AUTH_OAUTH_FAIL = "auth_oauth_fail"
}
declare enum AnalyticsCategory {
    AUTH = "auth"
}
type AnalyticsEventType = `${AnalyticsEvent}`;
type AnalyticsCategoryType = `${AnalyticsCategory}`;
interface AnalyticsEventParams {
    category?: AnalyticsCategoryType;
    label?: string;
    value?: number;
    [key: string]: any;
}
/**
 * Minimal analytics implementation
 * Logs to console in development, silent in production
 */
declare const Analytics: {
    /**
     * Track an analytics event
     */
    event(eventName: AnalyticsEventType, params?: AnalyticsEventParams): void;
    /**
     * Set user ID for tracking
     */
    setUser(userId: string): void;
};

export { type AccountsContextValue, AccountsProvider, Analytics, AnalyticsCategory, type AnalyticsCategoryType, AnalyticsEvent, type AnalyticsEventType, type AuthChannel, type AuthConfig, type AuthContextType, type AuthFormAutoSubmit, type AuthFormContextType, type AuthFormReturn, type AuthFormState, type AuthFormStateHandlers, type AuthFormSubmitHandlers, type AuthFormValidation, type AuthHelpProps, type AuthLayoutConfig, type AuthLayoutProps, AuthProvider, type AuthProviderProps, type AuthStep, type DeleteAccountResult, type PatchedUserProfileUpdateRequest, PatchedUserProfileUpdateRequestSchema, type ProfileCacheOptions, type TwoFactorDevice, type TwoFactorSetupData, type UseAuthFormOptions, type UseAuthFormStateReturn, type UseAutoAuthOptions, type UseDeleteAccountReturn, type UseGithubAuthOptions, type UseGithubAuthReturn, type UseTwoFactorOptions, type UseTwoFactorReturn, type UseTwoFactorSetupOptions, type UseTwoFactorSetupReturn, type UseTwoFactorStatusReturn, type UserProfile, authLogger, clearProfileCache, decodeBase64, detectChannelFromIdentifier, encodeBase64, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, logger, setCachedProfile, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthGuard, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useQueryParams, useSessionStorage, useTokenRefresh, useTwoFactor, useTwoFactorSetup, useTwoFactorStatus, validateEmail, validateIdentifier };
