@ariaui/shadow 0.1.4 → 0.1.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.
@@ -0,0 +1,665 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // tokens.ts
38
+ var tokens_exports = {};
39
+ __export(tokens_exports, {
40
+ ELEVATION_PRESETS: () => ELEVATION_PRESETS,
41
+ addLayer: () => addLayer,
42
+ buildRing: () => buildRing,
43
+ colorRing: () => colorRing,
44
+ colorShadow: () => colorShadow,
45
+ createElevationScale: () => createElevationScale,
46
+ createErrorRing: () => createErrorRing,
47
+ createFocusRing: () => createFocusRing,
48
+ createLayer: () => createLayer,
49
+ createShadow: () => createShadow,
50
+ getElevationLevels: () => getElevationLevels,
51
+ insetLayer: () => insetLayer,
52
+ interpolateElevation: () => interpolateElevation,
53
+ layerToString: () => layerToString,
54
+ mergeShadows: () => mergeShadows,
55
+ multiplyAlpha: () => multiplyAlpha,
56
+ offsetLayer: () => offsetLayer,
57
+ parseLayer: () => parseLayer,
58
+ parseShadow: () => parseShadow,
59
+ removeLayer: () => removeLayer,
60
+ resolveAllShadows: () => resolveAllShadows,
61
+ resolveDarkMultiplier: () => resolveDarkMultiplier,
62
+ resolveFocusRing: () => resolveFocusRing,
63
+ resolveLayerAlphas: () => resolveLayerAlphas,
64
+ resolveShadow: () => resolveShadow,
65
+ scaleLayer: () => scaleLayer,
66
+ scaleShadow: () => scaleShadow,
67
+ setLayerColor: () => setLayerColor,
68
+ setLayerOpacity: () => setLayerOpacity,
69
+ stepElevation: () => stepElevation,
70
+ toBoxShadow: () => toBoxShadow,
71
+ toCSSDeclaration: () => toCSSDeclaration,
72
+ toCSSProperties: () => toCSSProperties,
73
+ toTailwindClass: () => toTailwindClass,
74
+ withFocusRing: () => withFocusRing
75
+ });
76
+ module.exports = __toCommonJS(tokens_exports);
77
+
78
+ // src/parse.ts
79
+ function parseShadow(css) {
80
+ const trimmed = css.trim();
81
+ if (!trimmed || trimmed === "none") {
82
+ return { layers: [] };
83
+ }
84
+ const layers = splitShadowLayers(trimmed).map(parseLayer);
85
+ return { layers };
86
+ }
87
+ function parseLayer(css) {
88
+ var _a, _b, _c, _d;
89
+ const trimmed = css.trim();
90
+ const inset = trimmed.startsWith("inset ");
91
+ const rest = inset ? trimmed.slice(6).trim() : trimmed;
92
+ const { values, colorStr } = extractParts(rest);
93
+ const color = parseColorToOklch(colorStr);
94
+ return {
95
+ offsetX: (_a = values[0]) != null ? _a : "0px",
96
+ offsetY: (_b = values[1]) != null ? _b : "0px",
97
+ blur: (_c = values[2]) != null ? _c : "0px",
98
+ spread: (_d = values[3]) != null ? _d : "0px",
99
+ color,
100
+ inset
101
+ };
102
+ }
103
+ function splitShadowLayers(css) {
104
+ const layers = [];
105
+ let depth = 0;
106
+ let start = 0;
107
+ for (let i = 0; i < css.length; i++) {
108
+ const ch = css[i];
109
+ if (ch === "(") depth++;
110
+ else if (ch === ")") depth--;
111
+ else if (ch === "," && depth === 0) {
112
+ layers.push(css.slice(start, i).trim());
113
+ start = i + 1;
114
+ }
115
+ }
116
+ const last = css.slice(start).trim();
117
+ if (last) layers.push(last);
118
+ return layers;
119
+ }
120
+ function extractParts(str) {
121
+ const funcMatch = str.match(/(rgba?\(.+?\)|oklch\(.+?\)|hsla?\(.+?\))\s*$/i);
122
+ if (funcMatch) {
123
+ const colorStr = funcMatch[1];
124
+ const before = str.slice(0, str.length - funcMatch[0].length).trim();
125
+ return { values: before.split(/\s+/), colorStr };
126
+ }
127
+ const parts = str.split(/\s+/);
128
+ const isLength = (s) => /^-?[\d.]/.test(s);
129
+ let colorIdx = parts.length;
130
+ for (let i = parts.length - 1; i >= 0; i--) {
131
+ if (isLength(parts[i])) {
132
+ colorIdx = i + 1;
133
+ break;
134
+ }
135
+ }
136
+ if (colorIdx < parts.length) {
137
+ return {
138
+ values: parts.slice(0, colorIdx),
139
+ colorStr: parts.slice(colorIdx).join(" ")
140
+ };
141
+ }
142
+ if (!isLength(parts[0])) {
143
+ return {
144
+ values: parts.slice(1),
145
+ colorStr: parts[0]
146
+ };
147
+ }
148
+ return { values: parts, colorStr: "black" };
149
+ }
150
+ function parseColorToOklch(color) {
151
+ const c = color.trim().toLowerCase();
152
+ if (c.startsWith("oklch(")) {
153
+ const inner = c.slice(6, -1).trim();
154
+ const [colorPart, alphaPart] = inner.split("/").map((s) => s.trim());
155
+ const parts = colorPart.split(/\s+/);
156
+ let l = parseFloat(parts[0]);
157
+ if (parts[0].endsWith("%")) l = l / 100;
158
+ return {
159
+ l,
160
+ c: parseFloat(parts[1]) || 0,
161
+ h: parseFloat(parts[2]) || 0,
162
+ alpha: alphaPart !== void 0 ? parseFloat(alphaPart) : 1
163
+ };
164
+ }
165
+ if (c.startsWith("rgb")) {
166
+ const inner = c.replace(/rgba?\(/, "").replace(")", "").trim();
167
+ let r, g, b, a;
168
+ if (inner.includes("/")) {
169
+ const [colorPart, alphaPart] = inner.split("/").map((s) => s.trim());
170
+ const parts = colorPart.split(/[\s,]+/).map(Number);
171
+ [r, g, b] = parts;
172
+ a = parseFloat(alphaPart);
173
+ } else {
174
+ const parts = inner.split(/[\s,]+/).map(Number);
175
+ r = parts[0];
176
+ g = parts[1];
177
+ b = parts[2];
178
+ a = parts.length > 3 ? parts[3] : 1;
179
+ }
180
+ return srgbToOklchSimple(r / 255, g / 255, b / 255, a);
181
+ }
182
+ if (c.startsWith("#")) {
183
+ let h = c.slice(1);
184
+ if (h.length === 3) h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2];
185
+ if (h.length === 4)
186
+ h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2] + h[3] + h[3];
187
+ const r = parseInt(h.slice(0, 2), 16) / 255;
188
+ const g = parseInt(h.slice(2, 4), 16) / 255;
189
+ const b = parseInt(h.slice(4, 6), 16) / 255;
190
+ const a = h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1;
191
+ return srgbToOklchSimple(r, g, b, a);
192
+ }
193
+ if (c === "black") return { l: 0, c: 0, h: 0, alpha: 1 };
194
+ if (c === "white") return { l: 1, c: 0, h: 0, alpha: 1 };
195
+ if (c === "transparent") return { l: 0, c: 0, h: 0, alpha: 0 };
196
+ return { l: 0, c: 0, h: 0, alpha: 0 };
197
+ }
198
+ function srgbToOklchSimple(r, g, b, alpha) {
199
+ const toLinear = (c) => c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
200
+ const lr = toLinear(r);
201
+ const lg = toLinear(g);
202
+ const lb = toLinear(b);
203
+ const l = 0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb;
204
+ const m = 0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb;
205
+ const s = 0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb;
206
+ const l_ = Math.cbrt(l);
207
+ const m_ = Math.cbrt(m);
208
+ const s_ = Math.cbrt(s);
209
+ const L = 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_;
210
+ const a = 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_;
211
+ const bLab = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_;
212
+ const chroma = Math.sqrt(a * a + bLab * bLab);
213
+ let hue = Math.atan2(bLab, a) * 180 / Math.PI;
214
+ if (hue < 0) hue += 360;
215
+ if (chroma < 1e-8) hue = 0;
216
+ return { l: L, c: chroma, h: hue, alpha };
217
+ }
218
+
219
+ // src/layer.ts
220
+ var DEFAULTS = {
221
+ offsetX: "0px",
222
+ offsetY: "0px",
223
+ blur: "0px",
224
+ spread: "0px",
225
+ color: { l: 0, c: 0, h: 0, alpha: 0.1 },
226
+ inset: false
227
+ };
228
+ function createLayer(config = {}) {
229
+ return __spreadValues(__spreadValues({}, DEFAULTS), config);
230
+ }
231
+ function scaleLayer(layer, factor) {
232
+ return __spreadProps(__spreadValues({}, layer), {
233
+ offsetX: scalePx(layer.offsetX, factor),
234
+ offsetY: scalePx(layer.offsetY, factor),
235
+ blur: scalePx(layer.blur, factor),
236
+ spread: scalePx(layer.spread, factor)
237
+ });
238
+ }
239
+ function setLayerColor(layer, color) {
240
+ return __spreadProps(__spreadValues({}, layer), { color });
241
+ }
242
+ function setLayerOpacity(layer, alpha) {
243
+ return __spreadProps(__spreadValues({}, layer), {
244
+ color: __spreadProps(__spreadValues({}, layer.color), { alpha: clamp(alpha, 0, 1) })
245
+ });
246
+ }
247
+ function offsetLayer(layer, offset) {
248
+ var _a, _b;
249
+ return __spreadProps(__spreadValues({}, layer), {
250
+ offsetX: (_a = offset.x) != null ? _a : layer.offsetX,
251
+ offsetY: (_b = offset.y) != null ? _b : layer.offsetY
252
+ });
253
+ }
254
+ function insetLayer(layer, inset) {
255
+ return __spreadProps(__spreadValues({}, layer), { inset: inset != null ? inset : !layer.inset });
256
+ }
257
+ function scalePx(value, factor) {
258
+ const n = parseFloat(value);
259
+ if (Number.isNaN(n)) return value;
260
+ const scaled = Math.round(n * factor * 100) / 100;
261
+ return `${scaled}px`;
262
+ }
263
+ function clamp(value, min, max) {
264
+ return Math.max(min, Math.min(max, value));
265
+ }
266
+
267
+ // src/compose.ts
268
+ function createShadow(...layers) {
269
+ return { layers };
270
+ }
271
+ function addLayer(shadow, layer) {
272
+ return { layers: [...shadow.layers, layer] };
273
+ }
274
+ function removeLayer(shadow, index) {
275
+ return {
276
+ layers: shadow.layers.filter((_, i) => i !== index)
277
+ };
278
+ }
279
+ function mergeShadows(...shadows) {
280
+ return {
281
+ layers: shadows.flatMap((s) => s.layers)
282
+ };
283
+ }
284
+ function scaleShadow(shadow, factor) {
285
+ return {
286
+ layers: shadow.layers.map((layer) => scaleLayer(layer, factor))
287
+ };
288
+ }
289
+ function colorShadow(shadow, color, preserveAlpha = true) {
290
+ return {
291
+ layers: shadow.layers.map((layer) => {
292
+ const newColor = preserveAlpha ? __spreadProps(__spreadValues({}, color), { alpha: layer.color.alpha }) : color;
293
+ return setLayerColor(layer, newColor);
294
+ })
295
+ };
296
+ }
297
+ function multiplyAlpha(shadow, factor) {
298
+ return {
299
+ layers: shadow.layers.map((layer) => __spreadProps(__spreadValues({}, layer), {
300
+ color: __spreadProps(__spreadValues({}, layer.color), {
301
+ alpha: Math.max(0, Math.min(1, layer.color.alpha * factor))
302
+ })
303
+ }))
304
+ };
305
+ }
306
+
307
+ // src/elevation.ts
308
+ var GEOMETRY = {
309
+ xs: [
310
+ ["0px", "1px", "2px", "0px", 0.051]
311
+ ],
312
+ sm: [
313
+ ["0px", "1px", "3px", "0px", 0.102],
314
+ ["0px", "1px", "2px", "-1px", 0.102]
315
+ ],
316
+ md: [
317
+ ["0px", "4px", "6px", "-1px", 0.102],
318
+ ["0px", "2px", "4px", "-2px", 0.059]
319
+ ],
320
+ lg: [
321
+ ["0px", "12px", "16px", "-4px", 0.078],
322
+ ["0px", "4px", "6px", "-2px", 0.031],
323
+ ["0px", "2px", "2px", "-1px", 0.039]
324
+ ],
325
+ xl: [
326
+ ["0px", "20px", "24px", "-4px", 0.078],
327
+ ["0px", "8px", "8px", "-4px", 0.031],
328
+ ["0px", "3px", "3px", "-1.5px", 0.039]
329
+ ],
330
+ "2xl": [
331
+ ["0px", "24px", "48px", "-12px", 0.18],
332
+ ["0px", "4px", "4px", "-2px", 0.039]
333
+ ],
334
+ "3xl": [
335
+ ["0px", "32px", "64px", "-12px", 0.141],
336
+ ["0px", "5px", "5px", "-2.5px", 0.039]
337
+ ]
338
+ };
339
+ var LEVEL_ORDER = [
340
+ "none",
341
+ "xs",
342
+ "sm",
343
+ "md",
344
+ "lg",
345
+ "xl",
346
+ "2xl",
347
+ "3xl"
348
+ ];
349
+ function buildLayers(geometries, baseColor, alphaMultiplier) {
350
+ return geometries.map(([offsetX, offsetY, blur, spread, alpha]) => ({
351
+ offsetX,
352
+ offsetY,
353
+ blur,
354
+ spread,
355
+ color: __spreadProps(__spreadValues({}, baseColor), {
356
+ alpha: Math.max(0, Math.min(1, alpha * alphaMultiplier))
357
+ }),
358
+ inset: false
359
+ }));
360
+ }
361
+ var BLACK = { l: 0, c: 0, h: 0, alpha: 1 };
362
+ var ELEVATION_PRESETS = Object.fromEntries(
363
+ LEVEL_ORDER.map((level) => {
364
+ if (level === "none") return [level, { layers: [] }];
365
+ return [level, { layers: buildLayers(GEOMETRY[level], BLACK, 1) }];
366
+ })
367
+ );
368
+ function createElevationScale(config) {
369
+ var _a, _b;
370
+ const color = (_a = config == null ? void 0 : config.color) != null ? _a : BLACK;
371
+ const multiplier = (_b = config == null ? void 0 : config.alphaMultiplier) != null ? _b : 1;
372
+ return Object.fromEntries(
373
+ LEVEL_ORDER.map((level) => {
374
+ if (level === "none") return [level, { layers: [] }];
375
+ return [level, { layers: buildLayers(GEOMETRY[level], color, multiplier) }];
376
+ })
377
+ );
378
+ }
379
+ function interpolateElevation(from, to, t) {
380
+ const clamped = Math.max(0, Math.min(1, t));
381
+ const count = Math.min(from.layers.length, to.layers.length);
382
+ if (count === 0) {
383
+ return { layers: [] };
384
+ }
385
+ const layers = [];
386
+ for (let i = 0; i < count; i++) {
387
+ const a = from.layers[i];
388
+ const b = to.layers[i];
389
+ layers.push({
390
+ offsetX: lerpPx(a.offsetX, b.offsetX, clamped),
391
+ offsetY: lerpPx(a.offsetY, b.offsetY, clamped),
392
+ blur: lerpPx(a.blur, b.blur, clamped),
393
+ spread: lerpPx(a.spread, b.spread, clamped),
394
+ color: {
395
+ l: lerp(a.color.l, b.color.l, clamped),
396
+ c: lerp(a.color.c, b.color.c, clamped),
397
+ h: lerpHue(a.color.h, b.color.h, clamped),
398
+ alpha: lerp(a.color.alpha, b.color.alpha, clamped)
399
+ },
400
+ inset: clamped < 0.5 ? a.inset : b.inset
401
+ });
402
+ }
403
+ return { layers };
404
+ }
405
+ function stepElevation(current, direction) {
406
+ const idx = LEVEL_ORDER.indexOf(current);
407
+ if (idx === -1) return current;
408
+ const next = direction === "up" ? idx + 1 : idx - 1;
409
+ const clamped = Math.max(0, Math.min(LEVEL_ORDER.length - 1, next));
410
+ return LEVEL_ORDER[clamped];
411
+ }
412
+ function getElevationLevels() {
413
+ return LEVEL_ORDER;
414
+ }
415
+ function lerp(a, b, t) {
416
+ return Math.round((a + (b - a) * t) * 1e4) / 1e4;
417
+ }
418
+ function lerpPx(a, b, t) {
419
+ const na = parseFloat(a) || 0;
420
+ const nb = parseFloat(b) || 0;
421
+ const result = Math.round((na + (nb - na) * t) * 100) / 100;
422
+ return `${result}px`;
423
+ }
424
+ function lerpHue(a, b, t) {
425
+ let dh = b - a;
426
+ if (dh > 180) dh -= 360;
427
+ if (dh < -180) dh += 360;
428
+ let h = a + dh * t;
429
+ return (h % 360 + 360) % 360;
430
+ }
431
+
432
+ // src/ring.ts
433
+ var DEFAULT_RING = {
434
+ ringWidth: "2px",
435
+ ringOffset: "2px",
436
+ // brand-500 (violet): "60.6% 0.219 293"
437
+ ringColor: { l: 0.606, c: 0.219, h: 293, alpha: 1 },
438
+ // white background
439
+ bgColor: { l: 1, c: 0, h: 0, alpha: 1 }
440
+ };
441
+ var DEFAULT_ERROR_RING = {
442
+ ringWidth: "2px",
443
+ ringOffset: "2px",
444
+ // red-500: "63.7% 0.208 25"
445
+ ringColor: { l: 0.637, c: 0.208, h: 25, alpha: 1 },
446
+ bgColor: { l: 1, c: 0, h: 0, alpha: 1 }
447
+ };
448
+ function createFocusRing(config) {
449
+ const ring = __spreadValues(__spreadValues({}, DEFAULT_RING), config);
450
+ return buildRing(ring);
451
+ }
452
+ function createErrorRing(config) {
453
+ const ring = __spreadValues(__spreadValues({}, DEFAULT_ERROR_RING), config);
454
+ return buildRing(ring);
455
+ }
456
+ function buildRing(config) {
457
+ const offsetStr = config.ringOffset;
458
+ const totalStr = addPx(config.ringOffset, config.ringWidth);
459
+ const gapLayer = {
460
+ offsetX: "0px",
461
+ offsetY: "0px",
462
+ blur: "0px",
463
+ spread: offsetStr,
464
+ color: config.bgColor,
465
+ inset: false
466
+ };
467
+ const ringLayer = {
468
+ offsetX: "0px",
469
+ offsetY: "0px",
470
+ blur: "0px",
471
+ spread: totalStr,
472
+ color: config.ringColor,
473
+ inset: false
474
+ };
475
+ return { layers: [gapLayer, ringLayer] };
476
+ }
477
+ function withFocusRing(shadow, ring) {
478
+ return { layers: [...ring.layers, ...shadow.layers] };
479
+ }
480
+ function colorRing(ringColor) {
481
+ return createFocusRing({ ringColor });
482
+ }
483
+ function addPx(a, b) {
484
+ const na = parseFloat(a) || 0;
485
+ const nb = parseFloat(b) || 0;
486
+ return `${na + nb}px`;
487
+ }
488
+
489
+ // src/format.ts
490
+ var import_color = require("@ariaui/color");
491
+ function layerToString(layer) {
492
+ const parts = [];
493
+ if (layer.inset) parts.push("inset");
494
+ parts.push(layer.offsetX, layer.offsetY, layer.blur, layer.spread);
495
+ parts.push((0, import_color.toOklchString)(layer.color));
496
+ return parts.join(" ");
497
+ }
498
+ function toBoxShadow(shadow) {
499
+ if (shadow.layers.length === 0) return "none";
500
+ return shadow.layers.map(layerToString).join(", ");
501
+ }
502
+ function toCSSProperties(shadow) {
503
+ return { boxShadow: toBoxShadow(shadow) };
504
+ }
505
+ function toTailwindClass(shadow) {
506
+ if (shadow.layers.length === 0) return "shadow-none";
507
+ const value = shadow.layers.map((layer) => {
508
+ const parts = [];
509
+ if (layer.inset) parts.push("inset");
510
+ parts.push(layer.offsetX, layer.offsetY, layer.blur, layer.spread);
511
+ parts.push(formatOklchCompact(layer.color));
512
+ return parts.join("_");
513
+ }).join(",");
514
+ return `shadow-[${value}]`;
515
+ }
516
+ function toCSSDeclaration(shadow) {
517
+ return `box-shadow: ${toBoxShadow(shadow)};`;
518
+ }
519
+ function formatOklchCompact(color) {
520
+ const l = `${round(color.l * 100, 2)}%`;
521
+ const c = round(color.c, 4);
522
+ const h = round(color.h, 2);
523
+ if (color.alpha < 1) {
524
+ return `oklch(${l}_${c}_${h}/${round(color.alpha, 3)})`;
525
+ }
526
+ return `oklch(${l}_${c}_${h})`;
527
+ }
528
+ function round(value, decimals) {
529
+ const f = Math.pow(10, decimals);
530
+ return Math.round(value * f) / f;
531
+ }
532
+
533
+ // src/resolve.ts
534
+ var import_tokens = require("@ariaui/tokens");
535
+ var SHADOW_GEOMETRY = {
536
+ xs: [["0px", "1px", "2px", "0px"]],
537
+ sm: [["0px", "1px", "3px", "0px"], ["0px", "1px", "2px", "-1px"]],
538
+ md: [["0px", "4px", "6px", "-1px"], ["0px", "2px", "4px", "-2px"]],
539
+ lg: [["0px", "12px", "16px", "-4px"], ["0px", "4px", "6px", "-2px"], ["0px", "2px", "2px", "-1px"]],
540
+ xl: [["0px", "20px", "24px", "-4px"], ["0px", "8px", "8px", "-4px"], ["0px", "3px", "3px", "-1.5px"]],
541
+ "2xl": [["0px", "24px", "48px", "-12px"], ["0px", "4px", "4px", "-2px"]],
542
+ "3xl": [["0px", "32px", "64px", "-12px"], ["0px", "5px", "5px", "-2.5px"]]
543
+ };
544
+ var DEPTH_KEYS = {
545
+ xs: ["shadow-xs-depth-1"],
546
+ sm: ["shadow-sm-depth-1", "shadow-sm-depth-2"],
547
+ md: ["shadow-md-depth-1", "shadow-md-depth-2"],
548
+ lg: ["shadow-lg-depth-1", "shadow-lg-depth-2", "shadow-lg-depth-3"],
549
+ xl: ["shadow-xl-depth-1", "shadow-xl-depth-2", "shadow-xl-depth-3"],
550
+ "2xl": ["shadow-2xl-depth-1", "shadow-2xl-depth-2"],
551
+ "3xl": ["shadow-3xl-depth-1", "shadow-3xl-depth-2"]
552
+ };
553
+ function extractAlpha(tokenValue) {
554
+ const match = tokenValue.match(/\/\s*([\d.]+)\s*\)/);
555
+ if (match) return parseFloat(match[1]);
556
+ return 0;
557
+ }
558
+ function resolveBlack() {
559
+ const channels = import_tokens.base["black"];
560
+ return { l: 0, c: 0, h: 0, alpha: 1 };
561
+ }
562
+ function resolveShadow(level, mode = "light") {
563
+ if (level === "none") return { layers: [] };
564
+ const geometry = SHADOW_GEOMETRY[level];
565
+ const depthKeys = DEPTH_KEYS[level];
566
+ const map = mode === "dark" ? import_tokens.dark : import_tokens.light;
567
+ const baseColor = resolveBlack();
568
+ const layers = geometry.map((geo, i) => {
569
+ var _a, _b;
570
+ const depthKey = depthKeys[i];
571
+ const tokenValue = (_b = (_a = map[depthKey]) != null ? _a : import_tokens.light[depthKey]) != null ? _b : "";
572
+ const alpha = extractAlpha(tokenValue);
573
+ return {
574
+ offsetX: geo[0],
575
+ offsetY: geo[1],
576
+ blur: geo[2],
577
+ spread: geo[3],
578
+ color: __spreadProps(__spreadValues({}, baseColor), { alpha }),
579
+ inset: false
580
+ };
581
+ });
582
+ return { layers };
583
+ }
584
+ function resolveAllShadows(mode = "light") {
585
+ const levels = ["none", "xs", "sm", "md", "lg", "xl", "2xl", "3xl"];
586
+ return Object.fromEntries(
587
+ levels.map((level) => [level, resolveShadow(level, mode)])
588
+ );
589
+ }
590
+ function resolveFocusRing(variant = "default") {
591
+ var _a, _b;
592
+ const ringWidth = (_a = import_tokens.light["ring-width"]) != null ? _a : "2px";
593
+ const ringOffset = (_b = import_tokens.light["ring-offset"]) != null ? _b : "2px";
594
+ const ringColorKey = variant === "error" ? "focus-ring-error-color" : "focus-ring-color";
595
+ const ringColorRef = import_tokens.light[ringColorKey];
596
+ const bgColor = { l: 1, c: 0, h: 0, alpha: 1 };
597
+ let ringColor;
598
+ if (variant === "error") {
599
+ ringColor = { l: 0.637, c: 0.208, h: 25, alpha: 1 };
600
+ } else {
601
+ ringColor = { l: 0.606, c: 0.219, h: 293, alpha: 1 };
602
+ }
603
+ return { ringWidth, ringOffset, ringColor, bgColor };
604
+ }
605
+ function resolveLayerAlphas(level, mode = "light") {
606
+ if (level === "none") return [];
607
+ const depthKeys = DEPTH_KEYS[level];
608
+ const map = mode === "dark" ? import_tokens.dark : import_tokens.light;
609
+ return depthKeys.map((key) => {
610
+ var _a, _b;
611
+ const value = (_b = (_a = map[key]) != null ? _a : import_tokens.light[key]) != null ? _b : "";
612
+ return extractAlpha(value);
613
+ });
614
+ }
615
+ function resolveDarkMultiplier(level) {
616
+ if (level === "none") return 1;
617
+ const lightAlphas = resolveLayerAlphas(level, "light");
618
+ const darkAlphas = resolveLayerAlphas(level, "dark");
619
+ if (lightAlphas.length === 0) return 1;
620
+ let totalRatio = 0;
621
+ for (let i = 0; i < lightAlphas.length; i++) {
622
+ if (lightAlphas[i] > 0) {
623
+ totalRatio += darkAlphas[i] / lightAlphas[i];
624
+ }
625
+ }
626
+ return Math.round(totalRatio / lightAlphas.length * 1e3) / 1e3;
627
+ }
628
+ // Annotate the CommonJS export names for ESM import in node:
629
+ 0 && (module.exports = {
630
+ ELEVATION_PRESETS,
631
+ addLayer,
632
+ buildRing,
633
+ colorRing,
634
+ colorShadow,
635
+ createElevationScale,
636
+ createErrorRing,
637
+ createFocusRing,
638
+ createLayer,
639
+ createShadow,
640
+ getElevationLevels,
641
+ insetLayer,
642
+ interpolateElevation,
643
+ layerToString,
644
+ mergeShadows,
645
+ multiplyAlpha,
646
+ offsetLayer,
647
+ parseLayer,
648
+ parseShadow,
649
+ removeLayer,
650
+ resolveAllShadows,
651
+ resolveDarkMultiplier,
652
+ resolveFocusRing,
653
+ resolveLayerAlphas,
654
+ resolveShadow,
655
+ scaleLayer,
656
+ scaleShadow,
657
+ setLayerColor,
658
+ setLayerOpacity,
659
+ stepElevation,
660
+ toBoxShadow,
661
+ toCSSDeclaration,
662
+ toCSSProperties,
663
+ toTailwindClass,
664
+ withFocusRing
665
+ });