@optique/core 1.1.0-dev.2057 → 1.1.0-dev.2069

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.
@@ -835,6 +835,1136 @@ function fileSize(options = {}) {
835
835
  }
836
836
  };
837
837
  }
838
+ const CSS_NAMED_COLORS = {
839
+ aliceblue: {
840
+ r: 240,
841
+ g: 248,
842
+ b: 255,
843
+ a: 1
844
+ },
845
+ antiquewhite: {
846
+ r: 250,
847
+ g: 235,
848
+ b: 215,
849
+ a: 1
850
+ },
851
+ aqua: {
852
+ r: 0,
853
+ g: 255,
854
+ b: 255,
855
+ a: 1
856
+ },
857
+ aquamarine: {
858
+ r: 127,
859
+ g: 255,
860
+ b: 212,
861
+ a: 1
862
+ },
863
+ azure: {
864
+ r: 240,
865
+ g: 255,
866
+ b: 255,
867
+ a: 1
868
+ },
869
+ beige: {
870
+ r: 245,
871
+ g: 245,
872
+ b: 220,
873
+ a: 1
874
+ },
875
+ bisque: {
876
+ r: 255,
877
+ g: 228,
878
+ b: 196,
879
+ a: 1
880
+ },
881
+ black: {
882
+ r: 0,
883
+ g: 0,
884
+ b: 0,
885
+ a: 1
886
+ },
887
+ blanchedalmond: {
888
+ r: 255,
889
+ g: 235,
890
+ b: 205,
891
+ a: 1
892
+ },
893
+ blue: {
894
+ r: 0,
895
+ g: 0,
896
+ b: 255,
897
+ a: 1
898
+ },
899
+ blueviolet: {
900
+ r: 138,
901
+ g: 43,
902
+ b: 226,
903
+ a: 1
904
+ },
905
+ brown: {
906
+ r: 165,
907
+ g: 42,
908
+ b: 42,
909
+ a: 1
910
+ },
911
+ burlywood: {
912
+ r: 222,
913
+ g: 184,
914
+ b: 135,
915
+ a: 1
916
+ },
917
+ cadetblue: {
918
+ r: 95,
919
+ g: 158,
920
+ b: 160,
921
+ a: 1
922
+ },
923
+ chartreuse: {
924
+ r: 127,
925
+ g: 255,
926
+ b: 0,
927
+ a: 1
928
+ },
929
+ chocolate: {
930
+ r: 210,
931
+ g: 105,
932
+ b: 30,
933
+ a: 1
934
+ },
935
+ coral: {
936
+ r: 255,
937
+ g: 127,
938
+ b: 80,
939
+ a: 1
940
+ },
941
+ cornflowerblue: {
942
+ r: 100,
943
+ g: 149,
944
+ b: 237,
945
+ a: 1
946
+ },
947
+ cornsilk: {
948
+ r: 255,
949
+ g: 248,
950
+ b: 220,
951
+ a: 1
952
+ },
953
+ crimson: {
954
+ r: 220,
955
+ g: 20,
956
+ b: 60,
957
+ a: 1
958
+ },
959
+ cyan: {
960
+ r: 0,
961
+ g: 255,
962
+ b: 255,
963
+ a: 1
964
+ },
965
+ darkblue: {
966
+ r: 0,
967
+ g: 0,
968
+ b: 139,
969
+ a: 1
970
+ },
971
+ darkcyan: {
972
+ r: 0,
973
+ g: 139,
974
+ b: 139,
975
+ a: 1
976
+ },
977
+ darkgoldenrod: {
978
+ r: 184,
979
+ g: 134,
980
+ b: 11,
981
+ a: 1
982
+ },
983
+ darkgray: {
984
+ r: 169,
985
+ g: 169,
986
+ b: 169,
987
+ a: 1
988
+ },
989
+ darkgreen: {
990
+ r: 0,
991
+ g: 100,
992
+ b: 0,
993
+ a: 1
994
+ },
995
+ darkgrey: {
996
+ r: 169,
997
+ g: 169,
998
+ b: 169,
999
+ a: 1
1000
+ },
1001
+ darkkhaki: {
1002
+ r: 189,
1003
+ g: 183,
1004
+ b: 107,
1005
+ a: 1
1006
+ },
1007
+ darkmagenta: {
1008
+ r: 139,
1009
+ g: 0,
1010
+ b: 139,
1011
+ a: 1
1012
+ },
1013
+ darkolivegreen: {
1014
+ r: 85,
1015
+ g: 107,
1016
+ b: 47,
1017
+ a: 1
1018
+ },
1019
+ darkorange: {
1020
+ r: 255,
1021
+ g: 140,
1022
+ b: 0,
1023
+ a: 1
1024
+ },
1025
+ darkorchid: {
1026
+ r: 153,
1027
+ g: 50,
1028
+ b: 204,
1029
+ a: 1
1030
+ },
1031
+ darkred: {
1032
+ r: 139,
1033
+ g: 0,
1034
+ b: 0,
1035
+ a: 1
1036
+ },
1037
+ darksalmon: {
1038
+ r: 233,
1039
+ g: 150,
1040
+ b: 122,
1041
+ a: 1
1042
+ },
1043
+ darkseagreen: {
1044
+ r: 143,
1045
+ g: 188,
1046
+ b: 143,
1047
+ a: 1
1048
+ },
1049
+ darkslateblue: {
1050
+ r: 72,
1051
+ g: 61,
1052
+ b: 139,
1053
+ a: 1
1054
+ },
1055
+ darkslategray: {
1056
+ r: 47,
1057
+ g: 79,
1058
+ b: 79,
1059
+ a: 1
1060
+ },
1061
+ darkslategrey: {
1062
+ r: 47,
1063
+ g: 79,
1064
+ b: 79,
1065
+ a: 1
1066
+ },
1067
+ darkturquoise: {
1068
+ r: 0,
1069
+ g: 206,
1070
+ b: 209,
1071
+ a: 1
1072
+ },
1073
+ darkviolet: {
1074
+ r: 148,
1075
+ g: 0,
1076
+ b: 211,
1077
+ a: 1
1078
+ },
1079
+ deeppink: {
1080
+ r: 255,
1081
+ g: 20,
1082
+ b: 147,
1083
+ a: 1
1084
+ },
1085
+ deepskyblue: {
1086
+ r: 0,
1087
+ g: 191,
1088
+ b: 255,
1089
+ a: 1
1090
+ },
1091
+ dimgray: {
1092
+ r: 105,
1093
+ g: 105,
1094
+ b: 105,
1095
+ a: 1
1096
+ },
1097
+ dimgrey: {
1098
+ r: 105,
1099
+ g: 105,
1100
+ b: 105,
1101
+ a: 1
1102
+ },
1103
+ dodgerblue: {
1104
+ r: 30,
1105
+ g: 144,
1106
+ b: 255,
1107
+ a: 1
1108
+ },
1109
+ firebrick: {
1110
+ r: 178,
1111
+ g: 34,
1112
+ b: 34,
1113
+ a: 1
1114
+ },
1115
+ floralwhite: {
1116
+ r: 255,
1117
+ g: 250,
1118
+ b: 240,
1119
+ a: 1
1120
+ },
1121
+ forestgreen: {
1122
+ r: 34,
1123
+ g: 139,
1124
+ b: 34,
1125
+ a: 1
1126
+ },
1127
+ fuchsia: {
1128
+ r: 255,
1129
+ g: 0,
1130
+ b: 255,
1131
+ a: 1
1132
+ },
1133
+ gainsboro: {
1134
+ r: 220,
1135
+ g: 220,
1136
+ b: 220,
1137
+ a: 1
1138
+ },
1139
+ ghostwhite: {
1140
+ r: 248,
1141
+ g: 248,
1142
+ b: 255,
1143
+ a: 1
1144
+ },
1145
+ gold: {
1146
+ r: 255,
1147
+ g: 215,
1148
+ b: 0,
1149
+ a: 1
1150
+ },
1151
+ goldenrod: {
1152
+ r: 218,
1153
+ g: 165,
1154
+ b: 32,
1155
+ a: 1
1156
+ },
1157
+ gray: {
1158
+ r: 128,
1159
+ g: 128,
1160
+ b: 128,
1161
+ a: 1
1162
+ },
1163
+ green: {
1164
+ r: 0,
1165
+ g: 128,
1166
+ b: 0,
1167
+ a: 1
1168
+ },
1169
+ greenyellow: {
1170
+ r: 173,
1171
+ g: 255,
1172
+ b: 47,
1173
+ a: 1
1174
+ },
1175
+ grey: {
1176
+ r: 128,
1177
+ g: 128,
1178
+ b: 128,
1179
+ a: 1
1180
+ },
1181
+ honeydew: {
1182
+ r: 240,
1183
+ g: 255,
1184
+ b: 240,
1185
+ a: 1
1186
+ },
1187
+ hotpink: {
1188
+ r: 255,
1189
+ g: 105,
1190
+ b: 180,
1191
+ a: 1
1192
+ },
1193
+ indianred: {
1194
+ r: 205,
1195
+ g: 92,
1196
+ b: 92,
1197
+ a: 1
1198
+ },
1199
+ indigo: {
1200
+ r: 75,
1201
+ g: 0,
1202
+ b: 130,
1203
+ a: 1
1204
+ },
1205
+ ivory: {
1206
+ r: 255,
1207
+ g: 255,
1208
+ b: 240,
1209
+ a: 1
1210
+ },
1211
+ khaki: {
1212
+ r: 240,
1213
+ g: 230,
1214
+ b: 140,
1215
+ a: 1
1216
+ },
1217
+ lavender: {
1218
+ r: 230,
1219
+ g: 230,
1220
+ b: 250,
1221
+ a: 1
1222
+ },
1223
+ lavenderblush: {
1224
+ r: 255,
1225
+ g: 240,
1226
+ b: 245,
1227
+ a: 1
1228
+ },
1229
+ lawngreen: {
1230
+ r: 124,
1231
+ g: 252,
1232
+ b: 0,
1233
+ a: 1
1234
+ },
1235
+ lemonchiffon: {
1236
+ r: 255,
1237
+ g: 250,
1238
+ b: 205,
1239
+ a: 1
1240
+ },
1241
+ lightblue: {
1242
+ r: 173,
1243
+ g: 216,
1244
+ b: 230,
1245
+ a: 1
1246
+ },
1247
+ lightcoral: {
1248
+ r: 240,
1249
+ g: 128,
1250
+ b: 128,
1251
+ a: 1
1252
+ },
1253
+ lightcyan: {
1254
+ r: 224,
1255
+ g: 255,
1256
+ b: 255,
1257
+ a: 1
1258
+ },
1259
+ lightgoldenrodyellow: {
1260
+ r: 250,
1261
+ g: 250,
1262
+ b: 210,
1263
+ a: 1
1264
+ },
1265
+ lightgray: {
1266
+ r: 211,
1267
+ g: 211,
1268
+ b: 211,
1269
+ a: 1
1270
+ },
1271
+ lightgreen: {
1272
+ r: 144,
1273
+ g: 238,
1274
+ b: 144,
1275
+ a: 1
1276
+ },
1277
+ lightgrey: {
1278
+ r: 211,
1279
+ g: 211,
1280
+ b: 211,
1281
+ a: 1
1282
+ },
1283
+ lightpink: {
1284
+ r: 255,
1285
+ g: 182,
1286
+ b: 193,
1287
+ a: 1
1288
+ },
1289
+ lightsalmon: {
1290
+ r: 255,
1291
+ g: 160,
1292
+ b: 122,
1293
+ a: 1
1294
+ },
1295
+ lightseagreen: {
1296
+ r: 32,
1297
+ g: 178,
1298
+ b: 170,
1299
+ a: 1
1300
+ },
1301
+ lightskyblue: {
1302
+ r: 135,
1303
+ g: 206,
1304
+ b: 250,
1305
+ a: 1
1306
+ },
1307
+ lightslategray: {
1308
+ r: 119,
1309
+ g: 136,
1310
+ b: 153,
1311
+ a: 1
1312
+ },
1313
+ lightslategrey: {
1314
+ r: 119,
1315
+ g: 136,
1316
+ b: 153,
1317
+ a: 1
1318
+ },
1319
+ lightsteelblue: {
1320
+ r: 176,
1321
+ g: 196,
1322
+ b: 222,
1323
+ a: 1
1324
+ },
1325
+ lightyellow: {
1326
+ r: 255,
1327
+ g: 255,
1328
+ b: 224,
1329
+ a: 1
1330
+ },
1331
+ lime: {
1332
+ r: 0,
1333
+ g: 255,
1334
+ b: 0,
1335
+ a: 1
1336
+ },
1337
+ limegreen: {
1338
+ r: 50,
1339
+ g: 205,
1340
+ b: 50,
1341
+ a: 1
1342
+ },
1343
+ linen: {
1344
+ r: 250,
1345
+ g: 240,
1346
+ b: 230,
1347
+ a: 1
1348
+ },
1349
+ magenta: {
1350
+ r: 255,
1351
+ g: 0,
1352
+ b: 255,
1353
+ a: 1
1354
+ },
1355
+ maroon: {
1356
+ r: 128,
1357
+ g: 0,
1358
+ b: 0,
1359
+ a: 1
1360
+ },
1361
+ mediumaquamarine: {
1362
+ r: 102,
1363
+ g: 205,
1364
+ b: 170,
1365
+ a: 1
1366
+ },
1367
+ mediumblue: {
1368
+ r: 0,
1369
+ g: 0,
1370
+ b: 205,
1371
+ a: 1
1372
+ },
1373
+ mediumorchid: {
1374
+ r: 186,
1375
+ g: 85,
1376
+ b: 211,
1377
+ a: 1
1378
+ },
1379
+ mediumpurple: {
1380
+ r: 147,
1381
+ g: 112,
1382
+ b: 219,
1383
+ a: 1
1384
+ },
1385
+ mediumseagreen: {
1386
+ r: 60,
1387
+ g: 179,
1388
+ b: 113,
1389
+ a: 1
1390
+ },
1391
+ mediumslateblue: {
1392
+ r: 123,
1393
+ g: 104,
1394
+ b: 238,
1395
+ a: 1
1396
+ },
1397
+ mediumspringgreen: {
1398
+ r: 0,
1399
+ g: 250,
1400
+ b: 154,
1401
+ a: 1
1402
+ },
1403
+ mediumturquoise: {
1404
+ r: 72,
1405
+ g: 209,
1406
+ b: 204,
1407
+ a: 1
1408
+ },
1409
+ mediumvioletred: {
1410
+ r: 199,
1411
+ g: 21,
1412
+ b: 133,
1413
+ a: 1
1414
+ },
1415
+ midnightblue: {
1416
+ r: 25,
1417
+ g: 25,
1418
+ b: 112,
1419
+ a: 1
1420
+ },
1421
+ mintcream: {
1422
+ r: 245,
1423
+ g: 255,
1424
+ b: 250,
1425
+ a: 1
1426
+ },
1427
+ mistyrose: {
1428
+ r: 255,
1429
+ g: 228,
1430
+ b: 225,
1431
+ a: 1
1432
+ },
1433
+ moccasin: {
1434
+ r: 255,
1435
+ g: 228,
1436
+ b: 181,
1437
+ a: 1
1438
+ },
1439
+ navajowhite: {
1440
+ r: 255,
1441
+ g: 222,
1442
+ b: 173,
1443
+ a: 1
1444
+ },
1445
+ navy: {
1446
+ r: 0,
1447
+ g: 0,
1448
+ b: 128,
1449
+ a: 1
1450
+ },
1451
+ oldlace: {
1452
+ r: 253,
1453
+ g: 245,
1454
+ b: 230,
1455
+ a: 1
1456
+ },
1457
+ olive: {
1458
+ r: 128,
1459
+ g: 128,
1460
+ b: 0,
1461
+ a: 1
1462
+ },
1463
+ olivedrab: {
1464
+ r: 107,
1465
+ g: 142,
1466
+ b: 35,
1467
+ a: 1
1468
+ },
1469
+ orange: {
1470
+ r: 255,
1471
+ g: 165,
1472
+ b: 0,
1473
+ a: 1
1474
+ },
1475
+ orangered: {
1476
+ r: 255,
1477
+ g: 69,
1478
+ b: 0,
1479
+ a: 1
1480
+ },
1481
+ orchid: {
1482
+ r: 218,
1483
+ g: 112,
1484
+ b: 214,
1485
+ a: 1
1486
+ },
1487
+ palegoldenrod: {
1488
+ r: 238,
1489
+ g: 232,
1490
+ b: 170,
1491
+ a: 1
1492
+ },
1493
+ palegreen: {
1494
+ r: 152,
1495
+ g: 251,
1496
+ b: 152,
1497
+ a: 1
1498
+ },
1499
+ paleturquoise: {
1500
+ r: 175,
1501
+ g: 238,
1502
+ b: 238,
1503
+ a: 1
1504
+ },
1505
+ palevioletred: {
1506
+ r: 219,
1507
+ g: 112,
1508
+ b: 147,
1509
+ a: 1
1510
+ },
1511
+ papayawhip: {
1512
+ r: 255,
1513
+ g: 239,
1514
+ b: 213,
1515
+ a: 1
1516
+ },
1517
+ peachpuff: {
1518
+ r: 255,
1519
+ g: 218,
1520
+ b: 185,
1521
+ a: 1
1522
+ },
1523
+ peru: {
1524
+ r: 205,
1525
+ g: 133,
1526
+ b: 63,
1527
+ a: 1
1528
+ },
1529
+ pink: {
1530
+ r: 255,
1531
+ g: 192,
1532
+ b: 203,
1533
+ a: 1
1534
+ },
1535
+ plum: {
1536
+ r: 221,
1537
+ g: 160,
1538
+ b: 221,
1539
+ a: 1
1540
+ },
1541
+ powderblue: {
1542
+ r: 176,
1543
+ g: 224,
1544
+ b: 230,
1545
+ a: 1
1546
+ },
1547
+ purple: {
1548
+ r: 128,
1549
+ g: 0,
1550
+ b: 128,
1551
+ a: 1
1552
+ },
1553
+ rebeccapurple: {
1554
+ r: 102,
1555
+ g: 51,
1556
+ b: 153,
1557
+ a: 1
1558
+ },
1559
+ red: {
1560
+ r: 255,
1561
+ g: 0,
1562
+ b: 0,
1563
+ a: 1
1564
+ },
1565
+ rosybrown: {
1566
+ r: 188,
1567
+ g: 143,
1568
+ b: 143,
1569
+ a: 1
1570
+ },
1571
+ royalblue: {
1572
+ r: 65,
1573
+ g: 105,
1574
+ b: 225,
1575
+ a: 1
1576
+ },
1577
+ saddlebrown: {
1578
+ r: 139,
1579
+ g: 69,
1580
+ b: 19,
1581
+ a: 1
1582
+ },
1583
+ salmon: {
1584
+ r: 250,
1585
+ g: 128,
1586
+ b: 114,
1587
+ a: 1
1588
+ },
1589
+ sandybrown: {
1590
+ r: 244,
1591
+ g: 164,
1592
+ b: 96,
1593
+ a: 1
1594
+ },
1595
+ seagreen: {
1596
+ r: 46,
1597
+ g: 139,
1598
+ b: 87,
1599
+ a: 1
1600
+ },
1601
+ seashell: {
1602
+ r: 255,
1603
+ g: 245,
1604
+ b: 238,
1605
+ a: 1
1606
+ },
1607
+ sienna: {
1608
+ r: 160,
1609
+ g: 82,
1610
+ b: 45,
1611
+ a: 1
1612
+ },
1613
+ silver: {
1614
+ r: 192,
1615
+ g: 192,
1616
+ b: 192,
1617
+ a: 1
1618
+ },
1619
+ skyblue: {
1620
+ r: 135,
1621
+ g: 206,
1622
+ b: 235,
1623
+ a: 1
1624
+ },
1625
+ slateblue: {
1626
+ r: 106,
1627
+ g: 90,
1628
+ b: 205,
1629
+ a: 1
1630
+ },
1631
+ slategray: {
1632
+ r: 112,
1633
+ g: 128,
1634
+ b: 144,
1635
+ a: 1
1636
+ },
1637
+ slategrey: {
1638
+ r: 112,
1639
+ g: 128,
1640
+ b: 144,
1641
+ a: 1
1642
+ },
1643
+ snow: {
1644
+ r: 255,
1645
+ g: 250,
1646
+ b: 250,
1647
+ a: 1
1648
+ },
1649
+ springgreen: {
1650
+ r: 0,
1651
+ g: 255,
1652
+ b: 127,
1653
+ a: 1
1654
+ },
1655
+ steelblue: {
1656
+ r: 70,
1657
+ g: 130,
1658
+ b: 180,
1659
+ a: 1
1660
+ },
1661
+ tan: {
1662
+ r: 210,
1663
+ g: 180,
1664
+ b: 140,
1665
+ a: 1
1666
+ },
1667
+ teal: {
1668
+ r: 0,
1669
+ g: 128,
1670
+ b: 128,
1671
+ a: 1
1672
+ },
1673
+ thistle: {
1674
+ r: 216,
1675
+ g: 191,
1676
+ b: 216,
1677
+ a: 1
1678
+ },
1679
+ tomato: {
1680
+ r: 255,
1681
+ g: 99,
1682
+ b: 71,
1683
+ a: 1
1684
+ },
1685
+ transparent: {
1686
+ r: 0,
1687
+ g: 0,
1688
+ b: 0,
1689
+ a: 0
1690
+ },
1691
+ turquoise: {
1692
+ r: 64,
1693
+ g: 224,
1694
+ b: 208,
1695
+ a: 1
1696
+ },
1697
+ violet: {
1698
+ r: 238,
1699
+ g: 130,
1700
+ b: 238,
1701
+ a: 1
1702
+ },
1703
+ wheat: {
1704
+ r: 245,
1705
+ g: 222,
1706
+ b: 179,
1707
+ a: 1
1708
+ },
1709
+ white: {
1710
+ r: 255,
1711
+ g: 255,
1712
+ b: 255,
1713
+ a: 1
1714
+ },
1715
+ whitesmoke: {
1716
+ r: 245,
1717
+ g: 245,
1718
+ b: 245,
1719
+ a: 1
1720
+ },
1721
+ yellow: {
1722
+ r: 255,
1723
+ g: 255,
1724
+ b: 0,
1725
+ a: 1
1726
+ },
1727
+ yellowgreen: {
1728
+ r: 154,
1729
+ g: 205,
1730
+ b: 50,
1731
+ a: 1
1732
+ }
1733
+ };
1734
+ const CSS_NAMED_COLOR_KEYS = Object.keys(CSS_NAMED_COLORS);
1735
+ function hslToRgb(h, s, l) {
1736
+ h = (h % 360 + 360) % 360;
1737
+ const a = s * Math.min(l, 1 - l);
1738
+ const f = (n) => {
1739
+ const k = (n + h / 30) % 12;
1740
+ return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
1741
+ };
1742
+ return [
1743
+ Math.round(f(0) * 255),
1744
+ Math.round(f(8) * 255),
1745
+ Math.round(f(4) * 255)
1746
+ ];
1747
+ }
1748
+ function rgbToHsl(r, g, b) {
1749
+ const rn = r / 255, gn = g / 255, bn = b / 255;
1750
+ const max = Math.max(rn, gn, bn);
1751
+ const min = Math.min(rn, gn, bn);
1752
+ const l = (max + min) / 2;
1753
+ if (max === min) return [
1754
+ 0,
1755
+ 0,
1756
+ l * 100
1757
+ ];
1758
+ const d = max - min;
1759
+ const s = l > .5 ? d / (2 - max - min) : d / (max + min);
1760
+ let h;
1761
+ if (max === rn) h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;
1762
+ else if (max === gn) h = ((bn - rn) / d + 2) / 6;
1763
+ else h = ((rn - gn) / d + 4) / 6;
1764
+ return [
1765
+ h * 360,
1766
+ s * 100,
1767
+ l * 100
1768
+ ];
1769
+ }
1770
+ const COLOR_HEX_SHORT_REGEX = /^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])?$/;
1771
+ const COLOR_HEX_LONG_REGEX = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?$/;
1772
+ const COLOR_NUM_PATTERN = "(?:\\d+(?:\\.\\d*)?|\\d*\\.\\d+)";
1773
+ const COLOR_HUE_PATTERN = `(?:-?${COLOR_NUM_PATTERN})`;
1774
+ const COLOR_RGB_REGEX = new RegExp(`^rgba?\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*(?:,\\s*(${COLOR_NUM_PATTERN}))?\\s*\\)$`, "i");
1775
+ const COLOR_HSL_REGEX = new RegExp(`^hsla?\\(\\s*(${COLOR_HUE_PATTERN})\\s*,\\s*(${COLOR_NUM_PATTERN})%\\s*,\\s*(${COLOR_NUM_PATTERN})%\\s*(?:,\\s*(${COLOR_NUM_PATTERN}))?\\s*\\)$`, "i");
1776
+ const VALID_COLOR_FORMATS = [
1777
+ "hex",
1778
+ "rgb",
1779
+ "hsl",
1780
+ "named"
1781
+ ];
1782
+ /**
1783
+ * Creates a value parser that accepts CSS color strings and returns a
1784
+ * structured {@link Color} object with normalized RGBA components.
1785
+ *
1786
+ * Supported input notations by default:
1787
+ * - Hex: `#rgb`, `#rrggbb`, `#rgba`, `#rrggbbaa`
1788
+ * - RGB: `rgb(r, g, b)`, `rgba(r, g, b, a)`
1789
+ * - HSL: `hsl(h, s%, l%)`, `hsla(h, s%, l%, a)`
1790
+ * - Named: all 148 CSS Level 4 named colors (e.g., `red`, `rebeccapurple`)
1791
+ *
1792
+ * The `format()` method always outputs canonical lowercase hex
1793
+ * (`#rrggbb` when fully opaque, `#rrggbbaa` otherwise).
1794
+ *
1795
+ * @param options Configuration options for the parser.
1796
+ * @returns A sync value parser producing {@link Color} objects.
1797
+ * @throws {TypeError} If {@link ColorOptions.metavar} is an empty string, or
1798
+ * if {@link ColorOptions.formats} contains an invalid format name.
1799
+ * @throws {RangeError} If {@link ValueParser.format} is called with a
1800
+ * {@link Color} whose `r`, `g`, or `b` channel is not an integer in
1801
+ * 0–255, or whose `a` channel is not a finite number in 0–1.
1802
+ * @since 1.1.0
1803
+ */
1804
+ function color(options = {}) {
1805
+ const metavar = options.metavar ?? "COLOR";
1806
+ require_nonempty.ensureNonEmptyString(metavar);
1807
+ if (options.formats !== void 0) {
1808
+ for (const fmt of options.formats) if (!VALID_COLOR_FORMATS.includes(fmt)) throw new TypeError(`Expected formats to contain only ${VALID_COLOR_FORMATS.map((v) => JSON.stringify(v)).join(", ")}, but got: ${JSON.stringify(fmt)}.`);
1809
+ }
1810
+ const allowedFormats = options.formats ?? VALID_COLOR_FORMATS;
1811
+ const allowHex = allowedFormats.includes("hex");
1812
+ const allowRgb = allowedFormats.includes("rgb");
1813
+ const allowHsl = allowedFormats.includes("hsl");
1814
+ const allowNamed = allowedFormats.includes("named");
1815
+ const defaultPlaceholder = {
1816
+ r: 0,
1817
+ g: 0,
1818
+ b: 0,
1819
+ a: 1
1820
+ };
1821
+ const formatExamples = [
1822
+ ...allowHex ? ["#ff0000"] : [],
1823
+ ...allowRgb ? ["rgb(255, 0, 0)"] : [],
1824
+ ...allowHsl ? ["hsl(0, 100%, 50%)"] : [],
1825
+ ...allowNamed ? ["red"] : []
1826
+ ];
1827
+ function invalidFormatError(input) {
1828
+ return {
1829
+ success: false,
1830
+ error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : require_message.message`Expected a CSS color like ${require_message.valueSet(formatExamples, {
1831
+ fallback: "a valid color",
1832
+ type: "disjunction"
1833
+ })}, but got ${input}.`
1834
+ };
1835
+ }
1836
+ return {
1837
+ mode: "sync",
1838
+ metavar,
1839
+ placeholder: options.placeholder ?? defaultPlaceholder,
1840
+ parse(input) {
1841
+ const trimmed = input.trim();
1842
+ if (allowHex) {
1843
+ let m = COLOR_HEX_LONG_REGEX.exec(trimmed);
1844
+ if (m != null) {
1845
+ const r = parseInt(m[1], 16);
1846
+ const g = parseInt(m[2], 16);
1847
+ const b = parseInt(m[3], 16);
1848
+ const a = m[4] !== void 0 ? parseInt(m[4], 16) / 255 : 1;
1849
+ return {
1850
+ success: true,
1851
+ value: {
1852
+ r,
1853
+ g,
1854
+ b,
1855
+ a
1856
+ }
1857
+ };
1858
+ }
1859
+ m = COLOR_HEX_SHORT_REGEX.exec(trimmed);
1860
+ if (m != null) {
1861
+ const r = parseInt(m[1] + m[1], 16);
1862
+ const g = parseInt(m[2] + m[2], 16);
1863
+ const b = parseInt(m[3] + m[3], 16);
1864
+ const a = m[4] !== void 0 ? parseInt(m[4] + m[4], 16) / 255 : 1;
1865
+ return {
1866
+ success: true,
1867
+ value: {
1868
+ r,
1869
+ g,
1870
+ b,
1871
+ a
1872
+ }
1873
+ };
1874
+ }
1875
+ }
1876
+ if (allowRgb) {
1877
+ const m = COLOR_RGB_REGEX.exec(trimmed);
1878
+ if (m != null) {
1879
+ const r = parseInt(m[1], 10);
1880
+ const g = parseInt(m[2], 10);
1881
+ const b = parseInt(m[3], 10);
1882
+ const aRaw = m[4] !== void 0 ? parseFloat(m[4]) : 1;
1883
+ if (r > 255 || g > 255 || b > 255 || !Number.isFinite(aRaw) || aRaw < 0 || aRaw > 1) return invalidFormatError(input);
1884
+ const a = Math.round(aRaw * 255) / 255;
1885
+ return {
1886
+ success: true,
1887
+ value: {
1888
+ r,
1889
+ g,
1890
+ b,
1891
+ a
1892
+ }
1893
+ };
1894
+ }
1895
+ }
1896
+ if (allowHsl) {
1897
+ const m = COLOR_HSL_REGEX.exec(trimmed);
1898
+ if (m != null) {
1899
+ const h = parseFloat(m[1]);
1900
+ const s = parseFloat(m[2]);
1901
+ const l = parseFloat(m[3]);
1902
+ const aRaw = m[4] !== void 0 ? parseFloat(m[4]) : 1;
1903
+ if (!Number.isFinite(h) || !Number.isFinite(s) || s < 0 || s > 100 || !Number.isFinite(l) || l < 0 || l > 100 || !Number.isFinite(aRaw) || aRaw < 0 || aRaw > 1) return invalidFormatError(input);
1904
+ const [r, g, b] = hslToRgb(h, s / 100, l / 100);
1905
+ const a = Math.round(aRaw * 255) / 255;
1906
+ return {
1907
+ success: true,
1908
+ value: {
1909
+ r,
1910
+ g,
1911
+ b,
1912
+ a
1913
+ }
1914
+ };
1915
+ }
1916
+ }
1917
+ if (allowNamed) {
1918
+ const key = trimmed.toLowerCase();
1919
+ if (Object.hasOwn(CSS_NAMED_COLORS, key)) return {
1920
+ success: true,
1921
+ value: { ...CSS_NAMED_COLORS[key] }
1922
+ };
1923
+ }
1924
+ return invalidFormatError(input);
1925
+ },
1926
+ format(value) {
1927
+ const { r, g, b, a } = value;
1928
+ if (!Number.isInteger(r) || r < 0 || r > 255 || !Number.isInteger(g) || g < 0 || g > 255 || !Number.isInteger(b) || b < 0 || b > 255 || !Number.isFinite(a) || a < 0 || a > 1) throw new RangeError(`Color components out of range: r=${r}, g=${g}, b=${b}, a=${a}.`);
1929
+ const aStr = parseFloat(a.toFixed(4));
1930
+ if (allowHex) {
1931
+ const rh = r.toString(16).padStart(2, "0");
1932
+ const gh = g.toString(16).padStart(2, "0");
1933
+ const bh = b.toString(16).padStart(2, "0");
1934
+ if (a === 1) return `#${rh}${gh}${bh}`;
1935
+ const ah = Math.round(a * 255).toString(16).padStart(2, "0");
1936
+ return `#${rh}${gh}${bh}${ah}`;
1937
+ }
1938
+ if (allowRgb) return a === 1 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${aStr})`;
1939
+ if (allowHsl) {
1940
+ const [h, s, l] = rgbToHsl(r, g, b);
1941
+ const hStr = parseFloat(h.toFixed(4));
1942
+ const sStr = parseFloat(s.toFixed(4));
1943
+ const lStr = parseFloat(l.toFixed(4));
1944
+ return a === 1 ? `hsl(${hStr}, ${sStr}%, ${lStr}%)` : `hsla(${hStr}, ${sStr}%, ${lStr}%, ${aStr})`;
1945
+ }
1946
+ for (const [name, c] of Object.entries(CSS_NAMED_COLORS)) if (c.r === r && c.g === g && c.b === b && c.a === a) return name;
1947
+ throw new RangeError(`No CSS named color matches { r: ${r}, g: ${g}, b: ${b}, a: ${a} }.`);
1948
+ },
1949
+ normalize(value) {
1950
+ if (!Number.isInteger(value.r) || value.r < 0 || value.r > 255 || !Number.isInteger(value.g) || value.g < 0 || value.g > 255 || !Number.isInteger(value.b) || value.b < 0 || value.b > 255 || !Number.isFinite(value.a) || value.a < 0 || value.a > 1) return value;
1951
+ const a = Math.round(value.a * 255) / 255;
1952
+ return a === value.a ? value : {
1953
+ ...value,
1954
+ a
1955
+ };
1956
+ },
1957
+ *suggest(prefix) {
1958
+ if (allowNamed) {
1959
+ const lowerPrefix = prefix.toLowerCase();
1960
+ for (const name of CSS_NAMED_COLOR_KEYS) if (name.startsWith(lowerPrefix)) yield {
1961
+ kind: "literal",
1962
+ text: name
1963
+ };
1964
+ }
1965
+ }
1966
+ };
1967
+ }
838
1968
  /**
839
1969
  * The set of URL schemes that are considered "special" by the WHATWG URL
840
1970
  * Standard. These schemes always use the `://` authority syntax.
@@ -4014,12 +5144,104 @@ function cidr(options) {
4014
5144
  });
4015
5145
  return cidrParserObj;
4016
5146
  }
5147
+ const SEMVER_REGEX = /^(?<prefix>v)?(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<pre>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<meta>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
5148
+ const SEMVER_SUGGESTIONS = Object.freeze([
5149
+ "0.0.0",
5150
+ "1.0.0",
5151
+ "1.0.0-alpha",
5152
+ "1.0.0-alpha.1",
5153
+ "1.0.0+build.1",
5154
+ "1.0.0-alpha.1+build.1"
5155
+ ]);
5156
+ const SEMVER_SUGGESTIONS_WITH_PREFIX = Object.freeze([...SEMVER_SUGGESTIONS, ...SEMVER_SUGGESTIONS.map((s) => `v${s}`)]);
5157
+ function semVer(options = {}) {
5158
+ const metavar = options.metavar ?? "SEMVER";
5159
+ require_nonempty.ensureNonEmptyString(metavar);
5160
+ checkEnumOption(options, "type", ["string", "object"]);
5161
+ checkBooleanOption(options, "allowPrefix");
5162
+ const allowPrefix = options.allowPrefix ?? false;
5163
+ const objectMode = options.type === "object";
5164
+ const errorOption = options.errors?.invalidSemVer;
5165
+ const suggestions = allowPrefix ? SEMVER_SUGGESTIONS_WITH_PREFIX : SEMVER_SUGGESTIONS;
5166
+ function makeError(input) {
5167
+ return {
5168
+ success: false,
5169
+ error: errorOption ? typeof errorOption === "function" ? errorOption(input) : errorOption : require_message.message`Expected a valid Semantic Versioning 2.0.0 string (e.g. ${"1.0.0"}), but got ${input}.`
5170
+ };
5171
+ }
5172
+ if (objectMode) return {
5173
+ mode: "sync",
5174
+ metavar,
5175
+ placeholder: {
5176
+ major: 0,
5177
+ minor: 0,
5178
+ patch: 0
5179
+ },
5180
+ parse(input) {
5181
+ const m = SEMVER_REGEX.exec(input);
5182
+ if (m == null) return makeError(input);
5183
+ if (!allowPrefix && m.groups.prefix != null) return makeError(input);
5184
+ const major = parseInt(m.groups.major, 10);
5185
+ const minor = parseInt(m.groups.minor, 10);
5186
+ const patch = parseInt(m.groups.patch, 10);
5187
+ if (!Number.isSafeInteger(major) || !Number.isSafeInteger(minor) || !Number.isSafeInteger(patch)) return makeError(input);
5188
+ const result = {
5189
+ major,
5190
+ minor,
5191
+ patch,
5192
+ ...m.groups.pre != null ? { preRelease: m.groups.pre } : {},
5193
+ ...m.groups.meta != null ? { metadata: m.groups.meta } : {}
5194
+ };
5195
+ return {
5196
+ success: true,
5197
+ value: result
5198
+ };
5199
+ },
5200
+ format(value) {
5201
+ let s = `${value.major}.${value.minor}.${value.patch}`;
5202
+ if (value.preRelease != null) s += `-${value.preRelease}`;
5203
+ if (value.metadata != null) s += `+${value.metadata}`;
5204
+ return s;
5205
+ },
5206
+ *suggest(prefix) {
5207
+ for (const s of suggestions) if (s.startsWith(prefix)) yield {
5208
+ kind: "literal",
5209
+ text: s
5210
+ };
5211
+ }
5212
+ };
5213
+ return {
5214
+ mode: "sync",
5215
+ metavar,
5216
+ placeholder: "0.0.0",
5217
+ parse(input) {
5218
+ const m = SEMVER_REGEX.exec(input);
5219
+ if (m == null) return makeError(input);
5220
+ if (!allowPrefix && m.groups.prefix != null) return makeError(input);
5221
+ const canonical = `${m.groups.major}.${m.groups.minor}.${m.groups.patch}` + (m.groups.pre != null ? `-${m.groups.pre}` : "") + (m.groups.meta != null ? `+${m.groups.meta}` : "");
5222
+ return {
5223
+ success: true,
5224
+ value: canonical
5225
+ };
5226
+ },
5227
+ format(value) {
5228
+ return value;
5229
+ },
5230
+ *suggest(prefix) {
5231
+ for (const s of suggestions) if (s.startsWith(prefix)) yield {
5232
+ kind: "literal",
5233
+ text: s
5234
+ };
5235
+ }
5236
+ };
5237
+ }
4017
5238
 
4018
5239
  //#endregion
4019
5240
  exports.checkBooleanOption = checkBooleanOption;
4020
5241
  exports.checkEnumOption = checkEnumOption;
4021
5242
  exports.choice = choice;
4022
5243
  exports.cidr = cidr;
5244
+ exports.color = color;
4023
5245
  exports.domain = domain;
4024
5246
  exports.email = email;
4025
5247
  exports.ensureNonEmptyString = require_nonempty.ensureNonEmptyString;
@@ -4036,6 +5258,7 @@ exports.locale = locale;
4036
5258
  exports.macAddress = macAddress;
4037
5259
  exports.port = port;
4038
5260
  exports.portRange = portRange;
5261
+ exports.semVer = semVer;
4039
5262
  exports.socketAddress = socketAddress;
4040
5263
  exports.string = string;
4041
5264
  exports.url = url;