import { Item, FormDesign, Question, QuestionBase, SiteQuestion, Choice, MatrixColumn, EntityQuestion, Section, RosterMatrix, RosterGroup, Group, MatrixColumnQuestion, AssetQuestion, MatrixColumnCalculation, MatrixColumnText, DropdownQuestion, RadioQuestion, MulticheckQuestion, LikertQuestion, RankedQuestion, Timer, Instructions } from "./formDesign"; import { LocalizedString, Schema } from "@mwater/expressions"; import { EntityRef, ResponseData } from "./response"; import ResponseRow from "./ResponseRow"; /** Determine if locale is a right-to-left locale */ export declare function isRtlLocale(locale: string): boolean; export type AnswerType = "text" | "number" | "choice" | "choices" | "date" | "units" | "boolean" | "location" | "image" | "images" | "signature" | "texts" | "site" | "entity" | "admin_region" | "items_choices" | "matrix" | "aquagenx_cbt" | "cascading_list" | "cascading_ref" | "cascading_refs" | "ranked" | "asset" | "file" | "files" | "unknown"; /** Create ~ 128-bit uid without dashes */ export declare function createUid(): string; /** Create short unique id, with ~42 bits randomness to keep unique amoung a few choices */ export declare function createShortUid(): string; /** Create medium unique id, with ~58 bits randomness to keep unique amoung a 1,000,000 choices */ export declare function createMediumUid(): string; export declare function createBase32TimeCode(date: any): string; /** Determine if item is a question or a matrix column (which is similar and makes up * the contents of RosterMatrix) */ export declare function isQuestionOrMatrixColumnQuestion(item: Item | FormDesign): item is Question | MatrixColumnQuestion; /** Determine if item is a question */ export declare function isQuestion(item: Item | FormDesign): item is Question; /** Determine if item is a matrix column (which is similar and makes up * the contents of RosterMatrix) */ export declare function isMatrixColumnQuestion(item: Item | FormDesign): item is MatrixColumnQuestion; /** Determine if item is an expression */ export declare function isExpression(item: Item): item is MatrixColumnCalculation | MatrixColumnText; /** Determine if item is of type with contents */ export declare function isTypeWithContents(item: Item | FormDesign): item is Section | Group | RosterMatrix | RosterGroup | FormDesign; /** Determine if item has choices options (dropdown, radio, multicheck, likert, etc.) */ export declare function supportsChoices(item: Item | FormDesign): item is DropdownQuestion | RadioQuestion | MulticheckQuestion | LikertQuestion | RankedQuestion; /** Determine if item is a question that supports conditions */ export declare function supportsConditions(item: Item | FormDesign): item is Question | Section | Instructions | Timer | RosterGroup | RosterMatrix | Group; /** Determine if item is roster matrix or roster group */ export declare function isRoster(item: Item | FormDesign): item is RosterGroup | RosterMatrix; /** Determine if is form design type */ export declare function isFormDesign(item: Item | FormDesign): item is FormDesign; /** Determine if is matrix column */ export declare function isMatrixColumn(item: Item | FormDesign): item is MatrixColumn; /** Determine if item is disabled */ export declare function isDisabled(item: Item | FormDesign): boolean; /** Localize a localized string */ export declare function localizeString(str?: LocalizedString | null, locale?: string): string; /** Gets all questions in form before reference item specified * refItem can be null for all questions * rosterId is the rosterId to use. null for only top-level */ export declare function priorQuestions(formDesign: FormDesign, refItem?: Item | null, rosterId?: string | null): (Question | MatrixColumn)[]; export declare function getRosterIds(formDesign: any): string[]; export declare function findItem(formDesign: FormDesign, itemId: string): Item | undefined; /** Monotonic milliseconds for timing, falling back to wall clock where performance.now is missing */ export declare function now(): number; export declare function allItems(rootItem: FormDesign | Item): (Item | FormDesign)[]; export declare function prepareQuestion(q: any): any; export declare function changeQuestionType(question: any, newType: any): any; /** Normalizes the value of a "cascading_refs" answer to an array of row _ids. * Tolerates a bare string (the single-select shape) by wrapping it. Returns null when there is no selection. */ export declare function normalizeCascadingRefsValue(value: any): string[] | null; export declare function getAnswerType(q: QuestionBase | MatrixColumnQuestion): AnswerType; export declare function isSectioned(form: FormDesign): boolean; /** Repairs a paged form design (first top-level item a Section) whose top-level contents also contain * non-Section items, which cannot be rendered. Wraps each consecutive run of non-Section items in a new * Section. Returns the corrected design, or null if no repair was needed. Does not mutate the input. * New Section _ids are derived deterministically from the first wrapped item so that concurrent repairs * of the same design converge to identical output (important for three-way design merging). * A design whose first item is not a Section renders as a single page and is left alone unless * wrapLeading is true, which wraps leading non-Section items too if any top-level Section exists. */ export declare function normalizeMixedTopLevelSections(design: FormDesign, wrapLeading?: boolean): FormDesign | null; export declare function duplicateItem(item: any, idMap?: any): any; export declare function extractLocalizedStrings(obj: any): LocalizedString[]; export declare function updateLocalizations(formDesign: FormDesign): void; export declare function hasLocalizations(obj: any, locale: any): boolean; /** Finds all entity questions of the specified type, or legacy site questions */ export declare function findEntityQuestions(formDesign: FormDesign, entityType: string): (EntityQuestion | SiteQuestion | MatrixColumnQuestion)[]; /** Finds asset question in form * @param assetType optional asset type to match */ export declare function findAssetQuestion(formDesign: FormDesign, assetSystemId: number, assetType?: string): AssetQuestion | null; export declare function extractEntityReferences(formDesign: any, responseData: any): EntityRef[]; export declare function getSiteEntityType(question: SiteQuestion): string; /** Entity type (e.g. "water_point") that a site question or a site column of a roster matrix refers to */ export declare function getSiteOrSiteColumnEntityType(question: SiteQuestion | MatrixColumnQuestion): string; /** * Extracts all unique site entity types from all site questions and roster matrix site columns in a form design. * @param formDesign The form design object to extract site entity types from. * @returns An array of unique site entity types. */ export declare function getAllSiteEntityTypes(formDesign: FormDesign): string[]; /** Get list of custom table ids referenced by a form (cascading ref questions) * @deprecated Use getExtraTablesReferenced */ export declare function getCustomTablesReferenced(formDesign: FormDesign): string[]; /** * Get list of extra table ids referenced by a form (cascading ref questions and asset questions) */ export declare function getExtraTablesReferenced(formDesign: FormDesign): string[]; /** Determine if a choice is visible */ export declare function isChoiceVisible(choice: Choice, data: ResponseData, responseRow: ResponseRow, schema: Schema | undefined): Promise; /** Determines if a choice is allowed in a particular row of a fixed MatrixQuestion. * * Choices carry an optional `matrixRowIds` restriction. When it is absent the choice is * unrestricted and allowed in every row. When it is present the choice is only allowed in the * listed rows (so an empty array allows the choice nowhere, and ids of deleted rows simply match * nothing rather than lifting the restriction). * * `matrixRowId` is null/undefined when there is no fixed row context (roster matrices), in which * case the restriction does not apply and the choice is allowed. */ export declare function isChoiceAllowedInMatrixRow(choice: Choice, matrixRowId: string | null | undefined): boolean; /** Determines if the stored value of a fixed MatrixQuestion cell is a dropdown choice that is not * allowed in its row. Such answers are kept (never silently deleted), but are reported as invalid * so that the user has to correct them. * * Returns false for anything other than a dropdown column with a row-restricted choice, and for * values that reference a choice which no longer exists (that is not a row problem). */ export declare function isMatrixCellAnswerIncompatibleWithRow(column: MatrixColumn, matrixRowId: string | null | undefined, value: any): boolean; /** Convert Markdown text to sanitized HTML */ export declare function convertMarkdownToHtml(markdownText: string): string;