import { T as TagStub, a as Tag, S as SkuilderCourseData, Q as QualifiedCardID } from '../../types-legacy-DDY4N-Uq.js';
import { Moment } from 'moment';
import { A as AdminDBInterface, g as AssignedContent, h as StudyContentSource, i as StudentClassroomDBInterface, U as UserDBInterface, W as WeightedCard, T as TeacherClassroomDBInterface, b as CoursesDBInterface, C as CourseDBInterface, d as CourseInfo, D as DataLayerResult, e as ContentNavigationStrategyData, f as ContentNavigator, S as StudySessionItem, j as ScheduledCard } from '../../contentSource-BP9hznNV.js';
export { q as ContentSourceID, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, r as getStudySource, p as isReview } from '../../contentSource-BP9hznNV.js';
import * as _vue_skuilder_common from '@vue-skuilder/common';
import { ClassroomConfig, DataShape, CourseElo, CourseConfig as CourseConfig$1 } from '@vue-skuilder/common';
import { S as SyncStrategy, A as AccountCreationResult, a as AuthenticationResult } from '../../SyncStrategy-CyATpyLQ.js';

type NamespacedDatashape = string;
interface DataShape55 {
    name: NamespacedDatashape;
    questionTypes: PouchDB.Core.DocumentId[];
    serializedZodSchema?: string;
}
type NamespacedQuestion = string;
interface QuestionType55 {
    name: NamespacedQuestion;
    viewList: string[];
    dataShapeList: string[];
}
/**
 * metadata about a defined course
 *
 * Note: `courseID` is generated server-side. It is not present on
 * new courses at the time of writing, client-side, but always
 * present (!) when a CourseConfig is retrieved from the database
 */
interface CourseConfig {
    courseID?: string;
    name: string;
    description: string;
    public: boolean;
    deleted: boolean;
    creator: string;
    admins: string[];
    moderators: string[];
    dataShapes: DataShape55[];
    questionTypes: QuestionType55[];
    disambiguator?: string;
}

declare class AdminDB implements AdminDBInterface {
    private usersDB;
    constructor();
    getUsers(): Promise<PouchDB.Core.ExistingDocument<PouchDB.Core.AllDocsMeta>[]>;
    getCourses(): Promise<CourseConfig[]>;
    removeCourse(id: string): Promise<{
        ok: boolean;
        id: string;
        rev: string;
    }>;
    getClassrooms(): Promise<{
        _id: string;
        students: string[];
        teachers: string[];
        name: string;
        birthYear?: number;
        classMeetingSchedule: string;
        peerAssist: boolean;
        joinCode: string;
    }[]>;
}

declare const CLASSROOM_CONFIG = "ClassroomConfig";
type ClassroomMessage = object;
declare abstract class ClassroomDBBase {
    _id: string;
    protected _db: PouchDB.Database;
    protected _cfg: ClassroomConfig;
    protected _initComplete: boolean;
    protected readonly _content_prefix: string;
    protected get _content_searchkeys(): {
        startkey: string;
        endkey: string;
    };
    protected abstract init(): Promise<void>;
    getAssignedContent(): Promise<AssignedContent[]>;
    protected getContentId(content: AssignedContent): string;
    get ready(): boolean;
    getConfig(): ClassroomConfig;
}
declare class StudentClassroomDB extends ClassroomDBBase implements StudyContentSource, StudentClassroomDBInterface {
    private userMessages;
    private _user;
    private constructor();
    init(): Promise<void>;
    static factory(classID: string, user: UserDBInterface): Promise<StudentClassroomDB>;
    setChangeFcn(f: (value: unknown) => object): void;
    /**
     * Get cards with suitability scores for presentation.
     *
     * Gathers new cards from assigned content (courses, tags, cards) and
     * pending reviews scheduled for this classroom. Assigns score=1.0 to all.
     *
     * @param limit - Maximum number of cards to return
     * @returns Cards sorted by score descending (all scores = 1.0)
     */
    getWeightedCards(limit: number): Promise<WeightedCard[]>;
}
/**
 * Interface for managing a classroom.
 */
declare class TeacherClassroomDB extends ClassroomDBBase implements TeacherClassroomDBInterface {
    private _stuDb;
    private constructor();
    init(): Promise<void>;
    static factory(classID: string): Promise<TeacherClassroomDB>;
    removeContent(content: AssignedContent): Promise<void>;
    assignContent(content: AssignedContent): Promise<boolean>;
}
declare const ClassroomLookupDB: () => PouchDB.Database;
declare function getClassroomDB(classID: string, version: 'student' | 'teacher'): PouchDB.Database;
declare function getClassroomConfig(classID: string): Promise<ClassroomConfig>;

/**
 *
 * @param courseID id of the course (quilt) being added to
 * @param codeCourse
 * @param shape
 * @param data the datashape data - data required for this shape
 * @param author
 * @param uploads optional additional media uploads: img0, img1, ..., aud0, aud1,...
 * @returns
 */
declare function addNote55(courseID: string, codeCourse: string, shape: DataShape, data: unknown, author: string, tags: string[], uploads?: {
    [x: string]: PouchDB.Core.FullAttachment;
}, elo?: CourseElo): Promise<PouchDB.Core.Response>;
declare function getCredentialledCourseConfig(courseID: string): Promise<CourseConfig$1>;
/**
 Assciates a tag with a card.

 NB: DB stores tags as separate documents, with a list of card IDs.
     Consider renaming to `addCardToTag` to reflect this.

 NB: tags are created if they don't already exist

 @param updateELO whether to update the ELO of the card with the new tag. Default true.
 @package
*/
declare function addTagToCard(courseID: string, cardID: string, tagID: string, author: string, updateELO?: boolean): Promise<PouchDB.Core.Response>;
declare function getTagID(tagName: string): string;

declare class CoursesDB implements CoursesDBInterface {
    _courseIDs: string[] | undefined;
    constructor(courseIDs?: string[]);
    getCourseList(): Promise<CourseConfig$1[]>;
    getCourseConfig(courseId: string): Promise<CourseConfig$1>;
    disambiguateCourse(courseId: string, disambiguator: string): Promise<void>;
}
declare class CourseDB implements CourseDBInterface {
    private db;
    private id;
    private _getCurrentUser;
    private updateQueue;
    constructor(id: string, userLookup: () => Promise<UserDBInterface>);
    getCourseID(): string;
    getCourseInfo(): Promise<CourseInfo>;
    getInexperiencedCards(limit?: number): Promise<{
        courseId: string;
        cardId: any;
        count: any;
        elo: any;
    }[]>;
    getCardsByEloLimits(options?: {
        low: number;
        high: number;
        limit: number;
        page: number;
    }): Promise<string[]>;
    getCardEloData(id: string[]): Promise<CourseElo[]>;
    /**
     * Returns the lowest and highest `global` ELO ratings in the course
     */
    getELOBounds(): Promise<{
        low: any;
        high: any;
    }>;
    removeCard(id: string): Promise<PouchDB.Core.Response>;
    getCardDisplayableDataIDs(id: string[]): Promise<{
        [card: string]: string[];
    }>;
    getCardsByELO(elo: number, cardLimit?: number): Promise<{
        courseID: string;
        cardID: any;
        elo: any;
    }[]>;
    getCourseConfig(): Promise<CourseConfig$1>;
    updateCourseConfig(cfg: CourseConfig$1): Promise<PouchDB.Core.Response>;
    updateCardElo(cardId: string, elo: CourseElo): Promise<PouchDB.Core.Response>;
    getAppliedTags(cardId: string): Promise<PouchDB.Query.Response<TagStub>>;
    getAppliedTagsBatch(cardIds: string[]): Promise<Map<string, string[]>>;
    addTagToCard(cardId: string, tagId: string, updateELO?: boolean): Promise<PouchDB.Core.Response>;
    removeTagFromCard(cardId: string, tagId: string): Promise<PouchDB.Core.Response>;
    createTag(name: string, author: string): Promise<PouchDB.Core.Response>;
    getTag(tagId: string): Promise<PouchDB.Core.GetMeta & PouchDB.Core.Document<Tag>>;
    updateTag(tag: Tag): Promise<PouchDB.Core.Response>;
    getCourseTagStubs(): Promise<PouchDB.Core.AllDocsResponse<Tag>>;
    addNote(codeCourse: string, shape: DataShape, data: unknown, author: string, tags: string[], uploads?: {
        [key: string]: PouchDB.Core.FullAttachment;
    }, elo?: CourseElo): Promise<DataLayerResult>;
    getCourseDoc<T extends SkuilderCourseData>(id: string, options?: PouchDB.Core.GetOptions): Promise<PouchDB.Core.GetMeta & PouchDB.Core.Document<T>>;
    getCourseDocs<T extends SkuilderCourseData>(ids: string[], options?: PouchDB.Core.AllDocsOptions): Promise<PouchDB.Core.AllDocsWithKeysResponse<{} & T>>;
    getNavigationStrategy(id: string): Promise<ContentNavigationStrategyData>;
    getAllNavigationStrategies(): Promise<ContentNavigationStrategyData[]>;
    addNavigationStrategy(data: ContentNavigationStrategyData): Promise<void>;
    updateNavigationStrategy(id: string, data: ContentNavigationStrategyData): Promise<void>;
    /**
     * Creates an instantiated navigator for this course.
     *
     * Handles multiple generators by wrapping them in CompositeGenerator.
     * This is the preferred method for getting a ready-to-use navigator.
     *
     * @param user - User database interface
     * @returns Instantiated ContentNavigator ready for use
     */
    createNavigator(user: UserDBInterface): Promise<ContentNavigator>;
    /**
     * Get cards with suitability scores for presentation.
     *
     * This is the PRIMARY API for content sources going forward. Delegates to the
     * course's configured NavigationStrategy to get scored candidates.
     *
     * @param limit - Maximum number of cards to return
     * @returns Cards sorted by score descending
     */
    getWeightedCards(limit: number): Promise<WeightedCard[]>;
    getCardsCenteredAtELO(options?: {
        limit: number;
        elo: 'user' | 'random' | number;
    }, filter?: (a: QualifiedCardID) => boolean): Promise<StudySessionItem[]>;
    searchCards(query: string): Promise<any[]>;
    find(request: PouchDB.Find.FindRequest<any>): Promise<PouchDB.Find.FindResponse<any>>;
}
/**
 * Returns a list of registered datashapes for the specified
 * course.
 * @param courseID The ID of the course
 */
declare function getCourseDataShapes(courseID: string): Promise<_vue_skuilder_common.DataShape55[]>;
declare function getCredentialledDataShapes(courseID: string): Promise<_vue_skuilder_common.DataShape55[]>;
declare function getCourseQuestionTypes(courseID: string): Promise<_vue_skuilder_common.QuestionType55[]>;
declare function getCourseTagStubs(courseID: string): Promise<PouchDB.Core.AllDocsResponse<Tag>>;
declare function deleteTag(courseID: string, tagName: string): Promise<PouchDB.Core.Response>;
declare function createTag(courseID: string, tagName: string, author: string): Promise<PouchDB.Core.Response>;
declare function updateTag(tag: Tag): Promise<PouchDB.Core.Response>;
declare function getTag(courseID: string, tagName: string): Promise<Tag & PouchDB.Core.IdMeta & PouchDB.Core.GetMeta>;
declare function removeTagFromCard(courseID: string, cardID: string, tagID: string): Promise<PouchDB.Core.Response>;
/**
 * Returns an array of ancestor tag IDs, where:
 * return[0] = parent,
 * return[1] = grandparent,
 * return[2] = great grandparent,
 * etc.
 *
 * If ret is empty, the tag itself is a root
 */
declare function getAncestorTagIDs(courseID: string, tagID: string): string[];
declare function getChildTagStubs(courseID: string, tagID: string): Promise<PouchDB.Core.AllDocsResponse<{}>>;
declare function getAppliedTags(id_course: string, id_card: string): Promise<PouchDB.Query.Response<TagStub>>;
declare function updateCardElo(courseID: string, cardID: string, elo: CourseElo): Promise<PouchDB.Core.Response | undefined>;
declare function updateCredentialledCourseConfig(courseID: string, config: CourseConfig$1): Promise<PouchDB.Core.Response>;

/**
 * Sync strategy that implements full CouchDB remote synchronization
 * Handles account creation, authentication, and live sync with remote CouchDB server
 */
declare class CouchDBSyncStrategy implements SyncStrategy {
    private syncHandle?;
    setupRemoteDB(username: string): PouchDB.Database;
    getWriteDB(username: string): PouchDB.Database;
    startSync(localDB: PouchDB.Database, remoteDB: PouchDB.Database): void;
    stopSync?(): void;
    canCreateAccount(): boolean;
    canAuthenticate(): boolean;
    createAccount(username: string, password: string): Promise<AccountCreationResult>;
    authenticate(username: string, password: string): Promise<AuthenticationResult>;
    logout(): Promise<AuthenticationResult>;
    getCurrentUsername(): Promise<string>;
    /**
     * Migrate data from funnel account to real account
     */
    private migrateFunnelData;
    /**
     * Get remote CouchDB root database for authentication operations
     */
    private getRemoteCouchRootDB;
    /**
     * Get remote user database for a specific user
     */
    private getUserDB;
}

declare const localUserDB: PouchDB.Database;
declare function hexEncode(str: string): string;
/**
 * Creates PouchDB configuration with appropriate authentication method
 * - Uses HTTP Basic Auth when credentials are available (Node.js/MCP)
 * - Falls back to cookie auth for browser environments
 */
declare function createPouchDBConfig(): PouchDB.Configuration.RemoteDatabaseConfiguration;
declare function getCourseDB(courseID: string): PouchDB.Database;
declare function getLatestVersion(): Promise<string>;
/**
 * Checks the remote couchdb to see if a given username is available
 * @param username The username to be checked
 */
declare function usernameIsAvailable(username: string): Promise<boolean>;
declare function updateGuestAccountExpirationDate(guestDB: PouchDB.Database<object>): void;
declare function getCourseDocs<T extends SkuilderCourseData>(courseID: string, docIDs: string[], options?: PouchDB.Core.AllDocsOptions): Promise<PouchDB.Core.AllDocsWithKeysResponse<{} & T>>;
declare function getCourseDoc<T extends SkuilderCourseData>(courseID: string, docID: PouchDB.Core.DocumentId, options?: PouchDB.Core.GetOptions): Promise<T>;
/**
 * Returns *all* cards from the parameter courses, in
 * 'qualified' card format ("courseid-cardid")
 *
 * @param courseIDs A list of all course_ids to get cards from
 */
declare function getRandomCards(courseIDs: string[]): Promise<string[]>;
declare const REVIEW_TIME_FORMAT: string;
declare function getCouchUserDB(username: string): PouchDB.Database;
declare function scheduleCardReview(review: {
    user: string;
    course_id: string;
    card_id: PouchDB.Core.DocumentId;
    time: Moment;
    scheduledFor: ScheduledCard['scheduledFor'];
    schedulingAgentId: ScheduledCard['schedulingAgentId'];
}): void;
declare function filterAllDocsByPrefix<T>(db: PouchDB.Database, prefix: string, opts?: PouchDB.Core.AllDocsOptions): Promise<PouchDB.Core.AllDocsResponse<{} & T>>;
declare function getStartAndEndKeys(key: string): {
    startkey: string;
    endkey: string;
};

export { AdminDB, CLASSROOM_CONFIG, ClassroomLookupDB, type ClassroomMessage, CouchDBSyncStrategy, CourseDB, CoursesDB, REVIEW_TIME_FORMAT, StudentClassroomDB, StudyContentSource, StudySessionItem, TeacherClassroomDB, addNote55, addTagToCard, createPouchDBConfig, createTag, deleteTag, filterAllDocsByPrefix, getAncestorTagIDs, getAppliedTags, getChildTagStubs, getClassroomConfig, getClassroomDB, getCouchUserDB, getCourseDB, getCourseDataShapes, getCourseDoc, getCourseDocs, getCourseQuestionTypes, getCourseTagStubs, getCredentialledCourseConfig, getCredentialledDataShapes, getLatestVersion, getRandomCards, getStartAndEndKeys, getTag, getTagID, hexEncode, localUserDB, removeTagFromCard, scheduleCardReview, updateCardElo, updateCredentialledCourseConfig, updateGuestAccountExpirationDate, updateTag, usernameIsAvailable };
