Files
obsidian_note/.obsidian/plugins/obsidian-pomodoro-timer/main.js.crdownload

4447 lines
175 KiB
Plaintext
Raw Normal View History

2025-12-04 09:12:56 +08:00
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
// node_modules/obsidian-daily-notes-interface/dist/main.js
var require_main = __commonJS({
"node_modules/obsidian-daily-notes-interface/dist/main.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var obsidian = require("obsidian");
var DEFAULT_DAILY_NOTE_FORMAT = "YYYY-MM-DD";
var DEFAULT_WEEKLY_NOTE_FORMAT = "gggg-[W]ww";
var DEFAULT_MONTHLY_NOTE_FORMAT = "YYYY-MM";
var DEFAULT_QUARTERLY_NOTE_FORMAT = "YYYY-[Q]Q";
var DEFAULT_YEARLY_NOTE_FORMAT = "YYYY";
function shouldUsePeriodicNotesSettings(periodicity) {
var _a, _b;
const periodicNotes = window.app.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a[periodicity]) == null ? void 0 : _b.enabled);
}
function getDailyNoteSettings() {
var _a, _b, _c, _d;
try {
const { internalPlugins, plugins } = window.app;
if (shouldUsePeriodicNotesSettings("daily")) {
const { format: format2, folder: folder2, template: template2 } = ((_b = (_a = plugins.getPlugin("periodic-notes")) == null ? void 0 : _a.settings) == null ? void 0 : _b.daily) || {};
return {
format: format2 || DEFAULT_DAILY_NOTE_FORMAT,
folder: (folder2 == null ? void 0 : folder2.trim()) || "",
template: (template2 == null ? void 0 : template2.trim()) || ""
};
}
const { folder, format, template } = ((_d = (_c = internalPlugins.getPluginById("daily-notes")) == null ? void 0 : _c.instance) == null ? void 0 : _d.options) || {};
return {
format: format || DEFAULT_DAILY_NOTE_FORMAT,
folder: (folder == null ? void 0 : folder.trim()) || "",
template: (template == null ? void 0 : template.trim()) || ""
};
} catch (err) {
console.info("No custom daily note settings found!", err);
}
}
function getWeeklyNoteSettings() {
var _a, _b, _c, _d, _e, _f, _g;
try {
const pluginManager = window.app.plugins;
const calendarSettings = (_a = pluginManager.getPlugin("calendar")) == null ? void 0 : _a.options;
const periodicNotesSettings = (_c = (_b = pluginManager.getPlugin("periodic-notes")) == null ? void 0 : _b.settings) == null ? void 0 : _c.weekly;
if (shouldUsePeriodicNotesSettings("weekly")) {
return {
format: periodicNotesSettings.format || DEFAULT_WEEKLY_NOTE_FORMAT,
folder: ((_d = periodicNotesSettings.folder) == null ? void 0 : _d.trim()) || "",
template: ((_e = periodicNotesSettings.template) == null ? void 0 : _e.trim()) || ""
};
}
const settings2 = calendarSettings || {};
return {
format: settings2.weeklyNoteFormat || DEFAULT_WEEKLY_NOTE_FORMAT,
folder: ((_f = settings2.weeklyNoteFolder) == null ? void 0 : _f.trim()) || "",
template: ((_g = settings2.weeklyNoteTemplate) == null ? void 0 : _g.trim()) || ""
};
} catch (err) {
console.info("No custom weekly note settings found!", err);
}
}
function getMonthlyNoteSettings() {
var _a, _b, _c, _d;
const pluginManager = window.app.plugins;
try {
const settings2 = shouldUsePeriodicNotesSettings("monthly") && ((_b = (_a = pluginManager.getPlugin("periodic-notes")) == null ? void 0 : _a.settings) == null ? void 0 : _b.monthly) || {};
return {
format: settings2.format || DEFAULT_MONTHLY_NOTE_FORMAT,
folder: ((_c = settings2.folder) == null ? void 0 : _c.trim()) || "",
template: ((_d = settings2.template) == null ? void 0 : _d.trim()) || ""
};
} catch (err) {
console.info("No custom monthly note settings found!", err);
}
}
function getQuarterlyNoteSettings() {
var _a, _b, _c, _d;
const pluginManager = window.app.plugins;
try {
const settings2 = shouldUsePeriodicNotesSettings("quarterly") && ((_b = (_a = pluginManager.getPlugin("periodic-notes")) == null ? void 0 : _a.settings) == null ? void 0 : _b.quarterly) || {};
return {
format: settings2.format || DEFAULT_QUARTERLY_NOTE_FORMAT,
folder: ((_c = settings2.folder) == null ? void 0 : _c.trim()) || "",
template: ((_d = settings2.template) == null ? void 0 : _d.trim()) || ""
};
} catch (err) {
console.info("No custom quarterly note settings found!", err);
}
}
function getYearlyNoteSettings() {
var _a, _b, _c, _d;
const pluginManager = window.app.plugins;
try {
const settings2 = shouldUsePeriodicNotesSettings("yearly") && ((_b = (_a = pluginManager.getPlugin("periodic-notes")) == null ? void 0 : _a.settings) == null ? void 0 : _b.yearly) || {};
return {
format: settings2.format || DEFAULT_YEARLY_NOTE_FORMAT,
folder: ((_c = settings2.folder) == null ? void 0 : _c.trim()) || "",
template: ((_d = settings2.template) == null ? void 0 : _d.trim()) || ""
};
} catch (err) {
console.info("No custom yearly note settings found!", err);
}
}
function join2(...partSegments) {
let parts = [];
for (let i = 0, l = partSegments.length; i < l; i++) {
parts = parts.concat(partSegments[i].split("/"));
}
const newParts = [];
for (let i = 0, l = parts.length; i < l; i++) {
const part = parts[i];
if (!part || part === ".")
continue;
else
newParts.push(part);
}
if (parts[0] === "")
newParts.unshift("");
return newParts.join("/");
}
function basename(fullPath) {
let base = fullPath.substring(fullPath.lastIndexOf("/") + 1);
if (base.lastIndexOf(".") != -1)
base = base.substring(0, base.lastIndexOf("."));
return base;
}
async function ensureFolderExists(path) {
const dirs = path.replace(/\\/g, "/").split("/");
dirs.pop();
if (dirs.length) {
const dir = join2(...dirs);
if (!window.app.vault.getAbstractFileByPath(dir)) {
await window.app.vault.createFolder(dir);
}
}
}
async function getNotePath(directory, filename) {
if (!filename.endsWith(".md")) {
filename += ".md";
}
const path = obsidian.normalizePath(join2(directory, filename));
await ensureFolderExists(path);
return path;
}
async function getTemplateInfo(template) {
const { metadataCache, vault } = window.app;
const templatePath = obsidian.normalizePath(template);
if (templatePath === "/") {
return Promise.resolve(["", null]);
}
try {
const templateFile = metadataCache.getFirstLinkpathDest(templatePath, "");
const contents = await vault.cachedRead(templateFile);
const IFoldInfo = window.app.foldManager.load(templateFile);
return [contents, IFoldInfo];
} catch (err) {
console.error(`Failed to read the daily note template '${templatePath}'`, err);
new obsidian.Notice("Failed to read the daily note template");
return ["", null];
}
}
function getDateUID(date, granularity = "day") {
const ts = date.clone().startOf(granularity).format();
return `${granularity}-${ts}`;
}
function removeEscapedCharacters(format) {
return format.replace(/\[[^\]]*\]/g, "");
}
function isFormatAmbiguous(format, granularity) {
if (granularity === "week") {
const cleanFormat = removeEscapedCharacters(format);
return /w{1,2}/i.test(cleanFormat) && (/M{1,4}/.test(cleanFormat) || /D{1,4}/.test(cleanFormat));
}
return false;
}
function getDateFromFile(file, granularity) {
return getDateFromFilename(file.basename, granularity);
}
function getDateFromPath(path, granularity) {
return getDateFromFilename(basename(path), granularity);
}
function getDateFromFilename(filename, granularity) {
const getSettings = {
day: getDailyNoteSettings,
week: getWeeklyNoteSettings,
month: getMonthlyNoteSettings,
quarter: getQuarterlyNoteSettings,
year: getYearlyNoteSettings
};
const format = getSettings[granularity]().format.split("/").pop();
const noteDate = window.moment(filename, format, true);
if (!noteDate.isValid()) {
return null;
}
if (isFormatAmbiguous(format, granularity)) {
if (granularity === "week") {
const cleanFormat = removeEscapedCharacters(format);
if (/w{1,2}/i.test(cleanFormat)) {
return window.moment(
filename,
// If format contains week, remove day & month formatting
format.replace(/M{1,4}/g, "").replace(/D{1,4}/g, ""),
false
);
}
}
}
return noteDate;
}
var DailyNotesFolderMissingError = class extends Error {
};
async function createDailyNote2(date) {
const app = window.app;
const { vault } = app;
const moment4 = window.moment;
const { template, format, folder } = getDailyNoteSettings();
const [templateContents, IFoldInfo] = await getTemplateInfo(template);
const filename = date.format(format);
const normalizedPath = await getNotePath(folder, filename);
try {
const createdFile = await vault.create(normalizedPath, templateContents.replace(/{{\s*date\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, moment4().format("HH:mm")).replace(/{{\s*title\s*}}/gi, filename).replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now2 = moment4();
const currentDate = date.clone().set({
hour: now2.get("hour"),
minute: now2.get("minute"),
second: now2.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
}).replace(/{{\s*yesterday\s*}}/gi, date.clone().subtract(1, "day").format(format)).replace(/{{\s*tomorrow\s*}}/gi, date.clone().add(1, "d").format(format)));
app.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
}
function getDailyNote2(date, dailyNotes) {
var _a;
return (_a = dailyNotes[getDateUID(date, "day")]) != null ? _a : null;
}
function getAllDailyNotes2() {
const { vault } = window.app;
const { folder } = getDailyNoteSettings();
const dailyNotesFolder = vault.getAbstractFileByPath(obsidian.normalizePath(folder));
if (!dailyNotesFolder) {
throw new DailyNotesFolderMissingError("Failed to find daily notes folder");
}
const dailyNotes = {};
obsidian.Vault.recurseChildren(dailyNotesFolder, (note) => {
if (note instanceof obsidian.TFile) {
const date = getDateFromFile(note, "day");
if (date) {
const dateString = getDateUID(date, "day");
dailyNotes[dateString] = note;
}
}
});
return dailyNotes;
}
var WeeklyNotesFolderMissingError = class extends Error {
};
function getDaysOfWeek() {
const { moment: moment4 } = window;
let weekStart = moment4.localeData()._week.dow;
const daysOfWeek = [
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday"
];
while (weekStart) {
daysOfWeek.push(daysOfWeek.shift());
weekStart--;
}
return daysOfWeek;
}
function getDayOfWeekNumericalValue(dayOfWeekName) {
return getDaysOfWeek().indexOf(dayOfWeekName.toLowerCase());
}
async function createWeeklyNote(date) {
const { vault } = window.app;
const { template, format, folder } = getWeeklyNoteSettings();
const [templateContents, IFoldInfo] = await getTemplateInfo(template);
const filename = date.format(format);
const normalizedPath = await getNotePath(folder, filename);
try {
const createdFile = await vault.create(normalizedPath, templateContents.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now2 = window.moment();
const currentDate = date.clone().set({
hour: now2.get("hour"),
minute: now2.get("minute"),
second: now2.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
}).replace(/{{\s*title\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm")).replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi, (_, dayOfWeek, momentFormat) => {
const day = getDayOfWeekNumericalValue(dayOfWeek);
return date.weekday(day).format(momentFormat.trim());
}));
window.app.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
}
function getWeeklyNote(date, weeklyNotes) {
var _a;
return (_a = weeklyNotes[getDateUID(date, "week")]) != null ? _a : null;
}
function getAllWeeklyNotes() {
const weeklyNotes = {};
if (!appHasWeeklyNotesPluginLoaded()) {
return weeklyNotes;
}
const { vault } = window.app;
const { folder } = getWeeklyNoteSettings();
const weeklyNotesFolder = vault.getAbstractFileByPath(obsidian.normalizePath(folder));
if (!weeklyNotesFolder) {
throw new WeeklyNotesFolderMissingError("Failed to find weekly notes folder");
}
obsidian.Vault.recurseChildren(weeklyNotesFolder, (note) => {
if (note instanceof obsidian.TFile) {
const date = getDateFromFile(note, "week");
if (date) {
const dateString = getDateUID(date, "week");
weeklyNotes[dateString] = note;
}
}
});
return weeklyNotes;
}
var MonthlyNotesFolderMissingError = class extends Error {
};
async function createMonthlyNote(date) {
const { vault } = window.app;
const { template, format, folder } = getMonthlyNoteSettings();
const [templateContents, IFoldInfo] = await getTemplateInfo(template);
const filename = date.format(format);
const normalizedPath = await getNotePath(folder, filename);
try {
const createdFile = await vault.create(normalizedPath, templateContents.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now2 = window.moment();
const currentDate = date.clone().set({
hour: now2.get("hour"),
minute: now2.get("minute"),
second: now2.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
}).replace(/{{\s*date\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi, filename));
window.app.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
}
function getMonthlyNote(date, monthlyNotes) {
var _a;
return (_a = monthlyNotes[getDateUID(date, "month")]) != null ? _a : null;
}
function getAllMonthlyNotes() {
const monthlyNotes = {};
if (!appHasMonthlyNotesPluginLoaded()) {
return monthlyNotes;
}
const { vault } = window.app;
const { folder } = getMonthlyNoteSettings();
const monthlyNotesFolder = vault.getAbstractFileByPath(obsidian.normalizePath(folder));
if (!monthlyNotesFolder) {
throw new MonthlyNotesFolderMissingError("Failed to find monthly notes folder");
}
obsidian.Vault.recurseChildren(monthlyNotesFolder, (note) => {
if (note instanceof obsidian.TFile) {
const date = getDateFromFile(note, "month");
if (date) {
const dateString = getDateUID(date, "month");
monthlyNotes[dateString] = note;
}
}
});
return monthlyNotes;
}
var QuarterlyNotesFolderMissingError = class extends Error {
};
async function createQuarterlyNote(date) {
const { vault } = window.app;
const { template, format, folder } = getQuarterlyNoteSettings();
const [templateContents, IFoldInfo] = await getTemplateInfo(template);
const filename = date.format(format);
const normalizedPath = await getNotePath(folder, filename);
try {
const createdFile = await vault.create(normalizedPath, templateContents.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now2 = window.moment();
const currentDate = date.clone().set({
hour: now2.get("hour"),
minute: now2.get("minute"),
second: now2.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
}).replace(/{{\s*date\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi, filename));
window.app.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
}
function getQuarterlyNote(date, quarterly) {
var _a;
return (_a = quarterly[getDateUID(date, "quarter")]) != null ? _a : null;
}
function getAllQuarterlyNotes() {
const quarterly = {};
if (!appHasQuarterlyNotesPluginLoaded()) {
return quarterly;
}
const { vault } = window.app;
const { folder } = getQuarterlyNoteSettings();
const quarterlyFolder = vault.getAbstractFileByPath(obsidian.normalizePath(folder));
if (!quarterlyFolder) {
throw new QuarterlyNotesFolderMissingError("Failed to find quarterly notes folder");
}
obsidian.Vault.recurseChildren(quarterlyFolder, (note) => {
if (note instanceof obsidian.TFile) {
const date = getDateFromFile(note, "quarter");
if (date) {
const dateString = getDateUID(date, "quarter");
quarterly[dateString] = note;
}
}
});
return quarterly;
}
var YearlyNotesFolderMissingError = class extends Error {
};
async function createYearlyNote(date) {
const { vault } = window.app;
const { template, format, folder } = getYearlyNoteSettings();
const [templateContents, IFoldInfo] = await getTemplateInfo(template);
const filename = date.format(format);
const normalizedPath = await getNotePath(folder, filename);
try {
const createdFile = await vault.create(normalizedPath, templateContents.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now2 = window.moment();
const currentDate = date.clone().set({
hour: now2.get("hour"),
minute: now2.get("minute"),
second: now2.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
}).replace(/{{\s*date\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi, filename));
window.app.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
}
function getYearlyNote(date, yearlyNotes) {
var _a;
return (_a = yearlyNotes[getDateUID(date, "year")]) != null ? _a : null;
}
function getAllYearlyNotes() {
const yearlyNotes = {};
if (!appHasYearlyNotesPluginLoaded()) {
return yearlyNotes;
}
const { vault } = window.app;
const { folder } = getYearlyNoteSettings();
const yearlyNotesFolder = vault.getAbstractFileByPath(obsidian.normalizePath(folder));
if (!yearlyNotesFolder) {
throw new YearlyNotesFolderMissingError("Failed to find yearly notes folder");
}
obsidian.Vault.recurseChildren(yearlyNotesFolder, (note) => {
if (note instanceof obsidian.TFile) {
const date = getDateFromFile(note, "year");
if (date) {
const dateString = getDateUID(date, "year");
yearlyNotes[dateString] = note;
}
}
});
return yearlyNotes;
}
function appHasDailyNotesPluginLoaded() {
var _a, _b;
const { app } = window;
const dailyNotesPlugin = app.internalPlugins.plugins["daily-notes"];
if (dailyNotesPlugin && dailyNotesPlugin.enabled) {
return true;
}
const periodicNotes = app.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a.daily) == null ? void 0 : _b.enabled);
}
function appHasWeeklyNotesPluginLoaded() {
var _a, _b;
const { app } = window;
if (app.plugins.getPlugin("calendar")) {
return true;
}
const periodicNotes = app.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a.weekly) == null ? void 0 : _b.enabled);
}
function appHasMonthlyNotesPluginLoaded() {
var _a, _b;
const { app } = window;
const periodicNotes = app.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a.monthly) == null ? void 0 : _b.enabled);
}
function appHasQuarterlyNotesPluginLoaded() {
var _a, _b;
const { app } = window;
const periodicNotes = app.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a.quarterly) == null ? void 0 : _b.enabled);
}
function appHasYearlyNotesPluginLoaded() {
var _a, _b;
const { app } = window;
const periodicNotes = app.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a.yearly) == null ? void 0 : _b.enabled);
}
function getPeriodicNoteSettings(granularity) {
const getSettings = {
day: getDailyNoteSettings,
week: getWeeklyNoteSettings,
month: getMonthlyNoteSettings,
quarter: getQuarterlyNoteSettings,
year: getYearlyNoteSettings
}[granularity];
return getSettings();
}
function createPeriodicNote(granularity, date) {
const createFn = {
day: createDailyNote2,
month: createMonthlyNote,
week: createWeeklyNote
};
return createFn[granularity](date);
}
exports.DEFAULT_DAILY_NOTE_FORMAT = DEFAULT_DAILY_NOTE_FORMAT;
exports.DEFAULT_MONTHLY_NOTE_FORMAT = DEFAULT_MONTHLY_NOTE_FORMAT;
exports.DEFAULT_QUARTERLY_NOTE_FORMAT = DEFAULT_QUARTERLY_NOTE_FORMAT;
exports.DEFAULT_WEEKLY_NOTE_FORMAT = DEFAULT_WEEKLY_NOTE_FORMAT;
exports.DEFAULT_YEARLY_NOTE_FORMAT = DEFAULT_YEARLY_NOTE_FORMAT;
exports.appHasDailyNotesPluginLoaded = appHasDailyNotesPluginLoaded;
exports.appHasMonthlyNotesPluginLoaded = appHasMonthlyNotesPluginLoaded;
exports.appHasQuarterlyNotesPluginLoaded = appHasQuarterlyNotesPluginLoaded;
exports.appHasWeeklyNotesPluginLoaded = appHasWeeklyNotesPluginLoaded;
exports.appHasYearlyNotesPluginLoaded = appHasYearlyNotesPluginLoaded;
exports.createDailyNote = createDailyNote2;
exports.createMonthlyNote = createMonthlyNote;
exports.createPeriodicNote = createPeriodicNote;
exports.createQuarterlyNote = createQuarterlyNote;
exports.createWeeklyNote = createWeeklyNote;
exports.createYearlyNote = createYearlyNote;
exports.getAllDailyNotes = getAllDailyNotes2;
exports.getAllMonthlyNotes = getAllMonthlyNotes;
exports.getAllQuarterlyNotes = getAllQuarterlyNotes;
exports.getAllWeeklyNotes = getAllWeeklyNotes;
exports.getAllYearlyNotes = getAllYearlyNotes;
exports.getDailyNote = getDailyNote2;
exports.getDailyNoteSettings = getDailyNoteSettings;
exports.getDateFromFile = getDateFromFile;
exports.getDateFromPath = getDateFromPath;
exports.getDateUID = getDateUID;
exports.getMonthlyNote = getMonthlyNote;
exports.getMonthlyNoteSettings = getMonthlyNoteSettings;
exports.getPeriodicNoteSettings = getPeriodicNoteSettings;
exports.getQuarterlyNote = getQuarterlyNote;
exports.getQuarterlyNoteSettings = getQuarterlyNoteSettings;
exports.getTemplateInfo = getTemplateInfo;
exports.getWeeklyNote = getWeeklyNote;
exports.getWeeklyNoteSettings = getWeeklyNoteSettings;
exports.getYearlyNote = getYearlyNote;
exports.getYearlyNoteSettings = getYearlyNoteSettings;
}
});
// src/main.ts
var main_exports = {};
__export(main_exports, {
default: () => PomodoroTimerPlugin
});
module.exports = __toCommonJS(main_exports);
// src/TimerView.ts
var import_obsidian4 = require("obsidian");
// node_modules/svelte/src/runtime/internal/utils.js
function noop() {
}
function run(fn) {
return fn();
}
function blank_object() {
return /* @__PURE__ */ Object.create(null);
}
function run_all(fns) {
fns.forEach(run);
}
function is_function(thing) {
return typeof thing === "function";
}
function safe_not_equal(a, b) {
return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function";
}
function is_empty(obj) {
return Object.keys(obj).length === 0;
}
function subscribe(store, ...callbacks) {
if (store == null) {
for (const callback of callbacks) {
callback(void 0);
}
return noop;
}
const unsub = store.subscribe(...callbacks);
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
}
function component_subscribe(component, store, callback) {
component.$$.on_destroy.push(subscribe(store, callback));
}
// node_modules/svelte/src/runtime/internal/globals.js
var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : (
// @ts-ignore Node typings have this
global
);
// node_modules/svelte/src/runtime/internal/ResizeObserverSingleton.js
var ResizeObserverSingleton = class {
/** @param {ResizeObserverOptions} options */
constructor(options) {
/**
* @private
* @readonly
* @type {WeakMap<Element, import('./private.js').Listener>}
*/
__publicField(this, "_listeners", "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0);
/**
* @private
* @type {ResizeObserver}
*/
__publicField(this, "_observer");
/** @type {ResizeObserverOptions} */
__publicField(this, "options");
this.options = options;
}
/**
* @param {Element} element
* @param {import('./private.js').Listener} listener
* @returns {() => void}
*/
observe(element2, listener) {
this._listeners.set(element2, listener);
this._getObserver().observe(element2, this.options);
return () => {
this._listeners.delete(element2);
this._observer.unobserve(element2);
};
}
/**
* @private
*/
_getObserver() {
var _a;
return (_a = this._observer) != null ? _a : this._observer = new ResizeObserver((entries) => {
var _a2;
for (const entry of entries) {
ResizeObserverSingleton.entries.set(entry.target, entry);
(_a2 = this._listeners.get(entry.target)) == null ? void 0 : _a2(entry);
}
});
}
};
ResizeObserverSingleton.entries = "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0;
// node_modules/svelte/src/runtime/internal/dom.js
var is_hydrating = false;
function start_hydrating() {
is_hydrating = true;
}
function end_hydrating() {
is_hydrating = false;
}
function append(target, node) {
target.appendChild(node);
}
function append_styles(target, style_sheet_id, styles) {
const append_styles_to = get_root_for_style(target);
if (!append_styles_to.getElementById(style_sheet_id)) {
const style = element("style");
style.id = style_sheet_id;
style.textContent = styles;
append_stylesheet(append_styles_to, style);
}
}
function get_root_for_style(node) {
if (!node)
return document;
const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
if (root && /** @type {ShadowRoot} */
root.host) {
return (
/** @type {ShadowRoot} */
root
);
}
return node.ownerDocument;
}
function append_stylesheet(node, style) {
append(
/** @type {Document} */
node.head || node,
style
);
return style.sheet;
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor || null);
}
function detach(node) {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
}
function destroy_each(iterations, detaching) {
for (let i = 0; i < iterations.length; i += 1) {
if (iterations[i])
iterations[i].d(detaching);
}
}
function element(name) {
return document.createElement(name);
}
function svg_element(name) {
return document.createElementNS("http://www.w3.org/2000/svg", name);
}
function text(data) {
return document.createTextNode(data);
}
function space() {
return text(" ");
}
function empty() {
return text("");
}
function listen(node, event, handler, options) {
node.addEventListener(event, handler, options);
return () => node.removeEventListener(event, handler, options);
}
function attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
node.setAttribute(attribute, value);
}
function children(element2) {
return Array.from(element2.childNodes);
}
function set_data(text2, data) {
data = "" + data;
if (text2.data === data)
return;
text2.data = /** @type {string} */
data;
}
function set_input_value(input, value) {
input.value = value == null ? "" : value;
}
function set_style(node, key, value, important) {
if (value == null) {
node.style.removeProperty(key);
} else {
node.style.setProperty(key, value, important ? "important" : "");
}
}
function get_custom_elements_slots(element2) {
const result = {};
element2.childNodes.forEach(
/** @param {Element} node */
(node) => {
result[node.slot || "default"] = true;
}
);
return result;
}
// node_modules/svelte/src/runtime/internal/lifecycle.js
var current_component;
function set_current_component(component) {
current_component = component;
}
function get_current_component() {
if (!current_component)
throw new Error("Function called outside component initialization");
return current_component;
}
function afterUpdate(fn) {
get_current_component().$$.after_update.push(fn);
}
// node_modules/svelte/src/runtime/internal/scheduler.js
var dirty_components = [];
var binding_callbacks = [];
var render_callbacks = [];
var flush_callbacks = [];
var resolved_promise = /* @__PURE__ */ Promise.resolve();
var update_scheduled = false;
function schedule_update() {
if (!update_scheduled) {
update_scheduled = true;
resolved_promise.then(flush);
}
}
function add_render_callback(fn) {
render_callbacks.push(fn);
}
var seen_callbacks = /* @__PURE__ */ new Set();
var flushidx = 0;
function flush() {
if (flushidx !== 0) {
return;
}
const saved_component = current_component;
do {
try {
while (flushidx < dirty_components.length) {
const component = dirty_components[flushidx];
flushidx++;
set_current_component(component);
update(component.$$);
}
} catch (e) {
dirty_components.length = 0;
flushidx = 0;
throw e;
}
set_current_component(null);
dirty_components.length = 0;
flushidx = 0;
while (binding_callbacks.length)
binding_callbacks.pop()();
for (let i = 0; i < render_callbacks.length; i += 1) {
const callback = render_callbacks[i];
if (!seen_callbacks.has(callback)) {
seen_callbacks.add(callback);
callback();
}
}
render_callbacks.length = 0;
} while (dirty_components.length);
while (flush_callbacks.length) {
flush_callbacks.pop()();
}
update_scheduled = false;
seen_callbacks.clear();
set_current_component(saved_component);
}
function update($$) {
if ($$.fragment !== null) {
$$.update();
run_all($$.before_update);
const dirty = $$.dirty;
$$.dirty = [-1];
$$.fragment && $$.fragment.p($$.ctx, dirty);
$$.after_update.forEach(add_render_callback);
}
}
function flush_render_callbacks(fns) {
const filtered = [];
const targets = [];
render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c));
targets.forEach((c) => c());
render_callbacks = filtered;
}
// node_modules/svelte/src/runtime/internal/transitions.js
var outroing = /* @__PURE__ */ new Set();
var outros;
function group_outros() {
outros = {
r: 0,
c: [],
p: outros
// parent group
};
}
function check_outros() {
if (!outros.r) {
run_all(outros.c);
}
outros = outros.p;
}
function transition_in(block, local) {
if (block && block.i) {
outroing.delete(block);
block.i(local);
}
}
function transition_out(block, local, detach2, callback) {
if (block && block.o) {
if (outroing.has(block))
return;
outroing.add(block);
outros.c.push(() => {
outroing.delete(block);
if (callback) {
if (detach2)
block.d(1);
callback();
}
});
block.o(local);
} else if (callback) {
callback();
}
}
// node_modules/svelte/src/runtime/internal/each.js
function ensure_array_like(array_like_or_iterator) {
return (array_like_or_iterator == null ? void 0 : array_like_or_iterator.length) !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
}
// node_modules/svelte/src/shared/boolean_attributes.js
var _boolean_attributes = (
/** @type {const} */
[
"allowfullscreen",
"allowpaymentrequest",
"async",
"autofocus",
"autoplay",
"checked",
"controls",
"default",
"defer",
"disabled",
"formnovalidate",
"hidden",
"inert",
"ismap",
"loop",
"multiple",
"muted",
"nomodule",
"novalidate",
"open",
"playsinline",
"readonly",
"required",
"reversed",
"selected"
]
);
var boolean_attributes = /* @__PURE__ */ new Set([..._boolean_attributes]);
// node_modules/svelte/src/runtime/internal/Component.js
function create_component(block) {
block && block.c();
}
function mount_component(component, target, anchor) {
const { fragment, after_update } = component.$$;
fragment && fragment.m(target, anchor);
add_render_callback(() => {
const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
if (component.$$.on_destroy) {
component.$$.on_destroy.push(...new_on_destroy);
} else {
run_all(new_on_destroy);
}
component.$$.on_mount = [];
});
after_update.forEach(add_render_callback);
}
function destroy_component(component, detaching) {
const $$ = component.$$;
if ($$.fragment !== null) {
flush_render_callbacks($$.after_update);
run_all($$.on_destroy);
$$.fragment && $$.fragment.d(detaching);
$$.on_destroy = $$.fragment = null;
$$.ctx = [];
}
}
function make_dirty(component, i) {
if (component.$$.dirty[0] === -1) {
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
}
component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
}
function init(component, options, instance6, create_fragment6, not_equal, props, append_styles2 = null, dirty = [-1]) {
const parent_component = current_component;
set_current_component(component);
const $$ = component.$$ = {
fragment: null,
ctx: [],
// state
props,
update: noop,
not_equal,
bound: blank_object(),
// lifecycle
on_mount: [],
on_destroy: [],
on_disconnect: [],
before_update: [],
after_update: [],
context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
// everything else
callbacks: blank_object(),
dirty,
skip_bound: false,
root: options.target || parent_component.$$.root
};
append_styles2 && append_styles2($$.root);
let ready = false;
$$.ctx = instance6 ? instance6(component, options.props || {}, (i, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
if (!$$.skip_bound && $$.bound[i])
$$.bound[i](value);
if (ready)
make_dirty(component, i);
}
return ret;
}) : [];
$$.update();
ready = true;
run_all($$.before_update);
$$.fragment = create_fragment6 ? create_fragment6($$.ctx) : false;
if (options.target) {
if (options.hydrate) {
start_hydrating();
const nodes = children(options.target);
$$.fragment && $$.fragment.l(nodes);
nodes.forEach(detach);
} else {
$$.fragment && $$.fragment.c();
}
if (options.intro)
transition_in(component.$$.fragment);
mount_component(component, options.target, options.anchor);
end_hydrating();
flush();
}
set_current_component(parent_component);
}
var SvelteElement;
if (typeof HTMLElement === "function") {
SvelteElement = class extends HTMLElement {
constructor($$componentCtor, $$slots, use_shadow_dom) {
super();
/** The Svelte component constructor */
__publicField(this, "$$ctor");
/** Slots */
__publicField(this, "$$s");
/** The Svelte component instance */
__publicField(this, "$$c");
/** Whether or not the custom element is connected */
__publicField(this, "$$cn", false);
/** Component props data */
__publicField(this, "$$d", {});
/** `true` if currently in the process of reflecting component props back to attributes */
__publicField(this, "$$r", false);
/** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
__publicField(this, "$$p_d", {});
/** @type {Record<string, Function[]>} Event listeners */
__publicField(this, "$$l", {});
/** @type {Map<Function, Function>} Event listener unsubscribe functions */
__publicField(this, "$$l_u", /* @__PURE__ */ new Map());
this.$$ctor = $$componentCtor;
this.$$s = $$slots;
if (use_shadow_dom) {
this.attachShadow({ mode: "open" });
}
}
addEventListener(type, listener, options) {
this.$$l[type] = this.$$l[type] || [];
this.$$l[type].push(listener);
if (this.$$c) {
const unsub = this.$$c.$on(type, listener);
this.$$l_u.set(listener, unsub);
}
super.addEventListener(type, listener, options);
}
removeEventListener(type, listener, options) {
super.removeEventListener(type, listener, options);
if (this.$$c) {
const unsub = this.$$l_u.get(listener);
if (unsub) {
unsub();
this.$$l_u.delete(listener);
}
}
}
async connectedCallback() {
this.$$cn = true;
if (!this.$$c) {
let create_slot = function(name) {
return () => {
let node;
const obj = {
c: function create() {
node = element("slot");
if (name !== "default") {
attr(node, "name", name);
}
},
/**
* @param {HTMLElement} target
* @param {HTMLElement} [anchor]
*/
m: function mount(target, anchor) {
insert(target, node, anchor);
},
d: function destroy(detaching) {
if (detaching) {
detach(node);
}
}
};
return obj;
};
};
await Promise.resolve();
if (!this.$$cn) {
return;
}
const $$slots = {};
const existing_slots = get_custom_elements_slots(this);
for (const name of this.$$s) {
if (name in existing_slots) {
$$slots[name] = [create_slot(name)];
}
}
for (const attribute of this.attributes) {
const name = this.$$g_p(attribute.name);
if (!(name in this.$$d)) {
this.$$d[name] = get_custom_element_value(name, attribute.value, this.$$p_d, "toProp");
}
}
this.$$c = new this.$$ctor({
target: this.shadowRoot || this,
props: {
...this.$$d,
$$slots,
$$scope: {
ctx: []
}
}
});
const reflect_attributes = () => {
this.$$r = true;
for (const key in this.$$p_d) {
this.$$d[key] = this.$$c.$$.ctx[this.$$c.$$.props[key]];
if (this.$$p_d[key].reflect) {
const attribute_value = get_custom_element_value(
key,
this.$$d[key],
this.$$p_d,
"toAttribute"
);
if (attribute_value == null) {
this.removeAttribute(this.$$p_d[key].attribute || key);
} else {
this.setAttribute(this.$$p_d[key].attribute || key, attribute_value);
}
}
}
this.$$r = false;
};
this.$$c.$$.after_update.push(reflect_attributes);
reflect_attributes();
for (const type in this.$$l) {
for (const listener of this.$$l[type]) {
const unsub = this.$$c.$on(type, listener);
this.$$l_u.set(listener, unsub);
}
}
this.$$l = {};
}
}
// We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
// and setting attributes through setAttribute etc, this is helpful
attributeChangedCallback(attr2, _oldValue, newValue) {
var _a;
if (this.$$r)
return;
attr2 = this.$$g_p(attr2);
this.$$d[attr2] = get_custom_element_value(attr2, newValue, this.$$p_d, "toProp");
(_a = this.$$c) == null ? void 0 : _a.$set({ [attr2]: this.$$d[attr2] });
}
disconnectedCallback() {
this.$$cn = false;
Promise.resolve().then(() => {
if (!this.$$cn) {
this.$$c.$destroy();
this.$$c = void 0;
}
});
}
$$g_p(attribute_name) {
return Object.keys(this.$$p_d).find(
(key) => this.$$p_d[key].attribute === attribute_name || !this.$$p_d[key].attribute && key.toLowerCase() === attribute_name
) || attribute_name;
}
};
}
function get_custom_element_value(prop, value, props_definition, transform) {
var _a;
const type = (_a = props_definition[prop]) == null ? void 0 : _a.type;
value = type === "Boolean" && typeof value !== "boolean" ? value != null : value;
if (!transform || !props_definition[prop]) {
return value;
} else if (transform === "toAttribute") {
switch (type) {
case "Object":
case "Array":
return value == null ? null : JSON.stringify(value);
case "Boolean":
return value ? "" : null;
case "Number":
return value == null ? null : value;
default:
return value;
}
} else {
switch (type) {
case "Object":
case "Array":
return value && JSON.parse(value);
case "Boolean":
return value;
case "Number":
return value != null ? +value : value;
default:
return value;
}
}
}
var SvelteComponent = class {
constructor() {
/**
* ### PRIVATE API
*
* Do not use, may change at any time
*
* @type {any}
*/
__publicField(this, "$$");
/**
* ### PRIVATE API
*
* Do not use, may change at any time
*
* @type {any}
*/
__publicField(this, "$$set");
}
/** @returns {void} */
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
/**
* @template {Extract<keyof Events, string>} K
* @param {K} type
* @param {((e: Events[K]) => void) | null | undefined} callback
* @returns {() => void}
*/
$on(type, callback) {
if (!is_function(callback)) {
return noop;
}
const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
callbacks.push(callback);
return () => {
const index = callbacks.indexOf(callback);
if (index !== -1)
callbacks.splice(index, 1);
};
}
/**
* @param {Partial<Props>} props
* @returns {void}
*/
$set(props) {
if (this.$$set && !is_empty(props)) {
this.$$.skip_bound = true;
this.$$set(props);
this.$$.skip_bound = false;
}
}
};
// node_modules/svelte/src/shared/version.js
var PUBLIC_VERSION = "4";
// node_modules/svelte/src/runtime/internal/disclose-version/index.js
if (typeof window !== "undefined")
(window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
// src/TaskItemComponent.svelte
function add_css(target) {
append_styles(target, "svelte-u70618", ".pomodoro-tasks-item-desc.svelte-u70618{flex:1;overflow:hidden;width:100%;pointer-events:none;cursor:pointer}");
}
function create_fragment(ctx) {
let div;
return {
c() {
div = element("div");
attr(div, "class", "pomodoro-tasks-item-desc svelte-u70618");
},
m(target, anchor) {
insert(target, div, anchor);
ctx[3](div);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching) {
detach(div);
}
ctx[3](null);
}
};
}
function instance($$self, $$props, $$invalidate) {
let { render } = $$props;
let { content } = $$props;
let el;
afterUpdate(() => {
el.empty();
render(content, el);
});
function div_binding($$value) {
binding_callbacks[$$value ? "unshift" : "push"](() => {
el = $$value;
$$invalidate(0, el);
});
}
$$self.$$set = ($$props2) => {
if ("render" in $$props2)
$$invalidate(1, render = $$props2.render);
if ("content" in $$props2)
$$invalidate(2, content = $$props2.content);
};
return [el, render, content, div_binding];
}
var TaskItemComponent = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { render: 1, content: 2 }, add_css);
}
};
var TaskItemComponent_default = TaskItemComponent;
// src/utils.ts
var import_obsidian = require("obsidian");
var import_obsidian_daily_notes_interface = __toESM(require_main());
// src/serializer/TaskModels.ts
var _TaskRegularExpressions = class {
};
var TaskRegularExpressions = _TaskRegularExpressions;
TaskRegularExpressions.dateFormat = "YYYY-MM-DD";
TaskRegularExpressions.dateTimeFormat = "YYYY-MM-DD HH:mm";
// Matches indentation before a list marker (including > for potentially nested blockquotes or Obsidian callouts)
TaskRegularExpressions.indentationRegex = /^([\s\t>]*)/;
// Matches - * and + list markers, or numbered list markers (eg 1.)
TaskRegularExpressions.listMarkerRegex = /([-*+]|[0-9]+\.)/;
// Matches a checkbox and saves the status character inside
TaskRegularExpressions.checkboxRegex = /\[(.)\]/u;
// Matches the rest of the task after the checkbox.
TaskRegularExpressions.afterCheckboxRegex = / *(.*)/u;
// Main regex for parsing a line. It matches the following:
// - Indentation
// - List marker
// - Status character
// - Rest of task after checkbox markdown
// See Task.extractTaskComponents() for abstraction around this regular expression.
// That is private for now, but could be made public in future if needed.
TaskRegularExpressions.taskRegex = new RegExp(
_TaskRegularExpressions.indentationRegex.source + _TaskRegularExpressions.listMarkerRegex.source + " +" + _TaskRegularExpressions.checkboxRegex.source + _TaskRegularExpressions.afterCheckboxRegex.source,
"u"
);
// Used with the "Create or Edit Task" command to parse indentation and status if present
TaskRegularExpressions.nonTaskRegex = new RegExp(
_TaskRegularExpressions.indentationRegex.source + _TaskRegularExpressions.listMarkerRegex.source + "? *(" + _TaskRegularExpressions.checkboxRegex.source + ")?" + _TaskRegularExpressions.afterCheckboxRegex.source,
"u"
);
// Used with "Toggle Done" command to detect a list item that can get a checkbox added to it.
TaskRegularExpressions.listItemRegex = new RegExp(
_TaskRegularExpressions.indentationRegex.source + _TaskRegularExpressions.listMarkerRegex.source
);
// Match on block link at end.
TaskRegularExpressions.blockLinkRegex = / \^[a-zA-Z0-9-]+$/u;
// Regex to match all hash tags, basically hash followed by anything but the characters in the negation.
// To ensure URLs are not caught it is looking of beginning of string tag and any
// tag that has a space in front of it. Any # that has a character in front
// of it will be ignored.
// EXAMPLE:
// description: '#dog #car http://www/ddd#ere #house'
// matches: #dog, #car, #house
// MAINTENANCE NOTE:
// If hashTags is modified, please update 'Recognising Tags' in Tags.md in the docs.
TaskRegularExpressions.hashTags = /(^|\s)#[^ !@#$%^&*(),.?":{}|<>]+/g;
TaskRegularExpressions.hashTagsFromEnd = new RegExp(
_TaskRegularExpressions.hashTags.source + "$"
);
// src/utils.ts
function getTemplater(app) {
return app.plugins.plugins["templater-obsidian"];
}
async function parseWithTemplater(app, tfile, templateContent, log) {
const templater = getTemplater(app);
if (!templater)
return templateContent;
const preamble = `<%* const log = ${JSON.stringify(
log
)}; log.begin = moment(log.begin); log.end = moment(log.end); %>`;
return await templater.templater.parse_template(
{ target_file: tfile, run_mode: 4 },
`${preamble}${templateContent}`
);
}
var ensureFileExists = async (app, path) => {
const dirs = path.replace(/\\/g, "/").split("/");
dirs.pop();
if (dirs.length) {
const dir = join(...dirs);
if (!app.vault.getAbstractFileByPath(dir)) {
await app.vault.createFolder(dir);
}
}
const file = app.vault.getAbstractFileByPath(path);
if (file) {
if (file instanceof import_obsidian.TFile) {
const md = file;
if (md.extension == "md") {
return md;
} else {
throw new Error(`invalid file extension: ${md.extension}`);
}
} else {
throw new Error(`invalid file path: ${path}`);
}
} else {
return await app.vault.create(path, "");
}
};
var join = (...partSegments) => {
let parts = [];
for (let i = 0, l = partSegments.length; i < l; i++) {
parts = parts.concat(partSegments[i].split("/"));
}
const newParts = [];
for (let i = 0, l = parts.length; i < l; i++) {
const part = parts[i];
if (!part || part === ".")
continue;
else
newParts.push(part);
}
if (parts[0] === "")
newParts.unshift("");
return newParts.join("/");
};
var getDailyNoteFile = async () => {
const file = (0, import_obsidian_daily_notes_interface.getDailyNote)((0, import_obsidian.moment)(), (0, import_obsidian_daily_notes_interface.getAllDailyNotes)());
if (!file) {
return await (0, import_obsidian_daily_notes_interface.createDailyNote)((0, import_obsidian.moment)());
}
return file;
};
var HASH_TAGS_REG_EXP = /(^|\s)#[^ !@#$%^&*(),.?":{}|<>]+/g;
function extractHashtags(description) {
var _a, _b;
return (_b = (_a = description.match(HASH_TAGS_REG_EXP)) == null ? void 0 : _a.map((tag) => tag.trim())) != null ? _b : [];
}
function extractTaskComponents(line) {
const regexMatch = line.match(TaskRegularExpressions.taskRegex);
if (regexMatch === null) {
return null;
}
const indentation = regexMatch[1];
const listMarker = regexMatch[2];
const statusString = regexMatch[3];
const status = statusString;
let body = regexMatch[4].trim();
const blockLinkMatch = body.match(TaskRegularExpressions.blockLinkRegex);
const blockLink = blockLinkMatch !== null ? blockLinkMatch[0] : "";
if (blockLink !== "") {
body = body.replace(TaskRegularExpressions.blockLinkRegex, "").trim();
}
return { indentation, listMarker, status, body, blockLink };
}
function toInlineFieldRegex(innerFieldRegex) {
const fieldRegex = [
"(?:",
/* */
/(?=[^\]]+\])\[/,
// Try to match '[' if there's a ']' later in the string
/* */
"|",
/* */
/(?=[^)]+\))\(/,
// Otherwise, match '(' if there's a ')' later in the string
")",
/ */,
innerFieldRegex,
/ */,
/[)\]]/,
/(?: *,)?/,
// Allow trailing comma, enables workaround from #1913 for rendering issue
/$/
// Regexes are matched from the end of the string forwards
].map((val) => val instanceof RegExp ? val.source : val).join("");
return new RegExp(fieldRegex, innerFieldRegex.flags);
}
// node_modules/svelte/src/runtime/store/index.js
var subscriber_queue = [];
function readable(value, start) {
return {
subscribe: writable(value, start).subscribe
};
}
function writable(value, start = noop) {
let stop;
const subscribers = /* @__PURE__ */ new Set();
function set(new_value) {
if (safe_not_equal(value, new_value)) {
value = new_value;
if (stop) {
const run_queue = !subscriber_queue.length;
for (const subscriber of subscribers) {
subscriber[1]();
subscriber_queue.push(subscriber, value);
}
if (run_queue) {
for (let i = 0; i < subscriber_queue.length; i += 2) {
subscriber_queue[i][0](subscriber_queue[i + 1]);
}
subscriber_queue.length = 0;
}
}
}
}
function update2(fn) {
set(fn(value));
}
function subscribe2(run2, invalidate = noop) {
const subscriber = [run2, invalidate];
subscribers.add(subscriber);
if (subscribers.size === 1) {
stop = start(set, update2) || noop;
}
run2(value);
return () => {
subscribers.delete(subscriber);
if (subscribers.size === 0 && stop) {
stop();
stop = null;
}
};
}
return { set, update: update2, subscribe: subscribe2 };
}
function derived(stores, fn, initial_value) {
const single = !Array.isArray(stores);
const stores_array = single ? [stores] : stores;
if (!stores_array.every(Boolean)) {
throw new Error("derived() expects stores as input, got a falsy value");
}
const auto = fn.length < 2;
return readable(initial_value, (set, update2) => {
let started = false;
const values = [];
let pending = 0;
let cleanup = noop;
const sync = () => {
if (pending) {
return;
}
cleanup();
const result = fn(single ? values[0] : values, set, update2);
if (auto) {
set(result);
} else {
cleanup = is_function(result) ? result : noop;
}
};
const unsubscribers = stores_array.map(
(store, i) => subscribe(
store,
(value) => {
values[i] = value;
pending &= ~(1 << i);
if (started) {
sync();
}
},
() => {
pending |= 1 << i;
}
)
);
started = true;
sync();
return function stop() {
run_all(unsubscribers);
cleanup();
started = false;
};
});
}
// src/serializer/DefaultTaskSerializer.ts
var DEFAULT_SYMBOLS = {
// NEW_TASK_FIELD_EDIT_REQUIRED
prioritySymbols: {
Highest: "\u{1F53A}",
High: "\u23EB",
Medium: "\u{1F53C}",
Low: "\u{1F53D}",
Lowest: "\u23EC",
None: ""
},
startDateSymbol: "\u{1F6EB}",
createdDateSymbol: "\u2795",
scheduledDateSymbol: "\u23F3",
dueDateSymbol: "\u{1F4C5}",
doneDateSymbol: "\u2705",
cancelledDateSymbol: "\u274C",
recurrenceSymbol: "\u{1F501}",
pomodorosSymbol: "\u{1F345}::",
TaskFormatRegularExpressions: {
// The following regex's end with `$` because they will be matched and
// removed from the end until none are left.
priorityRegex: /([🔺⏫🔼🔽⏬])$/u,
startDateRegex: /🛫 *(\d{4}-\d{2}-\d{2})$/u,
createdDateRegex: / *(\d{4}-\d{2}-\d{2})$/u,
scheduledDateRegex: /[⏳⌛] *(\d{4}-\d{2}-\d{2})$/u,
dueDateRegex: /[📅📆🗓] *(\d{4}-\d{2}-\d{2})$/u,
doneDateRegex: /✅ *(\d{4}-\d{2}-\d{2})$/u,
cancelledDateRegex: /❌ *(\d{4}-\d{2}-\d{2})$/u,
recurrenceRegex: /🔁 ?([a-zA-Z0-9, !]+)$/iu,
pomodorosRegex: toInlineFieldRegex(/🍅:: *(\d* *\/? *\d*)/)
}
};
var DefaultTaskSerializer = class {
constructor(symbols) {
this.symbols = symbols;
}
/**
* Given the string captured in the first capture group of
* {@link DefaultTaskSerializerSymbols.TaskFormatRegularExpressions.priorityRegex},
* returns the corresponding Priority level.
*
* @param p String captured by priorityRegex
* @returns Corresponding priority if parsing was successful, otherwise {@link Priority.None}
*/
parsePriority(p) {
const { prioritySymbols } = this.symbols;
switch (p) {
case prioritySymbols.Lowest:
return "5" /* Lowest */;
case prioritySymbols.Low:
return "4" /* Low */;
case prioritySymbols.Medium:
return "2" /* Medium */;
case prioritySymbols.High:
return "1" /* High */;
case prioritySymbols.Highest:
return "0" /* Highest */;
default:
return "3" /* None */;
}
}
/* Parse TaskDetails from the textual description of a {@link Task}
*
* @param line The string to parse
*
* @return {TaskDetails}
*/
deserialize(line) {
const { TaskFormatRegularExpressions } = this.symbols;
let matched;
let priority = "3" /* None */;
let startDate = null;
let scheduledDate = null;
let dueDate = null;
let doneDate = null;
let cancelledDate = null;
let createdDate = null;
let recurrenceRule = "";
let pomodoros = "";
let trailingTags = "";
const maxRuns = 20;
let runs = 0;
do {
matched = false;
const pomodorosMatch = line.match(
TaskFormatRegularExpressions.pomodorosRegex
);
if (pomodorosMatch !== null) {
pomodoros = pomodorosMatch[1];
line = line.replace(TaskFormatRegularExpressions.pomodorosRegex, "").trim();
matched = true;
}
const priorityMatch = line.match(
TaskFormatRegularExpressions.priorityRegex
);
if (priorityMatch !== null) {
priority = this.parsePriority(priorityMatch[1]);
line = line.replace(TaskFormatRegularExpressions.priorityRegex, "").trim();
matched = true;
}
const doneDateMatch = line.match(
TaskFormatRegularExpressions.doneDateRegex
);
if (doneDateMatch !== null) {
doneDate = window.moment(
doneDateMatch[1],
TaskRegularExpressions.dateFormat
);
line = line.replace(TaskFormatRegularExpressions.doneDateRegex, "").trim();
matched = true;
}
const cancelledDateMatch = line.match(
TaskFormatRegularExpressions.cancelledDateRegex
);
if (cancelledDateMatch !== null) {
cancelledDate = window.moment(
cancelledDateMatch[1],
TaskRegularExpressions.dateFormat
);
line = line.replace(
TaskFormatRegularExpressions.cancelledDateRegex,
""
).trim();
matched = true;
}
const dueDateMatch = line.match(
TaskFormatRegularExpressions.dueDateRegex
);
if (dueDateMatch !== null) {
dueDate = window.moment(
dueDateMatch[1],
TaskRegularExpressions.dateFormat
);
line = line.replace(TaskFormatRegularExpressions.dueDateRegex, "").trim();
matched = true;
}
const scheduledDateMatch = line.match(
TaskFormatRegularExpressions.scheduledDateRegex
);
if (scheduledDateMatch !== null) {
scheduledDate = window.moment(
scheduledDateMatch[1],
TaskRegularExpressions.dateFormat
);
line = line.replace(
TaskFormatRegularExpressions.scheduledDateRegex,
""
).trim();
matched = true;
}
const startDateMatch = line.match(
TaskFormatRegularExpressions.startDateRegex
);
if (startDateMatch !== null) {
startDate = window.moment(
startDateMatch[1],
TaskRegularExpressions.dateFormat
);
line = line.replace(TaskFormatRegularExpressions.startDateRegex, "").trim();
matched = true;
}
const createdDateMatch = line.match(
TaskFormatRegularExpressions.createdDateRegex
);
if (createdDateMatch !== null) {
createdDate = window.moment(
createdDateMatch[1],
TaskRegularExpressions.dateFormat
);
line = line.replace(TaskFormatRegularExpressions.createdDateRegex, "").trim();
matched = true;
}
const recurrenceMatch = line.match(
TaskFormatRegularExpressions.recurrenceRegex
);
if (recurrenceMatch !== null) {
recurrenceRule = recurrenceMatch[1].trim();
line = line.replace(TaskFormatRegularExpressions.recurrenceRegex, "").trim();
matched = true;
}
const tagsMatch = line.match(TaskRegularExpressions.hashTagsFromEnd);
if (tagsMatch != null) {
line = line.replace(TaskRegularExpressions.hashTagsFromEnd, "").trim();
matched = true;
const tagName = tagsMatch[0].trim();
trailingTags = trailingTags.length > 0 ? [tagName, trailingTags].join(" ") : tagName;
}
runs++;
} while (matched && runs <= maxRuns);
if (trailingTags.length > 0)
line += " " + trailingTags;
return {
description: line,
priority,
startDate,
createdDate,
scheduledDate,
dueDate,
doneDate,
cancelledDate,
recurrenceRule,
pomodoros,
tags: extractHashtags(line)
};
}
};
// src/serializer/DataviewTaskSerializer.ts
var DATAVIEW_SYMBOLS = {
// NEW_TASK_FIELD_EDIT_REQUIRED
prioritySymbols: {
Highest: "priority:: highest",
High: "priority:: high",
Medium: "priority:: medium",
Low: "priority:: low",
Lowest: "priority:: lowest",
None: ""
},
startDateSymbol: "start::",
createdDateSymbol: "created::",
scheduledDateSymbol: "scheduled::",
dueDateSymbol: "due::",
doneDateSymbol: "completion::",
cancelledDateSymbol: "cancelled::",
recurrenceSymbol: "repeat::",
pomodorosSymbol: "\u{1F345}::",
TaskFormatRegularExpressions: {
priorityRegex: toInlineFieldRegex(
/priority:: *(highest|high|medium|low|lowest)/
),
startDateRegex: toInlineFieldRegex(/start:: *(\d{4}-\d{2}-\d{2})/),
createdDateRegex: toInlineFieldRegex(/created:: *(\d{4}-\d{2}-\d{2})/),
scheduledDateRegex: toInlineFieldRegex(
/scheduled:: *(\d{4}-\d{2}-\d{2})/
),
dueDateRegex: toInlineFieldRegex(/due:: *(\d{4}-\d{2}-\d{2})/),
doneDateRegex: toInlineFieldRegex(/completion:: *(\d{4}-\d{2}-\d{2})/),
cancelledDateRegex: toInlineFieldRegex(
/cancelled:: *(\d{4}-\d{2}-\d{2})/
),
recurrenceRegex: toInlineFieldRegex(/repeat:: *([a-zA-Z0-9, !]+)/),
pomodorosRegex: toInlineFieldRegex(/🍅:: *(\d* *\/? *\d*)/)
}
};
var DataviewTaskSerializer = class extends DefaultTaskSerializer {
constructor() {
super(DATAVIEW_SYMBOLS);
}
parsePriority(p) {
switch (p) {
case "highest":
return "0" /* Highest */;
case "high":
return "1" /* High */;
case "medium":
return "2" /* Medium */;
case "low":
return "4" /* Low */;
case "lowest":
return "5" /* Lowest */;
default:
return "3" /* None */;
}
}
};
// src/serializer/index.ts
var POMODORO_REGEX = new RegExp(
"(?:(?=[^\\]]+\\])\\[|(?=[^)]+\\))\\() *\u{1F345}:: *(\\d* *\\/? *\\d*) *[)\\]](?: *,)?"
);
var DESERIALIZERS = {
TASKS: new DefaultTaskSerializer(DEFAULT_SYMBOLS),
DATAVIEW: new DataviewTaskSerializer()
};
// src/Tasks.ts
var Tasks = class {
constructor(plugin) {
this.unsubscribers = [];
this.state = {
list: []
};
this.plugin = plugin;
this._store = writable(this.state);
this.unsubscribers.push(
this._store.subscribe((state) => {
this.state = state;
})
);
this.unsubscribers.push(
derived(this.plugin.tracker, ($tracker) => {
var _a;
return (_a = $tracker.file) == null ? void 0 : _a.path;
}).subscribe(() => {
var _a;
let file = (_a = this.plugin.tracker) == null ? void 0 : _a.file;
if (file) {
this.loadFileTasks(file);
} else {
this.clearTasks();
}
})
);
this.subscribe = this._store.subscribe;
this.plugin.registerEvent(
plugin.app.metadataCache.on(
"changed",
(file, content, cache) => {
var _a, _b;
if (file.extension === "md" && file == this.plugin.tracker.file) {
let tasks = resolveTasks(
this.plugin.getSettings().taskFormat,
file,
content,
cache
);
this._store.update((state) => {
state.list = tasks;
return state;
});
if ((_b = (_a = this.plugin.tracker) == null ? void 0 : _a.task) == null ? void 0 : _b.blockLink) {
let task = tasks.find(
(item) => {
var _a2, _b2;
return item.blockLink && item.blockLink === ((_b2 = (_a2 = this.plugin.tracker) == null ? void 0 : _a2.task) == null ? void 0 : _b2.blockLink);
}
);
if (task) {
this.plugin.tracker.sync(task);
}
}
}
}
)
);
}
static getDeserializer(format) {
return DESERIALIZERS[format];
}
loadFileTasks(file) {
if (file.extension == "md") {
this.plugin.app.vault.cachedRead(file).then((c) => {
let tasks = resolveTasks(
this.plugin.getSettings().taskFormat,
file,
c,
this.plugin.app.metadataCache.getFileCache(file)
);
this._store.update(() => ({
list: tasks
}));
});
} else {
this._store.update(() => ({
file,
list: []
}));
}
}
clearTasks() {
this._store.update(() => ({
list: []
}));
}
destroy() {
for (let unsub of this.unsubscribers) {
unsub();
}
}
};
function resolveTasks(format, file, content, metadata) {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
if (!content || !metadata) {
return [];
}
let cache = {};
const lines = content.split("\n");
for (let rawElement of metadata.listItems || []) {
if (rawElement.task) {
let lineNr = rawElement.position.start.line;
let line = lines[lineNr];
const components = extractTaskComponents(line);
if (!components) {
continue;
}
let detail = DESERIALIZERS[format].deserialize(components.body);
let [actual, expected] = detail.pomodoros.split("/");
const dateformat = "YYYY-MM-DD";
let item = {
text: line,
path: file.path,
fileName: file.name,
name: detail.description,
status: components.status,
blockLink: components.blockLink,
checked: rawElement.task != "" && rawElement.task != " ",
description: detail.description,
done: (_b = (_a = detail.doneDate) == null ? void 0 : _a.format(dateformat)) != null ? _b : "",
due: (_d = (_c = detail.dueDate) == null ? void 0 : _c.format(dateformat)) != null ? _d : "",
created: (_f = (_e = detail.createdDate) == null ? void 0 : _e.format(dateformat)) != null ? _f : "",
cancelled: (_h = (_g = detail.cancelledDate) == null ? void 0 : _g.format(dateformat)) != null ? _h : "",
scheduled: (_j = (_i = detail.scheduledDate) == null ? void 0 : _i.format(dateformat)) != null ? _j : "",
start: (_l = (_k = detail.startDate) == null ? void 0 : _k.format(dateformat)) != null ? _l : "",
priority: detail.priority,
recurrence: detail.recurrenceRule,
expected: expected ? parseInt(expected) : 0,
actual: actual === "" ? 0 : parseInt(actual),
tags: detail.tags,
line: lineNr
};
cache[lineNr] = item;
}
}
return Object.values(cache);
}
// src/Settings.ts
var import_obsidian2 = require("obsidian");
var _PomodoroSettings = class extends import_obsidian2.PluginSettingTab {
constructor(plugin, settings2) {
super(plugin.app, plugin);
this.updateSettings = (newSettings, refreshUI = false) => {
_PomodoroSettings.settings.update((settings2) => {
this._settings = { ...settings2, ...newSettings };
if (refreshUI) {
this.display();
}
return this._settings;
});
};
this.plugin = plugin;
this._settings = { ..._PomodoroSettings.DEFAULT_SETTINGS, ...settings2 };
_PomodoroSettings.settings.set(this._settings);
this.unsubscribe = _PomodoroSettings.settings.subscribe((settings3) => {
var _a;
this.plugin.saveData(settings3);
this._settings = settings3;
(_a = this.plugin.timer) == null ? void 0 : _a.setupTimer();
});
}
getSettings() {
return this._settings;
}
unload() {
this.unsubscribe();
}
display() {
const { containerEl } = this;
containerEl.empty();
new import_obsidian2.Setting(containerEl).setName("Enable Status Bar Timer").addToggle((toggle) => {
toggle.setValue(this._settings.useStatusBarTimer);
toggle.onChange((value) => {
this.updateSettings({ useStatusBarTimer: value });
});
});
new import_obsidian2.Setting(containerEl).setHeading().setName("Notification");
new import_obsidian2.Setting(containerEl).setName("Use System Notification").addToggle((toggle) => {
toggle.setValue(this._settings.useSystemNotification);
toggle.onChange((value) => {
this.updateSettings({ useSystemNotification: value });
});
});
new import_obsidian2.Setting(containerEl).setName("Sound Notification").addToggle((toggle) => {
toggle.setValue(this._settings.notificationSound);
toggle.onChange((value) => {
this.updateSettings({ notificationSound: value }, true);
});
});
if (this._settings.notificationSound) {
new import_obsidian2.Setting(containerEl).setName("Custom Notification Audio").addText((text2) => {
text2.inputEl.style.width = "100%";
text2.setPlaceholder("path/to/sound.mp3");
text2.setValue(this._settings.customSound);
text2.onChange((value) => {
this.updateSettings({ customSound: value });
});
}).addExtraButton((button) => {
button.setIcon("play");
button.setTooltip("play");
button.onClick(() => {
var _a;
(_a = this.plugin.timer) == null ? void 0 : _a.playAudio();
});
});
}
new import_obsidian2.Setting(containerEl).setHeading().setName("Task");
new import_obsidian2.Setting(containerEl).setName("Enable Task Tracking").setDesc(
"Important: Enabling this feature will automatically add a block ID when activating a task, unless a block ID is already present."
).addToggle((toggle) => {
toggle.setValue(this._settings.enableTaskTracking);
toggle.onChange((value) => {
this.updateSettings({ enableTaskTracking: value });
});
});
new import_obsidian2.Setting(containerEl).setName("Show Task Progress Background").addToggle((toggle) => {
toggle.setValue(this._settings.showTaskProgress);
toggle.onChange((value) => {
this.updateSettings({ showTaskProgress: value });
});
});
new import_obsidian2.Setting(containerEl).setName("Task Format").addDropdown((dropdown) => {
dropdown.selectEl.style.width = "160px";
dropdown.addOptions({
TASKS: "Tasks Emoji Format",
DATAVIEW: "Dataview"
});
dropdown.setValue(this._settings.taskFormat);
dropdown.onChange((value) => {
this.updateSettings(
{ taskFormat: value },
true
);
});
});
new import_obsidian2.Setting(containerEl).setHeading().setName("Log");
new import_obsidian2.Setting(containerEl).setName("Log File").addDropdown((dropdown) => {
dropdown.selectEl.style.width = "160px";
dropdown.addOptions({
NONE: "None",
DAILY: "Daily note",
FILE: "File"
});
dropdown.setValue(this._settings.logFile);
dropdown.onChange((value) => {
this.updateSettings({ logFile: value }, true);
});
});
if (this._settings.logFile != "NONE") {
if (this._settings.logFile === "FILE") {
new import_obsidian2.Setting(containerEl).setName("Log file path").setDesc("The file to log pomodoro sessions to").addText((text2) => {
text2.inputEl.style.width = "300px";
text2.setValue(this._settings.logPath);
text2.onChange((value) => {
this.updateSettings({ logPath: value });
});
});
}
new import_obsidian2.Setting(containerEl).setName("Log Level").addDropdown((dropdown) => {
dropdown.selectEl.style.width = "160px";
dropdown.addOptions({
ALL: "All",
WORK: "Work",
BREAK: "Break"
});
dropdown.setValue(this._settings.logLevel);
dropdown.onChange((value) => {
this.updateSettings({ logLevel: value });
});
});
const hasTemplater = !!getTemplater(this.app);
let example = "";
if (this._settings.logFormat == "SIMPLE") {
example = `**WORK(25m)**: from ${(0, import_obsidian2.moment)().subtract(25, "minutes").format("HH:mm")} - ${(0, import_obsidian2.moment)().format("HH:mm")}`;
}
if (this._settings.logFormat == "VERBOSE") {
example = `- \u{1F345} (pomodoro::WORK) (duration:: 25m) (begin:: ${(0, import_obsidian2.moment)().subtract(25, "minutes").format("YYYY-MM-DD HH:mm")}) - (end:: ${(0, import_obsidian2.moment)().format(
"YYYY-MM-DD HH:mm"
)})`;
}
new import_obsidian2.Setting(containerEl).setName("Log Format").setDesc(example).addDropdown((dropdown) => {
dropdown.selectEl.style.width = "160px";
dropdown.addOptions({
SIMPLE: "Simple",
VERBOSE: "Verbose",
CUSTOM: "Custom"
});
dropdown.setValue(this._settings.logFormat);
dropdown.onChange((value) => {
this.updateSettings(
{ logFormat: value },
true
);
});
});
if (this._settings.logFormat == "CUSTOM") {
const logTemplate = new import_obsidian2.Setting(containerEl).setName(
"Log template"
);
if (hasTemplater) {
logTemplate.addTextArea((text2) => {
text2.inputEl.style.width = "100%";
text2.inputEl.style.resize = "vertical";
text2.setPlaceholder("<% templater script goes here %>");
text2.setValue(this._settings.logTemplate);
text2.onChange((value) => {
this.updateSettings({ logTemplate: value });
});
});
} else {
logTemplate.setDesc(
createFragment((fragment) => {
const text1 = document.createElement("span");
text1.setText("Requires ");
text1.style.color = "var(--text-error)";
const a = document.createElement("a");
a.setText("Templater");
a.href = "obsidian://show-plugin?id=templater-obsidian";
const text2 = document.createElement("span");
text2.setText(
" plugin to be enabled, then click the refresh button"
);
text2.style.color = "var(--text-error)";
fragment.append(text1, a, text2);
})
).addButton((button) => {
button.setIcon("refresh-ccw");
button.onClick(() => {
this.display();
});
});
}
}
}
new import_obsidian2.Setting(containerEl).addButton((button) => {
button.setButtonText("Restore Settings");
button.onClick(() => {
this.updateSettings(_PomodoroSettings.DEFAULT_SETTINGS, true);
});
});
}
};
var PomodoroSettings = _PomodoroSettings;
PomodoroSettings.DEFAULT_SETTINGS = {
workLen: 25,
breakLen: 5,
autostart: false,
useStatusBarTimer: false,
notificationSound: true,
customSound: "",
showTaskProgress: true,
enableTaskTracking: false,
logFile: "NONE",
logFocused: false,
logPath: "",
logLevel: "ALL",
logTemplate: "",
logFormat: "VERBOSE",
useSystemNotification: false,
taskFormat: "TASKS"
};
PomodoroSettings.settings = writable(
_PomodoroSettings.DEFAULT_SETTINGS
);
// src/stores.ts
var settings = PomodoroSettings.settings;
// src/TasksComponent.svelte
var import_obsidian3 = require("obsidian");
function add_css2(target) {
append_styles(target, "svelte-1ipipwe", ".pomodoro-tasks-wrapper.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{width:100%;border:1px solid var(--background-modifier-border);border-radius:5px}.pomodoro-tasks-header-title.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{width:100%;background-color:var(--background-modifier-active-hover);padding:0.5rem 1rem;font-size:1rem;font-weight:bold;display:flex;justify-content:space-between;align-items:flex-end}.pomodoro-tasks-header-title.svelte-1ipipwe .pomodoro-tasks-file-name.svelte-1ipipwe.svelte-1ipipwe{flex:1;text-wrap:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:5px}.pomodoro-tasks-file-name.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{cursor:pointer}.pomodoro-tasks-header-title.svelte-1ipipwe .pomodoro-tasks-count.svelte-1ipipwe.svelte-1ipipwe{width:50px}.pomodoro-tasks-list.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe,.pomodoro-tasks-active.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{border-top:1px solid var(--background-modifier-border);width:100%}.pomodoro-tasks-item.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{display:flex;flex-direction:column;width:100%;padding:0.5rem 1rem;display:flex}.pomodoro-tasks-list.svelte-1ipipwe .pomodoro-tasks-item.svelte-1ipipwe.svelte-1ipipwe{cursor:pointer}.pomodoro-tasks-toolbar.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{width:100%}.pomodoro-tasks-count.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{color:var(--text-faint);font-size:0.8rem;text-wrap:nowrap}.pomodoro-tasks-filters.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{padding:0.5rem 1rem}.pomodoro-tasks-text-filter.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{border-top:1px solid var(--background-modifier-border);padding:0.5rem 0rem}.pomodoro-tasks-wrapper.svelte-1ipipwe input.svelte-1ipipwe.svelte-1ipipwe{width:100%;font-size:0.8rem;border:none;border-radius:0;background:transparent}.pomodoro-tasks-wrapper.svelte-1ipipwe input.svelte-1ipipwe.svelte-1ipipwe:active{border:none;box-shadow:none}.pomodoro-tasks-wrapper.svelte-1ipipwe input.svelte-1ipipwe.svelte-1ipipwe:focus{border:none;box-shadow:none}.pomodoro-tasks-text-filter.svelte-1ipipwe input.svelte-1ipipwe.svelte-1ipipwe{height:0.8rem}.pomodoro-tasks-filter.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{font-size:0.8rem;padding:1px 7px;border-radius:10px;cursor:pointer;color:var(--text-muted)}.pomodoro-tasks-name.svelte-1ipipwe svg.svelte-1ipipwe.svelte-1ipipwe{margin-right:5px}.pomodoro-tasks-name.svelte-1ipipwe svg.svelte-1ipipwe.svelte-1ipipwe{color:var(--color-blue)}.pomodoro-tasks-checked.svelte-1ipipwe .pomodoro-tasks-name.svelte-1ipipwe svg.svelte-1ipipwe{color:var(--color-green)}.pomodoro-tasks-name.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{width:100%;display:flex;align-items:baseline}.filter-active.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{background-color:var(--interactive-accent);color:var(--text-on-accent-inverted)}.pomodoro-tasks-item.svelte-1ipipwe+.pomodoro-tasks-item.svelte-1ipipwe.svelte-1ipipwe{border-top:1px solid var(--background-modifier-border)}.pomodoro-tasks-checked.svelte-1ipipwe .pomodoro-tasks-name.svelte-1ipipwe.svelte-1ipipwe{text-decoration:line-through;color:var(--text-muted)}.pomodoro-tasks-pin.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{cursor:pointer;padding-right:3px}.pomodoro-tasks-remove.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{cursor:pointer}.pomodoro-tasks-progress.svelte-1ipipwe.svelte-1ipipwe.svelte-1ipipwe{font-size:0.7rem;color:var(--text-muted);text-align:end;text-wrap:nowrap;overflow:hidden}");
}
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[23] = list[i];
return child_ctx;
}
function create_if_block(ctx) {
let div2;
let div1;
let div0;
let span0;
let t0;
let span1;
let t1_value = (
/*$tracker*/
ctx[6].file.name + ""
);
let t1;
let t2;
let span2;
let t3_value = (
/*filtered*/
ctx[5].length + ""
);
let t3;
let t4;
let t5;
let t6;
let current;
let mounted;
let dispose;
function select_block_type(ctx2, dirty) {
if (!/*$tracker*/
ctx2[6].pinned)
return create_if_block_5;
return create_else_block_1;
}
let current_block_type = select_block_type(ctx, -1);
let if_block0 = current_block_type(ctx);
let if_block1 = (
/*$tasks*/
ctx[4].list.length > 0 && create_if_block_3(ctx)
);
let if_block2 = (
/*filtered*/
ctx[5].length > 0 && create_if_block_1(ctx)
);
return {
c() {
div2 = element("div");
div1 = element("div");
div0 = element("div");
span0 = element("span");
if_block0.c();
t0 = space();
span1 = element("span");
t1 = text(t1_value);
t2 = space();
span2 = element("span");
t3 = text(t3_value);
t4 = text(" tasks");
t5 = space();
if (if_block1)
if_block1.c();
t6 = space();
if (if_block2)
if_block2.c();
attr(span0, "class", "pomodoro-tasks-pin svelte-1ipipwe");
attr(span1, "class", "pomodoro-tasks-file-name svelte-1ipipwe");
attr(span2, "class", "pomodoro-tasks-count svelte-1ipipwe");
attr(div0, "class", "pomodoro-tasks-header-title svelte-1ipipwe");
attr(div1, "class", "pomodoro-tasks-header");
attr(div2, "class", "pomodoro-tasks-wrapper svelte-1ipipwe");
},
m(target, anchor) {
insert(target, div2, anchor);
append(div2, div1);
append(div1, div0);
append(div0, span0);
if_block0.m(span0, null);
append(div0, t0);
append(div0, span1);
append(span1, t1);
append(div0, t2);
append(div0, span2);
append(span2, t3);
append(span2, t4);
append(div1, t5);
if (if_block1)
if_block1.m(div1, null);
append(div2, t6);
if (if_block2)
if_block2.m(div2, null);
current = true;
if (!mounted) {
dispose = [
listen(
span0,
"click",
/*togglePinned*/
ctx[9]
),
listen(
span1,
"click",
/*openFile*/
ctx[14]
)
];
mounted = true;
}
},
p(ctx2, dirty) {
if (current_block_type !== (current_block_type = select_block_type(ctx2, dirty))) {
if_block0.d(1);
if_block0 = current_block_type(ctx2);
if (if_block0) {
if_block0.c();
if_block0.m(span0, null);
}
}
if ((!current || dirty & /*$tracker*/
64) && t1_value !== (t1_value = /*$tracker*/
ctx2[6].file.name + ""))
set_data(t1, t1_value);
if ((!current || dirty & /*filtered*/
32) && t3_value !== (t3_value = /*filtered*/
ctx2[5].length + ""))
set_data(t3, t3_value);
if (
/*$tasks*/
ctx2[4].list.length > 0
) {
if (if_block1) {
if_block1.p(ctx2, dirty);
} else {
if_block1 = create_if_block_3(ctx2);
if_block1.c();
if_block1.m(div1, null);
}
} else if (if_block1) {
if_block1.d(1);
if_block1 = null;
}
if (
/*filtered*/
ctx2[5].length > 0
) {
if (if_block2) {
if_block2.p(ctx2, dirty);
if (dirty & /*filtered*/
32) {
transition_in(if_block2, 1);
}
} else {
if_block2 = create_if_block_1(ctx2);
if_block2.c();
transition_in(if_block2, 1);
if_block2.m(div2, null);
}
} else if (if_block2) {
group_outros();
transition_out(if_block2, 1, 1, () => {
if_block2 = null;
});
check_outros();
}
},
i(local) {
if (current)
return;
transition_in(if_block2);
current = true;
},
o(local) {
transition_out(if_block2);
current = false;
},
d(detaching) {
if (detaching) {
detach(div2);
}
if_block0.d();
if (if_block1)
if_block1.d();
if (if_block2)
if_block2.d();
mounted = false;
run_all(dispose);
}
};
}
function create_else_block_1(ctx) {
let svg;
let line0;
let line1;
let path0;
let path1;
return {
c() {
svg = svg_element("svg");
line0 = svg_element("line");
line1 = svg_element("line");
path0 = svg_element("path");
path1 = svg_element("path");
attr(line0, "x1", "2");
attr(line0, "x2", "22");
attr(line0, "y1", "2");
attr(line0, "y2", "22");
attr(line1, "x1", "12");
attr(line1, "x2", "12");
attr(line1, "y1", "17");
attr(line1, "y2", "22");
attr(path0, "d", "M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h12");
attr(path1, "d", "M15 9.34V6h1a2 2 0 0 0 0-4H7.89");
attr(svg, "xmlns", "http://www.w3.org/2000/svg");
attr(svg, "width", "12");
attr(svg, "height", "12");
attr(svg, "viewBox", "0 0 24 24");
attr(svg, "fill", "none");
attr(svg, "stroke", "currentColor");
attr(svg, "stroke-width", "2");
attr(svg, "stroke-linecap", "round");
attr(svg, "stroke-linejoin", "round");
attr(svg, "class", "lucide lucide-pin-off");
},
m(target, anchor) {
insert(target, svg, anchor);
append(svg, line0);
append(svg, line1);
append(svg, path0);
append(svg, path1);
},
d(detaching) {
if (detaching) {
detach(svg);
}
}
};
}
function create_if_block_5(ctx) {
let svg;
let line;
let path;
return {
c() {
svg = svg_element("svg");
line = svg_element("line");
path = svg_element("path");
attr(line, "x1", "12");
attr(line, "x2", "12");
attr(line, "y1", "17");
attr(line, "y2", "22");
attr(path, "d", "M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z");
attr(svg, "xmlns", "http://www.w3.org/2000/svg");
attr(svg, "width", "12");
attr(svg, "height", "12");
attr(svg, "viewBox", "0 0 24 24");
attr(svg, "fill", "none");
attr(svg, "stroke", "currentColor");
attr(svg, "stroke-width", "2");
attr(svg, "stroke-linecap", "round");
attr(svg, "stroke-linejoin", "round");
attr(svg, "class", "lucide lucide-pin");
},
m(target, anchor) {
insert(target, svg, anchor);
append(svg, line);
append(svg, path);
},
d(detaching) {
if (detaching) {
detach(svg);
}
}
};
}
function create_if_block_3(ctx) {
let div0;
let t0;
let div2;
let div1;
let span0;
let t1;
let span0_class_value;
let t2;
let span1;
let t3;
let span1_class_value;
let t4;
let span2;
let t5;
let span2_class_value;
let t6;
let div3;
let input;
let mounted;
let dispose;
let if_block = (
/*$tracker*/
ctx[6].task && create_if_block_4(ctx)
);
return {
c() {
div0 = element("div");
if (if_block)
if_block.c();
t0 = space();
div2 = element("div");
div1 = element("div");
span0 = element("span");
t1 = text("All");
t2 = space();
span1 = element("span");
t3 = text("Todo");
t4 = space();
span2 = element("span");
t5 = text("Completed");
t6 = space();
div3 = element("div");
input = element("input");
attr(div0, "class", "pomodoro-tasks-active svelte-1ipipwe");
attr(span0, "class", span0_class_value = "pomodoro-tasks-filter " + /*status*/
(ctx[2] === "" ? "filter-active" : "") + " svelte-1ipipwe");
attr(span1, "class", span1_class_value = "pomodoro-tasks-filter " + /*status*/
(ctx[2] === "todo" ? "filter-active" : "") + " svelte-1ipipwe");
attr(span2, "class", span2_class_value = "pomodoro-tasks-filter " + /*status*/
(ctx[2] === "completed" ? "filter-active" : "") + " svelte-1ipipwe");
attr(div1, "class", "pomodoro-tasks-filters svelte-1ipipwe");
attr(div2, "class", "pomodoro-tasks-toolbar svelte-1ipipwe");
attr(input, "type", "text");
attr(input, "placeholder", "Search...");
attr(input, "class", "svelte-1ipipwe");
attr(div3, "class", "pomodoro-tasks-text-filter svelte-1ipipwe");
},
m(target, anchor) {
insert(target, div0, anchor);
if (if_block)
if_block.m(div0, null);
insert(target, t0, anchor);
insert(target, div2, anchor);
append(div2, div1);
append(div1, span0);
append(span0, t1);
append(div1, t2);
append(div1, span1);
append(span1, t3);
append(div1, t4);
append(div1, span2);
append(span2, t5);
insert(target, t6, anchor);
insert(target, div3, anchor);
append(div3, input);
set_input_value(
input,
/*query*/
ctx[3]
);
if (!mounted) {
dispose = [
listen(
span0,
"click",
/*click_handler*/
ctx[17]
),
listen(
span1,
"click",
/*click_handler_1*/
ctx[18]
),
listen(
span2,
"click",
/*click_handler_2*/
ctx[19]
),
listen(
input,
"input",
/*input_input_handler*/
ctx[20]
)
];
mounted = true;
}
},
p(ctx2, dirty) {
if (
/*$tracker*/
ctx2[6].task
) {
if (if_block) {
if_block.p(ctx2, dirty);
} else {
if_block = create_if_block_4(ctx2);
if_block.c();
if_block.m(div0, null);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
if (dirty & /*status*/
4 && span0_class_value !== (span0_class_value = "pomodoro-tasks-filter " + /*status*/
(ctx2[2] === "" ? "filter-active" : "") + " svelte-1ipipwe")) {
attr(span0, "class", span0_class_value);
}
if (dirty & /*status*/
4 && span1_class_value !== (span1_class_value = "pomodoro-tasks-filter " + /*status*/
(ctx2[2] === "todo" ? "filter-active" : "") + " svelte-1ipipwe")) {
attr(span1, "class", span1_class_value);
}
if (dirty & /*status*/
4 && span2_class_value !== (span2_class_value = "pomodoro-tasks-filter " + /*status*/
(ctx2[2] === "completed" ? "filter-active" : "") + " svelte-1ipipwe")) {
attr(span2, "class", span2_class_value);
}
if (dirty & /*query*/
8 && input.value !== /*query*/
ctx2[3]) {
set_input_value(
input,
/*query*/
ctx2[3]
);
}
},
d(detaching) {
if (detaching) {
detach(div0);
detach(t0);
detach(div2);
detach(t6);
detach(div3);
}
if (if_block)
if_block.d();
mounted = false;
run_all(dispose);
}
};
}
function create_if_block_4(ctx) {
let div1;
let div0;
let input;
let input_value_value;
let t;
let span;
let mounted;
let dispose;
return {
c() {
var _a;
div1 = element("div");
div0 = element("div");
input = element("input");
t = space();
span = element("span");
span.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x svelte-1ipipwe"><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg>`;
attr(input, "type", "text");
input.value = input_value_value = /*$tracker*/
(_a = ctx[6].task) == null ? void 0 : _a.name;
attr(input, "class", "svelte-1ipipwe");
attr(span, "class", "pomodoro-tasks-remove svelte-1ipipwe");
attr(div0, "class", "pomodoro-tasks-name svelte-1ipipwe");
attr(div1, "class", "pomodoro-tasks-item svelte-1ipipwe");
},
m(target, anchor) {
insert(target, div1, anchor);
append(div1, div0);
append(div0, input);
append(div0, t);
append(div0, span);
if (!mounted) {
dispose = [
listen(
input,
"input",
/*changeTaskName*/
ctx[10]
),
listen(
span,
"click",
/*removeTask*/
ctx[11]
)
];
mounted = true;
}
},
p(ctx2, dirty) {
var _a;
if (dirty & /*$tracker*/
64 && input_value_value !== (input_value_value = /*$tracker*/
(_a = ctx2[6].task) == null ? void 0 : _a.name) && input.value !== input_value_value) {
input.value = input_value_value;
}
},
d(detaching) {
if (detaching) {
detach(div1);
}
mounted = false;
run_all(dispose);
}
};
}
function create_if_block_1(ctx) {
let div;
let current;
let each_value = ensure_array_like(
/*filtered*/
ctx[5]
);
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
}
const out = (i) => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
return {
c() {
div = element("div");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr(div, "class", "pomodoro-tasks-list svelte-1ipipwe");
},
m(target, anchor) {
insert(target, div, anchor);
for (let i = 0; i < each_blocks.length; i += 1) {
if (each_blocks[i]) {
each_blocks[i].m(div, null);
}
}
current = true;
},
p(ctx2, dirty) {
if (dirty & /*progress, filtered, activeTask, showTaskMenu, progressText, r*/
45472) {
each_value = ensure_array_like(
/*filtered*/
ctx2[5]
);
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx2, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(div, null);
}
}
group_outros();
for (i = each_value.length; i < each_blocks.length; i += 1) {
out(i);
}
check_outros();
}
},
i(local) {
if (current)
return;
for (let i = 0; i < each_value.length; i += 1) {
transition_in(each_blocks[i]);
}
current = true;
},
o(local) {
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
current = false;
},
d(detaching) {
if (detaching) {
detach(div);
}
destroy_each(each_blocks, detaching);
}
};
}
function create_else_block(ctx) {
let svg;
let circle;
return {
c() {
svg = svg_element("svg");
circle = svg_element("circle");
attr(circle, "cx", "12");
attr(circle, "cy", "12");
attr(circle, "r", "10");
attr(svg, "xmlns", "http://www.w3.org/2000/svg");
attr(svg, "width", "12");
attr(svg, "height", "12");
attr(svg, "viewBox", "0 0 24 24");
attr(svg, "fill", "none");
attr(svg, "stroke", "currentColor");
attr(svg, "stroke-width", "2");
attr(svg, "stroke-linecap", "round");
attr(svg, "stroke-linejoin", "round");
attr(svg, "class", "lucide lucide-circle svelte-1ipipwe");
},
m(target, anchor) {
insert(target, svg, anchor);
append(svg, circle);
},
d(detaching) {
if (detaching) {
detach(svg);
}
}
};
}
function create_if_block_2(ctx) {
let svg;
let path;
return {
c() {
svg = svg_element("svg");
path = svg_element("path");
attr(path, "d", "M20 6 9 17l-5-5");
attr(svg, "xmlns", "http://www.w3.org/2000/svg");
attr(svg, "width", "12");
attr(svg, "height", "12");
attr(svg, "viewBox", "0 0 24 24");
attr(svg, "fill", "none");
attr(svg, "stroke", "currentColor");
attr(svg, "stroke-width", "2");
attr(svg, "stroke-linecap", "round");
attr(svg, "stroke-linejoin", "round");
attr(svg, "class", "lucide lucide-check svelte-1ipipwe");
},
m(target, anchor) {
insert(target, svg, anchor);
append(svg, path);
},
d(detaching) {
if (detaching) {
detach(svg);
}
}
};
}
function create_each_block(ctx) {
let div2;
let div0;
let t0;
let taskitemcomponent;
let t1;
let div1;
let t2_value = (
/*progressText*/
ctx[13](
/*item*/
ctx[23]
) + ""
);
let t2;
let t3;
let div2_class_value;
let current;
let mounted;
let dispose;
function select_block_type_1(ctx2, dirty) {
if (
/*item*/
ctx2[23].checked
)
return create_if_block_2;
return create_else_block;
}
let current_block_type = select_block_type_1(ctx, -1);
let if_block = current_block_type(ctx);
taskitemcomponent = new TaskItemComponent_default({
props: {
render: (
/*r*/
ctx[7]
),
content: (
/*item*/
ctx[23].description
)
}
});
function click_handler_3() {
return (
/*click_handler_3*/
ctx[21](
/*item*/
ctx[23]
)
);
}
return {
c() {
div2 = element("div");
div0 = element("div");
if_block.c();
t0 = space();
create_component(taskitemcomponent.$$.fragment);
t1 = space();
div1 = element("div");
t2 = text(t2_value);
t3 = space();
attr(div0, "class", "pomodoro-tasks-name svelte-1ipipwe");
attr(div1, "class", "pomodoro-tasks-progress svelte-1ipipwe");
set_style(div2, "background", "linear-gradient(to right, rgba(var(--color-green-rgb),0.25) " + /*progress*/
ctx[12](
/*item*/
ctx[23]
) + "%, transparent 0%)");
attr(div2, "class", div2_class_value = "pomodoro-tasks-item " + /*item*/
(ctx[23].checked ? "pomodoro-tasks-checked" : "") + " svelte-1ipipwe");
},
m(target, anchor) {
insert(target, div2, anchor);
append(div2, div0);
if_block.m(div0, null);
append(div0, t0);
mount_component(taskitemcomponent, div0, null);
append(div2, t1);
append(div2, div1);
append(div1, t2);
append(div2, t3);
current = true;
if (!mounted) {
dispose = [
listen(div2, "click", click_handler_3),
listen(div2, "contextmenu", function() {
if (is_function(
/*showTaskMenu*/
ctx[15](
/*item*/
ctx[23]
)
))
ctx[15](
/*item*/
ctx[23]
).apply(this, arguments);
})
];
mounted = true;
}
},
p(new_ctx, dirty) {
ctx = new_ctx;
if (current_block_type !== (current_block_type = select_block_type_1(ctx, dirty))) {
if_block.d(1);
if_block = current_block_type(ctx);
if (if_block) {
if_block.c();
if_block.m(div0, t0);
}
}
const taskitemcomponent_changes = {};
if (dirty & /*filtered*/
32)
taskitemcomponent_changes.content = /*item*/
ctx[23].description;
taskitemcomponent.$set(taskitemcomponent_changes);
if ((!current || dirty & /*filtered*/
32) && t2_value !== (t2_value = /*progressText*/
ctx[13](
/*item*/
ctx[23]
) + ""))
set_data(t2, t2_value);
if (!current || dirty & /*filtered*/
32) {
set_style(div2, "background", "linear-gradient(to right, rgba(var(--color-green-rgb),0.25) " + /*progress*/
ctx[12](
/*item*/
ctx[23]
) + "%, transparent 0%)");
}
if (!current || dirty & /*filtered*/
32 && div2_class_value !== (div2_class_value = "pomodoro-tasks-item " + /*item*/
(ctx[23].checked ? "pomodoro-tasks-checked" : "") + " svelte-1ipipwe")) {
attr(div2, "class", div2_class_value);
}
},
i(local) {
if (current)
return;
transition_in(taskitemcomponent.$$.fragment, local);
current = true;
},
o(local) {
transition_out(taskitemcomponent.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching) {
detach(div2);
}
if_block.d();
destroy_component(taskitemcomponent);
mounted = false;
run_all(dispose);
}
};
}
function create_fragment2(ctx) {
let if_block_anchor;
let current;
let if_block = (
/*$tracker*/
ctx[6].file && create_if_block(ctx)
);
return {
c() {
if (if_block)
if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
if (if_block)
if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
},
p(ctx2, [dirty]) {
if (
/*$tracker*/
ctx2[6].file
) {
if (if_block) {
if_block.p(ctx2, dirty);
if (dirty & /*$tracker*/
64) {
transition_in(if_block, 1);
}
} else {
if_block = create_if_block(ctx2);
if_block.c();
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
group_outros();
transition_out(if_block, 1, 1, () => {
if_block = null;
});
check_outros();
}
},
i(local) {
if (current)
return;
transition_in(if_block);
current = true;
},
o(local) {
transition_out(if_block);
current = false;
},
d(detaching) {
if (detaching) {
detach(if_block_anchor);
}
if (if_block)
if_block.d(detaching);
}
};
}
function instance2($$self, $$props, $$invalidate) {
let filtered;
let $settings;
let $tasks, $$unsubscribe_tasks = noop, $$subscribe_tasks = () => ($$unsubscribe_tasks(), $$unsubscribe_tasks = subscribe(tasks, ($$value) => $$invalidate(4, $tasks = $$value)), tasks);
let $tracker, $$unsubscribe_tracker = noop, $$subscribe_tracker = () => ($$unsubscribe_tracker(), $$unsubscribe_tracker = subscribe(tracker, ($$value) => $$invalidate(6, $tracker = $$value)), tracker);
component_subscribe($$self, settings, ($$value) => $$invalidate(22, $settings = $$value));
$$self.$$.on_destroy.push(() => $$unsubscribe_tasks());
$$self.$$.on_destroy.push(() => $$unsubscribe_tracker());
let { tasks } = $$props;
$$subscribe_tasks();
let { tracker } = $$props;
$$subscribe_tracker();
let { render } = $$props;
const r = (content, el) => {
render(content, el);
};
let status = "";
let query = "";
const activeTask = (task) => {
tracker.active(task);
};
const togglePinned = () => {
tracker.togglePinned();
};
const changeTaskName = (e) => {
let target = e.target;
tracker.setTaskName(target.value);
};
const removeTask = () => {
tracker.clear();
};
const progress = (item) => {
if (!$settings.showTaskProgress) {
return 0;
}
if (item.expected > 0 && item.actual >= 0) {
return (item.actual / item.expected * 100).toFixed(2);
}
return 0;
};
const progressText = (item) => {
let { actual, expected } = item;
if (expected > 0) {
let unfinished = expected - actual;
let max = Math.max(expected, actual);
if (max > 10) {
if (unfinished > 0) {
return `\u25CC x ${unfinished} \u{1F345} x ${actual}`;
} else {
return `\u{1F345} x ${expected} \u{1F96B} x ${Math.abs(unfinished)}`;
}
} else {
if (unfinished > 0) {
return `${"\u{1F345}".repeat(actual)}${"\u25CC".repeat(unfinished)}`;
} else {
return `${"\u{1F345}".repeat(expected)}${"\u{1F96B}".repeat(Math.abs(unfinished))}`;
}
}
} else {
return actual > 10 ? `\u{1F345} x ${actual}` : actual > 0 ? `${"\u{1F345}".repeat(actual)}` : `- -`;
}
};
const openFile = (e) => {
tracker.openFile(e);
};
const showTaskMenu = (task) => (e) => {
const menu = new import_obsidian3.Menu();
menu.addItem((item) => {
item.setTitle("Open").onClick(() => {
tracker.openTask(e, task);
});
});
menu.showAtMouseEvent(e);
};
const click_handler = () => $$invalidate(2, status = "");
const click_handler_1 = () => $$invalidate(2, status = "todo");
const click_handler_2 = () => $$invalidate(2, status = "completed");
function input_input_handler() {
query = this.value;
$$invalidate(3, query);
}
const click_handler_3 = (item) => {
activeTask(item);
};
$$self.$$set = ($$props2) => {
if ("tasks" in $$props2)
$$subscribe_tasks($$invalidate(0, tasks = $$props2.tasks));
if ("tracker" in $$props2)
$$subscribe_tracker($$invalidate(1, tracker = $$props2.tracker));
if ("render" in $$props2)
$$invalidate(16, render = $$props2.render);
};
$$self.$$.update = () => {
if ($$self.$$.dirty & /*$tasks, query, status*/
28) {
$:
$$invalidate(5, filtered = $tasks ? $tasks.list.filter((item) => {
let statusMatch = true;
let textMatch = true;
if (query) {
textMatch = item.name.toLowerCase().includes(query.toLowerCase());
}
if (status) {
if (status === "todo")
statusMatch = !item.checked;
if (status === "completed")
statusMatch = item.checked;
}
return statusMatch && textMatch;
}) : []);
}
};
return [
tasks,
tracker,
status,
query,
$tasks,
filtered,
$tracker,
r,
activeTask,
togglePinned,
changeTaskName,
removeTask,
progress,
progressText,
openFile,
showTaskMenu,
render,
click_handler,
click_handler_1,
click_handler_2,
input_input_handler,
click_handler_3
];
}
var TasksComponent = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance2, create_fragment2, safe_not_equal, { tasks: 0, tracker: 1, render: 16 }, add_css2);
}
};
var TasksComponent_default = TasksComponent;
// src/TimerSettingsComponent.svelte
function add_css3(target) {
append_styles(target, "svelte-5jyrhn", ".pomodoro-settings-wrapper.svelte-5jyrhn.svelte-5jyrhn,.pomodoro-settings-list.svelte-5jyrhn.svelte-5jyrhn,.pomodoro-settings-item.svelte-5jyrhn.svelte-5jyrhn{width:100%}.pomodoro-settings-wrapper.svelte-5jyrhn.svelte-5jyrhn{border:1px solid var(--background-modifier-border);border-radius:5px}.pomodoro-settings-item.svelte-5jyrhn.svelte-5jyrhn{display:flex;font-size:0.8rem;align-items:center;justify-content:space-between;height:2rem;padding:0.5rem 1rem}.pomodoro-settings-item.svelte-5jyrhn+.pomodoro-settings-item.svelte-5jyrhn{border-top:1px solid var(--background-modifier-border)}.pomodoro-settings-item.svelte-5jyrhn input[type='number'].svelte-5jyrhn{font-size:0.8rem;border:none;border-radius:0;height:0.8rem;text-align:end;background:transparent}.pomodoro-settings-item.svelte-5jyrhn input[type='number'].svelte-5jyrhn:active{border:none;box-shadow:none}.pomodoro-settings-item.svelte-5jyrhn input[type='number'].svelte-5jyrhn:focus{border:none;box-shadow:none}");
}
function create_fragment3(ctx) {
let div16;
let div15;
let div2;
let div0;
let t1;
let div1;
let input0;
let input0_value_value;
let t2;
let div5;
let div3;
let t4;
let div4;
let input1;
let input1_value_value;
let t5;
let div8;
let div6;
let t7;
let div7;
let input2;
let t8;
let div11;
let div9;
let t10;
let div10;
let input3;
let t11;
let div14;
let div12;
let t13;
let div13;
let input4;
let mounted;
let dispose;
return {
c() {
div16 = element("div");
div15 = element("div");
div2 = element("div");
div0 = element("div");
div0.textContent = "Work";
t1 = space();
div1 = element("div");
input0 = element("input");
t2 = space();
div5 = element("div");
div3 = element("div");
div3.textContent = "Break";
t4 = space();
div4 = element("div");
input1 = element("input");
t5 = space();
div8 = element("div");
div6 = element("div");
div6.textContent = "Auto-start";
t7 = space();
div7 = element("div");
input2 = element("input");
t8 = space();
div11 = element("div");
div9 = element("div");
div9.textContent = "Notification Sound";
t10 = space();
div10 = element("div");
input3 = element("input");
t11 = space();
div14 = element("div");
div12 = element("div");
div12.textContent = "Prefer Saving to Task File";
t13 = space();
div13 = element("div");
input4 = element("input");
attr(div0, "class", "pomodoro-settings-label");
input0.value = input0_value_value = /*$settings*/
ctx[0].workLen;
attr(input0, "min", "1");
attr(input0, "type", "number");
attr(input0, "class", "svelte-5jyrhn");
attr(div1, "class", "pomodoro-settings-control");
attr(div2, "class", "pomodoro-settings-item svelte-5jyrhn");
attr(div3, "class", "pomodoro-settings-label");
input1.value = input1_value_value = /*$settings*/
ctx[0].breakLen;
attr(input1, "min", "0");
attr(input1, "type", "number");
attr(input1, "class", "svelte-5jyrhn");
attr(div4, "class", "pomodoro-settings-control");
attr(div5, "class", "pomodoro-settings-item svelte-5jyrhn");
attr(div6, "class", "pomodoro-settings-label");
attr(input2, "type", "checkbox");
attr(div7, "class", "pomodoro-settings-control");
attr(div8, "class", "pomodoro-settings-item svelte-5jyrhn");
attr(div9, "class", "pomodoro-settings-label");
attr(input3, "type", "checkbox");
attr(div10, "class", "pomodoro-settings-control");
attr(div11, "class", "pomodoro-settings-item svelte-5jyrhn");
attr(div12, "class", "pomodoro-settings-label");
attr(input4, "type", "checkbox");
attr(div13, "class", "pomodoro-settings-control");
attr(div14, "class", "pomodoro-settings-item svelte-5jyrhn");
attr(div15, "class", "pomodoro-settings-list svelte-5jyrhn");
attr(div16, "class", "pomodoro-settings-wrapper svelte-5jyrhn");
},
m(target, anchor) {
insert(target, div16, anchor);
append(div16, div15);
append(div15, div2);
append(div2, div0);
append(div2, t1);
append(div2, div1);
append(div1, input0);
append(div15, t2);
append(div15, div5);
append(div5, div3);
append(div5, t4);
append(div5, div4);
append(div4, input1);
append(div15, t5);
append(div15, div8);
append(div8, div6);
append(div8, t7);
append(div8, div7);
append(div7, input2);
input2.checked = /*$settings*/
ctx[0].autostart;
append(div15, t8);
append(div15, div11);
append(div11, div9);
append(div11, t10);
append(div11, div10);
append(div10, input3);
input3.checked = /*$settings*/
ctx[0].notificationSound;
append(div15, t11);
append(div15, div14);
append(div14, div12);
append(div14, t13);
append(div14, div13);
append(div13, input4);
input4.checked = /*$settings*/
ctx[0].logFocused;
if (!mounted) {
dispose = [
listen(
input0,
"change",
/*updateWorkLen*/
ctx[1]
),
listen(
input1,
"change",
/*updateBreakLen*/
ctx[2]
),
listen(
input2,
"change",
/*input2_change_handler*/
ctx[3]
),
listen(
input3,
"change",
/*input3_change_handler*/
ctx[4]
),
listen(
input4,
"change",
/*input4_change_handler*/
ctx[5]
)
];
mounted = true;
}
},
p(ctx2, [dirty]) {
if (dirty & /*$settings*/
1 && input0_value_value !== (input0_value_value = /*$settings*/
ctx2[0].workLen) && input0.value !== input0_value_value) {
input0.value = input0_value_value;
}
if (dirty & /*$settings*/
1 && input1_value_value !== (input1_value_value = /*$settings*/
ctx2[0].breakLen) && input1.value !== input1_value_value) {
input1.value = input1_value_value;
}
if (dirty & /*$settings*/
1) {
input2.checked = /*$settings*/
ctx2[0].autostart;
}
if (dirty & /*$settings*/
1) {
input3.checked = /*$settings*/
ctx2[0].notificationSound;
}
if (dirty & /*$settings*/
1) {
input4.checked = /*$settings*/
ctx2[0].logFocused;
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching) {
detach(div16);
}
mounted = false;
run_all(dispose);
}
};
}
function instance3($$self, $$props, $$invalidate) {
let $settings;
component_subscribe($$self, settings, ($$value) => $$invalidate(0, $settings = $$value));
const updateWorkLen = (e) => {
const target = e.target;
const value = parseInt(target.value);
settings.update((s) => {
if (value >= 1) {
s.workLen = value;
}
target.value = s.workLen.toString();
return s;
});
};
const updateBreakLen = (e) => {
const target = e.target;
const value = parseInt(target.value);
settings.update((s) => {
if (value >= 0) {
s.breakLen = value;
}
target.value = s.workLen.toString();
return s;
});
};
function input2_change_handler() {
$settings.autostart = this.checked;
settings.set($settings);
}
function input3_change_handler() {
$settings.notificationSound = this.checked;
settings.set($settings);
}
function input4_change_handler() {
$settings.logFocused = this.checked;
settings.set($settings);
}
return [
$settings,
updateWorkLen,
updateBreakLen,
input2_change_handler,
input3_change_handler,
input4_change_handler
];
}
var TimerSettingsComponent = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance3, create_fragment3, safe_not_equal, {}, add_css3);
}
};
var TimerSettingsComponent_default = TimerSettingsComponent;
// src/TimerViewComponent.svelte
function add_css4(target) {
append_styles(target, "svelte-1bkzjfd", ".container.svelte-1bkzjfd.svelte-1bkzjfd{width:100%;min-width:200px;display:flex;flex-direction:column;height:100%}.main.svelte-1bkzjfd.svelte-1bkzjfd{width:100%;display:flex;flex-direction:column;align-items:center;z-index:2}.timer.svelte-1bkzjfd.svelte-1bkzjfd{position:relative;width:160px;height:160px}.timer.svelte-1bkzjfd svg.svelte-1bkzjfd{-webkit-transform:rotate(-90deg);transform:rotate(-90deg);z-index:3}.timer-display.svelte-1bkzjfd.svelte-1bkzjfd{position:absolute;width:100%;height:160px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;z-index:4;padding:30px}.timer-text.svelte-1bkzjfd.svelte-1bkzjfd{display:block;color:var(--pomodoro-timer-text-color);font-size:1.1em;font-weight:bold;margin-block-start:1rem;margin-block-end:1.75rem}.status.svelte-1bkzjfd.svelte-1bkzjfd{font-size:0.7rem;display:flex;align-items:center}.status.svelte-1bkzjfd span.svelte-1bkzjfd{display:inline-block}.circle_timer.svelte-1bkzjfd.svelte-1bkzjfd{stroke:var(--pomodoro-timer-color)}.circle_animation.svelte-1bkzjfd.svelte-1bkzjfd{stroke-dasharray:440;stroke-dashoffset:440;stroke:var(--pomodoro-timer-elapsed-color)}.btn-group.svelte-1bkzjfd.svelte-1bkzjfd{margin-top:1rem;display:flex;justify-content:space-between;width:160px}.control.svelte-1bkzjfd.svelte-1bkzjfd{cursor:pointer}.control.svelte-1bkzjfd.svelte-1bkzjfd:hover{opacity:0.7}.control.svelte-1bkzjfd svg.svelte-1bkzjfd:active{opacity:0.5}.pomodoro-extra.svelte-1bkzjfd.svelte-1bkzjfd{width:100%;margin-top:2rem}.breath.svelte-1bkzjfd.svelte-1bkzjfd{width:5px;height:5px;margin-top:5px;display:inline-block;position:absolute;left:55px;background-color:var(--pomodoro-timer-dot-color);border-radius:5px;transform:translate(-50%, -50%);animation:svelte-1bkzjfd-blink 1s linear infinite}@keyframes svelte-1bkzjfd-blink{0%,100%{opacity:1}50%{opacity:0}}");
}
function create_if_block_42(ctx) {
let span;
return {
c() {
span = element("span");
attr(span, "class", "breath svelte-1bkzjfd");
},
m(target, anchor) {
insert(target, span, anchor);
},
d(detaching) {
if (detaching) {
detach(span);
}
}
};
}
function create_else_block_12(ctx) {
let span;
return {
c() {
span = element("span");
span.textContent = "Break";
attr(span, "class", "mode svelte-1bkzjfd");
},
m(target, anchor) {
insert(target, span, anchor);
},
d(detaching) {
if (detaching) {
detach(span);
}
}
};
}
function create_if_block_32(ctx) {
let span;
return {
c() {
span = element("span");
span.textContent = "Work";
attr(span, "class", "mode svelte-1bkzjfd");
},
m(target, anchor) {
insert(target, span, anchor);
},
d(detaching) {
if (detaching) {
detach(span);
}
}
};
}
function create_else_block2(ctx) {
let span;
let mounted;
let dispose;
return {
c() {
span = element("span");
span.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pause svelte-1bkzjfd"><rect width="4" height="16" x="6" y="4"></rect><rect width="4" height="16" x="14" y="4"></rect></svg>`;
attr(span, "class", "control svelte-1bkzjfd");
},
m(target, anchor) {
insert(target, span, anchor);
if (!mounted) {
dispose = listen(
span,
"click",
/*pause*/
ctx[9]
);
mounted = true;
}
},
p: noop,
d(detaching) {
if (detaching) {
detach(span);
}
mounted = false;
dispose();
}
};
}
function create_if_block_22(ctx) {
let span;
let mounted;
let dispose;
return {
c() {
span = element("span");
span.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-play svelte-1bkzjfd"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>`;
attr(span, "class", "control svelte-1bkzjfd");
},
m(target, anchor) {
insert(target, span, anchor);
if (!mounted) {
dispose = listen(
span,
"click",
/*start*/
ctx[7]
);
mounted = true;
}
},
p: noop,
d(detaching) {
if (detaching) {
detach(span);
}
mounted = false;
dispose();
}
};
}
function create_if_block_12(ctx) {
let timersettingscomponent;
let current;
timersettingscomponent = new TimerSettingsComponent_default({});
return {
c() {
create_component(timersettingscomponent.$$.fragment);
},
m(target, anchor) {
mount_component(timersettingscomponent, target, anchor);
current = true;
},
p: noop,
i(local) {
if (current)
return;
transition_in(timersettingscomponent.$$.fragment, local);
current = true;
},
o(local) {
transition_out(timersettingscomponent.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(timersettingscomponent, detaching);
}
};
}
function create_if_block2(ctx) {
let taskscomponent;
let current;
taskscomponent = new TasksComponent_default({
props: {
tasks: (
/*tasks*/
ctx[1]
),
tracker: (
/*tracker*/
ctx[2]
),
render: (
/*render*/
ctx[3]
)
}
});
return {
c() {
create_component(taskscomponent.$$.fragment);
},
m(target, anchor) {
mount_component(taskscomponent, target, anchor);
current = true;
},
p(ctx2, dirty) {
const taskscomponent_changes = {};
if (dirty & /*tasks*/
2)
taskscomponent_changes.tasks = /*tasks*/
ctx2[1];
if (dirty & /*tracker*/
4)
taskscomponent_changes.tracker = /*tracker*/
ctx2[2];
if (dirty & /*render*/
8)
taskscomponent_changes.render = /*render*/
ctx2[3];
taskscomponent.$set(taskscomponent_changes);
},
i(local) {
if (current)
return;
transition_in(taskscomponent.$$.fragment, local);
current = true;
},
o(local) {
transition_out(taskscomponent.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(taskscomponent, detaching);
}
};
}
function create_fragment4(ctx) {
let div7;
let div5;
let div3;
let div2;
let div0;
let t0;
let t1;
let span0;
let div0_class_value;
let t2;
let div1;
let span1;
let t3_value = (
/*$timer*/
ctx[4].remained.human + ""
);
let t3;
let t4;
let svg0;
let g;
let circle0;
let circle1;
let t5;
let div4;
let span2;
let t6;
let t7;
let span3;
let t8;
let span4;
let t9;
let div6;
let current_block_type_index;
let if_block3;
let current;
let mounted;
let dispose;
let if_block0 = (
/*$timer*/
ctx[4].running && create_if_block_42(ctx)
);
function select_block_type(ctx2, dirty) {
if (
/*$timer*/
ctx2[4].mode === "WORK"
)
return create_if_block_32;
return create_else_block_12;
}
let current_block_type = select_block_type(ctx, -1);
let if_block1 = current_block_type(ctx);
function select_block_type_1(ctx2, dirty) {
if (!/*$timer*/
ctx2[4].running)
return create_if_block_22;
return create_else_block2;
}
let current_block_type_1 = select_block_type_1(ctx, -1);
let if_block2 = current_block_type_1(ctx);
const if_block_creators = [create_if_block2, create_if_block_12];
const if_blocks = [];
function select_block_type_2(ctx2, dirty) {
if (
/*extra*/
ctx2[5] == "tasks"
)
return 0;
if (
/*extra*/
ctx2[5] == "settings"
)
return 1;
return -1;
}
if (~(current_block_type_index = select_block_type_2(ctx, -1))) {
if_block3 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
}
return {
c() {
div7 = element("div");
div5 = element("div");
div3 = element("div");
div2 = element("div");
div0 = element("div");
if (if_block0)
if_block0.c();
t0 = space();
if_block1.c();
t1 = space();
span0 = element("span");
t2 = space();
div1 = element("div");
span1 = element("span");
t3 = text(t3_value);
t4 = space();
svg0 = svg_element("svg");
g = svg_element("g");
circle0 = svg_element("circle");
circle1 = svg_element("circle");
t5 = space();
div4 = element("div");
span2 = element("span");
span2.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-list-todo svelte-1bkzjfd"><rect x="3" y="5" width="6" height="6" rx="1"></rect><path d="m3 17 2 2 4-4"></path><path d="M13 6h8"></path><path d="M13 12h8"></path><path d="M13 18h8"></path></svg>`;
t6 = space();
if_block2.c();
t7 = space();
span3 = element("span");
span3.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rotate-ccw svelte-1bkzjfd"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"></path><path d="M3 3v5h5"></path></svg>`;
t8 = space();
span4 = element("span");
span4.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-settings-2 svelte-1bkzjfd"><path d="M20 7h-9"></path><path d="M14 17H5"></path><circle cx="17" cy="17" r="3"></circle><circle cx="7" cy="7" r="3"></circle></svg>`;
t9 = space();
div6 = element("div");
if (if_block3)
if_block3.c();
attr(span0, "class", "svelte-1bkzjfd");
attr(div0, "class", div0_class_value = "status " + /*$timer*/
(ctx[4].inSession ? "" : "control") + " svelte-1bkzjfd");
attr(span1, "class", "timer-text svelte-1bkzjfd");
attr(div1, "class", "control svelte-1bkzjfd");
attr(div2, "class", "timer-display svelte-1bkzjfd");
attr(circle0, "class", "circle_timer svelte-1bkzjfd");
attr(circle0, "r", "69.85699");
attr(circle0, "cy", "81");
attr(circle0, "cx", "81");
attr(circle0, "stroke-width", "2");
attr(circle0, "fill", "none");
attr(circle1, "class", "circle_animation svelte-1bkzjfd");
attr(circle1, "r", "69.85699");
attr(circle1, "cy", "81");
attr(circle1, "cx", "81");
attr(circle1, "stroke-width", "8");
attr(circle1, "fill", "none");
set_style(
circle1,
"stroke-dashoffset",
/*strokeOffset*/
ctx[6]
);
attr(svg0, "class", "timer svelte-1bkzjfd");
attr(svg0, "width", "160");
attr(svg0, "height", "160");
attr(svg0, "xmlns", "http://www.w3.org/2000/svg");
attr(div3, "class", "timer svelte-1bkzjfd");
attr(span2, "class", "control svelte-1bkzjfd");
attr(span3, "class", "control svelte-1bkzjfd");
attr(span4, "class", "control svelte-1bkzjfd");
attr(div4, "class", "btn-group svelte-1bkzjfd");
attr(div5, "class", "main svelte-1bkzjfd");
attr(div6, "class", "pomodoro-extra svelte-1bkzjfd");
attr(div7, "class", "container svelte-1bkzjfd");
},
m(target, anchor) {
insert(target, div7, anchor);
append(div7, div5);
append(div5, div3);
append(div3, div2);
append(div2, div0);
if (if_block0)
if_block0.m(div0, null);
append(div0, t0);
if_block1.m(div0, null);
append(div0, t1);
append(div0, span0);
append(div2, t2);
append(div2, div1);
append(div1, span1);
append(span1, t3);
append(div3, t4);
append(div3, svg0);
append(svg0, g);
append(g, circle0);
append(g, circle1);
append(div5, t5);
append(div5, div4);
append(div4, span2);
append(div4, t6);
if_block2.m(div4, null);
append(div4, t7);
append(div4, span3);
append(div4, t8);
append(div4, span4);
append(div7, t9);
append(div7, div6);
if (~current_block_type_index) {
if_blocks[current_block_type_index].m(div6, null);
}
current = true;
if (!mounted) {
dispose = [
listen(
div0,
"click",
/*toggleMode*/
ctx[11]
),
listen(
div1,
"click",
/*toggleTimer*/
ctx[10]
),
listen(
span2,
"click",
/*click_handler*/
ctx[13]
),
listen(
span3,
"click",
/*reset*/
ctx[8]
),
listen(
span4,
"click",
/*click_handler_1*/
ctx[14]
)
];
mounted = true;
}
},
p(ctx2, [dirty]) {
if (
/*$timer*/
ctx2[4].running
) {
if (if_block0) {
} else {
if_block0 = create_if_block_42(ctx2);
if_block0.c();
if_block0.m(div0, t0);
}
} else if (if_block0) {
if_block0.d(1);
if_block0 = null;
}
if (current_block_type !== (current_block_type = select_block_type(ctx2, dirty))) {
if_block1.d(1);
if_block1 = current_block_type(ctx2);
if (if_block1) {
if_block1.c();
if_block1.m(div0, t1);
}
}
if (!current || dirty & /*$timer*/
16 && div0_class_value !== (div0_class_value = "status " + /*$timer*/
(ctx2[4].inSession ? "" : "control") + " svelte-1bkzjfd")) {
attr(div0, "class", div0_class_value);
}
if ((!current || dirty & /*$timer*/
16) && t3_value !== (t3_value = /*$timer*/
ctx2[4].remained.human + ""))
set_data(t3, t3_value);
if (!current || dirty & /*strokeOffset*/
64) {
set_style(
circle1,
"stroke-dashoffset",
/*strokeOffset*/
ctx2[6]
);
}
if (current_block_type_1 === (current_block_type_1 = select_block_type_1(ctx2, dirty)) && if_block2) {
if_block2.p(ctx2, dirty);
} else {
if_block2.d(1);
if_block2 = current_block_type_1(ctx2);
if (if_block2) {
if_block2.c();
if_block2.m(div4, t7);
}
}
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type_2(ctx2, dirty);
if (current_block_type_index === previous_block_index) {
if (~current_block_type_index) {
if_blocks[current_block_type_index].p(ctx2, dirty);
}
} else {
if (if_block3) {
group_outros();
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
check_outros();
}
if (~current_block_type_index) {
if_block3 = if_blocks[current_block_type_index];
if (!if_block3) {
if_block3 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
if_block3.c();
} else {
if_block3.p(ctx2, dirty);
}
transition_in(if_block3, 1);
if_block3.m(div6, null);
} else {
if_block3 = null;
}
}
},
i(local) {
if (current)
return;
transition_in(if_block3);
current = true;
},
o(local) {
transition_out(if_block3);
current = false;
},
d(detaching) {
if (detaching) {
detach(div7);
}
if (if_block0)
if_block0.d();
if_block1.d();
if_block2.d();
if (~current_block_type_index) {
if_blocks[current_block_type_index].d();
}
mounted = false;
run_all(dispose);
}
};
}
var offset = 440;
function instance4($$self, $$props, $$invalidate) {
let strokeOffset;
let $timer, $$unsubscribe_timer = noop, $$subscribe_timer = () => ($$unsubscribe_timer(), $$unsubscribe_timer = subscribe(timer, ($$value) => $$invalidate(4, $timer = $$value)), timer);
$$self.$$.on_destroy.push(() => $$unsubscribe_timer());
let { timer } = $$props;
$$subscribe_timer();
let { tasks } = $$props;
let { tracker } = $$props;
let { render } = $$props;
let extra = "tasks";
const start = () => {
if (!$timer.running) {
timer.start();
}
};
const reset = () => {
timer.reset();
};
const pause = () => {
if ($timer.running) {
timer.pause();
}
};
const toggleTimer = () => {
timer.toggleTimer();
};
const toggleMode = () => {
timer.toggleMode();
};
const toggleExtra = (value) => {
if (extra === value) {
$$invalidate(5, extra = "close");
return;
}
$$invalidate(5, extra = value);
};
const click_handler = () => {
toggleExtra("tasks");
};
const click_handler_1 = () => {
toggleExtra("settings");
};
$$self.$$set = ($$props2) => {
if ("timer" in $$props2)
$$subscribe_timer($$invalidate(0, timer = $$props2.timer));
if ("tasks" in $$props2)
$$invalidate(1, tasks = $$props2.tasks);
if ("tracker" in $$props2)
$$invalidate(2, tracker = $$props2.tracker);
if ("render" in $$props2)
$$invalidate(3, render = $$props2.render);
};
$$self.$$.update = () => {
if ($$self.$$.dirty & /*$timer*/
16) {
$:
$$invalidate(6, strokeOffset = $timer.remained.millis * offset / $timer.count);
}
};
return [
timer,
tasks,
tracker,
render,
$timer,
extra,
strokeOffset,
start,
reset,
pause,
toggleTimer,
toggleMode,
toggleExtra,
click_handler,
click_handler_1
];
}
var TimerViewComponent = class extends SvelteComponent {
constructor(options) {
super();
init(
this,
options,
instance4,
create_fragment4,
safe_not_equal,
{
timer: 0,
tasks: 1,
tracker: 2,
render: 3
},
add_css4
);
}
};
var TimerViewComponent_default = TimerViewComponent;
// src/TimerView.ts
var import_obsidian5 = require("obsidian");
var VIEW_TYPE_TIMER = "timer-view";
var TimerView = class extends import_obsidian4.ItemView {
constructor(plugin, leaf) {
super(leaf);
this.plugin = plugin;
this.icon = "timer";
}
getViewType() {
return VIEW_TYPE_TIMER;
}
getDisplayText() {
return "Timer";
}
async onOpen() {
this.component = new TimerViewComponent_default({
target: this.contentEl,
props: {
timer: this.plugin.timer,
tasks: this.plugin.tasks,
tracker: this.plugin.tracker,
render: (content, el) => {
import_obsidian5.MarkdownRenderer.render(
this.plugin.app,
content,
el,
"",
this
);
}
}
});
}
async onClose() {
var _a;
(_a = this.component) == null ? void 0 : _a.$destroy();
}
};
// src/main.ts
var import_obsidian10 = require("obsidian");
// src/StatusBarComponent.svelte
var import_obsidian8 = require("obsidian");
// src/clock.worker.ts
function inlineWorker() {
let blob = new Blob(['"use strict";var e=!1,s=()=>{e&&(self.postMessage(new Date().getTime()),requestAnimationFrame(s))};self.onmessage=async({data:n})=>{n?e||(e=!0,s()):e=!1};\n'], { type: "text/javascript" });
let url = URL.createObjectURL(blob);
let worker = new Worker(url);
URL.revokeObjectURL(url);
return worker;
}
// src/Timer.ts
var import_obsidian7 = require("obsidian");
// src/Logger.ts
var import_obsidian6 = require("obsidian");
var Logger = class {
constructor(plugin) {
this.plugin = plugin;
}
async log(ctx) {
const logFile = await this.resolveLogFile(ctx);
const log = this.createLog(ctx);
if (logFile) {
const logText = await this.toText(log, logFile);
if (logText) {
await this.plugin.app.vault.append(logFile, `
${logText}`);
}
}
return logFile;
}
async resolveLogFile(ctx) {
const settings2 = this.plugin.getSettings();
if (settings2.logLevel !== "ALL" && settings2.logLevel !== ctx.mode) {
return;
}
if (settings2.logFocused && ctx.task.path && ctx.task.path.endsWith("md")) {
const file = this.plugin.app.vault.getAbstractFileByPath(
ctx.task.path
);
if (file && file instanceof import_obsidian6.TFile) {
return file;
}
}
if (settings2.logFile === "NONE") {
return;
}
if (settings2.logFile === "DAILY") {
return await getDailyNoteFile();
}
if (settings2.logFile === "FILE") {
if (settings2.logPath) {
let path = settings2.logPath;
if (!path.endsWith("md")) {
path += ".md";
}
try {
return await ensureFileExists(this.plugin.app, path);
} catch (error) {
if (error instanceof Error) {
new import_obsidian6.Notice(error.message);
}
return;
}
}
}
}
createLog(ctx) {
return {
mode: ctx.mode,
duration: Math.floor(ctx.elapsed / 6e4),
begin: ctx.startTime,
end: new Date().getTime(),
session: ctx.duration,
task: ctx.task,
finished: ctx.count == ctx.elapsed
};
}
async toText(log, file) {
const settings2 = this.plugin.getSettings();
if (settings2.logFormat === "CUSTOM" && getTemplater(this.plugin.app)) {
try {
return await parseWithTemplater(
this.plugin.app,
file,
settings2.logTemplate,
log
);
} catch (e) {
new import_obsidian6.Notice("Invalid template");
console.error("invalid templat:", e);
return "";
}
} else {
if (!log.finished) {
return "";
}
let begin = (0, import_obsidian6.moment)(log.begin);
let end = (0, import_obsidian6.moment)(log.end);
if (settings2.logFormat === "SIMPLE") {
return `**${log.mode}(${log.duration}m)**: ${begin.format(
"HH:mm"
)} - ${end.format("HH:mm")}`;
}
if (settings2.logFormat === "VERBOSE") {
const emoji = log.mode == "WORK" ? "\u{1F345}" : "\u{1F964}";
return `- ${emoji} (pomodoro::${log.mode}) (duration:: ${log.duration}m) (begin:: ${begin.format(
"YYYY-MM-DD HH:mm"
)}) - (end:: ${end.format("YYYY-MM-DD HH:mm")})`;
}
return "";
}
}
};
// src/Notification.ts
var Notification_default = "data:audio/ogg;base64,T2dnUwACAAAAAAAAAACJwwLMAAAAAJ4PAf8BHgF2b3JiaXMAAAAAAkSsAAAAAAAAgLUBAAAAAAC4AU9nZ1MAAAAAAAAAAAAAicMCzAEAAAC2HLmLEUH///////////////////8HA3ZvcmJpcw0AAABMYXZmNTguNzYuMTAwAQAAACAAAABlbmNvZGVyPUxhdmM1OC4xMzQuMTAwIGxpYnZvcmJpcwEFdm9yYmlzJUJDVgEAQAAAJHMYKkalcxaEEBpCUBnjHELOa+wZQkwRghwyTFvLJXOQIaSgQohbKIHQkFUAAEAAAIdBeBSEikEIIYQlPViSgyc9CCGEiDl4FIRpQQghhBBCCCGEEEIIIYRFOWiSgydBCB2E4zA4DIPlOPgchEU5WBCDJ0HoIIQPQriag6w5CCGEJDVIUIMGOegchMIsKIqCxDC4FoQENSiMguQwyNSDC0KImoNJNfgahGdBeBaEaUEIIYQkQUiQgwZByBiERkFYkoMGObgUhMtBqBqEKjkIH4QgNGQVAJAAAKCiKIqiKAoQGrIKAMgAABBAURTHcRzJkRzJsRwLCA1ZBQAAAQAIAACgSIqkSI7kSJIkWZIlWZIlWZLmiaosy7Isy7IsyzIQGrIKAEgAAFBRDEVxFAcIDVkFAGQAAAigOIqlWIqlaIrniI4IhIasAgCAAAAEAAAQNENTPEeURM9UVde2bdu2bdu2bdu2bdu2bVuWZRkIDVkFAEAAABDSaWapBogwAxkGQkNWAQAIAACAEYowxIDQkFUAAEAAAIAYSg6iCa0535zjoFkOmkqxOR2cSLV5kpuKuTnnnHPOyeacMc4555yinFkMmgmtOeecxKBZCpoJrTnnnCexedCaKq0555xxzulgnBHGOeecJq15kJqNtTnnnAWtaY6aS7E555xIuXlSm0u1Oeecc84555xzzjnnnOrF6RycE84555yovbmWm9DFOeecT8bp3pwQzjnnnHPOOeecc84555wgNGQVAAAEAEAQho1h3CkI0udoIEYRYhoy6UH36DAJGoOcQurR6GiklDoIJZVxUkonCA1ZBQAAAgBACCGFFFJIIYUUUkghhRRiiCGGGHLKKaeggkoqqaiijDLLLLPMMssss8w67KyzDjsMMcQQQyutxFJTbTXWWGvuOeeag7RWWmuttVJKKaWUUgpCQ1YBACAAAARCBhlkkFFIIYUUYogpp5xyCiqogNCQVQAAIACAAAAAAE/yHNERHdERHdERHdERHdHxHM8RJVESJVESLdMyNdNTRVV1ZdeWdVm3fVvYhV33fd33fd34dWFYlmVZlmVZlmVZlmVZlmVZliA0ZBUAAAIAACCEEEJIIYUUUkgpxhhzzDnoJJQQCA1ZBQAAAgAIAAAAcBRHcRzJkRxJsiRL0iTN0ixP8zRPEz1RFEXTNFXRFV1RN21RNmXTNV1TNl1VVm1Xlm1btnXbl2Xb933f933f933f933f931dB0JDVgEAEgAAOpIjKZIiKZLjOI4kSUBoyCoAQAYAQAAAiuIojuM4kiRJkiVpkmd5lqiZmumZniqqQGjIKgAAEABAAAAAAAAAiqZ4iql4iqh4juiIkmiZlqipmivKpuy6ruu6ruu6ruu6ruu6ruu6ruu6ruu6ruu6ruu6ruu6ruu6rguEhqwCACQAAHQkR3IkR1IkRVIkR3KA0JBVAIAMAIAAABzDMSRFcizL0jRP8zRPEz3REz3TU0VXdIHQkFUAACAAgAAAAAAAAAzJsBTL0RxNEiXVUi1VUy3VUkXVU1VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU3TNE0TCA1ZCQCQAQCQEFMtLcaaCYskYtJqq6BjDFLspbFIKme1t8oxhRi1XhqHlFEQe6kkY4pBzC2k0CkmrdZUQoUUpJhjKhVSDlIgNGSFABCaAeBwHECyLECyLAAAAAAAAACQNA3QPA+wNA8AAAAAAAAAJE0DLE8DNM8DAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEDSNEDzPEDzPAAAAAAAAADQPA/wPBHwRBEAAAAAAAAALM8DNNEDPFEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEDSNEDzPEDzPAAAAAAAAACwPA/wRBHQPBEAAAAAAAAALM8DPFEEPNEDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAQ4AAAEGAhFBqyIgCIEwBwSBIkCZIEzQNIlgVNg6bBNAGSZUHToGkwTQAAAAAAAAAAAAAkTYOmQdMgigBJ06Bp0DSIIgAAAAAAAAAAAACSpkHToGkQRYCkadA0aBpEEQAAAAAAAAAAAADPNCGKEEWYJsAzTYgiRBGmCQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAYcAAACDChDBQasiIAiBMAcDiKZQEAgOM4lgUAAI7jWBYAAFiWJYoAAGBZmigCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAABhwAAAIMKEMFBqyEgCIAgBwKIplAcexLOA4lgUkybIAlgXQPICmAUQRAAgAAChwAAAIsEFTYnGAQkNWAgBRAAAGxbEsTRNFkqRpmieKJEnTPE8UaZrneZ5pwvM8zzQhiqJomhBFUTRNmKZpqiowTVUVAABQ4AAAEGCDpsTiAIWGrAQAQgIAHIpiWZrmeZ4niqapmiRJ0zxPFEXRNE1TVUmSpnmeKIqiaZqmqrIsTfM8URRF01RVVYWmeZ4oiqJpqqrqwvM8TxRF0TRV1XXheZ4niqJomqrquhBFUTRN01RNVXVdIIqmaZqqqqquC0RPFE1TVV3XdYHniaJpqqqrui4QTdNUVVV1XVkGmKZpqqrryjJAVVXVdV1XlgGqqqqu67qyDFBV13VdWZZlAK7rurIsywIAAA4cAAACjKCTjCqLsNGECw9AoSErAoAoAADAGKYUU8owJiGkEBrGJIQUQiYlpdJSqiCkUlIpFYRUSiolo5RSailVEFIpqZQKQiollVIAANiBAwDYgYVQaMhKACAPAIAwRinGGHNOIqQUY845JxFSijHnnJNKMeacc85JKRlzzDnnpJTOOeecc1JK5