112 lines
203 KiB
JavaScript
112 lines
203 KiB
JavaScript
/* obsidian-multisync */
|
|
var Wu=Object.create;var Ir=Object.defineProperty;var Vu=Object.getOwnPropertyDescriptor;var Xu=Object.getOwnPropertyNames;var Yu=Object.getPrototypeOf,Ku=Object.prototype.hasOwnProperty;var O=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Qu=(t,e)=>{for(var r in e)Ir(t,r,{get:e[r],enumerable:!0})},Ja=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xu(e))!Ku.call(t,n)&&n!==r&&Ir(t,n,{get:()=>e[n],enumerable:!(i=Vu(e,n))||i.enumerable});return t};var Gt=(t,e,r)=>(r=t!=null?Wu(Yu(t)):{},Ja(e||!t||!t.__esModule?Ir(r,"default",{value:t,enumerable:!0}):r,t)),Ju=t=>Ja(Ir({},"__esModule",{value:!0}),t);var ho=O((fg,uo)=>{"use strict";var lt=function(t){if(t=t||{},this.Promise=t.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=t.domainReentrant||!1,this.domainReentrant){if(typeof process=="undefined"||typeof process.domain=="undefined")throw new Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=t.timeout||lt.DEFAULT_TIMEOUT,this.maxOccupationTime=t.maxOccupationTime||lt.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=t.maxExecutionTime||lt.DEFAULT_MAX_EXECUTION_TIME,t.maxPending===1/0||Number.isInteger(t.maxPending)&&t.maxPending>=0?this.maxPending=t.maxPending:this.maxPending=lt.DEFAULT_MAX_PENDING};lt.DEFAULT_TIMEOUT=0;lt.DEFAULT_MAX_OCCUPATION_TIME=0;lt.DEFAULT_MAX_EXECUTION_TIME=0;lt.DEFAULT_MAX_PENDING=1e3;lt.prototype.acquire=function(t,e,r,i){if(Array.isArray(t))return this._acquireBatch(t,e,r,i);if(typeof e!="function")throw new Error("You must pass a function to execute");var n=null,a=null,o=null;typeof r!="function"&&(i=r,r=null,o=new this.Promise(function(v,k){n=v,a=k})),i=i||{};var s=!1,l=null,c=null,f=null,d=this,u=function(v,k,S){c&&(clearTimeout(c),c=null),f&&(clearTimeout(f),f=null),v&&(d.queues[t]&&d.queues[t].length===0&&delete d.queues[t],d.domainReentrant&&delete d.domains[t]),s||(o?k?a(k):n(S):typeof r=="function"&&r(k,S),s=!0),v&&d.queues[t]&&d.queues[t].length>0&&d.queues[t].shift()()},h=function(v){if(s)return u(v);l&&(clearTimeout(l),l=null),d.domainReentrant&&v&&(d.domains[t]=process.domain);var k=i.maxExecutionTime||d.maxExecutionTime;if(k&&(f=setTimeout(function(){d.queues[t]&&u(v,new Error("Maximum execution time is exceeded "+t))},k)),e.length===1){var S=!1;try{e(function(x,T){S||(S=!0,u(v,x,T))})}catch(x){S||(S=!0,u(v,x))}}else d._promiseTry(function(){return e()}).then(function(x){u(v,void 0,x)},function(x){u(v,x)})};d.domainReentrant&&process.domain&&(h=process.domain.bind(h));var m=i.maxPending||d.maxPending;if(!d.queues[t])d.queues[t]=[],h(!0);else if(d.domainReentrant&&process.domain&&process.domain===d.domains[t])h(!1);else if(d.queues[t].length>=m)u(!1,new Error("Too many pending tasks in queue "+t));else{var g=function(){h(!0)};i.skipQueue?d.queues[t].unshift(g):d.queues[t].push(g);var y=i.timeout||d.timeout;y&&(l=setTimeout(function(){l=null,u(!1,new Error("async-lock timed out in queue "+t))},y))}var b=i.maxOccupationTime||d.maxOccupationTime;if(b&&(c=setTimeout(function(){d.queues[t]&&u(!1,new Error("Maximum occupation time is exceeded in queue "+t))},b)),o)return o};lt.prototype._acquireBatch=function(t,e,r,i){typeof r!="function"&&(i=r,r=null);var n=this,a=function(s,l){return function(c){n.acquire(s,l,c,i)}},o=t.reduceRight(function(s,l){return a(l,s)},e);if(typeof r=="function")o(r);else return new this.Promise(function(s,l){o.length===1?o(function(c,f){c?l(c):s(f)}):s(o())})};lt.prototype.isBusy=function(t){return t?!!this.queues[t]:Object.keys(this.queues).length>0};lt.prototype._promiseTry=function(t){try{return this.Promise.resolve(t())}catch(e){return this.Promise.reject(e)}};uo.exports=lt});var wo=O((lg,po)=>{"use strict";po.exports=ho()});var mo=O((ug,cn)=>{typeof Object.create=="function"?cn.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:cn.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}}});var Ur=O((fn,yo)=>{var Fr=require("buffer"),$t=Fr.Buffer;function go(t,e){for(var r in t)e[r]=t[r]}$t.from&&$t.alloc&&$t.allocUnsafe&&$t.allocUnsafeSlow?yo.exports=Fr:(go(Fr,fn),fn.Buffer=ee);function ee(t,e,r){return $t(t,e,r)}ee.prototype=Object.create($t.prototype);go($t,ee);ee.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return $t(t,e,r)};ee.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var i=$t(t);return e!==void 0?typeof r=="string"?i.fill(e,r):i.fill(e):i.fill(0),i};ee.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return $t(t)};ee.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Fr.SlowBuffer(t)}});var _o=O((dg,bo)=>{var ed={}.toString;bo.exports=Array.isArray||function(t){return ed.call(t)=="[object Array]"}});var ye=O((hg,vo)=>{"use strict";vo.exports=TypeError});var ln=O((pg,xo)=>{"use strict";xo.exports=Object});var So=O((wg,Eo)=>{"use strict";Eo.exports=Error});var Ao=O((mg,ko)=>{"use strict";ko.exports=EvalError});var $o=O((gg,To)=>{"use strict";To.exports=RangeError});var Ro=O((yg,Oo)=>{"use strict";Oo.exports=ReferenceError});var un=O((bg,Io)=>{"use strict";Io.exports=SyntaxError});var Co=O((_g,Po)=>{"use strict";Po.exports=URIError});var Do=O((vg,Bo)=>{"use strict";Bo.exports=Math.abs});var Fo=O((xg,No)=>{"use strict";No.exports=Math.floor});var jo=O((Eg,Uo)=>{"use strict";Uo.exports=Math.max});var zo=O((Sg,Mo)=>{"use strict";Mo.exports=Math.min});var Ho=O((kg,Lo)=>{"use strict";Lo.exports=Math.pow});var qo=O((Ag,Go)=>{"use strict";Go.exports=Math.round});var Wo=O((Tg,Zo)=>{"use strict";Zo.exports=Number.isNaN||function(e){return e!==e}});var Xo=O(($g,Vo)=>{"use strict";var rd=Wo();Vo.exports=function(e){return rd(e)||e===0?e:e<0?-1:1}});var Ko=O((Og,Yo)=>{"use strict";Yo.exports=Object.getOwnPropertyDescriptor});var be=O((Rg,Qo)=>{"use strict";var jr=Ko();if(jr)try{jr([],"length")}catch(t){jr=null}Qo.exports=jr});var Xe=O((Ig,Jo)=>{"use strict";var Mr=Object.defineProperty||!1;if(Mr)try{Mr({},"a",{value:1})}catch(t){Mr=!1}Jo.exports=Mr});var dn=O((Pg,ts)=>{"use strict";ts.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),i=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var n=42;e[r]=n;for(var a in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(e,r);if(s.value!==n||s.enumerable!==!0)return!1}return!0}});var is=O((Cg,rs)=>{"use strict";var es=typeof Symbol!="undefined"&&Symbol,id=dn();rs.exports=function(){return typeof es!="function"||typeof Symbol!="function"||typeof es("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:id()}});var hn=O((Bg,ns)=>{"use strict";ns.exports=typeof Reflect!="undefined"&&Reflect.getPrototypeOf||null});var pn=O((Dg,as)=>{"use strict";var nd=ln();as.exports=nd.getPrototypeOf||null});var cs=O((Ng,ss)=>{"use strict";var ad="Function.prototype.bind called on incompatible ",od=Object.prototype.toString,sd=Math.max,cd="[object Function]",os=function(e,r){for(var i=[],n=0;n<e.length;n+=1)i[n]=e[n];for(var a=0;a<r.length;a+=1)i[a+e.length]=r[a];return i},fd=function(e,r){for(var i=[],n=r||0,a=0;n<e.length;n+=1,a+=1)i[a]=e[n];return i},ld=function(t,e){for(var r="",i=0;i<t.length;i+=1)r+=t[i],i+1<t.length&&(r+=e);return r};ss.exports=function(e){var r=this;if(typeof r!="function"||od.apply(r)!==cd)throw new TypeError(ad+r);for(var i=fd(arguments,1),n,a=function(){if(this instanceof n){var f=r.apply(this,os(i,arguments));return Object(f)===f?f:this}return r.apply(e,os(i,arguments))},o=sd(0,r.length-i.length),s=[],l=0;l<o;l++)s[l]="$"+l;if(n=Function("binder","return function ("+ld(s,",")+"){ return binder.apply(this,arguments); }")(a),r.prototype){var c=function(){};c.prototype=r.prototype,n.prototype=new c,c.prototype=null}return n}});var _e=O((Fg,fs)=>{"use strict";var ud=cs();fs.exports=Function.prototype.bind||ud});var zr=O((Ug,ls)=>{"use strict";ls.exports=Function.prototype.call});var Lr=O((jg,us)=>{"use strict";us.exports=Function.prototype.apply});var hs=O((Mg,ds)=>{"use strict";ds.exports=typeof Reflect!="undefined"&&Reflect&&Reflect.apply});var wn=O((zg,ps)=>{"use strict";var dd=_e(),hd=Lr(),pd=zr(),wd=hs();ps.exports=wd||dd.call(pd,hd)});var Hr=O((Lg,ws)=>{"use strict";var md=_e(),gd=ye(),yd=zr(),bd=wn();ws.exports=function(e){if(e.length<1||typeof e[0]!="function")throw new gd("a function is required");return bd(md,yd,e)}});var vs=O((Hg,_s)=>{"use strict";var _d=Hr(),ms=be(),ys;try{ys=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var mn=!!ys&&ms&&ms(Object.prototype,"__proto__"),bs=Object,gs=bs.getPrototypeOf;_s.exports=mn&&typeof mn.get=="function"?_d([mn.get]):typeof gs=="function"?function(e){return gs(e==null?e:bs(e))}:!1});var gn=O((Gg,ks)=>{"use strict";var xs=hn(),Es=pn(),Ss=vs();ks.exports=xs?function(e){return xs(e)}:Es?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Es(e)}:Ss?function(e){return Ss(e)}:null});var Ts=O((qg,As)=>{"use strict";var vd=Function.prototype.call,xd=Object.prototype.hasOwnProperty,Ed=_e();As.exports=Ed.call(vd,xd)});var _n=O((Zg,Cs)=>{"use strict";var N,Sd=ln(),kd=So(),Ad=Ao(),Td=$o(),$d=Ro(),Se=un(),Ee=ye(),Od=Co(),Rd=Do(),Id=Fo(),Pd=jo(),Cd=zo(),Bd=Ho(),Dd=qo(),Nd=Xo(),Is=Function,yn=function(t){try{return Is('"use strict"; return ('+t+").constructor;")()}catch(e){}},Ye=be(),Fd=Xe(),bn=function(){throw new Ee},Ud=Ye?function(){try{return arguments.callee,bn}catch(t){try{return Ye(arguments,"callee").get}catch(e){return bn}}}():bn,ve=is()(),V=gn(),jd=pn(),Md=hn(),Ps=Lr(),Ke=zr(),xe={},zd=typeof Uint8Array=="undefined"||!V?N:V(Uint8Array),re={__proto__:null,"%AggregateError%":typeof AggregateError=="undefined"?N:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?N:ArrayBuffer,"%ArrayIteratorPrototype%":ve&&V?V([][Symbol.iterator]()):N,"%AsyncFromSyncIteratorPrototype%":N,"%AsyncFunction%":xe,"%AsyncGenerator%":xe,"%AsyncGeneratorFunction%":xe,"%AsyncIteratorPrototype%":xe,"%Atomics%":typeof Atomics=="undefined"?N:Atomics,"%BigInt%":typeof BigInt=="undefined"?N:BigInt,"%BigInt64Array%":typeof BigInt64Array=="undefined"?N:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array=="undefined"?N:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?N:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":kd,"%eval%":eval,"%EvalError%":Ad,"%Float16Array%":typeof Float16Array=="undefined"?N:Float16Array,"%Float32Array%":typeof Float32Array=="undefined"?N:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?N:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?N:FinalizationRegistry,"%Function%":Is,"%GeneratorFunction%":xe,"%Int8Array%":typeof Int8Array=="undefined"?N:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?N:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?N:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ve&&V?V(V([][Symbol.iterator]())):N,"%JSON%":typeof JSON=="object"?JSON:N,"%Map%":typeof Map=="undefined"?N:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!ve||!V?N:V(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Sd,"%Object.getOwnPropertyDescriptor%":Ye,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?N:Promise,"%Proxy%":typeof Proxy=="undefined"?N:Proxy,"%RangeError%":Td,"%ReferenceError%":$d,"%Reflect%":typeof Reflect=="undefined"?N:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?N:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!ve||!V?N:V(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?N:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ve&&V?V(""[Symbol.iterator]()):N,"%Symbol%":ve?Symbol:N,"%SyntaxError%":Se,"%ThrowTypeError%":Ud,"%TypedArray%":zd,"%TypeError%":Ee,"%Uint8Array%":typeof Uint8Array=="undefined"?N:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?N:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?N:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?N:Uint32Array,"%URIError%":Od,"%WeakMap%":typeof WeakMap=="undefined"?N:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?N:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?N:WeakSet,"%Function.prototype.call%":Ke,"%Function.prototype.apply%":Ps,"%Object.defineProperty%":Fd,"%Object.getPrototypeOf%":jd,"%Math.abs%":Rd,"%Math.floor%":Id,"%Math.max%":Pd,"%Math.min%":Cd,"%Math.pow%":Bd,"%Math.round%":Dd,"%Math.sign%":Nd,"%Reflect.getPrototypeOf%":Md};if(V)try{null.error}catch(t){$s=V(V(t)),re["%Error.prototype%"]=$s}var $s,Ld=function t(e){var r;if(e==="%AsyncFunction%")r=yn("async function () {}");else if(e==="%GeneratorFunction%")r=yn("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=yn("async function* () {}");else if(e==="%AsyncGenerator%"){var i=t("%AsyncGeneratorFunction%");i&&(r=i.prototype)}else if(e==="%AsyncIteratorPrototype%"){var n=t("%AsyncGenerator%");n&&V&&(r=V(n.prototype))}return re[e]=r,r},Os={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Qe=_e(),Gr=Ts(),Hd=Qe.call(Ke,Array.prototype.concat),Gd=Qe.call(Ps,Array.prototype.splice),Rs=Qe.call(Ke,String.prototype.replace),qr=Qe.call(Ke,String.prototype.slice),qd=Qe.call(Ke,RegExp.prototype.exec),Zd=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Wd=/\\(\\)?/g,Vd=function(e){var r=qr(e,0,1),i=qr(e,-1);if(r==="%"&&i!=="%")throw new Se("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&r!=="%")throw new Se("invalid intrinsic syntax, expected opening `%`");var n=[];return Rs(e,Zd,function(a,o,s,l){n[n.length]=s?Rs(l,Wd,"$1"):o||a}),n},Xd=function(e,r){var i=e,n;if(Gr(Os,i)&&(n=Os[i],i="%"+n[0]+"%"),Gr(re,i)){var a=re[i];if(a===xe&&(a=Ld(i)),typeof a=="undefined"&&!r)throw new Ee("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:i,value:a}}throw new Se("intrinsic "+e+" does not exist!")};Cs.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new Ee("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Ee('"allowMissing" argument must be a boolean');if(qd(/^%?[^%]*%?$/,e)===null)throw new Se("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=Vd(e),n=i.length>0?i[0]:"",a=Xd("%"+n+"%",r),o=a.name,s=a.value,l=!1,c=a.alias;c&&(n=c[0],Gd(i,Hd([0,1],c)));for(var f=1,d=!0;f<i.length;f+=1){var u=i[f],h=qr(u,0,1),m=qr(u,-1);if((h==='"'||h==="'"||h==="`"||m==='"'||m==="'"||m==="`")&&h!==m)throw new Se("property names with quotes must have matching quotes");if((u==="constructor"||!d)&&(l=!0),n+="."+u,o="%"+n+"%",Gr(re,o))s=re[o];else if(s!=null){if(!(u in s)){if(!r)throw new Ee("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ye&&f+1>=i.length){var g=Ye(s,u);d=!!g,d&&"get"in g&&!("originalValue"in g.get)?s=g.get:s=s[u]}else d=Gr(s,u),s=s[u];d&&!l&&(re[o]=s)}}return s}});var vn=O((Wg,Ns)=>{"use strict";var Bs=_n(),Ds=Hr(),Yd=Ds([Bs("%String.prototype.indexOf%")]);Ns.exports=function(e,r){var i=Bs(e,!!r);return typeof i=="function"&&Yd(e,".prototype.")>-1?Ds([i]):i}});var Ms=O((Vg,js)=>{"use strict";var Us=Function.prototype.toString,ke=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,En,Zr;if(typeof ke=="function"&&typeof Object.defineProperty=="function")try{En=Object.defineProperty({},"length",{get:function(){throw Zr}}),Zr={},ke(function(){throw 42},null,En)}catch(t){t!==Zr&&(ke=null)}else ke=null;var Kd=/^\s*class\b/,Sn=function(e){try{var r=Us.call(e);return Kd.test(r)}catch(i){return!1}},xn=function(e){try{return Sn(e)?!1:(Us.call(e),!0)}catch(r){return!1}},Wr=Object.prototype.toString,Qd="[object Object]",Jd="[object Function]",th="[object GeneratorFunction]",eh="[object HTMLAllCollection]",rh="[object HTML document.all class]",ih="[object HTMLCollection]",nh=typeof Symbol=="function"&&!!Symbol.toStringTag,ah=!(0 in[,]),kn=function(){return!1};typeof document=="object"&&(Fs=document.all,Wr.call(Fs)===Wr.call(document.all)&&(kn=function(e){if((ah||!e)&&(typeof e=="undefined"||typeof e=="object"))try{var r=Wr.call(e);return(r===eh||r===rh||r===ih||r===Qd)&&e("")==null}catch(i){}return!1}));var Fs;js.exports=ke?function(e){if(kn(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{ke(e,null,En)}catch(r){if(r!==Zr)return!1}return!Sn(e)&&xn(e)}:function(e){if(kn(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(nh)return xn(e);if(Sn(e))return!1;var r=Wr.call(e);return r!==Jd&&r!==th&&!/^\[object HTML/.test(r)?!1:xn(e)}});var Hs=O((Xg,Ls)=>{"use strict";var oh=Ms(),sh=Object.prototype.toString,zs=Object.prototype.hasOwnProperty,ch=function(e,r,i){for(var n=0,a=e.length;n<a;n++)zs.call(e,n)&&(i==null?r(e[n],n,e):r.call(i,e[n],n,e))},fh=function(e,r,i){for(var n=0,a=e.length;n<a;n++)i==null?r(e.charAt(n),n,e):r.call(i,e.charAt(n),n,e)},lh=function(e,r,i){for(var n in e)zs.call(e,n)&&(i==null?r(e[n],n,e):r.call(i,e[n],n,e))};function uh(t){return sh.call(t)==="[object Array]"}Ls.exports=function(e,r,i){if(!oh(r))throw new TypeError("iterator must be a function");var n;arguments.length>=3&&(n=i),uh(e)?ch(e,r,n):typeof e=="string"?fh(e,r,n):lh(e,r,n)}});var qs=O((Yg,Gs)=>{"use strict";Gs.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var Ws=O((Kg,Zs)=>{"use strict";var An=qs(),dh=typeof globalThis=="undefined"?global:globalThis;Zs.exports=function(){for(var e=[],r=0;r<An.length;r++)typeof dh[An[r]]=="function"&&(e[e.length]=An[r]);return e}});var Ks=O((Qg,Ys)=>{"use strict";var Vs=Xe(),hh=un(),Ae=ye(),Xs=be();Ys.exports=function(e,r,i){if(!e||typeof e!="object"&&typeof e!="function")throw new Ae("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Ae("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Ae("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Ae("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Ae("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Ae("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,a=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,s=arguments.length>6?arguments[6]:!1,l=!!Xs&&Xs(e,r);if(Vs)Vs(e,r,{configurable:o===null&&l?l.configurable:!o,enumerable:n===null&&l?l.enumerable:!n,value:i,writable:a===null&&l?l.writable:!a});else if(s||!n&&!a&&!o)e[r]=i;else throw new hh("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var tc=O((Jg,Js)=>{"use strict";var Tn=Xe(),Qs=function(){return!!Tn};Qs.hasArrayLengthDefineBug=function(){if(!Tn)return null;try{return Tn([],"length",{value:1}).length!==1}catch(e){return!0}};Js.exports=Qs});var ac=O((ty,nc)=>{"use strict";var ph=_n(),ec=Ks(),wh=tc()(),rc=be(),ic=ye(),mh=ph("%Math.floor%");nc.exports=function(e,r){if(typeof e!="function")throw new ic("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||mh(r)!==r)throw new ic("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],n=!0,a=!0;if("length"in e&&rc){var o=rc(e,"length");o&&!o.configurable&&(n=!1),o&&!o.writable&&(a=!1)}return(n||a||!i)&&(wh?ec(e,"length",r,!0,!0):ec(e,"length",r)),e}});var sc=O((ey,oc)=>{"use strict";var gh=_e(),yh=Lr(),bh=wn();oc.exports=function(){return bh(gh,yh,arguments)}});var lc=O((ry,Vr)=>{"use strict";var _h=ac(),cc=Xe(),vh=Hr(),fc=sc();Vr.exports=function(e){var r=vh(arguments),i=1+e.length-(arguments.length-1);return _h(r,i>0?i:0,!0)};cc?cc(Vr.exports,"apply",{value:fc}):Vr.exports.apply=fc});var dc=O((iy,uc)=>{"use strict";var xh=dn();uc.exports=function(){return xh()&&!!Symbol.toStringTag}});var gc=O((ny,mc)=>{"use strict";var Kr=Hs(),Eh=Ws(),hc=lc(),On=vn(),Yr=be(),Xr=gn(),Sh=On("Object.prototype.toString"),wc=dc()(),pc=typeof globalThis=="undefined"?global:globalThis,$n=Eh(),Rn=On("String.prototype.slice"),kh=On("Array.prototype.indexOf",!0)||function(e,r){for(var i=0;i<e.length;i+=1)if(e[i]===r)return i;return-1},Qr={__proto__:null};wc&&Yr&&Xr?Kr($n,function(t){var e=new pc[t];if(Symbol.toStringTag in e&&Xr){var r=Xr(e),i=Yr(r,Symbol.toStringTag);if(!i&&r){var n=Xr(r);i=Yr(n,Symbol.toStringTag)}if(i&&i.get){var a=hc(i.get);Qr["$"+t]=a}}}):Kr($n,function(t){var e=new pc[t],r=e.slice||e.set;if(r){var i=hc(r);Qr["$"+t]=i}});var Ah=function(e){var r=!1;return Kr(Qr,function(i,n){if(!r)try{"$"+i(e)===n&&(r=Rn(n,1))}catch(a){}}),r},Th=function(e){var r=!1;return Kr(Qr,function(i,n){if(!r)try{i(e),r=Rn(n,1)}catch(a){}}),r};mc.exports=function(e){if(!e||typeof e!="object")return!1;if(!wc){var r=Rn(Sh(e),8,-1);return kh($n,r)>-1?r:r!=="Object"?!1:Th(e)}return Yr?Ah(e):null}});var bc=O((ay,yc)=>{"use strict";var $h=gc();yc.exports=function(e){return!!$h(e)}});var vc=O((oy,_c)=>{"use strict";var Oh=ye(),Rh=vn(),Ih=Rh("TypedArray.prototype.buffer",!0),Ph=bc();_c.exports=Ih||function(e){if(!Ph(e))throw new Oh("Not a Typed Array");return e.buffer}});var Sc=O((sy,Ec)=>{"use strict";var vt=Ur().Buffer,Ch=_o(),Bh=vc(),Dh=ArrayBuffer.isView||function(e){try{return Bh(e),!0}catch(r){return!1}},Nh=typeof Uint8Array!="undefined",xc=typeof ArrayBuffer!="undefined"&&typeof Uint8Array!="undefined",Fh=xc&&(vt.prototype instanceof Uint8Array||vt.TYPED_ARRAY_SUPPORT);Ec.exports=function(e,r){if(vt.isBuffer(e))return e.constructor&&!("isBuffer"in e)?vt.from(e):e;if(typeof e=="string")return vt.from(e,r);if(xc&&Dh(e)){if(e.byteLength===0)return vt.alloc(0);if(Fh){var i=vt.from(e.buffer,e.byteOffset,e.byteLength);if(i.byteLength===e.byteLength)return i}var n=e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=vt.from(n);if(a.length===e.byteLength)return a}if(Nh&&e instanceof Uint8Array)return vt.from(e);var o=Ch(e);if(o)for(var s=0;s<e.length;s+=1){var l=e[s];if(typeof l!="number"||l<0||l>255||~~l!==l)throw new RangeError("Array items must be numbers in the range 0-255.")}if(o||vt.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return vt.from(e);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var Ac=O((cy,kc)=>{"use strict";var Uh=Ur().Buffer,jh=Sc();function Jr(t,e){this._block=Uh.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}Jr.prototype.update=function(t,e){t=jh(t,e||"utf8");for(var r=this._block,i=this._blockSize,n=t.length,a=this._len,o=0;o<n;){for(var s=a%i,l=Math.min(n-o,i-s),c=0;c<l;c++)r[s+c]=t[o+c];a+=l,o+=l,a%i===0&&this._update(r)}return this._len+=n,this};Jr.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(r&4294967295)>>>0,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var a=this._hash();return t?a.toString(t):a};Jr.prototype._update=function(){throw new Error("_update must be implemented by subclass")};kc.exports=Jr});var Oc=O((fy,$c)=>{"use strict";var Mh=mo(),Tc=Ac(),zh=Ur().Buffer,Lh=[1518500249,1859775393,-1894007588,-899497514],Hh=new Array(80);function Je(){this.init(),this._w=Hh,Tc.call(this,64,56)}Mh(Je,Tc);Je.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Gh(t){return t<<1|t>>>31}function qh(t){return t<<5|t>>>27}function Zh(t){return t<<30|t>>>2}function Wh(t,e,r,i){return t===0?e&r|~e&i:t===2?e&r|e&i|r&i:e^r^i}Je.prototype._update=function(t){for(var e=this._w,r=this._a|0,i=this._b|0,n=this._c|0,a=this._d|0,o=this._e|0,s=0;s<16;++s)e[s]=t.readInt32BE(s*4);for(;s<80;++s)e[s]=Gh(e[s-3]^e[s-8]^e[s-14]^e[s-16]);for(var l=0;l<80;++l){var c=~~(l/20),f=qh(r)+Wh(c,i,n,a)+o+e[l]+Lh[c]|0;o=a,a=n,n=Zh(i),i=r,r=f}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=a+this._d|0,this._e=o+this._e|0};Je.prototype._hash=function(){var t=zh.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};$c.exports=Je});var Ic=O(In=>{var Rc;(function(t){typeof DO_NOT_EXPORT_CRC=="undefined"?typeof In=="object"?t(In):typeof define=="function"&&define.amd?define(function(){var e={};return t(e),e}):t(Rc={}):t(Rc={})})(function(t){t.version="1.2.2";function e(){for(var p=0,_=new Array(256),w=0;w!=256;++w)p=w,p=p&1?-306674912^p>>>1:p>>>1,p=p&1?-306674912^p>>>1:p>>>1,p=p&1?-306674912^p>>>1:p>>>1,p=p&1?-306674912^p>>>1:p>>>1,p=p&1?-306674912^p>>>1:p>>>1,p=p&1?-306674912^p>>>1:p>>>1,p=p&1?-306674912^p>>>1:p>>>1,p=p&1?-306674912^p>>>1:p>>>1,_[w]=p;return typeof Int32Array!="undefined"?new Int32Array(_):_}var r=e();function i(p){var _=0,w=0,A=0,E=typeof Int32Array!="undefined"?new Int32Array(4096):new Array(4096);for(A=0;A!=256;++A)E[A]=p[A];for(A=0;A!=256;++A)for(w=p[A],_=256+A;_<4096;_+=256)w=E[_]=w>>>8^p[w&255];var $=[];for(A=1;A!=16;++A)$[A-1]=typeof Int32Array!="undefined"?E.subarray(A*256,A*256+256):E.slice(A*256,A*256+256);return $}var n=i(r),a=n[0],o=n[1],s=n[2],l=n[3],c=n[4],f=n[5],d=n[6],u=n[7],h=n[8],m=n[9],g=n[10],y=n[11],b=n[12],v=n[13],k=n[14];function S(p,_){for(var w=_^-1,A=0,E=p.length;A<E;)w=w>>>8^r[(w^p.charCodeAt(A++))&255];return~w}function x(p,_){for(var w=_^-1,A=p.length-15,E=0;E<A;)w=k[p[E++]^w&255]^v[p[E++]^w>>8&255]^b[p[E++]^w>>16&255]^y[p[E++]^w>>>24]^g[p[E++]]^m[p[E++]]^h[p[E++]]^u[p[E++]]^d[p[E++]]^f[p[E++]]^c[p[E++]]^l[p[E++]]^s[p[E++]]^o[p[E++]]^a[p[E++]]^r[p[E++]];for(A+=15;E<A;)w=w>>>8^r[(w^p[E++])&255];return~w}function T(p,_){for(var w=_^-1,A=0,E=p.length,$=0,R=0;A<E;)$=p.charCodeAt(A++),$<128?w=w>>>8^r[(w^$)&255]:$<2048?(w=w>>>8^r[(w^(192|$>>6&31))&255],w=w>>>8^r[(w^(128|$&63))&255]):$>=55296&&$<57344?($=($&1023)+64,R=p.charCodeAt(A++)&1023,w=w>>>8^r[(w^(240|$>>8&7))&255],w=w>>>8^r[(w^(128|$>>2&63))&255],w=w>>>8^r[(w^(128|R>>6&15|($&3)<<4))&255],w=w>>>8^r[(w^(128|R&63))&255]):(w=w>>>8^r[(w^(224|$>>12&15))&255],w=w>>>8^r[(w^(128|$>>6&63))&255],w=w>>>8^r[(w^(128|$&63))&255]);return~w}t.table=r,t.bstr=S,t.buf=x,t.str=T})});var Ft=O(et=>{"use strict";var Vh=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Int32Array!="undefined";function Xh(t,e){return Object.prototype.hasOwnProperty.call(t,e)}et.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(var i in r)Xh(r,i)&&(t[i]=r[i])}}return t};et.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var Yh={arraySet:function(t,e,r,i,n){if(e.subarray&&t.subarray){t.set(e.subarray(r,r+i),n);return}for(var a=0;a<i;a++)t[n+a]=e[r+a]},flattenChunks:function(t){var e,r,i,n,a,o;for(i=0,e=0,r=t.length;e<r;e++)i+=t[e].length;for(o=new Uint8Array(i),n=0,e=0,r=t.length;e<r;e++)a=t[e],o.set(a,n),n+=a.length;return o}},Kh={arraySet:function(t,e,r,i,n){for(var a=0;a<i;a++)t[n+a]=e[r+a]},flattenChunks:function(t){return[].concat.apply([],t)}};et.setTyped=function(t){t?(et.Buf8=Uint8Array,et.Buf16=Uint16Array,et.Buf32=Int32Array,et.assign(et,Yh)):(et.Buf8=Array,et.Buf16=Array,et.Buf32=Array,et.assign(et,Kh))};et.setTyped(Vh)});var tf=O(Oe=>{"use strict";var Qh=Ft(),Jh=4,Pc=0,Cc=1,tp=2;function $e(t){for(var e=t.length;--e>=0;)t[e]=0}var ep=0,jc=1,rp=2,ip=3,np=258,Un=29,ar=256,er=ar+1+Un,Te=30,jn=19,Mc=2*er+1,ie=15,Pn=16,ap=7,Mn=256,zc=16,Lc=17,Hc=18,Nn=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ti=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],op=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Gc=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],sp=512,Ut=new Array((er+2)*2);$e(Ut);var tr=new Array(Te*2);$e(tr);var rr=new Array(sp);$e(rr);var ir=new Array(np-ip+1);$e(ir);var zn=new Array(Un);$e(zn);var ei=new Array(Te);$e(ei);function Cn(t,e,r,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}var qc,Zc,Wc;function Bn(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function Vc(t){return t<256?rr[t]:rr[256+(t>>>7)]}function nr(t,e){t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255}function st(t,e,r){t.bi_valid>Pn-r?(t.bi_buf|=e<<t.bi_valid&65535,nr(t,t.bi_buf),t.bi_buf=e>>Pn-t.bi_valid,t.bi_valid+=r-Pn):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function Ot(t,e,r){st(t,r[e*2],r[e*2+1])}function Xc(t,e){var r=0;do r|=t&1,t>>>=1,r<<=1;while(--e>0);return r>>>1}function cp(t){t.bi_valid===16?(nr(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)}function fp(t,e){var r=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,l=e.stat_desc.max_length,c,f,d,u,h,m,g=0;for(u=0;u<=ie;u++)t.bl_count[u]=0;for(r[t.heap[t.heap_max]*2+1]=0,c=t.heap_max+1;c<Mc;c++)f=t.heap[c],u=r[r[f*2+1]*2+1]+1,u>l&&(u=l,g++),r[f*2+1]=u,!(f>i)&&(t.bl_count[u]++,h=0,f>=s&&(h=o[f-s]),m=r[f*2],t.opt_len+=m*(u+h),a&&(t.static_len+=m*(n[f*2+1]+h)));if(g!==0){do{for(u=l-1;t.bl_count[u]===0;)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[l]--,g-=2}while(g>0);for(u=l;u!==0;u--)for(f=t.bl_count[u];f!==0;)d=t.heap[--c],!(d>i)&&(r[d*2+1]!==u&&(t.opt_len+=(u-r[d*2+1])*r[d*2],r[d*2+1]=u),f--)}}function Yc(t,e,r){var i=new Array(ie+1),n=0,a,o;for(a=1;a<=ie;a++)i[a]=n=n+r[a-1]<<1;for(o=0;o<=e;o++){var s=t[o*2+1];s!==0&&(t[o*2]=Xc(i[s]++,s))}}function lp(){var t,e,r,i,n,a=new Array(ie+1);for(r=0,i=0;i<Un-1;i++)for(zn[i]=r,t=0;t<1<<Nn[i];t++)ir[r++]=i;for(ir[r-1]=i,n=0,i=0;i<16;i++)for(ei[i]=n,t=0;t<1<<ti[i];t++)rr[n++]=i;for(n>>=7;i<Te;i++)for(ei[i]=n<<7,t=0;t<1<<ti[i]-7;t++)rr[256+n++]=i;for(e=0;e<=ie;e++)a[e]=0;for(t=0;t<=143;)Ut[t*2+1]=8,t++,a[8]++;for(;t<=255;)Ut[t*2+1]=9,t++,a[9]++;for(;t<=279;)Ut[t*2+1]=7,t++,a[7]++;for(;t<=287;)Ut[t*2+1]=8,t++,a[8]++;for(Yc(Ut,er+1,a),t=0;t<Te;t++)tr[t*2+1]=5,tr[t*2]=Xc(t,5);qc=new Cn(Ut,Nn,ar+1,er,ie),Zc=new Cn(tr,ti,0,Te,ie),Wc=new Cn(new Array(0),op,0,jn,ap)}function Kc(t){var e;for(e=0;e<er;e++)t.dyn_ltree[e*2]=0;for(e=0;e<Te;e++)t.dyn_dtree[e*2]=0;for(e=0;e<jn;e++)t.bl_tree[e*2]=0;t.dyn_ltree[Mn*2]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function Qc(t){t.bi_valid>8?nr(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function up(t,e,r,i){Qc(t),i&&(nr(t,r),nr(t,~r)),Qh.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}function Bc(t,e,r,i){var n=e*2,a=r*2;return t[n]<t[a]||t[n]===t[a]&&i[e]<=i[r]}function Dn(t,e,r){for(var i=t.heap[r],n=r<<1;n<=t.heap_len&&(n<t.heap_len&&Bc(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!Bc(e,i,t.heap[n],t.depth));)t.heap[r]=t.heap[n],r=n,n<<=1;t.heap[r]=i}function Dc(t,e,r){var i,n,a=0,o,s;if(t.last_lit!==0)do i=t.pending_buf[t.d_buf+a*2]<<8|t.pending_buf[t.d_buf+a*2+1],n=t.pending_buf[t.l_buf+a],a++,i===0?Ot(t,n,e):(o=ir[n],Ot(t,o+ar+1,e),s=Nn[o],s!==0&&(n-=zn[o],st(t,n,s)),i--,o=Vc(i),Ot(t,o,r),s=ti[o],s!==0&&(i-=ei[o],st(t,i,s)));while(a<t.last_lit);Ot(t,Mn,e)}function Fn(t,e){var r=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,a=e.stat_desc.elems,o,s,l=-1,c;for(t.heap_len=0,t.heap_max=Mc,o=0;o<a;o++)r[o*2]!==0?(t.heap[++t.heap_len]=l=o,t.depth[o]=0):r[o*2+1]=0;for(;t.heap_len<2;)c=t.heap[++t.heap_len]=l<2?++l:0,r[c*2]=1,t.depth[c]=0,t.opt_len--,n&&(t.static_len-=i[c*2+1]);for(e.max_code=l,o=t.heap_len>>1;o>=1;o--)Dn(t,r,o);c=a;do o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Dn(t,r,1),s=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=s,r[c*2]=r[o*2]+r[s*2],t.depth[c]=(t.depth[o]>=t.depth[s]?t.depth[o]:t.depth[s])+1,r[o*2+1]=r[s*2+1]=c,t.heap[1]=c++,Dn(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],fp(t,e),Yc(r,l,t.bl_count)}function Nc(t,e,r){var i,n=-1,a,o=e[0*2+1],s=0,l=7,c=4;for(o===0&&(l=138,c=3),e[(r+1)*2+1]=65535,i=0;i<=r;i++)a=o,o=e[(i+1)*2+1],!(++s<l&&a===o)&&(s<c?t.bl_tree[a*2]+=s:a!==0?(a!==n&&t.bl_tree[a*2]++,t.bl_tree[zc*2]++):s<=10?t.bl_tree[Lc*2]++:t.bl_tree[Hc*2]++,s=0,n=a,o===0?(l=138,c=3):a===o?(l=6,c=3):(l=7,c=4))}function Fc(t,e,r){var i,n=-1,a,o=e[0*2+1],s=0,l=7,c=4;for(o===0&&(l=138,c=3),i=0;i<=r;i++)if(a=o,o=e[(i+1)*2+1],!(++s<l&&a===o)){if(s<c)do Ot(t,a,t.bl_tree);while(--s!==0);else a!==0?(a!==n&&(Ot(t,a,t.bl_tree),s--),Ot(t,zc,t.bl_tree),st(t,s-3,2)):s<=10?(Ot(t,Lc,t.bl_tree),st(t,s-3,3)):(Ot(t,Hc,t.bl_tree),st(t,s-11,7));s=0,n=a,o===0?(l=138,c=3):a===o?(l=6,c=3):(l=7,c=4)}}function dp(t){var e;for(Nc(t,t.dyn_ltree,t.l_desc.max_code),Nc(t,t.dyn_dtree,t.d_desc.max_code),Fn(t,t.bl_desc),e=jn-1;e>=3&&t.bl_tree[Gc[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e}function hp(t,e,r,i){var n;for(st(t,e-257,5),st(t,r-1,5),st(t,i-4,4),n=0;n<i;n++)st(t,t.bl_tree[Gc[n]*2+1],3);Fc(t,t.dyn_ltree,e-1),Fc(t,t.dyn_dtree,r-1)}function pp(t){var e=4093624447,r;for(r=0;r<=31;r++,e>>>=1)if(e&1&&t.dyn_ltree[r*2]!==0)return Pc;if(t.dyn_ltree[9*2]!==0||t.dyn_ltree[10*2]!==0||t.dyn_ltree[13*2]!==0)return Cc;for(r=32;r<ar;r++)if(t.dyn_ltree[r*2]!==0)return Cc;return Pc}var Uc=!1;function wp(t){Uc||(lp(),Uc=!0),t.l_desc=new Bn(t.dyn_ltree,qc),t.d_desc=new Bn(t.dyn_dtree,Zc),t.bl_desc=new Bn(t.bl_tree,Wc),t.bi_buf=0,t.bi_valid=0,Kc(t)}function Jc(t,e,r,i){st(t,(ep<<1)+(i?1:0),3),up(t,e,r,!0)}function mp(t){st(t,jc<<1,3),Ot(t,Mn,Ut),cp(t)}function gp(t,e,r,i){var n,a,o=0;t.level>0?(t.strm.data_type===tp&&(t.strm.data_type=pp(t)),Fn(t,t.l_desc),Fn(t,t.d_desc),o=dp(t),n=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=n&&(n=a)):n=a=r+5,r+4<=n&&e!==-1?Jc(t,e,r,i):t.strategy===Jh||a===n?(st(t,(jc<<1)+(i?1:0),3),Dc(t,Ut,tr)):(st(t,(rp<<1)+(i?1:0),3),hp(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Dc(t,t.dyn_ltree,t.dyn_dtree)),Kc(t),i&&Qc(t)}function yp(t,e,r){return t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=r&255,t.last_lit++,e===0?t.dyn_ltree[r*2]++:(t.matches++,e--,t.dyn_ltree[(ir[r]+ar+1)*2]++,t.dyn_dtree[Vc(e)*2]++),t.last_lit===t.lit_bufsize-1}Oe._tr_init=wp;Oe._tr_stored_block=Jc;Oe._tr_flush_block=gp;Oe._tr_tally=yp;Oe._tr_align=mp});var Ln=O((hy,ef)=>{"use strict";function bp(t,e,r,i){for(var n=t&65535|0,a=t>>>16&65535|0,o=0;r!==0;){o=r>2e3?2e3:r,r-=o;do n=n+e[i++]|0,a=a+n|0;while(--o);n%=65521,a%=65521}return n|a<<16|0}ef.exports=bp});var Hn=O((py,rf)=>{"use strict";function _p(){for(var t,e=[],r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=t&1?3988292384^t>>>1:t>>>1;e[r]=t}return e}var vp=_p();function xp(t,e,r,i){var n=vp,a=i+r;t^=-1;for(var o=i;o<a;o++)t=t>>>8^n[(t^e[o])&255];return t^-1}rf.exports=xp});var ri=O((wy,nf)=>{"use strict";nf.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var hf=O(Pt=>{"use strict";var rt=Ft(),mt=tf(),cf=Ln(),qt=Hn(),Ep=ri(),se=0,Sp=1,kp=3,Yt=4,af=5,It=0,of=1,gt=-2,Ap=-3,Gn=-5,Tp=-1,$p=1,ii=2,Op=3,Rp=4,Ip=0,Pp=2,si=8,Cp=9,Bp=15,Dp=8,Np=29,Fp=256,Zn=Fp+1+Np,Up=30,jp=19,Mp=2*Zn+1,zp=15,U=3,Vt=258,xt=Vt+U+1,Lp=32,ci=42,Wn=69,ni=73,ai=91,oi=103,ne=113,sr=666,Z=1,cr=2,ae=3,Pe=4,Hp=3;function Xt(t,e){return t.msg=Ep[e],e}function sf(t){return(t<<1)-(t>4?9:0)}function Wt(t){for(var e=t.length;--e>=0;)t[e]=0}function Zt(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),r!==0&&(rt.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,e.pending===0&&(e.pending_out=0))}function Y(t,e){mt._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Zt(t.strm)}function j(t,e){t.pending_buf[t.pending++]=e}function or(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255}function Gp(t,e,r,i){var n=t.avail_in;return n>i&&(n=i),n===0?0:(t.avail_in-=n,rt.arraySet(e,t.input,t.next_in,n,r),t.state.wrap===1?t.adler=cf(t.adler,e,n,r):t.state.wrap===2&&(t.adler=qt(t.adler,e,n,r)),t.next_in+=n,t.total_in+=n,n)}function ff(t,e){var r=t.max_chain_length,i=t.strstart,n,a,o=t.prev_length,s=t.nice_match,l=t.strstart>t.w_size-xt?t.strstart-(t.w_size-xt):0,c=t.window,f=t.w_mask,d=t.prev,u=t.strstart+Vt,h=c[i+o-1],m=c[i+o];t.prev_length>=t.good_match&&(r>>=2),s>t.lookahead&&(s=t.lookahead);do if(n=e,!(c[n+o]!==m||c[n+o-1]!==h||c[n]!==c[i]||c[++n]!==c[i+1])){i+=2,n++;do;while(c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&i<u);if(a=Vt-(u-i),i=u-Vt,a>o){if(t.match_start=e,o=a,a>=s)break;h=c[i+o-1],m=c[i+o]}}while((e=d[e&f])>l&&--r!==0);return o<=t.lookahead?o:t.lookahead}function oe(t){var e=t.w_size,r,i,n,a,o;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-xt)){rt.arraySet(t.window,t.window,e,e,0),t.match_start-=e,t.strstart-=e,t.block_start-=e,i=t.hash_size,r=i;do n=t.head[--r],t.head[r]=n>=e?n-e:0;while(--i);i=e,r=i;do n=t.prev[--r],t.prev[r]=n>=e?n-e:0;while(--i);a+=e}if(t.strm.avail_in===0)break;if(i=Gp(t.strm,t.window,t.strstart+t.lookahead,a),t.lookahead+=i,t.lookahead+t.insert>=U)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=(t.ins_h<<t.hash_shift^t.window[o+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[o+U-1])&t.hash_mask,t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<U)););}while(t.lookahead<xt&&t.strm.avail_in!==0)}function qp(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(oe(t),t.lookahead===0&&e===se)return Z;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var i=t.block_start+r;if((t.strstart===0||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,Y(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-xt&&(Y(t,!1),t.strm.avail_out===0))return Z}return t.insert=0,e===Yt?(Y(t,!0),t.strm.avail_out===0?ae:Pe):(t.strstart>t.block_start&&(Y(t,!1),t.strm.avail_out===0),Z)}function qn(t,e){for(var r,i;;){if(t.lookahead<xt){if(oe(t),t.lookahead<xt&&e===se)return Z;if(t.lookahead===0)break}if(r=0,t.lookahead>=U&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+U-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),r!==0&&t.strstart-r<=t.w_size-xt&&(t.match_length=ff(t,r)),t.match_length>=U)if(i=mt._tr_tally(t,t.strstart-t.match_start,t.match_length-U),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=U){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+U-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart;while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else i=mt._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(Y(t,!1),t.strm.avail_out===0))return Z}return t.insert=t.strstart<U-1?t.strstart:U-1,e===Yt?(Y(t,!0),t.strm.avail_out===0?ae:Pe):t.last_lit&&(Y(t,!1),t.strm.avail_out===0)?Z:cr}function Re(t,e){for(var r,i,n;;){if(t.lookahead<xt){if(oe(t),t.lookahead<xt&&e===se)return Z;if(t.lookahead===0)break}if(r=0,t.lookahead>=U&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+U-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=U-1,r!==0&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-xt&&(t.match_length=ff(t,r),t.match_length<=5&&(t.strategy===$p||t.match_length===U&&t.strstart-t.match_start>4096)&&(t.match_length=U-1)),t.prev_length>=U&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-U,i=mt._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-U),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=n&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+U-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart);while(--t.prev_length!==0);if(t.match_available=0,t.match_length=U-1,t.strstart++,i&&(Y(t,!1),t.strm.avail_out===0))return Z}else if(t.match_available){if(i=mt._tr_tally(t,0,t.window[t.strstart-1]),i&&Y(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return Z}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=mt._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<U-1?t.strstart:U-1,e===Yt?(Y(t,!0),t.strm.avail_out===0?ae:Pe):t.last_lit&&(Y(t,!1),t.strm.avail_out===0)?Z:cr}function Zp(t,e){for(var r,i,n,a,o=t.window;;){if(t.lookahead<=Vt){if(oe(t),t.lookahead<=Vt&&e===se)return Z;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=U&&t.strstart>0&&(n=t.strstart-1,i=o[n],i===o[++n]&&i===o[++n]&&i===o[++n])){a=t.strstart+Vt;do;while(i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&n<a);t.match_length=Vt-(a-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=U?(r=mt._tr_tally(t,1,t.match_length-U),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=mt._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(Y(t,!1),t.strm.avail_out===0))return Z}return t.insert=0,e===Yt?(Y(t,!0),t.strm.avail_out===0?ae:Pe):t.last_lit&&(Y(t,!1),t.strm.avail_out===0)?Z:cr}function Wp(t,e){for(var r;;){if(t.lookahead===0&&(oe(t),t.lookahead===0)){if(e===se)return Z;break}if(t.match_length=0,r=mt._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(Y(t,!1),t.strm.avail_out===0))return Z}return t.insert=0,e===Yt?(Y(t,!0),t.strm.avail_out===0?ae:Pe):t.last_lit&&(Y(t,!1),t.strm.avail_out===0)?Z:cr}function Rt(t,e,r,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=i,this.func=n}var Ie;Ie=[new Rt(0,0,0,0,qp),new Rt(4,4,8,4,qn),new Rt(4,5,16,8,qn),new Rt(4,6,32,32,qn),new Rt(4,4,16,16,Re),new Rt(8,16,32,32,Re),new Rt(8,16,128,128,Re),new Rt(8,32,128,256,Re),new Rt(32,128,258,1024,Re),new Rt(32,258,258,4096,Re)];function Vp(t){t.window_size=2*t.w_size,Wt(t.head),t.max_lazy_match=Ie[t.level].max_lazy,t.good_match=Ie[t.level].good_length,t.nice_match=Ie[t.level].nice_length,t.max_chain_length=Ie[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=U-1,t.match_available=0,t.ins_h=0}function Xp(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=si,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new rt.Buf16(Mp*2),this.dyn_dtree=new rt.Buf16((2*Up+1)*2),this.bl_tree=new rt.Buf16((2*jp+1)*2),Wt(this.dyn_ltree),Wt(this.dyn_dtree),Wt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new rt.Buf16(zp+1),this.heap=new rt.Buf16(2*Zn+1),Wt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new rt.Buf16(2*Zn+1),Wt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function lf(t){var e;return!t||!t.state?Xt(t,gt):(t.total_in=t.total_out=0,t.data_type=Pp,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?ci:ne,t.adler=e.wrap===2?0:1,e.last_flush=se,mt._tr_init(e),It)}function uf(t){var e=lf(t);return e===It&&Vp(t.state),e}function Yp(t,e){return!t||!t.state||t.state.wrap!==2?gt:(t.state.gzhead=e,It)}function df(t,e,r,i,n,a){if(!t)return gt;var o=1;if(e===Tp&&(e=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),n<1||n>Cp||r!==si||i<8||i>15||e<0||e>9||a<0||a>Rp)return Xt(t,gt);i===8&&(i=9);var s=new Xp;return t.state=s,s.strm=t,s.wrap=o,s.gzhead=null,s.w_bits=i,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=n+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+U-1)/U),s.window=new rt.Buf8(s.w_size*2),s.head=new rt.Buf16(s.hash_size),s.prev=new rt.Buf16(s.w_size),s.lit_bufsize=1<<n+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new rt.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=e,s.strategy=a,s.method=r,uf(t)}function Kp(t,e){return df(t,e,si,Bp,Dp,Ip)}function Qp(t,e){var r,i,n,a;if(!t||!t.state||e>af||e<0)return t?Xt(t,gt):gt;if(i=t.state,!t.output||!t.input&&t.avail_in!==0||i.status===sr&&e!==Yt)return Xt(t,t.avail_out===0?Gn:gt);if(i.strm=t,r=i.last_flush,i.last_flush=e,i.status===ci)if(i.wrap===2)t.adler=0,j(i,31),j(i,139),j(i,8),i.gzhead?(j(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),j(i,i.gzhead.time&255),j(i,i.gzhead.time>>8&255),j(i,i.gzhead.time>>16&255),j(i,i.gzhead.time>>24&255),j(i,i.level===9?2:i.strategy>=ii||i.level<2?4:0),j(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(j(i,i.gzhead.extra.length&255),j(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=qt(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Wn):(j(i,0),j(i,0),j(i,0),j(i,0),j(i,0),j(i,i.level===9?2:i.strategy>=ii||i.level<2?4:0),j(i,Hp),i.status=ne);else{var o=si+(i.w_bits-8<<4)<<8,s=-1;i.strategy>=ii||i.level<2?s=0:i.level<6?s=1:i.level===6?s=2:s=3,o|=s<<6,i.strstart!==0&&(o|=Lp),o+=31-o%31,i.status=ne,or(i,o),i.strstart!==0&&(or(i,t.adler>>>16),or(i,t.adler&65535)),t.adler=1}if(i.status===Wn)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=qt(t.adler,i.pending_buf,i.pending-n,n)),Zt(t),n=i.pending,i.pending===i.pending_buf_size));)j(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(t.adler=qt(t.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=ni)}else i.status=ni;if(i.status===ni)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=qt(t.adler,i.pending_buf,i.pending-n,n)),Zt(t),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}i.gzindex<i.gzhead.name.length?a=i.gzhead.name.charCodeAt(i.gzindex++)&255:a=0,j(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>n&&(t.adler=qt(t.adler,i.pending_buf,i.pending-n,n)),a===0&&(i.gzindex=0,i.status=ai)}else i.status=ai;if(i.status===ai)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=qt(t.adler,i.pending_buf,i.pending-n,n)),Zt(t),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}i.gzindex<i.gzhead.comment.length?a=i.gzhead.comment.charCodeAt(i.gzindex++)&255:a=0,j(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>n&&(t.adler=qt(t.adler,i.pending_buf,i.pending-n,n)),a===0&&(i.status=oi)}else i.status=oi;if(i.status===oi&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&Zt(t),i.pending+2<=i.pending_buf_size&&(j(i,t.adler&255),j(i,t.adler>>8&255),t.adler=0,i.status=ne)):i.status=ne),i.pending!==0){if(Zt(t),t.avail_out===0)return i.last_flush=-1,It}else if(t.avail_in===0&&sf(e)<=sf(r)&&e!==Yt)return Xt(t,Gn);if(i.status===sr&&t.avail_in!==0)return Xt(t,Gn);if(t.avail_in!==0||i.lookahead!==0||e!==se&&i.status!==sr){var l=i.strategy===ii?Wp(i,e):i.strategy===Op?Zp(i,e):Ie[i.level].func(i,e);if((l===ae||l===Pe)&&(i.status=sr),l===Z||l===ae)return t.avail_out===0&&(i.last_flush=-1),It;if(l===cr&&(e===Sp?mt._tr_align(i):e!==af&&(mt._tr_stored_block(i,0,0,!1),e===kp&&(Wt(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),Zt(t),t.avail_out===0))return i.last_flush=-1,It}return e!==Yt?It:i.wrap<=0?of:(i.wrap===2?(j(i,t.adler&255),j(i,t.adler>>8&255),j(i,t.adler>>16&255),j(i,t.adler>>24&255),j(i,t.total_in&255),j(i,t.total_in>>8&255),j(i,t.total_in>>16&255),j(i,t.total_in>>24&255)):(or(i,t.adler>>>16),or(i,t.adler&65535)),Zt(t),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?It:of)}function Jp(t){var e;return!t||!t.state?gt:(e=t.state.status,e!==ci&&e!==Wn&&e!==ni&&e!==ai&&e!==oi&&e!==ne&&e!==sr?Xt(t,gt):(t.state=null,e===ne?Xt(t,Ap):It))}function tw(t,e){var r=e.length,i,n,a,o,s,l,c,f;if(!t||!t.state||(i=t.state,o=i.wrap,o===2||o===1&&i.status!==ci||i.lookahead))return gt;for(o===1&&(t.adler=cf(t.adler,e,r,0)),i.wrap=0,r>=i.w_size&&(o===0&&(Wt(i.head),i.strstart=0,i.block_start=0,i.insert=0),f=new rt.Buf8(i.w_size),rt.arraySet(f,e,r-i.w_size,i.w_size,0),e=f,r=i.w_size),s=t.avail_in,l=t.next_in,c=t.input,t.avail_in=r,t.next_in=0,t.input=e,oe(i);i.lookahead>=U;){n=i.strstart,a=i.lookahead-(U-1);do i.ins_h=(i.ins_h<<i.hash_shift^i.window[n+U-1])&i.hash_mask,i.prev[n&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=n,n++;while(--a);i.strstart=n,i.lookahead=U-1,oe(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=U-1,i.match_available=0,t.next_in=l,t.input=c,t.avail_in=s,i.wrap=o,It}Pt.deflateInit=Kp;Pt.deflateInit2=df;Pt.deflateReset=uf;Pt.deflateResetKeep=lf;Pt.deflateSetHeader=Yp;Pt.deflate=Qp;Pt.deflateEnd=Jp;Pt.deflateSetDictionary=tw;Pt.deflateInfo="pako deflate (from Nodeca project)"});var Vn=O(Ce=>{"use strict";var fi=Ft(),pf=!0,wf=!0;try{String.fromCharCode.apply(null,[0])}catch(t){pf=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){wf=!1}var fr=new fi.Buf8(256);for(jt=0;jt<256;jt++)fr[jt]=jt>=252?6:jt>=248?5:jt>=240?4:jt>=224?3:jt>=192?2:1;var jt;fr[254]=fr[254]=1;Ce.string2buf=function(t){var e,r,i,n,a,o=t.length,s=0;for(n=0;n<o;n++)r=t.charCodeAt(n),(r&64512)===55296&&n+1<o&&(i=t.charCodeAt(n+1),(i&64512)===56320&&(r=65536+(r-55296<<10)+(i-56320),n++)),s+=r<128?1:r<2048?2:r<65536?3:4;for(e=new fi.Buf8(s),a=0,n=0;a<s;n++)r=t.charCodeAt(n),(r&64512)===55296&&n+1<o&&(i=t.charCodeAt(n+1),(i&64512)===56320&&(r=65536+(r-55296<<10)+(i-56320),n++)),r<128?e[a++]=r:r<2048?(e[a++]=192|r>>>6,e[a++]=128|r&63):r<65536?(e[a++]=224|r>>>12,e[a++]=128|r>>>6&63,e[a++]=128|r&63):(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63,e[a++]=128|r>>>6&63,e[a++]=128|r&63);return e};function mf(t,e){if(e<65534&&(t.subarray&&wf||!t.subarray&&pf))return String.fromCharCode.apply(null,fi.shrinkBuf(t,e));for(var r="",i=0;i<e;i++)r+=String.fromCharCode(t[i]);return r}Ce.buf2binstring=function(t){return mf(t,t.length)};Ce.binstring2buf=function(t){for(var e=new fi.Buf8(t.length),r=0,i=e.length;r<i;r++)e[r]=t.charCodeAt(r);return e};Ce.buf2string=function(t,e){var r,i,n,a,o=e||t.length,s=new Array(o*2);for(i=0,r=0;r<o;){if(n=t[r++],n<128){s[i++]=n;continue}if(a=fr[n],a>4){s[i++]=65533,r+=a-1;continue}for(n&=a===2?31:a===3?15:7;a>1&&r<o;)n=n<<6|t[r++]&63,a--;if(a>1){s[i++]=65533;continue}n<65536?s[i++]=n:(n-=65536,s[i++]=55296|n>>10&1023,s[i++]=56320|n&1023)}return mf(s,i)};Ce.utf8border=function(t,e){var r;for(e=e||t.length,e>t.length&&(e=t.length),r=e-1;r>=0&&(t[r]&192)===128;)r--;return r<0||r===0?e:r+fr[t[r]]>e?r:e}});var Xn=O((yy,gf)=>{"use strict";function ew(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}gf.exports=ew});var vf=O(dr=>{"use strict";var lr=hf(),ur=Ft(),Kn=Vn(),Qn=ri(),rw=Xn(),_f=Object.prototype.toString,iw=0,Yn=4,Be=0,yf=1,bf=2,nw=-1,aw=0,ow=8;function ce(t){if(!(this instanceof ce))return new ce(t);this.options=ur.assign({level:nw,method:ow,chunkSize:16384,windowBits:15,memLevel:8,strategy:aw,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new rw,this.strm.avail_out=0;var r=lr.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Be)throw new Error(Qn[r]);if(e.header&&lr.deflateSetHeader(this.strm,e.header),e.dictionary){var i;if(typeof e.dictionary=="string"?i=Kn.string2buf(e.dictionary):_f.call(e.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(e.dictionary):i=e.dictionary,r=lr.deflateSetDictionary(this.strm,i),r!==Be)throw new Error(Qn[r]);this._dict_set=!0}}ce.prototype.push=function(t,e){var r=this.strm,i=this.options.chunkSize,n,a;if(this.ended)return!1;a=e===~~e?e:e===!0?Yn:iw,typeof t=="string"?r.input=Kn.string2buf(t):_f.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new ur.Buf8(i),r.next_out=0,r.avail_out=i),n=lr.deflate(r,a),n!==yf&&n!==Be)return this.onEnd(n),this.ended=!0,!1;(r.avail_out===0||r.avail_in===0&&(a===Yn||a===bf))&&(this.options.to==="string"?this.onData(Kn.buf2binstring(ur.shrinkBuf(r.output,r.next_out))):this.onData(ur.shrinkBuf(r.output,r.next_out)))}while((r.avail_in>0||r.avail_out===0)&&n!==yf);return a===Yn?(n=lr.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Be):(a===bf&&(this.onEnd(Be),r.avail_out=0),!0)};ce.prototype.onData=function(t){this.chunks.push(t)};ce.prototype.onEnd=function(t){t===Be&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ur.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Jn(t,e){var r=new ce(e);if(r.push(t,!0),r.err)throw r.msg||Qn[r.err];return r.result}function sw(t,e){return e=e||{},e.raw=!0,Jn(t,e)}function cw(t,e){return e=e||{},e.gzip=!0,Jn(t,e)}dr.Deflate=ce;dr.deflate=Jn;dr.deflateRaw=sw;dr.gzip=cw});var Ef=O((_y,xf)=>{"use strict";var li=30,fw=12;xf.exports=function(e,r){var i,n,a,o,s,l,c,f,d,u,h,m,g,y,b,v,k,S,x,T,p,_,w,A,E;i=e.state,n=e.next_in,A=e.input,a=n+(e.avail_in-5),o=e.next_out,E=e.output,s=o-(r-e.avail_out),l=o+(e.avail_out-257),c=i.dmax,f=i.wsize,d=i.whave,u=i.wnext,h=i.window,m=i.hold,g=i.bits,y=i.lencode,b=i.distcode,v=(1<<i.lenbits)-1,k=(1<<i.distbits)-1;t:do{g<15&&(m+=A[n++]<<g,g+=8,m+=A[n++]<<g,g+=8),S=y[m&v];e:for(;;){if(x=S>>>24,m>>>=x,g-=x,x=S>>>16&255,x===0)E[o++]=S&65535;else if(x&16){T=S&65535,x&=15,x&&(g<x&&(m+=A[n++]<<g,g+=8),T+=m&(1<<x)-1,m>>>=x,g-=x),g<15&&(m+=A[n++]<<g,g+=8,m+=A[n++]<<g,g+=8),S=b[m&k];r:for(;;){if(x=S>>>24,m>>>=x,g-=x,x=S>>>16&255,x&16){if(p=S&65535,x&=15,g<x&&(m+=A[n++]<<g,g+=8,g<x&&(m+=A[n++]<<g,g+=8)),p+=m&(1<<x)-1,p>c){e.msg="invalid distance too far back",i.mode=li;break t}if(m>>>=x,g-=x,x=o-s,p>x){if(x=p-x,x>d&&i.sane){e.msg="invalid distance too far back",i.mode=li;break t}if(_=0,w=h,u===0){if(_+=f-x,x<T){T-=x;do E[o++]=h[_++];while(--x);_=o-p,w=E}}else if(u<x){if(_+=f+u-x,x-=u,x<T){T-=x;do E[o++]=h[_++];while(--x);if(_=0,u<T){x=u,T-=x;do E[o++]=h[_++];while(--x);_=o-p,w=E}}}else if(_+=u-x,x<T){T-=x;do E[o++]=h[_++];while(--x);_=o-p,w=E}for(;T>2;)E[o++]=w[_++],E[o++]=w[_++],E[o++]=w[_++],T-=3;T&&(E[o++]=w[_++],T>1&&(E[o++]=w[_++]))}else{_=o-p;do E[o++]=E[_++],E[o++]=E[_++],E[o++]=E[_++],T-=3;while(T>2);T&&(E[o++]=E[_++],T>1&&(E[o++]=E[_++]))}}else if(x&64){e.msg="invalid distance code",i.mode=li;break t}else{S=b[(S&65535)+(m&(1<<x)-1)];continue r}break}}else if(x&64)if(x&32){i.mode=fw;break t}else{e.msg="invalid literal/length code",i.mode=li;break t}else{S=y[(S&65535)+(m&(1<<x)-1)];continue e}break}}while(n<a&&o<l);T=g>>3,n-=T,g-=T<<3,m&=(1<<g)-1,e.next_in=n,e.next_out=o,e.avail_in=n<a?5+(a-n):5-(n-a),e.avail_out=o<l?257+(l-o):257-(o-l),i.hold=m,i.bits=g}});var Rf=O((vy,Of)=>{"use strict";var Sf=Ft(),De=15,kf=852,Af=592,Tf=0,ta=1,$f=2,lw=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],uw=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],dw=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],hw=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];Of.exports=function(e,r,i,n,a,o,s,l){var c=l.bits,f=0,d=0,u=0,h=0,m=0,g=0,y=0,b=0,v=0,k=0,S,x,T,p,_,w=null,A=0,E,$=new Sf.Buf16(De+1),R=new Sf.Buf16(De+1),B=null,H=0,ht,W,tt;for(f=0;f<=De;f++)$[f]=0;for(d=0;d<n;d++)$[r[i+d]]++;for(m=c,h=De;h>=1&&$[h]===0;h--);if(m>h&&(m=h),h===0)return a[o++]=1<<24|64<<16|0,a[o++]=1<<24|64<<16|0,l.bits=1,0;for(u=1;u<h&&$[u]===0;u++);for(m<u&&(m=u),b=1,f=1;f<=De;f++)if(b<<=1,b-=$[f],b<0)return-1;if(b>0&&(e===Tf||h!==1))return-1;for(R[1]=0,f=1;f<De;f++)R[f+1]=R[f]+$[f];for(d=0;d<n;d++)r[i+d]!==0&&(s[R[r[i+d]]++]=d);if(e===Tf?(w=B=s,E=19):e===ta?(w=lw,A-=257,B=uw,H-=257,E=256):(w=dw,B=hw,E=-1),k=0,d=0,f=u,_=o,g=m,y=0,T=-1,v=1<<m,p=v-1,e===ta&&v>kf||e===$f&&v>Af)return 1;for(;;){ht=f-y,s[d]<E?(W=0,tt=s[d]):s[d]>E?(W=B[H+s[d]],tt=w[A+s[d]]):(W=96,tt=0),S=1<<f-y,x=1<<g,u=x;do x-=S,a[_+(k>>y)+x]=ht<<24|W<<16|tt|0;while(x!==0);for(S=1<<f-1;k&S;)S>>=1;if(S!==0?(k&=S-1,k+=S):k=0,d++,--$[f]===0){if(f===h)break;f=r[i+s[d]]}if(f>m&&(k&p)!==T){for(y===0&&(y=m),_+=u,g=f-y,b=1<<g;g+y<h&&(b-=$[g+y],!(b<=0));)g++,b<<=1;if(v+=1<<g,e===ta&&v>kf||e===$f&&v>Af)return 1;T=k&p,a[T]=m<<24|g<<16|_-o|0}}return k!==0&&(a[_+k]=f-y<<24|64<<16|0),l.bits=m,0}});var ul=O(Et=>{"use strict";var ut=Ft(),oa=Ln(),Ct=Hn(),pw=Ef(),hr=Rf(),ww=0,rl=1,il=2,If=4,mw=5,ui=6,fe=0,gw=1,yw=2,yt=-2,nl=-3,sa=-4,bw=-5,Pf=8,al=1,Cf=2,Bf=3,Df=4,Nf=5,Ff=6,Uf=7,jf=8,Mf=9,zf=10,pi=11,Mt=12,ea=13,Lf=14,ra=15,Hf=16,Gf=17,qf=18,Zf=19,di=20,hi=21,Wf=22,Vf=23,Xf=24,Yf=25,Kf=26,ia=27,Qf=28,Jf=29,z=30,ca=31,_w=32,vw=852,xw=592,Ew=15,Sw=Ew;function tl(t){return(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24)}function kw(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new ut.Buf16(320),this.work=new ut.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function ol(t){var e;return!t||!t.state?yt:(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=al,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new ut.Buf32(vw),e.distcode=e.distdyn=new ut.Buf32(xw),e.sane=1,e.back=-1,fe)}function sl(t){var e;return!t||!t.state?yt:(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,ol(t))}function cl(t,e){var r,i;return!t||!t.state||(i=t.state,e<0?(r=0,e=-e):(r=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?yt:(i.window!==null&&i.wbits!==e&&(i.window=null),i.wrap=r,i.wbits=e,sl(t))}function fl(t,e){var r,i;return t?(i=new kw,t.state=i,i.window=null,r=cl(t,e),r!==fe&&(t.state=null),r):yt}function Aw(t){return fl(t,Sw)}var el=!0,na,aa;function Tw(t){if(el){var e;for(na=new ut.Buf32(512),aa=new ut.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(hr(rl,t.lens,0,288,na,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;hr(il,t.lens,0,32,aa,0,t.work,{bits:5}),el=!1}t.lencode=na,t.lenbits=9,t.distcode=aa,t.distbits=5}function ll(t,e,r,i){var n,a=t.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new ut.Buf8(a.wsize)),i>=a.wsize?(ut.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>i&&(n=i),ut.arraySet(a.window,e,r-i,n,a.wnext),i-=n,i?(ut.arraySet(a.window,e,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0}function $w(t,e){var r,i,n,a,o,s,l,c,f,d,u,h,m,g,y=0,b,v,k,S,x,T,p,_,w=new ut.Buf8(4),A,E,$=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return yt;r=t.state,r.mode===Mt&&(r.mode=ea),o=t.next_out,n=t.output,l=t.avail_out,a=t.next_in,i=t.input,s=t.avail_in,c=r.hold,f=r.bits,d=s,u=l,_=fe;t:for(;;)switch(r.mode){case al:if(r.wrap===0){r.mode=ea;break}for(;f<16;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}if(r.wrap&2&&c===35615){r.check=0,w[0]=c&255,w[1]=c>>>8&255,r.check=Ct(r.check,w,2,0),c=0,f=0,r.mode=Cf;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((c&255)<<8)+(c>>8))%31){t.msg="incorrect header check",r.mode=z;break}if((c&15)!==Pf){t.msg="unknown compression method",r.mode=z;break}if(c>>>=4,f-=4,p=(c&15)+8,r.wbits===0)r.wbits=p;else if(p>r.wbits){t.msg="invalid window size",r.mode=z;break}r.dmax=1<<p,t.adler=r.check=1,r.mode=c&512?zf:Mt,c=0,f=0;break;case Cf:for(;f<16;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}if(r.flags=c,(r.flags&255)!==Pf){t.msg="unknown compression method",r.mode=z;break}if(r.flags&57344){t.msg="unknown header flags set",r.mode=z;break}r.head&&(r.head.text=c>>8&1),r.flags&512&&(w[0]=c&255,w[1]=c>>>8&255,r.check=Ct(r.check,w,2,0)),c=0,f=0,r.mode=Bf;case Bf:for(;f<32;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}r.head&&(r.head.time=c),r.flags&512&&(w[0]=c&255,w[1]=c>>>8&255,w[2]=c>>>16&255,w[3]=c>>>24&255,r.check=Ct(r.check,w,4,0)),c=0,f=0,r.mode=Df;case Df:for(;f<16;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}r.head&&(r.head.xflags=c&255,r.head.os=c>>8),r.flags&512&&(w[0]=c&255,w[1]=c>>>8&255,r.check=Ct(r.check,w,2,0)),c=0,f=0,r.mode=Nf;case Nf:if(r.flags&1024){for(;f<16;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}r.length=c,r.head&&(r.head.extra_len=c),r.flags&512&&(w[0]=c&255,w[1]=c>>>8&255,r.check=Ct(r.check,w,2,0)),c=0,f=0}else r.head&&(r.head.extra=null);r.mode=Ff;case Ff:if(r.flags&1024&&(h=r.length,h>s&&(h=s),h&&(r.head&&(p=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),ut.arraySet(r.head.extra,i,a,h,p)),r.flags&512&&(r.check=Ct(r.check,i,h,a)),s-=h,a+=h,r.length-=h),r.length))break t;r.length=0,r.mode=Uf;case Uf:if(r.flags&2048){if(s===0)break t;h=0;do p=i[a+h++],r.head&&p&&r.length<65536&&(r.head.name+=String.fromCharCode(p));while(p&&h<s);if(r.flags&512&&(r.check=Ct(r.check,i,h,a)),s-=h,a+=h,p)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=jf;case jf:if(r.flags&4096){if(s===0)break t;h=0;do p=i[a+h++],r.head&&p&&r.length<65536&&(r.head.comment+=String.fromCharCode(p));while(p&&h<s);if(r.flags&512&&(r.check=Ct(r.check,i,h,a)),s-=h,a+=h,p)break t}else r.head&&(r.head.comment=null);r.mode=Mf;case Mf:if(r.flags&512){for(;f<16;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}if(c!==(r.check&65535)){t.msg="header crc mismatch",r.mode=z;break}c=0,f=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=Mt;break;case zf:for(;f<32;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}t.adler=r.check=tl(c),c=0,f=0,r.mode=pi;case pi:if(r.havedict===0)return t.next_out=o,t.avail_out=l,t.next_in=a,t.avail_in=s,r.hold=c,r.bits=f,yw;t.adler=r.check=1,r.mode=Mt;case Mt:if(e===mw||e===ui)break t;case ea:if(r.last){c>>>=f&7,f-=f&7,r.mode=ia;break}for(;f<3;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}switch(r.last=c&1,c>>>=1,f-=1,c&3){case 0:r.mode=Lf;break;case 1:if(Tw(r),r.mode=di,e===ui){c>>>=2,f-=2;break t}break;case 2:r.mode=Gf;break;case 3:t.msg="invalid block type",r.mode=z}c>>>=2,f-=2;break;case Lf:for(c>>>=f&7,f-=f&7;f<32;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}if((c&65535)!==(c>>>16^65535)){t.msg="invalid stored block lengths",r.mode=z;break}if(r.length=c&65535,c=0,f=0,r.mode=ra,e===ui)break t;case ra:r.mode=Hf;case Hf:if(h=r.length,h){if(h>s&&(h=s),h>l&&(h=l),h===0)break t;ut.arraySet(n,i,a,h,o),s-=h,a+=h,l-=h,o+=h,r.length-=h;break}r.mode=Mt;break;case Gf:for(;f<14;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}if(r.nlen=(c&31)+257,c>>>=5,f-=5,r.ndist=(c&31)+1,c>>>=5,f-=5,r.ncode=(c&15)+4,c>>>=4,f-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=z;break}r.have=0,r.mode=qf;case qf:for(;r.have<r.ncode;){for(;f<3;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}r.lens[$[r.have++]]=c&7,c>>>=3,f-=3}for(;r.have<19;)r.lens[$[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},_=hr(ww,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,_){t.msg="invalid code lengths set",r.mode=z;break}r.have=0,r.mode=Zf;case Zf:for(;r.have<r.nlen+r.ndist;){for(;y=r.lencode[c&(1<<r.lenbits)-1],b=y>>>24,v=y>>>16&255,k=y&65535,!(b<=f);){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}if(k<16)c>>>=b,f-=b,r.lens[r.have++]=k;else{if(k===16){for(E=b+2;f<E;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}if(c>>>=b,f-=b,r.have===0){t.msg="invalid bit length repeat",r.mode=z;break}p=r.lens[r.have-1],h=3+(c&3),c>>>=2,f-=2}else if(k===17){for(E=b+3;f<E;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}c>>>=b,f-=b,p=0,h=3+(c&7),c>>>=3,f-=3}else{for(E=b+7;f<E;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}c>>>=b,f-=b,p=0,h=11+(c&127),c>>>=7,f-=7}if(r.have+h>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=z;break}for(;h--;)r.lens[r.have++]=p}}if(r.mode===z)break;if(r.lens[256]===0){t.msg="invalid code -- missing end-of-block",r.mode=z;break}if(r.lenbits=9,A={bits:r.lenbits},_=hr(rl,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,_){t.msg="invalid literal/lengths set",r.mode=z;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},_=hr(il,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,_){t.msg="invalid distances set",r.mode=z;break}if(r.mode=di,e===ui)break t;case di:r.mode=hi;case hi:if(s>=6&&l>=258){t.next_out=o,t.avail_out=l,t.next_in=a,t.avail_in=s,r.hold=c,r.bits=f,pw(t,u),o=t.next_out,n=t.output,l=t.avail_out,a=t.next_in,i=t.input,s=t.avail_in,c=r.hold,f=r.bits,r.mode===Mt&&(r.back=-1);break}for(r.back=0;y=r.lencode[c&(1<<r.lenbits)-1],b=y>>>24,v=y>>>16&255,k=y&65535,!(b<=f);){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}if(v&&!(v&240)){for(S=b,x=v,T=k;y=r.lencode[T+((c&(1<<S+x)-1)>>S)],b=y>>>24,v=y>>>16&255,k=y&65535,!(S+b<=f);){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}c>>>=S,f-=S,r.back+=S}if(c>>>=b,f-=b,r.back+=b,r.length=k,v===0){r.mode=Kf;break}if(v&32){r.back=-1,r.mode=Mt;break}if(v&64){t.msg="invalid literal/length code",r.mode=z;break}r.extra=v&15,r.mode=Wf;case Wf:if(r.extra){for(E=r.extra;f<E;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,f-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=Vf;case Vf:for(;y=r.distcode[c&(1<<r.distbits)-1],b=y>>>24,v=y>>>16&255,k=y&65535,!(b<=f);){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}if(!(v&240)){for(S=b,x=v,T=k;y=r.distcode[T+((c&(1<<S+x)-1)>>S)],b=y>>>24,v=y>>>16&255,k=y&65535,!(S+b<=f);){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}c>>>=S,f-=S,r.back+=S}if(c>>>=b,f-=b,r.back+=b,v&64){t.msg="invalid distance code",r.mode=z;break}r.offset=k,r.extra=v&15,r.mode=Xf;case Xf:if(r.extra){for(E=r.extra;f<E;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,f-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=z;break}r.mode=Yf;case Yf:if(l===0)break t;if(h=u-l,r.offset>h){if(h=r.offset-h,h>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=z;break}h>r.wnext?(h-=r.wnext,m=r.wsize-h):m=r.wnext-h,h>r.length&&(h=r.length),g=r.window}else g=n,m=o-r.offset,h=r.length;h>l&&(h=l),l-=h,r.length-=h;do n[o++]=g[m++];while(--h);r.length===0&&(r.mode=hi);break;case Kf:if(l===0)break t;n[o++]=r.length,l--,r.mode=hi;break;case ia:if(r.wrap){for(;f<32;){if(s===0)break t;s--,c|=i[a++]<<f,f+=8}if(u-=l,t.total_out+=u,r.total+=u,u&&(t.adler=r.check=r.flags?Ct(r.check,n,u,o-u):oa(r.check,n,u,o-u)),u=l,(r.flags?c:tl(c))!==r.check){t.msg="incorrect data check",r.mode=z;break}c=0,f=0}r.mode=Qf;case Qf:if(r.wrap&&r.flags){for(;f<32;){if(s===0)break t;s--,c+=i[a++]<<f,f+=8}if(c!==(r.total&4294967295)){t.msg="incorrect length check",r.mode=z;break}c=0,f=0}r.mode=Jf;case Jf:_=gw;break t;case z:_=nl;break t;case ca:return sa;case _w:default:return yt}return t.next_out=o,t.avail_out=l,t.next_in=a,t.avail_in=s,r.hold=c,r.bits=f,(r.wsize||u!==t.avail_out&&r.mode<z&&(r.mode<ia||e!==If))&&ll(t,t.output,t.next_out,u-t.avail_out)?(r.mode=ca,sa):(d-=t.avail_in,u-=t.avail_out,t.total_in+=d,t.total_out+=u,r.total+=u,r.wrap&&u&&(t.adler=r.check=r.flags?Ct(r.check,n,u,t.next_out-u):oa(r.check,n,u,t.next_out-u)),t.data_type=r.bits+(r.last?64:0)+(r.mode===Mt?128:0)+(r.mode===di||r.mode===ra?256:0),(d===0&&u===0||e===If)&&_===fe&&(_=bw),_)}function Ow(t){if(!t||!t.state)return yt;var e=t.state;return e.window&&(e.window=null),t.state=null,fe}function Rw(t,e){var r;return!t||!t.state||(r=t.state,!(r.wrap&2))?yt:(r.head=e,e.done=!1,fe)}function Iw(t,e){var r=e.length,i,n,a;return!t||!t.state||(i=t.state,i.wrap!==0&&i.mode!==pi)?yt:i.mode===pi&&(n=1,n=oa(n,e,r,0),n!==i.check)?nl:(a=ll(t,e,r,r),a?(i.mode=ca,sa):(i.havedict=1,fe))}Et.inflateReset=sl;Et.inflateReset2=cl;Et.inflateResetKeep=ol;Et.inflateInit=Aw;Et.inflateInit2=fl;Et.inflate=$w;Et.inflateEnd=Ow;Et.inflateGetHeader=Rw;Et.inflateSetDictionary=Iw;Et.inflateInfo="pako inflate (from Nodeca project)"});var fa=O((Ey,dl)=>{"use strict";dl.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var pl=O((Sy,hl)=>{"use strict";function Pw(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}hl.exports=Pw});var ml=O(wr=>{"use strict";var Ne=ul(),pr=Ft(),wi=Vn(),G=fa(),la=ri(),Cw=Xn(),Bw=pl(),wl=Object.prototype.toString;function le(t){if(!(this instanceof le))return new le(t);this.options=pr.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Cw,this.strm.avail_out=0;var r=Ne.inflateInit2(this.strm,e.windowBits);if(r!==G.Z_OK)throw new Error(la[r]);if(this.header=new Bw,Ne.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=wi.string2buf(e.dictionary):wl.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Ne.inflateSetDictionary(this.strm,e.dictionary),r!==G.Z_OK)))throw new Error(la[r])}le.prototype.push=function(t,e){var r=this.strm,i=this.options.chunkSize,n=this.options.dictionary,a,o,s,l,c,f=!1;if(this.ended)return!1;o=e===~~e?e:e===!0?G.Z_FINISH:G.Z_NO_FLUSH,typeof t=="string"?r.input=wi.binstring2buf(t):wl.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new pr.Buf8(i),r.next_out=0,r.avail_out=i),a=Ne.inflate(r,G.Z_NO_FLUSH),a===G.Z_NEED_DICT&&n&&(a=Ne.inflateSetDictionary(this.strm,n)),a===G.Z_BUF_ERROR&&f===!0&&(a=G.Z_OK,f=!1),a!==G.Z_STREAM_END&&a!==G.Z_OK)return this.onEnd(a),this.ended=!0,!1;r.next_out&&(r.avail_out===0||a===G.Z_STREAM_END||r.avail_in===0&&(o===G.Z_FINISH||o===G.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=wi.utf8border(r.output,r.next_out),l=r.next_out-s,c=wi.buf2string(r.output,s),r.next_out=l,r.avail_out=i-l,l&&pr.arraySet(r.output,r.output,s,l,0),this.onData(c)):this.onData(pr.shrinkBuf(r.output,r.next_out))),r.avail_in===0&&r.avail_out===0&&(f=!0)}while((r.avail_in>0||r.avail_out===0)&&a!==G.Z_STREAM_END);return a===G.Z_STREAM_END&&(o=G.Z_FINISH),o===G.Z_FINISH?(a=Ne.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===G.Z_OK):(o===G.Z_SYNC_FLUSH&&(this.onEnd(G.Z_OK),r.avail_out=0),!0)};le.prototype.onData=function(t){this.chunks.push(t)};le.prototype.onEnd=function(t){t===G.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=pr.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function ua(t,e){var r=new le(e);if(r.push(t,!0),r.err)throw r.msg||la[r.err];return r.result}function Dw(t,e){return e=e||{},e.raw=!0,ua(t,e)}wr.Inflate=le;wr.inflate=ua;wr.inflateRaw=Dw;wr.ungzip=ua});var bl=O((Ay,yl)=>{"use strict";var Nw=Ft().assign,Fw=vf(),Uw=ml(),jw=fa(),gl={};Nw(gl,Fw,Uw,jw);yl.exports=gl});var xl=O((Ty,vl)=>{"use strict";var _l=(t,e)=>function(...r){let i=e.promiseModule;return new i((n,a)=>{e.multiArgs?r.push((...o)=>{e.errorFirst?o[0]?a(o):(o.shift(),n(o)):n(o)}):e.errorFirst?r.push((o,s)=>{o?a(o):n(s)}):r.push(n),t.apply(this,r)})};vl.exports=(t,e)=>{e=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},e);let r=typeof t;if(!(t!==null&&(r==="object"||r==="function")))throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${t===null?"null":r}\``);let i=a=>{let o=s=>typeof s=="string"?a===s:s.test(a);return e.include?e.include.some(o):!e.exclude.some(o)},n;r==="function"?n=function(...a){return e.excludeMain?t(...a):_l(t,e).apply(this,a)}:n=Object.create(Object.getPrototypeOf(t));for(let a in t){let o=t[a];n[a]=typeof o=="function"&&i(a)?_l(o,e):o}return n}});var Il=O(($y,Rl)=>{function El(t){return Array.isArray(t)?t:[t]}var pa="",Sl=" ",da="\\",Mw=/^\s+$/,zw=/(?:[^\\]|^)\\$/,Lw=/^\\!/,Hw=/^\\#/,Gw=/\r?\n/g,qw=/^\.*\/|^\.+$/,ha="/",Tl="node-ignore";typeof Symbol!="undefined"&&(Tl=Symbol.for("node-ignore"));var kl=Tl,Zw=(t,e,r)=>Object.defineProperty(t,e,{value:r}),Ww=/([0-z])-([0-z])/g,$l=()=>!1,Vw=t=>t.replace(Ww,(e,r,i)=>r.charCodeAt(0)<=i.charCodeAt(0)?e:pa),Xw=t=>{let{length:e}=t;return t.slice(0,e-e%2)},Yw=[[/^\uFEFF/,()=>pa],[/((?:\\\\)*?)(\\?\s+)$/,(t,e,r)=>e+(r.indexOf("\\")===0?Sl:pa)],[/(\\+?)\s/g,(t,e)=>{let{length:r}=e;return e.slice(0,r-r%2)+Sl}],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,r)=>e+6<r.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(t,e,r)=>{let i=r.replace(/\\\*/g,"[^\\/]*");return e+i}],[/\\\\\\(?=[$.|*+(){^])/g,()=>da],[/\\\\/g,()=>da],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,r,i,n)=>e===da?`\\[${r}${Xw(i)}${n}`:n==="]"&&i.length%2===0?`[${Vw(r)}${i}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],Al=Object.create(null),Kw=(t,e)=>{let r=Al[t];return r||(r=Yw.reduce((i,[n,a])=>i.replace(n,a.bind(t)),t),Al[t]=r),e?new RegExp(r,"i"):new RegExp(r)},ga=t=>typeof t=="string",Qw=t=>t&&ga(t)&&!Mw.test(t)&&!zw.test(t)&&t.indexOf("#")!==0,Jw=t=>t.split(Gw),wa=class{constructor(e,r,i,n){this.origin=e,this.pattern=r,this.negative=i,this.regex=n}},t0=(t,e)=>{let r=t,i=!1;t.indexOf("!")===0&&(i=!0,t=t.substr(1)),t=t.replace(Lw,"!").replace(Hw,"#");let n=Kw(t,e);return new wa(r,t,i,n)},e0=(t,e)=>{throw new e(t)},zt=(t,e,r)=>ga(t)?t?zt.isNotRelative(t)?r(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:r("path must not be empty",TypeError):r(`path must be a string, but got \`${e}\``,TypeError),Ol=t=>qw.test(t);zt.isNotRelative=Ol;zt.convert=t=>t;var ma=class{constructor({ignorecase:e=!0,ignoreCase:r=e,allowRelativePaths:i=!1}={}){Zw(this,kl,!0),this._rules=[],this._ignoreCase=r,this._allowRelativePaths=i,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[kl]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(Qw(e)){let r=t0(e,this._ignoreCase);this._added=!0,this._rules.push(r)}}add(e){return this._added=!1,El(ga(e)?Jw(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,r){let i=!1,n=!1;return this._rules.forEach(a=>{let{negative:o}=a;if(n===o&&i!==n||o&&!i&&!n&&!r)return;a.regex.test(e)&&(i=!o,n=o)}),{ignored:i,unignored:n}}_test(e,r,i,n){let a=e&&zt.convert(e);return zt(a,e,this._allowRelativePaths?$l:e0),this._t(a,r,i,n)}_t(e,r,i,n){if(e in r)return r[e];if(n||(n=e.split(ha)),n.pop(),!n.length)return r[e]=this._testOne(e,i);let a=this._t(n.join(ha)+ha,r,i,n);return r[e]=a.ignored?a:this._testOne(e,i)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return El(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},mi=t=>new ma(t),r0=t=>zt(t&&zt.convert(t),t,$l);mi.isPathValid=r0;mi.default=mi;Rl.exports=mi;if(typeof process!="undefined"&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform==="win32")){let t=r=>/^\\\\\?\\/.test(r)||/["<>|\u0000-\u001F]+/u.test(r)?r:r.replace(/\\/g,"/");zt.convert=t;let e=/^[a-z]:\//i;zt.isNotRelative=r=>e.test(r)||Ol(r)}});var Cl=O((Oy,Pl)=>{"use strict";function i0(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bt(t,e,r){return e=e instanceof RegExp?e:new RegExp(i0(e),"g"),t.replace(e,r)}var n0={clean:function(e){if(typeof e!="string")throw new Error("Expected a string, received: "+e);return e=Bt(e,"./","/"),e=Bt(e,"..","."),e=Bt(e," ","-"),e=Bt(e,/^[~^:?*\\\-]/g,""),e=Bt(e,/[~^:?*\\]/g,"-"),e=Bt(e,/[~^:?*\\\-]$/g,""),e=Bt(e,"@{","-"),e=Bt(e,/\.$/g,""),e=Bt(e,/\/$/g,""),e=Bt(e,/\.lock$/g,""),e}};Pl.exports=n0});var Dl=O((Ry,Bl)=>{Bl.exports=function(t,e){var r=t,i=e,n=r.length,a=i.length,o=!1,s=null,l=n+1,c=[],f=[],d=[],u="",h=-1,m=0,g=1,y,b,v=function(){n>=a&&(y=r,b=n,r=i,i=y,n=a,a=b,o=!0,l=n+1)},k=function(p,_,w){return{x:p,y:_,k:w}},S=function(p,_){return{elem:p,t:_}},x=function(p,_,w){var A,E,$;for(_>w?A=c[p-1+l]:A=c[p+1+l],$=Math.max(_,w),E=$-p;E<n&&$<a&&r[E]===i[$];)++E,++$;return c[p+l]=f.length,f[f.length]=new k(E,$,A),$},T=function(p){var _,w,A,E,$;for(_=w=1,A=E=0,$=p.length-1;$>=0;--$)for(;A<p[$].x||E<p[$].y;)p[$].y-p[$].x>E-A?(o?d[d.length]=new S(i[E],h):d[d.length]=new S(i[E],g),++w,++E):p[$].y-p[$].x<E-A?(o?d[d.length]=new S(r[A],g):d[d.length]=new S(r[A],h),++_,++A):(d[d.length]=new S(r[A],m),u+=r[A],++_,++w,++A,++E)};return v(),{SES_DELETE:-1,SES_COMMON:0,SES_ADD:1,editdistance:function(){return s},getlcs:function(){return u},getses:function(){return d},compose:function(){var p,_,w,A,E,$,R,B;for(p=a-n,_=n+a+3,w={},R=0;R<_;++R)w[R]=-1,c[R]=-1;A=-1;do{for(++A,B=-A;B<=p-1;++B)w[B+l]=x(B,w[B-1+l]+1,w[B+1+l]);for(B=p+A;B>=p+1;--B)w[B+l]=x(B,w[B-1+l]+1,w[B+1+l]);w[p+l]=x(p,w[p-1+l]+1,w[p+1+l])}while(w[p+l]!==a);for(s=p+2*A,E=c[p+l],$=[];E!==-1;)$[$.length]=new k(f[E].x,f[E].y,null),E=f[E].k;T($)}}}});var Ul=O((Iy,Fl)=>{var a0=Dl();function o0(t,e){var r=new a0(t,e);r.compose();for(var i=r.getses(),n,a,o=t.length-1,s=e.length-1,l=i.length-1;l>=0;--l)i[l].t===r.SES_COMMON?(a?(a.chain={file1index:o,file2index:s,chain:null},a=a.chain):(n={file1index:o,file2index:s,chain:null},a=n),o--,s--):i[l].t===r.SES_DELETE?o--:i[l].t===r.SES_ADD&&s--;var c={file1index:-1,file2index:-1,chain:null};return a?(a.chain=c,n):c}function Nl(t,e){for(var r=[],i=t.length,n=e.length,a=o0(t,e);a!==null;a=a.chain){var o=i-a.file1index-1,s=n-a.file2index-1;i=a.file1index,n=a.file2index,(o||s)&&r.push({file1:[i+1,o],file2:[n+1,s]})}return r.reverse(),r}function s0(t,e,r){var i,n=Nl(e,t),a=Nl(e,r),o=[];function s(R,B){o.push([R.file1[0],B,R.file1[1],R.file2[0],R.file2[1]])}for(i=0;i<n.length;i++)s(n[i],0);for(i=0;i<a.length;i++)s(a[i],2);o.sort(function(R,B){return R[0]-B[0]});var l=[],c=0;function f(R){R>c&&(l.push([1,c,R-c]),c=R)}for(var d=0;d<o.length;d++){for(var u=d,h=o[d],m=h[0],g=m+h[2];d<o.length-1;){var y=o[d+1],b=y[0];if(b>g)break;g=Math.max(g,b+y[2]),d++}if(f(m),u==d)h[4]>0&&l.push([h[1],h[3],h[4]]);else{var v={0:[t.length,-1,e.length,-1],2:[r.length,-1,e.length,-1]};for(i=u;i<=d;i++){h=o[i];var k=h[1],S=v[k],x=h[0],T=x+h[2],p=h[3],_=p+h[4];S[0]=Math.min(p,S[0]),S[1]=Math.max(_,S[1]),S[2]=Math.min(x,S[2]),S[3]=Math.max(T,S[3])}var w=v[0][0]+(m-v[0][2]),A=v[0][1]+(g-v[0][3]),E=v[2][0]+(m-v[2][2]),$=v[2][1]+(g-v[2][3]);l.push([-1,w,A-w,m,g-m,E,$-E])}c=g}return f(e.length),l}function c0(t,e,r){var i=[],n=[t,e,r],a=s0(t,e,r),o=[];function s(){o.length&&i.push({ok:o}),o=[]}function l(h){for(var m=0;m<h.length;m++)o.push(h[m])}function c(h){if(h[2]!=h[6])return!0;for(var m=h[1],g=h[5],y=0;y<h[2];y++)if(t[y+m]!=r[y+g])return!0;return!1}for(var f=0;f<a.length;f++){var d=a[f],u=d[0];u==-1?c(d)?(s(),i.push({conflict:{a:t.slice(d[1],d[1]+d[2]),aIndex:d[1],o:e.slice(d[3],d[3]+d[4]),oIndex:d[3],b:r.slice(d[5],d[5]+d[6]),bIndex:d[5]}})):l(n[0].slice(d[1],d[1]+d[2])):l(n[u].slice(d[1],d[1]+d[2]))}return s(),i}Fl.exports=c0});var qm={};Qu(qm,{default:()=>Ji});module.exports=Ju(qm);var at=require("obsidian");var to={githubToken:"",githubUsername:"",repoName:"",autoSync:!0,syncIntervalMs:3e3,excludePatterns:[".obsidian/workspace",".obsidian/workspace.json",".obsidian/plugins/*/data.json"],lastSyncTime:0,commitMessageTemplate:"sync: {{datetime}}"};var ot=require("obsidian");var on=require("obsidian");var nn="Ov23liN8a7D1bDe2571X",eo="https://github.com/login/device/code",ro="https://github.com/login/oauth/access_token",an="https://api.github.com";var Pr="ObsidianMultiSync",Cr="sync@obsidian.local";var wt="main";async function io(){let t=await(0,on.requestUrl)({url:eo,method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:`client_id=${nn}&scope=repo`,throw:!1});if(t.status!==200)throw new Error(`GitHub Device Flow failed: ${t.status}`);return t.json}async function no(t,e,r,i){let n=Date.now()+r*1e3,a=e*1e3;return new Promise((o,s)=>{let l=async()=>{if(Date.now()>n){s(new Error("Device code expired. Please try connecting again."));return}i==null||i();let f=(await(0,on.requestUrl)({url:ro,method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:`client_id=${nn}&device_code=${t}&grant_type=urn:ietf:params:oauth:grant-type:device_code`,throw:!1})).json;if(f.access_token){o(f.access_token);return}switch(f.error){case"authorization_pending":setTimeout(l,a);break;case"slow_down":a+=5e3,setTimeout(l,a);break;case"expired_token":s(new Error("Code expired. Please reconnect."));break;case"access_denied":s(new Error("Access denied. You cancelled the authorization."));break;default:s(new Error(`Unknown error: ${f.error}`))}};setTimeout(l,a)})}var sn=require("obsidian");async function ao(t,e,r={}){var n,a;let i=await(0,sn.requestUrl)({url:`${an}${t}`,method:(n=r.method)!=null?n:"GET",headers:{Authorization:`Bearer ${e}`,Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","Content-Type":"application/json"},body:r.body?JSON.stringify(r.body):void 0,throw:!1});if(i.status>=400){let o=i.json;throw new Error(`GitHub API error ${i.status}: ${(a=o.message)!=null?a:"unknown"}`)}return i.json}async function oo(t){return ao("/user",t)}async function so(t,e,r){return(await(0,sn.requestUrl)({url:`${an}/repos/${e}/${r}`,method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/vnd.github+json"},throw:!1})).status===200}async function co(t,e,r){return ao("/user/repos",t,{method:"POST",body:{name:e,description:r,private:!0,auto_init:!1}})}function fo(t){return`obsidian-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}`}var Br=class extends ot.PluginSettingTab{constructor(e,r){super(e,r),this.plugin=r}display(){let{containerEl:e}=this;e.empty(),e.createEl("h2",{text:"MultiSync Settings"});let r=this.plugin.settings;if(e.createEl("h3",{text:"GitHub Account"}),r.githubToken&&r.githubUsername?(new ot.Setting(e).setName("Connected account").setDesc(`Signed in as @${r.githubUsername}`).addButton(i=>i.setButtonText("Disconnect").setWarning().onClick(async()=>{r.githubToken="",r.githubUsername="",r.repoName="",await this.plugin.saveSettings(),this.display(),new ot.Notice("Disconnected from GitHub.")})),new ot.Setting(e).setName("Vault repo").setDesc(`github.com/${r.githubUsername}/${r.repoName}`)):new ot.Setting(e).setName("Connect GitHub account").setDesc("Authorise MultiSync to access your private repos. Opens a browser window.").addButton(i=>{i.setButtonText("Connect GitHub").setCta().onClick(async()=>{await this.startDeviceFlow(i)})}),e.createEl("h3",{text:"Sync Options"}),new ot.Setting(e).setName("Auto-sync").setDesc("Automatically sync when files are modified.").addToggle(i=>i.setValue(r.autoSync).onChange(async n=>{r.autoSync=n,await this.plugin.saveSettings()})),new ot.Setting(e).setName("Sync debounce (ms)").setDesc("Wait this many milliseconds after the last edit before syncing.").addSlider(i=>i.setLimits(1e3,1e4,500).setValue(r.syncIntervalMs).setDynamicTooltip().onChange(async n=>{r.syncIntervalMs=n,await this.plugin.saveSettings()})),new ot.Setting(e).setName("Excluded patterns").setDesc("One pattern per line. These files will never be synced.").addTextArea(i=>i.setValue(r.excludePatterns.join(`
|
|
`)).onChange(async n=>{r.excludePatterns=n.split(`
|
|
`).map(a=>a.trim()).filter(Boolean),await this.plugin.saveSettings()})),e.createEl("h3",{text:"Manual Sync"}),new ot.Setting(e).setName("Sync now").setDesc("Immediately push all local changes and pull remote changes.").addButton(i=>i.setButtonText("Sync Now").onClick(async()=>{await this.plugin.triggerManualSync()})),r.lastSyncTime>0){let i=new Date(r.lastSyncTime).toLocaleString();e.createEl("p",{text:`Last synced: ${i}`,cls:"setting-item-description"})}}async startDeviceFlow(e){var r;e.setButtonText("Connecting\u2026").setDisabled(!0);try{let i=await io(),n=this.containerEl.createDiv({cls:"multisync-device-modal"});n.style.cssText="background:var(--background-secondary);border-radius:8px;padding:16px;margin-top:12px;text-align:center;",n.createEl("p",{text:"Open this URL in your browser and enter the code below:"});let a=n.createEl("a",{text:i.verification_uri,href:i.verification_uri});a.style.display="block";let o=n.createEl("h1",{text:i.user_code,cls:"multisync-user-code"});o.style.cssText="font-size:2rem;letter-spacing:0.25em;font-weight:700;color:var(--text-normal);background:var(--background-primary);border:2px solid var(--interactive-accent);border-radius:6px;padding:8px 24px;display:inline-block;margin:12px auto;font-family:monospace;",n.createEl("p",{text:"Waiting for you to approve in the browser\u2026",cls:"setting-item-description"}),e.setButtonText("Cancel").setDisabled(!1),window.open(i.verification_uri,"_blank");let s=await no(i.device_code,i.interval,i.expires_in);n.remove();let l=await oo(s);this.plugin.settings.githubToken=s,this.plugin.settings.githubUsername=l.login,await this.plugin.initializeRepo(s,l.login),await this.plugin.saveSettings(),new ot.Notice(`Connected as @${l.login}. Vault syncing started!`),this.display()}catch(i){let n=i instanceof Error?i.message:String(i);(r=this.containerEl.querySelector(".multisync-device-modal"))==null||r.remove(),new ot.Notice(`Connection failed: ${n}`),e.setButtonText("Connect GitHub").setDisabled(!1)}}};var td={idle:"\u2713 MultiSync",pulling:"\u2193 Syncing\u2026",pushing:"\u2191 Syncing\u2026",conflict:"\u26A0 Conflict",error:"\u2717 Sync Error",connecting:"\u2026 Connecting"},Dr=class{constructor(e){this.el=e.addStatusBarItem(),this.el.style.cursor="pointer",this.set("idle")}set(e,r){let i=td[e];this.el.setText(r?`${i}: ${r}`:i),this.el.setAttribute("data-sync-status",e)}onClick(e){this.el.addEventListener("click",e)}};var ge=require("obsidian");function lo(t){var a,o;let e=t.ours.split(`
|
|
`),r=t.theirs.split(`
|
|
`),i=Math.max(e.length,r.length),n=[];for(let s=0;s<i;s++){let l=(a=e[s])!=null?a:"",c=(o=r[s])!=null?o:"";l!==c&&(n.push(`Line ${s+1}:`),l&&n.push(` - ${l}`),c&&n.push(` + ${c}`))}return n.length>0?n.join(`
|
|
`):"(files are identical \u2014 safe to accept either)"}var Nr=class extends ge.Modal{constructor(r,i,n){super(r);this.currentIndex=0;this.conflicts=i,this.onResolve=n,this.component=new ge.Component}onOpen(){this.component.load(),this.renderCurrent()}onClose(){this.component.unload(),this.contentEl.empty()}renderCurrent(){let r=this.conflicts[this.currentIndex],{contentEl:i}=this;i.empty(),i.createEl("h2",{text:`Sync Conflict (${this.currentIndex+1} / ${this.conflicts.length})`}),i.createEl("p",{text:`File: ${r.path}`,cls:"conflict-filepath"});let n=i.createEl("pre",{cls:"conflict-diff"});n.style.cssText="background:var(--background-secondary);padding:8px;border-radius:4px;overflow:auto;max-height:180px;font-size:12px;",n.textContent=lo(r);let a=i.createDiv({cls:"conflict-columns"});a.style.cssText="display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:12px 0;";let o=a.createDiv();o.createEl("h4",{text:"Your version (this device)"});let s=o.createEl("pre");s.style.cssText="background:#1a3a1a;padding:8px;border-radius:4px;overflow:auto;max-height:260px;font-size:11px;white-space:pre-wrap;",s.textContent=r.ours.slice(0,2e3)+(r.ours.length>2e3?`
|
|
\u2026(truncated)`:"");let l=a.createDiv();l.createEl("h4",{text:"Remote version (other device)"});let c=l.createEl("pre");c.style.cssText="background:#1a1a3a;padding:8px;border-radius:4px;overflow:auto;max-height:260px;font-size:11px;white-space:pre-wrap;",c.textContent=r.theirs.slice(0,2e3)+(r.theirs.length>2e3?`
|
|
\u2026(truncated)`:""),new ge.Setting(i).addButton(f=>f.setButtonText("Keep Mine").onClick(async()=>{await this.resolve(r,r.ours)})).addButton(f=>f.setButtonText("Keep Theirs").setCta().onClick(async()=>{await this.resolve(r,r.theirs)})).addButton(f=>f.setButtonText("Open in Editor").onClick(()=>{this.close(),this.app.workspace.openLinkText(r.path,"",!0)}))}async resolve(r,i){await this.onResolve(r.path,i),this.currentIndex++,this.currentIndex<this.conflicts.length?this.renderCurrent():this.close()}};var yr=Gt(wo(),1),Xa=Gt(Oc(),1),ou=Gt(Ic(),1),Zi=Gt(bl(),1),gr=Gt(xl(),1),su=Gt(Il(),1),cu=Gt(Cl(),1),fu=Gt(Ul(),1),F=class t extends Error{constructor(e){super(e),this.caller=""}toJSON(){return{code:this.code,data:this.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(e){let r=new t(e.message);return r.code=e.code,r.data=e.data,r.caller=e.caller,r.stack=e.stack,r}get isIsomorphicGitError(){return!0}},bi=class t extends F{constructor(e){super(`Modifying the index is not possible because you have unmerged files: ${e.toString}. Fix them up in the work tree, and then use 'git add/rm as appropriate to mark resolution and make a commit.`),this.code=this.name=t.code,this.data={filepaths:e}}};bi.code="UnmergedPathsError";var I=class t extends F{constructor(e){super(`An internal error caused this command to fail.
|
|
|
|
If you're not a developer, report the bug to the developers of the application you're using. If this is a bug in isomorphic-git then you should create a proper bug yourselves. The bug should include a minimal reproduction and details about the version and environment.
|
|
|
|
Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${e}`),this.code=this.name=t.code,this.data={message:e}}};I.code="InternalError";var br=class t extends F{constructor(e){super(`The filepath "${e}" contains unsafe character sequences`),this.code=this.name=t.code,this.data={filepath:e}}};br.code="UnsafeFilepathError";var bt=class{constructor(e){this.buffer=e,this._start=0}eof(){return this._start>=this.buffer.length}tell(){return this._start}seek(e){this._start=e}slice(e){let r=this.buffer.slice(this._start,this._start+e);return this._start+=e,r}toString(e,r){let i=this.buffer.toString(e,this._start,this._start+r);return this._start+=r,i}write(e,r,i){let n=this.buffer.write(e,this._start,r,i);return this._start+=r,n}copy(e,r,i){let n=e.copy(this.buffer,this._start,r,i);return this._start+=n,n}readUInt8(){let e=this.buffer.readUInt8(this._start);return this._start+=1,e}writeUInt8(e){let r=this.buffer.writeUInt8(e,this._start);return this._start+=1,r}readUInt16BE(){let e=this.buffer.readUInt16BE(this._start);return this._start+=2,e}writeUInt16BE(e){let r=this.buffer.writeUInt16BE(e,this._start);return this._start+=2,r}readUInt32BE(){let e=this.buffer.readUInt32BE(this._start);return this._start+=4,e}writeUInt32BE(e){let r=this.buffer.writeUInt32BE(e,this._start);return this._start+=4,r}};function Wi(t,e){return-(t<e)||+(t>e)}function lu(t,e){return Wi(t.path,e.path)}function uu(t){let e=t>0?t>>12:0;e!==4&&e!==8&&e!==10&&e!==14&&(e=8);let r=t&511;return r&73?r=493:r=420,e!==8&&(r=0),(e<<12)+r}var Dt=2**32;function jl(t,e,r,i){if(t!==void 0&&e!==void 0)return[t,e];r===void 0&&(r=i.valueOf());let n=Math.floor(r/1e3),a=(r-n*1e3)*1e6;return[n,a]}function Me(t){let[e,r]=jl(t.ctimeSeconds,t.ctimeNanoseconds,t.ctimeMs,t.ctime),[i,n]=jl(t.mtimeSeconds,t.mtimeNanoseconds,t.mtimeMs,t.mtime);return{ctimeSeconds:e%Dt,ctimeNanoseconds:r%Dt,mtimeSeconds:i%Dt,mtimeNanoseconds:n%Dt,dev:t.dev%Dt,ino:t.ino%Dt,mode:uu(t.mode%Dt),uid:t.uid%Dt,gid:t.gid%Dt,size:t.size>-1?t.size%Dt:0}}function f0(t){let e="";for(let r of new Uint8Array(t))r<16&&(e+="0"),e+=r.toString(16);return e}var ya=null;async function Qt(t){return ya===null&&(ya=await u0()),ya?du(t):l0(t)}function l0(t){return new Xa.default().update(t).digest("hex")}async function du(t){let e=await crypto.subtle.digest("SHA-1",t);return f0(e)}async function u0(){try{return await du(new Uint8Array([]))==="da39a3ee5e6b4b0d3255bfef95601890afd80709"}catch(t){}return!1}function d0(t){return{assumeValid:!!(t&32768),extended:!!(t&16384),stage:(t&12288)>>12,nameLength:t&4095}}function h0(t){let e=t.flags;return e.extended=!1,e.nameLength=Math.min(Buffer.from(t.path).length,4095),(e.assumeValid?32768:0)+(e.extended?16384:0)+((e.stage&3)<<12)+(e.nameLength&4095)}var Oa=class t{constructor(e,r){this._dirty=!1,this._unmergedPaths=r||new Set,this._entries=e||new Map}_addEntry(e){if(e.flags.stage===0)e.stages=[e],this._entries.set(e.path,e),this._unmergedPaths.delete(e.path);else{let r=this._entries.get(e.path);r||(this._entries.set(e.path,e),r=e),r.stages[e.flags.stage]=e,this._unmergedPaths.add(e.path)}}static async from(e){if(Buffer.isBuffer(e))return t.fromBuffer(e);if(e===null)return new t(null);throw new I("invalid type passed to GitIndex.from")}static async fromBuffer(e){if(e.length===0)throw new I("Index file is empty (.git/index)");let r=new t,i=new bt(e),n=i.toString("utf8",4);if(n!=="DIRC")throw new I(`Invalid dircache magic file number: ${n}`);let a=await Qt(e.slice(0,-20)),o=e.slice(-20).toString("hex");if(o!==a)throw new I(`Invalid checksum in GitIndex buffer: expected ${o} but saw ${a}`);let s=i.readUInt32BE();if(s!==2)throw new I(`Unsupported dircache version: ${s}`);let l=i.readUInt32BE(),c=0;for(;!i.eof()&&c<l;){let f={};f.ctimeSeconds=i.readUInt32BE(),f.ctimeNanoseconds=i.readUInt32BE(),f.mtimeSeconds=i.readUInt32BE(),f.mtimeNanoseconds=i.readUInt32BE(),f.dev=i.readUInt32BE(),f.ino=i.readUInt32BE(),f.mode=i.readUInt32BE(),f.uid=i.readUInt32BE(),f.gid=i.readUInt32BE(),f.size=i.readUInt32BE(),f.oid=i.slice(20).toString("hex");let d=i.readUInt16BE();f.flags=d0(d);let u=e.indexOf(0,i.tell()+1)-i.tell();if(u<1)throw new I(`Got a path length of: ${u}`);if(f.path=i.toString("utf8",u),f.path.includes("..\\")||f.path.includes("../"))throw new br(f.path);let h=8-(i.tell()-12)%8;for(h===0&&(h=8);h--;){let m=i.readUInt8();if(m!==0)throw new I(`Expected 1-8 null characters but got '${m}' after ${f.path}`);if(i.eof())throw new I("Unexpected end of file")}f.stages=[],r._addEntry(f),c++}return r}get unmergedPaths(){return[...this._unmergedPaths]}get entries(){return[...this._entries.values()].sort(lu)}get entriesMap(){return this._entries}get entriesFlat(){return[...this.entries].flatMap(e=>e.stages.length>1?e.stages.filter(r=>r):e)}*[Symbol.iterator](){for(let e of this.entries)yield e}insert({filepath:e,stats:r,oid:i,stage:n=0}){r||(r={ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:0,uid:0,gid:0,size:0}),r=Me(r);let a=Buffer.from(e),o={ctimeSeconds:r.ctimeSeconds,ctimeNanoseconds:r.ctimeNanoseconds,mtimeSeconds:r.mtimeSeconds,mtimeNanoseconds:r.mtimeNanoseconds,dev:r.dev,ino:r.ino,mode:r.mode||33188,uid:r.uid,gid:r.gid,size:r.size,path:e,oid:i,flags:{assumeValid:!1,extended:!1,stage:n,nameLength:a.length<4095?a.length:4095},stages:[]};this._addEntry(o),this._dirty=!0}delete({filepath:e}){if(this._entries.has(e))this._entries.delete(e);else for(let r of this._entries.keys())r.startsWith(e+"/")&&this._entries.delete(r);this._unmergedPaths.has(e)&&this._unmergedPaths.delete(e),this._dirty=!0}clear(){this._entries.clear(),this._dirty=!0}has({filepath:e}){return this._entries.has(e)}render(){return this.entries.map(e=>`${e.mode.toString(8)} ${e.oid} ${e.path}`).join(`
|
|
`)}static async _entryToBuffer(e){let r=Buffer.from(e.path),i=Math.ceil((62+r.length+1)/8)*8,n=Buffer.alloc(i),a=new bt(n),o=Me(e);return a.writeUInt32BE(o.ctimeSeconds),a.writeUInt32BE(o.ctimeNanoseconds),a.writeUInt32BE(o.mtimeSeconds),a.writeUInt32BE(o.mtimeNanoseconds),a.writeUInt32BE(o.dev),a.writeUInt32BE(o.ino),a.writeUInt32BE(o.mode),a.writeUInt32BE(o.uid),a.writeUInt32BE(o.gid),a.writeUInt32BE(o.size),a.write(e.oid,20,"hex"),a.writeUInt16BE(h0(e)),a.write(e.path,r.length,"utf8"),n}async toObject(){let e=Buffer.alloc(12),r=new bt(e);r.write("DIRC",4,"utf8"),r.writeUInt32BE(2),r.writeUInt32BE(this.entriesFlat.length);let i=[];for(let s of this.entries)if(i.push(t._entryToBuffer(s)),s.stages.length>1)for(let l of s.stages)l&&l!==s&&i.push(t._entryToBuffer(l));i=await Promise.all(i);let n=Buffer.concat(i),a=Buffer.concat([e,n]),o=await Qt(a);return Buffer.concat([a,Buffer.from(o,"hex")])}};function Ra(t,e,r=!0,i=!0){let n=Me(t),a=Me(e);return r&&n.mode!==a.mode||n.mtimeSeconds!==a.mtimeSeconds||n.ctimeSeconds!==a.ctimeSeconds||n.uid!==a.uid||n.gid!==a.gid||i&&n.ino!==a.ino||n.size!==a.size}var ba=null,_a=Symbol("IndexCache");function p0(){return{map:new Map,stats:new Map}}async function w0(t,e,r){let[i,n]=await Promise.all([t.lstat(e),t.read(e)]),a=await Oa.from(n);r.map.set(e,a),r.stats.set(e,i)}async function m0(t,e,r){let i=r.stats.get(e);if(i===void 0)return!0;if(i===null)return!1;let n=await t.lstat(e);return n===null?!1:Ra(i,n)}var _t=class{static async acquire({fs:e,gitdir:r,cache:i,allowUnmerged:n=!0},a){i[_a]||(i[_a]=p0());let o=`${r}/index`;ba===null&&(ba=new yr.default({maxPending:1/0}));let s,l=[];return await ba.acquire(o,async()=>{let c=i[_a];await m0(e,o,c)&&await w0(e,o,c);let f=c.map.get(o);if(l=f.unmergedPaths,l.length&&!n)throw new bi(l);if(s=await a(f),f._dirty){let d=await f.toObject();await e.write(o,d),c.stats.set(o,await e.lstat(o)),f._dirty=!1}}),s}};function _i(t){let e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>-1&&(t=t.slice(e+1)),t}function ze(t){let e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e===-1?".":e===0?"/":t.slice(0,e)}function hu(t){let e=new Map,r=function(n){if(!e.has(n)){let a={type:"tree",fullpath:n,basename:_i(n),metadata:{},children:[]};e.set(n,a),a.parent=r(ze(n)),a.parent&&a.parent!==a&&a.parent.children.push(a)}return e.get(n)},i=function(n,a){if(!e.has(n)){let o={type:"blob",fullpath:n,basename:_i(n),metadata:a,parent:r(ze(n)),children:[]};o.parent&&o.parent.children.push(o),e.set(n,o)}return e.get(n)};r(".");for(let n of t)i(n.path,n);return e}function g0(t){switch(t){case 16384:return"tree";case 33188:return"blob";case 33261:return"blob";case 40960:return"blob";case 57344:return"commit"}throw new I(`Unexpected GitTree entry mode: ${t.toString(8)}`)}var Ia=class{constructor({fs:e,gitdir:r,cache:i}){this.treePromise=_t.acquire({fs:e,gitdir:r,cache:i},async function(a){return hu(a.entries)});let n=this;this.ConstructEntry=class{constructor(o){this._fullpath=o,this._type=!1,this._mode=!1,this._stat=!1,this._oid=!1}async type(){return n.type(this)}async mode(){return n.mode(this)}async stat(){return n.stat(this)}async content(){return n.content(this)}async oid(){return n.oid(this)}}}async readdir(e){let r=e._fullpath,n=(await this.treePromise).get(r);if(!n||n.type==="blob")return null;if(n.type!=="tree")throw new Error(`ENOTDIR: not a directory, scandir '${r}'`);let a=n.children.map(o=>o.fullpath);return a.sort(Wi),a}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){let i=(await this.treePromise).get(e._fullpath);if(!i)throw new Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);let n=i.type==="tree"?{}:Me(i.metadata);e._type=i.type==="tree"?"tree":g0(n.mode),e._mode=n.mode,i.type==="tree"?e._stat=void 0:e._stat=n}return e._stat}async content(e){}async oid(e){if(e._oid===!1){let i=(await this.treePromise).get(e._fullpath);e._oid=i.metadata.oid}return e._oid}},Vi=Symbol("GitWalkSymbol");function pu(){let t=Object.create(null);return Object.defineProperty(t,Vi,{value:function({fs:e,gitdir:r,cache:i}){return new Ia({fs:e,gitdir:r,cache:i})}}),Object.freeze(t),t}var ct=class t extends F{constructor(e){super(`Could not find ${e}.`),this.code=this.name=t.code,this.data={what:e}}};ct.code="NotFoundError";var Nt=class t extends F{constructor(e,r,i,n){super(`Object ${e} ${n?`at ${n}`:""}was anticipated to be a ${i} but it is a ${r}.`),this.code=this.name=t.code,this.data={oid:e,actual:r,expected:i,filepath:n}}};Nt.code="ObjectTypeError";var he=class t extends F{constructor(e){super(`Expected a 40-char hex object id but saw "${e}".`),this.code=this.name=t.code,this.data={value:e}}};he.code="InvalidOidError";var vi=class t extends F{constructor(e){super(`Could not find a fetch refspec for remote "${e}". Make sure the config file has an entry like the following:
|
|
[remote "${e}"]
|
|
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
`),this.code=this.name=t.code,this.data={remote:e}}};vi.code="NoRefspecError";var xi=class t{constructor(e){if(this.refs=new Map,this.parsedConfig=[],e){let r=null;this.parsedConfig=e.trim().split(`
|
|
`).map(i=>{if(/^\s*#/.test(i))return{line:i,comment:!0};let n=i.indexOf(" ");if(i.startsWith("^")){let a=i.slice(1);return this.refs.set(r+"^{}",a),{line:i,ref:r,peeled:a}}else{let a=i.slice(0,n);return r=i.slice(n+1),this.refs.set(r,a),{line:i,ref:r,oid:a}}})}return this}static from(e){return new t(e)}delete(e){this.parsedConfig=this.parsedConfig.filter(r=>r.ref!==e),this.refs.delete(e)}toString(){return this.parsedConfig.map(({line:e})=>e).join(`
|
|
`)+`
|
|
`}},Ei=class t{constructor({remotePath:e,localPath:r,force:i,matchPrefix:n}){Object.assign(this,{remotePath:e,localPath:r,force:i,matchPrefix:n})}static from(e){let[r,i,n,a,o]=e.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),s=r==="+",l=n==="*";if(l!==(o==="*"))throw new I("Invalid refspec");return new t({remotePath:i,localPath:a,force:s,matchPrefix:l})}translate(e){if(this.matchPrefix){if(e.startsWith(this.remotePath))return this.localPath+e.replace(this.remotePath,"")}else if(e===this.remotePath)return this.localPath;return null}reverseTranslate(e){if(this.matchPrefix){if(e.startsWith(this.localPath))return this.remotePath+e.replace(this.localPath,"")}else if(e===this.localPath)return this.remotePath;return null}},Pa=class t{constructor(e=[]){this.rules=e}static from(e){let r=[];for(let i of e)r.push(Ei.from(i));return new t(r)}add(e){let r=Ei.from(e);this.rules.push(r)}translate(e){let r=[];for(let i of this.rules)for(let n of e){let a=i.translate(n);a&&r.push([n,a])}return r}translateOne(e){let r=null;for(let i of this.rules){let n=i.translate(e);n&&(r=n)}return r}localNamespaces(){return this.rules.filter(e=>e.matchPrefix).map(e=>e.localPath.replace(/\/$/,""))}};function y0(t,e){let r=t.replace(/\^\{\}$/,""),i=e.replace(/\^\{\}$/,""),n=-(r<i)||+(r>i);return n===0?t.endsWith("^{}")?1:-1:n}function b0(t,e){let r="",i=0,n=-1,a=0,o="\0";for(let s=0;s<=t.length;++s){if(s<t.length)o=t[s];else{if(o==="/")break;o="/"}if(o==="/"){if(!(n===s-1||a===1))if(a===2){if(r.length<2||i!==2||r.at(-1)!=="."||r.at(-2)!=="."){if(r.length>2){let l=r.lastIndexOf("/");l===-1?(r="",i=0):(r=r.slice(0,l),i=r.length-1-r.lastIndexOf("/")),n=s,a=0;continue}else if(r.length!==0){r="",i=0,n=s,a=0;continue}}e&&(r+=r.length>0?"/..":"..",i=2)}else r.length>0?r+="/"+t.slice(n+1,s):r=t.slice(n+1,s),i=s-n-1;n=s,a=0}else o==="."&&a!==-1?++a:a=-1}return r}function _0(t){if(!t.length)return".";let e=t[0]==="/",r=t.at(-1)==="/";return t=b0(t,!e),t.length?(r&&(t+="/"),e?`/${t}`:t):e?"/":r?"./":"."}function P(...t){if(t.length===0)return".";let e;for(let r=0;r<t.length;++r){let i=t[r];i.length>0&&(e===void 0?e=i:e+="/"+i)}return e===void 0?".":_0(e)}var v0=t=>{if(typeof t=="number")return t;t=t.toLowerCase();let e=parseInt(t);return t.endsWith("k")&&(e*=1024),t.endsWith("m")&&(e*=1024*1024),t.endsWith("g")&&(e*=1024*1024*1024),e},mr=t=>{if(typeof t=="boolean")return t;if(t=t.trim().toLowerCase(),t==="true"||t==="yes"||t==="on")return!0;if(t==="false"||t==="no"||t==="off")return!1;throw Error(`Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${t}`)},Ml={core:{filemode:mr,bare:mr,logallrefupdates:mr,symlinks:mr,ignorecase:mr,bigFileThreshold:v0}},x0=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,E0=/^[A-Za-z0-9-.]+$/,S0=/^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/,k0=/^[A-Za-z][A-Za-z-]*$/,A0=/^(.*?)( *[#;].*)$/,T0=t=>{let e=x0.exec(t);if(e!=null){let[r,i]=e.slice(1);return[r,i]}return null},$0=t=>{let e=S0.exec(t);if(e!=null){let[r,i="true"]=e.slice(1),n=O0(i),a=R0(n);return[r,a]}return null},O0=t=>{let e=A0.exec(t);if(e==null)return t;let[r,i]=e.slice(1);return zl(r)&&zl(i)?`${r}${i}`:r},zl=t=>(t.match(/(?:^|[^\\])"/g)||[]).length%2!==0,R0=t=>t.split("").reduce((e,r,i,n)=>{let a=r==='"'&&n[i-1]!=="\\",o=r==="\\"&&n[i+1]==='"';return a||o?e:e+r},""),Ll=t=>t!=null?t.toLowerCase():null,Ca=(t,e,r)=>[Ll(t),e,Ll(r)].filter(i=>i!=null).join("."),Hl=t=>{let e=t.split("."),r=e.shift(),i=e.pop(),n=e.length?e.join("."):void 0;return{section:r,subsection:n,name:i,path:Ca(r,n,i),sectionPath:Ca(r,n,null),isSection:!!r}},I0=(t,e)=>t.reduce((r,i,n)=>e(i)?n:r,-1),Ba=class t{constructor(e){let r=null,i=null;this.parsedConfig=e?e.split(`
|
|
`).map(n=>{let a=null,o=null,s=n.trim(),l=T0(s),c=l!=null;if(c)[r,i]=l;else{let d=$0(s);d!=null&&([a,o]=d)}let f=Ca(r,i,a);return{line:n,isSection:c,section:r,subsection:i,name:a,value:o,path:f}}):[]}static from(e){return new t(e)}async get(e,r=!1){let i=Hl(e).path,n=this.parsedConfig.filter(a=>a.path===i).map(({section:a,name:o,value:s})=>{let l=Ml[a]&&Ml[a][o];return l?l(s):s});return r?n:n.pop()}async getall(e){return this.get(e,!0)}async getSubsections(e){return this.parsedConfig.filter(r=>r.isSection&&r.section===e).map(r=>r.subsection)}async deleteSection(e,r){this.parsedConfig=this.parsedConfig.filter(i=>!(i.section===e&&i.subsection===r))}async append(e,r){return this.set(e,r,!0)}async set(e,r,i=!1){let{section:n,subsection:a,name:o,path:s,sectionPath:l,isSection:c}=Hl(e),f=I0(this.parsedConfig,d=>d.path===s);if(r==null)f!==-1&&this.parsedConfig.splice(f,1);else if(f!==-1){let d=this.parsedConfig[f],u=Object.assign({},d,{name:o,value:r,modified:!0});i?this.parsedConfig.splice(f+1,0,u):this.parsedConfig[f]=u}else{let d=this.parsedConfig.findIndex(h=>h.path===l),u={section:n,subsection:a,name:o,value:r,modified:!0,path:s};if(E0.test(n)&&k0.test(o))if(d>=0)this.parsedConfig.splice(d+1,0,u);else{let h={isSection:c,section:n,subsection:a,modified:!0,path:l};this.parsedConfig.push(h,u)}}}toString(){return this.parsedConfig.map(({line:e,section:r,subsection:i,name:n,value:a,modified:o=!1})=>o?n!=null&&a!=null?typeof a=="string"&&/[#;]/.test(a)?` ${n} = "${a}"`:` ${n} = ${a}`:i!=null?`[${r} "${i}"]`:`[${r}]`:e).join(`
|
|
`)}},J=class{static async get({fs:e,gitdir:r}){let i=await e.read(`${r}/config`,{encoding:"utf8"});return Ba.from(i)}static async save({fs:e,gitdir:r,config:i}){await e.write(`${r}/config`,i.toString(),{encoding:"utf8"})}},gi=t=>[`${t}`,`refs/${t}`,`refs/tags/${t}`,`refs/heads/${t}`,`refs/remotes/${t}`,`refs/remotes/${t}/HEAD`],P0=["config","description","index","shallow","commondir"],va;async function Kt(t,e){return va===void 0&&(va=new yr.default),va.acquire(t,e)}var D=class t{static async updateRemoteRefs({fs:e,gitdir:r,remote:i,refs:n,symrefs:a,tags:o,refspecs:s=void 0,prune:l=!1,pruneTags:c=!1}){for(let y of n.values())if(!y.match(/[0-9a-f]{40}/))throw new he(y);let f=await J.get({fs:e,gitdir:r});if(!s){if(s=await f.getall(`remote.${i}.fetch`),s.length===0)throw new vi(i);s.unshift(`+HEAD:refs/remotes/${i}/HEAD`)}let d=Pa.from(s),u=new Map;if(c){let y=await t.listRefs({fs:e,gitdir:r,filepath:"refs/tags"});await t.deleteRefs({fs:e,gitdir:r,refs:y.map(b=>`refs/tags/${b}`)})}if(o){for(let y of n.keys())if(y.startsWith("refs/tags")&&!y.endsWith("^{}")&&!await t.exists({fs:e,gitdir:r,ref:y})){let b=n.get(y);u.set(y,b)}}let h=d.translate([...n.keys()]);for(let[y,b]of h){let v=n.get(y);u.set(b,v)}let m=d.translate([...a.keys()]);for(let[y,b]of m){let v=a.get(y),k=d.translateOne(v);k&&u.set(b,`ref: ${k}`)}let g=[];if(l){for(let y of d.localNamespaces()){let b=(await t.listRefs({fs:e,gitdir:r,filepath:y})).map(v=>`${y}/${v}`);for(let v of b)u.has(v)||g.push(v)}g.length>0&&await t.deleteRefs({fs:e,gitdir:r,refs:g})}for(let[y,b]of u)await Kt(y,async()=>e.write(P(r,y),`${b.trim()}
|
|
`,"utf8"));return{pruned:g}}static async writeRef({fs:e,gitdir:r,ref:i,value:n}){if(!n.match(/[0-9a-f]{40}/))throw new he(n);await Kt(i,async()=>e.write(P(r,i),`${n.trim()}
|
|
`,"utf8"))}static async writeSymbolicRef({fs:e,gitdir:r,ref:i,value:n}){await Kt(i,async()=>e.write(P(r,i),`ref: ${n.trim()}
|
|
`,"utf8"))}static async deleteRef({fs:e,gitdir:r,ref:i}){return t.deleteRefs({fs:e,gitdir:r,refs:[i]})}static async deleteRefs({fs:e,gitdir:r,refs:i}){await Promise.all(i.map(s=>e.rm(P(r,s))));let n=await Kt("packed-refs",async()=>e.read(`${r}/packed-refs`,{encoding:"utf8"})),a=xi.from(n),o=a.refs.size;for(let s of i)a.refs.has(s)&&a.delete(s);a.refs.size<o&&(n=a.toString(),await Kt("packed-refs",async()=>e.write(`${r}/packed-refs`,n,{encoding:"utf8"})))}static async resolve({fs:e,gitdir:r,ref:i,depth:n=void 0}){if(n!==void 0&&(n--,n===-1))return i;if(i.startsWith("ref: "))return i=i.slice(5),t.resolve({fs:e,gitdir:r,ref:i,depth:n});if(i.length===40&&/[0-9a-f]{40}/.test(i))return i;let a=await t.packedRefs({fs:e,gitdir:r}),o=gi(i).filter(s=>!P0.includes(s));for(let s of o){let l=await Kt(s,async()=>await e.read(`${r}/${s}`,{encoding:"utf8"})||a.get(s));if(l)return t.resolve({fs:e,gitdir:r,ref:l.trim(),depth:n})}throw new ct(i)}static async exists({fs:e,gitdir:r,ref:i}){try{return await t.expand({fs:e,gitdir:r,ref:i}),!0}catch(n){return!1}}static async expand({fs:e,gitdir:r,ref:i}){if(i.length===40&&/[0-9a-f]{40}/.test(i))return i;let n=await t.packedRefs({fs:e,gitdir:r}),a=gi(i);for(let o of a)if(await Kt(o,async()=>e.exists(`${r}/${o}`))||n.has(o))return o;throw new ct(i)}static async expandAgainstMap({ref:e,map:r}){let i=gi(e);for(let n of i)if(await r.has(n))return n;throw new ct(e)}static resolveAgainstMap({ref:e,fullref:r=e,depth:i=void 0,map:n}){if(i!==void 0&&(i--,i===-1))return{fullref:r,oid:e};if(e.startsWith("ref: "))return e=e.slice(5),t.resolveAgainstMap({ref:e,fullref:r,depth:i,map:n});if(e.length===40&&/[0-9a-f]{40}/.test(e))return{fullref:r,oid:e};let a=gi(e);for(let o of a){let s=n.get(o);if(s)return t.resolveAgainstMap({ref:s.trim(),fullref:o,depth:i,map:n})}throw new ct(e)}static async packedRefs({fs:e,gitdir:r}){let i=await Kt("packed-refs",async()=>e.read(`${r}/packed-refs`,{encoding:"utf8"}));return xi.from(i).refs}static async listRefs({fs:e,gitdir:r,filepath:i}){let n=t.packedRefs({fs:e,gitdir:r}),a=null;try{a=await e.readdirDeep(`${r}/${i}`),a=a.map(o=>o.replace(`${r}/${i}/`,""))}catch(o){a=[]}for(let o of(await n).keys())o.startsWith(i)&&(o=o.replace(i+"/",""),a.includes(o)||a.push(o));return a.sort(y0),a}static async listBranches({fs:e,gitdir:r,remote:i}){return i?t.listRefs({fs:e,gitdir:r,filepath:`refs/remotes/${i}`}):t.listRefs({fs:e,gitdir:r,filepath:"refs/heads"})}static async listTags({fs:e,gitdir:r}){return(await t.listRefs({fs:e,gitdir:r,filepath:"refs/tags"})).filter(n=>!n.endsWith("^{}"))}};function C0(t,e){return Wi(Gl(t),Gl(e))}function Gl(t){return t.mode==="040000"?t.path+"/":t.path}function wu(t){switch(t){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new I(`Unexpected GitTree entry mode: ${t}`)}function B0(t){let e=[],r=0;for(;r<t.length;){let i=t.indexOf(32,r);if(i===-1)throw new I(`GitTree: Error parsing buffer at byte location ${r}: Could not find the next space character.`);let n=t.indexOf(0,r);if(n===-1)throw new I(`GitTree: Error parsing buffer at byte location ${r}: Could not find the next null character.`);let a=t.slice(r,i).toString("utf8");a==="40000"&&(a="040000");let o=wu(a),s=t.slice(i+1,n).toString("utf8");if(s.includes("\\")||s.includes("/"))throw new br(s);let l=t.slice(n+1,n+21).toString("hex");r=n+21,e.push({mode:a,path:s,oid:l,type:o})}return e}function D0(t){if(typeof t=="number"&&(t=t.toString(8)),t.match(/^0?4.*/))return"040000";if(t.match(/^1006.*/))return"100644";if(t.match(/^1007.*/))return"100755";if(t.match(/^120.*/))return"120000";if(t.match(/^160.*/))return"160000";throw new I(`Could not understand file mode: ${t}`)}function N0(t){return!t.oid&&t.sha&&(t.oid=t.sha),t.mode=D0(t.mode),t.type||(t.type=wu(t.mode)),t}var Ht=class t{constructor(e){if(Buffer.isBuffer(e))this._entries=B0(e);else if(Array.isArray(e))this._entries=e.map(N0);else throw new I("invalid type passed to GitTree constructor");this._entries.sort(lu)}static from(e){return new t(e)}render(){return this._entries.map(e=>`${e.mode} ${e.type} ${e.oid} ${e.path}`).join(`
|
|
`)}toObject(){let e=[...this._entries];return e.sort(C0),Buffer.concat(e.map(r=>{let i=Buffer.from(r.mode.replace(/^0/,"")),n=Buffer.from(" "),a=Buffer.from(r.path,"utf8"),o=Buffer.from([0]),s=Buffer.from(r.oid,"hex");return Buffer.concat([i,n,a,o,s])}))}entries(){return this._entries}*[Symbol.iterator](){for(let e of this._entries)yield e}},Le=class{static wrap({type:e,object:r}){let i=`${e} ${r.length}\0`,n=i.length,a=n+r.length,o=new Uint8Array(a);for(let s=0;s<n;s++)o[s]=i.charCodeAt(s);return o.set(r,n),o}static unwrap(e){let r=e.indexOf(32),i=e.indexOf(0),n=e.slice(0,r).toString("utf8"),a=e.slice(r+1,i).toString("utf8"),o=e.length-(i+1);if(parseInt(a)!==o)throw new I(`Length mismatch: expected ${a} bytes but got ${o} instead.`);return{type:n,object:Buffer.from(e.slice(i+1))}}};async function F0({fs:t,gitdir:e,oid:r}){let i=`objects/${r.slice(0,2)}/${r.slice(2)}`,n=await t.read(`${e}/${i}`);return n?{object:n,format:"deflated",source:i}:null}function U0(t,e){let r=new bt(t),i=ql(r);if(i!==e.byteLength)throw new I(`applyDelta expected source buffer to be ${i} bytes but the provided buffer was ${e.length} bytes`);let n=ql(r),a,o=Wl(r,e);if(o.byteLength===n)a=o;else{a=Buffer.alloc(n);let s=new bt(a);for(s.copy(o);!r.eof();)s.copy(Wl(r,e));let l=s.tell();if(n!==l)throw new I(`applyDelta expected target buffer to be ${n} bytes but the resulting buffer was ${l} bytes`)}return a}function ql(t){let e=0,r=0,i=null;do i=t.readUInt8(),e|=(i&127)<<r,r+=7;while(i&128);return e}function Zl(t,e,r){let i=0,n=0;for(;r--;)e&1&&(i|=t.readUInt8()<<n),e>>=1,n+=8;return i}function Wl(t,e){let r=t.readUInt8(),i=128,n=15,a=112;if(r&i){let o=Zl(t,r&n,4),s=Zl(t,(r&a)>>4,3);return s===0&&(s=65536),e.slice(o,o+s)}else return t.slice(r)}function j0(t){let e=[t];return{next(){return Promise.resolve({done:e.length===0,value:e.pop()})},return(){return e=[],{}},[Symbol.asyncIterator](){return this}}}function mu(t){return t[Symbol.asyncIterator]?t[Symbol.asyncIterator]():t[Symbol.iterator]?t[Symbol.iterator]():t.next?t:j0(t)}var Si=class{constructor(e){if(typeof Buffer=="undefined")throw new Error("Missing Buffer dependency");this.stream=mu(e),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(e){if(!this.eof())return this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e),this.buffer.slice(this.undoCursor,this.cursor)}async skip(e){this.eof()||(this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:e,value:r}=await this.stream.next();return e&&(this._ended=!0,!r)?Buffer.alloc(0):(r&&(r=Buffer.from(r)),r)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(e){this.undoCursor=this.cursor,this.cursor+=e,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(e){if(this._ended)return;let r=[this.buffer];for(;this.cursor+e>M0(r);){let i=await this._next();if(this._ended)break;r.push(i)}this.buffer=Buffer.concat(r)}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 M0(t){return t.reduce((e,r)=>e+r.length,0)}async function z0(t,e){let r=new Si(t),i=await r.read(4);if(i=i.toString("utf8"),i!=="PACK")throw new I(`Invalid PACK header '${i}'`);let n=await r.read(4);if(n=n.readUInt32BE(0),n!==2)throw new I(`Invalid packfile version: ${n}`);let a=await r.read(4);if(a=a.readUInt32BE(0),!(a<1))for(;!r.eof()&&a--;){let o=r.tell(),{type:s,length:l,ofs:c,reference:f}=await L0(r),d=new Zi.default.Inflate;for(;!d.result;){let u=await r.chunk();if(!u)break;if(d.push(u,!1),d.err)throw new I(`Pako error: ${d.msg}`);if(d.result){if(d.result.length!==l)throw new I("Inflated object size is different from that stated in packfile.");await r.undo(),await r.read(u.length-d.strm.avail_in);let h=r.tell();await e({data:d.result,type:s,num:a,offset:o,end:h,reference:f,ofs:c})}}}}async function L0(t){let e=await t.byte(),r=e>>4&7,i=e&15;if(e&128){let o=4;do e=await t.byte(),i|=(e&127)<<o,o+=7;while(e&128)}let n,a;if(r===6){let o=0;n=0;let s=[];do e=await t.byte(),n|=(e&127)<<o,o+=7,s.push(e);while(e&128);a=Buffer.from(s)}return r===7&&(a=await t.read(20)),{type:r,length:i,ofs:n,reference:a}}var xa=!1;async function gu(t){return xa===null&&(xa=G0()),xa?H0(t):Zi.default.inflate(t)}async function H0(t){let e=new DecompressionStream("deflate"),r=new Blob([t]).stream().pipeThrough(e);return new Uint8Array(await new Response(r).arrayBuffer())}function G0(){try{if(new DecompressionStream("deflate"))return!0}catch(t){}return!1}function q0(t){let e=[],r=0,i=0;do{r=t.readUInt8();let n=r&127;e.push(n),i=r&128}while(i);return e.reduce((n,a)=>n+1<<7|a,-1)}function Z0(t,e){let r=e,i=4,n=null;do n=t.readUInt8(),r|=(n&127)<<i,i+=7;while(n&128);return r}var ki=class t{constructor(e){Object.assign(this,e),this.offsetCache={}}static async fromIdx({idx:e,getExternalRefDelta:r}){let i=new bt(e);if(i.slice(4).toString("hex")!=="ff744f63")return;let a=i.readUInt32BE();if(a!==2)throw new I(`Unable to read version ${a} packfile IDX. (Only version 2 supported)`);if(e.byteLength>2048*1024*1024)throw new I("To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.");i.seek(i.tell()+4*255);let o=i.readUInt32BE(),s=[];for(let f=0;f<o;f++){let d=i.slice(20).toString("hex");s[f]=d}i.seek(i.tell()+4*o);let l=new Map;for(let f=0;f<o;f++)l.set(s[f],i.readUInt32BE());let c=i.slice(20).toString("hex");return new t({hashes:s,crcs:{},offsets:l,packfileSha:c,getExternalRefDelta:r})}static async fromPack({pack:e,getExternalRefDelta:r,onProgress:i}){let n={1:"commit",2:"tree",3:"blob",4:"tag",6:"ofs-delta",7:"ref-delta"},a={},o=e.slice(-20).toString("hex"),s=[],l={},c=new Map,f=null,d=null;await z0([e],async({data:y,type:b,reference:v,offset:k,num:S})=>{f===null&&(f=S);let x=Math.floor((f-S)*100/f);x!==d&&i&&await i({phase:"Receiving objects",loaded:f-S,total:f}),d=x,b=n[b],["commit","tree","blob","tag"].includes(b)?a[k]={type:b,offset:k}:b==="ofs-delta"?a[k]={type:b,offset:k}:b==="ref-delta"&&(a[k]={type:b,offset:k})});let u=Object.keys(a).map(Number);for(let[y,b]of u.entries()){let v=y+1===u.length?e.byteLength-20:u[y+1],k=a[b],S=ou.default.buf(e.slice(b,v))>>>0;k.end=v,k.crc=S}let h=new t({pack:Promise.resolve(e),packfileSha:o,crcs:l,hashes:s,offsets:c,getExternalRefDelta:r});d=null;let m=0,g=[0,0,0,0,0,0,0,0,0,0,0,0];for(let y in a){y=Number(y);let b=Math.floor(m*100/f);b!==d&&i&&await i({phase:"Resolving deltas",loaded:m,total:f}),m++,d=b;let v=a[y];if(!v.oid)try{h.readDepth=0,h.externalReadDepth=0;let{type:k,object:S}=await h.readSlice({start:y});g[h.readDepth]+=1;let x=await Qt(Le.wrap({type:k,object:S}));v.oid=x,s.push(x),c.set(x,y),l[x]=v.crc}catch(k){continue}}return s.sort(),h}async toBuffer(){let e=[],r=(c,f)=>{e.push(Buffer.from(c,f))};r("ff744f63","hex"),r("00000002","hex");let i=new bt(Buffer.alloc(256*4));for(let c=0;c<256;c++){let f=0;for(let d of this.hashes)parseInt(d.slice(0,2),16)<=c&&f++;i.writeUInt32BE(f)}e.push(i.buffer);for(let c of this.hashes)r(c,"hex");let n=new bt(Buffer.alloc(this.hashes.length*4));for(let c of this.hashes)n.writeUInt32BE(this.crcs[c]);e.push(n.buffer);let a=new bt(Buffer.alloc(this.hashes.length*4));for(let c of this.hashes)a.writeUInt32BE(this.offsets.get(c));e.push(a.buffer),r(this.packfileSha,"hex");let o=Buffer.concat(e),s=await Qt(o),l=Buffer.alloc(20);return l.write(s,"hex"),Buffer.concat([o,l])}async load({pack:e}){this.pack=e}async unload(){this.pack=null}async read({oid:e}){if(!this.offsets.get(e)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(e);throw new I(`Could not read object ${e} from packfile`)}let r=this.offsets.get(e);return this.readSlice({start:r})}async readSlice({start:e}){if(this.offsetCache[e])return Object.assign({},this.offsetCache[e]);this.readDepth++;let r={16:"commit",32:"tree",48:"blob",64:"tag",96:"ofs_delta",112:"ref_delta"},i=await this.pack;if(!i)throw new I("Could not read packfile data. The packfile may be missing, corrupted, or too large to read into memory.");let n=i.slice(e),a=new bt(n),o=a.readUInt8(),s=o&112,l=r[s];if(l===void 0)throw new I("Unrecognized type: 0b"+s.toString(2));let c=o&15,f=c;o&128&&(f=Z0(a,c));let u=null,h=null;if(l==="ofs_delta"){let g=q0(a),y=e-g;({object:u,type:l}=await this.readSlice({start:y}))}if(l==="ref_delta"){let g=a.slice(20).toString("hex");({object:u,type:l}=await this.read({oid:g}))}let m=n.slice(a.tell());if(h=Buffer.from(await gu(m)),h.byteLength!==f)throw new I(`Packfile told us object would have length ${f} but it had length ${h.byteLength}`);return u&&(h=Buffer.from(U0(h,u))),this.readDepth>3&&(this.offsetCache[e]={type:l,object:h}),{type:l,format:"content",object:h}}},yi=Symbol("PackfileCache");async function W0({fs:t,filename:e,getExternalRefDelta:r,emitter:i,emitterPrefix:n}){let a=await t.read(e);return ki.fromIdx({idx:a,getExternalRefDelta:r})}function yu({fs:t,cache:e,filename:r,getExternalRefDelta:i,emitter:n,emitterPrefix:a}){e[yi]||(e[yi]=new Map);let o=e[yi].get(r);return o||(o=W0({fs:t,filename:r,getExternalRefDelta:i,emitter:n,emitterPrefix:a}),e[yi].set(r,o)),o}async function V0(t,{start:e=0,end:r=t.length}={}){return Qt(t.subarray(e,r))}async function X0({fs:t,cache:e,gitdir:r,oid:i,format:n="content",getExternalRefDelta:a}){let o=await t.readdir(P(r,"objects/pack"));o=o.filter(s=>s.endsWith(".idx"));for(let s of o){let l=`${r}/objects/pack/${s}`,c=await yu({fs:t,cache:e,filename:l,getExternalRefDelta:a});if(c.error)throw new I(c.error);if(c.offsets.has(i)){let f=l.replace(/idx$/,"pack");c.pack||(c.pack=t.read(f));let d=await c.pack;if(!d)throw c.pack=null,new I(`Could not read packfile at ${f}. The file may be missing, corrupted, or too large to read into memory.`);if(!c._checksumVerified){let h=c.packfileSha,m=d.subarray(-20),g=Array.from(m).map(b=>b.toString(16).padStart(2,"0")).join("");if(g!==h)throw new I(`Packfile trailer mismatch: expected ${h}, got ${g}. The packfile may be corrupted.`);let y=await V0(d,{start:0,end:d.length-20});if(y!==h)throw new I(`Packfile payload corrupted: calculated ${y} but expected ${h}. The packfile may have been tampered with.`);c._checksumVerified=!0}let u=await c.read({oid:i,getExternalRefDelta:a});return u.format="content",u.source=`objects/pack/${s.replace(/idx$/,"pack")}`,u}}return null}async function K({fs:t,cache:e,gitdir:r,oid:i,format:n="content"}){let a=f=>K({fs:t,cache:e,gitdir:r,oid:f}),o;if(i==="4b825dc642cb6eb9a060e54bf8d69288fbee4904"&&(o={format:"wrapped",object:Buffer.from("tree 0\0")}),o||(o=await F0({fs:t,gitdir:r,oid:i})),!o){if(o=await X0({fs:t,cache:e,gitdir:r,oid:i,getExternalRefDelta:a}),!o)throw new ct(i);return o}if(n==="deflated"||(o.format==="deflated"&&(o.object=Buffer.from(await gu(o.object)),o.format="wrapped"),n==="wrapped"))return o;let s=await Qt(o.object);if(s!==i)throw new I(`SHA check failed! Expected ${i}, computed ${s}`);let{object:l,type:c}=Le.unwrap(o.object);if(o.type=c,o.object=l,o.format="content",n==="content")return o;throw new I(`invalid requested format "${n}"`)}var Ai=class t extends F{constructor(e,r,i=!0){super(`Failed to create ${e} at ${r} because it already exists.${i?` (Hint: use 'force: true' parameter to overwrite existing ${e}.)`:""}`),this.code=this.name=t.code,this.data={noun:e,where:r,canForce:i}}};Ai.code="AlreadyExistsError";var Da=class t extends F{constructor(e,r,i){super(`Found multiple ${e} matching "${r}" (${i.join(", ")}). Use a longer abbreviation length to disambiguate them.`),this.code=this.name=t.code,this.data={nouns:e,short:r,matches:i}}};Da.code="AmbiguousError";var Ti=class t extends F{constructor(e){super(`Your local changes to the following files would be overwritten by checkout: ${e.join(", ")}`),this.code=this.name=t.code,this.data={filepaths:e}}};Ti.code="CheckoutConflictError";var Na=class t extends F{constructor(e,r){super(`Cannot cherry-pick merge commit ${e}. Merge commits have ${r} parents and require specifying which parent to use as the base.`),this.code=this.name=t.code,this.data={oid:e,parentCount:r}}};Na.code="CherryPickMergeCommitError";var Fa=class t extends F{constructor(e){super(`Cannot cherry-pick root commit ${e}. Root commits have no parents.`),this.code=this.name=t.code,this.data={oid:e}}};Fa.code="CherryPickRootCommitError";var $i=class t extends F{constructor(e,r){super(`Failed to checkout "${e}" because commit ${r} is not available locally. Do a git fetch to make the branch available locally.`),this.code=this.name=t.code,this.data={ref:e,oid:r}}};$i.code="CommitNotFetchedError";var Oi=class t extends F{constructor(){super("Empty response from git server."),this.code=this.name=t.code,this.data={}}};Oi.code="EmptyServerResponseError";var Ri=class t extends F{constructor(){super("A simple fast-forward merge was not possible."),this.code=this.name=t.code,this.data={}}};Ri.code="FastForwardError";var Ii=class t extends F{constructor(e,r){super(`One or more branches were not updated: ${e}`),this.code=this.name=t.code,this.data={prettyDetails:e,result:r}}};Ii.code="GitPushError";var _r=class t extends F{constructor(e,r,i){super(`HTTP Error: ${e} ${r}`),this.code=this.name=t.code,this.data={statusCode:e,statusMessage:r,response:i}}};_r.code="HttpError";var vr=class t extends F{constructor(e){let r="invalid filepath";e==="leading-slash"||e==="trailing-slash"?r='"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.':e==="directory"&&(r='"filepath" should not be a directory.'),super(r),this.code=this.name=t.code,this.data={reason:e}}};vr.code="InvalidFilepathError";var Pi=class t extends F{constructor(e,r){super(`"${e}" would be an invalid git reference. (Hint: a valid alternative would be "${r}".)`),this.code=this.name=t.code,this.data={ref:e,suggestion:r}}};Pi.code="InvalidRefNameError";var Ci=class t extends F{constructor(e){super(`Maximum search depth of ${e} exceeded.`),this.code=this.name=t.code,this.data={depth:e}}};Ci.code="MaxDepthError";var xr=class t extends F{constructor(){super("Merges with conflicts are not supported yet."),this.code=this.name=t.code,this.data={}}};xr.code="MergeNotSupportedError";var Er=class t extends F{constructor(e,r,i,n){super(`Automatic merge failed with one or more merge conflicts in the following files: ${e.toString()}. Fix conflicts then commit the result.`),this.code=this.name=t.code,this.data={filepaths:e,bothModified:r,deleteByUs:i,deleteByTheirs:n}}};Er.code="MergeConflictError";var pe=class t extends F{constructor(e){super(`No name was provided for ${e} in the argument or in the .git/config file.`),this.code=this.name=t.code,this.data={role:e}}};pe.code="MissingNameError";var St=class t extends F{constructor(e){super(`The function requires a "${e}" parameter but none was provided.`),this.code=this.name=t.code,this.data={parameter:e}}};St.code="MissingParameterError";var He=class t extends F{constructor(e){super('There are multiple errors that were thrown by the method. Please refer to the "errors" property to see more'),this.code=this.name=t.code,this.data={errors:e},this.errors=e}};He.code="MultipleGitError";var Ge=class t extends F{constructor(e,r){super(`Expected "${e}" but received "${r}".`),this.code=this.name=t.code,this.data={expected:e,actual:r}}};Ge.code="ParseError";var Sr=class t extends F{constructor(e){let r="";e==="not-fast-forward"?r=" because it was not a simple fast-forward":e==="tag-exists"&&(r=" because tag already exists"),super(`Push rejected${r}. Use "force: true" to override.`),this.code=this.name=t.code,this.data={reason:e}}};Sr.code="PushRejectedError";var de=class t extends F{constructor(e,r){super(`Remote does not support the "${e}" so the "${r}" parameter cannot be used.`),this.code=this.name=t.code,this.data={capability:e,parameter:r}}};de.code="RemoteCapabilityError";var Bi=class t extends F{constructor(e,r){super(`Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: ${e}`),this.code=this.name=t.code,this.data={preview:e,response:r}}};Bi.code="SmartHttpError";var Di=class t extends F{constructor(e,r,i){super(`Git remote "${e}" uses an unrecognized transport protocol: "${r}"`),this.code=this.name=t.code,this.data={url:e,transport:r,suggestion:i}}};Di.code="UnknownTransportError";var Ni=class t extends F{constructor(e){super(`Cannot parse remote URL: "${e}"`),this.code=this.name=t.code,this.data={url:e}}};Ni.code="UrlParseError";var kr=class t extends F{constructor(){super("The operation was canceled."),this.code=this.name=t.code,this.data={}}};kr.code="UserCanceledError";var Ua=class t extends F{constructor(e){super(`Could not merge index: Entry for '${e}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`),this.code=this.name=t.code,this.data={filepath:e}}};Ua.code="IndexResetError";var Fi=class t extends F{constructor(e){super(`"${e}" does not point to any commit. You're maybe working on a repository with no commits yet. `),this.code=this.name=t.code,this.data={ref:e}}};Fi.code="NoCommitError";function ja({name:t,email:e,timestamp:r,timezoneOffset:i}){return i=Y0(i),`${t} <${e}> ${r} ${i}`}function Y0(t){let e=K0(Q0(t));t=Math.abs(t);let r=Math.floor(t/60);t-=r*60;let i=String(r),n=String(t);return i.length<2&&(i="0"+i),n.length<2&&(n="0"+n),(e===-1?"-":"+")+i+n}function K0(t){return Math.sign(t)||(Object.is(t,-0)?-1:1)}function Q0(t){return t===0?t:-t}function Lt(t){return t=t.replace(/\r/g,""),t=t.replace(/^\n+/,""),t=t.replace(/\n+$/,"")+`
|
|
`,t}function Ui(t){let[,e,r,i,n]=t.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:e,email:r,timestamp:Number(i),timezoneOffset:J0(n)}}function J0(t){let[,e,r,i]=t.match(/(\+|-)(\d\d)(\d\d)/);return i=(e==="+"?1:-1)*(Number(r)*60+Number(i)),tm(i)}function tm(t){return t===0?t:-t}var we=class t{constructor(e){if(typeof e=="string")this._tag=e;else if(Buffer.isBuffer(e))this._tag=e.toString("utf8");else if(typeof e=="object")this._tag=t.render(e);else throw new I("invalid type passed to GitAnnotatedTag constructor")}static from(e){return new t(e)}static render(e){return`object ${e.object}
|
|
type ${e.type}
|
|
tag ${e.tag}
|
|
tagger ${ja(e.tagger)}
|
|
|
|
${e.message}
|
|
${e.gpgsig?e.gpgsig:""}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(`
|
|
|
|
`))}message(){let e=this.withoutSignature();return e.slice(e.indexOf(`
|
|
|
|
`)+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){let e=this.justHeaders().split(`
|
|
`),r=[];for(let n of e)n[0]===" "?r[r.length-1]+=`
|
|
`+n.slice(1):r.push(n);let i={};for(let n of r){let a=n.slice(0,n.indexOf(" ")),o=n.slice(n.indexOf(" ")+1);Array.isArray(i[a])?i[a].push(o):i[a]=o}return i.tagger&&(i.tagger=Ui(i.tagger)),i.committer&&(i.committer=Ui(i.committer)),i}withoutSignature(){let e=Lt(this._tag);return e.indexOf(`
|
|
-----BEGIN PGP SIGNATURE-----`)===-1?e:e.slice(0,e.lastIndexOf(`
|
|
-----BEGIN PGP SIGNATURE-----`))}gpgsig(){if(this._tag.indexOf(`
|
|
-----BEGIN PGP SIGNATURE-----`)===-1)return;let e=this._tag.slice(this._tag.indexOf("-----BEGIN PGP SIGNATURE-----"),this._tag.indexOf("-----END PGP SIGNATURE-----")+27);return Lt(e)}payload(){return this.withoutSignature()+`
|
|
`}toObject(){return Buffer.from(this._tag,"utf8")}static async sign(e,r,i){let n=e.payload(),{signature:a}=await r({payload:n,secretKey:i});a=Lt(a);let o=n+a;return t.from(o)}};function Ea(t){return t.trim().split(`
|
|
`).map(e=>" "+e).join(`
|
|
`)+`
|
|
`}function em(t){return t.split(`
|
|
`).map(e=>e.replace(/^ /,"")).join(`
|
|
`)}var kt=class t{constructor(e){if(typeof e=="string")this._commit=e;else if(Buffer.isBuffer(e))this._commit=e.toString("utf8");else if(typeof e=="object")this._commit=t.render(e);else throw new I("invalid type passed to GitCommit constructor")}static fromPayloadSignature({payload:e,signature:r}){let i=t.justHeaders(e),n=t.justMessage(e),a=Lt(i+`
|
|
gpgsig`+Ea(r)+`
|
|
`+n);return new t(a)}static from(e){return new t(e)}toObject(){return Buffer.from(this._commit,"utf8")}headers(){return this.parseHeaders()}message(){return t.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(e){return Lt(e.slice(e.indexOf(`
|
|
|
|
`)+2))}static justHeaders(e){return e.slice(0,e.indexOf(`
|
|
|
|
`))}parseHeaders(){let e=t.justHeaders(this._commit).split(`
|
|
`),r=[];for(let n of e)n[0]===" "?r[r.length-1]+=`
|
|
`+n.slice(1):r.push(n);let i={parent:[]};for(let n of r){let a=n.slice(0,n.indexOf(" ")),o=n.slice(n.indexOf(" ")+1);Array.isArray(i[a])?i[a].push(o):i[a]=o}return i.author&&(i.author=Ui(i.author)),i.committer&&(i.committer=Ui(i.committer)),i}static renderHeaders(e){let r="";if(e.tree?r+=`tree ${e.tree}
|
|
`:r+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
|
`,e.parent){if(e.parent.length===void 0)throw new I("commit 'parent' property should be an array");for(let a of e.parent)r+=`parent ${a}
|
|
`}let i=e.author;r+=`author ${ja(i)}
|
|
`;let n=e.committer||e.author;return r+=`committer ${ja(n)}
|
|
`,e.gpgsig&&(r+="gpgsig"+Ea(e.gpgsig)),r}static render(e){return t.renderHeaders(e)+`
|
|
`+Lt(e.message)}render(){return this._commit}withoutSignature(){let e=Lt(this._commit);if(e.indexOf(`
|
|
gpgsig`)===-1)return e;let r=e.slice(0,e.indexOf(`
|
|
gpgsig`)),i=e.slice(e.indexOf(`-----END PGP SIGNATURE-----
|
|
`)+28);return Lt(r+`
|
|
`+i)}isolateSignature(){let e=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return em(e)}static async sign(e,r,i){let n=e.withoutSignature(),a=t.justMessage(e._commit),{signature:o}=await r({payload:n,secretKey:i});o=Lt(o);let l=t.justHeaders(e._commit)+`
|
|
gpgsig`+Ea(o)+`
|
|
`+a;return t.from(l)}};async function ji({fs:t,cache:e,gitdir:r,oid:i}){if(i==="4b825dc642cb6eb9a060e54bf8d69288fbee4904")return{tree:Ht.from([]),oid:i};let{type:n,object:a}=await K({fs:t,cache:e,gitdir:r,oid:i});if(n==="tag")return i=we.from(a).parse().object,ji({fs:t,cache:e,gitdir:r,oid:i});if(n==="commit")return i=kt.from(a).parse().tree,ji({fs:t,cache:e,gitdir:r,oid:i});if(n!=="tree")throw new Nt(i,n,"tree");return{tree:Ht.from(a),oid:i}}var Ma=class{constructor({fs:e,gitdir:r,ref:i,cache:n}){this.fs=e,this.cache=n,this.gitdir=r,this.mapPromise=(async()=>{let o=new Map,s;try{s=await D.resolve({fs:e,gitdir:r,ref:i})}catch(c){c instanceof ct&&(s="4b825dc642cb6eb9a060e54bf8d69288fbee4904")}let l=await ji({fs:e,cache:this.cache,gitdir:r,oid:s});return l.type="tree",l.mode="40000",o.set(".",l),o})();let a=this;this.ConstructEntry=class{constructor(s){this._fullpath=s,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(e){let r=e._fullpath,{fs:i,cache:n,gitdir:a}=this,o=await this.mapPromise,s=o.get(r);if(!s)throw new Error(`No obj for ${r}`);let l=s.oid;if(!l)throw new Error(`No oid for obj ${JSON.stringify(s)}`);if(s.type!=="tree")return null;let{type:c,object:f}=await K({fs:i,cache:n,gitdir:a,oid:l});if(c!==s.type)throw new Nt(l,c,s.type);let d=Ht.from(f);for(let u of d)o.set(P(r,u.path),u);return d.entries().map(u=>P(r,u.path))}async type(e){if(e._type===!1){let r=await this.mapPromise,{type:i}=r.get(e._fullpath);e._type=i}return e._type}async mode(e){if(e._mode===!1){let r=await this.mapPromise,{mode:i}=r.get(e._fullpath);e._mode=uu(parseInt(i,8))}return e._mode}async stat(e){}async content(e){if(e._content===!1){let r=await this.mapPromise,{fs:i,cache:n,gitdir:a}=this,s=r.get(e._fullpath).oid,{type:l,object:c}=await K({fs:i,cache:n,gitdir:a,oid:s});l!=="blob"?e._content=void 0:e._content=new Uint8Array(c)}return e._content}async oid(e){if(e._oid===!1){let i=(await this.mapPromise).get(e._fullpath);e._oid=i.oid}return e._oid}};function Fe({ref:t="HEAD"}={}){let e=Object.create(null);return Object.defineProperty(e,Vi,{value:function({fs:r,gitdir:i,cache:n}){return new Ma({fs:r,gitdir:i,ref:t,cache:n})}}),Object.freeze(e),e}var za=class{constructor({fs:e,dir:r,gitdir:i,cache:n,refresh:a=!0}){this.fs=e,this.cache=n,this.dir=r,this.gitdir=i,this.refresh=a,this.config=null;let o=this;this.ConstructEntry=class{constructor(l){this._fullpath=l,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return o.type(this)}async mode(){return o.mode(this)}async stat(){return o.stat(this)}async content(){return o.content(this)}async oid(){return o.oid(this)}}}async readdir(e){let r=e._fullpath,{fs:i,dir:n}=this,a=await i.readdir(P(n,r));return a===null?null:a.map(o=>P(r,o))}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){let{fs:r,dir:i}=this,n=await r.lstat(`${i}/${e._fullpath}`);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);let a=n.isDirectory()?"tree":"blob";a==="blob"&&!n.isFile()&&!n.isSymbolicLink()&&(a="special"),e._type=a,n=Me(n),e._mode=n.mode,n.size===-1&&e._actualSize&&(n.size=e._actualSize),e._stat=n}return e._stat}async content(e){if(e._content===!1){let{fs:r,dir:i,gitdir:n}=this;if(await e.type()==="tree")e._content=void 0;else{let a;if(await e.mode()>>12===10)a=await r.readlink(`${i}/${e._fullpath}`);else{let s=await(await this._getGitConfig(r,n)).get("core.autocrlf");a=await r.read(`${i}/${e._fullpath}`,{autocrlf:s})}e._actualSize=a.length,e._stat&&e._stat.size===-1&&(e._stat.size=e._actualSize),e._content=new Uint8Array(a)}}return e._content}async oid(e){if(e._oid===!1){let r=this,{fs:i,gitdir:n,cache:a}=this,o;await _t.acquire({fs:i,gitdir:n,cache:a},async function(s){let l=s.entriesMap.get(e._fullpath),c=await e.stat(),d=await(await r._getGitConfig(i,n)).get("core.filemode"),u=typeof process!="undefined"?process.platform!=="win32":!0;if(!l||Ra(c,l,d,u)){let h=await e.content();h===void 0?o=void 0:(o=await Qt(Le.wrap({type:"blob",object:h})),r.refresh&&l&&o===l.oid&&(!d||c.mode===l.mode)&&Ra(c,l,d,u)&&s.insert({filepath:e._fullpath,stats:c,oid:o}))}else o=l.oid}),e._oid=o}return e._oid}async _getGitConfig(e,r){return this.config?this.config:(this.config=await J.get({fs:e,gitdir:r}),this.config)}};function bu({refresh:t=!0}={}){let e=Object.create(null);return Object.defineProperty(e,Vi,{value:function({fs:r,dir:i,gitdir:n,cache:a}){return new za({fs:r,dir:i,gitdir:n,cache:a,refresh:t})}}),Object.freeze(e),e}function rm(t,e){let r=e-t;return Array.from({length:r},(i,n)=>t+n)}var _u=typeof Array.prototype.flat=="undefined"?t=>t.reduce((e,r)=>e.concat(r),[]):t=>t.flat(),La=class{constructor(){this.value=null}consider(e){e!=null&&(this.value===null?this.value=e:e<this.value&&(this.value=e))}reset(){this.value=null}};function*im(t){let e=new La,r,i=[],n=t.length;for(let a=0;a<n;a++)i[a]=t[a].next().value,i[a]!==void 0&&e.consider(i[a]);if(e.value!==null)for(;;){let a=[];r=e.value,e.reset();for(let o=0;o<n;o++)i[o]!==void 0&&i[o]===r?(a[o]=i[o],i[o]=t[o].next().value):a[o]=null,i[o]!==void 0&&e.consider(i[o]);if(yield a,e.value===null)return}}async function Mi({fs:t,cache:e,dir:r,gitdir:i,trees:n,map:a=async(l,c)=>c,reduce:o=async(l,c)=>{let f=_u(c);return l!==void 0&&f.unshift(l),f},iterate:s=(l,c)=>Promise.all([...c].map(l))}){let l=n.map(h=>h[Vi]({fs:t,dir:r,gitdir:i,cache:e})),c=new Array(l.length).fill("."),f=rm(0,l.length),d=async h=>{f.forEach(y=>{let b=h[y];h[y]=b&&new l[y].ConstructEntry(b)});let g=(await Promise.all(f.map(y=>{let b=h[y];return b?l[y].readdir(b):[]}))).map(y=>(y===null?[]:y)[Symbol.iterator]());return{entries:h,children:im(g)}},u=async h=>{let{entries:m,children:g}=await d(h),y=m.find(v=>v&&v._fullpath)._fullpath,b=await a(y,m);if(b!==null){let v=await s(u,g);return v=v.filter(k=>k!==void 0),o(b,v)}};return u(c)}async function Ha(t,e){let r=await t.readdir(e);r==null?await t.rm(e):r.length?await Promise.all(r.map(i=>{let n=P(e,i);return t.lstat(n).then(a=>{if(a)return a.isDirectory()?Ha(t,n):t.rm(n)})})).then(()=>t.rmdir(e)):await t.rmdir(e)}function nm(t){return am(t)&&Vl(t.then)&&Vl(t.catch)}function am(t){return t&&typeof t=="object"}function Vl(t){return typeof t=="function"}function Xl(t){return nm((r=>{try{return r.readFile().catch(i=>i)}catch(i){return i}})(t))}var Yl=["readFile","writeFile","mkdir","rmdir","unlink","stat","lstat","readdir","readlink","symlink"];function Kl(t,e){if(Xl(e))for(let r of Yl)t[`_${r}`]=e[r].bind(e);else for(let r of Yl)t[`_${r}`]=(0,gr.default)(e[r].bind(e));Xl(e)?(e.cp&&(t._cp=e.cp.bind(e)),e.rm?t._rm=e.rm.bind(e):e.rmdir.length>1?t._rm=e.rmdir.bind(e):t._rm=Ha.bind(null,t)):(e.cp&&(t._cp=(0,gr.default)(e.cp.bind(e))),e.rm?t._rm=(0,gr.default)(e.rm.bind(e)):e.rmdir.length>2?t._rm=(0,gr.default)(e.rmdir.bind(e)):t._rm=Ha.bind(null,t))}var nt=class{constructor(e){if(typeof e._original_unwrapped_fs!="undefined")return e;let r=Object.getOwnPropertyDescriptor(e,"promises");r&&r.enumerable?Kl(this,e.promises):Kl(this,e),this._original_unwrapped_fs=e}async exists(e,r={}){try{return await this._stat(e),!0}catch(i){if(i.code==="ENOENT"||i.code==="ENOTDIR"||(i.code||"").includes("ENS"))return!1;throw console.log('Unhandled error in "FileSystem.exists()" function',i),i}}async read(e,r={}){try{let i=await this._readFile(e,r);if(r.autocrlf==="true")try{i=new TextDecoder("utf8",{fatal:!0}).decode(i),i=i.replace(/\r\n/g,`
|
|
`),i=new TextEncoder().encode(i)}catch(n){}return typeof i!="string"&&(i=Buffer.from(i)),i}catch(i){return null}}async write(e,r,i={}){try{await this._writeFile(e,r,i)}catch(n){await this.mkdir(ze(e)),await this._writeFile(e,r,i)}}async mkdir(e,r=!1){try{await this._mkdir(e)}catch(i){if(i===null||i.code==="EEXIST")return;if(r)throw i;if(i.code==="ENOENT"){let n=ze(e);if(n==="."||n==="/"||n===e)throw i;await this.mkdir(n),await this.mkdir(e,!0)}}}async rm(e){try{await this._unlink(e)}catch(r){if(r.code!=="ENOENT")throw r}}async rmdir(e,r){try{r&&r.recursive?await this._rm(e,r):await this._rmdir(e)}catch(i){if(i.code!=="ENOENT")throw i}}async readdir(e){try{let r=await this._readdir(e);return r.sort(Wi),r}catch(r){return r.code==="ENOTDIR"?null:[]}}async readdirDeep(e){let r=await this._readdir(e);return(await Promise.all(r.map(async n=>{let a=e+"/"+n;return(await this._stat(a)).isDirectory()?this.readdirDeep(a):a}))).reduce((n,a)=>n.concat(a),[])}async lstat(e){try{return await this._lstat(e)}catch(r){if(r.code==="ENOENT"||(r.code||"").includes("ENS"))return null;throw r}}async readlink(e,r={encoding:"buffer"}){try{let i=await this._readlink(e,r);return Buffer.isBuffer(i)?i:Buffer.from(i)}catch(i){if(i.code==="ENOENT"||(i.code||"").includes("ENS"))return null;throw i}}async writelink(e,r){return this._symlink(r.toString("utf8"),e)}};function C(t,e){if(e===void 0)throw new St(t)}function om(t){return t.startsWith("/")||/^[a-zA-Z]:[\\/]/.test(t)}async function dt({fsp:t,dotgit:e}){C("fsp",t),C("dotgit",e);let r=await t._stat(e).catch(()=>({isFile:()=>!1,isDirectory:()=>!1}));return r.isDirectory()?e:r.isFile()?t._readFile(e,"utf8").then(i=>i.trimRight().substr(8)).then(i=>om(i)?i:P(ze(e),i)):e}async function Ql(t,e){return!t&&!e?!1:t&&!e||!t&&e?!0:!(await t.type()==="tree"&&await e.type()==="tree"||await t.type()===await e.type()&&await t.mode()===await e.mode()&&await t.oid()===await e.oid())}var zi=class{static async isIgnored({fs:e,dir:r,gitdir:i=P(r,".git"),filepath:n}){if(_i(n)===".git")return!0;if(n===".")return!1;let a="",o=P(i,"info","exclude");await e.exists(o)&&(a=await e.read(o,"utf8"));let s=[{gitignore:P(r,".gitignore"),filepath:n}],l=n.split("/").filter(Boolean);for(let f=1;f<l.length;f++){let d=l.slice(0,f).join("/"),u=l.slice(f).join("/");s.push({gitignore:P(r,d,".gitignore"),filepath:u})}let c=!1;for(let f of s){let d;try{d=await e.read(f.gitignore,"utf8")}catch(m){if(m.code==="NOENT")continue}let u=(0,su.default)().add(a);u.add(d);let h=ze(f.filepath);if(h!=="."&&u.ignores(h))return!0;c?c=!u.test(f.filepath).unignored:c=u.test(f.filepath).ignored}return c}};async function sm({fs:t,gitdir:e,object:r,format:i,oid:n}){if(i!=="deflated")throw new I("GitObjectStoreLoose expects objects to write to be in deflated format");let a=`objects/${n.slice(0,2)}/${n.slice(2)}`,o=`${e}/${a}`;await t.exists(o)||await t.write(o,r)}var Sa=null;async function vu(t){return Sa===null&&(Sa=fm()),Sa?cm(t):Zi.default.deflate(t)}async function cm(t){let e=new CompressionStream("deflate"),r=new Blob([t]).stream().pipeThrough(e);return new Uint8Array(await new Response(r).arrayBuffer())}function fm(){try{return new CompressionStream("deflate").writable.close(),new Blob([]).stream().cancel(),!0}catch(t){return!1}}async function Ar({fs:t,gitdir:e,type:r,object:i,format:n="content",oid:a=void 0,dryRun:o=!1}){return n!=="deflated"&&(n!=="wrapped"&&(i=Le.wrap({type:r,object:i})),a=await Qt(i),i=Buffer.from(await vu(i))),o||await sm({fs:t,gitdir:e,object:i,format:"deflated",oid:a}),a}function lm(t){let e;for(;~(e=t.indexOf(92));)t[e]=47;return t}async function Xi({fs:t,dir:e,gitdir:r=P(e,".git"),filepath:i,cache:n={},force:a=!1,parallel:o=!0}){try{C("fs",t),C("dir",e),C("gitdir",r),C("filepath",i);let s=new nt(t),l=await dt({fsp:s,dotgit:r});await _t.acquire({fs:s,gitdir:l,cache:n},async c=>{let d=await(await J.get({fs:s,gitdir:l})).get("core.autocrlf");return Ga({dir:e,gitdir:l,fs:s,filepath:i,index:c,force:a,parallel:o,autocrlf:d})})}catch(s){throw s.caller="git.add",s}}async function Ga({dir:t,gitdir:e,fs:r,filepath:i,index:n,force:a,parallel:o,autocrlf:s}){i=Array.isArray(i)?i:[i];let l=i.map(async u=>{if(!a&&await zi.isIgnored({fs:r,dir:t,gitdir:e,filepath:u}))return;let h=await r.lstat(P(t,u));if(!h)throw new ct(u);if(h.isDirectory()){let m=await r.readdir(P(t,u));if(o){let g=m.map(y=>Ga({dir:t,gitdir:e,fs:r,filepath:[P(u,y)],index:n,force:a,parallel:o,autocrlf:s}));await Promise.all(g)}else for(let g of m)await Ga({dir:t,gitdir:e,fs:r,filepath:[P(u,g)],index:n,force:a,parallel:o,autocrlf:s})}else{let m=h.isSymbolicLink()?await r.readlink(P(t,u)).then(lm):await r.read(P(t,u),{autocrlf:s});if(m===null)throw new ct(u);let g=await Ar({fs:r,gitdir:e,type:"blob",object:m});n.insert({filepath:u,stats:h,oid:g})}}),c=await Promise.allSettled(l),f=c.filter(u=>u.status==="rejected").map(u=>u.reason);if(f.length>1)throw new He(f);if(f.length===1)throw f[0];return c.filter(u=>u.status==="fulfilled"&&u.value).map(u=>u.value)}async function Li({fs:t,gitdir:e,path:r}){return(await J.get({fs:t,gitdir:e})).get(r)}function xu(t,...e){for(let r of e)if(r)for(let i of Object.keys(r)){let n=r[i];n!==void 0&&(t[i]=n)}return t}async function qa({fs:t,gitdir:e,author:r,commit:i}){let n=Math.floor(Date.now()/1e3),a={name:await Li({fs:t,gitdir:e,path:"user.name"}),email:await Li({fs:t,gitdir:e,path:"user.email"})||"",timestamp:n,timezoneOffset:new Date(n*1e3).getTimezoneOffset()},o=xu({},a,i?i.author:void 0,r);if(o.name!==void 0)return o}async function Za({fs:t,gitdir:e,author:r,committer:i,commit:n}){let a=Math.floor(Date.now()/1e3),o={name:await Li({fs:t,gitdir:e,path:"user.name"}),email:await Li({fs:t,gitdir:e,path:"user.email"})||"",timestamp:a,timezoneOffset:new Date(a*1e3).getTimezoneOffset()},s=xu({},o,n?n.committer:void 0,r,i);if(s.name!==void 0)return s}async function Eu({fs:t,cache:e,gitdir:r,oid:i}){let{type:n,object:a}=await K({fs:t,cache:e,gitdir:r,oid:i});if(n==="tag")return i=we.from(a).parse().object,Eu({fs:t,cache:e,gitdir:r,oid:i});if(n!=="commit")throw new Nt(i,n,"commit");return{commit:kt.from(a),oid:i}}async function um({fs:t,cache:e,gitdir:r,oid:i}){let{commit:n,oid:a}=await Eu({fs:t,cache:e,gitdir:r,oid:i});return{oid:a,commit:n.parse(),payload:n.withoutSignature()}}async function Su({fs:t,cache:e,onSign:r,gitdir:i,message:n,author:a,committer:o,signingKey:s,amend:l=!1,dryRun:c=!1,noUpdateBranch:f=!1,ref:d,parent:u,tree:h}){let m=!1,g=!1;d||(g=!(await t.read(`${i}/HEAD`,{encoding:"utf8"})).startsWith("ref:"),d=await D.resolve({fs:t,gitdir:i,ref:"HEAD",depth:2}));let y,b;try{y=await D.resolve({fs:t,gitdir:i,ref:d}),b=await um({fs:t,gitdir:i,oid:y,cache:{}})}catch(S){m=!0}if(l&&m)throw new Fi(d);let v=l?await qa({fs:t,gitdir:i,author:a,commit:b.commit}):await qa({fs:t,gitdir:i,author:a});if(!v)throw new pe("author");let k=l?await Za({fs:t,gitdir:i,author:v,committer:o,commit:b.commit}):await Za({fs:t,gitdir:i,author:v,committer:o});if(!k)throw new pe("committer");return _t.acquire({fs:t,gitdir:i,cache:e,allowUnmerged:!1},async function(S){let T=hu(S.entries).get(".");if(h||(h=await ku({fs:t,gitdir:i,inode:T,dryRun:c})),u?u=await Promise.all(u.map(w=>D.resolve({fs:t,gitdir:i,ref:w}))):l?u=b.commit.parent:u=y?[y]:[],!n)if(l)n=b.commit.message;else throw new St("message");let p=kt.from({tree:h,parent:u,author:v,committer:k,message:n});s&&(p=await kt.sign(p,r,s));let _=await Ar({fs:t,gitdir:i,type:"commit",object:p.toObject(),dryRun:c});return!f&&!c&&await D.writeRef({fs:t,gitdir:i,ref:g?"HEAD":d,value:_}),_})}async function ku({fs:t,gitdir:e,inode:r,dryRun:i}){let n=r.children;for(let l of n)l.type==="tree"&&(l.metadata.mode="040000",l.metadata.oid=await ku({fs:t,gitdir:e,inode:l,dryRun:i}));let a=n.map(l=>({mode:l.metadata.mode,path:l.basename,oid:l.metadata.oid,type:l.type})),o=Ht.from(a);return await Ar({fs:t,gitdir:e,type:"tree",object:o.toObject(),dryRun:i})}async function dm({fs:t,cache:e,gitdir:r,oid:i,filepath:n}){if(n.startsWith("/"))throw new vr("leading-slash");if(n.endsWith("/"))throw new vr("trailing-slash");let a=i,o=await ji({fs:t,cache:e,gitdir:r,oid:i}),s=o.tree;if(n==="")i=o.oid;else{let l=n.split("/");i=await Au({fs:t,cache:e,gitdir:r,tree:s,pathArray:l,oid:a,filepath:n})}return i}async function Au({fs:t,cache:e,gitdir:r,tree:i,pathArray:n,oid:a,filepath:o}){let s=n.shift();for(let l of i)if(l.path===s){if(n.length===0)return l.oid;{let{type:c,object:f}=await K({fs:t,cache:e,gitdir:r,oid:l.oid});if(c!=="tree")throw new Nt(a,c,"tree",o);return i=Ht.from(f),Au({fs:t,cache:e,gitdir:r,tree:i,pathArray:n,oid:a,filepath:o})}}throw new ct(`file or directory found at "${a}:${o}"`)}var hm=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function pm(t,e){if(typeof t!="string")throw new TypeError("Reference name must be a string");return!hm.test(t)&&(!!e||t.includes("/"))}async function Tu({fs:t,gitdir:e,remote:r,url:i,force:n}){if(!pm(r,!0))throw new Pi(r,cu.default.clean(r));let a=await J.get({fs:t,gitdir:e});if(!n&&(await a.getSubsections("remote")).includes(r)&&i!==await a.get(`remote.${r}.url`))throw new Ai("remote",r);await a.set(`remote.${r}.url`,i),await a.set(`remote.${r}.fetch`,`+refs/heads/*:refs/remotes/${r}/*`),await J.save({fs:t,gitdir:e,config:a})}async function $u({fs:t,dir:e,gitdir:r=P(e,".git"),remote:i,url:n,force:a=!1}){try{C("fs",t),C("gitdir",r),C("remote",i),C("url",n);let o=new nt(t),s=await dt({fsp:o,dotgit:r});return await Tu({fs:o,gitdir:s,remote:i,url:n,force:a})}catch(o){throw o.caller="git.addRemote",o}}var Ou=(t,e)=>t==="."||e==null||e.length===0||e==="."?!0:e.length>=t.length?e.startsWith(t):t.startsWith(e);async function wm({fs:t,cache:e,onProgress:r,onPostCheckout:i,dir:n,gitdir:a,remote:o,ref:s,filepaths:l,noCheckout:c,noUpdateHead:f,dryRun:d,force:u,track:h=!0,nonBlocking:m=!1,batchSize:g=100}){let y;if(i)try{y=await D.resolve({fs:t,gitdir:a,ref:"HEAD"})}catch(v){y="0000000000000000000000000000000000000000"}let b;try{b=await D.resolve({fs:t,gitdir:a,ref:s})}catch(v){if(s==="HEAD")throw v;let k=`${o}/${s}`;if(b=await D.resolve({fs:t,gitdir:a,ref:k}),h){let S=await J.get({fs:t,gitdir:a});await S.set(`branch.${s}.remote`,o),await S.set(`branch.${s}.merge`,`refs/heads/${s}`),await J.save({fs:t,gitdir:a,config:S})}await D.writeRef({fs:t,gitdir:a,ref:`refs/heads/${s}`,value:b})}if(!c){let v;try{v=await mm({fs:t,cache:e,onProgress:r,dir:n,gitdir:a,ref:s,force:u,filepaths:l})}catch(p){throw p instanceof ct&&p.data.what===b?new $i(s,b):p}let k=v.filter(([p])=>p==="conflict").map(([p,_])=>_);if(k.length>0)throw new Ti(k);let S=v.filter(([p])=>p==="error").map(([p,_])=>_);if(S.length>0)throw new I(S.join(", "));if(d){i&&await i({previousHead:y,newHead:b,type:l!=null&&l.length>0?"file":"branch"});return}let x=0,T=v.length;if(await _t.acquire({fs:t,gitdir:a,cache:e},async function(p){await Promise.all(v.filter(([_])=>_==="delete"||_==="delete-index").map(async function([_,w]){let A=`${n}/${w}`;_==="delete"&&await t.rm(A),p.delete({filepath:w}),r&&await r({phase:"Updating workdir",loaded:++x,total:T})}))}),await _t.acquire({fs:t,gitdir:a,cache:e},async function(p){for(let[_,w]of v)if(_==="rmdir"||_==="rmdir-index"){let A=`${n}/${w}`;try{_==="rmdir"&&await t.rmdir(A),p.delete({filepath:w}),r&&await r({phase:"Updating workdir",loaded:++x,total:T})}catch(E){if(E.code==="ENOTEMPTY")console.log(`Did not delete ${w} because directory is not empty`);else throw E}}}),await Promise.all(v.filter(([p])=>p==="mkdir"||p==="mkdir-index").map(async function([p,_]){let w=`${n}/${_}`;await t.mkdir(w),r&&await r({phase:"Updating workdir",loaded:++x,total:T})})),m){let p=v.filter(([w])=>w==="create"||w==="create-index"||w==="update"||w==="mkdir-index"),_=await Jl("Update Working Dir",p.map(([w,A,E,$,R])=>()=>ym({fs:t,cache:e,gitdir:a,dir:n},[w,A,E,$,R])),r,g);await _t.acquire({fs:t,gitdir:a,cache:e,allowUnmerged:!0},async function(w){await Jl("Update Index",_.map(([A,E,$])=>()=>gm({index:w,fullpath:A,oid:E,stats:$})),r,g)})}else await _t.acquire({fs:t,gitdir:a,cache:e,allowUnmerged:!0},async function(p){var A,E;let _=await Promise.allSettled(v.filter(([$])=>$==="create"||$==="create-index"||$==="update"||$==="mkdir-index").map(async function([$,R,B,H,ht]){let W=`${n}/${R}`;if($!=="create-index"&&$!=="mkdir-index"){let{object:Jt}=await K({fs:t,cache:e,gitdir:a,oid:B});if(ht&&await t.rm(W),H===33188)await t.write(W,Jt);else if(H===33261)await t.write(W,Jt,{mode:511});else if(H===40960)await t.writelink(W,Jt);else throw new I(`Invalid mode 0o${H.toString(8)} detected in blob ${B}`)}let tt=await t.lstat(W);H===33261&&(tt.mode=493),$==="mkdir-index"&&(tt.mode=57344),p.insert({filepath:R,stats:tt,oid:B}),r&&await r({phase:"Updating workdir",loaded:++x,total:T})})),w=[];for(let $ of _)$.status==="rejected"&&(w.push($.reason),console.error("[isomorphic-git checkout] task rejected:",(E=(A=$.reason)==null?void 0:A.stack)!=null?E:$.reason));if(w.length>0)throw new He(w)});i&&await i({previousHead:y,newHead:b,type:l!=null&&l.length>0?"file":"branch"})}if(!f){let v=await D.expand({fs:t,gitdir:a,ref:s});v.startsWith("refs/heads")?await D.writeSymbolicRef({fs:t,gitdir:a,ref:"HEAD",value:v}):await D.writeRef({fs:t,gitdir:a,ref:"HEAD",value:b})}}async function mm({fs:t,cache:e,onProgress:r,dir:i,gitdir:n,ref:a,force:o,filepaths:s}){let l=0;return Mi({fs:t,cache:e,dir:i,gitdir:n,trees:[Fe({ref:a}),bu(),pu()],map:async function(c,[f,d,u]){if(c===".")return;if(s&&!s.some(m=>Ou(c,m)))return null;switch(r&&await r({phase:"Analyzing workdir",loaded:++l}),[!!u,!!f,!!d].map(Number).join("")){case"000":return;case"001":return o&&s&&s.includes(c)?["delete",c]:void 0;case"010":switch(await f.type()){case"tree":return["mkdir",c];case"blob":return["create",c,await f.oid(),await f.mode()];case"commit":return["mkdir-index",c,await f.oid(),await f.mode()];default:return["error",`new entry Unhandled type ${await f.type()}`]}case"011":switch(`${await f.type()}-${await d.type()}`){case"tree-tree":return;case"tree-blob":case"blob-tree":return["conflict",c];case"blob-blob":return await f.oid()!==await d.oid()?o?["update",c,await f.oid(),await f.mode(),await f.mode()!==await d.mode()]:["conflict",c]:await f.mode()!==await d.mode()?o?["update",c,await f.oid(),await f.mode(),!0]:["conflict",c]:["create-index",c,await f.oid(),await f.mode()];case"commit-tree":return;case"commit-blob":return["conflict",c];default:return["error",`new entry Unhandled type ${f.type}`]}case"100":return["delete-index",c];case"101":switch(await u.type()){case"tree":return["rmdir-index",c];case"blob":return await u.oid()!==await d.oid()?o?["delete",c]:["conflict",c]:["delete",c];case"commit":return["rmdir-index",c];default:return["error",`delete entry Unhandled type ${await u.type()}`]}case"110":case"111":switch(`${await u.type()}-${await f.type()}`){case"tree-tree":return;case"blob-blob":{if(await u.oid()===await f.oid()&&await u.mode()===await f.mode()&&!o)return;if(d){if(await d.oid()!==await u.oid()&&await d.oid()!==await f.oid())return o?["update",c,await f.oid(),await f.mode(),await f.mode()!==await d.mode()]:["conflict",c]}else if(o)return["update",c,await f.oid(),await f.mode(),await f.mode()!==await u.mode()];return await f.mode()!==await u.mode()?["update",c,await f.oid(),await f.mode(),!0]:await f.oid()!==await u.oid()?["update",c,await f.oid(),await f.mode(),!1]:void 0}case"tree-blob":return["update-dir-to-blob",c,await f.oid()];case"blob-tree":return["update-blob-to-tree",c];case"commit-commit":return["mkdir-index",c,await f.oid(),await f.mode()];default:return["error",`update entry Unhandled type ${await u.type()}-${await f.type()}`]}}},reduce:async function(c,f){return f=_u(f),c?c&&c[0]==="rmdir"?(f.push(c),f):(f.unshift(c),f):f}})}async function gm({index:t,fullpath:e,stats:r,oid:i}){try{t.insert({filepath:e,stats:r,oid:i})}catch(n){console.warn(`Error inserting ${e} into index:`,n)}}async function ym({fs:t,cache:e,gitdir:r,dir:i},[n,a,o,s,l]){let c=`${i}/${a}`;if(n!=="create-index"&&n!=="mkdir-index"){let{object:d}=await K({fs:t,cache:e,gitdir:r,oid:o});if(l&&await t.rm(c),s===33188)await t.write(c,d);else if(s===33261)await t.write(c,d,{mode:511});else if(s===40960)await t.writelink(c,d);else throw new I(`Invalid mode 0o${s.toString(8)} detected in blob ${o}`)}let f=await t.lstat(c);return s===33261&&(f.mode=493),n==="mkdir-index"&&(f.mode=57344),[a,o,f]}async function Jl(t,e,r,i){let n=[],a=[];for(let o=0;o<e.length;o+=i){let s=e.slice(o,o+i).map(c=>c());(await Promise.allSettled(s)).forEach(c=>{var f,d;c.status==="fulfilled"?n.push(c.value):(a.push(c.reason),console.error(`[isomorphic-git ${t}] task rejected:`,(d=(f=c.reason)==null?void 0:f.stack)!=null?d:c.reason))}),r&&await r({phase:"Updating workdir",loaded:o+s.length,total:e.length})}if(a.length>0)throw new He(a);return n}var ka=/^.*(\r?\n|$)/gm;function bm({branches:t,contents:e}){let r=t[1],i=t[2],n=e[0],a=e[1],o=e[2],s=a.match(ka),l=n.match(ka),c=o.match(ka),f=(0,fu.default)(s,l,c),d=7,u="",h=!0;for(let m of f)m.ok&&(u+=m.ok.join("")),m.conflict&&(h=!1,u+=`${"<".repeat(d)} ${r}
|
|
`,u+=m.conflict.a.join(""),u+=`${"=".repeat(d)}
|
|
`,u+=m.conflict.b.join(""),u+=`${">".repeat(d)} ${i}
|
|
`);return{cleanMerge:h,mergedText:u}}async function _m({fs:t,cache:e,dir:r,gitdir:i=P(r,".git"),index:n,ourOid:a,baseOid:o,theirOid:s,ourName:l="ours",baseName:c="base",theirName:f="theirs",dryRun:d=!1,abortOnConflict:u=!0,mergeDriver:h}){let m=Fe({ref:a}),g=Fe({ref:o}),y=Fe({ref:s}),b=[],v=[],k=[],S=[],x=await Mi({fs:t,cache:e,dir:r,gitdir:i,trees:[m,g,y],map:async function(T,[p,_,w]){let A=_i(T),E=await Ql(p,_),$=await Ql(w,_);switch(`${E}-${$}`){case"false-false":return{mode:await _.mode(),path:A,oid:await _.oid(),type:await _.type()};case"false-true":return!w&&await p.type()==="tree"?{mode:await p.mode(),path:A,oid:await p.oid(),type:await p.type()}:w?{mode:await w.mode(),path:A,oid:await w.oid(),type:await w.type()}:void 0;case"true-false":return!p&&await w.type()==="tree"?{mode:await w.mode(),path:A,oid:await w.oid(),type:await w.type()}:p?{mode:await p.mode(),path:A,oid:await p.oid(),type:await p.type()}:void 0;case"true-true":{if(p&&w&&await p.type()==="tree"&&await w.type()==="tree")return{mode:await p.mode(),path:A,oid:await p.oid(),type:"tree"};if(p&&w&&await p.type()==="blob"&&await w.type()==="blob")return vm({fs:t,gitdir:i,path:A,ours:p,base:_,theirs:w,ourName:l,baseName:c,theirName:f,mergeDriver:h}).then(async R=>{if(R.cleanMerge)u||n.insert({filepath:T,oid:R.mergeResult.oid,stage:0});else if(b.push(T),v.push(T),!u){let B="";_&&await _.type()==="blob"&&(B=await _.oid());let H=await p.oid(),ht=await w.oid();n.delete({filepath:T}),B&&n.insert({filepath:T,oid:B,stage:1}),n.insert({filepath:T,oid:H,stage:2}),n.insert({filepath:T,oid:ht,stage:3})}return R.mergeResult});if(_&&!p&&w&&await _.type()==="blob"&&await w.type()==="blob"){if(b.push(T),k.push(T),!u){let R=await _.oid(),B=await w.oid();n.delete({filepath:T}),n.insert({filepath:T,oid:R,stage:1}),n.insert({filepath:T,oid:B,stage:3})}return{mode:await w.mode(),oid:await w.oid(),type:"blob",path:A}}if(_&&p&&!w&&await _.type()==="blob"&&await p.type()==="blob"){if(b.push(T),S.push(T),!u){let R=await _.oid(),B=await p.oid();n.delete({filepath:T}),n.insert({filepath:T,oid:R,stage:1}),n.insert({filepath:T,oid:B,stage:2})}return{mode:await p.mode(),oid:await p.oid(),type:"blob",path:A}}if(_&&!p&&!w&&(await _.type()==="blob"||await _.type()==="tree"))return;throw new xr}}},reduce:b.length!==0&&(!r||u)?void 0:async(T,p)=>{let _=p.filter(Boolean);if(T&&!(T&&T.type==="tree"&&_.length===0&&T.path!==".")){if(_.length>0||T.path==="."&&_.length===0){let A=new Ht(_).toObject(),E=await Ar({fs:t,gitdir:i,type:"tree",object:A,dryRun:d});T.oid=E}return T}}});return b.length!==0?(r&&!u&&await Mi({fs:t,cache:e,dir:r,gitdir:i,trees:[Fe({ref:x.oid})],map:async function(T,[p]){let _=`${r}/${T}`;if(await p.type()==="blob"){let w=await p.mode(),A=new TextDecoder().decode(await p.content());await t.write(_,A,{mode:w})}return!0}}),new Er(b,v,k,S)):x.oid}async function vm({fs:t,gitdir:e,path:r,ours:i,base:n,theirs:a,ourName:o,theirName:s,baseName:l,dryRun:c,mergeDriver:f=bm}){let d="blob",u="100755",h="",m="";n&&await n.type()==="blob"&&(u=await n.mode(),h=await n.oid(),m=Buffer.from(await n.content()).toString("utf8"));let g=u===await i.mode()?await a.mode():await i.mode();if(await i.oid()===await a.oid())return{cleanMerge:!0,mergeResult:{mode:g,path:r,oid:await i.oid(),type:d}};if(await i.oid()===h)return{cleanMerge:!0,mergeResult:{mode:g,path:r,oid:await a.oid(),type:d}};if(await a.oid()===h)return{cleanMerge:!0,mergeResult:{mode:g,path:r,oid:await i.oid(),type:d}};let y=Buffer.from(await i.content()).toString("utf8"),b=Buffer.from(await a.content()).toString("utf8"),{mergedText:v,cleanMerge:k}=await f({branches:[l,o,s],contents:[m,y,b],path:r}),S=await Ar({fs:t,gitdir:e,type:"blob",object:Buffer.from(v,"utf8"),dryRun:c});return{cleanMerge:k,mergeResult:{mode:g,path:r,oid:S,type:d}}}var xm=/^refs\/(heads\/|tags\/|remotes\/)?(.*)/;function Ue(t){let e=xm.exec(t);return e?e[1]==="remotes/"&&t.endsWith("/HEAD")?e[2].slice(0,-5):e[2]:t}async function Ya({fs:t,gitdir:e,fullname:r=!1,test:i=!1}){let n=await D.resolve({fs:t,gitdir:e,ref:"HEAD",depth:2});if(i)try{await D.resolve({fs:t,gitdir:e,ref:n})}catch(a){return}if(n.startsWith("refs/"))return r?n:Ue(n)}function Em(t){return t=t.replace(/^git@([^:]+):/,"https://$1/"),t=t.replace(/^ssh:\/\//,"https://"),t}function Ru({username:t="",password:e=""}){return`Basic ${Buffer.from(`${t}:${e}`).toString("base64")}`}async function Tr(t,e){let r=mu(t);for(;;){let{value:i,done:n}=await r.next();if(i&&await e(i),n)break}r.return&&r.return()}async function Wa(t){let e=0,r=[];await Tr(t,a=>{r.push(a),e+=a.byteLength});let i=new Uint8Array(e),n=0;for(let a of r)i.set(a,n),n+=a.byteLength;return i}function tu(t){let e=t.match(/^https?:\/\/([^/]+)@/);if(e==null)return{url:t,auth:{}};e=e[1];let[r,i]=e.split(":");return t=t.replace(`${e}@`,""),{url:t,auth:{username:r,password:i}}}function Va(t,e){let r=e.toString(16);return"0".repeat(t-r.length)+r}var it=class{static flush(){return Buffer.from("0000","utf8")}static delim(){return Buffer.from("0001","utf8")}static encode(e){typeof e=="string"&&(e=Buffer.from(e));let r=e.length+4,i=Va(4,r);return Buffer.concat([Buffer.from(i,"utf8"),e])}static streamReader(e){let r=new Si(e);return async function(){try{let n=await r.read(4);if(n==null)return!0;if(n=parseInt(n.toString("utf8"),16),n===0||n===1)return null;let a=await r.read(n-4);return a==null?!0:a}catch(n){return e.error=n,!0}}}};async function eu(t){let e={},r;for(;r=await t(),r!==!0;){if(r===null)continue;r=r.toString("utf8").replace(/\n$/,"");let i=r.indexOf("=");if(i>-1){let n=r.slice(0,i),a=r.slice(i+1);e[n]=a}else e[r]=!0}return{protocolVersion:2,capabilities2:e}}async function ru(t,{service:e}){let r=new Set,i=new Map,n=new Map,a=it.streamReader(t),o=await a();for(;o===null;)o=await a();if(o===!0)throw new Oi;if(o.includes("version 2"))return eu(a);if(o.toString("utf8").replace(/\n$/,"")!==`# service=${e}`)throw new Ge(`# service=${e}\\n`,o.toString("utf8"));let s=await a();for(;s===null;)s=await a();if(s===!0)return{capabilities:r,refs:i,symrefs:n};if(s=s.toString("utf8"),s.includes("version 2"))return eu(a);let[l,c]=Aa(s,"\0","\\x00");if(c.split(" ").map(f=>r.add(f)),l!=="0000000000000000000000000000000000000000 capabilities^{}"){let[f,d]=Aa(l," "," ");for(i.set(d,f);;){let u=await a();if(u===!0)break;if(u!==null){let[h,m]=Aa(u.toString("utf8")," "," ");i.set(m,h)}}}for(let f of r)if(f.startsWith("symref=")){let d=f.match(/symref=([^:]+):(.*)/);d.length===3&&n.set(d[1],d[2])}return{protocolVersion:1,capabilities:r,refs:i,symrefs:n}}function Aa(t,e,r){let i=t.trim().split(e);if(i.length!==2)throw new Ge(`Two strings separated by '${r}'`,t.toString("utf8"));return i}var iu=(t,e)=>t.endsWith("?")?`${t}${e}`:`${t}/${e.replace(/^https?:\/\//,"")}`,nu=(t,e)=>{(e.username||e.password)&&(t.Authorization=Ru(e)),e.headers&&Object.assign(t,e.headers)},Ta=async t=>{try{let e=Buffer.from(await Wa(t.body)),r=e.toString("utf8");return{preview:r.length<256?r:r.slice(0,256)+"...",response:r,data:e}}catch(e){return{}}},Hi=class{static async capabilities(){return["discover","connect"]}static async discover({http:e,onProgress:r,onAuth:i,onAuthSuccess:n,onAuthFailure:a,corsProxy:o,service:s,url:l,headers:c,protocolVersion:f}){let{url:d,auth:u}=tu(l),h=o?iu(o,d):d;(u.username||u.password)&&(c.Authorization=Ru(u)),f===2&&(c["Git-Protocol"]="version=2");let m,g,y=!1;do if(m=await e.request({onProgress:r,method:"GET",url:`${h}/info/refs?service=${s}`,headers:c}),g=!1,m.statusCode===401||m.statusCode===203){let b=y?a:i;if(b){if(u=await b(d,{...u,headers:{...c}}),u&&u.cancel)throw new kr;u&&(nu(c,u),y=!0,g=!0)}}else m.statusCode===200&&y&&n&&await n(d,u);while(g);if(m.statusCode!==200){let{response:b}=await Ta(m);throw new _r(m.statusCode,m.statusMessage,b)}if(m.headers["content-type"]===`application/x-${s}-advertisement`){let b=await ru(m.body,{service:s});return b.auth=u,b}else{let{preview:b,response:v,data:k}=await Ta(m);try{let S=await ru([k],{service:s});return S.auth=u,S}catch(S){throw new Bi(b,v)}}}static async connect({http:e,onProgress:r,corsProxy:i,service:n,url:a,auth:o,body:s,headers:l}){let c=tu(a);c&&(a=c.url),i&&(a=iu(i,a)),l["content-type"]=`application/x-${n}-request`,l.accept=`application/x-${n}-result`,nu(l,o);let f=await e.request({onProgress:r,method:"POST",url:`${a}/${n}`,body:s,headers:l});if(f.statusCode!==200){let{response:d}=Ta(f);throw new _r(f.statusCode,f.statusMessage,d)}return f}},Gi=class{static getRemoteHelperFor({url:e}){let r=new Map;r.set("http",Hi),r.set("https",Hi);let i=Sm({url:e});if(!i)throw new Ni(e);if(r.has(i.transport))return r.get(i.transport);throw new Di(e,i.transport,i.transport==="ssh"?Em(e):void 0)}};function Sm({url:t}){if(t.startsWith("git@"))return{transport:"ssh",address:t};let e=t.match(/(\w+)(:\/\/|::)(.*)/);if(e!==null){if(e[2]==="://")return{transport:e[1],address:e[0]};if(e[2]==="::")return{transport:e[1],address:e[3]}}}var ue=null,qe=class{static async read({fs:e,gitdir:r}){ue===null&&(ue=new yr.default);let i=P(r,"shallow"),n=new Set;return await ue.acquire(i,async function(){let a=await e.read(i,{encoding:"utf8"});if(a===null||a.trim()==="")return n;a.trim().split(`
|
|
`).map(o=>n.add(o))}),n}static async write({fs:e,gitdir:r,oids:i}){ue===null&&(ue=new yr.default);let n=P(r,"shallow");if(i.size>0){let a=[...i].join(`
|
|
`)+`
|
|
`;await ue.acquire(n,async function(){await e.write(n,a,{encoding:"utf8"})})}else await ue.acquire(n,async function(){await e.rm(n)})}};async function km({fs:t,gitdir:e,oid:r}){let i=`objects/${r.slice(0,2)}/${r.slice(2)}`;return t.exists(`${e}/${i}`)}async function Am({fs:t,cache:e,gitdir:r,oid:i,getExternalRefDelta:n}){let a=await t.readdir(P(r,"objects/pack"));a=a.filter(o=>o.endsWith(".idx"));for(let o of a){let s=`${r}/objects/pack/${o}`,l=await yu({fs:t,cache:e,filename:s,getExternalRefDelta:n});if(l.error)throw new I(l.error);if(l.offsets.has(i))return!0}return!1}async function au({fs:t,cache:e,gitdir:r,oid:i,format:n="content"}){let a=s=>K({fs:t,cache:e,gitdir:r,oid:s}),o=await km({fs:t,gitdir:r,oid:i});return o||(o=await Am({fs:t,cache:e,gitdir:r,oid:i,getExternalRefDelta:a})),o}function Tm(t){let n="5041434b"+"00000002"+"00000000";return t.slice(0,12).toString("hex")===n}function Iu(t,e){let r=t.map(i=>i.split("=",1)[0]);return e.filter(i=>{let n=i.split("=",1)[0];return r.includes(n)})}var Pu={name:"isomorphic-git",version:"1.38.1",agent:"git/isomorphic-git@1.38.1"},je=class{constructor(){this._queue=[]}write(e){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){let r=this._waiting;this._waiting=null,r({value:e})}else this._queue.push(e)}end(){if(this._ended=!0,this._waiting){let e=this._waiting;this._waiting=null,e({done:!0})}}destroy(e){this.error=e,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(e=>{this._waiting=e})}};function $m(t){let e=t.indexOf("\r"),r=t.indexOf(`
|
|
`);return e===-1&&r===-1?-1:e===-1?r+1:r===-1?e+1:r===e+1?r+1:Math.min(e,r)+1}function Cu(t){let e=new je,r="";return(async()=>(await Tr(t,i=>{for(i=i.toString("utf8"),r+=i;;){let n=$m(r);if(n===-1)break;e.write(r.slice(0,n)),r=r.slice(n)}}),r.length>0&&e.write(r),e.end()))(),e}var qi=class{static demux(e){let r=it.streamReader(e),i=new je,n=new je,a=new je,o=async function(){let s=await r();if(s===null)return o();if(s===!0){i.end(),a.end(),e.error?n.destroy(e.error):n.end();return}switch(s[0]){case 1:{n.write(s.slice(1));break}case 2:{a.write(s.slice(1));break}case 3:{let l=s.slice(1);a.write(l),i.end(),a.end(),n.destroy(new Error(l.toString("utf8")));return}default:i.write(s)}o()};return o(),{packetlines:i,packfile:n,progress:a}}};async function Om(t){let{packetlines:e,packfile:r,progress:i}=qi.demux(t),n=[],a=[],o=[],s=!1,l=!1;return new Promise((c,f)=>{Tr(e,d=>{let u=d.toString("utf8").trim();if(u.startsWith("shallow")){let h=u.slice(-41).trim();h.length!==40&&f(new he(h)),n.push(h)}else if(u.startsWith("unshallow")){let h=u.slice(-41).trim();h.length!==40&&f(new he(h)),a.push(h)}else if(u.startsWith("ACK")){let[,h,m]=u.split(" ");o.push({oid:h,status:m}),m||(l=!0)}else u.startsWith("NAK")?(s=!0,l=!0):(l=!0,s=!0);l&&(t.error?f(t.error):c({shallows:n,unshallows:a,acks:o,nak:s,packfile:r,progress:i}))}).finally(()=>{l||(t.error?f(t.error):c({shallows:n,unshallows:a,acks:o,nak:s,packfile:r,progress:i}))})})}function Rm({capabilities:t=[],wants:e=[],haves:r=[],shallows:i=[],depth:n=null,since:a=null,exclude:o=[]}){let s=[];e=[...new Set(e)];let l=` ${t.join(" ")}`;for(let c of e)s.push(it.encode(`want ${c}${l}
|
|
`)),l="";for(let c of i)s.push(it.encode(`shallow ${c}
|
|
`));n!==null&&s.push(it.encode(`deepen ${n}
|
|
`)),a!==null&&s.push(it.encode(`deepen-since ${Math.floor(a.valueOf()/1e3)}
|
|
`));for(let c of o)s.push(it.encode(`deepen-not ${c}
|
|
`));s.push(it.flush());for(let c of r)s.push(it.encode(`have ${c}
|
|
`));return s.push(it.encode(`done
|
|
`)),s}async function Bu({fs:t,cache:e,http:r,onProgress:i,onMessage:n,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:l,ref:c,remoteRef:f,remote:d,url:u,corsProxy:h,depth:m=null,since:g=null,exclude:y=[],relative:b=!1,tags:v=!1,singleBranch:k=!1,headers:S={},prune:x=!1,pruneTags:T=!1}){let p=c||await Ya({fs:t,gitdir:l,test:!0}),_=await J.get({fs:t,gitdir:l}),w=d||p&&await _.get(`branch.${p}.remote`)||"origin",A=u||await _.get(`remote.${w}.url`);if(typeof A=="undefined")throw new St("remote OR url");let E=f||p&&await _.get(`branch.${p}.merge`)||c||"HEAD";h===void 0&&(h=await _.get("http.corsProxy"));let $=Gi.getRemoteHelperFor({url:A}),R=await $.discover({http:r,onAuth:a,onAuthSuccess:o,onAuthFailure:s,corsProxy:h,service:"git-upload-pack",url:A,headers:S,protocolVersion:1}),B=R.auth,H=R.refs;if(H.size===0)return{defaultBranch:null,fetchHead:null,fetchHeadDescription:null};if(m!==null&&!R.capabilities.has("shallow"))throw new de("shallow","depth");if(g!==null&&!R.capabilities.has("deepen-since"))throw new de("deepen-since","since");if(y.length>0&&!R.capabilities.has("deepen-not"))throw new de("deepen-not","exclude");if(b===!0&&!R.capabilities.has("deepen-relative"))throw new de("deepen-relative","relative");let{oid:ht,fullref:W}=D.resolveAgainstMap({ref:E,map:H});for(let M of H.keys())M===W||M==="HEAD"||M.startsWith("refs/heads/")||v&&M.startsWith("refs/tags/")||H.delete(M);let tt=Iu([...R.capabilities],["multi_ack_detailed","no-done","side-band-64k","ofs-delta",`agent=${Pu.agent}`]);b&&tt.push("deepen-relative");let Jt=k?[ht]:H.values(),tn=k?[p]:await D.listRefs({fs:t,gitdir:l,filepath:"refs"}),ft=[];for(let M of tn)try{M=await D.expand({fs:t,gitdir:l,ref:M});let X=await D.resolve({fs:t,gitdir:l,ref:M});await au({fs:t,cache:e,gitdir:l,oid:X})&&ft.push(X)}catch(X){}ft=[...new Set(ft)];let L=await qe.read({fs:t,gitdir:l}),At=R.capabilities.has("shallow")?[...L]:[],Q=Rm({capabilities:tt,wants:Jt,haves:ft,shallows:At,depth:m,since:g,exclude:y}),Ze=Buffer.from(await Wa(Q)),te=await $.connect({http:r,onProgress:i,corsProxy:h,service:"git-upload-pack",url:A,auth:B,body:[Ze],headers:S}),q=await Om(te.body);te.headers&&(q.headers=te.headers);for(let M of q.shallows)if(!L.has(M))try{let{object:X}=await K({fs:t,cache:e,gitdir:l,oid:M}),pt=new kt(X),Tt=await Promise.all(pt.headers().parent.map(Ve=>au({fs:t,cache:e,gitdir:l,oid:Ve})));Tt.length===0||Tt.every(Ve=>Ve)||L.add(M)}catch(X){L.add(M)}for(let M of q.unshallows)L.delete(M);if(await qe.write({fs:t,gitdir:l,oids:L}),k){let M=new Map([[W,ht]]),X=new Map,pt=10,Tt=W;for(;pt--;){let rn=R.symrefs.get(Tt);if(rn===void 0)break;X.set(Tt,rn),Tt=rn}let en=H.get(Tt);en&&M.set(Tt,en);let{pruned:Ve}=await D.updateRemoteRefs({fs:t,gitdir:l,remote:w,refs:M,symrefs:X,tags:v,prune:x});x&&(q.pruned=Ve)}else{let{pruned:M}=await D.updateRemoteRefs({fs:t,gitdir:l,remote:w,refs:H,symrefs:R.symrefs,tags:v,prune:x,pruneTags:T});x&&(q.pruned=M)}if(q.HEAD=R.symrefs.get("HEAD"),q.HEAD===void 0){let{oid:M}=D.resolveAgainstMap({ref:"HEAD",map:H});for(let[X,pt]of H.entries())if(X!=="HEAD"&&pt===M){q.HEAD=X;break}}let Zu=W.startsWith("refs/tags")?"tag":"branch";if(q.FETCH_HEAD={oid:ht,description:`${Zu} '${Ue(W)}' of ${A}`},i||n){let M=Cu(q.progress);Tr(M,async X=>{if(n&&await n(X),i){let pt=X.match(/([^:]*).*\((\d+?)\/(\d+?)\)/);pt&&await i({phase:pt[1].trim(),loaded:parseInt(pt[2],10),total:parseInt(pt[3],10)})}})}let Rr=Buffer.from(await Wa(q.packfile));if(te.body.error)throw te.body.error;let Qa=Rr.slice(-20).toString("hex"),We={defaultBranch:q.HEAD,fetchHead:q.FETCH_HEAD.oid,fetchHeadDescription:q.FETCH_HEAD.description};if(q.headers&&(We.headers=q.headers),x&&(We.pruned=q.pruned),Qa!==""&&!Tm(Rr)){We.packfile=`objects/pack/pack-${Qa}.pack`;let M=P(l,We.packfile);await t.write(M,Rr);let X=Tt=>K({fs:t,cache:e,gitdir:l,oid:Tt}),pt=await ki.fromPack({pack:Rr,getExternalRefDelta:X,onProgress:i});await t.write(M.replace(/\.pack$/,".idx"),await pt.toBuffer())}return We}async function Du({fs:t,bare:e=!1,dir:r,gitdir:i=e?r:P(r,".git"),defaultBranch:n="master"}){if(await t.exists(i+"/config"))return;let a=["hooks","info","objects/info","objects/pack","refs/heads","refs/tags"];a=a.map(o=>i+"/"+o);for(let o of a)await t.mkdir(o);await t.write(i+"/config",`[core]
|
|
repositoryformatversion = 0
|
|
filemode = false
|
|
bare = ${e}
|
|
`+(e?"":` logallrefupdates = true
|
|
`)+` symlinks = false
|
|
ignorecase = true
|
|
`),await t.write(i+"/HEAD",`ref: refs/heads/${n}
|
|
`)}async function Im({fs:t,cache:e,http:r,onProgress:i,onMessage:n,onAuth:a,onAuthSuccess:o,onAuthFailure:s,onPostCheckout:l,dir:c,gitdir:f,url:d,corsProxy:u,ref:h,remote:m,depth:g,since:y,exclude:b,relative:v,singleBranch:k,noCheckout:S,noTags:x,headers:T,nonBlocking:p,batchSize:_=100}){try{if(await Du({fs:t,gitdir:f}),await Tu({fs:t,gitdir:f,remote:m,url:d,force:!1}),u){let E=await J.get({fs:t,gitdir:f});await E.set("http.corsProxy",u),await J.save({fs:t,gitdir:f,config:E})}let{defaultBranch:w,fetchHead:A}=await Bu({fs:t,cache:e,http:r,onProgress:i,onMessage:n,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:f,ref:h,remote:m,corsProxy:u,depth:g,since:y,exclude:b,relative:v,singleBranch:k,headers:T,tags:!x});if(A===null)return;h=h||w,h=h.replace("refs/heads/",""),await wm({fs:t,cache:e,onProgress:i,onPostCheckout:l,dir:c,gitdir:f,ref:h,remote:m,noCheckout:S,nonBlocking:p,batchSize:_})}catch(w){throw await t.rmdir(f,{recursive:!0,maxRetries:10}).catch(()=>{}),w}}async function Nu({fs:t,http:e,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:l,gitdir:c=P(l,".git"),url:f,corsProxy:d=void 0,ref:u=void 0,remote:h="origin",depth:m=void 0,since:g=void 0,exclude:y=[],relative:b=!1,singleBranch:v=!1,noCheckout:k=!1,noTags:S=!1,headers:x={},cache:T={},nonBlocking:p=!1,batchSize:_=100}){try{C("fs",t),C("http",e),C("gitdir",c),k||C("dir",l),C("url",f);let w=new nt(t),A=await dt({fsp:w,dotgit:c});return await Im({fs:w,cache:T,http:e,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:l,gitdir:A,url:f,corsProxy:d,ref:u,remote:h,depth:m,since:g,exclude:y,relative:b,singleBranch:v,noCheckout:k,noTags:S,headers:x,nonBlocking:p,batchSize:_})}catch(w){throw w.caller="git.clone",w}}async function $r({fs:t,onSign:e,dir:r,gitdir:i=P(r,".git"),message:n,author:a,committer:o,signingKey:s,amend:l=!1,dryRun:c=!1,noUpdateBranch:f=!1,ref:d,parent:u,tree:h,cache:m={}}){try{C("fs",t),l||C("message",n),s&&C("onSign",e);let g=new nt(t),y=await dt({fsp:g,dotgit:i});return await Su({fs:g,cache:m,onSign:e,gitdir:y,message:n,author:a,committer:o,signingKey:s,amend:l,dryRun:c,noUpdateBranch:f,ref:d,parent:u,tree:h})}catch(g){throw g.caller="git.commit",g}}async function Pm({fs:t,gitdir:e,remote:r}){let i=await J.get({fs:t,gitdir:e});await i.deleteSection("remote",r),await J.save({fs:t,gitdir:e,config:i})}async function Fu({fs:t,dir:e,gitdir:r=P(e,".git"),remote:i}){try{C("fs",t),C("remote",i);let n=new nt(t),a=await dt({fsp:n,dotgit:r});return await Pm({fs:n,gitdir:a,remote:i})}catch(n){throw n.caller="git.deleteRemote",n}}async function Uu({fs:t,cache:e,gitdir:r,oids:i}){let n={},a=i.length,o=i.map((s,l)=>({index:l,oid:s}));for(;o.length;){let s=new Set;for(let{oid:c,index:f}of o)n[c]||(n[c]=new Set),n[c].add(f),n[c].size===a&&s.add(c);if(s.size>0)return[...s];let l=new Map;for(let{oid:c,index:f}of o)try{let{object:d}=await K({fs:t,cache:e,gitdir:r,oid:c}),u=kt.from(d),{parent:h}=u.parseHeaders();for(let m of h)(!n[m]||!n[m].has(f))&&l.set(m+":"+f,{oid:m,index:f})}catch(d){}o=Array.from(l.values())}return[]}async function Cm({fs:t,cache:e,dir:r,gitdir:i,ours:n,theirs:a,fastForward:o=!0,fastForwardOnly:s=!1,dryRun:l=!1,noUpdateBranch:c=!1,abortOnConflict:f=!0,message:d,author:u,committer:h,signingKey:m,onSign:g,mergeDriver:y,allowUnrelatedHistories:b=!1}){n===void 0&&(n=await Ya({fs:t,gitdir:i,fullname:!0})),n=await D.expand({fs:t,gitdir:i,ref:n}),a=await D.expand({fs:t,gitdir:i,ref:a});let v=await D.resolve({fs:t,gitdir:i,ref:n}),k=await D.resolve({fs:t,gitdir:i,ref:a}),S=await Uu({fs:t,cache:e,gitdir:i,oids:[v,k]});if(S.length!==1)if(S.length===0&&b)S.push("4b825dc642cb6eb9a060e54bf8d69288fbee4904");else throw new xr;let x=S[0];if(x===k)return{oid:v,alreadyMerged:!0};if(o&&x===v)return!l&&!c&&await D.writeRef({fs:t,gitdir:i,ref:n,value:k}),{oid:k,fastForward:!0};{if(s)throw new Ri;let T=await _t.acquire({fs:t,gitdir:i,cache:e,allowUnmerged:!1},async _=>_m({fs:t,cache:e,dir:r,gitdir:i,index:_,ourOid:v,theirOid:k,baseOid:x,ourName:Ue(n),baseName:"base",theirName:Ue(a),dryRun:l,abortOnConflict:f,mergeDriver:y}));if(T instanceof Er)throw T;return d||(d=`Merge branch '${Ue(a)}' into ${Ue(n)}`),{oid:await Su({fs:t,cache:e,gitdir:i,message:d,ref:n,tree:T,parent:[v,k],author:u,committer:h,signingKey:m,onSign:g,dryRun:l,noUpdateBranch:c}),tree:T,mergeCommit:!0}}}async function ju({fs:t,http:e,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:l=P(s,".git"),ref:c,remote:f,remoteRef:d,url:u,corsProxy:h,depth:m=null,since:g=null,exclude:y=[],relative:b=!1,tags:v=!1,singleBranch:k=!1,headers:S={},prune:x=!1,pruneTags:T=!1,cache:p={}}){try{C("fs",t),C("http",e),C("gitdir",l);let _=new nt(t),w=await dt({fsp:_,dotgit:l});return await Bu({fs:_,cache:p,http:e,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:o,gitdir:w,ref:c,remote:f,remoteRef:d,url:u,corsProxy:h,depth:m,since:g,exclude:y,relative:b,tags:v,singleBranch:k,headers:S,prune:x,pruneTags:T})}catch(_){throw _.caller="git.fetch",_}}async function Mu({fs:t,bare:e=!1,dir:r,gitdir:i=e?r:P(r,".git"),defaultBranch:n="master"}){try{C("fs",t),C("gitdir",i),e||C("dir",r);let a=new nt(t),o=await dt({fsp:a,dotgit:i});return await Du({fs:a,bare:e,dir:r,gitdir:o,defaultBranch:n})}catch(a){throw a.caller="git.init",a}}async function Bm({fs:t,cache:e,gitdir:r,oid:i,ancestor:n,depth:a}){let o=await qe.read({fs:t,gitdir:r});if(!i)throw new St("oid");if(!n)throw new St("ancestor");if(i===n)return!1;let s=[i],l=new Set,c=0;for(;s.length;){if(c++===a)throw new Ci(a);let f=s.shift(),{type:d,object:u}=await K({fs:t,cache:e,gitdir:r,oid:f});if(d!=="commit")throw new Nt(f,d,"commit");let h=kt.from(u).parse();for(let m of h.parent)if(m===n)return!0;if(!o.has(f))for(let m of h.parent)l.has(m)||(s.push(m),l.add(m))}return!1}async function Ka({fs:t,onSign:e,dir:r,gitdir:i=P(r,".git"),ours:n,theirs:a,fastForward:o=!0,fastForwardOnly:s=!1,dryRun:l=!1,noUpdateBranch:c=!1,abortOnConflict:f=!0,message:d,author:u,committer:h,signingKey:m,cache:g={},mergeDriver:y,allowUnrelatedHistories:b=!1}){try{C("fs",t),m&&C("onSign",e);let v=new nt(t),k=await dt({fsp:v,dotgit:i}),S=await qa({fs:v,gitdir:k,author:u});if(!S&&(!s||!o))throw new pe("author");let x=await Za({fs:v,gitdir:k,author:S,committer:h});if(!x&&(!s||!o))throw new pe("committer");return await Cm({fs:v,cache:g,dir:r,gitdir:k,ours:n,theirs:a,fastForward:o,fastForwardOnly:s,dryRun:l,noUpdateBranch:c,abortOnConflict:f,message:d,author:S,committer:x,signingKey:m,onSign:e,mergeDriver:y,allowUnrelatedHistories:b})}catch(v){throw v.caller="git.merge",v}}var Dm={commit:16,tree:32,blob:48,tag:64,ofs_delta:96,ref_delta:112};async function Nm({fs:t,cache:e,dir:r,gitdir:i=P(r,".git"),oids:n}){let a=new Xa.default,o=[];function s(f,d){let u=Buffer.from(f,d);o.push(u),a.update(u)}async function l({stype:f,object:d}){let u=Dm[f],h=d.length,m=h>15?128:0,g=h&15;h=h>>>4;let y=(m|u|g).toString(16);for(s(y,"hex");m;)m=h>127?128:0,y=m|h&127,s(Va(2,y),"hex"),h=h>>>7;s(Buffer.from(await vu(d)))}s("PACK"),s("00000002","hex"),s(Va(8,n.length),"hex");for(let f of n){let{type:d,object:u}=await K({fs:t,cache:e,gitdir:i,oid:f});await l({write:s,object:u,stype:d})}let c=a.digest();return o.push(c),o}async function Fm({fs:t,cache:e,dir:r,gitdir:i=P(r,".git"),start:n,finish:a}){let o=await qe.read({fs:t,gitdir:i}),s=new Set,l=new Set;for(let d of n)s.add(await D.resolve({fs:t,gitdir:i,ref:d}));for(let d of a)try{let u=await D.resolve({fs:t,gitdir:i,ref:d});l.add(u)}catch(u){}let c=new Set;async function f(d){c.add(d);let{type:u,object:h}=await K({fs:t,cache:e,gitdir:i,oid:d});if(u==="tag"){let g=we.from(h).headers().object;return f(g)}if(u!=="commit")throw new Nt(d,u,"commit");if(!o.has(d)){let g=kt.from(h).headers().parent;for(d of g)!l.has(d)&&!c.has(d)&&await f(d)}}for(let d of s)await f(d);return c}async function $a({fs:t,cache:e,dir:r,gitdir:i=P(r,".git"),oids:n}){let a=new Set;async function o(s){if(a.has(s))return;a.add(s);let{type:l,object:c}=await K({fs:t,cache:e,gitdir:i,oid:s});if(l==="tag"){let d=we.from(c).headers().object;await o(d)}else if(l==="commit"){let d=kt.from(c).headers().tree;await o(d)}else if(l==="tree"){let f=Ht.from(c);for(let d of f)d.type==="blob"&&a.add(d.oid),d.type==="tree"&&await o(d.oid)}}for(let s of n)await o(s);return a}async function Um(t){let e={},r="",i=it.streamReader(t),n=await i();for(;n!==!0;)n!==null&&(r+=n.toString("utf8")+`
|
|
`),n=await i();let a=r.toString("utf8").split(`
|
|
`);if(n=a.shift(),!n.startsWith("unpack "))throw new Ge('unpack ok" or "unpack [error message]',n);e.ok=n==="unpack ok",e.ok||(e.error=n.slice(7)),e.refs={};for(let o of a){if(o.trim()==="")continue;let s=o.slice(0,2),l=o.slice(3),c=l.indexOf(" ");c===-1&&(c=l.length);let f=l.slice(0,c),d=l.slice(c+1);e.refs[f]={ok:s==="ok",error:d}}return e}async function jm({capabilities:t=[],triplets:e=[]}){let r=[],i=`\0 ${t.join(" ")}`;for(let n of e)r.push(it.encode(`${n.oldoid} ${n.oid} ${n.fullRef}${i}
|
|
`)),i="";return r.push(it.flush()),r}async function Mm({fs:t,cache:e,http:r,onProgress:i,onMessage:n,onAuth:a,onAuthSuccess:o,onAuthFailure:s,onPrePush:l,gitdir:c,ref:f,remoteRef:d,remote:u,url:h,force:m=!1,delete:g=!1,corsProxy:y,headers:b={}}){let v=f||await Ya({fs:t,gitdir:c});if(typeof v=="undefined")throw new St("ref");let k=await J.get({fs:t,gitdir:c});u=u||await k.get(`branch.${v}.pushRemote`)||await k.get("remote.pushDefault")||await k.get(`branch.${v}.remote`)||"origin";let S=h||await k.get(`remote.${u}.pushurl`)||await k.get(`remote.${u}.url`);if(typeof S=="undefined")throw new St("remote OR url");let x=d||await k.get(`branch.${v}.merge`);if(typeof S=="undefined")throw new St("remoteRef");y===void 0&&(y=await k.get("http.corsProxy"));let T=await D.expand({fs:t,gitdir:c,ref:v}),p=g?"0000000000000000000000000000000000000000":await D.resolve({fs:t,gitdir:c,ref:T}),_=Gi.getRemoteHelperFor({url:S}),w=await _.discover({http:r,onAuth:a,onAuthSuccess:o,onAuthFailure:s,corsProxy:y,service:"git-receive-pack",url:S,headers:b,protocolVersion:1}),A=w.auth,E;if(!x)E=T;else try{E=await D.expandAgainstMap({ref:x,map:w.refs})}catch(L){if(L instanceof ct)E=x.startsWith("refs/")?x:`refs/heads/${x}`;else throw L}let $=w.refs.get(E)||"0000000000000000000000000000000000000000";if(l&&!await l({remote:u,url:S,localRef:{ref:g?"(delete)":T,oid:p},remoteRef:{ref:E,oid:$}}))throw new kr;let R=!w.capabilities.has("no-thin"),B=new Set;if(!g){let L=[...w.refs.values()],At=new Set;if($!=="0000000000000000000000000000000000000000"){let Q=await Uu({fs:t,cache:e,gitdir:c,oids:[p,$]});for(let Ze of Q)L.push(Ze);R&&(At=await $a({fs:t,cache:e,gitdir:c,oids:Q}))}if(!L.includes(p)){let Q=await Fm({fs:t,cache:e,gitdir:c,start:[p],finish:L});B=await $a({fs:t,cache:e,gitdir:c,oids:Q})}if(R){try{let Q=await D.resolve({fs:t,gitdir:c,ref:`refs/remotes/${u}/HEAD`,depth:2}),{oid:Ze}=await D.resolveAgainstMap({ref:Q.replace(`refs/remotes/${u}/`,""),fullref:Q,map:w.refs}),te=[Ze];for(let q of await $a({fs:t,cache:e,gitdir:c,oids:te}))At.add(q)}catch(Q){}for(let Q of At)B.delete(Q)}if(p===$&&(m=!0),!m){if(T.startsWith("refs/tags")&&$!=="0000000000000000000000000000000000000000")throw new Sr("tag-exists");if(p!=="0000000000000000000000000000000000000000"&&$!=="0000000000000000000000000000000000000000"&&!await Bm({fs:t,cache:e,gitdir:c,oid:p,ancestor:$,depth:-1}))throw new Sr("not-fast-forward")}}let H=Iu([...w.capabilities],["report-status","side-band-64k",`agent=${Pu.agent}`]),ht=await jm({capabilities:H,triplets:[{oldoid:$,oid:p,fullRef:E}]}),W=g?[]:await Nm({fs:t,cache:e,gitdir:c,oids:[...B]}),tt=await _.connect({http:r,onProgress:i,corsProxy:y,service:"git-receive-pack",url:S,auth:A,headers:b,body:[...ht,...W]}),{packfile:Jt,progress:tn}=await qi.demux(tt.body);if(n){let L=Cu(tn);Tr(L,async At=>{await n(At)})}let ft=await Um(Jt);if(tt.headers&&(ft.headers=tt.headers),u&&ft.ok&&ft.refs[E].ok&&!T.startsWith("refs/tags")){let L=`refs/remotes/${u}/${E.replace("refs/heads","")}`;g?await D.deleteRef({fs:t,gitdir:c,ref:L}):await D.writeRef({fs:t,gitdir:c,ref:L,value:p})}if(ft.ok&&Object.values(ft.refs).every(L=>L.ok))return ft;{let L=Object.entries(ft.refs).filter(([At,Q])=>!Q.ok).map(([At,Q])=>`
|
|
- ${At}: ${Q.error}`).join("");throw new Ii(L,ft)}}async function Yi({fs:t,http:e,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:o,onPrePush:s,dir:l,gitdir:c=P(l,".git"),ref:f,remoteRef:d,remote:u="origin",url:h,force:m=!1,delete:g=!1,corsProxy:y,headers:b={},cache:v={}}){try{C("fs",t),C("http",e),C("gitdir",c);let k=new nt(t),S=await dt({fsp:k,dotgit:c});return await Mm({fs:k,cache:v,http:e,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:o,onPrePush:s,gitdir:S,ref:f,remoteRef:d,remote:u,url:h,force:m,delete:g,corsProxy:y,headers:b})}catch(k){throw k.caller="git.push",k}}async function zu({fs:t,cache:e,gitdir:r,oid:i}){let{type:n,object:a}=await K({fs:t,cache:e,gitdir:r,oid:i});if(n==="tag")return i=we.from(a).parse().object,zu({fs:t,cache:e,gitdir:r,oid:i});if(n!=="blob")throw new Nt(i,n,"blob");return{oid:i,blob:new Uint8Array(a)}}async function zm({fs:t,cache:e,gitdir:r,oid:i,filepath:n=void 0}){return n!==void 0&&(i=await dm({fs:t,cache:e,gitdir:r,oid:i,filepath:n})),await zu({fs:t,cache:e,gitdir:r,oid:i})}async function Lu({fs:t,dir:e,gitdir:r=P(e,".git"),oid:i,filepath:n,cache:a={}}){try{C("fs",t),C("gitdir",r),C("oid",i);let o=new nt(t),s=await dt({fsp:o,dotgit:r});return await zm({fs:o,cache:a,gitdir:s,oid:i,filepath:n})}catch(o){throw o.caller="git.readBlob",o}}async function Hu({fs:t,dir:e,gitdir:r=P(e,".git"),filepath:i,cache:n={}}){try{C("fs",t),C("gitdir",r),C("filepath",i);let a=new nt(t),o=await dt({fsp:a,dotgit:r});await _t.acquire({fs:a,gitdir:o,cache:n},async function(s){s.delete({filepath:i})})}catch(a){throw a.caller="git.remove",a}}async function me({fs:t,dir:e,gitdir:r=P(e,".git"),ref:i,depth:n}){try{C("fs",t),C("gitdir",r),C("ref",i);let a=new nt(t),o=await dt({fsp:a,dotgit:r});return await D.resolve({fs:a,gitdir:o,ref:i,depth:n})}catch(a){throw a.caller="git.resolveRef",a}}async function Ki({fs:t,dir:e,gitdir:r=P(e,".git"),ref:i="HEAD",filepaths:n=["."],filter:a,cache:o={},ignored:s=!1,refresh:l=!0}){try{C("fs",t),C("gitdir",r),C("ref",i);let c=new nt(t),f=await dt({fsp:c,dotgit:r});return await Mi({fs:c,cache:o,dir:e,gitdir:f,trees:[Fe({ref:i}),bu({refresh:l}),pu()],map:async function(d,[u,h,m]){if(!u&&!m&&h&&!s&&await zi.isIgnored({fs:c,dir:e,filepath:d})||!n.some(_=>Ou(d,_)))return null;if(a&&!a(d))return;let[g,y,b]=await Promise.all([u&&u.type(),h&&h.type(),m&&m.type()]),v=[g,y,b].includes("blob");if((g==="tree"||g==="special")&&!v)return;if(g==="commit")return null;if((y==="tree"||y==="special")&&!v)return;if(b==="commit")return null;if((b==="tree"||b==="special")&&!v)return;let k=g==="blob"?await u.oid():void 0,S=b==="blob"?await m.oid():void 0,x;g!=="blob"&&y==="blob"&&b!=="blob"?x="42":y==="blob"&&(x=await h.oid());let T=[void 0,k,x,S],p=T.map(_=>T.indexOf(_));return p.shift(),[d,...p]}})}catch(c){throw c.caller="git.statusMatrix",c}}var qu=require("obsidian");function Gu(t,e){function r(n){let a=n.replace(/\\/g,"/"),o=e.replace(/\\/g,"/").replace(/\/$/,"");return a.startsWith(o+"/")?a.slice(o.length+1):a}let i={async readFile(n,a){try{let o=await t.readBinary(r(n));return(a==null?void 0:a.encoding)==="utf8"?Buffer.from(o).toString("utf8"):Buffer.from(o)}catch(o){let s=new Error(`ENOENT: no such file or directory, open '${n}'`);throw s.code="ENOENT",s}},async writeFile(n,a){let o=r(n),s=o.split("/");if(s.length>1){let l=s.slice(0,-1).join("/");try{await t.mkdir(l)}catch(c){}}if(typeof a=="string")await t.write(o,a);else{let l=Buffer.isBuffer(a)?a:Buffer.from(a);await t.writeBinary(o,l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength))}},async unlink(n){try{await t.remove(r(n))}catch(a){}},async readdir(n){try{let a=await t.list(r(n)),o=a.files.map(l=>l.split("/").pop());return[...a.folders.map(l=>l.split("/").pop()),...o]}catch(a){let o=new Error(`ENOENT: no such file or directory, scandir '${n}'`);throw o.code="ENOENT",o}},async mkdir(n,a){try{await t.mkdir(r(n))}catch(o){}},async rmdir(n){},async stat(n){var a,o,s;try{let l=await t.stat(r(n));if(!l)throw new Error("no stat");let c=l.type!=="file";return{type:c?"dir":"file",mode:c?16877:33188,size:(a=l.size)!=null?a:0,ino:0,mtimeMs:(o=l.mtime)!=null?o:Date.now(),ctimeMs:(s=l.ctime)!=null?s:Date.now(),uid:1,gid:1,dev:1,isFile:()=>!c,isDirectory:()=>c,isSymbolicLink:()=>!1}}catch(l){let c=new Error(`ENOENT: no such file or directory, stat '${n}'`);throw c.code="ENOENT",c}},async lstat(n){return i.stat(n)},async readlink(n){throw Object.assign(new Error(`EINVAL: readlink not supported '${n}'`),{code:"EINVAL"})},async symlink(){throw Object.assign(new Error("EINVAL: symlink not supported"),{code:"EINVAL"})},async chmod(){}};return{promises:i}}var Hm={async request({url:t,method:e,headers:r,body:i}){let n;if(i){let l=[];for await(let u of i)l.push(u);let c=l.reduce((u,h)=>u+h.length,0),f=new Uint8Array(c),d=0;for(let u of l)f.set(u,d),d+=u.length;n=f.buffer}let a=await(0,qu.requestUrl)({url:t,method:e,headers:r,body:n,throw:!1}),o=a.arrayBuffer;async function*s(){yield new Uint8Array(o)}return{url:t,method:e,statusCode:a.status,statusMessage:"OK",body:s(),headers:a.headers}}},Or=class{constructor(e,r,i,n,a){this.fs=Gu(e,r),this.dir=r,this.token=i,this.username=n,this.remoteUrl=`https://github.com/${n}/${a}.git`}gitOpts(){return{fs:this.fs,http:Hm,dir:this.dir,author:{name:Pr,email:Cr}}}netOpts(){let e=this.token,r=this.username;return{...this.gitOpts(),url:this.remoteUrl,onAuth:()=>({username:r,password:e}),onAuthFailure:()=>{throw new Error("GitHub authentication failed. Please reconnect your account in MultiSync settings.")}}}async isInitialized(){try{return await me({fs:this.fs,dir:this.dir,ref:"HEAD"}),!0}catch(e){return!1}}async hasLocalBranch(){try{return await me({fs:this.fs,dir:this.dir,ref:wt}),!0}catch(e){return!1}}async safeFetch(){try{return await ju({...this.netOpts(),ref:wt,singleBranch:!0}),await me({fs:this.fs,dir:this.dir,ref:"FETCH_HEAD"})}catch(e){return null}}async clone(){return await Nu({...this.netOpts(),singleBranch:!0,depth:1}),this.hasLocalBranch()}async initAndPush(e){await this.isInitialized()||await Mu({fs:this.fs,dir:this.dir,defaultBranch:wt});for(let n of e)try{await Xi({fs:this.fs,dir:this.dir,filepath:n})}catch(a){}await this.hasLocalBranch()?(await Ki({fs:this.fs,dir:this.dir})).some(([,o,s,l])=>o!==1||s!==1||l!==1)&&await $r({...this.gitOpts(),message:"sync: initial vault snapshot"}):await $r({...this.gitOpts(),message:"sync: initial vault snapshot"});try{await Fu({fs:this.fs,dir:this.dir,remote:"origin"})}catch(n){}await $u({fs:this.fs,dir:this.dir,remote:"origin",url:this.remoteUrl}),await Yi({...this.netOpts(),ref:wt,force:!1})}async sync(e){let r=[];try{for(let a of e)try{await Xi({fs:this.fs,dir:this.dir,filepath:a})}catch(o){try{await Hu({fs:this.fs,dir:this.dir,filepath:a})}catch(s){}}let i;try{i=(await Ki({fs:this.fs,dir:this.dir})).some(([,o,s,l])=>o!==1||s!==1||l!==1)}catch(a){i=e.length>0}if(i){let a=new Date().toISOString().replace("T"," ").slice(0,19);await $r({...this.gitOpts(),message:`sync: ${a}`})}let n=await this.safeFetch();if(n&&await this.hasLocalBranch()){let a=await me({fs:this.fs,dir:this.dir,ref:wt});n!==a&&await Ka({fs:this.fs,dir:this.dir,ours:wt,theirs:n,author:{name:Pr,email:Cr},message:"sync: merge remote changes",fastForwardOnly:!1})}if(await this.hasLocalBranch()){let a=await Ki({fs:this.fs,dir:this.dir});for(let[o,s,l,c]of a)if(c===2||s===0&&l===2&&c===0){let f=await this.readFileContent(o),d=await this.readRemoteFileContent(o);r.push({path:o,ours:f,theirs:d})}}return r.length===0&&await this.hasLocalBranch()&&await Yi({...this.netOpts(),ref:wt}),{success:r.length===0,conflictFiles:r}}catch(i){let n=i instanceof Error?i.message:String(i);return{success:!1,conflictFiles:[],error:n}}}async resolveConflict(e,r){let i=`${this.dir}/${e}`;await this.fs.promises.writeFile(i,r),await Xi({fs:this.fs,dir:this.dir,filepath:e}),await $r({...this.gitOpts(),message:`sync: resolve conflict in ${e}`}),await Yi({...this.netOpts(),ref:wt})}async pull(){if(!await this.hasLocalBranch())return;let e=await this.safeFetch();if(!e)return;let r=await me({fs:this.fs,dir:this.dir,ref:wt});e!==r&&await Ka({fs:this.fs,dir:this.dir,ours:wt,theirs:e,author:{name:Pr,email:Cr},message:"sync: merge remote changes",fastForwardOnly:!1})}async readFileContent(e){try{return await this.fs.promises.readFile(`${this.dir}/${e}`,{encoding:"utf8"})}catch(r){return""}}async readRemoteFileContent(e){try{let r=await me({fs:this.fs,dir:this.dir,ref:`refs/remotes/origin/${wt}`}),{blob:i}=await Lu({fs:this.fs,dir:this.dir,oid:r,filepath:e});return new TextDecoder().decode(i)}catch(r){return""}}};var Qi=class{constructor(e,r){this.pendingFiles=new Set;this.debounceTimer=null;this.running=!1;this.gitSync=e,this.onStatus=r}enqueue(e){this.pendingFiles.add(e),this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>this.flush(),3e3)}async flushNow(){return this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.flush()}async flush(){if(this.running||this.pendingFiles.size===0)return null;this.running=!0;let e=[...this.pendingFiles];this.pendingFiles.clear();try{this.onStatus("pushing");let r=await this.gitSync.sync(e);return r.conflictFiles.length>0?this.onStatus("conflict"):r.success?this.onStatus("idle"):this.onStatus("error",r.error),r}catch(r){let i=r instanceof Error?r.message:String(r);return this.onStatus("error",i),{success:!1,conflictFiles:[],error:i}}finally{this.running=!1,this.pendingFiles.size>0&&setTimeout(()=>this.flush(),500)}}};var Ji=class extends at.Plugin{constructor(){super(...arguments);this.gitSync=null;this.syncQueue=null}async onload(){await this.loadSettings(),this.statusBar=new Dr(this),this.statusBar.onClick(()=>this.triggerManualSync()),this.addSettingTab(new Br(this.app,this)),this.addCommand({id:"sync-now",name:"Sync vault now",callback:()=>this.triggerManualSync()}),this.settings.githubToken&&this.settings.githubUsername&&this.settings.repoName&&await this.bootSyncEngine(),this.app.workspace.onLayoutReady(async()=>{if(this.gitSync){this.setStatus("pulling");try{await this.gitSync.pull(),this.setStatus("idle")}catch(r){this.setStatus("error","Pull failed on open")}}}),this.registerEvent(this.app.vault.on("modify",r=>{r instanceof at.TFile&&(!this.syncQueue||!this.settings.autoSync||this.isExcluded(r.path)||this.syncQueue.enqueue(r.path))})),this.registerEvent(this.app.vault.on("create",r=>{r instanceof at.TFile&&(!this.syncQueue||!this.settings.autoSync||this.isExcluded(r.path)||this.syncQueue.enqueue(r.path))})),this.registerEvent(this.app.vault.on("delete",r=>{r instanceof at.TFile&&(!this.syncQueue||!this.settings.autoSync||this.syncQueue.enqueue(r.path))})),this.registerEvent(this.app.vault.on("rename",(r,i)=>{!this.syncQueue||!this.settings.autoSync||this.syncQueue.enqueue(i)}))}async onunload(){this.syncQueue&&await this.syncQueue.flushNow()}async loadSettings(){this.settings=Object.assign({},to,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}setStatus(r,i){this.statusBar.set(r,i)}async initializeRepo(r,i){var u;this.setStatus("connecting");let n=this.app.vault.getName(),a=fo(n);this.settings.repoName=a;let o=this.app.vault.adapter,s=(u=o.basePath)!=null?u:"",l=new Or(o,s,r,i,a),c=await so(r,i,a),f=await l.isInitialized(),d=()=>this.app.vault.getFiles().map(h=>h.path).filter(h=>!this.isExcluded(h));c?f?new at.Notice(`Reconnected to: ${i}/${a}`):await l.clone()?new at.Notice(`Cloned repo: ${i}/${a}`):(await l.initAndPush(d()),new at.Notice(`Initialised repo: ${i}/${a}`)):(await co(r,a,`Obsidian vault: ${n}`),await l.initAndPush(d()),new at.Notice(`Created private repo: ${i}/${a}`)),this.settings.lastSyncTime=Date.now(),await this.saveSettings(),await this.bootSyncEngine(),this.setStatus("idle")}async bootSyncEngine(){var s;let{githubToken:r,githubUsername:i,repoName:n}=this.settings;if(!r||!i||!n)return;let a=this.app.vault.adapter,o=(s=a.basePath)!=null?s:"";this.gitSync=new Or(a,o,r,i,n),this.syncQueue=new Qi(this.gitSync,(l,c)=>{this.setStatus(l,c),l==="idle"&&(this.settings.lastSyncTime=Date.now(),this.saveSettings())})}async triggerManualSync(){if(!this.gitSync){new at.Notice("MultiSync: not connected. Please connect your GitHub account in settings.");return}this.setStatus("pulling");try{let r=this.app.vault.getFiles().map(n=>n.path).filter(n=>!this.isExcluded(n)),i=await this.gitSync.sync(r);i.conflictFiles.length>0?(this.setStatus("conflict"),this.showConflictModal(i.conflictFiles)):i.success?(this.settings.lastSyncTime=Date.now(),await this.saveSettings(),this.setStatus("idle"),new at.Notice("Vault synced successfully.")):(this.setStatus("error",i.error),new at.Notice(`Sync error: ${i.error}`))}catch(r){let i=r instanceof Error?r.message:String(r);this.setStatus("error",i),new at.Notice(`Sync failed: ${i}`)}}showConflictModal(r){new Nr(this.app,r,async(i,n)=>{await this.gitSync.resolveConflict(i,n),this.settings.lastSyncTime=Date.now(),await this.saveSettings(),this.setStatus("idle")}).open()}isExcluded(r){return this.settings.excludePatterns.some(i=>{let a=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${a}$`).test(r)})}};
|
|
/*! Bundled license information:
|
|
|
|
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 *)
|
|
|
|
isomorphic-git/index.js:
|
|
(*!
|
|
* This code for `path.join` is directly copied from @zenfs/core/path for bundle size improvements.
|
|
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
* Copyright (c) James Prevett and other ZenFS contributors.
|
|
*)
|
|
*/
|
|
|
|
/* nosourcemap */ |