UNPKG

64.1 kBJavaScriptView Raw
1// src/internal/util.ts
2var includes = (value, search) => !!~value.indexOf(search);
3var join = (parts, separator = "-") => parts.join(separator);
4var joinTruthy = (parts, separator) => join(parts.filter(Boolean), separator);
5var tail = (array, startIndex = 1) => array.slice(startIndex);
6var identity = (value) => value;
7var noop = () => {
8};
9var capitalize = (value) => value[0].toUpperCase() + tail(value);
10var hyphenate = (value) => value.replace(/[A-Z]/g, "-$&").toLowerCase();
11var evalThunk = (value, context) => {
12 while (typeof value == "function") {
13 value = value(context);
14 }
15 return value;
16};
17var ensureMaxSize = (map, max) => {
18 if (map.size > max) {
19 map.delete(map.keys().next().value);
20 }
21};
22var isCSSProperty = (key, value) => !includes("@:&", key[0]) && (includes("rg", (typeof value)[5]) || Array.isArray(value));
23var merge = (target, source, context) => source ? Object.keys(source).reduce((target2, key) => {
24 const value = evalThunk(source[key], context);
25 if (isCSSProperty(key, value)) {
26 target2[hyphenate(key)] = value;
27 } else {
28 target2[key] = key[0] == "@" && includes("figa", key[1]) ? (target2[key] || []).concat(value) : merge(target2[key] || {}, value, context);
29 }
30 return target2;
31}, target) : target;
32var escape = typeof CSS !== "undefined" && CSS.escape || ((className) => className.replace(/[!"'`*+.,;:\\/<=>?@#$%&^|~()[\]{}]/g, "\\$&").replace(/^\d/, "\\3$& "));
33var buildMediaQuery = (screen) => {
34 if (!Array.isArray(screen)) {
35 screen = [screen];
36 }
37 return "@media " + join(screen.map((screen2) => {
38 if (typeof screen2 == "string") {
39 screen2 = {min: screen2};
40 }
41 return screen2.raw || join(Object.keys(screen2).map((feature) => `(${feature}-width:${screen2[feature]})`), " and ");
42 }), ",");
43};
44var cyrb32 = (value) => {
45 for (var h = 9, index = value.length; index--; ) {
46 h = Math.imul(h ^ value.charCodeAt(index), 1597334677);
47 }
48 return "tw-" + ((h ^ h >>> 9) >>> 0).toString(36);
49};
50var sortedInsertionIndex = (array, element) => {
51 for (var low = 0, high = array.length; low < high; ) {
52 const pivot = high + low >> 1;
53 if (array[pivot] <= element) {
54 low = pivot + 1;
55 } else {
56 high = pivot;
57 }
58 }
59 return high;
60};
61
62// src/twind/parse.ts
63var groupings;
64var rules;
65var startGrouping = (value = "") => {
66 groupings.push(value);
67 return "";
68};
69var endGrouping = (isWhitespace) => {
70 groupings.length = Math.max(groupings.lastIndexOf("") + ~~isWhitespace, 0);
71};
72var onlyPrefixes = (s) => s && !includes("!:", s[0]);
73var onlyVariants = (s) => s[0] == ":";
74var addRule = (directive2, negate) => {
75 rules.push({
76 v: groupings.filter(onlyVariants),
77 d: directive2,
78 n: negate,
79 i: includes(groupings, "!"),
80 $: ""
81 });
82};
83var saveRule = (buffer) => {
84 const negate = buffer[0] == "-";
85 if (negate) {
86 buffer = tail(buffer);
87 }
88 const prefix = join(groupings.filter(onlyPrefixes));
89 addRule(buffer == "&" ? prefix : (prefix && prefix + "-") + buffer, negate);
90 return "";
91};
92var parseString = (token, isVariant) => {
93 let buffer = "";
94 for (let char, dynamic = false, position2 = 0; char = token[position2++]; ) {
95 if (dynamic || char == "[") {
96 buffer += char;
97 dynamic = char != "]";
98 continue;
99 }
100 switch (char) {
101 case ":":
102 buffer = buffer && startGrouping(":" + (token[position2] == char ? token[position2++] : "") + buffer);
103 break;
104 case "(":
105 buffer = buffer && startGrouping(buffer);
106 startGrouping();
107 break;
108 case "!":
109 startGrouping(char);
110 break;
111 case ")":
112 case " ":
113 case " ":
114 case "\n":
115 case "\r":
116 buffer = buffer && saveRule(buffer);
117 endGrouping(char !== ")");
118 break;
119 default:
120 buffer += char;
121 }
122 }
123 if (buffer) {
124 if (isVariant) {
125 startGrouping(":" + buffer);
126 } else if (buffer.slice(-1) == "-") {
127 startGrouping(buffer.slice(0, -1));
128 } else {
129 saveRule(buffer);
130 }
131 }
132};
133var parseGroupedToken = (token) => {
134 startGrouping();
135 parseToken(token);
136 endGrouping();
137};
138var parseGroup = (key, token) => {
139 if (token) {
140 startGrouping();
141 const isVariant = includes("tbu", (typeof token)[1]);
142 parseString(key, isVariant);
143 if (isVariant) {
144 parseGroupedToken(token);
145 }
146 endGrouping();
147 }
148};
149var parseToken = (token) => {
150 switch (typeof token) {
151 case "string":
152 parseString(token);
153 break;
154 case "function":
155 addRule(token);
156 break;
157 case "object":
158 if (Array.isArray(token)) {
159 token.forEach(parseGroupedToken);
160 } else if (token) {
161 Object.keys(token).forEach((key) => {
162 parseGroup(key, token[key]);
163 });
164 }
165 }
166};
167var staticsCaches = new WeakMap();
168var buildStatics = (strings) => {
169 let statics = staticsCaches.get(strings);
170 if (!statics) {
171 let slowModeIndex = NaN;
172 let buffer = "";
173 statics = strings.map((token, index) => {
174 if (slowModeIndex !== slowModeIndex && (token.slice(-1) == "[" || includes(":-(", (strings[index + 1] || "")[0]))) {
175 slowModeIndex = index;
176 }
177 if (index >= slowModeIndex) {
178 return (interpolation) => {
179 if (index == slowModeIndex) {
180 buffer = "";
181 }
182 buffer += token;
183 if (includes("rg", (typeof interpolation)[5])) {
184 buffer += interpolation;
185 } else if (interpolation) {
186 parseString(buffer);
187 buffer = "";
188 parseToken(interpolation);
189 }
190 if (index == strings.length - 1) {
191 parseString(buffer);
192 }
193 };
194 }
195 const staticRules = rules = [];
196 parseString(token);
197 const activeGroupings = [...groupings];
198 rules = [];
199 return (interpolation) => {
200 rules.push(...staticRules);
201 groupings = [...activeGroupings];
202 if (interpolation) {
203 parseToken(interpolation);
204 }
205 };
206 });
207 staticsCaches.set(strings, statics);
208 }
209 return statics;
210};
211var parse = (tokens) => {
212 groupings = [];
213 rules = [];
214 if (Array.isArray(tokens[0]) && Array.isArray(tokens[0].raw)) {
215 buildStatics(tokens[0]).forEach((apply2, index) => apply2(tokens[index + 1]));
216 } else {
217 parseToken(tokens);
218 }
219 return rules;
220};
221
222// src/twind/directive.ts
223var isFunctionFree;
224var detectFunction = (key, value) => {
225 if (typeof value == "function") {
226 isFunctionFree = false;
227 }
228 return value;
229};
230var stringify = (data) => {
231 isFunctionFree = true;
232 const key = JSON.stringify(data, detectFunction);
233 return isFunctionFree && key;
234};
235var cacheByFactory = new WeakMap();
236var directive = (factory, data) => {
237 const key = stringify(data);
238 let directive2;
239 if (key) {
240 var cache = cacheByFactory.get(factory);
241 if (!cache) {
242 cacheByFactory.set(factory, cache = new Map());
243 }
244 directive2 = cache.get(key);
245 }
246 if (!directive2) {
247 directive2 = Object.defineProperty((params, context) => {
248 context = Array.isArray(params) ? context : params;
249 return evalThunk(factory(data, context), context);
250 }, "toJSON", {
251 value: () => key || data
252 });
253 if (cache) {
254 cache.set(key, directive2);
255 ensureMaxSize(cache, 1e4);
256 }
257 }
258 return directive2;
259};
260
261// src/twind/apply.ts
262var applyFactory = (tokens, {css}) => css(parse(tokens));
263var apply = (...tokens) => directive(applyFactory, tokens);
264
265// src/twind/helpers.ts
266var positions = (resolve) => (value, position2, prefix, suffix) => {
267 if (value) {
268 const properties = position2 && resolve(position2);
269 if (properties && properties.length > 0) {
270 return properties.reduce((declarations, property2) => {
271 declarations[joinTruthy([prefix, property2, suffix])] = value;
272 return declarations;
273 }, {});
274 }
275 }
276};
277var corners = /* @__PURE__ */ positions((key) => ({
278 t: ["top-left", "top-right"],
279 r: ["top-right", "bottom-right"],
280 b: ["bottom-left", "bottom-right"],
281 l: ["bottom-left", "top-left"],
282 tl: ["top-left"],
283 tr: ["top-right"],
284 bl: ["bottom-left"],
285 br: ["bottom-right"]
286})[key]);
287var expandEdges = (key) => {
288 const parts = ({x: "lr", y: "tb"}[key] || key || "").split("").sort();
289 for (let index = parts.length; index--; ) {
290 if (!(parts[index] = {
291 t: "top",
292 r: "right",
293 b: "bottom",
294 l: "left"
295 }[parts[index]]))
296 return;
297 }
298 if (parts.length)
299 return parts;
300};
301var edges = /* @__PURE__ */ positions(expandEdges);
302
303// src/twind/plugins.ts
304var _;
305var __;
306var $;
307var toColumnsOrRows = (x) => x == "cols" ? "columns" : "rows";
308var property = (property2) => (params, context, id) => ({
309 [property2]: id + ((_ = join(params)) && "-" + _)
310});
311var propertyValue = (property2, separator) => (params, context, id) => (_ = join(params, separator)) && {
312 [property2 || id]: _
313};
314var themeProperty = (section) => (params, {theme: theme2}, id) => (_ = theme2(section || id, params)) && {
315 [section || id]: _
316};
317var themePropertyFallback = (section, separator) => (params, {theme: theme2}, id) => (_ = theme2(section || id, params, join(params, separator))) && {
318 [section || id]: _
319};
320var alias = (handler, name) => (params, context) => handler(params, context, name);
321var display = property("display");
322var position = property("position");
323var textTransform = property("textTransform");
324var textDecoration = property("textDecoration");
325var fontStyle = property("fontStyle");
326var fontVariantNumeric = (key) => (params, context, id) => ({
327 ["--tw-" + key]: id,
328 fontVariantNumeric: "var(--tw-ordinal,/*!*/ /*!*/) var(--tw-slashed-zero,/*!*/ /*!*/) var(--tw-numeric-figure,/*!*/ /*!*/) var(--tw-numeric-spacing,/*!*/ /*!*/) var(--tw-numeric-fraction,/*!*/ /*!*/)"
329});
330var inset = (params, {theme: theme2}, id) => (_ = theme2("inset", params)) && {[id]: _};
331var opacityProperty = (params, theme2, id, section = id) => (_ = theme2(section + "Opacity", tail(params))) && {
332 [`--tw-${id}-opacity`]: _
333};
334var parseColorComponent = (chars, factor) => Math.round(parseInt(chars, 16) * factor);
335var asRGBA = (color, opacityProperty2, opacityDefault) => {
336 if (color && color[0] == "#" && (_ = (color.length - 1) / 3) && ($ = [17, 1, 0.062272][_ - 1])) {
337 return `rgba(${parseColorComponent(color.substr(1, _), $)},${parseColorComponent(color.substr(1 + _, _), $)},${parseColorComponent(color.substr(1 + 2 * _, _), $)},${opacityProperty2 ? `var(--tw-${opacityProperty2}${opacityDefault ? "," + opacityDefault : ""})` : opacityDefault || 1})`;
338 }
339 return color;
340};
341var withOpacityFallback = (property2, kind, color) => color && typeof color == "string" ? (_ = asRGBA(color, kind + "-opacity")) && _ !== color ? {
342 [`--tw-${kind}-opacity`]: "1",
343 [property2]: [color, _]
344} : {[property2]: color} : void 0;
345var transparentTo = (color) => ($ = asRGBA(color, "", "0")) == _ ? "transparent" : $;
346var reversableEdge = (params, {theme: theme2}, id, section, prefix, suffix) => (_ = {x: ["right", "left"], y: ["bottom", "top"]}[params[0]]) && ($ = `--tw-${id}-${params[0]}-reverse`) ? params[1] == "reverse" ? {
347 [$]: "1"
348} : {
349 [$]: "0",
350 [joinTruthy([prefix, _[0], suffix])]: (__ = theme2(section, tail(params))) && `calc(${__} * var(${$}))`,
351 [joinTruthy([prefix, _[1], suffix])]: __ && [__, `calc(${__} * calc(1 - var(${$})))`]
352} : void 0;
353var placeHelper = (property2, params) => params[0] && {
354 [property2]: (includes("wun", (params[0] || "")[3]) ? "space-" : "") + params[0]
355};
356var contentPluginFor = (property2) => (params) => includes(["start", "end"], params[0]) ? {[property2]: "flex-" + params[0]} : placeHelper(property2, params);
357var gridPlugin = (kind) => (params, {theme: theme2}) => {
358 if (_ = theme2("grid" + capitalize(kind), params, "")) {
359 return {["grid-" + kind]: _};
360 }
361 switch (params[0]) {
362 case "span":
363 return params[1] && {
364 ["grid-" + kind]: `span ${params[1]} / span ${params[1]}`
365 };
366 case "start":
367 case "end":
368 return (_ = theme2("grid" + capitalize(kind) + capitalize(params[0]), tail(params), join(tail(params)))) && {
369 [`grid-${kind}-${params[0]}`]: _
370 };
371 }
372};
373var border = (params, {theme: theme2}, id) => {
374 switch (params[0]) {
375 case "solid":
376 case "dashed":
377 case "dotted":
378 case "double":
379 case "none":
380 return propertyValue("borderStyle")(params);
381 case "collapse":
382 case "separate":
383 return propertyValue("borderCollapse")(params);
384 case "opacity":
385 return opacityProperty(params, theme2, id);
386 }
387 return (_ = theme2(id + "Width", params, "")) ? {borderWidth: _} : withOpacityFallback("borderColor", id, theme2(id + "Color", params));
388};
389var transform = (gpu) => (gpu ? "translate3d(var(--tw-translate-x,0),var(--tw-translate-y,0),0)" : "translateX(var(--tw-translate-x,0)) translateY(var(--tw-translate-y,0))") + " rotate(var(--tw-rotate,0)) skewX(var(--tw-skew-x,0)) skewY(var(--tw-skew-y,0)) scaleX(var(--tw-scale-x,1)) scaleY(var(--tw-scale-y,1))";
390var transformXYFunction = (params, context, id) => params[0] && (_ = context.theme(id, params[1] || params[0])) && {
391 [`--tw-${id}-x`]: params[0] !== "y" && _,
392 [`--tw-${id}-y`]: params[0] !== "x" && _,
393 transform: [`${id}${params[1] ? params[0].toUpperCase() : ""}(${_})`, transform()]
394};
395var edgesPluginFor = (key) => (params, context, id) => id[1] ? edges(context.theme(key, params), id[1], key) : themeProperty(key)(params, context, id);
396var padding = edgesPluginFor("padding");
397var margin = edgesPluginFor("margin");
398var minMax = (params, {theme: theme2}, id) => (_ = {w: "width", h: "height"}[params[0]]) && {
399 [_ = `${id}${capitalize(_)}`]: theme2(_, tail(params))
400};
401var filter = (params, {theme: theme2}, id) => {
402 const parts = id.split("-");
403 const prefix = parts[0] == "backdrop" ? parts[0] + "-" : "";
404 if (!prefix) {
405 params.unshift(...parts);
406 }
407 if (params[0] == "filter") {
408 const filters = [
409 "blur",
410 "brightness",
411 "contrast",
412 "grayscale",
413 "hue-rotate",
414 "invert",
415 prefix && "opacity",
416 "saturate",
417 "sepia",
418 !prefix && "drop-shadow"
419 ].filter(Boolean);
420 return params[1] == "none" ? {[prefix + "filter"]: "none"} : filters.reduce((css, key) => {
421 css["--tw-" + prefix + key] = "var(--tw-empty,/*!*/ /*!*/)";
422 return css;
423 }, {
424 [prefix + "filter"]: filters.map((key) => `var(--tw-${prefix}${key})`).join(" ")
425 });
426 }
427 $ = params.shift();
428 if (includes(["hue", "drop"], $))
429 $ += capitalize(params.shift());
430 return (_ = theme2(prefix ? "backdrop" + capitalize($) : $, params)) && {
431 ["--tw-" + prefix + $]: (Array.isArray(_) ? _ : [_]).map((_4) => `${hyphenate($)}(${_4})`).join(" ")
432 };
433};
434var corePlugins = {
435 group: (params, {tag}, id) => tag(join([id, ...params])),
436 hidden: alias(display, "none"),
437 inline: display,
438 block: display,
439 contents: display,
440 flow: display,
441 table: (params, context, id) => includes(["auto", "fixed"], params[0]) ? {tableLayout: params[0]} : display(params, context, id),
442 flex(params, context, id) {
443 switch (params[0]) {
444 case "row":
445 case "col":
446 return {
447 flexDirection: join(params[0] == "col" ? ["column", ...tail(params)] : params)
448 };
449 case "nowrap":
450 case "wrap":
451 return {flexWrap: join(params)};
452 case "grow":
453 case "shrink":
454 _ = context.theme("flex" + capitalize(params[0]), tail(params), params[1] || 1);
455 return _ != null && {
456 ["flex-" + params[0]]: "" + _
457 };
458 }
459 return (_ = context.theme("flex", params, "")) ? {flex: _} : display(params, context, id);
460 },
461 grid(params, context, id) {
462 switch (params[0]) {
463 case "cols":
464 case "rows":
465 return (_ = context.theme("gridTemplate" + capitalize(toColumnsOrRows(params[0])), tail(params), params.length == 2 && Number(params[1]) ? `repeat(${params[1]},minmax(0,1fr))` : join(tail(params)))) && {
466 ["gridTemplate-" + toColumnsOrRows(params[0])]: _
467 };
468 case "flow":
469 return params.length > 1 && {
470 gridAutoFlow: join(params[1] == "col" ? ["column", ...tail(params, 2)] : tail(params), " ")
471 };
472 }
473 return display(params, context, id);
474 },
475 auto: (params, {theme: theme2}) => includes(["cols", "rows"], params[0]) && (_ = theme2("gridAuto" + capitalize(toColumnsOrRows(params[0])), tail(params), join(tail(params)))) && {
476 ["gridAuto-" + toColumnsOrRows(params[0])]: _
477 },
478 static: position,
479 fixed: position,
480 absolute: position,
481 relative: position,
482 sticky: position,
483 visible: {visibility: "visible"},
484 invisible: {visibility: "hidden"},
485 antialiased: {
486 WebkitFontSmoothing: "antialiased",
487 MozOsxFontSmoothing: "grayscale"
488 },
489 "subpixel-antialiased": {
490 WebkitFontSmoothing: "auto",
491 MozOsxFontSmoothing: "auto"
492 },
493 truncate: {
494 overflow: "hidden",
495 whiteSpace: "nowrap",
496 textOverflow: "ellipsis"
497 },
498 "sr-only": {
499 position: "absolute",
500 width: "1px",
501 height: "1px",
502 padding: "0",
503 margin: "-1px",
504 overflow: "hidden",
505 whiteSpace: "nowrap",
506 clip: "rect(0,0,0,0)",
507 borderWidth: "0"
508 },
509 "not-sr-only": {
510 position: "static",
511 width: "auto",
512 height: "auto",
513 padding: "0",
514 margin: "0",
515 overflow: "visible",
516 whiteSpace: "normal",
517 clip: "auto"
518 },
519 resize: (params) => ({
520 resize: {x: "horizontal", y: "vertical"}[params[0]] || params[0] || "both"
521 }),
522 box: (params) => params[0] && {boxSizing: params[0] + "-box"},
523 appearance: propertyValue(),
524 cursor: themePropertyFallback(),
525 float: propertyValue(),
526 clear: propertyValue(),
527 decoration: propertyValue("boxDecorationBreak"),
528 isolate: {isolation: "isolate"},
529 isolation: propertyValue(),
530 "mix-blend": propertyValue("mixBlendMode"),
531 top: inset,
532 right: inset,
533 bottom: inset,
534 left: inset,
535 inset: (params, {theme: theme2}) => (_ = expandEdges(params[0])) ? edges(theme2("inset", tail(params)), params[0]) : (_ = theme2("inset", params)) && {
536 top: _,
537 right: _,
538 bottom: _,
539 left: _
540 },
541 underline: textDecoration,
542 "line-through": textDecoration,
543 "no-underline": alias(textDecoration, "none"),
544 "text-underline": alias(textDecoration, "underline"),
545 "text-no-underline": alias(textDecoration, "none"),
546 "text-line-through": alias(textDecoration, "line-through"),
547 uppercase: textTransform,
548 lowercase: textTransform,
549 capitalize: textTransform,
550 "normal-case": alias(textTransform, "none"),
551 "text-normal-case": alias(textTransform, "none"),
552 italic: fontStyle,
553 "not-italic": alias(fontStyle, "normal"),
554 "font-italic": alias(fontStyle, "italic"),
555 "font-not-italic": alias(fontStyle, "normal"),
556 font: (params, context, id) => (_ = context.theme("fontFamily", params, "")) ? {fontFamily: _} : themeProperty("fontWeight")(params, context, id),
557 items: (params) => params[0] && {
558 alignItems: includes(["start", "end"], params[0]) ? "flex-" + params[0] : join(params)
559 },
560 "justify-self": propertyValue(),
561 "justify-items": propertyValue(),
562 justify: contentPluginFor("justifyContent"),
563 content: contentPluginFor("alignContent"),
564 self: contentPluginFor("alignSelf"),
565 place: (params) => params[0] && placeHelper("place-" + params[0], tail(params)),
566 overscroll: (params) => params[0] && {
567 ["overscrollBehavior" + (params[1] ? "-" + params[0] : "")]: params[1] || params[0]
568 },
569 col: gridPlugin("column"),
570 row: gridPlugin("row"),
571 duration: themeProperty("transitionDuration"),
572 delay: themeProperty("transitionDelay"),
573 tracking: themeProperty("letterSpacing"),
574 leading: themeProperty("lineHeight"),
575 z: themeProperty("zIndex"),
576 opacity: themeProperty(),
577 ease: themeProperty("transitionTimingFunction"),
578 p: padding,
579 py: padding,
580 px: padding,
581 pt: padding,
582 pr: padding,
583 pb: padding,
584 pl: padding,
585 m: margin,
586 my: margin,
587 mx: margin,
588 mt: margin,
589 mr: margin,
590 mb: margin,
591 ml: margin,
592 w: themeProperty("width"),
593 h: themeProperty("height"),
594 min: minMax,
595 max: minMax,
596 fill: themeProperty(),
597 order: themeProperty(),
598 origin: themePropertyFallback("transformOrigin", " "),
599 select: propertyValue("userSelect"),
600 "pointer-events": propertyValue(),
601 align: propertyValue("verticalAlign"),
602 whitespace: propertyValue("whiteSpace"),
603 "normal-nums": {fontVariantNumeric: "normal"},
604 ordinal: fontVariantNumeric("ordinal"),
605 "slashed-zero": fontVariantNumeric("slashed-zero"),
606 "lining-nums": fontVariantNumeric("numeric-figure"),
607 "oldstyle-nums": fontVariantNumeric("numeric-figure"),
608 "proportional-nums": fontVariantNumeric("numeric-spacing"),
609 "tabular-nums": fontVariantNumeric("numeric-spacing"),
610 "diagonal-fractions": fontVariantNumeric("numeric-fraction"),
611 "stacked-fractions": fontVariantNumeric("numeric-fraction"),
612 overflow: (params, context, id) => includes(["ellipsis", "clip"], params[0]) ? propertyValue("textOverflow")(params) : params[1] ? {["overflow-" + params[0]]: params[1]} : propertyValue()(params, context, id),
613 transform: (params) => params[0] == "none" ? {transform: "none"} : {
614 "--tw-translate-x": "0",
615 "--tw-translate-y": "0",
616 "--tw-rotate": "0",
617 "--tw-skew-x": "0",
618 "--tw-skew-y": "0",
619 "--tw-scale-x": "1",
620 "--tw-scale-y": "1",
621 transform: transform(params[0] == "gpu")
622 },
623 rotate: (params, {theme: theme2}) => (_ = theme2("rotate", params)) && {
624 "--tw-rotate": _,
625 transform: [`rotate(${_})`, transform()]
626 },
627 scale: transformXYFunction,
628 translate: transformXYFunction,
629 skew: transformXYFunction,
630 gap: (params, context, id) => (_ = {x: "column", y: "row"}[params[0]]) ? {[_ + "Gap"]: context.theme("gap", tail(params))} : themeProperty("gap")(params, context, id),
631 stroke: (params, context, id) => (_ = context.theme("stroke", params, "")) ? {stroke: _} : themeProperty("strokeWidth")(params, context, id),
632 outline: (params, {theme: theme2}) => (_ = theme2("outline", params)) && {
633 outline: _[0],
634 outlineOffset: _[1]
635 },
636 "break-normal": {
637 wordBreak: "normal",
638 overflowWrap: "normal"
639 },
640 "break-words": {overflowWrap: "break-word"},
641 "break-all": {wordBreak: "break-all"},
642 text(params, {theme: theme2}, id) {
643 switch (params[0]) {
644 case "left":
645 case "center":
646 case "right":
647 case "justify":
648 return {textAlign: params[0]};
649 case "uppercase":
650 case "lowercase":
651 case "capitalize":
652 return textTransform([], _, params[0]);
653 case "opacity":
654 return opacityProperty(params, theme2, id);
655 }
656 const fontSize = theme2("fontSize", params, "");
657 if (fontSize) {
658 return typeof fontSize == "string" ? {fontSize} : {
659 fontSize: fontSize[0],
660 ...typeof fontSize[1] == "string" ? {lineHeight: fontSize[1]} : fontSize[1]
661 };
662 }
663 return withOpacityFallback("color", "text", theme2("textColor", params));
664 },
665 bg(params, {theme: theme2}, id) {
666 switch (params[0]) {
667 case "fixed":
668 case "local":
669 case "scroll":
670 return propertyValue("backgroundAttachment", ",")(params);
671 case "bottom":
672 case "center":
673 case "left":
674 case "right":
675 case "top":
676 return propertyValue("backgroundPosition", " ")(params);
677 case "no":
678 return params[1] == "repeat" && propertyValue("backgroundRepeat")(params);
679 case "repeat":
680 return includes("xy", params[1]) ? propertyValue("backgroundRepeat")(params) : {backgroundRepeat: params[1] || params[0]};
681 case "opacity":
682 return opacityProperty(params, theme2, id, "background");
683 case "clip":
684 case "origin":
685 return params[1] && {
686 ["background-" + params[0]]: params[1] + (params[1] == "text" ? "" : "-box")
687 };
688 case "blend":
689 return propertyValue("background-blend-mode")(tail(params));
690 case "gradient":
691 if (params[1] == "to" && (_ = expandEdges(params[2]))) {
692 return {
693 backgroundImage: `linear-gradient(to ${join(_, " ")},var(--tw-gradient-stops))`
694 };
695 }
696 }
697 return (_ = theme2("backgroundPosition", params, "")) ? {backgroundPosition: _} : (_ = theme2("backgroundSize", params, "")) ? {backgroundSize: _} : (_ = theme2("backgroundImage", params, "")) ? {backgroundImage: _} : withOpacityFallback("backgroundColor", "bg", theme2("backgroundColor", params));
698 },
699 from: (params, {theme: theme2}) => (_ = theme2("gradientColorStops", params)) && {
700 "--tw-gradient-from": _,
701 "--tw-gradient-stops": `var(--tw-gradient-from),var(--tw-gradient-to,${transparentTo(_)})`
702 },
703 via: (params, {theme: theme2}) => (_ = theme2("gradientColorStops", params)) && {
704 "--tw-gradient-stops": `var(--tw-gradient-from),${_},var(--tw-gradient-to,${transparentTo(_)})`
705 },
706 to: (params, {theme: theme2}) => (_ = theme2("gradientColorStops", params)) && {
707 "--tw-gradient-to": _
708 },
709 border: (params, context, id) => expandEdges(params[0]) ? edges(context.theme("borderWidth", tail(params)), params[0], "border", "width") : border(params, context, id),
710 divide: (params, context, id) => (_ = reversableEdge(params, context, id, "divideWidth", "border", "width") || border(params, context, id)) && {
711 "&>:not([hidden])~:not([hidden])": _
712 },
713 space: (params, context, id) => (_ = reversableEdge(params, context, id, "space", "margin")) && {
714 "&>:not([hidden])~:not([hidden])": _
715 },
716 placeholder: (params, {theme: theme2}, id) => (_ = params[0] == "opacity" ? opacityProperty(params, theme2, id) : withOpacityFallback("color", "placeholder", theme2("placeholderColor", params))) && {
717 "&::placeholder": _
718 },
719 shadow: (params, {theme: theme2}) => (_ = theme2("boxShadow", params)) && {
720 ":global": {
721 "*": {
722 "--tw-shadow": "0 0 transparent"
723 }
724 },
725 "--tw-shadow": _ == "none" ? "0 0 transparent" : _,
726 boxShadow: [
727 _,
728 `var(--tw-ring-offset-shadow,0 0 transparent),var(--tw-ring-shadow,0 0 transparent),var(--tw-shadow)`
729 ]
730 },
731 animate: (params, {theme: theme2, tag}) => {
732 if ($ = theme2("animation", params)) {
733 const parts = $.split(" ");
734 if ((_ = theme2("keyframes", parts[0], __ = {})) !== __) {
735 return ($ = tag(parts[0])) && {
736 animation: $ + " " + join(tail(parts), " "),
737 ["@keyframes " + $]: _
738 };
739 }
740 return {animation: $};
741 }
742 },
743 ring(params, {theme: theme2}, id) {
744 switch (params[0]) {
745 case "inset":
746 return {"--tw-ring-inset": "inset"};
747 case "opacity":
748 return opacityProperty(params, theme2, id);
749 case "offset":
750 return (_ = theme2("ringOffsetWidth", tail(params), "")) ? {
751 "--tw-ring-offset-width": _
752 } : {
753 "--tw-ring-offset-color": theme2("ringOffsetColor", tail(params))
754 };
755 }
756 return (_ = theme2("ringWidth", params, "")) ? {
757 "--tw-ring-offset-shadow": `var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)`,
758 "--tw-ring-shadow": `var(--tw-ring-inset) 0 0 0 calc(${_} + var(--tw-ring-offset-width)) var(--tw-ring-color)`,
759 boxShadow: `var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 transparent)`,
760 ":global": {
761 "*": {
762 "--tw-ring-inset": "var(--tw-empty,/*!*/ /*!*/)",
763 "--tw-ring-offset-width": theme2("ringOffsetWidth", "", "0px"),
764 "--tw-ring-offset-color": theme2("ringOffsetColor", "", "#fff"),
765 "--tw-ring-color": asRGBA(theme2("ringColor", "", "#93c5fd"), "ring-opacity", theme2("ringOpacity", "", "0.5")),
766 "--tw-ring-offset-shadow": "0 0 transparent",
767 "--tw-ring-shadow": "0 0 transparent"
768 }
769 }
770 } : {
771 "--tw-ring-opacity": "1",
772 "--tw-ring-color": asRGBA(theme2("ringColor", params), "ring-opacity")
773 };
774 },
775 object: (params, context, id) => includes(["contain", "cover", "fill", "none", "scale-down"], join(params)) ? {objectFit: join(params)} : themePropertyFallback("objectPosition", " ")(params, context, id),
776 list: (params, context, id) => join(params) == "item" ? display(params, context, id) : includes(["inside", "outside"], join(params)) ? {listStylePosition: params[0]} : themePropertyFallback("listStyleType")(params, context, id),
777 rounded: (params, context, id) => corners(context.theme("borderRadius", tail(params), ""), params[0], "border", "radius") || themeProperty("borderRadius")(params, context, id),
778 "transition-none": {transitionProperty: "none"},
779 transition: (params, {theme: theme2}) => ({
780 transitionProperty: theme2("transitionProperty", params),
781 transitionTimingFunction: theme2("transitionTimingFunction", ""),
782 transitionDuration: theme2("transitionDuration", "")
783 }),
784 container: (params, {theme: theme2}) => {
785 const {screens = theme2("screens"), center, padding: padding2} = theme2("container");
786 const paddingFor = (screen) => (_ = padding2 && (typeof padding2 == "string" ? padding2 : padding2[screen] || padding2.DEFAULT)) ? {
787 paddingRight: _,
788 paddingLeft: _
789 } : {};
790 return Object.keys(screens).reduce((rules2, screen) => {
791 if (($ = screens[screen]) && typeof $ == "string") {
792 rules2[buildMediaQuery($)] = {
793 "&": {
794 "max-width": $,
795 ...paddingFor(screen)
796 }
797 };
798 }
799 return rules2;
800 }, {
801 width: "100%",
802 ...center ? {marginRight: "auto", marginLeft: "auto"} : {},
803 ...paddingFor("xs")
804 });
805 },
806 filter,
807 blur: filter,
808 brightness: filter,
809 contrast: filter,
810 grayscale: filter,
811 "hue-rotate": filter,
812 invert: filter,
813 saturate: filter,
814 sepia: filter,
815 "drop-shadow": filter,
816 backdrop: filter
817};
818
819// src/twind/preflight.ts
820var createPreflight = (theme2) => ({
821 ":root": {tabSize: 4},
822 "body,blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre,fieldset,ol,ul": {margin: "0"},
823 button: {backgroundColor: "transparent", backgroundImage: "none"},
824 'button,[type="button"],[type="reset"],[type="submit"]': {WebkitAppearance: "button"},
825 "button:focus": {outline: ["1px dotted", "5px auto -webkit-focus-ring-color"]},
826 "fieldset,ol,ul,legend": {padding: "0"},
827 "ol,ul": {listStyle: "none"},
828 html: {
829 lineHeight: "1.5",
830 WebkitTextSizeAdjust: "100%",
831 fontFamily: theme2("fontFamily.sans", "ui-sans-serif,system-ui,sans-serif")
832 },
833 body: {fontFamily: "inherit", lineHeight: "inherit"},
834 "*,::before,::after": {
835 boxSizing: "border-box",
836 border: `0 solid ${theme2("borderColor.DEFAULT", "currentColor")}`
837 },
838 hr: {height: "0", color: "inherit", borderTopWidth: "1px"},
839 img: {borderStyle: "solid"},
840 textarea: {resize: "vertical"},
841 "input::placeholder,textarea::placeholder": {
842 opacity: "1",
843 color: theme2("placeholderColor.DEFAULT", theme2("colors.gray.400", "#a1a1aa"))
844 },
845 'button,[role="button"]': {cursor: "pointer"},
846 table: {textIndent: "0", borderColor: "inherit", borderCollapse: "collapse"},
847 "h1,h2,h3,h4,h5,h6": {fontSize: "inherit", fontWeight: "inherit"},
848 a: {color: "inherit", textDecoration: "inherit"},
849 "button,input,optgroup,select,textarea": {
850 fontFamily: "inherit",
851 fontSize: "100%",
852 margin: "0",
853 padding: "0",
854 lineHeight: "inherit",
855 color: "inherit"
856 },
857 "button,select": {textTransform: "none"},
858 "::-moz-focus-inner": {borderStyle: "none", padding: "0"},
859 ":-moz-focusring": {outline: "1px dotted ButtonText"},
860 ":-moz-ui-invalid": {boxShadow: "none"},
861 progress: {verticalAlign: "baseline"},
862 "::-webkit-inner-spin-button,::-webkit-outer-spin-button": {height: "auto"},
863 '[type="search"]': {WebkitAppearance: "textfield", outlineOffset: "-2px"},
864 "::-webkit-search-decoration": {WebkitAppearance: "none"},
865 "::-webkit-file-upload-button": {WebkitAppearance: "button", font: "inherit"},
866 summary: {display: "list-item"},
867 "abbr[title]": {textDecoration: "underline dotted"},
868 "b,strong": {fontWeight: "bolder"},
869 "pre,code,kbd,samp": {
870 fontFamily: theme2("fontFamily", "mono", "ui-monospace,monospace"),
871 fontSize: "1em"
872 },
873 "sub,sup": {fontSize: "75%", lineHeight: "0", position: "relative", verticalAlign: "baseline"},
874 sub: {bottom: "-0.25em"},
875 sup: {top: "-0.5em"},
876 "img,svg,video,canvas,audio,iframe,embed,object": {display: "block", verticalAlign: "middle"},
877 "img,video": {maxWidth: "100%", height: "auto"}
878});
879
880// src/twind/variants.ts
881var coreVariants = {
882 dark: "@media (prefers-color-scheme:dark)",
883 sticky: "@supports ((position: -webkit-sticky) or (position:sticky))",
884 "motion-reduce": "@media (prefers-reduced-motion:reduce)",
885 "motion-safe": "@media (prefers-reduced-motion:no-preference)",
886 first: "&:first-child",
887 last: "&:last-child",
888 even: "&:nth-child(2n)",
889 odd: "&:nth-child(odd)",
890 children: "&>*",
891 siblings: "&~*",
892 sibling: "&+*",
893 override: "&&"
894};
895
896// src/internal/dom.ts
897var STYLE_ELEMENT_ID = "__twind";
898var getStyleElement = (nonce) => {
899 let element = self[STYLE_ELEMENT_ID];
900 if (!element) {
901 element = document.head.appendChild(document.createElement("style"));
902 element.id = STYLE_ELEMENT_ID;
903 nonce && (element.nonce = nonce);
904 element.appendChild(document.createTextNode(""));
905 }
906 return element;
907};
908
909// src/twind/sheets.ts
910var cssomSheet = ({
911 nonce,
912 target = getStyleElement(nonce).sheet
913} = {}) => {
914 const offset = target.cssRules.length;
915 return {
916 target,
917 insert: (rule, index) => target.insertRule(rule, offset + index)
918 };
919};
920var voidSheet = () => ({
921 target: null,
922 insert: noop
923});
924
925// src/twind/modes.ts
926var mode = (report) => ({
927 unknown(section, key = [], optional, context) {
928 if (!optional) {
929 this.report({id: "UNKNOWN_THEME_VALUE", key: section + "." + join(key)}, context);
930 }
931 },
932 report({id, ...info}) {
933 return report(`[${id}] ${JSON.stringify(info)}`);
934 }
935});
936var warn = /* @__PURE__ */ mode((message) => console.warn(message));
937var strict = /* @__PURE__ */ mode((message) => {
938 throw new Error(message);
939});
940var silent = /* @__PURE__ */ mode(noop);
941
942// src/twind/prefix.ts
943import {cssPropertyAlias, cssPropertyPrefixFlags, cssValuePrefixFlags} from "style-vendorizer";
944var noprefix = (property2, value, important) => `${property2}:${value}${important ? " !important" : ""}`;
945var autoprefix = (property2, value, important) => {
946 let cssText = "";
947 const propertyAlias = cssPropertyAlias(property2);
948 if (propertyAlias)
949 cssText += `${noprefix(propertyAlias, value, important)};`;
950 let flags = cssPropertyPrefixFlags(property2);
951 if (flags & 1)
952 cssText += `-webkit-${noprefix(property2, value, important)};`;
953 if (flags & 2)
954 cssText += `-moz-${noprefix(property2, value, important)};`;
955 if (flags & 4)
956 cssText += `-ms-${noprefix(property2, value, important)};`;
957 flags = cssValuePrefixFlags(property2, value);
958 if (flags & 1)
959 cssText += `${noprefix(property2, `-webkit-${value}`, important)};`;
960 if (flags & 2)
961 cssText += `${noprefix(property2, `-moz-${value}`, important)};`;
962 if (flags & 4)
963 cssText += `${noprefix(property2, `-ms-${value}`, important)};`;
964 cssText += noprefix(property2, value, important);
965 return cssText;
966};
967
968// src/twind/theme.ts
969var ratios = (start, end) => {
970 const result = {};
971 do {
972 for (let dividend = 1; dividend < start; dividend++) {
973 result[`${dividend}/${start}`] = Number((dividend / start * 100).toFixed(6)) + "%";
974 }
975 } while (++start <= end);
976 return result;
977};
978var exponential = (stop, unit, start = 0) => {
979 const result = {};
980 for (; start <= stop; start = start * 2 || 1) {
981 result[start] = start + unit;
982 }
983 return result;
984};
985var linear = (stop, unit = "", divideBy = 1, start = 0, step = 1, result = {}) => {
986 for (; start <= stop; start += step) {
987 result[start] = start / divideBy + unit;
988 }
989 return result;
990};
991var alias2 = (section) => (theme2) => theme2(section);
992var themeFactory = (args, {theme: theme2}) => theme2(...args);
993var theme = (...args) => directive(themeFactory, args);
994var defaultTheme = {
995 screens: {
996 sm: "640px",
997 md: "768px",
998 lg: "1024px",
999 xl: "1280px",
1000 "2xl": "1536px"
1001 },
1002 colors: {
1003 transparent: "transparent",
1004 current: "currentColor",
1005 black: "#000",
1006 white: "#fff",
1007 gray: {
1008 50: "#f9fafb",
1009 100: "#f3f4f6",
1010 200: "#e5e7eb",
1011 300: "#d1d5db",
1012 400: "#9ca3af",
1013 500: "#6b7280",
1014 600: "#4b5563",
1015 700: "#374151",
1016 800: "#1f2937",
1017 900: "#111827"
1018 },
1019 red: {
1020 50: "#fef2f2",
1021 100: "#fee2e2",
1022 200: "#fecaca",
1023 300: "#fca5a5",
1024 400: "#f87171",
1025 500: "#ef4444",
1026 600: "#dc2626",
1027 700: "#b91c1c",
1028 800: "#991b1b",
1029 900: "#7f1d1d"
1030 },
1031 yellow: {
1032 50: "#fffbeb",
1033 100: "#fef3c7",
1034 200: "#fde68a",
1035 300: "#fcd34d",
1036 400: "#fbbf24",
1037 500: "#f59e0b",
1038 600: "#d97706",
1039 700: "#b45309",
1040 800: "#92400e",
1041 900: "#78350f"
1042 },
1043 green: {
1044 50: "#ecfdf5",
1045 100: "#d1fae5",
1046 200: "#a7f3d0",
1047 300: "#6ee7b7",
1048 400: "#34d399",
1049 500: "#10b981",
1050 600: "#059669",
1051 700: "#047857",
1052 800: "#065f46",
1053 900: "#064e3b"
1054 },
1055 blue: {
1056 50: "#eff6ff",
1057 100: "#dbeafe",
1058 200: "#bfdbfe",
1059 300: "#93c5fd",
1060 400: "#60a5fa",
1061 500: "#3b82f6",
1062 600: "#2563eb",
1063 700: "#1d4ed8",
1064 800: "#1e40af",
1065 900: "#1e3a8a"
1066 },
1067 indigo: {
1068 50: "#eef2ff",
1069 100: "#e0e7ff",
1070 200: "#c7d2fe",
1071 300: "#a5b4fc",
1072 400: "#818cf8",
1073 500: "#6366f1",
1074 600: "#4f46e5",
1075 700: "#4338ca",
1076 800: "#3730a3",
1077 900: "#312e81"
1078 },
1079 purple: {
1080 50: "#f5f3ff",
1081 100: "#ede9fe",
1082 200: "#ddd6fe",
1083 300: "#c4b5fd",
1084 400: "#a78bfa",
1085 500: "#8b5cf6",
1086 600: "#7c3aed",
1087 700: "#6d28d9",
1088 800: "#5b21b6",
1089 900: "#4c1d95"
1090 },
1091 pink: {
1092 50: "#fdf2f8",
1093 100: "#fce7f3",
1094 200: "#fbcfe8",
1095 300: "#f9a8d4",
1096 400: "#f472b6",
1097 500: "#ec4899",
1098 600: "#db2777",
1099 700: "#be185d",
1100 800: "#9d174d",
1101 900: "#831843"
1102 }
1103 },
1104 spacing: {
1105 px: "1px",
1106 0: "0px",
1107 .../* @__PURE__ */ linear(4, "rem", 4, 0.5, 0.5),
1108 .../* @__PURE__ */ linear(12, "rem", 4, 5),
1109 14: "3.5rem",
1110 .../* @__PURE__ */ linear(64, "rem", 4, 16, 4),
1111 72: "18rem",
1112 80: "20rem",
1113 96: "24rem"
1114 },
1115 durations: {
1116 75: "75ms",
1117 100: "100ms",
1118 150: "150ms",
1119 200: "200ms",
1120 300: "300ms",
1121 500: "500ms",
1122 700: "700ms",
1123 1e3: "1000ms"
1124 },
1125 animation: {
1126 none: "none",
1127 spin: "spin 1s linear infinite",
1128 ping: "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite",
1129 pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
1130 bounce: "bounce 1s infinite"
1131 },
1132 backdropBlur: /* @__PURE__ */ alias2("blur"),
1133 backdropBrightness: /* @__PURE__ */ alias2("brightness"),
1134 backdropContrast: /* @__PURE__ */ alias2("contrast"),
1135 backdropGrayscale: /* @__PURE__ */ alias2("grayscale"),
1136 backdropHueRotate: /* @__PURE__ */ alias2("hueRotate"),
1137 backdropInvert: /* @__PURE__ */ alias2("invert"),
1138 backdropOpacity: /* @__PURE__ */ alias2("opacity"),
1139 backdropSaturate: /* @__PURE__ */ alias2("saturate"),
1140 backdropSepia: /* @__PURE__ */ alias2("sepia"),
1141 backgroundColor: /* @__PURE__ */ alias2("colors"),
1142 backgroundImage: {
1143 none: "none"
1144 },
1145 backgroundOpacity: /* @__PURE__ */ alias2("opacity"),
1146 backgroundSize: {
1147 auto: "auto",
1148 cover: "cover",
1149 contain: "contain"
1150 },
1151 blur: {
1152 0: "0",
1153 sm: "4px",
1154 DEFAULT: "8px",
1155 md: "12px",
1156 lg: "16px",
1157 xl: "24px",
1158 "2xl": "40px",
1159 "3xl": "64px"
1160 },
1161 brightness: {
1162 .../* @__PURE__ */ linear(200, "", 100, 0, 50),
1163 .../* @__PURE__ */ linear(110, "", 100, 90, 5),
1164 75: "0.75",
1165 125: "1.25"
1166 },
1167 borderColor: (theme2) => ({
1168 ...theme2("colors"),
1169 DEFAULT: theme2("colors.gray.200", "currentColor")
1170 }),
1171 borderOpacity: /* @__PURE__ */ alias2("opacity"),
1172 borderRadius: {
1173 none: "0px",
1174 sm: "0.125rem",
1175 DEFAULT: "0.25rem",
1176 md: "0.375rem",
1177 lg: "0.5rem",
1178 xl: "0.75rem",
1179 "2xl": "1rem",
1180 "3xl": "1.5rem",
1181 "1/2": "50%",
1182 full: "9999px"
1183 },
1184 borderWidth: {
1185 DEFAULT: "1px",
1186 .../* @__PURE__ */ exponential(8, "px")
1187 },
1188 boxShadow: {
1189 sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
1190 DEFAULT: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",
1191 md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
1192 lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
1193 xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
1194 "2xl": "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
1195 inner: "inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)",
1196 none: "none"
1197 },
1198 contrast: {
1199 .../* @__PURE__ */ linear(200, "", 100, 0, 50),
1200 75: "0.75",
1201 125: "1.25"
1202 },
1203 divideColor: /* @__PURE__ */ alias2("borderColor"),
1204 divideOpacity: /* @__PURE__ */ alias2("borderOpacity"),
1205 divideWidth: /* @__PURE__ */ alias2("borderWidth"),
1206 dropShadow: {
1207 sm: "0 1px 1px rgba(0,0,0,0.05)",
1208 DEFAULT: ["0 1px 2px rgba(0, 0, 0, 0.1)", "0 1px 1px rgba(0, 0, 0, 0.06)"],
1209 md: ["0 4px 3px rgba(0, 0, 0, 0.07)", "0 2px 2px rgba(0, 0, 0, 0.06)"],
1210 lg: ["0 10px 8px rgba(0, 0, 0, 0.04)", "0 4px 3px rgba(0, 0, 0, 0.1)"],
1211 xl: ["0 20px 13px rgba(0, 0, 0, 0.03)", "0 8px 5px rgba(0, 0, 0, 0.08)"],
1212 "2xl": "0 25px 25px rgba(0, 0, 0, 0.15)",
1213 none: "0 0 #0000"
1214 },
1215 fill: {current: "currentColor"},
1216 grayscale: {
1217 0: "0",
1218 DEFAULT: "100%"
1219 },
1220 hueRotate: {
1221 0: "0deg",
1222 15: "15deg",
1223 30: "30deg",
1224 60: "60deg",
1225 90: "90deg",
1226 180: "180deg"
1227 },
1228 invert: {
1229 0: "0",
1230 DEFAULT: "100%"
1231 },
1232 flex: {
1233 1: "1 1 0%",
1234 auto: "1 1 auto",
1235 initial: "0 1 auto",
1236 none: "none"
1237 },
1238 fontFamily: {
1239 sans: 'ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"'.split(","),
1240 serif: 'ui-serif,Georgia,Cambria,"Times New Roman",Times,serif'.split(","),
1241 mono: 'ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace'.split(",")
1242 },
1243 fontSize: {
1244 xs: ["0.75rem", "1rem"],
1245 sm: ["0.875rem", "1.25rem"],
1246 base: ["1rem", "1.5rem"],
1247 lg: ["1.125rem", "1.75rem"],
1248 xl: ["1.25rem", "1.75rem"],
1249 "2xl": ["1.5rem", "2rem"],
1250 "3xl": ["1.875rem", "2.25rem"],
1251 "4xl": ["2.25rem", "2.5rem"],
1252 "5xl": ["3rem", "1"],
1253 "6xl": ["3.75rem", "1"],
1254 "7xl": ["4.5rem", "1"],
1255 "8xl": ["6rem", "1"],
1256 "9xl": ["8rem", "1"]
1257 },
1258 fontWeight: {
1259 thin: "100",
1260 extralight: "200",
1261 light: "300",
1262 normal: "400",
1263 medium: "500",
1264 semibold: "600",
1265 bold: "700",
1266 extrabold: "800",
1267 black: "900"
1268 },
1269 gridTemplateColumns: {},
1270 gridTemplateRows: {},
1271 gridAutoColumns: {
1272 min: "min-content",
1273 max: "max-content",
1274 fr: "minmax(0,1fr)"
1275 },
1276 gridAutoRows: {
1277 min: "min-content",
1278 max: "max-content",
1279 fr: "minmax(0,1fr)"
1280 },
1281 gridColumn: {
1282 auto: "auto",
1283 "span-full": "1 / -1"
1284 },
1285 gridRow: {
1286 auto: "auto",
1287 "span-full": "1 / -1"
1288 },
1289 gap: /* @__PURE__ */ alias2("spacing"),
1290 gradientColorStops: /* @__PURE__ */ alias2("colors"),
1291 height: (theme2) => ({
1292 auto: "auto",
1293 ...theme2("spacing"),
1294 ...ratios(2, 6),
1295 full: "100%",
1296 screen: "100vh"
1297 }),
1298 inset: (theme2) => ({
1299 auto: "auto",
1300 ...theme2("spacing"),
1301 ...ratios(2, 4),
1302 full: "100%"
1303 }),
1304 keyframes: {
1305 spin: {
1306 from: {
1307 transform: "rotate(0deg)"
1308 },
1309 to: {
1310 transform: "rotate(360deg)"
1311 }
1312 },
1313 ping: {
1314 "0%": {
1315 transform: "scale(1)",
1316 opacity: "1"
1317 },
1318 "75%,100%": {
1319 transform: "scale(2)",
1320 opacity: "0"
1321 }
1322 },
1323 pulse: {
1324 "0%,100%": {
1325 opacity: "1"
1326 },
1327 "50%": {
1328 opacity: ".5"
1329 }
1330 },
1331 bounce: {
1332 "0%, 100%": {
1333 transform: "translateY(-25%)",
1334 animationTimingFunction: "cubic-bezier(0.8,0,1,1)"
1335 },
1336 "50%": {
1337 transform: "none",
1338 animationTimingFunction: "cubic-bezier(0,0,0.2,1)"
1339 }
1340 }
1341 },
1342 letterSpacing: {
1343 tighter: "-0.05em",
1344 tight: "-0.025em",
1345 normal: "0em",
1346 wide: "0.025em",
1347 wider: "0.05em",
1348 widest: "0.1em"
1349 },
1350 lineHeight: {
1351 none: "1",
1352 tight: "1.25",
1353 snug: "1.375",
1354 normal: "1.5",
1355 relaxed: "1.625",
1356 loose: "2",
1357 .../* @__PURE__ */ linear(10, "rem", 4, 3)
1358 },
1359 margin: (theme2) => ({
1360 auto: "auto",
1361 ...theme2("spacing")
1362 }),
1363 maxHeight: (theme2) => ({
1364 ...theme2("spacing"),
1365 full: "100%",
1366 screen: "100vh"
1367 }),
1368 maxWidth: (theme2, {breakpoints}) => ({
1369 none: "none",
1370 0: "0rem",
1371 xs: "20rem",
1372 sm: "24rem",
1373 md: "28rem",
1374 lg: "32rem",
1375 xl: "36rem",
1376 "2xl": "42rem",
1377 "3xl": "48rem",
1378 "4xl": "56rem",
1379 "5xl": "64rem",
1380 "6xl": "72rem",
1381 "7xl": "80rem",
1382 full: "100%",
1383 min: "min-content",
1384 max: "max-content",
1385 prose: "65ch",
1386 ...breakpoints(theme2("screens"))
1387 }),
1388 minHeight: {
1389 0: "0px",
1390 full: "100%",
1391 screen: "100vh"
1392 },
1393 minWidth: {
1394 0: "0px",
1395 full: "100%",
1396 min: "min-content",
1397 max: "max-content"
1398 },
1399 opacity: {
1400 .../* @__PURE__ */ linear(100, "", 100, 0, 10),
1401 5: "0.05",
1402 25: "0.25",
1403 75: "0.75",
1404 95: "0.95"
1405 },
1406 order: {
1407 first: "-9999",
1408 last: "9999",
1409 none: "0",
1410 .../* @__PURE__ */ linear(12, "", 1, 1)
1411 },
1412 outline: {
1413 none: ["2px solid transparent", "2px"],
1414 white: ["2px dotted white", "2px"],
1415 black: ["2px dotted black", "2px"]
1416 },
1417 padding: /* @__PURE__ */ alias2("spacing"),
1418 placeholderColor: /* @__PURE__ */ alias2("colors"),
1419 placeholderOpacity: /* @__PURE__ */ alias2("opacity"),
1420 ringColor: (theme2) => ({
1421 DEFAULT: theme2("colors.blue.500", "#3b82f6"),
1422 ...theme2("colors")
1423 }),
1424 ringOffsetColor: /* @__PURE__ */ alias2("colors"),
1425 ringOffsetWidth: /* @__PURE__ */ exponential(8, "px"),
1426 ringOpacity: (theme2) => ({
1427 DEFAULT: "0.5",
1428 ...theme2("opacity")
1429 }),
1430 ringWidth: {
1431 DEFAULT: "3px",
1432 .../* @__PURE__ */ exponential(8, "px")
1433 },
1434 rotate: {
1435 .../* @__PURE__ */ exponential(2, "deg"),
1436 .../* @__PURE__ */ exponential(12, "deg", 3),
1437 .../* @__PURE__ */ exponential(180, "deg", 45)
1438 },
1439 saturate: /* @__PURE__ */ linear(200, "", 100, 0, 50),
1440 scale: {
1441 .../* @__PURE__ */ linear(150, "", 100, 0, 50),
1442 .../* @__PURE__ */ linear(110, "", 100, 90, 5),
1443 75: "0.75",
1444 125: "1.25"
1445 },
1446 sepia: {
1447 0: "0",
1448 DEFAULT: "100%"
1449 },
1450 skew: {
1451 .../* @__PURE__ */ exponential(2, "deg"),
1452 .../* @__PURE__ */ exponential(12, "deg", 3)
1453 },
1454 space: /* @__PURE__ */ alias2("spacing"),
1455 stroke: {
1456 current: "currentColor"
1457 },
1458 strokeWidth: /* @__PURE__ */ linear(2),
1459 textColor: /* @__PURE__ */ alias2("colors"),
1460 textOpacity: /* @__PURE__ */ alias2("opacity"),
1461 transitionDuration: (theme2) => ({
1462 DEFAULT: "150ms",
1463 ...theme2("durations")
1464 }),
1465 transitionDelay: /* @__PURE__ */ alias2("durations"),
1466 transitionProperty: {
1467 none: "none",
1468 all: "all",
1469 DEFAULT: "background-color,border-color,color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter",
1470 colors: "background-color,border-color,color,fill,stroke",
1471 opacity: "opacity",
1472 shadow: "box-shadow",
1473 transform: "transform"
1474 },
1475 transitionTimingFunction: {
1476 DEFAULT: "cubic-bezier(0.4,0,0.2,1)",
1477 linear: "linear",
1478 in: "cubic-bezier(0.4,0,1,1)",
1479 out: "cubic-bezier(0,0,0.2,1)",
1480 "in-out": "cubic-bezier(0.4,0,0.2,1)"
1481 },
1482 translate: (theme2) => ({
1483 ...theme2("spacing"),
1484 ...ratios(2, 4),
1485 full: "100%"
1486 }),
1487 width: (theme2) => ({
1488 auto: "auto",
1489 ...theme2("spacing"),
1490 ...ratios(2, 6),
1491 ...ratios(12, 12),
1492 screen: "100vw",
1493 full: "100%",
1494 min: "min-content",
1495 max: "max-content"
1496 }),
1497 zIndex: {
1498 auto: "auto",
1499 .../* @__PURE__ */ linear(50, "", 1, 0, 10)
1500 }
1501};
1502var flattenColorPalette = (colors, target = {}, prefix = []) => {
1503 Object.keys(colors).forEach((property2) => {
1504 const value = colors[property2];
1505 if (property2 == "DEFAULT") {
1506 target[join(prefix)] = value;
1507 target[join(prefix, ".")] = value;
1508 }
1509 const key = [...prefix, property2];
1510 target[join(key)] = value;
1511 target[join(key, ".")] = value;
1512 if (value && typeof value == "object") {
1513 flattenColorPalette(value, target, key);
1514 }
1515 }, target);
1516 return target;
1517};
1518var resolveContext = {
1519 negative: () => ({}),
1520 breakpoints: (screens) => Object.keys(screens).filter((key) => typeof screens[key] == "string").reduce((target, key) => {
1521 target["screen-" + key] = screens[key];
1522 return target;
1523 }, {})
1524};
1525var handleArbitraryValues = (section, key) => (key = key[0] == "[" && key.slice(-1) == "]" && key.slice(1, -1)) && includes(section, "olor") == /^(#|(hsl|rgb)a?\(|[a-z]+$)/.test(key) && (includes(key, "calc(") ? key.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ") : key);
1526var makeThemeResolver = (config) => {
1527 const cache = new Map();
1528 const theme2 = {...defaultTheme, ...config};
1529 const deref = (theme3, section) => {
1530 const base = theme3 && theme3[section];
1531 const value = typeof base == "function" ? base(resolve, resolveContext) : base;
1532 return value && section == "colors" ? flattenColorPalette(value) : value;
1533 };
1534 const resolve = (section, key, defaultValue) => {
1535 const keypath = section.split(".");
1536 section = keypath[0];
1537 if (keypath.length > 1) {
1538 defaultValue = key;
1539 key = join(tail(keypath), ".");
1540 }
1541 let base = cache.get(section);
1542 if (!base) {
1543 cache.set(section, base = {...deref(theme2, section)});
1544 Object.assign(base, deref(theme2.extend, section));
1545 }
1546 if (key != null) {
1547 key = (Array.isArray(key) ? join(key) : key) || "DEFAULT";
1548 const value = handleArbitraryValues(section, key) || base[key];
1549 return value == null ? defaultValue : Array.isArray(value) && !includes(["fontSize", "outline", "dropShadow"], section) ? join(value, ",") : value;
1550 }
1551 return base;
1552 };
1553 return resolve;
1554};
1555
1556// src/twind/translate.ts
1557var translate = (plugins, context) => (rule, isTranslating) => {
1558 if (typeof rule.d == "function") {
1559 return rule.d(context);
1560 }
1561 const parameters = rule.d.split(/-(?![^[]*])/g);
1562 if (!isTranslating && parameters[0] == "tw" && rule.$ == rule.d) {
1563 return rule.$;
1564 }
1565 for (let index = parameters.length; index; index--) {
1566 const id = join(parameters.slice(0, index));
1567 const plugin = plugins[id];
1568 if (plugin) {
1569 return typeof plugin == "function" ? plugin(tail(parameters, index), context, id) : typeof plugin == "string" ? context[isTranslating ? "css" : "tw"](plugin) : plugin;
1570 }
1571 }
1572};
1573
1574// src/twind/decorate.ts
1575var _2;
1576var GROUP_RE = /^:(group(?:(?!-focus).+?)*)-(.+)$/;
1577var NOT_PREFIX_RE = /^(:not)-(.+)/;
1578var prepareVariantSelector = (variant) => variant[1] == "[" ? tail(variant) : variant;
1579var decorate = (darkMode, variants, {theme: theme2, tag}) => {
1580 const applyVariant = (translation, variant) => {
1581 if (_2 = theme2("screens", tail(variant), "")) {
1582 return {[buildMediaQuery(_2)]: translation};
1583 }
1584 if (variant == ":dark" && darkMode == "class") {
1585 return {".dark &": translation};
1586 }
1587 if (_2 = GROUP_RE.exec(variant)) {
1588 return {[`.${escape(tag(_2[1]))}:${_2[2]} &`]: translation};
1589 }
1590 return {
1591 [variants[tail(variant)] || "&" + variant.replace(NOT_PREFIX_RE, (_4, not, variant2) => not + "(" + prepareVariantSelector(":" + variant2) + ")")]: translation
1592 };
1593 };
1594 return (translation, rule) => rule.v.reduceRight(applyVariant, translation);
1595};
1596
1597// src/twind/presedence.ts
1598var _3;
1599var responsivePrecedence = (css) => (((_3 = /(?:^|min-width: *)(\d+(?:.\d+)?)(p)?/.exec(css)) ? +_3[1] / (_3[2] ? 15 : 1) / 10 : 0) & 31) << 22;
1600var seperatorPrecedence = (string) => {
1601 _3 = 0;
1602 for (let index = string.length; index--; ) {
1603 _3 += includes("-:,", string[index]);
1604 }
1605 return _3;
1606};
1607var atRulePresedence = (css) => (seperatorPrecedence(css) & 15) << 18;
1608var PRECEDENCES_BY_PSEUDO_CLASS = [
1609 "rst",
1610 "st",
1611 "en",
1612 "d",
1613 "nk",
1614 "sited",
1615 "pty",
1616 "ecked",
1617 "cus-w",
1618 "ver",
1619 "cus",
1620 "cus-v",
1621 "tive",
1622 "sable",
1623 "ad-on",
1624 "tiona",
1625 "quire"
1626];
1627var pseudoPrecedence = (pseudoClass) => 1 << (~(_3 = PRECEDENCES_BY_PSEUDO_CLASS.indexOf(pseudoClass.replace(GROUP_RE, ":$2").slice(3, 8))) ? _3 : 17);
1628var makeVariantPresedenceCalculator = (theme2, variants) => (presedence, variant) => presedence | ((_3 = theme2("screens", tail(variant), "")) ? 1 << 27 | responsivePrecedence(buildMediaQuery(_3)) : variant == ":dark" ? 1 << 30 : (_3 = variants[variant] || variant.replace(NOT_PREFIX_RE, ":$2"))[0] == "@" ? atRulePresedence(_3) : pseudoPrecedence(variant));
1629var declarationPropertyPrecedence = (property2) => property2[0] == "-" ? 0 : seperatorPrecedence(property2) + ((_3 = /^(?:(border-(?!w|c|sty)|[tlbr].{2,4}m?$|c.{7}$)|([fl].{5}l|g.{8}$|pl))/.exec(property2)) ? +!!_3[1] || -!!_3[2] : 0) + 1;
1630
1631// src/twind/serialize.ts
1632var stringifyBlock = (body, selector) => selector + "{" + body + "}";
1633var serialize = (prefix, variants, context) => {
1634 const {theme: theme2, tag} = context;
1635 const tagVar = (_4, property2) => "--" + tag(property2);
1636 const tagVars = (value) => `${value}`.replace(/--(tw-[\w-]+)\b/g, tagVar);
1637 const stringifyDeclaration = (property2, value, important) => {
1638 property2 = tagVars(property2);
1639 return Array.isArray(value) ? join(value.filter(Boolean).map((value2) => prefix(property2, tagVars(value2), important)), ";") : prefix(property2, tagVars(value), important);
1640 };
1641 let rules2;
1642 const stringify3 = (atRules, selector, presedence, css, important) => {
1643 if (Array.isArray(css)) {
1644 css.forEach((css2) => css2 && stringify3(atRules, selector, presedence, css2, important));
1645 return;
1646 }
1647 let declarations = "";
1648 let maxPropertyPresedence = 0;
1649 let numberOfDeclarations = 0;
1650 if (css["@apply"]) {
1651 css = merge(evalThunk(apply(css["@apply"]), context), {...css, "@apply": void 0}, context);
1652 }
1653 Object.keys(css).forEach((key) => {
1654 const value = evalThunk(css[key], context);
1655 if (isCSSProperty(key, value)) {
1656 if (value !== "" && key.length > 1) {
1657 const property2 = hyphenate(key);
1658 numberOfDeclarations += 1;
1659 maxPropertyPresedence = Math.max(maxPropertyPresedence, declarationPropertyPrecedence(property2));
1660 declarations = (declarations && declarations + ";") + stringifyDeclaration(property2, value, important);
1661 }
1662 } else if (value) {
1663 if (key == ":global") {
1664 key = "@global";
1665 }
1666 if (key[0] == "@") {
1667 if (key[1] == "g") {
1668 stringify3([], "", 0, value, important);
1669 } else if (key[1] == "f") {
1670 stringify3([], key, 0, value, important);
1671 } else if (key[1] == "k") {
1672 const currentSize = rules2.length;
1673 stringify3([], "", 0, value, important);
1674 const waypoints = rules2.splice(currentSize, rules2.length - currentSize);
1675 rules2.push({
1676 r: stringifyBlock(join(waypoints.map((p) => p.r), ""), key),
1677 p: waypoints.reduce((sum, p) => sum + p.p, 0)
1678 });
1679 } else if (key[1] == "i") {
1680 ;
1681 (Array.isArray(value) ? value : [value]).forEach((value2) => value2 && rules2.push({p: 0, r: `${key} ${value2};`}));
1682 } else {
1683 if (key[2] == "c") {
1684 key = buildMediaQuery(context.theme("screens", tail(key, 8).trim()));
1685 }
1686 stringify3([...atRules, key], selector, presedence | responsivePrecedence(key) | atRulePresedence(key), value, important);
1687 }
1688 } else {
1689 stringify3(atRules, selector ? join(selector.split(/,(?![^[]*])/g).map((selectorPart) => join(key.split(/,(?![^[]*])/g).map((keyPart) => includes(keyPart, "&") ? keyPart.replace(/&/g, selectorPart) : (selectorPart && selectorPart + " ") + keyPart), ",")), ",") : key, presedence, value, important);
1690 }
1691 }
1692 });
1693 if (numberOfDeclarations) {
1694 rules2.push({
1695 r: atRules.reduceRight(stringifyBlock, stringifyBlock(declarations, selector)),
1696 p: presedence * (1 << 8) + ((Math.max(0, 15 - numberOfDeclarations) & 15) << 4 | (maxPropertyPresedence || 15) & 15)
1697 });
1698 }
1699 };
1700 const variantPresedence = makeVariantPresedenceCalculator(theme2, variants);
1701 return (css, className, rule, layer = 0) => {
1702 layer <<= 28;
1703 rules2 = [];
1704 stringify3([], className ? "." + escape(className) : "", rule ? rule.v.reduceRight(variantPresedence, layer) : layer, css, rule && rule.i);
1705 return rules2;
1706 };
1707};
1708
1709// src/twind/inject.ts
1710var inject = (sheet, mode2, init, context) => {
1711 let sortedPrecedences;
1712 init((value = []) => sortedPrecedences = value);
1713 let insertedRules;
1714 init((value = new Set()) => insertedRules = value);
1715 return ({r: css, p: presedence}) => {
1716 if (!insertedRules.has(css)) {
1717 insertedRules.add(css);
1718 const index = sortedInsertionIndex(sortedPrecedences, presedence);
1719 try {
1720 sheet.insert(css, index);
1721 sortedPrecedences.splice(index, 0, presedence);
1722 } catch (error) {
1723 if (!/:-[mwo]/.test(css)) {
1724 mode2.report({id: "INJECT_CSS_ERROR", css, error}, context);
1725 }
1726 }
1727 }
1728 };
1729};
1730
1731// src/twind/configure.ts
1732var sanitize = (value, defaultValue, disabled, enabled = defaultValue) => value === false ? disabled : value === true ? enabled : value || defaultValue;
1733var loadMode = (mode2) => (typeof mode2 == "string" ? {t: strict, a: warn, i: silent}[mode2[1]] : mode2) || warn;
1734var stringifyVariant = (selector, variant) => selector + (variant[1] == ":" ? tail(variant, 2) + ":" : tail(variant)) + ":";
1735var stringify2 = (rule, directive2 = rule.d) => typeof directive2 == "function" ? "" : rule.v.reduce(stringifyVariant, "") + (rule.i ? "!" : "") + (rule.n ? "-" : "") + directive2;
1736var COMPONENT_PROPS = {_: {value: "", writable: true}};
1737var configure = (config = {}) => {
1738 const theme2 = makeThemeResolver(config.theme);
1739 const mode2 = loadMode(config.mode);
1740 const hash = sanitize(config.hash, false, false, cyrb32);
1741 const important = config.important;
1742 let activeRule = {v: []};
1743 let translateDepth = 0;
1744 const lastTranslations = [];
1745 const context = {
1746 tw: (...tokens) => process(tokens),
1747 theme: (section, key, defaultValue) => {
1748 const value = theme2(section, key, defaultValue) ?? mode2.unknown(section, key == null || Array.isArray(key) ? key : key.split("."), defaultValue != null, context);
1749 return activeRule.n && value && includes("rg", (typeof value)[5]) ? `calc(${value} * -1)` : value;
1750 },
1751 tag: (value) => hash ? hash(value) : value,
1752 css: (rules2) => {
1753 translateDepth++;
1754 const lastTranslationsIndex = lastTranslations.length;
1755 try {
1756 ;
1757 (typeof rules2 == "string" ? parse([rules2]) : rules2).forEach(convert);
1758 const css = Object.create(null, COMPONENT_PROPS);
1759 for (let index = lastTranslationsIndex; index < lastTranslations.length; index++) {
1760 const translation = lastTranslations[index];
1761 if (translation) {
1762 switch (typeof translation) {
1763 case "object":
1764 merge(css, translation, context);
1765 break;
1766 case "string":
1767 css._ += (css._ && " ") + translation;
1768 }
1769 }
1770 }
1771 return css;
1772 } finally {
1773 lastTranslations.length = lastTranslationsIndex;
1774 translateDepth--;
1775 }
1776 }
1777 };
1778 const translate2 = translate({...corePlugins, ...config.plugins}, context);
1779 const doTranslate = (rule) => {
1780 const parentRule = activeRule;
1781 activeRule = rule;
1782 try {
1783 return evalThunk(translate2(rule), context);
1784 } finally {
1785 activeRule = parentRule;
1786 }
1787 };
1788 const variants = {...coreVariants, ...config.variants};
1789 const decorate2 = decorate(config.darkMode || "media", variants, context);
1790 const serialize2 = serialize(sanitize(config.prefix, autoprefix, noprefix), variants, context);
1791 const sheet = config.sheet || (typeof window == "undefined" ? voidSheet() : cssomSheet(config));
1792 const {init = (callback) => callback()} = sheet;
1793 const inject2 = inject(sheet, mode2, init, context);
1794 let idToClassName;
1795 init((value = new Map()) => idToClassName = value);
1796 const inlineDirectiveName = new WeakMap();
1797 const evaluateFunctions = (key, value) => key == "_" ? void 0 : typeof value == "function" ? JSON.stringify(evalThunk(value, context), evaluateFunctions) : value;
1798 const convert = (rule) => {
1799 if (!translateDepth && activeRule.v.length) {
1800 rule = {...rule, v: [...activeRule.v, ...rule.v], $: ""};
1801 }
1802 if (!rule.$) {
1803 rule.$ = stringify2(rule, inlineDirectiveName.get(rule.d));
1804 }
1805 let className = translateDepth ? null : idToClassName.get(rule.$);
1806 if (className == null) {
1807 let translation = doTranslate(rule);
1808 if (!rule.$) {
1809 rule.$ = cyrb32(JSON.stringify(translation, evaluateFunctions));
1810 inlineDirectiveName.set(rule.d, rule.$);
1811 rule.$ = stringify2(rule, rule.$);
1812 }
1813 if (translation && typeof translation == "object") {
1814 rule.v = rule.v.map(prepareVariantSelector);
1815 if (important)
1816 rule.i = important;
1817 translation = decorate2(translation, rule);
1818 if (translateDepth) {
1819 lastTranslations.push(translation);
1820 } else {
1821 const layer = typeof rule.d == "function" ? typeof translation._ == "string" ? 1 : 3 : 2;
1822 className = hash || typeof rule.d == "function" ? (hash || cyrb32)(layer + rule.$) : rule.$;
1823 serialize2(translation, className, rule, layer).forEach(inject2);
1824 if (translation._) {
1825 className += " " + translation._;
1826 }
1827 }
1828 } else {
1829 if (typeof translation == "string") {
1830 className = translation;
1831 } else {
1832 className = rule.$;
1833 mode2.report({id: "UNKNOWN_DIRECTIVE", rule: className}, context);
1834 }
1835 if (translateDepth && typeof rule.d !== "function") {
1836 lastTranslations.push(className);
1837 }
1838 }
1839 if (!translateDepth) {
1840 idToClassName.set(rule.$, className);
1841 ensureMaxSize(idToClassName, 3e4);
1842 }
1843 }
1844 return className;
1845 };
1846 const process = (tokens) => join(parse(tokens).map(convert).filter(Boolean), " ");
1847 const preflight = sanitize(config.preflight, identity, false);
1848 if (preflight) {
1849 const css = createPreflight(theme2);
1850 const styles = serialize2(typeof preflight == "function" ? evalThunk(preflight(css, context), context) || css : {...css, ...preflight});
1851 init((injected = (styles.forEach(inject2), true)) => injected);
1852 }
1853 return {
1854 init: () => mode2.report({id: "LATE_SETUP_CALL"}, context),
1855 process
1856 };
1857};
1858
1859// src/twind/instance.ts
1860var create = (config) => {
1861 let process = (tokens) => {
1862 init();
1863 return process(tokens);
1864 };
1865 let init = (config2) => {
1866 ;
1867 ({process, init} = configure(config2));
1868 };
1869 if (config)
1870 init(config);
1871 let context;
1872 const fromContext = (key) => () => {
1873 if (!context) {
1874 process([
1875 (_4) => {
1876 context = _4;
1877 return "";
1878 }
1879 ]);
1880 }
1881 return context[key];
1882 };
1883 return {
1884 tw: Object.defineProperties((...tokens) => process(tokens), {
1885 theme: {
1886 get: fromContext("theme")
1887 }
1888 }),
1889 setup: (config2) => init(config2)
1890 };
1891};
1892
1893// src/twind/default.ts
1894var {tw, setup} = /* @__PURE__ */ create();
1895export {
1896 apply,
1897 autoprefix,
1898 create,
1899 cssomSheet,
1900 directive,
1901 cyrb32 as hash,
1902 mode,
1903 noprefix,
1904 setup,
1905 silent,
1906 strict,
1907 theme,
1908 tw,
1909 voidSheet,
1910 warn
1911};
1912//# sourceMappingURL=twind.esnext.js.map