import { Box } from "../box/box.js";
import { Icon } from "../icon/icon.js";
import { Button } from "../button/button.js";
import { Card } from "../card/card.js";
import { H4 } from "../heading/headings.js";
import { tutorialColors } from "./consts.js";
import { TutorialStep } from "./tutorialStep.js";
import "../index.js";
import { useEffect, useState } from "react";
import { jsx, jsxs } from "react/jsx-runtime";

//#region src/tutorial/tutorialCard.tsx
function TutorialCard({ actionLabel = "Action", className, title, readMoreLink, steps: propsSteps = [], showSkipButton, onAction, onDismiss, onFinish, includeFinalPage, useContentTitle }) {
	const [steps, setSteps] = useState([]);
	const [activeStep, setActiveStep] = useState(0);
	useEffect(() => {
		if (title && propsSteps.length) {
			const s = propsSteps.map((step, key) => ({
				active: false,
				step,
				key
			}));
			const finalStep = {
				title: `Completed!`,
				content: `${readMoreLink ? "To learn more, please visit:" : "Thank you!"}`
			};
			if (readMoreLink) finalStep.readMoreLink = readMoreLink;
			includeFinalPage ? setSteps([...s, {
				step: finalStep,
				key: propsSteps.length
			}]) : setSteps([...s]);
		}
	}, [title, propsSteps]);
	const isStartStep = activeStep === 0;
	const isFinalStep = includeFinalPage ? activeStep === propsSteps.length : activeStep === propsSteps.length - 1;
	return /* @__PURE__ */ jsxs(Card, {
		bg: tutorialColors.bg,
		className,
		color: tutorialColors.color,
		column: true,
		justifyContent: "space-between",
		minH: 400,
		px: 3,
		py: 2,
		w: 580,
		children: [
			/* @__PURE__ */ jsxs(Box, {
				alignContent: "center",
				alignItems: "center",
				flex: 0,
				flexDirection: "row",
				flexGrow: 0,
				justifyContent: "space-between",
				minH: 48,
				row: true,
				style: { WebkitFlexGrow: "0" },
				children: [/* @__PURE__ */ jsx(H4, {
					color: tutorialColors.color,
					children: useContentTitle ? steps[activeStep]?.step?.title : title
				}), !isFinalStep && /* @__PURE__ */ jsx(Button, {
					"aria-label": "close",
					icon: "uiTimes",
					onClick: onDismiss,
					scale: 2,
					variant: "tertiaryLight"
				})]
			}),
			/* @__PURE__ */ jsx(Box, {
				flex: 5,
				row: true,
				children: steps?.map?.((s) => /* @__PURE__ */ jsx(TutorialStep, {
					active: s.key === activeStep,
					content: s.step.content,
					readMoreLink: s.step.readMoreLink,
					title: s.step.title,
					useContentTitle
				}, s.step.title))
			}),
			/* @__PURE__ */ jsxs(Box, {
				alignItems: "center",
				justifyContent: "space-between",
				mt: 0,
				children: [/* @__PURE__ */ jsxs(Box, {
					alignItems: "center",
					justifyContent: "space-between",
					w: "-webkit-fill-available",
					children: [
						/* @__PURE__ */ jsx(Button, {
							"aria-label": "previous",
							color: tutorialColors.buttonColor,
							disabled: isStartStep,
							icon: "uiArrowLeft",
							onClick: () => setActiveStep(activeStep - 1),
							scale: 2,
							transition: "none",
							variant: "tertiaryLight",
							w: "34"
						}),
						/* @__PURE__ */ jsx(Box, {
							className: "vuiTutorialStepDots",
							children: steps?.map?.((s) => /* @__PURE__ */ jsx(Icon, {
								color: s.key === activeStep ? tutorialColors.color : "darkBlue.30",
								cursor: "pointer",
								hoverColor: tutorialColors.buttonColor,
								name: "uiDotFull",
								onClick: () => setActiveStep(s.key)
							}, s.key))
						}),
						/* @__PURE__ */ jsx(Button, {
							"aria-label": "next",
							color: tutorialColors.buttonColor,
							disabled: isFinalStep,
							icon: "uiArrowRight",
							onClick: () => setActiveStep(activeStep + 1),
							scale: 2,
							transition: "none",
							variant: "tertiaryLight",
							w: "34"
						})
					]
				}), (showSkipButton || isFinalStep || !!onAction) && /* @__PURE__ */ jsxs(Box, {
					alignItems: "center",
					justifyContent: "space-between",
					children: [
						showSkipButton && !isFinalStep && /* @__PURE__ */ jsx(Button, {
							mx: 1,
							onClick: onDismiss,
							variant: "secondaryLight",
							children: "Skip"
						}),
						isFinalStep && /* @__PURE__ */ jsx(Button, {
							mx: 1,
							onClick: onFinish,
							variant: "primaryLight",
							children: "I got it"
						}),
						!!onAction && /* @__PURE__ */ jsx(Button, {
							ml: 1,
							mr: showSkipButton || isFinalStep ? 12 : 2,
							onClick: onAction,
							variant: "primaryLight",
							children: actionLabel
						})
					]
				})]
			})
		]
	});
}
TutorialCard.displayName = "TutorialCard";

//#endregion
export { TutorialCard };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=tutorialCard.js.map