@vef-framework/shared 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cjs/color/color-ops.cjs +1 -76
  2. package/dist/cjs/color/index.cjs +1 -24
  3. package/dist/cjs/color/name.cjs +1 -49
  4. package/dist/cjs/color/palette.cjs +1 -126
  5. package/dist/cjs/constants/color-names.cjs +1 -1580
  6. package/dist/cjs/constants/color-palettes.cjs +1 -372
  7. package/dist/cjs/constants/index.cjs +1 -14
  8. package/dist/cjs/index.cjs +1 -339
  9. package/dist/cjs/types/color.cjs +1 -3
  10. package/dist/cjs/types/common.cjs +1 -3
  11. package/dist/cjs/types/deep-keys.cjs +1 -3
  12. package/dist/cjs/types/index.cjs +1 -7
  13. package/dist/cjs/utils/chrono.cjs +1 -139
  14. package/dist/cjs/utils/equal.cjs +1 -175
  15. package/dist/cjs/utils/error.cjs +3 -60
  16. package/dist/cjs/utils/event.cjs +1 -62
  17. package/dist/cjs/utils/format.cjs +1 -31
  18. package/dist/cjs/utils/function.cjs +1 -49
  19. package/dist/cjs/utils/id.cjs +1 -38
  20. package/dist/cjs/utils/index.cjs +1 -86
  21. package/dist/cjs/utils/key.cjs +1 -34
  22. package/dist/cjs/utils/lib.cjs +1 -234
  23. package/dist/cjs/utils/object.cjs +1 -20
  24. package/dist/cjs/utils/path.cjs +1 -63
  25. package/dist/cjs/utils/pinyin.cjs +1 -53
  26. package/dist/cjs/utils/security.cjs +1 -44
  27. package/dist/cjs/utils/string.cjs +1 -13
  28. package/dist/cjs/utils/task.cjs +1 -17
  29. package/dist/cjs/utils/tree.cjs +1 -262
  30. package/dist/cjs/utils/zod.cjs +1 -14
  31. package/dist/es/color/color-ops.js +64 -58
  32. package/dist/es/color/index.js +18 -4
  33. package/dist/es/color/name.js +24 -37
  34. package/dist/es/color/palette.js +67 -100
  35. package/dist/es/constants/color-names.js +6 -9
  36. package/dist/es/constants/color-palettes.js +8 -15
  37. package/dist/es/constants/index.js +8 -3
  38. package/dist/es/index.js +165 -30
  39. package/dist/es/types/color.js +1 -1
  40. package/dist/es/types/common.js +1 -1
  41. package/dist/es/types/deep-keys.js +1 -1
  42. package/dist/es/types/index.js +3 -4
  43. package/dist/es/utils/chrono.js +71 -88
  44. package/dist/es/utils/equal.js +111 -161
  45. package/dist/es/utils/error.js +28 -25
  46. package/dist/es/utils/event.js +18 -23
  47. package/dist/es/utils/format.js +16 -22
  48. package/dist/es/utils/function.js +32 -32
  49. package/dist/es/utils/id.js +18 -27
  50. package/dist/es/utils/index.js +80 -18
  51. package/dist/es/utils/key.js +19 -25
  52. package/dist/es/utils/lib.js +64 -10
  53. package/dist/es/utils/object.js +11 -14
  54. package/dist/es/utils/path.js +57 -48
  55. package/dist/es/utils/pinyin.js +28 -29
  56. package/dist/es/utils/security.js +29 -37
  57. package/dist/es/utils/string.js +7 -8
  58. package/dist/es/utils/task.js +7 -12
  59. package/dist/es/utils/tree.js +156 -219
  60. package/dist/es/utils/zod.js +7 -6
  61. package/package.json +1 -1
@@ -1,262 +1 @@
1
- /*! @vef-framework/shared v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:13.127Z */
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
-
6
- require('./lib.cjs');
7
- const radashi = require('radashi');
8
-
9
- function flattenTree(tree, options = {}) {
10
- const {
11
- childrenKey = "children",
12
- includeParent = false,
13
- includeLevel = false,
14
- transform,
15
- filter
16
- } = options;
17
- const result = [];
18
- function traverse(nodes, parent, level = 0) {
19
- if (!radashi.isArray(nodes)) {
20
- return;
21
- }
22
- for (const node of nodes) {
23
- const context = { parent, level };
24
- if (radashi.isFunction(filter) && !filter(node, context)) {
25
- const children2 = node[childrenKey];
26
- if (radashi.isArray(children2)) {
27
- traverse(children2, node, level + 1);
28
- }
29
- continue;
30
- }
31
- let newNode = node;
32
- if (radashi.isFunction(transform)) {
33
- newNode = transform(node, context);
34
- } else if (includeParent || includeLevel) {
35
- const flattenedNode = { data: node };
36
- if (includeParent) {
37
- flattenedNode.parent = parent;
38
- }
39
- if (includeLevel) {
40
- flattenedNode.level = level;
41
- }
42
- newNode = flattenedNode;
43
- }
44
- result.push(newNode);
45
- const children = node[childrenKey];
46
- if (radashi.isArray(children)) {
47
- traverse(children, node, level + 1);
48
- }
49
- }
50
- }
51
- traverse(tree);
52
- return result;
53
- }
54
- function getNodeValue(node, accessor) {
55
- return radashi.isFunction(accessor) ? accessor(node) : node[accessor];
56
- }
57
- function buildTree(nodes, options = {}) {
58
- const {
59
- idKey = "id",
60
- parentIdKey = "parentId",
61
- childrenKey = "children",
62
- rootValue,
63
- transform
64
- } = options;
65
- if (!radashi.isArray(nodes) || nodes.length === 0) {
66
- return [];
67
- }
68
- const nodeMap = /* @__PURE__ */ new Map();
69
- const rootNodes = [];
70
- for (const node of nodes) {
71
- const nodeId = getNodeValue(node, idKey);
72
- nodeMap.set(nodeId, { ...node });
73
- }
74
- for (const originalNode of nodes) {
75
- const nodeId = getNodeValue(originalNode, idKey);
76
- const parentId = getNodeValue(originalNode, parentIdKey);
77
- const node = nodeMap.get(nodeId);
78
- const isRoot = radashi.isFunction(rootValue) ? rootValue(originalNode) : parentId === rootValue || radashi.isNullish(parentId);
79
- if (isRoot) {
80
- rootNodes.push(node);
81
- } else {
82
- const parentNode = nodeMap.get(parentId);
83
- if (parentNode) {
84
- if (!radashi.isArray(parentNode[childrenKey])) {
85
- parentNode[childrenKey] = [];
86
- }
87
- parentNode[childrenKey].push(node);
88
- } else {
89
- rootNodes.push(node);
90
- }
91
- }
92
- }
93
- if (radashi.isFunction(transform)) {
94
- let transformNode = function(node, level = 0) {
95
- const children = node[childrenKey];
96
- const transformedNode = transformFn(node, { children, level });
97
- if (radashi.isArray(children)) {
98
- transformedNode[childrenKey] = children.map((child) => transformNode(child, level + 1));
99
- }
100
- return transformedNode;
101
- };
102
- const transformFn = transform;
103
- return rootNodes.map((node) => transformNode(node));
104
- }
105
- return rootNodes;
106
- }
107
- function findNodeInTree(tree, predicate, childrenKey = "children") {
108
- function search(nodes, parent, level = 0) {
109
- if (radashi.isArray(nodes)) {
110
- for (const node of nodes) {
111
- if (predicate(node, { parent, level })) {
112
- return node;
113
- }
114
- const children = node[childrenKey];
115
- if (radashi.isArray(children)) {
116
- const found = search(children, node, level + 1);
117
- if (found) {
118
- return found;
119
- }
120
- }
121
- }
122
- }
123
- }
124
- return search(tree);
125
- }
126
- function traverseTree(tree, callback, options = {}) {
127
- const { strategy = "dfs", childrenKey = "children" } = options;
128
- if (!radashi.isArray(tree)) {
129
- return;
130
- }
131
- if (strategy === "bfs") {
132
- const queue = tree.map((node, index) => {
133
- return {
134
- node,
135
- level: 0,
136
- index
137
- };
138
- });
139
- while (queue.length > 0) {
140
- const item = queue.shift();
141
- callback(item.node, {
142
- parent: item.parent,
143
- level: item.level,
144
- index: item.index
145
- });
146
- const children = item.node[childrenKey];
147
- if (radashi.isArray(children)) {
148
- for (const [index, child] of children.entries()) {
149
- queue.push({
150
- node: child,
151
- parent: item.node,
152
- level: item.level + 1,
153
- index
154
- });
155
- }
156
- }
157
- }
158
- } else {
159
- let traverse = function(nodes, parent, level = 0) {
160
- if (!radashi.isArray(nodes)) {
161
- return;
162
- }
163
- for (const [index, node] of nodes.entries()) {
164
- callback(node, {
165
- parent,
166
- level,
167
- index
168
- });
169
- const children = node[childrenKey];
170
- if (radashi.isArray(children)) {
171
- traverse(children, node, level + 1);
172
- }
173
- }
174
- };
175
- traverse(tree);
176
- }
177
- }
178
- function mapTree(tree, callback, childrenKey = "children") {
179
- function transform(nodes, parent, level = 0) {
180
- if (!radashi.isArray(nodes)) {
181
- return [];
182
- }
183
- return nodes.map((node, index) => {
184
- const mappedNode = callback(node, {
185
- parent,
186
- level,
187
- index
188
- });
189
- const children = node[childrenKey];
190
- if (radashi.isArray(children)) {
191
- mappedNode[childrenKey] = transform(children, node, level + 1);
192
- }
193
- return mappedNode;
194
- });
195
- }
196
- return transform(tree);
197
- }
198
- function filterTree(tree, predicate, childrenKey = "children") {
199
- function filter(nodes, parent, level = 0) {
200
- if (!radashi.isArray(nodes)) {
201
- return [];
202
- }
203
- return nodes.reduce((acc, node, index) => {
204
- if (!predicate(node, {
205
- parent,
206
- level,
207
- index
208
- })) {
209
- return acc;
210
- }
211
- const children = node[childrenKey];
212
- const newNode = { ...node };
213
- if (children && radashi.isArray(children)) {
214
- const filteredChildren = filter(children, node, level + 1);
215
- if (filteredChildren.length > 0) {
216
- newNode[childrenKey] = filteredChildren;
217
- } else {
218
- delete newNode[childrenKey];
219
- }
220
- }
221
- acc.push(newNode);
222
- return acc;
223
- }, []);
224
- }
225
- return filter(tree);
226
- }
227
- function filterTreeWithAncestors(tree, predicate, childrenKey = "children") {
228
- function filter(nodes, parent, level = 0) {
229
- if (!radashi.isArray(nodes)) {
230
- return [];
231
- }
232
- const result = [];
233
- for (const [index, node] of nodes.entries()) {
234
- const nodeMatches = predicate(node, {
235
- parent,
236
- level,
237
- index
238
- });
239
- const children = node[childrenKey];
240
- const filteredChildren = radashi.isArray(children) ? filter(children, node, level + 1) : [];
241
- if (nodeMatches || filteredChildren.length > 0) {
242
- const newNode = { ...node };
243
- if (filteredChildren.length > 0) {
244
- newNode[childrenKey] = filteredChildren;
245
- } else {
246
- delete newNode[childrenKey];
247
- }
248
- result.push(newNode);
249
- }
250
- }
251
- return result;
252
- }
253
- return filter(tree);
254
- }
255
-
256
- exports.buildTree = buildTree;
257
- exports.filterTree = filterTree;
258
- exports.filterTreeWithAncestors = filterTreeWithAncestors;
259
- exports.findNodeInTree = findNodeInTree;
260
- exports.flattenTree = flattenTree;
261
- exports.mapTree = mapTree;
262
- exports.traverseTree = traverseTree;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./lib.cjs");const i=require("radashi");function N(c,l={}){const{childrenKey:a="children",includeParent:h=!1,includeLevel:o=!1,transform:u,filter:e}=l,r=[];function t(n,d,s=0){if(i.isArray(n))for(const f of n){const p={parent:d,level:s};if(i.isFunction(e)&&!e(f,p)){const A=f[a];i.isArray(A)&&t(A,f,s+1);continue}let y=f;if(i.isFunction(u))y=u(f,p);else if(h||o){const A={data:f};h&&(A.parent=d),o&&(A.level=s),y=A}r.push(y);const m=f[a];i.isArray(m)&&t(m,f,s+1)}}return t(c),r}function T(c,l){return i.isFunction(l)?l(c):c[l]}function g(c,l={}){const{idKey:a="id",parentIdKey:h="parentId",childrenKey:o="children",rootValue:u,transform:e}=l;if(!i.isArray(c)||c.length===0)return[];const r=new Map,t=[];for(const n of c){const d=T(n,a);r.set(d,{...n})}for(const n of c){const d=T(n,a),s=T(n,h),f=r.get(d);if(i.isFunction(u)?u(n):s===u||i.isNullish(s))t.push(f);else{const y=r.get(s);y?(i.isArray(y[o])||(y[o]=[]),y[o].push(f)):t.push(f)}}if(i.isFunction(e)){let n=function(s,f=0){const p=s[o],y=d(s,{children:p,level:f});return i.isArray(p)&&(y[o]=p.map(m=>n(m,f+1))),y};const d=e;return t.map(s=>n(s))}return t}function I(c,l,a="children"){function h(o,u,e=0){if(i.isArray(o))for(const r of o){if(l(r,{parent:u,level:e}))return r;const t=r[a];if(i.isArray(t)){const n=h(t,r,e+1);if(n)return n}}}return h(c)}function x(c,l,a={}){const{strategy:h="dfs",childrenKey:o="children"}=a;if(i.isArray(c))if(h==="bfs"){const u=c.map((e,r)=>({node:e,level:0,index:r}));for(;u.length>0;){const e=u.shift();l(e.node,{parent:e.parent,level:e.level,index:e.index});const r=e.node[o];if(i.isArray(r))for(const[t,n]of r.entries())u.push({node:n,parent:e.node,level:e.level+1,index:t})}}else{let u=function(e,r,t=0){if(i.isArray(e))for(const[n,d]of e.entries()){l(d,{parent:r,level:t,index:n});const s=d[o];i.isArray(s)&&u(s,d,t+1)}};u(c)}}function F(c,l,a="children"){function h(o,u,e=0){return i.isArray(o)?o.map((r,t)=>{const n=l(r,{parent:u,level:e,index:t}),d=r[a];return i.isArray(d)&&(n[a]=h(d,r,e+1)),n}):[]}return h(c)}function w(c,l,a="children"){function h(o,u,e=0){return i.isArray(o)?o.reduce((r,t,n)=>{if(!l(t,{parent:u,level:e,index:n}))return r;const d=t[a],s={...t};if(d&&i.isArray(d)){const f=h(d,t,e+1);f.length>0?s[a]=f:delete s[a]}return r.push(s),r},[]):[]}return h(c)}function b(c,l,a="children"){function h(o,u,e=0){if(!i.isArray(o))return[];const r=[];for(const[t,n]of o.entries()){const d=l(n,{parent:u,level:e,index:t}),s=n[a],f=i.isArray(s)?h(s,n,e+1):[];if(d||f.length>0){const p={...n};f.length>0?p[a]=f:delete p[a],r.push(p)}}return r}return h(c)}exports.buildTree=g;exports.filterTree=w;exports.filterTreeWithAncestors=b;exports.findNodeInTree=I;exports.flattenTree=N;exports.mapTree=F;exports.traverseTree=x;
@@ -1,14 +1 @@
1
- /*! @vef-framework/shared v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:13.127Z */
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
-
6
- const zod = require('zod');
7
- const locales = require('zod/locales');
8
-
9
- zod.z.config(locales.zhCN());
10
-
11
- Object.defineProperty(exports, "z", {
12
- enumerable: true,
13
- get: () => zod.z
14
- });
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),r=require("zod/locales");e.z.config(r.zhCN());Object.defineProperty(exports,"z",{enumerable:!0,get:()=>e.z});
@@ -1,62 +1,68 @@
1
- /*! @vef-framework/shared v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:13.127Z */
2
- import { extend, colord } from 'colord';
3
- import labPlugin from 'colord/plugins/lab';
4
- import mixPlugin from 'colord/plugins/mix';
5
- import namesPlugin from 'colord/plugins/names';
6
-
7
- extend([namesPlugin, mixPlugin, labPlugin]);
8
- const WHITE_COLOR = "#ffffff";
9
- function isValidColor(color) {
10
- return colord(color).isValid();
11
- }
12
- function toHexColor(color) {
13
- return colord(color).toHex();
14
- }
15
- function toRgbColor(color) {
16
- return colord(color).toRgb();
17
- }
18
- function toHslColor(color) {
19
- return colord(color).toHsl();
20
- }
21
- function toHsvColor(color) {
22
- return colord(color).toHsv();
23
- }
24
- function getColorDifference(firstColor, secondColor) {
25
- return colord(firstColor).delta(secondColor);
26
- }
27
- function convertHslToHex(hslColor) {
28
- return colord(hslColor).toHex();
29
- }
30
- function setColorAlpha(color, alphaValue) {
31
- return colord(color).alpha(alphaValue).toHex();
32
- }
33
- function mixColor(baseColor, blendColor, blendRatio) {
34
- return colord(baseColor).mix(blendColor, blendRatio).toHex();
35
- }
36
- function convertTransparentToOpaque(color, alphaValue, backgroundColor = WHITE_COLOR) {
37
- const transparentColor = setColorAlpha(color, alphaValue);
38
- const {
39
- r: foregroundR,
40
- g: foregroundG,
41
- b: foregroundB
42
- } = colord(transparentColor).toRgb();
43
- const {
44
- r: backgroundR,
45
- g: backgroundG,
46
- b: backgroundB
47
- } = colord(backgroundColor).toRgb();
48
- const resultRgb = {
49
- r: calculateRgbComponent(foregroundR, backgroundR, alphaValue),
50
- g: calculateRgbComponent(foregroundG, backgroundG, alphaValue),
51
- b: calculateRgbComponent(foregroundB, backgroundB, alphaValue)
1
+ import { extend as b, colord as t } from "colord";
2
+ import x from "colord/plugins/lab";
3
+ import C from "colord/plugins/mix";
4
+ import d from "colord/plugins/names";
5
+ b([d, C, x]);
6
+ const u = "#ffffff";
7
+ function O(o) {
8
+ return t(o).isValid();
9
+ }
10
+ function P(o) {
11
+ return t(o).toHex();
12
+ }
13
+ function k(o) {
14
+ return t(o).toRgb();
15
+ }
16
+ function q(o) {
17
+ return t(o).toHsl();
18
+ }
19
+ function B(o) {
20
+ return t(o).toHsv();
21
+ }
22
+ function E(o, r) {
23
+ return t(o).delta(r);
24
+ }
25
+ function G(o) {
26
+ return t(o).toHex();
27
+ }
28
+ function R(o, r) {
29
+ return t(o).alpha(r).toHex();
30
+ }
31
+ function W(o, r, n) {
32
+ return t(o).mix(r, n).toHex();
33
+ }
34
+ function A(o, r, n = u) {
35
+ const i = R(o, r), {
36
+ r: f,
37
+ g: c,
38
+ b: l
39
+ } = t(i).toRgb(), {
40
+ r: s,
41
+ g,
42
+ b: m
43
+ } = t(n).toRgb(), H = {
44
+ r: e(f, s, r),
45
+ g: e(c, g, r),
46
+ b: e(l, m, r)
52
47
  };
53
- return colord(resultRgb).toHex();
48
+ return t(H).toHex();
54
49
  }
55
- function isWhiteColor(color) {
56
- return colord(color).isEqual(WHITE_COLOR);
50
+ function D(o) {
51
+ return t(o).isEqual(u);
57
52
  }
58
- function calculateRgbComponent(foregroundValue, backgroundValue, alphaValue) {
59
- return backgroundValue + (foregroundValue - backgroundValue) * alphaValue;
53
+ function e(o, r, n) {
54
+ return r + (o - r) * n;
60
55
  }
61
-
62
- export { convertHslToHex, convertTransparentToOpaque, getColorDifference, isValidColor, isWhiteColor, mixColor, setColorAlpha, toHexColor, toHslColor, toHsvColor, toRgbColor };
56
+ export {
57
+ G as convertHslToHex,
58
+ A as convertTransparentToOpaque,
59
+ E as getColorDifference,
60
+ O as isValidColor,
61
+ D as isWhiteColor,
62
+ W as mixColor,
63
+ R as setColorAlpha,
64
+ P as toHexColor,
65
+ q as toHslColor,
66
+ B as toHsvColor,
67
+ k as toRgbColor
68
+ };
@@ -1,4 +1,18 @@
1
- /*! @vef-framework/shared v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:13.127Z */
2
- export { convertHslToHex, convertTransparentToOpaque, getColorDifference, isValidColor, isWhiteColor, mixColor, setColorAlpha, toHexColor, toHslColor, toHsvColor, toRgbColor } from './color-ops.js';
3
- export { getColorName } from './name.js';
4
- export { getColorPalette } from './palette.js';
1
+ import { convertHslToHex as e, convertTransparentToOpaque as t, getColorDifference as l, isValidColor as C, isWhiteColor as a, mixColor as s, setColorAlpha as i, toHexColor as p, toHslColor as x, toHsvColor as f, toRgbColor as m } from "./color-ops.js";
2
+ import { getColorName as H } from "./name.js";
3
+ import { getColorPalette as c } from "./palette.js";
4
+ export {
5
+ e as convertHslToHex,
6
+ t as convertTransparentToOpaque,
7
+ l as getColorDifference,
8
+ H as getColorName,
9
+ c as getColorPalette,
10
+ C as isValidColor,
11
+ a as isWhiteColor,
12
+ s as mixColor,
13
+ i as setColorAlpha,
14
+ p as toHexColor,
15
+ x as toHslColor,
16
+ f as toHsvColor,
17
+ m as toRgbColor
18
+ };
@@ -1,45 +1,32 @@
1
- /*! @vef-framework/shared v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:13.127Z */
2
- import '../constants/index.js';
3
- import { toHexColor, toRgbColor, toHslColor } from './color-ops.js';
4
- import { colorEntries } from '../constants/color-names.js';
5
-
6
- const COLOR_DISTANCE_WEIGHTS = {
1
+ import "../constants/index.js";
2
+ import { toHexColor as p, toRgbColor as m, toHslColor as C } from "./color-ops.js";
3
+ import { colorEntries as i } from "../constants/color-names.js";
4
+ const f = {
7
5
  RGB: 1,
8
6
  HSL: 2
9
7
  };
10
- function getColorName(color) {
11
- const inputHex = toHexColor(color);
12
- const inputRgb = toRgbColor(color);
13
- const inputHsl = toHslColor(color);
14
- let closestColorName = "";
15
- let smallestDistance = Number.POSITIVE_INFINITY;
16
- let closestColorIndex = -1;
17
- const exactMatch = colorEntries.find(([hexValue]) => inputHex === hexValue);
18
- if (exactMatch) {
19
- return exactMatch[1];
8
+ function b(t) {
9
+ const o = p(t), n = m(t), r = C(t);
10
+ let e = "", c = Number.POSITIVE_INFINITY, s = -1;
11
+ const a = i.find(([l]) => o === l);
12
+ if (a)
13
+ return a[1];
14
+ for (const [l, [H, I]] of i.entries()) {
15
+ const u = R(n, r, H);
16
+ u < c && (c = u, e = I, s = l);
20
17
  }
21
- for (const [index, [hexValue, colorName]] of colorEntries.entries()) {
22
- const distance = calculateColorDistance(inputRgb, inputHsl, hexValue);
23
- if (distance < smallestDistance) {
24
- smallestDistance = distance;
25
- closestColorName = colorName;
26
- closestColorIndex = index;
27
- }
28
- }
29
- return closestColorName || colorEntries[closestColorIndex]?.[1] || "Unknown";
18
+ return e || i[s]?.[1] || "Unknown";
30
19
  }
31
- function calculateRgbDistance(rgb1, rgb2) {
32
- return (rgb1.r - rgb2.r) ** 2 + (rgb1.g - rgb2.g) ** 2 + (rgb1.b - rgb2.b) ** 2;
20
+ function D(t, o) {
21
+ return (t.r - o.r) ** 2 + (t.g - o.g) ** 2 + (t.b - o.b) ** 2;
33
22
  }
34
- function calculateHslDistance(hsl1, hsl2) {
35
- return (hsl1.h - hsl2.h) ** 2 + (hsl1.s - hsl2.s) ** 2 + (hsl1.l - hsl2.l) ** 2;
23
+ function N(t, o) {
24
+ return (t.h - o.h) ** 2 + (t.s - o.s) ** 2 + (t.l - o.l) ** 2;
36
25
  }
37
- function calculateColorDistance(sourceRgb, sourceHsl, targetHex) {
38
- const targetRgb = toRgbColor(targetHex);
39
- const targetHsl = toHslColor(targetHex);
40
- const rgbDistance = calculateRgbDistance(sourceRgb, targetRgb);
41
- const hslDistance = calculateHslDistance(sourceHsl, targetHsl);
42
- return rgbDistance * COLOR_DISTANCE_WEIGHTS.RGB + hslDistance * COLOR_DISTANCE_WEIGHTS.HSL;
26
+ function R(t, o, n) {
27
+ const r = m(n), e = C(n), c = D(t, r), s = N(o, e);
28
+ return c * f.RGB + s * f.HSL;
43
29
  }
44
-
45
- export { getColorName };
30
+ export {
31
+ b as getColorName
32
+ };