UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

770 lines • 55.1 kB
import { jsx, jsxs, Fragment } from "react/jsx-runtime"; import { c } from "react/compiler-runtime"; import { Card, Flex, Inline, Stack, Text, Button, Menu, Box, Heading, Label, Container, Badge, useTheme } from "@sanity/ui"; import { parse } from "date-fns/parse"; import { useState, useContext, useEffect, useRef, useMemo } from "react"; import { useStateLink, useRouter, Link } from "sanity/router"; import { styled } from "styled-components"; import { RELEASES_DOCS_URL, useTimeZone, sortByExecuteDate, getLastExecuteDate, SCHEDULE_STATE_DICTIONARY, SCHEDULE_FILTERS, ScheduleItem, SanityDefaultPreview, useScheduleOperation, useSchedulePublishingUpsell, useScheduledPublishingEnabled, UpsellPanel, ContextMenuButton, SCHEDULE_ACTION_DICTIONARY, useWorkspace, usePollSchedules, useTranslation, SCHEDULED_PUBLISHING_TIME_ZONE_SCOPE, ErrorCallout, LoadingBlock, TOOL_HEADER_HEIGHT, TimeZoneButton, TimeZoneButtonElementQuery, useScheduledDraftsEnabled, RELEASES_SCHEDULED_DRAFTS_INTENT } from "./index2.js"; import { InfoOutlineIcon } from "@sanity/icons/InfoOutline"; import { isSameDay } from "date-fns/isSameDay"; import { SchedulesContext } from "sanity/_singletons"; import { CheckmarkIcon } from "@sanity/icons/Checkmark"; import { CloseIcon } from "@sanity/icons/Close"; import { SelectIcon } from "@sanity/icons/Select"; import { format } from "date-fns/format"; import { Button as Button$1, MenuButton, MenuItem, Tooltip } from "./index.js"; import { WarningOutlineIcon } from "@sanity/icons/WarningOutline"; import { CheckmarkCircleIcon } from "@sanity/icons/CheckmarkCircle"; import { useVirtualizer } from "@tanstack/react-virtual"; import { SortIcon } from "@sanity/icons/Sort"; import { CalendarFilter } from "./CalendarFilter.js"; import { isWeekend } from "date-fns/isWeekend"; import { gray, red } from "@sanity/color"; const InfoCallout = () => { const $ = c(5); let t0; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(Text, { size: 2, children: /* @__PURE__ */ jsx(InfoOutlineIcon, {}) }), $[0] = t0) : t0 = $[0]; let t1; $[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: "Schedule Publishing is not enabled" }), $[1] = t1) : t1 = $[1]; let t2; $[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsxs(Text, { size: 1, children: [ "We recommend using", " ", /* @__PURE__ */ jsx("a", { target: "_blank", href: RELEASES_DOCS_URL, rel: "noreferrer", children: "Releases" }), "." ] }), $[2] = t2) : t2 = $[2]; let t3; $[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsxs(Text, { size: 1, children: [ "Scheduled Publishing is not enabled by default. It can be enabled in the config by setting ", /* @__PURE__ */ jsx("code", { children: "scheduledPublishing.enabled = true" }) ] }), $[3] = t3) : t3 = $[3]; let t4; return $[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = /* @__PURE__ */ jsx(Card, { overflow: "hidden", padding: 4, radius: 2, shadow: 1, tone: "suggest", children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 4, children: [ t0, /* @__PURE__ */ jsxs(Inline, { space: 3, children: [ t1, /* @__PURE__ */ jsxs(Stack, { space: 3, marginTop: 2, children: [ t2, t3, /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx("a", { target: "_blank", href: "https://www.sanity.io/docs/scheduled-publishing", rel: "noreferrer", children: "Read the docs" }) }) ] }) ] }) ] }) }), $[4] = t4) : t4 = $[4], t4; }, EMPTY_SCHEDULE = []; function SchedulesProvider(t0) { const $ = c(22), { children, value } = t0, [sortBy, setSortBy] = useState(value.sortBy || "executeAt"); let t1; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = { type: "scheduledPublishing" }, $[0] = t1) : t1 = $[0]; const { utcToCurrentZoneDate } = useTimeZone(t1); let t2; $[1] !== utcToCurrentZoneDate ? (t2 = (wallDate) => function(schedule) { const executeDate = getLastExecuteDate(schedule); if (!executeDate) return !1; const scheduleDate = new Date(executeDate), zonedScheduleDate = utcToCurrentZoneDate(scheduleDate); return isSameDay(zonedScheduleDate, wallDate); }, $[1] = utcToCurrentZoneDate, $[2] = t2) : t2 = $[2]; const filterByDate = t2, filterByState = _temp$1; let t3; $[3] !== filterByDate || $[4] !== sortBy || $[5] !== value.scheduleState || $[6] !== value.schedules || $[7] !== value.selectedDate ? (t3 = value.schedules.filter((scheduleState_0) => value.selectedDate ? filterByDate(value.selectedDate)(scheduleState_0) : filterByState(value.scheduleState)(scheduleState_0)).sort((a, b) => { if (sortBy === "createdAt") return a[sortBy] < b[sortBy] ? 1 : -1; if (sortBy === "executeAt") { const reverseOrder = !(value.scheduleState === "scheduled" || value.selectedDate); return sortByExecuteDate({ reverseOrder })(a, b); } return 1; }) || [], $[3] = filterByDate, $[4] = sortBy, $[5] = value.scheduleState, $[6] = value.schedules, $[7] = value.selectedDate, $[8] = t3) : t3 = $[8]; const activeSchedules = t3; let t4; $[9] !== filterByDate || $[10] !== value.schedules ? (t4 = (wallDate_0) => value.schedules.filter(filterByDate(wallDate_0)).sort(sortByExecuteDate()), $[9] = filterByDate, $[10] = value.schedules, $[11] = t4) : t4 = $[11]; const schedulesByDate = t4, t5 = value.schedules || EMPTY_SCHEDULE; let t6; $[12] !== activeSchedules || $[13] !== schedulesByDate || $[14] !== sortBy || $[15] !== t5 || $[16] !== value.scheduleState || $[17] !== value.selectedDate ? (t6 = { activeSchedules, schedules: t5, schedulesByDate, scheduleState: value.scheduleState, selectedDate: value.selectedDate, setSortBy, sortBy }, $[12] = activeSchedules, $[13] = schedulesByDate, $[14] = sortBy, $[15] = t5, $[16] = value.scheduleState, $[17] = value.selectedDate, $[18] = t6) : t6 = $[18]; const context = t6; let t7; return $[19] !== children || $[20] !== context ? (t7 = /* @__PURE__ */ jsx(SchedulesContext.Provider, { value: context, children }), $[19] = children, $[20] = context, $[21] = t7) : t7 = $[21], t7; } function _temp$1(scheduleState) { return function(schedule_0) { return schedule_0.state === scheduleState; }; } function useSchedules() { const context = useContext(SchedulesContext); if (context === void 0) throw new Error("useSchedules must be used within a SchedulesProvider"); return context; } function useFilteredSchedules(schedules, filter) { const $ = c(5); let t0; if ($[0] !== filter || $[1] !== schedules) { let t1; $[3] !== filter ? (t1 = (schedule) => schedule.state === filter, $[3] = filter, $[4] = t1) : t1 = $[4], t0 = schedules.filter(t1), $[0] = filter, $[1] = schedules, $[2] = t0; } else t0 = $[2]; return t0; } const ScheduleFilter = (props) => { const $ = c(16), { selected, schedules, state } = props, count = useFilteredSchedules(schedules, state).length, hasItems = count > 0, critical = state === "cancelled"; let t0; $[0] !== state ? (t0 = { state: { state } }, $[0] = state, $[1] = t0) : t0 = $[1]; const { href, onClick } = useStateLink(t0), t1 = critical ? "critical" : "default", t2 = SCHEDULE_STATE_DICTIONARY[state]; let t3; $[2] !== t2.title ? (t3 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t2.title }), $[2] = t2.title, $[3] = t3) : t3 = $[3]; let t4; $[4] !== count || $[5] !== hasItems ? (t4 = hasItems && /* @__PURE__ */ jsx(Text, { size: 0, children: count }), $[4] = count, $[5] = hasItems, $[6] = t4) : t4 = $[6]; let t5; $[7] !== t3 || $[8] !== t4 ? (t5 = /* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [ t3, t4 ] }), $[7] = t3, $[8] = t4, $[9] = t5) : t5 = $[9]; let t6; return $[10] !== href || $[11] !== onClick || $[12] !== selected || $[13] !== t1 || $[14] !== t5 ? (t6 = /* @__PURE__ */ jsx(Button, { as: "a", href, mode: "bleed", onClick, selected, tone: t1, padding: 2, children: t5 }), $[10] = href, $[11] = onClick, $[12] = selected, $[13] = t1, $[14] = t5, $[15] = t6) : t6 = $[15], t6; }, ScheduleFilters = (props) => { const $ = c(26), { onClearDate, selectedDate } = props, { navigate } = useRouter(), { schedules, scheduleState } = useSchedules(); let t0; $[0] !== navigate ? (t0 = (state) => { navigate(state); }, $[0] = navigate, $[1] = t0) : t0 = $[1]; const handleMenuClick = t0, currentSchedules = useFilteredSchedules(schedules, scheduleState); let t1; $[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = ["block", "block", "none"], $[2] = t1) : t1 = $[2]; let t2; $[3] !== onClearDate || $[4] !== selectedDate ? (t2 = selectedDate && /* @__PURE__ */ jsx(Button$1, { iconRight: CloseIcon, onClick: onClearDate, text: format(selectedDate, "d MMMM yyyy"), tone: "primary" }), $[3] = onClearDate, $[4] = selectedDate, $[5] = t2) : t2 = $[5]; let t3; $[6] !== currentSchedules?.length || $[7] !== handleMenuClick || $[8] !== scheduleState ? (t3 = scheduleState && /* @__PURE__ */ jsx(MenuButton, { button: /* @__PURE__ */ jsx(Button$1, { iconRight: SelectIcon, mode: "ghost", text: `${SCHEDULE_STATE_DICTIONARY[scheduleState].title} (${currentSchedules?.length || 0})`, tone: "default" }), id: "state", menu: /* @__PURE__ */ jsx(Menu, { style: { minWidth: "175px" }, children: SCHEDULE_FILTERS.map((filter) => /* @__PURE__ */ jsx(MenuItem, { iconRight: filter === scheduleState ? CheckmarkIcon : void 0, onClick: handleMenuClick.bind(void 0, { state: filter }), text: SCHEDULE_STATE_DICTIONARY[filter].title }, filter)) }), popover: { placement: "bottom" } }), $[6] = currentSchedules?.length, $[7] = handleMenuClick, $[8] = scheduleState, $[9] = t3) : t3 = $[9]; let t4; $[10] !== t2 || $[11] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Box, { display: t1, children: [ t2, t3 ] }), $[10] = t2, $[11] = t3, $[12] = t4) : t4 = $[12]; let t5; $[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = ["none", "none", "block"], $[13] = t5) : t5 = $[13]; let t6; $[14] !== onClearDate || $[15] !== selectedDate ? (t6 = selectedDate && /* @__PURE__ */ jsx(Button$1, { iconRight: CloseIcon, onClick: onClearDate, text: format(selectedDate, "d MMMM yyyy"), tone: "primary" }), $[14] = onClearDate, $[15] = selectedDate, $[16] = t6) : t6 = $[16]; let t7; $[17] !== scheduleState || $[18] !== schedules ? (t7 = scheduleState && /* @__PURE__ */ jsx(Flex, { gap: 2, children: SCHEDULE_FILTERS.map((filter_0) => /* @__PURE__ */ jsx(ScheduleFilter, { schedules, selected: scheduleState === filter_0, state: filter_0 }, filter_0)) }), $[17] = scheduleState, $[18] = schedules, $[19] = t7) : t7 = $[19]; let t8; $[20] !== t6 || $[21] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Box, { display: t5, children: [ t6, t7 ] }), $[20] = t6, $[21] = t7, $[22] = t8) : t8 = $[22]; let t9; return $[23] !== t4 || $[24] !== t8 ? (t9 = /* @__PURE__ */ jsxs(Fragment, { children: [ t4, t8 ] }), $[23] = t4, $[24] = t8, $[25] = t9) : t9 = $[25], t9; }, BigIconComingSoon = (props) => { const $ = c(15); let t0, t1, t10, t11, t12, t2, t3, t4, t5, t6, t7, t8, t9; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "M54 26C54 28.7614 49.0751 31 43 31C36.9249 31 32 28.7614 32 26C32 23.2386 36.9249 7 43 7C49.0751 7 54 23.2386 54 26Z", stroke: "#7B8CA8", strokeWidth: "1.2" }), t1 = /* @__PURE__ */ jsx("path", { d: "M65 71.5V57M65 71.5L60.5789 69.0132M65 71.5L60.5789 73.9868M65 57L57 52.5L54 54.1875M65 57V42.5M65 57L57 47M65 57L58.1586 60.8483M65 57L60.5789 67.5M65 42.5L57 38L54 39.6875M65 42.5L57 47M65 42.5V27.5M57 47L65 27.5M57 47L54 39.6875M57 47L54 45.3125M57 47L54 50.75M57 23L65 27.5M57 23L54 24.6875V39.6875M57 23V60M65 27.5L57 32L54 30.3125", stroke: "#7B8CA8", strokeWidth: "1.2" }), t2 = /* @__PURE__ */ jsx("path", { d: "M54 76C54 78.7614 49.0751 81 43 81C36.9249 81 32 78.7614 32 76M54 76H60.5V63L54 57M54 76V57M32 76H25V63L32 57M32 76V57M32 26V57M54 26V57M54 45C54 47.7614 49.0751 50 43 50V35C49.0751 35 54 32.7614 54 30", stroke: "#7B8CA8", strokeWidth: "1.2" }), t3 = /* @__PURE__ */ jsx("path", { d: "M43 45.5701H44.8976L45.8465 43.1981L46.9679 42.7335L49.3162 43.7399L50.658 42.3981L49.6516 40.0499L50.1161 38.9284L52.4882 37.9795V36.0819L50.1161 35.1331L49.6516 34.0116M47.1334 34.9653C47.5197 35.5597 47.7441 36.269 47.7441 37.0307C47.7441 39.1268 46.0449 40.826 43.9488 40.826C43.6212 40.826 43.3033 40.7845 43 40.7064", stroke: "#7B8CA8", strokeWidth: "1.2", strokeLinejoin: "round" }), t4 = /* @__PURE__ */ jsx("path", { d: "M63.5464 78.6739L64.9606 78.0321L67.4355 78.5135L68.6174 78.2913L69.6174 77.1566H71.6174L72.6174 78.2913L73.7994 78.5135L76.2743 78.0321L77.6885 78.6739M63.5464 78.6739L64.607 79.7972L64.1174 80.3336L63.5464 80.4373M63.5464 78.6739V80.4373M77.6885 78.6739L76.6278 79.7972L77.1174 80.3336L77.6885 80.4373M77.6885 78.6739V80.4373M63.5464 80.4373L61.6174 80.7875V81.6952L64.1174 82.1491L64.607 82.6855L63.5464 83.8088L64.9606 84.4506L67.4355 83.9693L68.6174 84.1915L69.6174 85.3261H71.6174L72.6174 84.1915L73.7994 83.9693L76.2743 84.4506L77.6885 83.8088L76.6278 82.6855L77.1174 82.1491L79.6174 81.6952V80.7875L77.6885 80.4373", stroke: "#7B8CA8", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" }), t5 = /* @__PURE__ */ jsx("path", { d: "M79.6174 81.4647V84.7162L77.6885 85.0664M76.2743 87.4716L77.6885 86.8298V85.0664M76.2743 87.4716L73.7994 86.9902L72.6174 87.2124L71.6174 88.3471M76.2743 87.4716V84.7162M61.6174 81.4647V84.7162L63.5464 85.0664M71.6174 88.3471H69.6174M71.6174 88.3471V85.3261M69.6174 88.3471L68.6174 87.2124L67.4355 86.9902L64.9606 87.4716M69.6174 88.3471V85.3261M64.9606 87.4716L64.2535 87.1507L63.5464 86.8298V85.0664M64.9606 87.4716V84.6825M63.5464 84.039V85.0664M77.6885 84.039V85.0664", stroke: "#7B8CA8", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" }), t6 = /* @__PURE__ */ jsx("path", { d: "M73.6174 81.2412C73.6174 81.9932 72.2743 82.6028 70.6174 82.6028C68.9606 82.6028 67.6174 81.9932 67.6174 81.2412C67.6174 80.4892 68.9606 79.8796 70.6174 79.8796C72.2743 79.8796 73.6174 80.4892 73.6174 81.2412Z", stroke: "#7B8CA8", strokeWidth: "1.2" }), t7 = /* @__PURE__ */ jsx("path", { d: "M90 85.3616C90 86.1136 88.6569 86.7232 87 86.7232C85.3431 86.7232 84 86.1136 84 85.3616M90 85.3616C90 84.6096 88.6569 84 87 84C85.3431 84 84 84.6096 84 85.3616M90 85.3616V87.3616C90 88.1136 88.6569 88.7232 87 88.7232C85.3431 88.7232 84 88.1136 84 87.3616V85.3616", stroke: "#7B8CA8", strokeWidth: "1.2" }), t8 = /* @__PURE__ */ jsx("path", { d: "M82 89.8648C82 90.3425 81.3284 90.7297 80.5 90.7297C79.6716 90.7297 79 90.3425 79 89.8648M82 89.8648C82 89.3872 81.3284 89 80.5 89C79.6716 89 79 89.3872 79 89.8648M82 89.8648V91.1352C82 91.6128 81.3284 92 80.5 92C79.6716 92 79 91.6128 79 91.1352V89.8648", stroke: "#7B8CA8", strokeWidth: "1.2" }), t9 = /* @__PURE__ */ jsx("path", { d: "M52.7555 46.7289L52.5381 45.0136L51.2951 44.6903L50.2695 46.0824L49.4558 46.1956L48.0892 45.1364L46.9817 45.7867L47.2408 47.4962L46.7455 48.1517L45.0302 48.3691L44.7069 49.612M51.1084 47.9593C49.8968 47.6442 48.6622 48.2485 48.1434 49.3385", stroke: "#7B8CA8", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" }), t10 = /* @__PURE__ */ jsx("path", { d: "M39 80.5L38 83.5C38 84.8807 40.2386 86 43 86C45.7614 86 48 84.8807 48 83.5L47 80.5", stroke: "#7B8CA8", strokeWidth: "1.2" }), t11 = /* @__PURE__ */ jsx("path", { d: "M32 77L31 80C31 81.3807 33.2386 82.5 36 82.5C36.9107 82.5 37.7646 82.3783 38.5 82.1655", stroke: "#7B8CA8", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" }), t12 = /* @__PURE__ */ jsx("path", { d: "M54 77L55 80C55 81.3807 52.7614 82.5 50 82.5C49.0893 82.5 48.2354 82.3783 47.5 82.1655", stroke: "#7B8CA8", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" }), $[0] = t0, $[1] = t1, $[2] = t10, $[3] = t11, $[4] = t12, $[5] = t2, $[6] = t3, $[7] = t4, $[8] = t5, $[9] = t6, $[10] = t7, $[11] = t8, $[12] = t9) : (t0 = $[0], t1 = $[1], t10 = $[2], t11 = $[3], t12 = $[4], t2 = $[5], t3 = $[6], t4 = $[7], t5 = $[8], t6 = $[9], t7 = $[10], t8 = $[11], t9 = $[12]); let t13; return $[13] !== props ? (t13 = /* @__PURE__ */ jsxs("svg", { width: "100", height: "100", viewBox: "0 0 100 100", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [ t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12 ] }), $[13] = props, $[14] = t13) : t13 = $[14], t13; }, BigIconScreen = (props) => { const $ = c(9); let t0, t1, t2, t3, t4, t5, t6; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "M35 84.5L41.7308 67H50V69.5M65 84.5L58.2692 67M32 65H42.5H50H57.5H81V23H19V65H24", stroke: "#7B8CA8", strokeWidth: "1.2" }), t1 = /* @__PURE__ */ jsx("path", { d: "M84 16V23H16V16M84 16H16M84 16L82 14H18L16 16", stroke: "#7B8CA8", strokeWidth: "1.2" }), t2 = /* @__PURE__ */ jsx("path", { d: "M24 65H18L17 67H83L82 65H32", stroke: "#7B8CA8", strokeWidth: "1.2" }), t3 = /* @__PURE__ */ jsx("circle", { cx: "50", cy: "72", r: "2", stroke: "#7B8CA8", strokeWidth: "1.2" }), t4 = /* @__PURE__ */ jsx("path", { d: "M24 63C24 61.8954 24.8954 61 26 61H30C31.1046 61 32 61.8954 32 63V67H24V63Z", stroke: "#7B8CA8", strokeWidth: "1.2" }), t5 = /* @__PURE__ */ jsx("path", { d: "M24 65C24 63.8954 24.8954 63 26 63H30C31.1046 63 32 63.8954 32 65V67H24V65Z", stroke: "#7B8CA8", strokeWidth: "1.2" }), t6 = /* @__PURE__ */ jsx("path", { d: "M28 44.9975C31.0617 44.62 33.5601 42.4793 35.2478 39.995C36.199 38.5947 36.9116 37.0761 36.9653 35.3597C36.9973 34.3355 36.8332 33.1459 35.8944 32.5454C35.3035 32.1675 34.4935 32.0285 33.8044 32.0022C32.7788 31.9631 32.1643 32.4357 31.8489 33.4197C30.3123 38.2145 33.0184 42.7025 36.3911 45.8977C38.1152 47.531 40.0746 48.9275 42.1179 50.1294C43.9867 51.2287 46.003 52.2595 48.1189 52.7885C48.9466 52.9954 50.4951 53.3913 51.3211 52.954C52.3579 52.4051 51.8285 49.7323 51.7091 48.9809C51.3862 46.9486 50.7293 45.0311 49.8726 43.1662C49.3791 42.0918 48.7948 40.8004 47.9999 39.8967C47.4959 39.3237 47.1331 39.4889 47.1101 40.2278C47.0699 41.5204 47.5768 42.7535 48.3103 43.7973C50.633 47.1024 54.4924 49.4656 58.2792 50.6985C59.9643 51.2471 61.8953 51.7306 63.6853 51.6193C65.3845 51.5137 65.6225 50.1321 65.7287 48.655C65.9958 44.9405 64.9629 40.7695 62.6403 37.7963C61.615 36.4839 60.3547 35.6334 58.6879 35.4476C57.7554 35.3437 56.665 35.3303 55.7391 35.5097C54.8073 35.6903 54.0162 36.297 54.3371 37.3462C54.6464 38.3572 55.8044 39.0666 56.6444 39.5759C57.983 40.3876 59.4813 40.9898 61.0262 41.2624C63.2658 41.6576 65.1745 41.1715 67.141 40.1346C67.9966 39.6835 68.8825 39.1795 69.4379 38.3861", stroke: "#7B8CA8", strokeWidth: "1.2" }), $[0] = t0, $[1] = t1, $[2] = t2, $[3] = t3, $[4] = t4, $[5] = t5, $[6] = t6) : (t0 = $[0], t1 = $[1], t2 = $[2], t3 = $[3], t4 = $[4], t5 = $[5], t6 = $[6]); let t7; return $[7] !== props ? (t7 = /* @__PURE__ */ jsxs("svg", { width: "100", height: "100", viewBox: "0 0 100 100", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [ t0, t1, t2, t3, t4, t5, t6 ] }), $[7] = props, $[8] = t7) : t7 = $[8], t7; }, BigIconSuccess = (props) => { const $ = c(16); let t0, t1, t10, t11, t12, t13, t2, t3, t4, t5, t6, t7, t8, t9; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("path", { d: "M35.5034 34.5961C35.6531 34.1763 35.8628 33.792 36.1352 33.4478C37.6813 31.4827 40.9503 31.2145 44.9898 32.3554M35.5034 34.5961L24.12 78.5806C23.4656 81.1092 26.1309 83.2083 28.4357 81.9796L68.4485 60.6484M35.5034 34.5961C34.2315 38.1622 37.2902 44.2842 43.0792 50.0342M68.4485 60.6484C68.8174 60.4078 69.1391 60.118 69.4084 59.7777C70.9736 57.7883 70.4521 54.4677 68.3472 50.7308M68.4485 60.6484C65.1795 62.7806 58.1999 61.0522 51.0413 56.4338M49.3164 55.2667C48.6043 54.7622 47.8933 54.2299 47.1867 53.6707C46.3331 52.9953 45.5161 52.3044 44.7387 51.6037M49.3164 55.2667C49.8913 55.674 50.4669 56.0632 51.0413 56.4338M49.3164 55.2667C52.3445 53.1871 58.7283 49.8329 66.4965 47.8874M51.0413 56.4338C55.9305 53.432 62.4593 51.6876 68.3472 50.7308M43.0792 50.0342C43.6098 50.5612 44.1634 51.0852 44.7387 51.6037M43.0792 50.0342C44.4006 45.7138 45.8116 38.387 44.9898 32.3554M44.7387 51.6037C47.6743 44.2968 48.7135 38.3712 48.6643 33.6916M63.9622 36.487C63.2905 34.23 62.35 29.5386 63.9622 28.8293C65.9774 27.9426 68.5569 33.5045 70.8139 32.2148C73.0709 30.9251 69.4435 27.7814 70.8139 25.2019C72.1842 22.6224 79.6002 28.4262 81.2123 23.4285C82.502 19.4304 79.7614 16.6574 78.2298 15.7708M66.4965 47.8874C70.7697 46.8171 75.462 46.1731 80.2449 46.4019L80.2449 49.7068C77.5329 49.6936 73.1535 49.9498 68.3472 50.7308M66.4965 47.8874C64.45 45.1054 61.6564 42.2264 58.3003 39.5859C55.0633 37.039 51.7429 35.0416 48.6643 33.6916M48.6643 33.6916C48.5822 25.8794 45.4671 21.5396 43.0792 20.043L39.941 23.4285C42.9851 25.0774 44.4569 28.4441 44.9898 32.3554", stroke: "#7B8CA8", strokeWidth: "1.2" }), t1 = /* @__PURE__ */ jsx("path", { d: "M32.2094 47.3001C31.0515 50.5465 34.6857 56.6214 40.9597 61.5862C47.2404 66.5562 53.9958 68.696 56.8839 66.8122", stroke: "#7B8CA8", strokeWidth: "1.2" }), t2 = /* @__PURE__ */ jsx("path", { d: "M28.8867 60.1903C28.1245 62.3275 30.5169 66.3267 34.6472 69.595C38.7818 72.8669 43.229 74.2755 45.1303 73.0354", stroke: "#7B8CA8", strokeWidth: "1.2" }), t3 = /* @__PURE__ */ jsx("path", { d: "M26.2718 70.2225C25.8147 71.5039 27.2491 73.9016 29.7254 75.8611C32.2044 77.8228 34.8707 78.6673 36.0106 77.9238", stroke: "#7B8CA8", strokeWidth: "1.2" }), t4 = /* @__PURE__ */ jsx("path", { d: "M28.0529 44.1724C29.5354 43.1981 32.3735 40.6904 31.8652 38.4538C31.2298 35.6581 22.8425 38.9622 22.7155 36.5477C22.5884 34.1331 27.0361 30.575 26.909 28.6688C26.7819 26.7626 18.6489 30.8291 18.6489 26.8896C18.6489 23.738 21.36 22.1029 22.7155 21.6793", stroke: "#7B8CA8", strokeWidth: "1.2" }), t5 = /* @__PURE__ */ jsx("rect", { x: "21.8833", y: "50.1122", width: "3.03077", height: "3.03077", transform: "rotate(-24.7154 21.8833 50.1122)", stroke: "#7B8CA8", strokeWidth: "1.2" }), t6 = /* @__PURE__ */ jsx("rect", { x: "16.0527", y: "36.722", width: "3.03077", height: "3.03077", transform: "rotate(4.36851 16.0527 36.722)", stroke: "#7B8CA8", strokeWidth: "1.2" }), t7 = /* @__PURE__ */ jsx("rect", { x: "27.9448", y: "22.8353", width: "3.03077", height: "3.03077", transform: "rotate(-24.7154 27.9448 22.8353)", stroke: "#7B8CA8", strokeWidth: "1.2" }), t8 = /* @__PURE__ */ jsx("rect", { x: "53.7065", y: "33.443", width: "3.03077", height: "3.03077", transform: "rotate(-24.7154 53.7065 33.443)", stroke: "#7B8CA8", strokeWidth: "1.2" }), t9 = /* @__PURE__ */ jsx("rect", { x: "67.3447", y: "13.743", width: "3.03077", height: "3.03077", transform: "rotate(-24.7154 67.3447 13.743)", stroke: "#7B8CA8", strokeWidth: "1.2" }), t10 = /* @__PURE__ */ jsx("rect", { x: "74.9219", y: "54.6584", width: "3.03077", height: "3.03077", transform: "rotate(-24.7154 74.9219 54.6584)", stroke: "#7B8CA8", strokeWidth: "1.2" }), t11 = /* @__PURE__ */ jsx("rect", { x: "70.3755", y: "66.7814", width: "3.03077", height: "3.03077", transform: "rotate(-24.7154 70.3755 66.7814)", stroke: "#7B8CA8", strokeWidth: "1.2" }), t12 = /* @__PURE__ */ jsx("rect", { x: "77.9526", y: "78.9045", width: "3.03077", height: "3.03077", transform: "rotate(-24.7154 77.9526 78.9045)", stroke: "#7B8CA8", strokeWidth: "1.2" }), t13 = /* @__PURE__ */ jsx("rect", { x: "82.4985", y: "62.2353", width: "3.03077", height: "3.03077", transform: "rotate(-24.7154 82.4985 62.2353)", stroke: "#7B8CA8", strokeWidth: "1.2" }), $[0] = t0, $[1] = t1, $[2] = t10, $[3] = t11, $[4] = t12, $[5] = t13, $[6] = t2, $[7] = t3, $[8] = t4, $[9] = t5, $[10] = t6, $[11] = t7, $[12] = t8, $[13] = t9) : (t0 = $[0], t1 = $[1], t10 = $[2], t11 = $[3], t12 = $[4], t13 = $[5], t2 = $[6], t3 = $[7], t4 = $[8], t5 = $[9], t6 = $[10], t7 = $[11], t8 = $[12], t9 = $[13]); let t14; return $[14] !== props ? (t14 = /* @__PURE__ */ jsxs("svg", { width: "100", height: "100", viewBox: "0 0 100 100", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [ t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13 ] }), $[14] = props, $[15] = t14) : t14 = $[15], t14; }, EmptySchedules = (props) => { const $ = c(16), { scheduleState, selectedDate } = props; let BigIcon, description, heading; bb0: switch (scheduleState) { case "succeeded": { description = "When a scheduled document is successfully published it moves to this list view.", heading = "No completed scheduled publications ... yet", BigIcon = BigIconComingSoon; break bb0; } case "cancelled": { description = "Schedules can fail for several reasons, for example when their documents are deleted. When they do, they show up here.", heading = "No failed scheduled publications", BigIcon = BigIconSuccess; break bb0; } case "scheduled": { description = "When editing a document, create a new scheduled publication from the menu next to the Publish button.", heading = "No upcoming scheduled publications", BigIcon = BigIconScreen; break bb0; } } if (selectedDate) { description = "No schedules for this date."; let t02; $[0] !== selectedDate ? (t02 = format(selectedDate, "d MMMM yyyy"), $[0] = selectedDate, $[1] = t02) : t02 = $[1], heading = t02, BigIcon = BigIconScreen; } let t0; $[2] !== BigIcon ? (t0 = BigIcon && /* @__PURE__ */ jsx(BigIcon, {}), $[2] = BigIcon, $[3] = t0) : t0 = $[3]; let t1; $[4] !== t0 ? (t1 = /* @__PURE__ */ jsx(Flex, { justify: "center", children: t0 }), $[4] = t0, $[5] = t1) : t1 = $[5]; let t2; $[6] !== heading ? (t2 = heading && /* @__PURE__ */ jsx(Heading, { align: "center", size: 1, children: heading }), $[6] = heading, $[7] = t2) : t2 = $[7]; let t3; $[8] !== description ? (t3 = description && /* @__PURE__ */ jsx(Text, { align: "center", size: 1, children: description }), $[8] = description, $[9] = t3) : t3 = $[9]; let t4; $[10] !== t2 || $[11] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Stack, { space: 4, children: [ t2, t3 ] }), $[10] = t2, $[11] = t3, $[12] = t4) : t4 = $[12]; let t5; return $[13] !== t1 || $[14] !== t4 ? (t5 = /* @__PURE__ */ jsx(Card, { paddingX: 6, paddingBottom: 8, paddingTop: 7, radius: 2, shadow: 1, children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [ t1, t4 ] }) }), $[13] = t1, $[14] = t4, $[15] = t5) : t5 = $[15], t5; }, SCHEDULE_RENDER_DELAY_MS = 200; function VirtualListItem(props) { const $ = c(10), { item: t0, measureElement } = props, { content, virtualRow } = t0, t1 = `translateY(${virtualRow.start}px)`; let t2; $[0] !== t1 ? (t2 = { position: "absolute", top: 0, left: 0, width: "100%", transform: t1 }, $[0] = t1, $[1] = t2) : t2 = $[1]; const style = t2; let t3; $[2] !== content ? (t3 = typeof content == "string" ? /* @__PURE__ */ jsx(MonthHeading, { content }) : /* @__PURE__ */ jsx(DelayedScheduleItem, { schedule: content }), $[2] = content, $[3] = t3) : t3 = $[3]; let t4; return $[4] !== measureElement || $[5] !== style || $[6] !== t3 || $[7] !== virtualRow.index || $[8] !== virtualRow.key ? (t4 = /* @__PURE__ */ jsx(Box, { "data-index": virtualRow.index, paddingBottom: 2, ref: measureElement, style, children: t3 }, virtualRow.key), $[4] = measureElement, $[5] = style, $[6] = t3, $[7] = virtualRow.index, $[8] = virtualRow.key, $[9] = t4) : t4 = $[9], t4; } function DelayedScheduleItem(t0) { const $ = c(4), { schedule } = t0; let t1; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx(PlaceholderScheduleItem, {}), $[0] = t1) : t1 = $[0]; const [delayedScheduleItem, setDelayedScheduleItem] = useState(t1); let t2, t3; return $[1] !== schedule ? (t2 = () => { let canUpdate = !0; const timeout = setTimeout(() => { canUpdate && setDelayedScheduleItem(/* @__PURE__ */ jsx(ScheduleItem, { schedule, type: "tool" })); }, SCHEDULE_RENDER_DELAY_MS); return () => { canUpdate = !1, clearTimeout(timeout); }; }, t3 = [schedule], $[1] = schedule, $[2] = t2, $[3] = t3) : (t2 = $[2], t3 = $[3]), useEffect(t2, t3), delayedScheduleItem; } function MonthHeading(t0) { const $ = c(2), { content } = t0; let t1; return $[0] !== content ? (t1 = /* @__PURE__ */ jsx(Flex, { align: "flex-end", paddingBottom: 2, paddingTop: 4, children: /* @__PURE__ */ jsx(Label, { muted: !0, size: 1, children: content }) }), $[0] = content, $[1] = t1) : t1 = $[1], t1; } function PlaceholderScheduleItem() { const $ = c(1); let t0; return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(Card, { padding: 1, radius: 2, shadow: 1, children: /* @__PURE__ */ jsx(Card, { padding: 1, children: /* @__PURE__ */ jsx(SanityDefaultPreview, { isPlaceholder: !0 }) }) }), $[0] = t0) : t0 = $[0], t0; } function getLocalizedDate(date) { return new Date(date).toLocaleString("default", { month: "long", year: "numeric" }); } const VirtualList = () => { const $ = c(26), { activeSchedules, scheduleState, sortBy } = useSchedules(), { measureElement, virtualList, totalSize, containerRef } = useVirtualizedSchedules(activeSchedules, sortBy), { deleteSchedules } = useScheduleOperation(); let t0; $[0] !== activeSchedules || $[1] !== deleteSchedules ? (t0 = () => { deleteSchedules({ schedules: activeSchedules || [] }); }, $[0] = activeSchedules, $[1] = deleteSchedules, $[2] = t0) : t0 = $[2]; const handleClearSchedules = t0; let t1; $[3] !== containerRef ? (t1 = () => { containerRef?.current?.scrollTo(0, 0); }, $[3] = containerRef, $[4] = t1) : t1 = $[4]; let t2; $[5] !== containerRef || $[6] !== scheduleState || $[7] !== sortBy ? (t2 = [scheduleState, sortBy, containerRef], $[5] = containerRef, $[6] = scheduleState, $[7] = sortBy, $[8] = t2) : t2 = $[8], useEffect(t1, t2); const t3 = `${totalSize}px`; let t4; $[9] !== t3 ? (t4 = { height: t3, width: "100%", position: "relative" }, $[9] = t3, $[10] = t4) : t4 = $[10]; let t5; if ($[11] !== measureElement || $[12] !== virtualList) { let t62; $[14] !== measureElement ? (t62 = (item) => /* @__PURE__ */ jsx(VirtualListItem, { item, measureElement }, item.key), $[14] = measureElement, $[15] = t62) : t62 = $[15], t5 = virtualList.map(t62), $[11] = measureElement, $[12] = virtualList, $[13] = t5; } else t5 = $[13]; let t6; $[16] !== t4 || $[17] !== t5 ? (t6 = /* @__PURE__ */ jsx(Box, { style: t4, children: t5 }), $[16] = t4, $[17] = t5, $[18] = t6) : t6 = $[18]; let t7; $[19] !== handleClearSchedules || $[20] !== scheduleState ? (t7 = scheduleState === "succeeded" && /* @__PURE__ */ jsx(Flex, { justify: "center", marginTop: 6, children: /* @__PURE__ */ jsx(Button$1, { icon: CheckmarkCircleIcon, mode: "ghost", onClick: handleClearSchedules, text: "Clear all completed schedules" }) }), $[19] = handleClearSchedules, $[20] = scheduleState, $[21] = t7) : t7 = $[21]; let t8; return $[22] !== containerRef || $[23] !== t6 || $[24] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Box, { paddingBottom: 6, paddingTop: 1, paddingX: 4, ref: containerRef, overflow: "hidden", children: [ t6, t7 ] }), $[22] = containerRef, $[23] = t6, $[24] = t7, $[25] = t8) : t8 = $[25], t8; }; function useVirtualizedSchedules(activeSchedules, sortBy) { const containerRef = useRef(null), listSourceItems = useMemo(() => { const items = []; return activeSchedules.forEach((schedule, index) => { if (sortBy == "executeAt") { const previousSchedule = activeSchedules[index - 1], previousExecuteDate = getLastExecuteDate(previousSchedule), datePrevious = index > 0 && previousExecuteDate ? getLocalizedDate(previousExecuteDate) : null, currentExecuteDate = getLastExecuteDate(schedule), dateCurrent = currentExecuteDate ? getLocalizedDate(currentExecuteDate) : null; dateCurrent !== datePrevious && items.push(dateCurrent || "No date specified"); } items.push(schedule); }), items; }, [activeSchedules, sortBy]), virtualizer = useVirtualizer({ count: listSourceItems.length, getScrollElement: () => containerRef.current, estimateSize: () => 50, overscan: 5 }), virtualList = virtualizer.getVirtualItems().map((virtualRow) => { const item = listSourceItems[virtualRow.index]; return { content: item, key: typeof item == "string" ? item : item.id, virtualRow }; }); return { containerRef, measureElement: virtualizer.measureElement, totalSize: virtualizer.getTotalSize(), virtualList }; } const Panel = /* @__PURE__ */ styled(Container).withConfig({ displayName: "Panel", componentId: "sc-1ny9eog-0" })(["width:auto;"]), Schedules = () => { const $ = c(13), { activeSchedules, selectedDate, scheduleState } = useSchedules(), { upsellData, telemetryLogs } = useSchedulePublishingUpsell(), { mode } = useScheduledPublishingEnabled(), showWarning = mode === "upsell" && scheduleState === "scheduled"; let t0; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = { height: "100%" }, $[0] = t0) : t0 = $[0]; let t1; $[1] !== mode || $[2] !== telemetryLogs || $[3] !== upsellData ? (t1 = mode === "upsell" && upsellData && /* @__PURE__ */ jsx(Panel, { width: 1, padding: 4, paddingBottom: 1, children: /* @__PURE__ */ jsx(UpsellPanel, { layout: "horizontal", data: upsellData, onPrimaryClick: telemetryLogs.panelPrimaryClicked, onSecondaryClick: telemetryLogs.panelSecondaryClicked }) }), $[1] = mode, $[2] = telemetryLogs, $[3] = upsellData, $[4] = t1) : t1 = $[4]; let t2; $[5] !== activeSchedules.length || $[6] !== scheduleState || $[7] !== selectedDate || $[8] !== showWarning ? (t2 = activeSchedules.length === 0 ? /* @__PURE__ */ jsx(Panel, { width: 1, padding: 4, paddingTop: 4, children: /* @__PURE__ */ jsx(EmptySchedules, { scheduleState, selectedDate }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [ showWarning && /* @__PURE__ */ jsx(Card, { margin: 4, marginBottom: 2, padding: 3, tone: "caution", radius: 3, shadow: 1, children: /* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", children: [ /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(WarningOutlineIcon, {}) }), /* @__PURE__ */ jsx(Text, { size: 1, children: "Your scheduled documents won't be published automatically unless you upgrade your plan. You can still publish them manually." }) ] }) }), /* @__PURE__ */ jsx(Box, { paddingTop: showWarning ? 0 : 4, children: /* @__PURE__ */ jsx(VirtualList, {}) }) ] }), $[5] = activeSchedules.length, $[6] = scheduleState, $[7] = selectedDate, $[8] = showWarning, $[9] = t2) : t2 = $[9]; let t3; return $[10] !== t1 || $[11] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Box, { style: t0, children: [ t1, t2 ] }), $[10] = t1, $[11] = t2, $[12] = t3) : t3 = $[12], t3; }, SchedulesContextMenu = () => { const $ = c(15), { setSortBy, sortBy } = useSchedules(); let t0; $[0] !== setSortBy ? (t0 = () => setSortBy("createdAt"), $[0] = setSortBy, $[1] = t0) : t0 = $[1]; const handleSortByCreateAt = t0; let t1; $[2] !== setSortBy ? (t1 = () => setSortBy("executeAt"), $[2] = setSortBy, $[3] = t1) : t1 = $[3]; const handleSortByExecuteAt = t1; let t2; $[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(ContextMenuButton, {}), $[4] = t2) : t2 = $[4]; let t3; $[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = { minWidth: "250px" }, $[5] = t3) : t3 = $[5]; const t4 = sortBy === "createdAt" ? CheckmarkIcon : void 0; let t5; $[6] !== handleSortByCreateAt || $[7] !== t4 ? (t5 = /* @__PURE__ */ jsx(MenuItem, { icon: SortIcon, iconRight: t4, onClick: handleSortByCreateAt, text: "Sort by time added" }), $[6] = handleSortByCreateAt, $[7] = t4, $[8] = t5) : t5 = $[8]; const t6 = sortBy === "executeAt" ? CheckmarkIcon : void 0; let t7; $[9] !== handleSortByExecuteAt || $[10] !== t6 ? (t7 = /* @__PURE__ */ jsx(MenuItem, { icon: SortIcon, iconRight: t6, onClick: handleSortByExecuteAt, text: "Sort by time scheduled" }), $[9] = handleSortByExecuteAt, $[10] = t6, $[11] = t7) : t7 = $[11]; let t8; return $[12] !== t5 || $[13] !== t7 ? (t8 = /* @__PURE__ */ jsx(MenuButton, { button: t2, id: "sort", menu: /* @__PURE__ */ jsxs(Menu, { style: t3, children: [ t5, t7 ] }) }), $[12] = t5, $[13] = t7, $[14] = t8) : t8 = $[14], t8; }, Pip = (props) => { const $ = c(8), { mode: t0, selected } = props, mode = t0 === void 0 ? "default" : t0; let t1; $[0] !== mode || $[1] !== selected ? (t1 = mode === "default" ? { background: gray[selected ? 100 : 300].hex } : {}, $[0] = mode, $[1] = selected, $[2] = t1) : t1 = $[2]; let t2; $[3] !== mode ? (t2 = mode === "failed" ? { background: red[500].hex } : {}, $[3] = mode, $[4] = t2) : t2 = $[4]; let t3; return $[5] !== t1 || $[6] !== t2 ? (t3 = /* @__PURE__ */ jsx(Box, { style: { ...t1, ...t2, borderRadius: "2px", height: "2px", width: "100%" } }), $[5] = t1, $[6] = t2, $[7] = t3) : t3 = $[7], t3; }; function CalendarDay(props) { const $ = c(60), { date, focused, isCurrentMonth, isToday, onSelect, selected } = props, { schedulesByDate } = useSchedules(); let t0; $[0] !== date || $[1] !== schedulesByDate ? (t0 = schedulesByDate(date), $[0] = date, $[1] = schedulesByDate, $[2] = t0) : t0 = $[2]; const schedules = t0; let t1; $[3] !== date || $[4] !== onSelect || $[5] !== selected ? (t1 = () => { onSelect(selected ? void 0 : date); }, $[3] = date, $[4] = onSelect, $[5] = selected, $[6] = t1) : t1 = $[6]; const handleClick = t1; let tone; isToday || selected ? tone = "primary" : (isWeekend(date), tone = "default"); const hasSchedules = schedules.length > 0; let t2; $[7] !== schedules ? (t2 = schedules.filter(_temp), $[7] = schedules, $[8] = t2) : t2 = $[8]; let t3; $[9] !== schedules ? (t3 = schedules.filter(_temp2), $[9] = schedules, $[10] = t3) : t3 = $[10]; let t4; $[11] !== schedules ? (t4 = schedules.filter(_temp3), $[11] = schedules, $[12] = t4) : t4 = $[12]; let t5; $[13] !== t2 || $[14] !== t3 || $[15] !== t4 ? (t5 = { completed: t2, failed: t3, upcoming: t4 }, $[13] = t2, $[14] = t3, $[15] = t4, $[16] = t5) : t5 = $[16]; const { completed, failed, upcoming } = t5; let t6; $[17] !== date || $[18] !== schedules ? (t6 = /* @__PURE__ */ jsx(TooltipContent, { date, schedules }), $[17] = date, $[18] = schedules, $[19] = t6) : t6 = $[19]; const t7 = !hasSchedules; let t8; $[20] !== date ? (t8 = date.toDateString(), $[20] = date, $[21] = t8) : t8 = $[21]; const t9 = focused ? "true" : ""; let t10; $[22] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = { position: "relative" }, $[22] = t10) : t10 = $[22]; const t11 = !selected && !isCurrentMonth ? 0.35 : 1; let t12; $[23] !== t11 ? (t12 = { opacity: t11, textAlign: "center" }, $[23] = t11, $[24] = t12) : t12 = $[24]; let t13; $[25] !== date || $[26] !== selected ? (t13 = selected ? /* @__PURE__ */ jsx(CloseIcon, {}) : date.getDate(), $[25] = date, $[26] = selected, $[27] = t13) : t13 = $[27]; let t14; $[28] !== t12 || $[29] !== t13 ? (t14 = /* @__PURE__ */ jsx(Text, { size: 1, style: t12, children: t13 }), $[28] = t12, $[29] = t13, $[30] = t14) : t14 = $[30]; let t15; $[31] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t15 = { bottom: 2, left: 2, position: "absolute", right: 2 }, $[31] = t15) : t15 = $[31]; let t16; $[32] !== completed.length || $[33] !== selected ? (t16 = completed.length > 0 && /* @__PURE__ */ jsx(Pip, { selected }), $[32] = completed.length, $[33] = selected, $[34] = t16) : t16 = $[34]; let t17; $[35] !== selected || $[36] !== upcoming.length ? (t17 = upcoming.length > 0 && /* @__PURE__ */ jsx(Pip, { selected }), $[35] = selected, $[36] = upcoming.length, $[37] = t17) : t17 = $[37]; let t18; $[38] !== failed.length || $[39] !== selected ? (t18 = failed.length > 0 && /* @__PURE__ */ jsx(Pip, { mode: "failed", selected }), $[38] = failed.length, $[39] = selected, $[40] = t18) : t18 = $[40]; let t19; $[41] !== t16 || $[42] !== t17 || $[43] !== t18 ? (t19 = /* @__PURE__ */ jsx(Box, { style: t15, children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 1, justify: "center", children: [ t16, t17, t18 ] }) }), $[41] = t16, $[42] = t17, $[43] = t18, $[44] = t19) : t19 = $[44]; let t20; $[45] !== handleClick || $[46] !== selected || $[47] !== t14 || $[48] !== t19 || $[49] !== t8 || $[50] !== t9 || $[51] !== tone ? (t20 = /* @__PURE__ */ jsxs(Card, { "aria-label": t8, "aria-pressed": selected, as: "button", __unstable_focusRing: !0, "data-weekday": !0, "data-focused": t9, role: "button", tabIndex: -1, onClick: handleClick, paddingX: 3, paddingY: 4, radius: 2, selected, style: t10, tone, children: [ t14, t19 ] }), $[45] = handleClick, $[46] = selected, $[47] = t14, $[48] = t19, $[49] = t8, $[50] = t9, $[51] = tone, $[52] = t20) : t20 = $[52]; let t21; $[53] !== t20 || $[54] !== t6 || $[55] !== t7 ? (t21 = /* @__PURE__ */ jsx(Tooltip, { content: t6, disabled: t7, portal: !0, children: t20 }), $[53] = t20, $[54] = t6, $[55] = t7, $[56] = t21) : t21 = $[56]; let t22; return $[57] !== selected || $[58] !== t21 ? (t22 = /* @__PURE__ */ jsx("div", { "aria-selected": selected, "data-ui": "CalendarDay", children: t21 }), $[57] = selected, $[58] = t21, $[59] = t22) : t22 = $[59], t22; } function _temp3(s_1) { return s_1.state === "scheduled"; } function _temp2(s_0) { return s_0.state === "cancelled"; } function _temp(s) { return s.state === "succeeded"; } function TooltipContent(props) { const $ = c(12), { date, schedules: t0 } = props, schedules = t0 === void 0 ? [] : t0; let t1; $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = { type: "scheduledPublishing" }, $[0] = t1) : t1 = $[0]; const { formatDateTz } = useTimeZone(t1), schedulesByState = schedules.reduce(_temp4, { cancelled: [], succeeded: [], scheduled: [] }), T0 = Box, t2 = 3; let t3; $[1] !== date ? (t3 = format(date, "d MMMM yyyy"), $[1] = date, $[2] = t3) : t3 = $[2]; let t4; $[3] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, { marginBottom: 4, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t3 }) }), $[3] = t3, $[4] = t4) : t4 = $[4]; const T1 = Stack, t5 = 3, t6 = Object.keys(schedulesByState).map((key) => { const stateSchedules = schedulesByState[key]; return stateSchedules.length === 0 ? null : /* @__PURE__ */ jsxs(Stack, { space: 2, children: [ /* @__PURE__ */ jsx(Label, { muted: !0, size: 0, children: SCHEDULE_STATE_DICTIONARY[key].title }), /* @__PURE__ */ jsx(Stack, { space: 1, children: stateSchedules.filter(_temp5).map((schedule_0) => { const executeDate = getLastExecuteDate(schedule_0); return executeDate ? /* @__PURE__ */ jsxs(Inline, { space: 2, children: [ /* @__PURE__ */ jsx(Box, { style: { width: "60px" }, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "regular", children: formatDateTz({ date: new Date(executeDate), format: "p" }) }) }), /* @__PURE__ */ jsx(Flex, { align: "center", style: { flexShrink: 0, opacity: schedule_0.action === "unpublish" ? 1 : 0 }, children: /* @__PURE__ */ jsx(Badge, { fontSize: 0, mode: "outline", tone: SCHEDULE_ACTION_DICTIONARY[schedule_0.action].badgeTone, children: schedule_0.action }) }) ] }, schedule_0.id) : null; }) }) ] }, key); }); let t7; $[5] !== T1 || $[6] !== t6 ? (t7 = /* @__PURE__ */ jsx(T1, { space: t5, children: t6 }), $[5] = T1, $[6] = t6, $[7] = t7) : t7 = $[7]; let t8; return $[8] !== T0 || $[9] !== t4 || $[10] !== t7 ? (t8 = /* @__PURE__ */ jsxs(T0, { padding: t2, children: [ t4, t7 ] }), $[8] = T0, $[9] = t4, $[10] = t7, $[11] = t8) : t8 = $[11], t8; } function _temp5(schedule) { return schedule.executeAt; } function _temp4(acc, val) { return acc[val.state].push(val), acc; } const ToolCalendar = (props) => { const $ = c(11), { onSelect, selectedDate, timeZoneScope } = props, { getCurrentZoneDate, utcToCurrentZoneDate } = useTimeZone(timeZoneScope); let t0; $[0] !== getCurrentZoneDate || $[1] !== selectedDate ? (t0 = selectedDate || getCurrentZoneDate(), $[0] = getCurrentZoneDate, $[1] = selectedDate, $[2] = t0) : t0 = $[2]; const [focusedDate, setFocusedDate] = useState(t0); let t1; $[3] !== utcToCurrentZoneDate ? (t1 = (date) => { setFocusedDate(utcToCurrentZoneDate(date)); }, $[3] = utcToCurrentZoneDate, $[4] = t1) : t1 = $[4]; const handleFocusDateChange = t1; let t2; return $[5] !== focusedDate || $[6] !== handleFocusDateChange || $[7] !== onSelect || $[8] !== selectedDate || $[9] !== timeZoneScope ? (t2 = /* @__PURE__ */ jsx(CalendarFilter, { focusedDate, onFocusedDateChange: handleFocusDateChange, onSelect, selectedDate, renderCalendarDay: CalendarDay, timeZoneScope }), $[5] = focusedDate, $[6] = handleFocusDateChange, $[7] = onSelect, $[8] = selectedDate, $[9] = timeZoneScope, $[10] = t2) : t2 = $[10], t2; }, Column = /* @__PURE__ */ styled(Box).withConfig({ displayName: "Column", componentId: "sc-1q185kz-0" })(["flex-direction:column;&:not(:last-child){border-right:1px solid var(--card-border-color);}"]), NO_SCHEDULE = [], DATE_SLUG_FORMAT = "yyyy-MM-dd"; function ScheduledDraftsBanner() { const $ = c(4), router = useRouter(), isScheduledDraftsEnabled = useScheduledDraftsEnabled(); let t0; $[0] !== router ? (t0 = router.resolveIntentLink(RELEASES_SCHEDULED_DRAFTS_INTENT, { view: "drafts" }), $[0] = router, $[1] = t0) : t0 = $[1]; const releasesUrl = t0; if (isScheduledDraftsEnabled) { let t1; return $[2] !== releasesUrl ? (t1 = /* @__PURE__ */ jsx(Card, { padding: 4, tone: "caution", children: /* @__PURE__ */ jsx(Flex, { gap: 3, align: "center", justify: "center", children: /* @__PURE__ */ jsxs(Text, { size: 1, weight: "medium", children: [ "Scheduled Drafts is enabled for this Studio. All new Scheduled Drafts will be", " ", /* @__PURE__ */ jsx(Link, { href: releasesUrl, children: "available here" }) ] }) }) }), $[2] = releasesUrl, $[3] = t1) : t1 = $[3], t1; } } function Tool() { const $ = c(60), router = useRouter(), { scheduledPublishing } = useWorkspace(), { sanity: theme } = useTheme(), { error, isInitialLoading, schedules: t0 } = usePollSchedules(), schedules = t0 === void 0 ? NO_SCHEDULE : t0, { t } = useTranslation(), { enabled, hasUsedScheduledPublishing } = useScheduledPublishingEnabled(), lastScheduleState = useRef(void 0), scheduleState = router.state.state; let t1; $[0] !== router.state.date ? (t1 = router.state.date ? parse(router.state.date, DATE_SLUG_FORMAT, /* @__PURE__ */ new Date()) : void 0, $[0] = router.state.date, $[1] = t1) : t1 = $[1]; const selectedDate = t1; let t2, t3; $[2] !== router.state.state ? (t2 = () => { router.state.state && (lastScheduleState.current = router.state.state); }, t3 = [router.state.state], $[2] = router.state.state, $[3] = t2, $[4] = t3) : (t2 = $[3], t3 = $[4]), useEffect(t2, t3), useFallbackNavigation(router, scheduleState, selectedDate); const { formatDateTz, timeZone } = useTimeZone(SCHEDULED_PUBLISHING_TIME_ZONE_SCOPE); let t4; $[5] !== scheduleState || $[6] !== schedules || $[7] !== selectedDate ? (t4 = { schedules, scheduleState, selectedDate }, $[5] = scheduleState, $[6] = schedules, $[7] = selectedDate, $[8] = t4) : t4 = $[8]; const schedulesContext = t4; let t5; $[9] !== router ? (t5 = () => { router.navigate({ state: lastScheduleState?.current || SCHEDULE_FILTERS[0] }); }, $[9] = router, $[10] = t5) : t5 = $[10]; const handleClearDate = t5; let t6; $[11] !== formatDateTz || $[12] !== router ? (t6 = (date) => { date ? router.navigate({ date: formatDateTz({ date, format: DATE_SLUG_FORMAT }) }) : router.navigate({ state: lastScheduleState?.current || SCHEDULE_FILTERS[0] }); }, $[11] = formatDateTz, $[12] = router, $[13] = t6) : t6 = $[13]; const handleSelectDate = t6; if (!enabled) { if (scheduledPublishing.__internal__workspaceEnabled) { let t73; return $[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t73 = /* @__PURE__ */ jsx(Container, { width: 1, paddingTop: 4, children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, paddingX: 4, children: /* @__PURE__ */ jsx(ErrorCallout, { description: "Something went wrong loading permissions, please try again.", title: "Permissions check failed" }) }) }), $[14] = t73) : t73 = $[14], t73; } let t72; return $[15] !== hasUsedScheduledPublishing.loading ? (t72 = /* @__PURE__ */ jsx(Container, { width: 1, paddingTop: 4, children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, paddingX: 4, children: hasUsedScheduledPublishing.loading ? /* @__PURE__ */ jsx(LoadingBlock, {}) : /* @__PURE__ */ jsx(InfoCallout, {}) }) }), $[15] = hasUsedSchedul