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