diff --git a/README.md b/README.md index 01d01e1..a908009 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,20 @@ jobs: token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} ``` +When you use GitHub's built-in `generate_release_notes` support, you can optionally +pin the comparison base explicitly with `previous_tag`. This is useful when the default +comparison range does not match the release series you want to publish. + +```yaml +- name: Release + uses: softprops/action-gh-release@v2 + with: + tag_name: stage-2026-03-15 + target_commitish: ${{ github.sha }} + previous_tag: prod-2026-03-01 + generate_release_notes: true +``` + ### 💅 Customizing #### inputs @@ -196,6 +210,7 @@ The following are optional as `step.with` keys | `token` | String | Authorized GitHub token or PAT. Defaults to `${{ github.token }}` when omitted. A non-empty explicit token overrides `GITHUB_TOKEN`. Passing `""` treats the token as explicitly unset, so omit the input entirely or use an expression such as `${{ inputs.token || github.token }}` when wrapping this action in a composite action. | | `discussion_category_name` | String | If specified, a discussion of the specified category is created and linked to the release. The value must be a category that already exists in the repository. For more information, see ["Managing categories for discussions in your repository."](https://docs.github.com/en/discussions/managing-discussions-for-your-community/managing-categories-for-discussions-in-your-repository) | | `generate_release_notes` | Boolean | Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes. See the [GitHub docs for this feature](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) for more information | +| `previous_tag` | String | Optional. When `generate_release_notes` is enabled, use this tag as GitHub's `previous_tag_name` comparison base. If omitted, GitHub chooses the comparison base automatically. | | `append_body` | Boolean | Append to existing body instead of overwriting it | | `make_latest` | String | Specifies whether this release should be set as the latest release for the repository. Drafts and prereleases cannot be set as latest. Can be `true`, `false`, or `legacy`. Uses GitHub api defaults if not provided | diff --git a/__tests__/github.test.ts b/__tests__/github.test.ts index 0973f83..12d4688 100644 --- a/__tests__/github.test.ts +++ b/__tests__/github.test.ts @@ -2,6 +2,7 @@ import { asset, findTagFromReleases, finalizeRelease, + GitHubReleaser, mimeOrDefault, release, Release, @@ -32,6 +33,7 @@ describe('github', () => { input_target_commitish: undefined, input_discussion_category_name: undefined, input_generate_release_notes: false, + input_previous_tag: undefined, input_append_body: false, input_make_latest: undefined, }; @@ -146,6 +148,86 @@ describe('github', () => { }); }); + describe('GitHubReleaser', () => { + it('passes previous_tag_name to generateReleaseNotes and strips it from createRelease', async () => { + const generateReleaseNotes = vi.fn(async () => ({ + data: { + name: 'Generated release', + body: "## What's Changed\n* Added support for previous_tag", + }, + })); + const createRelease = vi.fn(async (params) => ({ + data: { + id: 1, + upload_url: 'test', + html_url: 'test', + tag_name: params.tag_name, + name: params.name, + body: params.body, + target_commitish: params.target_commitish || 'main', + draft: params.draft ?? false, + prerelease: params.prerelease ?? false, + assets: [], + }, + })); + + const releaser = new GitHubReleaser({ + rest: { + repos: { + generateReleaseNotes, + createRelease, + updateRelease: vi.fn(), + getReleaseByTag: vi.fn(), + listReleaseAssets: vi.fn(), + deleteReleaseAsset: vi.fn(), + deleteRelease: vi.fn(), + updateReleaseAsset: vi.fn(), + listReleases: { + endpoint: { + merge: vi.fn(), + }, + }, + }, + }, + paginate: { + iterator: vi.fn(), + }, + request: vi.fn(), + } as any); + + await releaser.createRelease({ + owner: 'owner', + repo: 'repo', + tag_name: 'v1.0.0', + name: 'v1.0.0', + body: 'Intro', + draft: false, + prerelease: false, + target_commitish: 'abc123', + discussion_category_name: undefined, + generate_release_notes: true, + make_latest: undefined, + previous_tag_name: 'v0.9.0', + }); + + expect(generateReleaseNotes).toHaveBeenCalledWith({ + owner: 'owner', + repo: 'repo', + tag_name: 'v1.0.0', + target_commitish: 'abc123', + previous_tag_name: 'v0.9.0', + }); + expect(createRelease).toHaveBeenCalledWith( + expect.objectContaining({ + tag_name: 'v1.0.0', + body: "Intro\n\n## What's Changed\n* Added support for previous_tag", + generate_release_notes: false, + }), + ); + expect(createRelease.mock.calls[0][0]).not.toHaveProperty('previous_tag_name'); + }); + }); + describe('finalizeRelease input_draft behavior', () => { const draftRelease: Release = { id: 1, @@ -340,6 +422,101 @@ describe('github', () => { }); describe('error handling', () => { + it('passes previous_tag_name through when creating a release with generated notes', async () => { + const createReleaseSpy = vi.fn(async () => ({ + data: { + id: 1, + upload_url: 'test', + html_url: 'test', + tag_name: 'v1.0.0', + name: 'test', + body: 'generated notes', + target_commitish: 'main', + draft: true, + prerelease: false, + assets: [], + }, + })); + + await release( + { + ...config, + input_generate_release_notes: true, + input_previous_tag: 'v0.9.0', + }, + { + getReleaseByTag: () => Promise.reject({ status: 404 }), + createRelease: createReleaseSpy, + updateRelease: () => Promise.reject('Not implemented'), + finalizeRelease: () => Promise.reject('Not implemented'), + allReleases: async function* () { + yield { data: [] }; + }, + listReleaseAssets: () => Promise.reject('Not implemented'), + deleteReleaseAsset: () => Promise.reject('Not implemented'), + deleteRelease: () => Promise.reject('Not implemented'), + updateReleaseAsset: () => Promise.reject('Not implemented'), + uploadReleaseAsset: () => Promise.reject('Not implemented'), + }, + 1, + ); + + expect(createReleaseSpy).toHaveBeenCalledWith( + expect.objectContaining({ + tag_name: 'v1.0.0', + generate_release_notes: true, + previous_tag_name: 'v0.9.0', + }), + ); + }); + + it('passes previous_tag_name through when updating a release with generated notes', async () => { + const existingRelease: Release = { + id: 1, + upload_url: 'test', + html_url: 'test', + tag_name: 'v1.0.0', + name: 'test', + body: 'existing body', + target_commitish: 'main', + draft: false, + prerelease: false, + assets: [], + }; + const updateReleaseSpy = vi.fn(async () => ({ data: existingRelease })); + + await release( + { + ...config, + input_generate_release_notes: true, + input_previous_tag: 'v0.9.0', + }, + { + getReleaseByTag: () => Promise.resolve({ data: existingRelease }), + createRelease: () => Promise.reject('Not implemented'), + updateRelease: updateReleaseSpy, + finalizeRelease: () => Promise.reject('Not implemented'), + allReleases: async function* () { + yield { data: [existingRelease] }; + }, + listReleaseAssets: () => Promise.reject('Not implemented'), + deleteReleaseAsset: () => Promise.reject('Not implemented'), + deleteRelease: () => Promise.reject('Not implemented'), + updateReleaseAsset: () => Promise.reject('Not implemented'), + uploadReleaseAsset: () => Promise.reject('Not implemented'), + }, + 1, + ); + + expect(updateReleaseSpy).toHaveBeenCalledWith( + expect.objectContaining({ + release_id: existingRelease.id, + generate_release_notes: true, + previous_tag_name: 'v0.9.0', + }), + ); + }); + it('creates published prereleases without the forced draft-first path', async () => { const prereleaseConfig = { ...config, diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts index b7640e3..b142c6e 100644 --- a/__tests__/util.test.ts +++ b/__tests__/util.test.ts @@ -174,6 +174,29 @@ describe('util', () => { }); }); describe('parseConfig', () => { + const baseParsedConfig = { + github_ref: '', + github_repository: '', + github_token: '', + input_working_directory: undefined, + input_append_body: false, + input_body: undefined, + input_body_path: undefined, + input_draft: undefined, + input_prerelease: undefined, + input_preserve_order: undefined, + input_files: [], + input_overwrite_files: undefined, + input_name: undefined, + input_tag_name: undefined, + input_fail_on_unmatched_files: false, + input_target_commitish: undefined, + input_discussion_category_name: undefined, + input_generate_release_notes: false, + input_previous_tag: undefined, + input_make_latest: undefined, + }; + it('parses basic config', () => { assert.deepStrictEqual( parseConfig({ @@ -186,27 +209,7 @@ describe('util', () => { INPUT_TARGET_COMMITISH: '', INPUT_DISCUSSION_CATEGORY_NAME: '', }), - { - github_ref: '', - github_repository: '', - github_token: '', - input_working_directory: undefined, - input_append_body: false, - input_body: undefined, - input_body_path: undefined, - input_draft: undefined, - input_prerelease: undefined, - input_preserve_order: undefined, - input_files: [], - input_overwrite_files: undefined, - input_name: undefined, - input_tag_name: undefined, - input_fail_on_unmatched_files: false, - input_target_commitish: undefined, - input_discussion_category_name: undefined, - input_generate_release_notes: false, - input_make_latest: undefined, - }, + baseParsedConfig, ); }); @@ -216,25 +219,8 @@ describe('util', () => { INPUT_TARGET_COMMITISH: 'affa18ef97bc9db20076945705aba8c516139abd', }), { - github_ref: '', - github_repository: '', - github_token: '', - input_working_directory: undefined, - input_append_body: false, - input_body: undefined, - input_body_path: undefined, - input_draft: undefined, - input_prerelease: undefined, - input_files: [], - input_overwrite_files: undefined, - input_preserve_order: undefined, - input_name: undefined, - input_tag_name: undefined, - input_fail_on_unmatched_files: false, + ...baseParsedConfig, input_target_commitish: 'affa18ef97bc9db20076945705aba8c516139abd', - input_discussion_category_name: undefined, - input_generate_release_notes: false, - input_make_latest: undefined, }, ); }); @@ -244,25 +230,8 @@ describe('util', () => { INPUT_DISCUSSION_CATEGORY_NAME: 'releases', }), { - github_ref: '', - github_repository: '', - github_token: '', - input_working_directory: undefined, - input_append_body: false, - input_body: undefined, - input_body_path: undefined, - input_draft: undefined, - input_prerelease: undefined, - input_files: [], - input_preserve_order: undefined, - input_name: undefined, - input_overwrite_files: undefined, - input_tag_name: undefined, - input_fail_on_unmatched_files: false, - input_target_commitish: undefined, + ...baseParsedConfig, input_discussion_category_name: 'releases', - input_generate_release_notes: false, - input_make_latest: undefined, }, ); }); @@ -273,25 +242,20 @@ describe('util', () => { INPUT_GENERATE_RELEASE_NOTES: 'true', }), { - github_ref: '', - github_repository: '', - github_token: '', - input_working_directory: undefined, - input_append_body: false, - input_body: undefined, - input_body_path: undefined, - input_draft: undefined, - input_prerelease: undefined, - input_preserve_order: undefined, - input_files: [], - input_overwrite_files: undefined, - input_name: undefined, - input_tag_name: undefined, - input_fail_on_unmatched_files: false, - input_target_commitish: undefined, - input_discussion_category_name: undefined, + ...baseParsedConfig, input_generate_release_notes: true, - input_make_latest: undefined, + }, + ); + }); + + it('supports an explicit previous tag for release notes generation', () => { + assert.deepStrictEqual( + parseConfig({ + INPUT_PREVIOUS_TAG: ' v1.2.3 ', + }), + { + ...baseParsedConfig, + input_previous_tag: 'v1.2.3', }, ); }); @@ -306,25 +270,11 @@ describe('util', () => { INPUT_TOKEN: 'input-token', }), { - github_ref: '', - github_repository: '', + ...baseParsedConfig, github_token: 'input-token', - input_working_directory: undefined, - input_append_body: false, - input_body: undefined, - input_body_path: undefined, input_draft: false, input_prerelease: true, input_preserve_order: true, - input_files: [], - input_overwrite_files: undefined, - input_name: undefined, - input_tag_name: undefined, - input_fail_on_unmatched_files: false, - input_target_commitish: undefined, - input_discussion_category_name: undefined, - input_generate_release_notes: false, - input_make_latest: undefined, }, ); }); @@ -335,25 +285,8 @@ describe('util', () => { INPUT_TOKEN: ' ', }), { - github_ref: '', - github_repository: '', + ...baseParsedConfig, github_token: 'env-token', - input_working_directory: undefined, - input_append_body: false, - input_body: undefined, - input_body_path: undefined, - input_draft: undefined, - input_prerelease: undefined, - input_preserve_order: undefined, - input_files: [], - input_overwrite_files: undefined, - input_name: undefined, - input_tag_name: undefined, - input_fail_on_unmatched_files: false, - input_target_commitish: undefined, - input_discussion_category_name: undefined, - input_generate_release_notes: false, - input_make_latest: undefined, }, ); }); @@ -365,25 +298,10 @@ describe('util', () => { INPUT_TOKEN: 'input-token', }), { - github_ref: '', - github_repository: '', + ...baseParsedConfig, github_token: 'input-token', - input_working_directory: undefined, - input_append_body: false, - input_body: undefined, - input_body_path: undefined, input_draft: false, input_prerelease: true, - input_preserve_order: undefined, - input_files: [], - input_overwrite_files: undefined, - input_name: undefined, - input_tag_name: undefined, - input_fail_on_unmatched_files: false, - input_target_commitish: undefined, - input_discussion_category_name: undefined, - input_generate_release_notes: false, - input_make_latest: undefined, }, ); }); @@ -394,25 +312,9 @@ describe('util', () => { INPUT_PRERELEASE: 'true', }), { - github_ref: '', - github_repository: '', - github_token: '', - input_working_directory: undefined, - input_append_body: false, - input_body: undefined, - input_body_path: undefined, + ...baseParsedConfig, input_draft: false, input_prerelease: true, - input_preserve_order: undefined, - input_files: [], - input_overwrite_files: undefined, - input_name: undefined, - input_tag_name: undefined, - input_fail_on_unmatched_files: false, - input_target_commitish: undefined, - input_discussion_category_name: undefined, - input_generate_release_notes: false, - input_make_latest: undefined, }, ); }); @@ -422,24 +324,7 @@ describe('util', () => { INPUT_MAKE_LATEST: 'false', }), { - github_ref: '', - github_repository: '', - github_token: '', - input_working_directory: undefined, - input_append_body: false, - input_body: undefined, - input_body_path: undefined, - input_draft: undefined, - input_prerelease: undefined, - input_preserve_order: undefined, - input_files: [], - input_name: undefined, - input_overwrite_files: undefined, - input_tag_name: undefined, - input_fail_on_unmatched_files: false, - input_target_commitish: undefined, - input_discussion_category_name: undefined, - input_generate_release_notes: false, + ...baseParsedConfig, input_make_latest: 'false', }, ); @@ -450,25 +335,8 @@ describe('util', () => { INPUT_APPEND_BODY: 'true', }), { - github_ref: '', - github_repository: '', - github_token: '', - input_working_directory: undefined, + ...baseParsedConfig, input_append_body: true, - input_body: undefined, - input_body_path: undefined, - input_draft: undefined, - input_prerelease: undefined, - input_preserve_order: undefined, - input_files: [], - input_overwrite_files: undefined, - input_name: undefined, - input_tag_name: undefined, - input_fail_on_unmatched_files: false, - input_target_commitish: undefined, - input_discussion_category_name: undefined, - input_generate_release_notes: false, - input_make_latest: undefined, }, ); }); diff --git a/action.yml b/action.yml index 748096d..c0fe1dc 100644 --- a/action.yml +++ b/action.yml @@ -53,6 +53,10 @@ inputs: generate_release_notes: description: "Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes." required: false + previous_tag: + description: "Optional. When generate_release_notes is enabled, use this tag as GitHub's previous_tag_name comparison base. If omitted, GitHub chooses the comparison base automatically." + required: false + default: "" append_body: description: "Append to existing body instead of overwriting it. Default is false." required: false diff --git a/dist/index.js b/dist/index.js index b793661..40b49e2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -47,16 +47,14 @@ ${o}`;break;case"retry":SB(o)&&(s[i]=o);break;case"id":UB(o)&&(s[i]=o);break;cas `+e.errors.map(t=>` - ${t.message}`).join(` `)}var QM=class extends Error{constructor(e,t,s){super(fM(s)),this.request=e,this.headers=t,this.response=s,this.errors=s.errors,this.data=s.data,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}name="GraphqlResponseError";errors;data},BM=["method","baseUrl","url","headers","request","query","mediaType","operationName"],CM=["query","method","url"],LC=/\/api\/v3\/?$/;function IM(e,t,s){if(s){if(typeof t=="string"&&"query"in s)return Promise.reject(new Error('[@octokit/graphql] "query" cannot be used as variable name'));for(let n in s)if(CM.includes(n))return Promise.reject(new Error(`[@octokit/graphql] "${n}" cannot be used as variable name`))}let r=typeof t=="string"?Object.assign({query:t},s):t,i=Object.keys(r).reduce((n,a)=>BM.includes(a)?(n[a]=r[a],n):(n.variables||(n.variables={}),n.variables[a]=r[a],n),{}),o=r.baseUrl||e.endpoint.DEFAULTS.baseUrl;return LC.test(o)&&(i.url=o.replace(LC,"/api/graphql")),e(i).then(n=>{if(n.data.errors){let a={};for(let A of Object.keys(n.headers))a[A]=n.headers[A];throw new QM(i,a,n.data)}return n.data.data})}function Gu(e,t){let s=e.defaults(t);return Object.assign((i,o)=>IM(s,i,o),{defaults:Gu.bind(null,s),endpoint:s.endpoint})}var aJ=Gu(io,{headers:{"user-agent":`octokit-graphql.js/${mM} ${ds()}`},method:"POST",url:"/graphql"});function _C(e){return Gu(e,{method:"POST",url:"/graphql"})}var Mu="(?:[a-zA-Z0-9_-]+)",YC="\\.",OC=new RegExp(`^${Mu}${YC}${Mu}${YC}${Mu}$`),wM=OC.test.bind(OC);async function bM(e){let t=wM(e),s=e.startsWith("v1.")||e.startsWith("ghs_"),r=e.startsWith("ghu_");return{type:"token",token:e,tokenType:t?"app":s?"installation":r?"user-to-server":"oauth"}}function yM(e){return e.split(/\./).length===3?`bearer ${e}`:`token ${e}`}async function xM(e,t,s,r){let i=t.endpoint.merge(s,r);return i.headers.authorization=yM(e),t(i)}var JC=function(t){if(!t)throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");if(typeof t!="string")throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string");return t=t.replace(/^(token|bearer) +/i,""),Object.assign(bM.bind(null,t),{hook:xM.bind(null,t)})};var Lu="7.0.6";var PC=()=>{},vM=console.warn.bind(console),kM=console.error.bind(console);function DM(e={}){return typeof e.debug!="function"&&(e.debug=PC),typeof e.info!="function"&&(e.info=PC),typeof e.warn!="function"&&(e.warn=vM),typeof e.error!="function"&&(e.error=kM),e}var HC=`octokit-core.js/${Lu} ${ds()}`,Ta=class{static VERSION=Lu;static defaults(t){return class extends this{constructor(...r){let i=r[0]||{};if(typeof t=="function"){super(t(i));return}super(Object.assign({},t,i,i.userAgent&&t.userAgent?{userAgent:`${i.userAgent} ${t.userAgent}`}:null))}}}static plugins=[];static plugin(...t){let s=this.plugins;return class extends this{static plugins=s.concat(t.filter(i=>!s.includes(i)))}}constructor(t={}){let s=new mC.Collection,r={baseUrl:io.endpoint.DEFAULTS.baseUrl,headers:{},request:Object.assign({},t.request,{hook:s.bind(null,"request")}),mediaType:{previews:[],format:""}};if(r.headers["user-agent"]=t.userAgent?`${t.userAgent} ${HC}`:HC,t.baseUrl&&(r.baseUrl=t.baseUrl),t.previews&&(r.mediaType.previews=t.previews),t.timeZone&&(r.headers["time-zone"]=t.timeZone),this.request=io.defaults(r),this.graphql=_C(this.request).defaults(r),this.log=DM(t.log),this.hook=s,t.authStrategy){let{authStrategy:o,...n}=t,a=o(Object.assign({request:this.request,log:this.log,octokit:this,octokitOptions:n},t.auth));s.wrap("request",a.hook),this.auth=a}else if(!t.auth)this.auth=async()=>({type:"unauthenticated"});else{let o=JC(t.auth);s.wrap("request",o.hook),this.auth=o}let i=this.constructor;for(let o=0;o({async next(){if(!a)return{done:!0};try{let A=await i({method:o,url:a,headers:n}),c=NM(A);if(a=((c.headers.link||"").match(/<([^<>]+)>;\s*rel="next"/)||[])[1],!a&&"total_commits"in c.data){let u=new URL(c.url),l=u.searchParams,p=parseInt(l.get("page")||"1",10),g=parseInt(l.get("per_page")||"250",10);p*g{if(i.done)return t;let o=!1;function n(){o=!0}return t=t.concat(r?r(i.value,n):i.value.data),o?t:WC(e,t,s,r)})}var kJ=Object.assign(qC,{iterator:Ju});function Pu(e){return{paginate:Object.assign(qC.bind(null,e),{iterator:Ju.bind(null,e)})}}Pu.VERSION=UM;var SJ=new Wr,Hu=uC(),GM={baseUrl:Hu,request:{agent:cC(Hu),fetch:lC(Hu)}},jC=Ta.plugin(Ou,Pu).defaults(GM);function zC(e,t){let s=Object.assign({},t||{}),r=AC(e,s);return r&&(s.auth=r),s}var GJ=new Wr;function ZC(e,t,...s){let r=jC.plugin(...s);return new r(zC(e,t))}var xw=require("fs"),vw=require("fs/promises"),kw=de(AI()),Dw=require("path");var HI=require("node:url"),$r=require("node:path"),zI=require("node:url"),Dt=require("fs"),ZL=de(require("node:fs"),1),Qs=require("node:fs/promises"),qa=require("node:events"),rp=de(require("node:stream"),1),ZI=require("node:string_decoder"),FI=(e,t,s)=>{let r=e instanceof RegExp?cI(e,s):e,i=t instanceof RegExp?cI(t,s):t,o=r!==null&&i!=null&&VM(r,i,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+r.length,o[1]),post:s.slice(o[1]+i.length)}},cI=(e,t)=>{let s=t.match(e);return s?s[0]:null},VM=(e,t,s)=>{let r,i,o,n,a,A=s.indexOf(e),c=s.indexOf(t,A+1),u=A;if(A>=0&&c>0){if(e===t)return[A,c];for(r=[],o=s.length;u>=0&&!a;){if(u===A)r.push(u),A=s.indexOf(e,u+1);else if(r.length===1){let l=r.pop();l!==void 0&&(a=[l,c])}else i=r.pop(),i!==void 0&&i=0?A:c}r.length&&n!==void 0&&(a=[o,n])}return a},SI="\0SLASH"+Math.random()+"\0",UI="\0OPEN"+Math.random()+"\0",tp="\0CLOSE"+Math.random()+"\0",NI="\0COMMA"+Math.random()+"\0",GI="\0PERIOD"+Math.random()+"\0",qM=new RegExp(SI,"g"),WM=new RegExp(UI,"g"),jM=new RegExp(tp,"g"),zM=new RegExp(NI,"g"),ZM=new RegExp(GI,"g"),KM=/\\\\/g,XM=/\\{/g,$M=/\\}/g,eL=/\\,/g,tL=/\\./g,sL=1e5;function qu(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function rL(e){return e.replace(KM,SI).replace(XM,UI).replace($M,tp).replace(eL,NI).replace(tL,GI)}function iL(e){return e.replace(qM,"\\").replace(WM,"{").replace(jM,"}").replace(zM,",").replace(ZM,".")}function MI(e){if(!e)return[""];let t=[],s=FI("{","}",e);if(!s)return e.split(",");let{pre:r,body:i,post:o}=s,n=r.split(",");n[n.length-1]+="{"+i+"}";let a=MI(o);return o.length&&(n[n.length-1]+=a.shift(),n.push.apply(n,a)),t.push.apply(t,n),t}function oL(e,t={}){if(!e)return[];let{max:s=sL}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),uo(rL(e),s,!0).map(iL)}function nL(e){return"{"+e+"}"}function aL(e){return/^-?0\d/.test(e)}function AL(e,t){return e<=t}function cL(e,t){return e>=t}function uo(e,t,s){let r=[],i=FI("{","}",e);if(!i)return[e];let o=i.pre,n=i.post.length?uo(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let a=0;a=0;if(!c&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+"{"+i.body+tp+i.post,uo(e,t,!0)):[e];let l;if(c)l=i.body.split(/\.\./);else if(l=MI(i.body),l.length===1&&l[0]!==void 0&&(l=uo(l[0],t,!1).map(nL),l.length===1))return n.map(g=>i.pre+l[0]+g);let p;if(c&&l[0]!==void 0&&l[1]!==void 0){let g=qu(l[0]),h=qu(l[1]),E=Math.max(l[0].length,l[1].length),m=l.length===3&&l[2]!==void 0?Math.abs(qu(l[2])):1,d=AL;h0){let Y=new Array(b+1).join("0");C<0?B="-"+Y+B.slice(1):B=Y+B}}p.push(B)}}else{p=[];for(let g=0;g{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},lL={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},oo=e=>e.replace(/[[\]\\-]/g,"\\$&"),uL=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lI=e=>e.join(""),pL=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let r=[],i=[],o=s+1,n=!1,a=!1,A=!1,c=!1,u=s,l="";e:for(;ol?r.push(oo(l)+"-"+oo(h)):h===l&&r.push(oo(h)),l="",o++;continue}if(e.startsWith("-]",o+1)){r.push(oo(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){l=h,o+=2;continue}r.push(oo(h)),o++}if(us?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),gL=new Set(["!","?","+","*","@"]),uI=e=>gL.has(e),hL="(?!(?:^|/)\\.\\.?(?:$|/))",Fa="(?!\\.)",dL=new Set(["[","."]),EL=new Set(["..","."]),mL=new Set("().*{}+?[]^$\\!"),fL=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),sp="[^/]",pI=sp+"*?",gI=sp+"+?",LI=class He{type;#e;#t;#i=!1;#s=[];#r;#A;#a;#c=!1;#l;#g;#h=!1;constructor(t,s,r={}){this.type=t,t&&(this.#t=!0),this.#r=s,this.#e=this.#r?this.#r.#e:this,this.#l=this.#e===this?r:this.#e.#l,this.#a=this.#e===this?[]:this.#e.#a,t==="!"&&!this.#e.#c&&this.#a.push(this),this.#A=this.#r?this.#r.#s.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#s)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#g!==void 0?this.#g:this.type?this.#g=this.type+"("+this.#s.map(t=>String(t)).join("|")+")":this.#g=this.#s.map(t=>String(t)).join("")}#u(){if(this!==this.#e)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let t;for(;t=this.#a.pop();){if(t.type!=="!")continue;let s=t,r=s.#r;for(;r;){for(let i=s.#A+1;!r.type&&itypeof s=="string"?s:s.toJSON()):[this.type,...this.#s.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#c&&this.#r?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#r?.isStart())return!1;if(this.#A===0)return!0;let t=this.#r;for(let s=0;stypeof p!="string"),c=this.#s.map(p=>{let[g,h,E,m]=typeof p=="string"?He.#C(p,this.#t,A):p.toRegExpSource(t);return this.#t=this.#t||E,this.#i=this.#i||m,g}).join(""),u="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&EL.has(this.#s[0]))){let p=dL,g=s&&p.has(c.charAt(0))||c.startsWith("\\.")&&p.has(c.charAt(2))||c.startsWith("\\.\\.")&&p.has(c.charAt(4)),h=!s&&!t&&p.has(c.charAt(0));u=g?hL:h?Fa:""}let l="";return this.isEnd()&&this.#e.#c&&this.#r?.type==="!"&&(l="(?:$|\\/)"),[u+c+l,Xr(c),this.#t=!!this.#t,this.#i]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#d(s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let A=this.toString();return this.#s=[A],this.type=null,this.#t=void 0,[A,Xr(this.toString()),!1,!1]}let n=!r||t||s||!Fa?"":this.#d(!0);n===o&&(n=""),n&&(o=`(?:${o})(?:${n})*?`);let a="";if(this.type==="!"&&this.#h)a=(this.isStart()&&!s?Fa:"")+gI;else{let A=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Fa:"")+pI+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&n?")":this.type==="*"&&n?")?":`)${this.type}`;a=i+o+A}return[a,Xr(o),this.#t=!!this.#t,this.#i]}#d(t){return this.#s.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[r,i,o,n]=s.toRegExpSource(t);return this.#i=this.#i||n,r}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#C(t,s,r=!1){let i=!1,o="",n=!1,a=!1;for(let A=0;As?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),ye=(e,t,s={})=>(Ja(t),!s.nocomment&&t.charAt(0)==="#"?!1:new fs(t,s).match(e)),QL=/^\*+([^+@!?\*\[\(]*)$/,BL=e=>t=>!t.startsWith(".")&&t.endsWith(e),CL=e=>t=>t.endsWith(e),IL=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),wL=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),bL=/^\*+\.\*+$/,yL=e=>!e.startsWith(".")&&e.includes("."),xL=e=>e!=="."&&e!==".."&&e.includes("."),vL=/^\.\*+$/,kL=e=>e!=="."&&e!==".."&&e.startsWith("."),DL=/^\*+$/,RL=e=>e.length!==0&&!e.startsWith("."),TL=e=>e.length!==0&&e!=="."&&e!=="..",FL=/^\?+([^+@!?\*\[\(]*)?$/,SL=([e,t=""])=>{let s=YI([e]);return t?(t=t.toLowerCase(),r=>s(r)&&r.toLowerCase().endsWith(t)):s},UL=([e,t=""])=>{let s=OI([e]);return t?(t=t.toLowerCase(),r=>s(r)&&r.toLowerCase().endsWith(t)):s},NL=([e,t=""])=>{let s=OI([e]);return t?r=>s(r)&&r.endsWith(t):s},GL=([e,t=""])=>{let s=YI([e]);return t?r=>s(r)&&r.endsWith(t):s},YI=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},OI=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},JI=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",hI={win32:{sep:"\\"},posix:{sep:"/"}},ML=JI==="win32"?hI.win32.sep:hI.posix.sep;ye.sep=ML;var be=Symbol("globstar **");ye.GLOBSTAR=be;var LL="[^/]",_L=LL+"*?",YL="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",OL="(?:(?!(?:\\/|^)\\.).)*?",JL=(e,t={})=>s=>ye(s,e,t);ye.filter=JL;var $e=(e,t={})=>Object.assign({},e,t),PL=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return ye;let t=ye;return Object.assign((s,r,i={})=>t(s,r,$e(e,i)),{Minimatch:class extends t.Minimatch{constructor(s,r={}){super(s,$e(e,r))}static defaults(s){return t.defaults($e(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,r,i={}){super(s,r,$e(e,i))}static fromGlob(s,r={}){return t.AST.fromGlob(s,$e(e,r))}},unescape:(s,r={})=>t.unescape(s,$e(e,r)),escape:(s,r={})=>t.escape(s,$e(e,r)),filter:(s,r={})=>t.filter(s,$e(e,r)),defaults:s=>t.defaults($e(e,s)),makeRe:(s,r={})=>t.makeRe(s,$e(e,r)),braceExpand:(s,r={})=>t.braceExpand(s,$e(e,r)),match:(s,r,i={})=>t.match(s,r,$e(e,i)),sep:t.sep,GLOBSTAR:be})};ye.defaults=PL;var PI=(e,t={})=>(Ja(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:oL(e,{max:t.braceExpandMax}));ye.braceExpand=PI;var HL=(e,t={})=>new fs(e,t).makeRe();ye.makeRe=HL;var VL=(e,t,s={})=>{let r=new fs(t,s);return e=e.filter(i=>r.match(i)),r.options.nonull&&!e.length&&e.push(t),e};ye.match=VL;var dI=/[?*]|[+@!]\(.*?\)|\[|\]/,qL=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),fs=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,t={}){Ja(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||JI,this.isWindows=this.platform==="win32";let s="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[s]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...i)=>console.error(...i)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(i=>this.slashSplit(i));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let r=this.globParts.map((i,o,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let a=i[0]===""&&i[1]===""&&(i[2]==="?"||!dI.test(i[2]))&&!dI.test(i[3]),A=/^[a-z]:/i.test(i[0]);if(a)return[...i.slice(0,4),...i.slice(4).map(c=>this.parse(c))];if(A)return[i[0],...i.slice(1).map(c=>this.parse(c))]}return i.map(a=>this.parse(a))});if(this.debug(this.pattern,r),this.set=r.filter(i=>i.indexOf(!1)===-1),this.isWindows)for(let i=0;i=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let r=s;for(;t[r+1]==="**";)r++;r!==s&&t.splice(s,r-s)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((s,r)=>{let i=s[s.length-1];return r==="**"&&i==="**"?s:r===".."&&i&&i!==".."&&i!=="."&&i!=="**"?(s.pop(),s):(s.push(r),s)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let r=1;rr&&s.splice(r+1,o-r);let n=s[r+1],a=s[r+2],A=s[r+3];if(n!==".."||!a||a==="."||a===".."||!A||A==="."||A==="..")continue;t=!0,s.splice(r,1);let c=s.slice(0);c[r]="**",e.push(c),r--}if(!this.preserveMultipleSlashes){for(let o=1;ot.length)}partsMatch(e,t,s=!1){let r=0,i=0,o=[],n="";for(;rf?t=t.slice(C):f>C&&(e=e.slice(f)))}}let{optimizationLevel:i=1}=this.options;i>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var o=0,n=0,a=e.length,A=t.length;o>> no match, partial?`,e,l,t,p),l===a))}let h;if(typeof c=="string"?(h=u===c,this.debug("string match",c,u,h)):(h=c.test(u),this.debug("pattern match",c,u,h)),!h)return!1}if(o===a&&n===A)return!0;if(o===a)return s;if(n===A)return o===a-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return PI(this.pattern,this.options)}parse(e){Ja(e);let t=this.options;if(e==="**")return be;if(e==="")return"";let s,r=null;(s=e.match(DL))?r=t.dot?TL:RL:(s=e.match(QL))?r=(t.nocase?t.dot?wL:IL:t.dot?CL:BL)(s[1]):(s=e.match(FL))?r=(t.nocase?t.dot?UL:SL:t.dot?NL:GL)(s):(s=e.match(bL))?r=t.dot?xL:yL:(s=e.match(vL))&&(r=kL);let i=LI.fromGlob(e,this.options).toMMPattern();return r&&typeof i=="object"&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,s=t.noglobstar?_L:t.dot?YL:OL,r=new Set(t.nocase?["i"]:[]),i=e.map(a=>{let A=a.map(u=>{if(u instanceof RegExp)for(let l of u.flags.split(""))r.add(l);return typeof u=="string"?qL(u):u===be?be:u._src});A.forEach((u,l)=>{let p=A[l+1],g=A[l-1];u!==be||g===be||(g===void 0?p!==void 0&&p!==be?A[l+1]="(?:\\/|"+s+"\\/)?"+p:A[l]=s:p===void 0?A[l-1]=g+"(?:\\/|\\/"+s+")?":p!==be&&(A[l-1]=g+"(?:\\/|\\/"+s+"\\/)"+p,A[l+1]=be))});let c=A.filter(u=>u!==be);if(this.partial&&c.length>=1){let u=[];for(let l=1;l<=c.length;l++)u.push(c.slice(0,l).join("/"));return"(?:"+u.join("|")+")"}return c.join("/")}).join("|"),[o,n]=e.length>1?["(?:",")"]:["",""];i="^"+o+i+n+"$",this.partial&&(i="^(?:\\/|"+o+i.slice(1,-1)+n+")$"),this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let s=this.options;this.isWindows&&(e=e.split("\\").join("/"));let r=this.slashSplit(e);this.debug(this.pattern,"split",r);let i=this.set;this.debug(this.pattern,"set",i);let o=r[r.length-1];if(!o)for(let n=r.length-2;!o&&n>=0;n--)o=r[n];for(let n=0;n{typeof ep.emitWarning=="function"?ep.emitWarning(e,t,s,r):console.error(`[${s}] ${t}: ${e}`)},Pa=globalThis.AbortController,EI=globalThis.AbortSignal;if(typeof Pa>"u"){EI=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,r){this._onabort.push(r)}},Pa=class{constructor(){t()}signal=new EI;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s)}}};let e=ep.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,qI("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var jL=e=>!VI.has(e),ms=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),WI=e=>ms(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Ya:null:null,Ya=class extends Array{constructor(e){super(e),this.fill(0)}},zL=class po{heap;length;static#e=!1;static create(t){let s=WI(t);if(!s)return[];po.#e=!0;let r=new po(t,s);return po.#e=!1,r}constructor(t,s){if(!po.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},Va=class jI{#e;#t;#i;#s;#r;#A;#a;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#g;#h;#u;#n;#d;#C;#B;#E;#k;#m;#b;#y;#f;#Q;#I;#x;#o;#U;static unsafeExposeInternals(t){return{starts:t.#y,ttls:t.#f,autopurgeTimers:t.#Q,sizes:t.#b,keyMap:t.#h,keyList:t.#u,valList:t.#n,next:t.#d,prev:t.#C,get head(){return t.#B},get tail(){return t.#E},free:t.#k,isBackgroundFetch:s=>t.#p(s),backgroundFetch:(s,r,i,o)=>t.#J(s,r,i,o),moveToTail:s=>t.#G(s),indexes:s=>t.#R(s),rindexes:s=>t.#T(s),isStale:s=>t.#w(s)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#g}get size(){return this.#l}get fetchMethod(){return this.#A}get memoMethod(){return this.#a}get dispose(){return this.#i}get onInsert(){return this.#s}get disposeAfter(){return this.#r}constructor(t){let{max:s=0,ttl:r,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:A,dispose:c,onInsert:u,disposeAfter:l,noDisposeOnSet:p,noUpdateTTL:g,maxSize:h=0,maxEntrySize:E=0,sizeCalculation:m,fetchMethod:d,memoMethod:f,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:B,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:Y,ignoreFetchAbort:O,perf:pe}=t;if(pe!==void 0&&typeof pe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#c=pe??WL,s!==0&&!ms(s))throw new TypeError("max option must be a nonnegative integer");let he=s?WI(s):Array;if(!he)throw new Error("invalid max value: "+s);if(this.#e=s,this.#t=h,this.maxEntrySize=E||this.#t,this.sizeCalculation=m,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(f!==void 0&&typeof f!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#a=f,d!==void 0&&typeof d!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#A=d,this.#x=!!d,this.#h=new Map,this.#u=new Array(s).fill(void 0),this.#n=new Array(s).fill(void 0),this.#d=new he(s),this.#C=new he(s),this.#B=0,this.#E=0,this.#k=zL.create(s),this.#l=0,this.#g=0,typeof c=="function"&&(this.#i=c),typeof u=="function"&&(this.#s=u),typeof l=="function"?(this.#r=l,this.#m=[]):(this.#r=void 0,this.#m=void 0),this.#I=!!this.#i,this.#U=!!this.#s,this.#o=!!this.#r,this.noDisposeOnSet=!!p,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!Y,this.ignoreFetchAbort=!!O,this.maxEntrySize!==0){if(this.#t!==0&&!ms(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!ms(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#H()}if(this.allowStale=!!A,this.noDeleteOnStaleGet=!!B,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=ms(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!ms(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#F()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let ht="LRU_CACHE_UNBOUNDED";jL(ht)&&(VI.add(ht),qI("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ht,jI))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#F(){let t=new Ya(this.#e),s=new Ya(this.#e);this.#f=t,this.#y=s;let r=this.ttlAutopurge?new Array(this.#e):void 0;this.#Q=r,this.#L=(n,a,A=this.#c.now())=>{if(s[n]=a!==0?A:0,t[n]=a,r?.[n]&&(clearTimeout(r[n]),r[n]=void 0),a!==0&&r){let c=setTimeout(()=>{this.#w(n)&&this.#D(this.#u[n],"expire")},a+1);c.unref&&c.unref(),r[n]=c}},this.#v=n=>{s[n]=t[n]!==0?this.#c.now():0},this.#S=(n,a)=>{if(t[a]){let A=t[a],c=s[a];if(!A||!c)return;n.ttl=A,n.start=c,n.now=i||o();let u=n.now-c;n.remainingTTL=A-u}};let i=0,o=()=>{let n=this.#c.now();if(this.ttlResolution>0){i=n;let a=setTimeout(()=>i=0,this.ttlResolution);a.unref&&a.unref()}return n};this.getRemainingTTL=n=>{let a=this.#h.get(n);if(a===void 0)return 0;let A=t[a],c=s[a];if(!A||!c)return 1/0;let u=(i||o())-c;return A-u},this.#w=n=>{let a=s[n],A=t[n];return!!A&&!!a&&(i||o())-a>A}}#v=()=>{};#S=()=>{};#L=()=>{};#w=()=>!1;#H(){let t=new Ya(this.#e);this.#g=0,this.#b=t,this.#M=s=>{this.#g-=t[s],t[s]=0},this.#_=(s,r,i,o)=>{if(this.#p(r))return 0;if(!ms(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(r,s),!ms(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#N=(s,r,i)=>{if(t[s]=r,this.#t){let o=this.#t-t[s];for(;this.#g>o;)this.#O(!0)}this.#g+=t[s],i&&(i.entrySize=r,i.totalCalculatedSize=this.#g)}}#M=t=>{};#N=(t,s,r)=>{};#_=(t,s,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#R({allowStale:t=this.allowStale}={}){if(this.#l)for(let s=this.#E;!(!this.#Y(s)||((t||!this.#w(s))&&(yield s),s===this.#B));)s=this.#C[s]}*#T({allowStale:t=this.allowStale}={}){if(this.#l)for(let s=this.#B;!(!this.#Y(s)||((t||!this.#w(s))&&(yield s),s===this.#E));)s=this.#d[s]}#Y(t){return t!==void 0&&this.#h.get(this.#u[t])===t}*entries(){for(let t of this.#R())this.#n[t]!==void 0&&this.#u[t]!==void 0&&!this.#p(this.#n[t])&&(yield[this.#u[t],this.#n[t]])}*rentries(){for(let t of this.#T())this.#n[t]!==void 0&&this.#u[t]!==void 0&&!this.#p(this.#n[t])&&(yield[this.#u[t],this.#n[t]])}*keys(){for(let t of this.#R()){let s=this.#u[t];s!==void 0&&!this.#p(this.#n[t])&&(yield s)}}*rkeys(){for(let t of this.#T()){let s=this.#u[t];s!==void 0&&!this.#p(this.#n[t])&&(yield s)}}*values(){for(let t of this.#R())this.#n[t]!==void 0&&!this.#p(this.#n[t])&&(yield this.#n[t])}*rvalues(){for(let t of this.#T())this.#n[t]!==void 0&&!this.#p(this.#n[t])&&(yield this.#n[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,s={}){for(let r of this.#R()){let i=this.#n[r],o=this.#p(i)?i.__staleWhileFetching:i;if(o!==void 0&&t(o,this.#u[r],this))return this.get(this.#u[r],s)}}forEach(t,s=this){for(let r of this.#R()){let i=this.#n[r],o=this.#p(i)?i.__staleWhileFetching:i;o!==void 0&&t.call(s,o,this.#u[r],this)}}rforEach(t,s=this){for(let r of this.#T()){let i=this.#n[r],o=this.#p(i)?i.__staleWhileFetching:i;o!==void 0&&t.call(s,o,this.#u[r],this)}}purgeStale(){let t=!1;for(let s of this.#T({allowStale:!0}))this.#w(s)&&(this.#D(this.#u[s],"expire"),t=!0);return t}info(t){let s=this.#h.get(t);if(s===void 0)return;let r=this.#n[s],i=this.#p(r)?r.__staleWhileFetching:r;if(i===void 0)return;let o={value:i};if(this.#f&&this.#y){let n=this.#f[s],a=this.#y[s];if(n&&a){let A=n-(this.#c.now()-a);o.ttl=A,o.start=Date.now()}}return this.#b&&(o.size=this.#b[s]),o}dump(){let t=[];for(let s of this.#R({allowStale:!0})){let r=this.#u[s],i=this.#n[s],o=this.#p(i)?i.__staleWhileFetching:i;if(o===void 0||r===void 0)continue;let n={value:o};if(this.#f&&this.#y){n.ttl=this.#f[s];let a=this.#c.now()-this.#y[s];n.start=Math.floor(Date.now()-a)}this.#b&&(n.size=this.#b[s]),t.unshift([r,n])}return t}load(t){this.clear();for(let[s,r]of t){if(r.start){let i=Date.now()-r.start;r.start=this.#c.now()-i}this.set(s,r.value,r)}}set(t,s,r={}){if(s===void 0)return this.delete(t),this;let{ttl:i=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:A}=r,{noUpdateTTL:c=this.noUpdateTTL}=r,u=this.#_(t,s,r.size||0,a);if(this.maxEntrySize&&u>this.maxEntrySize)return A&&(A.set="miss",A.maxEntrySizeExceeded=!0),this.#D(t,"set"),this;let l=this.#l===0?void 0:this.#h.get(t);if(l===void 0)l=this.#l===0?this.#E:this.#k.length!==0?this.#k.pop():this.#l===this.#e?this.#O(!1):this.#l,this.#u[l]=t,this.#n[l]=s,this.#h.set(t,l),this.#d[this.#E]=l,this.#C[l]=this.#E,this.#E=l,this.#l++,this.#N(l,u,A),A&&(A.set="add"),c=!1,this.#U&&this.#s?.(s,t,"add");else{this.#G(l);let p=this.#n[l];if(s!==p){if(this.#x&&this.#p(p)){p.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=p;g!==void 0&&!n&&(this.#I&&this.#i?.(g,t,"set"),this.#o&&this.#m?.push([g,t,"set"]))}else n||(this.#I&&this.#i?.(p,t,"set"),this.#o&&this.#m?.push([p,t,"set"]));if(this.#M(l),this.#N(l,u,A),this.#n[l]=s,A){A.set="replace";let g=p&&this.#p(p)?p.__staleWhileFetching:p;g!==void 0&&(A.oldValue=g)}}else A&&(A.set="update");this.#U&&this.onInsert?.(s,t,s===p?"update":"replace")}if(i!==0&&!this.#f&&this.#F(),this.#f&&(c||this.#L(l,i,o),A&&this.#S(A,l)),!n&&this.#o&&this.#m){let p=this.#m,g;for(;g=p?.shift();)this.#r?.(...g)}return this}pop(){try{for(;this.#l;){let t=this.#n[this.#B];if(this.#O(!0),this.#p(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#o&&this.#m){let t=this.#m,s;for(;s=t?.shift();)this.#r?.(...s)}}}#O(t){let s=this.#B,r=this.#u[s],i=this.#n[s];return this.#x&&this.#p(i)?i.__abortController.abort(new Error("evicted")):(this.#I||this.#o)&&(this.#I&&this.#i?.(i,r,"evict"),this.#o&&this.#m?.push([i,r,"evict"])),this.#M(s),this.#Q?.[s]&&(clearTimeout(this.#Q[s]),this.#Q[s]=void 0),t&&(this.#u[s]=void 0,this.#n[s]=void 0,this.#k.push(s)),this.#l===1?(this.#B=this.#E=0,this.#k.length=0):this.#B=this.#d[s],this.#h.delete(r),this.#l--,s}has(t,s={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=s,o=this.#h.get(t);if(o!==void 0){let n=this.#n[o];if(this.#p(n)&&n.__staleWhileFetching===void 0)return!1;if(this.#w(o))i&&(i.has="stale",this.#S(i,o));else return r&&this.#v(o),i&&(i.has="hit",this.#S(i,o)),!0}else i&&(i.has="miss");return!1}peek(t,s={}){let{allowStale:r=this.allowStale}=s,i=this.#h.get(t);if(i===void 0||!r&&this.#w(i))return;let o=this.#n[i];return this.#p(o)?o.__staleWhileFetching:o}#J(t,s,r,i){let o=s===void 0?void 0:this.#n[s];if(this.#p(o))return o;let n=new Pa,{signal:a}=r;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let A={signal:n.signal,options:r,context:i},c=(E,m=!1)=>{let{aborted:d}=n.signal,f=r.ignoreFetchAbort&&E!==void 0,C=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&E!==void 0);if(r.status&&(d&&!m?(r.status.fetchAborted=!0,r.status.fetchError=n.signal.reason,f&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),d&&!f&&!m)return l(n.signal.reason,C);let B=g,b=this.#n[s];return(b===g||f&&m&&b===void 0)&&(E===void 0?B.__staleWhileFetching!==void 0?this.#n[s]=B.__staleWhileFetching:this.#D(t,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(t,E,A.options))),E},u=E=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=E),l(E,!1)),l=(E,m)=>{let{aborted:d}=n.signal,f=d&&r.allowStaleOnFetchAbort,C=f||r.allowStaleOnFetchRejection,B=C||r.noDeleteOnFetchRejection,b=g;if(this.#n[s]===g&&(!B||!m&&b.__staleWhileFetching===void 0?this.#D(t,"fetch"):f||(this.#n[s]=b.__staleWhileFetching)),C)return r.status&&b.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),b.__staleWhileFetching;if(b.__returned===b)throw E},p=(E,m)=>{let d=this.#A?.(t,o,A);d&&d instanceof Promise&&d.then(f=>E(f===void 0?void 0:f),m),n.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(E(void 0),r.allowStaleOnFetchAbort&&(E=f=>c(f,!0)))})};r.status&&(r.status.fetchDispatched=!0);let g=new Promise(p).then(c,u),h=Object.assign(g,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,h,{...A.options,status:void 0}),s=this.#h.get(t)):this.#n[s]=h,h}#p(t){if(!this.#x)return!1;let s=t;return!!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Pa}async fetch(t,s={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:A=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:E,forceRefresh:m=!1,status:d,signal:f}=s;if(!this.#x)return d&&(d.fetch="get"),this.get(t,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:d});let C={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:A,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:h,ignoreFetchAbort:g,status:d,signal:f},B=this.#h.get(t);if(B===void 0){d&&(d.fetch="miss");let b=this.#J(t,B,C,E);return b.__returned=b}else{let b=this.#n[B];if(this.#p(b)){let he=r&&b.__staleWhileFetching!==void 0;return d&&(d.fetch="inflight",he&&(d.returnedStale=!0)),he?b.__staleWhileFetching:b.__returned=b}let Y=this.#w(B);if(!m&&!Y)return d&&(d.fetch="hit"),this.#G(B),i&&this.#v(B),d&&this.#S(d,B),b;let O=this.#J(t,B,C,E),pe=O.__staleWhileFetching!==void 0&&r;return d&&(d.fetch=Y?"stale":"refresh",pe&&Y&&(d.returnedStale=!0)),pe?O.__staleWhileFetching:O.__returned=O}}async forceFetch(t,s={}){let r=await this.fetch(t,s);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(t,s={}){let r=this.#a;if(!r)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:o,...n}=s,a=this.get(t,n);if(!o&&a!==void 0)return a;let A=r(t,a,{options:n,context:i});return this.set(t,A,n),A}get(t,s={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=s,a=this.#h.get(t);if(a!==void 0){let A=this.#n[a],c=this.#p(A);return n&&this.#S(n,a),this.#w(a)?(n&&(n.get="stale"),c?(n&&r&&A.__staleWhileFetching!==void 0&&(n.returnedStale=!0),r?A.__staleWhileFetching:void 0):(o||this.#D(t,"expire"),n&&r&&(n.returnedStale=!0),r?A:void 0)):(n&&(n.get="hit"),c?A.__staleWhileFetching:(this.#G(a),i&&this.#v(a),A))}else n&&(n.get="miss")}#P(t,s){this.#C[s]=t,this.#d[t]=s}#G(t){t!==this.#E&&(t===this.#B?this.#B=this.#d[t]:this.#P(this.#C[t],this.#d[t]),this.#P(this.#E,t),this.#E=t)}delete(t){return this.#D(t,"delete")}#D(t,s){let r=!1;if(this.#l!==0){let i=this.#h.get(t);if(i!==void 0)if(this.#Q?.[i]&&(clearTimeout(this.#Q?.[i]),this.#Q[i]=void 0),r=!0,this.#l===1)this.#V(s);else{this.#M(i);let o=this.#n[i];if(this.#p(o)?o.__abortController.abort(new Error("deleted")):(this.#I||this.#o)&&(this.#I&&this.#i?.(o,t,s),this.#o&&this.#m?.push([o,t,s])),this.#h.delete(t),this.#u[i]=void 0,this.#n[i]=void 0,i===this.#E)this.#E=this.#C[i];else if(i===this.#B)this.#B=this.#d[i];else{let n=this.#C[i];this.#d[n]=this.#d[i];let a=this.#d[i];this.#C[a]=this.#C[i]}this.#l--,this.#k.push(i)}}if(this.#o&&this.#m?.length){let i=this.#m,o;for(;o=i?.shift();)this.#r?.(...o)}return r}clear(){return this.#V("delete")}#V(t){for(let s of this.#T({allowStale:!0})){let r=this.#n[s];if(this.#p(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#u[s];this.#I&&this.#i?.(r,i,t),this.#o&&this.#m?.push([r,i,t])}}if(this.#h.clear(),this.#n.fill(void 0),this.#u.fill(void 0),this.#f&&this.#y){this.#f.fill(0),this.#y.fill(0);for(let s of this.#Q??[])s!==void 0&&clearTimeout(s);this.#Q?.fill(void 0)}if(this.#b&&this.#b.fill(0),this.#B=0,this.#E=0,this.#k.length=0,this.#g=0,this.#l=0,this.#o&&this.#m){let s=this.#m,r;for(;r=s?.shift();)this.#r?.(...r)}}},mI=typeof process=="object"&&process?process:{stdout:null,stderr:null},KL=e=>!!e&&typeof e=="object"&&(e instanceof Ha||e instanceof rp.default||XL(e)||$L(e)),XL=e=>!!e&&typeof e=="object"&&e instanceof qa.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==rp.default.Writable.prototype.pipe,$L=e=>!!e&&typeof e=="object"&&e instanceof qa.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",Vt=Symbol("EOF"),qt=Symbol("maybeEmitEnd"),Es=Symbol("emittedEnd"),Sa=Symbol("emittingEnd"),no=Symbol("emittedError"),Ua=Symbol("closed"),fI=Symbol("read"),Na=Symbol("flush"),QI=Symbol("flushChunk"),pt=Symbol("encoding"),Zr=Symbol("decoder"),ce=Symbol("flowing"),ao=Symbol("paused"),Kr=Symbol("resume"),le=Symbol("buffer"),we=Symbol("pipes"),ue=Symbol("bufferLength"),Wu=Symbol("bufferPush"),Ga=Symbol("bufferShift"),Qe=Symbol("objectMode"),se=Symbol("destroyed"),ju=Symbol("error"),zu=Symbol("emitData"),BI=Symbol("emitEnd"),Zu=Symbol("emitEnd2"),vt=Symbol("async"),Ku=Symbol("abort"),Ma=Symbol("aborted"),Ao=Symbol("signal"),Ws=Symbol("dataListeners"),Pe=Symbol("discarded"),co=e=>Promise.resolve().then(e),e_=e=>e(),t_=e=>e==="end"||e==="finish"||e==="prefinish",s_=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,r_=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),KI=class{src;dest;opts;ondrain;constructor(e,t,s){this.src=e,this.dest=t,this.opts=s,this.ondrain=()=>e[Kr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},i_=class extends KI{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,s){super(e,t,s),this.proxyErrors=r=>this.dest.emit("error",r),e.on("error",this.proxyErrors)}},o_=e=>!!e.objectMode,n_=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",Ha=class extends qa.EventEmitter{[ce]=!1;[ao]=!1;[we]=[];[le]=[];[Qe];[pt];[vt];[Zr];[Vt]=!1;[Es]=!1;[Sa]=!1;[Ua]=!1;[no]=null;[ue]=0;[se]=!1;[Ao];[Ma]=!1;[Ws]=0;[Pe]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");o_(t)?(this[Qe]=!0,this[pt]=null):n_(t)?(this[pt]=t.encoding,this[Qe]=!1):(this[Qe]=!1,this[pt]=null),this[vt]=!!t.async,this[Zr]=this[pt]?new ZI.StringDecoder(this[pt]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[le]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[we]});let{signal:s}=t;s&&(this[Ao]=s,s.aborted?this[Ku]():s.addEventListener("abort",()=>this[Ku]()))}get bufferLength(){return this[ue]}get encoding(){return this[pt]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Qe]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[vt]}set async(e){this[vt]=this[vt]||!!e}[Ku](){this[Ma]=!0,this.emit("abort",this[Ao]?.reason),this.destroy(this[Ao]?.reason)}get aborted(){return this[Ma]}set aborted(e){}write(e,t,s){if(this[Ma])return!1;if(this[Vt])throw new Error("write after end");if(this[se])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(s=t,t="utf8"),t||(t="utf8");let r=this[vt]?co:e_;if(!this[Qe]&&!Buffer.isBuffer(e)){if(r_(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(s_(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Qe]?(this[ce]&&this[ue]!==0&&this[Na](!0),this[ce]?this.emit("data",e):this[Wu](e),this[ue]!==0&&this.emit("readable"),s&&r(s),this[ce]):e.length?(typeof e=="string"&&!(t===this[pt]&&!this[Zr]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[pt]&&(e=this[Zr].write(e)),this[ce]&&this[ue]!==0&&this[Na](!0),this[ce]?this.emit("data",e):this[Wu](e),this[ue]!==0&&this.emit("readable"),s&&r(s),this[ce]):(this[ue]!==0&&this.emit("readable"),s&&r(s),this[ce])}read(e){if(this[se])return null;if(this[Pe]=!1,this[ue]===0||e===0||e&&e>this[ue])return this[qt](),null;this[Qe]&&(e=null),this[le].length>1&&!this[Qe]&&(this[le]=[this[pt]?this[le].join(""):Buffer.concat(this[le],this[ue])]);let t=this[fI](e||null,this[le][0]);return this[qt](),t}[fI](e,t){if(this[Qe])this[Ga]();else{let s=t;e===s.length||e===null?this[Ga]():typeof s=="string"?(this[le][0]=s.slice(e),t=s.slice(0,e),this[ue]-=e):(this[le][0]=s.subarray(e),t=s.subarray(0,e),this[ue]-=e)}return this.emit("data",t),!this[le].length&&!this[Vt]&&this.emit("drain"),t}end(e,t,s){return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t="utf8"),e!==void 0&&this.write(e,t),s&&this.once("end",s),this[Vt]=!0,this.writable=!1,(this[ce]||!this[ao])&&this[qt](),this}[Kr](){this[se]||(!this[Ws]&&!this[we].length&&(this[Pe]=!0),this[ao]=!1,this[ce]=!0,this.emit("resume"),this[le].length?this[Na]():this[Vt]?this[qt]():this.emit("drain"))}resume(){return this[Kr]()}pause(){this[ce]=!1,this[ao]=!0,this[Pe]=!1}get destroyed(){return this[se]}get flowing(){return this[ce]}get paused(){return this[ao]}[Wu](e){this[Qe]?this[ue]+=1:this[ue]+=e.length,this[le].push(e)}[Ga](){return this[Qe]?this[ue]-=1:this[ue]-=this[le][0].length,this[le].shift()}[Na](e=!1){do;while(this[QI](this[Ga]())&&this[le].length);!e&&!this[le].length&&!this[Vt]&&this.emit("drain")}[QI](e){return this.emit("data",e),this[ce]}pipe(e,t){if(this[se])return e;this[Pe]=!1;let s=this[Es];return t=t||{},e===mI.stdout||e===mI.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,s?t.end&&e.end():(this[we].push(t.proxyErrors?new i_(this,e,t):new KI(this,e,t)),this[vt]?co(()=>this[Kr]()):this[Kr]()),e}unpipe(e){let t=this[we].find(s=>s.dest===e);t&&(this[we].length===1?(this[ce]&&this[Ws]===0&&(this[ce]=!1),this[we]=[]):this[we].splice(this[we].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let s=super.on(e,t);if(e==="data")this[Pe]=!1,this[Ws]++,!this[we].length&&!this[ce]&&this[Kr]();else if(e==="readable"&&this[ue]!==0)super.emit("readable");else if(t_(e)&&this[Es])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[no]){let r=t;this[vt]?co(()=>r.call(this,this[no])):r.call(this,this[no])}return s}removeListener(e,t){return this.off(e,t)}off(e,t){let s=super.off(e,t);return e==="data"&&(this[Ws]=this.listeners("data").length,this[Ws]===0&&!this[Pe]&&!this[we].length&&(this[ce]=!1)),s}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Ws]=0,!this[Pe]&&!this[we].length&&(this[ce]=!1)),t}get emittedEnd(){return this[Es]}[qt](){!this[Sa]&&!this[Es]&&!this[se]&&this[le].length===0&&this[Vt]&&(this[Sa]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ua]&&this.emit("close"),this[Sa]=!1)}emit(e,...t){let s=t[0];if(e!=="error"&&e!=="close"&&e!==se&&this[se])return!1;if(e==="data")return!this[Qe]&&!s?!1:this[vt]?(co(()=>this[zu](s)),!0):this[zu](s);if(e==="end")return this[BI]();if(e==="close"){if(this[Ua]=!0,!this[Es]&&!this[se])return!1;let i=super.emit("close");return this.removeAllListeners("close"),i}else if(e==="error"){this[no]=s,super.emit(ju,s);let i=!this[Ao]||this.listeners("error").length?super.emit("error",s):!1;return this[qt](),i}else if(e==="resume"){let i=super.emit("resume");return this[qt](),i}else if(e==="finish"||e==="prefinish"){let i=super.emit(e);return this.removeAllListeners(e),i}let r=super.emit(e,...t);return this[qt](),r}[zu](e){for(let s of this[we])s.dest.write(e)===!1&&this.pause();let t=this[Pe]?!1:super.emit("data",e);return this[qt](),t}[BI](){return this[Es]?!1:(this[Es]=!0,this.readable=!1,this[vt]?(co(()=>this[Zu]()),!0):this[Zu]())}[Zu](){if(this[Zr]){let t=this[Zr].end();if(t){for(let s of this[we])s.dest.write(t);this[Pe]||super.emit("data",t)}}for(let t of this[we])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[Qe]||(e.dataLength=0);let t=this.promise();return this.on("data",s=>{e.push(s),this[Qe]||(e.dataLength+=s.length)}),await t,e}async concat(){if(this[Qe])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[pt]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(se,()=>t(new Error("stream destroyed"))),this.on("error",s=>t(s)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Pe]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let s=this.read();if(s!==null)return Promise.resolve({done:!1,value:s});if(this[Vt])return t();let r,i,o=c=>{this.off("data",n),this.off("end",a),this.off(se,A),t(),i(c)},n=c=>{this.off("error",o),this.off("end",a),this.off(se,A),this.pause(),r({value:c,done:!!this[Vt]})},a=()=>{this.off("error",o),this.off("data",n),this.off(se,A),t(),r({done:!0,value:void 0})},A=()=>o(new Error("stream destroyed"));return new Promise((c,u)=>{i=u,r=c,this.once(se,A),this.once("error",o),this.once("end",a),this.once("data",n)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Pe]=!1;let e=!1,t=()=>(this.pause(),this.off(ju,t),this.off(se,t),this.off("end",t),e=!0,{done:!0,value:void 0}),s=()=>{if(e)return t();let r=this.read();return r===null?t():{done:!1,value:r}};return this.once("end",t),this.once(ju,t),this.once(se,t),{next:s,throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[se])return e?this.emit("error",e):this.emit(se),this;this[se]=!0,this[Pe]=!0,this[le].length=0,this[ue]=0;let t=this;return typeof t.close=="function"&&!this[Ua]&&t.close(),e?this.emit("error",e):this.emit(se),this}static get isStream(){return KL}},a_=Dt.realpathSync.native,go={lstatSync:Dt.lstatSync,readdir:Dt.readdir,readdirSync:Dt.readdirSync,readlinkSync:Dt.readlinkSync,realpathSync:a_,promises:{lstat:Qs.lstat,readdir:Qs.readdir,readlink:Qs.readlink,realpath:Qs.realpath}},XI=e=>!e||e===go||e===ZL?go:{...go,...e,promises:{...go.promises,...e.promises||{}}},$I=/^\\\\\?\\([a-z]:)\\?$/i,A_=e=>e.replace(/\//g,"\\").replace($I,"$1\\"),c_=/[\\\/]/,tt=0,ew=1,tw=2,kt=4,sw=6,rw=8,js=10,iw=12,et=15,lo=~et,Xu=16,CI=32,ho=64,gt=128,La=256,Oa=512,II=ho|gt|Oa,l_=1023,$u=e=>e.isFile()?rw:e.isDirectory()?kt:e.isSymbolicLink()?js:e.isCharacterDevice()?tw:e.isBlockDevice()?sw:e.isSocket()?iw:e.isFIFO()?ew:tt,wI=new Va({max:2**12}),Eo=e=>{let t=wI.get(e);if(t)return t;let s=e.normalize("NFKD");return wI.set(e,s),s},bI=new Va({max:2**12}),_a=e=>{let t=bI.get(e);if(t)return t;let s=Eo(e.toLowerCase());return bI.set(e,s),s},yI=class extends Va{constructor(){super({max:256})}},u_=class extends Va{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1})}},ow=Symbol("PathScurry setAsCwd"),Se=class{name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#i;get mode(){return this.#i}#s;get nlink(){return this.#s}#r;get uid(){return this.#r}#A;get gid(){return this.#A}#a;get rdev(){return this.#a}#c;get blksize(){return this.#c}#l;get ino(){return this.#l}#g;get size(){return this.#g}#h;get blocks(){return this.#h}#u;get atimeMs(){return this.#u}#n;get mtimeMs(){return this.#n}#d;get ctimeMs(){return this.#d}#C;get birthtimeMs(){return this.#C}#B;get atime(){return this.#B}#E;get mtime(){return this.#E}#k;get ctime(){return this.#k}#m;get birthtime(){return this.#m}#b;#y;#f;#Q;#I;#x;#o;#U;#F;#v;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=tt,s,r,i,o,n){this.name=e,this.#b=i?_a(e):Eo(e),this.#o=t&l_,this.nocase=i,this.roots=r,this.root=s||this,this.#U=o,this.#f=n.fullpath,this.#I=n.relative,this.#x=n.relativePosix,this.parent=n.parent,this.parent?this.#e=this.parent.#e:this.#e=XI(n.fs)}depth(){return this.#y!==void 0?this.#y:this.parent?this.#y=this.parent.depth()+1:this.#y=0}childrenCache(){return this.#U}resolve(e){if(!e)return this;let t=this.getRootString(e),s=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#S(s):this.#S(s)}#S(e){let t=this;for(let s of e)t=t.child(s);return t}children(){let e=this.#U.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#U.set(this,t),this.#o&=~Xu,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),r=this.nocase?_a(e):Eo(e);for(let a of s)if(a.#b===r)return a;let i=this.parent?this.sep:"",o=this.#f?this.#f+i+e:void 0,n=this.newChild(e,tt,{...t,parent:this,fullpath:o});return this.canReaddir()||(n.#o|=gt),s.push(n),n}relative(){if(this.isCWD)return"";if(this.#I!==void 0)return this.#I;let e=this.name,t=this.parent;if(!t)return this.#I=this.name;let s=t.relative();return s+(!s||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let e=this.name,t=this.parent;if(!t)return this.#x=this.fullpathPosix();let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(this.#f!==void 0)return this.#f;let e=this.name,t=this.parent;if(!t)return this.#f=this.name;let s=t.fullpath()+(t.parent?this.sep:"")+e;return this.#f=s}fullpathPosix(){if(this.#Q!==void 0)return this.#Q;if(this.sep==="/")return this.#Q=this.fullpath();if(!this.parent){let r=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(r)?this.#Q=`//?/${r}`:this.#Q=r}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return this.#Q=s}isUnknown(){return(this.#o&et)===tt}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#o&et)===rw}isDirectory(){return(this.#o&et)===kt}isCharacterDevice(){return(this.#o&et)===tw}isBlockDevice(){return(this.#o&et)===sw}isFIFO(){return(this.#o&et)===ew}isSocket(){return(this.#o&et)===iw}isSymbolicLink(){return(this.#o&js)===js}lstatCached(){return this.#o&CI?this:void 0}readlinkCached(){return this.#F}realpathCached(){return this.#v}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#F)return!0;if(!this.parent)return!1;let e=this.#o&et;return!(e!==tt&&e!==js||this.#o&La||this.#o>)}calledReaddir(){return!!(this.#o&Xu)}isENOENT(){return!!(this.#o>)}isNamed(e){return this.nocase?this.#b===_a(e):this.#b===Eo(e)}async readlink(){let e=this.#F;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#e.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return this.#F=s}catch(t){this.#T(t.code);return}}readlinkSync(){let e=this.#F;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#e.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return this.#F=s}catch(t){this.#T(t.code);return}}#L(e){this.#o|=Xu;for(let t=e.provisional;ts(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let s=this.children();if(this.calledReaddir()){let i=s.slice(0,s.provisional);t?e(null,i):queueMicrotask(()=>e(null,i));return}if(this.#G.push(e),this.#D)return;this.#D=!0;let r=this.fullpath();this.#e.readdir(r,{withFileTypes:!0},(i,o)=>{if(i)this.#_(i.code),s.provisional=0;else{for(let n of o)this.#Y(n,s);this.#L(s)}this.#V(s.slice(0,s.provisional))})}#q;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#q)await this.#q;else{let s=()=>{};this.#q=new Promise(r=>s=r);try{for(let r of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#Y(r,e);this.#L(e)}catch(r){this.#_(r.code),e.provisional=0}this.#q=void 0,s()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let s of this.#e.readdirSync(t,{withFileTypes:!0}))this.#Y(s,e);this.#L(e)}catch(s){this.#_(s.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#o&II)return!1;let e=et&this.#o;return e===tt||e===kt||e===js}shouldWalk(e,t){return(this.#o&kt)===kt&&!(this.#o&II)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#v)return this.#v;if(!((Oa|La|gt)&this.#o))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#v=this.resolve(e)}catch{this.#M()}}realpathSync(){if(this.#v)return this.#v;if(!((Oa|La|gt)&this.#o))try{let e=this.#e.realpathSync(this.fullpath());return this.#v=this.resolve(e)}catch{this.#M()}}[ow](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),s=[],r=this;for(;r&&r.parent;)t.add(r),r.#I=s.join(this.sep),r.#x=s.join("/"),r=r.parent,s.push("..");for(r=e;r&&r.parent&&!t.has(r);)r.#I=void 0,r.#x=void 0,r=r.parent}},nw=class aw extends Se{sep="\\";splitSep=c_;constructor(t,s=tt,r,i,o,n,a){super(t,s,r,i,o,n,a)}newChild(t,s=tt,r={}){return new aw(t,s,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(t){return $r.win32.parse(t).root}getRoot(t){if(t=A_(t.toUpperCase()),t===this.root.name)return this.root;for(let[s,r]of Object.entries(this.roots))if(this.sameRoot(t,s))return this.roots[t]=r;return this.roots[t]=new ip(t,this).root}sameRoot(t,s=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace($I,"$1\\"),t===s}},Aw=class cw extends Se{splitSep="/";sep="/";constructor(t,s=tt,r,i,o,n,a){super(t,s,r,i,o,n,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,s=tt,r={}){return new cw(t,s,this.root,this.roots,this.nocase,this.childrenCache(),r)}},lw=class{root;rootPath;roots;cwd;#e;#t;#i;nocase;#s;constructor(e=process.cwd(),t,s,{nocase:r,childrenCacheSize:i=16*1024,fs:o=go}={}){this.#s=XI(o),(e instanceof URL||e.startsWith("file://"))&&(e=(0,zI.fileURLToPath)(e));let n=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(n),this.#e=new yI,this.#t=new yI,this.#i=new u_(i);let a=n.substring(this.rootPath.length).split(s);if(a.length===1&&!a[0]&&a.pop(),r===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=r,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let A=this.root,c=a.length-1,u=t.sep,l=this.rootPath,p=!1;for(let g of a){let h=c--;A=A.child(g,{relative:new Array(h).fill("..").join(u),relativePosix:new Array(h).fill("..").join("/"),fullpath:l+=(p?"":u)+g}),p=!0}this.cwd=A}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#i}resolve(...e){let t="";for(let i=e.length-1;i>=0;i--){let o=e[i];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#e.get(t);if(s!==void 0)return s;let r=this.cwd.resolve(t).fullpath();return this.#e.set(t,r),r}resolvePosix(...e){let t="";for(let i=e.length-1;i>=0;i--){let o=e[i];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#t.get(t);if(s!==void 0)return s;let r=this.cwd.resolve(t).fullpathPosix();return this.#t.set(t,r),r}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s}=t;if(e.canReaddir()){let r=await e.readdir();return s?r:r.map(i=>i.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0}=t;return e.canReaddir()?s?e.readdirSync():e.readdirSync().map(r=>r.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=await e.readlink();return t?s:s?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=e.readlinkSync();return t?s:s?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=await e.realpath();return t?s:s?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=e.realpathSync();return t?s:s?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=[];(!i||i(e))&&n.push(s?e:e.fullpath());let a=new Set,A=(u,l)=>{a.add(u),u.readdirCB((p,g)=>{if(p)return l(p);let h=g.length;if(!h)return l();let E=()=>{--h===0&&l()};for(let m of g)(!i||i(m))&&n.push(s?m:m.fullpath()),r&&m.isSymbolicLink()?m.realpath().then(d=>d?.isUnknown()?d.lstat():d).then(d=>d?.shouldWalk(a,o)?A(d,E):E()):m.shouldWalk(a,o)?A(m,E):E()},!0)},c=e;return new Promise((u,l)=>{A(c,p=>{if(p)return l(p);u(n)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=[];(!i||i(e))&&n.push(s?e:e.fullpath());let a=new Set([e]);for(let A of a){let c=A.readdirSync();for(let u of c){(!i||i(u))&&n.push(s?u:u.fullpath());let l=u;if(u.isSymbolicLink()){if(!(r&&(l=u.realpathSync())))continue;l.isUnknown()&&l.lstatSync()}l.shouldWalk(a,o)&&a.add(l)}}return n}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t;(!i||i(e))&&(yield s?e:e.fullpath());let n=new Set([e]);for(let a of n){let A=a.readdirSync();for(let c of A){(!i||i(c))&&(yield s?c:c.fullpath());let u=c;if(c.isSymbolicLink()){if(!(r&&(u=c.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(n,o)&&n.add(u)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=new Ha({objectMode:!0});(!i||i(e))&&n.write(s?e:e.fullpath());let a=new Set,A=[e],c=0,u=()=>{let l=!1;for(;!l;){let p=A.shift();if(!p){c===0&&n.end();return}c++,a.add(p);let g=(E,m,d=!1)=>{if(E)return n.emit("error",E);if(r&&!d){let f=[];for(let C of m)C.isSymbolicLink()&&f.push(C.realpath().then(B=>B?.isUnknown()?B.lstat():B));if(f.length){Promise.all(f).then(()=>g(null,m,!0));return}}for(let f of m)f&&(!i||i(f))&&(n.write(s?f:f.fullpath())||(l=!0));c--;for(let f of m){let C=f.realpathCached()||f;C.shouldWalk(a,o)&&A.push(C)}l&&!n.flowing?n.once("drain",u):h||u()},h=!0;p.readdirCB(g,!0),h=!1}};return u(),n}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=new Ha({objectMode:!0}),a=new Set;(!i||i(e))&&n.write(s?e:e.fullpath());let A=[e],c=0,u=()=>{let l=!1;for(;!l;){let p=A.shift();if(!p){c===0&&n.end();return}c++,a.add(p);let g=p.readdirSync();for(let h of g)(!i||i(h))&&(n.write(s?h:h.fullpath())||(l=!0));c--;for(let h of g){let E=h;if(h.isSymbolicLink()){if(!(r&&(E=h.realpathSync())))continue;E.isUnknown()&&E.lstatSync()}E.shouldWalk(a,o)&&A.push(E)}}l&&!n.flowing&&n.once("drain",u)};return u(),n}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[ow](t)}},ip=class extends lw{sep="\\";constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,$r.win32,"\\",{...t,nocase:s}),this.nocase=s;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase}parseRootPath(e){return $r.win32.parse(e).root.toUpperCase()}newRoot(e){return new nw(this.rootPath,kt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},op=class extends lw{sep="/";constructor(e=process.cwd(),t={}){let{nocase:s=!1}=t;super(e,$r.posix,"/",{...t,nocase:s}),this.nocase=s}parseRootPath(e){return"/"}newRoot(e){return new Aw(this.rootPath,kt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},uw=class extends op{constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,{...t,nocase:s})}},JJ=process.platform==="win32"?nw:Aw,p_=process.platform==="win32"?ip:process.platform==="darwin"?uw:op,g_=e=>e.length>=1,h_=e=>e.length>=1,d_=Symbol.for("nodejs.util.inspect.custom"),pw=class gw{#e;#t;#i;length;#s;#r;#A;#a;#c;#l;#g=!0;constructor(t,s,r,i){if(!g_(t))throw new TypeError("empty pattern list");if(!h_(s))throw new TypeError("empty glob list");if(s.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,r<0||r>=this.length)throw new TypeError("index out of range");if(this.#e=t,this.#t=s,this.#i=r,this.#s=i,this.#i===0){if(this.isUNC()){let[o,n,a,A,...c]=this.#e,[u,l,p,g,...h]=this.#t;c[0]===""&&(c.shift(),h.shift());let E=[o,n,a,A,""].join("/"),m=[u,l,p,g,""].join("/");this.#e=[E,...c],this.#t=[m,...h],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[o,...n]=this.#e,[a,...A]=this.#t;n[0]===""&&(n.shift(),A.shift());let c=o+"/",u=a+"/";this.#e=[c,...n],this.#t=[u,...A],this.length=this.#e.length}}}[d_](){return"Pattern <"+this.#t.slice(this.#i).join("/")+">"}pattern(){return this.#e[this.#i]}isString(){return typeof this.#e[this.#i]=="string"}isGlobstar(){return this.#e[this.#i]===be}isRegExp(){return this.#e[this.#i]instanceof RegExp}globString(){return this.#A=this.#A||(this.#i===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join("/"):this.#t.join("/"):this.#t.slice(this.#i).join("/"))}hasMore(){return this.length>this.#i+1}rest(){return this.#r!==void 0?this.#r:this.hasMore()?(this.#r=new gw(this.#e,this.#t,this.#i+1,this.#s),this.#r.#l=this.#l,this.#r.#c=this.#c,this.#r.#a=this.#a,this.#r):this.#r=null}isUNC(){let t=this.#e;return this.#c!==void 0?this.#c:this.#c=this.#s==="win32"&&this.#i===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#e;return this.#a!==void 0?this.#a:this.#a=this.#s==="win32"&&this.#i===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#e;return this.#l!==void 0?this.#l:this.#l=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#e[0];return typeof t=="string"&&this.isAbsolute()&&this.#i===0?t:""}checkFollowGlobstar(){return!(this.#i===0||!this.isGlobstar()||!this.#g)}markFollowGlobstar(){return this.#i===0||!this.isGlobstar()||!this.#g?!1:(this.#g=!1,!0)}},E_=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",xI=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:s,noext:r,noglobstar:i,platform:o=E_}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:t,nocase:s,noext:r,noglobstar:i,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let n of e)this.add(n)}add(e){let t=new fs(e,this.mmopts);for(let s=0;s[e,!!(t&2),!!(t&1)])}},Q_=class{store=new Map;add(e,t){if(!e.canReaddir())return;let s=this.store.get(e);s?s.find(r=>r.globString()===t.globString())||s.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},vI=class dw{hasWalkedCache;matches=new f_;subwalks=new Q_;patterns;follow;dot;opts;constructor(t,s){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=s?s.copy():new m_}processPatterns(t,s){this.patterns=s;let r=s.map(i=>[t,i]);for(let[i,o]of r){this.hasWalkedCache.storeWalked(i,o);let n=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(n){i=i.resolve(n==="/"&&this.opts.root!==void 0?this.opts.root:n);let l=o.rest();if(l)o=l;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let A,c,u=!1;for(;typeof(A=o.pattern())=="string"&&(c=o.rest());)i=i.resolve(A),o=c,u=!0;if(A=o.pattern(),c=o.rest(),u){if(this.hasWalkedCache.hasWalked(i,o))continue;this.hasWalkedCache.storeWalked(i,o)}if(typeof A=="string"){let l=A===".."||A===""||A===".";this.matches.add(i.resolve(A),a,l);continue}else if(A===be){(!i.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(i,o);let l=c?.pattern(),p=c?.rest();if(!c||(l===""||l===".")&&!p)this.matches.add(i,a,l===""||l===".");else if(l===".."){let g=i.parent||i;p?this.hasWalkedCache.hasWalked(g,p)||this.subwalks.add(g,p):this.matches.add(g,a,!0)}}else A instanceof RegExp&&this.subwalks.add(i,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new dw(this.opts,this.hasWalkedCache)}filterEntries(t,s){let r=this.subwalks.get(t),i=this.child();for(let o of s)for(let n of r){let a=n.isAbsolute(),A=n.pattern(),c=n.rest();A===be?i.testGlobstar(o,n,c,a):A instanceof RegExp?i.testRegExp(o,A,c,a):i.testString(o,A,c,a)}return i}testGlobstar(t,s,r,i){if((this.dot||!t.name.startsWith("."))&&(s.hasMore()||this.matches.add(t,i,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,s):t.isSymbolicLink()&&(r&&s.checkFollowGlobstar()?this.subwalks.add(t,r):s.markFollowGlobstar()&&this.subwalks.add(t,s)))),r){let o=r.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,r.rest(),i);else if(o===".."){let n=t.parent||t;this.subwalks.add(n,r)}else o instanceof RegExp&&this.testRegExp(t,o,r.rest(),i)}}testRegExp(t,s,r,i){s.test(t.name)&&(r?this.subwalks.add(t,r):this.matches.add(t,i,!1))}testString(t,s,r,i){t.isNamed(s)&&(r?this.subwalks.add(t,r):this.matches.add(t,i,!1))}},B_=(e,t)=>typeof e=="string"?new xI([e],t):Array.isArray(e)?new xI(e,t):e,Ew=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#t;#i;signal;maxDepth;includeChildMatches;constructor(e,t,s){if(this.patterns=e,this.path=t,this.opts=s,this.#i=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#t=B_(s.ignore??[],s),!this.includeChildMatches&&typeof this.#t.add!="function")){let r="cannot ignore child matches, ignore lacks add() method.";throw new Error(r)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#s(e){return this.seen.has(e)||!!this.#t?.ignored?.(e)}#r(e){return!!this.#t?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||await e.realpath(),!s)return;e=s}let r=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let i=await r.realpath();i&&(i.isUnknown()||this.opts.stat)&&await i.lstat()}return this.matchCheckTest(r,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#s(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||e.realpathSync(),!s)return;e=s}let r=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let i=r.realpathSync();i&&(i?.isUnknown()||this.opts.stat)&&i.lstatSync()}return this.matchCheckTest(r,t)}matchFinish(e,t){if(this.#s(e))return;if(!this.includeChildMatches&&this.#t?.add){let i=`${e.relativePosix()}/**`;this.#t.add(i)}let s=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let r=this.opts.mark&&e.isDirectory()?this.#i:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(s){let i=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(i+r)}else{let i=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!i.startsWith(".."+this.#i)?"."+this.#i:"";this.matchEmit(i?o+i+r:"."+r)}}async match(e,t,s){let r=await this.matchCheck(e,s);r&&this.matchFinish(r,t)}matchSync(e,t,s){let r=this.matchCheckSync(e,s);r&&this.matchFinish(r,t)}walkCB(e,t,s){this.signal?.aborted&&s(),this.walkCB2(e,t,new vI(this.opts),s)}walkCB2(e,t,s,r){if(this.#r(e))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2(e,t,s,r));return}s.processPatterns(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||(i++,this.match(n,a,A).then(()=>o()));for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;i++;let a=n.readdirCached();n.calledReaddir()?this.walkCB3(n,a,s,o):n.readdirCB((A,c)=>this.walkCB3(n,c,s,o),!0)}o()}walkCB3(e,t,s,r){s=s.filterEntries(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||(i++,this.match(n,a,A).then(()=>o()));for(let[n,a]of s.subwalks.entries())i++,this.walkCB2(n,a,s.child(),o);o()}walkCBSync(e,t,s){this.signal?.aborted&&s(),this.walkCB2Sync(e,t,new vI(this.opts),s)}walkCB2Sync(e,t,s,r){if(this.#r(e))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,s,r));return}s.processPatterns(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||this.matchSync(n,a,A);for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;i++;let a=n.readdirSync();this.walkCB3Sync(n,a,s,o)}o()}walkCB3Sync(e,t,s,r){s=s.filterEntries(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||this.matchSync(n,a,A);for(let[n,a]of s.subwalks.entries())i++,this.walkCB2Sync(n,a,s.child(),o);o()}},kI=class extends Ew{matches=new Set;constructor(e,t,s){super(e,t,s)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},DI=class extends Ew{results;constructor(e,t,s){super(e,t,s),this.results=new Ha({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},C_=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",zs=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,HI.fileURLToPath)(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(a=>a.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(a=>a.includes("/")?a:`./**/${a}`)}if(this.pattern=e,this.platform=t.platform||C_,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let a=t.platform==="win32"?ip:t.platform==="darwin"?uw:t.platform?op:p_;this.scurry=new a(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",r={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},i=this.pattern.map(a=>new fs(a,r)),[o,n]=i.reduce((a,A)=>(a[0].push(...A.set),a[1].push(...A.globParts),a),[[],[]]);this.patterns=o.map((a,A)=>{let c=n[A];if(!c)throw new Error("invalid pattern object");return new pw(a,c,0,this.platform)})}async walk(){return[...await new kI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new kI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new DI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new DI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},I_=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new fs(s,t).hasMagic())return!0;return!1};function Wa(e,t={}){return new zs(e,t).streamSync()}function mw(e,t={}){return new zs(e,t).stream()}function fw(e,t={}){return new zs(e,t).walkSync()}async function RI(e,t={}){return new zs(e,t).walk()}function ja(e,t={}){return new zs(e,t).iterateSync()}function Qw(e,t={}){return new zs(e,t).iterate()}var w_=Wa,b_=Object.assign(mw,{sync:Wa}),y_=ja,x_=Object.assign(Qw,{sync:ja}),za=Object.assign(fw,{stream:Wa,iterate:ja}),TI=Object.assign(RI,{glob:RI,globSync:fw,sync:za,globStream:mw,stream:b_,globStreamSync:Wa,streamSync:w_,globIterate:Qw,iterate:x_,globIterateSync:ja,iterateSync:y_,Glob:zs,hasMagic:I_,escape:_I,unescape:Xr});TI.glob=TI;var mo=require("fs"),np=require("os"),Zs=de(require("path")),Bw=e=>{let t=e.indexOf("{");return t>-1?e.substring(0,t):e},ap=e=>{if(e.input_body_path)try{return(0,mo.readFileSync)(e.input_body_path,"utf8")}catch(t){console.warn(`\u26A0\uFE0F Failed to read body_path "${e.input_body_path}" (${t?.code??"ERR"}). Falling back to 'body' input.`)}return e.input_body},k_=e=>{let t=[],s="",r=0;for(let i of e)i==="{"&&r++,i==="}"&&r--,i===","&&r===0?(s.trim()&&t.push(s.trim()),s=""):s+=i;return s.trim()&&t.push(s.trim()),t},D_=e=>e.split(/\r?\n/).flatMap(t=>k_(t)).filter(t=>t.trim()!==""),R_=e=>{let t=e.INPUT_TOKEN?.trim();return t||e.GITHUB_TOKEN?.trim()||""},Cw=e=>({github_token:R_(e),github_ref:e.GITHUB_REF||"",github_repository:e.INPUT_REPOSITORY||e.GITHUB_REPOSITORY||"",input_name:e.INPUT_NAME,input_tag_name:Ap(e.INPUT_TAG_NAME?.trim()),input_body:e.INPUT_BODY,input_body_path:e.INPUT_BODY_PATH,input_files:D_(e.INPUT_FILES||""),input_working_directory:e.INPUT_WORKING_DIRECTORY||void 0,input_overwrite_files:e.INPUT_OVERWRITE_FILES?e.INPUT_OVERWRITE_FILES=="true":void 0,input_draft:e.INPUT_DRAFT?e.INPUT_DRAFT==="true":void 0,input_preserve_order:e.INPUT_PRESERVE_ORDER?e.INPUT_PRESERVE_ORDER=="true":void 0,input_prerelease:e.INPUT_PRERELEASE?e.INPUT_PRERELEASE=="true":void 0,input_fail_on_unmatched_files:e.INPUT_FAIL_ON_UNMATCHED_FILES=="true",input_target_commitish:e.INPUT_TARGET_COMMITISH||void 0,input_discussion_category_name:e.INPUT_DISCUSSION_CATEGORY_NAME||void 0,input_generate_release_notes:e.INPUT_GENERATE_RELEASE_NOTES=="true",input_append_body:e.INPUT_APPEND_BODY=="true",input_make_latest:T_(e.INPUT_MAKE_LATEST)}),T_=e=>{if(e==="true"||e==="false"||e==="legacy")return e},F_=(e,t=process.platform)=>t==="win32"?e.replace(/\\/g,"/"):e,S_=(e,t=(0,np.homedir)())=>e==="~"?t:e.startsWith("~/")||e.startsWith("~\\")?Zs.join(t,e.slice(2)):e,Iw=(e,t=process.platform,s=(0,np.homedir)())=>F_(S_(e,s),t),ww=(e,t)=>e.reduce((s,r)=>{let o=za(Iw(r),{cwd:t,dot:!0,absolute:!1}).map(n=>t&&!Zs.isAbsolute(n)?Zs.join(t,n):n).filter(n=>{try{return(0,mo.statSync)(n).isFile()}catch{return!1}});return s.concat(o)},[]),bw=(e,t)=>e.reduce((s,r)=>{let o=za(Iw(r),{cwd:t,dot:!0,absolute:!1}).filter(n=>{try{let a=t&&!Zs.isAbsolute(n)?Zs.join(t,n):n;return(0,mo.statSync)(a).isFile()}catch{return!1}});return s.concat(o.length==0?[r]:[])},[]),fo=e=>e.startsWith("refs/tags/"),Ap=e=>e&&(fo(e)?e.replace("refs/tags/",""):e),cp=e=>e.replace(/ /g,".");var Za=class{github;constructor(t){this.github=t}getReleaseByTag(t){return this.github.rest.repos.getReleaseByTag(t)}async getReleaseNotes(t){return await this.github.rest.repos.generateReleaseNotes(t)}truncateReleaseNotes(t){return t.substring(0,124999)}async createRelease(t){if(typeof t.make_latest=="string"&&!["true","false","legacy"].includes(t.make_latest)&&(t.make_latest=void 0),t.generate_release_notes){let s=await this.getReleaseNotes(t);t.generate_release_notes=!1,t.body?t.body=`${t.body} +>>> no match, partial?`,e,l,t,p),l===a))}let h;if(typeof c=="string"?(h=u===c,this.debug("string match",c,u,h)):(h=c.test(u),this.debug("pattern match",c,u,h)),!h)return!1}if(o===a&&n===A)return!0;if(o===a)return s;if(n===A)return o===a-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return PI(this.pattern,this.options)}parse(e){Ja(e);let t=this.options;if(e==="**")return be;if(e==="")return"";let s,r=null;(s=e.match(DL))?r=t.dot?TL:RL:(s=e.match(QL))?r=(t.nocase?t.dot?wL:IL:t.dot?CL:BL)(s[1]):(s=e.match(FL))?r=(t.nocase?t.dot?UL:SL:t.dot?NL:GL)(s):(s=e.match(bL))?r=t.dot?xL:yL:(s=e.match(vL))&&(r=kL);let i=LI.fromGlob(e,this.options).toMMPattern();return r&&typeof i=="object"&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,s=t.noglobstar?_L:t.dot?YL:OL,r=new Set(t.nocase?["i"]:[]),i=e.map(a=>{let A=a.map(u=>{if(u instanceof RegExp)for(let l of u.flags.split(""))r.add(l);return typeof u=="string"?qL(u):u===be?be:u._src});A.forEach((u,l)=>{let p=A[l+1],g=A[l-1];u!==be||g===be||(g===void 0?p!==void 0&&p!==be?A[l+1]="(?:\\/|"+s+"\\/)?"+p:A[l]=s:p===void 0?A[l-1]=g+"(?:\\/|\\/"+s+")?":p!==be&&(A[l-1]=g+"(?:\\/|\\/"+s+"\\/)"+p,A[l+1]=be))});let c=A.filter(u=>u!==be);if(this.partial&&c.length>=1){let u=[];for(let l=1;l<=c.length;l++)u.push(c.slice(0,l).join("/"));return"(?:"+u.join("|")+")"}return c.join("/")}).join("|"),[o,n]=e.length>1?["(?:",")"]:["",""];i="^"+o+i+n+"$",this.partial&&(i="^(?:\\/|"+o+i.slice(1,-1)+n+")$"),this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let s=this.options;this.isWindows&&(e=e.split("\\").join("/"));let r=this.slashSplit(e);this.debug(this.pattern,"split",r);let i=this.set;this.debug(this.pattern,"set",i);let o=r[r.length-1];if(!o)for(let n=r.length-2;!o&&n>=0;n--)o=r[n];for(let n=0;n{typeof ep.emitWarning=="function"?ep.emitWarning(e,t,s,r):console.error(`[${s}] ${t}: ${e}`)},Pa=globalThis.AbortController,EI=globalThis.AbortSignal;if(typeof Pa>"u"){EI=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,r){this._onabort.push(r)}},Pa=class{constructor(){t()}signal=new EI;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s)}}};let e=ep.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,qI("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var jL=e=>!VI.has(e),ms=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),WI=e=>ms(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Ya:null:null,Ya=class extends Array{constructor(e){super(e),this.fill(0)}},zL=class po{heap;length;static#e=!1;static create(t){let s=WI(t);if(!s)return[];po.#e=!0;let r=new po(t,s);return po.#e=!1,r}constructor(t,s){if(!po.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},Va=class jI{#e;#t;#i;#s;#r;#A;#a;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#g;#h;#u;#n;#d;#C;#B;#E;#k;#m;#b;#y;#f;#Q;#I;#x;#o;#U;static unsafeExposeInternals(t){return{starts:t.#y,ttls:t.#f,autopurgeTimers:t.#Q,sizes:t.#b,keyMap:t.#h,keyList:t.#u,valList:t.#n,next:t.#d,prev:t.#C,get head(){return t.#B},get tail(){return t.#E},free:t.#k,isBackgroundFetch:s=>t.#p(s),backgroundFetch:(s,r,i,o)=>t.#J(s,r,i,o),moveToTail:s=>t.#G(s),indexes:s=>t.#R(s),rindexes:s=>t.#T(s),isStale:s=>t.#w(s)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#g}get size(){return this.#l}get fetchMethod(){return this.#A}get memoMethod(){return this.#a}get dispose(){return this.#i}get onInsert(){return this.#s}get disposeAfter(){return this.#r}constructor(t){let{max:s=0,ttl:r,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:A,dispose:c,onInsert:u,disposeAfter:l,noDisposeOnSet:p,noUpdateTTL:g,maxSize:h=0,maxEntrySize:E=0,sizeCalculation:m,fetchMethod:d,memoMethod:f,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:B,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:Y,ignoreFetchAbort:O,perf:pe}=t;if(pe!==void 0&&typeof pe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#c=pe??WL,s!==0&&!ms(s))throw new TypeError("max option must be a nonnegative integer");let he=s?WI(s):Array;if(!he)throw new Error("invalid max value: "+s);if(this.#e=s,this.#t=h,this.maxEntrySize=E||this.#t,this.sizeCalculation=m,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(f!==void 0&&typeof f!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#a=f,d!==void 0&&typeof d!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#A=d,this.#x=!!d,this.#h=new Map,this.#u=new Array(s).fill(void 0),this.#n=new Array(s).fill(void 0),this.#d=new he(s),this.#C=new he(s),this.#B=0,this.#E=0,this.#k=zL.create(s),this.#l=0,this.#g=0,typeof c=="function"&&(this.#i=c),typeof u=="function"&&(this.#s=u),typeof l=="function"?(this.#r=l,this.#m=[]):(this.#r=void 0,this.#m=void 0),this.#I=!!this.#i,this.#U=!!this.#s,this.#o=!!this.#r,this.noDisposeOnSet=!!p,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!Y,this.ignoreFetchAbort=!!O,this.maxEntrySize!==0){if(this.#t!==0&&!ms(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!ms(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#H()}if(this.allowStale=!!A,this.noDeleteOnStaleGet=!!B,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=ms(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!ms(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#F()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let ht="LRU_CACHE_UNBOUNDED";jL(ht)&&(VI.add(ht),qI("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ht,jI))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#F(){let t=new Ya(this.#e),s=new Ya(this.#e);this.#f=t,this.#y=s;let r=this.ttlAutopurge?new Array(this.#e):void 0;this.#Q=r,this.#L=(n,a,A=this.#c.now())=>{if(s[n]=a!==0?A:0,t[n]=a,r?.[n]&&(clearTimeout(r[n]),r[n]=void 0),a!==0&&r){let c=setTimeout(()=>{this.#w(n)&&this.#D(this.#u[n],"expire")},a+1);c.unref&&c.unref(),r[n]=c}},this.#v=n=>{s[n]=t[n]!==0?this.#c.now():0},this.#S=(n,a)=>{if(t[a]){let A=t[a],c=s[a];if(!A||!c)return;n.ttl=A,n.start=c,n.now=i||o();let u=n.now-c;n.remainingTTL=A-u}};let i=0,o=()=>{let n=this.#c.now();if(this.ttlResolution>0){i=n;let a=setTimeout(()=>i=0,this.ttlResolution);a.unref&&a.unref()}return n};this.getRemainingTTL=n=>{let a=this.#h.get(n);if(a===void 0)return 0;let A=t[a],c=s[a];if(!A||!c)return 1/0;let u=(i||o())-c;return A-u},this.#w=n=>{let a=s[n],A=t[n];return!!A&&!!a&&(i||o())-a>A}}#v=()=>{};#S=()=>{};#L=()=>{};#w=()=>!1;#H(){let t=new Ya(this.#e);this.#g=0,this.#b=t,this.#M=s=>{this.#g-=t[s],t[s]=0},this.#_=(s,r,i,o)=>{if(this.#p(r))return 0;if(!ms(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(r,s),!ms(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#N=(s,r,i)=>{if(t[s]=r,this.#t){let o=this.#t-t[s];for(;this.#g>o;)this.#O(!0)}this.#g+=t[s],i&&(i.entrySize=r,i.totalCalculatedSize=this.#g)}}#M=t=>{};#N=(t,s,r)=>{};#_=(t,s,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#R({allowStale:t=this.allowStale}={}){if(this.#l)for(let s=this.#E;!(!this.#Y(s)||((t||!this.#w(s))&&(yield s),s===this.#B));)s=this.#C[s]}*#T({allowStale:t=this.allowStale}={}){if(this.#l)for(let s=this.#B;!(!this.#Y(s)||((t||!this.#w(s))&&(yield s),s===this.#E));)s=this.#d[s]}#Y(t){return t!==void 0&&this.#h.get(this.#u[t])===t}*entries(){for(let t of this.#R())this.#n[t]!==void 0&&this.#u[t]!==void 0&&!this.#p(this.#n[t])&&(yield[this.#u[t],this.#n[t]])}*rentries(){for(let t of this.#T())this.#n[t]!==void 0&&this.#u[t]!==void 0&&!this.#p(this.#n[t])&&(yield[this.#u[t],this.#n[t]])}*keys(){for(let t of this.#R()){let s=this.#u[t];s!==void 0&&!this.#p(this.#n[t])&&(yield s)}}*rkeys(){for(let t of this.#T()){let s=this.#u[t];s!==void 0&&!this.#p(this.#n[t])&&(yield s)}}*values(){for(let t of this.#R())this.#n[t]!==void 0&&!this.#p(this.#n[t])&&(yield this.#n[t])}*rvalues(){for(let t of this.#T())this.#n[t]!==void 0&&!this.#p(this.#n[t])&&(yield this.#n[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,s={}){for(let r of this.#R()){let i=this.#n[r],o=this.#p(i)?i.__staleWhileFetching:i;if(o!==void 0&&t(o,this.#u[r],this))return this.get(this.#u[r],s)}}forEach(t,s=this){for(let r of this.#R()){let i=this.#n[r],o=this.#p(i)?i.__staleWhileFetching:i;o!==void 0&&t.call(s,o,this.#u[r],this)}}rforEach(t,s=this){for(let r of this.#T()){let i=this.#n[r],o=this.#p(i)?i.__staleWhileFetching:i;o!==void 0&&t.call(s,o,this.#u[r],this)}}purgeStale(){let t=!1;for(let s of this.#T({allowStale:!0}))this.#w(s)&&(this.#D(this.#u[s],"expire"),t=!0);return t}info(t){let s=this.#h.get(t);if(s===void 0)return;let r=this.#n[s],i=this.#p(r)?r.__staleWhileFetching:r;if(i===void 0)return;let o={value:i};if(this.#f&&this.#y){let n=this.#f[s],a=this.#y[s];if(n&&a){let A=n-(this.#c.now()-a);o.ttl=A,o.start=Date.now()}}return this.#b&&(o.size=this.#b[s]),o}dump(){let t=[];for(let s of this.#R({allowStale:!0})){let r=this.#u[s],i=this.#n[s],o=this.#p(i)?i.__staleWhileFetching:i;if(o===void 0||r===void 0)continue;let n={value:o};if(this.#f&&this.#y){n.ttl=this.#f[s];let a=this.#c.now()-this.#y[s];n.start=Math.floor(Date.now()-a)}this.#b&&(n.size=this.#b[s]),t.unshift([r,n])}return t}load(t){this.clear();for(let[s,r]of t){if(r.start){let i=Date.now()-r.start;r.start=this.#c.now()-i}this.set(s,r.value,r)}}set(t,s,r={}){if(s===void 0)return this.delete(t),this;let{ttl:i=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:A}=r,{noUpdateTTL:c=this.noUpdateTTL}=r,u=this.#_(t,s,r.size||0,a);if(this.maxEntrySize&&u>this.maxEntrySize)return A&&(A.set="miss",A.maxEntrySizeExceeded=!0),this.#D(t,"set"),this;let l=this.#l===0?void 0:this.#h.get(t);if(l===void 0)l=this.#l===0?this.#E:this.#k.length!==0?this.#k.pop():this.#l===this.#e?this.#O(!1):this.#l,this.#u[l]=t,this.#n[l]=s,this.#h.set(t,l),this.#d[this.#E]=l,this.#C[l]=this.#E,this.#E=l,this.#l++,this.#N(l,u,A),A&&(A.set="add"),c=!1,this.#U&&this.#s?.(s,t,"add");else{this.#G(l);let p=this.#n[l];if(s!==p){if(this.#x&&this.#p(p)){p.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=p;g!==void 0&&!n&&(this.#I&&this.#i?.(g,t,"set"),this.#o&&this.#m?.push([g,t,"set"]))}else n||(this.#I&&this.#i?.(p,t,"set"),this.#o&&this.#m?.push([p,t,"set"]));if(this.#M(l),this.#N(l,u,A),this.#n[l]=s,A){A.set="replace";let g=p&&this.#p(p)?p.__staleWhileFetching:p;g!==void 0&&(A.oldValue=g)}}else A&&(A.set="update");this.#U&&this.onInsert?.(s,t,s===p?"update":"replace")}if(i!==0&&!this.#f&&this.#F(),this.#f&&(c||this.#L(l,i,o),A&&this.#S(A,l)),!n&&this.#o&&this.#m){let p=this.#m,g;for(;g=p?.shift();)this.#r?.(...g)}return this}pop(){try{for(;this.#l;){let t=this.#n[this.#B];if(this.#O(!0),this.#p(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#o&&this.#m){let t=this.#m,s;for(;s=t?.shift();)this.#r?.(...s)}}}#O(t){let s=this.#B,r=this.#u[s],i=this.#n[s];return this.#x&&this.#p(i)?i.__abortController.abort(new Error("evicted")):(this.#I||this.#o)&&(this.#I&&this.#i?.(i,r,"evict"),this.#o&&this.#m?.push([i,r,"evict"])),this.#M(s),this.#Q?.[s]&&(clearTimeout(this.#Q[s]),this.#Q[s]=void 0),t&&(this.#u[s]=void 0,this.#n[s]=void 0,this.#k.push(s)),this.#l===1?(this.#B=this.#E=0,this.#k.length=0):this.#B=this.#d[s],this.#h.delete(r),this.#l--,s}has(t,s={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=s,o=this.#h.get(t);if(o!==void 0){let n=this.#n[o];if(this.#p(n)&&n.__staleWhileFetching===void 0)return!1;if(this.#w(o))i&&(i.has="stale",this.#S(i,o));else return r&&this.#v(o),i&&(i.has="hit",this.#S(i,o)),!0}else i&&(i.has="miss");return!1}peek(t,s={}){let{allowStale:r=this.allowStale}=s,i=this.#h.get(t);if(i===void 0||!r&&this.#w(i))return;let o=this.#n[i];return this.#p(o)?o.__staleWhileFetching:o}#J(t,s,r,i){let o=s===void 0?void 0:this.#n[s];if(this.#p(o))return o;let n=new Pa,{signal:a}=r;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let A={signal:n.signal,options:r,context:i},c=(E,m=!1)=>{let{aborted:d}=n.signal,f=r.ignoreFetchAbort&&E!==void 0,C=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&E!==void 0);if(r.status&&(d&&!m?(r.status.fetchAborted=!0,r.status.fetchError=n.signal.reason,f&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),d&&!f&&!m)return l(n.signal.reason,C);let B=g,b=this.#n[s];return(b===g||f&&m&&b===void 0)&&(E===void 0?B.__staleWhileFetching!==void 0?this.#n[s]=B.__staleWhileFetching:this.#D(t,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(t,E,A.options))),E},u=E=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=E),l(E,!1)),l=(E,m)=>{let{aborted:d}=n.signal,f=d&&r.allowStaleOnFetchAbort,C=f||r.allowStaleOnFetchRejection,B=C||r.noDeleteOnFetchRejection,b=g;if(this.#n[s]===g&&(!B||!m&&b.__staleWhileFetching===void 0?this.#D(t,"fetch"):f||(this.#n[s]=b.__staleWhileFetching)),C)return r.status&&b.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),b.__staleWhileFetching;if(b.__returned===b)throw E},p=(E,m)=>{let d=this.#A?.(t,o,A);d&&d instanceof Promise&&d.then(f=>E(f===void 0?void 0:f),m),n.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(E(void 0),r.allowStaleOnFetchAbort&&(E=f=>c(f,!0)))})};r.status&&(r.status.fetchDispatched=!0);let g=new Promise(p).then(c,u),h=Object.assign(g,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,h,{...A.options,status:void 0}),s=this.#h.get(t)):this.#n[s]=h,h}#p(t){if(!this.#x)return!1;let s=t;return!!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Pa}async fetch(t,s={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:A=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:E,forceRefresh:m=!1,status:d,signal:f}=s;if(!this.#x)return d&&(d.fetch="get"),this.get(t,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:d});let C={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:A,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:h,ignoreFetchAbort:g,status:d,signal:f},B=this.#h.get(t);if(B===void 0){d&&(d.fetch="miss");let b=this.#J(t,B,C,E);return b.__returned=b}else{let b=this.#n[B];if(this.#p(b)){let he=r&&b.__staleWhileFetching!==void 0;return d&&(d.fetch="inflight",he&&(d.returnedStale=!0)),he?b.__staleWhileFetching:b.__returned=b}let Y=this.#w(B);if(!m&&!Y)return d&&(d.fetch="hit"),this.#G(B),i&&this.#v(B),d&&this.#S(d,B),b;let O=this.#J(t,B,C,E),pe=O.__staleWhileFetching!==void 0&&r;return d&&(d.fetch=Y?"stale":"refresh",pe&&Y&&(d.returnedStale=!0)),pe?O.__staleWhileFetching:O.__returned=O}}async forceFetch(t,s={}){let r=await this.fetch(t,s);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(t,s={}){let r=this.#a;if(!r)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:o,...n}=s,a=this.get(t,n);if(!o&&a!==void 0)return a;let A=r(t,a,{options:n,context:i});return this.set(t,A,n),A}get(t,s={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=s,a=this.#h.get(t);if(a!==void 0){let A=this.#n[a],c=this.#p(A);return n&&this.#S(n,a),this.#w(a)?(n&&(n.get="stale"),c?(n&&r&&A.__staleWhileFetching!==void 0&&(n.returnedStale=!0),r?A.__staleWhileFetching:void 0):(o||this.#D(t,"expire"),n&&r&&(n.returnedStale=!0),r?A:void 0)):(n&&(n.get="hit"),c?A.__staleWhileFetching:(this.#G(a),i&&this.#v(a),A))}else n&&(n.get="miss")}#P(t,s){this.#C[s]=t,this.#d[t]=s}#G(t){t!==this.#E&&(t===this.#B?this.#B=this.#d[t]:this.#P(this.#C[t],this.#d[t]),this.#P(this.#E,t),this.#E=t)}delete(t){return this.#D(t,"delete")}#D(t,s){let r=!1;if(this.#l!==0){let i=this.#h.get(t);if(i!==void 0)if(this.#Q?.[i]&&(clearTimeout(this.#Q?.[i]),this.#Q[i]=void 0),r=!0,this.#l===1)this.#V(s);else{this.#M(i);let o=this.#n[i];if(this.#p(o)?o.__abortController.abort(new Error("deleted")):(this.#I||this.#o)&&(this.#I&&this.#i?.(o,t,s),this.#o&&this.#m?.push([o,t,s])),this.#h.delete(t),this.#u[i]=void 0,this.#n[i]=void 0,i===this.#E)this.#E=this.#C[i];else if(i===this.#B)this.#B=this.#d[i];else{let n=this.#C[i];this.#d[n]=this.#d[i];let a=this.#d[i];this.#C[a]=this.#C[i]}this.#l--,this.#k.push(i)}}if(this.#o&&this.#m?.length){let i=this.#m,o;for(;o=i?.shift();)this.#r?.(...o)}return r}clear(){return this.#V("delete")}#V(t){for(let s of this.#T({allowStale:!0})){let r=this.#n[s];if(this.#p(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#u[s];this.#I&&this.#i?.(r,i,t),this.#o&&this.#m?.push([r,i,t])}}if(this.#h.clear(),this.#n.fill(void 0),this.#u.fill(void 0),this.#f&&this.#y){this.#f.fill(0),this.#y.fill(0);for(let s of this.#Q??[])s!==void 0&&clearTimeout(s);this.#Q?.fill(void 0)}if(this.#b&&this.#b.fill(0),this.#B=0,this.#E=0,this.#k.length=0,this.#g=0,this.#l=0,this.#o&&this.#m){let s=this.#m,r;for(;r=s?.shift();)this.#r?.(...r)}}},mI=typeof process=="object"&&process?process:{stdout:null,stderr:null},KL=e=>!!e&&typeof e=="object"&&(e instanceof Ha||e instanceof rp.default||XL(e)||$L(e)),XL=e=>!!e&&typeof e=="object"&&e instanceof qa.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==rp.default.Writable.prototype.pipe,$L=e=>!!e&&typeof e=="object"&&e instanceof qa.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",Vt=Symbol("EOF"),qt=Symbol("maybeEmitEnd"),Es=Symbol("emittedEnd"),Sa=Symbol("emittingEnd"),no=Symbol("emittedError"),Ua=Symbol("closed"),fI=Symbol("read"),Na=Symbol("flush"),QI=Symbol("flushChunk"),pt=Symbol("encoding"),Zr=Symbol("decoder"),ce=Symbol("flowing"),ao=Symbol("paused"),Kr=Symbol("resume"),le=Symbol("buffer"),we=Symbol("pipes"),ue=Symbol("bufferLength"),Wu=Symbol("bufferPush"),Ga=Symbol("bufferShift"),Qe=Symbol("objectMode"),se=Symbol("destroyed"),ju=Symbol("error"),zu=Symbol("emitData"),BI=Symbol("emitEnd"),Zu=Symbol("emitEnd2"),vt=Symbol("async"),Ku=Symbol("abort"),Ma=Symbol("aborted"),Ao=Symbol("signal"),Ws=Symbol("dataListeners"),Pe=Symbol("discarded"),co=e=>Promise.resolve().then(e),e_=e=>e(),t_=e=>e==="end"||e==="finish"||e==="prefinish",s_=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,r_=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),KI=class{src;dest;opts;ondrain;constructor(e,t,s){this.src=e,this.dest=t,this.opts=s,this.ondrain=()=>e[Kr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},i_=class extends KI{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,s){super(e,t,s),this.proxyErrors=r=>this.dest.emit("error",r),e.on("error",this.proxyErrors)}},o_=e=>!!e.objectMode,n_=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",Ha=class extends qa.EventEmitter{[ce]=!1;[ao]=!1;[we]=[];[le]=[];[Qe];[pt];[vt];[Zr];[Vt]=!1;[Es]=!1;[Sa]=!1;[Ua]=!1;[no]=null;[ue]=0;[se]=!1;[Ao];[Ma]=!1;[Ws]=0;[Pe]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");o_(t)?(this[Qe]=!0,this[pt]=null):n_(t)?(this[pt]=t.encoding,this[Qe]=!1):(this[Qe]=!1,this[pt]=null),this[vt]=!!t.async,this[Zr]=this[pt]?new ZI.StringDecoder(this[pt]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[le]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[we]});let{signal:s}=t;s&&(this[Ao]=s,s.aborted?this[Ku]():s.addEventListener("abort",()=>this[Ku]()))}get bufferLength(){return this[ue]}get encoding(){return this[pt]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Qe]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[vt]}set async(e){this[vt]=this[vt]||!!e}[Ku](){this[Ma]=!0,this.emit("abort",this[Ao]?.reason),this.destroy(this[Ao]?.reason)}get aborted(){return this[Ma]}set aborted(e){}write(e,t,s){if(this[Ma])return!1;if(this[Vt])throw new Error("write after end");if(this[se])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(s=t,t="utf8"),t||(t="utf8");let r=this[vt]?co:e_;if(!this[Qe]&&!Buffer.isBuffer(e)){if(r_(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(s_(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Qe]?(this[ce]&&this[ue]!==0&&this[Na](!0),this[ce]?this.emit("data",e):this[Wu](e),this[ue]!==0&&this.emit("readable"),s&&r(s),this[ce]):e.length?(typeof e=="string"&&!(t===this[pt]&&!this[Zr]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[pt]&&(e=this[Zr].write(e)),this[ce]&&this[ue]!==0&&this[Na](!0),this[ce]?this.emit("data",e):this[Wu](e),this[ue]!==0&&this.emit("readable"),s&&r(s),this[ce]):(this[ue]!==0&&this.emit("readable"),s&&r(s),this[ce])}read(e){if(this[se])return null;if(this[Pe]=!1,this[ue]===0||e===0||e&&e>this[ue])return this[qt](),null;this[Qe]&&(e=null),this[le].length>1&&!this[Qe]&&(this[le]=[this[pt]?this[le].join(""):Buffer.concat(this[le],this[ue])]);let t=this[fI](e||null,this[le][0]);return this[qt](),t}[fI](e,t){if(this[Qe])this[Ga]();else{let s=t;e===s.length||e===null?this[Ga]():typeof s=="string"?(this[le][0]=s.slice(e),t=s.slice(0,e),this[ue]-=e):(this[le][0]=s.subarray(e),t=s.subarray(0,e),this[ue]-=e)}return this.emit("data",t),!this[le].length&&!this[Vt]&&this.emit("drain"),t}end(e,t,s){return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t="utf8"),e!==void 0&&this.write(e,t),s&&this.once("end",s),this[Vt]=!0,this.writable=!1,(this[ce]||!this[ao])&&this[qt](),this}[Kr](){this[se]||(!this[Ws]&&!this[we].length&&(this[Pe]=!0),this[ao]=!1,this[ce]=!0,this.emit("resume"),this[le].length?this[Na]():this[Vt]?this[qt]():this.emit("drain"))}resume(){return this[Kr]()}pause(){this[ce]=!1,this[ao]=!0,this[Pe]=!1}get destroyed(){return this[se]}get flowing(){return this[ce]}get paused(){return this[ao]}[Wu](e){this[Qe]?this[ue]+=1:this[ue]+=e.length,this[le].push(e)}[Ga](){return this[Qe]?this[ue]-=1:this[ue]-=this[le][0].length,this[le].shift()}[Na](e=!1){do;while(this[QI](this[Ga]())&&this[le].length);!e&&!this[le].length&&!this[Vt]&&this.emit("drain")}[QI](e){return this.emit("data",e),this[ce]}pipe(e,t){if(this[se])return e;this[Pe]=!1;let s=this[Es];return t=t||{},e===mI.stdout||e===mI.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,s?t.end&&e.end():(this[we].push(t.proxyErrors?new i_(this,e,t):new KI(this,e,t)),this[vt]?co(()=>this[Kr]()):this[Kr]()),e}unpipe(e){let t=this[we].find(s=>s.dest===e);t&&(this[we].length===1?(this[ce]&&this[Ws]===0&&(this[ce]=!1),this[we]=[]):this[we].splice(this[we].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let s=super.on(e,t);if(e==="data")this[Pe]=!1,this[Ws]++,!this[we].length&&!this[ce]&&this[Kr]();else if(e==="readable"&&this[ue]!==0)super.emit("readable");else if(t_(e)&&this[Es])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[no]){let r=t;this[vt]?co(()=>r.call(this,this[no])):r.call(this,this[no])}return s}removeListener(e,t){return this.off(e,t)}off(e,t){let s=super.off(e,t);return e==="data"&&(this[Ws]=this.listeners("data").length,this[Ws]===0&&!this[Pe]&&!this[we].length&&(this[ce]=!1)),s}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Ws]=0,!this[Pe]&&!this[we].length&&(this[ce]=!1)),t}get emittedEnd(){return this[Es]}[qt](){!this[Sa]&&!this[Es]&&!this[se]&&this[le].length===0&&this[Vt]&&(this[Sa]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ua]&&this.emit("close"),this[Sa]=!1)}emit(e,...t){let s=t[0];if(e!=="error"&&e!=="close"&&e!==se&&this[se])return!1;if(e==="data")return!this[Qe]&&!s?!1:this[vt]?(co(()=>this[zu](s)),!0):this[zu](s);if(e==="end")return this[BI]();if(e==="close"){if(this[Ua]=!0,!this[Es]&&!this[se])return!1;let i=super.emit("close");return this.removeAllListeners("close"),i}else if(e==="error"){this[no]=s,super.emit(ju,s);let i=!this[Ao]||this.listeners("error").length?super.emit("error",s):!1;return this[qt](),i}else if(e==="resume"){let i=super.emit("resume");return this[qt](),i}else if(e==="finish"||e==="prefinish"){let i=super.emit(e);return this.removeAllListeners(e),i}let r=super.emit(e,...t);return this[qt](),r}[zu](e){for(let s of this[we])s.dest.write(e)===!1&&this.pause();let t=this[Pe]?!1:super.emit("data",e);return this[qt](),t}[BI](){return this[Es]?!1:(this[Es]=!0,this.readable=!1,this[vt]?(co(()=>this[Zu]()),!0):this[Zu]())}[Zu](){if(this[Zr]){let t=this[Zr].end();if(t){for(let s of this[we])s.dest.write(t);this[Pe]||super.emit("data",t)}}for(let t of this[we])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[Qe]||(e.dataLength=0);let t=this.promise();return this.on("data",s=>{e.push(s),this[Qe]||(e.dataLength+=s.length)}),await t,e}async concat(){if(this[Qe])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[pt]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(se,()=>t(new Error("stream destroyed"))),this.on("error",s=>t(s)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Pe]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let s=this.read();if(s!==null)return Promise.resolve({done:!1,value:s});if(this[Vt])return t();let r,i,o=c=>{this.off("data",n),this.off("end",a),this.off(se,A),t(),i(c)},n=c=>{this.off("error",o),this.off("end",a),this.off(se,A),this.pause(),r({value:c,done:!!this[Vt]})},a=()=>{this.off("error",o),this.off("data",n),this.off(se,A),t(),r({done:!0,value:void 0})},A=()=>o(new Error("stream destroyed"));return new Promise((c,u)=>{i=u,r=c,this.once(se,A),this.once("error",o),this.once("end",a),this.once("data",n)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Pe]=!1;let e=!1,t=()=>(this.pause(),this.off(ju,t),this.off(se,t),this.off("end",t),e=!0,{done:!0,value:void 0}),s=()=>{if(e)return t();let r=this.read();return r===null?t():{done:!1,value:r}};return this.once("end",t),this.once(ju,t),this.once(se,t),{next:s,throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[se])return e?this.emit("error",e):this.emit(se),this;this[se]=!0,this[Pe]=!0,this[le].length=0,this[ue]=0;let t=this;return typeof t.close=="function"&&!this[Ua]&&t.close(),e?this.emit("error",e):this.emit(se),this}static get isStream(){return KL}},a_=Dt.realpathSync.native,go={lstatSync:Dt.lstatSync,readdir:Dt.readdir,readdirSync:Dt.readdirSync,readlinkSync:Dt.readlinkSync,realpathSync:a_,promises:{lstat:Qs.lstat,readdir:Qs.readdir,readlink:Qs.readlink,realpath:Qs.realpath}},XI=e=>!e||e===go||e===ZL?go:{...go,...e,promises:{...go.promises,...e.promises||{}}},$I=/^\\\\\?\\([a-z]:)\\?$/i,A_=e=>e.replace(/\//g,"\\").replace($I,"$1\\"),c_=/[\\\/]/,tt=0,ew=1,tw=2,kt=4,sw=6,rw=8,js=10,iw=12,et=15,lo=~et,Xu=16,CI=32,ho=64,gt=128,La=256,Oa=512,II=ho|gt|Oa,l_=1023,$u=e=>e.isFile()?rw:e.isDirectory()?kt:e.isSymbolicLink()?js:e.isCharacterDevice()?tw:e.isBlockDevice()?sw:e.isSocket()?iw:e.isFIFO()?ew:tt,wI=new Va({max:2**12}),Eo=e=>{let t=wI.get(e);if(t)return t;let s=e.normalize("NFKD");return wI.set(e,s),s},bI=new Va({max:2**12}),_a=e=>{let t=bI.get(e);if(t)return t;let s=Eo(e.toLowerCase());return bI.set(e,s),s},yI=class extends Va{constructor(){super({max:256})}},u_=class extends Va{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1})}},ow=Symbol("PathScurry setAsCwd"),Se=class{name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#i;get mode(){return this.#i}#s;get nlink(){return this.#s}#r;get uid(){return this.#r}#A;get gid(){return this.#A}#a;get rdev(){return this.#a}#c;get blksize(){return this.#c}#l;get ino(){return this.#l}#g;get size(){return this.#g}#h;get blocks(){return this.#h}#u;get atimeMs(){return this.#u}#n;get mtimeMs(){return this.#n}#d;get ctimeMs(){return this.#d}#C;get birthtimeMs(){return this.#C}#B;get atime(){return this.#B}#E;get mtime(){return this.#E}#k;get ctime(){return this.#k}#m;get birthtime(){return this.#m}#b;#y;#f;#Q;#I;#x;#o;#U;#F;#v;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=tt,s,r,i,o,n){this.name=e,this.#b=i?_a(e):Eo(e),this.#o=t&l_,this.nocase=i,this.roots=r,this.root=s||this,this.#U=o,this.#f=n.fullpath,this.#I=n.relative,this.#x=n.relativePosix,this.parent=n.parent,this.parent?this.#e=this.parent.#e:this.#e=XI(n.fs)}depth(){return this.#y!==void 0?this.#y:this.parent?this.#y=this.parent.depth()+1:this.#y=0}childrenCache(){return this.#U}resolve(e){if(!e)return this;let t=this.getRootString(e),s=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#S(s):this.#S(s)}#S(e){let t=this;for(let s of e)t=t.child(s);return t}children(){let e=this.#U.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#U.set(this,t),this.#o&=~Xu,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),r=this.nocase?_a(e):Eo(e);for(let a of s)if(a.#b===r)return a;let i=this.parent?this.sep:"",o=this.#f?this.#f+i+e:void 0,n=this.newChild(e,tt,{...t,parent:this,fullpath:o});return this.canReaddir()||(n.#o|=gt),s.push(n),n}relative(){if(this.isCWD)return"";if(this.#I!==void 0)return this.#I;let e=this.name,t=this.parent;if(!t)return this.#I=this.name;let s=t.relative();return s+(!s||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let e=this.name,t=this.parent;if(!t)return this.#x=this.fullpathPosix();let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(this.#f!==void 0)return this.#f;let e=this.name,t=this.parent;if(!t)return this.#f=this.name;let s=t.fullpath()+(t.parent?this.sep:"")+e;return this.#f=s}fullpathPosix(){if(this.#Q!==void 0)return this.#Q;if(this.sep==="/")return this.#Q=this.fullpath();if(!this.parent){let r=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(r)?this.#Q=`//?/${r}`:this.#Q=r}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return this.#Q=s}isUnknown(){return(this.#o&et)===tt}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#o&et)===rw}isDirectory(){return(this.#o&et)===kt}isCharacterDevice(){return(this.#o&et)===tw}isBlockDevice(){return(this.#o&et)===sw}isFIFO(){return(this.#o&et)===ew}isSocket(){return(this.#o&et)===iw}isSymbolicLink(){return(this.#o&js)===js}lstatCached(){return this.#o&CI?this:void 0}readlinkCached(){return this.#F}realpathCached(){return this.#v}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#F)return!0;if(!this.parent)return!1;let e=this.#o&et;return!(e!==tt&&e!==js||this.#o&La||this.#o>)}calledReaddir(){return!!(this.#o&Xu)}isENOENT(){return!!(this.#o>)}isNamed(e){return this.nocase?this.#b===_a(e):this.#b===Eo(e)}async readlink(){let e=this.#F;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#e.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return this.#F=s}catch(t){this.#T(t.code);return}}readlinkSync(){let e=this.#F;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#e.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return this.#F=s}catch(t){this.#T(t.code);return}}#L(e){this.#o|=Xu;for(let t=e.provisional;ts(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let s=this.children();if(this.calledReaddir()){let i=s.slice(0,s.provisional);t?e(null,i):queueMicrotask(()=>e(null,i));return}if(this.#G.push(e),this.#D)return;this.#D=!0;let r=this.fullpath();this.#e.readdir(r,{withFileTypes:!0},(i,o)=>{if(i)this.#_(i.code),s.provisional=0;else{for(let n of o)this.#Y(n,s);this.#L(s)}this.#V(s.slice(0,s.provisional))})}#q;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#q)await this.#q;else{let s=()=>{};this.#q=new Promise(r=>s=r);try{for(let r of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#Y(r,e);this.#L(e)}catch(r){this.#_(r.code),e.provisional=0}this.#q=void 0,s()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let s of this.#e.readdirSync(t,{withFileTypes:!0}))this.#Y(s,e);this.#L(e)}catch(s){this.#_(s.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#o&II)return!1;let e=et&this.#o;return e===tt||e===kt||e===js}shouldWalk(e,t){return(this.#o&kt)===kt&&!(this.#o&II)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#v)return this.#v;if(!((Oa|La|gt)&this.#o))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#v=this.resolve(e)}catch{this.#M()}}realpathSync(){if(this.#v)return this.#v;if(!((Oa|La|gt)&this.#o))try{let e=this.#e.realpathSync(this.fullpath());return this.#v=this.resolve(e)}catch{this.#M()}}[ow](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),s=[],r=this;for(;r&&r.parent;)t.add(r),r.#I=s.join(this.sep),r.#x=s.join("/"),r=r.parent,s.push("..");for(r=e;r&&r.parent&&!t.has(r);)r.#I=void 0,r.#x=void 0,r=r.parent}},nw=class aw extends Se{sep="\\";splitSep=c_;constructor(t,s=tt,r,i,o,n,a){super(t,s,r,i,o,n,a)}newChild(t,s=tt,r={}){return new aw(t,s,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(t){return $r.win32.parse(t).root}getRoot(t){if(t=A_(t.toUpperCase()),t===this.root.name)return this.root;for(let[s,r]of Object.entries(this.roots))if(this.sameRoot(t,s))return this.roots[t]=r;return this.roots[t]=new ip(t,this).root}sameRoot(t,s=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace($I,"$1\\"),t===s}},Aw=class cw extends Se{splitSep="/";sep="/";constructor(t,s=tt,r,i,o,n,a){super(t,s,r,i,o,n,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,s=tt,r={}){return new cw(t,s,this.root,this.roots,this.nocase,this.childrenCache(),r)}},lw=class{root;rootPath;roots;cwd;#e;#t;#i;nocase;#s;constructor(e=process.cwd(),t,s,{nocase:r,childrenCacheSize:i=16*1024,fs:o=go}={}){this.#s=XI(o),(e instanceof URL||e.startsWith("file://"))&&(e=(0,zI.fileURLToPath)(e));let n=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(n),this.#e=new yI,this.#t=new yI,this.#i=new u_(i);let a=n.substring(this.rootPath.length).split(s);if(a.length===1&&!a[0]&&a.pop(),r===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=r,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let A=this.root,c=a.length-1,u=t.sep,l=this.rootPath,p=!1;for(let g of a){let h=c--;A=A.child(g,{relative:new Array(h).fill("..").join(u),relativePosix:new Array(h).fill("..").join("/"),fullpath:l+=(p?"":u)+g}),p=!0}this.cwd=A}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#i}resolve(...e){let t="";for(let i=e.length-1;i>=0;i--){let o=e[i];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#e.get(t);if(s!==void 0)return s;let r=this.cwd.resolve(t).fullpath();return this.#e.set(t,r),r}resolvePosix(...e){let t="";for(let i=e.length-1;i>=0;i--){let o=e[i];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#t.get(t);if(s!==void 0)return s;let r=this.cwd.resolve(t).fullpathPosix();return this.#t.set(t,r),r}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s}=t;if(e.canReaddir()){let r=await e.readdir();return s?r:r.map(i=>i.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0}=t;return e.canReaddir()?s?e.readdirSync():e.readdirSync().map(r=>r.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=await e.readlink();return t?s:s?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=e.readlinkSync();return t?s:s?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=await e.realpath();return t?s:s?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=e.realpathSync();return t?s:s?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=[];(!i||i(e))&&n.push(s?e:e.fullpath());let a=new Set,A=(u,l)=>{a.add(u),u.readdirCB((p,g)=>{if(p)return l(p);let h=g.length;if(!h)return l();let E=()=>{--h===0&&l()};for(let m of g)(!i||i(m))&&n.push(s?m:m.fullpath()),r&&m.isSymbolicLink()?m.realpath().then(d=>d?.isUnknown()?d.lstat():d).then(d=>d?.shouldWalk(a,o)?A(d,E):E()):m.shouldWalk(a,o)?A(m,E):E()},!0)},c=e;return new Promise((u,l)=>{A(c,p=>{if(p)return l(p);u(n)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=[];(!i||i(e))&&n.push(s?e:e.fullpath());let a=new Set([e]);for(let A of a){let c=A.readdirSync();for(let u of c){(!i||i(u))&&n.push(s?u:u.fullpath());let l=u;if(u.isSymbolicLink()){if(!(r&&(l=u.realpathSync())))continue;l.isUnknown()&&l.lstatSync()}l.shouldWalk(a,o)&&a.add(l)}}return n}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t;(!i||i(e))&&(yield s?e:e.fullpath());let n=new Set([e]);for(let a of n){let A=a.readdirSync();for(let c of A){(!i||i(c))&&(yield s?c:c.fullpath());let u=c;if(c.isSymbolicLink()){if(!(r&&(u=c.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(n,o)&&n.add(u)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=new Ha({objectMode:!0});(!i||i(e))&&n.write(s?e:e.fullpath());let a=new Set,A=[e],c=0,u=()=>{let l=!1;for(;!l;){let p=A.shift();if(!p){c===0&&n.end();return}c++,a.add(p);let g=(E,m,d=!1)=>{if(E)return n.emit("error",E);if(r&&!d){let f=[];for(let C of m)C.isSymbolicLink()&&f.push(C.realpath().then(B=>B?.isUnknown()?B.lstat():B));if(f.length){Promise.all(f).then(()=>g(null,m,!0));return}}for(let f of m)f&&(!i||i(f))&&(n.write(s?f:f.fullpath())||(l=!0));c--;for(let f of m){let C=f.realpathCached()||f;C.shouldWalk(a,o)&&A.push(C)}l&&!n.flowing?n.once("drain",u):h||u()},h=!0;p.readdirCB(g,!0),h=!1}};return u(),n}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=new Ha({objectMode:!0}),a=new Set;(!i||i(e))&&n.write(s?e:e.fullpath());let A=[e],c=0,u=()=>{let l=!1;for(;!l;){let p=A.shift();if(!p){c===0&&n.end();return}c++,a.add(p);let g=p.readdirSync();for(let h of g)(!i||i(h))&&(n.write(s?h:h.fullpath())||(l=!0));c--;for(let h of g){let E=h;if(h.isSymbolicLink()){if(!(r&&(E=h.realpathSync())))continue;E.isUnknown()&&E.lstatSync()}E.shouldWalk(a,o)&&A.push(E)}}l&&!n.flowing&&n.once("drain",u)};return u(),n}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[ow](t)}},ip=class extends lw{sep="\\";constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,$r.win32,"\\",{...t,nocase:s}),this.nocase=s;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase}parseRootPath(e){return $r.win32.parse(e).root.toUpperCase()}newRoot(e){return new nw(this.rootPath,kt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},op=class extends lw{sep="/";constructor(e=process.cwd(),t={}){let{nocase:s=!1}=t;super(e,$r.posix,"/",{...t,nocase:s}),this.nocase=s}parseRootPath(e){return"/"}newRoot(e){return new Aw(this.rootPath,kt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},uw=class extends op{constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,{...t,nocase:s})}},JJ=process.platform==="win32"?nw:Aw,p_=process.platform==="win32"?ip:process.platform==="darwin"?uw:op,g_=e=>e.length>=1,h_=e=>e.length>=1,d_=Symbol.for("nodejs.util.inspect.custom"),pw=class gw{#e;#t;#i;length;#s;#r;#A;#a;#c;#l;#g=!0;constructor(t,s,r,i){if(!g_(t))throw new TypeError("empty pattern list");if(!h_(s))throw new TypeError("empty glob list");if(s.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,r<0||r>=this.length)throw new TypeError("index out of range");if(this.#e=t,this.#t=s,this.#i=r,this.#s=i,this.#i===0){if(this.isUNC()){let[o,n,a,A,...c]=this.#e,[u,l,p,g,...h]=this.#t;c[0]===""&&(c.shift(),h.shift());let E=[o,n,a,A,""].join("/"),m=[u,l,p,g,""].join("/");this.#e=[E,...c],this.#t=[m,...h],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[o,...n]=this.#e,[a,...A]=this.#t;n[0]===""&&(n.shift(),A.shift());let c=o+"/",u=a+"/";this.#e=[c,...n],this.#t=[u,...A],this.length=this.#e.length}}}[d_](){return"Pattern <"+this.#t.slice(this.#i).join("/")+">"}pattern(){return this.#e[this.#i]}isString(){return typeof this.#e[this.#i]=="string"}isGlobstar(){return this.#e[this.#i]===be}isRegExp(){return this.#e[this.#i]instanceof RegExp}globString(){return this.#A=this.#A||(this.#i===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join("/"):this.#t.join("/"):this.#t.slice(this.#i).join("/"))}hasMore(){return this.length>this.#i+1}rest(){return this.#r!==void 0?this.#r:this.hasMore()?(this.#r=new gw(this.#e,this.#t,this.#i+1,this.#s),this.#r.#l=this.#l,this.#r.#c=this.#c,this.#r.#a=this.#a,this.#r):this.#r=null}isUNC(){let t=this.#e;return this.#c!==void 0?this.#c:this.#c=this.#s==="win32"&&this.#i===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#e;return this.#a!==void 0?this.#a:this.#a=this.#s==="win32"&&this.#i===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#e;return this.#l!==void 0?this.#l:this.#l=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#e[0];return typeof t=="string"&&this.isAbsolute()&&this.#i===0?t:""}checkFollowGlobstar(){return!(this.#i===0||!this.isGlobstar()||!this.#g)}markFollowGlobstar(){return this.#i===0||!this.isGlobstar()||!this.#g?!1:(this.#g=!1,!0)}},E_=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",xI=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:s,noext:r,noglobstar:i,platform:o=E_}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:t,nocase:s,noext:r,noglobstar:i,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let n of e)this.add(n)}add(e){let t=new fs(e,this.mmopts);for(let s=0;s[e,!!(t&2),!!(t&1)])}},Q_=class{store=new Map;add(e,t){if(!e.canReaddir())return;let s=this.store.get(e);s?s.find(r=>r.globString()===t.globString())||s.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},vI=class dw{hasWalkedCache;matches=new f_;subwalks=new Q_;patterns;follow;dot;opts;constructor(t,s){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=s?s.copy():new m_}processPatterns(t,s){this.patterns=s;let r=s.map(i=>[t,i]);for(let[i,o]of r){this.hasWalkedCache.storeWalked(i,o);let n=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(n){i=i.resolve(n==="/"&&this.opts.root!==void 0?this.opts.root:n);let l=o.rest();if(l)o=l;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let A,c,u=!1;for(;typeof(A=o.pattern())=="string"&&(c=o.rest());)i=i.resolve(A),o=c,u=!0;if(A=o.pattern(),c=o.rest(),u){if(this.hasWalkedCache.hasWalked(i,o))continue;this.hasWalkedCache.storeWalked(i,o)}if(typeof A=="string"){let l=A===".."||A===""||A===".";this.matches.add(i.resolve(A),a,l);continue}else if(A===be){(!i.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(i,o);let l=c?.pattern(),p=c?.rest();if(!c||(l===""||l===".")&&!p)this.matches.add(i,a,l===""||l===".");else if(l===".."){let g=i.parent||i;p?this.hasWalkedCache.hasWalked(g,p)||this.subwalks.add(g,p):this.matches.add(g,a,!0)}}else A instanceof RegExp&&this.subwalks.add(i,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new dw(this.opts,this.hasWalkedCache)}filterEntries(t,s){let r=this.subwalks.get(t),i=this.child();for(let o of s)for(let n of r){let a=n.isAbsolute(),A=n.pattern(),c=n.rest();A===be?i.testGlobstar(o,n,c,a):A instanceof RegExp?i.testRegExp(o,A,c,a):i.testString(o,A,c,a)}return i}testGlobstar(t,s,r,i){if((this.dot||!t.name.startsWith("."))&&(s.hasMore()||this.matches.add(t,i,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,s):t.isSymbolicLink()&&(r&&s.checkFollowGlobstar()?this.subwalks.add(t,r):s.markFollowGlobstar()&&this.subwalks.add(t,s)))),r){let o=r.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,r.rest(),i);else if(o===".."){let n=t.parent||t;this.subwalks.add(n,r)}else o instanceof RegExp&&this.testRegExp(t,o,r.rest(),i)}}testRegExp(t,s,r,i){s.test(t.name)&&(r?this.subwalks.add(t,r):this.matches.add(t,i,!1))}testString(t,s,r,i){t.isNamed(s)&&(r?this.subwalks.add(t,r):this.matches.add(t,i,!1))}},B_=(e,t)=>typeof e=="string"?new xI([e],t):Array.isArray(e)?new xI(e,t):e,Ew=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#t;#i;signal;maxDepth;includeChildMatches;constructor(e,t,s){if(this.patterns=e,this.path=t,this.opts=s,this.#i=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#t=B_(s.ignore??[],s),!this.includeChildMatches&&typeof this.#t.add!="function")){let r="cannot ignore child matches, ignore lacks add() method.";throw new Error(r)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#s(e){return this.seen.has(e)||!!this.#t?.ignored?.(e)}#r(e){return!!this.#t?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||await e.realpath(),!s)return;e=s}let r=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let i=await r.realpath();i&&(i.isUnknown()||this.opts.stat)&&await i.lstat()}return this.matchCheckTest(r,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#s(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||e.realpathSync(),!s)return;e=s}let r=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let i=r.realpathSync();i&&(i?.isUnknown()||this.opts.stat)&&i.lstatSync()}return this.matchCheckTest(r,t)}matchFinish(e,t){if(this.#s(e))return;if(!this.includeChildMatches&&this.#t?.add){let i=`${e.relativePosix()}/**`;this.#t.add(i)}let s=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let r=this.opts.mark&&e.isDirectory()?this.#i:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(s){let i=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(i+r)}else{let i=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!i.startsWith(".."+this.#i)?"."+this.#i:"";this.matchEmit(i?o+i+r:"."+r)}}async match(e,t,s){let r=await this.matchCheck(e,s);r&&this.matchFinish(r,t)}matchSync(e,t,s){let r=this.matchCheckSync(e,s);r&&this.matchFinish(r,t)}walkCB(e,t,s){this.signal?.aborted&&s(),this.walkCB2(e,t,new vI(this.opts),s)}walkCB2(e,t,s,r){if(this.#r(e))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2(e,t,s,r));return}s.processPatterns(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||(i++,this.match(n,a,A).then(()=>o()));for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;i++;let a=n.readdirCached();n.calledReaddir()?this.walkCB3(n,a,s,o):n.readdirCB((A,c)=>this.walkCB3(n,c,s,o),!0)}o()}walkCB3(e,t,s,r){s=s.filterEntries(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||(i++,this.match(n,a,A).then(()=>o()));for(let[n,a]of s.subwalks.entries())i++,this.walkCB2(n,a,s.child(),o);o()}walkCBSync(e,t,s){this.signal?.aborted&&s(),this.walkCB2Sync(e,t,new vI(this.opts),s)}walkCB2Sync(e,t,s,r){if(this.#r(e))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,s,r));return}s.processPatterns(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||this.matchSync(n,a,A);for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;i++;let a=n.readdirSync();this.walkCB3Sync(n,a,s,o)}o()}walkCB3Sync(e,t,s,r){s=s.filterEntries(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||this.matchSync(n,a,A);for(let[n,a]of s.subwalks.entries())i++,this.walkCB2Sync(n,a,s.child(),o);o()}},kI=class extends Ew{matches=new Set;constructor(e,t,s){super(e,t,s)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},DI=class extends Ew{results;constructor(e,t,s){super(e,t,s),this.results=new Ha({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},C_=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",zs=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,HI.fileURLToPath)(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(a=>a.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(a=>a.includes("/")?a:`./**/${a}`)}if(this.pattern=e,this.platform=t.platform||C_,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let a=t.platform==="win32"?ip:t.platform==="darwin"?uw:t.platform?op:p_;this.scurry=new a(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",r={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},i=this.pattern.map(a=>new fs(a,r)),[o,n]=i.reduce((a,A)=>(a[0].push(...A.set),a[1].push(...A.globParts),a),[[],[]]);this.patterns=o.map((a,A)=>{let c=n[A];if(!c)throw new Error("invalid pattern object");return new pw(a,c,0,this.platform)})}async walk(){return[...await new kI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new kI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new DI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new DI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},I_=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new fs(s,t).hasMagic())return!0;return!1};function Wa(e,t={}){return new zs(e,t).streamSync()}function mw(e,t={}){return new zs(e,t).stream()}function fw(e,t={}){return new zs(e,t).walkSync()}async function RI(e,t={}){return new zs(e,t).walk()}function ja(e,t={}){return new zs(e,t).iterateSync()}function Qw(e,t={}){return new zs(e,t).iterate()}var w_=Wa,b_=Object.assign(mw,{sync:Wa}),y_=ja,x_=Object.assign(Qw,{sync:ja}),za=Object.assign(fw,{stream:Wa,iterate:ja}),TI=Object.assign(RI,{glob:RI,globSync:fw,sync:za,globStream:mw,stream:b_,globStreamSync:Wa,streamSync:w_,globIterate:Qw,iterate:x_,globIterateSync:ja,iterateSync:y_,Glob:zs,hasMagic:I_,escape:_I,unescape:Xr});TI.glob=TI;var mo=require("fs"),np=require("os"),Zs=de(require("path")),Bw=e=>{let t=e.indexOf("{");return t>-1?e.substring(0,t):e},ap=e=>{if(e.input_body_path)try{return(0,mo.readFileSync)(e.input_body_path,"utf8")}catch(t){console.warn(`\u26A0\uFE0F Failed to read body_path "${e.input_body_path}" (${t?.code??"ERR"}). Falling back to 'body' input.`)}return e.input_body},k_=e=>{let t=[],s="",r=0;for(let i of e)i==="{"&&r++,i==="}"&&r--,i===","&&r===0?(s.trim()&&t.push(s.trim()),s=""):s+=i;return s.trim()&&t.push(s.trim()),t},D_=e=>e.split(/\r?\n/).flatMap(t=>k_(t)).filter(t=>t.trim()!==""),R_=e=>{let t=e.INPUT_TOKEN?.trim();return t||e.GITHUB_TOKEN?.trim()||""},Cw=e=>({github_token:R_(e),github_ref:e.GITHUB_REF||"",github_repository:e.INPUT_REPOSITORY||e.GITHUB_REPOSITORY||"",input_name:e.INPUT_NAME,input_tag_name:Ap(e.INPUT_TAG_NAME?.trim()),input_body:e.INPUT_BODY,input_body_path:e.INPUT_BODY_PATH,input_files:D_(e.INPUT_FILES||""),input_working_directory:e.INPUT_WORKING_DIRECTORY||void 0,input_overwrite_files:e.INPUT_OVERWRITE_FILES?e.INPUT_OVERWRITE_FILES=="true":void 0,input_draft:e.INPUT_DRAFT?e.INPUT_DRAFT==="true":void 0,input_preserve_order:e.INPUT_PRESERVE_ORDER?e.INPUT_PRESERVE_ORDER=="true":void 0,input_prerelease:e.INPUT_PRERELEASE?e.INPUT_PRERELEASE=="true":void 0,input_fail_on_unmatched_files:e.INPUT_FAIL_ON_UNMATCHED_FILES=="true",input_target_commitish:e.INPUT_TARGET_COMMITISH||void 0,input_discussion_category_name:e.INPUT_DISCUSSION_CATEGORY_NAME||void 0,input_generate_release_notes:e.INPUT_GENERATE_RELEASE_NOTES=="true",input_previous_tag:e.INPUT_PREVIOUS_TAG?.trim()||void 0,input_append_body:e.INPUT_APPEND_BODY=="true",input_make_latest:T_(e.INPUT_MAKE_LATEST)}),T_=e=>{if(e==="true"||e==="false"||e==="legacy")return e},F_=(e,t=process.platform)=>t==="win32"?e.replace(/\\/g,"/"):e,S_=(e,t=(0,np.homedir)())=>e==="~"?t:e.startsWith("~/")||e.startsWith("~\\")?Zs.join(t,e.slice(2)):e,Iw=(e,t=process.platform,s=(0,np.homedir)())=>F_(S_(e,s),t),ww=(e,t)=>e.reduce((s,r)=>{let o=za(Iw(r),{cwd:t,dot:!0,absolute:!1}).map(n=>t&&!Zs.isAbsolute(n)?Zs.join(t,n):n).filter(n=>{try{return(0,mo.statSync)(n).isFile()}catch{return!1}});return s.concat(o)},[]),bw=(e,t)=>e.reduce((s,r)=>{let o=za(Iw(r),{cwd:t,dot:!0,absolute:!1}).filter(n=>{try{let a=t&&!Zs.isAbsolute(n)?Zs.join(t,n):n;return(0,mo.statSync)(a).isFile()}catch{return!1}});return s.concat(o.length==0?[r]:[])},[]),fo=e=>e.startsWith("refs/tags/"),Ap=e=>e&&(fo(e)?e.replace("refs/tags/",""):e),cp=e=>e.replace(/ /g,".");var Za=class{github;constructor(t){this.github=t}getReleaseByTag(t){return this.github.rest.repos.getReleaseByTag(t)}async getReleaseNotes(t){return await this.github.rest.repos.generateReleaseNotes(t)}async prepareReleaseMutation(t){let{previous_tag_name:s,...r}=t;if(typeof r.make_latest=="string"&&!["true","false","legacy"].includes(r.make_latest)&&(r.make_latest=void 0),r.generate_release_notes){let i=await this.getReleaseNotes({owner:r.owner,repo:r.repo,tag_name:r.tag_name,target_commitish:r.target_commitish,previous_tag_name:s});r.generate_release_notes=!1,r.body?r.body=`${r.body} -${s.data.body}`:t.body=s.data.body}return t.body=t.body?this.truncateReleaseNotes(t.body):void 0,this.github.rest.repos.createRelease(t)}async updateRelease(t){if(typeof t.make_latest=="string"&&!["true","false","legacy"].includes(t.make_latest)&&(t.make_latest=void 0),t.generate_release_notes){let s=await this.getReleaseNotes(t);t.generate_release_notes=!1,t.body?t.body=`${t.body} - -${s.data.body}`:t.body=s.data.body}return t.body=t.body?this.truncateReleaseNotes(t.body):void 0,this.github.rest.repos.updateRelease(t)}async finalizeRelease(t){return await this.github.rest.repos.updateRelease({owner:t.owner,repo:t.repo,release_id:t.release_id,draft:!1,make_latest:t.make_latest})}allReleases(t){let s={per_page:100,...t};return this.github.paginate.iterator(this.github.rest.repos.listReleases.endpoint.merge(s))}async listReleaseAssets(t){return this.github.paginate(this.github.rest.repos.listReleaseAssets,{...t,per_page:100})}async deleteReleaseAsset(t){await this.github.rest.repos.deleteReleaseAsset(t)}async deleteRelease(t){await this.github.rest.repos.deleteRelease(t)}async updateReleaseAsset(t){return await this.github.rest.repos.updateReleaseAsset(t)}async uploadReleaseAsset(t){return this.github.request({method:"POST",url:t.url,headers:{"content-length":`${t.size}`,"content-type":t.mime,authorization:`token ${t.token}`},data:t.data})}},U_=e=>({name:(0,Dw.basename)(e),mime:N_(e),size:(0,xw.statSync)(e).size}),N_=e=>(0,kw.lookup)(e)||"application/octet-stream",Rw=async(e,t,s,r,i)=>{let[o,n]=e.github_repository.split("/"),{name:a,mime:A,size:c}=U_(r),u=s.match(/\/releases\/(\d+)\/assets/),l=u?Number(u[1]):void 0,p=i.find(({name:E,label:m})=>E===a||E===cp(a)||m===a);if(p){if(e.input_overwrite_files===!1)return console.log(`Asset ${a} already exists and overwrite_files is false...`),null;console.log(`\u267B\uFE0F Deleting previously uploaded asset ${a}...`),await t.deleteReleaseAsset({asset_id:p.id||1,owner:o,repo:n})}console.log(`\u2B06\uFE0F Uploading ${a}...`);let g=new URL(s);g.searchParams.append("name",a);let h=async()=>{let E=await(0,vw.open)(r);try{return await t.uploadReleaseAsset({url:g.toString(),size:c,mime:A,token:e.github_token,data:E.readableWebStream({type:"bytes"})})}finally{await E.close()}};try{let E=await h(),m=E.data;if(E.status!==201)throw new Error(`Failed to upload release asset ${a}. received status code ${E.status} +${i.data.body}`:r.body=i.data.body}return r.body=r.body?this.truncateReleaseNotes(r.body):void 0,r}truncateReleaseNotes(t){return t.substring(0,124999)}async createRelease(t){return this.github.rest.repos.createRelease(await this.prepareReleaseMutation(t))}async updateRelease(t){return this.github.rest.repos.updateRelease(await this.prepareReleaseMutation(t))}async finalizeRelease(t){return await this.github.rest.repos.updateRelease({owner:t.owner,repo:t.repo,release_id:t.release_id,draft:!1,make_latest:t.make_latest})}allReleases(t){let s={per_page:100,...t};return this.github.paginate.iterator(this.github.rest.repos.listReleases.endpoint.merge(s))}async listReleaseAssets(t){return this.github.paginate(this.github.rest.repos.listReleaseAssets,{...t,per_page:100})}async deleteReleaseAsset(t){await this.github.rest.repos.deleteReleaseAsset(t)}async deleteRelease(t){await this.github.rest.repos.deleteRelease(t)}async updateReleaseAsset(t){return await this.github.rest.repos.updateReleaseAsset(t)}async uploadReleaseAsset(t){return this.github.request({method:"POST",url:t.url,headers:{"content-length":`${t.size}`,"content-type":t.mime,authorization:`token ${t.token}`},data:t.data})}},U_=e=>({name:(0,Dw.basename)(e),mime:N_(e),size:(0,xw.statSync)(e).size}),N_=e=>(0,kw.lookup)(e)||"application/octet-stream",Rw=async(e,t,s,r,i)=>{let[o,n]=e.github_repository.split("/"),{name:a,mime:A,size:c}=U_(r),u=s.match(/\/releases\/(\d+)\/assets/),l=u?Number(u[1]):void 0,p=i.find(({name:E,label:m})=>E===a||E===cp(a)||m===a);if(p){if(e.input_overwrite_files===!1)return console.log(`Asset ${a} already exists and overwrite_files is false...`),null;console.log(`\u267B\uFE0F Deleting previously uploaded asset ${a}...`),await t.deleteReleaseAsset({asset_id:p.id||1,owner:o,repo:n})}console.log(`\u2B06\uFE0F Uploading ${a}...`);let g=new URL(s);g.searchParams.append("name",a);let h=async()=>{let E=await(0,vw.open)(r);try{return await t.uploadReleaseAsset({url:g.toString(),size:c,mime:A,token:e.github_token,data:E.readableWebStream({type:"bytes"})})}finally{await E.close()}};try{let E=await h(),m=E.data;if(E.status!==201)throw new Error(`Failed to upload release asset ${a}. received status code ${E.status} ${m.message} ${JSON.stringify(m.errors)}`);if(m.name&&m.name!==a&&m.id){console.log(`\u270F\uFE0F Restoring asset label to ${a}...`);try{let{data:d}=await t.updateReleaseAsset({owner:o,repo:n,asset_id:m.id,name:m.name,label:a});return console.log(`\u2705 Uploaded ${a}`),d}catch(d){console.warn(`error updating release asset label for ${a}: ${d}`)}}return console.log(`\u2705 Uploaded ${a}`),m}catch(E){let m=E?.status??E?.response?.status,d=E?.response?.data;if(e.input_overwrite_files!==!1&&m===422&&d?.errors?.[0]?.code==="already_exists"&&l!==void 0){console.log(`\u26A0\uFE0F Asset ${a} already exists (race condition), refreshing assets and retrying once...`);let C=(await t.listReleaseAssets({owner:o,repo:n,release_id:l})).find(({name:B})=>B==cp(a));if(C){await t.deleteReleaseAsset({owner:o,repo:n,asset_id:C.id});let B=await h(),b=B.data;if(B.status!==201)throw new Error(`Failed to upload release asset ${a}. received status code ${B.status} ${b.message} -${JSON.stringify(b.errors)}`);return console.log(`\u2705 Uploaded ${a}`),b}}throw E}},lp=async(e,t,s=3)=>{if(s<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[r,i]=e.github_repository.split("/"),o=Ap(e.input_tag_name)||(fo(e.github_ref)?e.github_ref.replace("refs/tags/",""):""),n=e.input_discussion_category_name,a=e.input_generate_release_notes;try{let A=await Tw(t,r,i,o);if(A===void 0)return await yw(o,e,t,r,i,n,a,s);let c=A;console.log(`Found release ${c.name} (with id=${c.id})`);let u=c.id,l;e.input_target_commitish&&e.input_target_commitish!==c.target_commitish?(console.log(`Updating commit from "${c.target_commitish}" to "${e.input_target_commitish}"`),l=e.input_target_commitish):l=c.target_commitish;let p=o,g=e.input_name||c.name||o,h=ap(e)||"",E=c.body||"",m;e.input_append_body&&h&&E?m=E+` -`+h:m=h||E;let d=e.input_prerelease!==void 0?e.input_prerelease:c.prerelease,f=e.input_make_latest;return{release:(await t.updateRelease({owner:r,repo:i,release_id:u,tag_name:p,target_commitish:l,name:g,body:m,draft:c.draft,prerelease:d,discussion_category_name:n,generate_release_notes:a,make_latest:f})).data,created:!1}}catch(A){if(A.status!==404)throw console.log(`\u26A0\uFE0F Unexpected error fetching GitHub release for tag ${e.github_ref}: ${A}`),A;return await yw(o,e,t,r,i,n,a,s)}},up=async(e,t,s,r=!1,i=3)=>{if(e.input_draft===!0||s.draft===!1)return s;if(i<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[o,n]=e.github_repository.split("/");try{let{data:a}=await t.finalizeRelease({owner:o,repo:n,release_id:s.id,make_latest:e.input_make_latest});return a}catch(a){if(console.warn(`error finalizing release: ${a}`),r&&s.draft&&P_(a)){let A=!1;try{console.log(`\u{1F9F9} Deleting draft release ${s.id} for tag ${s.tag_name} because tag creation is blocked by repository rules...`),await t.deleteRelease({owner:o,repo:n,release_id:s.id}),A=!0}catch(u){console.warn(`error deleting orphan draft release ${s.id}: ${u}`)}let c=A?`Deleted draft release ${s.id} to avoid leaving an orphaned draft release.`:`Failed to delete draft release ${s.id}; manual cleanup may still be required.`;throw new Error(`Tag creation for ${s.tag_name} is blocked by repository rules. ${c}`)}return console.log(`retrying... (${i-1} retries remaining)`),up(e,t,s,r,i-1)}},pp=async(e,t,s,r=3)=>{if(r<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[i,o]=e.github_repository.split("/");try{return await t.listReleaseAssets({owner:i,repo:o,release_id:s.id})}catch(n){return console.warn(`error listing assets of release: ${n}`),console.log(`retrying... (${r-1} retries remaining)`),pp(e,t,s,r-1)}};async function Tw(e,t,s,r){try{let{data:i}=await e.getReleaseByTag({owner:t,repo:s,tag:r});return i}catch(i){if(i.status===404)return;throw i}}var G_=1e3,M_=2;async function L_(e){await new Promise(t=>setTimeout(t,e))}async function __(e,t,s,r){let i=[],o=0;for await(let n of e.allReleases({owner:t,repo:s}))if(i.push(...n.data.filter(a=>a.tag_name===r)),o+=1,o>=M_)break;return i}function Y_(e,t){return t&&e.some(s=>s.id===t.id)||e.length===0?t:[...e].sort((s,r)=>s.draft!==r.draft?Number(s.draft)-Number(r.draft):s.id-r.id)[0]}async function O_(e,t,s,r,i,o){let n=Array.from(new Map(o.map(a=>[a.id,a])).values());for(let a of n)if(!(a.id===i||!a.draft||a.assets.length>0))try{console.log(`\u{1F9F9} Removing duplicate draft release ${a.id} for tag ${r}...`),await e.deleteRelease({owner:t,repo:s,release_id:a.id})}catch(A){console.warn(`error deleting duplicate release ${a.id}: ${A}`)}}async function J_(e,t,s,r,i,o){let n=Math.max(o,1);for(let a=1;a<=n;a+=1){let A;try{A=await Tw(e,t,s,r)}catch(l){console.warn(`error reloading release for tag ${r}: ${l}`)}let c=[];try{c=await __(e,t,s,r)}catch(l){console.warn(`error listing recent releases for tag ${r}: ${l}`)}let u=Y_(c,A);if(u)return u.id!==i.id&&console.log(`\u21AA\uFE0F Using release ${u.id} for tag ${r} instead of duplicate draft ${i.id}`),await O_(e,t,s,r,u.id,[i,...c]),u;as==="pre_receive"&&typeof r=="string"&&r.includes("creations being restricted"))}var Fw=require("process");async function H_(){try{let e=Cw(Fw.env);if(!e.input_tag_name&&!fo(e.github_ref)&&!e.input_draft)throw new Error("\u26A0\uFE0F GitHub Releases requires a tag");if(e.input_files){let a=bw(e.input_files,e.input_working_directory);if(a.forEach(A=>{if(e.input_fail_on_unmatched_files)throw new Error(`\u26A0\uFE0F Pattern '${A}' does not match any files.`);console.warn(`\u{1F914} Pattern '${A}' does not match any files.`)}),a.length>0&&e.input_fail_on_unmatched_files)throw new Error("\u26A0\uFE0F There were unmatched files")}let t=ZC(e.github_token,{throttle:{onRateLimit:(a,A)=>{if(console.warn(`Request quota exhausted for request ${A.method} ${A.url}`),A.request.retryCount===0)return console.log(`Retrying after ${a} seconds!`),!0},onAbuseLimit:(a,A)=>{console.warn(`Abuse detected for request ${A.method} ${A.url}`)}}}),s=new Za(t),r=await lp(e,s),i=r.release,o=r.created,n=new Set;if(e.input_files&&e.input_files.length>0){let a=ww(e.input_files,e.input_working_directory);if(a.length==0){if(e.input_fail_on_unmatched_files)throw new Error(`\u26A0\uFE0F ${e.input_files} does not include a valid file.`);console.warn(`\u{1F914} ${e.input_files} does not include a valid file.`)}let A=i.assets,c=async l=>{let p=await Rw(e,s,Bw(i.upload_url),l,A);return p?p.id:void 0},u;if(!e.input_preserve_order)u=await Promise.all(a.map(c));else{u=[];for(let l of a)u.push(await c(l))}n=new Set(u.filter(l=>l!==void 0))}console.log("Finalizing release..."),i=await up(e,s,i,o),console.log("Getting assets list...");{let a=[];n.size>0&&(a=(await pp(e,s,i)).filter(c=>n.has(c.id)).map(c=>{let{uploader:u,...l}=c;return l})),eo("assets",a)}console.log(`\u{1F389} Release ready at ${i.html_url}`),eo("url",i.html_url),eo("id",i.id.toString()),eo("upload_url",i.upload_url)}catch(e){eC(e.message)}}H_(); +${JSON.stringify(b.errors)}`);return console.log(`\u2705 Uploaded ${a}`),b}}throw E}},lp=async(e,t,s=3)=>{if(s<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[r,i]=e.github_repository.split("/"),o=Ap(e.input_tag_name)||(fo(e.github_ref)?e.github_ref.replace("refs/tags/",""):""),n=e.input_discussion_category_name,a=e.input_generate_release_notes,A=e.input_previous_tag;a&&A&&console.log(`\u{1F4DD} Generating release notes using previous tag ${A}`);try{let c=await Tw(t,r,i,o);if(c===void 0)return await yw(o,e,t,r,i,n,a,s,A);let u=c;console.log(`Found release ${u.name} (with id=${u.id})`);let l=u.id,p;e.input_target_commitish&&e.input_target_commitish!==u.target_commitish?(console.log(`Updating commit from "${u.target_commitish}" to "${e.input_target_commitish}"`),p=e.input_target_commitish):p=u.target_commitish;let g=o,h=e.input_name||u.name||o,E=ap(e)||"",m=u.body||"",d;e.input_append_body&&E&&m?d=m+` +`+E:d=E||m;let f=e.input_prerelease!==void 0?e.input_prerelease:u.prerelease,C=e.input_make_latest;return{release:(await t.updateRelease({owner:r,repo:i,release_id:l,tag_name:g,target_commitish:p,name:h,body:d,draft:u.draft,prerelease:f,discussion_category_name:n,generate_release_notes:a,make_latest:C,previous_tag_name:A})).data,created:!1}}catch(c){if(c.status!==404)throw console.log(`\u26A0\uFE0F Unexpected error fetching GitHub release for tag ${e.github_ref}: ${c}`),c;return await yw(o,e,t,r,i,n,a,s,A)}},up=async(e,t,s,r=!1,i=3)=>{if(e.input_draft===!0||s.draft===!1)return s;if(i<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[o,n]=e.github_repository.split("/");try{let{data:a}=await t.finalizeRelease({owner:o,repo:n,release_id:s.id,make_latest:e.input_make_latest});return a}catch(a){if(console.warn(`error finalizing release: ${a}`),r&&s.draft&&P_(a)){let A=!1;try{console.log(`\u{1F9F9} Deleting draft release ${s.id} for tag ${s.tag_name} because tag creation is blocked by repository rules...`),await t.deleteRelease({owner:o,repo:n,release_id:s.id}),A=!0}catch(u){console.warn(`error deleting orphan draft release ${s.id}: ${u}`)}let c=A?`Deleted draft release ${s.id} to avoid leaving an orphaned draft release.`:`Failed to delete draft release ${s.id}; manual cleanup may still be required.`;throw new Error(`Tag creation for ${s.tag_name} is blocked by repository rules. ${c}`)}return console.log(`retrying... (${i-1} retries remaining)`),up(e,t,s,r,i-1)}},pp=async(e,t,s,r=3)=>{if(r<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[i,o]=e.github_repository.split("/");try{return await t.listReleaseAssets({owner:i,repo:o,release_id:s.id})}catch(n){return console.warn(`error listing assets of release: ${n}`),console.log(`retrying... (${r-1} retries remaining)`),pp(e,t,s,r-1)}};async function Tw(e,t,s,r){try{let{data:i}=await e.getReleaseByTag({owner:t,repo:s,tag:r});return i}catch(i){if(i.status===404)return;throw i}}var G_=1e3,M_=2;async function L_(e){await new Promise(t=>setTimeout(t,e))}async function __(e,t,s,r){let i=[],o=0;for await(let n of e.allReleases({owner:t,repo:s}))if(i.push(...n.data.filter(a=>a.tag_name===r)),o+=1,o>=M_)break;return i}function Y_(e,t){return t&&e.some(s=>s.id===t.id)||e.length===0?t:[...e].sort((s,r)=>s.draft!==r.draft?Number(s.draft)-Number(r.draft):s.id-r.id)[0]}async function O_(e,t,s,r,i,o){let n=Array.from(new Map(o.map(a=>[a.id,a])).values());for(let a of n)if(!(a.id===i||!a.draft||a.assets.length>0))try{console.log(`\u{1F9F9} Removing duplicate draft release ${a.id} for tag ${r}...`),await e.deleteRelease({owner:t,repo:s,release_id:a.id})}catch(A){console.warn(`error deleting duplicate release ${a.id}: ${A}`)}}async function J_(e,t,s,r,i,o){let n=Math.max(o,1);for(let a=1;a<=n;a+=1){let A;try{A=await Tw(e,t,s,r)}catch(l){console.warn(`error reloading release for tag ${r}: ${l}`)}let c=[];try{c=await __(e,t,s,r)}catch(l){console.warn(`error listing recent releases for tag ${r}: ${l}`)}let u=Y_(c,A);if(u)return u.id!==i.id&&console.log(`\u21AA\uFE0F Using release ${u.id} for tag ${r} instead of duplicate draft ${i.id}`),await O_(e,t,s,r,u.id,[i,...c]),u;as==="pre_receive"&&typeof r=="string"&&r.includes("creations being restricted"))}var Fw=require("process");async function H_(){try{let e=Cw(Fw.env);if(!e.input_tag_name&&!fo(e.github_ref)&&!e.input_draft)throw new Error("\u26A0\uFE0F GitHub Releases requires a tag");if(e.input_files){let a=bw(e.input_files,e.input_working_directory);if(a.forEach(A=>{if(e.input_fail_on_unmatched_files)throw new Error(`\u26A0\uFE0F Pattern '${A}' does not match any files.`);console.warn(`\u{1F914} Pattern '${A}' does not match any files.`)}),a.length>0&&e.input_fail_on_unmatched_files)throw new Error("\u26A0\uFE0F There were unmatched files")}let t=ZC(e.github_token,{throttle:{onRateLimit:(a,A)=>{if(console.warn(`Request quota exhausted for request ${A.method} ${A.url}`),A.request.retryCount===0)return console.log(`Retrying after ${a} seconds!`),!0},onAbuseLimit:(a,A)=>{console.warn(`Abuse detected for request ${A.method} ${A.url}`)}}}),s=new Za(t),r=await lp(e,s),i=r.release,o=r.created,n=new Set;if(e.input_files&&e.input_files.length>0){let a=ww(e.input_files,e.input_working_directory);if(a.length==0){if(e.input_fail_on_unmatched_files)throw new Error(`\u26A0\uFE0F ${e.input_files} does not include a valid file.`);console.warn(`\u{1F914} ${e.input_files} does not include a valid file.`)}let A=i.assets,c=async l=>{let p=await Rw(e,s,Bw(i.upload_url),l,A);return p?p.id:void 0},u;if(!e.input_preserve_order)u=await Promise.all(a.map(c));else{u=[];for(let l of a)u.push(await c(l))}n=new Set(u.filter(l=>l!==void 0))}console.log("Finalizing release..."),i=await up(e,s,i,o),console.log("Getting assets list...");{let a=[];n.size>0&&(a=(await pp(e,s,i)).filter(c=>n.has(c.id)).map(c=>{let{uploader:u,...l}=c;return l})),eo("assets",a)}console.log(`\u{1F389} Release ready at ${i.html_url}`),eo("url",i.html_url),eo("id",i.id.toString()),eo("upload_url",i.upload_url)}catch(e){eC(e.message)}}H_(); /*! Bundled license information: undici/lib/web/fetch/body.js: diff --git a/src/github.ts b/src/github.ts index 30e47a4..d2f038c 100644 --- a/src/github.ts +++ b/src/github.ts @@ -31,37 +31,40 @@ export interface ReleaseResult { created: boolean; } +type ReleaseNotesParams = { + owner: string; + repo: string; + tag_name: string; + target_commitish: string | undefined; + previous_tag_name?: string; +}; + +type ReleaseMutationParams = { + owner: string; + repo: string; + tag_name: string; + name: string; + body: string | undefined; + draft: boolean | undefined; + prerelease: boolean | undefined; + target_commitish: string | undefined; + discussion_category_name: string | undefined; + generate_release_notes: boolean | undefined; + make_latest: 'true' | 'false' | 'legacy' | undefined; + previous_tag_name?: string; +}; + export interface Releaser { getReleaseByTag(params: { owner: string; repo: string; tag: string }): Promise<{ data: Release }>; - createRelease(params: { - owner: string; - repo: string; - tag_name: string; - name: string; - body: string | undefined; - draft: boolean | undefined; - prerelease: boolean | undefined; - target_commitish: string | undefined; - discussion_category_name: string | undefined; - generate_release_notes: boolean | undefined; - make_latest: 'true' | 'false' | 'legacy' | undefined; - }): Promise<{ data: Release }>; + createRelease(params: ReleaseMutationParams): Promise<{ data: Release }>; - updateRelease(params: { - owner: string; - repo: string; - release_id: number; - tag_name: string; - target_commitish: string; - name: string; - body: string | undefined; - draft: boolean | undefined; - prerelease: boolean | undefined; - discussion_category_name: string | undefined; - generate_release_notes: boolean | undefined; - make_latest: 'true' | 'false' | 'legacy' | undefined; - }): Promise<{ data: Release }>; + updateRelease( + params: ReleaseMutationParams & { + release_id: number; + target_commitish: string; + }, + ): Promise<{ data: Release }>; finalizeRelease(params: { owner: string; @@ -113,12 +116,7 @@ export class GitHubReleaser implements Releaser { return this.github.rest.repos.getReleaseByTag(params); } - async getReleaseNotes(params: { - owner: string; - repo: string; - tag_name: string; - target_commitish: string | undefined; - }): Promise<{ + async getReleaseNotes(params: ReleaseNotesParams): Promise<{ data: { name: string; body: string; @@ -127,75 +125,55 @@ export class GitHubReleaser implements Releaser { return await this.github.rest.repos.generateReleaseNotes(params); } + private async prepareReleaseMutation( + params: T, + ): Promise> { + const { previous_tag_name, ...releaseParams } = params; + + if ( + typeof releaseParams.make_latest === 'string' && + !['true', 'false', 'legacy'].includes(releaseParams.make_latest) + ) { + releaseParams.make_latest = undefined; + } + if (releaseParams.generate_release_notes) { + const releaseNotes = await this.getReleaseNotes({ + owner: releaseParams.owner, + repo: releaseParams.repo, + tag_name: releaseParams.tag_name, + target_commitish: releaseParams.target_commitish, + previous_tag_name, + }); + releaseParams.generate_release_notes = false; + if (releaseParams.body) { + releaseParams.body = `${releaseParams.body}\n\n${releaseNotes.data.body}`; + } else { + releaseParams.body = releaseNotes.data.body; + } + } + releaseParams.body = releaseParams.body + ? this.truncateReleaseNotes(releaseParams.body) + : undefined; + return releaseParams; + } + truncateReleaseNotes(input: string): string { // release notes can be a maximum of 125000 characters const githubNotesMaxCharLength = 125000; return input.substring(0, githubNotesMaxCharLength - 1); } - async createRelease(params: { - owner: string; - repo: string; - tag_name: string; - name: string; - body: string | undefined; - draft: boolean | undefined; - prerelease: boolean | undefined; - target_commitish: string | undefined; - discussion_category_name: string | undefined; - generate_release_notes: boolean | undefined; - make_latest: 'true' | 'false' | 'legacy' | undefined; - }): Promise<{ data: Release }> { - if ( - typeof params.make_latest === 'string' && - !['true', 'false', 'legacy'].includes(params.make_latest) - ) { - params.make_latest = undefined; - } - if (params.generate_release_notes) { - const releaseNotes = await this.getReleaseNotes(params); - params.generate_release_notes = false; - if (params.body) { - params.body = `${params.body}\n\n${releaseNotes.data.body}`; - } else { - params.body = releaseNotes.data.body; - } - } - params.body = params.body ? this.truncateReleaseNotes(params.body) : undefined; - return this.github.rest.repos.createRelease(params); + async createRelease(params: ReleaseMutationParams): Promise<{ data: Release }> { + return this.github.rest.repos.createRelease(await this.prepareReleaseMutation(params)); } - async updateRelease(params: { - owner: string; - repo: string; - release_id: number; - tag_name: string; - target_commitish: string; - name: string; - body: string | undefined; - draft: boolean | undefined; - prerelease: boolean | undefined; - discussion_category_name: string | undefined; - generate_release_notes: boolean | undefined; - make_latest: 'true' | 'false' | 'legacy' | undefined; - }): Promise<{ data: Release }> { - if ( - typeof params.make_latest === 'string' && - !['true', 'false', 'legacy'].includes(params.make_latest) - ) { - params.make_latest = undefined; - } - if (params.generate_release_notes) { - const releaseNotes = await this.getReleaseNotes(params); - params.generate_release_notes = false; - if (params.body) { - params.body = `${params.body}\n\n${releaseNotes.data.body}`; - } else { - params.body = releaseNotes.data.body; - } - } - params.body = params.body ? this.truncateReleaseNotes(params.body) : undefined; - return this.github.rest.repos.updateRelease(params); + async updateRelease( + params: ReleaseMutationParams & { + release_id: number; + target_commitish: string; + }, + ): Promise<{ data: Release }> { + return this.github.rest.repos.updateRelease(await this.prepareReleaseMutation(params)); } async finalizeRelease(params: { @@ -425,6 +403,11 @@ export const release = async ( const discussion_category_name = config.input_discussion_category_name; const generate_release_notes = config.input_generate_release_notes; + const previous_tag_name = config.input_previous_tag; + + if (generate_release_notes && previous_tag_name) { + console.log(`📝 Generating release notes using previous tag ${previous_tag_name}`); + } try { const _release: Release | undefined = await findTagFromReleases(releaser, owner, repo, tag); @@ -438,6 +421,7 @@ export const release = async ( discussion_category_name, generate_release_notes, maxRetries, + previous_tag_name, ); } @@ -491,6 +475,7 @@ export const release = async ( discussion_category_name, generate_release_notes, make_latest, + previous_tag_name, }); return { release: release.data, @@ -513,6 +498,7 @@ export const release = async ( discussion_category_name, generate_release_notes, maxRetries, + previous_tag_name, ); } }; @@ -796,6 +782,7 @@ async function createRelease( discussion_category_name: string | undefined, generate_release_notes: boolean | undefined, maxRetries: number, + previous_tag_name: string | undefined, ): Promise { const tag_name = tag; const name = config.input_name || tag; @@ -822,6 +809,7 @@ async function createRelease( discussion_category_name, generate_release_notes, make_latest, + previous_tag_name, }); const canonicalRelease = await canonicalizeCreatedRelease( releaser, diff --git a/src/util.ts b/src/util.ts index 69de83c..49a81d9 100644 --- a/src/util.ts +++ b/src/util.ts @@ -23,6 +23,7 @@ export interface Config { input_target_commitish?: string; input_discussion_category_name?: string; input_generate_release_notes?: boolean; + input_previous_tag?: string; input_append_body?: boolean; input_make_latest: 'true' | 'false' | 'legacy' | undefined; } @@ -114,6 +115,7 @@ export const parseConfig = (env: Env): Config => { input_target_commitish: env.INPUT_TARGET_COMMITISH || undefined, input_discussion_category_name: env.INPUT_DISCUSSION_CATEGORY_NAME || undefined, input_generate_release_notes: env.INPUT_GENERATE_RELEASE_NOTES == 'true', + input_previous_tag: env.INPUT_PREVIOUS_TAG?.trim() || undefined, input_append_body: env.INPUT_APPEND_BODY == 'true', input_make_latest: parseMakeLatest(env.INPUT_MAKE_LATEST), };