import 'package:equatable/equatable.dart';
import 'dart:typed_data';

enum FileType { folder, file }

class FileItem extends Equatable {
  final String? id;
  final String name;
  final String path;
  final FileType type;
  final int size; // in bytes, 0 for folders
  final DateTime lastModified;
  final String? localPath; // optional local file path for uploads
  final Uint8List? bytes; // optional file bytes for web/desktop uploads

  const FileItem({
    this.id,
    required this.name,
    required this.path,
    required this.type,
    this.size = 0,
    required this.lastModified,
    this.localPath,
    this.bytes,
  });

  @override
  List<Object?> get props => [id, name, path, type, size, lastModified];

  FileItem copyWith({
    String? id,
    String? name,
    String? path,
    FileType? type,
    int? size,
    DateTime? lastModified,
  }) {
    return FileItem(
      id: id ?? this.id,
      name: name ?? this.name,
      path: path ?? this.path,
      type: type ?? this.type,
      size: size ?? this.size,
      lastModified: lastModified ?? this.lastModified,
    );
  }
}
