import { S as StoreOpts, _ as CommentTarget, a as CommentValidationError, b as Page, c as CommentsSchema, d as commentsTableSql, f as Actor, g as CommentStatus, h as CommentInput, i as CommentSanitizationError, l as comments, m as CommentAuthor, o as InvalidCursorError, p as Comment, r as CommentNotFoundError, s as isCommentError, t as CommentAuthzError, u as commentsSchema, v as EntityRef, x as Sanitize, y as ListQuery } from "./errors-DEH0RQpz.js";
import { Querier } from "@platform-modules/db";
//#region src/model.d.ts
/** Maximum raw body length (cheap-DoS floor, spec §3). */
declare const MAX_BODY_LEN = 10000;
/** Normalized comment input — parentId always explicit null when absent. */
type NormalizedCommentInput = CommentInput & {
  parentId: string | null;
};
/**
 * Validator-agnostic boundary normalization (spec §3, coding-standard).
 * Throws CommentValidationError for: empty body, body > MAX_BODY_LEN, bad target, bad author.
 */
declare function normalizeCommentInput(raw: CommentInput): NormalizedCommentInput;
//#endregion
//#region src/store.d.ts
/**
 * list — flat paginated Page<Comment> (spec §3).
 * Default: status='published', order='oldest', limit=20.
 * Non-published statuses require actor.canModerate → CommentAuthzError.
 * Keyset: NUMERIC (createdAtMs, seq) — collation-safe (spec §3 ordering floor).
 */
declare function list(db: Querier<CommentsSchema>, target: CommentTarget, query?: ListQuery, actor?: Actor, _opts?: StoreOpts): Promise<Page<Comment>>;
/**
 * getById — returns Comment or null; same guest-email redaction as list (spec §3).
 * Returns tombstoned rows (trashed rows are still valid Comment shapes).
 */
declare function getById(db: Querier<CommentsSchema>, id: string, actor?: Actor, _opts?: StoreOpts): Promise<Comment | null>;
/**
 * post — create a new comment (spec §3).
 * sanitize REQUIRED (hard-floor #1); missing/non-function → CommentSanitizationError.
 * initialStatus defaults to 'pending'; non-moderator passing non-pending → CommentAuthzError.
 * depth stored at insert: parent.depth+1 capped at MAX_DEPTH; 0 for top-level.
 * Validates parent exists + shares same target.
 */
declare function post(db: Querier<CommentsSchema>, input: CommentInput, actor: Actor | null, sanitize: unknown, opts?: StoreOpts): Promise<EntityRef>;
/**
 * edit — update body + re-sanitize bodyHtml + bump editedAt (spec §3).
 * sanitize REQUIRED (hard-floor #1).
 * authz: author or canModerate (hard-floor #2).
 */
declare function edit(db: Querier<CommentsSchema>, id: string, body: string, actor: Actor, sanitize: unknown, _opts?: StoreOpts): Promise<EntityRef>;
/**
 * setStatus — moderation transition (spec §3).
 * Requires actor.canModerate (hard-floor #2).
 */
declare function setStatus(db: Querier<CommentsSchema>, id: string, status: CommentStatus, actor: Actor, _opts?: StoreOpts): Promise<EntityRef>;
/**
 * remove — tombstone if children exist, else hard-delete (spec §3 deletion floor).
 * authz: author or canModerate (hard-floor #2).
 */
declare function remove(db: Querier<CommentsSchema>, id: string, actor: Actor, _opts?: StoreOpts): Promise<void>;
/**
 * count — published-only count for "N comments" display (spec §3).
 */
declare function count(db: Querier<CommentsSchema>, target: CommentTarget, _opts?: StoreOpts): Promise<number>;
/**
 * listForModeration — CROSS-TARGET moderation queue (spec §3 hard-floor #5).
 * NO target filter — scans all rows, filtered by status only.
 * actor REQUIRED + canModerate UNCONDITIONAL (fail-closed) — cross-target enumeration is
 * privileged even for published rows. Default status=['pending'], default order='newest'.
 * Keyset (createdAtMs, seq) is globally sound (seq = per-store bigserial — total order
 * across all targets). Guest email VISIBLE (moderator-only by construction).
 */
declare function listForModeration(db: Querier<CommentsSchema>, query: ListQuery | undefined, actor: Actor, _opts?: StoreOpts): Promise<Page<Comment>>;
//#endregion
//#region src/authz.d.ts
/**
 * Object-level authz — IDOR floor (spec §3).
 * Allowed: authoring user OR actor.canModerate.
 * Guest-authored comments: no session identity → only a moderator may modify (standard comment behavior).
 */
declare function assertCanModify(actor: Actor | null, action: string, owner: CommentAuthor, commentId: string): void;
/**
 * Moderation transition gate (spec §3).
 * setStatus requires canModerate.
 */
declare function assertCanModerate(actor: Actor, action: string, commentId: string): void;
//#endregion
//#region src/cursor.d.ts
type Keyset = {
  createdAtMs: number;
  seq: number;
};
declare function encodeCursor(key: Keyset): string;
declare function decodeCursor(cursor: string): Keyset;
type ClampLimitOptions = {
  defaultLimit?: number;
  maxLimit?: number;
};
/** Clamp untrusted limit — non-finite/undefined/<=0 → default; huge → max. Never throws. */
declare function clampLimit(value: number | undefined, opts?: ClampLimitOptions): number;
//#endregion
export { type Actor, type ClampLimitOptions, type Comment, type CommentAuthor, CommentAuthzError, type CommentInput, CommentNotFoundError, CommentSanitizationError, type CommentStatus, type CommentTarget, CommentValidationError, type CommentsSchema, type EntityRef, InvalidCursorError, type Keyset, type ListQuery, MAX_BODY_LEN, type Page, type Sanitize, type StoreOpts, assertCanModerate, assertCanModify, clampLimit, comments, commentsSchema, commentsTableSql, count, decodeCursor, edit, encodeCursor, getById, isCommentError, list, listForModeration, normalizeCommentInput, post, remove, setStatus };