/**
 * Copyright © 2023 Nevis Security AG. All rights reserved.
 */

import { PromptOptions } from './PromptOptions';

/**
 * Defines the elements of the fingerprint prompt (description, cancel and fallback button texts).
 *
 * > [!IMPORTANT]
 * > Customization of the fingerprint prompt is supported only on iOS and is ignored on Android.
 *
 * @group User Interaction
 * @category Fingerprint
 */
export abstract class FingerprintPromptOptions extends PromptOptions {
	/**
	 * The cancel button text.
	 *
	 * A default title "Cancel" is used when this property is left nil or is set to empty string.
	 */
	abstract cancelButtonText?: string;

	/**
	 * The fallback button text.
	 *
	 * If set to empty string, the button will be hidden. A default title "Enter Password" is used
	 * when this property is unspecified.
	 */
	abstract fallbackButtonText?: string;

	/**
	 * Default constructor for {@link FingerprintPromptOptions}.
	 *
	 * @param cancelButtonText the cancel button text.
	 * @param description the optional description to be used to prompt the user.
	 * @param fallbackButtonText the fallback button text.
	 * @returns the created {@link FingerprintPromptOptions} instance.
	 */
	static create(
		cancelButtonText: string,
		description?: string,
		fallbackButtonText?: string
	): FingerprintPromptOptions {
		return new FingerprintPromptOptionsImpl(cancelButtonText, description, fallbackButtonText);
	}
}

export class FingerprintPromptOptionsImpl extends FingerprintPromptOptions {
	description?: string;
	cancelButtonText: string;
	fallbackButtonText?: string;

	constructor(cancelButtonText: string, description?: string, fallbackButtonText?: string) {
		super();
		this.description = description;
		this.cancelButtonText = cancelButtonText;
		this.fallbackButtonText = fallbackButtonText;
	}
}
