// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.12.0.

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

import '../frb_generated.dart';
import 'error.dart';
import 'media_files.dart';

// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `fmt`, `from`

/// Saves a draft for the given account and group.
///
/// Uses upsert semantics: creates a new draft or updates the existing one.
/// Only one draft is stored per (account, group) pair.
Future<Draft> saveDraft({
  required String pubkey,
  required String groupId,
  required String content,
  String? replyToId,
  required List<MediaFile> mediaAttachments,
}) => RustLib.instance.api.crateApiDraftsSaveDraft(
  pubkey: pubkey,
  groupId: groupId,
  content: content,
  replyToId: replyToId,
  mediaAttachments: mediaAttachments,
);

/// Loads the draft for the given account and group, if one exists.
Future<Draft?> loadDraft({required String pubkey, required String groupId}) =>
    RustLib.instance.api.crateApiDraftsLoadDraft(
      pubkey: pubkey,
      groupId: groupId,
    );

/// Deletes the draft for the given account and group.
///
/// No-op if no draft exists.
Future<void> deleteDraft({required String pubkey, required String groupId}) =>
    RustLib.instance.api.crateApiDraftsDeleteDraft(
      pubkey: pubkey,
      groupId: groupId,
    );

/// Flutter-compatible draft message for a specific group.
///
/// Drafts preserve unsent message state (text content and reply context)
/// scoped to an account and group. Only one draft exists per (account, group) pair.
class Draft {
  final String accountPubkey;
  final String mlsGroupId;
  final String content;
  final String? replyToId;
  final List<MediaFile> mediaAttachments;
  final DateTime createdAt;
  final DateTime updatedAt;

  const Draft({
    required this.accountPubkey,
    required this.mlsGroupId,
    required this.content,
    this.replyToId,
    required this.mediaAttachments,
    required this.createdAt,
    required this.updatedAt,
  });

  @override
  int get hashCode =>
      accountPubkey.hashCode ^
      mlsGroupId.hashCode ^
      content.hashCode ^
      replyToId.hashCode ^
      mediaAttachments.hashCode ^
      createdAt.hashCode ^
      updatedAt.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is Draft &&
          runtimeType == other.runtimeType &&
          accountPubkey == other.accountPubkey &&
          mlsGroupId == other.mlsGroupId &&
          content == other.content &&
          replyToId == other.replyToId &&
          mediaAttachments == other.mediaAttachments &&
          createdAt == other.createdAt &&
          updatedAt == other.updatedAt;
}
