import { D as DrizzleAuthService } from '../../drizzle-auth-service-Bxlovhv8.js';
import '../../enums-Dume-V5Y.js';
import 'drizzle-orm/pg-core';

/**
 * Auth Routes - Types
 * 路由处理器类型定义
 */

/**
 * 基础路由配置
 */
interface BaseRouteConfig {
    /**
     * 认证服务实例
     */
    authService: DrizzleAuthService;
    /**
     * 可选的 Analytics 服务
     */
    analytics?: {
        track: (eventName: string, properties: any) => Promise<void>;
    };
    /**
     * CORS 配置
     */
    cors?: {
        enabled?: boolean;
        origin?: string | string[];
        methods?: string[];
        allowedHeaders?: string[];
        credentials?: boolean;
    };
}
/**
 * 登录路由配置
 */
interface LoginRouteConfig extends BaseRouteConfig {
    /**
     * Cookie 配置
     */
    cookieOptions?: {
        name?: string;
        httpOnly?: boolean;
        secure?: boolean;
        sameSite?: 'strict' | 'lax' | 'none';
        maxAge?: number;
        path?: string;
    };
}
/**
 * 注册路由配置
 */
interface RegisterRouteConfig extends BaseRouteConfig {
    /**
     * 默认角色
     */
    defaultRole?: 'USER' | 'ADMIN' | 'SUPER_ADMIN';
    /**
     * 是否需要邮箱验证
     */
    emailVerificationRequired?: boolean;
    /**
     * Cookie 配置
     */
    cookieOptions?: {
        name?: string;
        httpOnly?: boolean;
        secure?: boolean;
        sameSite?: 'strict' | 'lax' | 'none';
        maxAge?: number;
        path?: string;
    };
}
/**
 * 标准 API 响应
 */
interface ApiResponse<T = any> {
    success: boolean;
    data?: T;
    error?: string;
    message?: string;
}

/**
 * Auth Routes - Login
 * 登录路由处理器
 */

/**
 * 创建登录路由处理器
 *
 * @example
 * ```typescript
 * import { createLoginHandler } from 'sa2kit/auth/routes';
 *
 * export const POST = createLoginHandler({
 *   authService: myAuthService,
 *   analytics: myAnalytics,
 *   cors: { enabled: true },
 * });
 * ```
 */
declare function createLoginHandler(config: LoginRouteConfig): (request: Request) => Promise<Response>;
/**
 * 创建 CORS 预检请求处理器
 */
declare function createLoginOptionsHandler(config: LoginRouteConfig): (request: Request) => Promise<Response>;

/**
 * Auth Routes - Register
 * 注册路由处理器
 */

/**
 * 创建注册路由处理器
 *
 * @example
 * ```typescript
 * import { createRegisterHandler } from 'sa2kit/auth/routes';
 *
 * export const POST = createRegisterHandler({
 *   authService: myAuthService,
 *   defaultRole: 'USER',
 *   cors: { enabled: true },
 * });
 * ```
 */
declare function createRegisterHandler(config: RegisterRouteConfig): (request: Request) => Promise<Response>;
/**
 * 创建 CORS 预检请求处理器
 */
declare function createRegisterOptionsHandler(config: RegisterRouteConfig): (request: Request) => Promise<Response>;

/**
 * Auth Routes - Me
 * 获取当前用户信息路由处理器
 */

/**
 * 创建获取当前用户信息路由处理器
 *
 * @example
 * ```typescript
 * import { createMeHandler } from 'sa2kit/auth/routes';
 *
 * export const GET = createMeHandler({
 *   authService: myAuthService,
 *   cors: { enabled: true },
 * });
 * ```
 */
declare function createMeHandler(config: BaseRouteConfig): (request: Request) => Promise<Response>;
/**
 * 创建 CORS 预检请求处理器
 */
declare function createMeOptionsHandler(config: BaseRouteConfig): (request: Request) => Promise<Response>;

/**
 * Auth Routes - Logout
 * 登出路由处理器
 */

/**
 * 创建登出路由处理器
 *
 * @example
 * ```typescript
 * import { createLogoutHandler } from 'sa2kit/auth/routes';
 *
 * export const POST = createLogoutHandler({
 *   authService: myAuthService,
 *   cors: { enabled: true },
 * });
 * ```
 */
declare function createLogoutHandler(config: BaseRouteConfig): (request: Request) => Promise<Response>;
/**
 * 创建 CORS 预检请求处理器
 */
declare function createLogoutOptionsHandler(config: BaseRouteConfig): (request: Request) => Promise<Response>;

/**
 * Auth Routes - Default Configurations
 * 默认路由配置
 */

/**
 * 创建默认的基础路由配置
 */
declare function createDefaultBaseConfig(authService: DrizzleAuthService, overrides?: Partial<BaseRouteConfig>): BaseRouteConfig;
/**
 * 创建默认的登录路由配置
 */
declare function createDefaultLoginConfig(authService: DrizzleAuthService, overrides?: Partial<LoginRouteConfig>): LoginRouteConfig;
/**
 * 创建默认的注册路由配置
 */
declare function createDefaultRegisterConfig(authService: DrizzleAuthService, overrides?: Partial<RegisterRouteConfig>): RegisterRouteConfig;

/**
 * Auth Routes - Analytics Adapter
 * 埋点适配器，用于适配不同的埋点服务
 */
/**
 * 埋点事件接口
 */
interface AnalyticsEvent {
    id: string;
    eventType: string;
    eventName: string;
    timestamp: string;
    priority: number;
    userId: string;
    sessionId: string;
    deviceId: string;
    platform: string;
    appVersion: string;
    sdkVersion: string;
    properties: Record<string, any>;
}
/**
 * 埋点服务接口
 */
interface AnalyticsService {
    insertAnalyticsEvents(events: AnalyticsEvent[]): Promise<void>;
}
/**
 * 创建埋点适配器
 *
 * @param analyticsService 埋点服务实例
 * @param options 可选配置
 * @returns 符合 sa2kit 格式的埋点函数
 *
 * @example
 * ```typescript
 * import { createAnalyticsAdapter } from 'sa2kit/auth/routes';
 * import { analyticsService } from '@/lib/analytics';
 *
 * const analytics = createAnalyticsAdapter(analyticsService, {
 *   platform: 'backend',
 *   appVersion: '1.0.0',
 * });
 *
 * // 在路由配置中使用
 * const config = createDefaultLoginConfig(authService, {
 *   analytics,
 * });
 * ```
 */
declare function createAnalyticsAdapter(analyticsService: AnalyticsService, options?: {
    platform?: string;
    appVersion?: string;
    sdkVersion?: string;
    deviceId?: string;
    generateId?: () => string;
}): {
    track: (eventName: string, properties: any) => Promise<void>;
};

export { type AnalyticsEvent, type AnalyticsService, type ApiResponse, type BaseRouteConfig, type LoginRouteConfig, type RegisterRouteConfig, createAnalyticsAdapter, createDefaultBaseConfig, createDefaultLoginConfig, createDefaultRegisterConfig, createLoginHandler, createLoginOptionsHandler, createLogoutHandler, createLogoutOptionsHandler, createMeHandler, createMeOptionsHandler, createRegisterHandler, createRegisterOptionsHandler };
