/**
 * @wrnexus/core — shared types and primitives used by every other package.
 */
export type {
  Context,
  Next,
  Middleware,
  PageMeta,
  PageComponent,
  SeoConfig,
  TFunction,
} from "./context.ts";
export { createContext, withContextHeaders } from "./context.ts";
export { createExecutionContext, executionContextFromHttp } from "./execution-context.ts";
export type {
  ExecutionContext,
  ExecutionContextInput,
  ExecutionKind,
  ResponseContext,
} from "./execution-context.ts";

export { escapeHtml, isSafeIslandName, isSafeRequestPath } from "./security.ts";
export { csrfToken, verifyCsrf, csrfProtection, CSRF_COOKIE, CSRF_HEADER } from "./csrf.ts";
export type { CsrfProtectionOptions } from "./csrf.ts";

export {
  hashPassword,
  verifyPassword,
  logIn,
  logOut,
  getUser,
  sessionAuth,
  requireAuth,
  SESSION_USER_KEY,
} from "./auth.ts";
export type { RequireAuthOptions } from "./auth.ts";

export { rateLimit, peerKey, proxyKey, defaultKey } from "./ratelimit.ts";
export type { RateLimitOptions, RateLimitStore, Bucket } from "./ratelimit.ts";

export { requestLogger } from "./logging.ts";
export type { RequestLoggerOptions, RequestRecord } from "./logging.ts";

export { TTLCache, cacheControl, withCacheControl, etag, notModified } from "./cache.ts";
export type { CacheControlOptions } from "./cache.ts";

export {
  saveUpload,
  saveUploadSecure,
  collectUploads,
  sanitizeFilename,
  randomUploadFilename,
  secureDownloadHeaders,
  UploadError,
} from "./uploads.ts";
export type {
  SaveUploadOptions,
  SecureUploadOptions,
  SavedUpload,
  UploadInspectionResult,
  UploadInspector,
  UploadScanner,
} from "./uploads.ts";

export { streamResponse, sse } from "./stream.ts";
export type { StreamResponseInit, ServerSentEvent } from "./stream.ts";

export {
  defineRoom,
  isRoomDefinition,
  createRealtimeRegistry,
  bridgeRealtime,
} from "./realtime.ts";
export type {
  RealtimeBus,
  RealtimeSocket,
  RealtimeHandler,
  RawSocket,
  Room,
  RoomClient,
  RoomHandlers,
  RoomAuthInfo,
  RoomDefinition,
  Target,
  RealtimeRegistry,
  RealtimeConnectMeta,
  RealtimeBridge,
  RealtimeEnvelope,
  RealtimeSecurityOptions,
  RealtimeRegistryOptions,
} from "./realtime.ts";

export type { Mode } from "./errors.ts";
export {
  renderDevError,
  renderProdError,
  renderError,
  renderNotFound,
  renderStatusPage,
} from "./errors.ts";

export type {
  ContentSecurityPolicyConfig,
  CorsConfig,
  CorsOrigin,
  CspDirectiveValue,
  HstsConfig,
  PermissionsPolicyConfig,
  RequestLimitsConfig,
  SecurityConfig,
  TrustedTypesConfig,
} from "./headers.ts";
export {
  createCorsPreflightResponse,
  withSecurityHeaders,
  isWebSocketOriginAllowed,
  resolveRequestUrl,
} from "./headers.ts";

export type {
  CookieOptions,
  CookieStore,
  LocalStorageSnapshot,
  SessionStore,
  SessionBackend,
  SessionEntry,
  AsyncSessionBackend,
  SessionPolicy,
} from "./storage.ts";
export { setSessionBackend, setSessionPolicy, loadSession } from "./storage.ts";

export { Fragment, Html, jsx, jsxs, mustache } from "./jsx-runtime.ts";
export type { Component as JSXComponent, Props as JSXProps, Renderable } from "./jsx-runtime.ts";

export { defineEndpoint, createRpcClient, EndpointError } from "./endpoint.ts";
export type {
  DefinedEndpoint,
  EndpointDefinition,
  EndpointErrorBody,
  RpcClientOptions,
  SchemaLike,
  OutputSchemaLike,
  InferEndpointSchema,
} from "./endpoint.ts";

export { defineAction, defineLoader, dedupe } from "./data.ts";
export type {
  ActionDefinition,
  CachePolicy,
  DefinedAction,
  DefinedLoader,
  LoaderDefinition,
} from "./data.ts";

export {
  assertTenantAccess,
  composeTenantResolvers,
  createTenantDirectory,
  createPersistentTenantDirectory,
  memoryTenantDirectoryStore,
  postgresTenantDirectoryStore,
  migrateTenants,
  POSTGRES_TENANT_DIRECTORY_SCHEMA,
  requireTenant,
  tenantFromDomain,
  tenantFromHeader,
  tenantFromPath,
  tenantFromSession,
  tenantFromSubdomain,
  tenantKey,
  tenantMiddleware,
  tenantScope,
} from "./tenant.ts";
export type {
  Tenant,
  TenantAuditEvent,
  TenantMembership,
  TenantQuota,
  TenantDirectoryStore,
  TenantSqlClient,
  TenantMiddlewareOptions,
  TenantResolver,
  TenantResource,
} from "./tenant.ts";

export { createTracer, tracingMiddleware, withSpan } from "./observability.ts";
export type { Span, SpanRecord, Tracer } from "./observability.ts";

export { defineFeatureFlags } from "./features.ts";
export type { FeatureFlags, FeatureRule, FeatureValue } from "./features.ts";

export { checkPerformanceBudgets, recommendedWebBudgets } from "./performance.ts";
export type { BudgetViolation, PerformanceBudgets, PerformanceMeasurement } from "./performance.ts";
export {
  Bulkhead,
  CircuitBreaker,
  ResilienceError,
  durationMs,
  resilientCall,
} from "./resilience.ts";
export type {
  BackoffStrategy,
  BulkheadOptions,
  CircuitBreakerOptions,
  CircuitBreakerSnapshot,
  Duration,
  ResilientCallOptions,
} from "./resilience.ts";
export {
  problem,
  serviceToken,
  ServiceContainer,
  ApplicationLifecycle,
  HealthRegistry,
  requestId,
  memoryIdempotencyStore,
  withIdempotency,
} from "./platform.ts";
export type {
  ProblemDetails,
  ProblemDetailsInput,
  ServiceToken,
  LifecyclePhase,
  LifecycleHandler,
  HealthCheck,
  HealthCheckResult,
  IdempotencyRecord,
  IdempotencyStore,
} from "./platform.ts";
