const protocol = location.protocol
const host = process.env.VUE_APP_GATEWAY || location.host

export const GATEWAY = `${protocol}//${host}`

export const GATEWAY_WS = `${protocol === 'https:' ? 'wss:' : 'ws:'}//${host}`

export const GATEWAY_CAMERA = `${GATEWAY_WS}${process.env.VUE_APP_CAMERA_PROXY}`

export const AssetType = {
  IMAGE: 1,
  VIDEO: 2,
  AUDIO: 3,
  PPT: 4,
  PDF: 5,
  DOC: 6
}

export const Role = {
  SUPER_ADMIN: 'ROLE_SUPER_ADMIN',
  ADMIN: 'ROLE_ADMIN',
  SUPERVISOR: 'ROLE_OPERATION_SUPERVISOR',
  STAFF: 'ROLE_OPERATION_STAFF',
  VISITOR: '__ROLE_VISITOR__'
}

export const State = {
  DRAFT: -1,
  READY: 0,
  SUBMITTED: 1,
  RESOLVED: 2,
  REJECTED: 3,
  CANCEL: 7,
  // 占位值
  REVIEW: 99,
  AVAILABLE: 100,
  AVAILABLE_ASSET: 101
}

export const ScheduleType = {
  RECUR: 2,
  COMPLEX: 3
}

export const PublishType = {
  CALENDAR: 1,
  EVENT: 2
}

export const EventPriority = {
  DEFAULT: 1,
  NORMAL: 2,
  INSERTED: 3
}

export const EventFreq = {
  ONCE: 'ONCE',
  WEEKLY: 'WEEKLY'
}

export const EventTarget = {
  PROGRAM: 1,
  RECUR: 2
}

export const ThirdPartyDevice = {
  GATEWAY: 0,
  RECEIVING_CARD: 1,
  SENDING_CARD: 2,
  SCREEN: 3,
  LED_CAMERA: 4,
  TRAFFIC_CAMERA: 5,
  PLC: 6
}

export const Camera = {
  LED: 1,
  TRAFFIC: 2
}

export const Transmitter = {
  IS_ASYNC: 1,
  SUPPORT_DETECTION: 1 << 1,
  SUPPORT_CONTENT_PROTECTION: 1 << 2,
  RECOVERY_CARD: 1 << 3
}

export const Access = {
  // backend
  MANAGE_TENANTS: 'manange-tenants',
  MANAGE_TENANT: 'manange-tenant',
  MANAGE_GROUP: 'manage-group',
  MANAGE_DEVICE: 'manage-device',
  MANAGE_CALENDAR: 'manage-calendar',
  VIEW_LOGS: 'view-logs'
}

export const RoleAccess = {
  [Role.SUPER_ADMIN]: [
    Access.MANAGE_TENANTS,
    Access.MANAGE_DEVICE,
    Access.MANAGE_CALENDAR,
    Access.MANAGE_GROUP,
    Access.VIEW_LOGS
  ],
  [Role.ADMIN]: [
    Access.MANAGE_TENANT,
    Access.MANAGE_DEVICE,
    Access.MANAGE_CALENDAR,
    Access.MANAGE_GROUP,
    Access.VIEW_LOGS
  ],
  [Role.SUPERVISOR]: [
    Access.MANAGE_DEVICE,
    Access.MANAGE_GROUP,
    Access.VIEW_LOGS
  ],
  [Role.STAFF]: [
    Access.MANAGE_DEVICE,
    Access.MANAGE_CALENDAR,
    Access.VIEW_LOGS
  ],
  [Role.VISITOR]: [
  ]
}

export const AlarmStrategy = {
  note: '短信',
  email: '邮件',
  wechat: '微信',
  wechatApplet: '小程序'
}

export const AlarmStrategies = ['note', 'email', 'wechat', 'wechatApplet']

export const AlarmType = {
  0: '疑似黑屏',
  1: '设备离线',
  2: '屏幕拓扑结构异常',
  3: '播放非法视频',
  4: '接收卡离线',
  5: '发送控制设备离线',
  6: '浪潮智能网关离线',
  7: '屏幕监控摄像头离线',
  8: '人流监测摄像头离线',
  9: '设备上线',
  10: '回采疑似',
  11: '回采不合规',
  12: '空档期',
  1000: '分割器异常'
}
