/**
 * Server-side helper to fetch content (page or entry) by path.
 *
 * Use this for dynamic routing where a path could resolve to either
 * a page or a content entry.
 */
import type { MediaAssetIndexItem, RouteMap, Theme } from '../../contracts';
import type { RiverbankClient, SiteResponse } from '../../client/types';
import type { PageProps } from '../components/Page';
import type { ResolvedBlockData } from '../../data/prefetchBlockData';
import type { RuntimeSdkConfig } from './loadPage';
import type { SdkCustomBlock } from '../../config/types';
/**
 * Site data included in content results for metadata generation.
 */
export type SiteData = SiteResponse['site'];
export type LoadContentParams = {
    client: RiverbankClient;
    siteId: string;
    path: string;
    /**
     * When true, forces a fresh site config fetch (bypasses caches).
     * Useful right after `riverbankcms push-config` in development.
     */
    forceSite?: boolean;
    /**
     * If true, fetches draft/unpublished content instead of published content.
     * This affects both pages and entries.
     * Requires API key with site access.
     *
     * @default false
     */
    preview?: boolean;
};
/**
 * Content entry data returned when a path resolves to an entry
 */
export type ContentEntryData = {
    id: string;
    /** Content type key (e.g., 'blog-post', 'product') */
    type: string | null;
    title: string;
    slug: string | null;
    path: string | null;
    status: string;
    publishAt: string | null;
    /** The raw content fields - use these to render your own UI */
    content: Record<string, unknown>;
    metaTitle: string | null;
    metaDescription: string | null;
    createdAt: string;
    updatedAt: string;
};
/**
 * Page metadata shape compatible with the preview editor shell.
 *
 * SDK sites can use this to seed the preview editing session without needing
 * an additional API call.
 */
export type PagePreviewMetadata = {
    draftTitle: string;
    draftPath: string;
    draftStatus: string;
    title: string;
    path: string;
    status: string;
    publishedAt: string | null;
    draftMetaTitle: string | null;
    draftMetaDescription: string | null;
    publishedMetaTitle: string | null;
    publishedMetaDescription: string | null;
    ogImageId: string | null;
};
/**
 * Result when path resolves to a page
 */
export type PageContentResult = {
    type: 'page';
    /** Page UUID (required for preview editing / block mutations) */
    pageId: string;
    /** Route UUID for this page (used by preview mode metadata editing) */
    routeId: string | null;
    /** Draft/published metadata record (used to seed the preview editor) */
    pageMetadata: PagePreviewMetadata;
    /** Page outline ready for rendering with <Page> component */
    page: PageProps['page'];
    /** Site theme for styling */
    theme: Theme;
    /** Site ID */
    siteId: string;
    /** Declarative custom blocks stored in DB (if any) */
    customBlocks?: SdkCustomBlock[];
    /** Pre-fetched block data for data loaders */
    resolvedData: ResolvedBlockData;
    /** Site data for metadata generation */
    site: SiteData;
    /**
     * SDK site configuration containing theme palette overrides.
     * When provided, the SDK palette tokens are merged into the theme tokens,
     * allowing blocks to use SDK-defined color tokens for section backgrounds.
     */
    sdkConfig: RuntimeSdkConfig | null;
    /**
     * Supabase storage URL for direct image access.
     * SDK sites receive this from the API instead of requiring NEXT_PUBLIC_SUPABASE_URL env var.
     */
    supabaseUrl?: string;
    /** Route map for CTA link resolution (routeId → path) */
    routeMap?: RouteMap;
    /** Page identifier to routeId lookup for { kind: 'page' } CTA links */
    pagesByIdentifier?: Record<string, string>;
    /** ContentType -> identifier -> routeId lookup for { kind: 'entry' } CTA links */
    entriesByIdentifier?: Record<string, Record<string, string>>;
    /** Canonical media assets for resolving identifier-only media values in preview/edit UIs. */
    mediaAssets?: MediaAssetIndexItem[];
};
/**
 * Result when path resolves to a content entry
 */
export type EntryContentResult = {
    type: 'entry';
    /** Raw entry data - render this however you want */
    entry: ContentEntryData;
    /** Template page for rendering the entry (if available) */
    templatePage: PageProps['page'] | null;
    /** Pre-fetched block data for template page data loaders */
    resolvedData: ResolvedBlockData;
    /** Data context for template blocks (includes entry content for bindings) */
    dataContext: {
        contentEntry: Record<string, unknown>;
    };
    /** Site theme for styling (useful if rendering with SDK components) */
    theme: Theme;
    /** Site ID */
    siteId: string;
    /** Declarative custom blocks stored in DB (if any) */
    customBlocks?: SdkCustomBlock[];
    /** Site data for metadata generation */
    site: SiteData;
    /**
     * SDK site configuration containing theme palette overrides.
     * When provided, the SDK palette tokens are merged into the theme tokens,
     * allowing blocks to use SDK-defined color tokens for section backgrounds.
     */
    sdkConfig: RuntimeSdkConfig | null;
    /**
     * Supabase storage URL for direct image access.
     * SDK sites receive this from the API instead of requiring NEXT_PUBLIC_SUPABASE_URL env var.
     */
    supabaseUrl?: string;
    /** Route map for CTA link resolution (routeId → path) */
    routeMap?: RouteMap;
    /** Page identifier to routeId lookup for { kind: 'page' } CTA links */
    pagesByIdentifier?: Record<string, string>;
    /** ContentType -> identifier -> routeId lookup for { kind: 'entry' } CTA links */
    entriesByIdentifier?: Record<string, Record<string, string>>;
    /** Canonical media assets for resolving identifier-only media values in preview/edit UIs. */
    mediaAssets?: MediaAssetIndexItem[];
};
/**
 * Discriminated union result from loadContent
 */
export type LoadContentResult = PageContentResult | EntryContentResult;
/**
 * Type guard to check if result is a page
 */
export declare function isPageContent(result: LoadContentResult): result is PageContentResult;
/**
 * Type guard to check if result is an entry
 */
export declare function isEntryContent(result: LoadContentResult): result is EntryContentResult;
/**
 * Server-side helper to fetch content by path.
 *
 * Returns a discriminated union - either page data (ready for `<Page>` component)
 * or raw entry data (for custom rendering).
 *
 * @example Dynamic routing with both pages and entries
 * ```tsx
 * import { loadContent, Page, isPageContent } from '@riverbankcms/sdk';
 *
 * export default async function DynamicRoute({ params }) {
 *   const content = await loadContent({
 *     client,
 *     siteId: 'site-123',
 *     path: `/${params.slug?.join('/') || ''}`,
 *   });
 *
 *   if (isPageContent(content)) {
 *     return <Page {...content} />;
 *   }
 *
 *   // Render entry with custom UI
 *   return (
 *     <article>
 *       <h1>{content.entry.title}</h1>
 *       <div>{content.entry.content.body}</div>
 *     </article>
 *   );
 * }
 * ```
 *
 * @example Entry-specific rendering based on content type
 * ```tsx
 * const content = await loadContent({ client, siteId, path });
 *
 * if (content.type === 'entry') {
 *   switch (content.entry.type) {
 *     case 'blog-post':
 *       return <BlogPost entry={content.entry} theme={content.theme} />;
 *     case 'product':
 *       return <ProductPage entry={content.entry} theme={content.theme} />;
 *     default:
 *       return <GenericEntry entry={content.entry} />;
 *   }
 * }
 *
 * return <Page {...content} />;
 * ```
 *
 * @example Preview mode for draft content
 * ```tsx
 * const content = await loadContent({
 *   client,
 *   siteId,
 *   path,
 *   preview: true, // Fetches draft content for both pages and entries
 * });
 * ```
 */
export declare function loadContent(params: LoadContentParams): Promise<LoadContentResult>;
