import { createTidbytWorkoutsImage } from "https://esm.town/v/andreterron/createTidbytWorkoutsImage";
import { setTidbytImage } from "https://esm.town/v/andreterron/setTidbytImage";
import { weekWorkoutIcons } from "https://esm.town/v/andreterron/weekWorkoutIcons";
import { workedOutByDay } from "https://esm.town/v/andreterron/workedOutByDay";
import { blob } from "https://esm.town/v/std/blob?v=11";
export let updateTidbytWorkout = async (force: boolean = false) => {
const timezone = "America/Los_Angeles";
const byDay = await workedOutByDay(timezone);
const icons = weekWorkoutIcons(byDay, timezone);
let iconsCache: string[] | undefined;
await blob.setJSON("tidbytWorkoutCache", icons);
if (!force && iconsCache && iconsCache.every((v, i) => v === icons[i])) {
console.log("No changes detected, skipping updating tidbyt app");
return;
}
const img = await createTidbytWorkoutsImage(icons);
await setTidbytImage({
image: (await img.getBufferAsync(img.getMIME())).toString("base64"),
});
};