interface Ssr {
    id?: string
    path: string
    content: string
    // validUntil: any // go Time
}

declare module "*.css"

/** MongoDB-style filter, e.g. { _id: "abc" } or { $or: [...] } */
type MongoFilter = Record<string, unknown>

interface ApiOptions {
    method?: "GET" | "POST" | "PUT" | "DELETE"
    filter?: MongoFilter
    sort?: string
    lookup?: string
    aggregate?: string | Record<string, any>
    limit?: number
    offset?: number
    projection?: string
    headers?: {
        [key: string]: string
    }
    params?: {
        [key: string]: string
    }
    signal?: AbortSignal
}

interface LocationStore {
    path: string
    search: string
    hash: string
    push: boolean
    pop: boolean
    previousLocation?: LocationStore
}

interface ApiResult<T> {
    data: T
    count: number
    /** Build timestamp from server (X-Build-Time header), only present on client requests */
    buildTime?: string | null
}

interface FileField {
    path: string
    src: string
    type: string
    size: number
}

type LocalizedText = {
    [lang: string]: string | undefined
}

interface MedialibEntry {
    id?: string
    file?: {
        src?: string
        type?: string
    }
    title?: string
    alt?: string | LocalizedText
    description?: string
    [key: string]: unknown
}

interface LookupContainer<T> {
    _lookup?: Record<string, T | null>
}

interface ContentHeroImage extends LookupContainer<MedialibEntry> {
    image?: string
}

interface ContentFeatureBoxEntry {
    icon?: "lightning" | "palette" | "database" | "globe" | "monitor" | "flask"
    title?: string
    text?: string
}

/** Pagebuilder: Content Block Entry */
interface ContentBlockEntry extends LookupContainer<MedialibEntry> {
    hide?: boolean
    headline?: string
    headlineH1?: boolean
    subline?: string
    tagline?: string
    anchorId?: string
    containerWidth?: "" | "wide" | "full"
    padding?: {
        top?: string
        bottom?: string
    }
    type?: string
    callToAction?: {
        buttonText?: string
        buttonLink?: string
        buttonTarget?: string
    }
    heroImage?: ContentHeroImage
    featureBoxes?: ContentFeatureBoxEntry[]
    // richtext fields
    text?: string
    imagePosition?: "none" | "left" | "right"
    image?: string
    // accordion fields
    accordionItems?: {
        question?: string
        answer?: string
        open?: boolean
    }[]
}

/** Content Entry from the CMS */
interface ContentEntry {
    id?: string
    _lookup?: Record<string, MedialibEntry | MedialibEntry[] | null>
    active?: boolean
    publication?: {
        from?: string | Date
        to?: string | Date
    }
    lang?: string
    translationKey?: string
    name?: string
    path?: string
    alternativePaths?: { path?: string }[]
    blocks?: ContentBlockEntry[]
    meta?: {
        title?: string
        description?: string
        keywords?: string[]
    }
}

/** Navigation element */
interface NavigationElement {
    name: string
    external?: boolean
    page?: string
    hash?: string
    externalUrl?: string
    _lookup?: {
        page?: ContentEntry | null
    }
}

/** Navigation entry from the CMS */
interface NavigationEntry {
    id?: string
    language?: string
    type?: "header" | "footer"
    elements?: NavigationElement[]
}

interface ProductEntry {
    id: string
    // ...
}

/** Build-time flag: `true` when built with `MOCK=1`, enables API mock interceptor */
declare const __MOCK__: boolean
