import Modal from '~/components/Modal'; import Language from '~/interfaces/Language'; /** * Password-protected document entry modal. * * Displays a password input form when the PDF document requires authentication. * The modal blocks the viewer until the correct password is submitted. * Password verification is delegated to a client-supplied listener via {@link onEnter}. * * The {@link show} method returns a `Promise` that resolves only when * the correct password is entered, allowing the caller to `await` it. */ export default class PasswordModal extends Modal { /** Callback invoked when the user submits a password. Returns whether the password is correct. */ private enterListener; /** Resolve function for the promise returned by {@link show}. */ private rslv; /** Reject function for the promise returned by {@link show}. */ private rej; /** Loading spinner shown during password verification. */ private loading; /** Password text input element. */ private passwordInput; /** Element that displays the "incorrect password" error message. */ private incorrect; /** Form submit button. */ private submitButton; /** * Creates a password modal and sets up form submission handling. * * @param context - The parent DOM element to append the modal into. * @param language - The locale resource for localized labels and messages. */ constructor(context: HTMLElement, language: Language); /** * Returns the localized HTML string for the password modal content. * * @returns The compiled Handlebars template string. */ render(): string; /** * Shows the password modal and returns a promise that resolves when the correct password is entered. * * The caller should `await` this method. The promise resolves after successful * password verification, or rejects if an error occurs during verification. * * @returns A promise that resolves when the password is accepted. */ show(): Promise; /** * Destroys the modal and its associated loading spinner. */ destroy(): void; /** * Registers a callback for password verification. * * The callback receives the entered password and must return `true` if the * password is correct, or `false` otherwise. The callback may be async. * * @param listener - The password verification callback. * @returns This instance for chaining. */ onEnter(listener: (password: string) => boolean | Promise): PasswordModal; }