"use strict";var qt=Object.create;var Q=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty;var Gt=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),Zt=(s,t)=>{for(var n in t)Q(s,n,{get:t[n],enumerable:!0})},pt=(s,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Wt(t))!Kt.call(s,i)&&i!==n&&Q(s,i,{get:()=>t[i],enumerable:!(e=Jt(t,i))||e.enumerable});return s};var Xt=(s,t,n)=>(n=s!=null?qt(Qt(s)):{},pt(t||!s||!s.__esModule?Q(n,"default",{value:s,enumerable:!0}):n,s)),te=s=>pt(Q({},"__esModule",{value:!0}),s);var Ht=Gt(u=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0});var b=require("obsidian"),rt="YYYY-MM-DD",lt="gggg-[W]ww",It="YYYY-MM",Et="YYYY-[Q]Q",Bt="YYYY";function _(s){var n,e;let t=window.app.plugins.getPlugin("periodic-notes");return t&&((e=(n=t.settings)==null?void 0:n[s])==null?void 0:e.enabled)}function H(){var s,t,n,e;try{let{internalPlugins:i,plugins:o}=window.app;if(_("daily")){let{format:r,folder:p,template:T}=((t=(s=o.getPlugin("periodic-notes"))==null?void 0:s.settings)==null?void 0:t.daily)||{};return{format:r||rt,folder:(p==null?void 0:p.trim())||"",template:(T==null?void 0:T.trim())||""}}let{folder:a,format:l,template:g}=((e=(n=i.getPluginById("daily-notes"))==null?void 0:n.instance)==null?void 0:e.options)||{};return{format:l||rt,folder:(a==null?void 0:a.trim())||"",template:(g==null?void 0:g.trim())||""}}catch(i){console.info("No custom daily note settings found!",i)}}function V(){var s,t,n,e,i,o,a;try{let l=window.app.plugins,g=(s=l.getPlugin("calendar"))==null?void 0:s.options,r=(n=(t=l.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:n.weekly;if(_("weekly"))return{format:r.format||lt,folder:((e=r.folder)==null?void 0:e.trim())||"",template:((i=r.template)==null?void 0:i.trim())||""};let p=g||{};return{format:p.weeklyNoteFormat||lt,folder:((o=p.weeklyNoteFolder)==null?void 0:o.trim())||"",template:((a=p.weeklyNoteTemplate)==null?void 0:a.trim())||""}}catch(l){console.info("No custom weekly note settings found!",l)}}function Y(){var t,n,e,i;let s=window.app.plugins;try{let o=_("monthly")&&((n=(t=s.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:n.monthly)||{};return{format:o.format||It,folder:((e=o.folder)==null?void 0:e.trim())||"",template:((i=o.template)==null?void 0:i.trim())||""}}catch(o){console.info("No custom monthly note settings found!",o)}}function j(){var t,n,e,i;let s=window.app.plugins;try{let o=_("quarterly")&&((n=(t=s.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:n.quarterly)||{};return{format:o.format||Et,folder:((e=o.folder)==null?void 0:e.trim())||"",template:((i=o.template)==null?void 0:i.trim())||""}}catch(o){console.info("No custom quarterly note settings found!",o)}}function q(){var t,n,e,i;let s=window.app.plugins;try{let o=_("yearly")&&((n=(t=s.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:n.yearly)||{};return{format:o.format||Bt,folder:((e=o.folder)==null?void 0:e.trim())||"",template:((i=o.template)==null?void 0:i.trim())||""}}catch(o){console.info("No custom yearly note settings found!",o)}}function Lt(...s){let t=[];for(let e=0,i=s.length;e{let it=e(),st=s.clone().set({hour:it.get("hour"),minute:it.get("minute"),second:it.get("second")});return f&&st.add(parseInt(w,10),h),P?st.format(P.substring(1).trim()):st.format(o)}).replace(/{{\s*yesterday\s*}}/gi,s.clone().subtract(1,"day").format(o)).replace(/{{\s*tomorrow\s*}}/gi,s.clone().add(1,"d").format(o)));return t.foldManager.save(T,g),T}catch(T){console.error(`Failed to create file: '${p}'`,T),new b.Notice("Unable to create new file.")}}function ue(s,t){var n;return(n=t[A(s,"day")])!=null?n:null}function ce(){let{vault:s}=window.app,{folder:t}=H(),n=s.getAbstractFileByPath(b.normalizePath(t));if(!n)throw new gt("Failed to find daily notes folder");let e={};return b.Vault.recurseChildren(n,i=>{if(i instanceof b.TFile){let o=D(i,"day");if(o){let a=A(o,"day");e[a]=i}}}),e}var ut=class extends Error{};function de(){let{moment:s}=window,t=s.localeData()._week.dow,n=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];for(;t;)n.push(n.shift()),t--;return n}function me(s){return de().indexOf(s.toLowerCase())}async function xt(s){let{vault:t}=window.app,{template:n,format:e,folder:i}=V(),[o,a]=await L(n),l=s.format(e),g=await J(i,l);try{let r=await t.create(g,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,T,c,m,f,w)=>{let h=window.moment(),P=s.clone().set({hour:h.get("hour"),minute:h.get("minute"),second:h.get("second")});return c&&P.add(parseInt(m,10),f),w?P.format(w.substring(1).trim()):P.format(e)}).replace(/{{\s*title\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi,(p,T,c)=>{let m=me(T);return s.weekday(m).format(c.trim())}));return window.app.foldManager.save(r,a),r}catch(r){console.error(`Failed to create file: '${g}'`,r),new b.Notice("Unable to create new file.")}}function pe(s,t){var n;return(n=t[A(s,"week")])!=null?n:null}function fe(){let s={};if(!Ot())return s;let{vault:t}=window.app,{folder:n}=V(),e=t.getAbstractFileByPath(b.normalizePath(n));if(!e)throw new ut("Failed to find weekly notes folder");return b.Vault.recurseChildren(e,i=>{if(i instanceof b.TFile){let o=D(i,"week");if(o){let a=A(o,"week");s[a]=i}}}),s}var ct=class extends Error{};async function Rt(s){let{vault:t}=window.app,{template:n,format:e,folder:i}=Y(),[o,a]=await L(n),l=s.format(e),g=await J(i,l);try{let r=await t.create(g,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,T,c,m,f,w)=>{let h=window.moment(),P=s.clone().set({hour:h.get("hour"),minute:h.get("minute"),second:h.get("second")});return c&&P.add(parseInt(m,10),f),w?P.format(w.substring(1).trim()):P.format(e)}).replace(/{{\s*date\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,l));return window.app.foldManager.save(r,a),r}catch(r){console.error(`Failed to create file: '${g}'`,r),new b.Notice("Unable to create new file.")}}function he(s,t){var n;return(n=t[A(s,"month")])!=null?n:null}function be(){let s={};if(!Ut())return s;let{vault:t}=window.app,{folder:n}=Y(),e=t.getAbstractFileByPath(b.normalizePath(n));if(!e)throw new ct("Failed to find monthly notes folder");return b.Vault.recurseChildren(e,i=>{if(i instanceof b.TFile){let o=D(i,"month");if(o){let a=A(o,"month");s[a]=i}}}),s}var dt=class extends Error{};async function we(s){let{vault:t}=window.app,{template:n,format:e,folder:i}=j(),[o,a]=await L(n),l=s.format(e),g=await J(i,l);try{let r=await t.create(g,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,T,c,m,f,w)=>{let h=window.moment(),P=s.clone().set({hour:h.get("hour"),minute:h.get("minute"),second:h.get("second")});return c&&P.add(parseInt(m,10),f),w?P.format(w.substring(1).trim()):P.format(e)}).replace(/{{\s*date\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,l));return window.app.foldManager.save(r,a),r}catch(r){console.error(`Failed to create file: '${g}'`,r),new b.Notice("Unable to create new file.")}}function ye(s,t){var n;return(n=t[A(s,"quarter")])!=null?n:null}function Te(){let s={};if(!zt())return s;let{vault:t}=window.app,{folder:n}=j(),e=t.getAbstractFileByPath(b.normalizePath(n));if(!e)throw new dt("Failed to find quarterly notes folder");return b.Vault.recurseChildren(e,i=>{if(i instanceof b.TFile){let o=D(i,"quarter");if(o){let a=A(o,"quarter");s[a]=i}}}),s}var mt=class extends Error{};async function Pe(s){let{vault:t}=window.app,{template:n,format:e,folder:i}=q(),[o,a]=await L(n),l=s.format(e),g=await J(i,l);try{let r=await t.create(g,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,T,c,m,f,w)=>{let h=window.moment(),P=s.clone().set({hour:h.get("hour"),minute:h.get("minute"),second:h.get("second")});return c&&P.add(parseInt(m,10),f),w?P.format(w.substring(1).trim()):P.format(e)}).replace(/{{\s*date\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,l));return window.app.foldManager.save(r,a),r}catch(r){console.error(`Failed to create file: '${g}'`,r),new b.Notice("Unable to create new file.")}}function ve(s,t){var n;return(n=t[A(s,"year")])!=null?n:null}function Ce(){let s={};if(!_t())return s;let{vault:t}=window.app,{folder:n}=q(),e=t.getAbstractFileByPath(b.normalizePath(n));if(!e)throw new mt("Failed to find yearly notes folder");return b.Vault.recurseChildren(e,i=>{if(i instanceof b.TFile){let o=D(i,"year");if(o){let a=A(o,"year");s[a]=i}}}),s}function Ae(){var e,i;let{app:s}=window,t=s.internalPlugins.plugins["daily-notes"];if(t&&t.enabled)return!0;let n=s.plugins.getPlugin("periodic-notes");return n&&((i=(e=n.settings)==null?void 0:e.daily)==null?void 0:i.enabled)}function Ot(){var n,e;let{app:s}=window;if(s.plugins.getPlugin("calendar"))return!0;let t=s.plugins.getPlugin("periodic-notes");return t&&((e=(n=t.settings)==null?void 0:n.weekly)==null?void 0:e.enabled)}function Ut(){var n,e;let{app:s}=window,t=s.plugins.getPlugin("periodic-notes");return t&&((e=(n=t.settings)==null?void 0:n.monthly)==null?void 0:e.enabled)}function zt(){var n,e;let{app:s}=window,t=s.plugins.getPlugin("periodic-notes");return t&&((e=(n=t.settings)==null?void 0:n.quarterly)==null?void 0:e.enabled)}function _t(){var n,e;let{app:s}=window,t=s.plugins.getPlugin("periodic-notes");return t&&((e=(n=t.settings)==null?void 0:n.yearly)==null?void 0:e.enabled)}function Fe(s){let t={day:H,week:V,month:Y,quarter:j,year:q}[s];return t()}function Se(s,t){return{day:$t,month:Rt,week:xt}[s](t)}u.DEFAULT_DAILY_NOTE_FORMAT=rt;u.DEFAULT_MONTHLY_NOTE_FORMAT=It;u.DEFAULT_QUARTERLY_NOTE_FORMAT=Et;u.DEFAULT_WEEKLY_NOTE_FORMAT=lt;u.DEFAULT_YEARLY_NOTE_FORMAT=Bt;u.appHasDailyNotesPluginLoaded=Ae;u.appHasMonthlyNotesPluginLoaded=Ut;u.appHasQuarterlyNotesPluginLoaded=zt;u.appHasWeeklyNotesPluginLoaded=Ot;u.appHasYearlyNotesPluginLoaded=_t;u.createDailyNote=$t;u.createMonthlyNote=Rt;u.createPeriodicNote=Se;u.createQuarterlyNote=we;u.createWeeklyNote=xt;u.createYearlyNote=Pe;u.getAllDailyNotes=ce;u.getAllMonthlyNotes=be;u.getAllQuarterlyNotes=Te;u.getAllWeeklyNotes=fe;u.getAllYearlyNotes=Ce;u.getDailyNote=ue;u.getDailyNoteSettings=H;u.getDateFromFile=D;u.getDateFromPath=ge;u.getDateUID=A;u.getMonthlyNote=he;u.getMonthlyNoteSettings=Y;u.getPeriodicNoteSettings=Fe;u.getQuarterlyNote=ye;u.getQuarterlyNoteSettings=j;u.getTemplateInfo=L;u.getWeeklyNote=pe;u.getWeeklyNoteSettings=V;u.getYearlyNote=ve;u.getYearlyNoteSettings=q});var Ne={};Zt(Ne,{default:()=>nt});module.exports=te(Ne);var jt=require("obsidian");var F=require("obsidian");var v=require("obsidian"),ee="https://raw.githubusercontent.com/",ne=async(s,t=!0,n="")=>{let e=`https://api.github.com/repos/${s}`;try{let i=await(0,v.request)({url:e,headers:n?{Authorization:`Token ${n}`}:{}});return(await JSON.parse(i)).private}catch(i){return t&&console.log("error in isPrivateRepo",e,i),!1}},K=async(s,t,n,e=!0,i="")=>{try{if(await ne(s,e,i)){let g=`https://api.github.com/repos/${s}/releases`,r=await(0,v.request)({url:g,headers:{Authorization:`Token ${i}`}}),T=(await JSON.parse(r)).find(f=>f.tag_name===t);if(!T)return null;let c=T.assets.find(f=>f.name===n);if(!c)return null;let m=await(0,v.request)({url:c.url,headers:{Authorization:`Token ${i}`,Accept:"application/octet-stream"}});return m==="Not Found"||m==='{"error":"Not Found"}'?null:m}let a=`https://github.com/${s}/releases/download/${t}/${n}`,l=await(0,v.request)({url:a,headers:i?{Authorization:`Token ${i}`}:{}});return l==="Not Found"||l==='{"error":"Not Found"}'?null:l}catch(o){return e&&console.log("error in grabReleaseFileFromRepository",URL,o),null}},ft=async(s,t=!0,n=!0,e="")=>{let i=ee+s+(t?"/HEAD/manifest.json":"/HEAD/manifest-beta.json");n&&console.log("grabManifestJsonFromRepository manifestJsonPath",i);let o=async l=>{try{return await(0,v.request)({url:"https://api.github.com/user",method:"GET",headers:{Authorization:`token ${l}`,"User-Agent":"request",accept:"application/vnd.github.v3+json"}}),!0}catch(g){return n&&console.log("Token validation error:",g),!1}},a=!1;e&&(a=await o(e),n&&console.log("Token valid:",a));try{let l=await(0,v.request)({url:i,headers:a?{Authorization:`Token ${e}`}:{}});return n&&console.log("grabManifestJsonFromRepository response",l),l==="404: Not Found"?null:await JSON.parse(l)}catch(l){return l!=="Error: Request failed, status 404"&&n&&console.log(`error in grabManifestJsonFromRepository for ${i}`,l),null}},ht=async(s=!0)=>{let t="https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-plugins.json";try{let n=await(0,v.request)({url:t});return n==="404: Not Found"?null:await JSON.parse(n)}catch(n){return s&&console.log("error in grabCommmunityPluginList",n),null}},bt=async(s=!0)=>{let t="https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-css-themes.json";try{let n=await(0,v.request)({url:t});return n==="404: Not Found"?null:await JSON.parse(n)}catch(n){return s&&console.log("error in grabCommmunityThemesList",n),null}},I=async(s,t=!1,n=!1)=>{let e=`https://raw.githubusercontent.com/${s}/HEAD/theme${t?"-beta":""}.css`;try{let i=await(0,v.request)({url:e});return i==="404: Not Found"?null:i}catch(i){return n&&console.log("error in grabCommmunityThemeCssFile",i),null}},wt=async(s,t=!0)=>{let n=`https://raw.githubusercontent.com/${s}/HEAD/manifest.json`;try{let e=await(0,v.request)({url:n});return e==="404: Not Found"?null:e}catch(e){return t&&console.log("error in grabCommmunityThemeManifestFile",e),null}},ie=s=>{let t=0;for(let n=0;nie(s).toString(),$=async(s,t,n)=>{let e=await I(s,t,n);return e?M(e):"0"},se=async(s,t,n=!0)=>{let e=`https://api.github.com/repos/${s}/commits?path=${t}&page=1&per_page=1`;try{let i=await(0,v.request)({url:e});return i==="404: Not Found"?null:JSON.parse(i)}catch(i){return n&&console.log("error in grabLastCommitInfoForAFile",i),null}},yt=async(s,t)=>{var e;let n=await se(s,t);return n&&n.length>0&&((e=n[0].commit.committer)!=null&&e.date)?n[0].commit.committer.date:""};var ot={pluginList:[],pluginSubListFrozenVersion:[],themesList:[],updateAtStartup:!0,updateThemesAtStartup:!0,enableAfterInstall:!0,loggingEnabled:!1,loggingPath:"BRAT-log",loggingVerboseEnabled:!1,debuggingMode:!1,notificationsEnabled:!0,personalAccessToken:""};function Tt(s,t,n=""){let e=!1;s.settings.pluginList.contains(t)||(s.settings.pluginList.unshift(t),e=!0),n!==""&&s.settings.pluginSubListFrozenVersion.filter(i=>i.repo===t).length===0&&(s.settings.pluginSubListFrozenVersion.unshift({repo:t,version:n}),e=!0),e&&s.saveSettings()}function Pt(s,t){return s.settings.pluginList.contains(t)}function vt(s,t,n){let e={repo:t,lastUpdate:M(n)};s.settings.themesList.unshift(e),s.saveSettings()}function Ct(s,t){return!!s.settings.themesList.find(e=>e.repo===t)}function At(s,t,n){for(let e of s.settings.themesList)e.repo===t&&(e.lastUpdate=n,s.saveSettings())}var x=require("obsidian");var G=require("obsidian");function d(s,t,n=10,e){if(!s.settings.notificationsEnabled)return;let i=e?G.Platform.isDesktop?"(click=dismiss, right-click=Info)":"(click=dismiss)":"",o=new G.Notice(`BRAT ${t} ${i}`,n*1e3);e&&(o.noticeEl.oncontextmenu=()=>{e()})}var E=(s,t=!0)=>{let n=s.createEl("div");n.style.float="right",t?(n.style.padding="15px",n.style.paddingLeft="15px",n.style.paddingRight="15px",n.style.marginLeft="15px"):(n.style.padding="10px",n.style.paddingLeft="15px",n.style.paddingRight="15px");let e=n.createDiv("coffee");e.addClass("ex-twitter-span"),e.style.paddingLeft="10px";let i=e.createDiv();i.innerText="Learn more about my work at:",e.appendChild(i);let o=e.createEl("a",{href:"https://tfthacker.com"});return o.innerText="https://tfthacker.com",n};var N=class extends x.Modal{constructor(t,n,e=!1,i=!1){super(t.app),this.plugin=t,this.betaPlugins=n,this.address="",this.openSettingsTabAfterwards=e,this.useFrozenVersion=i,this.enableAfterInstall=t.settings.enableAfterInstall,this.version=""}async submitForm(){if(this.address==="")return;let t=this.address.replace("https://github.com/","");if(t.endsWith(".git")&&(t=t.slice(0,-4)),Pt(this.plugin,t)){d(this.plugin,"This plugin is already in the list for beta testing",10);return}await this.betaPlugins.addPlugin(t,!1,!1,!1,this.version,!1,this.enableAfterInstall)&&this.close()}onOpen(){this.contentEl.createEl("h4",{text:"Github repository for beta plugin:"}),this.contentEl.createEl("form",{},t=>{t.addClass("brat-modal"),new x.Setting(t).addText(i=>{i.setPlaceholder("Repository (example: https://github.com/GitubUserName/repository-name)"),i.setValue(this.address),i.onChange(o=>{this.address=o.trim()}),i.inputEl.addEventListener("keydown",o=>{o.key==="Enter"&&this.address!==" "&&(this.useFrozenVersion&&this.version!==""||!this.useFrozenVersion)&&(o.preventDefault(),this.submitForm())}),i.inputEl.style.width="100%"}),this.useFrozenVersion&&new x.Setting(t).addText(i=>{i.setPlaceholder("Specify the release version tag (example: 1.0.0)"),i.onChange(o=>{this.version=o.trim()}),i.inputEl.style.width="100%"}),t.createDiv("modal-button-container",i=>{i.createEl("label",{cls:"mod-checkbox"},o=>{let a=o.createEl("input",{attr:{tabindex:-1},type:"checkbox"});a.checked=this.enableAfterInstall,a.addEventListener("click",()=>{this.enableAfterInstall=a.checked}),o.appendText("Enable after installing the plugin")}),i.createEl("button",{attr:{type:"button"},text:"Never mind"}).addEventListener("click",()=>{this.close()}),i.createEl("button",{attr:{type:"submit"},cls:"mod-cta",text:"Add Plugin"})});let n=t.createDiv();n.style.borderTop="1px solid #ccc",n.style.marginTop="30px";let e=n.createSpan();e.innerHTML="BRAT by TFTHacker",e.style.fontStyle="italic",n.appendChild(e),E(n,!1),window.setTimeout(()=>{let i=t.querySelectorAll(".brat-modal .setting-item-info");for(let o of Array.from(i))o.remove()},50),t.addEventListener("submit",i=>{i.preventDefault(),this.address!==""&&(this.useFrozenVersion&&this.version!==""||!this.useFrozenVersion)&&this.submitForm()})})}onClose(){this.openSettingsTabAfterwards&&(this.plugin.app.setting.open(),this.plugin.app.setting.openTabById(this.plugin.APP_ID))}};var Ft=require("obsidian");async function Z(){try{let s=await(0,Ft.requestUrl)(`https://obsidian.md/?${Math.random()}`);return s.status>=200&&s.status<300}catch(s){return!1}}var R=class{constructor(t){this.plugin=t}displayAddNewPluginModal(t=!1,n=!1){new N(this.plugin,this,t,n).open()}async validateRepository(t,n=!1,e=!1){let o=await ft(t,!n,this.plugin.settings.debuggingMode,this.plugin.settings.personalAccessToken);return o?"id"in o?"version"in o?o:(e&&d(this.plugin,`${t} The version attribute for the release is missing from the manifest file`,15),null):(e&&d(this.plugin,`${t} The plugin id attribute for the release is missing from the manifest file`,15),null):(e&&(d(this.plugin,`${t} This does not seem to be an obsidian plugin, as there is no manifest.json file.`,15),console.error("BRAT: validateRepository",t,n,e)),null)}async getAllReleaseFiles(t,n,e,i=""){let o=i===""?n.version:i,a=e||i!=="";return console.log({reallyGetManifestOrNot:a,version:o}),{mainJs:await K(t,o,"main.js",this.plugin.settings.debuggingMode,this.plugin.settings.personalAccessToken),manifest:a?await K(t,o,"manifest.json",this.plugin.settings.debuggingMode,this.plugin.settings.personalAccessToken):"",styles:await K(t,o,"styles.css",this.plugin.settings.debuggingMode,this.plugin.settings.personalAccessToken)}}async writeReleaseFilesToPluginFolder(t,n){var o,a;let e=`${(0,F.normalizePath)(`${this.plugin.app.vault.configDir}/plugins/${t}`)}/`,{adapter:i}=this.plugin.app.vault;await i.exists(e)||await i.mkdir(e),await i.write(`${e}main.js`,(o=n.mainJs)!=null?o:""),await i.write(`${e}manifest.json`,(a=n.manifest)!=null?a:""),n.styles&&await i.write(`${e}styles.css`,n.styles)}async addPlugin(t,n=!1,e=!1,i=!1,o="",a=!1,l=this.plugin.settings.enableAfterInstall){this.plugin.settings.debuggingMode&&console.log("BRAT: addPlugin",t,n,e,i,o,a,l);let g=10,r=await this.validateRepository(t,!0,!1),p=!!r;if(p||(r=await this.validateRepository(t,!1,!0)),r===null){let c=`${t} A manifest.json or manifest-beta.json file does not exist in the root directory of the repository. This plugin cannot be installed.`;return await this.plugin.log(c,!0),d(this.plugin,c,g),!1}if(!Object.hasOwn(r,"version")){let c=`${t} The manifest${p?"-beta":""}.json file in the root directory of the repository does not have a version number in the file. This plugin cannot be installed.`;return await this.plugin.log(c,!0),d(this.plugin,c,g),!1}if(!Object.hasOwn(r,"minAppVersion")&&!(0,F.requireApiVersion)(r.minAppVersion)){let c=`Plugin: ${t} The manifest${p?"-beta":""}.json for this plugin indicates that the Obsidian version of the app needs to be ${r.minAppVersion}, but this installation of Obsidian is ${F.apiVersion}. You will need to update your Obsidian to use this plugin or contact the plugin developer for more information.`;return await this.plugin.log(c,!0),d(this.plugin,c,30),!1}let T=async()=>{let c=await this.getAllReleaseFiles(t,r,p,o);if(console.log("rFiles",c),(p||c.manifest==="")&&(c.manifest=JSON.stringify(r)),this.plugin.settings.debuggingMode&&console.log("BRAT: rFiles.manifest",p,c),c.mainJs===null){let m=`${t} The release is not complete and cannot be download. main.js is missing from the Release`;return await this.plugin.log(m,!0),d(this.plugin,m,g),null}return c};if(!n||a){let c=await T();if(c===null)return!1;if(await this.writeReleaseFilesToPluginFolder(r.id,c),a||Tt(this.plugin,t,o),l){let{plugins:m}=this.plugin.app,f=(0,F.normalizePath)(`${m.getPluginFolder()}/${r.id}`);await m.loadManifest(f),await m.enablePluginAndSave(r.id)}if(await this.plugin.app.plugins.loadManifests(),a)await this.reloadPlugin(r.id),await this.plugin.log(`${t} reinstalled`,!0),d(this.plugin,`${t} Plugin has been reinstalled and reloaded.`,g);else{let m=o===""?"":` (version: ${o})`,f=`${t}${m} The plugin has been registered with BRAT.`;l||(f+=" You may still need to enable it the Community Plugin List."),await this.plugin.log(f,!0),d(this.plugin,f,g)}}else{let c=`${this.plugin.app.vault.configDir}/plugins/${r.id}/`,m="";try{m=await this.plugin.app.vault.adapter.read(`${c}manifest.json`)}catch(w){if(w.errno===-4058||w.errno===-2)return await this.addPlugin(t,!1,p,!1,o),!0;console.log("BRAT - Local Manifest Load",r.id,JSON.stringify(w,null,2))}if(o!==""||this.plugin.settings.pluginSubListFrozenVersion.map(w=>w.repo).includes(t))return d(this.plugin,`The version of ${t} is frozen, not updating.`,3),!1;let f=await JSON.parse(m);if(f.version!==r.version){let w=await T();if(w===null)return!1;if(e){let h=`There is an update available for ${r.id} from version ${f.version} to ${r.version}. `;await this.plugin.log(`${h}[Release Info](https://github.com/${t}/releases/tag/${r.version})`,!0),d(this.plugin,h,30,()=>{r&&window.open(`https://github.com/${t}/releases/tag/${r.version}`)})}else{await this.writeReleaseFilesToPluginFolder(r.id,w),await this.plugin.app.plugins.loadManifests(),await this.reloadPlugin(r.id);let h=`${r.id} Plugin has been updated from version ${f.version} to ${r.version}. `;await this.plugin.log(`${h}[Release Info](https://github.com/${t}/releases/tag/${r.version})`,!0),d(this.plugin,h,30,()=>{r&&window.open(`https://github.com/${t}/releases/tag/${r.version}`)})}}else i&&d(this.plugin,`No update available for ${t}`,3)}return!0}async reloadPlugin(t){let{plugins:n}=this.plugin.app;try{await n.disablePlugin(t),await n.enablePlugin(t)}catch(e){this.plugin.settings.debuggingMode&&console.log("reload plugin",e)}}async updatePlugin(t,n=!1,e=!1,i=!1){let o=await this.addPlugin(t,!0,n,e,"",i);return!o&&!n&&d(this.plugin,`${t} Update of plugin failed.`),o}async checkForPluginUpdatesAndInstallUpdates(t=!1,n=!1){if(!await Z()){console.log("BRAT: No internet detected.");return}let e,i="Checking for plugin updates STARTED";await this.plugin.log(i,!0),t&&this.plugin.settings.notificationsEnabled&&(e=new F.Notice(`BRAT ${i}`,3e4));let o=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(l=>l.repo));for(let l of this.plugin.settings.pluginList)o.has(l)||await this.updatePlugin(l,n);let a="Checking for plugin updates COMPLETED";await this.plugin.log(a,!0),t&&(e&&e.hide(),d(this.plugin,a,10))}deletePlugin(t){let n=`Removed ${t} from BRAT plugin list`;this.plugin.log(n,!0),this.plugin.settings.pluginList=this.plugin.settings.pluginList.filter(e=>e!==t),this.plugin.settings.pluginSubListFrozenVersion=this.plugin.settings.pluginSubListFrozenVersion.filter(e=>e.repo!==t),this.plugin.saveSettings()}getEnabledDisabledPlugins(t){let n=this.plugin.app.plugins,e=Object.values(n.manifests),i=Object.values(n.plugins).map(o=>o.manifest);return t?e.filter(o=>i.find(a=>o.id===a.id)):e.filter(o=>!i.find(a=>o.id===a.id))}};var k=require("obsidian");var O=async(s,t,n)=>{let e=await I(t,!0,s.settings.debuggingMode);if(e||(e=await I(t,!1,s.settings.debuggingMode)),!e)return d(s,"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 i=await wt(t,s.settings.debuggingMode);if(!i)return d(s,"There is no manifest.json file in the root path of this repository, so theme cannot be installed."),!1;let o=await JSON.parse(i),a=(0,k.normalizePath)(oe(s)+o.name),{adapter:l}=s.app.vault;await l.exists(a)||await l.mkdir(a),await l.write((0,k.normalizePath)(`${a}/theme.css`),e),await l.write((0,k.normalizePath)(`${a}/manifest.json`),i),At(s,t,M(e));let g="";return n?(vt(s,t,e),g=`${o.name} theme installed from ${t}. `,setTimeout(()=>{s.app.customCss.setTheme(o.name)},500)):g=`${o.name} theme updated from ${t}.`,s.log(`${g}[Theme Info](https://github.com/${t})`,!1),d(s,g,20,()=>{window.open(`https://github.com/${t}`)}),!0},B=async(s,t)=>{if(!await Z()){console.log("BRAT: No internet detected.");return}let n,e="Checking for beta theme updates STARTED";await s.log(e,!0),t&&s.settings.notificationsEnabled&&(n=new k.Notice(`BRAT ${e}`,3e4));for(let o of s.settings.themesList){let a=await $(o.repo,!0,s.settings.debuggingMode);a==="0"&&(a=await $(o.repo,!1,s.settings.debuggingMode)),console.log("BRAT: lastUpdateOnline",a),a!==o.lastUpdate&&await O(s,o.repo,!1)}let i="Checking for beta theme updates COMPLETED";(async()=>await s.log(i,!0))(),t&&(s.settings.notificationsEnabled&&n&&n.hide(),d(s,i))},X=(s,t)=>{s.settings.themesList=s.settings.themesList.filter(e=>e.repo!==t),s.saveSettings();let n=`Removed ${t} from BRAT themes list and will no longer be updated. However, the theme files still exist in the vault. To remove them, go into Settings > Appearance and remove the theme.`;s.log(n,!0),d(s,n)},oe=s=>`${(0,k.normalizePath)(`${s.app.vault.configDir}/themes`)}/`;var tt=require("obsidian");var S=class extends tt.Modal{constructor(t,n=!1){super(t.app),this.plugin=t,this.address="",this.openSettingsTabAfterwards=n}async submitForm(){if(this.address==="")return;let t=this.address.replace("https://github.com/","");if(Ct(this.plugin,t)){d(this.plugin,"This theme is already in the list for beta testing",10);return}await O(this.plugin,t,!0)&&this.close()}onOpen(){this.contentEl.createEl("h4",{text:"Github repository for beta theme:"}),this.contentEl.createEl("form",{},t=>{t.addClass("brat-modal"),new tt.Setting(t).addText(i=>{i.setPlaceholder("Repository (example: https://github.com/GitubUserName/repository-name"),i.setValue(this.address),i.onChange(o=>{this.address=o.trim()}),i.inputEl.addEventListener("keydown",o=>{o.key==="Enter"&&this.address!==" "&&(o.preventDefault(),this.submitForm())}),i.inputEl.style.width="100%",window.setTimeout(()=>{let o=document.querySelector(".setting-item-info");o&&o.remove(),i.inputEl.focus()},10)}),t.createDiv("modal-button-container",i=>{i.createEl("button",{attr:{type:"button"},text:"Never mind"}).addEventListener("click",()=>{this.close()}),i.createEl("button",{attr:{type:"submit"},cls:"mod-cta",text:"Add Theme"})});let n=t.createDiv();n.style.borderTop="1px solid #ccc",n.style.marginTop="30px";let e=n.createSpan();e.innerHTML="BRAT by TFTHacker",e.style.fontStyle="italic",n.appendChild(e),E(n,!1),window.setTimeout(()=>{let i=t.querySelectorAll(".brat-modal .setting-item-info");for(let o of Array.from(i))o.remove()},50),t.addEventListener("submit",i=>{i.preventDefault(),this.address!==""&&this.submitForm()})})}onClose(){this.openSettingsTabAfterwards&&(this.plugin.app.setting.openTab(),this.plugin.app.setting.openTabById(this.plugin.APP_ID))}};var St=require("obsidian"),C=class extends St.FuzzySuggestModal{constructor(n){super(n.app);this.data=[];this.scope.register(["Shift"],"Enter",e=>{this.enterTrigger(e)}),this.scope.register(["Ctrl"],"Enter",e=>{this.enterTrigger(e)})}setSuggesterData(n){this.data=n}display(n){this.callbackFunction=n,this.open()}getItems(){return this.data}getItemText(n){return n.display}onChooseItem(){}renderSuggestion(n,e){e.createEl("div",{text:n.item.display})}enterTrigger(n){var o;let e=(o=document.querySelector(".suggestion-item.is-selected div"))==null?void 0:o.textContent,i=this.data.find(a=>a.display===e);i&&(this.invokeCallback(i,n),this.close())}onChooseSuggestion(n,e){this.invokeCallback(n.item,e)}invokeCallback(n,e){typeof this.callbackFunction=="function"&&this.callbackFunction(n,e)}};var U=class{constructor(t){this.bratCommands=[{id:"AddBetaPlugin",icon:"BratIcon",name:"Plugins: Add a beta plugin for testing",showInRibbon:!0,callback:()=>{this.plugin.betaPlugins.displayAddNewPluginModal(!1,!1)}},{id:"AddBetaPluginWithFrozenVersion",icon:"BratIcon",name:"Plugins: Add a beta plugin with frozen version based on a release tag",showInRibbon:!0,callback:()=>{this.plugin.betaPlugins.displayAddNewPluginModal(!1,!0)}},{id:"checkForUpdatesAndUpdate",icon:"BratIcon",name:"Plugins: Check for updates to all beta plugins and UPDATE",showInRibbon:!0,callback:async()=>{await this.plugin.betaPlugins.checkForPluginUpdatesAndInstallUpdates(!0,!1)}},{id:"checkForUpdatesAndDontUpdate",icon:"BratIcon",name:"Plugins: Only check for updates to beta plugins, but don't Update",showInRibbon:!0,callback:async()=>{await this.plugin.betaPlugins.checkForPluginUpdatesAndInstallUpdates(!0,!0)}},{id:"updateOnePlugin",icon:"BratIcon",name:"Plugins: Choose a single plugin version to update",showInRibbon:!0,callback:()=>{let t=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(i=>i.repo)),n=Object.values(this.plugin.settings.pluginList).filter(i=>!t.has(i)).map(i=>({display:i,info:i})),e=new C(this.plugin);e.setSuggesterData(n),e.display(i=>{let o=`Checking for updates for ${i.info}`;this.plugin.log(o,!0),d(this.plugin,` ${o}`,3),this.plugin.betaPlugins.updatePlugin(i.info,!1,!0)})}},{id:"reinstallOnePlugin",icon:"BratIcon",name:"Plugins: Choose a single plugin to reinstall",showInRibbon:!0,callback:()=>{let t=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(i=>i.repo)),n=Object.values(this.plugin.settings.pluginList).filter(i=>!t.has(i)).map(i=>({display:i,info:i})),e=new C(this.plugin);e.setSuggesterData(n),e.display(i=>{let o=`Reinstalling ${i.info}`;d(this.plugin,` ${o}`,3),this.plugin.log(o,!0),this.plugin.betaPlugins.updatePlugin(i.info,!1,!1,!0)})}},{id:"restartPlugin",icon:"BratIcon",name:"Plugins: Restart a plugin that is already installed",showInRibbon:!0,callback:()=>{let t=Object.values(this.plugin.app.plugins.manifests).map(e=>({display:e.id,info:e.id})),n=new C(this.plugin);n.setSuggesterData(t),n.display(e=>{d(this.plugin,`${e.info} Plugin reloading .....`,5),this.plugin.betaPlugins.reloadPlugin(e.info)})}},{id:"disablePlugin",icon:"BratIcon",name:"Plugins: Disable a plugin - toggle it off",showInRibbon:!0,callback:()=>{let t=this.plugin.betaPlugins.getEnabledDisabledPlugins(!0).map(e=>({display:`${e.name} (${e.id})`,info:e.id})),n=new C(this.plugin);n.setSuggesterData(t),n.display(e=>{this.plugin.log(`${e.display} plugin disabled`,!1),this.plugin.settings.debuggingMode&&console.log(e.info),this.plugin.app.plugins.disablePluginAndSave(e.info)})}},{id:"enablePlugin",icon:"BratIcon",name:"Plugins: Enable a plugin - toggle it on",showInRibbon:!0,callback:()=>{let t=this.plugin.betaPlugins.getEnabledDisabledPlugins(!1).map(e=>({display:`${e.name} (${e.id})`,info:e.id})),n=new C(this.plugin);n.setSuggesterData(t),n.display(e=>{this.plugin.log(`${e.display} plugin enabled`,!1),this.plugin.app.plugins.enablePluginAndSave(e.info)})}},{id:"openGitHubZRepository",icon:"BratIcon",name:"Plugins: Open the GitHub repository for a plugin",showInRibbon:!0,callback:async()=>{let t=await ht(this.plugin.settings.debuggingMode);if(t){let n=Object.values(t).map(o=>({display:`Plugin: ${o.name} (${o.repo})`,info:o.repo})),e=Object.values(this.plugin.settings.pluginList).map(o=>({display:`BRAT: ${o}`,info:o}));for(let o of n)e.push(o);let i=new C(this.plugin);i.setSuggesterData(e),i.display(o=>{o.info&&window.open(`https://github.com/${o.info}`)})}}},{id:"openGitHubRepoTheme",icon:"BratIcon",name:"Themes: Open the GitHub repository for a theme (appearance)",showInRibbon:!0,callback:async()=>{let t=await bt(this.plugin.settings.debuggingMode);if(t){let n=Object.values(t).map(i=>({display:`Theme: ${i.name} (${i.repo})`,info:i.repo})),e=new C(this.plugin);e.setSuggesterData(n),e.display(i=>{i.info&&window.open(`https://github.com/${i.info}`)})}}},{id:"opentPluginSettings",icon:"BratIcon",name:"Plugins: Open Plugin Settings Tab",showInRibbon:!0,callback:()=>{let t=this.plugin.app.setting,n=Object.values(t.pluginTabs).map(o=>({display:`Plugin: ${o.name}`,info:o.id})),e=new C(this.plugin),i=Object.values(t.settingTabs).map(o=>({display:`Core: ${o.name}`,info:o.id}));for(let o of n)i.push(o);e.setSuggesterData(i),e.display(o=>{t.open(),t.openTabById(o.info)})}},{id:"GrabBetaTheme",icon:"BratIcon",name:"Themes: Grab a beta theme for testing from a Github repository",showInRibbon:!0,callback:()=>{new S(this.plugin).open()}},{id:"updateBetaThemes",icon:"BratIcon",name:"Themes: Update beta themes",showInRibbon:!0,callback:async()=>{await B(this.plugin,!0)}},{id:"allCommands",icon:"BratIcon",name:"All Commands list",showInRibbon:!1,callback:()=>{this.ribbonDisplayCommands()}}];this.plugin=t;for(let n of this.bratCommands)this.plugin.addCommand({id:n.id,name:n.name,icon:n.icon,callback:()=>{n.callback()}})}ribbonDisplayCommands(){let t=[];for(let a of this.bratCommands)a.showInRibbon&&t.push({display:a.name,info:a.callback});let n=new C(this.plugin),e=this.plugin.app.setting,i=Object.values(e.settingTabs).map(a=>({display:`Core: ${a.name}`,info:()=>{e.open(),e.openTabById(a.id)}})),o=Object.values(e.pluginTabs).map(a=>({display:`Plugin: ${a.name}`,info:()=>{e.open(),e.openTabById(a.id)}}));t.push({display:"---- Core Plugin Settings ----",info:()=>{this.ribbonDisplayCommands()}});for(let a of i)t.push(a);t.push({display:"---- Plugin Settings ----",info:()=>{this.ribbonDisplayCommands()}});for(let a of o)t.push(a);n.setSuggesterData(t),n.display(a=>{typeof a.info=="function"&&a.info()})}};var y=require("obsidian");var at=(s,t)=>{let n=new DocumentFragment,e=document.createElement("a");if(e.textContent=s,e.href=`https://github.com/${s}`,n.appendChild(e),t){let i=document.createTextNode(t);n.appendChild(i)}return n},et=class extends y.PluginSettingTab{constructor(t,n){super(t,n),this.plugin=n}display(){let{containerEl:t}=this;t.empty(),new y.Setting(t).setName("Auto-enable plugins after installation").setDesc('If enabled beta plugins will be automatically enabled after installtion by default. Note: you can toggle this on and off for each plugin in the "Add Plugin" form.').addToggle(e=>{e.setValue(this.plugin.settings.enableAfterInstall),e.onChange(async i=>{this.plugin.settings.enableAfterInstall=i,await this.plugin.saveSettings()})}),new y.Setting(t).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(e=>{e.setValue(this.plugin.settings.updateAtStartup),e.onChange(async i=>{this.plugin.settings.updateAtStartup=i,await this.plugin.saveSettings()})}),new y.Setting(t).setName("Auto-update themes at startup").setDesc("If enabled all beta themes will be checked for updates each time Obsidian starts.").addToggle(e=>{e.setValue(this.plugin.settings.updateThemesAtStartup),e.onChange(async i=>{this.plugin.settings.updateThemesAtStartup=i,await this.plugin.saveSettings()})}),E(t,!0),t.createEl("hr"),new y.Setting(t).setName("Beta plugin list").setHeading(),t.createEl("div",{text:'The following is a list of beta plugins added via the command palette "Add a beta plugin for testing" or "Add a beta plugin with frozen version for testing". A frozen version is a specific release of a plugin based on its release tag. '}),t.createEl("p"),t.createEl("div",{text:"Click the x button next to a plugin to remove it from the list."}),t.createEl("p"),t.createEl("span").createEl("b",{text:"Note: "}),t.createSpan({text:"This does not delete the plugin, this should be done from the Community Plugins tab in Settings."}),new y.Setting(t).addButton(e=>{e.setButtonText("Add Beta plugin"),e.onClick(()=>{this.plugin.app.setting.close(),this.plugin.betaPlugins.displayAddNewPluginModal(!0,!1)})});let n=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(e=>e.repo));for(let e of this.plugin.settings.pluginList)n.has(e)||new y.Setting(t).setName(at(e)).addButton(i=>{i.setIcon("cross"),i.setTooltip("Delete this beta plugin"),i.onClick(()=>{if(i.buttonEl.textContent==="")i.setButtonText("Click once more to confirm removal");else{let{buttonEl:o}=i,{parentElement:a}=o;a!=null&&a.parentElement&&(a.parentElement.remove(),this.plugin.betaPlugins.deletePlugin(e))}})});new y.Setting(t).addButton(e=>{e.setButtonText("Add Beta plugin with frozen version"),e.onClick(()=>{this.plugin.app.setting.close(),this.plugin.betaPlugins.displayAddNewPluginModal(!0,!0)})});for(let e of this.plugin.settings.pluginSubListFrozenVersion)new y.Setting(t).setName(at(e.repo,` (version ${e.version})`)).addButton(i=>{i.setIcon("cross"),i.setTooltip("Delete this beta plugin"),i.onClick(()=>{if(i.buttonEl.textContent==="")i.setButtonText("Click once more to confirm removal");else{let{buttonEl:o}=i,{parentElement:a}=o;a!=null&&a.parentElement&&(a.parentElement.remove(),this.plugin.betaPlugins.deletePlugin(e.repo))}})});new y.Setting(t).setName("Beta themes list").setHeading(),new y.Setting(t).addButton(e=>{e.setButtonText("Add Beta Theme"),e.onClick(()=>{this.plugin.app.setting.close(),new S(this.plugin).open()})});for(let e of this.plugin.settings.themesList)new y.Setting(t).setName(at(e.repo)).addButton(i=>{i.setIcon("cross"),i.setTooltip("Delete this beta theme"),i.onClick(()=>{if(i.buttonEl.textContent==="")i.setButtonText("Click once more to confirm removal");else{let{buttonEl:o}=i,{parentElement:a}=o;a!=null&&a.parentElement&&(a.parentElement.remove(),X(this.plugin,e.repo))}})});new y.Setting(t).setName("Monitoring").setHeading(),new y.Setting(t).setName("Enable Notifications").setDesc("BRAT will provide popup notifications for its various activities. Turn this off means no notifications from BRAT.").addToggle(e=>{e.setValue(this.plugin.settings.notificationsEnabled),e.onChange(async i=>{this.plugin.settings.notificationsEnabled=i,await this.plugin.saveSettings()})}),new y.Setting(t).setName("Enable Logging").setDesc("Plugin updates will be logged to a file in the log file.").addToggle(e=>{e.setValue(this.plugin.settings.loggingEnabled),e.onChange(async i=>{this.plugin.settings.loggingEnabled=i,await this.plugin.saveSettings()})}),new y.Setting(this.containerEl).setName("BRAT Log File Location").setDesc("Logs will be saved to this file. Don't add .md to the file name.").addSearch(e=>{e.setPlaceholder("Example: BRAT-log").setValue(this.plugin.settings.loggingPath).onChange(async i=>{this.plugin.settings.loggingPath=i,await this.plugin.saveSettings()})}),new y.Setting(t).setName("Enable Verbose Logging").setDesc("Get a lot more information in the log.").addToggle(e=>{e.setValue(this.plugin.settings.loggingVerboseEnabled),e.onChange(async i=>{this.plugin.settings.loggingVerboseEnabled=i,await this.plugin.saveSettings()})}),new y.Setting(t).setName("Debugging Mode").setDesc("Atomic Bomb level console logging. Can be used for troubleshoting and development.").addToggle(e=>{e.setValue(this.plugin.settings.debuggingMode),e.onChange(async i=>{this.plugin.settings.debuggingMode=i,await this.plugin.saveSettings()})}),new y.Setting(t).setName("Personal Access Token").setDesc("If you need to access private repositories, enter the personal access token here.").addText(e=>{var i;e.setPlaceholder("Enter your personal access token").setValue((i=this.plugin.settings.personalAccessToken)!=null?i:"").onChange(async o=>{this.plugin.settings.personalAccessToken=o,await this.plugin.saveSettings()})})}};var Nt=require("obsidian");function kt(){(0,Nt.addIcon)("BratIcon",'')}var z=class{constructor(t){this.console=(t,...n)=>{console.log(`BRAT: ${t}`,...n)};this.themes={themeseCheckAndUpates:async t=>{await B(this.plugin,t)},themeInstallTheme:async t=>{let n=t.replace("https://github.com/","");await O(this.plugin,n,!0)},themesDelete:t=>{let n=t.replace("https://github.com/","");X(this.plugin,n)},grabCommmunityThemeCssFile:async(t,n=!1)=>await I(t,n,this.plugin.settings.debuggingMode),grabChecksumOfThemeCssFile:async(t,n=!1)=>await $(t,n,this.plugin.settings.debuggingMode),grabLastCommitDateForFile:async(t,n)=>await yt(t,n)};this.plugin=t}};var W=require("obsidian"),Vt=Xt(Ht());async function Yt(s,t,n=!1){if(s.settings.debuggingMode&&console.log(`BRAT: ${t}`),s.settings.loggingEnabled){if(!s.settings.loggingVerboseEnabled&&n)return;let e=`${s.settings.loggingPath}.md`,i=`[[${(0,W.moment)().format((0,Vt.getDailyNoteSettings)().format).toString()}]] ${(0,W.moment)().format("HH:mm")}`,o=window.require("os"),a=W.Platform.isDesktop?o.hostname():"MOBILE",l=`${i} ${a} ${t.replace(` `," ")} `,g=s.app.vault.getAbstractFileByPath(e);g?await s.app.vault.append(g,l):g=await s.app.vault.create(e,l)}}var nt=class extends jt.Plugin{constructor(){super(...arguments);this.APP_NAME="BRAT";this.APP_ID="obsidian42-brat";this.settings=ot;this.betaPlugins=new R(this);this.commands=new U(this);this.bratApi=new z(this);this.obsidianProtocolHandler=n=>{if(!n.plugin&&!n.theme){d(this,"Could not locate the repository from the URL.",10);return}for(let e of["plugin","theme"])if(n[e]){let i=e==="plugin"?new N(this,this.betaPlugins):new S(this);i.address=n[e],i.open();return}}}onload(){console.log(`loading ${this.APP_NAME}`),this.loadSettings().then(()=>{this.app.workspace.onLayoutReady(()=>{this.addSettingTab(new et(this.app,this)),kt(),this.showRibbonButton(),this.registerObsidianProtocolHandler("brat",this.obsidianProtocolHandler),this.settings.updateAtStartup&&setTimeout(()=>{this.betaPlugins.checkForPluginUpdatesAndInstallUpdates(!1)},6e4),this.settings.updateThemesAtStartup&&setTimeout(()=>{B(this,!1)},12e4),setTimeout(()=>{window.bratAPI=this.bratApi},500)})}).catch(n=>{console.error("Failed to load settings:",n)})}showRibbonButton(){this.addRibbonIcon("BratIcon","BRAT",()=>{this.commands.ribbonDisplayCommands()})}async log(n,e=!1){await Yt(this,n,e)}onunload(){console.log(`unloading ${this.APP_NAME}`)}async loadSettings(){this.settings=Object.assign({},ot,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}}; /* nosourcemap */