import { z } from 'zod';
import type { SdkCustomBlock } from '@riverbankcms/blocks';
import type { CustomCssAtRuleInput, CustomCssRuleInput } from '@riverbankcms/theme-core';
import type { JsonValue } from './shared-contracts';
/** Request body for previewing schedule changes */
export type SchedulePreviewRequest = {
    /** New recurrence rule (null for single event) */
    recurrenceRule?: string | null;
    /** Default start time in HH:MM format */
    defaultStartTime: string;
    /** Duration in minutes */
    durationMinutes: number;
    /** Optional generation horizon in months for unbounded recurrence rules */
    generationWindowMonths?: number;
    /** ISO date string for first occurrence */
    startDate?: string;
};
/** Information about an occurrence affected by schedule change */
export type AffectedOccurrence = {
    id: string;
    startsAt: string;
    timeZone: string;
    registrationCount: number;
};
/** Information about a modified occurrence (has overrides or non-scheduled status) */
export type ModifiedOccurrence = {
    id: string;
    startsAt: string;
    timeZone: string;
    hasOverrides: boolean;
    status: string;
};
/** Response from schedule preview endpoint */
export type SchedulePreviewResponse = {
    /** IANA timezone used to render previewDates */
    timeZone: string;
    /** Summary of future occurrence changes */
    futureOccurrences: {
        /** Number that will be deleted (no registrations) */
        toDelete: number;
        /** Number that will be cancelled (has registrations) */
        toCancel: number;
        /** Number of new occurrences that will be created */
        toCreate: number;
    };
    /** Registrations that will be affected */
    affectedRegistrations: {
        /** Total count of registrations on affected occurrences */
        count: number;
        /** Details of each affected occurrence */
        occurrences: AffectedOccurrence[];
    };
    /** Occurrences with customizations that will be lost */
    modifiedOccurrences: {
        /** Count of modified occurrences */
        count: number;
        /** Details of each modified occurrence */
        occurrences: ModifiedOccurrence[];
    };
    /** Preview of first N dates from new schedule */
    previewDates: string[];
};
/** Result summary included in UpdateEventSeriesRequest response when regenerateSchedule is true */
export type RegenerationSummary = {
    deleted: number;
    cancelled: number;
    created: number;
};
export type AiPlaygroundApplyRequest = {
    pageId: string;
    patches: Array<{
        blockId?: string;
        ops: Array<Record<string, unknown>>;
    }>;
};
export type AiPlaygroundApplyResponse = {
    ok: boolean;
    applied: number;
    failed: number;
    errors: string[];
};
export type DebugArtifact = {
    filename: string;
    content: string;
    type: "text" | "json";
};
export type DebugArtifacts = {
    files: DebugArtifact[];
};
export type PageBlock = {
    kind: string;
    orderIndex: number;
    purpose: "header" | "content" | "footer";
    content: Record<string, unknown>;
};
export type PageConverterOutput = {
    page: {
        name: string;
        path: string;
        blocks: PageBlock[];
    };
    customBlocks?: Array<SdkCustomBlock & {
        customCssRules?: CustomCssRuleInput[];
        customCssAtRules?: CustomCssAtRuleInput[];
    }>;
    entries?: Array<{
        identifier: string;
        contentType: string;
        title: string;
        data: Record<string, unknown>;
        status?: "draft" | "published";
    }>;
    contentTypes?: Array<{
        key: string;
        name: string;
        description?: string;
        fields: Array<{
            id: string;
            type: string;
            label: string;
            required?: boolean;
            description?: string;
        }>;
        isRouted: boolean;
    }>;
};
export type PageConversionSuccess = {
    success: true;
    output: PageConverterOutput;
    sectionCount: number;
    builtinBlockCount: number;
    customBlockCount: number;
};
export type PageConversionAttempt = {
    attempt: number;
    pass: string;
    errors: string[];
};
export type PageConversionFailure = {
    success: false;
    error: string;
    attempts: PageConversionAttempt[];
};
export type PageConversionResult = PageConversionSuccess | PageConversionFailure;
export type PageConvertResponse = {
    result: PageConversionResult;
    debug: DebugArtifacts;
};
export type PageConvertJobStatus = "queued" | "running" | "succeeded" | "failed" | "canceled";
export type PageConvertJob = {
    id: string;
    siteId: string;
    requestedBy: string | null;
    sourceKind: "html" | "tsx";
    sourceLength: number;
    pageName: string | null;
    pagePath: string | null;
    status: PageConvertJobStatus;
    stage: string | null;
    lastMessage: string | null;
    attemptCount: number;
    heartbeatAt: string | null;
    result: PageConversionResult | null;
    debug: DebugArtifacts | null;
    error: string | null;
    createdAt: string;
    updatedAt: string;
    startedAt: string | null;
    completedAt: string | null;
};
export type PageConvertJobEventType = "status" | "progress" | "stage" | "error";
export type PageConvertJobEvent = {
    id: number;
    jobId: string;
    type: PageConvertJobEventType;
    message: string;
    detail?: unknown;
    createdAt: string;
};
export type PageConvertJobsCreateRequest = {
    source: string;
    sourceKind?: "html" | "tsx";
    pageName?: string;
    pagePath?: string;
};
export type PageConvertJobsCreateResponse = {
    job: PageConvertJob;
};
export type PageConvertJobsListResponse = {
    jobs: PageConvertJob[];
};
export type PageConvertJobGetResponse = {
    job: PageConvertJob;
};
export type PageConvertJobRunResponse = {
    ok: true;
    job: PageConvertJob;
    alreadyRunning: false;
} | {
    ok: true;
    job: PageConvertJob;
    alreadyRunning: true;
} | {
    ok: false;
    reason: "not_found" | "forbidden";
    job: null;
};
export type PageConvertJobEventsResponse = {
    events: PageConvertJobEvent[];
};
export type AiDesignerThemePatchOp = {
    op: "add";
    path: string;
    value: JsonValue;
} | {
    op: "replace";
    path: string;
    value: JsonValue;
} | {
    op: "remove";
    path: string;
};
export type ApplyAiDesignerThemePatchRequest = {
    baseThemeId: string;
    baseThemeUpdatedAt: string;
    ops: AiDesignerThemePatchOp[];
};
export type ApplyAiDesignerThemePatchResponse = {
    themeId: string;
    themeUpdatedAt: string;
};
export type ApplyAiDesignerPageOpsRequest = {
    kind: "reorder_blocks";
    pageId: string;
    baseBlockIds: string[];
    orderedBlockIds: string[];
} | {
    kind: "move_block";
    pageId: string;
    baseBlockIds: string[];
    blockId: string;
    afterBlockId: string | null;
} | {
    kind: "move_block";
    pageId: string;
    baseBlockIds: string[];
    blockId: string;
    beforeBlockId: string | null;
} | {
    kind: "swap_blocks";
    pageId: string;
    baseBlockIds: string[];
    blockIdA: string;
    blockIdB: string;
} | {
    kind: "delete_block";
    pageId: string;
    baseBlockIds: string[];
    blockId: string;
} | {
    kind: "add_block";
    pageId: string;
    baseBlockIds: string[];
    blockKind: string;
    afterBlockId?: string | null;
} | {
    kind: "duplicate_block";
    pageId: string;
    baseBlockIds: string[];
    blockId: string;
    afterBlockId?: string | null;
};
export type ApplyAiDesignerPageOpsResponse = {
    ok: true;
    warnings?: string[];
};
/**
 * RFC-6902 JSON Patch Operations
 * Standard JSON Patch format for AI Playground content updates
 */
export declare const Rfc6902PatchOp: z.ZodDiscriminatedUnion<[z.ZodObject<{
    op: z.ZodLiteral<"add">;
    path: z.ZodString;
    value: z.ZodUnknown;
}, z.core.$strip>, z.ZodObject<{
    op: z.ZodLiteral<"remove">;
    path: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
    op: z.ZodLiteral<"replace">;
    path: z.ZodString;
    value: z.ZodUnknown;
}, z.core.$strip>, z.ZodObject<{
    op: z.ZodLiteral<"move">;
    from: z.ZodString;
    path: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
    op: z.ZodLiteral<"copy">;
    from: z.ZodString;
    path: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
    op: z.ZodLiteral<"add_block">;
    blockKind: z.ZodString;
    afterBlockId: z.ZodNullable<z.ZodString>;
    content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
    rationale: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
    op: z.ZodLiteral<"delete_block">;
    blockId: z.ZodString;
    rationale: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
    op: z.ZodLiteral<"reorder_block">;
    blockId: z.ZodString;
    afterBlockId: z.ZodNullable<z.ZodString>;
    rationale: z.ZodString;
}, z.core.$strip>], "op">;
export declare const PlaygroundProposeRequest: z.ZodObject<{
    request: z.ZodString;
}, z.core.$strip>;
export declare const MultiPagePatchEnvelope: z.ZodObject<{
    pageId: z.ZodString;
    blockId: z.ZodOptional<z.ZodString>;
    blockKind: z.ZodOptional<z.ZodString>;
    blockPurpose: z.ZodNullable<z.ZodOptional<z.ZodString>>;
    ops: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
        op: z.ZodLiteral<"add">;
        path: z.ZodString;
        value: z.ZodUnknown;
    }, z.core.$strip>, z.ZodObject<{
        op: z.ZodLiteral<"remove">;
        path: z.ZodString;
    }, z.core.$strip>, z.ZodObject<{
        op: z.ZodLiteral<"replace">;
        path: z.ZodString;
        value: z.ZodUnknown;
    }, z.core.$strip>, z.ZodObject<{
        op: z.ZodLiteral<"move">;
        from: z.ZodString;
        path: z.ZodString;
    }, z.core.$strip>, z.ZodObject<{
        op: z.ZodLiteral<"copy">;
        from: z.ZodString;
        path: z.ZodString;
    }, z.core.$strip>, z.ZodObject<{
        op: z.ZodLiteral<"add_block">;
        blockKind: z.ZodString;
        afterBlockId: z.ZodNullable<z.ZodString>;
        content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
        rationale: z.ZodString;
    }, z.core.$strip>, z.ZodObject<{
        op: z.ZodLiteral<"delete_block">;
        blockId: z.ZodString;
        rationale: z.ZodString;
    }, z.core.$strip>, z.ZodObject<{
        op: z.ZodLiteral<"reorder_block">;
        blockId: z.ZodString;
        afterBlockId: z.ZodNullable<z.ZodString>;
        rationale: z.ZodString;
    }, z.core.$strip>], "op">>;
    rationale: z.ZodString;
    currentContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
}, z.core.$strip>;
export declare const MultiPageUpdateResponse: z.ZodObject<{
    patches: z.ZodArray<z.ZodObject<{
        pageId: z.ZodString;
        blockId: z.ZodOptional<z.ZodString>;
        blockKind: z.ZodOptional<z.ZodString>;
        blockPurpose: z.ZodNullable<z.ZodOptional<z.ZodString>>;
        ops: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
            op: z.ZodLiteral<"add">;
            path: z.ZodString;
            value: z.ZodUnknown;
        }, z.core.$strip>, z.ZodObject<{
            op: z.ZodLiteral<"remove">;
            path: z.ZodString;
        }, z.core.$strip>, z.ZodObject<{
            op: z.ZodLiteral<"replace">;
            path: z.ZodString;
            value: z.ZodUnknown;
        }, z.core.$strip>, z.ZodObject<{
            op: z.ZodLiteral<"move">;
            from: z.ZodString;
            path: z.ZodString;
        }, z.core.$strip>, z.ZodObject<{
            op: z.ZodLiteral<"copy">;
            from: z.ZodString;
            path: z.ZodString;
        }, z.core.$strip>, z.ZodObject<{
            op: z.ZodLiteral<"add_block">;
            blockKind: z.ZodString;
            afterBlockId: z.ZodNullable<z.ZodString>;
            content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
            rationale: z.ZodString;
        }, z.core.$strip>, z.ZodObject<{
            op: z.ZodLiteral<"delete_block">;
            blockId: z.ZodString;
            rationale: z.ZodString;
        }, z.core.$strip>, z.ZodObject<{
            op: z.ZodLiteral<"reorder_block">;
            blockId: z.ZodString;
            afterBlockId: z.ZodNullable<z.ZodString>;
            rationale: z.ZodString;
        }, z.core.$strip>], "op">>;
        rationale: z.ZodString;
        currentContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, z.core.$strip>>;
    assistantMessage: z.ZodString;
    pagesModified: z.ZodNumber;
    toolCallsUsed: z.ZodNumber;
}, z.core.$strip>;
export type StreamEvent = {
    type: 'status';
    message: string;
    detail?: string;
} | {
    type: 'tool_call';
    tool: string;
    args: unknown;
} | {
    type: 'tool_result';
    tool: string;
    summary: string;
} | {
    type: 'patch_group';
    envelope: MultiPagePatchEnvelope;
} | {
    type: 'complete';
    response: MultiPageUpdateResponse;
};
export type Rfc6902PatchOp = z.infer<typeof Rfc6902PatchOp>;
export type PlaygroundProposeRequest = z.infer<typeof PlaygroundProposeRequest>;
export type MultiPagePatchEnvelope = z.infer<typeof MultiPagePatchEnvelope>;
export type MultiPageUpdateResponse = z.infer<typeof MultiPageUpdateResponse>;
export { Rfc6902PatchOp as Rfc6902PatchOpSchema, PlaygroundProposeRequest as PlaygroundProposeRequestSchema, MultiPagePatchEnvelope as MultiPagePatchEnvelopeSchema, MultiPageUpdateResponse as MultiPageUpdateResponseSchema, };
export type AllowedField = {
    path: string;
    type: 'richtext' | 'plaintext' | 'url' | 'number' | 'boolean';
};
export type BlockContext = {
    id: string;
    kind: string;
    purpose: string | null;
    orderIndex: number;
    allowedPaths: string[];
    allowedFields?: AllowedField[];
    content: Record<string, unknown>;
};
export type PageContext = {
    site: {
        id: string;
        title: string;
        primaryDomain: string | null;
    };
    page: {
        id: string;
        path: string;
        title: string;
        slug: string | null;
        metaTitle: string | null;
        metaDescription: string | null;
        blocks: BlockContext[];
    };
};
