pyegeria 5.4.0.15__py3-none-any.whl → 5.4.0.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. commands/cat/.DS_Store +0 -0
  2. commands/cat/.env +8 -0
  3. commands/cat/debug_log +10 -0
  4. commands/cat/debug_log.log +0 -0
  5. commands/cat/dr_egeria_md.py +1 -1
  6. commands/cat/list_format_set.py +5 -3
  7. commands/cat/logs/pyegeria.log +27 -0
  8. commands/cli/debug_log.log +0 -0
  9. commands/ops/load_archive.py +26 -22
  10. commands/ops/logs/pyegeria.log +0 -0
  11. md_processing/.DS_Store +0 -0
  12. md_processing/dr_egeria_inbox/Derive-Dr-Gov-Defs.md +8 -0
  13. md_processing/dr_egeria_inbox/Dr.Egeria Templates.md +873 -0
  14. md_processing/dr_egeria_inbox/arch_test.md +57 -0
  15. md_processing/dr_egeria_inbox/archive/dr_egeria_intro.md +254 -0
  16. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_more_terms.md +696 -0
  17. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part1.md +254 -0
  18. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part2.md +298 -0
  19. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part3.md +608 -0
  20. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part4.md +94 -0
  21. md_processing/dr_egeria_inbox/archive/freddie_intro.md +284 -0
  22. md_processing/dr_egeria_inbox/archive/freddie_intro_orig.md +275 -0
  23. md_processing/dr_egeria_inbox/archive/test-term.md +110 -0
  24. md_processing/dr_egeria_inbox/cat_test.md +100 -0
  25. md_processing/dr_egeria_inbox/collections.md +39 -0
  26. md_processing/dr_egeria_inbox/data_designer_debug.log +6 -0
  27. md_processing/dr_egeria_inbox/data_designer_out.md +60 -0
  28. md_processing/dr_egeria_inbox/data_designer_search_test.md +11 -0
  29. md_processing/dr_egeria_inbox/data_field.md +54 -0
  30. md_processing/dr_egeria_inbox/data_spec.md +77 -0
  31. md_processing/dr_egeria_inbox/data_spec_test.md +2406 -0
  32. md_processing/dr_egeria_inbox/data_test.md +179 -0
  33. md_processing/dr_egeria_inbox/data_test2.md +429 -0
  34. md_processing/dr_egeria_inbox/data_test3.md +462 -0
  35. md_processing/dr_egeria_inbox/dr_egeria_data_designer_1.md +124 -0
  36. md_processing/dr_egeria_inbox/dr_egeria_intro_categories.md +168 -0
  37. md_processing/dr_egeria_inbox/dr_egeria_intro_part1.md +280 -0
  38. md_processing/dr_egeria_inbox/dr_egeria_intro_part2.md +313 -0
  39. md_processing/dr_egeria_inbox/dr_egeria_intro_part3.md +1073 -0
  40. md_processing/dr_egeria_inbox/dr_egeria_isc1.md +44 -0
  41. md_processing/dr_egeria_inbox/generated_help_report.md +9 -0
  42. md_processing/dr_egeria_inbox/glossary_list.md +5 -0
  43. md_processing/dr_egeria_inbox/glossary_search_test.md +40 -0
  44. md_processing/dr_egeria_inbox/glossary_test1.md +324 -0
  45. md_processing/dr_egeria_inbox/gov_def.md +424 -0
  46. md_processing/dr_egeria_inbox/gov_def2.md +447 -0
  47. md_processing/dr_egeria_inbox/product.md +50 -0
  48. md_processing/dr_egeria_inbox/rel.md +8 -0
  49. md_processing/dr_egeria_inbox/sb.md +119 -0
  50. md_processing/dr_egeria_inbox/solution-components.md +136 -0
  51. md_processing/dr_egeria_inbox/solution_blueprints.md +118 -0
  52. md_processing/dr_egeria_inbox/synonym_test.md +42 -0
  53. md_processing/dr_egeria_inbox/t2.md +268 -0
  54. md_processing/dr_egeria_outbox/.obsidian/app.json +1 -0
  55. md_processing/dr_egeria_outbox/.obsidian/appearance.json +1 -0
  56. md_processing/dr_egeria_outbox/.obsidian/community-plugins.json +6 -0
  57. md_processing/dr_egeria_outbox/.obsidian/core-plugins.json +31 -0
  58. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/data.json +10 -0
  59. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/main.js +4459 -0
  60. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/manifest.json +10 -0
  61. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/data.json +3 -0
  62. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/main.js +153 -0
  63. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/manifest.json +11 -0
  64. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/styles.css +1 -0
  65. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/main.js +500 -0
  66. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/manifest.json +12 -0
  67. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/styles.css +1 -0
  68. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/main.js +37 -0
  69. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/manifest.json +11 -0
  70. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/styles.css +220 -0
  71. md_processing/dr_egeria_outbox/.obsidian/types.json +28 -0
  72. md_processing/dr_egeria_outbox/.obsidian/workspace.json +220 -0
  73. md_processing/dr_egeria_outbox/Untitled.canvas +1 -0
  74. md_processing/dr_egeria_outbox/friday/processed-2025-07-18 15:00-product.md +62 -0
  75. md_processing/dr_egeria_outbox/friday/processed-2025-07-18 15:13-product.md +62 -0
  76. md_processing/dr_egeria_outbox/friday/processed-2025-07-20 13:23-product.md +47 -0
  77. md_processing/dr_egeria_outbox/friday/processed-2025-08-01 11:55-data_test3.md +503 -0
  78. md_processing/dr_egeria_outbox/monday/processed-2025-07-14 12:38-data_designer_out.md +663 -0
  79. md_processing/dr_egeria_outbox/monday/processed-2025-07-21 10:52-generated_help_report.md +2744 -0
  80. md_processing/dr_egeria_outbox/monday/processed-2025-07-21 18:38-collections.md +62 -0
  81. md_processing/dr_egeria_outbox/monday/processed-2025-08-01 11:34-gov_def.md +444 -0
  82. md_processing/dr_egeria_outbox/processed-2025-08-03 16:05-glossary_list.md +37 -0
  83. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 14:55-product.md +77 -0
  84. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 15:05-product.md +75 -0
  85. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 15:11-product.md +74 -0
  86. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 20:40-collections.md +49 -0
  87. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 15:00-Derive-Dr-Gov-Defs.md +719 -0
  88. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:13-Derive-Dr-Gov-Defs.md +41 -0
  89. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:14-Derive-Dr-Gov-Defs.md +33 -0
  90. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:50-Derive-Dr-Gov-Defs.md +192 -0
  91. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 22:08-gov_def2.md +486 -0
  92. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 22:10-gov_def2.md +486 -0
  93. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 08:53-gov_def2.md +486 -0
  94. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 08:54-gov_def2.md +486 -0
  95. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:03-gov_def2.md +486 -0
  96. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:06-gov_def2.md +486 -0
  97. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:10-gov_def2.md +486 -0
  98. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-16 19:15-gov_def2.md +527 -0
  99. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-17 12:08-gov_def2.md +527 -0
  100. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-17 14:27-gov_def2.md +485 -0
  101. md_processing/md_processing_utils/debug_log.log +0 -0
  102. md_processing/md_processing_utils/solution_architect_log.log +0 -0
  103. pyegeria/.DS_Store +0 -0
  104. pyegeria/__init__.py +2 -2
  105. pyegeria/_client_new.py +31 -1
  106. pyegeria/_output_formats.py +23 -0
  107. pyegeria/glossary_browser_omvs.py +178 -65
  108. pyegeria/platform_services.py +3 -3
  109. pyegeria/runtime_manager_omvs.py +55 -55
  110. {pyegeria-5.4.0.15.dist-info → pyegeria-5.4.0.17.dist-info}/METADATA +1 -1
  111. {pyegeria-5.4.0.15.dist-info → pyegeria-5.4.0.17.dist-info}/RECORD +114 -15
  112. {pyegeria-5.4.0.15.dist-info → pyegeria-5.4.0.17.dist-info}/LICENSE +0 -0
  113. {pyegeria-5.4.0.15.dist-info → pyegeria-5.4.0.17.dist-info}/WHEEL +0 -0
  114. {pyegeria-5.4.0.15.dist-info → pyegeria-5.4.0.17.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,4459 @@
1
+ 'use strict';
2
+
3
+ var obsidian = require('obsidian');
4
+
5
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
6
+
7
+ var obsidian__default = /*#__PURE__*/_interopDefaultLegacy(obsidian);
8
+
9
+ const DEFAULT_WEEK_FORMAT = "gggg-[W]ww";
10
+ const DEFAULT_WORDS_PER_DOT = 250;
11
+ const VIEW_TYPE_CALENDAR = "calendar";
12
+ const TRIGGER_ON_OPEN = "calendar:open";
13
+
14
+ const DEFAULT_DAILY_NOTE_FORMAT = "YYYY-MM-DD";
15
+ const DEFAULT_WEEKLY_NOTE_FORMAT = "gggg-[W]ww";
16
+ const DEFAULT_MONTHLY_NOTE_FORMAT = "YYYY-MM";
17
+
18
+ function shouldUsePeriodicNotesSettings(periodicity) {
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ const periodicNotes = window.app.plugins.getPlugin("periodic-notes");
21
+ return periodicNotes && periodicNotes.settings?.[periodicity]?.enabled;
22
+ }
23
+ /**
24
+ * Read the user settings for the `daily-notes` plugin
25
+ * to keep behavior of creating a new note in-sync.
26
+ */
27
+ function getDailyNoteSettings() {
28
+ try {
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ const { internalPlugins, plugins } = window.app;
31
+ if (shouldUsePeriodicNotesSettings("daily")) {
32
+ const { format, folder, template } = plugins.getPlugin("periodic-notes")?.settings?.daily || {};
33
+ return {
34
+ format: format || DEFAULT_DAILY_NOTE_FORMAT,
35
+ folder: folder?.trim() || "",
36
+ template: template?.trim() || "",
37
+ };
38
+ }
39
+ const { folder, format, template } = internalPlugins.getPluginById("daily-notes")?.instance?.options || {};
40
+ return {
41
+ format: format || DEFAULT_DAILY_NOTE_FORMAT,
42
+ folder: folder?.trim() || "",
43
+ template: template?.trim() || "",
44
+ };
45
+ }
46
+ catch (err) {
47
+ console.info("No custom daily note settings found!", err);
48
+ }
49
+ }
50
+ /**
51
+ * Read the user settings for the `weekly-notes` plugin
52
+ * to keep behavior of creating a new note in-sync.
53
+ */
54
+ function getWeeklyNoteSettings() {
55
+ try {
56
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
+ const pluginManager = window.app.plugins;
58
+ const calendarSettings = pluginManager.getPlugin("calendar")?.options;
59
+ const periodicNotesSettings = pluginManager.getPlugin("periodic-notes")
60
+ ?.settings?.weekly;
61
+ if (shouldUsePeriodicNotesSettings("weekly")) {
62
+ return {
63
+ format: periodicNotesSettings.format || DEFAULT_WEEKLY_NOTE_FORMAT,
64
+ folder: periodicNotesSettings.folder?.trim() || "",
65
+ template: periodicNotesSettings.template?.trim() || "",
66
+ };
67
+ }
68
+ const settings = calendarSettings || {};
69
+ return {
70
+ format: settings.weeklyNoteFormat || DEFAULT_WEEKLY_NOTE_FORMAT,
71
+ folder: settings.weeklyNoteFolder?.trim() || "",
72
+ template: settings.weeklyNoteTemplate?.trim() || "",
73
+ };
74
+ }
75
+ catch (err) {
76
+ console.info("No custom weekly note settings found!", err);
77
+ }
78
+ }
79
+ /**
80
+ * Read the user settings for the `periodic-notes` plugin
81
+ * to keep behavior of creating a new note in-sync.
82
+ */
83
+ function getMonthlyNoteSettings() {
84
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
+ const pluginManager = window.app.plugins;
86
+ try {
87
+ const settings = (shouldUsePeriodicNotesSettings("monthly") &&
88
+ pluginManager.getPlugin("periodic-notes")?.settings?.monthly) ||
89
+ {};
90
+ return {
91
+ format: settings.format || DEFAULT_MONTHLY_NOTE_FORMAT,
92
+ folder: settings.folder?.trim() || "",
93
+ template: settings.template?.trim() || "",
94
+ };
95
+ }
96
+ catch (err) {
97
+ console.info("No custom monthly note settings found!", err);
98
+ }
99
+ }
100
+
101
+ /**
102
+ * dateUID is a way of weekly identifying daily/weekly/monthly notes.
103
+ * They are prefixed with the granularity to avoid ambiguity.
104
+ */
105
+ function getDateUID$1(date, granularity = "day") {
106
+ const ts = date.clone().startOf(granularity).format();
107
+ return `${granularity}-${ts}`;
108
+ }
109
+ function removeEscapedCharacters(format) {
110
+ return format.replace(/\[[^\]]*\]/g, ""); // remove everything within brackets
111
+ }
112
+ /**
113
+ * XXX: When parsing dates that contain both week numbers and months,
114
+ * Moment choses to ignore the week numbers. For the week dateUID, we
115
+ * want the opposite behavior. Strip the MMM from the format to patch.
116
+ */
117
+ function isFormatAmbiguous(format, granularity) {
118
+ if (granularity === "week") {
119
+ const cleanFormat = removeEscapedCharacters(format);
120
+ return (/w{1,2}/i.test(cleanFormat) &&
121
+ (/M{1,4}/.test(cleanFormat) || /D{1,4}/.test(cleanFormat)));
122
+ }
123
+ return false;
124
+ }
125
+ function getDateFromFile(file, granularity) {
126
+ const getSettings = {
127
+ day: getDailyNoteSettings,
128
+ week: getWeeklyNoteSettings,
129
+ month: getMonthlyNoteSettings,
130
+ };
131
+ const format = getSettings[granularity]().format.split("/").pop();
132
+ const noteDate = window.moment(file.basename, format, true);
133
+ if (!noteDate.isValid()) {
134
+ return null;
135
+ }
136
+ if (isFormatAmbiguous(format, granularity)) {
137
+ if (granularity === "week") {
138
+ const cleanFormat = removeEscapedCharacters(format);
139
+ if (/w{1,2}/i.test(cleanFormat)) {
140
+ return window.moment(file.basename,
141
+ // If format contains week, remove day & month formatting
142
+ format.replace(/M{1,4}/g, "").replace(/D{1,4}/g, ""), false);
143
+ }
144
+ }
145
+ }
146
+ return noteDate;
147
+ }
148
+
149
+ // Credit: @creationix/path.js
150
+ function join(...partSegments) {
151
+ // Split the inputs into a list of path commands.
152
+ let parts = [];
153
+ for (let i = 0, l = partSegments.length; i < l; i++) {
154
+ parts = parts.concat(partSegments[i].split("/"));
155
+ }
156
+ // Interpret the path commands to get the new resolved path.
157
+ const newParts = [];
158
+ for (let i = 0, l = parts.length; i < l; i++) {
159
+ const part = parts[i];
160
+ // Remove leading and trailing slashes
161
+ // Also remove "." segments
162
+ if (!part || part === ".")
163
+ continue;
164
+ // Push new path segments.
165
+ else
166
+ newParts.push(part);
167
+ }
168
+ // Preserve the initial slash if there was one.
169
+ if (parts[0] === "")
170
+ newParts.unshift("");
171
+ // Turn back into a single string path.
172
+ return newParts.join("/");
173
+ }
174
+ async function ensureFolderExists(path) {
175
+ const dirs = path.replace(/\\/g, "/").split("/");
176
+ dirs.pop(); // remove basename
177
+ if (dirs.length) {
178
+ const dir = join(...dirs);
179
+ if (!window.app.vault.getAbstractFileByPath(dir)) {
180
+ await window.app.vault.createFolder(dir);
181
+ }
182
+ }
183
+ }
184
+ async function getNotePath(directory, filename) {
185
+ if (!filename.endsWith(".md")) {
186
+ filename += ".md";
187
+ }
188
+ const path = obsidian__default['default'].normalizePath(join(directory, filename));
189
+ await ensureFolderExists(path);
190
+ return path;
191
+ }
192
+ async function getTemplateInfo(template) {
193
+ const { metadataCache, vault } = window.app;
194
+ const templatePath = obsidian__default['default'].normalizePath(template);
195
+ if (templatePath === "/") {
196
+ return Promise.resolve(["", null]);
197
+ }
198
+ try {
199
+ const templateFile = metadataCache.getFirstLinkpathDest(templatePath, "");
200
+ const contents = await vault.cachedRead(templateFile);
201
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
202
+ const IFoldInfo = window.app.foldManager.load(templateFile);
203
+ return [contents, IFoldInfo];
204
+ }
205
+ catch (err) {
206
+ console.error(`Failed to read the daily note template '${templatePath}'`, err);
207
+ new obsidian__default['default'].Notice("Failed to read the daily note template");
208
+ return ["", null];
209
+ }
210
+ }
211
+
212
+ class DailyNotesFolderMissingError extends Error {
213
+ }
214
+ /**
215
+ * This function mimics the behavior of the daily-notes plugin
216
+ * so it will replace {{date}}, {{title}}, and {{time}} with the
217
+ * formatted timestamp.
218
+ *
219
+ * Note: it has an added bonus that it's not 'today' specific.
220
+ */
221
+ async function createDailyNote(date) {
222
+ const app = window.app;
223
+ const { vault } = app;
224
+ const moment = window.moment;
225
+ const { template, format, folder } = getDailyNoteSettings();
226
+ const [templateContents, IFoldInfo] = await getTemplateInfo(template);
227
+ const filename = date.format(format);
228
+ const normalizedPath = await getNotePath(folder, filename);
229
+ try {
230
+ const createdFile = await vault.create(normalizedPath, templateContents
231
+ .replace(/{{\s*date\s*}}/gi, filename)
232
+ .replace(/{{\s*time\s*}}/gi, moment().format("HH:mm"))
233
+ .replace(/{{\s*title\s*}}/gi, filename)
234
+ .replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
235
+ const now = moment();
236
+ const currentDate = date.clone().set({
237
+ hour: now.get("hour"),
238
+ minute: now.get("minute"),
239
+ second: now.get("second"),
240
+ });
241
+ if (calc) {
242
+ currentDate.add(parseInt(timeDelta, 10), unit);
243
+ }
244
+ if (momentFormat) {
245
+ return currentDate.format(momentFormat.substring(1).trim());
246
+ }
247
+ return currentDate.format(format);
248
+ })
249
+ .replace(/{{\s*yesterday\s*}}/gi, date.clone().subtract(1, "day").format(format))
250
+ .replace(/{{\s*tomorrow\s*}}/gi, date.clone().add(1, "d").format(format)));
251
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
252
+ app.foldManager.save(createdFile, IFoldInfo);
253
+ return createdFile;
254
+ }
255
+ catch (err) {
256
+ console.error(`Failed to create file: '${normalizedPath}'`, err);
257
+ new obsidian__default['default'].Notice("Unable to create new file.");
258
+ }
259
+ }
260
+ function getDailyNote(date, dailyNotes) {
261
+ return dailyNotes[getDateUID$1(date, "day")] ?? null;
262
+ }
263
+ function getAllDailyNotes() {
264
+ /**
265
+ * Find all daily notes in the daily note folder
266
+ */
267
+ const { vault } = window.app;
268
+ const { folder } = getDailyNoteSettings();
269
+ const dailyNotesFolder = vault.getAbstractFileByPath(obsidian__default['default'].normalizePath(folder));
270
+ if (!dailyNotesFolder) {
271
+ throw new DailyNotesFolderMissingError("Failed to find daily notes folder");
272
+ }
273
+ const dailyNotes = {};
274
+ obsidian__default['default'].Vault.recurseChildren(dailyNotesFolder, (note) => {
275
+ if (note instanceof obsidian__default['default'].TFile) {
276
+ const date = getDateFromFile(note, "day");
277
+ if (date) {
278
+ const dateString = getDateUID$1(date, "day");
279
+ dailyNotes[dateString] = note;
280
+ }
281
+ }
282
+ });
283
+ return dailyNotes;
284
+ }
285
+
286
+ class WeeklyNotesFolderMissingError extends Error {
287
+ }
288
+ function getDaysOfWeek$1() {
289
+ const { moment } = window;
290
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
291
+ let weekStart = moment.localeData()._week.dow;
292
+ const daysOfWeek = [
293
+ "sunday",
294
+ "monday",
295
+ "tuesday",
296
+ "wednesday",
297
+ "thursday",
298
+ "friday",
299
+ "saturday",
300
+ ];
301
+ while (weekStart) {
302
+ daysOfWeek.push(daysOfWeek.shift());
303
+ weekStart--;
304
+ }
305
+ return daysOfWeek;
306
+ }
307
+ function getDayOfWeekNumericalValue(dayOfWeekName) {
308
+ return getDaysOfWeek$1().indexOf(dayOfWeekName.toLowerCase());
309
+ }
310
+ async function createWeeklyNote(date) {
311
+ const { vault } = window.app;
312
+ const { template, format, folder } = getWeeklyNoteSettings();
313
+ const [templateContents, IFoldInfo] = await getTemplateInfo(template);
314
+ const filename = date.format(format);
315
+ const normalizedPath = await getNotePath(folder, filename);
316
+ try {
317
+ const createdFile = await vault.create(normalizedPath, templateContents
318
+ .replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
319
+ const now = window.moment();
320
+ const currentDate = date.clone().set({
321
+ hour: now.get("hour"),
322
+ minute: now.get("minute"),
323
+ second: now.get("second"),
324
+ });
325
+ if (calc) {
326
+ currentDate.add(parseInt(timeDelta, 10), unit);
327
+ }
328
+ if (momentFormat) {
329
+ return currentDate.format(momentFormat.substring(1).trim());
330
+ }
331
+ return currentDate.format(format);
332
+ })
333
+ .replace(/{{\s*title\s*}}/gi, filename)
334
+ .replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm"))
335
+ .replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi, (_, dayOfWeek, momentFormat) => {
336
+ const day = getDayOfWeekNumericalValue(dayOfWeek);
337
+ return date.weekday(day).format(momentFormat.trim());
338
+ }));
339
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
340
+ window.app.foldManager.save(createdFile, IFoldInfo);
341
+ return createdFile;
342
+ }
343
+ catch (err) {
344
+ console.error(`Failed to create file: '${normalizedPath}'`, err);
345
+ new obsidian__default['default'].Notice("Unable to create new file.");
346
+ }
347
+ }
348
+ function getWeeklyNote(date, weeklyNotes) {
349
+ return weeklyNotes[getDateUID$1(date, "week")] ?? null;
350
+ }
351
+ function getAllWeeklyNotes() {
352
+ const { vault } = window.app;
353
+ const { folder } = getWeeklyNoteSettings();
354
+ const weeklyNotesFolder = vault.getAbstractFileByPath(obsidian__default['default'].normalizePath(folder));
355
+ if (!weeklyNotesFolder) {
356
+ throw new WeeklyNotesFolderMissingError("Failed to find weekly notes folder");
357
+ }
358
+ const weeklyNotes = {};
359
+ obsidian__default['default'].Vault.recurseChildren(weeklyNotesFolder, (note) => {
360
+ if (note instanceof obsidian__default['default'].TFile) {
361
+ const date = getDateFromFile(note, "week");
362
+ if (date) {
363
+ const dateString = getDateUID$1(date, "week");
364
+ weeklyNotes[dateString] = note;
365
+ }
366
+ }
367
+ });
368
+ return weeklyNotes;
369
+ }
370
+
371
+ function appHasDailyNotesPluginLoaded() {
372
+ const { app } = window;
373
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
374
+ const dailyNotesPlugin = app.internalPlugins.plugins["daily-notes"];
375
+ if (dailyNotesPlugin && dailyNotesPlugin.enabled) {
376
+ return true;
377
+ }
378
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
379
+ const periodicNotes = app.plugins.getPlugin("periodic-notes");
380
+ return periodicNotes && periodicNotes.settings?.daily?.enabled;
381
+ }
382
+ var appHasDailyNotesPluginLoaded_1 = appHasDailyNotesPluginLoaded;
383
+ var createDailyNote_1 = createDailyNote;
384
+ var createWeeklyNote_1 = createWeeklyNote;
385
+ var getAllDailyNotes_1 = getAllDailyNotes;
386
+ var getAllWeeklyNotes_1 = getAllWeeklyNotes;
387
+ var getDailyNote_1 = getDailyNote;
388
+ var getDailyNoteSettings_1 = getDailyNoteSettings;
389
+ var getDateFromFile_1 = getDateFromFile;
390
+ var getDateUID_1$1 = getDateUID$1;
391
+ var getWeeklyNote_1 = getWeeklyNote;
392
+ var getWeeklyNoteSettings_1 = getWeeklyNoteSettings;
393
+
394
+ function noop$1() { }
395
+ function run$1(fn) {
396
+ return fn();
397
+ }
398
+ function blank_object$1() {
399
+ return Object.create(null);
400
+ }
401
+ function run_all$1(fns) {
402
+ fns.forEach(run$1);
403
+ }
404
+ function is_function$1(thing) {
405
+ return typeof thing === 'function';
406
+ }
407
+ function safe_not_equal$1(a, b) {
408
+ return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
409
+ }
410
+ function not_equal$1(a, b) {
411
+ return a != a ? b == b : a !== b;
412
+ }
413
+ function is_empty$1(obj) {
414
+ return Object.keys(obj).length === 0;
415
+ }
416
+ function subscribe(store, ...callbacks) {
417
+ if (store == null) {
418
+ return noop$1;
419
+ }
420
+ const unsub = store.subscribe(...callbacks);
421
+ return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
422
+ }
423
+ function get_store_value(store) {
424
+ let value;
425
+ subscribe(store, _ => value = _)();
426
+ return value;
427
+ }
428
+ function component_subscribe(component, store, callback) {
429
+ component.$$.on_destroy.push(subscribe(store, callback));
430
+ }
431
+ function detach$1(node) {
432
+ node.parentNode.removeChild(node);
433
+ }
434
+ function children$1(element) {
435
+ return Array.from(element.childNodes);
436
+ }
437
+
438
+ let current_component$1;
439
+ function set_current_component$1(component) {
440
+ current_component$1 = component;
441
+ }
442
+ function get_current_component$1() {
443
+ if (!current_component$1)
444
+ throw new Error('Function called outside component initialization');
445
+ return current_component$1;
446
+ }
447
+ function onDestroy(fn) {
448
+ get_current_component$1().$$.on_destroy.push(fn);
449
+ }
450
+
451
+ const dirty_components$1 = [];
452
+ const binding_callbacks$1 = [];
453
+ const render_callbacks$1 = [];
454
+ const flush_callbacks$1 = [];
455
+ const resolved_promise$1 = Promise.resolve();
456
+ let update_scheduled$1 = false;
457
+ function schedule_update$1() {
458
+ if (!update_scheduled$1) {
459
+ update_scheduled$1 = true;
460
+ resolved_promise$1.then(flush$1);
461
+ }
462
+ }
463
+ function add_render_callback$1(fn) {
464
+ render_callbacks$1.push(fn);
465
+ }
466
+ function add_flush_callback(fn) {
467
+ flush_callbacks$1.push(fn);
468
+ }
469
+ let flushing$1 = false;
470
+ const seen_callbacks$1 = new Set();
471
+ function flush$1() {
472
+ if (flushing$1)
473
+ return;
474
+ flushing$1 = true;
475
+ do {
476
+ // first, call beforeUpdate functions
477
+ // and update components
478
+ for (let i = 0; i < dirty_components$1.length; i += 1) {
479
+ const component = dirty_components$1[i];
480
+ set_current_component$1(component);
481
+ update$1(component.$$);
482
+ }
483
+ set_current_component$1(null);
484
+ dirty_components$1.length = 0;
485
+ while (binding_callbacks$1.length)
486
+ binding_callbacks$1.pop()();
487
+ // then, once components are updated, call
488
+ // afterUpdate functions. This may cause
489
+ // subsequent updates...
490
+ for (let i = 0; i < render_callbacks$1.length; i += 1) {
491
+ const callback = render_callbacks$1[i];
492
+ if (!seen_callbacks$1.has(callback)) {
493
+ // ...so guard against infinite loops
494
+ seen_callbacks$1.add(callback);
495
+ callback();
496
+ }
497
+ }
498
+ render_callbacks$1.length = 0;
499
+ } while (dirty_components$1.length);
500
+ while (flush_callbacks$1.length) {
501
+ flush_callbacks$1.pop()();
502
+ }
503
+ update_scheduled$1 = false;
504
+ flushing$1 = false;
505
+ seen_callbacks$1.clear();
506
+ }
507
+ function update$1($$) {
508
+ if ($$.fragment !== null) {
509
+ $$.update();
510
+ run_all$1($$.before_update);
511
+ const dirty = $$.dirty;
512
+ $$.dirty = [-1];
513
+ $$.fragment && $$.fragment.p($$.ctx, dirty);
514
+ $$.after_update.forEach(add_render_callback$1);
515
+ }
516
+ }
517
+ const outroing$1 = new Set();
518
+ let outros$1;
519
+ function transition_in$1(block, local) {
520
+ if (block && block.i) {
521
+ outroing$1.delete(block);
522
+ block.i(local);
523
+ }
524
+ }
525
+ function transition_out$1(block, local, detach, callback) {
526
+ if (block && block.o) {
527
+ if (outroing$1.has(block))
528
+ return;
529
+ outroing$1.add(block);
530
+ outros$1.c.push(() => {
531
+ outroing$1.delete(block);
532
+ if (callback) {
533
+ if (detach)
534
+ block.d(1);
535
+ callback();
536
+ }
537
+ });
538
+ block.o(local);
539
+ }
540
+ }
541
+
542
+ function bind(component, name, callback) {
543
+ const index = component.$$.props[name];
544
+ if (index !== undefined) {
545
+ component.$$.bound[index] = callback;
546
+ callback(component.$$.ctx[index]);
547
+ }
548
+ }
549
+ function create_component$1(block) {
550
+ block && block.c();
551
+ }
552
+ function mount_component$1(component, target, anchor, customElement) {
553
+ const { fragment, on_mount, on_destroy, after_update } = component.$$;
554
+ fragment && fragment.m(target, anchor);
555
+ if (!customElement) {
556
+ // onMount happens before the initial afterUpdate
557
+ add_render_callback$1(() => {
558
+ const new_on_destroy = on_mount.map(run$1).filter(is_function$1);
559
+ if (on_destroy) {
560
+ on_destroy.push(...new_on_destroy);
561
+ }
562
+ else {
563
+ // Edge case - component was destroyed immediately,
564
+ // most likely as a result of a binding initialising
565
+ run_all$1(new_on_destroy);
566
+ }
567
+ component.$$.on_mount = [];
568
+ });
569
+ }
570
+ after_update.forEach(add_render_callback$1);
571
+ }
572
+ function destroy_component$1(component, detaching) {
573
+ const $$ = component.$$;
574
+ if ($$.fragment !== null) {
575
+ run_all$1($$.on_destroy);
576
+ $$.fragment && $$.fragment.d(detaching);
577
+ // TODO null out other refs, including component.$$ (but need to
578
+ // preserve final state?)
579
+ $$.on_destroy = $$.fragment = null;
580
+ $$.ctx = [];
581
+ }
582
+ }
583
+ function make_dirty$1(component, i) {
584
+ if (component.$$.dirty[0] === -1) {
585
+ dirty_components$1.push(component);
586
+ schedule_update$1();
587
+ component.$$.dirty.fill(0);
588
+ }
589
+ component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
590
+ }
591
+ function init$1(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
592
+ const parent_component = current_component$1;
593
+ set_current_component$1(component);
594
+ const $$ = component.$$ = {
595
+ fragment: null,
596
+ ctx: null,
597
+ // state
598
+ props,
599
+ update: noop$1,
600
+ not_equal,
601
+ bound: blank_object$1(),
602
+ // lifecycle
603
+ on_mount: [],
604
+ on_destroy: [],
605
+ on_disconnect: [],
606
+ before_update: [],
607
+ after_update: [],
608
+ context: new Map(parent_component ? parent_component.$$.context : []),
609
+ // everything else
610
+ callbacks: blank_object$1(),
611
+ dirty,
612
+ skip_bound: false
613
+ };
614
+ let ready = false;
615
+ $$.ctx = instance
616
+ ? instance(component, options.props || {}, (i, ret, ...rest) => {
617
+ const value = rest.length ? rest[0] : ret;
618
+ if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
619
+ if (!$$.skip_bound && $$.bound[i])
620
+ $$.bound[i](value);
621
+ if (ready)
622
+ make_dirty$1(component, i);
623
+ }
624
+ return ret;
625
+ })
626
+ : [];
627
+ $$.update();
628
+ ready = true;
629
+ run_all$1($$.before_update);
630
+ // `false` as a special case of no DOM component
631
+ $$.fragment = create_fragment ? create_fragment($$.ctx) : false;
632
+ if (options.target) {
633
+ if (options.hydrate) {
634
+ const nodes = children$1(options.target);
635
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
636
+ $$.fragment && $$.fragment.l(nodes);
637
+ nodes.forEach(detach$1);
638
+ }
639
+ else {
640
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
641
+ $$.fragment && $$.fragment.c();
642
+ }
643
+ if (options.intro)
644
+ transition_in$1(component.$$.fragment);
645
+ mount_component$1(component, options.target, options.anchor, options.customElement);
646
+ flush$1();
647
+ }
648
+ set_current_component$1(parent_component);
649
+ }
650
+ /**
651
+ * Base class for Svelte components. Used when dev=false.
652
+ */
653
+ class SvelteComponent$1 {
654
+ $destroy() {
655
+ destroy_component$1(this, 1);
656
+ this.$destroy = noop$1;
657
+ }
658
+ $on(type, callback) {
659
+ const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
660
+ callbacks.push(callback);
661
+ return () => {
662
+ const index = callbacks.indexOf(callback);
663
+ if (index !== -1)
664
+ callbacks.splice(index, 1);
665
+ };
666
+ }
667
+ $set($$props) {
668
+ if (this.$$set && !is_empty$1($$props)) {
669
+ this.$$.skip_bound = true;
670
+ this.$$set($$props);
671
+ this.$$.skip_bound = false;
672
+ }
673
+ }
674
+ }
675
+
676
+ const subscriber_queue = [];
677
+ /**
678
+ * Create a `Writable` store that allows both updating and reading by subscription.
679
+ * @param {*=}value initial value
680
+ * @param {StartStopNotifier=}start start and stop notifications for subscriptions
681
+ */
682
+ function writable(value, start = noop$1) {
683
+ let stop;
684
+ const subscribers = [];
685
+ function set(new_value) {
686
+ if (safe_not_equal$1(value, new_value)) {
687
+ value = new_value;
688
+ if (stop) { // store is ready
689
+ const run_queue = !subscriber_queue.length;
690
+ for (let i = 0; i < subscribers.length; i += 1) {
691
+ const s = subscribers[i];
692
+ s[1]();
693
+ subscriber_queue.push(s, value);
694
+ }
695
+ if (run_queue) {
696
+ for (let i = 0; i < subscriber_queue.length; i += 2) {
697
+ subscriber_queue[i][0](subscriber_queue[i + 1]);
698
+ }
699
+ subscriber_queue.length = 0;
700
+ }
701
+ }
702
+ }
703
+ }
704
+ function update(fn) {
705
+ set(fn(value));
706
+ }
707
+ function subscribe(run, invalidate = noop$1) {
708
+ const subscriber = [run, invalidate];
709
+ subscribers.push(subscriber);
710
+ if (subscribers.length === 1) {
711
+ stop = start(set) || noop$1;
712
+ }
713
+ run(value);
714
+ return () => {
715
+ const index = subscribers.indexOf(subscriber);
716
+ if (index !== -1) {
717
+ subscribers.splice(index, 1);
718
+ }
719
+ if (subscribers.length === 0) {
720
+ stop();
721
+ stop = null;
722
+ }
723
+ };
724
+ }
725
+ return { set, update, subscribe };
726
+ }
727
+
728
+ const weekdays$1 = [
729
+ "sunday",
730
+ "monday",
731
+ "tuesday",
732
+ "wednesday",
733
+ "thursday",
734
+ "friday",
735
+ "saturday",
736
+ ];
737
+ const defaultSettings = Object.freeze({
738
+ shouldConfirmBeforeCreate: true,
739
+ weekStart: "locale",
740
+ wordsPerDot: DEFAULT_WORDS_PER_DOT,
741
+ showWeeklyNote: false,
742
+ weeklyNoteFormat: "",
743
+ weeklyNoteTemplate: "",
744
+ weeklyNoteFolder: "",
745
+ localeOverride: "system-default",
746
+ });
747
+ function appHasPeriodicNotesPluginLoaded() {
748
+ var _a, _b;
749
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
750
+ const periodicNotes = window.app.plugins.getPlugin("periodic-notes");
751
+ return periodicNotes && ((_b = (_a = periodicNotes.settings) === null || _a === void 0 ? void 0 : _a.weekly) === null || _b === void 0 ? void 0 : _b.enabled);
752
+ }
753
+ class CalendarSettingsTab extends obsidian.PluginSettingTab {
754
+ constructor(app, plugin) {
755
+ super(app, plugin);
756
+ this.plugin = plugin;
757
+ }
758
+ display() {
759
+ this.containerEl.empty();
760
+ if (!appHasDailyNotesPluginLoaded_1()) {
761
+ this.containerEl.createDiv("settings-banner", (banner) => {
762
+ banner.createEl("h3", {
763
+ text: "⚠️ Daily Notes plugin not enabled",
764
+ });
765
+ banner.createEl("p", {
766
+ cls: "setting-item-description",
767
+ text: "The calendar is best used in conjunction with either the Daily Notes plugin or the Periodic Notes plugin (available in the Community Plugins catalog).",
768
+ });
769
+ });
770
+ }
771
+ this.containerEl.createEl("h3", {
772
+ text: "General Settings",
773
+ });
774
+ this.addDotThresholdSetting();
775
+ this.addWeekStartSetting();
776
+ this.addConfirmCreateSetting();
777
+ this.addShowWeeklyNoteSetting();
778
+ if (this.plugin.options.showWeeklyNote &&
779
+ !appHasPeriodicNotesPluginLoaded()) {
780
+ this.containerEl.createEl("h3", {
781
+ text: "Weekly Note Settings",
782
+ });
783
+ this.containerEl.createEl("p", {
784
+ cls: "setting-item-description",
785
+ text: "Note: Weekly Note settings are moving. You are encouraged to install the 'Periodic Notes' plugin to keep the functionality in the future.",
786
+ });
787
+ this.addWeeklyNoteFormatSetting();
788
+ this.addWeeklyNoteTemplateSetting();
789
+ this.addWeeklyNoteFolderSetting();
790
+ }
791
+ this.containerEl.createEl("h3", {
792
+ text: "Advanced Settings",
793
+ });
794
+ this.addLocaleOverrideSetting();
795
+ }
796
+ addDotThresholdSetting() {
797
+ new obsidian.Setting(this.containerEl)
798
+ .setName("Words per dot")
799
+ .setDesc("How many words should be represented by a single dot?")
800
+ .addText((textfield) => {
801
+ textfield.setPlaceholder(String(DEFAULT_WORDS_PER_DOT));
802
+ textfield.inputEl.type = "number";
803
+ textfield.setValue(String(this.plugin.options.wordsPerDot));
804
+ textfield.onChange(async (value) => {
805
+ this.plugin.writeOptions(() => ({
806
+ wordsPerDot: value !== "" ? Number(value) : undefined,
807
+ }));
808
+ });
809
+ });
810
+ }
811
+ addWeekStartSetting() {
812
+ const { moment } = window;
813
+ const localizedWeekdays = moment.weekdays();
814
+ const localeWeekStartNum = window._bundledLocaleWeekSpec.dow;
815
+ const localeWeekStart = moment.weekdays()[localeWeekStartNum];
816
+ new obsidian.Setting(this.containerEl)
817
+ .setName("Start week on:")
818
+ .setDesc("Choose what day of the week to start. Select 'Locale default' to use the default specified by moment.js")
819
+ .addDropdown((dropdown) => {
820
+ dropdown.addOption("locale", `Locale default (${localeWeekStart})`);
821
+ localizedWeekdays.forEach((day, i) => {
822
+ dropdown.addOption(weekdays$1[i], day);
823
+ });
824
+ dropdown.setValue(this.plugin.options.weekStart);
825
+ dropdown.onChange(async (value) => {
826
+ this.plugin.writeOptions(() => ({
827
+ weekStart: value,
828
+ }));
829
+ });
830
+ });
831
+ }
832
+ addConfirmCreateSetting() {
833
+ new obsidian.Setting(this.containerEl)
834
+ .setName("Confirm before creating new note")
835
+ .setDesc("Show a confirmation modal before creating a new note")
836
+ .addToggle((toggle) => {
837
+ toggle.setValue(this.plugin.options.shouldConfirmBeforeCreate);
838
+ toggle.onChange(async (value) => {
839
+ this.plugin.writeOptions(() => ({
840
+ shouldConfirmBeforeCreate: value,
841
+ }));
842
+ });
843
+ });
844
+ }
845
+ addShowWeeklyNoteSetting() {
846
+ new obsidian.Setting(this.containerEl)
847
+ .setName("Show week number")
848
+ .setDesc("Enable this to add a column with the week number")
849
+ .addToggle((toggle) => {
850
+ toggle.setValue(this.plugin.options.showWeeklyNote);
851
+ toggle.onChange(async (value) => {
852
+ this.plugin.writeOptions(() => ({ showWeeklyNote: value }));
853
+ this.display(); // show/hide weekly settings
854
+ });
855
+ });
856
+ }
857
+ addWeeklyNoteFormatSetting() {
858
+ new obsidian.Setting(this.containerEl)
859
+ .setName("Weekly note format")
860
+ .setDesc("For more syntax help, refer to format reference")
861
+ .addText((textfield) => {
862
+ textfield.setValue(this.plugin.options.weeklyNoteFormat);
863
+ textfield.setPlaceholder(DEFAULT_WEEK_FORMAT);
864
+ textfield.onChange(async (value) => {
865
+ this.plugin.writeOptions(() => ({ weeklyNoteFormat: value }));
866
+ });
867
+ });
868
+ }
869
+ addWeeklyNoteTemplateSetting() {
870
+ new obsidian.Setting(this.containerEl)
871
+ .setName("Weekly note template")
872
+ .setDesc("Choose the file you want to use as the template for your weekly notes")
873
+ .addText((textfield) => {
874
+ textfield.setValue(this.plugin.options.weeklyNoteTemplate);
875
+ textfield.onChange(async (value) => {
876
+ this.plugin.writeOptions(() => ({ weeklyNoteTemplate: value }));
877
+ });
878
+ });
879
+ }
880
+ addWeeklyNoteFolderSetting() {
881
+ new obsidian.Setting(this.containerEl)
882
+ .setName("Weekly note folder")
883
+ .setDesc("New weekly notes will be placed here")
884
+ .addText((textfield) => {
885
+ textfield.setValue(this.plugin.options.weeklyNoteFolder);
886
+ textfield.onChange(async (value) => {
887
+ this.plugin.writeOptions(() => ({ weeklyNoteFolder: value }));
888
+ });
889
+ });
890
+ }
891
+ addLocaleOverrideSetting() {
892
+ var _a;
893
+ const { moment } = window;
894
+ const sysLocale = (_a = navigator.language) === null || _a === void 0 ? void 0 : _a.toLowerCase();
895
+ new obsidian.Setting(this.containerEl)
896
+ .setName("Override locale:")
897
+ .setDesc("Set this if you want to use a locale different from the default")
898
+ .addDropdown((dropdown) => {
899
+ dropdown.addOption("system-default", `Same as system (${sysLocale})`);
900
+ moment.locales().forEach((locale) => {
901
+ dropdown.addOption(locale, locale);
902
+ });
903
+ dropdown.setValue(this.plugin.options.localeOverride);
904
+ dropdown.onChange(async (value) => {
905
+ this.plugin.writeOptions(() => ({
906
+ localeOverride: value,
907
+ }));
908
+ });
909
+ });
910
+ }
911
+ }
912
+
913
+ const classList = (obj) => {
914
+ return Object.entries(obj)
915
+ .filter(([_k, v]) => !!v)
916
+ .map(([k, _k]) => k);
917
+ };
918
+ function clamp(num, lowerBound, upperBound) {
919
+ return Math.min(Math.max(lowerBound, num), upperBound);
920
+ }
921
+ function partition(arr, predicate) {
922
+ const pass = [];
923
+ const fail = [];
924
+ arr.forEach((elem) => {
925
+ if (predicate(elem)) {
926
+ pass.push(elem);
927
+ }
928
+ else {
929
+ fail.push(elem);
930
+ }
931
+ });
932
+ return [pass, fail];
933
+ }
934
+ /**
935
+ * Lookup the dateUID for a given file. It compares the filename
936
+ * to the daily and weekly note formats to find a match.
937
+ *
938
+ * @param file
939
+ */
940
+ function getDateUIDFromFile(file) {
941
+ if (!file) {
942
+ return null;
943
+ }
944
+ // TODO: I'm not checking the path!
945
+ let date = getDateFromFile_1(file, "day");
946
+ if (date) {
947
+ return getDateUID_1$1(date, "day");
948
+ }
949
+ date = getDateFromFile_1(file, "week");
950
+ if (date) {
951
+ return getDateUID_1$1(date, "week");
952
+ }
953
+ return null;
954
+ }
955
+ function getWordCount(text) {
956
+ const spaceDelimitedChars = /A-Za-z\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC/
957
+ .source;
958
+ const nonSpaceDelimitedWords = /\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u4E00-\u9FD5/
959
+ .source;
960
+ const pattern = new RegExp([
961
+ `(?:[0-9]+(?:(?:,|\\.)[0-9]+)*|[\\-${spaceDelimitedChars}])+`,
962
+ nonSpaceDelimitedWords,
963
+ ].join("|"), "g");
964
+ return (text.match(pattern) || []).length;
965
+ }
966
+
967
+ function createDailyNotesStore() {
968
+ let hasError = false;
969
+ const store = writable(null);
970
+ return Object.assign({ reindex: () => {
971
+ try {
972
+ const dailyNotes = getAllDailyNotes_1();
973
+ store.set(dailyNotes);
974
+ hasError = false;
975
+ }
976
+ catch (err) {
977
+ if (!hasError) {
978
+ // Avoid error being shown multiple times
979
+ console.log("[Calendar] Failed to find daily notes folder", err);
980
+ }
981
+ store.set({});
982
+ hasError = true;
983
+ }
984
+ } }, store);
985
+ }
986
+ function createWeeklyNotesStore() {
987
+ let hasError = false;
988
+ const store = writable(null);
989
+ return Object.assign({ reindex: () => {
990
+ try {
991
+ const weeklyNotes = getAllWeeklyNotes_1();
992
+ store.set(weeklyNotes);
993
+ hasError = false;
994
+ }
995
+ catch (err) {
996
+ if (!hasError) {
997
+ // Avoid error being shown multiple times
998
+ console.log("[Calendar] Failed to find weekly notes folder", err);
999
+ }
1000
+ store.set({});
1001
+ hasError = true;
1002
+ }
1003
+ } }, store);
1004
+ }
1005
+ const settings = writable(defaultSettings);
1006
+ const dailyNotes = createDailyNotesStore();
1007
+ const weeklyNotes = createWeeklyNotesStore();
1008
+ function createSelectedFileStore() {
1009
+ const store = writable(null);
1010
+ return Object.assign({ setFile: (file) => {
1011
+ const id = getDateUIDFromFile(file);
1012
+ store.set(id);
1013
+ } }, store);
1014
+ }
1015
+ const activeFile = createSelectedFileStore();
1016
+
1017
+ class ConfirmationModal extends obsidian.Modal {
1018
+ constructor(app, config) {
1019
+ super(app);
1020
+ const { cta, onAccept, text, title } = config;
1021
+ this.contentEl.createEl("h2", { text: title });
1022
+ this.contentEl.createEl("p", { text });
1023
+ this.contentEl.createDiv("modal-button-container", (buttonsEl) => {
1024
+ buttonsEl
1025
+ .createEl("button", { text: "Never mind" })
1026
+ .addEventListener("click", () => this.close());
1027
+ buttonsEl
1028
+ .createEl("button", {
1029
+ cls: "mod-cta",
1030
+ text: cta,
1031
+ })
1032
+ .addEventListener("click", async (e) => {
1033
+ await onAccept(e);
1034
+ this.close();
1035
+ });
1036
+ });
1037
+ }
1038
+ }
1039
+ function createConfirmationDialog({ cta, onAccept, text, title, }) {
1040
+ new ConfirmationModal(window.app, { cta, onAccept, text, title }).open();
1041
+ }
1042
+
1043
+ /**
1044
+ * Create a Daily Note for a given date.
1045
+ */
1046
+ async function tryToCreateDailyNote(date, inNewSplit, settings, cb) {
1047
+ const { workspace } = window.app;
1048
+ const { format } = getDailyNoteSettings_1();
1049
+ const filename = date.format(format);
1050
+ const createFile = async () => {
1051
+ const dailyNote = await createDailyNote_1(date);
1052
+ const leaf = inNewSplit
1053
+ ? workspace.splitActiveLeaf()
1054
+ : workspace.getUnpinnedLeaf();
1055
+ await leaf.openFile(dailyNote);
1056
+ cb === null || cb === void 0 ? void 0 : cb(dailyNote);
1057
+ };
1058
+ if (settings.shouldConfirmBeforeCreate) {
1059
+ createConfirmationDialog({
1060
+ cta: "Create",
1061
+ onAccept: createFile,
1062
+ text: `File ${filename} does not exist. Would you like to create it?`,
1063
+ title: "New Daily Note",
1064
+ });
1065
+ }
1066
+ else {
1067
+ await createFile();
1068
+ }
1069
+ }
1070
+
1071
+ /**
1072
+ * Create a Weekly Note for a given date.
1073
+ */
1074
+ async function tryToCreateWeeklyNote(date, inNewSplit, settings, cb) {
1075
+ const { workspace } = window.app;
1076
+ const { format } = getWeeklyNoteSettings_1();
1077
+ const filename = date.format(format);
1078
+ const createFile = async () => {
1079
+ const dailyNote = await createWeeklyNote_1(date);
1080
+ const leaf = inNewSplit
1081
+ ? workspace.splitActiveLeaf()
1082
+ : workspace.getUnpinnedLeaf();
1083
+ await leaf.openFile(dailyNote);
1084
+ cb === null || cb === void 0 ? void 0 : cb(dailyNote);
1085
+ };
1086
+ if (settings.shouldConfirmBeforeCreate) {
1087
+ createConfirmationDialog({
1088
+ cta: "Create",
1089
+ onAccept: createFile,
1090
+ text: `File ${filename} does not exist. Would you like to create it?`,
1091
+ title: "New Weekly Note",
1092
+ });
1093
+ }
1094
+ else {
1095
+ await createFile();
1096
+ }
1097
+ }
1098
+
1099
+ function noop() { }
1100
+ function assign(tar, src) {
1101
+ // @ts-ignore
1102
+ for (const k in src)
1103
+ tar[k] = src[k];
1104
+ return tar;
1105
+ }
1106
+ function is_promise(value) {
1107
+ return value && typeof value === 'object' && typeof value.then === 'function';
1108
+ }
1109
+ function run(fn) {
1110
+ return fn();
1111
+ }
1112
+ function blank_object() {
1113
+ return Object.create(null);
1114
+ }
1115
+ function run_all(fns) {
1116
+ fns.forEach(run);
1117
+ }
1118
+ function is_function(thing) {
1119
+ return typeof thing === 'function';
1120
+ }
1121
+ function safe_not_equal(a, b) {
1122
+ return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
1123
+ }
1124
+ function not_equal(a, b) {
1125
+ return a != a ? b == b : a !== b;
1126
+ }
1127
+ function is_empty(obj) {
1128
+ return Object.keys(obj).length === 0;
1129
+ }
1130
+ function create_slot(definition, ctx, $$scope, fn) {
1131
+ if (definition) {
1132
+ const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);
1133
+ return definition[0](slot_ctx);
1134
+ }
1135
+ }
1136
+ function get_slot_context(definition, ctx, $$scope, fn) {
1137
+ return definition[1] && fn
1138
+ ? assign($$scope.ctx.slice(), definition[1](fn(ctx)))
1139
+ : $$scope.ctx;
1140
+ }
1141
+ function get_slot_changes(definition, $$scope, dirty, fn) {
1142
+ if (definition[2] && fn) {
1143
+ const lets = definition[2](fn(dirty));
1144
+ if ($$scope.dirty === undefined) {
1145
+ return lets;
1146
+ }
1147
+ if (typeof lets === 'object') {
1148
+ const merged = [];
1149
+ const len = Math.max($$scope.dirty.length, lets.length);
1150
+ for (let i = 0; i < len; i += 1) {
1151
+ merged[i] = $$scope.dirty[i] | lets[i];
1152
+ }
1153
+ return merged;
1154
+ }
1155
+ return $$scope.dirty | lets;
1156
+ }
1157
+ return $$scope.dirty;
1158
+ }
1159
+ function update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {
1160
+ const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);
1161
+ if (slot_changes) {
1162
+ const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
1163
+ slot.p(slot_context, slot_changes);
1164
+ }
1165
+ }
1166
+ function null_to_empty(value) {
1167
+ return value == null ? '' : value;
1168
+ }
1169
+
1170
+ function append(target, node) {
1171
+ target.appendChild(node);
1172
+ }
1173
+ function insert(target, node, anchor) {
1174
+ target.insertBefore(node, anchor || null);
1175
+ }
1176
+ function detach(node) {
1177
+ node.parentNode.removeChild(node);
1178
+ }
1179
+ function destroy_each(iterations, detaching) {
1180
+ for (let i = 0; i < iterations.length; i += 1) {
1181
+ if (iterations[i])
1182
+ iterations[i].d(detaching);
1183
+ }
1184
+ }
1185
+ function element(name) {
1186
+ return document.createElement(name);
1187
+ }
1188
+ function svg_element(name) {
1189
+ return document.createElementNS('http://www.w3.org/2000/svg', name);
1190
+ }
1191
+ function text(data) {
1192
+ return document.createTextNode(data);
1193
+ }
1194
+ function space() {
1195
+ return text(' ');
1196
+ }
1197
+ function empty() {
1198
+ return text('');
1199
+ }
1200
+ function listen(node, event, handler, options) {
1201
+ node.addEventListener(event, handler, options);
1202
+ return () => node.removeEventListener(event, handler, options);
1203
+ }
1204
+ function attr(node, attribute, value) {
1205
+ if (value == null)
1206
+ node.removeAttribute(attribute);
1207
+ else if (node.getAttribute(attribute) !== value)
1208
+ node.setAttribute(attribute, value);
1209
+ }
1210
+ function set_attributes(node, attributes) {
1211
+ // @ts-ignore
1212
+ const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);
1213
+ for (const key in attributes) {
1214
+ if (attributes[key] == null) {
1215
+ node.removeAttribute(key);
1216
+ }
1217
+ else if (key === 'style') {
1218
+ node.style.cssText = attributes[key];
1219
+ }
1220
+ else if (key === '__value') {
1221
+ node.value = node[key] = attributes[key];
1222
+ }
1223
+ else if (descriptors[key] && descriptors[key].set) {
1224
+ node[key] = attributes[key];
1225
+ }
1226
+ else {
1227
+ attr(node, key, attributes[key]);
1228
+ }
1229
+ }
1230
+ }
1231
+ function children(element) {
1232
+ return Array.from(element.childNodes);
1233
+ }
1234
+ function set_data(text, data) {
1235
+ data = '' + data;
1236
+ if (text.wholeText !== data)
1237
+ text.data = data;
1238
+ }
1239
+ function toggle_class(element, name, toggle) {
1240
+ element.classList[toggle ? 'add' : 'remove'](name);
1241
+ }
1242
+
1243
+ let current_component;
1244
+ function set_current_component(component) {
1245
+ current_component = component;
1246
+ }
1247
+ function get_current_component() {
1248
+ if (!current_component)
1249
+ throw new Error('Function called outside component initialization');
1250
+ return current_component;
1251
+ }
1252
+
1253
+ const dirty_components = [];
1254
+ const binding_callbacks = [];
1255
+ const render_callbacks = [];
1256
+ const flush_callbacks = [];
1257
+ const resolved_promise = Promise.resolve();
1258
+ let update_scheduled = false;
1259
+ function schedule_update() {
1260
+ if (!update_scheduled) {
1261
+ update_scheduled = true;
1262
+ resolved_promise.then(flush);
1263
+ }
1264
+ }
1265
+ function add_render_callback(fn) {
1266
+ render_callbacks.push(fn);
1267
+ }
1268
+ let flushing = false;
1269
+ const seen_callbacks = new Set();
1270
+ function flush() {
1271
+ if (flushing)
1272
+ return;
1273
+ flushing = true;
1274
+ do {
1275
+ // first, call beforeUpdate functions
1276
+ // and update components
1277
+ for (let i = 0; i < dirty_components.length; i += 1) {
1278
+ const component = dirty_components[i];
1279
+ set_current_component(component);
1280
+ update(component.$$);
1281
+ }
1282
+ set_current_component(null);
1283
+ dirty_components.length = 0;
1284
+ while (binding_callbacks.length)
1285
+ binding_callbacks.pop()();
1286
+ // then, once components are updated, call
1287
+ // afterUpdate functions. This may cause
1288
+ // subsequent updates...
1289
+ for (let i = 0; i < render_callbacks.length; i += 1) {
1290
+ const callback = render_callbacks[i];
1291
+ if (!seen_callbacks.has(callback)) {
1292
+ // ...so guard against infinite loops
1293
+ seen_callbacks.add(callback);
1294
+ callback();
1295
+ }
1296
+ }
1297
+ render_callbacks.length = 0;
1298
+ } while (dirty_components.length);
1299
+ while (flush_callbacks.length) {
1300
+ flush_callbacks.pop()();
1301
+ }
1302
+ update_scheduled = false;
1303
+ flushing = false;
1304
+ seen_callbacks.clear();
1305
+ }
1306
+ function update($$) {
1307
+ if ($$.fragment !== null) {
1308
+ $$.update();
1309
+ run_all($$.before_update);
1310
+ const dirty = $$.dirty;
1311
+ $$.dirty = [-1];
1312
+ $$.fragment && $$.fragment.p($$.ctx, dirty);
1313
+ $$.after_update.forEach(add_render_callback);
1314
+ }
1315
+ }
1316
+ const outroing = new Set();
1317
+ let outros;
1318
+ function group_outros() {
1319
+ outros = {
1320
+ r: 0,
1321
+ c: [],
1322
+ p: outros // parent group
1323
+ };
1324
+ }
1325
+ function check_outros() {
1326
+ if (!outros.r) {
1327
+ run_all(outros.c);
1328
+ }
1329
+ outros = outros.p;
1330
+ }
1331
+ function transition_in(block, local) {
1332
+ if (block && block.i) {
1333
+ outroing.delete(block);
1334
+ block.i(local);
1335
+ }
1336
+ }
1337
+ function transition_out(block, local, detach, callback) {
1338
+ if (block && block.o) {
1339
+ if (outroing.has(block))
1340
+ return;
1341
+ outroing.add(block);
1342
+ outros.c.push(() => {
1343
+ outroing.delete(block);
1344
+ if (callback) {
1345
+ if (detach)
1346
+ block.d(1);
1347
+ callback();
1348
+ }
1349
+ });
1350
+ block.o(local);
1351
+ }
1352
+ }
1353
+
1354
+ function handle_promise(promise, info) {
1355
+ const token = info.token = {};
1356
+ function update(type, index, key, value) {
1357
+ if (info.token !== token)
1358
+ return;
1359
+ info.resolved = value;
1360
+ let child_ctx = info.ctx;
1361
+ if (key !== undefined) {
1362
+ child_ctx = child_ctx.slice();
1363
+ child_ctx[key] = value;
1364
+ }
1365
+ const block = type && (info.current = type)(child_ctx);
1366
+ let needs_flush = false;
1367
+ if (info.block) {
1368
+ if (info.blocks) {
1369
+ info.blocks.forEach((block, i) => {
1370
+ if (i !== index && block) {
1371
+ group_outros();
1372
+ transition_out(block, 1, 1, () => {
1373
+ if (info.blocks[i] === block) {
1374
+ info.blocks[i] = null;
1375
+ }
1376
+ });
1377
+ check_outros();
1378
+ }
1379
+ });
1380
+ }
1381
+ else {
1382
+ info.block.d(1);
1383
+ }
1384
+ block.c();
1385
+ transition_in(block, 1);
1386
+ block.m(info.mount(), info.anchor);
1387
+ needs_flush = true;
1388
+ }
1389
+ info.block = block;
1390
+ if (info.blocks)
1391
+ info.blocks[index] = block;
1392
+ if (needs_flush) {
1393
+ flush();
1394
+ }
1395
+ }
1396
+ if (is_promise(promise)) {
1397
+ const current_component = get_current_component();
1398
+ promise.then(value => {
1399
+ set_current_component(current_component);
1400
+ update(info.then, 1, info.value, value);
1401
+ set_current_component(null);
1402
+ }, error => {
1403
+ set_current_component(current_component);
1404
+ update(info.catch, 2, info.error, error);
1405
+ set_current_component(null);
1406
+ if (!info.hasCatch) {
1407
+ throw error;
1408
+ }
1409
+ });
1410
+ // if we previously had a then/catch block, destroy it
1411
+ if (info.current !== info.pending) {
1412
+ update(info.pending, 0);
1413
+ return true;
1414
+ }
1415
+ }
1416
+ else {
1417
+ if (info.current !== info.then) {
1418
+ update(info.then, 1, info.value, promise);
1419
+ return true;
1420
+ }
1421
+ info.resolved = promise;
1422
+ }
1423
+ }
1424
+ function outro_and_destroy_block(block, lookup) {
1425
+ transition_out(block, 1, 1, () => {
1426
+ lookup.delete(block.key);
1427
+ });
1428
+ }
1429
+ function update_keyed_each(old_blocks, dirty, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, next, get_context) {
1430
+ let o = old_blocks.length;
1431
+ let n = list.length;
1432
+ let i = o;
1433
+ const old_indexes = {};
1434
+ while (i--)
1435
+ old_indexes[old_blocks[i].key] = i;
1436
+ const new_blocks = [];
1437
+ const new_lookup = new Map();
1438
+ const deltas = new Map();
1439
+ i = n;
1440
+ while (i--) {
1441
+ const child_ctx = get_context(ctx, list, i);
1442
+ const key = get_key(child_ctx);
1443
+ let block = lookup.get(key);
1444
+ if (!block) {
1445
+ block = create_each_block(key, child_ctx);
1446
+ block.c();
1447
+ }
1448
+ else if (dynamic) {
1449
+ block.p(child_ctx, dirty);
1450
+ }
1451
+ new_lookup.set(key, new_blocks[i] = block);
1452
+ if (key in old_indexes)
1453
+ deltas.set(key, Math.abs(i - old_indexes[key]));
1454
+ }
1455
+ const will_move = new Set();
1456
+ const did_move = new Set();
1457
+ function insert(block) {
1458
+ transition_in(block, 1);
1459
+ block.m(node, next);
1460
+ lookup.set(block.key, block);
1461
+ next = block.first;
1462
+ n--;
1463
+ }
1464
+ while (o && n) {
1465
+ const new_block = new_blocks[n - 1];
1466
+ const old_block = old_blocks[o - 1];
1467
+ const new_key = new_block.key;
1468
+ const old_key = old_block.key;
1469
+ if (new_block === old_block) {
1470
+ // do nothing
1471
+ next = new_block.first;
1472
+ o--;
1473
+ n--;
1474
+ }
1475
+ else if (!new_lookup.has(old_key)) {
1476
+ // remove old block
1477
+ destroy(old_block, lookup);
1478
+ o--;
1479
+ }
1480
+ else if (!lookup.has(new_key) || will_move.has(new_key)) {
1481
+ insert(new_block);
1482
+ }
1483
+ else if (did_move.has(old_key)) {
1484
+ o--;
1485
+ }
1486
+ else if (deltas.get(new_key) > deltas.get(old_key)) {
1487
+ did_move.add(new_key);
1488
+ insert(new_block);
1489
+ }
1490
+ else {
1491
+ will_move.add(old_key);
1492
+ o--;
1493
+ }
1494
+ }
1495
+ while (o--) {
1496
+ const old_block = old_blocks[o];
1497
+ if (!new_lookup.has(old_block.key))
1498
+ destroy(old_block, lookup);
1499
+ }
1500
+ while (n)
1501
+ insert(new_blocks[n - 1]);
1502
+ return new_blocks;
1503
+ }
1504
+
1505
+ function get_spread_update(levels, updates) {
1506
+ const update = {};
1507
+ const to_null_out = {};
1508
+ const accounted_for = { $$scope: 1 };
1509
+ let i = levels.length;
1510
+ while (i--) {
1511
+ const o = levels[i];
1512
+ const n = updates[i];
1513
+ if (n) {
1514
+ for (const key in o) {
1515
+ if (!(key in n))
1516
+ to_null_out[key] = 1;
1517
+ }
1518
+ for (const key in n) {
1519
+ if (!accounted_for[key]) {
1520
+ update[key] = n[key];
1521
+ accounted_for[key] = 1;
1522
+ }
1523
+ }
1524
+ levels[i] = n;
1525
+ }
1526
+ else {
1527
+ for (const key in o) {
1528
+ accounted_for[key] = 1;
1529
+ }
1530
+ }
1531
+ }
1532
+ for (const key in to_null_out) {
1533
+ if (!(key in update))
1534
+ update[key] = undefined;
1535
+ }
1536
+ return update;
1537
+ }
1538
+ function get_spread_object(spread_props) {
1539
+ return typeof spread_props === 'object' && spread_props !== null ? spread_props : {};
1540
+ }
1541
+ function create_component(block) {
1542
+ block && block.c();
1543
+ }
1544
+ function mount_component(component, target, anchor, customElement) {
1545
+ const { fragment, on_mount, on_destroy, after_update } = component.$$;
1546
+ fragment && fragment.m(target, anchor);
1547
+ if (!customElement) {
1548
+ // onMount happens before the initial afterUpdate
1549
+ add_render_callback(() => {
1550
+ const new_on_destroy = on_mount.map(run).filter(is_function);
1551
+ if (on_destroy) {
1552
+ on_destroy.push(...new_on_destroy);
1553
+ }
1554
+ else {
1555
+ // Edge case - component was destroyed immediately,
1556
+ // most likely as a result of a binding initialising
1557
+ run_all(new_on_destroy);
1558
+ }
1559
+ component.$$.on_mount = [];
1560
+ });
1561
+ }
1562
+ after_update.forEach(add_render_callback);
1563
+ }
1564
+ function destroy_component(component, detaching) {
1565
+ const $$ = component.$$;
1566
+ if ($$.fragment !== null) {
1567
+ run_all($$.on_destroy);
1568
+ $$.fragment && $$.fragment.d(detaching);
1569
+ // TODO null out other refs, including component.$$ (but need to
1570
+ // preserve final state?)
1571
+ $$.on_destroy = $$.fragment = null;
1572
+ $$.ctx = [];
1573
+ }
1574
+ }
1575
+ function make_dirty(component, i) {
1576
+ if (component.$$.dirty[0] === -1) {
1577
+ dirty_components.push(component);
1578
+ schedule_update();
1579
+ component.$$.dirty.fill(0);
1580
+ }
1581
+ component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
1582
+ }
1583
+ function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
1584
+ const parent_component = current_component;
1585
+ set_current_component(component);
1586
+ const $$ = component.$$ = {
1587
+ fragment: null,
1588
+ ctx: null,
1589
+ // state
1590
+ props,
1591
+ update: noop,
1592
+ not_equal,
1593
+ bound: blank_object(),
1594
+ // lifecycle
1595
+ on_mount: [],
1596
+ on_destroy: [],
1597
+ on_disconnect: [],
1598
+ before_update: [],
1599
+ after_update: [],
1600
+ context: new Map(parent_component ? parent_component.$$.context : []),
1601
+ // everything else
1602
+ callbacks: blank_object(),
1603
+ dirty,
1604
+ skip_bound: false
1605
+ };
1606
+ let ready = false;
1607
+ $$.ctx = instance
1608
+ ? instance(component, options.props || {}, (i, ret, ...rest) => {
1609
+ const value = rest.length ? rest[0] : ret;
1610
+ if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
1611
+ if (!$$.skip_bound && $$.bound[i])
1612
+ $$.bound[i](value);
1613
+ if (ready)
1614
+ make_dirty(component, i);
1615
+ }
1616
+ return ret;
1617
+ })
1618
+ : [];
1619
+ $$.update();
1620
+ ready = true;
1621
+ run_all($$.before_update);
1622
+ // `false` as a special case of no DOM component
1623
+ $$.fragment = create_fragment ? create_fragment($$.ctx) : false;
1624
+ if (options.target) {
1625
+ if (options.hydrate) {
1626
+ const nodes = children(options.target);
1627
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1628
+ $$.fragment && $$.fragment.l(nodes);
1629
+ nodes.forEach(detach);
1630
+ }
1631
+ else {
1632
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1633
+ $$.fragment && $$.fragment.c();
1634
+ }
1635
+ if (options.intro)
1636
+ transition_in(component.$$.fragment);
1637
+ mount_component(component, options.target, options.anchor, options.customElement);
1638
+ flush();
1639
+ }
1640
+ set_current_component(parent_component);
1641
+ }
1642
+ /**
1643
+ * Base class for Svelte components. Used when dev=false.
1644
+ */
1645
+ class SvelteComponent {
1646
+ $destroy() {
1647
+ destroy_component(this, 1);
1648
+ this.$destroy = noop;
1649
+ }
1650
+ $on(type, callback) {
1651
+ const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
1652
+ callbacks.push(callback);
1653
+ return () => {
1654
+ const index = callbacks.indexOf(callback);
1655
+ if (index !== -1)
1656
+ callbacks.splice(index, 1);
1657
+ };
1658
+ }
1659
+ $set($$props) {
1660
+ if (this.$$set && !is_empty($$props)) {
1661
+ this.$$.skip_bound = true;
1662
+ this.$$set($$props);
1663
+ this.$$.skip_bound = false;
1664
+ }
1665
+ }
1666
+ }
1667
+
1668
+ /**
1669
+ * dateUID is a way of weekly identifying daily/weekly/monthly notes.
1670
+ * They are prefixed with the granularity to avoid ambiguity.
1671
+ */
1672
+ function getDateUID(date, granularity = "day") {
1673
+ const ts = date.clone().startOf(granularity).format();
1674
+ return `${granularity}-${ts}`;
1675
+ }
1676
+ var getDateUID_1 = getDateUID;
1677
+
1678
+ /* src/components/Dot.svelte generated by Svelte v3.35.0 */
1679
+
1680
+ function add_css$5() {
1681
+ var style = element("style");
1682
+ style.id = "svelte-1widvzq-style";
1683
+ style.textContent = ".dot.svelte-1widvzq,.hollow.svelte-1widvzq{display:inline-block;height:6px;width:6px;margin:0 1px}.filled.svelte-1widvzq{fill:var(--color-dot)}.active.filled.svelte-1widvzq{fill:var(--text-on-accent)}.hollow.svelte-1widvzq{fill:none;stroke:var(--color-dot)}.active.hollow.svelte-1widvzq{fill:none;stroke:var(--text-on-accent)}";
1684
+ append(document.head, style);
1685
+ }
1686
+
1687
+ // (14:0) {:else}
1688
+ function create_else_block$1(ctx) {
1689
+ let svg;
1690
+ let circle;
1691
+ let svg_class_value;
1692
+
1693
+ return {
1694
+ c() {
1695
+ svg = svg_element("svg");
1696
+ circle = svg_element("circle");
1697
+ attr(circle, "cx", "3");
1698
+ attr(circle, "cy", "3");
1699
+ attr(circle, "r", "2");
1700
+ attr(svg, "class", svg_class_value = "" + (null_to_empty(`hollow ${/*className*/ ctx[0]}`) + " svelte-1widvzq"));
1701
+ attr(svg, "viewBox", "0 0 6 6");
1702
+ attr(svg, "xmlns", "http://www.w3.org/2000/svg");
1703
+ toggle_class(svg, "active", /*isActive*/ ctx[2]);
1704
+ },
1705
+ m(target, anchor) {
1706
+ insert(target, svg, anchor);
1707
+ append(svg, circle);
1708
+ },
1709
+ p(ctx, dirty) {
1710
+ if (dirty & /*className*/ 1 && svg_class_value !== (svg_class_value = "" + (null_to_empty(`hollow ${/*className*/ ctx[0]}`) + " svelte-1widvzq"))) {
1711
+ attr(svg, "class", svg_class_value);
1712
+ }
1713
+
1714
+ if (dirty & /*className, isActive*/ 5) {
1715
+ toggle_class(svg, "active", /*isActive*/ ctx[2]);
1716
+ }
1717
+ },
1718
+ d(detaching) {
1719
+ if (detaching) detach(svg);
1720
+ }
1721
+ };
1722
+ }
1723
+
1724
+ // (6:0) {#if isFilled}
1725
+ function create_if_block$2(ctx) {
1726
+ let svg;
1727
+ let circle;
1728
+ let svg_class_value;
1729
+
1730
+ return {
1731
+ c() {
1732
+ svg = svg_element("svg");
1733
+ circle = svg_element("circle");
1734
+ attr(circle, "cx", "3");
1735
+ attr(circle, "cy", "3");
1736
+ attr(circle, "r", "2");
1737
+ attr(svg, "class", svg_class_value = "" + (null_to_empty(`dot filled ${/*className*/ ctx[0]}`) + " svelte-1widvzq"));
1738
+ attr(svg, "viewBox", "0 0 6 6");
1739
+ attr(svg, "xmlns", "http://www.w3.org/2000/svg");
1740
+ toggle_class(svg, "active", /*isActive*/ ctx[2]);
1741
+ },
1742
+ m(target, anchor) {
1743
+ insert(target, svg, anchor);
1744
+ append(svg, circle);
1745
+ },
1746
+ p(ctx, dirty) {
1747
+ if (dirty & /*className*/ 1 && svg_class_value !== (svg_class_value = "" + (null_to_empty(`dot filled ${/*className*/ ctx[0]}`) + " svelte-1widvzq"))) {
1748
+ attr(svg, "class", svg_class_value);
1749
+ }
1750
+
1751
+ if (dirty & /*className, isActive*/ 5) {
1752
+ toggle_class(svg, "active", /*isActive*/ ctx[2]);
1753
+ }
1754
+ },
1755
+ d(detaching) {
1756
+ if (detaching) detach(svg);
1757
+ }
1758
+ };
1759
+ }
1760
+
1761
+ function create_fragment$6(ctx) {
1762
+ let if_block_anchor;
1763
+
1764
+ function select_block_type(ctx, dirty) {
1765
+ if (/*isFilled*/ ctx[1]) return create_if_block$2;
1766
+ return create_else_block$1;
1767
+ }
1768
+
1769
+ let current_block_type = select_block_type(ctx);
1770
+ let if_block = current_block_type(ctx);
1771
+
1772
+ return {
1773
+ c() {
1774
+ if_block.c();
1775
+ if_block_anchor = empty();
1776
+ },
1777
+ m(target, anchor) {
1778
+ if_block.m(target, anchor);
1779
+ insert(target, if_block_anchor, anchor);
1780
+ },
1781
+ p(ctx, [dirty]) {
1782
+ if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) {
1783
+ if_block.p(ctx, dirty);
1784
+ } else {
1785
+ if_block.d(1);
1786
+ if_block = current_block_type(ctx);
1787
+
1788
+ if (if_block) {
1789
+ if_block.c();
1790
+ if_block.m(if_block_anchor.parentNode, if_block_anchor);
1791
+ }
1792
+ }
1793
+ },
1794
+ i: noop,
1795
+ o: noop,
1796
+ d(detaching) {
1797
+ if_block.d(detaching);
1798
+ if (detaching) detach(if_block_anchor);
1799
+ }
1800
+ };
1801
+ }
1802
+
1803
+ function instance$6($$self, $$props, $$invalidate) {
1804
+ let { className = "" } = $$props;
1805
+ let { isFilled } = $$props;
1806
+ let { isActive } = $$props;
1807
+
1808
+ $$self.$$set = $$props => {
1809
+ if ("className" in $$props) $$invalidate(0, className = $$props.className);
1810
+ if ("isFilled" in $$props) $$invalidate(1, isFilled = $$props.isFilled);
1811
+ if ("isActive" in $$props) $$invalidate(2, isActive = $$props.isActive);
1812
+ };
1813
+
1814
+ return [className, isFilled, isActive];
1815
+ }
1816
+
1817
+ class Dot extends SvelteComponent {
1818
+ constructor(options) {
1819
+ super();
1820
+ if (!document.getElementById("svelte-1widvzq-style")) add_css$5();
1821
+ init(this, options, instance$6, create_fragment$6, safe_not_equal, { className: 0, isFilled: 1, isActive: 2 });
1822
+ }
1823
+ }
1824
+
1825
+ /* src/components/MetadataResolver.svelte generated by Svelte v3.35.0 */
1826
+
1827
+ const get_default_slot_changes_1 = dirty => ({});
1828
+ const get_default_slot_context_1 = ctx => ({ metadata: null });
1829
+ const get_default_slot_changes = dirty => ({ metadata: dirty & /*metadata*/ 1 });
1830
+ const get_default_slot_context = ctx => ({ metadata: /*resolvedMeta*/ ctx[3] });
1831
+
1832
+ // (11:0) {:else}
1833
+ function create_else_block(ctx) {
1834
+ let current;
1835
+ const default_slot_template = /*#slots*/ ctx[2].default;
1836
+ const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[1], get_default_slot_context_1);
1837
+
1838
+ return {
1839
+ c() {
1840
+ if (default_slot) default_slot.c();
1841
+ },
1842
+ m(target, anchor) {
1843
+ if (default_slot) {
1844
+ default_slot.m(target, anchor);
1845
+ }
1846
+
1847
+ current = true;
1848
+ },
1849
+ p(ctx, dirty) {
1850
+ if (default_slot) {
1851
+ if (default_slot.p && dirty & /*$$scope*/ 2) {
1852
+ update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[1], dirty, get_default_slot_changes_1, get_default_slot_context_1);
1853
+ }
1854
+ }
1855
+ },
1856
+ i(local) {
1857
+ if (current) return;
1858
+ transition_in(default_slot, local);
1859
+ current = true;
1860
+ },
1861
+ o(local) {
1862
+ transition_out(default_slot, local);
1863
+ current = false;
1864
+ },
1865
+ d(detaching) {
1866
+ if (default_slot) default_slot.d(detaching);
1867
+ }
1868
+ };
1869
+ }
1870
+
1871
+ // (7:0) {#if metadata}
1872
+ function create_if_block$1(ctx) {
1873
+ let await_block_anchor;
1874
+ let promise;
1875
+ let current;
1876
+
1877
+ let info = {
1878
+ ctx,
1879
+ current: null,
1880
+ token: null,
1881
+ hasCatch: false,
1882
+ pending: create_pending_block,
1883
+ then: create_then_block,
1884
+ catch: create_catch_block,
1885
+ value: 3,
1886
+ blocks: [,,,]
1887
+ };
1888
+
1889
+ handle_promise(promise = /*metadata*/ ctx[0], info);
1890
+
1891
+ return {
1892
+ c() {
1893
+ await_block_anchor = empty();
1894
+ info.block.c();
1895
+ },
1896
+ m(target, anchor) {
1897
+ insert(target, await_block_anchor, anchor);
1898
+ info.block.m(target, info.anchor = anchor);
1899
+ info.mount = () => await_block_anchor.parentNode;
1900
+ info.anchor = await_block_anchor;
1901
+ current = true;
1902
+ },
1903
+ p(new_ctx, dirty) {
1904
+ ctx = new_ctx;
1905
+ info.ctx = ctx;
1906
+
1907
+ if (dirty & /*metadata*/ 1 && promise !== (promise = /*metadata*/ ctx[0]) && handle_promise(promise, info)) ; else {
1908
+ const child_ctx = ctx.slice();
1909
+ child_ctx[3] = info.resolved;
1910
+ info.block.p(child_ctx, dirty);
1911
+ }
1912
+ },
1913
+ i(local) {
1914
+ if (current) return;
1915
+ transition_in(info.block);
1916
+ current = true;
1917
+ },
1918
+ o(local) {
1919
+ for (let i = 0; i < 3; i += 1) {
1920
+ const block = info.blocks[i];
1921
+ transition_out(block);
1922
+ }
1923
+
1924
+ current = false;
1925
+ },
1926
+ d(detaching) {
1927
+ if (detaching) detach(await_block_anchor);
1928
+ info.block.d(detaching);
1929
+ info.token = null;
1930
+ info = null;
1931
+ }
1932
+ };
1933
+ }
1934
+
1935
+ // (1:0) <svelte:options immutable /> <script lang="ts">; export let metadata; </script> {#if metadata}
1936
+ function create_catch_block(ctx) {
1937
+ return {
1938
+ c: noop,
1939
+ m: noop,
1940
+ p: noop,
1941
+ i: noop,
1942
+ o: noop,
1943
+ d: noop
1944
+ };
1945
+ }
1946
+
1947
+ // (8:37) <slot metadata="{resolvedMeta}
1948
+ function create_then_block(ctx) {
1949
+ let current;
1950
+ const default_slot_template = /*#slots*/ ctx[2].default;
1951
+ const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[1], get_default_slot_context);
1952
+
1953
+ return {
1954
+ c() {
1955
+ if (default_slot) default_slot.c();
1956
+ },
1957
+ m(target, anchor) {
1958
+ if (default_slot) {
1959
+ default_slot.m(target, anchor);
1960
+ }
1961
+
1962
+ current = true;
1963
+ },
1964
+ p(ctx, dirty) {
1965
+ if (default_slot) {
1966
+ if (default_slot.p && dirty & /*$$scope, metadata*/ 3) {
1967
+ update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[1], dirty, get_default_slot_changes, get_default_slot_context);
1968
+ }
1969
+ }
1970
+ },
1971
+ i(local) {
1972
+ if (current) return;
1973
+ transition_in(default_slot, local);
1974
+ current = true;
1975
+ },
1976
+ o(local) {
1977
+ transition_out(default_slot, local);
1978
+ current = false;
1979
+ },
1980
+ d(detaching) {
1981
+ if (default_slot) default_slot.d(detaching);
1982
+ }
1983
+ };
1984
+ }
1985
+
1986
+ // (1:0) <svelte:options immutable /> <script lang="ts">; export let metadata; </script> {#if metadata}
1987
+ function create_pending_block(ctx) {
1988
+ return {
1989
+ c: noop,
1990
+ m: noop,
1991
+ p: noop,
1992
+ i: noop,
1993
+ o: noop,
1994
+ d: noop
1995
+ };
1996
+ }
1997
+
1998
+ function create_fragment$5(ctx) {
1999
+ let current_block_type_index;
2000
+ let if_block;
2001
+ let if_block_anchor;
2002
+ let current;
2003
+ const if_block_creators = [create_if_block$1, create_else_block];
2004
+ const if_blocks = [];
2005
+
2006
+ function select_block_type(ctx, dirty) {
2007
+ if (/*metadata*/ ctx[0]) return 0;
2008
+ return 1;
2009
+ }
2010
+
2011
+ current_block_type_index = select_block_type(ctx);
2012
+ if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
2013
+
2014
+ return {
2015
+ c() {
2016
+ if_block.c();
2017
+ if_block_anchor = empty();
2018
+ },
2019
+ m(target, anchor) {
2020
+ if_blocks[current_block_type_index].m(target, anchor);
2021
+ insert(target, if_block_anchor, anchor);
2022
+ current = true;
2023
+ },
2024
+ p(ctx, [dirty]) {
2025
+ let previous_block_index = current_block_type_index;
2026
+ current_block_type_index = select_block_type(ctx);
2027
+
2028
+ if (current_block_type_index === previous_block_index) {
2029
+ if_blocks[current_block_type_index].p(ctx, dirty);
2030
+ } else {
2031
+ group_outros();
2032
+
2033
+ transition_out(if_blocks[previous_block_index], 1, 1, () => {
2034
+ if_blocks[previous_block_index] = null;
2035
+ });
2036
+
2037
+ check_outros();
2038
+ if_block = if_blocks[current_block_type_index];
2039
+
2040
+ if (!if_block) {
2041
+ if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
2042
+ if_block.c();
2043
+ } else {
2044
+ if_block.p(ctx, dirty);
2045
+ }
2046
+
2047
+ transition_in(if_block, 1);
2048
+ if_block.m(if_block_anchor.parentNode, if_block_anchor);
2049
+ }
2050
+ },
2051
+ i(local) {
2052
+ if (current) return;
2053
+ transition_in(if_block);
2054
+ current = true;
2055
+ },
2056
+ o(local) {
2057
+ transition_out(if_block);
2058
+ current = false;
2059
+ },
2060
+ d(detaching) {
2061
+ if_blocks[current_block_type_index].d(detaching);
2062
+ if (detaching) detach(if_block_anchor);
2063
+ }
2064
+ };
2065
+ }
2066
+
2067
+ function instance$5($$self, $$props, $$invalidate) {
2068
+ let { $$slots: slots = {}, $$scope } = $$props;
2069
+
2070
+ let { metadata } = $$props;
2071
+
2072
+ $$self.$$set = $$props => {
2073
+ if ("metadata" in $$props) $$invalidate(0, metadata = $$props.metadata);
2074
+ if ("$$scope" in $$props) $$invalidate(1, $$scope = $$props.$$scope);
2075
+ };
2076
+
2077
+ return [metadata, $$scope, slots];
2078
+ }
2079
+
2080
+ class MetadataResolver extends SvelteComponent {
2081
+ constructor(options) {
2082
+ super();
2083
+ init(this, options, instance$5, create_fragment$5, not_equal, { metadata: 0 });
2084
+ }
2085
+ }
2086
+
2087
+ function isMacOS() {
2088
+ return navigator.appVersion.indexOf("Mac") !== -1;
2089
+ }
2090
+ function isMetaPressed(e) {
2091
+ return isMacOS() ? e.metaKey : e.ctrlKey;
2092
+ }
2093
+ function getDaysOfWeek(..._args) {
2094
+ return window.moment.weekdaysShort(true);
2095
+ }
2096
+ function isWeekend(date) {
2097
+ return date.isoWeekday() === 6 || date.isoWeekday() === 7;
2098
+ }
2099
+ function getStartOfWeek(days) {
2100
+ return days[0].weekday(0);
2101
+ }
2102
+ /**
2103
+ * Generate a 2D array of daily information to power
2104
+ * the calendar view.
2105
+ */
2106
+ function getMonth(displayedMonth, ..._args) {
2107
+ const locale = window.moment().locale();
2108
+ const month = [];
2109
+ let week;
2110
+ const startOfMonth = displayedMonth.clone().locale(locale).date(1);
2111
+ const startOffset = startOfMonth.weekday();
2112
+ let date = startOfMonth.clone().subtract(startOffset, "days");
2113
+ for (let _day = 0; _day < 42; _day++) {
2114
+ if (_day % 7 === 0) {
2115
+ week = {
2116
+ days: [],
2117
+ weekNum: date.week(),
2118
+ };
2119
+ month.push(week);
2120
+ }
2121
+ week.days.push(date);
2122
+ date = date.clone().add(1, "days");
2123
+ }
2124
+ return month;
2125
+ }
2126
+
2127
+ /* src/components/Day.svelte generated by Svelte v3.35.0 */
2128
+
2129
+ function add_css$4() {
2130
+ var style = element("style");
2131
+ style.id = "svelte-q3wqg9-style";
2132
+ style.textContent = ".day.svelte-q3wqg9{background-color:var(--color-background-day);border-radius:4px;color:var(--color-text-day);cursor:pointer;font-size:0.8em;height:100%;padding:4px;position:relative;text-align:center;transition:background-color 0.1s ease-in, color 0.1s ease-in;vertical-align:baseline}.day.svelte-q3wqg9:hover{background-color:var(--interactive-hover)}.day.active.svelte-q3wqg9:hover{background-color:var(--interactive-accent-hover)}.adjacent-month.svelte-q3wqg9{opacity:0.25}.today.svelte-q3wqg9{color:var(--color-text-today)}.day.svelte-q3wqg9:active,.active.svelte-q3wqg9,.active.today.svelte-q3wqg9{color:var(--text-on-accent);background-color:var(--interactive-accent)}.dot-container.svelte-q3wqg9{display:flex;flex-wrap:wrap;justify-content:center;line-height:6px;min-height:6px}";
2133
+ append(document.head, style);
2134
+ }
2135
+
2136
+ function get_each_context$2(ctx, list, i) {
2137
+ const child_ctx = ctx.slice();
2138
+ child_ctx[11] = list[i];
2139
+ return child_ctx;
2140
+ }
2141
+
2142
+ // (36:8) {#each metadata.dots as dot}
2143
+ function create_each_block$2(ctx) {
2144
+ let dot;
2145
+ let current;
2146
+ const dot_spread_levels = [/*dot*/ ctx[11]];
2147
+ let dot_props = {};
2148
+
2149
+ for (let i = 0; i < dot_spread_levels.length; i += 1) {
2150
+ dot_props = assign(dot_props, dot_spread_levels[i]);
2151
+ }
2152
+
2153
+ dot = new Dot({ props: dot_props });
2154
+
2155
+ return {
2156
+ c() {
2157
+ create_component(dot.$$.fragment);
2158
+ },
2159
+ m(target, anchor) {
2160
+ mount_component(dot, target, anchor);
2161
+ current = true;
2162
+ },
2163
+ p(ctx, dirty) {
2164
+ const dot_changes = (dirty & /*metadata*/ 128)
2165
+ ? get_spread_update(dot_spread_levels, [get_spread_object(/*dot*/ ctx[11])])
2166
+ : {};
2167
+
2168
+ dot.$set(dot_changes);
2169
+ },
2170
+ i(local) {
2171
+ if (current) return;
2172
+ transition_in(dot.$$.fragment, local);
2173
+ current = true;
2174
+ },
2175
+ o(local) {
2176
+ transition_out(dot.$$.fragment, local);
2177
+ current = false;
2178
+ },
2179
+ d(detaching) {
2180
+ destroy_component(dot, detaching);
2181
+ }
2182
+ };
2183
+ }
2184
+
2185
+ // (22:2) <MetadataResolver metadata="{metadata}" let:metadata>
2186
+ function create_default_slot$1(ctx) {
2187
+ let div1;
2188
+ let t0_value = /*date*/ ctx[0].format("D") + "";
2189
+ let t0;
2190
+ let t1;
2191
+ let div0;
2192
+ let div1_class_value;
2193
+ let current;
2194
+ let mounted;
2195
+ let dispose;
2196
+ let each_value = /*metadata*/ ctx[7].dots;
2197
+ let each_blocks = [];
2198
+
2199
+ for (let i = 0; i < each_value.length; i += 1) {
2200
+ each_blocks[i] = create_each_block$2(get_each_context$2(ctx, each_value, i));
2201
+ }
2202
+
2203
+ const out = i => transition_out(each_blocks[i], 1, 1, () => {
2204
+ each_blocks[i] = null;
2205
+ });
2206
+
2207
+ let div1_levels = [
2208
+ {
2209
+ class: div1_class_value = `day ${/*metadata*/ ctx[7].classes.join(" ")}`
2210
+ },
2211
+ /*metadata*/ ctx[7].dataAttributes || {}
2212
+ ];
2213
+
2214
+ let div1_data = {};
2215
+
2216
+ for (let i = 0; i < div1_levels.length; i += 1) {
2217
+ div1_data = assign(div1_data, div1_levels[i]);
2218
+ }
2219
+
2220
+ return {
2221
+ c() {
2222
+ div1 = element("div");
2223
+ t0 = text(t0_value);
2224
+ t1 = space();
2225
+ div0 = element("div");
2226
+
2227
+ for (let i = 0; i < each_blocks.length; i += 1) {
2228
+ each_blocks[i].c();
2229
+ }
2230
+
2231
+ attr(div0, "class", "dot-container svelte-q3wqg9");
2232
+ set_attributes(div1, div1_data);
2233
+ toggle_class(div1, "active", /*selectedId*/ ctx[6] === getDateUID_1(/*date*/ ctx[0], "day"));
2234
+ toggle_class(div1, "adjacent-month", !/*date*/ ctx[0].isSame(/*displayedMonth*/ ctx[5], "month"));
2235
+ toggle_class(div1, "today", /*date*/ ctx[0].isSame(/*today*/ ctx[4], "day"));
2236
+ toggle_class(div1, "svelte-q3wqg9", true);
2237
+ },
2238
+ m(target, anchor) {
2239
+ insert(target, div1, anchor);
2240
+ append(div1, t0);
2241
+ append(div1, t1);
2242
+ append(div1, div0);
2243
+
2244
+ for (let i = 0; i < each_blocks.length; i += 1) {
2245
+ each_blocks[i].m(div0, null);
2246
+ }
2247
+
2248
+ current = true;
2249
+
2250
+ if (!mounted) {
2251
+ dispose = [
2252
+ listen(div1, "click", function () {
2253
+ if (is_function(/*onClick*/ ctx[2] && /*click_handler*/ ctx[8])) (/*onClick*/ ctx[2] && /*click_handler*/ ctx[8]).apply(this, arguments);
2254
+ }),
2255
+ listen(div1, "contextmenu", function () {
2256
+ if (is_function(/*onContextMenu*/ ctx[3] && /*contextmenu_handler*/ ctx[9])) (/*onContextMenu*/ ctx[3] && /*contextmenu_handler*/ ctx[9]).apply(this, arguments);
2257
+ }),
2258
+ listen(div1, "pointerover", function () {
2259
+ if (is_function(/*onHover*/ ctx[1] && /*pointerover_handler*/ ctx[10])) (/*onHover*/ ctx[1] && /*pointerover_handler*/ ctx[10]).apply(this, arguments);
2260
+ })
2261
+ ];
2262
+
2263
+ mounted = true;
2264
+ }
2265
+ },
2266
+ p(new_ctx, dirty) {
2267
+ ctx = new_ctx;
2268
+ if ((!current || dirty & /*date*/ 1) && t0_value !== (t0_value = /*date*/ ctx[0].format("D") + "")) set_data(t0, t0_value);
2269
+
2270
+ if (dirty & /*metadata*/ 128) {
2271
+ each_value = /*metadata*/ ctx[7].dots;
2272
+ let i;
2273
+
2274
+ for (i = 0; i < each_value.length; i += 1) {
2275
+ const child_ctx = get_each_context$2(ctx, each_value, i);
2276
+
2277
+ if (each_blocks[i]) {
2278
+ each_blocks[i].p(child_ctx, dirty);
2279
+ transition_in(each_blocks[i], 1);
2280
+ } else {
2281
+ each_blocks[i] = create_each_block$2(child_ctx);
2282
+ each_blocks[i].c();
2283
+ transition_in(each_blocks[i], 1);
2284
+ each_blocks[i].m(div0, null);
2285
+ }
2286
+ }
2287
+
2288
+ group_outros();
2289
+
2290
+ for (i = each_value.length; i < each_blocks.length; i += 1) {
2291
+ out(i);
2292
+ }
2293
+
2294
+ check_outros();
2295
+ }
2296
+
2297
+ set_attributes(div1, div1_data = get_spread_update(div1_levels, [
2298
+ (!current || dirty & /*metadata*/ 128 && div1_class_value !== (div1_class_value = `day ${/*metadata*/ ctx[7].classes.join(" ")}`)) && { class: div1_class_value },
2299
+ dirty & /*metadata*/ 128 && (/*metadata*/ ctx[7].dataAttributes || {})
2300
+ ]));
2301
+
2302
+ toggle_class(div1, "active", /*selectedId*/ ctx[6] === getDateUID_1(/*date*/ ctx[0], "day"));
2303
+ toggle_class(div1, "adjacent-month", !/*date*/ ctx[0].isSame(/*displayedMonth*/ ctx[5], "month"));
2304
+ toggle_class(div1, "today", /*date*/ ctx[0].isSame(/*today*/ ctx[4], "day"));
2305
+ toggle_class(div1, "svelte-q3wqg9", true);
2306
+ },
2307
+ i(local) {
2308
+ if (current) return;
2309
+
2310
+ for (let i = 0; i < each_value.length; i += 1) {
2311
+ transition_in(each_blocks[i]);
2312
+ }
2313
+
2314
+ current = true;
2315
+ },
2316
+ o(local) {
2317
+ each_blocks = each_blocks.filter(Boolean);
2318
+
2319
+ for (let i = 0; i < each_blocks.length; i += 1) {
2320
+ transition_out(each_blocks[i]);
2321
+ }
2322
+
2323
+ current = false;
2324
+ },
2325
+ d(detaching) {
2326
+ if (detaching) detach(div1);
2327
+ destroy_each(each_blocks, detaching);
2328
+ mounted = false;
2329
+ run_all(dispose);
2330
+ }
2331
+ };
2332
+ }
2333
+
2334
+ function create_fragment$4(ctx) {
2335
+ let td;
2336
+ let metadataresolver;
2337
+ let current;
2338
+
2339
+ metadataresolver = new MetadataResolver({
2340
+ props: {
2341
+ metadata: /*metadata*/ ctx[7],
2342
+ $$slots: {
2343
+ default: [
2344
+ create_default_slot$1,
2345
+ ({ metadata }) => ({ 7: metadata }),
2346
+ ({ metadata }) => metadata ? 128 : 0
2347
+ ]
2348
+ },
2349
+ $$scope: { ctx }
2350
+ }
2351
+ });
2352
+
2353
+ return {
2354
+ c() {
2355
+ td = element("td");
2356
+ create_component(metadataresolver.$$.fragment);
2357
+ },
2358
+ m(target, anchor) {
2359
+ insert(target, td, anchor);
2360
+ mount_component(metadataresolver, td, null);
2361
+ current = true;
2362
+ },
2363
+ p(ctx, [dirty]) {
2364
+ const metadataresolver_changes = {};
2365
+ if (dirty & /*metadata*/ 128) metadataresolver_changes.metadata = /*metadata*/ ctx[7];
2366
+
2367
+ if (dirty & /*$$scope, metadata, selectedId, date, displayedMonth, today, onClick, onContextMenu, onHover*/ 16639) {
2368
+ metadataresolver_changes.$$scope = { dirty, ctx };
2369
+ }
2370
+
2371
+ metadataresolver.$set(metadataresolver_changes);
2372
+ },
2373
+ i(local) {
2374
+ if (current) return;
2375
+ transition_in(metadataresolver.$$.fragment, local);
2376
+ current = true;
2377
+ },
2378
+ o(local) {
2379
+ transition_out(metadataresolver.$$.fragment, local);
2380
+ current = false;
2381
+ },
2382
+ d(detaching) {
2383
+ if (detaching) detach(td);
2384
+ destroy_component(metadataresolver);
2385
+ }
2386
+ };
2387
+ }
2388
+
2389
+ function instance$4($$self, $$props, $$invalidate) {
2390
+
2391
+
2392
+ let { date } = $$props;
2393
+ let { metadata } = $$props;
2394
+ let { onHover } = $$props;
2395
+ let { onClick } = $$props;
2396
+ let { onContextMenu } = $$props;
2397
+ let { today } = $$props;
2398
+ let { displayedMonth = null } = $$props;
2399
+ let { selectedId = null } = $$props;
2400
+ const click_handler = e => onClick(date, isMetaPressed(e));
2401
+ const contextmenu_handler = e => onContextMenu(date, e);
2402
+ const pointerover_handler = e => onHover(date, e.target, isMetaPressed(e));
2403
+
2404
+ $$self.$$set = $$props => {
2405
+ if ("date" in $$props) $$invalidate(0, date = $$props.date);
2406
+ if ("metadata" in $$props) $$invalidate(7, metadata = $$props.metadata);
2407
+ if ("onHover" in $$props) $$invalidate(1, onHover = $$props.onHover);
2408
+ if ("onClick" in $$props) $$invalidate(2, onClick = $$props.onClick);
2409
+ if ("onContextMenu" in $$props) $$invalidate(3, onContextMenu = $$props.onContextMenu);
2410
+ if ("today" in $$props) $$invalidate(4, today = $$props.today);
2411
+ if ("displayedMonth" in $$props) $$invalidate(5, displayedMonth = $$props.displayedMonth);
2412
+ if ("selectedId" in $$props) $$invalidate(6, selectedId = $$props.selectedId);
2413
+ };
2414
+
2415
+ return [
2416
+ date,
2417
+ onHover,
2418
+ onClick,
2419
+ onContextMenu,
2420
+ today,
2421
+ displayedMonth,
2422
+ selectedId,
2423
+ metadata,
2424
+ click_handler,
2425
+ contextmenu_handler,
2426
+ pointerover_handler
2427
+ ];
2428
+ }
2429
+
2430
+ class Day extends SvelteComponent {
2431
+ constructor(options) {
2432
+ super();
2433
+ if (!document.getElementById("svelte-q3wqg9-style")) add_css$4();
2434
+
2435
+ init(this, options, instance$4, create_fragment$4, not_equal, {
2436
+ date: 0,
2437
+ metadata: 7,
2438
+ onHover: 1,
2439
+ onClick: 2,
2440
+ onContextMenu: 3,
2441
+ today: 4,
2442
+ displayedMonth: 5,
2443
+ selectedId: 6
2444
+ });
2445
+ }
2446
+ }
2447
+
2448
+ /* src/components/Arrow.svelte generated by Svelte v3.35.0 */
2449
+
2450
+ function add_css$3() {
2451
+ var style = element("style");
2452
+ style.id = "svelte-156w7na-style";
2453
+ style.textContent = ".arrow.svelte-156w7na.svelte-156w7na{align-items:center;cursor:pointer;display:flex;justify-content:center;width:24px}.arrow.is-mobile.svelte-156w7na.svelte-156w7na{width:32px}.right.svelte-156w7na.svelte-156w7na{transform:rotate(180deg)}.arrow.svelte-156w7na svg.svelte-156w7na{color:var(--color-arrow);height:16px;width:16px}";
2454
+ append(document.head, style);
2455
+ }
2456
+
2457
+ function create_fragment$3(ctx) {
2458
+ let div;
2459
+ let svg;
2460
+ let path;
2461
+ let mounted;
2462
+ let dispose;
2463
+
2464
+ return {
2465
+ c() {
2466
+ div = element("div");
2467
+ svg = svg_element("svg");
2468
+ path = svg_element("path");
2469
+ attr(path, "fill", "currentColor");
2470
+ attr(path, "d", "M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z");
2471
+ attr(svg, "focusable", "false");
2472
+ attr(svg, "role", "img");
2473
+ attr(svg, "xmlns", "http://www.w3.org/2000/svg");
2474
+ attr(svg, "viewBox", "0 0 320 512");
2475
+ attr(svg, "class", "svelte-156w7na");
2476
+ attr(div, "class", "arrow svelte-156w7na");
2477
+ attr(div, "aria-label", /*tooltip*/ ctx[1]);
2478
+ toggle_class(div, "is-mobile", /*isMobile*/ ctx[3]);
2479
+ toggle_class(div, "right", /*direction*/ ctx[2] === "right");
2480
+ },
2481
+ m(target, anchor) {
2482
+ insert(target, div, anchor);
2483
+ append(div, svg);
2484
+ append(svg, path);
2485
+
2486
+ if (!mounted) {
2487
+ dispose = listen(div, "click", function () {
2488
+ if (is_function(/*onClick*/ ctx[0])) /*onClick*/ ctx[0].apply(this, arguments);
2489
+ });
2490
+
2491
+ mounted = true;
2492
+ }
2493
+ },
2494
+ p(new_ctx, [dirty]) {
2495
+ ctx = new_ctx;
2496
+
2497
+ if (dirty & /*tooltip*/ 2) {
2498
+ attr(div, "aria-label", /*tooltip*/ ctx[1]);
2499
+ }
2500
+
2501
+ if (dirty & /*direction*/ 4) {
2502
+ toggle_class(div, "right", /*direction*/ ctx[2] === "right");
2503
+ }
2504
+ },
2505
+ i: noop,
2506
+ o: noop,
2507
+ d(detaching) {
2508
+ if (detaching) detach(div);
2509
+ mounted = false;
2510
+ dispose();
2511
+ }
2512
+ };
2513
+ }
2514
+
2515
+ function instance$3($$self, $$props, $$invalidate) {
2516
+ let { onClick } = $$props;
2517
+ let { tooltip } = $$props;
2518
+ let { direction } = $$props;
2519
+
2520
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2521
+ let isMobile = window.app.isMobile;
2522
+
2523
+ $$self.$$set = $$props => {
2524
+ if ("onClick" in $$props) $$invalidate(0, onClick = $$props.onClick);
2525
+ if ("tooltip" in $$props) $$invalidate(1, tooltip = $$props.tooltip);
2526
+ if ("direction" in $$props) $$invalidate(2, direction = $$props.direction);
2527
+ };
2528
+
2529
+ return [onClick, tooltip, direction, isMobile];
2530
+ }
2531
+
2532
+ class Arrow extends SvelteComponent {
2533
+ constructor(options) {
2534
+ super();
2535
+ if (!document.getElementById("svelte-156w7na-style")) add_css$3();
2536
+ init(this, options, instance$3, create_fragment$3, safe_not_equal, { onClick: 0, tooltip: 1, direction: 2 });
2537
+ }
2538
+ }
2539
+
2540
+ /* src/components/Nav.svelte generated by Svelte v3.35.0 */
2541
+
2542
+ function add_css$2() {
2543
+ var style = element("style");
2544
+ style.id = "svelte-1vwr9dd-style";
2545
+ style.textContent = ".nav.svelte-1vwr9dd.svelte-1vwr9dd{align-items:center;display:flex;margin:0.6em 0 1em;padding:0 8px;width:100%}.nav.is-mobile.svelte-1vwr9dd.svelte-1vwr9dd{padding:0}.title.svelte-1vwr9dd.svelte-1vwr9dd{color:var(--color-text-title);font-size:1.5em;margin:0}.is-mobile.svelte-1vwr9dd .title.svelte-1vwr9dd{font-size:1.3em}.month.svelte-1vwr9dd.svelte-1vwr9dd{font-weight:500;text-transform:capitalize}.year.svelte-1vwr9dd.svelte-1vwr9dd{color:var(--interactive-accent)}.right-nav.svelte-1vwr9dd.svelte-1vwr9dd{display:flex;justify-content:center;margin-left:auto}.reset-button.svelte-1vwr9dd.svelte-1vwr9dd{cursor:pointer;border-radius:4px;color:var(--text-muted);font-size:0.7em;font-weight:600;letter-spacing:1px;margin:0 4px;padding:0px 4px;text-transform:uppercase}.is-mobile.svelte-1vwr9dd .reset-button.svelte-1vwr9dd{display:none}";
2546
+ append(document.head, style);
2547
+ }
2548
+
2549
+ function create_fragment$2(ctx) {
2550
+ let div2;
2551
+ let h3;
2552
+ let span0;
2553
+ let t0_value = /*displayedMonth*/ ctx[0].format("MMM") + "";
2554
+ let t0;
2555
+ let t1;
2556
+ let span1;
2557
+ let t2_value = /*displayedMonth*/ ctx[0].format("YYYY") + "";
2558
+ let t2;
2559
+ let t3;
2560
+ let div1;
2561
+ let arrow0;
2562
+ let t4;
2563
+ let div0;
2564
+ let t6;
2565
+ let arrow1;
2566
+ let current;
2567
+ let mounted;
2568
+ let dispose;
2569
+
2570
+ arrow0 = new Arrow({
2571
+ props: {
2572
+ direction: "left",
2573
+ onClick: /*decrementDisplayedMonth*/ ctx[3],
2574
+ tooltip: "Previous Month"
2575
+ }
2576
+ });
2577
+
2578
+ arrow1 = new Arrow({
2579
+ props: {
2580
+ direction: "right",
2581
+ onClick: /*incrementDisplayedMonth*/ ctx[2],
2582
+ tooltip: "Next Month"
2583
+ }
2584
+ });
2585
+
2586
+ return {
2587
+ c() {
2588
+ div2 = element("div");
2589
+ h3 = element("h3");
2590
+ span0 = element("span");
2591
+ t0 = text(t0_value);
2592
+ t1 = space();
2593
+ span1 = element("span");
2594
+ t2 = text(t2_value);
2595
+ t3 = space();
2596
+ div1 = element("div");
2597
+ create_component(arrow0.$$.fragment);
2598
+ t4 = space();
2599
+ div0 = element("div");
2600
+ div0.textContent = `${/*todayDisplayStr*/ ctx[4]}`;
2601
+ t6 = space();
2602
+ create_component(arrow1.$$.fragment);
2603
+ attr(span0, "class", "month svelte-1vwr9dd");
2604
+ attr(span1, "class", "year svelte-1vwr9dd");
2605
+ attr(h3, "class", "title svelte-1vwr9dd");
2606
+ attr(div0, "class", "reset-button svelte-1vwr9dd");
2607
+ attr(div1, "class", "right-nav svelte-1vwr9dd");
2608
+ attr(div2, "class", "nav svelte-1vwr9dd");
2609
+ toggle_class(div2, "is-mobile", /*isMobile*/ ctx[5]);
2610
+ },
2611
+ m(target, anchor) {
2612
+ insert(target, div2, anchor);
2613
+ append(div2, h3);
2614
+ append(h3, span0);
2615
+ append(span0, t0);
2616
+ append(h3, t1);
2617
+ append(h3, span1);
2618
+ append(span1, t2);
2619
+ append(div2, t3);
2620
+ append(div2, div1);
2621
+ mount_component(arrow0, div1, null);
2622
+ append(div1, t4);
2623
+ append(div1, div0);
2624
+ append(div1, t6);
2625
+ mount_component(arrow1, div1, null);
2626
+ current = true;
2627
+
2628
+ if (!mounted) {
2629
+ dispose = [
2630
+ listen(h3, "click", function () {
2631
+ if (is_function(/*resetDisplayedMonth*/ ctx[1])) /*resetDisplayedMonth*/ ctx[1].apply(this, arguments);
2632
+ }),
2633
+ listen(div0, "click", function () {
2634
+ if (is_function(/*resetDisplayedMonth*/ ctx[1])) /*resetDisplayedMonth*/ ctx[1].apply(this, arguments);
2635
+ })
2636
+ ];
2637
+
2638
+ mounted = true;
2639
+ }
2640
+ },
2641
+ p(new_ctx, [dirty]) {
2642
+ ctx = new_ctx;
2643
+ if ((!current || dirty & /*displayedMonth*/ 1) && t0_value !== (t0_value = /*displayedMonth*/ ctx[0].format("MMM") + "")) set_data(t0, t0_value);
2644
+ if ((!current || dirty & /*displayedMonth*/ 1) && t2_value !== (t2_value = /*displayedMonth*/ ctx[0].format("YYYY") + "")) set_data(t2, t2_value);
2645
+ const arrow0_changes = {};
2646
+ if (dirty & /*decrementDisplayedMonth*/ 8) arrow0_changes.onClick = /*decrementDisplayedMonth*/ ctx[3];
2647
+ arrow0.$set(arrow0_changes);
2648
+ const arrow1_changes = {};
2649
+ if (dirty & /*incrementDisplayedMonth*/ 4) arrow1_changes.onClick = /*incrementDisplayedMonth*/ ctx[2];
2650
+ arrow1.$set(arrow1_changes);
2651
+ },
2652
+ i(local) {
2653
+ if (current) return;
2654
+ transition_in(arrow0.$$.fragment, local);
2655
+ transition_in(arrow1.$$.fragment, local);
2656
+ current = true;
2657
+ },
2658
+ o(local) {
2659
+ transition_out(arrow0.$$.fragment, local);
2660
+ transition_out(arrow1.$$.fragment, local);
2661
+ current = false;
2662
+ },
2663
+ d(detaching) {
2664
+ if (detaching) detach(div2);
2665
+ destroy_component(arrow0);
2666
+ destroy_component(arrow1);
2667
+ mounted = false;
2668
+ run_all(dispose);
2669
+ }
2670
+ };
2671
+ }
2672
+
2673
+ function instance$2($$self, $$props, $$invalidate) {
2674
+
2675
+ let { displayedMonth } = $$props;
2676
+ let { today } = $$props;
2677
+ let { resetDisplayedMonth } = $$props;
2678
+ let { incrementDisplayedMonth } = $$props;
2679
+ let { decrementDisplayedMonth } = $$props;
2680
+
2681
+ // Get the word 'Today' but localized to the current language
2682
+ const todayDisplayStr = today.calendar().split(/\d|\s/)[0];
2683
+
2684
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2685
+ let isMobile = window.app.isMobile;
2686
+
2687
+ $$self.$$set = $$props => {
2688
+ if ("displayedMonth" in $$props) $$invalidate(0, displayedMonth = $$props.displayedMonth);
2689
+ if ("today" in $$props) $$invalidate(6, today = $$props.today);
2690
+ if ("resetDisplayedMonth" in $$props) $$invalidate(1, resetDisplayedMonth = $$props.resetDisplayedMonth);
2691
+ if ("incrementDisplayedMonth" in $$props) $$invalidate(2, incrementDisplayedMonth = $$props.incrementDisplayedMonth);
2692
+ if ("decrementDisplayedMonth" in $$props) $$invalidate(3, decrementDisplayedMonth = $$props.decrementDisplayedMonth);
2693
+ };
2694
+
2695
+ return [
2696
+ displayedMonth,
2697
+ resetDisplayedMonth,
2698
+ incrementDisplayedMonth,
2699
+ decrementDisplayedMonth,
2700
+ todayDisplayStr,
2701
+ isMobile,
2702
+ today
2703
+ ];
2704
+ }
2705
+
2706
+ class Nav extends SvelteComponent {
2707
+ constructor(options) {
2708
+ super();
2709
+ if (!document.getElementById("svelte-1vwr9dd-style")) add_css$2();
2710
+
2711
+ init(this, options, instance$2, create_fragment$2, safe_not_equal, {
2712
+ displayedMonth: 0,
2713
+ today: 6,
2714
+ resetDisplayedMonth: 1,
2715
+ incrementDisplayedMonth: 2,
2716
+ decrementDisplayedMonth: 3
2717
+ });
2718
+ }
2719
+ }
2720
+
2721
+ /* src/components/WeekNum.svelte generated by Svelte v3.35.0 */
2722
+
2723
+ function add_css$1() {
2724
+ var style = element("style");
2725
+ style.id = "svelte-egt0yd-style";
2726
+ style.textContent = "td.svelte-egt0yd{border-right:1px solid var(--background-modifier-border)}.week-num.svelte-egt0yd{background-color:var(--color-background-weeknum);border-radius:4px;color:var(--color-text-weeknum);cursor:pointer;font-size:0.65em;height:100%;padding:4px;text-align:center;transition:background-color 0.1s ease-in, color 0.1s ease-in;vertical-align:baseline}.week-num.svelte-egt0yd:hover{background-color:var(--interactive-hover)}.week-num.active.svelte-egt0yd:hover{background-color:var(--interactive-accent-hover)}.active.svelte-egt0yd{color:var(--text-on-accent);background-color:var(--interactive-accent)}.dot-container.svelte-egt0yd{display:flex;flex-wrap:wrap;justify-content:center;line-height:6px;min-height:6px}";
2727
+ append(document.head, style);
2728
+ }
2729
+
2730
+ function get_each_context$1(ctx, list, i) {
2731
+ const child_ctx = ctx.slice();
2732
+ child_ctx[11] = list[i];
2733
+ return child_ctx;
2734
+ }
2735
+
2736
+ // (35:8) {#each metadata.dots as dot}
2737
+ function create_each_block$1(ctx) {
2738
+ let dot;
2739
+ let current;
2740
+ const dot_spread_levels = [/*dot*/ ctx[11]];
2741
+ let dot_props = {};
2742
+
2743
+ for (let i = 0; i < dot_spread_levels.length; i += 1) {
2744
+ dot_props = assign(dot_props, dot_spread_levels[i]);
2745
+ }
2746
+
2747
+ dot = new Dot({ props: dot_props });
2748
+
2749
+ return {
2750
+ c() {
2751
+ create_component(dot.$$.fragment);
2752
+ },
2753
+ m(target, anchor) {
2754
+ mount_component(dot, target, anchor);
2755
+ current = true;
2756
+ },
2757
+ p(ctx, dirty) {
2758
+ const dot_changes = (dirty & /*metadata*/ 64)
2759
+ ? get_spread_update(dot_spread_levels, [get_spread_object(/*dot*/ ctx[11])])
2760
+ : {};
2761
+
2762
+ dot.$set(dot_changes);
2763
+ },
2764
+ i(local) {
2765
+ if (current) return;
2766
+ transition_in(dot.$$.fragment, local);
2767
+ current = true;
2768
+ },
2769
+ o(local) {
2770
+ transition_out(dot.$$.fragment, local);
2771
+ current = false;
2772
+ },
2773
+ d(detaching) {
2774
+ destroy_component(dot, detaching);
2775
+ }
2776
+ };
2777
+ }
2778
+
2779
+ // (24:2) <MetadataResolver metadata="{metadata}" let:metadata>
2780
+ function create_default_slot(ctx) {
2781
+ let div1;
2782
+ let t0;
2783
+ let t1;
2784
+ let div0;
2785
+ let div1_class_value;
2786
+ let current;
2787
+ let mounted;
2788
+ let dispose;
2789
+ let each_value = /*metadata*/ ctx[6].dots;
2790
+ let each_blocks = [];
2791
+
2792
+ for (let i = 0; i < each_value.length; i += 1) {
2793
+ each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i));
2794
+ }
2795
+
2796
+ const out = i => transition_out(each_blocks[i], 1, 1, () => {
2797
+ each_blocks[i] = null;
2798
+ });
2799
+
2800
+ return {
2801
+ c() {
2802
+ div1 = element("div");
2803
+ t0 = text(/*weekNum*/ ctx[0]);
2804
+ t1 = space();
2805
+ div0 = element("div");
2806
+
2807
+ for (let i = 0; i < each_blocks.length; i += 1) {
2808
+ each_blocks[i].c();
2809
+ }
2810
+
2811
+ attr(div0, "class", "dot-container svelte-egt0yd");
2812
+ attr(div1, "class", div1_class_value = "" + (null_to_empty(`week-num ${/*metadata*/ ctx[6].classes.join(" ")}`) + " svelte-egt0yd"));
2813
+ toggle_class(div1, "active", /*selectedId*/ ctx[5] === getDateUID_1(/*days*/ ctx[1][0], "week"));
2814
+ },
2815
+ m(target, anchor) {
2816
+ insert(target, div1, anchor);
2817
+ append(div1, t0);
2818
+ append(div1, t1);
2819
+ append(div1, div0);
2820
+
2821
+ for (let i = 0; i < each_blocks.length; i += 1) {
2822
+ each_blocks[i].m(div0, null);
2823
+ }
2824
+
2825
+ current = true;
2826
+
2827
+ if (!mounted) {
2828
+ dispose = [
2829
+ listen(div1, "click", function () {
2830
+ if (is_function(/*onClick*/ ctx[3] && /*click_handler*/ ctx[8])) (/*onClick*/ ctx[3] && /*click_handler*/ ctx[8]).apply(this, arguments);
2831
+ }),
2832
+ listen(div1, "contextmenu", function () {
2833
+ if (is_function(/*onContextMenu*/ ctx[4] && /*contextmenu_handler*/ ctx[9])) (/*onContextMenu*/ ctx[4] && /*contextmenu_handler*/ ctx[9]).apply(this, arguments);
2834
+ }),
2835
+ listen(div1, "pointerover", function () {
2836
+ if (is_function(/*onHover*/ ctx[2] && /*pointerover_handler*/ ctx[10])) (/*onHover*/ ctx[2] && /*pointerover_handler*/ ctx[10]).apply(this, arguments);
2837
+ })
2838
+ ];
2839
+
2840
+ mounted = true;
2841
+ }
2842
+ },
2843
+ p(new_ctx, dirty) {
2844
+ ctx = new_ctx;
2845
+ if (!current || dirty & /*weekNum*/ 1) set_data(t0, /*weekNum*/ ctx[0]);
2846
+
2847
+ if (dirty & /*metadata*/ 64) {
2848
+ each_value = /*metadata*/ ctx[6].dots;
2849
+ let i;
2850
+
2851
+ for (i = 0; i < each_value.length; i += 1) {
2852
+ const child_ctx = get_each_context$1(ctx, each_value, i);
2853
+
2854
+ if (each_blocks[i]) {
2855
+ each_blocks[i].p(child_ctx, dirty);
2856
+ transition_in(each_blocks[i], 1);
2857
+ } else {
2858
+ each_blocks[i] = create_each_block$1(child_ctx);
2859
+ each_blocks[i].c();
2860
+ transition_in(each_blocks[i], 1);
2861
+ each_blocks[i].m(div0, null);
2862
+ }
2863
+ }
2864
+
2865
+ group_outros();
2866
+
2867
+ for (i = each_value.length; i < each_blocks.length; i += 1) {
2868
+ out(i);
2869
+ }
2870
+
2871
+ check_outros();
2872
+ }
2873
+
2874
+ if (!current || dirty & /*metadata*/ 64 && div1_class_value !== (div1_class_value = "" + (null_to_empty(`week-num ${/*metadata*/ ctx[6].classes.join(" ")}`) + " svelte-egt0yd"))) {
2875
+ attr(div1, "class", div1_class_value);
2876
+ }
2877
+
2878
+ if (dirty & /*metadata, selectedId, getDateUID, days*/ 98) {
2879
+ toggle_class(div1, "active", /*selectedId*/ ctx[5] === getDateUID_1(/*days*/ ctx[1][0], "week"));
2880
+ }
2881
+ },
2882
+ i(local) {
2883
+ if (current) return;
2884
+
2885
+ for (let i = 0; i < each_value.length; i += 1) {
2886
+ transition_in(each_blocks[i]);
2887
+ }
2888
+
2889
+ current = true;
2890
+ },
2891
+ o(local) {
2892
+ each_blocks = each_blocks.filter(Boolean);
2893
+
2894
+ for (let i = 0; i < each_blocks.length; i += 1) {
2895
+ transition_out(each_blocks[i]);
2896
+ }
2897
+
2898
+ current = false;
2899
+ },
2900
+ d(detaching) {
2901
+ if (detaching) detach(div1);
2902
+ destroy_each(each_blocks, detaching);
2903
+ mounted = false;
2904
+ run_all(dispose);
2905
+ }
2906
+ };
2907
+ }
2908
+
2909
+ function create_fragment$1(ctx) {
2910
+ let td;
2911
+ let metadataresolver;
2912
+ let current;
2913
+
2914
+ metadataresolver = new MetadataResolver({
2915
+ props: {
2916
+ metadata: /*metadata*/ ctx[6],
2917
+ $$slots: {
2918
+ default: [
2919
+ create_default_slot,
2920
+ ({ metadata }) => ({ 6: metadata }),
2921
+ ({ metadata }) => metadata ? 64 : 0
2922
+ ]
2923
+ },
2924
+ $$scope: { ctx }
2925
+ }
2926
+ });
2927
+
2928
+ return {
2929
+ c() {
2930
+ td = element("td");
2931
+ create_component(metadataresolver.$$.fragment);
2932
+ attr(td, "class", "svelte-egt0yd");
2933
+ },
2934
+ m(target, anchor) {
2935
+ insert(target, td, anchor);
2936
+ mount_component(metadataresolver, td, null);
2937
+ current = true;
2938
+ },
2939
+ p(ctx, [dirty]) {
2940
+ const metadataresolver_changes = {};
2941
+ if (dirty & /*metadata*/ 64) metadataresolver_changes.metadata = /*metadata*/ ctx[6];
2942
+
2943
+ if (dirty & /*$$scope, metadata, selectedId, days, onClick, startOfWeek, onContextMenu, onHover, weekNum*/ 16639) {
2944
+ metadataresolver_changes.$$scope = { dirty, ctx };
2945
+ }
2946
+
2947
+ metadataresolver.$set(metadataresolver_changes);
2948
+ },
2949
+ i(local) {
2950
+ if (current) return;
2951
+ transition_in(metadataresolver.$$.fragment, local);
2952
+ current = true;
2953
+ },
2954
+ o(local) {
2955
+ transition_out(metadataresolver.$$.fragment, local);
2956
+ current = false;
2957
+ },
2958
+ d(detaching) {
2959
+ if (detaching) detach(td);
2960
+ destroy_component(metadataresolver);
2961
+ }
2962
+ };
2963
+ }
2964
+
2965
+ function instance$1($$self, $$props, $$invalidate) {
2966
+
2967
+
2968
+ let { weekNum } = $$props;
2969
+ let { days } = $$props;
2970
+ let { metadata } = $$props;
2971
+ let { onHover } = $$props;
2972
+ let { onClick } = $$props;
2973
+ let { onContextMenu } = $$props;
2974
+ let { selectedId = null } = $$props;
2975
+ let startOfWeek;
2976
+ const click_handler = e => onClick(startOfWeek, isMetaPressed(e));
2977
+ const contextmenu_handler = e => onContextMenu(days[0], e);
2978
+ const pointerover_handler = e => onHover(startOfWeek, e.target, isMetaPressed(e));
2979
+
2980
+ $$self.$$set = $$props => {
2981
+ if ("weekNum" in $$props) $$invalidate(0, weekNum = $$props.weekNum);
2982
+ if ("days" in $$props) $$invalidate(1, days = $$props.days);
2983
+ if ("metadata" in $$props) $$invalidate(6, metadata = $$props.metadata);
2984
+ if ("onHover" in $$props) $$invalidate(2, onHover = $$props.onHover);
2985
+ if ("onClick" in $$props) $$invalidate(3, onClick = $$props.onClick);
2986
+ if ("onContextMenu" in $$props) $$invalidate(4, onContextMenu = $$props.onContextMenu);
2987
+ if ("selectedId" in $$props) $$invalidate(5, selectedId = $$props.selectedId);
2988
+ };
2989
+
2990
+ $$self.$$.update = () => {
2991
+ if ($$self.$$.dirty & /*days*/ 2) {
2992
+ $$invalidate(7, startOfWeek = getStartOfWeek(days));
2993
+ }
2994
+ };
2995
+
2996
+ return [
2997
+ weekNum,
2998
+ days,
2999
+ onHover,
3000
+ onClick,
3001
+ onContextMenu,
3002
+ selectedId,
3003
+ metadata,
3004
+ startOfWeek,
3005
+ click_handler,
3006
+ contextmenu_handler,
3007
+ pointerover_handler
3008
+ ];
3009
+ }
3010
+
3011
+ class WeekNum extends SvelteComponent {
3012
+ constructor(options) {
3013
+ super();
3014
+ if (!document.getElementById("svelte-egt0yd-style")) add_css$1();
3015
+
3016
+ init(this, options, instance$1, create_fragment$1, not_equal, {
3017
+ weekNum: 0,
3018
+ days: 1,
3019
+ metadata: 6,
3020
+ onHover: 2,
3021
+ onClick: 3,
3022
+ onContextMenu: 4,
3023
+ selectedId: 5
3024
+ });
3025
+ }
3026
+ }
3027
+
3028
+ async function metadataReducer(promisedMetadata) {
3029
+ const meta = {
3030
+ dots: [],
3031
+ classes: [],
3032
+ dataAttributes: {},
3033
+ };
3034
+ const metas = await Promise.all(promisedMetadata);
3035
+ return metas.reduce((acc, meta) => ({
3036
+ classes: [...acc.classes, ...(meta.classes || [])],
3037
+ dataAttributes: Object.assign(acc.dataAttributes, meta.dataAttributes),
3038
+ dots: [...acc.dots, ...(meta.dots || [])],
3039
+ }), meta);
3040
+ }
3041
+ function getDailyMetadata(sources, date, ..._args) {
3042
+ return metadataReducer(sources.map((source) => source.getDailyMetadata(date)));
3043
+ }
3044
+ function getWeeklyMetadata(sources, date, ..._args) {
3045
+ return metadataReducer(sources.map((source) => source.getWeeklyMetadata(date)));
3046
+ }
3047
+
3048
+ /* src/components/Calendar.svelte generated by Svelte v3.35.0 */
3049
+
3050
+ function add_css() {
3051
+ var style = element("style");
3052
+ style.id = "svelte-pcimu8-style";
3053
+ style.textContent = ".container.svelte-pcimu8{--color-background-heading:transparent;--color-background-day:transparent;--color-background-weeknum:transparent;--color-background-weekend:transparent;--color-dot:var(--text-muted);--color-arrow:var(--text-muted);--color-button:var(--text-muted);--color-text-title:var(--text-normal);--color-text-heading:var(--text-muted);--color-text-day:var(--text-normal);--color-text-today:var(--interactive-accent);--color-text-weeknum:var(--text-muted)}.container.svelte-pcimu8{padding:0 8px}.container.is-mobile.svelte-pcimu8{padding:0}th.svelte-pcimu8{text-align:center}.weekend.svelte-pcimu8{background-color:var(--color-background-weekend)}.calendar.svelte-pcimu8{border-collapse:collapse;width:100%}th.svelte-pcimu8{background-color:var(--color-background-heading);color:var(--color-text-heading);font-size:0.6em;letter-spacing:1px;padding:4px;text-transform:uppercase}";
3054
+ append(document.head, style);
3055
+ }
3056
+
3057
+ function get_each_context(ctx, list, i) {
3058
+ const child_ctx = ctx.slice();
3059
+ child_ctx[18] = list[i];
3060
+ return child_ctx;
3061
+ }
3062
+
3063
+ function get_each_context_1(ctx, list, i) {
3064
+ const child_ctx = ctx.slice();
3065
+ child_ctx[21] = list[i];
3066
+ return child_ctx;
3067
+ }
3068
+
3069
+ function get_each_context_2(ctx, list, i) {
3070
+ const child_ctx = ctx.slice();
3071
+ child_ctx[24] = list[i];
3072
+ return child_ctx;
3073
+ }
3074
+
3075
+ function get_each_context_3(ctx, list, i) {
3076
+ const child_ctx = ctx.slice();
3077
+ child_ctx[27] = list[i];
3078
+ return child_ctx;
3079
+ }
3080
+
3081
+ // (55:6) {#if showWeekNums}
3082
+ function create_if_block_2(ctx) {
3083
+ let col;
3084
+
3085
+ return {
3086
+ c() {
3087
+ col = element("col");
3088
+ },
3089
+ m(target, anchor) {
3090
+ insert(target, col, anchor);
3091
+ },
3092
+ d(detaching) {
3093
+ if (detaching) detach(col);
3094
+ }
3095
+ };
3096
+ }
3097
+
3098
+ // (58:6) {#each month[1].days as date}
3099
+ function create_each_block_3(ctx) {
3100
+ let col;
3101
+
3102
+ return {
3103
+ c() {
3104
+ col = element("col");
3105
+ attr(col, "class", "svelte-pcimu8");
3106
+ toggle_class(col, "weekend", isWeekend(/*date*/ ctx[27]));
3107
+ },
3108
+ m(target, anchor) {
3109
+ insert(target, col, anchor);
3110
+ },
3111
+ p(ctx, dirty) {
3112
+ if (dirty & /*isWeekend, month*/ 16384) {
3113
+ toggle_class(col, "weekend", isWeekend(/*date*/ ctx[27]));
3114
+ }
3115
+ },
3116
+ d(detaching) {
3117
+ if (detaching) detach(col);
3118
+ }
3119
+ };
3120
+ }
3121
+
3122
+ // (64:8) {#if showWeekNums}
3123
+ function create_if_block_1(ctx) {
3124
+ let th;
3125
+
3126
+ return {
3127
+ c() {
3128
+ th = element("th");
3129
+ th.textContent = "W";
3130
+ attr(th, "class", "svelte-pcimu8");
3131
+ },
3132
+ m(target, anchor) {
3133
+ insert(target, th, anchor);
3134
+ },
3135
+ d(detaching) {
3136
+ if (detaching) detach(th);
3137
+ }
3138
+ };
3139
+ }
3140
+
3141
+ // (67:8) {#each daysOfWeek as dayOfWeek}
3142
+ function create_each_block_2(ctx) {
3143
+ let th;
3144
+ let t_value = /*dayOfWeek*/ ctx[24] + "";
3145
+ let t;
3146
+
3147
+ return {
3148
+ c() {
3149
+ th = element("th");
3150
+ t = text(t_value);
3151
+ attr(th, "class", "svelte-pcimu8");
3152
+ },
3153
+ m(target, anchor) {
3154
+ insert(target, th, anchor);
3155
+ append(th, t);
3156
+ },
3157
+ p(ctx, dirty) {
3158
+ if (dirty & /*daysOfWeek*/ 32768 && t_value !== (t_value = /*dayOfWeek*/ ctx[24] + "")) set_data(t, t_value);
3159
+ },
3160
+ d(detaching) {
3161
+ if (detaching) detach(th);
3162
+ }
3163
+ };
3164
+ }
3165
+
3166
+ // (75:10) {#if showWeekNums}
3167
+ function create_if_block(ctx) {
3168
+ let weeknum;
3169
+ let current;
3170
+
3171
+ const weeknum_spread_levels = [
3172
+ /*week*/ ctx[18],
3173
+ {
3174
+ metadata: getWeeklyMetadata(/*sources*/ ctx[8], /*week*/ ctx[18].days[0], /*today*/ ctx[10])
3175
+ },
3176
+ { onClick: /*onClickWeek*/ ctx[7] },
3177
+ {
3178
+ onContextMenu: /*onContextMenuWeek*/ ctx[5]
3179
+ },
3180
+ { onHover: /*onHoverWeek*/ ctx[3] },
3181
+ { selectedId: /*selectedId*/ ctx[9] }
3182
+ ];
3183
+
3184
+ let weeknum_props = {};
3185
+
3186
+ for (let i = 0; i < weeknum_spread_levels.length; i += 1) {
3187
+ weeknum_props = assign(weeknum_props, weeknum_spread_levels[i]);
3188
+ }
3189
+
3190
+ weeknum = new WeekNum({ props: weeknum_props });
3191
+
3192
+ return {
3193
+ c() {
3194
+ create_component(weeknum.$$.fragment);
3195
+ },
3196
+ m(target, anchor) {
3197
+ mount_component(weeknum, target, anchor);
3198
+ current = true;
3199
+ },
3200
+ p(ctx, dirty) {
3201
+ const weeknum_changes = (dirty & /*month, getWeeklyMetadata, sources, today, onClickWeek, onContextMenuWeek, onHoverWeek, selectedId*/ 18344)
3202
+ ? get_spread_update(weeknum_spread_levels, [
3203
+ dirty & /*month*/ 16384 && get_spread_object(/*week*/ ctx[18]),
3204
+ dirty & /*getWeeklyMetadata, sources, month, today*/ 17664 && {
3205
+ metadata: getWeeklyMetadata(/*sources*/ ctx[8], /*week*/ ctx[18].days[0], /*today*/ ctx[10])
3206
+ },
3207
+ dirty & /*onClickWeek*/ 128 && { onClick: /*onClickWeek*/ ctx[7] },
3208
+ dirty & /*onContextMenuWeek*/ 32 && {
3209
+ onContextMenu: /*onContextMenuWeek*/ ctx[5]
3210
+ },
3211
+ dirty & /*onHoverWeek*/ 8 && { onHover: /*onHoverWeek*/ ctx[3] },
3212
+ dirty & /*selectedId*/ 512 && { selectedId: /*selectedId*/ ctx[9] }
3213
+ ])
3214
+ : {};
3215
+
3216
+ weeknum.$set(weeknum_changes);
3217
+ },
3218
+ i(local) {
3219
+ if (current) return;
3220
+ transition_in(weeknum.$$.fragment, local);
3221
+ current = true;
3222
+ },
3223
+ o(local) {
3224
+ transition_out(weeknum.$$.fragment, local);
3225
+ current = false;
3226
+ },
3227
+ d(detaching) {
3228
+ destroy_component(weeknum, detaching);
3229
+ }
3230
+ };
3231
+ }
3232
+
3233
+ // (85:10) {#each week.days as day (day.format())}
3234
+ function create_each_block_1(key_1, ctx) {
3235
+ let first;
3236
+ let day;
3237
+ let current;
3238
+
3239
+ day = new Day({
3240
+ props: {
3241
+ date: /*day*/ ctx[21],
3242
+ today: /*today*/ ctx[10],
3243
+ displayedMonth: /*displayedMonth*/ ctx[0],
3244
+ onClick: /*onClickDay*/ ctx[6],
3245
+ onContextMenu: /*onContextMenuDay*/ ctx[4],
3246
+ onHover: /*onHoverDay*/ ctx[2],
3247
+ metadata: getDailyMetadata(/*sources*/ ctx[8], /*day*/ ctx[21], /*today*/ ctx[10]),
3248
+ selectedId: /*selectedId*/ ctx[9]
3249
+ }
3250
+ });
3251
+
3252
+ return {
3253
+ key: key_1,
3254
+ first: null,
3255
+ c() {
3256
+ first = empty();
3257
+ create_component(day.$$.fragment);
3258
+ this.first = first;
3259
+ },
3260
+ m(target, anchor) {
3261
+ insert(target, first, anchor);
3262
+ mount_component(day, target, anchor);
3263
+ current = true;
3264
+ },
3265
+ p(new_ctx, dirty) {
3266
+ ctx = new_ctx;
3267
+ const day_changes = {};
3268
+ if (dirty & /*month*/ 16384) day_changes.date = /*day*/ ctx[21];
3269
+ if (dirty & /*today*/ 1024) day_changes.today = /*today*/ ctx[10];
3270
+ if (dirty & /*displayedMonth*/ 1) day_changes.displayedMonth = /*displayedMonth*/ ctx[0];
3271
+ if (dirty & /*onClickDay*/ 64) day_changes.onClick = /*onClickDay*/ ctx[6];
3272
+ if (dirty & /*onContextMenuDay*/ 16) day_changes.onContextMenu = /*onContextMenuDay*/ ctx[4];
3273
+ if (dirty & /*onHoverDay*/ 4) day_changes.onHover = /*onHoverDay*/ ctx[2];
3274
+ if (dirty & /*sources, month, today*/ 17664) day_changes.metadata = getDailyMetadata(/*sources*/ ctx[8], /*day*/ ctx[21], /*today*/ ctx[10]);
3275
+ if (dirty & /*selectedId*/ 512) day_changes.selectedId = /*selectedId*/ ctx[9];
3276
+ day.$set(day_changes);
3277
+ },
3278
+ i(local) {
3279
+ if (current) return;
3280
+ transition_in(day.$$.fragment, local);
3281
+ current = true;
3282
+ },
3283
+ o(local) {
3284
+ transition_out(day.$$.fragment, local);
3285
+ current = false;
3286
+ },
3287
+ d(detaching) {
3288
+ if (detaching) detach(first);
3289
+ destroy_component(day, detaching);
3290
+ }
3291
+ };
3292
+ }
3293
+
3294
+ // (73:6) {#each month as week (week.weekNum)}
3295
+ function create_each_block(key_1, ctx) {
3296
+ let tr;
3297
+ let t0;
3298
+ let each_blocks = [];
3299
+ let each_1_lookup = new Map();
3300
+ let t1;
3301
+ let current;
3302
+ let if_block = /*showWeekNums*/ ctx[1] && create_if_block(ctx);
3303
+ let each_value_1 = /*week*/ ctx[18].days;
3304
+ const get_key = ctx => /*day*/ ctx[21].format();
3305
+
3306
+ for (let i = 0; i < each_value_1.length; i += 1) {
3307
+ let child_ctx = get_each_context_1(ctx, each_value_1, i);
3308
+ let key = get_key(child_ctx);
3309
+ each_1_lookup.set(key, each_blocks[i] = create_each_block_1(key, child_ctx));
3310
+ }
3311
+
3312
+ return {
3313
+ key: key_1,
3314
+ first: null,
3315
+ c() {
3316
+ tr = element("tr");
3317
+ if (if_block) if_block.c();
3318
+ t0 = space();
3319
+
3320
+ for (let i = 0; i < each_blocks.length; i += 1) {
3321
+ each_blocks[i].c();
3322
+ }
3323
+
3324
+ t1 = space();
3325
+ this.first = tr;
3326
+ },
3327
+ m(target, anchor) {
3328
+ insert(target, tr, anchor);
3329
+ if (if_block) if_block.m(tr, null);
3330
+ append(tr, t0);
3331
+
3332
+ for (let i = 0; i < each_blocks.length; i += 1) {
3333
+ each_blocks[i].m(tr, null);
3334
+ }
3335
+
3336
+ append(tr, t1);
3337
+ current = true;
3338
+ },
3339
+ p(new_ctx, dirty) {
3340
+ ctx = new_ctx;
3341
+
3342
+ if (/*showWeekNums*/ ctx[1]) {
3343
+ if (if_block) {
3344
+ if_block.p(ctx, dirty);
3345
+
3346
+ if (dirty & /*showWeekNums*/ 2) {
3347
+ transition_in(if_block, 1);
3348
+ }
3349
+ } else {
3350
+ if_block = create_if_block(ctx);
3351
+ if_block.c();
3352
+ transition_in(if_block, 1);
3353
+ if_block.m(tr, t0);
3354
+ }
3355
+ } else if (if_block) {
3356
+ group_outros();
3357
+
3358
+ transition_out(if_block, 1, 1, () => {
3359
+ if_block = null;
3360
+ });
3361
+
3362
+ check_outros();
3363
+ }
3364
+
3365
+ if (dirty & /*month, today, displayedMonth, onClickDay, onContextMenuDay, onHoverDay, getDailyMetadata, sources, selectedId*/ 18261) {
3366
+ each_value_1 = /*week*/ ctx[18].days;
3367
+ group_outros();
3368
+ each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value_1, each_1_lookup, tr, outro_and_destroy_block, create_each_block_1, t1, get_each_context_1);
3369
+ check_outros();
3370
+ }
3371
+ },
3372
+ i(local) {
3373
+ if (current) return;
3374
+ transition_in(if_block);
3375
+
3376
+ for (let i = 0; i < each_value_1.length; i += 1) {
3377
+ transition_in(each_blocks[i]);
3378
+ }
3379
+
3380
+ current = true;
3381
+ },
3382
+ o(local) {
3383
+ transition_out(if_block);
3384
+
3385
+ for (let i = 0; i < each_blocks.length; i += 1) {
3386
+ transition_out(each_blocks[i]);
3387
+ }
3388
+
3389
+ current = false;
3390
+ },
3391
+ d(detaching) {
3392
+ if (detaching) detach(tr);
3393
+ if (if_block) if_block.d();
3394
+
3395
+ for (let i = 0; i < each_blocks.length; i += 1) {
3396
+ each_blocks[i].d();
3397
+ }
3398
+ }
3399
+ };
3400
+ }
3401
+
3402
+ function create_fragment$7(ctx) {
3403
+ let div;
3404
+ let nav;
3405
+ let t0;
3406
+ let table;
3407
+ let colgroup;
3408
+ let t1;
3409
+ let t2;
3410
+ let thead;
3411
+ let tr;
3412
+ let t3;
3413
+ let t4;
3414
+ let tbody;
3415
+ let each_blocks = [];
3416
+ let each2_lookup = new Map();
3417
+ let current;
3418
+
3419
+ nav = new Nav({
3420
+ props: {
3421
+ today: /*today*/ ctx[10],
3422
+ displayedMonth: /*displayedMonth*/ ctx[0],
3423
+ incrementDisplayedMonth: /*incrementDisplayedMonth*/ ctx[11],
3424
+ decrementDisplayedMonth: /*decrementDisplayedMonth*/ ctx[12],
3425
+ resetDisplayedMonth: /*resetDisplayedMonth*/ ctx[13]
3426
+ }
3427
+ });
3428
+
3429
+ let if_block0 = /*showWeekNums*/ ctx[1] && create_if_block_2();
3430
+ let each_value_3 = /*month*/ ctx[14][1].days;
3431
+ let each_blocks_2 = [];
3432
+
3433
+ for (let i = 0; i < each_value_3.length; i += 1) {
3434
+ each_blocks_2[i] = create_each_block_3(get_each_context_3(ctx, each_value_3, i));
3435
+ }
3436
+
3437
+ let if_block1 = /*showWeekNums*/ ctx[1] && create_if_block_1();
3438
+ let each_value_2 = /*daysOfWeek*/ ctx[15];
3439
+ let each_blocks_1 = [];
3440
+
3441
+ for (let i = 0; i < each_value_2.length; i += 1) {
3442
+ each_blocks_1[i] = create_each_block_2(get_each_context_2(ctx, each_value_2, i));
3443
+ }
3444
+
3445
+ let each_value = /*month*/ ctx[14];
3446
+ const get_key = ctx => /*week*/ ctx[18].weekNum;
3447
+
3448
+ for (let i = 0; i < each_value.length; i += 1) {
3449
+ let child_ctx = get_each_context(ctx, each_value, i);
3450
+ let key = get_key(child_ctx);
3451
+ each2_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
3452
+ }
3453
+
3454
+ return {
3455
+ c() {
3456
+ div = element("div");
3457
+ create_component(nav.$$.fragment);
3458
+ t0 = space();
3459
+ table = element("table");
3460
+ colgroup = element("colgroup");
3461
+ if (if_block0) if_block0.c();
3462
+ t1 = space();
3463
+
3464
+ for (let i = 0; i < each_blocks_2.length; i += 1) {
3465
+ each_blocks_2[i].c();
3466
+ }
3467
+
3468
+ t2 = space();
3469
+ thead = element("thead");
3470
+ tr = element("tr");
3471
+ if (if_block1) if_block1.c();
3472
+ t3 = space();
3473
+
3474
+ for (let i = 0; i < each_blocks_1.length; i += 1) {
3475
+ each_blocks_1[i].c();
3476
+ }
3477
+
3478
+ t4 = space();
3479
+ tbody = element("tbody");
3480
+
3481
+ for (let i = 0; i < each_blocks.length; i += 1) {
3482
+ each_blocks[i].c();
3483
+ }
3484
+
3485
+ attr(table, "class", "calendar svelte-pcimu8");
3486
+ attr(div, "id", "calendar-container");
3487
+ attr(div, "class", "container svelte-pcimu8");
3488
+ toggle_class(div, "is-mobile", /*isMobile*/ ctx[16]);
3489
+ },
3490
+ m(target, anchor) {
3491
+ insert(target, div, anchor);
3492
+ mount_component(nav, div, null);
3493
+ append(div, t0);
3494
+ append(div, table);
3495
+ append(table, colgroup);
3496
+ if (if_block0) if_block0.m(colgroup, null);
3497
+ append(colgroup, t1);
3498
+
3499
+ for (let i = 0; i < each_blocks_2.length; i += 1) {
3500
+ each_blocks_2[i].m(colgroup, null);
3501
+ }
3502
+
3503
+ append(table, t2);
3504
+ append(table, thead);
3505
+ append(thead, tr);
3506
+ if (if_block1) if_block1.m(tr, null);
3507
+ append(tr, t3);
3508
+
3509
+ for (let i = 0; i < each_blocks_1.length; i += 1) {
3510
+ each_blocks_1[i].m(tr, null);
3511
+ }
3512
+
3513
+ append(table, t4);
3514
+ append(table, tbody);
3515
+
3516
+ for (let i = 0; i < each_blocks.length; i += 1) {
3517
+ each_blocks[i].m(tbody, null);
3518
+ }
3519
+
3520
+ current = true;
3521
+ },
3522
+ p(ctx, [dirty]) {
3523
+ const nav_changes = {};
3524
+ if (dirty & /*today*/ 1024) nav_changes.today = /*today*/ ctx[10];
3525
+ if (dirty & /*displayedMonth*/ 1) nav_changes.displayedMonth = /*displayedMonth*/ ctx[0];
3526
+ nav.$set(nav_changes);
3527
+
3528
+ if (/*showWeekNums*/ ctx[1]) {
3529
+ if (if_block0) ; else {
3530
+ if_block0 = create_if_block_2();
3531
+ if_block0.c();
3532
+ if_block0.m(colgroup, t1);
3533
+ }
3534
+ } else if (if_block0) {
3535
+ if_block0.d(1);
3536
+ if_block0 = null;
3537
+ }
3538
+
3539
+ if (dirty & /*isWeekend, month*/ 16384) {
3540
+ each_value_3 = /*month*/ ctx[14][1].days;
3541
+ let i;
3542
+
3543
+ for (i = 0; i < each_value_3.length; i += 1) {
3544
+ const child_ctx = get_each_context_3(ctx, each_value_3, i);
3545
+
3546
+ if (each_blocks_2[i]) {
3547
+ each_blocks_2[i].p(child_ctx, dirty);
3548
+ } else {
3549
+ each_blocks_2[i] = create_each_block_3(child_ctx);
3550
+ each_blocks_2[i].c();
3551
+ each_blocks_2[i].m(colgroup, null);
3552
+ }
3553
+ }
3554
+
3555
+ for (; i < each_blocks_2.length; i += 1) {
3556
+ each_blocks_2[i].d(1);
3557
+ }
3558
+
3559
+ each_blocks_2.length = each_value_3.length;
3560
+ }
3561
+
3562
+ if (/*showWeekNums*/ ctx[1]) {
3563
+ if (if_block1) ; else {
3564
+ if_block1 = create_if_block_1();
3565
+ if_block1.c();
3566
+ if_block1.m(tr, t3);
3567
+ }
3568
+ } else if (if_block1) {
3569
+ if_block1.d(1);
3570
+ if_block1 = null;
3571
+ }
3572
+
3573
+ if (dirty & /*daysOfWeek*/ 32768) {
3574
+ each_value_2 = /*daysOfWeek*/ ctx[15];
3575
+ let i;
3576
+
3577
+ for (i = 0; i < each_value_2.length; i += 1) {
3578
+ const child_ctx = get_each_context_2(ctx, each_value_2, i);
3579
+
3580
+ if (each_blocks_1[i]) {
3581
+ each_blocks_1[i].p(child_ctx, dirty);
3582
+ } else {
3583
+ each_blocks_1[i] = create_each_block_2(child_ctx);
3584
+ each_blocks_1[i].c();
3585
+ each_blocks_1[i].m(tr, null);
3586
+ }
3587
+ }
3588
+
3589
+ for (; i < each_blocks_1.length; i += 1) {
3590
+ each_blocks_1[i].d(1);
3591
+ }
3592
+
3593
+ each_blocks_1.length = each_value_2.length;
3594
+ }
3595
+
3596
+ if (dirty & /*month, today, displayedMonth, onClickDay, onContextMenuDay, onHoverDay, getDailyMetadata, sources, selectedId, getWeeklyMetadata, onClickWeek, onContextMenuWeek, onHoverWeek, showWeekNums*/ 18431) {
3597
+ each_value = /*month*/ ctx[14];
3598
+ group_outros();
3599
+ each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each2_lookup, tbody, outro_and_destroy_block, create_each_block, null, get_each_context);
3600
+ check_outros();
3601
+ }
3602
+ },
3603
+ i(local) {
3604
+ if (current) return;
3605
+ transition_in(nav.$$.fragment, local);
3606
+
3607
+ for (let i = 0; i < each_value.length; i += 1) {
3608
+ transition_in(each_blocks[i]);
3609
+ }
3610
+
3611
+ current = true;
3612
+ },
3613
+ o(local) {
3614
+ transition_out(nav.$$.fragment, local);
3615
+
3616
+ for (let i = 0; i < each_blocks.length; i += 1) {
3617
+ transition_out(each_blocks[i]);
3618
+ }
3619
+
3620
+ current = false;
3621
+ },
3622
+ d(detaching) {
3623
+ if (detaching) detach(div);
3624
+ destroy_component(nav);
3625
+ if (if_block0) if_block0.d();
3626
+ destroy_each(each_blocks_2, detaching);
3627
+ if (if_block1) if_block1.d();
3628
+ destroy_each(each_blocks_1, detaching);
3629
+
3630
+ for (let i = 0; i < each_blocks.length; i += 1) {
3631
+ each_blocks[i].d();
3632
+ }
3633
+ }
3634
+ };
3635
+ }
3636
+
3637
+ function instance$7($$self, $$props, $$invalidate) {
3638
+
3639
+
3640
+ let { localeData } = $$props;
3641
+ let { showWeekNums = false } = $$props;
3642
+ let { onHoverDay } = $$props;
3643
+ let { onHoverWeek } = $$props;
3644
+ let { onContextMenuDay } = $$props;
3645
+ let { onContextMenuWeek } = $$props;
3646
+ let { onClickDay } = $$props;
3647
+ let { onClickWeek } = $$props;
3648
+ let { sources = [] } = $$props;
3649
+ let { selectedId } = $$props;
3650
+ let { today = window.moment() } = $$props;
3651
+ let { displayedMonth = today } = $$props;
3652
+ let month;
3653
+ let daysOfWeek;
3654
+
3655
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3656
+ let isMobile = window.app.isMobile;
3657
+
3658
+ function incrementDisplayedMonth() {
3659
+ $$invalidate(0, displayedMonth = displayedMonth.clone().add(1, "month"));
3660
+ }
3661
+
3662
+ function decrementDisplayedMonth() {
3663
+ $$invalidate(0, displayedMonth = displayedMonth.clone().subtract(1, "month"));
3664
+ }
3665
+
3666
+ function resetDisplayedMonth() {
3667
+ $$invalidate(0, displayedMonth = today.clone());
3668
+ }
3669
+
3670
+ $$self.$$set = $$props => {
3671
+ if ("localeData" in $$props) $$invalidate(17, localeData = $$props.localeData);
3672
+ if ("showWeekNums" in $$props) $$invalidate(1, showWeekNums = $$props.showWeekNums);
3673
+ if ("onHoverDay" in $$props) $$invalidate(2, onHoverDay = $$props.onHoverDay);
3674
+ if ("onHoverWeek" in $$props) $$invalidate(3, onHoverWeek = $$props.onHoverWeek);
3675
+ if ("onContextMenuDay" in $$props) $$invalidate(4, onContextMenuDay = $$props.onContextMenuDay);
3676
+ if ("onContextMenuWeek" in $$props) $$invalidate(5, onContextMenuWeek = $$props.onContextMenuWeek);
3677
+ if ("onClickDay" in $$props) $$invalidate(6, onClickDay = $$props.onClickDay);
3678
+ if ("onClickWeek" in $$props) $$invalidate(7, onClickWeek = $$props.onClickWeek);
3679
+ if ("sources" in $$props) $$invalidate(8, sources = $$props.sources);
3680
+ if ("selectedId" in $$props) $$invalidate(9, selectedId = $$props.selectedId);
3681
+ if ("today" in $$props) $$invalidate(10, today = $$props.today);
3682
+ if ("displayedMonth" in $$props) $$invalidate(0, displayedMonth = $$props.displayedMonth);
3683
+ };
3684
+
3685
+ $$self.$$.update = () => {
3686
+ if ($$self.$$.dirty & /*displayedMonth, localeData*/ 131073) {
3687
+ $$invalidate(14, month = getMonth(displayedMonth, localeData));
3688
+ }
3689
+
3690
+ if ($$self.$$.dirty & /*today, localeData*/ 132096) {
3691
+ $$invalidate(15, daysOfWeek = getDaysOfWeek(today, localeData));
3692
+ }
3693
+ };
3694
+
3695
+ return [
3696
+ displayedMonth,
3697
+ showWeekNums,
3698
+ onHoverDay,
3699
+ onHoverWeek,
3700
+ onContextMenuDay,
3701
+ onContextMenuWeek,
3702
+ onClickDay,
3703
+ onClickWeek,
3704
+ sources,
3705
+ selectedId,
3706
+ today,
3707
+ incrementDisplayedMonth,
3708
+ decrementDisplayedMonth,
3709
+ resetDisplayedMonth,
3710
+ month,
3711
+ daysOfWeek,
3712
+ isMobile,
3713
+ localeData
3714
+ ];
3715
+ }
3716
+
3717
+ class Calendar$1 extends SvelteComponent {
3718
+ constructor(options) {
3719
+ super();
3720
+ if (!document.getElementById("svelte-pcimu8-style")) add_css();
3721
+
3722
+ init(this, options, instance$7, create_fragment$7, not_equal, {
3723
+ localeData: 17,
3724
+ showWeekNums: 1,
3725
+ onHoverDay: 2,
3726
+ onHoverWeek: 3,
3727
+ onContextMenuDay: 4,
3728
+ onContextMenuWeek: 5,
3729
+ onClickDay: 6,
3730
+ onClickWeek: 7,
3731
+ sources: 8,
3732
+ selectedId: 9,
3733
+ today: 10,
3734
+ displayedMonth: 0,
3735
+ incrementDisplayedMonth: 11,
3736
+ decrementDisplayedMonth: 12,
3737
+ resetDisplayedMonth: 13
3738
+ });
3739
+ }
3740
+
3741
+ get incrementDisplayedMonth() {
3742
+ return this.$$.ctx[11];
3743
+ }
3744
+
3745
+ get decrementDisplayedMonth() {
3746
+ return this.$$.ctx[12];
3747
+ }
3748
+
3749
+ get resetDisplayedMonth() {
3750
+ return this.$$.ctx[13];
3751
+ }
3752
+ }
3753
+
3754
+ const langToMomentLocale = {
3755
+ en: "en-gb",
3756
+ zh: "zh-cn",
3757
+ "zh-TW": "zh-tw",
3758
+ ru: "ru",
3759
+ ko: "ko",
3760
+ it: "it",
3761
+ id: "id",
3762
+ ro: "ro",
3763
+ "pt-BR": "pt-br",
3764
+ cz: "cs",
3765
+ da: "da",
3766
+ de: "de",
3767
+ es: "es",
3768
+ fr: "fr",
3769
+ no: "nn",
3770
+ pl: "pl",
3771
+ pt: "pt",
3772
+ tr: "tr",
3773
+ hi: "hi",
3774
+ nl: "nl",
3775
+ ar: "ar",
3776
+ ja: "ja",
3777
+ };
3778
+ const weekdays = [
3779
+ "sunday",
3780
+ "monday",
3781
+ "tuesday",
3782
+ "wednesday",
3783
+ "thursday",
3784
+ "friday",
3785
+ "saturday",
3786
+ ];
3787
+ function overrideGlobalMomentWeekStart(weekStart) {
3788
+ const { moment } = window;
3789
+ const currentLocale = moment.locale();
3790
+ // Save the initial locale weekspec so that we can restore
3791
+ // it when toggling between the different options in settings.
3792
+ if (!window._bundledLocaleWeekSpec) {
3793
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3794
+ window._bundledLocaleWeekSpec = moment.localeData()._week;
3795
+ }
3796
+ if (weekStart === "locale") {
3797
+ moment.updateLocale(currentLocale, {
3798
+ week: window._bundledLocaleWeekSpec,
3799
+ });
3800
+ }
3801
+ else {
3802
+ moment.updateLocale(currentLocale, {
3803
+ week: {
3804
+ dow: weekdays.indexOf(weekStart) || 0,
3805
+ },
3806
+ });
3807
+ }
3808
+ }
3809
+ /**
3810
+ * Sets the locale used by the calendar. This allows the calendar to
3811
+ * default to the user's locale (e.g. Start Week on Sunday/Monday/Friday)
3812
+ *
3813
+ * @param localeOverride locale string (e.g. "en-US")
3814
+ */
3815
+ function configureGlobalMomentLocale(localeOverride = "system-default", weekStart = "locale") {
3816
+ var _a;
3817
+ const obsidianLang = localStorage.getItem("language") || "en";
3818
+ const systemLang = (_a = navigator.language) === null || _a === void 0 ? void 0 : _a.toLowerCase();
3819
+ let momentLocale = langToMomentLocale[obsidianLang];
3820
+ if (localeOverride !== "system-default") {
3821
+ momentLocale = localeOverride;
3822
+ }
3823
+ else if (systemLang.startsWith(obsidianLang)) {
3824
+ // If the system locale is more specific (en-gb vs en), use the system locale.
3825
+ momentLocale = systemLang;
3826
+ }
3827
+ const currentLocale = window.moment.locale(momentLocale);
3828
+ console.debug(`[Calendar] Trying to switch Moment.js global locale to ${momentLocale}, got ${currentLocale}`);
3829
+ overrideGlobalMomentWeekStart(weekStart);
3830
+ return currentLocale;
3831
+ }
3832
+
3833
+ /* src/ui/Calendar.svelte generated by Svelte v3.35.0 */
3834
+
3835
+ function create_fragment(ctx) {
3836
+ let calendarbase;
3837
+ let updating_displayedMonth;
3838
+ let current;
3839
+
3840
+ function calendarbase_displayedMonth_binding(value) {
3841
+ /*calendarbase_displayedMonth_binding*/ ctx[12](value);
3842
+ }
3843
+
3844
+ let calendarbase_props = {
3845
+ sources: /*sources*/ ctx[1],
3846
+ today: /*today*/ ctx[9],
3847
+ onHoverDay: /*onHoverDay*/ ctx[2],
3848
+ onHoverWeek: /*onHoverWeek*/ ctx[3],
3849
+ onContextMenuDay: /*onContextMenuDay*/ ctx[6],
3850
+ onContextMenuWeek: /*onContextMenuWeek*/ ctx[7],
3851
+ onClickDay: /*onClickDay*/ ctx[4],
3852
+ onClickWeek: /*onClickWeek*/ ctx[5],
3853
+ localeData: /*today*/ ctx[9].localeData(),
3854
+ selectedId: /*$activeFile*/ ctx[10],
3855
+ showWeekNums: /*$settings*/ ctx[8].showWeeklyNote
3856
+ };
3857
+
3858
+ if (/*displayedMonth*/ ctx[0] !== void 0) {
3859
+ calendarbase_props.displayedMonth = /*displayedMonth*/ ctx[0];
3860
+ }
3861
+
3862
+ calendarbase = new Calendar$1({ props: calendarbase_props });
3863
+ binding_callbacks$1.push(() => bind(calendarbase, "displayedMonth", calendarbase_displayedMonth_binding));
3864
+
3865
+ return {
3866
+ c() {
3867
+ create_component$1(calendarbase.$$.fragment);
3868
+ },
3869
+ m(target, anchor) {
3870
+ mount_component$1(calendarbase, target, anchor);
3871
+ current = true;
3872
+ },
3873
+ p(ctx, [dirty]) {
3874
+ const calendarbase_changes = {};
3875
+ if (dirty & /*sources*/ 2) calendarbase_changes.sources = /*sources*/ ctx[1];
3876
+ if (dirty & /*today*/ 512) calendarbase_changes.today = /*today*/ ctx[9];
3877
+ if (dirty & /*onHoverDay*/ 4) calendarbase_changes.onHoverDay = /*onHoverDay*/ ctx[2];
3878
+ if (dirty & /*onHoverWeek*/ 8) calendarbase_changes.onHoverWeek = /*onHoverWeek*/ ctx[3];
3879
+ if (dirty & /*onContextMenuDay*/ 64) calendarbase_changes.onContextMenuDay = /*onContextMenuDay*/ ctx[6];
3880
+ if (dirty & /*onContextMenuWeek*/ 128) calendarbase_changes.onContextMenuWeek = /*onContextMenuWeek*/ ctx[7];
3881
+ if (dirty & /*onClickDay*/ 16) calendarbase_changes.onClickDay = /*onClickDay*/ ctx[4];
3882
+ if (dirty & /*onClickWeek*/ 32) calendarbase_changes.onClickWeek = /*onClickWeek*/ ctx[5];
3883
+ if (dirty & /*today*/ 512) calendarbase_changes.localeData = /*today*/ ctx[9].localeData();
3884
+ if (dirty & /*$activeFile*/ 1024) calendarbase_changes.selectedId = /*$activeFile*/ ctx[10];
3885
+ if (dirty & /*$settings*/ 256) calendarbase_changes.showWeekNums = /*$settings*/ ctx[8].showWeeklyNote;
3886
+
3887
+ if (!updating_displayedMonth && dirty & /*displayedMonth*/ 1) {
3888
+ updating_displayedMonth = true;
3889
+ calendarbase_changes.displayedMonth = /*displayedMonth*/ ctx[0];
3890
+ add_flush_callback(() => updating_displayedMonth = false);
3891
+ }
3892
+
3893
+ calendarbase.$set(calendarbase_changes);
3894
+ },
3895
+ i(local) {
3896
+ if (current) return;
3897
+ transition_in$1(calendarbase.$$.fragment, local);
3898
+ current = true;
3899
+ },
3900
+ o(local) {
3901
+ transition_out$1(calendarbase.$$.fragment, local);
3902
+ current = false;
3903
+ },
3904
+ d(detaching) {
3905
+ destroy_component$1(calendarbase, detaching);
3906
+ }
3907
+ };
3908
+ }
3909
+
3910
+ function instance($$self, $$props, $$invalidate) {
3911
+ let $settings;
3912
+ let $activeFile;
3913
+ component_subscribe($$self, settings, $$value => $$invalidate(8, $settings = $$value));
3914
+ component_subscribe($$self, activeFile, $$value => $$invalidate(10, $activeFile = $$value));
3915
+
3916
+
3917
+ let today;
3918
+ let { displayedMonth = today } = $$props;
3919
+ let { sources } = $$props;
3920
+ let { onHoverDay } = $$props;
3921
+ let { onHoverWeek } = $$props;
3922
+ let { onClickDay } = $$props;
3923
+ let { onClickWeek } = $$props;
3924
+ let { onContextMenuDay } = $$props;
3925
+ let { onContextMenuWeek } = $$props;
3926
+
3927
+ function tick() {
3928
+ $$invalidate(9, today = window.moment());
3929
+ }
3930
+
3931
+ function getToday(settings) {
3932
+ configureGlobalMomentLocale(settings.localeOverride, settings.weekStart);
3933
+ dailyNotes.reindex();
3934
+ weeklyNotes.reindex();
3935
+ return window.moment();
3936
+ }
3937
+
3938
+ // 1 minute heartbeat to keep `today` reflecting the current day
3939
+ let heartbeat = setInterval(
3940
+ () => {
3941
+ tick();
3942
+ const isViewingCurrentMonth = displayedMonth.isSame(today, "day");
3943
+
3944
+ if (isViewingCurrentMonth) {
3945
+ // if it's midnight on the last day of the month, this will
3946
+ // update the display to show the new month.
3947
+ $$invalidate(0, displayedMonth = today);
3948
+ }
3949
+ },
3950
+ 1000 * 60
3951
+ );
3952
+
3953
+ onDestroy(() => {
3954
+ clearInterval(heartbeat);
3955
+ });
3956
+
3957
+ function calendarbase_displayedMonth_binding(value) {
3958
+ displayedMonth = value;
3959
+ $$invalidate(0, displayedMonth);
3960
+ }
3961
+
3962
+ $$self.$$set = $$props => {
3963
+ if ("displayedMonth" in $$props) $$invalidate(0, displayedMonth = $$props.displayedMonth);
3964
+ if ("sources" in $$props) $$invalidate(1, sources = $$props.sources);
3965
+ if ("onHoverDay" in $$props) $$invalidate(2, onHoverDay = $$props.onHoverDay);
3966
+ if ("onHoverWeek" in $$props) $$invalidate(3, onHoverWeek = $$props.onHoverWeek);
3967
+ if ("onClickDay" in $$props) $$invalidate(4, onClickDay = $$props.onClickDay);
3968
+ if ("onClickWeek" in $$props) $$invalidate(5, onClickWeek = $$props.onClickWeek);
3969
+ if ("onContextMenuDay" in $$props) $$invalidate(6, onContextMenuDay = $$props.onContextMenuDay);
3970
+ if ("onContextMenuWeek" in $$props) $$invalidate(7, onContextMenuWeek = $$props.onContextMenuWeek);
3971
+ };
3972
+
3973
+ $$self.$$.update = () => {
3974
+ if ($$self.$$.dirty & /*$settings*/ 256) {
3975
+ $$invalidate(9, today = getToday($settings));
3976
+ }
3977
+ };
3978
+
3979
+ return [
3980
+ displayedMonth,
3981
+ sources,
3982
+ onHoverDay,
3983
+ onHoverWeek,
3984
+ onClickDay,
3985
+ onClickWeek,
3986
+ onContextMenuDay,
3987
+ onContextMenuWeek,
3988
+ $settings,
3989
+ today,
3990
+ $activeFile,
3991
+ tick,
3992
+ calendarbase_displayedMonth_binding
3993
+ ];
3994
+ }
3995
+
3996
+ class Calendar extends SvelteComponent$1 {
3997
+ constructor(options) {
3998
+ super();
3999
+
4000
+ init$1(this, options, instance, create_fragment, not_equal$1, {
4001
+ displayedMonth: 0,
4002
+ sources: 1,
4003
+ onHoverDay: 2,
4004
+ onHoverWeek: 3,
4005
+ onClickDay: 4,
4006
+ onClickWeek: 5,
4007
+ onContextMenuDay: 6,
4008
+ onContextMenuWeek: 7,
4009
+ tick: 11
4010
+ });
4011
+ }
4012
+
4013
+ get tick() {
4014
+ return this.$$.ctx[11];
4015
+ }
4016
+ }
4017
+
4018
+ function showFileMenu(app, file, position) {
4019
+ const fileMenu = new obsidian.Menu(app);
4020
+ fileMenu.addItem((item) => item
4021
+ .setTitle("Delete")
4022
+ .setIcon("trash")
4023
+ .onClick(() => {
4024
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4025
+ app.fileManager.promptForFileDeletion(file);
4026
+ }));
4027
+ app.workspace.trigger("file-menu", fileMenu, file, "calendar-context-menu", null);
4028
+ fileMenu.showAtPosition(position);
4029
+ }
4030
+
4031
+ const getStreakClasses = (file) => {
4032
+ return classList({
4033
+ "has-note": !!file,
4034
+ });
4035
+ };
4036
+ const streakSource = {
4037
+ getDailyMetadata: async (date) => {
4038
+ const file = getDailyNote_1(date, get_store_value(dailyNotes));
4039
+ return {
4040
+ classes: getStreakClasses(file),
4041
+ dots: [],
4042
+ };
4043
+ },
4044
+ getWeeklyMetadata: async (date) => {
4045
+ const file = getWeeklyNote_1(date, get_store_value(weeklyNotes));
4046
+ return {
4047
+ classes: getStreakClasses(file),
4048
+ dots: [],
4049
+ };
4050
+ },
4051
+ };
4052
+
4053
+ function getNoteTags(note) {
4054
+ var _a;
4055
+ if (!note) {
4056
+ return [];
4057
+ }
4058
+ const { metadataCache } = window.app;
4059
+ const frontmatter = (_a = metadataCache.getFileCache(note)) === null || _a === void 0 ? void 0 : _a.frontmatter;
4060
+ const tags = [];
4061
+ if (frontmatter) {
4062
+ const frontmatterTags = obsidian.parseFrontMatterTags(frontmatter) || [];
4063
+ tags.push(...frontmatterTags);
4064
+ }
4065
+ // strip the '#' at the beginning
4066
+ return tags.map((tag) => tag.substring(1));
4067
+ }
4068
+ function getFormattedTagAttributes(note) {
4069
+ const attrs = {};
4070
+ const tags = getNoteTags(note);
4071
+ const [emojiTags, nonEmojiTags] = partition(tags, (tag) => /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/.test(tag));
4072
+ if (nonEmojiTags) {
4073
+ attrs["data-tags"] = nonEmojiTags.join(" ");
4074
+ }
4075
+ if (emojiTags) {
4076
+ attrs["data-emoji-tag"] = emojiTags[0];
4077
+ }
4078
+ return attrs;
4079
+ }
4080
+ const customTagsSource = {
4081
+ getDailyMetadata: async (date) => {
4082
+ const file = getDailyNote_1(date, get_store_value(dailyNotes));
4083
+ return {
4084
+ dataAttributes: getFormattedTagAttributes(file),
4085
+ dots: [],
4086
+ };
4087
+ },
4088
+ getWeeklyMetadata: async (date) => {
4089
+ const file = getWeeklyNote_1(date, get_store_value(weeklyNotes));
4090
+ return {
4091
+ dataAttributes: getFormattedTagAttributes(file),
4092
+ dots: [],
4093
+ };
4094
+ },
4095
+ };
4096
+
4097
+ async function getNumberOfRemainingTasks(note) {
4098
+ if (!note) {
4099
+ return 0;
4100
+ }
4101
+ const { vault } = window.app;
4102
+ const fileContents = await vault.cachedRead(note);
4103
+ return (fileContents.match(/(-|\*) \[ \]/g) || []).length;
4104
+ }
4105
+ async function getDotsForDailyNote$1(dailyNote) {
4106
+ if (!dailyNote) {
4107
+ return [];
4108
+ }
4109
+ const numTasks = await getNumberOfRemainingTasks(dailyNote);
4110
+ const dots = [];
4111
+ if (numTasks) {
4112
+ dots.push({
4113
+ className: "task",
4114
+ color: "default",
4115
+ isFilled: false,
4116
+ });
4117
+ }
4118
+ return dots;
4119
+ }
4120
+ const tasksSource = {
4121
+ getDailyMetadata: async (date) => {
4122
+ const file = getDailyNote_1(date, get_store_value(dailyNotes));
4123
+ const dots = await getDotsForDailyNote$1(file);
4124
+ return {
4125
+ dots,
4126
+ };
4127
+ },
4128
+ getWeeklyMetadata: async (date) => {
4129
+ const file = getWeeklyNote_1(date, get_store_value(weeklyNotes));
4130
+ const dots = await getDotsForDailyNote$1(file);
4131
+ return {
4132
+ dots,
4133
+ };
4134
+ },
4135
+ };
4136
+
4137
+ const NUM_MAX_DOTS = 5;
4138
+ async function getWordLengthAsDots(note) {
4139
+ const { wordsPerDot = DEFAULT_WORDS_PER_DOT } = get_store_value(settings);
4140
+ if (!note || wordsPerDot <= 0) {
4141
+ return 0;
4142
+ }
4143
+ const fileContents = await window.app.vault.cachedRead(note);
4144
+ const wordCount = getWordCount(fileContents);
4145
+ const numDots = wordCount / wordsPerDot;
4146
+ return clamp(Math.floor(numDots), 1, NUM_MAX_DOTS);
4147
+ }
4148
+ async function getDotsForDailyNote(dailyNote) {
4149
+ if (!dailyNote) {
4150
+ return [];
4151
+ }
4152
+ const numSolidDots = await getWordLengthAsDots(dailyNote);
4153
+ const dots = [];
4154
+ for (let i = 0; i < numSolidDots; i++) {
4155
+ dots.push({
4156
+ color: "default",
4157
+ isFilled: true,
4158
+ });
4159
+ }
4160
+ return dots;
4161
+ }
4162
+ const wordCountSource = {
4163
+ getDailyMetadata: async (date) => {
4164
+ const file = getDailyNote_1(date, get_store_value(dailyNotes));
4165
+ const dots = await getDotsForDailyNote(file);
4166
+ return {
4167
+ dots,
4168
+ };
4169
+ },
4170
+ getWeeklyMetadata: async (date) => {
4171
+ const file = getWeeklyNote_1(date, get_store_value(weeklyNotes));
4172
+ const dots = await getDotsForDailyNote(file);
4173
+ return {
4174
+ dots,
4175
+ };
4176
+ },
4177
+ };
4178
+
4179
+ class CalendarView extends obsidian.ItemView {
4180
+ constructor(leaf) {
4181
+ super(leaf);
4182
+ this.openOrCreateDailyNote = this.openOrCreateDailyNote.bind(this);
4183
+ this.openOrCreateWeeklyNote = this.openOrCreateWeeklyNote.bind(this);
4184
+ this.onNoteSettingsUpdate = this.onNoteSettingsUpdate.bind(this);
4185
+ this.onFileCreated = this.onFileCreated.bind(this);
4186
+ this.onFileDeleted = this.onFileDeleted.bind(this);
4187
+ this.onFileModified = this.onFileModified.bind(this);
4188
+ this.onFileOpen = this.onFileOpen.bind(this);
4189
+ this.onHoverDay = this.onHoverDay.bind(this);
4190
+ this.onHoverWeek = this.onHoverWeek.bind(this);
4191
+ this.onContextMenuDay = this.onContextMenuDay.bind(this);
4192
+ this.onContextMenuWeek = this.onContextMenuWeek.bind(this);
4193
+ this.registerEvent(
4194
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4195
+ this.app.workspace.on("periodic-notes:settings-updated", this.onNoteSettingsUpdate));
4196
+ this.registerEvent(this.app.vault.on("create", this.onFileCreated));
4197
+ this.registerEvent(this.app.vault.on("delete", this.onFileDeleted));
4198
+ this.registerEvent(this.app.vault.on("modify", this.onFileModified));
4199
+ this.registerEvent(this.app.workspace.on("file-open", this.onFileOpen));
4200
+ this.settings = null;
4201
+ settings.subscribe((val) => {
4202
+ this.settings = val;
4203
+ // Refresh the calendar if settings change
4204
+ if (this.calendar) {
4205
+ this.calendar.tick();
4206
+ }
4207
+ });
4208
+ }
4209
+ getViewType() {
4210
+ return VIEW_TYPE_CALENDAR;
4211
+ }
4212
+ getDisplayText() {
4213
+ return "Calendar";
4214
+ }
4215
+ getIcon() {
4216
+ return "calendar-with-checkmark";
4217
+ }
4218
+ onClose() {
4219
+ if (this.calendar) {
4220
+ this.calendar.$destroy();
4221
+ }
4222
+ return Promise.resolve();
4223
+ }
4224
+ async onOpen() {
4225
+ // Integration point: external plugins can listen for `calendar:open`
4226
+ // to feed in additional sources.
4227
+ const sources = [
4228
+ customTagsSource,
4229
+ streakSource,
4230
+ wordCountSource,
4231
+ tasksSource,
4232
+ ];
4233
+ this.app.workspace.trigger(TRIGGER_ON_OPEN, sources);
4234
+ this.calendar = new Calendar({
4235
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4236
+ target: this.contentEl,
4237
+ props: {
4238
+ onClickDay: this.openOrCreateDailyNote,
4239
+ onClickWeek: this.openOrCreateWeeklyNote,
4240
+ onHoverDay: this.onHoverDay,
4241
+ onHoverWeek: this.onHoverWeek,
4242
+ onContextMenuDay: this.onContextMenuDay,
4243
+ onContextMenuWeek: this.onContextMenuWeek,
4244
+ sources,
4245
+ },
4246
+ });
4247
+ }
4248
+ onHoverDay(date, targetEl, isMetaPressed) {
4249
+ if (!isMetaPressed) {
4250
+ return;
4251
+ }
4252
+ const { format } = getDailyNoteSettings_1();
4253
+ const note = getDailyNote_1(date, get_store_value(dailyNotes));
4254
+ this.app.workspace.trigger("link-hover", this, targetEl, date.format(format), note === null || note === void 0 ? void 0 : note.path);
4255
+ }
4256
+ onHoverWeek(date, targetEl, isMetaPressed) {
4257
+ if (!isMetaPressed) {
4258
+ return;
4259
+ }
4260
+ const note = getWeeklyNote_1(date, get_store_value(weeklyNotes));
4261
+ const { format } = getWeeklyNoteSettings_1();
4262
+ this.app.workspace.trigger("link-hover", this, targetEl, date.format(format), note === null || note === void 0 ? void 0 : note.path);
4263
+ }
4264
+ onContextMenuDay(date, event) {
4265
+ const note = getDailyNote_1(date, get_store_value(dailyNotes));
4266
+ if (!note) {
4267
+ // If no file exists for a given day, show nothing.
4268
+ return;
4269
+ }
4270
+ showFileMenu(this.app, note, {
4271
+ x: event.pageX,
4272
+ y: event.pageY,
4273
+ });
4274
+ }
4275
+ onContextMenuWeek(date, event) {
4276
+ const note = getWeeklyNote_1(date, get_store_value(weeklyNotes));
4277
+ if (!note) {
4278
+ // If no file exists for a given day, show nothing.
4279
+ return;
4280
+ }
4281
+ showFileMenu(this.app, note, {
4282
+ x: event.pageX,
4283
+ y: event.pageY,
4284
+ });
4285
+ }
4286
+ onNoteSettingsUpdate() {
4287
+ dailyNotes.reindex();
4288
+ weeklyNotes.reindex();
4289
+ this.updateActiveFile();
4290
+ }
4291
+ async onFileDeleted(file) {
4292
+ if (getDateFromFile_1(file, "day")) {
4293
+ dailyNotes.reindex();
4294
+ this.updateActiveFile();
4295
+ }
4296
+ if (getDateFromFile_1(file, "week")) {
4297
+ weeklyNotes.reindex();
4298
+ this.updateActiveFile();
4299
+ }
4300
+ }
4301
+ async onFileModified(file) {
4302
+ const date = getDateFromFile_1(file, "day") || getDateFromFile_1(file, "week");
4303
+ if (date && this.calendar) {
4304
+ this.calendar.tick();
4305
+ }
4306
+ }
4307
+ onFileCreated(file) {
4308
+ if (this.app.workspace.layoutReady && this.calendar) {
4309
+ if (getDateFromFile_1(file, "day")) {
4310
+ dailyNotes.reindex();
4311
+ this.calendar.tick();
4312
+ }
4313
+ if (getDateFromFile_1(file, "week")) {
4314
+ weeklyNotes.reindex();
4315
+ this.calendar.tick();
4316
+ }
4317
+ }
4318
+ }
4319
+ onFileOpen(_file) {
4320
+ if (this.app.workspace.layoutReady) {
4321
+ this.updateActiveFile();
4322
+ }
4323
+ }
4324
+ updateActiveFile() {
4325
+ const { view } = this.app.workspace.activeLeaf;
4326
+ let file = null;
4327
+ if (view instanceof obsidian.FileView) {
4328
+ file = view.file;
4329
+ }
4330
+ activeFile.setFile(file);
4331
+ if (this.calendar) {
4332
+ this.calendar.tick();
4333
+ }
4334
+ }
4335
+ revealActiveNote() {
4336
+ const { moment } = window;
4337
+ const { activeLeaf } = this.app.workspace;
4338
+ if (activeLeaf.view instanceof obsidian.FileView) {
4339
+ // Check to see if the active note is a daily-note
4340
+ let date = getDateFromFile_1(activeLeaf.view.file, "day");
4341
+ if (date) {
4342
+ this.calendar.$set({ displayedMonth: date });
4343
+ return;
4344
+ }
4345
+ // Check to see if the active note is a weekly-note
4346
+ const { format } = getWeeklyNoteSettings_1();
4347
+ date = moment(activeLeaf.view.file.basename, format, true);
4348
+ if (date.isValid()) {
4349
+ this.calendar.$set({ displayedMonth: date });
4350
+ return;
4351
+ }
4352
+ }
4353
+ }
4354
+ async openOrCreateWeeklyNote(date, inNewSplit) {
4355
+ const { workspace } = this.app;
4356
+ const startOfWeek = date.clone().startOf("week");
4357
+ const existingFile = getWeeklyNote_1(date, get_store_value(weeklyNotes));
4358
+ if (!existingFile) {
4359
+ // File doesn't exist
4360
+ tryToCreateWeeklyNote(startOfWeek, inNewSplit, this.settings, (file) => {
4361
+ activeFile.setFile(file);
4362
+ });
4363
+ return;
4364
+ }
4365
+ const leaf = inNewSplit
4366
+ ? workspace.splitActiveLeaf()
4367
+ : workspace.getUnpinnedLeaf();
4368
+ await leaf.openFile(existingFile);
4369
+ activeFile.setFile(existingFile);
4370
+ }
4371
+ async openOrCreateDailyNote(date, inNewSplit) {
4372
+ const { workspace } = this.app;
4373
+ const existingFile = getDailyNote_1(date, get_store_value(dailyNotes));
4374
+ if (!existingFile) {
4375
+ // File doesn't exist
4376
+ tryToCreateDailyNote(date, inNewSplit, this.settings, (dailyNote) => {
4377
+ activeFile.setFile(dailyNote);
4378
+ });
4379
+ return;
4380
+ }
4381
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4382
+ const mode = this.app.vault.getConfig("defaultViewMode");
4383
+ const leaf = inNewSplit
4384
+ ? workspace.splitActiveLeaf()
4385
+ : workspace.getUnpinnedLeaf();
4386
+ await leaf.openFile(existingFile, { mode });
4387
+ activeFile.setFile(existingFile);
4388
+ }
4389
+ }
4390
+
4391
+ class CalendarPlugin extends obsidian.Plugin {
4392
+ onunload() {
4393
+ this.app.workspace
4394
+ .getLeavesOfType(VIEW_TYPE_CALENDAR)
4395
+ .forEach((leaf) => leaf.detach());
4396
+ }
4397
+ async onload() {
4398
+ this.register(settings.subscribe((value) => {
4399
+ this.options = value;
4400
+ }));
4401
+ this.registerView(VIEW_TYPE_CALENDAR, (leaf) => (this.view = new CalendarView(leaf)));
4402
+ this.addCommand({
4403
+ id: "show-calendar-view",
4404
+ name: "Open view",
4405
+ checkCallback: (checking) => {
4406
+ if (checking) {
4407
+ return (this.app.workspace.getLeavesOfType(VIEW_TYPE_CALENDAR).length === 0);
4408
+ }
4409
+ this.initLeaf();
4410
+ },
4411
+ });
4412
+ this.addCommand({
4413
+ id: "open-weekly-note",
4414
+ name: "Open Weekly Note",
4415
+ checkCallback: (checking) => {
4416
+ if (checking) {
4417
+ return !appHasPeriodicNotesPluginLoaded();
4418
+ }
4419
+ this.view.openOrCreateWeeklyNote(window.moment(), false);
4420
+ },
4421
+ });
4422
+ this.addCommand({
4423
+ id: "reveal-active-note",
4424
+ name: "Reveal active note",
4425
+ callback: () => this.view.revealActiveNote(),
4426
+ });
4427
+ await this.loadOptions();
4428
+ this.addSettingTab(new CalendarSettingsTab(this.app, this));
4429
+ if (this.app.workspace.layoutReady) {
4430
+ this.initLeaf();
4431
+ }
4432
+ else {
4433
+ this.registerEvent(this.app.workspace.on("layout-ready", this.initLeaf.bind(this)));
4434
+ }
4435
+ }
4436
+ initLeaf() {
4437
+ if (this.app.workspace.getLeavesOfType(VIEW_TYPE_CALENDAR).length) {
4438
+ return;
4439
+ }
4440
+ this.app.workspace.getRightLeaf(false).setViewState({
4441
+ type: VIEW_TYPE_CALENDAR,
4442
+ });
4443
+ }
4444
+ async loadOptions() {
4445
+ const options = await this.loadData();
4446
+ settings.update((old) => {
4447
+ return Object.assign(Object.assign({}, old), (options || {}));
4448
+ });
4449
+ await this.saveData(this.options);
4450
+ }
4451
+ async writeOptions(changeOpts) {
4452
+ settings.update((old) => (Object.assign(Object.assign({}, old), changeOpts(old))));
4453
+ await this.saveData(this.options);
4454
+ }
4455
+ }
4456
+
4457
+ module.exports = CalendarPlugin;
4458
+
4459
+ /* nosourcemap */