import { Environment } from '../../../../core/src/infrastructure/shared';
import { DomainError } from '../../../../core/src/errors/index.ts';
import { HINClient } from './integration/hin';
export interface PrescriptionSignProps {
    /**
     * Environment configuration for the prescription service
     * - 'local': Development environment (localhost:52247)
     * - 'dev': Development Azure Container Apps
     * - 'int': Integration Azure Container Apps
     * - 'prod': Production Azure Container Apps
     */
    environment: Environment;
    /** Base64-encoded CHMED prescription data to be signed */
    chmed: string;
    /** Access token for authenticating with the backend service */
    accessToken: string;
    /**
     * Optional existing session token to reuse authentication state.
     * If provided, the component will attempt to use existing authentication.
     */
    sessionToken?: string;
    /**
     * Optional callback invoked when the session token is updated.
     * Use this to persist the session token for reuse across components.
     */
    onSessionTokenUpdate?: (sessionToken: string) => void;
    /**
     * Optional callback invoked when prescription signing succeeds.
     * Receives the signed CHMED data as a base64-encoded string.
     * Optionally receives the generatedPdf if the option
     * shouldGeneratePdf is set to true.
     *
     * @see shouldGeneratePdf
     */
    onSuccess?: (signedCHMED: string) => void;
    /**
     * Optional callback invoked when prescription signing fails.
     * Receives a DomainError instance with full error context.
     */
    onError?: (error: DomainError) => void;
    /** Optional additional CSS class names to apply to the component */
    className?: string;
    /**
     * Optional flag to generate a PDF after signing the prescription.
     * If true, the component will attempt to generate a PDF of the signed prescription.
     */
    shouldGeneratePdf?: boolean;
}
/**
 * Internal events used by the prescription signing state machine
 * These events coordinate the complex authentication and signing workflow
 */
export type PrescriptionSignEvents = {
    type: 'OPEN_POPUP';
    popupRef: Window | null;
} | {
    type: 'CLOSE_POPUP';
} | {
    type: 'START';
    encodedCHMED: string;
    shouldGeneratePdf: boolean;
} | {
    type: 'TERMINATE';
} | {
    type: 'VERIFY_SESSION';
} | {
    type: 'REFRESH_TOKEN';
} | {
    type: 'GET_TOKEN';
} | {
    type: 'GET_SAML_AUTH_CODE';
    recoverable?: boolean;
    sessionToken: string;
} | {
    type: 'GET_SAML_AUTH_HANDLE';
    authCode: string;
} | {
    type: 'VALIDATE_CHMED';
    sessionToken: string;
} | {
    type: 'xstate.done.actor.getSAMLAuthHandle';
    sessionToken: string;
    recoverable?: boolean;
} | {
    type: 'SIGN_PRESCRIPTION';
    sessionToken: string;
    recoverable?: boolean;
} | {
    type: 'AUTHENTICATION_SUCCESS';
} | {
    type: 'ERROR';
    error: DomainError;
} | {
    type: 'UNAUTHORIZED_TOKEN';
} | {
    type: 'UNAUTHORIZED_HANDLE';
};
/**
 * Internal context used by the prescription signing state machine
 */
export type PrescriptionSignContext = {
    /** The client to comminucate with the component-service HIN features */
    hinClient: HINClient;
    /** The access token to authentify lib integrators */
    accessToken: string;
    /** The session token for the HIN authenticated user */
    sessionToken?: string;
    /** The CHMED data being processed (base64-encoded) */
    encodedCHMED?: string;
    /** The signed CHMED data returned from HIN (base64-encoded) */
    signedCHMED?: string;
    /** The generated PDF data if requested */
    generatedPdf?: string;
    /** Reference to the authentication popup window */
    popupRef: Window | null;
    /** Error accessible in the context. undefined when not in error state */
    error?: DomainError;
    /** Flag indicating if to generate a PDF after signing */
    shouldGeneratePdf: boolean;
};
/**
 * Inputs for machine context initialization
 */
export type PrescriptionSignContextInputs = {
    /** The environment configuration for the prescription service */
    environment: Environment;
    /** The access token to authentify lib integrators */
    accessToken: string;
    /** The session token for the HIN authenticated user */
    sessionToken?: string;
    /** Flag indicating if to generate a PDF after signing */
    shouldGeneratePdf: boolean;
};
