chunk-2KFFVZNJ.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  1. // node_modules/.pnpm/@ctrl+tinycolor@3.6.1/node_modules/@ctrl/tinycolor/dist/module/util.js
  2. function bound01(n, max) {
  3. if (isOnePointZero(n)) {
  4. n = "100%";
  5. }
  6. var isPercent = isPercentage(n);
  7. n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
  8. if (isPercent) {
  9. n = parseInt(String(n * max), 10) / 100;
  10. }
  11. if (Math.abs(n - max) < 1e-6) {
  12. return 1;
  13. }
  14. if (max === 360) {
  15. n = (n < 0 ? n % max + max : n % max) / parseFloat(String(max));
  16. } else {
  17. n = n % max / parseFloat(String(max));
  18. }
  19. return n;
  20. }
  21. function clamp01(val) {
  22. return Math.min(1, Math.max(0, val));
  23. }
  24. function isOnePointZero(n) {
  25. return typeof n === "string" && n.indexOf(".") !== -1 && parseFloat(n) === 1;
  26. }
  27. function isPercentage(n) {
  28. return typeof n === "string" && n.indexOf("%") !== -1;
  29. }
  30. function boundAlpha(a) {
  31. a = parseFloat(a);
  32. if (isNaN(a) || a < 0 || a > 1) {
  33. a = 1;
  34. }
  35. return a;
  36. }
  37. function convertToPercentage(n) {
  38. if (n <= 1) {
  39. return "".concat(Number(n) * 100, "%");
  40. }
  41. return n;
  42. }
  43. function pad2(c) {
  44. return c.length === 1 ? "0" + c : String(c);
  45. }
  46. // node_modules/.pnpm/@ctrl+tinycolor@3.6.1/node_modules/@ctrl/tinycolor/dist/module/conversion.js
  47. function rgbToRgb(r, g, b) {
  48. return {
  49. r: bound01(r, 255) * 255,
  50. g: bound01(g, 255) * 255,
  51. b: bound01(b, 255) * 255
  52. };
  53. }
  54. function rgbToHsl(r, g, b) {
  55. r = bound01(r, 255);
  56. g = bound01(g, 255);
  57. b = bound01(b, 255);
  58. var max = Math.max(r, g, b);
  59. var min = Math.min(r, g, b);
  60. var h = 0;
  61. var s = 0;
  62. var l = (max + min) / 2;
  63. if (max === min) {
  64. s = 0;
  65. h = 0;
  66. } else {
  67. var d = max - min;
  68. s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
  69. switch (max) {
  70. case r:
  71. h = (g - b) / d + (g < b ? 6 : 0);
  72. break;
  73. case g:
  74. h = (b - r) / d + 2;
  75. break;
  76. case b:
  77. h = (r - g) / d + 4;
  78. break;
  79. default:
  80. break;
  81. }
  82. h /= 6;
  83. }
  84. return { h, s, l };
  85. }
  86. function hue2rgb(p, q, t) {
  87. if (t < 0) {
  88. t += 1;
  89. }
  90. if (t > 1) {
  91. t -= 1;
  92. }
  93. if (t < 1 / 6) {
  94. return p + (q - p) * (6 * t);
  95. }
  96. if (t < 1 / 2) {
  97. return q;
  98. }
  99. if (t < 2 / 3) {
  100. return p + (q - p) * (2 / 3 - t) * 6;
  101. }
  102. return p;
  103. }
  104. function hslToRgb(h, s, l) {
  105. var r;
  106. var g;
  107. var b;
  108. h = bound01(h, 360);
  109. s = bound01(s, 100);
  110. l = bound01(l, 100);
  111. if (s === 0) {
  112. g = l;
  113. b = l;
  114. r = l;
  115. } else {
  116. var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  117. var p = 2 * l - q;
  118. r = hue2rgb(p, q, h + 1 / 3);
  119. g = hue2rgb(p, q, h);
  120. b = hue2rgb(p, q, h - 1 / 3);
  121. }
  122. return { r: r * 255, g: g * 255, b: b * 255 };
  123. }
  124. function rgbToHsv(r, g, b) {
  125. r = bound01(r, 255);
  126. g = bound01(g, 255);
  127. b = bound01(b, 255);
  128. var max = Math.max(r, g, b);
  129. var min = Math.min(r, g, b);
  130. var h = 0;
  131. var v = max;
  132. var d = max - min;
  133. var s = max === 0 ? 0 : d / max;
  134. if (max === min) {
  135. h = 0;
  136. } else {
  137. switch (max) {
  138. case r:
  139. h = (g - b) / d + (g < b ? 6 : 0);
  140. break;
  141. case g:
  142. h = (b - r) / d + 2;
  143. break;
  144. case b:
  145. h = (r - g) / d + 4;
  146. break;
  147. default:
  148. break;
  149. }
  150. h /= 6;
  151. }
  152. return { h, s, v };
  153. }
  154. function hsvToRgb(h, s, v) {
  155. h = bound01(h, 360) * 6;
  156. s = bound01(s, 100);
  157. v = bound01(v, 100);
  158. var i = Math.floor(h);
  159. var f = h - i;
  160. var p = v * (1 - s);
  161. var q = v * (1 - f * s);
  162. var t = v * (1 - (1 - f) * s);
  163. var mod = i % 6;
  164. var r = [v, q, p, p, t, v][mod];
  165. var g = [t, v, v, q, p, p][mod];
  166. var b = [p, p, t, v, v, q][mod];
  167. return { r: r * 255, g: g * 255, b: b * 255 };
  168. }
  169. function rgbToHex(r, g, b, allow3Char) {
  170. var hex = [
  171. pad2(Math.round(r).toString(16)),
  172. pad2(Math.round(g).toString(16)),
  173. pad2(Math.round(b).toString(16))
  174. ];
  175. if (allow3Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1))) {
  176. return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
  177. }
  178. return hex.join("");
  179. }
  180. function rgbaToHex(r, g, b, a, allow4Char) {
  181. var hex = [
  182. pad2(Math.round(r).toString(16)),
  183. pad2(Math.round(g).toString(16)),
  184. pad2(Math.round(b).toString(16)),
  185. pad2(convertDecimalToHex(a))
  186. ];
  187. if (allow4Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1)) && hex[3].startsWith(hex[3].charAt(1))) {
  188. return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
  189. }
  190. return hex.join("");
  191. }
  192. function convertDecimalToHex(d) {
  193. return Math.round(parseFloat(d) * 255).toString(16);
  194. }
  195. function convertHexToDecimal(h) {
  196. return parseIntFromHex(h) / 255;
  197. }
  198. function parseIntFromHex(val) {
  199. return parseInt(val, 16);
  200. }
  201. function numberInputToObject(color) {
  202. return {
  203. r: color >> 16,
  204. g: (color & 65280) >> 8,
  205. b: color & 255
  206. };
  207. }
  208. // node_modules/.pnpm/@ctrl+tinycolor@3.6.1/node_modules/@ctrl/tinycolor/dist/module/css-color-names.js
  209. var names = {
  210. aliceblue: "#f0f8ff",
  211. antiquewhite: "#faebd7",
  212. aqua: "#00ffff",
  213. aquamarine: "#7fffd4",
  214. azure: "#f0ffff",
  215. beige: "#f5f5dc",
  216. bisque: "#ffe4c4",
  217. black: "#000000",
  218. blanchedalmond: "#ffebcd",
  219. blue: "#0000ff",
  220. blueviolet: "#8a2be2",
  221. brown: "#a52a2a",
  222. burlywood: "#deb887",
  223. cadetblue: "#5f9ea0",
  224. chartreuse: "#7fff00",
  225. chocolate: "#d2691e",
  226. coral: "#ff7f50",
  227. cornflowerblue: "#6495ed",
  228. cornsilk: "#fff8dc",
  229. crimson: "#dc143c",
  230. cyan: "#00ffff",
  231. darkblue: "#00008b",
  232. darkcyan: "#008b8b",
  233. darkgoldenrod: "#b8860b",
  234. darkgray: "#a9a9a9",
  235. darkgreen: "#006400",
  236. darkgrey: "#a9a9a9",
  237. darkkhaki: "#bdb76b",
  238. darkmagenta: "#8b008b",
  239. darkolivegreen: "#556b2f",
  240. darkorange: "#ff8c00",
  241. darkorchid: "#9932cc",
  242. darkred: "#8b0000",
  243. darksalmon: "#e9967a",
  244. darkseagreen: "#8fbc8f",
  245. darkslateblue: "#483d8b",
  246. darkslategray: "#2f4f4f",
  247. darkslategrey: "#2f4f4f",
  248. darkturquoise: "#00ced1",
  249. darkviolet: "#9400d3",
  250. deeppink: "#ff1493",
  251. deepskyblue: "#00bfff",
  252. dimgray: "#696969",
  253. dimgrey: "#696969",
  254. dodgerblue: "#1e90ff",
  255. firebrick: "#b22222",
  256. floralwhite: "#fffaf0",
  257. forestgreen: "#228b22",
  258. fuchsia: "#ff00ff",
  259. gainsboro: "#dcdcdc",
  260. ghostwhite: "#f8f8ff",
  261. goldenrod: "#daa520",
  262. gold: "#ffd700",
  263. gray: "#808080",
  264. green: "#008000",
  265. greenyellow: "#adff2f",
  266. grey: "#808080",
  267. honeydew: "#f0fff0",
  268. hotpink: "#ff69b4",
  269. indianred: "#cd5c5c",
  270. indigo: "#4b0082",
  271. ivory: "#fffff0",
  272. khaki: "#f0e68c",
  273. lavenderblush: "#fff0f5",
  274. lavender: "#e6e6fa",
  275. lawngreen: "#7cfc00",
  276. lemonchiffon: "#fffacd",
  277. lightblue: "#add8e6",
  278. lightcoral: "#f08080",
  279. lightcyan: "#e0ffff",
  280. lightgoldenrodyellow: "#fafad2",
  281. lightgray: "#d3d3d3",
  282. lightgreen: "#90ee90",
  283. lightgrey: "#d3d3d3",
  284. lightpink: "#ffb6c1",
  285. lightsalmon: "#ffa07a",
  286. lightseagreen: "#20b2aa",
  287. lightskyblue: "#87cefa",
  288. lightslategray: "#778899",
  289. lightslategrey: "#778899",
  290. lightsteelblue: "#b0c4de",
  291. lightyellow: "#ffffe0",
  292. lime: "#00ff00",
  293. limegreen: "#32cd32",
  294. linen: "#faf0e6",
  295. magenta: "#ff00ff",
  296. maroon: "#800000",
  297. mediumaquamarine: "#66cdaa",
  298. mediumblue: "#0000cd",
  299. mediumorchid: "#ba55d3",
  300. mediumpurple: "#9370db",
  301. mediumseagreen: "#3cb371",
  302. mediumslateblue: "#7b68ee",
  303. mediumspringgreen: "#00fa9a",
  304. mediumturquoise: "#48d1cc",
  305. mediumvioletred: "#c71585",
  306. midnightblue: "#191970",
  307. mintcream: "#f5fffa",
  308. mistyrose: "#ffe4e1",
  309. moccasin: "#ffe4b5",
  310. navajowhite: "#ffdead",
  311. navy: "#000080",
  312. oldlace: "#fdf5e6",
  313. olive: "#808000",
  314. olivedrab: "#6b8e23",
  315. orange: "#ffa500",
  316. orangered: "#ff4500",
  317. orchid: "#da70d6",
  318. palegoldenrod: "#eee8aa",
  319. palegreen: "#98fb98",
  320. paleturquoise: "#afeeee",
  321. palevioletred: "#db7093",
  322. papayawhip: "#ffefd5",
  323. peachpuff: "#ffdab9",
  324. peru: "#cd853f",
  325. pink: "#ffc0cb",
  326. plum: "#dda0dd",
  327. powderblue: "#b0e0e6",
  328. purple: "#800080",
  329. rebeccapurple: "#663399",
  330. red: "#ff0000",
  331. rosybrown: "#bc8f8f",
  332. royalblue: "#4169e1",
  333. saddlebrown: "#8b4513",
  334. salmon: "#fa8072",
  335. sandybrown: "#f4a460",
  336. seagreen: "#2e8b57",
  337. seashell: "#fff5ee",
  338. sienna: "#a0522d",
  339. silver: "#c0c0c0",
  340. skyblue: "#87ceeb",
  341. slateblue: "#6a5acd",
  342. slategray: "#708090",
  343. slategrey: "#708090",
  344. snow: "#fffafa",
  345. springgreen: "#00ff7f",
  346. steelblue: "#4682b4",
  347. tan: "#d2b48c",
  348. teal: "#008080",
  349. thistle: "#d8bfd8",
  350. tomato: "#ff6347",
  351. turquoise: "#40e0d0",
  352. violet: "#ee82ee",
  353. wheat: "#f5deb3",
  354. white: "#ffffff",
  355. whitesmoke: "#f5f5f5",
  356. yellow: "#ffff00",
  357. yellowgreen: "#9acd32"
  358. };
  359. // node_modules/.pnpm/@ctrl+tinycolor@3.6.1/node_modules/@ctrl/tinycolor/dist/module/format-input.js
  360. function inputToRGB(color) {
  361. var rgb = { r: 0, g: 0, b: 0 };
  362. var a = 1;
  363. var s = null;
  364. var v = null;
  365. var l = null;
  366. var ok = false;
  367. var format = false;
  368. if (typeof color === "string") {
  369. color = stringInputToObject(color);
  370. }
  371. if (typeof color === "object") {
  372. if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
  373. rgb = rgbToRgb(color.r, color.g, color.b);
  374. ok = true;
  375. format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
  376. } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
  377. s = convertToPercentage(color.s);
  378. v = convertToPercentage(color.v);
  379. rgb = hsvToRgb(color.h, s, v);
  380. ok = true;
  381. format = "hsv";
  382. } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
  383. s = convertToPercentage(color.s);
  384. l = convertToPercentage(color.l);
  385. rgb = hslToRgb(color.h, s, l);
  386. ok = true;
  387. format = "hsl";
  388. }
  389. if (Object.prototype.hasOwnProperty.call(color, "a")) {
  390. a = color.a;
  391. }
  392. }
  393. a = boundAlpha(a);
  394. return {
  395. ok,
  396. format: color.format || format,
  397. r: Math.min(255, Math.max(rgb.r, 0)),
  398. g: Math.min(255, Math.max(rgb.g, 0)),
  399. b: Math.min(255, Math.max(rgb.b, 0)),
  400. a
  401. };
  402. }
  403. var CSS_INTEGER = "[-\\+]?\\d+%?";
  404. var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
  405. var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")");
  406. var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
  407. var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
  408. var matchers = {
  409. CSS_UNIT: new RegExp(CSS_UNIT),
  410. rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
  411. rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
  412. hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
  413. hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
  414. hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
  415. hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
  416. hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
  417. hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
  418. hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
  419. hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
  420. };
  421. function stringInputToObject(color) {
  422. color = color.trim().toLowerCase();
  423. if (color.length === 0) {
  424. return false;
  425. }
  426. var named = false;
  427. if (names[color]) {
  428. color = names[color];
  429. named = true;
  430. } else if (color === "transparent") {
  431. return { r: 0, g: 0, b: 0, a: 0, format: "name" };
  432. }
  433. var match = matchers.rgb.exec(color);
  434. if (match) {
  435. return { r: match[1], g: match[2], b: match[3] };
  436. }
  437. match = matchers.rgba.exec(color);
  438. if (match) {
  439. return { r: match[1], g: match[2], b: match[3], a: match[4] };
  440. }
  441. match = matchers.hsl.exec(color);
  442. if (match) {
  443. return { h: match[1], s: match[2], l: match[3] };
  444. }
  445. match = matchers.hsla.exec(color);
  446. if (match) {
  447. return { h: match[1], s: match[2], l: match[3], a: match[4] };
  448. }
  449. match = matchers.hsv.exec(color);
  450. if (match) {
  451. return { h: match[1], s: match[2], v: match[3] };
  452. }
  453. match = matchers.hsva.exec(color);
  454. if (match) {
  455. return { h: match[1], s: match[2], v: match[3], a: match[4] };
  456. }
  457. match = matchers.hex8.exec(color);
  458. if (match) {
  459. return {
  460. r: parseIntFromHex(match[1]),
  461. g: parseIntFromHex(match[2]),
  462. b: parseIntFromHex(match[3]),
  463. a: convertHexToDecimal(match[4]),
  464. format: named ? "name" : "hex8"
  465. };
  466. }
  467. match = matchers.hex6.exec(color);
  468. if (match) {
  469. return {
  470. r: parseIntFromHex(match[1]),
  471. g: parseIntFromHex(match[2]),
  472. b: parseIntFromHex(match[3]),
  473. format: named ? "name" : "hex"
  474. };
  475. }
  476. match = matchers.hex4.exec(color);
  477. if (match) {
  478. return {
  479. r: parseIntFromHex(match[1] + match[1]),
  480. g: parseIntFromHex(match[2] + match[2]),
  481. b: parseIntFromHex(match[3] + match[3]),
  482. a: convertHexToDecimal(match[4] + match[4]),
  483. format: named ? "name" : "hex8"
  484. };
  485. }
  486. match = matchers.hex3.exec(color);
  487. if (match) {
  488. return {
  489. r: parseIntFromHex(match[1] + match[1]),
  490. g: parseIntFromHex(match[2] + match[2]),
  491. b: parseIntFromHex(match[3] + match[3]),
  492. format: named ? "name" : "hex"
  493. };
  494. }
  495. return false;
  496. }
  497. function isValidCSSUnit(color) {
  498. return Boolean(matchers.CSS_UNIT.exec(String(color)));
  499. }
  500. // node_modules/.pnpm/@ctrl+tinycolor@3.6.1/node_modules/@ctrl/tinycolor/dist/module/index.js
  501. var TinyColor = (
  502. /** @class */
  503. function() {
  504. function TinyColor2(color, opts) {
  505. if (color === void 0) {
  506. color = "";
  507. }
  508. if (opts === void 0) {
  509. opts = {};
  510. }
  511. var _a;
  512. if (color instanceof TinyColor2) {
  513. return color;
  514. }
  515. if (typeof color === "number") {
  516. color = numberInputToObject(color);
  517. }
  518. this.originalInput = color;
  519. var rgb = inputToRGB(color);
  520. this.originalInput = color;
  521. this.r = rgb.r;
  522. this.g = rgb.g;
  523. this.b = rgb.b;
  524. this.a = rgb.a;
  525. this.roundA = Math.round(100 * this.a) / 100;
  526. this.format = (_a = opts.format) !== null && _a !== void 0 ? _a : rgb.format;
  527. this.gradientType = opts.gradientType;
  528. if (this.r < 1) {
  529. this.r = Math.round(this.r);
  530. }
  531. if (this.g < 1) {
  532. this.g = Math.round(this.g);
  533. }
  534. if (this.b < 1) {
  535. this.b = Math.round(this.b);
  536. }
  537. this.isValid = rgb.ok;
  538. }
  539. TinyColor2.prototype.isDark = function() {
  540. return this.getBrightness() < 128;
  541. };
  542. TinyColor2.prototype.isLight = function() {
  543. return !this.isDark();
  544. };
  545. TinyColor2.prototype.getBrightness = function() {
  546. var rgb = this.toRgb();
  547. return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1e3;
  548. };
  549. TinyColor2.prototype.getLuminance = function() {
  550. var rgb = this.toRgb();
  551. var R;
  552. var G;
  553. var B;
  554. var RsRGB = rgb.r / 255;
  555. var GsRGB = rgb.g / 255;
  556. var BsRGB = rgb.b / 255;
  557. if (RsRGB <= 0.03928) {
  558. R = RsRGB / 12.92;
  559. } else {
  560. R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
  561. }
  562. if (GsRGB <= 0.03928) {
  563. G = GsRGB / 12.92;
  564. } else {
  565. G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
  566. }
  567. if (BsRGB <= 0.03928) {
  568. B = BsRGB / 12.92;
  569. } else {
  570. B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
  571. }
  572. return 0.2126 * R + 0.7152 * G + 0.0722 * B;
  573. };
  574. TinyColor2.prototype.getAlpha = function() {
  575. return this.a;
  576. };
  577. TinyColor2.prototype.setAlpha = function(alpha) {
  578. this.a = boundAlpha(alpha);
  579. this.roundA = Math.round(100 * this.a) / 100;
  580. return this;
  581. };
  582. TinyColor2.prototype.isMonochrome = function() {
  583. var s = this.toHsl().s;
  584. return s === 0;
  585. };
  586. TinyColor2.prototype.toHsv = function() {
  587. var hsv = rgbToHsv(this.r, this.g, this.b);
  588. return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };
  589. };
  590. TinyColor2.prototype.toHsvString = function() {
  591. var hsv = rgbToHsv(this.r, this.g, this.b);
  592. var h = Math.round(hsv.h * 360);
  593. var s = Math.round(hsv.s * 100);
  594. var v = Math.round(hsv.v * 100);
  595. return this.a === 1 ? "hsv(".concat(h, ", ").concat(s, "%, ").concat(v, "%)") : "hsva(".concat(h, ", ").concat(s, "%, ").concat(v, "%, ").concat(this.roundA, ")");
  596. };
  597. TinyColor2.prototype.toHsl = function() {
  598. var hsl = rgbToHsl(this.r, this.g, this.b);
  599. return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };
  600. };
  601. TinyColor2.prototype.toHslString = function() {
  602. var hsl = rgbToHsl(this.r, this.g, this.b);
  603. var h = Math.round(hsl.h * 360);
  604. var s = Math.round(hsl.s * 100);
  605. var l = Math.round(hsl.l * 100);
  606. return this.a === 1 ? "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)") : "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(this.roundA, ")");
  607. };
  608. TinyColor2.prototype.toHex = function(allow3Char) {
  609. if (allow3Char === void 0) {
  610. allow3Char = false;
  611. }
  612. return rgbToHex(this.r, this.g, this.b, allow3Char);
  613. };
  614. TinyColor2.prototype.toHexString = function(allow3Char) {
  615. if (allow3Char === void 0) {
  616. allow3Char = false;
  617. }
  618. return "#" + this.toHex(allow3Char);
  619. };
  620. TinyColor2.prototype.toHex8 = function(allow4Char) {
  621. if (allow4Char === void 0) {
  622. allow4Char = false;
  623. }
  624. return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
  625. };
  626. TinyColor2.prototype.toHex8String = function(allow4Char) {
  627. if (allow4Char === void 0) {
  628. allow4Char = false;
  629. }
  630. return "#" + this.toHex8(allow4Char);
  631. };
  632. TinyColor2.prototype.toHexShortString = function(allowShortChar) {
  633. if (allowShortChar === void 0) {
  634. allowShortChar = false;
  635. }
  636. return this.a === 1 ? this.toHexString(allowShortChar) : this.toHex8String(allowShortChar);
  637. };
  638. TinyColor2.prototype.toRgb = function() {
  639. return {
  640. r: Math.round(this.r),
  641. g: Math.round(this.g),
  642. b: Math.round(this.b),
  643. a: this.a
  644. };
  645. };
  646. TinyColor2.prototype.toRgbString = function() {
  647. var r = Math.round(this.r);
  648. var g = Math.round(this.g);
  649. var b = Math.round(this.b);
  650. return this.a === 1 ? "rgb(".concat(r, ", ").concat(g, ", ").concat(b, ")") : "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(this.roundA, ")");
  651. };
  652. TinyColor2.prototype.toPercentageRgb = function() {
  653. var fmt = function(x) {
  654. return "".concat(Math.round(bound01(x, 255) * 100), "%");
  655. };
  656. return {
  657. r: fmt(this.r),
  658. g: fmt(this.g),
  659. b: fmt(this.b),
  660. a: this.a
  661. };
  662. };
  663. TinyColor2.prototype.toPercentageRgbString = function() {
  664. var rnd = function(x) {
  665. return Math.round(bound01(x, 255) * 100);
  666. };
  667. return this.a === 1 ? "rgb(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%)") : "rgba(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%, ").concat(this.roundA, ")");
  668. };
  669. TinyColor2.prototype.toName = function() {
  670. if (this.a === 0) {
  671. return "transparent";
  672. }
  673. if (this.a < 1) {
  674. return false;
  675. }
  676. var hex = "#" + rgbToHex(this.r, this.g, this.b, false);
  677. for (var _i = 0, _a = Object.entries(names); _i < _a.length; _i++) {
  678. var _b = _a[_i], key = _b[0], value = _b[1];
  679. if (hex === value) {
  680. return key;
  681. }
  682. }
  683. return false;
  684. };
  685. TinyColor2.prototype.toString = function(format) {
  686. var formatSet = Boolean(format);
  687. format = format !== null && format !== void 0 ? format : this.format;
  688. var formattedString = false;
  689. var hasAlpha = this.a < 1 && this.a >= 0;
  690. var needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith("hex") || format === "name");
  691. if (needsAlphaFormat) {
  692. if (format === "name" && this.a === 0) {
  693. return this.toName();
  694. }
  695. return this.toRgbString();
  696. }
  697. if (format === "rgb") {
  698. formattedString = this.toRgbString();
  699. }
  700. if (format === "prgb") {
  701. formattedString = this.toPercentageRgbString();
  702. }
  703. if (format === "hex" || format === "hex6") {
  704. formattedString = this.toHexString();
  705. }
  706. if (format === "hex3") {
  707. formattedString = this.toHexString(true);
  708. }
  709. if (format === "hex4") {
  710. formattedString = this.toHex8String(true);
  711. }
  712. if (format === "hex8") {
  713. formattedString = this.toHex8String();
  714. }
  715. if (format === "name") {
  716. formattedString = this.toName();
  717. }
  718. if (format === "hsl") {
  719. formattedString = this.toHslString();
  720. }
  721. if (format === "hsv") {
  722. formattedString = this.toHsvString();
  723. }
  724. return formattedString || this.toHexString();
  725. };
  726. TinyColor2.prototype.toNumber = function() {
  727. return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
  728. };
  729. TinyColor2.prototype.clone = function() {
  730. return new TinyColor2(this.toString());
  731. };
  732. TinyColor2.prototype.lighten = function(amount) {
  733. if (amount === void 0) {
  734. amount = 10;
  735. }
  736. var hsl = this.toHsl();
  737. hsl.l += amount / 100;
  738. hsl.l = clamp01(hsl.l);
  739. return new TinyColor2(hsl);
  740. };
  741. TinyColor2.prototype.brighten = function(amount) {
  742. if (amount === void 0) {
  743. amount = 10;
  744. }
  745. var rgb = this.toRgb();
  746. rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
  747. rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
  748. rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
  749. return new TinyColor2(rgb);
  750. };
  751. TinyColor2.prototype.darken = function(amount) {
  752. if (amount === void 0) {
  753. amount = 10;
  754. }
  755. var hsl = this.toHsl();
  756. hsl.l -= amount / 100;
  757. hsl.l = clamp01(hsl.l);
  758. return new TinyColor2(hsl);
  759. };
  760. TinyColor2.prototype.tint = function(amount) {
  761. if (amount === void 0) {
  762. amount = 10;
  763. }
  764. return this.mix("white", amount);
  765. };
  766. TinyColor2.prototype.shade = function(amount) {
  767. if (amount === void 0) {
  768. amount = 10;
  769. }
  770. return this.mix("black", amount);
  771. };
  772. TinyColor2.prototype.desaturate = function(amount) {
  773. if (amount === void 0) {
  774. amount = 10;
  775. }
  776. var hsl = this.toHsl();
  777. hsl.s -= amount / 100;
  778. hsl.s = clamp01(hsl.s);
  779. return new TinyColor2(hsl);
  780. };
  781. TinyColor2.prototype.saturate = function(amount) {
  782. if (amount === void 0) {
  783. amount = 10;
  784. }
  785. var hsl = this.toHsl();
  786. hsl.s += amount / 100;
  787. hsl.s = clamp01(hsl.s);
  788. return new TinyColor2(hsl);
  789. };
  790. TinyColor2.prototype.greyscale = function() {
  791. return this.desaturate(100);
  792. };
  793. TinyColor2.prototype.spin = function(amount) {
  794. var hsl = this.toHsl();
  795. var hue = (hsl.h + amount) % 360;
  796. hsl.h = hue < 0 ? 360 + hue : hue;
  797. return new TinyColor2(hsl);
  798. };
  799. TinyColor2.prototype.mix = function(color, amount) {
  800. if (amount === void 0) {
  801. amount = 50;
  802. }
  803. var rgb1 = this.toRgb();
  804. var rgb2 = new TinyColor2(color).toRgb();
  805. var p = amount / 100;
  806. var rgba = {
  807. r: (rgb2.r - rgb1.r) * p + rgb1.r,
  808. g: (rgb2.g - rgb1.g) * p + rgb1.g,
  809. b: (rgb2.b - rgb1.b) * p + rgb1.b,
  810. a: (rgb2.a - rgb1.a) * p + rgb1.a
  811. };
  812. return new TinyColor2(rgba);
  813. };
  814. TinyColor2.prototype.analogous = function(results, slices) {
  815. if (results === void 0) {
  816. results = 6;
  817. }
  818. if (slices === void 0) {
  819. slices = 30;
  820. }
  821. var hsl = this.toHsl();
  822. var part = 360 / slices;
  823. var ret = [this];
  824. for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results; ) {
  825. hsl.h = (hsl.h + part) % 360;
  826. ret.push(new TinyColor2(hsl));
  827. }
  828. return ret;
  829. };
  830. TinyColor2.prototype.complement = function() {
  831. var hsl = this.toHsl();
  832. hsl.h = (hsl.h + 180) % 360;
  833. return new TinyColor2(hsl);
  834. };
  835. TinyColor2.prototype.monochromatic = function(results) {
  836. if (results === void 0) {
  837. results = 6;
  838. }
  839. var hsv = this.toHsv();
  840. var h = hsv.h;
  841. var s = hsv.s;
  842. var v = hsv.v;
  843. var res = [];
  844. var modification = 1 / results;
  845. while (results--) {
  846. res.push(new TinyColor2({ h, s, v }));
  847. v = (v + modification) % 1;
  848. }
  849. return res;
  850. };
  851. TinyColor2.prototype.splitcomplement = function() {
  852. var hsl = this.toHsl();
  853. var h = hsl.h;
  854. return [
  855. this,
  856. new TinyColor2({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),
  857. new TinyColor2({ h: (h + 216) % 360, s: hsl.s, l: hsl.l })
  858. ];
  859. };
  860. TinyColor2.prototype.onBackground = function(background) {
  861. var fg = this.toRgb();
  862. var bg = new TinyColor2(background).toRgb();
  863. var alpha = fg.a + bg.a * (1 - fg.a);
  864. return new TinyColor2({
  865. r: (fg.r * fg.a + bg.r * bg.a * (1 - fg.a)) / alpha,
  866. g: (fg.g * fg.a + bg.g * bg.a * (1 - fg.a)) / alpha,
  867. b: (fg.b * fg.a + bg.b * bg.a * (1 - fg.a)) / alpha,
  868. a: alpha
  869. });
  870. };
  871. TinyColor2.prototype.triad = function() {
  872. return this.polyad(3);
  873. };
  874. TinyColor2.prototype.tetrad = function() {
  875. return this.polyad(4);
  876. };
  877. TinyColor2.prototype.polyad = function(n) {
  878. var hsl = this.toHsl();
  879. var h = hsl.h;
  880. var result = [this];
  881. var increment = 360 / n;
  882. for (var i = 1; i < n; i++) {
  883. result.push(new TinyColor2({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));
  884. }
  885. return result;
  886. };
  887. TinyColor2.prototype.equals = function(color) {
  888. return this.toRgbString() === new TinyColor2(color).toRgbString();
  889. };
  890. return TinyColor2;
  891. }()
  892. );
  893. export {
  894. rgbToHsv,
  895. rgbToHex,
  896. inputToRGB,
  897. TinyColor
  898. };
  899. //# sourceMappingURL=chunk-2KFFVZNJ.js.map