From 069456799e3bd1f2fcce552b6ab52832be51f3d9 Mon Sep 17 00:00:00 2001 From: Olivier Date: Mon, 7 Sep 2026 21:43:21 -0400 Subject: [PATCH] feat: add coloured calendar system indicators Add a selectable single-dot or per-system indicator mode. Date systems now carry configurable colours; results are cached per displayed month and invalidated when paths/settings change. Refine calendar hierarchy, spacing, hover, and today states. --- DOCUMENTATION.md | 64 ++++++++++++++---------- QA.md | 11 ++++ README.md | 13 ++++- main.js | 36 ++++++------- src/main.ts | 100 +++++++++++++++++++++++++++++++++++-- src/settings-tab.ts | 38 ++++++++++++++ src/settings.ts | 11 ++++ src/views/waypoint-view.ts | 24 ++++++++- styles.css | 80 +++++++++++++++++++++-------- 9 files changed, 305 insertions(+), 72 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 5f26efb..00f452d 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -51,14 +51,14 @@ Detaches all leaves of `WAYPOINT_VIEW_TYPE`. ```typescript interface WaypointSettings { - calendar: CalendarSettings; // firstDayOfWeek (0=Sun,1=Mon), showNoteIndicators + calendar: CalendarSettings; // week start, indicator visibility/style, daily indicator colour daily: PeriodNoteSettings; weekly: PeriodNoteSettings; monthly: PeriodNoteSettings; quarterly: PeriodNoteSettings; yearly: PeriodNoteSettings; dateSystems: DateSystemSettings[]; // day-scoped systems beyond the daily note, in menu order - recentFiles: RecentFilesSettings; // maxItems, updateOn, omittedPaths[], omittedTags[], filterTags[] + recentFiles: RecentFilesSettings; // maxItems, updateOn, omittedPaths[], omittedTags[], filterTags[] display: DisplaySettings; // px sizing for bookmark rows, fonts, icons, calendar cells } @@ -70,8 +70,10 @@ interface PeriodNoteSettings { } interface CalendarSettings { - firstDayOfWeek: number; // 0 = Sunday, 1 = Monday - showNoteIndicators: boolean; // dot on days with existing .md files + firstDayOfWeek: number; // 0 = Sunday, 1 = Monday + showNoteIndicators: boolean; // show or hide all calendar markers + indicatorMode: 'any' | 'systems'; // one neutral dot, or one coloured dot per date system + dailyIndicatorColor: string; // daily's colour in systems mode } interface RecentFilesSettings { @@ -157,24 +159,24 @@ A **date system** is a folder of notes whose filenames begin with a date. Daily ### `DateSystemSettings` -```typescript interface DateSystemSettings { - id: string; // stable across edits + reordering, so settings rows can key on it - name: string; // menu label, e.g. "Journal" - folder: string; // e.g. "periodic/journal" - nameFormat: string; // moment format string; may contain "{title}" - templateFile: string; // may omit the .md extension - typeProperty: string; // fallback frontmatter `type:` value - icon: string; // Lucide icon name for the menu item + id: string; // stable across edits + reordering, so settings rows can key on it + name: string; // menu label, e.g. "Journal" + folder: string; // e.g. "periodic/journal" + nameFormat: string; // moment format string; may contain "{title}" + templateFile: string; // may omit the .md extension + typeProperty: string; // fallback frontmatter `type:` value + icon: string; // Lucide icon name for the menu item + indicatorColor: string; // calendar dot colour in systems mode } ``` Configured systems live in `settings.dateSystems`, where array order is menu order. `DEFAULT_DATE_SYSTEM` (in `settings.ts`, typed `Omit`) supplies the field defaults for a newly added row **and** the merge base for saved ones, so a system persisted before a field existed still loads with that field defined. `DEFAULT_SETTINGS.dateSystems` ships two: -| `id` | `name` | Folder | `nameFormat` | Notes per date | -|---|---|---|---|---| -| `journal` | Journal | `periodic/journal` | `YYYY-MM-DD - [Journal]` | one | -| `meetings` | Meeting | `periodic/meetings` | `YYYY-MM-DD - {title}` | many | +| `id` | `name` | Folder | `nameFormat` | Indicator colour | Notes per date | +|---|---|---|---|---|---| +| `journal` | Journal | `periodic/journal` | `YYYY-MM-DD - [Journal]` | green (`#22c55e`) | one | +| `meetings` | Meeting | `periodic/meetings` | `YYYY-MM-DD - {title}` | violet (`#a855f7`) | many | ### Templater folder triggers @@ -210,21 +212,26 @@ Imports nothing from `'obsidian'` — callers make every moment call and pass th ### Plugin API (`main.ts`) ```typescript -/** One existing note of a date system, with the label the menu should show. */ interface DateSystemNote { file: TFile; - label: string; // free-text title for many-per-date systems, else the system name + label: string; // free-text title for many-per-date systems, else the system name } -/** A day-scoped system and the notes it already holds for one date. */ interface DateSystemNotes { system: DateSystemSettings; - notes: DateSystemNote[]; // sorted by basename; empty when the date has no note - multiple: boolean; // nameFormat carries {title}, i.e. many notes per date + notes: DateSystemNote[]; + multiple: boolean; // nameFormat carries {title} +} + +interface DateSystemIndicator { + id: string; + name: string; + color: string; } dateSystems(): DateSystemSettings[] findDateSystemNotes(date: moment.Moment): DateSystemNotes[] +getDateSystemIndicators(dates: moment.Moment[]): Map openDateSystemNote( system: DateSystemSettings, date: moment.Moment, @@ -232,6 +239,8 @@ openDateSystemNote( ): Promise ``` +**`getDateSystemIndicators(dates)`** — returns one `{ id, name, color }` marker per configured system with one or more notes on a requested day. The calendar calls it once for the visible month only in `indicatorMode: 'systems'`. It makes one vault pass, caches the result by displayed dates and date-system settings, and invalidates it on markdown create/delete/rename or any Settings change. It does not run on ordinary markdown edits: content edits cannot change a filename-derived indicator. + **`dateSystems()`** — every day-scoped system in menu order: the daily periodic note, synthesized into a `DateSystemSettings` from `settings.daily`, followed by `settings.dateSystems`. The daily note is therefore not a special case in any consumer. **`findDateSystemNotes(date)`** — **one** vault scan per call, not one per system. It formats each usable system's `before`/`after` affixes for `date` once, then walks the markdown file list a single time, bucketing each file into the system that claims it (`isInFolder` + `matchesSystemName`). Systems whose formats have no date token are omitted rather than offering an unsafe create action. It returns the remaining `DateSystemNotes` in `dateSystems()` order, each bucket sorted by basename. The calendar's day context menu is built from exactly one of these calls per right-click. @@ -348,7 +357,7 @@ The last section (`waypoint-section:last-child`) gets `margin-top: auto`, pushin - **Breadcrumb:** Q-label, month name, year — each clickable to open that period note. - **Nav buttons:** ◀/▶ shift month ±1. "Today" resets to current month. - **Week number column:** Clicking a week number opens the weekly note for that week's Monday; middle-clicking opens it in a new tab. -- **Day cells:** Left-click opens the daily note, middle-click opens it in a new tab, right-click opens the day context menu (below). `.other-month` dimmed. `.today` has accent border. `.has-note` gets a dot indicator, decided by the synchronous O(1) `plugin.hasNoteForDate(dateStr)` (a `Set` lookup — no per-cell vault scan). +- **Day cells:** Left-click opens the daily note, middle-click opens it in a new tab, right-click opens the day context menu (below). `.other-month` is muted; `.today` has an inset accent ring; hover receives a quiet fill. With `indicatorMode: 'any'`, `.has-note` shows the existing single neutral dot through the O(1) `plugin.hasNoteForDate(dateStr)` lookup. With `indicatorMode: 'systems'`, the view calls `getDateSystemIndicators()` once for the month and renders one tooltip-labelled coloured dot per matching daily/journal/meeting/custom system. - **Grid generation:** `getMonthGrid(year, month, firstDayOfWeek)` in `date-utils.ts` produces up to 6 weeks, each with 7 `CalendarDay` objects containing `moment`, `dayOfMonth`, `isToday`, `isCurrentMonth`, `isoWeekNumber`. **Day context menu (right-click):** Built from a single `plugin.findDateSystemNotes(day.date)` call. The first entry is a non-clickable header showing the full date. Then, per system in `dateSystems()` order: @@ -423,17 +432,18 @@ All classes prefixed with `waypoint-`. Uses Obsidian CSS variables throughout: - `--font-ui-small`, `--font-ui-medium`, `--font-semibold`, `--font-medium`, `--font-light` - `--text-muted`, `--text-faint`, `--text-accent`, `--text-on-accent`, `--text-error` -- `--background-modifier-border`, `--background-modifier-active-hover`, `--background-primary`, `--background-secondary` +- `--background-modifier-border`, `--background-modifier-active-hover`, `--background-modifier-hover`, `--background-primary`, `--background-primary-alt`, `--background-secondary` - `--interactive-accent` - `--cursor-link` (pointer cursor, with a `pointer` fallback) Key layout: - `.waypoint-view` — flex column, `overflow-y: auto`, 8px padding. - `.waypoint-section` — `flex-shrink: 0`, 16px bottom margin. Last section gets `margin-top: auto` (pins calendar to bottom). -- `.waypoint-section-header` — uppercase, muted, with bottom border. -- Calendar table — `table-layout: fixed`, `border-collapse: collapse`. -- `.waypoint-day.today` — accent color text + 1px accent border. -- `.waypoint-day.has-note::after` — 4px dot indicator. +- `.waypoint-calendar` — padded, bordered surface with separated day cells for clear scan lines. +- Calendar table — `table-layout: fixed`, `border-collapse: separate`, 2px horizontal / 3px vertical cell spacing. +- `.waypoint-day.today` — accent text with an inset accent ring, avoiding layout shifts. +- `.waypoint-day.has-note::after` — neutral single-dot indicator. +- `.waypoint-day-indicators` / `.waypoint-day-indicator` — compact ordered dot row; `--waypoint-indicator-color` carries each configured system colour. - `.waypoint-bm-chevron` — `rotate(-90deg)` on collapsed groups. - `.waypoint-bm-drop-line` / `.waypoint-bm-drop-below` — 3px accent border for drag indicators. diff --git a/QA.md b/QA.md index 0737991..d0efe7e 100644 --- a/QA.md +++ b/QA.md @@ -70,6 +70,17 @@ - [ ] Note indicator dots show on days with existing .md files - [ ] Today is highlighted with accent border +## Calendar: System-coloured indicators + +- [ ] Calendar → Indicator style → **Single dot** keeps one neutral dot for an existing date-named note +- [ ] Calendar → Indicator style → **Colour by note system** shows a blue dot for Daily, green for Journal, and violet for Meeting by default +- [ ] A day holding multiple meeting notes still shows exactly one Meeting dot +- [ ] A day holding Daily, Journal, and Meeting notes shows three compact dots in that order +- [ ] Hover each coloured dot → its date-system name is identified by a tooltip +- [ ] Change Daily/Journal/Meeting indicator colours in Settings → the visible calendar refreshes immediately +- [ ] Add a custom date system with its own colour and a matching note → its dot appears in system order +- [ ] Create, delete, or rename a date-system note → coloured dots refresh without changing months + ## Calendar: Date systems diff --git a/README.md b/README.md index aed369d..c213c7f 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Calendar, recent files, and custom bookmarks sidebar for Obsidian. ## Features -- **Calendar panel** — month grid; left-click a day opens its daily note, middle-click opens it in a tab, and right-click reveals every configured note system for that date -- **Date systems** — browse or create daily, journal, meeting, and other date-prefixed notes from a single day menu +- **Calendar panel** — refined month grid; left-click a day opens its daily note, middle-click opens it in a tab, and right-click reveals every configured note system for that date +- **Calendar indicators** — retain a single neutral note dot or show a coloured dot per daily, journal, meeting, or custom date system - **Recent files** — track recently opened/edited files - **Favorites** — custom bookmarks with groups, icons, and rename @@ -35,6 +35,15 @@ Configure systems in **Settings → Waypoint Sidebar → Date systems**. Each sy Ctrl/Cmd-click a menu entry opens it in a new tab. +### Calendar indicators + +Under **Settings → Waypoint Sidebar → Calendar**, choose either: + +- **Single dot** — the existing neutral marker for any note whose filename is exactly the date. +- **Colour by note system** — one compact coloured dot per configured date system that has a note on that day. Hover a dot to identify its system. + +Daily uses the Calendar tab’s colour picker. Journal, Meeting, and every custom system have their own **Indicator colour** picker under **Date systems**. The defaults are blue for Daily, green for Journal, and violet for Meeting. + ### Templater folder templates If a date system uses a Templater folder mapping, leave its Waypoint **Template file** field blank. Waypoint then creates a safe fallback note while Templater owns prompts, scripts, cursors, and rendered content. diff --git a/main.js b/main.js index 9cb9dbc..49f89fd 100644 --- a/main.js +++ b/main.js @@ -2,26 +2,26 @@ THIS IS A GENERATED/BUNDLED FILE BY ESBUILD */ -var _=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ce=Object.prototype.hasOwnProperty;var de=(p,d)=>{for(var e in d)_(p,e,{get:d[e],enumerable:!0})},pe=(p,d,e,a)=>{if(d&&typeof d=="object"||typeof d=="function")for(let i of le(d))!ce.call(p,i)&&i!==e&&_(p,i,{get:()=>d[i],enumerable:!(a=re(d,i))||a.enumerable});return p};var me=p=>pe(_({},"__esModule",{value:!0}),p);var ve={};de(ve,{default:()=>q});module.exports=me(ve);var f=require("obsidian");var R={name:"",folder:"",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"",icon:"file"},E={calendar:{firstDayOfWeek:1,showNoteIndicators:!0},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},dateSystems:[{id:"journal",name:"Journal",folder:"periodic/journal",nameFormat:"YYYY-MM-DD - [Journal]",templateFile:"",typeProperty:"journal",icon:"book-open"},{id:"meetings",name:"Meeting",folder:"periodic/meetings",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"meeting",icon:"users"}],recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[],filterTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var k=require("obsidian");var X="{title}";function W(p){let d=p.indexOf(X);return d<0?{before:p,after:"",hasTitle:!1}:{before:p.slice(0,d),after:p.slice(d+X.length),hasTitle:!0}}function J(p,d){if(!d)return!0;let e=d.endsWith("/")?d:`${d}/`;return p.startsWith(e)}function ee(p,d,e,a){return a?!d||p.length|#^[\]]/g;function ne(p){return p.replace(he,"-").replace(/\s+/g," ").trim()}function N(p){let{before:d}=W(p),e=d.replace(/\[[^\]]*\]/g,"");return/[YMDQGWEwdgeo]/.test(e)}var O=class extends k.PluginSettingTab{constructor(e,a,i,t){super(e,a);this.activeTab="calendar";this.plugin=a,this.settings=i,this.onSettingsChange=t}display(){let{containerEl:e}=this;e.empty();let a=e.createDiv({cls:"waypoint-settings-tabs"}),i=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"systems",label:"Date systems"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let n of i)a.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===n.key?" is-active":""}`,text:n.label}).addEventListener("click",()=>{this.activeTab=n.key,this.display()});let t=e.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(t);break;case"periodic":this.renderPeriodicTab(t);break;case"systems":this.renderSystemsTab(t);break;case"recent":this.renderRecentTab(t);break;case"display":this.renderDisplayTab(t);break;case"about":this.renderAboutTab(t);break}}renderCalendarTab(e){new k.Setting(e).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(a=>{a.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(i=>{this.settings.calendar.firstDayOfWeek=parseInt(i,10),this.saveAndRefresh()})}),new k.Setting(e).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(a=>{a.setValue(this.settings.calendar.showNoteIndicators).onChange(i=>{this.settings.calendar.showNoteIndicators=i,this.saveAndRefresh()})})}renderPeriodicTab(e){this.addPeriodNoteSettings(e,"Daily",this.settings.daily),this.addPeriodNoteSettings(e,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(e,"Monthly",this.settings.monthly),this.addPeriodNoteSettings(e,"Quarterly",this.settings.quarterly),this.addPeriodNoteSettings(e,"Yearly",this.settings.yearly)}addPeriodNoteSettings(e,a,i){new k.Setting(e).setHeading().setName(a),new k.Setting(e).setName("Folder").setDesc(`Folder path for ${a.toLowerCase()} notes.`).addText(t=>{t.setPlaceholder("periodic/daily"),t.setValue(i.folder),t.onChange(n=>{i.folder=n,this.saveAndRefresh()})}),new k.Setting(e).setName("Name format").setDesc(`Date format for ${a.toLowerCase()} note filenames (moment.js format).`).addText(t=>{t.setPlaceholder("yyyy-MM-dd"),t.setValue(i.nameFormat),t.onChange(n=>{i.nameFormat=n,this.saveAndRefresh()})}),new k.Setting(e).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(t=>{t.setPlaceholder("Templates/Daily note"),t.setValue(i.templateFile),t.onChange(n=>{i.templateFile=n,this.saveAndRefresh()})}),new k.Setting(e).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(t=>{t.setPlaceholder("daily-note"),t.setValue(i.typeProperty),t.onChange(n=>{i.typeProperty=n,this.saveAndRefresh()})})}renderSystemsTab(e){let a=new DocumentFragment;a.createDiv({text:"A date system is a folder of notes whose filenames start with a date. Each one appears in the calendar's right-click menu for that day."}),a.createDiv({text:"The daily note is configured under Periodic Notes and always comes first in that menu."}),a.createDiv({text:"Name format is a moment.js format. Literal words need bracket escaping, e.g. YYYY-MM-DD - [Journal]."}),a.createDiv({text:"Include {title} for systems that hold many notes per date, such as meetings: the text before the token finds the existing notes, and the token marks where a typed title goes. Without it, a date has exactly one note."}),new k.Setting(e).setHeading().setName("Date systems").setDesc(a),this.settings.dateSystems.forEach((i,t,n)=>{new k.Setting(e).setHeading().setName(i.name||"Untitled system").addExtraButton(o=>{o.setIcon("arrow-up").setTooltip("Move up").setDisabled(t===0).onClick(async()=>{if(t===0)return;let r=n[t-1];n[t-1]=n[t],n[t]=r,await this.saveAndRefresh(),this.display()})}).addExtraButton(o=>{o.setIcon("arrow-down").setTooltip("Move down").setDisabled(t===n.length-1).onClick(async()=>{if(t===n.length-1)return;let r=n[t+1];n[t+1]=n[t],n[t]=r,await this.saveAndRefresh(),this.display()})}).addExtraButton(o=>{o.setIcon("trash").setTooltip("Delete this date system").onClick(async()=>{n.splice(t,1),await this.saveAndRefresh(),this.display()})}),this.addSystemTextSetting(e,"Name","Label shown in the calendar right-click menu.",i,"name","Journal"),this.addSystemTextSetting(e,"Folder","Folder these notes live in.",i,"folder","periodic/journal");let s=this.addSystemTextSetting(e,"Name format","Filename format (moment.js format). Include {title} for many notes per date.",i,"nameFormat","YYYY-MM-DD - {title}");i.nameFormat&&!N(i.nameFormat)&&s.descEl.createDiv({cls:"waypoint-settings-warning",text:"This name format has no date placeholder, so it will never match or create dated notes."}),this.addSystemTextSetting(e,"Template file","Path to the template file. The .md extension is optional.",i,"templateFile","resources/template/journal"),this.addSystemTextSetting(e,"Type property","Fallback value for the 'type' frontmatter property, used when no template is found.",i,"typeProperty","journal-note"),this.addSystemTextSetting(e,"Icon","Lucide icon name for the menu item. Browse names at lucide.dev.",i,"icon","book-open")}),new k.Setting(e).addButton(i=>i.setButtonText("Add date system").setCta().onClick(async()=>{this.settings.dateSystems.push(Object.assign({id:`ds-${Date.now()}-${Math.random().toString(36).slice(2,6)}`},R)),await this.saveAndRefresh(),this.display()}))}addSystemTextSetting(e,a,i,t,n,s){return new k.Setting(e).setName(a).setDesc(i).addText(o=>{o.setPlaceholder(s),o.setValue(t[n]),o.onChange(r=>{t[n]=r,this.saveAndRefresh()})})}renderRecentTab(e){new k.Setting(e).setName("Max items").setDesc("Maximum number of recent files to track.").addText(n=>{n.inputEl.setAttr("type","number"),n.inputEl.setAttr("placeholder","50"),n.setValue(String(this.settings.recentFiles.maxItems)),n.inputEl.onblur=()=>{let s=parseInt(n.getValue(),10);!isNaN(s)&&s>0&&(this.settings.recentFiles.maxItems=s,this.saveAndRefresh())}}),new k.Setting(e).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(n=>{n.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(s=>{this.settings.recentFiles.updateOn=s,this.saveAndRefresh()})});let a=new DocumentFragment;a.appendText("Regex patterns for paths to exclude. One per line."),new k.Setting(e).setName("Omitted paths").setDesc(a).addTextArea(n=>{n.inputEl.setAttr("rows",4),n.setPlaceholder(`^archives/ -\\.png$`),n.setValue(this.settings.recentFiles.omittedPaths.join(` -`)),n.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=n.getValue().split(` -`).filter(s=>s.trim()),this.saveAndRefresh()}});let i=new DocumentFragment;i.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new k.Setting(e).setName("Omitted tags").setDesc(i).addTextArea(n=>{n.inputEl.setAttr("rows",4),n.setPlaceholder(`ignore -archive`),n.setValue(this.settings.recentFiles.omittedTags.join(` -`)),n.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=n.getValue().split(` -`).filter(s=>s.trim()),this.saveAndRefresh()}});let t=new DocumentFragment;t.appendText("Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property."),new k.Setting(e).setName("Filter tags").setDesc(t).addTextArea(n=>{n.inputEl.setAttr("rows",4),n.setPlaceholder(`meeting +var _=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ge=(p,d)=>{for(var e in d)_(p,e,{get:d[e],enumerable:!0})},fe=(p,d,e,a)=>{if(d&&typeof d=="object"||typeof d=="function")for(let n of he(d))!ue.call(p,n)&&n!==e&&_(p,n,{get:()=>d[n],enumerable:!(a=me(d,n))||a.enumerable});return p};var ye=p=>fe(_({},"__esModule",{value:!0}),p);var Se={};ge(Se,{default:()=>q});module.exports=ye(Se);var f=require("obsidian");var $={name:"",folder:"",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"",icon:"file",indicatorColor:"#64748b"},T={calendar:{firstDayOfWeek:1,showNoteIndicators:!0,indicatorMode:"any",dailyIndicatorColor:"#3b82f6"},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},dateSystems:[{id:"journal",name:"Journal",folder:"periodic/journal",nameFormat:"YYYY-MM-DD - [Journal]",templateFile:"",typeProperty:"journal",icon:"book-open",indicatorColor:"#22c55e"},{id:"meetings",name:"Meeting",folder:"periodic/meetings",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"meeting",icon:"users",indicatorColor:"#a855f7"}],recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[],filterTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var v=require("obsidian");var se="{title}";function R(p){let d=p.indexOf(se);return d<0?{before:p,after:"",hasTitle:!1}:{before:p.slice(0,d),after:p.slice(d+se.length),hasTitle:!0}}function Q(p,d){if(!d)return!0;let e=d.endsWith("/")?d:`${d}/`;return p.startsWith(e)}function U(p,d,e,a){return a?!d||p.length|#^[\]]/g;function re(p){return p.replace(ve,"-").replace(/\s+/g," ").trim()}function A(p){let{before:d}=R(p),e=d.replace(/\[[^\]]*\]/g,"");return/[YMDQGWEwdgeo]/.test(e)}var z=class extends v.PluginSettingTab{constructor(e,a,n,t){super(e,a);this.activeTab="calendar";this.plugin=a,this.settings=n,this.onSettingsChange=t}display(){let{containerEl:e}=this;e.empty();let a=e.createDiv({cls:"waypoint-settings-tabs"}),n=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"systems",label:"Date systems"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let i of n)a.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===i.key?" is-active":""}`,text:i.label}).addEventListener("click",()=>{this.activeTab=i.key,this.display()});let t=e.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(t);break;case"periodic":this.renderPeriodicTab(t);break;case"systems":this.renderSystemsTab(t);break;case"recent":this.renderRecentTab(t);break;case"display":this.renderDisplayTab(t);break;case"about":this.renderAboutTab(t);break}}renderCalendarTab(e){new v.Setting(e).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(a=>{a.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(n=>{this.settings.calendar.firstDayOfWeek=parseInt(n,10),this.saveAndRefresh()})}),new v.Setting(e).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(a=>{a.setValue(this.settings.calendar.showNoteIndicators).onChange(n=>{this.settings.calendar.showNoteIndicators=n,this.saveAndRefresh()})}),new v.Setting(e).setName("Indicator style").setDesc("Show one neutral dot for any dated note, or one coloured dot for each configured date system.").addDropdown(a=>{a.addOption("any","Single dot").addOption("systems","Colour by note system").setValue(this.settings.calendar.indicatorMode).onChange(n=>{this.settings.calendar.indicatorMode=n,this.saveAndRefresh()})}),new v.Setting(e).setName("Daily indicator colour").setDesc("Colour for daily-note dots when using \u201CColour by note system\u201D.").addColorPicker(a=>{a.setValue(this.settings.calendar.dailyIndicatorColor).onChange(n=>{this.settings.calendar.dailyIndicatorColor=n,this.saveAndRefresh()})})}renderPeriodicTab(e){this.addPeriodNoteSettings(e,"Daily",this.settings.daily),this.addPeriodNoteSettings(e,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(e,"Monthly",this.settings.monthly),this.addPeriodNoteSettings(e,"Quarterly",this.settings.quarterly),this.addPeriodNoteSettings(e,"Yearly",this.settings.yearly)}addPeriodNoteSettings(e,a,n){new v.Setting(e).setHeading().setName(a),new v.Setting(e).setName("Folder").setDesc(`Folder path for ${a.toLowerCase()} notes.`).addText(t=>{t.setPlaceholder("periodic/daily"),t.setValue(n.folder),t.onChange(i=>{n.folder=i,this.saveAndRefresh()})}),new v.Setting(e).setName("Name format").setDesc(`Date format for ${a.toLowerCase()} note filenames (moment.js format).`).addText(t=>{t.setPlaceholder("yyyy-MM-dd"),t.setValue(n.nameFormat),t.onChange(i=>{n.nameFormat=i,this.saveAndRefresh()})}),new v.Setting(e).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(t=>{t.setPlaceholder("Templates/Daily note"),t.setValue(n.templateFile),t.onChange(i=>{n.templateFile=i,this.saveAndRefresh()})}),new v.Setting(e).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(t=>{t.setPlaceholder("daily-note"),t.setValue(n.typeProperty),t.onChange(i=>{n.typeProperty=i,this.saveAndRefresh()})})}renderSystemsTab(e){let a=new DocumentFragment;a.createDiv({text:"A date system is a folder of notes whose filenames start with a date. Each one appears in the calendar's right-click menu for that day."}),a.createDiv({text:"The daily note is configured under Periodic Notes and always comes first in that menu."}),a.createDiv({text:"Name format is a moment.js format. Literal words need bracket escaping, e.g. YYYY-MM-DD - [Journal]."}),a.createDiv({text:"Include {title} for systems that hold many notes per date, such as meetings: the text before the token finds the existing notes, and the token marks where a typed title goes. Without it, a date has exactly one note."}),new v.Setting(e).setHeading().setName("Date systems").setDesc(a),this.settings.dateSystems.forEach((n,t,i)=>{new v.Setting(e).setHeading().setName(n.name||"Untitled system").addExtraButton(o=>{o.setIcon("arrow-up").setTooltip("Move up").setDisabled(t===0).onClick(async()=>{if(t===0)return;let r=i[t-1];i[t-1]=i[t],i[t]=r,await this.saveAndRefresh(),this.display()})}).addExtraButton(o=>{o.setIcon("arrow-down").setTooltip("Move down").setDisabled(t===i.length-1).onClick(async()=>{if(t===i.length-1)return;let r=i[t+1];i[t+1]=i[t],i[t]=r,await this.saveAndRefresh(),this.display()})}).addExtraButton(o=>{o.setIcon("trash").setTooltip("Delete this date system").onClick(async()=>{i.splice(t,1),await this.saveAndRefresh(),this.display()})}),this.addSystemTextSetting(e,"Name","Label shown in the calendar right-click menu.",n,"name","Journal"),this.addSystemTextSetting(e,"Folder","Folder these notes live in.",n,"folder","periodic/journal");let s=this.addSystemTextSetting(e,"Name format","Filename format (moment.js format). Include {title} for many notes per date.",n,"nameFormat","YYYY-MM-DD - {title}");n.nameFormat&&!A(n.nameFormat)&&s.descEl.createDiv({cls:"waypoint-settings-warning",text:"This name format has no date placeholder, so it will never match or create dated notes."}),this.addSystemTextSetting(e,"Template file","Path to the template file. The .md extension is optional.",n,"templateFile","resources/template/journal"),this.addSystemTextSetting(e,"Type property","Fallback value for the 'type' frontmatter property, used when no template is found.",n,"typeProperty","journal-note"),this.addSystemTextSetting(e,"Icon","Lucide icon name for the menu item. Browse names at lucide.dev.",n,"icon","book-open"),new v.Setting(e).setName("Indicator colour").setDesc("Colour for this system\u2019s dot when using \u201CColour by note system\u201D.").addColorPicker(o=>{o.setValue(n.indicatorColor).onChange(r=>{n.indicatorColor=r,this.saveAndRefresh()})})}),new v.Setting(e).addButton(n=>n.setButtonText("Add date system").setCta().onClick(async()=>{this.settings.dateSystems.push(Object.assign({id:`ds-${Date.now()}-${Math.random().toString(36).slice(2,6)}`},$)),await this.saveAndRefresh(),this.display()}))}addSystemTextSetting(e,a,n,t,i,s){return new v.Setting(e).setName(a).setDesc(n).addText(o=>{o.setPlaceholder(s),o.setValue(t[i]),o.onChange(r=>{t[i]=r,this.saveAndRefresh()})})}renderRecentTab(e){new v.Setting(e).setName("Max items").setDesc("Maximum number of recent files to track.").addText(i=>{i.inputEl.setAttr("type","number"),i.inputEl.setAttr("placeholder","50"),i.setValue(String(this.settings.recentFiles.maxItems)),i.inputEl.onblur=()=>{let s=parseInt(i.getValue(),10);!isNaN(s)&&s>0&&(this.settings.recentFiles.maxItems=s,this.saveAndRefresh())}}),new v.Setting(e).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(i=>{i.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(s=>{this.settings.recentFiles.updateOn=s,this.saveAndRefresh()})});let a=new DocumentFragment;a.appendText("Regex patterns for paths to exclude. One per line."),new v.Setting(e).setName("Omitted paths").setDesc(a).addTextArea(i=>{i.inputEl.setAttr("rows",4),i.setPlaceholder(`^archives/ +\\.png$`),i.setValue(this.settings.recentFiles.omittedPaths.join(` +`)),i.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=i.getValue().split(` +`).filter(s=>s.trim()),this.saveAndRefresh()}});let n=new DocumentFragment;n.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new v.Setting(e).setName("Omitted tags").setDesc(n).addTextArea(i=>{i.inputEl.setAttr("rows",4),i.setPlaceholder(`ignore +archive`),i.setValue(this.settings.recentFiles.omittedTags.join(` +`)),i.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=i.getValue().split(` +`).filter(s=>s.trim()),this.saveAndRefresh()}});let t=new DocumentFragment;t.appendText("Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property."),new v.Setting(e).setName("Filter tags").setDesc(t).addTextArea(i=>{i.inputEl.setAttr("rows",4),i.setPlaceholder(`meeting person -project`),n.setValue(this.settings.recentFiles.filterTags.join(` -`)),n.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=n.getValue().split(` -`).filter(s=>s.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new k.Setting(e).setHeading().setName("Bookmarks"),this.addSliderSetting(e,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(e,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(e,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(e,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(e,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new k.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new k.Setting(e).addButton(a=>a.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...E.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,a,i,t,n,s,o,r,c){let l=new k.Setting(e).setName(a).setDesc(`${i} (${t[n]}${c})`);l.addSlider(h=>{h.setLimits(s,o,r).setValue(t[n]).setDynamicTooltip().onChange(u=>{t[n]=u,l.setDesc(`${i} (${u}${c})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let a=this.plugin.manifest.version,i=e.createDiv();i.style.display="flex",i.style.alignItems="center",i.style.gap="12px",i.style.marginBottom="16px";let t=i.createDiv();t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.width="48px",t.style.height="48px",t.style.borderRadius="12px",t.style.background="var(--interactive-accent)",t.style.color="var(--text-on-accent)",t.style.fontSize="24px",(0,k.setIcon)(t,"compass");let n=i.createDiv(),s=n.createEl("h2",{text:"Waypoint Sidebar"});s.style.margin="0",s.style.lineHeight="1.2";let o=n.createDiv({text:`v${a}`});o.style.color="var(--text-muted)",o.style.fontSize="var(--font-ui-small)";let r=e.createDiv();r.style.marginBottom="20px",r.style.lineHeight="1.6",r.style.color="var(--text-normal)",r.innerHTML=["

Waypoint is a sidebar plugin that brings three essential panels into one view:

",'
    ',"
  • Calendar \u2014 a monthly grid for your periodic notes (daily, weekly, monthly, quarterly, yearly). Click any day, week, or month to open or create the corresponding note.
  • ","
  • Recent Files \u2014 a list of recently opened files with type filtering, drag-and-drop, and right-click actions.
  • ","
  • Bookmarks \u2014 custom bookmarks with icons, groups, nesting, and drag-and-drop reordering. Separate from Obsidian's native bookmarks.
  • ","
",'

Made by Olivier. Licensed under MIT.

'].join(` -`)}};var m=require("obsidian");var C=require("obsidian");function ie(p,d,e){let a=(0,C.moment)({year:p,month:d,day:1}),i=(0,C.moment)(a).endOf("month"),t=(0,C.moment)(a).subtract((a.day()-e+7)%7,"days"),n=(0,C.moment)().startOf("day"),s=[],o=(0,C.moment)(t);for(;o.isBefore(i)||o.month()===d;){let r=[];for(let c=0;c<7;c++)r.push({date:(0,C.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(n,"day"),isCurrentMonth:o.month()===d,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(s.push({weekNumber:r[0].isoWeekNumber,days:r}),s.length>=6)break}return s}var T="waypoint-view";function ue(p){return p.dragManager}var B=class extends m.ItemView{constructor(e,a){super(e);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let e=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",e.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",e.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",e.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",e.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",e.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",e.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,m.moment)().month();this.currentDisplayYear=(0,m.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.plugin=a}getViewType(){return T}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let e=this.contentEl.createDiv({cls:"waypoint-section"});e.createDiv({cls:"waypoint-section-header",text:"Calendar"});let a=e.createDiv({cls:"waypoint-calendar"}),i=(0,m.moment)(),t=(0,m.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),n=a.createDiv({cls:"waypoint-calendar-top"}),s=n.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=t.format("[Q]Q"),r=s.createSpan({cls:"waypoint-clickable",text:o});r.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",t)}),r.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("quarter",t,this.app.workspace.getLeaf("tab")))});let c=t.format("MMMM"),l=s.createSpan({cls:"waypoint-clickable",text:c});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",t)}),l.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("month",t,this.app.workspace.getLeaf("tab")))});let h=t.format("YYYY"),u=s.createSpan({cls:"waypoint-clickable",text:h});u.addEventListener("click",()=>{this.plugin.openPeriodNote("year",t)}),u.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("year",t,this.app.workspace.getLeaf("tab")))});let g=n.createDiv({cls:"waypoint-calendar-today-group"}),F=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(F,"chevron-left"),F.addEventListener("click",()=>this.navigateMonth(-1)),g.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,m.moment)().month(),this.currentDisplayYear=(0,m.moment)().year(),this.redraw()});let w=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(w,"chevron-right"),w.addEventListener("click",()=>this.navigateMonth(1));let b=a.createEl("table"),y=b.createEl("thead").createEl("tr");y.createEl("th",{text:""});let L=["sun","mon","tue","wed","thu","fri","sat"],V=this.plugin.settings.calendar.firstDayOfWeek;for(let D=0;D<7;D++){let Y=(V+D)%7;y.createEl("th",{text:L[Y]})}let M=b.createEl("tbody"),oe=ie(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let D of oe){let Y=M.createEl("tr"),G=Y.createEl("td",{cls:"waypoint-weeknum"});G.setText(String(D.weekNumber));let Z=D.days[0].date;G.addEventListener("click",()=>{this.plugin.openPeriodNote("week",Z)}),G.addEventListener("mousedown",S=>{S.button===1&&(S.preventDefault(),this.plugin.openPeriodNote("week",Z,this.app.workspace.getLeaf("tab")))});for(let S of D.days){let I=Y.createEl("td",{cls:"waypoint-day"});if(I.setText(String(S.dayOfMonth)),S.isCurrentMonth||I.addClass("other-month"),S.isToday&&I.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let P=S.date.format("YYYY-MM-DD");this.plugin.hasNoteForDate(P)&&I.addClass("has-note")}I.addEventListener("click",()=>{this.plugin.openPeriodNote("day",S.date)}),I.addEventListener("mousedown",P=>{P.button===1&&(P.preventDefault(),this.plugin.openPeriodNote("day",S.date,this.app.workspace.getLeaf("tab")))}),I.addEventListener("contextmenu",P=>{P.preventDefault(),P.stopPropagation(),this.showDayContextMenu(P,S.date)})}}}navigateMonth(e){let a=(0,m.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(e,"month");this.currentDisplayMonth=a.month(),this.currentDisplayYear=a.year(),this.redraw()}showDayContextMenu(e,a){let i=new m.Menu;i.addItem(t=>t.setTitle(a.format("dddd, MMMM D, YYYY")).setIsLabel(!0));for(let t of this.plugin.findDateSystemNotes(a)){let n=t.multiple||t.notes.length===0;if(t.notes.length+(n?1:0)===0)continue;i.addSeparator();for(let o of t.notes)i.addItem(r=>r.setTitle(o.label).setIcon(t.system.icon).onClick(c=>this.focusFile(o.file,m.Keymap.isModEvent(c))));if(!n)continue;let s=t.system.name.toLowerCase();i.addItem(o=>o.setTitle(t.multiple?`New ${s} note\u2026`:`New ${s} note`).setIcon("plus").onClick(r=>this.createDateSystemNote(t,a,m.Keymap.isModEvent(r))))}i.showAtPosition({x:e.clientX,y:e.clientY})}createDateSystemNote(e,a,i){if(!e.multiple){this.plugin.openDateSystemNote(e.system,a,{leaf:i?this.app.workspace.getLeaf(i):void 0});return}let t=e.system.name;new z(this.app,{title:`New ${t.toLowerCase()} note`,placeholder:`${t} with\u2026`,cta:"Create"},n=>{this.plugin.openDateSystemNote(e.system,a,{title:n,leaf:i?this.app.workspace.getLeaf(i):void 0})}).open()}renderRecentFiles(){var r,c;let e=this.contentEl.createDiv({cls:"waypoint-section waypoint-recent-files"});if(e.createDiv({cls:"waypoint-section-header",text:"Recent Files"}),this.plugin.recentFiles.length===0){e.createDiv({cls:"nav-file",text:"No recent files"});return}let a=this.plugin.settings.recentFiles.filterTags||[],i={};if(a.length>0){for(let l of a)i[l]=0;for(let l of this.plugin.recentFiles){let h=this.app.vault.getAbstractFileByPath(l.path);if(h instanceof m.TFile){let u=this.app.metadataCache.getFileCache(h),g=(r=u==null?void 0:u.frontmatter)==null?void 0:r.type;g&&typeof g=="string"&&i.hasOwnProperty(g)&&i[g]++}}}else for(let l of this.plugin.recentFiles){let h=this.app.vault.getAbstractFileByPath(l.path);if(h instanceof m.TFile){let u=this.app.metadataCache.getFileCache(h),g=(c=u==null?void 0:u.frontmatter)==null?void 0:c.type;g&&typeof g=="string"&&(i[g]=(i[g]||0)+1)}}if(Object.keys(i).length>0){let l=e.createDiv({cls:"waypoint-recent-filter"});l.createSpan({cls:`waypoint-recent-pill${this.recentFilesFilter?"":" is-active"}`,text:"all"}).addEventListener("click",()=>{this.recentFilesFilter=null,this.redraw()});let u=a.length>0?Object.entries(i):Object.entries(i).sort((g,F)=>F[1]-g[1]);for(let[g,F]of u){let x=l.createSpan({cls:`waypoint-recent-pill${this.recentFilesFilter===g?" is-active":""}`});x.setText(`${g} ${F}`),x.addEventListener("click",()=>{this.recentFilesFilter=this.recentFilesFilter===g?null:g,this.redraw()})}}let t=this.plugin.recentFiles;this.recentFilesFilter&&(t=this.plugin.recentFiles.filter(l=>{var u;let h=this.app.vault.getAbstractFileByPath(l.path);if(h instanceof m.TFile){let g=this.app.metadataCache.getFileCache(h);return((u=g==null?void 0:g.frontmatter)==null?void 0:u.type)===this.recentFilesFilter}return!1}));let n=this.app.workspace.getActiveFile(),s=e.createDiv({cls:"nav-folder mod-root"}),o=s.createDiv({cls:"nav-folder-children"});for(let l of t){let h=o.createDiv({cls:"tree-item nav-file"}),u=h.createDiv({cls:"tree-item-self is-clickable nav-file-title"});u.createDiv({cls:"tree-item-inner nav-file-title-content"}).setText(l.basename);let F=u.createDiv({cls:"tree-item-spacer"}),x=u.createDiv({cls:"waypoint-recent-remove"});(0,m.setIcon)(x,"x"),x.addEventListener("click",w=>{w.stopPropagation(),this.plugin.recentFiles=this.plugin.recentFiles.filter(b=>b.path!==l.path),this.plugin.persistRecentFiles(),this.redraw()}),(0,m.setTooltip)(h,l.path),n&&l.path===n.path&&u.addClass("is-active"),u.setAttr("draggable","true"),u.addEventListener("dragstart",w=>{let b=this.app.metadataCache.getFirstLinkpathDest(l.path,"");if(b){let v=ue(this.app),y=v.dragFile(w,b);v.onDragStart(w,y)}}),u.addEventListener("mouseover",w=>{this.app.workspace.trigger("hover-link",{event:w,source:T,hoverParent:s,targetEl:h,linktext:l.path})}),u.addEventListener("contextmenu",w=>{let b=new m.Menu;b.addItem(y=>y.setSection("action").setTitle("Open in new tab").setIcon("file-plus").onClick(()=>this.focusFile(l,"tab"))),b.addItem(y=>y.setSection("action").setTitle("Add to bookmarks").setIcon("bookmark").onClick(()=>{this.plugin.addBookmark(l.path,l.basename,"file"),new m.Notice(`Bookmarked: ${l.basename}`)}));let v=this.app.vault.getAbstractFileByPath(l.path);v&&this.app.workspace.trigger("file-menu",b,v,"link-context-menu"),b.showAtPosition({x:w.clientX,y:w.clientY})}),u.addEventListener("click",w=>{let b=m.Keymap.isModEvent(w);this.focusFile(l,b)}),u.addEventListener("mousedown",w=>{w.button===1&&(w.preventDefault(),this.focusFile(l,"tab"))})}}focusFile(e,a){let i=this.app.vault.getFiles().find(t=>t.path===e.path);i?this.app.workspace.getLeaf(a).openFile(i):(new m.Notice("Cannot find file"),this.plugin.recentFiles=this.plugin.recentFiles.filter(t=>t.path!==e.path),this.plugin.persistRecentFiles(),this.redraw())}renderFavorites(){let e=this.contentEl.createDiv({cls:"waypoint-section waypoint-favorites"}),a=e.createDiv({cls:"waypoint-section-header"});a.setText("Waypoint Bookmarks");let i=a.createEl("button",{cls:"waypoint-header-more"});if((0,m.setIcon)(i,"more-horizontal"),(0,m.setTooltip)(i,"Add bookmark"),i.addEventListener("click",t=>{let n=new m.Menu;n.addItem(s=>{s.setTitle("Add current file").setIcon("file-plus").onClick(()=>{let o=this.app.workspace.getActiveFile();o&&this.plugin.addBookmark(o.path,o.basename,"file")})}),n.addItem(s=>{s.setTitle("Add as parent note").setIcon("folder-plus").onClick(()=>{let o=this.app.workspace.getActiveFile();if(!o)return;let r=this.plugin.addBookmark(o.path,o.basename,"group","");r.filePath=o.path,this.plugin.saveWaypointData(),this.redraw()})}),n.addItem(s=>{s.setTitle("New group").setIcon("folder-plus").onClick(()=>{this.plugin.addBookmark("","New Group","group","")})}),n.addSeparator(),n.addItem(s=>{s.setTitle("Add separator").setIcon("minus").onClick(()=>{this.plugin.addBookmark("","","separator")})}),n.addItem(s=>{s.setTitle("Add spacer").setIcon("space").onClick(()=>{this.plugin.addBookmark("","","spacer")})}),n.showAtPosition({x:t.clientX,y:t.clientY})}),this.plugin.waypointData.bookmarks.length===0){e.createDiv({cls:"waypoint-bookmark-item",text:"No bookmarks"});return}this.renderBookmarkList(e,this.plugin.waypointData.bookmarks,0)}renderBookmarkList(e,a,i){for(let t=0;t{c.stopPropagation(),c.preventDefault(),this.showBookmarkContextMenu(c,n)});continue}if(n.type==="spacer"){let r=e.createDiv({cls:"waypoint-bookmark-item waypoint-bookmark-spacer"});r.setAttr("draggable","true"),r.setAttr("data-bm-id",n.id),r.style.paddingLeft=`${8+i*16}px`,r.style.cursor="grab",this.attachBookmarkDragHandlers(r,e,n,!1),r.addEventListener("contextmenu",c=>{c.stopPropagation(),c.preventDefault(),this.showBookmarkContextMenu(c,n)});continue}let s=n.type==="group",o=e.createDiv({cls:`waypoint-bookmark-item${s?" waypoint-bookmark-group":""}${n.collapsed?" collapsed":""}`});if(o.setAttr("draggable","true"),o.setAttr("data-bm-id",n.id),s||(o.style.paddingLeft=`${8+i*16}px`),this.attachBookmarkDragHandlers(o,e,n,!0),s){let r=o.createDiv({cls:"waypoint-bm-icon"});n.icon&&(0,m.setIcon)(r,n.icon);let c=o.createDiv({cls:"waypoint-bm-label",text:n.label}),l=o.createDiv({cls:"waypoint-bm-chevron"});(0,m.setIcon)(l,"chevron-down"),l.addEventListener("click",u=>{u.stopPropagation(),this.plugin.updateBookmark(n.id,{collapsed:!n.collapsed})}),o.addEventListener("click",u=>{if(n.filePath){let g=this.app.vault.getFileByPath(n.filePath);if(g){let F=m.Keymap.isModEvent(u);this.app.workspace.getLeaf(F).openFile(g);return}}this.plugin.updateBookmark(n.id,{collapsed:!n.collapsed})}),o.addEventListener("mousedown",u=>{if(u.button===1&&n.filePath){u.preventDefault();let g=this.app.vault.getFileByPath(n.filePath);g&&this.app.workspace.getLeaf("tab").openFile(g)}});let h=e.createDiv({cls:`waypoint-bookmark-children${n.collapsed?" collapsed":""}`});n.children&&n.children.length>0&&this.renderBookmarkList(h,n.children,i+1)}else{let r=o.createDiv({cls:"waypoint-bm-icon"});n.icon&&(0,m.setIcon)(r,n.icon);let c=o.createDiv({cls:"waypoint-bm-label",text:n.label});if(n.children&&n.children.length>0){let l=o.createDiv({cls:"waypoint-bm-chevron"});(0,m.setIcon)(l,"chevron-down"),l.addEventListener("click",h=>{h.stopPropagation(),this.plugin.updateBookmark(n.id,{collapsed:!n.collapsed})}),n.collapsed&&(o.addClass("collapsed"),l.style.transform="rotate(-90deg)")}if((0,m.setTooltip)(o,n.filePath),o.addEventListener("click",l=>{if(n.filePath){let h=this.app.vault.getFileByPath(n.filePath);if(h){let u=m.Keymap.isModEvent(l);this.app.workspace.getLeaf(u).openFile(h)}else new m.Notice("File not found"),this.plugin.removeBookmark(n.id)}}),o.addEventListener("mousedown",l=>{if(l.button===1&&n.filePath){l.preventDefault();let h=this.app.vault.getFileByPath(n.filePath);h&&this.app.workspace.getLeaf("tab").openFile(h)}}),n.children&&n.children.length>0){let l=e.createDiv({cls:`waypoint-bookmark-children${n.collapsed?" collapsed":""}`});this.renderBookmarkList(l,n.children,i+1)}}o.addEventListener("contextmenu",r=>{r.stopPropagation(),r.preventDefault(),this.showBookmarkContextMenu(r,n)})}}showBookmarkContextMenu(e,a){let i=new m.Menu;if(a.type==="separator"||a.type==="spacer"){i.addItem(t=>t.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(a.id))),i.showAtPosition({x:e.clientX,y:e.clientY});return}a.type==="file"?(i.addItem(t=>t.setTitle("Open in new tab").setIcon("file-plus").onClick(()=>{let n=this.app.vault.getFileByPath(a.filePath);n&&this.app.workspace.getLeaf("tab").openFile(n)})),i.addSeparator(),i.addItem(t=>t.setTitle("Rename").setIcon("pencil").onClick(()=>this.promptRename(a))),i.addItem(t=>t.setTitle("Change icon").setIcon("image").onClick(()=>this.promptIcon(a))),i.addSeparator(),i.addItem(t=>t.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(a.id)))):a.type==="group"&&(a.filePath&&(i.addItem(t=>t.setTitle("Open in new tab").setIcon("file-plus").onClick(()=>{let n=this.app.vault.getFileByPath(a.filePath);n&&this.app.workspace.getLeaf("tab").openFile(n)})),i.addSeparator()),i.addItem(t=>t.setTitle("Rename").setIcon("pencil").onClick(()=>this.promptRename(a))),i.addItem(t=>t.setTitle("Change icon").setIcon("image").onClick(()=>this.promptIcon(a))),i.addSeparator(),i.addItem(t=>t.setTitle("Add child bookmark").setIcon("file-plus").onClick(()=>{let n=this.app.workspace.getActiveFile();if(!n){new m.Notice("No active file");return}let s={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"file",label:n.basename,filePath:n.path,icon:"",children:[],collapsed:!1,indent:a.indent+1};a.children.push(s),this.plugin.saveWaypointData(),this.redraw()})),i.addItem(t=>t.setTitle("Add child note").setIcon("folder-plus").onClick(()=>{let n=this.app.workspace.getActiveFile();if(!n){new m.Notice("No active file");return}let s={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"group",label:n.basename,filePath:n.path,icon:"",children:[],collapsed:!1,indent:a.indent+1};a.children.push(s),this.plugin.saveWaypointData(),this.redraw()})),i.addItem(t=>t.setTitle("New sub-group").setIcon("folder-plus").onClick(()=>{let n={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"group",label:"New Group",filePath:"",icon:"",children:[],collapsed:!1,indent:a.indent+1};a.children.push(n),this.plugin.saveWaypointData(),this.redraw()})),i.addSeparator(),i.addItem(t=>t.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(a.id)))),i.showAtPosition({x:e.clientX,y:e.clientY})}attachBookmarkDragHandlers(e,a,i,t){let n=()=>{e.removeClass("waypoint-bm-drop-line"),e.removeClass("waypoint-bm-drop-below"),e.removeClass("waypoint-bm-drop-into")};e.addEventListener("dragstart",s=>{this.dragId=i.id,s.dataTransfer.effectAllowed="move",s.dataTransfer.setData("text/plain",i.id),e.addClass("waypoint-bm-dragging")}),e.addEventListener("dragend",()=>{this.dragId=null,a.querySelectorAll(".waypoint-bm-dragging, .waypoint-bm-drop-line, .waypoint-bm-drop-below, .waypoint-bm-drop-into").forEach(s=>{s.removeClass("waypoint-bm-dragging"),s.removeClass("waypoint-bm-drop-line"),s.removeClass("waypoint-bm-drop-below"),s.removeClass("waypoint-bm-drop-into")})}),e.addEventListener("dragenter",s=>{s.preventDefault(),!(!this.dragId||this.dragId===i.id)&&this.showDropIndicator(e,s,t)}),e.addEventListener("dragover",s=>{s.preventDefault(),!(!this.dragId||this.dragId===i.id)&&this.showDropIndicator(e,s,t)}),e.addEventListener("dragleave",n),e.addEventListener("drop",s=>{var c,l;s.preventDefault(),this.dragId=null,n();let o=(c=s.dataTransfer)==null?void 0:c.getData("text/plain");if(!o||o===i.id)return;let r=this.dropZones.get(e);t&&(r!=null&&r.into)?i.type==="group"?this.moveBookmarkToGroup(o,i.id):this.createParentNoteAndMove(o,i.id):this.moveBookmarkToPosition(o,i.id,(l=r==null?void 0:r.above)!=null?l:!1)})}showDropIndicator(e,a,i){let t=e.parentElement;t&&t.querySelectorAll(".waypoint-bm-drop-line, .waypoint-bm-drop-below, .waypoint-bm-drop-into").forEach(o=>{o.removeClass("waypoint-bm-drop-line"),o.removeClass("waypoint-bm-drop-below"),o.removeClass("waypoint-bm-drop-into")});let n=e.getBoundingClientRect(),s=a.clientY;if(i){let o=n.top+n.height*.25,r=n.top+n.height*.75;sr?(e.addClass("waypoint-bm-drop-line"),e.addClass("waypoint-bm-drop-below"),this.dropZones.set(e,{above:!1,into:!1})):(e.addClass("waypoint-bm-drop-into"),this.dropZones.set(e,{above:!1,into:!0}))}else{let o=s{let s=n.findIndex(o=>o.id===e);if(s>=0){let[o]=n.splice(s,1);return o}for(let o of n){let r=i(o.children);if(r)return r}return null},t=i(this.plugin.waypointData.bookmarks);if(t){if(a){let n=(s,o)=>s.id===o?!0:s.children.some(r=>n(r,o));if(t.id===a||n(t,a))return}if(a){let n=o=>{for(let r of o){if(r.id===a)return r;let c=n(r.children);if(c)return c}return null},s=n(this.plugin.waypointData.bookmarks);s&&(t.indent=s.indent+1,s.children.push(t))}else t.indent=0,this.plugin.waypointData.bookmarks.push(t);this.plugin.saveWaypointData(),this.redraw()}}createParentNoteAndMove(e,a){let i=o=>{let r=o.findIndex(c=>c.id===e);if(r>=0){let[c]=o.splice(r,1);return c}for(let c of o)if(c.children){let l=i(c.children);if(l)return l}return null},t=i(this.plugin.waypointData.bookmarks);if(!t)return;let n=o=>{for(let r of o){if(r.id===a)return r;if(r.children){let c=n(r.children);if(c)return c}}return null},s=n(this.plugin.waypointData.bookmarks);s&&(t.indent=s.indent+1,s.children.push(t),this.plugin.saveWaypointData(),this.redraw())}moveBookmarkToPosition(e,a,i){let t=r=>{let c=r.findIndex(l=>l.id===e);if(c>=0){let[l]=r.splice(c,1);return{item:l,parent:r}}for(let l of r)if(l.children){let h=t(l.children);if(h.item)return h}return{item:null,parent:[]}},{item:n}=t(this.plugin.waypointData.bookmarks);if(!n)return;let s=r=>{let c=r.findIndex(l=>l.id===a);if(c>=0)return{parent:r,idx:c};for(let l of r)if(l.children){let h=s(l.children);if(h)return h}return null},o=s(this.plugin.waypointData.bookmarks);if(!o)n.indent=0,this.plugin.waypointData.bookmarks.push(n);else{let r=i?o.idx:o.idx+1;o.parent.splice(r,0,n)}this.plugin.saveWaypointData(),this.redraw()}promptRename(e){new z(this.app,{title:"Rename bookmark",initialValue:e.label},a=>{a&&a.trim()&&this.plugin.updateBookmark(e.id,{label:a.trim()})}).open()}promptIcon(e){new K(this.app,e.icon,a=>{this.plugin.updateBookmark(e.id,{icon:a})}).open()}},z=class extends m.Modal{constructor(d,e,a){super(d),this.options=e,this.onSubmit=a}onOpen(){var t,n,s;this.titleEl.setText(this.options.title);let d=this.contentEl.createEl("input",{type:"text",value:(t=this.options.initialValue)!=null?t:"",placeholder:(n=this.options.placeholder)!=null?n:""});d.style.width="100%",d.style.marginBottom="12px",d.focus(),d.select();let e=this.contentEl.createDiv({cls:"modal-button-container"}),a=e.createEl("button",{text:"Cancel",cls:"mod-cta"});a.style.marginRight="8px",a.addEventListener("click",()=>this.close()),e.createEl("button",{text:(s=this.options.cta)!=null?s:"Save",cls:"mod-cta"}).addEventListener("click",()=>{this.onSubmit(d.value),this.close()}),d.addEventListener("keydown",o=>{o.key==="Enter"&&(this.onSubmit(d.value),this.close())})}onClose(){this.contentEl.empty()}},$=null;function ge(){return $||($=(async()=>{try{return await(await fetch("https://cdn.jsdelivr.net/npm/lucide-static@0.517.0/tags.json")).json()}catch(p){try{return await(await fetch("https://lucide.dev/api/tags")).json()}catch(d){return $=null,fe}}})()),$}var K=class extends m.Modal{constructor(e,a,i){super(e);this.allIcons=[];this.tagsMap={};this.loaded=!1;this.selected=a,this.onSubmit=i}async onOpen(){let e=this.contentEl;e.style.display="flex",e.style.flexDirection="column",e.style.gap="10px",this.titleEl.setText("Change icon");let a=e.createDiv({cls:"waypoint-icon-preview"});a.style.display="flex",a.style.alignItems="center",a.style.gap="10px",a.style.padding="12px 16px",a.style.borderRadius="8px",a.style.background="var(--background-secondary)",a.style.minHeight="48px";let i=a.createSpan();i.style.display="flex",this.selected&&(0,m.setIcon)(i,this.selected);let t=a.createSpan();t.style.fontWeight="var(--font-medium)",t.style.fontSize="var(--font-ui-medium)",t.setText(this.selected||"No icon");let n=e.createEl("input",{type:"text",placeholder:"Type to search (e.g. arrow, chart, home)..."});Object.assign(n.style,{width:"100%",boxSizing:"border-box",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--background-modifier-border)",background:"var(--background-primary)",color:"var(--text-normal)",fontSize:"var(--font-ui-medium)"}),n.focus();let s=e.createDiv({cls:"waypoint-icon-grid"});s.style.display="grid",s.style.gridTemplateColumns="repeat(auto-fill, minmax(52px, 1fr))",s.style.gap="4px",s.style.maxHeight="320px",s.style.overflowY="auto",s.style.padding="2px 0";let o=e.createDiv();o.style.display="flex",o.style.justifyContent="space-between",o.style.alignItems="center",o.style.fontSize="var(--font-ui-smaller)",o.style.color="var(--text-muted)",o.style.padding="0 4px";let r=o.createSpan();r.setText("Loading\u2026"),this.loadIcons().then(()=>{this.loaded=!0,r.setText(this.allIcons.length+" icons"),l(n.value)});let c,l=x=>{if(s.empty(),!this.loaded){s.createDiv({text:"Loading\u2026"});return}let w=x.toLowerCase().trim(),b=w?this.allIcons.filter(v=>{if(v.includes(w))return!0;let y=this.tagsMap[v];return y?y.some(L=>L.includes(w)):!1}).slice(0,80):this.allIcons.slice(0,80);if(b.length===0){let v=s.createDiv();v.style.gridColumn="1 / -1",v.style.textAlign="center",v.style.color="var(--text-muted)",v.style.padding="20px",v.setText('No icons match "'+x+'"');return}for(let v of b){let y=s.createDiv();y.setAttr("data-icon",v),y.style.display="flex",y.style.alignItems="center",y.style.justifyContent="center",y.style.aspectRatio="1",y.style.borderRadius="6px",y.style.cursor="var(--cursor-link, pointer)",y.style.transition="background 80ms",y.setAttr("title",v),v===this.selected?(y.style.background="var(--interactive-accent)",y.style.color="var(--text-on-accent)"):y.style.color="var(--text-muted)";let L=y.createSpan();L.style.display="flex",(0,m.setIcon)(L,v),y.addEventListener("mouseenter",()=>{v!==this.selected&&(y.style.background="var(--background-modifier-hover)")}),y.addEventListener("mouseleave",()=>{v!==this.selected&&(y.style.background="")}),y.addEventListener("click",()=>{this.selected=v,l(x),i.empty(),(0,m.setIcon)(i,v),t.setText(v),s.querySelectorAll("div[data-icon]").forEach(V=>{let M=V;M.getAttr("data-icon")===v?(M.style.background="var(--interactive-accent)",M.style.color="var(--text-on-accent)"):(M.style.background="",M.style.color="var(--text-muted)")})})}r.setText(b.length+" of "+this.allIcons.length+" icons")};n.addEventListener("input",()=>{window.clearTimeout(c),c=window.setTimeout(()=>l(n.value),60)}),n.addEventListener("keydown",x=>{x.key==="Escape"&&this.close()});let h=e.createDiv({cls:"modal-button-container"});h.createEl("button",{text:"No icon",cls:"waypoint-icon-clear"}).addEventListener("click",()=>{this.onSubmit(""),this.close()}),h.createEl("button",{text:"Cancel"}).addEventListener("click",()=>this.close());let F=h.createEl("button",{text:"Save",cls:"mod-cta"});F.style.marginLeft="8px",F.addEventListener("click",()=>{this.onSubmit(this.selected),this.close()})}onClose(){this.contentEl.empty()}async loadIcons(){let e=await ge();this.tagsMap=e,this.allIcons=Object.keys(e).sort()}},fe={file:[],folder:[],star:[],heart:[],bookmark:[],flag:[],pin:[],tag:[],book:[],"book-open":[],library:[],calendar:[],"calendar-days":[],clock:[],home:[],inbox:[],mail:[],search:[],settings:[],cog:[],user:[],users:[],zap:[],sparkles:[],target:[],link:[],globe:[],edit:[],pencil:[],anchor:[],award:[],bell:[],"bell-ring":[],brain:[],briefcase:[],camera:[],"chart-bar":[],"chart-line":[],"chart-pie":[],check:[],"check-circle":[],"chevron-down":[],"chevron-left":[],"chevron-right":[],"chevron-up":[],circle:[],clipboard:[],code:[],command:[],compass:[],copy:[],"credit-card":[],crown:[],database:[],download:[],"external-link":[],eye:[],"eye-off":[],"file-text":[],filter:[],fingerprint:[],flashlight:[],"folder-open":[],"folder-plus":[],gift:[],"git-branch":[],"git-commit":[],"git-merge":[],"git-pull-request":[],github:[],grid:[],hash:[],headphones:[],image:[],info:[],key:[],layers:[],layout:[],"life-buoy":[],"link-2":[],list:[],loader:[],lock:[],"log-in":[],"log-out":[],map:[],"map-pin":[],maximize:[],megaphone:[],menu:[],"message-circle":[],"message-square":[],mic:[],minimize:[],moon:[],"more-horizontal":[],"more-vertical":[],"mouse-pointer":[],move:[],music:[],navigation:[],"navigation-2":[],package:[],palette:[],paperclip:[],pause:[],phone:[],play:[],plus:[],"plus-circle":[],power:[],printer:[],radio:[],"refresh-cw":[],repeat:[],"rotate-ccw":[],"rotate-cw":[],rss:[],save:[],scissors:[],screen:[],send:[],server:[],share:[],"share-2":[],shield:[],"shield-off":[],"shopping-bag":[],"shopping-cart":[],shuffle:[],sidebar:[],slack:[],slash:[],sliders:[],smartphone:[],smile:[],speaker:[],square:[],"stop-circle":[],sun:[],sunrise:[],sunset:[],swords:[],table:[],tablet:[],terminal:[],thermometer:[],"thumbs-down":[],"thumbs-up":[],"toggle-left":[],"toggle-right":[],tool:[],trash:[],"trash-2":[],trello:[],"trending-down":[],"trending-up":[],triangle:[],truck:[],tv:[],twitter:[],type:[],umbrella:[],unlock:[],upload:[],"user-check":[],"user-minus":[],"user-plus":[],"user-x":[],video:[],"video-off":[],voicemail:[],volume:[],"volume-1":[],"volume-2":[],"volume-x":[],watch:[],wifi:[],"wifi-off":[],wind:[],x:[],"x-circle":[],"x-square":[],youtube:[],"zap-off":[],"zoom-in":[],"zoom-out":[],"arrow-down":[],"arrow-left":[],"arrow-right":[],"arrow-up":[],airplay:[],"alarm-clock":[],archive:[],armchair:[],atom:[],baby:[],backpack:[],badge:[],"badge-check":[],ban:[],banknote:[],barcode:[],bath:[],battery:[],"battery-charging":[],beer:[],bike:[],bird:[],bluetooth:[],bolt:[],bone:[],"bookmark-plus":[],bot:[],box:[],bug:[],building:[],bus:[],cake:[],calculator:[],car:[],"clipboard-check":[],cloud:[],"cloud-download":[],"cloud-lightning":[],"cloud-rain":[],"cloud-sun":[],"cloud-upload":[],clover:[],coffee:[],coins:[],contact:[],cookie:[],"corner-down-left":[],"corner-down-right":[],"corner-up-left":[],"corner-up-right":[],crosshair:[],"dice-1":[],"dice-6":[],"dollar-sign":[],"door-open":[],drama:[],droplet:[],drum:[],egg:[],equal:[],euro:[],factory:[],fan:[],feather:[],film:[],fish:[],flame:[],flask:[],flower:[],frown:[],fuel:[],gamepad:[],gauge:[],gem:[],ghost:[],glasses:[],"graduation-cap":[],hammer:[],"hard-drive":[],haze:[],"help-circle":[],"ice-cream":[],infinity:[],italic:[],"japanese-yen":[],keyboard:[],knife:[],lamp:[],landmark:[],languages:[],laptop:[],laugh:[],leaf:[],lightbulb:[],"list-plus":[],magnet:[],"mail-plus":[],meh:[],microscope:[],milestone:[],"minimize-2":[],monitor:[],mountain:[],mouse:[],network:[],newspaper:[],"package-check":[],"package-search":[],"paint-bucket":[],parking:[],"party-popper":[],"pen-tool":[],percent:[],"person-standing":[],"picture-in-picture-2":[],plane:[],plug:[],podcast:[],pointer:[],"pound-sterling":[],puzzle:[],"qr-code":[],rabbit:[],radar:[],rainbow:[],rocket:[],"roller-coaster":[],route:[],ruler:[],sailboat:[],scale:[],scan:[],school:[],ship:[],shirt:[],"shopping-basket":[],shovel:[],sigma:[],siren:[],skull:[],snowflake:[],soup:[],space:[],sparkle:[],stamp:[],store:[],subscript:[],superscript:[],syringe:[],tent:[],"tent-tree":[],"test-tube":[],theater:[],timer:[],train:[],"tree-deciduous":[],"tree-pine":[],trophy:[],typing:[],utensils:[],vibrate:[],wallet:[],wand:[],warehouse:[],waves:[],webcam:[],wheat:[],wine:[],wrench:[]};function Q(p,d,e){return!p||!d?null:p===d?e:p.startsWith(d+"/")?e+p.slice(d.length):null}var q=class extends f.Plugin{constructor(){super(...arguments);this.recentFiles=[];this.savePromise=Promise.resolve();this.markdownBasenames=new Set}async onload(){console.debug("Waypoint: loading plugin v"+this.manifest.version);let e=await this.loadData();this.applySettings(e),this.applyWaypointData(e),this.registerView(T,s=>new B(s,this)),this.addSettingTab(new O(this.app,this,this.settings,()=>{this.enforceRecentFilesLimit(),this.redrawAll()})),this.addCommand({id:"waypoint-open-view",name:"Open Waypoint sidebar",callback:async()=>{let s=this.app.workspace.getLeavesOfType(T);if(s.length>0)await this.app.workspace.revealLeaf(s[0]);else{let o=this.app.workspace.getLeftLeaf(!1);o&&(await o.setViewState({type:T}),await this.app.workspace.revealLeaf(o))}}}),this.addCommand({id:"waypoint-add-bookmark",name:"Add current file as Waypoint bookmark",callback:async()=>{let s=this.app.workspace.getActiveFile();if(!s){new f.Notice("No active file");return}this.addBookmark(s.path,s.basename,"file"),new f.Notice(`Bookmarked: ${s.basename}`)}}),this.addCommand({id:"waypoint-go-to-daily",name:"Go to daily note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"d"}],callback:async()=>{await this.openPeriodNote("day",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-weekly",name:"Go to weekly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"w"}],callback:async()=>{await this.openPeriodNote("week",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-monthly",name:"Go to monthly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"m"}],callback:async()=>{await this.openPeriodNote("month",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-quarterly",name:"Go to quarterly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"q"}],callback:async()=>{await this.openPeriodNote("quarter",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-yearly",name:"Go to yearly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"y"}],callback:async()=>{await this.openPeriodNote("year",(0,f.moment)())}});let a=["next","prev"],i=["daily","weekly","monthly","quarterly","yearly"],t={next:"Next",prev:"Previous"};for(let s of i)for(let o of a){let r=`waypoint-go-to-${o}-${s}`,c=`${t[o]} ${s} note`;this.addCommand({id:r,name:c,callback:async()=>{await this.navigatePeriodNote(o)}})}this.registerEvent(this.app.workspace.on("file-open",s=>{s&&this.onFileOpen(s)})),this.registerEvent(this.app.vault.on("create",s=>this.onVaultCreate(s))),this.registerEvent(this.app.vault.on("delete",s=>this.onVaultDelete(s))),this.registerEvent(this.app.vault.on("rename",(s,o)=>this.onRename(s,o))),this.registerEvent(this.app.vault.on("modify",s=>this.onFileModify(s))),this.app.workspace.onLayoutReady(()=>{if(this.buildMarkdownIndex(),this.app.workspace.getLeavesOfType(T).length===0){let o=this.app.workspace.getLeftLeaf(!1);o&&o.setViewState({type:T})}else this.broadcastRedraw()});let n=new Date().toDateString();this.registerInterval(window.setInterval(()=>{let s=new Date().toDateString();s!==n&&(n=s,this.redrawAll())},6e5))}async onunload(){this.app.workspace.detachLeavesOfType(T)}applySettings(e){let a=(e==null?void 0:e.settings)||{};this.settings=Object.assign({},E,a),this.settings.recentFiles=Object.assign({},E.recentFiles,a.recentFiles||{}),this.settings.calendar=Object.assign({},E.calendar,a.calendar||{}),this.settings.display=Object.assign({},E.display,a.display||{});for(let i of ye)this.settings[i]=Object.assign({},E[i],a[i]||{});this.settings.dateSystems=Array.isArray(a.dateSystems)?a.dateSystems.map(i=>Object.assign({},R,i)):E.dateSystems.map(i=>Object.assign({},i))}applyWaypointData(e){let a=(e==null?void 0:e.waypointData)||{};this.waypointData={bookmarks:Array.isArray(a.bookmarks)?a.bookmarks:[],recentFiles:Array.isArray(a.recentFiles)?a.recentFiles:[]},this.recentFiles=this.waypointData.recentFiles,this.recentFiles.length>this.settings.recentFiles.maxItems&&(this.recentFiles=this.recentFiles.slice(0,this.settings.recentFiles.maxItems),this.waypointData.recentFiles=this.recentFiles)}persistAll(){let e=this.savePromise.then(()=>(this.waypointData.recentFiles=this.recentFiles,this.saveData({settings:this.settings,waypointData:this.waypointData})));return this.savePromise=e.catch(()=>{}),e}async saveSettings(){await this.persistAll()}async saveWaypointData(){await this.persistAll()}enforceRecentFilesLimit(){this.recentFiles.length>this.settings.recentFiles.maxItems&&(this.recentFiles=this.recentFiles.slice(0,this.settings.recentFiles.maxItems),this.persistRecentFiles())}persistRecentFiles(){this.waypointData.recentFiles=this.recentFiles,window.clearTimeout(this.recentFilesSaveTimer),this.recentFilesSaveTimer=window.setTimeout(()=>{this.saveWaypointData()},300)}onFileOpen(e){this.settings.recentFiles.updateOn==="file-open"&&this.addToRecentFiles(e)}onFileModify(e){this.settings.recentFiles.updateOn==="file-edit"&&e instanceof f.TFile&&(this.recentFiles.length>0&&this.recentFiles[0].path===e.path||this.addToRecentFiles(e))}addToRecentFiles(e){this.isOmittedFromRecentFiles(e)||(this.recentFiles=this.recentFiles.filter(a=>a.path!==e.path),this.recentFiles.unshift({path:e.path,basename:e.basename}),this.recentFiles.length>this.settings.recentFiles.maxItems&&(this.recentFiles=this.recentFiles.slice(0,this.settings.recentFiles.maxItems)),this.persistRecentFiles(),this.broadcastRedraw())}isOmittedFromRecentFiles(e){for(let s of this.settings.recentFiles.omittedPaths)try{if(new RegExp(s).test(e.path))return!0}catch(o){}let a=this.settings.recentFiles.omittedTags;if(a.length===0)return!1;let i=this.app.metadataCache.getFileCache(e),t=(i?(0,f.getAllTags)(i):null)||[];if(t.length===0)return!1;let n=t.map(s=>s.replace(/^#/,""));for(let s of a)try{let o=new RegExp(s);if(n.some(r=>o.test(r)))return!0}catch(o){}return!1}onRename(e,a){let i=this.syncIndexForRename(e,a),t=!1;for(let s of this.recentFiles){let o=Q(s.path,a,e.path);o!==null&&(s.path=o,s.basename=se(o),t=!0)}let n=s=>{for(let o of s){if(o.filePath){let r=Q(o.filePath,a,e.path);r!==null&&(o.filePath=r,t=!0)}o.children&&n(o.children)}};n(this.waypointData.bookmarks),t&&(this.waypointData.recentFiles=this.recentFiles,this.persistAll()),(t||i)&&this.broadcastRedraw()}onVaultCreate(e){e instanceof f.TFile&&e.extension==="md"&&this.markdownBasenames.add(e.basename),this.broadcastRedraw()}onVaultDelete(e){e instanceof f.TFile&&e.extension==="md"&&this.removeFromMarkdownIndex(e.basename,e.path),this.broadcastRedraw()}buildMarkdownIndex(){this.markdownBasenames.clear();for(let e of this.app.vault.getMarkdownFiles())this.markdownBasenames.add(e.basename)}removeFromMarkdownIndex(e,a){return!this.markdownBasenames.has(e)||this.app.vault.getMarkdownFiles().some(t=>t.basename===e&&t.path!==a)?!1:(this.markdownBasenames.delete(e),!0)}syncIndexForRename(e,a){if(!(e instanceof f.TFile))return!1;let i=!1,t=se(a);return a.toLowerCase().endsWith(".md")&&(t!==e.basename||e.extension!=="md")&&(i=this.removeFromMarkdownIndex(t,a)),e.extension==="md"&&!this.markdownBasenames.has(e.basename)&&(this.markdownBasenames.add(e.basename),i=!0),i}hasNoteForDate(e){return this.markdownBasenames.has(e)}addBookmark(e,a,i="file",t=""){let s={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:i,label:a,filePath:i==="file"?e:"",icon:t,children:[],collapsed:!1,indent:0};return this.waypointData.bookmarks.push(s),this.saveWaypointData(),this.broadcastRedraw(),s}removeBookmark(e){let a=i=>{let t=i.findIndex(n=>n.id===e);if(t>=0)return i.splice(t,1),!0;for(let n of i)if(n.children&&a(n.children))return!0;return!1};a(this.waypointData.bookmarks),this.saveWaypointData(),this.broadcastRedraw()}updateBookmark(e,a){let i=n=>{for(let s of n){if(s.id===e)return s;if(s.children){let o=i(s.children);if(o)return o}}return null},t=i(this.waypointData.bookmarks);t&&(Object.assign(t,a),this.saveWaypointData(),this.broadcastRedraw())}periodAsDateSystem(e){let a=H[e],i=this.settings[a.key];return{id:a.key,name:a.label,folder:i.folder,nameFormat:i.nameFormat,templateFile:i.templateFile,typeProperty:i.typeProperty,icon:"calendar"}}dateSystems(){return[this.periodAsDateSystem("day"),...this.settings.dateSystems]}findDateSystemNotes(e){let a=this.dateSystems().map(i=>{let t=W(i.nameFormat);return{result:{system:i,notes:[],multiple:t.hasTitle},before:j(e,t.before),after:j(e,t.after),hasTitle:t.hasTitle,skip:!N(i.nameFormat)}});for(let i of this.app.vault.getMarkdownFiles())for(let t of a){if(t.skip)continue;let n=t.result.system;J(i.path,n.folder)&&ee(i.basename,t.before,t.after,t.hasTitle)&&t.result.notes.push({file:i,label:t.hasTitle?te(i.basename,t.before,t.after):n.name})}for(let i of a)i.result.notes.sort((t,n)=>t.file.basename.localeCompare(n.file.basename));return a.filter(i=>!i.skip).map(i=>i.result)}async openDateSystemNote(e,a,i){if(!N(e.nameFormat)){new f.Notice(`Waypoint: ${e.name||"This"} name format needs a date placeholder.`);return}let t=W(e.nameFormat),n=j(a,t.before),s=j(a,t.after),o;if(t.hasTitle){let h=ne((i==null?void 0:i.title)||"");if(!h){new f.Notice(`Waypoint: a ${e.name.toLowerCase()} note needs a title.`);return}o=n+h+s}else o=n+s;let r=e.folder?`${e.folder}/${o}.md`:`${o}.md`,c=this.app.vault.getFileByPath(r);if(!c&&(c=await this.createDatedNote(r,e,a),!c))return;await((i==null?void 0:i.leaf)||this.app.workspace.getLeaf(!1)).openFile(c)}async openPeriodNote(e,a,i){await this.openDateSystemNote(this.periodAsDateSystem(e),a,{leaf:i})}async createDatedNote(e,a,i){let t=a.name.toLowerCase(),n=e.lastIndexOf("/"),s=n<0?"":e.slice(0,n);try{await this.ensureFolderExists(s)}catch(h){return new f.Notice(`Waypoint: could not create the folder "${s}" for the ${t} note. -${U(h)} -Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,A),null}let o=a.templateFile,r=this.resolveTemplateFile(o),c;if(r)try{c=await this.app.vault.read(r)}catch(h){return new f.Notice(`Waypoint: could not read the template "${r.path}" for the ${t} note. -`+U(h),A),null}else c=`--- +project`),i.setValue(this.settings.recentFiles.filterTags.join(` +`)),i.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=i.getValue().split(` +`).filter(s=>s.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new v.Setting(e).setHeading().setName("Bookmarks"),this.addSliderSetting(e,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(e,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(e,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(e,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(e,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new v.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new v.Setting(e).addButton(a=>a.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...T.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,a,n,t,i,s,o,r,c){let l=new v.Setting(e).setName(a).setDesc(`${n} (${t[i]}${c})`);l.addSlider(h=>{h.setLimits(s,o,r).setValue(t[i]).setDynamicTooltip().onChange(u=>{t[i]=u,l.setDesc(`${n} (${u}${c})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let a=this.plugin.manifest.version,n=e.createDiv();n.style.display="flex",n.style.alignItems="center",n.style.gap="12px",n.style.marginBottom="16px";let t=n.createDiv();t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.width="48px",t.style.height="48px",t.style.borderRadius="12px",t.style.background="var(--interactive-accent)",t.style.color="var(--text-on-accent)",t.style.fontSize="24px",(0,v.setIcon)(t,"compass");let i=n.createDiv(),s=i.createEl("h2",{text:"Waypoint Sidebar"});s.style.margin="0",s.style.lineHeight="1.2";let o=i.createDiv({text:`v${a}`});o.style.color="var(--text-muted)",o.style.fontSize="var(--font-ui-small)";let r=e.createDiv();r.style.marginBottom="20px",r.style.lineHeight="1.6",r.style.color="var(--text-normal)",r.innerHTML=["

Waypoint is a sidebar plugin that brings three essential panels into one view:

",'
    ',"
  • Calendar \u2014 a monthly grid for your periodic notes (daily, weekly, monthly, quarterly, yearly). Click any day, week, or month to open or create the corresponding note.
  • ","
  • Recent Files \u2014 a list of recently opened files with type filtering, drag-and-drop, and right-click actions.
  • ","
  • Bookmarks \u2014 custom bookmarks with icons, groups, nesting, and drag-and-drop reordering. Separate from Obsidian's native bookmarks.
  • ","
",'

Made by Olivier. Licensed under MIT.

'].join(` +`)}};var m=require("obsidian");var C=require("obsidian");function le(p,d,e){let a=(0,C.moment)({year:p,month:d,day:1}),n=(0,C.moment)(a).endOf("month"),t=(0,C.moment)(a).subtract((a.day()-e+7)%7,"days"),i=(0,C.moment)().startOf("day"),s=[],o=(0,C.moment)(t);for(;o.isBefore(n)||o.month()===d;){let r=[];for(let c=0;c<7;c++)r.push({date:(0,C.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(i,"day"),isCurrentMonth:o.month()===d,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(s.push({weekNumber:r[0].isoWeekNumber,days:r}),s.length>=6)break}return s}var E="waypoint-view";function ke(p){return p.dragManager}var W=class extends m.ItemView{constructor(e,a){super(e);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let e=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",e.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",e.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",e.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",e.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",e.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",e.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,m.moment)().month();this.currentDisplayYear=(0,m.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.plugin=a}getViewType(){return E}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let e=this.contentEl.createDiv({cls:"waypoint-section"});e.createDiv({cls:"waypoint-section-header",text:"Calendar"});let a=e.createDiv({cls:"waypoint-calendar"}),n=(0,m.moment)(),t=(0,m.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),i=a.createDiv({cls:"waypoint-calendar-top"}),s=i.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=t.format("[Q]Q"),r=s.createSpan({cls:"waypoint-clickable",text:o});r.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",t)}),r.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("quarter",t,this.app.workspace.getLeaf("tab")))});let c=t.format("MMMM"),l=s.createSpan({cls:"waypoint-clickable",text:c});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",t)}),l.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("month",t,this.app.workspace.getLeaf("tab")))});let h=t.format("YYYY"),u=s.createSpan({cls:"waypoint-clickable",text:h});u.addEventListener("click",()=>{this.plugin.openPeriodNote("year",t)}),u.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("year",t,this.app.workspace.getLeaf("tab")))});let g=i.createDiv({cls:"waypoint-calendar-today-group"}),S=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(S,"chevron-left"),S.addEventListener("click",()=>this.navigateMonth(-1)),g.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,m.moment)().month(),this.currentDisplayYear=(0,m.moment)().year(),this.redraw()});let w=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(w,"chevron-right"),w.addEventListener("click",()=>this.navigateMonth(1));let b=a.createEl("table"),y=b.createEl("thead").createEl("tr");y.createEl("th",{text:""});let L=["sun","mon","tue","wed","thu","fri","sat"],G=this.plugin.settings.calendar.firstDayOfWeek;for(let D=0;D<7;D++){let N=(G+D)%7;y.createEl("th",{text:L[N]})}let P=b.createEl("tbody"),ee=le(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek),K=this.plugin.settings.calendar.showNoteIndicators&&this.plugin.settings.calendar.indicatorMode==="systems"?this.plugin.getDateSystemIndicators(ee.reduce((D,N)=>D.concat(N.days.map(Y=>Y.date)),[])):null;for(let D of ee){let N=P.createEl("tr"),Y=N.createEl("td",{cls:"waypoint-weeknum"});Y.setText(String(D.weekNumber));let te=D.days[0].date;Y.addEventListener("click",()=>{this.plugin.openPeriodNote("week",te)}),Y.addEventListener("mousedown",x=>{x.button===1&&(x.preventDefault(),this.plugin.openPeriodNote("week",te,this.app.workspace.getLeaf("tab")))});for(let x of D.days){let M=N.createEl("td",{cls:"waypoint-day"});if(M.setText(String(x.dayOfMonth)),x.isCurrentMonth||M.addClass("other-month"),x.isToday&&M.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let I=x.date.format("YYYY-MM-DD");if(this.plugin.settings.calendar.indicatorMode==="any")this.plugin.hasNoteForDate(I)&&M.addClass("has-note");else{let ne=(K==null?void 0:K.get(I))||[];if(ne.length>0){let pe=M.createDiv({cls:"waypoint-day-indicators"});for(let ie of ne){let ae=pe.createSpan({cls:"waypoint-day-indicator"});ae.style.setProperty("--waypoint-indicator-color",ie.color),(0,m.setTooltip)(ae,ie.name)}}}}M.addEventListener("click",()=>{this.plugin.openPeriodNote("day",x.date)}),M.addEventListener("mousedown",I=>{I.button===1&&(I.preventDefault(),this.plugin.openPeriodNote("day",x.date,this.app.workspace.getLeaf("tab")))}),M.addEventListener("contextmenu",I=>{I.preventDefault(),I.stopPropagation(),this.showDayContextMenu(I,x.date)})}}}navigateMonth(e){let a=(0,m.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(e,"month");this.currentDisplayMonth=a.month(),this.currentDisplayYear=a.year(),this.redraw()}showDayContextMenu(e,a){let n=new m.Menu;n.addItem(t=>t.setTitle(a.format("dddd, MMMM D, YYYY")).setIsLabel(!0));for(let t of this.plugin.findDateSystemNotes(a)){let i=t.multiple||t.notes.length===0;if(t.notes.length+(i?1:0)===0)continue;n.addSeparator();for(let o of t.notes)n.addItem(r=>r.setTitle(o.label).setIcon(t.system.icon).onClick(c=>this.focusFile(o.file,m.Keymap.isModEvent(c))));if(!i)continue;let s=t.system.name.toLowerCase();n.addItem(o=>o.setTitle(t.multiple?`New ${s} note\u2026`:`New ${s} note`).setIcon("plus").onClick(r=>this.createDateSystemNote(t,a,m.Keymap.isModEvent(r))))}n.showAtPosition({x:e.clientX,y:e.clientY})}createDateSystemNote(e,a,n){if(!e.multiple){this.plugin.openDateSystemNote(e.system,a,{leaf:n?this.app.workspace.getLeaf(n):void 0});return}let t=e.system.name;new H(this.app,{title:`New ${t.toLowerCase()} note`,placeholder:`${t} with\u2026`,cta:"Create"},i=>{this.plugin.openDateSystemNote(e.system,a,{title:i,leaf:n?this.app.workspace.getLeaf(n):void 0})}).open()}renderRecentFiles(){var r,c;let e=this.contentEl.createDiv({cls:"waypoint-section waypoint-recent-files"});if(e.createDiv({cls:"waypoint-section-header",text:"Recent Files"}),this.plugin.recentFiles.length===0){e.createDiv({cls:"nav-file",text:"No recent files"});return}let a=this.plugin.settings.recentFiles.filterTags||[],n={};if(a.length>0){for(let l of a)n[l]=0;for(let l of this.plugin.recentFiles){let h=this.app.vault.getAbstractFileByPath(l.path);if(h instanceof m.TFile){let u=this.app.metadataCache.getFileCache(h),g=(r=u==null?void 0:u.frontmatter)==null?void 0:r.type;g&&typeof g=="string"&&n.hasOwnProperty(g)&&n[g]++}}}else for(let l of this.plugin.recentFiles){let h=this.app.vault.getAbstractFileByPath(l.path);if(h instanceof m.TFile){let u=this.app.metadataCache.getFileCache(h),g=(c=u==null?void 0:u.frontmatter)==null?void 0:c.type;g&&typeof g=="string"&&(n[g]=(n[g]||0)+1)}}if(Object.keys(n).length>0){let l=e.createDiv({cls:"waypoint-recent-filter"});l.createSpan({cls:`waypoint-recent-pill${this.recentFilesFilter?"":" is-active"}`,text:"all"}).addEventListener("click",()=>{this.recentFilesFilter=null,this.redraw()});let u=a.length>0?Object.entries(n):Object.entries(n).sort((g,S)=>S[1]-g[1]);for(let[g,S]of u){let F=l.createSpan({cls:`waypoint-recent-pill${this.recentFilesFilter===g?" is-active":""}`});F.setText(`${g} ${S}`),F.addEventListener("click",()=>{this.recentFilesFilter=this.recentFilesFilter===g?null:g,this.redraw()})}}let t=this.plugin.recentFiles;this.recentFilesFilter&&(t=this.plugin.recentFiles.filter(l=>{var u;let h=this.app.vault.getAbstractFileByPath(l.path);if(h instanceof m.TFile){let g=this.app.metadataCache.getFileCache(h);return((u=g==null?void 0:g.frontmatter)==null?void 0:u.type)===this.recentFilesFilter}return!1}));let i=this.app.workspace.getActiveFile(),s=e.createDiv({cls:"nav-folder mod-root"}),o=s.createDiv({cls:"nav-folder-children"});for(let l of t){let h=o.createDiv({cls:"tree-item nav-file"}),u=h.createDiv({cls:"tree-item-self is-clickable nav-file-title"});u.createDiv({cls:"tree-item-inner nav-file-title-content"}).setText(l.basename);let S=u.createDiv({cls:"tree-item-spacer"}),F=u.createDiv({cls:"waypoint-recent-remove"});(0,m.setIcon)(F,"x"),F.addEventListener("click",w=>{w.stopPropagation(),this.plugin.recentFiles=this.plugin.recentFiles.filter(b=>b.path!==l.path),this.plugin.persistRecentFiles(),this.redraw()}),(0,m.setTooltip)(h,l.path),i&&l.path===i.path&&u.addClass("is-active"),u.setAttr("draggable","true"),u.addEventListener("dragstart",w=>{let b=this.app.metadataCache.getFirstLinkpathDest(l.path,"");if(b){let k=ke(this.app),y=k.dragFile(w,b);k.onDragStart(w,y)}}),u.addEventListener("mouseover",w=>{this.app.workspace.trigger("hover-link",{event:w,source:E,hoverParent:s,targetEl:h,linktext:l.path})}),u.addEventListener("contextmenu",w=>{let b=new m.Menu;b.addItem(y=>y.setSection("action").setTitle("Open in new tab").setIcon("file-plus").onClick(()=>this.focusFile(l,"tab"))),b.addItem(y=>y.setSection("action").setTitle("Add to bookmarks").setIcon("bookmark").onClick(()=>{this.plugin.addBookmark(l.path,l.basename,"file"),new m.Notice(`Bookmarked: ${l.basename}`)}));let k=this.app.vault.getAbstractFileByPath(l.path);k&&this.app.workspace.trigger("file-menu",b,k,"link-context-menu"),b.showAtPosition({x:w.clientX,y:w.clientY})}),u.addEventListener("click",w=>{let b=m.Keymap.isModEvent(w);this.focusFile(l,b)}),u.addEventListener("mousedown",w=>{w.button===1&&(w.preventDefault(),this.focusFile(l,"tab"))})}}focusFile(e,a){let n=this.app.vault.getFiles().find(t=>t.path===e.path);n?this.app.workspace.getLeaf(a).openFile(n):(new m.Notice("Cannot find file"),this.plugin.recentFiles=this.plugin.recentFiles.filter(t=>t.path!==e.path),this.plugin.persistRecentFiles(),this.redraw())}renderFavorites(){let e=this.contentEl.createDiv({cls:"waypoint-section waypoint-favorites"}),a=e.createDiv({cls:"waypoint-section-header"});a.setText("Waypoint Bookmarks");let n=a.createEl("button",{cls:"waypoint-header-more"});if((0,m.setIcon)(n,"more-horizontal"),(0,m.setTooltip)(n,"Add bookmark"),n.addEventListener("click",t=>{let i=new m.Menu;i.addItem(s=>{s.setTitle("Add current file").setIcon("file-plus").onClick(()=>{let o=this.app.workspace.getActiveFile();o&&this.plugin.addBookmark(o.path,o.basename,"file")})}),i.addItem(s=>{s.setTitle("Add as parent note").setIcon("folder-plus").onClick(()=>{let o=this.app.workspace.getActiveFile();if(!o)return;let r=this.plugin.addBookmark(o.path,o.basename,"group","");r.filePath=o.path,this.plugin.saveWaypointData(),this.redraw()})}),i.addItem(s=>{s.setTitle("New group").setIcon("folder-plus").onClick(()=>{this.plugin.addBookmark("","New Group","group","")})}),i.addSeparator(),i.addItem(s=>{s.setTitle("Add separator").setIcon("minus").onClick(()=>{this.plugin.addBookmark("","","separator")})}),i.addItem(s=>{s.setTitle("Add spacer").setIcon("space").onClick(()=>{this.plugin.addBookmark("","","spacer")})}),i.showAtPosition({x:t.clientX,y:t.clientY})}),this.plugin.waypointData.bookmarks.length===0){e.createDiv({cls:"waypoint-bookmark-item",text:"No bookmarks"});return}this.renderBookmarkList(e,this.plugin.waypointData.bookmarks,0)}renderBookmarkList(e,a,n){for(let t=0;t{c.stopPropagation(),c.preventDefault(),this.showBookmarkContextMenu(c,i)});continue}if(i.type==="spacer"){let r=e.createDiv({cls:"waypoint-bookmark-item waypoint-bookmark-spacer"});r.setAttr("draggable","true"),r.setAttr("data-bm-id",i.id),r.style.paddingLeft=`${8+n*16}px`,r.style.cursor="grab",this.attachBookmarkDragHandlers(r,e,i,!1),r.addEventListener("contextmenu",c=>{c.stopPropagation(),c.preventDefault(),this.showBookmarkContextMenu(c,i)});continue}let s=i.type==="group",o=e.createDiv({cls:`waypoint-bookmark-item${s?" waypoint-bookmark-group":""}${i.collapsed?" collapsed":""}`});if(o.setAttr("draggable","true"),o.setAttr("data-bm-id",i.id),s||(o.style.paddingLeft=`${8+n*16}px`),this.attachBookmarkDragHandlers(o,e,i,!0),s){let r=o.createDiv({cls:"waypoint-bm-icon"});i.icon&&(0,m.setIcon)(r,i.icon);let c=o.createDiv({cls:"waypoint-bm-label",text:i.label}),l=o.createDiv({cls:"waypoint-bm-chevron"});(0,m.setIcon)(l,"chevron-down"),l.addEventListener("click",u=>{u.stopPropagation(),this.plugin.updateBookmark(i.id,{collapsed:!i.collapsed})}),o.addEventListener("click",u=>{if(i.filePath){let g=this.app.vault.getFileByPath(i.filePath);if(g){let S=m.Keymap.isModEvent(u);this.app.workspace.getLeaf(S).openFile(g);return}}this.plugin.updateBookmark(i.id,{collapsed:!i.collapsed})}),o.addEventListener("mousedown",u=>{if(u.button===1&&i.filePath){u.preventDefault();let g=this.app.vault.getFileByPath(i.filePath);g&&this.app.workspace.getLeaf("tab").openFile(g)}});let h=e.createDiv({cls:`waypoint-bookmark-children${i.collapsed?" collapsed":""}`});i.children&&i.children.length>0&&this.renderBookmarkList(h,i.children,n+1)}else{let r=o.createDiv({cls:"waypoint-bm-icon"});i.icon&&(0,m.setIcon)(r,i.icon);let c=o.createDiv({cls:"waypoint-bm-label",text:i.label});if(i.children&&i.children.length>0){let l=o.createDiv({cls:"waypoint-bm-chevron"});(0,m.setIcon)(l,"chevron-down"),l.addEventListener("click",h=>{h.stopPropagation(),this.plugin.updateBookmark(i.id,{collapsed:!i.collapsed})}),i.collapsed&&(o.addClass("collapsed"),l.style.transform="rotate(-90deg)")}if((0,m.setTooltip)(o,i.filePath),o.addEventListener("click",l=>{if(i.filePath){let h=this.app.vault.getFileByPath(i.filePath);if(h){let u=m.Keymap.isModEvent(l);this.app.workspace.getLeaf(u).openFile(h)}else new m.Notice("File not found"),this.plugin.removeBookmark(i.id)}}),o.addEventListener("mousedown",l=>{if(l.button===1&&i.filePath){l.preventDefault();let h=this.app.vault.getFileByPath(i.filePath);h&&this.app.workspace.getLeaf("tab").openFile(h)}}),i.children&&i.children.length>0){let l=e.createDiv({cls:`waypoint-bookmark-children${i.collapsed?" collapsed":""}`});this.renderBookmarkList(l,i.children,n+1)}}o.addEventListener("contextmenu",r=>{r.stopPropagation(),r.preventDefault(),this.showBookmarkContextMenu(r,i)})}}showBookmarkContextMenu(e,a){let n=new m.Menu;if(a.type==="separator"||a.type==="spacer"){n.addItem(t=>t.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(a.id))),n.showAtPosition({x:e.clientX,y:e.clientY});return}a.type==="file"?(n.addItem(t=>t.setTitle("Open in new tab").setIcon("file-plus").onClick(()=>{let i=this.app.vault.getFileByPath(a.filePath);i&&this.app.workspace.getLeaf("tab").openFile(i)})),n.addSeparator(),n.addItem(t=>t.setTitle("Rename").setIcon("pencil").onClick(()=>this.promptRename(a))),n.addItem(t=>t.setTitle("Change icon").setIcon("image").onClick(()=>this.promptIcon(a))),n.addSeparator(),n.addItem(t=>t.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(a.id)))):a.type==="group"&&(a.filePath&&(n.addItem(t=>t.setTitle("Open in new tab").setIcon("file-plus").onClick(()=>{let i=this.app.vault.getFileByPath(a.filePath);i&&this.app.workspace.getLeaf("tab").openFile(i)})),n.addSeparator()),n.addItem(t=>t.setTitle("Rename").setIcon("pencil").onClick(()=>this.promptRename(a))),n.addItem(t=>t.setTitle("Change icon").setIcon("image").onClick(()=>this.promptIcon(a))),n.addSeparator(),n.addItem(t=>t.setTitle("Add child bookmark").setIcon("file-plus").onClick(()=>{let i=this.app.workspace.getActiveFile();if(!i){new m.Notice("No active file");return}let s={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"file",label:i.basename,filePath:i.path,icon:"",children:[],collapsed:!1,indent:a.indent+1};a.children.push(s),this.plugin.saveWaypointData(),this.redraw()})),n.addItem(t=>t.setTitle("Add child note").setIcon("folder-plus").onClick(()=>{let i=this.app.workspace.getActiveFile();if(!i){new m.Notice("No active file");return}let s={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"group",label:i.basename,filePath:i.path,icon:"",children:[],collapsed:!1,indent:a.indent+1};a.children.push(s),this.plugin.saveWaypointData(),this.redraw()})),n.addItem(t=>t.setTitle("New sub-group").setIcon("folder-plus").onClick(()=>{let i={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"group",label:"New Group",filePath:"",icon:"",children:[],collapsed:!1,indent:a.indent+1};a.children.push(i),this.plugin.saveWaypointData(),this.redraw()})),n.addSeparator(),n.addItem(t=>t.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(a.id)))),n.showAtPosition({x:e.clientX,y:e.clientY})}attachBookmarkDragHandlers(e,a,n,t){let i=()=>{e.removeClass("waypoint-bm-drop-line"),e.removeClass("waypoint-bm-drop-below"),e.removeClass("waypoint-bm-drop-into")};e.addEventListener("dragstart",s=>{this.dragId=n.id,s.dataTransfer.effectAllowed="move",s.dataTransfer.setData("text/plain",n.id),e.addClass("waypoint-bm-dragging")}),e.addEventListener("dragend",()=>{this.dragId=null,a.querySelectorAll(".waypoint-bm-dragging, .waypoint-bm-drop-line, .waypoint-bm-drop-below, .waypoint-bm-drop-into").forEach(s=>{s.removeClass("waypoint-bm-dragging"),s.removeClass("waypoint-bm-drop-line"),s.removeClass("waypoint-bm-drop-below"),s.removeClass("waypoint-bm-drop-into")})}),e.addEventListener("dragenter",s=>{s.preventDefault(),!(!this.dragId||this.dragId===n.id)&&this.showDropIndicator(e,s,t)}),e.addEventListener("dragover",s=>{s.preventDefault(),!(!this.dragId||this.dragId===n.id)&&this.showDropIndicator(e,s,t)}),e.addEventListener("dragleave",i),e.addEventListener("drop",s=>{var c,l;s.preventDefault(),this.dragId=null,i();let o=(c=s.dataTransfer)==null?void 0:c.getData("text/plain");if(!o||o===n.id)return;let r=this.dropZones.get(e);t&&(r!=null&&r.into)?n.type==="group"?this.moveBookmarkToGroup(o,n.id):this.createParentNoteAndMove(o,n.id):this.moveBookmarkToPosition(o,n.id,(l=r==null?void 0:r.above)!=null?l:!1)})}showDropIndicator(e,a,n){let t=e.parentElement;t&&t.querySelectorAll(".waypoint-bm-drop-line, .waypoint-bm-drop-below, .waypoint-bm-drop-into").forEach(o=>{o.removeClass("waypoint-bm-drop-line"),o.removeClass("waypoint-bm-drop-below"),o.removeClass("waypoint-bm-drop-into")});let i=e.getBoundingClientRect(),s=a.clientY;if(n){let o=i.top+i.height*.25,r=i.top+i.height*.75;sr?(e.addClass("waypoint-bm-drop-line"),e.addClass("waypoint-bm-drop-below"),this.dropZones.set(e,{above:!1,into:!1})):(e.addClass("waypoint-bm-drop-into"),this.dropZones.set(e,{above:!1,into:!0}))}else{let o=s{let s=i.findIndex(o=>o.id===e);if(s>=0){let[o]=i.splice(s,1);return o}for(let o of i){let r=n(o.children);if(r)return r}return null},t=n(this.plugin.waypointData.bookmarks);if(t){if(a){let i=(s,o)=>s.id===o?!0:s.children.some(r=>i(r,o));if(t.id===a||i(t,a))return}if(a){let i=o=>{for(let r of o){if(r.id===a)return r;let c=i(r.children);if(c)return c}return null},s=i(this.plugin.waypointData.bookmarks);s&&(t.indent=s.indent+1,s.children.push(t))}else t.indent=0,this.plugin.waypointData.bookmarks.push(t);this.plugin.saveWaypointData(),this.redraw()}}createParentNoteAndMove(e,a){let n=o=>{let r=o.findIndex(c=>c.id===e);if(r>=0){let[c]=o.splice(r,1);return c}for(let c of o)if(c.children){let l=n(c.children);if(l)return l}return null},t=n(this.plugin.waypointData.bookmarks);if(!t)return;let i=o=>{for(let r of o){if(r.id===a)return r;if(r.children){let c=i(r.children);if(c)return c}}return null},s=i(this.plugin.waypointData.bookmarks);s&&(t.indent=s.indent+1,s.children.push(t),this.plugin.saveWaypointData(),this.redraw())}moveBookmarkToPosition(e,a,n){let t=r=>{let c=r.findIndex(l=>l.id===e);if(c>=0){let[l]=r.splice(c,1);return{item:l,parent:r}}for(let l of r)if(l.children){let h=t(l.children);if(h.item)return h}return{item:null,parent:[]}},{item:i}=t(this.plugin.waypointData.bookmarks);if(!i)return;let s=r=>{let c=r.findIndex(l=>l.id===a);if(c>=0)return{parent:r,idx:c};for(let l of r)if(l.children){let h=s(l.children);if(h)return h}return null},o=s(this.plugin.waypointData.bookmarks);if(!o)i.indent=0,this.plugin.waypointData.bookmarks.push(i);else{let r=n?o.idx:o.idx+1;o.parent.splice(r,0,i)}this.plugin.saveWaypointData(),this.redraw()}promptRename(e){new H(this.app,{title:"Rename bookmark",initialValue:e.label},a=>{a&&a.trim()&&this.plugin.updateBookmark(e.id,{label:a.trim()})}).open()}promptIcon(e){new Z(this.app,e.icon,a=>{this.plugin.updateBookmark(e.id,{icon:a})}).open()}},H=class extends m.Modal{constructor(d,e,a){super(d),this.options=e,this.onSubmit=a}onOpen(){var t,i,s;this.titleEl.setText(this.options.title);let d=this.contentEl.createEl("input",{type:"text",value:(t=this.options.initialValue)!=null?t:"",placeholder:(i=this.options.placeholder)!=null?i:""});d.style.width="100%",d.style.marginBottom="12px",d.focus(),d.select();let e=this.contentEl.createDiv({cls:"modal-button-container"}),a=e.createEl("button",{text:"Cancel",cls:"mod-cta"});a.style.marginRight="8px",a.addEventListener("click",()=>this.close()),e.createEl("button",{text:(s=this.options.cta)!=null?s:"Save",cls:"mod-cta"}).addEventListener("click",()=>{this.onSubmit(d.value),this.close()}),d.addEventListener("keydown",o=>{o.key==="Enter"&&(this.onSubmit(d.value),this.close())})}onClose(){this.contentEl.empty()}},V=null;function we(){return V||(V=(async()=>{try{return await(await fetch("https://cdn.jsdelivr.net/npm/lucide-static@0.517.0/tags.json")).json()}catch(p){try{return await(await fetch("https://lucide.dev/api/tags")).json()}catch(d){return V=null,be}}})()),V}var Z=class extends m.Modal{constructor(e,a,n){super(e);this.allIcons=[];this.tagsMap={};this.loaded=!1;this.selected=a,this.onSubmit=n}async onOpen(){let e=this.contentEl;e.style.display="flex",e.style.flexDirection="column",e.style.gap="10px",this.titleEl.setText("Change icon");let a=e.createDiv({cls:"waypoint-icon-preview"});a.style.display="flex",a.style.alignItems="center",a.style.gap="10px",a.style.padding="12px 16px",a.style.borderRadius="8px",a.style.background="var(--background-secondary)",a.style.minHeight="48px";let n=a.createSpan();n.style.display="flex",this.selected&&(0,m.setIcon)(n,this.selected);let t=a.createSpan();t.style.fontWeight="var(--font-medium)",t.style.fontSize="var(--font-ui-medium)",t.setText(this.selected||"No icon");let i=e.createEl("input",{type:"text",placeholder:"Type to search (e.g. arrow, chart, home)..."});Object.assign(i.style,{width:"100%",boxSizing:"border-box",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--background-modifier-border)",background:"var(--background-primary)",color:"var(--text-normal)",fontSize:"var(--font-ui-medium)"}),i.focus();let s=e.createDiv({cls:"waypoint-icon-grid"});s.style.display="grid",s.style.gridTemplateColumns="repeat(auto-fill, minmax(52px, 1fr))",s.style.gap="4px",s.style.maxHeight="320px",s.style.overflowY="auto",s.style.padding="2px 0";let o=e.createDiv();o.style.display="flex",o.style.justifyContent="space-between",o.style.alignItems="center",o.style.fontSize="var(--font-ui-smaller)",o.style.color="var(--text-muted)",o.style.padding="0 4px";let r=o.createSpan();r.setText("Loading\u2026"),this.loadIcons().then(()=>{this.loaded=!0,r.setText(this.allIcons.length+" icons"),l(i.value)});let c,l=F=>{if(s.empty(),!this.loaded){s.createDiv({text:"Loading\u2026"});return}let w=F.toLowerCase().trim(),b=w?this.allIcons.filter(k=>{if(k.includes(w))return!0;let y=this.tagsMap[k];return y?y.some(L=>L.includes(w)):!1}).slice(0,80):this.allIcons.slice(0,80);if(b.length===0){let k=s.createDiv();k.style.gridColumn="1 / -1",k.style.textAlign="center",k.style.color="var(--text-muted)",k.style.padding="20px",k.setText('No icons match "'+F+'"');return}for(let k of b){let y=s.createDiv();y.setAttr("data-icon",k),y.style.display="flex",y.style.alignItems="center",y.style.justifyContent="center",y.style.aspectRatio="1",y.style.borderRadius="6px",y.style.cursor="var(--cursor-link, pointer)",y.style.transition="background 80ms",y.setAttr("title",k),k===this.selected?(y.style.background="var(--interactive-accent)",y.style.color="var(--text-on-accent)"):y.style.color="var(--text-muted)";let L=y.createSpan();L.style.display="flex",(0,m.setIcon)(L,k),y.addEventListener("mouseenter",()=>{k!==this.selected&&(y.style.background="var(--background-modifier-hover)")}),y.addEventListener("mouseleave",()=>{k!==this.selected&&(y.style.background="")}),y.addEventListener("click",()=>{this.selected=k,l(F),n.empty(),(0,m.setIcon)(n,k),t.setText(k),s.querySelectorAll("div[data-icon]").forEach(G=>{let P=G;P.getAttr("data-icon")===k?(P.style.background="var(--interactive-accent)",P.style.color="var(--text-on-accent)"):(P.style.background="",P.style.color="var(--text-muted)")})})}r.setText(b.length+" of "+this.allIcons.length+" icons")};i.addEventListener("input",()=>{window.clearTimeout(c),c=window.setTimeout(()=>l(i.value),60)}),i.addEventListener("keydown",F=>{F.key==="Escape"&&this.close()});let h=e.createDiv({cls:"modal-button-container"});h.createEl("button",{text:"No icon",cls:"waypoint-icon-clear"}).addEventListener("click",()=>{this.onSubmit(""),this.close()}),h.createEl("button",{text:"Cancel"}).addEventListener("click",()=>this.close());let S=h.createEl("button",{text:"Save",cls:"mod-cta"});S.style.marginLeft="8px",S.addEventListener("click",()=>{this.onSubmit(this.selected),this.close()})}onClose(){this.contentEl.empty()}async loadIcons(){let e=await we();this.tagsMap=e,this.allIcons=Object.keys(e).sort()}},be={file:[],folder:[],star:[],heart:[],bookmark:[],flag:[],pin:[],tag:[],book:[],"book-open":[],library:[],calendar:[],"calendar-days":[],clock:[],home:[],inbox:[],mail:[],search:[],settings:[],cog:[],user:[],users:[],zap:[],sparkles:[],target:[],link:[],globe:[],edit:[],pencil:[],anchor:[],award:[],bell:[],"bell-ring":[],brain:[],briefcase:[],camera:[],"chart-bar":[],"chart-line":[],"chart-pie":[],check:[],"check-circle":[],"chevron-down":[],"chevron-left":[],"chevron-right":[],"chevron-up":[],circle:[],clipboard:[],code:[],command:[],compass:[],copy:[],"credit-card":[],crown:[],database:[],download:[],"external-link":[],eye:[],"eye-off":[],"file-text":[],filter:[],fingerprint:[],flashlight:[],"folder-open":[],"folder-plus":[],gift:[],"git-branch":[],"git-commit":[],"git-merge":[],"git-pull-request":[],github:[],grid:[],hash:[],headphones:[],image:[],info:[],key:[],layers:[],layout:[],"life-buoy":[],"link-2":[],list:[],loader:[],lock:[],"log-in":[],"log-out":[],map:[],"map-pin":[],maximize:[],megaphone:[],menu:[],"message-circle":[],"message-square":[],mic:[],minimize:[],moon:[],"more-horizontal":[],"more-vertical":[],"mouse-pointer":[],move:[],music:[],navigation:[],"navigation-2":[],package:[],palette:[],paperclip:[],pause:[],phone:[],play:[],plus:[],"plus-circle":[],power:[],printer:[],radio:[],"refresh-cw":[],repeat:[],"rotate-ccw":[],"rotate-cw":[],rss:[],save:[],scissors:[],screen:[],send:[],server:[],share:[],"share-2":[],shield:[],"shield-off":[],"shopping-bag":[],"shopping-cart":[],shuffle:[],sidebar:[],slack:[],slash:[],sliders:[],smartphone:[],smile:[],speaker:[],square:[],"stop-circle":[],sun:[],sunrise:[],sunset:[],swords:[],table:[],tablet:[],terminal:[],thermometer:[],"thumbs-down":[],"thumbs-up":[],"toggle-left":[],"toggle-right":[],tool:[],trash:[],"trash-2":[],trello:[],"trending-down":[],"trending-up":[],triangle:[],truck:[],tv:[],twitter:[],type:[],umbrella:[],unlock:[],upload:[],"user-check":[],"user-minus":[],"user-plus":[],"user-x":[],video:[],"video-off":[],voicemail:[],volume:[],"volume-1":[],"volume-2":[],"volume-x":[],watch:[],wifi:[],"wifi-off":[],wind:[],x:[],"x-circle":[],"x-square":[],youtube:[],"zap-off":[],"zoom-in":[],"zoom-out":[],"arrow-down":[],"arrow-left":[],"arrow-right":[],"arrow-up":[],airplay:[],"alarm-clock":[],archive:[],armchair:[],atom:[],baby:[],backpack:[],badge:[],"badge-check":[],ban:[],banknote:[],barcode:[],bath:[],battery:[],"battery-charging":[],beer:[],bike:[],bird:[],bluetooth:[],bolt:[],bone:[],"bookmark-plus":[],bot:[],box:[],bug:[],building:[],bus:[],cake:[],calculator:[],car:[],"clipboard-check":[],cloud:[],"cloud-download":[],"cloud-lightning":[],"cloud-rain":[],"cloud-sun":[],"cloud-upload":[],clover:[],coffee:[],coins:[],contact:[],cookie:[],"corner-down-left":[],"corner-down-right":[],"corner-up-left":[],"corner-up-right":[],crosshair:[],"dice-1":[],"dice-6":[],"dollar-sign":[],"door-open":[],drama:[],droplet:[],drum:[],egg:[],equal:[],euro:[],factory:[],fan:[],feather:[],film:[],fish:[],flame:[],flask:[],flower:[],frown:[],fuel:[],gamepad:[],gauge:[],gem:[],ghost:[],glasses:[],"graduation-cap":[],hammer:[],"hard-drive":[],haze:[],"help-circle":[],"ice-cream":[],infinity:[],italic:[],"japanese-yen":[],keyboard:[],knife:[],lamp:[],landmark:[],languages:[],laptop:[],laugh:[],leaf:[],lightbulb:[],"list-plus":[],magnet:[],"mail-plus":[],meh:[],microscope:[],milestone:[],"minimize-2":[],monitor:[],mountain:[],mouse:[],network:[],newspaper:[],"package-check":[],"package-search":[],"paint-bucket":[],parking:[],"party-popper":[],"pen-tool":[],percent:[],"person-standing":[],"picture-in-picture-2":[],plane:[],plug:[],podcast:[],pointer:[],"pound-sterling":[],puzzle:[],"qr-code":[],rabbit:[],radar:[],rainbow:[],rocket:[],"roller-coaster":[],route:[],ruler:[],sailboat:[],scale:[],scan:[],school:[],ship:[],shirt:[],"shopping-basket":[],shovel:[],sigma:[],siren:[],skull:[],snowflake:[],soup:[],space:[],sparkle:[],stamp:[],store:[],subscript:[],superscript:[],syringe:[],tent:[],"tent-tree":[],"test-tube":[],theater:[],timer:[],train:[],"tree-deciduous":[],"tree-pine":[],trophy:[],typing:[],utensils:[],vibrate:[],wallet:[],wand:[],warehouse:[],waves:[],webcam:[],wheat:[],wine:[],wrench:[]};function J(p,d,e){return!p||!d?null:p===d?e:p.startsWith(d+"/")?e+p.slice(d.length):null}var q=class extends f.Plugin{constructor(){super(...arguments);this.recentFiles=[];this.savePromise=Promise.resolve();this.markdownBasenames=new Set;this.dateSystemIndicators=null;this.dateSystemIndicatorKey=""}async onload(){console.debug("Waypoint: loading plugin v"+this.manifest.version);let e=await this.loadData();this.applySettings(e),this.applyWaypointData(e),this.registerView(E,s=>new W(s,this)),this.addSettingTab(new z(this.app,this,this.settings,()=>{this.enforceRecentFilesLimit(),this.invalidateDateSystemIndicators(),this.redrawAll()})),this.addCommand({id:"waypoint-open-view",name:"Open Waypoint sidebar",callback:async()=>{let s=this.app.workspace.getLeavesOfType(E);if(s.length>0)await this.app.workspace.revealLeaf(s[0]);else{let o=this.app.workspace.getLeftLeaf(!1);o&&(await o.setViewState({type:E}),await this.app.workspace.revealLeaf(o))}}}),this.addCommand({id:"waypoint-add-bookmark",name:"Add current file as Waypoint bookmark",callback:async()=>{let s=this.app.workspace.getActiveFile();if(!s){new f.Notice("No active file");return}this.addBookmark(s.path,s.basename,"file"),new f.Notice(`Bookmarked: ${s.basename}`)}}),this.addCommand({id:"waypoint-go-to-daily",name:"Go to daily note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"d"}],callback:async()=>{await this.openPeriodNote("day",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-weekly",name:"Go to weekly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"w"}],callback:async()=>{await this.openPeriodNote("week",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-monthly",name:"Go to monthly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"m"}],callback:async()=>{await this.openPeriodNote("month",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-quarterly",name:"Go to quarterly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"q"}],callback:async()=>{await this.openPeriodNote("quarter",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-yearly",name:"Go to yearly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"y"}],callback:async()=>{await this.openPeriodNote("year",(0,f.moment)())}});let a=["next","prev"],n=["daily","weekly","monthly","quarterly","yearly"],t={next:"Next",prev:"Previous"};for(let s of n)for(let o of a){let r=`waypoint-go-to-${o}-${s}`,c=`${t[o]} ${s} note`;this.addCommand({id:r,name:c,callback:async()=>{await this.navigatePeriodNote(o)}})}this.registerEvent(this.app.workspace.on("file-open",s=>{s&&this.onFileOpen(s)})),this.registerEvent(this.app.vault.on("create",s=>this.onVaultCreate(s))),this.registerEvent(this.app.vault.on("delete",s=>this.onVaultDelete(s))),this.registerEvent(this.app.vault.on("rename",(s,o)=>this.onRename(s,o))),this.registerEvent(this.app.vault.on("modify",s=>this.onFileModify(s))),this.app.workspace.onLayoutReady(()=>{if(this.buildMarkdownIndex(),this.app.workspace.getLeavesOfType(E).length===0){let o=this.app.workspace.getLeftLeaf(!1);o&&o.setViewState({type:E})}else this.broadcastRedraw()});let i=new Date().toDateString();this.registerInterval(window.setInterval(()=>{let s=new Date().toDateString();s!==i&&(i=s,this.redrawAll())},6e5))}async onunload(){this.app.workspace.detachLeavesOfType(E)}applySettings(e){let a=(e==null?void 0:e.settings)||{};this.settings=Object.assign({},T,a),this.settings.recentFiles=Object.assign({},T.recentFiles,a.recentFiles||{}),this.settings.calendar=Object.assign({},T.calendar,a.calendar||{}),this.settings.display=Object.assign({},T.display,a.display||{});for(let n of De)this.settings[n]=Object.assign({},T[n],a[n]||{});this.settings.dateSystems=Array.isArray(a.dateSystems)?a.dateSystems.map(n=>{let t=T.dateSystems.find(i=>i.id===n.id);return Object.assign({},t||$,n)}):T.dateSystems.map(n=>Object.assign({},n))}applyWaypointData(e){let a=(e==null?void 0:e.waypointData)||{};this.waypointData={bookmarks:Array.isArray(a.bookmarks)?a.bookmarks:[],recentFiles:Array.isArray(a.recentFiles)?a.recentFiles:[]},this.recentFiles=this.waypointData.recentFiles,this.recentFiles.length>this.settings.recentFiles.maxItems&&(this.recentFiles=this.recentFiles.slice(0,this.settings.recentFiles.maxItems),this.waypointData.recentFiles=this.recentFiles)}persistAll(){let e=this.savePromise.then(()=>(this.waypointData.recentFiles=this.recentFiles,this.saveData({settings:this.settings,waypointData:this.waypointData})));return this.savePromise=e.catch(()=>{}),e}async saveSettings(){await this.persistAll()}async saveWaypointData(){await this.persistAll()}enforceRecentFilesLimit(){this.recentFiles.length>this.settings.recentFiles.maxItems&&(this.recentFiles=this.recentFiles.slice(0,this.settings.recentFiles.maxItems),this.persistRecentFiles())}persistRecentFiles(){this.waypointData.recentFiles=this.recentFiles,window.clearTimeout(this.recentFilesSaveTimer),this.recentFilesSaveTimer=window.setTimeout(()=>{this.saveWaypointData()},300)}onFileOpen(e){this.settings.recentFiles.updateOn==="file-open"&&this.addToRecentFiles(e)}onFileModify(e){this.settings.recentFiles.updateOn==="file-edit"&&e instanceof f.TFile&&(this.recentFiles.length>0&&this.recentFiles[0].path===e.path||this.addToRecentFiles(e))}addToRecentFiles(e){this.isOmittedFromRecentFiles(e)||(this.recentFiles=this.recentFiles.filter(a=>a.path!==e.path),this.recentFiles.unshift({path:e.path,basename:e.basename}),this.recentFiles.length>this.settings.recentFiles.maxItems&&(this.recentFiles=this.recentFiles.slice(0,this.settings.recentFiles.maxItems)),this.persistRecentFiles(),this.broadcastRedraw())}isOmittedFromRecentFiles(e){for(let s of this.settings.recentFiles.omittedPaths)try{if(new RegExp(s).test(e.path))return!0}catch(o){}let a=this.settings.recentFiles.omittedTags;if(a.length===0)return!1;let n=this.app.metadataCache.getFileCache(e),t=(n?(0,f.getAllTags)(n):null)||[];if(t.length===0)return!1;let i=t.map(s=>s.replace(/^#/,""));for(let s of a)try{let o=new RegExp(s);if(i.some(r=>o.test(r)))return!0}catch(o){}return!1}onRename(e,a){this.invalidateDateSystemIndicators();let n=this.syncIndexForRename(e,a),t=!1;for(let s of this.recentFiles){let o=J(s.path,a,e.path);o!==null&&(s.path=o,s.basename=de(o),t=!0)}let i=s=>{for(let o of s){if(o.filePath){let r=J(o.filePath,a,e.path);r!==null&&(o.filePath=r,t=!0)}o.children&&i(o.children)}};i(this.waypointData.bookmarks),t&&(this.waypointData.recentFiles=this.recentFiles,this.persistAll()),(t||n)&&this.broadcastRedraw()}onVaultCreate(e){e instanceof f.TFile&&e.extension==="md"&&(this.markdownBasenames.add(e.basename),this.invalidateDateSystemIndicators()),this.broadcastRedraw()}onVaultDelete(e){e instanceof f.TFile&&e.extension==="md"&&(this.removeFromMarkdownIndex(e.basename,e.path),this.invalidateDateSystemIndicators()),this.broadcastRedraw()}buildMarkdownIndex(){this.markdownBasenames.clear();for(let e of this.app.vault.getMarkdownFiles())this.markdownBasenames.add(e.basename)}invalidateDateSystemIndicators(){this.dateSystemIndicators=null,this.dateSystemIndicatorKey=""}removeFromMarkdownIndex(e,a){return!this.markdownBasenames.has(e)||this.app.vault.getMarkdownFiles().some(t=>t.basename===e&&t.path!==a)?!1:(this.markdownBasenames.delete(e),!0)}syncIndexForRename(e,a){if(!(e instanceof f.TFile))return!1;let n=!1,t=de(a);return a.toLowerCase().endsWith(".md")&&(t!==e.basename||e.extension!=="md")&&(n=this.removeFromMarkdownIndex(t,a)),e.extension==="md"&&!this.markdownBasenames.has(e.basename)&&(this.markdownBasenames.add(e.basename),n=!0),n}hasNoteForDate(e){return this.markdownBasenames.has(e)}addBookmark(e,a,n="file",t=""){let s={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:n,label:a,filePath:n==="file"?e:"",icon:t,children:[],collapsed:!1,indent:0};return this.waypointData.bookmarks.push(s),this.saveWaypointData(),this.broadcastRedraw(),s}removeBookmark(e){let a=n=>{let t=n.findIndex(i=>i.id===e);if(t>=0)return n.splice(t,1),!0;for(let i of n)if(i.children&&a(i.children))return!0;return!1};a(this.waypointData.bookmarks),this.saveWaypointData(),this.broadcastRedraw()}updateBookmark(e,a){let n=i=>{for(let s of i){if(s.id===e)return s;if(s.children){let o=n(s.children);if(o)return o}}return null},t=n(this.waypointData.bookmarks);t&&(Object.assign(t,a),this.saveWaypointData(),this.broadcastRedraw())}periodAsDateSystem(e){let a=j[e],n=this.settings[a.key];return{id:a.key,name:a.label,folder:n.folder,nameFormat:n.nameFormat,templateFile:n.templateFile,typeProperty:n.typeProperty,icon:"calendar",indicatorColor:this.settings.calendar.dailyIndicatorColor}}dateSystems(){return[this.periodAsDateSystem("day"),...this.settings.dateSystems]}findDateSystemNotes(e){let a=this.dateSystems().map(n=>{let t=R(n.nameFormat);return{result:{system:n,notes:[],multiple:t.hasTitle},before:B(e,t.before),after:B(e,t.after),hasTitle:t.hasTitle,skip:!A(n.nameFormat)}});for(let n of this.app.vault.getMarkdownFiles())for(let t of a){if(t.skip)continue;let i=t.result.system;Q(n.path,i.folder)&&U(n.basename,t.before,t.after,t.hasTitle)&&t.result.notes.push({file:n,label:t.hasTitle?oe(n.basename,t.before,t.after):i.name})}for(let n of a)n.result.notes.sort((t,i)=>t.file.basename.localeCompare(i.file.basename));return a.filter(n=>!n.skip).map(n=>n.result)}getDateSystemIndicators(e){var o;let a=e.map(r=>r.format("YYYY-MM-DD")),n=this.dateSystems().filter(r=>A(r.nameFormat)).map(r=>{let c=R(r.nameFormat);return{system:r,hasTitle:c.hasTitle,dates:e.map((l,h)=>({dateStr:a[h],before:B(l,c.before),after:B(l,c.after)}))}}),t=JSON.stringify({dates:a,systems:n.map(({system:r})=>[r.id,r.name,r.folder,r.nameFormat,r.indicatorColor])});if(this.dateSystemIndicators&&this.dateSystemIndicatorKey===t)return this.dateSystemIndicators;let i=new Map;for(let r of a)i.set(r,new Set);for(let r of this.app.vault.getMarkdownFiles())for(let c of n)if(Q(r.path,c.system.folder))for(let l of c.dates)U(r.basename,l.before,l.after,c.hasTitle)&&((o=i.get(l.dateStr))==null||o.add(c.system.id));let s=new Map;for(let r of a){let c=i.get(r);s.set(r,n.filter(({system:l})=>c==null?void 0:c.has(l.id)).map(({system:l})=>({id:l.id,name:l.name,color:l.indicatorColor})))}return this.dateSystemIndicatorKey=t,this.dateSystemIndicators=s,s}async openDateSystemNote(e,a,n){if(!A(e.nameFormat)){new f.Notice(`Waypoint: ${e.name||"This"} name format needs a date placeholder.`);return}let t=R(e.nameFormat),i=B(a,t.before),s=B(a,t.after),o;if(t.hasTitle){let h=re((n==null?void 0:n.title)||"");if(!h){new f.Notice(`Waypoint: a ${e.name.toLowerCase()} note needs a title.`);return}o=i+h+s}else o=i+s;let r=e.folder?`${e.folder}/${o}.md`:`${o}.md`,c=this.app.vault.getFileByPath(r);if(!c&&(c=await this.createDatedNote(r,e,a),!c))return;await((n==null?void 0:n.leaf)||this.app.workspace.getLeaf(!1)).openFile(c)}async openPeriodNote(e,a,n){await this.openDateSystemNote(this.periodAsDateSystem(e),a,{leaf:n})}async createDatedNote(e,a,n){let t=a.name.toLowerCase(),i=e.lastIndexOf("/"),s=i<0?"":e.slice(0,i);try{await this.ensureFolderExists(s)}catch(h){return new f.Notice(`Waypoint: could not create the folder "${s}" for the ${t} note. +${X(h)} +Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,O),null}let o=a.templateFile,r=this.resolveTemplateFile(o),c;if(r)try{c=await this.app.vault.read(r)}catch(h){return new f.Notice(`Waypoint: could not read the template "${r.path}" for the ${t} note. +`+X(h),O),null}else c=`--- type: ${a.typeProperty} -date: ${i.format("YYYY-MM-DD")} +date: ${n.format("YYYY-MM-DD")} --- `;let l;try{l=await this.app.vault.create(e,c)}catch(h){return new f.Notice(`Waypoint: could not create the ${t} note at "${e}". -${U(h)}`,A),null}return o&&!r?new f.Notice(`Created ${t} note: ${l.basename} -Template "${o}" was not found, so a basic note was created instead.`,A):new f.Notice(`Created ${t} note: ${l.basename}`),l}async ensureFolderExists(e){if(!e||this.app.vault.getAbstractFileByPath(e)instanceof f.TFolder)return;let a="";for(let i of e.split("/"))if(i&&(a=a?`${a}/${i}`:i,!(this.app.vault.getAbstractFileByPath(a)instanceof f.TFolder)))try{await this.app.vault.createFolder(a)}catch(t){if(!(this.app.vault.getAbstractFileByPath(a)instanceof f.TFolder))throw t}}resolveTemplateFile(e){if(!e)return null;let a=e.toLowerCase().endsWith(".md")?e:`${e}.md`;return this.app.vault.getFileByPath(a)}detectPeriodType(e){for(let a of ae){let i=this.settings[H[a].key].nameFormat;if(!i)continue;let t=(0,f.moment)(e,i,!0);if(t.isValid())return{period:a,date:t}}return null}async navigatePeriodNote(e){let a=this.app.workspace.getActiveFile();if(!a){new f.Notice("No active file");return}let i=this.detectPeriodType(a.basename);if(!i){let r=ae.map(c=>`${H[c].label.toLowerCase()} "${this.settings[H[c].key].nameFormat}"`).join(", ");new f.Notice(`Waypoint: "${a.basename}" does not match any configured periodic note format. -Expected one of: ${r}.`,A);return}let{period:t,date:n}=i,s=e==="next"?1:-1,o=t==="quarter"?n.clone().add(s*3,"months"):n.clone().add(s,`${t}s`);await this.openPeriodNote(t,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let e=this.app.workspace.getLeavesOfType(T);for(let a of e)a.view instanceof B&&a.view.redraw()}},ye=["daily","weekly","monthly","quarterly","yearly"],H={day:{key:"daily",label:"Daily"},week:{key:"weekly",label:"Weekly"},month:{key:"monthly",label:"Monthly"},quarter:{key:"quarterly",label:"Quarterly"},year:{key:"yearly",label:"Yearly"}},ae=["day","week","month","quarter","year"];function se(p){return p.slice(p.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}var A=1e4;function U(p){return p instanceof Error?p.message:String(p)}function j(p,d){return d?p.format(d):""} +${X(h)}`,O),null}return o&&!r?new f.Notice(`Created ${t} note: ${l.basename} +Template "${o}" was not found, so a basic note was created instead.`,O):new f.Notice(`Created ${t} note: ${l.basename}`),l}async ensureFolderExists(e){if(!e||this.app.vault.getAbstractFileByPath(e)instanceof f.TFolder)return;let a="";for(let n of e.split("/"))if(n&&(a=a?`${a}/${n}`:n,!(this.app.vault.getAbstractFileByPath(a)instanceof f.TFolder)))try{await this.app.vault.createFolder(a)}catch(t){if(!(this.app.vault.getAbstractFileByPath(a)instanceof f.TFolder))throw t}}resolveTemplateFile(e){if(!e)return null;let a=e.toLowerCase().endsWith(".md")?e:`${e}.md`;return this.app.vault.getFileByPath(a)}detectPeriodType(e){for(let a of ce){let n=this.settings[j[a].key].nameFormat;if(!n)continue;let t=(0,f.moment)(e,n,!0);if(t.isValid())return{period:a,date:t}}return null}async navigatePeriodNote(e){let a=this.app.workspace.getActiveFile();if(!a){new f.Notice("No active file");return}let n=this.detectPeriodType(a.basename);if(!n){let r=ce.map(c=>`${j[c].label.toLowerCase()} "${this.settings[j[c].key].nameFormat}"`).join(", ");new f.Notice(`Waypoint: "${a.basename}" does not match any configured periodic note format. +Expected one of: ${r}.`,O);return}let{period:t,date:i}=n,s=e==="next"?1:-1,o=t==="quarter"?i.clone().add(s*3,"months"):i.clone().add(s,`${t}s`);await this.openPeriodNote(t,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let e=this.app.workspace.getLeavesOfType(E);for(let a of e)a.view instanceof W&&a.view.redraw()}},De=["daily","weekly","monthly","quarterly","yearly"],j={day:{key:"daily",label:"Daily"},week:{key:"weekly",label:"Weekly"},month:{key:"monthly",label:"Monthly"},quarter:{key:"quarterly",label:"Quarterly"},year:{key:"yearly",label:"Yearly"}},ce=["day","week","month","quarter","year"];function de(p){return p.slice(p.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}var O=1e4;function X(p){return p instanceof Error?p.message:String(p)}function B(p,d){return d?p.format(d):""} diff --git a/src/main.ts b/src/main.ts index 5d3c472..0809dac 100644 --- a/src/main.ts +++ b/src/main.ts @@ -42,6 +42,13 @@ export interface DateSystemNotes { multiple: boolean; } +/** One coloured calendar marker for a date system that has a note on a day. */ +export interface DateSystemIndicator { + id: string; + name: string; + color: string; +} + export default class WaypointPlugin extends Plugin { public settings: WaypointSettings; public waypointData: WaypointData; @@ -51,6 +58,9 @@ export default class WaypointPlugin extends Plugin { private savePromise: Promise = Promise.resolve(); /** Basenames of every markdown file in the vault, for O(1) calendar lookups. */ private markdownBasenames: Set = new Set(); + /** Results for the displayed month; invalidated by markdown-file changes. */ + private dateSystemIndicators: Map | null = null; + private dateSystemIndicatorKey = ''; async onload(): Promise { console.debug('Waypoint: loading plugin v' + this.manifest.version); @@ -73,6 +83,7 @@ export default class WaypointPlugin extends Plugin { this.settings, () => { this.enforceRecentFilesLimit(); + this.invalidateDateSystemIndicators(); this.redrawAll(); }, )); @@ -247,10 +258,14 @@ export default class WaypointPlugin extends Plugin { } // Cloned, not Object.assign'd in: the defaults array would otherwise be // aliased into the live settings and the settings UI would edit - // DEFAULT_SETTINGS itself. Saved entries merge over - // DEFAULT_DATE_SYSTEM so older configs pick up fields added since. + // DEFAULT_DATE_SYSTEM so older configs pick up fields added since. Known + // built-ins use their own defaults too, preserving Journal/Meeting colours + // when this field is first introduced. this.settings.dateSystems = Array.isArray(s.dateSystems) - ? s.dateSystems.map(sys => Object.assign({}, DEFAULT_DATE_SYSTEM, sys)) + ? s.dateSystems.map(sys => { + const builtIn = DEFAULT_SETTINGS.dateSystems.find(defaultSystem => defaultSystem.id === sys.id); + return Object.assign({}, builtIn || DEFAULT_DATE_SYSTEM, sys); + }) : DEFAULT_SETTINGS.dateSystems.map(sys => Object.assign({}, sys)); } @@ -392,6 +407,7 @@ export default class WaypointPlugin extends Plugin { * inside a renamed folder. */ private onRename(file: TAbstractFile, oldPath: string): void { + this.invalidateDateSystemIndicators(); const indexChanged = this.syncIndexForRename(file, oldPath); let dataChanged = false; @@ -427,6 +443,7 @@ export default class WaypointPlugin extends Plugin { private onVaultCreate(file: TAbstractFile): void { if (file instanceof TFile && file.extension === 'md') { this.markdownBasenames.add(file.basename); + this.invalidateDateSystemIndicators(); } this.broadcastRedraw(); } @@ -434,6 +451,7 @@ export default class WaypointPlugin extends Plugin { private onVaultDelete(file: TAbstractFile): void { if (file instanceof TFile && file.extension === 'md') { this.removeFromMarkdownIndex(file.basename, file.path); + this.invalidateDateSystemIndicators(); } this.broadcastRedraw(); } @@ -447,6 +465,12 @@ export default class WaypointPlugin extends Plugin { } } + /** Forget a month result when markdown paths or date-system settings change. */ + private invalidateDateSystemIndicators(): void { + this.dateSystemIndicators = null; + this.dateSystemIndicatorKey = ''; + } + /** * Drop a basename from the index, unless another markdown file still * carries it. `path` is excluded from that check because the vault may not @@ -555,6 +579,7 @@ export default class WaypointPlugin extends Plugin { templateFile: periodSettings.templateFile, typeProperty: periodSettings.typeProperty, icon: 'calendar', + indicatorColor: this.settings.calendar.dailyIndicatorColor, }; } @@ -609,6 +634,75 @@ export default class WaypointPlugin extends Plugin { .map(bucket => bucket.result); } + /** + * Return one coloured indicator per system with a note on each requested day. + * + * The day grid calls this once per render. Its result is cached by the + * displayed dates and system settings, then invalidated by file changes, so + * a 42-cell calendar never repeats the vault scan per cell or per redraw. + */ + getDateSystemIndicators(dates: moment.Moment[]): Map { + const dateStrings = dates.map(date => date.format('YYYY-MM-DD')); + const systems = this.dateSystems() + .filter(system => formatHasDateToken(system.nameFormat)) + .map(system => { + const parts = splitNameFormat(system.nameFormat); + return { + system, + hasTitle: parts.hasTitle, + dates: dates.map((date, index) => ({ + dateStr: dateStrings[index], + before: formatDatePart(date, parts.before), + after: formatDatePart(date, parts.after), + })), + }; + }); + const key = JSON.stringify({ + dates: dateStrings, + systems: systems.map(({ system }) => [ + system.id, + system.name, + system.folder, + system.nameFormat, + system.indicatorColor, + ]), + }); + if (this.dateSystemIndicators && this.dateSystemIndicatorKey === key) { + return this.dateSystemIndicators; + } + + const matchingIds = new Map>(); + for (const dateStr of dateStrings) matchingIds.set(dateStr, new Set()); + + // The only vault traversal: filter a file by system folder first, then + // test it against the month's at-most-42 formatted day patterns. + for (const file of this.app.vault.getMarkdownFiles()) { + for (const entry of systems) { + if (!isInFolder(file.path, entry.system.folder)) continue; + for (const match of entry.dates) { + if (matchesSystemName(file.basename, match.before, match.after, entry.hasTitle)) { + matchingIds.get(match.dateStr)?.add(entry.system.id); + } + } + } + } + + const result = new Map(); + for (const dateStr of dateStrings) { + const ids = matchingIds.get(dateStr); + result.set(dateStr, systems + .filter(({ system }) => ids?.has(system.id)) + .map(({ system }) => ({ + id: system.id, + name: system.name, + color: system.indicatorColor, + }))); + } + this.dateSystemIndicatorKey = key; + this.dateSystemIndicators = result; + return result; + } + /** * Open (creating if needed) the note `system` holds for `date`. * diff --git a/src/settings-tab.ts b/src/settings-tab.ts index 967ed2a..fe545d6 100644 --- a/src/settings-tab.ts +++ b/src/settings-tab.ts @@ -96,6 +96,32 @@ export class WaypointSettingTab extends PluginSettingTab { this.saveAndRefresh(); }); }); + + new Setting(container) + .setName('Indicator style') + .setDesc('Show one neutral dot for any dated note, or one coloured dot for each configured date system.') + .addDropdown((dropdown) => { + dropdown + .addOption('any', 'Single dot') + .addOption('systems', 'Colour by note system') + .setValue(this.settings.calendar.indicatorMode) + .onChange((value: 'any' | 'systems') => { + this.settings.calendar.indicatorMode = value; + this.saveAndRefresh(); + }); + }); + + new Setting(container) + .setName('Daily indicator colour') + .setDesc('Colour for daily-note dots when using “Colour by note system”.') + .addColorPicker((color) => { + color + .setValue(this.settings.calendar.dailyIndicatorColor) + .onChange((value) => { + this.settings.calendar.dailyIndicatorColor = value; + this.saveAndRefresh(); + }); + }); } // ═══════════════════════════════ @@ -254,6 +280,18 @@ export class WaypointSettingTab extends PluginSettingTab { 'Icon', 'Lucide icon name for the menu item. Browse names at lucide.dev.', system, 'icon', 'book-open', ); + + new Setting(container) + .setName('Indicator colour') + .setDesc('Colour for this system’s dot when using “Colour by note system”.') + .addColorPicker((color) => { + color + .setValue(system.indicatorColor) + .onChange((value) => { + system.indicatorColor = value; + this.saveAndRefresh(); + }); + }); }); new Setting(container) diff --git a/src/settings.ts b/src/settings.ts index 97509d4..3ad2334 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -27,6 +27,8 @@ export interface DateSystemSettings { typeProperty: string; /** Lucide icon name for the menu item. */ icon: string; + /** CSS colour for this system's calendar indicator. */ + indicatorColor: string; } /** Field defaults for a newly added system, and the merge base for saved ones. */ @@ -37,11 +39,16 @@ export const DEFAULT_DATE_SYSTEM: Omit = { templateFile: '', typeProperty: '', icon: 'file', + indicatorColor: '#64748b', }; export interface CalendarSettings { firstDayOfWeek: number; // 0=Sunday, 1=Monday showNoteIndicators: boolean; + /** Single neutral dot, or a dot per day-scoped date system. */ + indicatorMode: 'any' | 'systems'; + /** Colour used by the synthesized daily system in `systems` mode. */ + dailyIndicatorColor: string; } export interface RecentFilesSettings { @@ -78,6 +85,8 @@ export const DEFAULT_SETTINGS: WaypointSettings = { calendar: { firstDayOfWeek: 1, // Monday showNoteIndicators: true, + indicatorMode: 'any', + dailyIndicatorColor: '#3b82f6', }, daily: { folder: 'periodic/daily', @@ -118,6 +127,7 @@ export const DEFAULT_SETTINGS: WaypointSettings = { templateFile: '', typeProperty: 'journal', icon: 'book-open', + indicatorColor: '#22c55e', }, { id: 'meetings', @@ -127,6 +137,7 @@ export const DEFAULT_SETTINGS: WaypointSettings = { templateFile: '', typeProperty: 'meeting', icon: 'users', + indicatorColor: '#a855f7', }, ], recentFiles: { diff --git a/src/views/waypoint-view.ts b/src/views/waypoint-view.ts index ead7de3..5f5c5f7 100644 --- a/src/views/waypoint-view.ts +++ b/src/views/waypoint-view.ts @@ -181,6 +181,14 @@ export class WaypointView extends ItemView { this.plugin.settings.calendar.firstDayOfWeek, ); + const systemIndicators = this.plugin.settings.calendar.showNoteIndicators + && this.plugin.settings.calendar.indicatorMode === 'systems' + ? this.plugin.getDateSystemIndicators(weeks.reduce( + (dates, week) => dates.concat(week.days.map(day => day.date)), + [], + )) + : null; + for (const week of weeks) { const row = tbody.createEl('tr'); @@ -211,8 +219,20 @@ export class WaypointView extends ItemView { if (this.plugin.settings.calendar.showNoteIndicators) { const dateStr = day.date.format('YYYY-MM-DD'); - if (this.plugin.hasNoteForDate(dateStr)) { - cell.addClass('has-note'); + if (this.plugin.settings.calendar.indicatorMode === 'any') { + if (this.plugin.hasNoteForDate(dateStr)) { + cell.addClass('has-note'); + } + } else { + const indicators = systemIndicators?.get(dateStr) || []; + if (indicators.length > 0) { + const dots = cell.createDiv({ cls: 'waypoint-day-indicators' }); + for (const indicator of indicators) { + const dot = dots.createSpan({ cls: 'waypoint-day-indicator' }); + dot.style.setProperty('--waypoint-indicator-color', indicator.color); + setTooltip(dot, indicator.name); + } + } } } diff --git a/styles.css b/styles.css index d77f856..668f074 100644 --- a/styles.css +++ b/styles.css @@ -58,29 +58,34 @@ .waypoint-calendar { font-size: var(--font-ui-small); + padding: 8px; + border: 1px solid var(--background-modifier-border); + border-radius: 10px; + background: var(--background-primary-alt); } .waypoint-calendar-top { display: flex; align-items: center; justify-content: space-between; - margin-bottom: 10px; + margin-bottom: 8px; } .waypoint-calendar-breadcrumb { display: flex; align-items: center; - gap: 6px; + gap: 4px; font-size: var(--font-ui-medium); font-weight: var(--font-semibold); - padding: 4px 0; + padding: 2px 0; } .waypoint-calendar-breadcrumb .waypoint-clickable { color: var(--text-muted); cursor: var(--cursor-link, pointer); - padding: 1px 4px; + padding: 2px 4px; border-radius: 4px; + transition: color 80ms, background-color 80ms; } .waypoint-calendar-breadcrumb .waypoint-clickable:hover { @@ -90,23 +95,25 @@ .waypoint-calendar .waypoint-separator { color: var(--text-faint); - margin: 0 2px; + margin: 0; } .waypoint-calendar-today-group { display: flex; align-items: center; - gap: 2px; + gap: 1px; } .waypoint-calendar-today-group button { background: none; border: none; cursor: var(--cursor-link, pointer); - padding: 2px 6px; + padding: 2px 5px; border-radius: 4px; color: var(--text-muted); font-size: var(--font-ui-small); + transition: color 80ms, background-color 80ms; + box-shadow: none; } .waypoint-calendar-today-group button:hover { @@ -121,30 +128,34 @@ .waypoint-calendar table { table-layout: fixed; width: 100%; - border-collapse: collapse; + border-collapse: separate; + border-spacing: 2px 3px; } .waypoint-calendar th, .waypoint-calendar td { text-align: center; - padding: 4px 2px; + padding: 0; font-size: var(--font-ui-small); - line-height: 1.6; } .waypoint-calendar th { + padding-bottom: 2px; font-weight: var(--font-medium); color: var(--text-faint); - font-size: calc(var(--font-ui-small) * 0.85); + font-size: calc(var(--font-ui-small) * 0.78); + letter-spacing: 0.04em; + text-transform: uppercase; } .waypoint-calendar .waypoint-weeknum { - font-size: calc(var(--font-ui-small) * 0.75); + width: 18px; + font-size: calc(var(--font-ui-small) * 0.72); color: var(--text-faint); font-weight: var(--font-light); cursor: var(--cursor-link, pointer); - padding: 2px 0; border-radius: 4px; + transition: color 80ms, background-color 80ms; } .waypoint-calendar .waypoint-weeknum:hover { @@ -154,42 +165,71 @@ .waypoint-calendar .waypoint-day { cursor: var(--cursor-link, pointer); - min-height: var(--wp-cal-cell-size, 32px); - padding: 2px 0; + height: var(--wp-cal-cell-size, 32px); + box-sizing: border-box; + padding: 2px 0 7px; border-radius: 6px; position: relative; width: 100%; vertical-align: middle; + transition: color 80ms, background-color 80ms, box-shadow 80ms; } .waypoint-calendar .waypoint-day:hover { - background-color: var(--background-modifier-active-hover); + background-color: var(--background-modifier-hover); } .waypoint-calendar .waypoint-day.other-month { - opacity: 0.35; + color: var(--text-faint); + opacity: 0.5; } .waypoint-calendar .waypoint-day.today { color: var(--text-accent); - border: 1px solid var(--text-accent); font-weight: var(--font-semibold); + box-shadow: inset 0 0 0 1px var(--text-accent); } +.waypoint-calendar .waypoint-day.today:hover { + background-color: var(--background-modifier-active-hover); +} + +/* Single-dot mode preserves the pre-date-systems indicator. */ .waypoint-calendar .waypoint-day.has-note::after { content: ''; - display: block; + position: absolute; + left: 50%; + bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background-color: var(--text-faint); - margin: 0 auto; + transform: translateX(-50%); } .waypoint-calendar .waypoint-day.today.has-note::after { background-color: var(--text-accent); } +/* Colour-by-system mode: one dot per matching system, in Settings order. */ +.waypoint-day-indicators { + position: absolute; + right: 0; + bottom: 3px; + left: 0; + display: flex; + justify-content: center; + gap: 3px; +} + +.waypoint-day-indicator { + width: 5px; + height: 5px; + border-radius: 50%; + background-color: var(--waypoint-indicator-color); + box-shadow: 0 0 0 1px var(--background-primary); +} + /* ── Recent Files ── */ .waypoint-recent-filter {