vbapm 0.6.14 → 0.7.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.
Files changed (72) hide show
  1. package/README.md +46 -0
  2. package/addins/build/vbapm.xlam +0 -0
  3. package/lib/_commonjsHelpers-Bjf42z7h.js +1 -0
  4. package/lib/actions/add-source.d.ts +11 -0
  5. package/lib/add-source-_Z4tr2ea.js +17 -0
  6. package/lib/bin/vbapm-add.d.ts +2 -0
  7. package/lib/build-project-CIZanDh1.js +3 -0
  8. package/lib/build-target-B03OPzeI.js +9 -0
  9. package/lib/crc32-Cc3OMFYk.js +1 -0
  10. package/lib/create-project-CTAlegO8.js +10 -0
  11. package/lib/debug.js +1 -1
  12. package/lib/errors.d.ts +4 -0
  13. package/lib/export-project-DdTYRyAw.js +4 -0
  14. package/lib/export-target-CEupP86g.js +4 -0
  15. package/lib/{get-target-e760a439.js → get-target-Ba_ZoGUl.js} +1 -1
  16. package/lib/index-BlteXxjY.js +1 -0
  17. package/lib/index-CB6KQLC7.js +13 -0
  18. package/lib/index-CEojr58e.js +2 -0
  19. package/lib/index-Cwtynogk.js +54 -0
  20. package/lib/index-DSgWshzu.js +2 -0
  21. package/lib/index-_8uEunjn.js +6 -0
  22. package/lib/index-mBZsirl0.js +14 -0
  23. package/lib/index.d.ts +1 -0
  24. package/lib/index.js +1 -1
  25. package/lib/init-project-BY-a8CIk.js +15 -0
  26. package/lib/installer-C0iBwEpK.js +9 -0
  27. package/lib/{load-from-project-acf7400a.js → load-from-project-wNJg8fme.js} +1 -1
  28. package/lib/once-fkpTAKD3.js +1 -0
  29. package/lib/one_ini_bg.wasm +0 -0
  30. package/lib/project-DFh-2QTw.js +20 -0
  31. package/lib/run-macro-Ck_8Iku3.js +1 -0
  32. package/lib/sat-solver-CqS8Vf6C.js +1 -0
  33. package/lib/string_decoder-CW-j4E6X.js +1 -0
  34. package/lib/test-project-CM-XUOdH.js +1 -0
  35. package/lib/tmp-C7yJT4iq.js +8 -0
  36. package/lib/toml-patch-r8oqFm0h.js +3 -0
  37. package/lib/transform-target-DJmqMjY0.js +2 -0
  38. package/lib/vbapm-add-QPN5uEGK.js +16 -0
  39. package/lib/vbapm-build-BKtQ6OeP.js +9 -0
  40. package/lib/vbapm-export-4H_qDinP.js +7 -0
  41. package/lib/{vbapm-init-5c8eb026.js → vbapm-init-BMY4x_xq.js} +2 -2
  42. package/lib/vbapm-new-DLW9SdvJ.js +17 -0
  43. package/lib/vbapm-run-DzRxAhlD.js +10 -0
  44. package/lib/{vbapm-test-a7b30592.js → vbapm-test-DInh0MDC.js} +1 -1
  45. package/lib/vbapm-version-3Xv7JjGv.js +8 -0
  46. package/lib/vbapm.js +11 -10
  47. package/package.json +124 -137
  48. package/lib/_commonjsHelpers-553b27b3.js +0 -1
  49. package/lib/build-project-eb8454f0.js +0 -3
  50. package/lib/build-target-dbcc69c7.js +0 -9
  51. package/lib/create-project-3154aace.js +0 -10
  52. package/lib/export-project-bc13c1ae.js +0 -4
  53. package/lib/export-target-5d28d188.js +0 -4
  54. package/lib/index-4ce3d28b.js +0 -6
  55. package/lib/index-72c1a91d.js +0 -3
  56. package/lib/index-c5b5f6d1.js +0 -2
  57. package/lib/index-ddd39b65.js +0 -5
  58. package/lib/init-project-ceecd718.js +0 -15
  59. package/lib/installer-dbc2c34a.js +0 -21
  60. package/lib/once-5205b917.js +0 -1
  61. package/lib/project-43370ed3.js +0 -29
  62. package/lib/run-macro-4f1375ca.js +0 -1
  63. package/lib/sat-solver-f9155891.js +0 -1
  64. package/lib/test-project-669dfcfb.js +0 -1
  65. package/lib/tmp-14f9d850.js +0 -9
  66. package/lib/toml-patch.es-6bd2145d.js +0 -3
  67. package/lib/vbapm-build-8ff58485.js +0 -9
  68. package/lib/vbapm-export-96798f4f.js +0 -7
  69. package/lib/vbapm-new-cd174cbb.js +0 -17
  70. package/lib/vbapm-run-2f17fb22.js +0 -10
  71. package/lib/vbapm-version-c5f3d55a.js +0 -8
  72. package/lib/workbook-xml-a61269f4.js +0 -2
@@ -1,6 +0,0 @@
1
- "use strict";var t=require("./_commonjsHelpers-553b27b3.js"),e=require("util"),i=require("./index-72c1a91d.js");function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}require("buffer");var a=r(e),n=function(t){if(t=t||{},this.Promise=t.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=t.domainReentrant||!1,this.domainReentrant){if("undefined"==typeof process||void 0===process.domain)throw new Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=t.timeout||n.DEFAULT_TIMEOUT,this.maxOccupationTime=t.maxOccupationTime||n.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=t.maxExecutionTime||n.DEFAULT_MAX_EXECUTION_TIME,t.maxPending===1/0||Number.isInteger(t.maxPending)&&t.maxPending>=0?this.maxPending=t.maxPending:this.maxPending=n.DEFAULT_MAX_PENDING};n.DEFAULT_TIMEOUT=0,n.DEFAULT_MAX_OCCUPATION_TIME=0,n.DEFAULT_MAX_EXECUTION_TIME=0,n.DEFAULT_MAX_PENDING=1e3,n.prototype.acquire=function(t,e,i,r){if(Array.isArray(t))return this._acquireBatch(t,e,i,r);if("function"!=typeof e)throw new Error("You must pass a function to execute");var a=null,n=null,s=null;"function"!=typeof i&&(r=i,i=null,s=new this.Promise(function(t,e){a=t,n=e})),r=r||{};var o=!1,c=null,f=null,d=null,h=this,l=function(e,r,c){f&&(clearTimeout(f),f=null),d&&(clearTimeout(d),d=null),e&&(h.queues[t]&&0===h.queues[t].length&&delete h.queues[t],h.domainReentrant&&delete h.domains[t]),o||(s?r?n(r):a(c):"function"==typeof i&&i(r,c),o=!0),e&&h.queues[t]&&h.queues[t].length>0&&h.queues[t].shift()()},u=function(i){if(o)return l(i);c&&(clearTimeout(c),c=null),h.domainReentrant&&i&&(h.domains[t]=process.domain);var a=r.maxExecutionTime||h.maxExecutionTime;if(a&&(d=setTimeout(function(){h.queues[t]&&l(i,new Error("Maximum execution time is exceeded "+t))},a)),1===e.length){var n=!1;try{e(function(t,e){n||(n=!0,l(i,t,e))})}catch(t){n||(n=!0,l(i,t))}}else h._promiseTry(function(){return e()}).then(function(t){l(i,void 0,t)},function(t){l(i,t)})};h.domainReentrant&&process.domain&&(u=process.domain.bind(u));var g=r.maxPending||h.maxPending;if(h.queues[t])if(h.domainReentrant&&process.domain&&process.domain===h.domains[t])u(!1);else if(h.queues[t].length>=g)l(!1,new Error("Too many pending tasks in queue "+t));else{var w=function(){u(!0)};r.skipQueue?h.queues[t].unshift(w):h.queues[t].push(w);var p=r.timeout||h.timeout;p&&(c=setTimeout(function(){c=null,l(!1,new Error("async-lock timed out in queue "+t))},p))}else h.queues[t]=[],u(!0);var m=r.maxOccupationTime||h.maxOccupationTime;return m&&(f=setTimeout(function(){h.queues[t]&&l(!1,new Error("Maximum occupation time is exceeded in queue "+t))},m)),s||void 0},n.prototype._acquireBatch=function(t,e,i,r){"function"!=typeof i&&(r=i,i=null);var a=this,n=t.reduceRight(function(t,e){return function(t,e){return function(i){a.acquire(t,e,i,r)}}(e,t)},e);if("function"!=typeof i)return new this.Promise(function(t,e){1===n.length?n(function(i,r){i?e(i):t(r)}):t(n())});n(i)},n.prototype.isBusy=function(t){return t?!!this.queues[t]:Object.keys(this.queues).length>0},n.prototype._promiseTry=function(t){try{return this.Promise.resolve(t())}catch(t){return this.Promise.reject(t)}};var s=n,o=t.createCommonjsModule(function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}}}),c=t.createCommonjsModule(function(t){try{var e=a.default;if("function"!=typeof e.inherits)throw"";t.exports=e.inherits}catch(e){t.exports=o}}),f=i.safeBuffer.Buffer;function d(t,e){this._block=f.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}d.prototype.update=function(t,e){t=i.toBuffer(t,e||"utf8");for(var r=this._block,a=this._blockSize,n=t.length,s=this._len,o=0;o<n;){for(var c=s%a,f=Math.min(n-o,a-c),d=0;d<f;d++)r[c+d]=t[o+d];o+=f,(s+=f)%a===0&&this._update(r)}return this._len+=n,this},d.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var i=8*this._len;if(i<=4294967295)this._block.writeUInt32BE(i,this._blockSize-4);else{var r=(4294967295&i)>>>0,a=(i-r)/4294967296;this._block.writeUInt32BE(a,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var n=this._hash();return t?n.toString(t):n},d.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var h=d,l=i.safeBuffer.Buffer,u=[1518500249,1859775393,-1894007588,-899497514],g=new Array(80);function w(){this.init(),this._w=g,h.call(this,64,56)}function p(t){return t<<1|t>>>31}function m(t){return t<<5|t>>>27}function y(t){return t<<30|t>>>2}function b(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}c(w,h),w.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},w.prototype._update=function(t){for(var e=this._w,i=0|this._a,r=0|this._b,a=0|this._c,n=0|this._d,s=0|this._e,o=0;o<16;++o)e[o]=t.readInt32BE(4*o);for(;o<80;++o)e[o]=p(e[o-3]^e[o-8]^e[o-14]^e[o-16]);for(var c=0;c<80;++c){var f=~~(c/20),d=m(i)+b(f,r,a,n)+s+e[c]+u[f]|0;s=n,n=a,a=y(r),r=i,i=d}this._a=i+this._a|0,this._b=r+this._b|0,this._c=a+this._c|0,this._d=n+this._d|0,this._e=s+this._e|0},w.prototype._hash=function(){var t=l.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t};var _=w,v=t.createCommonjsModule(function(t,e){!function(t){"undefined"==typeof DO_NOT_EXPORT_CRC?t(e):t({})}(function(t){t.version="1.2.0";var e=function(){for(var t=0,e=new Array(256),i=0;256!=i;++i)t=1&(t=1&(t=1&(t=1&(t=1&(t=1&(t=1&(t=1&(t=i)?-306674912^t>>>1:t>>>1)?-306674912^t>>>1:t>>>1)?-306674912^t>>>1:t>>>1)?-306674912^t>>>1:t>>>1)?-306674912^t>>>1:t>>>1)?-306674912^t>>>1:t>>>1)?-306674912^t>>>1:t>>>1)?-306674912^t>>>1:t>>>1,e[i]=t;return"undefined"!=typeof Int32Array?new Int32Array(e):e}();t.table=e,t.bstr=function(t,i){for(var r=-1^i,a=t.length-1,n=0;n<a;)r=(r=r>>>8^e[255&(r^t.charCodeAt(n++))])>>>8^e[255&(r^t.charCodeAt(n++))];return n===a&&(r=r>>>8^e[255&(r^t.charCodeAt(n))]),-1^r},t.buf=function(t,i){if(t.length>1e4)return function(t,i){for(var r=-1^i,a=t.length-7,n=0;n<a;)r=(r=(r=(r=(r=(r=(r=(r=r>>>8^e[255&(r^t[n++])])>>>8^e[255&(r^t[n++])])>>>8^e[255&(r^t[n++])])>>>8^e[255&(r^t[n++])])>>>8^e[255&(r^t[n++])])>>>8^e[255&(r^t[n++])])>>>8^e[255&(r^t[n++])])>>>8^e[255&(r^t[n++])];for(;n<a+7;)r=r>>>8^e[255&(r^t[n++])];return-1^r}(t,i);for(var r=-1^i,a=t.length-3,n=0;n<a;)r=(r=(r=(r=r>>>8^e[255&(r^t[n++])])>>>8^e[255&(r^t[n++])])>>>8^e[255&(r^t[n++])])>>>8^e[255&(r^t[n++])];for(;n<a+3;)r=r>>>8^e[255&(r^t[n++])];return-1^r},t.str=function(t,i){for(var r,a,n=-1^i,s=0,o=t.length;s<o;)(r=t.charCodeAt(s++))<128?n=n>>>8^e[255&(n^r)]:r<2048?n=(n=n>>>8^e[255&(n^(192|r>>6&31))])>>>8^e[255&(n^(128|63&r))]:r>=55296&&r<57344?(r=64+(1023&r),a=1023&t.charCodeAt(s++),n=(n=(n=(n=n>>>8^e[255&(n^(240|r>>8&7))])>>>8^e[255&(n^(128|r>>2&63))])>>>8^e[255&(n^(128|a>>6&15|(3&r)<<4))])>>>8^e[255&(n^(128|63&a))]):n=(n=(n=n>>>8^e[255&(n^(224|r>>12&15))])>>>8^e[255&(n^(128|r>>6&63))])>>>8^e[255&(n^(128|63&r))];return-1^n}})}),x=t.createCommonjsModule(function(t,e){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var a in i)r(i,a)&&(t[a]=i[a])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var a={arraySet:function(t,e,i,r,a){if(e.subarray&&t.subarray)t.set(e.subarray(i,i+r),a);else for(var n=0;n<r;n++)t[a+n]=e[i+n]},flattenChunks:function(t){var e,i,r,a,n,s;for(r=0,e=0,i=t.length;e<i;e++)r+=t[e].length;for(s=new Uint8Array(r),a=0,e=0,i=t.length;e<i;e++)n=t[e],s.set(n,a),a+=n.length;return s}},n={arraySet:function(t,e,i,r,a){for(var n=0;n<r;n++)t[a+n]=e[i+n]},flattenChunks:function(t){return[].concat.apply([],t)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,a)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,n))},e.setTyped(i)});function k(t){for(var e=t.length;--e>=0;)t[e]=0}var E=256,$=286,S=30,A=15,B=[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],R=[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],P=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],O=new Array(576);k(O);var I=new Array(60);k(I);var C=new Array(512);k(C);var z=new Array(256);k(z);var D=new Array(29);k(D);var T,U,N,M=new Array(S);function F(t,e,i,r,a){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=r,this.max_length=a,this.has_stree=t&&t.length}function H(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function q(t){return t<256?C[t]:C[256+(t>>>7)]}function L(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function W(t,e,i){t.bi_valid>16-i?(t.bi_buf|=e<<t.bi_valid&65535,L(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=i)}function G(t,e,i){W(t,i[2*e],i[2*e+1])}function Z(t,e){var i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1}function K(t,e,i){var r,a,n=new Array(16),s=0;for(r=1;r<=A;r++)n[r]=s=s+i[r-1]<<1;for(a=0;a<=e;a++){var o=t[2*a+1];0!==o&&(t[2*a]=Z(n[o]++,o))}}function V(t){var e;for(e=0;e<$;e++)t.dyn_ltree[2*e]=0;for(e=0;e<S;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function X(t){t.bi_valid>8?L(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function Y(t,e,i,r){var a=2*e,n=2*i;return t[a]<t[n]||t[a]===t[n]&&r[e]<=r[i]}function J(t,e,i){for(var r=t.heap[i],a=i<<1;a<=t.heap_len&&(a<t.heap_len&&Y(e,t.heap[a+1],t.heap[a],t.depth)&&a++,!Y(e,r,t.heap[a],t.depth));)t.heap[i]=t.heap[a],i=a,a<<=1;t.heap[i]=r}function Q(t,e,i){var r,a,n,s,o=0;if(0!==t.last_lit)do{r=t.pending_buf[t.d_buf+2*o]<<8|t.pending_buf[t.d_buf+2*o+1],a=t.pending_buf[t.l_buf+o],o++,0===r?G(t,a,e):(G(t,(n=z[a])+E+1,e),0!==(s=B[n])&&W(t,a-=D[n],s),G(t,n=q(--r),i),0!==(s=R[n])&&W(t,r-=M[n],s))}while(o<t.last_lit);G(t,256,e)}function tt(t,e){var i,r,a,n=e.dyn_tree,s=e.stat_desc.static_tree,o=e.stat_desc.has_stree,c=e.stat_desc.elems,f=-1;for(t.heap_len=0,t.heap_max=573,i=0;i<c;i++)0!==n[2*i]?(t.heap[++t.heap_len]=f=i,t.depth[i]=0):n[2*i+1]=0;for(;t.heap_len<2;)n[2*(a=t.heap[++t.heap_len]=f<2?++f:0)]=1,t.depth[a]=0,t.opt_len--,o&&(t.static_len-=s[2*a+1]);for(e.max_code=f,i=t.heap_len>>1;i>=1;i--)J(t,n,i);a=c;do{i=t.heap[1],t.heap[1]=t.heap[t.heap_len--],J(t,n,1),r=t.heap[1],t.heap[--t.heap_max]=i,t.heap[--t.heap_max]=r,n[2*a]=n[2*i]+n[2*r],t.depth[a]=(t.depth[i]>=t.depth[r]?t.depth[i]:t.depth[r])+1,n[2*i+1]=n[2*r+1]=a,t.heap[1]=a++,J(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var i,r,a,n,s,o,c=e.dyn_tree,f=e.max_code,d=e.stat_desc.static_tree,h=e.stat_desc.has_stree,l=e.stat_desc.extra_bits,u=e.stat_desc.extra_base,g=e.stat_desc.max_length,w=0;for(n=0;n<=A;n++)t.bl_count[n]=0;for(c[2*t.heap[t.heap_max]+1]=0,i=t.heap_max+1;i<573;i++)(n=c[2*c[2*(r=t.heap[i])+1]+1]+1)>g&&(n=g,w++),c[2*r+1]=n,r>f||(t.bl_count[n]++,s=0,r>=u&&(s=l[r-u]),o=c[2*r],t.opt_len+=o*(n+s),h&&(t.static_len+=o*(d[2*r+1]+s)));if(0!==w){do{for(n=g-1;0===t.bl_count[n];)n--;t.bl_count[n]--,t.bl_count[n+1]+=2,t.bl_count[g]--,w-=2}while(w>0);for(n=g;0!==n;n--)for(r=t.bl_count[n];0!==r;)(a=t.heap[--i])>f||(c[2*a+1]!==n&&(t.opt_len+=(n-c[2*a+1])*c[2*a],c[2*a+1]=n),r--)}}(t,e),K(n,f,t.bl_count)}function et(t,e,i){var r,a,n=-1,s=e[1],o=0,c=7,f=4;for(0===s&&(c=138,f=3),e[2*(i+1)+1]=65535,r=0;r<=i;r++)a=s,s=e[2*(r+1)+1],++o<c&&a===s||(o<f?t.bl_tree[2*a]+=o:0!==a?(a!==n&&t.bl_tree[2*a]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,n=a,0===s?(c=138,f=3):a===s?(c=6,f=3):(c=7,f=4))}function it(t,e,i){var r,a,n=-1,s=e[1],o=0,c=7,f=4;for(0===s&&(c=138,f=3),r=0;r<=i;r++)if(a=s,s=e[2*(r+1)+1],!(++o<c&&a===s)){if(o<f)do{G(t,a,t.bl_tree)}while(0!==--o);else 0!==a?(a!==n&&(G(t,a,t.bl_tree),o--),G(t,16,t.bl_tree),W(t,o-3,2)):o<=10?(G(t,17,t.bl_tree),W(t,o-3,3)):(G(t,18,t.bl_tree),W(t,o-11,7));o=0,n=a,0===s?(c=138,f=3):a===s?(c=6,f=3):(c=7,f=4)}}k(M);var rt=!1;function at(t,e,i,r){W(t,0+(r?1:0),3),function(t,e,i,r){X(t),r&&(L(t,i),L(t,~i)),x.arraySet(t.pending_buf,t.window,e,i,t.pending),t.pending+=i}(t,e,i,!0)}var nt=function(t,e,i,r){var a,n,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<E;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),tt(t,t.l_desc),tt(t,t.d_desc),s=function(t){var e;for(et(t,t.dyn_ltree,t.l_desc.max_code),et(t,t.dyn_dtree,t.d_desc.max_code),tt(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*j[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),a=t.opt_len+3+7>>>3,(n=t.static_len+3+7>>>3)<=a&&(a=n)):a=n=i+5,i+4<=a&&-1!==e?at(t,e,i,r):4===t.strategy||n===a?(W(t,2+(r?1:0),3),Q(t,O,I)):(W(t,4+(r?1:0),3),function(t,e,i,r){var a;for(W(t,e-257,5),W(t,i-1,5),W(t,r-4,4),a=0;a<r;a++)W(t,t.bl_tree[2*j[a]+1],3);it(t,t.dyn_ltree,e-1),it(t,t.dyn_dtree,i-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),Q(t,t.dyn_ltree,t.dyn_dtree)),V(t),r&&X(t)},st={_tr_init:function(t){rt||(!function(){var t,e,i,r,a,n=new Array(16);for(i=0,r=0;r<28;r++)for(D[r]=i,t=0;t<1<<B[r];t++)z[i++]=r;for(z[i-1]=r,a=0,r=0;r<16;r++)for(M[r]=a,t=0;t<1<<R[r];t++)C[a++]=r;for(a>>=7;r<S;r++)for(M[r]=a<<7,t=0;t<1<<R[r]-7;t++)C[256+a++]=r;for(e=0;e<=A;e++)n[e]=0;for(t=0;t<=143;)O[2*t+1]=8,t++,n[8]++;for(;t<=255;)O[2*t+1]=9,t++,n[9]++;for(;t<=279;)O[2*t+1]=7,t++,n[7]++;for(;t<=287;)O[2*t+1]=8,t++,n[8]++;for(K(O,287,n),t=0;t<S;t++)I[2*t+1]=5,I[2*t]=Z(t,5);T=new F(O,B,257,$,A),U=new F(I,R,0,S,A),N=new F(new Array(0),P,0,19,7)}(),rt=!0),t.l_desc=new H(t.dyn_ltree,T),t.d_desc=new H(t.dyn_dtree,U),t.bl_desc=new H(t.bl_tree,N),t.bi_buf=0,t.bi_valid=0,V(t)},_tr_stored_block:at,_tr_flush_block:nt,_tr_tally:function(t,e,i){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(z[i]+E+1)]++,t.dyn_dtree[2*q(e)]++),t.last_lit===t.lit_bufsize-1},_tr_align:function(t){W(t,2,3),G(t,256,O),function(t){16===t.bi_valid?(L(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}};var ot=function(t,e,i,r){for(var a=65535&t,n=t>>>16&65535,s=0;0!==i;){i-=s=i>2e3?2e3:i;do{n=n+(a=a+e[r++]|0)|0}while(--s);a%=65521,n%=65521}return a|n<<16};var ct=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();var ft,dt=function(t,e,i,r){var a=ct,n=r+i;t^=-1;for(var s=r;s<n;s++)t=t>>>8^a[255&(t^e[s])];return-1^t},ht={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},lt=-2,ut=258,gt=262,wt=103,pt=113,mt=666;function yt(t,e){return t.msg=ht[e],e}function bt(t){return(t<<1)-(t>4?9:0)}function _t(t){for(var e=t.length;--e>=0;)t[e]=0}function vt(t){var e=t.state,i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(x.arraySet(t.output,e.pending_buf,e.pending_out,i,t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))}function xt(t,e){st._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,vt(t.strm)}function kt(t,e){t.pending_buf[t.pending++]=e}function Et(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function $t(t,e,i,r){var a=t.avail_in;return a>r&&(a=r),0===a?0:(t.avail_in-=a,x.arraySet(e,t.input,t.next_in,a,i),1===t.state.wrap?t.adler=ot(t.adler,e,a,i):2===t.state.wrap&&(t.adler=dt(t.adler,e,a,i)),t.next_in+=a,t.total_in+=a,a)}function St(t,e){var i,r,a=t.max_chain_length,n=t.strstart,s=t.prev_length,o=t.nice_match,c=t.strstart>t.w_size-gt?t.strstart-(t.w_size-gt):0,f=t.window,d=t.w_mask,h=t.prev,l=t.strstart+ut,u=f[n+s-1],g=f[n+s];t.prev_length>=t.good_match&&(a>>=2),o>t.lookahead&&(o=t.lookahead);do{if(f[(i=e)+s]===g&&f[i+s-1]===u&&f[i]===f[n]&&f[++i]===f[n+1]){n+=2,i++;do{}while(f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&n<l);if(r=ut-(l-n),n=l-ut,r>s){if(t.match_start=e,s=r,r>=o)break;u=f[n+s-1],g=f[n+s]}}}while((e=h[e&d])>c&&0!==--a);return s<=t.lookahead?s:t.lookahead}function At(t){var e,i,r,a,n,s=t.w_size;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=s+(s-gt)){x.arraySet(t.window,t.window,s,s,0),t.match_start-=s,t.strstart-=s,t.block_start-=s,e=i=t.hash_size;do{r=t.head[--e],t.head[e]=r>=s?r-s:0}while(--i);e=i=s;do{r=t.prev[--e],t.prev[e]=r>=s?r-s:0}while(--i);a+=s}if(0===t.strm.avail_in)break;if(i=$t(t.strm,t.window,t.strstart+t.lookahead,a),t.lookahead+=i,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=(t.ins_h<<t.hash_shift^t.window[n+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[n+3-1])&t.hash_mask,t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<gt&&0!==t.strm.avail_in)}function Bt(t,e){for(var i,r;;){if(t.lookahead<gt){if(At(t),t.lookahead<gt&&0===e)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-gt&&(t.match_length=St(t,i)),t.match_length>=3)if(r=st._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else r=st._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}function Rt(t,e){for(var i,r,a;;){if(t.lookahead<gt){if(At(t),t.lookahead<gt&&0===e)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-gt&&(t.match_length=St(t,i),t.match_length<=5&&(1===t.strategy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){a=t.strstart+t.lookahead-3,r=st._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=a&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,r&&(xt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((r=st._tr_tally(t,0,t.window[t.strstart-1]))&&xt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=st._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}function Pt(t,e,i,r,a){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=r,this.func=a}function jt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new x.Buf16(1146),this.dyn_dtree=new x.Buf16(122),this.bl_tree=new x.Buf16(78),_t(this.dyn_ltree),_t(this.dyn_dtree),_t(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new x.Buf16(16),this.heap=new x.Buf16(573),_t(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new x.Buf16(573),_t(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Ot(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=2,(e=t.state).pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:pt,t.adler=2===e.wrap?0:1,e.last_flush=0,st._tr_init(e),0):yt(t,lt)}function It(t){var e,i=Ot(t);return 0===i&&((e=t.state).window_size=2*e.w_size,_t(e.head),e.max_lazy_match=ft[e.level].max_lazy,e.good_match=ft[e.level].good_length,e.nice_match=ft[e.level].nice_length,e.max_chain_length=ft[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0),i}function Ct(t,e,i,r,a,n){if(!t)return lt;var s=1;if(-1===e&&(e=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>9||8!==i||r<8||r>15||e<0||e>9||n<0||n>4)return yt(t,lt);8===r&&(r=9);var o=new jt;return t.state=o,o.strm=t,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=a+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new x.Buf8(2*o.w_size),o.head=new x.Buf16(o.hash_size),o.prev=new x.Buf16(o.w_size),o.lit_bufsize=1<<a+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new x.Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=n,o.method=i,It(t)}ft=[new Pt(0,0,0,0,function(t,e){var i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(At(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+i;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,xt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-gt&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(xt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(xt(t,!1),t.strm.avail_out),1)}),new Pt(4,4,8,4,Bt),new Pt(4,5,16,8,Bt),new Pt(4,6,32,32,Bt),new Pt(4,4,16,16,Rt),new Pt(8,16,32,32,Rt),new Pt(8,16,128,128,Rt),new Pt(8,32,128,256,Rt),new Pt(32,128,258,1024,Rt),new Pt(32,258,258,4096,Rt)];var zt=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==wt&&e!==pt&&e!==mt?yt(t,lt):(t.state=null,e===pt?yt(t,-3):0):lt},Dt={deflateInit:function(t,e){return Ct(t,e,8,15,8,0)},deflateInit2:Ct,deflateReset:It,deflateResetKeep:Ot,deflateSetHeader:function(t,e){return t&&t.state?2!==t.state.wrap?lt:(t.state.gzhead=e,0):lt},deflate:function(t,e){var i,r,a,n;if(!t||!t.state||e>5||e<0)return t?yt(t,lt):lt;if(r=t.state,!t.output||!t.input&&0!==t.avail_in||r.status===mt&&4!==e)return yt(t,0===t.avail_out?-5:lt);if(r.strm=t,i=r.last_flush,r.last_flush=e,42===r.status)if(2===r.wrap)t.adler=0,kt(r,31),kt(r,139),kt(r,8),r.gzhead?(kt(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),kt(r,255&r.gzhead.time),kt(r,r.gzhead.time>>8&255),kt(r,r.gzhead.time>>16&255),kt(r,r.gzhead.time>>24&255),kt(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),kt(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(kt(r,255&r.gzhead.extra.length),kt(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=dt(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(kt(r,0),kt(r,0),kt(r,0),kt(r,0),kt(r,0),kt(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),kt(r,3),r.status=pt);else{var s=8+(r.w_bits-8<<4)<<8;s|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(s|=32),s+=31-s%31,r.status=pt,Et(r,s),0!==r.strstart&&(Et(r,t.adler>>>16),Et(r,65535&t.adler)),t.adler=1}if(69===r.status)if(r.gzhead.extra){for(a=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>a&&(t.adler=dt(t.adler,r.pending_buf,r.pending-a,a)),vt(t),a=r.pending,r.pending!==r.pending_buf_size));)kt(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>a&&(t.adler=dt(t.adler,r.pending_buf,r.pending-a,a)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(t.adler=dt(t.adler,r.pending_buf,r.pending-a,a)),vt(t),a=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,kt(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>a&&(t.adler=dt(t.adler,r.pending_buf,r.pending-a,a)),0===n&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(t.adler=dt(t.adler,r.pending_buf,r.pending-a,a)),vt(t),a=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,kt(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>a&&(t.adler=dt(t.adler,r.pending_buf,r.pending-a,a)),0===n&&(r.status=wt)}else r.status=wt;if(r.status===wt&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&vt(t),r.pending+2<=r.pending_buf_size&&(kt(r,255&t.adler),kt(r,t.adler>>8&255),t.adler=0,r.status=pt)):r.status=pt),0!==r.pending){if(vt(t),0===t.avail_out)return r.last_flush=-1,0}else if(0===t.avail_in&&bt(e)<=bt(i)&&4!==e)return yt(t,-5);if(r.status===mt&&0!==t.avail_in)return yt(t,-5);if(0!==t.avail_in||0!==r.lookahead||0!==e&&r.status!==mt){var o=2===r.strategy?function(t,e){for(var i;;){if(0===t.lookahead&&(At(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,i=st._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}(r,e):3===r.strategy?function(t,e){for(var i,r,a,n,s=t.window;;){if(t.lookahead<=ut){if(At(t),t.lookahead<=ut&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=s[a=t.strstart-1])===s[++a]&&r===s[++a]&&r===s[++a]){n=t.strstart+ut;do{}while(r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&a<n);t.match_length=ut-(n-a),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=st._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=st._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}(r,e):ft[r.level].func(r,e);if(3!==o&&4!==o||(r.status=mt),1===o||3===o)return 0===t.avail_out&&(r.last_flush=-1),0;if(2===o&&(1===e?st._tr_align(r):5!==e&&(st._tr_stored_block(r,0,0,!1),3===e&&(_t(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),vt(t),0===t.avail_out))return r.last_flush=-1,0}return 4!==e?0:r.wrap<=0?1:(2===r.wrap?(kt(r,255&t.adler),kt(r,t.adler>>8&255),kt(r,t.adler>>16&255),kt(r,t.adler>>24&255),kt(r,255&t.total_in),kt(r,t.total_in>>8&255),kt(r,t.total_in>>16&255),kt(r,t.total_in>>24&255)):(Et(r,t.adler>>>16),Et(r,65535&t.adler)),vt(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?0:1)},deflateEnd:zt,deflateSetDictionary:function(t,e){var i,r,a,n,s,o,c,f,d=e.length;if(!t||!t.state)return lt;if(2===(n=(i=t.state).wrap)||1===n&&42!==i.status||i.lookahead)return lt;for(1===n&&(t.adler=ot(t.adler,e,d,0)),i.wrap=0,d>=i.w_size&&(0===n&&(_t(i.head),i.strstart=0,i.block_start=0,i.insert=0),f=new x.Buf8(i.w_size),x.arraySet(f,e,d-i.w_size,i.w_size,0),e=f,d=i.w_size),s=t.avail_in,o=t.next_in,c=t.input,t.avail_in=d,t.next_in=0,t.input=e,At(i);i.lookahead>=3;){r=i.strstart,a=i.lookahead-2;do{i.ins_h=(i.ins_h<<i.hash_shift^i.window[r+3-1])&i.hash_mask,i.prev[r&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=r,r++}while(--a);i.strstart=r,i.lookahead=2,At(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=o,t.input=c,t.avail_in=s,i.wrap=n,0},deflateInfo:"pako deflate (from Nodeca project)"},Tt=!0,Ut=!0;try{String.fromCharCode.apply(null,[0])}catch(t){Tt=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Ut=!1}for(var Nt=new x.Buf8(256),Mt=0;Mt<256;Mt++)Nt[Mt]=Mt>=252?6:Mt>=248?5:Mt>=240?4:Mt>=224?3:Mt>=192?2:1;Nt[254]=Nt[254]=1;function Ft(t,e){if(e<65534&&(t.subarray&&Ut||!t.subarray&&Tt))return String.fromCharCode.apply(null,x.shrinkBuf(t,e));for(var i="",r=0;r<e;r++)i+=String.fromCharCode(t[r]);return i}var Ht=function(t){var e,i,r,a,n,s=t.length,o=0;for(a=0;a<s;a++)55296==(64512&(i=t.charCodeAt(a)))&&a+1<s&&56320==(64512&(r=t.charCodeAt(a+1)))&&(i=65536+(i-55296<<10)+(r-56320),a++),o+=i<128?1:i<2048?2:i<65536?3:4;for(e=new x.Buf8(o),n=0,a=0;n<o;a++)55296==(64512&(i=t.charCodeAt(a)))&&a+1<s&&56320==(64512&(r=t.charCodeAt(a+1)))&&(i=65536+(i-55296<<10)+(r-56320),a++),i<128?e[n++]=i:i<2048?(e[n++]=192|i>>>6,e[n++]=128|63&i):i<65536?(e[n++]=224|i>>>12,e[n++]=128|i>>>6&63,e[n++]=128|63&i):(e[n++]=240|i>>>18,e[n++]=128|i>>>12&63,e[n++]=128|i>>>6&63,e[n++]=128|63&i);return e},qt=function(t){return Ft(t,t.length)},Lt=function(t){for(var e=new x.Buf8(t.length),i=0,r=e.length;i<r;i++)e[i]=t.charCodeAt(i);return e},Wt=function(t,e){var i,r,a,n,s=e||t.length,o=new Array(2*s);for(r=0,i=0;i<s;)if((a=t[i++])<128)o[r++]=a;else if((n=Nt[a])>4)o[r++]=65533,i+=n-1;else{for(a&=2===n?31:3===n?15:7;n>1&&i<s;)a=a<<6|63&t[i++],n--;n>1?o[r++]=65533:a<65536?o[r++]=a:(a-=65536,o[r++]=55296|a>>10&1023,o[r++]=56320|1023&a)}return Ft(o,r)},Gt=function(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Nt[t[i]]>e?i:e};var Zt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Kt=Object.prototype.toString;function Vt(t){if(!(this instanceof Vt))return new Vt(t);this.options=x.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zt,this.strm.avail_out=0;var i=Dt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(0!==i)throw new Error(ht[i]);if(e.header&&Dt.deflateSetHeader(this.strm,e.header),e.dictionary){var r;if(r="string"==typeof e.dictionary?Ht(e.dictionary):"[object ArrayBuffer]"===Kt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,0!==(i=Dt.deflateSetDictionary(this.strm,r)))throw new Error(ht[i]);this._dict_set=!0}}function Xt(t,e){var i=new Vt(e);if(i.push(t,!0),i.err)throw i.msg||ht[i.err];return i.result}Vt.prototype.push=function(t,e){var i,r,a=this.strm,n=this.options.chunkSize;if(this.ended)return!1;r=e===~~e?e:!0===e?4:0,"string"==typeof t?a.input=Ht(t):"[object ArrayBuffer]"===Kt.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new x.Buf8(n),a.next_out=0,a.avail_out=n),1!==(i=Dt.deflate(a,r))&&0!==i)return this.onEnd(i),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==r&&2!==r)||("string"===this.options.to?this.onData(qt(x.shrinkBuf(a.output,a.next_out))):this.onData(x.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==i);return 4===r?(i=Dt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,0===i):2!==r||(this.onEnd(0),a.avail_out=0,!0)},Vt.prototype.onData=function(t){this.chunks.push(t)},Vt.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=x.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Yt={Deflate:Vt,deflate:Xt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Xt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Xt(t,e)}},Jt=function(t,e){var i,r,a,n,s,o,c,f,d,h,l,u,g,w,p,m,y,b,_,v,x,k,E,$,S;i=t.state,r=t.next_in,$=t.input,a=r+(t.avail_in-5),n=t.next_out,S=t.output,s=n-(e-t.avail_out),o=n+(t.avail_out-257),c=i.dmax,f=i.wsize,d=i.whave,h=i.wnext,l=i.window,u=i.hold,g=i.bits,w=i.lencode,p=i.distcode,m=(1<<i.lenbits)-1,y=(1<<i.distbits)-1;t:do{g<15&&(u+=$[r++]<<g,g+=8,u+=$[r++]<<g,g+=8),b=w[u&m];e:for(;;){if(u>>>=_=b>>>24,g-=_,0===(_=b>>>16&255))S[n++]=65535&b;else{if(!(16&_)){if(64&_){if(32&_){i.mode=12;break t}t.msg="invalid literal/length code",i.mode=30;break t}b=w[(65535&b)+(u&(1<<_)-1)];continue e}for(v=65535&b,(_&=15)&&(g<_&&(u+=$[r++]<<g,g+=8),v+=u&(1<<_)-1,u>>>=_,g-=_),g<15&&(u+=$[r++]<<g,g+=8,u+=$[r++]<<g,g+=8),b=p[u&y];;){if(u>>>=_=b>>>24,g-=_,16&(_=b>>>16&255)){if(x=65535&b,g<(_&=15)&&(u+=$[r++]<<g,(g+=8)<_&&(u+=$[r++]<<g,g+=8)),(x+=u&(1<<_)-1)>c){t.msg="invalid distance too far back",i.mode=30;break t}if(u>>>=_,g-=_,x>(_=n-s)){if((_=x-_)>d&&i.sane){t.msg="invalid distance too far back",i.mode=30;break t}if(k=0,E=l,0===h){if(k+=f-_,_<v){v-=_;do{S[n++]=l[k++]}while(--_);k=n-x,E=S}}else if(h<_){if(k+=f+h-_,(_-=h)<v){v-=_;do{S[n++]=l[k++]}while(--_);if(k=0,h<v){v-=_=h;do{S[n++]=l[k++]}while(--_);k=n-x,E=S}}}else if(k+=h-_,_<v){v-=_;do{S[n++]=l[k++]}while(--_);k=n-x,E=S}for(;v>2;)S[n++]=E[k++],S[n++]=E[k++],S[n++]=E[k++],v-=3;v&&(S[n++]=E[k++],v>1&&(S[n++]=E[k++]))}else{k=n-x;do{S[n++]=S[k++],S[n++]=S[k++],S[n++]=S[k++],v-=3}while(v>2);v&&(S[n++]=S[k++],v>1&&(S[n++]=S[k++]))}break}if(64&_){t.msg="invalid distance code",i.mode=30;break t}b=p[(65535&b)+(u&(1<<_)-1)]}}break}}while(r<a&&n<o);r-=v=g>>3,u&=(1<<(g-=v<<3))-1,t.next_in=r,t.next_out=n,t.avail_in=r<a?a-r+5:5-(r-a),t.avail_out=n<o?o-n+257:257-(n-o),i.hold=u,i.bits=g},Qt=15,te=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],ee=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],ie=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],re=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],ae=function(t,e,i,r,a,n,s,o){var c,f,d,h,l,u,g,w,p,m=o.bits,y=0,b=0,_=0,v=0,k=0,E=0,$=0,S=0,A=0,B=0,R=null,P=0,j=new x.Buf16(16),O=new x.Buf16(16),I=null,C=0;for(y=0;y<=Qt;y++)j[y]=0;for(b=0;b<r;b++)j[e[i+b]]++;for(k=m,v=Qt;v>=1&&0===j[v];v--);if(k>v&&(k=v),0===v)return a[n++]=20971520,a[n++]=20971520,o.bits=1,0;for(_=1;_<v&&0===j[_];_++);for(k<_&&(k=_),S=1,y=1;y<=Qt;y++)if(S<<=1,(S-=j[y])<0)return-1;if(S>0&&(0===t||1!==v))return-1;for(O[1]=0,y=1;y<Qt;y++)O[y+1]=O[y]+j[y];for(b=0;b<r;b++)0!==e[i+b]&&(s[O[e[i+b]]++]=b);if(0===t?(R=I=s,u=19):1===t?(R=te,P-=257,I=ee,C-=257,u=256):(R=ie,I=re,u=-1),B=0,b=0,y=_,l=n,E=k,$=0,d=-1,h=(A=1<<k)-1,1===t&&A>852||2===t&&A>592)return 1;for(;;){g=y-$,s[b]<u?(w=0,p=s[b]):s[b]>u?(w=I[C+s[b]],p=R[P+s[b]]):(w=96,p=0),c=1<<y-$,_=f=1<<E;do{a[l+(B>>$)+(f-=c)]=g<<24|w<<16|p}while(0!==f);for(c=1<<y-1;B&c;)c>>=1;if(0!==c?(B&=c-1,B+=c):B=0,b++,0===--j[y]){if(y===v)break;y=e[i+s[b]]}if(y>k&&(B&h)!==d){for(0===$&&($=k),l+=_,S=1<<(E=y-$);E+$<v&&!((S-=j[E+$])<=0);)E++,S<<=1;if(A+=1<<E,1===t&&A>852||2===t&&A>592)return 1;a[d=B&h]=k<<24|E<<16|l-n}}return 0!==B&&(a[l+B]=y-$<<24|64<<16),o.bits=k,0},ne=-2,se=12,oe=30;function ce(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function fe(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new x.Buf16(320),this.work=new x.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function de(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new x.Buf32(852),e.distcode=e.distdyn=new x.Buf32(592),e.sane=1,e.back=-1,0):ne}function he(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,de(t)):ne}function le(t,e){var i,r;return t&&t.state?(r=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?ne:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=i,r.wbits=e,he(t))):ne}function ue(t,e){var i,r;return t?(r=new fe,t.state=r,r.window=null,0!==(i=le(t,e))&&(t.state=null),i):ne}var ge,we,pe=!0;function me(t){if(pe){var e;for(ge=new x.Buf32(512),we=new x.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ae(1,t.lens,0,288,ge,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ae(2,t.lens,0,32,we,0,t.work,{bits:5}),pe=!1}t.lencode=ge,t.lenbits=9,t.distcode=we,t.distbits=5}function ye(t,e,i,r){var a,n=t.state;return null===n.window&&(n.wsize=1<<n.wbits,n.wnext=0,n.whave=0,n.window=new x.Buf8(n.wsize)),r>=n.wsize?(x.arraySet(n.window,e,i-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((a=n.wsize-n.wnext)>r&&(a=r),x.arraySet(n.window,e,i-r,a,n.wnext),(r-=a)?(x.arraySet(n.window,e,i-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=a,n.wnext===n.wsize&&(n.wnext=0),n.whave<n.wsize&&(n.whave+=a))),0}var be={inflateReset:he,inflateReset2:le,inflateResetKeep:de,inflateInit:function(t){return ue(t,15)},inflateInit2:ue,inflate:function(t,e){var i,r,a,n,s,o,c,f,d,h,l,u,g,w,p,m,y,b,_,v,k,E,$,S,A=0,B=new x.Buf8(4),R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return ne;(i=t.state).mode===se&&(i.mode=13),s=t.next_out,a=t.output,c=t.avail_out,n=t.next_in,r=t.input,o=t.avail_in,f=i.hold,d=i.bits,h=o,l=c,E=0;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}if(2&i.wrap&&35615===f){i.check=0,B[0]=255&f,B[1]=f>>>8&255,i.check=dt(i.check,B,2,0),f=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&f)<<8)+(f>>8))%31){t.msg="incorrect header check",i.mode=oe;break}if(8!=(15&f)){t.msg="unknown compression method",i.mode=oe;break}if(d-=4,k=8+(15&(f>>>=4)),0===i.wbits)i.wbits=k;else if(k>i.wbits){t.msg="invalid window size",i.mode=oe;break}i.dmax=1<<k,t.adler=i.check=1,i.mode=512&f?10:se,f=0,d=0;break;case 2:for(;d<16;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}if(i.flags=f,8!=(255&i.flags)){t.msg="unknown compression method",i.mode=oe;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=oe;break}i.head&&(i.head.text=f>>8&1),512&i.flags&&(B[0]=255&f,B[1]=f>>>8&255,i.check=dt(i.check,B,2,0)),f=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}i.head&&(i.head.time=f),512&i.flags&&(B[0]=255&f,B[1]=f>>>8&255,B[2]=f>>>16&255,B[3]=f>>>24&255,i.check=dt(i.check,B,4,0)),f=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}i.head&&(i.head.xflags=255&f,i.head.os=f>>8),512&i.flags&&(B[0]=255&f,B[1]=f>>>8&255,i.check=dt(i.check,B,2,0)),f=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}i.length=f,i.head&&(i.head.extra_len=f),512&i.flags&&(B[0]=255&f,B[1]=f>>>8&255,i.check=dt(i.check,B,2,0)),f=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((u=i.length)>o&&(u=o),u&&(i.head&&(k=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),x.arraySet(i.head.extra,r,n,u,k)),512&i.flags&&(i.check=dt(i.check,r,u,n)),o-=u,n+=u,i.length-=u),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===o)break t;u=0;do{k=r[n+u++],i.head&&k&&i.length<65536&&(i.head.name+=String.fromCharCode(k))}while(k&&u<o);if(512&i.flags&&(i.check=dt(i.check,r,u,n)),o-=u,n+=u,k)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===o)break t;u=0;do{k=r[n+u++],i.head&&k&&i.length<65536&&(i.head.comment+=String.fromCharCode(k))}while(k&&u<o);if(512&i.flags&&(i.check=dt(i.check,r,u,n)),o-=u,n+=u,k)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;d<16;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}if(f!==(65535&i.check)){t.msg="header crc mismatch",i.mode=oe;break}f=0,d=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=se;break;case 10:for(;d<32;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}t.adler=i.check=ce(f),f=0,d=0,i.mode=11;case 11:if(0===i.havedict)return t.next_out=s,t.avail_out=c,t.next_in=n,t.avail_in=o,i.hold=f,i.bits=d,2;t.adler=i.check=1,i.mode=se;case se:if(5===e||6===e)break t;case 13:if(i.last){f>>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}switch(i.last=1&f,d-=1,3&(f>>>=1)){case 0:i.mode=14;break;case 1:if(me(i),i.mode=20,6===e){f>>>=2,d-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=oe}f>>>=2,d-=2;break;case 14:for(f>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}if((65535&f)!=(f>>>16^65535)){t.msg="invalid stored block lengths",i.mode=oe;break}if(i.length=65535&f,f=0,d=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(u=i.length){if(u>o&&(u=o),u>c&&(u=c),0===u)break t;x.arraySet(a,r,n,u,s),o-=u,n+=u,c-=u,s+=u,i.length-=u;break}i.mode=se;break;case 17:for(;d<14;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}if(i.nlen=257+(31&f),f>>>=5,d-=5,i.ndist=1+(31&f),f>>>=5,d-=5,i.ncode=4+(15&f),f>>>=4,d-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=oe;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;d<3;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}i.lens[R[i.have++]]=7&f,f>>>=3,d-=3}for(;i.have<19;)i.lens[R[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,$={bits:i.lenbits},E=ae(0,i.lens,0,19,i.lencode,0,i.work,$),i.lenbits=$.bits,E){t.msg="invalid code lengths set",i.mode=oe;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;m=(A=i.lencode[f&(1<<i.lenbits)-1])>>>16&255,y=65535&A,!((p=A>>>24)<=d);){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}if(y<16)f>>>=p,d-=p,i.lens[i.have++]=y;else{if(16===y){for(S=p+2;d<S;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}if(f>>>=p,d-=p,0===i.have){t.msg="invalid bit length repeat",i.mode=oe;break}k=i.lens[i.have-1],u=3+(3&f),f>>>=2,d-=2}else if(17===y){for(S=p+3;d<S;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}d-=p,k=0,u=3+(7&(f>>>=p)),f>>>=3,d-=3}else{for(S=p+7;d<S;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}d-=p,k=0,u=11+(127&(f>>>=p)),f>>>=7,d-=7}if(i.have+u>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=oe;break}for(;u--;)i.lens[i.have++]=k}}if(i.mode===oe)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=oe;break}if(i.lenbits=9,$={bits:i.lenbits},E=ae(1,i.lens,0,i.nlen,i.lencode,0,i.work,$),i.lenbits=$.bits,E){t.msg="invalid literal/lengths set",i.mode=oe;break}if(i.distbits=6,i.distcode=i.distdyn,$={bits:i.distbits},E=ae(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,$),i.distbits=$.bits,E){t.msg="invalid distances set",i.mode=oe;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(o>=6&&c>=258){t.next_out=s,t.avail_out=c,t.next_in=n,t.avail_in=o,i.hold=f,i.bits=d,Jt(t,l),s=t.next_out,a=t.output,c=t.avail_out,n=t.next_in,r=t.input,o=t.avail_in,f=i.hold,d=i.bits,i.mode===se&&(i.back=-1);break}for(i.back=0;m=(A=i.lencode[f&(1<<i.lenbits)-1])>>>16&255,y=65535&A,!((p=A>>>24)<=d);){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}if(m&&!(240&m)){for(b=p,_=m,v=y;m=(A=i.lencode[v+((f&(1<<b+_)-1)>>b)])>>>16&255,y=65535&A,!(b+(p=A>>>24)<=d);){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}f>>>=b,d-=b,i.back+=b}if(f>>>=p,d-=p,i.back+=p,i.length=y,0===m){i.mode=26;break}if(32&m){i.back=-1,i.mode=se;break}if(64&m){t.msg="invalid literal/length code",i.mode=oe;break}i.extra=15&m,i.mode=22;case 22:if(i.extra){for(S=i.extra;d<S;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}i.length+=f&(1<<i.extra)-1,f>>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;m=(A=i.distcode[f&(1<<i.distbits)-1])>>>16&255,y=65535&A,!((p=A>>>24)<=d);){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}if(!(240&m)){for(b=p,_=m,v=y;m=(A=i.distcode[v+((f&(1<<b+_)-1)>>b)])>>>16&255,y=65535&A,!(b+(p=A>>>24)<=d);){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}f>>>=b,d-=b,i.back+=b}if(f>>>=p,d-=p,i.back+=p,64&m){t.msg="invalid distance code",i.mode=oe;break}i.offset=y,i.extra=15&m,i.mode=24;case 24:if(i.extra){for(S=i.extra;d<S;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}i.offset+=f&(1<<i.extra)-1,f>>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=oe;break}i.mode=25;case 25:if(0===c)break t;if(u=l-c,i.offset>u){if((u=i.offset-u)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=oe;break}u>i.wnext?(u-=i.wnext,g=i.wsize-u):g=i.wnext-u,u>i.length&&(u=i.length),w=i.window}else w=a,g=s-i.offset,u=i.length;u>c&&(u=c),c-=u,i.length-=u;do{a[s++]=w[g++]}while(--u);0===i.length&&(i.mode=21);break;case 26:if(0===c)break t;a[s++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===o)break t;o--,f|=r[n++]<<d,d+=8}if(l-=c,t.total_out+=l,i.total+=l,l&&(t.adler=i.check=i.flags?dt(i.check,a,l,s-l):ot(i.check,a,l,s-l)),l=c,(i.flags?f:ce(f))!==i.check){t.msg="incorrect data check",i.mode=oe;break}f=0,d=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;d<32;){if(0===o)break t;o--,f+=r[n++]<<d,d+=8}if(f!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=oe;break}f=0,d=0}i.mode=29;case 29:E=1;break t;case oe:E=-3;break t;case 31:return-4;default:return ne}return t.next_out=s,t.avail_out=c,t.next_in=n,t.avail_in=o,i.hold=f,i.bits=d,(i.wsize||l!==t.avail_out&&i.mode<oe&&(i.mode<27||4!==e))&&ye(t,t.output,t.next_out,l-t.avail_out),h-=t.avail_in,l-=t.avail_out,t.total_in+=h,t.total_out+=l,i.total+=l,i.wrap&&l&&(t.adler=i.check=i.flags?dt(i.check,a,l,t.next_out-l):ot(i.check,a,l,t.next_out-l)),t.data_type=i.bits+(i.last?64:0)+(i.mode===se?128:0)+(20===i.mode||15===i.mode?256:0),(0===h&&0===l||4===e)&&0===E&&(E=-5),E},inflateEnd:function(t){if(!t||!t.state)return ne;var e=t.state;return e.window&&(e.window=null),t.state=null,0},inflateGetHeader:function(t,e){var i;return t&&t.state&&2&(i=t.state).wrap?(i.head=e,e.done=!1,0):ne},inflateSetDictionary:function(t,e){var i,r=e.length;return t&&t.state?0!==(i=t.state).wrap&&11!==i.mode?ne:11===i.mode&&ot(1,e,r,0)!==i.check?-3:ye(t,e,r,r)?(i.mode=31,-4):(i.havedict=1,0):ne},inflateInfo:"pako inflate (from Nodeca project)"},_e={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};var ve=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},xe=Object.prototype.toString;function ke(t){if(!(this instanceof ke))return new ke(t);this.options=x.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zt,this.strm.avail_out=0;var i=be.inflateInit2(this.strm,e.windowBits);if(i!==_e.Z_OK)throw new Error(ht[i]);if(this.header=new ve,be.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Ht(e.dictionary):"[object ArrayBuffer]"===xe.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=be.inflateSetDictionary(this.strm,e.dictionary))!==_e.Z_OK))throw new Error(ht[i])}function Ee(t,e){var i=new ke(e);if(i.push(t,!0),i.err)throw i.msg||ht[i.err];return i.result}ke.prototype.push=function(t,e){var i,r,a,n,s,o=this.strm,c=this.options.chunkSize,f=this.options.dictionary,d=!1;if(this.ended)return!1;r=e===~~e?e:!0===e?_e.Z_FINISH:_e.Z_NO_FLUSH,"string"==typeof t?o.input=Lt(t):"[object ArrayBuffer]"===xe.call(t)?o.input=new Uint8Array(t):o.input=t,o.next_in=0,o.avail_in=o.input.length;do{if(0===o.avail_out&&(o.output=new x.Buf8(c),o.next_out=0,o.avail_out=c),(i=be.inflate(o,_e.Z_NO_FLUSH))===_e.Z_NEED_DICT&&f&&(i=be.inflateSetDictionary(this.strm,f)),i===_e.Z_BUF_ERROR&&!0===d&&(i=_e.Z_OK,d=!1),i!==_e.Z_STREAM_END&&i!==_e.Z_OK)return this.onEnd(i),this.ended=!0,!1;o.next_out&&(0!==o.avail_out&&i!==_e.Z_STREAM_END&&(0!==o.avail_in||r!==_e.Z_FINISH&&r!==_e.Z_SYNC_FLUSH)||("string"===this.options.to?(a=Gt(o.output,o.next_out),n=o.next_out-a,s=Wt(o.output,a),o.next_out=n,o.avail_out=c-n,n&&x.arraySet(o.output,o.output,a,n,0),this.onData(s)):this.onData(x.shrinkBuf(o.output,o.next_out)))),0===o.avail_in&&0===o.avail_out&&(d=!0)}while((o.avail_in>0||0===o.avail_out)&&i!==_e.Z_STREAM_END);return i===_e.Z_STREAM_END&&(r=_e.Z_FINISH),r===_e.Z_FINISH?(i=be.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===_e.Z_OK):r!==_e.Z_SYNC_FLUSH||(this.onEnd(_e.Z_OK),o.avail_out=0,!0)},ke.prototype.onData=function(t){this.chunks.push(t)},ke.prototype.onEnd=function(t){t===_e.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=x.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var $e={Inflate:ke,inflate:Ee,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Ee(t,e)},ungzip:Ee},Se={};(0,x.assign)(Se,Yt,$e,_e);var Ae=Se;const Be=(t,e)=>function(...i){return new(0,e.promiseModule)((r,a)=>{e.multiArgs?i.push((...t)=>{e.errorFirst?t[0]?a(t):(t.shift(),r(t)):r(t)}):e.errorFirst?i.push((t,e)=>{t?a(t):r(e)}):i.push(r),t.apply(this,i)})};var Re=(t,e)=>{e=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},e);const i=typeof t;if(null===t||"object"!==i&&"function"!==i)throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${null===t?"null":i}\``);const r=t=>{const i=e=>"string"==typeof e?t===e:e.test(t);return e.include?e.include.some(i):!e.exclude.some(i)};let a;a="function"===i?function(...i){return e.excludeMain?t(...i):Be(t,e).apply(this,i)}:Object.create(Object.getPrototypeOf(t));for(const i in t){const n=t[i];a[i]="function"==typeof n&&r(i)?Be(n,e):n}return a};function Pe(t){return Array.isArray(t)?t:[t]}const je=/^\s+$/,Oe=/^\\!/,Ie=/^\\#/,Ce=/\r?\n/g,ze=/^\.*\/|^\.+$/,De="undefined"!=typeof Symbol?Symbol.for("node-ignore"):"node-ignore",Te=/([0-z])-([0-z])/g,Ue=[[/\\?\s+$/,t=>0===t.indexOf("\\")?" ":""],[/\\\s/g,()=>" "],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,i)=>e+6<i.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)\\\*(?=.+)/g,(t,e)=>`${e}[^\\/]*`],[/\\\\\\(?=[$.|*+(){^])/g,()=>"\\"],[/\\\\/g,()=>"\\"],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,i,r,a)=>"\\"===e?`\\[${i}${(t=>{const{length:e}=t;return t.slice(0,e-e%2)})(r)}${a}`:"]"===a&&r.length%2==0?`[${(t=>t.replace(Te,(t,e,i)=>e.charCodeAt(0)<=i.charCodeAt(0)?t:""))(i)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],Ne=Object.create(null),Me=t=>"string"==typeof t;class Fe{constructor(t,e,i,r){this.origin=t,this.pattern=e,this.negative=i,this.regex=r}}const He=(t,e)=>{const i=t;let r=!1;0===t.indexOf("!")&&(r=!0,t=t.substr(1));const a=((t,e,i)=>{const r=Ne[t];if(r)return r;const a=Ue.reduce((e,i)=>e.replace(i[0],i[1].bind(t)),t);return Ne[t]=i?new RegExp(a,"i"):new RegExp(a)})(t=t.replace(Oe,"!").replace(Ie,"#"),0,e);return new Fe(i,t,r,a)},qe=(t,e)=>{throw new e(t)},Le=(t,e,i)=>{if(!Me(t))return i(`path must be a string, but got \`${e}\``,TypeError);if(!t)return i("path must not be empty",TypeError);if(Le.isNotRelative(t)){return i(`path should be a ${"`path.relative()`d"} string, but got "${e}"`,RangeError)}return!0},We=t=>ze.test(t);Le.isNotRelative=We,Le.convert=t=>t;class Ge{constructor({ignorecase:t=!0}={}){var e,i,r;this._rules=[],this._ignorecase=t,e=this,i=De,r=!0,Object.defineProperty(e,i,{value:r}),this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(t){if(t&&t[De])return this._rules=this._rules.concat(t._rules),void(this._added=!0);if((t=>t&&Me(t)&&!je.test(t)&&0!==t.indexOf("#"))(t)){const e=He(t,this._ignorecase);this._added=!0,this._rules.push(e)}}add(t){return this._added=!1,Pe(Me(t)?(t=>t.split(Ce))(t):t).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(t){return this.add(t)}_testOne(t,e){let i=!1,r=!1;return this._rules.forEach(a=>{const{negative:n}=a;if(r===n&&i!==r||n&&!i&&!r&&!e)return;a.regex.test(t)&&(i=!n,r=n)}),{ignored:i,unignored:r}}_test(t,e,i,r){const a=t&&Le.convert(t);return Le(a,t,qe),this._t(a,e,i,r)}_t(t,e,i,r){if(t in e)return e[t];if(r||(r=t.split("/")),r.pop(),!r.length)return e[t]=this._testOne(t,i);const a=this._t(r.join("/")+"/",e,i,r);return e[t]=a.ignored?a:this._testOne(t,i)}ignores(t){return this._test(t,this._ignoreCache,!1).ignored}createFilter(){return t=>!this.ignores(t)}filter(t){return Pe(t).filter(this.createFilter())}test(t){return this._test(t,this._testCache,!0)}}const Ze=t=>new Ge(t),Ke=()=>!1;Ze.isPathValid=t=>Le(t&&Le.convert(t),t,Ke),Ze.default=Ze;var Ve=Ze;if("undefined"!=typeof process&&(process.env&&process.env.IGNORE_TEST_WIN32||"win32"===process.platform)){const t=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");Le.convert=t;const e=/^[a-z]:\//i;Le.isNotRelative=t=>e.test(t)||We(t)}function Xe(t,e,i){return e=e instanceof RegExp?e:new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),t.replace(e,i)}var Ye={clean:function(t){if("string"!=typeof t)throw new Error("Expected a string, received: "+t);return t=Xe(t,"./","/"),t=Xe(t,"..","."),t=Xe(t," ","-"),t=Xe(t,/^[~^:?*\\\-]/g,""),t=Xe(t,/[~^:?*\\]/g,"-"),t=Xe(t,/[~^:?*\\\-]$/g,""),t=Xe(t,"@{","-"),t=Xe(t,/\.$/g,""),t=Xe(t,/\/$/g,""),t=Xe(t,/\.lock$/g,"")}},Je=function(t,e){var i,r,a=t,n=e,s=a.length,o=n.length,c=!1,f=null,d=s+1,h=[],l=[],u=[],g="",w=function(t,e,i){return{x:t,y:e,k:i}},p=function(t,e){return{elem:t,t:e}},m=function(t,e,i){var r,c,f;for(r=e>i?h[t-1+d]:h[t+1+d],c=(f=Math.max(e,i))-t;c<s&&f<o&&a[c]===n[f];)++c,++f;return h[t+d]=l.length,l[l.length]=new w(c,f,r),f};return s>=o&&(i=a,r=s,a=n,n=i,s=o,o=r,c=!0,d=s+1),{SES_DELETE:-1,SES_COMMON:0,SES_ADD:1,editdistance:function(){return f},getlcs:function(){return g},getses:function(){return u},compose:function(){var t,e,i,r,y,b,_,v;for(t=o-s,e=s+o+3,i={},_=0;_<e;++_)i[_]=-1,h[_]=-1;r=-1;do{for(v=-++r;v<=t-1;++v)i[v+d]=m(v,i[v-1+d]+1,i[v+1+d]);for(v=t+r;v>=t+1;--v)i[v+d]=m(v,i[v-1+d]+1,i[v+1+d]);i[t+d]=m(t,i[t-1+d]+1,i[t+1+d])}while(i[t+d]!==o);for(f=t+2*r,y=h[t+d],b=[];-1!==y;)b[b.length]=new w(l[y].x,l[y].y,null),y=l[y].k;!function(t){var e,i,r;for(e=i=0,r=t.length-1;r>=0;--r)for(;e<t[r].x||i<t[r].y;)t[r].y-t[r].x>i-e?(u[u.length]=new p(n[i],c?-1:1),++i):t[r].y-t[r].x<i-e?(u[u.length]=new p(a[e],c?1:-1),++e):(u[u.length]=new p(a[e],0),g+=a[e],++e,++i)}(b)}}};function Qe(t,e){for(var i=[],r=t.length,a=e.length,n=function(t,e){var i=new Je(t,e);i.compose();for(var r,a,n=i.getses(),s=t.length-1,o=e.length-1,c=n.length-1;c>=0;--c)n[c].t===i.SES_COMMON?(a?(a.chain={file1index:s,file2index:o,chain:null},a=a.chain):a=r={file1index:s,file2index:o,chain:null},s--,o--):n[c].t===i.SES_DELETE?s--:n[c].t===i.SES_ADD&&o--;var f={file1index:-1,file2index:-1,chain:null};return a?(a.chain=f,r):f}(t,e);null!==n;n=n.chain){var s=r-n.file1index-1,o=a-n.file2index-1;r=n.file1index,a=n.file2index,(s||o)&&i.push({file1:[r+1,s],file2:[a+1,o]})}return i.reverse(),i}var ti=function(t,e,i){var r=[],a=[t,e,i],n=function(t,e,i){var r,a=Qe(e,t),n=Qe(e,i),s=[];function o(t,e){s.push([t.file1[0],e,t.file1[1],t.file2[0],t.file2[1]])}for(r=0;r<a.length;r++)o(a[r],0);for(r=0;r<n.length;r++)o(n[r],2);s.sort(function(t,e){return t[0]-e[0]});var c=[],f=0;function d(t){t>f&&(c.push([1,f,t-f]),f=t)}for(var h=0;h<s.length;h++){for(var l=h,u=s[h],g=u[0],w=g+u[2];h<s.length-1;){var p=s[h+1],m=p[0];if(m>w)break;w=Math.max(w,m+p[2]),h++}if(d(g),l==h)u[4]>0&&c.push([u[1],u[3],u[4]]);else{var y={0:[t.length,-1,e.length,-1],2:[i.length,-1,e.length,-1]};for(r=l;r<=h;r++){var b=y[(u=s[r])[1]],_=u[0],v=_+u[2],x=u[3],k=x+u[4];b[0]=Math.min(x,b[0]),b[1]=Math.max(k,b[1]),b[2]=Math.min(_,b[2]),b[3]=Math.max(v,b[3])}var E=y[0][0]+(g-y[0][2]),$=y[0][1]+(w-y[0][3]),S=y[2][0]+(g-y[2][2]),A=y[2][1]+(w-y[2][3]);c.push([-1,E,$-E,g,w-g,S,A-S])}f=w}return d(e.length),c}(t,e,i),s=[];function o(){s.length&&r.push({ok:s}),s=[]}function c(t){for(var e=0;e<t.length;e++)s.push(t[e])}function f(e){if(e[2]!=e[6])return!0;for(var r=e[1],a=e[5],n=0;n<e[2];n++)if(t[n+r]!=i[n+a])return!0;return!1}for(var d=0;d<n.length;d++){var h=n[d],l=h[0];-1==l?f(h)?(o(),r.push({conflict:{a:t.slice(h[1],h[1]+h[2]),aIndex:h[1],o:e.slice(h[3],h[3]+h[4]),oIndex:h[3],b:i.slice(h[5],h[5]+h[6]),bIndex:h[5]}})):c(a[0].slice(h[1],h[1]+h[2])):c(a[l].slice(h[1],h[1]+h[2]))}return o(),r};class ei extends Error{constructor(t){super(t),this.caller=""}toJSON(){return{code:this.code,data:this.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(t){const e=new ei(t.message);return e.code=t.code,e.data=t.data,e.caller=t.caller,e.stack=t.stack,e}get isIsomorphicGitError(){return!0}}class ii extends ei{constructor(t){super(`Modifying the index is not possible because you have unmerged files: ${t.toString}. Fix them up in the work tree, and then use 'git add/rm as appropriate to mark resolution and make a commit.`),this.code=this.name=ii.code,this.data={filepaths:t}}}ii.code="UnmergedPathsError";class ri extends ei{constructor(t){super(`An internal error caused this command to fail.\n\nIf you're not a developer, report the bug to the developers of the application you're using. If this is a bug in isomorphic-git then you should create a proper bug yourselves. The bug should include a minimal reproduction and details about the version and environment.\n\nPlease file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${t}`),this.code=this.name=ri.code,this.data={message:t}}}ri.code="InternalError";class ai extends ei{constructor(t){super(`The filepath "${t}" contains unsafe character sequences`),this.code=this.name=ai.code,this.data={filepath:t}}}ai.code="UnsafeFilepathError";class ni{constructor(t){this.buffer=t,this._start=0}eof(){return this._start>=this.buffer.length}tell(){return this._start}seek(t){this._start=t}slice(t){const e=this.buffer.slice(this._start,this._start+t);return this._start+=t,e}toString(t,e){const i=this.buffer.toString(t,this._start,this._start+e);return this._start+=e,i}write(t,e,i){const r=this.buffer.write(t,this._start,e,i);return this._start+=e,r}copy(t,e,i){const r=t.copy(this.buffer,this._start,e,i);return this._start+=r,r}readUInt8(){const t=this.buffer.readUInt8(this._start);return this._start+=1,t}writeUInt8(t){const e=this.buffer.writeUInt8(t,this._start);return this._start+=1,e}readUInt16BE(){const t=this.buffer.readUInt16BE(this._start);return this._start+=2,t}writeUInt16BE(t){const e=this.buffer.writeUInt16BE(t,this._start);return this._start+=2,e}readUInt32BE(){const t=this.buffer.readUInt32BE(this._start);return this._start+=4,t}writeUInt32BE(t){const e=this.buffer.writeUInt32BE(t,this._start);return this._start+=4,e}}function si(t,e){return-(t<e)||+(t>e)}function oi(t,e){return si(t.path,e.path)}function ci(t){let e=t>0?t>>12:0;4!==e&&8!==e&&10!==e&&14!==e&&(e=8);let i=511&t;return i=73&i?493:420,8!==e&&(i=0),(e<<12)+i}const fi=2**32;function di(t,e,i,r){if(void 0!==t&&void 0!==e)return[t,e];void 0===i&&(i=r.valueOf());const a=Math.floor(i/1e3);return[a,1e6*(i-1e3*a)]}function hi(t){const[e,i]=di(t.ctimeSeconds,t.ctimeNanoseconds,t.ctimeMs,t.ctime),[r,a]=di(t.mtimeSeconds,t.mtimeNanoseconds,t.mtimeMs,t.mtime);return{ctimeSeconds:e%fi,ctimeNanoseconds:i%fi,mtimeSeconds:r%fi,mtimeNanoseconds:a%fi,dev:t.dev%fi,ino:t.ino%fi,mode:ci(t.mode%fi),uid:t.uid%fi,gid:t.gid%fi,size:t.size>-1?t.size%fi:0}}let li=null;async function ui(t){return null===li&&(li=await async function(){try{return"da39a3ee5e6b4b0d3255bfef95601890afd80709"===await gi(new Uint8Array([]))}catch(t){}return!1}()),li?gi(t):function(t){return(new _).update(t).digest("hex")}(t)}async function gi(t){return function(t){let e="";for(const i of new Uint8Array(t))i<16&&(e+="0"),e+=i.toString(16);return e}(await crypto.subtle.digest("SHA-1",t))}function wi(t){return{assumeValid:Boolean(32768&t),extended:Boolean(16384&t),stage:(12288&t)>>12,nameLength:4095&t}}class pi{constructor(t,e){this._dirty=!1,this._unmergedPaths=e||new Set,this._entries=t||new Map}_addEntry(t){if(0===t.flags.stage)t.stages=[t],this._entries.set(t.path,t),this._unmergedPaths.delete(t.path);else{let e=this._entries.get(t.path);e||(this._entries.set(t.path,t),e=t),e.stages[t.flags.stage]=t,this._unmergedPaths.add(t.path)}}static async from(t){if(Buffer.isBuffer(t))return pi.fromBuffer(t);if(null===t)return new pi(null);throw new ri("invalid type passed to GitIndex.from")}static async fromBuffer(t){if(0===t.length)throw new ri("Index file is empty (.git/index)");const e=new pi,i=new ni(t),r=i.toString("utf8",4);if("DIRC"!==r)throw new ri(`Invalid dircache magic file number: ${r}`);const a=await ui(t.slice(0,-20)),n=t.slice(-20).toString("hex");if(n!==a)throw new ri(`Invalid checksum in GitIndex buffer: expected ${n} but saw ${a}`);const s=i.readUInt32BE();if(2!==s)throw new ri(`Unsupported dircache version: ${s}`);const o=i.readUInt32BE();let c=0;for(;!i.eof()&&c<o;){const r={};r.ctimeSeconds=i.readUInt32BE(),r.ctimeNanoseconds=i.readUInt32BE(),r.mtimeSeconds=i.readUInt32BE(),r.mtimeNanoseconds=i.readUInt32BE(),r.dev=i.readUInt32BE(),r.ino=i.readUInt32BE(),r.mode=i.readUInt32BE(),r.uid=i.readUInt32BE(),r.gid=i.readUInt32BE(),r.size=i.readUInt32BE(),r.oid=i.slice(20).toString("hex");const a=i.readUInt16BE();r.flags=wi(a);const n=t.indexOf(0,i.tell()+1)-i.tell();if(n<1)throw new ri(`Got a path length of: ${n}`);if(r.path=i.toString("utf8",n),r.path.includes("..\\")||r.path.includes("../"))throw new ai(r.path);let s=8-(i.tell()-12)%8;for(0===s&&(s=8);s--;){const t=i.readUInt8();if(0!==t)throw new ri(`Expected 1-8 null characters but got '${t}' after ${r.path}`);if(i.eof())throw new ri("Unexpected end of file")}r.stages=[],e._addEntry(r),c++}return e}get unmergedPaths(){return[...this._unmergedPaths]}get entries(){return[...this._entries.values()].sort(oi)}get entriesMap(){return this._entries}get entriesFlat(){return[...this.entries].flatMap(t=>t.stages.length>1?t.stages.filter(t=>t):t)}*[Symbol.iterator](){for(const t of this.entries)yield t}insert({filepath:t,stats:e,oid:i,stage:r=0}){e||(e={ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:0,uid:0,gid:0,size:0}),e=hi(e);const a=Buffer.from(t),n={ctimeSeconds:e.ctimeSeconds,ctimeNanoseconds:e.ctimeNanoseconds,mtimeSeconds:e.mtimeSeconds,mtimeNanoseconds:e.mtimeNanoseconds,dev:e.dev,ino:e.ino,mode:e.mode||33188,uid:e.uid,gid:e.gid,size:e.size,path:t,oid:i,flags:{assumeValid:!1,extended:!1,stage:r,nameLength:a.length<4095?a.length:4095},stages:[]};this._addEntry(n),this._dirty=!0}delete({filepath:t}){if(this._entries.has(t))this._entries.delete(t);else for(const e of this._entries.keys())e.startsWith(t+"/")&&this._entries.delete(e);this._unmergedPaths.has(t)&&this._unmergedPaths.delete(t),this._dirty=!0}clear(){this._entries.clear(),this._dirty=!0}has({filepath:t}){return this._entries.has(t)}render(){return this.entries.map(t=>`${t.mode.toString(8)} ${t.oid} ${t.path}`).join("\n")}static async _entryToBuffer(t){const e=Buffer.from(t.path),i=8*Math.ceil((62+e.length+1)/8),r=Buffer.alloc(i),a=new ni(r),n=hi(t);return a.writeUInt32BE(n.ctimeSeconds),a.writeUInt32BE(n.ctimeNanoseconds),a.writeUInt32BE(n.mtimeSeconds),a.writeUInt32BE(n.mtimeNanoseconds),a.writeUInt32BE(n.dev),a.writeUInt32BE(n.ino),a.writeUInt32BE(n.mode),a.writeUInt32BE(n.uid),a.writeUInt32BE(n.gid),a.writeUInt32BE(n.size),a.write(t.oid,20,"hex"),a.writeUInt16BE(function(t){const e=t.flags;return e.extended=!1,e.nameLength=Math.min(Buffer.from(t.path).length,4095),(e.assumeValid?32768:0)+(e.extended?16384:0)+((3&e.stage)<<12)+(4095&e.nameLength)}(t)),a.write(t.path,e.length,"utf8"),r}async toObject(){const t=Buffer.alloc(12),e=new ni(t);e.write("DIRC",4,"utf8"),e.writeUInt32BE(2),e.writeUInt32BE(this.entriesFlat.length);let i=[];for(const t of this.entries)if(i.push(pi._entryToBuffer(t)),t.stages.length>1)for(const e of t.stages)e&&e!==t&&i.push(pi._entryToBuffer(e));i=await Promise.all(i);const r=Buffer.concat(i),a=Buffer.concat([t,r]),n=await ui(a);return Buffer.concat([a,Buffer.from(n,"hex")])}}function mi(t,e,i=!0,r=!0){const a=hi(t),n=hi(e);return i&&a.mode!==n.mode||a.mtimeSeconds!==n.mtimeSeconds||a.ctimeSeconds!==n.ctimeSeconds||a.uid!==n.uid||a.gid!==n.gid||r&&a.ino!==n.ino||a.size!==n.size}let yi=null;const bi=Symbol("IndexCache");class _i{static async acquire({fs:t,gitdir:e,cache:i,allowUnmerged:r=!0},a){i[bi]||(i[bi]={map:new Map,stats:new Map});const n=`${e}/index`;let o;null===yi&&(yi=new s({maxPending:1/0}));let c=[];return await yi.acquire(n,async()=>{const e=i[bi];await async function(t,e,i){const r=i.stats.get(e);if(void 0===r)return!0;if(null===r)return!1;const a=await t.lstat(e);return null!==a&&mi(r,a)}(t,n,e)&&await async function(t,e,i){const[r,a]=await Promise.all([t.lstat(e),t.read(e)]),n=await pi.from(a);i.map.set(e,n),i.stats.set(e,r)}(t,n,e);const s=e.map.get(n);if(c=s.unmergedPaths,c.length&&!r)throw new ii(c);if(o=await a(s),s._dirty){const i=await s.toObject();await t.write(n,i),e.stats.set(n,await t.lstat(n)),s._dirty=!1}}),o}}function vi(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>-1&&(t=t.slice(e+1)),t}function xi(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return-1===e?".":0===e?"/":t.slice(0,e)}function ki(t){const e=new Map,i=function(t){if(!e.has(t)){const r={type:"tree",fullpath:t,basename:vi(t),metadata:{},children:[]};e.set(t,r),r.parent=i(xi(t)),r.parent&&r.parent!==r&&r.parent.children.push(r)}return e.get(t)},r=function(t,r){if(!e.has(t)){const a={type:"blob",fullpath:t,basename:vi(t),metadata:r,parent:i(xi(t)),children:[]};a.parent&&a.parent.children.push(a),e.set(t,a)}return e.get(t)};i(".");for(const e of t)r(e.path,e);return e}class Ei{constructor({fs:t,gitdir:e,cache:i}){this.treePromise=_i.acquire({fs:t,gitdir:e,cache:i},async function(t){return ki(t.entries)});const r=this;this.ConstructEntry=class{constructor(t){this._fullpath=t,this._type=!1,this._mode=!1,this._stat=!1,this._oid=!1}async type(){return r.type(this)}async mode(){return r.mode(this)}async stat(){return r.stat(this)}async content(){return r.content(this)}async oid(){return r.oid(this)}}}async readdir(t){const e=t._fullpath,i=(await this.treePromise).get(e);if(!i)return null;if("blob"===i.type)return null;if("tree"!==i.type)throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);const r=i.children.map(t=>t.fullpath);return r.sort(si),r}async type(t){return!1===t._type&&await t.stat(),t._type}async mode(t){return!1===t._mode&&await t.stat(),t._mode}async stat(t){if(!1===t._stat){const e=(await this.treePromise).get(t._fullpath);if(!e)throw new Error(`ENOENT: no such file or directory, lstat '${t._fullpath}'`);const i="tree"===e.type?{}:hi(e.metadata);t._type="tree"===e.type?"tree":function(t){switch(t){case 16384:return"tree";case 33188:case 33261:case 40960:return"blob";case 57344:return"commit"}throw new ri(`Unexpected GitTree entry mode: ${t.toString(8)}`)}(i.mode),t._mode=i.mode,"tree"===e.type?t._stat=void 0:t._stat=i}return t._stat}async content(t){}async oid(t){if(!1===t._oid){const e=(await this.treePromise).get(t._fullpath);t._oid=e.metadata.oid}return t._oid}}const $i=Symbol("GitWalkSymbol");function Si(){const t=Object.create(null);return Object.defineProperty(t,$i,{value:function({fs:t,gitdir:e,cache:i}){return new Ei({fs:t,gitdir:e,cache:i})}}),Object.freeze(t),t}class Ai extends ei{constructor(t){super(`Could not find ${t}.`),this.code=this.name=Ai.code,this.data={what:t}}}Ai.code="NotFoundError";class Bi extends ei{constructor(t,e,i,r){super(`Object ${t} ${r?`at ${r}`:""}was anticipated to be a ${i} but it is a ${e}.`),this.code=this.name=Bi.code,this.data={oid:t,actual:e,expected:i,filepath:r}}}Bi.code="ObjectTypeError";class Ri extends ei{constructor(t){super(`Expected a 40-char hex object id but saw "${t}".`),this.code=this.name=Ri.code,this.data={value:t}}}Ri.code="InvalidOidError";class Pi extends ei{constructor(t){super(`Could not find a fetch refspec for remote "${t}". Make sure the config file has an entry like the following:\n[remote "${t}"]\n\tfetch = +refs/heads/*:refs/remotes/origin/*\n`),this.code=this.name=Pi.code,this.data={remote:t}}}Pi.code="NoRefspecError";class ji{constructor(t){if(this.refs=new Map,this.parsedConfig=[],t){let e=null;this.parsedConfig=t.trim().split("\n").map(t=>{if(/^\s*#/.test(t))return{line:t,comment:!0};const i=t.indexOf(" ");if(t.startsWith("^")){const i=t.slice(1);return this.refs.set(e+"^{}",i),{line:t,ref:e,peeled:i}}{const r=t.slice(0,i);return e=t.slice(i+1),this.refs.set(e,r),{line:t,ref:e,oid:r}}})}return this}static from(t){return new ji(t)}delete(t){this.parsedConfig=this.parsedConfig.filter(e=>e.ref!==t),this.refs.delete(t)}toString(){return this.parsedConfig.map(({line:t})=>t).join("\n")+"\n"}}class Oi{constructor({remotePath:t,localPath:e,force:i,matchPrefix:r}){Object.assign(this,{remotePath:t,localPath:e,force:i,matchPrefix:r})}static from(t){const[e,i,r,a,n]=t.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),s="+"===e,o="*"===r;if(o!==("*"===n))throw new ri("Invalid refspec");return new Oi({remotePath:i,localPath:a,force:s,matchPrefix:o})}translate(t){if(this.matchPrefix){if(t.startsWith(this.remotePath))return this.localPath+t.replace(this.remotePath,"")}else if(t===this.remotePath)return this.localPath;return null}reverseTranslate(t){if(this.matchPrefix){if(t.startsWith(this.localPath))return this.remotePath+t.replace(this.localPath,"")}else if(t===this.localPath)return this.remotePath;return null}}class Ii{constructor(t=[]){this.rules=t}static from(t){const e=[];for(const i of t)e.push(Oi.from(i));return new Ii(e)}add(t){const e=Oi.from(t);this.rules.push(e)}translate(t){const e=[];for(const i of this.rules)for(const r of t){const t=i.translate(r);t&&e.push([r,t])}return e}translateOne(t){let e=null;for(const i of this.rules){const r=i.translate(t);r&&(e=r)}return e}localNamespaces(){return this.rules.filter(t=>t.matchPrefix).map(t=>t.localPath.replace(/\/$/,""))}}function Ci(t,e){const i=t.replace(/\^\{\}$/,""),r=e.replace(/\^\{\}$/,""),a=-(i<r)||+(i>r);return 0===a?t.endsWith("^{}")?1:-1:a}
2
- /*!
3
- * This code for `path.join` is directly copied from @zenfs/core/path for bundle size improvements.
4
- * SPDX-License-Identifier: LGPL-3.0-or-later
5
- * Copyright (c) James Prevett and other ZenFS contributors.
6
- */function zi(...t){if(0===t.length)return".";let e;for(let i=0;i<t.length;++i){const r=t[i];r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":function(t){if(!t.length)return".";const e="/"===t[0],i="/"===t.at(-1);return(t=function(t,e){let i="",r=0,a=-1,n=0,s="\0";for(let o=0;o<=t.length;++o){if(o<t.length)s=t[o];else{if("/"===s)break;s="/"}if("/"===s){if(a===o-1||1===n);else if(2===n){if(i.length<2||2!==r||"."!==i.at(-1)||"."!==i.at(-2)){if(i.length>2){const t=i.lastIndexOf("/");-1===t?(i="",r=0):(i=i.slice(0,t),r=i.length-1-i.lastIndexOf("/")),a=o,n=0;continue}if(0!==i.length){i="",r=0,a=o,n=0;continue}}e&&(i+=i.length>0?"/..":"..",r=2)}else i.length>0?i+="/"+t.slice(a+1,o):i=t.slice(a+1,o),r=o-a-1;a=o,n=0}else"."===s&&-1!==n?++n:n=-1}return i}(t,!e)).length?(i&&(t+="/"),e?`/${t}`:t):e?"/":i?"./":"."}(e)}const Di=t=>{if("boolean"==typeof t)return t;if("true"===(t=t.trim().toLowerCase())||"yes"===t||"on"===t)return!0;if("false"===t||"no"===t||"off"===t)return!1;throw Error(`Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${t}`)},Ti={core:{filemode:Di,bare:Di,logallrefupdates:Di,symlinks:Di,ignorecase:Di,bigFileThreshold:t=>{if("number"==typeof t)return t;t=t.toLowerCase();let e=parseInt(t);return t.endsWith("k")&&(e*=1024),t.endsWith("m")&&(e*=1048576),t.endsWith("g")&&(e*=1073741824),e}}},Ui=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,Ni=/^[A-Za-z0-9-.]+$/,Mi=/^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/,Fi=/^[A-Za-z][A-Za-z-]*$/,Hi=/^(.*?)( *[#;].*)$/,qi=t=>{const e=Hi.exec(t);if(null==e)return t;const[i,r]=e.slice(1);return Li(i)&&Li(r)?`${i}${r}`:i},Li=t=>(t.match(/(?:^|[^\\])"/g)||[]).length%2!=0,Wi=t=>t.split("").reduce((t,e,i,r)=>{const a='"'===e&&"\\"!==r[i-1],n="\\"===e&&'"'===r[i+1];return a||n?t:t+e},""),Gi=t=>null!=t?t.toLowerCase():null,Zi=(t,e,i)=>[Gi(t),e,Gi(i)].filter(t=>null!=t).join("."),Ki=t=>{const e=t.split("."),i=e.shift(),r=e.pop(),a=e.length?e.join("."):void 0;return{section:i,subsection:a,name:r,path:Zi(i,a,r),sectionPath:Zi(i,a,null),isSection:!!i}};class Vi{constructor(t){let e=null,i=null;this.parsedConfig=t?t.split("\n").map(t=>{let r=null,a=null;const n=t.trim(),s=(t=>{const e=Ui.exec(t);if(null!=e){const[t,i]=e.slice(1);return[t,i]}return null})(n),o=null!=s;if(o)[e,i]=s;else{const t=(t=>{const e=Mi.exec(t);if(null!=e){const[t,i="true"]=e.slice(1),r=qi(i);return[t,Wi(r)]}return null})(n);null!=t&&([r,a]=t)}const c=Zi(e,i,r);return{line:t,isSection:o,section:e,subsection:i,name:r,value:a,path:c}}):[]}static from(t){return new Vi(t)}async get(t,e=!1){const i=Ki(t).path,r=this.parsedConfig.filter(t=>t.path===i).map(({section:t,name:e,value:i})=>{const r=Ti[t]&&Ti[t][e];return r?r(i):i});return e?r:r.pop()}async getall(t){return this.get(t,!0)}async getSubsections(t){return this.parsedConfig.filter(e=>e.isSection&&e.section===t).map(t=>t.subsection)}async deleteSection(t,e){this.parsedConfig=this.parsedConfig.filter(i=>!(i.section===t&&i.subsection===e))}async append(t,e){return this.set(t,e,!0)}async set(t,e,i=!1){const{section:r,subsection:a,name:n,path:s,sectionPath:o,isSection:c}=Ki(t),f=(d=this.parsedConfig,h=t=>t.path===s,d.reduce((t,e,i)=>h(e)?i:t,-1));var d,h;if(null==e)-1!==f&&this.parsedConfig.splice(f,1);else if(-1!==f){const t=this.parsedConfig[f],r=Object.assign({},t,{name:n,value:e,modified:!0});i?this.parsedConfig.splice(f+1,0,r):this.parsedConfig[f]=r}else{const t=this.parsedConfig.findIndex(t=>t.path===o),i={section:r,subsection:a,name:n,value:e,modified:!0,path:s};if(Ni.test(r)&&Fi.test(n))if(t>=0)this.parsedConfig.splice(t+1,0,i);else{const t={isSection:c,section:r,subsection:a,modified:!0,path:o};this.parsedConfig.push(t,i)}}}toString(){return this.parsedConfig.map(({line:t,section:e,subsection:i,name:r,value:a,modified:n=!1})=>n?null!=r&&null!=a?"string"==typeof a&&/[#;]/.test(a)?`\t${r} = "${a}"`:`\t${r} = ${a}`:null!=i?`[${e} "${i}"]`:`[${e}]`:t).join("\n")}}class Xi{static async get({fs:t,gitdir:e}){const i=await t.read(`${e}/config`,{encoding:"utf8"});return Vi.from(i)}static async save({fs:t,gitdir:e,config:i}){await t.write(`${e}/config`,i.toString(),{encoding:"utf8"})}}const Yi=t=>[`${t}`,`refs/${t}`,`refs/tags/${t}`,`refs/heads/${t}`,`refs/remotes/${t}`,`refs/remotes/${t}/HEAD`],Ji=["config","description","index","shallow","commondir"];let Qi;async function tr(t,e){return void 0===Qi&&(Qi=new s),Qi.acquire(t,e)}class er{static async updateRemoteRefs({fs:t,gitdir:e,remote:i,refs:r,symrefs:a,tags:n,refspecs:s,prune:o=!1,pruneTags:c=!1}){for(const t of r.values())if(!t.match(/[0-9a-f]{40}/))throw new Ri(t);const f=await Xi.get({fs:t,gitdir:e});if(!s){if(0===(s=await f.getall(`remote.${i}.fetch`)).length)throw new Pi(i);s.unshift(`+HEAD:refs/remotes/${i}/HEAD`)}const d=Ii.from(s),h=new Map;if(c){const i=await er.listRefs({fs:t,gitdir:e,filepath:"refs/tags"});await er.deleteRefs({fs:t,gitdir:e,refs:i.map(t=>`refs/tags/${t}`)})}if(n)for(const i of r.keys())if(i.startsWith("refs/tags")&&!i.endsWith("^{}")&&!await er.exists({fs:t,gitdir:e,ref:i})){const t=r.get(i);h.set(i,t)}const l=d.translate([...r.keys()]);for(const[t,e]of l){const i=r.get(t);h.set(e,i)}const u=d.translate([...a.keys()]);for(const[t,e]of u){const i=a.get(t),r=d.translateOne(i);r&&h.set(e,`ref: ${r}`)}const g=[];if(o){for(const i of d.localNamespaces()){const r=(await er.listRefs({fs:t,gitdir:e,filepath:i})).map(t=>`${i}/${t}`);for(const t of r)h.has(t)||g.push(t)}g.length>0&&await er.deleteRefs({fs:t,gitdir:e,refs:g})}for(const[i,r]of h)await tr(i,async()=>t.write(zi(e,i),`${r.trim()}\n`,"utf8"));return{pruned:g}}static async writeRef({fs:t,gitdir:e,ref:i,value:r}){if(!r.match(/[0-9a-f]{40}/))throw new Ri(r);await tr(i,async()=>t.write(zi(e,i),`${r.trim()}\n`,"utf8"))}static async writeSymbolicRef({fs:t,gitdir:e,ref:i,value:r}){await tr(i,async()=>t.write(zi(e,i),`ref: ${r.trim()}\n`,"utf8"))}static async deleteRef({fs:t,gitdir:e,ref:i}){return er.deleteRefs({fs:t,gitdir:e,refs:[i]})}static async deleteRefs({fs:t,gitdir:e,refs:i}){await Promise.all(i.map(i=>t.rm(zi(e,i))));let r=await tr("packed-refs",async()=>t.read(`${e}/packed-refs`,{encoding:"utf8"}));const a=ji.from(r),n=a.refs.size;for(const t of i)a.refs.has(t)&&a.delete(t);a.refs.size<n&&(r=a.toString(),await tr("packed-refs",async()=>t.write(`${e}/packed-refs`,r,{encoding:"utf8"})))}static async resolve({fs:t,gitdir:e,ref:i,depth:r}){if(void 0!==r&&-1===--r)return i;if(i.startsWith("ref: "))return i=i.slice(5),er.resolve({fs:t,gitdir:e,ref:i,depth:r});if(40===i.length&&/[0-9a-f]{40}/.test(i))return i;const a=await er.packedRefs({fs:t,gitdir:e}),n=Yi(i).filter(t=>!Ji.includes(t));for(const i of n){const n=await tr(i,async()=>await t.read(`${e}/${i}`,{encoding:"utf8"})||a.get(i));if(n)return er.resolve({fs:t,gitdir:e,ref:n.trim(),depth:r})}throw new Ai(i)}static async exists({fs:t,gitdir:e,ref:i}){try{return await er.expand({fs:t,gitdir:e,ref:i}),!0}catch(t){return!1}}static async expand({fs:t,gitdir:e,ref:i}){if(40===i.length&&/[0-9a-f]{40}/.test(i))return i;const r=await er.packedRefs({fs:t,gitdir:e}),a=Yi(i);for(const i of a){if(await tr(i,async()=>t.exists(`${e}/${i}`)))return i;if(r.has(i))return i}throw new Ai(i)}static async expandAgainstMap({ref:t,map:e}){const i=Yi(t);for(const t of i)if(await e.has(t))return t;throw new Ai(t)}static resolveAgainstMap({ref:t,fullref:e=t,depth:i,map:r}){if(void 0!==i&&-1===--i)return{fullref:e,oid:t};if(t.startsWith("ref: "))return t=t.slice(5),er.resolveAgainstMap({ref:t,fullref:e,depth:i,map:r});if(40===t.length&&/[0-9a-f]{40}/.test(t))return{fullref:e,oid:t};const a=Yi(t);for(const t of a){const e=r.get(t);if(e)return er.resolveAgainstMap({ref:e.trim(),fullref:t,depth:i,map:r})}throw new Ai(t)}static async packedRefs({fs:t,gitdir:e}){const i=await tr("packed-refs",async()=>t.read(`${e}/packed-refs`,{encoding:"utf8"}));return ji.from(i).refs}static async listRefs({fs:t,gitdir:e,filepath:i}){const r=er.packedRefs({fs:t,gitdir:e});let a=null;try{a=await t.readdirDeep(`${e}/${i}`),a=a.map(t=>t.replace(`${e}/${i}/`,""))}catch(t){a=[]}for(let t of(await r).keys())t.startsWith(i)&&(t=t.replace(i+"/",""),a.includes(t)||a.push(t));return a.sort(Ci),a}static async listBranches({fs:t,gitdir:e,remote:i}){return i?er.listRefs({fs:t,gitdir:e,filepath:`refs/remotes/${i}`}):er.listRefs({fs:t,gitdir:e,filepath:"refs/heads"})}static async listTags({fs:t,gitdir:e}){return(await er.listRefs({fs:t,gitdir:e,filepath:"refs/tags"})).filter(t=>!t.endsWith("^{}"))}}function ir(t,e){return si(rr(t),rr(e))}function rr(t){return"040000"===t.mode?t.path+"/":t.path}function ar(t){switch(t){case"040000":return"tree";case"100644":case"100755":case"120000":return"blob";case"160000":return"commit"}throw new ri(`Unexpected GitTree entry mode: ${t}`)}function nr(t){return!t.oid&&t.sha&&(t.oid=t.sha),t.mode=function(t){if("number"==typeof t&&(t=t.toString(8)),t.match(/^0?4.*/))return"040000";if(t.match(/^1006.*/))return"100644";if(t.match(/^1007.*/))return"100755";if(t.match(/^120.*/))return"120000";if(t.match(/^160.*/))return"160000";throw new ri(`Could not understand file mode: ${t}`)}(t.mode),t.type||(t.type=ar(t.mode)),t}class sr{constructor(t){if(Buffer.isBuffer(t))this._entries=function(t){const e=[];let i=0;for(;i<t.length;){const r=t.indexOf(32,i);if(-1===r)throw new ri(`GitTree: Error parsing buffer at byte location ${i}: Could not find the next space character.`);const a=t.indexOf(0,i);if(-1===a)throw new ri(`GitTree: Error parsing buffer at byte location ${i}: Could not find the next null character.`);let n=t.slice(i,r).toString("utf8");"40000"===n&&(n="040000");const s=ar(n),o=t.slice(r+1,a).toString("utf8");if(o.includes("\\")||o.includes("/"))throw new ai(o);const c=t.slice(a+1,a+21).toString("hex");i=a+21,e.push({mode:n,path:o,oid:c,type:s})}return e}(t);else{if(!Array.isArray(t))throw new ri("invalid type passed to GitTree constructor");this._entries=t.map(nr)}this._entries.sort(oi)}static from(t){return new sr(t)}render(){return this._entries.map(t=>`${t.mode} ${t.type} ${t.oid} ${t.path}`).join("\n")}toObject(){const t=[...this._entries];return t.sort(ir),Buffer.concat(t.map(t=>{const e=Buffer.from(t.mode.replace(/^0/,"")),i=Buffer.from(" "),r=Buffer.from(t.path,"utf8"),a=Buffer.from([0]),n=Buffer.from(t.oid,"hex");return Buffer.concat([e,i,r,a,n])}))}entries(){return this._entries}*[Symbol.iterator](){for(const t of this._entries)yield t}}class or{static wrap({type:t,object:e}){const i=`${t} ${e.length}\0`,r=i.length,a=r+e.length,n=new Uint8Array(a);for(let t=0;t<r;t++)n[t]=i.charCodeAt(t);return n.set(e,r),n}static unwrap(t){const e=t.indexOf(32),i=t.indexOf(0),r=t.slice(0,e).toString("utf8"),a=t.slice(e+1,i).toString("utf8"),n=t.length-(i+1);if(parseInt(a)!==n)throw new ri(`Length mismatch: expected ${a} bytes but got ${n} instead.`);return{type:r,object:Buffer.from(t.slice(i+1))}}}async function cr({fs:t,gitdir:e,oid:i}){const r=`objects/${i.slice(0,2)}/${i.slice(2)}`,a=await t.read(`${e}/${r}`);return a?{object:a,format:"deflated",source:r}:null}function fr(t){let e=0,i=0,r=null;do{r=t.readUInt8(),e|=(127&r)<<i,i+=7}while(128&r);return e}function dr(t,e,i){let r=0,a=0;for(;i--;)1&e&&(r|=t.readUInt8()<<a),e>>=1,a+=8;return r}function hr(t,e){const i=t.readUInt8();if(128&i){const r=dr(t,15&i,4);let a=dr(t,(112&i)>>4,3);return 0===a&&(a=65536),e.slice(r,r+a)}return t.slice(i)}function lr(t){return t[Symbol.asyncIterator]?t[Symbol.asyncIterator]():t[Symbol.iterator]?t[Symbol.iterator]():t.next?t:function(t){let e=[t];return{next:()=>Promise.resolve({done:0===e.length,value:e.pop()}),return:()=>(e=[],{}),[Symbol.asyncIterator](){return this}}}(t)}class ur{constructor(t){if("undefined"==typeof Buffer)throw new Error("Missing Buffer dependency");this.stream=lr(t),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),this.cursor!==this.buffer.length||(await this._loadnext(),!this._ended)))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),this.cursor!==this.buffer.length||(await this._loadnext(),!this._ended)))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(t){if(!this.eof())return this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t),this.buffer.slice(this.undoCursor,this.cursor)}async skip(t){this.eof()||(this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:t,value:e}=await this.stream.next();return t&&(this._ended=!0,!e)?Buffer.alloc(0):(e&&(e=Buffer.from(e)),e)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(t){this.undoCursor=this.cursor,this.cursor+=t,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(t){if(this._ended)return;const e=[this.buffer];for(;this.cursor+t>gr(e);){const t=await this._next();if(this._ended)break;e.push(t)}this.buffer=Buffer.concat(e)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}}function gr(t){return t.reduce((t,e)=>t+e.length,0)}async function wr(t){let e=await t.byte();const i=e>>4&7;let r,a,n=15&e;if(128&e){let i=4;do{e=await t.byte(),n|=(127&e)<<i,i+=7}while(128&e)}if(6===i){let i=0;r=0;const n=[];do{e=await t.byte(),r|=(127&e)<<i,i+=7,n.push(e)}while(128&e);a=Buffer.from(n)}if(7===i){a=await t.read(20)}return{type:i,length:n,ofs:r,reference:a}}async function pr(t){return Ae.inflate(t)}class mr{constructor(t){Object.assign(this,t),this.offsetCache={}}static async fromIdx({idx:t,getExternalRefDelta:e}){const i=new ni(t);if("ff744f63"!==i.slice(4).toString("hex"))return;const r=i.readUInt32BE();if(2!==r)throw new ri(`Unable to read version ${r} packfile IDX. (Only version 2 supported)`);if(t.byteLength>2147483648)throw new ri("To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.");i.seek(i.tell()+1020);const a=i.readUInt32BE(),n=[];for(let t=0;t<a;t++){const e=i.slice(20).toString("hex");n[t]=e}i.seek(i.tell()+4*a);const s=new Map;for(let t=0;t<a;t++)s.set(n[t],i.readUInt32BE());const o=i.slice(20).toString("hex");return new mr({hashes:n,crcs:{},offsets:s,packfileSha:o,getExternalRefDelta:e})}static async fromPack({pack:t,getExternalRefDelta:e,onProgress:i}){const r={1:"commit",2:"tree",3:"blob",4:"tag",6:"ofs-delta",7:"ref-delta"},a={},n=t.slice(-20).toString("hex"),s=[],o={},c=new Map;let f=null,d=null;await async function(t,e){const i=new ur(t);let r=await i.read(4);if(r=r.toString("utf8"),"PACK"!==r)throw new ri(`Invalid PACK header '${r}'`);let a=await i.read(4);if(a=a.readUInt32BE(0),2!==a)throw new ri(`Invalid packfile version: ${a}`);let n=await i.read(4);if(n=n.readUInt32BE(0),!(n<1))for(;!i.eof()&&n--;){const t=i.tell(),{type:r,length:a,ofs:s,reference:o}=await wr(i),c=new Ae.Inflate;for(;!c.result;){const f=await i.chunk();if(!f)break;if(c.push(f,!1),c.err)throw new ri(`Pako error: ${c.msg}`);if(c.result){if(c.result.length!==a)throw new ri("Inflated object size is different from that stated in packfile.");await i.undo(),await i.read(f.length-c.strm.avail_in);const d=i.tell();await e({data:c.result,type:r,num:n,offset:t,end:d,reference:o,ofs:s})}}}}([t],async({data:t,type:e,reference:n,offset:s,num:o})=>{null===f&&(f=o);const c=Math.floor(100*(f-o)/f);c!==d&&i&&await i({phase:"Receiving objects",loaded:f-o,total:f}),d=c,(["commit","tree","blob","tag"].includes(e=r[e])||"ofs-delta"===e||"ref-delta"===e)&&(a[s]={type:e,offset:s})});const h=Object.keys(a).map(Number);for(const[e,i]of h.entries()){const r=e+1===h.length?t.byteLength-20:h[e+1],n=a[i],s=v.buf(t.slice(i,r))>>>0;n.end=r,n.crc=s}const l=new mr({pack:Promise.resolve(t),packfileSha:n,crcs:o,hashes:s,offsets:c,getExternalRefDelta:e});d=null;let u=0;const g=[0,0,0,0,0,0,0,0,0,0,0,0];for(let t in a){t=Number(t);const e=Math.floor(100*u/f);e!==d&&i&&await i({phase:"Resolving deltas",loaded:u,total:f}),u++,d=e;const r=a[t];if(!r.oid)try{l.readDepth=0,l.externalReadDepth=0;const{type:e,object:i}=await l.readSlice({start:t});g[l.readDepth]+=1;const a=await ui(or.wrap({type:e,object:i}));r.oid=a,s.push(a),c.set(a,t),o[a]=r.crc}catch(t){continue}}return s.sort(),l}async toBuffer(){const t=[],e=(e,i)=>{t.push(Buffer.from(e,i))};e("ff744f63","hex"),e("00000002","hex");const i=new ni(Buffer.alloc(1024));for(let t=0;t<256;t++){let e=0;for(const i of this.hashes)parseInt(i.slice(0,2),16)<=t&&e++;i.writeUInt32BE(e)}t.push(i.buffer);for(const t of this.hashes)e(t,"hex");const r=new ni(Buffer.alloc(4*this.hashes.length));for(const t of this.hashes)r.writeUInt32BE(this.crcs[t]);t.push(r.buffer);const a=new ni(Buffer.alloc(4*this.hashes.length));for(const t of this.hashes)a.writeUInt32BE(this.offsets.get(t));t.push(a.buffer),e(this.packfileSha,"hex");const n=Buffer.concat(t),s=await ui(n),o=Buffer.alloc(20);return o.write(s,"hex"),Buffer.concat([n,o])}async load({pack:t}){this.pack=t}async unload(){this.pack=null}async read({oid:t}){if(!this.offsets.get(t)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(t);throw new ri(`Could not read object ${t} from packfile`)}const e=this.offsets.get(t);return this.readSlice({start:e})}async readSlice({start:t}){if(this.offsetCache[t])return Object.assign({},this.offsetCache[t]);this.readDepth++;if(!this.pack)throw new ri("Tried to read from a GitPackIndex with no packfile loaded into memory");const e=(await this.pack).slice(t),i=new ni(e),r=i.readUInt8(),a=112&r;let n={16:"commit",32:"tree",48:"blob",64:"tag",96:"ofs_delta",112:"ref_delta"}[a];if(void 0===n)throw new ri("Unrecognized type: 0b"+a.toString(2));const s=15&r;let o=s;128&r&&(o=function(t,e){let i=e,r=4,a=null;do{a=t.readUInt8(),i|=(127&a)<<r,r+=7}while(128&a);return i}(i,s));let c=null,f=null;if("ofs_delta"===n){const e=function(t){const e=[];let i=0,r=0;do{i=t.readUInt8();const a=127&i;e.push(a),r=128&i}while(r);return e.reduce((t,e)=>t+1<<7|e,-1)}(i),r=t-e;({object:c,type:n}=await this.readSlice({start:r}))}if("ref_delta"===n){const t=i.slice(20).toString("hex");({object:c,type:n}=await this.read({oid:t}))}const d=e.slice(i.tell());if(f=Buffer.from(await pr(d)),f.byteLength!==o)throw new ri(`Packfile told us object would have length ${o} but it had length ${f.byteLength}`);return c&&(f=Buffer.from(function(t,e){const i=new ni(t),r=fr(i);if(r!==e.byteLength)throw new ri(`applyDelta expected source buffer to be ${r} bytes but the provided buffer was ${e.length} bytes`);const a=fr(i);let n;const s=hr(i,e);if(s.byteLength===a)n=s;else{n=Buffer.alloc(a);const t=new ni(n);for(t.copy(s);!i.eof();)t.copy(hr(i,e));const r=t.tell();if(a!==r)throw new ri(`applyDelta expected target buffer to be ${a} bytes but the resulting buffer was ${r} bytes`)}return n}(f,c))),this.readDepth>3&&(this.offsetCache[t]={type:n,object:f}),{type:n,format:"content",object:f}}}const yr=Symbol("PackfileCache");function br({fs:t,cache:e,filename:i,getExternalRefDelta:r,emitter:a,emitterPrefix:n}){e[yr]||(e[yr]=new Map);let s=e[yr].get(i);return s||(s=async function({fs:t,filename:e,getExternalRefDelta:i,emitter:r,emitterPrefix:a}){const n=await t.read(e);return mr.fromIdx({idx:n,getExternalRefDelta:i})}({fs:t,filename:i,getExternalRefDelta:r,emitter:a,emitterPrefix:n}),e[yr].set(i,s)),s}async function _r({fs:t,cache:e,gitdir:i,oid:r,format:a="content"}){const n=r=>_r({fs:t,cache:e,gitdir:i,oid:r});let s;if("4b825dc642cb6eb9a060e54bf8d69288fbee4904"===r&&(s={format:"wrapped",object:Buffer.from("tree 0\0")}),s||(s=await cr({fs:t,gitdir:i,oid:r})),!s){if(s=await async function({fs:t,cache:e,gitdir:i,oid:r,format:a="content",getExternalRefDelta:n}){let s=await t.readdir(zi(i,"objects/pack"));s=s.filter(t=>t.endsWith(".idx"));for(const a of s){const s=`${i}/objects/pack/${a}`,o=await br({fs:t,cache:e,filename:s,getExternalRefDelta:n});if(o.error)throw new ri(o.error);if(o.offsets.has(r)){if(!o.pack){const e=s.replace(/idx$/,"pack");o.pack=t.read(e)}const e=await o.read({oid:r,getExternalRefDelta:n});return e.format="content",e.source=`objects/pack/${a.replace(/idx$/,"pack")}`,e}}return null}({fs:t,cache:e,gitdir:i,oid:r,getExternalRefDelta:n}),!s)throw new Ai(r);return s}if("deflated"===a)return s;if("deflated"===s.format&&(s.object=Buffer.from(await pr(s.object)),s.format="wrapped"),"wrapped"===a)return s;const o=await ui(s.object);if(o!==r)throw new ri(`SHA check failed! Expected ${r}, computed ${o}`);const{object:c,type:f}=or.unwrap(s.object);if(s.type=f,s.object=c,s.format="content","content"===a)return s;throw new ri(`invalid requested format "${a}"`)}class vr extends ei{constructor(t,e,i=!0){super(`Failed to create ${t} at ${e} because it already exists.${i?` (Hint: use 'force: true' parameter to overwrite existing ${t}.)`:""}`),this.code=this.name=vr.code,this.data={noun:t,where:e,canForce:i}}}vr.code="AlreadyExistsError";class xr extends ei{constructor(t,e,i){super(`Found multiple ${t} matching "${e}" (${i.join(", ")}). Use a longer abbreviation length to disambiguate them.`),this.code=this.name=xr.code,this.data={nouns:t,short:e,matches:i}}}xr.code="AmbiguousError";class kr extends ei{constructor(t){super(`Your local changes to the following files would be overwritten by checkout: ${t.join(", ")}`),this.code=this.name=kr.code,this.data={filepaths:t}}}kr.code="CheckoutConflictError";class Er extends ei{constructor(t,e){super(`Cannot cherry-pick merge commit ${t}. Merge commits have ${e} parents and require specifying which parent to use as the base.`),this.code=this.name=Er.code,this.data={oid:t,parentCount:e}}}Er.code="CherryPickMergeCommitError";class $r extends ei{constructor(t){super(`Cannot cherry-pick root commit ${t}. Root commits have no parents.`),this.code=this.name=$r.code,this.data={oid:t}}}$r.code="CherryPickRootCommitError";class Sr extends ei{constructor(t,e){super(`Failed to checkout "${t}" because commit ${e} is not available locally. Do a git fetch to make the branch available locally.`),this.code=this.name=Sr.code,this.data={ref:t,oid:e}}}Sr.code="CommitNotFetchedError";class Ar extends ei{constructor(){super("Empty response from git server."),this.code=this.name=Ar.code,this.data={}}}Ar.code="EmptyServerResponseError";class Br extends ei{constructor(){super("A simple fast-forward merge was not possible."),this.code=this.name=Br.code,this.data={}}}Br.code="FastForwardError";class Rr extends ei{constructor(t,e){super(`One or more branches were not updated: ${t}`),this.code=this.name=Rr.code,this.data={prettyDetails:t,result:e}}}Rr.code="GitPushError";class Pr extends ei{constructor(t,e,i){super(`HTTP Error: ${t} ${e}`),this.code=this.name=Pr.code,this.data={statusCode:t,statusMessage:e,response:i}}}Pr.code="HttpError";class jr extends ei{constructor(t){let e="invalid filepath";"leading-slash"===t||"trailing-slash"===t?e='"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.':"directory"===t&&(e='"filepath" should not be a directory.'),super(e),this.code=this.name=jr.code,this.data={reason:t}}}jr.code="InvalidFilepathError";class Or extends ei{constructor(t,e){super(`"${t}" would be an invalid git reference. (Hint: a valid alternative would be "${e}".)`),this.code=this.name=Or.code,this.data={ref:t,suggestion:e}}}Or.code="InvalidRefNameError";class Ir extends ei{constructor(t){super(`Maximum search depth of ${t} exceeded.`),this.code=this.name=Ir.code,this.data={depth:t}}}Ir.code="MaxDepthError";class Cr extends ei{constructor(){super("Merges with conflicts are not supported yet."),this.code=this.name=Cr.code,this.data={}}}Cr.code="MergeNotSupportedError";class zr extends ei{constructor(t,e,i,r){super(`Automatic merge failed with one or more merge conflicts in the following files: ${t.toString()}. Fix conflicts then commit the result.`),this.code=this.name=zr.code,this.data={filepaths:t,bothModified:e,deleteByUs:i,deleteByTheirs:r}}}zr.code="MergeConflictError";class Dr extends ei{constructor(t){super(`No name was provided for ${t} in the argument or in the .git/config file.`),this.code=this.name=Dr.code,this.data={role:t}}}Dr.code="MissingNameError";class Tr extends ei{constructor(t){super(`The function requires a "${t}" parameter but none was provided.`),this.code=this.name=Tr.code,this.data={parameter:t}}}Tr.code="MissingParameterError";class Ur extends ei{constructor(t){super('There are multiple errors that were thrown by the method. Please refer to the "errors" property to see more'),this.code=this.name=Ur.code,this.data={errors:t},this.errors=t}}Ur.code="MultipleGitError";class Nr extends ei{constructor(t,e){super(`Expected "${t}" but received "${e}".`),this.code=this.name=Nr.code,this.data={expected:t,actual:e}}}Nr.code="ParseError";class Mr extends ei{constructor(t){let e="";"not-fast-forward"===t?e=" because it was not a simple fast-forward":"tag-exists"===t&&(e=" because tag already exists"),super(`Push rejected${e}. Use "force: true" to override.`),this.code=this.name=Mr.code,this.data={reason:t}}}Mr.code="PushRejectedError";class Fr extends ei{constructor(t,e){super(`Remote does not support the "${t}" so the "${e}" parameter cannot be used.`),this.code=this.name=Fr.code,this.data={capability:t,parameter:e}}}Fr.code="RemoteCapabilityError";class Hr extends ei{constructor(t,e){super(`Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: ${t}`),this.code=this.name=Hr.code,this.data={preview:t,response:e}}}Hr.code="SmartHttpError";class qr extends ei{constructor(t,e,i){super(`Git remote "${t}" uses an unrecognized transport protocol: "${e}"`),this.code=this.name=qr.code,this.data={url:t,transport:e,suggestion:i}}}qr.code="UnknownTransportError";class Lr extends ei{constructor(t){super(`Cannot parse remote URL: "${t}"`),this.code=this.name=Lr.code,this.data={url:t}}}Lr.code="UrlParseError";class Wr extends ei{constructor(){super("The operation was canceled."),this.code=this.name=Wr.code,this.data={}}}Wr.code="UserCanceledError";class Gr extends ei{constructor(t){super(`Could not merge index: Entry for '${t}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`),this.code=this.name=Gr.code,this.data={filepath:t}}}Gr.code="IndexResetError";class Zr extends ei{constructor(t){super(`"${t}" does not point to any commit. You're maybe working on a repository with no commits yet. `),this.code=this.name=Zr.code,this.data={ref:t}}}Zr.code="NoCommitError";var Kr=Object.freeze({__proto__:null,AlreadyExistsError:vr,AmbiguousError:xr,CheckoutConflictError:kr,CherryPickMergeCommitError:Er,CherryPickRootCommitError:$r,CommitNotFetchedError:Sr,EmptyServerResponseError:Ar,FastForwardError:Br,GitPushError:Rr,HttpError:Pr,InternalError:ri,InvalidFilepathError:jr,InvalidOidError:Ri,InvalidRefNameError:Or,MaxDepthError:Ir,MergeNotSupportedError:Cr,MergeConflictError:zr,MissingNameError:Dr,MissingParameterError:Tr,MultipleGitError:Ur,NoRefspecError:Pi,NotFoundError:Ai,ObjectTypeError:Bi,ParseError:Nr,PushRejectedError:Mr,RemoteCapabilityError:Fr,SmartHttpError:Hr,UnknownTransportError:qr,UnsafeFilepathError:ai,UrlParseError:Lr,UserCanceledError:Wr,UnmergedPathsError:ii,IndexResetError:Gr,NoCommitError:Zr});function Vr({name:t,email:e,timestamp:i,timezoneOffset:r}){return`${t} <${e}> ${i} ${r=function(t){const e=function(t){return Math.sign(t)||(Object.is(t,-0)?-1:1)}((i=t,0===i?i:-i));var i;t=Math.abs(t);const r=Math.floor(t/60);t-=60*r;let a=String(r),n=String(t);a.length<2&&(a="0"+a);n.length<2&&(n="0"+n);return(-1===e?"-":"+")+a+n}(r)}`}function Xr(t){return t=(t=(t=t.replace(/\r/g,"")).replace(/^\n+/,"")).replace(/\n+$/,"")+"\n"}function Yr(t){const[,e,i,r,a]=t.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:e,email:i,timestamp:Number(r),timezoneOffset:Jr(a)}}function Jr(t){let[,e,i,r]=t.match(/(\+|-)(\d\d)(\d\d)/);return r=("+"===e?1:-1)*(60*Number(i)+Number(r)),0===(a=r)?a:-a;var a}class Qr{constructor(t){if("string"==typeof t)this._tag=t;else if(Buffer.isBuffer(t))this._tag=t.toString("utf8");else{if("object"!=typeof t)throw new ri("invalid type passed to GitAnnotatedTag constructor");this._tag=Qr.render(t)}}static from(t){return new Qr(t)}static render(t){return`object ${t.object}\ntype ${t.type}\ntag ${t.tag}\ntagger ${Vr(t.tagger)}\n\n${t.message}\n${t.gpgsig?t.gpgsig:""}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf("\n\n"))}message(){const t=this.withoutSignature();return t.slice(t.indexOf("\n\n")+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){const t=this.justHeaders().split("\n"),e=[];for(const i of t)" "===i[0]?e[e.length-1]+="\n"+i.slice(1):e.push(i);const i={};for(const t of e){const e=t.slice(0,t.indexOf(" ")),r=t.slice(t.indexOf(" ")+1);Array.isArray(i[e])?i[e].push(r):i[e]=r}return i.tagger&&(i.tagger=Yr(i.tagger)),i.committer&&(i.committer=Yr(i.committer)),i}withoutSignature(){const t=Xr(this._tag);return-1===t.indexOf("\n-----BEGIN PGP SIGNATURE-----")?t:t.slice(0,t.lastIndexOf("\n-----BEGIN PGP SIGNATURE-----"))}gpgsig(){if(-1===this._tag.indexOf("\n-----BEGIN PGP SIGNATURE-----"))return;return Xr(this._tag.slice(this._tag.indexOf("-----BEGIN PGP SIGNATURE-----"),this._tag.indexOf("-----END PGP SIGNATURE-----")+27))}payload(){return this.withoutSignature()+"\n"}toObject(){return Buffer.from(this._tag,"utf8")}static async sign(t,e,i){const r=t.payload();let{signature:a}=await e({payload:r,secretKey:i});a=Xr(a);const n=r+a;return Qr.from(n)}}function ta(t){return t.trim().split("\n").map(t=>" "+t).join("\n")+"\n"}class ea{constructor(t){if("string"==typeof t)this._commit=t;else if(Buffer.isBuffer(t))this._commit=t.toString("utf8");else{if("object"!=typeof t)throw new ri("invalid type passed to GitCommit constructor");this._commit=ea.render(t)}}static fromPayloadSignature({payload:t,signature:e}){const i=ea.justHeaders(t),r=ea.justMessage(t),a=Xr(i+"\ngpgsig"+ta(e)+"\n"+r);return new ea(a)}static from(t){return new ea(t)}toObject(){return Buffer.from(this._commit,"utf8")}headers(){return this.parseHeaders()}message(){return ea.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(t){return Xr(t.slice(t.indexOf("\n\n")+2))}static justHeaders(t){return t.slice(0,t.indexOf("\n\n"))}parseHeaders(){const t=ea.justHeaders(this._commit).split("\n"),e=[];for(const i of t)" "===i[0]?e[e.length-1]+="\n"+i.slice(1):e.push(i);const i={parent:[]};for(const t of e){const e=t.slice(0,t.indexOf(" ")),r=t.slice(t.indexOf(" ")+1);Array.isArray(i[e])?i[e].push(r):i[e]=r}return i.author&&(i.author=Yr(i.author)),i.committer&&(i.committer=Yr(i.committer)),i}static renderHeaders(t){let e="";if(t.tree?e+=`tree ${t.tree}\n`:e+="tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904\n",t.parent){if(void 0===t.parent.length)throw new ri("commit 'parent' property should be an array");for(const i of t.parent)e+=`parent ${i}\n`}e+=`author ${Vr(t.author)}\n`;return e+=`committer ${Vr(t.committer||t.author)}\n`,t.gpgsig&&(e+="gpgsig"+ta(t.gpgsig)),e}static render(t){return ea.renderHeaders(t)+"\n"+Xr(t.message)}render(){return this._commit}withoutSignature(){const t=Xr(this._commit);if(-1===t.indexOf("\ngpgsig"))return t;return Xr(t.slice(0,t.indexOf("\ngpgsig"))+"\n"+t.slice(t.indexOf("-----END PGP SIGNATURE-----\n")+28))}isolateSignature(){const t=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return t.split("\n").map(t=>t.replace(/^ /,"")).join("\n")}static async sign(t,e,i){const r=t.withoutSignature(),a=ea.justMessage(t._commit);let{signature:n}=await e({payload:r,secretKey:i});n=Xr(n);const s=ea.justHeaders(t._commit)+"\ngpgsig"+ta(n)+"\n"+a;return ea.from(s)}}async function ia({fs:t,cache:e,gitdir:i,oid:r}){if("4b825dc642cb6eb9a060e54bf8d69288fbee4904"===r)return{tree:sr.from([]),oid:r};const{type:a,object:n}=await _r({fs:t,cache:e,gitdir:i,oid:r});if("tag"===a)return ia({fs:t,cache:e,gitdir:i,oid:r=Qr.from(n).parse().object});if("commit"===a)return ia({fs:t,cache:e,gitdir:i,oid:r=ea.from(n).parse().tree});if("tree"!==a)throw new Bi(r,a,"tree");return{tree:sr.from(n),oid:r}}class ra{constructor({fs:t,gitdir:e,ref:i,cache:r}){this.fs=t,this.cache=r,this.gitdir=e,this.mapPromise=(async()=>{const r=new Map;let a;try{a=await er.resolve({fs:t,gitdir:e,ref:i})}catch(t){t instanceof Ai&&(a="4b825dc642cb6eb9a060e54bf8d69288fbee4904")}const n=await ia({fs:t,cache:this.cache,gitdir:e,oid:a});return n.type="tree",n.mode="40000",r.set(".",n),r})();const a=this;this.ConstructEntry=class{constructor(t){this._fullpath=t,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}}}async readdir(t){const e=t._fullpath,{fs:i,cache:r,gitdir:a}=this,n=await this.mapPromise,s=n.get(e);if(!s)throw new Error(`No obj for ${e}`);const o=s.oid;if(!o)throw new Error(`No oid for obj ${JSON.stringify(s)}`);if("tree"!==s.type)return null;const{type:c,object:f}=await _r({fs:i,cache:r,gitdir:a,oid:o});if(c!==s.type)throw new Bi(o,c,s.type);const d=sr.from(f);for(const t of d)n.set(zi(e,t.path),t);return d.entries().map(t=>zi(e,t.path))}async type(t){if(!1===t._type){const e=await this.mapPromise,{type:i}=e.get(t._fullpath);t._type=i}return t._type}async mode(t){if(!1===t._mode){const e=await this.mapPromise,{mode:i}=e.get(t._fullpath);t._mode=ci(parseInt(i,8))}return t._mode}async stat(t){}async content(t){if(!1===t._content){const e=await this.mapPromise,{fs:i,cache:r,gitdir:a}=this,n=e.get(t._fullpath).oid,{type:s,object:o}=await _r({fs:i,cache:r,gitdir:a,oid:n});t._content="blob"!==s?void 0:new Uint8Array(o)}return t._content}async oid(t){if(!1===t._oid){const e=(await this.mapPromise).get(t._fullpath);t._oid=e.oid}return t._oid}}function aa({ref:t="HEAD"}={}){const e=Object.create(null);return Object.defineProperty(e,$i,{value:function({fs:e,gitdir:i,cache:r}){return new ra({fs:e,gitdir:i,ref:t,cache:r})}}),Object.freeze(e),e}class na{constructor({fs:t,dir:e,gitdir:i,cache:r}){this.fs=t,this.cache=r,this.dir=e,this.gitdir=i,this.config=null;const a=this;this.ConstructEntry=class{constructor(t){this._fullpath=t,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}}}async readdir(t){const e=t._fullpath,{fs:i,dir:r}=this,a=await i.readdir(zi(r,e));return null===a?null:a.map(t=>zi(e,t))}async type(t){return!1===t._type&&await t.stat(),t._type}async mode(t){return!1===t._mode&&await t.stat(),t._mode}async stat(t){if(!1===t._stat){const{fs:e,dir:i}=this;let r=await e.lstat(`${i}/${t._fullpath}`);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t._fullpath}'`);let a=r.isDirectory()?"tree":"blob";"blob"!==a||r.isFile()||r.isSymbolicLink()||(a="special"),t._type=a,r=hi(r),t._mode=r.mode,-1===r.size&&t._actualSize&&(r.size=t._actualSize),t._stat=r}return t._stat}async content(t){if(!1===t._content){const{fs:e,dir:i,gitdir:r}=this;if("tree"===await t.type())t._content=void 0;else{let a;if(await t.mode()>>12==10)a=await e.readlink(`${i}/${t._fullpath}`);else{const n=await this._getGitConfig(e,r),s=await n.get("core.autocrlf");a=await e.read(`${i}/${t._fullpath}`,{autocrlf:s})}t._actualSize=a.length,t._stat&&-1===t._stat.size&&(t._stat.size=t._actualSize),t._content=new Uint8Array(a)}}return t._content}async oid(t){if(!1===t._oid){const e=this,{fs:i,gitdir:r,cache:a}=this;let n;await _i.acquire({fs:i,gitdir:r,cache:a},async function(a){const s=a.entriesMap.get(t._fullpath),o=await t.stat(),c=await e._getGitConfig(i,r),f=await c.get("core.filemode"),d="undefined"==typeof process||!("win32"===process.platform);if(!s||mi(o,s,f,d)){const e=await t.content();void 0===e?n=void 0:(n=await ui(or.wrap({type:"blob",object:e})),!s||n!==s.oid||f&&o.mode!==s.mode||!mi(o,s,f,d)||a.insert({filepath:t._fullpath,stats:o,oid:n}))}else n=s.oid}),t._oid=n}return t._oid}async _getGitConfig(t,e){return this.config||(this.config=await Xi.get({fs:t,gitdir:e})),this.config}}function sa(){const t=Object.create(null);return Object.defineProperty(t,$i,{value:function({fs:t,dir:e,gitdir:i,cache:r}){return new na({fs:t,dir:e,gitdir:i,cache:r})}}),Object.freeze(t),t}const oa=void 0===Array.prototype.flat?t=>t.reduce((t,e)=>t.concat(e),[]):t=>t.flat();class ca{constructor(){this.value=null}consider(t){null!=t&&(null===this.value||t<this.value)&&(this.value=t)}reset(){this.value=null}}function*fa(t){const e=new ca;let i;const r=[],a=t.length;for(let i=0;i<a;i++)r[i]=t[i].next().value,void 0!==r[i]&&e.consider(r[i]);if(null!==e.value)for(;;){const n=[];i=e.value,e.reset();for(let s=0;s<a;s++)void 0!==r[s]&&r[s]===i?(n[s]=r[s],r[s]=t[s].next().value):n[s]=null,void 0!==r[s]&&e.consider(r[s]);if(yield n,null===e.value)return}}async function da({fs:t,cache:e,dir:i,gitdir:r,trees:a,map:n=async(t,e)=>e,reduce:s=async(t,e)=>{const i=oa(e);return void 0!==t&&i.unshift(t),i},iterate:o=(t,e)=>Promise.all([...e].map(t))}){const c=a.map(a=>a[$i]({fs:t,dir:i,gitdir:r,cache:e})),f=new Array(c.length).fill("."),d=function(t,e){const i=e-t;return Array.from({length:i},(e,i)=>t+i)}(0,c.length),h=async t=>{const{entries:e,children:i}=await(async t=>{d.forEach(e=>{const i=t[e];t[e]=i&&new c[e].ConstructEntry(i)});const e=(await Promise.all(d.map(e=>{const i=t[e];return i?c[e].readdir(i):[]}))).map(t=>(null===t?[]:t)[Symbol.iterator]());return{entries:t,children:fa(e)}})(t),r=e.find(t=>t&&t._fullpath)._fullpath,a=await n(r,e);if(null!==a){let t=await o(h,i);return t=t.filter(t=>void 0!==t),s(a,t)}};return h(f)}async function ha(t,e){const i=await t.readdir(e);null==i?await t.rm(e):i.length?await Promise.all(i.map(i=>{const r=zi(e,i);return t.lstat(r).then(e=>{if(e)return e.isDirectory()?ha(t,r):t.rm(r)})})).then(()=>t.rmdir(e)):await t.rmdir(e)}function la(t){return"function"==typeof t}function ua(t){return function(t){return t&&"object"==typeof t}(e=(t=>{try{return t.readFile().catch(t=>t)}catch(t){return t}})(t))&&la(e.then)&&la(e.catch);var e}const ga=["readFile","writeFile","mkdir","rmdir","unlink","stat","lstat","readdir","readlink","symlink"];function wa(t,e){if(ua(e))for(const i of ga)t[`_${i}`]=e[i].bind(e);else for(const i of ga)t[`_${i}`]=Re(e[i].bind(e));ua(e)?(e.cp&&(t._cp=e.cp.bind(e)),e.rm?t._rm=e.rm.bind(e):e.rmdir.length>1?t._rm=e.rmdir.bind(e):t._rm=ha.bind(null,t)):(e.cp&&(t._cp=Re(e.cp.bind(e))),e.rm?t._rm=Re(e.rm.bind(e)):e.rmdir.length>2?t._rm=Re(e.rmdir.bind(e)):t._rm=ha.bind(null,t))}class pa{constructor(t){if(void 0!==t._original_unwrapped_fs)return t;const e=Object.getOwnPropertyDescriptor(t,"promises");e&&e.enumerable?wa(this,t.promises):wa(this,t),this._original_unwrapped_fs=t}async exists(t,e={}){try{return await this._stat(t),!0}catch(t){if("ENOENT"===t.code||"ENOTDIR"===t.code||(t.code||"").includes("ENS"))return!1;throw console.log('Unhandled error in "FileSystem.exists()" function',t),t}}async read(t,e={}){try{let i=await this._readFile(t,e);if("true"===e.autocrlf)try{i=new TextDecoder("utf8",{fatal:!0}).decode(i),i=i.replace(/\r\n/g,"\n"),i=(new TextEncoder).encode(i)}catch(t){}return"string"!=typeof i&&(i=Buffer.from(i)),i}catch(t){return null}}async write(t,e,i={}){try{await this._writeFile(t,e,i)}catch(r){await this.mkdir(xi(t)),await this._writeFile(t,e,i)}}async mkdir(t,e=!1){try{await this._mkdir(t)}catch(i){if(null===i)return;if("EEXIST"===i.code)return;if(e)throw i;if("ENOENT"===i.code){const e=xi(t);if("."===e||"/"===e||e===t)throw i;await this.mkdir(e),await this.mkdir(t,!0)}}}async rm(t){try{await this._unlink(t)}catch(t){if("ENOENT"!==t.code)throw t}}async rmdir(t,e){try{e&&e.recursive?await this._rm(t,e):await this._rmdir(t)}catch(t){if("ENOENT"!==t.code)throw t}}async readdir(t){try{const e=await this._readdir(t);return e.sort(si),e}catch(t){return"ENOTDIR"===t.code?null:[]}}async readdirDeep(t){const e=await this._readdir(t);return(await Promise.all(e.map(async e=>{const i=t+"/"+e;return(await this._stat(i)).isDirectory()?this.readdirDeep(i):i}))).reduce((t,e)=>t.concat(e),[])}async lstat(t){try{return await this._lstat(t)}catch(t){if("ENOENT"===t.code||(t.code||"").includes("ENS"))return null;throw t}}async readlink(t,e={encoding:"buffer"}){try{const i=await this._readlink(t,e);return Buffer.isBuffer(i)?i:Buffer.from(i)}catch(t){if("ENOENT"===t.code||(t.code||"").includes("ENS"))return null;throw t}}async writelink(t,e){return this._symlink(e.toString("utf8"),t)}}function ma(t,e){if(void 0===e)throw new Tr(t)}async function ya({fsp:t,dotgit:e}){ma("fsp",t),ma("dotgit",e);const i=await t._stat(e).catch(()=>({isFile:()=>!1,isDirectory:()=>!1}));return i.isDirectory()?e:i.isFile()?t._readFile(e,"utf8").then(t=>t.trimRight().substr(8)).then(t=>zi(xi(e),t)):e}async function ba(t,e){return!(!t&&!e)&&(!(!t||e)||(!(t||!e)||("tree"!==await t.type()||"tree"!==await e.type())&&(await t.type()!==await e.type()||await t.mode()!==await e.mode()||await t.oid()!==await e.oid())))}async function _a({fs:t,dir:e,gitdir:i=zi(e,".git"),commit:r="HEAD",cache:a={}}){try{ma("fs",t),ma("dir",e),ma("gitdir",i);const n=new pa(t),s=[aa({ref:r}),sa(),Si()];let o=[];const c=await ya({fsp:n,dotgit:i});await _i.acquire({fs:n,gitdir:c,cache:a},async function(t){o=t.unmergedPaths});const f=await da({fs:n,cache:a,dir:e,gitdir:c,trees:s,map:async function(t,[e,i,r]){const a=!await ba(i,r),n=o.includes(t),s=!await ba(r,e);if(a||n)return e?{path:t,mode:await e.mode(),oid:await e.oid(),type:await e.type(),content:await e.content()}:void 0;if(s)return!1;throw new Gr(t)}});await _i.acquire({fs:n,gitdir:c,cache:a},async function(t){for(const i of f)if(!1!==i)if(i){if("blob"===i.type){const r=(new TextDecoder).decode(i.content);await n.write(`${e}/${i.path}`,r,{mode:i.mode}),t.insert({filepath:i.path,oid:i.oid,stage:0})}}else await n.rmdir(`${e}/${i.path}`,{recursive:!0}),t.delete({filepath:i.path})})}catch(t){throw t.caller="git.abortMerge",t}}class va{static async isIgnored({fs:t,dir:e,gitdir:i=zi(e,".git"),filepath:r}){if(".git"===vi(r))return!0;if("."===r)return!1;let a="";const n=zi(i,"info","exclude");await t.exists(n)&&(a=await t.read(n,"utf8"));const s=[{gitignore:zi(e,".gitignore"),filepath:r}],o=r.split("/").filter(Boolean);for(let t=1;t<o.length;t++){const i=o.slice(0,t).join("/"),r=o.slice(t).join("/");s.push({gitignore:zi(e,i,".gitignore"),filepath:r})}let c=!1;for(const e of s){let i;try{i=await t.read(e.gitignore,"utf8")}catch(t){if("NOENT"===t.code)continue}const r=Ve().add(a);r.add(i);const n=xi(e.filepath);if("."!==n&&r.ignores(n))return!0;c=c?!r.test(e.filepath).unignored:r.test(e.filepath).ignored}return c}}let xa=null;async function ka(t){return null===xa&&(xa=function(){try{new CompressionStream("deflate").writable.close();return new Blob([]).stream().cancel(),!0}catch(t){return!1}}()),xa?async function(t){const e=new CompressionStream("deflate"),i=new Blob([t]).stream().pipeThrough(e);return new Uint8Array(await new Response(i).arrayBuffer())}(t):Ae.deflate(t)}async function Ea({fs:t,gitdir:e,type:i,object:r,format:a="content",oid:n,dryRun:s=!1}){return"deflated"!==a&&("wrapped"!==a&&(r=or.wrap({type:i,object:r})),n=await ui(r),r=Buffer.from(await ka(r))),s||await async function({fs:t,gitdir:e,object:i,format:r,oid:a}){if("deflated"!==r)throw new ri("GitObjectStoreLoose expects objects to write to be in deflated format");const n=`${e}/objects/${a.slice(0,2)}/${a.slice(2)}`;await t.exists(n)||await t.write(n,i)}({fs:t,gitdir:e,object:r,format:"deflated",oid:n}),n}function $a(t){let e;for(;~(e=t.indexOf(92));)t[e]=47;return t}async function Sa({fs:t,dir:e,gitdir:i=zi(e,".git"),filepath:r,cache:a={},force:n=!1,parallel:s=!0}){try{ma("fs",t),ma("dir",e),ma("gitdir",i),ma("filepath",r);const o=new pa(t),c=await ya({fsp:o,dotgit:i});await _i.acquire({fs:o,gitdir:c,cache:a},async t=>{const i=await Xi.get({fs:o,gitdir:c}),a=await i.get("core.autocrlf");return Aa({dir:e,gitdir:c,fs:o,filepath:r,index:t,force:n,parallel:s,autocrlf:a})})}catch(t){throw t.caller="git.add",t}}async function Aa({dir:t,gitdir:e,fs:i,filepath:r,index:a,force:n,parallel:s,autocrlf:o}){const c=(r=Array.isArray(r)?r:[r]).map(async r=>{if(!n){if(await va.isIgnored({fs:i,dir:t,gitdir:e,filepath:r}))return}const c=await i.lstat(zi(t,r));if(!c)throw new Ai(r);if(c.isDirectory()){const c=await i.readdir(zi(t,r));if(s){const f=c.map(c=>Aa({dir:t,gitdir:e,fs:i,filepath:[zi(r,c)],index:a,force:n,parallel:s,autocrlf:o}));await Promise.all(f)}else for(const f of c)await Aa({dir:t,gitdir:e,fs:i,filepath:[zi(r,f)],index:a,force:n,parallel:s,autocrlf:o})}else{const n=c.isSymbolicLink()?await i.readlink(zi(t,r)).then($a):await i.read(zi(t,r),{autocrlf:o});if(null===n)throw new Ai(r);const s=await Ea({fs:i,gitdir:e,type:"blob",object:n});a.insert({filepath:r,stats:c,oid:s})}}),f=await Promise.allSettled(c),d=f.filter(t=>"rejected"===t.status).map(t=>t.reason);if(d.length>1)throw new Ur(d);if(1===d.length)throw d[0];return f.filter(t=>"fulfilled"===t.status&&t.value).map(t=>t.value)}async function Ba({fs:t,gitdir:e,path:i}){return(await Xi.get({fs:t,gitdir:e})).get(i)}function Ra(t,...e){for(const i of e)if(i)for(const e of Object.keys(i)){const r=i[e];void 0!==r&&(t[e]=r)}return t}async function Pa({fs:t,gitdir:e,author:i,commit:r}){const a=Math.floor(Date.now()/1e3),n=Ra({},{name:await Ba({fs:t,gitdir:e,path:"user.name"}),email:await Ba({fs:t,gitdir:e,path:"user.email"})||"",timestamp:a,timezoneOffset:new Date(1e3*a).getTimezoneOffset()},r?r.author:void 0,i);if(void 0!==n.name)return n}async function ja({fs:t,gitdir:e,author:i,committer:r,commit:a}){const n=Math.floor(Date.now()/1e3),s=Ra({},{name:await Ba({fs:t,gitdir:e,path:"user.name"}),email:await Ba({fs:t,gitdir:e,path:"user.email"})||"",timestamp:n,timezoneOffset:new Date(1e3*n).getTimezoneOffset()},a?a.committer:void 0,i,r);if(void 0!==s.name)return s}async function Oa({fs:t,cache:e,gitdir:i,oid:r}){const{type:a,object:n}=await _r({fs:t,cache:e,gitdir:i,oid:r});if("tag"===a)return Oa({fs:t,cache:e,gitdir:i,oid:r=Qr.from(n).parse().object});if("commit"!==a)throw new Bi(r,a,"commit");return{commit:ea.from(n),oid:r}}async function Ia({fs:t,cache:e,gitdir:i,oid:r}){const{commit:a,oid:n}=await Oa({fs:t,cache:e,gitdir:i,oid:r});return{oid:n,commit:a.parse(),payload:a.withoutSignature()}}async function Ca({fs:t,cache:e,onSign:i,gitdir:r,message:a,author:n,committer:s,signingKey:o,amend:c=!1,dryRun:f=!1,noUpdateBranch:d=!1,ref:h,parent:l,tree:u}){let g,w,p=!1,m=!1;if(!h){const e=await t.read(`${r}/HEAD`,{encoding:"utf8"});m=!e.startsWith("ref:"),h=await er.resolve({fs:t,gitdir:r,ref:"HEAD",depth:2})}try{g=await er.resolve({fs:t,gitdir:r,ref:h}),w=await Ia({fs:t,gitdir:r,oid:g,cache:{}})}catch{p=!0}if(c&&p)throw new Zr(h);const y=c?await Pa({fs:t,gitdir:r,author:n,commit:w.commit}):await Pa({fs:t,gitdir:r,author:n});if(!y)throw new Dr("author");const b=c?await ja({fs:t,gitdir:r,author:y,committer:s,commit:w.commit}):await ja({fs:t,gitdir:r,author:y,committer:s});if(!b)throw new Dr("committer");return _i.acquire({fs:t,gitdir:r,cache:e,allowUnmerged:!1},async function(e){const n=ki(e.entries).get(".");if(u||(u=await za({fs:t,gitdir:r,inode:n,dryRun:f})),l=l?await Promise.all(l.map(e=>er.resolve({fs:t,gitdir:r,ref:e}))):c?w.commit.parent:g?[g]:[],!a){if(!c)throw new Tr("message");a=w.commit.message}let s=ea.from({tree:u,parent:l,author:y,committer:b,message:a});o&&(s=await ea.sign(s,i,o));const p=await Ea({fs:t,gitdir:r,type:"commit",object:s.toObject(),dryRun:f});return d||f||await er.writeRef({fs:t,gitdir:r,ref:m?"HEAD":h,value:p}),p})}async function za({fs:t,gitdir:e,inode:i,dryRun:r}){const a=i.children;for(const i of a)"tree"===i.type&&(i.metadata.mode="040000",i.metadata.oid=await za({fs:t,gitdir:e,inode:i,dryRun:r}));const n=a.map(t=>({mode:t.metadata.mode,path:t.basename,oid:t.metadata.oid,type:t.type})),s=sr.from(n);return await Ea({fs:t,gitdir:e,type:"tree",object:s.toObject(),dryRun:r})}async function Da({fs:t,cache:e,gitdir:i,oid:r,filepath:a}){if(a.startsWith("/"))throw new jr("leading-slash");if(a.endsWith("/"))throw new jr("trailing-slash");const n=r,s=await ia({fs:t,cache:e,gitdir:i,oid:r}),o=s.tree;if(""===a)r=s.oid;else{const s=a.split("/");r=await Ta({fs:t,cache:e,gitdir:i,tree:o,pathArray:s,oid:n,filepath:a})}return r}async function Ta({fs:t,cache:e,gitdir:i,tree:r,pathArray:a,oid:n,filepath:s}){const o=a.shift();for(const c of r)if(c.path===o){if(0===a.length)return c.oid;{const{type:o,object:f}=await _r({fs:t,cache:e,gitdir:i,oid:c.oid});if("tree"!==o)throw new Bi(n,o,"tree",s);return Ta({fs:t,cache:e,gitdir:i,tree:r=sr.from(f),pathArray:a,oid:n,filepath:s})}}throw new Ai(`file or directory found at "${n}:${s}"`)}async function Ua({fs:t,cache:e,gitdir:i,oid:r,filepath:a}){void 0!==a&&(r=await Da({fs:t,cache:e,gitdir:i,oid:r,filepath:a}));const{tree:n,oid:s}=await ia({fs:t,cache:e,gitdir:i,oid:r});return{oid:s,tree:n.entries()}}async function Na({fs:t,gitdir:e,tree:i}){const r=sr.from(i).toObject();return await Ea({fs:t,gitdir:e,type:"tree",object:r,format:"content"})}async function Ma({fs:t,onSign:e,dir:i,gitdir:r=zi(i,".git"),ref:a="refs/notes/commits",oid:n,note:s,force:o,author:c,committer:f,signingKey:d,cache:h={}}){try{ma("fs",t),ma("gitdir",r),ma("oid",n),ma("note",s),d&&ma("onSign",e);const i=new pa(t),l=await Pa({fs:i,gitdir:r,author:c});if(!l)throw new Dr("author");const u=await ja({fs:i,gitdir:r,author:l,committer:f});if(!u)throw new Dr("committer");const g=await ya({fsp:i,dotgit:r});return await async function({fs:t,cache:e,onSign:i,gitdir:r,ref:a,oid:n,note:s,force:o,author:c,committer:f,signingKey:d}){let h;try{h=await er.resolve({gitdir:r,fs:t,ref:a})}catch(t){if(!(t instanceof Ai))throw t}let l=(await Ua({fs:t,cache:e,gitdir:r,oid:h||"4b825dc642cb6eb9a060e54bf8d69288fbee4904"})).tree;if(o)l=l.filter(t=>t.path!==n);else for(const t of l)if(t.path===n)throw new vr("note",n);"string"==typeof s&&(s=Buffer.from(s,"utf8"));const u=await Ea({fs:t,gitdir:r,type:"blob",object:s,format:"content"});l.push({mode:"100644",path:n,oid:u,type:"blob"});const g=await Na({fs:t,gitdir:r,tree:l});return await Ca({fs:t,cache:e,onSign:i,gitdir:r,ref:a,tree:g,parent:h&&[h],message:"Note added by 'isomorphic-git addNote'\n",author:c,committer:f,signingKey:d})}({fs:i,cache:h,onSign:e,gitdir:g,ref:a,oid:n,note:s,force:o,author:l,committer:u,signingKey:d})}catch(t){throw t.caller="git.addNote",t}}const Fa=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function Ha(t,e){if("string"!=typeof t)throw new TypeError("Reference name must be a string");return!Fa.test(t)&&(!!e||t.includes("/"))}async function qa({fs:t,gitdir:e,remote:i,url:r,force:a}){if(!Ha(i,!0))throw new Or(i,Ye.clean(i));const n=await Xi.get({fs:t,gitdir:e});if(!a){if((await n.getSubsections("remote")).includes(i)&&r!==await n.get(`remote.${i}.url`))throw new vr("remote",i)}await n.set(`remote.${i}.url`,r),await n.set(`remote.${i}.fetch`,`+refs/heads/*:refs/remotes/${i}/*`),await Xi.save({fs:t,gitdir:e,config:n})}async function La({fs:t,dir:e,gitdir:i=zi(e,".git"),remote:r,url:a,force:n=!1}){try{ma("fs",t),ma("gitdir",i),ma("remote",r),ma("url",a);const e=new pa(t),s=await ya({fsp:e,dotgit:i});return await qa({fs:e,gitdir:s,remote:r,url:a,force:n})}catch(t){throw t.caller="git.addRemote",t}}async function Wa({fs:t,onSign:e,dir:i,gitdir:r=zi(i,".git"),ref:a,tagger:n,message:s=a,gpgsig:o,object:c,signingKey:f,force:d=!1,cache:h={}}){try{ma("fs",t),ma("gitdir",r),ma("ref",a),f&&ma("onSign",e);const i=new pa(t),l=await ya({fsp:i,dotgit:r}),u=await Pa({fs:i,gitdir:l,author:n});if(!u)throw new Dr("tagger");return await async function({fs:t,cache:e,onSign:i,gitdir:r,ref:a,tagger:n,message:s=a,gpgsig:o,object:c,signingKey:f,force:d=!1}){if(a=a.startsWith("refs/tags/")?a:`refs/tags/${a}`,!d&&await er.exists({fs:t,gitdir:r,ref:a}))throw new vr("tag",a);const h=await er.resolve({fs:t,gitdir:r,ref:c||"HEAD"}),{type:l}=await _r({fs:t,cache:e,gitdir:r,oid:h});let u=Qr.from({object:h,type:l,tag:a.replace("refs/tags/",""),tagger:n,message:s,gpgsig:o});f&&(u=await Qr.sign(u,i,f));const g=await Ea({fs:t,gitdir:r,type:"tag",object:u.toObject()});await er.writeRef({fs:t,gitdir:r,ref:a,value:g})}({fs:i,cache:h,onSign:e,gitdir:l,ref:a,tagger:u,message:s,gpgsig:o,object:c,signingKey:f,force:d})}catch(t){throw t.caller="git.annotatedTag",t}}async function Ga({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r,object:a,checkout:n=!1,force:s=!1}){try{ma("fs",t),ma("gitdir",i),ma("ref",r);const e=new pa(t),o=await ya({fsp:e,dotgit:i});return await async function({fs:t,gitdir:e,ref:i,object:r,checkout:a=!1,force:n=!1}){if(!Ha(i,!0))throw new Or(i,Ye.clean(i));const s=`refs/heads/${i}`;if(!n&&await er.exists({fs:t,gitdir:e,ref:s}))throw new vr("branch",i,!1);let o;try{o=await er.resolve({fs:t,gitdir:e,ref:r||"HEAD"})}catch(t){}o&&await er.writeRef({fs:t,gitdir:e,ref:s,value:o}),a&&await er.writeSymbolicRef({fs:t,gitdir:e,ref:"HEAD",value:s})}({fs:e,gitdir:o,ref:r,object:a,checkout:n,force:s})}catch(t){throw t.caller="git.branch",t}}const Za=(t,e)=>"."===t||null==e||0===e.length||"."===e||(e.length>=t.length?e.startsWith(t):t.startsWith(e));async function Ka({fs:t,cache:e,onProgress:i,onPostCheckout:r,dir:a,gitdir:n,remote:s,ref:o,filepaths:c,noCheckout:f,noUpdateHead:d,dryRun:h,force:l,track:u=!0,nonBlocking:g=!1,batchSize:w=100}){let p,m;if(r)try{p=await er.resolve({fs:t,gitdir:n,ref:"HEAD"})}catch(t){p="0000000000000000000000000000000000000000"}try{m=await er.resolve({fs:t,gitdir:n,ref:o})}catch(e){if("HEAD"===o)throw e;const i=`${s}/${o}`;if(m=await er.resolve({fs:t,gitdir:n,ref:i}),u){const e=await Xi.get({fs:t,gitdir:n});await e.set(`branch.${o}.remote`,s),await e.set(`branch.${o}.merge`,`refs/heads/${o}`),await Xi.save({fs:t,gitdir:n,config:e})}await er.writeRef({fs:t,gitdir:n,ref:`refs/heads/${o}`,value:m})}if(!f){let s;try{s=await async function({fs:t,cache:e,onProgress:i,dir:r,gitdir:a,ref:n,force:s,filepaths:o}){let c=0;return da({fs:t,cache:e,dir:r,gitdir:a,trees:[aa({ref:n}),sa(),Si()],map:async function(t,[e,r,a]){if("."===t)return;if(o&&!o.some(e=>Za(t,e)))return null;i&&await i({phase:"Analyzing workdir",loaded:++c});switch([!!a,!!e,!!r].map(Number).join("")){case"000":return;case"001":return s&&o&&o.includes(t)?["delete",t]:void 0;case"010":switch(await e.type()){case"tree":return["mkdir",t];case"blob":return["create",t,await e.oid(),await e.mode()];case"commit":return["mkdir-index",t,await e.oid(),await e.mode()];default:return["error",`new entry Unhandled type ${await e.type()}`]}case"011":switch(`${await e.type()}-${await r.type()}`){case"tree-tree":case"commit-tree":return;case"tree-blob":case"blob-tree":case"commit-blob":return["conflict",t];case"blob-blob":return await e.oid()!==await r.oid()?s?["update",t,await e.oid(),await e.mode(),await e.mode()!==await r.mode()]:["conflict",t]:await e.mode()!==await r.mode()?s?["update",t,await e.oid(),await e.mode(),!0]:["conflict",t]:["create-index",t,await e.oid(),await e.mode()];default:return["error",`new entry Unhandled type ${e.type}`]}case"100":return["delete-index",t];case"101":switch(await a.type()){case"tree":case"commit":return["rmdir-index",t];case"blob":return await a.oid()!==await r.oid()?s?["delete",t]:["conflict",t]:["delete",t];default:return["error",`delete entry Unhandled type ${await a.type()}`]}case"110":case"111":switch(`${await a.type()}-${await e.type()}`){case"tree-tree":return;case"blob-blob":if(await a.oid()===await e.oid()&&await a.mode()===await e.mode()&&!s)return;if(r){if(await r.oid()!==await a.oid()&&await r.oid()!==await e.oid())return s?["update",t,await e.oid(),await e.mode(),await e.mode()!==await r.mode()]:["conflict",t]}else if(s)return["update",t,await e.oid(),await e.mode(),await e.mode()!==await a.mode()];return await e.mode()!==await a.mode()?["update",t,await e.oid(),await e.mode(),!0]:await e.oid()!==await a.oid()?["update",t,await e.oid(),await e.mode(),!1]:void 0;case"tree-blob":return["update-dir-to-blob",t,await e.oid()];case"blob-tree":return["update-blob-to-tree",t];case"commit-commit":return["mkdir-index",t,await e.oid(),await e.mode()];default:return["error",`update entry Unhandled type ${await a.type()}-${await e.type()}`]}}},reduce:async function(t,e){return e=oa(e),t?t&&"rmdir"===t[0]?(e.push(t),e):(e.unshift(t),e):e}})}({fs:t,cache:e,onProgress:i,dir:a,gitdir:n,ref:o,force:l,filepaths:c})}catch(t){throw t instanceof Ai&&t.data.what===m?new Sr(o,m):t}const f=s.filter(([t])=>"conflict"===t).map(([t,e])=>e);if(f.length>0)throw new kr(f);const d=s.filter(([t])=>"error"===t).map(([t,e])=>e);if(d.length>0)throw new ri(d.join(", "));if(h)return void(r&&await r({previousHead:p,newHead:m,type:null!=c&&c.length>0?"file":"branch"}));let u=0;const y=s.length;if(await _i.acquire({fs:t,gitdir:n,cache:e},async function(e){await Promise.all(s.filter(([t])=>"delete"===t||"delete-index"===t).map(async function([r,n]){const s=`${a}/${n}`;"delete"===r&&await t.rm(s),e.delete({filepath:n}),i&&await i({phase:"Updating workdir",loaded:++u,total:y})}))}),await _i.acquire({fs:t,gitdir:n,cache:e},async function(e){for(const[r,n]of s)if("rmdir"===r||"rmdir-index"===r){const s=`${a}/${n}`;try{"rmdir"===r&&await t.rmdir(s),e.delete({filepath:n}),i&&await i({phase:"Updating workdir",loaded:++u,total:y})}catch(t){if("ENOTEMPTY"!==t.code)throw t;console.log(`Did not delete ${n} because directory is not empty`)}}}),await Promise.all(s.filter(([t])=>"mkdir"===t||"mkdir-index"===t).map(async function([e,r]){const n=`${a}/${r}`;await t.mkdir(n),i&&await i({phase:"Updating workdir",loaded:++u,total:y})})),g){const r=s.filter(([t])=>"create"===t||"create-index"===t||"update"===t||"mkdir-index"===t),o=await Va("Update Working Dir",r.map(([i,r,s,o,c])=>()=>async function({fs:t,cache:e,gitdir:i,dir:r},[a,n,s,o,c]){const f=`${r}/${n}`;if("create-index"!==a&&"mkdir-index"!==a){const{object:r}=await _r({fs:t,cache:e,gitdir:i,oid:s});if(c&&await t.rm(f),33188===o)await t.write(f,r);else if(33261===o)await t.write(f,r,{mode:511});else{if(40960!==o)throw new ri(`Invalid mode 0o${o.toString(8)} detected in blob ${s}`);await t.writelink(f,r)}}const d=await t.lstat(f);33261===o&&(d.mode=493);"mkdir-index"===a&&(d.mode=57344);return[n,s,d]}({fs:t,cache:e,gitdir:n,dir:a},[i,r,s,o,c])),i,w);await _i.acquire({fs:t,gitdir:n,cache:e,allowUnmerged:!0},async function(t){await Va("Update Index",o.map(([e,i,r])=>()=>async function({index:t,fullpath:e,stats:i,oid:r}){try{t.insert({filepath:e,stats:i,oid:r})}catch(t){console.warn(`Error inserting ${e} into index:`,t)}}({index:t,fullpath:e,oid:i,stats:r})),i,w)})}else await _i.acquire({fs:t,gitdir:n,cache:e,allowUnmerged:!0},async function(r){await Promise.all(s.filter(([t])=>"create"===t||"create-index"===t||"update"===t||"mkdir-index"===t).map(async function([s,o,c,f,d]){const h=`${a}/${o}`;try{if("create-index"!==s&&"mkdir-index"!==s){const{object:i}=await _r({fs:t,cache:e,gitdir:n,oid:c});if(d&&await t.rm(h),33188===f)await t.write(h,i);else if(33261===f)await t.write(h,i,{mode:511});else{if(40960!==f)throw new ri(`Invalid mode 0o${f.toString(8)} detected in blob ${c}`);await t.writelink(h,i)}}const a=await t.lstat(h);33261===f&&(a.mode=493),"mkdir-index"===s&&(a.mode=57344),r.insert({filepath:o,stats:a,oid:c}),i&&await i({phase:"Updating workdir",loaded:++u,total:y})}catch(t){console.log(t)}}))});r&&await r({previousHead:p,newHead:m,type:null!=c&&c.length>0?"file":"branch"})}if(!d){const e=await er.expand({fs:t,gitdir:n,ref:o});e.startsWith("refs/heads")?await er.writeSymbolicRef({fs:t,gitdir:n,ref:"HEAD",value:e}):await er.writeRef({fs:t,gitdir:n,ref:"HEAD",value:m})}}async function Va(t,e,i,r){const a=[];try{for(let t=0;t<e.length;t+=r){const n=e.slice(t,t+r).map(t=>t());(await Promise.allSettled(n)).forEach(t=>{"fulfilled"===t.status&&a.push(t.value)}),i&&await i({phase:"Updating workdir",loaded:t+n.length,total:e.length})}return a}catch(e){console.error(`Error during ${t}: ${e}`)}return a}async function Xa({fs:t,onProgress:e,onPostCheckout:i,dir:r,gitdir:a=zi(r,".git"),remote:n="origin",ref:s,filepaths:o,noCheckout:c=!1,noUpdateHead:f=void 0===s,dryRun:d=!1,force:h=!1,track:l=!0,cache:u={},nonBlocking:g=!1,batchSize:w=100}){try{ma("fs",t),ma("dir",r),ma("gitdir",a);const p=s||"HEAD",m=new pa(t),y=await ya({fsp:m,dotgit:a});return await Ka({fs:m,cache:u,onProgress:e,onPostCheckout:i,dir:r,gitdir:y,remote:n,ref:p,filepaths:o,noCheckout:c,noUpdateHead:f,dryRun:d,force:h,track:l,nonBlocking:g,batchSize:w})}catch(t){throw t.caller="git.checkout",t}}const Ya=/^.*(\r?\n|$)/gm;function Ja({branches:t,contents:e}){const i=t[1],r=t[2],a=e[0],n=e[1],s=e[2],o=n.match(Ya),c=a.match(Ya),f=s.match(Ya),d=ti(o,c,f);let h="",l=!0;for(const t of d)t.ok&&(h+=t.ok.join("")),t.conflict&&(l=!1,h+=`${"<".repeat(7)} ${i}\n`,h+=t.conflict.a.join(""),h+=`${"=".repeat(7)}\n`,h+=t.conflict.b.join(""),h+=`${">".repeat(7)} ${r}\n`);return{cleanMerge:l,mergedText:h}}async function Qa({fs:t,cache:e,dir:i,gitdir:r=zi(i,".git"),index:a,ourOid:n,baseOid:s,theirOid:o,ourName:c="ours",baseName:f="base",theirName:d="theirs",dryRun:h=!1,abortOnConflict:l=!0,mergeDriver:u}){const g=aa({ref:n}),w=aa({ref:s}),p=aa({ref:o}),m=[],y=[],b=[],_=[],v=await da({fs:t,cache:e,dir:i,gitdir:r,trees:[g,w,p],map:async function(e,[i,n,s]){const o=vi(e);switch(`${await ba(i,n)}-${await ba(s,n)}`){case"false-false":return{mode:await n.mode(),path:o,oid:await n.oid(),type:await n.type()};case"false-true":return s||"tree"!==await i.type()?s?{mode:await s.mode(),path:o,oid:await s.oid(),type:await s.type()}:void 0:{mode:await i.mode(),path:o,oid:await i.oid(),type:await i.type()};case"true-false":return i||"tree"!==await s.type()?i?{mode:await i.mode(),path:o,oid:await i.oid(),type:await i.type()}:void 0:{mode:await s.mode(),path:o,oid:await s.oid(),type:await s.type()};case"true-true":if(i&&s&&"tree"===await i.type()&&"tree"===await s.type())return{mode:await i.mode(),path:o,oid:await i.oid(),type:"tree"};if(i&&s&&"blob"===await i.type()&&"blob"===await s.type())return async function({fs:t,gitdir:e,path:i,ours:r,base:a,theirs:n,ourName:s,theirName:o,baseName:c,dryRun:f,mergeDriver:d=Ja}){const h="blob";let l="100755",u="",g="";a&&"blob"===await a.type()&&(l=await a.mode(),u=await a.oid(),g=Buffer.from(await a.content()).toString("utf8"));const w=l===await r.mode()?await n.mode():await r.mode();if(await r.oid()===await n.oid())return{cleanMerge:!0,mergeResult:{mode:w,path:i,oid:await r.oid(),type:h}};if(await r.oid()===u)return{cleanMerge:!0,mergeResult:{mode:w,path:i,oid:await n.oid(),type:h}};if(await n.oid()===u)return{cleanMerge:!0,mergeResult:{mode:w,path:i,oid:await r.oid(),type:h}};const p=Buffer.from(await r.content()).toString("utf8"),m=Buffer.from(await n.content()).toString("utf8"),{mergedText:y,cleanMerge:b}=await d({branches:[c,s,o],contents:[g,p,m],path:i}),_=await Ea({fs:t,gitdir:e,type:"blob",object:Buffer.from(y,"utf8"),dryRun:f});return{cleanMerge:b,mergeResult:{mode:w,path:i,oid:_,type:h}}}({fs:t,gitdir:r,path:o,ours:i,base:n,theirs:s,ourName:c,baseName:f,theirName:d,mergeDriver:u}).then(async t=>{if(t.cleanMerge)l||a.insert({filepath:e,oid:t.mergeResult.oid,stage:0});else if(m.push(e),y.push(e),!l){let t="";n&&"blob"===await n.type()&&(t=await n.oid());const r=await i.oid(),o=await s.oid();a.delete({filepath:e}),t&&a.insert({filepath:e,oid:t,stage:1}),a.insert({filepath:e,oid:r,stage:2}),a.insert({filepath:e,oid:o,stage:3})}return t.mergeResult});if(n&&!i&&s&&"blob"===await n.type()&&"blob"===await s.type()){if(m.push(e),b.push(e),!l){const t=await n.oid(),i=await s.oid();a.delete({filepath:e}),a.insert({filepath:e,oid:t,stage:1}),a.insert({filepath:e,oid:i,stage:3})}return{mode:await s.mode(),oid:await s.oid(),type:"blob",path:o}}if(n&&i&&!s&&"blob"===await n.type()&&"blob"===await i.type()){if(m.push(e),_.push(e),!l){const t=await n.oid(),r=await i.oid();a.delete({filepath:e}),a.insert({filepath:e,oid:t,stage:1}),a.insert({filepath:e,oid:r,stage:2})}return{mode:await i.mode(),oid:await i.oid(),type:"blob",path:o}}if(n&&!i&&!s&&("blob"===await n.type()||"tree"===await n.type()))return;throw new Cr}},reduce:0===m.length||i&&!l?async(e,i)=>{const a=i.filter(Boolean);if(e&&(!e||"tree"!==e.type||0!==a.length||"."===e.path)){if(a.length>0||"."===e.path&&0===a.length){const i=new sr(a).toObject(),n=await Ea({fs:t,gitdir:r,type:"tree",object:i,dryRun:h});e.oid=n}return e}}:void 0});return 0!==m.length?(i&&!l&&await da({fs:t,cache:e,dir:i,gitdir:r,trees:[aa({ref:v.oid})],map:async function(e,[r]){const a=`${i}/${e}`;if("blob"===await r.type()){const e=await r.mode(),i=(new TextDecoder).decode(await r.content());await t.write(a,i,{mode:e})}return!0}}),new zr(m,y,b,_)):v.oid}const tn={stage:Si,workdir:sa};let en;async function rn(t,e){return void 0===en&&(en=new s),en.acquire(t,e)}async function an({fs:t,dir:e,gitdir:i,entries:r}){return Promise.all(r.map(async function r(a){if("tree"===a.type){if(!a.oid){const e=await Promise.all(a.children.map(r));a.oid=await Na({fs:t,gitdir:i,tree:e}),a.mode=16384}}else"blob"===a.type&&(a.oid=await async function(t,e,i,r,a=null){const n=zi(i,r),s=await t.lstat(n);if(!s)throw new Ai(n);if(s.isDirectory())throw new ri(`${n}: file expected, but found directory`);const o=a?await cr({fs:t,gitdir:e,oid:a}):void 0;let c=o?a:void 0;return o||await rn({fs:t,gitdir:e,currentFilepath:n},async()=>{const i=s.isSymbolicLink()?await t.readlink(n).then($a):await t.read(n);if(null===i)throw new Ai(n);c=await Ea({fs:t,gitdir:e,type:"blob",object:i})}),c}(t,i,e,a.path,a.oid),a.mode=33188);return a.path=a.path.split("/").pop(),a}))}async function nn({fs:t,dir:e,gitdir:i,treePair:r}){const a="stage"===r[1],n=r.map(t=>"string"==typeof t?tn[t]():t),s=[],o=await da({fs:t,cache:{},dir:e,gitdir:i,trees:n,map:async(r,[a,n])=>{if("."!==r&&!await va.isIgnored({fs:t,dir:e,gitdir:i,filepath:r}))return n?((!a||await a.oid()!==await n.oid()&&void 0!==await n.oid())&&s.push([a,n]),{mode:await n.mode(),path:r,oid:await n.oid(),type:await n.type()}):void 0},reduce:async(t,e)=>(e=e.filter(Boolean),t?(t.children=e,t):e.length>0?e:void 0),iterate:async(i,r)=>{const n=[];for(const i of r){const[r,o]=i;a?o&&(await t.exists(`${e}/${o.toString()}`)?n.push(i):s.push([null,o])):r&&(o?n.push(i):s.push([r,null]))}return n.length?Promise.all(n.map(i)):[]}});if(0===s.length||0===o.length)return null;const c=(await an({fs:t,dir:e,gitdir:i,entries:o})).filter(Boolean).map(t=>({mode:t.mode,path:t.path,oid:t.oid,type:t.type}));return Na({fs:t,gitdir:i,tree:c})}async function sn({fs:t,dir:e,gitdir:i,stashCommit:r,parentCommit:a,wasStaged:n}){const s=[],o=[],c=await da({fs:t,cache:{},dir:e,gitdir:i,trees:[aa({ref:a}),aa({ref:r})],map:async(r,[a,c])=>{if("."===r||await va.isIgnored({fs:t,dir:e,gitdir:i,filepath:r}))return;const f=c?await c.type():await a.type();if("tree"!==f&&"blob"!==f)return;if(!c&&a){const t="tree"===f?"rmdir":"rm";return"tree"===f&&s.push(r),"blob"===f&&n&&o.push({filepath:r,oid:await a.oid()}),{method:t,filepath:r}}const d=await c.oid();return a&&await a.oid()===d?void 0:"tree"===f?{method:"mkdir",filepath:r}:(n&&o.push({filepath:r,oid:d,stats:await t.lstat(zi(e,r))}),{method:"write",filepath:r,oid:d})}});await rn({fs:t,gitdir:i,dirRemoved:s,ops:c},async()=>{for(const r of c){const a=zi(e,r.filepath);switch(r.method){case"rmdir":await t.rmdir(a);break;case"mkdir":await t.mkdir(a);break;case"rm":await t.rm(a);break;case"write":if(!s.some(t=>a.startsWith(t))){const{object:e}=await _r({fs:t,cache:{},gitdir:i,oid:r.oid});await t.exists(a)&&await t.rm(a),await t.write(a,e)}}}}),await _i.acquire({fs:t,gitdir:i,cache:{}},async t=>{o.forEach(({filepath:e,stats:i,oid:r})=>{t.insert({filepath:e,stats:i,oid:r})})})}async function on({fs:t,cache:e,dir:i,gitdir:r,oid:a,dryRun:n=!1,noUpdateBranch:s=!1,abortOnConflict:o=!0,committer:c,mergeDriver:f}){const{commit:d,oid:h}=await Ia({fs:t,cache:e,gitdir:r,oid:a});if(d.parent.length>1)throw new Er(h,d.parent.length);if(0===d.parent.length)throw new $r(h);const l=await er.resolve({fs:t,gitdir:r,ref:"HEAD"}),{commit:u}=await Ia({fs:t,cache:e,gitdir:r,oid:l}),g=d.parent[0],{commit:w}=await Ia({fs:t,cache:e,gitdir:r,oid:g}),p=await _i.acquire({fs:t,gitdir:r,cache:e,allowUnmerged:!1},async a=>Qa({fs:t,cache:e,dir:i,gitdir:r,index:a,ourOid:u.tree,baseOid:w.tree,theirOid:d.tree,ourName:"HEAD",baseName:`parent of ${h.slice(0,7)}`,theirName:h.slice(0,7),dryRun:n,abortOnConflict:o,mergeDriver:f}));if(p instanceof zr)throw p;const m=await Ca({fs:t,cache:e,gitdir:r,message:d.message,tree:p,parent:[l],author:d.author,committer:c,dryRun:n,noUpdateBranch:s});return!i||n||s||await sn({fs:t,dir:i,gitdir:r,stashCommit:m,parentCommit:l,wasStaged:!0}),m}async function cn({fs:t,dir:e,gitdir:i=zi(e,".git"),oid:r,cache:a={},committer:n,dryRun:s=!1,noUpdateBranch:o=!1,abortOnConflict:c=!0,mergeDriver:f}){try{ma("fs",t),ma("gitdir",i),ma("oid",r);const d=new pa(t),h=await ya({fsp:d,dotgit:i}),{commit:l}=await Ia({fs:d,cache:a,gitdir:h,oid:r});if(l.parent&&l.parent.length>1)return await on({fs:d,cache:a,dir:e,gitdir:h,oid:r,dryRun:s,noUpdateBranch:o,abortOnConflict:c,committer:void 0,mergeDriver:f});const u=await ja({fs:d,gitdir:h,committer:n});if(!u)throw new Dr("committer");return await on({fs:d,cache:a,dir:e,gitdir:h,oid:r,dryRun:s,noUpdateBranch:o,abortOnConflict:c,committer:u,mergeDriver:f})}catch(t){throw t.caller="git.cherryPick",t}}const fn=/^refs\/(heads\/|tags\/|remotes\/)?(.*)/;function dn(t){const e=fn.exec(t);return e?"remotes/"===e[1]&&t.endsWith("/HEAD")?e[2].slice(0,-5):e[2]:t}async function hn({fs:t,gitdir:e,fullname:i=!1,test:r=!1}){const a=await er.resolve({fs:t,gitdir:e,ref:"HEAD",depth:2});if(r)try{await er.resolve({fs:t,gitdir:e,ref:a})}catch(t){return}if(a.startsWith("refs/"))return i?a:dn(a)}function ln({username:t="",password:e=""}){return`Basic ${Buffer.from(`${t}:${e}`).toString("base64")}`}async function un(t,e){const i=lr(t);for(;;){const{value:t,done:r}=await i.next();if(t&&await e(t),r)break}i.return&&i.return()}async function gn(t){let e=0;const i=[];await un(t,t=>{i.push(t),e+=t.byteLength});const r=new Uint8Array(e);let a=0;for(const t of i)r.set(t,a),a+=t.byteLength;return r}function wn(t){let e=t.match(/^https?:\/\/([^/]+)@/);if(null==e)return{url:t,auth:{}};e=e[1];const[i,r]=e.split(":");return{url:t=t.replace(`${e}@`,""),auth:{username:i,password:r}}}function pn(t,e){const i=e.toString(16);return"0".repeat(t-i.length)+i}class mn{static flush(){return Buffer.from("0000","utf8")}static delim(){return Buffer.from("0001","utf8")}static encode(t){"string"==typeof t&&(t=Buffer.from(t));const e=pn(4,t.length+4);return Buffer.concat([Buffer.from(e,"utf8"),t])}static streamReader(t){const e=new ur(t);return async function(){try{let t=await e.read(4);if(null==t)return!0;if(t=parseInt(t.toString("utf8"),16),0===t)return null;if(1===t)return null;const i=await e.read(t-4);return null==i||i}catch(e){return t.error=e,!0}}}}async function yn(t){const e={};let i;for(;i=await t(),!0!==i;){if(null===i)continue;i=i.toString("utf8").replace(/\n$/,"");const t=i.indexOf("=");if(t>-1){const r=i.slice(0,t),a=i.slice(t+1);e[r]=a}else e[i]=!0}return{protocolVersion:2,capabilities2:e}}async function bn(t,{service:e}){const i=new Set,r=new Map,a=new Map,n=mn.streamReader(t);let s=await n();for(;null===s;)s=await n();if(!0===s)throw new Ar;if(s.includes("version 2"))return yn(n);if(s.toString("utf8").replace(/\n$/,"")!==`# service=${e}`)throw new Nr(`# service=${e}\\n`,s.toString("utf8"));let o=await n();for(;null===o;)o=await n();if(!0===o)return{capabilities:i,refs:r,symrefs:a};if(o=o.toString("utf8"),o.includes("version 2"))return yn(n);const[c,f]=_n(o,"\0","\\x00");if(f.split(" ").map(t=>i.add(t)),"0000000000000000000000000000000000000000 capabilities^{}"!==c){const[t,e]=_n(c," "," ");for(r.set(e,t);;){const t=await n();if(!0===t)break;if(null!==t){const[e,i]=_n(t.toString("utf8")," "," ");r.set(i,e)}}}for(const t of i)if(t.startsWith("symref=")){const e=t.match(/symref=([^:]+):(.*)/);3===e.length&&a.set(e[1],e[2])}return{protocolVersion:1,capabilities:i,refs:r,symrefs:a}}function _n(t,e,i){const r=t.trim().split(e);if(2!==r.length)throw new Nr(`Two strings separated by '${i}'`,t.toString("utf8"));return r}const vn=(t,e)=>t.endsWith("?")?`${t}${e}`:`${t}/${e.replace(/^https?:\/\//,"")}`,xn=(t,e)=>{(e.username||e.password)&&(t.Authorization=ln(e)),e.headers&&Object.assign(t,e.headers)},kn=async t=>{try{const e=Buffer.from(await gn(t.body)),i=e.toString("utf8");return{preview:i.length<256?i:i.slice(0,256)+"...",response:i,data:e}}catch(t){return{}}};class En{static async capabilities(){return["discover","connect"]}static async discover({http:t,onProgress:e,onAuth:i,onAuthSuccess:r,onAuthFailure:a,corsProxy:n,service:s,url:o,headers:c,protocolVersion:f}){let{url:d,auth:h}=wn(o);const l=n?vn(n,d):d;let u,g;(h.username||h.password)&&(c.Authorization=ln(h)),2===f&&(c["Git-Protocol"]="version=2");let w=!1;do{if(u=await t.request({onProgress:e,method:"GET",url:`${l}/info/refs?service=${s}`,headers:c}),g=!1,401===u.statusCode||203===u.statusCode){const t=w?a:i;if(t){if(h=await t(d,{...h,headers:{...c}}),h&&h.cancel)throw new Wr;h&&(xn(c,h),w=!0,g=!0)}}else 200===u.statusCode&&w&&r&&await r(d,h)}while(g);if(200!==u.statusCode){const{response:t}=await kn(u);throw new Pr(u.statusCode,u.statusMessage,t)}if(u.headers["content-type"]===`application/x-${s}-advertisement`){const t=await bn(u.body,{service:s});return t.auth=h,t}{const{preview:t,response:e,data:i}=await kn(u);try{const t=await bn([i],{service:s});return t.auth=h,t}catch(i){throw new Hr(t,e)}}}static async connect({http:t,onProgress:e,corsProxy:i,service:r,url:a,auth:n,body:s,headers:o}){const c=wn(a);c&&(a=c.url),i&&(a=vn(i,a)),o["content-type"]=`application/x-${r}-request`,o.accept=`application/x-${r}-result`,xn(o,n);const f=await t.request({onProgress:e,method:"POST",url:`${a}/${r}`,body:s,headers:o});if(200!==f.statusCode){const{response:t}=kn(f);throw new Pr(f.statusCode,f.statusMessage,t)}return f}}class $n{static getRemoteHelperFor({url:t}){const e=new Map;e.set("http",En),e.set("https",En);const i=function({url:t}){if(t.startsWith("git@"))return{transport:"ssh",address:t};const e=t.match(/(\w+)(:\/\/|::)(.*)/);if(null===e)return;if("://"===e[2])return{transport:e[1],address:e[0]};if("::"===e[2])return{transport:e[1],address:e[3]}}({url:t});if(!i)throw new Lr(t);if(e.has(i.transport))return e.get(i.transport);throw new qr(t,i.transport,"ssh"===i.transport?function(t){return(t=t.replace(/^git@([^:]+):/,"https://$1/")).replace(/^ssh:\/\//,"https://")}(t):void 0)}}let Sn=null;class An{static async read({fs:t,gitdir:e}){null===Sn&&(Sn=new s);const i=zi(e,"shallow"),r=new Set;return await Sn.acquire(i,async function(){const e=await t.read(i,{encoding:"utf8"});return null===e||""===e.trim()?r:void e.trim().split("\n").map(t=>r.add(t))}),r}static async write({fs:t,gitdir:e,oids:i}){null===Sn&&(Sn=new s);const r=zi(e,"shallow");if(i.size>0){const e=[...i].join("\n")+"\n";await Sn.acquire(r,async function(){await t.write(r,e,{encoding:"utf8"})})}else await Sn.acquire(r,async function(){await t.rm(r)})}}async function Bn({fs:t,cache:e,gitdir:i,oid:r,format:a="content"}){const n=r=>_r({fs:t,cache:e,gitdir:i,oid:r});let s=await async function({fs:t,gitdir:e,oid:i}){const r=`objects/${i.slice(0,2)}/${i.slice(2)}`;return t.exists(`${e}/${r}`)}({fs:t,gitdir:i,oid:r});return s||(s=await async function({fs:t,cache:e,gitdir:i,oid:r,getExternalRefDelta:a}){let n=await t.readdir(zi(i,"objects/pack"));n=n.filter(t=>t.endsWith(".idx"));for(const s of n){const n=`${i}/objects/pack/${s}`,o=await br({fs:t,cache:e,filename:n,getExternalRefDelta:a});if(o.error)throw new ri(o.error);if(o.offsets.has(r))return!0}return!1}({fs:t,cache:e,gitdir:i,oid:r,getExternalRefDelta:n})),s}function Rn(t,e){const i=t.map(t=>t.split("=",1)[0]);return e.filter(t=>{const e=t.split("=",1)[0];return i.includes(e)})}const Pn="1.37.1",jn="git/isomorphic-git@1.37.1";class On{constructor(){this._queue=[]}write(t){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){const e=this._waiting;this._waiting=null,e({value:t})}else this._queue.push(t)}end(){if(this._ended=!0,this._waiting){const t=this._waiting;this._waiting=null,t({done:!0})}}destroy(t){this.error=t,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(t=>{this._waiting=t})}}function In(t){const e=t.indexOf("\r"),i=t.indexOf("\n");return-1===e&&-1===i?-1:-1===e?i+1:-1===i?e+1:i===e+1?i+1:Math.min(e,i)+1}function Cn(t){const e=new On;let i="";return(async()=>{await un(t,t=>{for(t=t.toString("utf8"),i+=t;;){const t=In(i);if(-1===t)break;e.write(i.slice(0,t)),i=i.slice(t)}}),i.length>0&&e.write(i),e.end()})(),e}class zn{static demux(t){const e=mn.streamReader(t),i=new On,r=new On,a=new On,n=async function(){const s=await e();if(null===s)return n();if(!0===s)return i.end(),a.end(),void(t.error?r.destroy(t.error):r.end());switch(s[0]){case 1:r.write(s.slice(1));break;case 2:a.write(s.slice(1));break;case 3:{const t=s.slice(1);return a.write(t),i.end(),a.end(),void r.destroy(new Error(t.toString("utf8")))}default:i.write(s)}n()};return n(),{packetlines:i,packfile:r,progress:a}}}async function Dn({fs:t,cache:e,http:i,onProgress:r,onMessage:a,onAuth:n,onAuthSuccess:s,onAuthFailure:o,gitdir:c,ref:f,remoteRef:d,remote:h,url:l,corsProxy:u,depth:g=null,since:w=null,exclude:p=[],relative:m=!1,tags:y=!1,singleBranch:b=!1,headers:_={},prune:v=!1,pruneTags:x=!1}){const k=f||await hn({fs:t,gitdir:c,test:!0}),E=await Xi.get({fs:t,gitdir:c}),$=h||k&&await E.get(`branch.${k}.remote`)||"origin",S=l||await E.get(`remote.${$}.url`);if(void 0===S)throw new Tr("remote OR url");const A=d||k&&await E.get(`branch.${k}.merge`)||f||"HEAD";void 0===u&&(u=await E.get("http.corsProxy"));const B=$n.getRemoteHelperFor({url:S}),R=await B.discover({http:i,onAuth:n,onAuthSuccess:s,onAuthFailure:o,corsProxy:u,service:"git-upload-pack",url:S,headers:_,protocolVersion:1}),P=R.auth,j=R.refs;if(0===j.size)return{defaultBranch:null,fetchHead:null,fetchHeadDescription:null};if(null!==g&&!R.capabilities.has("shallow"))throw new Fr("shallow","depth");if(null!==w&&!R.capabilities.has("deepen-since"))throw new Fr("deepen-since","since");if(p.length>0&&!R.capabilities.has("deepen-not"))throw new Fr("deepen-not","exclude");if(!0===m&&!R.capabilities.has("deepen-relative"))throw new Fr("deepen-relative","relative");const{oid:O,fullref:I}=er.resolveAgainstMap({ref:A,map:j});for(const t of j.keys())t===I||"HEAD"===t||t.startsWith("refs/heads/")||y&&t.startsWith("refs/tags/")||j.delete(t);const C=Rn([...R.capabilities],["multi_ack_detailed","no-done","side-band-64k","ofs-delta",`agent=${jn}`]);m&&C.push("deepen-relative");const z=b?[O]:j.values(),D=b?[k]:await er.listRefs({fs:t,gitdir:c,filepath:"refs"});let T=[];for(let i of D)try{i=await er.expand({fs:t,gitdir:c,ref:i});const r=await er.resolve({fs:t,gitdir:c,ref:i});await Bn({fs:t,cache:e,gitdir:c,oid:r})&&T.push(r)}catch(t){}T=[...new Set(T)];const U=await An.read({fs:t,gitdir:c}),N=function({capabilities:t=[],wants:e=[],haves:i=[],shallows:r=[],depth:a=null,since:n=null,exclude:s=[]}){const o=[];e=[...new Set(e)];let c=` ${t.join(" ")}`;for(const t of e)o.push(mn.encode(`want ${t}${c}\n`)),c="";for(const t of r)o.push(mn.encode(`shallow ${t}\n`));null!==a&&o.push(mn.encode(`deepen ${a}\n`)),null!==n&&o.push(mn.encode(`deepen-since ${Math.floor(n.valueOf()/1e3)}\n`));for(const t of s)o.push(mn.encode(`deepen-not ${t}\n`));o.push(mn.flush());for(const t of i)o.push(mn.encode(`have ${t}\n`));return o.push(mn.encode("done\n")),o}({capabilities:C,wants:z,haves:T,shallows:R.capabilities.has("shallow")?[...U]:[],depth:g,since:w,exclude:p}),M=Buffer.from(await gn(N)),F=await B.connect({http:i,onProgress:r,corsProxy:u,service:"git-upload-pack",url:S,auth:P,body:[M],headers:_}),H=await async function(t){const{packetlines:e,packfile:i,progress:r}=zn.demux(t),a=[],n=[],s=[];let o=!1,c=!1;return new Promise((f,d)=>{un(e,e=>{const h=e.toString("utf8").trim();if(h.startsWith("shallow")){const t=h.slice(-41).trim();40!==t.length&&d(new Ri(t)),a.push(t)}else if(h.startsWith("unshallow")){const t=h.slice(-41).trim();40!==t.length&&d(new Ri(t)),n.push(t)}else if(h.startsWith("ACK")){const[,t,e]=h.split(" ");s.push({oid:t,status:e}),e||(c=!0)}else h.startsWith("NAK")?(o=!0,c=!0):(c=!0,o=!0);c&&(t.error?d(t.error):f({shallows:a,unshallows:n,acks:s,nak:o,packfile:i,progress:r}))}).finally(()=>{c||(t.error?d(t.error):f({shallows:a,unshallows:n,acks:s,nak:o,packfile:i,progress:r}))})})}(F.body);F.headers&&(H.headers=F.headers);for(const i of H.shallows)if(!U.has(i))try{const{object:r}=await _r({fs:t,cache:e,gitdir:c,oid:i}),a=new ea(r),n=await Promise.all(a.headers().parent.map(i=>Bn({fs:t,cache:e,gitdir:c,oid:i})));0===n.length||n.every(t=>t)||U.add(i)}catch(t){U.add(i)}for(const t of H.unshallows)U.delete(t);if(await An.write({fs:t,gitdir:c,oids:U}),b){const e=new Map([[I,O]]),i=new Map;let r=10,a=I;for(;r--;){const t=R.symrefs.get(a);if(void 0===t)break;i.set(a,t),a=t}const n=j.get(a);n&&e.set(a,n);const{pruned:s}=await er.updateRemoteRefs({fs:t,gitdir:c,remote:$,refs:e,symrefs:i,tags:y,prune:v});v&&(H.pruned=s)}else{const{pruned:e}=await er.updateRemoteRefs({fs:t,gitdir:c,remote:$,refs:j,symrefs:R.symrefs,tags:y,prune:v,pruneTags:x});v&&(H.pruned=e)}if(H.HEAD=R.symrefs.get("HEAD"),void 0===H.HEAD){const{oid:t}=er.resolveAgainstMap({ref:"HEAD",map:j});for(const[e,i]of j.entries())if("HEAD"!==e&&i===t){H.HEAD=e;break}}const q=I.startsWith("refs/tags")?"tag":"branch";if(H.FETCH_HEAD={oid:O,description:`${q} '${dn(I)}' of ${S}`},r||a){un(Cn(H.progress),async t=>{if(a&&await a(t),r){const e=t.match(/([^:]*).*\((\d+?)\/(\d+?)\)/);e&&await r({phase:e[1].trim(),loaded:parseInt(e[2],10),total:parseInt(e[3],10)})}})}const L=Buffer.from(await gn(H.packfile));if(F.body.error)throw F.body.error;const W=L.slice(-20).toString("hex"),G={defaultBranch:H.HEAD,fetchHead:H.FETCH_HEAD.oid,fetchHeadDescription:H.FETCH_HEAD.description};if(H.headers&&(G.headers=H.headers),v&&(G.pruned=H.pruned),""!==W&&"5041434b0000000200000000"!==L.slice(0,12).toString("hex")){G.packfile=`objects/pack/pack-${W}.pack`;const i=zi(c,G.packfile);await t.write(i,L);const a=i=>_r({fs:t,cache:e,gitdir:c,oid:i}),n=await mr.fromPack({pack:L,getExternalRefDelta:a,onProgress:r});await t.write(i.replace(/\.pack$/,".idx"),await n.toBuffer())}return G}async function Tn({fs:t,bare:e=!1,dir:i,gitdir:r=(e?i:zi(i,".git")),defaultBranch:a="master"}){if(await t.exists(r+"/config"))return;let n=["hooks","info","objects/info","objects/pack","refs/heads","refs/tags"];n=n.map(t=>r+"/"+t);for(const e of n)await t.mkdir(e);await t.write(r+"/config",`[core]\n\trepositoryformatversion = 0\n\tfilemode = false\n\tbare = ${e}\n`+(e?"":"\tlogallrefupdates = true\n")+"\tsymlinks = false\n\tignorecase = true\n"),await t.write(r+"/HEAD",`ref: refs/heads/${a}\n`)}async function Un({fs:t,http:e,onProgress:i,onMessage:r,onAuth:a,onAuthSuccess:n,onAuthFailure:s,onPostCheckout:o,dir:c,gitdir:f=zi(c,".git"),url:d,corsProxy:h,ref:l,remote:u="origin",depth:g,since:w,exclude:p=[],relative:m=!1,singleBranch:y=!1,noCheckout:b=!1,noTags:_=!1,headers:v={},cache:x={},nonBlocking:k=!1,batchSize:E=100}){try{ma("fs",t),ma("http",e),ma("gitdir",f),b||ma("dir",c),ma("url",d);const $=new pa(t),S=await ya({fsp:$,dotgit:f});return await async function({fs:t,cache:e,http:i,onProgress:r,onMessage:a,onAuth:n,onAuthSuccess:s,onAuthFailure:o,onPostCheckout:c,dir:f,gitdir:d,url:h,corsProxy:l,ref:u,remote:g,depth:w,since:p,exclude:m,relative:y,singleBranch:b,noCheckout:_,noTags:v,headers:x,nonBlocking:k,batchSize:E=100}){try{if(await Tn({fs:t,gitdir:d}),await qa({fs:t,gitdir:d,remote:g,url:h,force:!1}),l){const e=await Xi.get({fs:t,gitdir:d});await e.set("http.corsProxy",l),await Xi.save({fs:t,gitdir:d,config:e})}const{defaultBranch:$,fetchHead:S}=await Dn({fs:t,cache:e,http:i,onProgress:r,onMessage:a,onAuth:n,onAuthSuccess:s,onAuthFailure:o,gitdir:d,ref:u,remote:g,corsProxy:l,depth:w,since:p,exclude:m,relative:y,singleBranch:b,headers:x,tags:!v});if(null===S)return;u=(u=u||$).replace("refs/heads/",""),await Ka({fs:t,cache:e,onProgress:r,onPostCheckout:c,dir:f,gitdir:d,ref:u,remote:g,noCheckout:_,nonBlocking:k,batchSize:E})}catch(e){throw await t.rmdir(d,{recursive:!0,maxRetries:10}).catch(()=>{}),e}}({fs:$,cache:x,http:e,onProgress:i,onMessage:r,onAuth:a,onAuthSuccess:n,onAuthFailure:s,onPostCheckout:o,dir:c,gitdir:S,url:d,corsProxy:h,ref:l,remote:u,depth:g,since:w,exclude:p,relative:m,singleBranch:y,noCheckout:b,noTags:_,headers:v,nonBlocking:k,batchSize:E})}catch(t){throw t.caller="git.clone",t}}async function Nn({fs:t,onSign:e,dir:i,gitdir:r=zi(i,".git"),message:a,author:n,committer:s,signingKey:o,amend:c=!1,dryRun:f=!1,noUpdateBranch:d=!1,ref:h,parent:l,tree:u,cache:g={}}){try{ma("fs",t),c||ma("message",a),o&&ma("onSign",e);const i=new pa(t),w=await ya({fsp:i,dotgit:r});return await Ca({fs:i,cache:g,onSign:e,gitdir:w,message:a,author:n,committer:s,signingKey:o,amend:c,dryRun:f,noUpdateBranch:d,ref:h,parent:l,tree:u})}catch(t){throw t.caller="git.commit",t}}async function Mn({fs:t,dir:e,gitdir:i=zi(e,".git"),fullname:r=!1,test:a=!1}){try{ma("fs",t),ma("gitdir",i);const e=new pa(t),n=await ya({fsp:e,dotgit:i});return await hn({fs:e,gitdir:n,fullname:r,test:a})}catch(t){throw t.caller="git.currentBranch",t}}async function Fn({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r}){try{ma("fs",t),ma("ref",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return await async function({fs:t,gitdir:e,ref:i}){if(i=i.startsWith("refs/heads/")?i:`refs/heads/${i}`,!await er.exists({fs:t,gitdir:e,ref:i}))throw new Ai(i);const r=await er.expand({fs:t,gitdir:e,ref:i});if(r===await hn({fs:t,gitdir:e,fullname:!0})){const i=await er.resolve({fs:t,gitdir:e,ref:r});await er.writeRef({fs:t,gitdir:e,ref:"HEAD",value:i})}await er.deleteRef({fs:t,gitdir:e,ref:r});const a=dn(i),n=await Xi.get({fs:t,gitdir:e});await n.deleteSection("branch",a),await Xi.save({fs:t,gitdir:e,config:n})}({fs:e,gitdir:a,ref:r})}catch(t){throw t.caller="git.deleteBranch",t}}async function Hn({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r}){try{ma("fs",t),ma("ref",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});await er.deleteRef({fs:e,gitdir:a,ref:r})}catch(t){throw t.caller="git.deleteRef",t}}async function qn({fs:t,dir:e,gitdir:i=zi(e,".git"),remote:r}){try{ma("fs",t),ma("remote",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return await async function({fs:t,gitdir:e,remote:i}){const r=await Xi.get({fs:t,gitdir:e});await r.deleteSection("remote",i),await Xi.save({fs:t,gitdir:e,config:r})}({fs:e,gitdir:a,remote:r})}catch(t){throw t.caller="git.deleteRemote",t}}async function Ln({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r}){try{ma("fs",t),ma("ref",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return await async function({fs:t,gitdir:e,ref:i}){i=i.startsWith("refs/tags/")?i:`refs/tags/${i}`,await er.deleteRef({fs:t,gitdir:e,ref:i})}({fs:e,gitdir:a,ref:r})}catch(t){throw t.caller="git.deleteTag",t}}async function Wn({fs:t,cache:e,gitdir:i,oid:r}){const a=await async function({fs:t,gitdir:e,oid:i}){const r=i.slice(0,2);return(await t.readdir(`${e}/objects/${r}`)).map(t=>`${r}${t}`).filter(t=>t.startsWith(i))}({fs:t,gitdir:i,oid:r}),n=await async function({fs:t,cache:e,gitdir:i,oid:r,getExternalRefDelta:a}){const n=[];let s=await t.readdir(zi(i,"objects/pack"));s=s.filter(t=>t.endsWith(".idx"));for(const o of s){const s=`${i}/objects/pack/${o}`,c=await br({fs:t,cache:e,filename:s,getExternalRefDelta:a});if(c.error)throw new ri(c.error);for(const t of c.offsets.keys())t.startsWith(r)&&n.push(t)}return n}({fs:t,cache:e,gitdir:i,oid:r,getExternalRefDelta:r=>_r({fs:t,cache:e,gitdir:i,oid:r})});for(const t of n)-1===a.indexOf(t)&&a.push(t);if(1===a.length)return a[0];if(a.length>1)throw new xr("oids",r,a);throw new Ai(`an object matching "${r}"`)}async function Gn({fs:t,dir:e,gitdir:i=zi(e,".git"),oid:r,cache:a={}}){try{ma("fs",t),ma("gitdir",i),ma("oid",r);const e=new pa(t),n=await ya({fsp:e,dotgit:i});return await Wn({fs:e,cache:a,gitdir:n,oid:r})}catch(t){throw t.caller="git.expandOid",t}}async function Zn({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r}){try{ma("fs",t),ma("gitdir",i),ma("ref",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return await er.expand({fs:e,gitdir:a,ref:r})}catch(t){throw t.caller="git.expandRef",t}}async function Kn({fs:t,cache:e,gitdir:i,oids:r}){const a={},n=r.length;let s=r.map((t,e)=>({index:e,oid:t}));for(;s.length;){const r=new Set;for(const{oid:t,index:e}of s)a[t]||(a[t]=new Set),a[t].add(e),a[t].size===n&&r.add(t);if(r.size>0)return[...r];const o=new Map;for(const{oid:r,index:n}of s)try{const{object:s}=await _r({fs:t,cache:e,gitdir:i,oid:r}),c=ea.from(s),{parent:f}=c.parseHeaders();for(const t of f)a[t]&&a[t].has(n)||o.set(t+":"+n,{oid:t,index:n})}catch(t){}s=Array.from(o.values())}return[]}async function Vn({fs:t,cache:e,dir:i,gitdir:r,ours:a,theirs:n,fastForward:s=!0,fastForwardOnly:o=!1,dryRun:c=!1,noUpdateBranch:f=!1,abortOnConflict:d=!0,message:h,author:l,committer:u,signingKey:g,onSign:w,mergeDriver:p,allowUnrelatedHistories:m=!1}){void 0===a&&(a=await hn({fs:t,gitdir:r,fullname:!0})),a=await er.expand({fs:t,gitdir:r,ref:a}),n=await er.expand({fs:t,gitdir:r,ref:n});const y=await er.resolve({fs:t,gitdir:r,ref:a}),b=await er.resolve({fs:t,gitdir:r,ref:n}),_=await Kn({fs:t,cache:e,gitdir:r,oids:[y,b]});if(1!==_.length){if(0!==_.length||!m)throw new Cr;_.push("4b825dc642cb6eb9a060e54bf8d69288fbee4904")}const v=_[0];if(v===b)return{oid:y,alreadyMerged:!0};if(s&&v===y)return c||f||await er.writeRef({fs:t,gitdir:r,ref:a,value:b}),{oid:b,fastForward:!0};{if(o)throw new Br;const s=await _i.acquire({fs:t,gitdir:r,cache:e,allowUnmerged:!1},async s=>Qa({fs:t,cache:e,dir:i,gitdir:r,index:s,ourOid:y,theirOid:b,baseOid:v,ourName:dn(a),baseName:"base",theirName:dn(n),dryRun:c,abortOnConflict:d,mergeDriver:p}));if(s instanceof zr)throw s;h||(h=`Merge branch '${dn(n)}' into ${dn(a)}`);return{oid:await Ca({fs:t,cache:e,gitdir:r,message:h,ref:a,tree:s,parent:[y,b],author:l,committer:u,signingKey:g,onSign:w,dryRun:c,noUpdateBranch:f}),tree:s,mergeCommit:!0}}}async function Xn({fs:t,cache:e,http:i,onProgress:r,onMessage:a,onAuth:n,onAuthSuccess:s,onAuthFailure:o,dir:c,gitdir:f,ref:d,url:h,remote:l,remoteRef:u,prune:g,pruneTags:w,fastForward:p,fastForwardOnly:m,corsProxy:y,singleBranch:b,headers:_,author:v,committer:x,signingKey:k}){try{if(!d){const e=await hn({fs:t,gitdir:f});if(!e)throw new Tr("ref");d=e}const{fetchHead:E,fetchHeadDescription:$}=await Dn({fs:t,cache:e,http:i,onProgress:r,onMessage:a,onAuth:n,onAuthSuccess:s,onAuthFailure:o,gitdir:f,corsProxy:y,ref:d,url:h,remote:l,remoteRef:u,singleBranch:b,headers:_,prune:g,pruneTags:w});await Vn({fs:t,cache:e,gitdir:f,ours:d,theirs:E,fastForward:p,fastForwardOnly:m,message:`Merge ${$}`,author:v,committer:x,signingKey:k,dryRun:!1,noUpdateBranch:!1}),await Ka({fs:t,cache:e,onProgress:r,dir:c,gitdir:f,ref:d,remote:l,noCheckout:!1})}catch(t){throw t.caller="git.pull",t}}async function Yn({fs:t,http:e,onProgress:i,onMessage:r,onAuth:a,onAuthSuccess:n,onAuthFailure:s,dir:o,gitdir:c=zi(o,".git"),ref:f,url:d,remote:h,remoteRef:l,corsProxy:u,singleBranch:g,headers:w={},cache:p={}}){try{ma("fs",t),ma("http",e),ma("gitdir",c);const m={name:"",email:"",timestamp:Date.now(),timezoneOffset:0},y=new pa(t),b=await ya({fsp:y,dotgit:c});return await Xn({fs:y,cache:p,http:e,onProgress:i,onMessage:r,onAuth:a,onAuthSuccess:n,onAuthFailure:s,dir:o,gitdir:b,ref:f,url:d,remote:h,remoteRef:l,fastForwardOnly:!0,corsProxy:u,singleBranch:g,headers:w,author:m,committer:m})}catch(t){throw t.caller="git.fastForward",t}}async function Jn({fs:t,http:e,onProgress:i,onMessage:r,onAuth:a,onAuthSuccess:n,onAuthFailure:s,dir:o,gitdir:c=zi(o,".git"),ref:f,remote:d,remoteRef:h,url:l,corsProxy:u,depth:g=null,since:w=null,exclude:p=[],relative:m=!1,tags:y=!1,singleBranch:b=!1,headers:_={},prune:v=!1,pruneTags:x=!1,cache:k={}}){try{ma("fs",t),ma("http",e),ma("gitdir",c);const o=new pa(t),E=await ya({fsp:o,dotgit:c});return await Dn({fs:o,cache:k,http:e,onProgress:i,onMessage:r,onAuth:a,onAuthSuccess:n,onAuthFailure:s,gitdir:E,ref:f,remote:d,remoteRef:h,url:l,corsProxy:u,depth:g,since:w,exclude:p,relative:m,tags:y,singleBranch:b,headers:_,prune:v,pruneTags:x})}catch(t){throw t.caller="git.fetch",t}}async function Qn({fs:t,dir:e,gitdir:i=zi(e,".git"),oids:r,cache:a={}}){try{ma("fs",t),ma("gitdir",i),ma("oids",r);const e=new pa(t),n=await ya({fsp:e,dotgit:i});return await Kn({fs:e,cache:a,gitdir:n,oids:r})}catch(t){throw t.caller="git.findMergeBase",t}}async function ts({fs:t,filepath:e}){if(await t.exists(zi(e,".git")))return e;{const i=xi(e);if(i===e)throw new Ai(`git root for ${e}`);return ts({fs:t,filepath:i})}}async function es({fs:t,filepath:e}){try{return ma("fs",t),ma("filepath",e),await ts({fs:new pa(t),filepath:e})}catch(t){throw t.caller="git.findRoot",t}}async function is({fs:t,dir:e,gitdir:i=zi(e,".git"),path:r}){try{ma("fs",t),ma("gitdir",i),ma("path",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return await Ba({fs:e,gitdir:a,path:r})}catch(t){throw t.caller="git.getConfig",t}}async function rs({fs:t,dir:e,gitdir:i=zi(e,".git"),path:r}){try{ma("fs",t),ma("gitdir",i),ma("path",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return await async function({fs:t,gitdir:e,path:i}){return(await Xi.get({fs:t,gitdir:e})).getall(i)}({fs:e,gitdir:a,path:r})}catch(t){throw t.caller="git.getConfigAll",t}}async function as({http:t,onAuth:e,onAuthSuccess:i,onAuthFailure:r,corsProxy:a,url:n,headers:s={},forPush:o=!1}){try{ma("http",t),ma("url",n);const c=$n.getRemoteHelperFor({url:n}),f=await c.discover({http:t,onAuth:e,onAuthSuccess:i,onAuthFailure:r,corsProxy:a,service:o?"git-receive-pack":"git-upload-pack",url:n,headers:s,protocolVersion:1}),d={capabilities:[...f.capabilities]};for(const[t,e]of f.refs){const i=t.split("/"),r=i.pop();let a=d;for(const t of i)a[t]=a[t]||{},a=a[t];a[r]=e}for(const[t,e]of f.symrefs){const i=t.split("/"),r=i.pop();let a=d;for(const t of i)a[t]=a[t]||{},a=a[t];a[r]=e}return d}catch(t){throw t.caller="git.getRemoteInfo",t}}function ns(t,e,i,r){const a=[];for(const[n,s]of t.refs){if(e&&!n.startsWith(e))continue;if(n.endsWith("^{}")){if(r){const t=n.replace("^{}",""),e=a[a.length-1],i=e.ref===t?e:a.find(e=>e.ref===t);if(void 0===i)throw new Error("I did not expect this to happen");i.peeled=s}continue}const o={ref:n,oid:s};i&&t.symrefs.has(n)&&(o.target=t.symrefs.get(n)),a.push(o)}return a}async function ss({http:t,onAuth:e,onAuthSuccess:i,onAuthFailure:r,corsProxy:a,url:n,headers:s={},forPush:o=!1,protocolVersion:c=2}){try{ma("http",t),ma("url",n);const f=$n.getRemoteHelperFor({url:n}),d=await f.discover({http:t,onAuth:e,onAuthSuccess:i,onAuthFailure:r,corsProxy:a,service:o?"git-receive-pack":"git-upload-pack",url:n,headers:s,protocolVersion:c});if(2===d.protocolVersion)return{protocolVersion:d.protocolVersion,capabilities:d.capabilities2};const h={};for(const t of d.capabilities){const[e,i]=t.split("=");h[e]=i||!0}return{protocolVersion:1,capabilities:h,refs:ns(d,void 0,!0,!0)}}catch(t){throw t.caller="git.getRemoteInfo2",t}}async function os({object:t}){try{ma("object",t),"string"==typeof t?t=Buffer.from(t,"utf8"):t instanceof Uint8Array||(t=new Uint8Array(t));const e="blob",{oid:i,object:r}=await async function({type:t,object:e,format:i="content",oid:r}){return"deflated"!==i&&("wrapped"!==i&&(e=or.wrap({type:t,object:e})),r=await ui(e)),{oid:r,object:e}}({type:e,format:"content",object:t});return{oid:i,type:e,object:r,format:"wrapped"}}catch(t){throw t.caller="git.hashBlob",t}}async function cs({fs:t,onProgress:e,dir:i,gitdir:r=zi(i,".git"),filepath:a,cache:n={}}){try{ma("fs",t),ma("dir",i),ma("gitdir",i),ma("filepath",a);const s=new pa(t),o=await ya({fsp:s,dotgit:r});return await async function({fs:t,cache:e,onProgress:i,dir:r,gitdir:a,filepath:n}){try{n=zi(r,n);const s=await t.read(n),o=i=>_r({fs:t,cache:e,gitdir:a,oid:i}),c=await mr.fromPack({pack:s,getExternalRefDelta:o,onProgress:i});return await t.write(n.replace(/\.pack$/,".idx"),await c.toBuffer()),{oids:[...c.hashes]}}catch(t){throw t.caller="git.indexPack",t}}({fs:s,cache:n,onProgress:e,dir:i,gitdir:o,filepath:a})}catch(t){throw t.caller="git.indexPack",t}}async function fs({fs:t,bare:e=!1,dir:i,gitdir:r=(e?i:zi(i,".git")),defaultBranch:a="master"}){try{ma("fs",t),ma("gitdir",r),e||ma("dir",i);const n=new pa(t),s=await ya({fsp:n,dotgit:r});return await Tn({fs:n,bare:e,dir:i,gitdir:s,defaultBranch:a})}catch(t){throw t.caller="git.init",t}}async function ds({fs:t,cache:e,gitdir:i,oid:r,ancestor:a,depth:n}){const s=await An.read({fs:t,gitdir:i});if(!r)throw new Tr("oid");if(!a)throw new Tr("ancestor");if(r===a)return!1;const o=[r],c=new Set;let f=0;for(;o.length;){if(f++===n)throw new Ir(n);const r=o.shift(),{type:d,object:h}=await _r({fs:t,cache:e,gitdir:i,oid:r});if("commit"!==d)throw new Bi(r,d,"commit");const l=ea.from(h).parse();for(const t of l.parent)if(t===a)return!0;if(!s.has(r))for(const t of l.parent)c.has(t)||(o.push(t),c.add(t))}return!1}async function hs({fs:t,dir:e,gitdir:i=zi(e,".git"),oid:r,ancestor:a,depth:n=-1,cache:s={}}){try{ma("fs",t),ma("gitdir",i),ma("oid",r),ma("ancestor",a);const e=new pa(t),o=await ya({fsp:e,dotgit:i});return await ds({fs:e,cache:s,gitdir:o,oid:r,ancestor:a,depth:n})}catch(t){throw t.caller="git.isDescendent",t}}async function ls({fs:t,dir:e,gitdir:i=zi(e,".git"),filepath:r}){try{ma("fs",t),ma("dir",e),ma("gitdir",i),ma("filepath",r);const a=new pa(t),n=await ya({fsp:a,dotgit:i});return va.isIgnored({fs:a,dir:e,gitdir:n,filepath:r})}catch(t){throw t.caller="git.isIgnored",t}}async function us({fs:t,dir:e,gitdir:i=zi(e,".git"),remote:r}){try{ma("fs",t),ma("gitdir",i);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return er.listBranches({fs:e,gitdir:a,remote:r})}catch(t){throw t.caller="git.listBranches",t}}async function gs({fs:t,gitdir:e,ref:i,cache:r}){if(i){const a=await er.resolve({gitdir:e,fs:t,ref:i}),n=[];return await ws({fs:t,cache:r,gitdir:e,oid:a,filenames:n,prefix:""}),n}return _i.acquire({fs:t,gitdir:e,cache:r},async function(t){return t.entries.map(t=>t.path)})}async function ws({fs:t,cache:e,gitdir:i,oid:r,filenames:a,prefix:n}){const{tree:s}=await Ua({fs:t,cache:e,gitdir:i,oid:r});for(const r of s)"tree"===r.type?await ws({fs:t,cache:e,gitdir:i,oid:r.oid,filenames:a,prefix:zi(n,r.path)}):a.push(zi(n,r.path))}async function ps({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r,cache:a={}}){try{ma("fs",t),ma("gitdir",i);const e=new pa(t),n=await ya({fsp:e,dotgit:i});return await gs({fs:e,cache:a,gitdir:n,ref:r})}catch(t){throw t.caller="git.listFiles",t}}async function ms({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r="refs/notes/commits",cache:a={}}){try{ma("fs",t),ma("gitdir",i),ma("ref",r);const e=new pa(t),n=await ya({fsp:e,dotgit:i});return await async function({fs:t,cache:e,gitdir:i,ref:r}){let a;try{a=await er.resolve({gitdir:i,fs:t,ref:r})}catch(t){if(t instanceof Ai)return[]}return(await Ua({fs:t,cache:e,gitdir:i,oid:a})).tree.map(t=>({target:t.path,note:t.oid}))}({fs:e,cache:a,gitdir:n,ref:r})}catch(t){throw t.caller="git.listNotes",t}}async function ys({fs:t,dir:e,gitdir:i=zi(e,".git"),filepath:r}){try{ma("fs",t),ma("gitdir",i);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return er.listRefs({fs:e,gitdir:a,filepath:r})}catch(t){throw t.caller="git.listRefs",t}}async function bs({fs:t,dir:e,gitdir:i=zi(e,".git")}){try{ma("fs",t),ma("gitdir",i);const e=new pa(t),r=await ya({fsp:e,dotgit:i});return await async function({fs:t,gitdir:e}){const i=await Xi.get({fs:t,gitdir:e}),r=await i.getSubsections("remote");return Promise.all(r.map(async t=>({remote:t,url:await i.get(`remote.${t}.url`)})))}({fs:e,gitdir:r})}catch(t){throw t.caller="git.listRemotes",t}}async function _s({http:t,onAuth:e,onAuthSuccess:i,onAuthFailure:r,corsProxy:a,url:n,headers:s={},forPush:o=!1,protocolVersion:c=2,prefix:f,symrefs:d,peelTags:h}){try{ma("http",t),ma("url",n);const l=await En.discover({http:t,onAuth:e,onAuthSuccess:i,onAuthFailure:r,corsProxy:a,service:o?"git-receive-pack":"git-upload-pack",url:n,headers:s,protocolVersion:c});if(1===l.protocolVersion)return ns(l,f,d,h);const u=await async function({prefix:t,symrefs:e,peelTags:i}){const r=[];return r.push(mn.encode("command=ls-refs\n")),r.push(mn.encode(`agent=${jn}\n`)),(i||e||t)&&r.push(mn.delim()),i&&r.push(mn.encode("peel")),e&&r.push(mn.encode("symrefs")),t&&r.push(mn.encode(`ref-prefix ${t}`)),r.push(mn.flush()),r}({prefix:f,symrefs:d,peelTags:h});return async function(t){const e=mn.streamReader(t),i=[];let r;for(;r=await e(),!0!==r;){if(null===r)continue;r=r.toString("utf8").replace(/\n$/,"");const[t,e,...a]=r.split(" "),n={ref:e,oid:t};for(const t of a){const[e,i]=t.split(":");"symref-target"===e?n.target=i:"peeled"===e&&(n.peeled=i)}i.push(n)}return i}((await En.connect({http:t,auth:l.auth,headers:s,corsProxy:a,service:o?"git-receive-pack":"git-upload-pack",url:n,body:u})).body)}catch(t){throw t.caller="git.listServerRefs",t}}async function vs({fs:t,dir:e,gitdir:i=zi(e,".git")}){try{ma("fs",t),ma("gitdir",i);const e=new pa(t),r=await ya({fsp:e,dotgit:i});return er.listTags({fs:e,gitdir:r})}catch(t){throw t.caller="git.listTags",t}}function xs(t,e){return t.committer.timestamp-e.committer.timestamp}async function ks({fs:t,cache:e,gitdir:i,oid:r,fileId:a}){if("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"===a)return;const n=r;let s;const o=await ia({fs:t,cache:e,gitdir:i,oid:r}),c=o.tree;return a===o.oid?s=o.path:(s=await Es({fs:t,cache:e,gitdir:i,tree:c,fileId:a,oid:n}),Array.isArray(s)&&(0===s.length?s=void 0:1===s.length&&(s=s[0]))),s}async function Es({fs:t,cache:e,gitdir:i,tree:r,fileId:a,oid:n,filepaths:s=[],parentPath:o=""}){const c=r.entries().map(function(r){let c;return r.oid===a?(c=zi(o,r.path),s.push(c)):"tree"===r.type&&(c=_r({fs:t,cache:e,gitdir:i,oid:r.oid}).then(function({object:c}){return Es({fs:t,cache:e,gitdir:i,tree:sr.from(c),fileId:a,oid:n,filepaths:s,parentPath:zi(o,r.path)})})),c});return await Promise.all(c),s}async function $s({fs:t,dir:e,gitdir:i=zi(e,".git"),filepath:r,ref:a="HEAD",depth:n,since:s,force:o,follow:c,cache:f={}}){try{ma("fs",t),ma("gitdir",i),ma("ref",a);const e=new pa(t),d=await ya({fsp:e,dotgit:i});return await async function({fs:t,cache:e,gitdir:i,filepath:r,ref:a,depth:n,since:s,force:o,follow:c}){const f=void 0===s?void 0:Math.floor(s.valueOf()/1e3),d=[],h=await An.read({fs:t,gitdir:i}),l=await er.resolve({fs:t,gitdir:i,ref:a}),u=[await Ia({fs:t,cache:e,gitdir:i,oid:l})];let g,w,p;function m(t){p&&r&&d.push(t)}for(;u.length>0;){const a=u.pop();if(void 0!==f&&a.commit.committer.timestamp<=f)break;if(r){let n;try{n=await Da({fs:t,cache:e,gitdir:i,oid:a.commit.tree,filepath:r}),w&&g!==n&&d.push(w),g=n,w=a,p=!0}catch(n){if(!(n instanceof Ai))throw n;{let s=c&&g;if(s&&(s=await ks({fs:t,cache:e,gitdir:i,oid:a.commit.tree,fileId:g}),s))if(Array.isArray(s)){if(w){const a=await ks({fs:t,cache:e,gitdir:i,oid:w.commit.tree,fileId:g});if(Array.isArray(a)){if(s=s.filter(t=>-1===a.indexOf(t)),1!==s.length){s=!1,w&&d.push(w);break}s=s[0],r=s,w&&d.push(w)}}}else r=s,w&&d.push(w);if(!s){if(p&&g&&(d.push(w),!o))break;if(!o&&!c)throw n}w=a,p=!1}}}else d.push(a);if(void 0!==n&&d.length===n){m(a);break}if(!h.has(a.oid))for(const r of a.commit.parent){const a=await Ia({fs:t,cache:e,gitdir:i,oid:r});u.map(t=>t.oid).includes(a.oid)||u.push(a)}0===u.length&&m(a),u.sort((t,e)=>xs(t.commit,e.commit))}return d}({fs:e,cache:f,gitdir:d,filepath:r,ref:a,depth:n,since:s,force:o,follow:c})}catch(t){throw t.caller="git.log",t}}async function Ss({fs:t,onSign:e,dir:i,gitdir:r=zi(i,".git"),ours:a,theirs:n,fastForward:s=!0,fastForwardOnly:o=!1,dryRun:c=!1,noUpdateBranch:f=!1,abortOnConflict:d=!0,message:h,author:l,committer:u,signingKey:g,cache:w={},mergeDriver:p,allowUnrelatedHistories:m=!1}){try{ma("fs",t),g&&ma("onSign",e);const y=new pa(t),b=await ya({fsp:y,dotgit:r}),_=await Pa({fs:y,gitdir:b,author:l});if(!(_||o&&s))throw new Dr("author");const v=await ja({fs:y,gitdir:b,author:_,committer:u});if(!(v||o&&s))throw new Dr("committer");return await Vn({fs:y,cache:w,dir:i,gitdir:b,ours:a,theirs:n,fastForward:s,fastForwardOnly:o,dryRun:c,noUpdateBranch:f,abortOnConflict:d,message:h,author:_,committer:v,signingKey:g,onSign:e,mergeDriver:p,allowUnrelatedHistories:m})}catch(t){throw t.caller="git.merge",t}}const As={commit:16,tree:32,blob:48,tag:64,ofs_delta:96,ref_delta:112};async function Bs({fs:t,cache:e,dir:i,gitdir:r=zi(i,".git"),oids:a}){const n=new _,s=[];function o(t,e){const i=Buffer.from(t,e);s.push(i),n.update(i)}async function c({stype:t,object:e}){const i=As[t];let r=e.length,a=r>15?128:0;const n=15&r;r>>>=4;let s=(a|i|n).toString(16);for(o(s,"hex");a;)a=r>127?128:0,s=a|127&r,o(pn(2,s),"hex"),r>>>=7;o(Buffer.from(await ka(e)))}o("PACK"),o("00000002","hex"),o(pn(8,a.length),"hex");for(const i of a){const{type:a,object:n}=await _r({fs:t,cache:e,gitdir:r,oid:i});await c({write:o,object:n,stype:a})}const f=n.digest();return s.push(f),s}async function Rs({fs:t,dir:e,gitdir:i=zi(e,".git"),oids:r,write:a=!1,cache:n={}}){try{ma("fs",t),ma("gitdir",i),ma("oids",r);const e=new pa(t),s=await ya({fsp:e,dotgit:i});return await async function({fs:t,cache:e,gitdir:i,oids:r,write:a}){const n=await Bs({fs:t,cache:e,gitdir:i,oids:r}),s=Buffer.from(await gn(n)),o=`pack-${s.slice(-20).toString("hex")}.pack`;return a?(await t.write(zi(i,`objects/pack/${o}`),s),{filename:o}):{filename:o,packfile:new Uint8Array(s)}}({fs:e,cache:n,gitdir:s,oids:r,write:a})}catch(t){throw t.caller="git.packObjects",t}}async function Ps({fs:t,http:e,onProgress:i,onMessage:r,onAuth:a,onAuthSuccess:n,onAuthFailure:s,dir:o,gitdir:c=zi(o,".git"),ref:f,url:d,remote:h,remoteRef:l,prune:u=!1,pruneTags:g=!1,fastForward:w=!0,fastForwardOnly:p=!1,corsProxy:m,singleBranch:y,headers:b={},author:_,committer:v,signingKey:x,cache:k={}}){try{ma("fs",t),ma("gitdir",c);const E=new pa(t),$=await ya({fsp:E,dotgit:c}),S=await Pa({fs:E,gitdir:$,author:_});if(!S)throw new Dr("author");const A=await ja({fs:E,gitdir:$,author:S,committer:v});if(!A)throw new Dr("committer");return await Xn({fs:E,cache:k,http:e,onProgress:i,onMessage:r,onAuth:a,onAuthSuccess:n,onAuthFailure:s,dir:o,gitdir:$,ref:f,url:d,remote:h,remoteRef:l,fastForward:w,fastForwardOnly:p,corsProxy:m,singleBranch:y,headers:b,author:S,committer:A,signingKey:x,prune:u,pruneTags:g})}catch(t){throw t.caller="git.pull",t}}async function js({fs:t,cache:e,dir:i,gitdir:r=zi(i,".git"),oids:a}){const n=new Set;async function s(i){if(n.has(i))return;n.add(i);const{type:a,object:o}=await _r({fs:t,cache:e,gitdir:r,oid:i});if("tag"===a){const t=Qr.from(o).headers().object;await s(t)}else if("commit"===a){const t=ea.from(o).headers().tree;await s(t)}else if("tree"===a){const t=sr.from(o);for(const e of t)"blob"===e.type&&n.add(e.oid),"tree"===e.type&&await s(e.oid)}}for(const t of a)await s(t);return n}async function Os({fs:t,cache:e,http:i,onProgress:r,onMessage:a,onAuth:n,onAuthSuccess:s,onAuthFailure:o,onPrePush:c,gitdir:f,ref:d,remoteRef:h,remote:l,url:u,force:g=!1,delete:w=!1,corsProxy:p,headers:m={}}){const y=d||await hn({fs:t,gitdir:f});if(void 0===y)throw new Tr("ref");const b=await Xi.get({fs:t,gitdir:f});l=l||await b.get(`branch.${y}.pushRemote`)||await b.get("remote.pushDefault")||await b.get(`branch.${y}.remote`)||"origin";const _=u||await b.get(`remote.${l}.pushurl`)||await b.get(`remote.${l}.url`);if(void 0===_)throw new Tr("remote OR url");const v=h||await b.get(`branch.${y}.merge`);if(void 0===_)throw new Tr("remoteRef");void 0===p&&(p=await b.get("http.corsProxy"));const x=await er.expand({fs:t,gitdir:f,ref:y}),k=w?"0000000000000000000000000000000000000000":await er.resolve({fs:t,gitdir:f,ref:x}),E=$n.getRemoteHelperFor({url:_}),$=await E.discover({http:i,onAuth:n,onAuthSuccess:s,onAuthFailure:o,corsProxy:p,service:"git-receive-pack",url:_,headers:m,protocolVersion:1}),S=$.auth;let A;if(v)try{A=await er.expandAgainstMap({ref:v,map:$.refs})}catch(t){if(!(t instanceof Ai))throw t;A=v.startsWith("refs/")?v:`refs/heads/${v}`}else A=x;const B=$.refs.get(A)||"0000000000000000000000000000000000000000";if(c){if(!await c({remote:l,url:_,localRef:{ref:w?"(delete)":x,oid:k},remoteRef:{ref:A,oid:B}}))throw new Wr}const R=!$.capabilities.has("no-thin");let P=new Set;if(!w){const i=[...$.refs.values()];let r=new Set;if("0000000000000000000000000000000000000000"!==B){const a=await Kn({fs:t,cache:e,gitdir:f,oids:[k,B]});for(const t of a)i.push(t);R&&(r=await js({fs:t,cache:e,gitdir:f,oids:a}))}if(!i.includes(k)){const r=await async function({fs:t,cache:e,dir:i,gitdir:r=zi(i,".git"),start:a,finish:n}){const s=await An.read({fs:t,gitdir:r}),o=new Set,c=new Set;for(const e of a)o.add(await er.resolve({fs:t,gitdir:r,ref:e}));for(const e of n)try{const i=await er.resolve({fs:t,gitdir:r,ref:e});c.add(i)}catch(t){}const f=new Set;async function d(i){f.add(i);const{type:a,object:n}=await _r({fs:t,cache:e,gitdir:r,oid:i});if("tag"===a)return d(Qr.from(n).headers().object);if("commit"!==a)throw new Bi(i,a,"commit");if(!s.has(i)){const t=ea.from(n).headers().parent;for(i of t)c.has(i)||f.has(i)||await d(i)}}for(const t of o)await d(t);return f}({fs:t,cache:e,gitdir:f,start:[k],finish:i});P=await js({fs:t,cache:e,gitdir:f,oids:r})}if(R){try{const i=await er.resolve({fs:t,gitdir:f,ref:`refs/remotes/${l}/HEAD`,depth:2}),{oid:a}=await er.resolveAgainstMap({ref:i.replace(`refs/remotes/${l}/`,""),fullref:i,map:$.refs}),n=[a];for(const i of await js({fs:t,cache:e,gitdir:f,oids:n}))r.add(i)}catch(t){}for(const t of r)P.delete(t)}if(k===B&&(g=!0),!g){if(x.startsWith("refs/tags")&&"0000000000000000000000000000000000000000"!==B)throw new Mr("tag-exists");if("0000000000000000000000000000000000000000"!==k&&"0000000000000000000000000000000000000000"!==B&&!await ds({fs:t,cache:e,gitdir:f,oid:k,ancestor:B,depth:-1}))throw new Mr("not-fast-forward")}}const j=Rn([...$.capabilities],["report-status","side-band-64k",`agent=${jn}`]),O=await async function({capabilities:t=[],triplets:e=[]}){const i=[];let r=`\0 ${t.join(" ")}`;for(const t of e)i.push(mn.encode(`${t.oldoid} ${t.oid} ${t.fullRef}${r}\n`)),r="";return i.push(mn.flush()),i}({capabilities:j,triplets:[{oldoid:B,oid:k,fullRef:A}]}),I=w?[]:await Bs({fs:t,cache:e,gitdir:f,oids:[...P]}),C=await E.connect({http:i,onProgress:r,corsProxy:p,service:"git-receive-pack",url:_,auth:S,headers:m,body:[...O,...I]}),{packfile:z,progress:D}=await zn.demux(C.body);if(a){un(Cn(D),async t=>{await a(t)})}const T=await async function(t){const e={};let i="";const r=mn.streamReader(t);let a=await r();for(;!0!==a;)null!==a&&(i+=a.toString("utf8")+"\n"),a=await r();const n=i.toString("utf8").split("\n");if(a=n.shift(),!a.startsWith("unpack "))throw new Nr('unpack ok" or "unpack [error message]',a);e.ok="unpack ok"===a,e.ok||(e.error=a.slice(7)),e.refs={};for(const t of n){if(""===t.trim())continue;const i=t.slice(0,2),r=t.slice(3);let a=r.indexOf(" ");-1===a&&(a=r.length);const n=r.slice(0,a),s=r.slice(a+1);e.refs[n]={ok:"ok"===i,error:s}}return e}(z);if(C.headers&&(T.headers=C.headers),l&&T.ok&&T.refs[A].ok&&!x.startsWith("refs/tags")){const e=`refs/remotes/${l}/${A.replace("refs/heads","")}`;w?await er.deleteRef({fs:t,gitdir:f,ref:e}):await er.writeRef({fs:t,gitdir:f,ref:e,value:k})}if(T.ok&&Object.values(T.refs).every(t=>t.ok))return T;{const t=Object.entries(T.refs).filter(([t,e])=>!e.ok).map(([t,e])=>`\n - ${t}: ${e.error}`).join("");throw new Rr(t,T)}}async function Is({fs:t,http:e,onProgress:i,onMessage:r,onAuth:a,onAuthSuccess:n,onAuthFailure:s,onPrePush:o,dir:c,gitdir:f=zi(c,".git"),ref:d,remoteRef:h,remote:l="origin",url:u,force:g=!1,delete:w=!1,corsProxy:p,headers:m={},cache:y={}}){try{ma("fs",t),ma("http",e),ma("gitdir",f);const c=new pa(t),b=await ya({fsp:c,dotgit:f});return await Os({fs:c,cache:y,http:e,onProgress:i,onMessage:r,onAuth:a,onAuthSuccess:n,onAuthFailure:s,onPrePush:o,gitdir:b,ref:d,remoteRef:h,remote:l,url:u,force:g,delete:w,corsProxy:p,headers:m})}catch(t){throw t.caller="git.push",t}}async function Cs({fs:t,cache:e,gitdir:i,oid:r}){const{type:a,object:n}=await _r({fs:t,cache:e,gitdir:i,oid:r});if("tag"===a)return Cs({fs:t,cache:e,gitdir:i,oid:r=Qr.from(n).parse().object});if("blob"!==a)throw new Bi(r,a,"blob");return{oid:r,blob:new Uint8Array(n)}}async function zs({fs:t,cache:e,gitdir:i,oid:r,filepath:a}){void 0!==a&&(r=await Da({fs:t,cache:e,gitdir:i,oid:r,filepath:a}));return await Cs({fs:t,cache:e,gitdir:i,oid:r})}async function Ds({fs:t,dir:e,gitdir:i=zi(e,".git"),oid:r,filepath:a,cache:n={}}){try{ma("fs",t),ma("gitdir",i),ma("oid",r);const e=new pa(t),s=await ya({fsp:e,dotgit:i});return await zs({fs:e,cache:n,gitdir:s,oid:r,filepath:a})}catch(t){throw t.caller="git.readBlob",t}}async function Ts({fs:t,dir:e,gitdir:i=zi(e,".git"),oid:r,cache:a={}}){try{ma("fs",t),ma("gitdir",i),ma("oid",r);const e=new pa(t),n=await ya({fsp:e,dotgit:i});return await Ia({fs:e,cache:a,gitdir:n,oid:r})}catch(t){throw t.caller="git.readCommit",t}}async function Us({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r="refs/notes/commits",oid:a,cache:n={}}){try{ma("fs",t),ma("gitdir",i),ma("ref",r),ma("oid",a);const e=new pa(t),s=await ya({fsp:e,dotgit:i});return await async function({fs:t,cache:e,gitdir:i,ref:r="refs/notes/commits",oid:a}){const n=await er.resolve({gitdir:i,fs:t,ref:r}),{blob:s}=await zs({fs:t,cache:e,gitdir:i,oid:n,filepath:a});return s}({fs:e,cache:n,gitdir:s,ref:r,oid:a})}catch(t){throw t.caller="git.readNote",t}}async function Ns({fs:t,dir:e,gitdir:i=zi(e,".git"),oid:r,format:a="parsed",filepath:n,encoding:s,cache:o={}}){try{ma("fs",t),ma("gitdir",i),ma("oid",r);const e=new pa(t),c=await ya({fsp:e,dotgit:i});void 0!==n&&(r=await Da({fs:e,cache:o,gitdir:c,oid:r,filepath:n}));const f="parsed"===a?"content":a,d=await _r({fs:e,cache:o,gitdir:c,oid:r,format:f});if(d.oid=r,"parsed"===a)switch(d.format="parsed",d.type){case"commit":d.object=ea.from(d.object).parse();break;case"tree":d.object=sr.from(d.object).entries();break;case"blob":s?d.object=d.object.toString(s):(d.object=new Uint8Array(d.object),d.format="content");break;case"tag":d.object=Qr.from(d.object).parse();break;default:throw new Bi(d.oid,d.type,"blob|commit|tag|tree")}else"deflated"!==d.format&&"wrapped"!==d.format||(d.type=d.format);return d}catch(t){throw t.caller="git.readObject",t}}async function Ms({fs:t,dir:e,gitdir:i=zi(e,".git"),oid:r,cache:a={}}){try{ma("fs",t),ma("gitdir",i),ma("oid",r);const e=new pa(t),n=await ya({fsp:e,dotgit:i});return await async function({fs:t,cache:e,gitdir:i,oid:r}){const{type:a,object:n}=await _r({fs:t,cache:e,gitdir:i,oid:r,format:"content"});if("tag"!==a)throw new Bi(r,a,"tag");const s=Qr.from(n);return{oid:r,tag:s.parse(),payload:s.payload()}}({fs:e,cache:a,gitdir:n,oid:r})}catch(t){throw t.caller="git.readTag",t}}async function Fs({fs:t,dir:e,gitdir:i=zi(e,".git"),oid:r,filepath:a,cache:n={}}){try{ma("fs",t),ma("gitdir",i),ma("oid",r);const e=new pa(t),s=await ya({fsp:e,dotgit:i});return await Ua({fs:e,cache:n,gitdir:s,oid:r,filepath:a})}catch(t){throw t.caller="git.readTree",t}}async function Hs({fs:t,dir:e,gitdir:i=zi(e,".git"),filepath:r,cache:a={}}){try{ma("fs",t),ma("gitdir",i),ma("filepath",r);const e=new pa(t),n=await ya({fsp:e,dotgit:i});await _i.acquire({fs:e,gitdir:n,cache:a},async function(t){t.delete({filepath:r})})}catch(t){throw t.caller="git.remove",t}}async function qs({fs:t,onSign:e,dir:i,gitdir:r=zi(i,".git"),ref:a="refs/notes/commits",oid:n,author:s,committer:o,signingKey:c,cache:f={}}){try{ma("fs",t),ma("gitdir",r),ma("oid",n);const i=new pa(t),d=await ya({fsp:i,dotgit:r}),h=await Pa({fs:i,gitdir:d,author:s});if(!h)throw new Dr("author");const l=await ja({fs:i,gitdir:d,author:h,committer:o});if(!l)throw new Dr("committer");return await async function({fs:t,cache:e,onSign:i,gitdir:r,ref:a="refs/notes/commits",oid:n,author:s,committer:o,signingKey:c}){let f;try{f=await er.resolve({gitdir:r,fs:t,ref:a})}catch(t){if(!(t instanceof Ai))throw t}let d=(await Ua({fs:t,cache:e,gitdir:r,oid:f||"4b825dc642cb6eb9a060e54bf8d69288fbee4904"})).tree;d=d.filter(t=>t.path!==n);const h=await Na({fs:t,gitdir:r,tree:d});return await Ca({fs:t,cache:e,onSign:i,gitdir:r,ref:a,tree:h,parent:f&&[f],message:"Note removed by 'isomorphic-git removeNote'\n",author:s,committer:o,signingKey:c})}({fs:i,cache:f,onSign:e,gitdir:d,ref:a,oid:n,author:h,committer:l,signingKey:c})}catch(t){throw t.caller="git.removeNote",t}}async function Ls({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r,oldref:a,checkout:n=!1}){try{ma("fs",t),ma("gitdir",i),ma("ref",r),ma("oldref",a);const e=new pa(t),s=await ya({fsp:e,dotgit:i});return await async function({fs:t,gitdir:e,oldref:i,ref:r,checkout:a=!1}){if(!Ha(r,!0))throw new Or(r,Ye.clean(r));if(!Ha(i,!0))throw new Or(i,Ye.clean(i));const n=`refs/heads/${i}`,s=`refs/heads/${r}`;if(await er.exists({fs:t,gitdir:e,ref:s}))throw new vr("branch",r,!1);const o=await er.resolve({fs:t,gitdir:e,ref:n,depth:1});await er.writeRef({fs:t,gitdir:e,ref:s,value:o}),await er.deleteRef({fs:t,gitdir:e,ref:n});const c=await hn({fs:t,gitdir:e,fullname:!0});(a||c===n)&&await er.writeSymbolicRef({fs:t,gitdir:e,ref:"HEAD",value:s})}({fs:e,gitdir:s,ref:r,oldref:a,checkout:n})}catch(t){throw t.caller="git.renameBranch",t}}async function Ws({gitdir:t,type:e,object:i}){return ui(or.wrap({type:e,object:i}))}async function Gs({fs:t,dir:e,gitdir:i=zi(e,".git"),filepath:r,ref:a,cache:n={}}){try{ma("fs",t),ma("gitdir",i),ma("filepath",r);const s=new pa(t),o=await ya({fsp:s,dotgit:i});let c,f;try{c=await er.resolve({fs:s,gitdir:o,ref:a||"HEAD"})}catch(t){if(a)throw t}if(c)try{c=await Da({fs:s,cache:n,gitdir:o,oid:c,filepath:r})}catch(t){c=null}let d={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:0,uid:0,gid:0,size:0};const h=e&&await s.read(zi(e,r));h&&(f=await Ws({gitdir:o,type:"blob",object:h}),c===f&&(d=await s.lstat(zi(e,r)))),await _i.acquire({fs:s,gitdir:o,cache:n},async function(t){t.delete({filepath:r}),c&&t.insert({filepath:r,stats:d,oid:c})})}catch(t){throw t.caller="git.reset",t}}async function Zs({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r,depth:a}){try{ma("fs",t),ma("gitdir",i),ma("ref",r);const e=new pa(t),n=await ya({fsp:e,dotgit:i});return await er.resolve({fs:e,gitdir:n,ref:r,depth:a})}catch(t){throw t.caller="git.resolveRef",t}}async function Ks({fs:t,dir:e,gitdir:i=zi(e,".git"),path:r,value:a,append:n=!1}){try{ma("fs",t),ma("gitdir",i),ma("path",r);const e=new pa(t),s=await ya({fsp:e,dotgit:i}),o=await Xi.get({fs:e,gitdir:s});n?await o.append(r,a):await o.set(r,a),await Xi.save({fs:e,gitdir:s,config:o})}catch(t){throw t.caller="git.setConfig",t}}async function Vs({fs:t,gitdir:e,commit:i}){const r=ea.from(i).toObject();return await Ea({fs:t,gitdir:e,type:"commit",object:r,format:"content"})}class Xs{static get timezoneOffsetForRefLogEntry(){const t=(new Date).getTimezoneOffset(),e=Math.abs(Math.floor(t/60)),i=Math.abs(t%60).toString().padStart(2,"0");return`${t>0?"-":"+"}${e.toString().padStart(2,"0")}${i}`}static createStashReflogEntry(t,e,i){const r=t.name.replace(/\s/g,""),a=Math.floor(Date.now()/1e3),n=Xs.timezoneOffsetForRefLogEntry;return`0000000000000000000000000000000000000000 ${e} ${r} ${t.email} ${a} ${n}\t${i}\n`}static getStashReflogEntry(t,e=!1){return t.split("\n").filter(t=>t).reverse().map((t,i)=>e?`stash@{${i}}: ${t.split("\t")[1]}`:t)}}class Ys{constructor({fs:t,dir:e,gitdir:i=zi(e,".git")}){Object.assign(this,{fs:t,dir:e,gitdir:i,_author:null})}static get refStash(){return"refs/stash"}static get refLogsStash(){return"logs/refs/stash"}get refStashPath(){return zi(this.gitdir,Ys.refStash)}get refLogsStashPath(){return zi(this.gitdir,Ys.refLogsStash)}async getAuthor(){if(!this._author&&(this._author=await Pa({fs:this.fs,gitdir:this.gitdir,author:{}}),!this._author))throw new Dr("author");return this._author}async getStashSHA(t,e){if(!await this.fs.exists(this.refStashPath))return null;return(e||await this.readStashReflogs({parsed:!1}))[t].split(" ")[1]}async writeStashCommit({message:t,tree:e,parent:i}){return Vs({fs:this.fs,gitdir:this.gitdir,commit:{message:t,tree:e,parent:i,author:await this.getAuthor(),committer:await this.getAuthor()}})}async readStashCommit(t){const e=await this.readStashReflogs({parsed:!1});if(0!==t&&(t<0||t>e.length-1))throw new Or(`stash@${t}`,"number that is in range of [0, num of stash pushed]");const i=await this.getStashSHA(t,e);return i?Ia({fs:this.fs,cache:{},gitdir:this.gitdir,oid:i}):{}}async writeStashRef(t){return er.writeRef({fs:this.fs,gitdir:this.gitdir,ref:Ys.refStash,value:t})}async writeStashReflogEntry({stashCommit:t,message:e}){const i=await this.getAuthor(),r=Xs.createStashReflogEntry(i,t,e),a=this.refLogsStashPath;await rn({filepath:a,entry:r},async()=>{const t=await this.fs.exists(a)?await this.fs.read(a,"utf8"):"";await this.fs.write(a,t+r,"utf8")})}async readStashReflogs({parsed:t=!1}){if(!await this.fs.exists(this.refLogsStashPath))return[];const e=await this.fs.read(this.refLogsStashPath,"utf8");return Xs.getStashReflogEntry(e,t)}}async function Js({fs:t,dir:e,gitdir:i,message:r=""}){const a=new Ys({fs:t,dir:e,gitdir:i});await a.getAuthor();const n=await hn({fs:t,gitdir:i,fullname:!1}),s=await er.resolve({fs:t,gitdir:i,ref:"HEAD"}),o=(await Ts({fs:t,dir:e,gitdir:i,oid:s})).commit.message,c=[s];let f=null,d=aa({ref:"HEAD"});const h=await nn({fs:t,dir:e,gitdir:i,treePair:[aa({ref:"HEAD"}),"stage"]});if(h){const t=await a.writeStashCommit({message:`stash-Index: WIP on ${n} - ${(new Date).toISOString()}`,tree:h,parent:c});c.push(t),f=h,d=Si()}const l=await nn({fs:t,dir:e,gitdir:i,treePair:[d,"workdir"]});if(l){const t=await a.writeStashCommit({message:`stash-WorkDir: WIP on ${n} - ${(new Date).toISOString()}`,tree:l,parent:[c[c.length-1]]});c.push(t),f=l}if(!f||!h&&!l)throw new Ai("changes, nothing to stash");const u=(r.trim()||`WIP on ${n}`)+`: ${s.substring(0,7)} ${o}`;return{stashCommit:await a.writeStashCommit({message:u,tree:f,parent:c}),stashMsg:u,branch:n,stashMgr:a}}async function Qs({fs:t,dir:e,gitdir:i,message:r=""}){const{stashCommit:a,stashMsg:n,branch:s,stashMgr:o}=await Js({fs:t,dir:e,gitdir:i,message:r});return await o.writeStashRef(a),await o.writeStashReflogEntry({stashCommit:a,message:n}),await Xa({fs:t,dir:e,gitdir:i,ref:s,track:!1,force:!0}),a}async function to({fs:t,dir:e,gitdir:i,message:r=""}){const{stashCommit:a}=await Js({fs:t,dir:e,gitdir:i,message:r});return a}async function eo({fs:t,dir:e,gitdir:i,refIdx:r=0}){const a=new Ys({fs:t,dir:e,gitdir:i}),n=await a.readStashCommit(r),{parent:s=null}=n.commit?n.commit:{};if(s&&Array.isArray(s))for(let r=0;r<s.length-1;r++){const a=(await Ia({fs:t,cache:{},gitdir:i,oid:s[r+1]})).commit.message.startsWith("stash-Index");await sn({fs:t,dir:e,gitdir:i,stashCommit:s[r+1],parentCommit:s[r],wasStaged:a})}}async function io({fs:t,dir:e,gitdir:i,refIdx:r=0}){const a=new Ys({fs:t,dir:e,gitdir:i});if(!(await a.readStashCommit(r)).commit)return;const n=a.refStashPath;await rn(n,async()=>{await t.exists(n)&&await t.rm(n)});const s=await a.readStashReflogs({parsed:!1});if(!s.length)return;s.splice(r,1);const o=a.refLogsStashPath;await rn({reflogEntries:s,stashReflogPath:o,stashMgr:a},async()=>{if(s.length){await t.write(o,s.reverse().join("\n")+"\n","utf8");const e=s[s.length-1].split(" ")[1];await a.writeStashRef(e)}else await t.rm(o)})}async function ro({fs:t,dir:e,gitdir:i}){return new Ys({fs:t,dir:e,gitdir:i}).readStashReflogs({parsed:!0})}async function ao({fs:t,dir:e,gitdir:i}){const r=new Ys({fs:t,dir:e,gitdir:i}),a=[r.refStashPath,r.refLogsStashPath];await rn(a,async()=>{await Promise.all(a.map(async e=>{if(await t.exists(e))return t.rm(e)}))})}async function no({fs:t,dir:e,gitdir:i,refIdx:r=0}){await eo({fs:t,dir:e,gitdir:i,refIdx:r}),await io({fs:t,dir:e,gitdir:i,refIdx:r})}async function so({fs:t,dir:e,gitdir:i=zi(e,".git"),op:r="push",message:a="",refIdx:n=0}){ma("fs",t),ma("dir",e),ma("gitdir",i),ma("op",r);const s={push:Qs,apply:eo,drop:io,list:ro,clear:ao,pop:no,create:to},o=["apply","drop","pop"];try{const c=new pa(t),f=await ya({fsp:c,dotgit:i});["refs","logs","logs/refs"].map(t=>zi(f,t)).forEach(async t=>{await c.exists(t)||await c.mkdir(t)});const d=s[r];if(d){if(o.includes(r)&&n<0)throw new Or(`stash@${n}`,"number that is in range of [0, num of stash pushed]");return await d({fs:c,dir:e,gitdir:f,message:a,refIdx:n})}throw new Error(`To be implemented: ${r}`)}catch(t){throw t.caller="git.stash",t}}async function oo({fs:t,dir:e,gitdir:i=zi(e,".git"),filepath:r,cache:a={}}){try{ma("fs",t),ma("gitdir",i),ma("filepath",r);const n=new pa(t),s=await ya({fsp:n,dotgit:i});if(await va.isIgnored({fs:n,gitdir:s,dir:e,filepath:r}))return"ignored";const o=await async function({fs:t,cache:e,gitdir:i}){let r;try{r=await er.resolve({fs:t,gitdir:i,ref:"HEAD"})}catch(t){if(t instanceof Ai)return[]}const{tree:a}=await Ua({fs:t,cache:e,gitdir:i,oid:r});return a}({fs:n,cache:a,gitdir:s}),c=await co({fs:n,cache:a,gitdir:s,tree:o,path:r}),f=await _i.acquire({fs:n,gitdir:s,cache:a},async function(t){for(const e of t)if(e.path===r)return e;return null}),d=await n.lstat(zi(e,r)),h=null!==c,l=null!==f,u=null!==d,g=async()=>{if(l&&!mi(f,d))return f.oid;{const t=await n.read(zi(e,r)),i=await Ws({gitdir:s,type:"blob",object:t});return l&&f.oid===i&&-1!==d.size&&_i.acquire({fs:n,gitdir:s,cache:a},async function(t){t.insert({filepath:r,stats:d,oid:i})}),i}};if(!h&&!u&&!l)return"absent";if(!h&&!u&&l)return"*absent";if(!h&&u&&!l)return"*added";if(!h&&u&&l){return await g()===f.oid?"added":"*added"}if(h&&!u&&!l)return"deleted";if(h&&!u&&l)return f.oid,"*deleted";if(h&&u&&!l){return await g()===c?"*undeleted":"*undeletemodified"}if(h&&u&&l){const t=await g();return t===c?t===f.oid?"unmodified":"*unmodified":t===f.oid?"modified":"*modified"}}catch(t){throw t.caller="git.status",t}}async function co({fs:t,cache:e,gitdir:i,tree:r,path:a}){"string"==typeof a&&(a=a.split("/"));const n=a.shift();for(const s of r)if(s.path===n){if(0===a.length)return s.oid;const{type:r,object:n}=await _r({fs:t,cache:e,gitdir:i,oid:s.oid});if("tree"===r){return co({fs:t,cache:e,gitdir:i,tree:sr.from(n),path:a})}if("blob"===r)throw new Bi(s.oid,r,"blob",a.join("/"))}return null}async function fo({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r="HEAD",filepaths:a=["."],filter:n,cache:s={},ignored:o=!1}){try{ma("fs",t),ma("gitdir",i),ma("ref",r);const c=new pa(t),f=await ya({fsp:c,dotgit:i});return await da({fs:c,cache:s,dir:e,gitdir:f,trees:[aa({ref:r}),sa(),Si()],map:async function(t,[i,r,s]){if(!i&&!s&&r&&!o){if(await va.isIgnored({fs:c,dir:e,filepath:t}))return null}if(!a.some(e=>Za(t,e)))return null;if(n&&!n(t))return;const[f,d,h]=await Promise.all([i&&i.type(),r&&r.type(),s&&s.type()]),l=[f,d,h].includes("blob");if(("tree"===f||"special"===f)&&!l)return;if("commit"===f)return null;if(("tree"===d||"special"===d)&&!l)return;if("commit"===h)return null;if(("tree"===h||"special"===h)&&!l)return;const u="blob"===f?await i.oid():void 0,g="blob"===h?await s.oid():void 0;let w;"blob"!==f&&"blob"===d&&"blob"!==h?w="42":"blob"===d&&(w=await r.oid());const p=[void 0,u,w,g],m=p.map(t=>p.indexOf(t));return m.shift(),[t,...m]}})}catch(t){throw t.caller="git.statusMatrix",t}}async function ho({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r,object:a,force:n=!1}){try{ma("fs",t),ma("gitdir",i),ma("ref",r);const e=new pa(t);if(void 0===r)throw new Tr("ref");r=r.startsWith("refs/tags/")?r:`refs/tags/${r}`;const s=await ya({fsp:e,dotgit:i}),o=await er.resolve({fs:e,gitdir:s,ref:a||"HEAD"});if(!n&&await er.exists({fs:e,gitdir:s,ref:r}))throw new vr("tag",r);await er.writeRef({fs:e,gitdir:s,ref:r,value:o})}catch(t){throw t.caller="git.tag",t}}async function lo({fs:t,dir:e,gitdir:i=zi(e,".git"),cache:r={},filepath:a,oid:n,mode:s,add:o,remove:c,force:f}){try{ma("fs",t),ma("gitdir",i),ma("filepath",a);const d=new pa(t),h=await ya({fsp:d,dotgit:i});if(c)return await _i.acquire({fs:d,gitdir:h,cache:r},async function(t){if(!f){const t=await d.lstat(zi(e,a));if(t){if(t.isDirectory())throw new jr("directory");return}}t.has({filepath:a})&&t.delete({filepath:a})});let l;if(!n){if(l=await d.lstat(zi(e,a)),!l)throw new Ai(`file at "${a}" on disk and "remove" not set`);if(l.isDirectory())throw new jr("directory")}return await _i.acquire({fs:d,gitdir:h,cache:r},async function(t){if(!o&&!t.has({filepath:a}))throw new Ai(`file at "${a}" in index and "add" not set`);let i;if(n)i={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:s,uid:0,gid:0,size:0};else{i=l;const t=i.isSymbolicLink()?await d.readlink(zi(e,a)):await d.read(zi(e,a));n=await Ea({fs:d,gitdir:h,type:"blob",format:"content",object:t})}return t.insert({filepath:a,oid:n,stats:i}),n})}catch(t){throw t.caller="git.updateIndex",t}}function uo(){try{return Pn}catch(t){throw t.caller="git.version",t}}async function go({fs:t,dir:e,gitdir:i=zi(e,".git"),trees:r,map:a,reduce:n,iterate:s,cache:o={}}){try{ma("fs",t),ma("gitdir",i),ma("trees",r);const c=new pa(t),f=await ya({fsp:c,dotgit:i});return await da({fs:c,cache:o,dir:e,gitdir:f,trees:r,map:a,reduce:n,iterate:s})}catch(t){throw t.caller="git.walk",t}}async function wo({fs:t,dir:e,gitdir:i=zi(e,".git"),blob:r}){try{ma("fs",t),ma("gitdir",i),ma("blob",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return await Ea({fs:e,gitdir:a,type:"blob",object:r,format:"content"})}catch(t){throw t.caller="git.writeBlob",t}}async function po({fs:t,dir:e,gitdir:i=zi(e,".git"),commit:r}){try{ma("fs",t),ma("gitdir",i),ma("commit",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return await Vs({fs:e,gitdir:a,commit:r})}catch(t){throw t.caller="git.writeCommit",t}}async function mo({fs:t,dir:e,gitdir:i=zi(e,".git"),type:r,object:a,format:n="parsed",oid:s,encoding:o}){try{const e=new pa(t),c=await ya({fsp:e,dotgit:i});if("parsed"===n){switch(r){case"commit":a=ea.from(a).toObject();break;case"tree":a=sr.from(a).toObject();break;case"blob":a=Buffer.from(a,o);break;case"tag":a=Qr.from(a).toObject();break;default:throw new Bi(s||"",r,"blob|commit|tag|tree")}n="content"}return s=await Ea({fs:e,gitdir:c,type:r,object:a,oid:s,format:n})}catch(t){throw t.caller="git.writeObject",t}}async function yo({fs:t,dir:e,gitdir:i=zi(e,".git"),ref:r,value:a,force:n=!1,symbolic:s=!1}){try{ma("fs",t),ma("gitdir",i),ma("ref",r),ma("value",a);const e=new pa(t);if(!Ha(r,!0))throw new Or(r,Ye.clean(r));const o=await ya({fsp:e,dotgit:i});if(!n&&await er.exists({fs:e,gitdir:o,ref:r}))throw new vr("ref",r);s?await er.writeSymbolicRef({fs:e,gitdir:o,ref:r,value:a}):(a=await er.resolve({fs:e,gitdir:o,ref:a}),await er.writeRef({fs:e,gitdir:o,ref:r,value:a}))}catch(t){throw t.caller="git.writeRef",t}}async function bo({fs:t,dir:e,gitdir:i=zi(e,".git"),tag:r}){try{ma("fs",t),ma("gitdir",i),ma("tag",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return await async function({fs:t,gitdir:e,tag:i}){const r=Qr.from(i).toObject();return await Ea({fs:t,gitdir:e,type:"tag",object:r,format:"content"})}({fs:e,gitdir:a,tag:r})}catch(t){throw t.caller="git.writeTag",t}}async function _o({fs:t,dir:e,gitdir:i=zi(e,".git"),tree:r}){try{ma("fs",t),ma("gitdir",i),ma("tree",r);const e=new pa(t),a=await ya({fsp:e,dotgit:i});return await Na({fs:e,gitdir:a,tree:r})}catch(t){throw t.caller="git.writeTree",t}}var vo={Errors:Kr,STAGE:Si,TREE:aa,WORKDIR:sa,add:Sa,abortMerge:_a,addNote:Ma,addRemote:La,annotatedTag:Wa,branch:Ga,cherryPick:cn,checkout:Xa,clone:Un,commit:Nn,getConfig:is,getConfigAll:rs,setConfig:Ks,currentBranch:Mn,deleteBranch:Fn,deleteRef:Hn,deleteRemote:qn,deleteTag:Ln,expandOid:Gn,expandRef:Zn,fastForward:Yn,fetch:Jn,findMergeBase:Qn,findRoot:es,getRemoteInfo:as,getRemoteInfo2:ss,hashBlob:os,indexPack:cs,init:fs,isDescendent:hs,isIgnored:ls,listBranches:us,listFiles:ps,listNotes:ms,listRefs:ys,listRemotes:bs,listServerRefs:_s,listTags:vs,log:$s,merge:Ss,packObjects:Rs,pull:Ps,push:Is,readBlob:Ds,readCommit:Ts,readNote:Us,readObject:Ns,readTag:Ms,readTree:Fs,remove:Hs,removeNote:qs,renameBranch:Ls,resetIndex:Gs,updateIndex:lo,resolveRef:Zs,status:oo,statusMatrix:fo,tag:ho,version:uo,walk:go,writeBlob:wo,writeCommit:po,writeObject:mo,writeRef:yo,writeTag:bo,writeTree:_o,stash:so};exports.Errors=Kr,exports.STAGE=Si,exports.TREE=aa,exports.WORKDIR=sa,exports.abortMerge=_a,exports.add=Sa,exports.addNote=Ma,exports.addRemote=La,exports.annotatedTag=Wa,exports.branch=Ga,exports.checkout=Xa,exports.cherryPick=cn,exports.clone=Un,exports.commit=Nn,exports.currentBranch=Mn,exports.default=vo,exports.deleteBranch=Fn,exports.deleteRef=Hn,exports.deleteRemote=qn,exports.deleteTag=Ln,exports.expandOid=Gn,exports.expandRef=Zn,exports.fastForward=Yn,exports.fetch=Jn,exports.findMergeBase=Qn,exports.findRoot=es,exports.getConfig=is,exports.getConfigAll=rs,exports.getRemoteInfo=as,exports.getRemoteInfo2=ss,exports.hashBlob=os,exports.indexPack=cs,exports.init=fs,exports.isDescendent=hs,exports.isIgnored=ls,exports.listBranches=us,exports.listFiles=ps,exports.listNotes=ms,exports.listRefs=ys,exports.listRemotes=bs,exports.listServerRefs=_s,exports.listTags=vs,exports.log=$s,exports.merge=Ss,exports.packObjects=Rs,exports.pull=Ps,exports.push=Is,exports.readBlob=Ds,exports.readCommit=Ts,exports.readNote=Us,exports.readObject=Ns,exports.readTag=Ms,exports.readTree=Fs,exports.remove=Hs,exports.removeNote=qs,exports.renameBranch=Ls,exports.resetIndex=Gs,exports.resolveRef=Zs,exports.setConfig=Ks,exports.stash=so,exports.status=oo,exports.statusMatrix=fo,exports.tag=ho,exports.updateIndex=lo,exports.version=uo,exports.walk=go,exports.writeBlob=wo,exports.writeCommit=po,exports.writeObject=mo,exports.writeRef=yo,exports.writeTag=bo,exports.writeTree=_o;