import { IKosDataModel, IKosIdentifiable, KosCreationContext, KosData, PublicModelInterface } from '../../../core';
import { KeyValueUpdate } from './services';
import { KeyValueOptions } from './types';
export declare const MODEL_TYPE = "key-value-model";
/**
 * Key-Value Model - Persistent, reactive state storage with real-time synchronization across KOS applications.
 *
 * This model provides a namespaced key-value store that automatically persists data and synchronizes
 * changes across all connected clients in real-time. Perfect for storing user preferences, application
 * state, feature flags, or any data that needs to persist between sessions and sync across instances.
 *
 * ## Key Features
 * - **Persistent Storage** - Data survives application restarts and browser refreshes
 * - **Real-time Synchronization** - Changes propagate instantly to all connected clients
 * - **Namespace Isolation** - Multiple stores can coexist without key collisions
 * - **Type-Safe Values** - Supports string, number, boolean, and undefined types
 * - **Reactive Updates** - Automatic UI updates when values change (locally or remotely)
 * - **Topic-Based Sync** - Uses KOS event system for distributed state management
 *
 * ## Topic-Based Reactivity
 * The model listens to two KOS topics for real-time synchronization:
 * - **`/keyVal/set`** - Fired when any key-value pair is updated or added
 * - **`/keyVal/remove`** - Fired when a key is deleted from the store
 *
 * These topics ensure that all instances of the model with the same namespace stay
 * synchronized across browser tabs, windows, and even different client applications.
 * The model automatically filters events by namespace to ensure isolation.
 *
 * @interface
 *
 * @example Basic Usage
 * ```typescript
 * const preferences = KeyValue.instance('user-prefs')
 *   .options({ namespace: 'preferences' })
 *   .build();
 *
 * // Store values
 * await preferences.updateState('theme', 'dark');
 * await preferences.updateState('fontSize', 14);
 *
 * // Access reactive data
 * console.log(preferences.data.theme);     // 'dark'
 * console.log(preferences.data.fontSize);  // 14
 * ```
 *
 * @example React Integration
 * ```typescript
 * const UserSettings: React.FC = kosComponent(() => {
 *   const settings = useModel(KeyValue, 'app-settings');
 *
 *   return (
 *     <div>
 *       <p>Theme: {settings.data.theme || 'light'}</p>
 *       <button onClick={() => settings.updateState('theme', 'dark')}>
 *         Set Dark Theme
 *       </button>
 *     </div>
 *   );
 * });
 * ```
 *
 * @group KOS Model
 * @category State Management
 * @category Key-Value Store
 * @useDeclaredType
 * @see {@link KeyValueOptions} - Configuration options for key-value stores
 * @see {@link KeyValueUpdate} - Update event structure for synchronization
 */
export type KeyValueModel = PublicModelInterface<KeyValueModelImpl>;
/**
 * @ignore
 * @internal
 */
export declare class KeyValueModelImpl implements IKosDataModel, IKosIdentifiable {
    id: string;
    private logger;
    private namespace;
    data: KosData<Record<string, string | number | boolean | undefined>>;
    constructor(modelId: string, options: KeyValueOptions, context: KosCreationContext);
    /**
     * @internal
     */
    init(): Promise<void>;
    /**
     * Update or delete a key-value pair in the store.
     *
     * Changes are automatically persisted and synchronized across all instances
     * with the same namespace via KOS topics.
     *
     * @param key - The key to update or delete
     * @param value - The value to set (string | number | boolean), or undefined to delete the key
     * @returns Promise that resolves when the operation completes
     *
     * @example
     * ```typescript
     * // Set a value
     * await keyValue.updateState('theme', 'dark');
     *
     * // Delete a key
     * await keyValue.updateState('theme', undefined);
     * ```
     */
    updateState(key: string, value: string | number | boolean | undefined): Promise<void>;
    /**
     * Load initial data from persistent storage.
     *
     * @internal
     */
    load(): Promise<void>;
    /**
     * Topic handler for `/keyVal/set` events to sync updates across instances.
     *
     * Automatically called when any KeyValue model instance updates a value,
     * ensuring all instances with the same namespace stay synchronized.
     *
     * @param update - The key-value update event containing namespace, key, and new value
     */
    handleStateUpdate(update: KeyValueUpdate): void;
    /**
     * Topic handler for `/keyVal/remove` events to sync deletions across instances.
     *
     * Automatically called when any KeyValue model instance deletes a key,
     * ensuring all instances with the same namespace stay synchronized.
     *
     * @param update - The key-value update event containing namespace and deleted key
     */
    handleStateDelete(update: KeyValueUpdate): void;
}
//# sourceMappingURL=key-value-model.d.ts.map