import { system } from "../system/system.js";
import "../system/index.js";
import { createX } from "@xstyled/styled-components";
import scStyled, { createGlobalStyle, css } from "styled-components";
import { transform } from "@xstyled/core";
import { flattenStrings } from "@xstyled/util";

//#region src/core/styled.ts
/** Creates enhanced 'styled' function with optional style generators and prop-forwarding safeguard. */
function createBaseStyled(css$2, generator) {
	const config = generator ? forwardPropConfig(generator) : {};
	return ((component) => {
		return getCreateStyle(config ? scStyled(component).withConfig(config) : scStyled(component), css$2, generator);
	});
}
/** Enhances createGlobalStyle function with custom 'css' helper. */
function createCreateGlobalStyle() {
	const css$2 = createCssFunction();
	return ((...args) => createGlobalStyle([css$2(...args)]));
}
/** Enhances styled-components' 'css' function with automatic theming. */
function createCssFunction() {
	return ((...args) => {
		return flattenStrings(css(...args)).map(transform);
	});
}
/**
* Creates full 'styled' function with properties for components.
* Includes base version and system version using 'Box' postfix.
*/
function createStyled(generator) {
	const css$2 = createCssFunction();
	const styled$1 = createBaseStyled(css$2);
	const vstyled = createBaseStyled(css$2, generator);
	Object.keys(scStyled).forEach((key) => {
		styled$1[key] = styled$1(key);
		styled$1[`${key}Box`] = vstyled(key);
	});
	return styled$1;
}
/** Provides configuration to the 'styled' function, which filters out xstyled system props. */
function forwardPropConfig(generator) {
	return { shouldForwardProp: (prop, defaultValidatorFn) => {
		if (typeof prop === "string" && generator.meta.props.includes(prop)) return false;
		return defaultValidatorFn(prop);
	} };
}
/** Extends styled component with a given styles generator (system). */
function getCreateStyle(baseCreateStyle, css$2, generator) {
	const createStyle = (...args) => baseCreateStyle`${css$2(...args)}${generator}`;
	createStyle.attrs = (attrs) => getCreateStyle(baseCreateStyle.attrs(attrs), css$2, generator);
	createStyle.withConfig = (config) => getCreateStyle(baseCreateStyle.withConfig(config), css$2, generator);
	return createStyle;
}
const createGlobalStyle$1 = createCreateGlobalStyle();
const css$1 = createCssFunction();
const v = createX(system);
const styled = createStyled(system);

//#endregion
export { createGlobalStyle$1 as createGlobalStyle, css$1 as css, styled, v };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=styled.js.map