import { IKosIdentifiable, IKosModelHolder, PublicModelInterface } from '../../../core';
import { IKosModelContainer } from '../../../core/core/kos-container-model';
import { IKosDataModel, KosCreationContext } from '../../../core/core/kosModel';
import { StorageDeviceResponse } from './services';
import { StorageDeviceModel } from './storage-device-model';
import { StorageDeviceContainerOptions } from './types';
export declare const MODEL_TYPE = "storage-device-container-model";
export declare const TOPIC_STORAGE_AVAILABILITY = "/kos/storage";
/**
 * StorageDeviceContainer - Manages collections of storage devices with real-time discovery.
 *
 * The StorageDeviceContainer model provides centralized management of multiple storage devices
 * connected to KOS systems. It automatically discovers devices through REST API calls and
 * maintains real-time synchronization via WebSocket topics, handling device insertion,
 * removal, and state updates across the entire storage ecosystem.
 *
 * ## Key Features
 * - **Automatic Device Discovery** - Scans and loads all available storage devices
 * - **Real-time Synchronization** - WebSocket updates for insertion/removal events
 * - **Collection Management** - Add, remove, and query storage device collections
 * - **Availability Monitoring** - Track overall storage availability status
 * - **Volume Access** - Direct access to managed storage device instances
 * - **Parent-Child Architecture** - Proper lifecycle management for contained devices
 *
 * ## Topic-Based Reactivity
 * The model listens to these KOS topics for real-time synchronization:
 * - **`/kos/storage`** - Storage device availability changes (insertion/removal events)
 *   - Payload: `StorageDeviceResponse[]` - Array of current storage device states
 *   - Triggers automatic model updates, additions, and removals
 *   - Handles both physical device changes and mount/unmount operations
 *
 * ## Storage Management Operations
 * The container provides comprehensive storage device management:
 * - **Device Lifecycle**: Automatic creation and cleanup of StorageDevice models
 * - **State Synchronization**: Real-time updates from system storage changes
 * - **Collection Queries**: Access devices by ID, status, or availability
 * - **Volume Tracking**: Monitor mounted and available storage volumes
 *
 * ## Common Use Cases
 * - **Storage Management Dashboard** - Display all connected storage devices
 * - **File Transfer Interface** - Select available storage for operations
 * - **System Monitoring** - Track storage availability and health
 * - **Backup Management** - Identify backup destination devices
 * - **Multi-node Storage** - Manage distributed storage across KOS nodes
 * - **Device Diagnostics** - Monitor storage device runtime and status
 *
 * @example Basic Storage Container Usage
 * ```typescript
 * // Create storage device container for system management
 * const storageContainer = StorageDeviceContainer.instance('main-storage')
 *   .options({}) // Empty configuration - behavior driven by discovery
 *   .build();
 *
 * // Check overall storage availability
 * console.log(`Storage available: ${storageContainer.isStorageInserted}`);
 * console.log(`Total volumes: ${storageContainer.volumes.length}`);
 *
 * // Access individual storage devices
 * const usbDevice = storageContainer.getModel('usb-drive-1');
 * if (usbDevice && !usbDevice.removed) {
 *   console.log(`USB device mounted at: ${usbDevice.mountDir}`);
 * }
 * ```
 *
 * @example Storage Device Discovery and Management
 * ```typescript
 * // Container automatically handles device discovery
 * const storageManager = StorageDeviceContainer.instance('storage-mgr')
 *   .options({})
 *   .build();
 *
 * // Monitor storage changes with reactive patterns
 * const monitorStorageChanges = () => {
 *   // Container automatically updates via /kos/storage topic
 *   const availableDevices = storageManager.data.filter(device =>
 *     !device.removed && device.mountDir
 *   );
 *
 *   const localDevices = availableDevices.filter(device => device.local);
 *   const remoteDevices = availableDevices.filter(device => !device.local);
 *
 *   console.log(`Available storage: ${availableDevices.length} devices`);
 *   console.log(`Local: ${localDevices.length}, Remote: ${remoteDevices.length}`);
 *
 *   return {
 *     total: availableDevices.length,
 *     local: localDevices.length,
 *     remote: remoteDevices.length,
 *     devices: availableDevices
 *   };
 * };
 * ```
 *
 * @example React Storage Management Interface
 * ```typescript
 * const StorageManagerComponent: React.FC = kosComponent(() => {
 *   const storageContainer = useModel(StorageDeviceContainer, 'storage-manager');
 *
 *   // Reactive data automatically updates via WebSocket
 *   const availableDevices = storageContainer.volumes.filter(device =>
 *     !device.removed && device.mountDir
 *   );
 *
 *   const removedDevices = storageContainer.volumes.filter(device =>
 *     device.removed
 *   );
 *
 *   return (
 *     <div className="storage-manager">
 *       <div className="storage-status">
 *         <h2>Storage Overview</h2>
 *         <div className="status-indicator">
 *           <span className={storageContainer.isStorageInserted ? 'online' : 'offline'}>
 *             {storageContainer.isStorageInserted ? 'Storage Available' : 'No Storage'}
 *           </span>
 *         </div>
 *         <div className="device-count">
 *           Total Devices: {storageContainer.volumes.length}
 *         </div>
 *       </div>
 *
 *       <div className="device-sections">
 *         <section className="available-devices">
 *           <h3>Available Storage ({availableDevices.length})</h3>
 *           {availableDevices.map(device => (
 *             <StorageDeviceCard key={device.id} device={device} />
 *           ))}
 *         </section>
 *
 *         {removedDevices.length > 0 && (
 *           <section className="removed-devices">
 *             <h3>Recently Removed ({removedDevices.length})</h3>
 *             {removedDevices.map(device => (
 *               <StorageDeviceCard key={device.id} device={device} />
 *             ))}
 *           </section>
 *         )}
 *       </div>
 *     </div>
 *   );
 * });
 * ```
 *
 * @example Storage Device Filtering and Queries
 * ```typescript
 * // Create storage container for advanced device management
 * const storageController = StorageDeviceContainer.instance('storage-ctrl')
 *   .options({})
 *   .build();
 *
 * // Helper functions for device filtering
 * const getStorageQueries = (container: StorageDeviceContainer) => ({
 *   // Get all available (mounted and not removed) devices
 *   getAvailableDevices: () =>
 *     container.data.filter(device => !device.removed && device.mountDir),
 *
 *   // Get devices by specific node
 *   getDevicesByNode: (nodeId: string) =>
 *     container.data.filter(device => device.nodeId === nodeId),
 *
 *   // Get local vs remote devices
 *   getLocalDevices: () =>
 *     container.data.filter(device => device.local),
 *
 *   // Get devices by vendor
 *   getDevicesByVendor: (vendor: string) =>
 *     container.data.filter(device =>
 *       device.vendor.toLowerCase().includes(vendor.toLowerCase())
 *     ),
 *
 *   // Get backup-suitable devices (available with sufficient runtime)
 *   getBackupDevices: () =>
 *     container.data.filter(device =>
 *       !device.removed &&
 *       device.mountDir &&
 *       device.runTimeMs > 300000 // More than 5 minutes runtime
 *     ),
 *
 *   // Get device statistics
 *   getStorageStats: () => {
 *     const devices = container.data;
 *     return {
 *       total: devices.length,
 *       available: devices.filter(d => !d.removed && d.mountDir).length,
 *       removed: devices.filter(d => d.removed).length,
 *       local: devices.filter(d => d.local).length,
 *       remote: devices.filter(d => !d.local).length,
 *       averageRuntime: devices.reduce((sum, d) => sum + d.runTimeMs, 0) / devices.length
 *     };
 *   }
 * });
 *
 * // Usage examples
 * const queries = getStorageQueries(storageController);
 *
 * console.log('Storage Statistics:', queries.getStorageStats());
 * console.log('Available Devices:', queries.getAvailableDevices().length);
 * console.log('Backup-Ready Devices:', queries.getBackupDevices().length);
 * ```
 *
 * @example WebSocket Topic Synchronization
 * ```typescript
 * // The container automatically handles /kos/storage topic updates
 * const storageSync = StorageDeviceContainer.instance('sync-demo')
 *   .options({})
 *   .build();
 *
 * // Topic payload structure: StorageDeviceResponse[]
 * // Example payload when device is inserted:
 * // [
 * //   {
 * //     id: "usb-drive-new",
 * //     mountDir: "/media/usb-new",
 * //     vendor: "Kingston",
 * //     model: "DataTraveler",
 * //     label: "KINGSTON_32GB",
 * //     nodeId: "primary",
 * //     local: true,
 * //     removed: false,
 * //     runTimeMs: 0,
 * //     syspath: "/sys/devices/usb/new"
 * //   }
 * // ]
 *
 * // Container automatically:
 * // 1. Compares payload with existing models
 * // 2. Removes models not in payload (device unplugged)
 * // 3. Updates existing models with new state
 * // 4. Creates new models for discovered devices
 * // 5. Maintains parent-child relationships
 *
 * // Monitor changes reactively
 * const logStorageChanges = () => {
 *   const currentDevices = storageSync.data.map(device => ({
 *     id: device.id,
 *     vendor: device.vendor,
 *     mounted: !!device.mountDir,
 *     removed: device.removed
 *   }));
 *
 *   console.log('Current Storage State:', currentDevices);
 * };
 * ```
 *
 * @example Multi-Node Storage Architecture
 * ```typescript
 * // Container manages storage across distributed KOS nodes
 * const distributedStorage = StorageDeviceContainer.instance('distributed')
 *   .options({})
 *   .build();
 *
 * // Analyze storage distribution across nodes
 * const analyzeStorageDistribution = () => {
 *   const nodeGroups = distributedStorage.data.reduce((groups, device) => {
 *     const nodeId = device.nodeId;
 *     if (!groups[nodeId]) {
 *       groups[nodeId] = {
 *         nodeId,
 *         devices: [],
 *         available: 0,
 *         totalRuntime: 0
 *       };
 *     }
 *
 *     groups[nodeId].devices.push(device);
 *     if (!device.removed && device.mountDir) {
 *       groups[nodeId].available++;
 *     }
 *     groups[nodeId].totalRuntime += device.runTimeMs;
 *
 *     return groups;
 *   }, {} as Record<string, any>);
 *
 *   // Display node distribution
 *   Object.values(nodeGroups).forEach((node: any) => {
 *     const avgRuntime = node.totalRuntime / node.devices.length;
 *     console.log(`Node ${node.nodeId}:`);
 *     console.log(`  Devices: ${node.devices.length}`);
 *     console.log(`  Available: ${node.available}`);
 *     console.log(`  Avg Runtime: ${Math.round(avgRuntime / 60000)}min`);
 *   });
 *
 *   return nodeGroups;
 * };
 * ```
 *
 * @group KOS Model
 * @category Device Management
 *
 * @see {@link StorageDevice} - Individual storage device model
 * @see {@link StorageDeviceOptions} - Configuration options for storage devices
 * @see {@link StorageDeviceContainerOptions} - Container configuration options
 * @see {@link StorageDeviceResponse} - API response structure for device discovery
 */
export type StorageDeviceContainer = PublicModelInterface<StorageDeviceContainerModelImpl>;
export type StorageDeviceContainerModel = PublicModelInterface<StorageDeviceContainerModelImpl>;
/**
 * @ignore
 * @internal
 */
export declare class StorageDeviceContainerModelImpl implements IKosIdentifiable, IKosModelHolder<StorageDeviceModel>, IKosDataModel {
    id: string;
    private logger;
    private _models;
    constructor(modelId: string, options: StorageDeviceContainerOptions, context: KosCreationContext);
    getModel(id: string): StorageDeviceModel | undefined;
    get models(): IKosModelContainer<StorageDeviceModel>;
    get data(): StorageDeviceModel[];
    addModel(model: StorageDeviceModel): void;
    removeModel(id: string): void;
    init(): Promise<void>;
    get isStorageInserted(): boolean;
    get volumes(): StorageDeviceModel[];
    handleStorageAvailability(devices: StorageDeviceResponse[]): void;
    load(): Promise<void>;
}
//# sourceMappingURL=storage-device-container-model.d.ts.map