import { Mark } from './mark'
import { Keys } from '../store/auth/types'
import { Event } from 'nostr-tools'

export enum UserRole {
  signer = 'Signer',
  viewer = 'Viewer'
}

export interface User {
  pubkey: string
  role: UserRole
}

export interface Meta {
  modifiedAt: number
  createSignature: string
  docSignatures: { [key: `npub1${string}`]: string }
  exportSignature?: string
  keys?: { sender: string; keys: { [user: `npub1${string}`]: string } }
  timestamps?: Timestamp[]
}

export interface CreateSignatureEventContent {
  signers: `npub1${string}`[]
  viewers: `npub1${string}`[]
  fileHashes: { [key: string]: string }
  markConfig: Mark[]
  title: string
  zipUrl: string
}

export interface SignedEventContent {
  prevSig: string
  marks: Mark[]
}

export interface Sigit {
  fileUrl: string
  meta: Meta
}

export interface Timestamp {
  nostrId: string
  timestamp: string
}

export interface UserAppData {
  sigits: { [key: string]: Meta } // key will be id of create signature
  processedGiftWraps: string[] // an array of ids of processed gift wrapped events
  keyPair?: Keys // this key pair is used for blossom requests authentication
  blossomUrls: string[] // array for storing Urls for the files that stores all the sigits and processedGiftWraps on blossom
}

export interface DocSignatureEvent extends Event {
  parsedContent?: SignedEventContent
}
