import { CloudFrontRequest, CloudFrontRequestEvent } from 'aws-lambda';

/**
 * @see sites/www-docs/content/packages/@openhi/constructs/components/static-hosting/static-hosting.viewer-request-handler.md
 */
/**
 * Hosting mode controls how path-like URIs get a default document.
 *
 * - `spa`: path-like URIs (e.g. `/dashboard`, `/patients/123`) rewrite to
 *   `/index.html` so the single-page app's root index is served and the
 *   client-side router handles the path.
 * - `static`: path-like URIs append `/index.html` (e.g. `/docs` becomes
 *   `/docs/index.html`) so multi-page static sites can serve distinct
 *   HTML per path.
 */
type HostingMode = "spa" | "static";
/**
 * Viewer Request Handler for SPA mode.
 *
 * - Logs the request
 * - Rewrites path-like URIs to `/index.html`
 * - Prepends the Host header as a folder for multi-tenant routing
 */
declare const spaHandler: (event: CloudFrontRequestEvent) => Promise<CloudFrontRequest>;
/**
 * Viewer Request Handler for static (non-SPA) mode.
 *
 * - Logs the request
 * - Rewrites path-like URIs to `<path>/index.html`
 * - Prepends the Host header as a folder for multi-tenant routing
 */
declare const staticHandler: (event: CloudFrontRequestEvent) => Promise<CloudFrontRequest>;
/**
 * Adds a default document to the request URI based on the hosting mode.
 *
 * In both modes:
 * - `/` and `/index.html` become `/index.html`
 * - URIs whose last segment contains a dot are treated as static files and
 *   left unchanged.
 *
 * In `spa` mode, all other path-like URIs rewrite to `/index.html`.
 * In `static` mode, path-like URIs append `/index.html` (trailing slash
 * preserved as a single slash): `/docs` and `/docs/` both become
 * `/docs/index.html`.
 */
declare const addDefaultDocument: (request: CloudFrontRequest, mode: HostingMode) => CloudFrontRequest;
/**
 * Prepends the Host header as a folder to the request URI. Used for
 * multi-tenant routing where each domain maps to a folder in the S3
 * bucket (e.g. `example.com/foo` -\> `/example.com/foo`).
 */
declare const addDomainFolder: (request: CloudFrontRequest) => CloudFrontRequest;

export { type HostingMode, addDefaultDocument, addDomainFolder, spaHandler, staticHandler };
