{"version":3,"file":"ng-zorro-antd-core-color.mjs","sources":["../../components/core/color/color.ts","../../components/core/color/generate.ts","../../components/core/color/public-api.ts","../../components/core/color/ng-zorro-antd-core-color.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport const statusColors = ['success', 'processing', 'error', 'default', 'warning'] as const;\n\nexport const presetColors = [\n  'pink',\n  'red',\n  'yellow',\n  'orange',\n  'cyan',\n  'green',\n  'blue',\n  'purple',\n  'geekblue',\n  'magenta',\n  'volcano',\n  'gold',\n  'lime'\n] as const;\n\nexport type NzPresetColor = typeof presetColors[number];\nexport type NzStatusColor = typeof statusColors[number];\n\nexport function isPresetColor(color: string): color is NzPresetColor {\n  return presetColors.indexOf(color as NzSafeAny) !== -1;\n}\n\nexport function isStatusColor(color: string): color is NzPresetColor {\n  return statusColors.indexOf(color as NzSafeAny) !== -1;\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\n/**\n * Sync from @ant-design/colors(https://github.com/ant-design/ant-design-colors)\n */\n\nimport { rgbToHsv, rgbToHex, inputToRGB } from '@ctrl/tinycolor';\n\nconst hueStep = 2; // 色相阶梯\nconst saturationStep = 0.16; // 饱和度阶梯，浅色部分\nconst saturationStep2 = 0.05; // 饱和度阶梯，深色部分\nconst brightnessStep1 = 0.05; // 亮度阶梯，浅色部分\nconst brightnessStep2 = 0.15; // 亮度阶梯，深色部分\nconst lightColorCount = 5; // 浅色数量，主色上\nconst darkColorCount = 4; // 深色数量，主色下\n// 暗色主题颜色映射关系表\nconst darkColorMap = [\n  { index: 7, opacity: 0.15 },\n  { index: 6, opacity: 0.25 },\n  { index: 5, opacity: 0.3 },\n  { index: 5, opacity: 0.45 },\n  { index: 5, opacity: 0.65 },\n  { index: 5, opacity: 0.85 },\n  { index: 4, opacity: 0.9 },\n  { index: 3, opacity: 0.95 },\n  { index: 2, opacity: 0.97 },\n  { index: 1, opacity: 0.98 }\n];\n\ninterface HsvObject {\n  h: number;\n  s: number;\n  v: number;\n}\n\ninterface RgbObject {\n  r: number;\n  g: number;\n  b: number;\n}\n\n// Wrapper function ported from TinyColor.prototype.toHsv\n// Keep it here because of `hsv.h * 360`\nfunction toHsv({ r, g, b }: RgbObject): HsvObject {\n  const hsv = rgbToHsv(r, g, b);\n  return { h: hsv.h * 360, s: hsv.s, v: hsv.v };\n}\n\n// Wrapper function ported from TinyColor.prototype.toHexString\n// Keep it here because of the prefix `#`\nfunction toHex({ r, g, b }: RgbObject): string {\n  return `#${rgbToHex(r, g, b, false)}`;\n}\n\n// Wrapper function ported from TinyColor.prototype.mix, not treeshakable.\n// Amount in range [0, 1]\n// Assume color1 & color2 has no alpha, since the following src code did so.\nfunction mix(rgb1: RgbObject, rgb2: RgbObject, amount: number): RgbObject {\n  const p = amount / 100;\n  const rgb = {\n    r: (rgb2.r - rgb1.r) * p + rgb1.r,\n    g: (rgb2.g - rgb1.g) * p + rgb1.g,\n    b: (rgb2.b - rgb1.b) * p + rgb1.b\n  };\n  return rgb;\n}\n\nfunction getHue(hsv: HsvObject, i: number, light?: boolean): number {\n  let hue: number;\n  // 根据色相不同，色相转向不同\n  if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {\n    hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;\n  } else {\n    hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;\n  }\n  if (hue < 0) {\n    hue += 360;\n  } else if (hue >= 360) {\n    hue -= 360;\n  }\n  return hue;\n}\n\nfunction getSaturation(hsv: HsvObject, i: number, light?: boolean): number {\n  // grey color don't change saturation\n  if (hsv.h === 0 && hsv.s === 0) {\n    return hsv.s;\n  }\n  let saturation: number;\n  if (light) {\n    saturation = hsv.s - saturationStep * i;\n  } else if (i === darkColorCount) {\n    saturation = hsv.s + saturationStep;\n  } else {\n    saturation = hsv.s + saturationStep2 * i;\n  }\n  // 边界值修正\n  if (saturation > 1) {\n    saturation = 1;\n  }\n  // 第一格的 s 限制在 0.06-0.1 之间\n  if (light && i === lightColorCount && saturation > 0.1) {\n    saturation = 0.1;\n  }\n  if (saturation < 0.06) {\n    saturation = 0.06;\n  }\n  return Number(saturation.toFixed(2));\n}\n\nfunction getValue(hsv: HsvObject, i: number, light?: boolean): number {\n  let value: number;\n  if (light) {\n    value = hsv.v + brightnessStep1 * i;\n  } else {\n    value = hsv.v - brightnessStep2 * i;\n  }\n  if (value > 1) {\n    value = 1;\n  }\n  return Number(value.toFixed(2));\n}\n\ninterface Opts {\n  theme?: 'dark' | 'default';\n  backgroundColor?: string;\n}\n\nexport function generate(color: string, opts: Opts = {}): string[] {\n  const patterns: string[] = [];\n  const pColor = inputToRGB(color);\n  for (let i = lightColorCount; i > 0; i -= 1) {\n    const hsv = toHsv(pColor);\n    const colorString: string = toHex(\n      inputToRGB({\n        h: getHue(hsv, i, true),\n        s: getSaturation(hsv, i, true),\n        v: getValue(hsv, i, true)\n      })\n    );\n    patterns.push(colorString);\n  }\n  patterns.push(toHex(pColor));\n  for (let i = 1; i <= darkColorCount; i += 1) {\n    const hsv = toHsv(pColor);\n    const colorString: string = toHex(\n      inputToRGB({\n        h: getHue(hsv, i),\n        s: getSaturation(hsv, i),\n        v: getValue(hsv, i)\n      })\n    );\n    patterns.push(colorString);\n  }\n\n  // dark theme patterns\n  if (opts.theme === 'dark') {\n    return darkColorMap.map(({ index, opacity }) => {\n      const darkColorString: string = toHex(\n        mix(inputToRGB(opts.backgroundColor || '#141414'), inputToRGB(patterns[index]), opacity * 100)\n      );\n      return darkColorString;\n    });\n  }\n  return patterns;\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './color';\nexport * from './generate';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;AAGG;AAII,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAW;AAEjF,MAAA,YAAY,GAAG;IAC1B,MAAM;IACN,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,UAAU;IACV,SAAS;IACT,SAAS;IACT,MAAM;IACN,MAAM;EACG;AAKL,SAAU,aAAa,CAAC,KAAa,EAAA;IACzC,OAAO,YAAY,CAAC,OAAO,CAAC,KAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;AACzD,CAAC;AAEK,SAAU,aAAa,CAAC,KAAa,EAAA;IACzC,OAAO,YAAY,CAAC,OAAO,CAAC,KAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;AACzD;;AClCA;;;AAGG;AAQH,MAAM,OAAO,GAAG,CAAC,CAAC;AAClB,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB;AACA,MAAM,YAAY,GAAG;AACnB,IAAA,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;AAC3B,IAAA,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;AAC3B,IAAA,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE;AAC1B,IAAA,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;AAC3B,IAAA,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EA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