import {
  DataList
} from "./chunk-VTJZMOSP.js";
import {
  toast
} from "./chunk-CYYWMYE7.js";
import {
  Button
} from "./chunk-U7JPP7WJ.js";

// src/app/platform/userInfos/utils.tsx
import { format } from "date-fns";
import { CopyIcon } from "@radix-ui/react-icons";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
var infoList = [
  { label: "\uC774\uB984", getValue: (customer) => customer == null ? void 0 : customer.username },
  { label: "\uC131\uBCC4", getValue: (customer) => customer == null ? void 0 : customer.gender },
  {
    label: "\uC0DD\uB144\uC6D4\uC77C",
    getValue: (customer) => (customer == null ? void 0 : customer.birthdate) && format(customer.birthdate, "yyyy.MM.dd")
  },
  { label: "\uBD80\uC11C", getValue: (customer) => customer == null ? void 0 : customer.team },
  { label: "\uC9C1\uCC45", getValue: (customer) => customer == null ? void 0 : customer.position },
  { label: "\uC9C1\uAE09", getValue: (customer) => customer == null ? void 0 : customer.level },
  { label: "\uC774\uBA54\uC77C", getValue: (customer) => customer == null ? void 0 : customer.email, copyable: true },
  {
    label: "\uC804\uD654\uBC88\uD638",
    getValue: (customer) => customer == null ? void 0 : customer.phone,
    render: (value) => {
      return value == null ? void 0 : value.replace(/[^0-9]/g, "").replace(/^(\d{2,3})(\d{3,4})(\d{4})$/, `$1-$2-$3`);
    },
    copyable: true
  }
];
var sessionStatusChecker = (value, session) => {
  if ((session == null ? void 0 : session.state) === "inProgress") {
    return value;
  }
  return "-";
};
var sessionList = [
  {
    label: "\uC9C4\uD589\uC911\uC778 \uC138\uC158",
    getValue: (session) => {
      return sessionStatusChecker(
        `${(session == null ? void 0 : session.currentSession) || "-"}\uD68C\uCC28/${(session == null ? void 0 : session.totalSession) || "-"}\uD68C\uCC28`,
        session
      );
    }
  },
  {
    label: "\uB2E4\uC74C \uC138\uC158 \uC77C\uC2DC",
    getValue: (session) => sessionStatusChecker(
      (session == null ? void 0 : session.nextSessionDate) ? format(session.nextSessionDate, "yyyy\uB144 MM\uC6D4 dd\uC77C HH\uC2DC mm\uBD84") : "-",
      session
    )
  },
  {
    label: "\uB2E4\uC74C \uC138\uC158 \uCC38\uC5EC \uBC29\uC2DD",
    getValue: (session) => sessionStatusChecker((session == null ? void 0 : session.nextSessionType) || "-", session)
  },
  {
    label: "\uCF54\uCE6D \uB9CC\uB8CC \uAE30\uD55C",
    getValue: (session) => (session == null ? void 0 : session.expiredAt) ? format(session.expiredAt, "yyyy\uB144 MM\uC6D4 dd\uC77C") : "-"
  }
];
var renderItem = (info, data) => {
  const value = info.getValue(data);
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    info.render ? info.render(value) : value || "-",
    info.copyable && value ? /* @__PURE__ */ jsx(CopyButton, { value }) : null
  ] });
};
var renderDataListItem = (info, data) => {
  return /* @__PURE__ */ jsxs(DataList.Item, { children: [
    /* @__PURE__ */ jsx(DataList.Label, { children: info.label }),
    /* @__PURE__ */ jsx(DataList.Value, { children: renderItem(info, data) })
  ] }, info.label);
};
function CopyButton(props) {
  return /* @__PURE__ */ jsx(
    Button,
    {
      color: "gray",
      onClick: () => {
        void navigator.clipboard.writeText(props.value);
        toast.success("\uBCF5\uC0AC\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
      },
      style: { marginLeft: "0", marginTop: "0" },
      variant: "transparent",
      children: /* @__PURE__ */ jsx(CopyIcon, {})
    }
  );
}

export {
  infoList,
  sessionList,
  renderItem,
  renderDataListItem,
  CopyButton
};
//# sourceMappingURL=chunk-I5XSLBW2.js.map