{
  "version": 3,
  "sources": ["ssg:https://asset.29cm.co.kr/contents/framer/components/systems/KeywordCollection/KeywordCollectionTags/KeywordCollectionTags.utils.js"],
  "sourcesContent": ["import { createKRTimeZoneDate } from \"../../../../utils/createUTCDate.js\";\nimport { isAbove } from \"../../../../utils/date.js\";\nimport { ko } from \"../../../../node_modules/date-fns/locale/ko.js\";\nimport { isBefore } from \"../../../../node_modules/date-fns/isBefore.js\";\nimport { isWithinInterval } from \"../../../../node_modules/date-fns/isWithinInterval.js\";\nimport { formatDate as format } from \"../../../../node_modules/date-fns/format.js\";\nconst SEPARATOR = \"@\";\nconst reservedWords = [\"DATE\", \"GENDER\"];\nconst getProductGroupType = (productGroupList) => {\n  const includedReservedWordProductGroup = productGroupList.find((group) => group.title.includes(SEPARATOR));\n  if (includedReservedWordProductGroup === void 0) {\n    return \"KEYWORD\";\n  }\n  const firstReservedWord = includedReservedWordProductGroup.title.split(SEPARATOR)[0];\n  if (!reservedWords.includes(firstReservedWord)) {\n    return \"KEYWORD\";\n  }\n  return firstReservedWord;\n};\nconst reshapeProductGroupList = (productGroupList, productGroupType, gender) => {\n  if (productGroupType === \"DATE\") {\n    return reshapeDateProductGroupList(productGroupList);\n  }\n  if (productGroupType === \"GENDER\") {\n    return reshapeGenderProductGroupList(productGroupList, gender);\n  }\n  return productGroupList;\n};\nconst findInitialProductGroupId = (collectionProductGroup, reshapedProductGroupList, productGroupType) => {\n  if (collectionProductGroup.length === 0) {\n    return void 0;\n  }\n  if (productGroupType === \"DATE\") {\n    const currentProductGroupList = findCurrentProductGroupListByDate(collectionProductGroup);\n    return currentProductGroupList.productGroupId;\n  }\n  return reshapedProductGroupList[0].productGroupId;\n};\nconst reshapeDateProductGroupList = (productGroupList) => productGroupList.map((group) => ({\n  ...group,\n  title: formatTitle(group.title, \"DATE\")\n}));\nconst reshapeGenderProductGroupList = (productGroupList, gender) => {\n  const genderProductGroup = productGroupList.reduce((acc, cur) => {\n    const isCommonGroup = !cur.title.includes(SEPARATOR);\n    if (isCommonGroup) {\n      return {\n        ...acc,\n        common: [...acc.common, cur]\n      };\n    }\n    const isNotAllowedReservedWord = cur.title.split(SEPARATOR)[0] !== \"GENDER\";\n    if (isNotAllowedReservedWord) {\n      return {\n        ...acc,\n        notAllowed: [...acc.notAllowed, cur]\n      };\n    }\n    const groupGender = cur.title.split(SEPARATOR)[1].split(\":\")[0];\n    const formattedTitleGroup = {\n      ...cur,\n      title: formatTitle(cur.title, \"GENDER\")\n    };\n    switch (groupGender) {\n      case \"F\":\n        return {\n          ...acc,\n          female: [...acc.female, formattedTitleGroup]\n        };\n      case \"M\":\n        return {\n          ...acc,\n          male: [...acc.male, formattedTitleGroup]\n        };\n      default:\n        return {\n          ...acc,\n          notAllowed: [...acc.notAllowed, cur]\n        };\n    }\n  }, {\n    male: [],\n    female: [],\n    common: [],\n    notAllowed: []\n  });\n  if (!gender || gender === \"F\") {\n    return [...genderProductGroup.female, ...genderProductGroup.common, ...genderProductGroup.male, ...genderProductGroup.notAllowed];\n  }\n  return [...genderProductGroup.male, ...genderProductGroup.common, ...genderProductGroup.female, ...genderProductGroup.notAllowed];\n};\nconst findCurrentProductGroupIndex = (productGroupList) => {\n  const now = createKRTimeZoneDate();\n  return productGroupList.findIndex((group, index) => {\n    const standardDate = new Date(group.title.split(\"@\")[1]);\n    const nextGroupList = productGroupList[index + 1];\n    const nextDate = nextGroupList ? new Date(nextGroupList.title.split(\"@\")[1]) : null;\n    const isFirstProductGroupList = index === 0;\n    const isLastProductGroupList = nextDate === null;\n    const isBeforeStart = isFirstProductGroupList && isBefore(now, standardDate);\n    const isLast = isLastProductGroupList && isAbove(now, standardDate);\n    const isWithin = !isLastProductGroupList && isWithinInterval(now, {\n      start: standardDate,\n      end: nextDate\n    });\n    return isBeforeStart || isLast || isWithin;\n  });\n};\nconst findCurrentProductGroupListByDate = (productGroupList) => {\n  const currentIndex = findCurrentProductGroupIndex(productGroupList);\n  return productGroupList[currentIndex ?? 0];\n};\nconst formatTitle = (title, reservedWord) => {\n  if (!reservedWord) {\n    return title;\n  }\n  const [, needToFormatTitle] = title.split(SEPARATOR);\n  switch (reservedWord) {\n    case \"DATE\":\n      return format(new Date(needToFormatTitle), \"M.d. EEEEE\", {\n        locale: ko\n      });\n    case \"GENDER\":\n      return needToFormatTitle.split(\":\")[1];\n    default:\n      return title;\n  }\n};\nexport {\n  findCurrentProductGroupIndex,\n  findInitialProductGroupId,\n  getProductGroupType,\n  reshapeProductGroupList\n};\n"],
  "mappings": "wKAMA,IAAMA,EAAY,IACZC,EAAgB,CAAC,OAAQ,QAAQ,EACjCC,EAAuBC,GAAqB,CAChD,IAAMC,EAAmCD,EAAiB,KAAME,GAAUA,EAAM,MAAM,SAASL,CAAS,CAAC,EACzG,GAAII,IAAqC,OACvC,MAAO,UAET,IAAME,EAAoBF,EAAiC,MAAM,MAAMJ,CAAS,EAAE,CAAC,EACnF,OAAKC,EAAc,SAASK,CAAiB,EAGtCA,EAFE,SAGX,EACMC,EAA0B,CAACJ,EAAkBK,EAAkBC,IAC/DD,IAAqB,OAChBE,EAA4BP,CAAgB,EAEjDK,IAAqB,SAChBG,EAA8BR,EAAkBM,CAAM,EAExDN,EAEHS,EAA4B,CAACC,EAAwBC,EAA0BN,IAAqB,CACxG,GAAIK,EAAuB,SAAW,EAGtC,OAAIL,IAAqB,OACSO,EAAkCF,CAAsB,EACzD,eAE1BC,EAAyB,CAAC,EAAE,cACrC,EACMJ,EAA+BP,GAAqBA,EAAiB,IAAKE,IAAW,CACzF,GAAGA,EACH,MAAOW,EAAYX,EAAM,MAAO,MAAM,CACxC,EAAE,EACIM,EAAgC,CAACR,EAAkBM,IAAW,CAClE,IAAMQ,EAAqBd,EAAiB,OAAO,CAACe,EAAKC,IAAQ,CAE/D,GADsB,CAACA,EAAI,MAAM,SAASnB,CAAS,EAEjD,MAAO,CACL,GAAGkB,EACH,OAAQ,CAAC,GAAGA,EAAI,OAAQC,CAAG,CAC7B,EAGF,GADiCA,EAAI,MAAM,M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BG,EAAST,EAAKG,CAAY,EACrEO,EAASH,GAA0BI,EAAQX,EAAKG,CAAY,EAC5DS,EAAW,CAACL,GAA0BM,EAAiBb,EAAK,CAChE,MAAOG,EACP,IAAKE,CACP,CAAC,EACD,OAAOG,GAAiBE,GAAUE,CACpC,CAAC,CACH,EACMpB,EAAqCZ,GAAqB,CAC9D,IAAMkC,EAAef,EAA6BnB,CAAgB,EAClE,OAAOA,EAAiBkC,GAAgB,CAAC,CAC3C,EACMrB,EAAc,CAACsB,EAAOC,IAAiB,CAC3C,GAAI,CAACA,EACH,OAAOD,EAET,GAAM,CAAC,CAAEE,CAAiB,EAAIF,EAAM,MAAMtC,CAAS,EACnD,OAAQuC,EAAc,CACpB,IAAK,OACH,OAAOE,EAAO,IAAI,KAAKD,CAAiB,EAAG,aAAc,CACvD,OAAQE,CACV,CAAC,EACH,IAAK,SACH,OAAOF,EAAkB,MAAM,GAAG,EAAE,CAAC,EACvC,QACE,OAAOF,CACX,CACF",
  "names": ["SEPARATOR", "reservedWords", "getProductGroupType", "productGroupList", "includedReservedWordProductGroup", "group", "firstReservedWord", "reshapeProductGroupList", "productGroupType", "gender", "reshapeDateProductGroupList", "reshapeGenderProductGroupList", "findInitialProductGroupId", "collectionProductGroup", "reshapedProductGroupList", "findCurrentProductGroupListByDate", "formatTitle", "genderProductGroup", "acc", "cur", "groupGender", "formattedTitleGroup", "findCurrentProductGroupIndex", "now", "createKRTimeZoneDate", "index", "standardDate", "nextGroupList", "nextDate", "isFirstProductGroupList", "isLastProductGroupList", "isBeforeStart", "isBefore", "isLast", "isAbove", "isWithin", "isWithinInterval", "currentIndex", "title", "reservedWord", "needToFormatTitle", "format", "ko"]
}
