${s}`,e*1e3);t&&(o.noticeEl.oncontextmenu=()=>a(this,null,function*(){t()}))}function z(){return a(this,null,function*(){try{let i=yield fetch("https://obsidian.md/?"+Math.random());return i.status>=200&&i.status<300}catch(i){return!1}})}var Pt=i=>(0,q.normalizePath)(i.app.vault.configDir+"/themes")+"/",nt=(i,n,e="")=>a(void 0,null,function*(){let t=yield et(n);if(!t)return m(i,"There is no obsidian.css file in the root path of this repository, so there is no theme to install."),!1;yield vt(i,e,t);let s=`${e}themeinstalledfrom${n}.`;return i.log(s+`[ThemeInfo](https://github.com/${n})`,!1),m(i,`${s}`,10,()=>a(void 0,null,function*(){window.open(`https://github.com/${n}`)})),setTimeout(()=>{i.app.customCss.setTheme(e)},500),!0}),vt=(i,n,e)=>a(void 0,null,function*(){let t=Pt(i),s=i.app.vault.adapter;(yield s.exists(t))===!1&&(yield s.mkdir(t)),yield s.write(t+n+".css",e)}),Nt=i=>a(void 0,null,function*(){let n=yield Y(),e=Object.values(n).map(s=>({display:`Theme: ${s.name} (${s.repo})`,info:s})),t=new v(i);t.setSuggesterData(e),yield t.display(s=>a(void 0,null,function*(){yield nt(i,s.info.repo,s.info.name)}))}),V=i=>("BRAT-"+i.replace("/","----")).substr(0,100),Ct=(i,n)=>a(void 0,null,function*(){i.settings.themesList=i.settings.themesList.filter(t=>t.repo!=n),i.saveSettings(),yield i.app.vault.adapter.remove(Pt(i)+V(n)+".css");let e=`Removed ${n} from BRAT themes list and deleted from vault`;i.log(e,!0),m(i,`${e}`)}),J=(i,n)=>a(void 0,null,function*(){if((yield z())===!1){console.log("BRAT: No internet detected.");return}let e,t="Checking for beta theme updates STARTED";i.log(t,!0),n&&i.settings.notificationsEnabled&&(e=new q.Notice(`BRAT
${t}`,3e4));for(let o of i.settings.themesList){let r=yield j(o.repo,"obsidian.css");r!==o.lastUpdate&&(yield ee(i,o.repo,o.lastUpdate,r))}let s="Checking for beta theme updates COMPLETED";i.log(s,!0),n&&(i.settings.notificationsEnabled&&e.hide(),m(i,s))}),ee=(i,n,e="",t="")=>a(void 0,null,function*(){let s=yield et(n);if(!s)return m(i,"There is no obsidian.css file in the root path of the ${cssGithubRepository} repository, so this theme cannot be updated."),!1;let o=V(n);yield vt(i,o,s),yt(i,n,t);let r=`${o}themeupdatedfrom${n}.Fromdate:${e}to${t}`;return i.log(r+`[ThemeInfo](https://github.com/${n})`,!1),m(i,`${r}`,20,()=>a(void 0,null,function*(){window.open(`https://github.com/${n}`)})),!0});var W=require("obsidian");var S=class extends W.Modal{constructor(e,t=!1){super(e.app);this.plugin=e,this.address="",this.openSettingsTabAfterwards=t}submitForm(){return a(this,null,function*(){if(this.address==="")return;let e=this.address.replace("https://github.com/","");if(yield wt(this.plugin,e)){m(this.plugin,"This plugin is already in the list for beta testing",10);return}(yield nt(this.plugin,e,V(e)))&&(yield bt(this.plugin,e),this.close())})}onOpen(){this.contentEl.createEl("h4",{text:"Github repository for beta theme:"}),this.contentEl.createEl("form",{},e=>{new W.Setting(e).addText(t=>{t.setPlaceholder("Repository (example: GitubUserName/repository-name"),t.onChange(s=>{this.address=s.trim()}),t.inputEl.addEventListener("keydown",s=>a(this,null,function*(){s.key==="Enter"&&this.address!==" "&&(s.preventDefault(),yield this.submitForm())})),t.inputEl.style.width="100%",window.setTimeout(()=>{let s=document.querySelector(".setting-item-info");s&&s.remove(),t.inputEl.focus()},10)}),e.createDiv("modal-button-container",t=>{t.createEl("button",{attr:{type:"button"},text:"Never mind"}).addEventListener("click",()=>this.close()),t.createEl("button",{attr:{type:"submit"},cls:"mod-cta",text:"Add Theme"})}),e.addEventListener("submit",t=>a(this,null,function*(){t.preventDefault(),this.address!==""&&(yield this.submitForm())}))})}onClose(){return a(this,null,function*(){this.openSettingsTabAfterwards&&(yield this.plugin.app.setting.open(),yield this.plugin.app.setting.openTabById("obsidian42-brat"))})}};var Q=class extends T.PluginSettingTab{constructor(e,t){super(e,t);this.plugin=t}display(){let{containerEl:e}=this;e.empty(),e.createEl("h2",{text:this.plugin.appName}),new T.Setting(e).setName("Auto-update plugins at startup").setDesc("If enabled all beta plugins will be checked for updates each time Obsidian starts.").addToggle(t=>{t.setValue(this.plugin.settings.updateAtStartup),t.onChange(s=>a(this,null,function*(){this.plugin.settings.updateAtStartup=s,yield this.plugin.saveSettings()}))}),new T.Setting(e).setName("Auto-update themes at startup").setDesc("If enabled all beta themes will be checked for updates each time Obsidian starts.").addToggle(t=>{t.setValue(this.plugin.settings.updateThemesAtStartup),t.onChange(s=>a(this,null,function*(){this.plugin.settings.updateThemesAtStartup=s,yield this.plugin.saveSettings()}))}),new T.Setting(e).setName("Ribbon Button").setDesc("Toggle ribbon button off and on.").addToggle(t=>{t.setValue(this.plugin.settings.ribbonIconEnabled),t.onChange(s=>a(this,null,function*(){this.plugin.settings.ribbonIconEnabled=s,this.plugin.settings.ribbonIconEnabled===!1?this.plugin.ribbonIcon.remove():this.plugin.showRibbonButton(),yield this.plugin.saveSettings()}))}),e.createEl("hr"),e.createEl("h2",{text:"Beta Plugin List"}),e.createEl("div",{text:'The following is a list of beta plugins added via the command palette "Add a beta plugin for testing". '}),e.createEl("p"),e.createEl("div",{text:"Click the x button next to a plugin to remove it from the list."}),e.createEl("p"),e.createEl("span").createEl("b",{text:"Note: "}),e.createSpan({text:"This does not delete the plugin, this should be done from the Community Plugins tab in Settings."}),new T.Setting(e).addButton(t=>{t.setButtonText("Add Beta plugin"),t.onClick(()=>a(this,null,function*(){this.plugin.app.setting.close(),yield this.plu
Pluginhasbeenupdatedfromversion${P.version}to${r.version}.`;this.plugin.log(y+`[ReleaseInfo](https://github.com/${n}/releases/tag/${r.version})`,!1),m(this.plugin,y,30,()=>a(this,null,function*(){window.open(`https://github.com/${n}/releases/tag/${r.version}`)}))}}else s&&m(this.plugin,`No update available for ${n}`,3)}return!0})}reloadPlugin(n){return a(this,null,function*(){let e=this.plugin.app.plugins;try{yield e.disablePlugin(n),yield e.enablePlugin(n)}catch(t){console.log("reload plugin",t)}})}updatePlugin(n,e=!1,t=!1){return a(this,null,function*(){let s=yield this.addPlugin(n,!0,e,t);return s===!1&&e===!1&&m(this.plugin,`${n}
Updateofpluginfailed.`),s})}checkForUpdatesAndInstallUpdates(n=!1,e=!1){return a(this,null,function*(){if((yield z())===!1){console.log("BRAT: No internet detected.");return}let t,s="Checking for plugin updates STARTED";this.plugin.log(s,!0),n&&this.plugin.settings.notificationsEnabled&&(t=new K.Notice(`BRAT
${s}`,3e4));for(let r of this.plugin.settings.pluginList)yield this.updatePlugin(r,e);let o="Checking for plugin updates COMPLETED";this.plugin.log(o,!0),n&&(t.hide(),m(this.plugin,o,10))})}deletePlugin(n){return a(this,null,function*(){let e=`Removed${n}fromBRATpluginlist`;this.plugin.log(e,!0),this.plugin.settings.pluginList=this.plugin.settings.pluginList.filter(t=>t!=n),this.plugin.saveSettings()})}getEnabledDisabledPlugins(n){let e=this.plugin.app.plugins,t=Object.values(e.manifests),s=Object.values(e.plugins).map(o=>o.manifest);return n?t.filter(o=>s.find(r=>o.id===r.id)):t.filter(o=>!s.find(r=>o.id===r.id))}};var At=require("obsidian");function St(){(0,At.addIcon)("BratIcon",'<path fill="currentColor" stroke="currentColor" d="M 41.667969 41.667969 C 41.667969 39.367188 39.800781 37.5 37.5 37.5 C 35.199219 37.5 33.332031 39.367188 33.332031 41.667969 C 33.332031 43.96875 35.199219 45.832031 37.5 45.832031 C 39.800781 45.832031 41.667969 43.96875 41.667969 41.667969 Z M 60.417969 58.582031 C 59.460938 58.023438 58.320312 57.867188 57.25 58.148438 C 56.179688 58.429688 55.265625 59.125 54.707031 60.082031 C 53.746094 61.777344 51.949219 62.820312 50 62.820312 C 48.050781 62.820312 46.253906 61.777344 45.292969 60.082031 C 44.734375 59.125 43.820312 58.429688 42.75 58.148438 C 41.679688 57.867188 40.539062 58.023438 39.582031 58.582031 C 37.597656 59.726562 36.910156 62.257812 38.042969 64.25 C 40.5 68.53125 45.0625 71.171875 50 71.171875 C 54.9375 71.171875 59.5 68.53125 61.957031 64.25 C 63.089844 62.257812 62.402344 59.726562 60.417969 58.582031 Z M 62.5 37.5 C 60.199219 37.5 58.332031 39.367188 58.332031 41.667969 C 58.332031 43.96875 60.199219 45.832031 62.5 45.832031 C 64.800781 45.832031 66.667969 43.96875 66.667969 41.667969 C 66.667969 39.367188 64.800781 37.5 62.5 37.5 Z M 50 8.332031 C 26.988281 8.332031 8.332031 26.988281 8.332031 50 C 8.332031 73.011719 26.988281 91.667969 50 91.667969 C 73.011719 91.667969 91.667969 73.011719 91.667969 50 C 91.667969 26.988281 73.011719 8.332031 50 8.332031 Z M 50 83.332031 C 33.988281 83.402344 20.191406 72.078125 17.136719 56.363281 C 14.078125 40.644531 22.628906 24.976562 37.5 19.042969 C 37.457031 19.636719 37.457031 20.238281 37.5 20.832031 C 37.5 27.738281 43.097656 33.332031 50 33.332031 C 52.300781 33.332031 54.167969 31.46875 54.167969 29.167969 C 54.167969 26.867188 52.300781 25 50 25 C 47.699219 25 45.832031 23.132812 45.832031 20.832031 C 45.832031 18.53125 47.699219 16.667969 50 16.667969 C 68.410156 16.667969 83.332031 31.589844 83.332031 50 C 83.332031 68.410156 68.410156 83.332031 50 83.332031 Z M 50 83.332031 " />')}var $=require("obsidian"),Ht=Kt(_t());function Yt(i,n,e=!1){if(i.settings.debuggingMode&&console.log("BRAT: "+n),i.settings.loggingEnabled){if(i.settings.loggingVerboseEnabled===!1&&e===!0)return;{let t=i.settings.loggingPath+".md",s="[["+(0,$.moment)().format((0,Ht.getDailyNoteSettings)().format).toString()+"]] "+(0,$.moment)().format("HH:mm"),o=$.Platform.isDesktop?window.require("os").hostname():"MOBILE",r=s+" "+o+" "+n.replace(`
`," ")+`
`;setTimeout(()=>a(this,null,function*(){if((yield i.app.vault.adapter.exists(t))===!0){let u=yield i.app.vault.adapter.read(t);r=r+u;let c=i.app.vault.getAbstractFileByPath(t);yield i.app.vault.modify(c,r)}else yield i.app.vault.create(t,r)}),10)}}}var U=class{constructor(n){this.bratCommands=[{id:"BRAT-AddBetaPlugin",icon:"BratIcon",name:"Plugins: Add a beta plugin for testing",showInRibbon:!0,callback:()=>a(this,null,function*(){yield this.plugin.betaPlugins.displayAddNewPluginModal()})},{id:"BRAT-checkForUpdatesAndUpdate",icon:"BratIcon",name:"Plugins: Check for updates to all beta plugins and UPDATE",showInRibbon:!0,callback:()=>a(this,null,function*(){yield this.plugin.betaPlugins.checkForUpdatesAndInstallUpdates(!0,!1)})},{id:"BRAT-checkForUpdatesAndDontUpdate",icon:"BratIcon",name:"Plugins: Only check for updates to beta plugins, but don't Update",showInRibbon:!0,callback:()=>a(this,null,function*(){yield this.plugin.betaPlugins.checkForUpdatesAndInstallUpdates(!0,!0)})},{id:"BRAT-updateOnePlugin",icon:"BratIcon",name:"Plugins: Choose a single plugin to update",showInRibbon:!0,callback:()=>a(this,null,function*(){let n=Object.values(this.plugin.settings.pluginList).map(t=>({display:t,info:t})),e=new v(this.plugin);e.setSuggesterData(n),yield e.display(t=>a(this,null,function*(){let s=`Checkingforupdatesfor${t.info}`;this.plugin.log(s,!0),m(this.plugin,`
${s}`,3),yield this.plugin.betaPlugins.updatePlugin(t.info,!1,!0)}))})},{id:"BRAT-restartPlugin",icon:"BratIcon",name:"Plugins: Restart a plugin that is already installed",showInRibbon:!0,callback:()=>a(this,null,function*(){let n=Object.values(this.plugin.app.plugins.manifests).map(t=>({display:t.id,info:t.id})),e=new v(this.plugin);e.setSuggesterData(n),yield e.display(t=>a(this,null,function*(){m(this.plugin,`${t.info}
Pluginreloading.....`,5),yield this.plugin.betaPlugins.reloadPlugin(t.info)}))})},{id:"BRAT-disablePlugin",icon:"BratIcon",name:"Plugins: Disable a plugin - toggle it off",showInRibbon:!0,callback:()=>a(this,null,function*(){let n=this.plugin.betaPlugins.getEnabledDisabledPlugins(!0).map(t=>({display:`${t.name}(${t.id})`,info:t.id})),e=new v(this.plugin);e.setSuggesterData(n),yield e.display(t=>a(this,null,function*(){this.plugin.log(`${t.display}plugindisabled`,!1),yield this.plugin.app.plugins.disablePlugin(t.info)}))})},{id:"BRAT-enablePlugin",icon:"BratIcon",name:"Plugins: Enable a plugin - toggle it on",showInRibbon:!0,callback:()=>a(this,null,function*(){let n=this.plugin.betaPlugins.getEnabledDisabledPlugins(!1).map(t=>({display:`${t.name}(${t.id})`,info:t.id})),e=new v(this.plugin);e.setSuggesterData(n),yield e.display(t=>a(this,null,function*(){this.plugin.log(`${t.display}pluginenabled`,!1),yield this.plugin.app.plugins.enablePlugin(t.info)}))})},{id:"BRAT-openGitHubZRepository",icon:"BratIcon",name:"Plugins: Open the GitHub repository for a plugin",showInRibbon:!0,callback:()=>a(this,null,function*(){let n=yield mt(),e=Object.values(n).map(o=>({display:`Plugin:${o.name}(${o.repo})`,info:o.repo})),t=Object.values(this.plugin.settings.pluginList).map(o=>({display:"BRAT: "+o,info:o}));e.forEach(o=>t.push(o));let s=new v(this.plugin);s.setSuggesterData(t),yield s.display(o=>a(this,null,function*(){o.info&&window.open(`https://github.com/${o.info}`)}))})},{id:"BRAT-openGitHubRepoTheme",icon:"BratIcon",name:"Themes: Open the GitHub repository for a theme (appearance)",showInRibbon:!0,callback:()=>a(this,null,function*(){let n=yield Y(),e=Object.values(n).map(s=>({display:`Theme: ${s.name} (${s.repo})`,info:s.repo})),t=new v(this.plugin);t.setSuggesterData(e),yield t.display(s=>a(this,null,function*(){s.info&&window.open(`https://github.com/${s.info}`)}))})},{id:"BRAT-opentPluginSettings",icon:"BratIcon",name:"Plugins: Open Plugin Settings Tab",showInRibbon:!0,callback:()=>a(this,null,function*(){let n=this.plugin.app.setting,e=Object.values(n.pluginTabs).map(o=>({display:"Plugin: "+o.name,info:o.id})),t=new v(this.plugin),s=Object.values(n.settingTabs).map(o=>({display:"Core: "+o.name,info:o.id}));e.forEach(o=>s.push(o)),t.setSuggesterData(s),yield t.display(o=>a(this,null,function*(){n.open(),n.openTabById(o.info)}))})},{id:"BRAT-GrabCommunityTheme",icon:"BratIcon",name:"Themes: Grab a community theme",showInRibbon:!0,callback:()=>a(this,null,function*(){return yield Nt(this.plugin)})},{id:"BRAT-GrabBetaTheme",icon:"BratIcon",name:"Themes: Grab a beta theme for testing from a Github repository",showInRibbon:!0,callback:()=>a(this,null,function*(){new S(this.plugin).open()})},{id:"BRAT-updateBetaThemes",icon:"BratIcon",name:"Themes: Update beta themes",showInRibbon:!0,callback:()=>a(this,null,function*(){return yield J(this.plugin,!0)})},{id:"BRAT-switchTheme",icon:"BratIcon",name:"Themes: Switch Active Theme ",showInRibbon:!0,callback:()=>a(this,null,function*(){let n=Object.values(this.plugin.app.customCss.themes).map(t=>({display:t,info:t}));n.unshift({display:"Obsidian Default Theme",info:""});let e=new v(this.plugin);e.setSuggesterData(n),yield e.display(t=>a(this,null,function*(){this.plugin.log(`Switched to theme ${t.display}`,!1),this.plugin.app.customCss.setTheme(t.info)}))})},{id:"BRAT-allCommands",icon:"BratIcon",name:"All Commands list",showInRibbon:!1,callback:()=>a(this,null,function*(){return this.ribbonDisplayCommands()})}];this.plugin=n,this.bratCommands.forEach(e=>a(this,null,function*(){this.plugin.addCommand({id:e.id,name:e.name,icon:e.icon,callback:()=>a(this,null,function*(){yield e.callback()})})}))}ribbonDisplayCommands(){return a(this,null,function*(){let n=[];this.bratCommands.forEach(r=>{r.showInRibbon&&n.push({display:r.name,info:r.callback})});let e=new v(this.plugin),t=this.plugin.app.setting,s=Object.values(t.settingTabs).map(r=>({display:"Core: "+r.name,info:()=>a(this,null,function*(){t.open(),t.openTabById(r.id)})})),o=Object.values(t.pluginTabs).map(r=>({display:"Plugi