@scolladon/tsgit 2.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -2
- package/dist/cjs/adapters/browser/index.cjs +1 -2
- package/dist/cjs/adapters/memory/index.cjs +1 -2
- package/dist/cjs/adapters/node/index.cjs +1 -2
- package/dist/cjs/chunks/adapter-detect-DW9fsw9d.cjs +1 -0
- package/dist/cjs/chunks/browser-http-transport-DGwW5YL7.cjs +1 -0
- package/dist/cjs/chunks/context-BcoAzPuU.cjs +0 -1
- package/dist/cjs/chunks/error-CfLWDui_.cjs +1 -0
- package/dist/cjs/chunks/index-Cy44GVR6.cjs +1 -0
- package/dist/cjs/chunks/inflate-CmCtM4-w.cjs +1 -0
- package/dist/cjs/chunks/lru-cache-1OU7JhD8.cjs +0 -1
- package/dist/cjs/chunks/memory-http-transport-CGriODcQ.cjs +1 -0
- package/dist/cjs/chunks/node-ssh-transport-PFu3ijfp.cjs +1 -0
- package/dist/cjs/chunks/{progress-CxU62NC1.cjs → progress-D8Dqbftk.cjs} +1 -2
- package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs +0 -1
- package/dist/cjs/chunks/repository-Ci-BBxk0.cjs +1 -0
- package/dist/cjs/chunks/write-sparse-checkout-C1dsHCAD.cjs +1 -0
- package/dist/cjs/commands/index.cjs +1 -2
- package/dist/cjs/index.browser.cjs +1 -2
- package/dist/cjs/index.cjs +1 -2
- package/dist/cjs/index.default.cjs +1 -2
- package/dist/cjs/index.node.cjs +1 -2
- package/dist/cjs/operators/index.cjs +0 -1
- package/dist/cjs/primitives/index.cjs +1 -2
- package/dist/cjs/transport/index.cjs +0 -1
- package/dist/esm/adapters/browser/index.js +1 -2
- package/dist/esm/adapters/memory/index.js +1 -2
- package/dist/esm/adapters/node/index.js +1 -2
- package/dist/esm/chunks/adapter-detect-BkCMnjrI.js +1 -0
- package/dist/esm/chunks/browser-http-transport-CSxAte5h.js +1 -0
- package/dist/esm/chunks/context-CumKOV7K.js +0 -1
- package/dist/esm/chunks/error-BotOd-nD.js +1 -0
- package/dist/esm/chunks/index-DsvINN8n.js +1 -0
- package/dist/esm/chunks/inflate-BCIXqeeE.js +1 -0
- package/dist/esm/chunks/lru-cache-Cy7C7Lx2.js +0 -1
- package/dist/esm/chunks/memory-http-transport-caqmMGR1.js +1 -0
- package/dist/esm/chunks/node-ssh-transport-BgSv2IhT.js +1 -0
- package/dist/esm/chunks/{progress-BZobfl7p.js → progress-B_AJnOHx.js} +1 -2
- package/dist/esm/chunks/readable-stream-CGuf8k1J.js +0 -1
- package/dist/esm/chunks/repository-DyxknzvE.js +1 -0
- package/dist/esm/chunks/write-sparse-checkout-BwHbNKNS.js +1 -0
- package/dist/esm/commands/index.js +1 -2
- package/dist/esm/index.browser.js +1 -2
- package/dist/esm/index.default.js +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.node.js +1 -2
- package/dist/esm/operators/index.js +0 -1
- package/dist/esm/primitives/index.js +1 -2
- package/dist/esm/transport/index.js +0 -1
- package/dist/types/adapters/browser/index.d.cts +5 -3
- package/dist/types/adapters/browser/index.d.ts +5 -3
- package/dist/types/adapters/memory/index.d.cts +31 -4
- package/dist/types/adapters/memory/index.d.ts +31 -4
- package/dist/types/adapters/node/index.d.cts +146 -40
- package/dist/types/adapters/node/index.d.ts +146 -40
- package/dist/types/chunks/{context-YDw6qicq.d.cts → context-CF1YF2S8.d.cts} +165 -6
- package/dist/types/chunks/{context-CCL0_F8R.d.ts → context-sIhhtk2u.d.ts} +165 -6
- package/dist/types/chunks/{http-transport--_NdQOiw.d.cts → http-transport-DirKfK2S.d.cts} +1 -1
- package/dist/types/chunks/{http-transport--_NdQOiw.d.ts → http-transport-DirKfK2S.d.ts} +1 -1
- package/dist/types/chunks/index-B5Dps3fg.d.ts +2468 -0
- package/dist/types/chunks/index-B_A8VLaf.d.ts +1221 -0
- package/dist/types/chunks/index-Dfh8cvEs.d.cts +2468 -0
- package/dist/types/chunks/index-Dqxddhav.d.cts +1221 -0
- package/dist/types/chunks/progress-BjAKfkam.d.ts +1217 -0
- package/dist/types/chunks/progress-Ldnfb8st.d.cts +1217 -0
- package/dist/types/chunks/reflog-entry-Cqh3QrPH.d.ts +697 -0
- package/dist/types/chunks/reflog-entry-Dy-O27Dd.d.cts +697 -0
- package/dist/types/chunks/{repository-FoS_Laoy.d.ts → repository-D8QBTkEz.d.ts} +58 -20
- package/dist/types/chunks/{repository-BeifCqp0.d.cts → repository-D9YrVhcH.d.cts} +58 -20
- package/dist/types/commands/index.d.cts +4 -1259
- package/dist/types/commands/index.d.ts +4 -1259
- package/dist/types/index.browser.d.cts +7 -8
- package/dist/types/index.browser.d.ts +7 -8
- package/dist/types/index.d.cts +61 -124
- package/dist/types/index.d.ts +61 -124
- package/dist/types/index.default.d.cts +7 -8
- package/dist/types/index.default.d.ts +7 -8
- package/dist/types/index.node.d.cts +7 -8
- package/dist/types/index.node.d.ts +7 -8
- package/dist/types/primitives/index.d.cts +4 -692
- package/dist/types/primitives/index.d.ts +4 -692
- package/dist/types/transport/index.d.cts +1 -1
- package/dist/types/transport/index.d.ts +1 -1
- package/package.json +94 -28
- package/dist/cjs/adapters/browser/index.cjs.map +0 -1
- package/dist/cjs/adapters/memory/index.cjs.map +0 -1
- package/dist/cjs/adapters/node/index.cjs.map +0 -1
- package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs +0 -2
- package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs.map +0 -1
- package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs +0 -2
- package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs.map +0 -1
- package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +0 -1
- package/dist/cjs/chunks/error-CfjFO3x_.cjs +0 -2
- package/dist/cjs/chunks/error-CfjFO3x_.cjs.map +0 -1
- package/dist/cjs/chunks/index-BWCq_5BJ.cjs +0 -2
- package/dist/cjs/chunks/index-BWCq_5BJ.cjs.map +0 -1
- package/dist/cjs/chunks/lru-cache-1OU7JhD8.cjs.map +0 -1
- package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs +0 -2
- package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs.map +0 -1
- package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs +0 -2
- package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs.map +0 -1
- package/dist/cjs/chunks/progress-CxU62NC1.cjs.map +0 -1
- package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs.map +0 -1
- package/dist/cjs/chunks/repository-BEg2zNtx.cjs +0 -2
- package/dist/cjs/chunks/repository-BEg2zNtx.cjs.map +0 -1
- package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs +0 -2
- package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs.map +0 -1
- package/dist/cjs/commands/index.cjs.map +0 -1
- package/dist/cjs/index.browser.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.default.cjs.map +0 -1
- package/dist/cjs/index.node.cjs.map +0 -1
- package/dist/cjs/operators/index.cjs.map +0 -1
- package/dist/cjs/primitives/index.cjs.map +0 -1
- package/dist/cjs/transport/index.cjs.map +0 -1
- package/dist/esm/adapters/browser/index.js.map +0 -1
- package/dist/esm/adapters/memory/index.js.map +0 -1
- package/dist/esm/adapters/node/index.js.map +0 -1
- package/dist/esm/chunks/adapter-detect-DkZhhUhd.js +0 -2
- package/dist/esm/chunks/adapter-detect-DkZhhUhd.js.map +0 -1
- package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js +0 -2
- package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js.map +0 -1
- package/dist/esm/chunks/context-CumKOV7K.js.map +0 -1
- package/dist/esm/chunks/error-Dc-SRSJK.js +0 -2
- package/dist/esm/chunks/error-Dc-SRSJK.js.map +0 -1
- package/dist/esm/chunks/index-jH0UMhh-.js +0 -2
- package/dist/esm/chunks/index-jH0UMhh-.js.map +0 -1
- package/dist/esm/chunks/lru-cache-Cy7C7Lx2.js.map +0 -1
- package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js +0 -2
- package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js.map +0 -1
- package/dist/esm/chunks/node-http-transport-DPa2lK3T.js +0 -2
- package/dist/esm/chunks/node-http-transport-DPa2lK3T.js.map +0 -1
- package/dist/esm/chunks/progress-BZobfl7p.js.map +0 -1
- package/dist/esm/chunks/readable-stream-CGuf8k1J.js.map +0 -1
- package/dist/esm/chunks/repository-DF6ePd1x.js +0 -2
- package/dist/esm/chunks/repository-DF6ePd1x.js.map +0 -1
- package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js +0 -2
- package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js.map +0 -1
- package/dist/esm/commands/index.js.map +0 -1
- package/dist/esm/index.browser.js.map +0 -1
- package/dist/esm/index.default.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.node.js.map +0 -1
- package/dist/esm/operators/index.js.map +0 -1
- package/dist/esm/primitives/index.js.map +0 -1
- package/dist/esm/transport/index.js.map +0 -1
- package/dist/types/chunks/index-entry-DtEbVpOG.d.cts +0 -47
- package/dist/types/chunks/index-entry-UD4dvtKh.d.ts +0 -47
- package/dist/types/chunks/progress-7KKiXXfX.d.ts +0 -405
- package/dist/types/chunks/progress-By8yFaUE.d.cts +0 -405
- package/dist/types/chunks/reflog-entry-BbNnXCTC.d.cts +0 -368
- package/dist/types/chunks/reflog-entry-CSzjnZd4.d.ts +0 -368
- package/dist/types/chunks/write-tree-C3oNxOlX.d.cts +0 -196
- package/dist/types/chunks/write-tree-DRI-LzSr.d.ts +0 -196
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("./error-CfLWDui_.cjs");const e=[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],s=[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],n=[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],i=[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],r=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],o=r.length;class a{bytes;bytePos;bitBuffer=0;bitCount=0;constructor(t,e){this.bytes=t,this.bytePos=e}get position(){return this.bytePos}readBits(e){const s=this.peekBits(e);if(s.availableBits<e)throw t.decompressFailed("unexpected end of deflate stream");return this.dropBits(e),s.value}peekBits(t){return this.fill(t),{value:this.bitBuffer&(1<<t)-1,availableBits:Math.min(this.bitCount,t)}}dropBits(t){this.bitBuffer>>>=t,this.bitCount-=t,this.ungetSpareBytes()}alignToByte(){this.bitBuffer=0,this.bitCount=0}readBytes(e){if(this.bytePos+e>this.bytes.length)throw t.decompressFailed("unexpected end of deflate stream");const s=this.bytes.subarray(this.bytePos,this.bytePos+e);return this.bytePos+=e,s}fill(t){for(;this.bitCount<t&&this.bytePos<this.bytes.length;)this.bitBuffer|=this.bytes[this.bytePos]<<this.bitCount,this.bitCount+=8,this.bytePos+=1}ungetSpareBytes(){const t=Math.floor(this.bitCount/8);0!==t&&(this.bitCount-=8*t,this.bitBuffer&=(1<<this.bitCount)-1,this.bytePos-=t)}}class l{maxBytes;buffer=new Uint8Array(64);length=0;constructor(t){this.maxBytes=t}append(t){this.ensureCapacity(this.length+t.length),this.buffer.set(t,this.length),this.length+=t.length}appendByte(t){this.ensureCapacity(this.length+1),this.buffer[this.length]=t,this.length+=1}copyBackReference(e,s){if(e>this.length)throw t.decompressFailed("distance exceeds output");this.ensureCapacity(this.length+s);const n=this.length-e;if(e>=s)return this.buffer.copyWithin(this.length,n,n+s),void(this.length+=s);this.copyOverlapping(n,s)}copyOverlapping(t,e){let s=t;for(let t=0;t<e;t+=1)this.buffer[this.length]=this.buffer[s],this.length+=1,s+=1}toUint8Array(){return this.buffer.subarray(0,this.length)}ensureCapacity(e){if(e>this.maxBytes)throw t.decompressFailed("inflated output exceeds safety cap");if(e<=this.buffer.length)return;const s=new Uint8Array(this.nextCapacity(e));s.set(this.buffer.subarray(0,this.length)),this.buffer=s}nextCapacity(t){let e=this.buffer.length;for(;e<t;)e*=2;return Math.min(e,this.maxBytes)}}function h(t){return t[0]|t[1]<<8}function c(e,s){e.alignToByte();const n=h(e.readBytes(2));if(h(e.readBytes(2))!==(65535&~n))throw t.decompressFailed("stored block length mismatch");s.append(e.readBytes(n))}function u(e,s){const n=function(t){const e=new Uint16Array(16);for(const s of t)s>0&&(e[s]=e[s]+1);return e}(e);!function(e,s){if("fixed"!==s&&0!==e.maxUsedLength&&0!==e.unusedCodes&&("code-length"===s||1!==e.maxUsedLength))throw t.decompressFailed(function(t){return"code-length"===t?"invalid code lengths set":"literal-length"===t?"invalid literal/lengths set":"invalid distances set"}(s))}(function(e){let s=1,n=0;for(let i=1;i<=15;i+=1){const r=e[i];if(r>0&&(n=i),s=2*s-r,s<0)throw t.decompressFailed("invalid huffman code lengths")}return{unusedCodes:s,maxUsedLength:n}}(n),s);const i=function(t,e){const s=function(t){const e=new Uint16Array(17);for(let s=1;s<=15;s+=1)e[s+1]=e[s]+t[s];return e}(e),n=new Uint16Array(t.length);return t.forEach((t,e)=>{if(0===t)return;const i=s[t];n[i]=e,s[t]=i+1}),n}(e,n);return{counts:n,symbols:i,root:f(n,i)}}function f(t,e){const s=new Uint8Array(512),n=new Uint16Array(512);let i=0,r=0;for(let o=1;o<=9;o+=1){const a=t[o];for(let t=0;t<a;t+=1)d(s,n,i+t,o,e[r+t]);r+=a,i+=a,i<<=1}return{lengths:s,symbols:n}}function d(t,e,s,n,i){const r=1<<n;for(let o=function(t,e){let s=0;for(let n=0;n<e;n+=1)s=s<<1|t>>n&1;return s}(s,n);o<512;o+=r)t[o]=n,e[o]=i}function p(e,s){const n=e.peekBits(9),i=s.root.lengths[n.value];return 0===i||i>n.availableBits?function(e,s){let n=0,i=0,r=0;for(let t=1;t<=15;t+=1){n|=e.readBits(1);const o=s.counts[t];if(n-i<o)return s.symbols[r+(n-i)];r+=o,i+=o,i<<=1,n<<=1}throw t.decompressFailed("invalid huffman code")}(e,s):(e.dropBits(i),s.root.symbols[n.value])}const y=u([[144,8],[112,9],[24,7],[8,8]].flatMap(([t,e])=>Array(t).fill(e)),"fixed"),b=u(Array(30).fill(5),"fixed");function g(r,o,a,l){const h=function(n,i){const r=i-257;if(r>=e.length)throw t.decompressFailed("invalid length code");return e[r]+n.readBits(s[r])}(r,l),c=function(e,s){if(s>=n.length)throw t.decompressFailed("invalid distance code");return n[s]+e.readBits(i[s])}(r,p(r,a));o.copyBackReference(c,h)}function B(t,e,s,n){for(;;){const i=p(t,s);if(i<256)e.appendByte(i);else{if(256===i)return;g(t,e,n,i)}}}function m(e,s,n,i){const{value:r,count:o}=function(e,s,n){if(16===n){if(0===s.length)throw t.decompressFailed("code-length repeat with no previous length");return{value:s[s.length-1],count:e.readBits(2)+3}}return 17===n?{value:0,count:e.readBits(3)+3}:{value:0,count:e.readBits(7)+11}}(e,s,n);if(s.length+o>i)throw t.decompressFailed("invalid code-length run");for(let t=0;t<o;t+=1)s.push(r)}function w(t){const e=t.readBits(5)+257,s=t.readBits(5)+1,n=t.readBits(4)+4,i=function(t,e){const s=new Array(o).fill(0);for(let n=0;n<e;n+=1)s[r[n]]=t.readBits(3);return s}(t,n),a=function(t,e,s){const n=[];for(;n.length<s;){const i=p(t,e);i<16?n.push(i):m(t,n,i,s)}return n}(t,u(i,"code-length"),e+s);return{litLenTable:u(a.slice(0,e),"literal-length"),distTable:u(a.slice(e),"distance")}}exports.inflateZlibMember=function(e,s,n=2147483648){const i=new a(e,s);!function(e){const s=e.readBytes(2),n=s[0],i=s[1];if(8!=(15&n))throw t.decompressFailed("unsupported compression method");if(n>>4>7)throw t.decompressFailed("invalid window size");if((256*n+i)%31!=0)throw t.decompressFailed("invalid zlib header checksum");if(i>>5&1)throw t.decompressFailed("preset dictionary not supported")}(i);const r=new l(n);!function(e,s){let n=!1;for(;!n;)switch(n=1===e.readBits(1),e.readBits(2)){case 0:c(e,s);break;case 1:B(e,s,y,b);break;case 2:{const{litLenTable:t,distTable:n}=w(e);B(e,s,t,n);break}default:throw t.decompressFailed("reserved block type")}}(i,r);const o=r.toUint8Array();return function(e,s){var n;if(e.alignToByte(),((n=e.readBytes(4))[0]<<24|n[1]<<16|n[2]<<8|n[3])>>>0!==function(t){let e=1,s=0;for(const n of t)e=(e+n)%65521,s=(s+e)%65521;return(s<<16|e)>>>0}(s))throw t.decompressFailed("adler32 checksum mismatch")}(i,o),{output:o,bytesConsumed:i.position-s}};
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
"use strict";const e=Object.freeze({digestLength:20,hexLength:40}),t=Object.freeze({digestLength:32,hexLength:64});exports.SHA1_CONFIG=e,exports.SHA256_CONFIG=t,exports.createLruCache=function(e,t=Number.POSITIVE_INFINITY){const n=new Map;let r=null,l=null,u=0;function i(e){null!==e.prev?e.prev.next=e.next:r=e.next,null!==e.next?e.next.prev=e.prev:l=e.prev,e.prev=null,e.next=null}function s(e){e.next=r,e.prev=null,null!==r&&(r.prev=e),r=e,null===l&&(l=e)}return{get maxSize(){return e},get currentSize(){return u},get entryCount(){return n.size},get(e){const t=n.get(e);if(void 0!==t)return i(t),s(t),t.value},set(r,o,c){if(c<=0)throw new Error("byteSize must be positive");if(c>e)return;const v=n.get(r);if(void 0!==v)u-=v.byteSize,v.value=o,v.byteSize=c,u+=c,i(v),s(v);else{const e={key:r,value:o,byteSize:c,prev:null,next:null};n.set(r,e),s(e),u+=c}!function(){for(;(u>e||n.size>t)&&null!==l;){const e=l;i(e),n.delete(e.key),u-=e.byteSize}}()},has:e=>n.has(e),delete(e){const t=n.get(e);return void 0!==t&&(i(t),n.delete(e),u-=t.byteSize,!0)},clear(){n.clear(),r=null,l=null,u=0}}};
|
|
2
|
-
//# sourceMappingURL=lru-cache-1OU7JhD8.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("./inflate-CmCtM4-w.cjs"),s=require("./error-CfLWDui_.cjs");async function e(t,s){const e=s,i=new ReadableStream({start(s){s.enqueue(t),s.close()}}).pipeTo(e.writable).catch(()=>{}),r=e.readable.getReader(),o=[];let n=0;for(;;){const{done:t,value:s}=await r.read();if(t)break;o.push(s),n+=s.length}await i;const h=new Uint8Array(n);let a=0;for(const t of o)h.set(t,a),a+=t.length;return h}function i(t){return t instanceof Error?t.message:String(t)}class r{files=new Map;directories=new Set;symlinks=new Map;times=new Map;rootDir;homePath;xdgPath;systemPath;constructor(t){this.rootDir=t.rootDir,this.homePath=t.home??"/home/user",this.xdgPath=t.xdg??"/home/user/.config",this.systemPath=t.systemConfig??"/etc/gitconfig",this.directories.add(this.rootDir);for(const[s,e]of Object.entries(t.files??{})){const t=this.resolve(s);this.files.set(t,e.slice()),this.touch(t),this.ensureParentDirs(t)}}homedir=()=>this.homePath;xdgConfigHome=()=>this.xdgPath;systemConfigPath=()=>this.systemPath;read=async t=>{const e=this.resolve(t),i=this.files.get(e);if(void 0===i)throw s.fileNotFound(t);return i.slice()};readSlice=async(t,e,i)=>{if(e<0||i<0)throw s.permissionDenied(t);const r=this.resolve(t),o=this.files.get(r);if(void 0===o)throw s.fileNotFound(t);const n=Math.min(e+i,o.length);return o.slice(e,n)};readUtf8=async t=>{const s=await this.read(t);return(new TextDecoder).decode(s)};write=async(t,s)=>{const e=this.resolve(t);this.ensureParentDirs(e),this.files.set(e,s.slice()),this.touch(e)};writeStream=async(t,s)=>{const e=[];for await(const t of s)e.push(t);const i=e.reduce((t,s)=>t+s.length,0),r=new Uint8Array(i);let o=0;for(const t of e)r.set(t,o),o+=t.length;await this.write(t,r)};writeExclusive=async(t,e)=>{const i=this.resolve(t);if(this.files.has(i)||this.symlinks.has(i))throw s.fileExists(t);this.ensureParentDirs(i),this.files.set(i,e.slice()),this.touch(i)};writeUtf8=async(t,s)=>{await this.write(t,(new TextEncoder).encode(s))};appendUtf8=async(t,s)=>{const e=await this.readExistingUtf8(t);await this.writeUtf8(t,e+s)};async readExistingUtf8(t){const s=this.files.get(this.resolve(t));return(new TextDecoder).decode(s)}exists=async t=>{const s=this.resolve(t);return this.files.has(s)||this.directories.has(s)||this.symlinks.has(s)};static SYMLINK_FOLLOW_LIMIT=40;stat=async t=>this.statFollowing(t,t,0);async statFollowing(t,e,i){if(i>=r.SYMLINK_FOLLOW_LIMIT)throw s.unsupportedOperation("stat",`symlink loop: ${e}`);const o=this.resolve(t),n=this.symlinks.get(o);return void 0!==n?this.statFollowing(n,e,i+1):this.buildStat(o,e)}lstat=async t=>{const s=this.resolve(t),e=this.symlinks.get(s);return void 0!==e?this.makeStatRecord({size:e.length,isFile:!1,isDirectory:!1,isSymbolicLink:!0,times:this.times.get(s)}):this.buildStat(s,t)};readdir=async t=>{const e=this.resolve(t);if(this.files.has(e))throw s.notADirectory(t);if(!this.directories.has(e))throw s.notADirectory(t);const i=`${e}/`,r=new Map;for(const t of this.files.keys())this.addDirectEntry(t,i,r,"file");for(const t of this.symlinks.keys())this.addDirectEntry(t,i,r,"symlink");for(const t of this.directories)t!==e&&this.addDirectEntry(t,i,r,"directory");return Array.from(r.values())};mkdir=async t=>{const e=this.resolve(t);if(this.files.has(e)||this.symlinks.has(e))throw s.notADirectory(t);this.addDirectoryRecursive(e)};rm=async t=>{const e=this.resolve(t);if(this.files.has(e))return this.files.delete(e),void this.times.delete(e);if(this.symlinks.has(e))return this.symlinks.delete(e),void this.times.delete(e);if(this.directories.has(e)){if(this.hasChildren(e))throw s.directoryNotEmpty(t);return this.directories.delete(e),void this.times.delete(e)}throw s.fileNotFound(t)};rename=async(t,e)=>{const i=this.resolve(t),r=this.resolve(e),o=this.files.get(i),n=this.symlinks.get(i);if(void 0===o&&void 0===n){if(this.directories.has(i))return void this.renameDirectory(i,r);throw s.fileNotFound(t)}const h=this.times.get(i);this.ensureParentDirs(r),this.files.delete(r),this.symlinks.delete(r),this.times.delete(r),void 0!==o&&(this.files.delete(i),this.files.set(r,o)),void 0!==n&&(this.symlinks.delete(i),this.symlinks.set(r,n)),this.times.delete(i),this.times.set(r,h)};renameDirectory(t,s){this.ensureParentDirs(s);const e=e=>e===t?s:`${s}${e.slice(t.length)}`,i=s=>{for(const[i,r]of[...s])(i===t||i.startsWith(`${t}/`))&&(s.delete(i),s.set(e(i),r))};for(const s of[...this.directories])(s===t||s.startsWith(`${t}/`))&&(this.directories.delete(s),this.directories.add(e(s)));i(this.files),i(this.symlinks),i(this.times)}readlink=async t=>{const e=this.resolve(t),i=this.symlinks.get(e);if(void 0===i)throw s.fileNotFound(t);return i};symlink=async(t,e)=>{const i=this.resolve(e);if(this.files.has(i)||this.symlinks.has(i)||this.directories.has(i))throw s.fileExists(e);this.ensureParentDirs(i),this.symlinks.set(i,t),this.touch(i)};chmod=async(t,s)=>{this.resolve(t)};rmRecursive=async t=>{const s=this.resolve(t);this.removeLeafEntry(s)||this.directories.has(s)&&this.removeSubtree(s)};removeLeafEntry(t){return this.files.has(t)?(this.files.delete(t),this.times.delete(t),!0):!!this.symlinks.has(t)&&(this.symlinks.delete(t),this.times.delete(t),!0)}removeSubtree(t){const s=`${t}/`,e=n(this.files.keys(),s),i=n(this.symlinks.keys(),s),r=function(t,s,e){const i=[];for(const r of t)(r===s||r.startsWith(e))&&i.push(r);return i}(this.directories,t,s);h(e,this.files,this.times),h(i,this.symlinks,this.times),function(t,s,e){for(const i of t)s.delete(i),e.delete(i)}(r,this.directories,this.times)}openWithNoFollow=async(t,e)=>{const i=this.resolve(t);if(this.symlinks.has(i))throw s.permissionDenied(t);if(!this.files.has(i))throw s.fileNotFound(t);return this.makeMemoryHandle(i)};makeMemoryHandle(t){return{read:async(s,e,i,r)=>{const o=this.files.get(t),n=r??0,h=Math.min(n+i,o.length),a=o.subarray(n,Math.max(n,h));return s.set(a,e),a.length},write:async s=>{this.files.set(t,s.slice()),this.touch(t)},stat:async()=>this.buildStat(t,t),close:async()=>{}}}resolve(t){const e=function(t,s){const e=(s.startsWith("/")?s:`${t}/${s}`).split("/"),i=[];for(const t of e)""!==t&&"."!==t&&(".."!==t?i.push(t):i.pop());return`/${i.join("/")}`}(this.rootDir,t);if(e!==this.rootDir&&!e.startsWith(`${this.rootDir}/`))throw s.permissionDenied(t);return e}ensureParentDirs(t){this.addDirectoryRecursive(o(t))}addDirectoryRecursive(t){let e=t;for(;e.length>=this.rootDir.length;){if(this.files.has(e)||this.symlinks.has(e))throw s.notADirectory(e);if(this.directories.add(e),e===this.rootDir)break;e=o(e)}}touch(t){const s=Date.now();this.times.set(t,{ctimeMs:s,mtimeMs:s})}buildStat(t,e){const i=this.files.get(t);if(void 0!==i)return this.makeStatRecord({size:i.byteLength,isFile:!0,isDirectory:!1,isSymbolicLink:!1,times:this.times.get(t)});if(this.directories.has(t))return this.makeStatRecord({size:0,isFile:!1,isDirectory:!0,isSymbolicLink:!1,times:this.times.get(t)});throw s.fileNotFound(e)}makeStatRecord(t){const s=t.times??{ctimeMs:0,mtimeMs:0};return{ctimeMs:s.ctimeMs,mtimeMs:s.mtimeMs,dev:0,ino:0,mode:33188,uid:0,gid:0,size:t.size,isFile:t.isFile,isDirectory:t.isDirectory,isSymbolicLink:t.isSymbolicLink}}hasChildren(t){const s=`${t}/`;for(const t of this.files.keys())if(t.startsWith(s))return!0;for(const t of this.symlinks.keys())if(t.startsWith(s))return!0;for(const e of this.directories)if(e!==t&&e.startsWith(s))return!0;return!1}addDirectEntry(t,s,e,i){if(!t.startsWith(s))return;const r=t.slice(s.length),o=r.indexOf("/"),n=-1===o?r:r.slice(0,o);e.has(n)||e.set(n,-1!==o?{name:n,isFile:!1,isDirectory:!0,isSymbolicLink:!1}:{name:n,isFile:"file"===i,isDirectory:"directory"===i,isSymbolicLink:"symlink"===i})}}function o(t){return t.slice(0,t.lastIndexOf("/"))}function n(t,s){const e=[];for(const i of t)i.startsWith(s)&&e.push(i);return e}function h(t,s,e){for(const i of t)s.delete(i),e.delete(i)}const a={sha1:"SHA-1",sha256:"SHA-256"},c={sha1:20,sha256:32};function l(t){let s="";for(const e of t)s+=e.toString(16).padStart(2,"0");return s}function d(t,s){return`${t}:${s}`}exports.MemoryCompressor=class{constructor(){if("undefined"==typeof CompressionStream||"undefined"==typeof DecompressionStream)throw s.compressFailed("CompressionStream/DecompressionStream unavailable")}deflate=async(t,r)=>{try{return await e(t,new CompressionStream("deflate"))}catch(t){throw s.compressFailed(i(t))}};deflateRaw=async(t,r)=>{try{return await e(t,new CompressionStream("deflate-raw"))}catch(t){throw s.compressFailed(i(t))}};inflate=async t=>{try{return await e(t,new DecompressionStream("deflate"))}catch(t){throw s.decompressFailed(i(t))}};streamInflate=async(s,e)=>t.inflateZlibMember(s,e);createInflateStream=()=>new DecompressionStream("deflate")},exports.MemoryFileSystem=r,exports.MemoryHashService=class{algorithm;digestLength;subtleAlgo;subtle;constructor(t="sha1"){const e=globalThis.crypto?.subtle;if(void 0===e)throw s.hashFailed("crypto.subtle unavailable");this.subtle=e,this.algorithm=t,this.digestLength=c[t],this.subtleAlgo=a[t]}hash=async t=>{const s=await this.subtle.digest(this.subtleAlgo,t);return new Uint8Array(s)};hashHex=async t=>l(await this.hash(t));createHasher=()=>{const t=[],e=this.subtle,i=this.subtleAlgo;let r=!1;const o=async()=>{if(r)throw s.hashFailed("cannot digest after digest");r=!0;const o=t.reduce((t,s)=>t+s.length,0),n=new Uint8Array(o);let h=0;for(const s of t)n.set(s,h),h+=s.length;const a=await e.digest(i,n);return new Uint8Array(a)};return{update:e=>{if(r)throw s.hashFailed("cannot update after digest");t.push(e.slice())},digest:o,digestHex:async()=>l(await o())}}},exports.MemoryHttpTransport=class{mocks=new Map;request=async t=>{const e=d(t.method,t.url),i=this.mocks.get(e);if(void 0===i)throw s.networkError(`no mock for ${t.url}`);const r=i.body.slice();return{statusCode:i.statusCode,headers:i.headers,body:new ReadableStream({start(t){t.enqueue(r),t.close()}})}};addMockResponse(t){const s={};for(const[e,i]of Object.entries(t.response.headers))s[e.toLowerCase()]=i;this.mocks.set(d(t.method,t.url),{statusCode:t.response.statusCode,headers:s,body:t.response.body.slice()})}clearMocks(){this.mocks.clear()}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("node:child_process"),e=require("node:zlib"),i=require("./error-CfLWDui_.cjs"),s=require("node:fs"),r=require("node:os"),n=require("node:path"),a=require("node:stream/promises"),o=require("./lru-cache-1OU7JhD8.cjs"),c=require("node:fs/promises"),h=require("node:crypto"),l=require("node:http"),d=require("node:https"),p=require("node:stream");function u(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}}),e.default=t,Object.freeze(e)}var m=u(s),w=u(r),f=u(n),y=u(c),g=u(l),v=u(d);const O={spawn:t.spawn},P=t=>{const e=t.reduce((t,e)=>t+e.length,0),i=new Uint8Array(e);let s=0;for(const e of t)i.set(e,s),s+=e.length;return i};function C(t){return t instanceof Error?t.message:String(t)}const k=y,N=t=>{if("\\"!==t&&"/"!==t)throw new Error(`PathPolicy: unsupported separator ${JSON.stringify(t)}`);return t},E=(t,e)=>({sep:N(t.sep),caseInsensitive:e,isAbsolute:e=>t.isAbsolute(e),resolve:(...e)=>t.resolve(...e),join:(...e)=>t.join(...e),dirname:e=>t.dirname(e),basename:e=>t.basename(e),rootOf:e=>t.parse(e).root,normalizeForCompare:t=>{return e?(i=t,i.startsWith("\\\\?\\UNC\\")?"\\\\"+i.slice(8):i.startsWith("\\\\?\\")?i.slice(4):i).toLowerCase():t;var i}}),R=E(f.posix,!1),b=E(f.win32,!0),D="win32"===process.platform?b:R;function x(t,e){return{normalized:t,withSep:t+e}}function F(t,e,i=D){return i.isAbsolute(t)?t:i.join(e,t)}function S(t){return t instanceof Error&&"code"in t}function I(t,e,i=D){const s=i.normalizeForCompare(e);return s===t||s.startsWith(t+i.sep)}function T(t,e,i){return t===e||t.startsWith(i)}function z(t,e){switch(t.code){case"ENOENT":return i.fileNotFound(e);case"EEXIST":return i.fileExists(e);case"ENOTDIR":return i.notADirectory(e);case"ENOTEMPTY":return i.directoryNotEmpty(e);case"EACCES":case"EPERM":case"ELOOP":case"EISDIR":return i.permissionDenied(e);default:return i.unsupportedOperation("filesystem",t.code??"UNKNOWN")}}async function L(t,e){try{return await t()}catch(t){if(S(t))throw z(t,e);throw t}}async function U(t,e=D,i=k){const s=e.rootOf(t),r=t.slice(s.length).split(e.sep).filter(Boolean);for(let t=r.length;t>0;t--){const n=s+r.slice(0,t).join(e.sep);try{const s=await i.realpath(n),a=r.slice(t).join(e.sep);return a.length>0?e.join(s,a):s}catch(t){if(S(t)&&"ENOENT"===t.code)continue;throw t}}const n=await i.realpath(s);return r.length>0?e.join(n,r.join(e.sep)):n}function j(t){const e={ctimeMs:Number(t.ctimeMs),mtimeMs:Number(t.mtimeMs),dev:Number(t.dev),ino:Number(t.ino),mode:Number(t.mode),uid:Number(t.uid),gid:Number(t.gid),size:Number(t.size),isFile:t.isFile(),isDirectory:t.isDirectory(),isSymbolicLink:t.isSymbolicLink()};return void 0!==t.ctimeNs&&void 0!==t.mtimeNs?{...e,ctimeNs:t.ctimeNs,mtimeNs:t.mtimeNs}:e}const A={sha1:20,sha256:32},W={stat:c.stat,spawn:t.spawn};class H{chunks=[];size=0;append(t){const e=t.subarray(0,Math.max(0,1048576-this.size));this.chunks.push(e),this.size+=e.length}value(){return Buffer.concat(this.chunks).toString("utf8")}}function q(t){const e={};for(const[i,s]of Object.entries(t))void 0!==s&&(e[i.toLowerCase()]=Array.isArray(s)?s.join(", "):s);return e}const M={spawn:t.spawn};exports.NodeCommandRunner=class{isWindows;ops;constructor(t=process.platform,e=O){this.isWindows="win32"===t,this.ops=e}run(t){return((t,e,i,s)=>new Promise(r=>{const n=t.spawn(e,[i,s.command],{cwd:s.cwd,env:{...process.env,...s.env},stdio:["pipe","pipe","inherit"]}),a=s.signal,o=()=>{n.kill()};a?.addEventListener("abort",o),!0===a?.aborted&&n.kill(),void 0!==s.stdin&&(n.stdin.write(s.stdin),n.stdin.end());const c=[];n.stdout.on("data",t=>{c.push(t)});const h=t=>{a?.removeEventListener("abort",o),r(c.length>0?{exitCode:t,stdout:P(c)}:{exitCode:t})};n.on("error",()=>{h(127)}),n.on("close",t=>{h(t??128)})}))(this.ops,this.isWindows?"cmd":"sh",this.isWindows?"/c":"-c",t)}},exports.NodeCompressor=class{maxInflatedBytes;constructor(t){this.maxInflatedBytes=t?.maxInflatedBytes??2147483648}deflate=async(t,s)=>{try{return new Uint8Array(void 0===s?e.deflateSync(t):e.deflateSync(t,{level:s}))}catch(t){throw i.compressFailed(C(t))}};deflateRaw=async(t,s)=>{try{return new Uint8Array(void 0===s?e.deflateRawSync(t):e.deflateRawSync(t,{level:s}))}catch(t){throw i.compressFailed(C(t))}};inflate=async t=>{try{return new Uint8Array(e.inflateSync(t,{maxOutputLength:this.maxInflatedBytes}))}catch(t){throw i.decompressFailed(C(t))}};streamInflate=async(t,s)=>{const r=this.maxInflatedBytes;return new Promise((n,a)=>{const o=e.createInflate(),c=[];let h=0;const l=t.subarray(s);o.on("data",t=>{if(h+=t.length,h>r)return o.destroy(),void a(i.decompressFailed("inflated output exceeds safety cap"));c.push(new Uint8Array(t))}),o.on("end",()=>{const t=o.bytesWritten,e=function(t){const e=t.reduce((t,e)=>t+e.length,0),i=new Uint8Array(e);let s=0;for(const e of t)i.set(e,s),s+=e.length;return i}(c);n({output:e,bytesConsumed:t})}),o.on("error",t=>{a(i.decompressFailed(t.message))}),o.end(l)})};createInflateStream=()=>{const t=this.maxInflatedBytes,s=e.createInflate();let r,n,a=0;return new TransformStream({start(e){r=e,s.on("data",e=>{if(a+=e.length,a>t)return r?.error(i.decompressFailed("inflated output exceeds safety cap")),void s.destroy();r?.enqueue(new Uint8Array(e))}),n=new Promise((t,e)=>{s.on("end",()=>{r?.terminate(),t()}),s.on("error",t=>{const s=i.decompressFailed(t.message);r?.error(s),e(s)})})},transform(t){s.write(t)},flush:()=>(s.end(),n)})}},exports.NodeEnvReader=class{get(t){return process.env[t]}},exports.NodeFileSystem=class{rootDir;pathPolicy;fsOps;parentRealpathCache=o.createLruCache(131072,512);canonicalRootPromise=void 0;resolvedCanonicalRootPrefix=void 0;normalizedRootDirPrefix=void 0;constructor(t,e=D,i=k){this.rootDir=t,this.pathPolicy=e,this.fsOps=i}getRootDirPrefix(){return void 0===this.normalizedRootDirPrefix&&(this.normalizedRootDirPrefix=x(this.pathPolicy.normalizeForCompare(this.rootDir),this.pathPolicy.sep)),this.normalizedRootDirPrefix}getNormalizedRootDir(){return this.getRootDirPrefix().normalized}async getCanonicalRoot(){return void 0===this.canonicalRootPromise&&(this.canonicalRootPromise=this.fsOps.realpath(this.rootDir).then(t=>{const e=x(this.pathPolicy.normalizeForCompare(t),this.pathPolicy.sep);return this.resolvedCanonicalRootPrefix=e,e}).catch(t=>{throw this.canonicalRootPromise=void 0,this.resolvedCanonicalRootPrefix=void 0,t})),this.canonicalRootPromise}async resolveCanonicalRoot(){let t=this.resolvedCanonicalRootPrefix;return void 0===t&&(t=await this.getCanonicalRoot()),t}read=async t=>{const e=await this.checkContainment(t,"read");return L(async()=>new Uint8Array(await this.fsOps.readFile(e)),t)};readSlice=async(t,e,s)=>{if(e<0||s<0)throw i.permissionDenied(t);const r=await this.checkContainment(t,"read");let n;try{return await L(async()=>{n=await this.fsOps.open(r,"r");const t=Buffer.alloc(s),{bytesRead:i}=await n.read(t,0,s,e);return Uint8Array.from(t.subarray(0,i))},t)}finally{await(n?.close())}};readUtf8=async t=>{const e=await this.checkContainment(t,"read");return L(()=>this.fsOps.readFile(e,"utf-8"),t)};write=async(t,e)=>{const i=await this.checkContainment(t,"creation");await L(async()=>{await this.fsOps.mkdir(this.pathPolicy.dirname(i),{recursive:!0}),await this.fsOps.writeFile(i,e)},t)};writeStream=async(t,e)=>{const i=await this.checkContainment(t,"creation");await L(async()=>{await this.fsOps.mkdir(this.pathPolicy.dirname(i),{recursive:!0}),await a.pipeline(e,m.createWriteStream(i))},t)};writeExclusive=async(t,e)=>{const i=await this.checkContainment(t,"creation");await L(async()=>{await this.fsOps.mkdir(this.pathPolicy.dirname(i),{recursive:!0}),await this.fsOps.writeFile(i,e,{flag:"wx"})},t)};writeUtf8=async(t,e)=>{const i=await this.checkContainment(t,"creation");await L(async()=>{await this.fsOps.mkdir(this.pathPolicy.dirname(i),{recursive:!0}),await this.fsOps.writeFile(i,e,"utf-8")},t)};appendUtf8=async(t,e)=>{const i=await this.checkContainment(t,"creation");await L(async()=>{await this.fsOps.mkdir(this.pathPolicy.dirname(i),{recursive:!0}),await this.fsOps.appendFile(i,e,"utf-8")},t)};exists=async t=>{const e=this.pathPolicy.resolve(F(t,this.rootDir,this.pathPolicy)),s=this.getNormalizedRootDir(),r=(await this.resolveCanonicalRoot()).normalized;try{if(!I(r,await this.fsOps.realpath(e),this.pathPolicy))throw i.permissionDenied(t);return!0}catch(n){if(n instanceof i.TsgitError)throw n;if(S(n)&&"ENOENT"===n.code){if(!I(s,e,this.pathPolicy)&&!I(r,e,this.pathPolicy))throw i.permissionDenied(t);return!1}if(S(n))throw z(n,t);throw n}};stat=async t=>{const e=await this.checkContainment(t,"read");return L(async()=>j(await this.fsOps.stat(e,{bigint:!0})),t)};lstat=async t=>{const e=await this.checkContainment(t,"lstat");return L(async()=>j(await this.fsOps.lstat(e,{bigint:!0})),t)};readdir=async t=>{const e=await this.checkContainment(t,"read");return L(async()=>(await this.fsOps.readdir(e,{withFileTypes:!0})).map(t=>({name:t.name,isFile:t.isFile(),isDirectory:t.isDirectory(),isSymbolicLink:t.isSymbolicLink()})),t)};mkdir=async t=>{const e=await this.checkContainment(t,"creation");await L(()=>this.fsOps.mkdir(e,{recursive:!0}),t)};rm=async t=>{const e=await this.checkContainment(t,"lstat");await L(()=>this.fsOps.rm(e),t)};rename=async(t,e)=>{const i=await this.checkContainment(t,"read"),s=await this.checkContainment(e,"creation");await L(async()=>{await this.fsOps.mkdir(this.pathPolicy.dirname(s),{recursive:!0}),await this.fsOps.rename(i,s)},t),this.parentRealpathCache.clear()};readlink=async t=>{const e=await this.checkContainment(t,"lstat");return L(()=>this.fsOps.readlink(e),t)};symlink=async(t,e)=>{if(this.pathPolicy.isAbsolute(t)){const s=this.pathPolicy.resolve(t),r=await U(s,this.pathPolicy,this.fsOps),n=this.getNormalizedRootDir(),a=(await this.resolveCanonicalRoot()).normalized;if(!I(n,r,this.pathPolicy)&&!I(a,r,this.pathPolicy))throw i.permissionDenied(e)}const s=await this.checkContainment(e,"creation");await L(async()=>{await this.fsOps.mkdir(this.pathPolicy.dirname(s),{recursive:!0}),await this.fsOps.symlink(t,s)},e)};chmod=async(t,e)=>{const i=await this.checkContainment(t,"read");await L(()=>this.fsOps.chmod(i,e),t)};rmRecursive=async t=>{let e;try{e=await this.checkContainment(t,"lstat"),await L(()=>this.fsOps.lstat(e),t)}catch(t){if(t instanceof i.TsgitError&&"FILE_NOT_FOUND"===t.data.code)return;throw t}await this.removeTree(e,t),this.parentRealpathCache.clear()};openWithNoFollow=async(t,e)=>{const s=await this.checkContainment(t,"lstat");if(this.pathPolicy.caseInsensitive&&await this.isSymlinkLeaf(s))throw i.permissionDenied(t);const r="write"===e?m.constants.O_WRONLY:m.constants.O_RDONLY;return function(t){let e=!1;return{read:async(e,i,s,r)=>{const{bytesRead:n}=await t.read(e,i,s,r??null);return n},write:async e=>{await t.write(e,0,e.length)},stat:async()=>j(await t.stat({bigint:!0})),close:async()=>{e||(e=!0,await t.close())}}}(await L(()=>this.fsOps.open(s,r|m.constants.O_NOFOLLOW),t).catch(e=>{if(function(t,e=D){return!!e.caseInsensitive&&t instanceof i.TsgitError&&("PERMISSION_DENIED"===t.data.code||"UNSUPPORTED_OPERATION"===t.data.code)}(e,this.pathPolicy))throw i.permissionDenied(t);throw e}))};async isSymlinkLeaf(t){try{return(await this.fsOps.lstat(t)).isSymbolicLink()}catch(t){if(S(t)&&"ENOENT"===t.code)return!1;throw t}}async removeTree(t,e){const i=await L(()=>this.fsOps.lstat(t),e);if(!i.isDirectory()||i.isSymbolicLink())return void await L(()=>this.fsOps.rm(t,{force:!0}),e);const s=await L(()=>this.fsOps.readdir(t,{withFileTypes:!0}),e);await async function(t,e,i){if(0===t.length)return;let s=0;const r=Math.min(8,t.length),n=Array.from({length:r},async()=>{for(;;){const e=s;if(s+=1,e>=t.length)return;const r=t[e];if(void 0===r)return;await i(r)}});await Promise.all(n)}(s,0,i=>this.removeTree(this.pathPolicy.join(t,i.name),e)),await L(()=>this.fsOps.rmdir(t),e)}async resolveForCreation(t,e,s,r){const n=await this.realpathForCreation(e,s,r);let a;try{a={ok:!0,isSymlink:(await this.fsOps.lstat(n)).isSymbolicLink()}}catch(t){a={ok:!1,err:t}}return function(t,e){if(t.ok){if(t.isSymlink)throw i.permissionDenied(e);return}const{err:s}=t;if(S(s)){if("ENOENT"===s.code)return;throw z(s,e)}throw s}(a,t),n}async cachedParentRealpath(t,e,i){const s=this.parentRealpathCache.get(t);if(void 0!==s)return s;const r=await this.fsOps.realpath(t),n={realParent:r,contained:this.isContainedInEitherRoot(r,e,i)};return this.parentRealpathCache.set(t,n,t.length+r.length),n}async realpathForCreation(t,e,i){const s=this.pathPolicy.dirname(t),r=this.pathPolicy.basename(t);try{const{realParent:t}=await this.cachedParentRealpath(s,e,i);return this.pathPolicy.join(t,r)}catch(e){if(S(e)&&"ENOENT"===e.code)return U(t,this.pathPolicy,this.fsOps);throw e}}async resolveForMode(t,e,s,r,n){if("read"===s){if(!this.isContainedInEitherRoot(e,r,n))throw i.permissionDenied(t);return{real:await this.fsOps.realpath(e),contained:void 0}}if("lstat"===s){const s=this.containmentVerdict(e,r,n);if(!s.contained)throw i.permissionDenied(t);const a=this.pathPolicy.dirname(e),o=this.pathPolicy.basename(e),{realParent:c,contained:h}=await this.cachedParentRealpath(a,r,n);return{real:this.pathPolicy.join(c,o),contained:s.isExactRoot?void 0:h}}return{real:await this.resolveForCreation(t,e,r,n),contained:void 0}}isContainedInEitherRoot(t,e,i){return this.containmentVerdict(t,e,i).contained}containmentVerdict(t,e,i){const s=this.pathPolicy.normalizeForCompare(t),r=s===e.normalized||s===i.normalized;return{contained:r||T(s,e.normalized,e.withSep)||T(s,i.normalized,i.withSep),isExactRoot:r}}async checkContainment(t,e){const s=this.pathPolicy.resolve(F(t,this.rootDir,this.pathPolicy)),r=this.getRootDirPrefix(),n=await this.resolveCanonicalRoot();try{const{real:a,contained:o}=await this.resolveForMode(t,s,e,r,n);if(!(o??this.isContainedInEitherRoot(a,r,n)))throw i.permissionDenied(t);return a}catch(e){if(e instanceof i.TsgitError)throw e;if(S(e)&&"ENOENT"===e.code)throw i.fileNotFound(t);if(S(e))throw z(e,t);throw e}}homedir(){return w.homedir()}xdgConfigHome(){const t=process.env.XDG_CONFIG_HOME;return void 0!==t&&t.length>0?t:f.join(w.homedir(),".config")}systemConfigPath(){return"win32"===process.platform?`${process.env.ProgramData??"C:\\ProgramData"}\\Git\\config`:"/etc/gitconfig"}},exports.NodeHashService=class{algorithm;digestLength;constructor(t="sha1"){this.algorithm=t,this.digestLength=A[t]}hash=async t=>new Uint8Array(h.createHash(this.algorithm).update(t).digest());hashHex=async t=>h.createHash(this.algorithm).update(t).digest("hex");createHasher=()=>{const t=h.createHash(this.algorithm);let e=!1;return{update:s=>{if(e)throw i.hashFailed("cannot update after digest");t.update(s)},digest:async()=>{if(e)throw i.hashFailed("cannot digest after digest");return e=!0,new Uint8Array(t.digest())},digestHex:async()=>{if(e)throw i.hashFailed("cannot digest after digest");return e=!0,t.digest("hex")}}}},exports.NodeHookRunner=class{isWindows;ops;constructor(t=process.platform,e=W){this.isWindows="win32"===t,this.ops=e}async run(t){const e=f.join(t.hooksDir,t.name);return await this.isRunnable(e)?((t,e,i)=>new Promise(s=>{const r=t(e,i.args,{cwd:i.workDir,env:{...process.env,GIT_DIR:i.gitDir,GIT_INDEX_FILE:`${i.gitDir}/index`}}),n=new H,a=new H;r.stdout.on("data",t=>{n.append(t)}),r.stderr.on("data",t=>{a.append(t)});const o=i.signal,c=()=>{r.kill()};o?.addEventListener("abort",c),!0===o?.aborted&&r.kill();const h=t=>{o?.removeEventListener("abort",c),s(t)};r.on("error",t=>{h({kind:"ran",exitCode:126,stdout:"",stderr:String(t)})}),r.on("close",t=>{h({kind:"ran",exitCode:t??128,stdout:n.value(),stderr:a.value()})}),r.stdin.on("error",()=>{}),r.stdin.end(i.stdin)}))(this.ops.spawn,e,t):{kind:"skipped"}}async isRunnable(t){let e,i;try{const s=await this.ops.stat(t);e=s.mode,i=s.isFile()}catch{return!1}return!!i&&(this.isWindows||!!(73&e))}},exports.NodeHttpTransport=class{allowInsecureHttp;constructor(t={}){this.allowInsecureHttp=t.allowInsecureHttp??!1}request=async t=>{const e=new URL(t.url);if("http:"===e.protocol&&!this.allowInsecureHttp)throw i.networkError("HTTPS required — set allowInsecureHttp to allow plaintext HTTP");const s="https:"===e.protocol?v:g;return new Promise((r,n)=>{const a={method:t.method,headers:{...t.headers}};void 0!==t.signal&&(a.signal=t.signal);const o=s.request(e,a,t=>{r({statusCode:t.statusCode,headers:q(t.headers),body:p.Readable.toWeb(t)})});o.on("error",t=>{n(i.networkError(function(t){switch(t.code){case"ENOTFOUND":return"DNS resolution failed";case"ECONNREFUSED":return"Connection refused";case"ETIMEDOUT":return"Connection timed out";default:return"network error"}}(t)))}),void 0!==t.body&&o.write(Buffer.from(t.body)),o.end()})}},exports.NodeSshTransport=class{ops;constructor(t=M){this.ops=t}open=async t=>{const e=this.ops.spawn(t.command,t.args,(t=>({env:{...process.env,...t.env},stdio:["pipe","pipe","inherit"],...void 0!==t.signal?{signal:t.signal}:{}}))(t)),i=(t=>new Promise(e=>{t.on("error",()=>e(127)),t.on("close",t=>e(t??128))}))(e);return{stdin:p.Writable.toWeb(e.stdin),stdout:p.Readable.toWeb(e.stdout),exit:i,close:async()=>{e.kill(),await i}}}},exports.nativePolicy=D,exports.realCommandRunnerOps=O;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./error-
|
|
2
|
-
//# sourceMappingURL=progress-CxU62NC1.cjs.map
|
|
1
|
+
"use strict";var e=require("./error-CfLWDui_.cjs");const r=Object.freeze({start:()=>{},update:()=>{},end:()=>{}}),t=/\x1b\[[0-9;]*m/g,o=/[<>&"']/g,s=r=>{let s=r.replace(t,"");return s=e.sanitize(s),s=s.replace(o,e=>`&#${e.charCodeAt(0)};`),s};exports.consoleProgress=e=>{const r=r=>{try{e(r)}catch{}};return{start:(e,t)=>r(((e,r)=>`${s(e)}: start${void 0!==r?`/${r}`:""}`)(e,t)),update:(e,t,o,c)=>r(((e,r,t,o)=>{const c=`${s(e)}: ${r}${void 0!==t?`/${t}`:""}`;return void 0!==o&&""!==o?`${c} ${s(o)}`:c})(e,t,o,c)),end:e=>r((e=>`${s(e)}: done`)(e))}},exports.noopProgress=r;
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
"use strict";exports.readableStreamToAsyncIterable=e=>({[Symbol.asyncIterator](){const a=e.getReader();return{next:async()=>{const{done:e,value:t}=await a.read();return e?{done:!0,value:void 0}:{done:!1,value:t}},return:async()=>{try{await a.cancel()}catch{}return{done:!0,value:void 0}}}}});
|
|
2
|
-
//# sourceMappingURL=readable-stream-MTA6D0Zh.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./write-sparse-checkout-C1dsHCAD.cjs"),t=require("./error-CfLWDui_.cjs"),r=require("./index-Cy44GVR6.cjs"),s=require("./adapter-detect-DW9fsw9d.cjs"),a=require("./progress-D8Dqbftk.cjs"),i=require("../primitives/index.cjs");const o=(r,s,a,i)=>{let o=null;a.subscribe(()=>{});return{resolve:async(a,n)=>{const c=i.current("index"),d=!0===n?.bypassCache;if(!d&&null!==o&&o.cachedGen===c)return o.parsed;const l=e.indexPath(a.layout.gitDir),m=await(async e=>{try{return await s.stat(e)}catch(e){if(e instanceof t.TsgitError&&"FILE_NOT_FOUND"===e.data.code)return null;throw e}})(l);if(!d&&null!==o&&null!==m&&await(async(e,t,r)=>{return(a=r).size===(i=e.observed).size&&a.ino===i.ino&&a.mtimeMs===i.mtimeMs&&(void 0===a.mtimeNs||void 0===i.mtimeNs||a.mtimeNs===i.mtimeNs)&&(!((e,t)=>void 0===e.mtimeNs||void 0===t.mtimeNs)(r,e.observed)||(async(e,t,r)=>{const a=e.parsed.trailerSha.length;if(0===a||r.size<a)return!1;const i=await(async(e,t,r,s)=>e.readSlice(t,s-r,r))(s,t,a,r.size);return((e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]!==t[r])return!1;return!0})(i,e.parsed.trailerSha)})(e,t,r));var a,i})(o,l,m))return o.cachedGen=c,o.parsed;const h=await r.resolve(a,n);return o=null!==m?{parsed:h,observed:m,cachedGen:c}:null,h}}},n=e=>e.isSymbolicLink?"120000":73&e.mode?"100755":"100644",c=(e,t)=>{const r=(e=>({mode:n(e),size:e.size,mtimeMs:e.mtimeMs,...void 0===e.mtimeNs?{}:{mtimeNs:e.mtimeNs},ino:BigInt(e.ino)}))(t);return{source:"workdir",path:e,mode:r.mode,kind:t.isSymbolicLink?"symlink":"file",stat:r}},d=(t,r)=>((t,r)=>({...r,read:async()=>(await e.readBlob(t,r.oid)).content}))(t,{source:"index",path:r.path,oid:r.id,mode:r.mode,stage:r.flags.stage,flags:{assumeUnchanged:r.flags.assumeValid,skipWorktree:r.flags.skipWorktree,intentToAdd:r.flags.intentToAdd},cachedStat:{size:r.fileSize,mtimeMs:1e3*r.mtimeSeconds+Math.floor(r.mtimeNanoseconds/1e6),ino:BigInt(r.ino)}}),l=e=>"120000"===e?"symlink":"160000"===e?"submodule":"file",m=(t,r,s,a)=>((t,r)=>({...r,read:async()=>(await e.readBlob(t,r.oid)).content}))(t,{source:"tree",path:r,oid:s,mode:a,kind:l(a)}),h=new TextEncoder,u=e=>e.isSymbolicLink?"120000":73&e.mode?"100755":"100644",f=(r,s)=>{const a=e.joinPath(r.layout.workDir,s.path),i=async()=>"symlink"===s.kind?(async(e,t)=>{const r=await e.fs.readlink(t);return h.encode(r)})(r,a):r.fs.read(a);return{...s,hash:async()=>(async(t,r)=>{const s=h.encode(`blob ${r.length}\0`),a=new Uint8Array(s.length+r.length);a.set(s,0),a.set(r,s.length);const i=await t.hash.hashHex(a);return e.ObjectId.from(i)})(r,await i()),read:i,readLink:async()=>{if("symlink"!==s.kind)throw t.unsupportedOperation("readLink",`entry is not a symlink (kind=${s.kind})`);return r.fs.readlink(a)},verify:async()=>{const e=await(async(e,t)=>{const r=await e.fs.lstat(t);return{mode:u(r),size:r.size,mtimeMs:r.mtimeMs,...void 0===r.mtimeNs?{}:{mtimeNs:r.mtimeNs},ino:BigInt(r.ino)}})(r,a);if(!((e,t)=>e.mode===t.mode&&e.size===t.size&&e.mtimeMs===t.mtimeMs)(s.stat,e))throw t.workdirRace(s.path,s.stat,e)}}},p=(t,s)=>((t,s)=>{let a=null;return{kind:"tree",entries:async function*(i){const o=await(async e=>{if(null!==a&&!e)return a;const r=await t.treeResolver.resolve(t.ctx,s,{bypassCache:e});return a=r,r})(!0===i?.bypassCache),n={recursive:!1!==i?.recurse,...void 0===i?.maxDepth?{}:{maxDepth:i.maxDepth},...void 0===i?.maxEntries?{}:{maxEntries:i.maxEntries}};for await(const s of e.walkTree(t.ctx,o,n))e.isDirectory(s.mode)||(void 0===i?.paths||r.matchesPathspec(i.paths,s.path))&&(yield m(t.ctx,s.path,s.id,s.mode))}}})({ctx:t.ctx,treeResolver:t.treeResolver},s),w=async(t,r)=>{const s=await e.readObject(t,r);if("commit"!==s.type)throw e.unexpectedObjectType("commit",s.type,r);return s.data.tree},v=async(t,r)=>{const s=await e.resolveRef(t.ctx,r,{peel:!0}),a=await w(t.ctx,s);return p(t,a)},g=new Set(["FILE_NOT_FOUND","REF_NOT_FOUND"]),y=(e,r)=>async()=>(async(e,r)=>{const s=`${e.ctx.layout.gitDir}/${r}`;if(!await e.ctx.fs.exists(s))return null;try{return await v(e,r)}catch(e){if(e instanceof t.TsgitError&&g.has(e.data.code))return null;throw e}})(e,r),b=t=>({head:()=>({kind:"commit",entries:async function*(e){const r=await v(t,"HEAD");yield*r.entries(e)}}),commit:e=>({kind:"commit",entries:async function*(r){const s=await w(t.ctx,e);yield*p(t,s).entries(r)}}),tree:e=>p(t,e),index:()=>(e=>{let t=null;return{kind:"index",entries:async function*(s){const a=await(async r=>{if(null!==t)return t;const s=await e.indexResolver.resolve(e.ctx,{bypassCache:r});return t=s,s})(!0===s?.bypassCache);let i=0;const o=s?.maxEntries??Number.POSITIVE_INFINITY;for(const t of a.entries){if(i>=o)return;(void 0===s?.paths||r.matchesPathspec(s.paths,t.path))&&(yield d(e.ctx,t),i+=1)}}}})({ctx:t.ctx,indexResolver:t.indexResolver}),workdir:e=>((e,t)=>({kind:"workdir",entries:async function*(r){const s=((e,t)=>{const r=t?.paths??e?.paths,s=t?.maxDepth??e?.maxDepth,a=t?.maxEntries??e?.maxEntries,i=t?.signal??e?.signal,o=e?.excludes;return{...void 0===r?{}:{paths:r},...void 0===o?{}:{excludes:o},...void 0===s?{}:{maxDepth:s},...void 0===a?{}:{maxEntries:a},...void 0===i?{}:{signal:i}}})(t,r),a=e.enumerator.enumerate(e.ctx,s);if("verified"===t?.consistency){const t=[];for await(const e of a)t.push(e);for(const r of t)yield f(e.ctx,r);return}for await(const t of a)yield f(e.ctx,t)}}))({ctx:t.ctx,enumerator:t.workdirEnumerator},e),mergeHead:y(t,e.MERGE_HEAD),cherryPickHead:y(t,e.CHERRY_PICK_HEAD),revertHead:y(t,e.REVERT_HEAD),fetchHead:y(t,e.FETCH_HEAD),stashEntry:e=>x(t,e)}),k=async(t,r)=>{const s=await e.readObject(t,r);if("commit"!==s.type)throw e.unexpectedObjectType("commit",s.type,r);return s.data.tree},x=async(t,r)=>{const s=await e.readReflog(t.ctx,"refs/stash"),a=s[s.length-1-r];if(void 0===a)return null;const i=await e.readObject(t.ctx,a.newId);if("commit"!==i.type)throw e.unexpectedObjectType("commit",i.type,a.newId);const[,o,n]=i.data.parents;if(void 0===o)return null;const c=await k(t.ctx,o),d=void 0!==n?p(t,await k(t.ctx,n)):null;return l={index:p(t,c),workdir:p(t,i.data.tree),untracked:d},{kind:"stash",...l};var l},N=["fs","transport","compressor","hash"],R=e=>{if(null!==e&&"object"==typeof e&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.keys(e))R(e[t])}},O=/^[A-Za-z]:[/\\]/,D=(e,r,s=[])=>{const a="string"==typeof r?[r]:r,i=new Set(s.filter(e=>e.length>0&&!e.split(/[\\/]/).includes(".."))),o=e=>{if(!a.some(t=>S(e,t))&&!i.has(e))throw t.pathspecOutsideRepo(e)};return{read:t=>(o(t),e.read(t)),readSlice:(t,r,s)=>(o(t),e.readSlice(t,r,s)),readUtf8:t=>(o(t),e.readUtf8(t)),write:(t,r)=>(o(t),e.write(t,r)),writeStream:(t,r)=>(o(t),e.writeStream(t,r)),writeExclusive:(t,r)=>(o(t),e.writeExclusive(t,r)),writeUtf8:(t,r)=>(o(t),e.writeUtf8(t,r)),appendUtf8:(t,r)=>(o(t),e.appendUtf8(t,r)),exists:t=>(o(t),e.exists(t)),stat:t=>(o(t),e.stat(t)),lstat:t=>(o(t),e.lstat(t)),readdir:t=>(o(t),e.readdir(t)),mkdir:t=>(o(t),e.mkdir(t)),rm:t=>(o(t),e.rm(t)),rename:(t,r)=>(o(t),o(r),e.rename(t,r)),readlink:t=>(o(t),e.readlink(t)),symlink:(t,r)=>(o(r),e.symlink(t,r)),chmod:(t,r)=>(o(t),e.chmod(t,r)),rmRecursive:t=>(o(t),e.rmRecursive(t)),openWithNoFollow:(t,r)=>(o(t),e.openWithNoFollow(t,r)),homedir:()=>e.homedir(),xdgConfigHome:()=>e.xdgConfigHome(),systemConfigPath:()=>e.systemConfigPath()}},E=e=>e.replace(/\\/g,"/"),S=(e,t)=>{const r=E(e),s=E(t);if(r===s)return!0;const a=s.endsWith("/")?s:`${s}/`;return r.startsWith(a)},C=(e,r)=>{for(const t of e)if(r||!I(t))return t;if(0===e.length)throw t.blockedHost("<unresolved>","no DNS records returned");throw t.blockedHost(e[0],"all resolved addresses are in a blocked range")},I=e=>e.includes(":")?j(e):T(e),T=e=>{const t=(e=>{const t=e.split(".");if(4!==t.length)return;const r=[];for(const e of t){if(!/^\d{1,3}$/.test(e))return;const t=Number(e);if(t>255)return;r.push(t)}return r})(e);if(void 0===t)return!1;const[r,s]=t;return 0===r||10===r||100===r&&s>=64&&s<=127||127===r||169===r&&254===s||172===r&&s>=16&&s<=31||192===r&&168===s||r>=224},j=e=>{const t=e.toLowerCase(),r=t.match(/::ffff:(?:0:)?(\d+\.\d+\.\d+\.\d+)$/);if(void 0!==r?.[1])return T(r[1]);const s=t.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);if(void 0!==s?.[1]&&void 0!==s[2]){const e=parseInt(s[1],16),t=parseInt(s[2],16);return T(`${e>>8}.${255&e}.${t>>8}.${255&t}`)}return!!("::1"===t||"::"===t||t.startsWith("fe80:")||t.startsWith("fe80::")||t.startsWith("ff")||t.startsWith("fc")||t.startsWith("fd"))},P=(e,r)=>{const s=r?.allowInsecure??!1,a=r?.allowPrivateNetworks??!1,i=r?.dnsResolver??z;return{request:async r=>(await(async(e,r)=>{(e=>{for(let r=0;r<e.length;r+=1){const s=e.charCodeAt(r);if(10===s||13===s)throw t.invalidUrl("contains forbidden control character")}})(e);const s=(e=>{try{return new URL(e)}catch{throw t.invalidUrl("not a valid URL")}})(e);((e,r)=>{const s=e.protocol;if("https:"!==s&&("http:"!==s||!r))throw t.unsupportedScheme(s.replace(":",""))})(s,r.allowInsecure??!1),(e=>{if(""!==e.hash)throw t.invalidUrl("URL fragment is not allowed")})(s);const a=await r.resolver(s.hostname);return{url:e,pinnedAddress:C(a,r.allowPrivateNetworks??!1)}})(r.url,{resolver:i,allowInsecure:s,allowPrivateNetworks:a}),e.request(r))}},z=async()=>[],B=e=>{const t=[],r=e=>{try{return e()}catch{return}},s=r(()=>e.homedir()),a=r(()=>e.xdgConfigHome()),i=r(()=>e.systemConfigPath());return void 0!==s&&t.push(`${s}/.gitconfig`),void 0!==a&&t.push(`${a}/git/config`),void 0!==i&&i.length>0&&t.push(i),t},U=s=>{const a=(()=>{const e={index:0,refs:0,objects:0};return{current:t=>e[t],bump:t=>{e[t]+=1}}})(),i=(e=>{const t=new Set;return{emitter:{emit:r=>{e.bump(r);for(const e of t)e(r)}},stream:{subscribe:e=>(t.add(e),{dispose:()=>{t.delete(e)}})}}})(a),n=(e=>{let t=null;return{resolve:(r,s)=>!0===s?.bypassCache?e.resolve(r,s):t??((r,s)=>{const a=e.resolve(r,s).finally(()=>{t=null});return t=a,a})(r,s)}})(o({resolve:t=>e.readIndex(t)},s.fs,i.stream,a)),d=((e,t={})=>{const r=t.maxSize??256,s=new Map,a=async(t,a,i)=>{const o=await e.resolve(t,a,i);if(s.set(a,o),s.size>r){const e=s.keys().next().value;void 0!==e&&s.delete(e)}return o};return{resolve:async(e,t,r)=>{if(!0===r?.bypassCache)return a(e,t,r);const i=s.get(t);return void 0!==i?(s.delete(t),s.set(t,i),i):a(e,t,r)}}})({resolve:async(t,r)=>{const s=await e.readObject(t,r);if("tree"!==s.type)throw e.unexpectedObjectType("tree",s.type,r);return s}}),l={enumerate:(s,a)=>async function*(s,a){const i=()=>!0===a.signal?.aborted||!0===s.signal?.aborted;if(i())throw t.operationAborted();const o=a.excludes,n=e.walkWorkingTree(s,{...void 0===a.maxDepth?{}:{maxDepth:a.maxDepth},...void 0===a.maxEntries?{}:{maxEntries:a.maxEntries},...void 0===o?{}:{ignore:o}});for await(const{path:e,stat:s}of n){if(i())throw t.operationAborted();(void 0===a.paths||r.matchesPathspec(a.paths,e))&&(yield c(e,s))}}(s,a)};return b({ctx:s,indexResolver:n,treeResolver:d,workdirEnumerator:l})};exports.openRepository=async(o,n)=>{(e=>{if(void 0!==e.cwd&&!(e=>e.startsWith("/")||e.startsWith("\\\\")||O.test(e))(e.cwd))throw t.invalidOption("cwd","must be an absolute path");const r=e.config;void 0!==r&&((e=>{if(void 0!==e){if(!Number.isInteger(e))throw t.invalidOption("parallelism","must be an integer");if(e<1||e>32)throw t.invalidOption("parallelism",`must be in 1..32 (got ${e})`)}})(r.parallelism),(e=>{if(void 0!==e&&e<1024)throw t.invalidOption("maxResponseBytes",`must be >= 1024 (got ${e})`)})(r.maxResponseBytes),(e=>{if(void 0!==e&&e<0)throw t.invalidOption("breakStaleLockMs",`must be >= 0 (got ${e})`)})(r.breakStaleLockMs),(e=>{if(void 0!==e&&e<1)throw t.invalidOption("maxObjectsPerPack",`must be >= 1 (got ${e})`)})(r.maxObjectsPerPack),(e=>{if(void 0!==e&&e<1)throw t.invalidOption("maxDnsResults",`must be >= 1 (got ${e})`)})(r.maxDnsResults),(e=>{if(void 0!==e&&"function"!=typeof e)throw t.invalidOption("dnsResolver","must be a function")})(r.dnsResolver))})(o);const c=o.cwd??(s.isNode()?globalThis.process.cwd():"/"),d=((e,r)=>{const s={fs:e.fs??r.fs,hash:e.hash??r.hash,compressor:e.compressor??r.compressor,transport:e.transport??r.transport};if(void 0===s.fs)throw t.adapterUnavailable(r.runtime,"fs adapter missing");if(void 0===s.hash)throw t.adapterUnavailable(r.runtime,"hash adapter missing");if(void 0===s.compressor)throw t.adapterUnavailable(r.runtime,"compressor adapter missing");if(void 0===s.transport)throw t.adapterUnavailable(r.runtime,"transport adapter missing");return s})(o,n),l=!0===o.unsafeRawAdapters?d:{...d,fs:D(d.fs,n.layout.workDir,B(d.fs)),transport:P(d.transport,o.config)},m=n.layout.gitDir,h=void 0!==o.config?(u={...o.config},R(u),u):void 0;var u;const f=new AbortController,p=void 0!==o.signal?AbortSignal.any([f.signal,o.signal]):f.signal,w={fs:l.fs,hash:l.hash,compressor:l.compressor,transport:l.transport,progress:o.progress??a.noopProgress,layout:n.layout,cwd:c,runtime:n.runtime,hashConfig:n.hashConfig,deltaCache:n.deltaCache,signal:p,worktreeFs:e=>{const t=[..."string"==typeof e?[e]:e,m],r=n.makeWorktreeFs?.(t)??d.fs;return!0===o.unsafeRawAdapters?r:D(r,t,B(r))}},v=void 0!==o.logger?s.wrapLoggerSanitizer(o.logger):void 0;let g;const y=Object.freeze({...w,...(b={config:h,logger:v,hooks:!1===o.hooks?void 0:o.hooks??n.hooks,command:!1===o.command?void 0:o.command??n.command,env:n.env,ssh:n.ssh},{...void 0!==b.config?{config:b.config}:{},...void 0!==b.logger?{logger:b.logger}:{},...void 0!==b.hooks?{hooks:b.hooks}:{},...void 0!==b.command?{command:b.command}:{},...void 0!==b.env?{env:b.env}:{},...void 0!==b.ssh?{ssh:b.ssh}:{}}),promisor:{fetch:e=>r.createPromisorRemote(g).fetch(e)}});var b;g=y;let k,x="OPEN";const E=()=>{if(y.signal.aborted)throw t.repositoryDisposed()},S=U(y),C=Object.freeze({snapshot:S,add:(e,t)=>(E(),r.add(y,e,t)),archive:e=>(E(),r.archive(y,e)),blame:(e,t)=>(E(),r.blame(y,e,t)),branch:r.bindBranchNamespace(y,E),bundle:r.bindBundleNamespace(y,E),checkout:e=>(E(),r.checkout(y,e)),catFile:e=>(E(),r.catFile(y,e)),cherryPick:r.bindCherryPickNamespace(y,E),clone:e=>(E(),r.clone(y,e)),commit:e=>(E(),r.commit(y,e)),config:r.bindConfigNamespace(y,E),describe:(e,t)=>(E(),r.describe(y,e,t)),diff:e=>(E(),r.diff(y,e??{})),fetch:e=>(E(),r.fetch(y,e)),fetchMissing:e=>(E(),r.fetchMissing(y,e)),fsck:e=>(E(),r.fsck(y,e)),grep:e=>(E(),r.grep(y,e)),init:e=>(E(),r.init(y,e)),log:e=>(E(),r.log(y,e)),merge:r.bindMergeNamespace(y,E),mv:(e,t,s)=>(E(),r.mv(y,e,t,s)),nameRev:(e,t)=>(E(),r.nameRev(y,e,t)),notes:r.bindNotesNamespace(y,E),pull:e=>(E(),r.pull(y,e)),push:e=>(E(),r.push(y,e)),readFileAt:(e,t,s)=>(E(),r.readFileAt(y,e,t,s)),rangeDiff:e=>(E(),r.rangeDiff(y,e)),rebase:r.bindRebaseNamespace(y,E),reflog:e=>(E(),r.reflog(y,e)),remote:r.bindRemoteNamespace(y,E),reset:e=>(E(),r.reset(y,e)),revert:r.bindRevertNamespace(y,E),revParse:e=>(E(),r.revParse(y,e)),rm:(e,t)=>(E(),r.rm(y,e,t)),shortlog:e=>(E(),r.shortlog(y,e)),show:(e,t)=>(E(),r.show(y,e,t)),sparseCheckout:r.bindSparseCheckoutNamespace(y,E),stash:r.bindStashNamespace(y,E),status:()=>(E(),r.status(y)),submodule:r.bindSubmoduleNamespace(y,E),tag:r.bindTagNamespace(y,E),whatchanged:e=>(E(),r.whatchanged(y,e)),worktree:r.bindWorktreeNamespace(y,E),primitives:Object.freeze({bisectMidpoint:(e,t)=>(E(),i.bisectMidpoint(y,e,t)),catFileBatch:(t,r)=>(E(),e.catFileBatch(y,t,r)),createCommit:t=>(E(),e.createCommit(y,t)),diffTrees:(t,r,s)=>(E(),e.diffTrees(y,t,r,s)),getRepoRoot:()=>(E(),e.getRepoRoot(y)),hashBlob:(t,r)=>(E(),e.hashBlob(y,t,r)),isIgnored:e=>(E(),i.isIgnored(y,e)),mergeBase:(t,r)=>(E(),e.mergeBase(y,t,r)),readBlob:(t,r)=>(E(),e.readBlob(y,t,r)),readIndex:()=>(E(),e.readIndex(y)),readObject:(t,r)=>(E(),e.readObject(y,t,r)),readTree:t=>(E(),e.readTree(y,t)),resolveRef:(t,r)=>(E(),e.resolveRef(y,t,r)),runHook:(t,r)=>(E(),e.runHook(y,t,r)),streamBlob:(t,r)=>(E(),e.streamBlob(y,t,r)),updateRef:(t,r,s)=>(E(),e.updateRef(y,t,r,s)),walkCommits:t=>(E(),e.walkCommits(y,t)),walkCommitsByDate:t=>(E(),e.walkCommitsByDate(y,t)),walkSubmodules:t=>(E(),e.walkSubmodules(y,t)),walkTree:(t,r)=>(E(),e.walkTree(y,t,r)),walkWorkingTree:t=>(E(),e.walkWorkingTree(y,t)),writeObject:t=>(E(),e.writeObject(y,t)),writeTree:t=>(E(),e.writeTree(y,t))}),ctx:y,dispose:async()=>{if("DISPOSED"!==x)return void 0!==k||(x="DISPOSING",f.abort(),k=(async()=>{await new Promise(e=>{"function"==typeof setImmediate?setImmediate(e):setTimeout(e,0)}),await(async e=>{await Promise.all(N.map(t=>(async(e,t)=>{const r=e[t];if("function"==typeof r.dispose)try{await r.dispose()}catch(r){e.logger?.warn?.("disposeAdapters: port dispose threw",{port:t,err:String(r)})}})(e,t)))})(y),x="DISPOSED"})()),k}});return C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./error-CfLWDui_.cjs"),t=require("./readable-stream-MTA6D0Zh.cjs");const n=t=>new e.TsgitError({code:"INVALID_OBJECT_ID",value:t}),o=t=>new e.TsgitError({code:"INVALID_OBJECT_HEADER",reason:t}),r=(t,n)=>new e.TsgitError({code:"INVALID_TREE_ENTRY",offset:t,reason:n}),s=t=>new e.TsgitError({code:"INVALID_COMMIT",reason:t}),i=t=>new e.TsgitError({code:"INVALID_TAG",reason:t}),a=(t,n)=>new e.TsgitError({code:"INVALID_IDENTITY",line:t,reason:n}),c=t=>new e.TsgitError({code:"OBJECT_NOT_FOUND",id:t}),d=(t,n)=>new e.TsgitError({code:"OBJECT_HASH_MISMATCH",expected:t,actual:n}),u=(t,n,o)=>new e.TsgitError({code:"UNEXPECTED_OBJECT_TYPE",expected:t,actual:n,id:o}),f=t=>new e.TsgitError({code:"TREE_DEPTH_EXCEEDED",depth:t}),l=(t,n)=>new e.TsgitError({code:"TREE_ENTRY_LIMIT_EXCEEDED",count:t,limit:n}),h=(t,n,o)=>new e.TsgitError({code:"OBJECT_TOO_LARGE",id:t,actualSize:n,limit:o}),p={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"40000",GITLINK:"160000"},g=new Set(Object.values(p)),w=new Map([["040000",p.DIRECTORY]]);function m(t){return function(t){if(!g.has(t))throw new e.TsgitError({code:"INVALID_FILE_MODE",value:t});return t}(w.get(t)??t)}function y(e){return e===p.DIRECTORY}function v(e){return e.isSymbolicLink?p.SYMLINK:73&e.mode?p.EXECUTABLE:p.REGULAR}const x=function(){const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e}();function b(e){let t=4294967295;for(let n=0;n<e.length;n++)t=x[255&(t^e[n])]^t>>>8;return(4294967295^t)>>>0}const k=e=>/[a-zA-Z0-9-]/.test(e),E=e=>{if(!/[a-zA-Z]/.test(e[0]))return 0;for(let t=1;t<e.length;t+=1)if(!k(e[t]))return t},I=/[\n\0]/,T=t=>{const n=t.indexOf(".");if(-1===n)throw e.configKeyInvalid(t,"missing-name");const o=t.slice(0,n),r=t.lastIndexOf("."),s=t.slice(r+1),i=n===r?void 0:t.slice(n+1,r);if(0===o.length&&void 0===i)throw e.configKeyInvalid(t,"empty-section");if(0===s.length)throw e.configKeyInvalid(t,"missing-name");if(o.length>0){const n=E(o);if(void 0!==n)throw e.configKeyInvalid(t,"bad-character",n)}const a=E(s);if(void 0!==a)throw e.configKeyInvalid(t,"bad-character",r+1+a);if(void 0!==i&&I.test(i)){const o=i.search(I);throw e.configKeyInvalid(t,"bad-character",n+1+o)}return{section:o.toLowerCase(),subsection:i,name:s.toLowerCase()}},C=1e6,S=t=>new e.TsgitError({code:"INVALID_INDEX_HEADER",reason:t}),$=(t,n)=>new e.TsgitError({code:"INVALID_INDEX_ENTRY",offset:t,reason:n}),D={assumeValid:!1,stage:0,skipWorktree:!1,intentToAdd:!1},O=e=>({ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:e.mode,uid:0,gid:0,fileSize:0,id:e.id,flags:{...D,skipWorktree:!0},path:e.path}),L=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function A(e){const t=new Array(e.length);for(let n=0;n<e.length;n++)t[n]=L[e[n]];return t.join("")}function M(e){if(e.length%2!=0)throw new Error("Hex string must have even length");const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2){const o=_(e.charCodeAt(n)),r=_(e.charCodeAt(n+1));if(-1===o||-1===r)throw new Error(`Invalid hex character at position ${n}`);t[n/2]=o<<4|r}return t}function _(e){return e>=48&&e<=57?e-48:e>=97&&e<=102?e-87:-1}function U(e,t){const n=Math.min(e.length,t.length);for(let o=0;o<n;o++)if(e[o]!==t[o])return e[o]-t[o];return e.length-t.length}function N(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function R(e,t,n){for(let o=n;o<e.length;o++)if(e[o]===t)return o;return-1}const P=new TextEncoder,F=new TextDecoder;function B(e){return P.encode(e)}function W(e){return F.decode(e)}function j(e){const t=e.indexOf("\n\n");return-1===t?{headerPart:e,message:""}:{headerPart:e.slice(0,t),message:e.slice(t+2)}}function z(e,t){if(e.includes("\n")||e.includes(" ")||""===e)throw new Error(`invalid header key: ${e}`);const n=t.split("\n");return[`${e} ${n[0]}`,...n.slice(1).map(e=>` ${e}`)].join("\n")}function H(e){const t=e.indexOf(" ");return-1===t?{key:e,value:""}:{key:e.slice(0,t),value:e.slice(t+1)}}function G(e){const t=e.lastIndexOf(">");if(-1===t)throw a(e,"missing closing angle bracket");const n=e.lastIndexOf("<",t);if(-1===n)throw a(e,"missing opening angle bracket");const o=e.slice(0,n),r=o.endsWith(" ")?o.slice(0,-1):o,s=e.slice(n+1,t),i=e.slice(t+1).trim().split(/\s+/);if(i.length<2)throw a(e,"missing timestamp or timezone");const c=Number(i[0]);if(!Number.isSafeInteger(c))throw a(e,"invalid timestamp");const d=i[1];if(!/^[+-]\d{4}$/.test(d))throw a(e,"invalid timezone offset");return{name:r,email:s,timestamp:c,timezoneOffset:d}}const K=/[\n\r\0]/;function V(e){const t=`${e.name} <${e.email}>`;if(K.test(e.name))throw a(t,"name contains forbidden control character");if(K.test(e.email))throw a(t,"email contains forbidden control character");if(K.test(e.timezoneOffset))throw a(t,"timezoneOffset contains forbidden control character");if(e.name.includes("<")||e.name.includes(">"))throw a(t,"invalid identity fields");if(e.email.includes("<")||e.email.includes(">"))throw a(t,"invalid identity fields");if(!/^[+-]\d{4}$/.test(e.timezoneOffset))throw a(t,"invalid identity fields");return`${e.name} <${e.email}> ${e.timestamp} ${e.timezoneOffset}`}const Y=/^[0-9a-f]{40}$/,q=/^[0-9a-f]{64}$/,X={from(e){if(!Y.test(e)&&!q.test(e))throw n(e);return e},fromRaw(e){if(20!==e.length&&32!==e.length)throw n(`raw bytes length ${e.length} is not 20 or 32`);return X.from(A(e))}},J=X.from("0000000000000000000000000000000000000000");X.from("4b825dc642cb6eb9a060e54bf8d69288fbee4904");const Q={from(e){if(""===e)throw new Error("RefName must not be empty");return e}},Z={from(e){if(""===e)throw new Error("FilePath must not be empty");return e}};function ee(e){const t=[],{data:n}=e;t.push(`tree ${n.tree}`);for(const e of n.parents)t.push(`parent ${e}`);t.push(`author ${V(n.author)}`),t.push(`committer ${V(n.committer)}`),void 0!==n.gpgSignature&&t.push(z("gpgsig",n.gpgSignature));for(const e of n.extraHeaders)t.push(z(e.key,e.value));return B(`${t.join("\n")}\n\n${n.message}`)}const te=new Set(["blob","tree","commit","tag"]);function ne(e){const t=R(e,0,0);if(-1===t)throw o("missing null terminator");const n=W(e.subarray(0,t)),r=n.indexOf(" ");if(-1===r)throw o("missing space between type and size");const s=n.slice(0,r);if(!te.has(s))throw o(`unknown object type: ${s}`);const i=n.slice(r+1),a=Number(i);if(!Number.isFinite(a)||a<0||i!==String(a))throw o(`invalid size: ${i}`);return{type:s,size:a,contentOffset:t+1}}const oe=new Set(["blob","tree","commit","tag"]),re=/-----BEGIN (?:PGP|SSH) SIGNATURE-----[\s\S]*-----END (?:PGP|SSH) SIGNATURE-----\n?$/;function se(e){const t=[],{data:n}=e;if(t.push(`object ${n.object}`),t.push(`type ${n.objectType}`),""===n.tagName||n.tagName.includes("\n")||n.tagName.includes("\0"))throw i(`invalid tag name: ${n.tagName}`);t.push(`tag ${n.tagName}`),void 0!==n.tagger&&t.push(`tagger ${V(n.tagger)}`);for(const e of n.extraHeaders)t.push(z(e.key,e.value));return B(`${t.join("\n")}\n\n${void 0!==n.gpgSignature?`${n.message}${n.gpgSignature}`:n.message}`)}function ie(e,t){const n=ae(e.entries).map(e=>({mode:B(e.mode),name:B(e.name),hash:M(e.id)})),o=n.reduce((e,n)=>e+n.mode.length+1+n.name.length+1+t.digestLength,0),r=new Uint8Array(o);let s=0;for(const e of n)r.set(e.mode,s),s+=e.mode.length,r[s++]=32,r.set(e.name,s),s+=e.name.length,r[s++]=0,r.set(e.hash,s),s+=e.hash.length;return r}function ae(e){const t=e.map(e=>({entry:e,sortKey:de(e.name,y(e.mode))}));return t.sort((e,t)=>U(e.sortKey,t.sortKey)),t.map(e=>e.entry)}function ce(e,t){return U(de(e.name,y(e.mode)),de(t.name,y(t.mode)))}function de(e,t){const n=B(e);if(!t)return n;const o=new Uint8Array(n.length+1);return o.set(n),o[n.length]=47,o}function ue(e,t,n){const{type:a,size:c,contentOffset:d}=ne(t),u=t.subarray(d);if(u.length!==c)throw o(`size mismatch: header says ${c}, actual content is ${u.length}`);switch(a){case"blob":return function(e,t){return{type:"blob",id:e,content:t}}(e,u);case"tree":return function(e,t,n){const o=[],s=new Set;let i=0;for(;i<t.length;){const e=R(t,32,i);if(-1===e)throw r(i,"missing space after mode");const a=W(t.subarray(i,e)),c=R(t,0,e+1);if(-1===c)throw r(i,"missing null after name");const d=W(t.subarray(e+1,c));if(""===d||"."===d||".."===d||d.includes("/"))throw r(i,`invalid entry name: ${d}`);const u=c+1,f=u+n.digestLength;if(f>t.length)throw r(i,"truncated hash");const l=t.subarray(u,f),h=X.fromRaw(l),p=m(a);if(s.has(d))throw r(i,`duplicate entry name: ${d}`);s.add(d),o.push({mode:p,name:d,id:h}),i=f}return{type:"tree",id:e,entries:o}}(e,u,n);case"commit":return function(e,t){const{headerPart:n,message:o}=j(W(t)),r=n.split("\n"),{tree:i,parents:a,author:c,committer:d,nextIndex:u}=function(e){if(!e[0].startsWith("tree "))throw s("first line must be tree");const t=X.from(e[0].slice(5)),n=[];let o=1;for(;o<e.length&&e[o].startsWith("parent ");)n.push(X.from(e[o].slice(7))),o++;if(o>=e.length||!e[o].startsWith("author "))throw s("missing author");const r=G(e[o].slice(7));if(o++,o>=e.length||!e[o].startsWith("committer "))throw s("missing committer");const i=G(e[o].slice(10));return o++,{tree:t,parents:n,author:r,committer:i,nextIndex:o}}(r),{gpgSignature:f,extraHeaders:l}=function(e,t){return function(e,t,n,o){let r;const s=[];let i=t;for(;i<e.length;){const{key:t,value:a}=H(e[i]);""===t&&n("unexpected continuation line without preceding header");const c=[a];let d=i;for(let t=i+1;t<e.length;t++){const n=e[t];if(!n.startsWith(" "))break;c.push(n.slice(1)),d=t}i=d+1;const u=c.join("\n");"gpgsig"===t?(void 0!==r&&o("duplicate gpgsig header"),r=u):s.push({key:t,value:u})}return{gpgSignature:r,extraHeaders:s}}(e,t,e=>{throw s(e)},e=>{throw s(e)})}(r,u);return{type:"commit",id:e,data:{tree:i,parents:a,author:c,committer:d,message:o,...void 0!==f?{gpgSignature:f}:{},extraHeaders:l}}}(e,u);case"tag":return function(e,t){const{headerPart:n,message:o}=j(W(t)),r=n.split("\n"),{object:s,objectType:a,tagName:c,nextIndex:d}=function(e){if(!e[0].startsWith("object "))throw i("first line must be object");const t=X.from(e[0].slice(7));if(e.length<2||!e[1].startsWith("type "))throw i("second line must be type");const n=e[1].slice(5);if(!oe.has(n))throw i(`invalid object type: ${n}`);if(e.length<3||!e[2].startsWith("tag "))throw i("third line must be tag name");const o=e[2].slice(4);if(""===o||o.includes("\0")||o.includes("\n"))throw i(`invalid tag name: ${o}`);return{object:t,objectType:n,tagName:o,nextIndex:3}}(r),{tagger:u,nextIndex:f}=function(e,t){return t<e.length&&e[t].startsWith("tagger ")?{tagger:G(e[t].slice(7)),nextIndex:t+1}:{tagger:void 0,nextIndex:t}}(r,d),{extraHeaders:l}=function(e,t){const n=[];let o=t;for(;o<e.length;){const{key:t,value:r}=H(e[o]);if(""===t)throw i("unexpected continuation line without preceding header");const s=[r];let a=o;for(let t=o+1;t<e.length;t++){const n=e[t];if(!n.startsWith(" "))break;s.push(n.slice(1)),a=t}o=a+1,n.push({key:t,value:s.join("\n")})}return{extraHeaders:n}}(r,f),{message:h,gpgSignature:p}=function(e){const t=re.exec(e);return null===t?{message:e,gpgSignature:void 0}:{message:e.slice(0,t.index),gpgSignature:t[0]}}(o);return{type:"tag",id:e,data:{object:s,objectType:a,tagName:c,...void 0!==u?{tagger:u}:{},message:h,...void 0!==p?{gpgSignature:p}:{},extraHeaders:l}}}(e,u)}}function fe(e,t){let n;switch(e.type){case"blob":n=e.content;break;case"tree":n=ie(e,t);break;case"commit":n=ee(e);break;case"tag":n=se(e)}const o=B(`${e.type} ${n.length}\0`),r=new Uint8Array(o.length+n.length);return r.set(o,0),r.set(n,o.length),r}const le=(e,t)=>{switch(e.type){case"blob":return e.content.byteLength;case"tree":return ie(e,t).byteLength;case"commit":return ee(e).byteLength;case"tag":return se(e).byteLength}},he=new Set(["",".",".."]),pe=new Set([1564,8206,8207,8234,8235,8236,8237,8238,8294,8295,8296,8297]),ge=e=>""===e?"empty segment rejected":"."===e?"'.' segment rejected":"'..' segment rejected",we=e=>e<32||e>=127&&e<=159,me=(e,t)=>{if(e.startsWith("/"))throw $(t,"absolute path rejected");const n=(e=>{for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(92===n)return"backslash rejected";if(we(n))return"control character rejected";if(pe.has(n))return"bidi control character rejected"}})(e);if(void 0!==n)throw $(t,n);for(const n of e.split("/"))if(he.has(n))throw $(t,ge(n))};function ye(e,t,n,o){const r=e.getUint16(t+60),s=!!(16384&r);if(s&&3!==n)throw $(t,"extended flag requires index v3");const i=s?2:0;if(t+62+i>o-20)throw $(t,"truncated extended flags");return{flags:(a=r,c=s?e.getUint16(t+62):0,{assumeValid:!!(32768&a),stage:a>>>12&3,skipWorktree:!!(16384&c),intentToAdd:!!(8192&c)}),extendedSize:i};var a,c}function ve(e,t){for(let n=t;n<e.length;n++)if(0===e[n])return n;return-1}function xe(e,t){const n=e.path,o=t.path;return n<o?-1:n>o?1:0}function be(e,t,n,o,r,s){t.setUint32(n,o.ctimeSeconds),t.setUint32(n+4,o.ctimeNanoseconds),t.setUint32(n+8,o.mtimeSeconds),t.setUint32(n+12,o.mtimeNanoseconds),t.setUint32(n+16,o.dev),t.setUint32(n+20,o.ino),t.setUint32(n+24,Number.parseInt(o.mode,8)),t.setUint32(n+28,o.uid),t.setUint32(n+32,o.gid),t.setUint32(n+36,o.fileSize);const i=M(o.id);e.set(i,n+40);const a=Math.min(r.length,4095);t.setUint16(n+60,(o.flags.assumeValid?32768:0)|(s?16384:0)|o.flags.stage<<12|a),s&&t.setUint16(n+62,(o.flags.skipWorktree?16384:0)|(o.flags.intentToAdd?8192:0)),e.set(r,n+62+(s?2:0))}function ke(e){switch(e.type){case"add":case"rename":case"copy":return e.newPath;case"delete":return e.oldPath;case"modify":case"type-change":return e.path}}function Ee(e){return e===p.REGULAR||e===p.EXECUTABLE?"file":e===p.SYMLINK?"symlink":e===p.DIRECTORY?"directory":"gitlink"}function Ie(e,t){return Ee(e)===Ee(t)}function Te(e){return"gitlink"===Ee(e)}const Ce=new TextEncoder;function Se(e,t){return U(Ce.encode(e),Ce.encode(t))}function $e(e,t){const n=e.map(e=>({item:e,key:Ce.encode(t(e))}));return n.sort((e,t)=>U(e.key,t.key)),n.map(e=>e.item)}function De(e){return 32===e||9===e}function Oe(e){const t=e.length-1;return t>=0&&10===e[t]?t:e.length}function Le(e,t){const n=function(e,t){return t.ignoreCrAtEol||"all"===t.mode||"change"===t.mode||"at-eol"===t.mode?function(e){const t=Oe(e),n=t-1;if(n<0||13!==e[n])return e;const o=new Uint8Array(e.length-1);return o.set(e.subarray(0,n)),t<e.length&&(o[n]=10),o}(e):e}(e,t);switch(t.mode){case"all":return function(e){const t=Oe(e),n=[];for(let o=0;o<t;o++){const t=e[o];De(t)||n.push(t)}return t<e.length&&n.push(10),new Uint8Array(n)}(n);case"change":return function(e){const t=Oe(e),n=[];let o=!1;for(let r=0;r<t;r++){const t=e[r];De(t)?o||(n.push(32),o=!0):(o=!1,n.push(t))}return n.length>0&&32===n[n.length-1]&&n.pop(),t<e.length&&n.push(10),new Uint8Array(n)}(n);case"at-eol":return function(e){const t=Oe(e);let n=t;for(;n>0&&De(e[n-1]);)n--;if(n===t&&t===e.length)return e;const o=new Uint8Array(n+(t<e.length?1:0));return o.set(e.subarray(0,n)),t<e.length&&(o[n]=10),o}(n);case"none":return n}}const Ae={mode:"none",ignoreCrAtEol:!1};function Me(e,t){return 0===Oe(Le(e,t))}const _e=1e5;function Ue(e){const t=[];let n=0;for(let o=0;o<e.length;o++)10===e[o]&&(t.push(e.subarray(n,o+1)),n=o+1);return n<e.length&&t.push(e.subarray(n)),t}function Ne(e){return function(e){const t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(0===e[n])return!0;return!1}(e)||function(e){let t=0,n=0;for(let o=0;o<e.length;o++){if(t++,t>=65536)return!0;if(10===e[o]){if(n++,n>=_e)return!0;t=0}}return t>0&&(n++,n>=_e)}(e)}function Re(e,t,n,o){return o===-n||e[o-1+t]<e[o+1+t]}function Pe(e,t,n,o,r,s,i){let a=Re(n,o,r,s)?n[s+1+o]:n[s-1+o]+1,c=a-s;for(;a<e.length&&c<t.length&&i(e[a],t[c]);)a++,c++;return{x:a,y:c}}function Fe(e){const t=[];let n=0,o=0,r=0;for(;r<e.length;){const s=e[r],i=n,a=o;for(;e[r]===s;)"equal"===s?(n++,o++):"delete"===s?n++:o++,r++;t.push({kind:"equal"===s?"common":"delete"===s?"ours-only":"theirs-only",oursStart:i,oursEnd:n,theirsStart:a,theirsEnd:o})}return t}function Be(e,t,n){const o=n?.lineKey,r=o?(e,t)=>function(e,t,n){return N(Le(e,n),Le(t,n))}(e,t,o):N,s=Ue(e),i=Ue(t),a=s.length,c=i.length;if(0===a&&0===c)return{hunks:[{kind:"common",oursStart:0,oursEnd:0,theirsStart:0,theirsEnd:0}],oursLines:s,theirsLines:i,degraded:!1};const d=function(e,t,n){const o=e.length,r=t.length;if(o+r>5e4)return;const s=o+r,i=s,a=new Array(2*s+1).fill(0),c=[],d=1e3*s;let u=0;for(let s=0;;s++){const f=2*s+1,l=new Array(f);for(let e=0;e<f;e++)l[e]=a[i-s+e];c.push(l);for(let f=-s;f<=s;f+=2){if(u++,u>d)return;const l=Pe(e,t,a,i,s,f,n);if(a[f+i]=l.x,l.x>=o&&l.y>=r)return{trace:c,totalD:s}}}}(s,i,r);return void 0===d?function(e,t){const n=[];return e.length>0&&n.push({kind:"ours-only",oursStart:0,oursEnd:e.length,theirsStart:0,theirsEnd:0}),t.length>0&&n.push({kind:"theirs-only",oursStart:e.length,oursEnd:e.length,theirsStart:0,theirsEnd:t.length}),{hunks:n,oursLines:e,theirsLines:t,degraded:!0}}(s,i):{hunks:Fe(function(e,t,n){const o=[];let r=e,s=t;for(let e=n.length-1;e>0;e--){const t=n[e],i=e,a=r-s,c=Re(t,i,e,a)?a+1:a-1,d=t[c+i],u=d-c;for(;r>d&&s>u;)o.push("equal"),r--,s--;o.push(r===d?"insert":"delete"),r===d?s--:r--}for(;r>0;)o.push("equal"),r--;return o.reverse(),o}(a,c,d.trace)),oursLines:s,theirsLines:i,degraded:!1}}const We=6e4,je=107927;function ze(e){const t=new Map,n=e.length;let o=0,r=0,s=0;for(let i=0;i<n;i++){const n=e[i],a=o;if(o=(o<<7^r>>>25)+n>>>0,r=(r<<7^a>>>25)>>>0,s++,s>=64||10===n){const e=(o+Math.imul(r,97))%je;t.set(e,(t.get(e)??0)+s),s=0,o=0,r=0}}if(s>0){const e=(o+Math.imul(r,97))%je;t.set(e,(t.get(e)??0)+s)}return t}function He(e,t){let n=0;for(const[o,r]of e){const e=t.get(o)??0;e>0&&(n+=Math.min(r,e))}return n}function Ge(e,t){const n=t.get(e.newId);if(void 0===n||1!==n.length)return;const o=n[0];return{rename:{type:"rename",oldPath:o.oldPath,newPath:e.newPath,oldId:o.oldId,newId:e.newId,oldMode:o.oldMode,newMode:e.newMode,similarity:{score:We,maxScore:We}},consumedDelete:o}}function Ke(e,t,n){if("ours-only"===t.kind){for(let o=t.oursStart;o<t.oursEnd;o++)if(!Me(e.oursLines[o],n))return!0;return!1}for(let o=t.theirsStart;o<t.theirsEnd;o++)if(!Me(e.theirsLines[o],n))return!0;return!1}function Ve(e,t,n){return"theirs-only"!==t.kind?0:void 0===n||Ke(e,t,n)?t.theirsEnd-t.theirsStart:0}function Ye(e,t,n){return"ours-only"!==t.kind?0:void 0===n||Ke(e,t,n)?t.oursEnd-t.oursStart:0}const qe=(e,t,n)=>{const o=n?.numstatBinaryOverride;if("binary"===o||void 0===o&&(Ne(e)||Ne(t)))return{added:0,deleted:0,binary:!0};const r=n?.lineKey,s=Be(e,t,void 0!==r?{lineKey:r}:void 0),i=!0===n?.ignoreBlankLines?r??Ae:void 0;let a=0,c=0;for(const e of s.hunks)a+=Ve(s,e,i),c+=Ye(s,e,i);return{added:a,deleted:c,binary:!1}};function Xe(e){return{type:"add",newPath:e.name,newId:e.id,newMode:e.mode}}function Je(e){return{type:"delete",oldPath:e.name,oldId:e.id,oldMode:e.mode}}function Qe(e,t){if(e.id!==t.id||e.mode!==t.mode)return Ie(e.mode,t.mode)?{type:"modify",path:e.name,oldId:e.id,newId:t.id,oldMode:e.mode,newMode:t.mode}:{type:"type-change",path:e.name,oldId:e.id,newId:t.id,oldMode:e.mode,newMode:t.mode}}function Ze(e){return void 0===e?[]:ae(e.entries)}function et(e,t){const n=Ze(e),o=Ze(t),r=[];let s=0,i=0;for(;s<n.length&&i<o.length;){const e=n[s],t=o[i],a=ce(e,t);if(a<0)r.push(Je(e)),s++;else if(a>0)r.push(Xe(t)),i++;else{const n=Qe(e,t);void 0!==n&&r.push(n),s++,i++}}for(;s<n.length;)r.push(Je(n[s])),s++;for(;i<o.length;)r.push(Xe(o[i])),i++;return{changes:r}}const tt=(e,t,n)=>{const o=((e,t,n)=>{let o;for(let r=0;r<e.length;r+=1){const s=e[r];s.directoryOnly&&!n||s.compiled.test(t)&&(o={rule:s,index:r})}return o})(e,t,n);return void 0===o?{verdict:"unset"}:{verdict:o.rule.negated?"unignored":"ignored",ruleIndex:o.index}},nt=(e,t)=>{if(""===t)return e;const n=`${t}/`;return e.startsWith(n)?e.slice(n.length):void 0},ot=(e,t,n)=>{let o={verdict:"unset"};for(const r of e){const e=nt(t,r.basedir);if(void 0===e)continue;const s=tt(r.rules,e,n);void 0!==s.ruleIndex&&(o={verdict:s.verdict,level:r,ruleIndex:s.ruleIndex})}return o},rt={kind:"star-slash"},st=(e,t)=>{const n=e[t];return"*"===n?((e,t)=>{if("*"!==e[t+1])return{token:{kind:"star"},next:t+1};const n=t+2;return"/"===e[n]?{token:{kind:"star-slash"},next:n+1}:{token:{kind:"star-star"},next:n}})(e,t):"?"===n?{token:{kind:"single"},next:t+1}:{token:{kind:"literal",char:n},next:t+1}},it=(e,t,n)=>{switch(e.kind){case"literal":return((e,t,n)=>{const o=new Uint8Array(t.length+1);for(let r=0;r<t.length;r++)t[r]===e&&1===n[r+1]&&(o[r]=1);return o})(e.char,t,n);case"single":return((e,t)=>{const n=new Uint8Array(e.length+1);for(let o=0;o<e.length;o++)"/"!==e[o]&&1===t[o+1]&&(n[o]=1);return n})(t,n);case"star":return((e,t)=>{const n=new Uint8Array(e.length+1);n[e.length]=1===t[e.length]?1:0;for(let o=e.length-1;o>=0;o--)n[o]=1===t[o]||"/"!==e[o]&&1===n[o+1]?1:0;return n})(t,n);case"star-star":return((e,t)=>{const n=new Uint8Array(e.length+1);n[e.length]=1===t[e.length]?1:0;for(let o=e.length-1;o>=0;o--)n[o]=1===t[o]||1===n[o+1]?1:0;return n})(t,n);case"star-slash":return((e,t)=>{const n=new Uint8Array(e.length+1);for(let o=e.length-1;o>=0;o--)n[o]="/"===e[o]&&1===t[o+1]||1===n[o+1]?1:0;const o=new Uint8Array(e.length+1);for(let r=0;r<=e.length;r++)o[r]=1===t[r]||1===n[r]?1:0;return o})(t,n)}},at=(e,t)=>{const n=(e=>{const t=[];let n=0;for(;n<e.length;){const o=st(e,n);t.push(o.token),n=o.next}return t})(e);return{test:e=>((e,t,n)=>{let o=((e,t)=>{const n=new Uint8Array(e.length+1);if(n[e.length]=1,t)for(let t=0;t<e.length;t++)"/"===e[t]&&(n[t]=1);return n})(n,!0===t.withDirSuffix);for(let t=e.length-1;t>=0;t--)o=it(e[t],n,o);return t.anchored||(o=it(rt,n,o)),1===o[0]})(n,t,e)}},ct=e=>{let t=e.length;for(;t>0&&32===e.charCodeAt(t-1)&&!(t>=2&&92===e.charCodeAt(t-2));)t-=1;return e.slice(0,t)},dt=e=>e.replace(/\\(.)/g,"$1"),ut=e=>{if(""===e)return;if(/^\s*$/.test(e))return;if(e.startsWith("#"))return;const t=ct(e),n=t.startsWith("!"),o=n?t.slice(1):t,r=o.endsWith("/"),s=r?o.slice(0,-1):o,i=s.startsWith("/")||s.includes("/"),a=s.startsWith("/")?s.slice(1):s;return{negated:n,anchored:i,directoryOnly:r,cleanPattern:dt(a)}},ft=t=>new e.TsgitError({code:"INVALID_REFLOG_ENTRY",reason:t}),lt=/[\n\r]/;function ht(e){if(lt.test(e.message))throw ft("message contains a line break");const t=V(e.identity),n=`${e.oldId} ${e.newId} ${t}`;return""===e.message?`${n}\n`:`${n}\t${e.message}\n`}function pt(e){const t=e.indexOf("\t"),n=-1===t?e:e.slice(0,t),o=-1===t?"":e.slice(t+1);if(" "!==n[40]||" "!==n[81])throw ft("misplaced field separator");return{oldId:wt(n.slice(0,40)),newId:wt(n.slice(41,81)),identity:function(e){try{return G(e)}catch{throw ft("invalid identity")}}(n.slice(82)),message:o}}function gt(e){return e.replace(/[\r\n]+/g," ").trim()}function wt(e){try{return X.from(e)}catch{throw ft("invalid object id")}}const mt=["refs/heads/","refs/remotes/","refs/notes/"];const yt=t=>new e.TsgitError({code:"INVALID_REF",reason:t}),vt=t=>new e.TsgitError({code:"INVALID_PACKED_REFS",reason:t}),xt=t=>new e.TsgitError({code:"REF_NOT_FOUND",name:t}),bt=(t,n)=>new e.TsgitError({code:"REF_CHAIN_TOO_DEEP",depth:t,chain:n}),kt=t=>new e.TsgitError({code:"REF_CYCLE_DETECTED",chain:t}),Et=t=>new e.TsgitError({code:"REF_LOCKED",name:t}),It=new Set(["~","^",":","?","*","[","\\"," "]);function Tt(e){if(""===e)throw yt("ref name must not be empty");if(e.startsWith("/")||e.endsWith("/"))throw yt("ref name must not start or end with /");if(e.startsWith("-"))throw yt("ref name must not start with -");if("@"===e)throw yt("ref name must not be single @");if(e.includes(".."))throw yt("ref name must not contain ..");if(e.includes("//"))throw yt("ref name must not contain consecutive slashes");if(e.includes("@{"))throw yt("ref name must not contain @{");if(e.endsWith("."))throw yt("ref name must not end with .");!function(e){for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<=31||127===n)throw yt("ref name contains forbidden character");const o=e[t];if(void 0!==o&&It.has(o))throw yt("ref name contains forbidden character");if(n>=8234&&n<=8238||n>=8294&&n<=8297)throw yt("ref name contains forbidden Unicode override")}}(e);const t=e.split("/");for(const e of t){if(e.startsWith("."))throw yt("ref name component must not start with .");if(e.endsWith(".lock"))throw yt("ref name component must not end with .lock")}return e}function Ct(e){const t=e.replace(/[\r\n]+$/,"");if(""===t)throw yt("empty ref content");if(t.startsWith("ref: ")){const e=t.slice(5);if(""===e)throw yt("empty symbolic ref target");return{type:"symbolic",target:Tt(e)}}return{type:"direct",target:X.from(t)}}const St="MERGE_HEAD",$t="ORIG_HEAD",Dt="CHERRY_PICK_HEAD",Ot="REVERT_HEAD",Lt="FETCH_HEAD",At=new Set(["HEAD",$t,Lt,St,Dt,Ot,"BISECT_HEAD"]),Mt=["refs/bisect/","refs/worktree/","refs/rewritten/"],_t=e=>{const t=e.split("/"),n=[];for(let e=t.length-1;e>0;e-=1)n.push(t.slice(0,e).join("/"));return n},Ut=e=>{const t=e.replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+$/,"");for(const n of t.split("/"))Nt(n,e);return t},Nt=(t,n)=>{const o=n.slice(0,128);if(""===t||"."===t||".."===t)throw e.invalidOption("patterns",`cone directory has an invalid segment: ${o}`);if(t.includes("*")||t.includes("?"))throw e.invalidOption("patterns",`cone directory must not contain glob metacharacters: ${o}`);if(/[\n\r\0]/.test(t))throw e.invalidOption("patterns",`cone directory must not contain control characters: ${o}`)},Rt=e=>{if(!e.startsWith("/")||!e.endsWith("/"))return;const t=e.slice(1,-1);return""===t||t.startsWith("!")?void 0:t},Pt=(e,t)=>{const n=(e=>{if(e.directoryOnly)return!0;const t=e.cleanPattern.split("/"),n=t[t.length-1];return!n.includes("*")&&!n.includes("?")})(e);return{source:t,negated:e.negated,matcher:at(e.cleanPattern,{anchored:e.anchored,withDirSuffix:n})}},Ft=new TextEncoder,Bt=t=>{const n=t.split("\n").map(e=>e.replace(/\r$/,"")),o=[];for(const t of n){if(Ft.encode(t).byteLength>256)throw e.invalidOption("patterns","pattern exceeds max length 256 bytes");const n=ut(t);if(void 0!==n){if(o.length>=2048)throw e.invalidOption("patterns","pattern file exceeds max 2048 patterns");o.push(Pt(n,t))}}return o},Wt=(e,t)=>{if(t){const t=(e=>{const t=e.split("\n").map(e=>e.replace(/\r$/,""));if("/*"!==t[0]||"!/*/"!==t[1])return;const n=new Set,o=new Set;let r=2;for(;r<t.length;){const e=t[r];if(""===e){r+=1;continue}const s=Rt(e);if(void 0===s)return;r+=1,t[r]===`!/${s}/*/`?(o.add(s),r+=1):n.add(s)}return{mode:"cone",recursive:n,parents:o}})(e);return void 0!==t?{spec:t,degraded:!1}:{spec:{mode:"no-cone",rules:Bt(e)},degraded:!0}}return{spec:{mode:"no-cone",rules:Bt(e)},degraded:!1}},jt=e=>{return"cone"===e.mode?(e=>t=>{const n=(e=>{const t=e.lastIndexOf("/");return-1===t?"":e.slice(0,t)})(t);if(""===n)return!0;if(e.parents.has(n))return!0;let o=n;for(;;){if(e.recursive.has(o))return!0;const t=o.lastIndexOf("/");if(-1===t)return!1;o=o.slice(0,t)}})(e):(t=e.rules,e=>{let n=!1;for(const o of t)o.matcher.test(e)&&(n=!o.negated);return n});var t},zt=t=>new e.TsgitError({code:"INVALID_PACK_HEADER",reason:t}),Ht=t=>new e.TsgitError({code:"INVALID_PACK_INDEX",reason:t}),Gt=(t,n)=>new e.TsgitError({code:"INVALID_PACK_ENTRY",offset:t,reason:n}),Kt=t=>new e.TsgitError({code:"INVALID_DELTA",reason:t}),Vt=t=>new e.TsgitError({code:"DELTA_CHAIN_TOO_DEEP",depth:t});function Yt(e,t){if(t>=e.length)throw Kt("truncated variable-length integer");let n=0,o=0,r=t,s=0,i=e[r];for(n=(127&i)<<o>>>0,o+=7,s+=1;128&i;){if(s>=5)throw Kt("variable-length integer too long");if(r+=1,r>=e.length)throw Kt("truncated variable-length integer");i=e[r],n=(n|(127&i)<<o)>>>0,o+=7,s+=1}return{value:n,nextOffset:r+1}}function qt(e,t,n){const o=function(e){let t=0;return 1&e&&(t+=1),2&e&&(t+=1),4&e&&(t+=1),8&e&&(t+=1),16&e&&(t+=1),32&e&&(t+=1),64&e&&(t+=1),t}(n);if(t+o>e.length)throw Kt(`COPY instruction truncated: needs ${o} bytes at position ${t}`);let r=t,s=0,i=0;return 1&n&&(s|=e[r],r+=1),2&n&&(s|=e[r]<<8,r+=1),4&n&&(s|=e[r]<<16,r+=1),8&n&&(s=(s|16777216*e[r])>>>0,r+=1),16&n&&(i|=e[r],r+=1),32&n&&(i|=e[r]<<8,r+=1),64&n&&(i|=e[r]<<16,r+=1),0===i&&(i=65536),{offset:s,size:i,nextPos:r}}function Xt(e,t,n,o,r){if(e+t>n)throw Kt(`COPY out of bounds: offset=${e} size=${t} exceeds base length ${n}`);if(o+t>r)throw Kt(`COPY overflows target: position=${o} size=${t} exceeds target length ${r}`)}function Jt(e,t,n,o,r,s){if(0===n)throw Kt("INSERT with N=0 is reserved");if(t+n>e.length)throw Kt(`INSERT data truncated: needs ${n} bytes at position ${t}`);if(r+n>s)throw Kt(`INSERT overflows target: position=${r} size=${n} exceeds target length ${s}`);return o.set(e.subarray(t,t+n),r),{nextPos:t+n,nextResultPos:r+n}}function Qt(e,t){const{value:n,nextOffset:o}=Yt(t,0),{value:r,nextOffset:s}=Yt(t,o);!function(e,t,n){if(e.length!==t)throw Kt(`source length mismatch: expected ${t}, got ${e.length}`);if(n>2147483648)throw Kt(`target length ${n} exceeds maximum allowed size`)}(e,n,r);const i=new Uint8Array(r);let a=0,c=s;for(;c<t.length;){const n=t[c];if(c+=1,128&n){const{offset:o,size:s,nextPos:d}=qt(t,c,n);c=d,Xt(o,s,e.length,a,r),i.set(e.subarray(o,o+s),a),a+=s}else{const e=Jt(t,c,n,i,a,r);c=e.nextPos,a=e.nextResultPos}}if(a!==r)throw Kt(`underfill: produced ${a} bytes but target length is ${r}`);return i}const Zt=1346454347;function en(e,t,n){const{type:o,size:r,nextPos:s}=function(e,t){if(t>=e.length)throw Gt(t,"unexpected end of header");let n=t;const o=e[n],r=o>>4&7;let s=15&o,i=4,a=0;for(;128&e[n];){if(a+=1,a>5)throw Gt(t,"size encoding too long");if(n+=1,n>=e.length)throw Gt(t,"unexpected end of header");s|=(127&e[n])<<i,i+=7}return{type:r,size:s,nextPos:n+1}}(e,t);if(function(e,t){if(5===e)throw Gt(t,"reserved type 5");if(e<1||e>7)throw Gt(t,`unknown type ${e}`)}(o,t),6===o){const{distance:n,nextPos:o}=function(e,t,n){if(t>=e.length)throw Gt(n,"unexpected end of OFS_DELTA distance");let o=t,r=127&e[o],s=0;for(;128&e[o];){if(s+=1,s>4)throw Gt(n,"OFS_DELTA distance encoding too long");if(o+=1,o>=e.length)throw Gt(n,"unexpected end of OFS_DELTA distance");r=r+1<<7|127&e[o]}return{distance:r,nextPos:o+1}}(e,s,t);return{type:6,size:r,dataOffset:o,baseDistance:n}}if(7===o){const o=s+n.digestLength;if(o>e.length)throw Gt(t,"unexpected end of REF_DELTA base id");return{type:7,size:r,dataOffset:o,baseId:A(e.subarray(s,o))}}return{type:o,size:r,dataOffset:s}}function tn(e,t){const n=[];let o=(7&e)<<4|15&t,r=t>>>4;for(r>0&&(o|=128),n.push(o);r>0;){let e=127&r;r>>>=7,r>0&&(e|=128),n.push(e)}return new Uint8Array(n)}const nn=1032,on=20;function rn(e,t){return e._view.getUint32(8+4*t)}function sn(e,t,n){const o=nn+t*on,r=e._bytes;for(let e=0;e<on;e+=1){const t=r[o+e]-n[e];if(0!==t)return t}return 0}function an(e,t){const n=e._view.getUint32(e.smallOffsetsTableOffset+4*t);if(2147483648&n){const t=2147483647&n,o=e.largeOffsetsTableOffset+8*t;if(o+8>e.trailerOffset)throw Ht(`large offset index ${t} out of range`);const r=e._view.getUint32(o),s=e._view.getUint32(o+4);if(r>2097151)throw Ht(`pack offset exceeds safe JavaScript number range: high word=${r}`);return 4294967296*r+s}return n}function cn(e,t){const n=M(t),o=n[0];let r=0===o?0:rn(e,o-1),s=rn(e,o);for(;r<s;){const t=r+s>>>1,o=sn(e,t,n);if(o<0)r=t+1;else{if(!(o>0))return an(e,t);s=t}}}const dn=/^[0-9a-f]+$/;function un(e){const t=[];for(let n=0;n<e.objectCount;n++){const o=nn+n*on,r=e._bytes.subarray(o,o+on);t.push(A(r))}return t}function fn(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function ln(e){const t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t);let o=0;for(const t of e)n.set(t,o),o+=t.length;return n}const hn=e=>e.layout.commonDir??e.layout.gitDir,pn=(e,t)=>(e=>At.has(e)||Mt.some(t=>e.startsWith(t)))(t)?e.layout.gitDir:hn(e),gn=(e,t)=>`${e}/objects/${function(e){return`${e.slice(0,2)}/${e.slice(2)}`}(t)}`,wn=(e,t)=>`${e}/${t}`,mn=e=>`${e}/index`,yn=(e,t)=>`${e}/objects/${t}`,vn=(e,t)=>`${e}/logs/${t}`,xn=e=>`${e}/info/sparse-checkout`,bn=".lock";async function kn(e,t,n,o){const r=`${n}${bn}`;try{await e.fs.writeExclusive(r,o)}catch(e){if(En(e))throw Et(t);throw e}try{await e.fs.rename(r,n)}catch(t){try{await e.fs.rm(r)}catch(e){if(!In(e))throw e}throw t}}function En(t){return t instanceof e.TsgitError&&"FILE_EXISTS"===t.data.code}function In(t){return t instanceof e.TsgitError&&"FILE_NOT_FOUND"===t.data.code}let Tn=new WeakMap;const Cn=e=>Sn(e).then(e=>e.parsed),Sn=e=>{const t=Tn.get(e);if(void 0!==t)return t;const n=Dn(e);return Tn.set(e,n),n},$n=e=>{Tn.delete(e)},Dn=async e=>{const t=`${hn(e)}/config`,n=await On(e,t);if(void 0===n)return{parsed:{},tokens:[],source:t};const o=Fn(n,t);return{parsed:lo(Yn(o)),tokens:o,source:t}},On=async(t,n)=>{try{return await t.fs.readUtf8(n)}catch(t){if(t instanceof e.TsgitError&&"FILE_NOT_FOUND"===t.data.code)return;throw t}},Ln=(e,t,n,o)=>e.toLowerCase()===n.toLowerCase()&&t===o,An=async(e,t,n,o)=>{const{tokens:r,source:s}=await Sn(e),i=new Set(o.map(e=>e.toLowerCase()));let a=!1;for(const e of r){if("header"===e.kind){a=Ln(e.section,e.subsection,t,n);continue}if(!a||"entry"!==e.kind||null!==e.value)continue;const o=e.key.toLowerCase();if(!i.has(o))continue;const r=t.toLowerCase();return{key:void 0===n?`${r}.${o}`:`${r}.${n}.${o}`,source:s,line:e.startLine+1}}},Mn=new Set(["loosecompression","compression"]),_n=e=>e>="a"&&e<="z"||e>="A"&&e<="Z",Un=e=>_n(e)||e>="0"&&e<="9"||"-"===e,Nn=e=>" "===e||"\t"===e,Rn=(t,n,o,r)=>{const s=t[n];if(o>=s.length||!_n(s[o]))throw e.configParseError(n+1,r);let i=o+1;for(;i<s.length&&Un(s[i]);)i+=1;const a=s.slice(o,i);for(;i<s.length&&Nn(s[i]);)i+=1;const c={key:a,value:null,nextLineIdx:n+1};if(i>=s.length)return c;const d=s[i];if("\r"===d&&i===s.length-1)return c;if("="!==d)throw e.configParseError(n+1,r);const u=Jn(t,n,i+1,r);return{key:a,value:u.value,nextLineIdx:u.nextLineIdx}},Pn=(e,t)=>{let n=t;for(;n<e.length&&Nn(e[n]);)n+=1;return n},Fn=(e,t)=>Bn(e.split("\n"),e.endsWith("\n"),t),Bn=(e,t,n)=>{const o=[],r=t?e.length-1:e.length;let s=0;for(;s<r;)s=Wn(o,e,s,n);return o},Wn=(t,n,o,r)=>{const s=n[o];if(""===no(s).trim())return t.push(""===s.trim()?{kind:"blank",line:o}:{kind:"comment",line:o}),o+1;const i=ro(s);if("header"===i.parse.kind)return zn(t,n,o,i,r);if("malformed"===i.parse.kind)throw e.configParseError(o+1,r,i.parse.partialName);return jn(t,n,o,r)},jn=(e,t,n,o)=>{const r=Pn(t[n],0),s=Rn(t,n,r,o);return e.push({kind:"entry",key:s.key,value:s.value,startLine:n,endLine:s.nextLineIdx}),s.nextLineIdx},zn=(t,n,o,r,s)=>{const i=n[o];let a=r,c=Kn(i,a.endOffset);for(;"["===i[c];){if(Hn(t,a,o,!1),a=ro(i,c),"header"!==a.parse.kind)throw e.configParseError(o+1,s,Gn(a.parse));c=Kn(i,a.endOffset)}const d=i[c],u="#"===d||";"===d;if(Hn(t,a,o,u),c>=i.length||u)return o+1;const f=Rn(n,o,c,s);return t.push({kind:"entry",key:f.key,value:f.value,startLine:o,endLine:f.nextLineIdx,sharesHeaderLine:!0,startCol:c}),f.nextLineIdx},Hn=(e,t,n,o)=>{const r=t.parse;e.push({kind:"header",section:r.section,subsection:r.subsection,line:n,hasComment:o})},Gn=e=>"malformed"===e.kind?e.partialName:void 0,Kn=(e,t)=>{let n=t;for(;n<e.length&&Xn.has(e[n]);)n+=1;return n},Vn=(e,t)=>Yn(Fn(e,t)),Yn=e=>{const t=[],n={section:"",subsection:void 0,entries:[]};let o=n;for(const n of e)"header"===n.kind?(o={section:n.section,subsection:n.subsection,entries:[]},t.push(o)):"entry"===n.kind&&o.entries.push({key:n.key,value:n.value});return n.entries.length>0?[n,...t]:t},qn=new Map([["n","\n"],["t","\t"],["b","\b"],["\\","\\"],['"','"']]),Xn=new Set([" ","\t","\r"]),Jn=(t,n,o,r)=>{const s={lineIdx:n,col:o},i={out:"",trimLen:-1,inQuotes:!1,inComment:!1};for(;s.lineIdx<t.length;){if(s.col>=t[s.lineIdx].length){if(i.inQuotes)throw e.configParseError(s.lineIdx+1,r);return to(i,s.lineIdx+1)}Qn(t,s,i,r)}return to(i,s.lineIdx)},Qn=(e,t,n,o)=>{const r=e[t.lineIdx][t.col];if(t.col+=1,!n.inComment)if(n.inQuotes||!Xn.has(r))if(n.inQuotes||"#"!==r&&";"!==r)if("\\"!==r){if('"'===r)return n.inQuotes=!n.inQuotes,void(n.trimLen=-1);n.out+=r,n.trimLen=-1}else Zn(e,t,n,o);else n.inComment=!0;else eo(n,r)},Zn=(t,n,o,r)=>{const s=t[n.lineIdx];if(n.col>=s.length)return n.lineIdx+=1,void(n.col=0);const i=qn.get(s[n.col]);if(void 0===i)throw e.configParseError(n.lineIdx+1,r);n.col+=1,o.out+=i,o.trimLen=-1},eo=(e,t)=>{""!==e.out&&(-1===e.trimLen&&(e.trimLen=e.out.length),e.out+=t)},to=(e,t)=>({value:-1===e.trimLen?e.out:e.out.slice(0,e.trimLen),nextLineIdx:t}),no=e=>{const t=[oo(e,"#"),oo(e,";")].filter(e=>e>=0);return 0===t.length?e:e.slice(0,Math.min(...t))},oo=(e,t)=>{let n=!1;for(let o=0;o<e.length;o+=1){const r=e[o];if(n&&"\\"===r)o+=1;else if('"'===r)n=!n;else if(!n&&r===t)return o}return-1},ro=(e,t=0)=>{const n=Pn(e,t);if("["!==e[n])return io;const o=n+1,r=e.indexOf("]",o),s=so(e,o,r);return-1===s?co(e,o,r):uo(e,o,s)},so=(e,t,n)=>{const o=-1===n?e.length:n;for(let n=t;n<o;n+=1)if('"'===e[n])return n;return-1},io={parse:{kind:"not-header"},endOffset:0},ao=/^[A-Za-z0-9.-]+$/,co=(e,t,n)=>{if(-1===n)return io;const o=e.slice(t,n);return ao.test(o)?{parse:{kind:"header",section:o,subsection:void 0},endOffset:n+1}:io},uo=(e,t,n)=>{const{parse:o,closeQuoteAt:r}=((e,t,n)=>{const o=e.slice(t,n).trim(),r=o.toLowerCase(),s=n>t?e[n-1]:void 0;return void 0!==s&&Xn.has(s)?((e,t,n,o)=>{const r=((e,t)=>{let n="",o=t+1;for(;o<e.length;){const t=e[o];if("\\"!==t){if('"'===t)return{subsection:n,closeQuoteAt:o};n+=t,o+=1}else{if(o+1>=e.length)return{partial:n};n+=e[o+1],o+=2}}return{partial:n}})(e,t);return"partial"in r?{parse:{kind:"malformed",partialName:`${o}.${r.partial}`}}:e.startsWith("]",r.closeQuoteAt+1)?{parse:{kind:"header",section:n,subsection:r.subsection},closeQuoteAt:r.closeQuoteAt}:{parse:{kind:"malformed",partialName:`${o}.${r.subsection}`}}})(e,n,o,r):{parse:{kind:"malformed",partialName:r}}})(e,t,n);return"header"!==o.kind||void 0===r?{parse:o,endOffset:0}:{parse:o,endOffset:r+2}},fo=(e,t)=>{void 0!==t.subsection?((e,t,n)=>{"remote"===t.section?yo(e,n,t):"branch"===t.section?xo(e,n,t):"submodule"===t.section?bo(e,n,t):"merge"===t.section?ko(e,n,t):"diff"===t.section?Eo(e,n,t):"filter"===t.section?To(e,n,t):"gpg"===t.section&&_o(e,n,t)})(e,t,t.subsection):"remote"===t.section?vo(e,t):"core"===t.section?po(e,t):"user"===t.section?wo(e,t):"extensions"===t.section?Co(e,t):"commit"===t.section?So(e,t):"tag"===t.section?$o(e,t):"push"===t.section?Lo(e,t):"gpg"===t.section&&Mo(e,t)},lo=e=>{const t={};for(const n of e)fo(t,n);return Uo(t)},ho=(e,t,n)=>"bare"===t?{...e,bare:Ro(n)}:"logallrefupdates"===t?{...e,logAllRefUpdates:go(n)}:"sparsecheckout"===t?{...e,sparseCheckout:Ro(n)}:"sparsecheckoutcone"===t?{...e,sparseCheckoutCone:Ro(n)}:null!==n?"excludesfile"===t?{...e,excludesFile:n}:"attributesfile"===t?{...e,attributesFile:n}:"hookspath"===t?{...e,hooksPath:n}:"notesref"===t?{...e,notesRef:n}:"sshcommand"===t?{...e,sshCommand:n}:"loosecompression"===t||"compression"===t?((e,t,n)=>{const o=Wo(n);if(o.ok){if("loosecompression"===t)return{...e,looseCompression:o.value,looseCompressionFromLoose:!0};if(!0!==e.looseCompressionFromLoose)return{...e,looseCompression:o.value}}})(e,t,n):void 0:void 0,po=(e,t)=>{for(const{key:n,value:o}of t.entries){const t=ho(e.core??{},n.toLowerCase(),o);void 0!==t&&(e.core=t)}},go=e=>null!==e&&"always"===e.toLowerCase()?"always":Ro(e),wo=(e,t)=>{for(const{key:n,value:o}of t.entries)null!==o&&("name"===n?e.user={...e.user,name:o}:"email"===n?e.user={...e.user,email:o}:"signingkey"===n.toLowerCase()&&(e.user={...e.user,signingKey:o}))},mo=(e,t,n)=>{const o=t.toLowerCase();"url"===o?null!==n&&(e.url=n):"pushurl"===o?null!==n&&(e.pushUrl=n):"fetch"===o?null!==n&&(e.fetch??=[],e.fetch.push(n)):"promisor"===o?e.promisor=Ro(n):"partialclonefilter"===o&&null!==n&&(e.partialCloneFilter=n)},yo=(e,t,n)=>{e.remote??=new Map;const o=e.remote.get(t)??{},r={...o,fetch:o.fetch?[...o.fetch]:[]};for(const{key:e,value:t}of n.entries)mo(r,e,t);e.remote.set(t,(e=>{const t={};return void 0!==e.url&&(t.url=e.url),void 0!==e.pushUrl&&(t.pushUrl=e.pushUrl),void 0!==e.fetch&&e.fetch.length>0&&(t.fetch=e.fetch),void 0!==e.promisor&&(t.promisor=e.promisor),void 0!==e.partialCloneFilter&&(t.partialCloneFilter=e.partialCloneFilter),t})(r))},vo=(e,t)=>{for(const{key:n,value:o}of t.entries)null!==o&&"pushdefault"===n.toLowerCase()&&(e.remotePushDefault=o)},xo=(e,t,n)=>{e.branch??=new Map;const o={...e.branch.get(t)??{}};for(const{key:e,value:t}of n.entries)null!==t&&("remote"===e?o.remote=t:"merge"===e?o.merge=t:"pushremote"===e.toLowerCase()&&(o.pushRemote=t));e.branch.set(t,o)},bo=(e,t,n)=>{e.submodule??=new Map;const o={...e.submodule.get(t)??{}};for(const{key:e,value:t}of n.entries){const n=e.toLowerCase();"url"===n?null!==t&&(o.url=t):"active"===n?o.active=Ro(t):"update"===n&&null!==t&&(o.update=t)}e.submodule.set(t,o)},ko=(e,t,n)=>{e.merge??=new Map;const o={...e.merge.get(t)??{}};for(const{key:e,value:t}of n.entries){if(null===t)continue;const n=e.toLowerCase();"name"===n?o.name=t:"driver"===n?o.driver=t:"recursive"===n&&(o.recursive=t)}e.merge.set(t,o)},Eo=(e,t,n)=>{e.diff??=new Map;const o={...e.diff.get(t)??{}};for(const{key:e,value:t}of n.entries){const n=e.toLowerCase();if("textconv"===n){if(null===t)continue;o.textconv=t}else"cachetextconv"===n&&(o.cachetextconv=Ro(t))}e.diff.set(t,o)},Io=(e,t,n)=>{const o=t.toLowerCase();"required"!==o?null!==n&&("clean"===o?e.clean=n:"smudge"===o?e.smudge=n:"process"===o&&(e.process=n)):e.required=Ro(n)},To=(e,t,n)=>{e.filter??=new Map;const o={...e.filter.get(t)??{}};for(const{key:e,value:t}of n.entries)Io(o,e,t);e.filter.set(t,o)},Co=(e,t)=>{for(const{key:n,value:o}of t.entries)"partialclone"===n.toLowerCase()&&null!==o&&(e.extensions={...e.extensions,partialClone:o})},So=(e,t)=>{for(const{key:n,value:o}of t.entries)"gpgsign"===n.toLowerCase()&&(e.commit={...e.commit,gpgSign:Ro(o)})},$o=(e,t)=>{for(const{key:n,value:o}of t.entries)"gpgsign"===n.toLowerCase()&&(e.tag={...e.tag,gpgSign:Ro(o)})},Do=e=>null!==e&&"if-asked"===e.toLowerCase()?"if-asked":Ro(e)?"true":"false",Oo=e=>"tracking"===e?"upstream":"nothing"===e||"current"===e||"upstream"===e||"simple"===e||"matching"===e?e:void 0,Lo=(e,t)=>{for(const{key:n,value:o}of t.entries)if("gpgsign"===n.toLowerCase())e.push={...e.push,gpgSign:Do(o)};else if("default"===n.toLowerCase()){const t=Oo(o);void 0!==t&&(e.push={...e.push,default:t})}},Ao=e=>"openpgp"===e||"ssh"===e||"x509"===e,Mo=(e,t)=>{for(const{key:n,value:o}of t.entries){if(null===o)continue;const t=n.toLowerCase();"format"===t&&Ao(o)?e.gpg={...e.gpg,format:o}:"program"===t&&(e.gpg={...e.gpg,program:o})}},_o=(e,t,n)=>{if("ssh"===t)for(const{key:t,value:o}of n.entries)"program"===t.toLowerCase()&&null!==o&&(e.gpg={...e.gpg,ssh:{...e.gpg?.ssh,program:o}})},Uo=e=>{const t={},n=(e=>{if(void 0!==e)return{...void 0!==e.bare?{bare:e.bare}:{},...void 0!==e.excludesFile?{excludesFile:e.excludesFile}:{},...void 0!==e.attributesFile?{attributesFile:e.attributesFile}:{},...void 0!==e.logAllRefUpdates?{logAllRefUpdates:e.logAllRefUpdates}:{},...void 0!==e.hooksPath?{hooksPath:e.hooksPath}:{},...void 0!==e.notesRef?{notesRef:e.notesRef}:{},...void 0!==e.sparseCheckout?{sparseCheckout:e.sparseCheckout}:{},...void 0!==e.sparseCheckoutCone?{sparseCheckoutCone:e.sparseCheckoutCone}:{},...void 0!==e.looseCompression?{looseCompression:e.looseCompression}:{},...void 0!==e.sshCommand?{sshCommand:e.sshCommand}:{}}})(e.core);void 0!==n&&(t.core=n);const o=(e=>{if(void 0!==e)return void 0!==e.name&&void 0!==e.email||void 0!==e.signingKey?{...void 0!==e.name?{name:e.name}:{},...void 0!==e.email?{email:e.email}:{},...void 0!==e.signingKey?{signingKey:e.signingKey}:{}}:void 0})(e.user);return void 0!==o&&(t.user=o),void 0!==e.remote&&e.remote.size>0&&(t.remote=e.remote),void 0!==e.remotePushDefault&&(t.remotePushDefault=e.remotePushDefault),void 0!==e.extensions&&(t.extensions=e.extensions),void 0!==e.branch&&e.branch.size>0&&(t.branch=e.branch),void 0!==e.submodule&&e.submodule.size>0&&(t.submodule=e.submodule),void 0!==e.merge&&e.merge.size>0&&(t.merge=e.merge),((e,t)=>{void 0!==e.diff&&e.diff.size>0&&(t.diff=e.diff),void 0!==e.filter&&e.filter.size>0&&(t.filter=e.filter)})(e,t),((e,t)=>{void 0!==e.commit&&(t.commit=e.commit),void 0!==e.tag&&(t.tag=e.tag),void 0!==e.push&&(t.push=e.push),void 0!==e.gpg&&(t.gpg=e.gpg)})(e,t),t},No=new Set(["true","yes","on","1"]),Ro=e=>null===e||No.has(e.toLowerCase()),Po=BigInt("9223372036854775807"),Fo=BigInt("-9223372036854775808"),Bo=new Map([["k",BigInt(1024)],["K",BigInt(1024)],["m",BigInt(1024)*BigInt(1024)],["M",BigInt(1024)*BigInt(1024)],["g",BigInt(1024)*BigInt(1024)*BigInt(1024)],["G",BigInt(1024)*BigInt(1024)*BigInt(1024)]]),Wo=e=>{const t=(e??"").replace(/^[ \t]+/,""),n="+"===t[0]||"-"===t[0]?t.slice(1):t,o=(e=>{const t=/^0[xX][0-9a-fA-F]+/.exec(e);if(null!==t)return{token:t[0],radix:16};if("0"===e[0])return{token:/^0[0-7]*/.exec(e)[0],radix:8};const n=/^[0-9]+/.exec(e);return null===n?null:{token:n[0],radix:10}})(n);if(null===o)return{ok:!1,reason:"invalid unit"};const r=n.slice(o.token.length),s=""===r?BigInt(1):Bo.get(r);if(void 0===s)return{ok:!1,reason:"invalid unit"};const i=((e,t)=>{const n=(16===t?e.slice(2):8===t?e.slice(1):e).replace(/^0+/,"");return n.length>32?null:""===n?BigInt(0):BigInt(`${16===t?"0x":8===t?"0o":""}${n}`)})(o.token,o.radix);if(null===i)return{ok:!1,reason:"out of range"};const a=("-"===t[0]?-i:i)*s;return a<Fo||a>Po?{ok:!1,reason:"out of range"}:{ok:!0,value:Number(a)}};async function jo(e){const t=await Cn(e),{name:n,email:o}=(r=t.user,void 0!==r?.name&&void 0!==r?.email?{name:r.name,email:r.email}:{name:"tsgit",email:"tsgit@localhost"});var r;return{name:n,email:o,timestamp:Math.floor(Date.now()/1e3),timezoneOffset:"+0000"}}const zo=268435456,Ho=1e6,Go=1048576;async function Ko(e,t,n){await e.fs.appendUtf8(vn(pn(e,t),t),ht(n))}async function Vo(e,t){return e.fs.exists(vn(pn(e,t),t))}async function Yo(e,t){const n=vn(pn(e,t),t);await e.fs.exists(n)&&await e.fs.rm(n)}async function qo(e,t,n){const o=await e.fs.readdir(t),r=[];for(const s of o){const o=""===n?s.name:`${n}/${s.name}`;s.isDirectory?r.push(...await qo(e,`${t}/${s.name}`,o)):r.push(o)}return r}async function Xo(e,t,n,o,r){if(!await async function(e,t){if(await Vo(e,t))return!0;return function(e,t){return"always"===t.logAllRefUpdates||!1!==t.logAllRefUpdates&&(!0===t.logAllRefUpdates||!0!==t.bare)&&function(e){return"HEAD"===e||mt.some(t=>e.startsWith(t))}(e)}(t,(await Cn(e)).core??{})}(e,t))return;const s=await jo(e);await Ko(e,t,{oldId:n,newId:o,identity:s,message:gt(r)})}const Jo=new WeakMap;function Qo(e){let t=Jo.get(e);return void 0===t&&(t=function(e){let t;const n=t=>pn(e,t);async function o(){const n=`${hn(e)}/packed-refs`;if(!await e.fs.exists(n))return{entries:[],peeling:"none",sorted:!1};const o=await e.fs.stat(n),r=`${o.mtimeMs}:${o.size}`;if(void 0!==t&&t.mtimeKey===r)return t.parsed;const s=function(e){if(""===e)return{entries:[],peeling:"none",sorted:!1};const t=e.split("\n"),{peeling:n,sorted:o,startIndex:r}=function(e){const t=e[0];if(t?.startsWith("# pack-refs with:")){const e=t.slice(17).trim(),n=""===e?[]:e.split(/\s+/),o=n.includes("peeled");return{peeling:n.includes("fully-peeled")?"fully":o?"tags":"none",sorted:n.includes("sorted"),startIndex:1}}return{peeling:"none",sorted:!1,startIndex:0}}(t);return{entries:function(e,t){const n=[];for(let o=t;o<e.length;o++){const t=e[o];if(void 0===t||""===t||t.startsWith("#"))continue;if(t.startsWith("^")){if(0===n.length)throw vt("peel line without preceding ref entry");const e=X.from(t.slice(1)),o=n.length-1;n[o]={...n[o],peeled:e};continue}const r=t.indexOf(" ");if(-1===r)throw vt(`invalid ref line format: ${t.slice(0,80)}`);const s=t.slice(0,r),i=t.slice(r+1),a=X.from(s);n.push({name:Q.from(i),id:a})}return n}(t,r),peeling:n,sorted:o}}(await e.fs.readUtf8(n));return t={parsed:s,mtimeKey:r},s}async function r(t){const o=wn(n(t),t);if(await e.fs.exists(o))return e.fs.readUtf8(o)}return{async resolveDirect(e){const t=await r(e);if(void 0!==t){const e=Ct(t);return"symbolic"===e.type?{kind:"symbolic",target:e.target}:{kind:"direct",id:e.target}}const n=await o();for(const t of n.entries)if(t.name===e)return{kind:"direct",id:t.id};return{kind:"missing"}},async writeLoose(t,o){const r=wn(n(t),t);await e.fs.writeUtf8(r,function(e){return`${e}\n`}(o))},async removeLoose(t){const o=wn(n(t),t);await e.fs.exists(o)&&await e.fs.rm(o)},isLoose:async t=>e.fs.exists(wn(n(t),t)),readLooseRaw:async e=>r(e),getPackedRefs:o}}(e),Jo.set(e,t)),t}const Zo="HEAD",er=(e,t)=>e.endsWith("/")?`${e}${t}`:`${e}/${t}`,tr=new Map([["binary",new Map([["diff",!1],["merge",!1],["text",!1]])]]),nr=(e,t)=>{const n=new Map;for(const[o,r]of e){const e=!0===r?t.get(o):void 0;if(n.set(o,r),void 0!==e)for(const[t,o]of e)n.set(t,o)}return n},or=e=>"t"===e?"\t":"n"===e?"\n":"r"===e?"\r":e,rr=e=>{if(e.startsWith('"')){const{value:t,end:n}=(e=>{let t="",n=1;for(;n<e.length;){const o=e[n];if("\\"===o){const o=e[n+1];if(void 0===o)break;t+=or(o),n+=2;continue}if('"'===o){n+=1;break}t+=o,n+=1}return{value:t,end:n}})(e);return{pattern:t,rest:e.slice(n)}}const t=e.search(/\s/);return-1===t?{pattern:e,rest:""}:{pattern:e.slice(0,t),rest:e.slice(t)}},sr=e=>e.split(/\s+/).filter(e=>""!==e),ir=e=>{if(e.startsWith("-")){const t=e.slice(1);return""===t?void 0:{name:t,value:!1}}if(e.startsWith("!")){const t=e.slice(1);return""===t?void 0:{name:t,value:"unspecified"}}const t=e.indexOf("=");if(-1!==t){const n=e.slice(0,t);return""===n?void 0:{name:n,value:{set:e.slice(t+1)}}}return{name:e,value:!0}},ar=e=>{const t=new Map;for(const n of e){const e=ir(n);void 0!==e&&t.set(e.name,e.value)}return t},cr=(e,t,n)=>{const{anchored:o,directoryOnly:r,body:s}=(e=>{const t=e.endsWith("/"),n=t?e.slice(0,-1):e;return{anchored:n.includes("/"),directoryOnly:t,body:n.startsWith("/")?n.slice(1):n}})(e);return{pattern:e,anchored:o,directoryOnly:r,lineNumber:n,compiled:at(s,{anchored:o}),attributes:ar(sr(t))}},dr=e=>{const t=sr(e),[n,...o]=t;if(void 0!==n)return{name:n,attributes:ar(o)}},ur=(e,t,n,o)=>{const r=((e,t)=>{if(""===t)return e;const n=`${t}/`;return e.startsWith(n)?e.slice(n.length):void 0})(t,e.basedir);if(void 0===r)return;let s;for(const t of e.rules){if(!t.compiled.test(r))continue;const e=nr(t.attributes,o).get(n);void 0!==e&&(s=e)}return s},fr=(e,t,n,o)=>{for(const r of e){const e=ur(r,t,n,o);if(void 0!==e)return e}return"unspecified"},lr=(e,t)=>{if("~"===t)return e.layout.homeDir;if(t.startsWith("~/")){if(void 0===e.layout.homeDir)return;return`${e.layout.homeDir}/${t.slice(2)}`}return t},hr=async(t,n,o,r)=>{let s;try{s=await t.fs.lstat(n)}catch(t){if(t instanceof e.TsgitError&&"FILE_NOT_FOUND"===t.data.code)return;throw t}if(s.isFile&&!s.isSymbolicLink){if(s.size>o)throw r((e=>{const t=e.lastIndexOf("/");return-1===t?e:e.slice(t+1)})(n),s.size,o);return t.fs.readUtf8(n)}},pr=async(t,n)=>{const o=await hr(t,n,1048576,e.gitattributesFileTooLarge);return void 0===o?void 0:(e=>{const t=[],n=[],o=e.split("\n");for(let e=0;e<o.length;e+=1){const r=o[e].trim();if(""===r||r.startsWith("#"))continue;if(r.startsWith("[attr]")){const e=dr(r.slice(6));void 0!==e&&n.push(e);continue}const{pattern:s,rest:i}=rr(r);t.push(cr(s,i,e+1))}return{rules:t,macros:n}})(o)},gr=(e,t)=>pr(e,er(e.layout.workDir,""===t?".gitattributes":`${t}/.gitattributes`)),wr=async e=>{const t=await(e=>pr(e,`${hn(e)}/info/attributes`))(e),n=await(async e=>{const t=(await Cn(e)).core?.attributesFile;if(void 0===t||""===t)return;const n=lr(e,t);return void 0!==n?pr(e,n):void 0})(e),o=await gr(e,""),r=((e,t=tr)=>{const n=new Map(t);for(const t of e)n.set(t.name,t.attributes);return n})([...t?.macros??[],...o?.macros??[],...n?.macros??[]]),s=new Map([["",o]]),i=async t=>{if(s.has(t))return s.get(t);const n=await gr(e,t);return s.set(t,n),n};return{sourcesForPath:async e=>{const o=[];void 0!==t&&o.push({basedir:"",rules:t.rules});for(const t of(e=>{const t=e.split("/");t.pop();const n=[];for(let e=t.length;e>=1;e-=1)n.push(t.slice(0,e).join("/"));return n.push(""),n})(e)){const e=await i(t);void 0!==e&&o.push({basedir:t,rules:e.rules})}return void 0!==n&&o.push({basedir:"",rules:n.rules}),{sources:o,macros:r}}}},mr=async(e,t)=>{const n=fe(t,e.hashConfig);return{bytes:n,id:await e.hash.hashHex(n)}},yr=new TextDecoder,vr=async(e,t)=>{await e.fs.lstat(t).then(()=>!0).catch(()=>!1)&&await e.fs.rm(t)},xr=async(e,t,n,o)=>{await vr(e,t),await e.fs.write(t,n),void 0!==o&&await e.fs.chmod(t,o===p.EXECUTABLE?493:420)},br=async(e,t,n,o)=>{const r=er(e.layout.workDir,t);if(o===p.SYMLINK)return await vr(e,r),void await e.fs.symlink(yr.decode(n),r);o!==p.GITLINK?await xr(e,r,n,o):await e.fs.mkdir(r)},kr=async(e,t,n,o)=>{await vr(e,t),await e.fs.writeStream(t,n),void 0!==o&&await e.fs.chmod(t,o===p.EXECUTABLE?493:420)},Er="empty from",Ir="too many seeds";function Tr(e){return 0===e.length}function Cr(e){return e.length>1024}function Sr(e){return!!(e.includes("\0")||e.includes("\r")||e.includes("\n\n")||e.startsWith("\n")||e.endsWith("\n"))}function $r(e){return 0===e.length||!!(e.includes("\0")||e.includes("\r")||e.includes("\n"))||!(!e.includes(" ")&&!e.includes("\t"))}const Dr="index file exceeds 256 MiB",Or="pack .idx file exceeds 64 MiB";function Lr(e){return e>268435456}function Ar(e){return e>67108864}function Mr(e,t=5){return e>t}function _r(e,t=5){return e>t}function Ur(e){return"160000"===e}function Nr(e,t){return e>t}const Rr=/^[0-9a-f]{40}$/,Pr=/^[0-9a-f]{64}$/;function Fr(e){return Rr.test(e)||Pr.test(e)}function Br(e){return e.isFile&&e.name.endsWith(".idx")&&!(t=e.name).includes("/")&&!t.includes("\\")&&!t.includes("..");var t}async function Wr(e,t,n){const o=`${t}/${n}`,r=await async function(e,t){if(Ar((await e.fs.stat(t)).size))throw Ht(Or);const n=await e.fs.read(t);if(Ar(n.length))throw Ht(Or);return n}(e,o),s=function(e){if(e.length<1032)throw Ht("truncated: file too short for header and fanout");const t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0);if(4285812579!==n)throw Ht(`invalid magic: expected 0xff744f63, got 0x${n.toString(16).padStart(8,"0")}`);const o=t.getUint32(4);if(2!==o)throw Ht(`unsupported version: expected 2, got ${o}`);!function(e){let t=0;for(let n=0;n<256;n++){const o=e.getUint32(8+4*n);if(o<t)throw Ht(`non-monotonic fanout at index ${n}: ${t} > ${o}`);t=o}}(t);const r=t.getUint32(1028),s=nn+r*on,i=s+4*r,a=i+4*r,c=e.length-40,d=nn+r*on+4*r+4*r+40;if(e.length<d)throw Ht(`truncated: expected at least ${d} bytes for ${r} objects, got ${e.length}`);return{objectCount:r,crc32TableOffset:s,smallOffsetsTableOffset:i,largeOffsetsTableOffset:a,trailerOffset:c,_bytes:e,_view:t}}(r),i=n.slice(0,-4),a=`${t}/${i}.pack`;let c;return{name:i,index:s,packPath:a,idxPath:o,offsetTable:async()=>{if(void 0!==c)return c;const t=(await e.fs.stat(a)).size,n=function(e){const t=[];for(let n=0;n<e.objectCount;n+=1)t.push(an(e,n));return t}(s),o=[...n].sort((e,t)=>e-t),r=t-e.hashConfig.digestLength;if(r<0)throw Ht("pack file too small to contain a trailer");return c={sortedOffsets:o,packFileSize:t,trailerStart:r},c}}}function jr(e,t){const{sortedOffsets:n,trailerStart:o}=e,r=function(e,t){let n=0,o=e.length;for(;n<o;){const r=n+o>>>1;e[r]<t?n=r+1:o=r}return n}(n,t);if(r>=n.length||n[r]!==t)throw Ht("offset not in pack index: corrupt index");return r===n.length-1?o:n[r+1]}function zr(e){let t;async function n(){if(void 0!==t)return t;const n=`${hn(e)}/objects/pack`;if(!await e.fs.exists(n))return t=[],t;const o=await e.fs.readdir(n),r=[];for(const t of o)Br(t)&&r.push(await Wr(e,n,t.name));return t=r,t}return{all:n,refresh(){t=void 0},async lookup(e){const t=await n();for(const n of t){const t=cn(n.index,e);if(void 0!==t)return{pack:n,offset:t}}}}}async function Hr(e,t,n,o,r){Vr(e);const s=await async function(e,t){const n=gn(hn(e),t);if(!await e.fs.exists(n))return;const o=await e.fs.read(n);return e.compressor.inflate(o)}(e,n);if(void 0!==s)return Vr(e),function(e,t,n){if(void 0===n)return;const{contentOffset:o}=ne(t),r=t.length-o;if(r>n)throw h(e,r,n)}(n,s,r),qr(e,n,s,o);Vr(e);const i=await t.lookup(n);if(void 0===i)throw c(n);Vr(e);const a=await Xr(e,t,i,n,r);return Vr(e),qr(e,n,a,o)}function Gr(e,t,n){if(void 0!==n&&t>n)throw h(e,t,n)}function Kr(e,t,n,o){if(void 0===n)return;if(1!==o)return;const r=function(e){const{nextOffset:t}=Yt(e,0),{value:n}=Yt(e,t);return n}(t);if(r>n)throw h(e,r,n)}function Vr(t){if(!0===t.signal?.aborted)throw e.operationAborted()}async function Yr(e,t){const n=gn(hn(e),t);if(await e.fs.exists(n))return e.fs.read(n)}async function qr(e,t,n,o){if(o){const o=await e.hash.hashHex(n);if(Vr(e),o!==t)throw d(t,o)}return ue(t,n,e.hashConfig)}async function Xr(e,t,n,o,r){const s=await async function(e,t,n,o,r){const s=[];let i=n,a=0;const d=await n.pack.offsetTable();for(;;){Vr(e);const n=jr(d,i.offset);if(n>d.packFileSize)throw Ht("next offset exceeds pack file size: corrupt index");const{header:u,chunk:f,headerEndInChunk:l}=await Qr(e,i,n);if(Jr(u))return Gr(o,u.size,r),{deltas:s,baseContent:await e.compressor.inflate(f.subarray(l)),baseType:u.type};if(a+=1,a>50)throw Vt(a);const h=await e.compressor.inflate(f.subarray(l));if(Kr(o,h,r,a),6===u.type){const e=i.offset-u.baseDistance;if(e<0)throw c(o);s.push({instructions:h,resolvedBaseId:void 0}),i={pack:i.pack,offset:e};continue}if(7===u.type){const n=u.baseId;s.push({instructions:h,resolvedBaseId:n});const o=await Zr(e,t,n,r);return{deltas:s,baseContent:o.content,baseType:o.type}}throw c(o)}}(e,t,n,o,r);let i=s.baseContent;for(let e=s.deltas.length-1;e>=0;e-=1){const t=s.deltas[e];if(void 0===t)break;i=Qt(i,t.instructions)}if(void 0!==r&&i.length>r)throw h(o,i.length,r);const a=function(e,t,n){const o=function(e,t){switch(e){case 1:return"commit";case 2:return"tree";case 3:return"blob";case 4:return"tag";default:throw c(t)}}(t,n),r=`${o} ${e.length}\0`,s=(new TextEncoder).encode(r),i=new Uint8Array(s.length+e.length);return i.set(s,0),i.set(e,s.length),i}(i,s.baseType,o);return ns(e.deltaCache,o,a),a}function Jr(e){return 1===e.type||2===e.type||3===e.type||4===e.type}async function Qr(e,t,n){const o=n-t.offset;if(o<=0)throw Ht("slice length ≤ 0: next offset not beyond entry offset");const r=await e.fs.readSlice(t.pack.packPath,t.offset,o),s=en(r,0,e.hashConfig);return{header:s,chunk:r,headerEndInChunk:s.dataOffset}}async function Zr(e,t,n,o){const r=e.deltaCache.get(n);if(void 0!==r)return function(e,t,n){if(void 0===n)return;const o=t.indexOf(0);if(o<0)return;const r=t.length-(o+1);if(r>n)throw h(e,r,n)}(n,r,o),es(r,n);const s=fe(await Hr(e,t,n,!1,o),e.hashConfig);return ns(e.deltaCache,n,s),es(s,n)}function es(e,t){const n=e.indexOf(0);if(n<0)throw c(t);const o=e.subarray(0,n).indexOf(32);if(o<0)throw c(t);const r=(new TextDecoder).decode(e.subarray(0,o));return{content:e.subarray(n+1),type:ts(r,t)}}function ts(e,t){switch(e){case"commit":return 1;case"tree":return 2;case"blob":return 3;case"tag":return 4;default:throw c(t)}}function ns(e,t,n){e.set(t,n,n.length)}const os=new WeakMap,rs=new WeakMap;function ss(e){let t=os.get(e);return void 0===t&&(t=zr(e),os.set(e,t)),t}async function is(t,n,o){const r=o?.verifyHash??!0,s=ss(t);try{return await Hr(t,s,n,r,o?.maxBytes)}catch(i){const a=t.promisor;if(void 0===a||!function(t){return t instanceof e.TsgitError&&"OBJECT_NOT_FOUND"===t.data.code}(i))throw i;if(!await async function(e,t,n){const o=function(e){let t=rs.get(e);return void 0===t&&(t=new Map,rs.set(e,t)),t}(e),r=o.get(n);if(void 0!==r)return r;const s=t.fetch([n]).then(e=>e.attempted);o.set(n,s);try{return await s}finally{o.delete(n)}}(t,a,n))throw i;return s.refresh(),Hr(t,s,n,r,o?.maxBytes)}}async function as(e,t,n){const o=await is(e,t,n);if("blob"!==o.type)throw u("blob",o.type,t);return o}const cs={kind:"identity"},ds=async(e,t,n)=>{const{sources:o,macros:r}=await t.sourcesForPath(n);return((e,t)=>!1===t||!0===t||"unspecified"===t?Promise.resolve(cs):(async(e,t)=>{const n=(await Cn(e)).filter?.get(t);return void 0===n?cs:{kind:"external",name:t,...void 0!==n.clean&&{clean:n.clean},...void 0!==n.smudge&&{smudge:n.smudge},required:n.required??!1}})(e,t.set))(e,fr(o,n,"filter",r))},us=async(e,t,n,o)=>{const{gitDir:r,workDir:s}=e.layout,i=await t.run({command:n,cwd:s,env:{GIT_DIR:r},stdin:o,...void 0!==e.signal?{signal:e.signal}:{}});return 0!==i.exitCode?{ok:!1,exitCode:i.exitCode}:{ok:!0,bytes:i.stdout??new Uint8Array(0)}};async function fs(t,n,r){const s=r?.verifyHash??!0;if(!0===t.signal?.aborted)throw e.operationAborted();const i=await Yr(t,n);if(void 0!==i)return function(t,n,r,s){const i=async function*(t,n,r,s){const i=s?t.hash.createHasher():void 0,a=r[Symbol.asyncIterator](),c=await a.next();if(!0===c.done)throw o(`inflate stream produced no output for object ${n}`);const d=await async function(e,t,n){let r=n;for(;;){const n=r.indexOf(0);if(-1!==n){const{type:t}=ne(r);if("blob"!==t)throw u("blob",t,e);return{headerBytes:r.subarray(0,n+1),content:r.subarray(n+1)}}const s=await t.next();if(!0===s.done)throw o(`no NUL terminator found in inflated object ${e}`);r=ps(r,s.value)}}(n,a,c.value);i?.update(d.headerBytes),d.content.length>0&&(i?.update(d.content),yield d.content);for await(const n of{[Symbol.asyncIterator]:()=>a}){if(!0===t.signal?.aborted)throw e.operationAborted();i?.update(n),yield n}await ls(i,n)}(t,n,hs(t,r),s);return Object.assign(i,{materialised:!1})}(t,n,i,s);const a=ss(t),d=await a.lookup(n);if(void 0===d)throw c(n);const f=jr(await d.pack.offsetTable(),d.offset),{header:l,chunk:h,headerEndInChunk:p}=await Qr(t,d,f);if(Jr(l)){if(3!==l.type)throw u("blob",function(e){switch(e){case 1:return"commit";case 2:return"tree";case 4:return"tag"}}(l.type),n);return function(t,n,o,r,s){const i=async function*(t,n,o,r,s){const i=s?t.hash.createHasher():void 0;if(void 0!==i){const e=(new TextEncoder).encode(`blob ${r}\0`);i.update(e)}for await(const n of o){if(!0===t.signal?.aborted)throw e.operationAborted();i?.update(n),yield n}await ls(i,n)}(t,n,hs(t,o),r,s);return Object.assign(i,{materialised:!1})}(t,n,h.subarray(p),l.size,s)}return async function(e,t,n,o){const{type:r,contentOffset:s}=ne(n);if("blob"!==r)throw u("blob",r,t);const i=n.subarray(0,s),a=n.subarray(s);return Object.assign(async function*(){const n=o?e.hash.createHasher():void 0;n?.update(i),a.length>0&&(n?.update(a),yield a),await ls(n,t)}(),{materialised:!0})}(t,n,await Xr(t,a,d,n,void 0),s)}async function ls(e,t){if(void 0===e)return;const n=await e.digestHex();if(n!==t)throw d(t,n)}function hs(e,n){const o=new ReadableStream({start(e){e.enqueue(n),e.close()}}).pipeThrough(e.compressor.createInflateStream());return t.readableStreamToAsyncIterable(o)}function ps(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}const gs=async(t,n,o)=>!!await t.fs.exists(n)&&!await(async(t,n,o)=>{let r;try{r=await t.fs.read(n)}catch(t){if(t instanceof e.TsgitError&&"FILE_NOT_FOUND"===t.data.code)return!0;throw t}const{id:s}=await mr(t,{type:"blob",content:r});return s===o})(t,n,o),ws=async(e,t,n)=>{const o=er(t,n.path);if("update"===n.kind||"delete"===n.kind){if(void 0===n.previousId)return;return await gs(e,o,n.previousId)?{class:"local-changes",path:n.path}:void 0}if("add"===n.kind)return await(async(e,t)=>e.fs.exists(t))(e,o)?{class:"untracked",path:n.path}:void 0},ms=async(t,n,o,r)=>{const s=er(n,o.path);if("noop"!==o.kind)if("delete"!==o.kind){if(void 0!==o.id)return await(async(t,n,o,r,s)=>{if(r===p.GITLINK)return void await br(t,n,new Uint8Array,r);if(r===p.SYMLINK){const e=await as(t,o);return void await br(t,n,e.content,r)}if(void 0!==s&&void 0!==t.command){const i=await ds(t,s,n);if("external"===i.kind&&void 0!==i.smudge){const s=await as(t,o),a=await us(t,t.command,i.smudge,s.content);if(!a.ok){if(i.required)throw e.smudgeFilterFailed(n,i.name,a.exitCode);return void await br(t,n,s.content,r)}return void await br(t,n,a.bytes,r)}}const i=await fs(t,o);await(async(e,t,n,o)=>{await kr(e,er(e.layout.workDir,t),n,o)})(t,n,i,r)})(t,o.path,o.id,o.mode,r),(async(e,t,n,o,r)=>{const s=await e.fs.lstat(t);return{ctimeSeconds:Math.floor(s.ctimeMs/1e3),ctimeNanoseconds:Number(s.ctimeNs??0n)%1e9,mtimeSeconds:Math.floor(s.mtimeMs/1e3),mtimeNanoseconds:Number(s.mtimeNs??0n)%1e9,dev:s.dev,ino:s.ino,mode:r,uid:s.uid,gid:s.gid,fileSize:s.size,id:o,flags:D,path:n}})(t,s,o.path,o.id,o.mode)}else await vr(t,s)},ys=async(t,n)=>{const{changeset:o,force:r,workdir:s}=n;if(!r){const n=await(async(e,t,n)=>{const o=[],r=[];for(const s of n.entries){const n=await ws(e,t,s);void 0!==n&&("local-changes"===n.class?o.push(n.path):r.push(n.path))}return{localChanges:o.sort(Se),untracked:r.sort(Se)}})(t,s,o);if(n.localChanges.length>0||n.untracked.length>0)throw e.checkoutOverwriteDirty(n)}let i;return(async(e,t,n,o)=>{const r=[];let s=0,i=0;for(const a of t.entries){const c=void 0!==e.command?await o():void 0,d=await ms(e,n,a,c);"delete"===a.kind?i+=1:"add"!==a.kind&&"update"!==a.kind||(s+=1,void 0!==d&&r.push(d)),"noop"!==a.kind&&e.progress.update("checkout:materialize",s+i,t.stats.add+t.stats.update+t.stats.delete,a.path)}return{writtenEntries:r,written:s,deleted:i}})(t,o,s,()=>i??=wr(t))},vs=(e,t,n)=>void 0===t&&void 0!==n?{kind:"add",path:e,mode:n.mode,id:n.id,previousId:void 0,previousMode:void 0}:void 0!==t&&void 0===n?{kind:"delete",path:e,mode:t.mode,id:void 0,previousId:t.id,previousMode:t.mode}:{kind:t.id===n.id&&t.mode===n.mode?"noop":"update",path:e,mode:n.mode,id:n.id,previousId:t.id,previousMode:t.mode},xs=(e,t)=>{const n=(e=>{const t=new Map;for(const n of e.entries)0===n.flags.stage&&t.set(n.path,{id:n.id,mode:n.mode});return t})(e),o=(e=>{const t=new Map;for(const n of e)t.set(n.path,n);return t})(t),r=new Set;for(const e of n.keys())r.add(e);for(const e of o.keys())r.add(e);const s=[],i={add:0,update:0,delete:0,noop:0};for(const e of[...r].sort()){const t=vs(e,n.get(e),o.get(e));s.push(t),i[t.kind]+=1}return{entries:s,stats:i}};async function*bs(e,t,n){const o={ctx:e,recursive:n?.recursive??!0,maxDepth:n?.maxDepth??1024,maxEntries:n?.maxEntries??C},r="string"==typeof t?await async function(e,t){const n=await is(e,t);if("tree"!==n.type)throw u("tree",n.type,t);return n}(e,t):t;yield*ks(o,{value:0},r,"",0,[])}async function*ks(t,n,o,r,s,i){if(i.includes(o.id))throw new e.TsgitError({code:"TREE_CYCLE_DETECTED",id:o.id});if(function(e,t){return e>t}(s,t.maxDepth))throw f(s);const a=[...i,o.id];for(const i of o.entries){if(t.ctx.signal?.aborted)throw e.operationAborted();const o=""===r?i.name:`${r}/${i.name}`;if(n.value+=1,Nr(n.value,t.maxEntries))throw l(n.value,t.maxEntries);if(yield{path:o,id:i.id,mode:i.mode},!Es(t.recursive,i.mode))continue;const c=await is(t.ctx,i.id);"tree"===c.type&&(yield*ks(t,n,c,o,s+1,a))}}function Es(e,t){return!!e&&y(t)}const Is=(e,t)=>e.filter(e=>t.has(e.path)),Ts=(e,t,n)=>t.get(e)??n.get(e),Cs=e=>{const t={add:0,update:0,delete:0,noop:0};for(const n of e)t[n.kind]+=1;return t},Ss=async(e,t)=>{const n=await(async(e,t)=>{const n=[];for await(const o of bs(e,t))o.mode!==p.DIRECTORY&&n.push({path:o.path,id:o.id,mode:o.mode});return n})(e,t.targetTree),o=((e,t)=>{if(void 0!==t.paths)return{target:Is(e,t.paths),indexForDiff:{...t.currentIndex,entries:Is(t.currentIndex.entries,t.paths)},excluded:[]};const n=t.sparse;if(void 0!==n){const o=[],r=[];for(const t of e)(n(t.path)?o:r).push(t);return{target:o,indexForDiff:{...t.currentIndex,entries:t.currentIndex.entries.filter(e=>!e.flags.skipWorktree)},excluded:r}}return{target:e,indexForDiff:t.currentIndex,excluded:[]}})(n,t),r=xs(o.indexForDiff,o.target),s=!0===t.forceRewriteAll?(e=>{const t=e.entries.map(e=>"noop"===e.kind?{...e,kind:"update"}:e);return{entries:t,stats:Cs(t)}})(r):r,i=await ys(e,{changeset:s,force:t.force??!1,workdir:e.layout.workDir}),a=((e,t,n,o)=>{const r=(e=>{const t=new Map;for(const n of e)t.set(n.path,n);return t})(e),s=(e=>{const t=new Map;for(const n of e.entries)0===n.flags.stage&&t.set(n.path,n);return t})(t),i=((e,t)=>{if(void 0===t)return[];const n=[];for(const[o,r]of e)t.has(o)||n.push(r);return n})(s,o);for(const e of n){const t=Ts(e.path,r,s);void 0!==t&&i.push(t)}return i.sort((e,t)=>e.path<t.path?-1:1),i})(i.writtenEntries,t.currentIndex,o.target,t.paths);var c;return{newIndexEntries:0===o.excluded.length?a:(c=[...a,...o.excluded.map(O)],[...c].sort(xe)),written:i.written,deleted:i.deleted}};async function $s(e){const t=mn(e.layout.gitDir);if(!await e.fs.exists(t))return{version:2,entries:[],extensions:[],trailerSha:new Uint8Array(0)};if(Lr((await e.fs.stat(t)).size))throw S(Dr);const n=await e.fs.read(t);if(Lr(n.length))throw S(Dr);const o=e.hashConfig.digestLength;if(n.length<o)throw S("file is shorter than the hash trailer");const r=n.subarray(0,n.length-o),s=A(n.subarray(n.length-o));if(await e.hash.hashHex(r)!==s)throw S("index trailer checksum mismatch");return function(e){if(e.length<12)throw S("truncated header");const t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(1145655875!==t.getUint32(0))throw S("invalid signature: expected DIRC");const n=t.getUint32(4);if(2!==n&&3!==n)throw S(`unsupported version: ${n}`);const o=t.getUint32(8);if(62*o>e.length-12-20)throw S(`entry count ${o} exceeds file capacity`);let r=12;const s=[];for(let i=0;i<o;i++){const o=r;if(r+62>e.length-20)throw $(r,"truncated entry");const i=t.getUint32(r),a=t.getUint32(r+4),c=t.getUint32(r+8),d=t.getUint32(r+12),u=t.getUint32(r+16),f=t.getUint32(r+20),l=t.getUint32(r+24),h=t.getUint32(r+28),p=t.getUint32(r+32),g=t.getUint32(r+36),w=A(e.subarray(r+40,r+60)),y=t.getUint16(r+60),{flags:v,extendedSize:x}=ye(t,r,n,e.length),b=m(l.toString(8));r+=62+x;const k=ve(e,r);if(-1===k)throw $(o,"missing NUL terminator");const E=4095&y,I=W(e.subarray(r,4095===E?k:r+E));me(I,o),r=k+1,r=o+(r-o+7&-8),s.push({ctimeSeconds:i,ctimeNanoseconds:a,mtimeSeconds:c,mtimeNanoseconds:d,dev:u,ino:f,mode:b,uid:h,gid:p,fileSize:g,id:w,flags:v,path:Z.from(I)})}const i=function(e,t,n){const o=[],r=e.length-20;for(;t+8<=r;){const s=W(e.subarray(t,t+4)),i=n.getUint32(t+4);if(t+8+i>r)throw $(t,"extension size exceeds remaining bytes");const a=s.charCodeAt(0);if(a>=97&&a<=122){const e=s.replace(/[^\x20-\x7e]/g,"?");throw $(t,`mandatory extension '${e}' not supported`)}const c=e.slice(t+8,t+8+i);o.push({signature:s,data:c}),t+=8+i}return o}(e,r,t);return{version:n,entries:s,extensions:i,trailerSha:e.slice(e.length-20)}}(n)}const Ds=1048576,Os=new TextDecoder,Ls=async t=>{const n=xn(t.layout.gitDir);let o;try{o=await t.fs.read(n)}catch(t){if(t instanceof e.TsgitError&&"FILE_NOT_FOUND"===t.data.code)return;throw t}if(o.byteLength>Ds)throw e.sparsePatternFileTooLarge("info/sparse-checkout",o.byteLength,Ds);return Os.decode(o)},As=(t,n)=>new e.TsgitError(void 0===n?{code:"RESOURCE_LOCKED",resource:"index",path:t}:{code:"RESOURCE_LOCKED",resource:"index",path:t,mtimeMs:n}),Ms=async(t,n={})=>{const o=`${mn(t.layout.gitDir)}${bn}`,r=mn(t.layout.gitDir),s=n.now??(()=>Date.now()),i=t.config?.breakStaleLockMs;try{await t.fs.writeExclusive(o,new Uint8Array)}catch(n){if(!(n instanceof e.TsgitError)||"FILE_EXISTS"!==n.data.code)throw n;if(void 0===i)throw As(o,await _s(t,o));await Us(t,o,i,s)}return Ns(t,o,r)},_s=async(e,t)=>{try{return(await e.fs.lstat(t)).mtimeMs}catch{return}},Us=async(t,n,o,r)=>{const s=await _s(t,n);if(void 0===s)return void await t.fs.writeExclusive(n,new Uint8Array);const i=r()-s;if(i<0)throw As(n,s);if(i<o)throw As(n,s);await t.fs.rm(n);try{await t.fs.writeExclusive(n,new Uint8Array)}catch(o){if(o instanceof e.TsgitError&&"FILE_EXISTS"===o.data.code)throw As(n,await _s(t,n));throw o}},Ns=(t,n,o)=>{let r=!1,s=!1;return{release:async()=>{if(!r&&!s){s=!0;try{await t.fs.rm(n)}catch(t){if(!(t instanceof e.TsgitError)||"FILE_NOT_FOUND"!==t.data.code)throw t}}},commit:async e=>{if(r||s)return;const i=function(e){const t=[...e.entries].sort(xe),n=t.map(e=>{const t=B(e.path),n=e.flags.skipWorktree||e.flags.intentToAdd;return{entry:e,pathBytes:t,extended:n,paddedLength:62+(n?2:0)+t.length+8&-8}}),o=e.extensions.map(e=>({ext:e,sigBytes:B(e.signature),totalLength:8+e.data.length})),r=12+n.reduce((e,t)=>e+t.paddedLength,0)+o.reduce((e,t)=>e+t.totalLength,0),s=new Uint8Array(r),i=new DataView(s.buffer),a=n.some(e=>e.extended)?3:2;i.setUint32(0,1145655875),i.setUint32(4,a),i.setUint32(8,t.length);let c=12;for(const{entry:e,pathBytes:t,extended:o,paddedLength:r}of n)be(s,i,c,e,t,o),c+=r;for(const{ext:e,sigBytes:t,totalLength:n}of o)s.set(t,c),i.setUint32(c+4,e.data.length),s.set(e.data,c+8),c+=n;return s}({entries:[...e],extensions:[]}),a=await t.hash.hash(i),c=new Uint8Array(i.length+a.length);c.set(i,0),c.set(a,i.length),await t.fs.write(n,c),await t.fs.rename(n,o),r=!0}}},Rs=new TextEncoder,Ps=new Set([".git"]),Fs=e=>{""===e&&Ws(e),zs(e)>4096&&Ws(e),e.startsWith("/")&&Ws(e),e.includes("\\")&&Ws(e),e.includes("\0")&&Ws(e);const t=e.split("/");for(const n of t)js(n,e);return e},Bs=e=>{const t=e.toLowerCase();return!!Ps.has(t)||".git"===t.replace(/[. ]+$/,"")},Ws=t=>{throw e.pathspecOutsideRepo(t)},js=(e,t)=>{""===e&&Ws(t),"."!==e&&".."!==e||Ws(t),zs(e)>255&&Ws(t),Bs(e)&&Ws(t),e.includes(":")&&Ws(t);for(let n=0;n<e.length;n+=1){const o=e.charCodeAt(n);(o<=31||127===o)&&Ws(t)}},zs=e=>Rs.encode(e).length,Hs=(e,t)=>""===e?t:`${e}/${t}`;async function*Gs(t,n,o,r,s){if(r>t.maxDepth)throw f(r);const i=await t.ctx.fs.readdir(Vs(t,o));if(s||!i.some(Ys))for(const s of i){if(t.ctx.signal?.aborted)throw e.operationAborted();Bs(s.name)||(yield*Ks(t,n,o,r,s))}}async function*Ks(e,t,n,o,r){const s=Hs(n,r.name);if(Fs(s),r.isDirectory&&!r.isSymbolicLink){if(void 0!==e.ignore&&await e.ignore(s,!0))return;return void(yield*Gs(e,t,s,o+1,!1))}if(!r.isFile&&!r.isSymbolicLink)return;if(void 0!==e.ignore&&await e.ignore(s,!1))return;if(t.value+=1,t.value>e.maxEntries)throw l(t.value,e.maxEntries);const i=await e.ctx.fs.lstat(er(e.ctx.layout.workDir,s));yield{path:s,stat:i}}const Vs=(e,t)=>""===t?e.ctx.layout.workDir:er(e.ctx.layout.workDir,t),Ys=e=>!!Bs(e.name)&&(e.isDirectory||e.isFile&&!e.isSymbolicLink);async function qs(t,n){if(t.signal?.aborted)throw e.operationAborted();const{bytes:o,id:r}=await mr(t,n),s=n.id;if(""!==s&&s!==r)throw d(n.id,r);if(t.signal?.aborted)throw e.operationAborted();const i=await Cn(t),a=i.core?.looseCompression,c=r.slice(0,2);await t.fs.mkdir(yn(t.layout.gitDir,c));const u=gn(t.layout.gitDir,r),f=void 0!==a&&a>=-1&&a<=9?await t.compressor.deflate(o,a):await t.compressor.deflate(o);try{await t.fs.writeExclusive(u,f)}catch(e){if(Xs(e))return r;throw e}return r}function Xs(t){return t instanceof e.TsgitError&&"FILE_EXISTS"===t.data.code}const Js=async(e,t)=>{const n=er(e.layout.workDir,""===t?".gitignore":`${t}/.gitignore`);return Qs(e,n)},Qs=async(t,n)=>{const o=await hr(t,n,1048576,e.gitignoreFileTooLarge);return void 0===o?void 0:(e=>{const t=[],n=e.split("\n");for(let e=0;e<n.length;e+=1){const o=n[e],r=ut(o);if(void 0===r)continue;const{negated:s,anchored:i,directoryOnly:a,cleanPattern:c}=r;t.push({pattern:dt(ct(o)),negated:s,directoryOnly:a,anchored:i,lineNumber:e+1,compiled:at(c,{anchored:i})})}return t})(o)},Zs=async e=>{const t=[],n=await(async e=>{const t=await Cn(e),n=t.core?.excludesFile;if(void 0===n||""===n)return;const o=lr(e,n);return void 0!==o?Qs(e,o):void 0})(e);void 0!==n&&t.push({basedir:"",rules:n,kind:"global"});const o=await(async e=>Qs(e,`${hn(e)}/info/exclude`))(e);void 0!==o&&t.push({basedir:"",rules:o,kind:"info"});const r=await Js(e,"");void 0!==r&&t.push({basedir:"",rules:r,kind:"gitignore"});const s=new Map;return{base:t,loadDirRules:async t=>{const n=s.get(t);if(void 0!==n)return n;const o=await Js(e,t)??[];return s.set(t,o),o}}};async function ei(e,t,n){const o=n?.maxSymbolicDepth??5,r=n?.maxPeelDepth??5,s=n?.peel??!1,i=Qo(e),a=await async function(e,t,n){const o=[];let r=t,s=0;for(;;){if("HEAD"!==r&&Tt(r),o.includes(r))throw kt([...o,r]);o.push(r);const t=await e.resolveDirect(r);if("missing"===t.kind)throw xt(r);if("direct"===t.kind)return t.id;if(s+=1,Mr(s,n))throw bt(s,o);r=t.target}}(i,t,o);return s?async function(e,t,n){let o=t,r=0;for(;;){const t=await is(e,o);if("tag"!==t.type)return o;if(r+=1,_r(r,n))throw bt(r,[]);o=t.data.object}}(e,a,r):a}async function ti(e,t){let n=Fr(t)?t:await ei(e,t),o=await is(e,n),r=0;for(;"commit"===o.type||"tag"===o.type;){if(r+=1,r>5)throw bt(r,[]);n="commit"===o.type?o.data.tree:o.data.object,o=await is(e,n)}if("tree"!==o.type)throw u("tree",o.type,n);return o}const ni=e=>e-1>>1,oi=e=>2*e+1,ri=e=>2*e+2,si=(e,t,n)=>{const o=e[t];e[t]=e[n],e[n]=o},ii=(e,t,n,o)=>o<e.length&&t(e[o],e[n])?o:n;class ai{less;values=[];constructor(e){this.less=e}push(e){this.values.push(e),((e,t)=>{let n=this.values.length-1;for(;n>0&&t(e[n],e[ni(n)]);)si(e,n,ni(n)),n=ni(n)})(this.values,this.less)}pop(){if(0===this.values.length)return;const e=this.values[0],t=this.values.pop();return this.values.length>0&&(this.values[0]=t,((e,t)=>{let n=0;for(;;){const o=oi(n);if(o>=e.length)return;const r=ii(e,t,o,ri(n));if(!t(e[r],e[n]))return;si(e,n,r),n=r}})(this.values,this.less)),e}size(){return this.values.length}entries(){return this.values}}const ci=(e,t)=>e.date>t.date||e.date===t.date&&e.oid<t.oid;async function di(e,t,n){const o=new Array(e.length);let r=0;const s=async()=>{for(;r<e.length;){const t=r++;o[t]=await n(e[t])}},i=Math.min(t,e.length),a=[];for(let e=0;e<i;e++)a.push(s());return await Promise.all(a),o}async function ui(e,t){return di(t,32,async t=>({id:t,bytes:(await as(e,t)).content}))}function fi(e,t){const n=[];for(const t of e)n.push({oldPath:t.oldPath,oldId:t.oldId,oldMode:t.oldMode});for(const e of t)"modify"!==e.type&&"type-change"!==e.type||Te(e.oldMode)||n.push({oldPath:e.path,oldId:e.oldId,oldMode:e.oldMode});return n}function li(e,t){const n=new Map;for(const o of e){if(n.has(o))continue;const e=t.get(o);void 0!==e&&n.set(o,{chunkMap:ze(e),size:e.length})}return n}function hi(e,t,n,o,r){if(function(e,t,n){const o=Math.max(e,t),r=Math.min(e,t);return o*(We-n)<(o-r)*We}(e.size,t.size,n))return;const s=function(e,t,n,o){const r=Math.max(t,o);if(0===r)return We;if(0===t||0===o)return 0;const s=He(e,n);return Math.trunc(s*We/r)}(e.chunkMap,e.size,t.chunkMap,t.size);s>=n&&function(e,t){if(e.length<4)return void e.push(t);let n=0;for(let t=1;t<e.length;t++){const o=e[t],r=e[n];void 0!==o&&void 0!==r&&o.score<r.score&&(n=t)}const o=e[n];void 0!==o&&t.score>o.score&&(e[n]=t)}(r,{...o,score:s})}function pi(e,t,n){return{type:"rename",oldPath:e.oldPath,newPath:t.newPath,oldId:e.oldId,newId:t.newId,oldMode:e.oldMode,newMode:t.newMode,similarity:{score:n,maxScore:We}}}function gi(e,t,n){return{type:"copy",oldPath:e.oldPath,newPath:t.newPath,oldId:e.oldId,newId:t.newId,oldMode:e.oldMode,newMode:t.newMode,similarity:{score:n,maxScore:We}}}async function wi(e,t){const{adds:n,deletes:o,threshold:r,copyThreshold:s,copies:i,copySources:a}=t;if(0===o.length&&0===a.length)return null;const c=[...o.map(e=>e.oldId),...a.map(e=>e.oldId)],d=await async function(e,t,n){const[o,r]=await Promise.all([ui(e,t),ui(e,n.map(e=>e.newId))]),s=new Map(o.map(e=>[e.id,e.bytes])),i=new Map(r.map(e=>[e.id,e.bytes]));return{srcFingerprints:li(t,s),dstFingerprints:li(n.map(e=>e.newId),i)}}(e,c,n),u=function(e){const t=new Set,n=new Set,o=[];for(const r of e)if(!n.has(r.add))if("rename"===r.kind){if(t.has(r.src))continue;t.add(r.src),n.add(r.add),o.push({kind:"rename",change:pi(r.src,r.add,r.score),del:r.src,add:r.add})}else n.add(r.add),o.push({kind:"copy",change:gi(r.src,r.add,r.score),add:r.add});return o}(function(e,t,n,o,r,s,{srcFingerprints:i,dstFingerprints:a}){const c=function(e,t,n,o,r){const s=[];for(const i of t){const t=o.get(i.newId);if(void 0===t)continue;const a=[];for(const o of e){const e=n.get(o.oldId);void 0!==e&&hi(e,t,r,{kind:"rename",src:o,add:i,score:0},a)}for(const e of a)s.push(e)}return s}(e,t,i,a,r),d="off"!==o?function(e,t,n,o,r){const s=[];for(const i of t){const t=o.get(i.newId);if(void 0===t)continue;const a=[];for(const o of e){const e=n.get(o.oldId);void 0!==e&&hi(e,t,r,{kind:"copy",src:o,add:i,score:0},a)}for(const e of a)s.push(e)}return s}(n,t,i,a,s):[],u=[...c,...d];return u.sort((e,t)=>t.score!==e.score?t.score-e.score:"rename"===e.kind&&"copy"===t.kind?-1:"copy"===e.kind&&"rename"===t.kind?1:0),u}(o,n,a,i,r,s,d)),f=u.filter(e=>"rename"===e.kind),l=u.filter(e=>"copy"===e.kind);return{renames:f.map(e=>e.change),copyChanges:l.map(e=>e.change),consumedDeletes:new Set(f.map(e=>e.del)),consumedAdds:new Set(u.map(e=>e.add))}}function mi(e,t){const n=e.length,o=Math.max(n,t.length),{srcCopied:r,literalAdded:s}=function(e,t){const n=t.length;if(0===e.length||0===n)return{srcCopied:0,literalAdded:n};const o=He(ze(e),ze(t));return{srcCopied:o,literalAdded:n-o}}(e,t),i=n-r,a=Math.min(i+s,o);return{computedBreakScore:o>0?Math.trunc(a*We/o):0,dissimilarity:n>0?Math.trunc(i*We/n):0}}function yi(e,t,n){const o=new Map(t.map(e=>[e.original.path,e])),r=[];for(const t of e.changes){const e="modify"===t.type&&n.has(t.path)?o.get(t.path):void 0;void 0!==e?r.push(e.del,e.add):r.push(t)}return{changes:r}}function vi(e,t){return e.dissimilarity>=t?{...e.original,broken:{score:e.dissimilarity,maxScore:We}}:e.original}function xi(e,t,n){if(0===t.length)return e;const{presentDels:o,presentAdds:r}=function(e,t){const n=new Set(t.map(e=>e.del)),o=new Set(t.map(e=>e.add)),r=new Set,s=new Set;for(const t of e)"delete"===t.type&&n.has(t)?r.add(t):"add"===t.type&&o.has(t)&&s.add(t);return{presentDels:r,presentAdds:s}}(e,t),s=new Set,i=[];for(const e of t){const t=o.has(e.del),a=r.has(e.add);(t||a)&&t&&a&&(s.add(e.del),s.add(e.add),i.push(vi(e,n)))}return 0===s.size?e:[...e.filter(e=>!s.has(e)),...i]}function bi(e,t,n){return 0===t.length?{changes:$e(e,ke)}:{changes:$e(xi(e,t,n),ke)}}async function ki(e,t,n,o){const{threshold:r,copyThreshold:s,limit:i,copies:a,breakRewrites:c}=function(e){const t=e?.threshold??3e4;return{threshold:t,copyThreshold:e?.copyThreshold??t,limit:e?.limit??1e3,copies:e?.copies??"off",breakRewrites:e?.breakRewrites??!1}}(n),d=function(e){return function(e){return{breakScore:e.score,mergeScore:0===e.merge?36e3:e.merge}}(!1!==e&&void 0!==e?e:{score:3e4,merge:36e3}).mergeScore}(c),{broken:u,workingDiff:f}=await async function(e,t,n){if(!1===n||void 0===n)return{broken:[],workingDiff:t};const o=0!==n.score?n.score:3e4,r=await async function(e,t,n){const o=t.changes.filter(e=>"modify"===e.type&&!Te(e.oldMode));if(0===o.length)return{broken:[],patchedDiff:t};const{records:r,paths:s}=await async function(e,t,n){const o=t.flatMap(e=>[e.oldId,e.newId]),r=await ui(e,o),s=new Map(r.map(e=>[e.id,e.bytes])),i=[],a=new Set;for(const e of t){const t=s.get(e.oldId)??new Uint8Array(0),o=s.get(e.newId)??new Uint8Array(0),{computedBreakScore:r,dissimilarity:c}=mi(t,o);r<n||(i.push({original:e,del:{type:"delete",oldPath:e.path,oldId:e.oldId,oldMode:e.oldMode},add:{type:"add",newPath:e.path,newId:e.newId,newMode:e.newMode},dissimilarity:c}),a.add(e.path))}return{records:i,paths:a}}(e,o,n);return 0===r.length?{broken:[],patchedDiff:t}:{broken:r,patchedDiff:yi(t,r,s)}}(e,t,o);return{broken:r.broken,workingDiff:r.patchedDiff}}(e,t,c),l=function(e,t={}){const n=t.limit??1e3,o=t.maxSameIdDeletes??100,{adds:r,deletes:s,other:i}=function(e){const t=[],n=[],o=[];for(const r of e)"add"===r.type?t.push(r):"delete"===r.type?n.push(r):o.push(r);return{adds:t,deletes:n,other:o}}(e.changes);if(r.length*s.length>n)return e;const a=function(e,t){const n=new Map;for(const t of e){const e=n.get(t.oldId);void 0===e?n.set(t.oldId,[t]):e.push(t)}const o=new Map;for(const[e,r]of n)r.length<=t&&o.set(e,r);return o}(s,o),c=new Set,d=[],u=[];for(const e of r){const t=Ge(e,a);void 0===t?u.push(e):(d.push(t.rename),c.add(t.consumedDelete))}const f=s.filter(e=>!c.has(e));return{changes:$e([...u,...f,...d,...i],ke)}}(f,{...n,limit:Number.MAX_SAFE_INTEGER}),{adds:h,deletes:p,other:g}=function(e){const t=[],n=[],o=[];for(const r of e)"add"===r.type?Te(r.newMode)?o.push(r):t.push(r):"delete"===r.type?Te(r.oldMode)?o.push(r):n.push(r):o.push(r);return{adds:t,deletes:n,other:o}}(l.changes);if(!(h.length>0&&p.length>0||"off"!==a&&h.length>0))return bi(l.changes,u,d);const w=function(e,t,n,o,r,s){if("off"===e)return[];if("on"===e)return fi(n,o);const i=void 0!==r?function(e){const t=[];for(const[n,o]of e)Te(o.mode)||t.push({oldPath:n,oldId:o.id,oldMode:o.mode});return t}(r):fi(n,o);return 0!==s&&t.length*i.length>s*s?fi(n,o):i}(a,h,p,g,o,i);return bi(0!==i&&h.length*(p.length+w.length)>i*i?l.changes:function(e,t,n,o){const r=o?.consumedDeletes??new Set,s=o?.consumedAdds??new Set,i=o?.renames??[],a=o?.copyChanges??[];return[...e.filter(e=>!s.has(e)),...t.filter(e=>!r.has(e)),...i,...a,...n]}(h,p,g,await wi(e,{adds:h,deletes:p,threshold:r,copyThreshold:s,copies:a,copySources:w})),u,d)}const Ei=async(e,t)=>{const n=new Map;for await(const o of bs(e,t))o.mode!==p.DIRECTORY&&n.set(o.path,{id:o.id,mode:o.mode});return{entries:n}},Ii=new Uint8Array(0),Ti={},Ci={patch:"binary",numstat:"binary"},Si={patch:"text",numstat:"text"},$i={patch:"text",numstat:"binary"},Di=new TextEncoder;function Oi(e){return Di.encode(`Subproject commit ${e}\n`)}async function Li(e,t,n){return Te(t)?Oi(n):(await as(e,n)).content}async function Ai(e,t,n,o){const{sources:r,macros:s}=await t.sourcesForPath(n),i=fr(r,n,"diff",s);let a,c=!1;var d,u;return!1!==i&&!0!==i&&"unspecified"!==i&&(a=await async function(e,t){const n=(await Cn(e)).diff?.get(t),o=n?.textconv;return void 0!==o&&""!==o?o:void 0}(e,i.set),c=void 0!==a),{pair:(d=i,u={textconvConfigured:c,rawIsBinary:!!c&&await o()},!1===d?Ci:!0===d?Si:"unspecified"===d?Ti:u.textconvConfigured?u.rawIsBinary?$i:Si:Ti),command:a}}async function Mi(e,t,n,o,r,s,i){return Te(s)?i:(async(e,t,n,o,r)=>{const s=`${e.layout.gitDir}/TEXTCONV_INPUT_${r}`;await e.fs.write(s,o);try{return(await t.run({command:`${n} ${s}`,cwd:e.layout.workDir,env:{GIT_DIR:e.layout.gitDir},...void 0!==e.signal?{signal:e.signal}:{}})).stdout??Ii}finally{await e.fs.rm(s)}})(e,t,n,i,`${r}_${a=ke(o),a.replace(/[^a-zA-Z0-9]/g,"_").slice(0,64)}`);var a}function _i(e,t){return{...e,...void 0!==t.patch?{patchBinaryOverride:t.patch}:{},...void 0!==t.numstat?{numstatBinaryOverride:t.numstat}:{}}}async function Ui(e,t,n,o,r,s,i,a){return void 0===t.runner||void 0===n?[r,s]:Promise.all([Mi(e,t.runner,n,o,"old",i,r),Mi(e,t.runner,n,o,"new",a,s)])}async function Ni(e,t,n){let o;const r=!0===n?.applyTextconv?{runner:e.command,getProvider:()=>o??=wr(e)}:void 0;return di(t,32,t=>async function(e,t,n){return"add"===t.type?async function(e,t,n){if(Te(t.newMode))return{change:t,newContent:Oi(t.newId)};const o=(await as(e,t.newId)).content;if(void 0===n)return{change:t,newContent:o};const r=await n.getProvider(),{pair:s,command:i}=await Ai(e,r,ke(t),()=>Ne(o));return _i({change:t,newContent:void 0!==n.runner&&void 0!==i?await Mi(e,n.runner,i,t,"new",t.newMode,o):o},s)}(e,t,n):"delete"===t.type?async function(e,t,n){if(Te(t.oldMode))return{change:t,oldContent:Oi(t.oldId)};const o=(await as(e,t.oldId)).content;if(void 0===n)return{change:t,oldContent:o};const r=await n.getProvider(),{pair:s,command:i}=await Ai(e,r,ke(t),()=>Ne(o));return _i({change:t,oldContent:void 0!==n.runner&&void 0!==i?await Mi(e,n.runner,i,t,"old",t.oldMode,o):o},s)}(e,t,n):"rename"===t.type||"copy"===t.type?async function(e,t,n){if(t.similarity.score===We){if(void 0===n)return{change:t};const o=await n.getProvider(),{pair:r}=await Ai(e,o,ke(t),async()=>!Te(t.newMode)&&Ne((await as(e,t.newId)).content));return _i({change:t},r)}const[o,r]=await Promise.all([as(e,t.oldId),as(e,t.newId)]);if(void 0===n)return{change:t,oldContent:o.content,newContent:r.content};const s=await n.getProvider(),{pair:i,command:a}=await Ai(e,s,ke(t),()=>Ne(o.content)||Ne(r.content)),[c,d]=await Ui(e,n,a,t,o.content,r.content,t.oldMode,t.newMode);return _i({change:t,oldContent:c,newContent:d},i)}(e,t,n):t.oldId!==t.newId||Te(t.oldMode)||Te(t.newMode)?async function(e,t,n){const[o,r]=await Promise.all([Li(e,t.oldMode,t.oldId),Li(e,t.newMode,t.newId)]);if(void 0===n)return{change:t,oldContent:o,newContent:r};const s=Te(t.oldMode)?new Uint8Array(0):o,i=Te(t.newMode)?new Uint8Array(0):r,a=await n.getProvider(),{pair:c,command:d}=await Ai(e,a,ke(t),()=>Ne(s)||Ne(i)),[u,f]=await Ui(e,n,d,t,o,r,t.oldMode,t.newMode);return _i({change:t,oldContent:u,newContent:f},c)}(e,t,n):async function(e,t,n){const o=(await as(e,t.oldId)).content;if(void 0===n)return{change:t,oldContent:o,newContent:o};const r=await n.getProvider(),{pair:s,command:i}=await Ai(e,r,ke(t),()=>Ne(o)),[a,c]=await Ui(e,n,i,t,o,o,t.oldMode,t.newMode);return _i({change:t,oldContent:a,newContent:c},s)}(e,t,n)}(e,t,r))}const Ri=new Uint8Array(0);function Pi(e,t,n,o){const r=void 0!==o?{numstatBinaryOverride:o}:{};return t?{lineKey:e,ignoreBlankLines:n,...r}:n?{ignoreBlankLines:n,...r}:void 0!==o?{numstatBinaryOverride:o}:void 0}function Fi(e,t){return"modify"===e.type&&0===t.added&&0===t.deleted&&!t.binary}async function Bi(e,t){if(void 0!==t)return"string"==typeof t?ti(e,t):t}async function Wi(e,t){if(void 0===t)return;const n=await Ei(e,t),o=Array.from(n.entries,([e,t])=>({name:e,mode:t.mode,id:t.id}));return{type:"tree",id:t.id,entries:o}}const ji=async(e,t)=>{const n=fe(t,e.hashConfig),o=n.indexOf(0),r=n.subarray(o+1),s=await e.compressor.deflate(r);return{type:zi(t.type),uncompressedSize:r.length,compressedData:s}},zi=e=>{switch(e){case"commit":return 1;case"tree":return 2;case"blob":return 3;case"tag":return 4}},Hi=(t,n)=>{if(t.emitted.has(n))return!1;if(t.emitted.size>=t.cap)throw new e.TsgitError({code:"PACK_TOO_LARGE",objectCount:t.emitted.size+1,limit:t.cap});return t.emitted.add(n),!0},Gi=async(e,t,n)=>{let o=t;for(let t=0;t<16;t+=1){const t=await is(e,o);if("tag"!==t.type)return o;n(o),o=t.data.object}return o},Ki=async(e,t,n)=>{try{const o=await is(e,t,{verifyHash:n.verifyHash});return"commit"===o.type?o:void 0}catch(e){if(n.ignoreMissing&&Vi(e))return void n.missing.add(t);throw e}},Vi=t=>t instanceof e.TsgitError&&"OBJECT_NOT_FOUND"===t.data.code;async function*Yi(t,n){!function(t){if(Tr(t.from))throw e.invalidWalkInput(Er);if(Cr(t.from))throw e.invalidWalkInput(Ir)}(n);const o=n.order??"topo",r=n.ignoreMissing??!1,s=n.verifyHash??!0,i={queue:[...n.from],visited:new Set,missing:new Set,until:new Set(n.until??[]),shallow:n.shallow??new Set};for(;i.queue.length>0;){if(t.signal?.aborted)throw e.operationAborted();const n=i.queue.shift();if(i.visited.has(n)||i.until.has(n))continue;const a=await Ki(t,n,{verifyHash:s,ignoreMissing:r,missing:i.missing});void 0!==a&&(i.visited.add(n),yield a,qi(i,a,o))}}function qi(t,n,o){if(t.shallow.has(n.id))return;const r="first-parent"===o&&n.data.parents.length>0?[n.data.parents[0]]:n.data.parents;for(const n of r)if(!(t.visited.has(n)||t.missing.has(n)||t.until.has(n))){if(t.queue.length>=65536)throw e.invalidWalkInput("walk queue exceeds bound");t.queue.push(n)}}async function Xi(e,t,n){const o=await e.fs.readdir(t),r=[];for(const s of o){const o=`${n}/${s.name}`;s.isDirectory?r.push(...await Xi(e,`${t}/${s.name}`,o)):r.push(o)}return r}const Ji=(e,t)=>e.some(e=>!(4&(t.get(e.oid)??0))),Qi=async(e,t,n)=>{const o=new Map,r=new ai(ci),s=async(t,n)=>{var s;o.set(t,(o.get(t)??0)|n),r.push({oid:t,date:(s=await e(t),s?.data.committer.timestamp??0),value:void 0})};await s(t,1);for(const e of n)await s(e,2);for(;Ji(r.entries(),o);){const{oid:t}=r.pop();let n=7&(o.get(t)??0);3===n&&(o.set(t,8|(o.get(t)??0)),n|=4);const i=await e(t);for(const e of i?.data.parents??[])((o.get(e)??0)&n)!==n&&await s(e,n)}return o},Zi=async(e,t)=>{const n=[...new Set(t)];if(n.length<=1)return n;const o=[];for(const t of n){const r=n.filter(e=>e!==t);2&((await Qi(e,t,r)).get(t)??0)||o.push(t)}return o},ea=async(e,t,n)=>{if(0===n.length)return[t];const o=(e=>{const t=[];for(const[n,o]of e)8&o&&t.push(n);return t})(await Qi(e,t,n));return Zi(e,o)},ta=new TextEncoder,na=new Set(["side-band-64k","side-band"]),oa=(e,t)=>({packPath:"",idxPath:"",objectCount:0,packSha:"",shallow:e,unshallow:t}),ra=t=>new e.TsgitError({code:"PACK_TOO_LARGE",objectCount:0,limit:t}),sa=async(e,t)=>{const n=t.hash.digestLength;if(e.length<12+n)throw zt("trailer mismatch: pack too short for header + trailer");const o=e.length-n,r=e.subarray(0,o),s=e.subarray(o),i=await t.hash.hashHex(r),a=A(s);if(i!==a)throw zt(`trailer mismatch: expected ${i}, got ${a}`);return i},ia=async(e,t,n)=>{const o=await aa(e,t);return(await ca(e,o,n)).slice().sort((e,t)=>e.offset-t.offset).map(e=>({id:e.id,crc32:e.crc32,offset:e.offset}))},aa=async(t,n)=>{const o=function(e){if(e.length<12)throw zt("truncated: pack header requires 12 bytes");const t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0);if(n!==Zt)throw zt(`invalid magic: expected 0x5041434b, got 0x${n.toString(16).padStart(8,"0")}`);const o=t.getUint32(4);if(2!==o)throw zt(`unsupported version: expected 2, got ${o}`);return{version:o,objectCount:t.getUint32(8)}}(n),r=t.config?.maxObjectsPerPack??5e7;if(o.objectCount>r)throw new e.TsgitError({code:"PACK_TOO_LARGE",objectCount:o.objectCount,limit:r});const s=n.length-t.hash.digestLength,i=[];let a=12;for(let e=0;e<o.objectCount;e+=1){const e=en(n,a,t.hashConfig),o=await t.compressor.streamInflate(n,e.dataOffset),r=e.dataOffset+o.bytesConsumed;if(r>s)throw zt("entry extends past pack trailer");const c=b(n.subarray(a,r));i.push({offset:a,header:e,inflated:o.output,crc32:c}),a=r}if(a!==s)throw zt("extra bytes between last entry and trailer");return i},ca=async(e,t,n)=>{const o=new Map,r=new Map;let s=t;for(;s.length>0;){const t=[];let i=!1;for(const a of s){const s=await fa(e,a,o,r,n);void 0===s?t.push(a):(o.set(s.offset,s),r.set(s.id,s),i=!0)}if(!i)throw da(t);s=t}return[...o.values()]},da=e=>{const t=e[0];if(void 0===t)return zt("unresolved deltas: empty queue (internal invariant violated)");const n=ua(t.header);return zt(void 0!==n?`unresolved REF_DELTA: base ${n} not in pack`:`unresolved entry at offset ${t.offset}`)},ua=e=>{if(!ha(e)&&6!==e.type)return e.baseId},fa=async(e,t,n,o,r)=>{if(ha(t.header)){const n=pa(t.header.type);return{id:await ga(e,n,t.inflated),type:n,content:t.inflated,crc32:t.crc32,offset:t.offset}}if(6===t.header.type){const o=t.offset-t.header.baseDistance;if(o<12)throw zt(`OFS_DELTA at offset ${t.offset} points before pack body: distance ${t.header.baseDistance}`);const r=n.get(o);if(void 0===r)return;return la(e,t,r)}const s=o.get(t.header.baseId);if(void 0!==s)return la(e,t,s);if(void 0===r)return;const i=await r(t.header.baseId);return void 0!==i?la(e,t,{type:i.type,content:i.content}):void 0},la=async(e,t,n)=>{const o=Qt(n.content,t.inflated);return{id:await ga(e,n.type,o),type:n.type,content:o,crc32:t.crc32,offset:t.offset}},ha=e=>1===e.type||2===e.type||3===e.type||4===e.type,pa=e=>{switch(e){case 1:return"commit";case 2:return"tree";case 3:return"blob";case 4:return"tag"}},ga=async(e,t,n)=>{const o=ta.encode(`${t} ${n.length}\0`),r=new Uint8Array(o.length+n.length);return r.set(o,0),r.set(n,o.length),e.hash.hashHex(r)},wa=async(e,t,n)=>{const o=function(e,t){if(20!==t.length)throw Ht(`packChecksum must be 20 bytes, got ${t.length}`);const n=e.map(e=>({shaBytes:M(e.id),entry:e}));n.sort((e,t)=>U(e.shaBytes,t.shaBytes));const o=n.length;let r=0;for(const e of n)e.entry.offset>2147483647&&(r+=1);const s=20*o,i=4*o,a=4*o,c=1032+s+i+a+8*r+20,d=new Uint8Array(c),u=new DataView(d.buffer);u.setUint32(0,4285812579),u.setUint32(4,2);const f=new Uint32Array(256);for(const{shaBytes:e}of n)f[e[0]]+=1;const l=new Uint32Array(256);let h=0;for(let e=0;e<256;e++)h+=f[e],l[e]=h;for(let e=0;e<256;e++)u.setUint32(8+4*e,l[e]);for(let e=0;e<o;e++)d.set(n[e].shaBytes,1032+20*e);const p=1032+s;for(let e=0;e<o;e++)u.setUint32(p+4*e,n[e].entry.crc32);const g=p+i;let w=0;const m=g+a;for(let e=0;e<o;e++){const t=n[e].entry.offset;if(t>2147483647){u.setUint32(g+4*e,2147483648|w);const n=Math.floor(t/4294967296),o=t>>>0;u.setUint32(m+8*w,n),u.setUint32(m+8*w+4,o),w+=1}else u.setUint32(g+4*e,t)}return d.set(t,c-20),d}(t.map(e=>({id:e.id,crc32:e.crc32,offset:e.offset})),M(n)),r=M(await e.hash.hashHex(o)),s=new Uint8Array(o.length+r.length);return s.set(o,0),s.set(r,o.length),s},ma=async(e,t,n,o,r,s)=>{const i=`${e.layout.gitDir}/objects/pack`;await e.fs.mkdir(i);const a=`${i}/pack-${o}.pack`,c=`${i}/pack-${o}.idx`;return await e.fs.writeExclusive(a,t),await e.fs.writeExclusive(c,n),s&&await e.fs.writeExclusive(`${i}/pack-${o}.promisor`,new Uint8Array(0)),{packPath:a,idxPath:c,objectCount:r,packSha:o}},ya=t=>{if(t.signal?.aborted)throw e.operationAborted()},va=async(t,n,o)=>{try{return((e,t,n)=>({ok:!0,id:t,type:n.type,size:le(n,e.hashConfig),object:n}))(t,n,await is(t,n,o))}catch(t){if((t=>t instanceof e.TsgitError&&"OBJECT_NOT_FOUND"===t.data.code)(t))return(e=>({ok:!1,id:e,reason:"missing"}))(n);throw t}},xa=async(t,n,o,r)=>{const s=await An(t,n,o,r);if(void 0!==s)throw e.configMissingValue(s.key,s.source,s.line)},ba=(e,t)=>{const n=`${t.gitDir}/hooks`;return void 0===e?n:""===e?`${t.gitDir}/.tsgit-no-hooks`:e.startsWith("~/")?void 0===t.homeDir?n:`${t.homeDir}/${e.slice(2)}`:(o=e).startsWith("/")||/^[A-Za-z]:[\\/]/.test(o)?e:er(t.workDir,e);var o},ka=async(e,t,n)=>{const o=e.hooks;if(void 0===o)return;await xa(e,"core",void 0,["hookspath"]);const r=await Cn(e),s={name:t,hooksDir:ba(r.core?.hooksPath,e.layout),workDir:e.layout.workDir,gitDir:e.layout.gitDir,args:n.args??[],stdin:n.stdin??"",...void 0!==e.signal?{signal:e.signal}:{}};return o.run(s)};async function Ea(e,t){if(t.length>C)throw l(t.length,C);return qs(e,{type:"tree",id:"",entries:t})}const Ia=e=>{let t=0;for(const n of e)"/"===n&&(t+=1);if(t>4096)throw f(t)},Ta=async(e,t)=>{const{files:n,subdirs:o}=(e=>{const t=[],n=new Map;for(const o of e){const e=o.path.indexOf("/");if(-1===e){t.push(o);continue}const r=o.path.slice(0,e),s=o.path.slice(e+1),i=n.get(r),a={path:s,id:o.id,mode:o.mode};void 0===i?n.set(r,[a]):i.push(a)}return{files:t,subdirs:n}})(t),r=[];for(const e of n)r.push({name:e.path,id:e.id,mode:e.mode});for(const[t,n]of o){const o=await Ta(e,n);r.push({name:t,id:o,mode:p.DIRECTORY})}return Ea(e,r)},Ca=new TextEncoder,Sa=async(e,t,n)=>{const o=er(e.layout.workDir,t.path),r=await e.fs.lstat(o).catch(()=>{});if(void 0===r)return{status:"absent"};const s=v(r);if(t.mode!==p.GITLINK&&!Ie(s,t.mode))return{status:"type-changed",worktreeMode:s};try{const i=r.isSymbolicLink?Ca.encode(await e.fs.readlink(o)):await e.fs.read(o),a=r.isSymbolicLink||void 0===n||void 0===e.command?i:await(async(e,t,n,o,r)=>{const s=await ds(e,n,o);if("external"!==s.kind||void 0===s.clean)return r;const i=await us(e,t,s.clean,r);return i.ok?i.bytes:r})(e,e.command,n,t.path,i),{id:c}=await mr(e,{type:"blob",id:"",content:a});return c!==t.id?{status:"modified",worktreeMode:s}:{status:s===t.mode?"unchanged":"mode-changed",worktreeMode:s}}catch{return{status:"modified",worktreeMode:s}}};async function $a(e,t){if(t.message.includes("\0"))throw s("message contains NUL");var n,o;if(o=t.message,(new TextEncoder).encode(o).byteLength>16777216)throw s("message exceeds 16 MiB");if(void 0!==t.gpgSignature&&((n=t.gpgSignature).includes("\0")||n.includes("\r")))throw s("gpgSignature contains header-boundary chars");if(void 0!==t.extraHeaders)for(const e of t.extraHeaders){if($r(e.key))throw s("extraHeader key contains forbidden characters");if(Sr(e.value))throw s("extraHeader value contains header-boundary chars")}return V(t.author),V(t.committer),qs(e,{type:"commit",id:"",data:{tree:t.tree,parents:t.parents,author:t.author,committer:t.committer,message:t.message,...void 0!==t.gpgSignature?{gpgSignature:t.gpgSignature}:{},extraHeaders:t.extraHeaders??[]}})}const Da=e=>`${e.layout.gitDir}/shallow`,Oa=t=>t instanceof e.TsgitError&&"FILE_NOT_FOUND"===t.data.code,La=async e=>{let t;try{t=await e.fs.readUtf8(Da(e))}catch(e){if(Oa(e))return new Set;throw e}const n=new Set;for(const e of t.split("\n")){const t=e.trim();0!==t.length&&Ma(t)&&n.add(X.from(t))}return n},Aa=/^[0-9a-f]{40}([0-9a-f]{24})?$/i,Ma=e=>Aa.test(e),_a=(e,t)=>e.section.toLowerCase()===t.section&&(void 0===t.subsection?void 0===e.subsection:e.subsection===t.subsection),Ua=(e,t)=>{const n=[];for(const o of e)if(_a(o,t))for(const e of o.entries)e.key.toLowerCase()===t.name&&n.push({value:e.value});return n},Na=["system","global","local","worktree"],Ra=async(e,t)=>{try{return await e.fs.exists(t)}catch{return!1}},Pa=(t,n)=>{try{return n()}catch(n){if(n instanceof e.TsgitError&&"UNSUPPORTED_OPERATION"===n.data.code)throw e.configScopeNotAvailable(t,"browser-adapter");throw n}},Fa=async(t,n)=>{if("local"===n)return`${hn(t)}/config`;if("worktree"===n){if(!await(async t=>{const n=`${hn(t)}/config`,o=await(async(t,n)=>{try{return await t.fs.readUtf8(n)}catch(t){if(t instanceof e.TsgitError&&"FILE_NOT_FOUND"===t.data.code)return;throw t}})(t,n);if(void 0===o)return!1;const r=Vn(o,n);for(const e of r)if("extensions"===e.section.toLowerCase()&&void 0===e.subsection)for(const t of e.entries)if("worktreeconfig"===t.key.toLowerCase())return"true"===t.value;return!1})(t))throw e.configScopeNotAvailable("worktree","worktree-extension-unset");return`${t.layout.gitDir}/config.worktree`}if("global"===n){const e=Pa("global",()=>t.fs.xdgConfigHome()),n=Pa("global",()=>t.fs.homedir()),o=`${e}/git/config`;if(await Ra(t,o))return o;const r=`${n}/.gitconfig`;return await Ra(t,r),r}const o=Pa("system",()=>t.fs.systemConfigPath());if(0===o.length)throw e.configSystemPathUnresolved();return o};let Ba=new WeakMap;const Wa=e=>{Ba.delete(e)},ja=(t,n)=>{const o=(e=>{const t=Ba.get(e);if(void 0!==t)return t;const n=new Map;return Ba.set(e,n),n})(t),r=o.get(n);if(void 0!==r)return r;const s=(async(t,n)=>{const o=await Fa(t,n);try{const e=await t.fs.readUtf8(o);return Vn(e,o)}catch(t){if(t instanceof e.TsgitError){const e=t.data.code;if("FILE_NOT_FOUND"===e||"PERMISSION_DENIED"===e)return[]}throw t}})(t,n);return o.set(n,s),s},za=async(t,n)=>{try{return{scope:n,sections:await ja(t,n)}}catch(t){if(t instanceof e.TsgitError){const e=t.data.code;if("CONFIG_SCOPE_NOT_AVAILABLE"===e)return;if("CONFIG_SYSTEM_PATH_UNRESOLVED"===e)return}throw t}},Ha=async({ctx:e,scope:t})=>{if(void 0!==t)return(await ja(e,t)).map(e=>({scope:t,section:e}));const n=[];for(const t of Na){const o=await za(e,t);void 0!==o&&n.push(o)}return(e=>{const t=new Map;for(const{scope:n,sections:o}of e)t.set(n,o);const n=[];for(const e of Na){const o=t.get(e);if(void 0!==o)for(const t of o)n.push({scope:e,section:t})}return n})(n)},Ga=async(e,t,n)=>{if(void 0!==n){const o=await ja(e,n);return Ua(o,t).map(e=>({value:e.value,scope:n}))}return((e,t)=>{const n=[];for(const{scope:o,section:r}of e)if(_a(r,t))for(const e of r.entries)e.key.toLowerCase()===t.name&&n.push({value:e.value,scope:o});return n})((await Ha({ctx:e})).map(({scope:e,section:t})=>({scope:e,section:t})),t)},Ka=(e,t)=>`\t${e} = ${(e=>{const t=e.replaceAll("\\","\\\\").replaceAll('"','\\"').replaceAll("\n","\\n").replaceAll("\t","\\t");return(e=>e.startsWith(" ")||e.endsWith(" ")||e.includes(";")||e.includes("#")||e.includes("\r"))(e)?`"${t}"`:t})(t)}`,Va=(e,t)=>void 0===t?`[${e}]`:`[${e} "${(e=>e.replaceAll("\\","\\\\").replaceAll('"','\\"'))(t)}"]`,Ya=(t,n)=>{if(/[\n\r\0]/.test(n))throw e.invalidOption("config",`${t} must not contain a newline or NUL`)},qa=t=>{if(t.includes("\0"))throw e.invalidOption("config","value must not contain a NUL byte")},Xa=t=>{if(/[\n\0]/.test(t))throw e.invalidOption("config","subsection must not contain a newline or NUL")},Ja=t=>{if(/[\s\0[\]"\\]/.test(t))throw e.invalidOption("config","section must not contain whitespace, NUL, brackets, quotes, or backslashes")},Qa=(t,n)=>{if(""===t&&void 0===n)throw e.invalidOption("config","section name must not be empty without a subsection")},Za=e=>void 0===e.subsection?e.section:`${e.section}.${e.subsection}`,ec=e=>{const t=ro(e);if("header"===t.parse.kind)return{rawName:Za(t.parse),endOffset:t.endOffset}},tc=(e,t)=>{for(let n=0;n<e.length;n+=1)if(ec(e[n])?.rawName===t)return n;return-1},nc=(e,t)=>{const n=e.split("\n"),o=[];let r=!1;for(const e of n){const n=ec(e);void 0===n||(r=n.rawName===t),r||o.push(e)}return((e,t)=>""===e[e.length-1]&&t.length>0&&""!==t[t.length-1]?[...t,""]:t)(n,o).join("\n")},oc=(e,t,n)=>{Ja(n.section),Qa(n.section,n.subsection),void 0!==n.subsection&&Xa(n.subsection);const o=e.split("\n").map(e=>{const o=ec(e);return void 0===o||o.rawName!==t?e:((e,t,n)=>{const o=Va(n.section,n.subsection),r=Kn(e,t);return r>=e.length?o:`${o}\n\t${e.slice(r)}`})(e,o.endOffset,n)});return o.join("\n")},rc=async(t,n)=>{try{return await t.fs.readUtf8(n)}catch(t){if(t instanceof e.TsgitError&&"FILE_NOT_FOUND"===t.data.code)return"";throw t}},sc=(e,t)=>({sectionLc:e.toLowerCase(),subsection:t}),ic=(e,t)=>e.section.toLowerCase()===t.sectionLc&&e.subsection===t.subsection,ac=(e,t)=>{let n,o,r=!1;for(const s of e)"header"===s.kind?(r&&(n=o),r=ic(s,t),o=r?s.line+1:void 0):r&&"entry"===s.kind&&(o=s.endLine);return r&&(n=o),n},cc=(e,t,n,o)=>{const r=o.endsWith("\n")?e.length-1:e.length,s=Math.min(t,r),i=[...e.slice(0,s),n,...e.slice(s)];return s===e.length&&i.push(""),i},dc=(e,t,n,o,r)=>{Ja(t),Qa(t,n),Ya("key",o),qa(r),void 0!==n&&Xa(n);const s=e.split("\n"),i=Bn(s,e.endsWith("\n")),a=sc(t,n),c=((e,t,n)=>{const o=n.toLowerCase();let r=!1;for(const n of e)if("header"===n.kind)r=ic(n,t);else if(r&&"entry"===n.kind&&n.key.toLowerCase()===o)return n})(i,a,o);if(void 0!==c)return((e,t,n,o)=>{const r=n.sharesHeaderLine?((e,t)=>{for(const n of e)if("header"===n.kind&&n.line===t.startLine)return n})(t,n):void 0,s=void 0!==r?[Va(r.section,r.subsection),o]:[o],i=[...e.slice(0,n.startLine),...s,...e.slice(n.endLine)];return(n.endLine===e.length?[...i,""]:i).join("\n")})(s,i,c,Ka(o,r));const d=ac(i,a);return void 0===d?`${""===e?"":e.endsWith("\n")?e:`${e}\n`}${Va(t,n)}\n${Ka(o,r)}\n`:cc(s,d,Ka(o,r),e).join("\n")},uc=e=>[e.header.line,...e.bodyTokens.flatMap(e=>"entry"===e.kind?fc([e]):[e.line])],fc=e=>e.flatMap(e=>Array.from({length:e.endLine-e.startLine},(t,n)=>e.startLine+n)),lc=(e,t,n,o)=>{Ja(t),void 0!==n&&Xa(n),Ya("key",o);const r=e.split("\n"),s=sc(t,n),i=(e=>{const t=[];for(let n=0;n<e.length;n++){const o=e[n];if("header"!==o.kind)continue;const r=[];let s=n+1;for(;s<e.length&&"header"!==e[s].kind;)r.push(e[s]),s++;t.push({header:o,bodyTokens:r}),n=s-1}return t})(Bn(r,e.endsWith("\n"))),a=o.toLowerCase(),c=i.filter(e=>ic(e.header,s)).map(e=>((e,t)=>{const n=((e,t)=>e.bodyTokens.flatMap(e=>"entry"===e.kind&&e.key.toLowerCase()===t?[{startLine:e.startLine,endLine:e.endLine}]:[]))(e,t);return 0===n.length?{excluded:[]}:((e,t)=>e.header.hasComment||e.bodyTokens.some(e=>"comment"===e.kind||"entry"===e.kind&&e.key.toLowerCase()!==t))(e,t)?n.some(t=>t.startLine===e.header.line)?{excluded:fc(n).filter(t=>t!==e.header.line),headerRewrite:{line:e.header.line,text:Va(e.header.section,e.header.subsection)}}:{excluded:fc(n)}:{excluded:uc(e)}})(e,a));return((e,t)=>{const n=new Set(t.flatMap(e=>e.excluded)),o=new Map(t.flatMap(e=>e.headerRewrite?[[e.headerRewrite.line,e.headerRewrite.text]]:[]));if(0===n.size&&0===o.size)return;const r=[];for(const[t,s]of e.entries())n.has(t)||r.push(o.get(t)??s);return(n.has(e.length-1)?[...r,""]:r).join("\n")})(r,c)??e},hc=async(e,t)=>{const n=`${e.layout.gitDir}/config`,o=await rc(e,n);wc(o,n);const r=t.reduce((e,t)=>dc(e,t.section,t.subsection,t.key,t.value),o);await e.fs.writeUtf8(n,r),$n(e)},pc=(e,t)=>"set"===t.kind?dc(e,t.section,t.subsection,t.key,t.value):"appendEntry"===t.kind?gc(e,t.section,t.subsection,t.key,t.value):"removeEntry"===t.kind?lc(e,t.section,t.subsection,t.key):"removeSection"===t.kind?nc(e,Za({section:t.section,subsection:t.subsection})):oc(e,Za({section:t.section,subsection:t.from}),{section:t.section,subsection:t.to}),gc=(e,t,n,o,r)=>{Ja(t),Qa(t,n),Ya("key",o),qa(r),void 0!==n&&Xa(n);const s=e.split("\n"),i=Bn(s,e.endsWith("\n")),a=sc(t,n),c=ac(i,a);return void 0===c?`${""===e?"":e.endsWith("\n")?e:`${e}\n`}${Va(t,n)}\n${Ka(o,r)}\n`:cc(s,c,Ka(o,r),e).join("\n")},wc=(t,n)=>{try{return Vn(t,n)}catch(t){if(t instanceof e.TsgitError&&"CONFIG_PARSE_ERROR"===t.data.code&&void 0!==t.data.partialSectionName)throw e.configInvalidFile(t.data.partialSectionName,n);throw t}},mc=e=>`'${e.replaceAll("'","'\\''")}'`,yc=new Uint8Array(0),vc=new TextDecoder,xc=/-----BEGIN (?:PGP|SSH) SIGNATURE-----[\s\S]*-----END (?:PGP|SSH) SIGNATURE-----/,bc=e=>xc.test(e),kc=t=>t instanceof e.TsgitError&&"FILE_NOT_FOUND"===t.data.code,Ec=async(e,t)=>{try{await e.fs.rm(t)}catch(e){if(!kc(e))throw e}},Ic=(e,t)=>t?e.data.parents.slice(0,1):e.data.parents;async function*Tc(t,n){const o=n.shallow??new Set,r={heap:new ai(ci),seen:new Set(n.from),until:new Set(n.until??[]),firstParent:n.firstParent??!1,read:Cc(t,n)};for(await Sc(r);r.heap.size()>0;){if(t.signal?.aborted)throw e.operationAborted();const{value:n}=r.heap.pop();yield{commit:n,frontierEmpty:0===r.heap.size(),frontier:()=>r.heap.entries().map(e=>e.oid)},o.has(n.id)||await $c(r,n)}}const Cc=(e,t)=>{const n=t.verifyHash??!0,o=t.ignoreMissing??!1,r=new Set;return t=>Ki(e,t,{verifyHash:n,ignoreMissing:o,missing:r})},Sc=async e=>{for(const t of e.seen)e.until.has(t)||await Dc(e,t)},$c=async(e,t)=>{for(const n of Ic(t,e.firstParent))e.seen.has(n)||e.until.has(n)||(e.seen.add(n),await Dc(e,n))},Dc=async(e,t)=>{const n=await e.read(t);void 0!==n&&e.heap.push({oid:t,date:n.data.committer.timestamp,value:n})},Oc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),Lc=/^[A-Za-z]:/,Ac=e=>{if(e.startsWith("-"))return!0;if(e.includes("\\"))return!0;if((e=>{for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n<=31)return!0;if(127===n)return!0}return!1})(e))return!0;if(Lc.test(e))return!0;for(const t of e.split("/")){if(""===t)return!0;if("."===t)return!0;if(".."===t)return!0}return!1},Mc=(e,t)=>void 0!==t?{...e,stage:0,skipWorktree:!1}:{...e,stage:0},_c=(e,t)=>e.path<t.path?-1:e.path>t.path?1:0,Uc={kind:"empty"},Nc=()=>({slots:Array.from({length:16},()=>Uc),preserved:[]}),Rc=e=>({kind:"internal",node:e}),Pc=(e,t,n)=>({...e,slots:e.slots.map((e,o)=>o===t?n:e)}),Fc=(e,t)=>Number.parseInt(e.charAt(t),16),Bc=e=>"note"===e.kind?e.key:e.prefix,Wc=(e,t,n)=>{const o=Bc(t),r=Fc(o,n),s=e.slots[r];if("empty"===s.kind)return Pc(e,r,t);if("internal"===s.kind)return Pc(e,r,Rc(Wc(s.node,t,n+1)));if(Bc(s)===o)return Pc(e,r,t);const i=Wc(Wc(Nc(),s,n+1),t,n+1);return Pc(e,r,Rc(i))},jc=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,zc=/^[0-9a-f]{2}$/,Hc=(e,t)=>{const n=[];return{...e.reduce((e,o)=>{const r=((e,t)=>{const n=t+e.name;return!y(e.mode)&&jc.test(n)?{kind:"note",key:X.from(n),val:e.id}:y(e.mode)&&zc.test(e.name)?{kind:"subtree",prefix:n,oid:e.id}:null})(o,t);return null===r?(n.push(o),e):Wc(e,r,t.length)},Nc()),preserved:n}},Gc=e=>Hc(e,""),Kc=async(e,t)=>Hc(await t(e.oid),e.prefix),Vc="refs/notes/",Yc=`${Vc}commits`,qc=t=>{if(!t.startsWith(Vc))throw e.notesRefOutside(t);return t},Xc=(e,t,n)=>{const o=`${e.layout.gitDir}/modules/${t}`,r=er(e.layout.workDir,n),{promisor:s,hooks:i,...a}=e;return Object.freeze({...a,layout:Object.freeze({workDir:r,gitDir:o,bare:!1,...void 0!==e.layout.homeDir?{homeDir:e.layout.homeDir}:{}}),cwd:r})},Jc=async(e,t,n,o=new Set)=>{if(void 0===t)return;const r=`${e.layout.gitDir}/modules/${t}`;return!o.has(r)&&await e.fs.exists(`${r}/HEAD`)?Xc(e,t,n):void 0},Qc=(e,t)=>{if(null===t.value)return e;const n=t.key.toLowerCase();return"path"===n?{...e,path:t.value}:"url"===n?{...e,url:t.value}:"update"===n?{...e,update:t.value}:"branch"===n?{...e,branch:t.value}:e},Zc=e=>{if("submodule"!==e.section)return;if(void 0===e.subsection)return;if(Ac(e.subsection))return;const t=e.entries.reduce(Qc,{});return{name:e.subsection,...void 0!==t.path?{path:t.path}:{},...void 0!==t.url?{url:t.url}:{},...void 0!==t.update?{update:t.update}:{},...void 0!==t.branch?{branch:t.branch}:{}}},ed=e=>{const t=[];for(const n of Vn(e,".gitmodules")){const e=Zc(n);void 0!==e&&t.push(e)}return t},td=Q.from("HEAD"),nd=new TextDecoder;async function*od(e,t,n,o,r,s,i,a){const c=await sd(e,t);for await(const d of bs(e,t,{recursive:!0})){if(d.mode!==p.GITLINK)continue;const t=Hs(r,d.path),u=c.get(d.path);if(yield rd(u,d.path,d.id,t,n,o),!i)continue;if(n>=a)continue;const f=await Jc(e,u?.name,d.path,s);if(void 0===f)continue;const l=await id(f,d.id);if(void 0===l)continue;const h=new Set(s).add(f.layout.gitDir);yield*od(f,l,n+1,t,t,h,i,a)}}const rd=(e,t,n,o,r,s)=>({name:e?.name??t,path:o,commit:n,depth:r,...void 0!==e?.url?{url:e.url}:{},...void 0!==e?.branch?{branch:e.branch}:{},...void 0!==s?{parent:s}:{}}),sd=async(e,t)=>{const n=t.entries.find(e=>".gitmodules"===e.name);if(void 0===n)return new Map;if(n.mode!==p.REGULAR&&n.mode!==p.EXECUTABLE)return new Map;const o=await as(e,n.id,{maxBytes:Go}),r=nd.decode(o.content),s=new Map;for(const e of ed(r))void 0!==e.path&&s.set(e.path,e);return s},id=async(t,n)=>{try{return await ti(t,n)}catch(t){if(t instanceof e.TsgitError&&"OBJECT_NOT_FOUND"===t.data.code)return;throw t}},ad=(e,t)=>[...Array.from({length:t},(t,n)=>e.slice(2*n,2*n+2)),e.slice(2*t)].join("/"),cd=e=>Array.from({length:e.length/2},(t,n)=>e.slice(2*n,2*n+2)).join("/"),dd=async(e,t,n,o,r,s)=>{return"empty"===e.kind?[]:"note"===e.kind?[{name:ad(e.key,r),mode:p.REGULAR,oid:e.val}]:"internal"===e.kind?(await ud(e.node,n,o+1,r,s+(i=t,i.toString(16)))).entries:o<2*r?[{name:cd(e.prefix),mode:p.DIRECTORY,oid:e.oid}]:(await ud(await Kc(e,n),n,e.prefix.length,r,e.prefix)).entries;var i},ud=async(e,t,n,o,r)=>{const s=((e,t,n)=>t%2!=0||t>2*n?n:e.slots.every(e=>{return"subtree"===(t=e.kind)||"internal"===t;var t})?n+1:n)(e,n,o),i=[];for(const[o,a]of e.slots.entries())i.push(...await dd(a,o,t,n,s,r));const a=e.preserved.map(e=>((e,t)=>({name:""===t?e.name:`${cd(t)}/${e.name}`,mode:e.mode,oid:e.id}))(e,r));return{entries:[...i,...a]}};async function fd(e,t){const n=[],o=new Map;for(const e of t){const t=e.name.indexOf("/");if(-1===t)n.push({id:e.oid,mode:e.mode,name:e.name});else{const n=e.name.slice(0,t),r=e.name.slice(t+1),s=o.get(n)??[];s.push({name:r,mode:e.mode,oid:e.oid}),o.set(n,s)}}const r=[];for(const[t,n]of o){const o=await fd(e,n);r.push({id:o,mode:p.DIRECTORY,name:t})}return Ea(e,ae([...n,...r]))}exports.BinaryHeap=ai,exports.CHERRY_PICK_HEAD=Dt,exports.DEFAULT_NOTES_REF=Yc,exports.EMPTY_SLOT=Uc,exports.FETCH_HEAD=Lt,exports.FILE_MODE=p,exports.FilePath=Z,exports.MAX_CONCURRENT_BLOB_LOADS=32,exports.MAX_FLAT_TREE_ENTRIES=C,exports.MAX_GITMODULES_BYTES=Go,exports.MAX_HAVES=256,exports.MAX_LINE_BYTES=65536,exports.MAX_PUSH_OBJECTS=Ho,exports.MAX_SCORE=We,exports.MAX_SPARSE_PATTERN_FILE_BYTES=Ds,exports.MAX_SUBMODULE_DEPTH=100,exports.MAX_WALK_SEEDS=1024,exports.MAX_WORKING_TREE_BLOB_BYTES=zo,exports.MERGE_HEAD=St,exports.MERGE_MSG="MERGE_MSG",exports.NONE_KEY=Ae,exports.ORIG_HEAD=$t,exports.ObjectId=X,exports.REBASE_HEAD="REBASE_HEAD",exports.REVERT_HEAD=Ot,exports.RefName=Q,exports.STAGE0_FLAGS=D,exports.ZERO_OID=J,exports.acquireIndexLock=Ms,exports.appendReflog=Ko,exports.applyChangeset=ys,exports.applyConfigOpInText=pc,exports.assertNoValuelessConfig=xa,exports.atomicWriteRef=kn,exports.boundedMap=di,exports.buildAttributeProvider=wr,exports.buildConeSpec=e=>{const t=new Set(e.map(Ut)),n=new Set;for(const e of t)for(const o of _t(e))t.has(o)||n.add(o);return{mode:"cone",recursive:t,parents:n}},exports.buildIgnoreEvaluator=Zs,exports.buildIndexFromTree=async(e,t)=>{const n=(e=>{const t=new Map;for(const n of e.entries)0===n.flags.stage&&t.set(n.path,n);return t})(t.currentIndex),o=await(async(e,t)=>{const n=[];for await(const o of bs(e,t))o.mode!==p.DIRECTORY&&n.push({path:o.path,id:o.id,mode:o.mode});return n})(e,t.targetTree),r=o.map(e=>((e,t,n)=>{if(void 0!==n&&!n(e.path))return O(e);const o=t.get(e.path);return void 0!==o&&o.id===e.id&&o.mode===e.mode?{...o,flags:Mc(o.flags,n)}:(e=>({ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:e.mode,uid:0,gid:0,fileSize:0,id:e.id,flags:D,path:e.path}))(e)})(e,n,t.sparse));return r.sort(_c),r},exports.buildPack=async(e,t)=>{const n=[];for(const o of t.oids){const t=await is(e,o);n.push(await ji(e,t))}const o=function(e){const t=function(e,t){const n=new Uint8Array(12),o=new DataView(n.buffer);return o.setUint32(0,Zt),o.setUint32(4,2),o.setUint32(8,t),n}(0,e.length),n=[t],o=[];let r=t.length;for(const t of e){const e=fn(tn(t.type,t.uncompressedSize),t.compressedData),s=b(e);o.push({crc32:s,offset:r}),n.push(e),r+=e.length}return{data:ln(n),entries:o}}(n),r=await e.hash.hash(o.data),s=A(r),i=new Uint8Array(o.data.length+r.length);return i.set(o.data,0),i.set(r,o.data.length),{bytes:i,sha:s,objectCount:n.length}},exports.buildRepoIgnorePredicate=async e=>{const t=await Zs(e),n=[...t.base],o=new Set([]);return async(e,r)=>{for(const r of(e=>{const t=e.split("/");if(t.length<=1)return[];const n=[];for(let e=1;e<t.length;e+=1)n.push(t.slice(0,e).join("/"));return n})(e)){if(o.has(r))continue;o.add(r);const e=await t.loadDirRules(r);e.length>0&&n.push({basedir:r,rules:e})}return"ignored"===((e,t,n)=>ot(e,t,n).verdict)(n,e,r)}},exports.buildSparseMatcher=jt,exports.bytesEqual=N,exports.catFileBatch=async function*(e,t,n){const o=void 0===n?.maxBytes?void 0:{maxBytes:n.maxBytes};for await(const n of t){ya(e);const t=await va(e,n,o);yield t,ya(e)}},exports.chainGap=(e,t,n)=>[...t.slice(n+1)].reduceRight((e,t)=>Rc(Pc(Nc(),Fc(t,0),e)),Rc(e)),exports.commitDateWalk=Tc,exports.commonGitDir=hn,exports.compareBytes=U,exports.comparePaths=Se,exports.compareWorkingTreeDelta=Sa,exports.compareWorkingTreeEntry=async(e,t,n)=>(await Sa(e,t,n)).status,exports.compileGlob=at,exports.computeChangeset=xs,exports.containsGlob=e=>e.includes("*")||e.includes("?"),exports.crc32=b,exports.createCommit=$a,exports.createEmptyTrie=Nc,exports.createPackRegistry=zr,exports.createTag=async function(e,t){return V(t.tagger),qs(e,{type:"tag",id:"",data:{object:t.object,objectType:t.objectType,tagName:t.tagName,tagger:t.tagger,message:t.message,...void 0!==t.gpgSignature?{gpgSignature:t.gpgSignature}:{},extraHeaders:t.extraHeaders??[]}})},exports.deleteReflog=Yo,exports.deriveSubmoduleCloneContext=(e,t,n)=>Xc(e,t,n),exports.deriveSubmoduleContext=Jc,exports.deriveWorkingMode=v,exports.diffLines=Be,exports.diffTrees=async function(e,t,n,o){const[r,s]=await Promise.all([Bi(e,t),Bi(e,n)]),i=!0===o?.recursive?await async function(e,t,n){const[o,r]=await Promise.all([Wi(e,t),Wi(e,n)]);return et(o,r)}(e,r,s):et(r,s),a=!0===o?.detectRenames?await ki(e,i,o.renameOptions,await async function(e,t,n){if("harder"!==n?.copies||void 0===t)return;return(await Ei(e,t)).entries}(e,r,o.renameOptions)):i,c={mode:(d=o??{}).ignoreWhitespace??"none",ignoreCrAtEol:d.ignoreCrAtEol??!1};var d;const u="none"!==(f=c).mode||f.ignoreCrAtEol;var f;const l=!0===o?.ignoreBlankLines,h=!0===o?.withStat;return u||h?async function(e,t,n,o,r,s){const i=await Ni(e,t.changes,{applyTextconv:!0}),a=[];for(const e of i){const t=qe(e.oldContent??Ri,e.newContent??Ri,Pi(n,o,r,e.numstatBinaryOverride));o&&Fi(e.change,t)||a.push(s?{...e.change,...t}:e.change)}return{changes:a}}(e,a,c,u,l,h):a},exports.drainPackBodyBounded=async(e,t,n)=>{const o=e.config?.maxResponseBytes??536870912,r=[];let s=0,i=0;for await(const a of n){if(s+a.byteLength>o)throw ra(o);r.push(a),s+=a.byteLength,s-i>=65536&&(e.progress.update(t.progressOp,s),i=s)}0!==s&&s!==i&&e.progress.update(t.progressOp,s);const a=new Uint8Array(s);let c=0;for(const e of r)a.set(e,c),c+=e.byteLength;return a},exports.enumerateObjects=async function(e,t){const n=!1!==t?.includePacks,o=new Set;return await async function(e,t){const n=hn(e);for(const o of Oc){const r=yn(n,o);if(!await e.fs.exists(r))continue;const s=await e.fs.readdir(r);for(const e of s)e.isFile&&t.add(`${o}${e.name}`)}}(e,o),n&&await async function(e,t){const n=ss(e),o=await n.all();for(const e of o)for(const n of un(e.index))t.add(n)}(e,o),[...o].sort()},exports.enumeratePushObjects=async function*(e,t){const n={emitted:new Set,cap:t.maxObjects??Ho},o=await(async(e,t,n)=>{const o=[];for(const r of n){const n=await Gi(e,r,e=>{Hi(t,e)});o.push(n)}return o})(e,n,t.wants);for(const e of n.emitted)yield e;yield*async function*(e,t,n,o){for await(const r of Yi(e,{from:n,until:o,ignoreMissing:!0})){Hi(t,r.id)&&(yield r.id),Hi(t,r.data.tree)&&(yield r.data.tree);for await(const n of bs(e,r.data.tree,{recursive:!0}))Ur(n.mode)||Hi(t,n.id)&&(yield n.id)}}(e,n,o,t.haves)},exports.enumerateRefs=async function(e){const t=new Set;await e.fs.exists(`${e.layout.gitDir}/HEAD`)&&t.add("HEAD");for(const n of await async function(e){const t=`${e.layout.gitDir}/refs`;return await e.fs.exists(t)?Xi(e,t,"refs"):[]}(e))t.add(n);for(const n of(await Qo(e).getPackedRefs()).entries)t.add(n.name);return[...t]},exports.exceedsMaxPeelDepth=_r,exports.fetchPack=async(e,t,n)=>{e.progress.start(n.progressOp);try{const o=await(async(e,t,n)=>t(e,n))(e,t,n);return 0===o.packBytes.length?oa(o.shallow,o.unshallow):await(async(e,t,n)=>{const o=await sa(t.packBytes,e),r=await ia(e,t.packBytes);if(0===r.length)return oa(t.shallow,t.unshallow);const s=await wa(e,r,o),i=await ma(e,t.packBytes,s,o,r.length,!0===n.promisor);return function(e){os.get(e)?.refresh()}(e),{...i,shallow:t.shallow,unshallow:t.unshallow}})(e,o,n)}finally{e.progress.end(n.progressOp)}},exports.findByPrefix=function(e,t){if(t.length<4)throw Ht(`prefix too short: minimum 4 hex chars, got ${t.length}`);if(t.length>40)throw Ht(`prefix too long: maximum 40 hex chars, got ${t.length}`);if(!dn.test(t))throw Ht("prefix contains non-hex characters");const n=t.padEnd(40,"0"),o=t.padEnd(40,"f"),r=M(n),s=M(o),i=r[0],a=0===i?0:rn(e,i-1),c=rn(e,s[0]),d=function(e,t,n,o){let r=t,s=n;for(;r<s;){const t=r+s>>>1;sn(e,t,o)<0?r=t+1:s=t}return r}(e,a,c,r),u=function(e,t,n,o){let r=t,s=n;for(;r<s;){const t=r+s>>>1;sn(e,t,o)<=0?r=t+1:s=t}return r}(e,a,c,s),f=[];for(let t=d;t<u;t++){const n=nn+t*on,o=e._bytes.subarray(n,n+on);f.push(A(o))}return f},exports.findFirstInvalidCompression=async e=>{const{tokens:t,source:n}=await Sn(e);let o=!1;for(const e of t){if("header"===e.kind){o=Ln(e.section,e.subsection,"core",void 0);continue}if(!o||"entry"!==e.kind)continue;const t=e.key.toLowerCase();if(!Mn.has(t))continue;const r=`core.${t}`,s=e.startLine+1;if(null===e.value)return{key:r,source:n,line:s,failure:{kind:"numeric",value:"",reason:"invalid unit"}};const i=Wo(e.value);if(!i.ok)return{key:r,source:n,line:s,failure:{kind:"numeric",value:e.value,reason:i.reason}};if(i.value<-1||i.value>9)return{key:r,source:n,line:s,failure:{kind:"zlib",level:i.value}}}},exports.findFirstValuelessEntry=An,exports.findFirstValuelessInSection=async(e,t,n,{requireSubsection:o=!1}={})=>{const{tokens:r,source:s}=await Sn(e),i=new Set(n.map(e=>e.toLowerCase())),a=t.toLowerCase();let c,d=!1;for(const e of r){if("header"===e.kind){d=e.section.toLowerCase()===a,c=e.subsection;continue}if(!d||"entry"!==e.kind||null!==e.value)continue;if(o&&void 0===c)continue;const t=e.key.toLowerCase();if(i.has(t))return{key:void 0===c?`${a}.${t}`:`${a}.${c}.${t}`,source:s,line:e.startLine+1}}},exports.findInvalidPushDefault=async e=>{const{tokens:t,source:n}=await Sn(e);let o=!1;for(const e of t)if("header"!==e.kind){if(o&&"entry"===e.kind&&"default"===e.key.toLowerCase()&&null!==e.value&&void 0===Oo(e.value))return{key:"push.default",source:n,line:e.startLine+1,value:e.value}}else o=Ln(e.section,e.subsection,"push",void 0)},exports.flattenTree=Ei,exports.getAllConfigValues=async({ctx:e,key:t,scope:n})=>{const o=T(t);return{key:t,values:await Ga(e,o,n)}},exports.getConfigValue=async({ctx:t,key:n,scope:o})=>{const r=T(n),s=await Ga(t,r,o);if(0===s.length)return{key:n,value:void 0};if(s.length>1)throw e.configMultipleValues(n,s.length,"read",o);const[i]=s;return{key:n,value:i.value,scope:i.scope}},exports.getPackRegistry=ss,exports.getRefStore=Qo,exports.getRepoRoot=e=>e.layout.workDir,exports.hasObject=async(e,t)=>void 0!==await ss(e).lookup(t)||e.fs.exists(gn(hn(e),t)),exports.hasSideBand=e=>e.some(e=>na.has(e)),exports.hashBlob=async(t,n,o={})=>{if(t.signal?.aborted)throw e.operationAborted();if(n.byteLength>zo)throw e.workingTreeFileTooLarge("(hashBlob-content)",n.byteLength,zo);const{id:r}=await mr(t,{type:"blob",content:n});return!0!==o.write?r:qs(t,{type:"blob",id:r,content:n})},exports.indexOf=R,exports.indexPath=mn,exports.internalSlot=Rc,exports.invalidCommit=s,exports.invalidIdentity=a,exports.invalidateConfigCache=$n,exports.invalidateScopedConfigCache=Wa,exports.isBinary=Ne,exports.isBlankLine=Me,exports.isDirectory=y,exports.isGitlink=Ur,exports.isSafeRefName=function(e){try{return Tt(e),!0}catch{return!1}},exports.isSameKind=Ie,exports.isUnsafeSubmoduleName=Ac,exports.isWorkingTreeDirty=gs,exports.isWorkingTreeModified=e=>"unchanged"!==e&&"absent"!==e,exports.joinPath=er,exports.joinPathSegment=Hs,exports.kindOf=Ee,exports.listReflogs=async function(e){const t=`${e.layout.gitDir}/logs`;return await e.fs.exists(t)?qo(e,t,""):[]},exports.loadNotesTree=async function(t,n){const o=new Map,r=e=>{const n=o.get(e);if(void 0!==n)return n;const r=async function(e,t){const n=await is(e,t);if("tree"!==n.type)throw u("tree",n.type,t);return n.entries}(t,e);return o.set(e,r),r},s=await ei(t,n).catch(t=>{if(!(t instanceof e.TsgitError&&"REF_NOT_FOUND"===t.data.code))throw t});if(void 0===s)return{trie:Gc([]),read:r,notesCommitOid:void 0,notesTreeOid:void 0};const i=await is(t,s);if("commit"!==i.type)throw u("commit",i.type,s);const a=i.data.tree,c=await is(t,a);if("tree"!==c.type)throw u("tree",c.type,a);return{trie:Gc(c.entries),read:r,notesCommitOid:s,notesTreeOid:a}},exports.loadSparseMatcher=async e=>{const t=await Cn(e);if(!0!==t.core?.sparseCheckout)return;const n=!0===t.core.sparseCheckoutCone,o=await Ls(e),r=Wt(o??"",n);return r.degraded&&void 0!==o&&e.logger?.warn?.(".git/info/sparse-checkout is not cone-shaped; falling back to non-cone matching"),jt(r.spec)},exports.looksLikeObjectId=Fr,exports.looseCompressedBytes=Yr,exports.looseObjectPath=gn,exports.looseRefPath=wn,exports.matchInStackVerbose=ot,exports.materialisePatchFiles=Ni,exports.materializeTree=Ss,exports.materializeWorktreeFromHead=async e=>{const t=await ti(e,"HEAD"),n=await Ms(e);try{const o=await $s(e),r=await Ss(e,{targetTree:t.id,currentIndex:o});return await n.commit(r.newIndexEntries),r}finally{await n.release()}},exports.maybeBuildAttributeProvider=e=>void 0!==e.command?wr(e):Promise.resolve(void 0),exports.mergeBase=async(t,n,o)=>{if(0===n.length)throw e.invalidWalkInput("mergeBase requires at least one commit");const r=(e=>{const t=new Map;return async n=>{if(!t.has(n)){const o=await is(e,n);t.set(n,"commit"===o.type?o:void 0)}return t.get(n)}})(t),s=[...o?.octopus?await(async(e,t)=>{let n=[t[0]];for(let o=1;o<t.length;o+=1){const r=[];for(const s of n)r.push(...await ea(e,t[o],[s]));n=r}return Zi(e,n)})(r,n):await ea(r,n[0],n.slice(1))].sort();return!0===o?.all?s:s.slice(0,1)},exports.nibbleAt=Fc,exports.objectNotFound=c,exports.objectsDir=yn,exports.parseGitmodules=ed,exports.parseHeader=ne,exports.parseIniSections=Vn,exports.parseLooseRef=Ct,exports.parseSparseCheckout=Wt,exports.placeLeaf=Wc,exports.precedes=ci,exports.primaryPath=ke,exports.qualifyKey=(e,t)=>{const n=t.toLowerCase();if(""===e.section&&void 0===e.subsection)return n;const o=e.section.toLowerCase();return void 0===e.subsection?`${o}.${n}`:`${o}.${e.subsection}.${n}`},exports.readBlob=as,exports.readConfig=Cn,exports.readConfigSections=Ha,exports.readHeadTree=async t=>{const n=await ei(t,"HEAD").catch(t=>{if(!(t instanceof e.TsgitError&&"REF_NOT_FOUND"===t.data.code))throw t});if(void 0===n)return;const o=await is(t,n);if("commit"!==o.type)throw u("commit",o.type,n);return Ei(t,o.data.tree)},exports.readIndex=$s,exports.readObject=is,exports.readReflog=async function(e,t){const n=vn(pn(e,t),t);if(!await e.fs.exists(n))return[];if((await e.fs.stat(n)).size>16777216)throw ft("reflog file exceeds 16777216 bytes");return(await e.fs.readUtf8(n)).split("\n").filter(e=>""!==e).map(pt)},exports.readShallow=La,exports.readSparsePatternText=Ls,exports.readTree=ti,exports.recordRefUpdate=Xo,exports.refNotFound=xt,exports.reflogEntryOutOfRange=(t,n,o)=>new e.TsgitError({code:"REFLOG_ENTRY_OUT_OF_RANGE",ref:t,requested:n,available:o}),exports.reflogExists=Vo,exports.reflogNotFound=t=>new e.TsgitError({code:"REFLOG_NOT_FOUND",ref:t}),exports.removeConfigSection=async({ctx:t,sectionName:n,scope:o})=>{const r=o??"local",s=await Fa(t,r),i=await rc(t,s);if(-1===tc(i.split("\n"),n))throw e.configSectionNotFound(n,r);const a=nc(i,n);await t.fs.writeUtf8(s,a),$n(t),Wa(t)},exports.removeWorkingTreeFile=async(e,t)=>{const n=er(e.layout.workDir,t);await vr(e,n)},exports.renameConfigSection=async({ctx:t,oldName:n,newName:o,scope:r})=>{const s=(t=>{if(""===t)throw e.invalidOption("config",`invalid section name: ${t}`);const n=t.indexOf("."),o=-1===n?t:t.slice(0,n);if(o.length>0&&!/^[a-zA-Z0-9-]+$/.test(o))throw e.invalidOption("config",`invalid section name: ${t}`);return-1===n?{section:o}:{section:o,subsection:t.slice(n+1)}})(o);void 0!==s.subsection&&Xa(s.subsection);const i=r??"local",a=await Fa(t,i),c=await rc(t,a);if(-1===tc(c.split("\n"),n))throw e.configSectionNotFound(n,i);const d=oc(c,n,s);await t.fs.writeUtf8(a,d),$n(t),Wa(t)},exports.resolveAttribute=fr,exports.resolveFilterDriver=ds,exports.resolveNotesRef=async function(e,t){if(void 0!==t)return Tt((e=>e.startsWith(Vc)?e:e.startsWith("notes/")?`refs/${e}`:`${Vc}${e}`)(t));const n=e.env?.get("GIT_NOTES_REF");if(void 0!==n)return Tt(qc(n));const o=await Cn(e),r=o.core?.notesRef;return void 0!==r?Tt(qc(r)):Yc},exports.resolveRef=ei,exports.resolveReflogIdentity=jo,exports.resolveSigningSelector=e=>e.keyOverride??e.signingKey??e.fallbackIdent,exports.resolveTagChain=Gi,exports.runFilterDriver=us,exports.runHook=async(t,n,o={})=>{const r=await ka(t,n,o);if(void 0!==r&&"skipped"!==r.kind&&0!==r.exitCode)throw e.hookFailed(n,r.exitCode,r.stderr)},exports.runInformationalHook=async(e,t,n={})=>{await ka(e,t,n)},exports.sanitizeReflogMessage=gt,exports.selectParents=Ic,exports.serializeCommitContent=ee,exports.serializeCone=e=>{const t=[...e.parents,...e.recursive].sort();let n="";for(const o of t)n+=`/${o}/\n`,e.parents.has(o)&&(n+=`!/${o}/*/\n`);return"/*\n!/*/\n"+n},exports.serializeObject=fe,exports.serializeSymbolicRef=function(e){return`ref: ${e}\n`},exports.serializeTagContent=se,exports.setConfigEntry=async({ctx:t,key:n,value:o,scope:r})=>{const s=T(n);((t,n)=>{for(let o=0;o<n.length;o+=1)if(0===n.charCodeAt(o))throw e.configValueInvalid(t,o)})(n,o);const i=r??"local";await(async(e,t)=>{const n=await Fa(e,t),r=await rc(e,n);wc(r,n);const i=dc(r,s.section,s.subsection,s.name,o);await e.fs.writeUtf8(n,i),$n(e),Wa(e)})(t,i)},exports.setConfigEntryInText=dc,exports.setCoreConfigEntryInText=(e,t,n)=>dc(e,"core",void 0,t,n),exports.setSlot=Pc,exports.signPayload=async(e,t,n)=>{const o=e.command;return void 0===o?{ok:!1,reason:"off-node"}:"x509"===n.format?{ok:!1,reason:"unsupported-format"}:"ssh"===n.format?(async(e,t,n,o)=>{const r=o.program??"ssh-keygen",s=`${e.layout.gitDir}/GIT_SIGNING_BUFFER`,i=`${s}.sig`;await e.fs.write(s,n);try{if(0!==(await t.run({command:`${mc(r)} -Y sign -n git -f ${mc(o.selector)} ${mc(s)}`,cwd:e.layout.workDir,env:{GIT_DIR:e.layout.gitDir},...void 0!==e.signal?{signal:e.signal}:{}})).exitCode)return{ok:!1,reason:"signer-failed"};const n=await(async(e,t)=>{try{return vc.decode(await e.fs.read(t))}catch(e){if(kc(e))return;throw e}})(e,i);return void 0!==n&&bc(n)?{ok:!0,armor:n}:{ok:!1,reason:"signer-failed"}}finally{await Ec(e,s),await Ec(e,i)}})(e,o,t,n):(async(e,t,n,o)=>{const r=o.program??"gpg",s=await t.run({command:`${mc(r)} --status-fd=2 -bsau ${mc(o.selector)}`,cwd:e.layout.workDir,env:{GIT_DIR:e.layout.gitDir},stdin:n,...void 0!==e.signal?{signal:e.signal}:{}}),i=vc.decode(s.stdout??yc);return 0===s.exitCode&&bc(i)?{ok:!0,armor:i}:{ok:!1,reason:"signer-failed"}})(e,o,t,n)},exports.skipWorktreeEntry=O,exports.sortByPath=$e,exports.sparseCheckoutPath=xn,exports.splitLines=Ue,exports.sqQuote=mc,exports.streamBlob=fs,exports.synthesizeTreeFromIndex=async(e,t)=>Ta(e,(e=>{const t=[];for(const n of e)0===n.flags.stage&&(me(n.path,-1),Ia(n.path),t.push({path:n.path,id:n.id,mode:n.mode}));return t})(t)),exports.toSimilarityPercent=function(e){return 100*e/We|0},exports.treeDepthExceeded=f,exports.tryEmit=Hi,exports.unexpectedObjectType=u,exports.unpackSubtree=Kc,exports.unsetAllConfigEntries=async({ctx:e,key:t,scope:n})=>{const o=T(t),r=n??"local",s=await Fa(e,r),i=await rc(e,s),a=wc(i,s);if(0===Ua(a,o).length)return;const c=lc(i,o.section,o.subsection,o.name);await e.fs.writeUtf8(s,c),$n(e),Wa(e)},exports.unsetConfigEntry=async({ctx:t,key:n,scope:o})=>{const r=T(n),s=o??"local",i=await Fa(t,s),a=await rc(t,i),c=wc(a,i),d=Ua(c,r);if(0===d.length)return;if(d.length>1)throw e.configMultipleValues(n,d.length,"remove",s);const u=lc(a,r.section,r.subsection,r.name);await t.fs.writeUtf8(i,u),$n(t),Wa(t)},exports.updateConfigEntries=hc,exports.updateConfigOperations=async(e,t)=>{const n=`${e.layout.gitDir}/config`,o=await rc(e,n);wc(o,n);const r=t.reduce(pc,o);await e.fs.writeUtf8(n,r),$n(e)},exports.updateCoreConfig=async(e,t)=>{await hc(e,Object.entries(t).map(([e,t])=>({section:"core",key:e,value:t})))},exports.updateRef=async function(t,n,o,r){Tt(n);const s=wn(t.layout.gitDir,n),i=Qo(t),a=await i.resolveDirect(n);if(void 0!==r.expected){const t="direct"===a.kind?a.id:"absent";if(r.expected!==t)throw((t,n,o)=>new e.TsgitError({code:"REF_UPDATE_CONFLICT",name:t,expected:n,actual:o}))(n,r.expected,t)}if(!0===r.delete)return await async function(t,n){if(await t.isLoose(n))return void await t.removeLoose(n);if("direct"===(await t.resolveDirect(n)).kind)throw e.unsupportedOperation("delete-packed-ref","deleting packed-only refs requires packed-refs rewrite");throw xt(n)}(i,n),void await Yo(t,n);const c="direct"===a.kind?a.id:J,d=(new TextEncoder).encode(`${o}\n`);await kn(t,n,s,d),c!==o&&await Xo(t,n,c,o,r.reflogMessage),await async function(e,t,n,o,r,s){const i=await t.resolveDirect(Zo);"symbolic"===i.kind&&i.target===n&&await Xo(e,Zo,o,r,s)}(t,i,n,c,o,r.reflogMessage)},exports.updateShallow=async(e,t)=>{const n=new Set(await La(e));for(const e of t.shallow)n.add(e);for(const e of t.unshallow)n.delete(e);const o=Da(e);if(0===n.size)return void await(async(e,t)=>{try{await e.fs.rm(t)}catch(e){if(Oa(e))return;throw e}})(e,o);const r=[...n].sort(),s=(new TextEncoder).encode(r.map(e=>`${e}\n`).join(""));await(async(e,t,n)=>{const o=(e=>`${e.layout.gitDir}/shallow.lock`)(e);await e.fs.writeExclusive(o,n);try{await e.fs.rename(o,t)}catch(t){try{await e.fs.rm(o)}catch(e){if(!Oa(e))throw e}throw t}})(e,o,s)},exports.validateRefName=Tt,exports.validateWorkingTreePath=Fs,exports.verifyPackTrailer=sa,exports.walkCommits=Yi,exports.walkCommitsByDate=async function*(t,n){(t=>{if(Tr(t))throw e.invalidWalkInput(Er);if(Cr(t))throw e.invalidWalkInput(Ir)})(n.from);for await(const e of Tc(t,n))yield e.commit},exports.walkPackEntries=ia,exports.walkSubmodules=async function*(e,t){const n=t?.ref??td,o=!0===t?.recursive,r=t?.maxDepth??100,s=await ti(e,n),i=new Set([e.layout.gitDir]);yield*od(e,s,0,void 0,"",i,o,r)},exports.walkTree=bs,exports.walkWorkingTree=async function*(e,t){const n={ctx:e,maxDepth:t?.maxDepth??4096,maxEntries:t?.maxEntries??C,ignore:t?.ignore};yield*Gs(n,{value:0},"",0,!0)},exports.writeNotesTree=async function(e,t){const n=await((e,t,n=0,o=0)=>ud(e,t,n,o,""))(t.trie,t.read);return $a(e,{tree:await fd(e,n.entries),parents:void 0!==t.prevCommitOid?[t.prevCommitOid]:[],author:t.author,committer:t.author,message:t.message})},exports.writeObject=qs,exports.writeReflog=async function(e,t,n){const o=n.map(ht).join("");await e.fs.writeUtf8(vn(pn(e,t),t),o)},exports.writeSparsePatternText=async(e,t)=>{await e.fs.mkdir(`${e.layout.gitDir}/info`),await e.fs.writeUtf8(xn(e.layout.gitDir),t)},exports.writeTree=Ea,exports.writeWorkingTreeEntry=br,exports.writeWorkingTreeFile=async(e,t,n)=>{await xr(e,er(e.layout.workDir,t),n)},exports.writeWorkingTreeFileStream=async(e,t,n)=>{await kr(e,er(e.layout.workDir,t),n)};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../chunks/index-
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";var e=require("../chunks/index-Cy44GVR6.cjs");require("../chunks/error-CfLWDui_.cjs"),require("../chunks/write-sparse-checkout-C1dsHCAD.cjs"),require("../chunks/readable-stream-MTA6D0Zh.cjs"),require("../transport/index.cjs"),exports.add=e.add,exports.archive=e.archive,exports.bindBranchNamespace=e.bindBranchNamespace,exports.bindBundleNamespace=e.bindBundleNamespace,exports.bindCherryPickNamespace=e.bindCherryPickNamespace,exports.bindConfigNamespace=e.bindConfigNamespace,exports.bindMergeNamespace=e.bindMergeNamespace,exports.bindNotesNamespace=e.bindNotesNamespace,exports.bindRebaseNamespace=e.bindRebaseNamespace,exports.bindRemoteNamespace=e.bindRemoteNamespace,exports.bindRevertNamespace=e.bindRevertNamespace,exports.bindSparseCheckoutNamespace=e.bindSparseCheckoutNamespace,exports.bindStashNamespace=e.bindStashNamespace,exports.bindSubmoduleNamespace=e.bindSubmoduleNamespace,exports.bindTagNamespace=e.bindTagNamespace,exports.bindWorktreeNamespace=e.bindWorktreeNamespace,exports.blame=e.blame,exports.branchCreate=e.branchCreate,exports.branchDelete=e.branchDelete,exports.branchList=e.branchList,exports.branchRename=e.branchRename,exports.bundleCreate=e.bundleCreate,exports.bundleListHeads=e.bundleListHeads,exports.bundleVerify=e.bundleVerify,exports.catFile=e.catFile,exports.checkout=e.checkout,exports.cherryPickAbort=e.cherryPickAbort,exports.cherryPickContinue=e.cherryPickContinue,exports.cherryPickRun=e.cherryPickRun,exports.cherryPickSkip=e.cherryPickSkip,exports.clone=e.clone,exports.commit=e.commit,exports.configGet=e.configGet,exports.configGetAll=e.configGetAll,exports.configGetRegexp=e.configGetRegexp,exports.configList=e.configList,exports.configRemoveSection=e.configRemoveSection,exports.configRenameSection=e.configRenameSection,exports.configSet=e.configSet,exports.configUnset=e.configUnset,exports.configUnsetAll=e.configUnsetAll,exports.createPromisorRemote=e.createPromisorRemote,exports.describe=e.describe,exports.diff=e.diff,exports.fetch=e.fetch,exports.fetchMissing=e.fetchMissing,exports.fsck=e.fsck,exports.grep=e.grep,exports.init=e.init,exports.log=e.log,exports.mergeAbort=e.mergeAbort,exports.mergeContinue=e.mergeContinue,exports.mergeRun=e.mergeRun,exports.mv=e.mv,exports.nameRev=e.nameRev,exports.notesAdd=e.notesAdd,exports.notesList=e.notesList,exports.notesRead=e.notesRead,exports.notesRemove=e.notesRemove,exports.pull=e.pull,exports.push=e.push,exports.rangeDiff=e.rangeDiff,exports.readFileAt=e.readFileAt,exports.rebaseAbort=e.rebaseAbort,exports.rebaseContinue=e.rebaseContinue,exports.rebaseRun=e.rebaseRun,exports.rebaseSkip=e.rebaseSkip,exports.reflog=e.reflog,exports.remoteAdd=e.remoteAdd,exports.remoteList=e.remoteList,exports.remoteRemove=e.remoteRemove,exports.remoteRename=e.remoteRename,exports.remoteSetUrl=e.remoteSetUrl,exports.remoteShow=e.remoteShow,exports.reset=e.reset,exports.revParse=e.revParse,exports.revertAbort=e.revertAbort,exports.revertContinue=e.revertContinue,exports.revertRun=e.revertRun,exports.revertSkip=e.revertSkip,exports.rm=e.rm,exports.shortlog=e.shortlog,exports.show=e.show,exports.sparseCheckoutAdd=e.sparseCheckoutAdd,exports.sparseCheckoutDisable=e.sparseCheckoutDisable,exports.sparseCheckoutList=e.sparseCheckoutList,exports.sparseCheckoutReapply=e.sparseCheckoutReapply,exports.sparseCheckoutSet=e.sparseCheckoutSet,exports.stashApply=e.stashApply,exports.stashDrop=e.stashDrop,exports.stashList=e.stashList,exports.stashPop=e.stashPop,exports.stashPush=e.stashPush,exports.status=e.status,exports.submoduleAdd=e.submoduleAdd,exports.submoduleDeinit=e.submoduleDeinit,exports.submoduleInit=e.submoduleInit,exports.submoduleList=e.submoduleList,exports.submoduleSync=e.submoduleSync,exports.submoduleUpdate=e.submoduleUpdate,exports.tagCreate=e.tagCreate,exports.tagDelete=e.tagDelete,exports.tagList=e.tagList,exports.whatchanged=e.whatchanged,exports.worktreeAdd=e.worktreeAdd,exports.worktreeList=e.worktreeList,exports.worktreeMove=e.worktreeMove,exports.worktreeRemove=e.worktreeRemove;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./chunks/browser-http-transport-
|
|
2
|
-
//# sourceMappingURL=index.browser.cjs.map
|
|
1
|
+
"use strict";var e=require("./chunks/browser-http-transport-DGwW5YL7.cjs"),r=require("./chunks/lru-cache-1OU7JhD8.cjs"),s=require("./chunks/repository-Ci-BBxk0.cjs"),t=require("./chunks/adapter-detect-DW9fsw9d.cjs"),o=require("./chunks/progress-D8Dqbftk.cjs"),c=require("./chunks/write-sparse-checkout-C1dsHCAD.cjs");require("./chunks/inflate-CmCtM4-w.cjs"),require("./chunks/error-CfLWDui_.cjs"),require("./chunks/index-Cy44GVR6.cjs"),require("./chunks/readable-stream-MTA6D0Zh.cjs"),require("./transport/index.cjs"),require("./primitives/index.cjs"),exports.detectRuntime=t.detectRuntime,exports.isBrowser=t.isBrowser,exports.isNode=t.isNode,exports.consoleProgress=o.consoleProgress,exports.noopProgress=o.noopProgress,exports.FilePath=c.FilePath,exports.ObjectId=c.ObjectId,exports.RefName=c.RefName,exports.openRepository=async t=>{const o=t.gitDirName??".git",c={fs:new e.BrowserFileSystem(t.rootHandle),hash:new e.BrowserHashService,compressor:new e.BrowserCompressor,transport:new e.BrowserHttpTransport,runtime:"browser",layout:{workDir:"/",gitDir:`/${o}`,bare:t.bare??!1},hashConfig:r.SHA1_CONFIG,deltaCache:r.createLruCache(t.deltaCacheMaxBytes??16777216,t.deltaCacheMaxEntries??65536)},{rootHandle:a,gitDirName:i,bare:n,deltaCacheMaxBytes:u,deltaCacheMaxEntries:p,...h}=t;return s.openRepository({cwd:"/",...h},c)};
|