{"version":3,"file":"Schedulable.DSDYMJMM.mjs","names":["useMemo","useState"],"sources":["https:/asset.29cm.co.kr/contents/framer/components/primitives/Schedulable/Schedulable.types.js","https:/asset.29cm.co.kr/contents/framer/components/primitives/Schedulable/Schedulable.utils.js","https:/asset.29cm.co.kr/contents/framer/components/primitives/Schedulable/Schedulable.hooks.js","https:/asset.29cm.co.kr/contents/framer/components/primitives/Schedulable/Schedulable.js","https:/framerusercontent.com/modules/bv2yzxT3iEOjAMleVPGP/8UbCcuQA0I1fhMsF0CR6/Schedulable.js"],"sourcesContent":["var ScheduleType = /* @__PURE__ */ ((ScheduleType2) => {\n  ScheduleType2[ScheduleType2[\"MANUAL\"] = 0] = \"MANUAL\";\n  ScheduleType2[ScheduleType2[\"REPEAT\"] = 1] = \"REPEAT\";\n  return ScheduleType2;\n})(ScheduleType || {});\nexport {\n  ScheduleType\n};\n","import { createKRTimeZoneDate } from \"../../../utils/createUTCDate.js\";\nimport { ScheduleType } from \"./Schedulable.types.js\";\nimport { isAbove, composeFramerDateTime } from \"../../../utils/date.js\";\nimport { isWithinInterval } from \"../../../node_modules/date-fns/isWithinInterval.js\";\nimport { differenceInCalendarDays } from \"../../../node_modules/date-fns/differenceInCalendarDays.js\";\nconst findCurrentSchedule = (schedules) => {\n  const now = createKRTimeZoneDate();\n  return schedules.find((schedule, index) => {\n    const {\n      scheduledAt\n    } = schedule;\n    const nextSchedule = schedules[index + 1];\n    const nextScheduledAt = (nextSchedule == null ? void 0 : nextSchedule.scheduledAt) ? nextSchedule.scheduledAt : null;\n    const hasNextSchedule = nextScheduledAt != null;\n    const isLast = !hasNextSchedule && isAbove(now, scheduledAt);\n    const isWithin = hasNextSchedule && isWithinInterval(now, {\n      start: scheduledAt,\n      end: nextScheduledAt\n    });\n    return isLast || isWithin;\n  });\n};\nconst toSchedules = (scheduleType, manualSchedules, repeatSchedules) => {\n  const schedules = [];\n  switch (scheduleType) {\n    case ScheduleType.MANUAL:\n      schedules.push(...convertManualSchedulesToSchedules(manualSchedules));\n      break;\n    case ScheduleType.REPEAT:\n      schedules.push(...convertRepeatSchedulesToSchedules(repeatSchedules));\n      break;\n  }\n  return sortSchedulesAscending(schedules);\n};\nconst convertManualSchedulesToSchedules = (manualSchedules) => {\n  return manualSchedules.map(({\n    scheduledAt,\n    sequence\n  }) => ({\n    scheduledAt: composeFramerDateTime(scheduledAt),\n    sequence\n  }));\n};\nconst convertRepeatSchedulesToSchedules = (repeatSchedules) => {\n  const isMultiple = repeatSchedules.length > 1;\n  return repeatSchedules.flatMap((repeatSchedule, repeatScheduleIndex) => {\n    const {\n      startAt,\n      endAt,\n      repeatAt\n    } = repeatSchedule;\n    const diff = differenceInCalendarDays(endAt, startAt);\n    return Array.from({\n      length: diff + 1\n    }, (_, index) => {\n      const date = createKRTimeZoneDate(startAt);\n      const {\n        hours,\n        minutes,\n        seconds\n      } = repeatAt;\n      date.setDate(date.getDate() + index);\n      date.setHours(hours, minutes, seconds);\n      return {\n        scheduledAt: date,\n        sequence: (isMultiple ? repeatScheduleIndex : index) + 1\n      };\n    });\n  });\n};\nconst sortSchedulesAscending = (schedules) => {\n  return [...schedules].sort((x, y) => x.scheduledAt.getTime() - y.scheduledAt.getTime());\n};\nexport {\n  findCurrentSchedule,\n  toSchedules\n};\n","import { useMemo, useState } from \"react\";\nimport { toSchedules, findCurrentSchedule } from \"./Schedulable.utils.js\";\nimport useInterval from \"../../../node_modules/react-use/esm/useInterval.js\";\nconst MS_IN_SECOND = 1e3;\nconst useCurrentSchedule = (scheduleType, manualSchedules, repeatSchedules) => {\n  const schedules = useMemo(() => toSchedules(scheduleType, manualSchedules, repeatSchedules), [scheduleType, manualSchedules, repeatSchedules]);\n  const [schedule, setSchedule] = useState(findCurrentSchedule(schedules));\n  useInterval(() => {\n    const current = findCurrentSchedule(schedules);\n    const isEquals = (schedule == null ? void 0 : schedule.scheduledAt) === (current == null ? void 0 : current.scheduledAt);\n    if (isEquals) {\n      return;\n    }\n    setSchedule(current);\n  }, MS_IN_SECOND);\n  return schedule;\n};\nexport {\n  useCurrentSchedule\n};\n","import { jsx } from \"react/jsx-runtime\";\nimport { withCSS, addPropertyControls, ControlType } from \"framer\";\nimport { ScheduleType } from \"./Schedulable.types.js\";\nimport { useCurrentSchedule } from \"./Schedulable.hooks.js\";\nimport { Placeholder } from \"../../@shared/Placeholder/Placeholder.js\";\nimport { useIsMounted } from \"../../../hooks/useIsMounted.js\";\nconst COMPONENT_NAME = \"schedulable\";\nconst css = [`\n    .${COMPONENT_NAME}-container {\n      width: 100%;\n      height: auto;\n    }\n  `, `\n    .${COMPONENT_NAME}-container > div {\n      width: 100% !important;\n    }\n  `];\nconst Schedulable = withCSS(({\n  scheduleType,\n  schedules,\n  repeatSchedules,\n  components\n}) => {\n  const schedule = useCurrentSchedule(scheduleType, schedules, repeatSchedules);\n  const isMounted = useIsMounted();\n  const hasSequence = (schedule == null ? void 0 : schedule.sequence) !== void 0;\n  if (components.length === 0) {\n    return /* @__PURE__ */ jsx(Placeholder, {});\n  }\n  if (!isMounted) {\n    return null;\n  }\n  return /* @__PURE__ */ jsx(\"div\", { className: `${COMPONENT_NAME}-container`, children: hasSequence ? components[schedule.sequence - 1] : null }, `schedulable-${(schedule == null ? void 0 : schedule.sequence) ?? 0}`);\n}, css);\naddPropertyControls(Schedulable, {\n  scheduleType: {\n    type: ControlType.Enum,\n    title: \"노출 예약 유형\",\n    options: [ScheduleType.MANUAL, ScheduleType.REPEAT],\n    optionTitles: [\"수동\", \"반복\"],\n    displaySegmentedControl: true\n  },\n  schedules: {\n    hidden: ({\n      scheduleType\n    }) => scheduleType !== ScheduleType.MANUAL,\n    title: \"수동 노출 일정 목록\",\n    type: ControlType.Array,\n    control: {\n      title: \"날짜 및 요소 번호\",\n      type: ControlType.Object,\n      controls: {\n        scheduledAt: {\n          title: \"요소 노출 시작일시\",\n          type: ControlType.Object,\n          controls: {\n            date: {\n              type: ControlType.Date,\n              title: \"날짜\",\n              defaultValue: (/* @__PURE__ */ new Date()).toString()\n            },\n            hours: {\n              type: ControlType.Number,\n              title: \"시\",\n              description: \"0 ~ 23시 기준\",\n              defaultValue: 0,\n              min: 0,\n              max: 23,\n              unit: \"시\",\n              step: 1,\n              displayStepper: true\n            },\n            minutes: {\n              type: ControlType.Number,\n              title: \"분\",\n              defaultValue: 0,\n              min: 0,\n              max: 59,\n              unit: \"분\",\n              step: 1,\n              displayStepper: true\n            },\n            seconds: {\n              type: ControlType.Number,\n              title: \"초\",\n              defaultValue: 0,\n              min: 0,\n              max: 59,\n              unit: \"초\",\n              step: 1,\n              displayStepper: true\n            }\n          }\n        },\n        sequence: {\n          title: \"요소 번호\",\n          type: ControlType.Number,\n          defaultValue: 1,\n          unit: \"번째\",\n          min: 1,\n          displayStepper: true\n        }\n      }\n    }\n  },\n  repeatSchedules: {\n    hidden: ({\n      scheduleType\n    }) => scheduleType !== ScheduleType.REPEAT,\n    type: ControlType.Array,\n    title: \"반복 노출 일정 목록\",\n    description: \"하나의 일정만 입력한 경우 - 하나의 일정에 따라 요소들이 반복됩니다.\\nex. 일정 A 에 따라 요소 X, Y 반복\\n\\n여러 일정을 입력한 경우 - 여러 개의 일정에 따라 요소들이 각각 반복됩니다.\\nex. 일정 A 에 요소 X, 일정 B 에 요소 Y 반복\",\n    control: {\n      type: ControlType.Object,\n      title: \"반복 일정\",\n      controls: {\n        startAt: {\n          type: ControlType.Date,\n          title: \"시작일\",\n          description: \"반복 일정이 시작되는 날짜를 입력합니다.\",\n          defaultValue: (/* @__PURE__ */ new Date()).toString()\n        },\n        endAt: {\n          type: ControlType.Date,\n          title: \"종료일\",\n          description: \"반복 일정이 종료되는 날짜를 입력합니다.\",\n          defaultValue: (/* @__PURE__ */ new Date()).toString()\n        },\n        repeatAt: {\n          type: ControlType.Object,\n          title: \"반복 시작 시간\",\n          description: \"일정이 매일 반복되는 시간을 입력합니다.\\nex) 10시 0분 0초 입력 -> 매일 오전 10시에 컴포넌트 변경\",\n          controls: {\n            hours: {\n              type: ControlType.Number,\n              title: \"시\",\n              defaultValue: 0,\n              min: 0,\n              max: 23,\n              unit: \"시\",\n              step: 1,\n              displayStepper: true\n            },\n            minutes: {\n              type: ControlType.Number,\n              title: \"분\",\n              defaultValue: 0,\n              min: 0,\n              max: 59,\n              unit: \"분\",\n              step: 1,\n              displayStepper: true\n            },\n            seconds: {\n              type: ControlType.Number,\n              title: \"초\",\n              defaultValue: 0,\n              min: 0,\n              max: 59,\n              unit: \"초\",\n              step: 1,\n              displayStepper: true\n            }\n          }\n        }\n      }\n    }\n  },\n  components: {\n    title: \"요소 목록\",\n    description: \"최상단부터 1번째로 시작\",\n    type: ControlType.Array,\n    control: {\n      title: \"요소\",\n      type: ControlType.ComponentInstance\n    }\n  }\n});\nexport {\n  Schedulable\n};\n","import{Schedulable}from\"https://asset.29cm.co.kr/contents/framer/components/primitives/Schedulable/Schedulable.js\";Schedulable.displayName=\"Schedulable\";/**\n * @framerDisableUnlink\n */export default Schedulable;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Schedulable\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Schedulable.map"],"mappings":"sWAAI,GAAiC,IACnC,EAAc,EAAc,OAAY,GAAK,SAC7C,EAAc,EAAc,OAAY,GAAK,SACtC,IACN,GAAgB,EAAE,CAAC,2BCJiD,IACjB,IACkB,IACc,IACgB,CAChG,EAAuB,GAAc,CACzC,IAAM,EAAM,GAAsB,CAClC,OAAO,EAAU,MAAM,EAAU,IAAU,CACzC,GAAM,CACJ,eACE,EACE,EAAe,EAAU,EAAQ,GACjC,EAAmB,GAA6C,YAAe,EAAa,YAAc,KAC1G,EAAkB,GAAmB,KACrC,EAAS,CAAC,GAAmB,EAAQ,EAAK,EAAY,CACtD,EAAW,GAAmB,EAAiB,EAAK,CACxD,MAAO,EACP,IAAK,EACN,CAAC,CACF,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AAY,OAClB,aAAc,EACd,KAAM,KACN,IAAK,EACL,eAAgB,GACjB,CACF,CACF,CACF,CACD,gBAAiB,CACf,QAAS,CACP,kBACI,IAAiB,EAAa,OACpC,KAAM,EAAY,MAClB,MAAO,cACP,YAAa;;;;iCACb,QAAS,CACP,KAAM,EAAY,OAClB,MAAO,QACP,SAAU,CACR,QAAS,CACP,KAAM,EAAY,KAClB,MAAO,MACP,YAAa,yBACb,aAA+B,IAAI,MAAM,CAAE,UAAU,CACtD,CACD,MAAO,CACL,KAAM,EAAY,KAClB,MAAO,MACP,YAAa,yBACb,aAA+B,IAAI,MAAM,CAAE,UAAU,CACtD,CACD,SAAU,CACR,KAAM,EAAY,OAClB,MAAO,WACP,YAAa;wCACb,SAAU,CACR,MAAO,CACL,KAAM,EAAY,OAClB,MAAO,IACP,aAAc,EACd,IAAK,EACL,IAAK,GACL,KAAM,IACN,KAAM,EACN,eAAgB,GACjB,CACD,QAAS,CACP,KAAM,EAAY,OAClB,MAAO,IACP,aAAc,EACd,IAAK,EACL,IAAK,GACL,KAAM,IACN,KAAM,EACN,eAAgB,GACjB,CACD,QAAS,CACP,KAAM,EAAY,OAClB,MAAO,IACP,aAAc,EACd,IAAK,EACL,IAAK,GACL,KAAM,IACN,KAAM,EACN,eAAgB,GACjB,CACF,CACF,CACF,CACF,CACF,CACD,WAAY,CACV,MAAO,QACP,YAAa,gBACb,KAAM,EAAY,MAClB,QAAS,CACP,MAAO,KACP,KAAM,EAAY,kBACnB,CACF,CACF,CAAC,mBCjLiH,GAAY,YAAY,gBAEzH"}