1
0
Fork 0
knowledge-base/.obsidian/plugins/obsidian-git/main.js

383 lines
684 KiB
JavaScript
Raw Normal View History

2022-09-04 12:54:22 +00:00
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
2022-10-14 21:20:54 +00:00
if you want to view the source visit the plugins github repository (https://github.com/denolehov/obsidian-git)
2022-09-04 12:54:22 +00:00
*/
2024-12-09 19:19:31 +00:00
var rk=Object.create;var Pa=Object.defineProperty;var ik=Object.getOwnPropertyDescriptor;var ak=Object.getOwnPropertyNames;var sk=Object.getPrototypeOf,ok=Object.prototype.hasOwnProperty;var lk=(e,t,n)=>t in e?Pa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ck=(e,t)=>()=>(e&&(t=e(e=0)),t);var R=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),uk=(e,t)=>{for(var n in t)Pa(e,n,{get:t[n],enumerable:!0})},hm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ak(t))!ok.call(e,i)&&i!==n&&Pa(e,i,{get:()=>t[i],enumerable:!(r=ik(t,i))||r.enumerable});return e};var Xe=(e,t,n)=>(n=e!=null?rk(sk(e)):{},hm(t||!e||!e.__esModule?Pa(n,"default",{value:e,enumerable:!0}):n,e)),fk=e=>hm(Pa({},"__esModule",{value:!0}),e);var ut=(e,t,n)=>lk(e,typeof t!="symbol"?t+"":t,n);var mm=R(fo=>{"use strict";v();fo.byteLength=dk;fo.toByteArray=mk;fo.fromByteArray=vk;var vn=[],Zt=[],hk=typeof Uint8Array!="undefined"?Uint8Array:Array,vu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Fr=0,dm=vu.length;Fr<dm;++Fr)vn[Fr]=vu[Fr],Zt[vu.charCodeAt(Fr)]=Fr;var Fr,dm;Zt[45]=62;Zt[95]=63;function pm(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function dk(e){var t=pm(e),n=t[0],r=t[1];return(n+r)*3/4-r}function pk(e,t,n){return(t+n)*3/4-n}function mk(e){var t,n=pm(e),r=n[0],i=n[1],a=new hk(pk(e,r,i)),s=0,o=i>0?r-4:r,l;for(l=0;l<o;l+=4)t=Zt[e.charCodeAt(l)]<<18|Zt[e.charCodeAt(l+1)]<<12|Zt[e.charCodeAt(l+2)]<<6|Zt[e.charCodeAt(l+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=t&255;return i===2&&(t=Zt[e.charCodeAt(l)]<<2|Zt[e.charCodeAt(l+1)]>>4,a[s++]=t&255),i===1&&(t=Zt[e.charCodeAt(l)]<<10|Zt[e.charCodeAt(l+1)]<<4|Zt[e.charCodeAt(l+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function gk(e){return vn[e>>18&63]+vn[e>>12&63]+vn[e>>6&63]+vn[e&63]}function yk(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(gk(r));return i.join("")}function vk(e){for(var t,n=e.length,r=n%3,i=[],a=16383,s=0,o=n-r;s<o;s+=a)i.push(yk(e,s,s+a>o?o:s+a));return r===1?(t=e[n-1],i.push(vn[t>>2]+vn[t<<4&63]+"==")):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(vn[t>>10]+vn[t>>4&63]+vn[t<<2&63]+"=")),i.join("")}});var gm=R(wu=>{v();wu.read=function(e,t,n,r,i){var a,s,o=i*8-r-1,l=(1<<o)-1,c=l>>1,u=-7,f=n?i-1:0,h=n?-1:1,d=e[t+f];for(f+=h,a=d&(1<<-u)-1,d>>=-u,u+=o;u>0;a=a*256+e[t+f],f+=h,u-=8);for(s=a&(1<<-u)-1,a>>=-u,u+=r;u>0;s=s*256+e[t+f],f+=h,u-=8);if(a===0)a=1-c;else{if(a===l)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,r),a=a-c}return(d?-1:1)*s*Math.pow(2,a-r)};wu.write=function(e,t,n,r,i,a){var s,o,l,c=a*8-i-1,u=(1<<c)-1,f=u>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:a-1,p=r?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+f>=1?t+=h/l:t+=h*Math.pow(2,1-f),t*l>=2&&(s++,l/=2),s+f>=u?(o=0,s=u):s+f>=1?(o=(t*l-1)*Math.pow(2,i),s=s+f):(o=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;e[n+d]=o&255,d+=p,o/=256,i-=8);for(s=s<<i|o,c+=i;c>0;e[n+d]=s&255,d+=p,s/=256,c-=8);e[n+d-p]|=g*128}});var Cu=R(fi=>{"use strict";v();var bu=mm(),ci=gm(),ym=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;fi.Buffer=O;fi.SlowBuffer=Ek;fi.INSPECT_MAX_BYTES=50;var ho=2147483647;fi.kMaxLength=ho;O.TYPED_ARRAY_SUPPORT=wk();!O.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function wk(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch(e){return!1}}Object.defineProperty(O.prototype,"parent",{enumerable:!0,get:function(){if(O.isBuffer(this))return this.buffer}});Object.defineProperty(O.prototype,"offset",{enumerable:!0,get:function(){if(O.isBuffer(
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function XP(e,t){if(e){if(typeof e=="string")return t2(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t2(e,t)}}function t2(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function YP(e,t){if(!(typeof Symbol=="undefined"||!(Symbol.iterator in Object(e)))){var n=[],r=!0,i=!1,a=void 0;try{for(var s=e[Symbol.iterator](),o;!(r=(o=s.next()).done)&&(n.push(o.value),!(t&&n.length===t));r=!0);}catch(l){i=!0,a=l}finally{try{!r&&s.return!=null&&s.return()}finally{if(i)throw a}}return n}}function ZP(e){if(Array.isArray(e))return e}var r2=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?$/,i2=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])?$/,a2=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(0|1|0?\.\d+|\d+%))?\s*\)$/,s2=/^rgba?\(\s*(\d+)\s+(\d+)\s+(\d+)(?:\s*\/\s*(0|1|0?\.\d+|\d+%))?\s*\)$/,o2=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(0|1|0?\.\d+|\d+%))?\s*\)$/,l2=/^rgba?\(\s*(\d+%)\s+(\d+%)\s+(\d+%)(?:\s*\/\s*(0|1|0?\.\d+|\d+%))?\s*\)$/,c2=/^hsla?\(\s*(\d+)(deg|rad|grad|turn)?\s*,\s*(\d+)%\s*,\s*(\d+)%(?:\s*,\s*(0|1|0?\.\d+|\d+%))?\s*\)$/;function Ps(e,t){return e.indexOf(t)>-1}function KP(e,t,n){var r=e/255,i=t/255,a=n/255,s=Math.max(r,i,a),o=Math.min(r,i,a),l=s-o,c=(s+o)/2;if(l===0)return[0,0,c*100];var u=l/(1-Math.abs(2*c-1)),f=function(){switch(s){case r:return(i-a)/l%6;case i:return(a-r)/l+2;default:return(r-i)/l+4}}();return[f*60,u*100,c*100]}function JP(e,t,n){var r=e/60,i=t/100,a=n/100,s=(1-Math.abs(2*a-1))*i,o=s*(1-Math.abs(r%2-1)),l=a-s/2,c=function(){return r<1?[s,o,0]:r<2?[o,s,0]:r<3?[0,s,o]:r<4?[0,o,s]:r<5?[o,0,s]:[s,0,o]}(),u=Ft(c,3),f=u[0],h=u[1],d=u[2];return[(f+l)*255,(h+l)*255,(d+l)*255]}var QP=function(){function e(t){var n=Ft(t,4),r=n[0],i=n[1],a=n[2],s=n[3];VP(this,e),this.values=[Math.max(Math.min(parseInt(r,10),255),0),Math.max(Math.min(parseInt(i,10),255),0),Math.max(Math.min(parseInt(a,10),255),0),s==null?1:Math.max(Math.min(parseFloat(s),255),0)]}return WP(e,[{key:"toRgbString",value:function(){var n=Ft(this.values,4),r=n[0],i=n[1],a=n[2],s=n[3];return s===1?"rgb(".concat(r,", ").concat(i,", ").concat(a,")"):"rgba(".concat(r,", ").concat(i,", ").concat(a,", ").concat(s,")")}},{key:"toHslString",value:function(){var n=this.toHslaArray(),r=Ft(n,4),i=r[0],a=r[1],s=r[2],o=r[3];return o===1?"hsl(".concat(i,", ").concat(a,"%, ").concat(s,"%)"):"hsla(".concat(i,", ").concat(a,"%, ").concat(s,"%, ").concat(o,")")}},{key:"toHexString",value:function(){var n=Ft(this.values,4),r=n[0],i=n[1],a=n[2],s=n[3];return r=Number(r).toString(16).padStart(2,"0"),i=Number(i).toString(16).padStart(2,"0"),a=Number(a).toString(16).padStart(2,"0"),s=s<1?parseInt(s*255,10).toString(16).padStart(2,"0"):"","#".concat(r).concat(i).concat(a).concat(s)}},{key:"toRgbaArray",value:function(){return this.values}},{key:"toHslaArray",value:function(){var n=Ft(this.values,4),r=n[0],i=n[1],a=n[2],s=n[3],o=KP(r,i,a),l=Ft(o,3),c=l[0],u=l[1],f=l[2];return[c,u,f,s]}}]),e}();function Yi(e){var t=Ft(e,4),n=t[0],r=t[1],i=t[2],a=t[3];return new QP([n,r,i,a])}function Gh(e){var t=Ft(e,3),n=t[0],r=t[1],i=t[2];return Yi([n,r,i,1])}function Cl(e){var t=Ft(e,4),n=t[0],r=t[1],i=t[2],a=t[3],s=JP(n,r,i),o=Ft(s,3),l=o[0],c=o[1],u=o[2];return Yi([l,c,u,a])}function u2(e){var t=Ft(e,3),n=t[0],r=t[1],i=t[2];return Cl([n,r,i,1])}function eM(e){var t=r2.exec(e)||i2.exec(e),n=Ft(t,5),r=n[1],i=n[2],a=n[3],s=n[4];return r=parseInt(r.length<2?r.repeat(2):r,16),i=parseInt(i.length<2?i.repeat(2):i,16),a=parseInt(a.length<2?a.repeat(2):a,16),s=s&&(parseInt(s.length<2?s.repeat(2):s,16)/255).toPrecision(1)||1,Yi([r,i,a,s])}function tM(e){var t=a2.exec(e)||o2.exec(e)||s2.exec(e)||l2.exec(e),n=Ft(t,5),r=n[1],i=n[2],a=n[3],s=n[4];return r=Ps(r,"%")?parseInt(r,10)*255/100:parseInt(r,10),i=Ps(i,"%")?parseInt(i,10)*255/100:pa
`)>=0)return!1;return!0}function iI(e,t){var n;if(e.indent===" ")n=" ";else if(typeof e.indent=="number"&&e.indent>0)n=Mn.call(Array(e.indent+1)," ");else return null;return{base:n,prev:Mn.call(Array(t+1),n)}}function md(e,t){if(e.length===0)return"";var n=`
`+t.prev+t.base;return n+Mn.call(e,","+n)+`
`+t.prev}function Vl(e,t){var n=pd(e),r=[];if(n){r.length=e.length;for(var i=0;i<e.length;i++)r[i]=gr(e,i)?t(e[i],e):""}var a=typeof cd=="function"?cd(e):[],s;if(ta){s={};for(var o=0;o<a.length;o++)s["$"+a[o]]=a[o]}for(var l in e)gr(e,l)&&(n&&String(Number(l))===l&&l<e.length||ta&&s["$"+l]instanceof Symbol||(hx.call(/[^\w$]/,l)?r.push(t(l,e)+": "+t(e[l],e)):r.push(l+": "+t(e[l],e))));if(typeof cd=="function")for(var c=0;c<a.length;c++)dx.call(e,a[c])&&r.push("["+t(a[c])+"]: "+t(e[a[c]],e));return r}});var bd=R((ZB,xx)=>{"use strict";v();var bx=pn(),na=qt(),aI=wx(),sI=Wn(),Xl=bx("%WeakMap%",!0),Yl=bx("%Map%",!0),oI=na("WeakMap.prototype.get",!0),lI=na("WeakMap.prototype.set",!0),cI=na("WeakMap.prototype.has",!0),uI=na("Map.prototype.get",!0),fI=na("Map.prototype.set",!0),hI=na("Map.prototype.has",!0),wd=function(e,t){for(var n=e,r;(r=n.next)!==null;n=r)if(r.key===t)return n.next=r.next,r.next=e.next,e.next=r,r},dI=function(e,t){var n=wd(e,t);return n&&n.value},pI=function(e,t,n){var r=wd(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}},mI=function(e,t){return!!wd(e,t)};xx.exports=function(){var t,n,r,i={assert:function(a){if(!i.has(a))throw new sI("Side channel does not contain "+aI(a))},get:function(a){if(Xl&&a&&(typeof a=="object"||typeof a=="function")){if(t)return oI(t,a)}else if(Yl){if(n)return uI(n,a)}else if(r)return dI(r,a)},has:function(a){if(Xl&&a&&(typeof a=="object"||typeof a=="function")){if(t)return cI(t,a)}else if(Yl){if(n)return hI(n,a)}else if(r)return mI(r,a);return!1},set:function(a,s){Xl&&a&&(typeof a=="object"||typeof a=="function")?(t||(t=new Xl),lI(t,a,s)):Yl?(n||(n=new Yl),fI(n,a,s)):(r||(r={key:{},next:null}),pI(r,a,s))}};return i}});var Sx=R((JB,_x)=>{"use strict";v();var gI=Yh(),$s=bd()(),qn=Wn(),xd={assert:function(e,t){if(!e||typeof e!="object"&&typeof e!="function")throw new qn("`O` is not an object");if(typeof t!="string")throw new qn("`slot` must be a string");if($s.assert(e),!xd.has(e,t))throw new qn("`"+t+"` is not present on `O`")},get:function(e,t){if(!e||typeof e!="object"&&typeof e!="function")throw new qn("`O` is not an object");if(typeof t!="string")throw new qn("`slot` must be a string");var n=$s.get(e);return n&&n["$"+t]},has:function(e,t){if(!e||typeof e!="object"&&typeof e!="function")throw new qn("`O` is not an object");if(typeof t!="string")throw new qn("`slot` must be a string");var n=$s.get(e);return!!n&&gI(n,"$"+t)},set:function(e,t,n){if(!e||typeof e!="object"&&typeof e!="function")throw new qn("`O` is not an object");if(typeof t!="string")throw new qn("`slot` must be a string");var r=$s.get(e);r||(r={},$s.set(e,r)),r["$"+t]=n}};Object.freeze&&Object.freeze(xd);_x.exports=xd});var kx=R((eN,Ax)=>{"use strict";v();var Hs=Sx(),yI=SyntaxError,Ex=typeof StopIteration=="object"?StopIteration:null;Ax.exports=function(t){if(!Ex)throw new yI("this environment lacks StopIteration");Hs.set(t,"[[Done]]",!1);var n={next:function(){var i=Hs.get(this,"[[Iterator]]"),a=Hs.get(i,"[[Done]]");try{return{done:a,value:a?void 0:i.next()}}catch(s){if(Hs.set(i,"[[Done]]",!0),s!==Ex)throw s;return{done:!0,value:void 0}}}};return Hs.set(n,"[[Iterator]]",t),n}});var _d=R((nN,Tx)=>{v();var vI={}.toString;Tx.exports=Array.isArray||function(e){return vI.call(e)=="[object Array]"}});var Sd=R((iN,Cx)=>{"use strict";v();var wI=String.prototype.valueOf,bI=function(t){try{return wI.call(t),!0}catch(n){return!1}},xI=Object.prototype.toString,_I="[object String]",SI=mr()();Cx.exports=function(t){return typeof t=="string"?!0:typeof t!="object"?!1:SI?bI(t):xI.call(t)===_I}});var Ad=R((sN,Mx)=>{"use strict";v();var Ed=typeof Map=="function"&&Map.prototype?Map:null,EI=typeof Set=="function"&&Set.prototype?Set:null,Zl;Ed||(Zl=function(t){return!1});var Px=Ed?Map.prototype.has:null,Fx=EI?Set.prototype.has:null;!Zl&&!Px&&(Zl=function(t){return!1});Mx.exports=Zl||function(t){if(!t||typeof t!="object")return!1;try{if(Px.call(t),Fx)try{Fx.call(t)}catch(n){return!0}return t instanceof Ed}catch(n){}return!1}});var Td=R((lN,Rx)=>{"use strict";v();var AI=typeof Map=="function"&&Map.prototype?Map:null,kd=typeof Set=="f
`});Pe=!1,$=ae.length}function be(ot,ee){var Ie="="+D,Ee=ot.indexOf(Ie,ee),G=c(ot.substring(ot.indexOf("=",ee)+1,Ee)).split(" ");return z=G[0],D=G[G.length-1],Ee+Ie.length-1}for(_&&(_=_.split(" "),z=_[0],D=_[1]),de=0;de<C;de++)j==P?u(z,E,de)?(--de,se(),j=L):E.charAt(de)==`
`?gt(Pe):he+=E.charAt(de):j==L?(de+=z.length-1,le=e.tags[E.charAt(de+1)],Y=le?E.charAt(de+1):"_v",Y=="="?(de=be(E,de),j=P):(le&&de++,j=N),Pe=de):u(D,E,de)?(ae.push({tag:Y,n:c(he),otag:z,ctag:D,i:Y=="/"?Pe-z.length:de+D.length}),he="",de+=D.length-1,j=P,Y=="{"&&(D=="}}"?de++:l(ae[ae.length-1]))):he+=E.charAt(de);return gt(Pe,!0),ae};function l(y){y.n.substr(y.n.length-1)==="}"&&(y.n=y.n.substring(0,y.n.length-1))}function c(y){return y.trim?y.trim():y.replace(/^\s*|\s*$/g,"")}function u(y,E,_){if(E.charAt(_)!=y.charAt(0))return!1;for(var C=1,P=y.length;C<P;C++)if(E.charAt(_+C)!=y.charAt(C))return!1;return!0}var f={_t:!0,"\n":!0,$:!0,"/":!0};function h(y,E,_,C){var P=[],L=null,N=null,j=null;for(N=_[_.length-1];y.length>0;){if(j=y.shift(),N&&N.tag=="<"&&!(j.tag in f))throw new Error("Illegal content in < super tag.");if(e.tags[j.tag]<=e.tags.$||d(j,C))_.push(j),j.nodes=h(y,j.tag,_,C);else if(j.tag=="/"){if(_.length===0)throw new Error("Closing tag without opener: /"+j.n);if(L=_.pop(),j.n!=L.n&&!p(j.n,L.n,C))throw new Error("Nesting error: "+L.n+" vs. "+j.n);return L.end=j.i,P}else j.tag==`
`&&(j.last=y.length==0||y[0].tag==`
`);P.push(j)}if(_.length>0)throw new Error("missing closing tag: "+_.pop().n);return P}function d(y,E){for(var _=0,C=E.length;_<C;_++)if(E[_].o==y.n)return y.tag="#",!0}function p(y,E,_){for(var C=0,P=_.length;C<P;C++)if(_[C].c==y&&_[C].o==E)return!0}function g(y){var E=[];for(var _ in y)E.push('"'+b(_)+'": function(c,p,t,i) {'+y[_]+"}");return"{ "+E.join(",")+" }"}function m(y){var E=[];for(var _ in y.partials)E.push('"'+b(_)+'":{name:"'+b(y.partials[_].name)+'", '+m(y.partials[_])+"}");return"partials: {"+E.join(",")+"}, subs: "+g(y.subs)}e.stringify=function(y,E,_){return"{code: function (c,p,i) { "+e.wrapMain(y.code)+" },"+m(y)+"}"};var w=0;e.generate=function(y,E,_){w=0;var C={code:"",subs:{},partials:{}};return e.walk(y,C),_.asString?this.stringify(C,E,_):this.makeTemplate(C,E,_)},e.wrapMain=function(y){return'var t=this;t.b(i=i||"");'+y+"return t.fl();"},e.template=e.Template,e.makeTemplate=function(y,E,_){var C=this.makePartials(y);return C.code=new Function("c","p","i",this.wrapMain(y.code)),new this.template(C,E,this,_)},e.makePartials=function(y){var E,_={subs:{},partials:y.partials,name:y.name};for(E in _.partials)_.partials[E]=this.makePartials(_.partials[E]);for(E in y.subs)_.subs[E]=new Function("c","p","t","i",y.subs[E]);return _};function b(y){return y.replace(a,"\\\\").replace(n,'\\"').replace(r,"\\n").replace(i,"\\r").replace(s,"\\u2028").replace(o,"\\u2029")}function S(y){return~y.indexOf(".")?"d":"f"}function A(y,E){var _="<"+(E.prefix||""),C=_+y.n+w++;return E.partials[C]={name:y.n,partials:{}},E.code+='t.b(t.rp("'+b(C)+'",c,p,"'+(y.indent||"")+'"));',C}e.codegen={"#":function(y,E){E.code+="if(t.s(t."+S(y.n)+'("'+b(y.n)+'",c,p,1),c,p,0,'+y.i+","+y.end+',"'+y.otag+" "+y.ctag+'")){t.rs(c,p,function(c,p,t){',e.walk(y.nodes,E),E.code+="});c.pop();}"},"^":function(y,E){E.code+="if(!t.s(t."+S(y.n)+'("'+b(y.n)+'",c,p,1),c,p,1,0,0,"")){',e.walk(y.nodes,E),E.code+="};"},">":A,"<":function(y,E){var _={partials:{},code:"",subs:{},inPartial:!0};e.walk(y.nodes,_);var C=E.partials[A(y,E)];C.subs=_.subs,C.partials=_.partials},$:function(y,E){var _={subs:{},code:"",partials:E.partials,prefix:y.n};e.walk(y.nodes,_),E.subs[y.n]=_.code,E.inPartial||(E.code+='t.sub("'+b(y.n)+'",c,p,i);')},"\n":function(y,E){E.code+=k('"\\n"'+(y.last?"":" + i"))},_v:function(y,E){E.code+="t.b(t.v(t."+S(y.n)+'("'+b(y.n)+'",c,p,0)));'},_t:function(y,E){E.code+=k('"'+b(y.text)+'"')},"{":x,"&":x};function x(y,E){E.code+="t.b(t.t(t."+S(y.n)+'("'+b(y.n)+'",c,p,0)));'}function k(y){return"t.b("+y+");"}e.walk=function(y,E){for(var _,C=0,P=y.length;C<P;C++)_=e.codegen[y[C].tag],_&&_(y[C],E);return E},e.parse=function(y,E,_){return _=_||{},h(y,"",[],_.sectionTags||[])},e.cache={},e.cacheKey=function(y,E){return[y,!!E.asString,!!E.disableLambda,E.delimiters,!!E.modelGet].join("||")},e.compile=function(y,E){E=E||{};var _=e.cacheKey(y,E),C=this.cache[_];if(C){var P=C.partials;for(var L in P)delete P[L].instance;return C}return C=this.generate(this.parse(this.scan(y,E.delimiters),y,E),y,E),this.cache[_]=C}})(typeof Gp!="undefined"?Gp:Hogan)});var ZE=R(zp=>{v();var nj={};(function(e){e.Template=function(h,d,p,g){h=h||{},this.r=h.code||this.r,this.c=p,this.options=g||{},this.text=d||"",this.partials=h.partials||{},this.subs=h.subs||{},this.buf=""},e.Template.prototype={r:function(h,d,p){return""},v:u,t:c,render:function(d,p,g){return this.ri([d],p||{},g)},ri:function(h,d,p){return this.r(h,d,p)},ep:function(h,d){var p=this.partials[h],g=d[p.name];if(p.instance&&p.base==g)return p.instance;if(typeof g=="string"){if(!this.c)throw new Error("No compiler available.");g=this.c.compile(g,this.options)}if(!g)return null;if(this.partials[h].base=g,p.subs){d.stackText||(d.stackText={});for(key in p.subs)d.stackText[key]||(d.stackText[key]=this.activeSub!==void 0&&d.stackText[this.activeSub]?d.stackText[this.activeSub]:this.text);g=n(g,p.subs,p.partials,this.stackSubs,this.stackPartials,d.stackText)}return this.partials[h].instance=g,g},rp:function(h,d,p,g){var m=this.ep(h,p);return m?m.ri(d,p,g):""},rs:function(h,d,p){var g=h[h.length-1];if(!f(g)){p(h,d,this);
`)}static async _entryToBuffer(t){let n=Buffer.from(t.path),r=Math.ceil((62+n.length+1)/8)*8,i=Buffer.alloc(r),a=new en(i),s=Ai(t);return a.writeUInt32BE(s.ctimeSeconds),a.writeUInt32BE(s.ctimeNanoseconds),a.writeUInt32BE(s.mtimeSeconds),a.writeUInt32BE(s.mtimeNanoseconds),a.writeUInt32BE(s.dev),a.writeUInt32BE(s.ino),a.writeUInt32BE(s.mode),a.writeUInt32BE(s.uid),a.writeUInt32BE(s.gid),a.writeUInt32BE(s.size),a.write(t.oid,20,"hex"),a.writeUInt16BE(y5(t)),a.write(t.path,n.length,"utf8"),i}async toObject(){let t=Buffer.alloc(12),n=new en(t);n.write("DIRC",4,"utf8"),n.writeUInt32BE(2),n.writeUInt32BE(this.entriesFlat.length);let r=[];for(let o of this.entries)if(r.push(e._entryToBuffer(o)),o.stages.length>1)for(let l of o.stages)l&&l!==o&&r.push(e._entryToBuffer(l));r=await Promise.all(r);let i=Buffer.concat(r),a=Buffer.concat([t,i]),s=await Un(a);return Buffer.concat([a,Buffer.from(s,"hex")])}};function Do(e,t,n=!0,r=!0){let i=Ai(e),a=Ai(t);return n&&i.mode!==a.mode||i.mtimeSeconds!==a.mtimeSeconds||i.ctimeSeconds!==a.ctimeSeconds||i.uid!==a.uid||i.gid!==a.gid||r&&i.ino!==a.ino||i.size!==a.size}var _f=null,_i=Symbol("IndexCache");function v5(){return{map:new Map,stats:new Map}}async function w5(e,t,n){let r=await e.lstat(t),i=await e.read(t),a=await Mf.from(i);n.map.set(t,a),n.stats.set(t,r)}async function b5(e,t,n){let r=n.stats.get(t);if(r===void 0)return!0;let i=await e.lstat(t);return r===null||i===null?!1:Do(r,i)}var ct=class{static async acquire({fs:t,gitdir:n,cache:r,allowUnmerged:i=!0},a){r[_i]||(r[_i]=v5());let s=`${n}/index`;_f===null&&(_f=new Za.default({maxPending:1/0}));let o,l=[];return await _f.acquire(s,async()=>{await b5(t,s,r[_i])&&await w5(t,s,r[_i]);let c=r[_i].map.get(s);if(l=c.unmergedPaths,l.length&&!i)throw new Ka(l);if(o=await a(c),c._dirty){let u=await c.toObject();await t.write(s,u),r[_i].stats.set(s,await t.lstat(s)),c._dirty=!1}}),o}};function Bo(e){let t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t>-1&&(e=e.slice(t+1)),e}function ki(e){let t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?".":t===0?"/":e.slice(0,t)}function F1(e){let t=new Map,n=function(i){if(!t.has(i)){let a={type:"tree",fullpath:i,basename:Bo(i),metadata:{},children:[]};t.set(i,a),a.parent=n(ki(i)),a.parent&&a.parent!==a&&a.parent.children.push(a)}return t.get(i)},r=function(i,a){if(!t.has(i)){let s={type:"blob",fullpath:i,basename:Bo(i),metadata:a,parent:n(ki(i)),children:[]};s.parent&&s.parent.children.push(s),t.set(i,s)}return t.get(i)};n(".");for(let i of e)r(i.path,i);return t}function x5(e){switch(e){case 16384:return"tree";case 33188:return"blob";case 33261:return"blob";case 40960:return"blob";case 57344:return"commit"}throw new ue(`Unexpected GitTree entry mode: ${e.toString(8)}`)}var Of=class{constructor({fs:t,gitdir:n,cache:r}){this.treePromise=ct.acquire({fs:t,gitdir:n,cache:r},async function(a){return F1(a.entries)});let i=this;this.ConstructEntry=class{constructor(s){this._fullpath=s,this._type=!1,this._mode=!1,this._stat=!1,this._oid=!1}async type(){return i.type(this)}async mode(){return i.mode(this)}async stat(){return i.stat(this)}async content(){return i.content(this)}async oid(){return i.oid(this)}}}async readdir(t){let n=t._fullpath,i=(await this.treePromise).get(n);if(!i||i.type==="blob")return null;if(i.type!=="tree")throw new Error(`ENOTDIR: not a directory, scandir '${n}'`);let a=i.children.map(s=>s.fullpath);return a.sort(Xo),a}async type(t){return t._type===!1&&await t.stat(),t._type}async mode(t){return t._mode===!1&&await t.stat(),t._mode}async stat(t){if(t._stat===!1){let r=(await this.treePromise).get(t._fullpath);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t._fullpath}'`);let i=r.type==="tree"?{}:Ai(r.metadata);t._type=r.type==="tree"?"tree":x5(i.mode),t._mode=i.mode,r.type==="tree"?t._stat=void 0:t._stat=i}return t._stat}async content(t){}async oid(t){if(t._oid===!1){let r=(await this.treePromise).get(t._fullpath);t._oid=r.metadata.oid}return t._oid}},Yo=Symbol("GitWalkSymbol");function Zo(){let e=Object.create(null);return Object.definePr
[remote "${t}"]
fetch = +refs/heads/*:refs/remotes/origin/*
`),this.code=this.name=e.code,this.data={remote:t}}};Ja.code="NoRefspecError";var No=class e{constructor(t){if(this.refs=new Map,this.parsedConfig=[],t){let n=null;this.parsedConfig=t.trim().split(`
`).map(r=>{if(/^\s*#/.test(r))return{line:r,comment:!0};let i=r.indexOf(" ");if(r.startsWith("^")){let a=r.slice(1);return this.refs.set(n+"^{}",a),{line:r,ref:n,peeled:a}}else{let a=r.slice(0,i);return n=r.slice(i+1),this.refs.set(n,a),{line:r,ref:n,oid:a}}})}return this}static from(t){return new e(t)}delete(t){this.parsedConfig=this.parsedConfig.filter(n=>n.ref!==t),this.refs.delete(t)}toString(){return this.parsedConfig.map(({line:t})=>t).join(`
`)+`
`}},$o=class e{constructor({remotePath:t,localPath:n,force:r,matchPrefix:i}){Object.assign(this,{remotePath:t,localPath:n,force:r,matchPrefix:i})}static from(t){let[n,r,i,a,s]=t.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),o=n==="+",l=i==="*";if(l!==(s==="*"))throw new ue("Invalid refspec");return new e({remotePath:r,localPath:a,force:o,matchPrefix:l})}translate(t){if(this.matchPrefix){if(t.startsWith(this.remotePath))return this.localPath+t.replace(this.remotePath,"")}else if(t===this.remotePath)return this.localPath;return null}reverseTranslate(t){if(this.matchPrefix){if(t.startsWith(this.localPath))return this.remotePath+t.replace(this.localPath,"")}else if(t===this.localPath)return this.remotePath;return null}},If=class e{constructor(t=[]){this.rules=t}static from(t){let n=[];for(let r of t)n.push($o.from(r));return new e(n)}add(t){let n=$o.from(t);this.rules.push(n)}translate(t){let n=[];for(let r of this.rules)for(let i of t){let a=r.translate(i);a&&n.push([i,a])}return n}translateOne(t){let n=null;for(let r of this.rules){let i=r.translate(t);i&&(n=i)}return n}localNamespaces(){return this.rules.filter(t=>t.matchPrefix).map(t=>t.localPath.replace(/\/$/,""))}};function _5(e,t){let n=e.replace(/\^\{\}$/,""),r=t.replace(/\^\{\}$/,""),i=-(n<r)||+(n>r);return i===0?e.endsWith("^{}")?1:-1:i}var n1=new Map;function r1(e){let t=n1.get(e);return t||(t=S5(e),n1.set(e,t)),t}function S5(e){return e=e.split("/./").join("/").replace(/\/{2,}/g,"/"),e==="/."?"/":e==="./"||(e.startsWith("./")&&(e=e.slice(2)),e.endsWith("/.")&&(e=e.slice(0,-2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e==="")?".":e}function B(...e){return r1(e.map(r1).join("/"))}var E5=e=>{e=e.toLowerCase();let t=parseInt(e);return e.endsWith("k")&&(t*=1024),e.endsWith("m")&&(t*=1024*1024),e.endsWith("g")&&(t*=1024*1024*1024),t},Ya=e=>{if(e=e.trim().toLowerCase(),e==="true"||e==="yes"||e==="on")return!0;if(e==="false"||e==="no"||e==="off")return!1;throw Error(`Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${e}`)},i1={core:{filemode:Ya,bare:Ya,logallrefupdates:Ya,symlinks:Ya,ignorecase:Ya,bigFileThreshold:E5}},A5=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,k5=/^[A-Za-z0-9-.]+$/,T5=/^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/,C5=/^[A-Za-z][A-Za-z-]*$/,F5=/^(.*?)( *[#;].*)$/,P5=e=>{let t=A5.exec(e);if(t!=null){let[n,r]=t.slice(1);return[n,r]}return null},M5=e=>{let t=T5.exec(e);if(t!=null){let[n,r="true"]=t.slice(1),i=O5(r),a=I5(i);return[n,a]}return null},O5=e=>{let t=F5.exec(e);if(t==null)return e;let[n,r]=t.slice(1);return a1(n)&&a1(r)?`${n}${r}`:n},a1=e=>(e.match(/(?:^|[^\\])"/g)||[]).length%2!==0,I5=e=>e.split("").reduce((t,n,r,i)=>{let a=n==='"'&&i[r-1]!=="\\",s=n==="\\"&&i[r+1]==='"';return a||s?t:t+n},""),s1=e=>e!=null?e.toLowerCase():null,Rf=(e,t,n)=>[s1(e),t,s1(n)].filter(r=>r!=null).join("."),o1=e=>{let t=e.split("."),n=t.shift(),r=t.pop(),i=t.length?t.join("."):void 0;return{section:n,subsection:i,name:r,path:Rf(n,i,r),sectionPath:Rf(n,i,null)}},R5=(e,t)=>e.reduce((n,r,i)=>t(r)?i:n,-1),Lf=class e{constructor(t){let n=null,r=null;this.parsedConfig=t?t.split(`
`).map(i=>{let a=null,s=null,o=i.trim(),l=P5(o),c=l!=null;if(c)[n,r]=l;else{let f=M5(o);f!=null&&([a,s]=f)}let u=Rf(n,r,a);return{line:i,isSection:c,section:n,subsection:r,name:a,value:s,path:u}}):[]}static from(t){return new e(t)}async get(t,n=!1){let r=o1(t).path,i=this.parsedConfig.filter(a=>a.path===r).map(({section:a,name:s,value:o})=>{let l=i1[a]&&i1[a][s];return l?l(o):o});return n?i:i.pop()}async getall(t){return this.get(t,!0)}async getSubsections(t){return this.parsedConfig.filter(n=>n.section===t&&n.isSection).map(n=>n.subsection)}async deleteSection(t,n){this.parsedConfig=this.parsedConfig.filter(r=>!(r.section===t&&r.subsection===n))}async append(t,n){return this.set(t,n,!0)}async set(t,n,r=!1){let{section:i,subsection:a,name:s,path:o,sectionPath:l}=o1(t),c=R5(this.parsedConfig,u=>u.path===o);if(n==null)c!==-1&&this.parsedConfig.splice(c,1);else if(c!==-1){let u=this.parsedConfig[c],f=Object.assign({},u,{name:s,value:n,modified:!0});r?this.parsedConfig.splice(c+1,0,f):this.parsedConfig[c]=f}else{let u=this.parsedConfig.findIndex(h=>h.path===l),f={section:i,subsection:a,name:s,value:n,modified:!0,path:o};if(k5.test(i)&&C5.test(s))if(u>=0)this.parsedConfig.splice(u+1,0,f);else{let h={section:i,subsection:a,modified:!0,path:l};this.parsedConfig.push(h,f)}}}toString(){return this.parsedConfig.map(({line:t,section:n,subsection:r,name:i,value:a,modified:s=!1})=>s?i!=null&&a!=null?typeof a=="string"&&/[#;]/.test(a)?` ${i} = "${a}"`:` ${i} = ${a}`:r!=null?`[${n} "${r}"]`:`[${n}]`:t).join(`
`)}},Ve=class{static async get({fs:t,gitdir:n}){let r=await t.read(`${n}/config`,{encoding:"utf8"});return Lf.from(r)}static async save({fs:t,gitdir:n,config:r}){await t.write(`${n}/config`,r.toString(),{encoding:"utf8"})}},Ro=e=>[`${e}`,`refs/${e}`,`refs/tags/${e}`,`refs/heads/${e}`,`refs/remotes/${e}`,`refs/remotes/${e}/HEAD`],L5=["config","description","index","shallow","commondir"],Sf;async function sr(e,t){return Sf===void 0&&(Sf=new Za.default),Sf.acquire(e,t)}var q=class e{static async updateRemoteRefs({fs:t,gitdir:n,remote:r,refs:i,symrefs:a,tags:s,refspecs:o=void 0,prune:l=!1,pruneTags:c=!1}){for(let m of i.values())if(!m.match(/[0-9a-f]{40}/))throw new cr(m);let u=await Ve.get({fs:t,gitdir:n});if(!o){if(o=await u.getall(`remote.${r}.fetch`),o.length===0)throw new Ja(r);o.unshift(`+HEAD:refs/remotes/${r}/HEAD`)}let f=If.from(o),h=new Map;if(c){let m=await e.listRefs({fs:t,gitdir:n,filepath:"refs/tags"});await e.deleteRefs({fs:t,gitdir:n,refs:m.map(w=>`refs/tags/${w}`)})}if(s){for(let m of i.keys())if(m.startsWith("refs/tags")&&!m.endsWith("^{}")&&!await e.exists({fs:t,gitdir:n,ref:m})){let w=i.get(m);h.set(m,w)}}let d=f.translate([...i.keys()]);for(let[m,w]of d){let b=i.get(m);h.set(w,b)}let p=f.translate([...a.keys()]);for(let[m,w]of p){let b=a.get(m),S=f.translateOne(b);S&&h.set(w,`ref: ${S}`)}let g=[];if(l){for(let m of f.localNamespaces()){let w=(await e.listRefs({fs:t,gitdir:n,filepath:m})).map(b=>`${m}/${b}`);for(let b of w)h.has(b)||g.push(b)}g.length>0&&await e.deleteRefs({fs:t,gitdir:n,refs:g})}for(let[m,w]of h)await sr(m,async()=>t.write(B(n,m),`${w.trim()}
`,"utf8"));return{pruned:g}}static async writeRef({fs:t,gitdir:n,ref:r,value:i}){if(!i.match(/[0-9a-f]{40}/))throw new cr(i);await sr(r,async()=>t.write(B(n,r),`${i.trim()}
`,"utf8"))}static async writeSymbolicRef({fs:t,gitdir:n,ref:r,value:i}){await sr(r,async()=>t.write(B(n,r),`ref: ${i.trim()}
`,"utf8"))}static async deleteRef({fs:t,gitdir:n,ref:r}){return e.deleteRefs({fs:t,gitdir:n,refs:[r]})}static async deleteRefs({fs:t,gitdir:n,refs:r}){await Promise.all(r.map(o=>t.rm(B(n,o))));let i=await sr("packed-refs",async()=>t.read(`${n}/packed-refs`,{encoding:"utf8"})),a=No.from(i),s=a.refs.size;for(let o of r)a.refs.has(o)&&a.delete(o);a.refs.size<s&&(i=a.toString(),await sr("packed-refs",async()=>t.write(`${n}/packed-refs`,i,{encoding:"utf8"})))}static async resolve({fs:t,gitdir:n,ref:r,depth:i=void 0}){if(i!==void 0&&(i--,i===-1))return r;if(r.startsWith("ref: "))return r=r.slice(5),e.resolve({fs:t,gitdir:n,ref:r,depth:i});if(r.length===40&&/[0-9a-f]{40}/.test(r))return r;let a=await e.packedRefs({fs:t,gitdir:n}),s=Ro(r).filter(o=>!L5.includes(o));for(let o of s){let l=await sr(o,async()=>await t.read(`${n}/${o}`,{encoding:"utf8"})||a.get(o));if(l)return e.resolve({fs:t,gitdir:n,ref:l.trim(),depth:i})}throw new Re(r)}static async exists({fs:t,gitdir:n,ref:r}){try{return await e.expand({fs:t,gitdir:n,ref:r}),!0}catch(i){return!1}}static async expand({fs:t,gitdir:n,ref:r}){if(r.length===40&&/[0-9a-f]{40}/.test(r))return r;let i=await e.packedRefs({fs:t,gitdir:n}),a=Ro(r);for(let s of a)if(await sr(s,async()=>t.exists(`${n}/${s}`))||i.has(s))return s;throw new Re(r)}static async expandAgainstMap({ref:t,map:n}){let r=Ro(t);for(let i of r)if(await n.has(i))return i;throw new Re(t)}static resolveAgainstMap({ref:t,fullref:n=t,depth:r=void 0,map:i}){if(r!==void 0&&(r--,r===-1))return{fullref:n,oid:t};if(t.startsWith("ref: "))return t=t.slice(5),e.resolveAgainstMap({ref:t,fullref:n,depth:r,map:i});if(t.length===40&&/[0-9a-f]{40}/.test(t))return{fullref:n,oid:t};let a=Ro(t);for(let s of a){let o=i.get(s);if(o)return e.resolveAgainstMap({ref:o.trim(),fullref:s,depth:r,map:i})}throw new Re(t)}static async packedRefs({fs:t,gitdir:n}){let r=await sr("packed-refs",async()=>t.read(`${n}/packed-refs`,{encoding:"utf8"}));return No.from(r).refs}static async listRefs({fs:t,gitdir:n,filepath:r}){let i=e.packedRefs({fs:t,gitdir:n}),a=null;try{a=await t.readdirDeep(`${n}/${r}`),a=a.map(s=>s.replace(`${n}/${r}/`,""))}catch(s){a=[]}for(let s of(await i).keys())s.startsWith(r)&&(s=s.replace(r+"/",""),a.includes(s)||a.push(s));return a.sort(_5),a}static async listBranches({fs:t,gitdir:n,remote:r}){return r?e.listRefs({fs:t,gitdir:n,filepath:`refs/remotes/${r}`}):e.listRefs({fs:t,gitdir:n,filepath:"refs/heads"})}static async listTags({fs:t,gitdir:n}){return(await e.listRefs({fs:t,gitdir:n,filepath:"refs/tags"})).filter(i=>!i.endsWith("^{}"))}};function j5(e,t){return Xo(l1(e),l1(t))}function l1(e){return e.mode==="040000"?e.path+"/":e.path}function P1(e){switch(e){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new ue(`Unexpected GitTree entry mode: ${e}`)}function D5(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(32,n);if(r===-1)throw new ue(`GitTree: Error parsing buffer at byte location ${n}: Could not find the next space character.`);let i=e.indexOf(0,n);if(i===-1)throw new ue(`GitTree: Error parsing buffer at byte location ${n}: Could not find the next null character.`);let a=e.slice(n,r).toString("utf8");a==="40000"&&(a="040000");let s=P1(a),o=e.slice(r+1,i).toString("utf8");if(o.includes("\\")||o.includes("/"))throw new Ei(o);let l=e.slice(i+1,i+21).toString("hex");n=i+21,t.push({mode:a,path:o,oid:l,type:s})}return t}function B5(e){if(typeof e=="number"&&(e=e.toString(8)),e.match(/^0?4.*/))return"040000";if(e.match(/^1006.*/))return"100644";if(e.match(/^1007.*/))return"100755";if(e.match(/^120.*/))return"120000";if(e.match(/^160.*/))return"160000";throw new ue(`Could not understand file mode: ${e}`)}function N5(e){return!e.oid&&e.sha&&(e.oid=e.sha),e.mode=B5(e.mode),e.type||(e.type=P1(e.mode)),e}var It=class e{constructor(t){if(Buffer.isBuffer(t))this._entries=D5(t);else if(Array.isArray(t))this._entries=t.map(N5);else throw new ue("invalid type passed to GitTree constructor");this._entries.sort(k1)}static from(t){return new e(t)}render(){
`)}toObject(){let t=[...this._entries];return t.sort(j5),Buffer.concat(t.map(n=>{let r=Buffer.from(n.mode.replace(/^0/,"")),i=Buffer.from(" "),a=Buffer.from(n.path,"utf8"),s=Buffer.from([0]),o=Buffer.from(n.oid,"hex");return Buffer.concat([r,i,a,s,o])}))}entries(){return this._entries}*[Symbol.iterator](){for(let t of this._entries)yield t}},ur=class{static wrap({type:t,object:n}){return Buffer.concat([Buffer.from(`${t} ${n.byteLength.toString()}\0`),Buffer.from(n)])}static unwrap(t){let n=t.indexOf(32),r=t.indexOf(0),i=t.slice(0,n).toString("utf8"),a=t.slice(n+1,r).toString("utf8"),s=t.length-(r+1);if(parseInt(a)!==s)throw new ue(`Length mismatch: expected ${a} bytes but got ${s} instead.`);return{type:i,object:Buffer.from(t.slice(r+1))}}};async function $5({fs:e,gitdir:t,oid:n}){let r=`objects/${n.slice(0,2)}/${n.slice(2)}`,i=await e.read(`${t}/${r}`);return i?{object:i,format:"deflated",source:r}:null}function H5(e,t){let n=new en(e),r=c1(n);if(r!==t.byteLength)throw new ue(`applyDelta expected source buffer to be ${r} bytes but the provided buffer was ${t.length} bytes`);let i=c1(n),a,s=f1(n,t);if(s.byteLength===i)a=s;else{a=Buffer.alloc(i);let o=new en(a);for(o.copy(s);!n.eof();)o.copy(f1(n,t));let l=o.tell();if(i!==l)throw new ue(`applyDelta expected target buffer to be ${i} bytes but the resulting buffer was ${l} bytes`)}return a}function c1(e){let t=0,n=0,r=null;do r=e.readUInt8(),t|=(r&127)<<n,n+=7;while(r&128);return t}function u1(e,t,n){let r=0,i=0;for(;n--;)t&1&&(r|=e.readUInt8()<<i),t>>=1,i+=8;return r}function f1(e,t){let n=e.readUInt8(),r=128,i=15,a=112;if(n&r){let s=u1(e,n&i,4),o=u1(e,(n&a)>>4,3);return o===0&&(o=65536),t.slice(s,s+o)}else return e.slice(n)}function U5(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function M1(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:U5(e)}var Ho=class{constructor(t){if(typeof Buffer=="undefined")throw new Error("Missing Buffer dependency");this.stream=M1(t),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(t){if(!this.eof())return this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t),this.buffer.slice(this.undoCursor,this.cursor)}async skip(t){this.eof()||(this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:t,value:n}=await this.stream.next();return t&&(this._ended=!0,!n)?Buffer.alloc(0):(n&&(n=Buffer.from(n)),n)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(t){this.undoCursor=this.cursor,this.cursor+=t,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(t){if(this._ended)return;let n=[this.buffer];for(;this.cursor+t>G5(n);){let r=await this._next();if(this._ended)break;n.push(r)}this.buffer=Buffer.concat(n)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}};function G5(e){return e.reduce((t,n)=>t+n.length,0)}async function z5(e,t){let n=new Ho(e),r=await n.read(4);if(r=r.toString("utf8"),r!=="PACK")throw new ue(`Invalid PACK header '${r}'`);l
`,e}function Uo(e){let[,t,n,r,i]=e.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:t,email:n,timestamp:Number(r),timezoneOffset:tC(i)}}function tC(e){let[,t,n,r]=e.match(/(\+|-)(\d\d)(\d\d)/);return r=(t==="+"?1:-1)*(Number(n)*60+Number(r)),nC(r)}function nC(e){return e===0?e:-e}var Ut=class e{constructor(t){if(typeof t=="string")this._tag=t;else if(Buffer.isBuffer(t))this._tag=t.toString("utf8");else if(typeof t=="object")this._tag=e.render(t);else throw new ue("invalid type passed to GitAnnotatedTag constructor")}static from(t){return new e(t)}static render(t){return`object ${t.object}
type ${t.type}
tag ${t.tag}
tagger ${jf(t.tagger)}
${t.message}
${t.gpgsig?t.gpgsig:""}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(`
`))}message(){let t=this.withoutSignature();return t.slice(t.indexOf(`
`)+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){let t=this.justHeaders().split(`
`),n=[];for(let i of t)i[0]===" "?n[n.length-1]+=`
`+i.slice(1):n.push(i);let r={};for(let i of n){let a=i.slice(0,i.indexOf(" ")),s=i.slice(i.indexOf(" ")+1);Array.isArray(r[a])?r[a].push(s):r[a]=s}return r.tagger&&(r.tagger=Uo(r.tagger)),r.committer&&(r.committer=Uo(r.committer)),r}withoutSignature(){let t=Hn(this._tag);return t.indexOf(`
-----BEGIN PGP SIGNATURE-----`)===-1?t:t.slice(0,t.lastIndexOf(`
-----BEGIN PGP SIGNATURE-----`))}gpgsig(){if(this._tag.indexOf(`
-----BEGIN PGP SIGNATURE-----`)===-1)return;let t=this._tag.slice(this._tag.indexOf("-----BEGIN PGP SIGNATURE-----"),this._tag.indexOf("-----END PGP SIGNATURE-----")+27);return Hn(t)}payload(){return this.withoutSignature()+`
`}toObject(){return Buffer.from(this._tag,"utf8")}static async sign(t,n,r){let i=t.payload(),{signature:a}=await n({payload:i,secretKey:r});a=Hn(a);let s=i+a;return e.from(s)}};function Af(e){return e.trim().split(`
`).map(t=>" "+t).join(`
`)+`
`}function rC(e){return e.split(`
`).map(t=>t.replace(/^ /,"")).join(`
`)}var Rt=class e{constructor(t){if(typeof t=="string")this._commit=t;else if(Buffer.isBuffer(t))this._commit=t.toString("utf8");else if(typeof t=="object")this._commit=e.render(t);else throw new ue("invalid type passed to GitCommit constructor")}static fromPayloadSignature({payload:t,signature:n}){let r=e.justHeaders(t),i=e.justMessage(t),a=Hn(r+`
gpgsig`+Af(n)+`
`+i);return new e(a)}static from(t){return new e(t)}toObject(){return Buffer.from(this._commit,"utf8")}headers(){return this.parseHeaders()}message(){return e.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(t){return Hn(t.slice(t.indexOf(`
`)+2))}static justHeaders(t){return t.slice(0,t.indexOf(`
`))}parseHeaders(){let t=e.justHeaders(this._commit).split(`
`),n=[];for(let i of t)i[0]===" "?n[n.length-1]+=`
`+i.slice(1):n.push(i);let r={parent:[]};for(let i of n){let a=i.slice(0,i.indexOf(" ")),s=i.slice(i.indexOf(" ")+1);Array.isArray(r[a])?r[a].push(s):r[a]=s}return r.author&&(r.author=Uo(r.author)),r.committer&&(r.committer=Uo(r.committer)),r}static renderHeaders(t){let n="";if(t.tree?n+=`tree ${t.tree}
`:n+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
`,t.parent){if(t.parent.length===void 0)throw new ue("commit 'parent' property should be an array");for(let a of t.parent)n+=`parent ${a}
`}let r=t.author;n+=`author ${jf(r)}
`;let i=t.committer||t.author;return n+=`committer ${jf(i)}
`,t.gpgsig&&(n+="gpgsig"+Af(t.gpgsig)),n}static render(t){return e.renderHeaders(t)+`
`+Hn(t.message)}render(){return this._commit}withoutSignature(){let t=Hn(this._commit);if(t.indexOf(`
gpgsig`)===-1)return t;let n=t.slice(0,t.indexOf(`
gpgsig`)),r=t.slice(t.indexOf(`-----END PGP SIGNATURE-----
`)+28);return Hn(n+`
`+r)}isolateSignature(){let t=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return rC(t)}static async sign(t,n,r){let i=t.withoutSignature(),a=e.justMessage(t._commit),{signature:s}=await n({payload:i,secretKey:r});s=Hn(s);let l=e.justHeaders(t._commit)+`
gpgsig`+Af(s)+`
`+a;return e.from(l)}};async function Oi({fs:e,cache:t,gitdir:n,oid:r}){if(r==="4b825dc642cb6eb9a060e54bf8d69288fbee4904")return{tree:It.from([]),oid:r};let{type:i,object:a}=await We({fs:e,cache:t,gitdir:n,oid:r});if(i==="tag")return r=Ut.from(a).parse().object,Oi({fs:e,cache:t,gitdir:n,oid:r});if(i==="commit")return r=Rt.from(a).parse().tree,Oi({fs:e,cache:t,gitdir:n,oid:r});if(i!=="tree")throw new At(r,i,"tree");return{tree:It.from(a),oid:r}}var Df=class{constructor({fs:t,gitdir:n,ref:r,cache:i}){this.fs=t,this.cache=i,this.gitdir=n,this.mapPromise=(async()=>{let s=new Map,o;try{o=await q.resolve({fs:t,gitdir:n,ref:r})}catch(c){c instanceof Re&&(o="4b825dc642cb6eb9a060e54bf8d69288fbee4904")}let l=await Oi({fs:t,cache:this.cache,gitdir:n,oid:o});return l.type="tree",l.mode="40000",s.set(".",l),s})();let a=this;this.ConstructEntry=class{constructor(o){this._fullpath=o,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}}}async readdir(t){let n=t._fullpath,{fs:r,cache:i,gitdir:a}=this,s=await this.mapPromise,o=s.get(n);if(!o)throw new Error(`No obj for ${n}`);let l=o.oid;if(!l)throw new Error(`No oid for obj ${JSON.stringify(o)}`);if(o.type!=="tree")return null;let{type:c,object:u}=await We({fs:r,cache:i,gitdir:a,oid:l});if(c!==o.type)throw new At(l,c,o.type);let f=It.from(u);for(let h of f)s.set(B(n,h.path),h);return f.entries().map(h=>B(n,h.path))}async type(t){if(t._type===!1){let n=await this.mapPromise,{type:r}=n.get(t._fullpath);t._type=r}return t._type}async mode(t){if(t._mode===!1){let n=await this.mapPromise,{mode:r}=n.get(t._fullpath);t._mode=T1(parseInt(r,8))}return t._mode}async stat(t){}async content(t){if(t._content===!1){let n=await this.mapPromise,{fs:r,cache:i,gitdir:a}=this,o=n.get(t._fullpath).oid,{type:l,object:c}=await We({fs:r,cache:i,gitdir:a,oid:o});l!=="blob"?t._content=void 0:t._content=new Uint8Array(c)}return t._content}async oid(t){if(t._oid===!1){let r=(await this.mapPromise).get(t._fullpath);t._oid=r.oid}return t._oid}};function lr({ref:e="HEAD"}={}){let t=Object.create(null);return Object.defineProperty(t,Yo,{value:function({fs:n,gitdir:r,cache:i}){return new Df({fs:n,gitdir:r,ref:e,cache:i})}}),Object.freeze(t),t}var Bf=class{constructor({fs:t,dir:n,gitdir:r,cache:i}){this.fs=t,this.cache=i,this.dir=n,this.gitdir=r;let a=this;this.ConstructEntry=class{constructor(o){this._fullpath=o,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}}}async readdir(t){let n=t._fullpath,{fs:r,dir:i}=this,a=await r.readdir(B(i,n));return a===null?null:a.map(s=>B(n,s))}async type(t){return t._type===!1&&await t.stat(),t._type}async mode(t){return t._mode===!1&&await t.stat(),t._mode}async stat(t){if(t._stat===!1){let{fs:n,dir:r}=this,i=await n.lstat(`${r}/${t._fullpath}`);if(!i)throw new Error(`ENOENT: no such file or directory, lstat '${t._fullpath}'`);let a=i.isDirectory()?"tree":"blob";a==="blob"&&!i.isFile()&&!i.isSymbolicLink()&&(a="special"),t._type=a,i=Ai(i),t._mode=i.mode,i.size===-1&&t._actualSize&&(i.size=t._actualSize),t._stat=i}return t._stat}async content(t){if(t._content===!1){let{fs:n,dir:r,gitdir:i}=this;if(await t.type()==="tree")t._content=void 0;else{let s=await(await Ve.get({fs:n,gitdir:i})).get("core.autocrlf"),o=await n.read(`${r}/${t._fullpath}`,{autocrlf:s});t._actualSize=o.length,t._stat&&t._stat.size===-1&&(t._stat.size=t._actualSize),t._content=new Uint8Array(o)}}return t._content}async oid(t){if(t._oid===!1){let{fs:n,gitdir:r,cache:i}=this,a;await ct.acquire({fs:n,gitdir:r,cache:i},async function(s){let o=s.entriesMap.get(t._fullpath),l=await t.stat(),u=await(await Ve.get({fs:n,gitdir:r})).get("core.filemode"),f=typeof process!="undefined"?process.platform!=="win32":!0;!o||Do(l,o,u,f)?await t.content()===void
`),r=new TextEncoder().encode(r)}catch(i){}return typeof r!="string"&&(r=Buffer.from(r)),r}catch(r){return null}}async write(t,n,r={}){try{await this._writeFile(t,n,r);return}catch(i){await this.mkdir(ki(t)),await this._writeFile(t,n,r)}}async mkdir(t,n=!1){try{await this._mkdir(t);return}catch(r){if(r===null||r.code==="EEXIST")return;if(n)throw r;if(r.code==="ENOENT"){let i=ki(t);if(i==="."||i==="/"||i===t)throw r;await this.mkdir(i),await this.mkdir(t,!0)}}}async rm(t){try{await this._unlink(t)}catch(n){if(n.code!=="ENOENT")throw n}}async rmdir(t,n){try{n&&n.recursive?await this._rm(t,n):await this._rmdir(t)}catch(r){if(r.code!=="ENOENT")throw r}}async readdir(t){try{let n=await this._readdir(t);return n.sort(Xo),n}catch(n){return n.code==="ENOTDIR"?null:[]}}async readdirDeep(t){let n=await this._readdir(t);return(await Promise.all(n.map(async i=>{let a=t+"/"+i;return(await this._stat(a)).isDirectory()?this.readdirDeep(a):a}))).reduce((i,a)=>i.concat(a),[])}async lstat(t){try{return await this._lstat(t)}catch(n){if(n.code==="ENOENT")return null;throw n}}async readlink(t,n={encoding:"buffer"}){try{let r=await this._readlink(t,n);return Buffer.isBuffer(r)?r:Buffer.from(r)}catch(r){if(r.code==="ENOENT")return null;throw r}}async writelink(t,n){return this._symlink(n.toString("utf8"),t)}};function F(e,t){if(t===void 0)throw new Ot(e)}async function Go(e,t){return!e&&!t?!1:e&&!t||!e&&t?!0:!(await e.type()==="tree"&&await t.type()==="tree"||await e.type()===await t.type()&&await e.mode()===await t.mode()&&await e.oid()===await t.oid())}async function lC({fs:e,dir:t,gitdir:n=B(t,".git"),commit:r="HEAD",cache:i={}}){try{F("fs",e),F("dir",t),F("gitdir",n);let a=new Q(e),s=[lr({ref:r}),Ko(),Zo()],o=[];await ct.acquire({fs:a,gitdir:n,cache:i},async function(c){o=c.unmergedPaths});let l=await Ii({fs:a,cache:i,dir:t,gitdir:n,trees:s,map:async function(c,[u,f,h]){let d=!await Go(f,h),p=o.includes(c),g=!await Go(h,u);if(d||p)return u?{path:c,mode:await u.mode(),oid:await u.oid(),type:await u.type(),content:await u.content()}:void 0;if(g)return!1;throw new fs(c)}});await ct.acquire({fs:a,gitdir:n,cache:i},async function(c){for(let u of l)if(u!==!1){if(!u){await a.rmdir(`${t}/${u.path}`,{recursive:!0}),c.delete({filepath:u.path});continue}if(u.type==="blob"){let f=new TextDecoder().decode(u.content);await a.write(`${t}/${u.path}`,f,{mode:u.mode}),c.insert({filepath:u.path,oid:u.oid,stage:0})}}})}catch(a){throw a.caller="git.abortMerge",a}}var Ri=class{static async isIgnored({fs:t,dir:n,gitdir:r=B(n,".git"),filepath:i}){if(Bo(i)===".git")return!0;if(i===".")return!1;let a="",s=B(r,"info","exclude");await t.exists(s)&&(a=await t.read(s,"utf8"));let o=[{gitignore:B(n,".gitignore"),filepath:i}],l=i.split("/").filter(Boolean);for(let u=1;u<l.length;u++){let f=l.slice(0,u).join("/"),h=l.slice(u).join("/");o.push({gitignore:B(n,f,".gitignore"),filepath:h})}let c=!1;for(let u of o){let f;try{f=await t.read(u.gitignore,"utf8")}catch(p){if(p.code==="NOENT")continue}let h=(0,E1.default)().add(a);h.add(f);let d=ki(u.filepath);if(d!=="."&&h.ignores(d))return!0;c?c=!h.test(u.filepath).unignored:c=h.test(u.filepath).ignored}return c}};async function cC({fs:e,gitdir:t,object:n,format:r,oid:i}){if(r!=="deflated")throw new ue("GitObjectStoreLoose expects objects to write to be in deflated format");let a=`objects/${i.slice(0,2)}/${i.slice(2)}`,s=`${t}/${a}`;await e.exists(s)||await e.write(s,n)}var kf=null;async function R1(e){return kf===null&&(kf=fC()),kf?uC(e):qo.default.deflate(e)}async function uC(e){let t=new CompressionStream("deflate"),n=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function fC(){try{return new CompressionStream("deflate").writable.close(),new Blob([]).stream().cancel(),!0}catch(e){return!1}}async function Gt({fs:e,gitdir:t,type:n,object:r,format:i="content",oid:a=void 0,dryRun:s=!1}){return i!=="deflated"&&(i!=="wrapped"&&(r=ur.wrap({type:n,object:r})),a=await Un(r),r=Buffer.from(await R1(r))),s||await cC({fs:e,gitdir:t,object:r,format:"deflated",oid:a}),a}function hC(e){let t;
`,author:l,committer:c,signingKey:u})}async function mC({fs:e,onSign:t,dir:n,gitdir:r=B(n,".git"),ref:i="refs/notes/commits",oid:a,note:s,force:o,author:l,committer:c,signingKey:u,cache:f={}}){try{F("fs",e),F("gitdir",r),F("oid",a),F("note",s),u&&F("onSign",t);let h=new Q(e),d=await Gr({fs:h,gitdir:r,author:l});if(!d)throw new kt("author");let p=await Li({fs:h,gitdir:r,author:d,committer:c});if(!p)throw new kt("committer");return await pC({fs:new Q(h),cache:f,onSign:t,gitdir:r,ref:i,oid:a,note:s,force:o,author:d,committer:p,signingKey:u})}catch(h){throw h.caller="git.addNote",h}}async function N1({fs:e,gitdir:t,remote:n,url:r,force:i}){if(n!==fn.default.clean(n))throw new Gn(n,fn.default.clean(n));let a=await Ve.get({fs:e,gitdir:t});if(!i&&(await a.getSubsections("remote")).includes(n)&&r!==await a.get(`remote.${n}.url`))throw new hn("remote",n);await a.set(`remote.${n}.url`,r),await a.set(`remote.${n}.fetch`,`+refs/heads/*:refs/remotes/${n}/*`),await Ve.save({fs:e,gitdir:t,config:a})}async function gC({fs:e,dir:t,gitdir:n=B(t,".git"),remote:r,url:i,force:a=!1}){try{return F("fs",e),F("gitdir",n),F("remote",r),F("url",i),await N1({fs:new Q(e),gitdir:n,remote:r,url:i,force:a})}catch(s){throw s.caller="git.addRemote",s}}async function yC({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tagger:a,message:s=i,gpgsig:o,object:l,signingKey:c,force:u=!1}){if(i=i.startsWith("refs/tags/")?i:`refs/tags/${i}`,!u&&await q.exists({fs:e,gitdir:r,ref:i}))throw new hn("tag",i);let f=await q.resolve({fs:e,gitdir:r,ref:l||"HEAD"}),{type:h}=await We({fs:e,cache:t,gitdir:r,oid:f}),d=Ut.from({object:f,type:h,tag:i.replace("refs/tags/",""),tagger:a,message:s,gpgsig:o});c&&(d=await Ut.sign(d,n,c));let p=await Gt({fs:e,gitdir:r,type:"tag",object:d.toObject()});await q.writeRef({fs:e,gitdir:r,ref:i,value:p})}async function vC({fs:e,onSign:t,dir:n,gitdir:r=B(n,".git"),ref:i,tagger:a,message:s=i,gpgsig:o,object:l,signingKey:c,force:u=!1,cache:f={}}){try{F("fs",e),F("gitdir",r),F("ref",i),c&&F("onSign",t);let h=new Q(e),d=await Gr({fs:h,gitdir:r,author:a});if(!d)throw new kt("tagger");return await yC({fs:h,cache:f,onSign:t,gitdir:r,ref:i,tagger:d,message:s,gpgsig:o,object:l,signingKey:c,force:u})}catch(h){throw h.caller="git.annotatedTag",h}}async function wC({fs:e,gitdir:t,ref:n,object:r,checkout:i=!1,force:a=!1}){if(n!==fn.default.clean(n))throw new Gn(n,fn.default.clean(n));let s=`refs/heads/${n}`;if(!a&&await q.exists({fs:e,gitdir:t,ref:s}))throw new hn("branch",n,!1);let o;try{o=await q.resolve({fs:e,gitdir:t,ref:r||"HEAD"})}catch(l){}o&&await q.writeRef({fs:e,gitdir:t,ref:s,value:o}),i&&await q.writeSymbolicRef({fs:e,gitdir:t,ref:"HEAD",value:s})}async function bC({fs:e,dir:t,gitdir:n=B(t,".git"),ref:r,object:i,checkout:a=!1,force:s=!1}){try{return F("fs",e),F("gitdir",n),F("ref",r),await wC({fs:new Q(e),gitdir:n,ref:r,object:i,checkout:a,force:s})}catch(o){throw o.caller="git.branch",o}}var $1=(e,t)=>e==="."||t==null||t.length===0||t==="."?!0:t.length>=e.length?t.startsWith(e):e.startsWith(t);async function Wf({fs:e,cache:t,onProgress:n,onPostCheckout:r,dir:i,gitdir:a,remote:s,ref:o,filepaths:l,noCheckout:c,noUpdateHead:u,dryRun:f,force:h,track:d=!0}){let p;if(r)try{p=await q.resolve({fs:e,gitdir:a,ref:"HEAD"})}catch(m){p="0000000000000000000000000000000000000000"}let g;try{g=await q.resolve({fs:e,gitdir:a,ref:o})}catch(m){if(o==="HEAD")throw m;let w=`${s}/${o}`;if(g=await q.resolve({fs:e,gitdir:a,ref:w}),d){let b=await Ve.get({fs:e,gitdir:a});await b.set(`branch.${o}.remote`,s),await b.set(`branch.${o}.merge`,`refs/heads/${o}`),await Ve.save({fs:e,gitdir:a,config:b})}await q.writeRef({fs:e,gitdir:a,ref:`refs/heads/${o}`,value:g})}if(!c){let m;try{m=await xC({fs:e,cache:t,onProgress:n,dir:i,gitdir:a,ref:o,force:h,filepaths:l})}catch(x){throw x instanceof Re&&x.data.what===g?new ns(o,g):x}let w=m.filter(([x])=>x==="conflict").map(([x,k])=>k);if(w.length>0)throw new ts(w);let b=m.filter(([x])=>x==="error").map(([x,k])=>k);if(b.length>0)throw new ue(b.join(", "));if(f){r&&await r({previousHead:p,newHead:g,type:l!=null&&l.length>0?"file":"branch"});return}
`).map(s=>i.add(s))}),i}static async write({fs:t,gitdir:n,oids:r}){$r===null&&($r=new Za.default);let i=B(n,"shallow");if(r.size>0){let a=[...r].join(`
`)+`
`;await $r.acquire(i,async function(){await t.write(i,a,{encoding:"utf8"})})}else await $r.acquire(i,async function(){await t.rm(i)})}};async function kC({fs:e,gitdir:t,oid:n}){let r=`objects/${n.slice(0,2)}/${n.slice(2)}`;return e.exists(`${t}/${r}`)}async function TC({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i}){let a=await e.readdir(B(n,"objects/pack"));a=a.filter(s=>s.endsWith(".idx"));for(let s of a){let o=`${n}/objects/pack/${s}`,l=await zf({fs:e,cache:t,filename:o,getExternalRefDelta:i});if(l.error)throw new ue(l.error);if(l.offsets.has(r))return!0}return!1}async function x1({fs:e,cache:t,gitdir:n,oid:r,format:i="content"}){let a=o=>We({fs:e,cache:t,gitdir:n,oid:o}),s=await kC({fs:e,gitdir:n,oid:r});return s||(s=await TC({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a})),s}function CC(e){let i="5041434b"+"00000002"+"00000000";return e.slice(0,12).toString("hex")===i}function U1(e,t){let n=e.map(r=>r.split("=",1)[0]);return t.filter(r=>{let i=r.split("=",1)[0];return n.includes(i)})}var Qo={name:"isomorphic-git",version:"1.27.1",agent:"git/isomorphic-git@1.27.1"},Si=class{constructor(){this._queue=[]}write(t){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){let n=this._waiting;this._waiting=null,n({value:t})}else this._queue.push(t)}end(){if(this._ended=!0,this._waiting){let t=this._waiting;this._waiting=null,t({done:!0})}}destroy(t){this.error=t,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(t=>{this._waiting=t})}};function FC(e){let t=e.indexOf("\r"),n=e.indexOf(`
`);return t===-1&&n===-1?-1:t===-1?n+1:n===-1?t+1:n===t+1?n+1:Math.min(t,n)+1}function G1(e){let t=new Si,n="";return(async()=>(await gs(e,r=>{for(r=r.toString("utf8"),n+=r;;){let i=FC(n);if(i===-1)break;t.write(n.slice(0,i)),n=n.slice(i)}}),n.length>0&&t.write(n),t.end()))(),t}var Wo=class{static demux(t){let n=ze.streamReader(t),r=new Si,i=new Si,a=new Si,s=async function(){let o=await n();if(o===null)return s();if(o===!0){r.end(),a.end(),t.error?i.destroy(t.error):i.end();return}switch(o[0]){case 1:{i.write(o.slice(1));break}case 2:{a.write(o.slice(1));break}case 3:{let l=o.slice(1);a.write(l),r.end(),a.end(),i.destroy(new Error(l.toString("utf8")));return}default:r.write(o)}s()};return s(),{packetlines:r,packfile:i,progress:a}}};async function PC(e){let{packetlines:t,packfile:n,progress:r}=Wo.demux(e),i=[],a=[],s=[],o=!1,l=!1;return new Promise((c,u)=>{gs(t,f=>{let h=f.toString("utf8").trim();if(h.startsWith("shallow")){let d=h.slice(-41).trim();d.length!==40&&u(new cr(d)),i.push(d)}else if(h.startsWith("unshallow")){let d=h.slice(-41).trim();d.length!==40&&u(new cr(d)),a.push(d)}else if(h.startsWith("ACK")){let[,d,p]=h.split(" ");s.push({oid:d,status:p}),p||(l=!0)}else h.startsWith("NAK")?(o=!0,l=!0):(l=!0,o=!0);l&&(e.error?u(e.error):c({shallows:i,unshallows:a,acks:s,nak:o,packfile:n,progress:r}))}).finally(()=>{l||(e.error?u(e.error):c({shallows:i,unshallows:a,acks:s,nak:o,packfile:n,progress:r}))})})}function MC({capabilities:e=[],wants:t=[],haves:n=[],shallows:r=[],depth:i=null,since:a=null,exclude:s=[]}){let o=[];t=[...new Set(t)];let l=` ${e.join(" ")}`;for(let c of t)o.push(ze.encode(`want ${c}${l}
`)),l="";for(let c of r)o.push(ze.encode(`shallow ${c}
`));i!==null&&o.push(ze.encode(`deepen ${i}
`)),a!==null&&o.push(ze.encode(`deepen-since ${Math.floor(a.valueOf()/1e3)}
`));for(let c of s)o.push(ze.encode(`deepen-not ${c}
`));o.push(ze.flush());for(let c of n)o.push(ze.encode(`have ${c}
`));return o.push(ze.encode(`done
`)),o}async function qf({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:s,onAuthFailure:o,gitdir:l,ref:c,remoteRef:u,remote:f,url:h,corsProxy:d,depth:p=null,since:g=null,exclude:m=[],relative:w=!1,tags:b=!1,singleBranch:S=!1,headers:A={},prune:x=!1,pruneTags:k=!1}){let y=c||await Vr({fs:e,gitdir:l,test:!0}),E=await Ve.get({fs:e,gitdir:l}),_=f||y&&await E.get(`branch.${y}.remote`)||"origin",C=h||await E.get(`remote.${_}.url`);if(typeof C=="undefined")throw new Ot("remote OR url");let P=u||y&&await E.get(`branch.${y}.merge`)||c||"HEAD";d===void 0&&(d=await E.get("http.corsProxy"));let L=Di.getRemoteHelperFor({url:C}),N=await L.discover({http:n,onAuth:a,onAuthSuccess:s,onAuthFailure:o,corsProxy:d,service:"git-upload-pack",url:C,headers:A,protocolVersion:1}),j=N.auth,Y=N.refs;if(Y.size===0)return{defaultBranch:null,fetchHead:null,fetchHeadDescription:null};if(p!==null&&!N.capabilities.has("shallow"))throw new or("shallow","depth");if(g!==null&&!N.capabilities.has("deepen-since"))throw new or("deepen-since","since");if(m.length>0&&!N.capabilities.has("deepen-not"))throw new or("deepen-not","exclude");if(w===!0&&!N.capabilities.has("deepen-relative"))throw new or("deepen-relative","relative");let{oid:le,fullref:he}=q.resolveAgainstMap({ref:P,map:Y});for(let G of Y.keys())G===he||G==="HEAD"||G.startsWith("refs/heads/")||b&&G.startsWith("refs/tags/")||Y.delete(G);let ae=U1([...N.capabilities],["multi_ack_detailed","no-done","side-band-64k","ofs-delta",`agent=${Qo.agent}`]);w&&ae.push("deepen-relative");let Pe=S?[le]:Y.values(),de=S?[y]:await q.listRefs({fs:e,gitdir:l,filepath:"refs"}),$=[];for(let G of de)try{G=await q.expand({fs:e,gitdir:l,ref:G});let rt=await q.resolve({fs:e,gitdir:l,ref:G});await x1({fs:e,cache:t,gitdir:l,oid:rt})&&$.push(rt)}catch(rt){}$=[...new Set($)];let z=await zr.read({fs:e,gitdir:l}),D=N.capabilities.has("shallow")?[...z]:[],se=MC({capabilities:ae,wants:Pe,haves:$,shallows:D,depth:p,since:g,exclude:m}),Se=Buffer.from(await Vo(se)),gt=await L.connect({http:n,onProgress:r,corsProxy:d,service:"git-upload-pack",url:C,auth:j,body:[Se],headers:A}),be=await PC(gt.body);gt.headers&&(be.headers=gt.headers);for(let G of be.shallows)if(!z.has(G))try{let{object:rt}=await We({fs:e,cache:t,gitdir:l,oid:G}),H=new Rt(rt),Z=await Promise.all(H.headers().parent.map(Ke=>x1({fs:e,cache:t,gitdir:l,oid:Ke})));Z.length===0||Z.every(Ke=>Ke)||z.add(G)}catch(rt){z.add(G)}for(let G of be.unshallows)z.delete(G);if(await zr.write({fs:e,gitdir:l,oids:z}),S){let G=new Map([[he,le]]),rt=new Map,H=10,Z=he;for(;H--;){let _t=N.symrefs.get(Z);if(_t===void 0)break;rt.set(Z,_t),Z=_t}let ye=Y.get(Z);ye&&G.set(Z,ye);let{pruned:Ke}=await q.updateRemoteRefs({fs:e,gitdir:l,remote:_,refs:G,symrefs:rt,tags:b,prune:x});x&&(be.pruned=Ke)}else{let{pruned:G}=await q.updateRemoteRefs({fs:e,gitdir:l,remote:_,refs:Y,symrefs:N.symrefs,tags:b,prune:x,pruneTags:k});x&&(be.pruned=G)}if(be.HEAD=N.symrefs.get("HEAD"),be.HEAD===void 0){let{oid:G}=q.resolveAgainstMap({ref:"HEAD",map:Y});for(let[rt,H]of Y.entries())if(rt!=="HEAD"&&H===G){be.HEAD=rt;break}}let ot=he.startsWith("refs/tags")?"tag":"branch";if(be.FETCH_HEAD={oid:le,description:`${ot} '${Hr(he)}' of ${C}`},r||i){let G=G1(be.progress);gs(G,async rt=>{if(i&&await i(rt),r){let H=rt.match(/([^:]*).*\((\d+?)\/(\d+?)\)/);H&&await r({phase:H[1].trim(),loaded:parseInt(H[2],10),total:parseInt(H[3],10)})}})}let ee=Buffer.from(await Vo(be.packfile));if(gt.body.error)throw gt.body.error;let Ie=ee.slice(-20).toString("hex"),Ee={defaultBranch:be.HEAD,fetchHead:be.FETCH_HEAD.oid,fetchHeadDescription:be.FETCH_HEAD.description};if(be.headers&&(Ee.headers=be.headers),x&&(Ee.pruned=be.pruned),Ie!==""&&!CC(ee)){Ee.packfile=`objects/pack/pack-${Ie}.pack`;let G=B(l,Ee.packfile);await e.write(G,ee);let rt=Z=>We({fs:e,cache:t,gitdir:l,oid:Z}),H=await Qa.fromPack({pack:ee,getExternalRefDelta:rt,onProgress:r});await e.write(G.replace(/\.pack$/,".idx"),await H.toBuffer())}return Ee}async function z1({fs:e,bare:t=!1,dir:n,gitdir:r=t?n:B(n,".git"),defaultBranch:i="master"}){if(await e.exists(r+"/config"))re
repositoryformatversion = 0
filemode = false
bare = ${t}
`+(t?"":` logallrefupdates = true
`)+` symlinks = false
ignorecase = true
`),await e.write(r+"/HEAD",`ref: refs/heads/${i}
`)}async function OC({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:s,onAuthFailure:o,onPostCheckout:l,dir:c,gitdir:u,url:f,corsProxy:h,ref:d,remote:p,depth:g,since:m,exclude:w,relative:b,singleBranch:S,noCheckout:A,noTags:x,headers:k}){try{if(await z1({fs:e,gitdir:u}),await N1({fs:e,gitdir:u,remote:p,url:f,force:!1}),h){let _=await Ve.get({fs:e,gitdir:u});await _.set("http.corsProxy",h),await Ve.save({fs:e,gitdir:u,config:_})}let{defaultBranch:y,fetchHead:E}=await qf({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:s,onAuthFailure:o,gitdir:u,ref:d,remote:p,corsProxy:h,depth:g,since:m,exclude:w,relative:b,singleBranch:S,headers:k,tags:!x});if(E===null)return;d=d||y,d=d.replace("refs/heads/",""),await Wf({fs:e,cache:t,onProgress:r,onPostCheckout:l,dir:c,gitdir:u,ref:d,remote:p,noCheckout:A})}catch(y){throw await e.rmdir(u,{recursive:!0,maxRetries:10}).catch(()=>{}),y}}async function IC({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:s,onPostCheckout:o,dir:l,gitdir:c=B(l,".git"),url:u,corsProxy:f=void 0,ref:h=void 0,remote:d="origin",depth:p=void 0,since:g=void 0,exclude:m=[],relative:w=!1,singleBranch:b=!1,noCheckout:S=!1,noTags:A=!1,headers:x={},cache:k={}}){try{return F("fs",e),F("http",t),F("gitdir",c),S||F("dir",l),F("url",u),await OC({fs:new Q(e),cache:k,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:s,onPostCheckout:o,dir:l,gitdir:c,url:u,corsProxy:f,ref:h,remote:d,depth:p,since:g,exclude:m,relative:w,singleBranch:b,noCheckout:S,noTags:A,headers:x})}catch(y){throw y.caller="git.clone",y}}async function RC({fs:e,onSign:t,dir:n,gitdir:r=B(n,".git"),message:i,author:a,committer:s,signingKey:o,amend:l=!1,dryRun:c=!1,noUpdateBranch:u=!1,ref:f,parent:h,tree:d,cache:p={}}){try{F("fs",e),l||F("message",i),o&&F("onSign",t);let g=new Q(e);return await Jo({fs:g,cache:p,onSign:t,gitdir:r,message:i,author:a,committer:s,signingKey:o,amend:l,dryRun:c,noUpdateBranch:u,ref:f,parent:h,tree:d})}catch(g){throw g.caller="git.commit",g}}async function LC({fs:e,dir:t,gitdir:n=B(t,".git"),fullname:r=!1,test:i=!1}){try{return F("fs",e),F("gitdir",n),await Vr({fs:new Q(e),gitdir:n,fullname:r,test:i})}catch(a){throw a.caller="git.currentBranch",a}}async function jC({fs:e,gitdir:t,ref:n}){if(n=n.startsWith("refs/heads/")?n:`refs/heads/${n}`,!await q.exists({fs:e,gitdir:t,ref:n}))throw new Re(n);let i=await q.expand({fs:e,gitdir:t,ref:n}),a=await Vr({fs:e,gitdir:t,fullname:!0});if(i===a){let l=await q.resolve({fs:e,gitdir:t,ref:i});await q.writeRef({fs:e,gitdir:t,ref:"HEAD",value:l})}await q.deleteRef({fs:e,gitdir:t,ref:i});let s=Hr(n),o=await Ve.get({fs:e,gitdir:t});await o.deleteSection("branch",s),await Ve.save({fs:e,gitdir:t,config:o})}async function DC({fs:e,dir:t,gitdir:n=B(t,".git"),ref:r}){try{return F("fs",e),F("ref",r),await jC({fs:new Q(e),gitdir:n,ref:r})}catch(i){throw i.caller="git.deleteBranch",i}}async function BC({fs:e,dir:t,gitdir:n=B(t,".git"),ref:r}){try{F("fs",e),F("ref",r),await q.deleteRef({fs:new Q(e),gitdir:n,ref:r})}catch(i){throw i.caller="git.deleteRef",i}}async function NC({fs:e,gitdir:t,remote:n}){let r=await Ve.get({fs:e,gitdir:t});await r.deleteSection("remote",n),await Ve.save({fs:e,gitdir:t,config:r})}async function $C({fs:e,dir:t,gitdir:n=B(t,".git"),remote:r}){try{return F("fs",e),F("remote",r),await NC({fs:new Q(e),gitdir:n,remote:r})}catch(i){throw i.caller="git.deleteRemote",i}}async function HC({fs:e,gitdir:t,ref:n}){n=n.startsWith("refs/tags/")?n:`refs/tags/${n}`,await q.deleteRef({fs:e,gitdir:t,ref:n})}async function UC({fs:e,dir:t,gitdir:n=B(t,".git"),ref:r}){try{return F("fs",e),F("ref",r),await HC({fs:new Q(e),gitdir:n,ref:r})}catch(i){throw i.caller="git.deleteTag",i}}async function GC({fs:e,gitdir:t,oid:n}){let r=n.slice(0,2);return(await e.readdir(`${t}/objects/${r}`)).map(a=>`${r}${a}`).filter(a=>a.startsWith(n))}async function zC({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i}){let a=[],s=await e.readdir(B(n,"objects/pack"));s=s.filter(o=>o.endsWith(".idx"));for(let o of s){let l=`${n}/objects/pac
`,h+=p.conflict.a.join(""),h+=`${"=".repeat(f)}
`,h+=p.conflict.b.join(""),h+=`${">".repeat(f)} ${r}
`);return{cleanMerge:d,mergedText:h}}async function YC({fs:e,cache:t,dir:n,gitdir:r=B(n,".git"),index:i,ourOid:a,baseOid:s,theirOid:o,ourName:l="ours",baseName:c="base",theirName:u="theirs",dryRun:f=!1,abortOnConflict:h=!0,mergeDriver:d}){let p=lr({ref:a}),g=lr({ref:s}),m=lr({ref:o}),w=[],b=[],S=[],A=[],x=await Ii({fs:e,cache:t,dir:n,gitdir:r,trees:[p,g,m],map:async function(k,[y,E,_]){let C=Bo(k),P=await Go(y,E),L=await Go(_,E);switch(`${P}-${L}`){case"false-false":return{mode:await E.mode(),path:C,oid:await E.oid(),type:await E.type()};case"false-true":return _?{mode:await _.mode(),path:C,oid:await _.oid(),type:await _.type()}:void 0;case"true-false":return y?{mode:await y.mode(),path:C,oid:await y.oid(),type:await y.type()}:void 0;case"true-true":{if(y&&E&&_&&await y.type()==="blob"&&await E.type()==="blob"&&await _.type()==="blob")return ZC({fs:e,gitdir:r,path:C,ours:y,base:E,theirs:_,ourName:l,baseName:c,theirName:u,mergeDriver:d}).then(async N=>{if(N.cleanMerge)h||i.insert({filepath:k,oid:N.mergeResult.oid,stage:0});else if(w.push(k),b.push(k),!h){let j=await E.oid(),Y=await y.oid(),le=await _.oid();i.delete({filepath:k}),i.insert({filepath:k,oid:j,stage:1}),i.insert({filepath:k,oid:Y,stage:2}),i.insert({filepath:k,oid:le,stage:3})}return N.mergeResult});if(E&&!y&&_&&await E.type()==="blob"&&await _.type()==="blob"){if(w.push(k),S.push(k),!h){let N=await E.oid(),j=await _.oid();i.delete({filepath:k}),i.insert({filepath:k,oid:N,stage:1}),i.insert({filepath:k,oid:j,stage:3})}return{mode:await _.mode(),oid:await _.oid(),type:"blob",path:C}}if(E&&y&&!_&&await E.type()==="blob"&&await y.type()==="blob"){if(w.push(k),A.push(k),!h){let N=await E.oid(),j=await y.oid();i.delete({filepath:k}),i.insert({filepath:k,oid:N,stage:1}),i.insert({filepath:k,oid:j,stage:2})}return{mode:await y.mode(),oid:await y.oid(),type:"blob",path:C}}if(E&&!y&&!_&&await E.type()==="blob")return;throw new Ci}}},reduce:w.length!==0&&(!n||h)?void 0:async(k,y)=>{let E=y.filter(Boolean);if(k&&!(k&&k.type==="tree"&&E.length===0)){if(E.length>0){let C=new It(E).toObject(),P=await Gt({fs:e,gitdir:r,type:"tree",object:C,dryRun:f});k.oid=P}return k}}});return w.length!==0?(n&&!h&&await Ii({fs:e,cache:t,dir:n,gitdir:r,trees:[lr({ref:x.oid})],map:async function(k,[y]){let E=`${n}/${k}`;if(await y.type()==="blob"){let _=await y.mode(),C=new TextDecoder().decode(await y.content());await e.write(E,C,{mode:_})}return!0}}),new Fi(w,b,S,A)):x.oid}async function ZC({fs:e,gitdir:t,path:n,ours:r,base:i,theirs:a,ourName:s,theirName:o,baseName:l,dryRun:c,mergeDriver:u=XC}){let f="blob",h=await i.mode()===await r.mode()?await a.mode():await r.mode();if(await r.oid()===await a.oid())return{cleanMerge:!0,mergeResult:{mode:h,path:n,oid:await r.oid(),type:f}};if(await r.oid()===await i.oid())return{cleanMerge:!0,mergeResult:{mode:h,path:n,oid:await a.oid(),type:f}};if(await a.oid()===await i.oid())return{cleanMerge:!0,mergeResult:{mode:h,path:n,oid:await r.oid(),type:f}};let d=Buffer.from(await r.content()).toString("utf8"),p=Buffer.from(await i.content()).toString("utf8"),g=Buffer.from(await a.content()).toString("utf8"),{mergedText:m,cleanMerge:w}=await u({branches:[l,s,o],contents:[p,d,g],path:n}),b=await Gt({fs:e,gitdir:t,type:"blob",object:Buffer.from(m,"utf8"),dryRun:c});return{cleanMerge:w,mergeResult:{mode:h,path:n,oid:b,type:f}}}async function V1({fs:e,cache:t,dir:n,gitdir:r,ours:i,theirs:a,fastForward:s=!0,fastForwardOnly:o=!1,dryRun:l=!1,noUpdateBranch:c=!1,abortOnConflict:u=!0,message:f,author:h,committer:d,signingKey:p,onSign:g,mergeDriver:m}){i===void 0&&(i=await Vr({fs:e,gitdir:r,fullname:!0})),i=await q.expand({fs:e,gitdir:r,ref:i}),a=await q.expand({fs:e,gitdir:r,ref:a});let w=await q.resolve({fs:e,gitdir:r,ref:i}),b=await q.resolve({fs:e,gitdir:r,ref:a}),S=await Xf({fs:e,cache:t,gitdir:r,oids:[w,b]});if(S.length!==1)throw new Ci;let A=S[0];if(A===b)return{oid:w,alreadyMerged:!0};if(s&&A===w)return!l&&!c&&await q.writeRef({fs:e,gitdir:r,ref:i,value:b}),{oid:b,fastForward:!0};{if(o)throw new is;let x=await ct.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1}
`)),r.push(ze.encode(`agent=${Qo.agent}
`)),(n||t||e)&&r.push(ze.delim()),n&&r.push(ze.encode("peel")),t&&r.push(ze.encode("symrefs")),e&&r.push(ze.encode(`ref-prefix ${e}`)),r.push(ze.flush()),r}async function _8({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,url:a,headers:s={},forPush:o=!1,protocolVersion:l=2,prefix:c,symrefs:u,peelTags:f}){try{F("http",e),F("url",a);let h=await ji.discover({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,service:o?"git-receive-pack":"git-upload-pack",url:a,headers:s,protocolVersion:l});if(h.protocolVersion===1)return X1(h,c,u,f);let d=await x8({prefix:c,symrefs:u,peelTags:f}),p=await ji.connect({http:e,auth:h.auth,headers:s,corsProxy:i,service:o?"git-receive-pack":"git-upload-pack",url:a,body:d});return b8(p.body)}catch(h){throw h.caller="git.listServerRefs",h}}async function S8({fs:e,dir:t,gitdir:n=B(t,".git")}){try{return F("fs",e),F("gitdir",n),q.listTags({fs:new Q(e),gitdir:n})}catch(r){throw r.caller="git.listTags",r}}function E8(e,t){return e.committer.timestamp-t.committer.timestamp}var A8="e69de29bb2d1d6434b8b29ae775ad8c2e48c5391";async function _1({fs:e,cache:t,gitdir:n,oid:r,fileId:i}){if(i===A8)return;let a=r,s,o=await Oi({fs:e,cache:t,gitdir:n,oid:r}),l=o.tree;return i===o.oid?s=o.path:(s=await K1({fs:e,cache:t,gitdir:n,tree:l,fileId:i,oid:a}),Array.isArray(s)&&(s.length===0?s=void 0:s.length===1&&(s=s[0]))),s}async function K1({fs:e,cache:t,gitdir:n,tree:r,fileId:i,oid:a,filepaths:s=[],parentPath:o=""}){let l=r.entries().map(function(c){let u;return c.oid===i?(u=B(o,c.path),s.push(u)):c.type==="tree"&&(u=We({fs:e,cache:t,gitdir:n,oid:c.oid}).then(function({object:f}){return K1({fs:e,cache:t,gitdir:n,tree:It.from(f),fileId:i,oid:a,filepaths:s,parentPath:B(o,c.path)})})),u});return await Promise.all(l),s}async function k8({fs:e,cache:t,gitdir:n,filepath:r,ref:i,depth:a,since:s,force:o,follow:l}){let c=typeof s=="undefined"?void 0:Math.floor(s.valueOf()/1e3),u=[],f=await zr.read({fs:e,gitdir:n}),h=await q.resolve({fs:e,gitdir:n,ref:i}),d=[await zo({fs:e,cache:t,gitdir:n,oid:h})],p,g,m;function w(b){m&&r&&u.push(b)}for(;d.length>0;){let b=d.pop();if(c!==void 0&&b.commit.committer.timestamp<=c)break;if(r){let S;try{S=await ms({fs:e,cache:t,gitdir:n,oid:b.commit.tree,filepath:r}),g&&p!==S&&u.push(g),p=S,g=b,m=!0}catch(A){if(A instanceof Re){let x=l&&p;if(x&&(x=await _1({fs:e,cache:t,gitdir:n,oid:b.commit.tree,fileId:p}),x))if(Array.isArray(x)){if(g){let k=await _1({fs:e,cache:t,gitdir:n,oid:g.commit.tree,fileId:p});if(Array.isArray(k))if(x=x.filter(y=>k.indexOf(y)===-1),x.length===1)x=x[0],r=x,g&&u.push(g);else{x=!1,g&&u.push(g);break}}}else r=x,g&&u.push(g);if(!x){if(m&&p&&(u.push(g),!o))break;if(!o&&!l)throw A}g=b,m=!1}else throw A}}else u.push(b);if(a!==void 0&&u.length===a){w(b);break}if(!f.has(b.oid))for(let S of b.commit.parent){let A=await zo({fs:e,cache:t,gitdir:n,oid:S});d.map(x=>x.oid).includes(A.oid)||d.push(A)}d.length===0&&w(b),d.sort((S,A)=>E8(S.commit,A.commit))}return u}async function T8({fs:e,dir:t,gitdir:n=B(t,".git"),filepath:r,ref:i="HEAD",depth:a,since:s,force:o,follow:l,cache:c={}}){try{return F("fs",e),F("gitdir",n),F("ref",i),await k8({fs:new Q(e),cache:c,gitdir:n,filepath:r,ref:i,depth:a,since:s,force:o,follow:l})}catch(u){throw u.caller="git.log",u}}async function C8({fs:e,onSign:t,dir:n,gitdir:r=B(n,".git"),ours:i,theirs:a,fastForward:s=!0,fastForwardOnly:o=!1,dryRun:l=!1,noUpdateBranch:c=!1,abortOnConflict:u=!0,message:f,author:h,committer:d,signingKey:p,cache:g={},mergeDriver:m}){try{F("fs",e),p&&F("onSign",t);let w=new Q(e),b=await Gr({fs:w,gitdir:r,author:h});if(!b&&(!o||!s))throw new kt("author");let S=await Li({fs:w,gitdir:r,author:b,committer:d});if(!S&&(!o||!s))throw new kt("committer");return await V1({fs:w,cache:g,dir:n,gitdir:r,ours:i,theirs:a,fastForward:s,fastForwardOnly:o,dryRun:l,noUpdateBranch:c,abortOnConflict:u,message:f,author:b,committer:S,signingKey:p,onSign:t,mergeDriver:m})}catch(w){throw w.caller="git.merge",w}}var F8={commit:16,tree:32,blob:48,tag:64,ofs_delta:96,ref_delta:112};async function J1({fs:e,cache:t,dir:n,gitdir:r=B(n,".git"),oid
`),i=await r();let a=n.toString("utf8").split(`
`);if(i=a.shift(),!i.startsWith("unpack "))throw new Ur('unpack ok" or "unpack [error message]',i);t.ok=i==="unpack ok",t.ok||(t.error=i.slice(7)),t.refs={};for(let s of a){if(s.trim()==="")continue;let o=s.slice(0,2),l=s.slice(3),c=l.indexOf(" ");c===-1&&(c=l.length);let u=l.slice(0,c),f=l.slice(c+1);t.refs[u]={ok:o==="ok",error:f}}return t}async function L8({capabilities:e=[],triplets:t=[]}){let n=[],r=`\0 ${e.join(" ")}`;for(let i of t)n.push(ze.encode(`${i.oldoid} ${i.oid} ${i.fullRef}${r}
`)),r="";return n.push(ze.flush()),n}async function j8({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:s,onAuthFailure:o,onPrePush:l,gitdir:c,ref:u,remoteRef:f,remote:h,url:d,force:p=!1,delete:g=!1,corsProxy:m,headers:w={}}){let b=u||await Vr({fs:e,gitdir:c});if(typeof b=="undefined")throw new Ot("ref");let S=await Ve.get({fs:e,gitdir:c});h=h||await S.get(`branch.${b}.pushRemote`)||await S.get("remote.pushDefault")||await S.get(`branch.${b}.remote`)||"origin";let A=d||await S.get(`remote.${h}.pushurl`)||await S.get(`remote.${h}.url`);if(typeof A=="undefined")throw new Ot("remote OR url");let x=f||await S.get(`branch.${b}.merge`);if(typeof A=="undefined")throw new Ot("remoteRef");m===void 0&&(m=await S.get("http.corsProxy"));let k=await q.expand({fs:e,gitdir:c,ref:b}),y=g?"0000000000000000000000000000000000000000":await q.resolve({fs:e,gitdir:c,ref:k}),E=Di.getRemoteHelperFor({url:A}),_=await E.discover({http:n,onAuth:a,onAuthSuccess:s,onAuthFailure:o,corsProxy:m,service:"git-receive-pack",url:A,headers:w,protocolVersion:1}),C=_.auth,P;if(!x)P=k;else try{P=await q.expandAgainstMap({ref:x,map:_.refs})}catch(z){if(z instanceof Re)P=x.startsWith("refs/")?x:`refs/heads/${x}`;else throw z}let L=_.refs.get(P)||"0000000000000000000000000000000000000000";if(l&&!await l({remote:h,url:A,localRef:{ref:g?"(delete)":k,oid:y},remoteRef:{ref:P,oid:L}}))throw new Mi;let N=!_.capabilities.has("no-thin"),j=new Set;if(!g){let z=[..._.refs.values()],D=new Set;if(L!=="0000000000000000000000000000000000000000"){let se=await Xf({fs:e,cache:t,gitdir:c,oids:[y,L]});for(let Se of se)z.push(Se);N&&(D=await Pf({fs:e,cache:t,gitdir:c,oids:se}))}if(!z.includes(y)){let se=await I8({fs:e,cache:t,gitdir:c,start:[y],finish:z});j=await Pf({fs:e,cache:t,gitdir:c,oids:se})}if(N){try{let se=await q.resolve({fs:e,gitdir:c,ref:`refs/remotes/${h}/HEAD`,depth:2}),{oid:Se}=await q.resolveAgainstMap({ref:se.replace(`refs/remotes/${h}/`,""),fullref:se,map:_.refs}),gt=[Se];for(let be of await Pf({fs:e,cache:t,gitdir:c,oids:gt}))D.add(be)}catch(se){}for(let se of D)j.delete(se)}if(y===L&&(p=!0),!p){if(k.startsWith("refs/tags")&&L!=="0000000000000000000000000000000000000000")throw new Pi("tag-exists");if(y!=="0000000000000000000000000000000000000000"&&L!=="0000000000000000000000000000000000000000"&&!await Y1({fs:e,cache:t,gitdir:c,oid:y,ancestor:L,depth:-1}))throw new Pi("not-fast-forward")}}let Y=U1([..._.capabilities],["report-status","side-band-64k",`agent=${Qo.agent}`]),le=await L8({capabilities:Y,triplets:[{oldoid:L,oid:y,fullRef:P}]}),he=g?[]:await J1({fs:e,cache:t,gitdir:c,oids:[...j]}),ae=await E.connect({http:n,onProgress:r,corsProxy:m,service:"git-receive-pack",url:A,auth:C,headers:w,body:[...le,...he]}),{packfile:Pe,progress:de}=await Wo.demux(ae.body);if(i){let z=G1(de);gs(z,async D=>{await i(D)})}let $=await R8(Pe);if(ae.headers&&($.headers=ae.headers),h&&$.ok&&$.refs[P].ok&&!k.startsWith("refs/tags")){let z=`refs/remotes/${h}/${P.replace("refs/heads","")}`;g?await q.deleteRef({fs:e,gitdir:c,ref:z}):await q.writeRef({fs:e,gitdir:c,ref:z,value:y})}if($.ok&&Object.values($.refs).every(z=>z.ok))return $;{let z=Object.entries($.refs).filter(([D,se])=>!se.ok).map(([D,se])=>`
- ${D}: ${se.error}`).join("");throw new as(z,$)}}async function D8({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:s,onPrePush:o,dir:l,gitdir:c=B(l,".git"),ref:u,remoteRef:f,remote:h="origin",url:d,force:p=!1,delete:g=!1,corsProxy:m,headers:w={},cache:b={}}){try{return F("fs",e),F("http",t),F("gitdir",c),await j8({fs:new Q(e),cache:b,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:s,onPrePush:o,gitdir:c,ref:u,remoteRef:f,remote:h,url:d,force:p,delete:g,corsProxy:m,headers:w})}catch(S){throw S.caller="git.push",S}}async function Q1({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await We({fs:e,cache:t,gitdir:n,oid:r});if(i==="tag")return r=Ut.from(a).parse().object,Q1({fs:e,cache:t,gitdir:n,oid:r});if(i!=="blob")throw new At(r,i,"blob");return{oid:r,blob:new Uint8Array(a)}}async function ey({fs:e,cache:t,gitdir:n,oid:r,filepath:i=void 0}){return i!==void 0&&(r=await ms({fs:e,cache:t,gitdir:n,oid:r,filepath:i})),await Q1({fs:e,cache:t,gitdir:n,oid:r})}async function ys({fs:e,dir:t,gitdir:n=B(t,".git"),oid:r,filepath:i,cache:a={}}){try{return F("fs",e),F("gitdir",n),F("oid",r),await ey({fs:new Q(e),cache:a,gitdir:n,oid:r,filepath:i})}catch(s){throw s.caller="git.readBlob",s}}async function B8({fs:e,dir:t,gitdir:n=B(t,".git"),oid:r,cache:i={}}){try{return F("fs",e),F("gitdir",n),F("oid",r),await zo({fs:new Q(e),cache:i,gitdir:n,oid:r})}catch(a){throw a.caller="git.readCommit",a}}async function N8({fs:e,cache:t,gitdir:n,ref:r="refs/notes/commits",oid:i}){let a=await q.resolve({gitdir:n,fs:e,ref:r}),{blob:s}=await ey({fs:e,cache:t,gitdir:n,oid:a,filepath:i});return s}async function $8({fs:e,dir:t,gitdir:n=B(t,".git"),ref:r="refs/notes/commits",oid:i,cache:a={}}){try{return F("fs",e),F("gitdir",n),F("ref",r),F("oid",i),await N8({fs:new Q(e),cache:a,gitdir:n,ref:r,oid:i})}catch(s){throw s.caller="git.readNote",s}}async function H8({fs:e,dir:t,gitdir:n=B(t,".git"),oid:r,format:i="parsed",filepath:a=void 0,encoding:s=void 0,cache:o={}}){try{F("fs",e),F("gitdir",n),F("oid",r);let l=new Q(e);a!==void 0&&(r=await ms({fs:l,cache:o,gitdir:n,oid:r,filepath:a}));let u=await We({fs:l,cache:o,gitdir:n,oid:r,format:i==="parsed"?"content":i});if(u.oid=r,i==="parsed")switch(u.format="parsed",u.type){case"commit":u.object=Rt.from(u.object).parse();break;case"tree":u.object=It.from(u.object).entries();break;case"blob":s?u.object=u.object.toString(s):(u.object=new Uint8Array(u.object),u.format="content");break;case"tag":u.object=Ut.from(u.object).parse();break;default:throw new At(u.oid,u.type,"blob|commit|tag|tree")}else(u.format==="deflated"||u.format==="wrapped")&&(u.type=u.format);return u}catch(l){throw l.caller="git.readObject",l}}async function U8({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await We({fs:e,cache:t,gitdir:n,oid:r,format:"content"});if(i!=="tag")throw new At(r,i,"tag");let s=Ut.from(a);return{oid:r,tag:s.parse(),payload:s.payload()}}async function G8({fs:e,dir:t,gitdir:n=B(t,".git"),oid:r,cache:i={}}){try{return F("fs",e),F("gitdir",n),F("oid",r),await U8({fs:new Q(e),cache:i,gitdir:n,oid:r})}catch(a){throw a.caller="git.readTag",a}}async function z8({fs:e,dir:t,gitdir:n=B(t,".git"),oid:r,filepath:i=void 0,cache:a={}}){try{return F("fs",e),F("gitdir",n),F("oid",r),await Bi({fs:new Q(e),cache:a,gitdir:n,oid:r,filepath:i})}catch(s){throw s.caller="git.readTree",s}}async function V8({fs:e,dir:t,gitdir:n=B(t,".git"),filepath:r,cache:i={}}){try{F("fs",e),F("gitdir",n),F("filepath",r),await ct.acquire({fs:new Q(e),gitdir:n,cache:i},async function(a){a.delete({filepath:r})})}catch(a){throw a.caller="git.remove",a}}async function W8({fs:e,cache:t,onSign:n,gitdir:r,ref:i="refs/notes/commits",oid:a,author:s,committer:o,signingKey:l}){let c;try{c=await q.resolve({gitdir:r,fs:e,ref:i})}catch(p){if(!(p instanceof Re))throw p}let f=(await Bi({fs:e,gitdir:r,oid:c||"4b825dc642cb6eb9a060e54bf8d69288fbee4904"})).tree;f=f.filter(p=>p.path!==a);let h=await Vf({fs:e,gitdir:r,tree:f});return await Jo({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tree:h,parent:c&&[c],message:`Note removed
`,author:s,committer:o,signingKey:l})}async function q8({fs:e,onSign:t,dir:n,gitdir:r=B(n,".git"),ref:i="refs/notes/commits",oid:a,author:s,committer:o,signingKey:l,cache:c={}}){try{F("fs",e),F("gitdir",r),F("oid",a);let u=new Q(e),f=await Gr({fs:u,gitdir:r,author:s});if(!f)throw new kt("author");let h=await Li({fs:u,gitdir:r,author:f,committer:o});if(!h)throw new kt("committer");return await W8({fs:u,cache:c,onSign:t,gitdir:r,ref:i,oid:a,author:f,committer:h,signingKey:l})}catch(u){throw u.caller="git.removeNote",u}}async function X8({fs:e,gitdir:t,oldref:n,ref:r,checkout:i=!1}){if(r!==fn.default.clean(r))throw new Gn(r,fn.default.clean(r));if(n!==fn.default.clean(n))throw new Gn(n,fn.default.clean(n));let a=`refs/heads/${n}`,s=`refs/heads/${r}`;if(await q.exists({fs:e,gitdir:t,ref:s}))throw new hn("branch",r,!1);let l=await q.resolve({fs:e,gitdir:t,ref:a,depth:1});await q.writeRef({fs:e,gitdir:t,ref:s,value:l}),await q.deleteRef({fs:e,gitdir:t,ref:a});let u=await Vr({fs:e,gitdir:t,fullname:!0})===a;(i||u)&&await q.writeSymbolicRef({fs:e,gitdir:t,ref:"HEAD",value:s})}async function Y8({fs:e,dir:t,gitdir:n=B(t,".git"),ref:r,oldref:i,checkout:a=!1}){try{return F("fs",e),F("gitdir",n),F("ref",r),F("oldref",i),await X8({fs:new Q(e),gitdir:n,ref:r,oldref:i,checkout:a})}catch(s){throw s.caller="git.renameBranch",s}}async function ty({gitdir:e,type:t,object:n}){return Un(ur.wrap({type:t,object:n}))}async function Z8({fs:e,dir:t,gitdir:n=B(t,".git"),filepath:r,ref:i,cache:a={}}){try{F("fs",e),F("gitdir",n),F("filepath",r);let s=new Q(e),o,l;try{o=await q.resolve({fs:s,gitdir:n,ref:i||"HEAD"})}catch(f){if(i)throw f}if(o)try{o=await ms({fs:s,cache:a,gitdir:n,oid:o,filepath:r})}catch(f){o=null}let c={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:0,uid:0,gid:0,size:0},u=t&&await s.read(B(t,r));u&&(l=await ty({gitdir:n,type:"blob",object:u}),o===l&&(c=await s.lstat(B(t,r)))),await ct.acquire({fs:s,gitdir:n,cache:a},async function(f){f.delete({filepath:r}),o&&f.insert({filepath:r,stats:c,oid:o})})}catch(s){throw s.caller="git.reset",s}}async function K8({fs:e,dir:t,gitdir:n=B(t,".git"),ref:r,depth:i}){try{return F("fs",e),F("gitdir",n),F("ref",r),await q.resolve({fs:new Q(e),gitdir:n,ref:r,depth:i})}catch(a){throw a.caller="git.resolveRef",a}}async function J8({fs:e,dir:t,gitdir:n=B(t,".git"),path:r,value:i,append:a=!1}){try{F("fs",e),F("gitdir",n),F("path",r);let s=new Q(e),o=await Ve.get({fs:s,gitdir:n});a?await o.append(r,i):await o.set(r,i),await Ve.save({fs:s,gitdir:n,config:o})}catch(s){throw s.caller="git.setConfig",s}}async function Q8({fs:e,dir:t,gitdir:n=B(t,".git"),filepath:r,cache:i={}}){try{F("fs",e),F("gitdir",n),F("filepath",r);let a=new Q(e);if(await Ri.isIgnored({fs:a,gitdir:n,dir:t,filepath:r}))return"ignored";let o=await e6({fs:a,cache:i,gitdir:n}),l=await ny({fs:a,cache:i,gitdir:n,tree:o,path:r}),c=await ct.acquire({fs:a,gitdir:n,cache:i},async function(g){for(let m of g)if(m.path===r)return m;return null}),u=await a.lstat(B(t,r)),f=l!==null,h=c!==null,d=u!==null,p=async()=>{if(h&&!Do(c,u))return c.oid;{let g=await a.read(B(t,r)),m=await ty({gitdir:n,type:"blob",object:g});return h&&c.oid===m&&u.size!==-1&&ct.acquire({fs:a,gitdir:n,cache:i},async function(w){w.insert({filepath:r,stats:u,oid:m})}),m}};if(!f&&!d&&!h)return"absent";if(!f&&!d&&h)return"*absent";if(!f&&d&&!h)return"*added";if(!f&&d&&h)return await p()===c.oid?"added":"*added";if(f&&!d&&!h)return"deleted";if(f&&!d&&h)return l===c.oid,"*deleted";if(f&&d&&!h)return await p()===l?"*undeleted":"*undeletemodified";if(f&&d&&h){let g=await p();return g===l?g===c.oid?"unmodified":"*unmodified":g===c.oid?"modified":"*modified"}}catch(a){throw a.caller="git.status",a}}async function ny({fs:e,cache:t,gitdir:n,tree:r,path:i}){typeof i=="string"&&(i=i.split("/"));let a=i.shift();for(let s of r)if(s.path===a){if(i.length===0)return s.oid;let{type:o,object:l}=await We({fs:e,cache:t,gitdir:n,oid:s.oid});if(o==="tree"){let c=It.from(l);return ny({fs:e,cache:t,gitdir:n,tree:c,path:i})}if(o==="blob")throw new At(s.oid,o,"blob",i.join("/"))}return null}async functi
`){return e.split(n).reduce((r,i)=>{let a=t?i.trim():i;return a&&r.push(a),r},[])}function yh(e,t){return ks(e,!0).map(n=>t(n))}function vh(e){return(0,gl.exists)(e,gl.FOLDER)}function we(e,t){return Array.isArray(e)?e.includes(t)||e.push(t):e.add(t),t}function Zy(e,t){return Array.isArray(e)&&!e.includes(t)&&e.push(t),e}function yl(e,t){if(Array.isArray(e)){let n=e.indexOf(t);n>=0&&e.splice(n,1)}else e.delete(t);return t}function Cn(e){return Array.isArray(e)?e:[e]}function Ky(e){return e.replace(/[\s-]+(.)/g,(t,n)=>n.toUpperCase())}function Jy(e){return Cn(e).map(String)}function Oe(e,t=0){if(e==null)return t;let n=parseInt(e,10);return isNaN(n)?t:n}function xs(e,t){let n=[];for(let r=0,i=e.length;r<i;r++)n.push(t,e[r]);return n}function _s(e){return(Array.isArray(e)?Buffer.concat(e):e).toString("utf-8")}function Qy(e,t){return Object.assign({},...t.map(n=>n in e?{[n]:e[n]}:{}))}function rh(e=0){return new Promise(t=>setTimeout(t,e))}function ih(e){if(e!==!1)return e}var zi,Zr,Ts,vl=W({"src/lib/utils/util.ts"(){"use strict";zi="\0",Zr=()=>{},Ts=Object.prototype.toString.call.bind(Object.prototype.toString)}});function Fn(e,t,n){return t(e)?e:arguments.length>2?n:void 0}function wh(e,t){let n=ul(e)?"string":typeof e;return/number|string|boolean/.test(n)&&(!t||!t.includes(n))}function bh(e){return!!e&&Ts(e)==="[object Object]"}function ev(e){return typeof e=="function"}var Cs,yt,tv,fl,xh,nv=W({"src/lib/utils/argument-filters.ts"(){"use strict";vl(),Es(),Cs=e=>Array.isArray(e),yt=e=>typeof e=="string",tv=e=>Array.isArray(e)&&e.every(yt),fl=e=>yt(e)||Array.isArray(e)&&e.every(yt),xh=e=>e==null||"number|boolean|function".includes(typeof e)?!1:Array.isArray(e)||typeof e=="string"||typeof e.length=="number"}}),ah,$6=W({"src/lib/utils/exit-codes.ts"(){"use strict";ah=(e=>(e[e.SUCCESS=0]="SUCCESS",e[e.ERROR=1]="ERROR",e[e.NOT_FOUND=-2]="NOT_FOUND",e[e.UNCLEAN=128]="UNCLEAN",e))(ah||{})}}),Ss,H6=W({"src/lib/utils/git-output-streams.ts"(){"use strict";Ss=class{constructor(e,t){this.stdOut=e,this.stdErr=t}asStrings(){return new Ss(this.stdOut.toString("utf8"),this.stdErr.toString("utf8"))}}}}),fe,hr,U6=W({"src/lib/utils/line-parser.ts"(){"use strict";fe=class{constructor(e,t){this.matches=[],this.parse=(n,r)=>(this.resetMatches(),this._regExp.every((i,a)=>this.addMatch(i,a,n(a)))?this.useMatches(r,this.prepareMatches())!==!1:!1),this._regExp=Array.isArray(e)?e:[e],t&&(this.useMatches=t)}useMatches(e,t){throw new Error("LineParser:useMatches not implemented")}resetMatches(){this.matches.length=0}prepareMatches(){return this.matches}addMatch(e,t,n){let r=n&&e.exec(n);return r&&this.pushMatch(t,r),!!r}pushMatch(e,t){this.matches.push(...t.slice(1))}},hr=class extends fe{addMatch(e,t,n){return/^remote:\s/.test(String(n))&&super.addMatch(e,t,n)}pushMatch(e,t){(e>0||t.length>1)&&super.pushMatch(e,t)}}}});function rv(...e){let t=process.cwd(),n=Object.assign(tn({baseDir:t},iv),...e.filter(r=>typeof r=="object"&&r));return n.baseDir=n.baseDir||t,n.trimmed=n.trimmed===!0,n}var iv,G6=W({"src/lib/utils/simple-git-options.ts"(){"use strict";iv={binary:"git",maxConcurrentProcesses:5,config:[],trimmed:!1}}});function _h(e,t=[]){return bh(e)?Object.keys(e).reduce((n,r)=>{let i=e[r];return ul(i)?n.push(i):wh(i,["boolean"])?n.push(r+"="+i):n.push(r),n},t):t}function Lt(e,t=0,n=!1){let r=[];for(let i=0,a=t<0?e.length:t;i<a;i++)"string|number".includes(typeof e[i])&&r.push(String(e[i]));return _h(Sh(e),r),n||r.push(...z6(e)),r}function z6(e){let t=typeof Yr(e)=="function";return Fn(Yr(e,t?1:0),Cs,[])}function Sh(e){let t=ev(Yr(e));return Fn(Yr(e,t?1:0),bh)}function Ze(e,t=!0){let n=Vy(Yr(e));return t||Wy(n)?n:void 0}var V6=W({"src/lib/utils/task-options.ts"(){"use strict";nv(),vl(),Es()}});function sh(e,t){return e(t.stdOut,t.stdErr)}function Dt(e,t,n,r=!0){return Cn(n).forEach(i=>{for(let a=ks(i,r),s=0,o=a.length;s<o;s++){let l=(c=0)=>{if(!(s+c>=o))return a[s+c]};t.some(({parse:c})=>c(l,e))}}),e}var W6=W({"src/lib/utils/task-parser.ts"(){"use strict";vl()}}),av={};et(av,{ExitCodes:()=>ah,GitOutputStreams:()=>Ss,LineParser:()=>fe,NOOP:()=>Zr,NULL:(
`)){let l=qy(s,`
`);o=l[0],s=l[1]}yield{file:a,key:o,value:s}}}var _v,s4=W({"src/lib/responses/ConfigList.ts"(){"use strict";oe(),_v=class{constructor(){this.files=[],this.values=Object.create(null)}get all(){return this._all||(this._all=this.files.reduce((e,t)=>Object.assign(e,this.values[t]),{})),this._all}addFile(e){if(!(e in this.values)){let t=Yr(this.files);this.values[e]=t?Object.create(this.values[t]):{},this.files.push(e)}return this.values[e]}addValue(e,t,n){let r=this.addFile(e);r.hasOwnProperty(t)?Array.isArray(r[t])?r[t].push(n):r[t]=[r[t],n]:r[t]=n,this._all=void 0}}}});function Kf(e,t){return typeof e=="string"&&ch.hasOwnProperty(e)?e:t}function o4(e,t,n,r){let i=["config",`--${r}`];return n&&i.push("--add"),i.push(e,t),{commands:i,format:"utf-8",parser(a){return a}}}function l4(e,t){let n=["config","--null","--show-origin","--get-all",e];return t&&n.splice(1,0,`--${t}`),{commands:n,format:"utf-8",parser(r){return i4(r,e)}}}function c4(e){let t=["config","--list","--show-origin","--null"];return e&&t.push(`--${e}`),{commands:t,format:"utf-8",parser(n){return r4(n)}}}function u4(){return{addConfig(e,t,...n){return this._runTask(o4(e,t,n[0]===!0,Kf(n[1],"local")),Ze(arguments))},getConfig(e,t){return this._runTask(l4(e,Kf(t,void 0)),Ze(arguments))},listConfig(...e){return this._runTask(c4(Kf(e[0],void 0)),Ze(arguments))}}}var ch,Sv=W({"src/lib/tasks/config.ts"(){"use strict";s4(),oe(),ch=(e=>(e.system="system",e.global="global",e.local="local",e.worktree="worktree",e))(ch||{})}});function f4(e){return Ev.has(e)}var Jf,Ev,Av=W({"src/lib/tasks/diff-name-status.ts"(){"use strict";Jf=(e=>(e.ADDED="A",e.COPIED="C",e.DELETED="D",e.MODIFIED="M",e.RENAMED="R",e.CHANGED="T",e.UNMERGED="U",e.UNKNOWN="X",e.BROKEN="B",e))(Jf||{}),Ev=new Set(Object.values(Jf))}});function h4(...e){return new Tv().param(...e)}function d4(e){let t=new Set,n={};return yh(e,r=>{let[i,a,s]=r.split(zi);t.add(i),(n[i]=n[i]||[]).push({line:Oe(a),path:i,preview:s})}),{paths:t,results:n}}function p4(){return{grep(e){let t=Ze(arguments),n=Lt(arguments);for(let i of kv)if(n.includes(i))return this._runTask(jt(`git.grep: use of "${i}" is not supported.`),t);typeof e=="string"&&(e=h4().param(e));let r=["grep","--null","-n","--full-name",...n,...e];return this._runTask({commands:r,format:"utf-8",parser(i){return d4(i)}},t)}}}var kv,vs,hy,Tv,Cv=W({"src/lib/tasks/grep.ts"(){"use strict";oe(),Qe(),kv=["-h"],vs=Symbol("grepQuery"),Tv=class{constructor(){this[hy]=[]}*[(hy=vs,Symbol.iterator)](){for(let e of this[vs])yield e}and(...e){return e.length&&this[vs].push("--and","(",...xs(e,"-e"),")"),this}param(...e){return this[vs].push(...xs(e,"-e")),this}}}}),Fv={};et(Fv,{ResetMode:()=>ol,getResetMode:()=>g4,resetTask:()=>m4});function m4(e,t){let n=["reset"];return Pv(e)&&n.push(`--${e}`),n.push(...t),Tt(n)}function g4(e){if(Pv(e))return e;switch(typeof e){case"string":case"undefined":return"soft"}}function Pv(e){return Mv.includes(e)}var ol,Mv,Ov=W({"src/lib/tasks/reset.ts"(){"use strict";Qe(),ol=(e=>(e.MIXED="mixed",e.SOFT="soft",e.HARD="hard",e.MERGE="merge",e.KEEP="keep",e))(ol||{}),Mv=Array.from(Object.values(ol))}});function y4(){return(0,hl.default)("simple-git")}function dy(e,t,n){return!t||!String(t).replace(/\s*/,"")?n?(r,...i)=>{e(r,...i),n(r,...i)}:e:(r,...i)=>{e(`%s ${r}`,t,...i),n&&n(r,...i)}}function v4(e,t,{namespace:n}){if(typeof e=="string")return e;let r=t&&t.namespace||"";return r.startsWith(n)?r.substr(n.length+1):r||n}function Fh(e,t,n,r=y4()){let i=e&&`[${e}]`||"",a=[],s=typeof t=="string"?r.extend(t):t,o=v4(Fn(t,yt),s,r);return c(n);function l(u,f){return we(a,Fh(e,o.replace(/^[^:]+/,u),f,r))}function c(u){let f=u&&`[${u}]`||"",h=s&&dy(s,f)||Zr,d=dy(r,`${i} ${f}`,h);return Object.assign(s?h:d,{label:e,sibling:l,info:d,step:c})}}var Iv=W({"src/lib/git-logger.ts"(){"use strict";oe(),hl.default.formatters.L=e=>String(xh(e)?e.length:"-"),hl.default.formatters.B=e=>Buffer.isBuffer(e)?e.toString("utf8"):Ts(e)}}),il,uh,w4=W({"src/lib/runners/tasks-pending-queue.ts"(){"use strict";dr(),Iv(),il=class{constructor(e="GitExecutor"){this.logLabel=e,this._queue=new
`).map(pP).filter(Boolean);t||n.sort(function(i,a){let s=i.split("."),o=a.split(".");if(s.length===1||o.length===1)return dP(al(s[0]),al(o[0]));for(let l=0,c=Math.max(s.length,o.length);l<c;l++){let u=$w(al(s[l]),al(o[l]));if(u)return u}return 0});let r=t?n[0]:[...n].reverse().find(i=>i.indexOf(".")>=0);return new Dy(n,r)}}}),Uw={};et(Uw,{addAnnotatedTagTask:()=>vP,addTagTask:()=>yP,tagListTask:()=>gP});function gP(e=[]){let t=e.some(n=>/^--sort=/.test(n));return{format:"utf-8",commands:["tag","-l",...e],parser(n){return Hw(n,t)}}}function yP(e){return{format:"utf-8",commands:["tag",e],parser(){return{name:e}}}}function vP(e,t){return{format:"utf-8",commands:["tag","-a","-m",t,e],parser(){return{name:e}}}}var wP=W({"src/lib/tasks/tag.ts"(){"use strict";mP()}}),bP=D6({"src/git.js"(e,t){"use strict";var{GitExecutor:n}=(_4(),Ye(Lv)),{SimpleGitApi:r}=(bF(),Ye(mw)),{Scheduler:i}=(xF(),Ye(gw)),{configurationErrorTask:a}=(Qe(),Ye(lh)),{asArray:s,filterArray:o,filterPrimitives:l,filterString:c,filterStringOrStringArray:u,filterType:f,getTrailingOptions:h,trailingFunctionArgument:d,trailingOptionsArgument:p}=(oe(),Ye(av)),{applyPatchTask:g}=(SF(),Ye(ww)),{branchTask:m,branchLocalTask:w,deleteBranchesTask:b,deleteBranchTask:S}=(RF(),Ye(Aw)),{checkIgnoreTask:A}=(DF(),Ye(Cw)),{checkIsRepoTask:x}=(cv(),Ye(sv)),{cloneTask:k,cloneMirrorTask:y}=($F(),Ye(Fw)),{cleanWithOptionsTask:E,isCleanOptionsArray:_}=(bv(),Ye(vv)),{diffSummaryTask:C}=(jh(),Ye(Xv)),{fetchTask:P}=(VF(),Ye(Ow)),{moveTask:L}=(YF(),Ye(Rw)),{pullTask:N}=(KF(),Ye(Lw)),{pushTagsTask:j}=(cw(),Ye(lw)),{addRemoteTask:Y,getRemotesTask:le,listRemotesTask:he,remoteTask:ae,removeRemoteTask:Pe}=(sP(),Ye(Dw)),{getResetMode:de,resetTask:$}=(Ov(),Ye(Fv)),{stashListTask:z}=(lP(),Ye(Bw)),{addSubModuleTask:D,initSubModuleTask:se,subModuleTask:Se,updateSubModuleTask:gt}=(hP(),Ye(Nw)),{addAnnotatedTagTask:be,addTagTask:ot,tagListTask:ee}=(wP(),Ye(Uw)),{straightThroughBufferTask:Ie,straightThroughStringTask:Ee}=(Qe(),Ye(lh));function G(H,Z){this._plugins=Z,this._executor=new n(H.baseDir,new i(H.maxConcurrentProcesses),Z),this._trimmed=H.trimmed}(G.prototype=Object.create(r.prototype)).constructor=G,G.prototype.customBinary=function(H){return this._plugins.reconfigure("binary",H),this},G.prototype.env=function(H,Z){return arguments.length===1&&typeof H=="object"?this._executor.env=H:(this._executor.env=this._executor.env||{})[H]=Z,this},G.prototype.stashList=function(H){return this._runTask(z(p(arguments)||{},o(H)&&H||[]),d(arguments))};function rt(H,Z,ye,Ke){return typeof ye!="string"?a(`git.${H}() requires a string 'repoPath'`):Z(ye,f(Ke,c),h(arguments))}G.prototype.clone=function(){return this._runTask(rt("clone",k,...arguments),d(arguments))},G.prototype.mirror=function(){return this._runTask(rt("mirror",y,...arguments),d(arguments))},G.prototype.mv=function(H,Z){return this._runTask(L(H,Z),d(arguments))},G.prototype.checkoutLatestTag=function(H){var Z=this;return this.pull(function(){Z.tags(function(ye,Ke){Z.checkout(Ke.latest,H)})})},G.prototype.pull=function(H,Z,ye,Ke){return this._runTask(N(f(H,c),f(Z,c),h(arguments)),d(arguments))},G.prototype.fetch=function(H,Z){return this._runTask(P(f(H,c),f(Z,c),h(arguments)),d(arguments))},G.prototype.silent=function(H){return console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this will be an error in version 3"),this},G.prototype.tags=function(H,Z){return this._runTask(ee(h(arguments)),d(arguments))},G.prototype.rebase=function(){return this._runTask(Ee(["rebase",...h(arguments)]),d(arguments))},G.prototype.reset=function(H){return this._runTask($(de(H),h(arguments)),d(arguments))},G.prototype.revert=function(H){let Z=d(arguments);return typeof H!="string"?this._runTask(a("Commit must be a string"),Z):this._runTask(Ee(["revert",...h(arguments,0,!0),H]),Z)},G.prototype.addTag=function(H){let Z=typeof H=="string"?ot(H):a("Git.addTag requires a tag name");return this._runTask(Z,d(arguments))},G.prototype.addAnnotatedTag=function(H,Z){return this._runTask
PROMPT="$1"
TEMP_FILE="$OBSIDIAN_GIT_CREDENTIALS_INPUT"
cleanup() {
rm -f "$TEMP_FILE" "$TEMP_FILE.response"
}
trap cleanup EXIT
echo "$PROMPT" > "$TEMP_FILE"
while [ ! -e "$TEMP_FILE.response" ]; do
if [ ! -e "$TEMP_FILE" ]; then
echo "Trigger file got removed: Abort" >&2
exit 1
fi
sleep 0.1
done
RESPONSE=$(cat "$TEMP_FILE.response")
echo "$RESPONSE"
`;v();var qw=require("obsidian"),GP={options:[],placeholder:"",allowEmpty:!1,onlySelection:!1,initialValue:void 0},$e=class extends qw.SuggestModal{constructor(t,n){super(t.app),this.config={...GP,...n},this.setPlaceholder(this.config.placeholder)}openAndGetResult(){return new Promise(t=>{this.resolve=t,this.open(),this.config.initialValue!=null&&(this.inputEl.value=this.config.initialValue,this.inputEl.dispatchEvent(new Event("input")))})}onClose(){new Promise(t=>setTimeout(t,10)).then(()=>{this.resolve&&this.resolve(void 0)})}getSuggestions(t){return this.config.onlySelection?this.config.options:this.config.allowEmpty?[t.length>0?t:" ",...this.config.options]:[t.length>0?t:"...",...this.config.options]}renderSuggestion(t,n){n.setText(t)}onChooseSuggestion(t,n){if(this.resolve){let r;this.config.allowEmpty&&t===" "?r="":t==="..."?r=void 0:r=t,this.resolve(r)}}};v();function Xw(e,t){let n=Object.assign({},e.lineAuthor,t.lineAuthor);return Object.assign({},e,t,{lineAuthor:n})}var Xi=class extends Error{constructor(n){super("No network connection available");this.originalError=n}};v();var PS=Xe(h2()),MS=Xe(FS()),aa=require("obsidian"),lp=(e,t)=>e==="."||t==null||t.length===0||t==="."?!0:t.length>=e.length?t.startsWith(e):e.startsWith(t);function Xt(e,t){let n;if(t){if(t.button===0||t.button===1){let r=aa.Keymap.isModEvent(t);n=e.workspace.getLeaf(r)}}else n=e.workspace.getLeaf(!1);return n}function In(e,t,n,r,i){if(t.button==2){let a=e.vault.getAbstractFileByPath(n);if(a!=null){let s=new aa.Menu;e.workspace.trigger("file-menu",s,a,i,r),s.showAtPosition({x:t.pageX,y:t.pageY})}}}function wr(e){throw new Error("Impossible branch: "+e)}function cp(e){return`rgb(${e.r},${e.g},${e.b})`}function OS(e){var a;let t=(a=PS.fromString(e))==null?void 0:a.toRgbaArray();if(t===void 0)return;let[n,r,i]=t;return{r:n,g:r,b:i}}function IS(e){return e.diff(aa.moment.unix(0),"seconds")}function RS(e){if(e.length!==0)return e.slice().sort()[Math.floor(e.length/2)]}function LS(e,t){return(0,MS.default)(e,t,{strict:!0})}function br(e,t){return new Proxy(e,{get(n,r){return r==="length"?Math.min(t,n.length):n[r]}})}function jS(e,t,n){return e.length<=t?new Array(t-e.length).fill(n).join("")+e:e.substring(e.length-t)}function DS(e,t){if(t<=0)return e;let n=new Array(t).fill(" ").join(""),r=e.substring(t,e.length);return n+r}function up(e,t,n){return e<=t&&t<=n}function xr(e){let[t,...n]=e.split("/");return[t,n.length===0?void 0:n.join("/")]}function Bt(e){return e.endsWith("/")?e:e.split("/").last().replace(".md","")}function Us(e){return e===1?"1 minute":`${e} minutes`}v();var BS=require("obsidian"),sa=class{constructor(t){this.plugin=t,this.app=t.app}getRelativeVaultPath(t){return this.plugin.settings.basePath?this.plugin.settings.basePath+"/"+t:t}getRelativeRepoPath(t,n=!0){return n&&this.plugin.settings.basePath.length>0?t.substring(this.plugin.settings.basePath.length+1):t}unload(){}_getTreeStructure(t,n=0){let r=[];for(t=[...t];t.length>0;){let i=t.first(),a=i.path.substring(n);if(a.contains("/")){let s=a.substring(0,a.indexOf("/")),o=t.filter(c=>c.path.substring(n).startsWith(s+"/"));o.forEach(c=>t.remove(c));let l=i.path.substring(0,a.indexOf("/")+n);r.push({title:s,path:l,vaultPath:this.getRelativeVaultPath(l),children:this._getTreeStructure(o,(n>0?n+s.length:s.length)+1)})}else r.push({title:a,data:i,path:i.path,vaultPath:this.getRelativeVaultPath(i.path)}),t.remove(i)}return r}simplify(t){var n,r,i,a;for(let s of t){for(;;){let o=((n=s.children)==null?void 0:n.length)==1,l=((i=(r=s.children)==null?void 0:r.first())==null?void 0:i.data)==null;if(!(s.children!=null&&o&&l))break;let c=s.children.first();s.title+="/"+c.title,s.data=c.data,s.path=c.path,s.vaultPath=c.vaultPath,s.children=c.children}s.children!=null&&this.simplify(s.children),(a=s.children)==null||a.sort((o,l)=>{let c=(l.data==null?1:0)-(o.data==null?1:0);return c!=0?c:o.title.localeCompare(l.title)})}return t.sort((s,o)=>{let l=(o.data==null?1:0)-(s.data==null?1:0);return l!=0?l:s.title.localeCompare(o.title)})}getTreeStructure(t){let n=this._getTreeStructure(t);return this.s
`):i="Too many files to list",t=t+`
Affected files:
`+i}return t}};var Le=class extends sa{constructor(n){super(n);this.useDefaultWindowsGitPath=!1}async setGitInstance(n=!1){if(this.isGitInstalled()){let r=this.app.vault.adapter,i=r.getBasePath(),a=i;this.plugin.settings.basePath&&(await r.exists((0,Xn.normalizePath)(this.plugin.settings.basePath))?a=He.join(i,this.plugin.settings.basePath):n||new Xn.Notice("ObsidianGit: Base path does not exist")),this.absoluteRepoPath=a,this.git=zw({baseDir:a,binary:this.plugin.localStorage.getGitPath()||(this.useDefaultWindowsGitPath?kl:void 0),config:["core.quotepath=off"],unsafe:{allowUnsafeCustomBinary:!0}});let s=this.plugin.localStorage.getPATHPaths(),o=this.plugin.localStorage.getEnvVars(),l=this.plugin.settings.gitDir;if(s.length>0){let f=process.env.PATH+":"+s.join(":");process.env.PATH=f}l&&(process.env.GIT_DIR=l);for(let f of o){let[h,d]=f.split("=");process.env[h]=d}if(HS.default.enable("simple-git"),await this.git.checkIsRepo()){let f=await this.git.revparse("--show-cdup"),h=(0,Gs.resolve)(a+Gs.sep+f);this.absoluteRepoPath=h,await this.git.cwd(h)}let c=He.join(i,this.app.vault.configDir,"plugins","obsidian-git"),u=He.join(c,qi);process.env.SSH_ASKPASS==null&&(process.env.SSH_ASKPASS=u),process.env.OBSIDIAN_GIT_CREDENTIALS_INPUT=He.join(c,Tl),process.env.SSH_ASKPASS==u&&this.askpass().catch(f=>this.plugin.displayError(f))}}getRelativeVaultPath(n){let i=this.app.vault.adapter.getBasePath(),a=He.join(this.absoluteRepoPath,n),s=He.relative(i,a);return Xn.Platform.isWin&&(s=s.replace(/\\/g,"/")),s}getRelativeRepoPath(n,r=!0){if(r){let a=this.plugin.app.vault.adapter.getBasePath(),s=this.absoluteRepoPath,o=He.join(a,n),l=He.relative(s,o);return Xn.Platform.isWin&&(l=l.replace(/\\/g,"/")),l}return n}async askpass(){let n=this.app.vault.adapter,r=n.getBasePath(),i=He.join(r,this.app.vault.configDir,"plugins","obsidian-git"),a=this.app.vault.configDir+"/plugins/obsidian-git/";await Yn.writeFile(He.join(i,qi),Ww),await Yn.chmod(He.join(i,qi),493),this.watchAbortController=new AbortController;let{signal:s}=this.watchAbortController;try{let o=Yn.watch(i,{signal:s});for await(let l of o){if(l.filename!=Tl)continue;let c=a+Tl;if(!await n.exists(c))continue;let u=await n.read(c),f;u.length>60&&(f=new Xn.Notice(u,999999));let h=await new $e(this.plugin,{allowEmpty:!0,placeholder:u.length>60?"Enter a response to the message.":u}).openAndGetResult();f==null||f.hide(),await n.exists(c)&&await n.write(`${c}.response`,h!=null?h:"")}}catch(o){this.plugin.displayError(o),await Yn.rm(He.join(i,qi),{force:!0}),await Yn.rm(He.join(i,`${qi}.response`),{force:!0}),await new Promise(l=>setTimeout(l,5e3)),this.plugin.log("Retry watch for ask pass"),await this.askpass()}}unload(){var n;(n=this.watchAbortController)==null||n.abort()}async status(){this.plugin.setPluginState({gitAction:1});let n=await this.git.status();this.plugin.setPluginState({gitAction:0});let r=n.files.map(i=>{let a=this.formatPath(i);return{path:a.path,from:a.from,index:i.index==="?"?"U":i.index,working_dir:i.working_dir==="?"?"U":i.working_dir,vault_path:this.getRelativeVaultPath(a.path)}});return{all:r,changed:r.filter(i=>i.working_dir!==" "),staged:r.filter(i=>i.index!==" "&&i.index!="U"),conflicted:n.conflicted.map(i=>this.formatPath({path:i}).path)}}async submoduleAwareHeadRevisonInContainingDirectory(n){let r=this.getRelativeRepoPath(n),a=["-C",He.dirname(r),"rev-parse","HEAD"],s=this.git.raw(a);return s.catch(o=>console.warn("obsidian-git: rev-parse error:",o)),s}async getSubmodulePaths(){return new Promise(n=>{this.git.outputHandler((r,i,a,s)=>{if(!(s.contains("submodule")&&s.contains("foreach")))return;let o="",l=this.app.vault.adapter.getBasePath()+(this.plugin.settings.basePath?"/"+this.plugin.settings.basePath:"");i.on("data",c=>{o+=c.toString("utf8")}),i.on("end",()=>{let u=o.split(`
`).map(f=>{let h=f.match(/'([^']*)'/);if(h!=null)return l+"/"+h[1]+Gs.sep}).filter(f=>!!f);u.reverse(),n(u)})}),this.git.subModule(["foreach","--recursive",""]).then(()=>{this.git.outputHandler(()=>{})},r=>this.plugin.displayError(r))})}formatPath(n,r=!1){function i(a){if(a!=null)return a.startsWith('"')&&a.endsWith('"')?a.substring(1,a.length-1):a}return r?{from:i(n.from),path:i(n.path)}:{path:i(n.path)}}async blame(n,r,i){if(n=this.getRelativeRepoPath(n),!await this.isTracked(n))return"untracked";let a=await this.getSubmoduleOfFile(n),s=a?["-C",a.submodule]:[],o=a?a.relativeFilepath:n;s.push("blame","--porcelain"),i&&s.push("-w");let l=`-C${Al}`;switch(r){case"inactive":break;case"same-commit":s.push("-C",l);break;case"all-commits":s.push("-C","-C",l);break;default:wr(r)}s.push("--",o);let c=await this.git.raw(s);return VR(c)}async isTracked(n){let r=await this.getSubmoduleOfFile(n),i=r?["-C",r.submodule]:[],a=r?r.relativeFilepath:n;return i.push("ls-files","--",a),this.git.raw(i).then(s=>s.trim()!=="")}async commitAll({message:n}){if(this.plugin.settings.updateSubmodules){this.plugin.setPluginState({gitAction:4});let i=await this.getSubmodulePaths();for(let a of i)await this.git.cwd({path:a,root:!1}).add("-A"),await this.git.cwd({path:a,root:!1}).commit(await this.formatCommitMessage(n))}this.plugin.setPluginState({gitAction:3}),await this.git.add("-A"),this.plugin.setPluginState({gitAction:4});let r=await this.git.commit(await this.formatCommitMessage(n));return this.app.workspace.trigger("obsidian-git:head-change"),r.summary.changes}async commit({message:n,amend:r}){this.plugin.setPluginState({gitAction:4});let i=(await this.git.commit(await this.formatCommitMessage(n),r?["--amend"]:[])).summary.changes;return this.app.workspace.trigger("obsidian-git:head-change"),this.plugin.setPluginState({gitAction:0}),i}async stage(n,r){this.plugin.setPluginState({gitAction:3}),n=this.getRelativeRepoPath(n,r),await this.git.add(["--",n]),this.plugin.setPluginState({gitAction:0})}async stageAll({dir:n}){this.plugin.setPluginState({gitAction:3}),await this.git.add(n!=null?n:"-A"),this.plugin.setPluginState({gitAction:0})}async unstageAll({dir:n}){this.plugin.setPluginState({gitAction:3}),await this.git.reset(n!=null?["--",n]:[]),this.plugin.setPluginState({gitAction:0})}async unstage(n,r){this.plugin.setPluginState({gitAction:3}),n=this.getRelativeRepoPath(n,r),await this.git.reset(["--",n]),this.plugin.setPluginState({gitAction:0})}async discard(n){this.plugin.setPluginState({gitAction:3}),await this.isTracked(n)?await this.git.checkout(["--",n]):await this.app.vault.adapter.rmdir(this.getRelativeVaultPath(n),!0),this.plugin.setPluginState({gitAction:0})}async hashObject(n){n=this.getRelativeRepoPath(n);let r=await this.getSubmoduleOfFile(n),i=r?["-C",r.submodule]:[],a=r?r.relativeFilepath:n;return i.push("hash-object","--",a),this.git.raw(i)}async discardAll({dir:n}){return this.discard(n!=null?n:".")}async pull(){this.plugin.setPluginState({gitAction:2});try{this.plugin.settings.updateSubmodules&&await this.git.subModule(["update","--remote","--merge","--recursive"]);let n=await this.branchInfo(),r=await this.git.revparse([n.current]);if(!n.tracking&&this.plugin.settings.updateSubmodules){this.plugin.log("No tracking branch found. Ignoring pull of main repo and updating submodules only.");return}await this.git.fetch();let i=await this.git.revparse([n.tracking]);if(r!==i){if(this.plugin.settings.syncMethod==="merge"||this.plugin.settings.syncMethod==="rebase")try{switch(this.plugin.settings.syncMethod){case"merge":await this.git.merge([n.tracking]);break;case"rebase":await this.git.rebase([n.tracking])}}catch(o){this.plugin.displayError(`Pull failed (${this.plugin.settings.syncMethod}): ${"message"in o?o.message:o}`);return}else if(this.plugin.settings.syncMethod==="reset")try{await this.git.raw(["update-ref",`refs/heads/${n.current}`,i]),await this.unstageAll({})}catch(o){this.plugin.displayError(`Sync failed (${this.plugin.settings.syncMethod}): ${"message"in o?o.message:o}`)}this.app.workspace.trigger("obsidian-git:head-chan
`):[]}async removeRemote(n){await this.git.removeRemote(n)}async updateUpstreamBranch(n){try{await this.git.branch(["--set-upstream-to",n])}catch(r){try{await this.git.branch(["--set-upstream",n])}catch(i){await this.git.push(["--set-upstream",...xr(n)])}}}updateGitPath(n){return this.setGitInstance()}updateBasePath(n){return this.setGitInstance(!0)}async getDiffString(n,r=!1,i){return r?await this.git.diff(["--cached","--",n]):i?await this.git.show([`${i}`,"--",n]):await this.git.diff(["--",n])}async diff(n,r,i){return await this.git.diff([`${r}..${i}`,"--",n])}async getSubmoduleOfFile(n){if(!await this.app.vault.adapter.exists(He.dirname(n)))return;let r=await this.git.raw(["-C",He.dirname(n),"rev-parse","--show-toplevel"],l=>l&&console.warn("get-submodule-of-file",l==null?void 0:l.message));if(r=r.trim(),(await this.git.raw(["-C",He.dirname(n),"rev-parse","--show-superproject-working-tree"],l=>l&&console.warn("get-submodule-of-file",l==null?void 0:l.message))).trim()==="")return;let s=this.app.vault.adapter.getFullPath(He.normalize(n)),o=He.relative(r,s);return{submodule:r,relativeFilepath:o}}async getLastCommitTime(){let n=await this.git.log({n:1});if(n!=null&&n.latest!=null)return new Date(n.latest.date)}isGitInstalled(){let n=this.plugin.localStorage.getGitPath(),r=(0,hp.spawnSync)(n||"git",["--version"],{stdio:"ignore"});if(r.error)if(Xn.Platform.isWin&&!n){this.plugin.log(`Git not found in PATH. Checking standard installation path(${kl}) of Git for Windows.`);let i=(0,hp.spawnSync)(kl,["--version"],{stdio:"ignore"});if(i.error)return console.error(i.error),!1;this.useDefaultWindowsGitPath=!0}else return console.error(r.error),!1;else this.useDefaultWindowsGitPath=!1;return!0}convertErrors(n){if(n instanceof dn){let r=String(n.message);if(r.contains("Could not resolve host")||r.contains("Unable to resolve host")||r.match(/ssh: connect to host .*? port .*?: Operation timed out/)!=null||r.match(/ssh: connect to host .*? port .*?: Network is unreachable/)!=null||r.match(/ssh: connect to host .*? port .*?: Undefined error: 0/)!=null)throw new Xi(r)}throw n}},US={hash:"000000",isZeroCommit:!0,summary:""};function VR(e){let n=e.replace(`\r
`,`
`).split(`
`),r={commits:new Map,hashPerLine:[void 0],originalFileLineNrPerLine:[void 0],finalFileLineNrPerLine:[void 0],groupSizePerStartingLine:new Map},i=1;for(let a=0;a<n.length;){if(NS(n[a])){let s=n[a].split(" "),o=WR(s,i,r);for(a++;NS(n[a]);a++){let l=n[a].split(" ");qR(l,r,i)}XR(r.commits.get(o)),i+=1}else if(!(n[a]===""&&a===n.length-1))throw Error(`Expected non-whitespace line or EOF, but found: ${n[a]}`);a++}return r}function WR(e,t,n){let r=e[0];if(n.hashPerLine.push(r),n.originalFileLineNrPerLine.push(parseInt(e[1])),n.finalFileLineNrPerLine.push(parseInt(e[2])),e.length>=4&&n.groupSizePerStartingLine.set(t,parseInt(e[3])),parseInt(e[2])!==t)throw Error(`git-blame output is out of order: ${t} vs ${e[2]}`);return r}function qR(e,t,n){let r=e[0],i=e.slice(1).join(" "),a=t.hashPerLine[n],s=t.commits.get(a)||{hash:a,author:{},committer:{},previous:{}};switch(r){case"summary":s.summary=i;break;case"author":s.author.name=i;break;case"author-mail":s.author.email=$S(i);break;case"author-time":s.author.epochSeconds=parseInt(i);break;case"author-tz":s.author.tz=i;break;case"committer":s.committer.name=i;break;case"committer-mail":s.committer.email=$S(i);break;case"committer-time":s.committer.epochSeconds=parseInt(i);break;case"committer-tz":s.committer.tz=i;break;case"previous":s.previous.commitHash=i;break;case"filename":s.previous.filename=i;break}t.commits.set(a,s)}function XR(e){if(e.summary===void 0)throw Error(`Summary not provided for commit: ${e.hash}`);fp(e.author)&&(e.author=void 0),fp(e.committer)&&(e.committer=void 0),fp(e.previous)&&(e.previous=void 0),e.isZeroCommit=!!e.hash.match(/^0*$/)}function fp(e){return!e||Object.keys(e).length===0}function NS(e){return e.length>0&&e[0].trim()===e[0]}function $S(e){let t=e.startsWith("<")?e.substring(1):e;return t.endsWith(">")?t.substring(0,t.length-1):t}v();var SE=require("@codemirror/state");v();var nE=require("@codemirror/state"),Fc=require("obsidian");v();var dp=class{constructor(){this.eventsPerFilepath=new Map;this.startRemoveStalesSubscribersInterval()}ifFilepathDefinedTransformSubscribers(t,n){if(t)return this.ensureInitialized(t),n(this.eventsPerFilepath.get(t))}forEachSubscriber(t){this.eventsPerFilepath.forEach(n=>n.forEach(t))}ensureInitialized(t){this.eventsPerFilepath.get(t)||this.eventsPerFilepath.set(t,new Set)}startRemoveStalesSubscribersInterval(){this.removeStalesSubscribersTimer=window.setInterval(()=>this==null?void 0:this.forEachSubscriber(t=>t==null?void 0:t.removeIfStale()),6e4)}clear(){window.clearInterval(this.removeStalesSubscribersTimer),this.eventsPerFilepath.clear()}},oa=new dp;v();var kc=require("@codemirror/state"),KS=Xe(pp());v();var V=require("obsidian");v();v();function gn(){}gn.prototype={diff:function(t,n){var r,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=i.callback;typeof i=="function"&&(a=i,i={});var s=this;function o(A){return A=s.postProcess(A,i),a?(setTimeout(function(){a(A)},0),!0):A}t=this.castInput(t,i),n=this.castInput(n,i),t=this.removeEmpty(this.tokenize(t,i)),n=this.removeEmpty(this.tokenize(n,i));var l=n.length,c=t.length,u=1,f=l+c;i.maxEditLength!=null&&(f=Math.min(f,i.maxEditLength));var h=(r=i.timeout)!==null&&r!==void 0?r:1/0,d=Date.now()+h,p=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(p[0],n,t,0,i);if(p[0].oldPos+1>=c&&g+1>=l)return o(GS(s,p[0].lastComponent,n,t,s.useLongestToken));var m=-1/0,w=1/0;function b(){for(var A=Math.max(m,-u);A<=Math.min(w,u);A+=2){var x=void 0,k=p[A-1],y=p[A+1];k&&(p[A-1]=void 0);var E=!1;if(y){var _=y.oldPos-A;E=y&&0<=_&&_<l}var C=k&&k.oldPos+1<c;if(!E&&!C){p[A]=void 0;continue}if(!C||E&&k.oldPos<y.oldPos?x=s.addToPath(y,!0,!1,0,i):x=s.addToPath(k,!1,!0,1,i),g=s.extractCommon(x,n,t,A,i),x.oldPos+1>=c&&g+1>=l)return o(GS(s,x.lastComponent,n,t,s.useLongestToken));p[A]=x,x.oldPos+1>=c&&(w=Math.min(w,A-1)),g+1>=l&&(m=Math.max(m,A+1))}u++}if(a)(function A(){setTimeout(function(){if(u>f||Date.now()>d)return a();b()||A()},0)})();else for(;u<=f&&Date.now()<=d;){var S=b();if(S)return S}},addToPath:function(t,n,r,i,a){var s=t.lastComponent;return s&&!a.oneChangePerToken&
`));var n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(var i=0;i<r.length;i++){var a=r[i];i%2&&!t.newlineIsToken?n[n.length-1]+=a:n.push(a)}return n};xc.equals=function(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
`)&&(e=e.slice(0,-1)),t.endsWith(`
`)&&(t=t.slice(0,-1))),gn.prototype.equals.call(this,e,t,n)};function XS(e,t,n){return xc.diff(e,t,n)}var JR=new gn;JR.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var QR=new gn;QR.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function YS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function wc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?YS(Object(n),!0).forEach(function(r){nL(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YS(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function eL(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function tL(e){var t=eL(e,"string");return typeof t=="symbol"?t:t+""}function vp(e){"@babel/helpers - typeof";return vp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vp(e)}function nL(e,t,n){return t=tL(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mp(e){return rL(e)||iL(e)||aL(e)||sL()}function rL(e){if(Array.isArray(e))return wp(e)}function iL(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function aL(e,t){if(e){if(typeof e=="string")return wp(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return wp(e,t)}}function wp(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function sL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Vs=new gn;Vs.useLongestToken=!0;Vs.tokenize=xc.tokenize;Vs.castInput=function(e,t){var n=t.undefinedReplacement,r=t.stringifyReplacer,i=r===void 0?function(a,s){return typeof s=="undefined"?n:s}:r;return typeof e=="string"?e:JSON.stringify(bp(e,null,null,i),i," ")};Vs.equals=function(e,t,n){return gn.prototype.equals.call(Vs,e.replace(/,([\r\n])/g,"$1"),t.replace(/,([\r\n])/g,"$1"),n)};function bp(e,t,n,r,i){t=t||[],n=n||[],r&&(e=r(i,e));var a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];var s;if(Object.prototype.toString.call(e)==="[object Array]"){for(t.push(e),s=new Array(e.length),n.push(s),a=0;a<e.length;a+=1)s[a]=bp(e[a],t,n,r,i);return t.pop(),n.pop(),s}if(e&&e.toJSON&&(e=e.toJSON()),vp(e)==="object"&&e!==null){t.push(e),s={},n.push(s);var o=[],l;for(l in e)Object.prototype.hasOwnProperty.call(e,l)&&o.push(l);for(o.sort(),a=0;a<o.length;a+=1)l=o[a],s[l]=bp(e[l],t,n,r,l);t.pop(),n.pop()}else s=e;return s}var xp=new gn;xp.tokenize=function(e){return e.slice()};xp.join=xp.removeEmpty=function(e){return e};function ZS(e,t,n,r,i,a,s){if(s||(s={}),typeof s=="function"&&(s={callback:s}),typeof s.context=="undefined"&&(s.context=4),s.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(s.callback){var o=s,l=o.callback;XS(n,r,wc(wc({},s),{},{callback:function(f){var h=c(f);l(h)}}))}else return c(XS(n,r,s));function c(u){if(!u)return;u.push({value:"",lines:[]});function f(E){return E.map(function(_){return" "+_})}for(var h=[],d=0,p=0,g=[],m=1,w=1,b=function(){var _=u[S],C=_.lines||lL(_.value);if(_.lines=C,_.added||_.removed){var P;if(!d){var L=u[S-1];d=m,p=w,L&&(g=s.context>0?f(L.lines.slice(-s.context)):[],d-=g.length,p-=g.length)}(P=g).push.apply(P,mp(C.map(function(he){return(_.added?"+":"-")+he}))),_.added?w+=C.length:m+=C.length}else{if(d)if(C.length<=s.context*2&&S<u.length-2){var N;(N=g).push.apply(N,mp(f(C)))}else{var j,Y=Math.min(C.length,s.context);(j=g).push.apply(j,mp(f(C.slice(0,Y))));var le={oldStart:d,oldLines:m-d+Y,newStart:p,newLines:w-p+Y,lines:g};h.push(le),d=0,p=0,g=[]}m+=C.length,w+=C.length}},S=0;S<u.length;S++)b();for(var A=0,x=h;A<x.length;A++)for(var k=x[A],y=0;y<k.lines.length;y++)k.lines[y].endsWith(`
`)?k.lines[y]=k.lines[y].slice(0,-1):(k.lines.splice(y+1,0,"\\ No newline at end of file"),y++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:h}}}function _p(e){if(Array.isArray(e))return e.map(_p).join(`
`);var t=[];e.oldFileName==e.newFileName&&t.push("Index: "+e.oldFileName),t.push("==================================================================="),t.push("--- "+e.oldFileName+(typeof e.oldHeader=="undefined"?"":" "+e.oldHeader)),t.push("+++ "+e.newFileName+(typeof e.newHeader=="undefined"?"":" "+e.newHeader));for(var n=0;n<e.hunks.length;n++){var r=e.hunks[n];r.oldLines===0&&(r.oldStart-=1),r.newLines===0&&(r.newStart-=1),t.push("@@ -"+r.oldStart+","+r.oldLines+" +"+r.newStart+","+r.newLines+" @@"),t.push.apply(t,r.lines)}return t.join(`
`)+`
`}function oL(e,t,n,r,i,a,s){var o;if(typeof s=="function"&&(s={callback:s}),(o=s)!==null&&o!==void 0&&o.callback){var c=s,u=c.callback;ZS(e,t,n,r,i,a,wc(wc({},s),{},{callback:function(h){h?u(_p(h)):u()}}))}else{var l=ZS(e,t,n,r,i,a,s);return l?_p(l):void 0}}function _c(e,t,n,r,i,a){return oL(e,e,t,n,r,i,a)}function lL(e){var t=e.endsWith(`
`),n=e.split(`
`).map(function(r){return r+`
`});return t?n.pop():n.push(n.pop().slice(0,-1)),n}var ei=require("obsidian");v();var _r=require("obsidian"),Sc=class{constructor(t,n){this.plugin=n;this.promises={};this.adapter=t.adapter,this.vault=t,this.lastBasePath=this.plugin.settings.basePath,this.promises.readFile=this.readFile.bind(this),this.promises.writeFile=this.writeFile.bind(this),this.promises.readdir=this.readdir.bind(this),this.promises.mkdir=this.mkdir.bind(this),this.promises.rmdir=this.rmdir.bind(this),this.promises.stat=this.stat.bind(this),this.promises.unlink=this.unlink.bind(this),this.promises.lstat=this.lstat.bind(this),this.promises.readlink=this.readlink.bind(this),this.promises.symlink=this.symlink.bind(this)}async readFile(t,n){var r;if(this.maybeLog("Read: "+t+JSON.stringify(n)),n=="utf8"||n.encoding=="utf8"){let i=this.vault.getAbstractFileByPath(t);return i instanceof _r.TFile?(this.maybeLog("Reuse"),this.vault.read(i)):this.adapter.read(t)}else{if(t.endsWith(this.gitDir+"/index"))return this.plugin.settings.basePath!=this.lastBasePath?(this.clearIndex(),this.lastBasePath=this.plugin.settings.basePath,this.adapter.readBinary(t)):(r=this.index)!=null?r:this.adapter.readBinary(t);let i=this.vault.getAbstractFileByPath(t);return i instanceof _r.TFile?(this.maybeLog("Reuse"),this.vault.readBinary(i)):this.adapter.readBinary(t)}}async writeFile(t,n){if(this.maybeLog("Write: "+t),typeof n=="string"){let r=this.vault.getAbstractFileByPath(t);return r instanceof _r.TFile?this.vault.modify(r,n):this.adapter.write(t,n)}else if(t.endsWith(this.gitDir+"/index"))this.index=n,this.indexmtime=Date.now();else{let r=this.vault.getAbstractFileByPath(t);return r instanceof _r.TFile?this.vault.modifyBinary(r,n):this.adapter.writeBinary(t,n)}}async readdir(t){t==="."&&(t="/");let n=await this.adapter.list(t),r=[...n.files,...n.folders],i;return t!=="/"?i=r.map(a=>(0,_r.normalizePath)(a.substring(t.length))):i=r,i}async mkdir(t){return this.adapter.mkdir(t)}async rmdir(t,n){var r,i;return this.adapter.rmdir(t,(i=(r=n==null?void 0:n.options)==null?void 0:r.recursive)!=null?i:!1)}async stat(t){if(t.endsWith(this.gitDir+"/index")){if(this.index!==void 0&&this.indexctime!=null&&this.indexmtime!=null)return{isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1,size:this.index.length,type:"file",ctimeMs:this.indexctime,mtimeMs:this.indexmtime};{let r=await this.adapter.stat(t);if(r==null)throw{code:"ENOENT"};return this.indexctime=r.ctime,this.indexmtime=r.mtime,{ctimeMs:r.ctime,mtimeMs:r.mtime,size:r.size,type:"file",isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1}}}t==="."&&(t="/");let n=this.vault.getAbstractFileByPath(t);if(this.maybeLog("Stat: "+t),n instanceof _r.TFile)return this.maybeLog("Reuse stat"),{ctimeMs:n.stat.ctime,mtimeMs:n.stat.mtime,size:n.stat.size,type:"file",isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1};{let r=await this.adapter.stat(t);if(r)return{ctimeMs:r.ctime,mtimeMs:r.mtime,size:r.size,type:r.type==="folder"?"directory":r.type,isFile:()=>r.type==="file",isDirectory:()=>r.type==="folder",isSymbolicLink:()=>!1};throw{code:"ENOENT"}}}async unlink(t){return this.adapter.remove(t)}async lstat(t){return this.stat(t)}async readlink(t){throw new Error(`readlink of (${t}) is not implemented.`)}async symlink(t){throw new Error(`symlink of (${t}) is not implemented.`)}async saveAndClear(){this.index!==void 0&&await this.adapter.writeBinary(this.plugin.gitManager.getRelativeVaultPath(this.gitDir+"/index"),this.index,{ctime:this.indexctime,mtime:this.indexmtime}),this.clearIndex()}clearIndex(){this.index=void 0,this.indexctime=void 0,this.indexmtime=void 0}get gitDir(){return this.plugin.settings.gitDir||".git"}maybeLog(t){}};var yn=class extends sa{constructor(n){super(n);this.FILE=0;this.HEAD=1;this.WORKDIR=2;this.STAGE=3;this.status_mapping={"000":" ","003":"AD","020":"??","022":"A ","023":"AM",100:"D ",101:" D",103:"MD",110:"DA",111:" ",113:"MM",120:"DA",121:" M",122:"M ",123:"MM"};this.noticeLength=999999;this.fs=new Sc(this.app.vault,this.plugin)}getRepo(){return{fs:this.fs,dir:this.plugin.settings.basePath,gitdir:this.plug
`);return{message:o[0],author:{name:s.commit.author.name,email:s.commit.author.email},body:o.slice(1).join(`
`),date:new Date(s.commit.committer.timestamp).toDateString(),diff:{changed:0,files:(await this.getFileChangesCount(s.commit.parent.first(),s.oid)).map(l=>({path:l.path,status:l.type,vault_path:this.getRelativeVaultPath(l.path),hash:s.oid,binary:void 0}))},hash:s.oid,refs:[]}}))}updateBasePath(n){return this.getRepo().dir=n,Promise.resolve()}async updateUpstreamBranch(n){let[r,i]=xr(n),a=await this.branchInfo();await this.wrapFS(ie.push({...this.getRepo(),remote:r,remoteRef:i})),await this.setConfig(`branch.${a.current}.merge`,`refs/heads/${i}`)}updateGitPath(n){return Promise.resolve()}async getFileChangesCount(n,r){return this.walkDifference({walkers:[ie.TREE({ref:n}),ie.TREE({ref:r})]})}async walkDifference({walkers:n,dir:r}){return await this.wrapFS(ie.walk({...this.getRepo(),trees:n,map:async function(a,[s,o]){if(!lp(a,r))return null;if(await(s==null?void 0:s.type())==="tree"||await(o==null?void 0:o.type())==="tree")return;let l=await(s==null?void 0:s.oid()),c=await(o==null?void 0:o.oid()),u="equal";if(l!==c&&(u="M"),l===void 0&&(u="A"),c===void 0&&(u="D"),l===void 0&&c===void 0&&(console.log("Something weird happened:"),console.log(s),console.log(o)),u!=="equal")return{path:a,type:u}}}))}async getStagedFiles(n="."){return(await this.walkDifference({walkers:[ie.TREE({ref:"HEAD"}),ie.STAGE()],dir:n})).map(i=>({vault_path:this.getRelativeVaultPath(i.path),filepath:i.path}))}async getUnstagedFiles(n="."){let r,i=window.setTimeout(()=>{r=new ei.Notice("This takes longer: Getting status",this.noticeLength)},2e4);try{let a=this.getRepo(),s=await this.wrapFS(ie.walk({...a,trees:[ie.WORKDIR(),ie.STAGE()],map:async function(o,[l,c]){if(!c&&l&&await ie.isIgnored({...a,filepath:o})||!lp(o,n))return null;let[u,f]=await Promise.all([l&&l.type(),c&&c.type()]),h=[u,f].includes("blob");if((u==="tree"||u==="special")&&!h)return;if(f==="commit")return null;if((f==="tree"||f==="special")&&!h)return;let d=f==="blob"?await c.oid():void 0,p;return u==="blob"&&f!=="blob"?p="42":u==="blob"&&(p=await l.oid()),p?p!==d?{filepath:o,deleted:!1}:null:{filepath:o,deleted:!0}}}));return window.clearTimeout(i),r==null||r.hide(),s}catch(a){throw window.clearTimeout(i),r==null||r.hide(),this.plugin.displayError(a),a}}async getDiffString(n,r=!1,i){let a=this.getRelativeVaultPath(n),s=async(c,[u])=>{if(n==c){let f=await u.oid();return(await ie.readBlob({...this.getRepo(),oid:f})).blob}};if(i){let c=await ys({...this.getRepo(),filepath:n,oid:i}).then(d=>new TextDecoder().decode(d.blob)).catch(d=>{if(!(d instanceof ie.Errors.NotFoundError))throw d}),u=await ie.readCommit({...this.getRepo(),oid:i}),f=await ys({...this.getRepo(),filepath:n,oid:u.commit.parent.first()}).then(d=>new TextDecoder().decode(d.blob)).catch(d=>{if(!(d instanceof ie.Errors.NotFoundError))throw d});return _c(a,f!=null?f:"",c!=null?c:"")}let o=(await ie.walk({...this.getRepo(),trees:[ie.STAGE()],map:s})).first(),l=new TextDecoder().decode(o);if(r){let c=await this.resolveRef("HEAD").then(f=>ys({...this.getRepo(),filepath:n,oid:f})).then(f=>new TextDecoder().decode(f.blob)).catch(f=>{if(!(f instanceof ie.Errors.NotFoundError))throw f});return _c(a,c!=null?c:"",l)}else{let c;return await this.app.vault.adapter.exists(a)?c=await this.app.vault.adapter.read(a):c="",_c(a,l,c)}}async getLastCommitTime(){let n=this.getRepo(),r=await this.resolveRef("HEAD"),a=(await ie.readCommit({...n,oid:r})).commit.committer.timestamp;return new Date(a*1e3)}getFileStatusResult(n){let r=this.status_mapping[`${n[this.HEAD]}${n[this.WORKDIR]}${n[this.STAGE]}`];return{index:r[0]=="?"?"U":r[0],working_dir:r[1]=="?"?"U":r[1],path:n[this.FILE],vault_path:this.getRelativeVaultPath(n[this.FILE])}}async checkAuthorInfo(){let n=await this.getConfig("user.name"),r=await this.getConfig("user.email");if(!n||!r)throw Error("Git author name and email are not set. Please set both fields in the settings.")}showNotice(n,r=!0){if(!this.plugin.settings.disablePopups)return new ei.Notice(n,r?this.noticeLength:void 0)}};function cL(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){r
If turned on, do auto ${i} every ${Us(r.settings.autoSaveInterval)} after stopping file edits.
This also prevents auto ${i} while editing a file. If turned off, it's independent from the last file edit.`).addToggle(u=>u.setValue(r.settings.autoBackupAfterFileChange).onChange(async f=>{r.settings.autoBackupAfterFileChange=f,this.display(),await r.saveSettings(),r.automaticsManager.reload("commit")})),this.mayDisableSetting(s,r.settings.setLastSaveToLastCommit),s=new V.Setting(n).setName(`Auto ${i} after latest commit`).setDesc(`If turned on, sets last auto ${i} timestamp to the latest commit timestamp. This reduces the frequency of auto ${i} when doing manual commits.`).addToggle(u=>u.setValue(r.settings.setLastSaveToLastCommit).onChange(async f=>{r.settings.setLastSaveToLastCommit=f,await r.saveSettings(),r.automaticsManager.reload("commit"),this.display()})),this.mayDisableSetting(s,r.settings.autoBackupAfterFileChange),s=new V.Setting(n).setName("Auto push interval (minutes)").setDesc("Push commits every X minutes. Set to 0 (default) to disable.").addText(u=>u.setValue(String(r.settings.autoPushInterval)).onChange(async f=>{isNaN(Number(f))?new V.Notice("Please specify a valid number."):(r.settings.autoPushInterval=Number(f),await r.saveSettings(),r.automaticsManager.reload("push"),r.settings.autoPushInterval>0?new V.Notice(`Automatic push enabled! Every ${Us(r.settings.autoPushInterval)}.`):r.settings.autoPushInterval<=0&&new V.Notice("Automatic push disabled!"))})),this.mayDisableSetting(s,!r.settings.differentIntervalCommitAndPush),new V.Setting(n).setName("Auto pull interval (minutes)").setDesc("Pull changes every X minutes. Set to 0 (default) to disable.").addText(u=>u.setValue(String(r.settings.autoPullInterval)).onChange(async f=>{isNaN(Number(f))?new V.Notice("Please specify a valid number."):(r.settings.autoPullInterval=Number(f),await r.saveSettings(),r.automaticsManager.reload("pull"),r.settings.autoPullInterval>0?new V.Notice(`Automatic pull enabled! Every ${Us(r.settings.autoPullInterval)}.`):r.settings.autoPullInterval<=0&&new V.Notice("Automatic pull disabled!"))})),new V.Setting(n).setName(`Specify custom commit message on auto ${i}`).setDesc("You will get a pop up to specify your message.").addToggle(u=>u.setValue(r.settings.customMessageOnAutoBackup).onChange(async f=>{r.settings.customMessageOnAutoBackup=f,await r.saveSettings(),this.display()})),s=new V.Setting(n).setName(`Commit message on auto ${i}`).setDesc("Available placeholders: {{date}} (see below), {{hostname}} (see below), {{numFiles}} (number of changed files in the commit) and {{files}} (changed files in commit message).").addTextArea(u=>u.setPlaceholder("vault backup: {{date}}").setValue(r.settings.autoCommitMessage).onChange(async f=>{r.settings.autoCommitMessage=f,await r.saveSettings()})),this.mayDisableSetting(s,r.settings.customMessageOnAutoBackup),new V.Setting(n).setName("Commit message").setHeading(),new V.Setting(n).setName("Commit message on manual commit").setDesc("Available placeholders: {{date}} (see below), {{hostname}} (see below), {{numFiles}} (number of changed files in the commit) and {{files}} (changed files in commit message).").addTextArea(u=>u.setPlaceholder("vault backup: {{date}}").setValue(r.settings.commitMessage?r.settings.commitMessage:"").onChange(async f=>{r.settings.commitMessage=f,await r.saveSettings()}));let c=new V.Setting(n).setName("{{date}} placeholder format").addMomentFormat(u=>u.setDefaultFormat(r.settings.commitDateFormat).setValue(r.settings.commitDateFormat).onChange(async f=>{r.settings.commitDateFormat=f,await r.saveSettings()}));c.descEl.innerHTML=`
Specify custom date format. E.g. "${Hh}. See <a href="https://momentjs.com">Moment.js</a> for more formats.`,new V.Setting(n).setName("{{hostname}} placeholder replacement").setDesc("Specify custom hostname for every device.").addText(u=>{var f;return u.setValue((f=r.localStorage.getHostname())!=null?f:"").onChange(h=>{r.localStorage.setHostname(h)})}),new V.Setting(n).setName("Preview commit message").addButton(u=>u.setButtonText("Preview").onClick(async()=>{let f=await r.gitManager.formatCommitMessage(r.settings.commitMessage);new V.Notice(`${f}`)})),new V.Setting(n).setName("List filenames affected by commit in the commit body").addToggle(u=>u.setValue(r.settings.listChangedFilesInMessageBody).onChange(async f=>{r.settings.listChangedFilesInMessageBody=f,await r.saveSettings()})),new V.Setting(n).setName("Pull").setHeading(),r.gitManager instanceof Le&&new V.Setting(n).setName("Merge strategy").setDesc("Decide how to integrate commits from your remote branch into your local branch.").addDropdown(u=>{let f={merge:"Merge",rebase:"Rebase",reset:"Other sync service (Only updates the HEAD without touching the working directory)"};u.addOptions(f),u.setValue(r.settings.syncMethod),u.onChange(async h=>{r.settings.syncMethod=h,await r.saveSettings()})}),new V.Setting(n).setName("Pull on startup").setDesc("Automatically pull commits when Obsidian starts.").addToggle(u=>u.setValue(r.settings.autoPullOnBoot).onChange(async f=>{r.settings.autoPullOnBoot=f,await r.saveSettings()})),new V.Setting(n).setName("Commit-and-sync").setDesc("Commit-and-sync with default settings means staging everything -> committing -> pulling -> pushing. Ideally this is a single action that you do regularly to keep your local and remote repository in sync.").setHeading(),s=new V.Setting(n).setName("Push on commit-and-sync").setDesc(`Most of the time you want to push after committing. Turning this off turns a commit-and-sync action into commit ${r.settings.pullBeforePush?"and pull ":""}only. It will still be called commit-and-sync.`).addToggle(u=>u.setValue(!r.settings.disablePush).onChange(async f=>{r.settings.disablePush=!f,this.display(),await r.saveSettings()})),new V.Setting(n).setName("Pull on commit-and-sync").setDesc(`On commit-and-sync, pull commits as well. Turning this off turns a commit-and-sync action into commit ${r.settings.disablePush?"":"and push "}only.`).addToggle(u=>u.setValue(r.settings.pullBeforePush).onChange(async f=>{r.settings.pullBeforePush=f,this.display(),await r.saveSettings()})),r.gitManager instanceof Le&&(new V.Setting(n).setName("Line author information").setHeading(),this.addLineAuthorInfoSettings())}new V.Setting(n).setName("History view").setHeading(),new V.Setting(n).setName("Show Author").setDesc("Show the author of the commit in the history view.").addDropdown(c=>{let u={hide:"Hide",full:"Full",initials:"Initials"};c.addOptions(u),c.setValue(r.settings.authorInHistoryView),c.onChange(async f=>{r.settings.authorInHistoryView=f,await r.saveSettings(),await r.refresh()})}),new V.Setting(n).setName("Show Date").setDesc("Show the date of the commit in the history view. The {{date}} placeholder format is used to display the date.").addToggle(c=>c.setValue(r.settings.dateInHistoryView).onChange(async u=>{r.settings.dateInHistoryView=u,await r.saveSettings(),await r.refresh()})),new V.Setting(n).setName("Source control view").setHeading(),new V.Setting(n).setName("Automatically refresh source control view on file changes").setDesc("On slower machines this may cause lags. If so, just disable this option.").addToggle(c=>c.setValue(r.settings.refreshSourceControl).onChange(async u=>{r.settings.refreshSourceControl=u,await r.saveSettings()})),new V.Setting(n).setName("Source control view refresh interval").setDesc("Milliseconds to wait after file change before refreshing the Source Control View.").addText(c=>c.setValue(r.settings.refreshSourceControlTimer.toString()).setPlaceholder("7000").onChange(async u=>{r.settings.refreshSourceControlTimer=Math.max(parseInt(u),500),await r.saveSettings(),r.setRefreshDebouncer(
`)),c.onChange(u=>{r.localStorage.setEnvVars(u.split(`
`))})}),r.gitManager instanceof Le&&new V.Setting(n).setName("Additional PATH environment variable paths").setDesc("Use each line for one path").addTextArea(c=>{c.setValue(r.localStorage.getPATHPaths().join(`
`)),c.onChange(u=>{r.localStorage.setPATHPaths(u.split(`
`))})}),r.gitManager instanceof Le&&new V.Setting(n).setName("Reload with new environment variables").setDesc("Removing previously added environment variables will not take effect until Obsidian is restarted.").addButton(c=>{c.setButtonText("Reload"),c.setCta(),c.onClick(async()=>{await r.gitManager.setGitInstance()})}),new V.Setting(n).setName("Custom base path (Git repository path)").setDesc(`
Sets the relative path to the vault from which the Git binary should be executed.
Mostly used to set the path to the Git repository, which is only required if the Git repository is below the vault root directory. Use "\\" instead of "/" on Windows.
`).addText(c=>{c.setValue(r.settings.basePath),c.setPlaceholder("directory/directory-with-git-repo"),c.onChange(async u=>{r.settings.basePath=u,await r.saveSettings(),r.gitManager.updateBasePath(u||"").catch(f=>r.displayError(f))})}),new V.Setting(n).setName("Custom Git directory path (Instead of '.git')").setDesc('Requires restart of Obsidian to take effect. Use "\\" instead of "/" on Windows.').addText(c=>{c.setValue(r.settings.gitDir),c.setPlaceholder(".git"),c.onChange(async u=>{r.settings.gitDir=u,await r.saveSettings()})}),new V.Setting(n).setName("Disable on this device").setDesc("Disables the plugin on this device. This setting is not synced.").addToggle(c=>c.setValue(r.localStorage.getPluginDisabled()).onChange(u=>{r.localStorage.setPluginDisabled(u),u?r.unloadPlugin():r.init({fromReload:!0}).catch(f=>r.displayError(f)),new V.Notice("Obsidian must be restarted for the changes to take affect.")})),new V.Setting(n).setName("Support").setHeading(),new V.Setting(n).setName("Donate").setDesc("If you like this Plugin, consider donating to support continued development.").addButton(c=>{c.buttonEl.outerHTML="<a href='https://ko-fi.com/F1F195IQ5' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi3.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>"});let o=n.createDiv();o.setAttr("align","center"),o.setAttr("style","margin: var(--size-4-2)");let l=o.createEl("button");if(l.setText("Copy Debug Information"),l.onclick=async()=>{await window.navigator.clipboard.writeText(JSON.stringify({settings:this.plugin.settings,pluginVersion:this.plugin.manifest.version},null,4)),new V.Notice("Debug information copied to clipboard. May contain sensitive information!")},V.Platform.isDesktopApp){let c=n.createDiv();c.setAttr("align","center"),c.setText(`Debugging and logging:
You can always see the logs of this and every other plugin by opening the console with`);let u=n.createDiv();u.setAttr("align","center"),u.addClass("obsidian-git-shortcuts"),V.Platform.isMacOS===!0?u.createEl("kbd",{text:"CMD (\u2318) + OPTION (\u2325) + I"}):u.createEl("kbd",{text:"CTRL + SHIFT + I"})}}mayDisableSetting(n,r){r&&(n.setDisabled(r),n.setClass("obsidian-git-disabled"))}configureLineAuthorShowStatus(n){this.settings.lineAuthor.show=n,this.plugin.saveSettings(),n?this.plugin.lineAuthoringFeature.activateFeature():this.plugin.lineAuthoringFeature.deactivateFeature()}async lineAuthorSettingHandler(n,r){this.settings.lineAuthor[n]=r,await this.plugin.saveSettings(),this.plugin.lineAuthoringFeature.refreshLineAuthorViews()}beforeSaveSettings(){let n=this.settings.lineAuthor;n.authorDisplay!=="hide"&&(n.lastShownAuthorDisplay=n.authorDisplay),n.dateTimeFormatOptions!=="hide"&&(n.lastShownDateTimeFormatOptions=n.dateTimeFormatOptions)}addLineAuthorInfoSettings(){let n=new V.Setting(this.containerEl).setName("Show commit authoring information next to each line");if(this.plugin.lineAuthoringFeature.isAvailableOnCurrentPlatform()||n.setDesc("Only available on desktop currently.").setDisabled(!0),n.descEl.innerHTML=`
<a href="${pL}">Feature guide and quick examples</a></br>
The commit hash, author name and authoring date can all be individually toggled.</br>Hide everything, to only show the age-colored sidebar.`,n.addToggle(r=>r.setValue(this.settings.lineAuthor.show).onChange(i=>{this.configureLineAuthorShowStatus(i),this.display()})),this.settings.lineAuthor.show){let r=new V.Setting(this.containerEl).setName("Follow movement and copies across files and commits").setDesc("").addDropdown(a=>{a.addOptions({inactive:"Do not follow (default)","same-commit":"Follow within same commit","all-commits":"Follow within all commits (maybe slow)"}),a.setValue(this.settings.lineAuthor.followMovement),a.onChange(s=>this.lineAuthorSettingHandler("followMovement",s))});if(r.descEl.innerHTML=`
By default (deactivated), each line only shows the newest commit where it was changed.
<br/>
With <i>same commit</i>, cut-copy-paste-ing of text is followed within the same commit and the original commit of authoring will be shown.
<br/>
With <i>all commits</i>, cut-copy-paste-ing text inbetween multiple commits will be detected.
<br/>
It uses <a href="https://git-scm.com/docs/git-blame">git-blame</a> and
for matches (at least ${Al} characters) within the same (or all) commit(s), <em>the originating</em> commit's information is shown.`,new V.Setting(this.containerEl).setName("Show commit hash").addToggle(a=>{a.setValue(this.settings.lineAuthor.showCommitHash),a.onChange(s=>this.lineAuthorSettingHandler("showCommitHash",s))}),new V.Setting(this.containerEl).setName("Author name display").setDesc("If and how the author is displayed").addDropdown(a=>{let s={hide:"Hide",initials:"Initials (default)","first name":"First name","last name":"Last name",full:"Full name"};a.addOptions(s),a.setValue(this.settings.lineAuthor.authorDisplay),a.onChange(async o=>this.lineAuthorSettingHandler("authorDisplay",o))}),new V.Setting(this.containerEl).setName("Authoring date display").setDesc("If and how the date and time of authoring the line is displayed").addDropdown(a=>{let s={hide:"Hide",date:"Date (default)",datetime:"Date and time","natural language":"Natural language",custom:"Custom"};a.addOptions(s),a.setValue(this.settings.lineAuthor.dateTimeFormatOptions),a.onChange(async o=>{await this.lineAuthorSettingHandler("dateTimeFormatOptions",o),this.display()})}),this.settings.lineAuthor.dateTimeFormatOptions==="custom"){let a=new V.Setting(this.containerEl);a.setName("Custom authoring date format").addText(s=>{s.setValue(this.settings.lineAuthor.dateTimeFormatCustomString),s.setPlaceholder("YYYY-MM-DD HH:mm"),s.onChange(async o=>{await this.lineAuthorSettingHandler("dateTimeFormatCustomString",o),a.descEl.innerHTML=this.previewCustomDateTimeDescriptionHtml(o)})}),a.descEl.innerHTML=this.previewCustomDateTimeDescriptionHtml(this.settings.lineAuthor.dateTimeFormatCustomString)}new V.Setting(this.containerEl).setName("Authoring date display timezone").addDropdown(a=>{let s={"viewer-local":"My local (default)","author-local":"Author's local",utc0000:"UTC+0000/Z"};a.addOptions(s),a.setValue(this.settings.lineAuthor.dateTimeTimezone),a.onChange(async o=>this.lineAuthorSettingHandler("dateTimeTimezone",o))}).descEl.innerHTML=`
The time-zone in which the authoring date should be shown.
Either your local time-zone (default),
the author's time-zone during commit creation or
<a href="https://en.wikipedia.org/wiki/UTC%C2%B100:00">UTC\xB100:00</a>.
`;let i=new V.Setting(this.containerEl).setName("Oldest age in coloring");i.descEl.innerHTML=this.previewOldestAgeDescriptionHtml(this.settings.lineAuthor.coloringMaxAge)[0],i.addText(a=>{a.setPlaceholder("1y"),a.setValue(this.settings.lineAuthor.coloringMaxAge),a.onChange(async s=>{let[o,l]=this.previewOldestAgeDescriptionHtml(s);i.descEl.innerHTML=o,l&&(await this.lineAuthorSettingHandler("coloringMaxAge",s),this.refreshColorSettingsName("oldest"))})}),this.createColorSetting("newest"),this.createColorSetting("oldest"),new V.Setting(this.containerEl).setName("Text color").addText(a=>{a.setValue(this.settings.lineAuthor.textColorCss),a.onChange(async s=>{await this.lineAuthorSettingHandler("textColorCss",s)})}).descEl.innerHTML=`
The CSS color of the gutter text.<br/>
It is higly recommended to use
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties">
CSS variables</a>
defined by themes
(e.g. <pre style="display:inline">var(--text-muted)</pre> or
<pre style="display:inline">var(--text-on-accent)</pre>,
because they automatically adapt to theme changes.<br/>
2022-09-04 12:54:22 +00:00
2024-12-09 19:19:31 +00:00
See: <a href="https://github.com/obsidian-community/obsidian-theme-template/blob/main/obsidian.css">
List of available CSS variables in Obsidian
<a/>
`,new V.Setting(this.containerEl).setName("Ignore whitespace and newlines in changes").addToggle(a=>{a.setValue(this.settings.lineAuthor.ignoreWhitespace),a.onChange(s=>this.lineAuthorSettingHandler("ignoreWhitespace",s))}).descEl.innerHTML=`
Whitespace and newlines are interpreted as
part of the document and in changes
by default (hence not ignored).
This makes the last line being shown as 'changed'
when a new subsequent line is added,
even if the previously last line's text is the same.
<br>
If you don't care about purely-whitespace changes
(e.g. list nesting / quote indentation changes),
then activating this will provide more meaningful change detection.
`}}createColorSetting(n){let r=new V.Setting(this.containerEl).setName("").addText(i=>{let a=Sp(n,this.settings.lineAuthor),s=Sp(n,Pn.lineAuthor);i.setPlaceholder(cp(s)),i.setValue(cp(a)),i.onChange(async o=>{let l=OS(o);if(l!==void 0){let c=n==="newest"?"colorNew":"colorOld";await this.lineAuthorSettingHandler(c,l)}this.refreshColorSettingsDesc(n,l)})});this.lineAuthorColorSettings.set(n,r),this.refreshColorSettingsName(n),this.refreshColorSettingsDesc(n,Sp(n,this.settings.lineAuthor))}refreshColorSettingsName(n){let r=this.lineAuthorColorSettings.get(n);if(r){let i=n==="oldest"?`oldest (${this.settings.lineAuthor.coloringMaxAge} or older)`:"newest";r.nameEl.innerText=`Color for ${i} commits`}}refreshColorSettingsDesc(n,r){let i=this.lineAuthorColorSettings.get(n);i&&(i.descEl.innerHTML=this.colorSettingPreviewDescHtml(n,this.settings.lineAuthor,r!==void 0))}colorSettingPreviewDescHtml(n,r,i){let a=i?Ep(n,r):"rgba(127,127,127,0.3)",s=V.moment.unix(V.moment.now()/1e3).format("YYYY-MM-DD"),o=i?`abcdef Author Name ${s}`:"invalid color";return`Supports 'rgb(r,g,b)', 'hsl(h,s,l)', hex (#) and
named colors (e.g. 'black', 'purple'). Color preview: ${`<div
class="line-author-settings-preview"
style="background-color: ${a}; width: 30ch;"
>${o}</div>`}`}previewCustomDateTimeDescriptionHtml(n){let r=(0,V.moment)().format(n);return`<a href="${dL}">Format string</a> to display the authoring date.</br>Currently: ${r}`}previewOldestAgeDescriptionHtml(n){let r=Ac(n);return[`The oldest age in the line author coloring. Everything older will have the same color.
</br>Smallest valid age is "1d". Currently: ${r!==void 0?`${r.asDays()} days`:"invalid!"}`,r]}};function Sp(e,t){return e==="oldest"?t.colorOld:t.colorNew}function Ac(e){let t=V.moment.duration("P"+e.toUpperCase());return t.isValid()&&t.asDays()&&t.asDays()>=1?t:void 0}function JS(e,t,n){if(!(e===void 0||t===void 0||n===void 0))return`head${e}-obj${t}-path${n}`}var QS=kc.Annotation.define();function eE(e,t,n){return n.update({annotations:QS.of({key:e,la:t,lineOffsetsFromUnsavedChanges:new Map})})}function mL(e){return e.annotation(QS)}var la=kc.StateField.define({create:e=>{},update:(e,t)=>{var n;return(n=mL(t))!=null?n:gL(t,e)},compare:(e,t)=>(e==null?void 0:e.key)===(t==null?void 0:t.key)});function Tc(e){var a;let t=KS.sha256.create();if(!e)return t;let{la:n,key:r,lineOffsetsFromUnsavedChanges:i}=e;t.update(n==="untracked"?"t":"f"),t.update(r);for(let[s,o]of(a=i.entries())!=null?a:[])t.update([s,o]);return t}var an={get:void 0,save:void 0};function tE(e,t){an.get=e,an.save=t}function Cc(e){var t,n;return(n=(t=Ac(e.coloringMaxAge))==null?void 0:t.asDays())!=null?n:Ac(Pn.lineAuthor.coloringMaxAge).asDays()}function gL(e,t){if(t)return e.changes.empty||e.changes.iterChanges((n,r,i,a)=>{var p;let s=e.startState.doc,{newDoc:o}=e,l=s.lineAt(n).number,c=s.lineAt(r).number,u=o.lineAt(i).number,f=o.lineAt(a).number,h=c-l+1,d=f-u+1;for(let g=u;g<=f;g++){let m=(p=t.lineOffsetsFromUnsavedChanges.get(g))!=null?p:0,w=f===g,b=d-h;w&&(m+=b),t.lineOffsetsFromUnsavedChanges.set(g,m)}}),t}var Ap=class{constructor(t){this.state=t;this.subscribeMe()}notifyLineAuthoring(t,n){if(this.view===void 0){console.warn(`Git: View is not defined for editor cache key. Unforeseen situation. id: ${t}`);return}let r=this.view.state,i=eE(t,n,r);this.view.dispatch(i)}updateToNewState(t){let n=this.lastSeenPath&&this.filepath!=this.lastSeenPath;return this.state=t,n&&(this.unsubscribeMe(this.lastSeenPath),this.subscribeMe()),this}removeIfStale(){this.view.destroyed&&this.unsubscribeMe(this.lastSeenPath)}subscribeMe(){this.filepath!==void 0&&(oa.ifFilepathDefinedTransformSubscribers(this.filepath,t=>t.add(this)),this.lastSeenPath=this.filepath)}unsubscribeMe(t){oa.ifFilepathDefinedTransformSubscribers(t,n=>n.delete(this))}get filepath(){var t,n;return(n=(t=this.state.field(Fc.editorInfoField))==null?void 0:t.file)==null?void 0:n.path}get view(){return this.state.field(Fc.editorEditorField)}},rE=nE.StateField.define({create:e=>new Ap(e),update:(e,t)=>e.updateToNewState(t.state),compare:(e,t)=>e===t});v();function iE(){ca=void 0,kp=[],Pc=0,Oc.clear(),Ic.clear(),ua.clear()}var ca,Mc=()=>ca;function aE(e,t){var i;let n=t.length;if(n<((i=ca==null?void 0:ca.length)!=null?i:0))return;ca={gutter:e,length:n,text:t};let r=an.get();n!==r.gutterSpacingFallbackLength&&(r.gutterSpacingFallbackLength=n,an.save(r))}var kp=[],yL=15,Pc=0;function sE(e){kp[Pc]=e,Pc=(Pc+1)%yL}function oE(){return RS(kp)}var Oc=new Map,Ic=new Map,ua=new Set;v();var bE=require("@codemirror/state"),xE=require("@codemirror/view");v();var Pp=require("@codemirror/view"),gE=Xe(pp()),jc=require("obsidian");v();v();var Rc={x:-10,y:-10};function lE(){Rc.x===-10&&window.addEventListener("mousedown",e=>{Rc.x=e.clientX,Rc.y=e.clientY})}function cE(){for(let e of ua)if(vL(e,Rc))return e}function vL(e,t){let{x:n,y:r,width:i,height:a}=e.getBoundingClientRect();return n<=t.x&&t.x<=n+i&&r<=t.y&&t.y<=r+a}v();var Ws={};var uE="data-commit";function fE(e,t,n){if(t.hasFocus())return;let r=cE();if(!r)return;let i=bL(r);i&&(!i.isZeroCommit&&!i.isWaitingGutter&&wL(i,e),Tp("showCommitHash",e),Tp("authorDisplay",e),Tp("dateTimeFormatOptions",e))}function wL(e,t){t.addItem(n=>n.setTitle("Copy commit hash").setIcon("copy").setSection("obs-git-line-author-copy").onClick(r=>navigator.clipboard.writeText(e.hash)))}function Tp(e,t){var l,c;let n,r,i=Ws.plugin.settings.lineAuthor,a=i[e],s=typeof a=="boolean"?a:a!=="hide",o=Pn.lineAuthor[e];if(e==="showCommitHash")n="Show commit hash",r=a;else if(e==="authorDisplay"){let u=(l=i.lastShownAuthorDisplay)!=null?l:o;n="Show author "+(s?a:u),r=s?"hide":u}else if(e==="dat
(${this.unPushedCommits} unpushed commits)`)}else this.statusBarEl.ariaLabel=n?"Git is offline":"Git is ready";n?(0,sn.setIcon)(this.iconEl,"globe"):(0,sn.setIcon)(this.iconEl,"check"),this.plugin.settings.changedFilesInStatusBar&&this.plugin.cachedStatus&&this.textEl.setText(this.plugin.cachedStatus.changed.length.toString()),this.statusBarEl.addClass(this.base+"idle")}async refreshCommitTimestamp(){this.lastCommitTimestamp=await this.plugin.gitManager.getLastCommitTime(),this.unPushedCommits=await this.plugin.gitManager.getUnpushedCommits()}remove(){this.statusBarEl.remove()}};v();var Uc=require("obsidian"),Hc=class extends Uc.SuggestModal{constructor(n){super(n.app);this.plugin=n;this.resolve=null;this.setPlaceholder("Type your message and select optional the version with the added date.")}openAndGetResult(){return new Promise(n=>{this.resolve=n,this.open()})}onClose(){new Promise(n=>setTimeout(n,10)).then(()=>{this.resolve&&this.resolve(void 0)})}getSuggestions(n){let r=(0,Uc.moment)().format(this.plugin.settings.commitDateFormat);return n==""&&(n="..."),[n,`${r}: ${n}`,`${n}: ${r}`]}renderSuggestion(n,r){r.innerText=n}onChooseSuggestion(n,r){this.resolve&&this.resolve(n)}};v();var AE=require("obsidian"),qs=class{constructor(t){this.plugin=t}saveLastAuto(t,n){n==="backup"?this.plugin.localStorage.setLastAutoBackup(t.toString()):n==="pull"?this.plugin.localStorage.setLastAutoPull(t.toString()):n==="push"&&this.plugin.localStorage.setLastAutoPush(t.toString())}loadLastAuto(){var t,n,r;return{backup:new Date((t=this.plugin.localStorage.getLastAutoBackup())!=null?t:""),pull:new Date((n=this.plugin.localStorage.getLastAutoPull())!=null?n:""),push:new Date((r=this.plugin.localStorage.getLastAutoPush())!=null?r:"")}}async init(){await this.setUpAutoCommitAndSync();let t=this.loadLastAuto();if(this.plugin.settings.differentIntervalCommitAndPush&&this.plugin.settings.autoPushInterval>0){let n=new Date,r=this.plugin.settings.autoPushInterval-Math.round((n.getTime()-t.push.getTime())/1e3/60);this.startAutoPush(r<=0?0:r)}if(this.plugin.settings.autoPullInterval>0){let n=new Date,r=this.plugin.settings.autoPullInterval-Math.round((n.getTime()-t.pull.getTime())/1e3/60);this.startAutoPull(r<=0?0:r)}}unload(){this.clearAutoPull(),this.clearAutoPush(),this.clearAutoCommitAndSync()}reload(...t){t.contains("commit")&&(this.clearAutoCommitAndSync(),this.plugin.settings.autoSaveInterval>0&&this.startAutoCommitAndSync(this.plugin.settings.autoSaveInterval)),t.contains("push")&&(this.clearAutoPush(),this.plugin.settings.differentIntervalCommitAndPush&&this.plugin.settings.autoPushInterval>0&&this.startAutoPush(this.plugin.settings.autoPushInterval)),t.contains("pull")&&(this.clearAutoPull(),this.plugin.settings.autoPullInterval>0&&this.startAutoPull(this.plugin.settings.autoPullInterval))}async setUpAutoCommitAndSync(){if(this.plugin.settings.setLastSaveToLastCommit){this.clearAutoCommitAndSync();let t=await this.plugin.gitManager.getLastCommitTime();t&&this.plugin.localStorage.setLastAutoBackup(t.toString())}if(!this.timeoutIDCommitAndSync&&!this.plugin.autoCommitDebouncer){let t=this.loadLastAuto();if(this.plugin.settings.autoSaveInterval>0){let n=new Date,r=this.plugin.settings.autoSaveInterval-Math.round((n.getTime()-t.backup.getTime())/1e3/60);this.startAutoCommitAndSync(r<=0?0:r)}}}startAutoCommitAndSync(t){let n=(t!=null?t:this.plugin.settings.autoSaveInterval)*6e4;this.plugin.settings.autoBackupAfterFileChange?t===0?this.doAutoCommitAndSync():this.plugin.autoCommitDebouncer=(0,AE.debounce)(()=>this.doAutoCommitAndSync(),n,!0):(n>2147483647&&(n=2147483647),this.timeoutIDCommitAndSync=window.setTimeout(()=>this.doAutoCommitAndSync(),n))}doAutoCommitAndSync(){this.plugin.promiseQueue.addTask(()=>this.plugin.settings.differentIntervalCommitAndPush?this.plugin.commit({fromAuto:!0}):this.plugin.commitAndSync(!0)),this.saveLastAuto(new Date,"backup"),this.startAutoCommitAndSync()}startAutoPull(t){let n=(t!=null?t:this.plugin.settings.autoPullInterval)*6e4;n>2147483647&&(n=2147483647),this.timeoutIDPull=window.setTimeout(()=>{this.plugin.
`).split(`
`);function Y(){i!==null&&r!==null&&(r.blocks.push(i),i=null)}function le(){r!==null&&(!r.oldName&&l!==null&&(r.oldName=l),!r.newName&&c!==null&&(r.newName=c),r.newName&&(n.push(r),r=null)),l=null,c=null}function he(){Y(),le(),r={blocks:[],deletedLines:0,addedLines:0}}function ae($){Y();let z;r!==null&&((z=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec($))?(r.isCombined=!1,a=parseInt(z[1],10),o=parseInt(z[2],10)):(z=/^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec($))?(r.isCombined=!0,a=parseInt(z[1],10),s=parseInt(z[2],10),o=parseInt(z[3],10)):($.startsWith(h)&&console.error("Failed to parse lines, starting in 0!"),a=0,o=0,r.isCombined=!1)),i={lines:[],oldStartLine:a,oldStartLine2:s,newStartLine:o,header:$}}function Pe($){if(r===null||i===null||a===null||o===null)return;let z={content:$},D=r.isCombined?["+ "," +","++"]:["+"],se=r.isCombined?["- "," -","--"]:["-"];BE($,D)?(r.addedLines++,z.type=Ue.INSERT,z.oldNumber=void 0,z.newNumber=o++):BE($,se)?(r.deletedLines++,z.type=Ue.DELETE,z.oldNumber=a++,z.newNumber=void 0):(z.type=Ue.CONTEXT,z.oldNumber=a++,z.newNumber=o++),i.lines.push(z)}function de($,z){let D=z;for(;D<j.length-3;){if($.startsWith("diff"))return!1;if(j[D].startsWith(u)&&j[D+1].startsWith(f)&&j[D+2].startsWith(h))return!0;D++}return!1}return j.forEach(($,z)=>{if(!$||$.startsWith("*"))return;let D,se=j[z-1],Se=j[z+1],gt=j[z+2];if($.startsWith("diff --git")||$.startsWith("diff --combined")){if(he(),(D=/^diff --git "?([a-ciow]\/.+)"? "?([a-ciow]\/.+)"?/.exec($))&&(l=Sr(D[1],void 0,t.dstPrefix),c=Sr(D[2],void 0,t.srcPrefix)),r===null)throw new Error("Where is my file !!!");r.isGitDiff=!0;return}if($.startsWith("Binary files")&&!(r!=null&&r.isGitDiff)){if(he(),(D=/^Binary files "?([a-ciow]\/.+)"? and "?([a-ciow]\/.+)"? differ/.exec($))&&(l=Sr(D[1],void 0,t.dstPrefix),c=Sr(D[2],void 0,t.srcPrefix)),r===null)throw new Error("Where is my file !!!");r.isBinary=!0;return}if((!r||!r.isGitDiff&&r&&$.startsWith(u)&&Se.startsWith(f)&&gt.startsWith(h))&&he(),r!=null&&r.isTooBig)return;if(r&&(typeof t.diffMaxChanges=="number"&&r.addedLines+r.deletedLines>t.diffMaxChanges||typeof t.diffMaxLineLength=="number"&&$.length>t.diffMaxLineLength)){r.isTooBig=!0,r.addedLines=0,r.deletedLines=0,r.blocks=[],i=null;let ot=typeof t.diffTooBigMessage=="function"?t.diffTooBigMessage(n.length):"Diff too big to be displayed";ae(ot);return}if($.startsWith(u)&&Se.startsWith(f)||$.startsWith(f)&&se.startsWith(u)){if(r&&!r.oldName&&$.startsWith("--- ")&&(D=RL($,t.srcPrefix))){r.oldName=D,r.language=DE(r.oldName,r.language);return}if(r&&!r.newName&&$.startsWith("+++ ")&&(D=LL($,t.dstPrefix))){r.newName=D,r.language=DE(r.newName,r.language);return}}if(r&&($.startsWith(h)||r.isGitDiff&&r.oldName&&r.newName&&!i)){ae($);return}if(i&&($.startsWith("+")||$.startsWith("-")||$.startsWith(" "))){Pe($);return}let be=!de($,z);if(r===null)throw new Error("Where is my file !!!");(D=d.exec($))?r.oldMode=D[1]:(D=p.exec($))?r.newMode=D[1]:(D=g.exec($))?(r.deletedFileMode=D[1],r.isDeleted=!0):(D=m.exec($))?(r.newFileMode=D[1],r.isNew=!0):(D=w.exec($))?(be&&(r.oldName=D[1]),r.isCopy=!0):(D=b.exec($))?(be&&(r.newName=D[1]),r.isCopy=!0):(D=S.exec($))?(be&&(r.oldName=D[1]),r.isRename=!0):(D=A.exec($))?(be&&(r.newName=D[1]),r.isRename=!0):(D=E.exec($))?(r.isBinary=!0,r.oldName=Sr(D[1],void 0,t.srcPrefix),r.newName=Sr(D[2],void 0,t.dstPrefix),ae("Binary file")):_.test($)?(r.isBinary=!0,ae($)):(D=x.exec($))?r.unchangedPercentage=parseInt(D[1],10):(D=k.exec($))?r.changedPercentage=parseInt(D[1],10):(D=y.exec($))?(r.checksumBefore=D[1],r.checksumAfter=D[2],D[3]&&(r.mode=D[3])):(D=C.exec($))?(r.checksumBefore=[D[2],D[3]],r.checksumAfter=D[1]):(D=P.exec($))?(r.oldMode=[D[2],D[3]],r.newMode=D[1]):(D=L.exec($))?(r.newFileMode=D[1],r.isNew=!0):(D=N.exec($))&&(r.deletedFileMode=D[1],r.isDeleted=!0)}),Y(),le(),n}v();v();v();function Zn(){}Zn.prototype={diff:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=r.callback;typeof r=="function"&&(i=r,r={}),this.options=r;var a=this;function s(g){return i?(setTimeout(function(){i(void
`);return this.hoganUtils.render(qE,"wrapper",{colorScheme:ma(this.config.colorScheme),filesNumber:t.length,files:n})}};v();var Hp=Object.assign(Object.assign({},ii),{renderNothingWhenEmpty:!1,matchingMaxComparisons:2500,maxLineSizeInBlockForComparison:200}),Ks="generic",XE="line-by-line",KL="icon",JL="tag",Js=class{constructor(t,n={}){this.hoganUtils=t,this.config=Object.assign(Object.assign({},Hp),n)}render(t){let n=t.map(r=>{let i;return r.blocks.length?i=this.generateFileHtml(r):i=this.generateEmptyDiff(),this.makeFileDiffHtml(r,i)}).join(`
`);return this.hoganUtils.render(Ks,"wrapper",{colorScheme:ma(this.config.colorScheme),content:n})}makeFileDiffHtml(t,n){if(this.config.renderNothingWhenEmpty&&Array.isArray(t.blocks)&&t.blocks.length===0)return"";let r=this.hoganUtils.template(XE,"file-diff"),i=this.hoganUtils.template(Ks,"file-path"),a=this.hoganUtils.template(KL,"file"),s=this.hoganUtils.template(JL,ya(t));return r.render({file:t,fileHtmlId:ga(t),diffs:n,filePath:i.render({fileDiffName:ai(t)},{fileIcon:a,fileTag:s})})}generateEmptyDiff(){return this.hoganUtils.render(Ks,"empty-diff",{contentClass:"d2h-code-line",CSSLineClass:mt})}generateFileHtml(t){let n=da(ha(r=>on(r.content,t.isCombined).content));return t.blocks.map(r=>{let i=this.hoganUtils.render(Ks,"block-header",{CSSLineClass:mt,blockHeader:t.isTooBig?r.header:Er(r.header),lineClass:"d2h-code-linenumber",contentClass:"d2h-code-line"});return this.applyLineGroupping(r).forEach(([a,s,o])=>{if(s.length&&o.length&&!a.length)this.applyRematchMatching(s,o,n).map(([l,c])=>{let{left:u,right:f}=this.processChangedLines(t,t.isCombined,l,c);i+=u,i+=f});else if(a.length)a.forEach(l=>{let{prefix:c,content:u}=on(l.content,t.isCombined);i+=this.generateSingleLineHtml(t,{type:mt.CONTEXT,prefix:c,content:u,oldNumber:l.oldNumber,newNumber:l.newNumber})});else if(s.length||o.length){let{left:l,right:c}=this.processChangedLines(t,t.isCombined,s,o);i+=l,i+=c}else console.error("Unknown state reached while processing groups of lines",a,s,o)}),i}).join(`
`)}applyLineGroupping(t){let n=[],r=[],i=[];for(let a=0;a<t.lines.length;a++){let s=t.lines[a];(s.type!==Ue.INSERT&&i.length||s.type===Ue.CONTEXT&&r.length>0)&&(n.push([[],r,i]),r=[],i=[]),s.type===Ue.CONTEXT?n.push([[s],[],[]]):s.type===Ue.INSERT&&r.length===0?n.push([[],[],[s]]):s.type===Ue.INSERT&&r.length>0?i.push(s):s.type===Ue.DELETE&&r.push(s)}return(r.length||i.length)&&(n.push([[],r,i]),r=[],i=[]),n}applyRematchMatching(t,n,r){let i=t.length*n.length,a=Math.max.apply(null,[0].concat(t.concat(n).map(o=>o.content.length)));return i<this.config.matchingMaxComparisons&&a<this.config.maxLineSizeInBlockForComparison&&(this.config.matching==="lines"||this.config.matching==="words")?r(t,n):[[t,n]]}processChangedLines(t,n,r,i){let a={right:"",left:""},s=Math.max(r.length,i.length);for(let o=0;o<s;o++){let l=r[o],c=i[o],u=l!==void 0&&c!==void 0?qc(l.content,c.content,n,this.config):void 0,f=l!==void 0&&l.oldNumber!==void 0?Object.assign(Object.assign({},u!==void 0?{prefix:u.oldLine.prefix,content:u.oldLine.content,type:mt.DELETE_CHANGES}:Object.assign(Object.assign({},on(l.content,n)),{type:pa(l.type)})),{oldNumber:l.oldNumber,newNumber:l.newNumber}):void 0,h=c!==void 0&&c.newNumber!==void 0?Object.assign(Object.assign({},u!==void 0?{prefix:u.newLine.prefix,content:u.newLine.content,type:mt.INSERT_CHANGES}:Object.assign(Object.assign({},on(c.content,n)),{type:pa(c.type)})),{oldNumber:c.oldNumber,newNumber:c.newNumber}):void 0,{left:d,right:p}=this.generateLineHtml(t,f,h);a.left+=d,a.right+=p}return a}generateLineHtml(t,n,r){return{left:this.generateSingleLineHtml(t,n),right:this.generateSingleLineHtml(t,r)}}generateSingleLineHtml(t,n){if(n===void 0)return"";let r=this.hoganUtils.render(XE,"numbers",{oldNumber:n.oldNumber||"",newNumber:n.newNumber||""});return this.hoganUtils.render(Ks,"line",{type:n.type,lineClass:"d2h-code-linenumber",contentClass:"d2h-code-line",prefix:n.prefix===" "?"&nbsp;":n.prefix,content:n.content,lineNumber:r,line:n,file:t})}};v();var Up=Object.assign(Object.assign({},ii),{renderNothingWhenEmpty:!1,matchingMaxComparisons:2500,maxLineSizeInBlockForComparison:200}),Qs="generic",QL="side-by-side",ej="icon",tj="tag",eo=class{constructor(t,n={}){this.hoganUtils=t,this.config=Object.assign(Object.assign({},Up),n)}render(t){let n=t.map(r=>{let i;return r.blocks.length?i=this.generateFileHtml(r):i=this.generateEmptyDiff(),this.makeFileDiffHtml(r,i)}).join(`
`);return this.hoganUtils.render(Qs,"wrapper",{colorScheme:ma(this.config.colorScheme),content:n})}makeFileDiffHtml(t,n){if(this.config.renderNothingWhenEmpty&&Array.isArray(t.blocks)&&t.blocks.length===0)return"";let r=this.hoganUtils.template(QL,"file-diff"),i=this.hoganUtils.template(Qs,"file-path"),a=this.hoganUtils.template(ej,"file"),s=this.hoganUtils.template(tj,ya(t));return r.render({file:t,fileHtmlId:ga(t),diffs:n,filePath:i.render({fileDiffName:ai(t)},{fileIcon:a,fileTag:s})})}generateEmptyDiff(){return{right:"",left:this.hoganUtils.render(Qs,"empty-diff",{contentClass:"d2h-code-side-line",CSSLineClass:mt})}}generateFileHtml(t){let n=da(ha(r=>on(r.content,t.isCombined).content));return t.blocks.map(r=>{let i={left:this.makeHeaderHtml(r.header,t),right:this.makeHeaderHtml("")};return this.applyLineGroupping(r).forEach(([a,s,o])=>{if(s.length&&o.length&&!a.length)this.applyRematchMatching(s,o,n).map(([l,c])=>{let{left:u,right:f}=this.processChangedLines(t.isCombined,l,c);i.left+=u,i.right+=f});else if(a.length)a.forEach(l=>{let{prefix:c,content:u}=on(l.content,t.isCombined),{left:f,right:h}=this.generateLineHtml({type:mt.CONTEXT,prefix:c,content:u,number:l.oldNumber},{type:mt.CONTEXT,prefix:c,content:u,number:l.newNumber});i.left+=f,i.right+=h});else if(s.length||o.length){let{left:l,right:c}=this.processChangedLines(t.isCombined,s,o);i.left+=l,i.right+=c}else console.error("Unknown state reached while processing groups of lines",a,s,o)}),i}).reduce((r,i)=>({left:r.left+i.left,right:r.right+i.right}),{left:"",right:""})}applyLineGroupping(t){let n=[],r=[],i=[];for(let a=0;a<t.lines.length;a++){let s=t.lines[a];(s.type!==Ue.INSERT&&i.length||s.type===Ue.CONTEXT&&r.length>0)&&(n.push([[],r,i]),r=[],i=[]),s.type===Ue.CONTEXT?n.push([[s],[],[]]):s.type===Ue.INSERT&&r.length===0?n.push([[],[],[s]]):s.type===Ue.INSERT&&r.length>0?i.push(s):s.type===Ue.DELETE&&r.push(s)}return(r.length||i.length)&&(n.push([[],r,i]),r=[],i=[]),n}applyRematchMatching(t,n,r){let i=t.length*n.length,a=Math.max.apply(null,[0].concat(t.concat(n).map(o=>o.content.length)));return i<this.config.matchingMaxComparisons&&a<this.config.maxLineSizeInBlockForComparison&&(this.config.matching==="lines"||this.config.matching==="words")?r(t,n):[[t,n]]}makeHeaderHtml(t,n){return this.hoganUtils.render(Qs,"block-header",{CSSLineClass:mt,blockHeader:n!=null&&n.isTooBig?t:Er(t),lineClass:"d2h-code-side-linenumber",contentClass:"d2h-code-side-line"})}processChangedLines(t,n,r){let i={right:"",left:""},a=Math.max(n.length,r.length);for(let s=0;s<a;s++){let o=n[s],l=r[s],c=o!==void 0&&l!==void 0?qc(o.content,l.content,t,this.config):void 0,u=o!==void 0&&o.oldNumber!==void 0?Object.assign(Object.assign({},c!==void 0?{prefix:c.oldLine.prefix,content:c.oldLine.content,type:mt.DELETE_CHANGES}:Object.assign(Object.assign({},on(o.content,t)),{type:pa(o.type)})),{number:o.oldNumber}):void 0,f=l!==void 0&&l.newNumber!==void 0?Object.assign(Object.assign({},c!==void 0?{prefix:c.newLine.prefix,content:c.newLine.content,type:mt.INSERT_CHANGES}:Object.assign(Object.assign({},on(l.content,t)),{type:pa(l.type)})),{number:l.newNumber}):void 0,{left:h,right:d}=this.generateLineHtml(u,f);i.left+=h,i.right+=d}return i}generateLineHtml(t,n){return{left:this.generateSingleHtml(t),right:this.generateSingleHtml(n)}}generateSingleHtml(t){let n="d2h-code-side-linenumber",r="d2h-code-side-line";return this.hoganUtils.render(Qs,"line",{type:(t==null?void 0:t.type)||`${mt.CONTEXT} d2h-emptyplaceholder`,lineClass:t!==void 0?n:`${n} d2h-code-side-emptyplaceholder`,contentClass:t!==void 0?r:`${r} d2h-code-side-emptyplaceholder`,prefix:(t==null?void 0:t.prefix)===" "?"&nbsp;":t==null?void 0:t.prefix,content:t==null?void 0:t.content,lineNumber:t==null?void 0:t.number})}};v();var Wp=Xe(Vp());v();var it=Xe(Vp()),tt={};tt["file-summary-line"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<li class="d2h-file-list-line">'),r.b(`
`+n),r.b(' <span class="d2h-file-name-wrapper">'),r.b(`
`+n),r.b(r.rp("<fileIcon0",e,t," ")),r.b(' <a href="#'),r.b(r.v(r.f("fileHtmlId",e,t,0))),r.b('" class="d2h-file-name">'),r.b(r.v(r.f("fileName",e,t,0))),r.b("</a>"),r.b(`
`+n),r.b(' <span class="d2h-file-stats">'),r.b(`
`+n),r.b(' <span class="d2h-lines-added">'),r.b(r.v(r.f("addedLines",e,t,0))),r.b("</span>"),r.b(`
`+n),r.b(' <span class="d2h-lines-deleted">'),r.b(r.v(r.f("deletedLines",e,t,0))),r.b("</span>"),r.b(`
`+n),r.b(" </span>"),r.b(`
`+n),r.b(" </span>"),r.b(`
`+n),r.b("</li>"),r.fl()},partials:{"<fileIcon0":{name:"fileIcon",partials:{},subs:{}}},subs:{}});tt["file-summary-wrapper"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<div class="d2h-file-list-wrapper '),r.b(r.v(r.f("colorScheme",e,t,0))),r.b('">'),r.b(`
`+n),r.b(' <div class="d2h-file-list-header">'),r.b(`
`+n),r.b(' <span class="d2h-file-list-title">Files changed ('),r.b(r.v(r.f("filesNumber",e,t,0))),r.b(")</span>"),r.b(`
`+n),r.b(' <a class="d2h-file-switch d2h-hide">hide</a>'),r.b(`
`+n),r.b(' <a class="d2h-file-switch d2h-show">show</a>'),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b(' <ol class="d2h-file-list">'),r.b(`
`+n),r.b(" "),r.b(r.t(r.f("files",e,t,0))),r.b(`
`+n),r.b(" </ol>"),r.b(`
`+n),r.b("</div>"),r.fl()},partials:{},subs:{}});tt["generic-block-header"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b("<tr>"),r.b(`
`+n),r.b(' <td class="'),r.b(r.v(r.f("lineClass",e,t,0))),r.b(" "),r.b(r.v(r.d("CSSLineClass.INFO",e,t,0))),r.b('"></td>'),r.b(`
`+n),r.b(' <td class="'),r.b(r.v(r.d("CSSLineClass.INFO",e,t,0))),r.b('">'),r.b(`
`+n),r.b(' <div class="'),r.b(r.v(r.f("contentClass",e,t,0))),r.b('">'),r.s(r.f("blockHeader",e,t,1),e,t,0,156,173,"{{ }}")&&(r.rs(e,t,function(i,a,s){s.b(s.t(s.f("blockHeader",i,a,0)))}),e.pop()),r.s(r.f("blockHeader",e,t,1),e,t,1,0,0,"")||r.b("&nbsp;"),r.b("</div>"),r.b(`
`+n),r.b(" </td>"),r.b(`
`+n),r.b("</tr>"),r.fl()},partials:{},subs:{}});tt["generic-empty-diff"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b("<tr>"),r.b(`
`+n),r.b(' <td class="'),r.b(r.v(r.d("CSSLineClass.INFO",e,t,0))),r.b('">'),r.b(`
`+n),r.b(' <div class="'),r.b(r.v(r.f("contentClass",e,t,0))),r.b('">'),r.b(`
`+n),r.b(" File without changes"),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b(" </td>"),r.b(`
`+n),r.b("</tr>"),r.fl()},partials:{},subs:{}});tt["generic-file-path"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-file-name-wrapper">'),r.b(`
`+n),r.b(r.rp("<fileIcon0",e,t," ")),r.b(' <span class="d2h-file-name">'),r.b(r.v(r.f("fileDiffName",e,t,0))),r.b("</span>"),r.b(`
`+n),r.b(r.rp("<fileTag1",e,t," ")),r.b("</span>"),r.b(`
`+n),r.b('<label class="d2h-file-collapse">'),r.b(`
`+n),r.b(' <input class="d2h-file-collapse-input" type="checkbox" name="viewed" value="viewed">'),r.b(`
`+n),r.b(" Viewed"),r.b(`
`+n),r.b("</label>"),r.fl()},partials:{"<fileIcon0":{name:"fileIcon",partials:{},subs:{}},"<fileTag1":{name:"fileTag",partials:{},subs:{}}},subs:{}});tt["generic-line"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b("<tr>"),r.b(`
`+n),r.b(' <td class="'),r.b(r.v(r.f("lineClass",e,t,0))),r.b(" "),r.b(r.v(r.f("type",e,t,0))),r.b('">'),r.b(`
`+n),r.b(" "),r.b(r.t(r.f("lineNumber",e,t,0))),r.b(`
`+n),r.b(" </td>"),r.b(`
`+n),r.b(' <td class="'),r.b(r.v(r.f("type",e,t,0))),r.b('">'),r.b(`
`+n),r.b(' <div class="'),r.b(r.v(r.f("contentClass",e,t,0))),r.b('">'),r.b(`
`+n),r.s(r.f("prefix",e,t,1),e,t,0,162,238,"{{ }}")&&(r.rs(e,t,function(i,a,s){s.b(' <span class="d2h-code-line-prefix">'),s.b(s.t(s.f("prefix",i,a,0))),s.b("</span>"),s.b(`
`+n)}),e.pop()),r.s(r.f("prefix",e,t,1),e,t,1,0,0,"")||(r.b(' <span class="d2h-code-line-prefix">&nbsp;</span>'),r.b(`
`+n)),r.s(r.f("content",e,t,1),e,t,0,371,445,"{{ }}")&&(r.rs(e,t,function(i,a,s){s.b(' <span class="d2h-code-line-ctn">'),s.b(s.t(s.f("content",i,a,0))),s.b("</span>"),s.b(`
`+n)}),e.pop()),r.s(r.f("content",e,t,1),e,t,1,0,0,"")||(r.b(' <span class="d2h-code-line-ctn"><br></span>'),r.b(`
`+n)),r.b(" </div>"),r.b(`
`+n),r.b(" </td>"),r.b(`
`+n),r.b("</tr>"),r.fl()},partials:{},subs:{}});tt["generic-wrapper"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<div class="d2h-wrapper '),r.b(r.v(r.f("colorScheme",e,t,0))),r.b('">'),r.b(`
`+n),r.b(" "),r.b(r.t(r.f("content",e,t,0))),r.b(`
`+n),r.b("</div>"),r.fl()},partials:{},subs:{}});tt["icon-file-added"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<svg aria-hidden="true" class="d2h-icon d2h-added" height="16" title="added" version="1.1" viewBox="0 0 14 16"'),r.b(`
`+n),r.b(' width="14">'),r.b(`
`+n),r.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM6 9H3V7h3V4h2v3h3v2H8v3H6V9z"></path>'),r.b(`
`+n),r.b("</svg>"),r.fl()},partials:{},subs:{}});tt["icon-file-changed"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1"'),r.b(`
`+n),r.b(' viewBox="0 0 14 16" width="14">'),r.b(`
`+n),r.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path>'),r.b(`
`+n),r.b("</svg>"),r.fl()},partials:{},subs:{}});tt["icon-file-deleted"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<svg aria-hidden="true" class="d2h-icon d2h-deleted" height="16" title="removed" version="1.1"'),r.b(`
`+n),r.b(' viewBox="0 0 14 16" width="14">'),r.b(`
`+n),r.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM11 9H3V7h8v2z"></path>'),r.b(`
`+n),r.b("</svg>"),r.fl()},partials:{},subs:{}});tt["icon-file-renamed"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<svg aria-hidden="true" class="d2h-icon d2h-moved" height="16" title="renamed" version="1.1"'),r.b(`
`+n),r.b(' viewBox="0 0 14 16" width="14">'),r.b(`
`+n),r.b(' <path d="M6 9H3V7h3V4l5 4-5 4V9z m8-7v12c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h12c0.55 0 1 0.45 1 1z m-1 0H1v12h12V2z"></path>'),r.b(`
`+n),r.b("</svg>"),r.fl()},partials:{},subs:{}});tt["icon-file"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">'),r.b(`
`+n),r.b(' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>'),r.b(`
`+n),r.b("</svg>"),r.fl()},partials:{},subs:{}});tt["line-by-line-file-diff"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<div id="'),r.b(r.v(r.f("fileHtmlId",e,t,0))),r.b('" class="d2h-file-wrapper" data-lang="'),r.b(r.v(r.d("file.language",e,t,0))),r.b('">'),r.b(`
`+n),r.b(' <div class="d2h-file-header">'),r.b(`
`+n),r.b(" "),r.b(r.t(r.f("filePath",e,t,0))),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b(' <div class="d2h-file-diff">'),r.b(`
`+n),r.b(' <div class="d2h-code-wrapper">'),r.b(`
`+n),r.b(' <table class="d2h-diff-table">'),r.b(`
`+n),r.b(' <tbody class="d2h-diff-tbody">'),r.b(`
`+n),r.b(" "),r.b(r.t(r.f("diffs",e,t,0))),r.b(`
`+n),r.b(" </tbody>"),r.b(`
`+n),r.b(" </table>"),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b("</div>"),r.fl()},partials:{},subs:{}});tt["line-by-line-numbers"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<div class="line-num1">'),r.b(r.v(r.f("oldNumber",e,t,0))),r.b("</div>"),r.b(`
`+n),r.b('<div class="line-num2">'),r.b(r.v(r.f("newNumber",e,t,0))),r.b("</div>"),r.fl()},partials:{},subs:{}});tt["side-by-side-file-diff"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<div id="'),r.b(r.v(r.f("fileHtmlId",e,t,0))),r.b('" class="d2h-file-wrapper" data-lang="'),r.b(r.v(r.d("file.language",e,t,0))),r.b('">'),r.b(`
`+n),r.b(' <div class="d2h-file-header">'),r.b(`
`+n),r.b(" "),r.b(r.t(r.f("filePath",e,t,0))),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b(' <div class="d2h-files-diff">'),r.b(`
`+n),r.b(' <div class="d2h-file-side-diff">'),r.b(`
`+n),r.b(' <div class="d2h-code-wrapper">'),r.b(`
`+n),r.b(' <table class="d2h-diff-table">'),r.b(`
`+n),r.b(' <tbody class="d2h-diff-tbody">'),r.b(`
`+n),r.b(" "),r.b(r.t(r.d("diffs.left",e,t,0))),r.b(`
`+n),r.b(" </tbody>"),r.b(`
`+n),r.b(" </table>"),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b(' <div class="d2h-file-side-diff">'),r.b(`
`+n),r.b(' <div class="d2h-code-wrapper">'),r.b(`
`+n),r.b(' <table class="d2h-diff-table">'),r.b(`
`+n),r.b(' <tbody class="d2h-diff-tbody">'),r.b(`
`+n),r.b(" "),r.b(r.t(r.d("diffs.right",e,t,0))),r.b(`
`+n),r.b(" </tbody>"),r.b(`
`+n),r.b(" </table>"),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b(" </div>"),r.b(`
`+n),r.b("</div>"),r.fl()},partials:{},subs:{}});tt["tag-file-added"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-added d2h-added-tag">ADDED</span>'),r.fl()},partials:{},subs:{}});tt["tag-file-changed"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span>'),r.fl()},partials:{},subs:{}});tt["tag-file-deleted"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-deleted d2h-deleted-tag">DELETED</span>'),r.fl()},partials:{},subs:{}});tt["tag-file-renamed"]=new it.Template({code:function(e,t,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-moved d2h-moved-tag">RENAMED</span>'),r.fl()},partials:{},subs:{}});var to=class{constructor({compiledTemplates:t={},rawTemplates:n={}}){let r=Object.entries(n).reduce((i,[a,s])=>{let o=Wp.compile(s,{asString:!1});return Object.assign(Object.assign({},i),{[a]:o})},{});this.preCompiledTemplates=Object.assign(Object.assign(Object.assign({},tt),t),r)}static compile(t){return Wp.compile(t,{asString:!1})}render(t,n,r,i,a){let s=this.templateKey(t,n);try{return this.preCompiledTemplates[s].render(r,i,a)}catch(o){throw new Error(`Could not find template to render '${s}'`)}}template(t,n){return this.preCompiledTemplates[this.templateKey(t,n)]}templateKey(t,n){return`${t}-${n}`}};var rj=Object.assign(Object.assign(Object.assign({},Hp),Up),{outputFormat:OE.LINE_BY_LINE,drawFileList:!0});function JE(e,t={}){let n=Object.assign(Object.assign({},rj),t),r=typeof e=="string"?$E(e,n):e,i=new to(n),{colorScheme:a}=n,s={colorScheme:a},o=n.drawFileList?new Xc(i,s).render(r):"",l=n.outputFormat==="side-by-side"?new eo(i,n).render(r):new Js(i,n).render(r);return o+l}var Zc=require("obsidian");var va=class extends Zc.ItemView{constructor(n,r){super(n);this.plugin=r;this.gettingDiff=!1;this.parser=new DOMParser,this.navigation=!0,this.gitRefreshRef=this.app.workspace.on("obsidian-git:refresh",()=>{this.refresh().catch(console.error)}),this.gitViewRefreshRef=this.app.workspace.on("obsidian-git:view-refresh",()=>{this.refresh().catch(console.error)})}getViewType(){return Ct.type}getDisplayText(){var n;if(((n=this.state)==null?void 0:n.file)!=null){let r=this.state.file.split("/").last();return r!=null&&r.endsWith(".md")&&(r=r.slice(0,-3)),Ct.name+` (${r})`}return Ct.name}getIcon(){return Ct.icon}async setState(n,r){this.state=n,Zc.Platform.isMobile&&(this.leaf.view.titleEl.textContent=this.getDisplayText()),await this.refresh()}getState(){return this.state}onClose(){return this.app.workspace.offref(this.gitRefreshRef),this.app.workspace.offref(this.gitViewRefreshRef),super.onClose()}async onOpen(){return await this.refresh(),super.onOpen()}async refresh(){var n;if((n=this.state)!=null&&n.file&&!this.gettingDiff&&this.plugin.gitManager){this.gettingDiff=!0;try{let r=await this.plugin.gitManager.getDiffString(this.state.file,this.state.staged,this.state.hash);this.contentEl.empty();let i=this.plugin.gitManager.getRelativeVaultPath(this.state.file);if(!r){if(this.plugin.gitManager instanceof Le&&await this.plugin.gitManager.isTracked(this.state.file))r=[`--- ${this.state.file}`,`+++ ${this.state.file}`,""].join(`
`);else if(await this.app.vault.adapter.exists(i)){let a=await this.app.vault.adapter.read(i);r=[...`--- /dev/null
2022-09-04 12:54:22 +00:00
+++ ${this.state.file}
2024-12-09 19:19:31 +00:00
@@ -0,0 +1,${a.split(`
`).length} @@`.split(`
`),...a.split(`
`).map(o=>`+${o}`)].join(`
`)}}if(r){let a=this.parser.parseFromString(JE(r),"text/html").querySelector(".d2h-file-diff");this.contentEl.append(a)}else{let a=this.contentEl.createDiv({cls:"obsidian-git-center"});a.createSpan({text:"\u26A0\uFE0F",attr:{style:"font-size: 2em"}}),a.createEl("br"),a.createSpan({text:"File not found: "+this.state.file})}}finally{this.gettingDiff=!1}}}};v();var MA=require("obsidian");v();v();v();v();function Ae(){}var no=e=>e;function qp(e){return e()}function Kc(){return Object.create(null)}function ke(e){e.forEach(qp)}function wa(e){return typeof e=="function"}function at(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function QE(e){return Object.keys(e).length===0}v();var eA=typeof window!="undefined",Xp=eA?()=>window.performance.now():()=>Date.now(),ro=eA?e=>requestAnimationFrame(e):Ae;v();var ba=new Set;function tA(e){ba.forEach(t=>{t.c(e)||(ba.delete(t),t.f())}),ba.size!==0&&ro(tA)}function Yp(e){let t;return ba.size===0&&ro(tA),{promise:new Promise(n=>{ba.add(t={c:e,f:n})}),abort(){ba.delete(t)}}}v();v();v();v();var Zp=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;var Jc=class e{constructor(t){ut(this,"_listeners","WeakMap"in Zp?new WeakMap:void 0);ut(this,"_observer");ut(this,"options");this.options=t}observe(t,n){return this._listeners.set(t,n),this._getObserver().observe(t,this.options),()=>{this._listeners.delete(t),this._observer.unobserve(t)}}_getObserver(){var t;return(t=this._observer)!=null?t:this._observer=new ResizeObserver(n=>{var r;for(let i of n)e.entries.set(i.target,i),(r=this._listeners.get(i.target))==null||r(i)})}};Jc.entries="WeakMap"in Zp?new WeakMap:void 0;var nA=!1;function rA(){nA=!0}function iA(){nA=!1}function M(e,t){e.appendChild(t)}function Nt(e,t,n){let r=Qc(e);if(!r.getElementById(t)){let i=I("style");i.id=t,i.textContent=n,sA(r,i)}}function Qc(e){if(!e)return document;let t=e.getRootNode?e.getRootNode():e.ownerDocument;return t&&t.host?t:e.ownerDocument}function aA(e){let t=I("style");return t.textContent="/* empty */",sA(Qc(e),t),t.sheet}function sA(e,t){return M(e.head||e,t),t.sheet}function re(e,t,n){e.insertBefore(t,n||null)}function ne(e){e.parentNode&&e.parentNode.removeChild(e)}function ln(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function I(e){return document.createElement(e)}function Te(e){return document.createTextNode(e)}function J(){return Te(" ")}function xa(){return Te("")}function te(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function xe(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function T(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function oA(e){return Array.from(e.childNodes)}function Me(e,t){t=""+t,e.data!==t&&(e.data=t)}function Kp(e,t){e.value=t==null?"":t}function Yt(e,t,n,r){n==null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function ce(e,t,n){e.classList.toggle(t,!!n)}function eu(e,t,{bubbles:n=!1,cancelable:r=!1}={}){return new CustomEvent(e,{detail:t,bubbles:n,cancelable:r})}function lA(e){let t={};return e.childNodes.forEach(n=>{t[n.slot||"default"]=!0}),t}var tu=new Map,nu=0;function aj(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function sj(e,t){let n={stylesheet:aA(t),rules:{}};return tu.set(e,n),n}function ru(e,t,n,r,i,a,s,o=0){let l=16.666/r,c=`{
`;for(let m=0;m<=1;m+=l){let w=t+(n-t)*a(m);c+=m*100+`%{${s(w,1-w)}}
`}let u=c+`100% {${s(n,1-n)}}
}`,f=`__svelte_${aj(u)}_${o}`,h=Qc(e),{stylesheet:d,rules:p}=tu.get(h)||sj(h,e);p[f]||(p[f]=!0,d.insertRule(`@keyframes ${f} ${u}`,d.cssRules.length));let g=e.style.animation||"";return e.style.animation=`${g?`${g}, `:""}${f} ${r}ms linear ${i}ms 1 both`,nu+=1,f}function Jp(e,t){let n=(e.style.animation||"").split(", "),r=n.filter(t?a=>a.indexOf(t)<0:a=>a.indexOf("__svelte")===-1),i=n.length-r.length;i&&(e.style.animation=r.join(", "),nu-=i,nu||oj())}function oj(){ro(()=>{nu||(tu.forEach(e=>{let{ownerNode:t}=e.stylesheet;t&&ne(t)}),tu.clear())})}v();v();v();v();var Ar;function Kn(e){Ar=e}function cA(){if(!Ar)throw new Error("Function called outside component initialization");return Ar}function io(e){cA().$$.on_destroy.push(e)}function kr(e,t){let n=e.$$.callbacks[t.type];n&&n.slice().forEach(r=>r.call(this,t))}var si=[];var je=[],Sa=[],uA=[],lj=Promise.resolve(),em=!1;function fA(){em||(em=!0,lj.then(iu))}function wt(e){Sa.push(e)}var Qp=new Set,_a=0;function iu(){if(_a!==0)return;let e=Ar;do{try{for(;_a<si.length;){let t=si[_a];_a++,Kn(t),cj(t.$$)}}catch(t){throw si.length=0,_a=0,t}for(Kn(null),si.length=0,_a=0;je.length;)je.pop()();for(let t=0;t<Sa.length;t+=1){let n=Sa[t];Qp.has(n)||(Qp.add(n),n())}Sa.length=0}while(si.length);for(;uA.length;)uA.pop()();em=!1,Qp.clear(),Kn(e)}function cj(e){if(e.fragment!==null){e.update(),ke(e.before_update);let t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(wt)}}function hA(e){let t=[],n=[];Sa.forEach(r=>e.indexOf(r)===-1?t.push(r):n.push(r)),n.forEach(r=>r()),Sa=t}var ao;function uj(){return ao||(ao=Promise.resolve(),ao.then(()=>{ao=null})),ao}function tm(e,t,n){e.dispatchEvent(eu(`${t?"intro":"outro"}${n}`))}var au=new Set,Jn;function Ce(){Jn={r:0,c:[],p:Jn}}function Fe(){Jn.r||ke(Jn.c),Jn=Jn.p}function U(e,t){e&&e.i&&(au.delete(e),e.i(t))}function X(e,t,n,r){if(e&&e.o){if(au.has(e))return;au.add(e),Jn.c.push(()=>{au.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}var fj={duration:0};function bt(e,t,n,r){let a=t(e,n,{direction:"both"}),s=r?0:1,o=null,l=null,c=null,u;function f(){c&&Jp(e,c)}function h(p,g){let m=p.b-s;return g*=Math.abs(m),{a:s,b:p.b,d:m,duration:g,start:p.start,end:p.start+g,group:p.group}}function d(p){let{delay:g=0,duration:m=300,easing:w=no,tick:b=Ae,css:S}=a||fj,A={start:Xp()+g,b:p};p||(A.group=Jn,Jn.r+=1),"inert"in e&&(p?u!==void 0&&(e.inert=u):(u=e.inert,e.inert=!0)),o||l?l=A:(S&&(f(),c=ru(e,s,p,m,g,w,S)),p&&b(0,1),o=h(A,m),wt(()=>tm(e,p,"start")),Yp(x=>{if(l&&x>l.start&&(o=h(l,m),l=null,tm(e,o.b,"start"),S&&(f(),c=ru(e,s,o.b,o.duration,0,w,a.css))),o){if(x>=o.end)b(s=o.b,1-s),tm(e,o.b,"end"),l||(o.b?f():--o.group.r||ke(o.group.c)),o=null;else if(x>=o.start){let k=x-o.start;s=o.a+o.d*w(k/o.duration),b(s,1-s)}}return!!(o||l)}))}return{run(p){wa(a)?uj().then(()=>{a=a({direction:p?"in":"out"}),d(p)}):d(p)},end(){f(),o=l=null}}}v();function nt(e){return(e==null?void 0:e.length)!==void 0?e:Array.from(e)}v();v();v();var hj=["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],dj=new Set([...hj]);v();v();v();function Ge(e){e&&e.c()}function De(e,t,n){let{fragment:r,after_update:i}=e.$$;r&&r.m(t,n),wt(()=>{let a=e.$$.on_mount.map(qp).filter(wa);e.$$.on_destroy?e.$$.on_destroy.push(...a):ke(a),e.$$.on_mount=[]}),i.forEach(wt)}function Be(e,t){let n=e.$$;n.fragment!==null&&(hA(n.after_update),ke(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function mj(e,t){e.$$.dirty[0]===-1&&(si.push(e),fA(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function st(e,t,n,r,i,a,s=null,o=[-1]){let l=Ar;Kn(e);let c=e.$$={fragment:null,ctx:[],props:a,update:Ae,not_equal:i,bound:Kc(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Kc(),dirty:o,skip_bound:!1,root:t.target||l.$$.root};s&&s(c.root);let u=!1;if(c.
`:""}${(y=e[0].author)==null?void 0:y.name}
${(0,so.moment)(e[0].date).format(e[3].settings.commitDateFormat)}
${e[0].message}`),T(r,"data-tooltip-position",e[5]),T(n,"class","tree-item nav-folder"),ce(n,"is-collapsed",e[4])},m(y,E){re(y,t,E),M(t,n),M(n,r),M(r,i),M(r,a),M(r,s),b&&b.m(s,null),M(s,o),S&&S.m(s,null),M(s,l),A&&A.m(s,null),M(s,c),M(s,u),M(u,h),M(n,p),x&&x.m(n,null),g=!0,m||(w=te(r,"click",e[8]),m=!0)},p(y,[E]){var _,C;(!g||E&16)&&ce(i,"is-collapsed",y[4]),y[0].refs.length>0?b?b.p(y,E):(b=xA(y),b.c(),b.m(s,o)):b&&(b.d(1),b=null),y[3].settings.authorInHistoryView!="hide"&&((_=y[0].author)!=null&&_.name)?S?S.p(y,E):(S=_A(y),S.c(),S.m(s,l)):S&&(S.d(1),S=null),y[3].settings.dateInHistoryView?A?A.p(y,E):(A=SA(y),A.c(),A.m(s,c)):A&&(A.d(1),A=null),(!g||E&1)&&f!==(f=y[0].message+"")&&Me(h,f),(!g||E&9&&d!==(d=`${y[0].refs.length>0?y[0].refs.join(", ")+`
`:""}${(C=y[0].author)==null?void 0:C.name}
${(0,so.moment)(y[0].date).format(y[3].settings.commitDateFormat)}
${y[0].message}`))&&T(r,"aria-label",d),(!g||E&32)&&T(r,"data-tooltip-position",y[5]),y[4]?x&&(Ce(),X(x,1,1,()=>{x=null}),Fe()):x?(x.p(y,E),E&16&&U(x,1)):(x=EA(y),x.c(),U(x,1),x.m(n,null)),(!g||E&16)&&ce(n,"is-collapsed",y[4])},i(y){g||(U(x),g=!0)},o(y){X(x),g=!1},d(y){y&&ne(t),b&&b.d(),S&&S.d(),A&&A.d(),x&&x.d(),m=!1,w()}}}function Cj(e,t,n){let r,i,{log:a}=t,{view:s}=t,{showTree:o}=t,{plugin:l}=t,c=!0;function u(h){let d=h.author.name;if(l.settings.authorInHistoryView=="full")return d;if(l.settings.authorInHistoryView=="initials")return d.split(" ").filter(g=>g.length>0).map(g=>g[0].toUpperCase()).join("")}let f=()=>n(4,c=!c);return e.$$set=h=>{"log"in h&&n(0,a=h.log),"view"in h&&n(1,s=h.view),"showTree"in h&&n(2,o=h.showTree),"plugin"in h&&n(3,l=h.plugin)},e.$$.update=()=>{e.$$.dirty&9&&n(6,r={title:"",path:"",vaultPath:"",children:l.gitManager.getTreeStructure(a.diff.files)}),e.$$.dirty&2&&n(5,i=s.leaf.getRoot().side=="left"?"right":"left")},[a,s,o,l,c,i,r,u,f]}var im=class extends qe{constructor(t){super(),st(this,t,Cj,Tj,at,{log:0,view:1,showTree:2,plugin:3})}},kA=im;function TA(e,t,n){let r=e.slice();return r[13]=t[n],r}function CA(e){let t,n,r=nt(e[6]),i=[];for(let s=0;s<r.length;s+=1)i[s]=FA(TA(e,r,s));let a=s=>X(i[s],1,1,()=>{i[s]=null});return{c(){t=I("div");for(let s=0;s<i.length;s+=1)i[s].c();T(t,"class","tree-item nav-folder mod-root")},m(s,o){re(s,t,o);for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(t,null);n=!0},p(s,o){if(o&71){r=nt(s[6]);let l;for(l=0;l<r.length;l+=1){let c=TA(s,r,l);i[l]?(i[l].p(c,o),U(i[l],1)):(i[l]=FA(c),i[l].c(),U(i[l],1),i[l].m(t,null))}for(Ce(),l=r.length;l<i.length;l+=1)a(l);Fe()}},i(s){if(!n){for(let o=0;o<r.length;o+=1)U(i[o]);n=!0}},o(s){i=i.filter(Boolean);for(let o=0;o<i.length;o+=1)X(i[o]);n=!1},d(s){s&&ne(t),ln(i,s)}}}function FA(e){let t,n;return t=new kA({props:{view:e[1],showTree:e[2],log:e[13],plugin:e[0]}}),{c(){Ge(t.$$.fragment)},m(r,i){De(t,r,i),n=!0},p(r,i){let a={};i&2&&(a.view=r[1]),i&4&&(a.showTree=r[2]),i&64&&(a.log=r[13]),i&1&&(a.plugin=r[0]),t.$set(a)},i(r){n||(U(t.$$.fragment,r),n=!0)},o(r){X(t.$$.fragment,r),n=!1},d(r){Be(t,r)}}}function Fj(e){let t,n,r,i,a,s,o,l,c,u,f,h=e[6]&&CA(e);return{c(){t=I("main"),n=I("div"),r=I("div"),i=I("div"),a=J(),s=I("div"),o=J(),l=I("div"),h&&h.c(),T(i,"id","layoutChange"),T(i,"class","clickable-icon nav-action-button"),T(i,"aria-label","Change Layout"),T(s,"id","refresh"),T(s,"class","clickable-icon nav-action-button"),T(s,"data-icon","refresh-cw"),T(s,"aria-label","Refresh"),Yt(s,"margin","1px"),ce(s,"loading",e[4]),T(r,"class","nav-buttons-container"),T(n,"class","nav-header"),T(l,"class","nav-files-container"),Yt(l,"position","relative")},m(d,p){re(d,t,p),M(t,n),M(n,r),M(r,i),e[8](i),M(r,a),M(r,s),e[10](s),M(t,o),M(t,l),h&&h.m(l,null),c=!0,u||(f=[te(i,"click",e[9]),te(s,"click",e[7])],u=!0)},p(d,[p]){(!c||p&16)&&ce(s,"loading",d[4]),d[6]?h?(h.p(d,p),p&64&&U(h,1)):(h=CA(d),h.c(),U(h,1),h.m(l,null)):h&&(Ce(),X(h,1,1,()=>{h=null}),Fe())},i(d){c||(U(h),c=!0)},o(d){X(h),c=!1},d(d){d&&ne(t),e[8](null),e[10](null),h&&h.d(),u=!1,ke(f)}}}function Pj(e,t,n){let{plugin:r}=t,{view:i}=t,a,s=[],o,l=r.settings.treeStructure,c,u;c=i.app.workspace.on("obsidian-git:view-refresh",()=>void h().catch(console.error)),h().catch(console.error),r.app.workspace.onLayoutReady(()=>{window.setTimeout(()=>{s.forEach(m=>(0,lu.setIcon)(m,m.getAttr("data-icon"))),(0,lu.setIcon)(u,l?"list":"folder")},0)}),io(()=>{i.app.workspace.offref(c)});function f(){i.app.workspace.trigger("obsidian-git:refresh")}function h(){return Ea(this,void 0,void 0,function*(){if(!r.gitReady){n(6,o=void 0);return}n(4,a=!0);let m=r.gitManager instanceof Le;n(6,o=yield r.gitManager.log(void 0,!1,m?50:10)),n(4,a=!1)})}function d(m){je[m?"unshift":"push"](()=>{u=m,n(3,u)})}let p=()=>{n(2,l=!l),n(0,r.settings.treeStructure=l,r),r.saveSettings()};function g(m){je[m?"unshift":"push"](()=>{s[6]=m,n(5,s)})}return e.$$set=m=>{"plugin"in m&&n(0,r=m.plugin),"view"in m&&n(1,i=m.view)},e.$$.update=()=>{e.$$.dirty&12&&u&&(u.empty(),(0,lu.setIcon)(u,l?"list":"folder"))},[r,i,l,u,a,s,o,f,d,p,g]}var am=
`)}. Please remove them.`),!0}}return!1}async writeAndOpenFile(t){t!==void 0&&await this.plugin.app.vault.adapter.write(Wi,t);let n=!1;this.plugin.app.workspace.iterateAllLeaves(r=>{r.getDisplayText()!=""&&Wi.startsWith(r.getDisplayText())&&(n=!0)}),n||await this.plugin.app.workspace.openLinkText(Wi,"/",!0)}};var gu=class extends _e.Plugin{constructor(){super(...arguments);this.tools=new uo(this);this.state={gitAction:0,loading:!1,offlineMode:!1};this.gitReady=!1;this.promiseQueue=new Nc(this);this.loading=!1;this.intervalsToClear=[];this.lineAuthoringFeature=new Bc(this)}setPluginState(n){var r;this.state=Object.assign(this.state,n),(r=this.statusBar)==null||r.display()}async updateCachedStatus(){var n,r;return this.cachedStatus=await this.gitManager.status(),this.cachedStatus.conflicted.length>0?(this.localStorage.setConflict(!0),await((n=this.branchBar)==null?void 0:n.display())):(this.localStorage.setConflict(!1),await((r=this.branchBar)==null?void 0:r.display())),this.cachedStatus}async refresh(){if(!this.gitReady)return;let n=this.app.workspace.getLeavesOfType(pt.type),r=this.app.workspace.getLeavesOfType(nn.type);(this.settings.changedFilesInStatusBar||n.some(i=>{var a;return!((a=i.isDeferred)!=null&&a)})||r.some(i=>{var a;return!((a=i.isDeferred)!=null&&a)}))&&(this.loading=!0,this.app.workspace.trigger("obsidian-git:view-refresh"),await this.updateCachedStatus().catch(i=>this.displayError(i)),this.loading=!1,this.app.workspace.trigger("obsidian-git:view-refresh"))}refreshUpdatedHead(){this.lineAuthoringFeature.refreshLineAuthorViews()}async onload(){console.log("loading "+this.manifest.name+" plugin: v"+this.manifest.version),Ws.plugin=this,this.localStorage=new Vc(this),this.localStorage.migrate(),await this.loadSettings(),await this.migrateSettings(),this.settingsTab=new Ec(this.app,this),this.addSettingTab(this.settingsTab),this.localStorage.getPluginDisabled()||(this.registerStuff(),this.app.workspace.onLayoutReady(()=>this.init({fromReload:!1}).catch(n=>this.displayError(n))))}onExternalSettingsChange(){this.reloadSettings().catch(n=>this.displayError(n))}async reloadSettings(){let n=JSON.stringify(this.settings);await this.loadSettings();let r=JSON.stringify(this.settings);n!==r&&(this.log("Reloading settings"),this.unloadPlugin(),await this.init({fromReload:!0}),this.app.workspace.getLeavesOfType(pt.type).forEach(i=>{var a;if(!((a=i.isDeferred)!=null&&a))return i.view.reload()}),this.app.workspace.getLeavesOfType(nn.type).forEach(i=>{var a;if(!((a=i.isDeferred)!=null&&a))return i.view.reload()}))}registerStuff(){this.registerEvent(this.app.workspace.on("obsidian-git:refresh",()=>{this.refresh().catch(n=>this.displayError(n))})),this.registerEvent(this.app.workspace.on("obsidian-git:head-change",()=>{this.refreshUpdatedHead()})),this.registerEvent(this.app.workspace.on("file-menu",(n,r,i)=>{this.handleFileMenu(n,r,i)})),this.registerEvent(this.app.workspace.on("active-leaf-change",n=>{this.handleViewActiveState(n)})),this.registerEvent(this.app.vault.on("modify",()=>{var n;this.debRefresh(),(n=this.autoCommitDebouncer)==null||n.call(this)})),this.registerEvent(this.app.vault.on("delete",()=>{var n;this.debRefresh(),(n=this.autoCommitDebouncer)==null||n.call(this)})),this.registerEvent(this.app.vault.on("create",()=>{var n;this.debRefresh(),(n=this.autoCommitDebouncer)==null||n.call(this)})),this.registerEvent(this.app.vault.on("rename",()=>{var n;this.debRefresh(),(n=this.autoCommitDebouncer)==null||n.call(this)})),this.registerView(pt.type,n=>new co(n,this)),this.registerView(nn.type,n=>new oo(n,this)),this.registerView(Ct.type,n=>new va(n,this)),this.addRibbonIcon("git-pull-request","Open Git source control",async()=>{var i;let n=this.app.workspace.getLeavesOfType(pt.type),r;n.length===0?(r=(i=this.app.workspace.getRightLeaf(!1))!=null?i:this.app.workspace.getLeaf(),await r.setViewState({type:pt.type})):r=n.first(),await this.app.workspace.revealLeaf(r),this.app.workspace.trigger("obsidian-git:refresh")}),this.registerHoverLinkSource(pt.type,{display:"Git View",defaultMod:!0}),this.lineAuthoringFeature.
`+this.gitManager.getRelativeRepoPath(n.path,!0)),this.refresh()}handleFileMenu(n,r,i){this.gitReady&&this.settings.showFileMenu&&r&&(this.settings.showFileMenu&&i=="file-explorer-context-menu"&&(n.addItem(a=>{a.setTitle("Git: Stage").setIcon("plus-circle").setSection("action").onClick(s=>{this.promiseQueue.addTask(async()=>{r instanceof _e.TFile?await this.gitManager.stage(r.path,!0):await this.gitManager.stageAll({dir:this.gitManager.getRelativeRepoPath(r.path,!0)}),this.displayMessage(`Staged ${r.path}`)})})}),n.addItem(a=>{a.setTitle("Git: Unstage").setIcon("minus-circle").setSection("action").onClick(s=>{this.promiseQueue.addTask(async()=>{r instanceof _e.TFile?await this.gitManager.unstage(r.path,!0):await this.gitManager.unstageAll({dir:this.gitManager.getRelativeRepoPath(r.path,!0)}),this.displayMessage(`Unstaged ${r.path}`)})})}),n.addItem(a=>{a.setTitle("Git: Add to .gitignore").setIcon("file-x").setSection("action").onClick(s=>{this.addFileToGitignore(r).catch(o=>this.displayError(o))})})),i=="git-source-control"&&n.addItem(a=>{a.setTitle("Git: Add to .gitignore").setIcon("file-x").setSection("action").onClick(s=>{this.addFileToGitignore(r).catch(o=>this.displayError(o))})}))}async migrateSettings(){this.settings.mergeOnPull!=null&&(this.settings.syncMethod=this.settings.mergeOnPull?"merge":"rebase",this.settings.mergeOnPull=void 0,await this.saveSettings()),this.settings.autoCommitMessage===void 0&&(this.settings.autoCommitMessage=this.settings.commitMessage,await this.saveSettings()),this.settings.gitPath!=null&&(this.localStorage.setGitPath(this.settings.gitPath),this.settings.gitPath=void 0,await this.saveSettings()),this.settings.username!=null&&(this.localStorage.setPassword(this.settings.username),this.settings.username=void 0,await this.saveSettings())}unloadPlugin(){var n,r;this.gitReady=!1,this.app.workspace.trigger("obsidian-git:refresh"),this.lineAuthoringFeature.deactivateFeature(),this.automaticsManager.unload(),(n=this.branchBar)==null||n.remove(),(r=this.statusBar)==null||r.remove(),this.gitManager.unload(),this.promiseQueue.clear();for(let i of this.intervalsToClear)window.clearInterval(i);this.intervalsToClear=[],this.debRefresh.cancel()}onunload(){this.unloadPlugin(),console.log("unloading "+this.manifest.name+" plugin")}async loadSettings(){let n=await this.loadData();n==null&&(n={showedMobileNotice:!0}),this.settings=Xw(Pn,n)}async saveSettings(){var n;(n=this.settingsTab)==null||n.beforeSaveSettings(),await this.saveData(this.settings)}get useSimpleGit(){return _e.Platform.isDesktopApp}async init({fromReload:n=!1}){var r;if(this.settings.showStatusBar){let i=this.addStatusBarItem();this.statusBar=new $c(i,this),this.intervalsToClear.push(window.setInterval(()=>{var a;return(a=this.statusBar)==null?void 0:a.display()},1e3))}try{this.useSimpleGit?(this.gitManager=new Le(this),await this.gitManager.setGitInstance()):this.gitManager=new yn(this);let i=await this.gitManager.checkRequirements();switch(i){case"missing-git":this.displayError(`Cannot run git command. Trying to run: '${this.localStorage.getGitPath()||"git"}' .`);break;case"missing-repo":new _e.Notice("Can't find a valid git repository. Please create one via the given command or clone an existing repo.",1e4);break;case"valid":if(this.gitReady=!0,this.setPluginState({gitAction:0}),_e.Platform.isDesktop&&this.settings.showBranchStatusBar){let a=this.addStatusBarItem();this.branchBar=new mu(a,this),this.intervalsToClear.push(window.setInterval(()=>{var s;return void((s=this.branchBar)==null?void 0:s.display().catch(console.error))},6e4))}await((r=this.branchBar)==null?void 0:r.display()),this.lineAuthoringFeature.conditionallyActivateBySettings(),this.app.workspace.trigger("obsidian-git:refresh"),!n&&this.settings.autoPullOnBoot&&this.promiseQueue.addTask(()=>this.pullChangesFromRemote()),this.automaticsManager=new qs(this),await this.automaticsManager.init();break;default:this.log("Something weird happened. The 'checkRequirements' result is "+i)}}catch(i){this.displayError(i),console.error(i)}}async createNewRepo(){try{await this.git
2022-12-22 16:21:07 +00:00
# Additional Instructions
I strongly recommend to use "Source mode" for viewing the conflicted files. For simple conflicts, in each file listed above replace every occurrence of the following text blocks with the desired text.
\`\`\`diff
<<<<<<< HEAD
File changes in local repository
=======
File changes in remote repository
>>>>>>> origin/main
2024-12-09 19:19:31 +00:00
\`\`\``]),await this.tools.writeAndOpenFile(r==null?void 0:r.join(`
`))}async editRemotes(){if(!await this.isAllInitialized())return;let n=await this.gitManager.getRemotes(),i=await new $e(this,{options:n,placeholder:"Select or create a new remote by typing its name and selecting it"}).openAndGetResult();if(i){let a=await this.gitManager.getRemoteUrl(i),o=await new $e(this,{initialValue:a}).openAndGetResult();if(o)return await this.gitManager.setRemote(i,o),i}}async selectRemoteBranch(){let n=await this.gitManager.getRemotes(),r;n.length===0&&(r=await this.editRemotes(),r==null&&(n=await this.gitManager.getRemotes()));let i=new $e(this,{options:n,placeholder:"Select or create a new remote by typing its name and selecting it"}),a=r!=null?r:await i.openAndGetResult();if(a){this.displayMessage("Fetching remote branches"),await this.gitManager.fetch(a);let s=await this.gitManager.getRemoteBranches(a);return await new $e(this,{options:s,placeholder:"Select or create a new remote branch by typing its name and selecting it"}).openAndGetResult()}}async removeRemote(){if(!await this.isAllInitialized())return;let n=await this.gitManager.getRemotes(),i=await new $e(this,{options:n,placeholder:"Select a remote"}).openAndGetResult();i&&await this.gitManager.removeRemote(i)}handleViewActiveState(n){var a,s;if(!(n!=null&&n.view.getState().file))return;let r=this.app.workspace.getLeavesOfType(pt.type).first(),i=this.app.workspace.getLeavesOfType(nn.type).first();if((a=r==null?void 0:r.view.containerEl.querySelector("div.nav-file-title.is-active"))==null||a.removeClass("is-active"),(s=i==null?void 0:i.view.containerEl.querySelector("div.nav-file-title.is-active"))==null||s.removeClass("is-active"),(n==null?void 0:n.view)instanceof va){let o=n.view.state.file;this.lastDiffViewState=n.view.getState();let l;r&&n.view.state.staged?l=r.view.containerEl.querySelector(`div.staged div.nav-file-title[data-path='${o}']`):r&&n.view.state.staged===!1&&!n.view.state.hash?l=r.view.containerEl.querySelector(`div.changes div.nav-file-title[data-path='${o}']`):i&&n.view.state.hash&&(l=i.view.containerEl.querySelector(`div.nav-file-title[data-path='${o}']`)),l==null||l.addClass("is-active")}else this.lastDiffViewState=void 0}handleNoNetworkError(n){this.state.offlineMode?this.log("Encountered network error, but already in offline mode"):this.displayError("Git: Going into offline mode. Future network errors will no longer be displayed.",2e3),this.setPluginState({gitAction:0,offlineMode:!0})}displayMessage(n,r=4*1e3){var i;(i=this.statusBar)==null||i.displayMessage(n.toLowerCase(),r),this.settings.disablePopups||(!this.settings.disablePopupsForNoChanges||!n.startsWith("No changes"))&&new _e.Notice(n,5*1e3),this.log(n)}displayError(n,r=10*1e3){var a;if(n instanceof ps.UserCanceledError){new _e.Notice("Aborted");return}let i;n instanceof Error?i=n:i=new Error(String(n)),this.setPluginState({gitAction:0}),new _e.Notice(i.message,r),console.error(`${this.manifest.id}:`,i.stack),(a=this.statusBar)==null||a.displayMessage(i.message.toLowerCase(),r)}log(...n){console.log(`${this.manifest.id}:`,...n)}};
2023-03-23 18:09:10 +00:00
/*! Bundled license information:
ieee754/index.js:
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
buffer/index.js:
(*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*)
safe-buffer/index.js:
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
crc-32/crc32.js:
(*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
2023-05-23 21:59:22 +00:00
js-sha256/src/sha256.js:
(**
* [js-sha256]{@link https://github.com/emn178/js-sha256}
*
* @version 0.9.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2017
* @license MIT
*)
2023-03-23 18:09:10 +00:00
feather-icons/dist/feather.js:
(*!
Copyright (c) 2016 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*)
2022-09-04 12:54:22 +00:00
*/
2024-12-09 19:19:31 +00:00
/* nosourcemap */