"use client";
import { rem } from "../../core/utils/units-converters/rem.mjs";
import { createVarsResolver } from "../../core/styles-api/create-vars-resolver/create-vars-resolver.mjs";
import { useProps } from "../../core/MantineProvider/use-props/use-props.mjs";
import { useStyles } from "../../core/styles-api/use-styles/use-styles.mjs";
import { factory } from "../../core/factory/factory.mjs";
import { Box } from "../../core/Box/Box.mjs";
import { Curve } from "./Curve/Curve.mjs";
import { getCurves } from "./get-curves/get-curves.mjs";
import RingProgress_module_default from "./RingProgress.module.mjs";
import { createElement } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/RingProgress/RingProgress.tsx
function getClampedThickness(thickness, size) {
	return Math.min(thickness || 12, (size || 120) / 4);
}
const defaultProps = {
	size: 120,
	thickness: 12,
	startAngle: 270
};
const varsResolver = createVarsResolver((_, { size, thickness, transitionDuration, startAngle }) => ({
	root: {
		"--rp-size": rem(size),
		"--rp-label-offset": rem(thickness * 2),
		"--rp-transition-duration": transitionDuration ? `${transitionDuration}ms` : void 0
	},
	svg: { "--rp-start-angle": `${startAngle}deg` }
}));
const RingProgress = factory((_props) => {
	const props = useProps("RingProgress", defaultProps, _props);
	const { classNames, className, style, styles, unstyled, vars, label, sections, size, thickness, roundCaps, rootColor, transitionDuration, sectionGap, startAngle, attributes, ...others } = props;
	const getStyles = useStyles({
		name: "RingProgress",
		classes: RingProgress_module_default,
		props,
		className,
		style,
		classNames,
		styles,
		unstyled,
		attributes,
		vars,
		varsResolver
	});
	const clampedThickness = getClampedThickness(thickness, size);
	const curves = getCurves({
		size,
		thickness: clampedThickness,
		sections,
		renderRoundedLineCaps: roundCaps,
		rootColor,
		sectionGap
	}).map(({ data, sum, root, lineRoundCaps, offset }, index) => /* @__PURE__ */ createElement(Curve, {
		...data,
		key: index,
		size,
		thickness: clampedThickness,
		sum,
		offset,
		color: data?.color,
		root,
		lineRoundCaps,
		getStyles
	}));
	return /* @__PURE__ */ jsxs(Box, {
		...getStyles("root"),
		size,
		...others,
		children: [/* @__PURE__ */ jsx("svg", {
			...getStyles("svg"),
			viewBox: `0 0 ${size} ${size}`,
			children: curves
		}), label && /* @__PURE__ */ jsx("div", {
			...getStyles("label"),
			children: label
		})]
	});
});
RingProgress.classes = RingProgress_module_default;
RingProgress.varsResolver = varsResolver;
RingProgress.displayName = "@mantine/core/RingProgress";
//#endregion
export { RingProgress };

//# sourceMappingURL=RingProgress.mjs.map