@wp-playground/storage 1.0.28 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -1,63 +1,63 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("@php-wasm/util"),Ue=require("octokit"),Se=require("crc-32"),Mt=require("pako");function ke(n){return new Ue.Octokit({auth:n})}function Te(n,r=""){r.length&&!r.endsWith("/")&&(r+="/");const o={};for(const s of n)s.path.startsWith(r)&&(o[s.path.substring(r.length)]=s.content);return o}async function vt(n,r,o,s,u,f={}){f.progress||(f.progress={foundFiles:0,downloadedFiles:0});const{onProgress:h}=f,a=[],w=[],{data:y}=await n.rest.repos.getContent({owner:r,repo:o,path:u,ref:s});if(!Array.isArray(y))throw new Error(`Expected the list of files to be an array, but got ${typeof y}`);for(const b of y)b.type==="file"?(++f.progress.foundFiles,h==null||h(f.progress),a.push(Ce(n,r,o,s,b).then(B=>(++f.progress.downloadedFiles,h==null||h(f.progress),B)))):b.type==="dir"&&w.push(vt(n,r,o,s,b.path,f));const g=await Promise.all(a),m=(await Promise.all(w)).flatMap(b=>b);return[...g,...m]}const $e=new Q.Semaphore({concurrency:15});async function Ce(n,r,o,s,u){const f=await $e.acquire();try{const{data:h}=await n.rest.repos.getContent({owner:r,repo:o,ref:s,path:u.path});if(!("content"in h))throw new Error(`No content found for ${u.path}`);return{name:u.name,path:u.path,content:Oe(h.content)}}finally{f()}}function Oe(n){const r=window.atob(n),o=r.length,s=new Uint8Array(o);for(let u=0;u<o;u++)s[u]=r.charCodeAt(u);return s}async function Pe(n,r,o,s,u){var g;const{data:f}=await n.rest.pulls.get({owner:r,repo:o,pull_number:s}),a=(g=(await n.rest.actions.listWorkflowRuns({owner:r,repo:o,branch:f.head.ref,workflow_id:u})).data.workflow_runs[0])==null?void 0:g.id,w=await n.rest.actions.listWorkflowRunArtifacts({owner:r,repo:o,run_id:a});return(await n.rest.actions.downloadArtifact({owner:r,repo:o,artifact_id:w.data.artifacts[0].id,archive_format:"zip"})).data}async function Re(n,r,o){var f;const{data:s,headers:u}=await n.request("GET /repos/{owner}/{repo}",{owner:r,repo:o});return!(!u["x-oauth-scopes"]||!((f=s.permissions)!=null&&f.push))}async function De(n,r,o,s,u){await n.request("GET /repos/{owner}/{repo}/branches/{branch}",{owner:r,repo:o,branch:s}).then(()=>!0,()=>!1)?await n.request("PATCH /repos/{owner}/{repo}/git/refs/{ref}",{owner:r,repo:o,sha:u,ref:`heads/${s}`}):await n.request("POST /repos/{owner}/{repo}/git/refs",{owner:r,repo:o,sha:u,ref:`refs/heads/${s}`})}async function Ne(n,r,o){const s=await n.request("GET /user");return(await n.request("GET /repos/{owner}/{repo}/forks",{owner:r,repo:o})).data.find(h=>h.owner&&h.owner.login===s.data.login)||await n.request("POST /repos/{owner}/{repo}/forks",{owner:r,repo:o}),s.data.login}async function je(n,r,o,s,u,f){const{data:{sha:h}}=await n.request("POST /repos/{owner}/{repo}/git/commits",{owner:r,repo:o,message:s,tree:f,parents:[u]});return h}async function Le(n,r,o,s,u){const f=await Gt(n,r,o,s,u);if(f.length===0)return null;const{data:{sha:h}}=await n.request("POST /repos/{owner}/{repo}/git/trees",{owner:r,repo:o,base_tree:s,tree:f});return h}async function Gt(n,r,o,s,u){const f=[];for(const[h,a]of u.create)f.push(gt(n,r,o,h,a));for(const[h,a]of u.update)f.push(gt(n,r,o,h,a));for(const h of u.delete)f.push(qt(n,r,o,s,h));return Promise.all(f).then(h=>h.filter(a=>!!a))}const Ht=new Q.Semaphore({concurrency:10});async function gt(n,r,o,s,u){const f=await Ht.acquire();try{if(ArrayBuffer.isView(u))try{const h=new TextDecoder("utf-8",{fatal:!0}).decode(u);return{path:s,content:h,mode:"100644"}}catch{const{data:{sha:a}}=await n.rest.git.createBlob({owner:r,repo:o,encoding:"base64",content:Me(u)});return{path:s,sha:a,mode:"100644"}}else return{path:s,content:u,mode:"100644"}}finally{f()}}async function qt(n,r,o,s,u){const f=await Ht.acquire();try{return await n.request("HEAD /repos/{owner}/{repo}/contents/:path",{owner:r,repo:o,ref:s,path:u}),{path:u,mode:"100644",sha:null}}catch{return}finally{f()}}function Me(n){const r=[],o=n.byteLength;for(let s=0;s<o;s++)r.push(String.fromCharCode(n[s]));return window.btoa(r.join(""))}async function*ve(n,r,{exceptPaths:o=[]}={}){if(r=Q.normalizePath(r),!await n.isDir(r)){await n.fileExists(r)&&(yield{path:r,read:async()=>await n.readFileAsBuffer(r)});return}const s=[r];for(;s.length;){const u=s.pop();if(!u)return;const f=await n.listFiles(u);for(const h of f){const a=Q.joinPaths(u,h);o.includes(a.substring(r.length+1))||(await n.isDir(a)?s.push(a):yield{path:a,read:async()=>await n.readFileAsBuffer(a)})}}}async function Ge(n,r){const o={create:new Map,update:new Map,delete:new Set},s=new Set;for await(const u of r){s.add(u.path);const f=n.get(u.path),h=await u.read();f?He(f,h)||o.update.set(u.path,h):o.create.set(u.path,h)}for(const u of n.keys())s.has(u)||o.delete.add(u);return o}function He(n,r){return n.length===r.length&&n.every((o,s)=>o===r[s])}async function zt(n){return n.type==="local-fs"?n.handle:Wt(n.path)}async function Wt(n){const r=n.split("/").filter(s=>s.length>0);let o=await navigator.storage.getDirectory();for(const s of r)o=await o.getDirectoryHandle(s,{create:!0});return o}async function qe(n){const o=await(await navigator.storage.getDirectory()).resolve(n);if(o===null)throw new DOMException("Unable to resolve path of OPFS directory handle.","NotFoundError");return"/"+o.join("/")}async function ze(n){const r=await zt(n);for await(const o of r.keys())await r.removeEntry(o,{recursive:!0})}function We(n){let r=[n];return{next(){return Promise.resolve({done:r.length===0,value:r.pop()})},return(){return r=[],{}},[Symbol.asyncIterator](){return this}}}function Yt(n){return n[Symbol.asyncIterator]?n[Symbol.asyncIterator]():n[Symbol.iterator]?n[Symbol.iterator]():n.next?n:We(n)}class Vt{constructor(r){if(typeof Buffer>"u")throw new Error("Missing Buffer dependency");this.stream=Yt(r),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(r){if(!this.eof())return this.started||await this._init(),this.cursor+r>this.buffer.length&&(this._trim(),await this._accumulate(r)),this._moveCursor(r),this.buffer.slice(this.undoCursor,this.cursor)}async skip(r){this.eof()||(this.started||await this._init(),this.cursor+r>this.buffer.length&&(this._trim(),await this._accumulate(r)),this._moveCursor(r))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:r,value:o}=await this.stream.next();return r&&(this._ended=!0,!o)?Buffer.alloc(0):(o&&(o=Buffer.from(o)),o)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(r){this.undoCursor=this.cursor,this.cursor+=r,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(r){if(this._ended)return;const o=[this.buffer];for(;this.cursor+r>Ye(o);){const s=await this._next();if(this._ended)break;o.push(s)}this.buffer=Buffer.concat(o)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}}function Ye(n){return n.reduce((r,o)=>r+o.length,0)}function Ve(n,r){const o=r.toString(16);return"0".repeat(n-o.length)+o}class k{static flush(){return Buffer.from("0000","utf8")}static delim(){return Buffer.from("0001","utf8")}static encode(r){typeof r=="string"&&(r=Buffer.from(r));const o=r.length+4,s=Ve(4,o);return Buffer.concat([Buffer.from(s,"utf8"),r])}static streamReader(r){const o=new Vt(r);return async function(){try{let u=await o.read(4);if(u==null)return!0;if(u=parseInt(u.toString("utf8"),16),u===0||u===1)return null;const f=await o.read(u-4);return f??!0}catch(u){return r.error=u,!0}}}}class J extends Error{constructor(r){super(r),this.caller=""}toJSON(){return{code:this.code,data:this.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(r){const o=new J(r.message);return o.code=r.code,o.data=r.data,o.caller=r.caller,o.stack=r.stack,o}get isIsomorphicGitError(){return!0}}class _ extends J{constructor(r){super(`An internal error caused this command to fail. Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${r}`),this.code=this.name=_.code,this.data={message:r}}}_.code="InternalError";class st extends J{constructor(r){super(`The filepath "${r}" contains unsafe character sequences`),this.code=this.name=st.code,this.data={filepath:r}}}st.code="UnsafeFilepathError";function Kt(n,r){return-(n<r)||+(n>r)}function Ke(n,r){return Kt(n.path,r.path)}function Je(n,r){return Kt(Rt(n),Rt(r))}function Rt(n){return n.mode==="040000"?n.path+"/":n.path}function Jt(n){switch(n){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new _(`Unexpected GitTree entry mode: ${n}`)}function Xe(n){const r=[];let o=0;for(;o<n.length;){const s=n.indexOf(32,o);if(s===-1)throw new _(`GitTree: Error parsing buffer at byte location ${o}: Could not find the next space character.`);const u=n.indexOf(0,o);if(u===-1)throw new _(`GitTree: Error parsing buffer at byte location ${o}: Could not find the next null character.`);let f=n.slice(o,s).toString("utf8");f==="40000"&&(f="040000");const h=Jt(f),a=n.slice(s+1,u).toString("utf8");if(a.includes("\\")||a.includes("/"))throw new st(a);const w=n.slice(u+1,u+21).toString("hex");o=u+21,r.push({mode:f,path:a,oid:w,type:h})}return r}function Ze(n){if(typeof n=="number"&&(n=n.toString(8)),n.match(/^0?4.*/))return"040000";if(n.match(/^1006.*/))return"100644";if(n.match(/^1007.*/))return"100755";if(n.match(/^120.*/))return"120000";if(n.match(/^160.*/))return"160000";throw new _(`Could not understand file mode: ${n}`)}function Qe(n){return!n.oid&&n.sha&&(n.oid=n.sha),n.mode=Ze(n.mode),n.type||(n.type=Jt(n.mode)),n}class Bt{constructor(r){if(Buffer.isBuffer(r))this._entries=Xe(r);else if(Array.isArray(r))this._entries=r.map(Qe);else throw new _("invalid type passed to GitTree constructor");this._entries.sort(Ke)}static from(r){return new Bt(r)}render(){return this._entries.map(r=>`${r.mode} ${r.type} ${r.oid} ${r.path}`).join(`
2
- `)}toObject(){const r=[...this._entries];return r.sort(Je),Buffer.concat(r.map(o=>{const s=Buffer.from(o.mode.replace(/^0/,"")),u=Buffer.from(" "),f=Buffer.from(o.path,"utf8"),h=Buffer.from([0]),a=Buffer.from(o.oid,"hex");return Buffer.concat([s,u,f,h,a])}))}entries(){return this._entries}*[Symbol.iterator](){for(const r of this._entries)yield r}}function mt({name:n,email:r,timestamp:o,timezoneOffset:s}){return s=tr(s),`${n} <${r}> ${o} ${s}`}function tr(n){const r=er(rr(n));n=Math.abs(n);const o=Math.floor(n/60);n-=o*60;let s=String(o),u=String(n);return s.length<2&&(s="0"+s),u.length<2&&(u="0"+u),(r===-1?"-":"+")+s+u}function er(n){return Math.sign(n)||(Object.is(n,-0)?-1:1)}function rr(n){return n===0?n:-n}function G(n){return n=n.replace(/\r/g,""),n=n.replace(/^\n+/,""),n=n.replace(/\n+$/,"")+`
3
- `,n}function ot(n){const[,r,o,s,u]=n.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:r,email:o,timestamp:Number(s),timezoneOffset:nr(u)}}function nr(n){let[,r,o,s]=n.match(/(\+|-)(\d\d)(\d\d)/);return s=(r==="+"?1:-1)*(Number(o)*60+Number(s)),ir(s)}function ir(n){return n===0?n:-n}class Z{constructor(r){if(typeof r=="string")this._tag=r;else if(Buffer.isBuffer(r))this._tag=r.toString("utf8");else if(typeof r=="object")this._tag=Z.render(r);else throw new _("invalid type passed to GitAnnotatedTag constructor")}static from(r){return new Z(r)}static render(r){return`object ${r.object}
4
- type ${r.type}
5
- tag ${r.tag}
6
- tagger ${mt(r.tagger)}
1
+ "use strict";var Fe=Object.create;var $t=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Se=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Ue=(i,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of Ie(t))!Ae.call(i,c)&&c!==n&&$t(i,c,{get:()=>t[c],enumerable:!(s=_e(t,c))||s.enumerable});return i};var Ct=(i,t,n)=>(n=i!=null?Fe(Se(i)):{},Ue(t||!i||!i.__esModule?$t(n,"default",{value:i,enumerable:!0}):n,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("@php-wasm/util"),ke=require("octokit"),Te=require("crc-32"),Lt=require("pako"),Z=require("@php-wasm/stream-compression"),K=require("@zip.js/zip.js");function $e(i){return new ke.Octokit({auth:i})}function Ce(i,t=""){t.length&&!t.endsWith("/")&&(t+="/");const n={};for(const s of i)s.path.startsWith(t)&&(n[s.path.substring(t.length)]=s.content);return n}async function Nt(i,t,n,s,c,f={}){f.progress||(f.progress={foundFiles:0,downloadedFiles:0});const{onProgress:h}=f,a=[],d=[],{data:y}=await i.rest.repos.getContent({owner:t,repo:n,path:c,ref:s});if(!Array.isArray(y))throw new Error(`Expected the list of files to be an array, but got ${typeof y}`);for(const b of y)b.type==="file"?(++f.progress.foundFiles,h==null||h(f.progress),a.push(Oe(i,t,n,s,b).then(x=>(++f.progress.downloadedFiles,h==null||h(f.progress),x)))):b.type==="dir"&&d.push(Nt(i,t,n,s,b.path,f));const m=await Promise.all(a),g=(await Promise.all(d)).flatMap(b=>b);return[...m,...g]}const Re=new Y.Semaphore({concurrency:15});async function Oe(i,t,n,s,c){const f=await Re.acquire();try{const{data:h}=await i.rest.repos.getContent({owner:t,repo:n,ref:s,path:c.path});if(!("content"in h))throw new Error(`No content found for ${c.path}`);return{name:c.name,path:c.path,content:De(h.content)}}finally{f()}}function De(i){const t=window.atob(i),n=t.length,s=new Uint8Array(n);for(let c=0;c<n;c++)s[c]=t.charCodeAt(c);return s}async function Pe(i,t,n,s,c){var m;const{data:f}=await i.rest.pulls.get({owner:t,repo:n,pull_number:s}),a=(m=(await i.rest.actions.listWorkflowRuns({owner:t,repo:n,branch:f.head.ref,workflow_id:c})).data.workflow_runs[0])==null?void 0:m.id,d=await i.rest.actions.listWorkflowRunArtifacts({owner:t,repo:n,run_id:a});return(await i.rest.actions.downloadArtifact({owner:t,repo:n,artifact_id:d.data.artifacts[0].id,archive_format:"zip"})).data}async function Me(i,t,n){var f;const{data:s,headers:c}=await i.request("GET /repos/{owner}/{repo}",{owner:t,repo:n});return!(!c["x-oauth-scopes"]||!((f=s.permissions)!=null&&f.push))}async function Le(i,t,n,s,c){await i.request("GET /repos/{owner}/{repo}/branches/{branch}",{owner:t,repo:n,branch:s}).then(()=>!0,()=>!1)?await i.request("PATCH /repos/{owner}/{repo}/git/refs/{ref}",{owner:t,repo:n,sha:c,ref:`heads/${s}`}):await i.request("POST /repos/{owner}/{repo}/git/refs",{owner:t,repo:n,sha:c,ref:`refs/heads/${s}`})}async function Ne(i,t,n){const s=await i.request("GET /user");return(await i.request("GET /repos/{owner}/{repo}/forks",{owner:t,repo:n})).data.find(h=>h.owner&&h.owner.login===s.data.login)||await i.request("POST /repos/{owner}/{repo}/forks",{owner:t,repo:n}),s.data.login}async function je(i,t,n,s,c,f){const{data:{sha:h}}=await i.request("POST /repos/{owner}/{repo}/git/commits",{owner:t,repo:n,message:s,tree:f,parents:[c]});return h}async function Ge(i,t,n,s,c){const f=await jt(i,t,n,s,c);if(f.length===0)return null;const{data:{sha:h}}=await i.request("POST /repos/{owner}/{repo}/git/trees",{owner:t,repo:n,base_tree:s,tree:f});return h}async function jt(i,t,n,s,c){const f=[];for(const[h,a]of c.create)f.push(yt(i,t,n,h,a));for(const[h,a]of c.update)f.push(yt(i,t,n,h,a));for(const h of c.delete)f.push(Ht(i,t,n,s,h));return Promise.all(f).then(h=>h.filter(a=>!!a))}const Gt=new Y.Semaphore({concurrency:10});async function yt(i,t,n,s,c){const f=await Gt.acquire();try{if(ArrayBuffer.isView(c))try{const h=new TextDecoder("utf-8",{fatal:!0}).decode(c);return{path:s,content:h,mode:"100644"}}catch{const{data:{sha:h}}=await i.rest.git.createBlob({owner:t,repo:n,encoding:"base64",content:He(c)});return{path:s,sha:h,mode:"100644"}}else return{path:s,content:c,mode:"100644"}}finally{f()}}async function Ht(i,t,n,s,c){const f=await Gt.acquire();try{return await i.request("HEAD /repos/{owner}/{repo}/contents/:path",{owner:t,repo:n,ref:s,path:c}),{path:c,mode:"100644",sha:null}}catch{return}finally{f()}}function He(i){const t=[],n=i.byteLength;for(let s=0;s<n;s++)t.push(String.fromCharCode(i[s]));return window.btoa(t.join(""))}async function*qe(i,t,{exceptPaths:n=[]}={}){if(t=Y.normalizePath(t),!await i.isDir(t)){await i.fileExists(t)&&(yield{path:t,read:async()=>await i.readFileAsBuffer(t)});return}const s=[t];for(;s.length;){const c=s.pop();if(!c)return;const f=await i.listFiles(c);for(const h of f){const a=Y.joinPaths(c,h);n.includes(a.substring(t.length+1))||(await i.isDir(a)?s.push(a):yield{path:a,read:async()=>await i.readFileAsBuffer(a)})}}}async function ze(i,t){const n={create:new Map,update:new Map,delete:new Set},s=new Set;for await(const c of t){s.add(c.path);const f=i.get(c.path),h=await c.read();f?We(f,h)||n.update.set(c.path,h):n.create.set(c.path,h)}for(const c of i.keys())s.has(c)||n.delete.add(c);return n}function We(i,t){return i.length===t.length&&i.every((n,s)=>n===t[s])}async function qt(i){return i.type==="local-fs"?i.handle:zt(i.path)}async function zt(i){const t=i.split("/").filter(s=>s.length>0);let n=await navigator.storage.getDirectory();for(const s of t)n=await n.getDirectoryHandle(s,{create:!0});return n}async function Ye(i){const n=await(await navigator.storage.getDirectory()).resolve(i);if(n===null)throw new DOMException("Unable to resolve path of OPFS directory handle.","NotFoundError");return"/"+n.join("/")}async function Je(i){const t=await qt(i);for await(const n of t.keys())await t.removeEntry(n,{recursive:!0})}function Ke(i){let t=[i];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function Wt(i){return i[Symbol.asyncIterator]?i[Symbol.asyncIterator]():i[Symbol.iterator]?i[Symbol.iterator]():i.next?i:Ke(i)}class Yt{constructor(t){if(typeof Buffer>"u")throw new Error("Missing Buffer dependency");this.stream=Wt(t),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(t){if(!this.eof())return this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t),this.buffer.slice(this.undoCursor,this.cursor)}async skip(t){this.eof()||(this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:t,value:n}=await this.stream.next();return t&&(this._ended=!0,!n)?Buffer.alloc(0):(n&&(n=Buffer.from(n)),n)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(t){this.undoCursor=this.cursor,this.cursor+=t,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(t){if(this._ended)return;const n=[this.buffer];for(;this.cursor+t>Ve(n);){const s=await this._next();if(this._ended)break;n.push(s)}this.buffer=Buffer.concat(n)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}}function Ve(i){return i.reduce((t,n)=>t+n.length,0)}function Ze(i,t){const n=t.toString(16);return"0".repeat(i-n.length)+n}class A{static flush(){return Buffer.from("0000","utf8")}static delim(){return Buffer.from("0001","utf8")}static encode(t){typeof t=="string"&&(t=Buffer.from(t));const n=t.length+4,s=Ze(4,n);return Buffer.concat([Buffer.from(s,"utf8"),t])}static streamReader(t){const n=new Yt(t);return async function(){try{let c=await n.read(4);if(c==null)return!0;if(c=parseInt(c.toString("utf8"),16),c===0||c===1)return null;const f=await n.read(c-4);return f??!0}catch(c){return t.error=c,!0}}}}class J extends Error{constructor(t){super(t),this.caller=""}toJSON(){return{code:this.code,data:this.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(t){const n=new J(t.message);return n.code=t.code,n.data=t.data,n.caller=t.caller,n.stack=t.stack,n}get isIsomorphicGitError(){return!0}}class F extends J{constructor(t){super(`An internal error caused this command to fail. Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${t}`),this.code=this.name=F.code,this.data={message:t}}}F.code="InternalError";class ot extends J{constructor(t){super(`The filepath "${t}" contains unsafe character sequences`),this.code=this.name=ot.code,this.data={filepath:t}}}ot.code="UnsafeFilepathError";function Jt(i,t){return-(i<t)||+(i>t)}function Xe(i,t){return Jt(i.path,t.path)}function Qe(i,t){return Jt(Rt(i),Rt(t))}function Rt(i){return i.mode==="040000"?i.path+"/":i.path}function Kt(i){switch(i){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new F(`Unexpected GitTree entry mode: ${i}`)}function tr(i){const t=[];let n=0;for(;n<i.length;){const s=i.indexOf(32,n);if(s===-1)throw new F(`GitTree: Error parsing buffer at byte location ${n}: Could not find the next space character.`);const c=i.indexOf(0,n);if(c===-1)throw new F(`GitTree: Error parsing buffer at byte location ${n}: Could not find the next null character.`);let f=i.slice(n,s).toString("utf8");f==="40000"&&(f="040000");const h=Kt(f),a=i.slice(s+1,c).toString("utf8");if(a.includes("\\")||a.includes("/"))throw new ot(a);const d=i.slice(c+1,c+21).toString("hex");n=c+21,t.push({mode:f,path:a,oid:d,type:h})}return t}function er(i){if(typeof i=="number"&&(i=i.toString(8)),i.match(/^0?4.*/))return"040000";if(i.match(/^1006.*/))return"100644";if(i.match(/^1007.*/))return"100755";if(i.match(/^120.*/))return"120000";if(i.match(/^160.*/))return"160000";throw new F(`Could not understand file mode: ${i}`)}function rr(i){return!i.oid&&i.sha&&(i.oid=i.sha),i.mode=er(i.mode),i.type||(i.type=Kt(i.mode)),i}class xt{constructor(t){if(Buffer.isBuffer(t))this._entries=tr(t);else if(Array.isArray(t))this._entries=t.map(rr);else throw new F("invalid type passed to GitTree constructor");this._entries.sort(Xe)}static from(t){return new xt(t)}render(){return this._entries.map(t=>`${t.mode} ${t.type} ${t.oid} ${t.path}`).join(`
2
+ `)}toObject(){const t=[...this._entries];return t.sort(Qe),Buffer.concat(t.map(n=>{const s=Buffer.from(n.mode.replace(/^0/,"")),c=Buffer.from(" "),f=Buffer.from(n.path,"utf8"),h=Buffer.from([0]),a=Buffer.from(n.oid,"hex");return Buffer.concat([s,c,f,h,a])}))}entries(){return this._entries}*[Symbol.iterator](){for(const t of this._entries)yield t}}function mt({name:i,email:t,timestamp:n,timezoneOffset:s}){return s=nr(s),`${i} <${t}> ${n} ${s}`}function nr(i){const t=ir(sr(i));i=Math.abs(i);const n=Math.floor(i/60);i-=n*60;let s=String(n),c=String(i);return s.length<2&&(s="0"+s),c.length<2&&(c="0"+c),(t===-1?"-":"+")+s+c}function ir(i){return Math.sign(i)||(Object.is(i,-0)?-1:1)}function sr(i){return i===0?i:-i}function G(i){return i=i.replace(/\r/g,""),i=i.replace(/^\n+/,""),i=i.replace(/\n+$/,"")+`
3
+ `,i}function it(i){const[,t,n,s,c]=i.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:t,email:n,timestamp:Number(s),timezoneOffset:or(c)}}function or(i){let[,t,n,s]=i.match(/(\+|-)(\d\d)(\d\d)/);return s=(t==="+"?1:-1)*(Number(n)*60+Number(s)),ar(s)}function ar(i){return i===0?i:-i}class V{constructor(t){if(typeof t=="string")this._tag=t;else if(Buffer.isBuffer(t))this._tag=t.toString("utf8");else if(typeof t=="object")this._tag=V.render(t);else throw new F("invalid type passed to GitAnnotatedTag constructor")}static from(t){return new V(t)}static render(t){return`object ${t.object}
4
+ type ${t.type}
5
+ tag ${t.tag}
6
+ tagger ${mt(t.tagger)}
7
7
 
8
- ${r.message}
9
- ${r.gpgsig?r.gpgsig:""}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(`
8
+ ${t.message}
9
+ ${t.gpgsig?t.gpgsig:""}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(`
10
10
 
11
- `))}message(){const r=this.withoutSignature();return r.slice(r.indexOf(`
11
+ `))}message(){const t=this.withoutSignature();return t.slice(t.indexOf(`
12
12
 
13
- `)+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){const r=this.justHeaders().split(`
14
- `),o=[];for(const u of r)u[0]===" "?o[o.length-1]+=`
15
- `+u.slice(1):o.push(u);const s={};for(const u of o){const f=u.slice(0,u.indexOf(" ")),h=u.slice(u.indexOf(" ")+1);Array.isArray(s[f])?s[f].push(h):s[f]=h}return s.tagger&&(s.tagger=ot(s.tagger)),s.committer&&(s.committer=ot(s.committer)),s}withoutSignature(){const r=G(this._tag);return r.indexOf(`
16
- -----BEGIN PGP SIGNATURE-----`)===-1?r:r.slice(0,r.lastIndexOf(`
13
+ `)+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){const t=this.justHeaders().split(`
14
+ `),n=[];for(const c of t)c[0]===" "?n[n.length-1]+=`
15
+ `+c.slice(1):n.push(c);const s={};for(const c of n){const f=c.slice(0,c.indexOf(" ")),h=c.slice(c.indexOf(" ")+1);Array.isArray(s[f])?s[f].push(h):s[f]=h}return s.tagger&&(s.tagger=it(s.tagger)),s.committer&&(s.committer=it(s.committer)),s}withoutSignature(){const t=G(this._tag);return t.indexOf(`
16
+ -----BEGIN PGP SIGNATURE-----`)===-1?t:t.slice(0,t.lastIndexOf(`
17
17
  -----BEGIN PGP SIGNATURE-----`))}gpgsig(){if(this._tag.indexOf(`
18
- -----BEGIN PGP SIGNATURE-----`)===-1)return;const r=this._tag.slice(this._tag.indexOf("-----BEGIN PGP SIGNATURE-----"),this._tag.indexOf("-----END PGP SIGNATURE-----")+27);return G(r)}payload(){return this.withoutSignature()+`
19
- `}toObject(){return Buffer.from(this._tag,"utf8")}static async sign(r,o,s){const u=r.payload();let{signature:f}=await o({payload:u,secretKey:s});f=G(f);const h=u+f;return Z.from(h)}}function pt(n){return n.trim().split(`
20
- `).map(r=>" "+r).join(`
18
+ -----BEGIN PGP SIGNATURE-----`)===-1)return;const t=this._tag.slice(this._tag.indexOf("-----BEGIN PGP SIGNATURE-----"),this._tag.indexOf("-----END PGP SIGNATURE-----")+27);return G(t)}payload(){return this.withoutSignature()+`
19
+ `}toObject(){return Buffer.from(this._tag,"utf8")}static async sign(t,n,s){const c=t.payload();let{signature:f}=await n({payload:c,secretKey:s});f=G(f);const h=c+f;return V.from(h)}}function lt(i){return i.trim().split(`
20
+ `).map(t=>" "+t).join(`
21
21
  `)+`
22
- `}function or(n){return n.split(`
23
- `).map(r=>r.replace(/^ /,"")).join(`
24
- `)}class P{constructor(r){if(typeof r=="string")this._commit=r;else if(Buffer.isBuffer(r))this._commit=r.toString("utf8");else if(typeof r=="object")this._commit=P.render(r);else throw new _("invalid type passed to GitCommit constructor")}static fromPayloadSignature({payload:r,signature:o}){const s=P.justHeaders(r),u=P.justMessage(r),f=G(s+`
25
- gpgsig`+pt(o)+`
26
- `+u);return new P(f)}static from(r){return new P(r)}toObject(){return Buffer.from(this._commit,"utf8")}headers(){return this.parseHeaders()}message(){return P.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(r){return G(r.slice(r.indexOf(`
22
+ `}function cr(i){return i.split(`
23
+ `).map(t=>t.replace(/^ /,"")).join(`
24
+ `)}class R{constructor(t){if(typeof t=="string")this._commit=t;else if(Buffer.isBuffer(t))this._commit=t.toString("utf8");else if(typeof t=="object")this._commit=R.render(t);else throw new F("invalid type passed to GitCommit constructor")}static fromPayloadSignature({payload:t,signature:n}){const s=R.justHeaders(t),c=R.justMessage(t),f=G(s+`
25
+ gpgsig`+lt(n)+`
26
+ `+c);return new R(f)}static from(t){return new R(t)}toObject(){return Buffer.from(this._commit,"utf8")}headers(){return this.parseHeaders()}message(){return R.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(t){return G(t.slice(t.indexOf(`
27
27
 
28
- `)+2))}static justHeaders(r){return r.slice(0,r.indexOf(`
28
+ `)+2))}static justHeaders(t){return t.slice(0,t.indexOf(`
29
29
 
30
- `))}parseHeaders(){const r=P.justHeaders(this._commit).split(`
31
- `),o=[];for(const u of r)u[0]===" "?o[o.length-1]+=`
32
- `+u.slice(1):o.push(u);const s={parent:[]};for(const u of o){const f=u.slice(0,u.indexOf(" ")),h=u.slice(u.indexOf(" ")+1);Array.isArray(s[f])?s[f].push(h):s[f]=h}return s.author&&(s.author=ot(s.author)),s.committer&&(s.committer=ot(s.committer)),s}static renderHeaders(r){let o="";if(r.tree?o+=`tree ${r.tree}
33
- `:o+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
34
- `,r.parent){if(r.parent.length===void 0)throw new _("commit 'parent' property should be an array");for(const f of r.parent)o+=`parent ${f}
35
- `}const s=r.author;o+=`author ${mt(s)}
36
- `;const u=r.committer||r.author;return o+=`committer ${mt(u)}
37
- `,r.gpgsig&&(o+="gpgsig"+pt(r.gpgsig)),o}static render(r){return P.renderHeaders(r)+`
38
- `+G(r.message)}render(){return this._commit}withoutSignature(){const r=G(this._commit);if(r.indexOf(`
39
- gpgsig`)===-1)return r;const o=r.slice(0,r.indexOf(`
40
- gpgsig`)),s=r.slice(r.indexOf(`-----END PGP SIGNATURE-----
41
- `)+28);return G(o+`
42
- `+s)}isolateSignature(){const r=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return or(r)}static async sign(r,o,s){const u=r.withoutSignature(),f=P.justMessage(r._commit);let{signature:h}=await o({payload:u,secretKey:s});h=G(h);const w=P.justHeaders(r._commit)+`
43
- gpgsig`+pt(h)+`
44
- `+f;return P.from(w)}}class sr{static wrap({type:r,object:o}){return Buffer.concat([Buffer.from(`${r} ${o.byteLength.toString()}\0`),Buffer.from(o)])}static unwrap(r){const o=r.indexOf(32),s=r.indexOf(0),u=r.slice(0,o).toString("utf8"),f=r.slice(o+1,s).toString("utf8"),h=r.length-(s+1);if(parseInt(f)!==h)throw new _(`Length mismatch: expected ${f} bytes but got ${h} instead.`);return{type:u,object:Buffer.from(r.slice(s+1))}}}class z{constructor(r){this.buffer=r,this._start=0}eof(){return this._start>=this.buffer.length}tell(){return this._start}seek(r){this._start=r}slice(r){const o=this.buffer.slice(this._start,this._start+r);return this._start+=r,o}toString(r,o){const s=this.buffer.toString(r,this._start,this._start+o);return this._start+=o,s}write(r,o,s){const u=this.buffer.write(r,this._start,o,s);return this._start+=o,u}copy(r,o,s){const u=r.copy(this.buffer,this._start,o,s);return this._start+=u,u}readUInt8(){const r=this.buffer.readUInt8(this._start);return this._start+=1,r}writeUInt8(r){const o=this.buffer.writeUInt8(r,this._start);return this._start+=1,o}readUInt16BE(){const r=this.buffer.readUInt16BE(this._start);return this._start+=2,r}writeUInt16BE(r){const o=this.buffer.writeUInt16BE(r,this._start);return this._start+=2,o}readUInt32BE(){const r=this.buffer.readUInt32BE(this._start);return this._start+=4,r}writeUInt32BE(r){const o=this.buffer.writeUInt32BE(r,this._start);return this._start+=4,o}}function ar(n,r){const o=new z(n),s=Dt(o);if(s!==r.byteLength)throw new _(`applyDelta expected source buffer to be ${s} bytes but the provided buffer was ${r.length} bytes`);const u=Dt(o);let f;const h=jt(o,r);if(h.byteLength===u)f=h;else{f=Buffer.alloc(u);const a=new z(f);for(a.copy(h);!o.eof();)a.copy(jt(o,r));const w=a.tell();if(u!==w)throw new _(`applyDelta expected target buffer to be ${u} bytes but the resulting buffer was ${w} bytes`)}return f}function Dt(n){let r=0,o=0,s=null;do s=n.readUInt8(),r|=(s&127)<<o,o+=7;while(s&128);return r}function Nt(n,r,o){let s=0,u=0;for(;o--;)r&1&&(s|=n.readUInt8()<<u),r>>=1,u+=8;return s}function jt(n,r){const o=n.readUInt8(),s=128,u=15,f=112;if(o&s){const h=Nt(n,o&u,4);let a=Nt(n,(o&f)>>4,3);return a===0&&(a=65536),r.slice(h,h+a)}else return n.slice(o)}async function cr(n,r){const o=new Vt(n);let s=await o.read(4);if(s=s.toString("utf8"),s!=="PACK")throw new _(`Invalid PACK header '${s}'`);let u=await o.read(4);if(u=u.readUInt32BE(0),u!==2)throw new _(`Invalid packfile version: ${u}`);let f=await o.read(4);if(f=f.readUInt32BE(0),!(f<1))for(;!o.eof()&&f--;){const h=o.tell(),{type:a,length:w,ofs:y,reference:g}=await ur(o),m=new Mt.Inflate;for(;!m.result;){const b=await o.chunk();if(!b)break;if(m.push(b,!1),m.err)throw new _(`Pako error: ${m.msg}`);if(m.result){if(m.result.length!==w)throw new _("Inflated object size is different from that stated in packfile.");await o.undo(),await o.read(b.length-m.strm.avail_in);const B=o.tell();await r({data:m.result,type:a,num:f,offset:h,end:B,reference:g,ofs:y})}}}}async function ur(n){let r=await n.byte();const o=r>>4&7;let s=r&15;if(r&128){let h=4;do r=await n.byte(),s|=(r&127)<<h,h+=7;while(r&128)}let u,f;if(o===6){let h=0;u=0;const a=[];do r=await n.byte(),u|=(r&127)<<h,h+=7,a.push(r);while(r&128);f=Buffer.from(a)}return o===7&&(f=await n.read(20)),{type:o,length:s,ofs:u,reference:f}}let fr=!1;async function hr(n){return fr?lr(n):Mt.inflate(n)}async function lr(n){const r=new DecompressionStream("deflate"),o=new Blob([n]).stream().pipeThrough(r);return new Uint8Array(await new Response(o).arrayBuffer())}function pr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var bt={exports:{}};typeof Object.create=="function"?bt.exports=function(r,o){o&&(r.super_=o,r.prototype=Object.create(o.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:bt.exports=function(r,o){if(o){r.super_=o;var s=function(){};s.prototype=o.prototype,r.prototype=new s,r.prototype.constructor=r}};var dr=bt.exports,xt={exports:{}},H={},at={};at.byteLength=gr;at.toByteArray=br;at.fromByteArray=Er;var j=[],R=[],wr=typeof Uint8Array<"u"?Uint8Array:Array,dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var K=0,yr=dt.length;K<yr;++K)j[K]=dt[K],R[dt.charCodeAt(K)]=K;R["-".charCodeAt(0)]=62;R["_".charCodeAt(0)]=63;function Xt(n){var r=n.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var o=n.indexOf("=");o===-1&&(o=r);var s=o===r?0:4-o%4;return[o,s]}function gr(n){var r=Xt(n),o=r[0],s=r[1];return(o+s)*3/4-s}function mr(n,r,o){return(r+o)*3/4-o}function br(n){var r,o=Xt(n),s=o[0],u=o[1],f=new wr(mr(n,s,u)),h=0,a=u>0?s-4:s,w;for(w=0;w<a;w+=4)r=R[n.charCodeAt(w)]<<18|R[n.charCodeAt(w+1)]<<12|R[n.charCodeAt(w+2)]<<6|R[n.charCodeAt(w+3)],f[h++]=r>>16&255,f[h++]=r>>8&255,f[h++]=r&255;return u===2&&(r=R[n.charCodeAt(w)]<<2|R[n.charCodeAt(w+1)]>>4,f[h++]=r&255),u===1&&(r=R[n.charCodeAt(w)]<<10|R[n.charCodeAt(w+1)]<<4|R[n.charCodeAt(w+2)]>>2,f[h++]=r>>8&255,f[h++]=r&255),f}function xr(n){return j[n>>18&63]+j[n>>12&63]+j[n>>6&63]+j[n&63]}function Br(n,r,o){for(var s,u=[],f=r;f<o;f+=3)s=(n[f]<<16&16711680)+(n[f+1]<<8&65280)+(n[f+2]&255),u.push(xr(s));return u.join("")}function Er(n){for(var r,o=n.length,s=o%3,u=[],f=16383,h=0,a=o-s;h<a;h+=f)u.push(Br(n,h,h+f>a?a:h+f));return s===1?(r=n[o-1],u.push(j[r>>2]+j[r<<4&63]+"==")):s===2&&(r=(n[o-2]<<8)+n[o-1],u.push(j[r>>10]+j[r>>4&63]+j[r<<2&63]+"=")),u.join("")}var Et={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Et.read=function(n,r,o,s,u){var f,h,a=u*8-s-1,w=(1<<a)-1,y=w>>1,g=-7,m=o?u-1:0,b=o?-1:1,B=n[r+m];for(m+=b,f=B&(1<<-g)-1,B>>=-g,g+=a;g>0;f=f*256+n[r+m],m+=b,g-=8);for(h=f&(1<<-g)-1,f>>=-g,g+=s;g>0;h=h*256+n[r+m],m+=b,g-=8);if(f===0)f=1-y;else{if(f===w)return h?NaN:(B?-1:1)*(1/0);h=h+Math.pow(2,s),f=f-y}return(B?-1:1)*h*Math.pow(2,f-s)};Et.write=function(n,r,o,s,u,f){var h,a,w,y=f*8-u-1,g=(1<<y)-1,m=g>>1,b=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=s?0:f-1,T=s?1:-1,L=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,h=g):(h=Math.floor(Math.log(r)/Math.LN2),r*(w=Math.pow(2,-h))<1&&(h--,w*=2),h+m>=1?r+=b/w:r+=b*Math.pow(2,1-m),r*w>=2&&(h++,w/=2),h+m>=g?(a=0,h=g):h+m>=1?(a=(r*w-1)*Math.pow(2,u),h=h+m):(a=r*Math.pow(2,m-1)*Math.pow(2,u),h=0));u>=8;n[o+B]=a&255,B+=T,a/=256,u-=8);for(h=h<<u|a,y+=u;y>0;n[o+B]=h&255,B+=T,h/=256,y-=8);n[o+B-T]|=L*128};/*!
30
+ `))}parseHeaders(){const t=R.justHeaders(this._commit).split(`
31
+ `),n=[];for(const c of t)c[0]===" "?n[n.length-1]+=`
32
+ `+c.slice(1):n.push(c);const s={parent:[]};for(const c of n){const f=c.slice(0,c.indexOf(" ")),h=c.slice(c.indexOf(" ")+1);Array.isArray(s[f])?s[f].push(h):s[f]=h}return s.author&&(s.author=it(s.author)),s.committer&&(s.committer=it(s.committer)),s}static renderHeaders(t){let n="";if(t.tree?n+=`tree ${t.tree}
33
+ `:n+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
34
+ `,t.parent){if(t.parent.length===void 0)throw new F("commit 'parent' property should be an array");for(const f of t.parent)n+=`parent ${f}
35
+ `}const s=t.author;n+=`author ${mt(s)}
36
+ `;const c=t.committer||t.author;return n+=`committer ${mt(c)}
37
+ `,t.gpgsig&&(n+="gpgsig"+lt(t.gpgsig)),n}static render(t){return R.renderHeaders(t)+`
38
+ `+G(t.message)}render(){return this._commit}withoutSignature(){const t=G(this._commit);if(t.indexOf(`
39
+ gpgsig`)===-1)return t;const n=t.slice(0,t.indexOf(`
40
+ gpgsig`)),s=t.slice(t.indexOf(`-----END PGP SIGNATURE-----
41
+ `)+28);return G(n+`
42
+ `+s)}isolateSignature(){const t=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return cr(t)}static async sign(t,n,s){const c=t.withoutSignature(),f=R.justMessage(t._commit);let{signature:h}=await n({payload:c,secretKey:s});h=G(h);const d=R.justHeaders(t._commit)+`
43
+ gpgsig`+lt(h)+`
44
+ `+f;return R.from(d)}}class ur{static wrap({type:t,object:n}){return Buffer.concat([Buffer.from(`${t} ${n.byteLength.toString()}\0`),Buffer.from(n)])}static unwrap(t){const n=t.indexOf(32),s=t.indexOf(0),c=t.slice(0,n).toString("utf8"),f=t.slice(n+1,s).toString("utf8"),h=t.length-(s+1);if(parseInt(f)!==h)throw new F(`Length mismatch: expected ${f} bytes but got ${h} instead.`);return{type:c,object:Buffer.from(t.slice(s+1))}}}class q{constructor(t){this.buffer=t,this._start=0}eof(){return this._start>=this.buffer.length}tell(){return this._start}seek(t){this._start=t}slice(t){const n=this.buffer.slice(this._start,this._start+t);return this._start+=t,n}toString(t,n){const s=this.buffer.toString(t,this._start,this._start+n);return this._start+=n,s}write(t,n,s){const c=this.buffer.write(t,this._start,n,s);return this._start+=n,c}copy(t,n,s){const c=t.copy(this.buffer,this._start,n,s);return this._start+=c,c}readUInt8(){const t=this.buffer.readUInt8(this._start);return this._start+=1,t}writeUInt8(t){const n=this.buffer.writeUInt8(t,this._start);return this._start+=1,n}readUInt16BE(){const t=this.buffer.readUInt16BE(this._start);return this._start+=2,t}writeUInt16BE(t){const n=this.buffer.writeUInt16BE(t,this._start);return this._start+=2,n}readUInt32BE(){const t=this.buffer.readUInt32BE(this._start);return this._start+=4,t}writeUInt32BE(t){const n=this.buffer.writeUInt32BE(t,this._start);return this._start+=4,n}}function fr(i,t){const n=new q(i),s=Ot(n);if(s!==t.byteLength)throw new F(`applyDelta expected source buffer to be ${s} bytes but the provided buffer was ${t.length} bytes`);const c=Ot(n);let f;const h=Pt(n,t);if(h.byteLength===c)f=h;else{f=Buffer.alloc(c);const a=new q(f);for(a.copy(h);!n.eof();)a.copy(Pt(n,t));const d=a.tell();if(c!==d)throw new F(`applyDelta expected target buffer to be ${c} bytes but the resulting buffer was ${d} bytes`)}return f}function Ot(i){let t=0,n=0,s=null;do s=i.readUInt8(),t|=(s&127)<<n,n+=7;while(s&128);return t}function Dt(i,t,n){let s=0,c=0;for(;n--;)t&1&&(s|=i.readUInt8()<<c),t>>=1,c+=8;return s}function Pt(i,t){const n=i.readUInt8(),s=128,c=15,f=112;if(n&s){const h=Dt(i,n&c,4);let a=Dt(i,(n&f)>>4,3);return a===0&&(a=65536),t.slice(h,h+a)}else return i.slice(n)}async function hr(i,t){const n=new Yt(i);let s=await n.read(4);if(s=s.toString("utf8"),s!=="PACK")throw new F(`Invalid PACK header '${s}'`);let c=await n.read(4);if(c=c.readUInt32BE(0),c!==2)throw new F(`Invalid packfile version: ${c}`);let f=await n.read(4);if(f=f.readUInt32BE(0),!(f<1))for(;!n.eof()&&f--;){const h=n.tell(),{type:a,length:d,ofs:y,reference:m}=await lr(n),g=new Lt.Inflate;for(;!g.result;){const b=await n.chunk();if(!b)break;if(g.push(b,!1),g.err)throw new F(`Pako error: ${g.msg}`);if(g.result){if(g.result.length!==d)throw new F("Inflated object size is different from that stated in packfile.");await n.undo(),await n.read(b.length-g.strm.avail_in);const x=n.tell();await t({data:g.result,type:a,num:f,offset:h,end:x,reference:m,ofs:y})}}}}async function lr(i){let t=await i.byte();const n=t>>4&7;let s=t&15;if(t&128){let h=4;do t=await i.byte(),s|=(t&127)<<h,h+=7;while(t&128)}let c,f;if(n===6){let h=0;c=0;const a=[];do t=await i.byte(),c|=(t&127)<<h,h+=7,a.push(t);while(t&128);f=Buffer.from(a)}return n===7&&(f=await i.read(20)),{type:n,length:s,ofs:c,reference:f}}async function pr(i){return Lt.inflate(i)}function dr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var gt={exports:{}};typeof Object.create=="function"?gt.exports=function(t,n){n&&(t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:gt.exports=function(t,n){if(n){t.super_=n;var s=function(){};s.prototype=n.prototype,t.prototype=new s,t.prototype.constructor=t}};var wr=gt.exports,bt={exports:{}},H={},at={};at.byteLength=gr;at.toByteArray=xr;at.fromByteArray=vr;var M=[],O=[],yr=typeof Uint8Array<"u"?Uint8Array:Array,pt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var W=0,mr=pt.length;W<mr;++W)M[W]=pt[W],O[pt.charCodeAt(W)]=W;O[45]=62;O[95]=63;function Vt(i){var t=i.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=i.indexOf("=");n===-1&&(n=t);var s=n===t?0:4-n%4;return[n,s]}function gr(i){var t=Vt(i),n=t[0],s=t[1];return(n+s)*3/4-s}function br(i,t,n){return(t+n)*3/4-n}function xr(i){var t,n=Vt(i),s=n[0],c=n[1],f=new yr(br(i,s,c)),h=0,a=c>0?s-4:s,d;for(d=0;d<a;d+=4)t=O[i.charCodeAt(d)]<<18|O[i.charCodeAt(d+1)]<<12|O[i.charCodeAt(d+2)]<<6|O[i.charCodeAt(d+3)],f[h++]=t>>16&255,f[h++]=t>>8&255,f[h++]=t&255;return c===2&&(t=O[i.charCodeAt(d)]<<2|O[i.charCodeAt(d+1)]>>4,f[h++]=t&255),c===1&&(t=O[i.charCodeAt(d)]<<10|O[i.charCodeAt(d+1)]<<4|O[i.charCodeAt(d+2)]>>2,f[h++]=t>>8&255,f[h++]=t&255),f}function Er(i){return M[i>>18&63]+M[i>>12&63]+M[i>>6&63]+M[i&63]}function Br(i,t,n){for(var s,c=[],f=t;f<n;f+=3)s=(i[f]<<16&16711680)+(i[f+1]<<8&65280)+(i[f+2]&255),c.push(Er(s));return c.join("")}function vr(i){for(var t,n=i.length,s=n%3,c=[],f=16383,h=0,a=n-s;h<a;h+=f)c.push(Br(i,h,h+f>a?a:h+f));return s===1?(t=i[n-1],c.push(M[t>>2]+M[t<<4&63]+"==")):s===2&&(t=(i[n-2]<<8)+i[n-1],c.push(M[t>>10]+M[t>>4&63]+M[t<<2&63]+"=")),c.join("")}var Et={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Et.read=function(i,t,n,s,c){var f,h,a=c*8-s-1,d=(1<<a)-1,y=d>>1,m=-7,g=n?c-1:0,b=n?-1:1,x=i[t+g];for(g+=b,f=x&(1<<-m)-1,x>>=-m,m+=a;m>0;f=f*256+i[t+g],g+=b,m-=8);for(h=f&(1<<-m)-1,f>>=-m,m+=s;m>0;h=h*256+i[t+g],g+=b,m-=8);if(f===0)f=1-y;else{if(f===d)return h?NaN:(x?-1:1)*(1/0);h=h+Math.pow(2,s),f=f-y}return(x?-1:1)*h*Math.pow(2,f-s)};Et.write=function(i,t,n,s,c,f){var h,a,d,y=f*8-c-1,m=(1<<y)-1,g=m>>1,b=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=s?0:f-1,U=s?1:-1,L=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,h=m):(h=Math.floor(Math.log(t)/Math.LN2),t*(d=Math.pow(2,-h))<1&&(h--,d*=2),h+g>=1?t+=b/d:t+=b*Math.pow(2,1-g),t*d>=2&&(h++,d/=2),h+g>=m?(a=0,h=m):h+g>=1?(a=(t*d-1)*Math.pow(2,c),h=h+g):(a=t*Math.pow(2,g-1)*Math.pow(2,c),h=0));c>=8;i[n+x]=a&255,x+=U,a/=256,c-=8);for(h=h<<c|a,y+=c;y>0;i[n+x]=h&255,x+=U,h/=256,y-=8);i[n+x-U]|=L*128};/*!
45
45
  * The buffer module from node.js, for the browser.
46
46
  *
47
47
  * @author Feross Aboukhadijeh <https://feross.org>
48
48
  * @license MIT
49
- */(function(n){const r=at,o=Et,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=M,n.INSPECT_MAX_BYTES=50;const u=2147483647;n.kMaxLength=u,a.TYPED_ARRAY_SUPPORT=f(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function f(){try{const i=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(i,t),i.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function h(i){if(i>u)throw new RangeError('The value "'+i+'" is invalid for option "size"');const t=new Uint8Array(i);return Object.setPrototypeOf(t,a.prototype),t}function a(i,t,e){if(typeof i=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(i)}return w(i,t,e)}a.poolSize=8192;function w(i,t,e){if(typeof i=="string")return b(i,t);if(ArrayBuffer.isView(i))return T(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(N(i,ArrayBuffer)||i&&N(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(N(i,SharedArrayBuffer)||i&&N(i.buffer,SharedArrayBuffer)))return L(i,t,e);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const c=i.valueOf&&i.valueOf();if(c!=null&&c!==i)return a.from(c,t,e);const l=D(i);if(l)return l;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return a.from(i[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}a.from=function(i,t,e){return w(i,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function y(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function g(i,t,e){return y(i),i<=0?h(i):t!==void 0?typeof e=="string"?h(i).fill(t,e):h(i).fill(t):h(i)}a.alloc=function(i,t,e){return g(i,t,e)};function m(i){return y(i),h(i<0?0:U(i)|0)}a.allocUnsafe=function(i){return m(i)},a.allocUnsafeSlow=function(i){return m(i)};function b(i,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const e=$(i,t)|0;let c=h(e);const l=c.write(i,t);return l!==e&&(c=c.slice(0,l)),c}function B(i){const t=i.length<0?0:U(i.length)|0,e=h(t);for(let c=0;c<t;c+=1)e[c]=i[c]&255;return e}function T(i){if(N(i,Uint8Array)){const t=new Uint8Array(i);return L(t.buffer,t.byteOffset,t.byteLength)}return B(i)}function L(i,t,e){if(t<0||i.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let c;return t===void 0&&e===void 0?c=new Uint8Array(i):e===void 0?c=new Uint8Array(i,t):c=new Uint8Array(i,t,e),Object.setPrototypeOf(c,a.prototype),c}function D(i){if(a.isBuffer(i)){const t=U(i.length)|0,e=h(t);return e.length===0||i.copy(e,0,0,t),e}if(i.length!==void 0)return typeof i.length!="number"||lt(i.length)?h(0):B(i);if(i.type==="Buffer"&&Array.isArray(i.data))return B(i.data)}function U(i){if(i>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return i|0}function M(i){return+i!=i&&(i=0),a.alloc(+i)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,e){if(N(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),N(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let c=t.length,l=e.length;for(let p=0,d=Math.min(c,l);p<d;++p)if(t[p]!==e[p]){c=t[p],l=e[p];break}return c<l?-1:l<c?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);let c;if(e===void 0)for(e=0,c=0;c<t.length;++c)e+=t[c].length;const l=a.allocUnsafe(e);let p=0;for(c=0;c<t.length;++c){let d=t[c];if(N(d,Uint8Array))p+d.length>l.length?(a.isBuffer(d)||(d=a.from(d)),d.copy(l,p)):Uint8Array.prototype.set.call(l,d,p);else if(a.isBuffer(d))d.copy(l,p);else throw new TypeError('"list" argument must be an Array of Buffers');p+=d.length}return l};function $(i,t){if(a.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||N(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);const e=i.length,c=arguments.length>2&&arguments[2]===!0;if(!c&&e===0)return 0;let l=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return ht(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Pt(i).length;default:if(l)return c?-1:ht(i).length;t=(""+t).toLowerCase(),l=!0}}a.byteLength=$;function v(i,t,e){let c=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(i||(i="utf8");;)switch(i){case"hex":return me(this,t,e);case"utf8":case"utf-8":return Ft(this,t,e);case"ascii":return ye(this,t,e);case"latin1":case"binary":return ge(this,t,e);case"base64":return de(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return be(this,t,e);default:if(c)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),c=!0}}a.prototype._isBuffer=!0;function C(i,t,e){const c=i[t];i[t]=i[e],i[e]=c}a.prototype.swap16=function(){const t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)C(this,e,e+1);return this},a.prototype.swap32=function(){const t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)C(this,e,e+3),C(this,e+1,e+2);return this},a.prototype.swap64=function(){const t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)C(this,e,e+7),C(this,e+1,e+6),C(this,e+2,e+5),C(this,e+3,e+4);return this},a.prototype.toString=function(){const t=this.length;return t===0?"":arguments.length===0?Ft(this,0,t):v.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0},a.prototype.inspect=function(){let t="";const e=n.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(t,e,c,l,p){if(N(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),c===void 0&&(c=t?t.length:0),l===void 0&&(l=0),p===void 0&&(p=this.length),e<0||c>t.length||l<0||p>this.length)throw new RangeError("out of range index");if(l>=p&&e>=c)return 0;if(l>=p)return-1;if(e>=c)return 1;if(e>>>=0,c>>>=0,l>>>=0,p>>>=0,this===t)return 0;let d=p-l,x=c-e;const F=Math.min(d,x),I=this.slice(l,p),A=t.slice(e,c);for(let E=0;E<F;++E)if(I[E]!==A[E]){d=I[E],x=A[E];break}return d<x?-1:x<d?1:0};function It(i,t,e,c,l){if(i.length===0)return-1;if(typeof e=="string"?(c=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,lt(e)&&(e=l?0:i.length-1),e<0&&(e=i.length+e),e>=i.length){if(l)return-1;e=i.length-1}else if(e<0)if(l)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,c)),a.isBuffer(t))return t.length===0?-1:_t(i,t,e,c,l);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?l?Uint8Array.prototype.indexOf.call(i,t,e):Uint8Array.prototype.lastIndexOf.call(i,t,e):_t(i,[t],e,c,l);throw new TypeError("val must be string, number or Buffer")}function _t(i,t,e,c,l){let p=1,d=i.length,x=t.length;if(c!==void 0&&(c=String(c).toLowerCase(),c==="ucs2"||c==="ucs-2"||c==="utf16le"||c==="utf-16le")){if(i.length<2||t.length<2)return-1;p=2,d/=2,x/=2,e/=2}function F(A,E){return p===1?A[E]:A.readUInt16BE(E*p)}let I;if(l){let A=-1;for(I=e;I<d;I++)if(F(i,I)===F(t,A===-1?0:I-A)){if(A===-1&&(A=I),I-A+1===x)return A*p}else A!==-1&&(I-=I-A),A=-1}else for(e+x>d&&(e=d-x),I=e;I>=0;I--){let A=!0;for(let E=0;E<x;E++)if(F(i,I+E)!==F(t,E)){A=!1;break}if(A)return I}return-1}a.prototype.includes=function(t,e,c){return this.indexOf(t,e,c)!==-1},a.prototype.indexOf=function(t,e,c){return It(this,t,e,c,!0)},a.prototype.lastIndexOf=function(t,e,c){return It(this,t,e,c,!1)};function ue(i,t,e,c){e=Number(e)||0;const l=i.length-e;c?(c=Number(c),c>l&&(c=l)):c=l;const p=t.length;c>p/2&&(c=p/2);let d;for(d=0;d<c;++d){const x=parseInt(t.substr(d*2,2),16);if(lt(x))return d;i[e+d]=x}return d}function fe(i,t,e,c){return it(ht(t,i.length-e),i,e,c)}function he(i,t,e,c){return it(Ie(t),i,e,c)}function le(i,t,e,c){return it(Pt(t),i,e,c)}function pe(i,t,e,c){return it(_e(t,i.length-e),i,e,c)}a.prototype.write=function(t,e,c,l){if(e===void 0)l="utf8",c=this.length,e=0;else if(c===void 0&&typeof e=="string")l=e,c=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(c)?(c=c>>>0,l===void 0&&(l="utf8")):(l=c,c=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const p=this.length-e;if((c===void 0||c>p)&&(c=p),t.length>0&&(c<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");l||(l="utf8");let d=!1;for(;;)switch(l){case"hex":return ue(this,t,e,c);case"utf8":case"utf-8":return fe(this,t,e,c);case"ascii":case"latin1":case"binary":return he(this,t,e,c);case"base64":return le(this,t,e,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,e,c);default:if(d)throw new TypeError("Unknown encoding: "+l);l=(""+l).toLowerCase(),d=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function de(i,t,e){return t===0&&e===i.length?r.fromByteArray(i):r.fromByteArray(i.slice(t,e))}function Ft(i,t,e){e=Math.min(i.length,e);const c=[];let l=t;for(;l<e;){const p=i[l];let d=null,x=p>239?4:p>223?3:p>191?2:1;if(l+x<=e){let F,I,A,E;switch(x){case 1:p<128&&(d=p);break;case 2:F=i[l+1],(F&192)===128&&(E=(p&31)<<6|F&63,E>127&&(d=E));break;case 3:F=i[l+1],I=i[l+2],(F&192)===128&&(I&192)===128&&(E=(p&15)<<12|(F&63)<<6|I&63,E>2047&&(E<55296||E>57343)&&(d=E));break;case 4:F=i[l+1],I=i[l+2],A=i[l+3],(F&192)===128&&(I&192)===128&&(A&192)===128&&(E=(p&15)<<18|(F&63)<<12|(I&63)<<6|A&63,E>65535&&E<1114112&&(d=E))}}d===null?(d=65533,x=1):d>65535&&(d-=65536,c.push(d>>>10&1023|55296),d=56320|d&1023),c.push(d),l+=x}return we(c)}const At=4096;function we(i){const t=i.length;if(t<=At)return String.fromCharCode.apply(String,i);let e="",c=0;for(;c<t;)e+=String.fromCharCode.apply(String,i.slice(c,c+=At));return e}function ye(i,t,e){let c="";e=Math.min(i.length,e);for(let l=t;l<e;++l)c+=String.fromCharCode(i[l]&127);return c}function ge(i,t,e){let c="";e=Math.min(i.length,e);for(let l=t;l<e;++l)c+=String.fromCharCode(i[l]);return c}function me(i,t,e){const c=i.length;(!t||t<0)&&(t=0),(!e||e<0||e>c)&&(e=c);let l="";for(let p=t;p<e;++p)l+=Fe[i[p]];return l}function be(i,t,e){const c=i.slice(t,e);let l="";for(let p=0;p<c.length-1;p+=2)l+=String.fromCharCode(c[p]+c[p+1]*256);return l}a.prototype.slice=function(t,e){const c=this.length;t=~~t,e=e===void 0?c:~~e,t<0?(t+=c,t<0&&(t=0)):t>c&&(t=c),e<0?(e+=c,e<0&&(e=0)):e>c&&(e=c),e<t&&(e=t);const l=this.subarray(t,e);return Object.setPrototypeOf(l,a.prototype),l};function S(i,t,e){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,c){t=t>>>0,e=e>>>0,c||S(t,e,this.length);let l=this[t],p=1,d=0;for(;++d<e&&(p*=256);)l+=this[t+d]*p;return l},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,c){t=t>>>0,e=e>>>0,c||S(t,e,this.length);let l=this[t+--e],p=1;for(;e>0&&(p*=256);)l+=this[t+--e]*p;return l},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||S(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||S(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||S(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||S(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=q(function(t){t=t>>>0,V(t,"offset");const e=this[t],c=this[t+7];(e===void 0||c===void 0)&&X(t,this.length-8);const l=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,p=this[++t]+this[++t]*2**8+this[++t]*2**16+c*2**24;return BigInt(l)+(BigInt(p)<<BigInt(32))}),a.prototype.readBigUInt64BE=q(function(t){t=t>>>0,V(t,"offset");const e=this[t],c=this[t+7];(e===void 0||c===void 0)&&X(t,this.length-8);const l=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],p=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+c;return(BigInt(l)<<BigInt(32))+BigInt(p)}),a.prototype.readIntLE=function(t,e,c){t=t>>>0,e=e>>>0,c||S(t,e,this.length);let l=this[t],p=1,d=0;for(;++d<e&&(p*=256);)l+=this[t+d]*p;return p*=128,l>=p&&(l-=Math.pow(2,8*e)),l},a.prototype.readIntBE=function(t,e,c){t=t>>>0,e=e>>>0,c||S(t,e,this.length);let l=e,p=1,d=this[t+--l];for(;l>0&&(p*=256);)d+=this[t+--l]*p;return p*=128,d>=p&&(d-=Math.pow(2,8*e)),d},a.prototype.readInt8=function(t,e){return t=t>>>0,e||S(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||S(t,2,this.length);const c=this[t]|this[t+1]<<8;return c&32768?c|4294901760:c},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||S(t,2,this.length);const c=this[t+1]|this[t]<<8;return c&32768?c|4294901760:c},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t=t>>>0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=q(function(t){t=t>>>0,V(t,"offset");const e=this[t],c=this[t+7];(e===void 0||c===void 0)&&X(t,this.length-8);const l=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(c<<24);return(BigInt(l)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)}),a.prototype.readBigInt64BE=q(function(t){t=t>>>0,V(t,"offset");const e=this[t],c=this[t+7];(e===void 0||c===void 0)&&X(t,this.length-8);const l=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(l)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+c)}),a.prototype.readFloatLE=function(t,e){return t=t>>>0,e||S(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||S(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||S(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||S(t,8,this.length),o.read(this,t,!1,52,8)};function O(i,t,e,c,l,p){if(!a.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>l||t<p)throw new RangeError('"value" argument is out of bounds');if(e+c>i.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,c,l){if(t=+t,e=e>>>0,c=c>>>0,!l){const x=Math.pow(2,8*c)-1;O(this,t,e,c,x,0)}let p=1,d=0;for(this[e]=t&255;++d<c&&(p*=256);)this[e+d]=t/p&255;return e+c},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,c,l){if(t=+t,e=e>>>0,c=c>>>0,!l){const x=Math.pow(2,8*c)-1;O(this,t,e,c,x,0)}let p=c-1,d=1;for(this[e+p]=t&255;--p>=0&&(d*=256);)this[e+p]=t/d&255;return e+c},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,c){return t=+t,e=e>>>0,c||O(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,c){return t=+t,e=e>>>0,c||O(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,c){return t=+t,e=e>>>0,c||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,c){return t=+t,e=e>>>0,c||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,c){return t=+t,e=e>>>0,c||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Ut(i,t,e,c,l){Ot(t,c,l,i,e,7);let p=Number(t&BigInt(4294967295));i[e++]=p,p=p>>8,i[e++]=p,p=p>>8,i[e++]=p,p=p>>8,i[e++]=p;let d=Number(t>>BigInt(32)&BigInt(4294967295));return i[e++]=d,d=d>>8,i[e++]=d,d=d>>8,i[e++]=d,d=d>>8,i[e++]=d,e}function St(i,t,e,c,l){Ot(t,c,l,i,e,7);let p=Number(t&BigInt(4294967295));i[e+7]=p,p=p>>8,i[e+6]=p,p=p>>8,i[e+5]=p,p=p>>8,i[e+4]=p;let d=Number(t>>BigInt(32)&BigInt(4294967295));return i[e+3]=d,d=d>>8,i[e+2]=d,d=d>>8,i[e+1]=d,d=d>>8,i[e]=d,e+8}a.prototype.writeBigUInt64LE=q(function(t,e=0){return Ut(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=q(function(t,e=0){return St(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(t,e,c,l){if(t=+t,e=e>>>0,!l){const F=Math.pow(2,8*c-1);O(this,t,e,c,F-1,-F)}let p=0,d=1,x=0;for(this[e]=t&255;++p<c&&(d*=256);)t<0&&x===0&&this[e+p-1]!==0&&(x=1),this[e+p]=(t/d>>0)-x&255;return e+c},a.prototype.writeIntBE=function(t,e,c,l){if(t=+t,e=e>>>0,!l){const F=Math.pow(2,8*c-1);O(this,t,e,c,F-1,-F)}let p=c-1,d=1,x=0;for(this[e+p]=t&255;--p>=0&&(d*=256);)t<0&&x===0&&this[e+p+1]!==0&&(x=1),this[e+p]=(t/d>>0)-x&255;return e+c},a.prototype.writeInt8=function(t,e,c){return t=+t,e=e>>>0,c||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,c){return t=+t,e=e>>>0,c||O(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,c){return t=+t,e=e>>>0,c||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,c){return t=+t,e=e>>>0,c||O(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,c){return t=+t,e=e>>>0,c||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},a.prototype.writeBigInt64LE=q(function(t,e=0){return Ut(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=q(function(t,e=0){return St(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function kt(i,t,e,c,l,p){if(e+c>i.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Tt(i,t,e,c,l){return t=+t,e=e>>>0,l||kt(i,t,e,4),o.write(i,t,e,c,23,4),e+4}a.prototype.writeFloatLE=function(t,e,c){return Tt(this,t,e,!0,c)},a.prototype.writeFloatBE=function(t,e,c){return Tt(this,t,e,!1,c)};function $t(i,t,e,c,l){return t=+t,e=e>>>0,l||kt(i,t,e,8),o.write(i,t,e,c,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,c){return $t(this,t,e,!0,c)},a.prototype.writeDoubleBE=function(t,e,c){return $t(this,t,e,!1,c)},a.prototype.copy=function(t,e,c,l){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(c||(c=0),!l&&l!==0&&(l=this.length),e>=t.length&&(e=t.length),e||(e=0),l>0&&l<c&&(l=c),l===c||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("sourceEnd out of bounds");l>this.length&&(l=this.length),t.length-e<l-c&&(l=t.length-e+c);const p=l-c;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,c,l):Uint8Array.prototype.set.call(t,this.subarray(c,l),e),p},a.prototype.fill=function(t,e,c,l){if(typeof t=="string"){if(typeof e=="string"?(l=e,e=0,c=this.length):typeof c=="string"&&(l=c,c=this.length),l!==void 0&&typeof l!="string")throw new TypeError("encoding must be a string");if(typeof l=="string"&&!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(t.length===1){const d=t.charCodeAt(0);(l==="utf8"&&d<128||l==="latin1")&&(t=d)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<c)throw new RangeError("Out of range index");if(c<=e)return this;e=e>>>0,c=c===void 0?this.length:c>>>0,t||(t=0);let p;if(typeof t=="number")for(p=e;p<c;++p)this[p]=t;else{const d=a.isBuffer(t)?t:a.from(t,l),x=d.length;if(x===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(p=0;p<c-e;++p)this[p+e]=d[p%x]}return this};const Y={};function ft(i,t,e){Y[i]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(l){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:l,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}ft("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ft("ERR_INVALID_ARG_TYPE",function(i,t){return`The "${i}" argument must be of type number. Received type ${typeof t}`},TypeError),ft("ERR_OUT_OF_RANGE",function(i,t,e){let c=`The value of "${i}" is out of range.`,l=e;return Number.isInteger(e)&&Math.abs(e)>2**32?l=Ct(String(e)):typeof e=="bigint"&&(l=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(l=Ct(l)),l+="n"),c+=` It must be ${t}. Received ${l}`,c},RangeError);function Ct(i){let t="",e=i.length;const c=i[0]==="-"?1:0;for(;e>=c+4;e-=3)t=`_${i.slice(e-3,e)}${t}`;return`${i.slice(0,e)}${t}`}function xe(i,t,e){V(t,"offset"),(i[t]===void 0||i[t+e]===void 0)&&X(t,i.length-(e+1))}function Ot(i,t,e,c,l,p){if(i>e||i<t){const d=typeof t=="bigint"?"n":"";let x;throw p>3?t===0||t===BigInt(0)?x=`>= 0${d} and < 2${d} ** ${(p+1)*8}${d}`:x=`>= -(2${d} ** ${(p+1)*8-1}${d}) and < 2 ** ${(p+1)*8-1}${d}`:x=`>= ${t}${d} and <= ${e}${d}`,new Y.ERR_OUT_OF_RANGE("value",x,i)}xe(c,l,p)}function V(i,t){if(typeof i!="number")throw new Y.ERR_INVALID_ARG_TYPE(t,"number",i)}function X(i,t,e){throw Math.floor(i)!==i?(V(i,e),new Y.ERR_OUT_OF_RANGE(e||"offset","an integer",i)):t<0?new Y.ERR_BUFFER_OUT_OF_BOUNDS:new Y.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,i)}const Be=/[^+/0-9A-Za-z-_]/g;function Ee(i){if(i=i.split("=")[0],i=i.trim().replace(Be,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function ht(i,t){t=t||1/0;let e;const c=i.length;let l=null;const p=[];for(let d=0;d<c;++d){if(e=i.charCodeAt(d),e>55295&&e<57344){if(!l){if(e>56319){(t-=3)>-1&&p.push(239,191,189);continue}else if(d+1===c){(t-=3)>-1&&p.push(239,191,189);continue}l=e;continue}if(e<56320){(t-=3)>-1&&p.push(239,191,189),l=e;continue}e=(l-55296<<10|e-56320)+65536}else l&&(t-=3)>-1&&p.push(239,191,189);if(l=null,e<128){if((t-=1)<0)break;p.push(e)}else if(e<2048){if((t-=2)<0)break;p.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;p.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;p.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return p}function Ie(i){const t=[];for(let e=0;e<i.length;++e)t.push(i.charCodeAt(e)&255);return t}function _e(i,t){let e,c,l;const p=[];for(let d=0;d<i.length&&!((t-=2)<0);++d)e=i.charCodeAt(d),c=e>>8,l=e%256,p.push(l),p.push(c);return p}function Pt(i){return r.toByteArray(Ee(i))}function it(i,t,e,c){let l;for(l=0;l<c&&!(l+e>=t.length||l>=i.length);++l)t[l+e]=i[l];return l}function N(i,t){return i instanceof t||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===t.name}function lt(i){return i!==i}const Fe=function(){const i="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){const c=e*16;for(let l=0;l<16;++l)t[c+l]=i[e]+i[l]}return t}();function q(i){return typeof BigInt>"u"?Ae:i}function Ae(){throw new Error("BigInt not supported")}})(H);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,r){var o=H,s=o.Buffer;function u(h,a){for(var w in h)a[w]=h[w]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?n.exports=o:(u(o,r),r.Buffer=f);function f(h,a,w){return s(h,a,w)}f.prototype=Object.create(s.prototype),u(s,f),f.from=function(h,a,w){if(typeof h=="number")throw new TypeError("Argument must not be a number");return s(h,a,w)},f.alloc=function(h,a,w){if(typeof h!="number")throw new TypeError("Argument must be a number");var y=s(h);return a!==void 0?typeof w=="string"?y.fill(a,w):y.fill(a):y.fill(0),y},f.allocUnsafe=function(h){if(typeof h!="number")throw new TypeError("Argument must be a number");return s(h)},f.allocUnsafeSlow=function(h){if(typeof h!="number")throw new TypeError("Argument must be a number");return o.SlowBuffer(h)}})(xt,xt.exports);var Zt=xt.exports,Qt=Zt.Buffer;function ct(n,r){this._block=Qt.alloc(n),this._finalSize=r,this._blockSize=n,this._len=0}ct.prototype.update=function(n,r){typeof n=="string"&&(r=r||"utf8",n=Qt.from(n,r));for(var o=this._block,s=this._blockSize,u=n.length,f=this._len,h=0;h<u;){for(var a=f%s,w=Math.min(u-h,s-a),y=0;y<w;y++)o[a+y]=n[h+y];f+=w,h+=w,f%s===0&&this._update(o)}return this._len+=u,this};ct.prototype.digest=function(n){var r=this._len%this._blockSize;this._block[r]=128,this._block.fill(0,r+1),r>=this._finalSize&&(this._update(this._block),this._block.fill(0));var o=this._len*8;if(o<=4294967295)this._block.writeUInt32BE(o,this._blockSize-4);else{var s=(o&4294967295)>>>0,u=(o-s)/4294967296;this._block.writeUInt32BE(u,this._blockSize-8),this._block.writeUInt32BE(s,this._blockSize-4)}this._update(this._block);var f=this._hash();return n?f.toString(n):f};ct.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Ir=ct,_r=dr,te=Ir,Fr=Zt.Buffer,Ar=[1518500249,1859775393,-1894007588,-899497514],Ur=new Array(80);function nt(){this.init(),this._w=Ur,te.call(this,64,56)}_r(nt,te);nt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Sr(n){return n<<1|n>>>31}function kr(n){return n<<5|n>>>27}function Tr(n){return n<<30|n>>>2}function $r(n,r,o,s){return n===0?r&o|~r&s:n===2?r&o|r&s|o&s:r^o^s}nt.prototype._update=function(n){for(var r=this._w,o=this._a|0,s=this._b|0,u=this._c|0,f=this._d|0,h=this._e|0,a=0;a<16;++a)r[a]=n.readInt32BE(a*4);for(;a<80;++a)r[a]=Sr(r[a-3]^r[a-8]^r[a-14]^r[a-16]);for(var w=0;w<80;++w){var y=~~(w/20),g=kr(o)+$r(y,s,u,f)+h+r[w]+Ar[y]|0;h=f,f=u,u=Tr(s),s=o,o=g}this._a=o+this._a|0,this._b=s+this._b|0,this._c=u+this._c|0,this._d=f+this._d|0,this._e=h+this._e|0};nt.prototype._hash=function(){var n=Fr.allocUnsafe(20);return n.writeInt32BE(this._a|0,0),n.writeInt32BE(this._b|0,4),n.writeInt32BE(this._c|0,8),n.writeInt32BE(this._d|0,12),n.writeInt32BE(this._e|0,16),n};var Cr=nt;const Or=pr(Cr);function Pr(n){let r="";for(const o of new Uint8Array(n))o<16&&(r+="0"),r+=o.toString(16);return r}let wt=null;async function Lt(n){return wt===null&&(wt=await Dr()),wt?ee(n):Rr(n)}function Rr(n){return new Or().update(n).digest("hex")}async function ee(n){const r=await crypto.subtle.digest("SHA-1",n);return Pr(r)}async function Dr(){try{if(await ee(new Uint8Array([]))==="da39a3ee5e6b4b0d3255bfef95601890afd80709")return!0}catch{}return!1}function Nr(n){const r=[];let o=0,s=0;do{o=n.readUInt8();const u=o&127;r.push(u),s=o&128}while(s);return r.reduce((u,f)=>u+1<<7|f,-1)}function jr(n,r){let o=r,s=4,u=null;do u=n.readUInt8(),o|=(u&127)<<s,s+=7;while(u&128);return o}class tt{constructor(r){Object.assign(this,r),this.offsetCache={}}static async fromIdx({idx:r,getExternalRefDelta:o}){const s=new z(r);if(s.slice(4).toString("hex")!=="ff744f63")return;const f=s.readUInt32BE();if(f!==2)throw new _(`Unable to read version ${f} packfile IDX. (Only version 2 supported)`);if(r.byteLength>2048*1024*1024)throw new _("To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.");s.seek(s.tell()+4*255);const h=s.readUInt32BE(),a=[];for(let g=0;g<h;g++){const m=s.slice(20).toString("hex");a[g]=m}s.seek(s.tell()+4*h);const w=new Map;for(let g=0;g<h;g++)w.set(a[g],s.readUInt32BE());const y=s.slice(20).toString("hex");return new tt({hashes:a,crcs:{},offsets:w,packfileSha:y,getExternalRefDelta:o})}static async fromPack({pack:r,getExternalRefDelta:o,onProgress:s}){const u={1:"commit",2:"tree",3:"blob",4:"tag",6:"ofs-delta",7:"ref-delta"},f={},h=r.slice(-20).toString("hex"),a=[],w={},y=new Map;let g=null,m=null;await cr([r],async({data:D,type:U,reference:M,offset:$,num:v})=>{g===null&&(g=v);const C=Math.floor((g-v)*100/g);C!==m&&s&&await s({phase:"Receiving objects",loaded:g-v,total:g}),m=C,U=u[U],["commit","tree","blob","tag"].includes(U)?f[$]={type:U,offset:$}:U==="ofs-delta"?f[$]={type:U,offset:$}:U==="ref-delta"&&(f[$]={type:U,offset:$})});const b=Object.keys(f).map(Number);for(const[D,U]of b.entries()){const M=D+1===b.length?r.byteLength-20:b[D+1],$=f[U],v=Se.buf(r.slice(U,M))>>>0;$.end=M,$.crc=v}const B=new tt({pack:Promise.resolve(r),packfileSha:h,crcs:w,hashes:a,offsets:y,getExternalRefDelta:o});m=null;let T=0;const L=[0,0,0,0,0,0,0,0,0,0,0,0];for(let D in f){D=Number(D);const U=Math.floor(T*100/g);U!==m&&s&&await s({phase:"Resolving deltas",loaded:T,total:g}),T++,m=U;const M=f[D];if(!M.oid)try{B.readDepth=0,B.externalReadDepth=0;const{type:$,object:v}=await B.readSlice({start:D});L[B.readDepth]+=1;const C=await Lt(sr.wrap({type:$,object:v}));M.oid=C,a.push(C),y.set(C,D),w[C]=M.crc}catch{continue}}return a.sort(),B}async toBuffer(){const r=[],o=(y,g)=>{r.push(Buffer.from(y,g))};o("ff744f63","hex"),o("00000002","hex");const s=new z(Buffer.alloc(256*4));for(let y=0;y<256;y++){let g=0;for(const m of this.hashes)parseInt(m.slice(0,2),16)<=y&&g++;s.writeUInt32BE(g)}r.push(s.buffer);for(const y of this.hashes)o(y,"hex");const u=new z(Buffer.alloc(this.hashes.length*4));for(const y of this.hashes)u.writeUInt32BE(this.crcs[y]);r.push(u.buffer);const f=new z(Buffer.alloc(this.hashes.length*4));for(const y of this.hashes)f.writeUInt32BE(this.offsets.get(y));r.push(f.buffer),o(this.packfileSha,"hex");const h=Buffer.concat(r),a=await Lt(h),w=Buffer.alloc(20);return w.write(a,"hex"),Buffer.concat([h,w])}async load({pack:r}){this.pack=r}async unload(){this.pack=null}async read({oid:r}){if(!this.offsets.get(r)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(r);throw new _(`Could not read object ${r} from packfile`)}const o=this.offsets.get(r);return this.readSlice({start:o})}async readSlice({start:r}){if(this.offsetCache[r])return Object.assign({},this.offsetCache[r]);this.readDepth++;const o={16:"commit",32:"tree",48:"blob",64:"tag",96:"ofs_delta",112:"ref_delta"};if(!this.pack)throw new _("Tried to read from a GitPackIndex with no packfile loaded into memory");const s=(await this.pack).slice(r),u=new z(s),f=u.readUInt8(),h=f&112;let a=o[h];if(a===void 0)throw new _("Unrecognized type: 0b"+h.toString(2));const w=f&15;let y=w;f&128&&(y=jr(u,w));let m=null,b=null;if(a==="ofs_delta"){const T=Nr(u),L=r-T;({object:m,type:a}=await this.readSlice({start:L}))}if(a==="ref_delta"){const T=u.slice(20).toString("hex");({object:m,type:a}=await this.read({oid:T}))}const B=s.slice(u.tell());if(b=Buffer.from(await hr(B)),b.byteLength!==y)throw new _(`Packfile told us object would have length ${y} but it had length ${b.byteLength}`);return m&&(b=Buffer.from(ar(b,m))),this.readDepth>3&&(this.offsetCache[r]={type:a,object:b}),{type:a,format:"content",object:b}}}class et extends J{constructor(r){super(`Expected a 40-char hex object id but saw "${r}".`),this.code=this.name=et.code,this.data={value:r}}}et.code="InvalidOidError";class ut extends J{constructor(r,o,s,u){super(`Object ${r} ${u?`at ${u}`:""}was anticipated to be a ${s} but it is a ${o}.`),this.code=this.name=ut.code,this.data={oid:r,actual:o,expected:s,filepath:u}}}ut.code="ObjectTypeError";async function re(n,r){const o=Yt(n);for(;;){const{value:s,done:u}=await o.next();if(s&&await r(s),u)break}o.return&&o.return()}async function rt(n){let r=0;const o=[];await re(n,f=>{o.push(f),r+=f.byteLength});const s=new Uint8Array(r);let u=0;for(const f of o)s.set(f,u),u+=f.byteLength;return s}class yt{constructor(){this._queue=[]}write(r){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){const o=this._waiting;this._waiting=null,o({value:r})}else this._queue.push(r)}end(){if(this._ended=!0,this._waiting){const r=this._waiting;this._waiting=null,r({done:!0})}}destroy(r){this.error=r,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(r=>{this._waiting=r})}}class Lr{static demux(r){const o=k.streamReader(r),s=new yt,u=new yt,f=new yt,h=async function(){const a=await o();if(a===null)return h();if(a===!0){s.end(),f.end(),r.error?u.destroy(r.error):u.end();return}switch(a[0]){case 1:{u.write(a.slice(1));break}case 2:{f.write(a.slice(1));break}case 3:{const w=a.slice(1);f.write(w),s.end(),f.end(),u.destroy(new Error(w.toString("utf8")));return}default:s.write(a)}h()};return h(),{packetlines:s,packfile:u,progress:f}}}async function ne(n){const{packetlines:r,packfile:o,progress:s}=Lr.demux(n),u=[],f=[],h=[];let a=!1,w=!1;return new Promise((y,g)=>{re(r,m=>{const b=m.toString("utf8").trim();if(b.startsWith("shallow")){const B=b.slice(-41).trim();B.length!==40&&g(new et(B)),u.push(B)}else if(b.startsWith("unshallow")){const B=b.slice(-41).trim();B.length!==40&&g(new et(B)),f.push(B)}else if(b.startsWith("ACK")){const[,B,T]=b.split(" ");h.push({oid:B,status:T}),T||(w=!0)}else b.startsWith("NAK")?(a=!0,w=!0):(w=!0,a=!0);w&&(n.error?g(n.error):y({shallows:u,unshallows:f,acks:h,nak:a,packfile:o,progress:s}))}).finally(()=>{w||(n.error?g(n.error):y({shallows:u,unshallows:f,acks:h,nak:a,packfile:o,progress:s}))})})}typeof window<"u"&&(window.Buffer=H.Buffer);async function Mr(n,r,o){const s=await se(n,r),u=await qr(s,r,o),f=await zr(n,o.map(a=>u[a].oid)),h={};return await Promise.all(o.map(async a=>{h[a]=await ae(f,u[a].oid)})),h}async function vr(n,r){const o=await se(n,r),s=await Hr(o,r);return s!=null&&s.object?ie(s):[]}async function Gr(n,r){switch((r.type==="infer"||r.type===void 0)&&(["","HEAD"].includes(r.value)?r={value:r.value,type:"refname"}:typeof r.value=="string"&&r.value.length===40&&(r={value:r.value,type:"commit"})),r.type==="branch"&&(r={value:`refs/heads/${r.value}`,type:"refname"}),r.type){case"commit":return r.value;case"refname":{const o=await oe(n,r.value);if(!(r.value in o))throw new Error(`Branch ${r.value} not found`);return o[r.value]}default:throw new Error(`Invalid ref type: ${r.type}`)}}function ie(n){return n.object.map(r=>{if(r.type==="blob")return{name:r.path,type:"file"};if(r.type==="tree"&&r.object)return{name:r.path,type:"folder",children:ie(r)}}).filter(r=>!!(r!=null&&r.name))}async function oe(n,r){const o=H.Buffer.from(await rt([k.encode(`command=ls-refs
50
- `),k.encode(`agent=git/2.37.3
51
- `),k.encode(`object-format=sha1
52
- `),k.delim(),k.encode(`peel
53
- `),k.encode(`ref-prefix ${r}
54
- `),k.flush()])),s=await fetch(n+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${o.length}`,"Git-Protocol":"version=2"},body:o}),u={};for await(const f of Wr(s)){const h=f.indexOf(" "),a=f.slice(0,h),w=f.slice(h+1,f.length-1);u[w]=a}return u}async function se(n,r){const o=H.Buffer.from(await rt([k.encode(`want ${r} multi_ack_detailed no-done side-band-64k thin-pack ofs-delta agent=git/2.37.3 filter
55
- `),k.encode(`filter blob:none
56
- `),k.encode(`shallow ${r}
57
- `),k.encode(`deepen 1
58
- `),k.flush(),k.encode(`done
59
- `),k.encode(`done
60
- `)])),s=await fetch(n+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${o.length}`},body:o}),u=ce(s.body),f=await ne(u),h=H.Buffer.from(await rt(f.packfile)),a=await tt.fromPack({pack:h}),w=a.read;return a.read=async function({oid:y,...g}){const m=await w.call(this,{oid:y,...g});return m.oid=y,m},a}async function Hr(n,r){const o=await n.read({oid:r});W(o);const s=await n.read({oid:o.object.tree}),u=[s];for(;u.length>0;){const f=u.pop(),h=await n.read({oid:f.oid});if(W(h),f.object=h.object,h.type==="tree")for(const a of h.object)a.type==="tree"&&u.push(a)}return s}async function qr(n,r,o){const s=await n.read({oid:r});W(s);const u=await n.read({oid:s.object.tree});W(u);const f={};for(const h of o){let a=u;const w=h.split("/");for(const y of w){if(a.type!=="tree")throw new Error(`Path not found in the repo: ${h}`);let g=!1;for(const m of a.object)if(m.path===y){try{a=await n.read({oid:m.oid}),W(a)}catch{a=m}g=!0;break}if(!g)throw new Error(`Path not found in the repo: ${h}`)}f[h]=a}return f}async function zr(n,r){const o=H.Buffer.from(await rt([...r.map(a=>k.encode(`want ${a} multi_ack_detailed no-done side-band-64k thin-pack ofs-delta agent=git/2.37.3
61
- `)),k.flush(),k.encode(`done
62
- `)])),s=await fetch(n+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${o.length}`},body:o}),u=ce(s.body),f=await ne(u),h=H.Buffer.from(await rt(f.packfile));return await tt.fromPack({pack:h})}async function ae(n,r){const o=await n.read({oid:r});if(W(o),o.type==="blob")return o.object;const s={};for(const{path:u,oid:f,type:h}of o.object)if(h==="blob"){const a=await n.read({oid:f});W(a),s[u]=a.object}else h==="tree"&&(s[u]=await ae(n,f));return s}function W(n){if(n.object instanceof H.Buffer)switch(n.type){case"commit":n.object=P.from(n.object).parse();break;case"tree":n.object=Bt.from(n.object).entries();break;case"blob":n.object=new Uint8Array(n.object),n.format="content";break;case"tag":n.object=Z.from(n.object).parse();break;default:throw new ut(n.oid,n.type,"blob|commit|tag|tree")}}async function*Wr(n){const r=await n.text();let o=0;for(;o<=r.length;){const s=parseInt(r.substring(o,o+4),16);if(s===0)break;yield r.substring(o+4,o+s),o+=s}}function ce(n){if(n[Symbol.asyncIterator])return n;const r=n.getReader();return{next(){return r.read()},return(){return r.releaseLock(),{}},[Symbol.asyncIterator](){return this}}}function Yr(n,r){r=Q.normalizePath(r);const o=["",".","/"].includes(r);let s=n;if(o)r="";else{const h=r.split("/");for(const a of h){const w=s==null?void 0:s.find(y=>y.name===a);if((w==null?void 0:w.type)==="folder")s=w.children;else return w?[w.name]:[]}}const u=[],f=[{tree:s,path:r}];for(;f.length>0;){const{tree:h,path:a}=f.pop();for(const w of h){const y=`${a}${a?"/":""}${w.name}`;w.type==="folder"?f.push({tree:w.children,path:y}):u.push(y)}}return u}function Vr(n,r){return n.startsWith(r)?n.substring(r.length):n}exports.changeset=Ge;exports.clearContentsFromMountDevice=ze;exports.createClient=ke;exports.createCommit=je;exports.createOrUpdateBranch=De;exports.createTree=Le;exports.createTreeNode=gt;exports.createTreeNodes=Gt;exports.deleteFile=qt;exports.directoryHandleFromMountDevice=zt;exports.directoryHandleToOpfsPath=qe;exports.filesListToObject=Te;exports.fork=Ne;exports.getArtifact=Pe;exports.getFilesFromDirectory=vt;exports.iterateFiles=ve;exports.listDescendantFiles=Yr;exports.listGitFiles=vr;exports.listGitRefs=oe;exports.mayPush=Re;exports.opfsPathToDirectoryHandle=Wt;exports.removePathPrefix=Vr;exports.resolveCommitHash=Gr;exports.sparseCheckout=Mr;
49
+ */(function(i){var t=at,n=Et,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=a,i.SlowBuffer=N,i.INSPECT_MAX_BYTES=50;var c=2147483647;i.kMaxLength=c,a.TYPED_ARRAY_SUPPORT=f(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function f(){try{var o=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(o,e),o.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function h(o){if(o>c)throw new RangeError('The value "'+o+'" is invalid for option "size"');var e=new Uint8Array(o);return Object.setPrototypeOf(e,a.prototype),e}function a(o,e,r){if(typeof o=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(o)}return d(o,e,r)}a.poolSize=8192;function d(o,e,r){if(typeof o=="string")return b(o,e);if(ArrayBuffer.isView(o))return U(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(P(o,ArrayBuffer)||o&&P(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(P(o,SharedArrayBuffer)||o&&P(o.buffer,SharedArrayBuffer)))return L(o,e,r);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var u=o.valueOf&&o.valueOf();if(u!=null&&u!==o)return a.from(u,e,r);var l=D(o);if(l)return l;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return a.from(o[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o)}a.from=function(o,e,r){return d(o,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function y(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}function m(o,e,r){return y(o),o<=0?h(o):e!==void 0?typeof r=="string"?h(o).fill(e,r):h(o).fill(e):h(o)}a.alloc=function(o,e,r){return m(o,e,r)};function g(o){return y(o),h(o<0?0:I(o)|0)}a.allocUnsafe=function(o){return g(o)},a.allocUnsafeSlow=function(o){return g(o)};function b(o,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=T(o,e)|0,u=h(r),l=u.write(o,e);return l!==r&&(u=u.slice(0,l)),u}function x(o){for(var e=o.length<0?0:I(o.length)|0,r=h(e),u=0;u<e;u+=1)r[u]=o[u]&255;return r}function U(o){if(P(o,Uint8Array)){var e=new Uint8Array(o);return L(e.buffer,e.byteOffset,e.byteLength)}return x(o)}function L(o,e,r){if(e<0||o.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(o.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var u;return e===void 0&&r===void 0?u=new Uint8Array(o):r===void 0?u=new Uint8Array(o,e):u=new Uint8Array(o,e,r),Object.setPrototypeOf(u,a.prototype),u}function D(o){if(a.isBuffer(o)){var e=I(o.length)|0,r=h(e);return r.length===0||o.copy(r,0,0,e),r}if(o.length!==void 0)return typeof o.length!="number"||ht(o.length)?h(0):x(o);if(o.type==="Buffer"&&Array.isArray(o.data))return x(o.data)}function I(o){if(o>=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return o|0}function N(o){return+o!=o&&(o=0),a.alloc(+o)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype},a.compare=function(e,r){if(P(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),P(r,Uint8Array)&&(r=a.from(r,r.offset,r.byteLength)),!a.isBuffer(e)||!a.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;for(var u=e.length,l=r.length,p=0,w=Math.min(u,l);p<w;++p)if(e[p]!==r[p]){u=e[p],l=r[p];break}return u<l?-1:l<u?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);var u;if(r===void 0)for(r=0,u=0;u<e.length;++u)r+=e[u].length;var l=a.allocUnsafe(r),p=0;for(u=0;u<e.length;++u){var w=e[u];if(P(w,Uint8Array))p+w.length>l.length?a.from(w).copy(l,p):Uint8Array.prototype.set.call(l,w,p);else if(a.isBuffer(w))w.copy(l,p);else throw new TypeError('"list" argument must be an Array of Buffers');p+=w.length}return l};function T(o,e){if(a.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||P(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);var r=o.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&r===0)return 0;for(var l=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return ft(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ut(o).length;default:if(l)return u?-1:ft(o).length;e=(""+e).toLowerCase(),l=!0}}a.byteLength=T;function j(o,e,r){var u=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(o||(o="utf8");;)switch(o){case"hex":return me(this,e,r);case"utf8":case"utf-8":return Ft(this,e,r);case"ascii":return we(this,e,r);case"latin1":case"binary":return ye(this,e,r);case"base64":return pe(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ge(this,e,r);default:if(u)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),u=!0}}a.prototype._isBuffer=!0;function $(o,e,r){var u=o[e];o[e]=o[r],o[r]=u}a.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<e;r+=2)$(this,r,r+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<e;r+=4)$(this,r,r+3),$(this,r+1,r+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<e;r+=8)$(this,r,r+7),$(this,r+1,r+6),$(this,r+2,r+5),$(this,r+3,r+4);return this},a.prototype.toString=function(){var e=this.length;return e===0?"":arguments.length===0?Ft(this,0,e):j.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0},a.prototype.inspect=function(){var e="",r=i.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(e,r,u,l,p){if(P(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),u===void 0&&(u=e?e.length:0),l===void 0&&(l=0),p===void 0&&(p=this.length),r<0||u>e.length||l<0||p>this.length)throw new RangeError("out of range index");if(l>=p&&r>=u)return 0;if(l>=p)return-1;if(r>=u)return 1;if(r>>>=0,u>>>=0,l>>>=0,p>>>=0,this===e)return 0;for(var w=p-l,E=u-r,B=Math.min(w,E),v=this.slice(l,p),k=e.slice(r,u),_=0;_<B;++_)if(v[_]!==k[_]){w=v[_],E=k[_];break}return w<E?-1:E<w?1:0};function Bt(o,e,r,u,l){if(o.length===0)return-1;if(typeof r=="string"?(u=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,ht(r)&&(r=l?0:o.length-1),r<0&&(r=o.length+r),r>=o.length){if(l)return-1;r=o.length-1}else if(r<0)if(l)r=0;else return-1;if(typeof e=="string"&&(e=a.from(e,u)),a.isBuffer(e))return e.length===0?-1:vt(o,e,r,u,l);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?l?Uint8Array.prototype.indexOf.call(o,e,r):Uint8Array.prototype.lastIndexOf.call(o,e,r):vt(o,[e],r,u,l);throw new TypeError("val must be string, number or Buffer")}function vt(o,e,r,u,l){var p=1,w=o.length,E=e.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(o.length<2||e.length<2)return-1;p=2,w/=2,E/=2,r/=2}function B(kt,Tt){return p===1?kt[Tt]:kt.readUInt16BE(Tt*p)}var v;if(l){var k=-1;for(v=r;v<w;v++)if(B(o,v)===B(e,k===-1?0:v-k)){if(k===-1&&(k=v),v-k+1===E)return k*p}else k!==-1&&(v-=v-k),k=-1}else for(r+E>w&&(r=w-E),v=r;v>=0;v--){for(var _=!0,nt=0;nt<E;nt++)if(B(o,v+nt)!==B(e,nt)){_=!1;break}if(_)return v}return-1}a.prototype.includes=function(e,r,u){return this.indexOf(e,r,u)!==-1},a.prototype.indexOf=function(e,r,u){return Bt(this,e,r,u,!0)},a.prototype.lastIndexOf=function(e,r,u){return Bt(this,e,r,u,!1)};function ce(o,e,r,u){r=Number(r)||0;var l=o.length-r;u?(u=Number(u),u>l&&(u=l)):u=l;var p=e.length;u>p/2&&(u=p/2);for(var w=0;w<u;++w){var E=parseInt(e.substr(w*2,2),16);if(ht(E))return w;o[r+w]=E}return w}function ue(o,e,r,u){return rt(ft(e,o.length-r),o,r,u)}function fe(o,e,r,u){return rt(Ee(e),o,r,u)}function he(o,e,r,u){return rt(Ut(e),o,r,u)}function le(o,e,r,u){return rt(Be(e,o.length-r),o,r,u)}a.prototype.write=function(e,r,u,l){if(r===void 0)l="utf8",u=this.length,r=0;else if(u===void 0&&typeof r=="string")l=r,u=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(u)?(u=u>>>0,l===void 0&&(l="utf8")):(l=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var p=this.length-r;if((u===void 0||u>p)&&(u=p),e.length>0&&(u<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");l||(l="utf8");for(var w=!1;;)switch(l){case"hex":return ce(this,e,r,u);case"utf8":case"utf-8":return ue(this,e,r,u);case"ascii":case"latin1":case"binary":return fe(this,e,r,u);case"base64":return he(this,e,r,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le(this,e,r,u);default:if(w)throw new TypeError("Unknown encoding: "+l);l=(""+l).toLowerCase(),w=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function pe(o,e,r){return e===0&&r===o.length?t.fromByteArray(o):t.fromByteArray(o.slice(e,r))}function Ft(o,e,r){r=Math.min(o.length,r);for(var u=[],l=e;l<r;){var p=o[l],w=null,E=p>239?4:p>223?3:p>191?2:1;if(l+E<=r){var B,v,k,_;switch(E){case 1:p<128&&(w=p);break;case 2:B=o[l+1],(B&192)===128&&(_=(p&31)<<6|B&63,_>127&&(w=_));break;case 3:B=o[l+1],v=o[l+2],(B&192)===128&&(v&192)===128&&(_=(p&15)<<12|(B&63)<<6|v&63,_>2047&&(_<55296||_>57343)&&(w=_));break;case 4:B=o[l+1],v=o[l+2],k=o[l+3],(B&192)===128&&(v&192)===128&&(k&192)===128&&(_=(p&15)<<18|(B&63)<<12|(v&63)<<6|k&63,_>65535&&_<1114112&&(w=_))}}w===null?(w=65533,E=1):w>65535&&(w-=65536,u.push(w>>>10&1023|55296),w=56320|w&1023),u.push(w),l+=E}return de(u)}var _t=4096;function de(o){var e=o.length;if(e<=_t)return String.fromCharCode.apply(String,o);for(var r="",u=0;u<e;)r+=String.fromCharCode.apply(String,o.slice(u,u+=_t));return r}function we(o,e,r){var u="";r=Math.min(o.length,r);for(var l=e;l<r;++l)u+=String.fromCharCode(o[l]&127);return u}function ye(o,e,r){var u="";r=Math.min(o.length,r);for(var l=e;l<r;++l)u+=String.fromCharCode(o[l]);return u}function me(o,e,r){var u=o.length;(!e||e<0)&&(e=0),(!r||r<0||r>u)&&(r=u);for(var l="",p=e;p<r;++p)l+=ve[o[p]];return l}function ge(o,e,r){for(var u=o.slice(e,r),l="",p=0;p<u.length-1;p+=2)l+=String.fromCharCode(u[p]+u[p+1]*256);return l}a.prototype.slice=function(e,r){var u=this.length;e=~~e,r=r===void 0?u:~~r,e<0?(e+=u,e<0&&(e=0)):e>u&&(e=u),r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),r<e&&(r=e);var l=this.subarray(e,r);return Object.setPrototypeOf(l,a.prototype),l};function S(o,e,r){if(o%1!==0||o<0)throw new RangeError("offset is not uint");if(o+e>r)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,r,u){e=e>>>0,r=r>>>0,u||S(e,r,this.length);for(var l=this[e],p=1,w=0;++w<r&&(p*=256);)l+=this[e+w]*p;return l},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,r,u){e=e>>>0,r=r>>>0,u||S(e,r,this.length);for(var l=this[e+--r],p=1;r>0&&(p*=256);)l+=this[e+--r]*p;return l},a.prototype.readUint8=a.prototype.readUInt8=function(e,r){return e=e>>>0,r||S(e,1,this.length),this[e]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||S(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||S(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||S(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||S(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,r,u){e=e>>>0,r=r>>>0,u||S(e,r,this.length);for(var l=this[e],p=1,w=0;++w<r&&(p*=256);)l+=this[e+w]*p;return p*=128,l>=p&&(l-=Math.pow(2,8*r)),l},a.prototype.readIntBE=function(e,r,u){e=e>>>0,r=r>>>0,u||S(e,r,this.length);for(var l=r,p=1,w=this[e+--l];l>0&&(p*=256);)w+=this[e+--l]*p;return p*=128,w>=p&&(w-=Math.pow(2,8*r)),w},a.prototype.readInt8=function(e,r){return e=e>>>0,r||S(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},a.prototype.readInt16LE=function(e,r){e=e>>>0,r||S(e,2,this.length);var u=this[e]|this[e+1]<<8;return u&32768?u|4294901760:u},a.prototype.readInt16BE=function(e,r){e=e>>>0,r||S(e,2,this.length);var u=this[e+1]|this[e]<<8;return u&32768?u|4294901760:u},a.prototype.readInt32LE=function(e,r){return e=e>>>0,r||S(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,r){return e=e>>>0,r||S(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,r){return e=e>>>0,r||S(e,4,this.length),n.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,r){return e=e>>>0,r||S(e,4,this.length),n.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||S(e,8,this.length),n.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||S(e,8,this.length),n.read(this,e,!1,52,8)};function C(o,e,r,u,l,p){if(!a.isBuffer(o))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>l||e<p)throw new RangeError('"value" argument is out of bounds');if(r+u>o.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,r,u,l){if(e=+e,r=r>>>0,u=u>>>0,!l){var p=Math.pow(2,8*u)-1;C(this,e,r,u,p,0)}var w=1,E=0;for(this[r]=e&255;++E<u&&(w*=256);)this[r+E]=e/w&255;return r+u},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,r,u,l){if(e=+e,r=r>>>0,u=u>>>0,!l){var p=Math.pow(2,8*u)-1;C(this,e,r,u,p,0)}var w=u-1,E=1;for(this[r+w]=e&255;--w>=0&&(E*=256);)this[r+w]=e/E&255;return r+u},a.prototype.writeUint8=a.prototype.writeUInt8=function(e,r,u){return e=+e,r=r>>>0,u||C(this,e,r,1,255,0),this[r]=e&255,r+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,r,u){return e=+e,r=r>>>0,u||C(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,r,u){return e=+e,r=r>>>0,u||C(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,r,u){return e=+e,r=r>>>0,u||C(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,r,u){return e=+e,r=r>>>0,u||C(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4},a.prototype.writeIntLE=function(e,r,u,l){if(e=+e,r=r>>>0,!l){var p=Math.pow(2,8*u-1);C(this,e,r,u,p-1,-p)}var w=0,E=1,B=0;for(this[r]=e&255;++w<u&&(E*=256);)e<0&&B===0&&this[r+w-1]!==0&&(B=1),this[r+w]=(e/E>>0)-B&255;return r+u},a.prototype.writeIntBE=function(e,r,u,l){if(e=+e,r=r>>>0,!l){var p=Math.pow(2,8*u-1);C(this,e,r,u,p-1,-p)}var w=u-1,E=1,B=0;for(this[r+w]=e&255;--w>=0&&(E*=256);)e<0&&B===0&&this[r+w+1]!==0&&(B=1),this[r+w]=(e/E>>0)-B&255;return r+u},a.prototype.writeInt8=function(e,r,u){return e=+e,r=r>>>0,u||C(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1},a.prototype.writeInt16LE=function(e,r,u){return e=+e,r=r>>>0,u||C(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2},a.prototype.writeInt16BE=function(e,r,u){return e=+e,r=r>>>0,u||C(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2},a.prototype.writeInt32LE=function(e,r,u){return e=+e,r=r>>>0,u||C(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4},a.prototype.writeInt32BE=function(e,r,u){return e=+e,r=r>>>0,u||C(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function It(o,e,r,u,l,p){if(r+u>o.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function St(o,e,r,u,l){return e=+e,r=r>>>0,l||It(o,e,r,4),n.write(o,e,r,u,23,4),r+4}a.prototype.writeFloatLE=function(e,r,u){return St(this,e,r,!0,u)},a.prototype.writeFloatBE=function(e,r,u){return St(this,e,r,!1,u)};function At(o,e,r,u,l){return e=+e,r=r>>>0,l||It(o,e,r,8),n.write(o,e,r,u,52,8),r+8}a.prototype.writeDoubleLE=function(e,r,u){return At(this,e,r,!0,u)},a.prototype.writeDoubleBE=function(e,r,u){return At(this,e,r,!1,u)},a.prototype.copy=function(e,r,u,l){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(u||(u=0),!l&&l!==0&&(l=this.length),r>=e.length&&(r=e.length),r||(r=0),l>0&&l<u&&(l=u),l===u||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("sourceEnd out of bounds");l>this.length&&(l=this.length),e.length-r<l-u&&(l=e.length-r+u);var p=l-u;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,u,l):Uint8Array.prototype.set.call(e,this.subarray(u,l),r),p},a.prototype.fill=function(e,r,u,l){if(typeof e=="string"){if(typeof r=="string"?(l=r,r=0,u=this.length):typeof u=="string"&&(l=u,u=this.length),l!==void 0&&typeof l!="string")throw new TypeError("encoding must be a string");if(typeof l=="string"&&!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(e.length===1){var p=e.charCodeAt(0);(l==="utf8"&&p<128||l==="latin1")&&(e=p)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<u)throw new RangeError("Out of range index");if(u<=r)return this;r=r>>>0,u=u===void 0?this.length:u>>>0,e||(e=0);var w;if(typeof e=="number")for(w=r;w<u;++w)this[w]=e;else{var E=a.isBuffer(e)?e:a.from(e,l),B=E.length;if(B===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(w=0;w<u-r;++w)this[w+r]=E[w%B]}return this};var be=/[^+/0-9A-Za-z-_]/g;function xe(o){if(o=o.split("=")[0],o=o.trim().replace(be,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}function ft(o,e){e=e||1/0;for(var r,u=o.length,l=null,p=[],w=0;w<u;++w){if(r=o.charCodeAt(w),r>55295&&r<57344){if(!l){if(r>56319){(e-=3)>-1&&p.push(239,191,189);continue}else if(w+1===u){(e-=3)>-1&&p.push(239,191,189);continue}l=r;continue}if(r<56320){(e-=3)>-1&&p.push(239,191,189),l=r;continue}r=(l-55296<<10|r-56320)+65536}else l&&(e-=3)>-1&&p.push(239,191,189);if(l=null,r<128){if((e-=1)<0)break;p.push(r)}else if(r<2048){if((e-=2)<0)break;p.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;p.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;p.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return p}function Ee(o){for(var e=[],r=0;r<o.length;++r)e.push(o.charCodeAt(r)&255);return e}function Be(o,e){for(var r,u,l,p=[],w=0;w<o.length&&!((e-=2)<0);++w)r=o.charCodeAt(w),u=r>>8,l=r%256,p.push(l),p.push(u);return p}function Ut(o){return t.toByteArray(xe(o))}function rt(o,e,r,u){for(var l=0;l<u&&!(l+r>=e.length||l>=o.length);++l)e[l+r]=o[l];return l}function P(o,e){return o instanceof e||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===e.name}function ht(o){return o!==o}var ve=function(){for(var o="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var u=r*16,l=0;l<16;++l)e[u+l]=o[r]+o[l];return e}()})(H);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(i,t){var n=H,s=n.Buffer;function c(h,a){for(var d in h)a[d]=h[d]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?i.exports=n:(c(n,t),t.Buffer=f);function f(h,a,d){return s(h,a,d)}f.prototype=Object.create(s.prototype),c(s,f),f.from=function(h,a,d){if(typeof h=="number")throw new TypeError("Argument must not be a number");return s(h,a,d)},f.alloc=function(h,a,d){if(typeof h!="number")throw new TypeError("Argument must be a number");var y=s(h);return a!==void 0?typeof d=="string"?y.fill(a,d):y.fill(a):y.fill(0),y},f.allocUnsafe=function(h){if(typeof h!="number")throw new TypeError("Argument must be a number");return s(h)},f.allocUnsafeSlow=function(h){if(typeof h!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(h)}})(bt,bt.exports);var Zt=bt.exports,Xt=Zt.Buffer;function ct(i,t){this._block=Xt.alloc(i),this._finalSize=t,this._blockSize=i,this._len=0}ct.prototype.update=function(i,t){typeof i=="string"&&(t=t||"utf8",i=Xt.from(i,t));for(var n=this._block,s=this._blockSize,c=i.length,f=this._len,h=0;h<c;){for(var a=f%s,d=Math.min(c-h,s-a),y=0;y<d;y++)n[a+y]=i[h+y];f+=d,h+=d,f%s===0&&this._update(n)}return this._len+=c,this};ct.prototype.digest=function(i){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var n=this._len*8;if(n<=4294967295)this._block.writeUInt32BE(n,this._blockSize-4);else{var s=(n&4294967295)>>>0,c=(n-s)/4294967296;this._block.writeUInt32BE(c,this._blockSize-8),this._block.writeUInt32BE(s,this._blockSize-4)}this._update(this._block);var f=this._hash();return i?f.toString(i):f};ct.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Fr=ct,_r=wr,Qt=Fr,Ir=Zt.Buffer,Sr=[1518500249,1859775393,-1894007588,-899497514],Ar=new Array(80);function et(){this.init(),this._w=Ar,Qt.call(this,64,56)}_r(et,Qt);et.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Ur(i){return i<<1|i>>>31}function kr(i){return i<<5|i>>>27}function Tr(i){return i<<30|i>>>2}function $r(i,t,n,s){return i===0?t&n|~t&s:i===2?t&n|t&s|n&s:t^n^s}et.prototype._update=function(i){for(var t=this._w,n=this._a|0,s=this._b|0,c=this._c|0,f=this._d|0,h=this._e|0,a=0;a<16;++a)t[a]=i.readInt32BE(a*4);for(;a<80;++a)t[a]=Ur(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var d=0;d<80;++d){var y=~~(d/20),m=kr(n)+$r(y,s,c,f)+h+t[d]+Sr[y]|0;h=f,f=c,c=Tr(s),s=n,n=m}this._a=n+this._a|0,this._b=s+this._b|0,this._c=c+this._c|0,this._d=f+this._d|0,this._e=h+this._e|0};et.prototype._hash=function(){var i=Ir.allocUnsafe(20);return i.writeInt32BE(this._a|0,0),i.writeInt32BE(this._b|0,4),i.writeInt32BE(this._c|0,8),i.writeInt32BE(this._d|0,12),i.writeInt32BE(this._e|0,16),i};var Cr=et;const Rr=dr(Cr);function Or(i){let t="";for(const n of new Uint8Array(i))n<16&&(t+="0"),t+=n.toString(16);return t}let dt=null;async function Mt(i){return dt===null&&(dt=await Pr()),dt?te(i):Dr(i)}function Dr(i){return new Rr().update(i).digest("hex")}async function te(i){const t=await crypto.subtle.digest("SHA-1",i);return Or(t)}async function Pr(){try{if(await te(new Uint8Array([]))==="da39a3ee5e6b4b0d3255bfef95601890afd80709")return!0}catch{}return!1}function Mr(i){const t=[];let n=0,s=0;do{n=i.readUInt8();const c=n&127;t.push(c),s=n&128}while(s);return t.reduce((c,f)=>c+1<<7|f,-1)}function Lr(i,t){let n=t,s=4,c=null;do c=i.readUInt8(),n|=(c&127)<<s,s+=7;while(c&128);return n}class X{constructor(t){Object.assign(this,t),this.offsetCache={}}static async fromIdx({idx:t,getExternalRefDelta:n}){const s=new q(t);if(s.slice(4).toString("hex")!=="ff744f63")return;const f=s.readUInt32BE();if(f!==2)throw new F(`Unable to read version ${f} packfile IDX. (Only version 2 supported)`);if(t.byteLength>2048*1024*1024)throw new F("To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.");s.seek(s.tell()+4*255);const h=s.readUInt32BE(),a=[];for(let m=0;m<h;m++){const g=s.slice(20).toString("hex");a[m]=g}s.seek(s.tell()+4*h);const d=new Map;for(let m=0;m<h;m++)d.set(a[m],s.readUInt32BE());const y=s.slice(20).toString("hex");return new X({hashes:a,crcs:{},offsets:d,packfileSha:y,getExternalRefDelta:n})}static async fromPack({pack:t,getExternalRefDelta:n,onProgress:s}){const c={1:"commit",2:"tree",3:"blob",4:"tag",6:"ofs-delta",7:"ref-delta"},f={},h=t.slice(-20).toString("hex"),a=[],d={},y=new Map;let m=null,g=null;await hr([t],async({data:D,type:I,reference:N,offset:T,num:j})=>{m===null&&(m=j);const $=Math.floor((m-j)*100/m);$!==g&&s&&await s({phase:"Receiving objects",loaded:m-j,total:m}),g=$,I=c[I],["commit","tree","blob","tag"].includes(I)?f[T]={type:I,offset:T}:I==="ofs-delta"?f[T]={type:I,offset:T}:I==="ref-delta"&&(f[T]={type:I,offset:T})});const b=Object.keys(f).map(Number);for(const[D,I]of b.entries()){const N=D+1===b.length?t.byteLength-20:b[D+1],T=f[I],j=Te.buf(t.slice(I,N))>>>0;T.end=N,T.crc=j}const x=new X({pack:Promise.resolve(t),packfileSha:h,crcs:d,hashes:a,offsets:y,getExternalRefDelta:n});g=null;let U=0;const L=[0,0,0,0,0,0,0,0,0,0,0,0];for(let D in f){D=Number(D);const I=Math.floor(U*100/m);I!==g&&s&&await s({phase:"Resolving deltas",loaded:U,total:m}),U++,g=I;const N=f[D];if(!N.oid)try{x.readDepth=0,x.externalReadDepth=0;const{type:T,object:j}=await x.readSlice({start:D});L[x.readDepth]+=1;const $=await Mt(ur.wrap({type:T,object:j}));N.oid=$,a.push($),y.set($,D),d[$]=N.crc}catch{continue}}return a.sort(),x}async toBuffer(){const t=[],n=(y,m)=>{t.push(Buffer.from(y,m))};n("ff744f63","hex"),n("00000002","hex");const s=new q(Buffer.alloc(256*4));for(let y=0;y<256;y++){let m=0;for(const g of this.hashes)parseInt(g.slice(0,2),16)<=y&&m++;s.writeUInt32BE(m)}t.push(s.buffer);for(const y of this.hashes)n(y,"hex");const c=new q(Buffer.alloc(this.hashes.length*4));for(const y of this.hashes)c.writeUInt32BE(this.crcs[y]);t.push(c.buffer);const f=new q(Buffer.alloc(this.hashes.length*4));for(const y of this.hashes)f.writeUInt32BE(this.offsets.get(y));t.push(f.buffer),n(this.packfileSha,"hex");const h=Buffer.concat(t),a=await Mt(h),d=Buffer.alloc(20);return d.write(a,"hex"),Buffer.concat([h,d])}async load({pack:t}){this.pack=t}async unload(){this.pack=null}async read({oid:t}){if(!this.offsets.get(t)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(t);throw new F(`Could not read object ${t} from packfile`)}const n=this.offsets.get(t);return this.readSlice({start:n})}async readSlice({start:t}){if(this.offsetCache[t])return Object.assign({},this.offsetCache[t]);this.readDepth++;const n={16:"commit",32:"tree",48:"blob",64:"tag",96:"ofs_delta",112:"ref_delta"};if(!this.pack)throw new F("Tried to read from a GitPackIndex with no packfile loaded into memory");const s=(await this.pack).slice(t),c=new q(s),f=c.readUInt8(),h=f&112;let a=n[h];if(a===void 0)throw new F("Unrecognized type: 0b"+h.toString(2));const d=f&15;let y=d;f&128&&(y=Lr(c,d));let g=null,b=null;if(a==="ofs_delta"){const U=Mr(c),L=t-U;({object:g,type:a}=await this.readSlice({start:L}))}if(a==="ref_delta"){const U=c.slice(20).toString("hex");({object:g,type:a}=await this.read({oid:U}))}const x=s.slice(c.tell());if(b=Buffer.from(await pr(x)),b.byteLength!==y)throw new F(`Packfile told us object would have length ${y} but it had length ${b.byteLength}`);return g&&(b=Buffer.from(fr(b,g))),this.readDepth>3&&(this.offsetCache[t]={type:a,object:b}),{type:a,format:"content",object:b}}}class Q extends J{constructor(t){super(`Expected a 40-char hex object id but saw "${t}".`),this.code=this.name=Q.code,this.data={value:t}}}Q.code="InvalidOidError";class ut extends J{constructor(t,n,s,c){super(`Object ${t} ${c?`at ${c}`:""}was anticipated to be a ${s} but it is a ${n}.`),this.code=this.name=ut.code,this.data={oid:t,actual:n,expected:s,filepath:c}}}ut.code="ObjectTypeError";async function ee(i,t){const n=Wt(i);for(;;){const{value:s,done:c}=await n.next();if(s&&await t(s),c)break}n.return&&n.return()}async function tt(i){let t=0;const n=[];await ee(i,f=>{n.push(f),t+=f.byteLength});const s=new Uint8Array(t);let c=0;for(const f of n)s.set(f,c),c+=f.byteLength;return s}class wt{constructor(){this._queue=[]}write(t){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){const n=this._waiting;this._waiting=null,n({value:t})}else this._queue.push(t)}end(){if(this._ended=!0,this._waiting){const t=this._waiting;this._waiting=null,t({done:!0})}}destroy(t){this.error=t,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(t=>{this._waiting=t})}}class Nr{static demux(t){const n=A.streamReader(t),s=new wt,c=new wt,f=new wt,h=async function(){const a=await n();if(a===null)return h();if(a===!0){s.end(),f.end(),t.error?c.destroy(t.error):c.end();return}switch(a[0]){case 1:{c.write(a.slice(1));break}case 2:{f.write(a.slice(1));break}case 3:{const d=a.slice(1);f.write(d),s.end(),f.end(),c.destroy(new Error(d.toString("utf8")));return}default:s.write(a)}h()};return h(),{packetlines:s,packfile:c,progress:f}}}async function re(i){const{packetlines:t,packfile:n,progress:s}=Nr.demux(i),c=[],f=[],h=[];let a=!1,d=!1;return new Promise((y,m)=>{ee(t,g=>{const b=g.toString("utf8").trim();if(b.startsWith("shallow")){const x=b.slice(-41).trim();x.length!==40&&m(new Q(x)),c.push(x)}else if(b.startsWith("unshallow")){const x=b.slice(-41).trim();x.length!==40&&m(new Q(x)),f.push(x)}else if(b.startsWith("ACK")){const[,x,U]=b.split(" ");h.push({oid:x,status:U}),U||(d=!0)}else b.startsWith("NAK")?(a=!0,d=!0):(d=!0,a=!0);d&&(i.error?m(i.error):y({shallows:c,unshallows:f,acks:h,nak:a,packfile:n,progress:s}))}).finally(()=>{d||(i.error?m(i.error):y({shallows:c,unshallows:f,acks:h,nak:a,packfile:n,progress:s}))})})}typeof window<"u"&&(window.Buffer=H.Buffer);async function jr(i,t,n){const s=await se(i,t),c=await zr(s,t,n),f=await Wr(i,n.map(a=>c[a].oid)),h={};return await Promise.all(n.map(async a=>{h[a]=await oe(f,c[a].oid)})),h}async function Gr(i,t){const n=await se(i,t),s=await qr(n,t);return s!=null&&s.object?ne(s):[]}async function Hr(i,t){switch((t.type==="infer"||t.type===void 0)&&(["","HEAD"].includes(t.value)?t={value:t.value,type:"refname"}:typeof t.value=="string"&&t.value.length===40&&(t={value:t.value,type:"commit"})),t.type==="branch"&&(t={value:`refs/heads/${t.value}`,type:"refname"}),t.type){case"commit":return t.value;case"refname":{const n=await ie(i,t.value);if(!(t.value in n))throw new Error(`Branch ${t.value} not found`);return n[t.value]}default:throw new Error(`Invalid ref type: ${t.type}`)}}function ne(i){return i.object.map(t=>{if(t.type==="blob")return{name:t.path,type:"file"};if(t.type==="tree"&&t.object)return{name:t.path,type:"folder",children:ne(t)}}).filter(t=>!!(t!=null&&t.name))}async function ie(i,t){const n=H.Buffer.from(await tt([A.encode(`command=ls-refs
50
+ `),A.encode(`agent=git/2.37.3
51
+ `),A.encode(`object-format=sha1
52
+ `),A.delim(),A.encode(`peel
53
+ `),A.encode(`ref-prefix ${t}
54
+ `),A.flush()])),s=await fetch(i+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${n.length}`,"Git-Protocol":"version=2"},body:n}),c={};for await(const f of Yr(s)){const h=f.indexOf(" "),a=f.slice(0,h),d=f.slice(h+1,f.length-1);c[d]=a}return c}async function se(i,t){const n=H.Buffer.from(await tt([A.encode(`want ${t} multi_ack_detailed no-done side-band-64k thin-pack ofs-delta agent=git/2.37.3 filter
55
+ `),A.encode(`filter blob:none
56
+ `),A.encode(`shallow ${t}
57
+ `),A.encode(`deepen 1
58
+ `),A.flush(),A.encode(`done
59
+ `),A.encode(`done
60
+ `)])),s=await fetch(i+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${n.length}`},body:n}),c=ae(s.body),f=await re(c),h=H.Buffer.from(await tt(f.packfile)),a=await X.fromPack({pack:h}),d=a.read;return a.read=async function({oid:y,...m}){const g=await d.call(this,{oid:y,...m});return g.oid=y,g},a}async function qr(i,t){const n=await i.read({oid:t});z(n);const s=await i.read({oid:n.object.tree}),c=[s];for(;c.length>0;){const f=c.pop(),h=await i.read({oid:f.oid});if(z(h),f.object=h.object,h.type==="tree")for(const a of h.object)a.type==="tree"&&c.push(a)}return s}async function zr(i,t,n){const s=await i.read({oid:t});z(s);const c=await i.read({oid:s.object.tree});z(c);const f={};for(const h of n){let a=c;const d=h.split("/");for(const y of d){if(a.type!=="tree")throw new Error(`Path not found in the repo: ${h}`);let m=!1;for(const g of a.object)if(g.path===y){try{a=await i.read({oid:g.oid}),z(a)}catch{a=g}m=!0;break}if(!m)throw new Error(`Path not found in the repo: ${h}`)}f[h]=a}return f}async function Wr(i,t){const n=H.Buffer.from(await tt([...t.map(a=>A.encode(`want ${a} multi_ack_detailed no-done side-band-64k thin-pack ofs-delta agent=git/2.37.3
61
+ `)),A.flush(),A.encode(`done
62
+ `)])),s=await fetch(i+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${n.length}`},body:n}),c=ae(s.body),f=await re(c),h=H.Buffer.from(await tt(f.packfile));return await X.fromPack({pack:h})}async function oe(i,t){const n=await i.read({oid:t});if(z(n),n.type==="blob")return n.object;const s={};for(const{path:c,oid:f,type:h}of n.object)if(h==="blob"){const a=await i.read({oid:f});z(a),s[c]=a.object}else h==="tree"&&(s[c]=await oe(i,f));return s}function z(i){if(i.object instanceof H.Buffer)switch(i.type){case"commit":i.object=R.from(i.object).parse();break;case"tree":i.object=xt.from(i.object).entries();break;case"blob":i.object=new Uint8Array(i.object),i.format="content";break;case"tag":i.object=V.from(i.object).parse();break;default:throw new ut(i.oid,i.type,"blob|commit|tag|tree")}}async function*Yr(i){const t=await i.text();let n=0;for(;n<=t.length;){const s=parseInt(t.substring(n,n+4),16);if(s===0)break;yield t.substring(n+4,n+s),n+=s}}function ae(i){if(i[Symbol.asyncIterator])return i;const t=i.getReader();return{next(){return t.read()},return(){return t.releaseLock(),{}},[Symbol.asyncIterator](){return this}}}function Jr(i,t){t=Y.normalizePath(t);const n=["",".","/"].includes(t);let s=i;if(n)t="";else{const h=t.split("/");for(const a of h){const d=s==null?void 0:s.find(y=>y.name===a);if((d==null?void 0:d.type)==="folder")s=d.children;else return d?[d.name]:[]}}const c=[],f=[{tree:s,path:t}];for(;f.length>0;){const{tree:h,path:a}=f.pop();for(const d of h){const y=`${a}${a?"/":""}${d.name}`;d.type==="folder"?f.push({tree:d.children,path:y}):c.push(y)}}return c}function Kr(i,t){return i.startsWith(t)?i.substring(t.length):i}class Vr{constructor(t){this.fileTree=t}async read(t){let n=this.getEntryAtPath(t);if(typeof n=="string")n=new TextEncoder().encode(n);else if(!(n instanceof Uint8Array))throw new Error(`Unsupported content type: ${typeof n}`);const s=new ReadableStream({start(c){c.enqueue(n),c.close()}});return new Z.StreamedFile(s,t,{filesize:n.byteLength})}getEntryAtPath(t){let n=t.replace(/^\//,""),s=this.fileTree;for(;n;){if(s[n])return s[n];const c=n.split("/"),f=c.shift();if(!f||!s[f])break;s=s[f],n=c.join("/")}throw new Error(`File not found at ${t}`)}}class st{constructor(t){this.entries=new Map,this.zipReader=t}static fromStream(t){const n=new K.ZipReader(new K.BlobReader(new Z.StreamedFile(t,"archive.zip")));return new st(n)}static fromArrayBuffer(t){const n=new K.ZipReader(new K.BlobReader(new Blob([t])));return new st(n)}async read(t){const n=await this.getEntry(t),s=await n.getData(new K.BlobWriter);return new Z.StreamedFile(s.stream(),t,{filesize:n.uncompressedSize})}async getEntry(t){const s=(await this.getEntries()).get(t.replace(/^\//,""));if(!s)throw new Error(`File ${t} not found in the zip.`);return s}async getEntries(){if(this.entries.size===0){const t=await this.zipReader.getEntries();for(const n of t)this.entries.set(n.filename,n)}return this.entries}}class Zr{constructor(t){if(!t.length)throw new Error("OverlayFilesystem requires at least one filesystem");this.filesystems=t}async read(t){const n=[];for(const c of this.filesystems)try{return await c.read(t)}catch(f){n.push(f instanceof Error?f:new Error(String(f)))}const s=n.map(c=>c.message).join("; ");throw new Error(`Failed to read ${t} from any filesystem: ${s}`,{cause:n})}}class Xr{constructor(t){if(this.baseUrl="",this.options=t,this.isDataUrl=t.baseUrl.startsWith("data:"),this.isDataUrl)return;const n=new URL("./",t.baseUrl);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("Unsupported protocol: "+n.protocol+". Only HTTP and HTTPS are supported.");this.baseUrl=n.origin+n.pathname}async read(t){if(this.isDataUrl)throw new Error("FetchFilesystem cannot fetch files from data URLs");t=Y.normalizePath(t);const n=t.replace(/^\//,""),s=new URL(n,this.baseUrl).toString();if(!s.startsWith(this.baseUrl))throw new Error(`Refused to read a file outside of the base URL: ${s}`);const c=this.options.corsProxy?`${this.options.corsProxy}${encodeURIComponent(s)}`:s,f=await fetch(c);if(!f.ok)throw new Error(`Failed to fetch file at ${t}: ${f.statusText}`);const h=f.headers.get("content-length")?parseInt(f.headers.get("content-length"),10):void 0;return new Z.StreamedFile(f.body,t,{filesize:h})}}class Qr{constructor(t){this.root=t}async ensureNodeModules(){if(!this.fs||!this.path){try{this.fs=await import("fs"),this.path=await import("path")}catch{this.fs=require("fs"),this.path=require("path")}this.root=this.path.resolve(this.root)+this.path.sep}}async read(t){if(await this.ensureNodeModules(),t=this.path.resolve(this.root,this.path.normalize(t.replace(/^\//,""))),!t.startsWith(this.root))throw new Error(`Refused to read a file outside of the root directory: ${t}`);return new Promise((n,s)=>{const c=this.path.resolve(t),f=this.fs.createReadStream(c);f.on("error",h=>{s(new Error(`Failed to read file at ${t}: ${h.message}`))}),this.fs.stat(c,(h,a)=>{h?s(new Error(`Failed to read file at ${t}: ${h.message}`)):n(new Z.StreamedFile(tn(f),t,{filesize:a.size}))})})}}function tn(i){return new ReadableStream({start(n){i.on("data",s=>n.enqueue(s)),i.on("end",()=>n.close())}})}exports.FetchFilesystem=Xr;exports.InMemoryFilesystem=Vr;exports.NodeJsFilesystem=Qr;exports.OverlayFilesystem=Zr;exports.ZipFilesystem=st;exports.changeset=ze;exports.clearContentsFromMountDevice=Je;exports.createClient=$e;exports.createCommit=je;exports.createOrUpdateBranch=Le;exports.createTree=Ge;exports.createTreeNode=yt;exports.createTreeNodes=jt;exports.deleteFile=Ht;exports.directoryHandleFromMountDevice=qt;exports.directoryHandleToOpfsPath=Ye;exports.filesListToObject=Ce;exports.fork=Ne;exports.getArtifact=Pe;exports.getFilesFromDirectory=Nt;exports.iterateFiles=qe;exports.listDescendantFiles=Jr;exports.listGitFiles=Gr;exports.listGitRefs=ie;exports.mayPush=Me;exports.opfsPathToDirectoryHandle=zt;exports.removePathPrefix=Kr;exports.resolveCommitHash=Hr;exports.sparseCheckout=jr;
63
63
  //# sourceMappingURL=index.cjs.map