import { Socket } from 'socket.io-client';

type AppProviderServices = Record<string, InstanceType<any>>;
interface AppProvider {
    get type(): "service" | "data" | "utils";
    services(params?: any): AppProviderServices;
}

declare abstract class AppModule {
    abstract name: string;
    abstract providers: AppProvider[];
    protected serviceRegistry: Record<string, any>;
    protected config: Record<string, any>;
    constructor(args: {
        deps: Record<string, AppModule>;
        config?: Record<string, any>;
    });
    init(): void;
    getService<T>(name: string): T;
    getConfig<T = any>(path?: string, throwIfMissing?: boolean): T | undefined;
}

declare class HttpError extends Error {
    status: string;
    details: any;
    constructor(message: string, status?: string, details?: any);
}

interface ApiResponse<T = any> {
    status: number;
    headers: Headers;
    body: T;
    rawBody: any;
    json: any;
}
interface ApiClient {
    key?: string;
}
interface ErrorHandlingStrategy {
    handleNetworkError?: (error: HttpError) => void;
    handleUnauthorizedError?: (error: HttpError) => void;
    handleForbiddenError?: (error: HttpError) => void;
    handleInvalidClientError?: (error: HttpError) => void;
    handleGenericError?: (error: HttpError, status: number) => void;
    shouldShowToast?: (error: HttpError, status: number) => boolean;
    getErrorTitle?: () => string;
}
interface Options extends RequestInit {
    client?: ApiClient;
    skipErrorToast?: boolean;
    errorHandling?: ErrorHandlingStrategy;
}

interface HttpClientConfig {
    apiUrl: string;
    errorHandlingStrategy?: ErrorHandlingStrategy;
    client?: ApiClient;
}
declare class HttpClient {
    private config;
    constructor(config: HttpClientConfig);
    get apiUrl(): string;
    get client(): ApiClient | undefined;
    get errorHandlingStrategy(): ErrorHandlingStrategy;
    static isValidObject(value: any): boolean;
    static flattenObject(value: any, path?: any[]): any;
    static jsonToQueryString(json: Record<string, any>): string;
    fetchJson<T = any>(url: string, options?: Options): Promise<ApiResponse<T>>;
    fetchData(url: string, options?: Options): Promise<Response>;
    private createHeaders;
    private interceptResponse;
    private isUnauthorized;
    private isLimitExceeded;
}

type CoreModuleConfig = {
    httpClient: HttpClient;
    secureStorage?: {
        getKey: (params?: any) => Promise<string>;
    };
};

declare class SharedProtectionPlanDataProvider implements AppProvider {
    private readonly core;
    constructor(core: AppModule);
    get type(): "data";
    services(): Record<string, any>;
}

/**
 * Drop-in replacement for SharedProtectionPlanDataProvider in dev/demo environments.
 * Keeps real local storage repos but swaps the API repo for a fake that simulates
 * auth events and moderator approvals with configurable delays.
 *
 * Usage — in SharedProtectionPlanModule:
 *   new FakeSharedProtectionPlanDataProvider(core)
 * instead of:
 *   new SharedProtectionPlanDataProvider(core)
 */
declare class FakeSharedProtectionPlanDataProvider implements AppProvider {
    private readonly core;
    constructor(core: AppModule);
    get type(): "data";
    services(): Record<string, any>;
}

declare class SharedProtectionPlanServiceProvider implements AppProvider {
    private readonly core;
    private readonly module;
    constructor(core: AppModule, module: AppModule);
    get type(): "service";
    services(): Record<string, any>;
}

declare class SharedProtectionPlanUseCaseProvider implements AppProvider {
    private readonly module;
    constructor(module: AppModule);
    get type(): "service";
    services(): Record<string, any>;
}

declare class SharedProtectionPlanModule extends AppModule {
    private readonly args;
    static readonly dependsOn: readonly ["core"];
    static readonly config?: CoreModuleConfig;
    name: string;
    constructor(args: {
        deps?: {
            core: AppModule;
        };
        config?: CoreModuleConfig;
    });
    get providers(): (FakeSharedProtectionPlanDataProvider | SharedProtectionPlanDataProvider | SharedProtectionPlanServiceProvider | SharedProtectionPlanUseCaseProvider)[];
}

/**
 * Union of all supported secret types that can be stored in a data asset.
 */
type SecretData = PlainTextAsset | UserAndPasswordAsset | RecoveryCodeAsset | PINCodeAsset | ApiKeyAsset | PrivateKeyAsset | SeedPhraseAsset | PaymentDebitCardAsset | PaymentCreditCardAsset | MediaAsset;
/**
 * Enumerates all possible asset types.
 */
type DataAssetType = 'PLAIN-TEXT' | 'ONLINE-ACCOUNT' | 'RECOVERY-CODE' | 'PIN-CODE' | 'API-KEY' | 'PRIVATE-KEY' | 'SEED-PHRASE' | 'PAYMENT-DEBIT-CARD' | 'PAYMENT-CREDIT-CARD' | 'PDF' | 'VIDEO';
/**
 * A secure, named asset that contains sensitive information such as passwords, keys, or account details.
 */
type DataAsset = {
    /**
     * Unique identifier of the asset.
     */
    id: string;
    /**
     * The type of secret stored. Used to determine how to parse and display the `secret` field.
     */
    type: DataAssetType;
    /**
     * Metadata describing the asset (e.g., name, notes).
     */
    meta: {
        /**
         * Display name for the asset.
         */
        name: string;
        /**
         * Optional notes or context for the asset.
         */
        notes?: string;
        /**
         * MIME type of the asset content (e.g. "application/pdf", "video/mp4").
         * Required when isMedia is true.
         */
        mimeType?: string;
        /**
         * True for binary media assets (PDF, VIDEO). When true, mimeType must be provided.
         * Used to correctly encode/decode the secret data during share generation and revelation.
         */
        isMedia?: boolean;
    };
    /**
     * The actual sensitive data, varying by asset type.
     */
    secret: SecretData;
};
/**
 * A simple plain text asset.
 */
type PlainTextAsset = {
    text: string;
};
/**
 * Credentials for logging into an app or website.
 */
type UserAndPasswordAsset = {
    appOrWebsite: string;
    email: string;
    username?: string;
    password: string;
};
/**
 * Backup recovery code for 2FA apps or websites.
 */
type RecoveryCodeAsset = {
    appOrWebsite: string;
    code: string;
};
/**
 * PIN code for a device or app.
 */
type PINCodeAsset = {
    deviceOrApp: string;
    code: string;
};
/**
 * API key for external services or apps.
 */
type ApiKeyAsset = {
    app: string;
    apiKey: string;
};
/**
 * Cryptocurrency private key and its associated public address.
 */
type PrivateKeyAsset = {
    publicAddress: string;
    privateKey: string;
};
/**
 * A seed phrase (mnemonic words) used to recover a crypto wallet.
 */
type SeedPhraseAsset = {
    words: string[];
};
/**
 * Sensitive information related to a debit card.
 */
type PaymentDebitCardAsset = {
    cardNumber: string;
    bank?: string;
    accountNumber?: string;
    cardHolderName?: string;
    expiryDate?: string;
    pinCode?: string;
    code?: string;
    clientId?: string;
};
/**
 * Sensitive information related to a credit card.
 */
type PaymentCreditCardAsset = {
    cardNumber: string;
    bank?: string;
    accountNumber?: string;
    cardHolderName?: string;
    expiryDate?: string;
    pinCode?: string;
    code?: string;
    clientId?: string;
};
/**
 * A binary media asset (PDF document or video file).
 *
 * When creating/sharing: `data` is a base64-encoded string.
 * When revealed via parseAssets({ denormalize: true }): `data` is a Blob with the correct MIME type.
 *
 * `mimeType` is stored inside the secret so it survives the SSDP+ round-trip
 * and is available during reconstruction without any extra metadata lookup.
 */
type MediaAsset = {
    /** Base64-encoded string (stored/shared) or a reconstructed Blob (after reveal). */
    data: string | Blob;
    /** MIME type of the content, e.g. "application/pdf" or "video/mp4". */
    mimeType: string;
};

declare class DataAssetManager {
    constructor();
    parseAssets(secrets: string, metadata: any, options?: {
        denormalize?: boolean;
    }): DataAsset[] | null;
    secrets(assets: DataAsset[]): ({
        text: string;
        id: string;
        type: DataAssetType;
    } | {
        appOrWebsite: string;
        email: string;
        username?: string;
        password: string;
        id: string;
        type: DataAssetType;
    } | {
        appOrWebsite: string;
        code: string;
        id: string;
        type: DataAssetType;
    } | {
        deviceOrApp: string;
        code: string;
        id: string;
        type: DataAssetType;
    } | {
        app: string;
        apiKey: string;
        id: string;
        type: DataAssetType;
    } | {
        publicAddress: string;
        privateKey: string;
        id: string;
        type: DataAssetType;
    } | {
        words: string[];
        id: string;
        type: DataAssetType;
    } | {
        cardNumber: string;
        bank?: string;
        accountNumber?: string;
        cardHolderName?: string;
        expiryDate?: string;
        pinCode?: string;
        code?: string;
        clientId?: string;
        id: string;
        type: DataAssetType;
    } | {
        cardNumber: string;
        bank?: string;
        accountNumber?: string;
        cardHolderName?: string;
        expiryDate?: string;
        pinCode?: string;
        code?: string;
        clientId?: string;
        id: string;
        type: DataAssetType;
    } | {
        data: string | Blob;
        mimeType: string;
        id: string;
        type: DataAssetType;
    })[];
    metadata(assets: DataAsset[]): {};
    toHex(assetsSecret: any[]): string;
    compress(assets: DataAsset[]): void;
    sanitizeAssetsValues(values: any): any[];
    private sanitizeValues;
    private base64ToBlob;
    private parseSecrets;
}

interface AccessPolicySubjectsProps {
    allow: string[];
    deny: string[];
}
interface AccessPolicyMetadataProps {
    updatedAt: string;
}
interface ProtectionPlanAccessPolicyProps {
    version: number;
    teams: AccessPolicySubjectsProps;
    members: AccessPolicySubjectsProps;
    metadata: AccessPolicyMetadataProps;
}
interface ProtectionPlanAccessPolicyPrimitiveProps extends ProtectionPlanAccessPolicyProps {
}
interface AccessPolicyFlatEntry {
    subjectType: 'team' | 'member';
    subjectId: string;
    accessType: 'allow' | 'deny';
}
declare class ProtectionPlanAccessPolicy {
    private props;
    constructor(props: ProtectionPlanAccessPolicyProps);
    private static validate;
    get version(): number;
    get teams(): AccessPolicySubjectsProps;
    get members(): AccessPolicySubjectsProps;
    get metadata(): AccessPolicyMetadataProps;
    toFlatEntries(): AccessPolicyFlatEntry[];
    static fromPrimitives(primitives: ProtectionPlanAccessPolicyPrimitiveProps): ProtectionPlanAccessPolicy;
    toPrimitives(): ProtectionPlanAccessPolicyPrimitiveProps;
}

interface SharedPlanShareProps {
    id: string;
    storageLayerId?: string;
    addresses: string[];
    createdAt?: Date;
    distributedAt?: Date;
    data?: string;
    key?: string;
}
declare class SharedPlanShare {
    private readonly props;
    constructor(props: SharedPlanShareProps);
    get id(): string;
    get storageLayerId(): string | undefined;
    get addresses(): string[];
    get data(): string | undefined;
    get key(): string | undefined;
    get createdAt(): Date | undefined;
    get distributedAt(): Date | undefined;
    static fromGeneration(props: {
        data: string;
        key: string;
    }): SharedPlanShare;
}

interface SharedPlanModeratorProps {
    id: string;
    firstName?: string;
    lastName?: string;
    email?: string;
}
interface SharedPlanModeratorPrimitiveProps extends SharedPlanModeratorProps {
}
declare class SharedPlanModerator {
    private readonly props;
    constructor(props: SharedPlanModeratorProps);
    get id(): string;
    get firstName(): string | undefined;
    get lastName(): string | undefined;
    get email(): string | undefined;
    toPrimitives(): SharedPlanModeratorPrimitiveProps;
}

type AuthMethodType = 'SAFEKEY_MOBILE' | 'EMAIL';
interface SharedPlanAuthenticationMethodProps {
    id: AuthMethodType;
    settings: any;
}
interface SharedPlanAuthenticationMethodPrimitiveProps extends Omit<SharedPlanAuthenticationMethodProps, "id"> {
    id: string;
}
declare class SharedPlanAuthenticationMethod {
    private readonly props;
    constructor(props: SharedPlanAuthenticationMethodProps);
    get id(): AuthMethodType;
    get settings(): any;
    toPrimitives(): SharedPlanAuthenticationMethodPrimitiveProps;
}

type SharedProtectionPlanStatus = 'DRAFT' | 'PROTECTED';
interface SharedPlanStorageLayer {
    id: "INHERITI_HSM" | "INHERITI_VAULT" | "INHERITI_CHAIN" | "GOOGLE_DRIVE" | "DROPBOX";
}
interface SharedProtectionPlanProps {
    id: string;
    tenantId?: string;
    type: 'BACKUP' | 'BUSINESS_CONTINUITY';
    name: string;
    description?: string;
    moderators?: SharedPlanModerator[];
    authenticationMethods?: SharedPlanAuthenticationMethod[];
    accessPolicy: ProtectionPlanAccessPolicy;
    mergeThreshold: number;
    shares: SharedPlanShare[];
    assets?: DataAsset[];
    status: SharedProtectionPlanStatus;
    storageLayers?: SharedPlanStorageLayer[];
    createdAt: Date;
    updatedAt: Date;
    accessType: "DIRECT" | "MODERATED";
    privacyMode: "PUBLIC" | "PRIVATE";
    assetsMetadata: any;
    categoryIds?: string[];
    code?: string;
}
interface SharedPlanSharePrimitiveProps {
    id: string;
    storageLayerId?: string;
    addresses: string[];
    data?: string;
    key?: string;
    createdAt?: Date | string;
    distributedAt?: Date | string;
}
interface SharedProtectionPlanPrimitiveProps extends Omit<SharedProtectionPlanProps, 'moderators' | 'authenticationMethods' | 'accessPolicy' | 'shares' | 'status' | 'createdAt' | 'updatedAt' | 'code'> {
    moderators?: SharedPlanModeratorPrimitiveProps[];
    authenticationMethods?: SharedPlanAuthenticationMethodPrimitiveProps[];
    accessPolicy: ProtectionPlanAccessPolicyPrimitiveProps;
    shares: SharedPlanSharePrimitiveProps[];
    status: string;
    createdAt: Date | string;
    updatedAt: Date | string;
    code?: string;
}
declare class SharedProtectionPlan {
    private readonly props;
    constructor(props: SharedProtectionPlanProps);
    get id(): string;
    get tenantId(): string | undefined;
    get type(): 'BACKUP' | 'BUSINESS_CONTINUITY';
    get name(): string;
    get description(): string | undefined;
    get privacyMode(): 'PUBLIC' | 'PRIVATE';
    get accessType(): 'DIRECT' | 'MODERATED';
    get accessPolicy(): ProtectionPlanAccessPolicy;
    get mergeThreshold(): number;
    get moderators(): SharedPlanModerator[] | undefined;
    get authenticationMethods(): SharedPlanAuthenticationMethod[] | undefined;
    get totalShares(): number;
    get assets(): DataAsset[] | undefined;
    get status(): SharedProtectionPlanStatus;
    get storageLayers(): SharedPlanStorageLayer[] | undefined;
    get assetsMetadata(): any;
    get categoryIds(): string[];
    get createdAt(): Date;
    get code(): string | undefined;
    get requiresAuthentication(): boolean;
    get isModerated(): boolean;
    static create(props: Omit<SharedProtectionPlanProps, "shares" | "status">): SharedProtectionPlan;
    withAssetsMetadata(assetsMetadata: any): SharedProtectionPlan;
    toPrimitives(): SharedProtectionPlanPrimitiveProps;
    static fromPrimitives(raw: SharedProtectionPlanPrimitiveProps): SharedProtectionPlan;
}

interface SharedProtectionPlanSummaryProps {
    id: string;
    name: string;
    description?: string;
    memberCount: number;
    threshold: number;
    createdAt: Date;
}
declare class SharedProtectionPlanSummary {
    private readonly props;
    constructor(props: SharedProtectionPlanSummaryProps);
    get id(): string;
    get name(): string;
    get description(): string | undefined;
    get memberCount(): number;
    get threshold(): number;
    get createdAt(): Date;
    get status(): string;
}

interface ProcessStepProps {
    id: string;
    status: 'COMPLETE' | 'INCOMPLETE' | 'IN_PROCESS';
}
interface ProcessStepPrimitiveProps extends ProcessStepProps {
}
declare class ProcessStep<T> {
    private props;
    constructor(props: ProcessStepProps & T);
    get id(): string;
    get isComplete(): boolean;
    get status(): "COMPLETE" | "INCOMPLETE" | "IN_PROCESS";
    get isPending(): boolean;
    get isInProcess(): boolean;
    static fromPrimitives(props: ProcessStepPrimitiveProps): ProcessStep<unknown>;
    reset(): void;
    markAsComplete(): void;
    markAsInProgress(): void;
    markAsIncomplete(): void;
    toPrimitives(): ProcessStepPrimitiveProps;
}

type SharedPlanConfigurationStepId = 'SHARES_CREATION' | 'SHARES_DISTRIBUTION' | "FINALIZE";
interface SharedPlanConfigurationProcessProps {
    id: string;
    planId: string;
    steps: ProcessStep<any>[];
    activeStep: number;
    stepErrors?: Record<string, string>;
    stepsAttempts?: Record<string, number>;
    createdAt: Date;
}
interface SharedPlanConfigurationProcessPrimitiveProps {
    id: string;
    planId: string;
    steps: ProcessStepPrimitiveProps[];
    activeStep: number;
    stepErrors?: Record<string, string>;
    stepsAttempts?: Record<string, number>;
    createdAt: Date;
}
declare class SharedPlanConfigurationProcess {
    private props;
    constructor(props: SharedPlanConfigurationProcessProps);
    get id(): string;
    get planId(): string;
    get steps(): ProcessStep<any>[];
    get createdAt(): Date;
    get activeStepIndex(): number;
    get currentStep(): ProcessStep<any>;
    get isCompleted(): boolean;
    get hasErrors(): boolean;
    static create(planId: string): SharedPlanConfigurationProcess;
    static fromPrimitives(props: SharedPlanConfigurationProcessPrimitiveProps): SharedPlanConfigurationProcess;
    start(): void;
    completeStep(step: ProcessStep<any>): void;
    setStepError(id: string, message: string): void;
    getStepError(id: string): string | undefined;
    cleanStepError(id: string): void;
    updateStepAttempt(id: string): void;
    stepCompleted(id: string): boolean | undefined;
    toPrimitives(): SharedPlanConfigurationProcessPrimitiveProps;
}

type SharedPlanMergeStep = 'PENDING' | 'PENDING_AUTHENTICATION' | 'WAITING_FOR_PERMISSION' | 'COLLECTING_SHARES' | 'REVEALING_DATA' | 'REVEALED' | 'COMPLETED' | 'FAILED';
interface CollectedShare {
    id: string;
    data: string;
    key: string;
}
interface SharedPlanMergeProcessProps {
    id: string;
    planId: string;
    step: SharedPlanMergeStep;
    collectedShares: CollectedShare[];
    requiredShares: number;
    /** Auth methods required by the plan — populated on initialize(). */
    authenticationMethods: SharedPlanAuthenticationMethod[];
    /** Moderators who need to approve — populated on initialize() for moderated plans. */
    moderators: SharedPlanModerator[];
    /** Auth methods confirmed so far — grows on each shared_plan_authenticated event. */
    authenticatedMethods: AuthMethodType[];
    /** Moderator IDs that have approved so far — grows on each shared_plan_permission_granted event. */
    approvedModeratorIds: string[];
    /** Storage layer IDs the plan is distributed across — populated on initialize(). */
    storageLayers: string[];
    /** Storage layer IDs whose shares have been successfully collected so far. */
    collectedStorageLayerIds: string[];
    createdAt: Date;
}
declare class SharedPlanMergeProcess {
    private readonly props;
    constructor(props: SharedPlanMergeProcessProps);
    get id(): string;
    get planId(): string;
    get step(): SharedPlanMergeStep;
    get collectedShares(): CollectedShare[];
    get requiredShares(): number;
    get authenticationMethods(): SharedPlanAuthenticationMethod[];
    get moderators(): SharedPlanModerator[];
    get authenticatedMethods(): AuthMethodType[];
    get approvedModeratorIds(): string[];
    get storageLayers(): string[];
    get collectedStorageLayerIds(): string[];
    get collectedCount(): number;
    get hasEnoughShares(): boolean;
    get pendingStorageLayers(): string[];
    static create(props: Omit<SharedPlanMergeProcessProps, 'step' | 'collectedShares' | 'authenticatedMethods' | 'approvedModeratorIds' | 'collectedStorageLayerIds'>): SharedPlanMergeProcess;
    withStep(step: SharedPlanMergeStep): SharedPlanMergeProcess;
    withShare(share: CollectedShare): SharedPlanMergeProcess;
    withAuthenticatedMethods(methods: AuthMethodType[]): SharedPlanMergeProcess;
    withApprovedModerators(ids: string[]): SharedPlanMergeProcess;
    withCollectedStorageLayer(layerId: string, share: CollectedShare): SharedPlanMergeProcess;
    toPrimitives(): {
        id: string;
        planId: string;
        step: SharedPlanMergeStep;
        collectedShares: CollectedShare[];
        requiredShares: number;
        authenticationMethods: SharedPlanAuthenticationMethodPrimitiveProps[];
        moderators: SharedPlanModeratorPrimitiveProps[];
        authenticatedMethods: AuthMethodType[];
        approvedModeratorIds: string[];
        storageLayers: string[];
        collectedStorageLayerIds: string[];
        createdAt: Date;
    };
    static fromPrimitives(raw: any): SharedPlanMergeProcess;
}

type SharedMergeStatus = 'NOT_STARTED' | 'PENDING' | 'PENDING_AUTHENTICATION' | 'WAITING_FOR_PERMISSION' | 'COLLECTING_SHARES' | 'REVEALING_DATA' | 'REVEALED' | 'COMPLETED' | 'FAILED';
interface AuthMethodView {
    id: AuthMethodType;
    checked: boolean;
}
interface ModeratorView {
    id: string;
    firstName?: string;
    lastName?: string;
    email?: string;
    approved: boolean;
}
interface StorageLayerView {
    id: string;
    collected: boolean;
}
interface SharedPlanMergeProcessViewProps {
    processId?: string;
    planId?: string;
    status: SharedMergeStatus;
    authenticationMethods: AuthMethodView[];
    moderators: ModeratorView[];
    storageLayers: StorageLayerView[];
    revealedAssets?: DataAsset[] | null;
}
declare class SharedPlanMergeProcessView {
    private readonly props;
    constructor(props: SharedPlanMergeProcessViewProps);
    static notStarted(): SharedPlanMergeProcessView;
    static build(process: SharedPlanMergeProcess, revealedAssets?: DataAsset[] | null): SharedPlanMergeProcessView;
    get processId(): string | undefined;
    get planId(): string | undefined;
    get status(): SharedMergeStatus;
    get isStarted(): boolean;
    get isAuthenticating(): boolean;
    get isWaitingForPermission(): boolean;
    get isCollectingShares(): boolean;
    get isRevealing(): boolean;
    get isRevealed(): boolean;
    get isCompleted(): boolean;
    get isFailed(): boolean;
    get isDone(): boolean;
    get authenticationMethods(): AuthMethodView[];
    get authProgress(): {
        completed: number;
        total: number;
    };
    get nextPendingAuthMethod(): AuthMethodView | undefined;
    get moderators(): ModeratorView[];
    get storageLayers(): StorageLayerView[];
    get sharesProgress(): {
        collected: number;
        total: number;
    };
    get permissionProgress(): {
        approved: number;
        total: number;
    };
    get nextPendingModerator(): ModeratorView | undefined;
    get revealedAssets(): DataAsset[] | null | undefined;
    toPrimitives(): SharedPlanMergeProcessViewProps;
}

interface SharedProtectionPlanViewProps {
    plan: SharedProtectionPlanSummary;
    configurationProcess?: SharedPlanConfigurationProcess;
    mergeProcess?: SharedPlanMergeProcessView;
}
declare class SharedProtectionPlanView {
    private readonly props;
    constructor(props: SharedProtectionPlanViewProps);
    get plan(): SharedProtectionPlanSummary;
    get configurationProcess(): SharedPlanConfigurationProcess | undefined;
    get mergeProcess(): SharedPlanMergeProcessView | undefined;
    get isConfigured(): boolean;
    get isMerging(): boolean;
}

interface AccessPolicyInput {
    teams: AccessPolicySubjectsProps;
    members: AccessPolicySubjectsProps;
}
interface SharedPlanModeratorsInput {
    id: string;
}
interface SharedPlanAuthenticationMethodInput {
    id: AuthMethodType;
}
interface CreateSharedProtectionPlanInput {
    id?: string;
    tenantId: string;
    type: 'BACKUP' | 'BUSINESS_CONTINUITY';
    name: string;
    description?: string;
    accessPolicy: AccessPolicyInput;
    privacyMode: "PUBLIC" | "PRIVATE";
    accessType?: "DIRECT" | "MODERATED";
    moderators?: SharedPlanModeratorsInput[];
    authenticationMethods?: SharedPlanAuthenticationMethodInput[];
    threshold: number;
    assets: (DataAsset | Omit<DataAsset, 'id'> & {
        id?: string;
    })[];
    categoryIds?: string[];
}

interface SharedPlanSharesGeneratorResult {
    dataShares: string[];
    keyShares: string[];
}
interface SharedPlanSharesGenerator {
    generate(data: Uint8Array, params: {
        total: number;
        threshold: number;
    }): Promise<SharedPlanSharesGeneratorResult>;
}

interface SharedPlanDataRevealer {
    reveal(dataShares: string[], keyShares: string[], params: {
        threshold: number;
        assetsMetadata?: any;
    }): Promise<DataAsset[]>;
}

interface SharedPlanEventHandlers {
    /** Generic process state change — use for view refreshes. */
    onProcessUpdated?: () => void | Promise<void>;
    /** Backend confirmed the user is authenticated (email link clicked / SafeKey approved). */
    onAuthenticated?: () => void | Promise<void>;
    /** All moderators granted permission. */
    onPermissionGranted?: () => void | Promise<void>;
}
interface SharedPlanEventListener {
    subscribe(planId: string, handlers: SharedPlanEventHandlers): void;
    unsubscribe(planId: string): void;
}

type SharedPlanViewStatus = 'DRAFT' | 'PROTECTED';
type SharedPlanViewType = 'BACKUP' | 'BUSINESS_CONTINUITY';
type SharedPlanViewPrivacyMode = 'PUBLIC' | 'PRIVATE';
type SharedPlanViewAccessType = 'DIRECT' | 'MODERATED';
interface SharedPlanViewModerator {
    id: string;
    countdown?: {
        days: number;
        hours: number;
        minutes: number;
    };
}
interface SharedPlanViewAuthenticationMethod {
    id: string;
    status?: string;
    settings?: any;
}
interface SharedPlanViewShare {
    id: string;
    storageLayerId?: string;
    addresses: string[];
    data?: string;
    key?: string;
    createdAt?: Date;
    distributedAt?: Date;
}
interface SharedPlanViewProps {
    id: string;
    tenantId?: string;
    creatorId?: string;
    code?: string;
    type: SharedPlanViewType;
    name: string;
    description?: string;
    status: SharedPlanViewStatus;
    privacyMode: SharedPlanViewPrivacyMode;
    accessType?: SharedPlanViewAccessType;
    mergeThreshold: number;
    mergeCount: number;
    moderators?: SharedPlanViewModerator[];
    authenticationMethods?: SharedPlanViewAuthenticationMethod[];
    shares: SharedPlanViewShare[];
    categoryIds: string[];
    accessPolicy?: any;
    settings?: any;
    configuredAt?: Date;
    createdAt: Date;
}
declare class SharedPlanView {
    private readonly props;
    constructor(props: SharedPlanViewProps);
    get id(): string;
    get tenantId(): string | undefined;
    get creatorId(): string | undefined;
    get code(): string | undefined;
    get type(): SharedPlanViewType;
    get name(): string;
    get description(): string | undefined;
    get status(): SharedPlanViewStatus;
    get isDraft(): boolean;
    get isProtected(): boolean;
    get isConfigured(): boolean;
    get privacyMode(): SharedPlanViewPrivacyMode;
    get accessType(): SharedPlanViewAccessType | undefined;
    get isModerated(): boolean;
    get mergeThreshold(): number;
    get mergeCount(): number;
    get moderators(): SharedPlanViewModerator[];
    get authenticationMethods(): SharedPlanViewAuthenticationMethod[];
    get requiresAuthentication(): boolean;
    get shares(): SharedPlanViewShare[];
    get totalShares(): number;
    get categoryIds(): string[];
    get accessPolicy(): any;
    get settings(): any;
    get configuredAt(): Date | undefined;
    get createdAt(): Date;
    static fromRaw(raw: any): SharedPlanView;
}

interface PaginationOptions {
    page?: number;
    perPage?: number;
}

interface QueryOptions {
    keepPreviousData?: boolean;
    enabled?: boolean;
    cacheTime?: number;
    staleTime?: number;
}

type ResourceCount = {
    count: number;
};

interface SortOptions {
    field?: string;
    order?: string;
}

interface UseQueryValue<T = any> {
    data?: T;
    total?: number;
    error?: any;
    isIdle: boolean;
    loading: boolean;
    loaded: boolean;
    refetch: any;
    isFetching: boolean;
    isRefetching: boolean;
}

type ResponseQueryValue<Model> = Omit<UseQueryValue, 'data' | 'isIdle'> & {
    data?: {
        [id: string]: Model;
    };
    isIdle?: boolean;
    ids?: string[];
};
interface UseGetListValue<T> extends ResponseQueryValue<T> {
}

interface APIRepositoryProps {
    httpClient: HttpClient;
    httpClientKey?: string;
}
interface RequestOptions {
}
declare abstract class APIRepository {
    protected readonly props: APIRepositoryProps;
    protected httpClient: HttpClient;
    constructor(props: APIRepositoryProps);
    findByCriteriaRequest<T>(resource: string, filter?: any, pagination?: PaginationOptions, sort?: SortOptions, withAuth?: boolean, options?: RequestOptions): Promise<T[]>;
    countRequest<T>(resource: string, where?: any, withAuth?: boolean, options?: RequestOptions): Promise<any>;
    findOneById<T>(resource: string, id: string, withAuth?: boolean, options?: RequestOptions): Promise<T | undefined>;
    create<T>(resource: string, data: any, withAuth?: boolean, options?: RequestOptions): Promise<any>;
    updateById<T>(resource: string, id: string, changes: any, withAuth?: boolean, options?: RequestOptions): Promise<any>;
    deleteById<T>(resource: string, id: string, withAuth?: boolean, options?: RequestOptions): Promise<void>;
    get<T>(path: string, withAuth?: boolean, options?: RequestOptions): Promise<T>;
    post<T>(path: string, data: any, withAuth?: boolean, options?: RequestOptions): Promise<any>;
    patch<T>(resource: string, changes: any, withAuth?: boolean, options?: RequestOptions): Promise<any>;
    getClientApiUrl(path: string): string;
    private getRequestOptions;
}

interface FindSharedPlansCriteria {
    tenantId?: string;
    teamId?: string;
    userId?: string;
    memberId?: string;
    q?: string;
    categoryId?: string;
    categoryIds?: string[];
    type?: string;
    storageLayerType?: string;
}
declare class FindSharedProtectionPlansByCriteriaUseCase {
    private readonly planRepository;
    constructor(planRepository: SharedProtectionPlanRepository);
    execute(filters: FindSharedPlansCriteria, pagination?: PaginationOptions, sort?: SortOptions): Promise<SharedPlanView[]>;
}

interface SharedProtectionPlanRepository {
    findById(id: string): Promise<SharedProtectionPlan | null>;
    findAll(): Promise<SharedPlanView[]>;
    findByCriteria(criteria: FindSharedPlansCriteria, pagination?: PaginationOptions, sort?: SortOptions): Promise<SharedPlanView[]>;
    count(criteria: FindSharedPlansCriteria): Promise<ResourceCount>;
    save(plan: SharedProtectionPlan): Promise<void>;
    delete(id: string): Promise<void>;
    /** Sends all encrypted shares to the backend to complete plan configuration. */
    configure(planId: string, shares: SharedPlanShare[]): Promise<void>;
}

interface SharedConfigurationProcessRepository {
    findByPlanId(planId: string): Promise<SharedPlanConfigurationProcess | null>;
    save(process: SharedPlanConfigurationProcess): Promise<void>;
    delete(planId: string): Promise<void>;
}

/** Local session storage — persists the in-progress merge process across page reloads. */
interface SharedMergingProcessLocalRepository {
    findById(id: string): Promise<SharedPlanMergeProcess | null>;
    save(process: SharedPlanMergeProcess): Promise<void>;
    delete(id: string): Promise<void>;
}

/** Remote API — all network calls for the merge process lifecycle. */
interface SharedMergingProcessApiRepository {
    startProcess(planId: string, processId: string): Promise<void>;
    requestAuthentication(processId: string): Promise<void>;
    getAuthenticationStatus(processId: string): Promise<{
        completedMethods: AuthMethodType[];
    }>;
    requestPermission(processId: string): Promise<void>;
    getPermissionStatus(processId: string): Promise<{
        approvedModeratorIds: string[];
    }>;
    /** Request the share from a specific storage layer. Awaits until the layer returns its share. */
    requestShares(processId: string, storageLayerId: string): Promise<CollectedShare>;
}

/** Combined interface used by the orchestrator. Implemented by an adapter. */
interface SharedMergingProcessRepository extends SharedMergingProcessLocalRepository, SharedMergingProcessApiRepository {
}

declare class CreateSharedProtectionPlanUseCase {
    private readonly planRepository;
    private readonly assetManager;
    constructor(planRepository: SharedProtectionPlanRepository, assetManager: DataAssetManager);
    execute(input: CreateSharedProtectionPlanInput): Promise<SharedProtectionPlan>;
}

declare class GetSharedProtectionPlanUseCase {
    private readonly planRepository;
    constructor(planRepository: SharedProtectionPlanRepository);
    execute(planId: string): Promise<SharedProtectionPlan | null>;
}

declare class CountSharedProtectionPlansUseCase {
    private readonly planRepository;
    constructor(planRepository: SharedProtectionPlanRepository);
    execute(criteria: FindSharedPlansCriteria): Promise<ResourceCount>;
}

interface GenerateSharesInput {
    assets: DataAsset[];
    threshold: number;
    total?: number;
}
declare class GenerateSharesUseCase {
    private readonly assetManager;
    private readonly generator;
    private static readonly DEFAULT_SHARES_TOTAL;
    constructor(assetManager: DataAssetManager, generator: SharedPlanSharesGenerator);
    execute(input: GenerateSharesInput): Promise<SharedPlanShare[]>;
}

declare class DistributeSharesUseCase {
    private readonly planRepository;
    private readonly configRepository;
    constructor(planRepository: SharedProtectionPlanRepository, configRepository: SharedConfigurationProcessRepository);
    execute(process: SharedPlanConfigurationProcess, shares: SharedPlanShare[], assetsMetadata?: any): Promise<void>;
}

interface ConfigureSharedProtectionPlanInput {
    planId: string;
    assets: DataAsset[];
    storageLayersCount: number;
    /** Override threshold; defaults to plan.mergeThreshold */
    threshold?: number;
}
interface ConfigureSharedProtectionPlanCallbacks {
    onSharesGenerated?: (shares: SharedPlanShare[]) => void;
    onSharesDistributed?: () => void;
    onCompleted?: () => void;
    onError?: (error: Error) => void;
    /** Signal that the backend pushed a process update via socket. */
    onProcessUpdated?: () => void;
}
interface ConfigureSharedProtectionPlanDeps {
    planRepository: SharedProtectionPlanRepository;
    configRepository: SharedConfigurationProcessRepository;
    generateShares: GenerateSharesUseCase;
    distributeShares: DistributeSharesUseCase;
    eventListener: SharedPlanEventListener;
    assetManager: DataAssetManager;
}
declare class ConfigureSharedProtectionPlanUseCase {
    private readonly deps;
    private activeSubscription;
    constructor(deps: ConfigureSharedProtectionPlanDeps);
    subscribe(planId: string, handlers: SharedPlanEventHandlers): void;
    unsubscribe(planId: string): void;
    execute(input: ConfigureSharedProtectionPlanInput, callbacks?: ConfigureSharedProtectionPlanCallbacks): Promise<void>;
}

declare class GetSharedPlanConfigurationProcessUseCase {
    private readonly configRepository;
    constructor(configRepository: SharedConfigurationProcessRepository);
    execute(planId: string): Promise<SharedPlanConfigurationProcess | null>;
}

declare class DeleteSharedPlanConfigurationProcessUseCase {
    private readonly configRepository;
    constructor(configRepository: SharedConfigurationProcessRepository);
    execute(planId: string): Promise<void>;
}

declare class SsdpPlusSharedPlanSharesGenerator implements SharedPlanSharesGenerator {
    generate(data: Uint8Array, params: {
        total: number;
        threshold: number;
    }): Promise<SharedPlanSharesGeneratorResult>;
}

declare class SsdpPlusSharedPlanDataRevealer implements SharedPlanDataRevealer {
    private readonly assetManager;
    constructor(assetManager: DataAssetManager);
    reveal(dataShares: string[], keyShares: string[], params: {
        threshold: number;
        assetsMetadata?: any;
    }): Promise<DataAsset[]>;
}

interface SocketSubscription {
    /** Server-room join event.  Omit when server-side subscription is explicit (e.g. requestToken). */
    subscribeEmit?: string;
    subscribePayload?: object;
    /** Server-room leave event. */
    unsubscribeEmit: string;
    unsubscribePayload: object;
    /** Pairs of socket event name + the exact handler reference used with socket.on(). */
    bindings: Array<{
        event: string;
        handler: (...args: any[]) => void;
    }>;
}
declare abstract class SocketIoBaseEventListener {
    protected readonly socket: Socket;
    private readonly subs;
    private readonly onReconnect;
    constructor(socket: Socket);
    /**
     * Register a subscription under `key`.
     * If a subscription with the same key already exists it is cleanly removed first
     * (deduplication — safe to call on every render / effect re-run).
     */
    protected register(key: string, sub: SocketSubscription): void;
    /**
     * Remove a subscription: calls socket.off() with the exact stored handler
     * references and emits the server-side unsubscribe event.
     */
    protected remove(key: string): void;
    /**
     * Update the reconnect payload for an existing subscription.
     * Use this when the server-side subscription is triggered by an explicit call
     * after the initial register() (e.g. requestToken), so that reconnect can
     * re-emit it automatically.
     */
    protected setReconnectEmit(key: string, subscribeEmit: string, subscribePayload: object): void;
    /**
     * Remove all active subscriptions and the reconnect handler.
     * Call when the listener itself is no longer needed (e.g. module teardown).
     */
    destroy(): void;
}

declare class SocketIoSharedPlanEventListener extends SocketIoBaseEventListener implements SharedPlanEventListener {
    constructor(socket: Socket);
    subscribe(planId: string, handlers: SharedPlanEventHandlers): void;
    unsubscribe(planId: string): void;
}

declare class AppSharedConfigurationProcessRepository extends APIRepository implements SharedConfigurationProcessRepository {
    private storage;
    constructor(props: APIRepositoryProps);
    findByPlanId(planId: string): Promise<SharedPlanConfigurationProcess | null>;
    save(process: SharedPlanConfigurationProcess): Promise<void>;
    delete(planId: string): Promise<void>;
}

/** Combines a local storage repo and an API repo into the single interface the orchestrator expects. */
declare class AppSharedMergingProcessRepository implements SharedMergingProcessRepository {
    private readonly local;
    private readonly api;
    constructor(local: SharedMergingProcessLocalRepository, api: SharedMergingProcessApiRepository);
    findById(id: string): Promise<SharedPlanMergeProcess | null>;
    save(process: SharedPlanMergeProcess): Promise<void>;
    delete(id: string): Promise<void>;
    startProcess(planId: string, processId: string): Promise<void>;
    requestAuthentication(processId: string): Promise<void>;
    getAuthenticationStatus(processId: string): Promise<{
        completedMethods: AuthMethodType[];
    }>;
    requestPermission(processId: string): Promise<void>;
    getPermissionStatus(processId: string): Promise<{
        approvedModeratorIds: string[];
    }>;
    requestShares(processId: string): Promise<CollectedShare[]>;
}

declare class AppSharedProtectionPlanRepository extends APIRepository implements SharedProtectionPlanRepository {
    constructor(props: APIRepositoryProps);
    findById(id: string): Promise<SharedProtectionPlan | null>;
    findAll(): Promise<SharedPlanView[]>;
    findByCriteria(criteria: FindSharedPlansCriteria, pagination?: PaginationOptions, sort?: SortOptions): Promise<SharedPlanView[]>;
    count(criteria: FindSharedPlansCriteria): Promise<ResourceCount>;
    save(plan: SharedProtectionPlan): Promise<void>;
    delete(id: string): Promise<void>;
    configure(planId: string, shares: SharedPlanShare[]): Promise<void>;
}

/** Fake implementation — stores plans in localStorage. Use in dev/demo environments. */
declare class FakeSharedProtectionPlanRepository extends APIRepository implements SharedProtectionPlanRepository {
    private storage;
    constructor(props: APIRepositoryProps);
    findById(id: string): Promise<SharedProtectionPlan | null>;
    findAll(): Promise<SharedProtectionPlanSummary[]>;
    findByCriteria(criteria: FindSharedPlansCriteria): Promise<SharedProtectionPlanSummary[]>;
    count(criteria: FindSharedPlansCriteria): Promise<{
        count: number;
    }>;
    save(plan: SharedProtectionPlan): Promise<void>;
    delete(id: string): Promise<void>;
    configure(planId: string, shares: SharedPlanShare[]): Promise<void>;
}

interface RevealSharedPlanDataInput {
    dataShares: string[];
    keyShares: string[];
    threshold: number;
    planId: string;
}
declare class RevealSharedPlanDataUseCase {
    private readonly revealer;
    private readonly planRepository;
    constructor(revealer: SharedPlanDataRevealer, planRepository: SharedProtectionPlanRepository);
    execute(input: RevealSharedPlanDataInput): Promise<DataAsset[] | null>;
}

interface MergeSharedProtectionPlanCallbacks {
    /**
     * Called once when the authentication step begins.
     * Convenience signal — the full method list and progress are on view.authenticationMethods.
     */
    onAuthenticationRequested?: () => void;
    /**
     * Called once when the permission step begins.
     * Convenience signal — the full moderator list and progress are on view.moderators.
     */
    onPermissionRequested?: () => void;
    /**
     * Called after each step/progress change.
     * The view carries all context: auth methods, moderators, progress, revealed assets.
     */
    onViewUpdate?: (view: SharedPlanMergeProcessView) => void;
    /** Called with the reconstructed assets when the process reaches REVEALED. Convenience — assets are also on view.revealedAssets. */
    onRevealed?: (assets: DataAsset[] | null) => void;
    onError?: (error: Error) => void;
}
interface MergeSharedProtectionPlanDeps {
    planRepository: SharedProtectionPlanRepository;
    mergeRepository: SharedMergingProcessRepository;
    revealUseCase: RevealSharedPlanDataUseCase;
    eventListener: SharedPlanEventListener;
}
declare class MergeSharedProtectionPlanUseCase {
    private readonly deps;
    private pendingAuthResolve;
    private pendingPermissionResolve;
    constructor(deps: MergeSharedProtectionPlanDeps);
    /**
     * Creates a new merge process for the given plan, registers it on the backend,
     * and persists it locally.
     * Returns a view pre-populated with the plan's auth methods and moderators.
     */
    initialize(planId: string): Promise<SharedPlanMergeProcessView>;
    /** Returns the current view for an existing process, or null if not found. */
    getView(processId: string): Promise<SharedPlanMergeProcessView | null>;
    /**
     * Run the orchestration from the process's current step.
     * Subscribes to plan events for the duration of the run and cleans up in a finally block.
     * All callbacks receive SharedPlanMergeProcessView — the internal domain model is never exposed.
     */
    run(processId: string, callbacks?: MergeSharedProtectionPlanCallbacks): Promise<void>;
    private runAuthenticationStep;
    private runPermissionStep;
    private runShareCollectionStep;
    private resolveInitialStep;
}

declare class GetSharedMergingProcessUseCase {
    private readonly mergeRepository;
    constructor(mergeRepository: SharedMergingProcessRepository);
    execute(processId: string): Promise<SharedPlanMergeProcessView | null>;
}

declare function useCreateSharedProtectionPlan(): {
    create: {
        execute: (input: CreateSharedProtectionPlanInput) => any;
        loading: boolean;
        data: any;
        error: any;
    };
};

declare function useGetSharedProtectionPlan(planId: string | undefined, options?: QueryOptions): {
    error?: any;
    isIdle: boolean;
    loading: boolean;
    loaded: boolean;
    refetch: any;
    isFetching: boolean;
    isRefetching: boolean;
    data?: SharedProtectionPlan | undefined;
};

declare function useFindSharedProtectionPlansByCriteria(criteria?: FindSharedPlansCriteria, pagination?: PaginationOptions, sort?: SortOptions, options?: QueryOptions): UseGetListValue<SharedPlanView>;

declare function useCountSharedProtectionPlans(criteria?: FindSharedPlansCriteria, options?: QueryOptions): Omit<UseQueryValue<any>, "data"> & {
    data?: ResourceCount;
};

type ConfigureStatus = 'idle' | 'running' | 'done' | 'error';
declare function useConfigureSharedProtectionPlan(planId?: string): {
    configure: {
        execute: (input: Omit<ConfigureSharedProtectionPlanInput, "planId">) => Promise<void>;
        loading: boolean;
        error: string | undefined;
    };
    retry: {
        execute: (input: Omit<ConfigureSharedProtectionPlanInput, "planId">) => Promise<void>;
    };
    reset: {
        execute: () => Promise<void>;
    };
    process: SharedPlanConfigurationProcess | null;
    status: ConfigureStatus;
    isRunning: boolean;
    isDone: boolean;
    hasError: boolean;
    error: string | undefined;
};

type MergeStatus = 'idle' | 'initializing' | 'running' | 'done' | 'error';
declare function useMergeSharedProtectionPlan(planId?: string): {
    start: {
        execute: () => Promise<void>;
        loading: boolean;
        error: string | undefined;
    };
    retry: {
        execute: () => Promise<void>;
    };
    process: SharedPlanMergeProcessView;
    status: MergeStatus;
    isRunning: boolean;
    isDone: boolean;
    hasError: boolean;
    error: string | undefined;
};

export { AppSharedConfigurationProcessRepository, AppSharedMergingProcessRepository, AppSharedProtectionPlanRepository, ConfigureSharedProtectionPlanUseCase, CountSharedProtectionPlansUseCase, CreateSharedProtectionPlanUseCase, DeleteSharedPlanConfigurationProcessUseCase, DistributeSharesUseCase, FakeSharedProtectionPlanRepository, FindSharedProtectionPlansByCriteriaUseCase, GenerateSharesUseCase, GetSharedMergingProcessUseCase, GetSharedPlanConfigurationProcessUseCase, GetSharedProtectionPlanUseCase, MergeSharedProtectionPlanUseCase, RevealSharedPlanDataUseCase, SharedPlanAuthenticationMethod, SharedPlanConfigurationProcess, SharedPlanMergeProcessView, SharedPlanModerator, SharedPlanShare, SharedProtectionPlan, SharedProtectionPlanModule, SharedProtectionPlanSummary, SharedProtectionPlanView, SocketIoSharedPlanEventListener, SsdpPlusSharedPlanDataRevealer, SsdpPlusSharedPlanSharesGenerator, useConfigureSharedProtectionPlan, useCountSharedProtectionPlans, useCreateSharedProtectionPlan, useFindSharedProtectionPlansByCriteria, useGetSharedProtectionPlan, useMergeSharedProtectionPlan };
export type { AuthMethodType, AuthMethodView, CollectedShare, ConfigureSharedProtectionPlanCallbacks, ConfigureSharedProtectionPlanDeps, ConfigureSharedProtectionPlanInput, CreateSharedProtectionPlanInput, FindSharedPlansCriteria, GenerateSharesInput, MergeSharedProtectionPlanCallbacks, MergeSharedProtectionPlanDeps, ModeratorView, RevealSharedPlanDataInput, SharedConfigurationProcessRepository, SharedMergeStatus, SharedMergingProcessRepository, SharedPlanConfigurationStepId, SharedPlanDataRevealer, SharedPlanEventHandlers, SharedPlanEventListener, SharedPlanMergeStep, SharedPlanSharesGenerator, SharedPlanSharesGeneratorResult, SharedPlanStorageLayer, SharedProtectionPlanProps, SharedProtectionPlanRepository };
