From 6a3c7f870cfdb531816b7deef24cd5f3c87357fc Mon Sep 17 00:00:00 2001 From: "fro-bot[bot]" <109017866+fro-bot[bot]@users.noreply.github.com> Date: Fri, 27 Mar 2026 17:43:46 -0700 Subject: [PATCH 1/6] chore(deps): update pnpm to v10.33.0 (#389) Co-authored-by: fro-bot[bot] <109017866+fro-bot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dd866722..a30e2aea 100644 --- a/package.json +++ b/package.json @@ -70,5 +70,5 @@ "typescript": "5.9.3", "vitest": "4.1.0" }, - "packageManager": "pnpm@10.32.1" + "packageManager": "pnpm@10.33.0" } From afa20ea67c778f3fd3594eb91ca5b6efb4ca98a7 Mon Sep 17 00:00:00 2001 From: "fro-bot[bot]" <109017866+fro-bot[bot]@users.noreply.github.com> Date: Sat, 28 Mar 2026 03:17:39 -0700 Subject: [PATCH 2/6] ci(deps): update github/codeql-action action to v4.35.1 (#388) Co-authored-by: fro-bot[bot] <109017866+fro-bot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yaml | 6 +++--- .github/workflows/scorecard.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml index ad0705b5..3f6fd19c 100644 --- a/.github/workflows/codeql-analysis.yaml +++ b/.github/workflows/codeql-analysis.yaml @@ -27,15 +27,15 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Initialize CodeQL - uses: github/codeql-action/init@b8bb9f28b8d3f992092362369c57161b755dea45 # v4.35.0 + uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1 with: languages: javascript queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@b8bb9f28b8d3f992092362369c57161b755dea45 # v4.35.0 + uses: github/codeql-action/autobuild@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@b8bb9f28b8d3f992092362369c57161b755dea45 # v4.35.0 + uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1 with: category: '/language:javascript' diff --git a/.github/workflows/scorecard.yaml b/.github/workflows/scorecard.yaml index b430b689..e34c5f54 100644 --- a/.github/workflows/scorecard.yaml +++ b/.github/workflows/scorecard.yaml @@ -65,6 +65,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: Upload to code-scanning - uses: github/codeql-action/upload-sarif@b8bb9f28b8d3f992092362369c57161b755dea45 # v4.35.0 + uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1 with: sarif_file: results.sarif From 70b1465328856897f6e9aa6f882790d030551803 Mon Sep 17 00:00:00 2001 From: "fro-bot[bot]" <109017866+fro-bot[bot]@users.noreply.github.com> Date: Sat, 28 Mar 2026 05:21:47 -0700 Subject: [PATCH 3/6] chore(dev): update dependency @vitest/eslint-plugin to v1.6.13 (#382) Co-authored-by: fro-bot[bot] <109017866+fro-bot[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index a30e2aea..b829d541 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@semantic-release/exec": "7.1.0", "@semantic-release/git": "10.0.1", "@types/node": "24.10.13", - "@vitest/eslint-plugin": "1.6.12", + "@vitest/eslint-plugin": "1.6.13", "conventional-changelog-conventionalcommits": "9.3.0", "eslint": "10.1.0", "eslint-config-prettier": "10.1.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 934742e3..04bd07d2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,7 +41,7 @@ importers: devDependencies: '@bfra.me/eslint-config': specifier: 0.50.1 - version: 0.50.1(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/rule-tester@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/typescript-estree@8.57.0(typescript@5.9.3))(@typescript-eslint/utils@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@vitest/eslint-plugin@1.6.12(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))))(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint-plugin-prettier@5.5.5(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint@10.1.0(jiti@2.6.1))(prettier@3.8.1))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) + version: 0.50.1(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/rule-tester@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/typescript-estree@8.57.0(typescript@5.9.3))(@typescript-eslint/utils@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@vitest/eslint-plugin@1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))))(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint-plugin-prettier@5.5.5(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint@10.1.0(jiti@2.6.1))(prettier@3.8.1))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) '@bfra.me/prettier-config': specifier: 0.16.7 version: 0.16.7(prettier@3.8.1) @@ -61,8 +61,8 @@ importers: specifier: 24.10.13 version: 24.10.13 '@vitest/eslint-plugin': - specifier: 1.6.12 - version: 1.6.12(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))) + specifier: 1.6.13 + version: 1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))) conventional-changelog-conventionalcommits: specifier: 9.3.0 version: 9.3.0 @@ -1332,14 +1332,17 @@ packages: cpu: [x64] os: [win32] - '@vitest/eslint-plugin@1.6.12': - resolution: {integrity: sha512-4kI47BJNFE+EQ5bmPbHzBF+ibNzx2Fj0Jo9xhWsTPxMddlHwIWl6YAxagefh461hrwx/W0QwBZpxGS404kBXyg==} + '@vitest/eslint-plugin@1.6.13': + resolution: {integrity: sha512-ui7JGWBoQpS5NKKW0FDb1eTuFEZ5EupEv2Psemuyfba7DfA5K52SeDLelt6P4pQJJ/4UGkker/BgMk/KrjH3WQ==} engines: {node: '>=18'} peerDependencies: + '@typescript-eslint/eslint-plugin': '*' eslint: '>=8.57.0' typescript: '>=5.0.0' vitest: '*' peerDependenciesMeta: + '@typescript-eslint/eslint-plugin': + optional: true typescript: optional: true vitest: @@ -4251,7 +4254,7 @@ snapshots: dependencies: is-in-ci: 2.0.0 - '@bfra.me/eslint-config@0.50.1(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/rule-tester@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/typescript-estree@8.57.0(typescript@5.9.3))(@typescript-eslint/utils@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@vitest/eslint-plugin@1.6.12(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))))(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint-plugin-prettier@5.5.5(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint@10.1.0(jiti@2.6.1))(prettier@3.8.1))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)': + '@bfra.me/eslint-config@0.50.1(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/rule-tester@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/typescript-estree@8.57.0(typescript@5.9.3))(@typescript-eslint/utils@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@vitest/eslint-plugin@1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))))(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint-plugin-prettier@5.5.5(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint@10.1.0(jiti@2.6.1))(prettier@3.8.1))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)': dependencies: '@bfra.me/es': 0.1.0 '@eslint-community/eslint-plugin-eslint-comments': 4.6.0(eslint@10.1.0(jiti@2.6.1)) @@ -4280,7 +4283,7 @@ snapshots: sort-package-json: 3.6.1 typescript-eslint: 8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) optionalDependencies: - '@vitest/eslint-plugin': 1.6.12(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))) + '@vitest/eslint-plugin': 1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))) eslint-config-prettier: 10.1.8(eslint@10.1.0(jiti@2.6.1)) eslint-plugin-prettier: 5.5.5(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint@10.1.0(jiti@2.6.1))(prettier@3.8.1) transitivePeerDependencies: @@ -5347,12 +5350,13 @@ snapshots: '@unrs/resolver-binding-win32-x64-msvc@1.11.1': optional: true - '@vitest/eslint-plugin@1.6.12(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)))': + '@vitest/eslint-plugin@1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)))': dependencies: '@typescript-eslint/scope-manager': 8.57.0 '@typescript-eslint/utils': 8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) eslint: 10.1.0(jiti@2.6.1) optionalDependencies: + '@typescript-eslint/eslint-plugin': 8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) typescript: 5.9.3 vitest: 4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)) transitivePeerDependencies: From 42cba0de5951d984ae35875c7e7e64f29244e20b Mon Sep 17 00:00:00 2001 From: "fro-bot[bot]" <109017866+fro-bot[bot]@users.noreply.github.com> Date: Sat, 28 Mar 2026 05:34:41 -0700 Subject: [PATCH 4/6] chore(dev): update dependency vitest to v4.1.1 (#385) Co-authored-by: fro-bot[bot] <109017866+fro-bot[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 104 ++++++++++++++++++++++++------------------------- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index b829d541..b0125b51 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "simple-git-hooks": "2.13.1", "tsdown": "0.21.4", "typescript": "5.9.3", - "vitest": "4.1.0" + "vitest": "4.1.1" }, "packageManager": "pnpm@10.33.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 04bd07d2..46e45a26 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,7 +41,7 @@ importers: devDependencies: '@bfra.me/eslint-config': specifier: 0.50.1 - version: 0.50.1(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/rule-tester@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/typescript-estree@8.57.0(typescript@5.9.3))(@typescript-eslint/utils@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@vitest/eslint-plugin@1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))))(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint-plugin-prettier@5.5.5(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint@10.1.0(jiti@2.6.1))(prettier@3.8.1))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) + version: 0.50.1(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/rule-tester@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/typescript-estree@8.57.0(typescript@5.9.3))(@typescript-eslint/utils@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@vitest/eslint-plugin@1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.1(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))))(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint-plugin-prettier@5.5.5(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint@10.1.0(jiti@2.6.1))(prettier@3.8.1))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) '@bfra.me/prettier-config': specifier: 0.16.7 version: 0.16.7(prettier@3.8.1) @@ -62,7 +62,7 @@ importers: version: 24.10.13 '@vitest/eslint-plugin': specifier: 1.6.13 - version: 1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))) + version: 1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.1(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))) conventional-changelog-conventionalcommits: specifier: 9.3.0 version: 9.3.0 @@ -106,8 +106,8 @@ importers: specifier: 5.9.3 version: 5.9.3 vitest: - specifier: 4.1.0 - version: 4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)) + specifier: 4.1.1 + version: 4.1.1(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)) packages: @@ -1348,34 +1348,34 @@ packages: vitest: optional: true - '@vitest/expect@4.1.0': - resolution: {integrity: sha512-EIxG7k4wlWweuCLG9Y5InKFwpMEOyrMb6ZJ1ihYu02LVj/bzUwn2VMU+13PinsjRW75XnITeFrQBMH5+dLvCDA==} + '@vitest/expect@4.1.1': + resolution: {integrity: sha512-xAV0fqBTk44Rn6SjJReEQkHP3RrqbJo6JQ4zZ7/uVOiJZRarBtblzrOfFIZeYUrukp2YD6snZG6IBqhOoHTm+A==} - '@vitest/mocker@4.1.0': - resolution: {integrity: sha512-evxREh+Hork43+Y4IOhTo+h5lGmVRyjqI739Rz4RlUPqwrkFFDF6EMvOOYjTx4E8Tl6gyCLRL8Mu7Ry12a13Tw==} + '@vitest/mocker@4.1.1': + resolution: {integrity: sha512-h3BOylsfsCLPeceuCPAAJ+BvNwSENgJa4hXoXu4im0bs9Lyp4URc4JYK4pWLZ4pG/UQn7AT92K6IByi6rE6g3A==} peerDependencies: msw: ^2.4.9 - vite: ^6.0.0 || ^7.0.0 || ^8.0.0-0 + vite: ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: msw: optional: true vite: optional: true - '@vitest/pretty-format@4.1.0': - resolution: {integrity: sha512-3RZLZlh88Ib0J7NQTRATfc/3ZPOnSUn2uDBUoGNn5T36+bALixmzphN26OUD3LRXWkJu4H0s5vvUeqBiw+kS0A==} + '@vitest/pretty-format@4.1.1': + resolution: {integrity: sha512-GM+TEQN5WhOygr1lp7skeVjdLPqqWMHsfzXrcHAqZJi/lIVh63H0kaRCY8MDhNWikx19zBUK8ceaLB7X5AH9NQ==} - '@vitest/runner@4.1.0': - resolution: {integrity: sha512-Duvx2OzQ7d6OjchL+trw+aSrb9idh7pnNfxrklo14p3zmNL4qPCDeIJAK+eBKYjkIwG96Bc6vYuxhqDXQOWpoQ==} + '@vitest/runner@4.1.1': + resolution: {integrity: sha512-f7+FPy75vN91QGWsITueq0gedwUZy1fLtHOCMeQpjs8jTekAHeKP80zfDEnhrleviLHzVSDXIWuCIOFn3D3f8A==} - '@vitest/snapshot@4.1.0': - resolution: {integrity: sha512-0Vy9euT1kgsnj1CHttwi9i9o+4rRLEaPRSOJ5gyv579GJkNpgJK+B4HSv/rAWixx2wdAFci1X4CEPjiu2bXIMg==} + '@vitest/snapshot@4.1.1': + resolution: {integrity: sha512-kMVSgcegWV2FibXEx9p9WIKgje58lcTbXgnJixfcg15iK8nzCXhmalL0ZLtTWLW9PH1+1NEDShiFFedB3tEgWg==} - '@vitest/spy@4.1.0': - resolution: {integrity: sha512-pz77k+PgNpyMDv2FV6qmk5ZVau6c3R8HC8v342T2xlFxQKTrSeYw9waIJG8KgV9fFwAtTu4ceRzMivPTH6wSxw==} + '@vitest/spy@4.1.1': + resolution: {integrity: sha512-6Ti/KT5OVaiupdIZEuZN7l3CZcR0cxnxt70Z0//3CtwgObwA6jZhmVBA3yrXSVN3gmwjgd7oDNLlsXz526gpRA==} - '@vitest/utils@4.1.0': - resolution: {integrity: sha512-XfPXT6a8TZY3dcGY8EdwsBulFCIw+BeeX0RZn2x/BtiY/75YGh8FeWGG8QISN/WhaqSrE2OrlDgtF8q5uhOTmw==} + '@vitest/utils@4.1.1': + resolution: {integrity: sha512-cNxAlaB3sHoCdL6pj6yyUXv9Gry1NHNg0kFTXdvSIZXLHsqKH7chiWOkwJ5s5+d/oMwcoG9T0bKU38JZWKusrQ==} abbrev@4.0.0: resolution: {integrity: sha512-a1wflyaL0tHtJSmLSOVybYhy22vRih4eduhhrkcjgrWGnRfrZtovJ2FRjxuTtkkj47O/baf0R86QU5OuYpz8fA==} @@ -3914,21 +3914,21 @@ packages: yaml: optional: true - vitest@4.1.0: - resolution: {integrity: sha512-YbDrMF9jM2Lqc++2530UourxZHmkKLxrs4+mYhEwqWS97WJ7wOYEkcr+QfRgJ3PW9wz3odRijLZjHEaRLTNbqw==} + vitest@4.1.1: + resolution: {integrity: sha512-yF+o4POL41rpAzj5KVILUxm1GCjKnELvaqmU9TLLUbMfDzuN0UpUR9uaDs+mCtjPe+uYPksXDRLQGGPvj1cTmA==} engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' '@opentelemetry/api': ^1.9.0 '@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0 - '@vitest/browser-playwright': 4.1.0 - '@vitest/browser-preview': 4.1.0 - '@vitest/browser-webdriverio': 4.1.0 - '@vitest/ui': 4.1.0 + '@vitest/browser-playwright': 4.1.1 + '@vitest/browser-preview': 4.1.1 + '@vitest/browser-webdriverio': 4.1.1 + '@vitest/ui': 4.1.1 happy-dom: '*' jsdom: '*' - vite: ^6.0.0 || ^7.0.0 || ^8.0.0-0 + vite: ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: '@edge-runtime/vm': optional: true @@ -4254,7 +4254,7 @@ snapshots: dependencies: is-in-ci: 2.0.0 - '@bfra.me/eslint-config@0.50.1(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/rule-tester@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/typescript-estree@8.57.0(typescript@5.9.3))(@typescript-eslint/utils@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@vitest/eslint-plugin@1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))))(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint-plugin-prettier@5.5.5(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint@10.1.0(jiti@2.6.1))(prettier@3.8.1))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)': + '@bfra.me/eslint-config@0.50.1(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/rule-tester@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@typescript-eslint/typescript-estree@8.57.0(typescript@5.9.3))(@typescript-eslint/utils@8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(@vitest/eslint-plugin@1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.1(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))))(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint-plugin-prettier@5.5.5(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint@10.1.0(jiti@2.6.1))(prettier@3.8.1))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)': dependencies: '@bfra.me/es': 0.1.0 '@eslint-community/eslint-plugin-eslint-comments': 4.6.0(eslint@10.1.0(jiti@2.6.1)) @@ -4283,7 +4283,7 @@ snapshots: sort-package-json: 3.6.1 typescript-eslint: 8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) optionalDependencies: - '@vitest/eslint-plugin': 1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))) + '@vitest/eslint-plugin': 1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.1(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))) eslint-config-prettier: 10.1.8(eslint@10.1.0(jiti@2.6.1)) eslint-plugin-prettier: 5.5.5(eslint-config-prettier@10.1.8(eslint@10.1.0(jiti@2.6.1)))(eslint@10.1.0(jiti@2.6.1))(prettier@3.8.1) transitivePeerDependencies: @@ -5350,7 +5350,7 @@ snapshots: '@unrs/resolver-binding-win32-x64-msvc@1.11.1': optional: true - '@vitest/eslint-plugin@1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)))': + '@vitest/eslint-plugin@1.6.13(@typescript-eslint/eslint-plugin@8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3)(vitest@4.1.1(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)))': dependencies: '@typescript-eslint/scope-manager': 8.57.0 '@typescript-eslint/utils': 8.57.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) @@ -5358,48 +5358,48 @@ snapshots: optionalDependencies: '@typescript-eslint/eslint-plugin': 8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) typescript: 5.9.3 - vitest: 4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)) + vitest: 4.1.1(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)) transitivePeerDependencies: - supports-color - '@vitest/expect@4.1.0': + '@vitest/expect@4.1.1': dependencies: '@standard-schema/spec': 1.1.0 '@types/chai': 5.2.3 - '@vitest/spy': 4.1.0 - '@vitest/utils': 4.1.0 + '@vitest/spy': 4.1.1 + '@vitest/utils': 4.1.1 chai: 6.2.2 tinyrainbow: 3.1.0 - '@vitest/mocker@4.1.0(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))': + '@vitest/mocker@4.1.1(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2))': dependencies: - '@vitest/spy': 4.1.0 + '@vitest/spy': 4.1.1 estree-walker: 3.0.3 magic-string: 0.30.21 optionalDependencies: vite: 7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2) - '@vitest/pretty-format@4.1.0': + '@vitest/pretty-format@4.1.1': dependencies: tinyrainbow: 3.1.0 - '@vitest/runner@4.1.0': + '@vitest/runner@4.1.1': dependencies: - '@vitest/utils': 4.1.0 + '@vitest/utils': 4.1.1 pathe: 2.0.3 - '@vitest/snapshot@4.1.0': + '@vitest/snapshot@4.1.1': dependencies: - '@vitest/pretty-format': 4.1.0 - '@vitest/utils': 4.1.0 + '@vitest/pretty-format': 4.1.1 + '@vitest/utils': 4.1.1 magic-string: 0.30.21 pathe: 2.0.3 - '@vitest/spy@4.1.0': {} + '@vitest/spy@4.1.1': {} - '@vitest/utils@4.1.0': + '@vitest/utils@4.1.1': dependencies: - '@vitest/pretty-format': 4.1.0 + '@vitest/pretty-format': 4.1.1 convert-source-map: 2.0.0 tinyrainbow: 3.1.0 @@ -8127,15 +8127,15 @@ snapshots: jiti: 2.6.1 yaml: 2.8.2 - vitest@4.1.0(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)): + vitest@4.1.1(@types/node@24.10.13)(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)): dependencies: - '@vitest/expect': 4.1.0 - '@vitest/mocker': 4.1.0(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)) - '@vitest/pretty-format': 4.1.0 - '@vitest/runner': 4.1.0 - '@vitest/snapshot': 4.1.0 - '@vitest/spy': 4.1.0 - '@vitest/utils': 4.1.0 + '@vitest/expect': 4.1.1 + '@vitest/mocker': 4.1.1(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2)) + '@vitest/pretty-format': 4.1.1 + '@vitest/runner': 4.1.1 + '@vitest/snapshot': 4.1.1 + '@vitest/spy': 4.1.1 + '@vitest/utils': 4.1.1 es-module-lexer: 2.0.0 expect-type: 1.3.0 magic-string: 0.30.21 From 86624082a8ac25312209c9dd13e2a3e674c542eb Mon Sep 17 00:00:00 2001 From: "Marcus R. Brown" Date: Sat, 28 Mar 2026 06:40:01 -0700 Subject: [PATCH 5/6] fix(session): preserve logical thread continuity (#393) * fix(session): preserve logical thread continuity * chore: update action build artifact --- dist/main.js | 68 +++---- ...3-28-session-continuity-post-ship-audit.md | 188 ++++++++++++++++++ src/features/agent/execution.ts | 23 +-- src/features/agent/opencode.test.ts | 65 ++++++ src/features/agent/prompt.test.ts | 50 +++++ src/features/agent/prompt.ts | 11 +- src/harness/phases/execute.ts | 3 + src/services/session/title-reassert.ts | 34 ++++ 8 files changed, 393 insertions(+), 49 deletions(-) create mode 100644 docs/audits/2026-03-28-session-continuity-post-ship-audit.md create mode 100644 src/services/session/title-reassert.ts diff --git a/dist/main.js b/dist/main.js index e6ac94b0..5e8af93a 100644 --- a/dist/main.js +++ b/dist/main.js @@ -123,31 +123,31 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K a `);o=c.pop()??``;for(let e of c){let i=e.split(` `),a=[],o;for(let e of i)if(e.startsWith(`data:`))a.push(e.replace(/^data:\s*/,``));else if(e.startsWith(`event:`))o=e.replace(/^event:\s*/,``);else if(e.startsWith(`id:`))u=e.replace(/^id:\s*/,``);else if(e.startsWith(`retry:`)){let t=Number.parseInt(e.replace(/^retry:\s*/,``),10);Number.isNaN(t)||(s=t)}let c,l=!1;if(a.length){let e=a.join(` -`);try{c=JSON.parse(e),l=!0}catch{c=e}}l&&(r&&await r(c),n&&(c=await n(c))),t?.({data:c,event:o,id:u,retry:s}),a.length&&(yield c)}}}finally{p.removeEventListener(`abort`,d),a.releaseLock()}break}catch(t){if(e?.(t),a!==void 0&&f>=a)break;await d(Math.min(s*2**(f-1),o??3e4))}}}()}},gt=async(e,t)=>{let n=typeof t==`function`?await t(e):t;if(n)return e.scheme===`bearer`?`Bearer ${n}`:e.scheme===`basic`?`Basic ${btoa(n)}`:n},_t={bodySerializer:e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)},vt=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},yt=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},bt=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},xt=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(yt(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=vt(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):B({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},B=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},St=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=bt(r),s=Object.entries(i).map(([t,i])=>B({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Ct=/\{[^{}]+\}/g,wt=({path:e,url:t})=>{let n=t,r=t.match(Ct);if(r)for(let t of r){let r=!1,i=t.substring(1,t.length-1),a=`simple`;i.endsWith(`*`)&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(`.`)?(i=i.substring(1),a=`label`):i.startsWith(`;`)&&(i=i.substring(1),a=`matrix`);let o=e[i];if(o==null)continue;if(Array.isArray(o)){n=n.replace(t,xt({explode:r,name:i,style:a,value:o}));continue}if(typeof o==`object`){n=n.replace(t,St({explode:r,name:i,style:a,value:o,valueOnly:!0}));continue}if(a===`matrix`){n=n.replace(t,`;${B({name:i,value:o})}`);continue}let s=encodeURIComponent(a===`label`?`.${o}`:o);n=n.replace(t,s)}return n},Tt=({baseUrl:e,path:t,query:n,querySerializer:r,url:i})=>{let a=i.startsWith(`/`)?i:`/${i}`,o=(e??``)+a;t&&(o=wt({path:t,url:o}));let s=n?r(n):``;return s.startsWith(`?`)&&(s=s.substring(1)),s&&(o+=`?${s}`),o},Et=({allowReserved:e,array:t,object:n}={})=>r=>{let i=[];if(r&&typeof r==`object`)for(let a in r){let o=r[a];if(o!=null)if(Array.isArray(o)){let n=xt({allowReserved:e,explode:!0,name:a,style:`form`,value:o,...t});n&&i.push(n)}else if(typeof o==`object`){let t=St({allowReserved:e,explode:!0,name:a,style:`deepObject`,value:o,...n});t&&i.push(t)}else{let t=B({allowReserved:e,name:a,value:o});t&&i.push(t)}}return i.join(`&`)},Dt=e=>{if(!e)return`stream`;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if(t===`multipart/form-data`)return`formData`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},Ot=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get(`Cookie`)?.includes(`${t}=`)):!1,kt=async({security:e,...t})=>{for(let n of e){if(Ot(t,n.name))continue;let e=await gt(n,t.auth);if(!e)continue;let r=n.name??`Authorization`;switch(n.in){case`query`:t.query||={},t.query[r]=e;break;case`cookie`:t.headers.append(`Cookie`,`${r}=${e}`);break;default:t.headers.set(r,e);break}}},At=e=>Tt({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==`function`?e.querySerializer:Et(e.querySerializer),url:e.url}),jt=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith(`/`)&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=Mt(e.headers,t.headers),n},Mt=(...e)=>{let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t};var Nt=class{_fns;constructor(){this._fns=[]}clear(){this._fns=[]}getInterceptorIndex(e){return typeof e==`number`?this._fns[e]?e:-1:this._fns.indexOf(e)}exists(e){let t=this.getInterceptorIndex(e);return!!this._fns[t]}eject(e){let t=this.getInterceptorIndex(e);this._fns[t]&&(this._fns[t]=null)}update(e,t){let n=this.getInterceptorIndex(e);return this._fns[n]?(this._fns[n]=t,e):!1}use(e){return this._fns=[...this._fns,e],this._fns.length-1}};const Pt=()=>({error:new Nt,request:new Nt,response:new Nt}),Ft=Et({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),It={"Content-Type":`application/json`},Lt=(e={})=>({..._t,headers:It,parseAs:`auto`,querySerializer:Ft,...e}),Rt=(e={})=>{let t=jt(Lt(),e),n=()=>({...t}),r=e=>(t=jt(t,e),n()),i=Pt(),a=async e=>{let n={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:Mt(t.headers,e.headers),serializedBody:void 0};return n.security&&await kt({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.serializedBody===void 0||n.serializedBody===``)&&n.headers.delete(`Content-Type`),{opts:n,url:At(n)}},o=async e=>{let{opts:t,url:n}=await a(e),r={redirect:`follow`,...t,body:t.serializedBody},o=new Request(n,r);for(let e of i.request._fns)e&&(o=await e(o,t));let s=t.fetch,c=await s(o);for(let e of i.response._fns)e&&(c=await e(c,o,t));let l={request:o,response:c};if(c.ok){if(c.status===204||c.headers.get(`Content-Length`)===`0`)return t.responseStyle===`data`?{}:{data:{},...l};let e=(t.parseAs===`auto`?Dt(c.headers.get(`Content-Type`)):t.parseAs)??`json`,n;switch(e){case`arrayBuffer`:case`blob`:case`formData`:case`json`:case`text`:n=await c[e]();break;case`stream`:return t.responseStyle===`data`?c.body:{data:c.body,...l}}return e===`json`&&(t.responseValidator&&await t.responseValidator(n),t.responseTransformer&&(n=await t.responseTransformer(n))),t.responseStyle===`data`?n:{data:n,...l}}let u=await c.text(),d;try{d=JSON.parse(u)}catch{}let f=d??u,p=f;for(let e of i.error._fns)e&&(p=await e(f,c,o,t));if(p||={},t.throwOnError)throw p;return t.responseStyle===`data`?void 0:{error:p,...l}},s=e=>{let t=t=>o({...t,method:e});return t.sse=async t=>{let{opts:n,url:r}=await a(t);return ht({...n,body:n.body,headers:n.headers,method:e,url:r})},t};return{buildUrl:At,connect:s(`CONNECT`),delete:s(`DELETE`),get:s(`GET`),getConfig:n,head:s(`HEAD`),interceptors:i,options:s(`OPTIONS`),patch:s(`PATCH`),post:s(`POST`),put:s(`PUT`),request:o,setConfig:r,trace:s(`TRACE`)}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const zt=Rt(Lt({baseUrl:`http://localhost:4096`}));var V=class{_client=zt;constructor(e){e?.client&&(this._client=e.client)}},Bt=class extends V{event(e){return(e?.client??this._client).get.sse({url:`/global/event`,...e})}},Vt=class extends V{list(e){return(e?.client??this._client).get({url:`/project`,...e})}current(e){return(e?.client??this._client).get({url:`/project/current`,...e})}},Ht=class extends V{list(e){return(e?.client??this._client).get({url:`/pty`,...e})}create(e){return(e?.client??this._client).post({url:`/pty`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}remove(e){return(e.client??this._client).delete({url:`/pty/{id}`,...e})}get(e){return(e.client??this._client).get({url:`/pty/{id}`,...e})}update(e){return(e.client??this._client).put({url:`/pty/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}connect(e){return(e.client??this._client).get({url:`/pty/{id}/connect`,...e})}},Ut=class extends V{get(e){return(e?.client??this._client).get({url:`/config`,...e})}update(e){return(e?.client??this._client).patch({url:`/config`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}providers(e){return(e?.client??this._client).get({url:`/config/providers`,...e})}},Wt=class extends V{ids(e){return(e?.client??this._client).get({url:`/experimental/tool/ids`,...e})}list(e){return(e.client??this._client).get({url:`/experimental/tool`,...e})}},Gt=class extends V{dispose(e){return(e?.client??this._client).post({url:`/instance/dispose`,...e})}},Kt=class extends V{get(e){return(e?.client??this._client).get({url:`/path`,...e})}},qt=class extends V{get(e){return(e?.client??this._client).get({url:`/vcs`,...e})}},Jt=class extends V{list(e){return(e?.client??this._client).get({url:`/session`,...e})}create(e){return(e?.client??this._client).post({url:`/session`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}status(e){return(e?.client??this._client).get({url:`/session/status`,...e})}delete(e){return(e.client??this._client).delete({url:`/session/{id}`,...e})}get(e){return(e.client??this._client).get({url:`/session/{id}`,...e})}update(e){return(e.client??this._client).patch({url:`/session/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}children(e){return(e.client??this._client).get({url:`/session/{id}/children`,...e})}todo(e){return(e.client??this._client).get({url:`/session/{id}/todo`,...e})}init(e){return(e.client??this._client).post({url:`/session/{id}/init`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}fork(e){return(e.client??this._client).post({url:`/session/{id}/fork`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}abort(e){return(e.client??this._client).post({url:`/session/{id}/abort`,...e})}unshare(e){return(e.client??this._client).delete({url:`/session/{id}/share`,...e})}share(e){return(e.client??this._client).post({url:`/session/{id}/share`,...e})}diff(e){return(e.client??this._client).get({url:`/session/{id}/diff`,...e})}summarize(e){return(e.client??this._client).post({url:`/session/{id}/summarize`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}messages(e){return(e.client??this._client).get({url:`/session/{id}/message`,...e})}prompt(e){return(e.client??this._client).post({url:`/session/{id}/message`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}message(e){return(e.client??this._client).get({url:`/session/{id}/message/{messageID}`,...e})}promptAsync(e){return(e.client??this._client).post({url:`/session/{id}/prompt_async`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}command(e){return(e.client??this._client).post({url:`/session/{id}/command`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}shell(e){return(e.client??this._client).post({url:`/session/{id}/shell`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}revert(e){return(e.client??this._client).post({url:`/session/{id}/revert`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}unrevert(e){return(e.client??this._client).post({url:`/session/{id}/unrevert`,...e})}},Yt=class extends V{list(e){return(e?.client??this._client).get({url:`/command`,...e})}},Xt=class extends V{authorize(e){return(e.client??this._client).post({url:`/provider/{id}/oauth/authorize`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}callback(e){return(e.client??this._client).post({url:`/provider/{id}/oauth/callback`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}},Zt=class extends V{list(e){return(e?.client??this._client).get({url:`/provider`,...e})}auth(e){return(e?.client??this._client).get({url:`/provider/auth`,...e})}oauth=new Xt({client:this._client})},Qt=class extends V{text(e){return(e.client??this._client).get({url:`/find`,...e})}files(e){return(e.client??this._client).get({url:`/find/file`,...e})}symbols(e){return(e.client??this._client).get({url:`/find/symbol`,...e})}},$t=class extends V{list(e){return(e.client??this._client).get({url:`/file`,...e})}read(e){return(e.client??this._client).get({url:`/file/content`,...e})}status(e){return(e?.client??this._client).get({url:`/file/status`,...e})}},en=class extends V{log(e){return(e?.client??this._client).post({url:`/log`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}agents(e){return(e?.client??this._client).get({url:`/agent`,...e})}},tn=class extends V{remove(e){return(e.client??this._client).delete({url:`/mcp/{name}/auth`,...e})}start(e){return(e.client??this._client).post({url:`/mcp/{name}/auth`,...e})}callback(e){return(e.client??this._client).post({url:`/mcp/{name}/auth/callback`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}authenticate(e){return(e.client??this._client).post({url:`/mcp/{name}/auth/authenticate`,...e})}set(e){return(e.client??this._client).put({url:`/auth/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}},nn=class extends V{status(e){return(e?.client??this._client).get({url:`/mcp`,...e})}add(e){return(e?.client??this._client).post({url:`/mcp`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}connect(e){return(e.client??this._client).post({url:`/mcp/{name}/connect`,...e})}disconnect(e){return(e.client??this._client).post({url:`/mcp/{name}/disconnect`,...e})}auth=new tn({client:this._client})},rn=class extends V{status(e){return(e?.client??this._client).get({url:`/lsp`,...e})}},an=class extends V{status(e){return(e?.client??this._client).get({url:`/formatter`,...e})}},on=class extends V{next(e){return(e?.client??this._client).get({url:`/tui/control/next`,...e})}response(e){return(e?.client??this._client).post({url:`/tui/control/response`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}},sn=class extends V{appendPrompt(e){return(e?.client??this._client).post({url:`/tui/append-prompt`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}openHelp(e){return(e?.client??this._client).post({url:`/tui/open-help`,...e})}openSessions(e){return(e?.client??this._client).post({url:`/tui/open-sessions`,...e})}openThemes(e){return(e?.client??this._client).post({url:`/tui/open-themes`,...e})}openModels(e){return(e?.client??this._client).post({url:`/tui/open-models`,...e})}submitPrompt(e){return(e?.client??this._client).post({url:`/tui/submit-prompt`,...e})}clearPrompt(e){return(e?.client??this._client).post({url:`/tui/clear-prompt`,...e})}executeCommand(e){return(e?.client??this._client).post({url:`/tui/execute-command`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}showToast(e){return(e?.client??this._client).post({url:`/tui/show-toast`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}publish(e){return(e?.client??this._client).post({url:`/tui/publish`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}control=new on({client:this._client})},cn=class extends V{subscribe(e){return(e?.client??this._client).get.sse({url:`/event`,...e})}},ln=class extends V{postSessionIdPermissionsPermissionId(e){return(e.client??this._client).post({url:`/session/{id}/permissions/{permissionID}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}global=new Bt({client:this._client});project=new Vt({client:this._client});pty=new Ht({client:this._client});config=new Ut({client:this._client});tool=new Wt({client:this._client});instance=new Gt({client:this._client});path=new Kt({client:this._client});vcs=new qt({client:this._client});session=new Jt({client:this._client});command=new Yt({client:this._client});provider=new Zt({client:this._client});find=new Qt({client:this._client});file=new $t({client:this._client});app=new en({client:this._client});mcp=new nn({client:this._client});lsp=new rn({client:this._client});formatter=new an({client:this._client});tui=new sn({client:this._client});auth=new tn({client:this._client});event=new cn({client:this._client})};function un(e){if(!e?.fetch){let t=e=>(e.timeout=!1,fetch(e));e={...e,fetch:t}}return e?.directory&&(e.headers={...e.headers,"x-opencode-directory":encodeURIComponent(e.directory)}),new ln({client:Rt(e)})}async function dn(e){e=Object.assign({hostname:`127.0.0.1`,port:4096,timeout:5e3},e??{});let t=[`serve`,`--hostname=${e.hostname}`,`--port=${e.port}`];e.config?.logLevel&&t.push(`--log-level=${e.config.logLevel}`);let n=je(`opencode`,t,{signal:e.signal,env:{...process.env,OPENCODE_CONFIG_CONTENT:JSON.stringify(e.config??{})}});return{url:await new Promise((t,r)=>{let i=setTimeout(()=>{r(Error(`Timeout waiting for server to start after ${e.timeout}ms`))},e.timeout),a=``;n.stdout?.on(`data`,e=>{a+=e.toString();let n=a.split(` -`);for(let e of n)if(e.startsWith(`opencode server listening`)){let n=e.match(/on\s+(https?:\/\/[^\s]+)/);if(!n)throw Error(`Failed to parse server url from output: ${e}`);clearTimeout(i),t(n[1]);return}}),n.stderr?.on(`data`,e=>{a+=e.toString()}),n.on(`exit`,e=>{clearTimeout(i);let t=`Server exited with code ${e}`;a.trim()&&(t+=`\nServer output: ${a}`),r(Error(t))}),n.on(`error`,e=>{clearTimeout(i),r(e)}),e.signal&&e.signal.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Aborted`))})}),close(){n.kill()}}}async function fn(e){let t=await dn({...e});return{client:un({baseUrl:t.url}),server:t}}async function pn(e){if(e<0||!Number.isFinite(e))throw Error(`Invalid sleep duration: ${e}`);return new Promise(t=>setTimeout(t,e))}const mn={api_error:`API Error`,configuration:`Configuration Error`,internal:`Internal Error`,llm_fetch_error:`LLM Fetch Error`,llm_timeout:`LLM Timeout`,permission:`Permission Error`,rate_limit:`Rate Limit`,validation:`Validation Error`};function hn(e){return e.type===`rate_limit`?`:warning:`:e.type===`llm_timeout`?`:hourglass:`:e.type===`llm_fetch_error`||e.retryable?`:warning:`:`:x:`}function gn(e){let t=hn(e),n=mn[e.type],r=[];return r.push(`${t} **${n}**`),r.push(``),r.push(e.message),e.details!=null&&(r.push(``),r.push(`> ${e.details}`)),e.suggestedAction!=null&&(r.push(``),r.push(`**Suggested action:** ${e.suggestedAction}`)),e.retryable&&(r.push(``),r.push(`_This error is retryable._`)),e.resetTime!=null&&(r.push(``),r.push(`_Rate limit resets at: ${e.resetTime.toISOString()}_`)),r.join(` -`)}function _n(e,t,n,r){return{type:e,message:t,retryable:n,details:r?.details,suggestedAction:r?.suggestedAction,resetTime:r?.resetTime}}const vn=[/fetch failed/i,/connect\s*timeout/i,/connecttimeouterror/i,/timed?\s*out/i,/econnrefused/i,/econnreset/i,/etimedout/i,/network error/i];function yn(e){if(e==null)return!1;let t=``;if(typeof e==`string`)t=e;else if(e instanceof Error)t=e.message,`cause`in e&&typeof e.cause==`string`&&(t+=` ${e.cause}`);else if(typeof e==`object`){let n=e;typeof n.message==`string`&&(t=n.message),typeof n.cause==`string`&&(t+=` ${n.cause}`)}return vn.some(e=>e.test(t))}function bn(e,t){return _n(`llm_fetch_error`,`LLM request failed: ${e}`,!0,{details:t==null?void 0:`Model: ${t}`,suggestedAction:`This is a transient network error. The request may succeed on retry, or try a different model.`})}function xn(e,t){return _n(`configuration`,`Agent error: ${e}`,!1,{details:t==null?void 0:`Requested agent: ${t}`,suggestedAction:`Verify the agent name is correct and the required plugins (e.g., oMo) are installed.`})}async function Sn(e,t,i,a,o,s=n,c){let l=Date.now(),u=0;for(;!a.aborted;){if(await pn(500),a.aborted)return{completed:!1,error:`Aborted`};if(c?.sessionError==null)u=0;else{if(u++,u>=3)return o.error(`Session error persisted through grace period`,{sessionId:t,error:c.sessionError,graceCycles:u}),{completed:!1,error:`Session error: ${c.sessionError}`};continue}if(c?.sessionIdle===!0)return o.debug(`Session idle detected via event stream`,{sessionId:t}),{completed:!0,error:null};let n=Date.now()-l;if(s>0&&n>=s)return o.warning(`Poll timeout reached`,{elapsedMs:n,maxPollTimeMs:s}),{completed:!1,error:`Poll timeout after ${n}ms`};try{let n=((await e.session.status({query:{directory:i}})).data??{})[t];if(n==null)o.debug(`Session status not found in poll response`,{sessionId:t});else if(n.type===`idle`)return o.debug(`Session idle detected via polling`,{sessionId:t}),{completed:!0,error:null};else o.debug(`Session status`,{sessionId:t,type:n.type});if(c!=null&&!c.firstMeaningfulEventReceived){let e=Date.now()-l;if(e>=9e4)return o.error(`No agent activity detected — server may have crashed during prompt processing`,{elapsedMs:e,sessionId:t}),{completed:!1,error:`No agent activity detected after ${e}ms — server may have crashed during prompt processing`}}}catch(e){o.debug(`Poll request failed`,{error:r(e)})}}return{completed:!1,error:`Aborted`}}async function Cn(e,t=2e3){await Promise.race([e,new Promise(e=>{setTimeout(e,t)})])}function wn(e){try{let t=new URL(e);return t.hostname===`github.com`||t.hostname===`api.github.com`}catch{return!1}}function Tn(e){try{let t=new URL(e);return t.hostname===`github.com`&&(t.pathname.startsWith(`/user-attachments/assets/`)||t.pathname.startsWith(`/user-attachments/files/`))}catch{return!1}}function En(e){let t=e.match(/https:\/\/github\.com\/[a-zA-Z0-9-]+\/[\w.-]+\/(?:pull|issues)\/\d+(?:#issuecomment-\d+)?/g)??[];return[...new Set(t)].filter(wn)}function Dn(e){let t=/\[[\w-]+\s+([a-f0-9]{7,40})\]/g,n=[];for(let r of e.matchAll(t))r[1]!=null&&n.push(r[1]);return[...new Set(n)]}const On={todowrite:[`Todo`,`\x1B[33m\x1B[1m`],todoread:[`Todo`,`\x1B[33m\x1B[1m`],bash:[`Bash`,`\x1B[31m\x1B[1m`],edit:[`Edit`,`\x1B[32m\x1B[1m`],glob:[`Glob`,`\x1B[34m\x1B[1m`],grep:[`Grep`,`\x1B[34m\x1B[1m`],list:[`List`,`\x1B[34m\x1B[1m`],read:[`Read`,`\x1B[35m\x1B[1m`],write:[`Write`,`\x1B[32m\x1B[1m`],websearch:[`Search`,`\x1B[2m\x1B[1m`]},kn=`\x1B[0m`;function An(){return N.env.NO_COLOR==null}function jn(e,t){let[n,r]=On[e.toLowerCase()]??[e,`\x1B[36m\x1B[1m`],i=n.padEnd(10,` `);An()?N.stdout.write(`\n${r}|${kn} ${i} ${kn}${t}\n`):N.stdout.write(`\n| ${i} ${t}\n`)}function Mn(e){N.stdout.write(`\n${e}\n`)}function Nn(e,t){t.debug(`Server event`,{eventType:e.type,properties:e.properties})}function Pn(e,t,n,r,i){let a=En(t);if(e.includes(`gh pr create`)){let e=a.filter(e=>e.includes(`/pull/`)&&!e.includes(`#`));for(let t of e)n.includes(t)||n.push(t)}if(e.includes(`git commit`)){let e=Dn(t);for(let t of e)r.includes(t)||r.push(t)}(e.includes(`gh issue comment`)||e.includes(`gh pr comment`))&&a.some(e=>e.includes(`#issuecomment`))&&i()}async function Fn(e,t,n,r,i){let a=``,o=null,s=null,c=null,l=[],u=[],d=0,f=null;for await(let p of e){if(n.aborted)break;if(Nn(p,r),p.type===`message.part.updated`){let e=p.properties.part;if(e.sessionID!==t)continue;if(i!=null&&(i.firstMeaningfulEventReceived=!0),e.type===`text`&&`text`in e&&typeof e.text==`string`){a=e.text;let t=`time`in e?e.time?.end:void 0;t!=null&&Number.isFinite(t)&&(Mn(a),a=``)}else if(e.type===`tool`){let t=e.state;t.status===`completed`&&(jn(e.tool,t.title),e.tool.toLowerCase()===`bash`&&Pn(String(t.input.command??t.input.cmd??``),String(t.output),l,u,()=>{d++}))}}else if(p.type===`message.updated`){let e=p.properties.info;e.sessionID===t&&e.role===`assistant`&&e.tokens!=null&&(i!=null&&(i.firstMeaningfulEventReceived=!0),o={input:e.tokens.input??0,output:e.tokens.output??0,reasoning:e.tokens.reasoning??0,cache:{read:e.tokens.cache?.read??0,write:e.tokens.cache?.write??0}},s=e.modelID??null,c=e.cost??null,r.debug(`Token usage received`,{tokens:o,model:s,cost:c}))}else if(p.type===`session.error`){if(p.properties.sessionID===t){let e=p.properties.error,t=typeof e==`string`?e:String(e);r.error(`Session error`,{error:e}),f=yn(e)?bn(t,s??void 0):xn(t),i!=null&&(i.sessionError=t)}}else p.type===`session.idle`&&p.properties.sessionID===t&&(i!=null&&(i.sessionIdle=!0),a.length>0&&(Mn(a),a=``))}return a.length>0&&Mn(a),{tokens:o,model:s,cost:c,prsCreated:l,commitsCreated:u,commentsPosted:d,llmError:f}}const In=5e3;async function Ln(e,t,n,r,i){let a=new AbortController,o={firstMeaningfulEventReceived:!1,sessionIdle:!1,sessionError:null},s=await e.event.subscribe(),c={tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null},l=Fn(s.stream,t,a.signal,i,o).then(e=>{c=e}).catch(e=>{e instanceof Error&&e.name!==`AbortError`&&i.debug(`Event stream error`,{error:e.message})}),u=async()=>{a.abort(),await Cn(l)};try{let s=await Sn(e,t,n,a.signal,i,r,o);if(await u(),!s.completed){let e=s.error??`Session did not reach idle state`;return i.error(`Session completion polling failed`,{error:e,sessionId:t}),{success:!1,error:e,llmError:c.llmError,shouldRetry:c.llmError!=null,eventStreamResult:c}}return{success:!0,error:null,llmError:null,shouldRetry:!1,eventStreamResult:c}}finally{a.abort(),await Cn(l)}}const Rn=e=>{if(e?.model!=null)return{providerID:e.model.providerID,modelID:e.model.modelID};if(!(e!=null&&Object.values(e.omoProviders).some(e=>e!==`no`)))return{providerID:E.providerID,modelID:E.modelID}};async function zn(e,t,n,r,i,a,o){let s={parts:[{type:`text`,text:n},...r??[]]},c=Rn(a);c!=null&&(s.model=c);let l=a?.agent??`sisyphus`;l!==`sisyphus`&&(s.agent=l);let u=await e.session.promptAsync({path:{id:t},body:s,query:{directory:i}});if(u.error!=null){let e=String(u.error),t=yn(u.error)?bn(e):null;return{success:!1,error:e,llmError:t,shouldRetry:t!=null,eventStreamResult:{tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:t}}}return Ln(e,t,i,a?.timeoutMs??18e5,o)}function Bn(){return[`## Critical Rules (NON-NEGOTIABLE)`,`- You are a NON-INTERACTIVE CI agent. Do NOT ask questions. Make decisions autonomously.`,`- Post EXACTLY ONE comment or review per invocation. Never multiple.`,`- Include the Run Summary marker block in your comment.`,"- Use `gh` CLI for all GitHub operations. Do not use the GitHub API directly.",`- Mark your comment with the bot identification marker.`].join(` -`)}function Vn(e,t,n){if(e==null)return``;let r=[`## Thread Identity`];return r.push(`**Logical Thread**: \`${e.key}\` (${e.entityType} #${e.entityId})`),t?(r.push(`**Status**: Continuing previous conversation thread.`),n!=null&&n.length>0&&(r.push(``),r.push(`**Thread Summary**:`),r.push(n))):r.push(`**Status**: Fresh conversation — no prior thread found for this entity.`),r.join(` -`)}function Hn(e){return e==null||e.length===0?``:[`## Current Thread Context`,`This is work from your PREVIOUS runs on this same entity:`,``,e].join(` -`)}function Un(){return[`## Reminder: Critical Rules`,"- ONE comment/review only. Include Run Summary marker. Use `gh` CLI only."].join(` -`)}function Wn(e,t){switch(e.eventType){case`issue_comment`:return{directive:`Respond to the comment above. Post your response as a single comment on this thread.`,appendMode:!0};case`discussion_comment`:return{directive:`Respond to the discussion comment above. Post your response as a single comment.`,appendMode:!0};case`issues`:return e.action===`opened`?{directive:`Triage this issue: summarize, reproduce if possible, propose next steps. Post your response as a single comment.`,appendMode:!0}:{directive:`Respond to the mention in this issue. Post your response as a single comment.`,appendMode:!0};case`pull_request`:return{directive:[`Review this pull request for code quality, potential bugs, and improvements.`,"If you are a requested reviewer, submit a review via `gh pr review` with your full response (including Run Summary) in the --body.",`Include the Run Summary in the review body. Do not post a separate comment.`,`If the author is a collaborator, prioritize actionable feedback over style nits.`].join(` -`),appendMode:!0};case`pull_request_review_comment`:return{directive:Gn(e),appendMode:!0};case`schedule`:case`workflow_dispatch`:return{directive:t??``,appendMode:!1};default:return{directive:`Execute the requested operation.`,appendMode:!0}}}function Gn(e){let t=e.target,n=[`Respond to the review comment.`,``];return t?.path!=null&&n.push(`**File:** \`${t.path}\``),t?.line!=null&&n.push(`**Line:** ${t.line}`),t?.commitId!=null&&n.push(`**Commit:** \`${t.commitId}\``),t?.diffHunk!=null&&t.diffHunk.length>0&&n.push(``,`**Diff Context:**`,"```diff",t.diffHunk,"```"),n.join(` -`)}function Kn(e,t){let{directive:n,appendMode:r}=Wn(e,t),i=[`## Task`,``];return r?(i.push(n),t!=null&&t.trim().length>0&&i.push(``,`**Additional Instructions:**`,t.trim())):i.push(n),i.push(``),i.join(` -`)}function qn(e,t){let{context:n,customPrompt:r,cacheStatus:i,sessionContext:a,logicalKey:o,isContinuation:s,currentThreadSessionId:c}=e,l=[],u=s===!0;l.push(Bn());let d=Vn(o??null,u,null);d.length>0&&l.push(d);let f=a!=null&&u&&c!=null?Xn(a.priorWorkContext,c):null;e.triggerContext==null?n.commentBody==null?l.push(`## Task +`);try{c=JSON.parse(e),l=!0}catch{c=e}}l&&(r&&await r(c),n&&(c=await n(c))),t?.({data:c,event:o,id:u,retry:s}),a.length&&(yield c)}}}finally{p.removeEventListener(`abort`,d),a.releaseLock()}break}catch(t){if(e?.(t),a!==void 0&&f>=a)break;await d(Math.min(s*2**(f-1),o??3e4))}}}()}},gt=async(e,t)=>{let n=typeof t==`function`?await t(e):t;if(n)return e.scheme===`bearer`?`Bearer ${n}`:e.scheme===`basic`?`Basic ${btoa(n)}`:n},_t={bodySerializer:e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)},vt=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},yt=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},bt=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},xt=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(yt(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=vt(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):St({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},St=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},Ct=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=bt(r),s=Object.entries(i).map(([t,i])=>St({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},wt=/\{[^{}]+\}/g,Tt=({path:e,url:t})=>{let n=t,r=t.match(wt);if(r)for(let t of r){let r=!1,i=t.substring(1,t.length-1),a=`simple`;i.endsWith(`*`)&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(`.`)?(i=i.substring(1),a=`label`):i.startsWith(`;`)&&(i=i.substring(1),a=`matrix`);let o=e[i];if(o==null)continue;if(Array.isArray(o)){n=n.replace(t,xt({explode:r,name:i,style:a,value:o}));continue}if(typeof o==`object`){n=n.replace(t,Ct({explode:r,name:i,style:a,value:o,valueOnly:!0}));continue}if(a===`matrix`){n=n.replace(t,`;${St({name:i,value:o})}`);continue}let s=encodeURIComponent(a===`label`?`.${o}`:o);n=n.replace(t,s)}return n},Et=({baseUrl:e,path:t,query:n,querySerializer:r,url:i})=>{let a=i.startsWith(`/`)?i:`/${i}`,o=(e??``)+a;t&&(o=Tt({path:t,url:o}));let s=n?r(n):``;return s.startsWith(`?`)&&(s=s.substring(1)),s&&(o+=`?${s}`),o},Dt=({allowReserved:e,array:t,object:n}={})=>r=>{let i=[];if(r&&typeof r==`object`)for(let a in r){let o=r[a];if(o!=null)if(Array.isArray(o)){let n=xt({allowReserved:e,explode:!0,name:a,style:`form`,value:o,...t});n&&i.push(n)}else if(typeof o==`object`){let t=Ct({allowReserved:e,explode:!0,name:a,style:`deepObject`,value:o,...n});t&&i.push(t)}else{let t=St({allowReserved:e,name:a,value:o});t&&i.push(t)}}return i.join(`&`)},Ot=e=>{if(!e)return`stream`;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if(t===`multipart/form-data`)return`formData`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},kt=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get(`Cookie`)?.includes(`${t}=`)):!1,At=async({security:e,...t})=>{for(let n of e){if(kt(t,n.name))continue;let e=await gt(n,t.auth);if(!e)continue;let r=n.name??`Authorization`;switch(n.in){case`query`:t.query||={},t.query[r]=e;break;case`cookie`:t.headers.append(`Cookie`,`${r}=${e}`);break;default:t.headers.set(r,e);break}}},jt=e=>Et({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==`function`?e.querySerializer:Dt(e.querySerializer),url:e.url}),Mt=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith(`/`)&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=Nt(e.headers,t.headers),n},Nt=(...e)=>{let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t};var Pt=class{_fns;constructor(){this._fns=[]}clear(){this._fns=[]}getInterceptorIndex(e){return typeof e==`number`?this._fns[e]?e:-1:this._fns.indexOf(e)}exists(e){let t=this.getInterceptorIndex(e);return!!this._fns[t]}eject(e){let t=this.getInterceptorIndex(e);this._fns[t]&&(this._fns[t]=null)}update(e,t){let n=this.getInterceptorIndex(e);return this._fns[n]?(this._fns[n]=t,e):!1}use(e){return this._fns=[...this._fns,e],this._fns.length-1}};const Ft=()=>({error:new Pt,request:new Pt,response:new Pt}),It=Dt({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),Lt={"Content-Type":`application/json`},Rt=(e={})=>({..._t,headers:Lt,parseAs:`auto`,querySerializer:It,...e}),zt=(e={})=>{let t=Mt(Rt(),e),n=()=>({...t}),r=e=>(t=Mt(t,e),n()),i=Ft(),a=async e=>{let n={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:Nt(t.headers,e.headers),serializedBody:void 0};return n.security&&await At({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.serializedBody===void 0||n.serializedBody===``)&&n.headers.delete(`Content-Type`),{opts:n,url:jt(n)}},o=async e=>{let{opts:t,url:n}=await a(e),r={redirect:`follow`,...t,body:t.serializedBody},o=new Request(n,r);for(let e of i.request._fns)e&&(o=await e(o,t));let s=t.fetch,c=await s(o);for(let e of i.response._fns)e&&(c=await e(c,o,t));let l={request:o,response:c};if(c.ok){if(c.status===204||c.headers.get(`Content-Length`)===`0`)return t.responseStyle===`data`?{}:{data:{},...l};let e=(t.parseAs===`auto`?Ot(c.headers.get(`Content-Type`)):t.parseAs)??`json`,n;switch(e){case`arrayBuffer`:case`blob`:case`formData`:case`json`:case`text`:n=await c[e]();break;case`stream`:return t.responseStyle===`data`?c.body:{data:c.body,...l}}return e===`json`&&(t.responseValidator&&await t.responseValidator(n),t.responseTransformer&&(n=await t.responseTransformer(n))),t.responseStyle===`data`?n:{data:n,...l}}let u=await c.text(),d;try{d=JSON.parse(u)}catch{}let f=d??u,p=f;for(let e of i.error._fns)e&&(p=await e(f,c,o,t));if(p||={},t.throwOnError)throw p;return t.responseStyle===`data`?void 0:{error:p,...l}},s=e=>{let t=t=>o({...t,method:e});return t.sse=async t=>{let{opts:n,url:r}=await a(t);return ht({...n,body:n.body,headers:n.headers,method:e,url:r})},t};return{buildUrl:jt,connect:s(`CONNECT`),delete:s(`DELETE`),get:s(`GET`),getConfig:n,head:s(`HEAD`),interceptors:i,options:s(`OPTIONS`),patch:s(`PATCH`),post:s(`POST`),put:s(`PUT`),request:o,setConfig:r,trace:s(`TRACE`)}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const Bt=zt(Rt({baseUrl:`http://localhost:4096`}));var B=class{_client=Bt;constructor(e){e?.client&&(this._client=e.client)}},Vt=class extends B{event(e){return(e?.client??this._client).get.sse({url:`/global/event`,...e})}},Ht=class extends B{list(e){return(e?.client??this._client).get({url:`/project`,...e})}current(e){return(e?.client??this._client).get({url:`/project/current`,...e})}},Ut=class extends B{list(e){return(e?.client??this._client).get({url:`/pty`,...e})}create(e){return(e?.client??this._client).post({url:`/pty`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}remove(e){return(e.client??this._client).delete({url:`/pty/{id}`,...e})}get(e){return(e.client??this._client).get({url:`/pty/{id}`,...e})}update(e){return(e.client??this._client).put({url:`/pty/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}connect(e){return(e.client??this._client).get({url:`/pty/{id}/connect`,...e})}},Wt=class extends B{get(e){return(e?.client??this._client).get({url:`/config`,...e})}update(e){return(e?.client??this._client).patch({url:`/config`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}providers(e){return(e?.client??this._client).get({url:`/config/providers`,...e})}},Gt=class extends B{ids(e){return(e?.client??this._client).get({url:`/experimental/tool/ids`,...e})}list(e){return(e.client??this._client).get({url:`/experimental/tool`,...e})}},Kt=class extends B{dispose(e){return(e?.client??this._client).post({url:`/instance/dispose`,...e})}},qt=class extends B{get(e){return(e?.client??this._client).get({url:`/path`,...e})}},Jt=class extends B{get(e){return(e?.client??this._client).get({url:`/vcs`,...e})}},Yt=class extends B{list(e){return(e?.client??this._client).get({url:`/session`,...e})}create(e){return(e?.client??this._client).post({url:`/session`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}status(e){return(e?.client??this._client).get({url:`/session/status`,...e})}delete(e){return(e.client??this._client).delete({url:`/session/{id}`,...e})}get(e){return(e.client??this._client).get({url:`/session/{id}`,...e})}update(e){return(e.client??this._client).patch({url:`/session/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}children(e){return(e.client??this._client).get({url:`/session/{id}/children`,...e})}todo(e){return(e.client??this._client).get({url:`/session/{id}/todo`,...e})}init(e){return(e.client??this._client).post({url:`/session/{id}/init`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}fork(e){return(e.client??this._client).post({url:`/session/{id}/fork`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}abort(e){return(e.client??this._client).post({url:`/session/{id}/abort`,...e})}unshare(e){return(e.client??this._client).delete({url:`/session/{id}/share`,...e})}share(e){return(e.client??this._client).post({url:`/session/{id}/share`,...e})}diff(e){return(e.client??this._client).get({url:`/session/{id}/diff`,...e})}summarize(e){return(e.client??this._client).post({url:`/session/{id}/summarize`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}messages(e){return(e.client??this._client).get({url:`/session/{id}/message`,...e})}prompt(e){return(e.client??this._client).post({url:`/session/{id}/message`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}message(e){return(e.client??this._client).get({url:`/session/{id}/message/{messageID}`,...e})}promptAsync(e){return(e.client??this._client).post({url:`/session/{id}/prompt_async`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}command(e){return(e.client??this._client).post({url:`/session/{id}/command`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}shell(e){return(e.client??this._client).post({url:`/session/{id}/shell`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}revert(e){return(e.client??this._client).post({url:`/session/{id}/revert`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}unrevert(e){return(e.client??this._client).post({url:`/session/{id}/unrevert`,...e})}},Xt=class extends B{list(e){return(e?.client??this._client).get({url:`/command`,...e})}},Zt=class extends B{authorize(e){return(e.client??this._client).post({url:`/provider/{id}/oauth/authorize`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}callback(e){return(e.client??this._client).post({url:`/provider/{id}/oauth/callback`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}},Qt=class extends B{list(e){return(e?.client??this._client).get({url:`/provider`,...e})}auth(e){return(e?.client??this._client).get({url:`/provider/auth`,...e})}oauth=new Zt({client:this._client})},$t=class extends B{text(e){return(e.client??this._client).get({url:`/find`,...e})}files(e){return(e.client??this._client).get({url:`/find/file`,...e})}symbols(e){return(e.client??this._client).get({url:`/find/symbol`,...e})}},en=class extends B{list(e){return(e.client??this._client).get({url:`/file`,...e})}read(e){return(e.client??this._client).get({url:`/file/content`,...e})}status(e){return(e?.client??this._client).get({url:`/file/status`,...e})}},tn=class extends B{log(e){return(e?.client??this._client).post({url:`/log`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}agents(e){return(e?.client??this._client).get({url:`/agent`,...e})}},nn=class extends B{remove(e){return(e.client??this._client).delete({url:`/mcp/{name}/auth`,...e})}start(e){return(e.client??this._client).post({url:`/mcp/{name}/auth`,...e})}callback(e){return(e.client??this._client).post({url:`/mcp/{name}/auth/callback`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}authenticate(e){return(e.client??this._client).post({url:`/mcp/{name}/auth/authenticate`,...e})}set(e){return(e.client??this._client).put({url:`/auth/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}},rn=class extends B{status(e){return(e?.client??this._client).get({url:`/mcp`,...e})}add(e){return(e?.client??this._client).post({url:`/mcp`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}connect(e){return(e.client??this._client).post({url:`/mcp/{name}/connect`,...e})}disconnect(e){return(e.client??this._client).post({url:`/mcp/{name}/disconnect`,...e})}auth=new nn({client:this._client})},an=class extends B{status(e){return(e?.client??this._client).get({url:`/lsp`,...e})}},on=class extends B{status(e){return(e?.client??this._client).get({url:`/formatter`,...e})}},sn=class extends B{next(e){return(e?.client??this._client).get({url:`/tui/control/next`,...e})}response(e){return(e?.client??this._client).post({url:`/tui/control/response`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}},cn=class extends B{appendPrompt(e){return(e?.client??this._client).post({url:`/tui/append-prompt`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}openHelp(e){return(e?.client??this._client).post({url:`/tui/open-help`,...e})}openSessions(e){return(e?.client??this._client).post({url:`/tui/open-sessions`,...e})}openThemes(e){return(e?.client??this._client).post({url:`/tui/open-themes`,...e})}openModels(e){return(e?.client??this._client).post({url:`/tui/open-models`,...e})}submitPrompt(e){return(e?.client??this._client).post({url:`/tui/submit-prompt`,...e})}clearPrompt(e){return(e?.client??this._client).post({url:`/tui/clear-prompt`,...e})}executeCommand(e){return(e?.client??this._client).post({url:`/tui/execute-command`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}showToast(e){return(e?.client??this._client).post({url:`/tui/show-toast`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}publish(e){return(e?.client??this._client).post({url:`/tui/publish`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}control=new sn({client:this._client})},ln=class extends B{subscribe(e){return(e?.client??this._client).get.sse({url:`/event`,...e})}},un=class extends B{postSessionIdPermissionsPermissionId(e){return(e.client??this._client).post({url:`/session/{id}/permissions/{permissionID}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}global=new Vt({client:this._client});project=new Ht({client:this._client});pty=new Ut({client:this._client});config=new Wt({client:this._client});tool=new Gt({client:this._client});instance=new Kt({client:this._client});path=new qt({client:this._client});vcs=new Jt({client:this._client});session=new Yt({client:this._client});command=new Xt({client:this._client});provider=new Qt({client:this._client});find=new $t({client:this._client});file=new en({client:this._client});app=new tn({client:this._client});mcp=new rn({client:this._client});lsp=new an({client:this._client});formatter=new on({client:this._client});tui=new cn({client:this._client});auth=new nn({client:this._client});event=new ln({client:this._client})};function dn(e){if(!e?.fetch){let t=e=>(e.timeout=!1,fetch(e));e={...e,fetch:t}}return e?.directory&&(e.headers={...e.headers,"x-opencode-directory":encodeURIComponent(e.directory)}),new un({client:zt(e)})}async function fn(e){e=Object.assign({hostname:`127.0.0.1`,port:4096,timeout:5e3},e??{});let t=[`serve`,`--hostname=${e.hostname}`,`--port=${e.port}`];e.config?.logLevel&&t.push(`--log-level=${e.config.logLevel}`);let n=je(`opencode`,t,{signal:e.signal,env:{...process.env,OPENCODE_CONFIG_CONTENT:JSON.stringify(e.config??{})}});return{url:await new Promise((t,r)=>{let i=setTimeout(()=>{r(Error(`Timeout waiting for server to start after ${e.timeout}ms`))},e.timeout),a=``;n.stdout?.on(`data`,e=>{a+=e.toString();let n=a.split(` +`);for(let e of n)if(e.startsWith(`opencode server listening`)){let n=e.match(/on\s+(https?:\/\/[^\s]+)/);if(!n)throw Error(`Failed to parse server url from output: ${e}`);clearTimeout(i),t(n[1]);return}}),n.stderr?.on(`data`,e=>{a+=e.toString()}),n.on(`exit`,e=>{clearTimeout(i);let t=`Server exited with code ${e}`;a.trim()&&(t+=`\nServer output: ${a}`),r(Error(t))}),n.on(`error`,e=>{clearTimeout(i),r(e)}),e.signal&&e.signal.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Aborted`))})}),close(){n.kill()}}}async function pn(e){let t=await fn({...e});return{client:dn({baseUrl:t.url}),server:t}}async function mn(e,t,n,r){if(n!=null)try{let i=await e.session.update({path:{id:t},body:{title:n}});i.error!=null&&r.warning(`Best-effort session title re-assertion failed`,{sessionId:t,sessionTitle:n,error:String(i.error)})}catch(e){r.warning(`Best-effort session title re-assertion failed`,{sessionId:t,sessionTitle:n,error:e instanceof Error?e.message:String(e)})}}async function hn(e){if(e<0||!Number.isFinite(e))throw Error(`Invalid sleep duration: ${e}`);return new Promise(t=>setTimeout(t,e))}const gn={api_error:`API Error`,configuration:`Configuration Error`,internal:`Internal Error`,llm_fetch_error:`LLM Fetch Error`,llm_timeout:`LLM Timeout`,permission:`Permission Error`,rate_limit:`Rate Limit`,validation:`Validation Error`};function _n(e){return e.type===`rate_limit`?`:warning:`:e.type===`llm_timeout`?`:hourglass:`:e.type===`llm_fetch_error`||e.retryable?`:warning:`:`:x:`}function vn(e){let t=_n(e),n=gn[e.type],r=[];return r.push(`${t} **${n}**`),r.push(``),r.push(e.message),e.details!=null&&(r.push(``),r.push(`> ${e.details}`)),e.suggestedAction!=null&&(r.push(``),r.push(`**Suggested action:** ${e.suggestedAction}`)),e.retryable&&(r.push(``),r.push(`_This error is retryable._`)),e.resetTime!=null&&(r.push(``),r.push(`_Rate limit resets at: ${e.resetTime.toISOString()}_`)),r.join(` +`)}function yn(e,t,n,r){return{type:e,message:t,retryable:n,details:r?.details,suggestedAction:r?.suggestedAction,resetTime:r?.resetTime}}const bn=[/fetch failed/i,/connect\s*timeout/i,/connecttimeouterror/i,/timed?\s*out/i,/econnrefused/i,/econnreset/i,/etimedout/i,/network error/i];function xn(e){if(e==null)return!1;let t=``;if(typeof e==`string`)t=e;else if(e instanceof Error)t=e.message,`cause`in e&&typeof e.cause==`string`&&(t+=` ${e.cause}`);else if(typeof e==`object`){let n=e;typeof n.message==`string`&&(t=n.message),typeof n.cause==`string`&&(t+=` ${n.cause}`)}return bn.some(e=>e.test(t))}function Sn(e,t){return yn(`llm_fetch_error`,`LLM request failed: ${e}`,!0,{details:t==null?void 0:`Model: ${t}`,suggestedAction:`This is a transient network error. The request may succeed on retry, or try a different model.`})}function Cn(e,t){return yn(`configuration`,`Agent error: ${e}`,!1,{details:t==null?void 0:`Requested agent: ${t}`,suggestedAction:`Verify the agent name is correct and the required plugins (e.g., oMo) are installed.`})}async function wn(e,t,i,a,o,s=n,c){let l=Date.now(),u=0;for(;!a.aborted;){if(await hn(500),a.aborted)return{completed:!1,error:`Aborted`};if(c?.sessionError==null)u=0;else{if(u++,u>=3)return o.error(`Session error persisted through grace period`,{sessionId:t,error:c.sessionError,graceCycles:u}),{completed:!1,error:`Session error: ${c.sessionError}`};continue}if(c?.sessionIdle===!0)return o.debug(`Session idle detected via event stream`,{sessionId:t}),{completed:!0,error:null};let n=Date.now()-l;if(s>0&&n>=s)return o.warning(`Poll timeout reached`,{elapsedMs:n,maxPollTimeMs:s}),{completed:!1,error:`Poll timeout after ${n}ms`};try{let n=((await e.session.status({query:{directory:i}})).data??{})[t];if(n==null)o.debug(`Session status not found in poll response`,{sessionId:t});else if(n.type===`idle`)return o.debug(`Session idle detected via polling`,{sessionId:t}),{completed:!0,error:null};else o.debug(`Session status`,{sessionId:t,type:n.type});if(c!=null&&!c.firstMeaningfulEventReceived){let e=Date.now()-l;if(e>=9e4)return o.error(`No agent activity detected — server may have crashed during prompt processing`,{elapsedMs:e,sessionId:t}),{completed:!1,error:`No agent activity detected after ${e}ms — server may have crashed during prompt processing`}}}catch(e){o.debug(`Poll request failed`,{error:r(e)})}}return{completed:!1,error:`Aborted`}}async function Tn(e,t=2e3){await Promise.race([e,new Promise(e=>{setTimeout(e,t)})])}function En(e){try{let t=new URL(e);return t.hostname===`github.com`||t.hostname===`api.github.com`}catch{return!1}}function Dn(e){try{let t=new URL(e);return t.hostname===`github.com`&&(t.pathname.startsWith(`/user-attachments/assets/`)||t.pathname.startsWith(`/user-attachments/files/`))}catch{return!1}}function On(e){let t=e.match(/https:\/\/github\.com\/[a-zA-Z0-9-]+\/[\w.-]+\/(?:pull|issues)\/\d+(?:#issuecomment-\d+)?/g)??[];return[...new Set(t)].filter(En)}function kn(e){let t=/\[[\w-]+\s+([a-f0-9]{7,40})\]/g,n=[];for(let r of e.matchAll(t))r[1]!=null&&n.push(r[1]);return[...new Set(n)]}const An={todowrite:[`Todo`,`\x1B[33m\x1B[1m`],todoread:[`Todo`,`\x1B[33m\x1B[1m`],bash:[`Bash`,`\x1B[31m\x1B[1m`],edit:[`Edit`,`\x1B[32m\x1B[1m`],glob:[`Glob`,`\x1B[34m\x1B[1m`],grep:[`Grep`,`\x1B[34m\x1B[1m`],list:[`List`,`\x1B[34m\x1B[1m`],read:[`Read`,`\x1B[35m\x1B[1m`],write:[`Write`,`\x1B[32m\x1B[1m`],websearch:[`Search`,`\x1B[2m\x1B[1m`]},jn=`\x1B[0m`;function Mn(){return N.env.NO_COLOR==null}function Nn(e,t){let[n,r]=An[e.toLowerCase()]??[e,`\x1B[36m\x1B[1m`],i=n.padEnd(10,` `);Mn()?N.stdout.write(`\n${r}|${jn} ${i} ${jn}${t}\n`):N.stdout.write(`\n| ${i} ${t}\n`)}function Pn(e){N.stdout.write(`\n${e}\n`)}function Fn(e,t){t.debug(`Server event`,{eventType:e.type,properties:e.properties})}function In(e,t,n,r,i){let a=On(t);if(e.includes(`gh pr create`)){let e=a.filter(e=>e.includes(`/pull/`)&&!e.includes(`#`));for(let t of e)n.includes(t)||n.push(t)}if(e.includes(`git commit`)){let e=kn(t);for(let t of e)r.includes(t)||r.push(t)}(e.includes(`gh issue comment`)||e.includes(`gh pr comment`))&&a.some(e=>e.includes(`#issuecomment`))&&i()}async function Ln(e,t,n,r,i){let a=``,o=null,s=null,c=null,l=[],u=[],d=0,f=null;for await(let p of e){if(n.aborted)break;if(Fn(p,r),p.type===`message.part.updated`){let e=p.properties.part;if(e.sessionID!==t)continue;if(i!=null&&(i.firstMeaningfulEventReceived=!0),e.type===`text`&&`text`in e&&typeof e.text==`string`){a=e.text;let t=`time`in e?e.time?.end:void 0;t!=null&&Number.isFinite(t)&&(Pn(a),a=``)}else if(e.type===`tool`){let t=e.state;t.status===`completed`&&(Nn(e.tool,t.title),e.tool.toLowerCase()===`bash`&&In(String(t.input.command??t.input.cmd??``),String(t.output),l,u,()=>{d++}))}}else if(p.type===`message.updated`){let e=p.properties.info;e.sessionID===t&&e.role===`assistant`&&e.tokens!=null&&(i!=null&&(i.firstMeaningfulEventReceived=!0),o={input:e.tokens.input??0,output:e.tokens.output??0,reasoning:e.tokens.reasoning??0,cache:{read:e.tokens.cache?.read??0,write:e.tokens.cache?.write??0}},s=e.modelID??null,c=e.cost??null,r.debug(`Token usage received`,{tokens:o,model:s,cost:c}))}else if(p.type===`session.error`){if(p.properties.sessionID===t){let e=p.properties.error,t=typeof e==`string`?e:String(e);r.error(`Session error`,{error:e}),f=xn(e)?Sn(t,s??void 0):Cn(t),i!=null&&(i.sessionError=t)}}else p.type===`session.idle`&&p.properties.sessionID===t&&(i!=null&&(i.sessionIdle=!0),a.length>0&&(Pn(a),a=``))}return a.length>0&&Pn(a),{tokens:o,model:s,cost:c,prsCreated:l,commitsCreated:u,commentsPosted:d,llmError:f}}const Rn=5e3;async function zn(e,t,n,r,i){let a=new AbortController,o={firstMeaningfulEventReceived:!1,sessionIdle:!1,sessionError:null},s=await e.event.subscribe(),c={tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null},l=Ln(s.stream,t,a.signal,i,o).then(e=>{c=e}).catch(e=>{e instanceof Error&&e.name!==`AbortError`&&i.debug(`Event stream error`,{error:e.message})}),u=async()=>{a.abort(),await Tn(l)};try{let s=await wn(e,t,n,a.signal,i,r,o);if(await u(),!s.completed){let e=s.error??`Session did not reach idle state`;return i.error(`Session completion polling failed`,{error:e,sessionId:t}),{success:!1,error:e,llmError:c.llmError,shouldRetry:c.llmError!=null,eventStreamResult:c}}return{success:!0,error:null,llmError:null,shouldRetry:!1,eventStreamResult:c}}finally{a.abort(),await Tn(l)}}const Bn=e=>{if(e?.model!=null)return{providerID:e.model.providerID,modelID:e.model.modelID};if(!(e!=null&&Object.values(e.omoProviders).some(e=>e!==`no`)))return{providerID:E.providerID,modelID:E.modelID}};async function Vn(e,t,n,r,i,a,o){let s={parts:[{type:`text`,text:n},...r??[]]},c=Bn(a);c!=null&&(s.model=c);let l=a?.agent??`sisyphus`;l!==`sisyphus`&&(s.agent=l);let u=await e.session.promptAsync({path:{id:t},body:s,query:{directory:i}});if(u.error!=null){let e=String(u.error),t=xn(u.error)?Sn(e):null;return{success:!1,error:e,llmError:t,shouldRetry:t!=null,eventStreamResult:{tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:t}}}return zn(e,t,i,a?.timeoutMs??18e5,o)}function Hn(){return[`## Critical Rules (NON-NEGOTIABLE)`,`- You are a NON-INTERACTIVE CI agent. Do NOT ask questions. Make decisions autonomously.`,`- Post EXACTLY ONE comment or review per invocation. Never multiple.`,`- Include the Run Summary marker block in your comment.`,"- Use `gh` CLI for all GitHub operations. Do not use the GitHub API directly.",`- Mark your comment with the bot identification marker.`].join(` +`)}function Un(e,t,n){if(e==null)return``;let r=[`## Thread Identity`];return r.push(`**Logical Thread**: \`${e.key}\` (${e.entityType} #${e.entityId})`),t?(r.push(`**Status**: Continuing previous conversation thread.`),n!=null&&n.length>0&&(r.push(``),r.push(`**Thread Summary**:`),r.push(n))):r.push(`**Status**: Fresh conversation — no prior thread found for this entity.`),r.join(` +`)}function Wn(e){return e==null||e.length===0?``:[`## Current Thread Context`,`This is work from your PREVIOUS runs on this same entity:`,``,e].join(` +`)}function Gn(){return[`## Reminder: Critical Rules`,"- ONE comment/review only. Include Run Summary marker. Use `gh` CLI only."].join(` +`)}function Kn(e,t){switch(e.eventType){case`issue_comment`:return{directive:`Respond to the comment above. Post your response as a single comment on this thread.`,appendMode:!0};case`discussion_comment`:return{directive:`Respond to the discussion comment above. Post your response as a single comment.`,appendMode:!0};case`issues`:return e.action===`opened`?{directive:`Triage this issue: summarize, reproduce if possible, propose next steps. Post your response as a single comment.`,appendMode:!0}:{directive:`Respond to the mention in this issue. Post your response as a single comment.`,appendMode:!0};case`pull_request`:return{directive:[`Review this pull request for code quality, potential bugs, and improvements.`,"If you are a requested reviewer, submit a review via `gh pr review` with your full response (including Run Summary) in the --body.",`Include the Run Summary in the review body. Do not post a separate comment.`,`If the author is a collaborator, prioritize actionable feedback over style nits.`].join(` +`),appendMode:!0};case`pull_request_review_comment`:return{directive:qn(e),appendMode:!0};case`schedule`:case`workflow_dispatch`:return{directive:t??``,appendMode:!1};default:return{directive:`Execute the requested operation.`,appendMode:!0}}}function qn(e){let t=e.target,n=[`Respond to the review comment.`,``];return t?.path!=null&&n.push(`**File:** \`${t.path}\``),t?.line!=null&&n.push(`**Line:** ${t.line}`),t?.commitId!=null&&n.push(`**Commit:** \`${t.commitId}\``),t?.diffHunk!=null&&t.diffHunk.length>0&&n.push(``,`**Diff Context:**`,"```diff",t.diffHunk,"```"),n.join(` +`)}function Jn(e,t){let{directive:n,appendMode:r}=Kn(e,t),i=[`## Task`,``];return r?(i.push(n),t!=null&&t.trim().length>0&&i.push(``,`**Additional Instructions:**`,t.trim())):i.push(n),i.push(``),i.join(` +`)}function Yn(e,t){let{context:n,customPrompt:r,cacheStatus:i,sessionContext:a,logicalKey:o,isContinuation:s,currentThreadSessionId:c}=e,l=[],u=s===!0;l.push(Hn());let d=Un(o??null,u,null);d.length>0&&l.push(d);let f=a!=null&&u&&c!=null?Qn(a.priorWorkContext,c):null;e.triggerContext==null?n.commentBody==null?l.push(`## Task Execute the requested operation for repository ${n.repo}. Follow all instructions and requirements listed in this prompt. `):l.push(`## Task Respond to the trigger comment above. Follow all instructions and requirements listed in this prompt. -`):l.push(Kn(e.triggerContext,r)),n.commentBody!=null&&l.push(`## Trigger Comment +`):l.push(Jn(e.triggerContext,r));let p=r?.trim()??null,m=n.commentBody?.trim()??null,h=p!=null&&p.length>0&&m!=null&&m.length>0&&p===m;n.commentBody!=null&&!h&&l.push(`## Trigger Comment **Author:** ${n.commentAuthor??`unknown`} \`\`\` ${n.commentBody} \`\`\` -`);let p=Hn(f);if(p.length>0&&l.push(p),r!=null&&r.trim().length>0&&e.triggerContext==null&&l.push(` +`);let g=Wn(f);if(g.length>0&&l.push(g),r!=null&&r.trim().length>0&&e.triggerContext==null&&l.push(` ${r.trim()} -`),e.triggerContext!=null){let t=e.triggerContext.eventType;(t===`pull_request`||t===`pull_request_review_comment`)&&l.push($n(n))}if(l.push(` +`),e.triggerContext!=null){let t=e.triggerContext.eventType;(t===`pull_request`||t===`pull_request_review_comment`)&&l.push(tr(n))}if(l.push(` ## Environment - **Repository:** ${n.repo} - **Branch/Ref:** ${n.ref} @@ -159,7 +159,7 @@ ${r.trim()} - **Number:** #${n.issueNumber} - **Title:** ${n.issueTitle??`N/A`} - **Type:** ${n.issueType??`unknown`} -`)}if(n.diffContext!=null&&l.push(Qn(n.diffContext)),n.hydratedContext!=null&&l.push(it(n.hydratedContext)),a!=null){let e=Zn(a,u,c,f!=null);e!=null&&l.push(e)}l.push(`# Agent Context +`)}if(n.diffContext!=null&&l.push(er(n.diffContext)),n.hydratedContext!=null&&l.push(it(n.hydratedContext)),a!=null){let e=$n(a,u,c,f!=null);e!=null&&l.push(e)}l.push(`# Agent Context You are the Fro Bot Agent running in a non-interactive CI environment (GitHub Actions). @@ -180,23 +180,23 @@ Before completing: 1. Ensure your session contains a summary of work done 2. Include key decisions, findings, and outcomes 3. This summary will be searchable in future agent runs -`),n.issueNumber!=null&&l.push(Jn(n,i,e.sessionId));let m=n.issueNumber??``,h=n.issueNumber!=null;l.push(`## GitHub Operations (Use gh CLI) +`),n.issueNumber!=null&&l.push(Xn(n,i,e.sessionId));let _=n.issueNumber??``,v=n.issueNumber!=null;l.push(`## GitHub Operations (Use gh CLI) The \`gh\` CLI is pre-authenticated. Use it for all GitHub operations. -${h?` +${v?` ### Posting Your Response See **Response Protocol** above. Post exactly one comment or review per run. \`\`\`bash # Post response as PR comment (use --body-file for long responses) -gh pr comment ${m} --body "Your response with Run Summary" +gh pr comment ${_} --body "Your response with Run Summary" # Submit PR review with response in body -gh pr review ${m} --approve --body "Your review with Run Summary" +gh pr review ${_} --approve --body "Your review with Run Summary" # Post response as issue comment -gh issue comment ${m} --body "Your response with Run Summary" +gh issue comment ${_} --body "Your response with Run Summary" \`\`\``:``} ### Creating PRs @@ -214,10 +214,10 @@ git push origin HEAD ### API Calls \`\`\`bash gh api repos/${n.repo}/issues --jq '.[].title' -gh api repos/${n.repo}/pulls/${m}/files --jq '.[].filename' +gh api repos/${n.repo}/pulls/${_}/files --jq '.[].filename' \`\`\` -`),l.push(Un());let g=l.join(` -`);return t.debug(`Built agent prompt`,{length:g.length,hasCustom:r!=null,hasSessionContext:a!=null}),g}function Jn(e,t,n){let r=e.issueNumber??``;return`## Response Protocol (REQUIRED) +`),l.push(Gn());let y=l.join(` +`);return t.debug(`Built agent prompt`,{length:y.length,hasCustom:r!=null,hasSessionContext:a!=null}),y}function Xn(e,t,n){let r=e.issueNumber??``;return`## Response Protocol (REQUIRED) You MUST post exactly ONE comment or review per invocation. All of your output — your response content AND the Run Summary — goes into that single artifact. @@ -253,17 +253,17 @@ Every response you post — regardless of channel (issue, PR, discussion, review \`\`\` -`}function Yn(e,t,n){let r=[t];if(e.recentSessions.length>0){r.push(``),r.push(`### Recent Sessions`),r.push(`| ID | Title | Updated | Messages | Agents |`),r.push(`|----|-------|---------|----------|--------|`);for(let t of e.recentSessions.slice(0,5)){let e=new Date(t.updatedAt).toISOString().split(`T`)[0],n=t.agents.join(`, `)||`N/A`,i=t.title||`Untitled`;r.push(`| ${t.id} | ${i} | ${e} | ${t.messageCount} | ${n} |`)}r.push(``),r.push("Use `session_read` to review any of these sessions in detail.")}if(n.length>0){r.push(``),r.push(`### Relevant Prior Work`),r.push(``),r.push(`The following sessions contain content related to this issue:`),r.push(``);for(let e of n.slice(0,3)){r.push(`**Session ${e.sessionId}:**`),r.push("```markdown");for(let t of e.matches.slice(0,2))r.push(`- ${t.excerpt}`);r.push("```"),r.push(``)}r.push("Use `session_read` to review full context before starting new investigation.")}return r.push(``),r.join(` -`)}function Xn(e,t){let n=e.filter(e=>e.sessionId===t);if(n.length===0)return null;let r=[];for(let e of n.slice(0,1)){r.push(`**Session ${e.sessionId}:**`),r.push("```markdown");for(let t of e.matches.slice(0,3))r.push(`- ${t.excerpt}`);r.push("```")}return r.join(` -`)}function Zn(e,t,n,r){if(t&&n!=null){let t=e.priorWorkContext.filter(e=>e.sessionId!==n);return e.recentSessions.length===0&&t.length===0?null:Yn(e,`## Related Historical Context`,t)}return e.recentSessions.length===0&&e.priorWorkContext.length===0&&r?null:Yn(e,`## Prior Session Context`,e.priorWorkContext)}function Qn(e){let t=[`## Pull Request Diff Summary`];if(t.push(``),t.push(`- **Changed Files:** ${e.changedFiles}`),t.push(`- **Additions:** +${e.additions}`),t.push(`- **Deletions:** -${e.deletions}`),e.truncated&&t.push(`- **Note:** Diff was truncated due to size limits`),e.files.length>0){t.push(``),t.push(`### Changed Files`),t.push(`| File | Status | +/- |`),t.push(`|------|--------|-----|`);for(let n of e.files.slice(0,20))t.push(`| \`${n.filename}\` | ${n.status} | +${n.additions}/-${n.deletions} |`);e.files.length>20&&t.push(`| ... | | +${e.files.length-20} more files |`)}return t.push(``),t.join(` -`)}function $n(e){let t=[`## Output Contract`,``];return t.push(`- Review action: approve/request-changes if confident; otherwise comment-only`),t.push(`- Requested reviewer: ${e.isRequestedReviewer?`yes`:`no`}`),e.authorAssociation!=null&&t.push(`- Author association: ${e.authorAssociation}`),t.push(``),t.join(` -`)}async function er(e,t,n,i){let a=Date.now(),o=new AbortController,s=n?.timeoutMs??18e5,c=null,l=!1,u=i==null,d=null;s>0&&(c=setTimeout(()=>{l=!0,t.warning(`Execution timeout reached`,{timeoutMs:s}),o.abort()},s)),t.info(`Executing OpenCode agent (SDK mode)`,{agent:n?.agent??`sisyphus`,hasModelOverride:n?.model!=null,timeoutMs:s});try{let r;if(i==null){let e=await fn({signal:o.signal});r=e.client,d=e.server}else r=i.client;let c;if(n?.continueSessionId==null){let e=n?.sessionTitle==null?void 0:{body:{title:n.sessionTitle}},i=e==null?await r.session.create():await r.session.create(e);if(i.data==null||i.error!=null)throw Error(`Failed to create session: ${i.error==null?`No data returned`:String(i.error)}`);c=i.data.id,t.info(`Created new OpenCode session`,{sessionId:c,sessionTitle:n?.sessionTitle??null})}else c=n.continueSessionId,t.info(`Continuing existing OpenCode session`,{sessionId:c});let u=qn({...e,sessionId:c},t),f=re();if(te()){let e=O(),n=Te.createHash(`sha256`).update(u).digest(`hex`),r=L.join(e,`prompt-${c}-${n.slice(0,8)}.txt`);try{await I.mkdir(e,{recursive:!0}),await I.writeFile(r,u,`utf8`),t.info(`Prompt artifact written`,{hash:n,path:r})}catch(e){t.warning(`Failed to write prompt artifact`,{error:e instanceof Error?e.message:String(e),path:r})}}let p={tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null},m=null,h=null;for(let i=1;i<=3;i++){if(l)return{success:!1,exitCode:130,duration:Date.now()-a,sessionId:c,error:`Execution timed out after ${s}ms`,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:h};if(s>0&&s-(Date.now()-a)<=5e3&&i>1)break;let o=i===1?u:`The previous request was interrupted by a network error (fetch failed). +`}function Zn(e,t,n){let r=[t];if(e.recentSessions.length>0){r.push(``),r.push(`### Recent Sessions`),r.push(`| ID | Title | Updated | Messages | Agents |`),r.push(`|----|-------|---------|----------|--------|`);for(let t of e.recentSessions.slice(0,5)){let e=new Date(t.updatedAt).toISOString().split(`T`)[0],n=t.agents.join(`, `)||`N/A`,i=t.title||`Untitled`;r.push(`| ${t.id} | ${i} | ${e} | ${t.messageCount} | ${n} |`)}r.push(``),r.push("Use `session_read` to review any of these sessions in detail.")}if(n.length>0){r.push(``),r.push(`### Relevant Prior Work`),r.push(``),r.push(`The following sessions contain content related to this issue:`),r.push(``);for(let e of n.slice(0,3)){r.push(`**Session ${e.sessionId}:**`),r.push("```markdown");for(let t of e.matches.slice(0,2))r.push(`- ${t.excerpt}`);r.push("```"),r.push(``)}r.push("Use `session_read` to review full context before starting new investigation.")}return r.push(``),r.join(` +`)}function Qn(e,t){let n=e.filter(e=>e.sessionId===t);if(n.length===0)return null;let r=[];for(let e of n.slice(0,1)){r.push(`**Session ${e.sessionId}:**`),r.push("```markdown");for(let t of e.matches.slice(0,3))r.push(`- ${t.excerpt}`);r.push("```")}return r.join(` +`)}function $n(e,t,n,r){if(t&&n!=null){let t=e.priorWorkContext.filter(e=>e.sessionId!==n);return e.recentSessions.length===0&&t.length===0?null:Zn(e,`## Related Historical Context`,t)}return e.recentSessions.length===0&&e.priorWorkContext.length===0&&r?null:Zn(e,`## Prior Session Context`,e.priorWorkContext)}function er(e){let t=[`## Pull Request Diff Summary`];if(t.push(``),t.push(`- **Changed Files:** ${e.changedFiles}`),t.push(`- **Additions:** +${e.additions}`),t.push(`- **Deletions:** -${e.deletions}`),e.truncated&&t.push(`- **Note:** Diff was truncated due to size limits`),e.files.length>0){t.push(``),t.push(`### Changed Files`),t.push(`| File | Status | +/- |`),t.push(`|------|--------|-----|`);for(let n of e.files.slice(0,20))t.push(`| \`${n.filename}\` | ${n.status} | +${n.additions}/-${n.deletions} |`);e.files.length>20&&t.push(`| ... | | +${e.files.length-20} more files |`)}return t.push(``),t.join(` +`)}function tr(e){let t=[`## Output Contract`,``];return t.push(`- Review action: approve/request-changes if confident; otherwise comment-only`),t.push(`- Requested reviewer: ${e.isRequestedReviewer?`yes`:`no`}`),e.authorAssociation!=null&&t.push(`- Author association: ${e.authorAssociation}`),t.push(``),t.join(` +`)}async function nr(e,t,n,i){let a=Date.now(),o=new AbortController,s=n?.timeoutMs??18e5,c=null,l=!1,u=i==null,d=null;s>0&&(c=setTimeout(()=>{l=!0,t.warning(`Execution timeout reached`,{timeoutMs:s}),o.abort()},s)),t.info(`Executing OpenCode agent (SDK mode)`,{agent:n?.agent??`sisyphus`,hasModelOverride:n?.model!=null,timeoutMs:s});try{let r;if(i==null){let e=await pn({signal:o.signal});r=e.client,d=e.server}else r=i.client;let c;if(n?.continueSessionId==null){let e=n?.sessionTitle==null?void 0:{body:{title:n.sessionTitle}},i=e==null?await r.session.create():await r.session.create(e);if(i.data==null||i.error!=null)throw Error(`Failed to create session: ${i.error==null?`No data returned`:String(i.error)}`);c=i.data.id,t.info(`Created new OpenCode session`,{sessionId:c,sessionTitle:n?.sessionTitle??null})}else c=n.continueSessionId,t.info(`Continuing existing OpenCode session`,{sessionId:c});let u=Yn({...e,sessionId:c},t),f=re();if(te()){let e=O(),n=Te.createHash(`sha256`).update(u).digest(`hex`),r=L.join(e,`prompt-${c}-${n.slice(0,8)}.txt`);try{await I.mkdir(e,{recursive:!0}),await I.writeFile(r,u,`utf8`),t.info(`Prompt artifact written`,{hash:n,path:r})}catch(e){t.warning(`Failed to write prompt artifact`,{error:e instanceof Error?e.message:String(e),path:r})}}let p={tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null},m=null,h=null;for(let i=1;i<=3;i++){if(l)return{success:!1,exitCode:130,duration:Date.now()-a,sessionId:c,error:`Execution timed out after ${s}ms`,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:h};if(s>0&&s-(Date.now()-a)<=5e3&&i>1)break;let o=i===1?u:`The previous request was interrupted by a network error (fetch failed). Please continue where you left off. If you were in the middle of a task, resume it. -If you had completed the task, confirm the completion.`,d=i===1?e.fileParts:void 0,g=await zn(r,c,o,d,f,n,t);if(g.success){if(p=g.eventStreamResult,n?.sessionTitle!=null)try{await r.session.update({sessionID:c,title:n.sessionTitle})}catch{t.debug(`Best-effort session title re-assertion failed`,{sessionId:c})}return{success:!0,exitCode:0,duration:Date.now()-a,sessionId:c,error:null,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:null}}if(m=g.error,h=g.llmError,!g.shouldRetry||i>=3)break;t.warning(`LLM fetch error detected, retrying with continuation prompt`,{attempt:i,maxAttempts:3,error:g.error,delayMs:In,sessionId:c}),await pn(In)}return{success:!1,exitCode:1,duration:Date.now()-a,sessionId:c,error:m??`Unknown error`,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:h}}catch(e){let n=Date.now()-a,i=r(e);return t.error(`OpenCode execution failed`,{error:i,durationMs:n}),{success:!1,exitCode:1,duration:n,sessionId:null,error:i,tokenUsage:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:yn(e)?bn(i):null}}finally{c!=null&&clearTimeout(c),o.abort(),u&&d?.close()}}async function tr(e,t,n){return t.commentId==null?(n.debug(`No comment ID, skipping eyes reaction`),!1):await Ve(e,t.repo,t.commentId,`eyes`,n)==null?!1:(n.info(`Added eyes reaction`,{commentId:t.commentId}),!0)}async function nr(e,t,n){return t.issueNumber==null?(n.debug(`No issue number, skipping working label`),!1):await We(e,t.repo,`agent: working`,`fcf2e1`,`Agent is currently working on this`,n)&&await Ge(e,t.repo,t.issueNumber,[`agent: working`],n)?(n.info(`Added working label`,{issueNumber:t.issueNumber}),!0):!1}async function rr(e,t,n){await Promise.all([tr(e,t,n),nr(e,t,n)])}async function ir(e,t,n){if(t.commentId==null||t.botLogin==null)return;let r=(await He(e,t.repo,t.commentId,n)).find(e=>e.content===`eyes`&&e.userLogin===t.botLogin);r!=null&&await Ue(e,t.repo,t.commentId,r.id,n)}async function ar(e,t,n,r){t.commentId!=null&&await Ve(e,t.repo,t.commentId,n,r)}async function or(e,t,n){if(t.commentId==null||t.botLogin==null){n.debug(`Missing comment ID or bot login, skipping reaction update`);return}try{await ir(e,t,n),await ar(e,t,`hooray`,n),n.info(`Updated reaction to success indicator`,{commentId:t.commentId,reaction:`hooray`})}catch(e){n.warning(`Failed to update reaction (non-fatal)`,{error:r(e)})}}async function sr(e,t,n){if(t.commentId==null||t.botLogin==null){n.debug(`Missing comment ID or bot login, skipping reaction update`);return}try{await ir(e,t,n),await ar(e,t,`confused`,n),n.info(`Updated reaction to confused`,{commentId:t.commentId})}catch(e){n.warning(`Failed to update failure reaction (non-fatal)`,{error:r(e)})}}async function cr(e,t,n){if(t.issueNumber==null){n.debug(`No issue number, skipping label removal`);return}await Ke(e,t.repo,t.issueNumber,`agent: working`,n)&&n.info(`Removed working label`,{issueNumber:t.issueNumber})}async function lr(e,t,n,r){n?await or(e,t,r):await sr(e,t,r),await cr(e,t,r)}var ur=class{constructor(){if(this.payload={},process.env.GITHUB_EVENT_PATH)if(be(process.env.GITHUB_EVENT_PATH))this.payload=JSON.parse(xe(process.env.GITHUB_EVENT_PATH,{encoding:`utf8`}));else{let e=process.env.GITHUB_EVENT_PATH;process.stdout.write(`GITHUB_EVENT_PATH ${e} does not exist${ve}`)}this.eventName=process.env.GITHUB_EVENT_NAME,this.sha=process.env.GITHUB_SHA,this.ref=process.env.GITHUB_REF,this.workflow=process.env.GITHUB_WORKFLOW,this.action=process.env.GITHUB_ACTION,this.actor=process.env.GITHUB_ACTOR,this.job=process.env.GITHUB_JOB,this.runAttempt=parseInt(process.env.GITHUB_RUN_ATTEMPT,10),this.runNumber=parseInt(process.env.GITHUB_RUN_NUMBER,10),this.runId=parseInt(process.env.GITHUB_RUN_ID,10),this.apiUrl=process.env.GITHUB_API_URL??`https://api.github.com`,this.serverUrl=process.env.GITHUB_SERVER_URL??`https://github.com`,this.graphqlUrl=process.env.GITHUB_GRAPHQL_URL??`https://api.github.com/graphql`}get issue(){let e=this.payload;return Object.assign(Object.assign({},this.repo),{number:(e.issue||e.pull_request||e).number})}get repo(){if(process.env.GITHUB_REPOSITORY){let[e,t]=process.env.GITHUB_REPOSITORY.split(`/`);return{owner:e,repo:t}}if(this.payload.repository)return{owner:this.payload.repository.owner.login,repo:this.payload.repository.name};throw Error(`context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'`)}},dr=S((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getProxyUrl=t,e.checkBypass=n;function t(e){let t=e.protocol===`https:`;if(n(e))return;let r=t?process.env.https_proxy||process.env.HTTPS_PROXY:process.env.http_proxy||process.env.HTTP_PROXY;if(r)try{return new i(r)}catch{if(!r.startsWith(`http://`)&&!r.startsWith(`https://`))return new i(`http://${r}`)}else return}function n(e){if(!e.hostname)return!1;let t=e.hostname;if(r(t))return!0;let n=process.env.no_proxy||process.env.NO_PROXY||``;if(!n)return!1;let i;e.port?i=Number(e.port):e.protocol===`http:`?i=80:e.protocol===`https:`&&(i=443);let a=[e.hostname.toUpperCase()];typeof i==`number`&&a.push(`${a[0]}:${i}`);for(let e of n.split(`,`).map(e=>e.trim().toUpperCase()).filter(e=>e))if(e===`*`||a.some(t=>t===e||t.endsWith(`.${e}`)||e.startsWith(`.`)&&t.endsWith(`${e}`)))return!0;return!1}function r(e){let t=e.toLowerCase();return t===`localhost`||t.startsWith(`127.`)||t.startsWith(`[::1]`)||t.startsWith(`[0:0:0:0:0:0:0:1]`)}var i=class extends URL{constructor(e,t){super(e,t),this._decodedUsername=decodeURIComponent(super.username),this._decodedPassword=decodeURIComponent(super.password)}get username(){return this._decodedUsername}get password(){return this._decodedPassword}}})),fr=C(S((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;oi(this,void 0,void 0,function*(){let t=Buffer.alloc(0);this.message.on(`data`,e=>{t=Buffer.concat([t,e])}),this.message.on(`end`,()=>{e(t.toString())})}))})}readBodyBuffer(){return i(this,void 0,void 0,function*(){return new Promise(e=>i(this,void 0,void 0,function*(){let t=[];this.message.on(`data`,e=>{t.push(e)}),this.message.on(`end`,()=>{e(Buffer.concat(t))})}))})}};e.HttpClientResponse=y;function b(e){return new URL(e).protocol===`https:`}e.HttpClient=class{constructor(e,t,n){this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=this._getUserAgentWithOrchestrationId(e),this.handlers=t||[],this.requestOptions=n,n&&(n.ignoreSslError!=null&&(this._ignoreSslError=n.ignoreSslError),this._socketTimeout=n.socketTimeout,n.allowRedirects!=null&&(this._allowRedirects=n.allowRedirects),n.allowRedirectDowngrade!=null&&(this._allowRedirectDowngrade=n.allowRedirectDowngrade),n.maxRedirects!=null&&(this._maxRedirects=Math.max(n.maxRedirects,0)),n.keepAlive!=null&&(this._keepAlive=n.keepAlive),n.allowRetries!=null&&(this._allowRetries=n.allowRetries),n.maxRetries!=null&&(this._maxRetries=n.maxRetries))}options(e,t){return i(this,void 0,void 0,function*(){return this.request(`OPTIONS`,e,null,t||{})})}get(e,t){return i(this,void 0,void 0,function*(){return this.request(`GET`,e,null,t||{})})}del(e,t){return i(this,void 0,void 0,function*(){return this.request(`DELETE`,e,null,t||{})})}post(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`POST`,e,t,n||{})})}patch(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`PATCH`,e,t,n||{})})}put(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`PUT`,e,t,n||{})})}head(e,t){return i(this,void 0,void 0,function*(){return this.request(`HEAD`,e,null,t||{})})}sendStream(e,t,n,r){return i(this,void 0,void 0,function*(){return this.request(e,t,n,r)})}getJson(e){return i(this,arguments,void 0,function*(e,t={}){t[f.Accept]=this._getExistingOrDefaultHeader(t,f.Accept,p.ApplicationJson);let n=yield this.get(e,t);return this._processResponse(n,this.requestOptions)})}postJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[f.Accept]=this._getExistingOrDefaultHeader(n,f.Accept,p.ApplicationJson),n[f.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,p.ApplicationJson);let i=yield this.post(e,r,n);return this._processResponse(i,this.requestOptions)})}putJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[f.Accept]=this._getExistingOrDefaultHeader(n,f.Accept,p.ApplicationJson),n[f.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,p.ApplicationJson);let i=yield this.put(e,r,n);return this._processResponse(i,this.requestOptions)})}patchJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[f.Accept]=this._getExistingOrDefaultHeader(n,f.Accept,p.ApplicationJson),n[f.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,p.ApplicationJson);let i=yield this.patch(e,r,n);return this._processResponse(i,this.requestOptions)})}request(e,t,n,r){return i(this,void 0,void 0,function*(){if(this._disposed)throw Error(`Client has already been disposed.`);let i=new URL(t),a=this._prepareRequest(e,i,r),o=this._allowRetries&&_.includes(e)?this._maxRetries+1:1,s=0,c;do{if(c=yield this.requestRaw(a,n),c&&c.message&&c.message.statusCode===d.Unauthorized){let e;for(let t of this.handlers)if(t.canHandleAuthentication(c)){e=t;break}return e?e.handleAuthentication(this,a,n):c}let t=this._maxRedirects;for(;c.message.statusCode&&h.includes(c.message.statusCode)&&this._allowRedirects&&t>0;){let o=c.message.headers.location;if(!o)break;let s=new URL(o);if(i.protocol===`https:`&&i.protocol!==s.protocol&&!this._allowRedirectDowngrade)throw Error(`Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.`);if(yield c.readBody(),s.hostname!==i.hostname)for(let e in r)e.toLowerCase()===`authorization`&&delete r[e];a=this._prepareRequest(e,s,r),c=yield this.requestRaw(a,n),t--}if(!c.message.statusCode||!g.includes(c.message.statusCode))return c;s+=1,s{function i(e,t){e?r(e):t?n(t):r(Error(`Unknown error`))}this.requestRawWithCallback(e,t,i)})})}requestRawWithCallback(e,t,n){typeof t==`string`&&(e.options.headers||(e.options.headers={}),e.options.headers[`Content-Length`]=Buffer.byteLength(t,`utf8`));let r=!1;function i(e,t){r||(r=!0,n(e,t))}let a=e.httpModule.request(e.options,e=>{i(void 0,new y(e))}),o;a.on(`socket`,e=>{o=e}),a.setTimeout(this._socketTimeout||3*6e4,()=>{o&&o.end(),i(Error(`Request timeout: ${e.options.path}`))}),a.on(`error`,function(e){i(e)}),t&&typeof t==`string`&&a.write(t,`utf8`),t&&typeof t!=`string`?(t.on(`close`,function(){a.end()}),t.pipe(a)):a.end()}getAgent(e){let t=new URL(e);return this._getAgent(t)}getAgentDispatcher(e){let t=new URL(e),n=s.getProxyUrl(t);if(n&&n.hostname)return this._getProxyAgentDispatcher(t,n)}_prepareRequest(e,t,n){let r={};r.parsedUrl=t;let i=r.parsedUrl.protocol===`https:`;r.httpModule=i?o:a;let s=i?443:80;if(r.options={},r.options.host=r.parsedUrl.hostname,r.options.port=r.parsedUrl.port?parseInt(r.parsedUrl.port):s,r.options.path=(r.parsedUrl.pathname||``)+(r.parsedUrl.search||``),r.options.method=e,r.options.headers=this._mergeHeaders(n),this.userAgent!=null&&(r.options.headers[`user-agent`]=this.userAgent),r.options.agent=this._getAgent(r.parsedUrl),this.handlers)for(let e of this.handlers)e.prepareRequest(r.options);return r}_mergeHeaders(e){return this.requestOptions&&this.requestOptions.headers?Object.assign({},S(this.requestOptions.headers),S(e||{})):S(e||{})}_getExistingOrDefaultHeader(e,t,n){let r;if(this.requestOptions&&this.requestOptions.headers){let e=S(this.requestOptions.headers)[t];e&&(r=typeof e==`number`?e.toString():e)}let i=e[t];return i===void 0?r===void 0?n:r:typeof i==`number`?i.toString():i}_getExistingOrDefaultContentTypeHeader(e,t){let n;if(this.requestOptions&&this.requestOptions.headers){let e=S(this.requestOptions.headers)[f.ContentType];e&&(n=typeof e==`number`?String(e):Array.isArray(e)?e.join(`, `):e)}let r=e[f.ContentType];return r===void 0?n===void 0?t:n:typeof r==`number`?String(r):Array.isArray(r)?r.join(`, `):r}_getAgent(e){let t,n=s.getProxyUrl(e),r=n&&n.hostname;if(this._keepAlive&&r&&(t=this._proxyAgent),r||(t=this._agent),t)return t;let i=e.protocol===`https:`,l=100;if(this.requestOptions&&(l=this.requestOptions.maxSockets||a.globalAgent.maxSockets),n&&n.hostname){let e={maxSockets:l,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(n.username||n.password)&&{proxyAuth:`${n.username}:${n.password}`}),{host:n.hostname,port:n.port})},r,a=n.protocol===`https:`;r=i?a?c.httpsOverHttps:c.httpsOverHttp:a?c.httpOverHttps:c.httpOverHttp,t=r(e),this._proxyAgent=t}if(!t){let e={keepAlive:this._keepAlive,maxSockets:l};t=i?new o.Agent(e):new a.Agent(e),this._agent=t}return i&&this._ignoreSslError&&(t.options=Object.assign(t.options||{},{rejectUnauthorized:!1})),t}_getProxyAgentDispatcher(e,t){let n;if(this._keepAlive&&(n=this._proxyAgentDispatcher),n)return n;let r=e.protocol===`https:`;return n=new u.ProxyAgent(Object.assign({uri:t.href,pipelining:this._keepAlive?1:0},(t.username||t.password)&&{token:`Basic ${Buffer.from(`${t.username}:${t.password}`).toString(`base64`)}`})),this._proxyAgentDispatcher=n,r&&this._ignoreSslError&&(n.options=Object.assign(n.options.requestTls||{},{rejectUnauthorized:!1})),n}_getUserAgentWithOrchestrationId(e){let t=e||`actions/http-client`,n=process.env.ACTIONS_ORCHESTRATION_ID;return n?`${t} actions_orchestration_id/${n.replace(/[^a-z0-9_.-]/gi,`_`)}`:t}_performExponentialBackoff(e){return i(this,void 0,void 0,function*(){e=Math.min(10,e);let t=5*2**e;return new Promise(e=>setTimeout(()=>e(),t))})}_processResponse(e,t){return i(this,void 0,void 0,function*(){return new Promise((n,r)=>i(this,void 0,void 0,function*(){let i=e.message.statusCode||0,a={statusCode:i,result:null,headers:{}};i===d.NotFound&&n(a);function o(e,t){if(typeof t==`string`){let e=new Date(t);if(!isNaN(e.valueOf()))return e}return t}let s,c;try{c=yield e.readBody(),c&&c.length>0&&(s=t&&t.deserializeDates?JSON.parse(c,o):JSON.parse(c),a.result=s),a.headers=e.message.headers}catch{}if(i>299){let e;e=s&&s.message?s.message:c&&c.length>0?c:`Failed request: (${i})`;let t=new v(e,i);t.result=a.result,r(t)}else n(a)}))})}};let S=e=>Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{})}))(),1),pr=ce(),mr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function hr(e,t){if(!e&&!t.auth)throw Error(`Parameter token or opts.auth is required`);if(e&&t.auth)throw Error(`Parameters token and opts.auth may not both be specified`);return typeof t.auth==`string`?t.auth:`token ${e}`}function gr(e){return new fr.HttpClient().getAgent(e)}function _r(e){return new fr.HttpClient().getAgentDispatcher(e)}function vr(e){let t=_r(e);return(e,n)=>mr(this,void 0,void 0,function*(){return(0,pr.fetch)(e,Object.assign(Object.assign({},n),{dispatcher:t}))})}function yr(){return process.env.GITHUB_API_URL||`https://api.github.com`}function br(){return typeof navigator==`object`&&`userAgent`in navigator?navigator.userAgent:typeof process==`object`&&process.version!==void 0?`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`:``}function xr(e,t,n,r){if(typeof n!=`function`)throw Error(`method for before hook must be a function`);return r||={},Array.isArray(t)?t.reverse().reduce((t,n)=>xr.bind(null,e,n,t,r),n)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((e,t)=>t.hook.bind(null,e,r),n)():n(r))}function Sr(e,t,n,r){let i=r;e.registry[n]||(e.registry[n]=[]),t===`before`&&(r=(e,t)=>Promise.resolve().then(i.bind(null,t)).then(e.bind(null,t))),t===`after`&&(r=(e,t)=>{let n;return Promise.resolve().then(e.bind(null,t)).then(e=>(n=e,i(n,t))).then(()=>n)}),t===`error`&&(r=(e,t)=>Promise.resolve().then(e.bind(null,t)).catch(e=>i(e,t))),e.registry[n].push({hook:r,orig:i})}function Cr(e,t,n){if(!e.registry[t])return;let r=e.registry[t].map(e=>e.orig).indexOf(n);r!==-1&&e.registry[t].splice(r,1)}const wr=Function.bind,Tr=wr.bind(wr);function Er(e,t,n){let r=Tr(Cr,null).apply(null,n?[t,n]:[t]);e.api={remove:r},e.remove=r,[`before`,`error`,`after`,`wrap`].forEach(r=>{let i=n?[t,r,n]:[t,r];e[r]=e.api[r]=Tr(Sr,null).apply(null,i)})}function Dr(){let e=Symbol(`Singular`),t={registry:{}},n=xr.bind(null,t,e);return Er(n,t,e),n}function Or(){let e={registry:{}},t=xr.bind(null,e);return Er(t,e),t}var kr={Singular:Dr,Collection:Or},Ar=`octokit-endpoint.js/0.0.0-development ${br()}`,jr={method:`GET`,baseUrl:`https://api.github.com`,headers:{accept:`application/vnd.github.v3+json`,"user-agent":Ar},mediaType:{format:``}};function Mr(e){return e?Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{}):{}}function Nr(e){if(typeof e!=`object`||!e||Object.prototype.toString.call(e)!==`[object Object]`)return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=Object.prototype.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Function.prototype.call(n)===Function.prototype.call(e)}function Pr(e,t){let n=Object.assign({},e);return Object.keys(t).forEach(r=>{Nr(t[r])&&r in e?n[r]=Pr(e[r],t[r]):Object.assign(n,{[r]:t[r]})}),n}function Fr(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function Ir(e,t,n){if(typeof t==`string`){let[e,r]=t.split(` `);n=Object.assign(r?{method:e,url:r}:{url:e},n)}else n=Object.assign({},t);n.headers=Mr(n.headers),Fr(n),Fr(n.headers);let r=Pr(e||{},n);return n.url===`/graphql`&&(e&&e.mediaType.previews?.length&&(r.mediaType.previews=e.mediaType.previews.filter(e=>!r.mediaType.previews.includes(e)).concat(r.mediaType.previews)),r.mediaType.previews=(r.mediaType.previews||[]).map(e=>e.replace(/-preview/,``))),r}function Lr(e,t){let n=/\?/.test(e)?`&`:`?`,r=Object.keys(t);return r.length===0?e:e+n+r.map(e=>e===`q`?`q=`+t.q.split(`+`).map(encodeURIComponent).join(`+`):`${e}=${encodeURIComponent(t[e])}`).join(`&`)}var Rr=/\{[^{}}]+\}/g;function zr(e){return e.replace(/(?:^\W+)|(?:(?e.concat(t),[]):[]}function Vr(e,t){let n={__proto__:null};for(let r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function Hr(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(e){return/%[0-9A-Fa-f]/.test(e)||(e=encodeURI(e).replace(/%5B/g,`[`).replace(/%5D/g,`]`)),e}).join(``)}function H(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return`%`+e.charCodeAt(0).toString(16).toUpperCase()})}function U(e,t,n){return t=e===`+`||e===`#`?Hr(t):H(t),n?H(n)+`=`+t:t}function W(e){return e!=null}function Ur(e){return e===`;`||e===`&`||e===`?`}function Wr(e,t,n,r){var i=e[n],a=[];if(W(i)&&i!==``)if(typeof i==`string`||typeof i==`number`||typeof i==`bigint`||typeof i==`boolean`)i=i.toString(),r&&r!==`*`&&(i=i.substring(0,parseInt(r,10))),a.push(U(t,i,Ur(t)?n:``));else if(r===`*`)Array.isArray(i)?i.filter(W).forEach(function(e){a.push(U(t,e,Ur(t)?n:``))}):Object.keys(i).forEach(function(e){W(i[e])&&a.push(U(t,i[e],e))});else{let e=[];Array.isArray(i)?i.filter(W).forEach(function(n){e.push(U(t,n))}):Object.keys(i).forEach(function(n){W(i[n])&&(e.push(H(n)),e.push(U(t,i[n].toString())))}),Ur(t)?a.push(H(n)+`=`+e.join(`,`)):e.length!==0&&a.push(e.join(`,`))}else t===`;`?W(i)&&a.push(H(n)):i===``&&(t===`&`||t===`?`)?a.push(H(n)+`=`):i===``&&a.push(``);return a}function Gr(e){return{expand:Kr.bind(null,e)}}function Kr(e,t){var n=[`+`,`#`,`.`,`/`,`;`,`?`,`&`];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(e,r,i){if(r){let e=``,i=[];if(n.indexOf(r.charAt(0))!==-1&&(e=r.charAt(0),r=r.substr(1)),r.split(/,/g).forEach(function(n){var r=/([^:\*]*)(?::(\d+)|(\*))?/.exec(n);i.push(Wr(t,e,r[1],r[2]||r[3]))}),e&&e!==`+`){var a=`,`;return e===`?`?a=`&`:e!==`#`&&(a=e),(i.length===0?``:e)+i.join(a)}else return i.join(`,`)}else return Hr(i)}),e===`/`?e:e.replace(/\/$/,``)}function qr(e){let t=e.method.toUpperCase(),n=(e.url||`/`).replace(/:([a-z]\w+)/g,`{$1}`),r=Object.assign({},e.headers),i,a=Vr(e,[`method`,`baseUrl`,`url`,`headers`,`request`,`mediaType`]),o=Br(n);n=Gr(n).expand(a),/^http/.test(n)||(n=e.baseUrl+n);let s=Vr(a,Object.keys(e).filter(e=>o.includes(e)).concat(`baseUrl`));return/application\/octet-stream/i.test(r.accept)||(e.mediaType.format&&(r.accept=r.accept.split(/,/).map(t=>t.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(`,`)),n.endsWith(`/graphql`)&&e.mediaType.previews?.length&&(r.accept=(r.accept.match(/(?`application/vnd.github.${t}-preview${e.mediaType.format?`.${e.mediaType.format}`:`+json`}`).join(`,`))),[`GET`,`HEAD`].includes(t)?n=Lr(n,s):`data`in s?i=s.data:Object.keys(s).length&&(i=s),!r[`content-type`]&&i!==void 0&&(r[`content-type`]=`application/json; charset=utf-8`),[`PATCH`,`PUT`].includes(t)&&i===void 0&&(i=``),Object.assign({method:t,url:n,headers:r},i===void 0?null:{body:i},e.request?{request:e.request}:null)}function Jr(e,t,n){return qr(Ir(e,t,n))}function Yr(e,t){let n=Ir(e,t),r=Jr.bind(null,n);return Object.assign(r,{DEFAULTS:n,defaults:Yr.bind(null,n),merge:Ir.bind(null,n),parse:qr})}var Xr=Yr(null,jr),Zr=S(((e,t)=>{let n=function(){};n.prototype=Object.create(null);let r=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu,i=/\\([\v\u0020-\u00ff])/gu,a=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,o={type:``,parameters:new n};Object.freeze(o.parameters),Object.freeze(o);function s(e){if(typeof e!=`string`)throw TypeError(`argument header is required and must be a string`);let t=e.indexOf(`;`),o=t===-1?e.trim():e.slice(0,t).trim();if(a.test(o)===!1)throw TypeError(`invalid media type`);let s={type:o.toLowerCase(),parameters:new n};if(t===-1)return s;let c,l,u;for(r.lastIndex=t;l=r.exec(e);){if(l.index!==t)throw TypeError(`invalid parameter format`);t+=l[0].length,c=l[1].toLowerCase(),u=l[2],u[0]===`"`&&(u=u.slice(1,u.length-1),i.test(u)&&(u=u.replace(i,`$1`))),s.parameters[c]=u}if(t!==e.length)throw TypeError(`invalid parameter format`);return s}function c(e){if(typeof e!=`string`)return o;let t=e.indexOf(`;`),s=t===-1?e.trim():e.slice(0,t).trim();if(a.test(s)===!1)return o;let c={type:s.toLowerCase(),parameters:new n};if(t===-1)return c;let l,u,d;for(r.lastIndex=t;u=r.exec(e);){if(u.index!==t)return o;t+=u[0].length,l=u[1].toLowerCase(),d=u[2],d[0]===`"`&&(d=d.slice(1,d.length-1),i.test(d)&&(d=d.replace(i,`$1`))),c.parameters[l]=d}return t===e.length?c:o}t.exports.default={parse:s,safeParse:c},t.exports.parse=s,t.exports.safeParse=c,t.exports.defaultContentType=o}))();const Qr=/^-?\d+$/,$r=/^-?\d+n+$/,ei=JSON.stringify,ti=JSON.parse,ni=/^-?\d+n$/,ri=/([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,ii=/([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,ai=(e,t,n)=>`rawJSON`in JSON?ei(e,(e,n)=>typeof n==`bigint`?JSON.rawJSON(n.toString()):typeof t==`function`?t(e,n):(Array.isArray(t)&&t.includes(e),n),n):e?ei(e,(e,n)=>typeof n==`string`&&n.match($r)||typeof n==`bigint`?n.toString()+`n`:typeof t==`function`?t(e,n):(Array.isArray(t)&&t.includes(e),n),n).replace(ri,`$1$2$3`).replace(ii,`$1$2$3`):ei(e,t,n),oi=()=>JSON.parse(`1`,(e,t,n)=>!!n&&n.source===`1`),si=(e,t,n,r)=>typeof t==`string`&&t.match(ni)?BigInt(t.slice(0,-1)):typeof t==`string`&&t.match($r)?t.slice(0,-1):typeof r==`function`?r(e,t,n):t,ci=(e,t)=>JSON.parse(e,(e,n,r)=>{let i=typeof n==`number`&&(n>2**53-1||n<-(2**53-1)),a=r&&Qr.test(r.source);return i&&a?BigInt(r.source):typeof t==`function`?t(e,n,r):n}),li=(2**53-1).toString(),ui=li.length,di=/"(?:\\.|[^"])*"|-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/g,fi=/^"-?\d+n+"$/,pi=(e,t)=>e?oi()?ci(e,t):ti(e.replace(di,(e,t,n,r)=>{let i=e[0]===`"`;if(i&&e.match(fi))return e.substring(0,e.length-1)+`n"`;let a=n||r,o=t&&(t.lengthsi(e,n,r,t)):ti(e,t);var mi=class extends Error{name;status;request;response;constructor(e,t,n){super(e,{cause:n.cause}),this.name=`HttpError`,this.status=Number.parseInt(t),Number.isNaN(this.status)&&(this.status=0),`response`in n&&(this.response=n.response);let r=Object.assign({},n.request);n.request.headers.authorization&&(r.headers=Object.assign({},n.request.headers,{authorization:n.request.headers.authorization.replace(/(?``;async function yi(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw Error(`fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing`);let n=e.request?.log||console,r=e.request?.parseSuccessResponseBody!==!1,i=_i(e.body)||Array.isArray(e.body)?ai(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([e,t])=>[e,String(t)])),o;try{o=await t(e.url,{method:e.method,body:i,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:`half`}})}catch(t){let n=`Unknown Error`;if(t instanceof Error){if(t.name===`AbortError`)throw t.status=500,t;n=t.message,t.name===`TypeError`&&`cause`in t&&(t.cause instanceof Error?n=t.cause.message:typeof t.cause==`string`&&(n=t.cause))}let r=new mi(n,500,{request:e});throw r.cause=t,r}let s=o.status,c=o.url,l={};for(let[e,t]of o.headers)l[e]=t;let u={url:c,status:s,headers:l,data:``};if(`deprecation`in l){let t=l.link&&l.link.match(/<([^<>]+)>; rel="deprecation"/),r=t&&t.pop();n.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${l.sunset}${r?`. See ${r}`:``}`)}if(s===204||s===205)return u;if(e.method===`HEAD`){if(s<400)return u;throw new mi(o.statusText,s,{response:u,request:e})}if(s===304)throw u.data=await bi(o),new mi(`Not modified`,s,{response:u,request:e});if(s>=400)throw u.data=await bi(o),new mi(Si(u.data),s,{response:u,request:e});return u.data=r?await bi(o):o.body,u}async function bi(e){let t=e.headers.get(`content-type`);if(!t)return e.text().catch(vi);let n=(0,Zr.safeParse)(t);if(xi(n)){let t=``;try{return t=await e.text(),pi(t)}catch{return t}}else if(n.type.startsWith(`text/`)||n.parameters.charset?.toLowerCase()===`utf-8`)return e.text().catch(vi);else return e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function xi(e){return e.type===`application/json`||e.type===`application/scim+json`}function Si(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return`Unknown error`;if(`message`in e){let t=`documentation_url`in e?` - ${e.documentation_url}`:``;return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(e=>JSON.stringify(e)).join(`, `)}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function Ci(e,t){let n=e.defaults(t);return Object.assign(function(e,t){let r=n.merge(e,t);if(!r.request||!r.request.hook)return yi(n.parse(r));let i=(e,t)=>yi(n.parse(n.merge(e,t)));return Object.assign(i,{endpoint:n,defaults:Ci.bind(null,n)}),r.request.hook(i,r)},{endpoint:n,defaults:Ci.bind(null,n)})}var wi=Ci(Xr,gi),Ti=`0.0.0-development`;function Ei(e){return`Request failed due to following response errors: +If you had completed the task, confirm the completion.`,d=i===1?e.fileParts:void 0,g=await(async()=>{try{return await Vn(r,c,o,d,f,n,t)}finally{await mn(r,c,n?.sessionTitle,t)}})();if(g.success)return p=g.eventStreamResult,{success:!0,exitCode:0,duration:Date.now()-a,sessionId:c,error:null,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:null};if(m=g.error,h=g.llmError,!g.shouldRetry||i>=3)break;t.warning(`LLM fetch error detected, retrying with continuation prompt`,{attempt:i,maxAttempts:3,error:g.error,delayMs:Rn,sessionId:c}),await hn(Rn)}return{success:!1,exitCode:1,duration:Date.now()-a,sessionId:c,error:m??`Unknown error`,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:h}}catch(e){let n=Date.now()-a,i=r(e);return t.error(`OpenCode execution failed`,{error:i,durationMs:n}),{success:!1,exitCode:1,duration:n,sessionId:null,error:i,tokenUsage:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:xn(e)?Sn(i):null}}finally{c!=null&&clearTimeout(c),o.abort(),u&&d?.close()}}async function rr(e,t,n){return t.commentId==null?(n.debug(`No comment ID, skipping eyes reaction`),!1):await Ve(e,t.repo,t.commentId,`eyes`,n)==null?!1:(n.info(`Added eyes reaction`,{commentId:t.commentId}),!0)}async function ir(e,t,n){return t.issueNumber==null?(n.debug(`No issue number, skipping working label`),!1):await We(e,t.repo,`agent: working`,`fcf2e1`,`Agent is currently working on this`,n)&&await Ge(e,t.repo,t.issueNumber,[`agent: working`],n)?(n.info(`Added working label`,{issueNumber:t.issueNumber}),!0):!1}async function ar(e,t,n){await Promise.all([rr(e,t,n),ir(e,t,n)])}async function or(e,t,n){if(t.commentId==null||t.botLogin==null)return;let r=(await He(e,t.repo,t.commentId,n)).find(e=>e.content===`eyes`&&e.userLogin===t.botLogin);r!=null&&await Ue(e,t.repo,t.commentId,r.id,n)}async function sr(e,t,n,r){t.commentId!=null&&await Ve(e,t.repo,t.commentId,n,r)}async function cr(e,t,n){if(t.commentId==null||t.botLogin==null){n.debug(`Missing comment ID or bot login, skipping reaction update`);return}try{await or(e,t,n),await sr(e,t,`hooray`,n),n.info(`Updated reaction to success indicator`,{commentId:t.commentId,reaction:`hooray`})}catch(e){n.warning(`Failed to update reaction (non-fatal)`,{error:r(e)})}}async function lr(e,t,n){if(t.commentId==null||t.botLogin==null){n.debug(`Missing comment ID or bot login, skipping reaction update`);return}try{await or(e,t,n),await sr(e,t,`confused`,n),n.info(`Updated reaction to confused`,{commentId:t.commentId})}catch(e){n.warning(`Failed to update failure reaction (non-fatal)`,{error:r(e)})}}async function ur(e,t,n){if(t.issueNumber==null){n.debug(`No issue number, skipping label removal`);return}await Ke(e,t.repo,t.issueNumber,`agent: working`,n)&&n.info(`Removed working label`,{issueNumber:t.issueNumber})}async function dr(e,t,n,r){n?await cr(e,t,r):await lr(e,t,r),await ur(e,t,r)}var fr=class{constructor(){if(this.payload={},process.env.GITHUB_EVENT_PATH)if(be(process.env.GITHUB_EVENT_PATH))this.payload=JSON.parse(xe(process.env.GITHUB_EVENT_PATH,{encoding:`utf8`}));else{let e=process.env.GITHUB_EVENT_PATH;process.stdout.write(`GITHUB_EVENT_PATH ${e} does not exist${ve}`)}this.eventName=process.env.GITHUB_EVENT_NAME,this.sha=process.env.GITHUB_SHA,this.ref=process.env.GITHUB_REF,this.workflow=process.env.GITHUB_WORKFLOW,this.action=process.env.GITHUB_ACTION,this.actor=process.env.GITHUB_ACTOR,this.job=process.env.GITHUB_JOB,this.runAttempt=parseInt(process.env.GITHUB_RUN_ATTEMPT,10),this.runNumber=parseInt(process.env.GITHUB_RUN_NUMBER,10),this.runId=parseInt(process.env.GITHUB_RUN_ID,10),this.apiUrl=process.env.GITHUB_API_URL??`https://api.github.com`,this.serverUrl=process.env.GITHUB_SERVER_URL??`https://github.com`,this.graphqlUrl=process.env.GITHUB_GRAPHQL_URL??`https://api.github.com/graphql`}get issue(){let e=this.payload;return Object.assign(Object.assign({},this.repo),{number:(e.issue||e.pull_request||e).number})}get repo(){if(process.env.GITHUB_REPOSITORY){let[e,t]=process.env.GITHUB_REPOSITORY.split(`/`);return{owner:e,repo:t}}if(this.payload.repository)return{owner:this.payload.repository.owner.login,repo:this.payload.repository.name};throw Error(`context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'`)}},pr=S((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getProxyUrl=t,e.checkBypass=n;function t(e){let t=e.protocol===`https:`;if(n(e))return;let r=t?process.env.https_proxy||process.env.HTTPS_PROXY:process.env.http_proxy||process.env.HTTP_PROXY;if(r)try{return new i(r)}catch{if(!r.startsWith(`http://`)&&!r.startsWith(`https://`))return new i(`http://${r}`)}else return}function n(e){if(!e.hostname)return!1;let t=e.hostname;if(r(t))return!0;let n=process.env.no_proxy||process.env.NO_PROXY||``;if(!n)return!1;let i;e.port?i=Number(e.port):e.protocol===`http:`?i=80:e.protocol===`https:`&&(i=443);let a=[e.hostname.toUpperCase()];typeof i==`number`&&a.push(`${a[0]}:${i}`);for(let e of n.split(`,`).map(e=>e.trim().toUpperCase()).filter(e=>e))if(e===`*`||a.some(t=>t===e||t.endsWith(`.${e}`)||e.startsWith(`.`)&&t.endsWith(`${e}`)))return!0;return!1}function r(e){let t=e.toLowerCase();return t===`localhost`||t.startsWith(`127.`)||t.startsWith(`[::1]`)||t.startsWith(`[0:0:0:0:0:0:0:1]`)}var i=class extends URL{constructor(e,t){super(e,t),this._decodedUsername=decodeURIComponent(super.username),this._decodedPassword=decodeURIComponent(super.password)}get username(){return this._decodedUsername}get password(){return this._decodedPassword}}})),mr=C(S((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;oi(this,void 0,void 0,function*(){let t=Buffer.alloc(0);this.message.on(`data`,e=>{t=Buffer.concat([t,e])}),this.message.on(`end`,()=>{e(t.toString())})}))})}readBodyBuffer(){return i(this,void 0,void 0,function*(){return new Promise(e=>i(this,void 0,void 0,function*(){let t=[];this.message.on(`data`,e=>{t.push(e)}),this.message.on(`end`,()=>{e(Buffer.concat(t))})}))})}};e.HttpClientResponse=y;function b(e){return new URL(e).protocol===`https:`}e.HttpClient=class{constructor(e,t,n){this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=this._getUserAgentWithOrchestrationId(e),this.handlers=t||[],this.requestOptions=n,n&&(n.ignoreSslError!=null&&(this._ignoreSslError=n.ignoreSslError),this._socketTimeout=n.socketTimeout,n.allowRedirects!=null&&(this._allowRedirects=n.allowRedirects),n.allowRedirectDowngrade!=null&&(this._allowRedirectDowngrade=n.allowRedirectDowngrade),n.maxRedirects!=null&&(this._maxRedirects=Math.max(n.maxRedirects,0)),n.keepAlive!=null&&(this._keepAlive=n.keepAlive),n.allowRetries!=null&&(this._allowRetries=n.allowRetries),n.maxRetries!=null&&(this._maxRetries=n.maxRetries))}options(e,t){return i(this,void 0,void 0,function*(){return this.request(`OPTIONS`,e,null,t||{})})}get(e,t){return i(this,void 0,void 0,function*(){return this.request(`GET`,e,null,t||{})})}del(e,t){return i(this,void 0,void 0,function*(){return this.request(`DELETE`,e,null,t||{})})}post(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`POST`,e,t,n||{})})}patch(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`PATCH`,e,t,n||{})})}put(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`PUT`,e,t,n||{})})}head(e,t){return i(this,void 0,void 0,function*(){return this.request(`HEAD`,e,null,t||{})})}sendStream(e,t,n,r){return i(this,void 0,void 0,function*(){return this.request(e,t,n,r)})}getJson(e){return i(this,arguments,void 0,function*(e,t={}){t[f.Accept]=this._getExistingOrDefaultHeader(t,f.Accept,p.ApplicationJson);let n=yield this.get(e,t);return this._processResponse(n,this.requestOptions)})}postJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[f.Accept]=this._getExistingOrDefaultHeader(n,f.Accept,p.ApplicationJson),n[f.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,p.ApplicationJson);let i=yield this.post(e,r,n);return this._processResponse(i,this.requestOptions)})}putJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[f.Accept]=this._getExistingOrDefaultHeader(n,f.Accept,p.ApplicationJson),n[f.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,p.ApplicationJson);let i=yield this.put(e,r,n);return this._processResponse(i,this.requestOptions)})}patchJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[f.Accept]=this._getExistingOrDefaultHeader(n,f.Accept,p.ApplicationJson),n[f.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,p.ApplicationJson);let i=yield this.patch(e,r,n);return this._processResponse(i,this.requestOptions)})}request(e,t,n,r){return i(this,void 0,void 0,function*(){if(this._disposed)throw Error(`Client has already been disposed.`);let i=new URL(t),a=this._prepareRequest(e,i,r),o=this._allowRetries&&_.includes(e)?this._maxRetries+1:1,s=0,c;do{if(c=yield this.requestRaw(a,n),c&&c.message&&c.message.statusCode===d.Unauthorized){let e;for(let t of this.handlers)if(t.canHandleAuthentication(c)){e=t;break}return e?e.handleAuthentication(this,a,n):c}let t=this._maxRedirects;for(;c.message.statusCode&&h.includes(c.message.statusCode)&&this._allowRedirects&&t>0;){let o=c.message.headers.location;if(!o)break;let s=new URL(o);if(i.protocol===`https:`&&i.protocol!==s.protocol&&!this._allowRedirectDowngrade)throw Error(`Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.`);if(yield c.readBody(),s.hostname!==i.hostname)for(let e in r)e.toLowerCase()===`authorization`&&delete r[e];a=this._prepareRequest(e,s,r),c=yield this.requestRaw(a,n),t--}if(!c.message.statusCode||!g.includes(c.message.statusCode))return c;s+=1,s{function i(e,t){e?r(e):t?n(t):r(Error(`Unknown error`))}this.requestRawWithCallback(e,t,i)})})}requestRawWithCallback(e,t,n){typeof t==`string`&&(e.options.headers||(e.options.headers={}),e.options.headers[`Content-Length`]=Buffer.byteLength(t,`utf8`));let r=!1;function i(e,t){r||(r=!0,n(e,t))}let a=e.httpModule.request(e.options,e=>{i(void 0,new y(e))}),o;a.on(`socket`,e=>{o=e}),a.setTimeout(this._socketTimeout||3*6e4,()=>{o&&o.end(),i(Error(`Request timeout: ${e.options.path}`))}),a.on(`error`,function(e){i(e)}),t&&typeof t==`string`&&a.write(t,`utf8`),t&&typeof t!=`string`?(t.on(`close`,function(){a.end()}),t.pipe(a)):a.end()}getAgent(e){let t=new URL(e);return this._getAgent(t)}getAgentDispatcher(e){let t=new URL(e),n=s.getProxyUrl(t);if(n&&n.hostname)return this._getProxyAgentDispatcher(t,n)}_prepareRequest(e,t,n){let r={};r.parsedUrl=t;let i=r.parsedUrl.protocol===`https:`;r.httpModule=i?o:a;let s=i?443:80;if(r.options={},r.options.host=r.parsedUrl.hostname,r.options.port=r.parsedUrl.port?parseInt(r.parsedUrl.port):s,r.options.path=(r.parsedUrl.pathname||``)+(r.parsedUrl.search||``),r.options.method=e,r.options.headers=this._mergeHeaders(n),this.userAgent!=null&&(r.options.headers[`user-agent`]=this.userAgent),r.options.agent=this._getAgent(r.parsedUrl),this.handlers)for(let e of this.handlers)e.prepareRequest(r.options);return r}_mergeHeaders(e){return this.requestOptions&&this.requestOptions.headers?Object.assign({},S(this.requestOptions.headers),S(e||{})):S(e||{})}_getExistingOrDefaultHeader(e,t,n){let r;if(this.requestOptions&&this.requestOptions.headers){let e=S(this.requestOptions.headers)[t];e&&(r=typeof e==`number`?e.toString():e)}let i=e[t];return i===void 0?r===void 0?n:r:typeof i==`number`?i.toString():i}_getExistingOrDefaultContentTypeHeader(e,t){let n;if(this.requestOptions&&this.requestOptions.headers){let e=S(this.requestOptions.headers)[f.ContentType];e&&(n=typeof e==`number`?String(e):Array.isArray(e)?e.join(`, `):e)}let r=e[f.ContentType];return r===void 0?n===void 0?t:n:typeof r==`number`?String(r):Array.isArray(r)?r.join(`, `):r}_getAgent(e){let t,n=s.getProxyUrl(e),r=n&&n.hostname;if(this._keepAlive&&r&&(t=this._proxyAgent),r||(t=this._agent),t)return t;let i=e.protocol===`https:`,l=100;if(this.requestOptions&&(l=this.requestOptions.maxSockets||a.globalAgent.maxSockets),n&&n.hostname){let e={maxSockets:l,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(n.username||n.password)&&{proxyAuth:`${n.username}:${n.password}`}),{host:n.hostname,port:n.port})},r,a=n.protocol===`https:`;r=i?a?c.httpsOverHttps:c.httpsOverHttp:a?c.httpOverHttps:c.httpOverHttp,t=r(e),this._proxyAgent=t}if(!t){let e={keepAlive:this._keepAlive,maxSockets:l};t=i?new o.Agent(e):new a.Agent(e),this._agent=t}return i&&this._ignoreSslError&&(t.options=Object.assign(t.options||{},{rejectUnauthorized:!1})),t}_getProxyAgentDispatcher(e,t){let n;if(this._keepAlive&&(n=this._proxyAgentDispatcher),n)return n;let r=e.protocol===`https:`;return n=new u.ProxyAgent(Object.assign({uri:t.href,pipelining:this._keepAlive?1:0},(t.username||t.password)&&{token:`Basic ${Buffer.from(`${t.username}:${t.password}`).toString(`base64`)}`})),this._proxyAgentDispatcher=n,r&&this._ignoreSslError&&(n.options=Object.assign(n.options.requestTls||{},{rejectUnauthorized:!1})),n}_getUserAgentWithOrchestrationId(e){let t=e||`actions/http-client`,n=process.env.ACTIONS_ORCHESTRATION_ID;return n?`${t} actions_orchestration_id/${n.replace(/[^a-z0-9_.-]/gi,`_`)}`:t}_performExponentialBackoff(e){return i(this,void 0,void 0,function*(){e=Math.min(10,e);let t=5*2**e;return new Promise(e=>setTimeout(()=>e(),t))})}_processResponse(e,t){return i(this,void 0,void 0,function*(){return new Promise((n,r)=>i(this,void 0,void 0,function*(){let i=e.message.statusCode||0,a={statusCode:i,result:null,headers:{}};i===d.NotFound&&n(a);function o(e,t){if(typeof t==`string`){let e=new Date(t);if(!isNaN(e.valueOf()))return e}return t}let s,c;try{c=yield e.readBody(),c&&c.length>0&&(s=t&&t.deserializeDates?JSON.parse(c,o):JSON.parse(c),a.result=s),a.headers=e.message.headers}catch{}if(i>299){let e;e=s&&s.message?s.message:c&&c.length>0?c:`Failed request: (${i})`;let t=new v(e,i);t.result=a.result,r(t)}else n(a)}))})}};let S=e=>Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{})}))(),1),hr=ce(),gr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function _r(e,t){if(!e&&!t.auth)throw Error(`Parameter token or opts.auth is required`);if(e&&t.auth)throw Error(`Parameters token and opts.auth may not both be specified`);return typeof t.auth==`string`?t.auth:`token ${e}`}function vr(e){return new mr.HttpClient().getAgent(e)}function yr(e){return new mr.HttpClient().getAgentDispatcher(e)}function br(e){let t=yr(e);return(e,n)=>gr(this,void 0,void 0,function*(){return(0,hr.fetch)(e,Object.assign(Object.assign({},n),{dispatcher:t}))})}function xr(){return process.env.GITHUB_API_URL||`https://api.github.com`}function V(){return typeof navigator==`object`&&`userAgent`in navigator?navigator.userAgent:typeof process==`object`&&process.version!==void 0?`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`:``}function Sr(e,t,n,r){if(typeof n!=`function`)throw Error(`method for before hook must be a function`);return r||={},Array.isArray(t)?t.reverse().reduce((t,n)=>Sr.bind(null,e,n,t,r),n)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((e,t)=>t.hook.bind(null,e,r),n)():n(r))}function Cr(e,t,n,r){let i=r;e.registry[n]||(e.registry[n]=[]),t===`before`&&(r=(e,t)=>Promise.resolve().then(i.bind(null,t)).then(e.bind(null,t))),t===`after`&&(r=(e,t)=>{let n;return Promise.resolve().then(e.bind(null,t)).then(e=>(n=e,i(n,t))).then(()=>n)}),t===`error`&&(r=(e,t)=>Promise.resolve().then(e.bind(null,t)).catch(e=>i(e,t))),e.registry[n].push({hook:r,orig:i})}function wr(e,t,n){if(!e.registry[t])return;let r=e.registry[t].map(e=>e.orig).indexOf(n);r!==-1&&e.registry[t].splice(r,1)}const Tr=Function.bind,Er=Tr.bind(Tr);function Dr(e,t,n){let r=Er(wr,null).apply(null,n?[t,n]:[t]);e.api={remove:r},e.remove=r,[`before`,`error`,`after`,`wrap`].forEach(r=>{let i=n?[t,r,n]:[t,r];e[r]=e.api[r]=Er(Cr,null).apply(null,i)})}function Or(){let e=Symbol(`Singular`),t={registry:{}},n=Sr.bind(null,t,e);return Dr(n,t,e),n}function kr(){let e={registry:{}},t=Sr.bind(null,e);return Dr(t,e),t}var Ar={Singular:Or,Collection:kr},jr=`octokit-endpoint.js/0.0.0-development ${V()}`,Mr={method:`GET`,baseUrl:`https://api.github.com`,headers:{accept:`application/vnd.github.v3+json`,"user-agent":jr},mediaType:{format:``}};function Nr(e){return e?Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{}):{}}function Pr(e){if(typeof e!=`object`||!e||Object.prototype.toString.call(e)!==`[object Object]`)return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=Object.prototype.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Function.prototype.call(n)===Function.prototype.call(e)}function Fr(e,t){let n=Object.assign({},e);return Object.keys(t).forEach(r=>{Pr(t[r])&&r in e?n[r]=Fr(e[r],t[r]):Object.assign(n,{[r]:t[r]})}),n}function Ir(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function Lr(e,t,n){if(typeof t==`string`){let[e,r]=t.split(` `);n=Object.assign(r?{method:e,url:r}:{url:e},n)}else n=Object.assign({},t);n.headers=Nr(n.headers),Ir(n),Ir(n.headers);let r=Fr(e||{},n);return n.url===`/graphql`&&(e&&e.mediaType.previews?.length&&(r.mediaType.previews=e.mediaType.previews.filter(e=>!r.mediaType.previews.includes(e)).concat(r.mediaType.previews)),r.mediaType.previews=(r.mediaType.previews||[]).map(e=>e.replace(/-preview/,``))),r}function Rr(e,t){let n=/\?/.test(e)?`&`:`?`,r=Object.keys(t);return r.length===0?e:e+n+r.map(e=>e===`q`?`q=`+t.q.split(`+`).map(encodeURIComponent).join(`+`):`${e}=${encodeURIComponent(t[e])}`).join(`&`)}var zr=/\{[^{}}]+\}/g;function Br(e){return e.replace(/(?:^\W+)|(?:(?e.concat(t),[]):[]}function Hr(e,t){let n={__proto__:null};for(let r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function Ur(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(e){return/%[0-9A-Fa-f]/.test(e)||(e=encodeURI(e).replace(/%5B/g,`[`).replace(/%5D/g,`]`)),e}).join(``)}function H(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return`%`+e.charCodeAt(0).toString(16).toUpperCase()})}function U(e,t,n){return t=e===`+`||e===`#`?Ur(t):H(t),n?H(n)+`=`+t:t}function W(e){return e!=null}function Wr(e){return e===`;`||e===`&`||e===`?`}function Gr(e,t,n,r){var i=e[n],a=[];if(W(i)&&i!==``)if(typeof i==`string`||typeof i==`number`||typeof i==`bigint`||typeof i==`boolean`)i=i.toString(),r&&r!==`*`&&(i=i.substring(0,parseInt(r,10))),a.push(U(t,i,Wr(t)?n:``));else if(r===`*`)Array.isArray(i)?i.filter(W).forEach(function(e){a.push(U(t,e,Wr(t)?n:``))}):Object.keys(i).forEach(function(e){W(i[e])&&a.push(U(t,i[e],e))});else{let e=[];Array.isArray(i)?i.filter(W).forEach(function(n){e.push(U(t,n))}):Object.keys(i).forEach(function(n){W(i[n])&&(e.push(H(n)),e.push(U(t,i[n].toString())))}),Wr(t)?a.push(H(n)+`=`+e.join(`,`)):e.length!==0&&a.push(e.join(`,`))}else t===`;`?W(i)&&a.push(H(n)):i===``&&(t===`&`||t===`?`)?a.push(H(n)+`=`):i===``&&a.push(``);return a}function Kr(e){return{expand:qr.bind(null,e)}}function qr(e,t){var n=[`+`,`#`,`.`,`/`,`;`,`?`,`&`];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(e,r,i){if(r){let e=``,i=[];if(n.indexOf(r.charAt(0))!==-1&&(e=r.charAt(0),r=r.substr(1)),r.split(/,/g).forEach(function(n){var r=/([^:\*]*)(?::(\d+)|(\*))?/.exec(n);i.push(Gr(t,e,r[1],r[2]||r[3]))}),e&&e!==`+`){var a=`,`;return e===`?`?a=`&`:e!==`#`&&(a=e),(i.length===0?``:e)+i.join(a)}else return i.join(`,`)}else return Ur(i)}),e===`/`?e:e.replace(/\/$/,``)}function Jr(e){let t=e.method.toUpperCase(),n=(e.url||`/`).replace(/:([a-z]\w+)/g,`{$1}`),r=Object.assign({},e.headers),i,a=Hr(e,[`method`,`baseUrl`,`url`,`headers`,`request`,`mediaType`]),o=Vr(n);n=Kr(n).expand(a),/^http/.test(n)||(n=e.baseUrl+n);let s=Hr(a,Object.keys(e).filter(e=>o.includes(e)).concat(`baseUrl`));return/application\/octet-stream/i.test(r.accept)||(e.mediaType.format&&(r.accept=r.accept.split(/,/).map(t=>t.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(`,`)),n.endsWith(`/graphql`)&&e.mediaType.previews?.length&&(r.accept=(r.accept.match(/(?`application/vnd.github.${t}-preview${e.mediaType.format?`.${e.mediaType.format}`:`+json`}`).join(`,`))),[`GET`,`HEAD`].includes(t)?n=Rr(n,s):`data`in s?i=s.data:Object.keys(s).length&&(i=s),!r[`content-type`]&&i!==void 0&&(r[`content-type`]=`application/json; charset=utf-8`),[`PATCH`,`PUT`].includes(t)&&i===void 0&&(i=``),Object.assign({method:t,url:n,headers:r},i===void 0?null:{body:i},e.request?{request:e.request}:null)}function Yr(e,t,n){return Jr(Lr(e,t,n))}function Xr(e,t){let n=Lr(e,t),r=Yr.bind(null,n);return Object.assign(r,{DEFAULTS:n,defaults:Xr.bind(null,n),merge:Lr.bind(null,n),parse:Jr})}var Zr=Xr(null,Mr),Qr=S(((e,t)=>{let n=function(){};n.prototype=Object.create(null);let r=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu,i=/\\([\v\u0020-\u00ff])/gu,a=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,o={type:``,parameters:new n};Object.freeze(o.parameters),Object.freeze(o);function s(e){if(typeof e!=`string`)throw TypeError(`argument header is required and must be a string`);let t=e.indexOf(`;`),o=t===-1?e.trim():e.slice(0,t).trim();if(a.test(o)===!1)throw TypeError(`invalid media type`);let s={type:o.toLowerCase(),parameters:new n};if(t===-1)return s;let c,l,u;for(r.lastIndex=t;l=r.exec(e);){if(l.index!==t)throw TypeError(`invalid parameter format`);t+=l[0].length,c=l[1].toLowerCase(),u=l[2],u[0]===`"`&&(u=u.slice(1,u.length-1),i.test(u)&&(u=u.replace(i,`$1`))),s.parameters[c]=u}if(t!==e.length)throw TypeError(`invalid parameter format`);return s}function c(e){if(typeof e!=`string`)return o;let t=e.indexOf(`;`),s=t===-1?e.trim():e.slice(0,t).trim();if(a.test(s)===!1)return o;let c={type:s.toLowerCase(),parameters:new n};if(t===-1)return c;let l,u,d;for(r.lastIndex=t;u=r.exec(e);){if(u.index!==t)return o;t+=u[0].length,l=u[1].toLowerCase(),d=u[2],d[0]===`"`&&(d=d.slice(1,d.length-1),i.test(d)&&(d=d.replace(i,`$1`))),c.parameters[l]=d}return t===e.length?c:o}t.exports.default={parse:s,safeParse:c},t.exports.parse=s,t.exports.safeParse=c,t.exports.defaultContentType=o}))();const $r=/^-?\d+$/,ei=/^-?\d+n+$/,ti=JSON.stringify,ni=JSON.parse,ri=/^-?\d+n$/,ii=/([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,ai=/([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,oi=(e,t,n)=>`rawJSON`in JSON?ti(e,(e,n)=>typeof n==`bigint`?JSON.rawJSON(n.toString()):typeof t==`function`?t(e,n):(Array.isArray(t)&&t.includes(e),n),n):e?ti(e,(e,n)=>typeof n==`string`&&n.match(ei)||typeof n==`bigint`?n.toString()+`n`:typeof t==`function`?t(e,n):(Array.isArray(t)&&t.includes(e),n),n).replace(ii,`$1$2$3`).replace(ai,`$1$2$3`):ti(e,t,n),si=()=>JSON.parse(`1`,(e,t,n)=>!!n&&n.source===`1`),ci=(e,t,n,r)=>typeof t==`string`&&t.match(ri)?BigInt(t.slice(0,-1)):typeof t==`string`&&t.match(ei)?t.slice(0,-1):typeof r==`function`?r(e,t,n):t,li=(e,t)=>JSON.parse(e,(e,n,r)=>{let i=typeof n==`number`&&(n>2**53-1||n<-(2**53-1)),a=r&&$r.test(r.source);return i&&a?BigInt(r.source):typeof t==`function`?t(e,n,r):n}),ui=(2**53-1).toString(),di=ui.length,fi=/"(?:\\.|[^"])*"|-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/g,pi=/^"-?\d+n+"$/,mi=(e,t)=>e?si()?li(e,t):ni(e.replace(fi,(e,t,n,r)=>{let i=e[0]===`"`;if(i&&e.match(pi))return e.substring(0,e.length-1)+`n"`;let a=n||r,o=t&&(t.lengthci(e,n,r,t)):ni(e,t);var hi=class extends Error{name;status;request;response;constructor(e,t,n){super(e,{cause:n.cause}),this.name=`HttpError`,this.status=Number.parseInt(t),Number.isNaN(this.status)&&(this.status=0),`response`in n&&(this.response=n.response);let r=Object.assign({},n.request);n.request.headers.authorization&&(r.headers=Object.assign({},n.request.headers,{authorization:n.request.headers.authorization.replace(/(?``;async function bi(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw Error(`fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing`);let n=e.request?.log||console,r=e.request?.parseSuccessResponseBody!==!1,i=vi(e.body)||Array.isArray(e.body)?oi(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([e,t])=>[e,String(t)])),o;try{o=await t(e.url,{method:e.method,body:i,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:`half`}})}catch(t){let n=`Unknown Error`;if(t instanceof Error){if(t.name===`AbortError`)throw t.status=500,t;n=t.message,t.name===`TypeError`&&`cause`in t&&(t.cause instanceof Error?n=t.cause.message:typeof t.cause==`string`&&(n=t.cause))}let r=new hi(n,500,{request:e});throw r.cause=t,r}let s=o.status,c=o.url,l={};for(let[e,t]of o.headers)l[e]=t;let u={url:c,status:s,headers:l,data:``};if(`deprecation`in l){let t=l.link&&l.link.match(/<([^<>]+)>; rel="deprecation"/),r=t&&t.pop();n.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${l.sunset}${r?`. See ${r}`:``}`)}if(s===204||s===205)return u;if(e.method===`HEAD`){if(s<400)return u;throw new hi(o.statusText,s,{response:u,request:e})}if(s===304)throw u.data=await xi(o),new hi(`Not modified`,s,{response:u,request:e});if(s>=400)throw u.data=await xi(o),new hi(Ci(u.data),s,{response:u,request:e});return u.data=r?await xi(o):o.body,u}async function xi(e){let t=e.headers.get(`content-type`);if(!t)return e.text().catch(yi);let n=(0,Qr.safeParse)(t);if(Si(n)){let t=``;try{return t=await e.text(),mi(t)}catch{return t}}else if(n.type.startsWith(`text/`)||n.parameters.charset?.toLowerCase()===`utf-8`)return e.text().catch(yi);else return e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function Si(e){return e.type===`application/json`||e.type===`application/scim+json`}function Ci(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return`Unknown error`;if(`message`in e){let t=`documentation_url`in e?` - ${e.documentation_url}`:``;return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(e=>JSON.stringify(e)).join(`, `)}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function wi(e,t){let n=e.defaults(t);return Object.assign(function(e,t){let r=n.merge(e,t);if(!r.request||!r.request.hook)return bi(n.parse(r));let i=(e,t)=>bi(n.parse(n.merge(e,t)));return Object.assign(i,{endpoint:n,defaults:wi.bind(null,n)}),r.request.hook(i,r)},{endpoint:n,defaults:wi.bind(null,n)})}var Ti=wi(Zr,_i),Ei=`0.0.0-development`;function Di(e){return`Request failed due to following response errors: `+e.errors.map(e=>` - ${e.message}`).join(` -`)}var Di=class extends Error{constructor(e,t,n){super(Ei(n)),this.request=e,this.headers=t,this.response=n,this.errors=n.errors,this.data=n.data,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}name=`GraphqlResponseError`;errors;data},Oi=[`method`,`baseUrl`,`url`,`headers`,`request`,`query`,`mediaType`,`operationName`],ki=[`query`,`method`,`url`],Ai=/\/api\/v3\/?$/;function ji(e,t,n){if(n){if(typeof t==`string`&&`query`in n)return Promise.reject(Error(`[@octokit/graphql] "query" cannot be used as variable name`));for(let e in n)if(ki.includes(e))return Promise.reject(Error(`[@octokit/graphql] "${e}" cannot be used as variable name`))}let r=typeof t==`string`?Object.assign({query:t},n):t,i=Object.keys(r).reduce((e,t)=>Oi.includes(t)?(e[t]=r[t],e):(e.variables||={},e.variables[t]=r[t],e),{}),a=r.baseUrl||e.endpoint.DEFAULTS.baseUrl;return Ai.test(a)&&(i.url=a.replace(Ai,`/api/graphql`)),e(i).then(e=>{if(e.data.errors){let t={};for(let n of Object.keys(e.headers))t[n]=e.headers[n];throw new Di(i,t,e.data)}return e.data.data})}function Mi(e,t){let n=e.defaults(t);return Object.assign((e,t)=>ji(n,e,t),{defaults:Mi.bind(null,n),endpoint:n.endpoint})}Mi(wi,{headers:{"user-agent":`octokit-graphql.js/${Ti} ${br()}`},method:`POST`,url:`/graphql`});function Ni(e){return Mi(e,{method:`POST`,url:`/graphql`})}var Pi=`(?:[a-zA-Z0-9_-]+)`,Fi=`\\.`,Ii=RegExp(`^${Pi}${Fi}${Pi}${Fi}${Pi}$`),Li=Ii.test.bind(Ii);async function Ri(e){let t=Li(e),n=e.startsWith(`v1.`)||e.startsWith(`ghs_`),r=e.startsWith(`ghu_`);return{type:`token`,token:e,tokenType:t?`app`:n?`installation`:r?`user-to-server`:`oauth`}}function zi(e){return e.split(/\./).length===3?`bearer ${e}`:`token ${e}`}async function Bi(e,t,n,r){let i=t.endpoint.merge(n,r);return i.headers.authorization=zi(e),t(i)}var Vi=function(e){if(!e)throw Error(`[@octokit/auth-token] No token passed to createTokenAuth`);if(typeof e!=`string`)throw Error(`[@octokit/auth-token] Token passed to createTokenAuth is not a string`);return e=e.replace(/^(token|bearer) +/i,``),Object.assign(Ri.bind(null,e),{hook:Bi.bind(null,e)})};const Hi=`7.0.6`,Ui=()=>{},Wi=console.warn.bind(console),Gi=console.error.bind(console);function Ki(e={}){return typeof e.debug!=`function`&&(e.debug=Ui),typeof e.info!=`function`&&(e.info=Ui),typeof e.warn!=`function`&&(e.warn=Wi),typeof e.error!=`function`&&(e.error=Gi),e}const qi=`octokit-core.js/${Hi} ${br()}`;var Ji=class{static VERSION=Hi;static defaults(e){return class extends this{constructor(...t){let n=t[0]||{};if(typeof e==`function`){super(e(n));return}super(Object.assign({},e,n,n.userAgent&&e.userAgent?{userAgent:`${n.userAgent} ${e.userAgent}`}:null))}}}static plugins=[];static plugin(...e){let t=this.plugins;return class extends this{static plugins=t.concat(e.filter(e=>!t.includes(e)))}}constructor(e={}){let t=new kr.Collection,n={baseUrl:wi.endpoint.DEFAULTS.baseUrl,headers:{},request:Object.assign({},e.request,{hook:t.bind(null,`request`)}),mediaType:{previews:[],format:``}};if(n.headers[`user-agent`]=e.userAgent?`${e.userAgent} ${qi}`:qi,e.baseUrl&&(n.baseUrl=e.baseUrl),e.previews&&(n.mediaType.previews=e.previews),e.timeZone&&(n.headers[`time-zone`]=e.timeZone),this.request=wi.defaults(n),this.graphql=Ni(this.request).defaults(n),this.log=Ki(e.log),this.hook=t,e.authStrategy){let{authStrategy:n,...r}=e,i=n(Object.assign({request:this.request,log:this.log,octokit:this,octokitOptions:r},e.auth));t.wrap(`request`,i.hook),this.auth=i}else if(!e.auth)this.auth=async()=>({type:`unauthenticated`});else{let n=Vi(e.auth);t.wrap(`request`,n.hook),this.auth=n}let r=this.constructor;for(let t=0;t({async next(){if(!s)return{done:!0};try{let e=ra(await i({method:a,url:s,headers:o}));if(s=((e.headers.link||``).match(/<([^<>]+)>;\s*rel="next"/)||[])[1],!s&&`total_commits`in e.data){let t=new URL(e.url),n=t.searchParams,r=parseInt(n.get(`page`)||`1`,10);r*parseInt(n.get(`per_page`)||`250`,10){if(i.done)return t;let a=!1;function o(){a=!0}return t=t.concat(r?r(i.value,o):i.value.data),a?t:oa(e,t,n,r)})}Object.assign(aa,{iterator:ia});function sa(e){return{paginate:Object.assign(aa.bind(null,e),{iterator:ia.bind(null,e)})}}sa.VERSION=na,new ur;const ca=yr(),la={baseUrl:ca,request:{agent:gr(ca),fetch:vr(ca)}},ua=Ji.plugin(ea,sa).defaults(la);function da(e,t){let n=Object.assign({},t||{}),r=hr(e,n);return r&&(n.auth=r),n}const fa=new ur;function pa(e,t,...n){return new(ua.plugin(...n))(da(e,t))}var K=C(ue(),1),ma=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},ha=class{constructor(e,t,n){if(e<1)throw Error(`max attempts should be greater than or equal to 1`);if(this.maxAttempts=e,this.minSeconds=Math.floor(t),this.maxSeconds=Math.floor(n),this.minSeconds>this.maxSeconds)throw Error(`min seconds should be less than or equal to max seconds`)}execute(e,t){return ma(this,void 0,void 0,function*(){let n=1;for(;nsetTimeout(t,e*1e3))})}},q=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},ga=class extends Error{constructor(e){super(`Unexpected HTTP response: ${e}`),this.httpStatusCode=e,Object.setPrototypeOf(this,new.target.prototype)}};const _a=process.platform===`win32`;process.platform;function va(e,t,n,r){return q(this,void 0,void 0,function*(){return t||=F.join(Na(),ye.randomUUID()),yield s(F.dirname(t)),j(`Downloading ${e}`),j(`Destination ${t}`),yield new ha(3,Pa(`TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS`,10),Pa(`TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS`,20)).execute(()=>q(this,void 0,void 0,function*(){return yield ya(e,t||``,n,r)}),e=>!(e instanceof ga&&e.httpStatusCode&&e.httpStatusCode<500&&e.httpStatusCode!==408&&e.httpStatusCode!==429))})}function ya(e,t,n,r){return q(this,void 0,void 0,function*(){if(P.existsSync(t))throw Error(`Destination file path ${t} already exists`);let i=new u(`actions/tool-cache`,[],{allowRetries:!1});n&&(j(`set auth`),r===void 0&&(r={}),r.authorization=n);let a=yield i.get(e,r);if(a.message.statusCode!==200){let t=new ga(a.message.statusCode);throw j(`Failed to download from "${e}". Code(${a.message.statusCode}) Message(${a.message.statusMessage})`),t}let o=Ce.promisify(Fe.pipeline),s=Pa(`TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY`,()=>a.message)(),c=!1;try{return yield o(s,P.createWriteStream(t)),j(`download complete`),c=!0,t}finally{if(!c){j(`download failed`);try{yield v(t)}catch(e){j(`Failed to delete '${t}'. ${e.message}`)}}}})}function ba(e,t){return q(this,arguments,void 0,function*(e,t,n=`xz`){if(!e)throw Error(`parameter 'file' is required`);t=yield Da(t),j(`Checking tar --version`);let r=``;yield M(`tar --version`,[],{ignoreReturnCode:!0,silent:!0,listeners:{stdout:e=>r+=e.toString(),stderr:e=>r+=e.toString()}}),j(r.trim());let i=r.toUpperCase().includes(`GNU TAR`),a;a=n instanceof Array?n:[n],m()&&!n.includes(`v`)&&a.push(`-v`);let o=t,s=e;return _a&&i&&(a.push(`--force-local`),o=t.replace(/\\/g,`/`),s=e.replace(/\\/g,`/`)),i&&(a.push(`--warning=no-unknown-keyword`),a.push(`--overwrite`)),a.push(`-C`,o,`-f`,s),yield M(`tar`,a),t})}function xa(e,t){return q(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'file' is required`);return t=yield Da(t),_a?yield Sa(e,t):yield Ca(e,t),t})}function Sa(e,t){return q(this,void 0,void 0,function*(){let n=e.replace(/'/g,`''`).replace(/"|\n|\r/g,``),r=t.replace(/'/g,`''`).replace(/"|\n|\r/g,``),i=yield b(`pwsh`,!1);if(i){let e=[`-NoLogo`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Unrestricted`,`-Command`,[`$ErrorActionPreference = 'Stop' ;`,`try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`,`try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${n}', '${r}', $true) }`,`catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${n}' -DestinationPath '${r}' -Force } else { throw $_ } } ;`].join(` `)];j(`Using pwsh at path: ${i}`),yield M(`"${i}"`,e)}else{let e=[`-NoLogo`,`-Sta`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Unrestricted`,`-Command`,[`$ErrorActionPreference = 'Stop' ;`,`try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`,`if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${n}' -DestinationPath '${r}' -Force }`,`else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${n}', '${r}', $true) }`].join(` `)],t=yield b(`powershell`,!0);j(`Using powershell at path: ${t}`),yield M(`"${t}"`,e)}})}function Ca(e,t){return q(this,void 0,void 0,function*(){let n=yield b(`unzip`,!0),r=[e];m()||r.unshift(`-q`),r.unshift(`-o`),yield M(`"${n}"`,r,{cwd:t})})}function wa(e,t,n,r){return q(this,void 0,void 0,function*(){if(n=K.clean(n)||n,r||=_e.arch(),j(`Caching tool ${t} ${n} ${r}`),j(`source dir: ${e}`),!P.statSync(e).isDirectory())throw Error(`sourceDir is not a directory`);let i=yield Oa(t,n,r);for(let t of P.readdirSync(e))yield y(F.join(e,t),i,{recursive:!0});return ka(t,n,r),i})}function Ta(e,t,n){if(!e)throw Error(`toolName parameter is required`);if(!t)throw Error(`versionSpec parameter is required`);n||=_e.arch(),Aa(t)||(t=ja(Ea(e,n),t));let r=``;if(t){t=K.clean(t)||``;let i=F.join(Ma(),e,t,n);j(`checking cache: ${i}`),P.existsSync(i)&&P.existsSync(`${i}.complete`)?(j(`Found tool in cache ${e} ${t} ${n}`),r=i):j(`not found`)}return r}function Ea(e,t){let n=[];t||=_e.arch();let r=F.join(Ma(),e);if(P.existsSync(r)){let e=P.readdirSync(r);for(let i of e)if(Aa(i)){let e=F.join(r,i,t||``);P.existsSync(e)&&P.existsSync(`${e}.complete`)&&n.push(i)}}return n}function Da(e){return q(this,void 0,void 0,function*(){return e||=F.join(Na(),ye.randomUUID()),yield s(e),e})}function Oa(e,t,n){return q(this,void 0,void 0,function*(){let r=F.join(Ma(),e,K.clean(t)||t,n||``);j(`destination ${r}`);let i=`${r}.complete`;return yield v(r),yield v(i),yield s(r),r})}function ka(e,t,n){let r=`${F.join(Ma(),e,K.clean(t)||t,n||``)}.complete`;P.writeFileSync(r,``),j(`finished caching tool`)}function Aa(e){let t=K.clean(e)||``;j(`isExplicit: ${t}`);let n=K.valid(t)!=null;return j(`explicit? ${n}`),n}function ja(e,t){let n=``;j(`evaluating ${e.length} versions`),e=e.sort((e,t)=>K.gt(e,t)?1:-1);for(let r=e.length-1;r>=0;r--){let i=e[r];if(K.satisfies(i,t)){n=i;break}}return j(n?`matched: ${n}`:`match not found`),n}function Ma(){let e=process.env.RUNNER_TOOL_CACHE||``;return Se(e,`Expected RUNNER_TOOL_CACHE to be defined`),e}function Na(){let e=process.env.RUNNER_TEMP||``;return Se(e,`Expected RUNNER_TEMP to be defined`),e}function Pa(e,t){let n=global[e];return n===void 0?t:n}function Fa(e){let t;try{t=JSON.parse(e)}catch(e){throw e instanceof SyntaxError?Error(`Invalid auth-json format: ${e.message}`):e}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`auth-json must be a JSON object`);return t}async function Ia(e,t,n){let r=L.join(t,`auth.json`);await I.mkdir(t,{recursive:!0});let i=JSON.stringify(e,null,2);return await I.writeFile(r,i,{mode:384}),n.info(`Populated auth.json`,{path:r,providers:Object.keys(e).length}),r}function La(){let e=N.platform,t=N.arch;return{os:{darwin:`darwin`,linux:`linux`,win32:`windows`}[e]??`linux`,arch:{arm64:`aarch64`,x64:`x64`}[t]??`x64`,ext:`.zip`}}function Ra(e,t){return`https://github.com/oven-sh/bun/releases/download/bun-${e.startsWith(`v`)?e:`v${e}`}/${`bun-${t.os}-${t.arch}${t.ext}`}`}async function za(e,t,n,i,a=pe){let o=La(),s=t.find(`bun`,a,o.arch);if(s.length>0)return e.info(`Bun found in cache`,{version:a,path:s}),i(s),await Va(s),{path:s,version:a,cached:!0};e.info(`Downloading Bun`,{version:a});let c=Ra(a,o);try{let r=await t.downloadTool(c);if(N.platform!==`win32`&&!await Ha(r,e,n))throw Error(`Downloaded Bun archive appears corrupted`);e.info(`Extracting Bun`);let s=await Ba(await t.extractZip(r),t),l=ke.dirname(s);e.info(`Caching Bun`);let u=await t.cacheDir(l,`bun`,a,o.arch);return i(u),await Va(u),e.info(`Bun installed`,{version:a,path:u}),{path:u,version:a,cached:!1}}catch(e){let t=r(e);throw Error(`Failed to install Bun ${a}: ${t}`)}}async function Ba(e,t){for(let n of await Oe.readdir(e,{withFileTypes:!0})){let{name:r}=n,i=ke.join(e,r);if(n.isFile()){if(r===`bun`||r===`bun.exe`)return i;if(/^bun.*\.zip/.test(r))return Ba(await t.extractZip(i),t)}if(r.startsWith(`bun`)&&n.isDirectory())return Ba(i,t)}throw Error(`Could not find executable: bun`)}async function Va(e){let t=e=>N.platform===`win32`?`${e}.exe`:e,n=ke.join(e,t(`bun`));try{await Oe.symlink(n,ke.join(e,t(`bunx`)))}catch(e){let t=typeof e==`object`?e.code:void 0;if(t!==`EEXIST`&&t!==`EPERM`&&t!==`EACCES`)throw e}}async function Ha(e,t,n){try{let{stdout:r}=await n.getExecOutput(`file`,[e],{silent:!0}),i=r.includes(`Zip archive`)||r.includes(`ZIP`);return i||t.warning(`Bun download validation failed`,{output:r.trim()}),i}catch{return t.debug(`Could not validate Bun download (file command unavailable)`),!0}}function Ua(e){return{debug:t=>e.debug(t),info:t=>e.info(t),warn:t=>e.warning(t),error:t=>e.error(t)}}function Wa(e){let{token:t,logger:n}=e;return n.debug(`Creating GitHub client with token`),pa(t,{log:Ua(n)})}async function Ga(e,t){try{let{data:n}=await e.rest.users.getAuthenticated();return t.debug(`Authenticated as`,{login:n.login,type:n.type}),n.login}catch{return t.debug(`Failed to get authenticated user, may be app token`),`fro-bot[bot]`}}async function Ka(e,t,n,r){let i=t??n,a=t==null?n.length>0?`github-token`:`none`:`app-token`;if(i.length===0)return r.warning(`No GitHub token available`),{authenticated:!1,method:`none`,botLogin:null};N.env.GH_TOKEN=i,r.info(`Configured authentication`,{method:a});let o=null;return e!=null&&(o=await Ga(e,r)),{authenticated:!0,method:a,botLogin:o}}async function qa(e,t){let n=await t.getExecOutput(`git`,[`config`,e],{ignoreReturnCode:!0,silent:!0});return n.exitCode===0&&n.stdout.trim().length>0?n.stdout.trim():null}async function Ja(e,t,n,r){let i=await qa(`user.name`,r),a=await qa(`user.email`,r);if(i!=null&&a!=null){n.info(`Git identity already configured`,{name:i,email:a});return}if(t==null)throw Error(`Cannot configure Git identity: no authenticated GitHub user`);let o=null;if(a==null){let r=await Xe(e,t,n);if(r==null)throw Error(`Cannot configure Git identity: failed to look up user ID for '${t}'`);o=String(r.id)}i??await r.exec(`git`,[`config`,`--global`,`user.name`,t],void 0);let s=`${o}+${t}@users.noreply.github.com`;a??await r.exec(`git`,[`config`,`--global`,`user.email`,s],void 0),n.info(`Configured git identity`,{name:i??t,email:a??s})}const Ya=new Set([`__proto__`,`prototype`,`constructor`]);function Xa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Za(e,t){let n=Object.create(null);for(let[t,r]of Object.entries(e))Ya.has(t)||(n[t]=r);for(let[e,r]of Object.entries(t)){if(Ya.has(e))continue;let t=n[e];Xa(r)&&Xa(t)?n[e]=Za(t,r):n[e]=r}return n}async function Qa(e,t,n){let r=JSON.parse(e);if(!Xa(r))throw Error(`omo-config must be a JSON object (non-null, non-array)`);let i=r;await I.mkdir(t,{recursive:!0});let a=L.join(t,`oh-my-opencode.json`),o={};try{let e=await I.readFile(a,`utf8`),t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(o=t)}catch(e){n.debug(`Using empty base oMo config`,{path:a,error:String(e)})}let s=Za(o,i);await I.writeFile(a,JSON.stringify(s,null,2)),n.info(`Wrote oMo config`,{path:a,keyCount:Object.keys(i).length})}async function $a(e,t,n={}){let{logger:i,execAdapter:a}=t,{claude:o=`no`,copilot:s=`no`,gemini:c=`no`,openai:l=`no`,opencodeZen:u=`no`,zaiCodingPlan:d=`no`,kimiForCoding:f=`no`}=n;i.info(`Installing Oh My OpenAgent plugin`,{version:e,claude:o,copilot:s,gemini:c,openai:l,opencodeZen:u,zaiCodingPlan:d,kimiForCoding:f});let p=``,m=[`oh-my-openagent@${e}`,`install`,`--no-tui`,`--skip-auth`,`--claude=${o}`,`--copilot=${s}`,`--gemini=${c}`,`--openai=${l}`,`--opencode-zen=${u}`,`--zai-coding-plan=${d}`,`--kimi-for-coding=${f}`];try{let t=await a.exec(`bunx`,m,{listeners:{stdout:e=>{p+=e.toString()},stderr:e=>{p+=e.toString()}},ignoreReturnCode:!0});if(t!==0){let e=`bunx oh-my-openagent install returned exit code ${t}`;return i.error(e,{output:p.slice(0,1e3)}),{installed:!1,version:null,error:`${e}\n${p.slice(0,500)}`}}let n=/oh-my-opencode@(\d+\.\d+\.\d+)/i.exec(p),r=n!=null&&n[1]!=null?n[1]:e;return i.info(`oMo plugin installed`,{version:r}),{installed:!0,version:r,error:null}}catch(e){let t=r(e),n=p.length>0?`${t}\nOutput: ${p.slice(0,500)}`:t;return i.error(`Failed to run oMo installer`,{error:t,output:p.slice(0,500)}),{installed:!1,version:null,error:`bunx oh-my-openagent install failed: ${n}`}}}const eo=`opencode`,to=g;function no(){let e=Ne.platform(),t=Ne.arch(),n={darwin:`darwin`,linux:`linux`,win32:`windows`},r={x64:`x64`,arm64:`arm64`},i=e===`win32`||e===`darwin`?`.zip`:`.tar.gz`;return{os:n[e]??`linux`,arch:r[t]??`x64`,ext:i}}function ro(e,t){return`https://github.com/anomalyco/opencode/releases/download/${e.startsWith(`v`)?e:`v${e}`}/${`opencode-${t.os}-${t.arch}${t.ext}`}`}async function io(e,t,n,r){if(N.platform===`win32`)return!0;try{let{stdout:i}=await r.getExecOutput(`file`,[e],{silent:!0}),a=(t===`.zip`?[`Zip archive`,`ZIP`]:[`gzip`,`tar`,`compressed`]).some(e=>i.includes(e));return a||n.warning(`Download validation failed`,{output:i.trim()}),a}catch{return n.debug(`Could not validate download (file command unavailable)`),!0}}async function ao(e,t,n,i,a=to){let o=no(),s=n.find(eo,e,o.arch);if(s.length>0)return t.info(`OpenCode found in cache`,{version:e,path:s}),{path:s,version:e,cached:!0};try{return await oo(e,o,t,n,i)}catch(n){t.warning(`Primary version install failed, trying fallback`,{requestedVersion:e,fallbackVersion:a,error:r(n)})}if(e!==a)try{let e=await oo(a,o,t,n,i);return t.info(`Installed fallback version`,{version:a}),e}catch(t){throw Error(`Failed to install OpenCode (tried ${e} and ${a}): ${r(t)}`)}throw Error(`Failed to install OpenCode version ${e}`)}async function oo(e,t,n,r,i){n.info(`Downloading OpenCode`,{version:e});let a=ro(e,t),o=await r.downloadTool(a);if(!await io(o,t.ext,n,i))throw Error(`Downloaded archive appears corrupted`);n.info(`Extracting OpenCode`);let s=t.ext===`.zip`?await r.extractZip(o):await r.extractTar(o);n.info(`Caching OpenCode`);let c=await r.cacheDir(s,eo,e,t.arch);return n.info(`OpenCode installed`,{version:e,path:c}),{path:c,version:e,cached:!1}}async function so(e){let t=await fetch(`https://api.github.com/repos/anomalyco/opencode/releases/latest`);if(!t.ok)throw Error(`Failed to fetch latest OpenCode version: ${t.statusText}`);let n=(await t.json()).tag_name.replace(/^v/,``);return e.info(`Latest OpenCode version`,{version:n}),n}const co={restoreCache:async(e,t,n)=>T(e,t,n),saveCache:async(e,t)=>oe(e,t)};function lo(e){let{os:t,opencodeVersion:n,omoVersion:r}=e;return`${me}-${t}-oc-${n}-omo-${r}`}function uo(e){let{os:t,opencodeVersion:n,omoVersion:r}=e;return[`${me}-${t}-oc-${n}-omo-${r}-`]}async function fo(e){let{logger:t,os:n,opencodeVersion:i,omoVersion:a,toolCachePath:o,bunCachePath:s,omoConfigPath:c,cacheAdapter:l=co}=e,u=lo({os:n,opencodeVersion:i,omoVersion:a}),d=uo({os:n,opencodeVersion:i,omoVersion:a}),f=[o,s,c];t.info(`Restoring tools cache`,{primaryKey:u,restoreKeys:[...d],paths:f});try{let e=await l.restoreCache(f,u,[...d]);return e==null?(t.info(`Tools cache miss - will install tools`),{hit:!1,restoredKey:null}):(t.info(`Tools cache restored`,{restoredKey:e}),{hit:!0,restoredKey:e})}catch(e){return t.warning(`Tools cache restore failed`,{error:r(e)}),{hit:!1,restoredKey:null}}}async function po(e){let{logger:t,os:n,opencodeVersion:i,omoVersion:a,toolCachePath:o,bunCachePath:s,omoConfigPath:c,cacheAdapter:l=co}=e,u=lo({os:n,opencodeVersion:i,omoVersion:a}),d=[o,s,c];t.info(`Saving tools cache`,{saveKey:u,paths:d});try{return await l.saveCache(d,u),t.info(`Tools cache saved`,{saveKey:u}),!0}catch(e){return e instanceof Error&&e.message.includes(`already exists`)?(t.info(`Tools cache key already exists, skipping save`),!0):(t.warning(`Tools cache save failed`,{error:r(e)}),!1)}}function mo(){return{find:Ta,downloadTool:va,extractTar:ba,extractZip:xa,cacheDir:wa}}function ho(){return{exec:M,getExecOutput:t}}async function go(t,n){let a=Date.now(),o=i({component:`setup`}),s=mo(),l=ho();try{o.info(`Starting setup`,{version:t.opencodeVersion});let i;try{i=Fa(t.authJson)}catch(e){return c(`Invalid auth-json: ${r(e)}`),null}let u=t.opencodeVersion;if(u===`latest`)try{u=await so(o)}catch(e){o.warning(`Failed to get latest version, using fallback`,{error:r(e)}),u=to}let f=t.omoVersion,m=N.env.RUNNER_TOOL_CACHE??`/opt/hostedtoolcache`,h=Ae(m,`opencode`),g=Ae(m,`bun`),_=Ae(Pe(),`.config`,`opencode`),v=se(),y=await fo({logger:o,os:v,opencodeVersion:u,omoVersion:f,toolCachePath:h,bunCachePath:g,omoConfigPath:_}),b=y.hit?`hit`:`miss`,x,S=!1,C=null;if(y.hit){let e=s.find(`opencode`,u);e.length>0?(x={path:e,version:u,cached:!0},o.info(`Tools cache hit, using cached OpenCode CLI`,{version:u,omoVersion:f})):o.warning(`Tools cache hit but binary not found in tool-cache, falling through to install`,{requestedVersion:u,restoredKey:y.restoredKey})}if(x==null)try{x=await ao(u,o,s,l)}catch(e){return c(`Failed to install OpenCode: ${r(e)}`),null}let w=!1;try{await za(o,s,l,p,pe),w=!0}catch(e){o.warning(`Bun installation failed, oMo will be unavailable`,{error:r(e)})}if(w){if(t.omoConfig!=null)try{await Qa(t.omoConfig,_,o)}catch(e){o.warning(`Failed to write omo-config, continuing without custom config`,{error:r(e)})}let e=await $a(f,{logger:o,execAdapter:l},t.omoProviders);e.installed?(o.info(`oMo installed`,{version:e.version}),S=!0):o.warning(`oMo installation failed, continuing without oMo`,{error:e.error??`unknown error`}),C=e.error}let T={autoupdate:!1};if(t.opencodeConfig!=null){let e;try{e=JSON.parse(t.opencodeConfig)}catch{return c(`opencode-config must be valid JSON`),null}if(typeof e!=`object`||!e||Array.isArray(e))return c(`opencode-config must be a JSON object`),null;Object.assign(T,e)}e(`OPENCODE_CONFIG_CONTENT`,JSON.stringify(T)),y.hit||await po({logger:o,os:v,opencodeVersion:u,omoVersion:f,toolCachePath:h,bunCachePath:g,omoConfigPath:_}),p(x.path),d(`opencode-path`,x.path),d(`opencode-version`,x.version),o.info(`OpenCode ready`,{version:x.version,cached:x.cached});let E=pa(n),D=await Ka(E,null,n,o);e(`GH_TOKEN`,n),o.info(`GitHub CLI configured`),await Ja(E,D.botLogin,o,l);let O=Ae(ie(),`opencode`),k=await Ia(i,O,o);d(`auth-json-path`,k),o.info(`auth.json populated`,{path:k});let ee=Date.now()-a,te={opencodePath:x.path,opencodeVersion:x.version,ghAuthenticated:D.authenticated,omoInstalled:S,omoError:C,toolsCacheStatus:b,duration:ee};return o.info(`Setup complete`,{duration:ee}),te}catch(e){let t=r(e);return o.error(`Setup failed`,{error:t}),c(t),null}}function _o(e){return{success:!0,data:e}}function vo(e){return{success:!1,error:e}}const yo=[`OWNER`,`MEMBER`,`COLLABORATOR`];async function bo(e,t){try{let{client:n,server:r}=await fn({signal:e});return t.debug(`OpenCode server bootstrapped`,{url:r.url}),_o({client:n,server:r,shutdown:()=>{r.close()}})}catch(e){let n=e instanceof Error?e.message:String(e);return t.warning(`Failed to bootstrap OpenCode server`,{error:n}),vo(Error(`Server bootstrap failed: ${n}`))}}async function xo(e,t){let n=e??`opencode`;try{let e=``;await M(n,[`--version`],{listeners:{stdout:t=>{e+=t.toString()}},silent:!0});let r=/(\d+\.\d+\.\d+)/.exec(e)?.[1]??null;return t.debug(`OpenCode version verified`,{version:r}),{available:!0,version:r}}catch{return t.debug(`OpenCode not available, will attempt auto-setup`),{available:!1,version:null}}}async function So(e){let{logger:t,opencodeVersion:n}=e,r=N.env.OPENCODE_PATH??null,i=await xo(r,t);if(i.available&&i.version!=null)return t.info(`OpenCode already available`,{version:i.version}),{path:r??`opencode`,version:i.version,didSetup:!1};t.info(`OpenCode not found, running auto-setup`,{requestedVersion:n});let a=await go({opencodeVersion:n,authJson:e.authJson,appId:null,privateKey:null,opencodeConfig:e.opencodeConfig,omoConfig:null,omoVersion:e.omoVersion,omoProviders:e.omoProviders},e.githubToken);if(a==null)throw Error(`Auto-setup failed: runSetup returned null`);return p(a.opencodePath),N.env.OPENCODE_PATH=a.opencodePath,t.info(`Auto-setup completed`,{version:a.opencodeVersion,path:a.opencodePath}),{path:a.opencodePath,version:a.opencodeVersion,didSetup:!0}}async function Co(e,t){let n={repo:e.agentContext.repo,commentId:e.agentContext.commentId,issueNumber:e.agentContext.issueNumber,issueType:e.agentContext.issueType,botLogin:e.botLogin},r=i({phase:`acknowledgment`});return await rr(e.githubClient,n,r),t.debug(`Acknowledgment phase completed`),n}function wo(e,t){try{JSON.parse(e)}catch{throw Error(`${t} must be valid JSON`)}}function To(e,t){let n=e.trim();if(!/^\d+$/.test(n))throw Error(`${t} must be a positive integer, received: ${e}`);let r=Number.parseInt(n,10);if(r===0)throw Error(`${t} must be a positive integer, received: ${e}`);return r}function Eo(e){let t=e.trim(),n=t.indexOf(`/`);if(n===-1)throw Error(`Invalid model format: "${e}". Expected "provider/model" (e.g., "anthropic/claude-sonnet-4-20250514")`);let r=t.slice(0,n).trim(),i=t.slice(n+1).trim();if(r.length===0)throw Error(`Invalid model format: "${e}". Provider cannot be empty.`);if(i.length===0)throw Error(`Invalid model format: "${e}". Model ID cannot be empty.`);return{providerID:r,modelID:i}}function Do(e,t=`timeout`){let n=e.trim();if(!/^\d+$/.test(n))throw Error(`${t} must be a non-negative integer, received: ${e}`);let r=Number.parseInt(n,10);if(Number.isNaN(r)||r<0)throw Error(`${t} must be a non-negative integer, received: ${e}`);return r}const Oo=[`claude`,`claude-max20`,`copilot`,`gemini`,`openai`,`opencode-zen`,`zai-coding-plan`,`kimi-for-coding`];function ko(e){let t=e.split(`,`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0),n=`no`,r=`no`,i=`no`,a=`no`,o=`no`,s=`no`,c=`no`;for(let e of t){if(!Oo.includes(e))throw Error(`Invalid omo-providers value: "${e}". Valid values: ${Oo.join(`, `)}`);switch(e){case`claude`:n=`yes`;break;case`claude-max20`:n=`max20`;break;case`copilot`:r=`yes`;break;case`gemini`:i=`yes`;break;case`openai`:a=`yes`;break;case`opencode-zen`:o=`yes`;break;case`zai-coding-plan`:s=`yes`;break;case`kimi-for-coding`:c=`yes`;break}}return{claude:n,copilot:r,gemini:i,openai:a,opencodeZen:o,zaiCodingPlan:s,kimiForCoding:c}}function Ao(){try{let e=A(`github-token`,{required:!0}).trim();if(e.length===0)return vo(Error(`github-token is required but was not provided`));let t=A(`auth-json`,{required:!0}).trim();if(t.length===0)return vo(Error(`auth-json is required but was not provided`));wo(t,`auth-json`);let r=A(`prompt`).trim(),i=r.length>0?r:null,a=A(`session-retention`).trim(),o=a.length>0?To(a,`session-retention`):50,s=A(`s3-backup`).trim().toLowerCase()===`true`,c=A(`s3-bucket`).trim(),l=c.length>0?c:null,u=A(`aws-region`).trim(),d=u.length>0?u:null,f=A(`agent`).trim(),p=f.length>0?f:w,m=A(`model`).trim(),h=m.length>0?Eo(m):null,_=A(`timeout`).trim(),v=_.length>0?Do(_):n,y=A(`opencode-version`).trim(),b=y.length>0?y:g,x=A(`skip-cache`).trim().toLowerCase()===`true`,S=A(`omo-version`).trim(),C=S.length>0?S:he,T=A(`omo-providers`).trim(),E=ko(T.length>0?T:``),D=A(`opencode-config`).trim(),O=D.length>0?D:null,k=A(`dedup-window`).trim(),ee=k.length>0?Do(k,`dedup-window`):ge;if(O!=null){wo(O,`opencode-config`);let e=JSON.parse(O);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Input 'opencode-config' must be a JSON object`)}return _o({githubToken:e,authJson:t,prompt:i,sessionRetention:o,s3Backup:s,s3Bucket:l,awsRegion:d,agent:p,model:h,timeoutMs:v,opencodeVersion:b,skipCache:x,omoVersion:C,omoProviders:E,opencodeConfig:O,dedupWindow:ee})}catch(e){return vo(e instanceof Error?e:Error(String(e)))}}async function jo(e){let t=Ao();if(!t.success)return c(`Invalid inputs: ${t.error.message}`),null;let n=t.data,r=i({phase:`main`});r.info(`Action inputs parsed`,{sessionRetention:n.sessionRetention,s3Backup:n.s3Backup,hasGithubToken:n.githubToken.length>0,hasPrompt:n.prompt!=null,agent:n.agent,hasModelOverride:n.model!=null,timeoutMs:n.timeoutMs});let o=await So({logger:r,opencodeVersion:n.opencodeVersion,githubToken:n.githubToken,authJson:n.authJson,omoVersion:n.omoVersion,omoProviders:n.omoProviders,opencodeConfig:n.opencodeConfig});return o.didSetup?r.info(`OpenCode auto-setup completed`,{version:o.version}):r.info(`OpenCode already available`,{version:o.version}),a(_.OPENCODE_VERSION,o.version),e.debug(`Bootstrap phase completed`,{opencodeVersion:o.version}),{inputs:n,logger:r,opencodeResult:o}}const Mo=/^[0-9a-f]{40}$/i;function No(){return{exec:M,getExecOutput:t}}async function Po(e){let{workspacePath:t,logger:n,execAdapter:i=No()}=e,a=L.join(t,`.git`),o=L.join(a,`opencode`);try{let e=(await I.readFile(o,`utf8`)).trim();if(e.length>0){if(Mo.test(e))return n.debug(`Project ID loaded from cache`,{projectId:e}),{projectId:e,source:`cached`};n.warning(`Invalid cached project ID format, regenerating`,{cachedId:e})}}catch(e){n.debug(`No cached project ID found`,{error:r(e)})}try{let e=await I.readFile(a,`utf8`),n=/^gitdir: (.+)$/m.exec(e);if(n==null)return{projectId:null,source:`error`,error:`Invalid .git file format`};a=L.resolve(t,n[1]),o=L.join(a,`opencode`)}catch(e){if((typeof e==`object`?e.code:void 0)!==`EISDIR`)return{projectId:null,source:`error`,error:`Not a git repository`}}try{let{stdout:e,exitCode:a}=await i.getExecOutput(`git`,[`rev-list`,`--max-parents=0`,`--all`],{cwd:t,silent:!0});if(a!==0||e.trim().length===0)return{projectId:null,source:`error`,error:`No commits found in repository`};let s=e.trim().split(` -`).map(e=>e.trim()).filter(e=>e.length>0).sort();if(s.length===0)return{projectId:null,source:`error`,error:`No root commits found`};let c=s[0];try{await I.writeFile(o,c,{encoding:`utf8`,flag:`wx`}),n.info(`Project ID generated and cached`,{projectId:c,source:`generated`})}catch(e){(typeof e==`object`?e.code:void 0)===`EEXIST`?n.debug(`Project ID file already written by concurrent process, skipping`,{projectId:c}):n.warning(`Failed to cache project ID (continuing)`,{error:r(e)})}return{projectId:c,source:`generated`}}catch(e){return{projectId:null,source:`error`,error:r(e)}}}async function Fo(e){let t=ne(),n=i({phase:`cache`}),r=re(),a=L.join(r,`.git`,`opencode`),o=await ae({components:t,logger:n,storagePath:k(),authPath:fe(),projectIdPath:a,opencodeVersion:e.opencodeResult.version}),s=o.corrupted?`corrupted`:o.hit?`hit`:`miss`;e.logger.info(`Cache restore completed`,{cacheStatus:s,key:o.key});let l=await Po({workspacePath:r,logger:n});l.source===`error`?n.warning(`Failed to generate project ID (continuing)`,{error:l.error}):n.debug(`Project ID ready`,{projectId:l.projectId,source:l.source});let u=i({phase:`server-bootstrap`}),d=await bo(new AbortController().signal,u);if(!d.success)return c(`OpenCode server bootstrap failed: ${d.error.message}`),null;let f=d.data;return u.info(`SDK server bootstrapped successfully`),{cacheResult:o,cacheStatus:s,serverHandle:f}}const Io={markdownImage:/!\[([^\]]*)\]\((https:\/\/github\.com\/user-attachments\/assets\/[^)]+)\)/gi,markdownLink:/\[([^\]]+)\]\((https:\/\/github\.com\/user-attachments\/files\/[^)]+)\)/gi,htmlImage:/]*src=["'](https:\/\/github\.com\/user-attachments\/assets\/[^"']+)["'][^>]*>/gi};function Lo(e,t,n){e.lastIndex=0;let r=e.exec(t);for(;r!=null;)n(r),r=e.exec(t);e.lastIndex=0}function Ro(e){let t=[],n=new Set;return Lo(Io.markdownImage,e,e=>{let r=e[2],i=e[1],a=e[0];r!=null&&i!=null&&!n.has(r)&&Tn(r)&&(n.add(r),t.push({url:r,originalMarkdown:a,altText:i,type:`image`}))}),Lo(Io.markdownLink,e,e=>{let r=e[2],i=e[1],a=e[0];r!=null&&i!=null&&!n.has(r)&&Tn(r)&&(n.add(r),t.push({url:r,originalMarkdown:a,altText:i,type:`file`}))}),Lo(Io.htmlImage,e,e=>{let r=e[1],i=e[0];if(r!=null&&!n.has(r)&&Tn(r)){n.add(r);let e=/alt=["']([^"']*)["']/i.exec(i);t.push({url:r,originalMarkdown:i,altText:e?.[1]??``,type:`image`})}}),Io.htmlImage.lastIndex=0,t}function zo(e,t,n){try{let r=new URL(e).pathname.split(`/`).at(-1);if(r!=null&&/\.[a-z0-9]+$/i.test(r))return r;if(t.trim().length>0){let e=t.replaceAll(/[^\w.-]/g,`_`).slice(0,50);return e.trim().length>0?e:`attachment_${n+1}`}return`attachment_${n+1}`}catch{return`attachment_${n+1}`}}const Bo={maxFiles:5,maxFileSizeBytes:5*1024*1024,maxTotalSizeBytes:15*1024*1024,allowedMimeTypes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`text/plain`,`text/markdown`,`text/csv`,`application/json`,`application/pdf`]},Vo=[`github.com`,`githubusercontent.com`];async function Ho(e,t,n,i,a){a.debug(`Downloading attachment`,{url:e.url});try{let r=await fetch(e.url,{headers:{Authorization:`Bearer ${n}`,Accept:`*/*`,"User-Agent":`fro-bot-agent`},redirect:`manual`}),o=r;if(r.status>=300&&r.status<400){let t=r.headers.get(`location`);if(t==null)return a.warning(`Redirect without location`,{url:e.url}),null;let n=new URL(t);if(!Vo.some(e=>n.hostname===e||n.hostname.endsWith(`.${e}`)))return a.warning(`Redirect to non-GitHub host blocked`,{url:e.url,redirectTo:n.hostname}),null;o=await fetch(t,{headers:{Accept:`*/*`,"User-Agent":`fro-bot-agent`},redirect:`follow`})}if(!o.ok)return a.warning(`Attachment download failed`,{url:e.url,status:o.status}),null;let s=o.headers.get(`content-length`);if(s!=null){let t=Number.parseInt(s,10);if(t>i.maxFileSizeBytes)return a.warning(`Attachment exceeds size limit (Content-Length)`,{url:e.url,size:t,limit:i.maxFileSizeBytes}),null}let c=we.from(await o.arrayBuffer());if(c.length>i.maxFileSizeBytes)return a.warning(`Attachment exceeds size limit`,{url:e.url,size:c.length,limit:i.maxFileSizeBytes}),null;let l=o.headers.get(`content-type`)??`application/octet-stream`,u=zo(e.url,e.altText,t),d=l.split(`;`)[0],f=d==null?`application/octet-stream`:d.trim(),p=await I.mkdtemp(L.join(Me.tmpdir(),`fro-bot-attachments-`)),m=u.trim().length>0?u:`attachment_${t+1}`,h=L.join(p,m);return await I.writeFile(h,c),a.debug(`Attachment downloaded`,{filename:u,mime:f,sizeBytes:c.length,tempPath:h}),{url:e.url,filename:u,mime:f,sizeBytes:c.length,tempPath:h}}catch(t){return a.warning(`Attachment download error`,{url:e.url,error:r(t)}),null}}async function Uo(e,t,n=Bo,r){return Promise.all(e.map(async(e,i)=>Ho(e,i,t,n,r)))}async function Wo(e,t){for(let n of e)try{await I.unlink(n);let e=L.dirname(n);await I.rmdir(e).catch(()=>{})}catch(e){t.debug(`Failed to cleanup temp file`,{path:n,error:r(e)})}}function Go(e){return e.map(e=>({type:`file`,mime:e.mime,url:De(e.tempPath).toString(),filename:e.filename}))}function Ko(e,t,n){let r=e,i=new Set(n.map(e=>e.filename));for(let e of t){let t=n.find(e=>i.has(e.filename));t!=null&&(r=r.replace(e.originalMarkdown,`@${t.filename}`))}return r}function qo(e,t,n,r){return{processed:n,skipped:r,modifiedBody:Ko(e,t,n),fileParts:Go(n),tempFiles:n.map(e=>e.tempPath)}}function Jo(e){if(e<0||!Number.isFinite(e))throw Error(`Invalid bytes value: ${e}`);return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Yo(e,t=Bo,n){let r=[],i=[],a=0;for(let o of e)if(o!=null){if(r.length>=t.maxFiles){i.push({url:o.url,reason:`Exceeds max file count (${t.maxFiles})`}),n.debug(`Attachment skipped: max count`,{url:o.url});continue}if(o.sizeBytes>t.maxFileSizeBytes){i.push({url:o.url,reason:`File too large (${Jo(o.sizeBytes)} > ${Jo(t.maxFileSizeBytes)})`}),n.debug(`Attachment skipped: too large`,{url:o.url,size:o.sizeBytes});continue}if(a+o.sizeBytes>t.maxTotalSizeBytes){i.push({url:o.url,reason:`Would exceed total size limit (${Jo(t.maxTotalSizeBytes)})`}),n.debug(`Attachment skipped: total size exceeded`,{url:o.url});continue}if(!Xo(o.mime,t.allowedMimeTypes)){i.push({url:o.url,reason:`MIME type not allowed: ${o.mime}`}),n.debug(`Attachment skipped: MIME type`,{url:o.url,mime:o.mime});continue}a+=o.sizeBytes,r.push({filename:o.filename,mime:o.mime,sizeBytes:o.sizeBytes,tempPath:o.tempPath}),n.info(`Attachment validated`,{filename:o.filename,mime:o.mime,sizeBytes:o.sizeBytes})}return{validated:r,skipped:i}}function Xo(e,t){let[n]=e.split(`/`);for(let r of t)if(r===e||r.endsWith(`/*`)&&n!=null&&n===r.slice(0,-2))return!0;return!1}function J(e){let t=L.resolve(e);return t.endsWith(L.sep)&&t.length>1?t.slice(0,-1):t}const Zo=e=>typeof e==`object`&&!!e,Y=e=>typeof e==`string`?e:null,Qo=e=>typeof e==`number`?e:null;function $o(e){if(Array.isArray(e))return e.filter(Zo).map(e=>({file:Y(e.file)??``,additions:Qo(e.additions)??0,deletions:Qo(e.deletions)??0}))}function es(e){return{id:e.id,version:e.version,projectID:e.projectID,directory:e.directory,parentID:e.parentID,title:e.title,time:{created:e.time.created,updated:e.time.updated,compacting:e.time.compacting,archived:e.time.archived},summary:e.summary==null?void 0:{additions:e.summary.additions,deletions:e.summary.deletions,files:e.summary.files,diffs:$o(e.summary.diffs)},share:e.share?.url==null?void 0:{url:e.share.url},permission:e.permission==null?void 0:{rules:e.permission.rules},revert:e.revert==null?void 0:{messageID:e.revert.messageID,partID:e.revert.partID,snapshot:e.revert.snapshot,diff:e.revert.diff}}}async function ts(e,t){let n=await e.project.list();if(n.error!=null||n.data==null)return t.warning(`SDK project list failed`,{error:String(n.error)}),[];if(!Array.isArray(n.data))return[];let r=[];for(let e of n.data){if(!Zo(e))continue;let t=Y(e.id),n=Y(e.worktree),i=Y(e.path);t==null||n==null||i==null||r.push({id:t,worktree:n,path:i,vcs:`git`,time:{created:0,updated:0}})}return r}async function ns(e,t,n){let r=J(t),i=await ts(e,n);for(let e of i){if(J(e.worktree)===r)return e;let t=Y(e.path);if(t!=null&&J(t)===r)return e}return null}function rs(e){return e.status===`running`?{status:`running`,input:e.input,time:{start:e.time.start}}:e.status===`error`?{status:`error`,input:e.input,error:e.error,time:{start:e.time.start,end:e.time.end}}:e.status===`pending`?{status:`pending`}:{status:`completed`,input:e.input,output:e.output,title:e.title,metadata:e.metadata,time:{start:e.time.start,end:e.time.end,compacted:e.time.compacted},attachments:void 0}}function is(e){let t={id:e.id,sessionID:e.sessionID,messageID:e.messageID};if(e.type===`text`)return{...t,type:`text`,text:e.text,synthetic:e.synthetic,ignored:e.ignored,time:e.time,metadata:e.metadata};if(e.type===`reasoning`)return{...t,type:`reasoning`,reasoning:e.reasoning??e.text,time:e.time};if(e.type===`tool`)return{...t,type:`tool`,callID:e.callID,tool:e.tool,state:rs(e.state),metadata:e.metadata};if(e.type!==`step-finish`)return{...t,type:`text`,text:`text`in e?e.text:``};let n=e;return{...t,type:`step-finish`,reason:n.reason,snapshot:n.snapshot,cost:n.cost,tokens:{input:n.tokens.input,output:n.tokens.output,reasoning:n.tokens.reasoning,cache:{read:n.tokens.cache.read,write:n.tokens.cache.write}}}}function as(e){if(e.role===`user`){let t=e;return{id:t.id,sessionID:t.sessionID,role:`user`,time:{created:t.time.created},summary:t.summary==null?void 0:{title:t.summary.title,body:t.summary.body,diffs:$o(t.summary.diffs)??[]},agent:t.agent,model:{providerID:t.model.providerID,modelID:t.model.modelID},system:t.system,tools:t.tools,variant:t.variant}}let t=e;return{id:t.id,sessionID:t.sessionID,role:`assistant`,time:{created:t.time.created,completed:t.time.completed},parentID:t.parentID,modelID:t.modelID,providerID:t.providerID,mode:t.mode,agent:t.agent??``,path:{cwd:t.path.cwd,root:t.path.root},summary:t.summary,cost:t.cost,tokens:{input:t.tokens.input,output:t.tokens.output,reasoning:t.tokens.reasoning,cache:{read:t.tokens.cache.read,write:t.tokens.cache.write}},finish:t.finish,error:t.error?{name:t.error.name,message:Y(t.error.data.message)??``}:void 0}}function os(e){return[...e.map(e=>{let t=as(`info`in e?e.info:e),n=`parts`in e?e.parts.map(is):void 0;return n==null||n.length===0?t:{...t,parts:n}})].sort((e,t)=>e.time.created-t.time.created)}async function ss(e,t,n){let r=await e.session.list({query:{directory:t}});return r.error==null&&r.data!=null?Array.isArray(r.data)?r.data.map(es):[]:(n.warning(`SDK session list failed`,{error:String(r.error)}),[])}async function cs(e,t,n){let r=await e.session.messages({path:{id:t}});return r.error==null&&r.data!=null?os(r.data):(n.warning(`SDK session messages failed`,{error:String(r.error)}),[])}async function ls(e,t,n,r){let i=await e.session.list({query:{directory:t,start:n,roots:!0,limit:10}});if(i.error!=null||i.data==null)return r.warning(`SDK session list failed`,{error:String(i.error)}),null;if(!Array.isArray(i.data)||i.data.length===0)return null;let a=i.data.map(es);if(a.length===0)return null;let o=a.reduce((e,t)=>t.time.created>e.time.created?t:e);return{projectID:o.projectID,session:o}}async function us(e,t,n){let r=await e.session.delete({path:{id:t}});if(r.error!=null){n.warning(`SDK session delete failed`,{sessionID:t,error:String(r.error)});return}n.debug(`Deleted session via SDK`,{sessionID:t})}const ds={maxSessions:50,maxAgeDays:30};async function fs(e,t,n,i){let{maxSessions:a,maxAgeDays:o}=n;if(i.info(`Starting session pruning`,{workspacePath:t,maxSessions:a,maxAgeDays:o}),await ns(e,t,i)==null)return i.debug(`No project found for pruning`,{workspacePath:t}),{prunedCount:0,prunedSessionIds:[],remainingCount:0,freedBytes:0};let s=await ss(e,t,i),c=s.filter(e=>e.parentID==null);if(c.length===0)return{prunedCount:0,prunedSessionIds:[],remainingCount:0,freedBytes:0};let l=[...c].sort((e,t)=>t.time.updated-e.time.updated),u=new Date;u.setDate(u.getDate()-o);let d=u.getTime(),f=new Set;for(let e of l)e.time.updated>=d&&f.add(e.id);for(let e=0;e!f.has(e.id)),m=new Set;for(let e of p){m.add(e.id);for(let t of s)t.parentID===e.id&&m.add(t.id)}if(m.size===0)return i.info(`No sessions to prune`),{prunedCount:0,prunedSessionIds:[],remainingCount:c.length,freedBytes:0};let h=[];for(let t of m)try{await us(e,t,i),h.push(t),i.debug(`Pruned session`,{sessionId:t})}catch(e){i.warning(`Failed to prune session`,{sessionId:t,error:r(e)})}let g=c.length-p.length;return i.info(`Session pruning complete`,{prunedCount:h.length,remainingCount:g}),{prunedCount:h.length,prunedSessionIds:h,remainingCount:g,freedBytes:0}}async function ps(e,t,n,r){let{limit:i,fromDate:a,toDate:o}=n;r.debug(`Listing sessions`,{directory:t,limit:i});let s=[...(await ss(e,t,r)).filter(e=>!(e.parentID!=null||a!=null&&e.time.createdo.getTime()))].sort((e,t)=>t.time.updated-e.time.updated),c=[],l=i==null?s:s.slice(0,i);for(let t of l){let n=await cs(e,t.id,r),i=ms(n);c.push({id:t.id,projectID:t.projectID,directory:t.directory,title:t.title,createdAt:t.time.created,updatedAt:t.time.updated,messageCount:n.length,agents:i,isChild:!1})}return r.info(`Listed sessions`,{count:c.length,directory:t}),c}function ms(e){let t=new Set;for(let n of e)n.agent!=null&&t.add(n.agent);return[...t]}async function hs(e,t,n,r,i){let{limit:a=20,caseSensitive:o=!1,sessionId:s}=r;i.debug(`Searching sessions`,{query:e,directory:n,limit:a,caseSensitive:o});let c=o?e:e.toLowerCase(),l=[],u=0;if(s!=null){let e=await gs(t,s,c,o,i);return e.length>0&&l.push({sessionId:s,matches:e.slice(0,a)}),l}let d=await ps(t,n,{},i);for(let e of d){if(u>=a)break;let n=await gs(t,e.id,c,o,i);if(n.length>0){let t=a-u;l.push({sessionId:e.id,matches:n.slice(0,t)}),u+=Math.min(n.length,t)}}return i.info(`Session search complete`,{query:e,resultCount:l.length,totalMatches:u}),l}async function gs(e,t,n,r,i){let a=await cs(e,t,i),o=[];for(let e of a){let t=e.parts??[];for(let i of t){let t=_s(i);if(t==null)continue;let a=r?t:t.toLowerCase();if(a.includes(n)){let r=a.indexOf(n),s=Math.max(0,r-50),c=Math.min(t.length,r+n.length+50),l=t.slice(s,c);o.push({messageId:e.id,partId:i.id,excerpt:`...${l}...`,role:e.role,agent:e.agent})}}}return o}function _s(e){switch(e.type){case`text`:return e.text;case`reasoning`:return e.reasoning;case`tool`:return e.state.status===`completed`?`${e.tool}: ${e.state.output}`:null;case`step-finish`:return null}}function vs(e){let t=[`--- Fro Bot Run Summary ---`,`Event: ${e.eventType}`,`Repo: ${e.repo}`,`Ref: ${e.ref}`,`Run ID: ${e.runId}`,`Cache: ${e.cacheStatus}`,`Duration: ${e.duration}s`];return e.sessionIds.length>0&&t.push(`Sessions used: ${e.sessionIds.join(`, `)}`),e.logicalKey!=null&&t.push(`Logical Thread: ${e.logicalKey}`),e.createdPRs.length>0&&t.push(`PRs created: ${e.createdPRs.join(`, `)}`),e.createdCommits.length>0&&t.push(`Commits: ${e.createdCommits.join(`, `)}`),e.tokenUsage!=null&&t.push(`Tokens: ${e.tokenUsage.input} in / ${e.tokenUsage.output} out`),t.join(` -`)}async function ys(e,t,n,i){let a=vs(t);try{let t=await n.session.prompt({path:{id:e},body:{noReply:!0,parts:[{type:`text`,text:a}]}});if(t.error!=null){i.warning(`SDK prompt writeback failed`,{sessionId:e,error:String(t.error)});return}i.info(`Session summary written via SDK`,{sessionId:e})}catch(t){i.warning(`SDK prompt writeback failed`,{sessionId:e,error:r(t)})}}async function bs(e){let{bootstrapLogger:t,reactionCtx:n,githubClient:r,agentSuccess:o,attachmentResult:s,serverHandle:c,detectedOpencodeVersion:l}=e;try{if(s!=null){let e=i({phase:`attachment-cleanup`});await Wo(s.tempFiles,e)}n!=null&&r!=null&&await lr(r,n,o,i({phase:`cleanup`}));let e=i({phase:`prune`}),t=re();if(c!=null){let n=J(t),r=await fs(c.client,n,ds,e);r.prunedCount>0&&e.info(`Pruned old sessions`,{pruned:r.prunedCount,remaining:r.remainingCount})}let u=ne(),d=i({phase:`cache-save`}),f=L.join(t,`.git`,`opencode`);await de({components:u,runId:D(),logger:d,storagePath:k(),authPath:fe(),projectIdPath:f,opencodeVersion:l})&&a(_.CACHE_SAVED,`true`)}catch(e){t.warning(`Cleanup failed (non-fatal)`,{error:e instanceof Error?e.message:String(e)})}finally{if(c!=null)try{c.shutdown()}catch(e){t.warning(`Server shutdown failed (non-fatal)`,{error:e instanceof Error?e.message:String(e)})}}}const xs=L.join(Ne.homedir(),`.cache`,`fro-bot-dedup`);function Ss(e){return e.replaceAll(`/`,`-`)}function Cs(e,t){let n=Ss(e);return L.join(xs,`${n}-${t.entityType}-${t.entityNumber}`)}function ws(e,t){return`${ee}-${Ss(e)}-${t.entityType}-${t.entityNumber}-`}function Ts(e,t,n){return`${ws(e,t)}${n}`}async function Es(e,t,n,i=le){let a=Cs(e,t),o=L.join(a,`sentinel.json`),s=ws(e,t);try{if(await I.rm(a,{recursive:!0,force:!0}),await I.mkdir(a,{recursive:!0}),await i.restoreCache([a],s,[])==null)return null;let e=await I.readFile(o,`utf8`);return JSON.parse(e)}catch(e){return n.debug(`Dedup marker restore failed; proceeding without marker`,{error:r(e),entityType:t.entityType,entityNumber:t.entityNumber}),null}}async function Ds(e,t,n,i,a=le){let o=Cs(e,t),s=L.join(o,`sentinel.json`),c=Ts(e,t,n.runId);try{return await I.mkdir(o,{recursive:!0}),await I.writeFile(s,JSON.stringify(n),`utf8`),await a.saveCache([o],c),!0}catch(e){return r(e).toLowerCase().includes(`already exists`)?!0:(i.debug(`Dedup marker save failed`,{error:r(e),entityType:t.entityType,entityNumber:t.entityNumber,saveKey:c}),!1)}}const Os=new Set([`pull_request`,`issues`]);function ks(e){return e.target==null||!Os.has(e.eventType)?null:e.eventType===`pull_request`&&e.target.kind===`pr`?{entityType:`pr`,entityNumber:e.target.number}:e.eventType===`issues`&&e.target.kind===`issue`?{entityType:`issue`,entityNumber:e.target.number}:null}async function As(e,t,n,r,a=i({phase:`dedup`}),o){let s=ks(t);if(e===0)return{shouldProceed:!0,entity:s};if(s==null)return{shouldProceed:!0,entity:null};let c=await Es(n,s,a,o);if(c==null||c.runId===t.runId)return{shouldProceed:!0,entity:s};let l=new Date(c.timestamp).getTime();if(Number.isNaN(l))return a.warning(`Dedup marker timestamp is invalid; proceeding without dedup`,{markerTimestamp:c.timestamp}),{shouldProceed:!0,entity:s};let u=Date.now()-l;return u<-6e4?(a.warning(`Dedup marker timestamp is too far in the future; proceeding without dedup`,{markerTimestamp:c.timestamp,markerAge:u}),{shouldProceed:!0,entity:s}):Math.max(0,u)>e?{shouldProceed:!0,entity:s}:(a.info(`Skipping duplicate trigger within dedup window`,{eventType:t.eventType,action:t.action,runId:t.runId,markerRunId:c.runId,markerTimestamp:c.timestamp,dedupWindow:e,entityType:s.entityType,entityNumber:s.entityNumber}),Be({sessionId:null,cacheStatus:`miss`,duration:Date.now()-r}),{shouldProceed:!1,entity:s})}async function js(e,t,n,r=i({phase:`dedup`}),a){await Ds(n,t,{timestamp:new Date().toISOString(),runId:e.runId,action:e.action??`unknown`,eventType:e.eventType,entityType:t.entityType,entityNumber:t.entityNumber},r,a)}async function Ms(e,t,n,r,o,s){let c={context:t.agentContext,customPrompt:e.inputs.prompt,cacheStatus:n.cacheStatus,sessionContext:{recentSessions:r.recentSessions,priorWorkContext:r.priorWorkContext},triggerContext:t.triggerResult.context,fileParts:r.attachmentResult?.fileParts},l=N.env.SKIP_AGENT_EXECUTION===`true`,u=Date.now(),d;if(l)e.logger.info(`Skipping agent execution (SKIP_AGENT_EXECUTION=true)`),d={success:!0,exitCode:0,sessionId:null,error:null,tokenUsage:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null};else{let t=i({phase:`execution`});t.info(`Starting OpenCode execution`,{logicalKey:r.logicalKey?.key??null,continueSessionId:r.continueSessionId});let a=await er(c,t,{agent:e.inputs.agent,model:e.inputs.model,timeoutMs:e.inputs.timeoutMs,omoProviders:e.inputs.omoProviders,continueSessionId:r.continueSessionId??void 0,sessionTitle:r.sessionTitle??void 0},n.serverHandle),o=a.sessionId;if(o==null){let e=i({phase:`session`}),t=await ls(n.serverHandle.client,r.normalizedWorkspace,u,e);t!=null&&(o=t.session.id,e.debug(`Identified session from execution`,{sessionId:o}))}d={...a,sessionId:o},t.info(`Completed OpenCode execution`,{success:d.success,sessionId:d.sessionId,logicalKey:r.logicalKey?.key??null})}d.sessionId!=null&&(a(_.SESSION_ID,d.sessionId),o.addSessionCreated(d.sessionId)),d.tokenUsage!=null&&o.setTokenUsage(d.tokenUsage,d.model,d.cost);for(let e of d.prsCreated)o.addPRCreated(e);for(let e of d.commitsCreated)o.addCommitCreated(e);for(let e=0;e`)}async function Fs(e,t,n){try{if(t.type===`pr`){let{data:n}=await e.rest.pulls.get({owner:t.owner,repo:t.repo,pull_number:t.number});return{title:n.title,body:n.body??``,author:n.user?.login??`unknown`}}let{data:n}=await e.rest.issues.get({owner:t.owner,repo:t.repo,issue_number:t.number});return{title:n.title,body:n.body??``,author:n.user?.login??`unknown`}}catch(e){return n.warning(`Failed to fetch issue/PR`,{target:t,error:r(e)}),null}}async function Is(e,t,n,i){let a=[],o=1;for(;o<=50;)try{let{data:r}=await e.rest.issues.listComments({owner:t.owner,repo:t.repo,issue_number:t.number,per_page:100,page:o});if(r.length===0)break;for(let e of r){let t=e.user?.login??`unknown`;a.push({id:e.id,body:e.body??``,author:t,authorAssociation:e.author_association??`NONE`,createdAt:e.created_at,updatedAt:e.updated_at,isBot:Ps(t,e.body??``,n)})}if(r.length<100)break;o++}catch(e){i.warning(`Failed to fetch comments page`,{target:t,page:o,error:r(e)});break}return a}async function Ls(e,t,n,i){try{let r=[],a=null,o=null,s=``,c=``,l=`unknown`,u=0;for(;u<50;){let d=(await e.graphql(` +`)}var Oi=class extends Error{constructor(e,t,n){super(Di(n)),this.request=e,this.headers=t,this.response=n,this.errors=n.errors,this.data=n.data,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}name=`GraphqlResponseError`;errors;data},ki=[`method`,`baseUrl`,`url`,`headers`,`request`,`query`,`mediaType`,`operationName`],Ai=[`query`,`method`,`url`],ji=/\/api\/v3\/?$/;function Mi(e,t,n){if(n){if(typeof t==`string`&&`query`in n)return Promise.reject(Error(`[@octokit/graphql] "query" cannot be used as variable name`));for(let e in n)if(Ai.includes(e))return Promise.reject(Error(`[@octokit/graphql] "${e}" cannot be used as variable name`))}let r=typeof t==`string`?Object.assign({query:t},n):t,i=Object.keys(r).reduce((e,t)=>ki.includes(t)?(e[t]=r[t],e):(e.variables||={},e.variables[t]=r[t],e),{}),a=r.baseUrl||e.endpoint.DEFAULTS.baseUrl;return ji.test(a)&&(i.url=a.replace(ji,`/api/graphql`)),e(i).then(e=>{if(e.data.errors){let t={};for(let n of Object.keys(e.headers))t[n]=e.headers[n];throw new Oi(i,t,e.data)}return e.data.data})}function Ni(e,t){let n=e.defaults(t);return Object.assign((e,t)=>Mi(n,e,t),{defaults:Ni.bind(null,n),endpoint:n.endpoint})}Ni(Ti,{headers:{"user-agent":`octokit-graphql.js/${Ei} ${V()}`},method:`POST`,url:`/graphql`});function Pi(e){return Ni(e,{method:`POST`,url:`/graphql`})}var Fi=`(?:[a-zA-Z0-9_-]+)`,Ii=`\\.`,Li=RegExp(`^${Fi}${Ii}${Fi}${Ii}${Fi}$`),Ri=Li.test.bind(Li);async function zi(e){let t=Ri(e),n=e.startsWith(`v1.`)||e.startsWith(`ghs_`),r=e.startsWith(`ghu_`);return{type:`token`,token:e,tokenType:t?`app`:n?`installation`:r?`user-to-server`:`oauth`}}function Bi(e){return e.split(/\./).length===3?`bearer ${e}`:`token ${e}`}async function Vi(e,t,n,r){let i=t.endpoint.merge(n,r);return i.headers.authorization=Bi(e),t(i)}var Hi=function(e){if(!e)throw Error(`[@octokit/auth-token] No token passed to createTokenAuth`);if(typeof e!=`string`)throw Error(`[@octokit/auth-token] Token passed to createTokenAuth is not a string`);return e=e.replace(/^(token|bearer) +/i,``),Object.assign(zi.bind(null,e),{hook:Vi.bind(null,e)})};const Ui=`7.0.6`,Wi=()=>{},Gi=console.warn.bind(console),Ki=console.error.bind(console);function qi(e={}){return typeof e.debug!=`function`&&(e.debug=Wi),typeof e.info!=`function`&&(e.info=Wi),typeof e.warn!=`function`&&(e.warn=Gi),typeof e.error!=`function`&&(e.error=Ki),e}const Ji=`octokit-core.js/${Ui} ${V()}`;var Yi=class{static VERSION=Ui;static defaults(e){return class extends this{constructor(...t){let n=t[0]||{};if(typeof e==`function`){super(e(n));return}super(Object.assign({},e,n,n.userAgent&&e.userAgent?{userAgent:`${n.userAgent} ${e.userAgent}`}:null))}}}static plugins=[];static plugin(...e){let t=this.plugins;return class extends this{static plugins=t.concat(e.filter(e=>!t.includes(e)))}}constructor(e={}){let t=new Ar.Collection,n={baseUrl:Ti.endpoint.DEFAULTS.baseUrl,headers:{},request:Object.assign({},e.request,{hook:t.bind(null,`request`)}),mediaType:{previews:[],format:``}};if(n.headers[`user-agent`]=e.userAgent?`${e.userAgent} ${Ji}`:Ji,e.baseUrl&&(n.baseUrl=e.baseUrl),e.previews&&(n.mediaType.previews=e.previews),e.timeZone&&(n.headers[`time-zone`]=e.timeZone),this.request=Ti.defaults(n),this.graphql=Pi(this.request).defaults(n),this.log=qi(e.log),this.hook=t,e.authStrategy){let{authStrategy:n,...r}=e,i=n(Object.assign({request:this.request,log:this.log,octokit:this,octokitOptions:r},e.auth));t.wrap(`request`,i.hook),this.auth=i}else if(!e.auth)this.auth=async()=>({type:`unauthenticated`});else{let n=Hi(e.auth);t.wrap(`request`,n.hook),this.auth=n}let r=this.constructor;for(let t=0;t({async next(){if(!s)return{done:!0};try{let e=ia(await i({method:a,url:s,headers:o}));if(s=((e.headers.link||``).match(/<([^<>]+)>;\s*rel="next"/)||[])[1],!s&&`total_commits`in e.data){let t=new URL(e.url),n=t.searchParams,r=parseInt(n.get(`page`)||`1`,10);r*parseInt(n.get(`per_page`)||`250`,10){if(i.done)return t;let a=!1;function o(){a=!0}return t=t.concat(r?r(i.value,o):i.value.data),a?t:sa(e,t,n,r)})}Object.assign(oa,{iterator:aa});function ca(e){return{paginate:Object.assign(oa.bind(null,e),{iterator:aa.bind(null,e)})}}ca.VERSION=ra,new fr;const la=xr(),ua={baseUrl:la,request:{agent:vr(la),fetch:br(la)}},da=Yi.plugin(ta,ca).defaults(ua);function fa(e,t){let n=Object.assign({},t||{}),r=_r(e,n);return r&&(n.auth=r),n}const pa=new fr;function ma(e,t,...n){return new(da.plugin(...n))(fa(e,t))}var K=C(ue(),1),ha=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},ga=class{constructor(e,t,n){if(e<1)throw Error(`max attempts should be greater than or equal to 1`);if(this.maxAttempts=e,this.minSeconds=Math.floor(t),this.maxSeconds=Math.floor(n),this.minSeconds>this.maxSeconds)throw Error(`min seconds should be less than or equal to max seconds`)}execute(e,t){return ha(this,void 0,void 0,function*(){let n=1;for(;nsetTimeout(t,e*1e3))})}},q=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},_a=class extends Error{constructor(e){super(`Unexpected HTTP response: ${e}`),this.httpStatusCode=e,Object.setPrototypeOf(this,new.target.prototype)}};const va=process.platform===`win32`;process.platform;function ya(e,t,n,r){return q(this,void 0,void 0,function*(){return t||=F.join(Pa(),ye.randomUUID()),yield s(F.dirname(t)),j(`Downloading ${e}`),j(`Destination ${t}`),yield new ga(3,Fa(`TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS`,10),Fa(`TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS`,20)).execute(()=>q(this,void 0,void 0,function*(){return yield ba(e,t||``,n,r)}),e=>!(e instanceof _a&&e.httpStatusCode&&e.httpStatusCode<500&&e.httpStatusCode!==408&&e.httpStatusCode!==429))})}function ba(e,t,n,r){return q(this,void 0,void 0,function*(){if(P.existsSync(t))throw Error(`Destination file path ${t} already exists`);let i=new u(`actions/tool-cache`,[],{allowRetries:!1});n&&(j(`set auth`),r===void 0&&(r={}),r.authorization=n);let a=yield i.get(e,r);if(a.message.statusCode!==200){let t=new _a(a.message.statusCode);throw j(`Failed to download from "${e}". Code(${a.message.statusCode}) Message(${a.message.statusMessage})`),t}let o=Ce.promisify(Fe.pipeline),s=Fa(`TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY`,()=>a.message)(),c=!1;try{return yield o(s,P.createWriteStream(t)),j(`download complete`),c=!0,t}finally{if(!c){j(`download failed`);try{yield v(t)}catch(e){j(`Failed to delete '${t}'. ${e.message}`)}}}})}function xa(e,t){return q(this,arguments,void 0,function*(e,t,n=`xz`){if(!e)throw Error(`parameter 'file' is required`);t=yield Oa(t),j(`Checking tar --version`);let r=``;yield M(`tar --version`,[],{ignoreReturnCode:!0,silent:!0,listeners:{stdout:e=>r+=e.toString(),stderr:e=>r+=e.toString()}}),j(r.trim());let i=r.toUpperCase().includes(`GNU TAR`),a;a=n instanceof Array?n:[n],m()&&!n.includes(`v`)&&a.push(`-v`);let o=t,s=e;return va&&i&&(a.push(`--force-local`),o=t.replace(/\\/g,`/`),s=e.replace(/\\/g,`/`)),i&&(a.push(`--warning=no-unknown-keyword`),a.push(`--overwrite`)),a.push(`-C`,o,`-f`,s),yield M(`tar`,a),t})}function Sa(e,t){return q(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'file' is required`);return t=yield Oa(t),va?yield Ca(e,t):yield wa(e,t),t})}function Ca(e,t){return q(this,void 0,void 0,function*(){let n=e.replace(/'/g,`''`).replace(/"|\n|\r/g,``),r=t.replace(/'/g,`''`).replace(/"|\n|\r/g,``),i=yield b(`pwsh`,!1);if(i){let e=[`-NoLogo`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Unrestricted`,`-Command`,[`$ErrorActionPreference = 'Stop' ;`,`try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`,`try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${n}', '${r}', $true) }`,`catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${n}' -DestinationPath '${r}' -Force } else { throw $_ } } ;`].join(` `)];j(`Using pwsh at path: ${i}`),yield M(`"${i}"`,e)}else{let e=[`-NoLogo`,`-Sta`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Unrestricted`,`-Command`,[`$ErrorActionPreference = 'Stop' ;`,`try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`,`if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${n}' -DestinationPath '${r}' -Force }`,`else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${n}', '${r}', $true) }`].join(` `)],t=yield b(`powershell`,!0);j(`Using powershell at path: ${t}`),yield M(`"${t}"`,e)}})}function wa(e,t){return q(this,void 0,void 0,function*(){let n=yield b(`unzip`,!0),r=[e];m()||r.unshift(`-q`),r.unshift(`-o`),yield M(`"${n}"`,r,{cwd:t})})}function Ta(e,t,n,r){return q(this,void 0,void 0,function*(){if(n=K.clean(n)||n,r||=_e.arch(),j(`Caching tool ${t} ${n} ${r}`),j(`source dir: ${e}`),!P.statSync(e).isDirectory())throw Error(`sourceDir is not a directory`);let i=yield ka(t,n,r);for(let t of P.readdirSync(e))yield y(F.join(e,t),i,{recursive:!0});return Aa(t,n,r),i})}function Ea(e,t,n){if(!e)throw Error(`toolName parameter is required`);if(!t)throw Error(`versionSpec parameter is required`);n||=_e.arch(),ja(t)||(t=Ma(Da(e,n),t));let r=``;if(t){t=K.clean(t)||``;let i=F.join(Na(),e,t,n);j(`checking cache: ${i}`),P.existsSync(i)&&P.existsSync(`${i}.complete`)?(j(`Found tool in cache ${e} ${t} ${n}`),r=i):j(`not found`)}return r}function Da(e,t){let n=[];t||=_e.arch();let r=F.join(Na(),e);if(P.existsSync(r)){let e=P.readdirSync(r);for(let i of e)if(ja(i)){let e=F.join(r,i,t||``);P.existsSync(e)&&P.existsSync(`${e}.complete`)&&n.push(i)}}return n}function Oa(e){return q(this,void 0,void 0,function*(){return e||=F.join(Pa(),ye.randomUUID()),yield s(e),e})}function ka(e,t,n){return q(this,void 0,void 0,function*(){let r=F.join(Na(),e,K.clean(t)||t,n||``);j(`destination ${r}`);let i=`${r}.complete`;return yield v(r),yield v(i),yield s(r),r})}function Aa(e,t,n){let r=`${F.join(Na(),e,K.clean(t)||t,n||``)}.complete`;P.writeFileSync(r,``),j(`finished caching tool`)}function ja(e){let t=K.clean(e)||``;j(`isExplicit: ${t}`);let n=K.valid(t)!=null;return j(`explicit? ${n}`),n}function Ma(e,t){let n=``;j(`evaluating ${e.length} versions`),e=e.sort((e,t)=>K.gt(e,t)?1:-1);for(let r=e.length-1;r>=0;r--){let i=e[r];if(K.satisfies(i,t)){n=i;break}}return j(n?`matched: ${n}`:`match not found`),n}function Na(){let e=process.env.RUNNER_TOOL_CACHE||``;return Se(e,`Expected RUNNER_TOOL_CACHE to be defined`),e}function Pa(){let e=process.env.RUNNER_TEMP||``;return Se(e,`Expected RUNNER_TEMP to be defined`),e}function Fa(e,t){let n=global[e];return n===void 0?t:n}function Ia(e){let t;try{t=JSON.parse(e)}catch(e){throw e instanceof SyntaxError?Error(`Invalid auth-json format: ${e.message}`):e}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`auth-json must be a JSON object`);return t}async function La(e,t,n){let r=L.join(t,`auth.json`);await I.mkdir(t,{recursive:!0});let i=JSON.stringify(e,null,2);return await I.writeFile(r,i,{mode:384}),n.info(`Populated auth.json`,{path:r,providers:Object.keys(e).length}),r}function Ra(){let e=N.platform,t=N.arch;return{os:{darwin:`darwin`,linux:`linux`,win32:`windows`}[e]??`linux`,arch:{arm64:`aarch64`,x64:`x64`}[t]??`x64`,ext:`.zip`}}function za(e,t){return`https://github.com/oven-sh/bun/releases/download/bun-${e.startsWith(`v`)?e:`v${e}`}/${`bun-${t.os}-${t.arch}${t.ext}`}`}async function Ba(e,t,n,i,a=pe){let o=Ra(),s=t.find(`bun`,a,o.arch);if(s.length>0)return e.info(`Bun found in cache`,{version:a,path:s}),i(s),await Ha(s),{path:s,version:a,cached:!0};e.info(`Downloading Bun`,{version:a});let c=za(a,o);try{let r=await t.downloadTool(c);if(N.platform!==`win32`&&!await Ua(r,e,n))throw Error(`Downloaded Bun archive appears corrupted`);e.info(`Extracting Bun`);let s=await Va(await t.extractZip(r),t),l=ke.dirname(s);e.info(`Caching Bun`);let u=await t.cacheDir(l,`bun`,a,o.arch);return i(u),await Ha(u),e.info(`Bun installed`,{version:a,path:u}),{path:u,version:a,cached:!1}}catch(e){let t=r(e);throw Error(`Failed to install Bun ${a}: ${t}`)}}async function Va(e,t){for(let n of await Oe.readdir(e,{withFileTypes:!0})){let{name:r}=n,i=ke.join(e,r);if(n.isFile()){if(r===`bun`||r===`bun.exe`)return i;if(/^bun.*\.zip/.test(r))return Va(await t.extractZip(i),t)}if(r.startsWith(`bun`)&&n.isDirectory())return Va(i,t)}throw Error(`Could not find executable: bun`)}async function Ha(e){let t=e=>N.platform===`win32`?`${e}.exe`:e,n=ke.join(e,t(`bun`));try{await Oe.symlink(n,ke.join(e,t(`bunx`)))}catch(e){let t=typeof e==`object`?e.code:void 0;if(t!==`EEXIST`&&t!==`EPERM`&&t!==`EACCES`)throw e}}async function Ua(e,t,n){try{let{stdout:r}=await n.getExecOutput(`file`,[e],{silent:!0}),i=r.includes(`Zip archive`)||r.includes(`ZIP`);return i||t.warning(`Bun download validation failed`,{output:r.trim()}),i}catch{return t.debug(`Could not validate Bun download (file command unavailable)`),!0}}function Wa(e){return{debug:t=>e.debug(t),info:t=>e.info(t),warn:t=>e.warning(t),error:t=>e.error(t)}}function Ga(e){let{token:t,logger:n}=e;return n.debug(`Creating GitHub client with token`),ma(t,{log:Wa(n)})}async function Ka(e,t){try{let{data:n}=await e.rest.users.getAuthenticated();return t.debug(`Authenticated as`,{login:n.login,type:n.type}),n.login}catch{return t.debug(`Failed to get authenticated user, may be app token`),`fro-bot[bot]`}}async function qa(e,t,n,r){let i=t??n,a=t==null?n.length>0?`github-token`:`none`:`app-token`;if(i.length===0)return r.warning(`No GitHub token available`),{authenticated:!1,method:`none`,botLogin:null};N.env.GH_TOKEN=i,r.info(`Configured authentication`,{method:a});let o=null;return e!=null&&(o=await Ka(e,r)),{authenticated:!0,method:a,botLogin:o}}async function Ja(e,t){let n=await t.getExecOutput(`git`,[`config`,e],{ignoreReturnCode:!0,silent:!0});return n.exitCode===0&&n.stdout.trim().length>0?n.stdout.trim():null}async function Ya(e,t,n,r){let i=await Ja(`user.name`,r),a=await Ja(`user.email`,r);if(i!=null&&a!=null){n.info(`Git identity already configured`,{name:i,email:a});return}if(t==null)throw Error(`Cannot configure Git identity: no authenticated GitHub user`);let o=null;if(a==null){let r=await Xe(e,t,n);if(r==null)throw Error(`Cannot configure Git identity: failed to look up user ID for '${t}'`);o=String(r.id)}i??await r.exec(`git`,[`config`,`--global`,`user.name`,t],void 0);let s=`${o}+${t}@users.noreply.github.com`;a??await r.exec(`git`,[`config`,`--global`,`user.email`,s],void 0),n.info(`Configured git identity`,{name:i??t,email:a??s})}const Xa=new Set([`__proto__`,`prototype`,`constructor`]);function Za(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Qa(e,t){let n=Object.create(null);for(let[t,r]of Object.entries(e))Xa.has(t)||(n[t]=r);for(let[e,r]of Object.entries(t)){if(Xa.has(e))continue;let t=n[e];Za(r)&&Za(t)?n[e]=Qa(t,r):n[e]=r}return n}async function $a(e,t,n){let r=JSON.parse(e);if(!Za(r))throw Error(`omo-config must be a JSON object (non-null, non-array)`);let i=r;await I.mkdir(t,{recursive:!0});let a=L.join(t,`oh-my-opencode.json`),o={};try{let e=await I.readFile(a,`utf8`),t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(o=t)}catch(e){n.debug(`Using empty base oMo config`,{path:a,error:String(e)})}let s=Qa(o,i);await I.writeFile(a,JSON.stringify(s,null,2)),n.info(`Wrote oMo config`,{path:a,keyCount:Object.keys(i).length})}async function eo(e,t,n={}){let{logger:i,execAdapter:a}=t,{claude:o=`no`,copilot:s=`no`,gemini:c=`no`,openai:l=`no`,opencodeZen:u=`no`,zaiCodingPlan:d=`no`,kimiForCoding:f=`no`}=n;i.info(`Installing Oh My OpenAgent plugin`,{version:e,claude:o,copilot:s,gemini:c,openai:l,opencodeZen:u,zaiCodingPlan:d,kimiForCoding:f});let p=``,m=[`oh-my-openagent@${e}`,`install`,`--no-tui`,`--skip-auth`,`--claude=${o}`,`--copilot=${s}`,`--gemini=${c}`,`--openai=${l}`,`--opencode-zen=${u}`,`--zai-coding-plan=${d}`,`--kimi-for-coding=${f}`];try{let t=await a.exec(`bunx`,m,{listeners:{stdout:e=>{p+=e.toString()},stderr:e=>{p+=e.toString()}},ignoreReturnCode:!0});if(t!==0){let e=`bunx oh-my-openagent install returned exit code ${t}`;return i.error(e,{output:p.slice(0,1e3)}),{installed:!1,version:null,error:`${e}\n${p.slice(0,500)}`}}let n=/oh-my-opencode@(\d+\.\d+\.\d+)/i.exec(p),r=n!=null&&n[1]!=null?n[1]:e;return i.info(`oMo plugin installed`,{version:r}),{installed:!0,version:r,error:null}}catch(e){let t=r(e),n=p.length>0?`${t}\nOutput: ${p.slice(0,500)}`:t;return i.error(`Failed to run oMo installer`,{error:t,output:p.slice(0,500)}),{installed:!1,version:null,error:`bunx oh-my-openagent install failed: ${n}`}}}const to=`opencode`,no=g;function ro(){let e=Ne.platform(),t=Ne.arch(),n={darwin:`darwin`,linux:`linux`,win32:`windows`},r={x64:`x64`,arm64:`arm64`},i=e===`win32`||e===`darwin`?`.zip`:`.tar.gz`;return{os:n[e]??`linux`,arch:r[t]??`x64`,ext:i}}function io(e,t){return`https://github.com/anomalyco/opencode/releases/download/${e.startsWith(`v`)?e:`v${e}`}/${`opencode-${t.os}-${t.arch}${t.ext}`}`}async function ao(e,t,n,r){if(N.platform===`win32`)return!0;try{let{stdout:i}=await r.getExecOutput(`file`,[e],{silent:!0}),a=(t===`.zip`?[`Zip archive`,`ZIP`]:[`gzip`,`tar`,`compressed`]).some(e=>i.includes(e));return a||n.warning(`Download validation failed`,{output:i.trim()}),a}catch{return n.debug(`Could not validate download (file command unavailable)`),!0}}async function oo(e,t,n,i,a=no){let o=ro(),s=n.find(to,e,o.arch);if(s.length>0)return t.info(`OpenCode found in cache`,{version:e,path:s}),{path:s,version:e,cached:!0};try{return await so(e,o,t,n,i)}catch(n){t.warning(`Primary version install failed, trying fallback`,{requestedVersion:e,fallbackVersion:a,error:r(n)})}if(e!==a)try{let e=await so(a,o,t,n,i);return t.info(`Installed fallback version`,{version:a}),e}catch(t){throw Error(`Failed to install OpenCode (tried ${e} and ${a}): ${r(t)}`)}throw Error(`Failed to install OpenCode version ${e}`)}async function so(e,t,n,r,i){n.info(`Downloading OpenCode`,{version:e});let a=io(e,t),o=await r.downloadTool(a);if(!await ao(o,t.ext,n,i))throw Error(`Downloaded archive appears corrupted`);n.info(`Extracting OpenCode`);let s=t.ext===`.zip`?await r.extractZip(o):await r.extractTar(o);n.info(`Caching OpenCode`);let c=await r.cacheDir(s,to,e,t.arch);return n.info(`OpenCode installed`,{version:e,path:c}),{path:c,version:e,cached:!1}}async function co(e){let t=await fetch(`https://api.github.com/repos/anomalyco/opencode/releases/latest`);if(!t.ok)throw Error(`Failed to fetch latest OpenCode version: ${t.statusText}`);let n=(await t.json()).tag_name.replace(/^v/,``);return e.info(`Latest OpenCode version`,{version:n}),n}const lo={restoreCache:async(e,t,n)=>T(e,t,n),saveCache:async(e,t)=>oe(e,t)};function uo(e){let{os:t,opencodeVersion:n,omoVersion:r}=e;return`${me}-${t}-oc-${n}-omo-${r}`}function fo(e){let{os:t,opencodeVersion:n,omoVersion:r}=e;return[`${me}-${t}-oc-${n}-omo-${r}-`]}async function po(e){let{logger:t,os:n,opencodeVersion:i,omoVersion:a,toolCachePath:o,bunCachePath:s,omoConfigPath:c,cacheAdapter:l=lo}=e,u=uo({os:n,opencodeVersion:i,omoVersion:a}),d=fo({os:n,opencodeVersion:i,omoVersion:a}),f=[o,s,c];t.info(`Restoring tools cache`,{primaryKey:u,restoreKeys:[...d],paths:f});try{let e=await l.restoreCache(f,u,[...d]);return e==null?(t.info(`Tools cache miss - will install tools`),{hit:!1,restoredKey:null}):(t.info(`Tools cache restored`,{restoredKey:e}),{hit:!0,restoredKey:e})}catch(e){return t.warning(`Tools cache restore failed`,{error:r(e)}),{hit:!1,restoredKey:null}}}async function mo(e){let{logger:t,os:n,opencodeVersion:i,omoVersion:a,toolCachePath:o,bunCachePath:s,omoConfigPath:c,cacheAdapter:l=lo}=e,u=uo({os:n,opencodeVersion:i,omoVersion:a}),d=[o,s,c];t.info(`Saving tools cache`,{saveKey:u,paths:d});try{return await l.saveCache(d,u),t.info(`Tools cache saved`,{saveKey:u}),!0}catch(e){return e instanceof Error&&e.message.includes(`already exists`)?(t.info(`Tools cache key already exists, skipping save`),!0):(t.warning(`Tools cache save failed`,{error:r(e)}),!1)}}function ho(){return{find:Ea,downloadTool:ya,extractTar:xa,extractZip:Sa,cacheDir:Ta}}function go(){return{exec:M,getExecOutput:t}}async function _o(t,n){let a=Date.now(),o=i({component:`setup`}),s=ho(),l=go();try{o.info(`Starting setup`,{version:t.opencodeVersion});let i;try{i=Ia(t.authJson)}catch(e){return c(`Invalid auth-json: ${r(e)}`),null}let u=t.opencodeVersion;if(u===`latest`)try{u=await co(o)}catch(e){o.warning(`Failed to get latest version, using fallback`,{error:r(e)}),u=no}let f=t.omoVersion,m=N.env.RUNNER_TOOL_CACHE??`/opt/hostedtoolcache`,h=Ae(m,`opencode`),g=Ae(m,`bun`),_=Ae(Pe(),`.config`,`opencode`),v=se(),y=await po({logger:o,os:v,opencodeVersion:u,omoVersion:f,toolCachePath:h,bunCachePath:g,omoConfigPath:_}),b=y.hit?`hit`:`miss`,x,S=!1,C=null;if(y.hit){let e=s.find(`opencode`,u);e.length>0?(x={path:e,version:u,cached:!0},o.info(`Tools cache hit, using cached OpenCode CLI`,{version:u,omoVersion:f})):o.warning(`Tools cache hit but binary not found in tool-cache, falling through to install`,{requestedVersion:u,restoredKey:y.restoredKey})}if(x==null)try{x=await oo(u,o,s,l)}catch(e){return c(`Failed to install OpenCode: ${r(e)}`),null}let w=!1;try{await Ba(o,s,l,p,pe),w=!0}catch(e){o.warning(`Bun installation failed, oMo will be unavailable`,{error:r(e)})}if(w){if(t.omoConfig!=null)try{await $a(t.omoConfig,_,o)}catch(e){o.warning(`Failed to write omo-config, continuing without custom config`,{error:r(e)})}let e=await eo(f,{logger:o,execAdapter:l},t.omoProviders);e.installed?(o.info(`oMo installed`,{version:e.version}),S=!0):o.warning(`oMo installation failed, continuing without oMo`,{error:e.error??`unknown error`}),C=e.error}let T={autoupdate:!1};if(t.opencodeConfig!=null){let e;try{e=JSON.parse(t.opencodeConfig)}catch{return c(`opencode-config must be valid JSON`),null}if(typeof e!=`object`||!e||Array.isArray(e))return c(`opencode-config must be a JSON object`),null;Object.assign(T,e)}e(`OPENCODE_CONFIG_CONTENT`,JSON.stringify(T)),y.hit||await mo({logger:o,os:v,opencodeVersion:u,omoVersion:f,toolCachePath:h,bunCachePath:g,omoConfigPath:_}),p(x.path),d(`opencode-path`,x.path),d(`opencode-version`,x.version),o.info(`OpenCode ready`,{version:x.version,cached:x.cached});let E=ma(n),D=await qa(E,null,n,o);e(`GH_TOKEN`,n),o.info(`GitHub CLI configured`),await Ya(E,D.botLogin,o,l);let O=Ae(ie(),`opencode`),k=await La(i,O,o);d(`auth-json-path`,k),o.info(`auth.json populated`,{path:k});let ee=Date.now()-a,te={opencodePath:x.path,opencodeVersion:x.version,ghAuthenticated:D.authenticated,omoInstalled:S,omoError:C,toolsCacheStatus:b,duration:ee};return o.info(`Setup complete`,{duration:ee}),te}catch(e){let t=r(e);return o.error(`Setup failed`,{error:t}),c(t),null}}function vo(e){return{success:!0,data:e}}function yo(e){return{success:!1,error:e}}const bo=[`OWNER`,`MEMBER`,`COLLABORATOR`];async function xo(e,t){try{let{client:n,server:r}=await pn({signal:e});return t.debug(`OpenCode server bootstrapped`,{url:r.url}),vo({client:n,server:r,shutdown:()=>{r.close()}})}catch(e){let n=e instanceof Error?e.message:String(e);return t.warning(`Failed to bootstrap OpenCode server`,{error:n}),yo(Error(`Server bootstrap failed: ${n}`))}}async function So(e,t){let n=e??`opencode`;try{let e=``;await M(n,[`--version`],{listeners:{stdout:t=>{e+=t.toString()}},silent:!0});let r=/(\d+\.\d+\.\d+)/.exec(e)?.[1]??null;return t.debug(`OpenCode version verified`,{version:r}),{available:!0,version:r}}catch{return t.debug(`OpenCode not available, will attempt auto-setup`),{available:!1,version:null}}}async function Co(e){let{logger:t,opencodeVersion:n}=e,r=N.env.OPENCODE_PATH??null,i=await So(r,t);if(i.available&&i.version!=null)return t.info(`OpenCode already available`,{version:i.version}),{path:r??`opencode`,version:i.version,didSetup:!1};t.info(`OpenCode not found, running auto-setup`,{requestedVersion:n});let a=await _o({opencodeVersion:n,authJson:e.authJson,appId:null,privateKey:null,opencodeConfig:e.opencodeConfig,omoConfig:null,omoVersion:e.omoVersion,omoProviders:e.omoProviders},e.githubToken);if(a==null)throw Error(`Auto-setup failed: runSetup returned null`);return p(a.opencodePath),N.env.OPENCODE_PATH=a.opencodePath,t.info(`Auto-setup completed`,{version:a.opencodeVersion,path:a.opencodePath}),{path:a.opencodePath,version:a.opencodeVersion,didSetup:!0}}async function wo(e,t){let n={repo:e.agentContext.repo,commentId:e.agentContext.commentId,issueNumber:e.agentContext.issueNumber,issueType:e.agentContext.issueType,botLogin:e.botLogin},r=i({phase:`acknowledgment`});return await ar(e.githubClient,n,r),t.debug(`Acknowledgment phase completed`),n}function To(e,t){try{JSON.parse(e)}catch{throw Error(`${t} must be valid JSON`)}}function Eo(e,t){let n=e.trim();if(!/^\d+$/.test(n))throw Error(`${t} must be a positive integer, received: ${e}`);let r=Number.parseInt(n,10);if(r===0)throw Error(`${t} must be a positive integer, received: ${e}`);return r}function Do(e){let t=e.trim(),n=t.indexOf(`/`);if(n===-1)throw Error(`Invalid model format: "${e}". Expected "provider/model" (e.g., "anthropic/claude-sonnet-4-20250514")`);let r=t.slice(0,n).trim(),i=t.slice(n+1).trim();if(r.length===0)throw Error(`Invalid model format: "${e}". Provider cannot be empty.`);if(i.length===0)throw Error(`Invalid model format: "${e}". Model ID cannot be empty.`);return{providerID:r,modelID:i}}function Oo(e,t=`timeout`){let n=e.trim();if(!/^\d+$/.test(n))throw Error(`${t} must be a non-negative integer, received: ${e}`);let r=Number.parseInt(n,10);if(Number.isNaN(r)||r<0)throw Error(`${t} must be a non-negative integer, received: ${e}`);return r}const ko=[`claude`,`claude-max20`,`copilot`,`gemini`,`openai`,`opencode-zen`,`zai-coding-plan`,`kimi-for-coding`];function Ao(e){let t=e.split(`,`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0),n=`no`,r=`no`,i=`no`,a=`no`,o=`no`,s=`no`,c=`no`;for(let e of t){if(!ko.includes(e))throw Error(`Invalid omo-providers value: "${e}". Valid values: ${ko.join(`, `)}`);switch(e){case`claude`:n=`yes`;break;case`claude-max20`:n=`max20`;break;case`copilot`:r=`yes`;break;case`gemini`:i=`yes`;break;case`openai`:a=`yes`;break;case`opencode-zen`:o=`yes`;break;case`zai-coding-plan`:s=`yes`;break;case`kimi-for-coding`:c=`yes`;break}}return{claude:n,copilot:r,gemini:i,openai:a,opencodeZen:o,zaiCodingPlan:s,kimiForCoding:c}}function jo(){try{let e=A(`github-token`,{required:!0}).trim();if(e.length===0)return yo(Error(`github-token is required but was not provided`));let t=A(`auth-json`,{required:!0}).trim();if(t.length===0)return yo(Error(`auth-json is required but was not provided`));To(t,`auth-json`);let r=A(`prompt`).trim(),i=r.length>0?r:null,a=A(`session-retention`).trim(),o=a.length>0?Eo(a,`session-retention`):50,s=A(`s3-backup`).trim().toLowerCase()===`true`,c=A(`s3-bucket`).trim(),l=c.length>0?c:null,u=A(`aws-region`).trim(),d=u.length>0?u:null,f=A(`agent`).trim(),p=f.length>0?f:w,m=A(`model`).trim(),h=m.length>0?Do(m):null,_=A(`timeout`).trim(),v=_.length>0?Oo(_):n,y=A(`opencode-version`).trim(),b=y.length>0?y:g,x=A(`skip-cache`).trim().toLowerCase()===`true`,S=A(`omo-version`).trim(),C=S.length>0?S:he,T=A(`omo-providers`).trim(),E=Ao(T.length>0?T:``),D=A(`opencode-config`).trim(),O=D.length>0?D:null,k=A(`dedup-window`).trim(),ee=k.length>0?Oo(k,`dedup-window`):ge;if(O!=null){To(O,`opencode-config`);let e=JSON.parse(O);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Input 'opencode-config' must be a JSON object`)}return vo({githubToken:e,authJson:t,prompt:i,sessionRetention:o,s3Backup:s,s3Bucket:l,awsRegion:d,agent:p,model:h,timeoutMs:v,opencodeVersion:b,skipCache:x,omoVersion:C,omoProviders:E,opencodeConfig:O,dedupWindow:ee})}catch(e){return yo(e instanceof Error?e:Error(String(e)))}}async function Mo(e){let t=jo();if(!t.success)return c(`Invalid inputs: ${t.error.message}`),null;let n=t.data,r=i({phase:`main`});r.info(`Action inputs parsed`,{sessionRetention:n.sessionRetention,s3Backup:n.s3Backup,hasGithubToken:n.githubToken.length>0,hasPrompt:n.prompt!=null,agent:n.agent,hasModelOverride:n.model!=null,timeoutMs:n.timeoutMs});let o=await Co({logger:r,opencodeVersion:n.opencodeVersion,githubToken:n.githubToken,authJson:n.authJson,omoVersion:n.omoVersion,omoProviders:n.omoProviders,opencodeConfig:n.opencodeConfig});return o.didSetup?r.info(`OpenCode auto-setup completed`,{version:o.version}):r.info(`OpenCode already available`,{version:o.version}),a(_.OPENCODE_VERSION,o.version),e.debug(`Bootstrap phase completed`,{opencodeVersion:o.version}),{inputs:n,logger:r,opencodeResult:o}}const No=/^[0-9a-f]{40}$/i;function Po(){return{exec:M,getExecOutput:t}}async function Fo(e){let{workspacePath:t,logger:n,execAdapter:i=Po()}=e,a=L.join(t,`.git`),o=L.join(a,`opencode`);try{let e=(await I.readFile(o,`utf8`)).trim();if(e.length>0){if(No.test(e))return n.debug(`Project ID loaded from cache`,{projectId:e}),{projectId:e,source:`cached`};n.warning(`Invalid cached project ID format, regenerating`,{cachedId:e})}}catch(e){n.debug(`No cached project ID found`,{error:r(e)})}try{let e=await I.readFile(a,`utf8`),n=/^gitdir: (.+)$/m.exec(e);if(n==null)return{projectId:null,source:`error`,error:`Invalid .git file format`};a=L.resolve(t,n[1]),o=L.join(a,`opencode`)}catch(e){if((typeof e==`object`?e.code:void 0)!==`EISDIR`)return{projectId:null,source:`error`,error:`Not a git repository`}}try{let{stdout:e,exitCode:a}=await i.getExecOutput(`git`,[`rev-list`,`--max-parents=0`,`--all`],{cwd:t,silent:!0});if(a!==0||e.trim().length===0)return{projectId:null,source:`error`,error:`No commits found in repository`};let s=e.trim().split(` +`).map(e=>e.trim()).filter(e=>e.length>0).sort();if(s.length===0)return{projectId:null,source:`error`,error:`No root commits found`};let c=s[0];try{await I.writeFile(o,c,{encoding:`utf8`,flag:`wx`}),n.info(`Project ID generated and cached`,{projectId:c,source:`generated`})}catch(e){(typeof e==`object`?e.code:void 0)===`EEXIST`?n.debug(`Project ID file already written by concurrent process, skipping`,{projectId:c}):n.warning(`Failed to cache project ID (continuing)`,{error:r(e)})}return{projectId:c,source:`generated`}}catch(e){return{projectId:null,source:`error`,error:r(e)}}}async function Io(e){let t=ne(),n=i({phase:`cache`}),r=re(),a=L.join(r,`.git`,`opencode`),o=await ae({components:t,logger:n,storagePath:k(),authPath:fe(),projectIdPath:a,opencodeVersion:e.opencodeResult.version}),s=o.corrupted?`corrupted`:o.hit?`hit`:`miss`;e.logger.info(`Cache restore completed`,{cacheStatus:s,key:o.key});let l=await Fo({workspacePath:r,logger:n});l.source===`error`?n.warning(`Failed to generate project ID (continuing)`,{error:l.error}):n.debug(`Project ID ready`,{projectId:l.projectId,source:l.source});let u=i({phase:`server-bootstrap`}),d=await xo(new AbortController().signal,u);if(!d.success)return c(`OpenCode server bootstrap failed: ${d.error.message}`),null;let f=d.data;return u.info(`SDK server bootstrapped successfully`),{cacheResult:o,cacheStatus:s,serverHandle:f}}const Lo={markdownImage:/!\[([^\]]*)\]\((https:\/\/github\.com\/user-attachments\/assets\/[^)]+)\)/gi,markdownLink:/\[([^\]]+)\]\((https:\/\/github\.com\/user-attachments\/files\/[^)]+)\)/gi,htmlImage:/]*src=["'](https:\/\/github\.com\/user-attachments\/assets\/[^"']+)["'][^>]*>/gi};function Ro(e,t,n){e.lastIndex=0;let r=e.exec(t);for(;r!=null;)n(r),r=e.exec(t);e.lastIndex=0}function zo(e){let t=[],n=new Set;return Ro(Lo.markdownImage,e,e=>{let r=e[2],i=e[1],a=e[0];r!=null&&i!=null&&!n.has(r)&&Dn(r)&&(n.add(r),t.push({url:r,originalMarkdown:a,altText:i,type:`image`}))}),Ro(Lo.markdownLink,e,e=>{let r=e[2],i=e[1],a=e[0];r!=null&&i!=null&&!n.has(r)&&Dn(r)&&(n.add(r),t.push({url:r,originalMarkdown:a,altText:i,type:`file`}))}),Ro(Lo.htmlImage,e,e=>{let r=e[1],i=e[0];if(r!=null&&!n.has(r)&&Dn(r)){n.add(r);let e=/alt=["']([^"']*)["']/i.exec(i);t.push({url:r,originalMarkdown:i,altText:e?.[1]??``,type:`image`})}}),Lo.htmlImage.lastIndex=0,t}function Bo(e,t,n){try{let r=new URL(e).pathname.split(`/`).at(-1);if(r!=null&&/\.[a-z0-9]+$/i.test(r))return r;if(t.trim().length>0){let e=t.replaceAll(/[^\w.-]/g,`_`).slice(0,50);return e.trim().length>0?e:`attachment_${n+1}`}return`attachment_${n+1}`}catch{return`attachment_${n+1}`}}const Vo={maxFiles:5,maxFileSizeBytes:5*1024*1024,maxTotalSizeBytes:15*1024*1024,allowedMimeTypes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`text/plain`,`text/markdown`,`text/csv`,`application/json`,`application/pdf`]},Ho=[`github.com`,`githubusercontent.com`];async function Uo(e,t,n,i,a){a.debug(`Downloading attachment`,{url:e.url});try{let r=await fetch(e.url,{headers:{Authorization:`Bearer ${n}`,Accept:`*/*`,"User-Agent":`fro-bot-agent`},redirect:`manual`}),o=r;if(r.status>=300&&r.status<400){let t=r.headers.get(`location`);if(t==null)return a.warning(`Redirect without location`,{url:e.url}),null;let n=new URL(t);if(!Ho.some(e=>n.hostname===e||n.hostname.endsWith(`.${e}`)))return a.warning(`Redirect to non-GitHub host blocked`,{url:e.url,redirectTo:n.hostname}),null;o=await fetch(t,{headers:{Accept:`*/*`,"User-Agent":`fro-bot-agent`},redirect:`follow`})}if(!o.ok)return a.warning(`Attachment download failed`,{url:e.url,status:o.status}),null;let s=o.headers.get(`content-length`);if(s!=null){let t=Number.parseInt(s,10);if(t>i.maxFileSizeBytes)return a.warning(`Attachment exceeds size limit (Content-Length)`,{url:e.url,size:t,limit:i.maxFileSizeBytes}),null}let c=we.from(await o.arrayBuffer());if(c.length>i.maxFileSizeBytes)return a.warning(`Attachment exceeds size limit`,{url:e.url,size:c.length,limit:i.maxFileSizeBytes}),null;let l=o.headers.get(`content-type`)??`application/octet-stream`,u=Bo(e.url,e.altText,t),d=l.split(`;`)[0],f=d==null?`application/octet-stream`:d.trim(),p=await I.mkdtemp(L.join(Me.tmpdir(),`fro-bot-attachments-`)),m=u.trim().length>0?u:`attachment_${t+1}`,h=L.join(p,m);return await I.writeFile(h,c),a.debug(`Attachment downloaded`,{filename:u,mime:f,sizeBytes:c.length,tempPath:h}),{url:e.url,filename:u,mime:f,sizeBytes:c.length,tempPath:h}}catch(t){return a.warning(`Attachment download error`,{url:e.url,error:r(t)}),null}}async function Wo(e,t,n=Vo,r){return Promise.all(e.map(async(e,i)=>Uo(e,i,t,n,r)))}async function Go(e,t){for(let n of e)try{await I.unlink(n);let e=L.dirname(n);await I.rmdir(e).catch(()=>{})}catch(e){t.debug(`Failed to cleanup temp file`,{path:n,error:r(e)})}}function Ko(e){return e.map(e=>({type:`file`,mime:e.mime,url:De(e.tempPath).toString(),filename:e.filename}))}function qo(e,t,n){let r=e,i=new Set(n.map(e=>e.filename));for(let e of t){let t=n.find(e=>i.has(e.filename));t!=null&&(r=r.replace(e.originalMarkdown,`@${t.filename}`))}return r}function Jo(e,t,n,r){return{processed:n,skipped:r,modifiedBody:qo(e,t,n),fileParts:Ko(n),tempFiles:n.map(e=>e.tempPath)}}function Yo(e){if(e<0||!Number.isFinite(e))throw Error(`Invalid bytes value: ${e}`);return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Xo(e,t=Vo,n){let r=[],i=[],a=0;for(let o of e)if(o!=null){if(r.length>=t.maxFiles){i.push({url:o.url,reason:`Exceeds max file count (${t.maxFiles})`}),n.debug(`Attachment skipped: max count`,{url:o.url});continue}if(o.sizeBytes>t.maxFileSizeBytes){i.push({url:o.url,reason:`File too large (${Yo(o.sizeBytes)} > ${Yo(t.maxFileSizeBytes)})`}),n.debug(`Attachment skipped: too large`,{url:o.url,size:o.sizeBytes});continue}if(a+o.sizeBytes>t.maxTotalSizeBytes){i.push({url:o.url,reason:`Would exceed total size limit (${Yo(t.maxTotalSizeBytes)})`}),n.debug(`Attachment skipped: total size exceeded`,{url:o.url});continue}if(!Zo(o.mime,t.allowedMimeTypes)){i.push({url:o.url,reason:`MIME type not allowed: ${o.mime}`}),n.debug(`Attachment skipped: MIME type`,{url:o.url,mime:o.mime});continue}a+=o.sizeBytes,r.push({filename:o.filename,mime:o.mime,sizeBytes:o.sizeBytes,tempPath:o.tempPath}),n.info(`Attachment validated`,{filename:o.filename,mime:o.mime,sizeBytes:o.sizeBytes})}return{validated:r,skipped:i}}function Zo(e,t){let[n]=e.split(`/`);for(let r of t)if(r===e||r.endsWith(`/*`)&&n!=null&&n===r.slice(0,-2))return!0;return!1}function J(e){let t=L.resolve(e);return t.endsWith(L.sep)&&t.length>1?t.slice(0,-1):t}const Qo=e=>typeof e==`object`&&!!e,Y=e=>typeof e==`string`?e:null,$o=e=>typeof e==`number`?e:null;function es(e){if(Array.isArray(e))return e.filter(Qo).map(e=>({file:Y(e.file)??``,additions:$o(e.additions)??0,deletions:$o(e.deletions)??0}))}function ts(e){return{id:e.id,version:e.version,projectID:e.projectID,directory:e.directory,parentID:e.parentID,title:e.title,time:{created:e.time.created,updated:e.time.updated,compacting:e.time.compacting,archived:e.time.archived},summary:e.summary==null?void 0:{additions:e.summary.additions,deletions:e.summary.deletions,files:e.summary.files,diffs:es(e.summary.diffs)},share:e.share?.url==null?void 0:{url:e.share.url},permission:e.permission==null?void 0:{rules:e.permission.rules},revert:e.revert==null?void 0:{messageID:e.revert.messageID,partID:e.revert.partID,snapshot:e.revert.snapshot,diff:e.revert.diff}}}async function ns(e,t){let n=await e.project.list();if(n.error!=null||n.data==null)return t.warning(`SDK project list failed`,{error:String(n.error)}),[];if(!Array.isArray(n.data))return[];let r=[];for(let e of n.data){if(!Qo(e))continue;let t=Y(e.id),n=Y(e.worktree),i=Y(e.path);t==null||n==null||i==null||r.push({id:t,worktree:n,path:i,vcs:`git`,time:{created:0,updated:0}})}return r}async function rs(e,t,n){let r=J(t),i=await ns(e,n);for(let e of i){if(J(e.worktree)===r)return e;let t=Y(e.path);if(t!=null&&J(t)===r)return e}return null}function is(e){return e.status===`running`?{status:`running`,input:e.input,time:{start:e.time.start}}:e.status===`error`?{status:`error`,input:e.input,error:e.error,time:{start:e.time.start,end:e.time.end}}:e.status===`pending`?{status:`pending`}:{status:`completed`,input:e.input,output:e.output,title:e.title,metadata:e.metadata,time:{start:e.time.start,end:e.time.end,compacted:e.time.compacted},attachments:void 0}}function as(e){let t={id:e.id,sessionID:e.sessionID,messageID:e.messageID};if(e.type===`text`)return{...t,type:`text`,text:e.text,synthetic:e.synthetic,ignored:e.ignored,time:e.time,metadata:e.metadata};if(e.type===`reasoning`)return{...t,type:`reasoning`,reasoning:e.reasoning??e.text,time:e.time};if(e.type===`tool`)return{...t,type:`tool`,callID:e.callID,tool:e.tool,state:is(e.state),metadata:e.metadata};if(e.type!==`step-finish`)return{...t,type:`text`,text:`text`in e?e.text:``};let n=e;return{...t,type:`step-finish`,reason:n.reason,snapshot:n.snapshot,cost:n.cost,tokens:{input:n.tokens.input,output:n.tokens.output,reasoning:n.tokens.reasoning,cache:{read:n.tokens.cache.read,write:n.tokens.cache.write}}}}function os(e){if(e.role===`user`){let t=e;return{id:t.id,sessionID:t.sessionID,role:`user`,time:{created:t.time.created},summary:t.summary==null?void 0:{title:t.summary.title,body:t.summary.body,diffs:es(t.summary.diffs)??[]},agent:t.agent,model:{providerID:t.model.providerID,modelID:t.model.modelID},system:t.system,tools:t.tools,variant:t.variant}}let t=e;return{id:t.id,sessionID:t.sessionID,role:`assistant`,time:{created:t.time.created,completed:t.time.completed},parentID:t.parentID,modelID:t.modelID,providerID:t.providerID,mode:t.mode,agent:t.agent??``,path:{cwd:t.path.cwd,root:t.path.root},summary:t.summary,cost:t.cost,tokens:{input:t.tokens.input,output:t.tokens.output,reasoning:t.tokens.reasoning,cache:{read:t.tokens.cache.read,write:t.tokens.cache.write}},finish:t.finish,error:t.error?{name:t.error.name,message:Y(t.error.data.message)??``}:void 0}}function ss(e){return[...e.map(e=>{let t=os(`info`in e?e.info:e),n=`parts`in e?e.parts.map(as):void 0;return n==null||n.length===0?t:{...t,parts:n}})].sort((e,t)=>e.time.created-t.time.created)}async function cs(e,t,n){let r=await e.session.list({query:{directory:t}});return r.error==null&&r.data!=null?Array.isArray(r.data)?r.data.map(ts):[]:(n.warning(`SDK session list failed`,{error:String(r.error)}),[])}async function ls(e,t,n){let r=await e.session.messages({path:{id:t}});return r.error==null&&r.data!=null?ss(r.data):(n.warning(`SDK session messages failed`,{error:String(r.error)}),[])}async function us(e,t,n,r){let i=await e.session.list({query:{directory:t,start:n,roots:!0,limit:10}});if(i.error!=null||i.data==null)return r.warning(`SDK session list failed`,{error:String(i.error)}),null;if(!Array.isArray(i.data)||i.data.length===0)return null;let a=i.data.map(ts);if(a.length===0)return null;let o=a.reduce((e,t)=>t.time.created>e.time.created?t:e);return{projectID:o.projectID,session:o}}async function ds(e,t,n){let r=await e.session.delete({path:{id:t}});if(r.error!=null){n.warning(`SDK session delete failed`,{sessionID:t,error:String(r.error)});return}n.debug(`Deleted session via SDK`,{sessionID:t})}const fs={maxSessions:50,maxAgeDays:30};async function ps(e,t,n,i){let{maxSessions:a,maxAgeDays:o}=n;if(i.info(`Starting session pruning`,{workspacePath:t,maxSessions:a,maxAgeDays:o}),await rs(e,t,i)==null)return i.debug(`No project found for pruning`,{workspacePath:t}),{prunedCount:0,prunedSessionIds:[],remainingCount:0,freedBytes:0};let s=await cs(e,t,i),c=s.filter(e=>e.parentID==null);if(c.length===0)return{prunedCount:0,prunedSessionIds:[],remainingCount:0,freedBytes:0};let l=[...c].sort((e,t)=>t.time.updated-e.time.updated),u=new Date;u.setDate(u.getDate()-o);let d=u.getTime(),f=new Set;for(let e of l)e.time.updated>=d&&f.add(e.id);for(let e=0;e!f.has(e.id)),m=new Set;for(let e of p){m.add(e.id);for(let t of s)t.parentID===e.id&&m.add(t.id)}if(m.size===0)return i.info(`No sessions to prune`),{prunedCount:0,prunedSessionIds:[],remainingCount:c.length,freedBytes:0};let h=[];for(let t of m)try{await ds(e,t,i),h.push(t),i.debug(`Pruned session`,{sessionId:t})}catch(e){i.warning(`Failed to prune session`,{sessionId:t,error:r(e)})}let g=c.length-p.length;return i.info(`Session pruning complete`,{prunedCount:h.length,remainingCount:g}),{prunedCount:h.length,prunedSessionIds:h,remainingCount:g,freedBytes:0}}async function ms(e,t,n,r){let{limit:i,fromDate:a,toDate:o}=n;r.debug(`Listing sessions`,{directory:t,limit:i});let s=[...(await cs(e,t,r)).filter(e=>!(e.parentID!=null||a!=null&&e.time.createdo.getTime()))].sort((e,t)=>t.time.updated-e.time.updated),c=[],l=i==null?s:s.slice(0,i);for(let t of l){let n=await ls(e,t.id,r),i=hs(n);c.push({id:t.id,projectID:t.projectID,directory:t.directory,title:t.title,createdAt:t.time.created,updatedAt:t.time.updated,messageCount:n.length,agents:i,isChild:!1})}return r.info(`Listed sessions`,{count:c.length,directory:t}),c}function hs(e){let t=new Set;for(let n of e)n.agent!=null&&t.add(n.agent);return[...t]}async function gs(e,t,n,r,i){let{limit:a=20,caseSensitive:o=!1,sessionId:s}=r;i.debug(`Searching sessions`,{query:e,directory:n,limit:a,caseSensitive:o});let c=o?e:e.toLowerCase(),l=[],u=0;if(s!=null){let e=await _s(t,s,c,o,i);return e.length>0&&l.push({sessionId:s,matches:e.slice(0,a)}),l}let d=await ms(t,n,{},i);for(let e of d){if(u>=a)break;let n=await _s(t,e.id,c,o,i);if(n.length>0){let t=a-u;l.push({sessionId:e.id,matches:n.slice(0,t)}),u+=Math.min(n.length,t)}}return i.info(`Session search complete`,{query:e,resultCount:l.length,totalMatches:u}),l}async function _s(e,t,n,r,i){let a=await ls(e,t,i),o=[];for(let e of a){let t=e.parts??[];for(let i of t){let t=vs(i);if(t==null)continue;let a=r?t:t.toLowerCase();if(a.includes(n)){let r=a.indexOf(n),s=Math.max(0,r-50),c=Math.min(t.length,r+n.length+50),l=t.slice(s,c);o.push({messageId:e.id,partId:i.id,excerpt:`...${l}...`,role:e.role,agent:e.agent})}}}return o}function vs(e){switch(e.type){case`text`:return e.text;case`reasoning`:return e.reasoning;case`tool`:return e.state.status===`completed`?`${e.tool}: ${e.state.output}`:null;case`step-finish`:return null}}function ys(e){let t=[`--- Fro Bot Run Summary ---`,`Event: ${e.eventType}`,`Repo: ${e.repo}`,`Ref: ${e.ref}`,`Run ID: ${e.runId}`,`Cache: ${e.cacheStatus}`,`Duration: ${e.duration}s`];return e.sessionIds.length>0&&t.push(`Sessions used: ${e.sessionIds.join(`, `)}`),e.logicalKey!=null&&t.push(`Logical Thread: ${e.logicalKey}`),e.createdPRs.length>0&&t.push(`PRs created: ${e.createdPRs.join(`, `)}`),e.createdCommits.length>0&&t.push(`Commits: ${e.createdCommits.join(`, `)}`),e.tokenUsage!=null&&t.push(`Tokens: ${e.tokenUsage.input} in / ${e.tokenUsage.output} out`),t.join(` +`)}async function bs(e,t,n,i){let a=ys(t);try{let t=await n.session.prompt({path:{id:e},body:{noReply:!0,parts:[{type:`text`,text:a}]}});if(t.error!=null){i.warning(`SDK prompt writeback failed`,{sessionId:e,error:String(t.error)});return}i.info(`Session summary written via SDK`,{sessionId:e})}catch(t){i.warning(`SDK prompt writeback failed`,{sessionId:e,error:r(t)})}}async function xs(e){let{bootstrapLogger:t,reactionCtx:n,githubClient:r,agentSuccess:o,attachmentResult:s,serverHandle:c,detectedOpencodeVersion:l}=e;try{if(s!=null){let e=i({phase:`attachment-cleanup`});await Go(s.tempFiles,e)}n!=null&&r!=null&&await dr(r,n,o,i({phase:`cleanup`}));let e=i({phase:`prune`}),t=re();if(c!=null){let n=J(t),r=await ps(c.client,n,fs,e);r.prunedCount>0&&e.info(`Pruned old sessions`,{pruned:r.prunedCount,remaining:r.remainingCount})}let u=ne(),d=i({phase:`cache-save`}),f=L.join(t,`.git`,`opencode`);await de({components:u,runId:D(),logger:d,storagePath:k(),authPath:fe(),projectIdPath:f,opencodeVersion:l})&&a(_.CACHE_SAVED,`true`)}catch(e){t.warning(`Cleanup failed (non-fatal)`,{error:e instanceof Error?e.message:String(e)})}finally{if(c!=null)try{c.shutdown()}catch(e){t.warning(`Server shutdown failed (non-fatal)`,{error:e instanceof Error?e.message:String(e)})}}}const Ss=L.join(Ne.homedir(),`.cache`,`fro-bot-dedup`);function Cs(e){return e.replaceAll(`/`,`-`)}function ws(e,t){let n=Cs(e);return L.join(Ss,`${n}-${t.entityType}-${t.entityNumber}`)}function Ts(e,t){return`${ee}-${Cs(e)}-${t.entityType}-${t.entityNumber}-`}function Es(e,t,n){return`${Ts(e,t)}${n}`}async function Ds(e,t,n,i=le){let a=ws(e,t),o=L.join(a,`sentinel.json`),s=Ts(e,t);try{if(await I.rm(a,{recursive:!0,force:!0}),await I.mkdir(a,{recursive:!0}),await i.restoreCache([a],s,[])==null)return null;let e=await I.readFile(o,`utf8`);return JSON.parse(e)}catch(e){return n.debug(`Dedup marker restore failed; proceeding without marker`,{error:r(e),entityType:t.entityType,entityNumber:t.entityNumber}),null}}async function Os(e,t,n,i,a=le){let o=ws(e,t),s=L.join(o,`sentinel.json`),c=Es(e,t,n.runId);try{return await I.mkdir(o,{recursive:!0}),await I.writeFile(s,JSON.stringify(n),`utf8`),await a.saveCache([o],c),!0}catch(e){return r(e).toLowerCase().includes(`already exists`)?!0:(i.debug(`Dedup marker save failed`,{error:r(e),entityType:t.entityType,entityNumber:t.entityNumber,saveKey:c}),!1)}}const ks=new Set([`pull_request`,`issues`]);function As(e){return e.target==null||!ks.has(e.eventType)?null:e.eventType===`pull_request`&&e.target.kind===`pr`?{entityType:`pr`,entityNumber:e.target.number}:e.eventType===`issues`&&e.target.kind===`issue`?{entityType:`issue`,entityNumber:e.target.number}:null}async function js(e,t,n,r,a=i({phase:`dedup`}),o){let s=As(t);if(e===0)return{shouldProceed:!0,entity:s};if(s==null)return{shouldProceed:!0,entity:null};let c=await Ds(n,s,a,o);if(c==null||c.runId===t.runId)return{shouldProceed:!0,entity:s};let l=new Date(c.timestamp).getTime();if(Number.isNaN(l))return a.warning(`Dedup marker timestamp is invalid; proceeding without dedup`,{markerTimestamp:c.timestamp}),{shouldProceed:!0,entity:s};let u=Date.now()-l;return u<-6e4?(a.warning(`Dedup marker timestamp is too far in the future; proceeding without dedup`,{markerTimestamp:c.timestamp,markerAge:u}),{shouldProceed:!0,entity:s}):Math.max(0,u)>e?{shouldProceed:!0,entity:s}:(a.info(`Skipping duplicate trigger within dedup window`,{eventType:t.eventType,action:t.action,runId:t.runId,markerRunId:c.runId,markerTimestamp:c.timestamp,dedupWindow:e,entityType:s.entityType,entityNumber:s.entityNumber}),Be({sessionId:null,cacheStatus:`miss`,duration:Date.now()-r}),{shouldProceed:!1,entity:s})}async function Ms(e,t,n,r=i({phase:`dedup`}),a){await Os(n,t,{timestamp:new Date().toISOString(),runId:e.runId,action:e.action??`unknown`,eventType:e.eventType,entityType:t.entityType,entityNumber:t.entityNumber},r,a)}async function Ns(e,t,n,r,o,s){let c={context:t.agentContext,customPrompt:e.inputs.prompt,cacheStatus:n.cacheStatus,sessionContext:{recentSessions:r.recentSessions,priorWorkContext:r.priorWorkContext},logicalKey:r.logicalKey??null,isContinuation:r.isContinuation,currentThreadSessionId:r.continueSessionId??null,triggerContext:t.triggerResult.context,fileParts:r.attachmentResult?.fileParts},l=N.env.SKIP_AGENT_EXECUTION===`true`,u=Date.now(),d;if(l)e.logger.info(`Skipping agent execution (SKIP_AGENT_EXECUTION=true)`),d={success:!0,exitCode:0,sessionId:null,error:null,tokenUsage:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null};else{let t=i({phase:`execution`});t.info(`Starting OpenCode execution`,{logicalKey:r.logicalKey?.key??null,continueSessionId:r.continueSessionId});let a=await nr(c,t,{agent:e.inputs.agent,model:e.inputs.model,timeoutMs:e.inputs.timeoutMs,omoProviders:e.inputs.omoProviders,continueSessionId:r.continueSessionId??void 0,sessionTitle:r.sessionTitle??void 0},n.serverHandle),o=a.sessionId;if(o==null){let e=i({phase:`session`}),t=await us(n.serverHandle.client,r.normalizedWorkspace,u,e);t!=null&&(o=t.session.id,e.debug(`Identified session from execution`,{sessionId:o}))}d={...a,sessionId:o},t.info(`Completed OpenCode execution`,{success:d.success,sessionId:d.sessionId,logicalKey:r.logicalKey?.key??null})}d.sessionId!=null&&(a(_.SESSION_ID,d.sessionId),o.addSessionCreated(d.sessionId)),d.tokenUsage!=null&&o.setTokenUsage(d.tokenUsage,d.model,d.cost);for(let e of d.prsCreated)o.addPRCreated(e);for(let e of d.commitsCreated)o.addCommitCreated(e);for(let e=0;e`)}async function Is(e,t,n){try{if(t.type===`pr`){let{data:n}=await e.rest.pulls.get({owner:t.owner,repo:t.repo,pull_number:t.number});return{title:n.title,body:n.body??``,author:n.user?.login??`unknown`}}let{data:n}=await e.rest.issues.get({owner:t.owner,repo:t.repo,issue_number:t.number});return{title:n.title,body:n.body??``,author:n.user?.login??`unknown`}}catch(e){return n.warning(`Failed to fetch issue/PR`,{target:t,error:r(e)}),null}}async function Ls(e,t,n,i){let a=[],o=1;for(;o<=50;)try{let{data:r}=await e.rest.issues.listComments({owner:t.owner,repo:t.repo,issue_number:t.number,per_page:100,page:o});if(r.length===0)break;for(let e of r){let t=e.user?.login??`unknown`;a.push({id:e.id,body:e.body??``,author:t,authorAssociation:e.author_association??`NONE`,createdAt:e.created_at,updatedAt:e.updated_at,isBot:Fs(t,e.body??``,n)})}if(r.length<100)break;o++}catch(e){i.warning(`Failed to fetch comments page`,{target:t,page:o,error:r(e)});break}return a}async function Rs(e,t,n,i){try{let r=[],a=null,o=null,s=``,c=``,l=`unknown`,u=0;for(;u<50;){let d=(await e.graphql(` query GetDiscussion($owner: String!, $repo: String!, $number: Int!, $after: String) { repository(owner: $owner, name: $repo) { discussion(number: $number) { @@ -287,7 +287,7 @@ If you had completed the task, confirm the completion.`,d=i===1?e.fileParts:void } } } -`,{owner:t.owner,repo:t.repo,number:t.number,after:a})).repository.discussion;if(d==null)return i.debug(`Discussion not found`,{target:t}),null;u===0&&(o=d.id,s=d.title,c=d.body,l=d.author?.login??`unknown`);for(let e of d.comments.nodes){let t=e.author?.login??`unknown`;r.push({id:e.id,body:e.body,author:t,authorAssociation:`NONE`,createdAt:e.createdAt,updatedAt:e.updatedAt,isBot:Ps(t,e.body,n)})}if(!d.comments.pageInfo.hasNextPage)break;a=d.comments.pageInfo.endCursor,u++}return{type:`discussion`,number:t.number,title:s,body:c,author:l,comments:r,discussionId:o??void 0}}catch(e){return i.warning(`Failed to fetch discussion`,{target:t,error:r(e)}),null}}async function Rs(e,t,n,r){if(t.type===`discussion`)return Ls(e,t,n,r);let i=await Fs(e,t,r);if(i==null)return null;let a=await Is(e,t,n,r);return{type:t.type,number:t.number,title:i.title,body:i.body,author:i.author,comments:a}}function zs(e,t){let n=e.comments.filter(e=>Ns(e.author,t)&&e.body.includes(``));return n.length===0?null:n.at(-1)??null}async function Bs(e,t,n,i){try{let{data:r}=await e.rest.issues.createComment({owner:t.owner,repo:t.repo,issue_number:t.number,body:n});return i.debug(`Created issue comment`,{commentId:r.id,target:t}),{commentId:r.id,created:!0,updated:!1,url:r.html_url}}catch(e){return i.warning(`Failed to create issue comment`,{target:t,error:r(e)}),null}}async function Vs(e,t,n,i,a){try{let{data:r}=await e.rest.issues.updateComment({owner:t.owner,repo:t.repo,comment_id:n,body:i});return a.debug(`Updated issue comment`,{commentId:r.id,target:t}),{commentId:r.id,created:!1,updated:!0,url:r.html_url}}catch(e){return a.warning(`Failed to update issue comment`,{target:t,commentId:n,error:r(e)}),null}}async function Hs(e,t,n,i){try{let r=(await e.graphql(` +`,{owner:t.owner,repo:t.repo,number:t.number,after:a})).repository.discussion;if(d==null)return i.debug(`Discussion not found`,{target:t}),null;u===0&&(o=d.id,s=d.title,c=d.body,l=d.author?.login??`unknown`);for(let e of d.comments.nodes){let t=e.author?.login??`unknown`;r.push({id:e.id,body:e.body,author:t,authorAssociation:`NONE`,createdAt:e.createdAt,updatedAt:e.updatedAt,isBot:Fs(t,e.body,n)})}if(!d.comments.pageInfo.hasNextPage)break;a=d.comments.pageInfo.endCursor,u++}return{type:`discussion`,number:t.number,title:s,body:c,author:l,comments:r,discussionId:o??void 0}}catch(e){return i.warning(`Failed to fetch discussion`,{target:t,error:r(e)}),null}}async function zs(e,t,n,r){if(t.type===`discussion`)return Rs(e,t,n,r);let i=await Is(e,t,r);if(i==null)return null;let a=await Ls(e,t,n,r);return{type:t.type,number:t.number,title:i.title,body:i.body,author:i.author,comments:a}}function Bs(e,t){let n=e.comments.filter(e=>Ps(e.author,t)&&e.body.includes(``));return n.length===0?null:n.at(-1)??null}async function Vs(e,t,n,i){try{let{data:r}=await e.rest.issues.createComment({owner:t.owner,repo:t.repo,issue_number:t.number,body:n});return i.debug(`Created issue comment`,{commentId:r.id,target:t}),{commentId:r.id,created:!0,updated:!1,url:r.html_url}}catch(e){return i.warning(`Failed to create issue comment`,{target:t,error:r(e)}),null}}async function Hs(e,t,n,i,a){try{let{data:r}=await e.rest.issues.updateComment({owner:t.owner,repo:t.repo,comment_id:n,body:i});return a.debug(`Updated issue comment`,{commentId:r.id,target:t}),{commentId:r.id,created:!1,updated:!0,url:r.html_url}}catch(e){return a.warning(`Failed to update issue comment`,{target:t,commentId:n,error:r(e)}),null}}async function Us(e,t,n,i){try{let r=(await e.graphql(` query GetDiscussionId($owner: String!, $repo: String!, $number: Int!) { repository(owner: $owner, name: $repo) { discussion(number: $number) { @@ -308,7 +308,7 @@ If you had completed the task, confirm the completion.`,d=i===1?e.fileParts:void } } } -`,{owner:t.owner,repo:t.repo,number:t.number})).repository.discussion;if(r==null)return i.warning(`Discussion not found`,{target:t}),null;if(n.updateExisting===!0&&n.botLogin!=null){let r=await Rs(e,t,n.botLogin,i);if(r!=null){let t=zs(r,n.botLogin);if(t!=null&&typeof t.id==`string`){let r=await e.graphql(` +`,{owner:t.owner,repo:t.repo,number:t.number})).repository.discussion;if(r==null)return i.warning(`Discussion not found`,{target:t}),null;if(n.updateExisting===!0&&n.botLogin!=null){let r=await zs(e,t,n.botLogin,i);if(r!=null){let t=Bs(r,n.botLogin);if(t!=null&&typeof t.id==`string`){let r=await e.graphql(` mutation UpdateDiscussionComment($commentId: ID!, $body: String!) { updateDiscussionComment(input: {commentId: $commentId, body: $body}) { comment { id url } @@ -320,4 +320,4 @@ If you had completed the task, confirm the completion.`,d=i===1?e.fileParts:void comment { id url } } } -`,{discussionId:r.id,body:n.body});return i.debug(`Created discussion comment`,{discussionId:r.id}),{commentId:a.addDiscussionComment.comment.id,created:!0,updated:!1,url:a.addDiscussionComment.comment.url}}catch(e){return i.warning(`Failed to post discussion comment`,{target:t,error:r(e)}),null}}async function Us(e,t,n,r){if(t.type===`discussion`)return Hs(e,t,n,r);if(n.updateExisting===!0&&n.botLogin!=null){let i=await Rs(e,t,n.botLogin,r);if(i!=null){let a=zs(i,n.botLogin);if(a!=null&&typeof a.id==`number`)return Vs(e,t,a.id,n.body,r)}}return Bs(e,t,n.body,r)}async function Ws(e,t,n,r,a,o,s){let l=Date.now()-o;if(Be({sessionId:r.sessionId,cacheStatus:n.cacheStatus,duration:l}),await Re({eventType:t.agentContext.eventName,repo:t.agentContext.repo,ref:t.agentContext.ref,runId:Number(t.agentContext.runId),runUrl:`https://github.com/${t.agentContext.repo}/actions/runs/${t.agentContext.runId}`,metrics:a.getMetrics(),agent:e.inputs.agent},s),r.success)return s.info(`Agent run completed successfully`,{durationMs:l}),0;if(r.llmError==null)return c(`Agent execution failed with exit code ${r.exitCode}`),r.exitCode;s.info(`Agent failed with recoverable LLM error`,{error:r.llmError.message,type:r.llmError.type,durationMs:l});let[u,d]=t.agentContext.repo.split(`/`),f={type:t.triggerResult.context.eventType===`discussion_comment`?`discussion`:t.agentContext.issueType===`pr`?`pr`:`issue`,number:t.agentContext.issueNumber??0,owner:u??``,repo:d??``};if(f.number>0&&f.owner.length>0&&f.repo.length>0){let e=gn(r.llmError),n=i({phase:`error-comment`}),o=await Us(t.githubClient,f,{body:e},n);o==null?n.warning(`Failed to post LLM error comment`):(n.info(`Posted LLM error comment`,{commentUrl:o.url}),a.incrementComments())}else s.warning(`Cannot post error comment: missing target context`);return 0}function Gs(e){switch(e){case`issue_comment`:return`issue_comment`;case`discussion`:case`discussion_comment`:return`discussion_comment`;case`workflow_dispatch`:return`workflow_dispatch`;case`issues`:return`issues`;case`pull_request`:return`pull_request`;case`pull_request_review_comment`:return`pull_request_review_comment`;case`schedule`:return`schedule`;default:return`unsupported`}}function Ks(e,t){switch(e){case`issue_comment`:{let e=t;return{type:`issue_comment`,action:e.action,issue:{number:e.issue.number,title:e.issue.title,body:e.issue.body??null,locked:e.issue.locked??!1,isPullRequest:e.issue.pull_request!=null},comment:{id:e.comment.id,body:e.comment.body,author:e.comment.user.login,authorAssociation:e.comment.author_association??`NONE`}}}case`discussion_comment`:{let e=t;return{type:`discussion_comment`,action:e.action,discussion:{number:e.discussion.number,title:e.discussion.title,body:e.discussion.body??null,locked:e.discussion.locked??!1},comment:{id:e.comment.id,body:e.comment.body??null,author:e.comment.user.login,authorAssociation:e.comment.author_association??`NONE`}}}case`issues`:{let e=t;return{type:`issues`,action:e.action,issue:{number:e.issue.number,title:e.issue.title,body:e.issue.body??null,locked:e.issue.locked??!1,authorAssociation:e.issue.author_association??`NONE`},sender:{login:e.sender.login}}}case`pull_request`:{let e=t,n=e.pull_request.requested_reviewers??[],r=`requested_reviewer`in e&&e.requested_reviewer!=null?{login:e.requested_reviewer.login,type:e.requested_reviewer.type}:null,i=`requested_team`in e&&e.requested_team!=null?{name:e.requested_team.name,slug:e.requested_team.slug}:null,a=n.flatMap(e=>`login`in e&&`type`in e?[{login:e.login,type:e.type}]:[]);return{type:`pull_request`,action:e.action,requestedReviewer:r,requestedTeam:i,pullRequest:{number:e.pull_request.number,title:e.pull_request.title,body:e.pull_request.body??null,locked:e.pull_request.locked??!1,draft:e.pull_request.draft??!1,authorAssociation:e.pull_request.author_association??`NONE`,requestedReviewers:a},sender:{login:e.sender.login}}}case`pull_request_review_comment`:{let e=t;return{type:`pull_request_review_comment`,action:e.action,pullRequest:{number:e.pull_request.number,title:e.pull_request.title,locked:e.pull_request.locked??!1},comment:{id:e.comment.id,body:e.comment.body,author:e.comment.user.login,authorAssociation:e.comment.author_association,path:e.comment.path,line:e.comment.line??null,diffHunk:e.comment.diff_hunk,commitId:e.comment.commit_id}}}case`workflow_dispatch`:return{type:`workflow_dispatch`,inputs:{prompt:t.inputs?.prompt??void 0}};case`schedule`:return{type:`schedule`,schedule:t.schedule??void 0};case`unsupported`:return{type:`unsupported`}}}function qs(e){let t=fa,n=Gs(t.eventName),r=Ks(n,t.payload);return e.debug(`Parsed GitHub context`,{eventName:t.eventName,eventType:n,repo:`${t.repo.owner}/${t.repo.repo}`}),{eventName:t.eventName,eventType:n,repo:t.repo,ref:t.ref,sha:t.sha,runId:t.runId,actor:t.actor,payload:t.payload,event:r}}function Js(e,t){return t.includes(e)}function X(e){return e.endsWith(`[bot]`)}function Ys(e,t){if(t.length===0)return!1;let n=t.replace(/\[bot\]$/i,``);return n.length===0?!1:new RegExp(String.raw`@${Xs(n)}(?:\[bot\])?(?:$|[^\w])`,`i`).test(e)}function Xs(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function Zs(e,t){if(t.length===0)return null;let n=t.replace(/\[bot\]$/i,``);if(n.length===0)return null;let r=new RegExp(String.raw`@${Xs(n)}(?:\[bot\])?\s*(.*)`,`is`).exec(e)?.[1];if(r==null)return null;let i=r.trim();if(i.length===0)return{raw:``,action:null,args:``};let a=i.split(/\s+/),o=a[0]??``;return{raw:i,action:o===``?null:o,args:a.slice(1).join(` `)}}function Z(e,t){if(t==null||t===``||e==null)return{hasMention:!1,command:null};let n=Ys(e,t);return{hasMention:n,command:n?Zs(e,t):null}}function Qs(e,t){if(e.type!==`issue_comment`)throw Error(`Event type must be issue_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r={kind:e.issue.isPullRequest?`pr`:`issue`,number:e.issue.number,title:e.issue.title,body:e.comment.body??null,locked:e.issue.locked},{hasMention:i,command:a}=Z(e.comment.body,t);return{action:e.action,author:n,target:r,commentBody:e.comment.body,commentId:e.comment.id,hasMention:i,command:a,isBotReviewRequested:!1}}function $s(e,t){if(e.type!==`discussion_comment`)throw Error(`Event type must be discussion_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r=e.comment.body??null,i={kind:`discussion`,number:e.discussion.number,title:e.discussion.title,body:r??e.discussion.body??null,locked:e.discussion.locked},{hasMention:a,command:o}=Z(r,t);return{action:e.action,author:n,target:i,commentBody:r,commentId:e.comment.id,hasMention:a,command:o,isBotReviewRequested:!1}}function ec(e,t){if(e.type!==`pull_request_review_comment`)throw Error(`Event type must be pull_request_review_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r={kind:`pr`,number:e.pullRequest.number,title:e.pullRequest.title,body:e.comment.body,locked:e.pullRequest.locked,path:e.comment.path,line:e.comment.line??void 0,diffHunk:e.comment.diffHunk,commitId:e.comment.commitId},{hasMention:i,command:a}=Z(e.comment.body,t);return{action:e.action,author:n,target:r,commentBody:e.comment.body,commentId:e.comment.id,hasMention:i,command:a,isBotReviewRequested:!1}}function tc(e,t,n){if(e.type!==`workflow_dispatch`)throw Error(`Event type must be workflow_dispatch`);let r=(n??e.inputs?.prompt??``).trim();return{action:null,author:{login:t,association:`OWNER`,isBot:!1},target:{kind:`manual`,number:0,title:`Manual workflow dispatch`,body:r===``?null:r,locked:!1},commentBody:r===``?null:r,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}function nc(e,t,n){let r=n?.trim()??``;return{action:null,author:{login:t,association:`OWNER`,isBot:!1},target:{kind:`manual`,number:0,title:`Scheduled workflow`,body:r===``?null:r,locked:!1},commentBody:r===``?null:r,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}function rc(e){return e.toLowerCase().replace(/\[bot\]$/i,``)}function ic(e,t){if(e.type!==`pull_request`||t==null||t===``)return!1;let n=rc(t);if(n===``)return!1;if(e.action===`review_requested`){let t=e.requestedReviewer?.login;return t!=null&&rc(t)===n}return e.action===`ready_for_review`?e.pullRequest.requestedReviewers.some(e=>rc(e.login)===n):!1}function ac(e,t){if(e.type!==`issues`)throw Error(`Event type must be issues`);let n={login:e.sender.login,association:e.issue.authorAssociation,isBot:X(e.sender.login)},r={kind:`issue`,number:e.issue.number,title:e.issue.title,body:e.issue.body,locked:e.issue.locked},{hasMention:i,command:a}=Z(e.issue.body??``,t);return{action:e.action,author:n,target:r,commentBody:e.issue.body,commentId:null,hasMention:i,command:a,isBotReviewRequested:!1}}function oc(e,t){if(e.type!==`pull_request`)throw Error(`Event type must be pull_request`);let n={login:e.sender.login,association:e.pullRequest.authorAssociation,isBot:X(e.sender.login)},r={kind:`pr`,number:e.pullRequest.number,title:e.pullRequest.title,body:e.pullRequest.body,locked:e.pullRequest.locked,isDraft:e.pullRequest.draft,requestedReviewerLogin:e.requestedReviewer?.login,requestedTeamSlug:e.requestedTeam?.slug,requestedReviewerLogins:e.pullRequest.requestedReviewers.map(e=>e.login)},{hasMention:i,command:a}=Z(e.pullRequest.body??``,t);return{action:e.action,author:n,target:r,commentBody:e.pullRequest.body,commentId:null,hasMention:i,command:a,isBotReviewRequested:ic(e,t)}}function Q(e,t){return{...e,action:t.action,author:t.author,target:t.target,commentBody:t.commentBody,commentId:t.commentId,hasMention:t.hasMention,command:t.command,isBotReviewRequested:t.isBotReviewRequested}}function sc(e,t,n){let r={eventType:e.eventType,eventName:e.eventName,repo:e.repo,ref:e.ref,sha:e.sha,runId:e.runId,actor:e.actor,raw:e};switch(e.eventType){case`issue_comment`:return Q(r,Qs(e.event,t));case`discussion_comment`:return Q(r,$s(e.event,t));case`workflow_dispatch`:return Q(r,tc(e.event,e.actor,n));case`issues`:return Q(r,ac(e.event,t));case`pull_request`:return Q(r,oc(e.event,t));case`pull_request_review_comment`:return Q(r,ec(e.event,t));case`schedule`:return Q(r,nc(e.event,e.actor,n));case`unsupported`:return{...r,action:null,author:null,target:null,commentBody:null,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}}function cc(e,t,n){let{targetLabel:r,actionLabel:i}=n;return e.action===`created`?e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`${r} is locked`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Comments from bots (${e.author.login}) are not processed`}:e.author!=null&&!Js(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.requireMention&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Comment does not mention the bot`}:{shouldSkip:!1}:{shouldSkip:!0,reason:`action_not_created`,message:`${i} action is '${e.action}', not 'created'`}}function lc(e,t){return cc(e,t,{targetLabel:`Issue or PR`,actionLabel:`Comment`})}function uc(e,t){return cc(e,t,{targetLabel:`Discussion`,actionLabel:`Discussion comment`})}const dc=[`opened`,`edited`];function fc(e){return dc.includes(e)}function pc(e,t){let n=e.action;return n==null||!fc(n)?{shouldSkip:!0,reason:`action_not_supported`,message:`Issues action '${n}' is not supported (only 'opened' and 'edited')`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Issues from bots (${e.author.login}) are not processed`}:e.author!=null&&!Js(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:n===`edited`&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Issue edit does not mention the bot`}:e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Issue is locked`}:{shouldSkip:!1}}function mc(e){return(e.promptInput?.trim()??``)===``?{shouldSkip:!0,reason:`prompt_required`,message:`Schedule trigger requires prompt input`}:{shouldSkip:!1}}function hc(e){return(e.commentBody?.trim()??``)===``?{shouldSkip:!0,reason:`prompt_required`,message:`Workflow dispatch requires prompt input`}:{shouldSkip:!1}}const gc=[`opened`,`synchronize`,`reopened`,`ready_for_review`,`review_requested`];function _c(e){return gc.includes(e)}function vc(e,t){let n=e.action;return n==null||!_c(n)?{shouldSkip:!0,reason:`action_not_supported`,message:`Pull request action '${n}' is not supported`}:e.action!==`review_requested`&&e.action!==`ready_for_review`&&e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Pull requests from bots (${e.author.login}) are not processed`}:e.author!=null&&!Js(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.skipDraftPRs&&e.target?.isDraft===!0?{shouldSkip:!0,reason:`draft_pr`,message:`Pull request is a draft`}:e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Pull request is locked`}:t.botLogin!=null&&t.botLogin!==``&&(e.action===`ready_for_review`||e.action===`review_requested`)&&e.isBotReviewRequested!==!0?{shouldSkip:!0,reason:`bot_not_requested`,message:`Pull request action '${e.action}' did not request review from the bot`}:{shouldSkip:!1}}function yc(e,t){let n=e.action;return n===`created`?e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Pull request is locked`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Review comments from bots (${e.author.login}) are not processed`}:e.author!=null&&!Js(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.requireMention&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Review comment does not mention the bot`}:{shouldSkip:!1}:{shouldSkip:!0,reason:`action_not_created`,message:`Review comment action '${n}' is not supported (only 'created')`}}function bc(e){return{shouldSkip:!0,reason:`unsupported_event`,message:`Unsupported event type: ${e}`}}function xc(e,t,n){if(e.eventType===`unsupported`)return n.debug(`Skipping unsupported event`,{eventName:e.eventName}),bc(e.eventName);switch(e.eventType){case`issue_comment`:return lc(e,t);case`discussion_comment`:return uc(e,t);case`issues`:return pc(e,t);case`pull_request`:return vc(e,t);case`pull_request_review_comment`:return yc(e,t);case`schedule`:return mc(t);case`workflow_dispatch`:return hc(e);default:return{shouldSkip:!1}}}const Sc={botLogin:null,requireMention:!0,allowedAssociations:yo,skipDraftPRs:!0,promptInput:null,senderAssociation:null};function Cc(e,t,n={}){let r={...Sc,...n},i=sc(e,r.botLogin,r.promptInput);r.senderAssociation!=null&&(i.action===`review_requested`||i.action===`ready_for_review`)&&i.author!=null&&(i={...i,author:{...i.author,association:r.senderAssociation}}),t.debug(`Routing event`,{eventName:e.eventName,eventType:e.eventType,hasMention:i.hasMention});let a=xc(i,r,t);return a.shouldSkip?{shouldProcess:!1,skipReason:a.reason,skipMessage:a.message,context:i}:{shouldProcess:!0,context:i}}async function wc(e,t){let n=i({phase:`context`}),r=qs(n),o=Wa({token:e.inputs.githubToken,logger:n}),s=await Ga(o,n),c=null;if(r.event.type===`pull_request`&&(r.event.action===`review_requested`||r.event.action===`ready_for_review`)){let{owner:e,repo:t}=r.repo;c=await Ye(o,e,t,r.event.sender.login,n)}let l=i({phase:`trigger`}),u=Cc(r,l,{botLogin:s,requireMention:!0,promptInput:e.inputs.prompt,senderAssociation:c});return u.shouldProcess?(l.info(`Event routed for processing`,{eventType:u.context.eventType,hasMention:u.context.hasMention,command:u.context.command?.action??null}),a(_.SHOULD_SAVE_CACHE,`true`),{githubClient:o,triggerResult:u,agentContext:await pt({logger:n,octokit:o,triggerContext:u.context,botLogin:s}),botLogin:s}):(l.info(`Skipping event`,{reason:u.skipReason,message:u.skipMessage}),Be({sessionId:null,cacheStatus:`miss`,duration:Date.now()-t}),null)}function $(e,t){return{key:`${e}-${t}`,entityType:e,entityId:t}}function Tc(e){return Ee(`sha256`).update(e).digest(`hex`).slice(0,8)}function Ec(e){if(e.eventType===`unsupported`)return null;if(e.eventType===`schedule`){let t=e.raw.event.type===`schedule`?e.raw.event.schedule:void 0;return $(`schedule`,Tc((t!=null&&t.trim().length>0?t:e.action)??`default`))}return e.eventType===`workflow_dispatch`?$(`dispatch`,String(e.runId)):e.target==null?null:e.eventType===`issue_comment`?e.target.kind===`issue`?$(`issue`,String(e.target.number)):e.target.kind===`pr`?$(`pr`,String(e.target.number)):null:e.eventType===`discussion_comment`?e.target.kind===`discussion`?$(`discussion`,String(e.target.number)):null:e.eventType===`issues`?e.target.kind===`issue`?$(`issue`,String(e.target.number)):null:(e.eventType===`pull_request`||e.eventType===`pull_request_review_comment`)&&e.target.kind===`pr`?$(`pr`,String(e.target.number)):null}function Dc(e){return`fro-bot: ${e.key}`}function Oc(e,t){let n=e.filter(e=>e.title===t);return n.length===0?null:n.reduce((e,t)=>t.time.updated>e.time.updated?t:e)}async function kc(e,t,n,r){try{let i=Oc(await ss(e,t,r),Dc(n));return i==null||i.time.archived!=null||i.time.compacting!=null?{status:`not-found`}:{status:`found`,session:i}}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}async function Ac(e,t,n,r){let a=i({phase:`session`}),o=J(re()),s=await ps(n.serverHandle.client,o,{limit:10},a);a.debug(`Listed recent sessions`,{count:s.length});let c=Ec(t.triggerResult.context),l=c==null?null:Dc(c),u=null,d=!1;if(c!=null){let e=await kc(n.serverHandle.client,o,c,a);e.status===`found`?(u=e.session.id,d=!0,a.info(`Session continuity: found existing session`,{logicalKey:c.key,sessionId:u})):e.status===`error`?a.warning(`Session continuity: lookup error, will create new`,{logicalKey:c.key,error:e.error}):a.info(`Session continuity: no existing session found`,{logicalKey:c.key})}let f=c?.key??t.agentContext.issueTitle??t.agentContext.repo,p=await hs(f,n.serverHandle.client,o,{limit:5},a);a.debug(`Searched prior sessions`,{query:f,resultCount:p.length});for(let e of p)r.addSessionUsed(e.sessionId);let m=i({phase:`attachments`}),h=t.agentContext.commentBody??``,g=Ro(h),_=null;if(g.length>0){m.info(`Processing attachments`,{count:g.length});let{validated:t,skipped:n}=Yo(await Uo(g,e.inputs.githubToken,void 0,m),void 0,m);(t.length>0||n.length>0)&&(_=qo(h,g,t,n),m.info(`Attachments processed`,{processed:t.length,skipped:n.length}))}return{recentSessions:s,priorWorkContext:p,attachmentResult:_,normalizedWorkspace:o,logicalKey:c,continueSessionId:u,isContinuation:d,sessionTitle:l}}async function jc(){let e=Date.now(),t=i({phase:`bootstrap`}),n=ze();n.start();let r=null,o=!1,s=0,l=null,u=null,d=null,f=null;a(_.SHOULD_SAVE_CACHE,`false`),a(_.CACHE_SAVED,`false`);try{t.info(`Starting Fro Bot Agent`);let i=await jo(t);if(i==null)return 1;d=i.opencodeResult.version;let a=await wc(i,e);if(a==null)return 0;l=a.githubClient;let c=`${a.triggerResult.context.repo.owner}/${a.triggerResult.context.repo.repo}`,p=await As(i.inputs.dedupWindow,a.triggerResult.context,c,e);if(!p.shouldProceed)return 0;r=await Co(a,i.logger);let m=await Fo(i);if(m==null)return 1;f=m.serverHandle,n.setCacheStatus(m.cacheStatus);let h=await Ac(i,a,m,n);u=h.attachmentResult;let g=await Ms(i,a,m,h,n,e);o=g.success,o&&p.entity!=null&&await js(a.triggerResult.context,p.entity,c),n.end(),s=await Ws(i,a,m,g,n,e,i.logger)}catch(r){s=1;let i=Date.now()-e,a=r instanceof Error?r.name:`UnknownError`,o=r instanceof Error?r.message:String(r);n.recordError(a,o,!1),n.end(),Be({sessionId:null,cacheStatus:`miss`,duration:i}),r instanceof Error?(t.error(`Agent failed`,{error:r.message}),c(r.message)):(t.error(`Agent failed with unknown error`),c(`An unknown error occurred`))}finally{await bs({bootstrapLogger:t,reactionCtx:r,githubClient:l,agentSuccess:o,attachmentResult:u,serverHandle:f,detectedOpencodeVersion:d})}return s}await jc().then(e=>{N.exit(e)});export{}; \ No newline at end of file +`,{discussionId:r.id,body:n.body});return i.debug(`Created discussion comment`,{discussionId:r.id}),{commentId:a.addDiscussionComment.comment.id,created:!0,updated:!1,url:a.addDiscussionComment.comment.url}}catch(e){return i.warning(`Failed to post discussion comment`,{target:t,error:r(e)}),null}}async function Ws(e,t,n,r){if(t.type===`discussion`)return Us(e,t,n,r);if(n.updateExisting===!0&&n.botLogin!=null){let i=await zs(e,t,n.botLogin,r);if(i!=null){let a=Bs(i,n.botLogin);if(a!=null&&typeof a.id==`number`)return Hs(e,t,a.id,n.body,r)}}return Vs(e,t,n.body,r)}async function Gs(e,t,n,r,a,o,s){let l=Date.now()-o;if(Be({sessionId:r.sessionId,cacheStatus:n.cacheStatus,duration:l}),await Re({eventType:t.agentContext.eventName,repo:t.agentContext.repo,ref:t.agentContext.ref,runId:Number(t.agentContext.runId),runUrl:`https://github.com/${t.agentContext.repo}/actions/runs/${t.agentContext.runId}`,metrics:a.getMetrics(),agent:e.inputs.agent},s),r.success)return s.info(`Agent run completed successfully`,{durationMs:l}),0;if(r.llmError==null)return c(`Agent execution failed with exit code ${r.exitCode}`),r.exitCode;s.info(`Agent failed with recoverable LLM error`,{error:r.llmError.message,type:r.llmError.type,durationMs:l});let[u,d]=t.agentContext.repo.split(`/`),f={type:t.triggerResult.context.eventType===`discussion_comment`?`discussion`:t.agentContext.issueType===`pr`?`pr`:`issue`,number:t.agentContext.issueNumber??0,owner:u??``,repo:d??``};if(f.number>0&&f.owner.length>0&&f.repo.length>0){let e=vn(r.llmError),n=i({phase:`error-comment`}),o=await Ws(t.githubClient,f,{body:e},n);o==null?n.warning(`Failed to post LLM error comment`):(n.info(`Posted LLM error comment`,{commentUrl:o.url}),a.incrementComments())}else s.warning(`Cannot post error comment: missing target context`);return 0}function Ks(e){switch(e){case`issue_comment`:return`issue_comment`;case`discussion`:case`discussion_comment`:return`discussion_comment`;case`workflow_dispatch`:return`workflow_dispatch`;case`issues`:return`issues`;case`pull_request`:return`pull_request`;case`pull_request_review_comment`:return`pull_request_review_comment`;case`schedule`:return`schedule`;default:return`unsupported`}}function qs(e,t){switch(e){case`issue_comment`:{let e=t;return{type:`issue_comment`,action:e.action,issue:{number:e.issue.number,title:e.issue.title,body:e.issue.body??null,locked:e.issue.locked??!1,isPullRequest:e.issue.pull_request!=null},comment:{id:e.comment.id,body:e.comment.body,author:e.comment.user.login,authorAssociation:e.comment.author_association??`NONE`}}}case`discussion_comment`:{let e=t;return{type:`discussion_comment`,action:e.action,discussion:{number:e.discussion.number,title:e.discussion.title,body:e.discussion.body??null,locked:e.discussion.locked??!1},comment:{id:e.comment.id,body:e.comment.body??null,author:e.comment.user.login,authorAssociation:e.comment.author_association??`NONE`}}}case`issues`:{let e=t;return{type:`issues`,action:e.action,issue:{number:e.issue.number,title:e.issue.title,body:e.issue.body??null,locked:e.issue.locked??!1,authorAssociation:e.issue.author_association??`NONE`},sender:{login:e.sender.login}}}case`pull_request`:{let e=t,n=e.pull_request.requested_reviewers??[],r=`requested_reviewer`in e&&e.requested_reviewer!=null?{login:e.requested_reviewer.login,type:e.requested_reviewer.type}:null,i=`requested_team`in e&&e.requested_team!=null?{name:e.requested_team.name,slug:e.requested_team.slug}:null,a=n.flatMap(e=>`login`in e&&`type`in e?[{login:e.login,type:e.type}]:[]);return{type:`pull_request`,action:e.action,requestedReviewer:r,requestedTeam:i,pullRequest:{number:e.pull_request.number,title:e.pull_request.title,body:e.pull_request.body??null,locked:e.pull_request.locked??!1,draft:e.pull_request.draft??!1,authorAssociation:e.pull_request.author_association??`NONE`,requestedReviewers:a},sender:{login:e.sender.login}}}case`pull_request_review_comment`:{let e=t;return{type:`pull_request_review_comment`,action:e.action,pullRequest:{number:e.pull_request.number,title:e.pull_request.title,locked:e.pull_request.locked??!1},comment:{id:e.comment.id,body:e.comment.body,author:e.comment.user.login,authorAssociation:e.comment.author_association,path:e.comment.path,line:e.comment.line??null,diffHunk:e.comment.diff_hunk,commitId:e.comment.commit_id}}}case`workflow_dispatch`:return{type:`workflow_dispatch`,inputs:{prompt:t.inputs?.prompt??void 0}};case`schedule`:return{type:`schedule`,schedule:t.schedule??void 0};case`unsupported`:return{type:`unsupported`}}}function Js(e){let t=pa,n=Ks(t.eventName),r=qs(n,t.payload);return e.debug(`Parsed GitHub context`,{eventName:t.eventName,eventType:n,repo:`${t.repo.owner}/${t.repo.repo}`}),{eventName:t.eventName,eventType:n,repo:t.repo,ref:t.ref,sha:t.sha,runId:t.runId,actor:t.actor,payload:t.payload,event:r}}function Ys(e,t){return t.includes(e)}function X(e){return e.endsWith(`[bot]`)}function Xs(e,t){if(t.length===0)return!1;let n=t.replace(/\[bot\]$/i,``);return n.length===0?!1:new RegExp(String.raw`@${Zs(n)}(?:\[bot\])?(?:$|[^\w])`,`i`).test(e)}function Zs(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function Qs(e,t){if(t.length===0)return null;let n=t.replace(/\[bot\]$/i,``);if(n.length===0)return null;let r=new RegExp(String.raw`@${Zs(n)}(?:\[bot\])?\s*(.*)`,`is`).exec(e)?.[1];if(r==null)return null;let i=r.trim();if(i.length===0)return{raw:``,action:null,args:``};let a=i.split(/\s+/),o=a[0]??``;return{raw:i,action:o===``?null:o,args:a.slice(1).join(` `)}}function Z(e,t){if(t==null||t===``||e==null)return{hasMention:!1,command:null};let n=Xs(e,t);return{hasMention:n,command:n?Qs(e,t):null}}function $s(e,t){if(e.type!==`issue_comment`)throw Error(`Event type must be issue_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r={kind:e.issue.isPullRequest?`pr`:`issue`,number:e.issue.number,title:e.issue.title,body:e.comment.body??null,locked:e.issue.locked},{hasMention:i,command:a}=Z(e.comment.body,t);return{action:e.action,author:n,target:r,commentBody:e.comment.body,commentId:e.comment.id,hasMention:i,command:a,isBotReviewRequested:!1}}function ec(e,t){if(e.type!==`discussion_comment`)throw Error(`Event type must be discussion_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r=e.comment.body??null,i={kind:`discussion`,number:e.discussion.number,title:e.discussion.title,body:r??e.discussion.body??null,locked:e.discussion.locked},{hasMention:a,command:o}=Z(r,t);return{action:e.action,author:n,target:i,commentBody:r,commentId:e.comment.id,hasMention:a,command:o,isBotReviewRequested:!1}}function tc(e,t){if(e.type!==`pull_request_review_comment`)throw Error(`Event type must be pull_request_review_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r={kind:`pr`,number:e.pullRequest.number,title:e.pullRequest.title,body:e.comment.body,locked:e.pullRequest.locked,path:e.comment.path,line:e.comment.line??void 0,diffHunk:e.comment.diffHunk,commitId:e.comment.commitId},{hasMention:i,command:a}=Z(e.comment.body,t);return{action:e.action,author:n,target:r,commentBody:e.comment.body,commentId:e.comment.id,hasMention:i,command:a,isBotReviewRequested:!1}}function nc(e,t,n){if(e.type!==`workflow_dispatch`)throw Error(`Event type must be workflow_dispatch`);let r=(n??e.inputs?.prompt??``).trim();return{action:null,author:{login:t,association:`OWNER`,isBot:!1},target:{kind:`manual`,number:0,title:`Manual workflow dispatch`,body:r===``?null:r,locked:!1},commentBody:r===``?null:r,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}function rc(e,t,n){let r=n?.trim()??``;return{action:null,author:{login:t,association:`OWNER`,isBot:!1},target:{kind:`manual`,number:0,title:`Scheduled workflow`,body:r===``?null:r,locked:!1},commentBody:r===``?null:r,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}function ic(e){return e.toLowerCase().replace(/\[bot\]$/i,``)}function ac(e,t){if(e.type!==`pull_request`||t==null||t===``)return!1;let n=ic(t);if(n===``)return!1;if(e.action===`review_requested`){let t=e.requestedReviewer?.login;return t!=null&&ic(t)===n}return e.action===`ready_for_review`?e.pullRequest.requestedReviewers.some(e=>ic(e.login)===n):!1}function oc(e,t){if(e.type!==`issues`)throw Error(`Event type must be issues`);let n={login:e.sender.login,association:e.issue.authorAssociation,isBot:X(e.sender.login)},r={kind:`issue`,number:e.issue.number,title:e.issue.title,body:e.issue.body,locked:e.issue.locked},{hasMention:i,command:a}=Z(e.issue.body??``,t);return{action:e.action,author:n,target:r,commentBody:e.issue.body,commentId:null,hasMention:i,command:a,isBotReviewRequested:!1}}function sc(e,t){if(e.type!==`pull_request`)throw Error(`Event type must be pull_request`);let n={login:e.sender.login,association:e.pullRequest.authorAssociation,isBot:X(e.sender.login)},r={kind:`pr`,number:e.pullRequest.number,title:e.pullRequest.title,body:e.pullRequest.body,locked:e.pullRequest.locked,isDraft:e.pullRequest.draft,requestedReviewerLogin:e.requestedReviewer?.login,requestedTeamSlug:e.requestedTeam?.slug,requestedReviewerLogins:e.pullRequest.requestedReviewers.map(e=>e.login)},{hasMention:i,command:a}=Z(e.pullRequest.body??``,t);return{action:e.action,author:n,target:r,commentBody:e.pullRequest.body,commentId:null,hasMention:i,command:a,isBotReviewRequested:ac(e,t)}}function Q(e,t){return{...e,action:t.action,author:t.author,target:t.target,commentBody:t.commentBody,commentId:t.commentId,hasMention:t.hasMention,command:t.command,isBotReviewRequested:t.isBotReviewRequested}}function cc(e,t,n){let r={eventType:e.eventType,eventName:e.eventName,repo:e.repo,ref:e.ref,sha:e.sha,runId:e.runId,actor:e.actor,raw:e};switch(e.eventType){case`issue_comment`:return Q(r,$s(e.event,t));case`discussion_comment`:return Q(r,ec(e.event,t));case`workflow_dispatch`:return Q(r,nc(e.event,e.actor,n));case`issues`:return Q(r,oc(e.event,t));case`pull_request`:return Q(r,sc(e.event,t));case`pull_request_review_comment`:return Q(r,tc(e.event,t));case`schedule`:return Q(r,rc(e.event,e.actor,n));case`unsupported`:return{...r,action:null,author:null,target:null,commentBody:null,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}}function lc(e,t,n){let{targetLabel:r,actionLabel:i}=n;return e.action===`created`?e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`${r} is locked`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Comments from bots (${e.author.login}) are not processed`}:e.author!=null&&!Ys(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.requireMention&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Comment does not mention the bot`}:{shouldSkip:!1}:{shouldSkip:!0,reason:`action_not_created`,message:`${i} action is '${e.action}', not 'created'`}}function uc(e,t){return lc(e,t,{targetLabel:`Issue or PR`,actionLabel:`Comment`})}function dc(e,t){return lc(e,t,{targetLabel:`Discussion`,actionLabel:`Discussion comment`})}const fc=[`opened`,`edited`];function pc(e){return fc.includes(e)}function mc(e,t){let n=e.action;return n==null||!pc(n)?{shouldSkip:!0,reason:`action_not_supported`,message:`Issues action '${n}' is not supported (only 'opened' and 'edited')`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Issues from bots (${e.author.login}) are not processed`}:e.author!=null&&!Ys(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:n===`edited`&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Issue edit does not mention the bot`}:e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Issue is locked`}:{shouldSkip:!1}}function hc(e){return(e.promptInput?.trim()??``)===``?{shouldSkip:!0,reason:`prompt_required`,message:`Schedule trigger requires prompt input`}:{shouldSkip:!1}}function gc(e){return(e.commentBody?.trim()??``)===``?{shouldSkip:!0,reason:`prompt_required`,message:`Workflow dispatch requires prompt input`}:{shouldSkip:!1}}const _c=[`opened`,`synchronize`,`reopened`,`ready_for_review`,`review_requested`];function vc(e){return _c.includes(e)}function yc(e,t){let n=e.action;return n==null||!vc(n)?{shouldSkip:!0,reason:`action_not_supported`,message:`Pull request action '${n}' is not supported`}:e.action!==`review_requested`&&e.action!==`ready_for_review`&&e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Pull requests from bots (${e.author.login}) are not processed`}:e.author!=null&&!Ys(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.skipDraftPRs&&e.target?.isDraft===!0?{shouldSkip:!0,reason:`draft_pr`,message:`Pull request is a draft`}:e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Pull request is locked`}:t.botLogin!=null&&t.botLogin!==``&&(e.action===`ready_for_review`||e.action===`review_requested`)&&e.isBotReviewRequested!==!0?{shouldSkip:!0,reason:`bot_not_requested`,message:`Pull request action '${e.action}' did not request review from the bot`}:{shouldSkip:!1}}function bc(e,t){let n=e.action;return n===`created`?e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Pull request is locked`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Review comments from bots (${e.author.login}) are not processed`}:e.author!=null&&!Ys(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.requireMention&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Review comment does not mention the bot`}:{shouldSkip:!1}:{shouldSkip:!0,reason:`action_not_created`,message:`Review comment action '${n}' is not supported (only 'created')`}}function xc(e){return{shouldSkip:!0,reason:`unsupported_event`,message:`Unsupported event type: ${e}`}}function Sc(e,t,n){if(e.eventType===`unsupported`)return n.debug(`Skipping unsupported event`,{eventName:e.eventName}),xc(e.eventName);switch(e.eventType){case`issue_comment`:return uc(e,t);case`discussion_comment`:return dc(e,t);case`issues`:return mc(e,t);case`pull_request`:return yc(e,t);case`pull_request_review_comment`:return bc(e,t);case`schedule`:return hc(t);case`workflow_dispatch`:return gc(e);default:return{shouldSkip:!1}}}const Cc={botLogin:null,requireMention:!0,allowedAssociations:bo,skipDraftPRs:!0,promptInput:null,senderAssociation:null};function wc(e,t,n={}){let r={...Cc,...n},i=cc(e,r.botLogin,r.promptInput);r.senderAssociation!=null&&(i.action===`review_requested`||i.action===`ready_for_review`)&&i.author!=null&&(i={...i,author:{...i.author,association:r.senderAssociation}}),t.debug(`Routing event`,{eventName:e.eventName,eventType:e.eventType,hasMention:i.hasMention});let a=Sc(i,r,t);return a.shouldSkip?{shouldProcess:!1,skipReason:a.reason,skipMessage:a.message,context:i}:{shouldProcess:!0,context:i}}async function Tc(e,t){let n=i({phase:`context`}),r=Js(n),o=Ga({token:e.inputs.githubToken,logger:n}),s=await Ka(o,n),c=null;if(r.event.type===`pull_request`&&(r.event.action===`review_requested`||r.event.action===`ready_for_review`)){let{owner:e,repo:t}=r.repo;c=await Ye(o,e,t,r.event.sender.login,n)}let l=i({phase:`trigger`}),u=wc(r,l,{botLogin:s,requireMention:!0,promptInput:e.inputs.prompt,senderAssociation:c});return u.shouldProcess?(l.info(`Event routed for processing`,{eventType:u.context.eventType,hasMention:u.context.hasMention,command:u.context.command?.action??null}),a(_.SHOULD_SAVE_CACHE,`true`),{githubClient:o,triggerResult:u,agentContext:await pt({logger:n,octokit:o,triggerContext:u.context,botLogin:s}),botLogin:s}):(l.info(`Skipping event`,{reason:u.skipReason,message:u.skipMessage}),Be({sessionId:null,cacheStatus:`miss`,duration:Date.now()-t}),null)}function $(e,t){return{key:`${e}-${t}`,entityType:e,entityId:t}}function Ec(e){return Ee(`sha256`).update(e).digest(`hex`).slice(0,8)}function Dc(e){if(e.eventType===`unsupported`)return null;if(e.eventType===`schedule`){let t=e.raw.event.type===`schedule`?e.raw.event.schedule:void 0;return $(`schedule`,Ec((t!=null&&t.trim().length>0?t:e.action)??`default`))}return e.eventType===`workflow_dispatch`?$(`dispatch`,String(e.runId)):e.target==null?null:e.eventType===`issue_comment`?e.target.kind===`issue`?$(`issue`,String(e.target.number)):e.target.kind===`pr`?$(`pr`,String(e.target.number)):null:e.eventType===`discussion_comment`?e.target.kind===`discussion`?$(`discussion`,String(e.target.number)):null:e.eventType===`issues`?e.target.kind===`issue`?$(`issue`,String(e.target.number)):null:(e.eventType===`pull_request`||e.eventType===`pull_request_review_comment`)&&e.target.kind===`pr`?$(`pr`,String(e.target.number)):null}function Oc(e){return`fro-bot: ${e.key}`}function kc(e,t){let n=e.filter(e=>e.title===t);return n.length===0?null:n.reduce((e,t)=>t.time.updated>e.time.updated?t:e)}async function Ac(e,t,n,r){try{let i=kc(await cs(e,t,r),Oc(n));return i==null||i.time.archived!=null||i.time.compacting!=null?{status:`not-found`}:{status:`found`,session:i}}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}async function jc(e,t,n,r){let a=i({phase:`session`}),o=J(re()),s=await ms(n.serverHandle.client,o,{limit:10},a);a.debug(`Listed recent sessions`,{count:s.length});let c=Dc(t.triggerResult.context),l=c==null?null:Oc(c),u=null,d=!1;if(c!=null){let e=await Ac(n.serverHandle.client,o,c,a);e.status===`found`?(u=e.session.id,d=!0,a.info(`Session continuity: found existing session`,{logicalKey:c.key,sessionId:u})):e.status===`error`?a.warning(`Session continuity: lookup error, will create new`,{logicalKey:c.key,error:e.error}):a.info(`Session continuity: no existing session found`,{logicalKey:c.key})}let f=c?.key??t.agentContext.issueTitle??t.agentContext.repo,p=await gs(f,n.serverHandle.client,o,{limit:5},a);a.debug(`Searched prior sessions`,{query:f,resultCount:p.length});for(let e of p)r.addSessionUsed(e.sessionId);let m=i({phase:`attachments`}),h=t.agentContext.commentBody??``,g=zo(h),_=null;if(g.length>0){m.info(`Processing attachments`,{count:g.length});let{validated:t,skipped:n}=Xo(await Wo(g,e.inputs.githubToken,void 0,m),void 0,m);(t.length>0||n.length>0)&&(_=Jo(h,g,t,n),m.info(`Attachments processed`,{processed:t.length,skipped:n.length}))}return{recentSessions:s,priorWorkContext:p,attachmentResult:_,normalizedWorkspace:o,logicalKey:c,continueSessionId:u,isContinuation:d,sessionTitle:l}}async function Mc(){let e=Date.now(),t=i({phase:`bootstrap`}),n=ze();n.start();let r=null,o=!1,s=0,l=null,u=null,d=null,f=null;a(_.SHOULD_SAVE_CACHE,`false`),a(_.CACHE_SAVED,`false`);try{t.info(`Starting Fro Bot Agent`);let i=await Mo(t);if(i==null)return 1;d=i.opencodeResult.version;let a=await Tc(i,e);if(a==null)return 0;l=a.githubClient;let c=`${a.triggerResult.context.repo.owner}/${a.triggerResult.context.repo.repo}`,p=await js(i.inputs.dedupWindow,a.triggerResult.context,c,e);if(!p.shouldProceed)return 0;r=await wo(a,i.logger);let m=await Io(i);if(m==null)return 1;f=m.serverHandle,n.setCacheStatus(m.cacheStatus);let h=await jc(i,a,m,n);u=h.attachmentResult;let g=await Ns(i,a,m,h,n,e);o=g.success,o&&p.entity!=null&&await Ms(a.triggerResult.context,p.entity,c),n.end(),s=await Gs(i,a,m,g,n,e,i.logger)}catch(r){s=1;let i=Date.now()-e,a=r instanceof Error?r.name:`UnknownError`,o=r instanceof Error?r.message:String(r);n.recordError(a,o,!1),n.end(),Be({sessionId:null,cacheStatus:`miss`,duration:i}),r instanceof Error?(t.error(`Agent failed`,{error:r.message}),c(r.message)):(t.error(`Agent failed with unknown error`),c(`An unknown error occurred`))}finally{await xs({bootstrapLogger:t,reactionCtx:r,githubClient:l,agentSuccess:o,attachmentResult:u,serverHandle:f,detectedOpencodeVersion:d})}return s}await Mc().then(e=>{N.exit(e)});export{}; \ No newline at end of file diff --git a/docs/audits/2026-03-28-session-continuity-post-ship-audit.md b/docs/audits/2026-03-28-session-continuity-post-ship-audit.md new file mode 100644 index 00000000..3f0c9587 --- /dev/null +++ b/docs/audits/2026-03-28-session-continuity-post-ship-audit.md @@ -0,0 +1,188 @@ +--- +title: "Session Continuity Post-Ship Audit" +date: 2026-03-28 +scope: v0.32.0+ (PR #376) +runs_sampled: 4 Fro Bot schedule runs (Mar 24-27, 2026) +--- + +## Session Continuity Post-Ship Audit + +## Executive Summary + +The session continuity feature (PR #376, v0.32.0) is **partially functioning**. Prompt restructuring (Non-Negotiable Rules, Constraint Reminder) works correctly. Session titles are set correctly at creation. But **session continuation never succeeds** — every run creates a fresh session because OpenCode auto-renames the title after the first prompt, and the title re-set after prompt was never implemented. + +**Impact**: Zero session continuity across runs. The agent cannot recall its prior work on the same entity. The "Thread Identity" section is never populated in prompts. + +## Runs Sampled + +| Run ID | Date | Event | Session ID | Title at Creation | +| ----------- | ---------- | -------- | ------------------- | ---------------------------- | +| 23500894440 | 2026-03-24 | schedule | ses_2df4c0cafffe... | `fro-bot: schedule-c757a308` | +| 23552690701 | 2026-03-25 | schedule | ses_2da20617dffe... | `fro-bot: schedule-c757a308` | +| 23606276260 | 2026-03-26 | schedule | ses_2d4fc0340ffe... | `fro-bot: schedule-c757a308` | +| 23655941186 | 2026-03-27 | schedule | ses_2cfed642fffe... | `fro-bot: schedule-c757a308` | + +All 4 runs: different session IDs despite identical logical key `schedule-c757a308`. + +## Findings + +### 1. CRITICAL: Session Title Auto-Overwrite (Root Cause) + +**Severity**: Critical — blocks all session continuity + +OpenCode auto-renames session titles based on the first message content. The title `fro-bot: schedule-c757a308` set at creation is overwritten (likely to something like "Daily maintenance report") before the cache is saved. The next run's resolver calls `findSessionByTitle()` looking for `fro-bot: schedule-c757a308` and finds no match. + +**Evidence**: + +- All 4 runs log: `Session continuity: no existing session found` +- All 4 runs log: `continueSessionId: null` +- All 4 runs: `Created new OpenCode session` with the correct title +- Cache IS restored from previous run (confirmed: `Cache hit for restore-key: opencode-storage-github-fro-bot-agent-main-Linux-23606276260`) +- 10 sessions exist at resolver time, none match the title + +**Root cause**: The plan specified "After successful prompt, **re-set title** via `session.update()` to guard against OpenCode's auto-title behavior" — but this was **never implemented** in `execution.ts`. There is no `session.update()` call anywhere in the codebase. + +**Fix**: Add `session.update()` call after each prompt to restore the logical key title. The OpenCode PATCH endpoint (`/session/{id}`) accepts `{ title }` — confirmed in `routes/session.ts:265`. + +### 2. WORKING: Prompt Restructuring (Instruction Sandwich) + +**Severity**: N/A — functioning correctly + +The prompt shows: + +- **Position 1**: `## Critical Rules (NON-NEGOTIABLE)` — 5-line hard constraints ✅ +- **Last position**: `## Reminder: Critical Rules` — 1-line recency reminder ✅ +- Task and Trigger Comment positioned near the top ✅ +- Agent Context demoted below task content ✅ + +### 3. WORKING: Logical Key Computation + +**Severity**: N/A — functioning correctly + +The logical key `schedule-c757a308` is: + +- Deterministic (same hash across all 4 runs) ✅ +- Correctly derived from the schedule event ✅ +- Used for session title and search fallback ✅ + +### 4. WORKING: Observability (Artifact Upload) + +**Severity**: N/A — functioning correctly + +All 4 Fro Bot schedule runs produced downloadable `opencode-logs` artifacts containing: + +- OpenCode server log (4,000-8,700 lines each) +- Prompt artifact file (197 lines each) +- Unique artifact names (`opencode-logs-{runId}-1`) ✅ + +### 5. ISSUE: Thread Identity Section Missing from Prompts + +**Severity**: High — dependent on session continuity + +The prompt shows NO "Thread Identity" section. This is expected given continuity never succeeds — the section is only populated when `logicalKey` and `isContinuation` are provided to the prompt builder. When `continueSessionId` is null, no thread identity is injected. + +**Fix**: Will resolve automatically once session continuity works. However, consider showing thread identity even on fresh sessions (e.g., "Fresh conversation — no prior thread found for schedule-c757a308") to aid debugging. + +### 6. ISSUE: Task Content Duplicated in Prompt + +**Severity**: Low — token waste + +The schedule task description appears verbatim in both: + +- `## Task` section (lines 8-37) +- `## Trigger Comment` section (lines 38-70) + +This is ~30 lines / ~400 tokens of pure duplication. For schedule events, the Task and Trigger Comment are identical because the `prompt` input IS the task. + +**Fix**: In `buildAgentPrompt()`, skip the Trigger Comment section when its content is identical to the Task section. + +### 7. NOISE: `tool.registry ... invalid` Entries + +**Severity**: Low — cosmetic noise + +Every run logs 14-24 instances of: + +``` +INFO service=tool.registry status=started invalid +INFO service=tool.registry status=completed duration=N invalid +``` + +The `invalid` here is NOT an error — it's the tool name. OpenCode's tool registry initializes a tool called `invalid` (likely a placeholder/sentinel). This is benign startup chatter from OpenCode internals. + +**Recommendation**: No action needed. Document as expected noise. + +### 8. NOISE: `Blocked 3 postinstalls` + +**Severity**: Low — cosmetic noise + +Every run logs exactly once: + +``` +Blocked 3 postinstalls. Run `bun pm untrusted` for details. +``` + +This is Bun's security policy for oMo's dependencies. Expected behavior. + +**Recommendation**: No action needed. Document as expected noise. + +### 9. OBSERVATION: Prior Session Context Shows Stale Sessions + +**Severity**: Medium — reduced context quality + +The "Prior Session Context" table shows sessions from March 3-22 (pre-v0.32.0), none of which are schedule-related maintenance sessions. The recent schedule sessions (Mar 24-26) don't appear because they likely got renamed by OpenCode and are no longer matching any useful search query. + +**Fix**: Will improve automatically once session continuity works. The "Current Thread Context" section will show the actual prior work from the same schedule thread. + +## Prioritized Action Items + +### P0: Fix session title persistence (blocks all continuity) + +Add `session.update()` call in `execution.ts` after successful prompt to re-set the logical key title. Without this, no session continuity can ever work. + +```typescript +// After successful prompt, re-set title to guard against auto-rename +if (sessionTitle != null) { + try { + await client.session.update({ + path: {id: sessionId}, + body: {title: sessionTitle} as Record, + }) + } catch { + logger.warning("Failed to re-set session title", {sessionId, sessionTitle}) + } +} +``` + +### P1: Show Thread Identity on fresh sessions too + +Currently Thread Identity only shows when `isContinuation` is true. Show it on fresh starts too so the logical key is visible in the prompt artifact for debugging: + +``` +## Thread Identity +**Logical Thread**: `schedule-c757a308` (schedule) +**Status**: Fresh conversation — no prior thread found for this entity. +``` + +### P2: Deduplicate Task / Trigger Comment for schedule events + +Skip the Trigger Comment section when it's identical to the Task section. Saves ~400 tokens per schedule run. + +### P3: Add debug logging for session title state + +Log the titles of sessions returned by `listSessionsForProject()` during resolution so we can see what titles the sessions actually have (vs. what we're searching for). + +## Metrics + +| Metric | Value | +| --------------------------------------- | ------------------------------------------------------------ | +| Runs sampled | 4 | +| Session continuity success rate | **0%** (0/4 runs) | +| Prompt restructuring working | **Yes** (Non-Negotiable Rules + Constraint Reminder present) | +| Artifact upload working | **Yes** (all 4 runs have artifacts) | +| Logical key computation working | **Yes** (deterministic `schedule-c757a308` across all runs) | +| OpenCode errors in logs | **0** | +| OpenCode warnings in logs | **0** | +| tool.registry "invalid" entries per run | 14-24 (benign noise) | +| Avg run duration | ~4-10 minutes | +| Avg OpenCode log size | 4,000-8,700 lines | +| Prompt size | 197 lines (~2,500 words) | diff --git a/src/features/agent/execution.ts b/src/features/agent/execution.ts index e2151d81..2906fee3 100644 --- a/src/features/agent/execution.ts +++ b/src/features/agent/execution.ts @@ -7,6 +7,7 @@ import * as crypto from 'node:crypto' import * as fs from 'node:fs/promises' import * as path from 'node:path' import {createOpencode} from '@opencode-ai/sdk' +import {reassertSessionTitle} from '../../services/session/title-reassert.js' import {sleep} from '../../shared/async.js' import {DEFAULT_AGENT, DEFAULT_TIMEOUT_MS} from '../../shared/constants.js' import {getGitHubWorkspace, getOpenCodeLogPath, isOpenCodePromptArtifactEnabled} from '../../shared/env.js' @@ -116,23 +117,17 @@ export async function executeOpenCode( const prompt = attempt === 1 ? initialPrompt : CONTINUATION_PROMPT const files = attempt === 1 ? promptOptions.fileParts : undefined - const result = await sendPromptToSession(client, sessionId, prompt, files, directory, config, logger) + const result = await (async () => { + try { + return await sendPromptToSession(client, sessionId, prompt, files, directory, config, logger) + } finally { + await reassertSessionTitle(client, sessionId, config?.sessionTitle, logger) + } + })() + if (result.success) { final = result.eventStreamResult - // Best-effort title re-assertion: OpenCode may auto-overwrite session titles - // based on first message content. Re-set to preserve deterministic lookup. - if (config?.sessionTitle != null) { - try { - await (client.session as unknown as {update: (args: Record) => Promise}).update({ - sessionID: sessionId, - title: config.sessionTitle, - }) - } catch { - logger.debug('Best-effort session title re-assertion failed', {sessionId}) - } - } - return { success: true, exitCode: 0, diff --git a/src/features/agent/opencode.test.ts b/src/features/agent/opencode.test.ts index 667b208a..655b0e8e 100644 --- a/src/features/agent/opencode.test.ts +++ b/src/features/agent/opencode.test.ts @@ -110,6 +110,7 @@ function createMockClient(options: { create: options.throwOnCreate ? vi.fn().mockRejectedValue(new Error('Session creation failed')) : vi.fn().mockResolvedValue({data: {id: 'ses_123', title: 'Test', version: '1'}}), + update: vi.fn().mockResolvedValue({data: {id: 'ses_123', title: 'Test', version: '1'}}), promptAsync: options.throwOnPrompt ? vi.fn().mockRejectedValue(new Error('Prompt failed')) : vi.fn().mockResolvedValue({data: options.promptResponse}), @@ -444,6 +445,70 @@ describe('executeOpenCode', () => { expect(result.duration).toBeGreaterThanOrEqual(0) }) + it('re-asserts session title with SDK update payload after prompt attempts', async () => { + // #given + const mockClient = createMockClient({ + promptResponse: {parts: [{type: 'text', text: 'Agent response'}]}, + }) + const mockOpencode = createMockOpencode({client: mockClient}) + vi.mocked(createOpencode).mockResolvedValue(mockOpencode as unknown as Awaited>) + const config: ExecutionConfig = { + agent: 'sisyphus', + model: null, + timeoutMs: 1800000, + omoProviders: { + claude: 'no', + copilot: 'no', + gemini: 'no', + openai: 'no', + opencodeZen: 'no', + zaiCodingPlan: 'no', + kimiForCoding: 'no', + }, + sessionTitle: 'fro-bot: schedule-c757a308', + } + + // #when + await executeOpenCode(createMockPromptOptions(), mockLogger, config) + + // #then + expect(mockClient.session.update).toHaveBeenCalledWith({ + path: {id: 'ses_123'}, + body: {title: 'fro-bot: schedule-c757a308'}, + }) + }) + + it('re-asserts session title even when prompt attempt fails', async () => { + // #given + const mockClient = createMockClient({throwOnPrompt: true}) + const mockOpencode = createMockOpencode({client: mockClient}) + vi.mocked(createOpencode).mockResolvedValue(mockOpencode as unknown as Awaited>) + const config: ExecutionConfig = { + agent: 'sisyphus', + model: null, + timeoutMs: 1800000, + omoProviders: { + claude: 'no', + copilot: 'no', + gemini: 'no', + openai: 'no', + opencodeZen: 'no', + zaiCodingPlan: 'no', + kimiForCoding: 'no', + }, + sessionTitle: 'fro-bot: schedule-c757a308', + } + + // #when + await executeOpenCode(createMockPromptOptions(), mockLogger, config) + + // #then + expect(mockClient.session.update).toHaveBeenCalledWith({ + path: {id: 'ses_123'}, + body: {title: 'fro-bot: schedule-c757a308'}, + }) + }) + it('returns failure result when prompt fails', async () => { // #given const mockClient = createMockClient({throwOnPrompt: true}) diff --git a/src/features/agent/prompt.test.ts b/src/features/agent/prompt.test.ts index ab24def3..874c4ca5 100644 --- a/src/features/agent/prompt.test.ts +++ b/src/features/agent/prompt.test.ts @@ -136,6 +136,25 @@ describe('buildAgentPrompt', () => { expect(prompt).toContain('**Status**: Continuing previous conversation thread.') }) + it('shows fresh thread identity status when logical key exists without continuation', () => { + // #given + const options: PromptOptions = { + context: createMockContext(), + customPrompt: null, + cacheStatus: 'hit', + logicalKey: createMockLogicalKey(), + isContinuation: false, + } + + // #when + const prompt = buildAgentPrompt(options, mockLogger) + + // #then + expect(prompt).toContain('## Thread Identity') + expect(prompt).toContain('**Logical Thread**: `pr-42` (pr #42)') + expect(prompt).toContain('**Status**: Fresh conversation — no prior thread found for this entity.') + }) + it('places current thread context above environment and historical context for continuation runs', () => { // #given const sessionContext: SessionContext = { @@ -570,6 +589,37 @@ describe('buildAgentPrompt', () => { expect(prompt).toContain('## GitHub Operations (Use gh CLI)') }) + it('skips Trigger Comment section when schedule prompt text matches trigger comment', () => { + // #given + const duplicatedTask = 'Run daily maintenance tasks and update the report issue.' + const context = createMockContext({ + eventName: 'schedule', + issueNumber: null, + issueTitle: null, + issueType: null, + commentBody: duplicatedTask, + }) + const triggerContext = createMockTriggerContext({ + eventType: 'schedule', + commentBody: duplicatedTask, + target: undefined, + }) + const options: PromptOptions = { + context, + customPrompt: ` ${duplicatedTask} `, + cacheStatus: 'hit', + triggerContext, + } + + // #when + const prompt = buildAgentPrompt(options, mockLogger) + + // #then + expect(prompt).toContain('## Task') + expect(prompt).toContain(duplicatedTask) + expect(prompt).not.toContain('## Trigger Comment') + }) + describe('session context', () => { it('includes session context section when sessionContext is provided', () => { // #given diff --git a/src/features/agent/prompt.ts b/src/features/agent/prompt.ts index 4e70cc00..10293e94 100644 --- a/src/features/agent/prompt.ts +++ b/src/features/agent/prompt.ts @@ -156,7 +156,16 @@ Respond to the trigger comment above. Follow all instructions and requirements l `) } - if (context.commentBody != null) { + const trimmedCustomPrompt = customPrompt?.trim() ?? null + const trimmedCommentBody = context.commentBody?.trim() ?? null + const triggerCommentDuplicatesTask = + trimmedCustomPrompt != null && + trimmedCustomPrompt.length > 0 && + trimmedCommentBody != null && + trimmedCommentBody.length > 0 && + trimmedCustomPrompt === trimmedCommentBody + + if (context.commentBody != null && !triggerCommentDuplicatesTask) { parts.push(`## Trigger Comment **Author:** ${context.commentAuthor ?? 'unknown'} diff --git a/src/harness/phases/execute.ts b/src/harness/phases/execute.ts index 5fce46d0..2e27e310 100644 --- a/src/harness/phases/execute.ts +++ b/src/harness/phases/execute.ts @@ -43,6 +43,9 @@ export async function runExecute( recentSessions: sessionPrep.recentSessions, priorWorkContext: sessionPrep.priorWorkContext, }, + logicalKey: sessionPrep.logicalKey ?? null, + isContinuation: sessionPrep.isContinuation, + currentThreadSessionId: sessionPrep.continueSessionId ?? null, triggerContext: routing.triggerResult.context, fileParts: sessionPrep.attachmentResult?.fileParts, } diff --git a/src/services/session/title-reassert.ts b/src/services/session/title-reassert.ts new file mode 100644 index 00000000..981337f4 --- /dev/null +++ b/src/services/session/title-reassert.ts @@ -0,0 +1,34 @@ +import type {Logger} from '../../shared/logger.js' +import type {SessionClient} from './backend.js' + +export async function reassertSessionTitle( + client: SessionClient, + sessionId: string, + title: string | undefined, + logger: Logger, +): Promise { + if (title == null) { + return + } + + try { + const response = await client.session.update({ + path: {id: sessionId}, + body: {title} as Record, + }) + + if (response.error != null) { + logger.warning('Best-effort session title re-assertion failed', { + sessionId, + sessionTitle: title, + error: String(response.error), + }) + } + } catch (error) { + logger.warning('Best-effort session title re-assertion failed', { + sessionId, + sessionTitle: title, + error: error instanceof Error ? error.message : String(error), + }) + } +} From 4a950a6fea103389791087e38f5e3f55d1968b8a Mon Sep 17 00:00:00 2001 From: "fro-bot[bot]" <109017866+fro-bot[bot]@users.noreply.github.com> Date: Sat, 28 Mar 2026 07:13:34 -0700 Subject: [PATCH 6/6] build(dev): update dependency tsdown to v0.21.5 (#392) --- dist/{cache-CqdRyjOf.js => cache-H1aH1Xpr.js} | 6 +- dist/main.js | 2 +- dist/post.js | 2 +- package.json | 2 +- pnpm-lock.yaml | 377 +++++++++++++----- 5 files changed, 281 insertions(+), 108 deletions(-) rename dist/{cache-CqdRyjOf.js => cache-H1aH1Xpr.js} (91%) diff --git a/dist/cache-CqdRyjOf.js b/dist/cache-H1aH1Xpr.js similarity index 91% rename from dist/cache-CqdRyjOf.js rename to dist/cache-H1aH1Xpr.js index 4893f567..36891389 100644 --- a/dist/cache-CqdRyjOf.js +++ b/dist/cache-H1aH1Xpr.js @@ -9,11 +9,11 @@ Content-Type: ${c.type||`application/octet-stream`}\r\n\r\n`);a.push(e,c,o),type `,Array.isArray(h))for(let e=0;e{t.removeListener(`error`,g)}),!d){let e=new c;queueMicrotask(()=>g(e))}},g=function(e){if(!d){if(d=!0,n(o.destroyed||o[w]&&i[x]<=1),o.off(`drain`,m).off(`error`,g),t.removeListener(`data`,p).removeListener(`end`,g).removeListener(`close`,h),!e)try{f.end()}catch(t){e=t}f.destroy(e),e&&(e.code!==`UND_ERR_INFO`||e.message!==`reset`)?r.destroy(t,e):r.destroy(t)}};t.on(`data`,p).on(`end`,g).on(`error`,g).on(`close`,h),t.resume&&t.resume(),o.on(`drain`,m).on(`error`,g),t.errorEmitted??t.errored?setImmediate(()=>g(t.errored)):(t.endEmitted??t.readableEnded)&&setImmediate(()=>g(null)),(t.closeEmitted??t.closed)&&setImmediate(h)}function je(e,t,i,a,o,s,c,l){try{t?r.isBuffer(t)&&(n(s===t.byteLength,`buffer body must have content length`),o.cork(),o.write(`${c}content-length: ${s}\r\n\r\n`,`latin1`),o.write(t),o.uncork(),a.onBodySent(t),!l&&a.reset!==!1&&(o[_]=!0)):s===0?o.write(`${c}content-length: 0\r\n\r\n`,`latin1`):(n(s===null,`no body must not have content length`),o.write(`${c}\r\n`,`latin1`)),a.onRequestSent(),i[le]()}catch(t){e(t)}}async function Ne(e,t,r,i,a,s,c,l){n(s===t.size,`blob body must have content length`);try{if(s!=null&&s!==t.size)throw new o;let e=Buffer.from(await t.arrayBuffer());a.cork(),a.write(`${c}content-length: ${s}\r\n\r\n`,`latin1`),a.write(e),a.uncork(),i.onBodySent(e),i.onRequestSent(),!l&&i.reset!==!1&&(a[_]=!0),r[le]()}catch(t){e(t)}}async function Pe(e,t,r,i,a,o,s,c){n(o!==0||r[x]===0,`iterator body cannot be pipelined`);let l=null;function u(){if(l){let e=l;l=null,e()}}let d=()=>new Promise((e,t)=>{n(l===null),a[j]?t(a[j]):l=e});a.on(`close`,u).on(`drain`,u);let f=new Fe({abort:e,socket:a,request:i,contentLength:o,client:r,expectsPayload:c,header:s});try{for await(let e of t){if(a[j])throw a[j];f.write(e)||await d()}f.end()}catch(e){f.destroy(e)}finally{a.off(`close`,u).off(`drain`,u)}}var Fe=class{constructor({abort:e,socket:t,request:n,contentLength:r,client:i,expectsPayload:a,header:o}){this.socket=t,this.request=n,this.contentLength=r,this.client=i,this.bytesWritten=0,this.expectsPayload=a,this.header=o,this.abort=e,t[w]=!0}write(e){let{socket:t,request:n,contentLength:r,client:i,bytesWritten:a,expectsPayload:s,header:c}=this;if(t[j])throw t[j];if(t.destroyed)return!1;let l=Buffer.byteLength(e);if(!l)return!0;if(r!==null&&a+l>r){if(i[ie])throw new o;process.emitWarning(new o)}t.cork(),a===0&&(!s&&n.reset!==!1&&(t[_]=!0),r===null?t.write(`${c}transfer-encoding: chunked\r\n`,`latin1`):t.write(`${c}content-length: ${r}\r\n\r\n`,`latin1`)),r===null&&t.write(`\r\n${l.toString(16)}\r\n`,`latin1`),this.bytesWritten+=l;let u=t.write(e);return t.uncork(),n.onBodySent(e),u||t[y].timeout&&t[y].timeoutType===3&&t[y].timeout.refresh&&t[y].timeout.refresh(),u}end(){let{socket:e,contentLength:t,client:n,bytesWritten:r,expectsPayload:i,header:a,request:s}=this;if(s.onRequestSent(),e[w]=!1,e[j])throw e[j];if(!e.destroyed){if(r===0?i?e.write(`${a}content-length: 0\r\n\r\n`,`latin1`):e.write(`${a}\r\n`,`latin1`):t===null&&e.write(`\r 0\r \r -`,`latin1`),t!==null&&r!==t){if(n[ie])throw new o;process.emitWarning(new o)}e[y].timeout&&e[y].timeoutType===3&&e[y].timeout.refresh&&e[y].timeout.refresh(),n[le]()}}destroy(e){let{socket:t,client:r,abort:i}=this;t[w]=!1,e&&(n(r[x]<=1,`pipeline should only contain this request`),i(e))}};t.exports=Te})),$e=I(((e,t)=>{let n=L(`node:assert`),{pipeline:r}=L(`node:stream`),i=z(),{RequestContentLengthMismatchError:a,RequestAbortedError:o,SocketError:s,InformationalError:c}=R(),{kUrl:l,kReset:u,kClient:d,kRunning:f,kPending:p,kQueue:m,kPendingIdx:h,kRunningIdx:g,kError:_,kSocket:v,kStrictContentLength:y,kOnError:b,kMaxConcurrentStreams:x,kHTTP2Session:S,kResume:C,kSize:w,kHTTPContext:T}=ke(),E=Symbol(`open streams`),D,O=!1,k;try{k=L(`node:http2`)}catch{k={constants:{}}}let{constants:{HTTP2_HEADER_AUTHORITY:A,HTTP2_HEADER_METHOD:j,HTTP2_HEADER_PATH:M,HTTP2_HEADER_SCHEME:N,HTTP2_HEADER_CONTENT_LENGTH:P,HTTP2_HEADER_EXPECT:ee,HTTP2_HEADER_STATUS:te}}=k;function ne(e){let t=[];for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r)t.push(Buffer.from(n),Buffer.from(e));else t.push(Buffer.from(n),Buffer.from(r));return t}async function F(e,t){e[v]=t,O||(O=!0,process.emitWarning(`H2 support is experimental, expect them to change at any time.`,{code:`UNDICI-H2`}));let r=k.connect(e[l],{createConnection:()=>t,peerMaxConcurrentStreams:e[x]});r[E]=0,r[d]=e,r[v]=t,i.addListener(r,`error`,ie),i.addListener(r,`frameError`,ae),i.addListener(r,`end`,oe),i.addListener(r,`goaway`,se),i.addListener(r,`close`,function(){let{[d]:e}=this,{[v]:t}=e,r=this[v][_]||this[_]||new s(`closed`,i.getSocketInfo(t));if(e[S]=null,e.destroyed){n(e[p]===0);let t=e[m].splice(e[g]);for(let n=0;n{a=!0}),{version:`h2`,defaultPipelining:1/0,write(...t){return le(e,...t)},resume(){re(e)},destroy(e,n){a?queueMicrotask(n):t.destroy(e).on(`close`,n)},get destroyed(){return t.destroyed},busy(){return!1}}}function re(e){let t=e[v];t?.destroyed===!1&&(e[w]===0&&e[x]===0?(t.unref(),e[S].unref()):(t.ref(),e[S].ref()))}function ie(e){n(e.code!==`ERR_TLS_CERT_ALTNAME_INVALID`),this[v][_]=e,this[d][b](e)}function ae(e,t,n){if(n===0){let n=new c(`HTTP/2: "frameError" received - type ${e}, code ${t}`);this[v][_]=n,this[d][b](n)}}function oe(){let e=new s(`other side closed`,i.getSocketInfo(this[v]));this.destroy(e),i.destroy(this[v],e)}function se(e){let t=this[_]||new s(`HTTP/2: "GOAWAY" frame received with code ${e}`,i.getSocketInfo(this)),r=this[d];if(r[v]=null,r[T]=null,this[S]!=null&&(this[S].destroy(t),this[S]=null),i.destroy(this[v],t),r[g]{t.aborted||t.completed||(n||=new o,i.errorRequest(e,t,n),T!=null&&i.destroy(T,n),i.destroy(x,n),e[m][e[g]++]=null,e[C]())};try{t.onConnect(F)}catch(n){i.errorRequest(e,t,n)}if(t.aborted)return!1;if(s===`CONNECT`)return r.ref(),T=r.request(w,{endStream:!1,signal:_}),T.id&&!T.pending?(t.onUpgrade(null,null,T),++r[E],e[m][e[g]++]=null):T.once(`ready`,()=>{t.onUpgrade(null,null,T),++r[E],e[m][e[g]++]=null}),T.once(`close`,()=>{--r[E],r[E]===0&&r.unref()}),!0;w[M]=u,w[N]=`https`;let re=s===`PUT`||s===`POST`||s===`PATCH`;x&&typeof x.read==`function`&&x.read(0);let ie=i.bodyLength(x);if(i.isFormDataLike(x)){D??=Ze().extractBody;let[e,t]=D(x);w[`content-type`]=t,x=e.stream,ie=e.length}if(ie??=t.contentLength,(ie===0||!re)&&(ie=null),ce(s)&&ie>0&&t.contentLength!=null&&t.contentLength!==ie){if(e[y])return i.errorRequest(e,t,new a),!1;process.emitWarning(new a)}ie!=null&&(n(x,`no body must not have content length`),w[P]=`${ie}`),r.ref();let ae=s===`GET`||s===`HEAD`||x===null;return p?(w[ee]=`100-continue`,T=r.request(w,{endStream:ae,signal:_}),T.once(`continue`,oe)):(T=r.request(w,{endStream:ae,signal:_}),oe()),++r[E],T.once(`response`,n=>{let{[te]:r,...a}=n;if(t.onResponseStarted(),t.aborted){let n=new o;i.errorRequest(e,t,n),i.destroy(T,n);return}t.onHeaders(Number(r),ne(a),T.resume.bind(T),``)===!1&&T.pause(),T.on(`data`,e=>{t.onData(e)===!1&&T.pause()})}),T.once(`end`,()=>{(T.state?.state==null||T.state.state<6)&&t.onComplete([]),r[E]===0&&r.unref(),F(new c(`HTTP/2: stream half-closed (remote)`)),e[m][e[g]++]=null,e[h]=e[g],e[C]()}),T.once(`close`,()=>{--r[E],r[E]===0&&r.unref()}),T.once(`error`,function(e){F(e)}),T.once(`frameError`,(e,t)=>{F(new c(`HTTP/2: "frameError" received - type ${e}, code ${t}`))}),!0;function oe(){!x||ie===0?ue(F,T,null,e,t,e[v],ie,re):i.isBuffer(x)?ue(F,T,x,e,t,e[v],ie,re):i.isBlobLike(x)?typeof x.stream==`function`?fe(F,T,x.stream(),e,t,e[v],ie,re):I(F,T,x,e,t,e[v],ie,re):i.isStream(x)?de(F,e[v],re,T,x,e,t,ie):i.isIterable(x)?fe(F,T,x,e,t,e[v],ie,re):n(!1)}}function ue(e,t,r,a,o,s,c,l){try{r!=null&&i.isBuffer(r)&&(n(c===r.byteLength,`buffer body must have content length`),t.cork(),t.write(r),t.uncork(),t.end(),o.onBodySent(r)),l||(s[u]=!0),o.onRequestSent(),a[C]()}catch(t){e(t)}}function de(e,t,a,o,s,c,l,d){n(d!==0||c[f]===0,`stream body cannot be pipelined`);let p=r(s,o,n=>{n?(i.destroy(p,n),e(n)):(i.removeAllListeners(p),l.onRequestSent(),a||(t[u]=!0),c[C]())});i.addListener(p,`data`,m);function m(e){l.onBodySent(e)}}async function I(e,t,r,i,o,s,c,l){n(c===r.size,`blob body must have content length`);try{if(c!=null&&c!==r.size)throw new a;let e=Buffer.from(await r.arrayBuffer());t.cork(),t.write(e),t.uncork(),t.end(),o.onBodySent(e),o.onRequestSent(),l||(s[u]=!0),i[C]()}catch(t){e(t)}}async function fe(e,t,r,i,a,o,s,c){n(s!==0||i[f]===0,`iterator body cannot be pipelined`);let l=null;function d(){if(l){let e=l;l=null,e()}}let p=()=>new Promise((e,t)=>{n(l===null),o[_]?t(o[_]):l=e});t.on(`close`,d).on(`drain`,d);try{for await(let e of r){if(o[_])throw o[_];let n=t.write(e);a.onBodySent(e),n||await p()}t.end(),a.onRequestSent(),c||(o[u]=!0),i[C]()}catch(t){e(t)}finally{t.off(`close`,d).off(`drain`,d)}}t.exports=F})),et=I(((e,t)=>{let n=z(),{kBodyUsed:r}=ke(),i=L(`node:assert`),{InvalidArgumentError:a}=R(),o=L(`node:events`),s=[300,301,302,303,307,308],c=Symbol(`body`);var l=class{constructor(e){this[c]=e,this[r]=!1}async*[Symbol.asyncIterator](){i(!this[r],`disturbed`),this[r]=!0,yield*this[c]}},u=class{constructor(e,t,s,c){if(t!=null&&(!Number.isInteger(t)||t<0))throw new a(`maxRedirections must be a positive number`);n.validateHandler(c,s.method,s.upgrade),this.dispatch=e,this.location=null,this.abort=null,this.opts={...s,maxRedirections:0},this.maxRedirections=t,this.handler=c,this.history=[],this.redirectionLimitReached=!1,n.isStream(this.opts.body)?(n.bodyLength(this.opts.body)===0&&this.opts.body.on(`data`,function(){i(!1)}),typeof this.opts.body.readableDidRead!=`boolean`&&(this.opts.body[r]=!1,o.prototype.on.call(this.opts.body,`data`,function(){this[r]=!0}))):(this.opts.body&&typeof this.opts.body.pipeTo==`function`||this.opts.body&&typeof this.opts.body!=`string`&&!ArrayBuffer.isView(this.opts.body)&&n.isIterable(this.opts.body))&&(this.opts.body=new l(this.opts.body))}onConnect(e){this.abort=e,this.handler.onConnect(e,{history:this.history})}onUpgrade(e,t,n){this.handler.onUpgrade(e,t,n)}onError(e){this.handler.onError(e)}onHeaders(e,t,r,i){if(this.location=this.history.length>=this.maxRedirections||n.isDisturbed(this.opts.body)?null:d(e,t),this.opts.throwOnMaxRedirect&&this.history.length>=this.maxRedirections){this.request&&this.request.abort(Error(`max redirects`)),this.redirectionLimitReached=!0,this.abort(Error(`max redirects`));return}if(this.opts.origin&&this.history.push(new URL(this.opts.path,this.opts.origin)),!this.location)return this.handler.onHeaders(e,t,r,i);let{origin:a,pathname:o,search:s}=n.parseURL(new URL(this.location,this.opts.origin&&new URL(this.opts.path,this.opts.origin))),c=s?`${o}${s}`:o;this.opts.headers=p(this.opts.headers,e===303,this.opts.origin!==a),this.opts.path=c,this.opts.origin=a,this.opts.maxRedirections=0,this.opts.query=null,e===303&&this.opts.method!==`HEAD`&&(this.opts.method=`GET`,this.opts.body=null)}onData(e){if(!this.location)return this.handler.onData(e)}onComplete(e){this.location?(this.location=null,this.abort=null,this.dispatch(this.opts,this)):this.handler.onComplete(e)}onBodySent(e){this.handler.onBodySent&&this.handler.onBodySent(e)}};function d(e,t){if(s.indexOf(e)===-1)return null;for(let e=0;e{let n=et();function r({maxRedirections:e}){return t=>function(r,i){let{maxRedirections:a=e}=r;if(!a)return t(r,i);let o=new n(t,a,r,i);return r={...r,maxRedirections:0},t(r,o)}}t.exports=r})),nt=I(((e,t)=>{let n=L(`node:assert`),r=L(`node:net`),i=L(`node:http`),a=z(),{channels:o}=Me(),s=Ne(),c=Fe(),{InvalidArgumentError:l,InformationalError:u,ClientDestroyedError:d}=R(),f=Le(),{kUrl:p,kServerName:m,kClient:h,kBusy:g,kConnect:_,kResuming:v,kRunning:y,kPending:b,kSize:x,kQueue:S,kConnected:C,kConnecting:w,kNeedDrain:T,kKeepAliveDefaultTimeout:E,kHostHeader:D,kPendingIdx:O,kRunningIdx:k,kError:A,kPipelining:j,kKeepAliveTimeoutValue:M,kMaxHeadersSize:N,kKeepAliveMaxTimeout:P,kKeepAliveTimeoutThreshold:ee,kHeadersTimeout:te,kBodyTimeout:ne,kStrictContentLength:F,kConnector:re,kMaxRedirections:ie,kMaxRequests:ae,kCounter:oe,kClose:se,kDestroy:ce,kDispatch:le,kInterceptors:ue,kLocalAddress:de,kMaxResponseSize:I,kOnError:fe,kHTTPContext:pe,kMaxConcurrentStreams:me,kResume:he}=ke(),ge=Qe(),_e=$e(),ve=!1,ye=Symbol(`kClosedResolve`),be=()=>{};function xe(e){return e[j]??e[pe]?.defaultPipelining??1}var Se=class extends c{constructor(e,{interceptors:t,maxHeaderSize:n,headersTimeout:o,socketTimeout:s,requestTimeout:c,connectTimeout:u,bodyTimeout:d,idleTimeout:h,keepAlive:g,keepAliveTimeout:_,maxKeepAliveTimeout:y,keepAliveMaxTimeout:b,keepAliveTimeoutThreshold:x,socketPath:C,pipelining:w,tls:A,strictContentLength:oe,maxCachedSessions:se,maxRedirections:ce,connect:le,maxRequestsPerClient:L,localAddress:ge,maxResponseSize:_e,autoSelectFamily:be,autoSelectFamilyAttemptTimeout:xe,maxConcurrentStreams:Se,allowH2:Te}={}){if(super(),g!==void 0)throw new l(`unsupported keepAlive, use pipelining=0 instead`);if(s!==void 0)throw new l(`unsupported socketTimeout, use headersTimeout & bodyTimeout instead`);if(c!==void 0)throw new l(`unsupported requestTimeout, use headersTimeout & bodyTimeout instead`);if(h!==void 0)throw new l(`unsupported idleTimeout, use keepAliveTimeout instead`);if(y!==void 0)throw new l(`unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead`);if(n!=null&&!Number.isFinite(n))throw new l(`invalid maxHeaderSize`);if(C!=null&&typeof C!=`string`)throw new l(`invalid socketPath`);if(u!=null&&(!Number.isFinite(u)||u<0))throw new l(`invalid connectTimeout`);if(_!=null&&(!Number.isFinite(_)||_<=0))throw new l(`invalid keepAliveTimeout`);if(b!=null&&(!Number.isFinite(b)||b<=0))throw new l(`invalid keepAliveMaxTimeout`);if(x!=null&&!Number.isFinite(x))throw new l(`invalid keepAliveTimeoutThreshold`);if(o!=null&&(!Number.isInteger(o)||o<0))throw new l(`headersTimeout must be a positive integer or zero`);if(d!=null&&(!Number.isInteger(d)||d<0))throw new l(`bodyTimeout must be a positive integer or zero`);if(le!=null&&typeof le!=`function`&&typeof le!=`object`)throw new l(`connect must be a function or an object`);if(ce!=null&&(!Number.isInteger(ce)||ce<0))throw new l(`maxRedirections must be a positive number`);if(L!=null&&(!Number.isInteger(L)||L<0))throw new l(`maxRequestsPerClient must be a positive number`);if(ge!=null&&(typeof ge!=`string`||r.isIP(ge)===0))throw new l(`localAddress must be valid string IP address`);if(_e!=null&&(!Number.isInteger(_e)||_e<-1))throw new l(`maxResponseSize must be a positive number`);if(xe!=null&&(!Number.isInteger(xe)||xe<-1))throw new l(`autoSelectFamilyAttemptTimeout must be a positive number`);if(Te!=null&&typeof Te!=`boolean`)throw new l(`allowH2 must be a valid boolean value`);if(Se!=null&&(typeof Se!=`number`||Se<1))throw new l(`maxConcurrentStreams must be a positive integer, greater than 0`);typeof le!=`function`&&(le=f({...A,maxCachedSessions:se,allowH2:Te,socketPath:C,timeout:u,...be?{autoSelectFamily:be,autoSelectFamilyAttemptTimeout:xe}:void 0,...le})),t?.Client&&Array.isArray(t.Client)?(this[ue]=t.Client,ve||(ve=!0,process.emitWarning(`Client.Options#interceptor is deprecated. Use Dispatcher#compose instead.`,{code:`UNDICI-CLIENT-INTERCEPTOR-DEPRECATED`}))):this[ue]=[Ce({maxRedirections:ce})],this[p]=a.parseOrigin(e),this[re]=le,this[j]=w??1,this[N]=n||i.maxHeaderSize,this[E]=_??4e3,this[P]=b??6e5,this[ee]=x??2e3,this[M]=this[E],this[m]=null,this[de]=ge??null,this[v]=0,this[T]=0,this[D]=`host: ${this[p].hostname}${this[p].port?`:${this[p].port}`:``}\r\n`,this[ne]=d??3e5,this[te]=o??3e5,this[F]=oe??!0,this[ie]=ce,this[ae]=L,this[ye]=null,this[I]=_e>-1?_e:-1,this[me]=Se??100,this[pe]=null,this[S]=[],this[k]=0,this[O]=0,this[he]=e=>De(this,e),this[fe]=e=>we(this,e)}get pipelining(){return this[j]}set pipelining(e){this[j]=e,this[he](!0)}get[b](){return this[S].length-this[O]}get[y](){return this[O]-this[k]}get[x](){return this[S].length-this[k]}get[C](){return!!this[pe]&&!this[w]&&!this[pe].destroyed}get[g](){return!!(this[pe]?.busy(null)||this[x]>=(xe(this)||1)||this[b]>0)}[_](e){Te(this),this.once(`connect`,e)}[le](e,t){let n=new s(e.origin||this[p].origin,e,t);return this[S].push(n),this[v]||(a.bodyLength(n.body)==null&&a.isIterable(n.body)?(this[v]=1,queueMicrotask(()=>De(this))):this[he](!0)),this[v]&&this[T]!==2&&this[g]&&(this[T]=2),this[T]<2}async[se](){return new Promise(e=>{this[x]?this[ye]=e:e(null)})}async[ce](e){return new Promise(t=>{let n=this[S].splice(this[O]);for(let t=0;t{this[ye]&&(this[ye](),this[ye]=null),t(null)};this[pe]?(this[pe].destroy(e,r),this[pe]=null):queueMicrotask(r),this[he]()})}};let Ce=tt();function we(e,t){if(e[y]===0&&t.code!==`UND_ERR_INFO`&&t.code!==`UND_ERR_SOCKET`){n(e[O]===e[k]);let r=e[S].splice(e[k]);for(let n=0;n{e[re]({host:t,hostname:i,protocol:s,port:c,servername:e[m],localAddress:e[de]},(e,t)=>{e?r(e):n(t)})});if(e.destroyed){a.destroy(r.on(`error`,be),new d);return}n(r);try{e[pe]=r.alpnProtocol===`h2`?await _e(e,r):await ge(e,r)}catch(e){throw r.destroy().on(`error`,be),e}e[w]=!1,r[oe]=0,r[ae]=e[ae],r[h]=e,r[A]=null,o.connected.hasSubscribers&&o.connected.publish({connectParams:{host:t,hostname:i,protocol:s,port:c,version:e[pe]?.version,servername:e[m],localAddress:e[de]},connector:e[re],socket:r}),e.emit(`connect`,e[p],[e])}catch(r){if(e.destroyed)return;if(e[w]=!1,o.connectError.hasSubscribers&&o.connectError.publish({connectParams:{host:t,hostname:i,protocol:s,port:c,version:e[pe]?.version,servername:e[m],localAddress:e[de]},connector:e[re],error:r}),r.code===`ERR_TLS_CERT_ALTNAME_INVALID`)for(n(e[y]===0);e[b]>0&&e[S][e[O]].servername===e[m];){let t=e[S][e[O]++];a.errorRequest(e,t,r)}else we(e,r);e.emit(`connectionError`,e[p],[e],r)}e[he]()}function Ee(e){e[T]=0,e.emit(`drain`,e[p],[e])}function De(e,t){e[v]!==2&&(e[v]=2,Oe(e,t),e[v]=0,e[k]>256&&(e[S].splice(0,e[k]),e[O]-=e[k],e[k]=0))}function Oe(e,t){for(;;){if(e.destroyed){n(e[b]===0);return}if(e[ye]&&!e[x]){e[ye](),e[ye]=null;return}if(e[pe]&&e[pe].resume(),e[g])e[T]=2;else if(e[T]===2){t?(e[T]=1,queueMicrotask(()=>Ee(e))):Ee(e);continue}if(e[b]===0||e[y]>=(xe(e)||1))return;let r=e[S][e[O]];if(e[p].protocol===`https:`&&e[m]!==r.servername){if(e[y]>0)return;e[m]=r.servername,e[pe]?.destroy(new u(`servername changed`),()=>{e[pe]=null,De(e)})}if(e[w])return;if(!e[pe]){Te(e);return}if(e[pe].destroyed||e[pe].busy(r))return;!r.aborted&&e[pe].write(r)?e[O]++:e[S].splice(e[O],1)}}t.exports=Se})),rt=I(((e,t)=>{let n=2048,r=n-1;var i=class{constructor(){this.bottom=0,this.top=0,this.list=Array(n),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&r)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&r}shift(){let e=this.list[this.bottom];return e===void 0?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&r,e)}};t.exports=class{constructor(){this.head=this.tail=new i}isEmpty(){return this.head.isEmpty()}push(e){this.head.isFull()&&(this.head=this.head.next=new i),this.head.push(e)}shift(){let e=this.tail,t=e.shift();return e.isEmpty()&&e.next!==null&&(this.tail=e.next),t}}})),it=I(((e,t)=>{let{kFree:n,kConnected:r,kPending:i,kQueued:a,kRunning:o,kSize:s}=ke(),c=Symbol(`pool`);t.exports=class{constructor(e){this[c]=e}get connected(){return this[c][r]}get free(){return this[c][n]}get pending(){return this[c][i]}get queued(){return this[c][a]}get running(){return this[c][o]}get size(){return this[c][s]}}})),at=I(((e,t)=>{let n=Fe(),r=rt(),{kConnected:i,kSize:a,kRunning:o,kPending:s,kQueued:c,kBusy:l,kFree:u,kUrl:d,kClose:f,kDestroy:p,kDispatch:m}=ke(),h=it(),g=Symbol(`clients`),_=Symbol(`needDrain`),v=Symbol(`queue`),y=Symbol(`closed resolve`),b=Symbol(`onDrain`),x=Symbol(`onConnect`),S=Symbol(`onDisconnect`),C=Symbol(`onConnectionError`),w=Symbol(`get dispatcher`),T=Symbol(`add client`),E=Symbol(`remove client`),D=Symbol(`stats`);t.exports={PoolBase:class extends n{constructor(){super(),this[v]=new r,this[g]=[],this[c]=0;let e=this;this[b]=function(t,n){let r=e[v],i=!1;for(;!i;){let t=r.shift();if(!t)break;e[c]--,i=!this.dispatch(t.opts,t.handler)}this[_]=i,!this[_]&&e[_]&&(e[_]=!1,e.emit(`drain`,t,[e,...n])),e[y]&&r.isEmpty()&&Promise.all(e[g].map(e=>e.close())).then(e[y])},this[x]=(t,n)=>{e.emit(`connect`,t,[e,...n])},this[S]=(t,n,r)=>{e.emit(`disconnect`,t,[e,...n],r)},this[C]=(t,n,r)=>{e.emit(`connectionError`,t,[e,...n],r)},this[D]=new h(this)}get[l](){return this[_]}get[i](){return this[g].filter(e=>e[i]).length}get[u](){return this[g].filter(e=>e[i]&&!e[_]).length}get[s](){let e=this[c];for(let{[s]:t}of this[g])e+=t;return e}get[o](){let e=0;for(let{[o]:t}of this[g])e+=t;return e}get[a](){let e=this[c];for(let{[a]:t}of this[g])e+=t;return e}get stats(){return this[D]}async[f](){this[v].isEmpty()?await Promise.all(this[g].map(e=>e.close())):await new Promise(e=>{this[y]=e})}async[p](e){for(;;){let t=this[v].shift();if(!t)break;t.handler.onError(e)}await Promise.all(this[g].map(t=>t.destroy(e)))}[m](e,t){let n=this[w]();return n?n.dispatch(e,t)||(n[_]=!0,this[_]=!this[w]()):(this[_]=!0,this[v].push({opts:e,handler:t}),this[c]++),!this[_]}[T](e){return e.on(`drain`,this[b]).on(`connect`,this[x]).on(`disconnect`,this[S]).on(`connectionError`,this[C]),this[g].push(e),this[_]&&queueMicrotask(()=>{this[_]&&this[b](e[d],[this,e])}),this}[E](e){e.close(()=>{let t=this[g].indexOf(e);t!==-1&&this[g].splice(t,1)}),this[_]=this[g].some(e=>!e[_]&&e.closed!==!0&&e.destroyed!==!0)}},kClients:g,kNeedDrain:_,kAddClient:T,kRemoveClient:E,kGetDispatcher:w}})),ot=I(((e,t)=>{let{PoolBase:n,kClients:r,kNeedDrain:i,kAddClient:a,kGetDispatcher:o}=at(),s=nt(),{InvalidArgumentError:c}=R(),l=z(),{kUrl:u,kInterceptors:d}=ke(),f=Le(),p=Symbol(`options`),m=Symbol(`connections`),h=Symbol(`factory`);function g(e,t){return new s(e,t)}t.exports=class extends n{constructor(e,{connections:t,factory:n=g,connect:i,connectTimeout:a,tls:o,maxCachedSessions:s,socketPath:_,autoSelectFamily:v,autoSelectFamilyAttemptTimeout:y,allowH2:b,...x}={}){if(super(),t!=null&&(!Number.isFinite(t)||t<0))throw new c(`invalid connections`);if(typeof n!=`function`)throw new c(`factory must be a function.`);if(i!=null&&typeof i!=`function`&&typeof i!=`object`)throw new c(`connect must be a function or an object`);typeof i!=`function`&&(i=f({...o,maxCachedSessions:s,allowH2:b,socketPath:_,timeout:a,...v?{autoSelectFamily:v,autoSelectFamilyAttemptTimeout:y}:void 0,...i})),this[d]=x.interceptors?.Pool&&Array.isArray(x.interceptors.Pool)?x.interceptors.Pool:[],this[m]=t||null,this[u]=l.parseOrigin(e),this[p]={...l.deepClone(x),connect:i,allowH2:b},this[p].interceptors=x.interceptors?{...x.interceptors}:void 0,this[h]=n,this.on(`connectionError`,(e,t,n)=>{for(let e of t){let t=this[r].indexOf(e);t!==-1&&this[r].splice(t,1)}})}[o](){for(let e of this[r])if(!e[i])return e;if(!this[m]||this[r].length{let{BalancedPoolMissingUpstreamError:n,InvalidArgumentError:r}=R(),{PoolBase:i,kClients:a,kNeedDrain:o,kAddClient:s,kRemoveClient:c,kGetDispatcher:l}=at(),u=ot(),{kUrl:d,kInterceptors:f}=ke(),{parseOrigin:p}=z(),m=Symbol(`factory`),h=Symbol(`options`),g=Symbol(`kGreatestCommonDivisor`),_=Symbol(`kCurrentWeight`),v=Symbol(`kIndex`),y=Symbol(`kWeight`),b=Symbol(`kMaxWeightPerServer`),x=Symbol(`kErrorPenalty`);function S(e,t){if(e===0)return t;for(;t!==0;){let n=t;t=e%t,e=n}return e}function C(e,t){return new u(e,t)}t.exports=class extends i{constructor(e=[],{factory:t=C,...n}={}){if(super(),this[h]=n,this[v]=-1,this[_]=0,this[b]=this[h].maxWeightPerServer||100,this[x]=this[h].errorPenalty||15,Array.isArray(e)||(e=[e]),typeof t!=`function`)throw new r(`factory must be a function.`);this[f]=n.interceptors?.BalancedPool&&Array.isArray(n.interceptors.BalancedPool)?n.interceptors.BalancedPool:[],this[m]=t;for(let t of e)this.addUpstream(t);this._updateBalancedPoolStats()}addUpstream(e){let t=p(e).origin;if(this[a].find(e=>e[d].origin===t&&e.closed!==!0&&e.destroyed!==!0))return this;let n=this[m](t,Object.assign({},this[h]));this[s](n),n.on(`connect`,()=>{n[y]=Math.min(this[b],n[y]+this[x])}),n.on(`connectionError`,()=>{n[y]=Math.max(1,n[y]-this[x]),this._updateBalancedPoolStats()}),n.on(`disconnect`,(...e)=>{let t=e[2];t&&t.code===`UND_ERR_SOCKET`&&(n[y]=Math.max(1,n[y]-this[x]),this._updateBalancedPoolStats())});for(let e of this[a])e[y]=this[b];return this._updateBalancedPoolStats(),this}_updateBalancedPoolStats(){let e=0;for(let t=0;te[d].origin===t&&e.closed!==!0&&e.destroyed!==!0);return n&&this[c](n),this}get upstreams(){return this[a].filter(e=>e.closed!==!0&&e.destroyed!==!0).map(e=>e[d].origin)}[l](){if(this[a].length===0)throw new n;if(!this[a].find(e=>!e[o]&&e.closed!==!0&&e.destroyed!==!0)||this[a].map(e=>e[o]).reduce((e,t)=>e&&t,!0))return;let e=0,t=this[a].findIndex(e=>!e[o]);for(;e++this[a][t][y]&&!e[o]&&(t=this[v]),this[v]===0&&(this[_]=this[_]-this[g],this[_]<=0&&(this[_]=this[b])),e[y]>=this[_]&&!e[o])return e}return this[_]=this[a][t][y],this[v]=t,this[a][t]}}})),ct=I(((e,t)=>{let{InvalidArgumentError:n}=R(),{kClients:r,kRunning:i,kClose:a,kDestroy:o,kDispatch:s,kInterceptors:c}=ke(),l=Fe(),u=ot(),d=nt(),f=z(),p=tt(),m=Symbol(`onConnect`),h=Symbol(`onDisconnect`),g=Symbol(`onConnectionError`),_=Symbol(`maxRedirections`),v=Symbol(`onDrain`),y=Symbol(`factory`),b=Symbol(`options`);function x(e,t){return t&&t.connections===1?new d(e,t):new u(e,t)}t.exports=class extends l{constructor({factory:e=x,maxRedirections:t=0,connect:i,...a}={}){if(super(),typeof e!=`function`)throw new n(`factory must be a function.`);if(i!=null&&typeof i!=`function`&&typeof i!=`object`)throw new n(`connect must be a function or an object`);if(!Number.isInteger(t)||t<0)throw new n(`maxRedirections must be a positive number`);i&&typeof i!=`function`&&(i={...i}),this[c]=a.interceptors?.Agent&&Array.isArray(a.interceptors.Agent)?a.interceptors.Agent:[p({maxRedirections:t})],this[b]={...f.deepClone(a),connect:i},this[b].interceptors=a.interceptors?{...a.interceptors}:void 0,this[_]=t,this[y]=e,this[r]=new Map,this[v]=(e,t)=>{this.emit(`drain`,e,[this,...t])},this[m]=(e,t)=>{this.emit(`connect`,e,[this,...t])},this[h]=(e,t,n)=>{this.emit(`disconnect`,e,[this,...t],n)},this[g]=(e,t,n)=>{this.emit(`connectionError`,e,[this,...t],n)}}get[i](){let e=0;for(let t of this[r].values())e+=t[i];return e}[s](e,t){let i;if(e.origin&&(typeof e.origin==`string`||e.origin instanceof URL))i=String(e.origin);else throw new n(`opts.origin must be a non-empty string or URL.`);let a=this[r].get(i);return a||(a=this[y](e.origin,this[b]).on(`drain`,this[v]).on(`connect`,this[m]).on(`disconnect`,this[h]).on(`connectionError`,this[g]),this[r].set(i,a)),a.dispatch(e,t)}async[a](){let e=[];for(let t of this[r].values())e.push(t.close());this[r].clear(),await Promise.all(e)}async[o](e){let t=[];for(let n of this[r].values())t.push(n.destroy(e));this[r].clear(),await Promise.all(t)}}})),lt=I(((e,t)=>{let{kProxy:n,kClose:r,kDestroy:i,kDispatch:a,kInterceptors:o}=ke(),{URL:s}=L(`node:url`),c=ct(),l=ot(),u=Fe(),{InvalidArgumentError:d,RequestAbortedError:f,SecureProxyConnectionError:p}=R(),m=Le(),h=nt(),g=Symbol(`proxy agent`),_=Symbol(`proxy client`),v=Symbol(`proxy headers`),y=Symbol(`request tls settings`),b=Symbol(`proxy tls settings`),x=Symbol(`connect endpoint function`),S=Symbol(`tunnel proxy`);function C(e){return e===`https:`?443:80}function w(e,t){return new l(e,t)}let T=()=>{};function E(e,t){return t.connections===1?new h(e,t):new l(e,t)}var D=class extends u{#e;constructor(e,{headers:t={},connect:n,factory:r}){if(super(),!e)throw new d(`Proxy URL is mandatory`);this[v]=t,r?this.#e=r(e,{connect:n}):this.#e=new h(e,{connect:n})}[a](e,t){let n=t.onHeaders;t.onHeaders=function(e,r,i){if(e===407){typeof t.onError==`function`&&t.onError(new d(`Proxy Authentication Required (407)`));return}n&&n.call(this,e,r,i)};let{origin:r,path:i=`/`,headers:o={}}=e;if(e.path=r+i,!(`host`in o)&&!(`Host`in o)){let{host:e}=new s(r);o.host=e}return e.headers={...this[v],...o},this.#e[a](e,t)}async[r](){return this.#e.close()}async[i](e){return this.#e.destroy(e)}},O=class extends u{constructor(e){if(super(),!e||typeof e==`object`&&!(e instanceof s)&&!e.uri)throw new d(`Proxy uri is mandatory`);let{clientFactory:t=w}=e;if(typeof t!=`function`)throw new d(`Proxy opts.clientFactory must be a function.`);let{proxyTunnel:r=!0}=e,i=this.#e(e),{href:a,origin:l,port:u,protocol:h,username:O,password:k,hostname:A}=i;if(this[n]={uri:a,protocol:h},this[o]=e.interceptors?.ProxyAgent&&Array.isArray(e.interceptors.ProxyAgent)?e.interceptors.ProxyAgent:[],this[y]=e.requestTls,this[b]=e.proxyTls,this[v]=e.headers||{},this[S]=r,e.auth&&e.token)throw new d(`opts.auth cannot be used in combination with opts.token`);e.auth?this[v][`proxy-authorization`]=`Basic ${e.auth}`:e.token?this[v][`proxy-authorization`]=e.token:O&&k&&(this[v][`proxy-authorization`]=`Basic ${Buffer.from(`${decodeURIComponent(O)}:${decodeURIComponent(k)}`).toString(`base64`)}`);let j=m({...e.proxyTls});this[x]=m({...e.requestTls});let M=e.factory||E,N=(e,t)=>{let{protocol:r}=new s(e);return!this[S]&&r===`http:`&&this[n].protocol===`http:`?new D(this[n].uri,{headers:this[v],connect:j,factory:M}):M(e,t)};this[_]=t(i,{connect:j}),this[g]=new c({...e,factory:N,connect:async(e,t)=>{let n=e.host;e.port||(n+=`:${C(e.protocol)}`);try{let{socket:r,statusCode:i}=await this[_].connect({origin:l,port:u,path:n,signal:e.signal,headers:{...this[v],host:e.host},servername:this[b]?.servername||A});if(i!==200&&(r.on(`error`,T).destroy(),t(new f(`Proxy response (${i}) !== 200 when HTTP Tunneling`))),e.protocol!==`https:`){t(null,r);return}let a;a=this[y]?this[y].servername:e.servername,this[x]({...e,servername:a,httpSocket:r},t)}catch(e){e.code===`ERR_TLS_CERT_ALTNAME_INVALID`?t(new p(e)):t(e)}}})}dispatch(e,t){let n=k(e.headers);if(A(n),n&&!(`host`in n)&&!(`Host`in n)){let{host:t}=new s(e.origin);n.host=t}return this[g].dispatch({...e,headers:n},t)}#e(e){return typeof e==`string`?new s(e):e instanceof s?e:new s(e.uri)}async[r](){await this[g].close(),await this[_].close()}async[i](){await this[g].destroy(),await this[_].destroy()}};function k(e){if(Array.isArray(e)){let t={};for(let n=0;ne.toLowerCase()===`proxy-authorization`))throw new d(`Proxy-Authorization should be sent in ProxyAgent constructor`)}t.exports=O})),ut=I(((e,t)=>{let n=Fe(),{kClose:r,kDestroy:i,kClosed:a,kDestroyed:o,kDispatch:s,kNoProxyAgent:c,kHttpProxyAgent:l,kHttpsProxyAgent:u}=ke(),d=lt(),f=ct(),p={"http:":80,"https:":443},m=!1;t.exports=class extends n{#e=null;#t=null;#n=null;constructor(e={}){super(),this.#n=e,m||(m=!0,process.emitWarning(`EnvHttpProxyAgent is experimental, expect them to change at any time.`,{code:`UNDICI-EHPA`}));let{httpProxy:t,httpsProxy:n,noProxy:r,...i}=e;this[c]=new f(i);let a=t??process.env.http_proxy??process.env.HTTP_PROXY;a?this[l]=new d({...i,uri:a}):this[l]=this[c];let o=n??process.env.https_proxy??process.env.HTTPS_PROXY;o?this[u]=new d({...i,uri:o}):this[u]=this[l],this.#a()}[s](e,t){let n=new URL(e.origin);return this.#r(n).dispatch(e,t)}async[r](){await this[c].close(),this[l][a]||await this[l].close(),this[u][a]||await this[u].close()}async[i](e){await this[c].destroy(e),this[l][o]||await this[l].destroy(e),this[u][o]||await this[u].destroy(e)}#r(e){let{protocol:t,host:n,port:r}=e;return n=n.replace(/:\d*$/,``).toLowerCase(),r=Number.parseInt(r,10)||p[t]||0,this.#i(n,r)?t===`https:`?this[u]:this[l]:this[c]}#i(e,t){if(this.#o&&this.#a(),this.#t.length===0)return!0;if(this.#e===`*`)return!1;for(let n=0;n{let n=L(`node:assert`),{kRetryHandlerDefaultRetry:r}=ke(),{RequestRetryError:i}=R(),{isDisturbed:a,parseHeaders:o,parseRangeHeader:s,wrapRequestBody:c}=z();function l(e){let t=Date.now();return new Date(e).getTime()-t}t.exports=class e{constructor(t,n){let{retryOptions:i,...a}=t,{retry:o,maxRetries:s,maxTimeout:l,minTimeout:u,timeoutFactor:d,methods:f,errorCodes:p,retryAfter:m,statusCodes:h}=i??{};this.dispatch=n.dispatch,this.handler=n.handler,this.opts={...a,body:c(t.body)},this.abort=null,this.aborted=!1,this.retryOpts={retry:o??e[r],retryAfter:m??!0,maxTimeout:l??30*1e3,minTimeout:u??500,timeoutFactor:d??2,maxRetries:s??5,methods:f??[`GET`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`TRACE`],statusCodes:h??[500,502,503,504,429],errorCodes:p??[`ECONNRESET`,`ECONNREFUSED`,`ENOTFOUND`,`ENETDOWN`,`ENETUNREACH`,`EHOSTDOWN`,`EHOSTUNREACH`,`EPIPE`,`UND_ERR_SOCKET`]},this.retryCount=0,this.retryCountCheckpoint=0,this.start=0,this.end=null,this.etag=null,this.resume=null,this.handler.onConnect(e=>{this.aborted=!0,this.abort?this.abort(e):this.reason=e})}onRequestSent(){this.handler.onRequestSent&&this.handler.onRequestSent()}onUpgrade(e,t,n){this.handler.onUpgrade&&this.handler.onUpgrade(e,t,n)}onConnect(e){this.aborted?e(this.reason):this.abort=e}onBodySent(e){if(this.handler.onBodySent)return this.handler.onBodySent(e)}static[r](e,{state:t,opts:n},r){let{statusCode:i,code:a,headers:o}=e,{method:s,retryOptions:c}=n,{maxRetries:u,minTimeout:d,maxTimeout:f,timeoutFactor:p,statusCodes:m,errorCodes:h,methods:g}=c,{counter:_}=t;if(a&&a!==`UND_ERR_REQ_RETRY`&&!h.includes(a)){r(e);return}if(Array.isArray(g)&&!g.includes(s)){r(e);return}if(i!=null&&Array.isArray(m)&&!m.includes(i)){r(e);return}if(_>u){r(e);return}let v=o?.[`retry-after`];v&&=(v=Number(v),Number.isNaN(v)?l(v):v*1e3);let y=v>0?Math.min(v,f):Math.min(d*p**(_-1),f);setTimeout(()=>r(null),y)}onHeaders(e,t,r,a){let c=o(t);if(this.retryCount+=1,e>=300)return this.retryOpts.statusCodes.includes(e)===!1?this.handler.onHeaders(e,t,r,a):(this.abort(new i(`Request failed`,e,{headers:c,data:{count:this.retryCount}})),!1);if(this.resume!=null){if(this.resume=null,e!==206&&(this.start>0||e!==200))return this.abort(new i(`server does not support the range header and the payload was partially consumed`,e,{headers:c,data:{count:this.retryCount}})),!1;let t=s(c[`content-range`]);if(!t)return this.abort(new i(`Content-Range mismatch`,e,{headers:c,data:{count:this.retryCount}})),!1;if(this.etag!=null&&this.etag!==c.etag)return this.abort(new i(`ETag mismatch`,e,{headers:c,data:{count:this.retryCount}})),!1;let{start:a,size:o,end:l=o-1}=t;return n(this.start===a,`content-range mismatch`),n(this.end==null||this.end===l,`content-range mismatch`),this.resume=r,!0}if(this.end==null){if(e===206){let i=s(c[`content-range`]);if(i==null)return this.handler.onHeaders(e,t,r,a);let{start:o,size:l,end:u=l-1}=i;n(o!=null&&Number.isFinite(o),`content-range mismatch`),n(u!=null&&Number.isFinite(u),`invalid content-length`),this.start=o,this.end=u}if(this.end==null){let e=c[`content-length`];this.end=e==null?null:Number(e)-1}return n(Number.isFinite(this.start)),n(this.end==null||Number.isFinite(this.end),`invalid content-length`),this.resume=r,this.etag=c.etag==null?null:c.etag,this.etag!=null&&this.etag.startsWith(`W/`)&&(this.etag=null),this.handler.onHeaders(e,t,r,a)}let l=new i(`Request failed`,e,{headers:c,data:{count:this.retryCount}});return this.abort(l),!1}onData(e){return this.start+=e.length,this.handler.onData(e)}onComplete(e){return this.retryCount=0,this.handler.onComplete(e)}onError(e){if(this.aborted||a(this.opts.body))return this.handler.onError(e);this.retryCount-this.retryCountCheckpoint>0?this.retryCount=this.retryCountCheckpoint+(this.retryCount-this.retryCountCheckpoint):this.retryCount+=1,this.retryOpts.retry(e,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},t.bind(this));function t(e){if(e!=null||this.aborted||a(this.opts.body))return this.handler.onError(e);if(this.start!==0){let e={range:`bytes=${this.start}-${this.end??``}`};this.etag!=null&&(e[`if-match`]=this.etag),this.opts={...this.opts,headers:{...this.opts.headers,...e}}}try{this.retryCountCheckpoint=this.retryCount,this.dispatch(this.opts,this)}catch(e){this.handler.onError(e)}}}}})),ft=I(((e,t)=>{let n=Pe(),r=dt();t.exports=class extends n{#e=null;#t=null;constructor(e,t={}){super(t),this.#e=e,this.#t=t}dispatch(e,t){let n=new r({...e,retryOptions:this.#t},{dispatch:this.#e.dispatch.bind(this.#e),handler:t});return this.#e.dispatch(e,n)}close(){return this.#e.close()}destroy(){return this.#e.destroy()}}})),pt=I(((e,t)=>{let n=L(`node:assert`),{Readable:r}=L(`node:stream`),{RequestAbortedError:i,NotSupportedError:a,InvalidArgumentError:o,AbortError:s}=R(),c=z(),{ReadableStreamFrom:l}=z(),u=Symbol(`kConsume`),d=Symbol(`kReading`),f=Symbol(`kBody`),p=Symbol(`kAbort`),m=Symbol(`kContentType`),h=Symbol(`kContentLength`),g=()=>{};var _=class extends r{constructor({resume:e,abort:t,contentType:n=``,contentLength:r,highWaterMark:i=64*1024}){super({autoDestroy:!0,read:e,highWaterMark:i}),this._readableState.dataEmitted=!1,this[p]=t,this[u]=null,this[f]=null,this[m]=n,this[h]=r,this[d]=!1}destroy(e){return!e&&!this._readableState.endEmitted&&(e=new i),e&&this[p](),super.destroy(e)}_destroy(e,t){this[d]?t(e):setImmediate(()=>{t(e)})}on(e,...t){return(e===`data`||e===`readable`)&&(this[d]=!0),super.on(e,...t)}addListener(e,...t){return this.on(e,...t)}off(e,...t){let n=super.off(e,...t);return(e===`data`||e===`readable`)&&(this[d]=this.listenerCount(`data`)>0||this.listenerCount(`readable`)>0),n}removeListener(e,...t){return this.off(e,...t)}push(e){return this[u]&&e!==null?(T(this[u],e),this[d]?super.push(e):!0):super.push(e)}async text(){return b(this,`text`)}async json(){return b(this,`json`)}async blob(){return b(this,`blob`)}async bytes(){return b(this,`bytes`)}async arrayBuffer(){return b(this,`arrayBuffer`)}async formData(){throw new a}get bodyUsed(){return c.isDisturbed(this)}get body(){return this[f]||(this[f]=l(this),this[u]&&(this[f].getReader(),n(this[f].locked))),this[f]}async dump(e){let t=Number.isFinite(e?.limit)?e.limit:128*1024,n=e?.signal;if(n!=null&&(typeof n!=`object`||!(`aborted`in n)))throw new o(`signal must be an AbortSignal`);return n?.throwIfAborted(),this._readableState.closeEmitted?null:await new Promise((e,r)=>{this[h]>t&&this.destroy(new s);let i=()=>{this.destroy(n.reason??new s)};n?.addEventListener(`abort`,i),this.on(`close`,function(){n?.removeEventListener(`abort`,i),n?.aborted?r(n.reason??new s):e(null)}).on(`error`,g).on(`data`,function(e){t-=e.length,t<=0&&this.destroy()}).resume()})}};function v(e){return e[f]&&e[f].locked===!0||e[u]}function y(e){return c.isDisturbed(e)||v(e)}async function b(e,t){return n(!e[u]),new Promise((n,r)=>{if(y(e)){let t=e._readableState;t.destroyed&&t.closeEmitted===!1?e.on(`error`,e=>{r(e)}).on(`close`,()=>{r(TypeError(`unusable`))}):r(t.errored??TypeError(`unusable`))}else queueMicrotask(()=>{e[u]={type:t,stream:e,resolve:n,reject:r,length:0,body:[]},e.on(`error`,function(e){E(this[u],e)}).on(`close`,function(){this[u].body!==null&&E(this[u],new i)}),x(e[u])})})}function x(e){if(e.body===null)return;let{_readableState:t}=e.stream;if(t.bufferIndex){let n=t.bufferIndex,r=t.buffer.length;for(let i=n;i2&&n[0]===239&&n[1]===187&&n[2]===191?3:0;return n.utf8Slice(i,r)}function C(e,t){if(e.length===0||t===0)return new Uint8Array;if(e.length===1)return new Uint8Array(e[0]);let n=new Uint8Array(Buffer.allocUnsafeSlow(t).buffer),r=0;for(let t=0;t{let n=L(`node:assert`),{ResponseStatusCodeError:r}=R(),{chunksDecode:i}=pt();async function a({callback:e,body:t,contentType:a,statusCode:c,statusMessage:l,headers:u}){n(t);let d=[],f=0;try{for await(let e of t)if(d.push(e),f+=e.length,f>131072){d=[],f=0;break}}catch{d=[],f=0}let p=`Response status code ${c}${l?`: ${l}`:``}`;if(c===204||!a||!f){queueMicrotask(()=>e(new r(p,c,u)));return}let m=Error.stackTraceLimit;Error.stackTraceLimit=0;let h;try{o(a)?h=JSON.parse(i(d,f)):s(a)&&(h=i(d,f))}catch{}finally{Error.stackTraceLimit=m}queueMicrotask(()=>e(new r(p,c,u,h)))}let o=e=>e.length>15&&e[11]===`/`&&e[0]===`a`&&e[1]===`p`&&e[2]===`p`&&e[3]===`l`&&e[4]===`i`&&e[5]===`c`&&e[6]===`a`&&e[7]===`t`&&e[8]===`i`&&e[9]===`o`&&e[10]===`n`&&e[12]===`j`&&e[13]===`s`&&e[14]===`o`&&e[15]===`n`,s=e=>e.length>4&&e[4]===`/`&&e[0]===`t`&&e[1]===`e`&&e[2]===`x`&&e[3]===`t`;t.exports={getResolveErrorBodyCallback:a,isContentTypeApplicationJson:o,isContentTypeText:s}})),ht=I(((e,t)=>{let n=L(`node:assert`),{Readable:r}=pt(),{InvalidArgumentError:i,RequestAbortedError:a}=R(),o=z(),{getResolveErrorBodyCallback:s}=mt(),{AsyncResource:c}=L(`node:async_hooks`);var l=class extends c{constructor(e,t){if(!e||typeof e!=`object`)throw new i(`invalid opts`);let{signal:n,method:r,opaque:s,body:c,onInfo:l,responseHeaders:u,throwOnError:d,highWaterMark:f}=e;try{if(typeof t!=`function`)throw new i(`invalid callback`);if(f&&(typeof f!=`number`||f<0))throw new i(`invalid highWaterMark`);if(n&&typeof n.on!=`function`&&typeof n.addEventListener!=`function`)throw new i(`signal must be an EventEmitter or EventTarget`);if(r===`CONNECT`)throw new i(`invalid method`);if(l&&typeof l!=`function`)throw new i(`invalid onInfo callback`);super(`UNDICI_REQUEST`)}catch(e){throw o.isStream(c)&&o.destroy(c.on(`error`,o.nop),e),e}this.method=r,this.responseHeaders=u||null,this.opaque=s||null,this.callback=t,this.res=null,this.abort=null,this.body=c,this.trailers={},this.context=null,this.onInfo=l||null,this.throwOnError=d,this.highWaterMark=f,this.signal=n,this.reason=null,this.removeAbortListener=null,o.isStream(c)&&c.on(`error`,e=>{this.onError(e)}),this.signal&&(this.signal.aborted?this.reason=this.signal.reason??new a:this.removeAbortListener=o.addAbortListener(this.signal,()=>{this.reason=this.signal.reason??new a,this.res?o.destroy(this.res.on(`error`,o.nop),this.reason):this.abort&&this.abort(this.reason),this.removeAbortListener&&=(this.res?.off(`close`,this.removeAbortListener),this.removeAbortListener(),null)}))}onConnect(e,t){if(this.reason){e(this.reason);return}n(this.callback),this.abort=e,this.context=t}onHeaders(e,t,n,i){let{callback:a,opaque:c,abort:l,context:u,responseHeaders:d,highWaterMark:f}=this,p=d===`raw`?o.parseRawHeaders(t):o.parseHeaders(t);if(e<200){this.onInfo&&this.onInfo({statusCode:e,headers:p});return}let m=d===`raw`?o.parseHeaders(t):p,h=m[`content-type`],g=m[`content-length`],_=new r({resume:n,abort:l,contentType:h,contentLength:this.method!==`HEAD`&&g?Number(g):null,highWaterMark:f});this.removeAbortListener&&_.on(`close`,this.removeAbortListener),this.callback=null,this.res=_,a!==null&&(this.throwOnError&&e>=400?this.runInAsyncScope(s,null,{callback:a,body:_,contentType:h,statusCode:e,statusMessage:i,headers:p}):this.runInAsyncScope(a,null,null,{statusCode:e,headers:p,trailers:this.trailers,opaque:c,body:_,context:u}))}onData(e){return this.res.push(e)}onComplete(e){o.parseHeaders(e,this.trailers),this.res.push(null)}onError(e){let{res:t,callback:n,body:r,opaque:i}=this;n&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(n,null,e,{opaque:i})})),t&&(this.res=null,queueMicrotask(()=>{o.destroy(t,e)})),r&&(this.body=null,o.destroy(r,e)),this.removeAbortListener&&=(t?.off(`close`,this.removeAbortListener),this.removeAbortListener(),null)}};function u(e,t){if(t===void 0)return new Promise((t,n)=>{u.call(this,e,(e,r)=>e?n(e):t(r))});try{this.dispatch(e,new l(e,t))}catch(n){if(typeof t!=`function`)throw n;let r=e?.opaque;queueMicrotask(()=>t(n,{opaque:r}))}}t.exports=u,t.exports.RequestHandler=l})),gt=I(((e,t)=>{let{addAbortListener:n}=z(),{RequestAbortedError:r}=R(),i=Symbol(`kListener`),a=Symbol(`kSignal`);function o(e){e.abort?e.abort(e[a]?.reason):e.reason=e[a]?.reason??new r,c(e)}function s(e,t){if(e.reason=null,e[a]=null,e[i]=null,t){if(t.aborted){o(e);return}e[a]=t,e[i]=()=>{o(e)},n(e[a],e[i])}}function c(e){e[a]&&(`removeEventListener`in e[a]?e[a].removeEventListener(`abort`,e[i]):e[a].removeListener(`abort`,e[i]),e[a]=null,e[i]=null)}t.exports={addSignal:s,removeSignal:c}})),_t=I(((e,t)=>{let n=L(`node:assert`),{finished:r,PassThrough:i}=L(`node:stream`),{InvalidArgumentError:a,InvalidReturnValueError:o}=R(),s=z(),{getResolveErrorBodyCallback:c}=mt(),{AsyncResource:l}=L(`node:async_hooks`),{addSignal:u,removeSignal:d}=gt();var f=class extends l{constructor(e,t,n){if(!e||typeof e!=`object`)throw new a(`invalid opts`);let{signal:r,method:i,opaque:o,body:c,onInfo:l,responseHeaders:d,throwOnError:f}=e;try{if(typeof n!=`function`)throw new a(`invalid callback`);if(typeof t!=`function`)throw new a(`invalid factory`);if(r&&typeof r.on!=`function`&&typeof r.addEventListener!=`function`)throw new a(`signal must be an EventEmitter or EventTarget`);if(i===`CONNECT`)throw new a(`invalid method`);if(l&&typeof l!=`function`)throw new a(`invalid onInfo callback`);super(`UNDICI_STREAM`)}catch(e){throw s.isStream(c)&&s.destroy(c.on(`error`,s.nop),e),e}this.responseHeaders=d||null,this.opaque=o||null,this.factory=t,this.callback=n,this.res=null,this.abort=null,this.context=null,this.trailers=null,this.body=c,this.onInfo=l||null,this.throwOnError=f||!1,s.isStream(c)&&c.on(`error`,e=>{this.onError(e)}),u(this,r)}onConnect(e,t){if(this.reason){e(this.reason);return}n(this.callback),this.abort=e,this.context=t}onHeaders(e,t,n,a){let{factory:l,opaque:u,context:d,callback:f,responseHeaders:p}=this,m=p===`raw`?s.parseRawHeaders(t):s.parseHeaders(t);if(e<200){this.onInfo&&this.onInfo({statusCode:e,headers:m});return}this.factory=null;let h;if(this.throwOnError&&e>=400){let n=(p===`raw`?s.parseHeaders(t):m)[`content-type`];h=new i,this.callback=null,this.runInAsyncScope(c,null,{callback:f,body:h,contentType:n,statusCode:e,statusMessage:a,headers:m})}else{if(l===null)return;if(h=this.runInAsyncScope(l,null,{statusCode:e,headers:m,opaque:u,context:d}),!h||typeof h.write!=`function`||typeof h.end!=`function`||typeof h.on!=`function`)throw new o(`expected Writable`);r(h,{readable:!1},e=>{let{callback:t,res:n,opaque:r,trailers:i,abort:a}=this;this.res=null,(e||!n.readable)&&s.destroy(n,e),this.callback=null,this.runInAsyncScope(t,null,e||null,{opaque:r,trailers:i}),e&&a()})}return h.on(`drain`,n),this.res=h,(h.writableNeedDrain===void 0?h._writableState?.needDrain:h.writableNeedDrain)!==!0}onData(e){let{res:t}=this;return t?t.write(e):!0}onComplete(e){let{res:t}=this;d(this),t&&(this.trailers=s.parseHeaders(e),t.end())}onError(e){let{res:t,callback:n,opaque:r,body:i}=this;d(this),this.factory=null,t?(this.res=null,s.destroy(t,e)):n&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(n,null,e,{opaque:r})})),i&&(this.body=null,s.destroy(i,e))}};function p(e,t,n){if(n===void 0)return new Promise((n,r)=>{p.call(this,e,t,(e,t)=>e?r(e):n(t))});try{this.dispatch(e,new f(e,t,n))}catch(t){if(typeof n!=`function`)throw t;let r=e?.opaque;queueMicrotask(()=>n(t,{opaque:r}))}}t.exports=p})),vt=I(((e,t)=>{let{Readable:n,Duplex:r,PassThrough:i}=L(`node:stream`),{InvalidArgumentError:a,InvalidReturnValueError:o,RequestAbortedError:s}=R(),c=z(),{AsyncResource:l}=L(`node:async_hooks`),{addSignal:u,removeSignal:d}=gt(),f=L(`node:assert`),p=Symbol(`resume`);var m=class extends n{constructor(){super({autoDestroy:!0}),this[p]=null}_read(){let{[p]:e}=this;e&&(this[p]=null,e())}_destroy(e,t){this._read(),t(e)}},h=class extends n{constructor(e){super({autoDestroy:!0}),this[p]=e}_read(){this[p]()}_destroy(e,t){!e&&!this._readableState.endEmitted&&(e=new s),t(e)}},g=class extends l{constructor(e,t){if(!e||typeof e!=`object`)throw new a(`invalid opts`);if(typeof t!=`function`)throw new a(`invalid handler`);let{signal:n,method:i,opaque:o,onInfo:l,responseHeaders:f}=e;if(n&&typeof n.on!=`function`&&typeof n.addEventListener!=`function`)throw new a(`signal must be an EventEmitter or EventTarget`);if(i===`CONNECT`)throw new a(`invalid method`);if(l&&typeof l!=`function`)throw new a(`invalid onInfo callback`);super(`UNDICI_PIPELINE`),this.opaque=o||null,this.responseHeaders=f||null,this.handler=t,this.abort=null,this.context=null,this.onInfo=l||null,this.req=new m().on(`error`,c.nop),this.ret=new r({readableObjectMode:e.objectMode,autoDestroy:!0,read:()=>{let{body:e}=this;e?.resume&&e.resume()},write:(e,t,n)=>{let{req:r}=this;r.push(e,t)||r._readableState.destroyed?n():r[p]=n},destroy:(e,t)=>{let{body:n,req:r,res:i,ret:a,abort:o}=this;!e&&!a._readableState.endEmitted&&(e=new s),o&&e&&o(),c.destroy(n,e),c.destroy(r,e),c.destroy(i,e),d(this),t(e)}}).on(`prefinish`,()=>{let{req:e}=this;e.push(null)}),this.res=null,u(this,n)}onConnect(e,t){let{ret:n,res:r}=this;if(this.reason){e(this.reason);return}f(!r,`pipeline cannot be retried`),f(!n.destroyed),this.abort=e,this.context=t}onHeaders(e,t,n){let{opaque:r,handler:i,context:a}=this;if(e<200){if(this.onInfo){let n=this.responseHeaders===`raw`?c.parseRawHeaders(t):c.parseHeaders(t);this.onInfo({statusCode:e,headers:n})}return}this.res=new h(n);let l;try{this.handler=null;let n=this.responseHeaders===`raw`?c.parseRawHeaders(t):c.parseHeaders(t);l=this.runInAsyncScope(i,null,{statusCode:e,headers:n,opaque:r,body:this.res,context:a})}catch(e){throw this.res.on(`error`,c.nop),e}if(!l||typeof l.on!=`function`)throw new o(`expected Readable`);l.on(`data`,e=>{let{ret:t,body:n}=this;!t.push(e)&&n.pause&&n.pause()}).on(`error`,e=>{let{ret:t}=this;c.destroy(t,e)}).on(`end`,()=>{let{ret:e}=this;e.push(null)}).on(`close`,()=>{let{ret:e}=this;e._readableState.ended||c.destroy(e,new s)}),this.body=l}onData(e){let{res:t}=this;return t.push(e)}onComplete(e){let{res:t}=this;t.push(null)}onError(e){let{ret:t}=this;this.handler=null,c.destroy(t,e)}};function _(e,t){try{let n=new g(e,t);return this.dispatch({...e,body:n.req},n),n.ret}catch(e){return new i().destroy(e)}}t.exports=_})),yt=I(((e,t)=>{let{InvalidArgumentError:n,SocketError:r}=R(),{AsyncResource:i}=L(`node:async_hooks`),a=z(),{addSignal:o,removeSignal:s}=gt(),c=L(`node:assert`);var l=class extends i{constructor(e,t){if(!e||typeof e!=`object`)throw new n(`invalid opts`);if(typeof t!=`function`)throw new n(`invalid callback`);let{signal:r,opaque:i,responseHeaders:a}=e;if(r&&typeof r.on!=`function`&&typeof r.addEventListener!=`function`)throw new n(`signal must be an EventEmitter or EventTarget`);super(`UNDICI_UPGRADE`),this.responseHeaders=a||null,this.opaque=i||null,this.callback=t,this.abort=null,this.context=null,o(this,r)}onConnect(e,t){if(this.reason){e(this.reason);return}c(this.callback),this.abort=e,this.context=null}onHeaders(){throw new r(`bad upgrade`,null)}onUpgrade(e,t,n){c(e===101);let{callback:r,opaque:i,context:o}=this;s(this),this.callback=null;let l=this.responseHeaders===`raw`?a.parseRawHeaders(t):a.parseHeaders(t);this.runInAsyncScope(r,null,null,{headers:l,socket:n,opaque:i,context:o})}onError(e){let{callback:t,opaque:n}=this;s(this),t&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(t,null,e,{opaque:n})}))}};function u(e,t){if(t===void 0)return new Promise((t,n)=>{u.call(this,e,(e,r)=>e?n(e):t(r))});try{let n=new l(e,t);this.dispatch({...e,method:e.method||`GET`,upgrade:e.protocol||`Websocket`},n)}catch(n){if(typeof t!=`function`)throw n;let r=e?.opaque;queueMicrotask(()=>t(n,{opaque:r}))}}t.exports=u})),bt=I(((e,t)=>{let n=L(`node:assert`),{AsyncResource:r}=L(`node:async_hooks`),{InvalidArgumentError:i,SocketError:a}=R(),o=z(),{addSignal:s,removeSignal:c}=gt();var l=class extends r{constructor(e,t){if(!e||typeof e!=`object`)throw new i(`invalid opts`);if(typeof t!=`function`)throw new i(`invalid callback`);let{signal:n,opaque:r,responseHeaders:a}=e;if(n&&typeof n.on!=`function`&&typeof n.addEventListener!=`function`)throw new i(`signal must be an EventEmitter or EventTarget`);super(`UNDICI_CONNECT`),this.opaque=r||null,this.responseHeaders=a||null,this.callback=t,this.abort=null,s(this,n)}onConnect(e,t){if(this.reason){e(this.reason);return}n(this.callback),this.abort=e,this.context=t}onHeaders(){throw new a(`bad connect`,null)}onUpgrade(e,t,n){let{callback:r,opaque:i,context:a}=this;c(this),this.callback=null;let s=t;s!=null&&(s=this.responseHeaders===`raw`?o.parseRawHeaders(t):o.parseHeaders(t)),this.runInAsyncScope(r,null,null,{statusCode:e,headers:s,socket:n,opaque:i,context:a})}onError(e){let{callback:t,opaque:n}=this;c(this),t&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(t,null,e,{opaque:n})}))}};function u(e,t){if(t===void 0)return new Promise((t,n)=>{u.call(this,e,(e,r)=>e?n(e):t(r))});try{let n=new l(e,t);this.dispatch({...e,method:`CONNECT`},n)}catch(n){if(typeof t!=`function`)throw n;let r=e?.opaque;queueMicrotask(()=>t(n,{opaque:r}))}}t.exports=u})),xt=I(((e,t)=>{t.exports.request=ht(),t.exports.stream=_t(),t.exports.pipeline=vt(),t.exports.upgrade=yt(),t.exports.connect=bt()})),St=I(((e,t)=>{let{UndiciError:n}=R(),r=Symbol.for(`undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED`);t.exports={MockNotMatchedError:class e extends n{constructor(t){super(t),Error.captureStackTrace(this,e),this.name=`MockNotMatchedError`,this.message=t||`The request does not match any registered mock dispatches`,this.code=`UND_MOCK_ERR_MOCK_NOT_MATCHED`}static[Symbol.hasInstance](e){return e&&e[r]===!0}[r]=!0}}})),Ct=I(((e,t)=>{t.exports={kAgent:Symbol(`agent`),kOptions:Symbol(`options`),kFactory:Symbol(`factory`),kDispatches:Symbol(`dispatches`),kDispatchKey:Symbol(`dispatch key`),kDefaultHeaders:Symbol(`default headers`),kDefaultTrailers:Symbol(`default trailers`),kContentLength:Symbol(`content length`),kMockAgent:Symbol(`mock agent`),kMockAgentSet:Symbol(`mock agent set`),kMockAgentGet:Symbol(`mock agent get`),kMockDispatch:Symbol(`mock dispatch`),kClose:Symbol(`close`),kOriginalClose:Symbol(`original agent close`),kOrigin:Symbol(`origin`),kIsMockActive:Symbol(`is mock active`),kNetConnect:Symbol(`net connect`),kGetNetConnect:Symbol(`get net connect`),kConnected:Symbol(`connected`)}})),wt=I(((e,t)=>{let{MockNotMatchedError:n}=St(),{kDispatches:r,kMockAgent:i,kOriginalDispatch:a,kOrigin:o,kGetNetConnect:s}=Ct(),{buildURL:c}=z(),{STATUS_CODES:l}=L(`node:http`),{types:{isPromise:u}}=L(`node:util`);function d(e,t){return typeof e==`string`?e===t:e instanceof RegExp?e.test(t):typeof e==`function`?e(t)===!0:!1}function f(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e.toLocaleLowerCase(),t]))}function p(e,t){if(Array.isArray(e)){for(let n=0;n!e).filter(({path:e})=>d(g(e),i));if(a.length===0)throw new n(`Mock dispatch not matched for path '${i}'`);if(a=a.filter(({method:e})=>d(e,t.method)),a.length===0)throw new n(`Mock dispatch not matched for method '${t.method}' on path '${i}'`);if(a=a.filter(({body:e})=>e===void 0?!0:d(e,t.body)),a.length===0)throw new n(`Mock dispatch not matched for body '${t.body}' on path '${i}'`);if(a=a.filter(e=>h(e,t.headers)),a.length===0)throw new n(`Mock dispatch not matched for headers '${typeof t.headers==`object`?JSON.stringify(t.headers):t.headers}' on path '${i}'`);return a[0]}function b(e,t,n){let r={timesInvoked:0,times:1,persist:!1,consumed:!1},i=typeof n==`function`?{callback:n}:{...n},a={...r,...t,pending:!0,data:{error:null,...i}};return e.push(a),a}function x(e,t){let n=e.findIndex(e=>e.consumed?_(e,t):!1);n!==-1&&e.splice(n,1)}function S(e){let{path:t,method:n,body:r,headers:i,query:a}=e;return{path:t,method:n,body:r,headers:i,query:a}}function C(e){let t=Object.keys(e),n=[];for(let r=0;r=h,i.pending=p0?setTimeout(()=>{g(this[r])},d):g(this[r]);function g(r,i=o){let l=Array.isArray(e.headers)?m(e.headers):e.headers,d=typeof i==`function`?i({...e,headers:l}):i;if(u(d)){d.then(e=>g(r,e));return}let f=v(d),p=C(s),h=C(c);t.onConnect?.(e=>t.onError(e),null),t.onHeaders?.(a,p,_,w(a)),t.onData?.(Buffer.from(f)),t.onComplete?.(h),x(r,n)}function _(){}return!0}function D(){let e=this[i],t=this[o],r=this[a];return function(i,a){if(e.isMockActive)try{E.call(this,i,a)}catch(o){if(o instanceof n){let c=e[s]();if(c===!1)throw new n(`${o.message}: subsequent request to origin ${t} was not allowed (net.connect disabled)`);if(O(c,t))r.call(this,i,a);else throw new n(`${o.message}: subsequent request to origin ${t} was not allowed (net.connect is not enabled for this origin)`)}else throw o}else r.call(this,i,a)}}function O(e,t){let n=new URL(t);return e===!0?!0:!!(Array.isArray(e)&&e.some(e=>d(e,n.host)))}function k(e){if(e){let{agent:t,...n}=e;return n}}t.exports={getResponseData:v,getMockDispatch:y,addMockDispatch:b,deleteMockDispatch:x,buildKey:S,generateKeyValues:C,matchValue:d,getResponse:T,getStatusText:w,mockDispatch:E,buildMockDispatch:D,checkNetConnect:O,buildMockOptions:k,getHeaderByName:p,buildHeadersFromArray:m}})),Tt=I(((e,t)=>{let{getResponseData:n,buildKey:r,addMockDispatch:i}=wt(),{kDispatches:a,kDispatchKey:o,kDefaultHeaders:s,kDefaultTrailers:c,kContentLength:l,kMockDispatch:u}=Ct(),{InvalidArgumentError:d}=R(),{buildURL:f}=z();var p=class{constructor(e){this[u]=e}delay(e){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw new d(`waitInMs must be a valid integer > 0`);return this[u].delay=e,this}persist(){return this[u].persist=!0,this}times(e){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw new d(`repeatTimes must be a valid integer > 0`);return this[u].times=e,this}},m=class{constructor(e,t){if(typeof e!=`object`)throw new d(`opts must be an object`);if(e.path===void 0)throw new d(`opts.path must be defined`);if(e.method===void 0&&(e.method=`GET`),typeof e.path==`string`)if(e.query)e.path=f(e.path,e.query);else{let t=new URL(e.path,`data://`);e.path=t.pathname+t.search}typeof e.method==`string`&&(e.method=e.method.toUpperCase()),this[o]=r(e),this[a]=t,this[s]={},this[c]={},this[l]=!1}createMockScopeDispatchData({statusCode:e,data:t,responseOptions:r}){let i=n(t),a=this[l]?{"content-length":i.length}:{};return{statusCode:e,data:t,headers:{...this[s],...a,...r.headers},trailers:{...this[c],...r.trailers}}}validateReplyParameters(e){if(e.statusCode===void 0)throw new d(`statusCode must be defined`);if(typeof e.responseOptions!=`object`||e.responseOptions===null)throw new d(`responseOptions must be an object`)}reply(e){if(typeof e==`function`)return new p(i(this[a],this[o],t=>{let n=e(t);if(typeof n!=`object`||!n)throw new d(`reply options callback must return an object`);let r={data:``,responseOptions:{},...n};return this.validateReplyParameters(r),{...this.createMockScopeDispatchData(r)}}));let t={statusCode:e,data:arguments[1]===void 0?``:arguments[1],responseOptions:arguments[2]===void 0?{}:arguments[2]};this.validateReplyParameters(t);let n=this.createMockScopeDispatchData(t);return new p(i(this[a],this[o],n))}replyWithError(e){if(e===void 0)throw new d(`error must be defined`);return new p(i(this[a],this[o],{error:e}))}defaultReplyHeaders(e){if(e===void 0)throw new d(`headers must be defined`);return this[s]=e,this}defaultReplyTrailers(e){if(e===void 0)throw new d(`trailers must be defined`);return this[c]=e,this}replyContentLength(){return this[l]=!0,this}};t.exports.MockInterceptor=m,t.exports.MockScope=p})),Et=I(((e,t)=>{let{promisify:n}=L(`node:util`),r=nt(),{buildMockDispatch:i}=wt(),{kDispatches:a,kMockAgent:o,kClose:s,kOriginalClose:c,kOrigin:l,kOriginalDispatch:u,kConnected:d}=Ct(),{MockInterceptor:f}=Tt(),p=ke(),{InvalidArgumentError:m}=R();t.exports=class extends r{constructor(e,t){if(super(e,t),!t||!t.agent||typeof t.agent.dispatch!=`function`)throw new m(`Argument opts.agent must implement Agent`);this[o]=t.agent,this[l]=e,this[a]=[],this[d]=1,this[u]=this.dispatch,this[c]=this.close.bind(this),this.dispatch=i.call(this),this.close=this[s]}get[p.kConnected](){return this[d]}intercept(e){return new f(e,this[a])}async[s](){await n(this[c])(),this[d]=0,this[o][p.kClients].delete(this[l])}}})),Dt=I(((e,t)=>{let{promisify:n}=L(`node:util`),r=ot(),{buildMockDispatch:i}=wt(),{kDispatches:a,kMockAgent:o,kClose:s,kOriginalClose:c,kOrigin:l,kOriginalDispatch:u,kConnected:d}=Ct(),{MockInterceptor:f}=Tt(),p=ke(),{InvalidArgumentError:m}=R();t.exports=class extends r{constructor(e,t){if(super(e,t),!t||!t.agent||typeof t.agent.dispatch!=`function`)throw new m(`Argument opts.agent must implement Agent`);this[o]=t.agent,this[l]=e,this[a]=[],this[d]=1,this[u]=this.dispatch,this[c]=this.close.bind(this),this.dispatch=i.call(this),this.close=this[s]}get[p.kConnected](){return this[d]}intercept(e){return new f(e,this[a])}async[s](){await n(this[c])(),this[d]=0,this[o][p.kClients].delete(this[l])}}})),Ot=I(((e,t)=>{let n={pronoun:`it`,is:`is`,was:`was`,this:`this`},r={pronoun:`they`,is:`are`,was:`were`,this:`these`};t.exports=class{constructor(e,t){this.singular=e,this.plural=t}pluralize(e){let t=e===1,i=t?n:r,a=t?this.singular:this.plural;return{...i,count:e,noun:a}}}})),kt=I(((e,t)=>{let{Transform:n}=L(`node:stream`),{Console:r}=L(`node:console`),i=process.versions.icu?`✅`:`Y `,a=process.versions.icu?`❌`:`N `;t.exports=class{constructor({disableColors:e}={}){this.transform=new n({transform(e,t,n){n(null,e)}}),this.logger=new r({stdout:this.transform,inspectOptions:{colors:!e&&!process.env.CI}})}format(e){let t=e.map(({method:e,path:t,data:{statusCode:n},persist:r,times:o,timesInvoked:s,origin:c})=>({Method:e,Origin:c,Path:t,"Status code":n,Persistent:r?i:a,Invocations:s,Remaining:r?1/0:o-s}));return this.logger.table(t),this.transform.read().toString()}}})),At=I(((e,t)=>{let{kClients:n}=ke(),r=ct(),{kAgent:i,kMockAgentSet:a,kMockAgentGet:o,kDispatches:s,kIsMockActive:c,kNetConnect:l,kGetNetConnect:u,kOptions:d,kFactory:f}=Ct(),p=Et(),m=Dt(),{matchValue:h,buildMockOptions:g}=wt(),{InvalidArgumentError:_,UndiciError:v}=R(),y=Pe(),b=Ot(),x=kt();t.exports=class extends y{constructor(e){if(super(e),this[l]=!0,this[c]=!0,e?.agent&&typeof e.agent.dispatch!=`function`)throw new _(`Argument opts.agent must implement Agent`);let t=e?.agent?e.agent:new r(e);this[i]=t,this[n]=t[n],this[d]=g(e)}get(e){let t=this[o](e);return t||(t=this[f](e),this[a](e,t)),t}dispatch(e,t){return this.get(e.origin),this[i].dispatch(e,t)}async close(){await this[i].close(),this[n].clear()}deactivate(){this[c]=!1}activate(){this[c]=!0}enableNetConnect(e){if(typeof e==`string`||typeof e==`function`||e instanceof RegExp)Array.isArray(this[l])?this[l].push(e):this[l]=[e];else if(e===void 0)this[l]=!0;else throw new _(`Unsupported matcher. Must be one of String|Function|RegExp.`)}disableNetConnect(){this[l]=!1}get isMockActive(){return this[c]}[a](e,t){this[n].set(e,t)}[f](e){let t=Object.assign({agent:this},this[d]);return this[d]&&this[d].connections===1?new p(e,t):new m(e,t)}[o](e){let t=this[n].get(e);if(t)return t;if(typeof e!=`string`){let t=this[f](`http://localhost:9999`);return this[a](e,t),t}for(let[t,r]of Array.from(this[n]))if(r&&typeof t!=`string`&&h(t,e)){let t=this[f](e);return this[a](e,t),t[s]=r[s],t}}[u](){return this[l]}pendingInterceptors(){let e=this[n];return Array.from(e.entries()).flatMap(([e,t])=>t[s].map(t=>({...t,origin:e}))).filter(({pending:e})=>e)}assertNoPendingInterceptors({pendingInterceptorsFormatter:e=new x}={}){let t=this.pendingInterceptors();if(t.length===0)return;let n=new b(`interceptor`,`interceptors`).pluralize(t.length);throw new v(` +`,`latin1`),t!==null&&r!==t){if(n[ie])throw new o;process.emitWarning(new o)}e[y].timeout&&e[y].timeoutType===3&&e[y].timeout.refresh&&e[y].timeout.refresh(),n[le]()}}destroy(e){let{socket:t,client:r,abort:i}=this;t[w]=!1,e&&(n(r[x]<=1,`pipeline should only contain this request`),i(e))}};t.exports=Te})),$e=I(((e,t)=>{let n=L(`node:assert`),{pipeline:r}=L(`node:stream`),i=z(),{RequestContentLengthMismatchError:a,RequestAbortedError:o,SocketError:s,InformationalError:c}=R(),{kUrl:l,kReset:u,kClient:d,kRunning:f,kPending:p,kQueue:m,kPendingIdx:h,kRunningIdx:g,kError:_,kSocket:v,kStrictContentLength:y,kOnError:b,kMaxConcurrentStreams:x,kHTTP2Session:S,kResume:C,kSize:w,kHTTPContext:T}=ke(),E=Symbol(`open streams`),D,O=!1,k;try{k=L(`node:http2`)}catch{k={constants:{}}}let{constants:{HTTP2_HEADER_AUTHORITY:A,HTTP2_HEADER_METHOD:j,HTTP2_HEADER_PATH:M,HTTP2_HEADER_SCHEME:N,HTTP2_HEADER_CONTENT_LENGTH:P,HTTP2_HEADER_EXPECT:ee,HTTP2_HEADER_STATUS:te}}=k;function ne(e){let t=[];for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r)t.push(Buffer.from(n),Buffer.from(e));else t.push(Buffer.from(n),Buffer.from(r));return t}async function F(e,t){e[v]=t,O||(O=!0,process.emitWarning(`H2 support is experimental, expect them to change at any time.`,{code:`UNDICI-H2`}));let r=k.connect(e[l],{createConnection:()=>t,peerMaxConcurrentStreams:e[x]});r[E]=0,r[d]=e,r[v]=t,i.addListener(r,`error`,ie),i.addListener(r,`frameError`,ae),i.addListener(r,`end`,oe),i.addListener(r,`goaway`,se),i.addListener(r,`close`,function(){let{[d]:e}=this,{[v]:t}=e,r=this[v][_]||this[_]||new s(`closed`,i.getSocketInfo(t));if(e[S]=null,e.destroyed){n(e[p]===0);let t=e[m].splice(e[g]);for(let n=0;n{a=!0}),{version:`h2`,defaultPipelining:1/0,write(...t){return le(e,...t)},resume(){re(e)},destroy(e,n){a?queueMicrotask(n):t.destroy(e).on(`close`,n)},get destroyed(){return t.destroyed},busy(){return!1}}}function re(e){let t=e[v];t?.destroyed===!1&&(e[w]===0&&e[x]===0?(t.unref(),e[S].unref()):(t.ref(),e[S].ref()))}function ie(e){n(e.code!==`ERR_TLS_CERT_ALTNAME_INVALID`),this[v][_]=e,this[d][b](e)}function ae(e,t,n){if(n===0){let n=new c(`HTTP/2: "frameError" received - type ${e}, code ${t}`);this[v][_]=n,this[d][b](n)}}function oe(){let e=new s(`other side closed`,i.getSocketInfo(this[v]));this.destroy(e),i.destroy(this[v],e)}function se(e){let t=this[_]||new s(`HTTP/2: "GOAWAY" frame received with code ${e}`,i.getSocketInfo(this)),r=this[d];if(r[v]=null,r[T]=null,this[S]!=null&&(this[S].destroy(t),this[S]=null),i.destroy(this[v],t),r[g]{t.aborted||t.completed||(n||=new o,i.errorRequest(e,t,n),T!=null&&i.destroy(T,n),i.destroy(x,n),e[m][e[g]++]=null,e[C]())};try{t.onConnect(F)}catch(n){i.errorRequest(e,t,n)}if(t.aborted)return!1;if(s===`CONNECT`)return r.ref(),T=r.request(w,{endStream:!1,signal:_}),T.id&&!T.pending?(t.onUpgrade(null,null,T),++r[E],e[m][e[g]++]=null):T.once(`ready`,()=>{t.onUpgrade(null,null,T),++r[E],e[m][e[g]++]=null}),T.once(`close`,()=>{--r[E],r[E]===0&&r.unref()}),!0;w[M]=u,w[N]=`https`;let re=s===`PUT`||s===`POST`||s===`PATCH`;x&&typeof x.read==`function`&&x.read(0);let ie=i.bodyLength(x);if(i.isFormDataLike(x)){D??=Ze().extractBody;let[e,t]=D(x);w[`content-type`]=t,x=e.stream,ie=e.length}if(ie??=t.contentLength,(ie===0||!re)&&(ie=null),ce(s)&&ie>0&&t.contentLength!=null&&t.contentLength!==ie){if(e[y])return i.errorRequest(e,t,new a),!1;process.emitWarning(new a)}ie!=null&&(n(x,`no body must not have content length`),w[P]=`${ie}`),r.ref();let ae=s===`GET`||s===`HEAD`||x===null;return p?(w[ee]=`100-continue`,T=r.request(w,{endStream:ae,signal:_}),T.once(`continue`,oe)):(T=r.request(w,{endStream:ae,signal:_}),oe()),++r[E],T.once(`response`,n=>{let{[te]:r,...a}=n;if(t.onResponseStarted(),t.aborted){let n=new o;i.errorRequest(e,t,n),i.destroy(T,n);return}t.onHeaders(Number(r),ne(a),T.resume.bind(T),``)===!1&&T.pause(),T.on(`data`,e=>{t.onData(e)===!1&&T.pause()})}),T.once(`end`,()=>{(T.state?.state==null||T.state.state<6)&&t.onComplete([]),r[E]===0&&r.unref(),F(new c(`HTTP/2: stream half-closed (remote)`)),e[m][e[g]++]=null,e[h]=e[g],e[C]()}),T.once(`close`,()=>{--r[E],r[E]===0&&r.unref()}),T.once(`error`,function(e){F(e)}),T.once(`frameError`,(e,t)=>{F(new c(`HTTP/2: "frameError" received - type ${e}, code ${t}`))}),!0;function oe(){!x||ie===0?ue(F,T,null,e,t,e[v],ie,re):i.isBuffer(x)?ue(F,T,x,e,t,e[v],ie,re):i.isBlobLike(x)?typeof x.stream==`function`?fe(F,T,x.stream(),e,t,e[v],ie,re):I(F,T,x,e,t,e[v],ie,re):i.isStream(x)?de(F,e[v],re,T,x,e,t,ie):i.isIterable(x)?fe(F,T,x,e,t,e[v],ie,re):n(!1)}}function ue(e,t,r,a,o,s,c,l){try{r!=null&&i.isBuffer(r)&&(n(c===r.byteLength,`buffer body must have content length`),t.cork(),t.write(r),t.uncork(),t.end(),o.onBodySent(r)),l||(s[u]=!0),o.onRequestSent(),a[C]()}catch(t){e(t)}}function de(e,t,a,o,s,c,l,d){n(d!==0||c[f]===0,`stream body cannot be pipelined`);let p=r(s,o,n=>{n?(i.destroy(p,n),e(n)):(i.removeAllListeners(p),l.onRequestSent(),a||(t[u]=!0),c[C]())});i.addListener(p,`data`,m);function m(e){l.onBodySent(e)}}async function I(e,t,r,i,o,s,c,l){n(c===r.size,`blob body must have content length`);try{if(c!=null&&c!==r.size)throw new a;let e=Buffer.from(await r.arrayBuffer());t.cork(),t.write(e),t.uncork(),t.end(),o.onBodySent(e),o.onRequestSent(),l||(s[u]=!0),i[C]()}catch(t){e(t)}}async function fe(e,t,r,i,a,o,s,c){n(s!==0||i[f]===0,`iterator body cannot be pipelined`);let l=null;function d(){if(l){let e=l;l=null,e()}}let p=()=>new Promise((e,t)=>{n(l===null),o[_]?t(o[_]):l=e});t.on(`close`,d).on(`drain`,d);try{for await(let e of r){if(o[_])throw o[_];let n=t.write(e);a.onBodySent(e),n||await p()}t.end(),a.onRequestSent(),c||(o[u]=!0),i[C]()}catch(t){e(t)}finally{t.off(`close`,d).off(`drain`,d)}}t.exports=F})),et=I(((e,t)=>{let n=z(),{kBodyUsed:r}=ke(),i=L(`node:assert`),{InvalidArgumentError:a}=R(),o=L(`node:events`),s=[300,301,302,303,307,308],c=Symbol(`body`);var l=class{constructor(e){this[c]=e,this[r]=!1}async*[Symbol.asyncIterator](){i(!this[r],`disturbed`),this[r]=!0,yield*this[c]}},u=class{constructor(e,t,s,c){if(t!=null&&(!Number.isInteger(t)||t<0))throw new a(`maxRedirections must be a positive number`);n.validateHandler(c,s.method,s.upgrade),this.dispatch=e,this.location=null,this.abort=null,this.opts={...s,maxRedirections:0},this.maxRedirections=t,this.handler=c,this.history=[],this.redirectionLimitReached=!1,n.isStream(this.opts.body)?(n.bodyLength(this.opts.body)===0&&this.opts.body.on(`data`,function(){i(!1)}),typeof this.opts.body.readableDidRead!=`boolean`&&(this.opts.body[r]=!1,o.prototype.on.call(this.opts.body,`data`,function(){this[r]=!0}))):(this.opts.body&&typeof this.opts.body.pipeTo==`function`||this.opts.body&&typeof this.opts.body!=`string`&&!ArrayBuffer.isView(this.opts.body)&&n.isIterable(this.opts.body))&&(this.opts.body=new l(this.opts.body))}onConnect(e){this.abort=e,this.handler.onConnect(e,{history:this.history})}onUpgrade(e,t,n){this.handler.onUpgrade(e,t,n)}onError(e){this.handler.onError(e)}onHeaders(e,t,r,i){if(this.location=this.history.length>=this.maxRedirections||n.isDisturbed(this.opts.body)?null:d(e,t),this.opts.throwOnMaxRedirect&&this.history.length>=this.maxRedirections){this.request&&this.request.abort(Error(`max redirects`)),this.redirectionLimitReached=!0,this.abort(Error(`max redirects`));return}if(this.opts.origin&&this.history.push(new URL(this.opts.path,this.opts.origin)),!this.location)return this.handler.onHeaders(e,t,r,i);let{origin:a,pathname:o,search:s}=n.parseURL(new URL(this.location,this.opts.origin&&new URL(this.opts.path,this.opts.origin))),c=s?`${o}${s}`:o;this.opts.headers=p(this.opts.headers,e===303,this.opts.origin!==a),this.opts.path=c,this.opts.origin=a,this.opts.maxRedirections=0,this.opts.query=null,e===303&&this.opts.method!==`HEAD`&&(this.opts.method=`GET`,this.opts.body=null)}onData(e){if(!this.location)return this.handler.onData(e)}onComplete(e){this.location?(this.location=null,this.abort=null,this.dispatch(this.opts,this)):this.handler.onComplete(e)}onBodySent(e){this.handler.onBodySent&&this.handler.onBodySent(e)}};function d(e,t){if(s.indexOf(e)===-1)return null;for(let e=0;e{let n=et();function r({maxRedirections:e}){return t=>function(r,i){let{maxRedirections:a=e}=r;if(!a)return t(r,i);let o=new n(t,a,r,i);return r={...r,maxRedirections:0},t(r,o)}}t.exports=r})),nt=I(((e,t)=>{let n=L(`node:assert`),r=L(`node:net`),i=L(`node:http`),a=z(),{channels:o}=Me(),s=Ne(),c=Fe(),{InvalidArgumentError:l,InformationalError:u,ClientDestroyedError:d}=R(),f=Le(),{kUrl:p,kServerName:m,kClient:h,kBusy:g,kConnect:_,kResuming:v,kRunning:y,kPending:b,kSize:x,kQueue:S,kConnected:C,kConnecting:w,kNeedDrain:T,kKeepAliveDefaultTimeout:E,kHostHeader:D,kPendingIdx:O,kRunningIdx:k,kError:A,kPipelining:j,kKeepAliveTimeoutValue:M,kMaxHeadersSize:N,kKeepAliveMaxTimeout:P,kKeepAliveTimeoutThreshold:ee,kHeadersTimeout:te,kBodyTimeout:ne,kStrictContentLength:F,kConnector:re,kMaxRedirections:ie,kMaxRequests:ae,kCounter:oe,kClose:se,kDestroy:ce,kDispatch:le,kInterceptors:ue,kLocalAddress:de,kMaxResponseSize:I,kOnError:fe,kHTTPContext:pe,kMaxConcurrentStreams:me,kResume:he}=ke(),ge=Qe(),_e=$e(),ve=!1,ye=Symbol(`kClosedResolve`),be=()=>{};function xe(e){return e[j]??e[pe]?.defaultPipelining??1}var Se=class extends c{constructor(e,{interceptors:t,maxHeaderSize:n,headersTimeout:o,socketTimeout:s,requestTimeout:c,connectTimeout:u,bodyTimeout:d,idleTimeout:h,keepAlive:g,keepAliveTimeout:_,maxKeepAliveTimeout:y,keepAliveMaxTimeout:b,keepAliveTimeoutThreshold:x,socketPath:C,pipelining:w,tls:A,strictContentLength:oe,maxCachedSessions:se,maxRedirections:ce,connect:le,maxRequestsPerClient:L,localAddress:ge,maxResponseSize:_e,autoSelectFamily:be,autoSelectFamilyAttemptTimeout:xe,maxConcurrentStreams:Se,allowH2:Te}={}){if(super(),g!==void 0)throw new l(`unsupported keepAlive, use pipelining=0 instead`);if(s!==void 0)throw new l(`unsupported socketTimeout, use headersTimeout & bodyTimeout instead`);if(c!==void 0)throw new l(`unsupported requestTimeout, use headersTimeout & bodyTimeout instead`);if(h!==void 0)throw new l(`unsupported idleTimeout, use keepAliveTimeout instead`);if(y!==void 0)throw new l(`unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead`);if(n!=null&&!Number.isFinite(n))throw new l(`invalid maxHeaderSize`);if(C!=null&&typeof C!=`string`)throw new l(`invalid socketPath`);if(u!=null&&(!Number.isFinite(u)||u<0))throw new l(`invalid connectTimeout`);if(_!=null&&(!Number.isFinite(_)||_<=0))throw new l(`invalid keepAliveTimeout`);if(b!=null&&(!Number.isFinite(b)||b<=0))throw new l(`invalid keepAliveMaxTimeout`);if(x!=null&&!Number.isFinite(x))throw new l(`invalid keepAliveTimeoutThreshold`);if(o!=null&&(!Number.isInteger(o)||o<0))throw new l(`headersTimeout must be a positive integer or zero`);if(d!=null&&(!Number.isInteger(d)||d<0))throw new l(`bodyTimeout must be a positive integer or zero`);if(le!=null&&typeof le!=`function`&&typeof le!=`object`)throw new l(`connect must be a function or an object`);if(ce!=null&&(!Number.isInteger(ce)||ce<0))throw new l(`maxRedirections must be a positive number`);if(L!=null&&(!Number.isInteger(L)||L<0))throw new l(`maxRequestsPerClient must be a positive number`);if(ge!=null&&(typeof ge!=`string`||r.isIP(ge)===0))throw new l(`localAddress must be valid string IP address`);if(_e!=null&&(!Number.isInteger(_e)||_e<-1))throw new l(`maxResponseSize must be a positive number`);if(xe!=null&&(!Number.isInteger(xe)||xe<-1))throw new l(`autoSelectFamilyAttemptTimeout must be a positive number`);if(Te!=null&&typeof Te!=`boolean`)throw new l(`allowH2 must be a valid boolean value`);if(Se!=null&&(typeof Se!=`number`||Se<1))throw new l(`maxConcurrentStreams must be a positive integer, greater than 0`);typeof le!=`function`&&(le=f({...A,maxCachedSessions:se,allowH2:Te,socketPath:C,timeout:u,...be?{autoSelectFamily:be,autoSelectFamilyAttemptTimeout:xe}:void 0,...le})),t?.Client&&Array.isArray(t.Client)?(this[ue]=t.Client,ve||(ve=!0,process.emitWarning(`Client.Options#interceptor is deprecated. Use Dispatcher#compose instead.`,{code:`UNDICI-CLIENT-INTERCEPTOR-DEPRECATED`}))):this[ue]=[Ce({maxRedirections:ce})],this[p]=a.parseOrigin(e),this[re]=le,this[j]=w??1,this[N]=n||i.maxHeaderSize,this[E]=_??4e3,this[P]=b??6e5,this[ee]=x??2e3,this[M]=this[E],this[m]=null,this[de]=ge??null,this[v]=0,this[T]=0,this[D]=`host: ${this[p].hostname}${this[p].port?`:${this[p].port}`:``}\r\n`,this[ne]=d??3e5,this[te]=o??3e5,this[F]=oe??!0,this[ie]=ce,this[ae]=L,this[ye]=null,this[I]=_e>-1?_e:-1,this[me]=Se??100,this[pe]=null,this[S]=[],this[k]=0,this[O]=0,this[he]=e=>De(this,e),this[fe]=e=>we(this,e)}get pipelining(){return this[j]}set pipelining(e){this[j]=e,this[he](!0)}get[b](){return this[S].length-this[O]}get[y](){return this[O]-this[k]}get[x](){return this[S].length-this[k]}get[C](){return!!this[pe]&&!this[w]&&!this[pe].destroyed}get[g](){return!!(this[pe]?.busy(null)||this[x]>=(xe(this)||1)||this[b]>0)}[_](e){Te(this),this.once(`connect`,e)}[le](e,t){let n=new s(e.origin||this[p].origin,e,t);return this[S].push(n),this[v]||(a.bodyLength(n.body)==null&&a.isIterable(n.body)?(this[v]=1,queueMicrotask(()=>De(this))):this[he](!0)),this[v]&&this[T]!==2&&this[g]&&(this[T]=2),this[T]<2}async[se](){return new Promise(e=>{this[x]?this[ye]=e:e(null)})}async[ce](e){return new Promise(t=>{let n=this[S].splice(this[O]);for(let t=0;t{this[ye]&&(this[ye](),this[ye]=null),t(null)};this[pe]?(this[pe].destroy(e,r),this[pe]=null):queueMicrotask(r),this[he]()})}};let Ce=tt();function we(e,t){if(e[y]===0&&t.code!==`UND_ERR_INFO`&&t.code!==`UND_ERR_SOCKET`){n(e[O]===e[k]);let r=e[S].splice(e[k]);for(let n=0;n{e[re]({host:t,hostname:i,protocol:s,port:c,servername:e[m],localAddress:e[de]},(e,t)=>{e?r(e):n(t)})});if(e.destroyed){a.destroy(r.on(`error`,be),new d);return}n(r);try{e[pe]=r.alpnProtocol===`h2`?await _e(e,r):await ge(e,r)}catch(e){throw r.destroy().on(`error`,be),e}e[w]=!1,r[oe]=0,r[ae]=e[ae],r[h]=e,r[A]=null,o.connected.hasSubscribers&&o.connected.publish({connectParams:{host:t,hostname:i,protocol:s,port:c,version:e[pe]?.version,servername:e[m],localAddress:e[de]},connector:e[re],socket:r}),e.emit(`connect`,e[p],[e])}catch(r){if(e.destroyed)return;if(e[w]=!1,o.connectError.hasSubscribers&&o.connectError.publish({connectParams:{host:t,hostname:i,protocol:s,port:c,version:e[pe]?.version,servername:e[m],localAddress:e[de]},connector:e[re],error:r}),r.code===`ERR_TLS_CERT_ALTNAME_INVALID`)for(n(e[y]===0);e[b]>0&&e[S][e[O]].servername===e[m];){let t=e[S][e[O]++];a.errorRequest(e,t,r)}else we(e,r);e.emit(`connectionError`,e[p],[e],r)}e[he]()}function Ee(e){e[T]=0,e.emit(`drain`,e[p],[e])}function De(e,t){e[v]!==2&&(e[v]=2,Oe(e,t),e[v]=0,e[k]>256&&(e[S].splice(0,e[k]),e[O]-=e[k],e[k]=0))}function Oe(e,t){for(;;){if(e.destroyed){n(e[b]===0);return}if(e[ye]&&!e[x]){e[ye](),e[ye]=null;return}if(e[pe]&&e[pe].resume(),e[g])e[T]=2;else if(e[T]===2){t?(e[T]=1,queueMicrotask(()=>Ee(e))):Ee(e);continue}if(e[b]===0||e[y]>=(xe(e)||1))return;let r=e[S][e[O]];if(e[p].protocol===`https:`&&e[m]!==r.servername){if(e[y]>0)return;e[m]=r.servername,e[pe]?.destroy(new u(`servername changed`),()=>{e[pe]=null,De(e)})}if(e[w])return;if(!e[pe]){Te(e);return}if(e[pe].destroyed||e[pe].busy(r))return;!r.aborted&&e[pe].write(r)?e[O]++:e[S].splice(e[O],1)}}t.exports=Se})),rt=I(((e,t)=>{let n=2048,r=n-1;var i=class{constructor(){this.bottom=0,this.top=0,this.list=Array(n),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&r)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&r}shift(){let e=this.list[this.bottom];return e===void 0?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&r,e)}};t.exports=class{constructor(){this.head=this.tail=new i}isEmpty(){return this.head.isEmpty()}push(e){this.head.isFull()&&(this.head=this.head.next=new i),this.head.push(e)}shift(){let e=this.tail,t=e.shift();return e.isEmpty()&&e.next!==null&&(this.tail=e.next),t}}})),it=I(((e,t)=>{let{kFree:n,kConnected:r,kPending:i,kQueued:a,kRunning:o,kSize:s}=ke(),c=Symbol(`pool`);t.exports=class{constructor(e){this[c]=e}get connected(){return this[c][r]}get free(){return this[c][n]}get pending(){return this[c][i]}get queued(){return this[c][a]}get running(){return this[c][o]}get size(){return this[c][s]}}})),at=I(((e,t)=>{let n=Fe(),r=rt(),{kConnected:i,kSize:a,kRunning:o,kPending:s,kQueued:c,kBusy:l,kFree:u,kUrl:d,kClose:f,kDestroy:p,kDispatch:m}=ke(),h=it(),g=Symbol(`clients`),_=Symbol(`needDrain`),v=Symbol(`queue`),y=Symbol(`closed resolve`),b=Symbol(`onDrain`),x=Symbol(`onConnect`),S=Symbol(`onDisconnect`),C=Symbol(`onConnectionError`),w=Symbol(`get dispatcher`),T=Symbol(`add client`),E=Symbol(`remove client`),D=Symbol(`stats`);t.exports={PoolBase:class extends n{constructor(){super(),this[v]=new r,this[g]=[],this[c]=0;let e=this;this[b]=function(t,n){let r=e[v],i=!1;for(;!i;){let t=r.shift();if(!t)break;e[c]--,i=!this.dispatch(t.opts,t.handler)}this[_]=i,!this[_]&&e[_]&&(e[_]=!1,e.emit(`drain`,t,[e,...n])),e[y]&&r.isEmpty()&&Promise.all(e[g].map(e=>e.close())).then(e[y])},this[x]=(t,n)=>{e.emit(`connect`,t,[e,...n])},this[S]=(t,n,r)=>{e.emit(`disconnect`,t,[e,...n],r)},this[C]=(t,n,r)=>{e.emit(`connectionError`,t,[e,...n],r)},this[D]=new h(this)}get[l](){return this[_]}get[i](){return this[g].filter(e=>e[i]).length}get[u](){return this[g].filter(e=>e[i]&&!e[_]).length}get[s](){let e=this[c];for(let{[s]:t}of this[g])e+=t;return e}get[o](){let e=0;for(let{[o]:t}of this[g])e+=t;return e}get[a](){let e=this[c];for(let{[a]:t}of this[g])e+=t;return e}get stats(){return this[D]}async[f](){this[v].isEmpty()?await Promise.all(this[g].map(e=>e.close())):await new Promise(e=>{this[y]=e})}async[p](e){for(;;){let t=this[v].shift();if(!t)break;t.handler.onError(e)}await Promise.all(this[g].map(t=>t.destroy(e)))}[m](e,t){let n=this[w]();return n?n.dispatch(e,t)||(n[_]=!0,this[_]=!this[w]()):(this[_]=!0,this[v].push({opts:e,handler:t}),this[c]++),!this[_]}[T](e){return e.on(`drain`,this[b]).on(`connect`,this[x]).on(`disconnect`,this[S]).on(`connectionError`,this[C]),this[g].push(e),this[_]&&queueMicrotask(()=>{this[_]&&this[b](e[d],[this,e])}),this}[E](e){e.close(()=>{let t=this[g].indexOf(e);t!==-1&&this[g].splice(t,1)}),this[_]=this[g].some(e=>!e[_]&&e.closed!==!0&&e.destroyed!==!0)}},kClients:g,kNeedDrain:_,kAddClient:T,kRemoveClient:E,kGetDispatcher:w}})),ot=I(((e,t)=>{let{PoolBase:n,kClients:r,kNeedDrain:i,kAddClient:a,kGetDispatcher:o}=at(),s=nt(),{InvalidArgumentError:c}=R(),l=z(),{kUrl:u,kInterceptors:d}=ke(),f=Le(),p=Symbol(`options`),m=Symbol(`connections`),h=Symbol(`factory`);function g(e,t){return new s(e,t)}t.exports=class extends n{constructor(e,{connections:t,factory:n=g,connect:i,connectTimeout:a,tls:o,maxCachedSessions:s,socketPath:_,autoSelectFamily:v,autoSelectFamilyAttemptTimeout:y,allowH2:b,...x}={}){if(super(),t!=null&&(!Number.isFinite(t)||t<0))throw new c(`invalid connections`);if(typeof n!=`function`)throw new c(`factory must be a function.`);if(i!=null&&typeof i!=`function`&&typeof i!=`object`)throw new c(`connect must be a function or an object`);typeof i!=`function`&&(i=f({...o,maxCachedSessions:s,allowH2:b,socketPath:_,timeout:a,...v?{autoSelectFamily:v,autoSelectFamilyAttemptTimeout:y}:void 0,...i})),this[d]=x.interceptors?.Pool&&Array.isArray(x.interceptors.Pool)?x.interceptors.Pool:[],this[m]=t||null,this[u]=l.parseOrigin(e),this[p]={...l.deepClone(x),connect:i,allowH2:b},this[p].interceptors=x.interceptors?{...x.interceptors}:void 0,this[h]=n,this.on(`connectionError`,(e,t,n)=>{for(let e of t){let t=this[r].indexOf(e);t!==-1&&this[r].splice(t,1)}})}[o](){for(let e of this[r])if(!e[i])return e;if(!this[m]||this[r].length{let{BalancedPoolMissingUpstreamError:n,InvalidArgumentError:r}=R(),{PoolBase:i,kClients:a,kNeedDrain:o,kAddClient:s,kRemoveClient:c,kGetDispatcher:l}=at(),u=ot(),{kUrl:d,kInterceptors:f}=ke(),{parseOrigin:p}=z(),m=Symbol(`factory`),h=Symbol(`options`),g=Symbol(`kGreatestCommonDivisor`),_=Symbol(`kCurrentWeight`),v=Symbol(`kIndex`),y=Symbol(`kWeight`),b=Symbol(`kMaxWeightPerServer`),x=Symbol(`kErrorPenalty`);function S(e,t){if(e===0)return t;for(;t!==0;){let n=t;t=e%t,e=n}return e}function C(e,t){return new u(e,t)}t.exports=class extends i{constructor(e=[],{factory:t=C,...n}={}){if(super(),this[h]=n,this[v]=-1,this[_]=0,this[b]=this[h].maxWeightPerServer||100,this[x]=this[h].errorPenalty||15,Array.isArray(e)||(e=[e]),typeof t!=`function`)throw new r(`factory must be a function.`);this[f]=n.interceptors?.BalancedPool&&Array.isArray(n.interceptors.BalancedPool)?n.interceptors.BalancedPool:[],this[m]=t;for(let t of e)this.addUpstream(t);this._updateBalancedPoolStats()}addUpstream(e){let t=p(e).origin;if(this[a].find(e=>e[d].origin===t&&e.closed!==!0&&e.destroyed!==!0))return this;let n=this[m](t,Object.assign({},this[h]));this[s](n),n.on(`connect`,()=>{n[y]=Math.min(this[b],n[y]+this[x])}),n.on(`connectionError`,()=>{n[y]=Math.max(1,n[y]-this[x]),this._updateBalancedPoolStats()}),n.on(`disconnect`,(...e)=>{let t=e[2];t&&t.code===`UND_ERR_SOCKET`&&(n[y]=Math.max(1,n[y]-this[x]),this._updateBalancedPoolStats())});for(let e of this[a])e[y]=this[b];return this._updateBalancedPoolStats(),this}_updateBalancedPoolStats(){let e=0;for(let t=0;te[d].origin===t&&e.closed!==!0&&e.destroyed!==!0);return n&&this[c](n),this}get upstreams(){return this[a].filter(e=>e.closed!==!0&&e.destroyed!==!0).map(e=>e[d].origin)}[l](){if(this[a].length===0)throw new n;if(!this[a].find(e=>!e[o]&&e.closed!==!0&&e.destroyed!==!0)||this[a].map(e=>e[o]).reduce((e,t)=>e&&t,!0))return;let e=0,t=this[a].findIndex(e=>!e[o]);for(;e++this[a][t][y]&&!e[o]&&(t=this[v]),this[v]===0&&(this[_]=this[_]-this[g],this[_]<=0&&(this[_]=this[b])),e[y]>=this[_]&&!e[o])return e}return this[_]=this[a][t][y],this[v]=t,this[a][t]}}})),ct=I(((e,t)=>{let{InvalidArgumentError:n}=R(),{kClients:r,kRunning:i,kClose:a,kDestroy:o,kDispatch:s,kInterceptors:c}=ke(),l=Fe(),u=ot(),d=nt(),f=z(),p=tt(),m=Symbol(`onConnect`),h=Symbol(`onDisconnect`),g=Symbol(`onConnectionError`),_=Symbol(`maxRedirections`),v=Symbol(`onDrain`),y=Symbol(`factory`),b=Symbol(`options`);function x(e,t){return t&&t.connections===1?new d(e,t):new u(e,t)}t.exports=class extends l{constructor({factory:e=x,maxRedirections:t=0,connect:i,...a}={}){if(super(),typeof e!=`function`)throw new n(`factory must be a function.`);if(i!=null&&typeof i!=`function`&&typeof i!=`object`)throw new n(`connect must be a function or an object`);if(!Number.isInteger(t)||t<0)throw new n(`maxRedirections must be a positive number`);i&&typeof i!=`function`&&(i={...i}),this[c]=a.interceptors?.Agent&&Array.isArray(a.interceptors.Agent)?a.interceptors.Agent:[p({maxRedirections:t})],this[b]={...f.deepClone(a),connect:i},this[b].interceptors=a.interceptors?{...a.interceptors}:void 0,this[_]=t,this[y]=e,this[r]=new Map,this[v]=(e,t)=>{this.emit(`drain`,e,[this,...t])},this[m]=(e,t)=>{this.emit(`connect`,e,[this,...t])},this[h]=(e,t,n)=>{this.emit(`disconnect`,e,[this,...t],n)},this[g]=(e,t,n)=>{this.emit(`connectionError`,e,[this,...t],n)}}get[i](){let e=0;for(let t of this[r].values())e+=t[i];return e}[s](e,t){let i;if(e.origin&&(typeof e.origin==`string`||e.origin instanceof URL))i=String(e.origin);else throw new n(`opts.origin must be a non-empty string or URL.`);let a=this[r].get(i);return a||(a=this[y](e.origin,this[b]).on(`drain`,this[v]).on(`connect`,this[m]).on(`disconnect`,this[h]).on(`connectionError`,this[g]),this[r].set(i,a)),a.dispatch(e,t)}async[a](){let e=[];for(let t of this[r].values())e.push(t.close());this[r].clear(),await Promise.all(e)}async[o](e){let t=[];for(let n of this[r].values())t.push(n.destroy(e));this[r].clear(),await Promise.all(t)}}})),lt=I(((e,t)=>{let{kProxy:n,kClose:r,kDestroy:i,kDispatch:a,kInterceptors:o}=ke(),{URL:s}=L(`node:url`),c=ct(),l=ot(),u=Fe(),{InvalidArgumentError:d,RequestAbortedError:f,SecureProxyConnectionError:p}=R(),m=Le(),h=nt(),g=Symbol(`proxy agent`),_=Symbol(`proxy client`),v=Symbol(`proxy headers`),y=Symbol(`request tls settings`),b=Symbol(`proxy tls settings`),x=Symbol(`connect endpoint function`),S=Symbol(`tunnel proxy`);function C(e){return e===`https:`?443:80}function w(e,t){return new l(e,t)}let T=()=>{};function E(e,t){return t.connections===1?new h(e,t):new l(e,t)}var D=class extends u{#e;constructor(e,{headers:t={},connect:n,factory:r}){if(super(),!e)throw new d(`Proxy URL is mandatory`);this[v]=t,r?this.#e=r(e,{connect:n}):this.#e=new h(e,{connect:n})}[a](e,t){let n=t.onHeaders;t.onHeaders=function(e,r,i){if(e===407){typeof t.onError==`function`&&t.onError(new d(`Proxy Authentication Required (407)`));return}n&&n.call(this,e,r,i)};let{origin:r,path:i=`/`,headers:o={}}=e;if(e.path=r+i,!(`host`in o)&&!(`Host`in o)){let{host:e}=new s(r);o.host=e}return e.headers={...this[v],...o},this.#e[a](e,t)}async[r](){return this.#e.close()}async[i](e){return this.#e.destroy(e)}},O=class extends u{constructor(e){if(super(),!e||typeof e==`object`&&!(e instanceof s)&&!e.uri)throw new d(`Proxy uri is mandatory`);let{clientFactory:t=w}=e;if(typeof t!=`function`)throw new d(`Proxy opts.clientFactory must be a function.`);let{proxyTunnel:r=!0}=e,i=this.#e(e),{href:a,origin:l,port:u,protocol:h,username:O,password:k,hostname:A}=i;if(this[n]={uri:a,protocol:h},this[o]=e.interceptors?.ProxyAgent&&Array.isArray(e.interceptors.ProxyAgent)?e.interceptors.ProxyAgent:[],this[y]=e.requestTls,this[b]=e.proxyTls,this[v]=e.headers||{},this[S]=r,e.auth&&e.token)throw new d(`opts.auth cannot be used in combination with opts.token`);e.auth?this[v][`proxy-authorization`]=`Basic ${e.auth}`:e.token?this[v][`proxy-authorization`]=e.token:O&&k&&(this[v][`proxy-authorization`]=`Basic ${Buffer.from(`${decodeURIComponent(O)}:${decodeURIComponent(k)}`).toString(`base64`)}`);let j=m({...e.proxyTls});this[x]=m({...e.requestTls});let M=e.factory||E,N=(e,t)=>{let{protocol:r}=new s(e);return!this[S]&&r===`http:`&&this[n].protocol===`http:`?new D(this[n].uri,{headers:this[v],connect:j,factory:M}):M(e,t)};this[_]=t(i,{connect:j}),this[g]=new c({...e,factory:N,connect:async(e,t)=>{let n=e.host;e.port||(n+=`:${C(e.protocol)}`);try{let{socket:r,statusCode:i}=await this[_].connect({origin:l,port:u,path:n,signal:e.signal,headers:{...this[v],host:e.host},servername:this[b]?.servername||A});if(i!==200&&(r.on(`error`,T).destroy(),t(new f(`Proxy response (${i}) !== 200 when HTTP Tunneling`))),e.protocol!==`https:`){t(null,r);return}let a;a=this[y]?this[y].servername:e.servername,this[x]({...e,servername:a,httpSocket:r},t)}catch(e){e.code===`ERR_TLS_CERT_ALTNAME_INVALID`?t(new p(e)):t(e)}}})}dispatch(e,t){let n=k(e.headers);if(A(n),n&&!(`host`in n)&&!(`Host`in n)){let{host:t}=new s(e.origin);n.host=t}return this[g].dispatch({...e,headers:n},t)}#e(e){return typeof e==`string`?new s(e):e instanceof s?e:new s(e.uri)}async[r](){await this[g].close(),await this[_].close()}async[i](){await this[g].destroy(),await this[_].destroy()}};function k(e){if(Array.isArray(e)){let t={};for(let n=0;ne.toLowerCase()===`proxy-authorization`))throw new d(`Proxy-Authorization should be sent in ProxyAgent constructor`)}t.exports=O})),ut=I(((e,t)=>{let n=Fe(),{kClose:r,kDestroy:i,kClosed:a,kDestroyed:o,kDispatch:s,kNoProxyAgent:c,kHttpProxyAgent:l,kHttpsProxyAgent:u}=ke(),d=lt(),f=ct(),p={"http:":80,"https:":443},m=!1;t.exports=class extends n{#e=null;#t=null;#n=null;constructor(e={}){super(),this.#n=e,m||(m=!0,process.emitWarning(`EnvHttpProxyAgent is experimental, expect them to change at any time.`,{code:`UNDICI-EHPA`}));let{httpProxy:t,httpsProxy:n,noProxy:r,...i}=e;this[c]=new f(i);let a=t??process.env.http_proxy??process.env.HTTP_PROXY;a?this[l]=new d({...i,uri:a}):this[l]=this[c];let o=n??process.env.https_proxy??process.env.HTTPS_PROXY;o?this[u]=new d({...i,uri:o}):this[u]=this[l],this.#a()}[s](e,t){let n=new URL(e.origin);return this.#r(n).dispatch(e,t)}async[r](){await this[c].close(),this[l][a]||await this[l].close(),this[u][a]||await this[u].close()}async[i](e){await this[c].destroy(e),this[l][o]||await this[l].destroy(e),this[u][o]||await this[u].destroy(e)}#r(e){let{protocol:t,host:n,port:r}=e;return n=n.replace(/:\d*$/,``).toLowerCase(),r=Number.parseInt(r,10)||p[t]||0,this.#i(n,r)?t===`https:`?this[u]:this[l]:this[c]}#i(e,t){if(this.#o&&this.#a(),this.#t.length===0)return!0;if(this.#e===`*`)return!1;for(let n=0;n{let n=L(`node:assert`),{kRetryHandlerDefaultRetry:r}=ke(),{RequestRetryError:i}=R(),{isDisturbed:a,parseHeaders:o,parseRangeHeader:s,wrapRequestBody:c}=z();function l(e){let t=Date.now();return new Date(e).getTime()-t}t.exports=class e{constructor(t,n){let{retryOptions:i,...a}=t,{retry:o,maxRetries:s,maxTimeout:l,minTimeout:u,timeoutFactor:d,methods:f,errorCodes:p,retryAfter:m,statusCodes:h}=i??{};this.dispatch=n.dispatch,this.handler=n.handler,this.opts={...a,body:c(t.body)},this.abort=null,this.aborted=!1,this.retryOpts={retry:o??e[r],retryAfter:m??!0,maxTimeout:l??30*1e3,minTimeout:u??500,timeoutFactor:d??2,maxRetries:s??5,methods:f??[`GET`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`TRACE`],statusCodes:h??[500,502,503,504,429],errorCodes:p??[`ECONNRESET`,`ECONNREFUSED`,`ENOTFOUND`,`ENETDOWN`,`ENETUNREACH`,`EHOSTDOWN`,`EHOSTUNREACH`,`EPIPE`,`UND_ERR_SOCKET`]},this.retryCount=0,this.retryCountCheckpoint=0,this.start=0,this.end=null,this.etag=null,this.resume=null,this.handler.onConnect(e=>{this.aborted=!0,this.abort?this.abort(e):this.reason=e})}onRequestSent(){this.handler.onRequestSent&&this.handler.onRequestSent()}onUpgrade(e,t,n){this.handler.onUpgrade&&this.handler.onUpgrade(e,t,n)}onConnect(e){this.aborted?e(this.reason):this.abort=e}onBodySent(e){if(this.handler.onBodySent)return this.handler.onBodySent(e)}static[r](e,{state:t,opts:n},r){let{statusCode:i,code:a,headers:o}=e,{method:s,retryOptions:c}=n,{maxRetries:u,minTimeout:d,maxTimeout:f,timeoutFactor:p,statusCodes:m,errorCodes:h,methods:g}=c,{counter:_}=t;if(a&&a!==`UND_ERR_REQ_RETRY`&&!h.includes(a)){r(e);return}if(Array.isArray(g)&&!g.includes(s)){r(e);return}if(i!=null&&Array.isArray(m)&&!m.includes(i)){r(e);return}if(_>u){r(e);return}let v=o?.[`retry-after`];v&&=(v=Number(v),Number.isNaN(v)?l(v):v*1e3);let y=Math.min(v>0?v:d*p**(_-1),f);setTimeout(()=>r(null),y)}onHeaders(e,t,r,a){let c=o(t);if(this.retryCount+=1,e>=300)return this.retryOpts.statusCodes.includes(e)===!1?this.handler.onHeaders(e,t,r,a):(this.abort(new i(`Request failed`,e,{headers:c,data:{count:this.retryCount}})),!1);if(this.resume!=null){if(this.resume=null,e!==206&&(this.start>0||e!==200))return this.abort(new i(`server does not support the range header and the payload was partially consumed`,e,{headers:c,data:{count:this.retryCount}})),!1;let t=s(c[`content-range`]);if(!t)return this.abort(new i(`Content-Range mismatch`,e,{headers:c,data:{count:this.retryCount}})),!1;if(this.etag!=null&&this.etag!==c.etag)return this.abort(new i(`ETag mismatch`,e,{headers:c,data:{count:this.retryCount}})),!1;let{start:a,size:o,end:l=o-1}=t;return n(this.start===a,`content-range mismatch`),n(this.end==null||this.end===l,`content-range mismatch`),this.resume=r,!0}if(this.end==null){if(e===206){let i=s(c[`content-range`]);if(i==null)return this.handler.onHeaders(e,t,r,a);let{start:o,size:l,end:u=l-1}=i;n(o!=null&&Number.isFinite(o),`content-range mismatch`),n(u!=null&&Number.isFinite(u),`invalid content-length`),this.start=o,this.end=u}if(this.end==null){let e=c[`content-length`];this.end=e==null?null:Number(e)-1}return n(Number.isFinite(this.start)),n(this.end==null||Number.isFinite(this.end),`invalid content-length`),this.resume=r,this.etag=c.etag==null?null:c.etag,this.etag!=null&&this.etag.startsWith(`W/`)&&(this.etag=null),this.handler.onHeaders(e,t,r,a)}let l=new i(`Request failed`,e,{headers:c,data:{count:this.retryCount}});return this.abort(l),!1}onData(e){return this.start+=e.length,this.handler.onData(e)}onComplete(e){return this.retryCount=0,this.handler.onComplete(e)}onError(e){if(this.aborted||a(this.opts.body))return this.handler.onError(e);this.retryCount-this.retryCountCheckpoint>0?this.retryCount=this.retryCountCheckpoint+(this.retryCount-this.retryCountCheckpoint):this.retryCount+=1,this.retryOpts.retry(e,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},t.bind(this));function t(e){if(e!=null||this.aborted||a(this.opts.body))return this.handler.onError(e);if(this.start!==0){let e={range:`bytes=${this.start}-${this.end??``}`};this.etag!=null&&(e[`if-match`]=this.etag),this.opts={...this.opts,headers:{...this.opts.headers,...e}}}try{this.retryCountCheckpoint=this.retryCount,this.dispatch(this.opts,this)}catch(e){this.handler.onError(e)}}}}})),ft=I(((e,t)=>{let n=Pe(),r=dt();t.exports=class extends n{#e=null;#t=null;constructor(e,t={}){super(t),this.#e=e,this.#t=t}dispatch(e,t){let n=new r({...e,retryOptions:this.#t},{dispatch:this.#e.dispatch.bind(this.#e),handler:t});return this.#e.dispatch(e,n)}close(){return this.#e.close()}destroy(){return this.#e.destroy()}}})),pt=I(((e,t)=>{let n=L(`node:assert`),{Readable:r}=L(`node:stream`),{RequestAbortedError:i,NotSupportedError:a,InvalidArgumentError:o,AbortError:s}=R(),c=z(),{ReadableStreamFrom:l}=z(),u=Symbol(`kConsume`),d=Symbol(`kReading`),f=Symbol(`kBody`),p=Symbol(`kAbort`),m=Symbol(`kContentType`),h=Symbol(`kContentLength`),g=()=>{};var _=class extends r{constructor({resume:e,abort:t,contentType:n=``,contentLength:r,highWaterMark:i=64*1024}){super({autoDestroy:!0,read:e,highWaterMark:i}),this._readableState.dataEmitted=!1,this[p]=t,this[u]=null,this[f]=null,this[m]=n,this[h]=r,this[d]=!1}destroy(e){return!e&&!this._readableState.endEmitted&&(e=new i),e&&this[p](),super.destroy(e)}_destroy(e,t){this[d]?t(e):setImmediate(()=>{t(e)})}on(e,...t){return(e===`data`||e===`readable`)&&(this[d]=!0),super.on(e,...t)}addListener(e,...t){return this.on(e,...t)}off(e,...t){let n=super.off(e,...t);return(e===`data`||e===`readable`)&&(this[d]=this.listenerCount(`data`)>0||this.listenerCount(`readable`)>0),n}removeListener(e,...t){return this.off(e,...t)}push(e){return this[u]&&e!==null?(T(this[u],e),this[d]?super.push(e):!0):super.push(e)}async text(){return b(this,`text`)}async json(){return b(this,`json`)}async blob(){return b(this,`blob`)}async bytes(){return b(this,`bytes`)}async arrayBuffer(){return b(this,`arrayBuffer`)}async formData(){throw new a}get bodyUsed(){return c.isDisturbed(this)}get body(){return this[f]||(this[f]=l(this),this[u]&&(this[f].getReader(),n(this[f].locked))),this[f]}async dump(e){let t=Number.isFinite(e?.limit)?e.limit:128*1024,n=e?.signal;if(n!=null&&(typeof n!=`object`||!(`aborted`in n)))throw new o(`signal must be an AbortSignal`);return n?.throwIfAborted(),this._readableState.closeEmitted?null:await new Promise((e,r)=>{this[h]>t&&this.destroy(new s);let i=()=>{this.destroy(n.reason??new s)};n?.addEventListener(`abort`,i),this.on(`close`,function(){n?.removeEventListener(`abort`,i),n?.aborted?r(n.reason??new s):e(null)}).on(`error`,g).on(`data`,function(e){t-=e.length,t<=0&&this.destroy()}).resume()})}};function v(e){return e[f]&&e[f].locked===!0||e[u]}function y(e){return c.isDisturbed(e)||v(e)}async function b(e,t){return n(!e[u]),new Promise((n,r)=>{if(y(e)){let t=e._readableState;t.destroyed&&t.closeEmitted===!1?e.on(`error`,e=>{r(e)}).on(`close`,()=>{r(TypeError(`unusable`))}):r(t.errored??TypeError(`unusable`))}else queueMicrotask(()=>{e[u]={type:t,stream:e,resolve:n,reject:r,length:0,body:[]},e.on(`error`,function(e){E(this[u],e)}).on(`close`,function(){this[u].body!==null&&E(this[u],new i)}),x(e[u])})})}function x(e){if(e.body===null)return;let{_readableState:t}=e.stream;if(t.bufferIndex){let n=t.bufferIndex,r=t.buffer.length;for(let i=n;i2&&n[0]===239&&n[1]===187&&n[2]===191?3:0;return n.utf8Slice(i,r)}function C(e,t){if(e.length===0||t===0)return new Uint8Array;if(e.length===1)return new Uint8Array(e[0]);let n=new Uint8Array(Buffer.allocUnsafeSlow(t).buffer),r=0;for(let t=0;t{let n=L(`node:assert`),{ResponseStatusCodeError:r}=R(),{chunksDecode:i}=pt();async function a({callback:e,body:t,contentType:a,statusCode:c,statusMessage:l,headers:u}){n(t);let d=[],f=0;try{for await(let e of t)if(d.push(e),f+=e.length,f>131072){d=[],f=0;break}}catch{d=[],f=0}let p=`Response status code ${c}${l?`: ${l}`:``}`;if(c===204||!a||!f){queueMicrotask(()=>e(new r(p,c,u)));return}let m=Error.stackTraceLimit;Error.stackTraceLimit=0;let h;try{o(a)?h=JSON.parse(i(d,f)):s(a)&&(h=i(d,f))}catch{}finally{Error.stackTraceLimit=m}queueMicrotask(()=>e(new r(p,c,u,h)))}let o=e=>e.length>15&&e[11]===`/`&&e[0]===`a`&&e[1]===`p`&&e[2]===`p`&&e[3]===`l`&&e[4]===`i`&&e[5]===`c`&&e[6]===`a`&&e[7]===`t`&&e[8]===`i`&&e[9]===`o`&&e[10]===`n`&&e[12]===`j`&&e[13]===`s`&&e[14]===`o`&&e[15]===`n`,s=e=>e.length>4&&e[4]===`/`&&e[0]===`t`&&e[1]===`e`&&e[2]===`x`&&e[3]===`t`;t.exports={getResolveErrorBodyCallback:a,isContentTypeApplicationJson:o,isContentTypeText:s}})),ht=I(((e,t)=>{let n=L(`node:assert`),{Readable:r}=pt(),{InvalidArgumentError:i,RequestAbortedError:a}=R(),o=z(),{getResolveErrorBodyCallback:s}=mt(),{AsyncResource:c}=L(`node:async_hooks`);var l=class extends c{constructor(e,t){if(!e||typeof e!=`object`)throw new i(`invalid opts`);let{signal:n,method:r,opaque:s,body:c,onInfo:l,responseHeaders:u,throwOnError:d,highWaterMark:f}=e;try{if(typeof t!=`function`)throw new i(`invalid callback`);if(f&&(typeof f!=`number`||f<0))throw new i(`invalid highWaterMark`);if(n&&typeof n.on!=`function`&&typeof n.addEventListener!=`function`)throw new i(`signal must be an EventEmitter or EventTarget`);if(r===`CONNECT`)throw new i(`invalid method`);if(l&&typeof l!=`function`)throw new i(`invalid onInfo callback`);super(`UNDICI_REQUEST`)}catch(e){throw o.isStream(c)&&o.destroy(c.on(`error`,o.nop),e),e}this.method=r,this.responseHeaders=u||null,this.opaque=s||null,this.callback=t,this.res=null,this.abort=null,this.body=c,this.trailers={},this.context=null,this.onInfo=l||null,this.throwOnError=d,this.highWaterMark=f,this.signal=n,this.reason=null,this.removeAbortListener=null,o.isStream(c)&&c.on(`error`,e=>{this.onError(e)}),this.signal&&(this.signal.aborted?this.reason=this.signal.reason??new a:this.removeAbortListener=o.addAbortListener(this.signal,()=>{this.reason=this.signal.reason??new a,this.res?o.destroy(this.res.on(`error`,o.nop),this.reason):this.abort&&this.abort(this.reason),this.removeAbortListener&&=(this.res?.off(`close`,this.removeAbortListener),this.removeAbortListener(),null)}))}onConnect(e,t){if(this.reason){e(this.reason);return}n(this.callback),this.abort=e,this.context=t}onHeaders(e,t,n,i){let{callback:a,opaque:c,abort:l,context:u,responseHeaders:d,highWaterMark:f}=this,p=d===`raw`?o.parseRawHeaders(t):o.parseHeaders(t);if(e<200){this.onInfo&&this.onInfo({statusCode:e,headers:p});return}let m=d===`raw`?o.parseHeaders(t):p,h=m[`content-type`],g=m[`content-length`],_=new r({resume:n,abort:l,contentType:h,contentLength:this.method!==`HEAD`&&g?Number(g):null,highWaterMark:f});this.removeAbortListener&&_.on(`close`,this.removeAbortListener),this.callback=null,this.res=_,a!==null&&(this.throwOnError&&e>=400?this.runInAsyncScope(s,null,{callback:a,body:_,contentType:h,statusCode:e,statusMessage:i,headers:p}):this.runInAsyncScope(a,null,null,{statusCode:e,headers:p,trailers:this.trailers,opaque:c,body:_,context:u}))}onData(e){return this.res.push(e)}onComplete(e){o.parseHeaders(e,this.trailers),this.res.push(null)}onError(e){let{res:t,callback:n,body:r,opaque:i}=this;n&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(n,null,e,{opaque:i})})),t&&(this.res=null,queueMicrotask(()=>{o.destroy(t,e)})),r&&(this.body=null,o.destroy(r,e)),this.removeAbortListener&&=(t?.off(`close`,this.removeAbortListener),this.removeAbortListener(),null)}};function u(e,t){if(t===void 0)return new Promise((t,n)=>{u.call(this,e,(e,r)=>e?n(e):t(r))});try{this.dispatch(e,new l(e,t))}catch(n){if(typeof t!=`function`)throw n;let r=e?.opaque;queueMicrotask(()=>t(n,{opaque:r}))}}t.exports=u,t.exports.RequestHandler=l})),gt=I(((e,t)=>{let{addAbortListener:n}=z(),{RequestAbortedError:r}=R(),i=Symbol(`kListener`),a=Symbol(`kSignal`);function o(e){e.abort?e.abort(e[a]?.reason):e.reason=e[a]?.reason??new r,c(e)}function s(e,t){if(e.reason=null,e[a]=null,e[i]=null,t){if(t.aborted){o(e);return}e[a]=t,e[i]=()=>{o(e)},n(e[a],e[i])}}function c(e){e[a]&&(`removeEventListener`in e[a]?e[a].removeEventListener(`abort`,e[i]):e[a].removeListener(`abort`,e[i]),e[a]=null,e[i]=null)}t.exports={addSignal:s,removeSignal:c}})),_t=I(((e,t)=>{let n=L(`node:assert`),{finished:r,PassThrough:i}=L(`node:stream`),{InvalidArgumentError:a,InvalidReturnValueError:o}=R(),s=z(),{getResolveErrorBodyCallback:c}=mt(),{AsyncResource:l}=L(`node:async_hooks`),{addSignal:u,removeSignal:d}=gt();var f=class extends l{constructor(e,t,n){if(!e||typeof e!=`object`)throw new a(`invalid opts`);let{signal:r,method:i,opaque:o,body:c,onInfo:l,responseHeaders:d,throwOnError:f}=e;try{if(typeof n!=`function`)throw new a(`invalid callback`);if(typeof t!=`function`)throw new a(`invalid factory`);if(r&&typeof r.on!=`function`&&typeof r.addEventListener!=`function`)throw new a(`signal must be an EventEmitter or EventTarget`);if(i===`CONNECT`)throw new a(`invalid method`);if(l&&typeof l!=`function`)throw new a(`invalid onInfo callback`);super(`UNDICI_STREAM`)}catch(e){throw s.isStream(c)&&s.destroy(c.on(`error`,s.nop),e),e}this.responseHeaders=d||null,this.opaque=o||null,this.factory=t,this.callback=n,this.res=null,this.abort=null,this.context=null,this.trailers=null,this.body=c,this.onInfo=l||null,this.throwOnError=f||!1,s.isStream(c)&&c.on(`error`,e=>{this.onError(e)}),u(this,r)}onConnect(e,t){if(this.reason){e(this.reason);return}n(this.callback),this.abort=e,this.context=t}onHeaders(e,t,n,a){let{factory:l,opaque:u,context:d,callback:f,responseHeaders:p}=this,m=p===`raw`?s.parseRawHeaders(t):s.parseHeaders(t);if(e<200){this.onInfo&&this.onInfo({statusCode:e,headers:m});return}this.factory=null;let h;if(this.throwOnError&&e>=400){let n=(p===`raw`?s.parseHeaders(t):m)[`content-type`];h=new i,this.callback=null,this.runInAsyncScope(c,null,{callback:f,body:h,contentType:n,statusCode:e,statusMessage:a,headers:m})}else{if(l===null)return;if(h=this.runInAsyncScope(l,null,{statusCode:e,headers:m,opaque:u,context:d}),!h||typeof h.write!=`function`||typeof h.end!=`function`||typeof h.on!=`function`)throw new o(`expected Writable`);r(h,{readable:!1},e=>{let{callback:t,res:n,opaque:r,trailers:i,abort:a}=this;this.res=null,(e||!n.readable)&&s.destroy(n,e),this.callback=null,this.runInAsyncScope(t,null,e||null,{opaque:r,trailers:i}),e&&a()})}return h.on(`drain`,n),this.res=h,(h.writableNeedDrain===void 0?h._writableState?.needDrain:h.writableNeedDrain)!==!0}onData(e){let{res:t}=this;return t?t.write(e):!0}onComplete(e){let{res:t}=this;d(this),t&&(this.trailers=s.parseHeaders(e),t.end())}onError(e){let{res:t,callback:n,opaque:r,body:i}=this;d(this),this.factory=null,t?(this.res=null,s.destroy(t,e)):n&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(n,null,e,{opaque:r})})),i&&(this.body=null,s.destroy(i,e))}};function p(e,t,n){if(n===void 0)return new Promise((n,r)=>{p.call(this,e,t,(e,t)=>e?r(e):n(t))});try{this.dispatch(e,new f(e,t,n))}catch(t){if(typeof n!=`function`)throw t;let r=e?.opaque;queueMicrotask(()=>n(t,{opaque:r}))}}t.exports=p})),vt=I(((e,t)=>{let{Readable:n,Duplex:r,PassThrough:i}=L(`node:stream`),{InvalidArgumentError:a,InvalidReturnValueError:o,RequestAbortedError:s}=R(),c=z(),{AsyncResource:l}=L(`node:async_hooks`),{addSignal:u,removeSignal:d}=gt(),f=L(`node:assert`),p=Symbol(`resume`);var m=class extends n{constructor(){super({autoDestroy:!0}),this[p]=null}_read(){let{[p]:e}=this;e&&(this[p]=null,e())}_destroy(e,t){this._read(),t(e)}},h=class extends n{constructor(e){super({autoDestroy:!0}),this[p]=e}_read(){this[p]()}_destroy(e,t){!e&&!this._readableState.endEmitted&&(e=new s),t(e)}},g=class extends l{constructor(e,t){if(!e||typeof e!=`object`)throw new a(`invalid opts`);if(typeof t!=`function`)throw new a(`invalid handler`);let{signal:n,method:i,opaque:o,onInfo:l,responseHeaders:f}=e;if(n&&typeof n.on!=`function`&&typeof n.addEventListener!=`function`)throw new a(`signal must be an EventEmitter or EventTarget`);if(i===`CONNECT`)throw new a(`invalid method`);if(l&&typeof l!=`function`)throw new a(`invalid onInfo callback`);super(`UNDICI_PIPELINE`),this.opaque=o||null,this.responseHeaders=f||null,this.handler=t,this.abort=null,this.context=null,this.onInfo=l||null,this.req=new m().on(`error`,c.nop),this.ret=new r({readableObjectMode:e.objectMode,autoDestroy:!0,read:()=>{let{body:e}=this;e?.resume&&e.resume()},write:(e,t,n)=>{let{req:r}=this;r.push(e,t)||r._readableState.destroyed?n():r[p]=n},destroy:(e,t)=>{let{body:n,req:r,res:i,ret:a,abort:o}=this;!e&&!a._readableState.endEmitted&&(e=new s),o&&e&&o(),c.destroy(n,e),c.destroy(r,e),c.destroy(i,e),d(this),t(e)}}).on(`prefinish`,()=>{let{req:e}=this;e.push(null)}),this.res=null,u(this,n)}onConnect(e,t){let{ret:n,res:r}=this;if(this.reason){e(this.reason);return}f(!r,`pipeline cannot be retried`),f(!n.destroyed),this.abort=e,this.context=t}onHeaders(e,t,n){let{opaque:r,handler:i,context:a}=this;if(e<200){if(this.onInfo){let n=this.responseHeaders===`raw`?c.parseRawHeaders(t):c.parseHeaders(t);this.onInfo({statusCode:e,headers:n})}return}this.res=new h(n);let l;try{this.handler=null;let n=this.responseHeaders===`raw`?c.parseRawHeaders(t):c.parseHeaders(t);l=this.runInAsyncScope(i,null,{statusCode:e,headers:n,opaque:r,body:this.res,context:a})}catch(e){throw this.res.on(`error`,c.nop),e}if(!l||typeof l.on!=`function`)throw new o(`expected Readable`);l.on(`data`,e=>{let{ret:t,body:n}=this;!t.push(e)&&n.pause&&n.pause()}).on(`error`,e=>{let{ret:t}=this;c.destroy(t,e)}).on(`end`,()=>{let{ret:e}=this;e.push(null)}).on(`close`,()=>{let{ret:e}=this;e._readableState.ended||c.destroy(e,new s)}),this.body=l}onData(e){let{res:t}=this;return t.push(e)}onComplete(e){let{res:t}=this;t.push(null)}onError(e){let{ret:t}=this;this.handler=null,c.destroy(t,e)}};function _(e,t){try{let n=new g(e,t);return this.dispatch({...e,body:n.req},n),n.ret}catch(e){return new i().destroy(e)}}t.exports=_})),yt=I(((e,t)=>{let{InvalidArgumentError:n,SocketError:r}=R(),{AsyncResource:i}=L(`node:async_hooks`),a=z(),{addSignal:o,removeSignal:s}=gt(),c=L(`node:assert`);var l=class extends i{constructor(e,t){if(!e||typeof e!=`object`)throw new n(`invalid opts`);if(typeof t!=`function`)throw new n(`invalid callback`);let{signal:r,opaque:i,responseHeaders:a}=e;if(r&&typeof r.on!=`function`&&typeof r.addEventListener!=`function`)throw new n(`signal must be an EventEmitter or EventTarget`);super(`UNDICI_UPGRADE`),this.responseHeaders=a||null,this.opaque=i||null,this.callback=t,this.abort=null,this.context=null,o(this,r)}onConnect(e,t){if(this.reason){e(this.reason);return}c(this.callback),this.abort=e,this.context=null}onHeaders(){throw new r(`bad upgrade`,null)}onUpgrade(e,t,n){c(e===101);let{callback:r,opaque:i,context:o}=this;s(this),this.callback=null;let l=this.responseHeaders===`raw`?a.parseRawHeaders(t):a.parseHeaders(t);this.runInAsyncScope(r,null,null,{headers:l,socket:n,opaque:i,context:o})}onError(e){let{callback:t,opaque:n}=this;s(this),t&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(t,null,e,{opaque:n})}))}};function u(e,t){if(t===void 0)return new Promise((t,n)=>{u.call(this,e,(e,r)=>e?n(e):t(r))});try{let n=new l(e,t);this.dispatch({...e,method:e.method||`GET`,upgrade:e.protocol||`Websocket`},n)}catch(n){if(typeof t!=`function`)throw n;let r=e?.opaque;queueMicrotask(()=>t(n,{opaque:r}))}}t.exports=u})),bt=I(((e,t)=>{let n=L(`node:assert`),{AsyncResource:r}=L(`node:async_hooks`),{InvalidArgumentError:i,SocketError:a}=R(),o=z(),{addSignal:s,removeSignal:c}=gt();var l=class extends r{constructor(e,t){if(!e||typeof e!=`object`)throw new i(`invalid opts`);if(typeof t!=`function`)throw new i(`invalid callback`);let{signal:n,opaque:r,responseHeaders:a}=e;if(n&&typeof n.on!=`function`&&typeof n.addEventListener!=`function`)throw new i(`signal must be an EventEmitter or EventTarget`);super(`UNDICI_CONNECT`),this.opaque=r||null,this.responseHeaders=a||null,this.callback=t,this.abort=null,s(this,n)}onConnect(e,t){if(this.reason){e(this.reason);return}n(this.callback),this.abort=e,this.context=t}onHeaders(){throw new a(`bad connect`,null)}onUpgrade(e,t,n){let{callback:r,opaque:i,context:a}=this;c(this),this.callback=null;let s=t;s!=null&&(s=this.responseHeaders===`raw`?o.parseRawHeaders(t):o.parseHeaders(t)),this.runInAsyncScope(r,null,null,{statusCode:e,headers:s,socket:n,opaque:i,context:a})}onError(e){let{callback:t,opaque:n}=this;c(this),t&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(t,null,e,{opaque:n})}))}};function u(e,t){if(t===void 0)return new Promise((t,n)=>{u.call(this,e,(e,r)=>e?n(e):t(r))});try{let n=new l(e,t);this.dispatch({...e,method:`CONNECT`},n)}catch(n){if(typeof t!=`function`)throw n;let r=e?.opaque;queueMicrotask(()=>t(n,{opaque:r}))}}t.exports=u})),xt=I(((e,t)=>{t.exports.request=ht(),t.exports.stream=_t(),t.exports.pipeline=vt(),t.exports.upgrade=yt(),t.exports.connect=bt()})),St=I(((e,t)=>{let{UndiciError:n}=R(),r=Symbol.for(`undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED`);t.exports={MockNotMatchedError:class e extends n{constructor(t){super(t),Error.captureStackTrace(this,e),this.name=`MockNotMatchedError`,this.message=t||`The request does not match any registered mock dispatches`,this.code=`UND_MOCK_ERR_MOCK_NOT_MATCHED`}static[Symbol.hasInstance](e){return e&&e[r]===!0}[r]=!0}}})),Ct=I(((e,t)=>{t.exports={kAgent:Symbol(`agent`),kOptions:Symbol(`options`),kFactory:Symbol(`factory`),kDispatches:Symbol(`dispatches`),kDispatchKey:Symbol(`dispatch key`),kDefaultHeaders:Symbol(`default headers`),kDefaultTrailers:Symbol(`default trailers`),kContentLength:Symbol(`content length`),kMockAgent:Symbol(`mock agent`),kMockAgentSet:Symbol(`mock agent set`),kMockAgentGet:Symbol(`mock agent get`),kMockDispatch:Symbol(`mock dispatch`),kClose:Symbol(`close`),kOriginalClose:Symbol(`original agent close`),kOrigin:Symbol(`origin`),kIsMockActive:Symbol(`is mock active`),kNetConnect:Symbol(`net connect`),kGetNetConnect:Symbol(`get net connect`),kConnected:Symbol(`connected`)}})),wt=I(((e,t)=>{let{MockNotMatchedError:n}=St(),{kDispatches:r,kMockAgent:i,kOriginalDispatch:a,kOrigin:o,kGetNetConnect:s}=Ct(),{buildURL:c}=z(),{STATUS_CODES:l}=L(`node:http`),{types:{isPromise:u}}=L(`node:util`);function d(e,t){return typeof e==`string`?e===t:e instanceof RegExp?e.test(t):typeof e==`function`?e(t)===!0:!1}function f(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e.toLocaleLowerCase(),t]))}function p(e,t){if(Array.isArray(e)){for(let n=0;n!e).filter(({path:e})=>d(g(e),i));if(a.length===0)throw new n(`Mock dispatch not matched for path '${i}'`);if(a=a.filter(({method:e})=>d(e,t.method)),a.length===0)throw new n(`Mock dispatch not matched for method '${t.method}' on path '${i}'`);if(a=a.filter(({body:e})=>e===void 0?!0:d(e,t.body)),a.length===0)throw new n(`Mock dispatch not matched for body '${t.body}' on path '${i}'`);if(a=a.filter(e=>h(e,t.headers)),a.length===0)throw new n(`Mock dispatch not matched for headers '${typeof t.headers==`object`?JSON.stringify(t.headers):t.headers}' on path '${i}'`);return a[0]}function b(e,t,n){let r={timesInvoked:0,times:1,persist:!1,consumed:!1},i=typeof n==`function`?{callback:n}:{...n},a={...r,...t,pending:!0,data:{error:null,...i}};return e.push(a),a}function x(e,t){let n=e.findIndex(e=>e.consumed?_(e,t):!1);n!==-1&&e.splice(n,1)}function S(e){let{path:t,method:n,body:r,headers:i,query:a}=e;return{path:t,method:n,body:r,headers:i,query:a}}function C(e){let t=Object.keys(e),n=[];for(let r=0;r=h,i.pending=p0?setTimeout(()=>{g(this[r])},d):g(this[r]);function g(r,i=o){let l=Array.isArray(e.headers)?m(e.headers):e.headers,d=typeof i==`function`?i({...e,headers:l}):i;if(u(d)){d.then(e=>g(r,e));return}let f=v(d),p=C(s),h=C(c);t.onConnect?.(e=>t.onError(e),null),t.onHeaders?.(a,p,_,w(a)),t.onData?.(Buffer.from(f)),t.onComplete?.(h),x(r,n)}function _(){}return!0}function D(){let e=this[i],t=this[o],r=this[a];return function(i,a){if(e.isMockActive)try{E.call(this,i,a)}catch(o){if(o instanceof n){let c=e[s]();if(c===!1)throw new n(`${o.message}: subsequent request to origin ${t} was not allowed (net.connect disabled)`);if(O(c,t))r.call(this,i,a);else throw new n(`${o.message}: subsequent request to origin ${t} was not allowed (net.connect is not enabled for this origin)`)}else throw o}else r.call(this,i,a)}}function O(e,t){let n=new URL(t);return e===!0?!0:!!(Array.isArray(e)&&e.some(e=>d(e,n.host)))}function k(e){if(e){let{agent:t,...n}=e;return n}}t.exports={getResponseData:v,getMockDispatch:y,addMockDispatch:b,deleteMockDispatch:x,buildKey:S,generateKeyValues:C,matchValue:d,getResponse:T,getStatusText:w,mockDispatch:E,buildMockDispatch:D,checkNetConnect:O,buildMockOptions:k,getHeaderByName:p,buildHeadersFromArray:m}})),Tt=I(((e,t)=>{let{getResponseData:n,buildKey:r,addMockDispatch:i}=wt(),{kDispatches:a,kDispatchKey:o,kDefaultHeaders:s,kDefaultTrailers:c,kContentLength:l,kMockDispatch:u}=Ct(),{InvalidArgumentError:d}=R(),{buildURL:f}=z();var p=class{constructor(e){this[u]=e}delay(e){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw new d(`waitInMs must be a valid integer > 0`);return this[u].delay=e,this}persist(){return this[u].persist=!0,this}times(e){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw new d(`repeatTimes must be a valid integer > 0`);return this[u].times=e,this}},m=class{constructor(e,t){if(typeof e!=`object`)throw new d(`opts must be an object`);if(e.path===void 0)throw new d(`opts.path must be defined`);if(e.method===void 0&&(e.method=`GET`),typeof e.path==`string`)if(e.query)e.path=f(e.path,e.query);else{let t=new URL(e.path,`data://`);e.path=t.pathname+t.search}typeof e.method==`string`&&(e.method=e.method.toUpperCase()),this[o]=r(e),this[a]=t,this[s]={},this[c]={},this[l]=!1}createMockScopeDispatchData({statusCode:e,data:t,responseOptions:r}){let i=n(t),a=this[l]?{"content-length":i.length}:{};return{statusCode:e,data:t,headers:{...this[s],...a,...r.headers},trailers:{...this[c],...r.trailers}}}validateReplyParameters(e){if(e.statusCode===void 0)throw new d(`statusCode must be defined`);if(typeof e.responseOptions!=`object`||e.responseOptions===null)throw new d(`responseOptions must be an object`)}reply(e){if(typeof e==`function`)return new p(i(this[a],this[o],t=>{let n=e(t);if(typeof n!=`object`||!n)throw new d(`reply options callback must return an object`);let r={data:``,responseOptions:{},...n};return this.validateReplyParameters(r),{...this.createMockScopeDispatchData(r)}}));let t={statusCode:e,data:arguments[1]===void 0?``:arguments[1],responseOptions:arguments[2]===void 0?{}:arguments[2]};this.validateReplyParameters(t);let n=this.createMockScopeDispatchData(t);return new p(i(this[a],this[o],n))}replyWithError(e){if(e===void 0)throw new d(`error must be defined`);return new p(i(this[a],this[o],{error:e}))}defaultReplyHeaders(e){if(e===void 0)throw new d(`headers must be defined`);return this[s]=e,this}defaultReplyTrailers(e){if(e===void 0)throw new d(`trailers must be defined`);return this[c]=e,this}replyContentLength(){return this[l]=!0,this}};t.exports.MockInterceptor=m,t.exports.MockScope=p})),Et=I(((e,t)=>{let{promisify:n}=L(`node:util`),r=nt(),{buildMockDispatch:i}=wt(),{kDispatches:a,kMockAgent:o,kClose:s,kOriginalClose:c,kOrigin:l,kOriginalDispatch:u,kConnected:d}=Ct(),{MockInterceptor:f}=Tt(),p=ke(),{InvalidArgumentError:m}=R();t.exports=class extends r{constructor(e,t){if(super(e,t),!t||!t.agent||typeof t.agent.dispatch!=`function`)throw new m(`Argument opts.agent must implement Agent`);this[o]=t.agent,this[l]=e,this[a]=[],this[d]=1,this[u]=this.dispatch,this[c]=this.close.bind(this),this.dispatch=i.call(this),this.close=this[s]}get[p.kConnected](){return this[d]}intercept(e){return new f(e,this[a])}async[s](){await n(this[c])(),this[d]=0,this[o][p.kClients].delete(this[l])}}})),Dt=I(((e,t)=>{let{promisify:n}=L(`node:util`),r=ot(),{buildMockDispatch:i}=wt(),{kDispatches:a,kMockAgent:o,kClose:s,kOriginalClose:c,kOrigin:l,kOriginalDispatch:u,kConnected:d}=Ct(),{MockInterceptor:f}=Tt(),p=ke(),{InvalidArgumentError:m}=R();t.exports=class extends r{constructor(e,t){if(super(e,t),!t||!t.agent||typeof t.agent.dispatch!=`function`)throw new m(`Argument opts.agent must implement Agent`);this[o]=t.agent,this[l]=e,this[a]=[],this[d]=1,this[u]=this.dispatch,this[c]=this.close.bind(this),this.dispatch=i.call(this),this.close=this[s]}get[p.kConnected](){return this[d]}intercept(e){return new f(e,this[a])}async[s](){await n(this[c])(),this[d]=0,this[o][p.kClients].delete(this[l])}}})),Ot=I(((e,t)=>{let n={pronoun:`it`,is:`is`,was:`was`,this:`this`},r={pronoun:`they`,is:`are`,was:`were`,this:`these`};t.exports=class{constructor(e,t){this.singular=e,this.plural=t}pluralize(e){let t=e===1,i=t?n:r,a=t?this.singular:this.plural;return{...i,count:e,noun:a}}}})),kt=I(((e,t)=>{let{Transform:n}=L(`node:stream`),{Console:r}=L(`node:console`),i=process.versions.icu?`✅`:`Y `,a=process.versions.icu?`❌`:`N `;t.exports=class{constructor({disableColors:e}={}){this.transform=new n({transform(e,t,n){n(null,e)}}),this.logger=new r({stdout:this.transform,inspectOptions:{colors:!e&&!process.env.CI}})}format(e){let t=e.map(({method:e,path:t,data:{statusCode:n},persist:r,times:o,timesInvoked:s,origin:c})=>({Method:e,Origin:c,Path:t,"Status code":n,Persistent:r?i:a,Invocations:s,Remaining:r?1/0:o-s}));return this.logger.table(t),this.transform.read().toString()}}})),At=I(((e,t)=>{let{kClients:n}=ke(),r=ct(),{kAgent:i,kMockAgentSet:a,kMockAgentGet:o,kDispatches:s,kIsMockActive:c,kNetConnect:l,kGetNetConnect:u,kOptions:d,kFactory:f}=Ct(),p=Et(),m=Dt(),{matchValue:h,buildMockOptions:g}=wt(),{InvalidArgumentError:_,UndiciError:v}=R(),y=Pe(),b=Ot(),x=kt();t.exports=class extends y{constructor(e){if(super(e),this[l]=!0,this[c]=!0,e?.agent&&typeof e.agent.dispatch!=`function`)throw new _(`Argument opts.agent must implement Agent`);let t=e?.agent?e.agent:new r(e);this[i]=t,this[n]=t[n],this[d]=g(e)}get(e){let t=this[o](e);return t||(t=this[f](e),this[a](e,t)),t}dispatch(e,t){return this.get(e.origin),this[i].dispatch(e,t)}async close(){await this[i].close(),this[n].clear()}deactivate(){this[c]=!1}activate(){this[c]=!0}enableNetConnect(e){if(typeof e==`string`||typeof e==`function`||e instanceof RegExp)Array.isArray(this[l])?this[l].push(e):this[l]=[e];else if(e===void 0)this[l]=!0;else throw new _(`Unsupported matcher. Must be one of String|Function|RegExp.`)}disableNetConnect(){this[l]=!1}get isMockActive(){return this[c]}[a](e,t){this[n].set(e,t)}[f](e){let t=Object.assign({agent:this},this[d]);return this[d]&&this[d].connections===1?new p(e,t):new m(e,t)}[o](e){let t=this[n].get(e);if(t)return t;if(typeof e!=`string`){let t=this[f](`http://localhost:9999`);return this[a](e,t),t}for(let[t,r]of Array.from(this[n]))if(r&&typeof t!=`string`&&h(t,e)){let t=this[f](e);return this[a](e,t),t[s]=r[s],t}}[u](){return this[l]}pendingInterceptors(){let e=this[n];return Array.from(e.entries()).flatMap(([e,t])=>t[s].map(t=>({...t,origin:e}))).filter(({pending:e})=>e)}assertNoPendingInterceptors({pendingInterceptorsFormatter:e=new x}={}){let t=this.pendingInterceptors();if(t.length===0)return;let n=new b(`interceptor`,`interceptors`).pluralize(t.length);throw new v(` ${n.count} ${n.noun} ${n.is} pending: ${e.format(t)} -`.trim())}}})),jt=I(((e,t)=>{let n=Symbol.for(`undici.globalDispatcher.1`),{InvalidArgumentError:r}=R(),i=ct();o()===void 0&&a(new i);function a(e){if(!e||typeof e.dispatch!=`function`)throw new r(`Argument agent must implement Agent`);Object.defineProperty(globalThis,n,{value:e,writable:!0,enumerable:!1,configurable:!1})}function o(){return globalThis[n]}t.exports={setGlobalDispatcher:a,getGlobalDispatcher:o}})),Mt=I(((e,t)=>{t.exports=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`handler must be an object`);this.#e=e}onConnect(...e){return this.#e.onConnect?.(...e)}onError(...e){return this.#e.onError?.(...e)}onUpgrade(...e){return this.#e.onUpgrade?.(...e)}onResponseStarted(...e){return this.#e.onResponseStarted?.(...e)}onHeaders(...e){return this.#e.onHeaders?.(...e)}onData(...e){return this.#e.onData?.(...e)}onComplete(...e){return this.#e.onComplete?.(...e)}onBodySent(...e){return this.#e.onBodySent?.(...e)}}})),Nt=I(((e,t)=>{let n=et();t.exports=e=>{let t=e?.maxRedirections;return e=>function(r,i){let{maxRedirections:a=t,...o}=r;return a?e(o,new n(e,a,r,i)):e(r,i)}}})),Pt=I(((e,t)=>{let n=dt();t.exports=e=>t=>function(r,i){return t(r,new n({...r,retryOptions:{...e,...r.retryOptions}},{handler:i,dispatch:t}))}})),Ft=I(((e,t)=>{let n=z(),{InvalidArgumentError:r,RequestAbortedError:i}=R(),a=Mt();var o=class extends a{#e=1024*1024;#t=null;#n=!1;#r=!1;#i=0;#a=null;#o=null;constructor({maxSize:e},t){if(super(t),e!=null&&(!Number.isFinite(e)||e<1))throw new r(`maxSize must be a number greater than 0`);this.#e=e??this.#e,this.#o=t}onConnect(e){this.#t=e,this.#o.onConnect(this.#s.bind(this))}#s(e){this.#r=!0,this.#a=e}onHeaders(e,t,r,a){let o=n.parseHeaders(t)[`content-length`];if(o!=null&&o>this.#e)throw new i(`Response size (${o}) larger than maxSize (${this.#e})`);return this.#r?!0:this.#o.onHeaders(e,t,r,a)}onError(e){this.#n||(e=this.#a??e,this.#o.onError(e))}onData(e){return this.#i+=e.length,this.#i>=this.#e&&(this.#n=!0,this.#r?this.#o.onError(this.#a):this.#o.onComplete([])),!0}onComplete(e){if(!this.#n){if(this.#r){this.#o.onError(this.reason);return}this.#o.onComplete(e)}}};function s({maxSize:e}={maxSize:1024*1024}){return t=>function(n,r){let{dumpMaxSize:i=e}=n;return t(n,new o({maxSize:i},r))}}t.exports=s})),It=I(((e,t)=>{let{isIP:n}=L(`node:net`),{lookup:r}=L(`node:dns`),i=Mt(),{InvalidArgumentError:a,InformationalError:o}=R(),s=2**31-1;var c=class{#e=0;#t=0;#n=new Map;dualStack=!0;affinity=null;lookup=null;pick=null;constructor(e){this.#e=e.maxTTL,this.#t=e.maxItems,this.dualStack=e.dualStack,this.affinity=e.affinity,this.lookup=e.lookup??this.#r,this.pick=e.pick??this.#i}get full(){return this.#n.size===this.#t}runLookup(e,t,n){let r=this.#n.get(e.hostname);if(r==null&&this.full){n(null,e.origin);return}let i={affinity:this.affinity,dualStack:this.dualStack,lookup:this.lookup,pick:this.pick,...t.dns,maxTTL:this.#e,maxItems:this.#t};if(r==null)this.lookup(e,i,(t,r)=>{if(t||r==null||r.length===0){n(t??new o(`No DNS entries found`));return}this.setRecords(e,r);let a=this.#n.get(e.hostname),s=this.pick(e,a,i.affinity),c;c=typeof s.port==`number`?`:${s.port}`:e.port===``?``:`:${e.port}`,n(null,`${e.protocol}//${s.family===6?`[${s.address}]`:s.address}${c}`)});else{let a=this.pick(e,r,i.affinity);if(a==null){this.#n.delete(e.hostname),this.runLookup(e,t,n);return}let o;o=typeof a.port==`number`?`:${a.port}`:e.port===``?``:`:${e.port}`,n(null,`${e.protocol}//${a.family===6?`[${a.address}]`:a.address}${o}`)}}#r(e,t,n){r(e.hostname,{all:!0,family:this.dualStack===!1?this.affinity:0,order:`ipv4first`},(e,t)=>{if(e)return n(e);let r=new Map;for(let e of t)r.set(`${e.address}:${e.family}`,e);n(null,r.values())})}#i(e,t,n){let r=null,{records:i,offset:a}=t,o;if(this.dualStack?(n??(a==null||a===s?(t.offset=0,n=4):(t.offset++,n=(t.offset&1)==1?6:4)),o=i[n]!=null&&i[n].ips.length>0?i[n]:i[n===4?6:4]):o=i[n],o==null||o.ips.length===0)return r;o.offset==null||o.offset===s?o.offset=0:o.offset++;let c=o.offset%o.ips.length;return r=o.ips[c]??null,r==null?r:Date.now()-r.timestamp>r.ttl?(o.ips.splice(c,1),this.pick(e,t,n)):r}setRecords(e,t){let n=Date.now(),r={records:{4:null,6:null}};for(let e of t){e.timestamp=n,typeof e.ttl==`number`?e.ttl=Math.min(e.ttl,this.#e):e.ttl=this.#e;let t=r.records[e.family]??{ips:[]};t.ips.push(e),r.records[e.family]=t}this.#n.set(e.hostname,r)}getHandler(e,t){return new l(this,e,t)}},l=class extends i{#e=null;#t=null;#n=null;#r=null;#i=null;constructor(e,{origin:t,handler:n,dispatch:r},i){super(n),this.#i=t,this.#r=n,this.#t={...i},this.#e=e,this.#n=r}onError(e){switch(e.code){case`ETIMEDOUT`:case`ECONNREFUSED`:if(this.#e.dualStack){this.#e.runLookup(this.#i,this.#t,(e,t)=>{if(e)return this.#r.onError(e);let n={...this.#t,origin:t};this.#n(n,this)});return}this.#r.onError(e);return;case`ENOTFOUND`:this.#e.deleteRecord(this.#i);default:this.#r.onError(e);break}}};t.exports=e=>{if(e?.maxTTL!=null&&(typeof e?.maxTTL!=`number`||e?.maxTTL<0))throw new a(`Invalid maxTTL. Must be a positive number`);if(e?.maxItems!=null&&(typeof e?.maxItems!=`number`||e?.maxItems<1))throw new a(`Invalid maxItems. Must be a positive number and greater than zero`);if(e?.affinity!=null&&e?.affinity!==4&&e?.affinity!==6)throw new a(`Invalid affinity. Must be either 4 or 6`);if(e?.dualStack!=null&&typeof e?.dualStack!=`boolean`)throw new a(`Invalid dualStack. Must be a boolean`);if(e?.lookup!=null&&typeof e?.lookup!=`function`)throw new a(`Invalid lookup. Must be a function`);if(e?.pick!=null&&typeof e?.pick!=`function`)throw new a(`Invalid pick. Must be a function`);let t=e?.dualStack??!0,r;r=t?e?.affinity??null:e?.affinity??4;let i=new c({maxTTL:e?.maxTTL??1e4,lookup:e?.lookup??null,pick:e?.pick??null,dualStack:t,affinity:r,maxItems:e?.maxItems??1/0});return e=>function(t,r){let a=t.origin.constructor===URL?t.origin:new URL(t.origin);return n(a.hostname)===0?(i.runLookup(a,t,(n,o)=>{if(n)return r.onError(n);let s=null;s={...t,servername:a.hostname,origin:o,headers:{host:a.hostname,...t.headers}},e(s,i.getHandler({origin:a,dispatch:e,handler:r},t))}),!0):e(t,r)}}})),Lt=I(((e,t)=>{let{kConstruct:n}=ke(),{kEnumerableProperty:r}=z(),{iteratorMixin:i,isValidHeaderName:a,isValidHeaderValue:o}=Ke(),{webidl:s}=Ge(),c=L(`node:assert`),l=L(`node:util`),u=Symbol(`headers map`),d=Symbol(`headers map sorted`);function f(e){return e===10||e===13||e===9||e===32}function p(e){let t=0,n=e.length;for(;n>t&&f(e.charCodeAt(n-1));)--n;for(;n>t&&f(e.charCodeAt(t));)++t;return t===0&&n===e.length?e:e.substring(t,n)}function m(e,t){if(Array.isArray(t))for(let n=0;n>`,`record`]})}function h(e,t,n){if(n=p(n),!a(t))throw s.errors.invalidArgument({prefix:`Headers.append`,value:t,type:`header name`});if(!o(n))throw s.errors.invalidArgument({prefix:`Headers.append`,value:n,type:`header value`});if(y(e)===`immutable`)throw TypeError(`immutable`);return x(e).append(t,n,!1)}function g(e,t){return e[0]>1),t[s][0]<=l[0]?o=s+1:a=s;if(r!==s){for(i=r;i>o;)t[i]=t[--i];t[o]=l}}if(!n.next().done)throw TypeError(`Unreachable`);return t}else{let e=0;for(let{0:n,1:{value:r}}of this[u])t[e++]=[n,r],c(r!==null);return t.sort(g)}}},v=class e{#e;#t;constructor(e=void 0){s.util.markAsUncloneable(this),e!==n&&(this.#t=new _,this.#e=`none`,e!==void 0&&(e=s.converters.HeadersInit(e,`Headers contructor`,`init`),m(this,e)))}append(t,n){s.brandCheck(this,e),s.argumentLengthCheck(arguments,2,`Headers.append`);let r=`Headers.append`;return t=s.converters.ByteString(t,r,`name`),n=s.converters.ByteString(n,r,`value`),h(this,t,n)}delete(t){if(s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.delete`),t=s.converters.ByteString(t,`Headers.delete`,`name`),!a(t))throw s.errors.invalidArgument({prefix:`Headers.delete`,value:t,type:`header name`});if(this.#e===`immutable`)throw TypeError(`immutable`);this.#t.contains(t,!1)&&this.#t.delete(t,!1)}get(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.get`);let n=`Headers.get`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:n,value:t,type:`header name`});return this.#t.get(t,!1)}has(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.has`);let n=`Headers.has`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:n,value:t,type:`header name`});return this.#t.contains(t,!1)}set(t,n){s.brandCheck(this,e),s.argumentLengthCheck(arguments,2,`Headers.set`);let r=`Headers.set`;if(t=s.converters.ByteString(t,r,`name`),n=s.converters.ByteString(n,r,`value`),n=p(n),!a(t))throw s.errors.invalidArgument({prefix:r,value:t,type:`header name`});if(!o(n))throw s.errors.invalidArgument({prefix:r,value:n,type:`header value`});if(this.#e===`immutable`)throw TypeError(`immutable`);this.#t.set(t,n,!1)}getSetCookie(){s.brandCheck(this,e);let t=this.#t.cookies;return t?[...t]:[]}get[d](){if(this.#t[d])return this.#t[d];let e=[],t=this.#t.toSortedArray(),n=this.#t.cookies;if(n===null||n.length===1)return this.#t[d]=t;for(let r=0;r>`](e,t,n,r.bind(e)):s.converters[`record`](e,t,n)}throw s.errors.conversionFailed({prefix:`Headers constructor`,argument:`Argument 1`,types:[`sequence>`,`record`]})},t.exports={fill:m,compareHeaderName:g,Headers:v,HeadersList:_,getHeadersGuard:y,setHeadersGuard:b,setHeadersList:S,getHeadersList:x}})),Rt=I(((e,t)=>{let{Headers:n,HeadersList:r,fill:i,getHeadersGuard:a,setHeadersGuard:o,setHeadersList:s}=Lt(),{extractBody:c,cloneBody:l,mixinBody:u,hasFinalizationRegistry:d,streamRegistry:f,bodyUnusable:p}=Ze(),m=z(),h=L(`node:util`),{kEnumerableProperty:g}=m,{isValidReasonPhrase:_,isCancelled:v,isAborted:y,isBlobLike:b,serializeJavascriptValueToJSONString:x,isErrorLike:S,isomorphicEncode:C,environmentSettingsObject:w}=Ke(),{redirectStatusSet:T,nullBodyStatus:E}=He(),{kState:D,kHeaders:O}=qe(),{webidl:k}=Ge(),{FormData:A}=Ye(),{URLSerializer:j}=We(),{kConstruct:M}=ke(),N=L(`node:assert`),{types:P}=L(`node:util`),ee=new TextEncoder(`utf-8`);var te=class e{static error(){return le(re(),`immutable`)}static json(e,t={}){k.argumentLengthCheck(arguments,1,`Response.json`),t!==null&&(t=k.converters.ResponseInit(t));let n=c(ee.encode(x(e))),r=le(F({}),`response`);return ce(r,t,{body:n[0],type:`application/json`}),r}static redirect(e,t=302){k.argumentLengthCheck(arguments,1,`Response.redirect`),e=k.converters.USVString(e),t=k.converters[`unsigned short`](t);let n;try{n=new URL(e,w.settingsObject.baseUrl)}catch(t){throw TypeError(`Failed to parse URL from ${e}`,{cause:t})}if(!T.has(t))throw RangeError(`Invalid status code ${t}`);let r=le(F({}),`immutable`);r[D].status=t;let i=C(j(n));return r[D].headersList.append(`location`,i,!0),r}constructor(e=null,t={}){if(k.util.markAsUncloneable(this),e===M)return;e!==null&&(e=k.converters.BodyInit(e)),t=k.converters.ResponseInit(t),this[D]=F({}),this[O]=new n(M),o(this[O],`response`),s(this[O],this[D].headersList);let r=null;if(e!=null){let[t,n]=c(e);r={body:t,type:n}}ce(this,t,r)}get type(){return k.brandCheck(this,e),this[D].type}get url(){k.brandCheck(this,e);let t=this[D].urlList,n=t[t.length-1]??null;return n===null?``:j(n,!0)}get redirected(){return k.brandCheck(this,e),this[D].urlList.length>1}get status(){return k.brandCheck(this,e),this[D].status}get ok(){return k.brandCheck(this,e),this[D].status>=200&&this[D].status<=299}get statusText(){return k.brandCheck(this,e),this[D].statusText}get headers(){return k.brandCheck(this,e),this[O]}get body(){return k.brandCheck(this,e),this[D].body?this[D].body.stream:null}get bodyUsed(){return k.brandCheck(this,e),!!this[D].body&&m.isDisturbed(this[D].body.stream)}clone(){if(k.brandCheck(this,e),p(this))throw k.errors.exception({header:`Response.clone`,message:`Body has already been consumed.`});let t=ne(this[D]);return d&&this[D].body?.stream&&f.register(this,new WeakRef(this[D].body.stream)),le(t,a(this[O]))}[h.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let n={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${h.formatWithOptions(t,n)}`}};u(te),Object.defineProperties(te.prototype,{type:g,url:g,status:g,ok:g,redirected:g,statusText:g,headers:g,clone:g,body:g,bodyUsed:g,[Symbol.toStringTag]:{value:`Response`,configurable:!0}}),Object.defineProperties(te,{json:g,redirect:g,error:g});function ne(e){if(e.internalResponse)return oe(ne(e.internalResponse),e.type);let t=F({...e,body:null});return e.body!=null&&(t.body=l(t,e.body)),t}function F(e){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:`default`,status:200,timingInfo:null,cacheState:``,statusText:``,...e,headersList:e?.headersList?new r(e?.headersList):new r,urlList:e?.urlList?[...e.urlList]:[]}}function re(e){return F({type:`error`,status:0,error:S(e)?e:Error(e&&String(e)),aborted:e&&e.name===`AbortError`})}function ie(e){return e.type===`error`&&e.status===0}function ae(e,t){return t={internalResponse:e,...t},new Proxy(e,{get(e,n){return n in t?t[n]:e[n]},set(e,n,r){return N(!(n in t)),e[n]=r,!0}})}function oe(e,t){if(t===`basic`)return ae(e,{type:`basic`,headersList:e.headersList});if(t===`cors`)return ae(e,{type:`cors`,headersList:e.headersList});if(t===`opaque`)return ae(e,{type:`opaque`,urlList:Object.freeze([]),status:0,statusText:``,body:null});if(t===`opaqueredirect`)return ae(e,{type:`opaqueredirect`,status:0,statusText:``,headersList:[],body:null});N(!1)}function se(e,t=null){return N(v(e)),y(e)?re(Object.assign(new DOMException(`The operation was aborted.`,`AbortError`),{cause:t})):re(Object.assign(new DOMException(`Request was cancelled.`),{cause:t}))}function ce(e,t,n){if(t.status!==null&&(t.status<200||t.status>599))throw RangeError(`init["status"] must be in the range of 200 to 599, inclusive.`);if(`statusText`in t&&t.statusText!=null&&!_(String(t.statusText)))throw TypeError(`Invalid statusText`);if(`status`in t&&t.status!=null&&(e[D].status=t.status),`statusText`in t&&t.statusText!=null&&(e[D].statusText=t.statusText),`headers`in t&&t.headers!=null&&i(e[O],t.headers),n){if(E.includes(e.status))throw k.errors.exception({header:`Response constructor`,message:`Invalid response status code ${e.status}`});e[D].body=n.body,n.type!=null&&!e[D].headersList.contains(`content-type`,!0)&&e[D].headersList.append(`content-type`,n.type,!0)}}function le(e,t){let r=new te(M);return r[D]=e,r[O]=new n(M),s(r[O],e.headersList),o(r[O],t),d&&e.body?.stream&&f.register(r,new WeakRef(e.body.stream)),r}k.converters.ReadableStream=k.interfaceConverter(ReadableStream),k.converters.FormData=k.interfaceConverter(A),k.converters.URLSearchParams=k.interfaceConverter(URLSearchParams),k.converters.XMLHttpRequestBodyInit=function(e,t,n){return typeof e==`string`?k.converters.USVString(e,t,n):b(e)?k.converters.Blob(e,t,n,{strict:!1}):ArrayBuffer.isView(e)||P.isArrayBuffer(e)?k.converters.BufferSource(e,t,n):m.isFormDataLike(e)?k.converters.FormData(e,t,n,{strict:!1}):e instanceof URLSearchParams?k.converters.URLSearchParams(e,t,n):k.converters.DOMString(e,t,n)},k.converters.BodyInit=function(e,t,n){return e instanceof ReadableStream?k.converters.ReadableStream(e,t,n):e?.[Symbol.asyncIterator]?e:k.converters.XMLHttpRequestBodyInit(e,t,n)},k.converters.ResponseInit=k.dictionaryConverter([{key:`status`,converter:k.converters[`unsigned short`],defaultValue:()=>200},{key:`statusText`,converter:k.converters.ByteString,defaultValue:()=>``},{key:`headers`,converter:k.converters.HeadersInit}]),t.exports={isNetworkError:ie,makeNetworkError:re,makeResponse:F,makeAppropriateNetworkError:se,filterResponse:oe,Response:te,cloneResponse:ne,fromInnerResponse:le}})),zt=I(((e,t)=>{let{kConnected:n,kSize:r}=ke();var i=class{constructor(e){this.value=e}deref(){return this.value[n]===0&&this.value[r]===0?void 0:this.value}},a=class{constructor(e){this.finalizer=e}register(e,t){e.on&&e.on(`disconnect`,()=>{e[n]===0&&e[r]===0&&this.finalizer(t)})}unregister(e){}};t.exports=function(){return process.env.NODE_V8_COVERAGE&&process.version.startsWith(`v18`)?(process._rawDebug(`Using compatibility WeakRef and FinalizationRegistry`),{WeakRef:i,FinalizationRegistry:a}):{WeakRef,FinalizationRegistry}}})),Bt=I(((e,t)=>{let{extractBody:n,mixinBody:r,cloneBody:i,bodyUnusable:a}=Ze(),{Headers:o,fill:s,HeadersList:c,setHeadersGuard:l,getHeadersGuard:u,setHeadersList:d,getHeadersList:f}=Lt(),{FinalizationRegistry:p}=zt()(),m=z(),h=L(`node:util`),{isValidHTTPToken:g,sameOrigin:_,environmentSettingsObject:v}=Ke(),{forbiddenMethodsSet:y,corsSafeListedMethodsSet:b,referrerPolicy:x,requestRedirect:S,requestMode:C,requestCredentials:w,requestCache:T,requestDuplex:E}=He(),{kEnumerableProperty:D,normalizedMethodRecordsBase:O,normalizedMethodRecords:k}=m,{kHeaders:A,kSignal:j,kState:M,kDispatcher:N}=qe(),{webidl:P}=Ge(),{URLSerializer:ee}=We(),{kConstruct:te}=ke(),ne=L(`node:assert`),{getMaxListeners:F,setMaxListeners:re,getEventListeners:ie,defaultMaxListeners:ae}=L(`node:events`),oe=Symbol(`abortController`),se=new p(({signal:e,abort:t})=>{e.removeEventListener(`abort`,t)}),ce=new WeakMap;function le(e){return t;function t(){let n=e.deref();if(n!==void 0){se.unregister(t),this.removeEventListener(`abort`,t),n.abort(this.reason);let e=ce.get(n.signal);if(e!==void 0){if(e.size!==0){for(let t of e){let e=t.deref();e!==void 0&&e.abort(this.reason)}e.clear()}ce.delete(n.signal)}}}}let ue=!1;var de=class e{constructor(t,r={}){if(P.util.markAsUncloneable(this),t===te)return;let i=`Request constructor`;P.argumentLengthCheck(arguments,1,i),t=P.converters.RequestInfo(t,i,`input`),r=P.converters.RequestInit(r,i,`init`);let u=null,p=null,h=v.settingsObject.baseUrl,x=null;if(typeof t==`string`){this[N]=r.dispatcher;let e;try{e=new URL(t,h)}catch(e){throw TypeError(`Failed to parse URL from `+t,{cause:e})}if(e.username||e.password)throw TypeError(`Request cannot be constructed from a URL that includes credentials: `+t);u=I({urlList:[e]}),p=`cors`}else this[N]=r.dispatcher||t[N],ne(t instanceof e),u=t[M],x=t[j];let S=v.settingsObject.origin,C=`client`;if(u.window?.constructor?.name===`EnvironmentSettingsObject`&&_(u.window,S)&&(C=u.window),r.window!=null)throw TypeError(`'window' option '${C}' must be null`);`window`in r&&(C=`no-window`),u=I({method:u.method,headersList:u.headersList,unsafeRequest:u.unsafeRequest,client:v.settingsObject,window:C,priority:u.priority,origin:u.origin,referrer:u.referrer,referrerPolicy:u.referrerPolicy,mode:u.mode,credentials:u.credentials,cache:u.cache,redirect:u.redirect,integrity:u.integrity,keepalive:u.keepalive,reloadNavigation:u.reloadNavigation,historyNavigation:u.historyNavigation,urlList:[...u.urlList]});let w=Object.keys(r).length!==0;if(w&&(u.mode===`navigate`&&(u.mode=`same-origin`),u.reloadNavigation=!1,u.historyNavigation=!1,u.origin=`client`,u.referrer=`client`,u.referrerPolicy=``,u.url=u.urlList[u.urlList.length-1],u.urlList=[u.url]),r.referrer!==void 0){let e=r.referrer;if(e===``)u.referrer=`no-referrer`;else{let t;try{t=new URL(e,h)}catch(t){throw TypeError(`Referrer "${e}" is not a valid URL.`,{cause:t})}t.protocol===`about:`&&t.hostname===`client`||S&&!_(t,v.settingsObject.baseUrl)?u.referrer=`client`:u.referrer=t}}r.referrerPolicy!==void 0&&(u.referrerPolicy=r.referrerPolicy);let T;if(T=r.mode===void 0?p:r.mode,T===`navigate`)throw P.errors.exception({header:`Request constructor`,message:`invalid request mode navigate.`});if(T!=null&&(u.mode=T),r.credentials!==void 0&&(u.credentials=r.credentials),r.cache!==void 0&&(u.cache=r.cache),u.cache===`only-if-cached`&&u.mode!==`same-origin`)throw TypeError(`'only-if-cached' can be set only with 'same-origin' mode`);if(r.redirect!==void 0&&(u.redirect=r.redirect),r.integrity!=null&&(u.integrity=String(r.integrity)),r.keepalive!==void 0&&(u.keepalive=!!r.keepalive),r.method!==void 0){let e=r.method,t=k[e];if(t!==void 0)u.method=t;else{if(!g(e))throw TypeError(`'${e}' is not a valid HTTP method.`);let t=e.toUpperCase();if(y.has(t))throw TypeError(`'${e}' HTTP method is unsupported.`);e=O[t]??e,u.method=e}!ue&&u.method===`patch`&&(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:`UNDICI-FETCH-patch`}),ue=!0)}r.signal!==void 0&&(x=r.signal),this[M]=u;let E=new AbortController;if(this[j]=E.signal,x!=null){if(!x||typeof x.aborted!=`boolean`||typeof x.addEventListener!=`function`)throw TypeError(`Failed to construct 'Request': member signal is not of type AbortSignal.`);if(x.aborted)E.abort(x.reason);else{this[oe]=E;let e=le(new WeakRef(E));try{(typeof F==`function`&&F(x)===ae||ie(x,`abort`).length>=ae)&&re(1500,x)}catch{}m.addAbortListener(x,e),se.register(E,{signal:x,abort:e},e)}}if(this[A]=new o(te),d(this[A],u.headersList),l(this[A],`request`),T===`no-cors`){if(!b.has(u.method))throw TypeError(`'${u.method} is unsupported in no-cors mode.`);l(this[A],`request-no-cors`)}if(w){let e=f(this[A]),t=r.headers===void 0?new c(e):r.headers;if(e.clear(),t instanceof c){for(let{name:n,value:r}of t.rawValues())e.append(n,r,!1);e.cookies=t.cookies}else s(this[A],t)}let D=t instanceof e?t[M].body:null;if((r.body!=null||D!=null)&&(u.method===`GET`||u.method===`HEAD`))throw TypeError(`Request with GET/HEAD method cannot have body.`);let ee=null;if(r.body!=null){let[e,t]=n(r.body,u.keepalive);ee=e,t&&!f(this[A]).contains(`content-type`,!0)&&this[A].append(`content-type`,t)}let ce=ee??D;if(ce!=null&&ce.source==null){if(ee!=null&&r.duplex==null)throw TypeError(`RequestInit: duplex option is required when sending a body.`);if(u.mode!==`same-origin`&&u.mode!==`cors`)throw TypeError(`If request is made from ReadableStream, mode should be "same-origin" or "cors"`);u.useCORSPreflightFlag=!0}let de=ce;if(ee==null&&D!=null){if(a(t))throw TypeError(`Cannot construct a Request with a Request object that has already been used.`);let e=new TransformStream;D.stream.pipeThrough(e),de={source:D.source,length:D.length,stream:e.readable}}this[M].body=de}get method(){return P.brandCheck(this,e),this[M].method}get url(){return P.brandCheck(this,e),ee(this[M].url)}get headers(){return P.brandCheck(this,e),this[A]}get destination(){return P.brandCheck(this,e),this[M].destination}get referrer(){return P.brandCheck(this,e),this[M].referrer===`no-referrer`?``:this[M].referrer===`client`?`about:client`:this[M].referrer.toString()}get referrerPolicy(){return P.brandCheck(this,e),this[M].referrerPolicy}get mode(){return P.brandCheck(this,e),this[M].mode}get credentials(){return this[M].credentials}get cache(){return P.brandCheck(this,e),this[M].cache}get redirect(){return P.brandCheck(this,e),this[M].redirect}get integrity(){return P.brandCheck(this,e),this[M].integrity}get keepalive(){return P.brandCheck(this,e),this[M].keepalive}get isReloadNavigation(){return P.brandCheck(this,e),this[M].reloadNavigation}get isHistoryNavigation(){return P.brandCheck(this,e),this[M].historyNavigation}get signal(){return P.brandCheck(this,e),this[j]}get body(){return P.brandCheck(this,e),this[M].body?this[M].body.stream:null}get bodyUsed(){return P.brandCheck(this,e),!!this[M].body&&m.isDisturbed(this[M].body.stream)}get duplex(){return P.brandCheck(this,e),`half`}clone(){if(P.brandCheck(this,e),a(this))throw TypeError(`unusable`);let t=fe(this[M]),n=new AbortController;if(this.signal.aborted)n.abort(this.signal.reason);else{let e=ce.get(this.signal);e===void 0&&(e=new Set,ce.set(this.signal,e));let t=new WeakRef(n);e.add(t),m.addAbortListener(n.signal,le(t))}return pe(t,n.signal,u(this[A]))}[h.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let n={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${h.formatWithOptions(t,n)}`}};r(de);function I(e){return{method:e.method??`GET`,localURLsOnly:e.localURLsOnly??!1,unsafeRequest:e.unsafeRequest??!1,body:e.body??null,client:e.client??null,reservedClient:e.reservedClient??null,replacesClientId:e.replacesClientId??``,window:e.window??`client`,keepalive:e.keepalive??!1,serviceWorkers:e.serviceWorkers??`all`,initiator:e.initiator??``,destination:e.destination??``,priority:e.priority??null,origin:e.origin??`client`,policyContainer:e.policyContainer??`client`,referrer:e.referrer??`client`,referrerPolicy:e.referrerPolicy??``,mode:e.mode??`no-cors`,useCORSPreflightFlag:e.useCORSPreflightFlag??!1,credentials:e.credentials??`same-origin`,useCredentials:e.useCredentials??!1,cache:e.cache??`default`,redirect:e.redirect??`follow`,integrity:e.integrity??``,cryptoGraphicsNonceMetadata:e.cryptoGraphicsNonceMetadata??``,parserMetadata:e.parserMetadata??``,reloadNavigation:e.reloadNavigation??!1,historyNavigation:e.historyNavigation??!1,userActivation:e.userActivation??!1,taintedOrigin:e.taintedOrigin??!1,redirectCount:e.redirectCount??0,responseTainting:e.responseTainting??`basic`,preventNoCacheCacheControlHeaderModification:e.preventNoCacheCacheControlHeaderModification??!1,done:e.done??!1,timingAllowFailed:e.timingAllowFailed??!1,urlList:e.urlList,url:e.urlList[0],headersList:e.headersList?new c(e.headersList):new c}}function fe(e){let t=I({...e,body:null});return e.body!=null&&(t.body=i(t,e.body)),t}function pe(e,t,n){let r=new de(te);return r[M]=e,r[j]=t,r[A]=new o(te),d(r[A],e.headersList),l(r[A],n),r}Object.defineProperties(de.prototype,{method:D,url:D,headers:D,redirect:D,clone:D,signal:D,duplex:D,destination:D,body:D,bodyUsed:D,isHistoryNavigation:D,isReloadNavigation:D,keepalive:D,integrity:D,cache:D,credentials:D,attribute:D,referrerPolicy:D,referrer:D,mode:D,[Symbol.toStringTag]:{value:`Request`,configurable:!0}}),P.converters.Request=P.interfaceConverter(de),P.converters.RequestInfo=function(e,t,n){return typeof e==`string`?P.converters.USVString(e,t,n):e instanceof de?P.converters.Request(e,t,n):P.converters.USVString(e,t,n)},P.converters.AbortSignal=P.interfaceConverter(AbortSignal),P.converters.RequestInit=P.dictionaryConverter([{key:`method`,converter:P.converters.ByteString},{key:`headers`,converter:P.converters.HeadersInit},{key:`body`,converter:P.nullableConverter(P.converters.BodyInit)},{key:`referrer`,converter:P.converters.USVString},{key:`referrerPolicy`,converter:P.converters.DOMString,allowedValues:x},{key:`mode`,converter:P.converters.DOMString,allowedValues:C},{key:`credentials`,converter:P.converters.DOMString,allowedValues:w},{key:`cache`,converter:P.converters.DOMString,allowedValues:T},{key:`redirect`,converter:P.converters.DOMString,allowedValues:S},{key:`integrity`,converter:P.converters.DOMString},{key:`keepalive`,converter:P.converters.boolean},{key:`signal`,converter:P.nullableConverter(e=>P.converters.AbortSignal(e,`RequestInit`,`signal`,{strict:!1}))},{key:`window`,converter:P.converters.any},{key:`duplex`,converter:P.converters.DOMString,allowedValues:E},{key:`dispatcher`,converter:P.converters.any}]),t.exports={Request:de,makeRequest:I,fromInnerRequest:pe,cloneRequest:fe}})),Vt=I(((e,t)=>{let{makeNetworkError:n,makeAppropriateNetworkError:r,filterResponse:i,makeResponse:a,fromInnerResponse:o}=Rt(),{HeadersList:s}=Lt(),{Request:c,cloneRequest:l}=Bt(),u=L(`node:zlib`),{bytesMatch:d,makePolicyContainer:f,clonePolicyContainer:p,requestBadPort:m,TAOCheck:h,appendRequestOriginHeader:g,responseLocationURL:_,requestCurrentURL:v,setRequestReferrerPolicyOnRedirect:y,tryUpgradeRequestToAPotentiallyTrustworthyURL:b,createOpaqueTimingInfo:x,appendFetchMetadata:S,corsCheck:C,crossOriginResourcePolicyCheck:w,determineRequestsReferrer:T,coarsenedSharedCurrentTime:E,createDeferredPromise:D,isBlobLike:O,sameOrigin:k,isCancelled:A,isAborted:j,isErrorLike:M,fullyReadBody:N,readableStreamClose:P,isomorphicEncode:ee,urlIsLocal:te,urlIsHttpHttpsScheme:ne,urlHasHttpsScheme:F,clampAndCoarsenConnectionTimingInfo:re,simpleRangeHeaderValue:ie,buildContentRange:ae,createInflate:oe,extractMimeType:se}=Ke(),{kState:ce,kDispatcher:le}=qe(),ue=L(`node:assert`),{safelyExtractBody:de,extractBody:I}=Ze(),{redirectStatusSet:fe,nullBodyStatus:pe,safeMethodsSet:me,requestBodyHeader:he,subresourceSet:ge}=He(),_e=L(`node:events`),{Readable:ve,pipeline:ye,finished:be}=L(`node:stream`),{addAbortListener:xe,isErrored:Se,isReadable:Ce,bufferToLowerCasedHeaderName:we}=z(),{dataURLProcessor:Te,serializeAMimeType:Ee,minimizeSupportedMimeType:De}=We(),{getGlobalDispatcher:Oe}=jt(),{webidl:ke}=Ge(),{STATUS_CODES:R}=L(`node:http`),Ae=[`GET`,`HEAD`],je=typeof __UNDICI_IS_NODE__<`u`||typeof esbuildDetection<`u`?`node`:`undici`,Me;var Ne=class extends _e{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state=`ongoing`}terminate(e){this.state===`ongoing`&&(this.state=`terminated`,this.connection?.destroy(e),this.emit(`terminated`,e))}abort(e){this.state===`ongoing`&&(this.state=`aborted`,e||=new DOMException(`The operation was aborted.`,`AbortError`),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit(`terminated`,e))}};function Pe(e){Ie(e,`fetch`)}function Fe(e,t=void 0){ke.argumentLengthCheck(arguments,1,`globalThis.fetch`);let n=D(),r;try{r=new c(e,t)}catch(e){return n.reject(e),n.promise}let i=r[ce];if(r.signal.aborted)return Re(n,i,null,r.signal.reason),n.promise;i.client.globalObject?.constructor?.name===`ServiceWorkerGlobalScope`&&(i.serviceWorkers=`none`);let a=null,s=!1,l=null;return xe(r.signal,()=>{s=!0,ue(l!=null),l.abort(r.signal.reason);let e=a?.deref();Re(n,i,e,r.signal.reason)}),l=ze({request:i,processResponseEndOfBody:Pe,processResponse:e=>{if(!s){if(e.aborted){Re(n,i,a,l.serializedAbortReason);return}if(e.type===`error`){n.reject(TypeError(`fetch failed`,{cause:e.error}));return}a=new WeakRef(o(e,`immutable`)),n.resolve(a.deref()),n=null}},dispatcher:r[le]}),n.promise}function Ie(e,t=`other`){if(e.type===`error`&&e.aborted||!e.urlList?.length)return;let n=e.urlList[0],r=e.timingInfo,i=e.cacheState;ne(n)&&r!==null&&(e.timingAllowPassed||(r=x({startTime:r.startTime}),i=``),r.endTime=E(),e.timingInfo=r,Le(r,n.href,t,globalThis,i))}let Le=performance.markResourceTiming;function Re(e,t,n,r){if(e&&e.reject(r),t.body!=null&&Ce(t.body?.stream)&&t.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e}),n==null)return;let i=n[ce];i.body!=null&&Ce(i.body?.stream)&&i.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e})}function ze({request:e,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseEndOfBody:i,processResponseConsumeBody:a,useParallelQueue:o=!1,dispatcher:s=Oe()}){ue(s);let c=null,l=!1;e.client!=null&&(c=e.client.globalObject,l=e.client.crossOriginIsolatedCapability);let u=x({startTime:E(l)}),d={controller:new Ne(s),request:e,timingInfo:u,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseConsumeBody:a,processResponseEndOfBody:i,taskDestination:c,crossOriginIsolatedCapability:l};return ue(!e.body||e.body.stream),e.window===`client`&&(e.window=e.client?.globalObject?.constructor?.name===`Window`?e.client:`no-window`),e.origin===`client`&&(e.origin=e.client.origin),e.policyContainer===`client`&&(e.client==null?e.policyContainer=f():e.policyContainer=p(e.client.policyContainer)),e.headersList.contains(`accept`,!0)||e.headersList.append(`accept`,`*/*`,!0),e.headersList.contains(`accept-language`,!0)||e.headersList.append(`accept-language`,`*`,!0),e.priority,ge.has(e.destination),Be(d).catch(e=>{d.controller.terminate(e)}),d.controller}async function Be(e,t=!1){let r=e.request,a=null;if(r.localURLsOnly&&!te(v(r))&&(a=n(`local URLs only`)),b(r),m(r)===`blocked`&&(a=n(`bad port`)),r.referrerPolicy===``&&(r.referrerPolicy=r.policyContainer.referrerPolicy),r.referrer!==`no-referrer`&&(r.referrer=T(r)),a===null&&(a=await(async()=>{let t=v(r);return k(t,r.url)&&r.responseTainting===`basic`||t.protocol===`data:`||r.mode===`navigate`||r.mode===`websocket`?(r.responseTainting=`basic`,await Ve(e)):r.mode===`same-origin`?n(`request mode cannot be "same-origin"`):r.mode===`no-cors`?r.redirect===`follow`?(r.responseTainting=`opaque`,await Ve(e)):n(`redirect mode cannot be "follow" for "no-cors" request`):ne(v(r))?(r.responseTainting=`cors`,await Ye(e)):n(`URL scheme must be a HTTP(S) scheme`)})()),t)return a;a.status!==0&&!a.internalResponse&&(r.responseTainting,r.responseTainting===`basic`?a=i(a,`basic`):r.responseTainting===`cors`?a=i(a,`cors`):r.responseTainting===`opaque`?a=i(a,`opaque`):ue(!1));let o=a.status===0?a:a.internalResponse;if(o.urlList.length===0&&o.urlList.push(...r.urlList),r.timingAllowFailed||(a.timingAllowPassed=!0),a.type===`opaque`&&o.status===206&&o.rangeRequested&&!r.headers.contains(`range`,!0)&&(a=o=n()),a.status!==0&&(r.method===`HEAD`||r.method===`CONNECT`||pe.includes(o.status))&&(o.body=null,e.controller.dump=!0),r.integrity){let t=t=>Je(e,n(t));if(r.responseTainting===`opaque`||a.body==null){t(a.error);return}await N(a.body,n=>{if(!d(n,r.integrity)){t(`integrity mismatch`);return}a.body=de(n)[0],Je(e,a)},t)}else Je(e,a)}function Ve(e){if(A(e)&&e.request.redirectCount===0)return Promise.resolve(r(e));let{request:t}=e,{protocol:i}=v(t);switch(i){case`about:`:return Promise.resolve(n(`about scheme is not supported`));case`blob:`:{Me||=L(`node:buffer`).resolveObjectURL;let e=v(t);if(e.search.length!==0)return Promise.resolve(n(`NetworkError when attempting to fetch resource.`));let r=Me(e.toString());if(t.method!==`GET`||!O(r))return Promise.resolve(n(`invalid method`));let i=a(),o=r.size,s=ee(`${o}`),c=r.type;if(t.headersList.contains(`range`,!0)){i.rangeRequested=!0;let e=ie(t.headersList.get(`range`,!0),!0);if(e===`failure`)return Promise.resolve(n(`failed to fetch the data URL`));let{rangeStartValue:a,rangeEndValue:s}=e;if(a===null)a=o-s,s=a+s-1;else{if(a>=o)return Promise.resolve(n(`Range start is greater than the blob's size.`));(s===null||s>=o)&&(s=o-1)}let l=r.slice(a,s,c);i.body=I(l)[0];let u=ee(`${l.size}`),d=ae(a,s,o);i.status=206,i.statusText=`Partial Content`,i.headersList.set(`content-length`,u,!0),i.headersList.set(`content-type`,c,!0),i.headersList.set(`content-range`,d,!0)}else{let e=I(r);i.statusText=`OK`,i.body=e[0],i.headersList.set(`content-length`,s,!0),i.headersList.set(`content-type`,c,!0)}return Promise.resolve(i)}case`data:`:{let e=Te(v(t));if(e===`failure`)return Promise.resolve(n(`failed to fetch the data URL`));let r=Ee(e.mimeType);return Promise.resolve(a({statusText:`OK`,headersList:[[`content-type`,{name:`Content-Type`,value:r}]],body:de(e.body)[0]}))}case`file:`:return Promise.resolve(n(`not implemented... yet...`));case`http:`:case`https:`:return Ye(e).catch(e=>n(e));default:return Promise.resolve(n(`unknown scheme`))}}function Ue(e,t){e.request.done=!0,e.processResponseDone!=null&&queueMicrotask(()=>e.processResponseDone(t))}function Je(e,t){let n=e.timingInfo,r=()=>{let r=Date.now();e.request.destination===`document`&&(e.controller.fullTimingInfo=n),e.controller.reportTimingSteps=()=>{if(e.request.url.protocol!==`https:`)return;n.endTime=r;let i=t.cacheState,a=t.bodyInfo;t.timingAllowPassed||(n=x(n),i=``);let o=0;if(e.request.mode!==`navigator`||!t.hasCrossOriginRedirects){o=t.status;let e=se(t.headersList);e!==`failure`&&(a.contentType=De(e))}e.request.initiatorType!=null&&Le(n,e.request.url.href,e.request.initiatorType,globalThis,i,a,o)};let i=()=>{e.request.done=!0,e.processResponseEndOfBody!=null&&queueMicrotask(()=>e.processResponseEndOfBody(t)),e.request.initiatorType!=null&&e.controller.reportTimingSteps()};queueMicrotask(()=>i())};e.processResponse!=null&&queueMicrotask(()=>{e.processResponse(t),e.processResponse=null});let i=t.type===`error`?t:t.internalResponse??t;i.body==null?r():be(i.body.stream,()=>{r()})}async function Ye(e){let t=e.request,r=null,i=null,a=e.timingInfo;if(t.serviceWorkers,r===null){if(t.redirect===`follow`&&(t.serviceWorkers=`none`),i=r=await Qe(e),t.responseTainting===`cors`&&C(t,r)===`failure`)return n(`cors failure`);h(t,r)===`failure`&&(t.timingAllowFailed=!0)}return(t.responseTainting===`opaque`||r.type===`opaque`)&&w(t.origin,t.client,t.destination,i)===`blocked`?n(`blocked`):(fe.has(i.status)&&(t.redirect!==`manual`&&e.controller.connection.destroy(void 0,!1),t.redirect===`error`?r=n(`unexpected redirect`):t.redirect===`manual`?r=i:t.redirect===`follow`?r=await Xe(e,r):ue(!1)),r.timingInfo=a,r)}function Xe(e,t){let r=e.request,i=t.internalResponse?t.internalResponse:t,a;try{if(a=_(i,v(r).hash),a==null)return t}catch(e){return Promise.resolve(n(e))}if(!ne(a))return Promise.resolve(n(`URL scheme must be a HTTP(S) scheme`));if(r.redirectCount===20)return Promise.resolve(n(`redirect count exceeded`));if(r.redirectCount+=1,r.mode===`cors`&&(a.username||a.password)&&!k(r,a))return Promise.resolve(n(`cross origin not allowed for request mode "cors"`));if(r.responseTainting===`cors`&&(a.username||a.password))return Promise.resolve(n(`URL cannot contain credentials for request mode "cors"`));if(i.status!==303&&r.body!=null&&r.body.source==null)return Promise.resolve(n());if([301,302].includes(i.status)&&r.method===`POST`||i.status===303&&!Ae.includes(r.method)){r.method=`GET`,r.body=null;for(let e of he)r.headersList.delete(e)}k(v(r),a)||(r.headersList.delete(`authorization`,!0),r.headersList.delete(`proxy-authorization`,!0),r.headersList.delete(`cookie`,!0),r.headersList.delete(`host`,!0)),r.body!=null&&(ue(r.body.source!=null),r.body=de(r.body.source)[0]);let o=e.timingInfo;return o.redirectEndTime=o.postRedirectStartTime=E(e.crossOriginIsolatedCapability),o.redirectStartTime===0&&(o.redirectStartTime=o.startTime),r.urlList.push(a),y(r,i),Be(e,!0)}async function Qe(e,t=!1,i=!1){let a=e.request,o=null,s=null,c=null;a.window===`no-window`&&a.redirect===`error`?(o=e,s=a):(s=l(a),o={...e},o.request=s);let u=a.credentials===`include`||a.credentials===`same-origin`&&a.responseTainting===`basic`,d=s.body?s.body.length:null,f=null;if(s.body==null&&[`POST`,`PUT`].includes(s.method)&&(f=`0`),d!=null&&(f=ee(`${d}`)),f!=null&&s.headersList.append(`content-length`,f,!0),d!=null&&s.keepalive,s.referrer instanceof URL&&s.headersList.append(`referer`,ee(s.referrer.href),!0),g(s),S(s),s.headersList.contains(`user-agent`,!0)||s.headersList.append(`user-agent`,je),s.cache===`default`&&(s.headersList.contains(`if-modified-since`,!0)||s.headersList.contains(`if-none-match`,!0)||s.headersList.contains(`if-unmodified-since`,!0)||s.headersList.contains(`if-match`,!0)||s.headersList.contains(`if-range`,!0))&&(s.cache=`no-store`),s.cache===`no-cache`&&!s.preventNoCacheCacheControlHeaderModification&&!s.headersList.contains(`cache-control`,!0)&&s.headersList.append(`cache-control`,`max-age=0`,!0),(s.cache===`no-store`||s.cache===`reload`)&&(s.headersList.contains(`pragma`,!0)||s.headersList.append(`pragma`,`no-cache`,!0),s.headersList.contains(`cache-control`,!0)||s.headersList.append(`cache-control`,`no-cache`,!0)),s.headersList.contains(`range`,!0)&&s.headersList.append(`accept-encoding`,`identity`,!0),s.headersList.contains(`accept-encoding`,!0)||(F(v(s))?s.headersList.append(`accept-encoding`,`br, gzip, deflate`,!0):s.headersList.append(`accept-encoding`,`gzip, deflate`,!0)),s.headersList.delete(`host`,!0),s.cache=`no-store`,s.cache!==`no-store`&&s.cache,c==null){if(s.cache===`only-if-cached`)return n(`only if cached`);let e=await $e(o,u,i);!me.has(s.method)&&e.status>=200&&e.status,c??=e}if(c.urlList=[...s.urlList],s.headersList.contains(`range`,!0)&&(c.rangeRequested=!0),c.requestIncludesCredentials=u,c.status===407)return a.window===`no-window`?n():A(e)?r(e):n(`proxy authentication required`);if(c.status===421&&!i&&(a.body==null||a.body.source!=null)){if(A(e))return r(e);e.controller.connection.destroy(),c=await Qe(e,t,!0)}return c}async function $e(e,t=!1,i=!1){ue(!e.controller.connection||e.controller.connection.destroyed),e.controller.connection={abort:null,destroyed:!1,destroy(e,t=!0){this.destroyed||(this.destroyed=!0,t&&this.abort?.(e??new DOMException(`The operation was aborted.`,`AbortError`)))}};let o=e.request,c=null,l=e.timingInfo;o.cache=`no-store`,o.mode;let d=null;if(o.body==null&&e.processRequestEndOfBody)queueMicrotask(()=>e.processRequestEndOfBody());else if(o.body!=null){let t=async function*(t){A(e)||(yield t,e.processRequestBodyChunkLength?.(t.byteLength))},n=()=>{A(e)||e.processRequestEndOfBody&&e.processRequestEndOfBody()},r=t=>{A(e)||(t.name===`AbortError`?e.controller.abort():e.controller.terminate(t))};d=(async function*(){try{for await(let e of o.body.stream)yield*t(e);n()}catch(e){r(e)}})()}try{let{body:t,status:n,statusText:r,headersList:i,socket:o}=await g({body:d});if(o)c=a({status:n,statusText:r,headersList:i,socket:o});else{let o=t[Symbol.asyncIterator]();e.controller.next=()=>o.next(),c=a({status:n,statusText:r,headersList:i})}}catch(t){return t.name===`AbortError`?(e.controller.connection.destroy(),r(e,t)):n(t)}let f=async()=>{await e.controller.resume()},p=t=>{A(e)||e.controller.abort(t)},m=new ReadableStream({async start(t){e.controller.controller=t},async pull(e){await f(e)},async cancel(e){await p(e)},type:`bytes`});c.body={stream:m,source:null,length:null},e.controller.onAborted=h,e.controller.on(`terminated`,h),e.controller.resume=async()=>{for(;;){let t,n;try{let{done:n,value:r}=await e.controller.next();if(j(e))break;t=n?void 0:r}catch(r){e.controller.ended&&!l.encodedBodySize?t=void 0:(t=r,n=!0)}if(t===void 0){P(e.controller.controller),Ue(e,c);return}if(l.decodedBodySize+=t?.byteLength??0,n){e.controller.terminate(t);return}let r=new Uint8Array(t);if(r.byteLength&&e.controller.controller.enqueue(r),Se(m)){e.controller.terminate();return}if(e.controller.controller.desiredSize<=0)return}};function h(t){j(e)?(c.aborted=!0,Ce(m)&&e.controller.controller.error(e.controller.serializedAbortReason)):Ce(m)&&e.controller.controller.error(TypeError(`terminated`,{cause:M(t)?t:void 0})),e.controller.connection.destroy()}return c;function g({body:t}){let n=v(o),r=e.controller.dispatcher;return new Promise((i,a)=>r.dispatch({path:n.pathname+n.search,origin:n.origin,method:o.method,body:r.isMockActive?o.body&&(o.body.source||o.body.stream):t,headers:o.headersList.entries,maxRedirections:0,upgrade:o.mode===`websocket`?`websocket`:void 0},{body:null,abort:null,onConnect(t){let{connection:n}=e.controller;l.finalConnectionTimingInfo=re(void 0,l.postRedirectStartTime,e.crossOriginIsolatedCapability),n.destroyed?t(new DOMException(`The operation was aborted.`,`AbortError`)):(e.controller.on(`terminated`,t),this.abort=n.abort=t),l.finalNetworkRequestStartTime=E(e.crossOriginIsolatedCapability)},onResponseStarted(){l.finalNetworkResponseStartTime=E(e.crossOriginIsolatedCapability)},onHeaders(e,t,n,r){if(e<200)return;let c=``,l=new s;for(let e=0;e5)return a(Error(`too many content-encodings in response: ${t.length}, maximum allowed is 5`)),!0;for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n===`x-gzip`||n===`gzip`)d.push(u.createGunzip({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if(n===`deflate`)d.push(oe({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if(n===`br`)d.push(u.createBrotliDecompress({flush:u.constants.BROTLI_OPERATION_FLUSH,finishFlush:u.constants.BROTLI_OPERATION_FLUSH}));else{d.length=0;break}}}let p=this.onError.bind(this);return i({status:e,statusText:r,headersList:l,body:d.length?ye(this.body,...d,e=>{e&&this.onError(e)}).on(`error`,p):this.body.on(`error`,p)}),!0},onData(t){if(e.controller.dump)return;let n=t;return l.encodedBodySize+=n.byteLength,this.body.push(n)},onComplete(){this.abort&&e.controller.off(`terminated`,this.abort),e.controller.onAborted&&e.controller.off(`terminated`,e.controller.onAborted),e.controller.ended=!0,this.body.push(null)},onError(t){this.abort&&e.controller.off(`terminated`,this.abort),this.body?.destroy(t),e.controller.terminate(t),a(t)},onUpgrade(e,t,n){if(e!==101)return;let r=new s;for(let e=0;e{t.exports={kState:Symbol(`FileReader state`),kResult:Symbol(`FileReader result`),kError:Symbol(`FileReader error`),kLastProgressEventFired:Symbol(`FileReader last progress event fired timestamp`),kEvents:Symbol(`FileReader events`),kAborted:Symbol(`FileReader aborted`)}})),Ut=I(((e,t)=>{let{webidl:n}=Ge(),r=Symbol(`ProgressEvent state`);var i=class e extends Event{constructor(e,t={}){e=n.converters.DOMString(e,`ProgressEvent constructor`,`type`),t=n.converters.ProgressEventInit(t??{}),super(e,t),this[r]={lengthComputable:t.lengthComputable,loaded:t.loaded,total:t.total}}get lengthComputable(){return n.brandCheck(this,e),this[r].lengthComputable}get loaded(){return n.brandCheck(this,e),this[r].loaded}get total(){return n.brandCheck(this,e),this[r].total}};n.converters.ProgressEventInit=n.dictionaryConverter([{key:`lengthComputable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`loaded`,converter:n.converters[`unsigned long long`],defaultValue:()=>0},{key:`total`,converter:n.converters[`unsigned long long`],defaultValue:()=>0},{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}]),t.exports={ProgressEvent:i}})),Wt=I(((e,t)=>{function n(e){if(!e)return`failure`;switch(e.trim().toLowerCase()){case`unicode-1-1-utf-8`:case`unicode11utf8`:case`unicode20utf8`:case`utf-8`:case`utf8`:case`x-unicode20utf8`:return`UTF-8`;case`866`:case`cp866`:case`csibm866`:case`ibm866`:return`IBM866`;case`csisolatin2`:case`iso-8859-2`:case`iso-ir-101`:case`iso8859-2`:case`iso88592`:case`iso_8859-2`:case`iso_8859-2:1987`:case`l2`:case`latin2`:return`ISO-8859-2`;case`csisolatin3`:case`iso-8859-3`:case`iso-ir-109`:case`iso8859-3`:case`iso88593`:case`iso_8859-3`:case`iso_8859-3:1988`:case`l3`:case`latin3`:return`ISO-8859-3`;case`csisolatin4`:case`iso-8859-4`:case`iso-ir-110`:case`iso8859-4`:case`iso88594`:case`iso_8859-4`:case`iso_8859-4:1988`:case`l4`:case`latin4`:return`ISO-8859-4`;case`csisolatincyrillic`:case`cyrillic`:case`iso-8859-5`:case`iso-ir-144`:case`iso8859-5`:case`iso88595`:case`iso_8859-5`:case`iso_8859-5:1988`:return`ISO-8859-5`;case`arabic`:case`asmo-708`:case`csiso88596e`:case`csiso88596i`:case`csisolatinarabic`:case`ecma-114`:case`iso-8859-6`:case`iso-8859-6-e`:case`iso-8859-6-i`:case`iso-ir-127`:case`iso8859-6`:case`iso88596`:case`iso_8859-6`:case`iso_8859-6:1987`:return`ISO-8859-6`;case`csisolatingreek`:case`ecma-118`:case`elot_928`:case`greek`:case`greek8`:case`iso-8859-7`:case`iso-ir-126`:case`iso8859-7`:case`iso88597`:case`iso_8859-7`:case`iso_8859-7:1987`:case`sun_eu_greek`:return`ISO-8859-7`;case`csiso88598e`:case`csisolatinhebrew`:case`hebrew`:case`iso-8859-8`:case`iso-8859-8-e`:case`iso-ir-138`:case`iso8859-8`:case`iso88598`:case`iso_8859-8`:case`iso_8859-8:1988`:case`visual`:return`ISO-8859-8`;case`csiso88598i`:case`iso-8859-8-i`:case`logical`:return`ISO-8859-8-I`;case`csisolatin6`:case`iso-8859-10`:case`iso-ir-157`:case`iso8859-10`:case`iso885910`:case`l6`:case`latin6`:return`ISO-8859-10`;case`iso-8859-13`:case`iso8859-13`:case`iso885913`:return`ISO-8859-13`;case`iso-8859-14`:case`iso8859-14`:case`iso885914`:return`ISO-8859-14`;case`csisolatin9`:case`iso-8859-15`:case`iso8859-15`:case`iso885915`:case`iso_8859-15`:case`l9`:return`ISO-8859-15`;case`iso-8859-16`:return`ISO-8859-16`;case`cskoi8r`:case`koi`:case`koi8`:case`koi8-r`:case`koi8_r`:return`KOI8-R`;case`koi8-ru`:case`koi8-u`:return`KOI8-U`;case`csmacintosh`:case`mac`:case`macintosh`:case`x-mac-roman`:return`macintosh`;case`iso-8859-11`:case`iso8859-11`:case`iso885911`:case`tis-620`:case`windows-874`:return`windows-874`;case`cp1250`:case`windows-1250`:case`x-cp1250`:return`windows-1250`;case`cp1251`:case`windows-1251`:case`x-cp1251`:return`windows-1251`;case`ansi_x3.4-1968`:case`ascii`:case`cp1252`:case`cp819`:case`csisolatin1`:case`ibm819`:case`iso-8859-1`:case`iso-ir-100`:case`iso8859-1`:case`iso88591`:case`iso_8859-1`:case`iso_8859-1:1987`:case`l1`:case`latin1`:case`us-ascii`:case`windows-1252`:case`x-cp1252`:return`windows-1252`;case`cp1253`:case`windows-1253`:case`x-cp1253`:return`windows-1253`;case`cp1254`:case`csisolatin5`:case`iso-8859-9`:case`iso-ir-148`:case`iso8859-9`:case`iso88599`:case`iso_8859-9`:case`iso_8859-9:1989`:case`l5`:case`latin5`:case`windows-1254`:case`x-cp1254`:return`windows-1254`;case`cp1255`:case`windows-1255`:case`x-cp1255`:return`windows-1255`;case`cp1256`:case`windows-1256`:case`x-cp1256`:return`windows-1256`;case`cp1257`:case`windows-1257`:case`x-cp1257`:return`windows-1257`;case`cp1258`:case`windows-1258`:case`x-cp1258`:return`windows-1258`;case`x-mac-cyrillic`:case`x-mac-ukrainian`:return`x-mac-cyrillic`;case`chinese`:case`csgb2312`:case`csiso58gb231280`:case`gb2312`:case`gb_2312`:case`gb_2312-80`:case`gbk`:case`iso-ir-58`:case`x-gbk`:return`GBK`;case`gb18030`:return`gb18030`;case`big5`:case`big5-hkscs`:case`cn-big5`:case`csbig5`:case`x-x-big5`:return`Big5`;case`cseucpkdfmtjapanese`:case`euc-jp`:case`x-euc-jp`:return`EUC-JP`;case`csiso2022jp`:case`iso-2022-jp`:return`ISO-2022-JP`;case`csshiftjis`:case`ms932`:case`ms_kanji`:case`shift-jis`:case`shift_jis`:case`sjis`:case`windows-31j`:case`x-sjis`:return`Shift_JIS`;case`cseuckr`:case`csksc56011987`:case`euc-kr`:case`iso-ir-149`:case`korean`:case`ks_c_5601-1987`:case`ks_c_5601-1989`:case`ksc5601`:case`ksc_5601`:case`windows-949`:return`EUC-KR`;case`csiso2022kr`:case`hz-gb-2312`:case`iso-2022-cn`:case`iso-2022-cn-ext`:case`iso-2022-kr`:case`replacement`:return`replacement`;case`unicodefffe`:case`utf-16be`:return`UTF-16BE`;case`csunicode`:case`iso-10646-ucs-2`:case`ucs-2`:case`unicode`:case`unicodefeff`:case`utf-16`:case`utf-16le`:return`UTF-16LE`;case`x-user-defined`:return`x-user-defined`;default:return`failure`}}t.exports={getEncoding:n}})),Gt=I(((e,t)=>{let{kState:n,kError:r,kResult:i,kAborted:a,kLastProgressEventFired:o}=Ht(),{ProgressEvent:s}=Ut(),{getEncoding:c}=Wt(),{serializeAMimeType:l,parseMIMEType:u}=We(),{types:d}=L(`node:util`),{StringDecoder:f}=L(`string_decoder`),{btoa:p}=L(`node:buffer`),m={enumerable:!0,writable:!1,configurable:!1};function h(e,t,s,c){if(e[n]===`loading`)throw new DOMException(`Invalid state`,`InvalidStateError`);e[n]=`loading`,e[i]=null,e[r]=null;let l=t.stream().getReader(),u=[],f=l.read(),p=!0;(async()=>{for(;!e[a];)try{let{done:m,value:h}=await f;if(p&&!e[a]&&queueMicrotask(()=>{g(`loadstart`,e)}),p=!1,!m&&d.isUint8Array(h))u.push(h),(e[o]===void 0||Date.now()-e[o]>=50)&&!e[a]&&(e[o]=Date.now(),queueMicrotask(()=>{g(`progress`,e)})),f=l.read();else if(m){queueMicrotask(()=>{e[n]=`done`;try{let n=_(u,s,t.type,c);if(e[a])return;e[i]=n,g(`load`,e)}catch(t){e[r]=t,g(`error`,e)}e[n]!==`loading`&&g(`loadend`,e)});break}}catch(t){if(e[a])return;queueMicrotask(()=>{e[n]=`done`,e[r]=t,g(`error`,e),e[n]!==`loading`&&g(`loadend`,e)});break}})()}function g(e,t){let n=new s(e,{bubbles:!1,cancelable:!1});t.dispatchEvent(n)}function _(e,t,n,r){switch(t){case`DataURL`:{let t=`data:`,r=u(n||`application/octet-stream`);r!==`failure`&&(t+=l(r)),t+=`;base64,`;let i=new f(`latin1`);for(let n of e)t+=p(i.write(n));return t+=p(i.end()),t}case`Text`:{let t=`failure`;if(r&&(t=c(r)),t===`failure`&&n){let e=u(n);e!==`failure`&&(t=c(e.parameters.get(`charset`)))}return t===`failure`&&(t=`UTF-8`),v(e,t)}case`ArrayBuffer`:return b(e).buffer;case`BinaryString`:{let t=``,n=new f(`latin1`);for(let r of e)t+=n.write(r);return t+=n.end(),t}}}function v(e,t){let n=b(e),r=y(n),i=0;r!==null&&(t=r,i=r===`UTF-8`?3:2);let a=n.slice(i);return new TextDecoder(t).decode(a)}function y(e){let[t,n,r]=e;return t===239&&n===187&&r===191?`UTF-8`:t===254&&n===255?`UTF-16BE`:t===255&&n===254?`UTF-16LE`:null}function b(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=0;return e.reduce((e,t)=>(e.set(t,n),n+=t.byteLength,e),new Uint8Array(t))}t.exports={staticPropertyDescriptors:m,readOperation:h,fireAProgressEvent:g}})),Kt=I(((e,t)=>{let{staticPropertyDescriptors:n,readOperation:r,fireAProgressEvent:i}=Gt(),{kState:a,kError:o,kResult:s,kEvents:c,kAborted:l}=Ht(),{webidl:u}=Ge(),{kEnumerableProperty:d}=z();var f=class e extends EventTarget{constructor(){super(),this[a]=`empty`,this[s]=null,this[o]=null,this[c]={loadend:null,error:null,abort:null,load:null,progress:null,loadstart:null}}readAsArrayBuffer(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsArrayBuffer`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`ArrayBuffer`)}readAsBinaryString(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsBinaryString`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`BinaryString`)}readAsText(t,n=void 0){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsText`),t=u.converters.Blob(t,{strict:!1}),n!==void 0&&(n=u.converters.DOMString(n,`FileReader.readAsText`,`encoding`)),r(this,t,`Text`,n)}readAsDataURL(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsDataURL`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`DataURL`)}abort(){if(this[a]===`empty`||this[a]===`done`){this[s]=null;return}this[a]===`loading`&&(this[a]=`done`,this[s]=null),this[l]=!0,i(`abort`,this),this[a]!==`loading`&&i(`loadend`,this)}get readyState(){switch(u.brandCheck(this,e),this[a]){case`empty`:return this.EMPTY;case`loading`:return this.LOADING;case`done`:return this.DONE}}get result(){return u.brandCheck(this,e),this[s]}get error(){return u.brandCheck(this,e),this[o]}get onloadend(){return u.brandCheck(this,e),this[c].loadend}set onloadend(t){u.brandCheck(this,e),this[c].loadend&&this.removeEventListener(`loadend`,this[c].loadend),typeof t==`function`?(this[c].loadend=t,this.addEventListener(`loadend`,t)):this[c].loadend=null}get onerror(){return u.brandCheck(this,e),this[c].error}set onerror(t){u.brandCheck(this,e),this[c].error&&this.removeEventListener(`error`,this[c].error),typeof t==`function`?(this[c].error=t,this.addEventListener(`error`,t)):this[c].error=null}get onloadstart(){return u.brandCheck(this,e),this[c].loadstart}set onloadstart(t){u.brandCheck(this,e),this[c].loadstart&&this.removeEventListener(`loadstart`,this[c].loadstart),typeof t==`function`?(this[c].loadstart=t,this.addEventListener(`loadstart`,t)):this[c].loadstart=null}get onprogress(){return u.brandCheck(this,e),this[c].progress}set onprogress(t){u.brandCheck(this,e),this[c].progress&&this.removeEventListener(`progress`,this[c].progress),typeof t==`function`?(this[c].progress=t,this.addEventListener(`progress`,t)):this[c].progress=null}get onload(){return u.brandCheck(this,e),this[c].load}set onload(t){u.brandCheck(this,e),this[c].load&&this.removeEventListener(`load`,this[c].load),typeof t==`function`?(this[c].load=t,this.addEventListener(`load`,t)):this[c].load=null}get onabort(){return u.brandCheck(this,e),this[c].abort}set onabort(t){u.brandCheck(this,e),this[c].abort&&this.removeEventListener(`abort`,this[c].abort),typeof t==`function`?(this[c].abort=t,this.addEventListener(`abort`,t)):this[c].abort=null}};f.EMPTY=f.prototype.EMPTY=0,f.LOADING=f.prototype.LOADING=1,f.DONE=f.prototype.DONE=2,Object.defineProperties(f.prototype,{EMPTY:n,LOADING:n,DONE:n,readAsArrayBuffer:d,readAsBinaryString:d,readAsText:d,readAsDataURL:d,abort:d,readyState:d,result:d,error:d,onloadstart:d,onprogress:d,onload:d,onabort:d,onerror:d,onloadend:d,[Symbol.toStringTag]:{value:`FileReader`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(f,{EMPTY:n,LOADING:n,DONE:n}),t.exports={FileReader:f}})),qt=I(((e,t)=>{t.exports={kConstruct:ke().kConstruct}})),Jt=I(((e,t)=>{let n=L(`node:assert`),{URLSerializer:r}=We(),{isValidHeaderName:i}=Ke();function a(e,t,n=!1){return r(e,n)===r(t,n)}function o(e){n(e!==null);let t=[];for(let n of e.split(`,`))n=n.trim(),i(n)&&t.push(n);return t}t.exports={urlEquals:a,getFieldValues:o}})),Yt=I(((e,t)=>{let{kConstruct:n}=qt(),{urlEquals:r,getFieldValues:i}=Jt(),{kEnumerableProperty:a,isDisturbed:o}=z(),{webidl:s}=Ge(),{Response:c,cloneResponse:l,fromInnerResponse:u}=Rt(),{Request:d,fromInnerRequest:f}=Bt(),{kState:p}=qe(),{fetching:m}=Vt(),{urlIsHttpHttpsScheme:h,createDeferredPromise:g,readAllBytes:_}=Ke(),v=L(`node:assert`);var y=class e{#e;constructor(){arguments[0]!==n&&s.illegalConstructor(),s.util.markAsUncloneable(this),this.#e=arguments[1]}async match(t,n={}){s.brandCheck(this,e);let r=`Cache.match`;s.argumentLengthCheck(arguments,1,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.CacheQueryOptions(n,r,`options`);let i=this.#i(t,n,1);if(i.length!==0)return i[0]}async matchAll(t=void 0,n={}){s.brandCheck(this,e);let r=`Cache.matchAll`;return t!==void 0&&(t=s.converters.RequestInfo(t,r,`request`)),n=s.converters.CacheQueryOptions(n,r,`options`),this.#i(t,n)}async add(t){s.brandCheck(this,e);let n=`Cache.add`;s.argumentLengthCheck(arguments,1,n),t=s.converters.RequestInfo(t,n,`request`);let r=[t];return await this.addAll(r)}async addAll(t){s.brandCheck(this,e);let n=`Cache.addAll`;s.argumentLengthCheck(arguments,1,n);let r=[],a=[];for(let e of t){if(e===void 0)throw s.errors.conversionFailed({prefix:n,argument:`Argument 1`,types:[`undefined is not allowed`]});if(e=s.converters.RequestInfo(e),typeof e==`string`)continue;let t=e[p];if(!h(t.url)||t.method!==`GET`)throw s.errors.exception({header:n,message:`Expected http/s scheme when method is not GET.`})}let o=[];for(let e of t){let t=new d(e)[p];if(!h(t.url))throw s.errors.exception({header:n,message:`Expected http/s scheme.`});t.initiator=`fetch`,t.destination=`subresource`,a.push(t);let c=g();o.push(m({request:t,processResponse(e){if(e.type===`error`||e.status===206||e.status<200||e.status>299)c.reject(s.errors.exception({header:`Cache.addAll`,message:`Received an invalid status code or the request failed.`}));else if(e.headersList.contains(`vary`)){let t=i(e.headersList.get(`vary`));for(let e of t)if(e===`*`){c.reject(s.errors.exception({header:`Cache.addAll`,message:`invalid vary field value`}));for(let e of o)e.abort();return}}},processResponseEndOfBody(e){if(e.aborted){c.reject(new DOMException(`aborted`,`AbortError`));return}c.resolve(e)}})),r.push(c.promise)}let c=await Promise.all(r),l=[],u=0;for(let e of c){let t={type:`put`,request:a[u],response:e};l.push(t),u++}let f=g(),_=null;try{this.#t(l)}catch(e){_=e}return queueMicrotask(()=>{_===null?f.resolve(void 0):f.reject(_)}),f.promise}async put(t,n){s.brandCheck(this,e);let r=`Cache.put`;s.argumentLengthCheck(arguments,2,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.Response(n,r,`response`);let a=null;if(a=t instanceof d?t[p]:new d(t)[p],!h(a.url)||a.method!==`GET`)throw s.errors.exception({header:r,message:`Expected an http/s scheme when method is not GET`});let c=n[p];if(c.status===206)throw s.errors.exception({header:r,message:`Got 206 status`});if(c.headersList.contains(`vary`)){let e=i(c.headersList.get(`vary`));for(let t of e)if(t===`*`)throw s.errors.exception({header:r,message:`Got * vary field value`})}if(c.body&&(o(c.body.stream)||c.body.stream.locked))throw s.errors.exception({header:r,message:`Response body is locked or disturbed`});let u=l(c),f=g();c.body==null?f.resolve(void 0):_(c.body.stream.getReader()).then(f.resolve,f.reject);let m=[],v={type:`put`,request:a,response:u};m.push(v);let y=await f.promise;u.body!=null&&(u.body.source=y);let b=g(),x=null;try{this.#t(m)}catch(e){x=e}return queueMicrotask(()=>{x===null?b.resolve():b.reject(x)}),b.promise}async delete(t,n={}){s.brandCheck(this,e);let r=`Cache.delete`;s.argumentLengthCheck(arguments,1,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.CacheQueryOptions(n,r,`options`);let i=null;if(t instanceof d){if(i=t[p],i.method!==`GET`&&!n.ignoreMethod)return!1}else v(typeof t==`string`),i=new d(t)[p];let a=[],o={type:`delete`,request:i,options:n};a.push(o);let c=g(),l=null,u;try{u=this.#t(a)}catch(e){l=e}return queueMicrotask(()=>{l===null?c.resolve(!!u?.length):c.reject(l)}),c.promise}async keys(t=void 0,n={}){s.brandCheck(this,e);let r=`Cache.keys`;t!==void 0&&(t=s.converters.RequestInfo(t,r,`request`)),n=s.converters.CacheQueryOptions(n,r,`options`);let i=null;if(t!==void 0)if(t instanceof d){if(i=t[p],i.method!==`GET`&&!n.ignoreMethod)return[]}else typeof t==`string`&&(i=new d(t)[p]);let a=g(),o=[];if(t===void 0)for(let e of this.#e)o.push(e[0]);else{let e=this.#n(i,n);for(let t of e)o.push(t[0])}return queueMicrotask(()=>{let e=[];for(let t of o){let n=f(t,new AbortController().signal,`immutable`);e.push(n)}a.resolve(Object.freeze(e))}),a.promise}#t(e){let t=this.#e,n=[...t],r=[],i=[];try{for(let n of e){if(n.type!==`delete`&&n.type!==`put`)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`operation type does not match "delete" or "put"`});if(n.type===`delete`&&n.response!=null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`delete operation should not have an associated response`});if(this.#n(n.request,n.options,r).length)throw new DOMException(`???`,`InvalidStateError`);let e;if(n.type===`delete`){if(e=this.#n(n.request,n.options),e.length===0)return[];for(let n of e){let e=t.indexOf(n);v(e!==-1),t.splice(e,1)}}else if(n.type===`put`){if(n.response==null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`put operation should have an associated response`});let i=n.request;if(!h(i.url))throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`expected http or https scheme`});if(i.method!==`GET`)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`not get method`});if(n.options!=null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`options must not be defined`});e=this.#n(n.request);for(let n of e){let e=t.indexOf(n);v(e!==-1),t.splice(e,1)}t.push([n.request,n.response]),r.push([n.request,n.response])}i.push([n.request,n.response])}return i}catch(e){throw this.#e.length=0,this.#e=n,e}}#n(e,t,n){let r=[],i=n??this.#e;for(let n of i){let[i,a]=n;this.#r(e,i,a,t)&&r.push(n)}return r}#r(e,t,n=null,a){let o=new URL(e.url),s=new URL(t.url);if(a?.ignoreSearch&&(s.search=``,o.search=``),!r(o,s,!0))return!1;if(n==null||a?.ignoreVary||!n.headersList.contains(`vary`))return!0;let c=i(n.headersList.get(`vary`));for(let n of c)if(n===`*`||t.headersList.get(n)!==e.headersList.get(n))return!1;return!0}#i(e,t,n=1/0){let r=null;if(e!==void 0)if(e instanceof d){if(r=e[p],r.method!==`GET`&&!t.ignoreMethod)return[]}else typeof e==`string`&&(r=new d(e)[p]);let i=[];if(e===void 0)for(let e of this.#e)i.push(e[1]);else{let e=this.#n(r,t);for(let t of e)i.push(t[1])}let a=[];for(let e of i){let t=u(e,`immutable`);if(a.push(t.clone()),a.length>=n)break}return Object.freeze(a)}};Object.defineProperties(y.prototype,{[Symbol.toStringTag]:{value:`Cache`,configurable:!0},match:a,matchAll:a,add:a,addAll:a,put:a,delete:a,keys:a});let b=[{key:`ignoreSearch`,converter:s.converters.boolean,defaultValue:()=>!1},{key:`ignoreMethod`,converter:s.converters.boolean,defaultValue:()=>!1},{key:`ignoreVary`,converter:s.converters.boolean,defaultValue:()=>!1}];s.converters.CacheQueryOptions=s.dictionaryConverter(b),s.converters.MultiCacheQueryOptions=s.dictionaryConverter([...b,{key:`cacheName`,converter:s.converters.DOMString}]),s.converters.Response=s.interfaceConverter(c),s.converters[`sequence`]=s.sequenceConverter(s.converters.RequestInfo),t.exports={Cache:y}})),Xt=I(((e,t)=>{let{kConstruct:n}=qt(),{Cache:r}=Yt(),{webidl:i}=Ge(),{kEnumerableProperty:a}=z();var o=class e{#e=new Map;constructor(){arguments[0]!==n&&i.illegalConstructor(),i.util.markAsUncloneable(this)}async match(t,a={}){if(i.brandCheck(this,e),i.argumentLengthCheck(arguments,1,`CacheStorage.match`),t=i.converters.RequestInfo(t),a=i.converters.MultiCacheQueryOptions(a),a.cacheName!=null){if(this.#e.has(a.cacheName))return await new r(n,this.#e.get(a.cacheName)).match(t,a)}else for(let e of this.#e.values()){let i=await new r(n,e).match(t,a);if(i!==void 0)return i}}async has(t){i.brandCheck(this,e);let n=`CacheStorage.has`;return i.argumentLengthCheck(arguments,1,n),t=i.converters.DOMString(t,n,`cacheName`),this.#e.has(t)}async open(t){i.brandCheck(this,e);let a=`CacheStorage.open`;if(i.argumentLengthCheck(arguments,1,a),t=i.converters.DOMString(t,a,`cacheName`),this.#e.has(t))return new r(n,this.#e.get(t));let o=[];return this.#e.set(t,o),new r(n,o)}async delete(t){i.brandCheck(this,e);let n=`CacheStorage.delete`;return i.argumentLengthCheck(arguments,1,n),t=i.converters.DOMString(t,n,`cacheName`),this.#e.delete(t)}async keys(){return i.brandCheck(this,e),[...this.#e.keys()]}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`CacheStorage`,configurable:!0},match:a,has:a,open:a,delete:a,keys:a}),t.exports={CacheStorage:o}})),Zt=I(((e,t)=>{t.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}})),Qt=I(((e,t)=>{function n(e){for(let t=0;t=0&&n<=8||n>=10&&n<=31||n===127)return!0}return!1}function r(e){for(let t=0;t126||n===34||n===40||n===41||n===60||n===62||n===64||n===44||n===59||n===58||n===92||n===47||n===91||n===93||n===63||n===61||n===123||n===125)throw Error(`Invalid cookie name`)}}function i(e){let t=e.length,n=0;if(e[0]===`"`){if(t===1||e[t-1]!==`"`)throw Error(`Invalid cookie value`);--t,++n}for(;n126||t===34||t===44||t===59||t===92)throw Error(`Invalid cookie value`)}}function a(e){for(let t=0;tt.toString().padStart(2,`0`));function u(e){return typeof e==`number`&&(e=new Date(e)),`${s[e.getUTCDay()]}, ${l[e.getUTCDate()]} ${c[e.getUTCMonth()]} ${e.getUTCFullYear()} ${l[e.getUTCHours()]}:${l[e.getUTCMinutes()]}:${l[e.getUTCSeconds()]} GMT`}function d(e){if(e<0)throw Error(`Invalid cookie max-age`)}function f(e){if(e.name.length===0)return null;r(e.name),i(e.value);let t=[`${e.name}=${e.value}`];e.name.startsWith(`__Secure-`)&&(e.secure=!0),e.name.startsWith(`__Host-`)&&(e.secure=!0,e.domain=null,e.path=`/`),e.secure&&t.push(`Secure`),e.httpOnly&&t.push(`HttpOnly`),typeof e.maxAge==`number`&&(d(e.maxAge),t.push(`Max-Age=${e.maxAge}`)),e.domain&&(o(e.domain),t.push(`Domain=${e.domain}`)),e.path&&(a(e.path),t.push(`Path=${e.path}`)),e.expires&&e.expires.toString()!==`Invalid Date`&&t.push(`Expires=${u(e.expires)}`),e.sameSite&&t.push(`SameSite=${e.sameSite}`);for(let n of e.unparsed){if(!n.includes(`=`))throw Error(`Invalid unparsed`);let[e,...r]=n.split(`=`);t.push(`${e.trim()}=${r.join(`=`)}`)}return t.join(`; `)}t.exports={isCTLExcludingHtab:n,validateCookieName:r,validateCookiePath:a,validateCookieValue:i,toIMFDate:u,stringify:f}})),$t=I(((e,t)=>{let{maxNameValuePairSize:n,maxAttributeValueSize:r}=Zt(),{isCTLExcludingHtab:i}=Qt(),{collectASequenceOfCodePointsFast:a}=We(),o=L(`node:assert`);function s(e){if(i(e))return null;let t=``,r=``,o=``,s=``;if(e.includes(`;`)){let n={position:0};t=a(`;`,e,n),r=e.slice(n.position)}else t=e;if(!t.includes(`=`))s=t;else{let e={position:0};o=a(`=`,t,e),s=t.slice(e.position+1)}return o=o.trim(),s=s.trim(),o.length+s.length>n?null:{name:o,value:s,...c(r)}}function c(e,t={}){if(e.length===0)return t;o(e[0]===`;`),e=e.slice(1);let n=``;e.includes(`;`)?(n=a(`;`,e,{position:0}),e=e.slice(n.length)):(n=e,e=``);let i=``,s=``;if(n.includes(`=`)){let e={position:0};i=a(`=`,n,e),s=n.slice(e.position+1)}else i=n;if(i=i.trim(),s=s.trim(),s.length>r)return c(e,t);let l=i.toLowerCase();if(l===`expires`)t.expires=new Date(s);else if(l===`max-age`){let n=s.charCodeAt(0);if((n<48||n>57)&&s[0]!==`-`||!/^\d+$/.test(s))return c(e,t);t.maxAge=Number(s)}else if(l===`domain`){let e=s;e[0]===`.`&&(e=e.slice(1)),e=e.toLowerCase(),t.domain=e}else if(l===`path`){let e=``;e=s.length===0||s[0]!==`/`?`/`:s,t.path=e}else if(l===`secure`)t.secure=!0;else if(l===`httponly`)t.httpOnly=!0;else if(l===`samesite`){let e=`Default`,n=s.toLowerCase();n.includes(`none`)&&(e=`None`),n.includes(`strict`)&&(e=`Strict`),n.includes(`lax`)&&(e=`Lax`),t.sameSite=e}else t.unparsed??=[],t.unparsed.push(`${i}=${s}`);return c(e,t)}t.exports={parseSetCookie:s,parseUnparsedAttributes:c}})),en=I(((e,t)=>{let{parseSetCookie:n}=$t(),{stringify:r}=Qt(),{webidl:i}=Ge(),{Headers:a}=Lt();function o(e){i.argumentLengthCheck(arguments,1,`getCookies`),i.brandCheck(e,a,{strict:!1});let t=e.get(`cookie`),n={};if(!t)return n;for(let e of t.split(`;`)){let[t,...r]=e.split(`=`);n[t.trim()]=r.join(`=`)}return n}function s(e,t,n){i.brandCheck(e,a,{strict:!1});let r=`deleteCookie`;i.argumentLengthCheck(arguments,2,r),t=i.converters.DOMString(t,r,`name`),n=i.converters.DeleteCookieAttributes(n),l(e,{name:t,value:``,expires:new Date(0),...n})}function c(e){i.argumentLengthCheck(arguments,1,`getSetCookies`),i.brandCheck(e,a,{strict:!1});let t=e.getSetCookie();return t?t.map(e=>n(e)):[]}function l(e,t){i.argumentLengthCheck(arguments,2,`setCookie`),i.brandCheck(e,a,{strict:!1}),t=i.converters.Cookie(t);let n=r(t);n&&e.append(`Set-Cookie`,n)}i.converters.DeleteCookieAttributes=i.dictionaryConverter([{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null}]),i.converters.Cookie=i.dictionaryConverter([{converter:i.converters.DOMString,key:`name`},{converter:i.converters.DOMString,key:`value`},{converter:i.nullableConverter(e=>typeof e==`number`?i.converters[`unsigned long long`](e):new Date(e)),key:`expires`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters[`long long`]),key:`maxAge`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`secure`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`httpOnly`,defaultValue:()=>null},{converter:i.converters.USVString,key:`sameSite`,allowedValues:[`Strict`,`Lax`,`None`]},{converter:i.sequenceConverter(i.converters.DOMString),key:`unparsed`,defaultValue:()=>[]}]),t.exports={getCookies:o,deleteCookie:s,getSetCookies:c,setCookie:l}})),tn=I(((e,t)=>{let{webidl:n}=Ge(),{kEnumerableProperty:r}=z(),{kConstruct:i}=ke(),{MessagePort:a}=L(`node:worker_threads`);var o=class e extends Event{#e;constructor(e,t={}){if(e===i){super(arguments[1],arguments[2]),n.util.markAsUncloneable(this);return}let r=`MessageEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.MessageEventInit(t,r,`eventInitDict`),super(e,t),this.#e=t,n.util.markAsUncloneable(this)}get data(){return n.brandCheck(this,e),this.#e.data}get origin(){return n.brandCheck(this,e),this.#e.origin}get lastEventId(){return n.brandCheck(this,e),this.#e.lastEventId}get source(){return n.brandCheck(this,e),this.#e.source}get ports(){return n.brandCheck(this,e),Object.isFrozen(this.#e.ports)||Object.freeze(this.#e.ports),this.#e.ports}initMessageEvent(t,r=!1,i=!1,a=null,o=``,s=``,c=null,l=[]){return n.brandCheck(this,e),n.argumentLengthCheck(arguments,1,`MessageEvent.initMessageEvent`),new e(t,{bubbles:r,cancelable:i,data:a,origin:o,lastEventId:s,source:c,ports:l})}static createFastMessageEvent(t,n){let r=new e(i,t,n);return r.#e=n,r.#e.data??=null,r.#e.origin??=``,r.#e.lastEventId??=``,r.#e.source??=null,r.#e.ports??=[],r}};let{createFastMessageEvent:s}=o;delete o.createFastMessageEvent;var c=class e extends Event{#e;constructor(e,t={}){let r=`CloseEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.CloseEventInit(t),super(e,t),this.#e=t,n.util.markAsUncloneable(this)}get wasClean(){return n.brandCheck(this,e),this.#e.wasClean}get code(){return n.brandCheck(this,e),this.#e.code}get reason(){return n.brandCheck(this,e),this.#e.reason}},l=class e extends Event{#e;constructor(e,t){let r=`ErrorEvent constructor`;n.argumentLengthCheck(arguments,1,r),super(e,t),n.util.markAsUncloneable(this),e=n.converters.DOMString(e,r,`type`),t=n.converters.ErrorEventInit(t??{}),this.#e=t}get message(){return n.brandCheck(this,e),this.#e.message}get filename(){return n.brandCheck(this,e),this.#e.filename}get lineno(){return n.brandCheck(this,e),this.#e.lineno}get colno(){return n.brandCheck(this,e),this.#e.colno}get error(){return n.brandCheck(this,e),this.#e.error}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`MessageEvent`,configurable:!0},data:r,origin:r,lastEventId:r,source:r,ports:r,initMessageEvent:r}),Object.defineProperties(c.prototype,{[Symbol.toStringTag]:{value:`CloseEvent`,configurable:!0},reason:r,code:r,wasClean:r}),Object.defineProperties(l.prototype,{[Symbol.toStringTag]:{value:`ErrorEvent`,configurable:!0},message:r,filename:r,lineno:r,colno:r,error:r}),n.converters.MessagePort=n.interfaceConverter(a),n.converters[`sequence`]=n.sequenceConverter(n.converters.MessagePort);let u=[{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}];n.converters.MessageEventInit=n.dictionaryConverter([...u,{key:`data`,converter:n.converters.any,defaultValue:()=>null},{key:`origin`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lastEventId`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`source`,converter:n.nullableConverter(n.converters.MessagePort),defaultValue:()=>null},{key:`ports`,converter:n.converters[`sequence`],defaultValue:()=>[]}]),n.converters.CloseEventInit=n.dictionaryConverter([...u,{key:`wasClean`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`code`,converter:n.converters[`unsigned short`],defaultValue:()=>0},{key:`reason`,converter:n.converters.USVString,defaultValue:()=>``}]),n.converters.ErrorEventInit=n.dictionaryConverter([...u,{key:`message`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`filename`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lineno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`colno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`error`,converter:n.converters.any}]),t.exports={MessageEvent:o,CloseEvent:c,ErrorEvent:l,createFastMessageEvent:s}})),nn=I(((e,t)=>{t.exports={uid:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,sentCloseFrameState:{NOT_SENT:0,PROCESSING:1,SENT:2},staticPropertyDescriptors:{enumerable:!0,writable:!1,configurable:!1},states:{CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},opcodes:{CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},maxUnsigned16Bit:2**16-1,parserStates:{INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},emptyBuffer:Buffer.allocUnsafe(0),sendHints:{string:1,typedArray:2,arrayBuffer:3,blob:4}}})),rn=I(((e,t)=>{t.exports={kWebSocketURL:Symbol(`url`),kReadyState:Symbol(`ready state`),kController:Symbol(`controller`),kResponse:Symbol(`response`),kBinaryType:Symbol(`binary type`),kSentClose:Symbol(`sent close`),kReceivedClose:Symbol(`received close`),kByteParser:Symbol(`byte parser`)}})),an=I(((e,t)=>{let{kReadyState:n,kController:r,kResponse:i,kBinaryType:a,kWebSocketURL:o}=rn(),{states:s,opcodes:c}=nn(),{ErrorEvent:l,createFastMessageEvent:u}=tn(),{isUtf8:d}=L(`node:buffer`),{collectASequenceOfCodePointsFast:f,removeHTTPWhitespace:p}=We();function m(e){return e[n]===s.CONNECTING}function h(e){return e[n]===s.OPEN}function g(e){return e[n]===s.CLOSING}function _(e){return e[n]===s.CLOSED}function v(e,t,n=(e,t)=>new Event(e,t),r={}){let i=n(e,r);t.dispatchEvent(i)}function y(e,t,r){if(e[n]!==s.OPEN)return;let i;if(t===c.TEXT)try{i=M(r)}catch{C(e,`Received invalid UTF-8 in text frame.`);return}else t===c.BINARY&&(i=e[a]===`blob`?new Blob([r]):b(r));v(`message`,e,u,{origin:e[o].origin,data:i})}function b(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function x(e){if(e.length===0)return!1;for(let t=0;t126||n===34||n===40||n===41||n===44||n===47||n===58||n===59||n===60||n===61||n===62||n===63||n===64||n===91||n===92||n===93||n===123||n===125)return!1}return!0}function S(e){return e>=1e3&&e<1015?e!==1004&&e!==1005&&e!==1006:e>=3e3&&e<=4999}function C(e,t){let{[r]:n,[i]:a}=e;n.abort(),a?.socket&&!a.socket.destroyed&&a.socket.destroy(),t&&v(`error`,e,(e,t)=>new l(e,t),{error:Error(t),message:t})}function w(e){return e===c.CLOSE||e===c.PING||e===c.PONG}function T(e){return e===c.CONTINUATION}function E(e){return e===c.TEXT||e===c.BINARY}function D(e){return E(e)||T(e)||w(e)}function O(e){let t={position:0},n=new Map;for(;t.position57)return!1}let t=Number.parseInt(e,10);return t>=8&&t<=15}let A=typeof process.versions.icu==`string`,j=A?new TextDecoder(`utf-8`,{fatal:!0}):void 0,M=A?j.decode.bind(j):function(e){if(d(e))return e.toString(`utf-8`);throw TypeError(`Invalid utf-8 received.`)};t.exports={isConnecting:m,isEstablished:h,isClosing:g,isClosed:_,fireEvent:v,isValidSubprotocol:x,isValidStatusCode:S,failWebsocketConnection:C,websocketMessageReceived:y,utf8Decode:M,isControlFrame:w,isContinuationFrame:T,isTextBinaryFrame:E,isValidOpcode:D,parseExtensions:O,isValidClientWindowBits:k}})),on=I(((e,t)=>{let{maxUnsigned16Bit:n}=nn(),r=16386,i,a=null,o=r;try{i=L(`node:crypto`)}catch{i={randomFillSync:function(e,t,n){for(let t=0;tn?(o+=8,a=127):i>125&&(o+=2,a=126);let c=Buffer.allocUnsafe(i+o);c[0]=c[1]=0,c[0]|=128,c[0]=(c[0]&240)+e,c[o-4]=r[0],c[o-3]=r[1],c[o-2]=r[2],c[o-1]=r[3],c[1]=a,a===126?c.writeUInt16BE(i,2):a===127&&(c[2]=c[3]=0,c.writeUIntBE(i,4,6)),c[1]|=128;for(let e=0;e{let{uid:n,states:r,sentCloseFrameState:i,emptyBuffer:a,opcodes:o}=nn(),{kReadyState:s,kSentClose:c,kByteParser:l,kReceivedClose:u,kResponse:d}=rn(),{fireEvent:f,failWebsocketConnection:p,isClosing:m,isClosed:h,isEstablished:g,parseExtensions:_}=an(),{channels:v}=Me(),{CloseEvent:y}=tn(),{makeRequest:b}=Bt(),{fetching:x}=Vt(),{Headers:S,getHeadersList:C}=Lt(),{getDecodeSplit:w}=Ke(),{WebsocketFrameSend:T}=on(),E;try{E=L(`node:crypto`)}catch{}function D(e,t,r,i,a,o){let s=e;s.protocol=e.protocol===`ws:`?`http:`:`https:`;let c=b({urlList:[s],client:r,serviceWorkers:`none`,referrer:`no-referrer`,mode:`websocket`,credentials:`include`,cache:`no-store`,redirect:`error`});o.headers&&(c.headersList=C(new S(o.headers)));let l=E.randomBytes(16).toString(`base64`);c.headersList.append(`sec-websocket-key`,l),c.headersList.append(`sec-websocket-version`,`13`);for(let e of t)c.headersList.append(`sec-websocket-protocol`,e);return c.headersList.append(`sec-websocket-extensions`,`permessage-deflate; client_max_window_bits`),x({request:c,useParallelQueue:!0,dispatcher:o.dispatcher,processResponse(e){if(e.type===`error`||e.status!==101){p(i,`Received network error or non-101 status code.`);return}if(t.length!==0&&!e.headersList.get(`Sec-WebSocket-Protocol`)){p(i,`Server did not respond with sent protocols.`);return}if(e.headersList.get(`Upgrade`)?.toLowerCase()!==`websocket`){p(i,`Server did not set Upgrade header to "websocket".`);return}if(e.headersList.get(`Connection`)?.toLowerCase()!==`upgrade`){p(i,`Server did not set Connection header to "upgrade".`);return}if(e.headersList.get(`Sec-WebSocket-Accept`)!==E.createHash(`sha1`).update(l+n).digest(`base64`)){p(i,`Incorrect hash received in Sec-WebSocket-Accept header.`);return}let r=e.headersList.get(`Sec-WebSocket-Extensions`),o;if(r!==null&&(o=_(r),!o.has(`permessage-deflate`))){p(i,`Sec-WebSocket-Extensions header does not match.`);return}let s=e.headersList.get(`Sec-WebSocket-Protocol`);if(s!==null&&!w(`sec-websocket-protocol`,c.headersList).includes(s)){p(i,`Protocol was not set in the opening handshake.`);return}e.socket.on(`data`,k),e.socket.on(`close`,A),e.socket.on(`error`,j),v.open.hasSubscribers&&v.open.publish({address:e.socket.address(),protocol:s,extensions:r}),a(e,o)}})}function O(e,t,n,l){if(!(m(e)||h(e)))if(!g(e))p(e,`Connection was closed before it was established.`),e[s]=r.CLOSING;else if(e[c]===i.NOT_SENT){e[c]=i.PROCESSING;let u=new T;t!==void 0&&n===void 0?(u.frameData=Buffer.allocUnsafe(2),u.frameData.writeUInt16BE(t,0)):t!==void 0&&n!==void 0?(u.frameData=Buffer.allocUnsafe(2+l),u.frameData.writeUInt16BE(t,0),u.frameData.write(n,2,`utf-8`)):u.frameData=a,e[d].socket.write(u.createFrame(o.CLOSE)),e[c]=i.SENT,e[s]=r.CLOSING}else e[s]=r.CLOSING}function k(e){this.ws[l].write(e)||this.pause()}function A(){let{ws:e}=this,{[d]:t}=e;t.socket.off(`data`,k),t.socket.off(`close`,A),t.socket.off(`error`,j);let n=e[c]===i.SENT&&e[u],a=1005,o=``,p=e[l].closingInfo;p&&!p.error?(a=p.code??1005,o=p.reason):e[u]||(a=1006),e[s]=r.CLOSED,f(`close`,e,(e,t)=>new y(e,t),{wasClean:n,code:a,reason:o}),v.close.hasSubscribers&&v.close.publish({websocket:e,code:a,reason:o})}function j(e){let{ws:t}=this;t[s]=r.CLOSING,v.socketError.hasSubscribers&&v.socketError.publish(e),this.destroy()}t.exports={establishWebSocketConnection:D,closeWebSocketConnection:O}})),cn=I(((e,t)=>{let{createInflateRaw:n,Z_DEFAULT_WINDOWBITS:r}=L(`node:zlib`),{isValidClientWindowBits:i}=an(),{MessageSizeExceededError:a}=R(),o=Buffer.from([0,0,255,255]),s=Symbol(`kBuffer`),c=Symbol(`kLength`);t.exports={PerMessageDeflate:class{#e;#t={};#n=!1;#r=null;constructor(e){this.#t.serverNoContextTakeover=e.has(`server_no_context_takeover`),this.#t.serverMaxWindowBits=e.get(`server_max_window_bits`)}decompress(e,t,l){if(this.#n){l(new a);return}if(!this.#e){let e=r;if(this.#t.serverMaxWindowBits){if(!i(this.#t.serverMaxWindowBits)){l(Error(`Invalid server_max_window_bits`));return}e=Number.parseInt(this.#t.serverMaxWindowBits)}try{this.#e=n({windowBits:e})}catch(e){l(e);return}this.#e[s]=[],this.#e[c]=0,this.#e.on(`data`,e=>{if(!this.#n){if(this.#e[c]+=e.length,this.#e[c]>4194304){if(this.#n=!0,this.#e.removeAllListeners(),this.#e.destroy(),this.#e=null,this.#r){let e=this.#r;this.#r=null,e(new a)}return}this.#e[s].push(e)}}),this.#e.on(`error`,e=>{this.#e=null,l(e)})}this.#r=l,this.#e.write(e),t&&this.#e.write(o),this.#e.flush(()=>{if(this.#n||!this.#e)return;let e=Buffer.concat(this.#e[s],this.#e[c]);this.#e[s].length=0,this.#e[c]=0,this.#r=null,l(null,e)})}}}})),ln=I(((e,t)=>{let{Writable:n}=L(`node:stream`),r=L(`node:assert`),{parserStates:i,opcodes:a,states:o,emptyBuffer:s,sentCloseFrameState:c}=nn(),{kReadyState:l,kSentClose:u,kResponse:d,kReceivedClose:f}=rn(),{channels:p}=Me(),{isValidStatusCode:m,isValidOpcode:h,failWebsocketConnection:g,websocketMessageReceived:_,utf8Decode:v,isControlFrame:y,isTextBinaryFrame:b,isContinuationFrame:x}=an(),{WebsocketFrameSend:S}=on(),{closeWebSocketConnection:C}=sn(),{PerMessageDeflate:w}=cn();t.exports={ByteParser:class extends n{#e=[];#t=0;#n=!1;#r=i.INFO;#i={};#a=[];#o;constructor(e,t){super(),this.ws=e,this.#o=t??new Map,this.#o.has(`permessage-deflate`)&&this.#o.set(`permessage-deflate`,new w(t))}_write(e,t,n){this.#e.push(e),this.#t+=e.length,this.#n=!0,this.run(n)}run(e){for(;this.#n;)if(this.#r===i.INFO){if(this.#t<2)return e();let t=this.consume(2),n=(t[0]&128)!=0,r=t[0]&15,o=(t[1]&128)==128,s=!n&&r!==a.CONTINUATION,c=t[1]&127,l=t[0]&64,u=t[0]&32,d=t[0]&16;if(!h(r))return g(this.ws,`Invalid opcode received`),e();if(o)return g(this.ws,`Frame cannot be masked`),e();if(l!==0&&!this.#o.has(`permessage-deflate`)){g(this.ws,`Expected RSV1 to be clear.`);return}if(u!==0||d!==0){g(this.ws,`RSV1, RSV2, RSV3 must be clear`);return}if(s&&!b(r)){g(this.ws,`Invalid frame type was fragmented.`);return}if(b(r)&&this.#a.length>0){g(this.ws,`Expected continuation frame`);return}if(this.#i.fragmented&&s){g(this.ws,`Fragmented frame exceeded 125 bytes.`);return}if((c>125||s)&&y(r)){g(this.ws,`Control frame either too large or fragmented`);return}if(x(r)&&this.#a.length===0&&!this.#i.compressed){g(this.ws,`Unexpected continuation frame`);return}c<=125?(this.#i.payloadLength=c,this.#r=i.READ_DATA):c===126?this.#r=i.PAYLOADLENGTH_16:c===127&&(this.#r=i.PAYLOADLENGTH_64),b(r)&&(this.#i.binaryType=r,this.#i.compressed=l!==0),this.#i.opcode=r,this.#i.masked=o,this.#i.fin=n,this.#i.fragmented=s}else if(this.#r===i.PAYLOADLENGTH_16){if(this.#t<2)return e();let t=this.consume(2);this.#i.payloadLength=t.readUInt16BE(0),this.#r=i.READ_DATA}else if(this.#r===i.PAYLOADLENGTH_64){if(this.#t<8)return e();let t=this.consume(8),n=t.readUInt32BE(0),r=t.readUInt32BE(4);if(n!==0||r>2**31-1){g(this.ws,`Received payload length > 2^31 bytes.`);return}this.#i.payloadLength=r,this.#r=i.READ_DATA}else if(this.#r===i.READ_DATA){if(this.#t{if(t){g(this.ws,t.message);return}if(this.#a.push(n),!this.#i.fin){this.#r=i.INFO,this.#n=!0,this.run(e);return}_(this.ws,this.#i.binaryType,Buffer.concat(this.#a)),this.#n=!0,this.#r=i.INFO,this.#a.length=0,this.run(e)}),this.#n=!1;break}else{if(this.#a.push(t),!this.#i.fragmented&&this.#i.fin){let e=Buffer.concat(this.#a);_(this.ws,this.#i.binaryType,e),this.#a.length=0}this.#r=i.INFO}}}consume(e){if(e>this.#t)throw Error(`Called consume() before buffers satiated.`);if(e===0)return s;if(this.#e[0].length===e)return this.#t-=this.#e[0].length,this.#e.shift();let t=Buffer.allocUnsafe(e),n=0;for(;n!==e;){let r=this.#e[0],{length:i}=r;if(i+n===e){t.set(this.#e.shift(),n);break}else if(i+n>e){t.set(r.subarray(0,e-n),n),this.#e[0]=r.subarray(e-n);break}else t.set(this.#e.shift(),n),n+=r.length}return this.#t-=e,t}parseCloseBody(e){r(e.length!==1);let t;if(e.length>=2&&(t=e.readUInt16BE(0)),t!==void 0&&!m(t))return{code:1002,reason:`Invalid status code`,error:!0};let n=e.subarray(2);n[0]===239&&n[1]===187&&n[2]===191&&(n=n.subarray(3));try{n=v(n)}catch{return{code:1007,reason:`Invalid UTF-8`,error:!0}}return{code:t,reason:n,error:!1}}parseControlFrame(e){let{opcode:t,payloadLength:n}=this.#i;if(t===a.CLOSE){if(n===1)return g(this.ws,`Received close frame with a 1-byte body.`),!1;if(this.#i.closeInfo=this.parseCloseBody(e),this.#i.closeInfo.error){let{code:e,reason:t}=this.#i.closeInfo;return C(this.ws,e,t,t.length),g(this.ws,t),!1}if(this.ws[u]!==c.SENT){let e=s;this.#i.closeInfo.code&&(e=Buffer.allocUnsafe(2),e.writeUInt16BE(this.#i.closeInfo.code,0));let t=new S(e);this.ws[d].socket.write(t.createFrame(a.CLOSE),e=>{e||(this.ws[u]=c.SENT)})}return this.ws[l]=o.CLOSING,this.ws[f]=!0,!1}else if(t===a.PING){if(!this.ws[f]){let t=new S(e);this.ws[d].socket.write(t.createFrame(a.PONG)),p.ping.hasSubscribers&&p.ping.publish({payload:e})}}else t===a.PONG&&p.pong.hasSubscribers&&p.pong.publish({payload:e});return!0}get closingInfo(){return this.#i.closeInfo}}}})),un=I(((e,t)=>{let{WebsocketFrameSend:n}=on(),{opcodes:r,sendHints:i}=nn(),a=rt(),o=Buffer[Symbol.species];var s=class{#e=new a;#t=!1;#n;constructor(e){this.#n=e}add(e,t,n){if(n!==i.blob){let r=c(e,n);if(!this.#t)this.#n.write(r,t);else{let e={promise:null,callback:t,frame:r};this.#e.push(e)}return}let r={promise:e.arrayBuffer().then(e=>{r.promise=null,r.frame=c(e,n)}),callback:t,frame:null};this.#e.push(r),this.#t||this.#r()}async#r(){this.#t=!0;let e=this.#e;for(;!e.isEmpty();){let t=e.shift();t.promise!==null&&await t.promise,this.#n.write(t.frame,t.callback),t.callback=t.frame=null}this.#t=!1}};function c(e,t){return new n(l(e,t)).createFrame(t===i.string?r.TEXT:r.BINARY)}function l(e,t){switch(t){case i.string:return Buffer.from(e);case i.arrayBuffer:case i.blob:return new o(e);case i.typedArray:return new o(e.buffer,e.byteOffset,e.byteLength)}}t.exports={SendQueue:s}})),dn=I(((e,t)=>{let{webidl:n}=Ge(),{URLSerializer:r}=We(),{environmentSettingsObject:i}=Ke(),{staticPropertyDescriptors:a,states:o,sentCloseFrameState:s,sendHints:c}=nn(),{kWebSocketURL:l,kReadyState:u,kController:d,kBinaryType:f,kResponse:p,kSentClose:m,kByteParser:h}=rn(),{isConnecting:g,isEstablished:_,isClosing:v,isValidSubprotocol:y,fireEvent:b}=an(),{establishWebSocketConnection:x,closeWebSocketConnection:S}=sn(),{ByteParser:C}=ln(),{kEnumerableProperty:w,isBlobLike:T}=z(),{getGlobalDispatcher:E}=jt(),{types:D}=L(`node:util`),{ErrorEvent:O,CloseEvent:k}=tn(),{SendQueue:A}=un();var j=class e extends EventTarget{#e={open:null,error:null,close:null,message:null};#t=0;#n=``;#r=``;#i;constructor(t,r=[]){super(),n.util.markAsUncloneable(this);let a=`WebSocket constructor`;n.argumentLengthCheck(arguments,1,a);let o=n.converters[`DOMString or sequence or WebSocketInit`](r,a,`options`);t=n.converters.USVString(t,a,`url`),r=o.protocols;let c=i.settingsObject.baseUrl,p;try{p=new URL(t,c)}catch(e){throw new DOMException(e,`SyntaxError`)}if(p.protocol===`http:`?p.protocol=`ws:`:p.protocol===`https:`&&(p.protocol=`wss:`),p.protocol!==`ws:`&&p.protocol!==`wss:`)throw new DOMException(`Expected a ws: or wss: protocol, got ${p.protocol}`,`SyntaxError`);if(p.hash||p.href.endsWith(`#`))throw new DOMException(`Got fragment`,`SyntaxError`);if(typeof r==`string`&&(r=[r]),r.length!==new Set(r.map(e=>e.toLowerCase())).size||r.length>0&&!r.every(e=>y(e)))throw new DOMException(`Invalid Sec-WebSocket-Protocol value`,`SyntaxError`);this[l]=new URL(p.href);let h=i.settingsObject;this[d]=x(p,r,h,this,(e,t)=>this.#a(e,t),o),this[u]=e.CONNECTING,this[m]=s.NOT_SENT,this[f]=`blob`}close(t=void 0,r=void 0){n.brandCheck(this,e);let i=`WebSocket.close`;if(t!==void 0&&(t=n.converters[`unsigned short`](t,i,`code`,{clamp:!0})),r!==void 0&&(r=n.converters.USVString(r,i,`reason`)),t!==void 0&&t!==1e3&&(t<3e3||t>4999))throw new DOMException(`invalid code`,`InvalidAccessError`);let a=0;if(r!==void 0&&(a=Buffer.byteLength(r),a>123))throw new DOMException(`Reason must be less than 123 bytes; received ${a}`,`SyntaxError`);S(this,t,r,a)}send(t){n.brandCheck(this,e);let r=`WebSocket.send`;if(n.argumentLengthCheck(arguments,1,r),t=n.converters.WebSocketSendData(t,r,`data`),g(this))throw new DOMException(`Sent before connected.`,`InvalidStateError`);if(!(!_(this)||v(this)))if(typeof t==`string`){let e=Buffer.byteLength(t);this.#t+=e,this.#i.add(t,()=>{this.#t-=e},c.string)}else D.isArrayBuffer(t)?(this.#t+=t.byteLength,this.#i.add(t,()=>{this.#t-=t.byteLength},c.arrayBuffer)):ArrayBuffer.isView(t)?(this.#t+=t.byteLength,this.#i.add(t,()=>{this.#t-=t.byteLength},c.typedArray)):T(t)&&(this.#t+=t.size,this.#i.add(t,()=>{this.#t-=t.size},c.blob))}get readyState(){return n.brandCheck(this,e),this[u]}get bufferedAmount(){return n.brandCheck(this,e),this.#t}get url(){return n.brandCheck(this,e),r(this[l])}get extensions(){return n.brandCheck(this,e),this.#r}get protocol(){return n.brandCheck(this,e),this.#n}get onopen(){return n.brandCheck(this,e),this.#e.open}set onopen(t){n.brandCheck(this,e),this.#e.open&&this.removeEventListener(`open`,this.#e.open),typeof t==`function`?(this.#e.open=t,this.addEventListener(`open`,t)):this.#e.open=null}get onerror(){return n.brandCheck(this,e),this.#e.error}set onerror(t){n.brandCheck(this,e),this.#e.error&&this.removeEventListener(`error`,this.#e.error),typeof t==`function`?(this.#e.error=t,this.addEventListener(`error`,t)):this.#e.error=null}get onclose(){return n.brandCheck(this,e),this.#e.close}set onclose(t){n.brandCheck(this,e),this.#e.close&&this.removeEventListener(`close`,this.#e.close),typeof t==`function`?(this.#e.close=t,this.addEventListener(`close`,t)):this.#e.close=null}get onmessage(){return n.brandCheck(this,e),this.#e.message}set onmessage(t){n.brandCheck(this,e),this.#e.message&&this.removeEventListener(`message`,this.#e.message),typeof t==`function`?(this.#e.message=t,this.addEventListener(`message`,t)):this.#e.message=null}get binaryType(){return n.brandCheck(this,e),this[f]}set binaryType(t){n.brandCheck(this,e),t!==`blob`&&t!==`arraybuffer`?this[f]=`blob`:this[f]=t}#a(e,t){this[p]=e;let n=new C(this,t);n.on(`drain`,M),n.on(`error`,N.bind(this)),e.socket.ws=this,this[h]=n,this.#i=new A(e.socket),this[u]=o.OPEN;let r=e.headersList.get(`sec-websocket-extensions`);r!==null&&(this.#r=r);let i=e.headersList.get(`sec-websocket-protocol`);i!==null&&(this.#n=i),b(`open`,this)}};j.CONNECTING=j.prototype.CONNECTING=o.CONNECTING,j.OPEN=j.prototype.OPEN=o.OPEN,j.CLOSING=j.prototype.CLOSING=o.CLOSING,j.CLOSED=j.prototype.CLOSED=o.CLOSED,Object.defineProperties(j.prototype,{CONNECTING:a,OPEN:a,CLOSING:a,CLOSED:a,url:w,readyState:w,bufferedAmount:w,onopen:w,onerror:w,onclose:w,close:w,onmessage:w,binaryType:w,send:w,extensions:w,protocol:w,[Symbol.toStringTag]:{value:`WebSocket`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(j,{CONNECTING:a,OPEN:a,CLOSING:a,CLOSED:a}),n.converters[`sequence`]=n.sequenceConverter(n.converters.DOMString),n.converters[`DOMString or sequence`]=function(e,t,r){return n.util.Type(e)===`Object`&&Symbol.iterator in e?n.converters[`sequence`](e):n.converters.DOMString(e,t,r)},n.converters.WebSocketInit=n.dictionaryConverter([{key:`protocols`,converter:n.converters[`DOMString or sequence`],defaultValue:()=>[]},{key:`dispatcher`,converter:n.converters.any,defaultValue:()=>E()},{key:`headers`,converter:n.nullableConverter(n.converters.HeadersInit)}]),n.converters[`DOMString or sequence or WebSocketInit`]=function(e){return n.util.Type(e)===`Object`&&!(Symbol.iterator in e)?n.converters.WebSocketInit(e):{protocols:n.converters[`DOMString or sequence`](e)}},n.converters.WebSocketSendData=function(e){if(n.util.Type(e)===`Object`){if(T(e))return n.converters.Blob(e,{strict:!1});if(ArrayBuffer.isView(e)||D.isArrayBuffer(e))return n.converters.BufferSource(e)}return n.converters.USVString(e)};function M(){this.ws[p].socket.resume()}function N(e){let t,n;e instanceof k?(t=e.reason,n=e.code):t=e.message,b(`error`,this,()=>new O(`error`,{error:e,message:t})),S(this,n)}t.exports={WebSocket:j}})),fn=I(((e,t)=>{function n(e){return e.indexOf(`\0`)===-1}function r(e){if(e.length===0)return!1;for(let t=0;t57)return!1;return!0}function i(e){return new Promise(t=>{setTimeout(t,e).unref()})}t.exports={isValidLastEventId:n,isASCIINumber:r,delay:i}})),pn=I(((e,t)=>{let{Transform:n}=L(`node:stream`),{isASCIINumber:r,isValidLastEventId:i}=fn(),a=[239,187,191];t.exports={EventSourceStream:class extends n{state=null;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(e={}){e.readableObjectMode=!0,super(e),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,t,n){if(e.length===0){n();return}if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:if(this.buffer[0]===a[0]){n();return}this.checkBOM=!1,n();return;case 2:if(this.buffer[0]===a[0]&&this.buffer[1]===a[1]){n();return}this.checkBOM=!1;break;case 3:if(this.buffer[0]===a[0]&&this.buffer[1]===a[1]&&this.buffer[2]===a[2]){this.buffer=Buffer.alloc(0),this.checkBOM=!1,n();return}this.checkBOM=!1;break;default:this.buffer[0]===a[0]&&this.buffer[1]===a[1]&&this.buffer[2]===a[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1;break}for(;this.pos0&&(t[a]=o);break}}processEvent(e){e.retry&&r(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),e.id&&i(e.id)&&(this.state.lastEventId=e.id),e.data!==void 0&&this.push({type:e.event||`message`,options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}}}})),mn=I(((e,t)=>{let{pipeline:n}=L(`node:stream`),{fetching:r}=Vt(),{makeRequest:i}=Bt(),{webidl:a}=Ge(),{EventSourceStream:o}=pn(),{parseMIMEType:s}=We(),{createFastMessageEvent:c}=tn(),{isNetworkError:l}=Rt(),{delay:u}=fn(),{kEnumerableProperty:d}=z(),{environmentSettingsObject:f}=Ke(),p=!1,m=3e3;var h=class e extends EventTarget{#e={open:null,error:null,message:null};#t=null;#n=!1;#r=0;#i=null;#a=null;#o;#s;constructor(e,t={}){super(),a.util.markAsUncloneable(this);let n=`EventSource constructor`;a.argumentLengthCheck(arguments,1,n),p||(p=!0,process.emitWarning(`EventSource is experimental, expect them to change at any time.`,{code:`UNDICI-ES`})),e=a.converters.USVString(e,n,`url`),t=a.converters.EventSourceInitDict(t,n,`eventSourceInitDict`),this.#o=t.dispatcher,this.#s={lastEventId:``,reconnectionTime:m};let r=f,o;try{o=new URL(e,r.settingsObject.baseUrl),this.#s.origin=o.origin}catch(e){throw new DOMException(e,`SyntaxError`)}this.#t=o.href;let s=`anonymous`;t.withCredentials&&(s=`use-credentials`,this.#n=!0);let c={redirect:`follow`,keepalive:!0,mode:`cors`,credentials:s===`anonymous`?`same-origin`:`omit`,referrer:`no-referrer`};c.client=f.settingsObject,c.headersList=[[`accept`,{name:`accept`,value:`text/event-stream`}]],c.cache=`no-store`,c.initiator=`other`,c.urlList=[new URL(this.#t)],this.#i=i(c),this.#c()}get readyState(){return this.#r}get url(){return this.#t}get withCredentials(){return this.#n}#c(){if(this.#r===2)return;this.#r=0;let e={request:this.#i,dispatcher:this.#o};e.processResponseEndOfBody=e=>{l(e)&&(this.dispatchEvent(new Event(`error`)),this.close()),this.#l()},e.processResponse=e=>{if(l(e))if(e.aborted){this.close(),this.dispatchEvent(new Event(`error`));return}else{this.#l();return}let t=e.headersList.get(`content-type`,!0),r=t===null?`failure`:s(t),i=r!==`failure`&&r.essence===`text/event-stream`;if(e.status!==200||i===!1){this.close(),this.dispatchEvent(new Event(`error`));return}this.#r=1,this.dispatchEvent(new Event(`open`)),this.#s.origin=e.urlList[e.urlList.length-1].origin;let a=new o({eventSourceSettings:this.#s,push:e=>{this.dispatchEvent(c(e.type,e.options))}});n(e.body.stream,a,e=>{e?.aborted===!1&&(this.close(),this.dispatchEvent(new Event(`error`)))})},this.#a=r(e)}async#l(){this.#r!==2&&(this.#r=0,this.dispatchEvent(new Event(`error`)),await u(this.#s.reconnectionTime),this.#r===0&&(this.#s.lastEventId.length&&this.#i.headersList.set(`last-event-id`,this.#s.lastEventId,!0),this.#c()))}close(){a.brandCheck(this,e),this.#r!==2&&(this.#r=2,this.#a.abort(),this.#i=null)}get onopen(){return this.#e.open}set onopen(e){this.#e.open&&this.removeEventListener(`open`,this.#e.open),typeof e==`function`?(this.#e.open=e,this.addEventListener(`open`,e)):this.#e.open=null}get onmessage(){return this.#e.message}set onmessage(e){this.#e.message&&this.removeEventListener(`message`,this.#e.message),typeof e==`function`?(this.#e.message=e,this.addEventListener(`message`,e)):this.#e.message=null}get onerror(){return this.#e.error}set onerror(e){this.#e.error&&this.removeEventListener(`error`,this.#e.error),typeof e==`function`?(this.#e.error=e,this.addEventListener(`error`,e)):this.#e.error=null}};let g={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:0,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:1,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:2,writable:!1}};Object.defineProperties(h,g),Object.defineProperties(h.prototype,g),Object.defineProperties(h.prototype,{close:d,onerror:d,onmessage:d,onopen:d,readyState:d,url:d,withCredentials:d}),a.converters.EventSourceInitDict=a.dictionaryConverter([{key:`withCredentials`,converter:a.converters.boolean,defaultValue:()=>!1},{key:`dispatcher`,converter:a.converters.any}]),t.exports={EventSource:h,defaultReconnectionTime:m}})),hn=I(((e,t)=>{let n=nt(),r=Pe(),i=ot(),a=st(),o=ct(),s=lt(),c=ut(),l=ft(),u=R(),d=z(),{InvalidArgumentError:f}=u,p=xt(),m=Le(),h=Et(),g=At(),_=Dt(),v=St(),y=dt(),{getGlobalDispatcher:b,setGlobalDispatcher:x}=jt(),S=Mt(),C=et(),w=tt();Object.assign(r.prototype,p),t.exports.Dispatcher=r,t.exports.Client=n,t.exports.Pool=i,t.exports.BalancedPool=a,t.exports.Agent=o,t.exports.ProxyAgent=s,t.exports.EnvHttpProxyAgent=c,t.exports.RetryAgent=l,t.exports.RetryHandler=y,t.exports.DecoratorHandler=S,t.exports.RedirectHandler=C,t.exports.createRedirectInterceptor=w,t.exports.interceptors={redirect:Nt(),retry:Pt(),dump:Ft(),dns:It()},t.exports.buildConnector=m,t.exports.errors=u,t.exports.util={parseHeaders:d.parseHeaders,headerNameToString:d.headerNameToString};function T(e){return(t,n,r)=>{if(typeof n==`function`&&(r=n,n=null),!t||typeof t!=`string`&&typeof t!=`object`&&!(t instanceof URL))throw new f(`invalid url`);if(n!=null&&typeof n!=`object`)throw new f(`invalid opts`);if(n&&n.path!=null){if(typeof n.path!=`string`)throw new f(`invalid opts.path`);let e=n.path;n.path.startsWith(`/`)||(e=`/${e}`),t=new URL(d.parseOrigin(t).origin+e)}else n||=typeof t==`object`?t:{},t=d.parseURL(t);let{agent:i,dispatcher:a=b()}=n;if(i)throw new f(`unsupported opts.agent. Did you mean opts.client?`);return e.call(a,{...n,origin:t.origin,path:t.search?`${t.pathname}${t.search}`:t.pathname,method:n.method||(n.body?`PUT`:`GET`)},r)}}t.exports.setGlobalDispatcher=x,t.exports.getGlobalDispatcher=b;let E=Vt().fetch;t.exports.fetch=async function(e,t=void 0){try{return await E(e,t)}catch(e){throw e&&typeof e==`object`&&Error.captureStackTrace(e),e}},t.exports.Headers=Lt().Headers,t.exports.Response=Rt().Response,t.exports.Request=Bt().Request,t.exports.FormData=Ye().FormData,t.exports.File=globalThis.File??L(`node:buffer`).File,t.exports.FileReader=Kt().FileReader;let{setGlobalOrigin:D,getGlobalOrigin:O}=Ue();t.exports.setGlobalOrigin=D,t.exports.getGlobalOrigin=O;let{CacheStorage:k}=Xt(),{kConstruct:A}=qt();t.exports.caches=new k(A);let{deleteCookie:j,getCookies:M,getSetCookies:N,setCookie:P}=en();t.exports.deleteCookie=j,t.exports.getCookies=M,t.exports.getSetCookies=N,t.exports.setCookie=P;let{parseMIMEType:ee,serializeAMimeType:te}=We();t.exports.parseMIMEType=ee,t.exports.serializeAMimeType=te;let{CloseEvent:ne,ErrorEvent:F,MessageEvent:re}=tn();t.exports.WebSocket=dn().WebSocket,t.exports.CloseEvent=ne,t.exports.ErrorEvent=F,t.exports.MessageEvent=re,t.exports.request=T(p.request),t.exports.stream=T(p.stream),t.exports.pipeline=T(p.pipeline),t.exports.connect=T(p.connect),t.exports.upgrade=T(p.upgrade),t.exports.MockClient=h,t.exports.MockPool=_,t.exports.MockAgent=g,t.exports.mockErrors=v;let{EventSource:ie}=mn();t.exports.EventSource=ie})),gn=me(Oe(),1),_n=hn(),vn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},yn;(function(e){e[e.OK=200]=`OK`,e[e.MultipleChoices=300]=`MultipleChoices`,e[e.MovedPermanently=301]=`MovedPermanently`,e[e.ResourceMoved=302]=`ResourceMoved`,e[e.SeeOther=303]=`SeeOther`,e[e.NotModified=304]=`NotModified`,e[e.UseProxy=305]=`UseProxy`,e[e.SwitchProxy=306]=`SwitchProxy`,e[e.TemporaryRedirect=307]=`TemporaryRedirect`,e[e.PermanentRedirect=308]=`PermanentRedirect`,e[e.BadRequest=400]=`BadRequest`,e[e.Unauthorized=401]=`Unauthorized`,e[e.PaymentRequired=402]=`PaymentRequired`,e[e.Forbidden=403]=`Forbidden`,e[e.NotFound=404]=`NotFound`,e[e.MethodNotAllowed=405]=`MethodNotAllowed`,e[e.NotAcceptable=406]=`NotAcceptable`,e[e.ProxyAuthenticationRequired=407]=`ProxyAuthenticationRequired`,e[e.RequestTimeout=408]=`RequestTimeout`,e[e.Conflict=409]=`Conflict`,e[e.Gone=410]=`Gone`,e[e.TooManyRequests=429]=`TooManyRequests`,e[e.InternalServerError=500]=`InternalServerError`,e[e.NotImplemented=501]=`NotImplemented`,e[e.BadGateway=502]=`BadGateway`,e[e.ServiceUnavailable=503]=`ServiceUnavailable`,e[e.GatewayTimeout=504]=`GatewayTimeout`})(yn||={});var bn;(function(e){e.Accept=`accept`,e.ContentType=`content-type`})(bn||={});var xn;(function(e){e.ApplicationJson=`application/json`})(xn||={});const Sn=[yn.MovedPermanently,yn.ResourceMoved,yn.SeeOther,yn.TemporaryRedirect,yn.PermanentRedirect],Cn=[yn.BadGateway,yn.ServiceUnavailable,yn.GatewayTimeout],wn=[`OPTIONS`,`GET`,`DELETE`,`HEAD`];var Tn=class e extends Error{constructor(t,n){super(t),this.name=`HttpClientError`,this.statusCode=n,Object.setPrototypeOf(this,e.prototype)}},En=class{constructor(e){this.message=e}readBody(){return vn(this,void 0,void 0,function*(){return new Promise(e=>vn(this,void 0,void 0,function*(){let t=Buffer.alloc(0);this.message.on(`data`,e=>{t=Buffer.concat([t,e])}),this.message.on(`end`,()=>{e(t.toString())})}))})}readBodyBuffer(){return vn(this,void 0,void 0,function*(){return new Promise(e=>vn(this,void 0,void 0,function*(){let t=[];this.message.on(`data`,e=>{t.push(e)}),this.message.on(`end`,()=>{e(Buffer.concat(t))})}))})}},Dn=class{constructor(e,t,n){this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=this._getUserAgentWithOrchestrationId(e),this.handlers=t||[],this.requestOptions=n,n&&(n.ignoreSslError!=null&&(this._ignoreSslError=n.ignoreSslError),this._socketTimeout=n.socketTimeout,n.allowRedirects!=null&&(this._allowRedirects=n.allowRedirects),n.allowRedirectDowngrade!=null&&(this._allowRedirectDowngrade=n.allowRedirectDowngrade),n.maxRedirects!=null&&(this._maxRedirects=Math.max(n.maxRedirects,0)),n.keepAlive!=null&&(this._keepAlive=n.keepAlive),n.allowRetries!=null&&(this._allowRetries=n.allowRetries),n.maxRetries!=null&&(this._maxRetries=n.maxRetries))}options(e,t){return vn(this,void 0,void 0,function*(){return this.request(`OPTIONS`,e,null,t||{})})}get(e,t){return vn(this,void 0,void 0,function*(){return this.request(`GET`,e,null,t||{})})}del(e,t){return vn(this,void 0,void 0,function*(){return this.request(`DELETE`,e,null,t||{})})}post(e,t,n){return vn(this,void 0,void 0,function*(){return this.request(`POST`,e,t,n||{})})}patch(e,t,n){return vn(this,void 0,void 0,function*(){return this.request(`PATCH`,e,t,n||{})})}put(e,t,n){return vn(this,void 0,void 0,function*(){return this.request(`PUT`,e,t,n||{})})}head(e,t){return vn(this,void 0,void 0,function*(){return this.request(`HEAD`,e,null,t||{})})}sendStream(e,t,n,r){return vn(this,void 0,void 0,function*(){return this.request(e,t,n,r)})}getJson(e){return vn(this,arguments,void 0,function*(e,t={}){t[bn.Accept]=this._getExistingOrDefaultHeader(t,bn.Accept,xn.ApplicationJson);let n=yield this.get(e,t);return this._processResponse(n,this.requestOptions)})}postJson(e,t){return vn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[bn.Accept]=this._getExistingOrDefaultHeader(n,bn.Accept,xn.ApplicationJson),n[bn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,xn.ApplicationJson);let i=yield this.post(e,r,n);return this._processResponse(i,this.requestOptions)})}putJson(e,t){return vn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[bn.Accept]=this._getExistingOrDefaultHeader(n,bn.Accept,xn.ApplicationJson),n[bn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,xn.ApplicationJson);let i=yield this.put(e,r,n);return this._processResponse(i,this.requestOptions)})}patchJson(e,t){return vn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[bn.Accept]=this._getExistingOrDefaultHeader(n,bn.Accept,xn.ApplicationJson),n[bn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,xn.ApplicationJson);let i=yield this.patch(e,r,n);return this._processResponse(i,this.requestOptions)})}request(e,t,n,r){return vn(this,void 0,void 0,function*(){if(this._disposed)throw Error(`Client has already been disposed.`);let i=new URL(t),a=this._prepareRequest(e,i,r),o=this._allowRetries&&wn.includes(e)?this._maxRetries+1:1,s=0,c;do{if(c=yield this.requestRaw(a,n),c&&c.message&&c.message.statusCode===yn.Unauthorized){let e;for(let t of this.handlers)if(t.canHandleAuthentication(c)){e=t;break}return e?e.handleAuthentication(this,a,n):c}let t=this._maxRedirects;for(;c.message.statusCode&&Sn.includes(c.message.statusCode)&&this._allowRedirects&&t>0;){let o=c.message.headers.location;if(!o)break;let s=new URL(o);if(i.protocol===`https:`&&i.protocol!==s.protocol&&!this._allowRedirectDowngrade)throw Error(`Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.`);if(yield c.readBody(),s.hostname!==i.hostname)for(let e in r)e.toLowerCase()===`authorization`&&delete r[e];a=this._prepareRequest(e,s,r),c=yield this.requestRaw(a,n),t--}if(!c.message.statusCode||!Cn.includes(c.message.statusCode))return c;s+=1,s{function i(e,t){e?r(e):t?n(t):r(Error(`Unknown error`))}this.requestRawWithCallback(e,t,i)})})}requestRawWithCallback(e,t,n){typeof t==`string`&&(e.options.headers||(e.options.headers={}),e.options.headers[`Content-Length`]=Buffer.byteLength(t,`utf8`));let r=!1;function i(e,t){r||(r=!0,n(e,t))}let a=e.httpModule.request(e.options,e=>{i(void 0,new En(e))}),o;a.on(`socket`,e=>{o=e}),a.setTimeout(this._socketTimeout||3*6e4,()=>{o&&o.end(),i(Error(`Request timeout: ${e.options.path}`))}),a.on(`error`,function(e){i(e)}),t&&typeof t==`string`&&a.write(t,`utf8`),t&&typeof t!=`string`?(t.on(`close`,function(){a.end()}),t.pipe(a)):a.end()}getAgent(e){let t=new URL(e);return this._getAgent(t)}getAgentDispatcher(e){let t=new URL(e),n=Ce(t);if(n&&n.hostname)return this._getProxyAgentDispatcher(t,n)}_prepareRequest(e,t,n){let r={};r.parsedUrl=t;let i=r.parsedUrl.protocol===`https:`;r.httpModule=i?p:f;let a=i?443:80;if(r.options={},r.options.host=r.parsedUrl.hostname,r.options.port=r.parsedUrl.port?parseInt(r.parsedUrl.port):a,r.options.path=(r.parsedUrl.pathname||``)+(r.parsedUrl.search||``),r.options.method=e,r.options.headers=this._mergeHeaders(n),this.userAgent!=null&&(r.options.headers[`user-agent`]=this.userAgent),r.options.agent=this._getAgent(r.parsedUrl),this.handlers)for(let e of this.handlers)e.prepareRequest(r.options);return r}_mergeHeaders(e){return this.requestOptions&&this.requestOptions.headers?Object.assign({},On(this.requestOptions.headers),On(e||{})):On(e||{})}_getExistingOrDefaultHeader(e,t,n){let r;if(this.requestOptions&&this.requestOptions.headers){let e=On(this.requestOptions.headers)[t];e&&(r=typeof e==`number`?e.toString():e)}let i=e[t];return i===void 0?r===void 0?n:r:typeof i==`number`?i.toString():i}_getExistingOrDefaultContentTypeHeader(e,t){let n;if(this.requestOptions&&this.requestOptions.headers){let e=On(this.requestOptions.headers)[bn.ContentType];e&&(n=typeof e==`number`?String(e):Array.isArray(e)?e.join(`, `):e)}let r=e[bn.ContentType];return r===void 0?n===void 0?t:n:typeof r==`number`?String(r):Array.isArray(r)?r.join(`, `):r}_getAgent(e){let t,n=Ce(e),r=n&&n.hostname;if(this._keepAlive&&r&&(t=this._proxyAgent),r||(t=this._agent),t)return t;let i=e.protocol===`https:`,a=100;if(this.requestOptions&&(a=this.requestOptions.maxSockets||f.globalAgent.maxSockets),n&&n.hostname){let e={maxSockets:a,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(n.username||n.password)&&{proxyAuth:`${n.username}:${n.password}`}),{host:n.hostname,port:n.port})},r,o=n.protocol===`https:`;r=i?o?gn.httpsOverHttps:gn.httpsOverHttp:o?gn.httpOverHttps:gn.httpOverHttp,t=r(e),this._proxyAgent=t}if(!t){let e={keepAlive:this._keepAlive,maxSockets:a};t=i?new p.Agent(e):new f.Agent(e),this._agent=t}return i&&this._ignoreSslError&&(t.options=Object.assign(t.options||{},{rejectUnauthorized:!1})),t}_getProxyAgentDispatcher(e,t){let n;if(this._keepAlive&&(n=this._proxyAgentDispatcher),n)return n;let r=e.protocol===`https:`;return n=new _n.ProxyAgent(Object.assign({uri:t.href,pipelining:this._keepAlive?1:0},(t.username||t.password)&&{token:`Basic ${Buffer.from(`${t.username}:${t.password}`).toString(`base64`)}`})),this._proxyAgentDispatcher=n,r&&this._ignoreSslError&&(n.options=Object.assign(n.options.requestTls||{},{rejectUnauthorized:!1})),n}_getUserAgentWithOrchestrationId(e){let t=e||`actions/http-client`,n=process.env.ACTIONS_ORCHESTRATION_ID;return n?`${t} actions_orchestration_id/${n.replace(/[^a-z0-9_.-]/gi,`_`)}`:t}_performExponentialBackoff(e){return vn(this,void 0,void 0,function*(){e=Math.min(10,e);let t=5*2**e;return new Promise(e=>setTimeout(()=>e(),t))})}_processResponse(e,t){return vn(this,void 0,void 0,function*(){return new Promise((n,r)=>vn(this,void 0,void 0,function*(){let i=e.message.statusCode||0,a={statusCode:i,result:null,headers:{}};i===yn.NotFound&&n(a);function o(e,t){if(typeof t==`string`){let e=new Date(t);if(!isNaN(e.valueOf()))return e}return t}let s,c;try{c=yield e.readBody(),c&&c.length>0&&(s=t&&t.deserializeDates?JSON.parse(c,o):JSON.parse(c),a.result=s),a.headers=e.message.headers}catch{}if(i>299){let e;e=s&&s.message?s.message:c&&c.length>0?c:`Failed request: (${i})`;let t=new Tn(e,i);t.result=a.result,r(t)}else n(a)}))})}};const On=e=>Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{});var kn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},An=class{constructor(e){this.token=e}prepareRequest(e){if(!e.headers)throw Error(`The request has no headers`);e.headers.Authorization=`Bearer ${this.token}`}canHandleAuthentication(){return!1}handleAuthentication(){return kn(this,void 0,void 0,function*(){throw Error(`not implemented`)})}},jn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const{access:Mn,appendFile:Nn,writeFile:Pn}=l,Fn=`GITHUB_STEP_SUMMARY`,In=new class{constructor(){this._buffer=``}filePath(){return jn(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;let e=process.env[Fn];if(!e)throw Error(`Unable to find environment variable for $${Fn}. Check if your runtime environment supports job summaries.`);try{yield Mn(e,s.R_OK|s.W_OK)}catch{throw Error(`Unable to access summary file: '${e}'. Check if the file has correct read/write permissions.`)}return this._filePath=e,this._filePath})}wrap(e,t,n={}){let r=Object.entries(n).map(([e,t])=>` ${e}="${t}"`).join(``);return t?`<${e}${r}>${t}`:`<${e}${r}>`}write(e){return jn(this,void 0,void 0,function*(){let t=!!e?.overwrite,n=yield this.filePath();return yield(t?Pn:Nn)(n,this._buffer,{encoding:`utf8`}),this.emptyBuffer()})}clear(){return jn(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer=``,this}addRaw(e,t=!1){return this._buffer+=e,t?this.addEOL():this}addEOL(){return this.addRaw(i)}addCodeBlock(e,t){let n=Object.assign({},t&&{lang:t}),r=this.wrap(`pre`,this.wrap(`code`,e),n);return this.addRaw(r).addEOL()}addList(e,t=!1){let n=t?`ol`:`ul`,r=e.map(e=>this.wrap(`li`,e)).join(``),i=this.wrap(n,r);return this.addRaw(i).addEOL()}addTable(e){let t=e.map(e=>{let t=e.map(e=>{if(typeof e==`string`)return this.wrap(`td`,e);let{header:t,data:n,colspan:r,rowspan:i}=e,a=t?`th`:`td`,o=Object.assign(Object.assign({},r&&{colspan:r}),i&&{rowspan:i});return this.wrap(a,n,o)}).join(``);return this.wrap(`tr`,t)}).join(``),n=this.wrap(`table`,t);return this.addRaw(n).addEOL()}addDetails(e,t){let n=this.wrap(`details`,this.wrap(`summary`,e)+t);return this.addRaw(n).addEOL()}addImage(e,t,n){let{width:r,height:i}=n||{},a=Object.assign(Object.assign({},r&&{width:r}),i&&{height:i}),o=this.wrap(`img`,null,Object.assign({src:e,alt:t},a));return this.addRaw(o).addEOL()}addHeading(e,t){let n=`h${t}`,r=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`].includes(n)?n:`h1`,i=this.wrap(r,e);return this.addRaw(i).addEOL()}addSeparator(){let e=this.wrap(`hr`,null);return this.addRaw(e).addEOL()}addBreak(){let e=this.wrap(`br`,null);return this.addRaw(e).addEOL()}addQuote(e,t){let n=Object.assign({},t&&{cite:t}),r=this.wrap(`blockquote`,e,n);return this.addRaw(r).addEOL()}addLink(e,t){let n=this.wrap(`a`,e,{href:t});return this.addRaw(n).addEOL()}};var Ln=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const{chmod:Rn,copyFile:zn,lstat:Bn,mkdir:Vn,open:Hn,readdir:Un,rename:Wn,rm:Gn,rmdir:Kn,stat:qn,symlink:Jn,unlink:Yn}=o.promises,Xn=process.platform===`win32`;function Zn(e){return Ln(this,void 0,void 0,function*(){let t=yield o.promises.readlink(e);return Xn&&!t.endsWith(`\\`)?`${t}\\`:t})}o.constants.O_RDONLY;function Qn(e){return Ln(this,void 0,void 0,function*(){try{yield qn(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}return!0})}function $n(e){if(e=tr(e),!e)throw Error(`isRooted() parameter "p" cannot be empty`);return Xn?e.startsWith(`\\`)||/^[A-Z]:/i.test(e):e.startsWith(`/`)}function er(e,t){return Ln(this,void 0,void 0,function*(){let n;try{n=yield qn(e)}catch(t){t.code!==`ENOENT`&&console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}if(n&&n.isFile()){if(Xn){let n=d.extname(e).toUpperCase();if(t.some(e=>e.toUpperCase()===n))return e}else if(nr(n))return e}let r=e;for(let i of t){e=r+i,n=void 0;try{n=yield qn(e)}catch(t){t.code!==`ENOENT`&&console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}if(n&&n.isFile()){if(Xn){try{let t=d.dirname(e),n=d.basename(e).toUpperCase();for(let r of yield Un(t))if(n===r.toUpperCase()){e=d.join(t,r);break}}catch(t){console.log(`Unexpected error attempting to determine the actual case of the file '${e}': ${t}`)}return e}else if(nr(n))return e}}return``})}function tr(e){return e||=``,Xn?(e=e.replace(/\//g,`\\`),e.replace(/\\\\+/g,`\\`)):e.replace(/\/\/+/g,`/`)}function nr(e){return(e.mode&1)>0||(e.mode&8)>0&&process.getgid!==void 0&&e.gid===process.getgid()||(e.mode&64)>0&&process.getuid!==void 0&&e.uid===process.getuid()}var rr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function ir(e,t){return rr(this,arguments,void 0,function*(e,t,n={}){let{force:r,recursive:i,copySourceDirectory:a}=lr(n),o=(yield Qn(t))?yield qn(t):null;if(o&&o.isFile()&&!r)return;let s=o&&o.isDirectory()&&a?d.join(t,d.basename(e)):t;if(!(yield Qn(e)))throw Error(`no such file or directory: ${e}`);if((yield qn(e)).isDirectory())if(i)yield ur(e,s,0,r);else throw Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`);else{if(d.relative(e,s)===``)throw Error(`'${s}' and '${e}' are the same file`);yield dr(e,s,r)}})}function ar(e){return rr(this,void 0,void 0,function*(){if(Xn&&/[*"<>|]/.test(e))throw Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');try{yield Gn(e,{force:!0,maxRetries:3,recursive:!0,retryDelay:300})}catch(e){throw Error(`File was unable to be removed ${e}`)}})}function or(e){return rr(this,void 0,void 0,function*(){_(e,`a path argument must be provided`),yield Vn(e,{recursive:!0})})}function sr(e,t){return rr(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'tool' is required`);if(t){let t=yield sr(e,!1);if(!t)throw Xn?Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`):Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);return t}let n=yield cr(e);return n&&n.length>0?n[0]:``})}function cr(e){return rr(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'tool' is required`);let t=[];if(Xn&&process.env.PATHEXT)for(let e of process.env.PATHEXT.split(d.delimiter))e&&t.push(e);if($n(e)){let n=yield er(e,t);return n?[n]:[]}if(e.includes(d.sep))return[];let n=[];if(process.env.PATH)for(let e of process.env.PATH.split(d.delimiter))e&&n.push(e);let r=[];for(let i of n){let n=yield er(d.join(i,e),t);n&&r.push(n)}return r})}function lr(e){return{force:e.force==null?!0:e.force,recursive:!!e.recursive,copySourceDirectory:e.copySourceDirectory==null?!0:!!e.copySourceDirectory}}function ur(e,t,n,r){return rr(this,void 0,void 0,function*(){if(n>=255)return;n++,yield or(t);let i=yield Un(e);for(let a of i){let i=`${e}/${a}`,o=`${t}/${a}`;(yield Bn(i)).isDirectory()?yield ur(i,o,n,r):yield dr(i,o,r)}yield Rn(t,(yield qn(e)).mode)})}function dr(e,t,n){return rr(this,void 0,void 0,function*(){if((yield Bn(e)).isSymbolicLink()){try{yield Bn(t),yield Yn(t)}catch(e){e.code===`EPERM`&&(yield Rn(t,`0666`),yield Yn(t))}yield Jn(yield Zn(e),t,Xn?`junction`:null)}else (!(yield Qn(t))||n)&&(yield zn(e,t))})}var fr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const pr=process.platform===`win32`;var mr=class extends m.EventEmitter{constructor(e,t,n){if(super(),!e)throw Error(`Parameter 'toolPath' cannot be null or empty.`);this.toolPath=e,this.args=t||[],this.options=n||{}}_debug(e){this.options.listeners&&this.options.listeners.debug&&this.options.listeners.debug(e)}_getCommandString(e,t){let n=this._getSpawnFileName(),r=this._getSpawnArgs(e),i=t?``:`[command]`;if(pr)if(this._isCmdFile()){i+=n;for(let e of r)i+=` ${e}`}else if(e.windowsVerbatimArguments){i+=`"${n}"`;for(let e of r)i+=` ${e}`}else{i+=this._windowsQuoteCmdArg(n);for(let e of r)i+=` ${this._windowsQuoteCmdArg(e)}`}else{i+=n;for(let e of r)i+=` ${e}`}return i}_processLineBuffer(e,t,r){try{let i=t+e.toString(),a=i.indexOf(n.EOL);for(;a>-1;)r(i.substring(0,a)),i=i.substring(a+n.EOL.length),a=i.indexOf(n.EOL);return i}catch(e){return this._debug(`error processing line. Failed with error ${e}`),``}}_getSpawnFileName(){return pr&&this._isCmdFile()?process.env.COMSPEC||`cmd.exe`:this.toolPath}_getSpawnArgs(e){if(pr&&this._isCmdFile()){let t=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(let n of this.args)t+=` `,t+=e.windowsVerbatimArguments?n:this._windowsQuoteCmdArg(n);return t+=`"`,[t]}return this.args}_endsWith(e,t){return e.endsWith(t)}_isCmdFile(){let e=this.toolPath.toUpperCase();return this._endsWith(e,`.CMD`)||this._endsWith(e,`.BAT`)}_windowsQuoteCmdArg(e){if(!this._isCmdFile())return this._uvQuoteCmdArg(e);if(!e)return`""`;let t=[` `,` `,`&`,`(`,`)`,`[`,`]`,`{`,`}`,`^`,`=`,`;`,`!`,`'`,`+`,`,`,"`",`~`,`|`,`<`,`>`,`"`],n=!1;for(let r of e)if(t.some(e=>e===r)){n=!0;break}if(!n)return e;let r=`"`,i=!0;for(let t=e.length;t>0;t--)r+=e[t-1],i&&e[t-1]===`\\`?r+=`\\`:e[t-1]===`"`?(i=!0,r+=`"`):i=!1;return r+=`"`,r.split(``).reverse().join(``)}_uvQuoteCmdArg(e){if(!e)return`""`;if(!e.includes(` `)&&!e.includes(` `)&&!e.includes(`"`))return e;if(!e.includes(`"`)&&!e.includes(`\\`))return`"${e}"`;let t=`"`,n=!0;for(let r=e.length;r>0;r--)t+=e[r-1],n&&e[r-1]===`\\`?t+=`\\`:e[r-1]===`"`?(n=!0,t+=`\\`):n=!1;return t+=`"`,t.split(``).reverse().join(``)}_cloneExecOptions(e){e||={};let t={cwd:e.cwd||process.cwd(),env:e.env||process.env,silent:e.silent||!1,windowsVerbatimArguments:e.windowsVerbatimArguments||!1,failOnStdErr:e.failOnStdErr||!1,ignoreReturnCode:e.ignoreReturnCode||!1,delay:e.delay||1e4};return t.outStream=e.outStream||process.stdout,t.errStream=e.errStream||process.stderr,t}_getSpawnOptions(e,t){e||={};let n={};return n.cwd=e.cwd,n.env=e.env,n.windowsVerbatimArguments=e.windowsVerbatimArguments||this._isCmdFile(),e.windowsVerbatimArguments&&(n.argv0=`"${t}"`),n}exec(){return fr(this,void 0,void 0,function*(){return!$n(this.toolPath)&&(this.toolPath.includes(`/`)||pr&&this.toolPath.includes(`\\`))&&(this.toolPath=d.resolve(process.cwd(),this.options.cwd||process.cwd(),this.toolPath)),this.toolPath=yield sr(this.toolPath,!0),new Promise((e,t)=>fr(this,void 0,void 0,function*(){this._debug(`exec tool: ${this.toolPath}`),this._debug(`arguments:`);for(let e of this.args)this._debug(` ${e}`);let r=this._cloneExecOptions(this.options);!r.silent&&r.outStream&&r.outStream.write(this._getCommandString(r)+n.EOL);let i=new gr(r,this.toolPath);if(i.on(`debug`,e=>{this._debug(e)}),this.options.cwd&&!(yield Qn(this.options.cwd)))return t(Error(`The cwd: ${this.options.cwd} does not exist!`));let a=this._getSpawnFileName(),o=O.spawn(a,this._getSpawnArgs(r),this._getSpawnOptions(this.options,a)),s=``;o.stdout&&o.stdout.on(`data`,e=>{this.options.listeners&&this.options.listeners.stdout&&this.options.listeners.stdout(e),!r.silent&&r.outStream&&r.outStream.write(e),s=this._processLineBuffer(e,s,e=>{this.options.listeners&&this.options.listeners.stdline&&this.options.listeners.stdline(e)})});let c=``;if(o.stderr&&o.stderr.on(`data`,e=>{i.processStderr=!0,this.options.listeners&&this.options.listeners.stderr&&this.options.listeners.stderr(e),!r.silent&&r.errStream&&r.outStream&&(r.failOnStdErr?r.errStream:r.outStream).write(e),c=this._processLineBuffer(e,c,e=>{this.options.listeners&&this.options.listeners.errline&&this.options.listeners.errline(e)})}),o.on(`error`,e=>{i.processError=e.message,i.processExited=!0,i.processClosed=!0,i.CheckComplete()}),o.on(`exit`,e=>{i.processExitCode=e,i.processExited=!0,this._debug(`Exit code ${e} received from tool '${this.toolPath}'`),i.CheckComplete()}),o.on(`close`,e=>{i.processExitCode=e,i.processExited=!0,i.processClosed=!0,this._debug(`STDIO streams have closed for tool '${this.toolPath}'`),i.CheckComplete()}),i.on(`done`,(n,r)=>{s.length>0&&this.emit(`stdline`,s),c.length>0&&this.emit(`errline`,c),o.removeAllListeners(),n?t(n):e(r)}),this.options.input){if(!o.stdin)throw Error(`child process missing stdin`);o.stdin.end(this.options.input)}}))})}};function hr(e){let t=[],n=!1,r=!1,i=``;function a(e){r&&e!==`"`&&(i+=`\\`),i+=e,r=!1}for(let o=0;o0&&(t.push(i),i=``);continue}a(s)}return i.length>0&&t.push(i.trim()),t}var gr=class e extends m.EventEmitter{constructor(e,t){if(super(),this.processClosed=!1,this.processError=``,this.processExitCode=0,this.processExited=!1,this.processStderr=!1,this.delay=1e4,this.done=!1,this.timeout=null,!t)throw Error(`toolPath must not be empty`);this.options=e,this.toolPath=t,e.delay&&(this.delay=e.delay)}CheckComplete(){this.done||(this.processClosed?this._setResult():this.processExited&&(this.timeout=k(e.HandleTimeout,this.delay,this)))}_debug(e){this.emit(`debug`,e)}_setResult(){let e;this.processExited&&(this.processError?e=Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`):this.processExitCode!==0&&!this.options.ignoreReturnCode?e=Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`):this.processStderr&&this.options.failOnStdErr&&(e=Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`))),this.timeout&&=(clearTimeout(this.timeout),null),this.done=!0,this.emit(`done`,e,this.processExitCode)}static HandleTimeout(e){if(!e.done){if(!e.processClosed&&e.processExited){let t=`The STDIO streams did not close within ${e.delay/1e3} seconds of the exit event from process '${e.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;e._debug(t)}e._setResult()}}},_r=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function vr(e,t,n){return _r(this,void 0,void 0,function*(){let r=hr(e);if(r.length===0)throw Error(`Parameter 'commandLine' cannot be null or empty.`);let i=r[0];return t=r.slice(1).concat(t||[]),new mr(i,t,n).exec()})}function yr(e,t,n){return _r(this,void 0,void 0,function*(){let r=``,i=``,a=new D(`utf8`),o=new D(`utf8`),s=n?.listeners?.stdout,c=n?.listeners?.stderr,l=Object.assign(Object.assign({},n?.listeners),{stdout:e=>{r+=a.write(e),s&&s(e)},stderr:e=>{i+=o.write(e),c&&c(e)}}),u=yield vr(e,t,Object.assign(Object.assign({},n),{listeners:l}));return r+=a.end(),i+=o.end(),{exitCode:u,stdout:r,stderr:i}})}r.platform(),r.arch();var br;(function(e){e[e.Success=0]=`Success`,e[e.Failure=1]=`Failure`})(br||={});function xr(e,t){let n=he(t);if(process.env[e]=n,process.env.GITHUB_ENV)return xe(`ENV`,Se(e,t));_e(`set-env`,{name:e},n)}function Sr(e){_e(`add-mask`,{},e)}function Cr(e){process.env.GITHUB_PATH?xe(`PATH`,e):_e(`add-path`,{},e),process.env.PATH=`${e}${d.delimiter}${process.env.PATH}`}function wr(e,t){let n=process.env[`INPUT_${e.replace(/ /g,`_`).toUpperCase()}`]||``;if(t&&t.required&&!n)throw Error(`Input required and not supplied: ${e}`);return t&&t.trimWhitespace===!1?n:n.trim()}function Tr(e,t){if(process.env.GITHUB_OUTPUT)return xe(`OUTPUT`,Se(e,t));process.stdout.write(n.EOL),_e(`set-output`,{name:e},he(t))}function Er(e){process.exitCode=br.Failure,Or(e)}function Dr(){return process.env.RUNNER_DEBUG===`1`}function B(e){_e(`debug`,{},e)}function Or(e,t={}){_e(`error`,ge(t),e instanceof Error?e.toString():e)}function kr(e,t={}){_e(`warning`,ge(t),e instanceof Error?e.toString():e)}function Ar(e){process.stdout.write(e+n.EOL)}function jr(e,t){if(process.env.GITHUB_STATE)return xe(`STATE`,Se(e,t));_e(`save-state`,{name:e},he(t))}function Mr(e){return process.env[`STATE_${e}`]||``}function Nr(e){return e instanceof Error?e.message:String(e)}const Pr=[`token`,`password`,`secret`,`key`,`auth`,`credential`,`bearer`,`apikey`,`api_key`,`access_token`,`refresh_token`,`private`];function Fr(e,t){let n=e.toLowerCase();return t.some(e=>n.includes(e.toLowerCase()))}function Ir(e,t=Pr){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>Ir(e,t));let n={};for(let[r,i]of Object.entries(e))Fr(r,t)&&typeof i==`string`?n[r]=`[REDACTED]`:typeof i==`object`&&i?n[r]=Ir(i,t):n[r]=i;return n}function Lr(e,t,n,r){let i=Ir({...n,...r}),a={timestamp:new Date().toISOString(),level:e,message:t,...i};if(r!=null&&`error`in r&&r.error instanceof Error){let e=r.error;a.error={message:e.message,name:e.name,stack:e.stack}}return JSON.stringify(a)}function Rr(e){return{debug:(t,n)=>{B(Lr(`debug`,t,e,n))},info:(t,n)=>{Ar(Lr(`info`,t,e,n))},warning:(t,n)=>{kr(Lr(`warning`,t,e,n))},error:(t,n)=>{Or(Lr(`error`,t,e,n))}}}const zr={SHOULD_SAVE_CACHE:`shouldSaveCache`,SESSION_ID:`sessionId`,CACHE_SAVED:`cacheSaved`,OPENCODE_VERSION:`opencodeVersion`},Br=`sisyphus`,Vr=18e5,Hr={providerID:`opencode`,modelID:`big-pickle`},Ur=`1.3.3`,Wr=`1.3.11`,Gr=`3.14.0`,Kr=`opencode-storage`,qr=`opencode-tools`,Jr=6e5,Yr=`fro-bot-dedup-v1`;function Xr(){let e=t.env.XDG_DATA_HOME;return e!=null&&e.trim().length>0?e:j.join(M.homedir(),`.local`,`share`)}function Zr(){return j.join(Xr(),`opencode`,`storage`)}function Qr(){return j.join(Xr(),`opencode`,`auth.json`)}function $r(){return j.join(Xr(),`opencode`,`log`)}function ei(){let e=t.env.OPENCODE_PROMPT_ARTIFACT;return e===`true`||e===`1`}function ti(){let e=t.env.RUNNER_OS;if(e!=null&&e.trim().length>0)return e;switch(M.platform()){case`darwin`:return`macOS`;case`win32`:return`Windows`;case`aix`:case`android`:case`freebsd`:case`haiku`:case`linux`:case`openbsd`:case`sunos`:case`cygwin`:case`netbsd`:return`Linux`}}function ni(){let e=t.env.GITHUB_REPOSITORY;return e!=null&&e.trim().length>0?e:`unknown/unknown`}function ri(){let e=t.env.GITHUB_REF_NAME;return e!=null&&e.trim().length>0?e:`main`}function ii(){let e=t.env.GITHUB_RUN_ID;return e!=null&&e.trim().length>0?Number(e):0}function ai(){let e=t.env.GITHUB_WORKSPACE;return e!=null&&e.trim().length>0?e:t.cwd()}var oi=I(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),si=I(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),ci=I(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=oi(),a=si();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),li=I(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),ui=I(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:er(t,e)}})),di=I(((e,t)=>{let n=si(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=oi(),{safeRe:a,t:o}=ci(),s=li(),{compareIdentifiers:c}=ui();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&tt.major?1:this.minort.minor?1:this.patcht.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=Number(n)?1:0;if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),fi=I(((e,t)=>{let n=di();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),pi=I(((e,t)=>{let n=fi();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),mi=I(((e,t)=>{let n=fi();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),hi=I(((e,t)=>{let n=di();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),gi=I(((e,t)=>{let n=fi();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),_i=I(((e,t)=>{let n=di();t.exports=(e,t)=>new n(e,t).major})),vi=I(((e,t)=>{let n=di();t.exports=(e,t)=>new n(e,t).minor})),yi=I(((e,t)=>{let n=di();t.exports=(e,t)=>new n(e,t).patch})),bi=I(((e,t)=>{let n=fi();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),xi=I(((e,t)=>{let n=di();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Si=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(t,e,r)})),Ci=I(((e,t)=>{let n=xi();t.exports=(e,t)=>n(e,t,!0)})),wi=I(((e,t)=>{let n=di();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),Ti=I(((e,t)=>{let n=wi();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),Ei=I(((e,t)=>{let n=wi();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),Di=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)>0})),Oi=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)<0})),ki=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)===0})),Ai=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)!==0})),ji=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)>=0})),Mi=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)<=0})),Ni=I(((e,t)=>{let n=ki(),r=Ai(),i=Di(),a=ji(),o=Oi(),s=Mi();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),Pi=I(((e,t)=>{let n=di(),r=fi(),{safeRe:i,t:a}=ci();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),Fi=I(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),Ii=I(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,O(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>D(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let b=[..._.values()];return r.set(t,b),b}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;te.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=S(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=w(e,t),o(`xrange`,e),e=E(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},S=(e,t)=>e.trim().split(/\s+/).map(e=>C(e,t)).join(` `),C=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},w=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>T(e,t)).join(` `)),T=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},E=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),D=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),O=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),k=(e,t,n)=>{for(let n=0;n0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),Li=I(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=li(),{safeRe:i,t:a}=ci(),o=Ni(),s=si(),c=di(),l=Ii()})),Ri=I(((e,t)=>{let n=Ii();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),zi=I(((e,t)=>{let n=Ii();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),Bi=I(((e,t)=>{let n=di(),r=Ii();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),Vi=I(((e,t)=>{let n=di(),r=Ii();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),Hi=I(((e,t)=>{let n=di(),r=Ii(),i=Di();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),Ui=I(((e,t)=>{let n=Ii();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),Wi=I(((e,t)=>{let n=di(),r=Li(),{ANY:i}=r,a=Ii(),o=Ri(),s=Di(),c=Oi(),l=Mi(),u=ji();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),Gi=I(((e,t)=>{let n=Wi();t.exports=(e,t,r)=>n(e,t,`>`,r)})),Ki=I(((e,t)=>{let n=Wi();t.exports=(e,t,r)=>n(e,t,`<`,r)})),qi=I(((e,t)=>{let n=Ii();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),Ji=I(((e,t)=>{let n=Ri(),r=xi();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length{let n=Ii(),r=Li(),{ANY:i}=r,a=Ri(),o=xi(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),Xi=I(((e,t)=>{let n=ci(),r=oi(),i=di(),a=ui();t.exports={parse:fi(),valid:pi(),clean:mi(),inc:hi(),diff:gi(),major:_i(),minor:vi(),patch:yi(),prerelease:bi(),compare:xi(),rcompare:Si(),compareLoose:Ci(),compareBuild:wi(),sort:Ti(),rsort:Ei(),gt:Di(),lt:Oi(),eq:ki(),neq:Ai(),gte:ji(),lte:Mi(),cmp:Ni(),coerce:Pi(),Comparator:Li(),Range:Ii(),satisfies:Ri(),toComparators:zi(),maxSatisfying:Bi(),minSatisfying:Vi(),minVersion:Hi(),validRange:Ui(),outside:Wi(),gtr:Gi(),ltr:Ki(),intersects:qi(),simplifyRange:Ji(),subset:Yi(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}}));function Zi(e){let t={followSymbolicLinks:!0,implicitDescendants:!0,matchDirectories:!0,omitBrokenSymbolicLinks:!0,excludeHiddenFiles:!1};return e&&(typeof e.followSymbolicLinks==`boolean`&&(t.followSymbolicLinks=e.followSymbolicLinks,B(`followSymbolicLinks '${t.followSymbolicLinks}'`)),typeof e.implicitDescendants==`boolean`&&(t.implicitDescendants=e.implicitDescendants,B(`implicitDescendants '${t.implicitDescendants}'`)),typeof e.matchDirectories==`boolean`&&(t.matchDirectories=e.matchDirectories,B(`matchDirectories '${t.matchDirectories}'`)),typeof e.omitBrokenSymbolicLinks==`boolean`&&(t.omitBrokenSymbolicLinks=e.omitBrokenSymbolicLinks,B(`omitBrokenSymbolicLinks '${t.omitBrokenSymbolicLinks}'`)),typeof e.excludeHiddenFiles==`boolean`&&(t.excludeHiddenFiles=e.excludeHiddenFiles,B(`excludeHiddenFiles '${t.excludeHiddenFiles}'`))),t}const Qi=process.platform===`win32`;function $i(e){if(e=ia(e),Qi&&/^\\\\[^\\]+(\\[^\\]+)?$/.test(e))return e;let t=d.dirname(e);return Qi&&/^\\\\[^\\]+\\[^\\]+\\$/.test(t)&&(t=ia(t)),t}function ea(e,t){if(g(e,`ensureAbsoluteRoot parameter 'root' must not be empty`),g(t,`ensureAbsoluteRoot parameter 'itemPath' must not be empty`),ta(t))return t;if(Qi){if(t.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)){let e=process.cwd();return g(e.match(/^[A-Z]:\\/i),`Expected current directory to start with an absolute drive root. Actual '${e}'`),t[0].toUpperCase()===e[0].toUpperCase()?t.length===2?`${t[0]}:\\${e.substr(3)}`:(e.endsWith(`\\`)||(e+=`\\`),`${t[0]}:\\${e.substr(3)}${t.substr(2)}`):`${t[0]}:\\${t.substr(2)}`}else if(ra(t).match(/^\\$|^\\[^\\]/)){let e=process.cwd();return g(e.match(/^[A-Z]:\\/i),`Expected current directory to start with an absolute drive root. Actual '${e}'`),`${e[0]}:\\${t.substr(1)}`}}return g(ta(e),`ensureAbsoluteRoot parameter 'root' must have an absolute root`),e.endsWith(`/`)||Qi&&e.endsWith(`\\`)||(e+=d.sep),e+t}function ta(e){return g(e,`hasAbsoluteRoot parameter 'itemPath' must not be empty`),e=ra(e),Qi?e.startsWith(`\\\\`)||/^[A-Z]:\\/i.test(e):e.startsWith(`/`)}function na(e){return g(e,`isRooted parameter 'itemPath' must not be empty`),e=ra(e),Qi?e.startsWith(`\\`)||/^[A-Z]:/i.test(e):e.startsWith(`/`)}function ra(e){return e||=``,Qi?(e=e.replace(/\//g,`\\`),(/^\\\\+[^\\]/.test(e)?`\\`:``)+e.replace(/\\\\+/g,`\\`)):e.replace(/\/\/+/g,`/`)}function ia(e){return e?(e=ra(e),!e.endsWith(d.sep)||e===d.sep||Qi&&/^[A-Z]:\\$/i.test(e)?e:e.substr(0,e.length-1)):``}var aa;(function(e){e[e.None=0]=`None`,e[e.Directory=1]=`Directory`,e[e.File=2]=`File`,e[e.All=3]=`All`})(aa||={});const oa=process.platform===`win32`;function sa(e){e=e.filter(e=>!e.negate);let t={};for(let n of e){let e=oa?n.searchPath.toUpperCase():n.searchPath;t[e]=`candidate`}let n=[];for(let r of e){let e=oa?r.searchPath.toUpperCase():r.searchPath;if(t[e]===`included`)continue;let i=!1,a=e,o=$i(a);for(;o!==a;){if(t[o]){i=!0;break}a=o,o=$i(a)}i||(n.push(r.searchPath),t[e]=`included`)}return n}function ca(e,t){let n=aa.None;for(let r of e)r.negate?n&=~r.match(t):n|=r.match(t);return n}function la(e,t){return e.some(e=>!e.negate&&e.partialMatch(t))}var ua=I(((e,t)=>{t.exports=function(e,t){for(var r=[],i=0;i{t.exports=n;function n(e,t,n){e instanceof RegExp&&(e=r(e,n)),t instanceof RegExp&&(t=r(t,n));var a=i(e,t,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+e.length,a[1]),post:n.slice(a[1]+t.length)}}function r(e,t){var n=t.match(e);return n?n[0]:null}n.range=i;function i(e,t,n){var r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;)u==c?(r.push(u),c=n.indexOf(e,u+1)):r.length==1?s=[r.pop(),l]:(i=r.pop(),i=0?c:l;r.length&&(s=[a,o])}return s}})),fa=I(((e,t)=>{var n=ua(),r=da();t.exports=p;var i=`\0SLASH`+Math.random()+`\0`,a=`\0OPEN`+Math.random()+`\0`,o=`\0CLOSE`+Math.random()+`\0`,s=`\0COMMA`+Math.random()+`\0`,c=`\0PERIOD`+Math.random()+`\0`;function l(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function u(e){return e.split(`\\\\`).join(i).split(`\\{`).join(a).split(`\\}`).join(o).split(`\\,`).join(s).split(`\\.`).join(c)}function d(e){return e.split(i).join(`\\`).split(a).join(`{`).split(o).join(`}`).split(s).join(`,`).split(c).join(`.`)}function f(e){if(!e)return[``];var t=[],n=r(`{`,`}`,e);if(!n)return e.split(`,`);var i=n.pre,a=n.body,o=n.post,s=i.split(`,`);s[s.length-1]+=`{`+a+`}`;var c=f(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),t.push.apply(t,s),t}function p(e){return e?(e.substr(0,2)===`{}`&&(e=`\\{\\}`+e.substr(2)),v(u(e),!0).map(d)):[]}function m(e){return`{`+e+`}`}function h(e){return/^-?0\d/.test(e)}function g(e,t){return e<=t}function _(e,t){return e>=t}function v(e,t){var i=[],a=r(`{`,`}`,e);if(!a||/\$$/.test(a.pre))return[e];var s=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),u=s||c,d=a.body.indexOf(`,`)>=0;if(!u&&!d)return a.post.match(/,(?!,).*\}/)?(e=a.pre+`{`+a.body+o+a.post,v(e)):[e];var p;if(u)p=a.body.split(/\.\./);else if(p=f(a.body),p.length===1&&(p=v(p[0],!1).map(m),p.length===1)){var y=a.post.length?v(a.post,!1):[``];return y.map(function(e){return a.pre+p[0]+e})}var b=a.pre,y=a.post.length?v(a.post,!1):[``],x;if(u){var S=l(p[0]),C=l(p[1]),w=Math.max(p[0].length,p[1].length),T=p.length==3?Math.abs(l(p[2])):1,E=g;C0){var j=Array(A+1).join(`0`);k=O<0?`-`+j+k.slice(1):j+k}}x.push(k)}}else x=n(p,function(e){return v(e,!1)});for(var M=0;M{t.exports=h,h.Minimatch=g;var n=function(){try{return L(`path`)}catch{}}()||{sep:`/`};h.sep=n.sep;var r=h.GLOBSTAR=g.GLOBSTAR={},i=fa(),a={"!":{open:`(?:(?!(?:`,close:`))[^/]*?)`},"?":{open:`(?:`,close:`)?`},"+":{open:`(?:`,close:`)+`},"*":{open:`(?:`,close:`)*`},"@":{open:`(?:`,close:`)`}},o=`[^/]`,s=o+`*?`,c=`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`,l=`(?:(?!(?:\\/|^)\\.).)*?`,u=d(`().*{}+?[]^$\\!`);function d(e){return e.split(``).reduce(function(e,t){return e[t]=!0,e},{})}var f=/\/+/;h.filter=p;function p(e,t){return t||={},function(n,r,i){return h(n,e,t)}}function m(e,t){t||={};var n={};return Object.keys(e).forEach(function(t){n[t]=e[t]}),Object.keys(t).forEach(function(e){n[e]=t[e]}),n}h.defaults=function(e){if(!e||typeof e!=`object`||!Object.keys(e).length)return h;var t=h,n=function(n,r,i){return t(n,r,m(e,i))};return n.Minimatch=function(n,r){return new t.Minimatch(n,m(e,r))},n.Minimatch.defaults=function(n){return t.defaults(m(e,n)).Minimatch},n.filter=function(n,r){return t.filter(n,m(e,r))},n.defaults=function(n){return t.defaults(m(e,n))},n.makeRe=function(n,r){return t.makeRe(n,m(e,r))},n.braceExpand=function(n,r){return t.braceExpand(n,m(e,r))},n.match=function(n,r,i){return t.match(n,r,m(e,i))},n},g.defaults=function(e){return h.defaults(e).Minimatch};function h(e,t,n){return x(t),n||={},!n.nocomment&&t.charAt(0)===`#`?!1:new g(t,n).match(e)}function g(e,t){if(!(this instanceof g))return new g(e,t);x(e),t||={},e=e.trim(),!t.allowWindowsEscape&&n.sep!==`/`&&(e=e.split(n.sep).join(`/`)),this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion===void 0?200:t.maxGlobstarRecursion,this.set=[],this.pattern=e,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.make()}g.prototype.debug=function(){},g.prototype.make=_;function _(){var e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate();var n=this.globSet=this.braceExpand();t.debug&&(this.debug=function(){console.error.apply(console,arguments)}),this.debug(this.pattern,n),n=this.globParts=n.map(function(e){return e.split(f)}),this.debug(this.pattern,n),n=n.map(function(e,t,n){return e.map(this.parse,this)},this),this.debug(this.pattern,n),n=n.filter(function(e){return e.indexOf(!1)===-1}),this.debug(this.pattern,n),this.set=n}g.prototype.parseNegate=v;function v(){var e=this.pattern,t=!1,n=this.options,r=0;if(!n.nonegate){for(var i=0,a=e.length;ib)throw TypeError(`pattern is too long`)};g.prototype.parse=C;var S={};function C(e,t){x(e);var n=this.options;if(e===`**`)if(n.noglobstar)e=`*`;else return r;if(e===``)return``;var i=``,c=!!n.nocase,l=!1,d=[],f=[],p,m=!1,h=-1,g=-1,_=e.charAt(0)===`.`?``:n.dot?`(?!(?:^|\\/)\\.{1,2}(?:$|\\/))`:`(?!\\.)`,v=this;function y(){if(p){switch(p){case`*`:i+=s,c=!0;break;case`?`:i+=o,c=!0;break;default:i+=`\\`+p;break}v.debug(`clearStateChar %j %j`,p,i),p=!1}}for(var b=0,C=e.length,w;b{let n=Symbol.for(`undici.globalDispatcher.1`),{InvalidArgumentError:r}=R(),i=ct();o()===void 0&&a(new i);function a(e){if(!e||typeof e.dispatch!=`function`)throw new r(`Argument agent must implement Agent`);Object.defineProperty(globalThis,n,{value:e,writable:!0,enumerable:!1,configurable:!1})}function o(){return globalThis[n]}t.exports={setGlobalDispatcher:a,getGlobalDispatcher:o}})),Mt=I(((e,t)=>{t.exports=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`handler must be an object`);this.#e=e}onConnect(...e){return this.#e.onConnect?.(...e)}onError(...e){return this.#e.onError?.(...e)}onUpgrade(...e){return this.#e.onUpgrade?.(...e)}onResponseStarted(...e){return this.#e.onResponseStarted?.(...e)}onHeaders(...e){return this.#e.onHeaders?.(...e)}onData(...e){return this.#e.onData?.(...e)}onComplete(...e){return this.#e.onComplete?.(...e)}onBodySent(...e){return this.#e.onBodySent?.(...e)}}})),Nt=I(((e,t)=>{let n=et();t.exports=e=>{let t=e?.maxRedirections;return e=>function(r,i){let{maxRedirections:a=t,...o}=r;return a?e(o,new n(e,a,r,i)):e(r,i)}}})),Pt=I(((e,t)=>{let n=dt();t.exports=e=>t=>function(r,i){return t(r,new n({...r,retryOptions:{...e,...r.retryOptions}},{handler:i,dispatch:t}))}})),Ft=I(((e,t)=>{let n=z(),{InvalidArgumentError:r,RequestAbortedError:i}=R(),a=Mt();var o=class extends a{#e=1024*1024;#t=null;#n=!1;#r=!1;#i=0;#a=null;#o=null;constructor({maxSize:e},t){if(super(t),e!=null&&(!Number.isFinite(e)||e<1))throw new r(`maxSize must be a number greater than 0`);this.#e=e??this.#e,this.#o=t}onConnect(e){this.#t=e,this.#o.onConnect(this.#s.bind(this))}#s(e){this.#r=!0,this.#a=e}onHeaders(e,t,r,a){let o=n.parseHeaders(t)[`content-length`];if(o!=null&&o>this.#e)throw new i(`Response size (${o}) larger than maxSize (${this.#e})`);return this.#r?!0:this.#o.onHeaders(e,t,r,a)}onError(e){this.#n||(e=this.#a??e,this.#o.onError(e))}onData(e){return this.#i+=e.length,this.#i>=this.#e&&(this.#n=!0,this.#r?this.#o.onError(this.#a):this.#o.onComplete([])),!0}onComplete(e){if(!this.#n){if(this.#r){this.#o.onError(this.reason);return}this.#o.onComplete(e)}}};function s({maxSize:e}={maxSize:1024*1024}){return t=>function(n,r){let{dumpMaxSize:i=e}=n;return t(n,new o({maxSize:i},r))}}t.exports=s})),It=I(((e,t)=>{let{isIP:n}=L(`node:net`),{lookup:r}=L(`node:dns`),i=Mt(),{InvalidArgumentError:a,InformationalError:o}=R(),s=2**31-1;var c=class{#e=0;#t=0;#n=new Map;dualStack=!0;affinity=null;lookup=null;pick=null;constructor(e){this.#e=e.maxTTL,this.#t=e.maxItems,this.dualStack=e.dualStack,this.affinity=e.affinity,this.lookup=e.lookup??this.#r,this.pick=e.pick??this.#i}get full(){return this.#n.size===this.#t}runLookup(e,t,n){let r=this.#n.get(e.hostname);if(r==null&&this.full){n(null,e.origin);return}let i={affinity:this.affinity,dualStack:this.dualStack,lookup:this.lookup,pick:this.pick,...t.dns,maxTTL:this.#e,maxItems:this.#t};if(r==null)this.lookup(e,i,(t,r)=>{if(t||r==null||r.length===0){n(t??new o(`No DNS entries found`));return}this.setRecords(e,r);let a=this.#n.get(e.hostname),s=this.pick(e,a,i.affinity),c;c=typeof s.port==`number`?`:${s.port}`:e.port===``?``:`:${e.port}`,n(null,`${e.protocol}//${s.family===6?`[${s.address}]`:s.address}${c}`)});else{let a=this.pick(e,r,i.affinity);if(a==null){this.#n.delete(e.hostname),this.runLookup(e,t,n);return}let o;o=typeof a.port==`number`?`:${a.port}`:e.port===``?``:`:${e.port}`,n(null,`${e.protocol}//${a.family===6?`[${a.address}]`:a.address}${o}`)}}#r(e,t,n){r(e.hostname,{all:!0,family:this.dualStack===!1?this.affinity:0,order:`ipv4first`},(e,t)=>{if(e)return n(e);let r=new Map;for(let e of t)r.set(`${e.address}:${e.family}`,e);n(null,r.values())})}#i(e,t,n){let r=null,{records:i,offset:a}=t,o;if(this.dualStack?(n??(a==null||a===s?(t.offset=0,n=4):(t.offset++,n=(t.offset&1)==1?6:4)),o=i[n]!=null&&i[n].ips.length>0?i[n]:i[n===4?6:4]):o=i[n],o==null||o.ips.length===0)return r;o.offset==null||o.offset===s?o.offset=0:o.offset++;let c=o.offset%o.ips.length;return r=o.ips[c]??null,r==null?r:Date.now()-r.timestamp>r.ttl?(o.ips.splice(c,1),this.pick(e,t,n)):r}setRecords(e,t){let n=Date.now(),r={records:{4:null,6:null}};for(let e of t){e.timestamp=n,typeof e.ttl==`number`?e.ttl=Math.min(e.ttl,this.#e):e.ttl=this.#e;let t=r.records[e.family]??{ips:[]};t.ips.push(e),r.records[e.family]=t}this.#n.set(e.hostname,r)}getHandler(e,t){return new l(this,e,t)}},l=class extends i{#e=null;#t=null;#n=null;#r=null;#i=null;constructor(e,{origin:t,handler:n,dispatch:r},i){super(n),this.#i=t,this.#r=n,this.#t={...i},this.#e=e,this.#n=r}onError(e){switch(e.code){case`ETIMEDOUT`:case`ECONNREFUSED`:if(this.#e.dualStack){this.#e.runLookup(this.#i,this.#t,(e,t)=>{if(e)return this.#r.onError(e);let n={...this.#t,origin:t};this.#n(n,this)});return}this.#r.onError(e);return;case`ENOTFOUND`:this.#e.deleteRecord(this.#i);default:this.#r.onError(e);break}}};t.exports=e=>{if(e?.maxTTL!=null&&(typeof e?.maxTTL!=`number`||e?.maxTTL<0))throw new a(`Invalid maxTTL. Must be a positive number`);if(e?.maxItems!=null&&(typeof e?.maxItems!=`number`||e?.maxItems<1))throw new a(`Invalid maxItems. Must be a positive number and greater than zero`);if(e?.affinity!=null&&e?.affinity!==4&&e?.affinity!==6)throw new a(`Invalid affinity. Must be either 4 or 6`);if(e?.dualStack!=null&&typeof e?.dualStack!=`boolean`)throw new a(`Invalid dualStack. Must be a boolean`);if(e?.lookup!=null&&typeof e?.lookup!=`function`)throw new a(`Invalid lookup. Must be a function`);if(e?.pick!=null&&typeof e?.pick!=`function`)throw new a(`Invalid pick. Must be a function`);let t=e?.dualStack??!0,r;r=t?e?.affinity??null:e?.affinity??4;let i=new c({maxTTL:e?.maxTTL??1e4,lookup:e?.lookup??null,pick:e?.pick??null,dualStack:t,affinity:r,maxItems:e?.maxItems??1/0});return e=>function(t,r){let a=t.origin.constructor===URL?t.origin:new URL(t.origin);return n(a.hostname)===0?(i.runLookup(a,t,(n,o)=>{if(n)return r.onError(n);let s=null;s={...t,servername:a.hostname,origin:o,headers:{host:a.hostname,...t.headers}},e(s,i.getHandler({origin:a,dispatch:e,handler:r},t))}),!0):e(t,r)}}})),Lt=I(((e,t)=>{let{kConstruct:n}=ke(),{kEnumerableProperty:r}=z(),{iteratorMixin:i,isValidHeaderName:a,isValidHeaderValue:o}=Ke(),{webidl:s}=Ge(),c=L(`node:assert`),l=L(`node:util`),u=Symbol(`headers map`),d=Symbol(`headers map sorted`);function f(e){return e===10||e===13||e===9||e===32}function p(e){let t=0,n=e.length;for(;n>t&&f(e.charCodeAt(n-1));)--n;for(;n>t&&f(e.charCodeAt(t));)++t;return t===0&&n===e.length?e:e.substring(t,n)}function m(e,t){if(Array.isArray(t))for(let n=0;n>`,`record`]})}function h(e,t,n){if(n=p(n),!a(t))throw s.errors.invalidArgument({prefix:`Headers.append`,value:t,type:`header name`});if(!o(n))throw s.errors.invalidArgument({prefix:`Headers.append`,value:n,type:`header value`});if(y(e)===`immutable`)throw TypeError(`immutable`);return x(e).append(t,n,!1)}function g(e,t){return e[0]>1),t[s][0]<=l[0]?o=s+1:a=s;if(r!==s){for(i=r;i>o;)t[i]=t[--i];t[o]=l}}if(!n.next().done)throw TypeError(`Unreachable`);return t}else{let e=0;for(let{0:n,1:{value:r}}of this[u])t[e++]=[n,r],c(r!==null);return t.sort(g)}}},v=class e{#e;#t;constructor(e=void 0){s.util.markAsUncloneable(this),e!==n&&(this.#t=new _,this.#e=`none`,e!==void 0&&(e=s.converters.HeadersInit(e,`Headers contructor`,`init`),m(this,e)))}append(t,n){s.brandCheck(this,e),s.argumentLengthCheck(arguments,2,`Headers.append`);let r=`Headers.append`;return t=s.converters.ByteString(t,r,`name`),n=s.converters.ByteString(n,r,`value`),h(this,t,n)}delete(t){if(s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.delete`),t=s.converters.ByteString(t,`Headers.delete`,`name`),!a(t))throw s.errors.invalidArgument({prefix:`Headers.delete`,value:t,type:`header name`});if(this.#e===`immutable`)throw TypeError(`immutable`);this.#t.contains(t,!1)&&this.#t.delete(t,!1)}get(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.get`);let n=`Headers.get`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:n,value:t,type:`header name`});return this.#t.get(t,!1)}has(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.has`);let n=`Headers.has`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:n,value:t,type:`header name`});return this.#t.contains(t,!1)}set(t,n){s.brandCheck(this,e),s.argumentLengthCheck(arguments,2,`Headers.set`);let r=`Headers.set`;if(t=s.converters.ByteString(t,r,`name`),n=s.converters.ByteString(n,r,`value`),n=p(n),!a(t))throw s.errors.invalidArgument({prefix:r,value:t,type:`header name`});if(!o(n))throw s.errors.invalidArgument({prefix:r,value:n,type:`header value`});if(this.#e===`immutable`)throw TypeError(`immutable`);this.#t.set(t,n,!1)}getSetCookie(){s.brandCheck(this,e);let t=this.#t.cookies;return t?[...t]:[]}get[d](){if(this.#t[d])return this.#t[d];let e=[],t=this.#t.toSortedArray(),n=this.#t.cookies;if(n===null||n.length===1)return this.#t[d]=t;for(let r=0;r>`](e,t,n,r.bind(e)):s.converters[`record`](e,t,n)}throw s.errors.conversionFailed({prefix:`Headers constructor`,argument:`Argument 1`,types:[`sequence>`,`record`]})},t.exports={fill:m,compareHeaderName:g,Headers:v,HeadersList:_,getHeadersGuard:y,setHeadersGuard:b,setHeadersList:S,getHeadersList:x}})),Rt=I(((e,t)=>{let{Headers:n,HeadersList:r,fill:i,getHeadersGuard:a,setHeadersGuard:o,setHeadersList:s}=Lt(),{extractBody:c,cloneBody:l,mixinBody:u,hasFinalizationRegistry:d,streamRegistry:f,bodyUnusable:p}=Ze(),m=z(),h=L(`node:util`),{kEnumerableProperty:g}=m,{isValidReasonPhrase:_,isCancelled:v,isAborted:y,isBlobLike:b,serializeJavascriptValueToJSONString:x,isErrorLike:S,isomorphicEncode:C,environmentSettingsObject:w}=Ke(),{redirectStatusSet:T,nullBodyStatus:E}=He(),{kState:D,kHeaders:O}=qe(),{webidl:k}=Ge(),{FormData:A}=Ye(),{URLSerializer:j}=We(),{kConstruct:M}=ke(),N=L(`node:assert`),{types:P}=L(`node:util`),ee=new TextEncoder(`utf-8`);var te=class e{static error(){return le(re(),`immutable`)}static json(e,t={}){k.argumentLengthCheck(arguments,1,`Response.json`),t!==null&&(t=k.converters.ResponseInit(t));let n=c(ee.encode(x(e))),r=le(F({}),`response`);return ce(r,t,{body:n[0],type:`application/json`}),r}static redirect(e,t=302){k.argumentLengthCheck(arguments,1,`Response.redirect`),e=k.converters.USVString(e),t=k.converters[`unsigned short`](t);let n;try{n=new URL(e,w.settingsObject.baseUrl)}catch(t){throw TypeError(`Failed to parse URL from ${e}`,{cause:t})}if(!T.has(t))throw RangeError(`Invalid status code ${t}`);let r=le(F({}),`immutable`);r[D].status=t;let i=C(j(n));return r[D].headersList.append(`location`,i,!0),r}constructor(e=null,t={}){if(k.util.markAsUncloneable(this),e===M)return;e!==null&&(e=k.converters.BodyInit(e)),t=k.converters.ResponseInit(t),this[D]=F({}),this[O]=new n(M),o(this[O],`response`),s(this[O],this[D].headersList);let r=null;if(e!=null){let[t,n]=c(e);r={body:t,type:n}}ce(this,t,r)}get type(){return k.brandCheck(this,e),this[D].type}get url(){k.brandCheck(this,e);let t=this[D].urlList,n=t[t.length-1]??null;return n===null?``:j(n,!0)}get redirected(){return k.brandCheck(this,e),this[D].urlList.length>1}get status(){return k.brandCheck(this,e),this[D].status}get ok(){return k.brandCheck(this,e),this[D].status>=200&&this[D].status<=299}get statusText(){return k.brandCheck(this,e),this[D].statusText}get headers(){return k.brandCheck(this,e),this[O]}get body(){return k.brandCheck(this,e),this[D].body?this[D].body.stream:null}get bodyUsed(){return k.brandCheck(this,e),!!this[D].body&&m.isDisturbed(this[D].body.stream)}clone(){if(k.brandCheck(this,e),p(this))throw k.errors.exception({header:`Response.clone`,message:`Body has already been consumed.`});let t=ne(this[D]);return d&&this[D].body?.stream&&f.register(this,new WeakRef(this[D].body.stream)),le(t,a(this[O]))}[h.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let n={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${h.formatWithOptions(t,n)}`}};u(te),Object.defineProperties(te.prototype,{type:g,url:g,status:g,ok:g,redirected:g,statusText:g,headers:g,clone:g,body:g,bodyUsed:g,[Symbol.toStringTag]:{value:`Response`,configurable:!0}}),Object.defineProperties(te,{json:g,redirect:g,error:g});function ne(e){if(e.internalResponse)return oe(ne(e.internalResponse),e.type);let t=F({...e,body:null});return e.body!=null&&(t.body=l(t,e.body)),t}function F(e){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:`default`,status:200,timingInfo:null,cacheState:``,statusText:``,...e,headersList:e?.headersList?new r(e?.headersList):new r,urlList:e?.urlList?[...e.urlList]:[]}}function re(e){return F({type:`error`,status:0,error:S(e)?e:Error(e&&String(e)),aborted:e&&e.name===`AbortError`})}function ie(e){return e.type===`error`&&e.status===0}function ae(e,t){return t={internalResponse:e,...t},new Proxy(e,{get(e,n){return n in t?t[n]:e[n]},set(e,n,r){return N(!(n in t)),e[n]=r,!0}})}function oe(e,t){if(t===`basic`)return ae(e,{type:`basic`,headersList:e.headersList});if(t===`cors`)return ae(e,{type:`cors`,headersList:e.headersList});if(t===`opaque`)return ae(e,{type:`opaque`,urlList:Object.freeze([]),status:0,statusText:``,body:null});if(t===`opaqueredirect`)return ae(e,{type:`opaqueredirect`,status:0,statusText:``,headersList:[],body:null});N(!1)}function se(e,t=null){return N(v(e)),y(e)?re(Object.assign(new DOMException(`The operation was aborted.`,`AbortError`),{cause:t})):re(Object.assign(new DOMException(`Request was cancelled.`),{cause:t}))}function ce(e,t,n){if(t.status!==null&&(t.status<200||t.status>599))throw RangeError(`init["status"] must be in the range of 200 to 599, inclusive.`);if(`statusText`in t&&t.statusText!=null&&!_(String(t.statusText)))throw TypeError(`Invalid statusText`);if(`status`in t&&t.status!=null&&(e[D].status=t.status),`statusText`in t&&t.statusText!=null&&(e[D].statusText=t.statusText),`headers`in t&&t.headers!=null&&i(e[O],t.headers),n){if(E.includes(e.status))throw k.errors.exception({header:`Response constructor`,message:`Invalid response status code ${e.status}`});e[D].body=n.body,n.type!=null&&!e[D].headersList.contains(`content-type`,!0)&&e[D].headersList.append(`content-type`,n.type,!0)}}function le(e,t){let r=new te(M);return r[D]=e,r[O]=new n(M),s(r[O],e.headersList),o(r[O],t),d&&e.body?.stream&&f.register(r,new WeakRef(e.body.stream)),r}k.converters.ReadableStream=k.interfaceConverter(ReadableStream),k.converters.FormData=k.interfaceConverter(A),k.converters.URLSearchParams=k.interfaceConverter(URLSearchParams),k.converters.XMLHttpRequestBodyInit=function(e,t,n){return typeof e==`string`?k.converters.USVString(e,t,n):b(e)?k.converters.Blob(e,t,n,{strict:!1}):ArrayBuffer.isView(e)||P.isArrayBuffer(e)?k.converters.BufferSource(e,t,n):m.isFormDataLike(e)?k.converters.FormData(e,t,n,{strict:!1}):e instanceof URLSearchParams?k.converters.URLSearchParams(e,t,n):k.converters.DOMString(e,t,n)},k.converters.BodyInit=function(e,t,n){return e instanceof ReadableStream?k.converters.ReadableStream(e,t,n):e?.[Symbol.asyncIterator]?e:k.converters.XMLHttpRequestBodyInit(e,t,n)},k.converters.ResponseInit=k.dictionaryConverter([{key:`status`,converter:k.converters[`unsigned short`],defaultValue:()=>200},{key:`statusText`,converter:k.converters.ByteString,defaultValue:()=>``},{key:`headers`,converter:k.converters.HeadersInit}]),t.exports={isNetworkError:ie,makeNetworkError:re,makeResponse:F,makeAppropriateNetworkError:se,filterResponse:oe,Response:te,cloneResponse:ne,fromInnerResponse:le}})),zt=I(((e,t)=>{let{kConnected:n,kSize:r}=ke();var i=class{constructor(e){this.value=e}deref(){return this.value[n]===0&&this.value[r]===0?void 0:this.value}},a=class{constructor(e){this.finalizer=e}register(e,t){e.on&&e.on(`disconnect`,()=>{e[n]===0&&e[r]===0&&this.finalizer(t)})}unregister(e){}};t.exports=function(){return process.env.NODE_V8_COVERAGE&&process.version.startsWith(`v18`)?(process._rawDebug(`Using compatibility WeakRef and FinalizationRegistry`),{WeakRef:i,FinalizationRegistry:a}):{WeakRef,FinalizationRegistry}}})),Bt=I(((e,t)=>{let{extractBody:n,mixinBody:r,cloneBody:i,bodyUnusable:a}=Ze(),{Headers:o,fill:s,HeadersList:c,setHeadersGuard:l,getHeadersGuard:u,setHeadersList:d,getHeadersList:f}=Lt(),{FinalizationRegistry:p}=zt()(),m=z(),h=L(`node:util`),{isValidHTTPToken:g,sameOrigin:_,environmentSettingsObject:v}=Ke(),{forbiddenMethodsSet:y,corsSafeListedMethodsSet:b,referrerPolicy:x,requestRedirect:S,requestMode:C,requestCredentials:w,requestCache:T,requestDuplex:E}=He(),{kEnumerableProperty:D,normalizedMethodRecordsBase:O,normalizedMethodRecords:k}=m,{kHeaders:A,kSignal:j,kState:M,kDispatcher:N}=qe(),{webidl:P}=Ge(),{URLSerializer:ee}=We(),{kConstruct:te}=ke(),ne=L(`node:assert`),{getMaxListeners:F,setMaxListeners:re,getEventListeners:ie,defaultMaxListeners:ae}=L(`node:events`),oe=Symbol(`abortController`),se=new p(({signal:e,abort:t})=>{e.removeEventListener(`abort`,t)}),ce=new WeakMap;function le(e){return t;function t(){let n=e.deref();if(n!==void 0){se.unregister(t),this.removeEventListener(`abort`,t),n.abort(this.reason);let e=ce.get(n.signal);if(e!==void 0){if(e.size!==0){for(let t of e){let e=t.deref();e!==void 0&&e.abort(this.reason)}e.clear()}ce.delete(n.signal)}}}}let ue=!1;var de=class e{constructor(t,r={}){if(P.util.markAsUncloneable(this),t===te)return;let i=`Request constructor`;P.argumentLengthCheck(arguments,1,i),t=P.converters.RequestInfo(t,i,`input`),r=P.converters.RequestInit(r,i,`init`);let u=null,p=null,h=v.settingsObject.baseUrl,x=null;if(typeof t==`string`){this[N]=r.dispatcher;let e;try{e=new URL(t,h)}catch(e){throw TypeError(`Failed to parse URL from `+t,{cause:e})}if(e.username||e.password)throw TypeError(`Request cannot be constructed from a URL that includes credentials: `+t);u=I({urlList:[e]}),p=`cors`}else this[N]=r.dispatcher||t[N],ne(t instanceof e),u=t[M],x=t[j];let S=v.settingsObject.origin,C=`client`;if(u.window?.constructor?.name===`EnvironmentSettingsObject`&&_(u.window,S)&&(C=u.window),r.window!=null)throw TypeError(`'window' option '${C}' must be null`);`window`in r&&(C=`no-window`),u=I({method:u.method,headersList:u.headersList,unsafeRequest:u.unsafeRequest,client:v.settingsObject,window:C,priority:u.priority,origin:u.origin,referrer:u.referrer,referrerPolicy:u.referrerPolicy,mode:u.mode,credentials:u.credentials,cache:u.cache,redirect:u.redirect,integrity:u.integrity,keepalive:u.keepalive,reloadNavigation:u.reloadNavigation,historyNavigation:u.historyNavigation,urlList:[...u.urlList]});let w=Object.keys(r).length!==0;if(w&&(u.mode===`navigate`&&(u.mode=`same-origin`),u.reloadNavigation=!1,u.historyNavigation=!1,u.origin=`client`,u.referrer=`client`,u.referrerPolicy=``,u.url=u.urlList[u.urlList.length-1],u.urlList=[u.url]),r.referrer!==void 0){let e=r.referrer;if(e===``)u.referrer=`no-referrer`;else{let t;try{t=new URL(e,h)}catch(t){throw TypeError(`Referrer "${e}" is not a valid URL.`,{cause:t})}t.protocol===`about:`&&t.hostname===`client`||S&&!_(t,v.settingsObject.baseUrl)?u.referrer=`client`:u.referrer=t}}r.referrerPolicy!==void 0&&(u.referrerPolicy=r.referrerPolicy);let T;if(T=r.mode===void 0?p:r.mode,T===`navigate`)throw P.errors.exception({header:`Request constructor`,message:`invalid request mode navigate.`});if(T!=null&&(u.mode=T),r.credentials!==void 0&&(u.credentials=r.credentials),r.cache!==void 0&&(u.cache=r.cache),u.cache===`only-if-cached`&&u.mode!==`same-origin`)throw TypeError(`'only-if-cached' can be set only with 'same-origin' mode`);if(r.redirect!==void 0&&(u.redirect=r.redirect),r.integrity!=null&&(u.integrity=String(r.integrity)),r.keepalive!==void 0&&(u.keepalive=!!r.keepalive),r.method!==void 0){let e=r.method,t=k[e];if(t!==void 0)u.method=t;else{if(!g(e))throw TypeError(`'${e}' is not a valid HTTP method.`);let t=e.toUpperCase();if(y.has(t))throw TypeError(`'${e}' HTTP method is unsupported.`);e=O[t]??e,u.method=e}!ue&&u.method===`patch`&&(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:`UNDICI-FETCH-patch`}),ue=!0)}r.signal!==void 0&&(x=r.signal),this[M]=u;let E=new AbortController;if(this[j]=E.signal,x!=null){if(!x||typeof x.aborted!=`boolean`||typeof x.addEventListener!=`function`)throw TypeError(`Failed to construct 'Request': member signal is not of type AbortSignal.`);if(x.aborted)E.abort(x.reason);else{this[oe]=E;let e=le(new WeakRef(E));try{(typeof F==`function`&&F(x)===ae||ie(x,`abort`).length>=ae)&&re(1500,x)}catch{}m.addAbortListener(x,e),se.register(E,{signal:x,abort:e},e)}}if(this[A]=new o(te),d(this[A],u.headersList),l(this[A],`request`),T===`no-cors`){if(!b.has(u.method))throw TypeError(`'${u.method} is unsupported in no-cors mode.`);l(this[A],`request-no-cors`)}if(w){let e=f(this[A]),t=r.headers===void 0?new c(e):r.headers;if(e.clear(),t instanceof c){for(let{name:n,value:r}of t.rawValues())e.append(n,r,!1);e.cookies=t.cookies}else s(this[A],t)}let D=t instanceof e?t[M].body:null;if((r.body!=null||D!=null)&&(u.method===`GET`||u.method===`HEAD`))throw TypeError(`Request with GET/HEAD method cannot have body.`);let ee=null;if(r.body!=null){let[e,t]=n(r.body,u.keepalive);ee=e,t&&!f(this[A]).contains(`content-type`,!0)&&this[A].append(`content-type`,t)}let ce=ee??D;if(ce!=null&&ce.source==null){if(ee!=null&&r.duplex==null)throw TypeError(`RequestInit: duplex option is required when sending a body.`);if(u.mode!==`same-origin`&&u.mode!==`cors`)throw TypeError(`If request is made from ReadableStream, mode should be "same-origin" or "cors"`);u.useCORSPreflightFlag=!0}let de=ce;if(ee==null&&D!=null){if(a(t))throw TypeError(`Cannot construct a Request with a Request object that has already been used.`);let e=new TransformStream;D.stream.pipeThrough(e),de={source:D.source,length:D.length,stream:e.readable}}this[M].body=de}get method(){return P.brandCheck(this,e),this[M].method}get url(){return P.brandCheck(this,e),ee(this[M].url)}get headers(){return P.brandCheck(this,e),this[A]}get destination(){return P.brandCheck(this,e),this[M].destination}get referrer(){return P.brandCheck(this,e),this[M].referrer===`no-referrer`?``:this[M].referrer===`client`?`about:client`:this[M].referrer.toString()}get referrerPolicy(){return P.brandCheck(this,e),this[M].referrerPolicy}get mode(){return P.brandCheck(this,e),this[M].mode}get credentials(){return this[M].credentials}get cache(){return P.brandCheck(this,e),this[M].cache}get redirect(){return P.brandCheck(this,e),this[M].redirect}get integrity(){return P.brandCheck(this,e),this[M].integrity}get keepalive(){return P.brandCheck(this,e),this[M].keepalive}get isReloadNavigation(){return P.brandCheck(this,e),this[M].reloadNavigation}get isHistoryNavigation(){return P.brandCheck(this,e),this[M].historyNavigation}get signal(){return P.brandCheck(this,e),this[j]}get body(){return P.brandCheck(this,e),this[M].body?this[M].body.stream:null}get bodyUsed(){return P.brandCheck(this,e),!!this[M].body&&m.isDisturbed(this[M].body.stream)}get duplex(){return P.brandCheck(this,e),`half`}clone(){if(P.brandCheck(this,e),a(this))throw TypeError(`unusable`);let t=fe(this[M]),n=new AbortController;if(this.signal.aborted)n.abort(this.signal.reason);else{let e=ce.get(this.signal);e===void 0&&(e=new Set,ce.set(this.signal,e));let t=new WeakRef(n);e.add(t),m.addAbortListener(n.signal,le(t))}return pe(t,n.signal,u(this[A]))}[h.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let n={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${h.formatWithOptions(t,n)}`}};r(de);function I(e){return{method:e.method??`GET`,localURLsOnly:e.localURLsOnly??!1,unsafeRequest:e.unsafeRequest??!1,body:e.body??null,client:e.client??null,reservedClient:e.reservedClient??null,replacesClientId:e.replacesClientId??``,window:e.window??`client`,keepalive:e.keepalive??!1,serviceWorkers:e.serviceWorkers??`all`,initiator:e.initiator??``,destination:e.destination??``,priority:e.priority??null,origin:e.origin??`client`,policyContainer:e.policyContainer??`client`,referrer:e.referrer??`client`,referrerPolicy:e.referrerPolicy??``,mode:e.mode??`no-cors`,useCORSPreflightFlag:e.useCORSPreflightFlag??!1,credentials:e.credentials??`same-origin`,useCredentials:e.useCredentials??!1,cache:e.cache??`default`,redirect:e.redirect??`follow`,integrity:e.integrity??``,cryptoGraphicsNonceMetadata:e.cryptoGraphicsNonceMetadata??``,parserMetadata:e.parserMetadata??``,reloadNavigation:e.reloadNavigation??!1,historyNavigation:e.historyNavigation??!1,userActivation:e.userActivation??!1,taintedOrigin:e.taintedOrigin??!1,redirectCount:e.redirectCount??0,responseTainting:e.responseTainting??`basic`,preventNoCacheCacheControlHeaderModification:e.preventNoCacheCacheControlHeaderModification??!1,done:e.done??!1,timingAllowFailed:e.timingAllowFailed??!1,urlList:e.urlList,url:e.urlList[0],headersList:e.headersList?new c(e.headersList):new c}}function fe(e){let t=I({...e,body:null});return e.body!=null&&(t.body=i(t,e.body)),t}function pe(e,t,n){let r=new de(te);return r[M]=e,r[j]=t,r[A]=new o(te),d(r[A],e.headersList),l(r[A],n),r}Object.defineProperties(de.prototype,{method:D,url:D,headers:D,redirect:D,clone:D,signal:D,duplex:D,destination:D,body:D,bodyUsed:D,isHistoryNavigation:D,isReloadNavigation:D,keepalive:D,integrity:D,cache:D,credentials:D,attribute:D,referrerPolicy:D,referrer:D,mode:D,[Symbol.toStringTag]:{value:`Request`,configurable:!0}}),P.converters.Request=P.interfaceConverter(de),P.converters.RequestInfo=function(e,t,n){return typeof e==`string`?P.converters.USVString(e,t,n):e instanceof de?P.converters.Request(e,t,n):P.converters.USVString(e,t,n)},P.converters.AbortSignal=P.interfaceConverter(AbortSignal),P.converters.RequestInit=P.dictionaryConverter([{key:`method`,converter:P.converters.ByteString},{key:`headers`,converter:P.converters.HeadersInit},{key:`body`,converter:P.nullableConverter(P.converters.BodyInit)},{key:`referrer`,converter:P.converters.USVString},{key:`referrerPolicy`,converter:P.converters.DOMString,allowedValues:x},{key:`mode`,converter:P.converters.DOMString,allowedValues:C},{key:`credentials`,converter:P.converters.DOMString,allowedValues:w},{key:`cache`,converter:P.converters.DOMString,allowedValues:T},{key:`redirect`,converter:P.converters.DOMString,allowedValues:S},{key:`integrity`,converter:P.converters.DOMString},{key:`keepalive`,converter:P.converters.boolean},{key:`signal`,converter:P.nullableConverter(e=>P.converters.AbortSignal(e,`RequestInit`,`signal`,{strict:!1}))},{key:`window`,converter:P.converters.any},{key:`duplex`,converter:P.converters.DOMString,allowedValues:E},{key:`dispatcher`,converter:P.converters.any}]),t.exports={Request:de,makeRequest:I,fromInnerRequest:pe,cloneRequest:fe}})),Vt=I(((e,t)=>{let{makeNetworkError:n,makeAppropriateNetworkError:r,filterResponse:i,makeResponse:a,fromInnerResponse:o}=Rt(),{HeadersList:s}=Lt(),{Request:c,cloneRequest:l}=Bt(),u=L(`node:zlib`),{bytesMatch:d,makePolicyContainer:f,clonePolicyContainer:p,requestBadPort:m,TAOCheck:h,appendRequestOriginHeader:g,responseLocationURL:_,requestCurrentURL:v,setRequestReferrerPolicyOnRedirect:y,tryUpgradeRequestToAPotentiallyTrustworthyURL:b,createOpaqueTimingInfo:x,appendFetchMetadata:S,corsCheck:C,crossOriginResourcePolicyCheck:w,determineRequestsReferrer:T,coarsenedSharedCurrentTime:E,createDeferredPromise:D,isBlobLike:O,sameOrigin:k,isCancelled:A,isAborted:j,isErrorLike:M,fullyReadBody:N,readableStreamClose:P,isomorphicEncode:ee,urlIsLocal:te,urlIsHttpHttpsScheme:ne,urlHasHttpsScheme:F,clampAndCoarsenConnectionTimingInfo:re,simpleRangeHeaderValue:ie,buildContentRange:ae,createInflate:oe,extractMimeType:se}=Ke(),{kState:ce,kDispatcher:le}=qe(),ue=L(`node:assert`),{safelyExtractBody:de,extractBody:I}=Ze(),{redirectStatusSet:fe,nullBodyStatus:pe,safeMethodsSet:me,requestBodyHeader:he,subresourceSet:ge}=He(),_e=L(`node:events`),{Readable:ve,pipeline:ye,finished:be}=L(`node:stream`),{addAbortListener:xe,isErrored:Se,isReadable:Ce,bufferToLowerCasedHeaderName:we}=z(),{dataURLProcessor:Te,serializeAMimeType:Ee,minimizeSupportedMimeType:De}=We(),{getGlobalDispatcher:Oe}=jt(),{webidl:ke}=Ge(),{STATUS_CODES:R}=L(`node:http`),Ae=[`GET`,`HEAD`],je=typeof __UNDICI_IS_NODE__<`u`||typeof esbuildDetection<`u`?`node`:`undici`,Me;var Ne=class extends _e{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state=`ongoing`}terminate(e){this.state===`ongoing`&&(this.state=`terminated`,this.connection?.destroy(e),this.emit(`terminated`,e))}abort(e){this.state===`ongoing`&&(this.state=`aborted`,e||=new DOMException(`The operation was aborted.`,`AbortError`),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit(`terminated`,e))}};function Pe(e){Ie(e,`fetch`)}function Fe(e,t=void 0){ke.argumentLengthCheck(arguments,1,`globalThis.fetch`);let n=D(),r;try{r=new c(e,t)}catch(e){return n.reject(e),n.promise}let i=r[ce];if(r.signal.aborted)return Re(n,i,null,r.signal.reason),n.promise;i.client.globalObject?.constructor?.name===`ServiceWorkerGlobalScope`&&(i.serviceWorkers=`none`);let a=null,s=!1,l=null;return xe(r.signal,()=>{s=!0,ue(l!=null),l.abort(r.signal.reason);let e=a?.deref();Re(n,i,e,r.signal.reason)}),l=ze({request:i,processResponseEndOfBody:Pe,processResponse:e=>{if(!s){if(e.aborted){Re(n,i,a,l.serializedAbortReason);return}if(e.type===`error`){n.reject(TypeError(`fetch failed`,{cause:e.error}));return}a=new WeakRef(o(e,`immutable`)),n.resolve(a.deref()),n=null}},dispatcher:r[le]}),n.promise}function Ie(e,t=`other`){if(e.type===`error`&&e.aborted||!e.urlList?.length)return;let n=e.urlList[0],r=e.timingInfo,i=e.cacheState;ne(n)&&r!==null&&(e.timingAllowPassed||(r=x({startTime:r.startTime}),i=``),r.endTime=E(),e.timingInfo=r,Le(r,n.href,t,globalThis,i))}let Le=performance.markResourceTiming;function Re(e,t,n,r){if(e&&e.reject(r),t.body!=null&&Ce(t.body?.stream)&&t.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e}),n==null)return;let i=n[ce];i.body!=null&&Ce(i.body?.stream)&&i.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e})}function ze({request:e,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseEndOfBody:i,processResponseConsumeBody:a,useParallelQueue:o=!1,dispatcher:s=Oe()}){ue(s);let c=null,l=!1;e.client!=null&&(c=e.client.globalObject,l=e.client.crossOriginIsolatedCapability);let u=x({startTime:E(l)}),d={controller:new Ne(s),request:e,timingInfo:u,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseConsumeBody:a,processResponseEndOfBody:i,taskDestination:c,crossOriginIsolatedCapability:l};return ue(!e.body||e.body.stream),e.window===`client`&&(e.window=e.client?.globalObject?.constructor?.name===`Window`?e.client:`no-window`),e.origin===`client`&&(e.origin=e.client.origin),e.policyContainer===`client`&&(e.client==null?e.policyContainer=f():e.policyContainer=p(e.client.policyContainer)),e.headersList.contains(`accept`,!0)||e.headersList.append(`accept`,`*/*`,!0),e.headersList.contains(`accept-language`,!0)||e.headersList.append(`accept-language`,`*`,!0),e.priority,ge.has(e.destination),Be(d).catch(e=>{d.controller.terminate(e)}),d.controller}async function Be(e,t=!1){let r=e.request,a=null;if(r.localURLsOnly&&!te(v(r))&&(a=n(`local URLs only`)),b(r),m(r)===`blocked`&&(a=n(`bad port`)),r.referrerPolicy===``&&(r.referrerPolicy=r.policyContainer.referrerPolicy),r.referrer!==`no-referrer`&&(r.referrer=T(r)),a===null&&(a=await(async()=>{let t=v(r);return k(t,r.url)&&r.responseTainting===`basic`||t.protocol===`data:`||r.mode===`navigate`||r.mode===`websocket`?(r.responseTainting=`basic`,await Ve(e)):r.mode===`same-origin`?n(`request mode cannot be "same-origin"`):r.mode===`no-cors`?r.redirect===`follow`?(r.responseTainting=`opaque`,await Ve(e)):n(`redirect mode cannot be "follow" for "no-cors" request`):ne(v(r))?(r.responseTainting=`cors`,await Ye(e)):n(`URL scheme must be a HTTP(S) scheme`)})()),t)return a;a.status!==0&&!a.internalResponse&&(r.responseTainting,r.responseTainting===`basic`?a=i(a,`basic`):r.responseTainting===`cors`?a=i(a,`cors`):r.responseTainting===`opaque`?a=i(a,`opaque`):ue(!1));let o=a.status===0?a:a.internalResponse;if(o.urlList.length===0&&o.urlList.push(...r.urlList),r.timingAllowFailed||(a.timingAllowPassed=!0),a.type===`opaque`&&o.status===206&&o.rangeRequested&&!r.headers.contains(`range`,!0)&&(a=o=n()),a.status!==0&&(r.method===`HEAD`||r.method===`CONNECT`||pe.includes(o.status))&&(o.body=null,e.controller.dump=!0),r.integrity){let t=t=>Je(e,n(t));if(r.responseTainting===`opaque`||a.body==null){t(a.error);return}await N(a.body,n=>{if(!d(n,r.integrity)){t(`integrity mismatch`);return}a.body=de(n)[0],Je(e,a)},t)}else Je(e,a)}function Ve(e){if(A(e)&&e.request.redirectCount===0)return Promise.resolve(r(e));let{request:t}=e,{protocol:i}=v(t);switch(i){case`about:`:return Promise.resolve(n(`about scheme is not supported`));case`blob:`:{Me||=L(`node:buffer`).resolveObjectURL;let e=v(t);if(e.search.length!==0)return Promise.resolve(n(`NetworkError when attempting to fetch resource.`));let r=Me(e.toString());if(t.method!==`GET`||!O(r))return Promise.resolve(n(`invalid method`));let i=a(),o=r.size,s=ee(`${o}`),c=r.type;if(t.headersList.contains(`range`,!0)){i.rangeRequested=!0;let e=ie(t.headersList.get(`range`,!0),!0);if(e===`failure`)return Promise.resolve(n(`failed to fetch the data URL`));let{rangeStartValue:a,rangeEndValue:s}=e;if(a===null)a=o-s,s=a+s-1;else{if(a>=o)return Promise.resolve(n(`Range start is greater than the blob's size.`));(s===null||s>=o)&&(s=o-1)}let l=r.slice(a,s,c);i.body=I(l)[0];let u=ee(`${l.size}`),d=ae(a,s,o);i.status=206,i.statusText=`Partial Content`,i.headersList.set(`content-length`,u,!0),i.headersList.set(`content-type`,c,!0),i.headersList.set(`content-range`,d,!0)}else{let e=I(r);i.statusText=`OK`,i.body=e[0],i.headersList.set(`content-length`,s,!0),i.headersList.set(`content-type`,c,!0)}return Promise.resolve(i)}case`data:`:{let e=Te(v(t));if(e===`failure`)return Promise.resolve(n(`failed to fetch the data URL`));let r=Ee(e.mimeType);return Promise.resolve(a({statusText:`OK`,headersList:[[`content-type`,{name:`Content-Type`,value:r}]],body:de(e.body)[0]}))}case`file:`:return Promise.resolve(n(`not implemented... yet...`));case`http:`:case`https:`:return Ye(e).catch(e=>n(e));default:return Promise.resolve(n(`unknown scheme`))}}function Ue(e,t){e.request.done=!0,e.processResponseDone!=null&&queueMicrotask(()=>e.processResponseDone(t))}function Je(e,t){let n=e.timingInfo,r=()=>{let r=Date.now();e.request.destination===`document`&&(e.controller.fullTimingInfo=n),e.controller.reportTimingSteps=()=>{if(e.request.url.protocol!==`https:`)return;n.endTime=r;let i=t.cacheState,a=t.bodyInfo;t.timingAllowPassed||(n=x(n),i=``);let o=0;if(e.request.mode!==`navigator`||!t.hasCrossOriginRedirects){o=t.status;let e=se(t.headersList);e!==`failure`&&(a.contentType=De(e))}e.request.initiatorType!=null&&Le(n,e.request.url.href,e.request.initiatorType,globalThis,i,a,o)};let i=()=>{e.request.done=!0,e.processResponseEndOfBody!=null&&queueMicrotask(()=>e.processResponseEndOfBody(t)),e.request.initiatorType!=null&&e.controller.reportTimingSteps()};queueMicrotask(()=>i())};e.processResponse!=null&&queueMicrotask(()=>{e.processResponse(t),e.processResponse=null});let i=t.type===`error`?t:t.internalResponse??t;i.body==null?r():be(i.body.stream,()=>{r()})}async function Ye(e){let t=e.request,r=null,i=null,a=e.timingInfo;if(t.serviceWorkers,r===null){if(t.redirect===`follow`&&(t.serviceWorkers=`none`),i=r=await Qe(e),t.responseTainting===`cors`&&C(t,r)===`failure`)return n(`cors failure`);h(t,r)===`failure`&&(t.timingAllowFailed=!0)}return(t.responseTainting===`opaque`||r.type===`opaque`)&&w(t.origin,t.client,t.destination,i)===`blocked`?n(`blocked`):(fe.has(i.status)&&(t.redirect!==`manual`&&e.controller.connection.destroy(void 0,!1),t.redirect===`error`?r=n(`unexpected redirect`):t.redirect===`manual`?r=i:t.redirect===`follow`?r=await Xe(e,r):ue(!1)),r.timingInfo=a,r)}function Xe(e,t){let r=e.request,i=t.internalResponse?t.internalResponse:t,a;try{if(a=_(i,v(r).hash),a==null)return t}catch(e){return Promise.resolve(n(e))}if(!ne(a))return Promise.resolve(n(`URL scheme must be a HTTP(S) scheme`));if(r.redirectCount===20)return Promise.resolve(n(`redirect count exceeded`));if(r.redirectCount+=1,r.mode===`cors`&&(a.username||a.password)&&!k(r,a))return Promise.resolve(n(`cross origin not allowed for request mode "cors"`));if(r.responseTainting===`cors`&&(a.username||a.password))return Promise.resolve(n(`URL cannot contain credentials for request mode "cors"`));if(i.status!==303&&r.body!=null&&r.body.source==null)return Promise.resolve(n());if([301,302].includes(i.status)&&r.method===`POST`||i.status===303&&!Ae.includes(r.method)){r.method=`GET`,r.body=null;for(let e of he)r.headersList.delete(e)}k(v(r),a)||(r.headersList.delete(`authorization`,!0),r.headersList.delete(`proxy-authorization`,!0),r.headersList.delete(`cookie`,!0),r.headersList.delete(`host`,!0)),r.body!=null&&(ue(r.body.source!=null),r.body=de(r.body.source)[0]);let o=e.timingInfo;return o.redirectEndTime=o.postRedirectStartTime=E(e.crossOriginIsolatedCapability),o.redirectStartTime===0&&(o.redirectStartTime=o.startTime),r.urlList.push(a),y(r,i),Be(e,!0)}async function Qe(e,t=!1,i=!1){let a=e.request,o=null,s=null,c=null;a.window===`no-window`&&a.redirect===`error`?(o=e,s=a):(s=l(a),o={...e},o.request=s);let u=a.credentials===`include`||a.credentials===`same-origin`&&a.responseTainting===`basic`,d=s.body?s.body.length:null,f=null;if(s.body==null&&[`POST`,`PUT`].includes(s.method)&&(f=`0`),d!=null&&(f=ee(`${d}`)),f!=null&&s.headersList.append(`content-length`,f,!0),d!=null&&s.keepalive,s.referrer instanceof URL&&s.headersList.append(`referer`,ee(s.referrer.href),!0),g(s),S(s),s.headersList.contains(`user-agent`,!0)||s.headersList.append(`user-agent`,je),s.cache===`default`&&(s.headersList.contains(`if-modified-since`,!0)||s.headersList.contains(`if-none-match`,!0)||s.headersList.contains(`if-unmodified-since`,!0)||s.headersList.contains(`if-match`,!0)||s.headersList.contains(`if-range`,!0))&&(s.cache=`no-store`),s.cache===`no-cache`&&!s.preventNoCacheCacheControlHeaderModification&&!s.headersList.contains(`cache-control`,!0)&&s.headersList.append(`cache-control`,`max-age=0`,!0),(s.cache===`no-store`||s.cache===`reload`)&&(s.headersList.contains(`pragma`,!0)||s.headersList.append(`pragma`,`no-cache`,!0),s.headersList.contains(`cache-control`,!0)||s.headersList.append(`cache-control`,`no-cache`,!0)),s.headersList.contains(`range`,!0)&&s.headersList.append(`accept-encoding`,`identity`,!0),s.headersList.contains(`accept-encoding`,!0)||(F(v(s))?s.headersList.append(`accept-encoding`,`br, gzip, deflate`,!0):s.headersList.append(`accept-encoding`,`gzip, deflate`,!0)),s.headersList.delete(`host`,!0),s.cache=`no-store`,s.cache!==`no-store`&&s.cache,c==null){if(s.cache===`only-if-cached`)return n(`only if cached`);let e=await $e(o,u,i);!me.has(s.method)&&e.status>=200&&e.status,c??=e}if(c.urlList=[...s.urlList],s.headersList.contains(`range`,!0)&&(c.rangeRequested=!0),c.requestIncludesCredentials=u,c.status===407)return a.window===`no-window`?n():A(e)?r(e):n(`proxy authentication required`);if(c.status===421&&!i&&(a.body==null||a.body.source!=null)){if(A(e))return r(e);e.controller.connection.destroy(),c=await Qe(e,t,!0)}return c}async function $e(e,t=!1,i=!1){ue(!e.controller.connection||e.controller.connection.destroyed),e.controller.connection={abort:null,destroyed:!1,destroy(e,t=!0){this.destroyed||(this.destroyed=!0,t&&this.abort?.(e??new DOMException(`The operation was aborted.`,`AbortError`)))}};let o=e.request,c=null,l=e.timingInfo;o.cache=`no-store`,o.mode;let d=null;if(o.body==null&&e.processRequestEndOfBody)queueMicrotask(()=>e.processRequestEndOfBody());else if(o.body!=null){let t=async function*(t){A(e)||(yield t,e.processRequestBodyChunkLength?.(t.byteLength))},n=()=>{A(e)||e.processRequestEndOfBody&&e.processRequestEndOfBody()},r=t=>{A(e)||(t.name===`AbortError`?e.controller.abort():e.controller.terminate(t))};d=(async function*(){try{for await(let e of o.body.stream)yield*t(e);n()}catch(e){r(e)}})()}try{let{body:t,status:n,statusText:r,headersList:i,socket:o}=await g({body:d});if(o)c=a({status:n,statusText:r,headersList:i,socket:o});else{let o=t[Symbol.asyncIterator]();e.controller.next=()=>o.next(),c=a({status:n,statusText:r,headersList:i})}}catch(t){return t.name===`AbortError`?(e.controller.connection.destroy(),r(e,t)):n(t)}let f=async()=>{await e.controller.resume()},p=t=>{A(e)||e.controller.abort(t)},m=new ReadableStream({async start(t){e.controller.controller=t},async pull(e){await f(e)},async cancel(e){await p(e)},type:`bytes`});c.body={stream:m,source:null,length:null},e.controller.onAborted=h,e.controller.on(`terminated`,h),e.controller.resume=async()=>{for(;;){let t,n;try{let{done:n,value:r}=await e.controller.next();if(j(e))break;t=n?void 0:r}catch(r){e.controller.ended&&!l.encodedBodySize?t=void 0:(t=r,n=!0)}if(t===void 0){P(e.controller.controller),Ue(e,c);return}if(l.decodedBodySize+=t?.byteLength??0,n){e.controller.terminate(t);return}let r=new Uint8Array(t);if(r.byteLength&&e.controller.controller.enqueue(r),Se(m)){e.controller.terminate();return}if(e.controller.controller.desiredSize<=0)return}};function h(t){j(e)?(c.aborted=!0,Ce(m)&&e.controller.controller.error(e.controller.serializedAbortReason)):Ce(m)&&e.controller.controller.error(TypeError(`terminated`,{cause:M(t)?t:void 0})),e.controller.connection.destroy()}return c;function g({body:t}){let n=v(o),r=e.controller.dispatcher;return new Promise((i,a)=>r.dispatch({path:n.pathname+n.search,origin:n.origin,method:o.method,body:r.isMockActive?o.body&&(o.body.source||o.body.stream):t,headers:o.headersList.entries,maxRedirections:0,upgrade:o.mode===`websocket`?`websocket`:void 0},{body:null,abort:null,onConnect(t){let{connection:n}=e.controller;l.finalConnectionTimingInfo=re(void 0,l.postRedirectStartTime,e.crossOriginIsolatedCapability),n.destroyed?t(new DOMException(`The operation was aborted.`,`AbortError`)):(e.controller.on(`terminated`,t),this.abort=n.abort=t),l.finalNetworkRequestStartTime=E(e.crossOriginIsolatedCapability)},onResponseStarted(){l.finalNetworkResponseStartTime=E(e.crossOriginIsolatedCapability)},onHeaders(e,t,n,r){if(e<200)return;let c=``,l=new s;for(let e=0;e5)return a(Error(`too many content-encodings in response: ${t.length}, maximum allowed is 5`)),!0;for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n===`x-gzip`||n===`gzip`)d.push(u.createGunzip({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if(n===`deflate`)d.push(oe({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if(n===`br`)d.push(u.createBrotliDecompress({flush:u.constants.BROTLI_OPERATION_FLUSH,finishFlush:u.constants.BROTLI_OPERATION_FLUSH}));else{d.length=0;break}}}let p=this.onError.bind(this);return i({status:e,statusText:r,headersList:l,body:d.length?ye(this.body,...d,e=>{e&&this.onError(e)}).on(`error`,p):this.body.on(`error`,p)}),!0},onData(t){if(e.controller.dump)return;let n=t;return l.encodedBodySize+=n.byteLength,this.body.push(n)},onComplete(){this.abort&&e.controller.off(`terminated`,this.abort),e.controller.onAborted&&e.controller.off(`terminated`,e.controller.onAborted),e.controller.ended=!0,this.body.push(null)},onError(t){this.abort&&e.controller.off(`terminated`,this.abort),this.body?.destroy(t),e.controller.terminate(t),a(t)},onUpgrade(e,t,n){if(e!==101)return;let r=new s;for(let e=0;e{t.exports={kState:Symbol(`FileReader state`),kResult:Symbol(`FileReader result`),kError:Symbol(`FileReader error`),kLastProgressEventFired:Symbol(`FileReader last progress event fired timestamp`),kEvents:Symbol(`FileReader events`),kAborted:Symbol(`FileReader aborted`)}})),Ut=I(((e,t)=>{let{webidl:n}=Ge(),r=Symbol(`ProgressEvent state`);var i=class e extends Event{constructor(e,t={}){e=n.converters.DOMString(e,`ProgressEvent constructor`,`type`),t=n.converters.ProgressEventInit(t??{}),super(e,t),this[r]={lengthComputable:t.lengthComputable,loaded:t.loaded,total:t.total}}get lengthComputable(){return n.brandCheck(this,e),this[r].lengthComputable}get loaded(){return n.brandCheck(this,e),this[r].loaded}get total(){return n.brandCheck(this,e),this[r].total}};n.converters.ProgressEventInit=n.dictionaryConverter([{key:`lengthComputable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`loaded`,converter:n.converters[`unsigned long long`],defaultValue:()=>0},{key:`total`,converter:n.converters[`unsigned long long`],defaultValue:()=>0},{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}]),t.exports={ProgressEvent:i}})),Wt=I(((e,t)=>{function n(e){if(!e)return`failure`;switch(e.trim().toLowerCase()){case`unicode-1-1-utf-8`:case`unicode11utf8`:case`unicode20utf8`:case`utf-8`:case`utf8`:case`x-unicode20utf8`:return`UTF-8`;case`866`:case`cp866`:case`csibm866`:case`ibm866`:return`IBM866`;case`csisolatin2`:case`iso-8859-2`:case`iso-ir-101`:case`iso8859-2`:case`iso88592`:case`iso_8859-2`:case`iso_8859-2:1987`:case`l2`:case`latin2`:return`ISO-8859-2`;case`csisolatin3`:case`iso-8859-3`:case`iso-ir-109`:case`iso8859-3`:case`iso88593`:case`iso_8859-3`:case`iso_8859-3:1988`:case`l3`:case`latin3`:return`ISO-8859-3`;case`csisolatin4`:case`iso-8859-4`:case`iso-ir-110`:case`iso8859-4`:case`iso88594`:case`iso_8859-4`:case`iso_8859-4:1988`:case`l4`:case`latin4`:return`ISO-8859-4`;case`csisolatincyrillic`:case`cyrillic`:case`iso-8859-5`:case`iso-ir-144`:case`iso8859-5`:case`iso88595`:case`iso_8859-5`:case`iso_8859-5:1988`:return`ISO-8859-5`;case`arabic`:case`asmo-708`:case`csiso88596e`:case`csiso88596i`:case`csisolatinarabic`:case`ecma-114`:case`iso-8859-6`:case`iso-8859-6-e`:case`iso-8859-6-i`:case`iso-ir-127`:case`iso8859-6`:case`iso88596`:case`iso_8859-6`:case`iso_8859-6:1987`:return`ISO-8859-6`;case`csisolatingreek`:case`ecma-118`:case`elot_928`:case`greek`:case`greek8`:case`iso-8859-7`:case`iso-ir-126`:case`iso8859-7`:case`iso88597`:case`iso_8859-7`:case`iso_8859-7:1987`:case`sun_eu_greek`:return`ISO-8859-7`;case`csiso88598e`:case`csisolatinhebrew`:case`hebrew`:case`iso-8859-8`:case`iso-8859-8-e`:case`iso-ir-138`:case`iso8859-8`:case`iso88598`:case`iso_8859-8`:case`iso_8859-8:1988`:case`visual`:return`ISO-8859-8`;case`csiso88598i`:case`iso-8859-8-i`:case`logical`:return`ISO-8859-8-I`;case`csisolatin6`:case`iso-8859-10`:case`iso-ir-157`:case`iso8859-10`:case`iso885910`:case`l6`:case`latin6`:return`ISO-8859-10`;case`iso-8859-13`:case`iso8859-13`:case`iso885913`:return`ISO-8859-13`;case`iso-8859-14`:case`iso8859-14`:case`iso885914`:return`ISO-8859-14`;case`csisolatin9`:case`iso-8859-15`:case`iso8859-15`:case`iso885915`:case`iso_8859-15`:case`l9`:return`ISO-8859-15`;case`iso-8859-16`:return`ISO-8859-16`;case`cskoi8r`:case`koi`:case`koi8`:case`koi8-r`:case`koi8_r`:return`KOI8-R`;case`koi8-ru`:case`koi8-u`:return`KOI8-U`;case`csmacintosh`:case`mac`:case`macintosh`:case`x-mac-roman`:return`macintosh`;case`iso-8859-11`:case`iso8859-11`:case`iso885911`:case`tis-620`:case`windows-874`:return`windows-874`;case`cp1250`:case`windows-1250`:case`x-cp1250`:return`windows-1250`;case`cp1251`:case`windows-1251`:case`x-cp1251`:return`windows-1251`;case`ansi_x3.4-1968`:case`ascii`:case`cp1252`:case`cp819`:case`csisolatin1`:case`ibm819`:case`iso-8859-1`:case`iso-ir-100`:case`iso8859-1`:case`iso88591`:case`iso_8859-1`:case`iso_8859-1:1987`:case`l1`:case`latin1`:case`us-ascii`:case`windows-1252`:case`x-cp1252`:return`windows-1252`;case`cp1253`:case`windows-1253`:case`x-cp1253`:return`windows-1253`;case`cp1254`:case`csisolatin5`:case`iso-8859-9`:case`iso-ir-148`:case`iso8859-9`:case`iso88599`:case`iso_8859-9`:case`iso_8859-9:1989`:case`l5`:case`latin5`:case`windows-1254`:case`x-cp1254`:return`windows-1254`;case`cp1255`:case`windows-1255`:case`x-cp1255`:return`windows-1255`;case`cp1256`:case`windows-1256`:case`x-cp1256`:return`windows-1256`;case`cp1257`:case`windows-1257`:case`x-cp1257`:return`windows-1257`;case`cp1258`:case`windows-1258`:case`x-cp1258`:return`windows-1258`;case`x-mac-cyrillic`:case`x-mac-ukrainian`:return`x-mac-cyrillic`;case`chinese`:case`csgb2312`:case`csiso58gb231280`:case`gb2312`:case`gb_2312`:case`gb_2312-80`:case`gbk`:case`iso-ir-58`:case`x-gbk`:return`GBK`;case`gb18030`:return`gb18030`;case`big5`:case`big5-hkscs`:case`cn-big5`:case`csbig5`:case`x-x-big5`:return`Big5`;case`cseucpkdfmtjapanese`:case`euc-jp`:case`x-euc-jp`:return`EUC-JP`;case`csiso2022jp`:case`iso-2022-jp`:return`ISO-2022-JP`;case`csshiftjis`:case`ms932`:case`ms_kanji`:case`shift-jis`:case`shift_jis`:case`sjis`:case`windows-31j`:case`x-sjis`:return`Shift_JIS`;case`cseuckr`:case`csksc56011987`:case`euc-kr`:case`iso-ir-149`:case`korean`:case`ks_c_5601-1987`:case`ks_c_5601-1989`:case`ksc5601`:case`ksc_5601`:case`windows-949`:return`EUC-KR`;case`csiso2022kr`:case`hz-gb-2312`:case`iso-2022-cn`:case`iso-2022-cn-ext`:case`iso-2022-kr`:case`replacement`:return`replacement`;case`unicodefffe`:case`utf-16be`:return`UTF-16BE`;case`csunicode`:case`iso-10646-ucs-2`:case`ucs-2`:case`unicode`:case`unicodefeff`:case`utf-16`:case`utf-16le`:return`UTF-16LE`;case`x-user-defined`:return`x-user-defined`;default:return`failure`}}t.exports={getEncoding:n}})),Gt=I(((e,t)=>{let{kState:n,kError:r,kResult:i,kAborted:a,kLastProgressEventFired:o}=Ht(),{ProgressEvent:s}=Ut(),{getEncoding:c}=Wt(),{serializeAMimeType:l,parseMIMEType:u}=We(),{types:d}=L(`node:util`),{StringDecoder:f}=L(`string_decoder`),{btoa:p}=L(`node:buffer`),m={enumerable:!0,writable:!1,configurable:!1};function h(e,t,s,c){if(e[n]===`loading`)throw new DOMException(`Invalid state`,`InvalidStateError`);e[n]=`loading`,e[i]=null,e[r]=null;let l=t.stream().getReader(),u=[],f=l.read(),p=!0;(async()=>{for(;!e[a];)try{let{done:m,value:h}=await f;if(p&&!e[a]&&queueMicrotask(()=>{g(`loadstart`,e)}),p=!1,!m&&d.isUint8Array(h))u.push(h),(e[o]===void 0||Date.now()-e[o]>=50)&&!e[a]&&(e[o]=Date.now(),queueMicrotask(()=>{g(`progress`,e)})),f=l.read();else if(m){queueMicrotask(()=>{e[n]=`done`;try{let n=_(u,s,t.type,c);if(e[a])return;e[i]=n,g(`load`,e)}catch(t){e[r]=t,g(`error`,e)}e[n]!==`loading`&&g(`loadend`,e)});break}}catch(t){if(e[a])return;queueMicrotask(()=>{e[n]=`done`,e[r]=t,g(`error`,e),e[n]!==`loading`&&g(`loadend`,e)});break}})()}function g(e,t){let n=new s(e,{bubbles:!1,cancelable:!1});t.dispatchEvent(n)}function _(e,t,n,r){switch(t){case`DataURL`:{let t=`data:`,r=u(n||`application/octet-stream`);r!==`failure`&&(t+=l(r)),t+=`;base64,`;let i=new f(`latin1`);for(let n of e)t+=p(i.write(n));return t+=p(i.end()),t}case`Text`:{let t=`failure`;if(r&&(t=c(r)),t===`failure`&&n){let e=u(n);e!==`failure`&&(t=c(e.parameters.get(`charset`)))}return t===`failure`&&(t=`UTF-8`),v(e,t)}case`ArrayBuffer`:return b(e).buffer;case`BinaryString`:{let t=``,n=new f(`latin1`);for(let r of e)t+=n.write(r);return t+=n.end(),t}}}function v(e,t){let n=b(e),r=y(n),i=0;r!==null&&(t=r,i=r===`UTF-8`?3:2);let a=n.slice(i);return new TextDecoder(t).decode(a)}function y(e){let[t,n,r]=e;return t===239&&n===187&&r===191?`UTF-8`:t===254&&n===255?`UTF-16BE`:t===255&&n===254?`UTF-16LE`:null}function b(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=0;return e.reduce((e,t)=>(e.set(t,n),n+=t.byteLength,e),new Uint8Array(t))}t.exports={staticPropertyDescriptors:m,readOperation:h,fireAProgressEvent:g}})),Kt=I(((e,t)=>{let{staticPropertyDescriptors:n,readOperation:r,fireAProgressEvent:i}=Gt(),{kState:a,kError:o,kResult:s,kEvents:c,kAborted:l}=Ht(),{webidl:u}=Ge(),{kEnumerableProperty:d}=z();var f=class e extends EventTarget{constructor(){super(),this[a]=`empty`,this[s]=null,this[o]=null,this[c]={loadend:null,error:null,abort:null,load:null,progress:null,loadstart:null}}readAsArrayBuffer(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsArrayBuffer`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`ArrayBuffer`)}readAsBinaryString(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsBinaryString`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`BinaryString`)}readAsText(t,n=void 0){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsText`),t=u.converters.Blob(t,{strict:!1}),n!==void 0&&(n=u.converters.DOMString(n,`FileReader.readAsText`,`encoding`)),r(this,t,`Text`,n)}readAsDataURL(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsDataURL`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`DataURL`)}abort(){if(this[a]===`empty`||this[a]===`done`){this[s]=null;return}this[a]===`loading`&&(this[a]=`done`,this[s]=null),this[l]=!0,i(`abort`,this),this[a]!==`loading`&&i(`loadend`,this)}get readyState(){switch(u.brandCheck(this,e),this[a]){case`empty`:return this.EMPTY;case`loading`:return this.LOADING;case`done`:return this.DONE}}get result(){return u.brandCheck(this,e),this[s]}get error(){return u.brandCheck(this,e),this[o]}get onloadend(){return u.brandCheck(this,e),this[c].loadend}set onloadend(t){u.brandCheck(this,e),this[c].loadend&&this.removeEventListener(`loadend`,this[c].loadend),typeof t==`function`?(this[c].loadend=t,this.addEventListener(`loadend`,t)):this[c].loadend=null}get onerror(){return u.brandCheck(this,e),this[c].error}set onerror(t){u.brandCheck(this,e),this[c].error&&this.removeEventListener(`error`,this[c].error),typeof t==`function`?(this[c].error=t,this.addEventListener(`error`,t)):this[c].error=null}get onloadstart(){return u.brandCheck(this,e),this[c].loadstart}set onloadstart(t){u.brandCheck(this,e),this[c].loadstart&&this.removeEventListener(`loadstart`,this[c].loadstart),typeof t==`function`?(this[c].loadstart=t,this.addEventListener(`loadstart`,t)):this[c].loadstart=null}get onprogress(){return u.brandCheck(this,e),this[c].progress}set onprogress(t){u.brandCheck(this,e),this[c].progress&&this.removeEventListener(`progress`,this[c].progress),typeof t==`function`?(this[c].progress=t,this.addEventListener(`progress`,t)):this[c].progress=null}get onload(){return u.brandCheck(this,e),this[c].load}set onload(t){u.brandCheck(this,e),this[c].load&&this.removeEventListener(`load`,this[c].load),typeof t==`function`?(this[c].load=t,this.addEventListener(`load`,t)):this[c].load=null}get onabort(){return u.brandCheck(this,e),this[c].abort}set onabort(t){u.brandCheck(this,e),this[c].abort&&this.removeEventListener(`abort`,this[c].abort),typeof t==`function`?(this[c].abort=t,this.addEventListener(`abort`,t)):this[c].abort=null}};f.EMPTY=f.prototype.EMPTY=0,f.LOADING=f.prototype.LOADING=1,f.DONE=f.prototype.DONE=2,Object.defineProperties(f.prototype,{EMPTY:n,LOADING:n,DONE:n,readAsArrayBuffer:d,readAsBinaryString:d,readAsText:d,readAsDataURL:d,abort:d,readyState:d,result:d,error:d,onloadstart:d,onprogress:d,onload:d,onabort:d,onerror:d,onloadend:d,[Symbol.toStringTag]:{value:`FileReader`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(f,{EMPTY:n,LOADING:n,DONE:n}),t.exports={FileReader:f}})),qt=I(((e,t)=>{t.exports={kConstruct:ke().kConstruct}})),Jt=I(((e,t)=>{let n=L(`node:assert`),{URLSerializer:r}=We(),{isValidHeaderName:i}=Ke();function a(e,t,n=!1){return r(e,n)===r(t,n)}function o(e){n(e!==null);let t=[];for(let n of e.split(`,`))n=n.trim(),i(n)&&t.push(n);return t}t.exports={urlEquals:a,getFieldValues:o}})),Yt=I(((e,t)=>{let{kConstruct:n}=qt(),{urlEquals:r,getFieldValues:i}=Jt(),{kEnumerableProperty:a,isDisturbed:o}=z(),{webidl:s}=Ge(),{Response:c,cloneResponse:l,fromInnerResponse:u}=Rt(),{Request:d,fromInnerRequest:f}=Bt(),{kState:p}=qe(),{fetching:m}=Vt(),{urlIsHttpHttpsScheme:h,createDeferredPromise:g,readAllBytes:_}=Ke(),v=L(`node:assert`);var y=class e{#e;constructor(){arguments[0]!==n&&s.illegalConstructor(),s.util.markAsUncloneable(this),this.#e=arguments[1]}async match(t,n={}){s.brandCheck(this,e);let r=`Cache.match`;s.argumentLengthCheck(arguments,1,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.CacheQueryOptions(n,r,`options`);let i=this.#i(t,n,1);if(i.length!==0)return i[0]}async matchAll(t=void 0,n={}){s.brandCheck(this,e);let r=`Cache.matchAll`;return t!==void 0&&(t=s.converters.RequestInfo(t,r,`request`)),n=s.converters.CacheQueryOptions(n,r,`options`),this.#i(t,n)}async add(t){s.brandCheck(this,e);let n=`Cache.add`;s.argumentLengthCheck(arguments,1,n),t=s.converters.RequestInfo(t,n,`request`);let r=[t];return await this.addAll(r)}async addAll(t){s.brandCheck(this,e);let n=`Cache.addAll`;s.argumentLengthCheck(arguments,1,n);let r=[],a=[];for(let e of t){if(e===void 0)throw s.errors.conversionFailed({prefix:n,argument:`Argument 1`,types:[`undefined is not allowed`]});if(e=s.converters.RequestInfo(e),typeof e==`string`)continue;let t=e[p];if(!h(t.url)||t.method!==`GET`)throw s.errors.exception({header:n,message:`Expected http/s scheme when method is not GET.`})}let o=[];for(let e of t){let t=new d(e)[p];if(!h(t.url))throw s.errors.exception({header:n,message:`Expected http/s scheme.`});t.initiator=`fetch`,t.destination=`subresource`,a.push(t);let c=g();o.push(m({request:t,processResponse(e){if(e.type===`error`||e.status===206||e.status<200||e.status>299)c.reject(s.errors.exception({header:`Cache.addAll`,message:`Received an invalid status code or the request failed.`}));else if(e.headersList.contains(`vary`)){let t=i(e.headersList.get(`vary`));for(let e of t)if(e===`*`){c.reject(s.errors.exception({header:`Cache.addAll`,message:`invalid vary field value`}));for(let e of o)e.abort();return}}},processResponseEndOfBody(e){if(e.aborted){c.reject(new DOMException(`aborted`,`AbortError`));return}c.resolve(e)}})),r.push(c.promise)}let c=await Promise.all(r),l=[],u=0;for(let e of c){let t={type:`put`,request:a[u],response:e};l.push(t),u++}let f=g(),_=null;try{this.#t(l)}catch(e){_=e}return queueMicrotask(()=>{_===null?f.resolve(void 0):f.reject(_)}),f.promise}async put(t,n){s.brandCheck(this,e);let r=`Cache.put`;s.argumentLengthCheck(arguments,2,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.Response(n,r,`response`);let a=null;if(a=t instanceof d?t[p]:new d(t)[p],!h(a.url)||a.method!==`GET`)throw s.errors.exception({header:r,message:`Expected an http/s scheme when method is not GET`});let c=n[p];if(c.status===206)throw s.errors.exception({header:r,message:`Got 206 status`});if(c.headersList.contains(`vary`)){let e=i(c.headersList.get(`vary`));for(let t of e)if(t===`*`)throw s.errors.exception({header:r,message:`Got * vary field value`})}if(c.body&&(o(c.body.stream)||c.body.stream.locked))throw s.errors.exception({header:r,message:`Response body is locked or disturbed`});let u=l(c),f=g();c.body==null?f.resolve(void 0):_(c.body.stream.getReader()).then(f.resolve,f.reject);let m=[],v={type:`put`,request:a,response:u};m.push(v);let y=await f.promise;u.body!=null&&(u.body.source=y);let b=g(),x=null;try{this.#t(m)}catch(e){x=e}return queueMicrotask(()=>{x===null?b.resolve():b.reject(x)}),b.promise}async delete(t,n={}){s.brandCheck(this,e);let r=`Cache.delete`;s.argumentLengthCheck(arguments,1,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.CacheQueryOptions(n,r,`options`);let i=null;if(t instanceof d){if(i=t[p],i.method!==`GET`&&!n.ignoreMethod)return!1}else v(typeof t==`string`),i=new d(t)[p];let a=[],o={type:`delete`,request:i,options:n};a.push(o);let c=g(),l=null,u;try{u=this.#t(a)}catch(e){l=e}return queueMicrotask(()=>{l===null?c.resolve(!!u?.length):c.reject(l)}),c.promise}async keys(t=void 0,n={}){s.brandCheck(this,e);let r=`Cache.keys`;t!==void 0&&(t=s.converters.RequestInfo(t,r,`request`)),n=s.converters.CacheQueryOptions(n,r,`options`);let i=null;if(t!==void 0)if(t instanceof d){if(i=t[p],i.method!==`GET`&&!n.ignoreMethod)return[]}else typeof t==`string`&&(i=new d(t)[p]);let a=g(),o=[];if(t===void 0)for(let e of this.#e)o.push(e[0]);else{let e=this.#n(i,n);for(let t of e)o.push(t[0])}return queueMicrotask(()=>{let e=[];for(let t of o){let n=f(t,new AbortController().signal,`immutable`);e.push(n)}a.resolve(Object.freeze(e))}),a.promise}#t(e){let t=this.#e,n=[...t],r=[],i=[];try{for(let n of e){if(n.type!==`delete`&&n.type!==`put`)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`operation type does not match "delete" or "put"`});if(n.type===`delete`&&n.response!=null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`delete operation should not have an associated response`});if(this.#n(n.request,n.options,r).length)throw new DOMException(`???`,`InvalidStateError`);let e;if(n.type===`delete`){if(e=this.#n(n.request,n.options),e.length===0)return[];for(let n of e){let e=t.indexOf(n);v(e!==-1),t.splice(e,1)}}else if(n.type===`put`){if(n.response==null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`put operation should have an associated response`});let i=n.request;if(!h(i.url))throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`expected http or https scheme`});if(i.method!==`GET`)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`not get method`});if(n.options!=null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`options must not be defined`});e=this.#n(n.request);for(let n of e){let e=t.indexOf(n);v(e!==-1),t.splice(e,1)}t.push([n.request,n.response]),r.push([n.request,n.response])}i.push([n.request,n.response])}return i}catch(e){throw this.#e.length=0,this.#e=n,e}}#n(e,t,n){let r=[],i=n??this.#e;for(let n of i){let[i,a]=n;this.#r(e,i,a,t)&&r.push(n)}return r}#r(e,t,n=null,a){let o=new URL(e.url),s=new URL(t.url);if(a?.ignoreSearch&&(s.search=``,o.search=``),!r(o,s,!0))return!1;if(n==null||a?.ignoreVary||!n.headersList.contains(`vary`))return!0;let c=i(n.headersList.get(`vary`));for(let n of c)if(n===`*`||t.headersList.get(n)!==e.headersList.get(n))return!1;return!0}#i(e,t,n=1/0){let r=null;if(e!==void 0)if(e instanceof d){if(r=e[p],r.method!==`GET`&&!t.ignoreMethod)return[]}else typeof e==`string`&&(r=new d(e)[p]);let i=[];if(e===void 0)for(let e of this.#e)i.push(e[1]);else{let e=this.#n(r,t);for(let t of e)i.push(t[1])}let a=[];for(let e of i){let t=u(e,`immutable`);if(a.push(t.clone()),a.length>=n)break}return Object.freeze(a)}};Object.defineProperties(y.prototype,{[Symbol.toStringTag]:{value:`Cache`,configurable:!0},match:a,matchAll:a,add:a,addAll:a,put:a,delete:a,keys:a});let b=[{key:`ignoreSearch`,converter:s.converters.boolean,defaultValue:()=>!1},{key:`ignoreMethod`,converter:s.converters.boolean,defaultValue:()=>!1},{key:`ignoreVary`,converter:s.converters.boolean,defaultValue:()=>!1}];s.converters.CacheQueryOptions=s.dictionaryConverter(b),s.converters.MultiCacheQueryOptions=s.dictionaryConverter([...b,{key:`cacheName`,converter:s.converters.DOMString}]),s.converters.Response=s.interfaceConverter(c),s.converters[`sequence`]=s.sequenceConverter(s.converters.RequestInfo),t.exports={Cache:y}})),Xt=I(((e,t)=>{let{kConstruct:n}=qt(),{Cache:r}=Yt(),{webidl:i}=Ge(),{kEnumerableProperty:a}=z();var o=class e{#e=new Map;constructor(){arguments[0]!==n&&i.illegalConstructor(),i.util.markAsUncloneable(this)}async match(t,a={}){if(i.brandCheck(this,e),i.argumentLengthCheck(arguments,1,`CacheStorage.match`),t=i.converters.RequestInfo(t),a=i.converters.MultiCacheQueryOptions(a),a.cacheName!=null){if(this.#e.has(a.cacheName))return await new r(n,this.#e.get(a.cacheName)).match(t,a)}else for(let e of this.#e.values()){let i=await new r(n,e).match(t,a);if(i!==void 0)return i}}async has(t){i.brandCheck(this,e);let n=`CacheStorage.has`;return i.argumentLengthCheck(arguments,1,n),t=i.converters.DOMString(t,n,`cacheName`),this.#e.has(t)}async open(t){i.brandCheck(this,e);let a=`CacheStorage.open`;if(i.argumentLengthCheck(arguments,1,a),t=i.converters.DOMString(t,a,`cacheName`),this.#e.has(t))return new r(n,this.#e.get(t));let o=[];return this.#e.set(t,o),new r(n,o)}async delete(t){i.brandCheck(this,e);let n=`CacheStorage.delete`;return i.argumentLengthCheck(arguments,1,n),t=i.converters.DOMString(t,n,`cacheName`),this.#e.delete(t)}async keys(){return i.brandCheck(this,e),[...this.#e.keys()]}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`CacheStorage`,configurable:!0},match:a,has:a,open:a,delete:a,keys:a}),t.exports={CacheStorage:o}})),Zt=I(((e,t)=>{t.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}})),Qt=I(((e,t)=>{function n(e){for(let t=0;t=0&&n<=8||n>=10&&n<=31||n===127)return!0}return!1}function r(e){for(let t=0;t126||n===34||n===40||n===41||n===60||n===62||n===64||n===44||n===59||n===58||n===92||n===47||n===91||n===93||n===63||n===61||n===123||n===125)throw Error(`Invalid cookie name`)}}function i(e){let t=e.length,n=0;if(e[0]===`"`){if(t===1||e[t-1]!==`"`)throw Error(`Invalid cookie value`);--t,++n}for(;n126||t===34||t===44||t===59||t===92)throw Error(`Invalid cookie value`)}}function a(e){for(let t=0;tt.toString().padStart(2,`0`));function u(e){return typeof e==`number`&&(e=new Date(e)),`${s[e.getUTCDay()]}, ${l[e.getUTCDate()]} ${c[e.getUTCMonth()]} ${e.getUTCFullYear()} ${l[e.getUTCHours()]}:${l[e.getUTCMinutes()]}:${l[e.getUTCSeconds()]} GMT`}function d(e){if(e<0)throw Error(`Invalid cookie max-age`)}function f(e){if(e.name.length===0)return null;r(e.name),i(e.value);let t=[`${e.name}=${e.value}`];e.name.startsWith(`__Secure-`)&&(e.secure=!0),e.name.startsWith(`__Host-`)&&(e.secure=!0,e.domain=null,e.path=`/`),e.secure&&t.push(`Secure`),e.httpOnly&&t.push(`HttpOnly`),typeof e.maxAge==`number`&&(d(e.maxAge),t.push(`Max-Age=${e.maxAge}`)),e.domain&&(o(e.domain),t.push(`Domain=${e.domain}`)),e.path&&(a(e.path),t.push(`Path=${e.path}`)),e.expires&&e.expires.toString()!==`Invalid Date`&&t.push(`Expires=${u(e.expires)}`),e.sameSite&&t.push(`SameSite=${e.sameSite}`);for(let n of e.unparsed){if(!n.includes(`=`))throw Error(`Invalid unparsed`);let[e,...r]=n.split(`=`);t.push(`${e.trim()}=${r.join(`=`)}`)}return t.join(`; `)}t.exports={isCTLExcludingHtab:n,validateCookieName:r,validateCookiePath:a,validateCookieValue:i,toIMFDate:u,stringify:f}})),$t=I(((e,t)=>{let{maxNameValuePairSize:n,maxAttributeValueSize:r}=Zt(),{isCTLExcludingHtab:i}=Qt(),{collectASequenceOfCodePointsFast:a}=We(),o=L(`node:assert`);function s(e){if(i(e))return null;let t=``,r=``,o=``,s=``;if(e.includes(`;`)){let n={position:0};t=a(`;`,e,n),r=e.slice(n.position)}else t=e;if(!t.includes(`=`))s=t;else{let e={position:0};o=a(`=`,t,e),s=t.slice(e.position+1)}return o=o.trim(),s=s.trim(),o.length+s.length>n?null:{name:o,value:s,...c(r)}}function c(e,t={}){if(e.length===0)return t;o(e[0]===`;`),e=e.slice(1);let n=``;e.includes(`;`)?(n=a(`;`,e,{position:0}),e=e.slice(n.length)):(n=e,e=``);let i=``,s=``;if(n.includes(`=`)){let e={position:0};i=a(`=`,n,e),s=n.slice(e.position+1)}else i=n;if(i=i.trim(),s=s.trim(),s.length>r)return c(e,t);let l=i.toLowerCase();if(l===`expires`)t.expires=new Date(s);else if(l===`max-age`){let n=s.charCodeAt(0);if((n<48||n>57)&&s[0]!==`-`||!/^\d+$/.test(s))return c(e,t);t.maxAge=Number(s)}else if(l===`domain`){let e=s;e[0]===`.`&&(e=e.slice(1)),e=e.toLowerCase(),t.domain=e}else if(l===`path`){let e=``;e=s.length===0||s[0]!==`/`?`/`:s,t.path=e}else if(l===`secure`)t.secure=!0;else if(l===`httponly`)t.httpOnly=!0;else if(l===`samesite`){let e=`Default`,n=s.toLowerCase();n.includes(`none`)&&(e=`None`),n.includes(`strict`)&&(e=`Strict`),n.includes(`lax`)&&(e=`Lax`),t.sameSite=e}else t.unparsed??=[],t.unparsed.push(`${i}=${s}`);return c(e,t)}t.exports={parseSetCookie:s,parseUnparsedAttributes:c}})),en=I(((e,t)=>{let{parseSetCookie:n}=$t(),{stringify:r}=Qt(),{webidl:i}=Ge(),{Headers:a}=Lt();function o(e){i.argumentLengthCheck(arguments,1,`getCookies`),i.brandCheck(e,a,{strict:!1});let t=e.get(`cookie`),n={};if(!t)return n;for(let e of t.split(`;`)){let[t,...r]=e.split(`=`);n[t.trim()]=r.join(`=`)}return n}function s(e,t,n){i.brandCheck(e,a,{strict:!1});let r=`deleteCookie`;i.argumentLengthCheck(arguments,2,r),t=i.converters.DOMString(t,r,`name`),n=i.converters.DeleteCookieAttributes(n),l(e,{name:t,value:``,expires:new Date(0),...n})}function c(e){i.argumentLengthCheck(arguments,1,`getSetCookies`),i.brandCheck(e,a,{strict:!1});let t=e.getSetCookie();return t?t.map(e=>n(e)):[]}function l(e,t){i.argumentLengthCheck(arguments,2,`setCookie`),i.brandCheck(e,a,{strict:!1}),t=i.converters.Cookie(t);let n=r(t);n&&e.append(`Set-Cookie`,n)}i.converters.DeleteCookieAttributes=i.dictionaryConverter([{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null}]),i.converters.Cookie=i.dictionaryConverter([{converter:i.converters.DOMString,key:`name`},{converter:i.converters.DOMString,key:`value`},{converter:i.nullableConverter(e=>typeof e==`number`?i.converters[`unsigned long long`](e):new Date(e)),key:`expires`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters[`long long`]),key:`maxAge`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`secure`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`httpOnly`,defaultValue:()=>null},{converter:i.converters.USVString,key:`sameSite`,allowedValues:[`Strict`,`Lax`,`None`]},{converter:i.sequenceConverter(i.converters.DOMString),key:`unparsed`,defaultValue:()=>[]}]),t.exports={getCookies:o,deleteCookie:s,getSetCookies:c,setCookie:l}})),tn=I(((e,t)=>{let{webidl:n}=Ge(),{kEnumerableProperty:r}=z(),{kConstruct:i}=ke(),{MessagePort:a}=L(`node:worker_threads`);var o=class e extends Event{#e;constructor(e,t={}){if(e===i){super(arguments[1],arguments[2]),n.util.markAsUncloneable(this);return}let r=`MessageEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.MessageEventInit(t,r,`eventInitDict`),super(e,t),this.#e=t,n.util.markAsUncloneable(this)}get data(){return n.brandCheck(this,e),this.#e.data}get origin(){return n.brandCheck(this,e),this.#e.origin}get lastEventId(){return n.brandCheck(this,e),this.#e.lastEventId}get source(){return n.brandCheck(this,e),this.#e.source}get ports(){return n.brandCheck(this,e),Object.isFrozen(this.#e.ports)||Object.freeze(this.#e.ports),this.#e.ports}initMessageEvent(t,r=!1,i=!1,a=null,o=``,s=``,c=null,l=[]){return n.brandCheck(this,e),n.argumentLengthCheck(arguments,1,`MessageEvent.initMessageEvent`),new e(t,{bubbles:r,cancelable:i,data:a,origin:o,lastEventId:s,source:c,ports:l})}static createFastMessageEvent(t,n){let r=new e(i,t,n);return r.#e=n,r.#e.data??=null,r.#e.origin??=``,r.#e.lastEventId??=``,r.#e.source??=null,r.#e.ports??=[],r}};let{createFastMessageEvent:s}=o;delete o.createFastMessageEvent;var c=class e extends Event{#e;constructor(e,t={}){let r=`CloseEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.CloseEventInit(t),super(e,t),this.#e=t,n.util.markAsUncloneable(this)}get wasClean(){return n.brandCheck(this,e),this.#e.wasClean}get code(){return n.brandCheck(this,e),this.#e.code}get reason(){return n.brandCheck(this,e),this.#e.reason}},l=class e extends Event{#e;constructor(e,t){let r=`ErrorEvent constructor`;n.argumentLengthCheck(arguments,1,r),super(e,t),n.util.markAsUncloneable(this),e=n.converters.DOMString(e,r,`type`),t=n.converters.ErrorEventInit(t??{}),this.#e=t}get message(){return n.brandCheck(this,e),this.#e.message}get filename(){return n.brandCheck(this,e),this.#e.filename}get lineno(){return n.brandCheck(this,e),this.#e.lineno}get colno(){return n.brandCheck(this,e),this.#e.colno}get error(){return n.brandCheck(this,e),this.#e.error}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`MessageEvent`,configurable:!0},data:r,origin:r,lastEventId:r,source:r,ports:r,initMessageEvent:r}),Object.defineProperties(c.prototype,{[Symbol.toStringTag]:{value:`CloseEvent`,configurable:!0},reason:r,code:r,wasClean:r}),Object.defineProperties(l.prototype,{[Symbol.toStringTag]:{value:`ErrorEvent`,configurable:!0},message:r,filename:r,lineno:r,colno:r,error:r}),n.converters.MessagePort=n.interfaceConverter(a),n.converters[`sequence`]=n.sequenceConverter(n.converters.MessagePort);let u=[{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}];n.converters.MessageEventInit=n.dictionaryConverter([...u,{key:`data`,converter:n.converters.any,defaultValue:()=>null},{key:`origin`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lastEventId`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`source`,converter:n.nullableConverter(n.converters.MessagePort),defaultValue:()=>null},{key:`ports`,converter:n.converters[`sequence`],defaultValue:()=>[]}]),n.converters.CloseEventInit=n.dictionaryConverter([...u,{key:`wasClean`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`code`,converter:n.converters[`unsigned short`],defaultValue:()=>0},{key:`reason`,converter:n.converters.USVString,defaultValue:()=>``}]),n.converters.ErrorEventInit=n.dictionaryConverter([...u,{key:`message`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`filename`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lineno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`colno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`error`,converter:n.converters.any}]),t.exports={MessageEvent:o,CloseEvent:c,ErrorEvent:l,createFastMessageEvent:s}})),nn=I(((e,t)=>{t.exports={uid:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,sentCloseFrameState:{NOT_SENT:0,PROCESSING:1,SENT:2},staticPropertyDescriptors:{enumerable:!0,writable:!1,configurable:!1},states:{CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},opcodes:{CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},maxUnsigned16Bit:2**16-1,parserStates:{INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},emptyBuffer:Buffer.allocUnsafe(0),sendHints:{string:1,typedArray:2,arrayBuffer:3,blob:4}}})),rn=I(((e,t)=>{t.exports={kWebSocketURL:Symbol(`url`),kReadyState:Symbol(`ready state`),kController:Symbol(`controller`),kResponse:Symbol(`response`),kBinaryType:Symbol(`binary type`),kSentClose:Symbol(`sent close`),kReceivedClose:Symbol(`received close`),kByteParser:Symbol(`byte parser`)}})),an=I(((e,t)=>{let{kReadyState:n,kController:r,kResponse:i,kBinaryType:a,kWebSocketURL:o}=rn(),{states:s,opcodes:c}=nn(),{ErrorEvent:l,createFastMessageEvent:u}=tn(),{isUtf8:d}=L(`node:buffer`),{collectASequenceOfCodePointsFast:f,removeHTTPWhitespace:p}=We();function m(e){return e[n]===s.CONNECTING}function h(e){return e[n]===s.OPEN}function g(e){return e[n]===s.CLOSING}function _(e){return e[n]===s.CLOSED}function v(e,t,n=(e,t)=>new Event(e,t),r={}){let i=n(e,r);t.dispatchEvent(i)}function y(e,t,r){if(e[n]!==s.OPEN)return;let i;if(t===c.TEXT)try{i=M(r)}catch{C(e,`Received invalid UTF-8 in text frame.`);return}else t===c.BINARY&&(i=e[a]===`blob`?new Blob([r]):b(r));v(`message`,e,u,{origin:e[o].origin,data:i})}function b(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function x(e){if(e.length===0)return!1;for(let t=0;t126||n===34||n===40||n===41||n===44||n===47||n===58||n===59||n===60||n===61||n===62||n===63||n===64||n===91||n===92||n===93||n===123||n===125)return!1}return!0}function S(e){return e>=1e3&&e<1015?e!==1004&&e!==1005&&e!==1006:e>=3e3&&e<=4999}function C(e,t){let{[r]:n,[i]:a}=e;n.abort(),a?.socket&&!a.socket.destroyed&&a.socket.destroy(),t&&v(`error`,e,(e,t)=>new l(e,t),{error:Error(t),message:t})}function w(e){return e===c.CLOSE||e===c.PING||e===c.PONG}function T(e){return e===c.CONTINUATION}function E(e){return e===c.TEXT||e===c.BINARY}function D(e){return E(e)||T(e)||w(e)}function O(e){let t={position:0},n=new Map;for(;t.position57)return!1}let t=Number.parseInt(e,10);return t>=8&&t<=15}let A=typeof process.versions.icu==`string`,j=A?new TextDecoder(`utf-8`,{fatal:!0}):void 0,M=A?j.decode.bind(j):function(e){if(d(e))return e.toString(`utf-8`);throw TypeError(`Invalid utf-8 received.`)};t.exports={isConnecting:m,isEstablished:h,isClosing:g,isClosed:_,fireEvent:v,isValidSubprotocol:x,isValidStatusCode:S,failWebsocketConnection:C,websocketMessageReceived:y,utf8Decode:M,isControlFrame:w,isContinuationFrame:T,isTextBinaryFrame:E,isValidOpcode:D,parseExtensions:O,isValidClientWindowBits:k}})),on=I(((e,t)=>{let{maxUnsigned16Bit:n}=nn(),r=16386,i,a=null,o=r;try{i=L(`node:crypto`)}catch{i={randomFillSync:function(e,t,n){for(let t=0;tn?(o+=8,a=127):i>125&&(o+=2,a=126);let c=Buffer.allocUnsafe(i+o);c[0]=c[1]=0,c[0]|=128,c[0]=(c[0]&240)+e,c[o-4]=r[0],c[o-3]=r[1],c[o-2]=r[2],c[o-1]=r[3],c[1]=a,a===126?c.writeUInt16BE(i,2):a===127&&(c[2]=c[3]=0,c.writeUIntBE(i,4,6)),c[1]|=128;for(let e=0;e{let{uid:n,states:r,sentCloseFrameState:i,emptyBuffer:a,opcodes:o}=nn(),{kReadyState:s,kSentClose:c,kByteParser:l,kReceivedClose:u,kResponse:d}=rn(),{fireEvent:f,failWebsocketConnection:p,isClosing:m,isClosed:h,isEstablished:g,parseExtensions:_}=an(),{channels:v}=Me(),{CloseEvent:y}=tn(),{makeRequest:b}=Bt(),{fetching:x}=Vt(),{Headers:S,getHeadersList:C}=Lt(),{getDecodeSplit:w}=Ke(),{WebsocketFrameSend:T}=on(),E;try{E=L(`node:crypto`)}catch{}function D(e,t,r,i,a,o){let s=e;s.protocol=e.protocol===`ws:`?`http:`:`https:`;let c=b({urlList:[s],client:r,serviceWorkers:`none`,referrer:`no-referrer`,mode:`websocket`,credentials:`include`,cache:`no-store`,redirect:`error`});o.headers&&(c.headersList=C(new S(o.headers)));let l=E.randomBytes(16).toString(`base64`);c.headersList.append(`sec-websocket-key`,l),c.headersList.append(`sec-websocket-version`,`13`);for(let e of t)c.headersList.append(`sec-websocket-protocol`,e);return c.headersList.append(`sec-websocket-extensions`,`permessage-deflate; client_max_window_bits`),x({request:c,useParallelQueue:!0,dispatcher:o.dispatcher,processResponse(e){if(e.type===`error`||e.status!==101){p(i,`Received network error or non-101 status code.`);return}if(t.length!==0&&!e.headersList.get(`Sec-WebSocket-Protocol`)){p(i,`Server did not respond with sent protocols.`);return}if(e.headersList.get(`Upgrade`)?.toLowerCase()!==`websocket`){p(i,`Server did not set Upgrade header to "websocket".`);return}if(e.headersList.get(`Connection`)?.toLowerCase()!==`upgrade`){p(i,`Server did not set Connection header to "upgrade".`);return}if(e.headersList.get(`Sec-WebSocket-Accept`)!==E.createHash(`sha1`).update(l+n).digest(`base64`)){p(i,`Incorrect hash received in Sec-WebSocket-Accept header.`);return}let r=e.headersList.get(`Sec-WebSocket-Extensions`),o;if(r!==null&&(o=_(r),!o.has(`permessage-deflate`))){p(i,`Sec-WebSocket-Extensions header does not match.`);return}let s=e.headersList.get(`Sec-WebSocket-Protocol`);if(s!==null&&!w(`sec-websocket-protocol`,c.headersList).includes(s)){p(i,`Protocol was not set in the opening handshake.`);return}e.socket.on(`data`,k),e.socket.on(`close`,A),e.socket.on(`error`,j),v.open.hasSubscribers&&v.open.publish({address:e.socket.address(),protocol:s,extensions:r}),a(e,o)}})}function O(e,t,n,l){if(!(m(e)||h(e)))if(!g(e))p(e,`Connection was closed before it was established.`),e[s]=r.CLOSING;else if(e[c]===i.NOT_SENT){e[c]=i.PROCESSING;let u=new T;t!==void 0&&n===void 0?(u.frameData=Buffer.allocUnsafe(2),u.frameData.writeUInt16BE(t,0)):t!==void 0&&n!==void 0?(u.frameData=Buffer.allocUnsafe(2+l),u.frameData.writeUInt16BE(t,0),u.frameData.write(n,2,`utf-8`)):u.frameData=a,e[d].socket.write(u.createFrame(o.CLOSE)),e[c]=i.SENT,e[s]=r.CLOSING}else e[s]=r.CLOSING}function k(e){this.ws[l].write(e)||this.pause()}function A(){let{ws:e}=this,{[d]:t}=e;t.socket.off(`data`,k),t.socket.off(`close`,A),t.socket.off(`error`,j);let n=e[c]===i.SENT&&e[u],a=1005,o=``,p=e[l].closingInfo;p&&!p.error?(a=p.code??1005,o=p.reason):e[u]||(a=1006),e[s]=r.CLOSED,f(`close`,e,(e,t)=>new y(e,t),{wasClean:n,code:a,reason:o}),v.close.hasSubscribers&&v.close.publish({websocket:e,code:a,reason:o})}function j(e){let{ws:t}=this;t[s]=r.CLOSING,v.socketError.hasSubscribers&&v.socketError.publish(e),this.destroy()}t.exports={establishWebSocketConnection:D,closeWebSocketConnection:O}})),cn=I(((e,t)=>{let{createInflateRaw:n,Z_DEFAULT_WINDOWBITS:r}=L(`node:zlib`),{isValidClientWindowBits:i}=an(),{MessageSizeExceededError:a}=R(),o=Buffer.from([0,0,255,255]),s=Symbol(`kBuffer`),c=Symbol(`kLength`);t.exports={PerMessageDeflate:class{#e;#t={};#n=!1;#r=null;constructor(e){this.#t.serverNoContextTakeover=e.has(`server_no_context_takeover`),this.#t.serverMaxWindowBits=e.get(`server_max_window_bits`)}decompress(e,t,l){if(this.#n){l(new a);return}if(!this.#e){let e=r;if(this.#t.serverMaxWindowBits){if(!i(this.#t.serverMaxWindowBits)){l(Error(`Invalid server_max_window_bits`));return}e=Number.parseInt(this.#t.serverMaxWindowBits)}try{this.#e=n({windowBits:e})}catch(e){l(e);return}this.#e[s]=[],this.#e[c]=0,this.#e.on(`data`,e=>{if(!this.#n){if(this.#e[c]+=e.length,this.#e[c]>4194304){if(this.#n=!0,this.#e.removeAllListeners(),this.#e.destroy(),this.#e=null,this.#r){let e=this.#r;this.#r=null,e(new a)}return}this.#e[s].push(e)}}),this.#e.on(`error`,e=>{this.#e=null,l(e)})}this.#r=l,this.#e.write(e),t&&this.#e.write(o),this.#e.flush(()=>{if(this.#n||!this.#e)return;let e=Buffer.concat(this.#e[s],this.#e[c]);this.#e[s].length=0,this.#e[c]=0,this.#r=null,l(null,e)})}}}})),ln=I(((e,t)=>{let{Writable:n}=L(`node:stream`),r=L(`node:assert`),{parserStates:i,opcodes:a,states:o,emptyBuffer:s,sentCloseFrameState:c}=nn(),{kReadyState:l,kSentClose:u,kResponse:d,kReceivedClose:f}=rn(),{channels:p}=Me(),{isValidStatusCode:m,isValidOpcode:h,failWebsocketConnection:g,websocketMessageReceived:_,utf8Decode:v,isControlFrame:y,isTextBinaryFrame:b,isContinuationFrame:x}=an(),{WebsocketFrameSend:S}=on(),{closeWebSocketConnection:C}=sn(),{PerMessageDeflate:w}=cn();t.exports={ByteParser:class extends n{#e=[];#t=0;#n=!1;#r=i.INFO;#i={};#a=[];#o;constructor(e,t){super(),this.ws=e,this.#o=t??new Map,this.#o.has(`permessage-deflate`)&&this.#o.set(`permessage-deflate`,new w(t))}_write(e,t,n){this.#e.push(e),this.#t+=e.length,this.#n=!0,this.run(n)}run(e){for(;this.#n;)if(this.#r===i.INFO){if(this.#t<2)return e();let t=this.consume(2),n=(t[0]&128)!=0,r=t[0]&15,o=(t[1]&128)==128,s=!n&&r!==a.CONTINUATION,c=t[1]&127,l=t[0]&64,u=t[0]&32,d=t[0]&16;if(!h(r))return g(this.ws,`Invalid opcode received`),e();if(o)return g(this.ws,`Frame cannot be masked`),e();if(l!==0&&!this.#o.has(`permessage-deflate`)){g(this.ws,`Expected RSV1 to be clear.`);return}if(u!==0||d!==0){g(this.ws,`RSV1, RSV2, RSV3 must be clear`);return}if(s&&!b(r)){g(this.ws,`Invalid frame type was fragmented.`);return}if(b(r)&&this.#a.length>0){g(this.ws,`Expected continuation frame`);return}if(this.#i.fragmented&&s){g(this.ws,`Fragmented frame exceeded 125 bytes.`);return}if((c>125||s)&&y(r)){g(this.ws,`Control frame either too large or fragmented`);return}if(x(r)&&this.#a.length===0&&!this.#i.compressed){g(this.ws,`Unexpected continuation frame`);return}c<=125?(this.#i.payloadLength=c,this.#r=i.READ_DATA):c===126?this.#r=i.PAYLOADLENGTH_16:c===127&&(this.#r=i.PAYLOADLENGTH_64),b(r)&&(this.#i.binaryType=r,this.#i.compressed=l!==0),this.#i.opcode=r,this.#i.masked=o,this.#i.fin=n,this.#i.fragmented=s}else if(this.#r===i.PAYLOADLENGTH_16){if(this.#t<2)return e();let t=this.consume(2);this.#i.payloadLength=t.readUInt16BE(0),this.#r=i.READ_DATA}else if(this.#r===i.PAYLOADLENGTH_64){if(this.#t<8)return e();let t=this.consume(8),n=t.readUInt32BE(0),r=t.readUInt32BE(4);if(n!==0||r>2**31-1){g(this.ws,`Received payload length > 2^31 bytes.`);return}this.#i.payloadLength=r,this.#r=i.READ_DATA}else if(this.#r===i.READ_DATA){if(this.#t{if(t){g(this.ws,t.message);return}if(this.#a.push(n),!this.#i.fin){this.#r=i.INFO,this.#n=!0,this.run(e);return}_(this.ws,this.#i.binaryType,Buffer.concat(this.#a)),this.#n=!0,this.#r=i.INFO,this.#a.length=0,this.run(e)}),this.#n=!1;break}else{if(this.#a.push(t),!this.#i.fragmented&&this.#i.fin){let e=Buffer.concat(this.#a);_(this.ws,this.#i.binaryType,e),this.#a.length=0}this.#r=i.INFO}}}consume(e){if(e>this.#t)throw Error(`Called consume() before buffers satiated.`);if(e===0)return s;if(this.#e[0].length===e)return this.#t-=this.#e[0].length,this.#e.shift();let t=Buffer.allocUnsafe(e),n=0;for(;n!==e;){let r=this.#e[0],{length:i}=r;if(i+n===e){t.set(this.#e.shift(),n);break}else if(i+n>e){t.set(r.subarray(0,e-n),n),this.#e[0]=r.subarray(e-n);break}else t.set(this.#e.shift(),n),n+=r.length}return this.#t-=e,t}parseCloseBody(e){r(e.length!==1);let t;if(e.length>=2&&(t=e.readUInt16BE(0)),t!==void 0&&!m(t))return{code:1002,reason:`Invalid status code`,error:!0};let n=e.subarray(2);n[0]===239&&n[1]===187&&n[2]===191&&(n=n.subarray(3));try{n=v(n)}catch{return{code:1007,reason:`Invalid UTF-8`,error:!0}}return{code:t,reason:n,error:!1}}parseControlFrame(e){let{opcode:t,payloadLength:n}=this.#i;if(t===a.CLOSE){if(n===1)return g(this.ws,`Received close frame with a 1-byte body.`),!1;if(this.#i.closeInfo=this.parseCloseBody(e),this.#i.closeInfo.error){let{code:e,reason:t}=this.#i.closeInfo;return C(this.ws,e,t,t.length),g(this.ws,t),!1}if(this.ws[u]!==c.SENT){let e=s;this.#i.closeInfo.code&&(e=Buffer.allocUnsafe(2),e.writeUInt16BE(this.#i.closeInfo.code,0));let t=new S(e);this.ws[d].socket.write(t.createFrame(a.CLOSE),e=>{e||(this.ws[u]=c.SENT)})}return this.ws[l]=o.CLOSING,this.ws[f]=!0,!1}else if(t===a.PING){if(!this.ws[f]){let t=new S(e);this.ws[d].socket.write(t.createFrame(a.PONG)),p.ping.hasSubscribers&&p.ping.publish({payload:e})}}else t===a.PONG&&p.pong.hasSubscribers&&p.pong.publish({payload:e});return!0}get closingInfo(){return this.#i.closeInfo}}}})),un=I(((e,t)=>{let{WebsocketFrameSend:n}=on(),{opcodes:r,sendHints:i}=nn(),a=rt(),o=Buffer[Symbol.species];var s=class{#e=new a;#t=!1;#n;constructor(e){this.#n=e}add(e,t,n){if(n!==i.blob){let r=c(e,n);if(!this.#t)this.#n.write(r,t);else{let e={promise:null,callback:t,frame:r};this.#e.push(e)}return}let r={promise:e.arrayBuffer().then(e=>{r.promise=null,r.frame=c(e,n)}),callback:t,frame:null};this.#e.push(r),this.#t||this.#r()}async#r(){this.#t=!0;let e=this.#e;for(;!e.isEmpty();){let t=e.shift();t.promise!==null&&await t.promise,this.#n.write(t.frame,t.callback),t.callback=t.frame=null}this.#t=!1}};function c(e,t){return new n(l(e,t)).createFrame(t===i.string?r.TEXT:r.BINARY)}function l(e,t){switch(t){case i.string:return Buffer.from(e);case i.arrayBuffer:case i.blob:return new o(e);case i.typedArray:return new o(e.buffer,e.byteOffset,e.byteLength)}}t.exports={SendQueue:s}})),dn=I(((e,t)=>{let{webidl:n}=Ge(),{URLSerializer:r}=We(),{environmentSettingsObject:i}=Ke(),{staticPropertyDescriptors:a,states:o,sentCloseFrameState:s,sendHints:c}=nn(),{kWebSocketURL:l,kReadyState:u,kController:d,kBinaryType:f,kResponse:p,kSentClose:m,kByteParser:h}=rn(),{isConnecting:g,isEstablished:_,isClosing:v,isValidSubprotocol:y,fireEvent:b}=an(),{establishWebSocketConnection:x,closeWebSocketConnection:S}=sn(),{ByteParser:C}=ln(),{kEnumerableProperty:w,isBlobLike:T}=z(),{getGlobalDispatcher:E}=jt(),{types:D}=L(`node:util`),{ErrorEvent:O,CloseEvent:k}=tn(),{SendQueue:A}=un();var j=class e extends EventTarget{#e={open:null,error:null,close:null,message:null};#t=0;#n=``;#r=``;#i;constructor(t,r=[]){super(),n.util.markAsUncloneable(this);let a=`WebSocket constructor`;n.argumentLengthCheck(arguments,1,a);let o=n.converters[`DOMString or sequence or WebSocketInit`](r,a,`options`);t=n.converters.USVString(t,a,`url`),r=o.protocols;let c=i.settingsObject.baseUrl,p;try{p=new URL(t,c)}catch(e){throw new DOMException(e,`SyntaxError`)}if(p.protocol===`http:`?p.protocol=`ws:`:p.protocol===`https:`&&(p.protocol=`wss:`),p.protocol!==`ws:`&&p.protocol!==`wss:`)throw new DOMException(`Expected a ws: or wss: protocol, got ${p.protocol}`,`SyntaxError`);if(p.hash||p.href.endsWith(`#`))throw new DOMException(`Got fragment`,`SyntaxError`);if(typeof r==`string`&&(r=[r]),r.length!==new Set(r.map(e=>e.toLowerCase())).size||r.length>0&&!r.every(e=>y(e)))throw new DOMException(`Invalid Sec-WebSocket-Protocol value`,`SyntaxError`);this[l]=new URL(p.href);let h=i.settingsObject;this[d]=x(p,r,h,this,(e,t)=>this.#a(e,t),o),this[u]=e.CONNECTING,this[m]=s.NOT_SENT,this[f]=`blob`}close(t=void 0,r=void 0){n.brandCheck(this,e);let i=`WebSocket.close`;if(t!==void 0&&(t=n.converters[`unsigned short`](t,i,`code`,{clamp:!0})),r!==void 0&&(r=n.converters.USVString(r,i,`reason`)),t!==void 0&&t!==1e3&&(t<3e3||t>4999))throw new DOMException(`invalid code`,`InvalidAccessError`);let a=0;if(r!==void 0&&(a=Buffer.byteLength(r),a>123))throw new DOMException(`Reason must be less than 123 bytes; received ${a}`,`SyntaxError`);S(this,t,r,a)}send(t){n.brandCheck(this,e);let r=`WebSocket.send`;if(n.argumentLengthCheck(arguments,1,r),t=n.converters.WebSocketSendData(t,r,`data`),g(this))throw new DOMException(`Sent before connected.`,`InvalidStateError`);if(!(!_(this)||v(this)))if(typeof t==`string`){let e=Buffer.byteLength(t);this.#t+=e,this.#i.add(t,()=>{this.#t-=e},c.string)}else D.isArrayBuffer(t)?(this.#t+=t.byteLength,this.#i.add(t,()=>{this.#t-=t.byteLength},c.arrayBuffer)):ArrayBuffer.isView(t)?(this.#t+=t.byteLength,this.#i.add(t,()=>{this.#t-=t.byteLength},c.typedArray)):T(t)&&(this.#t+=t.size,this.#i.add(t,()=>{this.#t-=t.size},c.blob))}get readyState(){return n.brandCheck(this,e),this[u]}get bufferedAmount(){return n.brandCheck(this,e),this.#t}get url(){return n.brandCheck(this,e),r(this[l])}get extensions(){return n.brandCheck(this,e),this.#r}get protocol(){return n.brandCheck(this,e),this.#n}get onopen(){return n.brandCheck(this,e),this.#e.open}set onopen(t){n.brandCheck(this,e),this.#e.open&&this.removeEventListener(`open`,this.#e.open),typeof t==`function`?(this.#e.open=t,this.addEventListener(`open`,t)):this.#e.open=null}get onerror(){return n.brandCheck(this,e),this.#e.error}set onerror(t){n.brandCheck(this,e),this.#e.error&&this.removeEventListener(`error`,this.#e.error),typeof t==`function`?(this.#e.error=t,this.addEventListener(`error`,t)):this.#e.error=null}get onclose(){return n.brandCheck(this,e),this.#e.close}set onclose(t){n.brandCheck(this,e),this.#e.close&&this.removeEventListener(`close`,this.#e.close),typeof t==`function`?(this.#e.close=t,this.addEventListener(`close`,t)):this.#e.close=null}get onmessage(){return n.brandCheck(this,e),this.#e.message}set onmessage(t){n.brandCheck(this,e),this.#e.message&&this.removeEventListener(`message`,this.#e.message),typeof t==`function`?(this.#e.message=t,this.addEventListener(`message`,t)):this.#e.message=null}get binaryType(){return n.brandCheck(this,e),this[f]}set binaryType(t){n.brandCheck(this,e),t!==`blob`&&t!==`arraybuffer`?this[f]=`blob`:this[f]=t}#a(e,t){this[p]=e;let n=new C(this,t);n.on(`drain`,M),n.on(`error`,N.bind(this)),e.socket.ws=this,this[h]=n,this.#i=new A(e.socket),this[u]=o.OPEN;let r=e.headersList.get(`sec-websocket-extensions`);r!==null&&(this.#r=r);let i=e.headersList.get(`sec-websocket-protocol`);i!==null&&(this.#n=i),b(`open`,this)}};j.CONNECTING=j.prototype.CONNECTING=o.CONNECTING,j.OPEN=j.prototype.OPEN=o.OPEN,j.CLOSING=j.prototype.CLOSING=o.CLOSING,j.CLOSED=j.prototype.CLOSED=o.CLOSED,Object.defineProperties(j.prototype,{CONNECTING:a,OPEN:a,CLOSING:a,CLOSED:a,url:w,readyState:w,bufferedAmount:w,onopen:w,onerror:w,onclose:w,close:w,onmessage:w,binaryType:w,send:w,extensions:w,protocol:w,[Symbol.toStringTag]:{value:`WebSocket`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(j,{CONNECTING:a,OPEN:a,CLOSING:a,CLOSED:a}),n.converters[`sequence`]=n.sequenceConverter(n.converters.DOMString),n.converters[`DOMString or sequence`]=function(e,t,r){return n.util.Type(e)===`Object`&&Symbol.iterator in e?n.converters[`sequence`](e):n.converters.DOMString(e,t,r)},n.converters.WebSocketInit=n.dictionaryConverter([{key:`protocols`,converter:n.converters[`DOMString or sequence`],defaultValue:()=>[]},{key:`dispatcher`,converter:n.converters.any,defaultValue:()=>E()},{key:`headers`,converter:n.nullableConverter(n.converters.HeadersInit)}]),n.converters[`DOMString or sequence or WebSocketInit`]=function(e){return n.util.Type(e)===`Object`&&!(Symbol.iterator in e)?n.converters.WebSocketInit(e):{protocols:n.converters[`DOMString or sequence`](e)}},n.converters.WebSocketSendData=function(e){if(n.util.Type(e)===`Object`){if(T(e))return n.converters.Blob(e,{strict:!1});if(ArrayBuffer.isView(e)||D.isArrayBuffer(e))return n.converters.BufferSource(e)}return n.converters.USVString(e)};function M(){this.ws[p].socket.resume()}function N(e){let t,n;e instanceof k?(t=e.reason,n=e.code):t=e.message,b(`error`,this,()=>new O(`error`,{error:e,message:t})),S(this,n)}t.exports={WebSocket:j}})),fn=I(((e,t)=>{function n(e){return e.indexOf(`\0`)===-1}function r(e){if(e.length===0)return!1;for(let t=0;t57)return!1;return!0}function i(e){return new Promise(t=>{setTimeout(t,e).unref()})}t.exports={isValidLastEventId:n,isASCIINumber:r,delay:i}})),pn=I(((e,t)=>{let{Transform:n}=L(`node:stream`),{isASCIINumber:r,isValidLastEventId:i}=fn(),a=[239,187,191];t.exports={EventSourceStream:class extends n{state=null;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(e={}){e.readableObjectMode=!0,super(e),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,t,n){if(e.length===0){n();return}if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:if(this.buffer[0]===a[0]){n();return}this.checkBOM=!1,n();return;case 2:if(this.buffer[0]===a[0]&&this.buffer[1]===a[1]){n();return}this.checkBOM=!1;break;case 3:if(this.buffer[0]===a[0]&&this.buffer[1]===a[1]&&this.buffer[2]===a[2]){this.buffer=Buffer.alloc(0),this.checkBOM=!1,n();return}this.checkBOM=!1;break;default:this.buffer[0]===a[0]&&this.buffer[1]===a[1]&&this.buffer[2]===a[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1;break}for(;this.pos0&&(t[a]=o);break}}processEvent(e){e.retry&&r(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),e.id&&i(e.id)&&(this.state.lastEventId=e.id),e.data!==void 0&&this.push({type:e.event||`message`,options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}}}})),mn=I(((e,t)=>{let{pipeline:n}=L(`node:stream`),{fetching:r}=Vt(),{makeRequest:i}=Bt(),{webidl:a}=Ge(),{EventSourceStream:o}=pn(),{parseMIMEType:s}=We(),{createFastMessageEvent:c}=tn(),{isNetworkError:l}=Rt(),{delay:u}=fn(),{kEnumerableProperty:d}=z(),{environmentSettingsObject:f}=Ke(),p=!1,m=3e3;var h=class e extends EventTarget{#e={open:null,error:null,message:null};#t=null;#n=!1;#r=0;#i=null;#a=null;#o;#s;constructor(e,t={}){super(),a.util.markAsUncloneable(this);let n=`EventSource constructor`;a.argumentLengthCheck(arguments,1,n),p||(p=!0,process.emitWarning(`EventSource is experimental, expect them to change at any time.`,{code:`UNDICI-ES`})),e=a.converters.USVString(e,n,`url`),t=a.converters.EventSourceInitDict(t,n,`eventSourceInitDict`),this.#o=t.dispatcher,this.#s={lastEventId:``,reconnectionTime:m};let r=f,o;try{o=new URL(e,r.settingsObject.baseUrl),this.#s.origin=o.origin}catch(e){throw new DOMException(e,`SyntaxError`)}this.#t=o.href;let s=`anonymous`;t.withCredentials&&(s=`use-credentials`,this.#n=!0);let c={redirect:`follow`,keepalive:!0,mode:`cors`,credentials:s===`anonymous`?`same-origin`:`omit`,referrer:`no-referrer`};c.client=f.settingsObject,c.headersList=[[`accept`,{name:`accept`,value:`text/event-stream`}]],c.cache=`no-store`,c.initiator=`other`,c.urlList=[new URL(this.#t)],this.#i=i(c),this.#c()}get readyState(){return this.#r}get url(){return this.#t}get withCredentials(){return this.#n}#c(){if(this.#r===2)return;this.#r=0;let e={request:this.#i,dispatcher:this.#o};e.processResponseEndOfBody=e=>{l(e)&&(this.dispatchEvent(new Event(`error`)),this.close()),this.#l()},e.processResponse=e=>{if(l(e))if(e.aborted){this.close(),this.dispatchEvent(new Event(`error`));return}else{this.#l();return}let t=e.headersList.get(`content-type`,!0),r=t===null?`failure`:s(t),i=r!==`failure`&&r.essence===`text/event-stream`;if(e.status!==200||i===!1){this.close(),this.dispatchEvent(new Event(`error`));return}this.#r=1,this.dispatchEvent(new Event(`open`)),this.#s.origin=e.urlList[e.urlList.length-1].origin;let a=new o({eventSourceSettings:this.#s,push:e=>{this.dispatchEvent(c(e.type,e.options))}});n(e.body.stream,a,e=>{e?.aborted===!1&&(this.close(),this.dispatchEvent(new Event(`error`)))})},this.#a=r(e)}async#l(){this.#r!==2&&(this.#r=0,this.dispatchEvent(new Event(`error`)),await u(this.#s.reconnectionTime),this.#r===0&&(this.#s.lastEventId.length&&this.#i.headersList.set(`last-event-id`,this.#s.lastEventId,!0),this.#c()))}close(){a.brandCheck(this,e),this.#r!==2&&(this.#r=2,this.#a.abort(),this.#i=null)}get onopen(){return this.#e.open}set onopen(e){this.#e.open&&this.removeEventListener(`open`,this.#e.open),typeof e==`function`?(this.#e.open=e,this.addEventListener(`open`,e)):this.#e.open=null}get onmessage(){return this.#e.message}set onmessage(e){this.#e.message&&this.removeEventListener(`message`,this.#e.message),typeof e==`function`?(this.#e.message=e,this.addEventListener(`message`,e)):this.#e.message=null}get onerror(){return this.#e.error}set onerror(e){this.#e.error&&this.removeEventListener(`error`,this.#e.error),typeof e==`function`?(this.#e.error=e,this.addEventListener(`error`,e)):this.#e.error=null}};let g={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:0,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:1,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:2,writable:!1}};Object.defineProperties(h,g),Object.defineProperties(h.prototype,g),Object.defineProperties(h.prototype,{close:d,onerror:d,onmessage:d,onopen:d,readyState:d,url:d,withCredentials:d}),a.converters.EventSourceInitDict=a.dictionaryConverter([{key:`withCredentials`,converter:a.converters.boolean,defaultValue:()=>!1},{key:`dispatcher`,converter:a.converters.any}]),t.exports={EventSource:h,defaultReconnectionTime:m}})),hn=I(((e,t)=>{let n=nt(),r=Pe(),i=ot(),a=st(),o=ct(),s=lt(),c=ut(),l=ft(),u=R(),d=z(),{InvalidArgumentError:f}=u,p=xt(),m=Le(),h=Et(),g=At(),_=Dt(),v=St(),y=dt(),{getGlobalDispatcher:b,setGlobalDispatcher:x}=jt(),S=Mt(),C=et(),w=tt();Object.assign(r.prototype,p),t.exports.Dispatcher=r,t.exports.Client=n,t.exports.Pool=i,t.exports.BalancedPool=a,t.exports.Agent=o,t.exports.ProxyAgent=s,t.exports.EnvHttpProxyAgent=c,t.exports.RetryAgent=l,t.exports.RetryHandler=y,t.exports.DecoratorHandler=S,t.exports.RedirectHandler=C,t.exports.createRedirectInterceptor=w,t.exports.interceptors={redirect:Nt(),retry:Pt(),dump:Ft(),dns:It()},t.exports.buildConnector=m,t.exports.errors=u,t.exports.util={parseHeaders:d.parseHeaders,headerNameToString:d.headerNameToString};function T(e){return(t,n,r)=>{if(typeof n==`function`&&(r=n,n=null),!t||typeof t!=`string`&&typeof t!=`object`&&!(t instanceof URL))throw new f(`invalid url`);if(n!=null&&typeof n!=`object`)throw new f(`invalid opts`);if(n&&n.path!=null){if(typeof n.path!=`string`)throw new f(`invalid opts.path`);let e=n.path;n.path.startsWith(`/`)||(e=`/${e}`),t=new URL(d.parseOrigin(t).origin+e)}else n||=typeof t==`object`?t:{},t=d.parseURL(t);let{agent:i,dispatcher:a=b()}=n;if(i)throw new f(`unsupported opts.agent. Did you mean opts.client?`);return e.call(a,{...n,origin:t.origin,path:t.search?`${t.pathname}${t.search}`:t.pathname,method:n.method||(n.body?`PUT`:`GET`)},r)}}t.exports.setGlobalDispatcher=x,t.exports.getGlobalDispatcher=b;let E=Vt().fetch;t.exports.fetch=async function(e,t=void 0){try{return await E(e,t)}catch(e){throw e&&typeof e==`object`&&Error.captureStackTrace(e),e}},t.exports.Headers=Lt().Headers,t.exports.Response=Rt().Response,t.exports.Request=Bt().Request,t.exports.FormData=Ye().FormData,t.exports.File=globalThis.File??L(`node:buffer`).File,t.exports.FileReader=Kt().FileReader;let{setGlobalOrigin:D,getGlobalOrigin:O}=Ue();t.exports.setGlobalOrigin=D,t.exports.getGlobalOrigin=O;let{CacheStorage:k}=Xt(),{kConstruct:A}=qt();t.exports.caches=new k(A);let{deleteCookie:j,getCookies:M,getSetCookies:N,setCookie:P}=en();t.exports.deleteCookie=j,t.exports.getCookies=M,t.exports.getSetCookies=N,t.exports.setCookie=P;let{parseMIMEType:ee,serializeAMimeType:te}=We();t.exports.parseMIMEType=ee,t.exports.serializeAMimeType=te;let{CloseEvent:ne,ErrorEvent:F,MessageEvent:re}=tn();t.exports.WebSocket=dn().WebSocket,t.exports.CloseEvent=ne,t.exports.ErrorEvent=F,t.exports.MessageEvent=re,t.exports.request=T(p.request),t.exports.stream=T(p.stream),t.exports.pipeline=T(p.pipeline),t.exports.connect=T(p.connect),t.exports.upgrade=T(p.upgrade),t.exports.MockClient=h,t.exports.MockPool=_,t.exports.MockAgent=g,t.exports.mockErrors=v;let{EventSource:ie}=mn();t.exports.EventSource=ie})),gn=me(Oe(),1),_n=hn(),vn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},yn;(function(e){e[e.OK=200]=`OK`,e[e.MultipleChoices=300]=`MultipleChoices`,e[e.MovedPermanently=301]=`MovedPermanently`,e[e.ResourceMoved=302]=`ResourceMoved`,e[e.SeeOther=303]=`SeeOther`,e[e.NotModified=304]=`NotModified`,e[e.UseProxy=305]=`UseProxy`,e[e.SwitchProxy=306]=`SwitchProxy`,e[e.TemporaryRedirect=307]=`TemporaryRedirect`,e[e.PermanentRedirect=308]=`PermanentRedirect`,e[e.BadRequest=400]=`BadRequest`,e[e.Unauthorized=401]=`Unauthorized`,e[e.PaymentRequired=402]=`PaymentRequired`,e[e.Forbidden=403]=`Forbidden`,e[e.NotFound=404]=`NotFound`,e[e.MethodNotAllowed=405]=`MethodNotAllowed`,e[e.NotAcceptable=406]=`NotAcceptable`,e[e.ProxyAuthenticationRequired=407]=`ProxyAuthenticationRequired`,e[e.RequestTimeout=408]=`RequestTimeout`,e[e.Conflict=409]=`Conflict`,e[e.Gone=410]=`Gone`,e[e.TooManyRequests=429]=`TooManyRequests`,e[e.InternalServerError=500]=`InternalServerError`,e[e.NotImplemented=501]=`NotImplemented`,e[e.BadGateway=502]=`BadGateway`,e[e.ServiceUnavailable=503]=`ServiceUnavailable`,e[e.GatewayTimeout=504]=`GatewayTimeout`})(yn||={});var bn;(function(e){e.Accept=`accept`,e.ContentType=`content-type`})(bn||={});var xn;(function(e){e.ApplicationJson=`application/json`})(xn||={});const Sn=[yn.MovedPermanently,yn.ResourceMoved,yn.SeeOther,yn.TemporaryRedirect,yn.PermanentRedirect],Cn=[yn.BadGateway,yn.ServiceUnavailable,yn.GatewayTimeout],wn=[`OPTIONS`,`GET`,`DELETE`,`HEAD`];var Tn=class e extends Error{constructor(t,n){super(t),this.name=`HttpClientError`,this.statusCode=n,Object.setPrototypeOf(this,e.prototype)}},En=class{constructor(e){this.message=e}readBody(){return vn(this,void 0,void 0,function*(){return new Promise(e=>vn(this,void 0,void 0,function*(){let t=Buffer.alloc(0);this.message.on(`data`,e=>{t=Buffer.concat([t,e])}),this.message.on(`end`,()=>{e(t.toString())})}))})}readBodyBuffer(){return vn(this,void 0,void 0,function*(){return new Promise(e=>vn(this,void 0,void 0,function*(){let t=[];this.message.on(`data`,e=>{t.push(e)}),this.message.on(`end`,()=>{e(Buffer.concat(t))})}))})}},Dn=class{constructor(e,t,n){this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=this._getUserAgentWithOrchestrationId(e),this.handlers=t||[],this.requestOptions=n,n&&(n.ignoreSslError!=null&&(this._ignoreSslError=n.ignoreSslError),this._socketTimeout=n.socketTimeout,n.allowRedirects!=null&&(this._allowRedirects=n.allowRedirects),n.allowRedirectDowngrade!=null&&(this._allowRedirectDowngrade=n.allowRedirectDowngrade),n.maxRedirects!=null&&(this._maxRedirects=Math.max(n.maxRedirects,0)),n.keepAlive!=null&&(this._keepAlive=n.keepAlive),n.allowRetries!=null&&(this._allowRetries=n.allowRetries),n.maxRetries!=null&&(this._maxRetries=n.maxRetries))}options(e,t){return vn(this,void 0,void 0,function*(){return this.request(`OPTIONS`,e,null,t||{})})}get(e,t){return vn(this,void 0,void 0,function*(){return this.request(`GET`,e,null,t||{})})}del(e,t){return vn(this,void 0,void 0,function*(){return this.request(`DELETE`,e,null,t||{})})}post(e,t,n){return vn(this,void 0,void 0,function*(){return this.request(`POST`,e,t,n||{})})}patch(e,t,n){return vn(this,void 0,void 0,function*(){return this.request(`PATCH`,e,t,n||{})})}put(e,t,n){return vn(this,void 0,void 0,function*(){return this.request(`PUT`,e,t,n||{})})}head(e,t){return vn(this,void 0,void 0,function*(){return this.request(`HEAD`,e,null,t||{})})}sendStream(e,t,n,r){return vn(this,void 0,void 0,function*(){return this.request(e,t,n,r)})}getJson(e){return vn(this,arguments,void 0,function*(e,t={}){t[bn.Accept]=this._getExistingOrDefaultHeader(t,bn.Accept,xn.ApplicationJson);let n=yield this.get(e,t);return this._processResponse(n,this.requestOptions)})}postJson(e,t){return vn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[bn.Accept]=this._getExistingOrDefaultHeader(n,bn.Accept,xn.ApplicationJson),n[bn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,xn.ApplicationJson);let i=yield this.post(e,r,n);return this._processResponse(i,this.requestOptions)})}putJson(e,t){return vn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[bn.Accept]=this._getExistingOrDefaultHeader(n,bn.Accept,xn.ApplicationJson),n[bn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,xn.ApplicationJson);let i=yield this.put(e,r,n);return this._processResponse(i,this.requestOptions)})}patchJson(e,t){return vn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[bn.Accept]=this._getExistingOrDefaultHeader(n,bn.Accept,xn.ApplicationJson),n[bn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,xn.ApplicationJson);let i=yield this.patch(e,r,n);return this._processResponse(i,this.requestOptions)})}request(e,t,n,r){return vn(this,void 0,void 0,function*(){if(this._disposed)throw Error(`Client has already been disposed.`);let i=new URL(t),a=this._prepareRequest(e,i,r),o=this._allowRetries&&wn.includes(e)?this._maxRetries+1:1,s=0,c;do{if(c=yield this.requestRaw(a,n),c&&c.message&&c.message.statusCode===yn.Unauthorized){let e;for(let t of this.handlers)if(t.canHandleAuthentication(c)){e=t;break}return e?e.handleAuthentication(this,a,n):c}let t=this._maxRedirects;for(;c.message.statusCode&&Sn.includes(c.message.statusCode)&&this._allowRedirects&&t>0;){let o=c.message.headers.location;if(!o)break;let s=new URL(o);if(i.protocol===`https:`&&i.protocol!==s.protocol&&!this._allowRedirectDowngrade)throw Error(`Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.`);if(yield c.readBody(),s.hostname!==i.hostname)for(let e in r)e.toLowerCase()===`authorization`&&delete r[e];a=this._prepareRequest(e,s,r),c=yield this.requestRaw(a,n),t--}if(!c.message.statusCode||!Cn.includes(c.message.statusCode))return c;s+=1,s{function i(e,t){e?r(e):t?n(t):r(Error(`Unknown error`))}this.requestRawWithCallback(e,t,i)})})}requestRawWithCallback(e,t,n){typeof t==`string`&&(e.options.headers||(e.options.headers={}),e.options.headers[`Content-Length`]=Buffer.byteLength(t,`utf8`));let r=!1;function i(e,t){r||(r=!0,n(e,t))}let a=e.httpModule.request(e.options,e=>{i(void 0,new En(e))}),o;a.on(`socket`,e=>{o=e}),a.setTimeout(this._socketTimeout||3*6e4,()=>{o&&o.end(),i(Error(`Request timeout: ${e.options.path}`))}),a.on(`error`,function(e){i(e)}),t&&typeof t==`string`&&a.write(t,`utf8`),t&&typeof t!=`string`?(t.on(`close`,function(){a.end()}),t.pipe(a)):a.end()}getAgent(e){let t=new URL(e);return this._getAgent(t)}getAgentDispatcher(e){let t=new URL(e),n=Ce(t);if(n&&n.hostname)return this._getProxyAgentDispatcher(t,n)}_prepareRequest(e,t,n){let r={};r.parsedUrl=t;let i=r.parsedUrl.protocol===`https:`;r.httpModule=i?p:f;let a=i?443:80;if(r.options={},r.options.host=r.parsedUrl.hostname,r.options.port=r.parsedUrl.port?parseInt(r.parsedUrl.port):a,r.options.path=(r.parsedUrl.pathname||``)+(r.parsedUrl.search||``),r.options.method=e,r.options.headers=this._mergeHeaders(n),this.userAgent!=null&&(r.options.headers[`user-agent`]=this.userAgent),r.options.agent=this._getAgent(r.parsedUrl),this.handlers)for(let e of this.handlers)e.prepareRequest(r.options);return r}_mergeHeaders(e){return this.requestOptions&&this.requestOptions.headers?Object.assign({},On(this.requestOptions.headers),On(e||{})):On(e||{})}_getExistingOrDefaultHeader(e,t,n){let r;if(this.requestOptions&&this.requestOptions.headers){let e=On(this.requestOptions.headers)[t];e&&(r=typeof e==`number`?e.toString():e)}let i=e[t];return i===void 0?r===void 0?n:r:typeof i==`number`?i.toString():i}_getExistingOrDefaultContentTypeHeader(e,t){let n;if(this.requestOptions&&this.requestOptions.headers){let e=On(this.requestOptions.headers)[bn.ContentType];e&&(n=typeof e==`number`?String(e):Array.isArray(e)?e.join(`, `):e)}let r=e[bn.ContentType];return r===void 0?n===void 0?t:n:typeof r==`number`?String(r):Array.isArray(r)?r.join(`, `):r}_getAgent(e){let t,n=Ce(e),r=n&&n.hostname;if(this._keepAlive&&r&&(t=this._proxyAgent),r||(t=this._agent),t)return t;let i=e.protocol===`https:`,a=100;if(this.requestOptions&&(a=this.requestOptions.maxSockets||f.globalAgent.maxSockets),n&&n.hostname){let e={maxSockets:a,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(n.username||n.password)&&{proxyAuth:`${n.username}:${n.password}`}),{host:n.hostname,port:n.port})},r,o=n.protocol===`https:`;r=i?o?gn.httpsOverHttps:gn.httpsOverHttp:o?gn.httpOverHttps:gn.httpOverHttp,t=r(e),this._proxyAgent=t}if(!t){let e={keepAlive:this._keepAlive,maxSockets:a};t=i?new p.Agent(e):new f.Agent(e),this._agent=t}return i&&this._ignoreSslError&&(t.options=Object.assign(t.options||{},{rejectUnauthorized:!1})),t}_getProxyAgentDispatcher(e,t){let n;if(this._keepAlive&&(n=this._proxyAgentDispatcher),n)return n;let r=e.protocol===`https:`;return n=new _n.ProxyAgent(Object.assign({uri:t.href,pipelining:this._keepAlive?1:0},(t.username||t.password)&&{token:`Basic ${Buffer.from(`${t.username}:${t.password}`).toString(`base64`)}`})),this._proxyAgentDispatcher=n,r&&this._ignoreSslError&&(n.options=Object.assign(n.options.requestTls||{},{rejectUnauthorized:!1})),n}_getUserAgentWithOrchestrationId(e){let t=e||`actions/http-client`,n=process.env.ACTIONS_ORCHESTRATION_ID;return n?`${t} actions_orchestration_id/${n.replace(/[^a-z0-9_.-]/gi,`_`)}`:t}_performExponentialBackoff(e){return vn(this,void 0,void 0,function*(){e=Math.min(10,e);let t=5*2**e;return new Promise(e=>setTimeout(()=>e(),t))})}_processResponse(e,t){return vn(this,void 0,void 0,function*(){return new Promise((n,r)=>vn(this,void 0,void 0,function*(){let i=e.message.statusCode||0,a={statusCode:i,result:null,headers:{}};i===yn.NotFound&&n(a);function o(e,t){if(typeof t==`string`){let e=new Date(t);if(!isNaN(e.valueOf()))return e}return t}let s,c;try{c=yield e.readBody(),c&&c.length>0&&(s=t&&t.deserializeDates?JSON.parse(c,o):JSON.parse(c),a.result=s),a.headers=e.message.headers}catch{}if(i>299){let e;e=s&&s.message?s.message:c&&c.length>0?c:`Failed request: (${i})`;let t=new Tn(e,i);t.result=a.result,r(t)}else n(a)}))})}};const On=e=>Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{});var kn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},An=class{constructor(e){this.token=e}prepareRequest(e){if(!e.headers)throw Error(`The request has no headers`);e.headers.Authorization=`Bearer ${this.token}`}canHandleAuthentication(){return!1}handleAuthentication(){return kn(this,void 0,void 0,function*(){throw Error(`not implemented`)})}},jn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const{access:Mn,appendFile:Nn,writeFile:Pn}=l,Fn=`GITHUB_STEP_SUMMARY`,In=new class{constructor(){this._buffer=``}filePath(){return jn(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;let e=process.env[Fn];if(!e)throw Error(`Unable to find environment variable for $${Fn}. Check if your runtime environment supports job summaries.`);try{yield Mn(e,s.R_OK|s.W_OK)}catch{throw Error(`Unable to access summary file: '${e}'. Check if the file has correct read/write permissions.`)}return this._filePath=e,this._filePath})}wrap(e,t,n={}){let r=Object.entries(n).map(([e,t])=>` ${e}="${t}"`).join(``);return t?`<${e}${r}>${t}`:`<${e}${r}>`}write(e){return jn(this,void 0,void 0,function*(){let t=!!e?.overwrite,n=yield this.filePath();return yield(t?Pn:Nn)(n,this._buffer,{encoding:`utf8`}),this.emptyBuffer()})}clear(){return jn(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer=``,this}addRaw(e,t=!1){return this._buffer+=e,t?this.addEOL():this}addEOL(){return this.addRaw(i)}addCodeBlock(e,t){let n=Object.assign({},t&&{lang:t}),r=this.wrap(`pre`,this.wrap(`code`,e),n);return this.addRaw(r).addEOL()}addList(e,t=!1){let n=t?`ol`:`ul`,r=e.map(e=>this.wrap(`li`,e)).join(``),i=this.wrap(n,r);return this.addRaw(i).addEOL()}addTable(e){let t=e.map(e=>{let t=e.map(e=>{if(typeof e==`string`)return this.wrap(`td`,e);let{header:t,data:n,colspan:r,rowspan:i}=e,a=t?`th`:`td`,o=Object.assign(Object.assign({},r&&{colspan:r}),i&&{rowspan:i});return this.wrap(a,n,o)}).join(``);return this.wrap(`tr`,t)}).join(``),n=this.wrap(`table`,t);return this.addRaw(n).addEOL()}addDetails(e,t){let n=this.wrap(`details`,this.wrap(`summary`,e)+t);return this.addRaw(n).addEOL()}addImage(e,t,n){let{width:r,height:i}=n||{},a=Object.assign(Object.assign({},r&&{width:r}),i&&{height:i}),o=this.wrap(`img`,null,Object.assign({src:e,alt:t},a));return this.addRaw(o).addEOL()}addHeading(e,t){let n=`h${t}`,r=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`].includes(n)?n:`h1`,i=this.wrap(r,e);return this.addRaw(i).addEOL()}addSeparator(){let e=this.wrap(`hr`,null);return this.addRaw(e).addEOL()}addBreak(){let e=this.wrap(`br`,null);return this.addRaw(e).addEOL()}addQuote(e,t){let n=Object.assign({},t&&{cite:t}),r=this.wrap(`blockquote`,e,n);return this.addRaw(r).addEOL()}addLink(e,t){let n=this.wrap(`a`,e,{href:t});return this.addRaw(n).addEOL()}};var Ln=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const{chmod:Rn,copyFile:zn,lstat:Bn,mkdir:Vn,open:Hn,readdir:Un,rename:Wn,rm:Gn,rmdir:Kn,stat:qn,symlink:Jn,unlink:Yn}=o.promises,Xn=process.platform===`win32`;function Zn(e){return Ln(this,void 0,void 0,function*(){let t=yield o.promises.readlink(e);return Xn&&!t.endsWith(`\\`)?`${t}\\`:t})}o.constants.O_RDONLY;function Qn(e){return Ln(this,void 0,void 0,function*(){try{yield qn(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}return!0})}function $n(e){if(e=tr(e),!e)throw Error(`isRooted() parameter "p" cannot be empty`);return Xn?e.startsWith(`\\`)||/^[A-Z]:/i.test(e):e.startsWith(`/`)}function er(e,t){return Ln(this,void 0,void 0,function*(){let n;try{n=yield qn(e)}catch(t){t.code!==`ENOENT`&&console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}if(n&&n.isFile()){if(Xn){let n=d.extname(e).toUpperCase();if(t.some(e=>e.toUpperCase()===n))return e}else if(nr(n))return e}let r=e;for(let i of t){e=r+i,n=void 0;try{n=yield qn(e)}catch(t){t.code!==`ENOENT`&&console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}if(n&&n.isFile()){if(Xn){try{let t=d.dirname(e),n=d.basename(e).toUpperCase();for(let r of yield Un(t))if(n===r.toUpperCase()){e=d.join(t,r);break}}catch(t){console.log(`Unexpected error attempting to determine the actual case of the file '${e}': ${t}`)}return e}else if(nr(n))return e}}return``})}function tr(e){return e||=``,Xn?(e=e.replace(/\//g,`\\`),e.replace(/\\\\+/g,`\\`)):e.replace(/\/\/+/g,`/`)}function nr(e){return(e.mode&1)>0||(e.mode&8)>0&&process.getgid!==void 0&&e.gid===process.getgid()||(e.mode&64)>0&&process.getuid!==void 0&&e.uid===process.getuid()}var rr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function ir(e,t){return rr(this,arguments,void 0,function*(e,t,n={}){let{force:r,recursive:i,copySourceDirectory:a}=lr(n),o=(yield Qn(t))?yield qn(t):null;if(o&&o.isFile()&&!r)return;let s=o&&o.isDirectory()&&a?d.join(t,d.basename(e)):t;if(!(yield Qn(e)))throw Error(`no such file or directory: ${e}`);if((yield qn(e)).isDirectory())if(i)yield ur(e,s,0,r);else throw Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`);else{if(d.relative(e,s)===``)throw Error(`'${s}' and '${e}' are the same file`);yield dr(e,s,r)}})}function ar(e){return rr(this,void 0,void 0,function*(){if(Xn&&/[*"<>|]/.test(e))throw Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');try{yield Gn(e,{force:!0,maxRetries:3,recursive:!0,retryDelay:300})}catch(e){throw Error(`File was unable to be removed ${e}`)}})}function or(e){return rr(this,void 0,void 0,function*(){_(e,`a path argument must be provided`),yield Vn(e,{recursive:!0})})}function sr(e,t){return rr(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'tool' is required`);if(t){let t=yield sr(e,!1);if(!t)throw Error(Xn?`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`:`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);return t}let n=yield cr(e);return n&&n.length>0?n[0]:``})}function cr(e){return rr(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'tool' is required`);let t=[];if(Xn&&process.env.PATHEXT)for(let e of process.env.PATHEXT.split(d.delimiter))e&&t.push(e);if($n(e)){let n=yield er(e,t);return n?[n]:[]}if(e.includes(d.sep))return[];let n=[];if(process.env.PATH)for(let e of process.env.PATH.split(d.delimiter))e&&n.push(e);let r=[];for(let i of n){let n=yield er(d.join(i,e),t);n&&r.push(n)}return r})}function lr(e){return{force:e.force==null?!0:e.force,recursive:!!e.recursive,copySourceDirectory:e.copySourceDirectory==null?!0:!!e.copySourceDirectory}}function ur(e,t,n,r){return rr(this,void 0,void 0,function*(){if(n>=255)return;n++,yield or(t);let i=yield Un(e);for(let a of i){let i=`${e}/${a}`,o=`${t}/${a}`;(yield Bn(i)).isDirectory()?yield ur(i,o,n,r):yield dr(i,o,r)}yield Rn(t,(yield qn(e)).mode)})}function dr(e,t,n){return rr(this,void 0,void 0,function*(){if((yield Bn(e)).isSymbolicLink()){try{yield Bn(t),yield Yn(t)}catch(e){e.code===`EPERM`&&(yield Rn(t,`0666`),yield Yn(t))}yield Jn(yield Zn(e),t,Xn?`junction`:null)}else (!(yield Qn(t))||n)&&(yield zn(e,t))})}var fr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const pr=process.platform===`win32`;var mr=class extends m.EventEmitter{constructor(e,t,n){if(super(),!e)throw Error(`Parameter 'toolPath' cannot be null or empty.`);this.toolPath=e,this.args=t||[],this.options=n||{}}_debug(e){this.options.listeners&&this.options.listeners.debug&&this.options.listeners.debug(e)}_getCommandString(e,t){let n=this._getSpawnFileName(),r=this._getSpawnArgs(e),i=t?``:`[command]`;if(pr)if(this._isCmdFile()){i+=n;for(let e of r)i+=` ${e}`}else if(e.windowsVerbatimArguments){i+=`"${n}"`;for(let e of r)i+=` ${e}`}else{i+=this._windowsQuoteCmdArg(n);for(let e of r)i+=` ${this._windowsQuoteCmdArg(e)}`}else{i+=n;for(let e of r)i+=` ${e}`}return i}_processLineBuffer(e,t,r){try{let i=t+e.toString(),a=i.indexOf(n.EOL);for(;a>-1;)r(i.substring(0,a)),i=i.substring(a+n.EOL.length),a=i.indexOf(n.EOL);return i}catch(e){return this._debug(`error processing line. Failed with error ${e}`),``}}_getSpawnFileName(){return pr&&this._isCmdFile()?process.env.COMSPEC||`cmd.exe`:this.toolPath}_getSpawnArgs(e){if(pr&&this._isCmdFile()){let t=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(let n of this.args)t+=` `,t+=e.windowsVerbatimArguments?n:this._windowsQuoteCmdArg(n);return t+=`"`,[t]}return this.args}_endsWith(e,t){return e.endsWith(t)}_isCmdFile(){let e=this.toolPath.toUpperCase();return this._endsWith(e,`.CMD`)||this._endsWith(e,`.BAT`)}_windowsQuoteCmdArg(e){if(!this._isCmdFile())return this._uvQuoteCmdArg(e);if(!e)return`""`;let t=[` `,` `,`&`,`(`,`)`,`[`,`]`,`{`,`}`,`^`,`=`,`;`,`!`,`'`,`+`,`,`,"`",`~`,`|`,`<`,`>`,`"`],n=!1;for(let r of e)if(t.some(e=>e===r)){n=!0;break}if(!n)return e;let r=`"`,i=!0;for(let t=e.length;t>0;t--)r+=e[t-1],i&&e[t-1]===`\\`?r+=`\\`:e[t-1]===`"`?(i=!0,r+=`"`):i=!1;return r+=`"`,r.split(``).reverse().join(``)}_uvQuoteCmdArg(e){if(!e)return`""`;if(!e.includes(` `)&&!e.includes(` `)&&!e.includes(`"`))return e;if(!e.includes(`"`)&&!e.includes(`\\`))return`"${e}"`;let t=`"`,n=!0;for(let r=e.length;r>0;r--)t+=e[r-1],n&&e[r-1]===`\\`?t+=`\\`:e[r-1]===`"`?(n=!0,t+=`\\`):n=!1;return t+=`"`,t.split(``).reverse().join(``)}_cloneExecOptions(e){e||={};let t={cwd:e.cwd||process.cwd(),env:e.env||process.env,silent:e.silent||!1,windowsVerbatimArguments:e.windowsVerbatimArguments||!1,failOnStdErr:e.failOnStdErr||!1,ignoreReturnCode:e.ignoreReturnCode||!1,delay:e.delay||1e4};return t.outStream=e.outStream||process.stdout,t.errStream=e.errStream||process.stderr,t}_getSpawnOptions(e,t){e||={};let n={};return n.cwd=e.cwd,n.env=e.env,n.windowsVerbatimArguments=e.windowsVerbatimArguments||this._isCmdFile(),e.windowsVerbatimArguments&&(n.argv0=`"${t}"`),n}exec(){return fr(this,void 0,void 0,function*(){return!$n(this.toolPath)&&(this.toolPath.includes(`/`)||pr&&this.toolPath.includes(`\\`))&&(this.toolPath=d.resolve(process.cwd(),this.options.cwd||process.cwd(),this.toolPath)),this.toolPath=yield sr(this.toolPath,!0),new Promise((e,t)=>fr(this,void 0,void 0,function*(){this._debug(`exec tool: ${this.toolPath}`),this._debug(`arguments:`);for(let e of this.args)this._debug(` ${e}`);let r=this._cloneExecOptions(this.options);!r.silent&&r.outStream&&r.outStream.write(this._getCommandString(r)+n.EOL);let i=new gr(r,this.toolPath);if(i.on(`debug`,e=>{this._debug(e)}),this.options.cwd&&!(yield Qn(this.options.cwd)))return t(Error(`The cwd: ${this.options.cwd} does not exist!`));let a=this._getSpawnFileName(),o=O.spawn(a,this._getSpawnArgs(r),this._getSpawnOptions(this.options,a)),s=``;o.stdout&&o.stdout.on(`data`,e=>{this.options.listeners&&this.options.listeners.stdout&&this.options.listeners.stdout(e),!r.silent&&r.outStream&&r.outStream.write(e),s=this._processLineBuffer(e,s,e=>{this.options.listeners&&this.options.listeners.stdline&&this.options.listeners.stdline(e)})});let c=``;if(o.stderr&&o.stderr.on(`data`,e=>{i.processStderr=!0,this.options.listeners&&this.options.listeners.stderr&&this.options.listeners.stderr(e),!r.silent&&r.errStream&&r.outStream&&(r.failOnStdErr?r.errStream:r.outStream).write(e),c=this._processLineBuffer(e,c,e=>{this.options.listeners&&this.options.listeners.errline&&this.options.listeners.errline(e)})}),o.on(`error`,e=>{i.processError=e.message,i.processExited=!0,i.processClosed=!0,i.CheckComplete()}),o.on(`exit`,e=>{i.processExitCode=e,i.processExited=!0,this._debug(`Exit code ${e} received from tool '${this.toolPath}'`),i.CheckComplete()}),o.on(`close`,e=>{i.processExitCode=e,i.processExited=!0,i.processClosed=!0,this._debug(`STDIO streams have closed for tool '${this.toolPath}'`),i.CheckComplete()}),i.on(`done`,(n,r)=>{s.length>0&&this.emit(`stdline`,s),c.length>0&&this.emit(`errline`,c),o.removeAllListeners(),n?t(n):e(r)}),this.options.input){if(!o.stdin)throw Error(`child process missing stdin`);o.stdin.end(this.options.input)}}))})}};function hr(e){let t=[],n=!1,r=!1,i=``;function a(e){r&&e!==`"`&&(i+=`\\`),i+=e,r=!1}for(let o=0;o0&&(t.push(i),i=``);continue}a(s)}return i.length>0&&t.push(i.trim()),t}var gr=class e extends m.EventEmitter{constructor(e,t){if(super(),this.processClosed=!1,this.processError=``,this.processExitCode=0,this.processExited=!1,this.processStderr=!1,this.delay=1e4,this.done=!1,this.timeout=null,!t)throw Error(`toolPath must not be empty`);this.options=e,this.toolPath=t,e.delay&&(this.delay=e.delay)}CheckComplete(){this.done||(this.processClosed?this._setResult():this.processExited&&(this.timeout=k(e.HandleTimeout,this.delay,this)))}_debug(e){this.emit(`debug`,e)}_setResult(){let e;this.processExited&&(this.processError?e=Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`):this.processExitCode!==0&&!this.options.ignoreReturnCode?e=Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`):this.processStderr&&this.options.failOnStdErr&&(e=Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`))),this.timeout&&=(clearTimeout(this.timeout),null),this.done=!0,this.emit(`done`,e,this.processExitCode)}static HandleTimeout(e){if(!e.done){if(!e.processClosed&&e.processExited){let t=`The STDIO streams did not close within ${e.delay/1e3} seconds of the exit event from process '${e.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;e._debug(t)}e._setResult()}}},_r=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function vr(e,t,n){return _r(this,void 0,void 0,function*(){let r=hr(e);if(r.length===0)throw Error(`Parameter 'commandLine' cannot be null or empty.`);let i=r[0];return t=r.slice(1).concat(t||[]),new mr(i,t,n).exec()})}function yr(e,t,n){return _r(this,void 0,void 0,function*(){let r=``,i=``,a=new D(`utf8`),o=new D(`utf8`),s=n?.listeners?.stdout,c=n?.listeners?.stderr,l=Object.assign(Object.assign({},n?.listeners),{stdout:e=>{r+=a.write(e),s&&s(e)},stderr:e=>{i+=o.write(e),c&&c(e)}}),u=yield vr(e,t,Object.assign(Object.assign({},n),{listeners:l}));return r+=a.end(),i+=o.end(),{exitCode:u,stdout:r,stderr:i}})}r.platform(),r.arch();var br;(function(e){e[e.Success=0]=`Success`,e[e.Failure=1]=`Failure`})(br||={});function xr(e,t){let n=he(t);if(process.env[e]=n,process.env.GITHUB_ENV)return xe(`ENV`,Se(e,t));_e(`set-env`,{name:e},n)}function Sr(e){_e(`add-mask`,{},e)}function Cr(e){process.env.GITHUB_PATH?xe(`PATH`,e):_e(`add-path`,{},e),process.env.PATH=`${e}${d.delimiter}${process.env.PATH}`}function wr(e,t){let n=process.env[`INPUT_${e.replace(/ /g,`_`).toUpperCase()}`]||``;if(t&&t.required&&!n)throw Error(`Input required and not supplied: ${e}`);return t&&t.trimWhitespace===!1?n:n.trim()}function Tr(e,t){if(process.env.GITHUB_OUTPUT)return xe(`OUTPUT`,Se(e,t));process.stdout.write(n.EOL),_e(`set-output`,{name:e},he(t))}function Er(e){process.exitCode=br.Failure,Or(e)}function Dr(){return process.env.RUNNER_DEBUG===`1`}function B(e){_e(`debug`,{},e)}function Or(e,t={}){_e(`error`,ge(t),e instanceof Error?e.toString():e)}function kr(e,t={}){_e(`warning`,ge(t),e instanceof Error?e.toString():e)}function Ar(e){process.stdout.write(e+n.EOL)}function jr(e,t){if(process.env.GITHUB_STATE)return xe(`STATE`,Se(e,t));_e(`save-state`,{name:e},he(t))}function Mr(e){return process.env[`STATE_${e}`]||``}function Nr(e){return e instanceof Error?e.message:String(e)}const Pr=[`token`,`password`,`secret`,`key`,`auth`,`credential`,`bearer`,`apikey`,`api_key`,`access_token`,`refresh_token`,`private`];function Fr(e,t){let n=e.toLowerCase();return t.some(e=>n.includes(e.toLowerCase()))}function Ir(e,t=Pr){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>Ir(e,t));let n={};for(let[r,i]of Object.entries(e))Fr(r,t)&&typeof i==`string`?n[r]=`[REDACTED]`:typeof i==`object`&&i?n[r]=Ir(i,t):n[r]=i;return n}function Lr(e,t,n,r){let i=Ir({...n,...r}),a={timestamp:new Date().toISOString(),level:e,message:t,...i};if(r!=null&&`error`in r&&r.error instanceof Error){let e=r.error;a.error={message:e.message,name:e.name,stack:e.stack}}return JSON.stringify(a)}function Rr(e){return{debug:(t,n)=>{B(Lr(`debug`,t,e,n))},info:(t,n)=>{Ar(Lr(`info`,t,e,n))},warning:(t,n)=>{kr(Lr(`warning`,t,e,n))},error:(t,n)=>{Or(Lr(`error`,t,e,n))}}}const zr={SHOULD_SAVE_CACHE:`shouldSaveCache`,SESSION_ID:`sessionId`,CACHE_SAVED:`cacheSaved`,OPENCODE_VERSION:`opencodeVersion`},Br=`sisyphus`,Vr=18e5,Hr={providerID:`opencode`,modelID:`big-pickle`},Ur=`1.3.3`,Wr=`1.3.11`,Gr=`3.14.0`,Kr=`opencode-storage`,qr=`opencode-tools`,Jr=6e5,Yr=`fro-bot-dedup-v1`;function Xr(){let e=t.env.XDG_DATA_HOME;return e!=null&&e.trim().length>0?e:j.join(M.homedir(),`.local`,`share`)}function Zr(){return j.join(Xr(),`opencode`,`storage`)}function Qr(){return j.join(Xr(),`opencode`,`auth.json`)}function $r(){return j.join(Xr(),`opencode`,`log`)}function ei(){let e=t.env.OPENCODE_PROMPT_ARTIFACT;return e===`true`||e===`1`}function ti(){let e=t.env.RUNNER_OS;if(e!=null&&e.trim().length>0)return e;switch(M.platform()){case`darwin`:return`macOS`;case`win32`:return`Windows`;case`aix`:case`android`:case`freebsd`:case`haiku`:case`linux`:case`openbsd`:case`sunos`:case`cygwin`:case`netbsd`:return`Linux`}}function ni(){let e=t.env.GITHUB_REPOSITORY;return e!=null&&e.trim().length>0?e:`unknown/unknown`}function ri(){let e=t.env.GITHUB_REF_NAME;return e!=null&&e.trim().length>0?e:`main`}function ii(){let e=t.env.GITHUB_RUN_ID;return e!=null&&e.trim().length>0?Number(e):0}function ai(){let e=t.env.GITHUB_WORKSPACE;return e!=null&&e.trim().length>0?e:t.cwd()}var oi=I(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),si=I(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),ci=I(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=oi(),a=si();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),li=I(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),ui=I(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:er(t,e)}})),di=I(((e,t)=>{let n=si(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=oi(),{safeRe:a,t:o}=ci(),s=li(),{compareIdentifiers:c}=ui();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&tt.major?1:this.minort.minor?1:this.patcht.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=Number(n)?1:0;if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),fi=I(((e,t)=>{let n=di();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),pi=I(((e,t)=>{let n=fi();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),mi=I(((e,t)=>{let n=fi();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),hi=I(((e,t)=>{let n=di();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),gi=I(((e,t)=>{let n=fi();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),_i=I(((e,t)=>{let n=di();t.exports=(e,t)=>new n(e,t).major})),vi=I(((e,t)=>{let n=di();t.exports=(e,t)=>new n(e,t).minor})),yi=I(((e,t)=>{let n=di();t.exports=(e,t)=>new n(e,t).patch})),bi=I(((e,t)=>{let n=fi();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),xi=I(((e,t)=>{let n=di();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Si=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(t,e,r)})),Ci=I(((e,t)=>{let n=xi();t.exports=(e,t)=>n(e,t,!0)})),wi=I(((e,t)=>{let n=di();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),Ti=I(((e,t)=>{let n=wi();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),Ei=I(((e,t)=>{let n=wi();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),Di=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)>0})),Oi=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)<0})),ki=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)===0})),Ai=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)!==0})),ji=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)>=0})),Mi=I(((e,t)=>{let n=xi();t.exports=(e,t,r)=>n(e,t,r)<=0})),Ni=I(((e,t)=>{let n=ki(),r=Ai(),i=Di(),a=ji(),o=Oi(),s=Mi();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),Pi=I(((e,t)=>{let n=di(),r=fi(),{safeRe:i,t:a}=ci();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),Fi=I(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),Ii=I(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,O(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>D(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let b=[..._.values()];return r.set(t,b),b}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;te.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=S(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=w(e,t),o(`xrange`,e),e=E(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},S=(e,t)=>e.trim().split(/\s+/).map(e=>C(e,t)).join(` `),C=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},w=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>T(e,t)).join(` `)),T=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},E=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),D=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),O=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),k=(e,t,n)=>{for(let n=0;n0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),Li=I(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=li(),{safeRe:i,t:a}=ci(),o=Ni(),s=si(),c=di(),l=Ii()})),Ri=I(((e,t)=>{let n=Ii();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),zi=I(((e,t)=>{let n=Ii();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),Bi=I(((e,t)=>{let n=di(),r=Ii();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),Vi=I(((e,t)=>{let n=di(),r=Ii();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),Hi=I(((e,t)=>{let n=di(),r=Ii(),i=Di();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),Ui=I(((e,t)=>{let n=Ii();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),Wi=I(((e,t)=>{let n=di(),r=Li(),{ANY:i}=r,a=Ii(),o=Ri(),s=Di(),c=Oi(),l=Mi(),u=ji();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),Gi=I(((e,t)=>{let n=Wi();t.exports=(e,t,r)=>n(e,t,`>`,r)})),Ki=I(((e,t)=>{let n=Wi();t.exports=(e,t,r)=>n(e,t,`<`,r)})),qi=I(((e,t)=>{let n=Ii();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),Ji=I(((e,t)=>{let n=Ri(),r=xi();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length{let n=Ii(),r=Li(),{ANY:i}=r,a=Ri(),o=xi(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),Xi=I(((e,t)=>{let n=ci(),r=oi(),i=di(),a=ui();t.exports={parse:fi(),valid:pi(),clean:mi(),inc:hi(),diff:gi(),major:_i(),minor:vi(),patch:yi(),prerelease:bi(),compare:xi(),rcompare:Si(),compareLoose:Ci(),compareBuild:wi(),sort:Ti(),rsort:Ei(),gt:Di(),lt:Oi(),eq:ki(),neq:Ai(),gte:ji(),lte:Mi(),cmp:Ni(),coerce:Pi(),Comparator:Li(),Range:Ii(),satisfies:Ri(),toComparators:zi(),maxSatisfying:Bi(),minSatisfying:Vi(),minVersion:Hi(),validRange:Ui(),outside:Wi(),gtr:Gi(),ltr:Ki(),intersects:qi(),simplifyRange:Ji(),subset:Yi(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}}));function Zi(e){let t={followSymbolicLinks:!0,implicitDescendants:!0,matchDirectories:!0,omitBrokenSymbolicLinks:!0,excludeHiddenFiles:!1};return e&&(typeof e.followSymbolicLinks==`boolean`&&(t.followSymbolicLinks=e.followSymbolicLinks,B(`followSymbolicLinks '${t.followSymbolicLinks}'`)),typeof e.implicitDescendants==`boolean`&&(t.implicitDescendants=e.implicitDescendants,B(`implicitDescendants '${t.implicitDescendants}'`)),typeof e.matchDirectories==`boolean`&&(t.matchDirectories=e.matchDirectories,B(`matchDirectories '${t.matchDirectories}'`)),typeof e.omitBrokenSymbolicLinks==`boolean`&&(t.omitBrokenSymbolicLinks=e.omitBrokenSymbolicLinks,B(`omitBrokenSymbolicLinks '${t.omitBrokenSymbolicLinks}'`)),typeof e.excludeHiddenFiles==`boolean`&&(t.excludeHiddenFiles=e.excludeHiddenFiles,B(`excludeHiddenFiles '${t.excludeHiddenFiles}'`))),t}const Qi=process.platform===`win32`;function $i(e){if(e=ia(e),Qi&&/^\\\\[^\\]+(\\[^\\]+)?$/.test(e))return e;let t=d.dirname(e);return Qi&&/^\\\\[^\\]+\\[^\\]+\\$/.test(t)&&(t=ia(t)),t}function ea(e,t){if(g(e,`ensureAbsoluteRoot parameter 'root' must not be empty`),g(t,`ensureAbsoluteRoot parameter 'itemPath' must not be empty`),ta(t))return t;if(Qi){if(t.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)){let e=process.cwd();return g(e.match(/^[A-Z]:\\/i),`Expected current directory to start with an absolute drive root. Actual '${e}'`),t[0].toUpperCase()===e[0].toUpperCase()?t.length===2?`${t[0]}:\\${e.substr(3)}`:(e.endsWith(`\\`)||(e+=`\\`),`${t[0]}:\\${e.substr(3)}${t.substr(2)}`):`${t[0]}:\\${t.substr(2)}`}else if(ra(t).match(/^\\$|^\\[^\\]/)){let e=process.cwd();return g(e.match(/^[A-Z]:\\/i),`Expected current directory to start with an absolute drive root. Actual '${e}'`),`${e[0]}:\\${t.substr(1)}`}}return g(ta(e),`ensureAbsoluteRoot parameter 'root' must have an absolute root`),e.endsWith(`/`)||Qi&&e.endsWith(`\\`)||(e+=d.sep),e+t}function ta(e){return g(e,`hasAbsoluteRoot parameter 'itemPath' must not be empty`),e=ra(e),Qi?e.startsWith(`\\\\`)||/^[A-Z]:\\/i.test(e):e.startsWith(`/`)}function na(e){return g(e,`isRooted parameter 'itemPath' must not be empty`),e=ra(e),Qi?e.startsWith(`\\`)||/^[A-Z]:/i.test(e):e.startsWith(`/`)}function ra(e){return e||=``,Qi?(e=e.replace(/\//g,`\\`),(/^\\\\+[^\\]/.test(e)?`\\`:``)+e.replace(/\\\\+/g,`\\`)):e.replace(/\/\/+/g,`/`)}function ia(e){return e?(e=ra(e),!e.endsWith(d.sep)||e===d.sep||Qi&&/^[A-Z]:\\$/i.test(e)?e:e.substr(0,e.length-1)):``}var aa;(function(e){e[e.None=0]=`None`,e[e.Directory=1]=`Directory`,e[e.File=2]=`File`,e[e.All=3]=`All`})(aa||={});const oa=process.platform===`win32`;function sa(e){e=e.filter(e=>!e.negate);let t={};for(let n of e){let e=oa?n.searchPath.toUpperCase():n.searchPath;t[e]=`candidate`}let n=[];for(let r of e){let e=oa?r.searchPath.toUpperCase():r.searchPath;if(t[e]===`included`)continue;let i=!1,a=e,o=$i(a);for(;o!==a;){if(t[o]){i=!0;break}a=o,o=$i(a)}i||(n.push(r.searchPath),t[e]=`included`)}return n}function ca(e,t){let n=aa.None;for(let r of e)r.negate?n&=~r.match(t):n|=r.match(t);return n}function la(e,t){return e.some(e=>!e.negate&&e.partialMatch(t))}var ua=I(((e,t)=>{t.exports=function(e,t){for(var r=[],i=0;i{t.exports=n;function n(e,t,n){e instanceof RegExp&&(e=r(e,n)),t instanceof RegExp&&(t=r(t,n));var a=i(e,t,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+e.length,a[1]),post:n.slice(a[1]+t.length)}}function r(e,t){var n=t.match(e);return n?n[0]:null}n.range=i;function i(e,t,n){var r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;)u==c?(r.push(u),c=n.indexOf(e,u+1)):r.length==1?s=[r.pop(),l]:(i=r.pop(),i=0?c:l;r.length&&(s=[a,o])}return s}})),fa=I(((e,t)=>{var n=ua(),r=da();t.exports=p;var i=`\0SLASH`+Math.random()+`\0`,a=`\0OPEN`+Math.random()+`\0`,o=`\0CLOSE`+Math.random()+`\0`,s=`\0COMMA`+Math.random()+`\0`,c=`\0PERIOD`+Math.random()+`\0`;function l(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function u(e){return e.split(`\\\\`).join(i).split(`\\{`).join(a).split(`\\}`).join(o).split(`\\,`).join(s).split(`\\.`).join(c)}function d(e){return e.split(i).join(`\\`).split(a).join(`{`).split(o).join(`}`).split(s).join(`,`).split(c).join(`.`)}function f(e){if(!e)return[``];var t=[],n=r(`{`,`}`,e);if(!n)return e.split(`,`);var i=n.pre,a=n.body,o=n.post,s=i.split(`,`);s[s.length-1]+=`{`+a+`}`;var c=f(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),t.push.apply(t,s),t}function p(e){return e?(e.substr(0,2)===`{}`&&(e=`\\{\\}`+e.substr(2)),v(u(e),!0).map(d)):[]}function m(e){return`{`+e+`}`}function h(e){return/^-?0\d/.test(e)}function g(e,t){return e<=t}function _(e,t){return e>=t}function v(e,t){var i=[],a=r(`{`,`}`,e);if(!a||/\$$/.test(a.pre))return[e];var s=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),u=s||c,d=a.body.indexOf(`,`)>=0;if(!u&&!d)return a.post.match(/,(?!,).*\}/)?(e=a.pre+`{`+a.body+o+a.post,v(e)):[e];var p;if(u)p=a.body.split(/\.\./);else if(p=f(a.body),p.length===1&&(p=v(p[0],!1).map(m),p.length===1)){var y=a.post.length?v(a.post,!1):[``];return y.map(function(e){return a.pre+p[0]+e})}var b=a.pre,y=a.post.length?v(a.post,!1):[``],x;if(u){var S=l(p[0]),C=l(p[1]),w=Math.max(p[0].length,p[1].length),T=p.length==3?Math.abs(l(p[2])):1,E=g;C0){var j=Array(A+1).join(`0`);k=O<0?`-`+j+k.slice(1):j+k}}x.push(k)}}else x=n(p,function(e){return v(e,!1)});for(var M=0;M{t.exports=h,h.Minimatch=g;var n=function(){try{return L(`path`)}catch{}}()||{sep:`/`};h.sep=n.sep;var r=h.GLOBSTAR=g.GLOBSTAR={},i=fa(),a={"!":{open:`(?:(?!(?:`,close:`))[^/]*?)`},"?":{open:`(?:`,close:`)?`},"+":{open:`(?:`,close:`)+`},"*":{open:`(?:`,close:`)*`},"@":{open:`(?:`,close:`)`}},o=`[^/]`,s=o+`*?`,c=`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`,l=`(?:(?!(?:\\/|^)\\.).)*?`,u=d(`().*{}+?[]^$\\!`);function d(e){return e.split(``).reduce(function(e,t){return e[t]=!0,e},{})}var f=/\/+/;h.filter=p;function p(e,t){return t||={},function(n,r,i){return h(n,e,t)}}function m(e,t){t||={};var n={};return Object.keys(e).forEach(function(t){n[t]=e[t]}),Object.keys(t).forEach(function(e){n[e]=t[e]}),n}h.defaults=function(e){if(!e||typeof e!=`object`||!Object.keys(e).length)return h;var t=h,n=function(n,r,i){return t(n,r,m(e,i))};return n.Minimatch=function(n,r){return new t.Minimatch(n,m(e,r))},n.Minimatch.defaults=function(n){return t.defaults(m(e,n)).Minimatch},n.filter=function(n,r){return t.filter(n,m(e,r))},n.defaults=function(n){return t.defaults(m(e,n))},n.makeRe=function(n,r){return t.makeRe(n,m(e,r))},n.braceExpand=function(n,r){return t.braceExpand(n,m(e,r))},n.match=function(n,r,i){return t.match(n,r,m(e,i))},n},g.defaults=function(e){return h.defaults(e).Minimatch};function h(e,t,n){return x(t),n||={},!n.nocomment&&t.charAt(0)===`#`?!1:new g(t,n).match(e)}function g(e,t){if(!(this instanceof g))return new g(e,t);x(e),t||={},e=e.trim(),!t.allowWindowsEscape&&n.sep!==`/`&&(e=e.split(n.sep).join(`/`)),this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion===void 0?200:t.maxGlobstarRecursion,this.set=[],this.pattern=e,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.make()}g.prototype.debug=function(){},g.prototype.make=_;function _(){var e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate();var n=this.globSet=this.braceExpand();t.debug&&(this.debug=function(){console.error.apply(console,arguments)}),this.debug(this.pattern,n),n=this.globParts=n.map(function(e){return e.split(f)}),this.debug(this.pattern,n),n=n.map(function(e,t,n){return e.map(this.parse,this)},this),this.debug(this.pattern,n),n=n.filter(function(e){return e.indexOf(!1)===-1}),this.debug(this.pattern,n),this.set=n}g.prototype.parseNegate=v;function v(){var e=this.pattern,t=!1,n=this.options,r=0;if(!n.nonegate){for(var i=0,a=e.length;ib)throw TypeError(`pattern is too long`)};g.prototype.parse=C;var S={};function C(e,t){x(e);var n=this.options;if(e===`**`)if(n.noglobstar)e=`*`;else return r;if(e===``)return``;var i=``,c=!!n.nocase,l=!1,d=[],f=[],p,m=!1,h=-1,g=-1,_=e.charAt(0)===`.`?``:n.dot?`(?!(?:^|\\/)\\.{1,2}(?:$|\\/))`:`(?!\\.)`,v=this;function y(){if(p){switch(p){case`*`:i+=s,c=!0;break;case`?`:i+=o,c=!0;break;default:i+=`\\`+p;break}v.debug(`clearStateChar %j %j`,p,i),p=!1}}for(var b=0,C=e.length,w;b-1;M--){var N=f[M],P=i.slice(0,N.reStart),ee=i.slice(N.reStart,N.reEnd-8),te=i.slice(N.reEnd-8,N.reEnd),ne=i.slice(N.reEnd);te+=ne;var F=P.split(`(`).length-1,re=ne;for(b=0;b=0&&(a=e[o],!a);o--);for(o=0;o=0;o--)if(t[o]===r){c=o;break}var l=t.slice(a,s),u=n?t.slice(s+1):t.slice(s+1,c),d=n?[]:t.slice(c+1);if(l.length){var f=e.slice(i,i+l.length);if(!this._matchOne(f,l,n,0,0))return!1;i+=l.length}var p=0;if(d.length){if(d.length+i>e.length)return!1;var m=e.length-d.length;if(this._matchOne(e,d,n,m,0))p=d.length;else{if(e[e.length-1]!==``||i+d.length===e.length||(m--,!this._matchOne(e,d,n,m,0)))return!1;p=d.length+1}}if(!u.length){var h=!!p;for(o=i;o0,`Parameter 'itemPath' must not be an empty array`);for(let t=0;te.getLiteral(t)).filter(e=>!o&&!(o=e===``));this.searchPath=new ha(s).toString(),this.rootRegExp=new RegExp(e.regExpEscape(s[0]),_a?`i`:``),this.isImplicitPattern=n;let c={dot:!0,nobrace:!0,nocase:_a,nocomment:!0,noext:!0,nonegate:!0};a=_a?a.replace(/\\/g,`/`):a,this.minimatch=new ga(a,c)}match(e){return this.segments[this.segments.length-1]===`**`?(e=ra(e),!e.endsWith(d.sep)&&this.isImplicitPattern===!1&&(e=`${e}${d.sep}`)):e=ia(e),this.minimatch.match(e)?this.trailingSeparator?aa.Directory:aa.All:aa.None}partialMatch(e){return e=ia(e),$i(e)===e?this.rootRegExp.test(e):this.minimatch.matchOne(e.split(_a?/\\+/:/\/+/),this.minimatch.set[0],!0)}static globEscape(e){return(_a?e:e.replace(/\\/g,`\\\\`)).replace(/(\[)(?=[^/]+\])/g,`[[]`).replace(/\?/g,`[?]`).replace(/\*/g,`[*]`)}static fixupPattern(t,r){g(t,`pattern cannot be empty`);let i=new ha(t).segments.map(t=>e.getLiteral(t));if(g(i.every((e,t)=>(e!==`.`||t===0)&&e!==`..`),`Invalid pattern '${t}'. Relative pathing '.' and '..' is not allowed.`),g(!na(t)||i[0],`Invalid pattern '${t}'. Root segment must not contain globs.`),t=ra(t),t===`.`||t.startsWith(`.${d.sep}`))t=e.globEscape(process.cwd())+t.substr(1);else if(t===`~`||t.startsWith(`~${d.sep}`))r||=n.homedir(),g(r,`Unable to determine HOME directory`),g(ta(r),`Expected HOME directory to be a rooted path. Actual '${r}'`),t=e.globEscape(r)+t.substr(1);else if(_a&&(t.match(/^[A-Z]:$/i)||t.match(/^[A-Z]:[^\\]/i))){let n=ea(`C:\\dummy-root`,t.substr(0,2));t.length>2&&!n.endsWith(`\\`)&&(n+=`\\`),t=e.globEscape(n)+t.substr(2)}else if(_a&&(t===`\\`||t.match(/^\\[^\\]/))){let n=ea(`C:\\dummy-root`,`\\`);n.endsWith(`\\`)||(n+=`\\`),t=e.globEscape(n)+t.substr(1)}else t=ea(e.globEscape(process.cwd()),t);return ra(t)}static getLiteral(e){let t=``;for(let n=0;n=0){if(r.length>1)return``;if(r){t+=r,n=i;continue}}}t+=r}return t}static regExpEscape(e){return e.replace(/[[\\^$.|?*+()]/g,`\\$&`)}},ya=class{constructor(e,t){this.path=e,this.level=t}},ba=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},xa=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},Sa=function(e){return this instanceof Sa?(this.v=e,this):new Sa(e)},Ca=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof Sa?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};const wa=process.platform===`win32`;var Ta=class e{constructor(e){this.patterns=[],this.searchPaths=[],this.options=Zi(e)}getSearchPaths(){return this.searchPaths.slice()}glob(){return ba(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,o=xa(this.globGenerator()),s;s=yield o.next(),e=s.done,!e;a=!0){r=s.value,a=!1;let e=r;i.push(e)}}catch(e){t={error:e}}finally{try{!a&&!e&&(n=o.return)&&(yield n.call(o))}finally{if(t)throw t.error}}return i})}globGenerator(){return Ca(this,arguments,function*(){let t=Zi(this.options),n=[];for(let e of this.patterns)n.push(e),t.implicitDescendants&&(e.trailingSeparator||e.segments[e.segments.length-1]!==`**`)&&n.push(new va(e.negate,!0,e.segments.concat(`**`)));let r=[];for(let e of sa(n)){B(`Search path '${e}'`);try{yield Sa(o.promises.lstat(e))}catch(e){if(e.code===`ENOENT`)continue;throw e}r.unshift(new ya(e,1))}let i=[];for(;r.length;){let a=r.pop(),s=ca(n,a.path),c=!!s||la(n,a.path);if(!s&&!c)continue;let l=yield Sa(e.stat(a,t,i));if(l&&!(t.excludeHiddenFiles&&d.basename(a.path).match(/^\./)))if(l.isDirectory()){if(s&aa.Directory&&t.matchDirectories)yield yield Sa(a.path);else if(!c)continue;let e=a.level+1,n=(yield Sa(o.promises.readdir(a.path))).map(t=>new ya(d.join(a.path,t),e));r.push(...n.reverse())}else s&aa.File&&(yield yield Sa(a.path))}})}static create(t,n){return ba(this,void 0,void 0,function*(){let r=new e(n);wa&&(t=t.replace(/\r\n/g,` `),t=t.replace(/\r/g,` `));let i=t.split(` @@ -34,7 +34,7 @@ ${e.format(t)} \r `,`utf-8`)],i=cc(r);i&&e.headers.set(`Content-Length`,i),e.body=await ic(r)}const uc=`multipartPolicy`,dc=new Set(`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'()+,-./:=?`);function fc(e){if(e.length>70)throw Error(`Multipart boundary "${e}" exceeds maximum length of 70 characters`);if(Array.from(e).some(e=>!dc.has(e)))throw Error(`Multipart boundary "${e}" contains invalid characters`)}function pc(){return{name:uc,async sendRequest(e,t){if(!e.multipartBody)return t(e);if(e.body)throw Error(`multipartBody and regular body cannot be set at the same time`);let n=e.multipartBody.boundary,r=e.headers.get(`Content-Type`)??`multipart/mixed`,i=r.match(/^(multipart\/[^ ;]+)(?:; *boundary=(.+))?$/);if(!i)throw Error(`Got multipart request body, but content-type header was not multipart: ${r}`);let[,a,o]=i;if(o&&n&&o!==n)throw Error(`Multipart boundary was specified as ${o} in the header, but got ${n} in the request body`);return n??=o,n?fc(n):n=ac(),e.headers.set(`Content-Type`,`${a}; boundary=${n}`),await lc(e,e.multipartBody.parts,n),e.multipartBody=void 0,t(e)}}}function mc(){return ko()}const hc=_o({logLevelEnvVarName:`AZURE_LOG_LEVEL`,namespace:`azure`});hc.logger;function gc(e){return hc.createClientLogger(e)}const _c=gc(`core-rest-pipeline`);function vc(e={}){return es({logger:_c.info,...e})}function yc(e={}){return ns(e)}function bc(){return`User-Agent`}async function xc(e){if(t&&t.versions){let n=`${N.type()} ${N.release()}; ${N.arch()}`,r=t.versions;r.bun?e.set(`Bun`,`${r.bun} (${n})`):r.deno?e.set(`Deno`,`${r.deno} (${n})`):r.node&&e.set(`Node`,`${r.node} (${n})`)}}const Sc=`1.22.3`;function Cc(e){let t=[];for(let[n,r]of e){let e=r?`${n}/${r}`:n;t.push(e)}return t.join(` `)}function wc(){return bc()}async function Tc(e){let t=new Map;t.set(`core-rest-pipeline`,Sc),await xc(t);let n=Cc(t);return e?`${e} ${n}`:n}const Ec=wc();function Dc(e={}){let t=Tc(e.userAgentPrefix);return{name:`userAgentPolicy`,async sendRequest(e,n){return e.headers.has(Ec)||e.headers.set(Ec,await t),n(e)}}}var Oc=class extends Error{constructor(e){super(e),this.name=`AbortError`}};function kc(e,t){let{cleanupBeforeAbort:n,abortSignal:r,abortErrorMsg:i}=t??{};return new Promise((t,a)=>{function o(){a(new Oc(i??`The operation was aborted.`))}function s(){r?.removeEventListener(`abort`,c)}function c(){n?.(),s(),o()}if(r?.aborted)return o();try{e(e=>{s(),t(e)},e=>{s(),a(e)})}catch(e){a(e)}r?.addEventListener(`abort`,c)})}function Ac(e,t){let n,{abortSignal:r,abortErrorMsg:i}=t??{};return kc(t=>{n=setTimeout(t,e)},{cleanupBeforeAbort:()=>clearTimeout(n),abortSignal:r,abortErrorMsg:i??`The delay was aborted.`})}function jc(e){if(jo(e))return e.message;{let t;try{t=typeof e==`object`&&e?JSON.stringify(e):String(e)}catch{t=`[unable to stringify input]`}return`Unknown error ${t}`}}function Mc(e){return jo(e)}function Nc(){return wo()}const Pc=bs,Fc=Symbol(`rawContent`);function Ic(e){return typeof e[Fc]==`function`}function Lc(e){return Ic(e)?e[Fc]():e}const Rc=uc;function zc(){let e=pc();return{name:Rc,sendRequest:async(t,n)=>{if(t.multipartBody)for(let e of t.multipartBody.parts)Ic(e.body)&&(e.body=Lc(e.body));return e.sendRequest(t,n)}}}function Bc(){return is()}function Vc(e={}){return ys(e)}function Hc(){return Ss()}function Uc(e){return Ks(e)}function Wc(e,t){return Xs(e,t)}function Gc(e=`x-ms-client-request-id`){return{name:`setClientRequestIdPolicy`,async sendRequest(t,n){return t.headers.has(e)||t.headers.set(e,t.requestId),n(t)}}}function Kc(e){return Zs(e)}function qc(e){return Qs(e)}const Jc={span:Symbol.for(`@azure/core-tracing span`),namespace:Symbol.for(`@azure/core-tracing namespace`)};function Yc(e={}){let t=new Xc(e.parentContext);return e.span&&(t=t.setValue(Jc.span,e.span)),e.namespace&&(t=t.setValue(Jc.namespace,e.namespace)),t}var Xc=class e{_contextMap;constructor(t){this._contextMap=t instanceof e?new Map(t._contextMap):new Map}setValue(t,n){let r=new e(this);return r._contextMap.set(t,n),r}getValue(e){return this._contextMap.get(e)}deleteValue(t){let n=new e(this);return n._contextMap.delete(t),n}};const Zc=I((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.state=void 0,e.state={instrumenterImplementation:void 0}}))().state;function Qc(){return{end:()=>{},isRecording:()=>!1,recordException:()=>{},setAttribute:()=>{},setStatus:()=>{},addEvent:()=>{}}}function $c(){return{createRequestHeaders:()=>({}),parseTraceparentHeader:()=>{},startSpan:(e,t)=>({span:Qc(),tracingContext:Yc({parentContext:t.tracingContext})}),withContext(e,t,...n){return t(...n)}}}function el(){return Zc.instrumenterImplementation||=$c(),Zc.instrumenterImplementation}function tl(e){let{namespace:t,packageName:n,packageVersion:r}=e;function i(e,i,a){let o=el().startSpan(e,{...a,packageName:n,packageVersion:r,tracingContext:i?.tracingOptions?.tracingContext}),s=o.tracingContext,c=o.span;return s.getValue(Jc.namespace)||(s=s.setValue(Jc.namespace,t)),c.setAttribute(`az.namespace`,s.getValue(Jc.namespace)),{span:c,updatedOptions:Object.assign({},i,{tracingOptions:{...i?.tracingOptions,tracingContext:s}})}}async function a(e,t,n,r){let{span:a,updatedOptions:s}=i(e,t,r);try{let e=await o(s.tracingOptions.tracingContext,()=>Promise.resolve(n(s,a)));return a.setStatus({status:`success`}),e}catch(e){throw a.setStatus({status:`error`,error:e}),e}finally{a.end()}}function o(e,t,...n){return el().withContext(e,t,...n)}function s(e){return el().parseTraceparentHeader(e)}function c(e){return el().createRequestHeaders(e)}return{startSpan:i,withSpan:a,withContext:o,parseTraceparentHeader:s,createRequestHeaders:c}}const nl=Ro;function rl(e){return zo(e)}function il(e={}){let t=Tc(e.userAgentPrefix),n=new Io({additionalAllowedQueryParameters:e.additionalAllowedQueryParameters}),r=al();return{name:`tracingPolicy`,async sendRequest(e,i){if(!r)return i(e);let a=await t,o={"http.url":n.sanitizeUrl(e.url),"http.method":e.method,"http.user_agent":a,requestId:e.requestId};a&&(o[`http.user_agent`]=a);let{span:s,tracingContext:c}=ol(r,e,o)??{};if(!s||!c)return i(e);try{let t=await r.withContext(c,i,e);return cl(s,t),t}catch(e){throw sl(s,e),e}}}}function al(){try{return tl({namespace:``,packageName:`@azure/core-rest-pipeline`,packageVersion:Sc})}catch(e){_c.warning(`Error when creating the TracingClient: ${jc(e)}`);return}}function ol(e,t,n){try{let{span:r,updatedOptions:i}=e.startSpan(`HTTP ${t.method}`,{tracingOptions:t.tracingOptions},{spanKind:`client`,spanAttributes:n});if(!r.isRecording()){r.end();return}let a=e.createRequestHeaders(i.tracingOptions.tracingContext);for(let[e,n]of Object.entries(a))t.headers.set(e,n);return{span:r,tracingContext:i.tracingOptions.tracingContext}}catch(e){_c.warning(`Skipping creating a tracing span due to an error: ${jc(e)}`);return}}function sl(e,t){try{e.setStatus({status:`error`,error:Mc(t)?t:void 0}),rl(t)&&t.statusCode&&e.setAttribute(`http.status_code`,t.statusCode),e.end()}catch(e){_c.warning(`Skipping tracing span processing due to an error: ${jc(e)}`)}}function cl(e,t){try{e.setAttribute(`http.status_code`,t.status);let n=t.headers.get(`x-ms-request-id`);n&&e.setAttribute(`serviceRequestId`,n),t.status>=400&&e.setStatus({status:`error`}),e.end()}catch(e){_c.warning(`Skipping tracing span processing due to an error: ${jc(e)}`)}}function ll(e){if(e instanceof AbortSignal)return{abortSignal:e};if(e.aborted)return{abortSignal:AbortSignal.abort(e.reason)};let t=new AbortController,n=!0;function r(){n&&=(e.removeEventListener(`abort`,i),!1)}function i(){t.abort(e.reason),r()}return e.addEventListener(`abort`,i),{abortSignal:t.signal,cleanup:r}}function ul(){return{name:`wrapAbortSignalLikePolicy`,sendRequest:async(e,t)=>{if(!e.abortSignal)return t(e);let{abortSignal:n,cleanup:r}=ll(e.abortSignal);e.abortSignal=n;try{return await t(e)}finally{r?.()}}}}function dl(e){let t=mc();return Pc&&(e.agent&&t.addPolicy(Kc(e.agent)),e.tlsOptions&&t.addPolicy(qc(e.tlsOptions)),t.addPolicy(Wc(e.proxyOptions)),t.addPolicy(Bc())),t.addPolicy(ul()),t.addPolicy(Hc(),{beforePolicies:[Rc]}),t.addPolicy(Dc(e.userAgentOptions)),t.addPolicy(Gc(e.telemetryOptions?.clientRequestIdHeaderName)),t.addPolicy(zc(),{afterPhase:`Deserialize`}),t.addPolicy(Vc(e.retryOptions),{phase:`Retry`}),t.addPolicy(il({...e.userAgentOptions,...e.loggingOptions}),{afterPhase:`Retry`}),Pc&&t.addPolicy(yc(e.redirectOptions),{afterPhase:`Retry`}),t.addPolicy(vc(e.loggingOptions),{afterPhase:`Sign`}),t}function fl(){let e=$o();return{async sendRequest(t){let{abortSignal:n,cleanup:r}=t.abortSignal?ll(t.abortSignal):{};try{return t.abortSignal=n,await e.sendRequest(t)}finally{r?.()}}}}function pl(e){return Co(e)}function ml(e){return Eo(e)}const hl={forcedRefreshWindowInMs:1e3,retryIntervalInMs:3e3,refreshWindowInMs:1e3*60*2};async function gl(e,t,n){async function r(){if(Date.now()e.getToken(t,s),a.retryIntervalInMs,r?.expiresOnTimestamp??Date.now()).then(e=>(n=null,r=e,i=s.tenantId,r)).catch(e=>{throw n=null,r=null,i=void 0,e})),n}return async(e,t)=>{let n=!!t.claims,a=i!==t.tenantId;return n&&(r=null),a||n||o.mustRefresh?s(e,t):(o.shouldRefresh&&s(e,t),r)}}async function vl(e,t){try{return[await t(e),void 0]}catch(e){if(rl(e)&&e.response)return[e.response,e];throw e}}async function yl(e){let{scopes:t,getAccessToken:n,request:r}=e,i=await n(t,{abortSignal:r.abortSignal,tracingOptions:r.tracingOptions,enableCae:!0});i&&e.request.headers.set(`Authorization`,`Bearer ${i.token}`)}function bl(e){return e.status===401&&e.headers.has(`WWW-Authenticate`)}async function xl(e,t){let{scopes:n}=e,r=await e.getAccessToken(n,{enableCae:!0,claims:t});return r?(e.request.headers.set(`Authorization`,`${r.tokenType??`Bearer`} ${r.token}`),!0):!1}function Sl(e){let{credential:t,scopes:n,challengeCallbacks:r}=e,i=e.logger||_c,a={authorizeRequest:r?.authorizeRequest?.bind(r)??yl,authorizeRequestOnChallenge:r?.authorizeRequestOnChallenge?.bind(r)},o=t?_l(t):()=>Promise.resolve(null);return{name:`bearerTokenAuthenticationPolicy`,async sendRequest(e,t){if(!e.url.toLowerCase().startsWith(`https://`))throw Error(`Bearer token authentication is not permitted for non-TLS protected (non-https) URLs.`);await a.authorizeRequest({scopes:Array.isArray(n)?n:[n],request:e,getAccessToken:o,logger:i});let r,s,c;if([r,s]=await vl(e,t),bl(r)){let l=wl(r.headers.get(`WWW-Authenticate`));if(l){let a;try{a=atob(l)}catch{return i.warning(`The WWW-Authenticate header contains "claims" that cannot be parsed. Unable to perform the Continuous Access Evaluation authentication flow. Unparsable claims: ${l}`),r}c=await xl({scopes:Array.isArray(n)?n:[n],response:r,request:e,getAccessToken:o,logger:i},a),c&&([r,s]=await vl(e,t))}else if(a.authorizeRequestOnChallenge&&(c=await a.authorizeRequestOnChallenge({scopes:Array.isArray(n)?n:[n],request:e,response:r,getAccessToken:o,logger:i}),c&&([r,s]=await vl(e,t)),bl(r)&&(l=wl(r.headers.get(`WWW-Authenticate`)),l))){let a;try{a=atob(l)}catch{return i.warning(`The WWW-Authenticate header contains "claims" that cannot be parsed. Unable to perform the Continuous Access Evaluation authentication flow. Unparsable claims: ${l}`),r}c=await xl({scopes:Array.isArray(n)?n:[n],response:r,request:e,getAccessToken:o,logger:i},a),c&&([r,s]=await vl(e,t))}}if(s)throw s;return r}}}function Cl(e){let t=/(\w+)\s+((?:\w+=(?:"[^"]*"|[^,]*),?\s*)+)/g,n=/(\w+)="([^"]*)"/g,r=[],i;for(;(i=t.exec(e))!==null;){let e=i[1],t=i[2],a={},o;for(;(o=n.exec(t))!==null;)a[o[1]]=o[2];r.push({scheme:e,params:a})}return r}function wl(e){if(e)return Cl(e).find(e=>e.scheme===`Bearer`&&e.params.claims&&e.params.error===`insufficient_claims`)?.params.claims}function Tl(e){let t=e;return t&&typeof t.getToken==`function`&&(t.signRequest===void 0||t.getToken.length>0)}const El=`DisableKeepAlivePolicy`;function Dl(){return{name:El,async sendRequest(e,t){return e.disableKeepAlive=!0,t(e)}}}function Ol(e){return e.getOrderedPolicies().some(e=>e.name===El)}function kl(e){return(e instanceof Buffer?e:Buffer.from(e.buffer)).toString(`base64`)}function Al(e){return Buffer.from(e,`base64`)}function jl(e,t){return t!==`Composite`&&t!==`Dictionary`&&(typeof e==`string`||typeof e==`number`||typeof e==`boolean`||t?.match(/^(Date|DateTime|DateTimeRfc1123|UnixTime|ByteArray|Base64Url)$/i)!==null||e==null)}const Ml=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Nl(e){return Ml.test(e)}const Pl=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i;function Fl(e){return Pl.test(e)}function Il(e){let t={...e.headers,...e.body};return e.hasNullableType&&Object.getOwnPropertyNames(t).length===0?e.shouldWrapBody?{body:null}:null:e.shouldWrapBody?{...e.headers,body:e.body}:t}function Ll(e,t){let n=e.parsedHeaders;if(e.request.method===`HEAD`)return{...n,body:e.parsedBody};let r=t&&t.bodyMapper,i=!!r?.nullable,a=r?.type.name;if(a===`Stream`)return{...n,blobBody:e.blobBody,readableStreamBody:e.readableStreamBody};let o=a===`Composite`&&r.type.modelProperties||{},s=Object.keys(o).some(e=>o[e].serializedName===``);if(a===`Sequence`||s){let t=e.parsedBody??[];for(let n of Object.keys(o))o[n].serializedName&&(t[n]=e.parsedBody?.[n]);if(n)for(let e of Object.keys(n))t[e]=n[e];return i&&!e.parsedBody&&!n&&Object.getOwnPropertyNames(o).length===0?null:t}return Il({body:e.parsedBody,headers:n,hasNullableType:i,shouldWrapBody:jl(e.parsedBody,a)})}var Rl=class{modelMappers;isXML;constructor(e={},t=!1){this.modelMappers=e,this.isXML=t}validateConstraints(e,t,n){let r=(e,r)=>{throw Error(`"${n}" with value "${t}" should satisfy the constraint "${e}": ${r}.`)};if(e.constraints&&t!=null){let{ExclusiveMaximum:n,ExclusiveMinimum:i,InclusiveMaximum:a,InclusiveMinimum:o,MaxItems:s,MaxLength:c,MinItems:l,MinLength:u,MultipleOf:d,Pattern:f,UniqueItems:p}=e.constraints;if(n!==void 0&&t>=n&&r(`ExclusiveMaximum`,n),i!==void 0&&t<=i&&r(`ExclusiveMinimum`,i),a!==void 0&&t>a&&r(`InclusiveMaximum`,a),o!==void 0&&ts&&r(`MaxItems`,s),c!==void 0&&t.length>c&&r(`MaxLength`,c),l!==void 0&&t.lengthn.indexOf(e)!==t)&&r(`UniqueItems`,p)}}serialize(e,t,n,r={xml:{}}){let i={xml:{rootName:r.xml.rootName??``,includeRoot:r.xml.includeRoot??!1,xmlCharKey:r.xml.xmlCharKey??`_`}},a={},o=e.type.name;n||=e.serializedName,o.match(/^Sequence$/i)!==null&&(a=[]),e.isConstant&&(t=e.defaultValue);let{required:s,nullable:c}=e;if(s&&c&&t===void 0)throw Error(`${n} cannot be undefined.`);if(s&&!c&&t==null)throw Error(`${n} cannot be null or undefined.`);if(!s&&c===!1&&t===null)throw Error(`${n} cannot be null.`);return t==null?a=t:o.match(/^any$/i)===null?o.match(/^(Number|String|Boolean|Object|Stream|Uuid)$/i)===null?o.match(/^Enum$/i)===null?o.match(/^(Date|DateTime|TimeSpan|DateTimeRfc1123|UnixTime)$/i)===null?o.match(/^ByteArray$/i)===null?o.match(/^Base64Url$/i)===null?o.match(/^Sequence$/i)===null?o.match(/^Dictionary$/i)===null?o.match(/^Composite$/i)!==null&&(a=nu(this,e,t,n,!!this.isXML,i)):a=Ql(this,e,t,n,!!this.isXML,i):a=Zl(this,e,t,n,!!this.isXML,i):a=Yl(n,t):a=Jl(n,t):a=Xl(o,t,n):a=ql(n,e.type.allowedValues,t):a=Kl(o,n,t):a=t,a}deserialize(e,t,n,r={xml:{}}){let i={xml:{rootName:r.xml.rootName??``,includeRoot:r.xml.includeRoot??!1,xmlCharKey:r.xml.xmlCharKey??`_`},ignoreUnknownProperties:r.ignoreUnknownProperties??!1};if(t==null)return this.isXML&&e.type.name===`Sequence`&&!e.xmlIsWrapped&&(t=[]),e.defaultValue!==void 0&&(t=e.defaultValue),t;let a,o=e.type.name;if(n||=e.serializedName,o.match(/^Composite$/i)!==null)a=au(this,e,t,n,i);else{if(this.isXML){let e=i.xml.xmlCharKey;t.$!==void 0&&t[e]!==void 0&&(t=t[e])}o.match(/^Number$/i)===null?o.match(/^Boolean$/i)===null?o.match(/^(String|Enum|Object|Stream|Uuid|TimeSpan|any)$/i)===null?o.match(/^(Date|DateTime|DateTimeRfc1123)$/i)===null?o.match(/^UnixTime$/i)===null?o.match(/^ByteArray$/i)===null?o.match(/^Base64Url$/i)===null?o.match(/^Sequence$/i)===null?o.match(/^Dictionary$/i)!==null&&(a=ou(this,e,t,n,i)):a=su(this,e,t,n,i):a=Hl(t):a=Al(t):a=Gl(t):a=new Date(t):a=t:a=t===`true`?!0:t===`false`?!1:t:(a=parseFloat(t),isNaN(a)&&(a=t))}return e.isConstant&&(a=e.defaultValue),a}};function zl(e={},t=!1){return new Rl(e,t)}function Bl(e,t){let n=e.length;for(;n-1>=0&&e[n-1]===t;)--n;return e.substr(0,n)}function Vl(e){if(e){if(!(e instanceof Uint8Array))throw Error(`Please provide an input of type Uint8Array for converting to Base64Url.`);return Bl(kl(e),`=`).replace(/\+/g,`-`).replace(/\//g,`_`)}}function Hl(e){if(e){if(e&&typeof e.valueOf()!=`string`)throw Error(`Please provide an input of type string for converting to Uint8Array`);return e=e.replace(/-/g,`+`).replace(/_/g,`/`),Al(e)}}function Ul(e){let t=[],n=``;if(e){let r=e.split(`.`);for(let e of r)e.charAt(e.length-1)===`\\`?n+=e.substr(0,e.length-1)+`.`:(n+=e,t.push(n),n=``)}return t}function Wl(e){if(e)return typeof e.valueOf()==`string`&&(e=new Date(e)),Math.floor(e.getTime()/1e3)}function Gl(e){if(e)return new Date(e*1e3)}function Kl(e,t,n){if(n!=null){if(e.match(/^Number$/i)!==null){if(typeof n!=`number`)throw Error(`${t} with value ${n} must be of type number.`)}else if(e.match(/^String$/i)!==null){if(typeof n.valueOf()!=`string`)throw Error(`${t} with value "${n}" must be of type string.`)}else if(e.match(/^Uuid$/i)!==null){if(!(typeof n.valueOf()==`string`&&Fl(n)))throw Error(`${t} with value "${n}" must be of type string and a valid uuid.`)}else if(e.match(/^Boolean$/i)!==null){if(typeof n!=`boolean`)throw Error(`${t} with value ${n} must be of type boolean.`)}else if(e.match(/^Stream$/i)!==null){let e=typeof n;if(e!==`string`&&typeof n.pipe!=`function`&&typeof n.tee!=`function`&&!(n instanceof ArrayBuffer)&&!ArrayBuffer.isView(n)&&!((typeof Blob==`function`||typeof Blob==`object`)&&n instanceof Blob)&&e!==`function`)throw Error(`${t} must be a string, Blob, ArrayBuffer, ArrayBufferView, ReadableStream, or () => ReadableStream.`)}}return n}function ql(e,t,n){if(!t)throw Error(`Please provide a set of allowedValues to validate ${e} as an Enum Type.`);if(!t.some(e=>typeof e.valueOf()==`string`?e.toLowerCase()===n.toLowerCase():e===n))throw Error(`${n} is not a valid value for ${e}. The valid values are: ${JSON.stringify(t)}.`);return n}function Jl(e,t){if(t!=null){if(!(t instanceof Uint8Array))throw Error(`${e} must be of type Uint8Array.`);t=kl(t)}return t}function Yl(e,t){if(t!=null){if(!(t instanceof Uint8Array))throw Error(`${e} must be of type Uint8Array.`);t=Vl(t)}return t}function Xl(e,t,n){if(t!=null){if(e.match(/^Date$/i)!==null){if(!(t instanceof Date||typeof t.valueOf()==`string`&&!isNaN(Date.parse(t))))throw Error(`${n} must be an instanceof Date or a string in ISO8601 format.`);t=t instanceof Date?t.toISOString().substring(0,10):new Date(t).toISOString().substring(0,10)}else if(e.match(/^DateTime$/i)!==null){if(!(t instanceof Date||typeof t.valueOf()==`string`&&!isNaN(Date.parse(t))))throw Error(`${n} must be an instanceof Date or a string in ISO8601 format.`);t=t instanceof Date?t.toISOString():new Date(t).toISOString()}else if(e.match(/^DateTimeRfc1123$/i)!==null){if(!(t instanceof Date||typeof t.valueOf()==`string`&&!isNaN(Date.parse(t))))throw Error(`${n} must be an instanceof Date or a string in RFC-1123 format.`);t=t instanceof Date?t.toUTCString():new Date(t).toUTCString()}else if(e.match(/^UnixTime$/i)!==null){if(!(t instanceof Date||typeof t.valueOf()==`string`&&!isNaN(Date.parse(t))))throw Error(`${n} must be an instanceof Date or a string in RFC-1123/ISO8601 format for it to be serialized in UnixTime/Epoch format.`);t=Wl(t)}else if(e.match(/^TimeSpan$/i)!==null&&!Nl(t))throw Error(`${n} must be a string in ISO 8601 format. Instead was "${t}".`)}return t}function Zl(e,t,n,r,i,a){if(!Array.isArray(n))throw Error(`${r} must be of type Array.`);let o=t.type.element;if(!o||typeof o!=`object`)throw Error(`element" metadata for an Array must be defined in the mapper and it must of type "object" in ${r}.`);o.type.name===`Composite`&&o.type.className&&(o=e.modelMappers[o.type.className]??o);let s=[];for(let t=0;te!==i)&&(o[i]=e.serialize(c,n[i],r+`["`+i+`"]`,a))}return o}return n}function ru(e,t,n,r){if(!n||!e.xmlNamespace)return t;let i={[e.xmlNamespacePrefix?`xmlns:${e.xmlNamespacePrefix}`:`xmlns`]:e.xmlNamespace};if([`Composite`].includes(e.type.name)){if(t.$)return t;{let e={...t};return e.$=i,e}}let a={};return a[r.xml.xmlCharKey]=t,a.$=i,a}function iu(e,t){return[`$`,t.xml.xmlCharKey].includes(e)}function au(e,t,n,r,i){let a=i.xml.xmlCharKey??`_`;uu(e,t)&&(t=lu(e,t,n,`serializedName`));let o=tu(e,t,r),s={},c=[];for(let l of Object.keys(o)){let u=o[l],d=Ul(o[l].serializedName);c.push(d[0]);let{serializedName:f,xmlName:p,xmlElementName:m}=u,h=r;f!==``&&f!==void 0&&(h=r+`.`+f);let g=u.headerCollectionPrefix;if(g){let t={};for(let r of Object.keys(n))r.startsWith(g)&&(t[r.substring(g.length)]=e.deserialize(u.type.value,n[r],h,i)),c.push(r);s[l]=t}else if(e.isXML)if(u.xmlIsAttribute&&n.$)s[l]=e.deserialize(u,n.$[p],h,i);else if(u.xmlIsMsText)n[a]===void 0?typeof n==`string`&&(s[l]=n):s[l]=n[a];else{let t=m||p||f;if(u.xmlIsWrapped){let t=n[p]?.[m]??[];s[l]=e.deserialize(u,t,h,i),c.push(p)}else{let r=n[t];s[l]=e.deserialize(u,r,h,i),c.push(t)}}else{let r,a=n,c=0;for(let e of d){if(!a)break;c++,a=a[e]}a===null&&c{for(let t in o)if(Ul(o[t].serializedName)[0]===e)return!1;return!0};for(let a in n)t(a)&&(s[a]=e.deserialize(l,n[a],r+`["`+a+`"]`,i))}else if(n&&!i.ignoreUnknownProperties)for(let e of Object.keys(n))s[e]===void 0&&!c.includes(e)&&!iu(e,i)&&(s[e]=n[e]);return s}function ou(e,t,n,r,i){let a=t.type.value;if(!a||typeof a!=`object`)throw Error(`"value" metadata for a Dictionary must be defined in the mapper and it must of type "object" in ${r}`);if(n){let t={};for(let o of Object.keys(n))t[o]=e.deserialize(a,n[o],r,i);return t}return n}function su(e,t,n,r,i){let a=t.type.element;if(!a||typeof a!=`object`)throw Error(`element" metadata for an Array must be defined in the mapper and it must of type "object" in ${r}`);if(n){Array.isArray(n)||(n=[n]),a.type.name===`Composite`&&a.type.className&&(a=e.modelMappers[a.type.className]??a);let t=[];for(let o=0;o{Object.defineProperty(e,`__esModule`,{value:!0}),e.state=void 0,e.state={operationRequestMap:new WeakMap}}))().state;function mu(e,t,n){let r=t.parameterPath,i=t.mapper,a;if(typeof r==`string`&&(r=[r]),Array.isArray(r)){if(r.length>0)if(i.isConstant)a=i.defaultValue;else{let t=hu(e,r);!t.propertyFound&&n&&(t=hu(n,r));let o=!1;t.propertyFound||(o=i.required||r[0]===`options`&&r.length===2),a=o?i.defaultValue:t.propertyValue}}else{i.required&&(a={});for(let t in r){let o=i.type.modelProperties[t],s=r[t],c=mu(e,{parameterPath:s,mapper:o},n);c!==void 0&&(a||={},a[t]=c)}}return a}function hu(e,t){let n={propertyFound:!1},r=0;for(;r=200&&n.status<300);s.headersMapper&&(a.parsedHeaders=o.serializer.deserialize(s.headersMapper,a.headers.toJSON(),`operationRes.parsedHeaders`,{xml:{},ignoreUnknownProperties:!0}))}return a}function Tu(e){let t=Object.keys(e.responses);return t.length===0||t.length===1&&t[0]===`default`}function Eu(e,t,n,r){let i=200<=e.status&&e.status<300;if(Tu(t)?i:n)if(n){if(!n.isError)return{error:null,shouldReturnResponse:!1}}else return{error:null,shouldReturnResponse:!1};let a=n??t.responses.default,o=new nl(e.request.streamResponseStatusCodes?.has(e.status)?`Unexpected status code: ${e.status}`:e.bodyAsText,{statusCode:e.status,request:e.request,response:e});if(!a&&!(e.parsedBody?.error?.code&&e.parsedBody?.error?.message))throw o;let s=a?.bodyMapper,c=a?.headersMapper;try{if(e.parsedBody){let n=e.parsedBody,i;if(s){let e=n;if(t.isXML&&s.type.name===fu.Sequence){e=[];let t=s.xmlElementName;typeof n==`object`&&t&&(e=n[t])}i=t.serializer.deserialize(s,e,`error.response.parsedBody`,r)}let a=n.error||i||n;o.code=a.code,a.message&&(o.message=a.message),s&&(o.response.parsedBody=i)}e.headers&&c&&(o.response.parsedHeaders=t.serializer.deserialize(c,e.headers.toJSON(),`operationRes.parsedHeaders`))}catch(t){o.message=`Error "${t.message}" occurred in deserializing the responseBody - "${e.bodyAsText}" for the default response.`}return{error:o,shouldReturnResponse:!1}}async function Du(e,t,n,r,i){if(!n.request.streamResponseStatusCodes?.has(n.status)&&n.bodyAsText){let a=n.bodyAsText,o=n.headers.get(`Content-Type`)||``,s=o?o.split(`;`).map(e=>e.toLowerCase()):[];try{if(s.length===0||s.some(t=>e.indexOf(t)!==-1))return n.parsedBody=JSON.parse(a),n;if(s.some(e=>t.indexOf(e)!==-1)){if(!i)throw Error(`Parsing XML not supported.`);return n.parsedBody=await i(a,r.xml),n}}catch(e){throw new nl(`Error "${e}" occurred while parsing the response body - ${n.bodyAsText}.`,{code:e.code||nl.PARSE_ERROR,statusCode:n.status,request:n.request,response:n})}}return n}function Ou(e){let t=new Set;for(let n in e.responses){let r=e.responses[n];r.bodyMapper&&r.bodyMapper.type.name===fu.Stream&&t.add(Number(n))}return t}function ku(e){let{parameterPath:t,mapper:n}=e,r;return r=typeof t==`string`?t:Array.isArray(t)?t.join(`.`):n.serializedName,r}function Au(e={}){let t=e.stringifyXML;return{name:`serializationPolicy`,async sendRequest(e,n){let r=vu(e),i=r?.operationSpec,a=r?.operationArguments;return i&&a&&(ju(e,a,i),Mu(e,a,i,t)),n(e)}}}function ju(e,t,n){if(n.headerParameters)for(let r of n.headerParameters){let i=mu(t,r);if(i!=null||r.mapper.required){i=n.serializer.serialize(r.mapper,i,ku(r));let t=r.mapper.headerCollectionPrefix;if(t)for(let n of Object.keys(i))e.headers.set(t+n,i[n]);else e.headers.set(r.mapper.serializedName||ku(r),i)}}let r=t.options?.requestOptions?.customHeaders;if(r)for(let t of Object.keys(r))e.headers.set(t,r[t])}function Mu(e,t,n,r=function(){throw Error(`XML serialization unsupported!`)}){let i=t.options?.serializerOptions,a={xml:{rootName:i?.xml.rootName??``,includeRoot:i?.xml.includeRoot??!1,xmlCharKey:i?.xml.xmlCharKey??`_`}},o=a.xml.xmlCharKey;if(n.requestBody&&n.requestBody.mapper){e.body=mu(t,n.requestBody);let i=n.requestBody.mapper,{required:s,serializedName:c,xmlName:l,xmlElementName:u,xmlNamespace:d,xmlNamespacePrefix:f,nullable:p}=i,m=i.type.name;try{if(e.body!==void 0&&e.body!==null||p&&e.body===null||s){let t=ku(n.requestBody);e.body=n.serializer.serialize(i,e.body,t,a);let s=m===fu.Stream;if(n.isXML){let t=f?`xmlns:${f}`:`xmlns`,n=Nu(d,t,m,e.body,a);m===fu.Sequence?e.body=r(Pu(n,u||l||c,t,d),{rootName:l||c,xmlCharKey:o}):s||(e.body=r(n,{rootName:l||c,xmlCharKey:o}))}else if(m===fu.String&&(n.contentType?.match(`text/plain`)||n.mediaType===`text`))return;else s||(e.body=JSON.stringify(e.body))}}catch(e){throw Error(`Error "${e.message}" occurred in serializing the payload - ${JSON.stringify(c,void 0,` `)}.`)}}else if(n.formDataParameters&&n.formDataParameters.length>0){e.formData={};for(let r of n.formDataParameters){let i=mu(t,r);if(i!=null){let t=r.mapper.serializedName||ku(r);e.formData[t]=n.serializer.serialize(r.mapper,i,ku(r),a)}}}}function Nu(e,t,n,r,i){if(e&&![`Composite`,`Sequence`,`Dictionary`].includes(n)){let n={};return n[i.xml.xmlCharKey]=r,n.$={[t]:e},n}return r}function Pu(e,t,n,r){if(Array.isArray(e)||(e=[e]),!n||!r)return{[t]:e};let i={[t]:e};return i.$={[n]:r},i}function Fu(e={}){let t=dl(e??{});return e.credentialOptions&&t.addPolicy(Sl({credential:e.credentialOptions.credential,scopes:e.credentialOptions.credentialScopes})),t.addPolicy(Au(e.serializationOptions),{phase:`Serialize`}),t.addPolicy(xu(e.deserializationOptions),{phase:`Deserialize`}),t}let Iu;function Lu(){return Iu||=fl(),Iu}const Ru={CSV:`,`,SSV:` `,Multi:`Multi`,TSV:` `,Pipes:`|`};function zu(e,t,n,r){let i=Vu(t,n,r),a=!1,o=Bu(e,i);if(t.path){let e=Bu(t.path,i);t.path===`/{nextLink}`&&e.startsWith(`/`)&&(e=e.substring(1)),Hu(e)?(o=e,a=!0):o=Uu(o,e)}let{queryParams:s,sequenceParams:c}=Wu(t,n,r);return o=Ku(o,s,c,a),o}function Bu(e,t){let n=e;for(let[e,r]of t)n=n.split(e).join(r);return n}function Vu(e,t,n){let r=new Map;if(e.urlParameters?.length)for(let i of e.urlParameters){let a=mu(t,i,n),o=ku(i);a=e.serializer.serialize(i.mapper,a,o),i.skipEncoding||(a=encodeURIComponent(a)),r.set(`{${i.mapper.serializedName||o}}`,a)}return r}function Hu(e){return e.includes(`://`)}function Uu(e,t){if(!t)return e;let n=new URL(e),r=n.pathname;r.endsWith(`/`)||(r=`${r}/`),t.startsWith(`/`)&&(t=t.substring(1));let i=t.indexOf(`?`);if(i!==-1){let e=t.substring(0,i),a=t.substring(i+1);r+=e,a&&(n.search=n.search?`${n.search}&${a}`:a)}else r+=t;return n.pathname=r,n.toString()}function Wu(e,t,n){let r=new Map,i=new Set;if(e.queryParameters?.length)for(let a of e.queryParameters){a.mapper.type.name===`Sequence`&&a.mapper.serializedName&&i.add(a.mapper.serializedName);let o=mu(t,a,n);if(o!=null||a.mapper.required){o=e.serializer.serialize(a.mapper,o,ku(a));let t=a.collectionFormat?Ru[a.collectionFormat]:``;if(Array.isArray(o)&&(o=o.map(e=>e??``)),a.collectionFormat===`Multi`&&o.length===0)continue;Array.isArray(o)&&(a.collectionFormat===`SSV`||a.collectionFormat===`TSV`)&&(o=o.join(t)),a.skipEncoding||(o=Array.isArray(o)?o.map(e=>encodeURIComponent(e)):encodeURIComponent(o)),Array.isArray(o)&&(a.collectionFormat===`CSV`||a.collectionFormat===`Pipes`)&&(o=o.join(t)),r.set(a.mapper.serializedName||ku(a),o)}}return{queryParams:r,sequenceParams:i}}function Gu(e){let t=new Map;if(!e||e[0]!==`?`)return t;e=e.slice(1);let n=e.split(`&`);for(let e of n){let[n,r]=e.split(`=`,2),i=t.get(n);i?Array.isArray(i)?i.push(r):t.set(n,[i,r]):t.set(n,r)}return t}function Ku(e,t,n,r=!1){if(t.size===0)return e;let i=new URL(e),a=Gu(i.search);for(let[e,i]of t){let t=a.get(e);if(Array.isArray(t))if(Array.isArray(i)){t.push(...i);let n=new Set(t);a.set(e,Array.from(n))}else t.push(i);else t?(Array.isArray(i)?i.unshift(t):n.has(e)&&a.set(e,[t,i]),r||a.set(e,i)):a.set(e,i)}let o=[];for(let[e,t]of a)if(typeof t==`string`)o.push(`${e}=${t}`);else if(Array.isArray(t))for(let n of t)o.push(`${e}=${n}`);else o.push(`${e}=${t}`);return i.search=o.length?`?${o.join(`&`)}`:``,i.toString()}const qu=gc(`core-client`);var Ju=class{_endpoint;_requestContentType;_allowInsecureConnection;_httpClient;pipeline;constructor(e={}){if(this._requestContentType=e.requestContentType,this._endpoint=e.endpoint??e.baseUri,e.baseUri&&qu.warning(`The baseUri option for SDK Clients has been deprecated, please use endpoint instead.`),this._allowInsecureConnection=e.allowInsecureConnection,this._httpClient=e.httpClient||Lu(),this.pipeline=e.pipeline||Yu(e),e.additionalPolicies?.length)for(let{policy:t,position:n}of e.additionalPolicies){let e=n===`perRetry`?`Sign`:void 0;this.pipeline.addPolicy(t,{afterPhase:e})}}async sendRequest(e){return this.pipeline.sendRequest(this._httpClient,e)}async sendOperationRequest(e,t){let n=t.baseUrl||this._endpoint;if(!n)throw Error(`If operationSpec.baseUrl is not specified, then the ServiceClient must have a endpoint string property that contains the base URL to use.`);let r=ml({url:zu(n,t,e,this)});r.method=t.httpMethod;let i=vu(r);i.operationSpec=t,i.operationArguments=e;let a=t.contentType||this._requestContentType;a&&t.requestBody&&r.headers.set(`Content-Type`,a);let o=e.options;if(o){let e=o.requestOptions;e&&(e.timeout&&(r.timeout=e.timeout),e.onUploadProgress&&(r.onUploadProgress=e.onUploadProgress),e.onDownloadProgress&&(r.onDownloadProgress=e.onDownloadProgress),e.shouldDeserialize!==void 0&&(i.shouldDeserialize=e.shouldDeserialize),e.allowInsecureConnection&&(r.allowInsecureConnection=!0)),o.abortSignal&&(r.abortSignal=o.abortSignal),o.tracingOptions&&(r.tracingOptions=o.tracingOptions)}this._allowInsecureConnection&&(r.allowInsecureConnection=!0),r.streamResponseStatusCodes===void 0&&(r.streamResponseStatusCodes=Ou(t));try{let e=await this.sendRequest(r),n=Ll(e,t.responses[e.status]);return o?.onResponse&&o.onResponse(e,n),n}catch(e){if(typeof e==`object`&&e?.response){let n=e.response,r=Ll(n,t.responses[e.statusCode]||t.responses.default);e.details=r,o?.onResponse&&o.onResponse(n,r,e)}throw e}}};function Yu(e){let t=Xu(e),n=e.credential&&t?{credentialScopes:t,credential:e.credential}:void 0;return Fu({...e,credentialOptions:n})}function Xu(e){if(e.credentialScopes)return e.credentialScopes;if(e.endpoint)return`${e.endpoint}/.default`;if(e.baseUri)return`${e.baseUri}/.default`;if(e.credential&&!e.credentialScopes)throw Error(`When using credentials, the ServiceClientOptions must contain either a endpoint or a credentialScopes. Unable to create a bearerTokenAuthenticationPolicy`)}const Zu={DefaultScope:`/.default`,HeaderConstants:{AUTHORIZATION:`authorization`}};function Qu(e){return/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/.test(e)}const $u=async e=>{let t=id(e.request),n=nd(e.response);if(n){let r=rd(n),i=td(e,r),a=ed(r);if(!a)return!1;let o=await e.getAccessToken(i,{...t,tenantId:a});return o?(e.request.headers.set(Zu.HeaderConstants.AUTHORIZATION,`${o.tokenType??`Bearer`} ${o.token}`),!0):!1}return!1};function ed(e){let t=new URL(e.authorization_uri).pathname.split(`/`)[1];if(t&&Qu(t))return t}function td(e,t){if(!t.resource_id)return e.scopes;let n=new URL(t.resource_id);n.pathname=Zu.DefaultScope;let r=n.toString();return r===`https://disk.azure.com/.default`&&(r=`https://disk.azure.com//.default`),[r]}function nd(e){let t=e.headers.get(`WWW-Authenticate`);if(e.status===401&&t)return t}function rd(e){return`${e.slice(7).trim()} `.split(` `).filter(e=>e).map(e=>(([e,t])=>({[e]:t}))(e.trim().split(`=`))).reduce((e,t)=>({...e,...t}),{})}function id(e){return{abortSignal:e.abortSignal,requestOptions:{timeout:e.timeout},tracingOptions:e.tracingOptions}}const ad=Symbol(`Original PipelineRequest`),od=Symbol.for(`@azure/core-client original request`);function sd(e,t={}){let n=e[ad],r=pl(e.headers.toJson({preserveCase:!0}));if(n)return n.headers=r,n;{let n=ml({url:e.url,method:e.method,headers:r,withCredentials:e.withCredentials,timeout:e.timeout,requestId:e.requestId,abortSignal:e.abortSignal,body:e.body,formData:e.formData,disableKeepAlive:!!e.keepAlive,onDownloadProgress:e.onDownloadProgress,onUploadProgress:e.onUploadProgress,proxySettings:e.proxySettings,streamResponseStatusCodes:e.streamResponseStatusCodes,agent:e.agent,requestOverrides:e.requestOverrides});return t.originalRequest&&(n[od]=t.originalRequest),n}}function cd(e,t){let n=t?.originalRequest??e,r={url:e.url,method:e.method,headers:ld(e.headers),withCredentials:e.withCredentials,timeout:e.timeout,requestId:e.headers.get(`x-ms-client-request-id`)||e.requestId,abortSignal:e.abortSignal,body:e.body,formData:e.formData,keepAlive:!!e.disableKeepAlive,onDownloadProgress:e.onDownloadProgress,onUploadProgress:e.onUploadProgress,proxySettings:e.proxySettings,streamResponseStatusCodes:e.streamResponseStatusCodes,agent:e.agent,requestOverrides:e.requestOverrides,clone(){throw Error(`Cannot clone a non-proxied WebResourceLike`)},prepare(){throw Error(`WebResourceLike.prepare() is not supported by @azure/core-http-compat`)},validateRequestProperties(){}};return t?.createProxy?new Proxy(r,{get(t,i,a){return i===ad?e:i===`clone`?()=>cd(sd(r,{originalRequest:n}),{createProxy:!0,originalRequest:n}):Reflect.get(t,i,a)},set(t,n,r,i){return n===`keepAlive`&&(e.disableKeepAlive=!r),typeof n==`string`&&[`url`,`method`,`withCredentials`,`timeout`,`requestId`,`abortSignal`,`body`,`formData`,`onDownloadProgress`,`onUploadProgress`,`proxySettings`,`streamResponseStatusCodes`,`agent`,`requestOverrides`].includes(n)&&(e[n]=r),Reflect.set(t,n,r,i)}}):r}function ld(e){return new dd(e.toJSON({preserveCase:!0}))}function ud(e){return e.toLowerCase()}var dd=class e{_headersMap;constructor(e){if(this._headersMap={},e)for(let t in e)this.set(t,e[t])}set(e,t){this._headersMap[ud(e)]={name:e,value:t.toString()}}get(e){let t=this._headersMap[ud(e)];return t?t.value:void 0}contains(e){return!!this._headersMap[ud(e)]}remove(e){let t=this.contains(e);return delete this._headersMap[ud(e)],t}rawHeaders(){return this.toJson({preserveCase:!0})}headersArray(){let e=[];for(let t in this._headersMap)e.push(this._headersMap[t]);return e}headerNames(){let e=[],t=this.headersArray();for(let n=0;nmd(await e.sendRequest(cd(t,{createProxy:!0})))}}const bd=`:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD`;bd+``,``+bd;const xd=RegExp(`^[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`);function Sd(e,t){let n=[],r=t.exec(e);for(;r;){let i=[];i.startIndex=t.lastIndex-r[0].length;let a=r.length;for(let e=0;e`&&e[a]!==` `&&e[a]!==` `&&e[a]!==` `&&e[a]!==`\r`;a++)c+=e[a];if(c=c.trim(),c[c.length-1]===`/`&&(c=c.substring(0,c.length-1),a--),!zd(c)){let t;return t=c.trim().length===0?`Invalid space after '<'.`:`Tag '`+c+`' is an invalid name.`,Ld(`InvalidTag`,t,Bd(e,a))}let l=Md(e,a);if(l===!1)return Ld(`InvalidAttr`,`Attributes for '`+c+`' have open quote.`,Bd(e,a));let u=l.value;if(a=l.index,u[u.length-1]===`/`){let n=a-u.length;u=u.substring(0,u.length-1);let i=Pd(u,t);if(i===!0)r=!0;else return Ld(i.err.code,i.err.msg,Bd(e,n+i.err.line))}else if(s){if(!l.tagClosed)return Ld(`InvalidTag`,`Closing tag '`+c+`' doesn't have proper closing.`,Bd(e,a));if(u.trim().length>0)return Ld(`InvalidTag`,`Closing tag '`+c+`' can't have attributes or invalid starting.`,Bd(e,o));if(n.length===0)return Ld(`InvalidTag`,`Closing tag '`+c+`' has not been opened.`,Bd(e,o));{let t=n.pop();if(c!==t.tagName){let n=Bd(e,t.tagStartPos);return Ld(`InvalidTag`,`Expected closing tag '`+t.tagName+`' (opened in line `+n.line+`, col `+n.col+`) instead of closing tag '`+c+`'.`,Bd(e,o))}n.length==0&&(i=!0)}}else{let s=Pd(u,t);if(s!==!0)return Ld(s.err.code,s.err.msg,Bd(e,a-u.length+s.err.line));if(i===!0)return Ld(`InvalidXml`,`Multiple possible root nodes found.`,Bd(e,a));t.unpairedTags.indexOf(c)!==-1||n.push({tagName:c,tagStartPos:o}),r=!0}for(a++;a0?Ld(`InvalidXml`,`Invalid '`+JSON.stringify(n.map(e=>e.tagName),null,4).replace(/\r?\n/g,``)+`' found.`,{line:1,col:1}):!0:Ld(`InvalidXml`,`Start tag expected.`,1)}function kd(e){return e===` `||e===` `||e===` -`||e===`\r`}function Ad(e,t){let n=t;for(;t5&&r===`xml`)return Ld(`InvalidXml`,`XML declaration allowed only at the start of the document.`,Bd(e,t));if(e[t]==`?`&&e[t+1]==`>`){t++;break}else continue}return t}function jd(e,t){if(e.length>t+5&&e[t+1]===`-`&&e[t+2]===`-`){for(t+=3;t`){t+=2;break}}else if(e.length>t+8&&e[t+1]===`D`&&e[t+2]===`O`&&e[t+3]===`C`&&e[t+4]===`T`&&e[t+5]===`Y`&&e[t+6]===`P`&&e[t+7]===`E`){let n=1;for(t+=8;t`&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]===`[`&&e[t+2]===`C`&&e[t+3]===`D`&&e[t+4]===`A`&&e[t+5]===`T`&&e[t+6]===`A`&&e[t+7]===`[`){for(t+=8;t`){t+=2;break}}return t}function Md(e,t){let n=``,r=``,i=!1;for(;t`&&r===``){i=!0;break}n+=e[t]}return r===``?{value:n,index:t,tagClosed:i}:!1}const Nd=RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,`g`);function Pd(e,t){let n=Sd(e,Nd),r={};for(let e=0;eTd.includes(e)?`__`+e:e,Ud={preserveOrder:!1,attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:Hd};function Wd(e,t){if(typeof e!=`string`)return;let n=e.toLowerCase();if(Td.some(e=>n===e.toLowerCase())||Ed.some(e=>n===e.toLowerCase()))throw Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function Gd(e){return typeof e==`boolean`?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof e==`object`&&e?{enabled:e.enabled!==!1,maxEntitySize:Math.max(1,e.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,e.maxExpansionDepth??10),maxTotalExpansions:Math.max(1,e.maxTotalExpansions??1e3),maxExpandedLength:Math.max(1,e.maxExpandedLength??1e5),maxEntityCount:Math.max(1,e.maxEntityCount??100),allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null}:Gd(!0)}const Kd=function(e){let t=Object.assign({},Ud,e),n=[{value:t.attributeNamePrefix,name:`attributeNamePrefix`},{value:t.attributesGroupName,name:`attributesGroupName`},{value:t.textNodeName,name:`textNodeName`},{value:t.cdataPropName,name:`cdataPropName`},{value:t.commentPropName,name:`commentPropName`}];for(let{value:e,name:t}of n)e&&Wd(e,t);return t.onDangerousProperty===null&&(t.onDangerousProperty=Hd),t.processEntities=Gd(t.processEntities),t.stopNodes&&Array.isArray(t.stopNodes)&&(t.stopNodes=t.stopNodes.map(e=>typeof e==`string`&&e.startsWith(`*.`)?`..`+e.substring(2):e)),t};let qd;qd=typeof Symbol==`function`?Symbol(`XML Node Metadata`):`@@xmlMetadata`;var Jd=class{constructor(e){this.tagname=e,this.child=[],this[`:@`]=Object.create(null)}add(e,t){e===`__proto__`&&(e=`#__proto__`),this.child.push({[e]:t})}addChild(e,t){e.tagname===`__proto__`&&(e.tagname=`#__proto__`),e[`:@`]&&Object.keys(e[`:@`]).length>0?this.child.push({[e.tagname]:e.child,":@":e[`:@`]}):this.child.push({[e.tagname]:e.child}),t!==void 0&&(this.child[this.child.length-1][qd]={startIndex:t})}static getMetaDataSymbol(){return qd}},Yd=class{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,t){let n=Object.create(null),r=0;if(e[t+3]===`O`&&e[t+4]===`C`&&e[t+5]===`T`&&e[t+6]===`Y`&&e[t+7]===`P`&&e[t+8]===`E`){t+=9;let i=1,a=!1,o=!1,s=``;for(;t=this.options.maxEntityCount)throw Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);let e=i.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n[i]={regx:RegExp(`&${e};`,`g`),val:a},r++}}else if(a&&Zd(e,`!ELEMENT`,t)){t+=8;let{index:n}=this.readElementExp(e,t+1);t=n}else if(a&&Zd(e,`!ATTLIST`,t))t+=8;else if(a&&Zd(e,`!NOTATION`,t)){t+=9;let{index:n}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=n}else if(Zd(e,`!--`,t))o=!0;else throw Error(`Invalid DOCTYPE`);i++,s=``}else if(e[t]===`>`){if(o?e[t-1]===`-`&&e[t-2]===`-`&&(o=!1,i--):i--,i===0)break}else e[t]===`[`?a=!0:s+=e[t];if(i!==0)throw Error(`Unclosed DOCTYPE`)}else throw Error(`Invalid Tag instead of DOCTYPE`);return{entities:n,i:t}}readEntityExp(e,t){t=Xd(e,t);let n=t;for(;tthis.options.maxEntitySize)throw Error(`Entity "${r}" size (${i.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[r,i,t]}readNotationExp(e,t){t=Xd(e,t);let n=t;for(;t{for(;t1||a.length===1&&!s))return e;{let r=Number(n),s=String(r);if(r===0)return r;if(s.search(/[eE]/)!==-1)return t.eNotation?r:e;if(n.indexOf(`.`)!==-1)return s===`0`||s===o||s===`${i}${o}`?r:e;let c=a?o:n;return a?c===s||i+c===s?r:e:c===s||c===i+s?r:e}}else return e}}const rf=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function af(e,t,n){if(!n.eNotation)return e;let r=t.match(rf);if(r){let i=r[1]||``,a=r[3].indexOf(`e`)===-1?`E`:`e`,o=r[2],s=i?e[o.length+1]===a:e[o.length]===a;return o.length>1&&s?e:o.length===1&&(r[3].startsWith(`.${a}`)||r[3][0]===a)?Number(t):n.leadingZeros&&!s?(t=(r[1]||``)+r[3],Number(t)):e}else return e}function of(e){return e&&e.indexOf(`.`)!==-1?(e=e.replace(/0+$/,``),e===`.`?e=`0`:e[0]===`.`?e=`0`+e:e[e.length-1]===`.`&&(e=e.substring(0,e.length-1)),e):e}function sf(e,t){if(parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw Error(`parseInt, Number.parseInt, window.parseInt are not supported`)}function cf(e,t,n){let r=t===1/0;switch(n.infinity.toLowerCase()){case`null`:return null;case`infinity`:return t;case`string`:return r?`Infinity`:`-Infinity`;default:return e}}function lf(e){return typeof e==`function`?e:Array.isArray(e)?t=>{for(let n of e)if(typeof n==`string`&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}var uf=class{constructor(e,t={}){this.pattern=e,this.separator=t.separator||`.`,this.segments=this._parse(e),this._hasDeepWildcard=this.segments.some(e=>e.type===`deep-wildcard`),this._hasAttributeCondition=this.segments.some(e=>e.attrName!==void 0),this._hasPositionSelector=this.segments.some(e=>e.position!==void 0)}_parse(e){let t=[],n=0,r=``;for(;n0){let e=this.path[this.path.length-1];e.values=void 0}let r=this.path.length;this.siblingStacks[r]||(this.siblingStacks[r]=new Map);let i=this.siblingStacks[r],a=n?`${n}:${e}`:e,o=i.get(a)||0,s=0;for(let e of i.values())s+=e;i.set(a,o+1);let c={tag:e,position:s,counter:o};n!=null&&(c.namespace=n),t!=null&&(c.values=t),this.path.push(c)}pop(){if(this.path.length===0)return;let e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){let t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){if(this.path.length!==0)return this.path[this.path.length-1].values?.[e]}hasAttr(e){if(this.path.length===0)return!1;let t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){let n=e||this.separator;return this.path.map(e=>t&&e.namespace?`${e.namespace}:${e.tag}`:e.tag).join(n)}toArray(){return this.path.map(e=>e.tag)}reset(){this.path=[],this.siblingStacks=[]}matches(e){let t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t=0&&t>=0;){let r=e[n];if(r.type===`deep-wildcard`){if(n--,n<0)return!0;let r=e[n],i=!1;for(let e=t;e>=0;e--){let a=e===this.path.length-1;if(this._matchSegment(r,this.path[e],a)){t=e-1,n--,i=!0;break}}if(!i)return!1}else{let e=t===this.path.length-1;if(!this._matchSegment(r,this.path[t],e))return!1;t--,n--}}return n<0}_matchSegment(e,t,n){if(e.tag!==`*`&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!==`*`&&e.namespace!==t.namespace)return!1;if(e.attrName!==void 0){if(!n||!t.values||!(e.attrName in t.values))return!1;if(e.attrValue!==void 0){let n=t.values[e.attrName];if(String(n)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!n)return!1;let r=t.counter??0;if(e.position===`first`&&r!==0||e.position===`odd`&&r%2!=1||e.position===`even`&&r%2!=0||e.position===`nth`&&r!==e.positionValue)return!1}return!0}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this.path=e.path.map(e=>({...e})),this.siblingStacks=e.siblingStacks.map(e=>new Map(e))}readOnly(){let e=this;return new Proxy(e,{get(e,t,n){if(df.has(t))return()=>{throw TypeError(`Cannot call '${t}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};let r=Reflect.get(e,t,n);return t===`path`||t===`siblingStacks`?Object.freeze(Array.isArray(r)?r.map(e=>e instanceof Map?Object.freeze(new Map(e)):Object.freeze({...e})):r):typeof r==`function`?r.bind(e):r},set(e,t){throw TypeError(`Cannot set property '${String(t)}' on a read-only Matcher.`)},deleteProperty(e,t){throw TypeError(`Cannot delete property '${String(t)}' from a read-only Matcher.`)}})}};function pf(e,t){if(!e)return{};let n=t.attributesGroupName?e[t.attributesGroupName]:e;if(!n)return{};let r={};for(let e in n)if(e.startsWith(t.attributeNamePrefix)){let i=e.substring(t.attributeNamePrefix.length);r[i]=n[e]}else r[e]=n[e];return r}function mf(e){if(!e||typeof e!=`string`)return;let t=e.indexOf(`:`);if(t!==-1&&t>0){let n=e.substring(0,t);if(n!==`xmlns`)return n}}var hf=class{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:`'`},gt:{regex:/&(gt|#62|#x3E);/g,val:`>`},lt:{regex:/&(lt|#60|#x3C);/g,val:`<`},quot:{regex:/&(quot|#34|#x22);/g,val:`"`}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:`&`},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:` `},cent:{regex:/&(cent|#162);/g,val:`¢`},pound:{regex:/&(pound|#163);/g,val:`£`},yen:{regex:/&(yen|#165);/g,val:`¥`},euro:{regex:/&(euro|#8364);/g,val:`€`},copyright:{regex:/&(copy|#169);/g,val:`©`},reg:{regex:/&(reg|#174);/g,val:`®`},inr:{regex:/&(inr|#8377);/g,val:`₹`},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>jf(t,10,`&#`)},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>jf(t,16,`&#x`)}},this.addExternalEntities=gf,this.parseXml=xf,this.parseTextData=_f,this.resolveNameSpace=vf,this.buildAttributesMap=bf,this.isItStopNode=Tf,this.replaceEntitiesValue=Cf,this.readStopNodeData=kf,this.saveTextToParentTag=wf,this.addChild=Sf,this.ignoreAttributesFn=lf(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new ff,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodeExpressions=[];for(let e=0;e0)){o||(e=this.replaceEntitiesValue(e,t,n));let r=this.options.jPath?n.toString():n,s=this.options.tagValueProcessor(t,e,r,i,a);return s==null?e:typeof s!=typeof e||s!==e?s:this.options.trimValues||e.trim()===e?Af(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function vf(e){if(this.options.removeNSPrefix){let t=e.split(`:`),n=e.charAt(0)===`/`?`/`:``;if(t[0]===`xmlns`)return``;t.length===2&&(e=n+t[1])}return e}const yf=RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,`gm`);function bf(e,t,n){if(this.options.ignoreAttributes!==!0&&typeof e==`string`){let r=Sd(e,yf),i=r.length,a={},o={};for(let e=0;e0&&typeof t==`object`&&t.updateCurrent&&t.updateCurrent(o);for(let e=0;e5&&r===`xml`)return Ld(`InvalidXml`,`XML declaration allowed only at the start of the document.`,Bd(e,t));if(e[t]==`?`&&e[t+1]==`>`){t++;break}else continue}return t}function jd(e,t){if(e.length>t+5&&e[t+1]===`-`&&e[t+2]===`-`){for(t+=3;t`){t+=2;break}}else if(e.length>t+8&&e[t+1]===`D`&&e[t+2]===`O`&&e[t+3]===`C`&&e[t+4]===`T`&&e[t+5]===`Y`&&e[t+6]===`P`&&e[t+7]===`E`){let n=1;for(t+=8;t`&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]===`[`&&e[t+2]===`C`&&e[t+3]===`D`&&e[t+4]===`A`&&e[t+5]===`T`&&e[t+6]===`A`&&e[t+7]===`[`){for(t+=8;t`){t+=2;break}}return t}function Md(e,t){let n=``,r=``,i=!1;for(;t`&&r===``){i=!0;break}n+=e[t]}return r===``?{value:n,index:t,tagClosed:i}:!1}const Nd=RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,`g`);function Pd(e,t){let n=Sd(e,Nd),r={};for(let e=0;eTd.includes(e)?`__`+e:e,Ud={preserveOrder:!1,attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:Hd};function Wd(e,t){if(typeof e!=`string`)return;let n=e.toLowerCase();if(Td.some(e=>n===e.toLowerCase())||Ed.some(e=>n===e.toLowerCase()))throw Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function Gd(e){return typeof e==`boolean`?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof e==`object`&&e?{enabled:e.enabled!==!1,maxEntitySize:Math.max(1,e.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,e.maxExpansionDepth??10),maxTotalExpansions:Math.max(1,e.maxTotalExpansions??1e3),maxExpandedLength:Math.max(1,e.maxExpandedLength??1e5),maxEntityCount:Math.max(1,e.maxEntityCount??100),allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null}:Gd(!0)}const Kd=function(e){let t=Object.assign({},Ud,e),n=[{value:t.attributeNamePrefix,name:`attributeNamePrefix`},{value:t.attributesGroupName,name:`attributesGroupName`},{value:t.textNodeName,name:`textNodeName`},{value:t.cdataPropName,name:`cdataPropName`},{value:t.commentPropName,name:`commentPropName`}];for(let{value:e,name:t}of n)e&&Wd(e,t);return t.onDangerousProperty===null&&(t.onDangerousProperty=Hd),t.processEntities=Gd(t.processEntities),t.stopNodes&&Array.isArray(t.stopNodes)&&(t.stopNodes=t.stopNodes.map(e=>typeof e==`string`&&e.startsWith(`*.`)?`..`+e.substring(2):e)),t};let qd;qd=typeof Symbol==`function`?Symbol(`XML Node Metadata`):`@@xmlMetadata`;var Jd=class{constructor(e){this.tagname=e,this.child=[],this[`:@`]=Object.create(null)}add(e,t){e===`__proto__`&&(e=`#__proto__`),this.child.push({[e]:t})}addChild(e,t){e.tagname===`__proto__`&&(e.tagname=`#__proto__`),e[`:@`]&&Object.keys(e[`:@`]).length>0?this.child.push({[e.tagname]:e.child,":@":e[`:@`]}):this.child.push({[e.tagname]:e.child}),t!==void 0&&(this.child[this.child.length-1][qd]={startIndex:t})}static getMetaDataSymbol(){return qd}},Yd=class{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,t){let n=Object.create(null),r=0;if(e[t+3]===`O`&&e[t+4]===`C`&&e[t+5]===`T`&&e[t+6]===`Y`&&e[t+7]===`P`&&e[t+8]===`E`){t+=9;let i=1,a=!1,o=!1,s=``;for(;t=this.options.maxEntityCount)throw Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);let e=i.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n[i]={regx:RegExp(`&${e};`,`g`),val:a},r++}}else if(a&&Zd(e,`!ELEMENT`,t)){t+=8;let{index:n}=this.readElementExp(e,t+1);t=n}else if(a&&Zd(e,`!ATTLIST`,t))t+=8;else if(a&&Zd(e,`!NOTATION`,t)){t+=9;let{index:n}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=n}else if(Zd(e,`!--`,t))o=!0;else throw Error(`Invalid DOCTYPE`);i++,s=``}else if(e[t]===`>`){if(o?e[t-1]===`-`&&e[t-2]===`-`&&(o=!1,i--):i--,i===0)break}else e[t]===`[`?a=!0:s+=e[t];if(i!==0)throw Error(`Unclosed DOCTYPE`)}else throw Error(`Invalid Tag instead of DOCTYPE`);return{entities:n,i:t}}readEntityExp(e,t){t=Xd(e,t);let n=t;for(;tthis.options.maxEntitySize)throw Error(`Entity "${r}" size (${i.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[r,i,t]}readNotationExp(e,t){t=Xd(e,t);let n=t;for(;t{for(;t1||a.length===1&&!s))return e;{let r=Number(n),s=String(r);if(r===0)return r;if(s.search(/[eE]/)!==-1)return t.eNotation?r:e;if(n.indexOf(`.`)!==-1)return s===`0`||s===o||s===`${i}${o}`?r:e;let c=a?o:n;return a?c===s||i+c===s?r:e:c===s||c===i+s?r:e}}else return e}}const rf=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function af(e,t,n){if(!n.eNotation)return e;let r=t.match(rf);if(r){let i=r[1]||``,a=r[3].indexOf(`e`)===-1?`E`:`e`,o=r[2],s=i?e[o.length+1]===a:e[o.length]===a;return o.length>1&&s?e:o.length===1&&(r[3].startsWith(`.${a}`)||r[3][0]===a)?Number(t):n.leadingZeros&&!s?(t=(r[1]||``)+r[3],Number(t)):e}else return e}function of(e){return e&&e.indexOf(`.`)!==-1?(e=e.replace(/0+$/,``),e===`.`?e=`0`:e[0]===`.`?e=`0`+e:e[e.length-1]===`.`&&(e=e.substring(0,e.length-1)),e):e}function sf(e,t){if(parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw Error(`parseInt, Number.parseInt, window.parseInt are not supported`)}function cf(e,t,n){let r=t===1/0;switch(n.infinity.toLowerCase()){case`null`:return null;case`infinity`:return t;case`string`:return r?`Infinity`:`-Infinity`;default:return e}}function lf(e){return typeof e==`function`?e:Array.isArray(e)?t=>{for(let n of e)if(typeof n==`string`&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}var uf=class{constructor(e,t={}){this.pattern=e,this.separator=t.separator||`.`,this.segments=this._parse(e),this._hasDeepWildcard=this.segments.some(e=>e.type===`deep-wildcard`),this._hasAttributeCondition=this.segments.some(e=>e.attrName!==void 0),this._hasPositionSelector=this.segments.some(e=>e.position!==void 0)}_parse(e){let t=[],n=0,r=``;for(;n0){let e=this.path[this.path.length-1];e.values=void 0}let r=this.path.length;this.siblingStacks[r]||(this.siblingStacks[r]=new Map);let i=this.siblingStacks[r],a=n?`${n}:${e}`:e,o=i.get(a)||0,s=0;for(let e of i.values())s+=e;i.set(a,o+1);let c={tag:e,position:s,counter:o};n!=null&&(c.namespace=n),t!=null&&(c.values=t),this.path.push(c)}pop(){if(this.path.length===0)return;let e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){let t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){if(this.path.length!==0)return this.path[this.path.length-1].values?.[e]}hasAttr(e){if(this.path.length===0)return!1;let t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){let n=e||this.separator;return this.path.map(e=>t&&e.namespace?`${e.namespace}:${e.tag}`:e.tag).join(n)}toArray(){return this.path.map(e=>e.tag)}reset(){this.path=[],this.siblingStacks=[]}matches(e){let t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t=0&&t>=0;){let r=e[n];if(r.type===`deep-wildcard`){if(n--,n<0)return!0;let r=e[n],i=!1;for(let e=t;e>=0;e--){let a=e===this.path.length-1;if(this._matchSegment(r,this.path[e],a)){t=e-1,n--,i=!0;break}}if(!i)return!1}else{let e=t===this.path.length-1;if(!this._matchSegment(r,this.path[t],e))return!1;t--,n--}}return n<0}_matchSegment(e,t,n){if(e.tag!==`*`&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!==`*`&&e.namespace!==t.namespace)return!1;if(e.attrName!==void 0){if(!n||!t.values||!(e.attrName in t.values))return!1;if(e.attrValue!==void 0){let n=t.values[e.attrName];if(String(n)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!n)return!1;let r=t.counter??0;if(e.position===`first`&&r!==0||e.position===`odd`&&r%2!=1||e.position===`even`&&r%2!=0||e.position===`nth`&&r!==e.positionValue)return!1}return!0}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this.path=e.path.map(e=>({...e})),this.siblingStacks=e.siblingStacks.map(e=>new Map(e))}readOnly(){return new Proxy(this,{get(e,t,n){if(df.has(t))return()=>{throw TypeError(`Cannot call '${t}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};let r=Reflect.get(e,t,n);return t===`path`||t===`siblingStacks`?Object.freeze(Array.isArray(r)?r.map(e=>e instanceof Map?Object.freeze(new Map(e)):Object.freeze({...e})):r):typeof r==`function`?r.bind(e):r},set(e,t){throw TypeError(`Cannot set property '${String(t)}' on a read-only Matcher.`)},deleteProperty(e,t){throw TypeError(`Cannot delete property '${String(t)}' from a read-only Matcher.`)}})}};function pf(e,t){if(!e)return{};let n=t.attributesGroupName?e[t.attributesGroupName]:e;if(!n)return{};let r={};for(let e in n)if(e.startsWith(t.attributeNamePrefix)){let i=e.substring(t.attributeNamePrefix.length);r[i]=n[e]}else r[e]=n[e];return r}function mf(e){if(!e||typeof e!=`string`)return;let t=e.indexOf(`:`);if(t!==-1&&t>0){let n=e.substring(0,t);if(n!==`xmlns`)return n}}var hf=class{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:`'`},gt:{regex:/&(gt|#62|#x3E);/g,val:`>`},lt:{regex:/&(lt|#60|#x3C);/g,val:`<`},quot:{regex:/&(quot|#34|#x22);/g,val:`"`}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:`&`},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:` `},cent:{regex:/&(cent|#162);/g,val:`¢`},pound:{regex:/&(pound|#163);/g,val:`£`},yen:{regex:/&(yen|#165);/g,val:`¥`},euro:{regex:/&(euro|#8364);/g,val:`€`},copyright:{regex:/&(copy|#169);/g,val:`©`},reg:{regex:/&(reg|#174);/g,val:`®`},inr:{regex:/&(inr|#8377);/g,val:`₹`},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>jf(t,10,`&#`)},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>jf(t,16,`&#x`)}},this.addExternalEntities=gf,this.parseXml=xf,this.parseTextData=_f,this.resolveNameSpace=vf,this.buildAttributesMap=bf,this.isItStopNode=Tf,this.replaceEntitiesValue=Cf,this.readStopNodeData=kf,this.saveTextToParentTag=wf,this.addChild=Sf,this.ignoreAttributesFn=lf(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new ff,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodeExpressions=[];for(let e=0;e0)){o||(e=this.replaceEntitiesValue(e,t,n));let r=this.options.jPath?n.toString():n,s=this.options.tagValueProcessor(t,e,r,i,a);return s==null?e:typeof s!=typeof e||s!==e?s:this.options.trimValues||e.trim()===e?Af(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function vf(e){if(this.options.removeNSPrefix){let t=e.split(`:`),n=e.charAt(0)===`/`?`/`:``;if(t[0]===`xmlns`)return``;t.length===2&&(e=n+t[1])}return e}const yf=RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,`gm`);function bf(e,t,n){if(this.options.ignoreAttributes!==!0&&typeof e==`string`){let r=Sd(e,yf),i=r.length,a={},o={};for(let e=0;e0&&typeof t==`object`&&t.updateCurrent&&t.updateCurrent(o);for(let e=0;e`,a,`Closing Tag is not closed.`),i=e.substring(a+2,t).trim();if(this.options.removeNSPrefix){let e=i.indexOf(`:`);e!==-1&&(i=i.substr(e+1))}i=Mf(this.options.transformTagName,i,``,this.options).tagName,n&&(r=this.saveTextToParentTag(r,n,this.readonlyMatcher));let o=this.matcher.getCurrentTag();if(i&&this.options.unpairedTags.indexOf(i)!==-1)throw Error(`Unpaired tag can not be used as closing tag: `);o&&this.options.unpairedTags.indexOf(o)!==-1&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,n=this.tagsNodeStack.pop(),r=``,a=t}else if(e[a+1]===`?`){let t=Of(e,a,!1,`?>`);if(!t)throw Error(`Pi Tag is not closed.`);if(r=this.saveTextToParentTag(r,n,this.readonlyMatcher),!(this.options.ignoreDeclaration&&t.tagName===`?xml`||this.options.ignorePiTags)){let e=new Jd(t.tagName);e.add(this.options.textNodeName,``),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[`:@`]=this.buildAttributesMap(t.tagExp,this.matcher,t.tagName)),this.addChild(n,e,this.readonlyMatcher,a)}a=t.closeIndex+1}else if(e.substr(a+1,3)===`!--`){let t=Df(e,`-->`,a+4,`Comment is not closed.`);if(this.options.commentPropName){let i=e.substring(a+4,t-2);r=this.saveTextToParentTag(r,n,this.readonlyMatcher),n.add(this.options.commentPropName,[{[this.options.textNodeName]:i}])}a=t}else if(e.substr(a+1,2)===`!D`){let t=i.readDocType(e,a);this.docTypeEntities=t.entities,a=t.i}else if(e.substr(a+1,2)===`![`){let t=Df(e,`]]>`,a,`CDATA is not closed.`)-2,i=e.substring(a+9,t);r=this.saveTextToParentTag(r,n,this.readonlyMatcher);let o=this.parseTextData(i,n.tagname,this.readonlyMatcher,!0,!1,!0,!0);o??=``,this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:i}]):n.add(this.options.textNodeName,o),a=t+2}else{let i=Of(e,a,this.options.removeNSPrefix);if(!i){let t=e.substring(Math.max(0,a-50),Math.min(e.length,a+50));throw Error(`readTagExp returned undefined at position ${a}. Context: "${t}"`)}let o=i.tagName,s=i.rawTagName,c=i.tagExp,l=i.attrExpPresent,u=i.closeIndex;if({tagName:o,tagExp:c}=Mf(this.options.transformTagName,o,c,this.options),this.options.strictReservedNames&&(o===this.options.commentPropName||o===this.options.cdataPropName||o===this.options.textNodeName||o===this.options.attributesGroupName))throw Error(`Invalid tag name: ${o}`);n&&r&&n.tagname!==`!xml`&&(r=this.saveTextToParentTag(r,n,this.readonlyMatcher,!1));let d=n;d&&this.options.unpairedTags.indexOf(d.tagname)!==-1&&(n=this.tagsNodeStack.pop(),this.matcher.pop());let f=!1;c.length>0&&c.lastIndexOf(`/`)===c.length-1&&(f=!0,o[o.length-1]===`/`?(o=o.substr(0,o.length-1),c=o):c=c.substr(0,c.length-1),l=o!==c);let p=null,m;m=mf(s),o!==t.tagname&&this.matcher.push(o,{},m),o!==c&&l&&(p=this.buildAttributesMap(c,this.matcher,o),p&&pf(p,this.options)),o!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode(this.stopNodeExpressions,this.matcher));let h=a;if(this.isCurrentNodeStopNode){let t=``;if(f)a=i.closeIndex;else if(this.options.unpairedTags.indexOf(o)!==-1)a=i.closeIndex;else{let n=this.readStopNodeData(e,s,u+1);if(!n)throw Error(`Unexpected end of ${s}`);a=n.i,t=n.tagContent}let r=new Jd(o);p&&(r[`:@`]=p),r.add(this.options.textNodeName,t),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(n,r,this.readonlyMatcher,h)}else{if(f){({tagName:o,tagExp:c}=Mf(this.options.transformTagName,o,c,this.options));let e=new Jd(o);p&&(e[`:@`]=p),this.addChild(n,e,this.readonlyMatcher,h),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(this.options.unpairedTags.indexOf(o)!==-1){let e=new Jd(o);p&&(e[`:@`]=p),this.addChild(n,e,this.readonlyMatcher,h),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=i.closeIndex;continue}else{let e=new Jd(o);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw Error(`Maximum nested tags exceeded`);this.tagsNodeStack.push(n),p&&(e[`:@`]=p),this.addChild(n,e,this.readonlyMatcher,h),n=e}r=``,a=u}}else r+=e[a];return t.child};function Sf(e,t,n,r){this.options.captureMetaData||(r=void 0);let i=this.options.jPath?n.toString():n,a=this.options.updateTag(t.tagname,i,t[`:@`]);a===!1||(typeof a==`string`&&(t.tagname=a),e.addChild(t,r))}function Cf(e,t,n){let r=this.options.processEntities;if(!r||!r.enabled)return e;if(r.allowedTags){let i=this.options.jPath?n.toString():n;if(!(Array.isArray(r.allowedTags)?r.allowedTags.includes(t):r.allowedTags(t,i)))return e}if(r.tagFilter){let i=this.options.jPath?n.toString():n;if(!r.tagFilter(t,i))return e}for(let t of Object.keys(this.docTypeEntities)){let n=this.docTypeEntities[t],i=e.match(n.regx);if(i){if(this.entityExpansionCount+=i.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions)throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);let t=e.length;if(e=e.replace(n.regx,n.val),r.maxExpandedLength&&(this.currentExpandedLength+=e.length-t,this.currentExpandedLength>r.maxExpandedLength))throw Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${r.maxExpandedLength}`)}}for(let t of Object.keys(this.lastEntities)){let n=this.lastEntities[t],i=e.match(n.regex);if(i&&(this.entityExpansionCount+=i.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions))throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);e=e.replace(n.regex,n.val)}if(e.indexOf(`&`)===-1)return e;if(this.options.htmlEntities)for(let t of Object.keys(this.htmlEntities)){let n=this.htmlEntities[t],i=e.match(n.regex);if(i&&(this.entityExpansionCount+=i.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions))throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);e=e.replace(n.regex,n.val)}return e=e.replace(this.ampEntity.regex,this.ampEntity.val),e}function wf(e,t,n,r){return e&&=(r===void 0&&(r=t.child.length===0),e=this.parseTextData(e,t.tagname,n,!1,t[`:@`]?Object.keys(t[`:@`]).length!==0:!1,r),e!==void 0&&e!==``&&t.add(this.options.textNodeName,e),``),e}function Tf(e,t){if(!e||e.length===0)return!1;for(let n=0;n`){let r,i=``;for(let a=t;a`){let i=Ef(e,t+1,r);if(!i)return;let a=i.data,o=i.index,s=a.search(/\s/),c=a,l=!0;s!==-1&&(c=a.substring(0,s),a=a.substring(s+1).trimStart());let u=c;if(n){let e=c.indexOf(`:`);e!==-1&&(c=c.substr(e+1),l=c!==i.data.substr(e+1))}return{tagName:c,tagExp:a,closeIndex:o,attrExpPresent:l,rawTagName:u}}function kf(e,t,n){let r=n,i=1;for(;n`,n,`${t} is not closed`);if(e.substring(n+2,a).trim()===t&&(i--,i===0))return{tagContent:e.substring(r,n),i:a};n=a}else if(e[n+1]===`?`)n=Df(e,`?>`,n+1,`StopNode is not closed.`);else if(e.substr(n+1,3)===`!--`)n=Df(e,`-->`,n+3,`StopNode is not closed.`);else if(e.substr(n+1,2)===`![`)n=Df(e,`]]>`,n,`StopNode is not closed.`)-2;else{let r=Of(e,n,`>`);r&&((r&&r.tagName)===t&&r.tagExp[r.tagExp.length-1]!==`/`&&i++,n=r.closeIndex)}}function Af(e,t,n){if(t&&typeof e==`string`){let t=e.trim();return t===`true`?!0:t===`false`?!1:nf(e,n)}else if(wd(e))return e;else return``}function jf(e,t,n){let r=Number.parseInt(e,t);return r>=0&&r<=1114111?String.fromCodePoint(r):n+e+`;`}function Mf(e,t,n,r){if(e){let r=e(t);n===t&&(n=r),t=r}return t=Nf(t,r),{tagName:t,tagExp:n}}function Nf(e,t){if(Ed.includes(e))throw Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return Td.includes(e)?t.onDangerousProperty(e):e}const Pf=Jd.getMetaDataSymbol();function Ff(e,t){if(!e||typeof e!=`object`)return{};if(!t)return e;let n={};for(let r in e)if(r.startsWith(t)){let i=r.substring(t.length);n[i]=e[r]}else n[r]=e[r];return n}function If(e,t,n,r){return Lf(e,t,n,r)}function Lf(e,t,n,r){let i,a={};for(let o=0;o0&&(a[t.textNodeName]=i):i!==void 0&&(a[t.textNodeName]=i),a}function Rf(e){let t=Object.keys(e);for(let e=0;e0&&(n=` `);let r=[];if(t.stopNodes&&Array.isArray(t.stopNodes))for(let e=0;et.maxNestedTags)throw Error(`Maximum nested tags exceeded`);if(!Array.isArray(e)){if(e!=null){let n=e.toString();return n=Xf(n,t),n}return``}for(let s=0;s`,o=!1,r.pop();continue}else if(l===t.commentPropName){a+=n+``,o=!0,r.pop();continue}else if(l[0]===`?`){let e=Jf(c[`:@`],t,d),i=l===`?xml`?``:n,s=c[l][0][t.textNodeName];s=s.length===0?``:` `+s,a+=i+`<${l}${s}${e}?>`,o=!0,r.pop();continue}let f=n;f!==``&&(f+=t.indentBy);let p=n+`<${l}${Jf(c[`:@`],t,d)}`,m;m=d?Gf(c[l],t):Uf(c[l],t,f,r,i),t.unpairedTags.indexOf(l)===-1?(!m||m.length===0)&&t.suppressEmptyNode?a+=p+`/>`:m&&m.endsWith(`>`)?a+=p+`>${m}${n}`:(a+=p+`>`,m&&n!==``&&(m.includes(`/>`)||m.includes(``):t.suppressUnpairedNode?a+=p+`>`:a+=p+`/>`,o=!0,r.pop()}return a}function Wf(e,t){if(!e||t.ignoreAttributes)return null;let n={},r=!1;for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let a=i.startsWith(t.attributeNamePrefix)?i.substr(t.attributeNamePrefix.length):i;n[a]=e[i],r=!0}return r?n:null}function Gf(e,t){if(!Array.isArray(e))return e==null?``:e.toString();let n=``;for(let r=0;r`:n+=`<${a}${e}>${r}`}}return n}function Kf(e,t){let n=``;if(e&&!t.ignoreAttributes)for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=e[r];i===!0&&t.suppressBooleanAttributes?n+=` ${r.substr(t.attributeNamePrefix.length)}`:n+=` ${r.substr(t.attributeNamePrefix.length)}="${i}"`}return n}function qf(e){let t=Object.keys(e);for(let n=0;n0&&t.processEntities)for(let n=0;n{for(let n of e)if(typeof n==`string`&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}const Qf={attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:` `,suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:RegExp(`&`,`g`),val:`&`},{regex:RegExp(`>`,`g`),val:`>`},{regex:RegExp(`<`,`g`),val:`<`},{regex:RegExp(`'`,`g`),val:`'`},{regex:RegExp(`"`,`g`),val:`"`}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0};function $f(e){if(this.options=Object.assign({},Qf,e),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(e=>typeof e==`string`&&e.startsWith(`*.`)?`..`+e.substring(2):e)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let e=0;e `,this.newLine=` diff --git a/dist/main.js b/dist/main.js index 5e8af93a..b86b561c 100644 --- a/dist/main.js +++ b/dist/main.js @@ -1,4 +1,4 @@ -import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,N as f,O as p,P as m,R as h,S as g,T as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_ as w,a as T,b as E,c as D,d as O,f as k,g as ee,h as te,i as ne,j as A,k as j,l as re,m as ie,n as ae,o as oe,p as se,q as ce,r as le,s as ue,t as de,u as fe,v as pe,w as me,x as he,y as ge,z as M}from"./cache-CqdRyjOf.js";import N from"node:process";import*as _e from"os";import{EOL as ve}from"os";import*as ye from"crypto";import*as P from"fs";import{existsSync as be,readFileSync as xe}from"fs";import*as F from"path";import{ok as Se}from"assert";import*as Ce from"util";import{Buffer as we}from"node:buffer";import*as Te from"node:crypto";import{createHash as Ee}from"node:crypto";import{pathToFileURL as De}from"node:url";import*as I from"node:fs/promises";import Oe from"node:fs/promises";import*as L from"node:path";import ke,{join as Ae}from"node:path";import{spawn as je}from"node:child_process";import*as Me from"node:os";import Ne,{homedir as Pe}from"node:os";import*as Fe from"stream";function Ie(e){switch(e){case`hit`:return`✅ hit`;case`miss`:return`🆕 miss`;case`corrupted`:return`⚠️ corrupted (clean start)`}}function Le(e){let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}async function Re(e,t){let{eventType:n,repo:i,ref:a,runId:s,runUrl:c,metrics:l,agent:u}=e;try{if(o.addHeading(`Fro Bot Agent Run`,2).addTable([[{data:`Field`,header:!0},{data:`Value`,header:!0}],[`Event`,n],[`Repository`,i],[`Ref`,a],[`Run ID`,`[${s}](${c})`],[`Agent`,u],[`Cache Status`,Ie(l.cacheStatus)],[`Duration`,l.duration==null?`N/A`:Le(l.duration)]]),(l.sessionsUsed.length>0||l.sessionsCreated.length>0)&&(o.addHeading(`Sessions`,3),l.sessionsUsed.length>0&&o.addRaw(`**Used:** ${l.sessionsUsed.join(`, `)}\n`),l.sessionsCreated.length>0&&o.addRaw(`**Created:** ${l.sessionsCreated.join(`, `)}\n`)),l.tokenUsage!=null&&(o.addHeading(`Token Usage`,3),o.addTable([[{data:`Metric`,header:!0},{data:`Count`,header:!0}],[`Input`,l.tokenUsage.input.toLocaleString()],[`Output`,l.tokenUsage.output.toLocaleString()],[`Reasoning`,l.tokenUsage.reasoning.toLocaleString()],[`Cache Read`,l.tokenUsage.cache.read.toLocaleString()],[`Cache Write`,l.tokenUsage.cache.write.toLocaleString()]]),l.model!=null&&o.addRaw(`**Model:** ${l.model}\n`),l.cost!=null&&o.addRaw(`**Cost:** $${l.cost.toFixed(4)}\n`)),(l.prsCreated.length>0||l.commitsCreated.length>0||l.commentsPosted>0)&&(o.addHeading(`Created Artifacts`,3),l.prsCreated.length>0&&o.addList([...l.prsCreated]),l.commitsCreated.length>0&&o.addList(l.commitsCreated.map(e=>`Commit \`${e.slice(0,7)}\``)),l.commentsPosted>0&&o.addRaw(`**Comments Posted:** ${l.commentsPosted}\n`)),l.errors.length>0){o.addHeading(`Errors`,3);for(let e of l.errors){let t=e.recoverable?`🔄 Recovered`:`❌ Failed`;o.addRaw(`- **${e.type}** (${t}): ${e.message}\n`)}}await o.write(),t.debug(`Wrote job summary`)}catch(e){let n=r(e);t.warning(`Failed to write job summary`,{error:n}),h(`Failed to write job summary: ${n}`)}}function ze(){let e=0,t=null,n=`miss`,r=[],i=[],a=[],o=[],s=0,c=null,l=null,u=null,d=[];return{start(){e=Date.now()},end(){t=Date.now()},setCacheStatus(e){n=e},addSessionUsed(e){r.includes(e)||r.push(e)},addSessionCreated(e){i.includes(e)||i.push(e)},addPRCreated(e){a.includes(e)||a.push(e)},addCommitCreated(e){o.includes(e)||o.push(e)},incrementComments(){s++},setTokenUsage(e,t,n){c=e,l=t,u=n},recordError(e,t,n){d.push({timestamp:new Date().toISOString(),type:e,message:t,recoverable:n})},getMetrics(){let f=t==null?Date.now()-e:t-e;return Object.freeze({startTime:e,endTime:t,duration:f,cacheStatus:n,sessionsUsed:Object.freeze([...r]),sessionsCreated:Object.freeze([...i]),prsCreated:Object.freeze([...a]),commitsCreated:Object.freeze([...o]),commentsPosted:s,tokenUsage:c,model:l,cost:u,errors:Object.freeze([...d])})}}}function Be(e){d(`session-id`,e.sessionId??``),d(`cache-status`,e.cacheStatus),d(`duration`,e.duration)}function R(e){let[t,n]=e.split(`/`);if(t==null||n==null||t.length===0||n.length===0)throw Error(`Invalid repository string: ${e}`);return{owner:t,repo:n}}async function Ve(e,t,n,i,a){try{let{owner:r,repo:o}=R(t),{data:s}=await e.rest.reactions.createForIssueComment({owner:r,repo:o,comment_id:n,content:i});return a.debug(`Created comment reaction`,{commentId:n,content:i,reactionId:s.id}),{id:s.id}}catch(e){return a.warning(`Failed to create comment reaction`,{commentId:n,content:i,error:r(e)}),null}}async function He(e,t,n,i){try{let{owner:r,repo:i}=R(t),{data:a}=await e.rest.reactions.listForIssueComment({owner:r,repo:i,comment_id:n,per_page:100});return a.map(e=>({id:e.id,content:e.content,userLogin:e.user?.login??null}))}catch(e){return i.warning(`Failed to list comment reactions`,{commentId:n,error:r(e)}),[]}}async function Ue(e,t,n,i,a){try{let{owner:r,repo:o}=R(t);return await e.rest.reactions.deleteForIssueComment({owner:r,repo:o,comment_id:n,reaction_id:i}),a.debug(`Deleted comment reaction`,{commentId:n,reactionId:i}),!0}catch(e){return a.warning(`Failed to delete comment reaction`,{commentId:n,reactionId:i,error:r(e)}),!1}}async function We(e,t,n,i,a,o){let{owner:s,repo:c}=R(t);try{return await e.rest.issues.createLabel({owner:s,repo:c,name:n,color:i,description:a}),o.debug(`Created label`,{name:n,color:i}),!0}catch(e){return e instanceof Error&&`status`in e&&e.status===422?(o.debug(`Label already exists`,{name:n}),!0):(o.warning(`Failed to create label`,{name:n,error:r(e)}),!1)}}async function Ge(e,t,n,i,a){try{let{owner:r,repo:o}=R(t);return await e.rest.issues.addLabels({owner:r,repo:o,issue_number:n,labels:[...i]}),a.debug(`Added labels to issue`,{issueNumber:n,labels:i}),!0}catch(e){return a.warning(`Failed to add labels to issue`,{issueNumber:n,labels:i,error:r(e)}),!1}}async function Ke(e,t,n,i,a){try{let{owner:r,repo:o}=R(t);return await e.rest.issues.removeLabel({owner:r,repo:o,issue_number:n,name:i}),a.debug(`Removed label from issue`,{issueNumber:n,label:i}),!0}catch(e){return e instanceof Error&&`status`in e&&e.status===404?(a.debug(`Label was not present on issue`,{issueNumber:n,label:i}),!0):(a.warning(`Failed to remove label from issue`,{issueNumber:n,label:i,error:r(e)}),!1)}}async function qe(e,t,n){try{let{owner:n,repo:r}=R(t),{data:i}=await e.rest.repos.get({owner:n,repo:r});return i.default_branch}catch(e){return n.warning(`Failed to get default branch`,{repo:t,error:r(e)}),`main`}}const Je={admin:`OWNER`,maintain:`MEMBER`,write:`COLLABORATOR`,triage:`COLLABORATOR`};async function Ye(e,t,n,i,a){try{let{data:r}=await e.rest.repos.getCollaboratorPermissionLevel({owner:t,repo:n,username:i}),o=Je[r.permission]??null;return a.debug(`Resolved sender permission`,{username:i,permission:r.permission,association:o}),o}catch(e){return a.warning(`Failed to resolve sender permission`,{username:i,error:r(e)}),null}}async function Xe(e,t,n){try{let{data:n}=await e.rest.users.getByUsername({username:t});return{id:n.id,login:n.login}}catch(e){return n.debug(`Failed to get user by username`,{username:t,error:r(e)}),null}}const Ze={maxComments:50,maxCommits:100,maxFiles:100,maxReviews:100,maxBodyBytes:10*1024,maxTotalBytes:100*1024},Qe=`…[truncated]`;function $e(e,t){if(e.length===0)return{text:``,truncated:!1};let n=new TextEncoder,r=n.encode(e);if(r.length<=t)return{text:e,truncated:!1};let i=t-n.encode(Qe).length;if(i<=0)return{text:Qe,truncated:!0};let a=r.slice(0,i),o=new TextDecoder(`utf-8`,{fatal:!1}).decode(a);for(;o.length>0&&o.charCodeAt(o.length-1)===65533;)a=a.slice(0,-1),o=new TextDecoder(`utf-8`,{fatal:!1}).decode(a);return{text:o+Qe,truncated:!0}}function et(e){return e.length===0?``:`**Labels:** ${e.map(e=>`\`${e.name}\``).join(`, `)}\n`}function tt(e){return e.length===0?``:`**Assignees:** ${e.map(e=>`@${e.login}`).join(`, `)}\n`}function nt(e){let t=[];t.push(`## Issue #${e.number}`),t.push(``),t.push(`**Title:** ${e.title}`),t.push(`**State:** ${e.state}`),t.push(`**Author:** ${e.author??`unknown`}`),t.push(`**Created:** ${e.createdAt}`);let n=et(e.labels);n.length>0&&t.push(n.trimEnd());let r=tt(e.assignees);if(r.length>0&&t.push(r.trimEnd()),t.push(``),t.push(`### Body`),t.push(``),t.push(e.body),e.bodyTruncated&&(t.push(``),t.push(`*Note: Body was truncated due to size limits.*`)),e.comments.length>0){t.push(``),t.push(`### Comments (${e.comments.length}${e.commentsTruncated?` of ${e.totalComments}`:``})`),e.commentsTruncated&&(t.push(``),t.push(`*Note: Comments were truncated due to limits.*`)),t.push(``);for(let n of e.comments)t.push(`**${n.author??`unknown`}** (${n.createdAt}):`),t.push(n.body),t.push(``)}return t.join(` +import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,N as f,O as p,P as m,R as h,S as g,T as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_ as w,a as T,b as E,c as D,d as O,f as k,g as ee,h as te,i as ne,j as A,k as j,l as re,m as ie,n as ae,o as oe,p as se,q as ce,r as le,s as ue,t as de,u as fe,v as pe,w as me,x as he,y as ge,z as M}from"./cache-H1aH1Xpr.js";import N from"node:process";import*as _e from"os";import{EOL as ve}from"os";import*as ye from"crypto";import*as P from"fs";import{existsSync as be,readFileSync as xe}from"fs";import*as F from"path";import{ok as Se}from"assert";import*as Ce from"util";import{Buffer as we}from"node:buffer";import*as Te from"node:crypto";import{createHash as Ee}from"node:crypto";import{pathToFileURL as De}from"node:url";import*as I from"node:fs/promises";import Oe from"node:fs/promises";import*as L from"node:path";import ke,{join as Ae}from"node:path";import{spawn as je}from"node:child_process";import*as Me from"node:os";import Ne,{homedir as Pe}from"node:os";import*as Fe from"stream";function Ie(e){switch(e){case`hit`:return`✅ hit`;case`miss`:return`🆕 miss`;case`corrupted`:return`⚠️ corrupted (clean start)`}}function Le(e){let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}async function Re(e,t){let{eventType:n,repo:i,ref:a,runId:s,runUrl:c,metrics:l,agent:u}=e;try{if(o.addHeading(`Fro Bot Agent Run`,2).addTable([[{data:`Field`,header:!0},{data:`Value`,header:!0}],[`Event`,n],[`Repository`,i],[`Ref`,a],[`Run ID`,`[${s}](${c})`],[`Agent`,u],[`Cache Status`,Ie(l.cacheStatus)],[`Duration`,l.duration==null?`N/A`:Le(l.duration)]]),(l.sessionsUsed.length>0||l.sessionsCreated.length>0)&&(o.addHeading(`Sessions`,3),l.sessionsUsed.length>0&&o.addRaw(`**Used:** ${l.sessionsUsed.join(`, `)}\n`),l.sessionsCreated.length>0&&o.addRaw(`**Created:** ${l.sessionsCreated.join(`, `)}\n`)),l.tokenUsage!=null&&(o.addHeading(`Token Usage`,3),o.addTable([[{data:`Metric`,header:!0},{data:`Count`,header:!0}],[`Input`,l.tokenUsage.input.toLocaleString()],[`Output`,l.tokenUsage.output.toLocaleString()],[`Reasoning`,l.tokenUsage.reasoning.toLocaleString()],[`Cache Read`,l.tokenUsage.cache.read.toLocaleString()],[`Cache Write`,l.tokenUsage.cache.write.toLocaleString()]]),l.model!=null&&o.addRaw(`**Model:** ${l.model}\n`),l.cost!=null&&o.addRaw(`**Cost:** $${l.cost.toFixed(4)}\n`)),(l.prsCreated.length>0||l.commitsCreated.length>0||l.commentsPosted>0)&&(o.addHeading(`Created Artifacts`,3),l.prsCreated.length>0&&o.addList([...l.prsCreated]),l.commitsCreated.length>0&&o.addList(l.commitsCreated.map(e=>`Commit \`${e.slice(0,7)}\``)),l.commentsPosted>0&&o.addRaw(`**Comments Posted:** ${l.commentsPosted}\n`)),l.errors.length>0){o.addHeading(`Errors`,3);for(let e of l.errors){let t=e.recoverable?`🔄 Recovered`:`❌ Failed`;o.addRaw(`- **${e.type}** (${t}): ${e.message}\n`)}}await o.write(),t.debug(`Wrote job summary`)}catch(e){let n=r(e);t.warning(`Failed to write job summary`,{error:n}),h(`Failed to write job summary: ${n}`)}}function ze(){let e=0,t=null,n=`miss`,r=[],i=[],a=[],o=[],s=0,c=null,l=null,u=null,d=[];return{start(){e=Date.now()},end(){t=Date.now()},setCacheStatus(e){n=e},addSessionUsed(e){r.includes(e)||r.push(e)},addSessionCreated(e){i.includes(e)||i.push(e)},addPRCreated(e){a.includes(e)||a.push(e)},addCommitCreated(e){o.includes(e)||o.push(e)},incrementComments(){s++},setTokenUsage(e,t,n){c=e,l=t,u=n},recordError(e,t,n){d.push({timestamp:new Date().toISOString(),type:e,message:t,recoverable:n})},getMetrics(){let f=t==null?Date.now()-e:t-e;return Object.freeze({startTime:e,endTime:t,duration:f,cacheStatus:n,sessionsUsed:Object.freeze([...r]),sessionsCreated:Object.freeze([...i]),prsCreated:Object.freeze([...a]),commitsCreated:Object.freeze([...o]),commentsPosted:s,tokenUsage:c,model:l,cost:u,errors:Object.freeze([...d])})}}}function Be(e){d(`session-id`,e.sessionId??``),d(`cache-status`,e.cacheStatus),d(`duration`,e.duration)}function R(e){let[t,n]=e.split(`/`);if(t==null||n==null||t.length===0||n.length===0)throw Error(`Invalid repository string: ${e}`);return{owner:t,repo:n}}async function Ve(e,t,n,i,a){try{let{owner:r,repo:o}=R(t),{data:s}=await e.rest.reactions.createForIssueComment({owner:r,repo:o,comment_id:n,content:i});return a.debug(`Created comment reaction`,{commentId:n,content:i,reactionId:s.id}),{id:s.id}}catch(e){return a.warning(`Failed to create comment reaction`,{commentId:n,content:i,error:r(e)}),null}}async function He(e,t,n,i){try{let{owner:r,repo:i}=R(t),{data:a}=await e.rest.reactions.listForIssueComment({owner:r,repo:i,comment_id:n,per_page:100});return a.map(e=>({id:e.id,content:e.content,userLogin:e.user?.login??null}))}catch(e){return i.warning(`Failed to list comment reactions`,{commentId:n,error:r(e)}),[]}}async function Ue(e,t,n,i,a){try{let{owner:r,repo:o}=R(t);return await e.rest.reactions.deleteForIssueComment({owner:r,repo:o,comment_id:n,reaction_id:i}),a.debug(`Deleted comment reaction`,{commentId:n,reactionId:i}),!0}catch(e){return a.warning(`Failed to delete comment reaction`,{commentId:n,reactionId:i,error:r(e)}),!1}}async function We(e,t,n,i,a,o){let{owner:s,repo:c}=R(t);try{return await e.rest.issues.createLabel({owner:s,repo:c,name:n,color:i,description:a}),o.debug(`Created label`,{name:n,color:i}),!0}catch(e){return e instanceof Error&&`status`in e&&e.status===422?(o.debug(`Label already exists`,{name:n}),!0):(o.warning(`Failed to create label`,{name:n,error:r(e)}),!1)}}async function Ge(e,t,n,i,a){try{let{owner:r,repo:o}=R(t);return await e.rest.issues.addLabels({owner:r,repo:o,issue_number:n,labels:[...i]}),a.debug(`Added labels to issue`,{issueNumber:n,labels:i}),!0}catch(e){return a.warning(`Failed to add labels to issue`,{issueNumber:n,labels:i,error:r(e)}),!1}}async function Ke(e,t,n,i,a){try{let{owner:r,repo:o}=R(t);return await e.rest.issues.removeLabel({owner:r,repo:o,issue_number:n,name:i}),a.debug(`Removed label from issue`,{issueNumber:n,label:i}),!0}catch(e){return e instanceof Error&&`status`in e&&e.status===404?(a.debug(`Label was not present on issue`,{issueNumber:n,label:i}),!0):(a.warning(`Failed to remove label from issue`,{issueNumber:n,label:i,error:r(e)}),!1)}}async function qe(e,t,n){try{let{owner:n,repo:r}=R(t),{data:i}=await e.rest.repos.get({owner:n,repo:r});return i.default_branch}catch(e){return n.warning(`Failed to get default branch`,{repo:t,error:r(e)}),`main`}}const Je={admin:`OWNER`,maintain:`MEMBER`,write:`COLLABORATOR`,triage:`COLLABORATOR`};async function Ye(e,t,n,i,a){try{let{data:r}=await e.rest.repos.getCollaboratorPermissionLevel({owner:t,repo:n,username:i}),o=Je[r.permission]??null;return a.debug(`Resolved sender permission`,{username:i,permission:r.permission,association:o}),o}catch(e){return a.warning(`Failed to resolve sender permission`,{username:i,error:r(e)}),null}}async function Xe(e,t,n){try{let{data:n}=await e.rest.users.getByUsername({username:t});return{id:n.id,login:n.login}}catch(e){return n.debug(`Failed to get user by username`,{username:t,error:r(e)}),null}}const Ze={maxComments:50,maxCommits:100,maxFiles:100,maxReviews:100,maxBodyBytes:10*1024,maxTotalBytes:100*1024},Qe=`…[truncated]`;function $e(e,t){if(e.length===0)return{text:``,truncated:!1};let n=new TextEncoder,r=n.encode(e);if(r.length<=t)return{text:e,truncated:!1};let i=t-n.encode(Qe).length;if(i<=0)return{text:Qe,truncated:!0};let a=r.slice(0,i),o=new TextDecoder(`utf-8`,{fatal:!1}).decode(a);for(;o.length>0&&o.charCodeAt(o.length-1)===65533;)a=a.slice(0,-1),o=new TextDecoder(`utf-8`,{fatal:!1}).decode(a);return{text:o+Qe,truncated:!0}}function et(e){return e.length===0?``:`**Labels:** ${e.map(e=>`\`${e.name}\``).join(`, `)}\n`}function tt(e){return e.length===0?``:`**Assignees:** ${e.map(e=>`@${e.login}`).join(`, `)}\n`}function nt(e){let t=[];t.push(`## Issue #${e.number}`),t.push(``),t.push(`**Title:** ${e.title}`),t.push(`**State:** ${e.state}`),t.push(`**Author:** ${e.author??`unknown`}`),t.push(`**Created:** ${e.createdAt}`);let n=et(e.labels);n.length>0&&t.push(n.trimEnd());let r=tt(e.assignees);if(r.length>0&&t.push(r.trimEnd()),t.push(``),t.push(`### Body`),t.push(``),t.push(e.body),e.bodyTruncated&&(t.push(``),t.push(`*Note: Body was truncated due to size limits.*`)),e.comments.length>0){t.push(``),t.push(`### Comments (${e.comments.length}${e.commentsTruncated?` of ${e.totalComments}`:``})`),e.commentsTruncated&&(t.push(``),t.push(`*Note: Comments were truncated due to limits.*`)),t.push(``);for(let n of e.comments)t.push(`**${n.author??`unknown`}** (${n.createdAt}):`),t.push(n.body),t.push(``)}return t.join(` `)}function rt(e){let t=[];t.push(`## Pull Request #${e.number}`),t.push(``),t.push(`**Title:** ${e.title}`),t.push(`**State:** ${e.state}`),t.push(`**Author:** ${e.author??`unknown`}`),t.push(`**Created:** ${e.createdAt}`),t.push(`**Base:** ${e.baseBranch} ← **Head:** ${e.headBranch}`),e.isFork&&t.push(`**Fork:** Yes (external contributor)`);let n=et(e.labels);n.length>0&&t.push(n.trimEnd());let r=tt(e.assignees);if(r.length>0&&t.push(r.trimEnd()),t.push(``),t.push(`### Description`),t.push(``),t.push(e.body),e.bodyTruncated&&(t.push(``),t.push(`*Note: Description was truncated due to size limits.*`)),e.files.length>0){t.push(``),t.push(`### Files Changed (${e.files.length}${e.filesTruncated?` of ${e.totalFiles}`:``})`),t.push(``),t.push(`| File | +/- |`),t.push(`|------|-----|`);for(let n of e.files)t.push(`| \`${n.path}\` | +${n.additions}/-${n.deletions} |`)}if(e.commits.length>0){t.push(``),t.push(`### Commits (${e.commits.length}${e.commitsTruncated?` of ${e.totalCommits}`:``})`),t.push(``);for(let n of e.commits){let e=n.oid.slice(0,7);t.push(`- \`${e}\` ${n.message.split(` `)[0]}`)}}if(e.reviews.length>0){t.push(``),t.push(`### Reviews (${e.reviews.length}${e.reviewsTruncated?` of ${e.totalReviews}`:``})`),t.push(``);for(let n of e.reviews)t.push(`**${n.author??`unknown`}** - ${n.state}`),n.body.length>0&&t.push(n.body),t.push(``)}if(e.comments.length>0){t.push(``),t.push(`### Comments (${e.comments.length}${e.commentsTruncated?` of ${e.totalComments}`:``})`),t.push(``);for(let n of e.comments)t.push(`**${n.author??`unknown`}** (${n.createdAt}):`),t.push(n.body),t.push(``)}return t.join(` `)}function it(e){return e.type===`issue`?nt(e):rt(e)}async function at(e,t,n,i,a,o){try{let[r,o]=await Promise.all([e.rest.issues.get({owner:t,repo:n,issue_number:i}),e.rest.issues.listComments({owner:t,repo:n,issue_number:i,per_page:a.maxComments})]),s=r.data,c=$e(s.body??``,a.maxBodyBytes),l=o.data.slice(0,a.maxComments).map(e=>({id:e.node_id??String(e.id),author:e.user?.login??null,body:e.body??``,createdAt:e.created_at,authorAssociation:e.author_association,isMinimized:!1})),u=(s.labels??[]).filter(e=>typeof e==`object`&&!!e&&`name`in e).map(e=>({name:e.name??``,color:e.color})),d=(s.assignees??[]).map(e=>({login:e?.login??``}));return{type:`issue`,number:s.number,title:s.title,body:c.text,bodyTruncated:c.truncated,state:s.state,author:s.user?.login??null,createdAt:s.created_at,labels:u,assignees:d,comments:l,commentsTruncated:o.data.length>=a.maxComments,totalComments:o.data.length}}catch(e){return o.warning(`REST issue fallback failed`,{owner:t,repo:n,number:i,error:r(e)}),null}}async function ot(e,t,n,i,a,o){try{let[s,c,l,u,d]=await Promise.all([e.rest.pulls.get({owner:t,repo:n,pull_number:i}),e.rest.pulls.listCommits({owner:t,repo:n,pull_number:i,per_page:a.maxCommits}),e.rest.pulls.listFiles({owner:t,repo:n,pull_number:i,per_page:a.maxFiles}),e.rest.pulls.listReviews({owner:t,repo:n,pull_number:i,per_page:a.maxReviews}),e.rest.issues.listComments({owner:t,repo:n,issue_number:i,per_page:a.maxComments})]),f=await e.rest.pulls.listRequestedReviewers({owner:t,repo:n,pull_number:i}).catch(e=>(o.warning(`Failed to fetch requested reviewers, defaulting to empty`,{owner:t,repo:n,number:i,error:r(e)}),{data:{users:[],teams:[]}})),p=s.data,m=$e(p.body??``,a.maxBodyBytes),h=p.base.repo?.owner.login,g=p.head.repo?.owner.login,_=g==null||h!==g,v=d.data.slice(0,a.maxComments).map(e=>({id:e.node_id??String(e.id),author:e.user?.login??null,body:e.body??``,createdAt:e.created_at,authorAssociation:e.author_association,isMinimized:!1})),y=c.data.slice(0,a.maxCommits).map(e=>({oid:e.sha,message:e.commit.message,author:e.commit.author?.name??null})),b=l.data.slice(0,a.maxFiles).map(e=>({path:e.filename,additions:e.additions,deletions:e.deletions,status:e.status})),x=u.data.slice(0,a.maxReviews).map(e=>({author:e.user?.login??null,state:e.state,body:e.body??``,createdAt:e.submitted_at??``,comments:[]})),S=(p.labels??[]).map(e=>({name:e.name??``,color:e.color})),C=(p.assignees??[]).map(e=>({login:e?.login??``})),w=(f.data.users??[]).map(e=>e.login),T=(f.data.teams??[]).map(e=>e.name);return{type:`pull_request`,number:p.number,title:p.title,body:m.text,bodyTruncated:m.truncated,state:p.state,author:p.user?.login??null,createdAt:p.created_at,baseBranch:p.base.ref,headBranch:p.head.ref,isFork:_,labels:S,assignees:C,comments:v,commentsTruncated:d.data.length>=a.maxComments,totalComments:d.data.length,commits:y,commitsTruncated:c.data.length>=a.maxCommits,totalCommits:c.data.length,files:b,filesTruncated:l.data.length>=a.maxFiles,totalFiles:l.data.length,reviews:x,reviewsTruncated:u.data.length>=a.maxReviews,totalReviews:u.data.length,authorAssociation:p.author_association,requestedReviewers:w,requestedReviewerTeams:T}}catch(e){return o.warning(`REST pull request fallback failed`,{owner:t,repo:n,number:i,error:r(e)}),null}}async function st(e,t,n,i,a,o){try{return await e.graphql(` diff --git a/dist/post.js b/dist/post.js index 83b402f4..da209ed4 100644 --- a/dist/post.js +++ b/dist/post.js @@ -1 +1 @@ -import{D as e,E as t,M as n,T as r,c as i,f as a,i as o,t as s,u as c}from"./cache-CqdRyjOf.js";async function l(l={}){let u=l.logger??t({phase:`post`}),d=n(r.SHOULD_SAVE_CACHE),f=n(r.CACHE_SAVED),p=n(r.SESSION_ID)||null,m=n(r.OPENCODE_VERSION)||null;if(u.debug(`Post-action state`,{shouldSaveCache:d,cacheSaved:f,sessionId:p,opencodeVersion:m}),d!==`true`){u.info(`Skipping post-action: event was not processed`,{shouldSaveCache:d});return}if(f===`true`){u.info(`Skipping post-action: cache already saved by main action`,{cacheSaved:f});return}try{await s({components:o(),runId:i(),logger:u,storagePath:a(),authPath:c(),opencodeVersion:m})?u.info(`Post-action cache saved`,{sessionId:p}):u.info(`Post-action: no cache content to save`,{sessionId:p})}catch(t){u.warning(`Post-action cache save failed (non-fatal)`,{error:e(t)})}}await l();export{}; \ No newline at end of file +import{D as e,E as t,M as n,T as r,c as i,f as a,i as o,t as s,u as c}from"./cache-H1aH1Xpr.js";async function l(l={}){let u=l.logger??t({phase:`post`}),d=n(r.SHOULD_SAVE_CACHE),f=n(r.CACHE_SAVED),p=n(r.SESSION_ID)||null,m=n(r.OPENCODE_VERSION)||null;if(u.debug(`Post-action state`,{shouldSaveCache:d,cacheSaved:f,sessionId:p,opencodeVersion:m}),d!==`true`){u.info(`Skipping post-action: event was not processed`,{shouldSaveCache:d});return}if(f===`true`){u.info(`Skipping post-action: cache already saved by main action`,{cacheSaved:f});return}try{await s({components:o(),runId:i(),logger:u,storagePath:a(),authPath:c(),opencodeVersion:m})?u.info(`Post-action cache saved`,{sessionId:p}):u.info(`Post-action: no cache content to save`,{sessionId:p})}catch(t){u.warning(`Post-action cache save failed (non-fatal)`,{error:e(t)})}}await l();export{}; \ No newline at end of file diff --git a/package.json b/package.json index b0125b51..d3e75328 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "read-package-up": "12.0.0", "semantic-release": "25.0.3", "simple-git-hooks": "2.13.1", - "tsdown": "0.21.4", + "tsdown": "0.21.5", "typescript": "5.9.3", "vitest": "4.1.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 46e45a26..fa35c8e1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -100,8 +100,8 @@ importers: specifier: 2.13.1 version: 2.13.1 tsdown: - specifier: 0.21.4 - version: 0.21.4(synckit@0.11.12)(typescript@5.9.3) + specifier: 0.21.5 + version: 0.21.5(synckit@0.11.12)(typescript@5.9.3) typescript: specifier: 5.9.3 version: 5.9.3 @@ -709,8 +709,8 @@ packages: resolution: {integrity: sha512-XRO0zi2NIUKq2lUk3T1ecFSld1fMWRKE6naRFGkgkdeosx7IslyUKNv5Dcb5PJTja9tHJoFu0v/7yEpAkrkrTg==} engines: {node: ^20.19.0 || ^22.13.0 || >=24} - '@oxc-project/types@0.115.0': - resolution: {integrity: sha512-4n91DKnebUS4yjUHl2g3/b2T+IUdCfmoZGhmwsovZCDaJSs+QkVAM+0AqqTxHSsHfeiMuueT75cZaZcT/m0pSw==} + '@oxc-project/types@0.122.0': + resolution: {integrity: sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA==} '@pkgr/core@0.2.9': resolution: {integrity: sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==} @@ -737,103 +737,201 @@ packages: '@quansync/fs@1.0.0': resolution: {integrity: sha512-4TJ3DFtlf1L5LDMaM6CanJ/0lckGNtJcMjQ1NAV6zDmA0tEHKZtxNKin8EgPaVX1YzljbxckyT2tJrpQKAtngQ==} - '@rolldown/binding-android-arm64@1.0.0-rc.9': - resolution: {integrity: sha512-lcJL0bN5hpgJfSIz/8PIf02irmyL43P+j1pTCfbD1DbLkmGRuFIA4DD3B3ZOvGqG0XiVvRznbKtN0COQVaKUTg==} + '@rolldown/binding-android-arm64@1.0.0-rc.11': + resolution: {integrity: sha512-SJ+/g+xNnOh6NqYxD0V3uVN4W3VfnrGsC9/hoglicgTNfABFG9JjISvkkU0dNY84MNHLWyOgxP9v9Y9pX4S7+A==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [android] - '@rolldown/binding-darwin-arm64@1.0.0-rc.9': - resolution: {integrity: sha512-J7Zk3kLYFsLtuH6U+F4pS2sYVzac0qkjcO5QxHS7OS7yZu2LRs+IXo+uvJ/mvpyUljDJ3LROZPoQfgBIpCMhdQ==} + '@rolldown/binding-android-arm64@1.0.0-rc.12': + resolution: {integrity: sha512-pv1y2Fv0JybcykuiiD3qBOBdz6RteYojRFY1d+b95WVuzx211CRh+ytI/+9iVyWQ6koTh5dawe4S/yRfOFjgaA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.0.0-rc.11': + resolution: {integrity: sha512-7WQgR8SfOPwmDZGFkThUvsmd/nwAWv91oCO4I5LS7RKrssPZmOt7jONN0cW17ydGC1n/+puol1IpoieKqQidmg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [darwin] - '@rolldown/binding-darwin-x64@1.0.0-rc.9': - resolution: {integrity: sha512-iwtmmghy8nhfRGeNAIltcNXzD0QMNaaA5U/NyZc1Ia4bxrzFByNMDoppoC+hl7cDiUq5/1CnFthpT9n+UtfFyg==} + '@rolldown/binding-darwin-arm64@1.0.0-rc.12': + resolution: {integrity: sha512-cFYr6zTG/3PXXF3pUO+umXxt1wkRK/0AYT8lDwuqvRC+LuKYWSAQAQZjCWDQpAH172ZV6ieYrNnFzVVcnSflAg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.0.0-rc.11': + resolution: {integrity: sha512-39Ks6UvIHq4rEogIfQBoBRusj0Q0nPVWIvqmwBLaT6aqQGIakHdESBVOPRRLacy4WwUPIx4ZKzfZ9PMW+IeyUQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.0.0-rc.12': + resolution: {integrity: sha512-ZCsYknnHzeXYps0lGBz8JrF37GpE9bFVefrlmDrAQhOEi4IOIlcoU1+FwHEtyXGx2VkYAvhu7dyBf75EJQffBw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [darwin] - '@rolldown/binding-freebsd-x64@1.0.0-rc.9': - resolution: {integrity: sha512-DLFYI78SCiZr5VvdEplsVC2Vx53lnA4/Ga5C65iyldMVaErr86aiqCoNBLl92PXPfDtUYjUh+xFFor40ueNs4Q==} + '@rolldown/binding-freebsd-x64@1.0.0-rc.11': + resolution: {integrity: sha512-jfsm0ZHfhiqrvWjJAmzsqiIFPz5e7mAoCOPBNTcNgkiid/LaFKiq92+0ojH+nmJmKYkre4t71BWXUZDNp7vsag==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-freebsd-x64@1.0.0-rc.12': + resolution: {integrity: sha512-dMLeprcVsyJsKolRXyoTH3NL6qtsT0Y2xeuEA8WQJquWFXkEC4bcu1rLZZSnZRMtAqwtrF/Ib9Ddtpa/Gkge9Q==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [freebsd] - '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.9': - resolution: {integrity: sha512-CsjTmTwd0Hri6iTw/DRMK7kOZ7FwAkrO4h8YWKoX/kcj833e4coqo2wzIFywtch/8Eb5enQ/lwLM7w6JX1W5RQ==} + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.11': + resolution: {integrity: sha512-zjQaUtSyq1nVe3nxmlSCuR96T1LPlpvmJ0SZy0WJFEsV4kFbXcq2u68L4E6O0XeFj4aex9bEauqjW8UQBeAvfQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.12': + resolution: {integrity: sha512-YqWjAgGC/9M1lz3GR1r1rP79nMgo3mQiiA+Hfo+pvKFK1fAJ1bCi0ZQVh8noOqNacuY1qIcfyVfP6HoyBRZ85Q==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] - '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.9': - resolution: {integrity: sha512-2x9O2JbSPxpxMDhP9Z74mahAStibTlrBMW0520+epJH5sac7/LwZW5Bmg/E6CXuEF53JJFW509uP+lSedaUNxg==} + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.11': + resolution: {integrity: sha512-WMW1yE6IOnehTcFE9eipFkm3XN63zypWlrJQ2iF7NrQ9b2LDRjumFoOGJE8RJJTJCTBAdmLMnJ8uVitACUUo1Q==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] libc: [glibc] - '@rolldown/binding-linux-arm64-musl@1.0.0-rc.9': - resolution: {integrity: sha512-JA1QRW31ogheAIRhIg9tjMfsYbglXXYGNPLdPEYrwFxdbkQCAzvpSCSHCDWNl4hTtrol8WeboCSEpjdZK8qrCg==} + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.12': + resolution: {integrity: sha512-/I5AS4cIroLpslsmzXfwbe5OmWvSsrFuEw3mwvbQ1kDxJ822hFHIx+vsN/TAzNVyepI/j/GSzrtCIwQPeKCLIg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.11': + resolution: {integrity: sha512-jfndI9tsfm4APzjNt6QdBkYwre5lRPUgHeDHoI7ydKUuJvz3lZeCfMsI56BZj+7BYqiKsJm7cfd/6KYV7ubrBg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.12': + resolution: {integrity: sha512-V6/wZztnBqlx5hJQqNWwFdxIKN0m38p8Jas+VoSfgH54HSj9tKTt1dZvG6JRHcjh6D7TvrJPWFGaY9UBVOaWPw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] libc: [musl] - '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.9': - resolution: {integrity: sha512-aOKU9dJheda8Kj8Y3w9gnt9QFOO+qKPAl8SWd7JPHP+Cu0EuDAE5wokQubLzIDQWg2myXq2XhTpOVS07qqvT+w==} + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.11': + resolution: {integrity: sha512-ZlFgw46NOAGMgcdvdYwAGu2Q+SLFA9LzbJLW+iyMOJyhj5wk6P3KEE9Gct4xWwSzFoPI7JCdYmYMzVtlgQ+zfw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [ppc64] os: [linux] libc: [glibc] - '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.9': - resolution: {integrity: sha512-OalO94fqj7IWRn3VdXWty75jC5dk4C197AWEuMhIpvVv2lw9fiPhud0+bW2ctCxb3YoBZor71QHbY+9/WToadA==} + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.12': + resolution: {integrity: sha512-AP3E9BpcUYliZCxa3w5Kwj9OtEVDYK6sVoUzy4vTOJsjPOgdaJZKFmN4oOlX0Wp0RPV2ETfmIra9x1xuayFB7g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.11': + resolution: {integrity: sha512-hIOYmuT6ofM4K04XAZd3OzMySEO4K0/nc9+jmNcxNAxRi6c5UWpqfw3KMFV4MVFWL+jQsSh+bGw2VqmaPMTLyw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.12': + resolution: {integrity: sha512-nWwpvUSPkoFmZo0kQazZYOrT7J5DGOJ/+QHHzjvNlooDZED8oH82Yg67HvehPPLAg5fUff7TfWFHQS8IV1n3og==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [s390x] os: [linux] libc: [glibc] - '@rolldown/binding-linux-x64-gnu@1.0.0-rc.9': - resolution: {integrity: sha512-cVEl1vZtBsBZna3YMjGXNvnYYrOJ7RzuWvZU0ffvJUexWkukMaDuGhUXn0rjnV0ptzGVkvc+vW9Yqy6h8YX4pg==} + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.11': + resolution: {integrity: sha512-qXBQQO9OvkjjQPLdUVr7Nr2t3QTZI7s4KZtfw7HzBgjbmAPSFwSv4rmET9lLSgq3rH/ndA3ngv3Qb8l2njoPNA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] libc: [glibc] - '@rolldown/binding-linux-x64-musl@1.0.0-rc.9': - resolution: {integrity: sha512-UzYnKCIIc4heAKgI4PZ3dfBGUZefGCJ1TPDuLHoCzgrMYPb5Rv6TLFuYtyM4rWyHM7hymNdsg5ik2C+UD9VDbA==} + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.12': + resolution: {integrity: sha512-RNrafz5bcwRy+O9e6P8Z/OCAJW/A+qtBczIqVYwTs14pf4iV1/+eKEjdOUta93q2TsT/FI0XYDP3TCky38LMAg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.11': + resolution: {integrity: sha512-/tpFfoSTzUkH9LPY+cYbqZBDyyX62w5fICq9qzsHLL8uTI6BHip3Q9Uzft0wylk/i8OOwKik8OxW+QAhDmzwmg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] libc: [musl] - '@rolldown/binding-openharmony-arm64@1.0.0-rc.9': - resolution: {integrity: sha512-+6zoiF+RRyf5cdlFQP7nm58mq7+/2PFaY2DNQeD4B87N36JzfF/l9mdBkkmTvSYcYPE8tMh/o3cRlsx1ldLfog==} + '@rolldown/binding-linux-x64-musl@1.0.0-rc.12': + resolution: {integrity: sha512-Jpw/0iwoKWx3LJ2rc1yjFrj+T7iHZn2JDg1Yny1ma0luviFS4mhAIcd1LFNxK3EYu3DHWCps0ydXQ5i/rrJ2ig==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.11': + resolution: {integrity: sha512-mcp3Rio2w72IvdZG0oQ4bM2c2oumtwHfUfKncUM6zGgz0KgPz4YmDPQfnXEiY5t3+KD/i8HG2rOB/LxdmieK2g==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [openharmony] - '@rolldown/binding-wasm32-wasi@1.0.0-rc.9': - resolution: {integrity: sha512-rgFN6sA/dyebil3YTlL2evvi/M+ivhfnyxec7AccTpRPccno/rPoNlqybEZQBkcbZu8Hy+eqNJCqfBR8P7Pg8g==} + '@rolldown/binding-openharmony-arm64@1.0.0-rc.12': + resolution: {integrity: sha512-vRugONE4yMfVn0+7lUKdKvN4D5YusEiPilaoO2sgUWpCvrncvWgPMzK00ZFFJuiPgLwgFNP5eSiUlv2tfc+lpA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.11': + resolution: {integrity: sha512-LXk5Hii1Ph9asuGRjBuz8TUxdc1lWzB7nyfdoRgI0WGPZKmCxvlKk8KfYysqtr4MfGElu/f/pEQRh8fcEgkrWw==} engines: {node: '>=14.0.0'} cpu: [wasm32] - '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.9': - resolution: {integrity: sha512-lHVNUG/8nlF1IQk1C0Ci574qKYyty2goMiPlRqkC5R+3LkXDkL5Dhx8ytbxq35m+pkHVIvIxviD+TWLdfeuadA==} + '@rolldown/binding-wasm32-wasi@1.0.0-rc.12': + resolution: {integrity: sha512-ykGiLr/6kkiHc0XnBfmFJuCjr5ZYKKofkx+chJWDjitX+KsJuAmrzWhwyOMSHzPhzOHOy7u9HlFoa5MoAOJ/Zg==} + engines: {node: '>=14.0.0'} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.11': + resolution: {integrity: sha512-dDwf5otnx0XgRY1yqxOC4ITizcdzS/8cQ3goOWv3jFAo4F+xQYni+hnMuO6+LssHHdJW7+OCVL3CoU4ycnh35Q==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [win32] - '@rolldown/binding-win32-x64-msvc@1.0.0-rc.9': - resolution: {integrity: sha512-G0oA4+w1iY5AGi5HcDTxWsoxF509hrFIPB2rduV5aDqS9FtDg1CAfa7V34qImbjfhIcA8C+RekocJZA96EarwQ==} + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.12': + resolution: {integrity: sha512-5eOND4duWkwx1AzCxadcOrNeighiLwMInEADT0YM7xeEOOFcovWZCq8dadXgcRHSf3Ulh1kFo/qvzoFiCLOL1Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.11': + resolution: {integrity: sha512-LN4/skhSggybX71ews7dAj6r2geaMJfm3kMbK2KhFMg9B10AZXnKoLCVVgzhMHL0S+aKtr4p8QbAW8k+w95bAA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.12': + resolution: {integrity: sha512-PyqoipaswDLAZtot351MLhrlrh6lcZPo2LSYE+VDxbVk24LVKAGOuE4hb8xZQmrPAuEtTZW8E6D2zc5EUZX4Lw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [win32] - '@rolldown/pluginutils@1.0.0-rc.9': - resolution: {integrity: sha512-w6oiRWgEBl04QkFZgmW+jnU1EC9b57Oihi2ot3HNWIQRqgHp5PnYDia5iZ5FF7rpa4EQdiqMDXjlqKGXBhsoXw==} + '@rolldown/pluginutils@1.0.0-rc.11': + resolution: {integrity: sha512-xQO9vbwBecJRv9EUcQ/y0dzSTJgA7Q6UVN7xp6B81+tBGSLVAK03yJ9NkJaUA7JFD91kbjxRSC/mDnmvXzbHoQ==} + + '@rolldown/pluginutils@1.0.0-rc.12': + resolution: {integrity: sha512-HHMwmarRKvoFsJorqYlFeFRzXZqCt2ETQlEDOb9aqssrnVBB1/+xgTGtuTrIk5vzLNX1MjMtTf7W9z3tsSbrxw==} '@rollup/rollup-android-arm-eabi@4.59.0': resolution: {integrity: sha512-upnNBkA6ZH2VKGcBj9Fyl9IGNPULcjXRlg0LLeaioQWueH30p6IXtJEbKAgvyv+mJaMxSm1l6xwDXYjpEMiLMg==} @@ -3189,8 +3287,8 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - picomatch@4.0.3: - resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} + picomatch@4.0.4: + resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==} engines: {node: '>=12'} pify@3.0.0: @@ -3382,8 +3480,13 @@ packages: vue-tsc: optional: true - rolldown@1.0.0-rc.9: - resolution: {integrity: sha512-9EbgWge7ZH+yqb4d2EnELAntgPTWbfL8ajiTW+SyhJEC4qhBbkCKbqFV4Ge4zmu5ziQuVbWxb/XwLZ+RIO7E8Q==} + rolldown@1.0.0-rc.11: + resolution: {integrity: sha512-NRjoKMusSjfRbSYiH3VSumlkgFe7kYAa3pzVOsVYVFY3zb5d7nS+a3KGQ7hJKXuYWbzJKPVQ9Wxq2UvyK+ENpw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + rolldown@1.0.0-rc.12: + resolution: {integrity: sha512-yP4USLIMYrwpPHEFB5JGH1uxhcslv6/hL0OyvTuY+3qlOSJvZ7ntYnoWpehBxufkgN0cvXxppuTu5hHa/zPh+A==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true @@ -3692,17 +3795,17 @@ packages: peerDependencies: typescript: '>=4.0.0' - tsdown@0.21.4: - resolution: {integrity: sha512-Q/kBi8SXkr4X6JI/NAZKZY1UuiEcbuXtIskL4tZCsgpDiEPM/2W6lC+OonNA31S+V3KsWedFvbFDBs23hvt+Aw==} + tsdown@0.21.5: + resolution: {integrity: sha512-TlgNhfPioAD6ECCUnZsxcUsXXuPPR4Rrxz3az741kL/M3oGIET4a9GajSNRNRx+jIva73TYUKQybrEPkDYN+fQ==} engines: {node: '>=20.19.0'} hasBin: true peerDependencies: '@arethetypeswrong/core': ^0.18.1 - '@tsdown/css': 0.21.4 - '@tsdown/exe': 0.21.4 + '@tsdown/css': 0.21.5 + '@tsdown/exe': 0.21.5 '@vitejs/devtools': '*' publint: ^0.3.0 - typescript: ^5.0.0 + typescript: ^5.0.0 || ^6.0.0 unplugin-unused: ^0.5.0 peerDependenciesMeta: '@arethetypeswrong/core': @@ -3841,8 +3944,8 @@ packages: unrs-resolver@1.11.1: resolution: {integrity: sha512-bSjt9pjaEBnNiGgc9rUiHGKv5l4/TGzDmYw3RhnkJGtLhbnnA/5qJj7x3dNDCRx/PJxu774LlH8lCOlB4hEfKg==} - unrun@0.2.32: - resolution: {integrity: sha512-opd3z6791rf281JdByf0RdRQrpcc7WyzqittqIXodM/5meNWdTwrVxeyzbaCp4/Rgls/um14oUaif1gomO8YGg==} + unrun@0.2.34: + resolution: {integrity: sha512-LyaghRBR++r7svhDK6tnDz2XaYHWdneBOA0jbS8wnRsHerI9MFljX4fIiTgbbNbEVzZ0C9P1OjWLLe1OqoaaEw==} engines: {node: '>=20.19.0'} hasBin: true peerDependencies: @@ -4764,7 +4867,7 @@ snapshots: '@ota-meshi/ast-token-store@0.3.0': {} - '@oxc-project/types@0.115.0': {} + '@oxc-project/types@0.122.0': {} '@pkgr/core@0.2.9': {} @@ -4790,54 +4893,103 @@ snapshots: dependencies: quansync: 1.0.0 - '@rolldown/binding-android-arm64@1.0.0-rc.9': + '@rolldown/binding-android-arm64@1.0.0-rc.11': optional: true - '@rolldown/binding-darwin-arm64@1.0.0-rc.9': + '@rolldown/binding-android-arm64@1.0.0-rc.12': optional: true - '@rolldown/binding-darwin-x64@1.0.0-rc.9': + '@rolldown/binding-darwin-arm64@1.0.0-rc.11': optional: true - '@rolldown/binding-freebsd-x64@1.0.0-rc.9': + '@rolldown/binding-darwin-arm64@1.0.0-rc.12': optional: true - '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.9': + '@rolldown/binding-darwin-x64@1.0.0-rc.11': optional: true - '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.9': + '@rolldown/binding-darwin-x64@1.0.0-rc.12': optional: true - '@rolldown/binding-linux-arm64-musl@1.0.0-rc.9': + '@rolldown/binding-freebsd-x64@1.0.0-rc.11': optional: true - '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.9': + '@rolldown/binding-freebsd-x64@1.0.0-rc.12': optional: true - '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.9': + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.11': optional: true - '@rolldown/binding-linux-x64-gnu@1.0.0-rc.9': + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.12': optional: true - '@rolldown/binding-linux-x64-musl@1.0.0-rc.9': + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.11': optional: true - '@rolldown/binding-openharmony-arm64@1.0.0-rc.9': + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.12': optional: true - '@rolldown/binding-wasm32-wasi@1.0.0-rc.9': + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.11': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.12': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.11': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.12': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.11': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.12': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.11': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.12': + optional: true + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.11': + optional: true + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.12': + optional: true + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.11': + optional: true + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.12': + optional: true + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.11': + dependencies: + '@napi-rs/wasm-runtime': 1.1.1 + optional: true + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.12': dependencies: '@napi-rs/wasm-runtime': 1.1.1 optional: true - '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.9': + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.11': optional: true - '@rolldown/binding-win32-x64-msvc@1.0.0-rc.9': + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.12': optional: true - '@rolldown/pluginutils@1.0.0-rc.9': {} + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.11': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.12': + optional: true + + '@rolldown/pluginutils@1.0.0-rc.11': {} + + '@rolldown/pluginutils@1.0.0-rc.12': {} '@rollup/rollup-android-arm-eabi@4.59.0': optional: true @@ -5068,7 +5220,7 @@ snapshots: eslint-visitor-keys: 4.2.1 espree: 10.4.0 estraverse: 5.3.0 - picomatch: 4.0.3 + picomatch: 4.0.4 '@tufjs/canonical-json@2.0.0': {} @@ -6213,9 +6365,9 @@ snapshots: dependencies: format: 0.2.2 - fdir@6.5.0(picomatch@4.0.3): + fdir@6.5.0(picomatch@4.0.4): optionalDependencies: - picomatch: 4.0.3 + picomatch: 4.0.4 figures@2.0.0: dependencies: @@ -6593,7 +6745,7 @@ snapshots: dependencies: commander: 14.0.3 listr2: 9.0.5 - picomatch: 4.0.3 + picomatch: 4.0.4 string-argv: 0.3.2 tinyexec: 1.0.4 yaml: 2.8.2 @@ -7375,7 +7527,7 @@ snapshots: picomatch@2.3.1: {} - picomatch@4.0.3: {} + picomatch@4.0.4: {} pify@3.0.0: {} @@ -7544,7 +7696,7 @@ snapshots: rfdc@1.4.1: {} - rolldown-plugin-dts@0.22.5(rolldown@1.0.0-rc.9)(typescript@5.9.3): + rolldown-plugin-dts@0.22.5(rolldown@1.0.0-rc.11)(typescript@5.9.3): dependencies: '@babel/generator': 8.0.0-rc.2 '@babel/helper-validator-identifier': 8.0.0-rc.2 @@ -7555,32 +7707,53 @@ snapshots: dts-resolver: 2.1.3 get-tsconfig: 4.13.6 obug: 2.1.1 - rolldown: 1.0.0-rc.9 + rolldown: 1.0.0-rc.11 optionalDependencies: typescript: 5.9.3 transitivePeerDependencies: - oxc-resolver - rolldown@1.0.0-rc.9: + rolldown@1.0.0-rc.11: dependencies: - '@oxc-project/types': 0.115.0 - '@rolldown/pluginutils': 1.0.0-rc.9 + '@oxc-project/types': 0.122.0 + '@rolldown/pluginutils': 1.0.0-rc.11 + optionalDependencies: + '@rolldown/binding-android-arm64': 1.0.0-rc.11 + '@rolldown/binding-darwin-arm64': 1.0.0-rc.11 + '@rolldown/binding-darwin-x64': 1.0.0-rc.11 + '@rolldown/binding-freebsd-x64': 1.0.0-rc.11 + '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-rc.11 + '@rolldown/binding-linux-arm64-gnu': 1.0.0-rc.11 + '@rolldown/binding-linux-arm64-musl': 1.0.0-rc.11 + '@rolldown/binding-linux-ppc64-gnu': 1.0.0-rc.11 + '@rolldown/binding-linux-s390x-gnu': 1.0.0-rc.11 + '@rolldown/binding-linux-x64-gnu': 1.0.0-rc.11 + '@rolldown/binding-linux-x64-musl': 1.0.0-rc.11 + '@rolldown/binding-openharmony-arm64': 1.0.0-rc.11 + '@rolldown/binding-wasm32-wasi': 1.0.0-rc.11 + '@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.11 + '@rolldown/binding-win32-x64-msvc': 1.0.0-rc.11 + + rolldown@1.0.0-rc.12: + dependencies: + '@oxc-project/types': 0.122.0 + '@rolldown/pluginutils': 1.0.0-rc.12 optionalDependencies: - '@rolldown/binding-android-arm64': 1.0.0-rc.9 - '@rolldown/binding-darwin-arm64': 1.0.0-rc.9 - '@rolldown/binding-darwin-x64': 1.0.0-rc.9 - '@rolldown/binding-freebsd-x64': 1.0.0-rc.9 - '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-rc.9 - '@rolldown/binding-linux-arm64-gnu': 1.0.0-rc.9 - '@rolldown/binding-linux-arm64-musl': 1.0.0-rc.9 - '@rolldown/binding-linux-ppc64-gnu': 1.0.0-rc.9 - '@rolldown/binding-linux-s390x-gnu': 1.0.0-rc.9 - '@rolldown/binding-linux-x64-gnu': 1.0.0-rc.9 - '@rolldown/binding-linux-x64-musl': 1.0.0-rc.9 - '@rolldown/binding-openharmony-arm64': 1.0.0-rc.9 - '@rolldown/binding-wasm32-wasi': 1.0.0-rc.9 - '@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.9 - '@rolldown/binding-win32-x64-msvc': 1.0.0-rc.9 + '@rolldown/binding-android-arm64': 1.0.0-rc.12 + '@rolldown/binding-darwin-arm64': 1.0.0-rc.12 + '@rolldown/binding-darwin-x64': 1.0.0-rc.12 + '@rolldown/binding-freebsd-x64': 1.0.0-rc.12 + '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-rc.12 + '@rolldown/binding-linux-arm64-gnu': 1.0.0-rc.12 + '@rolldown/binding-linux-arm64-musl': 1.0.0-rc.12 + '@rolldown/binding-linux-ppc64-gnu': 1.0.0-rc.12 + '@rolldown/binding-linux-s390x-gnu': 1.0.0-rc.12 + '@rolldown/binding-linux-x64-gnu': 1.0.0-rc.12 + '@rolldown/binding-linux-x64-musl': 1.0.0-rc.12 + '@rolldown/binding-openharmony-arm64': 1.0.0-rc.12 + '@rolldown/binding-wasm32-wasi': 1.0.0-rc.12 + '@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.12 + '@rolldown/binding-win32-x64-msvc': 1.0.0-rc.12 rollup@4.59.0: dependencies: @@ -7896,8 +8069,8 @@ snapshots: tinyglobby@0.2.15: dependencies: - fdir: 6.5.0(picomatch@4.0.3) - picomatch: 4.0.3 + fdir: 6.5.0(picomatch@4.0.4) + picomatch: 4.0.4 tinyrainbow@3.1.0: {} @@ -7928,10 +8101,10 @@ snapshots: ts-declaration-location@1.0.7(typescript@5.9.3): dependencies: - picomatch: 4.0.3 + picomatch: 4.0.4 typescript: 5.9.3 - tsdown@0.21.4(synckit@0.11.12)(typescript@5.9.3): + tsdown@0.21.5(synckit@0.11.12)(typescript@5.9.3): dependencies: ansis: 4.2.0 cac: 7.0.0 @@ -7940,15 +8113,15 @@ snapshots: hookable: 6.1.0 import-without-cache: 0.2.5 obug: 2.1.1 - picomatch: 4.0.3 - rolldown: 1.0.0-rc.9 - rolldown-plugin-dts: 0.22.5(rolldown@1.0.0-rc.9)(typescript@5.9.3) + picomatch: 4.0.4 + rolldown: 1.0.0-rc.11 + rolldown-plugin-dts: 0.22.5(rolldown@1.0.0-rc.11)(typescript@5.9.3) semver: 7.7.4 tinyexec: 1.0.4 tinyglobby: 0.2.15 tree-kill: 1.2.2 unconfig-core: 7.5.0 - unrun: 0.2.32(synckit@0.11.12) + unrun: 0.2.34(synckit@0.11.12) optionalDependencies: typescript: 5.9.3 transitivePeerDependencies: @@ -8086,9 +8259,9 @@ snapshots: '@unrs/resolver-binding-win32-ia32-msvc': 1.11.1 '@unrs/resolver-binding-win32-x64-msvc': 1.11.1 - unrun@0.2.32(synckit@0.11.12): + unrun@0.2.34(synckit@0.11.12): dependencies: - rolldown: 1.0.0-rc.9 + rolldown: 1.0.0-rc.12 optionalDependencies: synckit: 0.11.12 @@ -8116,8 +8289,8 @@ snapshots: vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(yaml@2.8.2): dependencies: esbuild: 0.27.4 - fdir: 6.5.0(picomatch@4.0.3) - picomatch: 4.0.3 + fdir: 6.5.0(picomatch@4.0.4) + picomatch: 4.0.4 postcss: 8.5.8 rollup: 4.59.0 tinyglobby: 0.2.15 @@ -8141,7 +8314,7 @@ snapshots: magic-string: 0.30.21 obug: 2.1.1 pathe: 2.0.3 - picomatch: 4.0.3 + picomatch: 4.0.4 std-env: 4.0.0 tinybench: 2.9.0 tinyexec: 1.0.4