/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var d=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var _=(m,h)=>{for(var i in h)d(m,i,{get:h[i],enumerable:!0})},O=(m,h,i,t)=>{if(h&&typeof h=="object"||typeof h=="function")for(let e of A(h))!U.call(m,e)&&e!==i&&d(m,e,{get:()=>h[e],enumerable:!(t=j(h,e))||t.enumerable});return m};var G=m=>O(d({},"__esModule",{value:!0}),m);var Q={};_(Q,{default:()=>c});module.exports=G(Q);var a=require("obsidian");var b={};var x={};var y={};var R={};var u={"created at":"created at","updated at":"updated at","Show preview contents":"Show preview contents","Show preview contents in the file explorer.":"Show preview contents in the file explorer.","Show image":"Show image","Show image in the preview contents from file content.":"Show image in the preview contents from file content.","Length of the preview contents.":"Length of the preview contents.","default: 50":"default: 50","Line clamp":"Line clamp","The number of lines to show in the preview contents.(1 - 10, default: 2).":"The number of lines to show in the preview contents.(1 - 10, default: 2).","Indents of the preview contents":"Indents of the preview contents","The indents of the preview contents.":"The indents of the preview contents.","Exclude special file/folder":"Exclude special file/folder","Path to file/folder that you want to exclude. Split multiple paths with line breaks.":"Path to file that you want to exclude. Split multiple paths with line breaks.","path/to/file.md or path/to/folder":"path/to/file.md or path/to/folder","Format preview contents":"Format preview contents","Remove frontmatter":"Remove frontmatter","Remove frontmatter of the file.":"Remove frontmatter of the file.","Remove bold and italic symbols":"Remove bold and italic symbols","Remove bold and italic symbols of the file.":"Remove bold and italic symbols of the file.","Remove highlight symbols":"Remove highlight symbols","Remove highlight symbols of the file.":"Remove highlight symbols of the file.","Remove code block":"Remove code block","Remove code block of the file.":"Remove code block of the file.","Remove quote":"Remove quote","Remove quote of the file.":"Remove quote of the file.","Remove blank line":"Remove blank line","Remove blank line of the file.":"Remove blank line of the file.","Remove title symbol":"Remove title symbol","Remove title symbol of the file.":"Remove title symbol of the file.","Remove first h1":"Remove first h1","Remove the first heading 1 of the file.":"Remove the first heading 1 of the file.","Remove first h2":"Remove first h2","Remove the first heading 2 of the file.":"Remove the first heading 2 of the file.","Custom remove rules":"Custom remove rules","Custom regular expression formatting preview text will be applied at the end. Split multiple expressions with line breaks.":"Custom regular expression formatting preview text will be applied at the end. Split multiple expressions with line breaks.","The content that you want to delete.":"The content that you want to delete.","File properties":"File properties","Display properties":"Display properties","Display file properties under detaile message. For example, created time, updated time, file size.":"Display file properties under detaile message. For example, created time, updated time, file size.","Created time format":"Created time format","ctime. Time of creation. Default is 'YYYY-MM-DD HH:mm:ss'":"ctime. Time of creation. Default is 'YYYY-MM-DD HH:mm:ss'","Modified time format":"Modified time format","mtime. Time of last modification. Default is 'YYYY-MM-DD HH:mm:ss'":"mtime. Time of last modification. Default is 'YYYY-MM-DD HH:mm:ss'","Properties format":"Properties format","Format of the file properties. Use 'ctime' and 'mtime'.":"Format of the file properties. Use 'ctime' and 'mtime'.","Reset to default":"Reset to default"};var S={};var F={};var T={};var C={};var D={};var E={};var k={};var P={};var $=require("obsidian");var M={};var Y={};var H={};var L={};var I={};var N={};var V={};var B={};var q={"created at":"\u521B\u5EFA\u4E8E","updated at":"\u66F4\u65B0\u4E8E","Show preview contents":"\u5F00\u542F\u5185\u5BB9\u9884\u89C8","Show preview contents in the file explorer.":"\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u67E5\u770B\u90E8\u5206\u7B14\u8BB0\u5185\u5BB9","Show image":"\u663E\u793A\u56FE\u7247","Show image in the preview contents from file content.":"\u5728\u7B14\u8BB0\u5185\u5BB9\u4E2D\u663E\u793A\u56FE\u7247","Length of the preview contents.":"\u9884\u89C8\u5185\u5BB9\u957F\u5EA6","default: 50":"\u9ED8\u8BA4 50","Line clamp":"\u884C\u6570\u9650\u5236","The number of lines to show in the preview contents.(1 - 10, default: 2).":"\u9884\u89C8\u5185\u5BB9\u884C\u6570\u9650\u5236(1-10, \u9ED8\u8BA42).","Indents of the preview contents":"\u9884\u89C8\u5185\u5BB9\u7F29\u8FDB","The indents of the preview contents.":"\u9884\u89C8\u5185\u5BB9\u7F29\u8FDB","Exclude special file/folder":"\u6392\u9664\u7279\u5B9A\u6587\u4EF6/\u6587\u4EF6\u5939","Path to file/folder that you want to exclude. Split multiple paths with line breaks.":"\u88AB\u6392\u9664\u7684\u6587\u4EF6/\u6587\u4EF6\u5939\u8DEF\u5F84\uFF0C\u6362\u884C\u5206\u5272\u591A\u4E2A\u8DEF\u5F84","path/to/file.md or path/to/folder":"path/to/file.md or path/to/folder","Format preview contents":"\u683C\u5F0F\u5316\u9884\u89C8\u5185\u5BB9","Remove frontmatter":"\u5220\u9664frontmatter","Remove frontmatter of the file.":"\u5220\u9664\u6587\u4EF6\u7684frontmatter","Remove bold and italic symbols":"\u5220\u9664\u7C97\u4F53\u548C\u659C\u4F53\u7B26\u53F7","Remove bold and italic symbols of the file.":"\u5220\u9664\u6587\u4EF6\u7684\u7C97\u4F53\u548C\u659C\u4F53\u7B26\u53F7","Remove highlight symbols":"\u5220\u9664\u9AD8\u4EAE\u7B26\u53F7","Remove highlight symbols of the file.":"\u5220\u9664\u6587\u4EF6\u7684\u9AD8\u4EAE\u7B26\u53F7","Remove code block":"\u5220\u9664\u4EE3\u7801\u5757","Remove code block of the file.":"\u5220\u9664\u6587\u4EF6\u7684\u4EE3\u7801\u5757","Remove quote":"\u5220\u9664\u5F15\u7528\u7B26\u53F7","Remove quote of the file.":"\u5220\u9664\u6587\u4EF6\u7684\u5F15\u7528\u7B26\u53F7","Remove blank line":"\u5220\u9664\u7A7A\u884C","Remove blank line of the file.":"\u5220\u9664\u6587\u4EF6\u7684\u7A7A\u884C","Remove title symbol":"\u5220\u9664\u6807\u9898\u7B26\u53F7","Remove title symbol of the file.":"\u5220\u9664\u6587\u4EF6\u7684\u6807\u9898\u7B26\u53F7","Remove first h1":"\u5220\u9664\u7B2C\u4E00\u4E2A h1","Remove the first heading 1 of the file.":"\u5220\u9664\u6587\u4EF6\u7684\u7B2C\u4E00\u4E2A\u4E00\u7EA7\u6807\u9898","Remove first h2":"\u5220\u9664\u7B2C\u4E00\u4E2A h2","Remove the first heading 2 of the file.":"\u5220\u9664\u6587\u4EF6\u7684\u7B2C\u4E00\u4E2A\u4E8C\u7EA7\u6807\u9898","Custom remove rules":"\u81EA\u5B9A\u4E49\u5220\u9664\u89C4\u5219","Custom regular expression formatting preview text will be applied at the end. Split multiple expressions with line breaks.":"\u81EA\u5B9A\u4E49\u6B63\u5219\u8868\u8FBE\u5F0F\u683C\u5F0F\u5316\u9884\u89C8\u6587\u672C\uFF0C\u4F1A\u5728\u6700\u540E\u5E94\u7528\u3002\u6362\u884C\u5206\u5272\u591A\u4E2A\u8868\u8FBE\u5F0F","The content that you want to delete.":"\u4F60\u60F3\u5220\u9664\u7684\u5185\u5BB9","File properties":"\u6587\u4EF6\u5C5E\u6027","Display properties":"\u663E\u793A\u5C5E\u6027","Display file properties under detaile message. For example, created time, updated time, file size.":"\u5728\u8BE6\u7EC6\u4FE1\u606F\u4E2D\u663E\u793A\u6587\u4EF6\u5C5E\u6027. \u4F8B\u5982, \u521B\u5EFA\u65F6\u95F4, \u66F4\u65B0\u65F6\u95F4, \u6587\u4EF6\u5927\u5C0F.","Created time format":"\u521B\u5EFA\u65F6\u95F4\u683C\u5F0F","ctime. Time of creation. Default is 'YYYY-MM-DD HH:mm:ss'":"ctime. \u521B\u5EFA\u65F6\u95F4. \u9ED8\u8BA4\u662F 'YYYY-MM-DD HH:mm:ss'","Modified time format":"\u4FEE\u6539\u65F6\u95F4\u683C\u5F0F","mtime. Time of last modification. Default is 'YYYY-MM-DD HH:mm:ss'":"mtime. \u6700\u540E\u4FEE\u6539\u65F6\u95F4. \u9ED8\u8BA4\u662F 'YYYY-MM-DD HH:mm:ss'","Properties format":"\u5C5E\u6027\u683C\u5F0F","Format of the file properties. Use 'ctime' and 'mtime'.":"\u5C5E\u6027\u683C\u5F0F. \u4F7F\u7528 'ctime' \u548C 'mtime'.","Reset to default":"\u91CD\u7F6E\u4E3A\u9ED8\u8BA4\u503C"};var W={"created at":"\u5275\u5EFA\u65BC","updated at":"\u66F4\u65B0\u65BC","Show preview contents":"\u986F\u793A\u9810\u89BD\u5167\u5BB9","Show preview contents in the file explorer.":"\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u67E5\u770B\u90E8\u5206\u7B46\u8A18\u5167\u5BB9","Show image":"\u986F\u793A\u5716\u7247","Show image in the preview contents from file content.":"\u5728\u7B46\u8A18\u5167\u5BB9\u4E2D\u986F\u793A\u5716\u7247","Length of the preview contents.":"\u9810\u89BD\u5167\u5BB9\u9577\u5EA6","default: 50":"\u9810\u8A2D 50","Line clamp":"\u884C\u6578\u9650\u5236","The number of lines to show in the preview contents.(1 - 10, default: 2).":"\u9810\u89BD\u5167\u5BB9\u884C\u6578\u9650\u5236(1-10, \u9810\u8A2D2).","Indents of the preview contents":"\u9810\u89BD\u5167\u5BB9\u7E2E\u9032","The indents of the preview contents.":"\u9810\u89BD\u5167\u5BB9\u7E2E\u9032","Exclude special file/folder":"\u6392\u9664\u7279\u5B9A\u6587\u4EF6/\u6587\u4EF6\u593E","Path to file/folder that you want to exclude. Split multiple paths with line breaks.":"\u88AB\u6392\u9664\u7684\u6587\u4EF6/\u6587\u4EF6\u593E\u8DEF\u5F91\uFF0C\u63DB\u884C\u5206\u5272\u591A\u500B\u8DEF\u5F91","path/to/file.md or path/to/folder":"path/to/file.md or path/to/folder","Format preview contents":"\u683C\u5F0F\u5316\u9810\u89BD\u5167\u5BB9","Remove frontmatter":"\u522A\u9664 frontmatter","Remove frontmatter of the file.":"\u522A\u9664\u6587\u4EF6\u7684 frontmatter","Remove bold and italic symbols":"\u522A\u9664\u7C97\u9AD4\u548C\u659C\u9AD4\u7B26\u865F","Remove bold and italic symbols of the file.":"\u522A\u9664\u6587\u4EF6\u7684\u7C97\u9AD4\u548C\u659C\u9AD4\u7B26\u865F","Remove highlight symbols":"\u522A\u9664\u9AD8\u4EAE\u7B26\u865F","Remove highlight symbols of the file.":"\u522A\u9664\u6587\u4EF6\u7684\u9AD8\u4EAE\u7B26\u865F","Remove code block":"\u522A\u9664\u4EE3\u78BC\u584A","Remove code block of the file.":"\u522A\u9664\u6587\u4EF6\u7684\u4EE3\u78BC\u584A","Remove quote":"\u522A\u9664\u5F15\u7528\u7B26\u865F","Remove quote of the file.":"\u522A\u9664\u6587\u4EF6\u7684\u5F15\u7528\u7B26\u865F","Remove blank line":"\u522A\u9664\u7A7A\u884C","Remove blank line of the file.":"\u522A\u9664\u6587\u4EF6\u7684\u7A7A\u884C","Remove title symbol":"\u522A\u9664\u6A19\u984C\u7B26\u865F","Remove title symbol of the file.":"\u522A\u9664\u6587\u4EF6\u7684\u6A19\u984C\u7B26\u865F","Remove first h1":"\u522A\u9664\u7B2C\u4E00\u500B h1","Remove the first heading 1 of the file.":"\u522A\u9664\u6587\u4EF6\u7684\u7B2C\u4E00\u500B\u4E00\u7D1A\u6A19\u984C","Remove first h2":"\u522A\u9664\u7B2C\u4E00\u500B h2","Remove the first heading 2 of the file.":"\u522A\u9664\u6587\u4EF6\u7684\u7B2C\u4E00\u500B\u4E8C\u7D1A\u6A19\u984C","Custom remove rules":"\u81EA\u5B9A\u7FA9\u522A\u9664\u898F\u5247","Custom regular expression formatting preview text will be applied at the end. Multiple expressions can be wrapped":"\u81EA\u5B9A\u7FA9\u6B63\u5247\u8868\u9054\u5F0F\u683C\u5F0F\u5316\u9810\u89BD\u6587\u672C\uFF0C\u6703\u5728\u6700\u5F8C\u61C9\u7528\u3002\u591A\u500B\u8868\u9054\u5F0F\u63DB\u884C\u5373\u53EF","The content that you want to delete.":"\u4F60\u60F3\u522A\u9664\u7684\u5167\u5BB9","File properties":"\u6587\u4EF6\u5C6C\u6027","Display properties":"\u986F\u793A\u5C6C\u6027","Display file properties under detaile message. For example, created time, updated time, file size.":"\u5728\u8A73\u7D30\u4FE1\u606F\u4E2D\u986F\u793A\u6587\u4EF6\u5C6C\u6027. \u4F8B\u5982, \u5275\u5EFA\u6642\u9593, \u66F4\u65B0\u6642\u9593, \u6587\u4EF6\u5927\u5C0F.","Created time format":"\u5275\u5EFA\u6642\u9593\u683C\u5F0F","ctime. Time of creation. Default is 'YYYY-MM-DD HH:mm:ss'":"ctime. \u5275\u5EFA\u6642\u9593. \u9810\u8A2D\u662F 'YYYY-MM-DD HH:mm:ss'","Modified time format":"\u4FEE\u6539\u6642\u9593\u683C\u5F0F","mtime. Time of last modification. Default is 'YYYY-MM-DD HH:mm:ss'":"mtime. \u6700\u5F8C\u4FEE\u6539\u6642\u9593. \u9810\u8A2D\u662F 'YYYY-MM-DD HH:mm:ss'","Properties format":"\u5C6C\u6027\u683C\u5F0F","Format of the file properties. Use 'ctime' and 'mtime'.":"\u5C6C\u6027\u683C\u5F0F. \u4F7F\u7528 'ctime' \u548C 'mtime'.","Reset to default":"\u91CD\u8A2D\u70BA\u9810\u8A2D"};var J={ar:b,cs:x,da:y,de:R,en:u,"en-gb":S,es:F,fr:T,hi:C,id:D,it:E,ja:k,ko:P,nl:M,nn:Y,pl:H,pt:L,"pt-br":I,ro:N,ru:V,tr:B,"zh-cn":q,"zh-tw":W},z=J[$.moment.locale()];function s(m){return z&&z[m]||u[m]}var w={showpreview:!0,lineClamp:2,indents:0,previewcontentslength:"50",ispreview:!1,format:{frontmatter:!0,bolditalic:!0,highlight:!0,codeblock:!0,quote:!0,blankline:!0,title:!0,firsth1:!0,firsth2:!1,customregex:[]},showImg:!0,showFileProperties:!1,ctimeFormat:"YYYY-MM-DD HH:mm:ss",mtimeFormat:"YYYY-MM-DD HH:mm:ss",propertiesFormat:`${s("created at")} ctime, ${s("updated at")} mtime`,excluded:[]},f=class extends a.PluginSettingTab{constructor(i,t){super(i,t);this.plugin=t}display(){let{containerEl:i}=this;i.empty(),new a.Setting(i).setName(s("Show preview contents")).setDesc(s("Show preview contents in the file explorer.")).addToggle(t=>t.setValue(this.plugin.settings.showpreview).onChange(async e=>{this.plugin.settings.showpreview=e,e?await this.plugin.initialize():await this.plugin.deletePreviewContents(),await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Show image")).setDesc(s("Show image in the preview contents from file content.")).addToggle(t=>t.setValue(this.plugin.settings.showImg).onChange(async e=>{this.plugin.settings.showImg=e,await this.plugin.refreshPreviewContents(),await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Length of the preview contents.")).setDesc(s("default: 50")).addText(t=>t.setPlaceholder("50").setValue(this.plugin.settings.previewcontentslength).onChange(async e=>{this.plugin.settings.previewcontentslength=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Line clamp")).setDesc(s("The number of lines to show in the preview contents.(1 - 10, default: 2).")).addSlider(t=>t.setLimits(1,10,1).setValue(this.plugin.settings.lineClamp).onChange(async e=>{this.plugin.settings.lineClamp=e,await this.plugin.refreshPreviewContents(),await this.plugin.saveSettings()}).setDynamicTooltip()),new a.Setting(i).setName(s("Indents of the preview contents")).setDesc(s("The indents of the preview contents.")).addSlider(t=>t.setLimits(0,10,1).setValue(this.plugin.settings.indents).onChange(async e=>{this.plugin.settings.indents=e,await this.plugin.refreshPreviewContents(),await this.plugin.saveSettings()}).setDynamicTooltip()),new a.Setting(i).setName(s("Exclude special file/folder")).setDesc(s("Path to file/folder that you want to exclude. Split multiple paths with line breaks.")).addTextArea(t=>t.setPlaceholder("path/to/file.md or path/to/folder").setValue(this.plugin.settings.excluded.join(`
`)).onChange(async e=>{this.plugin.settings.excluded=e.trim().split(`
`),await this.plugin.saveSettings(),await this.plugin.refreshPreviewContents()})),new a.Setting(i).setName(s("Format preview contents")).setHeading(),new a.Setting(i).setName(s("Remove frontmatter")).setDesc(s("Remove frontmatter of the file.")).addToggle(t=>t.setValue(this.plugin.settings.format.frontmatter).onChange(async e=>{this.plugin.settings.format.frontmatter=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Remove bold and italic symbols")).setDesc(s("Remove bold and italic symbols of the file.")).addToggle(t=>t.setValue(this.plugin.settings.format.bolditalic).onChange(async e=>{this.plugin.settings.format.bolditalic=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Remove highlight symbols")).setDesc(s("Remove highlight symbols of the file.")).addToggle(t=>t.setValue(this.plugin.settings.format.highlight).onChange(async e=>{this.plugin.settings.format.highlight=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Remove code block")).setDesc(s("Remove code block of the file.")).addToggle(t=>t.setValue(this.plugin.settings.format.codeblock).onChange(async e=>{this.plugin.settings.format.codeblock=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Remove quote")).setDesc(s("Remove quote of the file.")).addToggle(t=>t.setValue(this.plugin.settings.format.quote).onChange(async e=>{this.plugin.settings.format.quote=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Remove blank line")).setDesc(s("Remove blank line of the file.")).addToggle(t=>t.setValue(this.plugin.settings.format.blankline).onChange(async e=>{this.plugin.settings.format.blankline=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Remove title symbol")).setDesc(s("Remove title symbol of the file.")).addToggle(t=>t.setValue(this.plugin.settings.format.title).onChange(async e=>{this.plugin.settings.format.title=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Remove first h1")).setDesc(s("Remove the first heading 1 of the file.")).addToggle(t=>t.setValue(this.plugin.settings.format.firsth1).onChange(async e=>{this.plugin.settings.format.firsth1=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Remove first h2")).setDesc(s("Remove the first heading 2 of the file.")).addToggle(t=>t.setValue(this.plugin.settings.format.firsth2).onChange(async e=>{this.plugin.settings.format.firsth2=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Custom remove rules")).setDesc(s("Custom regular expression formatting preview text will be applied at the end. Split multiple expressions with line breaks.")).addTextArea(t=>{var e,o;return t.setPlaceholder("The content that you want to delete.").setValue((o=(e=this.plugin.settings.format.customregex)==null?void 0:e.join(`
`))!=null?o:"").onChange(async n=>{this.plugin.settings.format.customregex=n.trim().split(`
`),await this.plugin.saveSettings()})}),new a.Setting(i).setName(s("File properties")).setHeading(),new a.Setting(i).setName(s("Display properties")).setDesc(s("Display file properties under detaile message. For example, created time, updated time, file size.")).addToggle(t=>t.setValue(this.plugin.settings.showFileProperties).onChange(async e=>{this.plugin.settings.showFileProperties=e,await this.plugin.saveSettings()})),new a.Setting(i).setName(s("Created time format")).setDesc(s("ctime. Time of creation. Default is 'YYYY-MM-DD HH:mm:ss'")).addText(t=>t.setPlaceholder(this.plugin.settings.ctimeFormat).setValue(this.plugin.settings.ctimeFormat).onChange(async e=>{this.plugin.settings.ctimeFormat=e,await this.plugin.saveSettings()})).then(t=>this.addResetButton(t,"ctimeFormat")),new a.Setting(i).setName(s("Modified time format")).setDesc(s("mtime. Time of last modification. Default is 'YYYY-MM-DD HH:mm:ss'")).addText(t=>t.setPlaceholder(this.plugin.settings.mtimeFormat).setValue(this.plugin.settings.mtimeFormat).onChange(async e=>{this.plugin.settings.mtimeFormat=e,await this.plugin.saveSettings()})).then(t=>this.addResetButton(t,"mtimeFormat")),new a.Setting(i).setName(s("Properties format")).setDesc(s("Format of the file properties. Use 'ctime' and 'mtime'.")).addText(t=>t.setPlaceholder(this.plugin.settings.propertiesFormat).setValue(this.plugin.settings.propertiesFormat).onChange(async e=>{this.plugin.settings.propertiesFormat=e,await this.plugin.saveSettings()})).then(t=>this.addResetButton(t,"propertiesFormat"))}addResetButton(i,t,e=!0){i.addExtraButton(o=>o.setIcon("reset").setTooltip(s("Reset to default")).onClick(()=>{this.plugin.settings[t]=w[t],this.plugin.saveSettings(),e&&this.display()}))}};var l=require("obsidian"),c=class extends l.Plugin{constructor(){super(...arguments);this.previewContentsEl=[]}async onload(){var e;await this.loadSettings(),(e=this.settings.format)!=null&&e.customregex?this.settings.excluded||(this.settings.excluded=[],this.saveData(this.settings)):(this.settings.format.customregex=[],this.saveData(this.settings)),this.settingTab=new f(this.app,this),this.addSettingTab(this.settingTab),await this.initialize(),this.registerCommands();let t=((o,n)=>{let r;return()=>{clearTimeout(r),r=window.setTimeout(()=>o.apply(this),n)}})(async()=>{if(this.settings.showpreview&&this.settings.ispreview){let o=this.app.workspace.getActiveFile();if(o){let n=o.path,r=this.fileExplorerView.fileItems[n];r&&this.displayPreviewContentsByFileItem(r)}}},10);this.app.workspace.on("editor-change",t),this.app.workspace.on("file-menu",(o,n)=>{!n||this.settings.excluded.includes(n.path)||o.addItem(r=>{r.setIcon("trash"),r.setTitle(n instanceof l.TFolder?"Exclude folder":"Exclude file"),r.onClick(()=>{this.settings.excluded.push(n.path),this.saveSettings(),this.refreshPreviewContents()})})}),this.ttl=5,(0,l.addIcon)("captions",''),(0,l.addIcon)("captions-off",''),await this.saveSettings()}onunload(){this.showpreviewBtn.remove(),this.deletePreviewContents(),this.saveSettings()}async initialize(){this.app.workspace.onLayoutReady(async()=>{try{this.fileExplorerView=await this.getFileExplorerView(),this.fileNavEl=this.fileExplorerView.containerEl,this.initImagePaths(),this.createShowPreviewButton(this.fileNavEl.querySelector(".nav-header > .nav-buttons-container")),this.settings.showpreview&&await this.refreshPreviewContents()}catch(i){if(console.log(i),this.ttl<=0)return;this.ttl-=1,setTimeout(()=>{this.initialize()},1e3)}})}createShowPreviewButton(i){this.showpreviewBtn||(this.showpreviewBtn=i.createDiv({cls:"clickable-icon nav-action-button show-preview-button",attr:{"aria-label":"Show/Hide preview contents"}}),this.settings.ispreview?(0,l.setIcon)(this.showpreviewBtn,"captions-off"):(0,l.setIcon)(this.showpreviewBtn,"captions"),this.registerDomEvent(this.showpreviewBtn,"click",()=>{this.togglePreviewContents(),this.settings.ispreview?((0,l.setIcon)(this.showpreviewBtn,"captions-off"),this.settings.ispreview=!1):((0,l.setIcon)(this.showpreviewBtn,"captions"),this.settings.ispreview=!0),this.saveSettings()}))}async displayPreviewContents(){this.fileNavEl.classList.add("file-preview-nav");let i=this.fileExplorerView.fileItems;for(let t in i){let e=i[t];t==="/"||this.isExcluded(e.file)||!(e.file instanceof l.TFile)||e.file.extension!=="md"||this.isExcluded(e.file)||this.displayPreviewContentsByFileItem(e)}this.settings.ispreview=!0}isExcluded(i){return this.settings.excluded.some(t=>t&&i.path.startsWith(t))}async getFileExplorerView(){return new Promise((i,t)=>{let e=null,o=this.app.workspace.getLeavesOfType("file-explorer");o.length===0?t(Error("Could not find file explorer view.")):(e=o[0],i(e.view)),e||t(Error("Could not find file explorer view."))})}togglePreviewContents(){this.fileNavEl.classList.toggle("hide-preview-contents")}async deletePreviewContents(){this.fileNavEl.classList.remove("file-preview-nav"),this.fileNavEl.classList.remove("hide-preview-contents"),this.previewContentsEl.forEach(i=>{i.remove()}),this.previewContentsEl=[],this.settings.ispreview=!1,this.saveSettings()}async refreshPreviewContents(){this.settings.ispreview&&this.deletePreviewContents(),this.displayPreviewContents()}async displayPreviewContentsByFileItem(i){let t=i.file;t&&await this.app.vault.cachedRead(t).then(e=>{let o=this.formatContents(e.trim(),t.basename);if(o){if(i.innerEl&&i.el.querySelector(".nav-file-details")){let n=i.selfEl.querySelector(".tree-item-inner.nav-file-details");if(n&&o!==n.innerHTML&&(n.innerHTML=o),this.settings.showFileProperties){let r=(0,l.moment)(t.stat.ctime).format(this.settings.ctimeFormat),p=(0,l.moment)(t.stat.mtime).format(this.settings.mtimeFormat),g=this.settings.propertiesFormat.replace("ctime",r).replace("mtime",p),v=i.selfEl.querySelector(".nav-file-properties");v&&(v.innerHTML=g)}return}if(this.previewContentsEl.push(i.selfEl.createEl("div",{text:o,attr:{class:"tree-item-inner nav-file-details",style:`-webkit-line-clamp: ${this.settings.lineClamp}; text-indent: ${this.settings.indents}em;`}})),this.settings.showFileProperties){let n=(0,l.moment)(t.stat.ctime).format(this.settings.ctimeFormat),r=(0,l.moment)(t.stat.mtime).format(this.settings.mtimeFormat),p=this.settings.propertiesFormat.replace("ctime",n).replace("mtime",r);this.previewContentsEl.push(i.selfEl.createEl("div",{text:p,attr:{class:"nav-file-properties"}}))}if(this.settings.showImg){let n=this.getFirstImgPath(e);if(!n||i.el.querySelector(".nav-file-img"))return;i.el.classList.add("file-preview-show-img");let r=i.el.createEl("div",{attr:{class:"tree-item-inner nav-file-img"}});if(!n.startsWith("http")){let p=this.imagePaths.find(g=>g.endsWith(n))||n;n=this.app.vault.adapter.getResourcePath((0,l.normalizePath)(p))}r.createEl("div",{attr:{class:"preview-img",style:`background-image: url(${n})`}}),this.previewContentsEl.push(r)}}})}formatContents(i,t){let e=i;i.startsWith("---")&&this.settings.format.frontmatter&&(e=i.replace(/---[\s\S]*?---/,""));let o=e.indexOf(`
`),n=e.slice(0,o).trim();this.settings.format.firsth1&&(n.startsWith("# ")||n===t)&&(e=e.slice(o)),this.settings.format.firsth2&&n.startsWith("## ")&&(e=e.slice(o)),this.settings.format.bolditalic&&(e=e.replace(/(\*\*|__)(.*?)\1/g,"$2"),e=e.replace(/(\*|_)(.*?)\1/g,"$2")),this.settings.format.highlight&&(e=e.replace(/===(.*?)===/g,"$1")),this.settings.format.codeblock&&(e=e.replace(/`{5}[\s\S]*?`{5}/g,""),e=e.replace(/`{4}[\s\S]*?`{4}/g,""),e=e.replace(/`{3}[\s\S]*?`{3}/g,"")),this.settings.format.quote&&(e=e.replace(/(^>.*\n*)+/g,"")),this.settings.format.blankline&&(e=e.replace(/^\s*\n/g,"")),e=e.replace(/#+/g,""),e=e.replace(/!\[.*?\]\(.*?\)/g,""),e=e.replace(/\[\[.*?\]\]/g,""),e=e.replace(/\[.*?\]\(.*?\)/g,"");for(let r=0;re.path).filter(e=>this.pathIsImg(e));this.imagePaths=t}pathIsImg(i){return i.endsWith(".png")||i.endsWith(".jpg")||i.endsWith(".jpeg")||i.endsWith(".gif")||i.endsWith(".webp")}registerCommands(){this.addCommand({id:"refresh-preview-contents",name:"Refresh preview contents",callback:async()=>{this.refreshPreviewContents()}}),this.addCommand({id:"show-preview-contents",name:"Show preview contents",callback:async()=>{await this.displayPreviewContents()}}),this.addCommand({id:"hide-preview-contents",name:"Hide preview contents",callback:async()=>{this.fileNavEl.classList.add("hide-preview-contents"),this.settings.ispreview=!1,this.saveSettings()}}),this.addCommand({id:"show-preview-contents",name:"Show preview contents",callback:async()=>{this.fileNavEl.classList.remove("hide-preview-contents"),this.settings.ispreview=!0,this.saveSettings()}})}async loadSettings(){this.settings=Object.assign({},w,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}};
/* nosourcemap */