import { AreaMap, Centers, ColorMap, ColorSumItem } from "../../lib/filler/common/interfaces";

export enum FileDomain {
  org = 'org', // 原始线稿
  raw = 'raw',  // 矢量化线稿（可能是原始线稿，也可能是原始线稿(png/jpg)转出来的矢量线稿）
  page = 'page', //由raw生成
  map = 'map', //由raw生成
  rawColored = 'rawColored', //用来生成colorMap
  special = 'special',//彩绘稿
  specialThumb = 'specialThumb', //彩绘稿缩略图
  work = 'work', //由 colored or special 生成
  colorMap = 'colorMap',
  colorSum = 'colorSum',
  free = 'free', //自由上传
  centers = 'centers',
  //下面是暂时还没用到的
  //colorOrder = 'colorOrder',
  //centers = 'centers',
  //numberConfig = 'numberConfig',
}

export interface DomainConfig {
  name : string;
  accept : string;
  acceptText : string;
}

export const domainConfigs:  {[key : string] : DomainConfig} = {};
domainConfigs[FileDomain.raw] = { name : $localize`线稿(必选)自动转svg`, acceptText: 'svg/png/jpeg', accept : 'image/svg+xml,image/png,image/jpeg, image/jpg' }
domainConfigs[FileDomain.rawColored] = { name :$localize`上色稿(可选)`, acceptText: 'png/jpeg', accept : 'image/png,image/jpeg,image/jpg' }
// domainConfigs[FileDomain.special] = { name :$localize`彩绘稿(可选)`, acceptText: 'png/jpeg', accept : 'image/png,image/jpeg,image/jpg' }
domainConfigs[FileDomain.special] = { name :$localize`彩绘稿(可选)`, acceptText: 'png', accept : 'image/png' }
domainConfigs[FileDomain.specialThumb] = { name :$localize`彩绘稿缩略图(可选)`, acceptText: 'png/jpeg', accept : 'image/png,image/jpeg,image/jpg'}
domainConfigs[FileDomain.free] = { name :$localize`线稿`, acceptText: 'png/jpeg', accept : 'image/png,image/jpeg,image/jpg' }



export enum FileType {
  svg = 'image/svg+xml',
  png = 'image/png',
  jpeg = 'image/jpeg',
}

export interface FileInfo {
  blob: Blob,
  image?: HTMLImageElement, //preview image
  object ? : any; //json only
  domain?: FileDomain,
  sizeGood?: boolean, //尺寸是否匹配
  colorMap?: ColorMap; //仅供 colored和special使用
  colorSum?: ColorSumItem[]; //仅供 colored和special使用
  centers?: Centers,
  artMeta?: ArtMeta; //meta信息
}

export interface ArtMeta {
  category?: string;
  name?: string;
  tags?: string[];
  width ? : number,
  height ? : number,
  areaCount?: number; //色块数
  coloredAreaCount?: number; // 已经填色区块数 
  colorCount?: number;  //颜色数量
  orderedColorCount?: number;  //已排序颜色数量
}

export interface ArtUpload {
  fis: FileInfo[];
  artMeta?: ArtMeta;
}

export interface PreCheckResult {
  raw: HTMLImageElement,
  page: HTMLImageElement,
  map: HTMLImageElement,
  centers: Centers, // 中心点
  areaMap: AreaMap, // areamap
  R: number,  // 小区块半径阈值
  N: number,  // 小区块最大允许的数量
  count: number,  // 小区块数量
  result: boolean, // 检查最终结果
}