@ansh-ui/core 0.2.0

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 (100) hide show
  1. package/LICENSE +21 -0
  2. package/dist/behaviours.cjs +64 -0
  3. package/dist/behaviours.cjs.map +1 -0
  4. package/dist/behaviours.d.cts +3 -0
  5. package/dist/behaviours.d.ts +3 -0
  6. package/dist/behaviours.js +7 -0
  7. package/dist/behaviours.js.map +1 -0
  8. package/dist/chunk-23GSSIMK.cjs +439 -0
  9. package/dist/chunk-23GSSIMK.cjs.map +1 -0
  10. package/dist/chunk-56NNBIAO.js +2446 -0
  11. package/dist/chunk-56NNBIAO.js.map +1 -0
  12. package/dist/chunk-6PFYGJWD.cjs +136 -0
  13. package/dist/chunk-6PFYGJWD.cjs.map +1 -0
  14. package/dist/chunk-7MEIXWPH.js +313 -0
  15. package/dist/chunk-7MEIXWPH.js.map +1 -0
  16. package/dist/chunk-7MYTSAPR.js +83 -0
  17. package/dist/chunk-7MYTSAPR.js.map +1 -0
  18. package/dist/chunk-BOQQHICI.js +1036 -0
  19. package/dist/chunk-BOQQHICI.js.map +1 -0
  20. package/dist/chunk-C6XPQO2O.js +1170 -0
  21. package/dist/chunk-C6XPQO2O.js.map +1 -0
  22. package/dist/chunk-DXJ63QAR.cjs +723 -0
  23. package/dist/chunk-DXJ63QAR.cjs.map +1 -0
  24. package/dist/chunk-FAVIEION.js +705 -0
  25. package/dist/chunk-FAVIEION.js.map +1 -0
  26. package/dist/chunk-FNR35HTL.cjs +107 -0
  27. package/dist/chunk-FNR35HTL.cjs.map +1 -0
  28. package/dist/chunk-GHBRGMSO.cjs +91 -0
  29. package/dist/chunk-GHBRGMSO.cjs.map +1 -0
  30. package/dist/chunk-GJRIHN76.cjs +359 -0
  31. package/dist/chunk-GJRIHN76.cjs.map +1 -0
  32. package/dist/chunk-ILKUL7GD.cjs +115 -0
  33. package/dist/chunk-ILKUL7GD.cjs.map +1 -0
  34. package/dist/chunk-KTUBCQC3.js +409 -0
  35. package/dist/chunk-KTUBCQC3.js.map +1 -0
  36. package/dist/chunk-KU2C6GEA.js +90 -0
  37. package/dist/chunk-KU2C6GEA.js.map +1 -0
  38. package/dist/chunk-LGA3N3YJ.cjs +413 -0
  39. package/dist/chunk-LGA3N3YJ.cjs.map +1 -0
  40. package/dist/chunk-MMO7KO53.cjs +1060 -0
  41. package/dist/chunk-MMO7KO53.cjs.map +1 -0
  42. package/dist/chunk-NSXKCJJ7.js +109 -0
  43. package/dist/chunk-NSXKCJJ7.js.map +1 -0
  44. package/dist/chunk-QALZKHWH.js +387 -0
  45. package/dist/chunk-QALZKHWH.js.map +1 -0
  46. package/dist/chunk-R7UJ7MWP.cjs +2479 -0
  47. package/dist/chunk-R7UJ7MWP.cjs.map +1 -0
  48. package/dist/chunk-UJBXY6QC.cjs +1186 -0
  49. package/dist/chunk-UJBXY6QC.cjs.map +1 -0
  50. package/dist/chunk-YFQXRC5R.js +99 -0
  51. package/dist/chunk-YFQXRC5R.js.map +1 -0
  52. package/dist/color.cjs +257 -0
  53. package/dist/color.cjs.map +1 -0
  54. package/dist/color.d.cts +303 -0
  55. package/dist/color.d.ts +303 -0
  56. package/dist/color.js +8 -0
  57. package/dist/color.js.map +1 -0
  58. package/dist/easing.cjs +189 -0
  59. package/dist/easing.cjs.map +1 -0
  60. package/dist/easing.d.cts +134 -0
  61. package/dist/easing.d.ts +134 -0
  62. package/dist/easing.js +4 -0
  63. package/dist/easing.js.map +1 -0
  64. package/dist/effects.cjs +99 -0
  65. package/dist/effects.cjs.map +1 -0
  66. package/dist/effects.d.cts +5 -0
  67. package/dist/effects.d.ts +5 -0
  68. package/dist/effects.js +10 -0
  69. package/dist/effects.js.map +1 -0
  70. package/dist/index-CCdpefMp.d.ts +967 -0
  71. package/dist/index-CQEEPu-D.d.ts +435 -0
  72. package/dist/index-DHOfsEIn.d.cts +967 -0
  73. package/dist/index-Dl8GCsya.d.cts +435 -0
  74. package/dist/index.cjs +2206 -0
  75. package/dist/index.cjs.map +1 -0
  76. package/dist/index.d.cts +1122 -0
  77. package/dist/index.d.ts +1122 -0
  78. package/dist/index.js +1182 -0
  79. package/dist/index.js.map +1 -0
  80. package/dist/math.cjs +238 -0
  81. package/dist/math.cjs.map +1 -0
  82. package/dist/math.d.cts +120 -0
  83. package/dist/math.d.ts +120 -0
  84. package/dist/math.js +5 -0
  85. package/dist/math.js.map +1 -0
  86. package/dist/noise.cjs +78 -0
  87. package/dist/noise.cjs.map +1 -0
  88. package/dist/noise.d.cts +190 -0
  89. package/dist/noise.d.ts +190 -0
  90. package/dist/noise.js +5 -0
  91. package/dist/noise.js.map +1 -0
  92. package/dist/palette-6HkVltYU.d.cts +219 -0
  93. package/dist/palette-6HkVltYU.d.ts +219 -0
  94. package/dist/random--4mSc5Lp.d.cts +75 -0
  95. package/dist/random--4mSc5Lp.d.ts +75 -0
  96. package/dist/reduced-motion-D0LUgZle.d.cts +120 -0
  97. package/dist/reduced-motion-D0LUgZle.d.ts +120 -0
  98. package/dist/types-B1FLLf3-.d.cts +21 -0
  99. package/dist/types-B1FLLf3-.d.ts +21 -0
  100. package/package.json +78 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ansh contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ var chunkUJBXY6QC_cjs = require('./chunk-UJBXY6QC.cjs');
4
+ require('./chunk-MMO7KO53.cjs');
5
+ require('./chunk-LGA3N3YJ.cjs');
6
+ require('./chunk-GJRIHN76.cjs');
7
+ require('./chunk-ILKUL7GD.cjs');
8
+
9
+
10
+
11
+ Object.defineProperty(exports, "behaviours", {
12
+ enumerable: true,
13
+ get: function () { return chunkUJBXY6QC_cjs.behaviours; }
14
+ });
15
+ Object.defineProperty(exports, "captureStyles", {
16
+ enumerable: true,
17
+ get: function () { return chunkUJBXY6QC_cjs.captureStyles; }
18
+ });
19
+ Object.defineProperty(exports, "defineBehaviour", {
20
+ enumerable: true,
21
+ get: function () { return chunkUJBXY6QC_cjs.defineBehaviour; }
22
+ });
23
+ Object.defineProperty(exports, "getSplitResult", {
24
+ enumerable: true,
25
+ get: function () { return chunkUJBXY6QC_cjs.getSplitResult; }
26
+ });
27
+ Object.defineProperty(exports, "magnetic", {
28
+ enumerable: true,
29
+ get: function () { return chunkUJBXY6QC_cjs.magnetic; }
30
+ });
31
+ Object.defineProperty(exports, "marquee", {
32
+ enumerable: true,
33
+ get: function () { return chunkUJBXY6QC_cjs.marquee; }
34
+ });
35
+ Object.defineProperty(exports, "mountBehaviour", {
36
+ enumerable: true,
37
+ get: function () { return chunkUJBXY6QC_cjs.mountBehaviour; }
38
+ });
39
+ Object.defineProperty(exports, "parallax", {
40
+ enumerable: true,
41
+ get: function () { return chunkUJBXY6QC_cjs.parallax; }
42
+ });
43
+ Object.defineProperty(exports, "ripple", {
44
+ enumerable: true,
45
+ get: function () { return chunkUJBXY6QC_cjs.ripple; }
46
+ });
47
+ Object.defineProperty(exports, "scrollReveal", {
48
+ enumerable: true,
49
+ get: function () { return chunkUJBXY6QC_cjs.scrollReveal; }
50
+ });
51
+ Object.defineProperty(exports, "split", {
52
+ enumerable: true,
53
+ get: function () { return chunkUJBXY6QC_cjs.split; }
54
+ });
55
+ Object.defineProperty(exports, "splitText", {
56
+ enumerable: true,
57
+ get: function () { return chunkUJBXY6QC_cjs.splitText; }
58
+ });
59
+ Object.defineProperty(exports, "tilt", {
60
+ enumerable: true,
61
+ get: function () { return chunkUJBXY6QC_cjs.tilt; }
62
+ });
63
+ //# sourceMappingURL=behaviours.cjs.map
64
+ //# sourceMappingURL=behaviours.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"behaviours.cjs"}
@@ -0,0 +1,3 @@
1
+ export { B as BaseBehaviourOptions, a as BehaviourDefinition, b as BehaviourHandle, c as BehaviourInstance, d as BehaviourName, M as MagneticOptions, e as MarqueeOptions, P as ParallaxOptions, R as RippleOptions, f as ScrollRevealOptions, g as SplitTextOptions, h as SplitTextResult, i as SplitUnit, T as TiltOptions, k as behaviours, l as captureStyles, m as defineBehaviour, n as getSplitResult, o as magnetic, p as marquee, q as mountBehaviour, r as parallax, s as ripple, t as scrollReveal, u as split, v as splitText, y as tilt } from './index-Dl8GCsya.cjs';
2
+ import './reduced-motion-D0LUgZle.cjs';
3
+ import './types-B1FLLf3-.cjs';
@@ -0,0 +1,3 @@
1
+ export { B as BaseBehaviourOptions, a as BehaviourDefinition, b as BehaviourHandle, c as BehaviourInstance, d as BehaviourName, M as MagneticOptions, e as MarqueeOptions, P as ParallaxOptions, R as RippleOptions, f as ScrollRevealOptions, g as SplitTextOptions, h as SplitTextResult, i as SplitUnit, T as TiltOptions, k as behaviours, l as captureStyles, m as defineBehaviour, n as getSplitResult, o as magnetic, p as marquee, q as mountBehaviour, r as parallax, s as ripple, t as scrollReveal, u as split, v as splitText, y as tilt } from './index-CQEEPu-D.js';
2
+ import './reduced-motion-D0LUgZle.js';
3
+ import './types-B1FLLf3-.js';
@@ -0,0 +1,7 @@
1
+ export { behaviours, captureStyles, defineBehaviour, getSplitResult, magnetic, marquee, mountBehaviour, parallax, ripple, scrollReveal, split, splitText, tilt } from './chunk-C6XPQO2O.js';
2
+ import './chunk-BOQQHICI.js';
3
+ import './chunk-QALZKHWH.js';
4
+ import './chunk-7MEIXWPH.js';
5
+ import './chunk-KU2C6GEA.js';
6
+ //# sourceMappingURL=behaviours.js.map
7
+ //# sourceMappingURL=behaviours.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"behaviours.js"}
@@ -0,0 +1,439 @@
1
+ 'use strict';
2
+
3
+ var chunkFNR35HTL_cjs = require('./chunk-FNR35HTL.cjs');
4
+ var chunkLGA3N3YJ_cjs = require('./chunk-LGA3N3YJ.cjs');
5
+ var chunkGJRIHN76_cjs = require('./chunk-GJRIHN76.cjs');
6
+ var chunkILKUL7GD_cjs = require('./chunk-ILKUL7GD.cjs');
7
+
8
+ // src/color/format.ts
9
+ var byte = (c) => Math.round(chunkILKUL7GD_cjs.clamp(c, 0, 1) * 255);
10
+ function toHex(color, forceAlpha = false) {
11
+ const hex = (n) => n.toString(16).padStart(2, "0");
12
+ const base = `#${hex(byte(color.r))}${hex(byte(color.g))}${hex(byte(color.b))}`;
13
+ return color.a < 1 || forceAlpha ? `${base}${hex(byte(color.a))}` : base;
14
+ }
15
+ function toRgbString(color) {
16
+ const r = byte(color.r);
17
+ const g = byte(color.g);
18
+ const b = byte(color.b);
19
+ return color.a < 1 ? `rgba(${r}, ${g}, ${b}, ${chunkILKUL7GD_cjs.roundTo(chunkILKUL7GD_cjs.clamp(color.a, 0, 1), 4)})` : `rgb(${r}, ${g}, ${b})`;
20
+ }
21
+ function toHslString(color) {
22
+ const hsl = chunkLGA3N3YJ_cjs.rgbToHsl(color);
23
+ const h = chunkILKUL7GD_cjs.roundTo(hsl.h, 1);
24
+ const s = chunkILKUL7GD_cjs.roundTo(hsl.s * 100, 1);
25
+ const l = chunkILKUL7GD_cjs.roundTo(hsl.l * 100, 1);
26
+ return hsl.a < 1 ? `hsla(${h}, ${s}%, ${l}%, ${chunkILKUL7GD_cjs.roundTo(hsl.a, 4)})` : `hsl(${h}, ${s}%, ${l}%)`;
27
+ }
28
+ function toOklchString(color) {
29
+ const lch = chunkLGA3N3YJ_cjs.rgbToOklch(color);
30
+ const l = chunkILKUL7GD_cjs.roundTo(lch.l * 100, 2);
31
+ const c = chunkILKUL7GD_cjs.roundTo(lch.c, 4);
32
+ const h = chunkILKUL7GD_cjs.roundTo(lch.h, 2);
33
+ return lch.alpha < 1 ? `oklch(${l}% ${c} ${h} / ${chunkILKUL7GD_cjs.roundTo(lch.alpha, 4)})` : `oklch(${l}% ${c} ${h})`;
34
+ }
35
+ function toUint32(color) {
36
+ return (byte(color.a) << 24 | byte(color.b) << 16 | byte(color.g) << 8 | byte(color.r)) >>> 0;
37
+ }
38
+ function fromUint32(packed) {
39
+ return {
40
+ r: (packed & 255) / 255,
41
+ g: (packed >>> 8 & 255) / 255,
42
+ b: (packed >>> 16 & 255) / 255,
43
+ a: (packed >>> 24 & 255) / 255
44
+ };
45
+ }
46
+ function withAlpha(color, alpha) {
47
+ return { r: color.r, g: color.g, b: color.b, a: chunkILKUL7GD_cjs.clamp(alpha, 0, 1) };
48
+ }
49
+ function fadeBy(color, factor) {
50
+ return { r: color.r, g: color.g, b: color.b, a: chunkILKUL7GD_cjs.clamp(color.a * factor, 0, 1) };
51
+ }
52
+
53
+ // src/color/internal.ts
54
+ function oklchToLinearUnclamped(lch) {
55
+ const lab = chunkLGA3N3YJ_cjs.oklchToOklab(lch);
56
+ const l_ = lab.l + 0.3963377774 * lab.a + 0.2158037573 * lab.b;
57
+ const m_ = lab.l - 0.1055613458 * lab.a - 0.0638541728 * lab.b;
58
+ const s_ = lab.l - 0.0894841775 * lab.a - 1.291485548 * lab.b;
59
+ const l = l_ * l_ * l_;
60
+ const m = m_ * m_ * m_;
61
+ const s = s_ * s_ * s_;
62
+ return {
63
+ r: 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
64
+ g: -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
65
+ b: -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,
66
+ a: lch.alpha
67
+ };
68
+ }
69
+
70
+ // src/color/gamut.ts
71
+ var EPSILON = 1e-4;
72
+ var TOLERANCE = 1e-5;
73
+ function inSrgbGamut(lch) {
74
+ const lin = oklchToLinearUnclamped(lch);
75
+ return lin.r >= -TOLERANCE && lin.r <= 1 + TOLERANCE && lin.g >= -TOLERANCE && lin.g <= 1 + TOLERANCE && lin.b >= -TOLERANCE && lin.b <= 1 + TOLERANCE;
76
+ }
77
+ function gamutMapOklch(lch) {
78
+ if (inSrgbGamut(lch)) return lch;
79
+ const l = Math.min(1, Math.max(0, lch.l));
80
+ if (l <= 0) return { l: 0, c: 0, h: lch.h, alpha: lch.alpha };
81
+ if (l >= 1) return { l: 1, c: 0, h: lch.h, alpha: lch.alpha };
82
+ let low = 0;
83
+ let high = lch.c;
84
+ while (high - low > EPSILON) {
85
+ const mid = (low + high) / 2;
86
+ if (inSrgbGamut({ l, c: mid, h: lch.h, alpha: lch.alpha })) low = mid;
87
+ else high = mid;
88
+ }
89
+ return { l, c: low, h: lch.h, alpha: lch.alpha };
90
+ }
91
+ function maxChroma(l, h) {
92
+ if (l <= 0 || l >= 1) return 0;
93
+ let low = 0;
94
+ let high = 0.5;
95
+ while (high - low > EPSILON) {
96
+ const mid = (low + high) / 2;
97
+ if (inSrgbGamut({ l, c: mid, h, alpha: 1 })) low = mid;
98
+ else high = mid;
99
+ }
100
+ return low;
101
+ }
102
+ function oklchToRgbMapped(lch) {
103
+ const mapped = gamutMapOklch(lch);
104
+ const lin = oklchToLinearUnclamped(mapped);
105
+ return {
106
+ r: clamp01(linearToSrgb(lin.r)),
107
+ g: clamp01(linearToSrgb(lin.g)),
108
+ b: clamp01(linearToSrgb(lin.b)),
109
+ a: mapped.alpha
110
+ };
111
+ }
112
+ function gamutError(lch) {
113
+ if (inSrgbGamut(lch)) return 0;
114
+ return lch.c - gamutMapOklch(lch).c;
115
+ }
116
+ function isGamutStable(rgb) {
117
+ return inSrgbGamut(chunkLGA3N3YJ_cjs.rgbToOklch(rgb));
118
+ }
119
+ function clamp01(v) {
120
+ return v < 0 ? 0 : v > 1 ? 1 : v;
121
+ }
122
+ function linearToSrgb(c) {
123
+ return c <= 31308e-7 ? c * 12.92 : 1.055 * Math.abs(c) ** (1 / 2.4) * Math.sign(c) - 0.055;
124
+ }
125
+
126
+ // src/color/interpolate.ts
127
+ function mixColors(from, to, t, options) {
128
+ const a = chunkLGA3N3YJ_cjs.parseColor(from);
129
+ const b = chunkLGA3N3YJ_cjs.parseColor(to);
130
+ return mixParsed(a, b, chunkILKUL7GD_cjs.clamp(t, 0, 1), options);
131
+ }
132
+ function mixParsed(a, b, t, options) {
133
+ const space = options?.space ?? "oklab";
134
+ const alpha = chunkILKUL7GD_cjs.lerp(a.a, b.a, t);
135
+ switch (space) {
136
+ case "srgb":
137
+ return { r: chunkILKUL7GD_cjs.lerp(a.r, b.r, t), g: chunkILKUL7GD_cjs.lerp(a.g, b.g, t), b: chunkILKUL7GD_cjs.lerp(a.b, b.b, t), a: alpha };
138
+ case "lrgb": {
139
+ const la = chunkLGA3N3YJ_cjs.rgbToLinear(a);
140
+ const lb = chunkLGA3N3YJ_cjs.rgbToLinear(b);
141
+ return chunkLGA3N3YJ_cjs.linearToRgb({
142
+ r: chunkILKUL7GD_cjs.lerp(la.r, lb.r, t),
143
+ g: chunkILKUL7GD_cjs.lerp(la.g, lb.g, t),
144
+ b: chunkILKUL7GD_cjs.lerp(la.b, lb.b, t),
145
+ a: alpha
146
+ });
147
+ }
148
+ case "hsl": {
149
+ const ha = chunkLGA3N3YJ_cjs.rgbToHsl(a);
150
+ const hb = chunkLGA3N3YJ_cjs.rgbToHsl(b);
151
+ return chunkLGA3N3YJ_cjs.hslToRgb({
152
+ h: lerpHue(ha.h, hb.h, t, options?.hue ?? "shorter"),
153
+ s: chunkILKUL7GD_cjs.lerp(ha.s, hb.s, t),
154
+ l: chunkILKUL7GD_cjs.lerp(ha.l, hb.l, t),
155
+ a: alpha
156
+ });
157
+ }
158
+ case "oklch": {
159
+ const ca = chunkLGA3N3YJ_cjs.rgbToOklch(a);
160
+ const cb = chunkLGA3N3YJ_cjs.rgbToOklch(b);
161
+ const hueA = ca.c < 1e-5 ? cb.h : ca.h;
162
+ const hueB = cb.c < 1e-5 ? ca.h : cb.h;
163
+ const result = {
164
+ l: chunkILKUL7GD_cjs.lerp(ca.l, cb.l, t),
165
+ c: chunkILKUL7GD_cjs.lerp(ca.c, cb.c, t),
166
+ h: lerpHue(hueA, hueB, t, options?.hue ?? "shorter"),
167
+ alpha
168
+ };
169
+ return options?.gamutMap === false ? chunkLGA3N3YJ_cjs.oklabToRgb({
170
+ l: result.l,
171
+ a: Math.cos(result.h * Math.PI / 180) * result.c,
172
+ b: Math.sin(result.h * Math.PI / 180) * result.c,
173
+ alpha
174
+ }) : oklchToRgbMapped(result);
175
+ }
176
+ case "oklab":
177
+ default: {
178
+ const la = chunkLGA3N3YJ_cjs.rgbToOklab(a);
179
+ const lb = chunkLGA3N3YJ_cjs.rgbToOklab(b);
180
+ return chunkLGA3N3YJ_cjs.oklabToRgb({
181
+ l: chunkILKUL7GD_cjs.lerp(la.l, lb.l, t),
182
+ a: chunkILKUL7GD_cjs.lerp(la.a, lb.a, t),
183
+ b: chunkILKUL7GD_cjs.lerp(la.b, lb.b, t),
184
+ alpha
185
+ });
186
+ }
187
+ }
188
+ }
189
+ function lerpHue(from, to, t, direction) {
190
+ const a = chunkILKUL7GD_cjs.wrap(from, 0, 360);
191
+ const b = chunkILKUL7GD_cjs.wrap(to, 0, 360);
192
+ let delta = b - a;
193
+ switch (direction) {
194
+ case "increasing":
195
+ if (delta < 0) delta += 360;
196
+ break;
197
+ case "decreasing":
198
+ if (delta > 0) delta -= 360;
199
+ break;
200
+ case "longer":
201
+ if (Math.abs(delta) < 180) delta += delta >= 0 ? -360 : 360;
202
+ break;
203
+ case "shorter":
204
+ default:
205
+ if (delta > 180) delta -= 360;
206
+ else if (delta < -180) delta += 360;
207
+ break;
208
+ }
209
+ return chunkILKUL7GD_cjs.wrap(a + delta * t, 0, 360);
210
+ }
211
+ function createGradient(input, options) {
212
+ const stops = normalizeStops(input);
213
+ if (stops.length === 0) {
214
+ throw new RangeError("[ansh] createGradient() requires at least one colour stop.");
215
+ }
216
+ const parsed = stops.map((s) => chunkLGA3N3YJ_cjs.parseColor(s.color));
217
+ const offsets = stops.map((s) => s.offset);
218
+ const ease = chunkGJRIHN76_cjs.resolveEasing(options?.easing);
219
+ const mixOptions = {
220
+ space: options?.space ?? "oklab",
221
+ hue: options?.hue ?? "shorter",
222
+ gamutMap: options?.gamutMap
223
+ };
224
+ const at = (t) => {
225
+ const clamped = chunkILKUL7GD_cjs.clamp(t, 0, 1);
226
+ const last = parsed.length - 1;
227
+ if (last === 0) return parsed[0];
228
+ if (clamped <= offsets[0]) return parsed[0];
229
+ if (clamped >= offsets[last]) return parsed[last];
230
+ let i = 0;
231
+ while (i < last && offsets[i + 1] < clamped) i++;
232
+ const span = offsets[i + 1] - offsets[i];
233
+ const local = span <= 0 ? 0 : (clamped - offsets[i]) / span;
234
+ return mixParsed(parsed[i], parsed[i + 1], ease(local), mixOptions);
235
+ };
236
+ return {
237
+ at,
238
+ cssAt: (t) => toRgbString(at(t)),
239
+ sample(count) {
240
+ const n = Math.max(1, Math.floor(count));
241
+ const out = new Array(n);
242
+ for (let i = 0; i < n; i++) out[i] = at(n === 1 ? 0 : i / (n - 1));
243
+ return out;
244
+ },
245
+ toCss(direction = "to right", count = 16) {
246
+ const n = Math.max(2, Math.floor(count));
247
+ const parts = [];
248
+ for (let i = 0; i < n; i++) {
249
+ const t = i / (n - 1);
250
+ parts.push(`${toRgbString(at(t))} ${(t * 100).toFixed(2)}%`);
251
+ }
252
+ return `linear-gradient(${direction}, ${parts.join(", ")})`;
253
+ },
254
+ stops
255
+ };
256
+ }
257
+ function normalizeStops(input) {
258
+ if (input.length === 0) return [];
259
+ const isStopList = typeof input[0] === "object" && input[0] !== null && "offset" in input[0];
260
+ const stops = isStopList ? input.map((s) => ({
261
+ offset: chunkILKUL7GD_cjs.clamp(s.offset, 0, 1),
262
+ color: s.color
263
+ })) : input.map((color, i, arr) => ({
264
+ offset: arr.length === 1 ? 0 : i / (arr.length - 1),
265
+ color
266
+ }));
267
+ return stops.sort((a, b) => a.offset - b.offset);
268
+ }
269
+ function applyGradientStops(target, gradient, resolution = 24) {
270
+ const n = Math.max(2, Math.floor(resolution));
271
+ for (let i = 0; i < n; i++) {
272
+ const t = i / (n - 1);
273
+ target.addColorStop(t, toRgbString(gradient.at(t)));
274
+ }
275
+ return target;
276
+ }
277
+ function blend(base, over, amount = 0.5, space) {
278
+ return mixColors(base, over, amount, { space });
279
+ }
280
+ function composite(base, over) {
281
+ const b = chunkLGA3N3YJ_cjs.rgbToLinear(chunkLGA3N3YJ_cjs.parseColor(base));
282
+ const o = chunkLGA3N3YJ_cjs.rgbToLinear(chunkLGA3N3YJ_cjs.parseColor(over));
283
+ const alpha = o.a + b.a * (1 - o.a);
284
+ if (alpha <= 0) return { r: 0, g: 0, b: 0, a: 0 };
285
+ return chunkLGA3N3YJ_cjs.linearToRgb({
286
+ r: (o.r * o.a + b.r * b.a * (1 - o.a)) / alpha,
287
+ g: (o.g * o.a + b.g * b.a * (1 - o.a)) / alpha,
288
+ b: (o.b * o.a + b.b * b.a * (1 - o.a)) / alpha,
289
+ a: alpha
290
+ });
291
+ }
292
+
293
+ // src/color/palette.ts
294
+ var HARMONY_OFFSETS = {
295
+ analogous: [-30, 0, 30],
296
+ complementary: [0, 180],
297
+ splitComplementary: [0, 150, 210],
298
+ triadic: [0, 120, 240],
299
+ tetradic: [0, 60, 180, 240],
300
+ square: [0, 90, 180, 270],
301
+ monochromatic: [0]
302
+ };
303
+ function harmony(base, kind = "analogous") {
304
+ const lch = chunkLGA3N3YJ_cjs.rgbToOklch(chunkLGA3N3YJ_cjs.parseColor(base));
305
+ const offsets = HARMONY_OFFSETS[kind];
306
+ if (kind === "monochromatic") {
307
+ return [0.35, 0.5, 0.65, 0.8].map(
308
+ (l) => oklchToRgbMapped({ l, c: lch.c, h: lch.h, alpha: lch.alpha })
309
+ );
310
+ }
311
+ return offsets.map(
312
+ (offset) => oklchToRgbMapped({ l: lch.l, c: lch.c, h: chunkILKUL7GD_cjs.wrap(lch.h + offset, 0, 360), alpha: lch.alpha })
313
+ );
314
+ }
315
+ var TAILWIND_KEYS = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "950"];
316
+ function createScale(base, options = {}) {
317
+ const steps = Math.max(2, Math.floor(options.steps ?? 11));
318
+ const lightest = chunkILKUL7GD_cjs.clamp(options.lightest ?? 0.97, 0, 1);
319
+ const darkest = chunkILKUL7GD_cjs.clamp(options.darkest ?? 0.18, 0, 1);
320
+ const falloff = chunkILKUL7GD_cjs.clamp(options.chromaFalloff ?? 0.35, 0, 1);
321
+ const hueShift = options.hueShift ?? 0;
322
+ const lch = chunkLGA3N3YJ_cjs.rgbToOklch(chunkLGA3N3YJ_cjs.parseColor(base));
323
+ const colors = [];
324
+ for (let i = 0; i < steps; i++) {
325
+ const t = i / (steps - 1);
326
+ const l = chunkILKUL7GD_cjs.lerp(lightest, darkest, t);
327
+ const envelope = Math.sin(Math.PI * t);
328
+ const chromaFactor = 1 - falloff * (1 - envelope);
329
+ const c = Math.min(lch.c * chromaFactor, maxChroma(l, lch.h));
330
+ const h = chunkILKUL7GD_cjs.wrap(lch.h + hueShift * (t - 0.5) * 2, 0, 360);
331
+ colors.push(oklchToRgbMapped({ l, c, h, alpha: 1 }));
332
+ }
333
+ const hex = colors.map((c) => toHex(c));
334
+ const keys = steps === 11 ? TAILWIND_KEYS : colors.map((_, i) => String(i));
335
+ const byKey = {};
336
+ keys.forEach((key, i) => {
337
+ byKey[key] = hex[i];
338
+ });
339
+ return { colors, hex, byKey };
340
+ }
341
+ function generatePalette(options = {}) {
342
+ const count = Math.max(1, Math.floor(options.count ?? 5));
343
+ const rng = chunkFNR35HTL_cjs.createRng(options.seed ?? 1);
344
+ const lightness = chunkILKUL7GD_cjs.clamp(options.lightness ?? 0.65, 0.05, 0.98);
345
+ const saturation = chunkILKUL7GD_cjs.clamp(options.saturation ?? 0.85, 0, 1);
346
+ const spread = options.spread ?? 120;
347
+ const variance = chunkILKUL7GD_cjs.clamp(options.variance ?? 0.12, 0, 1);
348
+ const baseHue = options.baseHue ?? rng.next() * 360;
349
+ const GOLDEN_ANGLE = 137.507764;
350
+ const colors = [];
351
+ for (let i = 0; i < count; i++) {
352
+ const walk = count === 1 ? 0 : i * GOLDEN_ANGLE % 360 / 360;
353
+ const h = chunkILKUL7GD_cjs.wrap(baseHue + (walk - 0.5) * spread, 0, 360);
354
+ const l = chunkILKUL7GD_cjs.clamp(lightness + (rng.next() * 2 - 1) * variance * 0.5, 0.05, 0.98);
355
+ const c = maxChroma(l, h) * chunkILKUL7GD_cjs.clamp(saturation + (rng.next() * 2 - 1) * variance, 0, 1);
356
+ colors.push(oklchToRgbMapped({ l, c, h, alpha: 1 }));
357
+ }
358
+ return colors;
359
+ }
360
+ function expandPalette(colors, count) {
361
+ const n = Math.max(1, Math.floor(count));
362
+ if (colors.length === 0) throw new RangeError("[ansh] expandPalette() needs at least one colour.");
363
+ if (colors.length === 1) return new Array(n).fill(chunkLGA3N3YJ_cjs.parseColor(colors[0]));
364
+ if (colors.length >= n) return colors.slice(0, n).map((c) => chunkLGA3N3YJ_cjs.parseColor(c));
365
+ return createGradient(colors, { space: "oklch" }).sample(n);
366
+ }
367
+ function sortByLightness(colors, ascending = true) {
368
+ return colors.map((c) => chunkLGA3N3YJ_cjs.parseColor(c)).sort((a, b) => {
369
+ const delta = chunkLGA3N3YJ_cjs.rgbToOklch(a).l - chunkLGA3N3YJ_cjs.rgbToOklch(b).l;
370
+ return ascending ? delta : -delta;
371
+ });
372
+ }
373
+ function invertForSurface(colors, chromaBoost = 1.15) {
374
+ return colors.map((input) => {
375
+ const lch = chunkLGA3N3YJ_cjs.rgbToOklch(chunkLGA3N3YJ_cjs.parseColor(input));
376
+ const l = chunkILKUL7GD_cjs.clamp(1 - lch.l, 0.08, 0.95);
377
+ const c = Math.min(lch.c * chromaBoost, maxChroma(l, lch.h));
378
+ return oklchToRgbMapped({ l, c, h: lch.h, alpha: lch.alpha });
379
+ });
380
+ }
381
+ var palettes = {
382
+ /** Deep blue → violet → magenta. The house palette. */
383
+ ansh: ["#0275f4", "#5b3df5", "#9f0550"],
384
+ /** Cool northern lights: teal, green, indigo. */
385
+ aurora: ["#00d4ff", "#22e39a", "#4f46e5"],
386
+ /** Warm dusk: amber through rose. */
387
+ ember: ["#ff9d00", "#ff4d6d", "#c026d3"],
388
+ /** Oceanic blues and cyans. */
389
+ abyss: ["#012a4a", "#0275f4", "#00d4ff"],
390
+ /** Monochrome with a cool cast — for restrained, editorial designs. */
391
+ graphite: ["#f8fafc", "#94a3b8", "#0f172a"],
392
+ /** High-energy neon for AI and developer-tool aesthetics. */
393
+ neon: ["#00d4ff", "#8a2be2", "#ff0066"],
394
+ /** Soft pastel wash for marketing and onboarding. */
395
+ bloom: ["#fbcfe8", "#c7d2fe", "#a7f3d0"],
396
+ /** Gold and bronze — luxury, premium tiers, testimonials. */
397
+ gilded: ["#fde68a", "#d97706", "#78350f"]
398
+ };
399
+ function resolvePalette(input, fallback = "ansh") {
400
+ if (input === void 0) return palettes[fallback].map((c) => chunkLGA3N3YJ_cjs.parseColor(c));
401
+ if (typeof input === "string") {
402
+ const named = palettes[input];
403
+ return (named ?? palettes[fallback]).map((c) => chunkLGA3N3YJ_cjs.parseColor(c));
404
+ }
405
+ if (input.length === 0) return palettes[fallback].map((c) => chunkLGA3N3YJ_cjs.parseColor(c));
406
+ return input.map((c) => chunkLGA3N3YJ_cjs.parseColor(c));
407
+ }
408
+
409
+ exports.applyGradientStops = applyGradientStops;
410
+ exports.blend = blend;
411
+ exports.composite = composite;
412
+ exports.createGradient = createGradient;
413
+ exports.createScale = createScale;
414
+ exports.expandPalette = expandPalette;
415
+ exports.fadeBy = fadeBy;
416
+ exports.fromUint32 = fromUint32;
417
+ exports.gamutError = gamutError;
418
+ exports.gamutMapOklch = gamutMapOklch;
419
+ exports.generatePalette = generatePalette;
420
+ exports.harmony = harmony;
421
+ exports.inSrgbGamut = inSrgbGamut;
422
+ exports.invertForSurface = invertForSurface;
423
+ exports.isGamutStable = isGamutStable;
424
+ exports.lerpHue = lerpHue;
425
+ exports.maxChroma = maxChroma;
426
+ exports.mixColors = mixColors;
427
+ exports.mixParsed = mixParsed;
428
+ exports.oklchToRgbMapped = oklchToRgbMapped;
429
+ exports.palettes = palettes;
430
+ exports.resolvePalette = resolvePalette;
431
+ exports.sortByLightness = sortByLightness;
432
+ exports.toHex = toHex;
433
+ exports.toHslString = toHslString;
434
+ exports.toOklchString = toOklchString;
435
+ exports.toRgbString = toRgbString;
436
+ exports.toUint32 = toUint32;
437
+ exports.withAlpha = withAlpha;
438
+ //# sourceMappingURL=chunk-23GSSIMK.cjs.map
439
+ //# sourceMappingURL=chunk-23GSSIMK.cjs.map