import path from 'node:path';
import type { StxOptions } from './types';
/**
 * Render a STX template with server-side data
 *
 * @param template - Template path relative to viewsDir, or inline template string
 * @param data - Data to pass to the template
 * @param options - Render options
 */
export declare function render(template: string, data?: Record<string, unknown>, options?: {
    viewsDir?: string
    layoutsDir?: string
    stxOptions?: StxOptions
    ctx?: RequestContext
  }): Promise<Response>;
/**
 * Create a STX server application
 */
export declare function createApp(config?: AppConfig): void;
/** Session data store */
export declare interface SessionData {
  [key: string]: unknown
}
/** Session interface */
export declare interface Session {
  id: string
  data: SessionData
  get<T = unknown>(key: string): T | undefined
  set(key: string, value: unknown): void
  delete(key: string): void
  clear(): void
  has(key: string): boolean
  flash(key: string, value?: unknown): unknown | undefined
  regenerate(): void
  destroy(): void
}
/** Pluggable session store interface for production-ready backends (Redis, DB, etc.) */
export declare interface SessionStore {
  get(sessionId: string): Promise<SessionData | null>
  set(sessionId: string, data: SessionData, ttlSeconds: number): Promise<void>
  delete(sessionId: string): Promise<void>
}
/** Request context passed to route handlers */
export declare interface RequestContext {
  request: Request
  url: URL
  params: Record<string, string>
  query: Record<string, string>
  session: Session
  csrfToken: string
  formData: () => Promise<Record<string, string | File>>
  json: <T = unknown>() => Promise<T>
  cookies: Record<string, string>
  setCookie: (name: string, value: string, options?: CookieOptions) => void
  responseHeaders: Headers
  flash: (key: string, value: unknown) => void
  getFlash: (key: string) => unknown
  errors: ValidationErrors
  old: (key: string) => string
  isAuthenticated: () => boolean
  user: () => unknown
}
/** Cookie options */
export declare interface CookieOptions {
  maxAge?: number
  expires?: Date
  path?: string
  domain?: string
  secure?: boolean
  httpOnly?: boolean
  sameSite?: 'Strict' | 'Lax' | 'None'
}
/** Validation errors */
export declare interface ValidationErrors {
  [field: string]: string[]
}
/** App configuration */
export declare interface AppConfig {
  viewsDir?: string
  layoutsDir?: string
  defaultLayout?: string
  sessionSecret?: string
  sessionCookieName?: string
  sessionTtl?: number
  stxOptions?: StxOptions
  csrfCookieName?: string
  csrfEnabled?: boolean
  sessionStore?: SessionStore
}
/** Route handler */
// eslint-disable-next-line pickier/no-unused-vars
export type RouteHandler = (ctx: RequestContext) => Response | Promise<Response>;
/** Middleware function */
export type Middleware = (ctx: RequestContext, next: () => Promise<Response>) => Response | Promise<Response>;
/** Default in-memory session store. Use a custom SessionStore (Redis, DB) for production. */
export declare class MemorySessionStore implements SessionStore {
  get(sessionId: string): Promise<SessionData | null>;
  set(sessionId: string, data: SessionData, ttlSeconds: number): Promise<void>;
  delete(sessionId: string): Promise<void>;
}
