export interface AdminCloudtentaclesSourceItem {
  key: string
  label: string
  enabled: boolean
  baseUrl: string
  username: string
  password: string
  phone: string
  deviceId: string
  deviceType: number
}

export interface AdminCloudtentaclesSourcesConfig {
  enabled: boolean
  sources: AdminCloudtentaclesSourceItem[]
}

export interface AdminCloudtentaclesPersistedSession {
  token: string
  tokenMasked: string
  baseUrl: string
  username: string
  phoneMasked: string
  loggedInAt: string
  deviceId: string
  deviceType: number
  hasToken: boolean
}

export type AdminCloudtentaclesSessionItem = AdminCloudtentaclesPersistedSession

export interface AdminCloudtentaclesSessionsMap {
  [sourceKey: string]: AdminCloudtentaclesPersistedSession
}

export interface AdminCloudtentaclesSourceConfigResponse {
  filePath: string
  sessionFilePath: string
  enabled: boolean
  sources: AdminCloudtentaclesSourceItem[]
  sessions: AdminCloudtentaclesSessionsMap
}

export interface AdminCloudtentaclesOverrideDeliveryItem {
  cloudSkuId: number
  cloudSkuName: string
  quantity: number
}

export interface AdminCloudtentaclesOverrideRule {
  id: string
  enabled: boolean
  productName: string
  normalizedProductName: string
  sourceKey: string
  deliveryItems: AdminCloudtentaclesOverrideDeliveryItem[]
  notes: string
}

export interface AdminCloudtentaclesOverrideRuleConfig {
  filePath: string
  enabled: boolean
  rules: AdminCloudtentaclesOverrideRule[]
}

export interface AdminCloudtentaclesSendSmsResult {
  baseUrl: string
  username: string
  phone: string
  phoneMasked: string
  sentAt: string
  responseMessage: string
}

export interface AdminCloudtentaclesSessionSummary {
  tokenMasked: string
  permissionCount: number
  permissions: string[]
  persisted?: boolean
}

export interface AdminCloudtentaclesLoginTestResult {
  baseUrl: string
  username: string
  phoneMasked: string
  loggedInAt: string
  responseMessage: string
  token: string
  session: AdminCloudtentaclesSessionSummary
  userInfo: Record<string, unknown>
  asset: number
}

export interface AdminCloudtentaclesValidateSessionResult {
  baseUrl: string
  loggedInAt: string
  session: AdminCloudtentaclesSessionSummary
  userInfo: Record<string, unknown>
  asset: number
}

export interface AdminCloudtentaclesSkuItem {
  id: number
  categoriesId: number
  name: string
  description: string
  image: string
  inventory: number
  price: number
  listingTime: string
  delistingTime: string
  buyLimitMin: number
  buyLimitMax: number
  raw: Record<string, unknown>
}

export interface AdminCloudtentaclesSkuListResult {
  baseUrl: string
  itemCount: number
  occupiedItemCount: number
  items: AdminCloudtentaclesSkuItem[]
  rawItems: Record<string, unknown>[]
}

export interface AdminCloudtentaclesDeliveryRecordItem {
  createdAt: string
  recordId: string
  virtualNumberId: number
  userId: number
  count: number
  cdk: string
  exchangeUrl: string
  name: string
  skuId: number
  skuName: string
  skuImage: string
  phone: string
  status: number
  fulfillUser: string
  operatorName: string
  platformOrderId: string
  taskId: number
  taskNo: string
  orderShopId: string
  orderShopName: string
  consumeShopId: string
  consumeShopName: string
  roleName: string
  roleId: string
  localTaskStatus: string
  localDeliveryStatus: string
  localDispatchStatus: string
  localDispatchAt: string
  localResultCode: string
  localResultMessage: string
  matchConfidence: string
  raw: Record<string, unknown>
}

export interface AdminCloudtentaclesDeliveryRecordListResult {
  baseUrl: string
  page: number
  size: number
  total: number
  sourceKey?: string
  queryStartDate?: string
  queryEndDate?: string
  localOrderMatched?: boolean
  items: AdminCloudtentaclesDeliveryRecordItem[]
  raw: Record<string, unknown>
}

/** @deprecated Use AdminCloudtentaclesSourceItem + AdminCloudtentaclesSourcesConfig instead */
export interface AdminCloudtentaclesSourceConfig {
  enabled: boolean
  baseUrl: string
  username: string
  password: string
  phone: string
  deviceId: string
  deviceType: number
}

export interface AdminCloudtentaclesVnListItem {
  id: number
  phone: string
  status: number
  countTime: number
  bindInfo: string | Record<string, unknown> | null
  raw: Record<string, unknown>
}

export interface AdminCloudtentaclesVnListResult {
  baseUrl: string
  key: string
  itemCount: number
  items: AdminCloudtentaclesVnListItem[]
  rawItems: Array<Record<string, unknown>>
}
