import PouchDB from '@/api/PouchDB'

import type {
  QRCodeDocument,
  MessageDocument,
  WebPushSubscriptionDocument,
  PublicSettingsDocument,
  UserChatSettingsDocument,
} from '@hereconnect/types'

export const qrCodeDbRemote = new PouchDB<QRCodeDocument>(`${import.meta.env.VITE_API_URL}/qr`, {
  skip_setup: true,
})

export const qrCodeDbLocal = new PouchDB<QRCodeDocument>('qr')

export const messagesDbLocal = new PouchDB<MessageDocument>('messages')

export const webPushSubscriptionsDbRemote = new PouchDB<
  WebPushSubscriptionDocument<PushSubscriptionJSON>
>(`${import.meta.env.VITE_API_URL}/web_push_subscriptions`, {
  skip_setup: true,
})

export const publicSettingsDbRemote = new PouchDB<PublicSettingsDocument>(
  `${import.meta.env.VITE_API_URL}/public_settings`,
  {
    skip_setup: true,
  },
)

export const messagesDbRemote = new PouchDB<MessageDocument>(
  `${import.meta.env.VITE_API_URL}/messages`,
  {
    skip_setup: true,
  },
)

export const userChatSettingsDbRemote = new PouchDB<UserChatSettingsDocument>(
  `${import.meta.env.VITE_API_URL}/user_chat_settings`,
  {
    skip_setup: true,
  },
)
