/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ var W=Object.create;var y=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var D=(C,t)=>()=>(t||C((t={exports:{}}).exports,t),t.exports),X=(C,t)=>{for(var e in t)y(C,e,{get:t[e],enumerable:!0})},Z=(C,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of G(t))!K.call(C,n)&&n!==e&&y(C,n,{get:()=>t[n],enumerable:!(a=$(t,n))||a.enumerable});return C};var Y=(C,t,e)=>(e=C!=null?W(J(C)):{},Z(t||!C||!C.__esModule?y(e,"default",{value:C,enumerable:!0}):e,C)),Q=C=>Z(y({},"__esModule",{value:!0}),C);var I=D(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0})});var S=D(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0})});var H=D(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0})});var V=D(p=>{"use strict";var e1=p&&p.__createBinding||(Object.create?function(C,t,e,a){a===void 0&&(a=e);var n=Object.getOwnPropertyDescriptor(t,e);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(C,a,n)}:function(C,t,e,a){a===void 0&&(a=e),C[a]=t[e]}),T=p&&p.__exportStar||function(C,t){for(var e in C)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&e1(t,C,e)};Object.defineProperty(p,"__esModule",{value:!0});p.getApiSafe=p.getDefer=p.isPluginEnabled=p.PluginNotEnabledError=p.pluginId=void 0;T(I(),p);T(S(),p);T(H(),p);p.pluginId="obsidian-front-matter-title-plugin";var w=class extends Error{};p.PluginNotEnabledError=w;function t1(C){var t,e,a;return(a=(e=(t=C==null?void 0:C.plugins)===null||t===void 0?void 0:t.enabledPlugins)===null||e===void 0?void 0:e.has(p.pluginId))!==null&&a!==void 0?a:!1}p.isPluginEnabled=t1;function z(C){var t,e,a,n;let s=(e=(t=C==null?void 0:C.plugins)===null||t===void 0?void 0:t.getPlugin(p.pluginId))!==null&&e!==void 0?e:null,h=(n=(a=s==null?void 0:s.getDefer)===null||a===void 0?void 0:a.call(s))!==null&&n!==void 0?n:null;if(h===null)throw new w(`Plugin ${p.pluginId} is not enabled or old version`);return h}p.getDefer=z;function a1(C){return new k(null,C)}p.getApiSafe=a1;var k=class{constructor(t,e){this.api=t,this.app=e}before(){if(this.api!==null)return;let t=this.getDeffer();if(t===null)return;let e=t.getApi();if(e===null)return t.awaitPlugin().then(()=>{this.api=t.getApi()});this.api=e}getDeffer(){try{return z(this.app)}catch(t){if(t instanceof w)return null;throw t}}getResolverFactory(){var t,e;return this.before(),(e=(t=this.api)===null||t===void 0?void 0:t.getResolverFactory())!==null&&e!==void 0?e:null}getEventDispatcher(){var t,e;return this.before(),(e=(t=this.api)===null||t===void 0?void 0:t.getEventDispatcher())!==null&&e!==void 0?e:null}getEnabledFeatures(){var t,e;return this.before(),(e=(t=this.api)===null||t===void 0?void 0:t.getEnabledFeatures())!==null&&e!==void 0?e:[]}}});var l1={};X(l1,{default:()=>M});module.exports=Q(l1);var l=require("obsidian"),N=Y(V()),q=50,i1={recentFiles:[],omittedPaths:[],omittedTags:[],updateOn:"file-open",omitBookmarks:!1},u="recent-files",b=class extends l.ItemView{constructor(e,a,n){super(e);this.redraw=()=>{var o;let e=this.app.workspace.getActiveFile(),a=createDiv({cls:"nav-folder mod-root"}),n=a.createDiv({cls:"nav-folder-children"}),s=(0,N.getApiSafe)(this.app),f=s&&s.getEnabledFeatures().contains("explorer")?(o=s.getResolverFactory())==null?void 0:o.createResolver("explorer"):null;this.data.recentFiles.forEach(i=>{var _;let d=n.createDiv({cls:"tree-item nav-file recent-files-file"}),r=d.createDiv({cls:"tree-item-self is-clickable nav-file-title recent-files-title"}),g=r.createDiv({cls:"tree-item-inner nav-file-title-content"}),m=r.createDiv({cls:"nav-file-tag"}),r1=r.createDiv({cls:"tree-item-spacer"}),U=f&&(_=f.resolve(i.path))!=null?_:i.basename;g.setText(U);let F=this.app.vault.getFileByPath(i.path),E=F==null?void 0:F.extension;E&&E!=="md"&&m.setText(E),(0,l.setTooltip)(d,i.path),e&&i.path===e.path&&r.addClass("is-active"),r.setAttr("draggable","true"),r.addEventListener("dragstart",c=>{if(!(i!=null&&i.path))return;let v=this.app.metadataCache.getFirstLinkpathDest(i.path,""),L=this.app.dragManager,P=L.dragFile(c,v);L.onDragStart(c,P)}),r.addEventListener("mouseover",c=>{i!=null&&i.path&&this.app.workspace.trigger("hover-link",{event:c,source:u,hoverParent:a,targetEl:d,linktext:i.path})}),r.addEventListener("contextmenu",c=>{if(!(i!=null&&i.path))return;let v=new l.Menu;v.addItem(P=>P.setSection("action").setTitle("Open in new tab").setIcon("file-plus").onClick(()=>{this.focusFile(i,"tab")}));let L=this.app.vault.getAbstractFileByPath(i==null?void 0:i.path);this.app.workspace.trigger("file-menu",v,L,"link-context-menu"),v.showAtPosition({x:c.clientX,y:c.clientY})}),r.addEventListener("click",c=>{if(!i)return;let v=l.Keymap.isModEvent(c);this.focusFile(i,v)}),g.addEventListener("mousedown",c=>{i&&c.button===1&&(c.preventDefault(),this.focusFile(i,"tab"))});let O=r.createDiv({cls:"recent-files-file-delete menu-item-icon"});(0,l.setIcon)(O,"lucide-x"),O.addEventListener("click",async c=>{c.stopPropagation(),await this.removeFile(i),this.redraw()})}),this.contentEl.setChildrenInPlace([a])};this.removeFile=async e=>{this.data.recentFiles=this.data.recentFiles.filter(a=>a.path!==e.path),await this.plugin.saveData()};this.focusFile=(e,a)=>{let n=this.app.vault.getFiles().find(s=>s.path===e.path);n?this.app.workspace.getLeaf(a).openFile(n):(new l.Notice("Cannot find a file with that name"),this.data.recentFiles=this.data.recentFiles.filter(s=>s.path!==e.path),this.plugin.saveData(),this.redraw())};this.plugin=a,this.data=n}async onOpen(){this.redraw()}getViewType(){return u}getDisplayText(){return"Recent Files"}getIcon(){return"clock"}onPaneMenu(e){e.addItem(a=>{a.setTitle("Clear list").setIcon("sweep").onClick(async()=>{this.data.recentFiles=[],await this.plugin.saveData(),this.redraw()})}).addItem(a=>{a.setTitle("Close").setIcon("cross").onClick(()=>{this.app.workspace.detachLeavesOfType(u)})})}},M=class extends l.Plugin{constructor(){super(...arguments);this.pruneOmittedFiles=async()=>{let e=this.data.recentFiles.length;this.data.recentFiles=this.data.recentFiles.filter(this.shouldAddFile),e!==this.data.recentFiles.length&&await this.saveData()};this.pruneLength=async()=>{let e=this.data.recentFiles.length-(this.data.maxLength||q);e>0&&this.data.recentFiles.splice(this.data.recentFiles.length-e,e),await this.saveData()};this.shouldAddFile=e=>{var f,o;let a=this.data.omittedPaths.filter(i=>i.length>0),n=i=>{try{return new RegExp(i).test(e.path)}catch(d){return console.error("Recent Files: Invalid regex pattern: "+i),!1}};if(a.some(n))return!1;let s=this.app.vault.getFileByPath(e.path);if(s){let i=this.data.omittedTags.filter(g=>g.length>0),d=(o=(f=this.app.metadataCache.getFileCache(s))==null?void 0:f.frontmatter)==null?void 0:o.tags,r=g=>{try{return new RegExp(g).test(d.toString())}catch(m){return console.error("Recent Files: Invalid regex pattern: "+g),!1}};if(i.some(r))return!1}let h=this.app.internalPlugins.getEnabledPluginById("bookmarks");return!(s&&this.data.omitBookmarks&&h&&h.items.some(({path:d})=>d===s.path))};this.update=async e=>{if(!e)return;await this.updateData(e);let a=this.app.workspace.getLeavesOfType(u).first();a&&a.view instanceof b&&a.view.redraw()};this.onFileOpen=async e=>{if(!e)return;this.data.updateOn==="file-edit"?(this.app.workspace.off("quick-preview",this.waitingForEdit),this.registerEvent(this.app.workspace.on("quick-preview",this.waitingForEdit))):this.update(e);let a=this.app.workspace.getLeavesOfType(u).first();a&&a.view instanceof b&&a.view.redraw()};this.waitingForEdit=async(e,a)=>{this.update(e),this.app.workspace.off("quick-preview",this.waitingForEdit)};this.updateData=async e=>{let a=this.data.recentFiles.length;this.data.recentFiles=this.data.recentFiles.filter(s=>s.path!==e.path);let n=a!==this.data.recentFiles.length;this.shouldAddFile(e)&&(this.data.recentFiles.unshift({basename:e.basename,path:e.path}),n=!0),n&&await this.pruneLength()};this.handleRename=async(e,a)=>{var s;let n=this.data.recentFiles.find(h=>h.path===a);n&&(n.path=e.path,n.basename=this.trimExtension(e.name),(s=this.view)==null||s.redraw(),await this.saveData())};this.handleDelete=async e=>{var n;let a=this.data.recentFiles.length;this.data.recentFiles=this.data.recentFiles.filter(s=>s.path!==e.path),a!==this.data.recentFiles.length&&((n=this.view)==null||n.redraw(),await this.saveData())};this.trimExtension=e=>e.replace(/\.[^/.]+$/,"")}async onload(){console.log("Recent Files: Loading plugin v"+this.manifest.version),await this.loadData(),(0,l.addIcon)("sweep",C1),this.registerView(u,e=>this.view=new b(e,this,this.data)),this.addCommand({id:"recent-files-open",name:"Open",callback:async()=>{let e;[e]=this.app.workspace.getLeavesOfType(u),e||(e=this.app.workspace.getLeftLeaf(!1),await(e==null?void 0:e.setViewState({type:u}))),e&&this.app.workspace.revealLeaf(e)}}),this.app.workspace.registerHoverLinkSource(u,{display:"Recent Files",defaultMod:!0}),this.registerEvent(this.app.vault.on("rename",this.handleRename)),this.registerEvent(this.app.vault.on("delete",this.handleDelete)),this.registerEvent(this.app.workspace.on("file-open",this.onFileOpen)),this.addSettingTab(new x(this.app,this))}onunload(){this.app.workspace.unregisterHoverLinkSource(u)}async loadData(){this.data=Object.assign(i1,await super.loadData())}async saveData(){await super.saveData(this.data)}async onExternalSettingsChange(){var e;await this.loadData(),await this.pruneLength(),await this.pruneOmittedFiles(),(e=this.view)==null||e.redraw()}onUserEnable(){this.app.workspace.ensureSideLeaf(u,"left",{reveal:!0})}},x=class extends l.PluginSettingTab{constructor(t,e){super(t,e),this.plugin=e}display(){let{containerEl:t}=this;t.empty();let e=document.createDocumentFragment(),a=document.createElement("a");a.href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#writing_a_regular_expression_pattern",a.text="MDN - Regular expressions",e.append("RegExp patterns to ignore. One pattern per line. See "),e.append(a),e.append(" for help."),new l.Setting(t).setName("Omitted pathname patterns").setDesc(e).addTextArea(o=>{o.inputEl.setAttr("rows",6),o.setPlaceholder(`^daily/ \\.png$ foobar.*baz`).setValue(this.plugin.data.omittedPaths.join(` `)),o.inputEl.onblur=i=>{var r;let d=i.target.value;this.plugin.data.omittedPaths=d.split(` `),this.plugin.pruneOmittedFiles(),(r=this.plugin.view)==null||r.redraw()}});let n=document.createDocumentFragment();n.append("Frontmatter-tag patterns to ignore. One pattern per line."),new l.Setting(t).setName("Omitted frontmatter-tag patterns").setDesc(n).addTextArea(o=>{o.inputEl.setAttr("rows",6),o.setPlaceholder(`ignore archive/a/b`).setValue(this.plugin.data.omittedTags.join(` `)),o.inputEl.onblur=i=>{var r;let d=i.target.value;this.plugin.data.omittedTags=d.split(` `),this.plugin.pruneOmittedFiles(),(r=this.plugin.view)==null||r.redraw()}}),new l.Setting(t).setName("Omit bookmarked files").addToggle(o=>{o.setValue(this.plugin.data.omitBookmarks).onChange(i=>{var d;this.plugin.data.omitBookmarks=i,this.plugin.pruneOmittedFiles(),(d=this.plugin.view)==null||d.redraw()})}),new l.Setting(t).setName("Update list when file is:").addDropdown(o=>{o.addOption("file-open","Opened").addOption("file-edit","Changed").setValue(this.plugin.data.updateOn).onChange(i=>{var d;this.plugin.data.updateOn=i,this.plugin.pruneOmittedFiles(),(d=this.plugin.view)==null||d.redraw()})}),new l.Setting(t).setName("List length").setDesc("Maximum number of filenames to keep in the list.").addText(o=>{var i;o.inputEl.setAttr("type","number"),o.inputEl.setAttr("placeholder",q),o.setValue(((i=this.plugin.data.maxLength)==null?void 0:i.toString())||"").onChange(d=>{let r=parseInt(d,10);if(!Number.isNaN(r)&&r<=0){new l.Notice("List length must be a positive integer");return}}),o.inputEl.onblur=d=>{var m;let r=d.target.value,g=parseInt(r,10);this.plugin.data.maxLength=g,this.plugin.pruneLength(),(m=this.plugin.view)==null||m.redraw()}});let s=t.createEl("div",{cls:"recent-files-donation"}),h=document.createElement("p");h.appendText("If this plugin adds value for you and you would like to help support continued development, please use the buttons below:"),s.appendChild(h);let f=new DOMParser;s.appendChild(j("https://paypal.me/tgrosinger",f.parseFromString(s1,"text/xml").documentElement)),s.appendChild(j("https://www.buymeacoffee.com/tgrosinger",f.parseFromString(n1,"text/xml").documentElement))}},j=(C,t)=>{let e=document.createElement("a");return e.setAttribute("href",C),e.addClass("recent-files-donate-button"),e.appendChild(t),e},C1=` `,n1=` `,s1=` `; /* nosourcemap */