just-git 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -776,7 +776,7 @@ ${m}`,exitCode:0}}ie();ce();$r();ge();is();function $d(e,t){e.command("tag",{des
776
776
  `)}if(n.list)return Pd(s,n.name||void 0);if(n.name){if(!vc(n.name))return I(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let d=await wt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(d))return d;a=d}else if(a=await Z(s),!a)return I("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await B(s,c)&&!n.force)return I(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return I("no tag message specified (use -m)");let d=await nt(s,r.env);if(M(d))return d;let m=Mt(n.message),u=$c({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:m}),h=await Ae(s,"tag",u);await X(s,c,h)}else await X(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Pd(s)}})}async function Pd(e,t){let n=await pe(e,"refs/tags");if(n.length===0)return{stdout:"",stderr:"",exitCode:0};let r=n.map(o=>o.name.replace("refs/tags/",""));return t&&(r=r.filter(o=>on(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
777
777
  `)}
778
778
  `,stderr:"",exitCode:0}}var Od=new Set(["am","annotate","apply","archive","bugreport","bundle","cat-file","check-ignore","check-mailmap","check-ref-format","checkout-index","cherry","commit-tree","count-objects","credential","daemon","diff-files","diff-index","diff-tree","difftool","fast-export","fast-import","filter-branch","for-each-ref","format-patch","fsck","hash-object","instaweb","interpret-trailers","log--hierarchical","ls-remote","ls-tree","maintenance","merge-base","merge-tree","mergetool","multi-pack-index","name-rev","notes","pack-objects","pack-refs","patch-id","prune","range-diff","read-tree","receive-pack","replace","request-pull","rerere","rev-list","send-email","send-pack","shortlog","show-branch","show-ref","sparse-checkout","stash--helper","stripspace","submodule","symbolic-ref","unpack-objects","update-index","update-ref","upload-pack","var","verify-commit","verify-pack","verify-tag","whatchanged","worktree","write-tree"]),Iw={init:(e,t)=>Gl(e,t),clone:(e,t)=>ll(e,t),describe:(e,t)=>ul(e,t),fetch:(e,t)=>Il(e,t),pull:(e,t)=>nd(e,t),push:(e,t)=>rd(e,t),add:(e,t)=>Xc(e,t),blame:(e,t)=>Tf(e,t),commit:(e,t)=>ml(e,t),status:(e,t)=>kd(e,t),log:(e,t)=>Kl(e,t),branch:(e,t)=>Af(e,t),tag:(e,t)=>$d(e,t),checkout:(e,t)=>Mf(e,t),diff:(e,t)=>xl(e,t),reset:(e,t)=>ad(e,t),merge:(e,t)=>Xl(e,t),"cherry-pick":(e,t)=>Yf(e,t),revert:(e,t)=>dd(e,t),rebase:(e,t)=>td(e,t),mv:(e,t)=>Zl(e,t),rm:(e,t)=>ud(e,t),remote:(e,t)=>od(e,t),config:(e,t)=>wl(e,t),show:(e,t)=>md(e,t),stash:(e,t)=>Ed(e,t),"rev-parse":(e,t)=>ld(e,t),"ls-files":(e,t)=>Yl(e,t),clean:(e,t)=>Xf(e,t),switch:(e,t)=>xd(e,t),restore:(e,t)=>fd(e,t),reflog:(e,t)=>sd(e,t),repack:(e,t)=>Tl(e,t),gc:(e,t)=>Hl(e,t),bisect:(e,t)=>wf(e,t),grep:(e,t)=>jl(e,t)};function Id(e){let t=Xo("git",{description:"Git command"});for(let n of Object.values(Iw))n(t,e);return t.command("help",{description:"Display help information",args:[q.string().name("command").describe("Command to get help for").optional()],handler:async n=>{let r=n.command;if(!r)return{stdout:Er(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:Er(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
779
- `,exitCode:1}}}),t}var Sw="1.3.0";function vw(e,t){if(!e)return t;let n=e.locked?"locked":"defaults",r={"user.name":e.name,"user.email":e.email};return t?{...t,[n]:{...r,...t[n]}}:{[n]:r}}var qo=class{name="git";defaultFs;defaultCwd;blocked;hooks;inner;locks=new WeakMap;async withLock(t,n){let r=this.locks.get(t)??Promise.resolve(),o,s=new Promise(i=>{o=i});this.locks.set(t,s),await r;try{return await n()}finally{o()}}constructor(t){this.defaultFs=t?.fs,this.defaultCwd=t?.cwd??"/",this.hooks=t?.hooks,this.blocked=t?.disabled?.length?new Set(t.disabled):null;let n=t?.network,r=vw(t?.identity,t?.config),o={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},...r?{configOverrides:r}:{}};this.inner=Id(o).toCommand()}exec=async(t,n)=>{let r=n?.fs??this.defaultFs;if(!r)throw new Error("No filesystem: pass `fs` in exec() options or in createGit()");let o=n?.cwd??this.defaultCwd,s=Tw(t),i=new Map;if(n?.env)for(let[a,c]of Object.entries(n.env))i.set(a,c);return this.execute(s,{fs:r,cwd:o,env:i,stdin:n?.stdin??""})};execute=(t,n)=>this.withLock(n.fs,async()=>{let r=t[0]??"";if(r==="--version"||r==="version")return{stdout:`just-git version ${Sw} (virtual git implementation)
779
+ `,exitCode:1}}}),t}var Sw="1.3.1";function vw(e,t){if(!e)return t;let n=e.locked?"locked":"defaults",r={"user.name":e.name,"user.email":e.email};return t?{...t,[n]:{...r,...t[n]}}:{[n]:r}}var qo=class{name="git";defaultFs;defaultCwd;blocked;hooks;inner;locks=new WeakMap;async withLock(t,n){let r=this.locks.get(t)??Promise.resolve(),o,s=new Promise(i=>{o=i});this.locks.set(t,s),await r;try{return await n()}finally{o()}}constructor(t){this.defaultFs=t?.fs,this.defaultCwd=t?.cwd??"/",this.hooks=t?.hooks,this.blocked=t?.disabled?.length?new Set(t.disabled):null;let n=t?.network,r=vw(t?.identity,t?.config),o={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},...r?{configOverrides:r}:{}};this.inner=Id(o).toCommand()}exec=async(t,n)=>{let r=n?.fs??this.defaultFs;if(!r)throw new Error("No filesystem: pass `fs` in exec() options or in createGit()");let o=n?.cwd??this.defaultCwd,s=Tw(t),i=new Map;if(n?.env)for(let[a,c]of Object.entries(n.env))i.set(a,c);return this.execute(s,{fs:r,cwd:o,env:i,stdin:n?.stdin??""})};execute=(t,n)=>this.withLock(n.fs,async()=>{let r=t[0]??"";if(r==="--version"||r==="version")return{stdout:`just-git version ${Sw} (virtual git implementation)
780
780
  `,stderr:"",exitCode:0};if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
781
781
  `,exitCode:1};if(r&&Od.has(r))return{stdout:"",stderr:`git: '${r}' is not implemented. Run 'git help' for available commands.
782
782
  `,exitCode:1};if(this.hooks?.beforeCommand){let s=await this.hooks.beforeCommand({command:r,args:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1}}let o=await this.inner.execute(t,n);return this.hooks?.afterCommand&&await this.hooks.afterCommand({command:r,args:t.slice(1),result:o}),o})};function Tw(e){let t=[],n="",r=0;for(;r<e.length;){let o=e[r];if(o==='"'){for(r++;r<e.length&&e[r]!=='"';){if(e[r]==="\\"&&r+1<e.length){let s=e[r+1];if(s==='"'||s==="\\"){n+=s,r+=2;continue}}n+=e[r],r++}r++}else if(o==="'"){for(r++;r<e.length&&e[r]!=="'";)n+=e[r],r++;r++}else o===" "||o===" "?(n.length>0&&(t.push(n),n=""),r++):(n+=o,r++)}return n.length>0&&t.push(n),t.length>0&&t[0]==="git"&&t.shift(),t}function Hw(e){return new qo(e)}var Sd=new TextEncoder,Aw=new TextDecoder;function hn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function zo(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Ca=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:16877,mtime:new Date}),t)for(let[n,r]of Object.entries(t)){let o=hn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?Sd.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=zo(t);n!=="/"&&(this.data.has(n)||(this.ensureParents(n),this.data.set(n,{type:"directory",mode:16877,mtime:new Date})))}resolve(t){let n="",r=new Set;for(let o of hn(t).slice(1).split("/")){n=`${n}/${o}`;let s=0,i=this.data.get(n);for(;i?.type==="symlink"&&s<40;){if(r.has(n))throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`);r.add(n);let a=i.target;n=a.startsWith("/")?hn(a):hn(zo(n)+"/"+a),i=this.data.get(n),s++}if(s>=40)throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`)}return n}resolveParent(t){let n=hn(t);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let o="",s=new Set;for(let i=0;i<r.length-1;i++){o=`${o}/${r[i]}`;let a=this.data.get(o),c=0;for(;a?.type==="symlink"&&c<40;){if(s.has(o))throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`);s.add(o);let f=a.target;o=f.startsWith("/")?hn(f):hn(zo(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return Aw.decode(await this.readFileBuffer(t))}async readFileBuffer(t){let n=this.data.get(this.resolve(t));if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content}async writeFile(t,n){let r=this.resolve(t);this.ensureParents(r),this.data.set(r,{type:"file",content:typeof n=="string"?Sd.encode(n):n,mode:33188,mtime:new Date})}async exists(t){try{return this.data.has(this.resolve(t))}catch{return!1}}async stat(t){let n=this.data.get(this.resolve(t));if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);return{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:n.type==="file"?n.content.byteLength:0,mtime:n.mtime}}async lstat(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);return{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:r.type==="symlink",mode:r.mode,size:r.type==="file"?r.content.byteLength:r.type==="symlink"?r.target.length:0,mtime:r.mtime}}async mkdir(t,n){let r=hn(t);if(this.data.has(r)){if(this.data.get(r).type!=="directory")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let o=zo(r);if(o!=="/"&&!this.data.has(o))if(n?.recursive)await this.mkdir(o,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:16877,mtime:new Date})}async readdir(t){let n=this.resolve(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let o=n==="/"?"/":`${n}/`,s=new Set;for(let i of this.data.keys())if(i!==n&&i.startsWith(o)){let c=i.slice(o.length).split("/")[0];c&&s.add(c)}return[...s].sort()}async rm(t,n){let r=hn(t),o=this.data.get(r);if(!o){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(o.type==="directory"){if(!n?.recursive&&(await this.readdir(r)).length>0)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);let s=r==="/"?"/":`${r}/`;for(let i of[...this.data.keys()])i.startsWith(s)&&this.data.delete(i)}this.data.delete(r)}async readlink(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async symlink(t,n){let r=hn(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParents(r),this.data.set(r,{type:"symlink",target:t,mode:40960,mtime:new Date})}};Gn();export{qo as Git,Ca as MemoryFileSystem,Th as composeGitHooks,Hw as createGit,rr as findRepo,ee as isRejection};
@@ -169,8 +169,8 @@ interface ServerPolicy {
169
169
  denyNonFastForward?: boolean;
170
170
  /** Reject all ref deletions globally. */
171
171
  denyDeletes?: boolean;
172
- /** Reject deletion and overwrite of tags. Tags are treated as immutable. */
173
- denyDeleteTags?: boolean;
172
+ /** Tags are immutable no deletion, no overwrite once created. */
173
+ immutableTags?: boolean;
174
174
  }
175
175
  interface GitServerConfig<S = Session> {
176
176
  /**
@@ -1,40 +1,40 @@
1
- var ue=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});function T(r){return r!=null&&typeof r=="object"&&"reject"in r&&r.reject===!0}var ke="0000000000000000000000000000000000000000",st=(()=>{let r=new Array(256);for(let e=0;e<256;e++)r[e]=(e>>4).toString(16)+(e&15).toString(16);return r})();function he(r){let e="";for(let t=0;t<20;t++)e+=st[r[t]];return e}function Z(r,e){let t="";for(let n=0;n<20;n++)t+=st[r[e+n]];return t}function ye(r){let e=new Uint8Array(20);for(let t=0;t<20;t++)e[t]=parseInt(r.slice(t*2,t*2+2),16);return e}var or=new TextEncoder;function ve(r){return typeof r=="string"?or.encode(r):r}function ir(){if(typeof globalThis.Bun<"u")return()=>{let r=new Bun.CryptoHasher("sha1"),e={update(t){return r.update(ve(t)),e},hex:()=>Promise.resolve(r.digest("hex"))};return e};try{let r=ue(["node","crypto"].join(":"));if(typeof r.createHash=="function")return()=>{let e=r.createHash("sha1"),t={update(n){return e.update(ve(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t}}catch{}if(typeof globalThis.crypto?.subtle?.digest=="function")return()=>{let r=[],e={update(t){return r.push(ve(t)),e},async hex(){let t=0;for(let i of r)t+=i.byteLength;let n=new Uint8Array(t),s=0;for(let i of r)n.set(i,s),s+=i.byteLength;let a=await crypto.subtle.digest("SHA-1",n);return he(new Uint8Array(a))}};return e};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}var at=ir(),G=at;async function ot(r){return at().update(r).hex()}var cr=new Set(["tree","commit","tag"]),be=class{map=new Map;currentBytes=0;maxBytes;constructor(e=16*1024*1024){this.maxBytes=e}get(e){return this.map.get(e)}set(e,t){if(!cr.has(t.type))return;let n=t.content.byteLength;if(!(n>this.maxBytes/2)&&!this.map.has(e)){for(;this.currentBytes+n>this.maxBytes&&this.map.size>0;){let s=this.map.keys().next().value;this.currentBytes-=this.map.get(s).content.byteLength,this.map.delete(s)}this.map.set(e,t),this.currentBytes+=n}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}};var L=Uint8Array,F=Uint16Array,fr=Int32Array,it=new L([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,0,0,0]),ct=new L([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,0,0]),lr=new L([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ft=(r,e)=>{let t=new F(31);for(let s=0;s<31;++s)t[s]=e+=1<<r[s-1];let n=new fr(t[30]);for(let s=1;s<30;++s)for(let a=t[s];a<t[s+1];++a)n[a]=a-t[s]<<5|s;return{b:t,r:n}},{b:lt}=ft(it,2);lt[28]=258;var{b:dr}=ft(ct,0),Ae=new F(32768);for(let r=0;r<32768;++r){let e=(r&43690)>>1|(r&21845)<<1;e=(e&52428)>>2|(e&13107)<<2,e=(e&61680)>>4|(e&3855)<<4,Ae[r]=((e&65280)>>8|(e&255)<<8)>>1}var J=(r,e,t)=>{let n=r.length,s=0,a=new F(e);for(;s<n;++s)r[s]&&++a[r[s]-1];let i=new F(e);for(s=1;s<e;++s)i[s]=i[s-1]+a[s-1]<<1;let o;if(t){o=new F(1<<e);let f=15-e;for(s=0;s<n;++s)if(r[s]){let c=s<<4|r[s],l=e-r[s],d=i[r[s]-1]++<<l;for(let p=d|(1<<l)-1;d<=p;++d)o[Ae[d]>>f]=c}}else for(o=new F(n),s=0;s<n;++s)r[s]&&(o[s]=Ae[i[r[s]-1]++]>>15-r[s]);return o},Q=new L(288);for(let r=0;r<144;++r)Q[r]=8;for(let r=144;r<256;++r)Q[r]=9;for(let r=256;r<280;++r)Q[r]=7;for(let r=280;r<288;++r)Q[r]=8;var dt=new L(32);for(let r=0;r<32;++r)dt[r]=5;var pr=J(Q,9,1),ur=J(dt,5,1),Se=r=>{let e=r[0];for(let t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},U=(r,e,t)=>{let n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},je=(r,e)=>{let t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},pt=r=>(r+7)/8|0,hr=(r,e,t)=>((e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new L(r.subarray(e,t))),D=(r,e)=>{let t=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(e||t[r]||"unknown inflate error")},ut=(r,e,t,n)=>{let s=r.length,a=n?n.length:0;if(!s||e.f&&!e.l)return t||new L(0);let i=!t,o=i||e.i!=2,f=e.i;i&&(t=new L(s*3));let c=y=>{let R=t.length;if(y>R){let w=new L(Math.max(R*2,y));w.set(t),t=w}},l=e.f||0,d=e.p||0,p=e.b||0,u=e.l,h=e.d,m=e.m,g=e.n,b=s*8;do{if(!u){l=U(r,d,1);let P=U(r,d+1,3);if(d+=3,P)if(P==1)u=pr,h=ur,m=9,g=5;else if(P==2){let x=U(r,d,31)+257,O=U(r,d+10,15)+4,S=x+U(r,d+5,31)+1;d+=14;let E=new L(S),j=new L(19);for(let N=0;N<O;++N)j[lr[N]]=U(r,d+N*3,7);d+=O*3;let M=Se(j),I=(1<<M)-1,C=J(j,M,1);for(let N=0;N<S;){let rt=C[U(r,d,I)];d+=rt&15;let V=rt>>4;if(V<16)E[N++]=V;else{let nt=0,pe=0;for(V==16?(pe=3+U(r,d,3),d+=2,nt=E[N-1]):V==17?(pe=3+U(r,d,7),d+=3):V==18&&(pe=11+U(r,d,127),d+=7);pe--;)E[N++]=nt}}let $=E.subarray(0,x),tt=E.subarray(x);m=Se($),g=Se(tt),u=J($,m,1),h=J(tt,g,1)}else D(1);else{let x=pt(d)+4,O=r[x-4]|r[x-3]<<8,S=x+O;if(S>s){f&&D(0);break}o&&c(p+O),t.set(r.subarray(x,S),p),e.b=p+=O,e.p=d=S*8,e.f=l;continue}if(d>b){f&&D(0);break}}o&&c(p+131072);let y=(1<<m)-1,R=(1<<g)-1,w=d;for(;;w=d){let P=u[je(r,d)&y],x=P>>4;if(d+=P&15,d>b){f&&D(0);break}if(P||D(2),x<256)t[p++]=x;else if(x==256){w=d,u=null;break}else{let O=x-254;if(x>264){let I=x-257,C=it[I];O=U(r,d,(1<<C)-1)+lt[I],d+=C}let S=h[je(r,d)&R],E=S>>4;S||D(3),d+=S&15;let j=dr[E];if(E>3){let I=ct[E];j+=je(r,d)&(1<<I)-1,d+=I}if(d>b){f&&D(0);break}o&&c(p+131072);let M=p+O;if(p<j){let I=a-j,C=Math.min(j,M);for(I+p<0&&D(3);p<C;++p)t[p]=n[I+p]}for(;p<M;++p)t[p]=t[p-j]}}e.l=u,e.p=w,e.b=p,e.f=l,u&&(l=1,e.m=m,e.d=h,e.n=g)}while(!l);return p!=t.length&&i?hr(t,0,p):t.subarray(0,p)},ht=r=>(((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&D(0,"invalid zlib data"),r[1]&32&&D(0,"zlib dictionaries are not supported"),2);function yt(r){let e=ht(r);return ut(r.subarray(e,-4),{i:2})}function Ie(r){let e=ht(r),t={i:2},n=ut(r.subarray(e),t),s=pt(t.p);return{result:n,bytesConsumed:e+s+4}}async function yr(){let r;if(!(typeof document<"u"))try{r=ue(["node","zlib"].join(":"))}catch{try{r=await import(["node","zlib"].join(":"))}catch{}}if(r&&typeof r.deflateSync=="function"&&typeof r.inflateSync=="function"){let n=null;try{let s=r.inflateSync(r.deflateSync(Buffer.from("x")),{info:!0});s?.engine&&typeof s.engine.bytesWritten=="number"&&(n=a=>{let i=r.inflateSync(a,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:s=>new Uint8Array(r.deflateSync(s)),inflateSync:s=>new Uint8Array(r.inflateSync(s)),inflateWithConsumed:n??Ie}}let t;return typeof globalThis.CompressionStream=="function"?t=async n=>{let s=new CompressionStream("deflate"),a=s.writable.getWriter();return a.write(n),a.close(),new Uint8Array(await new Response(s.readable).arrayBuffer())}:t=()=>{throw new Error("No deflate implementation available. Requires node:zlib or CompressionStream.")},{deflateSync:t,inflateSync:yt,inflateWithConsumed:Ie}}var br=null;function bt(){return br??=yr()}async function me(r){return await(await bt()).deflateSync(r)}async function Te(r,e){let t=await bt(),{result:n,bytesConsumed:s}=t.inflateWithConsumed(r);if(n.byteLength!==e)throw new Error(`Inflate size mismatch: got ${n.byteLength}, expected ${e}`);return{result:n,bytesConsumed:s}}var z=1346454347,xe=2,xt=1,Rt=2,wt=3,Pt=4,W=6,ee=7,Ot={[xt]:"commit",[Rt]:"tree",[wt]:"blob",[Pt]:"tag"},Et={commit:xt,tree:Rt,blob:wt,tag:Pt};async function kt(r,e){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=t.getUint32(0);if(n!==z)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${z.toString(16)})`);let s=t.getUint32(4);if(s!==xe)throw new Error(`Unsupported pack version: ${s}`);if(r.byteLength>=32){let c=Z(r,r.byteLength-20),l=G();l.update(r.subarray(0,r.byteLength-20));let d=await l.hex();if(d!==c)throw new Error(`pack checksum mismatch: expected ${c}, computed ${d}`)}let a=t.getUint32(8),i=[],o=12;for(let c=0;c<a;c++){let l=await mr(r,o);i.push(l),o=l.nextOffset}return(await gr(i,e)).map((c,l)=>({...c,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function mr(r,e){let t=e,n=r[e++],s=n>>4&7,a=n&15,i=4;for(;n&128;)n=r[e++],a|=(n&127)<<i,i+=7;let o,f;if(s===W){let d=r[e++];for(o=d&127;d&128;)o+=1,d=r[e++],o=(o<<7)+(d&127);o=t-o}else s===ee&&(f=Z(r,e),e+=20);let{result:c,bytesConsumed:l}=await Te(r.subarray(e),a);return{headerOffset:t,typeNum:s,inflated:c,baseOffset:o,baseHash:f,nextOffset:e+l}}var mt=50;async function gr(r,e){let t=new Map;for(let a=0;a<r.length;a++)t.set(r[a].headerOffset,a);let n=new Array(r.length).fill(null);async function s(a,i=0){if(i>mt)throw new Error(`delta chain depth ${i} exceeds limit of ${mt}`);let o=n[a];if(o)return o;let f=r[a];if(f.typeNum!==W&&f.typeNum!==ee){let u=Ot[f.typeNum];if(!u)throw new Error(`Unknown object type: ${f.typeNum}`);let h={type:u,content:f.inflated,hash:await q(u,f.inflated)};return n[a]=h,h}if(f.typeNum===W){let u=t.get(f.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${f.baseOffset}`);let h=await s(u,i+1),m=ge(h.content,f.inflated),g={type:h.type,content:m,hash:await q(h.type,m)};return n[a]=g,g}let c=await xr(r,n,f.baseHash,s),l;if(c!==void 0)l=await s(c,i+1);else if(e){let u=await e(f.baseHash);u&&(l=u)}if(!l)throw new Error(`REF_DELTA base not found for hash ${f.baseHash}`);let d=ge(l.content,f.inflated),p={type:l.type,content:d,hash:await q(l.type,d)};return n[a]=p,p}for(let a=0;a<r.length;a++)await s(a);return n}async function xr(r,e,t,n){for(let s=0;s<e.length;s++)if(e[s]?.hash===t)return s;for(let s=0;s<r.length;s++){let a=r[s];if(a.typeNum!==W&&a.typeNum!==ee&&(await n(s)).hash===t)return s}}var Ue=class{buf=new Uint8Array(0);iter;eof=!1;_bytesRead=0;hasher;constructor(e,t=!1){this.iter=e[Symbol.asyncIterator](),this.hasher=t?G():null}get bytesRead(){return this._bytesRead}async pullMore(){if(this.eof)return!1;let{value:e,done:t}=await this.iter.next();if(t||!e)return this.eof=!0,!1;if(this.buf.byteLength===0)this.buf=new Uint8Array(e);else{let n=new Uint8Array(this.buf.byteLength+e.byteLength);n.set(this.buf),n.set(e,this.buf.byteLength),this.buf=n}return!0}async ensure(e){for(;this.buf.byteLength<e;)if(!await this.pullMore())throw new Error(`Unexpected end of pack data: needed ${e} bytes, have ${this.buf.byteLength}`)}consume(e){let t=new Uint8Array(this.buf.subarray(0,e));return this.hasher?.update(t),this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async readByte(){return await this.ensure(1),this.consume(1)[0]}async readExact(e){return await this.ensure(e),this.consume(e)}async readRaw(e){await this.ensure(e);let t=new Uint8Array(this.buf.subarray(0,e));return this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async inflateNext(e){for(this.buf.byteLength===0&&!this.eof&&await this.pullMore();;)try{let{result:t,bytesConsumed:n}=await Te(this.buf,e);return this.consume(n),t}catch{if(!this.eof&&await this.pullMore())continue;throw new Error(`Failed to inflate pack entry at byte ${this._bytesRead} (expected ${e} bytes)`)}}async hashHex(){if(!this.hasher)throw new Error("Hashing not enabled");return this.hasher.hex()}};async function*vt(r,e){let t=new Ue(r,!0),n=await t.readExact(12),s=new DataView(n.buffer,n.byteOffset,n.byteLength),a=s.getUint32(0);if(a!==z)throw new Error(`Invalid pack signature: 0x${a.toString(16)} (expected 0x${z.toString(16)})`);let i=s.getUint32(4);if(i!==xe)throw new Error(`Unsupported pack version: ${i}`);let o=s.getUint32(8),f=new Map,c=new Map;for(let p=0;p<o;p++){let u=t.bytesRead,h=await t.readByte(),m=h>>4&7,g=h&15,b=4;for(;h&128;)h=await t.readByte(),g|=(h&127)<<b,b+=7;let y,R;if(m===W){let x=await t.readByte();for(y=x&127;x&128;)y+=1,x=await t.readByte(),y=(y<<7)+(x&127);y=u-y}else if(m===ee){let x=await t.readExact(20);R=Z(x,0)}let w=await t.inflateNext(g),P;if(m!==W&&m!==ee){let x=Ot[m];if(!x)throw new Error(`Unknown object type: ${m}`);P={type:x,content:w,hash:await q(x,w)}}else if(m===W){let x=f.get(y);if(!x)throw new Error(`OFS_DELTA base not found at offset ${y}`);let O=ge(x.content,w);P={type:x.type,content:O,hash:await q(x.type,O)}}else{let x=c.get(R);if(!x&&e&&(x=await e(R)??void 0),!x)throw new Error(`REF_DELTA base not found for hash ${R}`);let O=ge(x.content,w);P={type:x.type,content:O,hash:await q(x.type,O)}}f.set(u,P),c.set(P.hash,P),yield P}let l=Z(await t.readRaw(20),0),d=await t.hashHex();if(d!==l)throw new Error(`pack checksum mismatch: expected ${l}, computed ${d}`)}function ge(r,e){let t=0,{value:n,newPos:s}=gt(e,t);if(t=s,n!==r.byteLength)throw new Error(`Delta base size mismatch: expected ${n}, got ${r.byteLength}`);let{value:a,newPos:i}=gt(e,t);t=i;let o=new Uint8Array(a),f=0;for(;t<e.byteLength;){let c=e[t++];if(c&128){let l=0,d=0;c&1&&(l=e[t++]),c&2&&(l|=e[t++]<<8),c&4&&(l|=e[t++]<<16),c&8&&(l|=e[t++]<<24),c&16&&(d=e[t++]),c&32&&(d|=e[t++]<<8),c&64&&(d|=e[t++]<<16),d===0&&(d=65536),o.set(r.subarray(l,l+d),f),f+=d}else if(c>0)o.set(e.subarray(t,t+c),f),f+=c,t+=c;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(f!==a)throw new Error(`Delta produced ${f} bytes, expected ${a}`);return o}async function Re(r){let e=[],t=new Map,n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,xe),s.setUint32(8,r.length),e.push(n);let a=12,i=[];for(let o of r){let f=a;t.set(o.hash,a);let c=o.delta&&o.deltaBaseHash?t.get(o.deltaBaseHash):void 0;if(o.delta&&c!==void 0){let l=Le(W,o.delta.byteLength),d=wr(a-c),p=await me(o.delta);e.push(l,d,p),a+=l.byteLength+d.byteLength+p.byteLength}else{let l=Et[o.type],d=Le(l,o.content.byteLength),p=await me(o.content);e.push(d,p),a+=d.byteLength+p.byteLength}i.push({hash:o.hash,offset:f,nextOffset:a})}return{data:await Rr(e),entries:i}}async function*St(r,e){let t=G(),n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,xe),s.setUint32(8,r),t.update(n),yield n;for await(let a of e){let i=Et[a.type],o=Le(i,a.content.byteLength),f=await me(a.content);t.update(o),t.update(f),yield Pr(o,f)}yield ye(await t.hex())}async function Rr(r){let e=0;for(let i of r)e+=i.byteLength;e+=20;let t=new Uint8Array(e),n=0;for(let i of r)t.set(i,n),n+=i.byteLength;let s=G();s.update(t.subarray(0,n));let a=await s.hex();return t.set(ye(a),n),t}function wr(r){let e=[];e.push(r&127);let t=r>>>7;for(;t>0;)e.unshift(128|--t&127),t>>>=7;return new Uint8Array(e)}function Le(r,e){let t=[],n=r<<4|e&15;for(e>>=4;e>0;)t.push(n|128),n=e&127,e>>=7;return t.push(n),new Uint8Array(t)}function gt(r,e){let t=0,n=0,s;do s=r[e++],t|=(s&127)<<n,n+=7;while(s&128);return{value:t,newPos:e}}function Pr(r,e){let t=new Uint8Array(r.byteLength+e.byteLength);return t.set(r,0),t.set(e,r.byteLength),t}var Or=new TextEncoder;async function q(r,e){let t=Or.encode(`${r} ${e.byteLength}\0`),n=G();return n.update(t),n.update(e),n.hex()}var Er=new TextEncoder,Sn=new TextDecoder;function jt(r,e){let t=Er.encode(`${r} ${e.byteLength}\0`),n=new Uint8Array(t.byteLength+e.byteLength);return n.set(t),n.set(e,t.byteLength),n}function te(r){let e=r.indexOf("<"),t=r.indexOf(">");if(e===-1||t===-1)throw new Error(`Malformed identity line: "${r}"`);let n=r.slice(0,e).trimEnd(),s=r.slice(e+1,t),a=r.slice(t+2),[i="0",o="+0000"]=a.split(" "),f=parseInt(i,10);return{name:n,email:s,timestamp:f,timezone:o}}var Tn=new TextEncoder,vr=new TextDecoder;function re(r){let e=vr.decode(r),t=e.indexOf(`
1
+ var ue=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});function T(r){return r!=null&&typeof r=="object"&&"reject"in r&&r.reject===!0}var ke="0000000000000000000000000000000000000000",st=(()=>{let r=new Array(256);for(let e=0;e<256;e++)r[e]=(e>>4).toString(16)+(e&15).toString(16);return r})();function he(r){let e="";for(let t=0;t<20;t++)e+=st[r[t]];return e}function Z(r,e){let t="";for(let n=0;n<20;n++)t+=st[r[e+n]];return t}function ye(r){let e=new Uint8Array(20);for(let t=0;t<20;t++)e[t]=parseInt(r.slice(t*2,t*2+2),16);return e}var or=new TextEncoder;function ve(r){return typeof r=="string"?or.encode(r):r}function ir(){if(typeof globalThis.Bun<"u")return()=>{let r=new Bun.CryptoHasher("sha1"),e={update(t){return r.update(ve(t)),e},hex:()=>Promise.resolve(r.digest("hex"))};return e};try{let r=ue(["node","crypto"].join(":"));if(typeof r.createHash=="function")return()=>{let e=r.createHash("sha1"),t={update(n){return e.update(ve(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t}}catch{}if(typeof globalThis.crypto?.subtle?.digest=="function")return()=>{let r=[],e={update(t){return r.push(ve(t)),e},async hex(){let t=0;for(let i of r)t+=i.byteLength;let n=new Uint8Array(t),s=0;for(let i of r)n.set(i,s),s+=i.byteLength;let a=await crypto.subtle.digest("SHA-1",n);return he(new Uint8Array(a))}};return e};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}var at=ir(),G=at;async function ot(r){return at().update(r).hex()}var cr=new Set(["tree","commit","tag"]),be=class{map=new Map;currentBytes=0;maxBytes;constructor(e=16*1024*1024){this.maxBytes=e}get(e){return this.map.get(e)}set(e,t){if(!cr.has(t.type))return;let n=t.content.byteLength;if(!(n>this.maxBytes/2)&&!this.map.has(e)){for(;this.currentBytes+n>this.maxBytes&&this.map.size>0;){let s=this.map.keys().next().value;this.currentBytes-=this.map.get(s).content.byteLength,this.map.delete(s)}this.map.set(e,t),this.currentBytes+=n}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}};var L=Uint8Array,F=Uint16Array,fr=Int32Array,it=new L([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,0,0,0]),ct=new L([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,0,0]),lr=new L([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ft=(r,e)=>{let t=new F(31);for(let s=0;s<31;++s)t[s]=e+=1<<r[s-1];let n=new fr(t[30]);for(let s=1;s<30;++s)for(let a=t[s];a<t[s+1];++a)n[a]=a-t[s]<<5|s;return{b:t,r:n}},{b:lt}=ft(it,2);lt[28]=258;var{b:dr}=ft(ct,0),Ae=new F(32768);for(let r=0;r<32768;++r){let e=(r&43690)>>1|(r&21845)<<1;e=(e&52428)>>2|(e&13107)<<2,e=(e&61680)>>4|(e&3855)<<4,Ae[r]=((e&65280)>>8|(e&255)<<8)>>1}var J=(r,e,t)=>{let n=r.length,s=0,a=new F(e);for(;s<n;++s)r[s]&&++a[r[s]-1];let i=new F(e);for(s=1;s<e;++s)i[s]=i[s-1]+a[s-1]<<1;let o;if(t){o=new F(1<<e);let f=15-e;for(s=0;s<n;++s)if(r[s]){let c=s<<4|r[s],l=e-r[s],d=i[r[s]-1]++<<l;for(let p=d|(1<<l)-1;d<=p;++d)o[Ae[d]>>f]=c}}else for(o=new F(n),s=0;s<n;++s)r[s]&&(o[s]=Ae[i[r[s]-1]++]>>15-r[s]);return o},Q=new L(288);for(let r=0;r<144;++r)Q[r]=8;for(let r=144;r<256;++r)Q[r]=9;for(let r=256;r<280;++r)Q[r]=7;for(let r=280;r<288;++r)Q[r]=8;var dt=new L(32);for(let r=0;r<32;++r)dt[r]=5;var pr=J(Q,9,1),ur=J(dt,5,1),Se=r=>{let e=r[0];for(let t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},U=(r,e,t)=>{let n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},je=(r,e)=>{let t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},pt=r=>(r+7)/8|0,hr=(r,e,t)=>((e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new L(r.subarray(e,t))),H=(r,e)=>{let t=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(e||t[r]||"unknown inflate error")},ut=(r,e,t,n)=>{let s=r.length,a=n?n.length:0;if(!s||e.f&&!e.l)return t||new L(0);let i=!t,o=i||e.i!=2,f=e.i;i&&(t=new L(s*3));let c=y=>{let R=t.length;if(y>R){let w=new L(Math.max(R*2,y));w.set(t),t=w}},l=e.f||0,d=e.p||0,p=e.b||0,u=e.l,h=e.d,m=e.m,g=e.n,b=s*8;do{if(!u){l=U(r,d,1);let P=U(r,d+1,3);if(d+=3,P)if(P==1)u=pr,h=ur,m=9,g=5;else if(P==2){let x=U(r,d,31)+257,O=U(r,d+10,15)+4,S=x+U(r,d+5,31)+1;d+=14;let E=new L(S),j=new L(19);for(let N=0;N<O;++N)j[lr[N]]=U(r,d+N*3,7);d+=O*3;let M=Se(j),I=(1<<M)-1,C=J(j,M,1);for(let N=0;N<S;){let rt=C[U(r,d,I)];d+=rt&15;let V=rt>>4;if(V<16)E[N++]=V;else{let nt=0,pe=0;for(V==16?(pe=3+U(r,d,3),d+=2,nt=E[N-1]):V==17?(pe=3+U(r,d,7),d+=3):V==18&&(pe=11+U(r,d,127),d+=7);pe--;)E[N++]=nt}}let $=E.subarray(0,x),tt=E.subarray(x);m=Se($),g=Se(tt),u=J($,m,1),h=J(tt,g,1)}else H(1);else{let x=pt(d)+4,O=r[x-4]|r[x-3]<<8,S=x+O;if(S>s){f&&H(0);break}o&&c(p+O),t.set(r.subarray(x,S),p),e.b=p+=O,e.p=d=S*8,e.f=l;continue}if(d>b){f&&H(0);break}}o&&c(p+131072);let y=(1<<m)-1,R=(1<<g)-1,w=d;for(;;w=d){let P=u[je(r,d)&y],x=P>>4;if(d+=P&15,d>b){f&&H(0);break}if(P||H(2),x<256)t[p++]=x;else if(x==256){w=d,u=null;break}else{let O=x-254;if(x>264){let I=x-257,C=it[I];O=U(r,d,(1<<C)-1)+lt[I],d+=C}let S=h[je(r,d)&R],E=S>>4;S||H(3),d+=S&15;let j=dr[E];if(E>3){let I=ct[E];j+=je(r,d)&(1<<I)-1,d+=I}if(d>b){f&&H(0);break}o&&c(p+131072);let M=p+O;if(p<j){let I=a-j,C=Math.min(j,M);for(I+p<0&&H(3);p<C;++p)t[p]=n[I+p]}for(;p<M;++p)t[p]=t[p-j]}}e.l=u,e.p=w,e.b=p,e.f=l,u&&(l=1,e.m=m,e.d=h,e.n=g)}while(!l);return p!=t.length&&i?hr(t,0,p):t.subarray(0,p)},ht=r=>(((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&H(0,"invalid zlib data"),r[1]&32&&H(0,"zlib dictionaries are not supported"),2);function yt(r){let e=ht(r);return ut(r.subarray(e,-4),{i:2})}function Ie(r){let e=ht(r),t={i:2},n=ut(r.subarray(e),t),s=pt(t.p);return{result:n,bytesConsumed:e+s+4}}async function yr(){let r;if(!(typeof document<"u"))try{r=ue(["node","zlib"].join(":"))}catch{try{r=await import(["node","zlib"].join(":"))}catch{}}if(r&&typeof r.deflateSync=="function"&&typeof r.inflateSync=="function"){let n=null;try{let s=r.inflateSync(r.deflateSync(Buffer.from("x")),{info:!0});s?.engine&&typeof s.engine.bytesWritten=="number"&&(n=a=>{let i=r.inflateSync(a,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:s=>new Uint8Array(r.deflateSync(s)),inflateSync:s=>new Uint8Array(r.inflateSync(s)),inflateWithConsumed:n??Ie}}let t;return typeof globalThis.CompressionStream=="function"?t=async n=>{let s=new CompressionStream("deflate"),a=s.writable.getWriter();return a.write(n),a.close(),new Uint8Array(await new Response(s.readable).arrayBuffer())}:t=()=>{throw new Error("No deflate implementation available. Requires node:zlib or CompressionStream.")},{deflateSync:t,inflateSync:yt,inflateWithConsumed:Ie}}var br=null;function bt(){return br??=yr()}async function me(r){return await(await bt()).deflateSync(r)}async function Te(r,e){let t=await bt(),{result:n,bytesConsumed:s}=t.inflateWithConsumed(r);if(n.byteLength!==e)throw new Error(`Inflate size mismatch: got ${n.byteLength}, expected ${e}`);return{result:n,bytesConsumed:s}}var z=1346454347,xe=2,xt=1,Rt=2,wt=3,Pt=4,W=6,ee=7,Ot={[xt]:"commit",[Rt]:"tree",[wt]:"blob",[Pt]:"tag"},Et={commit:xt,tree:Rt,blob:wt,tag:Pt};async function kt(r,e){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=t.getUint32(0);if(n!==z)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${z.toString(16)})`);let s=t.getUint32(4);if(s!==xe)throw new Error(`Unsupported pack version: ${s}`);if(r.byteLength>=32){let c=Z(r,r.byteLength-20),l=G();l.update(r.subarray(0,r.byteLength-20));let d=await l.hex();if(d!==c)throw new Error(`pack checksum mismatch: expected ${c}, computed ${d}`)}let a=t.getUint32(8),i=[],o=12;for(let c=0;c<a;c++){let l=await mr(r,o);i.push(l),o=l.nextOffset}return(await gr(i,e)).map((c,l)=>({...c,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function mr(r,e){let t=e,n=r[e++],s=n>>4&7,a=n&15,i=4;for(;n&128;)n=r[e++],a|=(n&127)<<i,i+=7;let o,f;if(s===W){let d=r[e++];for(o=d&127;d&128;)o+=1,d=r[e++],o=(o<<7)+(d&127);o=t-o}else s===ee&&(f=Z(r,e),e+=20);let{result:c,bytesConsumed:l}=await Te(r.subarray(e),a);return{headerOffset:t,typeNum:s,inflated:c,baseOffset:o,baseHash:f,nextOffset:e+l}}var mt=50;async function gr(r,e){let t=new Map;for(let a=0;a<r.length;a++)t.set(r[a].headerOffset,a);let n=new Array(r.length).fill(null);async function s(a,i=0){if(i>mt)throw new Error(`delta chain depth ${i} exceeds limit of ${mt}`);let o=n[a];if(o)return o;let f=r[a];if(f.typeNum!==W&&f.typeNum!==ee){let u=Ot[f.typeNum];if(!u)throw new Error(`Unknown object type: ${f.typeNum}`);let h={type:u,content:f.inflated,hash:await q(u,f.inflated)};return n[a]=h,h}if(f.typeNum===W){let u=t.get(f.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${f.baseOffset}`);let h=await s(u,i+1),m=ge(h.content,f.inflated),g={type:h.type,content:m,hash:await q(h.type,m)};return n[a]=g,g}let c=await xr(r,n,f.baseHash,s),l;if(c!==void 0)l=await s(c,i+1);else if(e){let u=await e(f.baseHash);u&&(l=u)}if(!l)throw new Error(`REF_DELTA base not found for hash ${f.baseHash}`);let d=ge(l.content,f.inflated),p={type:l.type,content:d,hash:await q(l.type,d)};return n[a]=p,p}for(let a=0;a<r.length;a++)await s(a);return n}async function xr(r,e,t,n){for(let s=0;s<e.length;s++)if(e[s]?.hash===t)return s;for(let s=0;s<r.length;s++){let a=r[s];if(a.typeNum!==W&&a.typeNum!==ee&&(await n(s)).hash===t)return s}}var Ue=class{buf=new Uint8Array(0);iter;eof=!1;_bytesRead=0;hasher;constructor(e,t=!1){this.iter=e[Symbol.asyncIterator](),this.hasher=t?G():null}get bytesRead(){return this._bytesRead}async pullMore(){if(this.eof)return!1;let{value:e,done:t}=await this.iter.next();if(t||!e)return this.eof=!0,!1;if(this.buf.byteLength===0)this.buf=new Uint8Array(e);else{let n=new Uint8Array(this.buf.byteLength+e.byteLength);n.set(this.buf),n.set(e,this.buf.byteLength),this.buf=n}return!0}async ensure(e){for(;this.buf.byteLength<e;)if(!await this.pullMore())throw new Error(`Unexpected end of pack data: needed ${e} bytes, have ${this.buf.byteLength}`)}consume(e){let t=new Uint8Array(this.buf.subarray(0,e));return this.hasher?.update(t),this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async readByte(){return await this.ensure(1),this.consume(1)[0]}async readExact(e){return await this.ensure(e),this.consume(e)}async readRaw(e){await this.ensure(e);let t=new Uint8Array(this.buf.subarray(0,e));return this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async inflateNext(e){for(this.buf.byteLength===0&&!this.eof&&await this.pullMore();;)try{let{result:t,bytesConsumed:n}=await Te(this.buf,e);return this.consume(n),t}catch{if(!this.eof&&await this.pullMore())continue;throw new Error(`Failed to inflate pack entry at byte ${this._bytesRead} (expected ${e} bytes)`)}}async hashHex(){if(!this.hasher)throw new Error("Hashing not enabled");return this.hasher.hex()}};async function*vt(r,e){let t=new Ue(r,!0),n=await t.readExact(12),s=new DataView(n.buffer,n.byteOffset,n.byteLength),a=s.getUint32(0);if(a!==z)throw new Error(`Invalid pack signature: 0x${a.toString(16)} (expected 0x${z.toString(16)})`);let i=s.getUint32(4);if(i!==xe)throw new Error(`Unsupported pack version: ${i}`);let o=s.getUint32(8),f=new Map,c=new Map;for(let p=0;p<o;p++){let u=t.bytesRead,h=await t.readByte(),m=h>>4&7,g=h&15,b=4;for(;h&128;)h=await t.readByte(),g|=(h&127)<<b,b+=7;let y,R;if(m===W){let x=await t.readByte();for(y=x&127;x&128;)y+=1,x=await t.readByte(),y=(y<<7)+(x&127);y=u-y}else if(m===ee){let x=await t.readExact(20);R=Z(x,0)}let w=await t.inflateNext(g),P;if(m!==W&&m!==ee){let x=Ot[m];if(!x)throw new Error(`Unknown object type: ${m}`);P={type:x,content:w,hash:await q(x,w)}}else if(m===W){let x=f.get(y);if(!x)throw new Error(`OFS_DELTA base not found at offset ${y}`);let O=ge(x.content,w);P={type:x.type,content:O,hash:await q(x.type,O)}}else{let x=c.get(R);if(!x&&e&&(x=await e(R)??void 0),!x)throw new Error(`REF_DELTA base not found for hash ${R}`);let O=ge(x.content,w);P={type:x.type,content:O,hash:await q(x.type,O)}}f.set(u,P),c.set(P.hash,P),yield P}let l=Z(await t.readRaw(20),0),d=await t.hashHex();if(d!==l)throw new Error(`pack checksum mismatch: expected ${l}, computed ${d}`)}function ge(r,e){let t=0,{value:n,newPos:s}=gt(e,t);if(t=s,n!==r.byteLength)throw new Error(`Delta base size mismatch: expected ${n}, got ${r.byteLength}`);let{value:a,newPos:i}=gt(e,t);t=i;let o=new Uint8Array(a),f=0;for(;t<e.byteLength;){let c=e[t++];if(c&128){let l=0,d=0;c&1&&(l=e[t++]),c&2&&(l|=e[t++]<<8),c&4&&(l|=e[t++]<<16),c&8&&(l|=e[t++]<<24),c&16&&(d=e[t++]),c&32&&(d|=e[t++]<<8),c&64&&(d|=e[t++]<<16),d===0&&(d=65536),o.set(r.subarray(l,l+d),f),f+=d}else if(c>0)o.set(e.subarray(t,t+c),f),f+=c,t+=c;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(f!==a)throw new Error(`Delta produced ${f} bytes, expected ${a}`);return o}async function Re(r){let e=[],t=new Map,n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,xe),s.setUint32(8,r.length),e.push(n);let a=12,i=[];for(let o of r){let f=a;t.set(o.hash,a);let c=o.delta&&o.deltaBaseHash?t.get(o.deltaBaseHash):void 0;if(o.delta&&c!==void 0){let l=Le(W,o.delta.byteLength),d=wr(a-c),p=await me(o.delta);e.push(l,d,p),a+=l.byteLength+d.byteLength+p.byteLength}else{let l=Et[o.type],d=Le(l,o.content.byteLength),p=await me(o.content);e.push(d,p),a+=d.byteLength+p.byteLength}i.push({hash:o.hash,offset:f,nextOffset:a})}return{data:await Rr(e),entries:i}}async function*St(r,e){let t=G(),n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,xe),s.setUint32(8,r),t.update(n),yield n;for await(let a of e){let i=Et[a.type],o=Le(i,a.content.byteLength),f=await me(a.content);t.update(o),t.update(f),yield Pr(o,f)}yield ye(await t.hex())}async function Rr(r){let e=0;for(let i of r)e+=i.byteLength;e+=20;let t=new Uint8Array(e),n=0;for(let i of r)t.set(i,n),n+=i.byteLength;let s=G();s.update(t.subarray(0,n));let a=await s.hex();return t.set(ye(a),n),t}function wr(r){let e=[];e.push(r&127);let t=r>>>7;for(;t>0;)e.unshift(128|--t&127),t>>>=7;return new Uint8Array(e)}function Le(r,e){let t=[],n=r<<4|e&15;for(e>>=4;e>0;)t.push(n|128),n=e&127,e>>=7;return t.push(n),new Uint8Array(t)}function gt(r,e){let t=0,n=0,s;do s=r[e++],t|=(s&127)<<n,n+=7;while(s&128);return{value:t,newPos:e}}function Pr(r,e){let t=new Uint8Array(r.byteLength+e.byteLength);return t.set(r,0),t.set(e,r.byteLength),t}var Or=new TextEncoder;async function q(r,e){let t=Or.encode(`${r} ${e.byteLength}\0`),n=G();return n.update(t),n.update(e),n.hex()}var Er=new TextEncoder,Sn=new TextDecoder;function jt(r,e){let t=Er.encode(`${r} ${e.byteLength}\0`),n=new Uint8Array(t.byteLength+e.byteLength);return n.set(t),n.set(e,t.byteLength),n}function te(r){let e=r.indexOf("<"),t=r.indexOf(">");if(e===-1||t===-1)throw new Error(`Malformed identity line: "${r}"`);let n=r.slice(0,e).trimEnd(),s=r.slice(e+1,t),a=r.slice(t+2),[i="0",o="+0000"]=a.split(" "),f=parseInt(i,10);return{name:n,email:s,timestamp:f,timezone:o}}var Tn=new TextEncoder,vr=new TextDecoder;function re(r){let e=vr.decode(r),t=e.indexOf(`
2
2
 
3
3
  `),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),a="",i=[],o,f;for(let c of n.split(`
4
4
  `)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),p=c.slice(l+1);switch(d){case"tree":a=p;break;case"parent":i.push(p);break;case"author":o=te(p);break;case"committer":f=te(p);break}}if(!a)throw new Error("Commit missing tree field");if(!o)throw new Error("Commit missing author field");if(!f)throw new Error("Commit missing committer field");return{type:"commit",tree:a,parents:i,author:o,committer:f,message:s}}var Cn=new TextEncoder,Sr=new TextDecoder;function _(r){let e=Sr.decode(r),t=e.indexOf(`
5
5
 
6
6
  `),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),a="",i="commit",o="",f;for(let c of n.split(`
7
- `)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),p=c.slice(l+1);switch(d){case"object":a=p;break;case"type":i=p;break;case"tag":o=p;break;case"tagger":f=te(p);break}}if(!a)throw new Error("Tag missing object field");if(!o)throw new Error("Tag missing tag name field");if(!f)throw new Error("Tag missing tagger field");return{type:"tag",object:a,objectType:i,name:o,tagger:f,message:s}}async function ne(r,e){return r.objectStore.read(e)}async function se(r,e){return r.objectStore.exists(e)}var Nn=new TextDecoder;async function X(r,e){let t=await ne(r,e);if(t.type!=="commit")throw new Error(`Expected commit object for ${e}, got ${t.type}`);return re(t.content)}function At(r){return typeof r=="string"?{type:"direct",hash:r}:r}var Ce=".lock";var jr=[1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,5,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,4,4];function Ar(r,e,t){let n=0,s=!1,a=e;for(;a<r.length;a++){let o=r.charCodeAt(a);switch(o<128?jr[o]:0){case 1:break;case 2:if(n===46)return{len:-1,starConsumed:s};n=o;continue;case 3:if(n===64)return{len:-1,starConsumed:s};n=o;continue;case 4:return{len:-1,starConsumed:s};case 5:if(!t)return{len:-1,starConsumed:s};s=!0,n=o;continue;default:n=o;continue}break}let i=a-e;return i===0?{len:0,starConsumed:s}:r.charCodeAt(e)===46?{len:-1,starConsumed:s}:i>=Ce.length&&r.slice(a-Ce.length,a)===Ce?{len:-1,starConsumed:s}:{len:i,starConsumed:s}}function It(r,e=0){if(r==="@"||r.length===0)return!1;let t=0,n=0,s=!!(e&2);for(;t<=r.length;){let{len:a,starConsumed:i}=Ar(r,t,s);if(a<0||a===0)return!1;i&&(s=!1),n++,t+=a+1}return!(r.charCodeAt(r.length-1)===46||!(e&1)&&n<2)}var _n=new TextEncoder,Tt=new TextDecoder,Ir=new Set(["100644","100755","040000","120000","160000"]);function Tr(r){return r.length===4&&r.toLowerCase()===".git"}function Ur(r,e){if(r.length===0)throw new Error("invalid tree entry: empty name");if(r.includes("/"))throw new Error(`invalid tree entry: name contains slash: '${r}'`);if(r.includes("\0"))throw new Error("invalid tree entry: name contains null byte");if(r==="."||r==="..")throw new Error(`invalid tree entry: '${r}'`);if(Tr(r))throw new Error(`invalid tree entry: '${r}'`);if(!Ir.has(e))throw new Error(`invalid tree entry mode: '${e}' for '${r}'`)}function De(r){let e=[],t=0;for(;t<r.byteLength;){let n=r.indexOf(32,t);if(n===-1)break;let s=Tt.decode(r.subarray(t,n)),a=r.indexOf(0,n+1);if(a===-1)break;let i=Tt.decode(r.subarray(n+1,a)),o=r.subarray(a+1,a+21),f=he(o),c=s.padStart(6,"0");Ur(i,c),e.push({mode:c,name:i,hash:f}),t=a+21}return{type:"tree",entries:e}}async function Ut(r,e,t){if(e===t)return!0;let n=new Set,s=[t],a=0;for(;a<s.length;){let i=s[a++];if(i===e)return!0;if(n.has(i))continue;n.add(i);let o;try{o=await X(r,i)}catch{continue}for(let f of o.parents)n.has(f)||s.push(f)}return!1}var Pe=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),Lr=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),we=64,Cr=4,He=4096,Lt=65536,Dr=127;function Hr(r){let e=r.byteLength;if(e===0)return null;let t=(e-1)/16|0;if(t===0)return null;let n=t>>>2;n<16&&(n=16),n=Br(n);let s=n-1,a=new Uint32Array(n),i=[],o=-1>>>0;for(let p=t*16-16;p>=0;p-=16){let u=0;for(let h=1;h<=16;h++)u=(u<<8|r[p+h])^Pe[u>>>23];if(u=u>>>0,u===o)i[i.length-1].ptr=p+16;else{o=u;let h=u&s;i.push({ptr:p+16,val:u}),a[h]++}}let f=new Map;for(let p of i){let u=p.val&s,h=f.get(u);h||(h=[],f.set(u,h)),h.push(p)}for(let[p,u]of f){if(u.length<=we)continue;let h=[],m=u.length/we;for(let g=0;g<we;g++)h.push(u[Math.floor(g*m)]);f.set(p,h),a[p]=we}let c=new Uint32Array(n+1),l=[],d=0;for(let p=0;p<n;p++){c[p]=d;let u=f.get(p);if(u){for(let h of u)l.push(h);d+=u.length}}return c[n]=d,{src:r,hashMask:s,buckets:c,entries:l}}function Nr(r,e,t){if(!r||e.byteLength===0)return null;let n=r.src.byteLength,s=e.byteLength,a=r.src,i=new Uint8Array(Math.max(s,1024)),o=0;function f(m){for(;o+m>i.length;){let g=new Uint8Array(i.length*2);g.set(i),i=g}}o=Dt(i,o,n),o=Dt(i,o,s),f(18),o++;let c=0,l=0,d=Math.min(16,s);for(let m=0;m<d;m++)i[o++]=e[m],c=(c<<8|e[m])^Pe[c>>>23],l++;c=c>>>0;let p=d,u=0,h=0;for(;p<s;){if(h<He){c^=Lr[e[p-16]],c=((c<<8|e[p])^Pe[c>>>23])>>>0;let m=c&r.hashMask,g=r.buckets[m],b=r.buckets[m+1];for(let y=g;y<b;y++){let R=r.entries[y];if(R.val!==c)continue;let w=R.ptr,P=a.byteLength-w,x=s-p;if(P>x&&(P=x),P<=h)break;let O=0;for(;O<P&&a[w+O]===e[p+O];)O++;if(O>h&&(h=O,u=w,h>=He))break}}if(h<Cr)f(2),l===0&&o++,i[o++]=e[p++],l++,l===Dr&&(i[o-l-1]=l,l=0),h=0;else{if(l>0){for(;u>0&&a[u-1]===e[p-1];)if(h++,u--,p--,o--,!(--l>0)){o--,l=-1;break}l>0&&(i[o-l-1]=l),l=0}let m=h>Lt?h-Lt:0;h-=m,f(8);let g=o++,b=128;if(u&255&&(i[o++]=u&255,b|=1),u&65280&&(i[o++]=u>>>8&255,b|=2),u&16711680&&(i[o++]=u>>>16&255,b|=4),u&4278190080&&(i[o++]=u>>>24&255,b|=8),h&255&&(i[o++]=h&255,b|=16),h&65280&&(i[o++]=h>>>8&255,b|=32),i[g]=b,p+=h,u+=h,h=m,u>4294967295&&(h=0),h<He){c=0;for(let y=-16;y<0;y++)c=(c<<8|e[p+y])^Pe[c>>>23];c=c>>>0}}if(t&&o>t)return null}return l>0&&(i[o-l-1]=l),t&&o>t?null:i.subarray(0,o)}var Ct={blob:0,tree:1,commit:2,tag:3};function Ht(r,e){let t=e?.window??10,n=e?.depth??50,s=r.slice().sort((c,l)=>{let d=Ct[c.type]??99,p=Ct[l.type]??99;return d!==p?d-p:l.content.byteLength-c.content.byteLength}),a=new Map,i=[],o=[],f=[];for(let c=0;c<s.length;c++){let l=s[c],d={hash:l.hash,type:l.type,content:l.content,depth:0},p=null,u=null,h=Math.max(0,c-t);for(let m=c-1;m>=h;m--){let g=s[m];if(g.type!==l.type||(a.get(g.hash)?.depth??0)>=n||l.content.byteLength<g.content.byteLength>>>5)continue;let R=o[m-h]??null;if(!R)continue;let w=p?p.byteLength:l.content.byteLength/2|0;if(w<16)continue;let P=Nr(R,l.content,w);P&&(!p||P.byteLength<p.byteLength)&&(p=P,u=g.hash)}if(p&&u){d.delta=p,d.deltaBase=u;let m=a.get(u);d.depth=(m?.depth??0)+1}a.set(l.hash,d),i.push(d),o.length>=t&&(o.shift(),f.shift()),o.push(Hr(l.content)),f.push(l.hash)}return i}function Br(r){let e=r;return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e<16?16:e}function Dt(r,e,t){let n=t;do{let s=n&127;n>>>=7,n>0&&(s|=128),r[e++]=s}while(n>0);return e}var Mr=2147483647;async function Nt(r,e,t,n){if(t>=Mr)return{shallow:[],unshallow:[...n]};let s=new Map,a=[];for(let c of e)!s.has(c)&&await se(r,c)&&(s.set(c,1),a.push({hash:c,level:1}));let i=new Set,o=0;for(;o<a.length;){let{hash:c,level:l}=a[o++];if(l>=t){i.add(c);continue}let d;try{d=await X(r,c)}catch{continue}for(let p of d.parents)!s.has(p)&&await se(r,p)&&(s.set(p,l+1),a.push({hash:p,level:l+1}))}let f=[];for(let c of n){let l=s.get(c);l!==void 0&&l<t&&f.push(c)}return{shallow:[...i],unshallow:f}}async function Ne(r,e,t,n,s){let a=s??n,i=new Set;for(let l of t)await ae(r,l,i,a);let o=[...e];if(s&&n)for(let l of s)try{let d=await X(r,l);for(let p of d.parents)i.has(p)||o.push(p)}catch{}let f=[],c=new Set;for(let l of o)await oe(r,l,i,c,f,n);return{count:f.length,objects:$r(f)}}async function Bt(r,e,t,n,s){let{count:a,objects:i}=await Ne(r,e,t,n,s);return{count:a,objects:Wr(r,i)}}async function*$r(r){for(let e of r)yield e}async function*Wr(r,e){for await(let t of e){let n=await ne(r,t.hash);yield{hash:t.hash,type:t.type,content:n.content}}}async function Mt(r){let e=[];for await(let t of r.objects)e.push(t);return e}async function ae(r,e,t,n){if(t.has(e)||(t.add(e),!await se(r,e)))return;let s=await ne(r,e);switch(s.type){case"commit":{let a=re(s.content);if(await ae(r,a.tree,t,n),!n?.has(e))for(let i of a.parents)await ae(r,i,t,n);break}case"tree":{let a=De(s.content);for(let i of a.entries)await ae(r,i.hash,t,n);break}case"tag":{let a=_(s.content);await ae(r,a.object,t,n);break}case"blob":break}}async function oe(r,e,t,n,s,a){if(n.has(e)||t.has(e))return;n.add(e);let i=await ne(r,e);switch(s.push({hash:e,type:i.type}),i.type){case"commit":{let o=re(i.content);if(await oe(r,o.tree,t,n,s,a),!a?.has(e))for(let f of o.parents)await oe(r,f,t,n,s,a);break}case"tree":{let o=De(i.content);for(let f of o.entries)await oe(r,f.hash,t,n,s,a);break}case"tag":{let o=_(i.content);await oe(r,o.object,t,n,s,a);break}case"blob":break}}var _r=new TextEncoder,Wt=new TextDecoder,$t=65520,Gr=new Uint8Array([48,48,48,48]);function k(r){let e=typeof r=="string"?_r.encode(r):r,t=4+e.byteLength;if(t>$t)throw new Error(`pkt-line too long: ${t} bytes (max ${$t})`);let n=t.toString(16).padStart(4,"0"),s=new Uint8Array(t);return s[0]=n.charCodeAt(0),s[1]=n.charCodeAt(1),s[2]=n.charCodeAt(2),s[3]=n.charCodeAt(3),s.set(e,4),s}function H(){return Gr.slice()}function B(...r){let e=0;for(let s of r)e+=s.byteLength;let t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}function _t(r){let e=[],t=0;for(;t<r.byteLength;){if(t+4>r.byteLength)throw new Error("Truncated pkt-line header");let n=Wt.decode(r.subarray(t,t+4)),s=parseInt(n,16);if(Number.isNaN(s))throw new Error(`Invalid pkt-line length: ${n}`);if(s===0){e.push({type:"flush"}),t+=4;continue}if(s<4)throw new Error(`Invalid pkt-line length: ${s}`);if(t+s>r.byteLength)throw new Error(`Truncated pkt-line: need ${s} bytes at offset ${t}, have ${r.byteLength-t}`);e.push({type:"data",data:r.subarray(t+4,t+s)}),t+=s}return e}function Gt(r){if(r.type==="flush")return"";let e=Wt.decode(r.data);return e.endsWith(`
7
+ `)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),p=c.slice(l+1);switch(d){case"object":a=p;break;case"type":i=p;break;case"tag":o=p;break;case"tagger":f=te(p);break}}if(!a)throw new Error("Tag missing object field");if(!o)throw new Error("Tag missing tag name field");if(!f)throw new Error("Tag missing tagger field");return{type:"tag",object:a,objectType:i,name:o,tagger:f,message:s}}async function ne(r,e){return r.objectStore.read(e)}async function se(r,e){return r.objectStore.exists(e)}var Nn=new TextDecoder;async function X(r,e){let t=await ne(r,e);if(t.type!=="commit")throw new Error(`Expected commit object for ${e}, got ${t.type}`);return re(t.content)}function At(r){return typeof r=="string"?{type:"direct",hash:r}:r}var Ce=".lock";var jr=[1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,5,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,4,4];function Ar(r,e,t){let n=0,s=!1,a=e;for(;a<r.length;a++){let o=r.charCodeAt(a);switch(o<128?jr[o]:0){case 1:break;case 2:if(n===46)return{len:-1,starConsumed:s};n=o;continue;case 3:if(n===64)return{len:-1,starConsumed:s};n=o;continue;case 4:return{len:-1,starConsumed:s};case 5:if(!t)return{len:-1,starConsumed:s};s=!0,n=o;continue;default:n=o;continue}break}let i=a-e;return i===0?{len:0,starConsumed:s}:r.charCodeAt(e)===46?{len:-1,starConsumed:s}:i>=Ce.length&&r.slice(a-Ce.length,a)===Ce?{len:-1,starConsumed:s}:{len:i,starConsumed:s}}function It(r,e=0){if(r==="@"||r.length===0)return!1;let t=0,n=0,s=!!(e&2);for(;t<=r.length;){let{len:a,starConsumed:i}=Ar(r,t,s);if(a<0||a===0)return!1;i&&(s=!1),n++,t+=a+1}return!(r.charCodeAt(r.length-1)===46||!(e&1)&&n<2)}var _n=new TextEncoder,Tt=new TextDecoder,Ir=new Set(["100644","100755","040000","120000","160000"]);function Tr(r){return r.length===4&&r.toLowerCase()===".git"}function Ur(r,e){if(r.length===0)throw new Error("invalid tree entry: empty name");if(r.includes("/"))throw new Error(`invalid tree entry: name contains slash: '${r}'`);if(r.includes("\0"))throw new Error("invalid tree entry: name contains null byte");if(r==="."||r==="..")throw new Error(`invalid tree entry: '${r}'`);if(Tr(r))throw new Error(`invalid tree entry: '${r}'`);if(!Ir.has(e))throw new Error(`invalid tree entry mode: '${e}' for '${r}'`)}function He(r){let e=[],t=0;for(;t<r.byteLength;){let n=r.indexOf(32,t);if(n===-1)break;let s=Tt.decode(r.subarray(t,n)),a=r.indexOf(0,n+1);if(a===-1)break;let i=Tt.decode(r.subarray(n+1,a)),o=r.subarray(a+1,a+21),f=he(o),c=s.padStart(6,"0");Ur(i,c),e.push({mode:c,name:i,hash:f}),t=a+21}return{type:"tree",entries:e}}async function Ut(r,e,t){if(e===t)return!0;let n=new Set,s=[t],a=0;for(;a<s.length;){let i=s[a++];if(i===e)return!0;if(n.has(i))continue;n.add(i);let o;try{o=await X(r,i)}catch{continue}for(let f of o.parents)n.has(f)||s.push(f)}return!1}var Pe=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),Lr=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),we=64,Cr=4,De=4096,Lt=65536,Hr=127;function Dr(r){let e=r.byteLength;if(e===0)return null;let t=(e-1)/16|0;if(t===0)return null;let n=t>>>2;n<16&&(n=16),n=Br(n);let s=n-1,a=new Uint32Array(n),i=[],o=-1>>>0;for(let p=t*16-16;p>=0;p-=16){let u=0;for(let h=1;h<=16;h++)u=(u<<8|r[p+h])^Pe[u>>>23];if(u=u>>>0,u===o)i[i.length-1].ptr=p+16;else{o=u;let h=u&s;i.push({ptr:p+16,val:u}),a[h]++}}let f=new Map;for(let p of i){let u=p.val&s,h=f.get(u);h||(h=[],f.set(u,h)),h.push(p)}for(let[p,u]of f){if(u.length<=we)continue;let h=[],m=u.length/we;for(let g=0;g<we;g++)h.push(u[Math.floor(g*m)]);f.set(p,h),a[p]=we}let c=new Uint32Array(n+1),l=[],d=0;for(let p=0;p<n;p++){c[p]=d;let u=f.get(p);if(u){for(let h of u)l.push(h);d+=u.length}}return c[n]=d,{src:r,hashMask:s,buckets:c,entries:l}}function Nr(r,e,t){if(!r||e.byteLength===0)return null;let n=r.src.byteLength,s=e.byteLength,a=r.src,i=new Uint8Array(Math.max(s,1024)),o=0;function f(m){for(;o+m>i.length;){let g=new Uint8Array(i.length*2);g.set(i),i=g}}o=Ht(i,o,n),o=Ht(i,o,s),f(18),o++;let c=0,l=0,d=Math.min(16,s);for(let m=0;m<d;m++)i[o++]=e[m],c=(c<<8|e[m])^Pe[c>>>23],l++;c=c>>>0;let p=d,u=0,h=0;for(;p<s;){if(h<De){c^=Lr[e[p-16]],c=((c<<8|e[p])^Pe[c>>>23])>>>0;let m=c&r.hashMask,g=r.buckets[m],b=r.buckets[m+1];for(let y=g;y<b;y++){let R=r.entries[y];if(R.val!==c)continue;let w=R.ptr,P=a.byteLength-w,x=s-p;if(P>x&&(P=x),P<=h)break;let O=0;for(;O<P&&a[w+O]===e[p+O];)O++;if(O>h&&(h=O,u=w,h>=De))break}}if(h<Cr)f(2),l===0&&o++,i[o++]=e[p++],l++,l===Hr&&(i[o-l-1]=l,l=0),h=0;else{if(l>0){for(;u>0&&a[u-1]===e[p-1];)if(h++,u--,p--,o--,!(--l>0)){o--,l=-1;break}l>0&&(i[o-l-1]=l),l=0}let m=h>Lt?h-Lt:0;h-=m,f(8);let g=o++,b=128;if(u&255&&(i[o++]=u&255,b|=1),u&65280&&(i[o++]=u>>>8&255,b|=2),u&16711680&&(i[o++]=u>>>16&255,b|=4),u&4278190080&&(i[o++]=u>>>24&255,b|=8),h&255&&(i[o++]=h&255,b|=16),h&65280&&(i[o++]=h>>>8&255,b|=32),i[g]=b,p+=h,u+=h,h=m,u>4294967295&&(h=0),h<De){c=0;for(let y=-16;y<0;y++)c=(c<<8|e[p+y])^Pe[c>>>23];c=c>>>0}}if(t&&o>t)return null}return l>0&&(i[o-l-1]=l),t&&o>t?null:i.subarray(0,o)}var Ct={blob:0,tree:1,commit:2,tag:3};function Dt(r,e){let t=e?.window??10,n=e?.depth??50,s=r.slice().sort((c,l)=>{let d=Ct[c.type]??99,p=Ct[l.type]??99;return d!==p?d-p:l.content.byteLength-c.content.byteLength}),a=new Map,i=[],o=[],f=[];for(let c=0;c<s.length;c++){let l=s[c],d={hash:l.hash,type:l.type,content:l.content,depth:0},p=null,u=null,h=Math.max(0,c-t);for(let m=c-1;m>=h;m--){let g=s[m];if(g.type!==l.type||(a.get(g.hash)?.depth??0)>=n||l.content.byteLength<g.content.byteLength>>>5)continue;let R=o[m-h]??null;if(!R)continue;let w=p?p.byteLength:l.content.byteLength/2|0;if(w<16)continue;let P=Nr(R,l.content,w);P&&(!p||P.byteLength<p.byteLength)&&(p=P,u=g.hash)}if(p&&u){d.delta=p,d.deltaBase=u;let m=a.get(u);d.depth=(m?.depth??0)+1}a.set(l.hash,d),i.push(d),o.length>=t&&(o.shift(),f.shift()),o.push(Dr(l.content)),f.push(l.hash)}return i}function Br(r){let e=r;return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e<16?16:e}function Ht(r,e,t){let n=t;do{let s=n&127;n>>>=7,n>0&&(s|=128),r[e++]=s}while(n>0);return e}var Mr=2147483647;async function Nt(r,e,t,n){if(t>=Mr)return{shallow:[],unshallow:[...n]};let s=new Map,a=[];for(let c of e)!s.has(c)&&await se(r,c)&&(s.set(c,1),a.push({hash:c,level:1}));let i=new Set,o=0;for(;o<a.length;){let{hash:c,level:l}=a[o++];if(l>=t){i.add(c);continue}let d;try{d=await X(r,c)}catch{continue}for(let p of d.parents)!s.has(p)&&await se(r,p)&&(s.set(p,l+1),a.push({hash:p,level:l+1}))}let f=[];for(let c of n){let l=s.get(c);l!==void 0&&l<t&&f.push(c)}return{shallow:[...i],unshallow:f}}async function Ne(r,e,t,n,s){let a=s??n,i=new Set;for(let l of t)await ae(r,l,i,a);let o=[...e];if(s&&n)for(let l of s)try{let d=await X(r,l);for(let p of d.parents)i.has(p)||o.push(p)}catch{}let f=[],c=new Set;for(let l of o)await oe(r,l,i,c,f,n);return{count:f.length,objects:$r(f)}}async function Bt(r,e,t,n,s){let{count:a,objects:i}=await Ne(r,e,t,n,s);return{count:a,objects:Wr(r,i)}}async function*$r(r){for(let e of r)yield e}async function*Wr(r,e){for await(let t of e){let n=await ne(r,t.hash);yield{hash:t.hash,type:t.type,content:n.content}}}async function Mt(r){let e=[];for await(let t of r.objects)e.push(t);return e}async function ae(r,e,t,n){if(t.has(e)||(t.add(e),!await se(r,e)))return;let s=await ne(r,e);switch(s.type){case"commit":{let a=re(s.content);if(await ae(r,a.tree,t,n),!n?.has(e))for(let i of a.parents)await ae(r,i,t,n);break}case"tree":{let a=He(s.content);for(let i of a.entries)await ae(r,i.hash,t,n);break}case"tag":{let a=_(s.content);await ae(r,a.object,t,n);break}case"blob":break}}async function oe(r,e,t,n,s,a){if(n.has(e)||t.has(e))return;n.add(e);let i=await ne(r,e);switch(s.push({hash:e,type:i.type}),i.type){case"commit":{let o=re(i.content);if(await oe(r,o.tree,t,n,s,a),!a?.has(e))for(let f of o.parents)await oe(r,f,t,n,s,a);break}case"tree":{let o=He(i.content);for(let f of o.entries)await oe(r,f.hash,t,n,s,a);break}case"tag":{let o=_(i.content);await oe(r,o.object,t,n,s,a);break}case"blob":break}}var _r=new TextEncoder,Wt=new TextDecoder,$t=65520,Gr=new Uint8Array([48,48,48,48]);function k(r){let e=typeof r=="string"?_r.encode(r):r,t=4+e.byteLength;if(t>$t)throw new Error(`pkt-line too long: ${t} bytes (max ${$t})`);let n=t.toString(16).padStart(4,"0"),s=new Uint8Array(t);return s[0]=n.charCodeAt(0),s[1]=n.charCodeAt(1),s[2]=n.charCodeAt(2),s[3]=n.charCodeAt(3),s.set(e,4),s}function D(){return Gr.slice()}function B(...r){let e=0;for(let s of r)e+=s.byteLength;let t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}function _t(r){let e=[],t=0;for(;t<r.byteLength;){if(t+4>r.byteLength)throw new Error("Truncated pkt-line header");let n=Wt.decode(r.subarray(t,t+4)),s=parseInt(n,16);if(Number.isNaN(s))throw new Error(`Invalid pkt-line length: ${n}`);if(s===0){e.push({type:"flush"}),t+=4;continue}if(s<4)throw new Error(`Invalid pkt-line length: ${s}`);if(t+s>r.byteLength)throw new Error(`Truncated pkt-line: need ${s} bytes at offset ${t}, have ${r.byteLength-t}`);e.push({type:"data",data:r.subarray(t+4,t+s)}),t+=s}return e}function Gt(r){if(r.type==="flush")return"";let e=Wt.decode(r.data);return e.endsWith(`
8
8
  `)?e.slice(0,-1):e}var Ft=65515;function Oe(r,e,t){let n=[],s=[...e];t&&s.push(`symref=HEAD:${t}`),s.push("agent=just-git/1.0");let a=s.join(" ");if(r.length===0)n.push(k(`0000000000000000000000000000000000000000 capabilities^{}\0${a}
9
9
  `));else for(let i=0;i<r.length;i++){let o=r[i];i===0?n.push(k(`${o.hash} ${o.name}\0${a}
10
10
  `)):n.push(k(`${o.hash} ${o.name}
11
- `))}return n.push(H()),B(...n)}function qt(r,e,t,n){let s=B(k(`# service=${e}
12
- `),H()),a=Oe(r,t,n),i=new Uint8Array(s.byteLength+a.byteLength);return i.set(s,0),i.set(a,s.byteLength),i}function zt(r){let e=_t(r),t=[],n=[],s=[],a=[],i,o=!1;for(let f of e){if(f.type==="flush")continue;let c=Gt(f);if(c.startsWith("want ")){let l=c.slice(5);if(t.length===0){let d=l.indexOf(" ");d!==-1?(t.push(l.slice(0,d)),a=l.slice(d+1).split(" ").filter(Boolean)):t.push(l)}else t.push(l)}else c.startsWith("have ")?n.push(c.slice(5)):c.startsWith("shallow ")?s.push(c.slice(8)):c.startsWith("deepen ")?(i=parseInt(c.slice(7),10),Number.isNaN(i)&&(i=void 0)):c==="done"&&(o=!0)}return{wants:t,haves:n,capabilities:a,clientShallows:s,depth:i,done:o}}function K(r,e,t,n){let s=[];if(n){for(let a of n.shallow)s.push(k(`shallow ${a}
11
+ `))}return n.push(D()),B(...n)}function qt(r,e,t,n){let s=B(k(`# service=${e}
12
+ `),D()),a=Oe(r,t,n),i=new Uint8Array(s.byteLength+a.byteLength);return i.set(s,0),i.set(a,s.byteLength),i}function zt(r){let e=_t(r),t=[],n=[],s=[],a=[],i,o=!1;for(let f of e){if(f.type==="flush")continue;let c=Gt(f);if(c.startsWith("want ")){let l=c.slice(5);if(t.length===0){let d=l.indexOf(" ");d!==-1?(t.push(l.slice(0,d)),a=l.slice(d+1).split(" ").filter(Boolean)):t.push(l)}else t.push(l)}else c.startsWith("have ")?n.push(c.slice(5)):c.startsWith("shallow ")?s.push(c.slice(8)):c.startsWith("deepen ")?(i=parseInt(c.slice(7),10),Number.isNaN(i)&&(i=void 0)):c==="done"&&(o=!0)}return{wants:t,haves:n,capabilities:a,clientShallows:s,depth:i,done:o}}function K(r,e,t,n){let s=[];if(n){for(let a of n.shallow)s.push(k(`shallow ${a}
13
13
  `));for(let a of n.unshallow)s.push(k(`unshallow ${a}
14
- `));s.push(H())}if(t&&t.length>0){for(let i of t)s.push(k(`ACK ${i} common
14
+ `));s.push(D())}if(t&&t.length>0){for(let i of t)s.push(k(`ACK ${i} common
15
15
  `));let a=t[t.length-1];s.push(k(`ACK ${a} ready
16
16
  `)),s.push(k(`ACK ${a}
17
17
  `))}else s.push(k(`NAK
18
- `));if(e){let a=0;for(;a<r.byteLength;){let i=Math.min(Ft,r.byteLength-a);s.push(Be(1,r.subarray(a,a+i))),a+=i}s.push(H())}else{let a=new Uint8Array(r.byteLength);a.set(r),s.push(a)}return B(...s)}function Xt(r){let e=[];for(let t of r.shallow)e.push(k(`shallow ${t}
18
+ `));if(e){let a=0;for(;a<r.byteLength;){let i=Math.min(Ft,r.byteLength-a);s.push(Be(1,r.subarray(a,a+i))),a+=i}s.push(D())}else{let a=new Uint8Array(r.byteLength);a.set(r),s.push(a)}return B(...s)}function Xt(r){let e=[];for(let t of r.shallow)e.push(k(`shallow ${t}
19
19
  `));for(let t of r.unshallow)e.push(k(`unshallow ${t}
20
- `));return e.push(H()),B(...e)}async function*Kt(r,e,t,n){if(n){let a=[];for(let i of n.shallow)a.push(k(`shallow ${i}
20
+ `));return e.push(D()),B(...e)}async function*Kt(r,e,t,n){if(n){let a=[];for(let i of n.shallow)a.push(k(`shallow ${i}
21
21
  `));for(let i of n.unshallow)a.push(k(`unshallow ${i}
22
- `));a.push(H()),yield B(...a)}let s=[];if(t&&t.length>0){for(let i of t)s.push(k(`ACK ${i} common
22
+ `));a.push(D()),yield B(...a)}let s=[];if(t&&t.length>0){for(let i of t)s.push(k(`ACK ${i} common
23
23
  `));let a=t[t.length-1];s.push(k(`ACK ${a} ready
24
24
  `)),s.push(k(`ACK ${a}
25
25
  `))}else s.push(k(`NAK
26
- `));if(yield B(...s),e){for await(let a of r){let i=0;for(;i<a.byteLength;){let o=Math.min(Ft,a.byteLength-i);yield Be(1,a.subarray(i,i+o)),i+=o}}yield H()}else for await(let a of r)yield a}function Yt(r){let e=new TextDecoder,t=[],n=[],s=0,a=!1;for(;s<r.byteLength&&!(s+4>r.byteLength);){let o=e.decode(r.subarray(s,s+4)),f=parseInt(o,16);if(Number.isNaN(f))break;if(f===0){a=!0,s+=4;break}if(f<4||s+f>r.byteLength)break;let c=r.subarray(s+4,s+f);s+=f;let l=c.indexOf(0),d;if(l!==-1)d=e.decode(c.subarray(0,l)),n=e.decode(c.subarray(l+1)).replace(/\n$/,"").split(" ").filter(Boolean);else{let u=e.decode(c);d=u.endsWith(`
26
+ `));if(yield B(...s),e){for await(let a of r){let i=0;for(;i<a.byteLength;){let o=Math.min(Ft,a.byteLength-i);yield Be(1,a.subarray(i,i+o)),i+=o}}yield D()}else for await(let a of r)yield a}function Yt(r){let e=new TextDecoder,t=[],n=[],s=0,a=!1;for(;s<r.byteLength&&!(s+4>r.byteLength);){let o=e.decode(r.subarray(s,s+4)),f=parseInt(o,16);if(Number.isNaN(f))break;if(f===0){a=!0,s+=4;break}if(f<4||s+f>r.byteLength)break;let c=r.subarray(s+4,s+f);s+=f;let l=c.indexOf(0),d;if(l!==-1)d=e.decode(c.subarray(0,l)),n=e.decode(c.subarray(l+1)).replace(/\n$/,"").split(" ").filter(Boolean);else{let u=e.decode(c);d=u.endsWith(`
27
27
  `)?u.slice(0,-1):u}let p=d.split(" ");p.length>=3&&t.push({oldHash:p[0],newHash:p[1],refName:p[2]})}let i=s<r.byteLength?r.subarray(s):new Uint8Array(0);return{commands:t,packData:i,capabilities:n,sawFlush:a}}function Y(r,e,t){let n=[];n.push(k(r?`unpack ok
28
28
  `:`unpack error
29
29
  `));for(let a of e)a.ok?n.push(k(`ok ${a.name}
30
30
  `)):n.push(k(`ng ${a.name} ${a.error??"failed"}
31
- `));n.push(H());let s=B(...n);if(t){let a=[];return a.push(Be(1,s)),a.push(H()),B(...a)}return s}function Be(r,e){let t=new Uint8Array(1+e.byteLength);return t[0]=r,t.set(e,1),k(t)}var ie=class{entries=new Map;currentBytes=0;maxBytes;hits=0;misses=0;constructor(e=256*1024*1024){this.maxBytes=e}static key(e,t,n){if(n.length>0)return null;let s=t.slice().sort();return`${e}\0${s.join(",")}`}get(e){let t=this.entries.get(e);return t?this.hits++:this.misses++,t}set(e,t){if(this.entries.has(e))return;let n=t.packData.byteLength;if(!(n>this.maxBytes)){for(;this.currentBytes+n>this.maxBytes&&this.entries.size>0;){let s=this.entries.keys().next().value;this.currentBytes-=this.entries.get(s).packData.byteLength,this.entries.delete(s)}this.entries.set(e,t),this.currentBytes+=n}}clear(){this.entries.clear(),this.currentBytes=0}get stats(){return{entries:this.entries.size,bytes:this.currentBytes,hits:this.hits,misses:this.misses}}},Vt=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","allow-reachable-sha1-in-want","shallow"],Zt=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Jt(r){let e=await r.refStore.listRefs("refs"),t=await r.refStore.readRef("HEAD"),n=[],s=null,a;if(t)if(t.type==="symbolic"){a=t.target;let o=await r.refStore.readRef(t.target);o?.type==="direct"&&(s=o.hash)}else s=t.hash;let i=e.slice().sort((o,f)=>o.name<f.name?-1:o.name>f.name?1:0);if(!s&&i.length>0){let o=qr(i);o&&(s=o.hash,a=o.name)}s&&n.push({name:"HEAD",hash:s});for(let o of i)if(n.push({name:o.name,hash:o.hash}),o.name.startsWith("refs/tags/"))try{let f=await r.objectStore.read(o.hash);if(f.type==="tag"){let c=_(f.content);n.push({name:`${o.name}^{}`,hash:c.object})}}catch{}return{refs:n,headTarget:a}}var Fr=["refs/heads/main","refs/heads/master"];function qr(r){for(let t of Fr){let n=r.find(s=>s.name===t);if(n)return n}return r.find(t=>t.name.startsWith("refs/heads/"))??null}function Me(r,e,t){return qt(r,e,e==="git-upload-pack"?Vt:Zt,t)}function $e(r,e,t){return Oe(r,e==="git-upload-pack"?Vt:Zt,t)}async function ce(r,e,t,n,s){let{refs:a,headTarget:i}=await Jt(r),o=a;if(n?.advertiseRefs){let f=await n.advertiseRefs({repo:r,repoId:e,refs:a,service:t,session:s});if(T(f))return f;f&&(o=f)}return{refs:o,headTarget:i}}async function fe(r,e,t){let{wants:n,haves:s,capabilities:a,clientShallows:i,depth:o,done:f}=zt(e);if(n.length===0)return K(new Uint8Array(0),!1);let c=a.includes("multi_ack_detailed"),l=a.includes("side-band-64k"),d,p,u;if(i.length>0&&(u=new Set(i)),o!==void 0){let g=await Nt(r,n,o,u??new Set);d=g,p=new Set(g.shallow)}if(d&&!f)return Xt(d);let h;if(c&&s.length>0){h=[];for(let g of s)await r.objectStore.exists(g)&&h.push(g);h.length===0&&(h=void 0)}let m=!p&&t?.cache&&t.cacheKey?ie.key(t.cacheKey,n,s):null;if(m&&t?.cache){let g=t.cache.get(m);if(g)return K(g.packData,l,h)}return t?.noDelta?zr(r,n,s,a,l,h,d,p,u):Xr(r,n,s,a,l,h,t,m,d,p,u)}async function zr(r,e,t,n,s,a,i,o,f){let{count:c,objects:l}=await Ne(r,e,t,o,f);if(c===0){let{data:y}=await Re([]),R=K(y,s,a,i);return new ReadableStream({start(w){w.enqueue(R),w.close()}})}let d=[];for await(let y of l)d.push(y);let p=new Set(d.map(y=>y.hash)),u=[];if(n.includes("include-tag")){let y=await r.refStore.listRefs("refs/tags");for(let R of y)if(!p.has(R.hash))try{let w=await r.objectStore.read(R.hash);if(w.type==="tag"){let P=_(w.content);p.has(P.object)&&u.push({hash:R.hash,type:"tag",content:w.content})}}catch{}}let h=d.length+u.length;async function*m(){for(let y of d){let R=await r.objectStore.read(y.hash);yield{type:R.type,content:R.content}}for(let y of u)yield{type:y.type,content:y.content}}let g=St(h,m()),b=Kt(g,s,a,i);return new ReadableStream({async pull(y){let{value:R,done:w}=await b.next();w?y.close():y.enqueue(R)}})}async function Xr(r,e,t,n,s,a,i,o,f,c,l){let d=await Bt(r,e,t,c,l);if(d.count===0){let{data:y}=await Re([]);return K(y,s,a,f)}let p=await Mt(d),u=new Set(p.map(y=>y.hash));if(n.includes("include-tag")){let y=await r.refStore.listRefs("refs/tags");for(let R of y)if(!u.has(R.hash))try{let w=await r.objectStore.read(R.hash);if(w.type==="tag"){let P=_(w.content);u.has(P.object)&&(p.push({hash:R.hash,type:"tag",content:w.content}),u.add(R.hash))}}catch{}}let h=i?.deltaWindow?{window:i.deltaWindow}:void 0,m=Ht(p,h),g=m.map(y=>({hash:y.hash,type:y.type,content:y.content,delta:y.delta,deltaBaseHash:y.deltaBase})),{data:b}=await Re(g);if(o&&i?.cache){let y=m.filter(R=>R.delta).length;i.cache.set(o,{packData:b,objectCount:p.length,deltaCount:y})}return K(b,s,a,f)}async function We(r,e){let{commands:t,packData:n,capabilities:s,sawFlush:a}=Yt(e),i=!0;if(n.byteLength>0)try{await r.objectStore.ingestPack(n)}catch{i=!1}return{updates:await Qt(r,t,i),unpackOk:i,capabilities:s,sawFlush:a}}async function _e(r,e,t,n,s=!0){let a=!0;try{let f=vt(n,async c=>{try{return await r.objectStore.read(c)}catch{return null}});await r.objectStore.ingestPackStream(f)}catch{a=!1}return{updates:await Qt(r,e,a),unpackOk:a,capabilities:t,sawFlush:s}}async function Qt(r,e,t){let n=[];for(let s of e){let a=s.oldHash===ke,i=s.newHash===ke,o=!1;if(!a&&!i&&t)try{o=await Ut(r,s.oldHash,s.newHash)}catch{}n.push({ref:s.refName,oldHash:a?null:s.oldHash,newHash:s.newHash,isFF:o,isCreate:a,isDelete:i})}return n}async function le(r){let{repo:e,repoId:t,ingestResult:n,hooks:s,session:a}=r,{updates:i}=n;if(s?.preReceive){let c=await s.preReceive({repo:e,repoId:t,updates:i,session:a});if(T(c)){let l=c.message??"pre-receive hook declined";return{refResults:i.map(d=>({ref:d.ref,ok:!1,error:l})),applied:[]}}}let o=[],f=[];for(let c of i){if(!c.isDelete&&!It(c.ref)){o.push({ref:c.ref,ok:!1,error:"invalid refname"});continue}if(s?.update){let l=await s.update({repo:e,repoId:t,update:c,session:a});if(T(l)){o.push({ref:c.ref,ok:!1,error:l.message??"update hook declined"});continue}}try{let l=c.isCreate?null:c.oldHash,d=c.isDelete?null:{type:"direct",hash:c.newHash};if(!await e.refStore.compareAndSwapRef(c.ref,l,d)){o.push({ref:c.ref,ok:!1,error:"failed to lock"});continue}o.push({ref:c.ref,ok:!0}),f.push(c)}catch(l){o.push({ref:c.ref,ok:!1,error:l instanceof Error?l.message:String(l)})}}if(s?.postReceive&&f.length>0)try{await s.postReceive({repo:e,repoId:t,updates:f,session:a})}catch{}return{refResults:o,applied:f}}function tr(r){let e=r.match(/^git[\s-](upload-pack|receive-pack)\s+'?([^']+?)'?\s*$/);if(!e)return null;let t=`git-${e[1]}`,n=e[2];return n.startsWith("/")&&(n=n.slice(1)),{service:t,repoPath:n}}var Kr=new TextEncoder;async function rr(r,e,t){let{resolveRepo:n,hooks:s,packCache:a,packOptions:i,session:o}=t,f=e.writable.getWriter();try{let c=tr(r);if(!c)return Ee(e,`fatal: unrecognized command '${r}'
31
+ `));n.push(D());let s=B(...n);if(t){let a=[];return a.push(Be(1,s)),a.push(D()),B(...a)}return s}function Be(r,e){let t=new Uint8Array(1+e.byteLength);return t[0]=r,t.set(e,1),k(t)}var ie=class{entries=new Map;currentBytes=0;maxBytes;hits=0;misses=0;constructor(e=256*1024*1024){this.maxBytes=e}static key(e,t,n){if(n.length>0)return null;let s=t.slice().sort();return`${e}\0${s.join(",")}`}get(e){let t=this.entries.get(e);return t?this.hits++:this.misses++,t}set(e,t){if(this.entries.has(e))return;let n=t.packData.byteLength;if(!(n>this.maxBytes)){for(;this.currentBytes+n>this.maxBytes&&this.entries.size>0;){let s=this.entries.keys().next().value;this.currentBytes-=this.entries.get(s).packData.byteLength,this.entries.delete(s)}this.entries.set(e,t),this.currentBytes+=n}}clear(){this.entries.clear(),this.currentBytes=0}get stats(){return{entries:this.entries.size,bytes:this.currentBytes,hits:this.hits,misses:this.misses}}},Vt=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","allow-reachable-sha1-in-want","shallow"],Zt=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Jt(r){let e=await r.refStore.listRefs("refs"),t=await r.refStore.readRef("HEAD"),n=[],s=null,a;if(t)if(t.type==="symbolic"){a=t.target;let o=await r.refStore.readRef(t.target);o?.type==="direct"&&(s=o.hash)}else s=t.hash;let i=e.slice().sort((o,f)=>o.name<f.name?-1:o.name>f.name?1:0);if(!s&&i.length>0){let o=qr(i);o&&(s=o.hash,a=o.name)}s&&n.push({name:"HEAD",hash:s});for(let o of i)if(n.push({name:o.name,hash:o.hash}),o.name.startsWith("refs/tags/"))try{let f=await r.objectStore.read(o.hash);if(f.type==="tag"){let c=_(f.content);n.push({name:`${o.name}^{}`,hash:c.object})}}catch{}return{refs:n,headTarget:a}}var Fr=["refs/heads/main","refs/heads/master"];function qr(r){for(let t of Fr){let n=r.find(s=>s.name===t);if(n)return n}return r.find(t=>t.name.startsWith("refs/heads/"))??null}function Me(r,e,t){return qt(r,e,e==="git-upload-pack"?Vt:Zt,t)}function $e(r,e,t){return Oe(r,e==="git-upload-pack"?Vt:Zt,t)}async function ce(r,e,t,n,s){let{refs:a,headTarget:i}=await Jt(r),o=a;if(n?.advertiseRefs){let f=await n.advertiseRefs({repo:r,repoId:e,refs:a,service:t,session:s});if(T(f))return f;f&&(o=f)}return{refs:o,headTarget:i}}async function fe(r,e,t){let{wants:n,haves:s,capabilities:a,clientShallows:i,depth:o,done:f}=zt(e);if(n.length===0)return K(new Uint8Array(0),!1);let c=a.includes("multi_ack_detailed"),l=a.includes("side-band-64k"),d,p,u;if(i.length>0&&(u=new Set(i)),o!==void 0){let g=await Nt(r,n,o,u??new Set);d=g,p=new Set(g.shallow)}if(d&&!f)return Xt(d);let h;if(c&&s.length>0){h=[];for(let g of s)await r.objectStore.exists(g)&&h.push(g);h.length===0&&(h=void 0)}let m=!p&&t?.cache&&t.cacheKey?ie.key(t.cacheKey,n,s):null;if(m&&t?.cache){let g=t.cache.get(m);if(g)return K(g.packData,l,h)}return t?.noDelta?zr(r,n,s,a,l,h,d,p,u):Xr(r,n,s,a,l,h,t,m,d,p,u)}async function zr(r,e,t,n,s,a,i,o,f){let{count:c,objects:l}=await Ne(r,e,t,o,f);if(c===0){let{data:y}=await Re([]),R=K(y,s,a,i);return new ReadableStream({start(w){w.enqueue(R),w.close()}})}let d=[];for await(let y of l)d.push(y);let p=new Set(d.map(y=>y.hash)),u=[];if(n.includes("include-tag")){let y=await r.refStore.listRefs("refs/tags");for(let R of y)if(!p.has(R.hash))try{let w=await r.objectStore.read(R.hash);if(w.type==="tag"){let P=_(w.content);p.has(P.object)&&u.push({hash:R.hash,type:"tag",content:w.content})}}catch{}}let h=d.length+u.length;async function*m(){for(let y of d){let R=await r.objectStore.read(y.hash);yield{type:R.type,content:R.content}}for(let y of u)yield{type:y.type,content:y.content}}let g=St(h,m()),b=Kt(g,s,a,i);return new ReadableStream({async pull(y){let{value:R,done:w}=await b.next();w?y.close():y.enqueue(R)}})}async function Xr(r,e,t,n,s,a,i,o,f,c,l){let d=await Bt(r,e,t,c,l);if(d.count===0){let{data:y}=await Re([]);return K(y,s,a,f)}let p=await Mt(d),u=new Set(p.map(y=>y.hash));if(n.includes("include-tag")){let y=await r.refStore.listRefs("refs/tags");for(let R of y)if(!u.has(R.hash))try{let w=await r.objectStore.read(R.hash);if(w.type==="tag"){let P=_(w.content);u.has(P.object)&&(p.push({hash:R.hash,type:"tag",content:w.content}),u.add(R.hash))}}catch{}}let h=i?.deltaWindow?{window:i.deltaWindow}:void 0,m=Dt(p,h),g=m.map(y=>({hash:y.hash,type:y.type,content:y.content,delta:y.delta,deltaBaseHash:y.deltaBase})),{data:b}=await Re(g);if(o&&i?.cache){let y=m.filter(R=>R.delta).length;i.cache.set(o,{packData:b,objectCount:p.length,deltaCount:y})}return K(b,s,a,f)}async function We(r,e){let{commands:t,packData:n,capabilities:s,sawFlush:a}=Yt(e),i=!0;if(n.byteLength>0)try{await r.objectStore.ingestPack(n)}catch{i=!1}return{updates:await Qt(r,t,i),unpackOk:i,capabilities:s,sawFlush:a}}async function _e(r,e,t,n,s=!0){let a=!0;try{let f=vt(n,async c=>{try{return await r.objectStore.read(c)}catch{return null}});await r.objectStore.ingestPackStream(f)}catch{a=!1}return{updates:await Qt(r,e,a),unpackOk:a,capabilities:t,sawFlush:s}}async function Qt(r,e,t){let n=[];for(let s of e){let a=s.oldHash===ke,i=s.newHash===ke,o=!1;if(!a&&!i&&t)try{o=await Ut(r,s.oldHash,s.newHash)}catch{}n.push({ref:s.refName,oldHash:a?null:s.oldHash,newHash:s.newHash,isFF:o,isCreate:a,isDelete:i})}return n}async function le(r){let{repo:e,repoId:t,ingestResult:n,hooks:s,session:a}=r,{updates:i}=n;if(s?.preReceive){let c=await s.preReceive({repo:e,repoId:t,updates:i,session:a});if(T(c)){let l=c.message??"pre-receive hook declined";return{refResults:i.map(d=>({ref:d.ref,ok:!1,error:l})),applied:[]}}}let o=[],f=[];for(let c of i){if(!c.isDelete&&!It(c.ref)){o.push({ref:c.ref,ok:!1,error:"invalid refname"});continue}if(s?.update){let l=await s.update({repo:e,repoId:t,update:c,session:a});if(T(l)){o.push({ref:c.ref,ok:!1,error:l.message??"update hook declined"});continue}}try{let l=c.isCreate?null:c.oldHash,d=c.isDelete?null:{type:"direct",hash:c.newHash};if(!await e.refStore.compareAndSwapRef(c.ref,l,d)){o.push({ref:c.ref,ok:!1,error:"failed to lock"});continue}o.push({ref:c.ref,ok:!0}),f.push(c)}catch(l){o.push({ref:c.ref,ok:!1,error:l instanceof Error?l.message:String(l)})}}if(s?.postReceive&&f.length>0)try{await s.postReceive({repo:e,repoId:t,updates:f,session:a})}catch{}return{refResults:o,applied:f}}function tr(r){let e=r.match(/^git[\s-](upload-pack|receive-pack)\s+'?([^']+?)'?\s*$/);if(!e)return null;let t=`git-${e[1]}`,n=e[2];return n.startsWith("/")&&(n=n.slice(1)),{service:t,repoPath:n}}var Kr=new TextEncoder;async function rr(r,e,t){let{resolveRepo:n,hooks:s,packCache:a,packOptions:i,session:o}=t,f=e.writable.getWriter();try{let c=tr(r);if(!c)return Ee(e,`fatal: unrecognized command '${r}'
32
32
  `),128;let{service:l,repoPath:d}=c,p=await n(d);if(!p)return Ee(e,`fatal: '${d}' does not appear to be a git repository
33
33
  `),128;let{repo:u,repoId:h}=p,m=await ce(u,h,l,s,o);if(T(m))return Ee(e,`fatal: ${m.message??"access denied"}
34
34
  `),128;await f.write($e(m.refs,l,m.headTarget));let g=new Ge(e.readable);try{if(l==="git-upload-pack"){let b=await Vr(g),y=await fe(u,b,{cache:a,cacheKey:h,noDelta:i?.noDelta,deltaWindow:i?.deltaWindow});await Qr(f,y)}else{let{commands:b,capabilities:y}=await Zr(g),R=g.streamRemaining();await Yr({writer:f,repo:u,repoId:h,commands:b,capabilities:y,packStream:R,hooks:s,session:o})}}finally{g.release()}return 0}catch(c){return t.onError?.(c),Ee(e,`fatal: internal error
35
35
  `),128}finally{try{await f.close()}catch{}}}async function Yr(r){let{writer:e,repo:t,repoId:n,commands:s,capabilities:a,packStream:i,hooks:o,session:f}=r,c=await _e(t,s,a,i);if(c.updates.length===0)return;let l=c.capabilities.includes("side-band-64k"),d=c.capabilities.includes("report-status");if(!c.unpackOk){if(d){let u=c.updates.map(h=>({name:h.ref,ok:!1,error:"unpack failed"}));await e.write(Y(!1,u,l))}return}let{refResults:p}=await le({repo:t,repoId:n,ingestResult:c,hooks:o,session:f});if(d){let u=p.map(h=>({name:h.ref,ok:h.ok,error:h.error}));await e.write(Y(!0,u,l))}}function Ee(r,e){r.writeStderr?.(Kr.encode(e))}var er=new TextDecoder,Ge=class{buf=new Uint8Array(0);byteReader;eof=!1;constructor(e){this.byteReader=e.getReader()}async fill(e){for(;this.buf.byteLength<e&&!this.eof;){let t=await this.byteReader.read();if(t.done||!t.value){this.eof=!0;break}let n=t.value,s=new Uint8Array(this.buf.byteLength+n.byteLength);s.set(this.buf),s.set(n,this.buf.byteLength),this.buf=s}return this.buf.byteLength>=e}consume(e){let t=this.buf.subarray(0,e);return this.buf=this.buf.subarray(e),t}async readPktLine(){if(!await this.fill(4))return null;let e=er.decode(this.buf.subarray(0,4)),t=parseInt(e,16);if(t===0)return{type:"flush",raw:this.consume(4)};if(t<4||!await this.fill(t))return null;let n=new Uint8Array(this.consume(t));return{type:"data",raw:n,text:er.decode(n.subarray(4))}}async*streamRemaining(){for(this.buf.byteLength>0&&(yield this.consume(this.buf.byteLength));!this.eof;){let e=await this.byteReader.read();if(e.done||!e.value){this.eof=!0;break}yield e.value}}release(){this.byteReader.releaseLock()}};async function Vr(r){let e=[];for(;;){let t=await r.readPktLine();if(!t||(e.push(t.raw),t.type==="data"&&t.text.trimEnd()==="done"))break}return Jr(e)}async function Zr(r){let e=[],t=[],n=!0;for(;;){let s=await r.readPktLine();if(!s||s.type==="flush")break;let a=s.text;if(a.endsWith(`
36
36
  `)&&(a=a.slice(0,-1)),n){let o=a.indexOf("\0");o!==-1&&(t=a.slice(o+1).split(" ").filter(Boolean),a=a.slice(0,o)),n=!1}let i=a.split(" ");i.length>=3&&e.push({oldHash:i[0],newHash:i[1],refName:i[2]})}return{commands:e,capabilities:t}}function Jr(r){if(r.length===0)return new Uint8Array(0);if(r.length===1)return r[0];let e=0;for(let s of r)e+=s.byteLength;let t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}async function Qr(r,e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{value:n,done:s}=await t.read();if(s)break;await r.write(n)}}finally{t.releaseLock()}}else await r.write(e)}function nr(r){function e(t){return{objectStore:new Fe(r,t),refStore:new qe(r,t)}}return{async createRepo(t,n){if(await r.hasRepo(t))throw new Error(`repo '${t}' already exists`);let a=n?.defaultBranch??"main";return await r.insertRepo(t),await r.putRef(t,"HEAD",{type:"symbolic",target:`refs/heads/${a}`}),e(t)},async repo(t){return await r.hasRepo(t)?e(t):null},async deleteRepo(t){await r.deleteRepo(t)}}}var Fe=class{constructor(e,t){this.driver=e;this.repoId=t}cache=new be;async write(e,t){let n=jt(e,t),s=await ot(n);return await this.driver.putObject(this.repoId,s,e,t),s}async read(e){let t=this.cache.get(e);if(t)return t;let n=await this.driver.getObject(this.repoId,e);if(!n)throw new Error(`object ${e} not found`);return this.cache.set(e,n),n}async exists(e){return!!await this.driver.hasObject(this.repoId,e)}async ingestPack(e){if(e.byteLength<32||new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(8)===0)return 0;let s=this.driver,a=this.repoId,i=await kt(e,async o=>{let f=await s.getObject(a,o);return f?{type:f.type,content:new Uint8Array(f.content)}:null});return await s.putObjects(a,i.map(o=>({hash:o.hash,type:o.type,content:o.content}))),i.length}async ingestPackStream(e){let t=[];for await(let n of e)t.push({hash:n.hash,type:n.type,content:n.content});return t.length===0?0:(await this.driver.putObjects(this.repoId,t),t.length)}async findByPrefix(e){return e.length<4?[]:Array.from(await this.driver.findObjectsByPrefix(this.repoId,e))}},qe=class{constructor(e,t){this.driver=e;this.repoId=t}async readRef(e){return await this.driver.getRef(this.repoId,e)??null}async writeRef(e,t){await this.driver.putRef(this.repoId,e,At(t))}async deleteRef(e){await this.driver.removeRef(this.repoId,e)}async listRefs(e){let t=await this.driver.listRefs(this.repoId,e),n=[];for(let s of t)if(s.ref.type==="direct")n.push({name:s.name,hash:s.ref.hash});else if(s.ref.type==="symbolic"){let a=await ze(i=>this.driver.getRef(this.repoId,i),s.ref.target);a&&n.push({name:s.name,hash:a})}return n}async compareAndSwapRef(e,t,n){return!!await this.driver.atomicRefUpdate(this.repoId,s=>de(s.getRef(e),a=>{let i=a?a.type==="direct"?a.hash:ze(o=>s.getRef(o),a.target):null;return de(i,o=>{if(t===null){if(a!==null)return!1}else if(o!==t)return!1;return n===null?de(s.removeRef(e),()=>!0):de(s.putRef(e,n),()=>!0)})}))}};function de(r,e){return r instanceof Promise?r.then(e):e(r)}function ze(r,e,t=0){return t>10?null:de(r(e),n=>n?n.type==="direct"?n.hash:n.type==="symbolic"?ze(r,n.target,t+1):null:null)}var en={http:r=>({transport:"http",request:r}),ssh:r=>({transport:"ssh",username:r.username})};function tn(r){if(!r||!r.storage)throw new TypeError("createServer: config.storage is required. Example: createServer({ storage: new MemoryStorage() })");let e=nr(r.storage),t=r.resolve??(b=>b),n=r.autoCreate,{basePath:s}=r;async function a(b){let y=await t(b);if(y==null)return null;let R=await e.repo(y);if(R)return{repo:R,repoId:y};if(!n)return null;let w=typeof n=="object"?{defaultBranch:n.defaultBranch}:void 0;return{repo:await e.createRepo(y,w),repoId:y}}let i=sn(r.policy,r.hooks),o=r.session??en,f=r.packCache===!1?void 0:new ie(r.packCache?.maxBytes),c=r.onError===!1?void 0:r.onError??(b=>{let y=b instanceof Error?b.message:String(b);console.error(`[server] Internal error: ${y}`)}),l=!1,d=0,p=null,u=null;function h(){return l?!1:(d++,!0)}function m(){d--,l&&d===0&&p?.()}let g={async fetch(b){if(!h())return new Response("Service Unavailable",{status:503});let y;try{let R=await o.http(b);if(R instanceof Response)return R;y=R;let w=new URL(b.url),P=decodeURIComponent(w.pathname);if(s){let x=s.replace(/\/+$/,"");if(!P.startsWith(x))return new Response("Not Found",{status:404});P=P.slice(x.length)}if(P.startsWith("/")||(P=`/${P}`),P.endsWith("/info/refs")&&b.method==="GET"){let x=w.searchParams.get("service");if(x!=="git-upload-pack"&&x!=="git-receive-pack")return new Response("Unsupported service",{status:403});let O=Xe(P,"/info/refs"),S=await a(O);if(!S)return new Response("Not Found",{status:404});let E=await ce(S.repo,S.repoId,x,i,y);if(T(E))return new Response(E.message??"Forbidden",{status:403});let j=Me(E.refs,x,E.headTarget);return new Response(j,{headers:{"Content-Type":`application/x-${x}-advertisement`,"Cache-Control":"no-cache"}})}if(P.endsWith("/git-upload-pack")&&b.method==="POST"){let x=Xe(P,"/git-upload-pack"),O=await a(x);if(!O)return new Response("Not Found",{status:404});let S=await sr(b),E=await fe(O.repo,S,{cache:f,cacheKey:O.repoId,noDelta:r.packOptions?.noDelta,deltaWindow:r.packOptions?.deltaWindow});return new Response(E,{headers:{"Content-Type":"application/x-git-upload-pack-result"}})}if(P.endsWith("/git-receive-pack")&&b.method==="POST"){let x=Xe(P,"/git-receive-pack"),O=await a(x);if(!O)return new Response("Not Found",{status:404});let S=await sr(b),E=await We(O.repo,S);if(!E.sawFlush&&E.updates.length===0)return new Response("Bad Request",{status:400});let j=E.capabilities.includes("side-band-64k"),M=E.capabilities.includes("report-status");if(!E.unpackOk){if(M){let C=E.updates.map($=>({name:$.ref,ok:!1,error:"unpack failed"}));return new Response(Y(!1,C,j),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}return new Response(new Uint8Array(0),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}let{refResults:I}=await le({repo:O.repo,repoId:O.repoId,ingestResult:E,hooks:i,session:y});if(M){let C=I.map($=>({name:$.ref,ok:$.ok,error:$.error}));return new Response(Y(!0,C,j),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}return new Response(new Uint8Array(0),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}return new Response("Not Found",{status:404})}catch(R){return c?.(R,y),new Response("Internal Server Error",{status:500})}finally{m()}},async handleSession(b,y,R){if(!h())return y.writeStderr?.(new TextEncoder().encode(`fatal: server shutting down
37
- `)),128;try{let w=await o.ssh(R??{});return await rr(b,y,{resolveRepo:a,hooks:i,packCache:f,packOptions:r.packOptions,session:w,onError:c?P=>c(P,w):void 0})}finally{m()}},nodeHandler(b,y){let R=[];b.on("data",w=>R.push(new Uint8Array(w))),b.on("error",()=>{y.writeHead(500),y.end("Internal Server Error")}),b.on("end",()=>{rn(g,b,R,y).catch(()=>{try{y.writeHead(500),y.end("Internal Server Error")}catch{}})})},createRepo:(b,y)=>e.createRepo(b,y),repo:b=>e.repo(b),deleteRepo:b=>e.deleteRepo(b),get closed(){return l},asNetwork(b="http://git"){return{allowed:[b.endsWith("/")?b:`${b}/`],fetch:(R,w)=>g.fetch(new Request(R,w))}},async close(b){if(l)return u??Promise.resolve();if(l=!0,f?.clear(),d!==0){if(u=new Promise(y=>{p=y}),b?.signal){if(b.signal.aborted){p();return}let y=()=>p?.();b.signal.addEventListener("abort",y,{once:!0}),u.then(()=>b.signal.removeEventListener("abort",y))}return u}}};return g}function Xe(r,e){let t=r.slice(0,-e.length);return t.startsWith("/")&&(t=t.slice(1)),t}async function sr(r){let e=new Uint8Array(await r.arrayBuffer()),t=r.headers.get("content-encoding");if(t==="gzip"||t==="x-gzip"){let n=new DecompressionStream("gzip"),s=n.writable.getWriter();return s.write(e),s.close(),new Uint8Array(await new Response(n.readable).arrayBuffer())}return e}async function rn(r,e,t,n){let s=typeof e.headers.host=="string"?e.headers.host:"localhost",a=new URL(e.url??"/",`http://${s}`),i=new Headers;for(let[u,h]of Object.entries(e.headers))if(h!==void 0)if(Array.isArray(h))for(let m of h)i.append(u,m);else i.set(u,h);let o=e.method??"GET",f;if(o!=="GET"&&o!=="HEAD"){let u=0;for(let g of t)u+=g.byteLength;let h=new Uint8Array(u),m=0;for(let g of t)h.set(g,m),m+=g.byteLength;f=h}let c=new Request(a.href,{method:o,headers:i,body:f}),l=await r.fetch(c),d={};l.headers.forEach((u,h)=>{d[h]=u}),n.writeHead(l.status,d);let p=new Uint8Array(await l.arrayBuffer());p.byteLength>0&&n.write(p),n.end()}function nn(r){let{protectedBranches:e=[],denyNonFastForward:t=!1,denyDeletes:n=!1,denyDeleteTags:s=!1}=r,a=new Set(e.map(o=>o.startsWith("refs/")?o:`refs/heads/${o}`)),i={};return a.size>0&&(i.preReceive=async o=>{for(let f of o.updates)if(a.has(f.ref)){if(f.isDelete)return{reject:!0,message:`cannot delete protected branch ${f.ref}`};if(!f.isCreate&&!f.isFF)return{reject:!0,message:`non-fast-forward push to protected branch ${f.ref}`}}}),(t||n||s)&&(i.update=async o=>{if(n&&o.update.isDelete)return{reject:!0,message:"ref deletion denied"};if(s&&o.update.ref.startsWith("refs/tags/")){if(o.update.isDelete)return{reject:!0,message:"tag deletion denied"};if(!o.update.isCreate)return{reject:!0,message:"tag overwrite denied"}}if(t&&!o.update.isCreate&&!o.update.isDelete&&!o.update.isFF)return{reject:!0,message:"non-fast-forward"}}),i}function sn(r,e){let t=r?nn(r):void 0;return t&&e?ar(t,e):t??e}function ar(...r){let e=r.filter(o=>o!=null);if(e.length===0)return{};if(e.length===1)return e[0];let t={},n=e.filter(o=>o.preReceive).map(o=>o.preReceive);n.length>0&&(t.preReceive=async o=>{for(let f of n){let c=await f(o);if(T(c))return c}});let s=e.filter(o=>o.update).map(o=>o.update);s.length>0&&(t.update=async o=>{for(let f of s){let c=await f(o);if(T(c))return c}});let a=e.filter(o=>o.postReceive).map(o=>o.postReceive);a.length>0&&(t.postReceive=async o=>{for(let f of a)try{await f(o)}catch{}});let i=e.filter(o=>o.advertiseRefs).map(o=>o.advertiseRefs);return i.length>0&&(t.advertiseRefs=async o=>{let f=o.refs;for(let c of i){let l=await c({...o,refs:f});if(T(l))return l;l&&(f=l)}return f}),t}var Ke=class{repos=new Set;objects=new Map;refs=new Map;hasRepo(e){return this.repos.has(e)}insertRepo(e){this.repos.add(e)}deleteRepo(e){this.repos.delete(e),this.objects.get(e)?.clear(),this.objects.delete(e),this.refs.get(e)?.clear(),this.refs.delete(e)}getObject(e,t){let n=this.getObjMap(e).get(t);return n?{type:n.type,content:new Uint8Array(n.content)}:null}putObject(e,t,n,s){let a=this.getObjMap(e);a.has(t)||a.set(t,{type:n,content:new Uint8Array(s)})}putObjects(e,t){let n=this.getObjMap(e);for(let s of t)n.has(s.hash)||n.set(s.hash,{type:s.type,content:new Uint8Array(s.content)})}hasObject(e,t){return this.getObjMap(e).has(t)}findObjectsByPrefix(e,t){let n=[];for(let s of this.getObjMap(e).keys())s.startsWith(t)&&n.push(s);return n}getRef(e,t){return this.getRefMap(e).get(t)??null}putRef(e,t,n){this.getRefMap(e).set(t,n)}removeRef(e,t){this.getRefMap(e).delete(t)}listRefs(e,t){let n=[];for(let[s,a]of this.getRefMap(e))t&&!s.startsWith(t)||n.push({name:s,ref:a});return n}atomicRefUpdate(e,t){let n=this.getRefMap(e);return t({getRef:s=>n.get(s)??null,putRef:(s,a)=>{n.set(s,a)},removeRef:s=>{n.delete(s)}})}repoIds(){return Array.from(this.repos)}getObjMap(e){let t=this.objects.get(e);return t||(t=new Map,this.objects.set(e,t)),t}getRefMap(e){let t=this.refs.get(e);return t||(t=new Map,this.refs.set(e,t)),t}};var an=`
37
+ `)),128;try{let w=await o.ssh(R??{});return await rr(b,y,{resolveRepo:a,hooks:i,packCache:f,packOptions:r.packOptions,session:w,onError:c?P=>c(P,w):void 0})}finally{m()}},nodeHandler(b,y){let R=[];b.on("data",w=>R.push(new Uint8Array(w))),b.on("error",()=>{y.writeHead(500),y.end("Internal Server Error")}),b.on("end",()=>{rn(g,b,R,y).catch(()=>{try{y.writeHead(500),y.end("Internal Server Error")}catch{}})})},createRepo:(b,y)=>e.createRepo(b,y),repo:b=>e.repo(b),deleteRepo:b=>e.deleteRepo(b),get closed(){return l},asNetwork(b="http://git"){return{allowed:[b.endsWith("/")?b:`${b}/`],fetch:(R,w)=>g.fetch(new Request(R,w))}},async close(b){if(l)return u??Promise.resolve();if(l=!0,f?.clear(),d!==0){if(u=new Promise(y=>{p=y}),b?.signal){if(b.signal.aborted){p();return}let y=()=>p?.();b.signal.addEventListener("abort",y,{once:!0}),u.then(()=>b.signal.removeEventListener("abort",y))}return u}}};return g}function Xe(r,e){let t=r.slice(0,-e.length);return t.startsWith("/")&&(t=t.slice(1)),t}async function sr(r){let e=new Uint8Array(await r.arrayBuffer()),t=r.headers.get("content-encoding");if(t==="gzip"||t==="x-gzip"){let n=new DecompressionStream("gzip"),s=n.writable.getWriter();return s.write(e),s.close(),new Uint8Array(await new Response(n.readable).arrayBuffer())}return e}async function rn(r,e,t,n){let s=typeof e.headers.host=="string"?e.headers.host:"localhost",a=new URL(e.url??"/",`http://${s}`),i=new Headers;for(let[u,h]of Object.entries(e.headers))if(h!==void 0)if(Array.isArray(h))for(let m of h)i.append(u,m);else i.set(u,h);let o=e.method??"GET",f;if(o!=="GET"&&o!=="HEAD"){let u=0;for(let g of t)u+=g.byteLength;let h=new Uint8Array(u),m=0;for(let g of t)h.set(g,m),m+=g.byteLength;f=h}let c=new Request(a.href,{method:o,headers:i,body:f}),l=await r.fetch(c),d={};l.headers.forEach((u,h)=>{d[h]=u}),n.writeHead(l.status,d);let p=new Uint8Array(await l.arrayBuffer());p.byteLength>0&&n.write(p),n.end()}function nn(r){let{protectedBranches:e=[],denyNonFastForward:t=!1,denyDeletes:n=!1,immutableTags:s=!1}=r,a=new Set(e.map(o=>o.startsWith("refs/")?o:`refs/heads/${o}`)),i={};return a.size>0&&(i.preReceive=async o=>{for(let f of o.updates)if(a.has(f.ref)){if(f.isDelete)return{reject:!0,message:`cannot delete protected branch ${f.ref}`};if(!f.isCreate&&!f.isFF)return{reject:!0,message:`non-fast-forward push to protected branch ${f.ref}`}}}),(t||n||s)&&(i.update=async o=>{if(n&&o.update.isDelete)return{reject:!0,message:"ref deletion denied"};if(s&&o.update.ref.startsWith("refs/tags/")){if(o.update.isDelete)return{reject:!0,message:"tag deletion denied"};if(!o.update.isCreate)return{reject:!0,message:"tag overwrite denied"}}if(t&&!o.update.isCreate&&!o.update.isDelete&&!o.update.isFF)return{reject:!0,message:"non-fast-forward"}}),i}function sn(r,e){let t=r?nn(r):void 0;return t&&e?ar(t,e):t??e}function ar(...r){let e=r.filter(o=>o!=null);if(e.length===0)return{};if(e.length===1)return e[0];let t={},n=e.filter(o=>o.preReceive).map(o=>o.preReceive);n.length>0&&(t.preReceive=async o=>{for(let f of n){let c=await f(o);if(T(c))return c}});let s=e.filter(o=>o.update).map(o=>o.update);s.length>0&&(t.update=async o=>{for(let f of s){let c=await f(o);if(T(c))return c}});let a=e.filter(o=>o.postReceive).map(o=>o.postReceive);a.length>0&&(t.postReceive=async o=>{for(let f of a)try{await f(o)}catch{}});let i=e.filter(o=>o.advertiseRefs).map(o=>o.advertiseRefs);return i.length>0&&(t.advertiseRefs=async o=>{let f=o.refs;for(let c of i){let l=await c({...o,refs:f});if(T(l))return l;l&&(f=l)}return f}),t}var Ke=class{repos=new Set;objects=new Map;refs=new Map;hasRepo(e){return this.repos.has(e)}insertRepo(e){this.repos.add(e)}deleteRepo(e){this.repos.delete(e),this.objects.get(e)?.clear(),this.objects.delete(e),this.refs.get(e)?.clear(),this.refs.delete(e)}getObject(e,t){let n=this.getObjMap(e).get(t);return n?{type:n.type,content:new Uint8Array(n.content)}:null}putObject(e,t,n,s){let a=this.getObjMap(e);a.has(t)||a.set(t,{type:n,content:new Uint8Array(s)})}putObjects(e,t){let n=this.getObjMap(e);for(let s of t)n.has(s.hash)||n.set(s.hash,{type:s.type,content:new Uint8Array(s.content)})}hasObject(e,t){return this.getObjMap(e).has(t)}findObjectsByPrefix(e,t){let n=[];for(let s of this.getObjMap(e).keys())s.startsWith(t)&&n.push(s);return n}getRef(e,t){return this.getRefMap(e).get(t)??null}putRef(e,t,n){this.getRefMap(e).set(t,n)}removeRef(e,t){this.getRefMap(e).delete(t)}listRefs(e,t){let n=[];for(let[s,a]of this.getRefMap(e))t&&!s.startsWith(t)||n.push({name:s,ref:a});return n}atomicRefUpdate(e,t){let n=this.getRefMap(e);return t({getRef:s=>n.get(s)??null,putRef:(s,a)=>{n.set(s,a)},removeRef:s=>{n.delete(s)}})}repoIds(){return Array.from(this.repos)}getObjMap(e){let t=this.objects.get(e);return t||(t=new Map,this.objects.set(e,t)),t}getRefMap(e){let t=this.refs.get(e);return t||(t=new Map,this.refs.set(e,t)),t}};var an=`
38
38
  CREATE TABLE IF NOT EXISTS repos (
39
39
  id TEXT PRIMARY KEY
40
40
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "just-git",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Pure TypeScript git implementation: virtual filesystem client and embeddable server.",
5
5
  "keywords": [
6
6
  "agent",