/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
*/
var q=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(g,m)=>{for(var e in m)q(g,e,{get:m[e],enumerable:!0})},ie=(g,m,e,i)=>{if(m&&typeof m=="object"||typeof m=="function")for(let s of J(m))!ee.call(g,s)&&s!==e&&q(g,s,{get:()=>m[s],enumerable:!(i=X(m,s))||i.enumerable});return g};var ne=g=>ie(q({},"__esModule",{value:!0}),g);var le={};te(le,{default:()=>O});module.exports=ne(le);var y=require("obsidian");var P={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"},recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[],filterTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var w=require("obsidian");var R=class extends w.PluginSettingTab{constructor(e,i,s,n){super(e,i);this.activeTab="calendar";this.plugin=i,this.settings=s,this.onSettingsChange=n}display(){let{containerEl:e}=this;e.empty();let i=e.createDiv({cls:"waypoint-settings-tabs"}),s=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let t of s)i.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===t.key?" is-active":""}`,text:t.label}).addEventListener("click",()=>{this.activeTab=t.key,this.display()});let n=e.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(n);break;case"periodic":this.renderPeriodicTab(n);break;case"recent":this.renderRecentTab(n);break;case"display":this.renderDisplayTab(n);break;case"about":this.renderAboutTab(n);break}}renderCalendarTab(e){new w.Setting(e).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(i=>{i.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(s=>{this.settings.calendar.firstDayOfWeek=parseInt(s,10),this.saveAndRefresh()})}),new w.Setting(e).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(i=>{i.setValue(this.settings.calendar.showNoteIndicators).onChange(s=>{this.settings.calendar.showNoteIndicators=s,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,i,s){new w.Setting(e).setHeading().setName(i),new w.Setting(e).setName("Folder").setDesc(`Folder path for ${i.toLowerCase()} notes.`).addText(n=>{n.setPlaceholder("periodic/daily"),n.setValue(s.folder),n.onChange(t=>{s.folder=t,this.saveAndRefresh()})}),new w.Setting(e).setName("Name format").setDesc(`Date format for ${i.toLowerCase()} note filenames (moment.js format).`).addText(n=>{n.setPlaceholder("yyyy-MM-dd"),n.setValue(s.nameFormat),n.onChange(t=>{s.nameFormat=t,this.saveAndRefresh()})}),new w.Setting(e).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(n=>{n.setPlaceholder("Templates/Daily note"),n.setValue(s.templateFile),n.onChange(t=>{s.templateFile=t,this.saveAndRefresh()})}),new w.Setting(e).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(n=>{n.setPlaceholder("daily-note"),n.setValue(s.typeProperty),n.onChange(t=>{s.typeProperty=t,this.saveAndRefresh()})})}renderRecentTab(e){new w.Setting(e).setName("Max items").setDesc("Maximum number of recent files to track.").addText(t=>{t.inputEl.setAttr("type","number"),t.inputEl.setAttr("placeholder","50"),t.setValue(String(this.settings.recentFiles.maxItems)),t.inputEl.onblur=()=>{let a=parseInt(t.getValue(),10);!isNaN(a)&&a>0&&(this.settings.recentFiles.maxItems=a,this.saveAndRefresh())}}),new w.Setting(e).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(t=>{t.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(a=>{this.settings.recentFiles.updateOn=a,this.saveAndRefresh()})});let i=new DocumentFragment;i.appendText("Regex patterns for paths to exclude. One per line."),new w.Setting(e).setName("Omitted paths").setDesc(i).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`^archives/
\\.png$`),t.setValue(this.settings.recentFiles.omittedPaths.join(`
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=t.getValue().split(`
`).filter(a=>a.trim()),this.saveAndRefresh()}});let s=new DocumentFragment;s.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new w.Setting(e).setName("Omitted tags").setDesc(s).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`ignore
archive`),t.setValue(this.settings.recentFiles.omittedTags.join(`
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=t.getValue().split(`
`).filter(a=>a.trim()),this.saveAndRefresh()}});let n=new DocumentFragment;n.appendText("Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property."),new w.Setting(e).setName("Filter tags").setDesc(n).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`meeting
person
project`),t.setValue(this.settings.recentFiles.filterTags.join(`
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=t.getValue().split(`
`).filter(a=>a.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new w.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 w.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new w.Setting(e).addButton(i=>i.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...P.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,i,s,n,t,a,o,r,c){let l=new w.Setting(e).setName(i).setDesc(`${s} (${n[t]}${c})`);l.addSlider(h=>{h.setLimits(a,o,r).setValue(n[t]).setDynamicTooltip().onChange(p=>{n[t]=p,l.setDesc(`${s} (${p}${c})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let i=this.plugin.manifest.version,s=e.createDiv();s.style.display="flex",s.style.alignItems="center",s.style.gap="12px",s.style.marginBottom="16px";let n=s.createDiv();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.width="48px",n.style.height="48px",n.style.borderRadius="12px",n.style.background="var(--interactive-accent)",n.style.color="var(--text-on-accent)",n.style.fontSize="24px",(0,w.setIcon)(n,"compass");let t=s.createDiv(),a=t.createEl("h2",{text:"Waypoint Sidebar"});a.style.margin="0",a.style.lineHeight="1.2";let o=t.createDiv({text:`v${i}`});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 d=require("obsidian");var I=require("obsidian");function Q(g,m,e){let i=(0,I.moment)({year:g,month:m,day:1}),s=(0,I.moment)(i).endOf("month"),n=(0,I.moment)(i).subtract((i.day()-e+7)%7,"days"),t=(0,I.moment)().startOf("day"),a=[],o=(0,I.moment)(n);for(;o.isBefore(s)||o.month()===m;){let r=[];for(let c=0;c<7;c++)r.push({date:(0,I.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(t,"day"),isCurrentMonth:o.month()===m,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(a.push({weekNumber:r[0].isoWeekNumber,days:r}),a.length>=6)break}return a}var T="waypoint-view";function ae(g){return g.dragManager}var L=class extends d.ItemView{constructor(e,i){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,d.moment)().month();this.currentDisplayYear=(0,d.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.plugin=i}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 i=e.createDiv({cls:"waypoint-calendar"}),s=(0,d.moment)(),n=(0,d.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),t=i.createDiv({cls:"waypoint-calendar-top"}),a=t.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=n.format("[Q]Q"),r=a.createSpan({cls:"waypoint-clickable",text:o});r.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",n)}),r.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("quarter",n,this.app.workspace.getLeaf("tab")))});let c=n.format("MMMM"),l=a.createSpan({cls:"waypoint-clickable",text:c});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",n)}),l.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("month",n,this.app.workspace.getLeaf("tab")))});let h=n.format("YYYY"),p=a.createSpan({cls:"waypoint-clickable",text:h});p.addEventListener("click",()=>{this.plugin.openPeriodNote("year",n)}),p.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("year",n,this.app.workspace.getLeaf("tab")))});let u=t.createDiv({cls:"waypoint-calendar-today-group"}),D=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,d.setIcon)(D,"chevron-left"),D.addEventListener("click",()=>this.navigateMonth(-1)),u.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,d.moment)().month(),this.currentDisplayYear=(0,d.moment)().year(),this.redraw()});let k=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,d.setIcon)(k,"chevron-right"),k.addEventListener("click",()=>this.navigateMonth(1));let b=i.createEl("table"),f=b.createEl("thead").createEl("tr");f.createEl("th",{text:""});let C=["sun","mon","tue","wed","thu","fri","sat"],$=this.plugin.settings.calendar.firstDayOfWeek;for(let F=0;F<7;F++){let A=($+F)%7;f.createEl("th",{text:C[A]})}let S=b.createEl("tbody"),U=Q(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let F of U){let A=S.createEl("tr"),z=A.createEl("td",{cls:"waypoint-weeknum"});z.setText(String(F.weekNumber));let K=F.days[0].date;z.addEventListener("click",()=>{this.plugin.openPeriodNote("week",K)}),z.addEventListener("mousedown",E=>{E.button===1&&(E.preventDefault(),this.plugin.openPeriodNote("week",K,this.app.workspace.getLeaf("tab")))});for(let E of F.days){let M=A.createEl("td",{cls:"waypoint-day"});if(M.setText(String(E.dayOfMonth)),E.isCurrentMonth||M.addClass("other-month"),E.isToday&&M.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let N=E.date.format("YYYY-MM-DD");this.plugin.hasNoteForDate(N)&&M.addClass("has-note")}M.addEventListener("click",()=>{this.plugin.openPeriodNote("day",E.date)}),M.addEventListener("mousedown",N=>{N.button===1&&(N.preventDefault(),this.plugin.openPeriodNote("day",E.date,this.app.workspace.getLeaf("tab")))})}}}navigateMonth(e){let i=(0,d.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(e,"month");this.currentDisplayMonth=i.month(),this.currentDisplayYear=i.year(),this.redraw()}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 i=this.plugin.settings.recentFiles.filterTags||[],s={};if(i.length>0){for(let l of i)s[l]=0;for(let l of this.plugin.recentFiles){let h=this.app.vault.getAbstractFileByPath(l.path);if(h instanceof d.TFile){let p=this.app.metadataCache.getFileCache(h),u=(r=p==null?void 0:p.frontmatter)==null?void 0:r.type;u&&typeof u=="string"&&s.hasOwnProperty(u)&&s[u]++}}}else for(let l of this.plugin.recentFiles){let h=this.app.vault.getAbstractFileByPath(l.path);if(h instanceof d.TFile){let p=this.app.metadataCache.getFileCache(h),u=(c=p==null?void 0:p.frontmatter)==null?void 0:c.type;u&&typeof u=="string"&&(s[u]=(s[u]||0)+1)}}if(Object.keys(s).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 p=i.length>0?Object.entries(s):Object.entries(s).sort((u,D)=>D[1]-u[1]);for(let[u,D]of p){let x=l.createSpan({cls:`waypoint-recent-pill${this.recentFilesFilter===u?" is-active":""}`});x.setText(`${u} ${D}`),x.addEventListener("click",()=>{this.recentFilesFilter=this.recentFilesFilter===u?null:u,this.redraw()})}}let n=this.plugin.recentFiles;this.recentFilesFilter&&(n=this.plugin.recentFiles.filter(l=>{var p;let h=this.app.vault.getAbstractFileByPath(l.path);if(h instanceof d.TFile){let u=this.app.metadataCache.getFileCache(h);return((p=u==null?void 0:u.frontmatter)==null?void 0:p.type)===this.recentFilesFilter}return!1}));let t=this.app.workspace.getActiveFile(),a=e.createDiv({cls:"nav-folder mod-root"}),o=a.createDiv({cls:"nav-folder-children"});for(let l of n){let h=o.createDiv({cls:"tree-item nav-file"}),p=h.createDiv({cls:"tree-item-self is-clickable nav-file-title"});p.createDiv({cls:"tree-item-inner nav-file-title-content"}).setText(l.basename);let D=p.createDiv({cls:"tree-item-spacer"}),x=p.createDiv({cls:"waypoint-recent-remove"});(0,d.setIcon)(x,"x"),x.addEventListener("click",k=>{k.stopPropagation(),this.plugin.recentFiles=this.plugin.recentFiles.filter(b=>b.path!==l.path),this.plugin.persistRecentFiles(),this.redraw()}),(0,d.setTooltip)(h,l.path),t&&l.path===t.path&&p.addClass("is-active"),p.setAttr("draggable","true"),p.addEventListener("dragstart",k=>{let b=this.app.metadataCache.getFirstLinkpathDest(l.path,"");if(b){let v=ae(this.app),f=v.dragFile(k,b);v.onDragStart(k,f)}}),p.addEventListener("mouseover",k=>{this.app.workspace.trigger("hover-link",{event:k,source:T,hoverParent:a,targetEl:h,linktext:l.path})}),p.addEventListener("contextmenu",k=>{let b=new d.Menu;b.addItem(f=>f.setSection("action").setTitle("Open in new tab").setIcon("file-plus").onClick(()=>this.focusFile(l,"tab"))),b.addItem(f=>f.setSection("action").setTitle("Add to bookmarks").setIcon("bookmark").onClick(()=>{this.plugin.addBookmark(l.path,l.basename,"file"),new d.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:k.clientX,y:k.clientY})}),p.addEventListener("click",k=>{let b=d.Keymap.isModEvent(k);this.focusFile(l,b)}),p.addEventListener("mousedown",k=>{k.button===1&&(k.preventDefault(),this.focusFile(l,"tab"))})}}focusFile(e,i){let s=this.app.vault.getFiles().find(n=>n.path===e.path);s?this.app.workspace.getLeaf(i).openFile(s):(new d.Notice("Cannot find file"),this.plugin.recentFiles=this.plugin.recentFiles.filter(n=>n.path!==e.path),this.plugin.persistRecentFiles(),this.redraw())}renderFavorites(){let e=this.contentEl.createDiv({cls:"waypoint-section waypoint-favorites"}),i=e.createDiv({cls:"waypoint-section-header"});i.setText("Waypoint Bookmarks");let s=i.createEl("button",{cls:"waypoint-header-more"});if((0,d.setIcon)(s,"more-horizontal"),(0,d.setTooltip)(s,"Add bookmark"),s.addEventListener("click",n=>{let t=new d.Menu;t.addItem(a=>{a.setTitle("Add current file").setIcon("file-plus").onClick(()=>{let o=this.app.workspace.getActiveFile();o&&this.plugin.addBookmark(o.path,o.basename,"file")})}),t.addItem(a=>{a.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()})}),t.addItem(a=>{a.setTitle("New group").setIcon("folder-plus").onClick(()=>{this.plugin.addBookmark("","New Group","group","")})}),t.addSeparator(),t.addItem(a=>{a.setTitle("Add separator").setIcon("minus").onClick(()=>{this.plugin.addBookmark("","","separator")})}),t.addItem(a=>{a.setTitle("Add spacer").setIcon("space").onClick(()=>{this.plugin.addBookmark("","","spacer")})}),t.showAtPosition({x:n.clientX,y:n.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,i,s){for(let n=0;n{c.stopPropagation(),c.preventDefault(),this.showBookmarkContextMenu(c,t)});continue}if(t.type==="spacer"){let r=e.createDiv({cls:"waypoint-bookmark-item waypoint-bookmark-spacer"});r.setAttr("draggable","true"),r.setAttr("data-bm-id",t.id),r.style.paddingLeft=`${8+s*16}px`,r.style.cursor="grab",this.attachBookmarkDragHandlers(r,e,t,!1),r.addEventListener("contextmenu",c=>{c.stopPropagation(),c.preventDefault(),this.showBookmarkContextMenu(c,t)});continue}let a=t.type==="group",o=e.createDiv({cls:`waypoint-bookmark-item${a?" waypoint-bookmark-group":""}${t.collapsed?" collapsed":""}`});if(o.setAttr("draggable","true"),o.setAttr("data-bm-id",t.id),a||(o.style.paddingLeft=`${8+s*16}px`),this.attachBookmarkDragHandlers(o,e,t,!0),a){let r=o.createDiv({cls:"waypoint-bm-icon"});t.icon&&(0,d.setIcon)(r,t.icon);let c=o.createDiv({cls:"waypoint-bm-label",text:t.label}),l=o.createDiv({cls:"waypoint-bm-chevron"});(0,d.setIcon)(l,"chevron-down"),l.addEventListener("click",p=>{p.stopPropagation(),this.plugin.updateBookmark(t.id,{collapsed:!t.collapsed})}),o.addEventListener("click",p=>{if(t.filePath){let u=this.app.vault.getFileByPath(t.filePath);if(u){let D=d.Keymap.isModEvent(p);this.app.workspace.getLeaf(D).openFile(u);return}}this.plugin.updateBookmark(t.id,{collapsed:!t.collapsed})}),o.addEventListener("mousedown",p=>{if(p.button===1&&t.filePath){p.preventDefault();let u=this.app.vault.getFileByPath(t.filePath);u&&this.app.workspace.getLeaf("tab").openFile(u)}});let h=e.createDiv({cls:`waypoint-bookmark-children${t.collapsed?" collapsed":""}`});t.children&&t.children.length>0&&this.renderBookmarkList(h,t.children,s+1)}else{let r=o.createDiv({cls:"waypoint-bm-icon"});t.icon&&(0,d.setIcon)(r,t.icon);let c=o.createDiv({cls:"waypoint-bm-label",text:t.label});if(t.children&&t.children.length>0){let l=o.createDiv({cls:"waypoint-bm-chevron"});(0,d.setIcon)(l,"chevron-down"),l.addEventListener("click",h=>{h.stopPropagation(),this.plugin.updateBookmark(t.id,{collapsed:!t.collapsed})}),t.collapsed&&(o.addClass("collapsed"),l.style.transform="rotate(-90deg)")}if((0,d.setTooltip)(o,t.filePath),o.addEventListener("click",l=>{if(t.filePath){let h=this.app.vault.getFileByPath(t.filePath);if(h){let p=d.Keymap.isModEvent(l);this.app.workspace.getLeaf(p).openFile(h)}else new d.Notice("File not found"),this.plugin.removeBookmark(t.id)}}),o.addEventListener("mousedown",l=>{if(l.button===1&&t.filePath){l.preventDefault();let h=this.app.vault.getFileByPath(t.filePath);h&&this.app.workspace.getLeaf("tab").openFile(h)}}),t.children&&t.children.length>0){let l=e.createDiv({cls:`waypoint-bookmark-children${t.collapsed?" collapsed":""}`});this.renderBookmarkList(l,t.children,s+1)}}o.addEventListener("contextmenu",r=>{r.stopPropagation(),r.preventDefault(),this.showBookmarkContextMenu(r,t)})}}showBookmarkContextMenu(e,i){let s=new d.Menu;if(i.type==="separator"||i.type==="spacer"){s.addItem(n=>n.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(i.id))),s.showAtPosition({x:e.clientX,y:e.clientY});return}i.type==="file"?(s.addItem(n=>n.setTitle("Open in new tab").setIcon("file-plus").onClick(()=>{let t=this.app.vault.getFileByPath(i.filePath);t&&this.app.workspace.getLeaf("tab").openFile(t)})),s.addSeparator(),s.addItem(n=>n.setTitle("Rename").setIcon("pencil").onClick(()=>this.promptRename(i))),s.addItem(n=>n.setTitle("Change icon").setIcon("image").onClick(()=>this.promptIcon(i))),s.addSeparator(),s.addItem(n=>n.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(i.id)))):i.type==="group"&&(i.filePath&&(s.addItem(n=>n.setTitle("Open in new tab").setIcon("file-plus").onClick(()=>{let t=this.app.vault.getFileByPath(i.filePath);t&&this.app.workspace.getLeaf("tab").openFile(t)})),s.addSeparator()),s.addItem(n=>n.setTitle("Rename").setIcon("pencil").onClick(()=>this.promptRename(i))),s.addItem(n=>n.setTitle("Change icon").setIcon("image").onClick(()=>this.promptIcon(i))),s.addSeparator(),s.addItem(n=>n.setTitle("Add child bookmark").setIcon("file-plus").onClick(()=>{let t=this.app.workspace.getActiveFile();if(!t){new d.Notice("No active file");return}let a={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"file",label:t.basename,filePath:t.path,icon:"",children:[],collapsed:!1,indent:i.indent+1};i.children.push(a),this.plugin.saveWaypointData(),this.redraw()})),s.addItem(n=>n.setTitle("Add child note").setIcon("folder-plus").onClick(()=>{let t=this.app.workspace.getActiveFile();if(!t){new d.Notice("No active file");return}let a={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"group",label:t.basename,filePath:t.path,icon:"",children:[],collapsed:!1,indent:i.indent+1};i.children.push(a),this.plugin.saveWaypointData(),this.redraw()})),s.addItem(n=>n.setTitle("New sub-group").setIcon("folder-plus").onClick(()=>{let t={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"group",label:"New Group",filePath:"",icon:"",children:[],collapsed:!1,indent:i.indent+1};i.children.push(t),this.plugin.saveWaypointData(),this.redraw()})),s.addSeparator(),s.addItem(n=>n.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(i.id)))),s.showAtPosition({x:e.clientX,y:e.clientY})}attachBookmarkDragHandlers(e,i,s,n){let t=()=>{e.removeClass("waypoint-bm-drop-line"),e.removeClass("waypoint-bm-drop-below"),e.removeClass("waypoint-bm-drop-into")};e.addEventListener("dragstart",a=>{this.dragId=s.id,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",s.id),e.addClass("waypoint-bm-dragging")}),e.addEventListener("dragend",()=>{this.dragId=null,i.querySelectorAll(".waypoint-bm-dragging, .waypoint-bm-drop-line, .waypoint-bm-drop-below, .waypoint-bm-drop-into").forEach(a=>{a.removeClass("waypoint-bm-dragging"),a.removeClass("waypoint-bm-drop-line"),a.removeClass("waypoint-bm-drop-below"),a.removeClass("waypoint-bm-drop-into")})}),e.addEventListener("dragenter",a=>{a.preventDefault(),!(!this.dragId||this.dragId===s.id)&&this.showDropIndicator(e,a,n)}),e.addEventListener("dragover",a=>{a.preventDefault(),!(!this.dragId||this.dragId===s.id)&&this.showDropIndicator(e,a,n)}),e.addEventListener("dragleave",t),e.addEventListener("drop",a=>{var c,l;a.preventDefault(),this.dragId=null,t();let o=(c=a.dataTransfer)==null?void 0:c.getData("text/plain");if(!o||o===s.id)return;let r=this.dropZones.get(e);n&&(r!=null&&r.into)?s.type==="group"?this.moveBookmarkToGroup(o,s.id):this.createParentNoteAndMove(o,s.id):this.moveBookmarkToPosition(o,s.id,(l=r==null?void 0:r.above)!=null?l:!1)})}showDropIndicator(e,i,s){let n=e.parentElement;n&&n.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 t=e.getBoundingClientRect(),a=i.clientY;if(s){let o=t.top+t.height*.25,r=t.top+t.height*.75;ar?(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=a{let a=t.findIndex(o=>o.id===e);if(a>=0){let[o]=t.splice(a,1);return o}for(let o of t){let r=s(o.children);if(r)return r}return null},n=s(this.plugin.waypointData.bookmarks);if(n){if(i){let t=(a,o)=>a.id===o?!0:a.children.some(r=>t(r,o));if(n.id===i||t(n,i))return}if(i){let t=o=>{for(let r of o){if(r.id===i)return r;let c=t(r.children);if(c)return c}return null},a=t(this.plugin.waypointData.bookmarks);a&&(n.indent=a.indent+1,a.children.push(n))}else n.indent=0,this.plugin.waypointData.bookmarks.push(n);this.plugin.saveWaypointData(),this.redraw()}}createParentNoteAndMove(e,i){let s=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=s(c.children);if(l)return l}return null},n=s(this.plugin.waypointData.bookmarks);if(!n)return;let t=o=>{for(let r of o){if(r.id===i)return r;if(r.children){let c=t(r.children);if(c)return c}}return null},a=t(this.plugin.waypointData.bookmarks);a&&(n.indent=a.indent+1,a.children.push(n),this.plugin.saveWaypointData(),this.redraw())}moveBookmarkToPosition(e,i,s){let n=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=n(l.children);if(h.item)return h}return{item:null,parent:[]}},{item:t}=n(this.plugin.waypointData.bookmarks);if(!t)return;let a=r=>{let c=r.findIndex(l=>l.id===i);if(c>=0)return{parent:r,idx:c};for(let l of r)if(l.children){let h=a(l.children);if(h)return h}return null},o=a(this.plugin.waypointData.bookmarks);if(!o)t.indent=0,this.plugin.waypointData.bookmarks.push(t);else{let r=s?o.idx:o.idx+1;o.parent.splice(r,0,t)}this.plugin.saveWaypointData(),this.redraw()}promptRename(e){new V(this.app,e.label,i=>{i&&i.trim()&&this.plugin.updateBookmark(e.id,{label:i.trim()})}).open()}promptIcon(e){new G(this.app,e.icon,i=>{this.plugin.updateBookmark(e.id,{icon:i})}).open()}},V=class extends d.Modal{constructor(m,e,i){super(m),this.currentValue=e,this.onSubmit=i}onOpen(){this.titleEl.setText("Rename bookmark");let m=this.contentEl.createEl("input",{type:"text",value:this.currentValue});m.style.width="100%",m.style.marginBottom="12px",m.focus(),m.select();let e=this.contentEl.createDiv({cls:"modal-button-container"}),i=e.createEl("button",{text:"Cancel",cls:"mod-cta"});i.style.marginRight="8px",i.addEventListener("click",()=>this.close()),e.createEl("button",{text:"Save",cls:"mod-cta"}).addEventListener("click",()=>{this.onSubmit(m.value),this.close()}),m.addEventListener("keydown",n=>{n.key==="Enter"&&(this.onSubmit(m.value),this.close())})}onClose(){this.contentEl.empty()}},W=null;function se(){return W||(W=(async()=>{try{return await(await fetch("https://cdn.jsdelivr.net/npm/lucide-static@0.517.0/tags.json")).json()}catch(g){try{return await(await fetch("https://lucide.dev/api/tags")).json()}catch(m){return W=null,oe}}})()),W}var G=class extends d.Modal{constructor(e,i,s){super(e);this.allIcons=[];this.tagsMap={};this.loaded=!1;this.selected=i,this.onSubmit=s}async onOpen(){let e=this.contentEl;e.style.display="flex",e.style.flexDirection="column",e.style.gap="10px",this.titleEl.setText("Change icon");let i=e.createDiv({cls:"waypoint-icon-preview"});i.style.display="flex",i.style.alignItems="center",i.style.gap="10px",i.style.padding="12px 16px",i.style.borderRadius="8px",i.style.background="var(--background-secondary)",i.style.minHeight="48px";let s=i.createSpan();s.style.display="flex",this.selected&&(0,d.setIcon)(s,this.selected);let n=i.createSpan();n.style.fontWeight="var(--font-medium)",n.style.fontSize="var(--font-ui-medium)",n.setText(this.selected||"No icon");let t=e.createEl("input",{type:"text",placeholder:"Type to search (e.g. arrow, chart, home)..."});Object.assign(t.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)"}),t.focus();let a=e.createDiv({cls:"waypoint-icon-grid"});a.style.display="grid",a.style.gridTemplateColumns="repeat(auto-fill, minmax(52px, 1fr))",a.style.gap="4px",a.style.maxHeight="320px",a.style.overflowY="auto",a.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(t.value)});let c,l=x=>{if(a.empty(),!this.loaded){a.createDiv({text:"Loading\u2026"});return}let k=x.toLowerCase().trim(),b=k?this.allIcons.filter(v=>{if(v.includes(k))return!0;let f=this.tagsMap[v];return f?f.some(C=>C.includes(k)):!1}).slice(0,80):this.allIcons.slice(0,80);if(b.length===0){let v=a.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 f=a.createDiv();f.setAttr("data-icon",v),f.style.display="flex",f.style.alignItems="center",f.style.justifyContent="center",f.style.aspectRatio="1",f.style.borderRadius="6px",f.style.cursor="var(--cursor-link, pointer)",f.style.transition="background 80ms",f.setAttr("title",v),v===this.selected?(f.style.background="var(--interactive-accent)",f.style.color="var(--text-on-accent)"):f.style.color="var(--text-muted)";let C=f.createSpan();C.style.display="flex",(0,d.setIcon)(C,v),f.addEventListener("mouseenter",()=>{v!==this.selected&&(f.style.background="var(--background-modifier-hover)")}),f.addEventListener("mouseleave",()=>{v!==this.selected&&(f.style.background="")}),f.addEventListener("click",()=>{this.selected=v,l(x),s.empty(),(0,d.setIcon)(s,v),n.setText(v),a.querySelectorAll("div[data-icon]").forEach($=>{let S=$;S.getAttr("data-icon")===v?(S.style.background="var(--interactive-accent)",S.style.color="var(--text-on-accent)"):(S.style.background="",S.style.color="var(--text-muted)")})})}r.setText(b.length+" of "+this.allIcons.length+" icons")};t.addEventListener("input",()=>{window.clearTimeout(c),c=window.setTimeout(()=>l(t.value),60)}),t.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 D=h.createEl("button",{text:"Save",cls:"mod-cta"});D.style.marginLeft="8px",D.addEventListener("click",()=>{this.onSubmit(this.selected),this.close()})}onClose(){this.contentEl.empty()}async loadIcons(){let e=await se();this.tagsMap=e,this.allIcons=Object.keys(e).sort()}},oe={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 H(g,m,e){return!g||!m?null:g===m?e:g.startsWith(m+"/")?e+g.slice(m.length):null}var O=class extends y.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,a=>new L(a,this)),this.addSettingTab(new R(this.app,this,this.settings,()=>{this.enforceRecentFilesLimit(),this.redrawAll()})),this.addCommand({id:"waypoint-open-view",name:"Open Waypoint sidebar",callback:async()=>{let a=this.app.workspace.getLeavesOfType(T);if(a.length>0)await this.app.workspace.revealLeaf(a[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 a=this.app.workspace.getActiveFile();if(!a){new y.Notice("No active file");return}this.addBookmark(a.path,a.basename,"file"),new y.Notice(`Bookmarked: ${a.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,y.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,y.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,y.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,y.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,y.moment)())}});let i=["next","prev"],s=["daily","weekly","monthly","quarterly","yearly"],n={next:"Next",prev:"Previous"};for(let a of s)for(let o of i){let r=`waypoint-go-to-${o}-${a}`,c=`${n[o]} ${a} note`;this.addCommand({id:r,name:c,callback:async()=>{await this.navigatePeriodNote(o)}})}this.registerEvent(this.app.workspace.on("file-open",a=>{a&&this.onFileOpen(a)})),this.registerEvent(this.app.vault.on("create",a=>this.onVaultCreate(a))),this.registerEvent(this.app.vault.on("delete",a=>this.onVaultDelete(a))),this.registerEvent(this.app.vault.on("rename",(a,o)=>this.onRename(a,o))),this.registerEvent(this.app.vault.on("modify",a=>this.onFileModify(a))),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 t=new Date().toDateString();this.registerInterval(window.setInterval(()=>{let a=new Date().toDateString();a!==t&&(t=a,this.redrawAll())},6e5))}async onunload(){this.app.workspace.detachLeavesOfType(T)}applySettings(e){let i=(e==null?void 0:e.settings)||{};this.settings=Object.assign({},P,i),this.settings.recentFiles=Object.assign({},P.recentFiles,i.recentFiles||{}),this.settings.calendar=Object.assign({},P.calendar,i.calendar||{}),this.settings.display=Object.assign({},P.display,i.display||{});for(let s of re)this.settings[s]=Object.assign({},P[s],i[s]||{})}applyWaypointData(e){let i=(e==null?void 0:e.waypointData)||{};this.waypointData={bookmarks:Array.isArray(i.bookmarks)?i.bookmarks:[],recentFiles:Array.isArray(i.recentFiles)?i.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 y.TFile&&(this.recentFiles.length>0&&this.recentFiles[0].path===e.path||this.addToRecentFiles(e))}addToRecentFiles(e){this.isOmittedFromRecentFiles(e)||(this.recentFiles=this.recentFiles.filter(i=>i.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 a of this.settings.recentFiles.omittedPaths)try{if(new RegExp(a).test(e.path))return!0}catch(o){}let i=this.settings.recentFiles.omittedTags;if(i.length===0)return!1;let s=this.app.metadataCache.getFileCache(e),n=(s?(0,y.getAllTags)(s):null)||[];if(n.length===0)return!1;let t=n.map(a=>a.replace(/^#/,""));for(let a of i)try{let o=new RegExp(a);if(t.some(r=>o.test(r)))return!0}catch(o){}return!1}onRename(e,i){let s=this.syncIndexForRename(e,i),n=!1;for(let a of this.recentFiles){let o=H(a.path,i,e.path);o!==null&&(a.path=o,a.basename=Z(o),n=!0)}let t=a=>{for(let o of a){if(o.filePath){let r=H(o.filePath,i,e.path);r!==null&&(o.filePath=r,n=!0)}o.children&&t(o.children)}};t(this.waypointData.bookmarks),n&&(this.waypointData.recentFiles=this.recentFiles,this.persistAll()),(n||s)&&this.broadcastRedraw()}onVaultCreate(e){e instanceof y.TFile&&e.extension==="md"&&this.markdownBasenames.add(e.basename),this.broadcastRedraw()}onVaultDelete(e){e instanceof y.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,i){return!this.markdownBasenames.has(e)||this.app.vault.getMarkdownFiles().some(n=>n.basename===e&&n.path!==i)?!1:(this.markdownBasenames.delete(e),!0)}syncIndexForRename(e,i){if(!(e instanceof y.TFile))return!1;let s=!1,n=Z(i);return i.toLowerCase().endsWith(".md")&&(n!==e.basename||e.extension!=="md")&&(s=this.removeFromMarkdownIndex(n,i)),e.extension==="md"&&!this.markdownBasenames.has(e.basename)&&(this.markdownBasenames.add(e.basename),s=!0),s}hasNoteForDate(e){return this.markdownBasenames.has(e)}addBookmark(e,i,s="file",n=""){let a={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:s,label:i,filePath:s==="file"?e:"",icon:n,children:[],collapsed:!1,indent:0};return this.waypointData.bookmarks.push(a),this.saveWaypointData(),this.broadcastRedraw(),a}removeBookmark(e){let i=s=>{let n=s.findIndex(t=>t.id===e);if(n>=0)return s.splice(n,1),!0;for(let t of s)if(t.children&&i(t.children))return!0;return!1};i(this.waypointData.bookmarks),this.saveWaypointData(),this.broadcastRedraw()}updateBookmark(e,i){let s=t=>{for(let a of t){if(a.id===e)return a;if(a.children){let o=s(a.children);if(o)return o}}return null},n=s(this.waypointData.bookmarks);n&&(Object.assign(n,i),this.saveWaypointData(),this.broadcastRedraw())}async openPeriodNote(e,i,s){let n=Y[e],t=this.settings[n.key],a=i.format(t.nameFormat)+".md",o=t.folder?`${t.folder}/${a}`:a,r=this.app.vault.getFileByPath(o);if(!r&&(r=await this.createPeriodNote(o,t,i,n.label),!r))return;await(s||this.app.workspace.getLeaf(!1)).openFile(r)}async createPeriodNote(e,i,s,n){let t=n.toLowerCase(),a=e.lastIndexOf("/"),o=a<0?"":e.slice(0,a);try{await this.ensureFolderExists(o)}catch(p){return new y.Notice(`Waypoint: could not create the folder "${o}" for the ${t} note.
${j(p)}
Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,B),null}let r=i.templateFile,c=this.resolveTemplateFile(r),l;if(c)try{l=await this.app.vault.read(c)}catch(p){return new y.Notice(`Waypoint: could not read the template "${c.path}" for the ${t} note.
`+j(p),B),null}else l=`---
type: ${i.typeProperty}
date: ${s.format("YYYY-MM-DD")}
---
`;let h;try{h=await this.app.vault.create(e,l)}catch(p){return new y.Notice(`Waypoint: could not create the ${t} note at "${e}".
${j(p)}`,B),null}return r&&!c?new y.Notice(`Created ${t} note: ${h.basename}
Template "${r}" was not found, so a basic note was created instead.`,B):new y.Notice(`Created ${t} note: ${h.basename}`),h}async ensureFolderExists(e){if(!e||this.app.vault.getAbstractFileByPath(e)instanceof y.TFolder)return;let i="";for(let s of e.split("/"))if(s&&(i=i?`${i}/${s}`:s,!(this.app.vault.getAbstractFileByPath(i)instanceof y.TFolder)))try{await this.app.vault.createFolder(i)}catch(n){if(!(this.app.vault.getAbstractFileByPath(i)instanceof y.TFolder))throw n}}resolveTemplateFile(e){if(!e)return null;let i=e.toLowerCase().endsWith(".md")?e:`${e}.md`;return this.app.vault.getFileByPath(i)}detectPeriodType(e){for(let i of _){let s=this.settings[Y[i].key].nameFormat;if(!s)continue;let n=(0,y.moment)(e,s,!0);if(n.isValid())return{period:i,date:n}}return null}async navigatePeriodNote(e){let i=this.app.workspace.getActiveFile();if(!i){new y.Notice("No active file");return}let s=this.detectPeriodType(i.basename);if(!s){let r=_.map(c=>`${Y[c].label.toLowerCase()} "${this.settings[Y[c].key].nameFormat}"`).join(", ");new y.Notice(`Waypoint: "${i.basename}" does not match any configured periodic note format.
Expected one of: ${r}.`,B);return}let{period:n,date:t}=s,a=e==="next"?1:-1,o=n==="quarter"?t.clone().add(a*3,"months"):t.clone().add(a,`${n}s`);await this.openPeriodNote(n,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let e=this.app.workspace.getLeavesOfType(T);for(let i of e)i.view instanceof L&&i.view.redraw()}},re=["daily","weekly","monthly","quarterly","yearly"],Y={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"}},_=["day","week","month","quarter","year"];function Z(g){return g.slice(g.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}var B=1e4;function j(g){return g instanceof Error?g.message:String(g)}