"use strict";var Oi=Object.create;var we=Object.defineProperty;var Bi=Object.getOwnPropertyDescriptor;var Fi=Object.getOwnPropertyNames;var qi=Object.getPrototypeOf,Mi=Object.prototype.hasOwnProperty;var b=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Vi=(i,e)=>{for(var t in e)we(i,t,{get:e[t],enumerable:!0})},yt=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fi(e))!Mi.call(i,n)&&n!==t&&we(i,n,{get:()=>e[n],enumerable:!(s=Bi(e,n))||s.enumerable});return i};var Et=(i,e,t)=>(t=i!=null?Oi(qi(i)):{},yt(e||!i||!i.__esModule?we(t,"default",{value:i,enumerable:!0}):t,i)),Ui=i=>yt(we({},"__esModule",{value:!0}),i);var W=b((la,Rt)=>{"use strict";var _i="2.0.0",Gi=Number.MAX_SAFE_INTEGER||9007199254740991,ji=16,Hi=250,zi=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Rt.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:ji,MAX_SAFE_BUILD_LENGTH:Hi,MAX_SAFE_INTEGER:Gi,RELEASE_TYPES:zi,SEMVER_SPEC_VERSION:_i,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var ne=b((ua,$t)=>{"use strict";var Yi=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...i)=>console.error("SEMVER",...i):()=>{};$t.exports=Yi});var Z=b((V,At)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:Ye,MAX_SAFE_BUILD_LENGTH:Xi,MAX_LENGTH:Wi}=W(),Zi=ne();V=At.exports={};var Ji=V.re=[],Ki=V.safeRe=[],h=V.src=[],Qi=V.safeSrc=[],f=V.t={},en=0,Xe="[a-zA-Z0-9-]",tn=[["\\s",1],["\\d",Wi],[Xe,Xi]],sn=i=>{for(let[e,t]of tn)i=i.split(`${e}*`).join(`${e}{0,${t}}`).split(`${e}+`).join(`${e}{1,${t}}`);return i},v=(i,e,t)=>{let s=sn(e),n=en++;Zi(i,n,e),f[i]=n,h[n]=e,Qi[n]=s,Ji[n]=new RegExp(e,t?"g":void 0),Ki[n]=new RegExp(s,t?"g":void 0)};v("NUMERICIDENTIFIER","0|[1-9]\\d*");v("NUMERICIDENTIFIERLOOSE","\\d+");v("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${Xe}*`);v("MAINVERSION",`(${h[f.NUMERICIDENTIFIER]})\\.(${h[f.NUMERICIDENTIFIER]})\\.(${h[f.NUMERICIDENTIFIER]})`);v("MAINVERSIONLOOSE",`(${h[f.NUMERICIDENTIFIERLOOSE]})\\.(${h[f.NUMERICIDENTIFIERLOOSE]})\\.(${h[f.NUMERICIDENTIFIERLOOSE]})`);v("PRERELEASEIDENTIFIER",`(?:${h[f.NONNUMERICIDENTIFIER]}|${h[f.NUMERICIDENTIFIER]})`);v("PRERELEASEIDENTIFIERLOOSE",`(?:${h[f.NONNUMERICIDENTIFIER]}|${h[f.NUMERICIDENTIFIERLOOSE]})`);v("PRERELEASE",`(?:-(${h[f.PRERELEASEIDENTIFIER]}(?:\\.${h[f.PRERELEASEIDENTIFIER]})*))`);v("PRERELEASELOOSE",`(?:-?(${h[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${h[f.PRERELEASEIDENTIFIERLOOSE]})*))`);v("BUILDIDENTIFIER",`${Xe}+`);v("BUILD",`(?:\\+(${h[f.BUILDIDENTIFIER]}(?:\\.${h[f.BUILDIDENTIFIER]})*))`);v("FULLPLAIN",`v?${h[f.MAINVERSION]}${h[f.PRERELEASE]}?${h[f.BUILD]}?`);v("FULL",`^${h[f.FULLPLAIN]}$`);v("LOOSEPLAIN",`[v=\\s]*${h[f.MAINVERSIONLOOSE]}${h[f.PRERELEASELOOSE]}?${h[f.BUILD]}?`);v("LOOSE",`^${h[f.LOOSEPLAIN]}$`);v("GTLT","((?:<|>)?=?)");v("XRANGEIDENTIFIERLOOSE",`${h[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);v("XRANGEIDENTIFIER",`${h[f.NUMERICIDENTIFIER]}|x|X|\\*`);v("XRANGEPLAIN",`[v=\\s]*(${h[f.XRANGEIDENTIFIER]})(?:\\.(${h[f.XRANGEIDENTIFIER]})(?:\\.(${h[f.XRANGEIDENTIFIER]})(?:${h[f.PRERELEASE]})?${h[f.BUILD]}?)?)?`);v("XRANGEPLAINLOOSE",`[v=\\s]*(${h[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${h[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${h[f.XRANGEIDENTIFIERLOOSE]})(?:${h[f.PRERELEASELOOSE]})?${h[f.BUILD]}?)?)?`);v("XRANGE",`^${h[f.GTLT]}\\s*${h[f.XRANGEPLAIN]}$`);v("XRANGELOOSE",`^${h[f.GTLT]}\\s*${h[f.XRANGEPLAINLOOSE]}$`);v("COERCEPLAIN",`(^|[^\\d])(\\d{1,${Ye}})(?:\\.(\\d{1,${Ye}}))?(?:\\.(\\d{1,${Ye}}))?`);v("COERCE",`${h[f.COERCEPLAIN]}(?:$|[^\\d])`);v("COERCEFULL",h[f.COERCEPLAIN]+`(?:${h[f.PRERELEASE]})?(?:${h[f.BUILD]})?(?:$|[^\\d])`);v("COERCERTL",h[f.COERCE],!0);v("COERCERTLFULL",h[f.COERCEFULL],!0);v("LONETILDE","(?:~>?)");v("TILDETRIM",`(\\s*)${h[f.LONETILDE]}\\s+`,!0);V.tildeTrimReplace="$1~";v("TILDE",`^${h[f.LONETILDE]}${h[f.XRANGEPLAIN]}$`);v("TILDELOOSE",`^${h[f.LONETILDE]}${h[f.XRANGEPLAINLOOSE]}$`);v("LONECARET","(?:\\^)");v("CARETTRIM",`(\\s*)${h[f.LONECARET]}\\s+`,!0);V.caretTrimReplace="$1^";v("CARET",`^${h[f.LONECARET]}${h[f.XRANGEPLAIN]}$`);v("CARETLOOSE",`^${h[f.LONECARET]}${h[f.XRANGEPLAINLOOSE]}$`);v("COMPARATORLOOSE",`^${h[f.GTLT]}\\s*(${h[f.LOOSEPLAIN]})$|^$`);v("COMPARATOR",`^${h[f.GTLT]}\\s*(${h[f.FULLPLAIN]})$|^$`);v("COMPARATORTRIM",`(\\s*)${h[f.GTLT]}\\s*(${h[f.LOOSEPLAIN]}|${h[f.XRANGEPLAIN]})`,!0);V.comparatorTrimReplace="$1$2$3";v("HYPHENRANGE",`^\\s*(${h[f.XRANGEPLAIN]})\\s+-\\s+(${h[f.XRANGEPLAIN]})\\s*$`);v("HYPHENRANGELOOSE",`^\\s*(${h[f.XRANGEPLAINLOOSE]})\\s+-\\s+(${h[f.XRANGEPLAINLOOSE]})\\s*$`);v("STAR","(<|>)?=?\\s*\\*");v("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");v("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var ve=b((ca,It)=>{"use strict";var nn=Object.freeze({loose:!0}),rn=Object.freeze({}),on=i=>i?typeof i!="object"?nn:i:rn;It.exports=on});var We=b((ga,kt)=>{"use strict";var Ct=/^[0-9]+$/,St=(i,e)=>{if(typeof i=="number"&&typeof e=="number")return i===e?0:iSt(e,i);kt.exports={compareIdentifiers:St,rcompareIdentifiers:an}});var I=b((pa,xt)=>{"use strict";var Te=ne(),{MAX_LENGTH:Lt,MAX_SAFE_INTEGER:Pe}=W(),{safeRe:ye,t:Ee}=Z(),ln=ve(),{compareIdentifiers:Ze}=We(),Je=class i{constructor(e,t){if(t=ln(t),e instanceof i){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>Lt)throw new TypeError(`version is longer than ${Lt} characters`);Te("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let s=e.trim().match(t.loose?ye[Ee.LOOSE]:ye[Ee.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>Pe||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Pe||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Pe||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let r=+n;if(r>=0&&re.major?1:this.minore.minor?1:this.patche.patch?1:0}comparePre(e){if(e instanceof i||(e=new i(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let s=this.prerelease[t],n=e.prerelease[t];if(Te("prerelease compare",t,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return Ze(s,n)}while(++t)}compareBuild(e){e instanceof i||(e=new i(e,this.options));let t=0;do{let s=this.build[t],n=e.build[t];if(Te("build compare",t,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return Ze(s,n)}while(++t)}inc(e,t,s){if(e.startsWith("pre")){if(!t&&s===!1)throw new Error("invalid increment argument: identifier is empty");if(t){let n=`-${t}`.match(this.options.loose?ye[Ee.PRERELEASELOOSE]:ye[Ee.PRERELEASE]);if(!n||n[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,s);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,s);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,s),this.inc("pre",t,s);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t,s),this.inc("pre",t,s);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let n=Number(s)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]=="number"&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(t){let r=[t,n];s===!1&&(r=[t]),Ze(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};xt.exports=Je});var _=b((da,Dt)=>{"use strict";var Nt=I(),un=(i,e,t=!1)=>{if(i instanceof Nt)return i;try{return new Nt(i,e)}catch(s){if(!t)return null;throw s}};Dt.exports=un});var Bt=b((ma,Ot)=>{"use strict";var cn=_(),gn=(i,e)=>{let t=cn(i,e);return t?t.version:null};Ot.exports=gn});var qt=b((ha,Ft)=>{"use strict";var pn=_(),dn=(i,e)=>{let t=pn(i.trim().replace(/^[=v]+/,""),e);return t?t.version:null};Ft.exports=dn});var Ut=b((fa,Vt)=>{"use strict";var Mt=I(),mn=(i,e,t,s,n)=>{typeof t=="string"&&(n=s,s=t,t=void 0);try{return new Mt(i instanceof Mt?i.version:i,t).inc(e,s,n).version}catch(r){return null}};Vt.exports=mn});var jt=b((ba,Gt)=>{"use strict";var _t=_(),hn=(i,e)=>{let t=_t(i,null,!0),s=_t(e,null,!0),n=t.compare(s);if(n===0)return null;let r=n>0,o=r?t:s,u=r?s:t,l=!!o.prerelease.length;if(!!u.prerelease.length&&!l){if(!u.patch&&!u.minor)return"major";if(u.compareMain(o)===0)return u.minor&&!u.patch?"minor":"patch"}let d=l?"pre":"";return t.major!==s.major?d+"major":t.minor!==s.minor?d+"minor":t.patch!==s.patch?d+"patch":"prerelease"};Gt.exports=hn});var zt=b((wa,Ht)=>{"use strict";var fn=I(),bn=(i,e)=>new fn(i,e).major;Ht.exports=bn});var Xt=b((va,Yt)=>{"use strict";var wn=I(),vn=(i,e)=>new wn(i,e).minor;Yt.exports=vn});var Zt=b((Ta,Wt)=>{"use strict";var Tn=I(),Pn=(i,e)=>new Tn(i,e).patch;Wt.exports=Pn});var Kt=b((Pa,Jt)=>{"use strict";var yn=_(),En=(i,e)=>{let t=yn(i,e);return t&&t.prerelease.length?t.prerelease:null};Jt.exports=En});var O=b((ya,es)=>{"use strict";var Qt=I(),Rn=(i,e,t)=>new Qt(i,t).compare(new Qt(e,t));es.exports=Rn});var ss=b((Ea,ts)=>{"use strict";var $n=O(),An=(i,e,t)=>$n(e,i,t);ts.exports=An});var ns=b((Ra,is)=>{"use strict";var In=O(),Cn=(i,e)=>In(i,e,!0);is.exports=Cn});var Re=b(($a,os)=>{"use strict";var rs=I(),Sn=(i,e,t)=>{let s=new rs(i,t),n=new rs(e,t);return s.compare(n)||s.compareBuild(n)};os.exports=Sn});var ls=b((Aa,as)=>{"use strict";var kn=Re(),Ln=(i,e)=>i.sort((t,s)=>kn(t,s,e));as.exports=Ln});var cs=b((Ia,us)=>{"use strict";var xn=Re(),Nn=(i,e)=>i.sort((t,s)=>xn(s,t,e));us.exports=Nn});var re=b((Ca,gs)=>{"use strict";var Dn=O(),On=(i,e,t)=>Dn(i,e,t)>0;gs.exports=On});var $e=b((Sa,ps)=>{"use strict";var Bn=O(),Fn=(i,e,t)=>Bn(i,e,t)<0;ps.exports=Fn});var Ke=b((ka,ds)=>{"use strict";var qn=O(),Mn=(i,e,t)=>qn(i,e,t)===0;ds.exports=Mn});var Qe=b((La,ms)=>{"use strict";var Vn=O(),Un=(i,e,t)=>Vn(i,e,t)!==0;ms.exports=Un});var Ae=b((xa,hs)=>{"use strict";var _n=O(),Gn=(i,e,t)=>_n(i,e,t)>=0;hs.exports=Gn});var Ie=b((Na,fs)=>{"use strict";var jn=O(),Hn=(i,e,t)=>jn(i,e,t)<=0;fs.exports=Hn});var et=b((Da,bs)=>{"use strict";var zn=Ke(),Yn=Qe(),Xn=re(),Wn=Ae(),Zn=$e(),Jn=Ie(),Kn=(i,e,t,s)=>{switch(e){case"===":return typeof i=="object"&&(i=i.version),typeof t=="object"&&(t=t.version),i===t;case"!==":return typeof i=="object"&&(i=i.version),typeof t=="object"&&(t=t.version),i!==t;case"":case"=":case"==":return zn(i,t,s);case"!=":return Yn(i,t,s);case">":return Xn(i,t,s);case">=":return Wn(i,t,s);case"<":return Zn(i,t,s);case"<=":return Jn(i,t,s);default:throw new TypeError(`Invalid operator: ${e}`)}};bs.exports=Kn});var tt=b((Oa,ws)=>{"use strict";var Qn=I(),er=_(),{safeRe:Ce,t:Se}=Z(),tr=(i,e)=>{if(i instanceof Qn)return i;if(typeof i=="number"&&(i=String(i)),typeof i!="string")return null;e=e||{};let t=null;if(!e.rtl)t=i.match(e.includePrerelease?Ce[Se.COERCEFULL]:Ce[Se.COERCE]);else{let l=e.includePrerelease?Ce[Se.COERCERTLFULL]:Ce[Se.COERCERTL],g;for(;(g=l.exec(i))&&(!t||t.index+t[0].length!==i.length);)(!t||g.index+g[0].length!==t.index+t[0].length)&&(t=g),l.lastIndex=g.index+g[1].length+g[2].length;l.lastIndex=-1}if(t===null)return null;let s=t[2],n=t[3]||"0",r=t[4]||"0",o=e.includePrerelease&&t[5]?`-${t[5]}`:"",u=e.includePrerelease&&t[6]?`+${t[6]}`:"";return er(`${s}.${n}.${r}${o}${u}`,e)};ws.exports=tr});var Ts=b((Ba,vs)=>{"use strict";var sr=_(),ir=W(),nr=I(),rr=(i,e,t)=>{if(!ir.RELEASE_TYPES.includes(e))return null;let s=or(i,t);return s&&ar(s,e)},or=(i,e)=>{let t=i instanceof nr?i.version:i;return sr(t,e)},ar=(i,e)=>{if(lr(e))return i.version;switch(i.prerelease=[],e){case"major":i.minor=0,i.patch=0;break;case"minor":i.patch=0;break}return i.format()},lr=i=>i.startsWith("pre");vs.exports=rr});var ys=b((Fa,Ps)=>{"use strict";var st=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(e,t)}return this}};Ps.exports=st});var q=b((qa,As)=>{"use strict";var ur=/\s+/g,it=class i{constructor(e,t){if(t=gr(t),e instanceof i)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new i(e.raw,t);if(e instanceof nt)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(ur," "),this.set=this.raw.split("||").map(s=>this.parseRange(s.trim())).filter(s=>s.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let s=this.set[0];if(this.set=this.set.filter(n=>!Rs(n[0])),this.set.length===0)this.set=[s];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&Tr(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e0&&(this.formatted+="||");let t=this.set[e];for(let s=0;s0&&(this.formatted+=" "),this.formatted+=t[s].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){e=e.replace(vr,"");let s=((this.options.includePrerelease&&br)|(this.options.loose&&wr))+":"+e,n=Es.get(s);if(n)return n;let r=this.options.loose,o=r?S[C.HYPHENRANGELOOSE]:S[C.HYPHENRANGE];e=e.replace(o,kr(this.options.includePrerelease)),y("hyphen replace",e),e=e.replace(S[C.COMPARATORTRIM],mr),y("comparator trim",e),e=e.replace(S[C.TILDETRIM],hr),y("tilde trim",e),e=e.replace(S[C.CARETTRIM],fr),y("caret trim",e);let u=e.split(" ").map(a=>Pr(a,this.options)).join(" ").split(/\s+/).map(a=>Sr(a,this.options));r&&(u=u.filter(a=>(y("loose invalid filter",a,this.options),!!a.match(S[C.COMPARATORLOOSE])))),y("range list",u);let l=new Map,g=u.map(a=>new nt(a,this.options));for(let a of g){if(Rs(a))return[a];l.set(a.value,a)}l.size>1&&l.has("")&&l.delete("");let d=[...l.values()];return Es.set(s,d),d}intersects(e,t){if(!(e instanceof i))throw new TypeError("a Range is required");return this.set.some(s=>$s(s,t)&&e.set.some(n=>$s(n,t)&&s.every(r=>n.every(o=>r.intersects(o,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new pr(e,this.options)}catch(t){return!1}for(let t=0;ti.value==="<0.0.0-0",Tr=i=>i.value==="",$s=(i,e)=>{let t=!0,s=i.slice(),n=s.pop();for(;t&&s.length;)t=s.every(r=>n.intersects(r,e)),n=s.pop();return t},Pr=(i,e)=>(i=i.replace(S[C.BUILD],""),y("comp",i,e),i=Rr(i,e),y("caret",i),i=yr(i,e),y("tildes",i),i=Ar(i,e),y("xrange",i),i=Cr(i,e),y("stars",i),i),k=i=>!i||i.toLowerCase()==="x"||i==="*",yr=(i,e)=>i.trim().split(/\s+/).map(t=>Er(t,e)).join(" "),Er=(i,e)=>{let t=e.loose?S[C.TILDELOOSE]:S[C.TILDE];return i.replace(t,(s,n,r,o,u)=>{y("tilde",i,s,n,r,o,u);let l;return k(n)?l="":k(r)?l=`>=${n}.0.0 <${+n+1}.0.0-0`:k(o)?l=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:u?(y("replaceTilde pr",u),l=`>=${n}.${r}.${o}-${u} <${n}.${+r+1}.0-0`):l=`>=${n}.${r}.${o} <${n}.${+r+1}.0-0`,y("tilde return",l),l})},Rr=(i,e)=>i.trim().split(/\s+/).map(t=>$r(t,e)).join(" "),$r=(i,e)=>{y("caret",i,e);let t=e.loose?S[C.CARETLOOSE]:S[C.CARET],s=e.includePrerelease?"-0":"";return i.replace(t,(n,r,o,u,l)=>{y("caret",i,n,r,o,u,l);let g;return k(r)?g="":k(o)?g=`>=${r}.0.0${s} <${+r+1}.0.0-0`:k(u)?r==="0"?g=`>=${r}.${o}.0${s} <${r}.${+o+1}.0-0`:g=`>=${r}.${o}.0${s} <${+r+1}.0.0-0`:l?(y("replaceCaret pr",l),r==="0"?o==="0"?g=`>=${r}.${o}.${u}-${l} <${r}.${o}.${+u+1}-0`:g=`>=${r}.${o}.${u}-${l} <${r}.${+o+1}.0-0`:g=`>=${r}.${o}.${u}-${l} <${+r+1}.0.0-0`):(y("no pr"),r==="0"?o==="0"?g=`>=${r}.${o}.${u}${s} <${r}.${o}.${+u+1}-0`:g=`>=${r}.${o}.${u}${s} <${r}.${+o+1}.0-0`:g=`>=${r}.${o}.${u} <${+r+1}.0.0-0`),y("caret return",g),g})},Ar=(i,e)=>(y("replaceXRanges",i,e),i.split(/\s+/).map(t=>Ir(t,e)).join(" ")),Ir=(i,e)=>{i=i.trim();let t=e.loose?S[C.XRANGELOOSE]:S[C.XRANGE];return i.replace(t,(s,n,r,o,u,l)=>{y("xRange",i,s,n,r,o,u,l);let g=k(r),d=g||k(o),a=d||k(u),c=a;return n==="="&&c&&(n=""),l=e.includePrerelease?"-0":"",g?n===">"||n==="<"?s="<0.0.0-0":s="*":n&&c?(d&&(o=0),u=0,n===">"?(n=">=",d?(r=+r+1,o=0,u=0):(o=+o+1,u=0)):n==="<="&&(n="<",d?r=+r+1:o=+o+1),n==="<"&&(l="-0"),s=`${n+r}.${o}.${u}${l}`):d?s=`>=${r}.0.0${l} <${+r+1}.0.0-0`:a&&(s=`>=${r}.${o}.0${l} <${r}.${+o+1}.0-0`),y("xRange return",s),s})},Cr=(i,e)=>(y("replaceStars",i,e),i.trim().replace(S[C.STAR],"")),Sr=(i,e)=>(y("replaceGTE0",i,e),i.trim().replace(S[e.includePrerelease?C.GTE0PRE:C.GTE0],"")),kr=i=>(e,t,s,n,r,o,u,l,g,d,a,c)=>(k(s)?t="":k(n)?t=`>=${s}.0.0${i?"-0":""}`:k(r)?t=`>=${s}.${n}.0${i?"-0":""}`:o?t=`>=${t}`:t=`>=${t}${i?"-0":""}`,k(g)?l="":k(d)?l=`<${+g+1}.0.0-0`:k(a)?l=`<${g}.${+d+1}.0-0`:c?l=`<=${g}.${d}.${a}-${c}`:i?l=`<${g}.${d}.${+a+1}-0`:l=`<=${l}`,`${t} ${l}`.trim()),Lr=(i,e,t)=>{for(let s=0;s0){let n=i[s].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}});var oe=b((Ma,xs)=>{"use strict";var ae=Symbol("SemVer ANY"),at=class i{static get ANY(){return ae}constructor(e,t){if(t=Is(t),e instanceof i){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),ot("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===ae?this.value="":this.value=this.operator+this.semver.version,ot("comp",this)}parse(e){let t=this.options.loose?Cs[Ss.COMPARATORLOOSE]:Cs[Ss.COMPARATOR],s=e.match(t);if(!s)throw new TypeError(`Invalid comparator: ${e}`);this.operator=s[1]!==void 0?s[1]:"",this.operator==="="&&(this.operator=""),s[2]?this.semver=new ks(s[2],this.options.loose):this.semver=ae}toString(){return this.value}test(e){if(ot("Comparator.test",e,this.options.loose),this.semver===ae||e===ae)return!0;if(typeof e=="string")try{e=new ks(e,this.options)}catch(t){return!1}return rt(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof i))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new Ls(e.value,t).test(this.value):e.operator===""?e.value===""?!0:new Ls(this.value,t).test(e.semver):(t=Is(t),t.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||rt(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||rt(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}};xs.exports=at;var Is=ve(),{safeRe:Cs,t:Ss}=Z(),rt=et(),ot=ne(),ks=I(),Ls=q()});var le=b((Va,Ns)=>{"use strict";var xr=q(),Nr=(i,e,t)=>{try{e=new xr(e,t)}catch(s){return!1}return e.test(i)};Ns.exports=Nr});var Os=b((Ua,Ds)=>{"use strict";var Dr=q(),Or=(i,e)=>new Dr(i,e).set.map(t=>t.map(s=>s.value).join(" ").trim().split(" "));Ds.exports=Or});var Fs=b((_a,Bs)=>{"use strict";var Br=I(),Fr=q(),qr=(i,e,t)=>{let s=null,n=null,r=null;try{r=new Fr(e,t)}catch(o){return null}return i.forEach(o=>{r.test(o)&&(!s||n.compare(o)===-1)&&(s=o,n=new Br(s,t))}),s};Bs.exports=qr});var Ms=b((Ga,qs)=>{"use strict";var Mr=I(),Vr=q(),Ur=(i,e,t)=>{let s=null,n=null,r=null;try{r=new Vr(e,t)}catch(o){return null}return i.forEach(o=>{r.test(o)&&(!s||n.compare(o)===1)&&(s=o,n=new Mr(s,t))}),s};qs.exports=Ur});var _s=b((ja,Us)=>{"use strict";var lt=I(),_r=q(),Vs=re(),Gr=(i,e)=>{i=new _r(i,e);let t=new lt("0.0.0");if(i.test(t)||(t=new lt("0.0.0-0"),i.test(t)))return t;t=null;for(let s=0;s{let u=new lt(o.semver.version);switch(o.operator){case">":u.prerelease.length===0?u.patch++:u.prerelease.push(0),u.raw=u.format();case"":case">=":(!r||Vs(u,r))&&(r=u);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${o.operator}`)}}),r&&(!t||Vs(t,r))&&(t=r)}return t&&i.test(t)?t:null};Us.exports=Gr});var js=b((Ha,Gs)=>{"use strict";var jr=q(),Hr=(i,e)=>{try{return new jr(i,e).range||"*"}catch(t){return null}};Gs.exports=Hr});var ke=b((za,Xs)=>{"use strict";var zr=I(),Ys=oe(),{ANY:Yr}=Ys,Xr=q(),Wr=le(),Hs=re(),zs=$e(),Zr=Ie(),Jr=Ae(),Kr=(i,e,t,s)=>{i=new zr(i,s),e=new Xr(e,s);let n,r,o,u,l;switch(t){case">":n=Hs,r=Zr,o=zs,u=">",l=">=";break;case"<":n=zs,r=Jr,o=Hs,u="<",l="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(Wr(i,e,s))return!1;for(let g=0;g{p.semver===Yr&&(p=new Ys(">=0.0.0")),a=a||p,c=c||p,n(p.semver,a.semver,s)?a=p:o(p.semver,c.semver,s)&&(c=p)}),a.operator===u||a.operator===l||(!c.operator||c.operator===u)&&r(i,c.semver))return!1;if(c.operator===l&&o(i,c.semver))return!1}return!0};Xs.exports=Kr});var Zs=b((Ya,Ws)=>{"use strict";var Qr=ke(),eo=(i,e,t)=>Qr(i,e,">",t);Ws.exports=eo});var Ks=b((Xa,Js)=>{"use strict";var to=ke(),so=(i,e,t)=>to(i,e,"<",t);Js.exports=so});var ti=b((Wa,ei)=>{"use strict";var Qs=q(),io=(i,e,t)=>(i=new Qs(i,t),e=new Qs(e,t),i.intersects(e,t));ei.exports=io});var ii=b((Za,si)=>{"use strict";var no=le(),ro=O();si.exports=(i,e,t)=>{let s=[],n=null,r=null,o=i.sort((d,a)=>ro(d,a,t));for(let d of o)no(d,e,t)?(r=d,n||(n=d)):(r&&s.push([n,r]),r=null,n=null);n&&s.push([n,null]);let u=[];for(let[d,a]of s)d===a?u.push(d):!a&&d===o[0]?u.push("*"):a?d===o[0]?u.push(`<=${a}`):u.push(`${d} - ${a}`):u.push(`>=${d}`);let l=u.join(" || "),g=typeof e.raw=="string"?e.raw:String(e);return l.length{"use strict";var ni=q(),gt=oe(),{ANY:ut}=gt,ct=le(),pt=O(),oo=(i,e,t={})=>{if(i===e)return!0;i=new ni(i,t),e=new ni(e,t);let s=!1;e:for(let n of i.set){for(let r of e.set){let o=lo(n,r,t);if(s=s||o!==null,o)continue e}if(s)return!1}return!0},ao=[new gt(">=0.0.0-0")],ri=[new gt(">=0.0.0")],lo=(i,e,t)=>{if(i===e)return!0;if(i.length===1&&i[0].semver===ut){if(e.length===1&&e[0].semver===ut)return!0;t.includePrerelease?i=ao:i=ri}if(e.length===1&&e[0].semver===ut){if(t.includePrerelease)return!0;e=ri}let s=new Set,n,r;for(let p of i)p.operator===">"||p.operator===">="?n=oi(n,p,t):p.operator==="<"||p.operator==="<="?r=ai(r,p,t):s.add(p.semver);if(s.size>1)return null;let o;if(n&&r){if(o=pt(n.semver,r.semver,t),o>0)return null;if(o===0&&(n.operator!==">="||r.operator!=="<="))return null}for(let p of s){if(n&&!ct(p,String(n),t)||r&&!ct(p,String(r),t))return null;for(let m of e)if(!ct(p,String(m),t))return!1;return!0}let u,l,g,d,a=r&&!t.includePrerelease&&r.semver.prerelease.length?r.semver:!1,c=n&&!t.includePrerelease&&n.semver.prerelease.length?n.semver:!1;a&&a.prerelease.length===1&&r.operator==="<"&&a.prerelease[0]===0&&(a=!1);for(let p of e){if(d=d||p.operator===">"||p.operator===">=",g=g||p.operator==="<"||p.operator==="<=",n){if(c&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===c.major&&p.semver.minor===c.minor&&p.semver.patch===c.patch&&(c=!1),p.operator===">"||p.operator===">="){if(u=oi(n,p,t),u===p&&u!==n)return!1}else if(n.operator===">="&&!p.test(n.semver))return!1}if(r){if(a&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===a.major&&p.semver.minor===a.minor&&p.semver.patch===a.patch&&(a=!1),p.operator==="<"||p.operator==="<="){if(l=ai(r,p,t),l===p&&l!==r)return!1}else if(r.operator==="<="&&!p.test(r.semver))return!1}if(!p.operator&&(r||n)&&o!==0)return!1}return!(n&&g&&!r&&o!==0||r&&d&&!n&&o!==0||c||a)},oi=(i,e,t)=>{if(!i)return e;let s=pt(i.semver,e.semver,t);return s>0?i:s<0||e.operator===">"&&i.operator===">="?e:i},ai=(i,e,t)=>{if(!i)return e;let s=pt(i.semver,e.semver,t);return s<0?i:s>0||e.operator==="<"&&i.operator==="<="?e:i};li.exports=oo});var mt=b((Ka,pi)=>{"use strict";var dt=Z(),ci=W(),uo=I(),gi=We(),co=_(),go=Bt(),po=qt(),mo=Ut(),ho=jt(),fo=zt(),bo=Xt(),wo=Zt(),vo=Kt(),To=O(),Po=ss(),yo=ns(),Eo=Re(),Ro=ls(),$o=cs(),Ao=re(),Io=$e(),Co=Ke(),So=Qe(),ko=Ae(),Lo=Ie(),xo=et(),No=tt(),Do=Ts(),Oo=oe(),Bo=q(),Fo=le(),qo=Os(),Mo=Fs(),Vo=Ms(),Uo=_s(),_o=js(),Go=ke(),jo=Zs(),Ho=Ks(),zo=ti(),Yo=ii(),Xo=ui();pi.exports={parse:co,valid:go,clean:po,inc:mo,diff:ho,major:fo,minor:bo,patch:wo,prerelease:vo,compare:To,rcompare:Po,compareLoose:yo,compareBuild:Eo,sort:Ro,rsort:$o,gt:Ao,lt:Io,eq:Co,neq:So,gte:ko,lte:Lo,cmp:xo,coerce:No,truncate:Do,Comparator:Oo,Range:Bo,satisfies:Fo,toComparators:qo,maxSatisfying:Mo,minSatisfying:Vo,minVersion:Uo,validRange:_o,outside:Go,gtr:jo,ltr:Ho,intersects:zo,simplifyRange:Yo,subset:Xo,SemVer:uo,re:dt.re,src:dt.src,tokens:dt.t,SEMVER_SPEC_VERSION:ci.SEMVER_SPEC_VERSION,RELEASE_TYPES:ci.RELEASE_TYPES,compareIdentifiers:gi.compareIdentifiers,rcompareIdentifiers:gi.rcompareIdentifiers}});var na={};Vi(na,{default:()=>Ge});module.exports=Ui(na);var Di=require("obsidian");var F=require("obsidian");var ie=require("obsidian"),He=class extends ie.Modal{constructor(t,s){super(t.app);this.resolve=s;this.isConfirmed=!1;let n={app:t.app,cancelButtonText:"Cancel",cssClass:"",message:t.message,okButtonText:"OK",title:""};this.options={...n,...t},this.containerEl.addClass("confirm-modal")}onClose(){super.onClose(),this.resolve(this.isConfirmed)}onOpen(){super.onOpen(),this.titleEl.setText(this.options.title),this.contentEl.createEl("p",{text:this.options.message});let t=new ie.ButtonComponent(this.contentEl);t.setClass("ok-button"),t.setButtonText(this.options.okButtonText),t.setCta(),t.onClick(()=>{this.isConfirmed=!0,this.close()});let s=new ie.ButtonComponent(this.contentEl);s.setButtonText(this.options.cancelButtonText),s.onClick(this.close.bind(this))}};async function ze(i){return await new Promise(e=>{new He(i,e).open()})}var N=class extends Error{constructor(e,t,s,n,r){let o=Math.ceil((s-Math.floor(Date.now()/1e3))/60);super(`${r} API rate limit exceeded. Reset in ${o} minutes.`),this.limit=e,this.remaining=t,this.reset=s,this.requestUrl=n}getMinutesToReset(){return Math.ceil((this.reset-Math.floor(Date.now()/1e3))/60)}},A=class extends Error{constructor(e,t,s={}){super(e),this.status=t,this.statusMessage=e,this.headers=s,this.name="ProviderResponseError"}};var Le=require("obsidian"),ue=Et(mt());function di(i){return Object.keys(i).reduce((e,t)=>(e[t.toLowerCase()]=i[t],e),{})}var xe=class{parseUrl(e){var o,u;let t=e.replace(/https?:\/\//i,"");t.toLowerCase().startsWith("github.com/")&&(t=t.slice(11)),t.toLowerCase().endsWith(".git")&&(t=t.slice(0,-4)),t.endsWith("/")&&(t=t.slice(0,-1));let s=t.split("/"),n=(o=s[0])!=null?o:"",r=(u=s[1])!=null?u:"";return{host:"api.github.com",owner:n,repo:r,apiBaseUrl:"https://api.github.com",rawBaseUrl:"https://raw.githubusercontent.com",isGitHub:!0}}formatRepoUrl(e){return`${e.owner}/${e.repo}`}async getRepoInfo(e,t){var s;try{return{exists:!0,isPrivate:(s=(await this.apiRequest({url:`${e.apiBaseUrl}/repos/${e.owner}/${e.repo}`,headers:t?{Authorization:`Token ${t}`}:{}})).json.private)!=null?s:!1}}catch(n){if(n instanceof A&&n.status===404)return{exists:!1,isPrivate:!1};throw n}}async listReleases(e,t){try{return(await this.apiRequest({url:`${e.apiBaseUrl}/repos/${e.owner}/${e.repo}/releases?per_page=100`,headers:t?{Authorization:`Token ${t}`}:{}})).json.map(r=>({version:r.tag_name,prerelease:r.prerelease}))}catch(s){if(s instanceof N||s instanceof A)throw s;return null}}async getRelease(e,t,s=!1,n){var r;try{let o=t&&t!=="latest"?`${e.apiBaseUrl}/repos/${e.owner}/${e.repo}/releases/tags/${t}`:`${e.apiBaseUrl}/repos/${e.owner}/${e.repo}/releases`,u={Accept:"application/vnd.github.v3+json"};n&&(u.Authorization=`Token ${n}`);let l=await this.apiRequest({url:o,headers:u});return l.status===404?null:(r=(t&&t!=="latest"?[this.normalizeRelease(l.json)]:l.json.map(a=>this.normalizeRelease(a))).sort((a,c)=>{try{let p=(0,ue.coerce)(a.tag_name,{includePrerelease:!0,loose:!0}),m=(0,ue.coerce)(c.tag_name,{includePrerelease:!0,loose:!0});return p&&m?(0,ue.compare)(m.version,p.version):0}catch(p){return new Date(c.published_at).getTime()-new Date(a.published_at).getTime()}}).filter(a=>s||!a.prerelease)[0])!=null?r:null}catch(o){if(o instanceof N)throw o;if(o instanceof A){if(o.status===404)return null;throw o}return null}}async getAsset(e,t,s,n){let r=e.assets.find(l=>l.name===t);if(!r)return null;let o={Accept:"application/octet-stream"};s&&n&&(o.Authorization=`Token ${n}`);let u=s?r.url:r.browser_download_url;try{let l=await(0,Le.requestUrl)({url:u,headers:o});return l.status===200?l.text:null}catch(l){return null}}async getRawFile(e,t,s="HEAD",n){let r=`${e.rawBaseUrl}/${e.owner}/${e.repo}/${s}/${t}`;try{let o={};n&&(o.Authorization=`Token ${n}`);let u=await(0,Le.requestUrl)({url:r,headers:o});return u.status===404?null:u.text}catch(o){return null}}async validateToken(e,t){var r,o,u,l;if(!e)return{valid:!1,message:"No token provided"};let s=["ghp_","github_pat_","ghs_"];if(!s.some(g=>e.toLowerCase().startsWith(g)))return{valid:!1,message:`Invalid token format. Valid prefixes: ${s.join(", ")}`,details:{validPrefixes:s.join(", ")}};try{let g=`_brat_validate_${Date.now()%1e4}/_probe_`;return await this.apiRequest({url:`https://api.github.com/repos/${g}`,headers:{Authorization:`Token ${e}`,Accept:"application/vnd.github.v3+json"}}),{valid:!0,message:"Token is valid"}}catch(g){if(g instanceof A){let d=di(g.headers),a=(o=(r=d["x-oauth-scopes"])==null?void 0:r.split(", "))!=null?o:[],c=d["github-authentication-token-expiration"];if(g.status===404){let p={valid:!0,message:"Token is valid"};return a.length>0&&(p.details={scopes:a.join(", ")}),c&&(p.details={...p.details,expires:c}),p}if(g.status===403){if(parseInt((u=d["x-ratelimit-remaining"])!=null?u:"0",10)===0){let m=parseInt((l=d["x-ratelimit-reset"])!=null?l:"0",10),P=Math.ceil((m-Math.floor(Date.now()/1e3))/60);return{valid:!1,message:`GitHub API rate limit exceeded. Reset in ${P} minutes.`,details:{resetInMinutes:String(P)}}}return{valid:!1,message:"Token lacks required permissions (repo scope needed)",details:{requiredScopes:"repo, public_repo"}}}return{valid:!1,message:`GitHub API error: ${g.status} ${g.statusMessage}`}}return{valid:!1,message:`Token validation failed: ${g}`}}}normalizeRelease(e){var t,s,n;return{url:e.url,tag_name:e.tag_name,name:(t=e.name)!=null?t:e.tag_name,published_at:e.published_at,prerelease:(s=e.prerelease)!=null?s:!1,assets:((n=e.assets)!=null?n:[]).map(r=>({name:r.name,url:r.url,browser_download_url:r.browser_download_url}))}}async apiRequest(e){var t,s,n,r,o,u;e.headers={...e.headers,"User-Agent":"Obsidian/BRAT-Gitea-Plugin"};try{return await(0,Le.requestUrl)(e)}catch(l){let g=l,d=(t=g.status)!=null?t:400,a=di((s=g.headers)!=null?s:{});if(d===403){let c=parseInt((n=a["x-ratelimit-remaining"])!=null?n:"0",10);if(c===0){let p=parseInt((r=a["x-ratelimit-limit"])!=null?r:"0",10),m=parseInt((o=a["x-ratelimit-reset"])!=null?o:"0",10);throw new N(p,c,m,e.url,"GitHub")}}throw new A((u=g.message)!=null?u:"GitHub API error",d,a)}}};var Ne=require("obsidian"),ce=Et(mt());var De=class{constructor(){this.defaultBranch="HEAD"}parseUrl(e){let t=e.trim();/^https?:\/\//i.test(t)||(t=`https://${t}`);let s=new URL(t),n=s.hostname,o=s.pathname.replace(/^\/+/,"").replace(/\/+$/,"").split("/"),u="",l="",g=0;o.length>=2&&(u=o[o.length-2],l=o[o.length-1]),l.toLowerCase().endsWith(".git")&&(l=l.slice(0,-4));let d=s.protocol;return{host:n,owner:u,repo:l,apiBaseUrl:`${d}//${n}/api/v1`,rawBaseUrl:`${d}//${n}`,isGitHub:!1}}formatRepoUrl(e){return`${e.host}/${e.owner}/${e.repo}`}async getRepoInfo(e,t){var s;try{return{exists:!0,isPrivate:(s=(await this.apiRequest({url:`${e.apiBaseUrl}/repos/${e.owner}/${e.repo}`,headers:t?{Authorization:`token ${t}`}:{}})).json.private)!=null?s:!1}}catch(n){if(n instanceof A&&n.status===404)return{exists:!1,isPrivate:!1};throw n}}async listReleases(e,t){try{return(await this.apiRequest({url:`${e.apiBaseUrl}/repos/${e.owner}/${e.repo}/releases?limit=100`,headers:t?{Authorization:`token ${t}`}:{}})).json.map(r=>{var o;return{version:r.tag_name,prerelease:(o=r.prerelease)!=null?o:!1}})}catch(s){if(s instanceof N||s instanceof A)throw s;return null}}async getRelease(e,t,s=!1,n){var r;try{let o=t&&t!=="latest"?`${e.apiBaseUrl}/repos/${e.owner}/${e.repo}/releases/tags/${t}`:`${e.apiBaseUrl}/repos/${e.owner}/${e.repo}/releases`,u={};n&&(u.Authorization=`token ${n}`);let l=await this.apiRequest({url:o,headers:u});return l.status===404?null:(r=(t&&t!=="latest"?[this.normalizeRelease(l.json)]:l.json.map(a=>this.normalizeRelease(a))).sort((a,c)=>{try{let p=(0,ce.coerce)(a.tag_name,{includePrerelease:!0,loose:!0}),m=(0,ce.coerce)(c.tag_name,{includePrerelease:!0,loose:!0});return p&&m?(0,ce.compare)(m.version,p.version):0}catch(p){return new Date(c.published_at).getTime()-new Date(a.published_at).getTime()}}).filter(a=>s||!a.prerelease)[0])!=null?r:null}catch(o){if(o instanceof N)throw o;if(o instanceof A){if(o.status===404)return null;throw o}return null}}async getAsset(e,t,s,n){let r=e.assets.find(l=>l.name===t);if(!r)return null;let o={Accept:"application/octet-stream"};n&&(o.Authorization=`token ${n}`);let u=s?r.url:r.browser_download_url;try{let l=await(0,Ne.requestUrl)({url:u,headers:o});return l.status===200?l.text:null}catch(l){return null}}async getRawFile(e,t,s,n){let r=s!=null?s:this.defaultBranch,o=`${e.rawBaseUrl}/${e.owner}/${e.repo}/raw/${r}/${t}`;try{let u={};n&&(u.Authorization=`token ${n}`);let l=await(0,Ne.requestUrl)({url:o,headers:u});return l.status===404?null:l.text}catch(u){return null}}async validateToken(e,t){var s;if(!e)return{valid:!1,message:"No token provided"};try{return t&&t.owner&&t.repo?(await this.apiRequest({url:`${t.apiBaseUrl}/repos/${t.owner}/${t.repo}`,headers:{Authorization:`token ${e}`}}),{valid:!0,message:"Token is valid"}):(await this.apiRequest({url:`${(s=t==null?void 0:t.apiBaseUrl)!=null?s:"https://localhost/api/v1"}/user`,headers:{Authorization:`token ${e}`}})).status===200?{valid:!0,message:"Token is valid"}:{valid:!1,message:"Token validation failed"}}catch(n){return n instanceof A?n.status===401||n.status===403?{valid:!1,message:`Token rejected: ${n.statusMessage}`}:n.status===404?{valid:!0,message:"Token is valid (no specific repo access checked)"}:{valid:!1,message:`API error: ${n.status} ${n.statusMessage}`}:{valid:!1,message:`Token validation failed: ${n}`}}}normalizeRelease(e){var t,s,n,r;return{url:e.url,tag_name:e.tag_name,name:(t=e.name)!=null?t:e.tag_name,published_at:(s=e.published_at)!=null?s:e.created_at,prerelease:(n=e.prerelease)!=null?n:!1,assets:((r=e.assets)!=null?r:[]).map(o=>({name:o.name,url:o.url,browser_download_url:o.browser_download_url}))}}async apiRequest(e){var t,s,n,r,o;e.headers={...e.headers,"User-Agent":"Obsidian/BRAT-Gitea-Plugin"};try{return await(0,Ne.requestUrl)(e)}catch(u){let l=u,g=(t=l.status)!=null?t:400,d=(s=l.message)!=null?s:"API error",a={};if(l.headers)for(let[p,m]of Object.entries(l.headers))a[p.toLowerCase()]=String(m);let c=parseInt((n=a["x-ratelimit-remaining"])!=null?n:"",10);if(g===403&&!isNaN(c)&&c===0){let p=parseInt((r=a["x-ratelimit-limit"])!=null?r:"0",10),m=parseInt((o=a["x-ratelimit-reset"])!=null?o:"0",10);throw new N(p,c,m,e.url,"Gitea")}throw new A(d,g,a)}}};var ht=null,ft=null;function mi(){return ht||(ht=new xe),ht}function Wo(){return ft||(ft=new De),ft}function J(i){let e=i.trim();return/^[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+$/.test(e)||/github\.com/i.test(e)?mi():Wo()}function j(i){let e=J(i),t=e.parseUrl(i);return{provider:e,parsed:t}}function Zo(i){let e=0;for(let t=0;tZo(i).toString(),bt={pluginList:[],pluginSubListFrozenVersion:[],themesList:[],updateAtStartup:!0,updateThemesAtStartup:!0,enableAfterInstall:!0,loggingEnabled:!1,loggingPath:"BRAT-log",loggingVerboseEnabled:!1,debuggingMode:!1,notificationsEnabled:!0,globalTokenName:"",personalAccessToken:"",selectLatestPluginVersionByDefault:!1,allowIncompatiblePlugins:!1};function hi(i,e,t="latest",s=!1,n="",r=""){let o=!1;i.settings.pluginList.contains(e)||(i.settings.pluginList.unshift(e),o=!0);let u=i.settings.pluginSubListFrozenVersion.find(l=>l.repo===e);u?(Object.assign(u,{repo:e,version:t,token:void 0,tokenName:n||u.tokenName,isIncompatible:s||void 0,giteaUrl:r||u.giteaUrl}),o=!0):(i.settings.pluginSubListFrozenVersion.unshift({repo:e,version:t,token:void 0,tokenName:n||void 0,isIncompatible:s||void 0,giteaUrl:r||void 0}),o=!0),o&&i.saveSettings()}function Oe(i,e){return i.settings.pluginList.contains(e)}function fi(i,e,t){let s={repo:e,lastUpdate:Jo(t)};i.settings.themesList.unshift(s),i.saveSettings()}function bi(i,e){return!!i.settings.themesList.find(s=>s.repo===e)}function wt(i,e,t){let s=i.settings.pluginSubListFrozenVersion.find(n=>n.repo===e);s&&(s.tokenName=t||void 0,i.saveSettings())}function wi(i,e,t){for(let s of i.settings.themesList)s.repo===e&&(s.lastUpdate=t,i.saveSettings())}var B=require("obsidian");var K=class{constructor(e){this.statusEl=e}async validateToken(e,t){if(!e)return this.updateStatus("No token provided",!1),!1;try{let s=t?J(t):J("github.com/test/test"),n=t?s.parseUrl(t):void 0,r=await s.validateToken(e,n);return r.valid?(this.showValidInfo(r),!0):(this.showError(r),!1)}catch(s){return console.error("Token validation error:",s),this.updateStatus("Failed to validate token",!1),!1}}updateStatus(e,t){this.statusEl&&(this.statusEl.empty(),this.statusEl.removeClass("valid","invalid"),this.statusEl.addClass(t?"valid":"invalid"),this.statusEl.setText(e))}showValidInfo(e){var s,n;if(!this.statusEl)return;this.statusEl.empty(),this.statusEl.removeClass("invalid"),this.statusEl.addClass("valid");let t=this.statusEl.createDiv({cls:"brat-token-details"});if(t.createDiv({text:"\u2713 Valid token",cls:"brat-token-status valid"}),(s=e.details)!=null&&s.scopes&&t.createDiv({text:`Scopes: ${e.details.scopes}`,cls:"brat-token-scopes"}),(n=e.details)!=null&&n.expires){let r=new Date(e.details.expires),o=Math.ceil((r.getTime()-Date.now())/(1e3*60*60*24));o<7&&t.createDiv({text:`\u26A0\uFE0F Token expires in ${o} days`,cls:"brat-token-warning"})}}showError(e){var s,n;if(!this.statusEl)return;this.statusEl.empty(),this.statusEl.removeClass("valid"),this.statusEl.addClass("invalid");let t=this.statusEl.createDiv({cls:"brat-token-error"});t.createDiv({text:`\u2717 ${e.message}`}),(s=e.details)!=null&&s.validPrefixes&&t.createDiv({text:`Valid prefixes: ${e.details.validPrefixes}`}),(n=e.details)!=null&&n.requiredScopes&&t.createDiv({text:`Required scopes: ${e.details.requiredScopes}`})}};function Ko(i,e){let t=new DocumentFragment,s=document.createElement("a");return/^[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+$/.test(i)?(s.textContent=i,s.href=`https://github.com/${i}`):(s.textContent=i,s.href=i.startsWith("http")?i:`https://${i}`),s.target="_blank",t.appendChild(s),e&&t.appendChild(document.createTextNode(e)),t}function vi({prependText:i,url:e,text:t,appendText:s}){let n=new DocumentFragment,r=document.createElement("a");return r.textContent=t,r.href=e,i&&n.appendChild(document.createTextNode(i)),n.appendChild(r),s&&n.appendChild(document.createTextNode(s)),n}var ge=Ko;var Be=require("obsidian");function w(i,e,t=10,s){if(!i.settings.notificationsEnabled)return;let n=s?Be.Platform.isDesktop?"(click=dismiss, right-click=Info)":"(click=dismiss)":"",r=new Be.Notice(`BRAT ${e} ${n}`,t*1e3);s&&(r.noticeEl.oncontextmenu=()=>{s()})}var Q=(i,e=!0)=>{let t=i.createEl("div");t.style.float="right",e?(t.style.padding="15px",t.style.paddingLeft="15px",t.style.paddingRight="15px",t.style.marginLeft="15px"):(t.style.padding="10px",t.style.paddingLeft="15px",t.style.paddingRight="15px");let s=t.createDiv("coffee");s.addClass("ex-twitter-span"),s.style.paddingLeft="10px";let n=s.createDiv();n.innerText="Learn more about my work at:",s.appendChild(n);let r=s.createEl("a",{href:"https://tfthacker.com"});return r.innerText="https://tfthacker.com",t};var Ti=require("obsidian"),Fe=class extends Ti.SuggestModal{constructor(e,t,s,n,r){super(e),this.versions=s,this.selected=n,this.onChoose=r,this.setTitle("Select a version"),this.setPlaceholder(`Type to search for a version for ${t}`),this.setInstructions([{command:"\u2191\u2193",purpose:"Navigate versions"},{command:"\u21B5",purpose:"Select version"},{command:"esc",purpose:"Dismiss modal"}])}getSuggestions(e){let t=e.toLowerCase();return this.versions.filter(s=>s.version.toLowerCase().contains(t))}renderSuggestion(e,t){t.createEl("div",{text:`${e.version} ${e.prerelease?"(Prerelease)":""}`})}onChooseSuggestion(e){this.onChoose(e.version)}onNoSuggestion(){this.onChoose(this.selected?this.selected:""),this.close()}};var H=class extends B.Modal{constructor(t,s,n=!1,r=!1,o="",u="",l=""){super(t.app);this.versionSetting=null;this.repositoryAddressEl=null;this.tokenInputEl=null;this.validateButton=null;this.validator=null;this.addPluginButton=null;this.cancelButton=null;this.plugin=t,this.betaPlugins=s,this.address=o,this.version=u,this.secretName=l,this.openSettingsTabAfterwards=n,this.updateVersion=r,this.enableAfterInstall=t.settings.enableAfterInstall,this.giteaInstanceUrl=""}async submitForm(){if(this.address==="")return;let t=this.scrubAddress(this.address);if(this.plugin.settings.pluginSubListFrozenVersion.find(r=>r.repo===t)){await this.betaPlugins.addPlugin(t,!1,!1,!1,this.version,!0,this.enableAfterInstall,this.secretName)&&this.close(),this.resetButtons();return}if(!this.version&&Oe(this.plugin,t)){w(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.secretName)&&this.close(),this.resetButtons()}resetButtons(){var t,s,n,r;(t=this.cancelButton)==null||t.setDisabled(!1),(s=this.addPluginButton)==null||s.setDisabled(!1),(n=this.addPluginButton)==null||n.setButtonText("Add Plugin"),(r=this.versionSetting)==null||r.setDisabled(!1)}updateVersionDropdown(t,s,n=""){let r;t.clear(),s.length>0&&!n&&this.plugin.settings.selectLatestPluginVersionByDefault?(r="latest",this.version="latest"):r=n,s.length<20||B.Platform.isMobile?t.addDropdown(u=>{u.addOption("","Select a version"),u.addOption("latest","Latest version");for(let l of s)u.addOption(l.version,`${l.version} ${l.prerelease?"(Prerelease)":""}`);u.onChange(l=>{var g;this.version=l,(g=this.addPluginButton)==null||g.setDisabled(this.version==="")}),u.setValue(r),u.selectEl.addClass("brat-version-selector"),u.selectEl.style.width="100%"}):t.addButton(u=>{u.setButtonText(r==="latest"?"Latest version":r||"Select a version...").setClass("brat-version-selector").setClass("button").onClick(()=>{let g=[{version:"latest",prerelease:!1},...s];new Fe(this.app,this.address,g,r,a=>{var c;this.version=a,u.setButtonText(a==="latest"?"Latest version":a||"Select a version..."),(c=this.addPluginButton)==null||c.setDisabled(this.version==="")}).open()})})}scrubAddress(t){let s=t.trim();return/^[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+$/.test(s)?s:/github\.com/i.test(s)?s.replace(/https?:\/\/github\.com\//i,"").replace(/\.git$/i,"").replace(/\/$/,""):s.replace(/\.git$/i,"").replace(/\/$/,"")}isValidRepository(t){let s=t.trim().replace(/\.git$/i,""),n=/^(?:https?:\/\/github\.com\/)?([a-zA-Z0-9._-]+)\/([a-zA-Z0-9._-]+)$/i,r=/^https?:\/\/[a-zA-Z0-9.-]+\/[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+$/i;return n.test(s)||r.test(s)}onOpen(){let t=this.contentEl.createEl("h4");this.address?(t.appendText("Change plugin version: "),t.appendChild(ge(this.address))):t.setText("Repository for beta plugin:"),this.contentEl.createEl("form",{},s=>{s.addClass("brat-modal"),(!this.address||!this.updateVersion)&&new B.Setting(s).setClass("repository-setting").then(d=>{d.addText(a=>{this.repositoryAddressEl=a,a.setPlaceholder(`Repository URL or path GitHub: GitHubUserName/repo (or full URL) Gitea: https://git.example.com/user/repo`),a.setValue(this.address),a.onChange(c=>{var p,m;this.address=this.scrubAddress(c.trim()),this.version!==""&&(!this.address||!this.isValidRepository(this.address))&&this.versionSetting&&(this.updateVersionDropdown(this.versionSetting,[]),this.versionSetting.settingEl.classList.add("disabled-setting"),this.versionSetting.setDisabled(!0),a.inputEl.classList.remove("valid-repository"),a.inputEl.classList.remove("invalid-repository")),this.version||(this.isValidRepository(this.address)?(p=this.addPluginButton)==null||p.setDisabled(!1):(m=this.addPluginButton)==null||m.setDisabled(!0))}),a.inputEl.addEventListener("keydown",async c=>{c.key==="Enter"&&(this.address&&(this.updateVersion&&this.version!==""||!this.updateVersion)&&(c.preventDefault(),this.disableForm(),this.submitForm()),await this.updateRepositoryVersionInfo(this.version,n))}),a.inputEl.addEventListener("blur",async()=>{await this.updateRepositoryVersionInfo(this.version,n)}),d.setDesc("Repository"),a.inputEl.style.width="100%"})});let n=s.createDiv("validation-status");this.address||n.setText(`Enter a repository address to validate it. Supports GitHub and Gitea.`),this.versionSetting=new B.Setting(s).setClass("version-setting").setClass("disabled-setting"),this.updateVersionDropdown(this.versionSetting,[],this.version),this.versionSetting.setDisabled(!0);let r=s.createDiv("token-setting");if(new B.Setting(r).setName("Access Token").setDesc("Select a secret as token for this repository (optional)").addComponent(g=>new B.SecretComponent(this.plugin.app,g).setValue(this.secretName).onChange(async d=>{var c,p,m,P,E;if(this.secretName=(d==null?void 0:d.trim())||"",!this.secretName){this.address&&Oe(this.plugin,this.address)&&(wt(this.plugin,this.address,""),w(this.plugin,`Token setting cleared for ${this.address}`,3)),this.updateRepositoryVersionInfo(this.version,n);return}let a=this.secretName?this.plugin.app.secretStorage.getSecret(this.secretName):null;a&&(this.validToken=await((c=this.validator)==null?void 0:c.validateToken(a,this.address)),this.validToken?((P=this.validateButton)==null||P.setButtonText("Valid"),(E=this.validateButton)==null||E.setDisabled(!0),this.address&&(await this.updateRepositoryVersionInfo(this.version,n),Oe(this.plugin,this.address)&&(wt(this.plugin,this.address,this.secretName),w(this.plugin,`Token setting updated for ${this.address}`,3)))):((p=this.validateButton)==null||p.setButtonText("Invalid"),(m=this.validateButton)==null||m.setDisabled(!1)))})),this.validator=new K,this.secretName){let g=this.plugin.app.secretStorage.getSecret(this.secretName);g&&this.validator.validateToken(g,this.address).then(d=>{var a,c;this.validToken=d,this.validToken&&((a=this.validateButton)==null||a.setButtonText("Valid"),(c=this.validateButton)==null||c.setDisabled(!0))})}s.createDiv("modal-button-container",g=>{var d;g.createEl("label",{cls:"mod-checkbox"},a=>{let c=a.createEl("input",{attr:{tabindex:-1},type:"checkbox"});c.checked=this.enableAfterInstall,c.addEventListener("click",()=>{this.enableAfterInstall=c.checked}),a.appendText("Enable after installing the plugin")}),this.cancelButton=new B.ButtonComponent(g).setButtonText("Never mind").setClass("mod-cancel").onClick(()=>this.close()),this.addPluginButton=new B.ButtonComponent(g).setButtonText(this.updateVersion&&this.address?"Change version":"Add plugin").setCta().onClick(()=>{this.address!==""&&(this.updateVersion&&this.version!==""||!this.updateVersion)&&(this.disableForm(),this.submitForm())}),(this.updateVersion||this.address==="")&&((d=this.addPluginButton)==null||d.setDisabled(!0))});let o=s.createDiv();o.style.borderTop="1px solid var(--background-modifier-border)",o.style.marginTop="30px",o.style.paddingTop="8px";let u=o.createSpan();u.createEl("a",{href:"https://bit.ly/o42-twitter",text:"TFTHacker"}),u.appendText(" and "),u.createEl("a",{href:"https://github.com/johannrichard",text:"johannrichard"}),u.appendText(" \u2014 Gitea fork"),u.style.fontStyle="italic",o.appendChild(u),Q(o,!1);let l=s.querySelectorAll("button");for(let g of Array.from(l))g.setAttribute("type","button");s.addEventListener("submit",g=>{g.preventDefault(),g.stopPropagation()})}),this.address&&window.setTimeout(async()=>{await this.updateRepositoryVersionInfo(this.version)},100)}disableForm(){var t,s,n,r;(t=this.addPluginButton)==null||t.setDisabled(!0),(s=this.addPluginButton)==null||s.setButtonText("Installing \u2026"),(n=this.cancelButton)==null||n.setDisabled(!0),(r=this.versionSetting)==null||r.setDisabled(!0)}async updateRepositoryVersionInfo(t="",s){var o,u,l;let n=this.repositoryAddressEl;if(!this.address){s==null||s.setText("Repository address is required."),s==null||s.addClass("validation-status-error");return}if(!this.isValidRepository(this.address)){s==null||s.setText("Invalid address. Expected: user/repo (GitHub) or https://host/user/repo (Gitea)."),s==null||s.addClass("validation-status-error");return}s==null||s.setText("Validating repository..."),s==null||s.removeClass("validation-status-error"),this.versionSetting&&this.updateVersion&&this.updateVersionDropdown(this.versionSetting,[]);let r=this.scrubAddress(this.address);try{let g="";if(this.secretName){let p=this.plugin.app.secretStorage.getSecret(this.secretName);p&&(g=p)}else if(this.plugin.settings.globalTokenName){let p=this.plugin.app.secretStorage.getSecret(this.plugin.settings.globalTokenName);p&&(g=p)}let{provider:d,parsed:a}=j(r),c=await d.listReleases(a,g);c&&c.length>0?(n==null||n.inputEl.classList.remove("invalid-repository"),n==null||n.inputEl.classList.add("valid-repository"),s==null||s.setText(""),this.versionSetting&&(this.versionSetting.settingEl.classList.remove("disabled-setting"),this.versionSetting.setDisabled(!1),this.updateVersionDropdown(this.versionSetting,c,t))):(n==null||n.inputEl.classList.remove("valid-repository"),n==null||n.inputEl.classList.add("invalid-repository"),s==null||s.setText("No releases found in this repository."),s==null||s.addClass("validation-status-error"),(o=this.versionSetting)==null||o.settingEl.classList.add("disabled-setting"),(u=this.versionSetting)==null||u.setDisabled(!0),(l=this.addPluginButton)==null||l.setDisabled(!0))}catch(g){if(g instanceof N)n==null||n.inputEl.classList.remove("valid-repository"),n==null||n.inputEl.classList.add("validation-error"),s==null||s.setText(`API rate limit exceeded. Try again in ${g.getMinutesToReset()} minutes.`),this.disableVersionAndButton(),w(this.plugin,`${g.message} Consider adding an access token in settings.`,20);else if(g instanceof A){switch(g.status){case 404:s==null||s.setText("Repository not found. Check the address or provide a valid token for private repos.");break;case 403:s==null||s.setText("Access denied. Check your access token.");break;default:s==null||s.setText(`Error: ${g.message}`)}s==null||s.addClass("validation-status-error"),this.disableVersionAndButton(),w(this.plugin,g.message,20)}else s==null||s.setText(`Unexpected error: ${g}. Enable debug mode for details.`),s==null||s.addClass("validation-status-error"),this.disableVersionAndButton()}}disableVersionAndButton(){var t,s;(t=this.versionSetting)==null||t.setDisabled(!0),(s=this.addPluginButton)==null||s.setDisabled(!0)}onClose(){this.openSettingsTabAfterwards&&(this.plugin.app.setting.open(),this.plugin.app.setting.openTabById(this.plugin.APP_ID))}};var Pi=require("obsidian");async function qe(){try{let i=await(0,Pi.requestUrl)(`https://obsidian.md/?${Math.random()}`);return i.status>=200&&i.status<300}catch(i){return!1}}var yi=O(),Me=tt(),pe=class{constructor(e){this.plugin=e}resolveProvider(e){return j(e)}getGiteaUrlForRepo(e){var s;let t=this.plugin.settings.pluginSubListFrozenVersion.find(n=>n.repo===e);return(s=t==null?void 0:t.giteaUrl)!=null?s:""}async getTokenForRepo(e,t){return t?await this.plugin.app.secretStorage.getSecret(t)||"":this.plugin.settings.globalTokenName&&await this.plugin.app.secretStorage.getSecret(this.plugin.settings.globalTokenName)||""}displayAddNewPluginModal(e=!1,t=!1,s="",n="",r=""){new H(this.plugin,this,e,t,s,n,r).open()}async validateRepository(e,t=!1,s=!1,n="",r="",o=""){let{provider:l,parsed:g}=this.resolveProvider(e),d=r;try{let a=await l.getRepoInfo(g,d),c=await l.getRelease(g,n||void 0,t,d);if(!c)return s&&(w(this.plugin,`${e} This does not seem to be an obsidian plugin with valid releases, as there are no releases available.`,15),console.error("BRAT: validateRepository",e)),null;let p=await l.getAsset(c,"manifest.json",a.isPrivate,d);if(!p)return s&&w(this.plugin,`${e} This does not seem to be an obsidian plugin, as there is no manifest.json file in the release.`,15),null;let m=JSON.parse(p);if(!("id"in m))return s&&w(this.plugin,`${e} The plugin id attribute is missing from the manifest file`,15),null;if(!("version"in m))return s&&w(this.plugin,`${e} The version attribute is missing from the manifest file`,15),null;try{let P=Me(c.tag_name,{includePrerelease:!0,loose:!0}),E=Me(m.version,{includePrerelease:!0,loose:!0});P&&E&&yi(P,E)!==0&&(s&&w(this.plugin,`${e} Version mismatch: release tag '${c.tag_name}' vs manifest '${m.version}'. Using release version.`,15),m.version=P.version)}catch(P){}return m}catch(a){if(a instanceof N){let c=`${g.host} API rate limit exceeded. Reset in ${a.getMinutesToReset()} minutes.`;throw s&&w(this.plugin,c,15),console.error(`BRAT: validateRepository ${a}`),w(this.plugin,`${a.message} Consider adding a personal access token in BRAT settings for higher limits.`,20),a}if(a instanceof A)throw s&&(a.status===401?w(this.plugin,`${e} Authentication error. Verify that your access token is valid.`,15):w(this.plugin,`${e} API error ${a.status}: ${a.message}`,15)),console.error(`BRAT: validateRepository ${a}`),a;return s&&w(this.plugin,`${e} Unspecified error: ${a}. Enable debug for more info.`,15),null}}async getAllReleaseFiles(e,t,s="",n="",r=""){let{provider:o,parsed:u}=this.resolveProvider(e),g=(await o.getRepoInfo(u,n)).isPrivate,d=await o.getRelease(u,s||void 0,t,n);if(!d)return Promise.reject("No release found");let a=t||s!=="";return console.log({reallyGetManifestOrNot:a,version:d.tag_name}),{mainJs:await o.getAsset(d,"main.js",g,n),manifest:a?await o.getAsset(d,"manifest.json",g,n):"",styles:await o.getAsset(d,"styles.css",g,n)}}async writeReleaseFilesToPluginFolder(e,t){var r,o;let s=`${(0,F.normalizePath)(`${this.plugin.app.vault.configDir}/plugins/${e}`)}/`,{adapter:n}=this.plugin.app.vault;await n.exists(s)||await n.mkdir(s),await n.write(`${s}main.js`,(r=t.mainJs)!=null?r:""),await n.write(`${s}manifest.json`,(o=t.manifest)!=null?o:""),t.styles&&await n.write(`${s}styles.css`,t.styles)}async addPlugin(e,t=!1,s=!1,n=!1,r="",o=!1,u=this.plugin.settings.enableAfterInstall,l=""){try{this.plugin.settings.debuggingMode&&console.log("BRAT: addPlugin",e,t,s,n,r,o,u,l?"with secret":"public");let{provider:g,parsed:d}=this.resolveProvider(e),a="";l&&l.trim()!==""?(a=await this.plugin.app.secretStorage.getSecret(l)||"",a||w(this.plugin,`Secret not found for token name: ${l}. Please add it to SecretStorage or clear the token name for this plugin.`,10)):this.plugin.settings.globalTokenName&&(a=await this.plugin.app.secretStorage.getSecret(this.plugin.settings.globalTokenName)||"");let c=this.getGiteaUrlForRepo(e),p=10,m=await this.validateRepository(e,!0,!0,r,a,c),P=!!m;if(P||(m=await this.validateRepository(e,!1,!0,r,a,c)),m===null){let R=`${e} A manifest.json file does not exist in the latest release. This plugin cannot be installed.`;return await this.plugin.log(R,!0),w(this.plugin,R,p),!1}if(!Object.hasOwn(m,"version")){let R=`${e} The manifest.json does not have a version number. Cannot install.`;return await this.plugin.log(R,!0),w(this.plugin,R,p),!1}let E=!1;if(Object.hasOwn(m,"minAppVersion")&&!(0,F.requireApiVersion)(m.minAppVersion)){if(r===""||r==="latest"||!this.plugin.settings.allowIncompatiblePlugins){let T=`Plugin: ${e} Requires Obsidian ${m.minAppVersion}, but you have ${F.apiVersion}. Update Obsidian or contact the developer.`;return await this.plugin.log(T,!0),w(this.plugin,T,30),!1}if(!await ze({app:this.plugin.app,message:createFragment(T=>{T.appendText("Plugin: "),T.createEl("code",{text:e}),T.createEl("br"),T.appendText("The manifest requires Obsidian "),T.createEl("code",{text:m.minAppVersion}),T.appendText(", but you have "),T.createEl("code",{text:F.apiVersion}),T.appendText(". Install at your own risk?")})}))return!1;E=!0}let se=async()=>{var D,X;let R=await this.getAllReleaseFiles(e,P,r,a,c);(P||R.manifest==="")&&(R.manifest=JSON.stringify(m));let T=JSON.parse((D=R.manifest)!=null?D:"");if(E&&(T.brat={isIncompatible:!0,minAppVersionOriginal:T.minAppVersion},T.minAppVersion=F.apiVersion),F.Platform.isMobile&&T.isDesktopOnly)if(this.plugin.settings.allowIncompatiblePlugins){if(!await ze({app:this.plugin.app,message:createFragment($=>{$.appendText("Plugin: "),$.createEl("code",{text:e}),$.createEl("br"),$.appendText("This plugin is desktop-only, but you are on mobile."),$.createEl("br"),$.appendText("Install at your own risk?")})}))return null;T.isDesktopOnly=!1,(X=T.brat)!=null||(T.brat={}),T.brat.isDesktopOnlyOriginal=!0,T.brat.isIncompatible=!0,E=!0}else{let x=`Plugin: ${e} Cannot install desktop-only plugin on mobile.`;return await this.plugin.log(x,!0),w(this.plugin,x,30),null}if(E&&(R.manifest=JSON.stringify(T)),R.mainJs===null){let x=`${e} main.js is missing from the release.`;return await this.plugin.log(x,!0),w(this.plugin,x,p),null}return R};if(!t||o){let R=await se();if(R===null)return!1;if(await this.writeReleaseFilesToPluginFolder(m.id,R),hi(this.plugin,e,r,E,l,d.isGitHub?"":d.rawBaseUrl),u){let{plugins:T}=this.plugin.app,D=(0,F.normalizePath)(`${T.getPluginFolder()}/${m.id}`);await T.loadManifest(D),await T.enablePluginAndSave(m.id)}if(await this.plugin.app.plugins.loadManifests(),o)await this.reloadPlugin(m.id),await this.plugin.log(`${e} reinstalled`,!0),w(this.plugin,`${e} Plugin reinstalled (version ${m.version})`,p);else{let T=r===""?"":` (version: ${r})`,D=`${e}${T} Plugin registered with BRAT.`;u||(D+=" You may need to enable it in Community Plugins."),await this.plugin.log(D,!0),w(this.plugin,D,p)}}else{let T=`${`${this.plugin.app.vault.configDir}/plugins/${m.id}/`}manifest.json`,D=this.plugin.app.vault.adapter;if(!await D.exists(T))return await this.addPlugin(e,!1,P,!1,r,!1,this.plugin.settings.enableAfterInstall,l);let X=await D.read(T);if(r!==""&&r!=="latest")return w(this.plugin,`${e} version is frozen, not updating.`,3),!1;let x=JSON.parse(X),$=Me(x.version,{includePrerelease:!0,loose:!0}),be=Me(m.version,{includePrerelease:!0,loose:!0});if($&&be&&yi($,be)===-1){let G=await se();if(G===null)return!1;if(s){let Pt=`Update available for ${m.id}: ${x.version} \u2192 ${m.version}. `;return await this.plugin.log(Pt,!0),w(this.plugin,Pt,30),!1}await this.writeReleaseFilesToPluginFolder(m.id,G),await this.plugin.app.plugins.loadManifests();let je=await this.reloadPlugin(m.id),Tt=je?`${m.id} Updated: ${x.version} \u2192 ${m.version}. `:`${m.id} Updated files to ${m.version}, but failed to re-enable automatically. Enable it manually in Community Plugins.`;return await this.plugin.log(Tt,!0),w(this.plugin,Tt,je?30:0),je}return n&&w(this.plugin,`No update for ${e}`,3),!0}}catch(g){console.error(`BRAT: Error adding plugin ${e}:`,g);let d=g instanceof Error?g.message:"Unknown error";return await this.plugin.log(`Error ${t?"updating":"adding"} plugin ${e}: ${d}`,!0),!1}return!0}async reloadPlugin(e){let{plugins:t}=this.plugin.app;try{return await t.disablePlugin(e),await t.enablePlugin(e),!0}catch(s){let n=s instanceof Error?s.message:String(s);console.error(`BRAT: Failed to reload plugin ${e}`,s),await this.plugin.log(`Failed to reload ${e} after update: ${n}`,!0);try{return await t.enablePluginAndSave(e),!0}catch(r){let o=r instanceof Error?r.message:String(r);return console.error(`BRAT: Fallback re-enable failed for ${e}`,r),await this.plugin.log(`Fallback re-enable also failed for ${e}: ${o}`,!0),!1}}}async updatePlugin(e,t=!1,s=!1,n=!1,r=""){let o=await this.addPlugin(e,!0,t,s,"",n,!1,r);return!o&&!t&&w(this.plugin,`${e} Update failed.`),o}async checkForPluginUpdatesAndInstallUpdates(e=!1,t=!1){if(!await qe()){console.log("BRAT: No internet detected.");return}let s,n="Checking for plugin updates STARTED";await this.plugin.log(n,!0),e&&this.plugin.settings.notificationsEnabled&&(s=new F.Notice(`BRAT ${n}`,3e4));let r=new Map(this.plugin.settings.pluginSubListFrozenVersion.map(l=>[l.repo,l.version])),o=new Map(this.plugin.settings.pluginSubListFrozenVersion.map(l=>[l.repo,l.tokenName||""]));for(let l of this.plugin.settings.pluginList){let g=r.get(l);g&&g!=="latest"||await this.updatePlugin(l,t,!1,!1,o.get(l)||"")}let u="Checking for plugin updates COMPLETED";await this.plugin.log(u,!0),e&&(s&&s.hide(),w(this.plugin,u,10))}deletePlugin(e){let t=`Removed ${e} from BRAT plugin list`;this.plugin.log(t,!0),this.plugin.settings.pluginList=this.plugin.settings.pluginList.filter(s=>s!==e),this.plugin.settings.pluginSubListFrozenVersion=this.plugin.settings.pluginSubListFrozenVersion.filter(s=>s.repo!==e),this.plugin.saveSettings()}getEnabledDisabledPlugins(e){let t=this.plugin.app.plugins,s=Object.values(t.manifests),n=Object.values(t.plugins).map(r=>r.manifest);return e?s.filter(r=>n.find(o=>r.id===o.id)):s.filter(r=>!n.find(o=>r.id===o.id))}checkIncompatiblePlugins(){let e=this.plugin.settings.pluginSubListFrozenVersion.filter(t=>t.isIncompatible).map(t=>t.repo);e.length>0&&w(this.plugin,`The following incompatible plugins were forcefully installed and may not work as expected: ${e.join(` `)}`,30)}};var z=require("obsidian");function Qo(i){let e=0;for(let t=0;tQo(i).toString(),de=async(i,e,t)=>{let{provider:s,parsed:n}=j(e),r=await s.getRawFile(n,"theme-beta.css","HEAD");if(r||(r=await s.getRawFile(n,"theme.css","HEAD")),!r)return w(i,"No theme.css or theme-beta.css found in the repository root. Cannot install theme."),!1;let o=await s.getRawFile(n,"manifest.json","HEAD");if(!o)return w(i,"No manifest.json found in the repository root. Theme cannot be installed."),!1;let u=await JSON.parse(o),l=(0,z.normalizePath)(ea(i)+u.name),{adapter:g}=i.app.vault;await g.exists(l)||await g.mkdir(l),await g.write((0,z.normalizePath)(`${l}/theme.css`),r),await g.write((0,z.normalizePath)(`${l}/manifest.json`),o),wi(i,e,Ri(r));let d="";return t?(fi(i,e,r),d=`${u.name} theme installed from ${e}. `,setTimeout(()=>{i.app.customCss.setTheme(u.name)},500)):d=`${u.name} theme updated from ${e}.`,i.log(d,!1),w(i,d,20,()=>{window.open(`${n.rawBaseUrl}/${n.owner}/${n.repo}`)}),!0},ee=async(i,e)=>{if(!await qe()){console.log("BRAT: No internet detected.");return}let t,s="Checking for beta theme updates STARTED";await i.log(s,!0),e&&i.settings.notificationsEnabled&&(t=new z.Notice(`BRAT ${s}`,3e4));for(let r of i.settings.themesList){let{provider:o,parsed:u}=j(r.repo),l=await Ei(o,u,!0);l==="0"&&(l=await Ei(o,u,!1)),l!==r.lastUpdate&&await de(i,r.repo,!1)}let n="Checking for beta theme updates COMPLETED";await i.log(n,!0),e&&(i.settings.notificationsEnabled&&t&&t.hide(),w(i,n))},Ve=(i,e)=>{i.settings.themesList=i.settings.themesList.filter(s=>s.repo!==e),i.saveSettings();let t=`Removed ${e} from BRAT themes list. Theme files still exist \u2014 remove via Settings > Appearance.`;i.log(t,!0),w(i,t)},ea=i=>`${(0,z.normalizePath)(`${i.app.vault.configDir}/themes`)}/`;async function Ei(i,e,t){let s=t?"theme-beta.css":"theme.css",n=await i.getRawFile(e,s,"HEAD");return n?Ri(n):"0"}var $i="brat-migrations";async function ta(i,e){try{let t=await i.vault.adapter.read(`${i.vault.configDir}/plugins/obsidian42-brat/${$i}.json`);return JSON.parse(t).appliedMigrations.includes(e)}catch(t){return!1}}async function sa(i,e){try{let t=`${i.vault.configDir}/plugins/obsidian42-brat/${$i}.json`,s={appliedMigrations:[]};try{let n=await i.vault.adapter.read(t);s=JSON.parse(n)}catch(n){}s.appliedMigrations.includes(e)||(s.appliedMigrations.push(e),await i.vault.adapter.write(t,JSON.stringify(s,null,2)))}catch(t){console.error(`BRAT: Failed to mark migration ${e} complete:`,t)}}async function Ai(i,e,t){let s="tokens-to-secretstorage-v1";if(!await ta(i,s))try{let n=0,r=l=>{let d=`brat-gh-${l.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}`;return d.length>64?d.substring(0,64).replace(/-$/,""):d},o=l=>{let g=i.secretStorage.listSecrets();for(let d of g)if(i.secretStorage.getSecret(d)===l)return d;return null},u=(l,g)=>{let d=o(l);return d?(console.log(`BRAT: Reusing existing secret "${d}"`),d):(i.secretStorage.setSecret(g,l),console.log(`BRAT: Created new secret "${g}"`),g)};if(e.personalAccessToken&&e.personalAccessToken.trim()!==""){let l=e.personalAccessToken.trim(),d=u(l,"brat-gh-global");e.globalTokenName=d,e.personalAccessToken="",n++}if(e.pluginSubListFrozenVersion){for(let l of e.pluginSubListFrozenVersion)if(l.token&&l.token.trim()!==""){let g=l.token.trim(),d=r(l.repo),a=u(g,d);l.tokenName=a,l.token=void 0,n++}}n>0&&(await t(),console.log(`BRAT: Migrated ${n} token(s) to SecretStorage`)),await sa(i,s)}catch(n){console.error("BRAT: Failed to migrate tokens to SecretStorage:",n)}}var Y=require("obsidian");var U=class extends Y.Modal{constructor(e,t=!1){super(e.app),this.plugin=e,this.address="",this.openSettingsTabAfterwards=t}async submitForm(){if(this.address==="")return;let e=this.address.replace("https://github.com/","");if(bi(this.plugin,e)){w(this.plugin,"This theme is already in the list for beta testing",10);return}await de(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 Y.Setting(e).addText(n=>{n.setPlaceholder("Repository (example: https://github.com/user/repo or https://git.example.com/user/repo)"),n.setValue(this.address),n.onChange(r=>{this.address=r.trim()}),n.inputEl.addEventListener("keydown",r=>{r.key==="Enter"&&this.address!==" "&&(r.preventDefault(),this.submitForm())}),n.inputEl.style.width="100%",window.setTimeout(()=>{let r=document.querySelector(".setting-item-info");r&&r.remove(),n.inputEl.focus()},10)}),e.createDiv("modal-button-container",n=>{new Y.ButtonComponent(n).setButtonText("Never mind").onClick(()=>{this.close()}),new Y.ButtonComponent(n).setButtonText("Add theme").setCta().onClick(r=>{r.preventDefault(),console.log("Add theme button clicked"),this.address!==""&&this.submitForm()})});let t=e.createDiv();t.style.borderTop="1px solid #ccc",t.style.marginTop="30px";let s=t.createSpan();s.createEl("a",{href:"https://bit.ly/o42-twitter",text:"TFTHacker"}),s.appendText(" and "),s.createEl("a",{href:"https://github.com/johannrichard",text:"johannrichard"}),s.style.fontStyle="italic",t.appendChild(s),Q(t,!1),window.setTimeout(()=>{let n=e.querySelectorAll(".brat-modal .setting-item-info");for(let r of Array.from(n))r.remove()},50)})}onClose(){this.openSettingsTabAfterwards&&(this.plugin.app.setting.openTab(),this.plugin.app.setting.openTabById(this.plugin.APP_ID))}};var Ii=require("obsidian");function Ci(){(0,Ii.addIcon)("BratIcon",'')}var vt=require("obsidian"),Si=async(i=!0)=>{let e="https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-plugins.json";try{let t=await(0,vt.requestUrl)({url:e});return t.status===404?null:t.json}catch(t){return i&&console.log("error in grabCommmunityPluginList",t),null}},ki=async(i=!0)=>{let e="https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-css-themes.json";try{let t=await(0,vt.requestUrl)({url:e});return t.status===404?null:t.json}catch(t){return i&&console.log("error in grabCommmunityThemesList",t),null}};var Li=require("obsidian"),M=class extends Li.FuzzySuggestModal{constructor(t){super(t.app);this.data=[];this.scope.register(["Shift"],"Enter",s=>{this.enterTrigger(s)}),this.scope.register(["Ctrl"],"Enter",s=>{this.enterTrigger(s)})}setSuggesterData(t){this.data=t}display(t){this.callbackFunction=t,this.open()}getItems(){return this.data}getItemText(t){return t.display}onChooseItem(){}renderSuggestion(t,s){s.createEl("div",{text:t.item.display})}enterTrigger(t){var r;let s=(r=document.querySelector(".suggestion-item.is-selected div"))==null?void 0:r.textContent,n=this.data.find(o=>o.display===s);n&&(this.invokeCallback(n,t),this.close())}onChooseSuggestion(t,s){this.invokeCallback(t.item,s)}invokeCallback(t,s){typeof this.callbackFunction=="function"&&this.callbackFunction(t,s)}};var me=class{constructor(e){this.bratCommands=[{id:"AddBetaPlugin",icon:"BratIcon",name:"Plugins: Add a beta plugin for testing (with or without version)",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 e=new Map(this.plugin.settings.pluginSubListFrozenVersion.map(n=>[n.repo,{version:n.version,token:n.token}])),t=Object.values(this.plugin.settings.pluginList).filter(n=>{let r=e.get(n);return!(r!=null&&r.version)||r.version==="latest"}).map(n=>({display:n,info:n})),s=new M(this.plugin);s.setSuggesterData(t),s.display(n=>{let r=`Checking for updates for ${n.info}`,o=e.get(n.info);this.plugin.log(r,!0),w(this.plugin,` ${r}`,3),this.plugin.betaPlugins.updatePlugin(n.info,!1,!0,!1,o==null?void 0:o.token)})}},{id:"reinstallOnePlugin",icon:"BratIcon",name:"Plugins: Choose a single plugin to reinstall",showInRibbon:!0,callback:()=>{let e=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(n=>n.repo)),t=Object.values(this.plugin.settings.pluginList).filter(n=>!e.has(n)).map(n=>({display:n,info:n})),s=new M(this.plugin);s.setSuggesterData(t),s.display(n=>{let r=`Reinstalling ${n.info}`;w(this.plugin,` ${r}`,3),this.plugin.log(r,!0),this.plugin.betaPlugins.updatePlugin(n.info,!1,!1,!0)})}},{id:"restartPlugin",icon:"BratIcon",name:"Plugins: Restart a plugin that is already installed",showInRibbon:!0,callback:()=>{let e=Object.values(this.plugin.app.plugins.manifests).map(s=>({display:s.id,info:s.id})),t=new M(this.plugin);t.setSuggesterData(e),t.display(s=>{w(this.plugin,`${s.info} Plugin reloading .....`,5),this.plugin.betaPlugins.reloadPlugin(s.info)})}},{id:"disablePlugin",icon:"BratIcon",name:"Plugins: Disable a plugin - toggle it off",showInRibbon:!0,callback:()=>{let e=this.plugin.betaPlugins.getEnabledDisabledPlugins(!0).map(s=>({display:`${s.name} (${s.id})`,info:s.id})),t=new M(this.plugin);t.setSuggesterData(e),t.display(s=>{this.plugin.log(`${s.display} plugin disabled`,!1),this.plugin.settings.debuggingMode&&console.log(s.info),this.plugin.app.plugins.disablePluginAndSave(s.info)})}},{id:"enablePlugin",icon:"BratIcon",name:"Plugins: Enable a plugin - toggle it on",showInRibbon:!0,callback:()=>{let e=this.plugin.betaPlugins.getEnabledDisabledPlugins(!1).map(s=>({display:`${s.name} (${s.id})`,info:s.id})),t=new M(this.plugin);t.setSuggesterData(e),t.display(s=>{this.plugin.log(`${s.display} plugin enabled`,!1),this.plugin.app.plugins.enablePluginAndSave(s.info)})}},{id:"openGitHubZRepository",icon:"BratIcon",name:"Plugins: Open the GitHub repository for a plugin",showInRibbon:!0,callback:async()=>{let e=await Si(this.plugin.settings.debuggingMode);if(e){let t=Object.values(e).map(r=>({display:`Plugin: ${r.name} (${r.repo})`,info:r.repo})),s=Object.values(this.plugin.settings.pluginList).map(r=>({display:`BRAT: ${r}`,info:r}));for(let r of t)s.push(r);let n=new M(this.plugin);n.setSuggesterData(s),n.display(r=>{r.info&&window.open(`https://github.com/${r.info}`)})}}},{id:"openGitHubRepoTheme",icon:"BratIcon",name:"Themes: Open the GitHub repository for a theme (appearance)",showInRibbon:!0,callback:async()=>{let e=await ki(this.plugin.settings.debuggingMode);if(e){let t=Object.values(e).map(n=>({display:`Theme: ${n.name} (${n.repo})`,info:n.repo})),s=new M(this.plugin);s.setSuggesterData(t),s.display(n=>{n.info&&window.open(`https://github.com/${n.info}`)})}}},{id:"opentPluginSettings",icon:"BratIcon",name:"Plugins: Open Plugin Settings Tab",showInRibbon:!0,callback:()=>{let e=this.plugin.app.setting,t=Object.values(e.pluginTabs).map(r=>({display:`Plugin: ${r.name}`,info:r.id})),s=new M(this.plugin),n=Object.values(e.settingTabs).map(r=>({display:`Core: ${r.name}`,info:r.id}));for(let r of t)n.push(r);s.setSuggesterData(n),s.display(r=>{e.open(),e.openTabById(r.info)})}},{id:"GrabBetaTheme",icon:"BratIcon",name:"Themes: Grab a beta theme for testing from a Github repository",showInRibbon:!0,callback:()=>{new U(this.plugin).open()}},{id:"updateBetaThemes",icon:"BratIcon",name:"Themes: Update beta themes",showInRibbon:!0,callback:async()=>{await ee(this.plugin,!0)}},{id:"allCommands",icon:"BratIcon",name:"All Commands list",showInRibbon:!1,callback:()=>{this.ribbonDisplayCommands()}}];this.plugin=e;for(let t of this.bratCommands)this.plugin.addCommand({id:t.id,name:t.name,icon:t.icon,callback:()=>{t.callback()}})}ribbonDisplayCommands(){let e=[];for(let o of this.bratCommands)o.showInRibbon&&e.push({display:o.name,info:o.callback});let t=new M(this.plugin),s=this.plugin.app.setting,n=Object.values(s.settingTabs).map(o=>({display:`Core: ${o.name}`,info:()=>{s.open(),s.openTabById(o.id)}})),r=Object.values(s.pluginTabs).map(o=>({display:`Plugin: ${o.name}`,info:()=>{s.open(),s.openTabById(o.id)}}));e.push({display:"---- Core Plugin Settings ----",info:()=>{this.ribbonDisplayCommands()}});for(let o of n)e.push(o);e.push({display:"---- Plugin Settings ----",info:()=>{this.ribbonDisplayCommands()}});for(let o of r)e.push(o);t.setSuggesterData(e),t.display(o=>{typeof o.info=="function"&&o.info()})}};var L=require("obsidian");var Ue=class extends L.PluginSettingTab{constructor(t,s){super(t,s);this.accessTokenSetting=null;this.accessTokenButton=null;this.tokenInfo=null;this.validator=null;this.plugin=s}display(){let{containerEl:t}=this;t.empty(),t.addClass("brat-settings"),new L.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(a=>{a.setValue(this.plugin.settings.enableAfterInstall).onChange(async c=>{this.plugin.settings.enableAfterInstall=c,await this.plugin.saveSettings()})}),new L.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(a=>{a.setValue(this.plugin.settings.updateAtStartup).onChange(async c=>{this.plugin.settings.updateAtStartup=c,await this.plugin.saveSettings()})}),new L.Setting(t).setName("Auto-update themes at startup").setDesc("If enabled all beta themes will be checked for updates each time Obsidian starts.").addToggle(a=>{a.setValue(this.plugin.settings.updateThemesAtStartup).onChange(async c=>{this.plugin.settings.updateThemesAtStartup=c,await this.plugin.saveSettings()})}),new L.Setting(t).setName("Select latest plugin version by default").setDesc("If enabled the latest version will be selected by default when adding a new plugin.").addToggle(a=>{a.setValue(this.plugin.settings.selectLatestPluginVersionByDefault).onChange(async c=>{this.plugin.settings.selectLatestPluginVersionByDefault=c,await this.plugin.saveSettings()})}),new L.Setting(t).setName("Allow incompatible plugins").setDesc("If enabled, plugins with higher app versions will be allowed to be installed. Also it allows desktop-only plugins to be installed on mobile devices.").addToggle(a=>{a.setValue(this.plugin.settings.allowIncompatiblePlugins).onChange(async c=>{this.plugin.settings.allowIncompatiblePlugins=c,await this.plugin.saveSettings()})}),Q(t,!0),t.createEl("hr");let s=new Map(this.plugin.settings.pluginSubListFrozenVersion.map(a=>[a.repo,a])),n=new Map,r=new L.SettingGroup(t).setHeading("Beta plugin list");r.addSearch(a=>{a.setPlaceholder("Filter plugins"),a.onChange(c=>{let p=c.toLowerCase().trim();n.forEach(({container:m,pluginName:P})=>{p===""||P.includes(p)?m.removeAttribute("hidden"):m.setAttribute("hidden","true")})})}),r.addSetting(a=>{let c=document.createDocumentFragment();c.createEl("div",{text:'Plugins added via "Add a beta plugin for testing". Supports both GitHub and Gitea repositories.'}),c.createEl("p"),c.createEl("div",{text:"Click the 'Edit' button next to a plugin to change installed version. Click x to remove from list."}),c.createEl("p"),c.createEl("span").createEl("b",{text:"Note: "}),c.createSpan({text:"Removing from the list does not delete the plugin \u2014 remove from Community Plugins tab instead."}),a.setDesc(c),a.addButton(p=>{p.setButtonText("Add beta plugin").setCta().onClick(()=>{this.plugin.betaPlugins.displayAddNewPluginModal(!0)})})});for(let a of this.plugin.settings.pluginList){let c=s.get(a);r.addSetting(p=>{let m=(c==null?void 0:c.tokenName)||"",P=m?this.plugin.app.secretStorage.getSecret(m):"",E=!!(m&&!P),se=!!(c!=null&&c.giteaUrl),R=document.createDocumentFragment(),T=c!=null&&c.version?` Tracked version: ${c.version} ${c.version==="latest"?"":"(frozen)"}`:"",D=c!=null&&c.isIncompatible?" (incompatible)":"",X=se?" (Gitea)":"";R.createDiv({text:`${T}${D}${X}`}),E&&R.createDiv({text:` Secret not defined or empty: ${m}`,cls:"mod-warning",title:"Token name configured but secret is missing. Add the secret or update the plugin configuration."}),p.setName(ge(a)).setDesc(R);let x=p.settingEl;x.addClass("brat-plugin-item"),se&&x.addClass("brat-plugin-gitea"),n.set(a,{container:x,pluginName:a.toLowerCase()}),(!(c!=null&&c.version)||c.version==="latest")&&p.addButton($=>{E?$.setIcon("sync").setTooltip(`Secret missing: ${m}. Please add the secret or update the plugin configuration.`).setWarning().setDisabled(!0):$.setIcon("sync").setTooltip("Check and update plugin").onClick(async()=>{await this.plugin.betaPlugins.updatePlugin(a,!1,!0,!1,(c==null?void 0:c.tokenName)||"")})}),p.addButton($=>{$.setIcon("edit").setTooltip("Change version and update settings"),E&&$.setWarning(),$.onClick(()=>{this.plugin.betaPlugins.displayAddNewPluginModal(!0,!0,a,c==null?void 0:c.version,(c==null?void 0:c.tokenName)||""),this.plugin.app.setting.updatePluginSection()})}).addButton($=>{$.setIcon("cross").setTooltip("Remove this beta plugin").setWarning().onClick(()=>{if($.buttonEl.textContent==="")$.setButtonText("Click once more to confirm removal");else{let{buttonEl:be}=$,{parentElement:G}=be;G!=null&&G.parentElement&&(G.parentElement.remove(),this.plugin.betaPlugins.deletePlugin(a))}})})})}let o=new Map,u=new L.SettingGroup(t).setHeading("Beta themes list");u.addSetting(a=>a.addButton(c=>{c.setButtonText("Add beta theme").setCta().onClick(()=>{this.plugin.app.setting.close(),new U(this.plugin).open()})})),u.addSearch(a=>{a.setPlaceholder("Filter themes"),a.onChange(c=>{let p=c.toLowerCase().trim();o.forEach(({container:m,themeName:P})=>{p===""||P.includes(p)?m.removeAttribute("hidden"):m.setAttribute("hidden","true")})})});for(let a of this.plugin.settings.themesList)u.addSetting(c=>{c.setName(ge(a.repo));let p=c.settingEl;p.addClass("brat-theme-item"),o.set(a.repo,{container:p,themeName:a.repo.toLowerCase()}),c.addButton(m=>{m.setIcon("cross").setTooltip("Delete this beta theme").onClick(()=>{if(m.buttonEl.textContent==="")m.setButtonText("Click once more to confirm removal");else{let{buttonEl:P}=m,{parentElement:E}=P;E!=null&&E.parentElement&&(E.parentElement.remove(),Ve(this.plugin,a.repo))}})})});new L.SettingGroup(t).setHeading("Monitoring").addSetting(a=>a.setName("Enable notifications").setDesc("BRAT will provide popup notifications for its various activities. Turn this off means no notifications from BRAT.").addToggle(c=>{c.setValue(this.plugin.settings.notificationsEnabled),c.onChange(async p=>{this.plugin.settings.notificationsEnabled=p,await this.plugin.saveSettings()})})).addSetting(a=>a.setName("Enable logging").setDesc("Plugin updates will be logged to a file in the log file.").addToggle(c=>{c.setValue(this.plugin.settings.loggingEnabled).onChange(async p=>{this.plugin.settings.loggingEnabled=p,await this.plugin.saveSettings()})})).addSetting(a=>a.setName("BRAT log file location").setDesc("Logs will be saved to this file. Don't add .md to the file name.").addSearch(c=>{c.setPlaceholder("Example: BRAT-log").setValue(this.plugin.settings.loggingPath).onChange(async p=>{this.plugin.settings.loggingPath=p,await this.plugin.saveSettings()})})).addSetting(a=>a.setName("Enable verbose logging").setDesc("Get a lot more information in the log.").addToggle(c=>{c.setValue(this.plugin.settings.loggingVerboseEnabled).onChange(async p=>{this.plugin.settings.loggingVerboseEnabled=p,await this.plugin.saveSettings()})})).addSetting(a=>a.setName("Debugging mode").setDesc("Atomic Bomb level console logging. Can be used for troubleshooting and development.").addToggle(c=>{c.setValue(this.plugin.settings.debuggingMode).onChange(async p=>{this.plugin.settings.debuggingMode=p,await this.plugin.saveSettings()})}));let g=new L.SettingGroup(t).setHeading("Access Token"),d="";g.addSetting(a=>{a.setName("Personal access token").setDesc(vi({prependText:"Increase rate limits for GitHub, or access private repos. Create one in ",url:"https://github.com/settings/tokens/new?scopes=public_repo",text:"your GitHub settings",appendText:". For Gitea, create a token in your Gitea instance settings."})),this.accessTokenSetting=new L.SecretComponent(this.plugin.app,a.controlEl),this.accessTokenSetting.setValue(this.plugin.settings.globalTokenName||"").onChange(async c=>{var m,P,E;let p=(c==null?void 0:c.trim())||"";this.plugin.settings.globalTokenName=p,await this.plugin.saveSettings(),p?(d=this.plugin.app.secretStorage.getSecret(p)||"",(m=this.accessTokenButton)==null||m.setDisabled(!1)):(d="",(P=this.accessTokenButton)==null||P.setDisabled(!0),await((E=this.validator)==null?void 0:E.validateToken("")))}),this.plugin.settings.globalTokenName&&(d=this.plugin.app.secretStorage.getSecret(this.plugin.settings.globalTokenName)||""),a.addExtraButton(c=>{c.setIcon("cross").setTooltip("Clear personal access token").onClick(async()=>{var p,m;this.plugin.settings.globalTokenName="",await this.plugin.saveSettings(),(p=this.accessTokenSetting)==null||p.setValue(""),d="",await((m=this.validator)==null?void 0:m.validateToken(""))})}).addButton(c=>{this.accessTokenButton=c,c.setButtonText("Validate").setCta().onClick(async()=>{var p;d&&await((p=this.validator)==null?void 0:p.validateToken(d))})}).then(()=>{var c;this.tokenInfo=this.createTokenInfoElement(t),this.validator=new K(this.tokenInfo),(c=this.validator)==null||c.validateToken(d).then(p=>{var m;(m=this.accessTokenButton)==null||m.setDisabled(p||!this.plugin.settings.globalTokenName)})})})}createTokenInfoElement(t){let s=t.createDiv({cls:"brat-token-info"});return s.createDiv({cls:"brat-token-status"}),s.createDiv({cls:"brat-token-details"}),s}};var he=class{constructor(e){this.console=(e,...t)=>{console.log(`BRAT: ${e}`,...t)};this.themes={themeseCheckAndUpates:async e=>{await ee(this.plugin,e)},themeInstallTheme:async e=>{await de(this.plugin,e,!0)},themesDelete:e=>{Ve(this.plugin,e)},getThemeChecksum:async(e,t=!1)=>{try{let s=J(e),n=s.parseUrl(e),r=t?"theme-beta.css":"theme.css",o=await s.getRawFile(n,r,"HEAD");if(!o)return"0";let u=0;for(let l=0;l{if(!t.plugin&&!t.theme){w(this,"Could not locate the repository from the URL.",10);return}for(let s of["plugin","theme"])if(t[s]){let n;switch(s){case"plugin":n=new H(this,this.betaPlugins,!0,!1,t[s],t.version?t.version:void 0),n.open();break;case"theme":n=new U(this),n.address=t[s],n.open();break}return}}}onload(){console.log(`loading ${this.APP_NAME}`),Ci(),this.addRibbonIcon("BratIcon","BRAT",()=>{this.commands.ribbonDisplayCommands()}),this.loadSettings().then(async()=>{await Ai(this.app,this.settings,()=>this.saveSettings()),this.app.workspace.onLayoutReady(()=>{this.addSettingTab(new Ue(this.app,this)),this.registerObsidianProtocolHandler("brat",this.obsidianProtocolHandler),this.betaPlugins.checkIncompatiblePlugins(),this.settings.updateAtStartup&&setTimeout(()=>{this.betaPlugins.checkForPluginUpdatesAndInstallUpdates(!1)},6e4),this.settings.updateThemesAtStartup&&setTimeout(()=>{ee(this,!1)},12e4),setTimeout(()=>{window.bratAPI=this.bratApi},500)})}).catch(t=>{console.error("Failed to load settings:",t)})}async log(t,s=!1){await Ni(this,t,s)}onunload(){console.log(`unloading ${this.APP_NAME}`)}async loadSettings(){this.settings=Object.assign({},bt,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}};