161 lines
4.9 KiB
TypeScript
161 lines
4.9 KiB
TypeScript
// Metro module 10247 (f10248).
|
||
import { DayOfWeek } from "../../_bundle/Module1892";
|
||
import { intl } from "../../intl/index.native";
|
||
import FamilyCenter_messages from "./FamilyCenter.messages";
|
||
let c6836_3, c6836_4, c6836_5, c6836_6, formatDays, getScheduleRuleDateRange;
|
||
const setsEqual = function setsEqual(set, a1) {
|
||
if (set.size !== a1.size) {
|
||
return false;
|
||
}
|
||
for (const item of set) {
|
||
if (a1.has(item)) {
|
||
continue;
|
||
}
|
||
return false;
|
||
}
|
||
return true;
|
||
};
|
||
formatDays = function formatDays(days) {
|
||
const set = new Set(days);
|
||
let c17802_0 = set;
|
||
if (setsEqual(set, c6836_6)) {
|
||
return intl.string(FamilyCenter_messages.bPjqd1);
|
||
}
|
||
if (setsEqual(set, c6836_4)) {
|
||
return intl.string(FamilyCenter_messages["4dr9L9"]);
|
||
}
|
||
if (setsEqual(set, c6836_5)) {
|
||
return intl.string(FamilyCenter_messages["6lTTJ+"]);
|
||
}
|
||
let c17802_1 = new Intl.DateTimeFormat(intl.currentLocale, {
|
||
weekday: "short"
|
||
});
|
||
return c6836_3.map((item, index) => c17802_0.has(item) ? c17802_1.format(new Date(2025, 0, 5 + index)) : null).filter((item) => item !== null).join(", ");
|
||
};
|
||
getScheduleRuleDateRange = function getScheduleRuleDateRange(rule) {
|
||
const r4 = rule.startTime != null;
|
||
let r23 = "";
|
||
if (r4) {
|
||
const r24 = rule.endTime != null;
|
||
r23 = "";
|
||
if (r24) {
|
||
const startTime = rule.startTime;
|
||
const r39 = new Intl.DateTimeFormat(intl.currentLocale, {
|
||
hour: "numeric",
|
||
minute: "2-digit"
|
||
}).format(new Date(2025, 0, 1, startTime.hours, startTime.minutes));
|
||
const endTime = rule.endTime;
|
||
r23 = `${r39} – ${new Intl.DateTimeFormat(intl.currentLocale, {
|
||
hour: "numeric",
|
||
minute: "2-digit"
|
||
}).format(new Date(2025, 0, 1, endTime.hours, endTime.minutes))}`;
|
||
}
|
||
}
|
||
return r23;
|
||
};
|
||
c6836_3 = [DayOfWeek.SUNDAY, DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY, DayOfWeek.SATURDAY];
|
||
c6836_4 = new Set(c6836_3.slice(1, 6));
|
||
c6836_5 = new Set([c6836_3[0], c6836_3[6]]);
|
||
c6836_6 = new Set(c6836_3);
|
||
export { c6836_3 as DAYS_ORDERED };
|
||
export function getShortDayLabels(a0) {
|
||
let c17803_0 = new Intl.DateTimeFormat(intl.currentLocale, {
|
||
weekday: a0
|
||
});
|
||
return c6836_3.map((item, index) => c17803_0.format(new Date(2025, 0, 5 + index)));
|
||
}
|
||
export function formatTime(a0) {
|
||
return new Intl.DateTimeFormat(intl.currentLocale, {
|
||
hour: "numeric",
|
||
minute: "2-digit"
|
||
}).format(new Date(2025, 0, 1, a0.hours, a0.minutes));
|
||
}
|
||
export { formatDays };
|
||
export function timeToMinutes(a0) {
|
||
return 60 * a0.hours + a0.minutes;
|
||
}
|
||
export function formatDuration(a0) {
|
||
const hours = a0 / 60;
|
||
return Number.isInteger(hours) ? intl.formatToPlainString(FamilyCenter_messages.hFDcmZ, {
|
||
hours
|
||
}) : intl.formatToPlainString(FamilyCenter_messages.wcrXLM, {
|
||
hours: Math.floor(hours)
|
||
});
|
||
}
|
||
export { getScheduleRuleDateRange };
|
||
export function formatRestrictedScheduleInAppSubtitle(a0) {
|
||
if (a0.startTime != null && a0.endTime != null) {
|
||
const days = formatDays(a0.days);
|
||
const startTime = a0.startTime;
|
||
const startTime3 = new Intl.DateTimeFormat(intl.currentLocale, {
|
||
hour: "numeric",
|
||
minute: "2-digit"
|
||
}).format(new Date(2025, 0, 1, startTime.hours, startTime.minutes));
|
||
const endTime = a0.endTime;
|
||
const endTime3 = new Intl.DateTimeFormat(intl.currentLocale, {
|
||
hour: "numeric",
|
||
minute: "2-digit"
|
||
}).format(new Date(2025, 0, 1, endTime.hours, endTime.minutes));
|
||
const startTime2 = a0.startTime;
|
||
const r66 = 60 * startTime2.hours + startTime2.minutes;
|
||
const endTime2 = a0.endTime;
|
||
return intl.formatToPlainString(r66 > 60 * endTime2.hours + endTime2.minutes ? FamilyCenter_messages.OxveI8 : FamilyCenter_messages["ERTn+E"], {
|
||
days,
|
||
startTime: startTime3,
|
||
endTime: endTime3
|
||
});
|
||
}
|
||
return null;
|
||
}
|
||
export function sortRulesByStartTime(a0) {
|
||
return a0.slice().sort((a, b) => {
|
||
let r7 = a.startTime?.hours;
|
||
if (r7 == null) {
|
||
r7 = 0;
|
||
}
|
||
const r1 = 60 * r7;
|
||
let r12 = a.startTime?.minutes;
|
||
if (r12 == null) {
|
||
r12 = 0;
|
||
}
|
||
const r14 = r1 + r12;
|
||
let r16 = b.startTime?.hours;
|
||
if (r16 == null) {
|
||
r16 = 0;
|
||
}
|
||
const r17 = 60 * r16;
|
||
let r5 = b.startTime?.minutes;
|
||
if (r5 == null) {
|
||
r5 = 0;
|
||
}
|
||
return r14 - (r17 + r5);
|
||
});
|
||
}
|
||
export function toTimeProto(a0) {
|
||
return {
|
||
hours: a0.hours,
|
||
minutes: a0.minutes,
|
||
seconds: 0,
|
||
nanos: 0
|
||
};
|
||
}
|
||
export function computeOverlappingInfo(c17804_0, c17804_1, c17804_2) {
|
||
const conflictingEntries = [];
|
||
let c17804_3 = conflictingEntries;
|
||
c6836_3.forEach((item, index) => {
|
||
let c26639_0 = item;
|
||
if (c17804_0.has(item)) {
|
||
const r11 = c17804_1.find((item) => item.days.includes(c26639_0));
|
||
if (r11 != null) {
|
||
c17804_3.push({
|
||
dayLabel: c17804_2[index],
|
||
timeRange: getScheduleRuleDateRange(r11)
|
||
});
|
||
}
|
||
}
|
||
});
|
||
return {
|
||
conflictingEntries
|
||
};
|
||
}
|