import {
  useCurriculumReviewContext
} from "./chunk-WZVJYDVP.js";
import {
  getCurriculumIcon,
  getCurriculumQuestionIconColor,
  getCurriculumQuestionTypeDescription
} from "./chunk-PAFFDZBG.js";
import {
  Separator
} from "./chunk-HYITAA4J.js";
import {
  Grid
} from "./chunk-EGEQY3KT.js";
import {
  Badge
} from "./chunk-FCIHNIOH.js";
import {
  Typo
} from "./chunk-PARGQUJB.js";
import {
  Heading
} from "./chunk-34OQDUQR.js";
import {
  Box
} from "./chunk-4Y5BEXVN.js";
import {
  Button
} from "./chunk-AFPH32MF.js";
import {
  Flex
} from "./chunk-25HMMI7R.js";

// src/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/start-review.tsx
import { jsx, jsxs } from "react/jsx-runtime";
var renderPreviewContent = (args) => {
  const { question } = args;
  const Icon = getCurriculumIcon({
    type: question.type,
    icon: question.icon
  });
  const getDescription = () => {
    return [
      getCurriculumQuestionTypeDescription(question.type),
      question.duration ? `${question.duration}\uBD84` : ""
    ].filter(Boolean).join(" | ");
  };
  return /* @__PURE__ */ jsxs(
    Grid,
    {
      columns: "16px 1fr",
      gap: "2",
      px: "4",
      py: "2",
      width: "100%",
      children: [
        /* @__PURE__ */ jsx(Box, { mt: "1", children: /* @__PURE__ */ jsx(Icon, { color: getCurriculumQuestionIconColor(question.type) }) }),
        /* @__PURE__ */ jsxs(Box, { children: [
          /* @__PURE__ */ jsx(Typo, { as: "p", color: "gray", weight: "bold", children: question.title }),
          /* @__PURE__ */ jsx(Typo, { color: "gray", children: getDescription() })
        ] })
      ]
    },
    question.uuid
  );
};
var getReviewContentValue = (question, answer) => {
  var _a, _b, _c;
  if (question.type === "question_satisfaction_option") {
    return (_c = (_b = (_a = question.options) == null ? void 0 : _a.find((option) => option.value === Number(answer))) == null ? void 0 : _b.label) != null ? _c : "";
  }
  return answer;
};
var renderReviewContent = (args) => {
  const { question, answer } = args;
  const Icon = getCurriculumIcon({
    type: question.type,
    icon: question.icon
  });
  const color = getCurriculumQuestionIconColor(question.type);
  const badgeColor = ["question_radio", "question_satisfaction_option"].includes(question.type) ? "accent" : "neutral";
  const value = getReviewContentValue(question, answer);
  return /* @__PURE__ */ jsxs(
    Grid,
    {
      columns: "16px 1fr",
      gap: "2",
      px: "4",
      py: "2",
      width: "100%",
      children: [
        /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Icon, { color }) }),
        /* @__PURE__ */ jsxs(Box, { children: [
          /* @__PURE__ */ jsx(Typo, { as: "p", color: "gray", mb: "2", weight: "bold", children: question.title }),
          /* @__PURE__ */ jsx(Badge, { color: badgeColor, size: "large", style: { whiteSpace: "break-spaces", lineBreak: "anywhere" }, children: value || "(\uBBF8 \uC751\uB2F5)" })
        ] })
      ]
    },
    question.uuid
  );
};
function StartReview({ onStart }) {
  const { curriculum, reviewContents, sectionTitle, done, formik } = useCurriculumReviewContext();
  return /* @__PURE__ */ jsx(
    Flex,
    {
      align: "center",
      direction: "column",
      height: "100%",
      justify: "center",
      width: "100%",
      children: /* @__PURE__ */ jsxs(
        Flex,
        {
          align: "center",
          direction: "column",
          height: "100%",
          justify: "center",
          maxWidth: "650px",
          pb: { initial: "6", sm: "0" },
          pt: { initial: "4", sm: "0" },
          px: { initial: "4", sm: "0" },
          width: "100%",
          children: [
            /* @__PURE__ */ jsx(Typo, { color: "gray", mb: "1", children: curriculum.title }),
            /* @__PURE__ */ jsx(Heading, { variant: "heading3", children: reviewContents.title }),
            /* @__PURE__ */ jsx(Separator, { my: "4", style: { width: 100 } }),
            /* @__PURE__ */ jsxs(Typo, { align: "left", as: "p", color: "gray", mb: "4", children: [
              /* @__PURE__ */ jsx(Typo, { as: "span", weight: "bold", children: sectionTitle }),
              " ",
              /* @__PURE__ */ jsx(Typo, { children: reviewContents.description })
            ] }),
            /* @__PURE__ */ jsx(Box, { mb: "5", overflowY: "auto", width: "100%", children: reviewContents.questions.map((question) => {
              if (done) {
                return renderReviewContent({ question, answer: formik.values.answers[question.uuid] });
              }
              return renderPreviewContent({ question });
            }) }),
            /* @__PURE__ */ jsx(Button, { color: "yellow", onClick: onStart, variant: done ? "outline" : "solid", children: done ? "\uB098\uC758 \uC751\uB2F5 \uC218\uC815\uD558\uAE30" : reviewContents.buttonTitle })
          ]
        }
      )
    }
  );
}
var start_review_default = StartReview;

export {
  start_review_default
};
//# sourceMappingURL=chunk-5QII45FD.js.map