import { ResourceType } from "src/app/components/resources-sidebar/sidebar-data";
import { RoomData } from "../room.service";
import { AccountAvatarRecord } from "./account-records";
import { WorkspaceQueryDialogueRecord } from "./workspace-records";

export interface RawRoomRecord {
  /**
   * encrypted: Uint8Array,
   * decrypted: roomDataQueryDataRecord
   */
  data: Uint8Array | RoomData;
  id: string;
  nanoSessions: { [key: string]: number };
  ownerAccountId: string;
  pinnedKey: Uint8Array;
  savedKey?: Uint8Array;
  topMessageId: string | null;
  seenMessageId: string;
  type: ResourceType;
  ordering: number | null;
  inaccessible?: boolean;
  ignore?: boolean;
}

export interface RoomRecord extends RawRoomRecord {
  error: boolean | null;
  errorMessage: string;
  public: boolean;
}

export interface DialogueDataRecord extends WorkspaceQueryDialogueRecord {}

export interface MessageRecord {
  id;
  posterId;
  content: string;
  edited: boolean;
  error?: boolean;
  errorMessage?: string;
}

export interface roomConfigRecord {
  block: Uint8Array;
  id: string;
  signature: Uint8Array;
}

export interface RoomMemberRecord {
  accounts: RoomMemberAccountRecord[];
  id: string;
  ownerAccountId: string;
}

export interface RoomMemberAccountRecord {
  administrator: boolean;
  id: string;
  msgBrdModerate: null | boolean;
}

export interface RoomPermissionRecord {
  accounts: RoomPermissionAccountRecord[];
  maxMembers: number;
  id: string;
  msgBrdReadOnly: null | boolean;
  ownerAccountId: string;
}

export interface RoomPermissionAccountRecord {
  id: string;
  rejected: null | boolean;
  msgBrdModerate: null | boolean;
}

export interface RoomMyPermissionAccountRecord {
  driveAdhoc: boolean;
  driveWrite: boolean;
  administrator: boolean;
  id: string;
  msgBrdModerate: null | boolean;
  driveUpload: boolean;
}

export interface RoomMyPermissionRecord {
  account?: RoomMyPermissionAccountRecord;
  allowAnonymous: boolean;
  id: string;
  msgBrdReadOnly: null | boolean; // TODO def
  ownerAccountId: string;
}
