@tetrax/squircle 1.0.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.
package/dist/core.js ADDED
@@ -0,0 +1,629 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/core/index.ts
21
+ var core_exports = {};
22
+ __export(core_exports, {
23
+ computeSquirclePath: () => computeSquirclePath,
24
+ drawSquircleRect: () => drawSquircleRect,
25
+ getSvgPath: () => getSvgPath,
26
+ parseSquircleClasses: () => parseSquircleClasses
27
+ });
28
+ module.exports = __toCommonJS(core_exports);
29
+
30
+ // src/core/squircle-path.ts
31
+ function toRadians(deg) {
32
+ return deg * Math.PI / 180;
33
+ }
34
+ function rounded(strings, ...values) {
35
+ return strings.reduce((acc, str, i) => {
36
+ const value = values[i];
37
+ return typeof value === "number" ? acc + str + value.toFixed(4) : acc + str + (value ?? "");
38
+ }, "");
39
+ }
40
+ function getPathParamsForCorner({
41
+ cornerRadius,
42
+ cornerSmoothing,
43
+ preserveSmoothing,
44
+ roundingAndSmoothingBudget
45
+ }) {
46
+ if (cornerRadius <= 0 || roundingAndSmoothingBudget <= 0) {
47
+ return { a: 0, b: 0, c: 0, d: 0, p: 0, cornerRadius: 0, arcSectionLength: 0 };
48
+ }
49
+ let p = (1 + cornerSmoothing) * cornerRadius;
50
+ if (!preserveSmoothing) {
51
+ const maxCornerSmoothing = roundingAndSmoothingBudget / cornerRadius - 1;
52
+ cornerSmoothing = Math.min(cornerSmoothing, maxCornerSmoothing);
53
+ p = Math.min(p, roundingAndSmoothingBudget);
54
+ }
55
+ const arcMeasure = 90 * (1 - cornerSmoothing);
56
+ const arcSectionLength = Math.sin(toRadians(arcMeasure / 2)) * cornerRadius * Math.sqrt(2);
57
+ const angleAlpha = (90 - arcMeasure) / 2;
58
+ const p3ToP4Distance = cornerRadius * Math.tan(toRadians(angleAlpha / 2));
59
+ const angleBeta = 45 * cornerSmoothing;
60
+ const c = p3ToP4Distance * Math.cos(toRadians(angleBeta));
61
+ const d = c * Math.tan(toRadians(angleBeta));
62
+ let b = (p - arcSectionLength - c - d) / 3;
63
+ let a = 2 * b;
64
+ if (preserveSmoothing && p > roundingAndSmoothingBudget) {
65
+ const p1ToP3MaxDistance = roundingAndSmoothingBudget - d - arcSectionLength - c;
66
+ const minA = p1ToP3MaxDistance / 6;
67
+ const maxB = p1ToP3MaxDistance - minA;
68
+ b = Math.min(b, maxB);
69
+ a = p1ToP3MaxDistance - b;
70
+ p = Math.min(p, roundingAndSmoothingBudget);
71
+ }
72
+ return { a, b, c, d, p, arcSectionLength, cornerRadius };
73
+ }
74
+ function drawTopRightPath({ cornerRadius, a, b, c, d, p, arcSectionLength }) {
75
+ if (cornerRadius) {
76
+ return rounded`c ${a} 0 ${a + b} 0 ${a + b + c} ${d} a ${cornerRadius} ${cornerRadius} 0 0 1 ${arcSectionLength} ${arcSectionLength} c ${d} ${c} ${d} ${b + c} ${d} ${a + b + c}`;
77
+ }
78
+ return rounded`l ${p} 0`;
79
+ }
80
+ function drawBottomRightPath({ cornerRadius, a, b, c, d, p, arcSectionLength }) {
81
+ if (cornerRadius) {
82
+ return rounded`c 0 ${a} 0 ${a + b} ${-d} ${a + b + c} a ${cornerRadius} ${cornerRadius} 0 0 1 ${-arcSectionLength} ${arcSectionLength} c ${-c} ${d} ${-(b + c)} ${d} ${-(a + b + c)} ${d}`;
83
+ }
84
+ return rounded`l 0 ${p}`;
85
+ }
86
+ function drawBottomLeftPath({ cornerRadius, a, b, c, d, p, arcSectionLength }) {
87
+ if (cornerRadius) {
88
+ return rounded`c ${-a} 0 ${-(a + b)} 0 ${-(a + b + c)} ${-d} a ${cornerRadius} ${cornerRadius} 0 0 1 ${-arcSectionLength} ${-arcSectionLength} c ${-d} ${-c} ${-d} ${-(b + c)} ${-d} ${-(a + b + c)}`;
89
+ }
90
+ return rounded`l ${-p} 0`;
91
+ }
92
+ function drawTopLeftPath({ cornerRadius, a, b, c, d, p, arcSectionLength }) {
93
+ if (cornerRadius) {
94
+ return rounded`c 0 ${-a} 0 ${-(a + b)} ${d} ${-(a + b + c)} a ${cornerRadius} ${cornerRadius} 0 0 1 ${arcSectionLength} ${-arcSectionLength} c ${c} ${-d} ${b + c} ${-d} ${a + b + c} ${-d}`;
95
+ }
96
+ return rounded`l 0 ${-p}`;
97
+ }
98
+ function getSVGPathFromPathParams({
99
+ width,
100
+ height,
101
+ topLeftPathParams,
102
+ topRightPathParams,
103
+ bottomRightPathParams,
104
+ bottomLeftPathParams
105
+ }) {
106
+ return `
107
+ M ${width - topRightPathParams.p} 0
108
+ ${drawTopRightPath(topRightPathParams)}
109
+ L ${width} ${height - bottomRightPathParams.p}
110
+ ${drawBottomRightPath(bottomRightPathParams)}
111
+ L ${bottomLeftPathParams.p} ${height}
112
+ ${drawBottomLeftPath(bottomLeftPathParams)}
113
+ L 0 ${topLeftPathParams.p}
114
+ ${drawTopLeftPath(topLeftPathParams)}
115
+ Z
116
+ `.replace(/[\t\s\n]+/g, " ").trim();
117
+ }
118
+ var adjacentsByCorner = {
119
+ topLeft: [
120
+ { corner: "topRight", side: "top" },
121
+ { corner: "bottomLeft", side: "left" }
122
+ ],
123
+ topRight: [
124
+ { corner: "topLeft", side: "top" },
125
+ { corner: "bottomRight", side: "right" }
126
+ ],
127
+ bottomLeft: [
128
+ { corner: "bottomRight", side: "bottom" },
129
+ { corner: "topLeft", side: "left" }
130
+ ],
131
+ bottomRight: [
132
+ { corner: "bottomLeft", side: "bottom" },
133
+ { corner: "topRight", side: "right" }
134
+ ]
135
+ };
136
+ function distributeAndNormalize({
137
+ topLeftCornerRadius,
138
+ topRightCornerRadius,
139
+ bottomRightCornerRadius,
140
+ bottomLeftCornerRadius,
141
+ width,
142
+ height
143
+ }) {
144
+ const roundingAndSmoothingBudgetMap = {
145
+ topLeft: -1,
146
+ topRight: -1,
147
+ bottomLeft: -1,
148
+ bottomRight: -1
149
+ };
150
+ const cornerRadiusMap = {
151
+ topLeft: topLeftCornerRadius,
152
+ topRight: topRightCornerRadius,
153
+ bottomLeft: bottomLeftCornerRadius,
154
+ bottomRight: bottomRightCornerRadius
155
+ };
156
+ Object.entries(cornerRadiusMap).sort(([, r1], [, r2]) => r2 - r1).forEach(([corner, radius]) => {
157
+ const adjacents = adjacentsByCorner[corner];
158
+ const budget = Math.min(
159
+ ...adjacents.map((adj) => {
160
+ const adjRadius = cornerRadiusMap[adj.corner];
161
+ if (radius === 0 && adjRadius === 0) return 0;
162
+ const adjBudget = roundingAndSmoothingBudgetMap[adj.corner];
163
+ const sideLen = adj.side === "top" || adj.side === "bottom" ? width : height;
164
+ return adjBudget >= 0 ? sideLen - roundingAndSmoothingBudgetMap[adj.corner] : radius / (radius + adjRadius) * sideLen;
165
+ })
166
+ );
167
+ roundingAndSmoothingBudgetMap[corner] = budget;
168
+ cornerRadiusMap[corner] = Math.min(radius, budget);
169
+ });
170
+ return {
171
+ topLeft: { radius: cornerRadiusMap.topLeft, roundingAndSmoothingBudget: roundingAndSmoothingBudgetMap.topLeft },
172
+ topRight: { radius: cornerRadiusMap.topRight, roundingAndSmoothingBudget: roundingAndSmoothingBudgetMap.topRight },
173
+ bottomLeft: { radius: cornerRadiusMap.bottomLeft, roundingAndSmoothingBudget: roundingAndSmoothingBudgetMap.bottomLeft },
174
+ bottomRight: { radius: cornerRadiusMap.bottomRight, roundingAndSmoothingBudget: roundingAndSmoothingBudgetMap.bottomRight }
175
+ };
176
+ }
177
+ function drawPureBezierTopRight(r) {
178
+ if (r <= 0) return "";
179
+ return rounded`c ${0.3 * r} 0 ${0.473 * r} 0 ${0.619 * r} ${0.039 * r} c ${0.185 * r} ${0.049 * r} ${0.293 * r} ${0.157 * r} ${0.342 * r} ${0.342 * r} c ${0.039 * r} ${0.146 * r} ${0.039 * r} ${0.319 * r} ${0.039 * r} ${0.619 * r}`;
180
+ }
181
+ function drawPureBezierBottomRight(r) {
182
+ if (r <= 0) return "";
183
+ return rounded`c 0 ${0.3 * r} 0 ${0.473 * r} ${-0.039 * r} ${0.619 * r} c ${-0.049 * r} ${0.185 * r} ${-0.157 * r} ${0.293 * r} ${-0.342 * r} ${0.342 * r} c ${-0.146 * r} ${0.039 * r} ${-0.319 * r} ${0.039 * r} ${-0.619 * r} ${0.039 * r}`;
184
+ }
185
+ function drawPureBezierBottomLeft(r) {
186
+ if (r <= 0) return "";
187
+ return rounded`c ${-0.3 * r} 0 ${-0.473 * r} 0 ${-0.619 * r} ${-0.039 * r} c ${-0.185 * r} ${-0.049 * r} ${-0.293 * r} ${-0.157 * r} ${-0.342 * r} ${-0.342 * r} c ${-0.039 * r} ${-0.146 * r} ${-0.039 * r} ${-0.319 * r} ${-0.039 * r} ${-0.619 * r}`;
188
+ }
189
+ function drawPureBezierTopLeft(r) {
190
+ if (r <= 0) return "";
191
+ return rounded`c 0 ${-0.3 * r} 0 ${-0.473 * r} ${0.039 * r} ${-0.619 * r} c ${0.049 * r} ${-0.185 * r} ${0.157 * r} ${-0.293 * r} ${0.342 * r} ${-0.342 * r} c ${0.146 * r} ${-0.039 * r} ${0.319 * r} ${-0.039 * r} ${0.619 * r} ${-0.039 * r}`;
192
+ }
193
+ function getPureBezierSVGPath(width, height, tl, tr, br, bl) {
194
+ return `
195
+ M ${width - tr} 0
196
+ ${drawPureBezierTopRight(tr)}
197
+ L ${width} ${height - br}
198
+ ${drawPureBezierBottomRight(br)}
199
+ L ${bl} ${height}
200
+ ${drawPureBezierBottomLeft(bl)}
201
+ L 0 ${tl}
202
+ ${drawPureBezierTopLeft(tl)}
203
+ Z
204
+ `.replace(/[\t\s\n]+/g, " ").trim();
205
+ }
206
+ function getSvgPath({
207
+ cornerRadius = 0,
208
+ topLeftCornerRadius,
209
+ topRightCornerRadius,
210
+ bottomRightCornerRadius,
211
+ bottomLeftCornerRadius,
212
+ cornerSmoothing = 1,
213
+ width,
214
+ height,
215
+ preserveSmoothing = false,
216
+ g2Continuous = false
217
+ }) {
218
+ const tl = topLeftCornerRadius ?? cornerRadius;
219
+ const tr = topRightCornerRadius ?? cornerRadius;
220
+ const bl = bottomLeftCornerRadius ?? cornerRadius;
221
+ const br = bottomRightCornerRadius ?? cornerRadius;
222
+ if (g2Continuous) {
223
+ const { topLeft: topLeft2, topRight: topRight2, bottomLeft: bottomLeft2, bottomRight: bottomRight2 } = distributeAndNormalize({
224
+ topLeftCornerRadius: tl,
225
+ topRightCornerRadius: tr,
226
+ bottomRightCornerRadius: br,
227
+ bottomLeftCornerRadius: bl,
228
+ width,
229
+ height
230
+ });
231
+ return getPureBezierSVGPath(
232
+ width,
233
+ height,
234
+ topLeft2.radius,
235
+ topRight2.radius,
236
+ bottomRight2.radius,
237
+ bottomLeft2.radius
238
+ );
239
+ }
240
+ if (tl === tr && tr === br && br === bl) {
241
+ const roundingAndSmoothingBudget = Math.min(width, height) / 2;
242
+ const clampedRadius = Math.min(tl, roundingAndSmoothingBudget);
243
+ const params = getPathParamsForCorner({
244
+ cornerRadius: clampedRadius,
245
+ cornerSmoothing,
246
+ preserveSmoothing,
247
+ roundingAndSmoothingBudget
248
+ });
249
+ return getSVGPathFromPathParams({
250
+ width,
251
+ height,
252
+ topLeftPathParams: params,
253
+ topRightPathParams: params,
254
+ bottomLeftPathParams: params,
255
+ bottomRightPathParams: params
256
+ });
257
+ }
258
+ const { topLeft, topRight, bottomLeft, bottomRight } = distributeAndNormalize({
259
+ topLeftCornerRadius: tl,
260
+ topRightCornerRadius: tr,
261
+ bottomRightCornerRadius: br,
262
+ bottomLeftCornerRadius: bl,
263
+ width,
264
+ height
265
+ });
266
+ return getSVGPathFromPathParams({
267
+ width,
268
+ height,
269
+ topLeftPathParams: getPathParamsForCorner({ cornerSmoothing, preserveSmoothing, cornerRadius: topLeft.radius, roundingAndSmoothingBudget: topLeft.roundingAndSmoothingBudget }),
270
+ topRightPathParams: getPathParamsForCorner({ cornerSmoothing, preserveSmoothing, cornerRadius: topRight.radius, roundingAndSmoothingBudget: topRight.roundingAndSmoothingBudget }),
271
+ bottomRightPathParams: getPathParamsForCorner({ cornerSmoothing, preserveSmoothing, cornerRadius: bottomRight.radius, roundingAndSmoothingBudget: bottomRight.roundingAndSmoothingBudget }),
272
+ bottomLeftPathParams: getPathParamsForCorner({ cornerSmoothing, preserveSmoothing, cornerRadius: bottomLeft.radius, roundingAndSmoothingBudget: bottomLeft.roundingAndSmoothingBudget })
273
+ });
274
+ }
275
+ function computeSquirclePath(width, height, cornerRadius, cornerSmoothing = 1, preserveSmoothing = false, g2Continuous = false) {
276
+ if (width <= 0 || height <= 0 || cornerRadius <= 0) return "";
277
+ return getSvgPath({ width, height, cornerRadius, cornerSmoothing, preserveSmoothing, g2Continuous });
278
+ }
279
+ function drawSquircleRect(ctx, x, y, width, height, cornerRadius, smoothing = 1) {
280
+ let tlR = 0, trR = 0, brR = 0, blR = 0;
281
+ if (typeof cornerRadius === "number") {
282
+ tlR = trR = brR = blR = cornerRadius;
283
+ } else if (cornerRadius) {
284
+ tlR = cornerRadius.tl ?? 0;
285
+ trR = cornerRadius.tr ?? 0;
286
+ brR = cornerRadius.br ?? 0;
287
+ blR = cornerRadius.bl ?? 0;
288
+ }
289
+ const { topLeft, topRight, bottomLeft, bottomRight } = distributeAndNormalize({
290
+ topLeftCornerRadius: tlR,
291
+ topRightCornerRadius: trR,
292
+ bottomRightCornerRadius: brR,
293
+ bottomLeftCornerRadius: blR,
294
+ width,
295
+ height
296
+ });
297
+ const rTL = topLeft.radius;
298
+ const rTR = topRight.radius;
299
+ const rBR = bottomRight.radius;
300
+ const rBL = bottomLeft.radius;
301
+ const left = x;
302
+ const top = y;
303
+ const right = x + width;
304
+ const bottom = y + height;
305
+ ctx.moveTo(left + rTL, top);
306
+ ctx.lineTo(right - rTR, top);
307
+ if (rTR > 0) {
308
+ ctx.bezierCurveTo(
309
+ right - rTR + 0.3 * rTR,
310
+ top,
311
+ right - rTR + 0.473 * rTR,
312
+ top,
313
+ right - rTR + 0.619 * rTR,
314
+ top + 0.039 * rTR
315
+ );
316
+ ctx.bezierCurveTo(
317
+ right - rTR + 0.804 * rTR,
318
+ top + 0.088 * rTR,
319
+ right - rTR + 0.961 * rTR,
320
+ top + 0.196 * rTR,
321
+ right,
322
+ top + rTR - 0.619 * rTR
323
+ );
324
+ ctx.bezierCurveTo(
325
+ right,
326
+ top + rTR - 0.319 * rTR,
327
+ right,
328
+ top + rTR - 0.146 * rTR,
329
+ right,
330
+ top + rTR
331
+ );
332
+ }
333
+ ctx.lineTo(right, bottom - rBR);
334
+ if (rBR > 0) {
335
+ ctx.bezierCurveTo(
336
+ right,
337
+ bottom - rBR + 0.3 * rBR,
338
+ right,
339
+ bottom - rBR + 0.473 * rBR,
340
+ right - 0.039 * rBR,
341
+ bottom - rBR + 0.619 * rBR
342
+ );
343
+ ctx.bezierCurveTo(
344
+ right - 0.088 * rBR,
345
+ bottom - rBR + 0.804 * rBR,
346
+ right - 0.196 * rBR,
347
+ bottom - rBR + 0.961 * rBR,
348
+ right - rBR + 0.619 * rBR,
349
+ bottom
350
+ );
351
+ ctx.bezierCurveTo(
352
+ right - rBR + 0.319 * rBR,
353
+ bottom,
354
+ right - rBR + 0.146 * rBR,
355
+ bottom,
356
+ right - rBR,
357
+ bottom
358
+ );
359
+ }
360
+ ctx.lineTo(left + rBL, bottom);
361
+ if (rBL > 0) {
362
+ ctx.bezierCurveTo(
363
+ left + rBL - 0.3 * rBL,
364
+ bottom,
365
+ left + rBL - 0.473 * rBL,
366
+ bottom,
367
+ left + rBL - 0.619 * rBL,
368
+ bottom - 0.039 * rBL
369
+ );
370
+ ctx.bezierCurveTo(
371
+ left + rBL - 0.804 * rBL,
372
+ bottom - 0.088 * rBL,
373
+ left + rBL - 0.961 * rBL,
374
+ bottom - 0.196 * rBL,
375
+ left,
376
+ bottom - rBL + 0.619 * rBL
377
+ );
378
+ ctx.bezierCurveTo(
379
+ left,
380
+ bottom - rBL + 0.319 * rBL,
381
+ left,
382
+ bottom - rBL + 0.146 * rBL,
383
+ left,
384
+ bottom - rBL
385
+ );
386
+ }
387
+ ctx.lineTo(left, top + rTL);
388
+ if (rTL > 0) {
389
+ ctx.bezierCurveTo(
390
+ left,
391
+ top + rTL - 0.3 * rTL,
392
+ left,
393
+ top + rTL - 0.473 * rTL,
394
+ left + 0.039 * rTL,
395
+ top + rTL - 0.619 * rTL
396
+ );
397
+ ctx.bezierCurveTo(
398
+ left + 0.088 * rTL,
399
+ top + rTL - 0.804 * rTL,
400
+ left + 0.196 * rTL,
401
+ top + rTL - 0.961 * rTL,
402
+ left + rTL - 0.619 * rTL,
403
+ top
404
+ );
405
+ ctx.bezierCurveTo(
406
+ left + rTL - 0.319 * rTL,
407
+ top,
408
+ left + rTL - 0.146 * rTL,
409
+ top,
410
+ left + rTL,
411
+ top
412
+ );
413
+ }
414
+ ctx.closePath();
415
+ }
416
+
417
+ // src/core/class-parser.ts
418
+ var ROUNDED_RE = /^rounded-squircle-(\d+)$/;
419
+ var SMOOTHING_RE = /^corner-smoothing-(\d{1,3})$/;
420
+ var SQUIRCLE_BORDER_WIDTH_RE = /^squircle-border-(\d+(\.\d+)?)$/;
421
+ var TW_BORDER_COLOR_RE = /^border-(\[.+\]|[\w-]+)(\/(\d+))?$/;
422
+ var TW_BORDER_WIDTH_RE = /^border-(\d+)$/;
423
+ var TW_BORDER_BASE_RE = /^border$/;
424
+ var BORDER_COLORS = {
425
+ "gray-50": "#f9fafb",
426
+ "gray-100": "#f3f4f6",
427
+ "gray-200": "#e5e7eb",
428
+ "gray-300": "#d1d5db",
429
+ "gray-400": "#9ca3af",
430
+ "gray-500": "#6b7280",
431
+ "gray-600": "#4b5563",
432
+ "gray-700": "#374151",
433
+ "gray-800": "#1f2937",
434
+ "gray-900": "#111827",
435
+ "slate-50": "#f8fafc",
436
+ "slate-100": "#f1f5f9",
437
+ "slate-200": "#e2e8f0",
438
+ "slate-300": "#cbd5e1",
439
+ "slate-400": "#94a3b8",
440
+ "slate-500": "#64748b",
441
+ "slate-600": "#475569",
442
+ "slate-700": "#334155",
443
+ "slate-800": "#1e293b",
444
+ "slate-900": "#0f172a",
445
+ "red-50": "#fef2f2",
446
+ "red-100": "#fee2e2",
447
+ "red-200": "#fecaca",
448
+ "red-300": "#fca5a5",
449
+ "red-400": "#f87171",
450
+ "red-500": "#ef4444",
451
+ "red-600": "#dc2626",
452
+ "red-700": "#b91c1c",
453
+ "red-800": "#991b1b",
454
+ "red-900": "#7f1d1d",
455
+ "blue-50": "#eff6ff",
456
+ "blue-100": "#dbeafe",
457
+ "blue-200": "#bfdbfe",
458
+ "blue-300": "#93c5fd",
459
+ "blue-400": "#60a5fa",
460
+ "blue-500": "#3b82f6",
461
+ "blue-600": "#2563eb",
462
+ "blue-700": "#1d4ed8",
463
+ "blue-800": "#1e40af",
464
+ "blue-900": "#1e3a8a",
465
+ "green-50": "#f0fdf4",
466
+ "green-100": "#dcfce7",
467
+ "green-200": "#bbf7d0",
468
+ "green-300": "#86efac",
469
+ "green-400": "#4ade80",
470
+ "green-500": "#22c55e",
471
+ "green-600": "#16a34a",
472
+ "green-700": "#15803d",
473
+ "green-800": "#166534",
474
+ "green-900": "#14532d",
475
+ "yellow-50": "#fefce8",
476
+ "yellow-100": "#fef9c3",
477
+ "yellow-200": "#fef08a",
478
+ "yellow-300": "#fde047",
479
+ "yellow-400": "#facc15",
480
+ "yellow-500": "#eab308",
481
+ "yellow-600": "#ca8a04",
482
+ "yellow-700": "#a16207",
483
+ "yellow-800": "#854d0e",
484
+ "yellow-900": "#713f12",
485
+ "purple-50": "#faf5ff",
486
+ "purple-100": "#f3e8ff",
487
+ "purple-200": "#e9d5ff",
488
+ "purple-300": "#d8b4fe",
489
+ "purple-400": "#c084fc",
490
+ "purple-500": "#a855f7",
491
+ "purple-600": "#9333ea",
492
+ "purple-700": "#7e22ce",
493
+ "purple-800": "#6b21a8",
494
+ "purple-900": "#581c87",
495
+ "pink-50": "#fdf2f8",
496
+ "pink-100": "#fce7f3",
497
+ "pink-200": "#fbcfe8",
498
+ "pink-300": "#f9a8d4",
499
+ "pink-400": "#f472b6",
500
+ "pink-500": "#ec4899",
501
+ "pink-600": "#db2777",
502
+ "pink-700": "#be185d",
503
+ "pink-800": "#9d174d",
504
+ "pink-900": "#831843",
505
+ "orange-50": "#fff7ed",
506
+ "orange-100": "#ffedd5",
507
+ "orange-200": "#fed7aa",
508
+ "orange-300": "#fdba74",
509
+ "orange-400": "#fb923c",
510
+ "orange-500": "#f97316",
511
+ "orange-600": "#ea580c",
512
+ "orange-700": "#c2410c",
513
+ "orange-800": "#9a3412",
514
+ "orange-900": "#7c2d12",
515
+ "teal-50": "#f0fdfa",
516
+ "teal-100": "#ccfbf1",
517
+ "teal-200": "#99f6e4",
518
+ "teal-300": "#5eead4",
519
+ "teal-400": "#2dd4bf",
520
+ "teal-500": "#14b8a6",
521
+ "teal-600": "#0d9488",
522
+ "teal-700": "#0f766e",
523
+ "teal-800": "#115e59",
524
+ "teal-900": "#134e4a",
525
+ white: "#ffffff",
526
+ black: "#000000",
527
+ transparent: "transparent"
528
+ };
529
+ function hexToRgba(hex, opacity) {
530
+ const h = hex.replace(/#/g, "");
531
+ const r = parseInt(h.substring(0, 2), 16);
532
+ const g = parseInt(h.substring(2, 4), 16);
533
+ const b = parseInt(h.substring(4, 6), 16);
534
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
535
+ }
536
+ function resolveColorToken(token, opacity) {
537
+ if (token.startsWith("[") && token.endsWith("]")) {
538
+ const raw = token.slice(1, -1);
539
+ if (opacity !== void 0 && raw.startsWith("#")) {
540
+ return hexToRgba(raw, opacity);
541
+ }
542
+ return raw;
543
+ }
544
+ const hex = BORDER_COLORS[token];
545
+ if (!hex) return null;
546
+ if (opacity !== void 0) return hexToRgba(hex, opacity);
547
+ return hex;
548
+ }
549
+ function parseSquircleClasses(className = "") {
550
+ const classes = className.split(/\s+/).filter(Boolean);
551
+ let cornerRadius = null;
552
+ let cornerSmoothing = 1;
553
+ let squircleBorder = false;
554
+ let borderColor = null;
555
+ let borderWidth = null;
556
+ let g2Continuous = false;
557
+ const rest = [];
558
+ for (const cls of classes) {
559
+ let matched = false;
560
+ let m = cls.match(ROUNDED_RE);
561
+ if (m) {
562
+ cornerRadius = Number(m[1]);
563
+ matched = true;
564
+ }
565
+ if (!matched) {
566
+ m = cls.match(SMOOTHING_RE);
567
+ if (m) {
568
+ cornerSmoothing = Math.min(100, Math.max(0, Number(m[1]))) / 100;
569
+ matched = true;
570
+ }
571
+ }
572
+ if (!matched && cls === "squircle-border") {
573
+ squircleBorder = true;
574
+ matched = true;
575
+ }
576
+ if (!matched && cls === "squircle-g2") {
577
+ g2Continuous = true;
578
+ matched = true;
579
+ }
580
+ if (!matched) {
581
+ m = cls.match(SQUIRCLE_BORDER_WIDTH_RE);
582
+ if (m) {
583
+ squircleBorder = true;
584
+ borderWidth = Number(m[1]);
585
+ matched = true;
586
+ }
587
+ }
588
+ if (!matched && squircleBorder) {
589
+ m = cls.match(TW_BORDER_WIDTH_RE);
590
+ if (m) {
591
+ borderWidth = Number(m[1]);
592
+ matched = true;
593
+ }
594
+ if (!matched && cls.match(TW_BORDER_BASE_RE)) {
595
+ borderWidth = 1;
596
+ matched = true;
597
+ }
598
+ if (!matched) {
599
+ m = cls.match(TW_BORDER_COLOR_RE);
600
+ if (m) {
601
+ const colorToken = m[1];
602
+ const opacityPercent = m[3] ? Number(m[3]) / 100 : void 0;
603
+ const resolved = resolveColorToken(colorToken, opacityPercent);
604
+ if (resolved) {
605
+ borderColor = resolved;
606
+ matched = true;
607
+ }
608
+ }
609
+ }
610
+ }
611
+ if (!matched) rest.push(cls);
612
+ }
613
+ return {
614
+ cornerRadius,
615
+ cornerSmoothing,
616
+ squircleBorder,
617
+ borderColor,
618
+ borderWidth: borderWidth ?? 1,
619
+ g2Continuous,
620
+ restClasses: rest.join(" ")
621
+ };
622
+ }
623
+ // Annotate the CommonJS export names for ESM import in node:
624
+ 0 && (module.exports = {
625
+ computeSquirclePath,
626
+ drawSquircleRect,
627
+ getSvgPath,
628
+ parseSquircleClasses
629
+ });