${s}`,e*1e3);n&&(o.noticeEl.oncontextmenu=()=>a(this,null,function*(){n()}))}function X(){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 x=(i,t,e)=>a(void 0,null,function*(){let n=yield L(t,!0,i.settings.debuggingMode);if(n||(n=yield L(t,!1,i.settings.debuggingMode)),!n)return p(i,"There is no theme.css or theme-beta.css file in the root path of this repository, so there is no theme to install."),!1;let s=yield be(t,i.settings.debuggingMode);if(!s)return p(i,"There is no manifest.json file in the root path of this repository, so theme cannot be installed."),!1;let o=yield JSON.parse(s),r=(0,N.normalizePath)(it(i)+o.name),l=i.app.vault.adapter;(yield l.exists(r))===!1&&(yield l.mkdir(r)),yield l.write((0,N.normalizePath)(r+"/theme.css"),n),yield l.write((0,N.normalizePath)(r+"/manifest.json"),s),Se(i,t,M(n));let g="";return e?(yield ve(i,t,n),g=`${o.name}themeinstalledfrom${t}.`,setTimeout(()=>{i.app.customCss.setTheme(o.name)},500)):g=`${o.name}themeupdatedfrom${t}.`,i.log(g+`[ThemeInfo](https://github.com/${t})`,!1),p(i,`${g}`,20,()=>a(void 0,null,function*(){window.open(`https://github.com/${t}`)})),!0}),I=(i,t)=>a(void 0,null,function*(){if((yield X())===!1){console.log("BRAT: No internet detected.");return}let e,n="Checking for beta theme updates STARTED";i.log(n,!0),t&&i.settings.notificationsEnabled&&(e=new N.Notice(`BRAT
${n}`,3e4));for(let o of i.settings.themesList){let r=yield R(o.repo,!0,i.settings.debuggingMode);r==="0"&&(r=yield R(o.repo,!1,i.settings.debuggingMode)),r!==o.lastUpdate&&(yield x(i,o.repo,!1))}let s="Checking for beta theme updates COMPLETED";i.log(s,!0),t&&(i.settings.notificationsEnabled&&e.hide(),p(i,s))}),ee=(i,t)=>a(void 0,null,function*(){i.settings.themesList=i.settings.themesList.filter(n=>n.repo!=t),i.saveSettings();let e=`Removed${t}fromBRATthemeslistandwillnolongerbeupdated.However,thethemefilesstillexistinthevault.Toremovethem,gointoSettings>Appearanceandremovethetheme.`;i.log(e,!0),p(i,`${e}`)}),it=i=>(0,N.normalizePath)(i.app.vault.configDir+"/themes")+"/";var te=require("obsidian");var k=(i,t=!0)=>{let e=t?40:30,n=i.createEl("div");n.style.float="right",t===!1?(n.style.padding="10px",n.style.paddingLeft="15px",n.style.paddingRight="15px"):(n.style.padding="15px",n.style.paddingLeft="15px",n.style.paddingRight="15px",n.style.marginLeft="15px");let s=n.createSpan("coffee");s.addClass("ex-coffee-span");let r=s.createEl("a",{href:"https://bit.ly/o42-kofi"}).createEl("img",{attr:{src:"https://cdn.ko-fi.com/cdn/kofi3.png?v=3"}});r.height=e;let l=n.createSpan("coffee");l.addClass("ex-twitter-span"),l.style.paddingLeft="10px";let u=l.createEl("a",{href:"https://bit.ly/o42-twitter"}).createEl("img",{attr:{src:"https://cdn.cdnlogo.com/logos/t/96/twitter-icon.svg"}});u.height=e;let m=n.createSpan("coffee");m.addClass("ex-twitter-span"),m.style.paddingLeft="10px",m.style.right="0";let h=m.createEl("a",{href:"https://bit.ly/o42-medium"}).createEl("img",{attr:{src:"https://miro.medium.com/v2/resize:fill:176:176/1*sHhtYhaCe2Uc3IU0IgKwIQ.png"}});return h.height=e,n};var E=class extends te.Modal{constructor(e,n=!1){super(e.app);this.plugin=e,this.address="",this.openSettingsTabAfterwards=n}submitForm(){return a(this,null,function*(){if(this.address==="")return;let e=this.address.replace("https://github.com/","");if(yield Ce(this.plugin,e)){p(this.plugin,"This plugin is already in the list for beta testing",10);return}(yield x(this.plugin,e,!0))&&this.close()})}onOpen(){this.contentEl.createEl("h4",{text:"Github repository for beta theme:"}),this.contentEl.createEl("form",{},e=>{e.addClass("brat-modal"),new te.Setting(e).addText(o=>{o.setPlaceholder("Repository (example: https://github.com/GitubUserName/repository-name"),o.onChange(r=>{this.address=r.trim()}),o.inputEl.addEventListener("keydown",r=>a(this,null,function*(){r.key==="Enter"&&this.address!==" "&&(r.preventDefault(),yield this.submitForm())})),o.inputEl.style.width="100%",window.setTimeout(()=>{let r=document.querySelector(".setting-item-info");r&&r.remove(),o.inputEl.focus()},10)}),e.createDiv("modal-button-container",o=>{o.createEl("button",{attr:{type:"button"},text:"Never mind"}).addEventListener("click",()=>this.close()),o.createEl("button",{attr:{type:"submit"},cls:"mod-cta",text:"Add Theme"})});let n=e.createDiv();n.style.borderTop="1px solid #ccc",n.style.marginTop="30px";let s=n.createSpan();s.innerHTML="BRAT by <a href='https://bit.ly/o42-twitter'>TFTHacker</a>",s.style.fontStyle="italic",n.appendChild(s),k(n,!1),window.setTimeout(()=>{e.querySelectorAll(".brat-modal .setting-item-info").forEach(r=>{r.remove()})},50),e.addEventListener("submit",o=>a(this,null,function*(){o.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 ne=class extends v.PluginSettingTab{constructor(e,n){super(e,n);this.plugin=n}display(){let{containerEl:e}=this;e.empty(),k(e,!0),e.createEl("h1",{text:this.plugin.appName}),e.createEl("h2",{text:"by TfTHacker"}),new v.Setting(e).setName("Auto-update plugins at startup").setDesc("If enabled all beta plugins will be checked for updates each time Obsidian starts. Note: this does not update frozen version plugins.").addToggle(s=>{s.setValue(this.plugin.settings.updateAtStartup),s.onChange(o=>a(this,null,func
Pluginhasbeenupdatedfromversion${T.version}to${l.version}.`;this.plugin.log(b+`[ReleaseInfo](https://github.com/${t}/releases/tag/${l.version})`,!1),p(this.plugin,b,30,()=>a(this,null,function*(){window.open(`https://github.com/${t}/releases/tag/${l.version}`)}))}}else s&&p(this.plugin,`No update available for ${t}`,3)}return!0})}reloadPlugin(t){return a(this,null,function*(){let e=this.plugin.app.plugins;try{yield e.disablePlugin(t),yield e.enablePlugin(t)}catch(n){this.plugin.settings.debuggingMode&&console.log("reload plugin",n)}})}updatePlugin(t,e=!1,n=!1){return a(this,null,function*(){let s=yield this.addPlugin(t,!0,e,n);return s===!1&&e===!1&&p(this.plugin,`${t}
Updateofpluginfailed.`),s})}checkForUpdatesAndInstallUpdates(t=!1,e=!1){return a(this,null,function*(){if((yield X())===!1){console.log("BRAT: No internet detected.");return}let n,s="Checking for plugin updates STARTED";this.plugin.log(s,!0),t&&this.plugin.settings.notificationsEnabled&&(n=new A.Notice(`BRAT
${s}`,3e4));let o=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(l=>l.repo));for(let l of this.plugin.settings.pluginList)o.has(l)||(yield this.updatePlugin(l,e));let r="Checking for plugin updates COMPLETED";this.plugin.log(r,!0),t&&(n.hide(),p(this.plugin,r,10))})}deletePlugin(t){return a(this,null,function*(){let e=`Removed${t}fromBRATpluginlist`;this.plugin.log(e,!0),this.plugin.settings.pluginList=this.plugin.settings.pluginList.filter(n=>n!=t),this.plugin.settings.pluginSubListFrozenVersion=this.plugin.settings.pluginSubListFrozenVersion.filter(n=>n.repo!=t),this.plugin.saveSettings()})}getEnabledDisabledPlugins(t){let e=this.plugin.app.plugins,n=Object.values(e.manifests),s=Object.values(e.plugins).map(o=>o.manifest);return t?n.filter(o=>s.find(r=>o.id===r.id)):n.filter(o=>!s.find(r=>o.id===r.id))}};var Fe=require("obsidian");function Ae(){(0,Fe.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 J=require("obsidian"),_e=Ze(ze());function He(i,t,e=!1){if(i.settings.debuggingMode&&console.log("BRAT: "+t),i.settings.loggingEnabled){if(i.settings.loggingVerboseEnabled===!1&&e===!0)return;{let n=i.settings.loggingPath+".md",s="[["+(0,J.moment)().format((0,_e.getDailyNoteSettings)().format).toString()+"]] "+(0,J.moment)().format("HH:mm"),o=J.Platform.isDesktop?window.require("os").hostname():"MOBILE",r=s+" "+o+" "+t.replace(`
`;setTimeout(()=>a(this,null,function*(){if((yield i.app.vault.adapter.exists(n))===!0){let l=yield i.app.vault.adapter.read(n);r=r+l;let g=i.app.vault.getAbstractFileByPath(n);yield i.app.vault.modify(g,r)}else yield i.app.vault.create(n,r)}),10)}}}var Ve=require("obsidian");var S=class extends Ve.FuzzySuggestModal{constructor(e){super(e.app);this.scope.register(["Shift"],"Enter",n=>this.enterTrigger(n)),this.scope.register(["Ctrl"],"Enter",n=>this.enterTrigger(n))}setSuggesterData(e){this.data=e}display(e){return a(this,null,function*(){this.callbackFunction=e,this.open()})}getItems(){return this.data}getItemText(e){return e.display}onChooseItem(){}renderSuggestion(e,n){n.createEl("div",{text:e.item.display})}enterTrigger(e){let n=document.querySelector(".suggestion-item.is-selected div").textContent,s=this.data.find(o=>o.display===n);s&&(this.invokeCallback(s,e),this.close())}onChooseSuggestion(e,n){this.invokeCallback(e.item,n)}invokeCallback(e,n){this.callbackFunction(e,n)}};var W=class{constructor(t){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(!1,!1)})},{id:"BRAT-AddBetaPluginWithFrozenVersion",icon:"BratIcon",name:"Plugins: Add a beta plugin with frozen version based on a release tag",showInRibbon:!0,callback:()=>a(this,null,function*(){yield this.plugin.betaPlugins.displayAddNewPluginModal(!1,!0)})},{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 version to update",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(s=>s.repo)),e=Object.values(this.plugin.settings.pluginList).filter(s=>!t.has(s)).map(s=>({display:s,info:s})),n=new S(this.plugin);n.setSuggesterData(e),yield n.display(s=>a(this,null,function*(){let o=`Checkingforupdatesfor${s.info}`;this.plugin.log(o,!0),p(this.plugin,`
${o}`,3),yield this.plugin.betaPlugins.updatePlugin(s.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 t=Object.values(this.plugin.app.plugins.manifests).map(n=>({display:n.id,info:n.id})),e=new S(this.plugin);e.setSuggesterData(t),yield e.display(n=>a(this,null,function*(){p(this.plugin,`${n.info}
Pluginreloading.....`,5),yield this.plugin.betaPlugins.reloadPlugin(n.info)}))})},{id:"BRAT-disablePlugin",icon:"BratIcon",name:"Plugins: Disable a plugin - toggle it off",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=this.plugin.betaPlugins.getEnabledDisabledPlugins(!0).map(n=>({display:`${n.name}(${n.id})`,info:n.id})),e=new S(this.plugin);e.setSuggesterData(t),yield e.display(n=>a(this,null,function*(){this.plugin.log(`${n.display}plugindisabled`,!1),this.plugin.settings.debuggingMode&&console.log(n.info),yield this.plugin.app.plugins.disablePluginAndSave(n.info)}))})},{id:"BRAT-enablePlugin",icon:"BratIcon",name:"Plugins: Enable a plugin - toggle it on",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=this.plugin.betaPlugins.getEnabledDisabledPlugins(!1).map(n=>({display:`${n.name}(${n.id})`,info:n.id})),e=new S(this.plugin);e.setSuggesterData(t),yield e.display(n=>a(this,null,function*(){this.plugin.log(`${n.display}pluginenabled`,!1),yield this.plugin.app.plugins.enablePluginAndSave(n.info)}))})},{id:"BRAT-openGitHubZRepository",icon:"BratIcon",name:"Plugins: Open the GitHub repository for a plugin",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=yield fe(this.plugin.settings.debuggingMode),e=Object.values(t).map(o=>({display:`Plugin:${o.name}(${o.repo})`,info:o.repo})),n=Object.values(this.plugin.settings.pluginList).map(o=>({display:"BRAT: "+o,info:o}));e.forEach(o=>n.push(o));let s=new S(this.plugin);s.setSuggesterData(n),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 t=yield he(this.plugin.settings.debuggingMode),e=Object.values(t).map(s=>({display:`Theme: ${s.name} (${s.repo})`,info:s.repo})),n=new S(this.plugin);n.setSuggesterData(e),yield n.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 t=this.plugin.app.setting,e=Object.values(t.pluginTabs).map(o=>({display:"Plugin: "+o.name,info:o.id})),n=new S(this.plugin),s=Object.values(t.settingTabs).map(o=>({display:"Core: "+o.name,info:o.id}));e.forEach(o=>s.push(o)),n.setSuggesterData(s),yield n.display(o=>a(this,null,function*(){t.open(),t.openTabById(o.info)}))})},{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 E(this.plugin).open()})},{id:"BRAT-updateBetaThemes",icon:"BratIcon",name:"Themes: Update beta themes",showInRibbon:!0,callback:()=>a(this,null,function*(){return yield I(this.plugin,!0)})},{id:"BRAT-allCommands",icon:"BratIcon",name:"All Commands list",showInRibbon:!1,callback:()=>a(this,null,function*(){return this.ribbonDisplayCommands()})}];this.plugin=t,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 t=[];this.bratCommands.forEach(r=>{r.showInRibbon&&t.push({display:r.name,info:r.callback})});let e=new S(this.plugin),n=this.plugin.app.setting,s=Object.values(n.settingTabs).map(r=>({display:"Core: "+r.name,info:()=>a(this,null,function*(){n.open(),n.openTabById(r.id)})})),o=Object.values(n.pluginTabs).map(r=>({display:"Plugin: "+r.name,info:()=>a(this,null,function*(){n.open(),n.openTabById(r.id)})}));t.push({display:"---- Core Plugin Settings ----",info:()=>a(this,null,function*(){yield this.ribbonDisplayCommands()})}),s.forEach(r=>t.push(r)),t.push({display:"---- Plugin Settings ----",info:()=>a(this,null,function*(){yield this.ribbonDisplayCommands()})}),o.forEach(r=>t.push(r)),e.setSuggesterData(t),yield e.display(r=>a(this,null,function*(){return yield r.info()}))})}};var Q=class{constructor(t){th