/** A JSON-compatible metadata value attached to a submission. */ type FormbrewMetadataValue = boolean | number | string | null | FormbrewMetadataValue[] | { [key: string]: FormbrewMetadataValue; }; type FormbrewSubmissionMetadata = Record; type LengthValidation = { maxLength?: number; minLength?: number; }; type NumberValidation = { allowNegative?: boolean; integer?: boolean; max?: number; maxDecimalPlaces?: number; min?: number; }; type WebsiteValidation = LengthValidation & { httpsOnly?: boolean; }; type SelectionValidation = { maxSelections?: number; minSelections?: number; }; type ChoiceOption = { id: string; label: string; value: string; }; type ChoiceFieldConfig = { options: ChoiceOption[]; reservedValues?: string[]; }; /** TEXT field configuration. `null` renders a single-line input. */ type TextFieldConfig = { multiline: boolean; }; /** DATETIME rendering mode. `both` combines a date and time in one control. */ type DateTimeMode = "both" | "date" | "time"; type DateTimeFieldConfig = { mode: DateTimeMode; }; /** HIDDEN field configuration. `null` seeds no default value. */ type HiddenFieldConfig = { defaultValue: string; }; type ConfirmFieldConfig = { targetFieldId: string; }; type ContentFieldConfig = { document: ContentDocument; version: 1; }; /** Inline mark applied to a run of text within a content node. */ type ContentMark = { type: "bold"; } | { type: "italic"; } | { attrs: { href: string; }; type: "link"; }; /** A run of non-empty text with optional inline marks. */ type ContentTextNode = { marks?: ContentMark[]; text: string; type: "text"; }; /** A hard line break inside a paragraph or heading. */ type ContentHardBreakNode = { type: "hardBreak"; }; /** Inline content permitted inside paragraphs and headings. */ type ContentInlineNode = ContentHardBreakNode | ContentTextNode; type ContentParagraphNode = { content?: ContentInlineNode[]; type: "paragraph"; }; type ContentHeadingNode = { attrs: { level: 2 | 3; }; content?: ContentInlineNode[]; type: "heading"; }; type ContentListItemNode = { content: ContentParagraphNode[]; type: "listItem"; }; type ContentBulletListNode = { content: ContentListItemNode[]; type: "bulletList"; }; type ContentOrderedListNode = { attrs?: { start: number; }; content: ContentListItemNode[]; type: "orderedList"; }; /** A top-level block permitted at the root of a content document. */ type ContentBlockNode = ContentBulletListNode | ContentHeadingNode | ContentOrderedListNode | ContentParagraphNode; /** A safe, structured rich-text document rendered without raw HTML. */ type ContentDocument = { content: ContentBlockNode[]; type: "doc"; }; type PublicFormFieldBase = { columnIndex: number; helpText: string | null; id: string; key: string; label: string; placeholder: string | null; required: boolean; rowIndex: number; }; type TextFieldDefinition = PublicFormFieldBase & { configJson: TextFieldConfig | null; type: "TEXT"; validationJson: LengthValidation | null; }; type EmailFieldDefinition = PublicFormFieldBase & { configJson: null; type: "EMAIL"; validationJson: LengthValidation | null; }; type NumberFieldDefinition = PublicFormFieldBase & { configJson: null; type: "NUMBER"; validationJson: NumberValidation | null; }; type PhoneFieldDefinition = PublicFormFieldBase & { configJson: null; type: "PHONE"; validationJson: LengthValidation | null; }; type WebsiteFieldDefinition = PublicFormFieldBase & { configJson: null; type: "WEBSITE"; validationJson: WebsiteValidation | null; }; type CheckboxFieldDefinition = PublicFormFieldBase & { configJson: null; type: "CHECKBOX"; validationJson: null; }; type CheckboxGroupFieldDefinition = PublicFormFieldBase & { configJson: ChoiceFieldConfig; type: "CHECKBOX_GROUP"; validationJson: SelectionValidation | null; }; type RadioGroupFieldDefinition = PublicFormFieldBase & { configJson: ChoiceFieldConfig; type: "RADIO_GROUP"; validationJson: null; }; type SelectFieldDefinition = PublicFormFieldBase & { configJson: ChoiceFieldConfig; type: "SELECT"; validationJson: null; }; type DateTimeFieldDefinition = PublicFormFieldBase & { configJson: DateTimeFieldConfig; type: "DATETIME"; validationJson: null; }; type HiddenFieldDefinition = PublicFormFieldBase & { configJson: HiddenFieldConfig | null; required: false; type: "HIDDEN"; validationJson: null; }; type ConfirmFieldDefinition = PublicFormFieldBase & { configJson: ConfirmFieldConfig; required: false; type: "CONFIRM"; validationJson: null; }; type ContentFieldDefinition = PublicFormFieldBase & { configJson: ContentFieldConfig; required: false; type: "CONTENT"; validationJson: null; }; /** A discriminated union of every renderable public field definition. */ type PublicFormField = TextFieldDefinition | EmailFieldDefinition | NumberFieldDefinition | PhoneFieldDefinition | WebsiteFieldDefinition | CheckboxFieldDefinition | CheckboxGroupFieldDefinition | RadioGroupFieldDefinition | SelectFieldDefinition | DateTimeFieldDefinition | HiddenFieldDefinition | ConfirmFieldDefinition | ContentFieldDefinition; /** The public, render-safe form definition returned by Formbrew. */ type PublicFormDefinition = { fields: PublicFormField[]; honeypotFieldName: string; id: string; name: string; schemaVersion: number; slug: string; submitButtonLabel: string; successMessage: string; }; /** The unwrapped result of a successful submission. */ type FormbrewSubmissionResult = { id: string; message: string; }; type FormbrewErrorOptions = { cause?: unknown; code: string; details?: unknown; status?: number | null; }; /** A normalized Formbrew API, response, network, or configuration error. */ declare class FormbrewError extends Error { readonly code: string; readonly details?: unknown; readonly status: number | null; constructor(message: string, options: FormbrewErrorOptions); } declare const isFormbrewError: (error: unknown) => error is FormbrewError; /** Submission metadata or a callback that supplies it at submission time. */ type FormbrewMetadataProvider = FormbrewSubmissionMetadata | (() => FormbrewSubmissionMetadata); type FormbrewFormController = { readonly definition: PublicFormDefinition; readonly form: HTMLFormElement; readonly target: HTMLElement; destroy(): void; reset(): void; }; type FormbrewEmbedErrorPhase = "load" | "submit"; type FormbrewEmbedErrorDetail = { error: FormbrewError; phase: FormbrewEmbedErrorPhase; }; type FormbrewEmbedReadyDetail = { controller: FormbrewFormController; definition: PublicFormDefinition; }; type FormbrewEmbedSuccessDetail = { controller: FormbrewFormController; result: FormbrewSubmissionResult; }; type FormbrewFormElement = HTMLElement & { readonly controller: FormbrewFormController | null; readonly state: "error" | "loading" | "ready" | null; }; type FormbrewEmbedEventMap = { "formbrew:error": CustomEvent; "formbrew:ready": CustomEvent; "formbrew:success": CustomEvent; }; type FormbrewEmbedOptions = { baseUrl?: string; metadata?: FormbrewMetadataProvider; onError?: (error: FormbrewError, controller: FormbrewFormController) => void; onSuccess?: (result: FormbrewSubmissionResult, controller: FormbrewFormController) => void; signal?: AbortSignal; token: string; }; type FormbrewGlobal = { FormbrewError: typeof FormbrewError; isFormbrewError(error: unknown): error is FormbrewError; render(target: string | HTMLElement, options: FormbrewEmbedOptions): Promise; version: string; }; /** Fetches and mounts a managed Formbrew form in a browser element. */ declare const render: (target: string | HTMLElement, options: FormbrewEmbedOptions) => Promise; declare const version: string; export { type FormbrewEmbedErrorDetail, type FormbrewEmbedErrorPhase, type FormbrewEmbedEventMap, type FormbrewEmbedOptions, type FormbrewEmbedReadyDetail, type FormbrewEmbedSuccessDetail, FormbrewError, type FormbrewFormElement, type FormbrewGlobal, isFormbrewError, render, version };