'use strict'; const plugin = require('tailwindcss/plugin'); const animations = require('@vace/animations'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; } const plugin__default = /*#__PURE__*/_interopDefaultLegacy(plugin); function toSnake(str) { return str.replace(/[A-Z]/g, (letter) => "-" + letter.toLowerCase()); } const easingSnap = Object.keys(animations.easing).reduce((obj, key) => { obj[toSnake(key).replace("ease-", "")] = animations.easing[key]; return obj; }, /* @__PURE__ */ Object.create(null)); const theme = { animationDelay: { 100: "100ms", 150: "150ms", 200: "200ms", 300: "300ms", 500: "500ms", 700: "700ms", 1e3: "1000ms", "1s": "1s", "2s": "2s", "3s": "3s", "4s": "4s", "5s": "5s" }, animationDuration: { 100: "100ms", 150: "150ms", 200: "200ms", 300: "300ms", 500: "500ms", 700: "700ms", 1e3: "1000ms", "1s": "1s", "2s": "2s", "3s": "3s", "4s": "4s", "5s": "5s" }, animationTimingFunction: { "ease": "ease", "in": "ease-in", "out": "ease-out", "in-out": "ease-in-out", "linear": "linear", "start": "step-start", "end": "step-end", "1": "steps(1, end)", "2": "steps(2, end)", "3": "steps(3, end)", "4": "steps(4, end)", "5": "steps(5, end)", "frames-1": "frames(1, end)", "frames-2": "frames(2, end)", "frames-3": "frames(3, end)", "frames-4": "frames(4, end)", "frames-5": "frames(5, end)", ...easingSnap }, animationIterationCount: { infinite: "infinite", inf: "infinite", 1: 1, 2: 2, 3: 3 }, animationDirection: { normal: "normal", reverse: "reverse", rev: "reverse", alternate: "alternate", alt: "alternate", "alternate-reverse": "alternate-reverse", "altrev": "alternate-reverse" }, animationFillMode: { none: "none", fwd: "forwards", forwards: "forwards", bck: "backwards", backwards: "backwards", both: "both" }, animationPlayState: { running: "running", paused: "paused" }, animationTransformOrigin: { center: "center", top: "top", t: "top", "top-right": "top right", tr: "top right", right: "right", r: "right", "bottom-right": "bottom right", "br": "bottom right", bottom: "bottom", b: "bottom", "bottom-left": "bottom left", "bl": "bottom left", left: "left", l: "left", "top-left": "top left", "tl": "top left" } }; const index = plugin__default.withOptions( function pluginFunction({ prefix = "ani", properties } = {}) { return function pluginCreator({ addUtilities, matchUtilities, theme: theme2 }) { const indexed = /* @__PURE__ */ Object.create(null); const components = animations.animations.reduce((conf, anim) => { const key = `${prefix}-${anim.name}`; indexed[anim.name] = key; const { animationDelay = "0s", animationDuration = "1s", animationDirection = "normal", animationIterationCount = 1, animationFillMode = "both", animationPlayState = "running", animationTimeingFunction = "ease", backfaceVisibility = null } = { ...properties, ...anim.properties }; conf[key] = { backfaceVisibility, animation: [ `var(--${prefix}-dur, ${animationDuration})`, `var(--${prefix}-ease${animationTimeingFunction ? `, ${animationTimeingFunction}` : ""})`, `var(--${prefix}-delay, ${animationDelay})`, `var(--${prefix}-repeat${animationIterationCount ? `, ${animationIterationCount}` : ""})`, `var(--${prefix}-dir${animationDirection ? `, ${animationDirection}` : ""})`, `var(--${prefix}-mode, ${animationFillMode})`, `var(--${prefix}-state${animationPlayState ? `, ${animationPlayState}` : ""})`, key ].join(" "), [`@keyframes ${key}`]: anim.keyframes }; return conf; }, /* @__PURE__ */ Object.create(null)); matchUtilities({ [prefix]: (value) => components[value] }, { values: indexed }); matchUtilities( { [prefix + "-delay"]: (value) => ({ [`--${prefix}-delay`]: _addTimeMs(value) }) }, { values: theme2("animationDelay") } ); matchUtilities( { [prefix + "-dur"]: (value) => ({ [`--${prefix}-dur`]: _addTimeMs(value) }) }, { values: theme2("animationDuration") } ); matchUtilities( { [prefix + "-repeat"]: (value) => ({ [`--${prefix}-repeat`]: value }) }, { values: theme2("animationIterationCount") } ); matchUtilities( { [prefix + "-ease"]: (value) => ({ [`--${prefix}-ease`]: _addStep(value) }) }, { values: theme2("animationTimingFunction") } ); _createShortCut("animationDirection", "dir"); _createShortCut("animationFillMode", "mode"); _createShortCut("animationPlayState", "state"); _createShortCut("animationTransformOrigin", "origin", "transformOrigin"); function _createShortCut(themeName, keyPrefix, useCssField) { const config = theme2(themeName); const mapkeys = Object.keys(config); const cached = /* @__PURE__ */ Object.create(null); const shortPrefix = keyPrefix ? `${prefix}-${keyPrefix}` : prefix; for (const key of mapkeys) { cached[`.${shortPrefix}-${key}`] = { [useCssField || `--${prefix}-${keyPrefix}`]: config[key] }; } addUtilities(cached); } function _addTimeMs(val) { return +val !== +val ? val : val + "ms"; } function _addStep(val) { return +val !== +val ? val : `steps(${val}, end)`; } }; }, function pluginConfig(options) { return { theme }; } ); module.exports = index;