walkdiff 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +83 -3
- package/app-ui/assets/{index-CW9T4O2t.js → index-BRMcNFUc.js} +1 -1
- package/app-ui/index.html +1 -1
- package/package.json +2 -1
- package/report-ui/assets/index-CFriIC6-.css +1 -0
- package/report-ui/assets/index-DOjOcj6E.js +81 -0
- package/report-ui/index.html +2 -2
- package/walkdiff.mjs +1951 -58
- package/report-ui/assets/index-CNwloc-G.css +0 -1
- package/report-ui/assets/index-CjDznYrY.js +0 -81
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
- **The Risks tab is a one-page overview:**
|
|
6
|
+
- **Headline:** the security summary, plus what else needs a decision or is background.
|
|
7
|
+
- **Index:** a row per kind of finding (supply chain, breaking change, docs drift and so on), grouped into security, decisions and background, with counts coloured by the worst finding. It stays in view as you scroll.
|
|
8
|
+
- **Sections:** one per kind, with what to check and its findings, ordered by kind and then severity. The checks that ran and didn't come last.
|
|
9
|
+
- **Links:** each section has a link of its own, such as `#risks/supplyChain`, and the review brief's new **At a glance** card links straight to them.
|
|
10
|
+
- **Breaking changes in API schemas:** each OpenAPI, GraphQL or protobuf file a PR changes or deletes is compared with its version at the merge base. A change that breaks clients already running is high; one that only breaks code built against the schema is medium.
|
|
11
|
+
- **OpenAPI 3 and Swagger 2:** removed operations; new or newly required parameters and request fields; enum values clients can no longer send; and response fields that were removed, retyped, or are no longer always there.
|
|
12
|
+
- **GraphQL:** removed types, fields, arguments and enum values; changed types; output fields that can now be null; and inputs that became required.
|
|
13
|
+
- **Protobuf:** removed RPCs, messages and enums; changed types; field numbers that changed; and fields removed or renamed without reserving their number.
|
|
14
|
+
- **Split schemas:** GraphQL and protobuf files are read together, so a type that moves to another file is compared with itself there. A schema that can't be parsed is listed under "Not checked".
|
|
15
|
+
- **Docs drift:** a new check flags docs a PR leaves out of date.
|
|
16
|
+
- **Stale mentions:** Markdown, reStructuredText or AsciiDoc that still mentions a command-line option, environment variable, config key, function or type the PR removes or renames. Changelogs and upgrade guides, and lines that also name the replacement, are left alone.
|
|
17
|
+
- **Doc comments:** a comment that still describes a parameter its changed function dropped, or leaves out one it gained.
|
|
18
|
+
- **Hotspots:** a new check notes changed files that had a change reverted in the last 90 days, keep needing fixes, or change far more often than most, from their commits in the year before the PR. A hotspot ranks higher on the review path and says why.
|
|
19
|
+
- **Where the history comes from:** git for local reviews. For hosted PRs, GitHub's or GitLab's API, which reads only the changed files' paths; on GitHub this needs a token.
|
|
20
|
+
- **Settings:** it can be turned off, and the list of what leaves your machine names it.
|
|
21
|
+
- **Mixed-concern PRs:** a new Scope check asks whether a PR should be split.
|
|
22
|
+
- **Tidy-ups and upgrades:** behaviour changes buried among 5 or more files that are only reformatted, renamed or moved, or among 10 or more upgraded packages.
|
|
23
|
+
- **Unrelated packages:** behaviour changes in workspace packages that neither depend on nor use each other.
|
|
24
|
+
|
|
3
25
|
## 0.12.0
|
|
4
26
|
|
|
5
27
|
- **Attack surface:** new HTTP endpoints are noted where a PR adds them, in Express, Koa, Fastify, Hono, NestJS, FastAPI, Flask, Django, Spring, JAX-RS, ASP.NET, Go's `net/http`, gin, echo, chi, axum, actix and Rocket. A new endpoint without the auth its neighbours in the file declare is flagged, as is code that turns auth or CSRF checks off, such as `[AllowAnonymous]`, `permitAll()` or `@csrf_exempt`. A route moved within the PR isn't counted as new.
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
A review companion for GitHub pull requests and GitLab merge requests. `walkdiff review <url>` fetches the
|
|
6
6
|
change, analyzes it, and serves a local report.
|
|
7
7
|
|
|
8
|
-
Status: early release, [v0.
|
|
8
|
+
Status: early release, [v0.13.0](CHANGELOG.md). To run it on your team's PRs, see the [pilot guide](docs/pilot.md).
|
|
9
9
|
|
|
10
10
|
**Documentation:** [website](https://navasvarela.github.io/walkdiff/), [getting started](docs/getting-started.md), [configuration](docs/configuration.md), [troubleshooting](docs/troubleshooting.md), [security policy](SECURITY.md).
|
|
11
11
|
|
|
@@ -15,6 +15,13 @@ The report opens on a brief: what to check, how many changes need attention, and
|
|
|
15
15
|
|
|
16
16
|
All changes has five tabs, including **Conversation** in the app: **Changes** (files, the map of each file and the changed units), **Impact** (where other code uses what changed), **Risks** (each check's result and every finding) and **AI review**. Each tab shows a count, and its name in the URL lets you link to it, as in `#risks`.
|
|
17
17
|
|
|
18
|
+
**Risks** is a one-page overview:
|
|
19
|
+
- **Headline:** the security summary, with how many findings need a decision or are background.
|
|
20
|
+
- **Index:** a row per kind of finding (supply chain, breaking change, docs drift and so on), grouped into security, decisions and background, with counts coloured by the worst finding. It stays in view as you scroll.
|
|
21
|
+
- **Sections:** one per kind of finding, with what to check and its findings, then the checks that ran and didn't.
|
|
22
|
+
|
|
23
|
+
Each section has a link of its own, as in `#risks/supplyChain`, and the review brief's **At a glance** card links straight to them.
|
|
24
|
+
|
|
18
25
|
- **Changed units, not hunks.** For Rust, TypeScript/JavaScript, Python, Go, Java, Kotlin, C#, C and C++, each changed function,
|
|
19
26
|
method, type, class or macro appears once, whole, before and after, with edited words marked. A class shows only the
|
|
20
27
|
code it owns; its methods are separate cards. In JavaScript and TypeScript tests, each `describe`,
|
|
@@ -117,7 +124,7 @@ Tokens and code stay on your machine, apart from the host itself, package names
|
|
|
117
124
|
|
|
118
125
|
## In CI
|
|
119
126
|
|
|
120
|
-
The GitHub Action (`navasvarela/walkdiff@v0.
|
|
127
|
+
The GitHub Action (`navasvarela/walkdiff@v0.13.0`) and the GitLab template (`ci/gitlab-ci.yml`) generate the report for each PR, keep it as a job artifact, and post one summary comment that is updated on each push. The [pilot guide](docs/pilot.md) has the setup. Locally, `walkdiff review` also works without a URL inside a CI job, and `walkdiff comment --report <dir> --report-url <url>` posts the summary.
|
|
121
128
|
|
|
122
129
|
## AI review
|
|
123
130
|
|
|
@@ -246,6 +253,20 @@ functions under a framework's decorator are skipped, as the decorator can change
|
|
|
246
253
|
name that's still available after its definition went, through an alias, a `__getattr__` shim or a move to
|
|
247
254
|
another file. A removal that untouched code still uses shows up as a broken reference instead.
|
|
248
255
|
|
|
256
|
+
**API schemas:** each OpenAPI, GraphQL or protobuf file the PR changes or deletes is compared with its version at
|
|
257
|
+
the merge base. A new schema file can't break anyone, so it isn't compared on its own. What breaks clients
|
|
258
|
+
already running, such as a removed operation, is high, and what breaks code built against the schema is medium.
|
|
259
|
+
|
|
260
|
+
| Format | Flags |
|
|
261
|
+
| --- | --- |
|
|
262
|
+
| OpenAPI 3 and Swagger 2 (YAML or JSON) | Removed operations; new or newly required parameters, request bodies and request fields; enum values clients can no longer send; removed or retyped response fields, and ones that are no longer always there. Bodies are compared at their top level, following `$ref`s and `allOf` within the file |
|
|
263
|
+
| GraphQL (`.graphql`, `.graphqls`, `.gql`) | Removed types, fields, arguments and enum values; retyped fields and arguments; output fields that can now be null; arguments and input fields that became required, or are new and required |
|
|
264
|
+
| Protobuf (`.proto`) | Removed RPCs, messages and enums; retyped RPCs and fields; fields and enum values whose number changed; fields and enum values removed or renamed without reserving their number |
|
|
265
|
+
|
|
266
|
+
GraphQL and protobuf schemas are often split across files, so the PR's files of each are read as one. A type
|
|
267
|
+
that moves to another file is compared with itself there. A schema Walkdiff can't parse is listed under "Not
|
|
268
|
+
checked" with the file and why.
|
|
269
|
+
|
|
249
270
|
**Database migrations:** dropped or renamed tables and columns and changed column types, in raw SQL (including
|
|
250
271
|
Prisma, Goose, dbmate and Flyway files), Alembic, Django, Rails, Knex, Sequelize and TypeORM. Only the added lines
|
|
251
272
|
that run on the way up count, so rollbacks aren't flagged. Neither are temporary tables, or names the
|
|
@@ -261,9 +282,68 @@ mentions an unusual name. Django's `AlterField` isn't checked, since it mostly c
|
|
|
261
282
|
- A key removed from a config file (`config/*.yml`, `settings.toml`, `appsettings.json`, `*.example.json` and
|
|
262
283
|
similar) while code still reads it. Ordinary words like `name` are left out, as matches on them mean little.
|
|
263
284
|
|
|
264
|
-
Not covered yet:
|
|
285
|
+
Not covered yet: GraphQL union members and directives, OpenAPI `$ref`s to other files, and nested body
|
|
286
|
+
fields beyond the top level; public struct fields and interface members, new required trait methods, re-exports removed from an entry point
|
|
265
287
|
without the definition changing, and inputs of a GitHub Action's `action.yml`.
|
|
266
288
|
|
|
289
|
+
## Docs drift
|
|
290
|
+
|
|
291
|
+
Walkdiff flags docs a PR leaves out of date, under its own "Docs drift" category. These are review signals,
|
|
292
|
+
not security findings.
|
|
293
|
+
|
|
294
|
+
- **Names the docs still use:** a command-line option (a quoted `--flag` in code), an environment variable, a
|
|
295
|
+
config key, or a function or type that the PR removes or renames, while Markdown, reStructuredText or AsciiDoc
|
|
296
|
+
files at head still mention it.
|
|
297
|
+
- **Severity:** options and settings are medium, because whoever follows the docs gets an error or a setting
|
|
298
|
+
that silently does nothing. Code names are low.
|
|
299
|
+
- **What's skipped:** a name that code at head still uses anywhere doesn't count, since it may be defined
|
|
300
|
+
elsewhere. Neither do changelogs, release notes, upgrade and migration guides, or a line that names the
|
|
301
|
+
replacement too, which is describing the rename.
|
|
302
|
+
- **Doc comments that no longer match:** a function the PR changes whose doc comment still describes a parameter
|
|
303
|
+
it removed, or doesn't describe one it added while describing the others. This reads JSDoc, Javadoc and KDoc
|
|
304
|
+
`@param`, Python's `Args:`, NumPy `Parameters` and `:param:` sections, and Rust's `# Arguments`.
|
|
305
|
+
|
|
306
|
+
Only what the PR changes is compared, so docs that were already out of date aren't flagged.
|
|
307
|
+
|
|
308
|
+
## Hotspots
|
|
309
|
+
|
|
310
|
+
Walkdiff notes changed files whose recent history says to look harder. It reads each file's commits in the
|
|
311
|
+
year before the merge base, so the PR's own commits never count:
|
|
312
|
+
|
|
313
|
+
| Note | When |
|
|
314
|
+
| --- | --- |
|
|
315
|
+
| Had a change reverted recently | A commit starting with "Revert" touched it in the 90 days before the PR |
|
|
316
|
+
| Often fixed | At least 5 commits that fixed something touched it, a quarter or more of its changes. Fixes are commits with "fix", "bug", "hotfix", "regression", "crash" or "broken" in their subject, but not ones about typos, lint, formatting, docs, tests, CI, builds or dependencies |
|
|
317
|
+
| Changes often | 30 or more commits touched it |
|
|
318
|
+
|
|
319
|
+
These go under the "Hotspot" category. They're context, not questions: they don't count as security and the
|
|
320
|
+
review plan doesn't list them, but a hotspot file ranks higher on the review path and says why.
|
|
321
|
+
|
|
322
|
+
**Where the history comes from:**
|
|
323
|
+
- **`--local` reviews and checkouts with history:** the repository itself.
|
|
324
|
+
- **Hosted PRs and MRs:** these fetch only the PR's own commits, so Walkdiff asks the host. On GitHub that's one
|
|
325
|
+
GraphQL query for up to 20 files, which needs a token. On GitLab it's one request per file.
|
|
326
|
+
|
|
327
|
+
Offline, without a GitHub token, or in a shallow clone, the Risks tab lists Hotspots under "Not checked". It
|
|
328
|
+
looks at up to 60 changed code files, and can be turned off in the app's Settings.
|
|
329
|
+
|
|
330
|
+
## Scope
|
|
331
|
+
|
|
332
|
+
Walkdiff flags PRs that mix concerns, under the "Scope" category, as a question for the review plan: should it be
|
|
333
|
+
split? Each changed file is sorted by what it carries:
|
|
334
|
+
|
|
335
|
+
- **Behaviour:** code units added, removed, or edited beyond formatting and comments.
|
|
336
|
+
- **Tidy-up:** code that's only reformatted, re-commented, renamed or moved.
|
|
337
|
+
- **Dependencies:** lockfiles.
|
|
338
|
+
- **Neither:** tests, docs, CI and config, which travel with the change they belong to.
|
|
339
|
+
|
|
340
|
+
It flags two things:
|
|
341
|
+
|
|
342
|
+
| Note | When |
|
|
343
|
+
| --- | --- |
|
|
344
|
+
| Mixes a tidy-up or upgrades with behaviour changes | Alongside behaviour changes, 5 or more tidy-up files, or 10 or more packages the lockfiles already had moved to new versions. New packages don't count, since they come with the code that uses them |
|
|
345
|
+
| Changes packages that don't use each other | Behaviour changes in two or more workspace packages (folders with their own `package.json`, `Cargo.toml`, `go.mod` and so on), each with at least 3 changed units, where neither declares a dependency on the other, names something the other changes, or calls it |
|
|
346
|
+
|
|
267
347
|
## Code quality
|
|
268
348
|
|
|
269
349
|
Walkdiff flags poor implementations and bad practice in the code a PR adds, under the "Code quality"
|
|
@@ -60,4 +60,4 @@ Error generating stack: `+e.message+`
|
|
|
60
60
|
|
|
61
61
|
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=de,c=!it.jitless,l=c&&fe.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Mr([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Fr(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!ke(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Pe(e,r,at())))}),t)}var Ir=O(`$ZodUnion`,(e,t)=>{A.init(e,t),D(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),D(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),D(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),D(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>ee(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Fr(t,r,e,i)):Fr(o,r,e,i)}});function Lr(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var Rr=O(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ir.init(e,t);let n=e._zod.parse;D(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||ne(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=re(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=y(()=>Lr(t));e._zod.parse=(i,a)=>{let o=i.value;if(!de(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),zr=O(`$ZodIntersection`,(e,t)=>{A.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Vr(e,t,n)):Vr(e,i,a)}});function Br(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(pe(e)&&pe(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Br(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Br(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Vr(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Br(t.value,n.value);if(!c.valid){if(ke(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Hr=O(`$ZodEnum`,(e,t)=>{A.init(e,t);let n=h(t.entries),r=new Set(n);e._zod.values=r,D(e,`pattern`,e=>{let t=h(e.def.entries).filter(e=>he.has(typeof e));return RegExp(t.length?`^(${t.map(e=>ge(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ur=O(`$ZodLiteral`,(e,t)=>{A.init(e,t);let n=new Set(t.values);e._zod.values=n,D(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?ge(e):e?ge(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Wr=O(`$ZodTransform`,(e,t)=>{A.init(e,t),e._zod.optin=`optional`,it.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new rt(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new nt;return n.value=i,n}});function Gr(e,t){return e.value=t.issues.length?void 0:t.value,e}var Kr=O(`$ZodOptional`,(e,t)=>{A.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,D(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),D(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ee(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Gr(e,t)):Gr(e,r)}return t.innerType._zod.run(e,n)}}),qr=O(`$ZodExactOptional`,(e,t)=>{Kr.init(e,t),D(e,`values`,e=>e.def.innerType._zod.values),D(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Jr=O(`$ZodNullable`,(e,t)=>{A.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin),D(e,`optout`,e=>e.def.innerType._zod.optout),D(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ee(t.source)}|null)$`):void 0}),D(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Yr=O(`$ZodDefault`,(e,t)=>{A.init(e,t),e._zod.optin=`defaulted`,D(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Xr(e,t)):Xr(r,t)}});function Xr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Zr=O(`$ZodPrefault`,(e,t)=>{A.init(e,t),e._zod.optin=`defaulted`,D(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Qr=O(`$ZodNonOptional`,(e,t)=>{A.init(e,t),D(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>$r(t,e)):$r(i,e)}});function $r(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function ei(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Pe(e,r,at()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var ti=O(`$ZodCatch`,(e,t)=>{A.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),D(e,`optout`,e=>e.def.innerType._zod.optout),D(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>ei(e,r,t,n)):ei(e,r,t,n)}}),ni=O(`$ZodPipe`,(e,t)=>{A.init(e,t),D(e,`values`,e=>e.def.in._zod.values),D(e,`optin`,e=>e.def.in._zod.optin),D(e,`optout`,e=>e.def.out._zod.optout),D(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ri(e,t.in,n)):ri(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ri(e,t.out,n)):ri(r,t.out,n)}});function ri(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var ii=O(`$ZodReadonly`,(e,t)=>{A.init(e,t),D(e,`propValues`,e=>e.def.innerType._zod.propValues),D(e,`values`,e=>e.def.innerType._zod.values),D(e,`optin`,e=>e.def.innerType?._zod?.optin),D(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ai):ai(r)}});function ai(e){return e.memo||(e.value=Object.freeze(e.value)),e}var oi=O(`$ZodCustom`,(e,t)=>{fn.init(e,t),A.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>si(t,n,r,e));si(i,n,r,e)}});function si(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ze(e))}}var ci=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},li=`~memo`,ui=[];function di(e){return typeof e==`object`&&!!e}function fi(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var pi=new WeakMap,mi=0,hi=1,gi=2;function _i(e,t,n){let r=pi.get(e);if(r!==void 0)return r?gi:mi;if(t.has(e))return gi;t.add(e);let i=mi,a=e=>{if(i!==gi&&e?._zod){let r=_i(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=mi;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?hi:o.value?._zod?_i(o.value,t,n):mi;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=re(c);s(e?o(e,!0):hi),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?_i(r,t,!1):hi);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),vi(e,i)}function vi(e,t){return t!==hi&&pi.set(e,t===gi),t}function yi(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var bi,xi=[],Si={alloc(e,t,n){let r=bi;if(!r)return n;bi=void 0;let i={value:n,issues:null};return r.set(t.value,i),xi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&wi(n,e.value))throw new ci;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=_i(e,new Set,!1);if(i===mi)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===gi||r?n=!0:r=!0}let l=s.value;if(!di(l))return t(s,c);let u=c[li];u||(u={buckets:new WeakMap,backEdges:void 0},c[li]=u);let d;i===c?d=a:(d=yi(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...fi(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;bi=d;let p=xi.length,m=t(s,c);bi=void 0;let h=xi.length>p?xi.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?fi(e.issues):ui),e)):(h&&(h.issues=m.issues.length?fi(m.issues):ui),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Ci(){return Si}function wi(e,t){let n=e[li]?.backEdges;return n!==void 0&&di(t)&&n.has(t)}var Ti=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Re(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ve(e.values[0])}`:`Invalid option: expected one of ${g(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${g(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Ei(){return{localeError:Ti()}}var Di,Oi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ki(){return new Oi}(Di=globalThis).__zod_globalRegistry??(Di.__zod_globalRegistry=ki());var Ai=globalThis.__zod_globalRegistry;function ji(e){return e.checks&&=[...e.checks],e}function Mi(e,t){return new e(ji({type:`string`,...C(t)}))}function Ni(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...C(t)})}function Pi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...C(t)})}function Fi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...C(t)})}function Ii(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...C(t)})}function Li(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...C(t)})}function Ri(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...C(t)})}function zi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...C(t)})}function Bi(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...C(t)})}function Vi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...C(t)})}function Hi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...C(t)})}function Ui(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...C(t)})}function Wi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...C(t)})}function Gi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...C(t)})}function Ki(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...C(t)})}function qi(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...C(t)})}function Ji(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...C(t)})}function Yi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...C(t)})}function Xi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...C(t)})}function Zi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...C(t)})}function Qi(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...C(t)})}function $i(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...C(t)})}function ea(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...C(t)})}function ta(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...C(t)})}function na(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...C(t)})}function ra(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...C(t)})}function ia(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...C(t)})}function aa(e,t){return new e(ji({type:`number`,checks:[],...C(t)}))}function oa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...C(t)})}function sa(e,t){return new e({type:`boolean`,...C(t)})}function ca(e){return new e({type:`unknown`})}function la(e,t){return new e({type:`never`,...C(t)})}function ua(e,t){return new hn({check:`less_than`,...C(t),value:e,inclusive:!1})}function da(e,t){return new hn({check:`less_than`,...C(t),value:e,inclusive:!0})}function fa(e,t){return new gn({check:`greater_than`,...C(t),value:e,inclusive:!1})}function M(e,t){return new gn({check:`greater_than`,...C(t),value:e,inclusive:!0})}function pa(e,t){return new _n({check:`multiple_of`,...C(t),value:e})}function ma(e,t){return new yn({check:`max_length`,...C(t),maximum:e})}function ha(e,t){return new bn({check:`min_length`,...C(t),minimum:e})}function ga(e,t){return new xn({check:`length_equals`,...C(t),length:e})}function _a(e,t){return new Cn({check:`string_format`,format:`regex`,...C(t),pattern:e})}function va(e){return new wn({check:`string_format`,format:`lowercase`,...C(e)})}function ya(e){return new Tn({check:`string_format`,format:`uppercase`,...C(e)})}function ba(e,t){return new En({check:`string_format`,format:`includes`,...C(t),includes:e})}function xa(e,t){return new Dn({check:`string_format`,format:`starts_with`,...C(t),prefix:e})}function Sa(e,t){return new On({check:`string_format`,format:`ends_with`,...C(t),suffix:e})}function Ca(e){return new kn({check:`overwrite`,tx:e})}function wa(e){return Ca(t=>t.normalize(e))}function Ta(){return Ca(e=>e.trim())}function Ea(){return Ca(e=>e.toLowerCase())}function Da(){return Ca(e=>e.toUpperCase())}function Oa(){return Ca(e=>le(e))}function ka(e,t,n){return new e({type:`array`,element:t,...C(n)})}function Aa(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...C(n)})}function ja(e,t){let n=Ma(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(ze(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(ze(r))}},e(t.value,t)),t);return n}function Ma(e,t){let n=new fn({check:`custom`,...C(t)});return n._zod.check=e,n}function Na(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&ne(e,t,n[t]);return e}function Pa(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Ai,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Fa(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Ia(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Ia(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Na(o.schema,c),t.io===`input`&&Ka(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function La(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ra(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${La(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+La(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
62
62
|
|
|
63
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function za(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;za(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Ba=new Set([`type`,`properties`,`required`,`additionalProperties`]),Va=[`oneOf`,`anyOf`];function Ha(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ua(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ba.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Ha(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}ne(n,r,e.length===1?e[0]:Ua(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Ha(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Wa(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ba)if(t in e)return;let n=t.filter(e=>Va.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ua(t);else{let e=n[0],i=Va.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ua([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Na(e,r))}function Ga(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Na(i,s),Na(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())za(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Wa(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Na(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,ne(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Ja(t,`input`,e.processors),output:Ja(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ka(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ka(r.element,n);if(r.type===`set`)return Ka(r.valueType,n);if(r.type===`lazy`)return Ka(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Ka(r.innerType,n);if(r.type===`intersection`)return Ka(r.left,n)||Ka(r.right,n);if(r.type===`record`||r.type===`map`)return Ka(r.keyType,n)||Ka(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ka(r.in,n)||Ka(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ka(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ka(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ka(e,n))return!0;return!!(r.rest&&Ka(r.rest,n))}return!1}var qa=(e,t={})=>n=>{let r=Pa({...n,processors:t});return Ia(e,r),Ra(r,e),Ga(r,e)},Ja=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Pa({...i??{},target:a,io:t,processors:n});return Ia(e,o),Ra(o,e),Ga(o,e)},Ya=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Xa=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Za=(e,t)=>{Ya(e,`minimum`,t),Xa(e,`maximum`,t)},Qa=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},$a=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},eo=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},to=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},no=(e,t)=>Ya(e,`minimum`,t.minimum),ro=(e,t)=>Xa(e,`maximum`,t.maximum),io=e=>(t,n)=>{to(t,n.format);let[r,i]=e[n.format];Ya(t,`minimum`,r),Xa(t,`maximum`,i)},ao={greater_than:(e,t)=>Ya(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Xa(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Qa(e,t.value),number_format:io(be),bigint_format:io(xe),min_length:no,max_length:ro,length_equals:(e,t)=>Za(e,t.length),min_size:no,max_size:ro,size_equals:(e,t)=>Za(e,t.size),string_format:(e,t)=>{to(e,t.format),t.pattern&&$a(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>eo(e,t.mime)};function oo(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)ao[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ya(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ya(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Xa(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Xa(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Qa(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&eo(t,i.mime);for(let e of i.patterns??[])$a(t,e);return t}var so={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},co=new Map([[fr,Zt],[mr,Qt]]),lo=e=>co.get(e)??e,uo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=oo(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=so[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(lo);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},fo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=oo(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Fa(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},po=(e,t,n,r)=>{n.type=`boolean`},mo=(e,t,n,r)=>{n.not={}},ho=(e,t,n,r)=>{let i=e._zod.def,a=h(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},go=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Fa(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Fa(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},_o=(e,t,n,r)=>{Fa(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},vo=(e,t,n,r)=>{Fa(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},yo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=oo(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Ia(a.element,t,{...r,path:[...r.path,`items`]})};function bo(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?bo(t.out):t.type===`catch`?bo(t.innerType):e._zod.optin}var xo=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Fa(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)ne(i.properties,e,Ia(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?bo(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Ia(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},So=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ia(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Co=(e,t,n,r)=>{let i=e._zod.def,a=Ia(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ia(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},wo=(e,t,n,r)=>{let i=e._zod.def,a=Ia(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},To=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Eo=Symbol();function Do(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Fa(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Eo):JSON.parse(o)}var Oo=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Do(i.defaultValue,e,t,n,r);o!==Eo&&(n.default=o)},ko=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Do(i.defaultValue,e,t,n,r);o!==Eo&&(n._prefault=o)},Ao=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Fa(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},jo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Ia(o,t,r);let s=t.seen.get(e);s.ref=o},Mo=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},No=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Po=new WeakSet([Object.prototype,Error.prototype]);function Fo(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Io=O(`ZodError`,(e,t)=>{dt.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Po.has(n)||(Po.add(n),Fo(n,`format`,e=>t=>mt(e,t)),Fo(n,`flatten`,e=>t=>pt(e,t)),Fo(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,_,2)}),Fo(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,_,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Lo=gt(Io),Ro=_t(Io),zo=vt(Io),Bo=bt(Io),Vo=Et(Io),Ho=Dt(Io),Uo=Ot(Io),Wo=kt(Io),Go=At(Io),Ko=jt(Io),qo=Mt(Io),Jo=Nt(Io);function Yo(){it.localeError||at(Ei())}function Xo(){it.memoizer||at({memoizer:Ci()})}var N=O(`ZodType`,(e,t)=>(Yo(),A.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(se(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return _e(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(cc(e,t))},superRefine(e,t){return this.check(lc(e,t))},overwrite(e){return this.check(Ca(e))},optional(){return Ws(this)},exactOptional(){return Ks(this)},nullable(){return Js(this)},nullish(){return Ws(Js(this))},nonoptional(e){return ec(this,e)},array(){return R(this)},or(e){return Ps([this,e])},and(e){return Rs(this,e)},transform(e){return ic(this,Hs(e))},default(e){return Xs(this,e)},prefault(e){return Qs(this,e)},catch(e){return nc(this,e)},pipe(e){return ic(this,e)},readonly(){return oc(this)},describe(e){let t=this.clone();return Ai.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ai.get(this);let t=this.clone();return Ai.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return He(this,`~standard`,{...Pn(this),jsonSchema:{input:Ja(this,`input`),output:Ja(this,`output`)}})},set"~standard"(e){Ve(this,`~standard`,e)},parse:function e(t,n){return Lo(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ro(this,t,n,{callee:e})},safeParse(e,t){return zo(this,e,t)},async safeParseAsync(e,t){return Bo(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ve(this,`spa`,e)},validate(e,t){return Ct(this,e,t)},validateAsync(e,t){return Tt(this,e,t)},encode:function e(t,n){return Vo(this,t,n,{callee:e})},decode:function e(t,n){return Ho(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Uo(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Wo(this,t,n,{callee:e})},safeEncode(e,t){return Go(this,e,t)},safeDecode(e,t){return Ko(this,e,t)},async safeEncodeAsync(e,t){return qo(this,e,t)},async safeDecodeAsync(e,t){return Jo(this,e,t)},toJSONSchema(e){return qa(this,{})(e)},get description(){return Ai.get(this)?.description},get _def(){return this._zod.def}}),P=O(`_ZodString`,(e,t)=>{Fn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r)},Ue({format:e=>oo(e).format??null,minLength:e=>oo(e).minimum??null,maxLength:e=>oo(e).maximum??null},{regex(...e){return this.check(_a(...e))},includes(...e){return this.check(ba(...e))},startsWith(...e){return this.check(xa(...e))},endsWith(...e){return this.check(Sa(...e))},min(...e){return this.check(ha(...e))},max(...e){return this.check(ma(...e))},length(...e){return this.check(ga(...e))},nonempty(...e){return this.check(ha(1,...e))},lowercase(e){return this.check(va(e))},uppercase(e){return this.check(ya(e))},trim(){return this.check(Ta())},normalize(...e){return this.check(wa(...e))},toLowerCase(){return this.check(Ea())},toUpperCase(){return this.check(Da())},slugify(){return this.check(Oa())}})),Zo=O(`ZodString`,(e,t)=>{Fn.init(e,t),P.init(e,t)},{email(e){return this.check(Ni(ns,e))},url(e){return this.check(zi(as,e))},jwt(e){return this.check(ea(xs,e))},emoji(e){return this.check(Bi(ss,e))},guid(e){return this.check(Pi(rs,e))},uuid(e){return this.check(Fi(is,e))},uuidv4(e){return this.check(Ii(is,e))},uuidv6(e){return this.check(Li(is,e))},uuidv7(e){return this.check(Ri(is,e))},nanoid(e){return this.check(Vi(cs,e))},cuid(e){return this.check(Hi(ls,e))},cuid2(e){return this.check(Ui(us,e))},ulid(e){return this.check(Wi(ds,e))},base64(e){return this.check(Zi(vs,e))},base64url(e){return this.check(Qi(ys,e))},xid(e){return this.check(Gi(fs,e))},ksuid(e){return this.check(Ki(ps,e))},ipv4(e){return this.check(qi(ms,e))},ipv6(e){return this.check(Ji(hs,e))},cidrv4(e){return this.check(Yi(gs,e))},cidrv6(e){return this.check(Xi(_s,e))},e164(e){return this.check($i(bs,e))},datetime(e){return this.check(ta(Qo,e))},date(e){return this.check(na($o,e))},time(e){return this.check(ra(es,e))},duration(e){return this.check(ia(ts,e))}});function F(e){return Mi(Zo,e)}var I=O(`ZodStringFormat`,(e,t)=>{j.init(e,t),P.init(e,t)}),Qo=O(`ZodISODateTime`,(e,t)=>{er.init(e,t),I.init(e,t)}),$o=O(`ZodISODate`,(e,t)=>{tr.init(e,t),I.init(e,t)}),es=O(`ZodISOTime`,(e,t)=>{nr.init(e,t),I.init(e,t)}),ts=O(`ZodISODuration`,(e,t)=>{rr.init(e,t),I.init(e,t)}),ns=O(`ZodEmail`,(e,t)=>{Rn.init(e,t),I.init(e,t)}),rs=O(`ZodGUID`,(e,t)=>{In.init(e,t),I.init(e,t)}),is=O(`ZodUUID`,(e,t)=>{Ln.init(e,t),I.init(e,t)}),as=O(`ZodURL`,(e,t)=>{Kn.init(e,t),I.init(e,t)});function os(e){return zi(as,e)}var ss=O(`ZodEmoji`,(e,t)=>{qn.init(e,t),I.init(e,t)}),cs=O(`ZodNanoID`,(e,t)=>{Jn.init(e,t),I.init(e,t)}),ls=O(`ZodCUID`,(e,t)=>{Yn.init(e,t),I.init(e,t)}),us=O(`ZodCUID2`,(e,t)=>{Xn.init(e,t),I.init(e,t)}),ds=O(`ZodULID`,(e,t)=>{Zn.init(e,t),I.init(e,t)}),fs=O(`ZodXID`,(e,t)=>{Qn.init(e,t),I.init(e,t)}),ps=O(`ZodKSUID`,(e,t)=>{$n.init(e,t),I.init(e,t)}),ms=O(`ZodIPv4`,(e,t)=>{ir.init(e,t),I.init(e,t)}),hs=O(`ZodIPv6`,(e,t)=>{sr.init(e,t),I.init(e,t)}),gs=O(`ZodCIDRv4`,(e,t)=>{cr.init(e,t),I.init(e,t)}),_s=O(`ZodCIDRv6`,(e,t)=>{ur.init(e,t),I.init(e,t)}),vs=O(`ZodBase64`,(e,t)=>{pr.init(e,t),I.init(e,t)}),ys=O(`ZodBase64URL`,(e,t)=>{gr.init(e,t),I.init(e,t)}),bs=O(`ZodE164`,(e,t)=>{_r.init(e,t),I.init(e,t)}),xs=O(`ZodJWT`,(e,t)=>{yr.init(e,t),I.init(e,t)}),Ss=O(`ZodNumber`,(e,t)=>{br.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.isFinite=!0},Ue({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=oo(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=oo(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=oo(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>oo(e).format??null},{gt(e,t){return this.check(fa(e,t))},gte(e,t){return this.check(M(e,t))},min(e,t){return this.check(M(e,t))},lt(e,t){return this.check(ua(e,t))},lte(e,t){return this.check(da(e,t))},max(e,t){return this.check(da(e,t))},int(e){return this.check(ws(e))},safe(e){return this.check(ws(e))},positive(e){return this.check(fa(0,e))},nonnegative(e){return this.check(M(0,e))},negative(e){return this.check(ua(0,e))},nonpositive(e){return this.check(da(0,e))},multipleOf(e,t){return this.check(pa(e,t))},step(e,t){return this.check(pa(e,t))},finite(){return this}}));function L(e){return aa(Ss,e)}var Cs=O(`ZodNumberFormat`,(e,t)=>{xr.init(e,t),Ss.init(e,t)});function ws(e){return oa(Cs,e)}var Ts=O(`ZodBoolean`,(e,t)=>{Sr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r)});function Es(e){return sa(Ts,e)}var Ds=O(`ZodUnknown`,(e,t)=>{Cr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Os(){return ca(Ds)}var ks=O(`ZodNever`,(e,t)=>{wr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r)});function As(e){return la(ks,e)}var js=O(`ZodArray`,(e,t)=>{Xo(),Or.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.element=t.element},{min(e,t){return this.check(ha(e,t))},nonempty(e){return this.check(ha(1,e))},max(e,t){return this.check(ma(e,t))},length(e,t){return this.check(ga(e,t))},unwrap(){return this.element}});function R(e,t){return ka(js,e,t)}var Ms=O(`ZodObject`,(e,t)=>{Xo(),Pr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),Ye(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return B(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(se(this._zod.def,{catchall:e}))},passthrough(){return this.clone(se(this._zod.def,{catchall:Os()}))},loose(){return this.clone(se(this._zod.def,{catchall:Os()}))},strict(){return this.clone(se(this._zod.def,{catchall:As()}))},strip(){return this.clone(se(this._zod.def,{catchall:void 0}))},extend(e){return Te(this,e)},safeExtend(e){return w(this,e)},merge(e){return T(this,e)},pick(e){return Se(this,e)},omit(e){return we(this,e)},partial(...e){return De(Us,this,e[0])},exactPartial(...e){return De(Gs,this,e[0],`exactPartial`)},required(...e){return Oe($s,this,e[0])}});function z(e,t){return new Ms({type:`object`,shape:e??{},...C(t)})}var Ns=O(`ZodUnion`,(e,t)=>{Ir.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.options=t.options});function Ps(e,t){return new Ns({type:`union`,options:e,...C(t)})}var Fs=O(`ZodDiscriminatedUnion`,(e,t)=>{Ns.init(e,t),Rr.init(e,t)});function Is(e,t,n){return new Fs({type:`union`,options:t,discriminator:e,...C(n)})}var Ls=O(`ZodIntersection`,(e,t)=>{zr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r)});function Rs(e,t){return new Ls({type:`intersection`,left:e,right:t})}var zs=O(`ZodEnum`,(e,t)=>{Hr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new zs({...t,checks:[],...C(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new zs({...t,checks:[],...C(r),entries:i})}});function B(e,t){return new zs({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...C(t)})}var Bs=O(`ZodLiteral`,(e,t)=>{Ur.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function V(e,t){return new Bs({type:`literal`,values:Array.isArray(e)?e:[e],...C(t)})}var Vs=O(`ZodTransform`,(e,t)=>{Xo(),Wr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new rt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ze(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(ze(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Hs(e){return new Vs({type:`transform`,transform:e})}var Us=O(`ZodOptional`,(e,t)=>{Kr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ws(e){return new Us({type:`optional`,innerType:e})}var Gs=O(`ZodExactOptional`,(e,t)=>{qr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ks(e){return new Gs({type:`optional`,innerType:e})}var qs=O(`ZodNullable`,(e,t)=>{Jr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Js(e){return new qs({type:`nullable`,innerType:e})}var Ys=O(`ZodDefault`,(e,t)=>{Yr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Xs(e,t){return new Ys({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():me(t)}})}var Zs=O(`ZodPrefault`,(e,t)=>{Zr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qs(e,t){return new Zs({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():me(t)}})}var $s=O(`ZodNonOptional`,(e,t)=>{Qr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ec(e,t){return new $s({type:`nonoptional`,innerType:e,...C(t)})}var tc=O(`ZodCatch`,(e,t)=>{ti.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nc(e,t){return new tc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Ze(t)})}var rc=O(`ZodPipe`,(e,t)=>{ni.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.in=t.in,e.out=t.out});function ic(e,t){return new rc({type:`pipe`,in:e,out:t})}var ac=O(`ZodReadonly`,(e,t)=>{ii.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oc(e){return new ac({type:`readonly`,innerType:e})}var sc=O(`ZodCustom`,(e,t)=>{oi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r)});function cc(e,t={}){return Aa(sc,e,t)}function lc(e,t){return ja(e,t)}function uc(e){return ta(Qo,e)}var dc={Host:`host`,Branches:`branches`},fc=z({number:L().int().positive(),title:F(),author:F(),headRef:F().min(1),baseRef:F().min(1)}),pc=z({source:B(dc),trunk:F().min(1),members:R(fc).min(2).max(20).readonly(),leftOut:R(fc).max(20).readonly()}),mc=z({id:L().int().positive(),position:L().int().positive()}),hc=pc.extend({joining:R(L().int().positive()).min(1).readonly()});z({ai:Es()});var gc={GitHub:`github`,GitLab:`gitlab`},_c=F().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/).brand(),vc={title:F(),description:F(),author:F(),baseRef:F(),headRef:F(),baseSha:_c,headSha:_c,mergeBaseSha:_c},yc=Is(`host`,[z({host:B(gc),url:os(),repositoryWebUrl:os(),number:L().int().positive(),...vc}),z({host:V(`local`),repositoryName:F(),...vc})]),bc=L().int().positive(),xc={Context:`context`,Added:`added`,Removed:`removed`},Sc=Is(`kind`,[z({kind:V(xc.Context),content:F(),oldLine:bc,newLine:bc}),z({kind:V(xc.Added),content:F(),newLine:bc}),z({kind:V(xc.Removed),content:F(),oldLine:bc})]),Cc=z({oldStart:L().int().nonnegative(),oldLines:L().int().nonnegative(),newStart:L().int().nonnegative(),newLines:L().int().nonnegative(),section:F(),lines:R(Sc).readonly()}),wc={Text:`text`,Binary:`binary`},Tc=Is(`kind`,[z({kind:V(wc.Text),hunks:R(Cc).readonly()}),z({kind:V(wc.Binary)})]),Ec={Added:`added`,Modified:`modified`,Deleted:`deleted`,Renamed:`renamed`,Copied:`copied`},Dc={Rust:`rust`,TypeScript:`typescript`,Tsx:`tsx`,Python:`python`,Go:`go`,Java:`java`,C:`c`,Cpp:`cpp`,Kotlin:`kotlin`,CSharp:`csharp`},Oc={Function:`function`,Method:`method`,Class:`class`,Struct:`struct`,Enum:`enum`,Trait:`trait`,Impl:`impl`,Interface:`interface`,TypeAlias:`typeAlias`,Constant:`constant`,Macro:`macro`,Module:`module`,TestSuite:`testSuite`,Test:`test`,TestHook:`testHook`,ModuleScope:`moduleScope`},kc=z({startLine:bc,endLine:bc,text:F(),elidesNestedUnits:Es()}),Ac={Added:`added`,Removed:`removed`,Modified:`modified`,Renamed:`renamed`,MovedIn:`movedIn`,MovedOut:`movedOut`},jc={Semantic:`semantic`,CommentsOnly:`commentsOnly`,FormattingOnly:`formattingOnly`},Mc=z({path:F().min(1),qualifiedName:F()}),Nc=Is(`kind`,[z({kind:V(Ac.Added),after:kc}),z({kind:V(Ac.Removed),before:kc}),z({kind:V(Ac.Modified),weight:B(jc),before:kc,after:kc}),z({kind:V(Ac.Renamed),previousName:F(),before:kc,after:kc}),z({kind:V(Ac.MovedIn),from:Mc,edited:Es().default(!1),before:kc,after:kc}),z({kind:V(Ac.MovedOut),to:Mc,edited:Es().default(!1),before:kc})]),Pc=z({parametersAdded:R(F()).readonly(),parametersRemoved:R(F()).readonly(),parametersChanged:R(F()).readonly(),returnType:z({before:F().nullable(),after:F().nullable()}).nullable(),callsAdded:R(F()).readonly(),callsRemoved:R(F()).readonly(),errorPathsDelta:L().int(),branchesDelta:L().int(),complexity:z({before:L().int(),after:L().int()}).nullable()}),Fc=z({kind:B(Oc),name:F(),qualifiedName:F(),change:Nc,facts:Pc.nullable()}),Ic=z({path:F().min(1),line:bc,callerQualifiedName:F().nullable(),confidence:B({Exact:`exact`,Likely:`likely`,Possible:`possible`}),touchedByPullRequest:Es(),snippet:F()}),Lc={Traced:`traced`,TooCommon:`tooCommon`,Skipped:`skipped`},Rc=Is(`status`,[z({status:V(Lc.Traced),searchedName:F(),references:R(Ic).readonly(),totalReferences:L().int().nonnegative()}),z({status:V(Lc.TooCommon),searchedName:F(),matchingFiles:L().int().positive()}),z({status:V(Lc.Skipped),searchedName:F(),reason:F()})]),zc=Fc.extend({impact:Rc.nullable()}),Bc=z({kind:B({Lockfile:`lockfile`,Generated:`generated`,Vendored:`vendored`}),reason:F()}),Vc={Analyzed:`analyzed`,UnsupportedLanguage:`unsupportedLanguage`,Skipped:`skipped`},Hc=z({kind:B(Oc),qualifiedName:F(),startLine:bc,endLine:bc}),Uc=z({caller:F(),callee:F()}),Wc=Is(`status`,[z({status:V(Vc.Analyzed),language:B(Dc),units:R(zc).readonly(),outline:R(Hc).readonly(),calls:R(Uc).readonly()}),z({status:V(Vc.UnsupportedLanguage)}),z({status:V(Vc.Skipped),reason:F()})]),Gc=z({path:F().min(1),additions:L().int().nonnegative(),deletions:L().int().nonnegative(),content:Tc}),Kc={previousPath:F().min(1),similarity:L().int().min(0).max(100)},qc=z({diff:Is(`status`,[Gc.extend({status:V(Ec.Added)}),Gc.extend({status:V(Ec.Modified)}),Gc.extend({status:V(Ec.Deleted)}),Gc.extend({status:V(Ec.Renamed),...Kc}),Gc.extend({status:V(Ec.Copied),...Kc})]),noise:Bc.nullable(),syntax:Wc}),Jc={High:`high`,Medium:`medium`,Low:`low`},Yc={Secret:`secret`,DangerousApi:`dangerousApi`,SensitivePath:`sensitivePath`,Dependency:`dependency`,Vulnerability:`vulnerability`,CodeScan:`codeScan`,CodeQuality:`codeQuality`,Tests:`tests`,Size:`size`,BrokenReference:`brokenReference`,BreakingChange:`breakingChange`,License:`license`,AttackSurface:`attackSurface`,Infrastructure:`infrastructure`,SupplyChain:`supplyChain`},Xc=z({path:F().min(1),line:bc.nullable()}),Zc={Security:`security`,Review:`review`,Context:`context`},Qc=z({id:F().min(1),label:F().min(1),kind:B(Zc),advice:F()}),$c=z({ruleId:F(),category:F().min(1),severity:B(Jc),title:F(),detail:F(),location:Xc.nullable(),evidence:F().nullable(),unit:F().optional(),check:F().optional()}),el=z({check:F(),reason:F()}),tl=z({name:F(),detail:F(),security:Es().optional()}),nl=z({securityLevel:B(Jc),findings:R($c).readonly(),checksRun:R(tl).readonly(),notChecked:R(el).readonly(),dimensions:R(Qc).readonly().optional()}),rl=z({path:F().min(1),side:B({Before:`before`,After:`after`}),startLine:bc,endLine:bc}),il=z({path:F().min(1),qualifiedName:F()}),al=z({title:F(),summary:F(),units:R(il).readonly()}),ol=z({claim:F(),verdict:B({Matches:`matches`,Contradicts:`contradicts`,Undocumented:`undocumented`,NotFound:`notFound`}),explanation:F(),citations:R(rl).readonly()}),sl=z({question:F(),why:F(),citations:R(rl).min(1).readonly()}),cl={Disabled:`disabled`,Unavailable:`unavailable`,Completed:`completed`},ll=Is(`status`,[z({status:V(cl.Disabled)}),z({status:V(cl.Unavailable),reason:F()}),z({status:V(cl.Completed),model:F(),chapters:R(al).readonly(),intent:R(ol).readonly(),questions:R(sl).readonly(),droppedStatements:L().int().nonnegative(),unitsSummarizedOnly:L().int().nonnegative(),usage:z({inputTokens:L().int().nonnegative(),outputTokens:L().int().nonnegative()}),estimatedCostUsd:L().nonnegative().nullable(),cached:Es()})]),ul=z({source:F(),files:R(z({path:F().min(1),coveredLines:R(bc).readonly(),uncoveredLines:R(bc).readonly()})).readonly()});z({schemaVersion:V(11),generatedAt:uc(),pullRequest:yc,files:R(qc).readonly(),risk:nl,ai:ll,testCoverage:ul.nullable().default(null),feedbackUrl:os({protocol:/^https?$/}).nullable()});var dl={Queued:`queued`,Analyzing:`analyzing`,Ready:`ready`,Failed:`failed`};z({reports:R(z({name:F().min(1),text:F()})).min(1)});var fl=z({headSha:_c,baseRef:F()}),pl=z({id:L().int().positive(),url:os(),host:B(gc),displayName:F(),number:L().int().positive(),status:B(dl),step:B(d).nullable().default(null),error:F().nullable(),hasReport:Es(),ai:Es(),title:F().nullable(),author:F().nullable(),securityLevel:B(Jc).nullable(),unitsToReview:L().int().nonnegative().nullable(),untouchedReferences:L().int().nonnegative().nullable(),findings:L().int().nonnegative().nullable(),coverageSource:F().nullable(),reportHead:fl.nullable(),stack:mc.nullable(),stackOffer:hc.nullable().default(null),createdAt:uc(),updatedAt:uc()});z({url:F().min(1),ai:Es()});function ml(e,t,n,r){return{id:e,label:t,kind:n,advice:r}}var hl=[ml(Yc.Secret,`Possible secret`,Zc.Security,`If it's real, revoke it.`),ml(Yc.AttackSurface,`Attack surface`,Zc.Security,`Check who can reach it and what it trusts.`),ml(Yc.DangerousApi,`Risky API`,Zc.Security,`Check that users can't control the input.`),ml(Yc.SupplyChain,`Supply chain`,Zc.Security,`Check where the package comes from before installing it.`),ml(Yc.Dependency,`Dependency`,Zc.Security,`Check that you trust it.`),ml(Yc.Vulnerability,`Known vulnerability`,Zc.Security,`Upgrade before merging if you can.`),ml(Yc.Infrastructure,`Infrastructure`,Zc.Security,`Check it's intended for this environment.`),ml(Yc.SensitivePath,`Sensitive area`,Zc.Security,`Check this is intended.`),ml(Yc.CodeScan,`Code scan`,Zc.Security,`Check whether it applies here.`),ml(Yc.BreakingChange,`Breaking change`,Zc.Review,`This may break callers or a deployment, so check who depends on it.`),ml(Yc.BrokenReference,`Broken reference`,Zc.Review,`Check that nothing still depends on it.`),ml(Yc.License,`Licence`,Zc.Review,`Check it's acceptable before merging.`),ml(Yc.Tests,`Tests`,Zc.Review,`Ask whether this needs tests.`),ml(Yc.CodeQuality,`Code quality`,Zc.Context,``),ml(Yc.Size,`Size`,Zc.Context,``)];new Map(hl.map(e=>[e.id,e])),Oc.TestSuite,Oc.Test,Oc.TestHook,Oc.Function,Oc.Method,Oc.Class;var gl={Semgrep:`semgrep`,Gitleaks:`gitleaks`,OsvScanner:`osvScanner`,OsvDatabase:`osvDatabase`,DependencyTrust:`dependencyTrust`,NpmReleases:`npmReleases`,Zizmor:`zizmor`,Poutine:`poutine`,Ruff:`ruff`,Oxlint:`oxlint`,Jscpd:`jscpd`,FunctionMetrics:`functionMetrics`},_l={Anthropic:`anthropic`,OpenAiCompatible:`openaiCompatible`},vl=`claude-opus-5-5`,yl=new Set([`localhost`,`127.0.0.1`,`[::1]`]);function bl(e){return yl.has(e.hostname)}function xl(e){if(!URL.canParse(e))return`Enter a full address, such as https://api.example.com/v1`;let t=new URL(e);if(!(t.protocol===`https:`||t.protocol===`http:`&&bl(t)))return`Use https, because this address receives your code and API key. Plain http only works for a model on this machine`}var Sl=z({provider:B(_l),model:F().trim().min(1,`Enter a model name`),baseUrl:F().nullable(),maxInputTokens:L().int().positive(),enabledByDefault:Es()}).superRefine((e,t)=>{if(e.provider!==_l.OpenAiCompatible)return;let n=e.baseUrl===null?`Enter the provider's address`:xl(e.baseUrl);n!==void 0&&t.addIssue({code:`custom`,path:[`baseUrl`],message:n})}),Cl=z({disabledChecks:R(B(gl)).readonly(),ai:Sl});_l.Anthropic;var wl=`local`,Tl=`ANTHROPIC_BASE_URL`;function El(e,t){if(e.provider===_l.Anthropic||e.baseUrl===null){if(t===void 0)return{label:`Anthropic`,isLocal:!1,ids:[_l.Anthropic]};let{host:e}=new URL(t);return{label:`${e}, set by ${Tl}`,isLocal:!1,ids:[e]}}let n=new URL(e.baseUrl);return bl(n)?{label:`a model on this machine`,isLocal:!0,ids:[n.host,wl]}:{label:n.host,isLocal:!1,ids:[n.host]}}var Dl=z({where:F(),what:F(),when:F()}),Ol=z({id:B(gl),name:F(),purpose:F(),installed:Es().nullable(),install:F().nullable(),sends:Dl.nullable()}),kl=z({settings:Cl,anthropicBaseUrl:F().nullable()}),Al=z({settings:Cl,checks:R(Ol).readonly(),aiKeys:z({anthropic:Es(),openaiCompatible:Es()}),anthropicBaseUrl:F().nullable(),offline:Es()}),jl=z({ok:Es(),message:F()}),Ml={Comment:`comment`,Approve:`approve`,RequestChanges:`requestChanges`},Nl=6e4,Pl=L().int().positive(),Fl={Old:`old`,New:`new`},Il=z({oldLine:Pl.nullable(),newLine:Pl.nullable()}),Ll=z({side:B(Fl),start:Il,end:Il}),Rl=z({path:F().min(1),previousPath:F().min(1),line:Pl.nullable(),label:F(),range:Ll.nullable().default(null),body:F().trim().min(1).max(Nl)});z({event:B(Ml),body:F().trim().max(Nl),headSha:F().min(1),comments:R(Rl).readonly()}).superRefine((e,t)=>{e.event===Ml.RequestChanges&&e.body===``&&e.comments.length===0&&t.addIssue({code:`custom`,path:[`body`],message:`Say what needs to change`}),e.event===Ml.Comment&&e.body===``&&e.comments.length===0&&t.addIssue({code:`custom`,path:[`body`],message:`Add a comment first`})}),z({body:F().trim().min(1).max(Nl)}),z({resolved:Es()});var zl={Approved:`approved`,ChangesRequested:`changesRequested`,Commented:`commented`,Other:`other`},Bl=z({author:F(),body:F(),createdAt:F(),url:F().nullable()}),Vl=z({id:F().min(1),path:F().nullable(),line:Pl.nullable(),side:B(Fl).default(Fl.New),isResolved:Es(),isOutdated:Es(),comments:R(Bl).readonly()}),Hl=z({name:F(),state:B(zl)});z({reviewers:R(Hl).readonly(),threads:R(Vl).readonly(),truncated:Es()}),z({url:F()});var Ul={Open:`open`,Merged:`merged`,Closed:`closed`},Wl=z({state:B(Ul),headSha:_c,baseRef:F()}),Gl={None:`none`,NoReport:`noReport`,NewCommits:`newCommits`,Retargeted:`retargeted`},Kl={Checked:`checked`,Failed:`failed`},ql=Is(`check`,[z({check:V(Kl.Checked),reviewId:L().int().positive(),status:Wl,reportChange:B(Gl),reviewers:R(Hl).readonly()}),z({check:V(Kl.Failed),reviewId:L().int().positive(),error:F()})]),Jl=z({id:L().int().positive(),trunk:F(),members:R(ql).readonly()});function Yl(e,t){return`${e===gc.GitHub?`#`:`!`}${t}`}z({body:F().trim().max(Nl),members:R(z({reviewId:L().int().positive(),headSha:_c})).min(1).max(20)});var Xl=z({reviewId:L().int().positive(),reason:F()}),Zl=z({error:F(),blocked:R(Xl).min(1)}),Ql={Posted:`posted`,Refused:`refused`},$l=z({results:R(Is(`outcome`,[z({outcome:V(Ql.Posted),reviewId:L().int().positive(),url:F()}),z({outcome:V(Ql.Refused),reviewId:L().int().positive(),error:F()})]))}),eu=`walkdiff-progress:`,tu=z({reviewed:L().int().nonnegative(),total:L().int().nonnegative(),drafts:L().int().nonnegative(),head:fl}).refine(e=>e.reviewed<=e.total);function nu(e){return`${eu}${e}`}function ru(e){if(e!==null)try{let t=tu.safeParse(JSON.parse(e));return t.success?t.data:void 0}catch{return}}var iu=`X-Walkdiff-Key`;function au(){return document.querySelector(`meta[name="walkdiff-api-key"]`)?.getAttribute(`content`)??``}async function ou(e,t,n){let r=await fetch(e,{method:t,headers:{[iu]:au(),...n===void 0?{}:{"Content-Type":`application/json`}},...n===void 0?{}:{body:JSON.stringify(n)}});return{status:r.status,payload:await r.json()}}async function H(e,t,n){let{status:r,payload:i}=await ou(e,t,n);if(r>=400)throw Error(U(i)??`The app answered ${r}`);return i}function U(e){return typeof e==`object`&&e&&`error`in e&&typeof e.error==`string`?e.error:void 0}async function su(){return pl.array().parse(await H(`/api/reviews`,`GET`))}async function cu(e){await H(`/api/reviews`,`POST`,e)}async function lu(e){await H(`/api/reviews/${e}/refresh`,`POST`)}async function uu(e,t){let n=await Promise.all(t.map(async e=>({name:e.name,text:await e.text()})));await H(`/api/reviews/${e}/coverage`,`POST`,{reports:n})}async function du(e){await H(`/api/reviews/${e}`,`DELETE`)}async function fu(e,t){await H(`/api/reviews/${e}/stack`,`POST`,t)}async function pu(e){await H(`/api/reviews/${e}/stack`,`DELETE`)}async function mu(e){return Jl.parse(await H(`/api/stacks/${e}`,`GET`))}async function hu(e){return Jl.parse(await H(`/api/stacks/${e}/refresh`,`POST`))}var gu=409,_u={Ready:`ready`,Done:`done`,Blocked:`blocked`};async function vu(e,t){let n=await ou(`/api/stacks/${e}/approve/check`,`POST`,t);if(n.status===gu)return{kind:_u.Blocked,blocked:Zl.parse(n.payload)};if(n.status>=400)throw Error(U(n.payload)??`The app answered ${n.status}`);return{kind:_u.Ready}}async function yu(e,t){let n=await ou(`/api/stacks/${e}/approve`,`POST`,t);if(n.status===gu)return{kind:_u.Blocked,blocked:Zl.parse(n.payload)};if(n.status>=400)throw Error(U(n.payload)??`The app answered ${n.status}`);return{kind:_u.Done,result:$l.parse(n.payload)}}async function bu(e){await H(`/api/stacks/${e}`,`DELETE`)}async function xu(){return Al.parse(await H(`/api/settings`,`GET`))}async function Su(){return kl.parse(await H(`/api/settings/current`,`GET`))}async function Cu(e){return Al.parse(await H(`/api/settings`,`PUT`,e))}async function wu(){return jl.parse(await H(`/api/settings/test-ai`,`POST`))}function Tu(){let[e,t]=(0,l.useState)({destination:void 0,enabledByDefault:!1,problem:void 0});return(0,l.useEffect)(()=>{Su().then(({settings:e,anthropicBaseUrl:n})=>t({destination:El(e.ai,n??void 0),enabledByDefault:e.ai.enabledByDefault,problem:void 0})).catch(e=>t(t=>({...t,problem:e instanceof Error?e.message:String(e)})))},[]),e}function Eu(e){return e===void 0?`Include AI review`:e.isLocal?`Include AI review (uses a model on this machine; your code stays here)`:`Include AI review (sends the changed code to ${e.label}, and may cost money)`}var Du=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2064%2064'%20role='img'%20aria-label='Walkdiff'%3e%3cdefs%3e%3clinearGradient%20id='walk'%20x1='0'%20y1='0'%20x2='1'%20y2='0'%3e%3cstop%20offset='0'%20stop-color='%23f85149'/%3e%3cstop%20offset='1'%20stop-color='%233fb950'/%3e%3c/linearGradient%3e%3c/defs%3e%3crect%20width='64'%20height='64'%20rx='14'%20fill='%230d1117'/%3e%3cpath%20d='M11%2018%20L22%2046%20L32%2026%20L42%2046%20L53%2018'%20fill='none'%20stroke='url(%23walk)'%20stroke-width='6'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3ccircle%20cx='11'%20cy='18'%20r='5.5'%20fill='%23f85149'/%3e%3ccircle%20cx='32'%20cy='26'%20r='4'%20fill='%23e6edf3'/%3e%3ccircle%20cx='53'%20cy='18'%20r='5.5'%20fill='%233fb950'/%3e%3c/svg%3e`,Ou={NotStarted:`notStarted`,Partly:`partly`,Done:`done`,Changed:`changed`,NothingToReview:`nothingToReview`};function ku(e){return Au(Pu(e.url),e.reportHead)}function Au(e,t){if(e===void 0)return{stage:Ou.NotStarted,drafts:0};let{drafts:n,reviewed:r,total:i}=e,a=Nu(e.head,t);return a&&i===0?{stage:Ou.NothingToReview,drafts:n}:r===0?{stage:Ou.NotStarted,drafts:n}:a?r===i?{stage:Ou.Done,drafts:n}:{stage:Ou.Partly,reviewed:r,total:i,drafts:n}:{stage:Ou.Changed,drafts:n}}function ju(e){let t=e.drafts===0?``:`, ${e.drafts} ${e.drafts===1?`comment`:`comments`} not posted`;return`${Mu(e)}${t}`}function Mu(e){switch(e.stage){case Ou.NotStarted:return`not started`;case Ou.Partly:return`${e.reviewed} of ${e.total} reviewed`;case Ou.Done:return`✓ reviewed`;case Ou.Changed:return`changed since you reviewed it`;case Ou.NothingToReview:return`nothing to mark as reviewed`}}function Nu(e,t){return t!==null&&e.headSha===t.headSha&&e.baseRef===t.baseRef}function Pu(e){try{return ru(window.localStorage.getItem(nu(e)))}catch{return}}var Fu={Review:`review`,Stack:`stack`};function Iu(e){let t=[],n=new Set;for(let r of e){if(r.stack===null){t.push({kind:Fu.Review,review:r});continue}let{id:i}=r.stack;if(n.has(i))continue;n.add(i);let a=e.filter(e=>e.stack?.id===i).toSorted((e,t)=>(e.stack?.position??0)-(t.stack?.position??0));t.push({kind:Fu.Stack,id:i,members:a})}return t}function Lu(e,t){return e.url.replace(/\d+$/,String(t))}function Ru(e,t){return`${Yl(e.host,t.number)} ${t.title}`}function zu(e,t,n){let r=new Set(n.map(e=>e.url));return e.joining.filter(e=>!r.has(Lu(t,e)))}var Bu={Good:`good`,Attention:`attention`,Muted:`muted`,Problem:`problem`};function Vu(e){if(e.check===Kl.Failed)return[{text:`Couldn't check: ${e.error}`,tone:Bu.Problem}];if(e.status.state===Ul.Merged)return[{text:`Merged`,tone:Bu.Muted}];if(e.status.state===Ul.Closed)return[{text:`Closed`,tone:Bu.Muted}];let t=[],n=Hu(e.reportChange,e.status.baseRef);n!==void 0&&t.push(n);let r=Uu(e,zl.Approved);r.length>0&&t.push({text:`Approved by ${r.join(`, `)}`,tone:Bu.Good});let i=Uu(e,zl.ChangesRequested);return i.length>0&&t.push({text:`Changes requested by ${i.join(`, `)}`,tone:Bu.Attention}),t}function Hu(e,t){switch(e){case Gl.None:return;case Gl.NoReport:return{text:`No report yet`,tone:Bu.Attention};case Gl.NewCommits:return{text:`New commits`,tone:Bu.Attention};case Gl.Retargeted:return{text:`Retargeted to ${t}`,tone:Bu.Attention}}}function Uu(e,t){return e.check===Kl.Checked?e.reviewers.filter(e=>e.state===t).map(e=>e.name):[]}function Wu(e){if(e?.check===Kl.Checked&&e.status.state!==Ul.Open)return e.status.state}function Gu(e){return Wu(e)!==void 0}function Ku(e,t){let n=t?.members??[],r=e.length-n.filter(Gu).length,i=[`${r} ${r===1?`PR`:`PRs`}`],a=n.filter(e=>!Gu(e)&&Uu(e,zl.Approved).length>0).length;a>0&&i.push(`${a} approved`);let o=n.filter(e=>e.check===Kl.Checked&&e.reportChange!==Gl.None).length;return o>0&&i.push(`${o} ${o===1?`needs`:`need`} a refresh`),i.join(` · `)}function qu(e){return e.status===dl.Queued||e.status===dl.Analyzing}function Ju(e,t){if(e===void 0)return{ready:!1,blocker:`Still checking with the host.`};if(e.check===Kl.Failed)return{ready:!1,blocker:`Couldn't check it: ${e.error}`};switch(e.reportChange){case Gl.NoReport:return{ready:!1,blocker:`It has no report yet.`};case Gl.NewCommits:return{ready:!1,blocker:`It has new commits. Refresh it first.`};case Gl.Retargeted:return{ready:!1,blocker:`It merges into ${e.status.baseRef} now. Refresh it first.`};case Gl.None:return{ready:!0,headSha:e.status.headSha,warnings:Yu(t)}}}function Yu(e){return[Xu(e.drafts),Zu(e)].filter(e=>e!==void 0)}function Xu(e){if(e!==0)return e===1?`It has a comment you haven't posted. Open it to post it, or approve without it.`:`It has ${e} comments you haven't posted. Open it to post them, or approve without them.`}function Zu(e){switch(e.stage){case Ou.NotStarted:return`You haven't started reviewing it.`;case Ou.Partly:return`You've reviewed ${e.reviewed} of ${e.total} changes.`;case Ou.Changed:return`It changed since you reviewed it. Open it to see what's new.`;case Ou.Done:case Ou.NothingToReview:return}}function Qu(e){return/^https?:\/\//i.test(e)}var $u=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),W=e(((e,t)=>{t.exports=$u()}))();function ed({review:e,offer:t,reviews:n,destination:r,onAccept:i,onDismiss:a}){let[o,s]=(0,l.useState)(e.ai),c=e.stack!==null,u=zu(t,e,n).length,d=t.joining.length;return(0,W.jsxs)(`section`,{className:`stack-offer`,"aria-label":`Stack found`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{children:c?`${d} new ${d===1?`PR`:`PRs`} joined this stack`:`Part of a stack of ${t.members.length}`}),` into `,(0,W.jsx)(`code`,{children:t.trunk}),`: `,(0,W.jsx)(G,{review:e,members:t.members})]}),t.leftOut.length>0&&(0,W.jsx)(K,{review:e,offer:t}),u>0?(0,W.jsxs)(`label`,{className:`add-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),Eu(r),`, for the `,u===1?`PR`:`${u} PRs`,` not on your list yet`]}):(0,W.jsxs)(`p`,{className:`stack-offer-note`,children:[d===1?`It's`:`They're all`,` on your list already, and will be grouped without analyzing again.`]}),(0,W.jsxs)(`div`,{className:`review-actions`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>i(o),children:c?`Add to the stack`:`Review the whole stack`}),(0,W.jsx)(`button`,{type:`button`,onClick:a,children:`Not now`})]})]})}function G({review:e,members:t}){return(0,W.jsx)(W.Fragment,{children:t.map((t,n)=>(0,W.jsxs)(l.Fragment,{children:[n>0&&` → `,t.number===e.number?(0,W.jsxs)(`strong`,{children:[Ru(e,t),` (this one)`]}):(0,W.jsx)(`a`,{href:Lu(e,t.number),target:`_blank`,rel:`noreferrer`,children:Ru(e,t)})]},t.number))})}function K({review:e,offer:t}){let n=t.members.at(-1);return n===void 0?null:(0,W.jsxs)(`p`,{className:`stack-offer-note`,children:[t.leftOut.map((n,r)=>(0,W.jsxs)(l.Fragment,{children:[r>0&&(r===t.leftOut.length-1?` and `:`, `),(0,W.jsx)(`a`,{href:Lu(e,n.number),target:`_blank`,rel:`noreferrer`,children:Ru(e,n)})]},n.number)),` `,`also build on `,Ru(e,n),`. Add them on their own if you want to review them.`]})}var q=`https://github.com/navasvarela/walkdiff/blob/main/docs/troubleshooting.md`,J={[dl.Queued]:`Queued`,[dl.Analyzing]:`Analyzing…`,[dl.Ready]:`Ready`,[dl.Failed]:`Failed`},Y={[Jc.High]:`High severity finding`,[Jc.Medium]:`Medium severity finding`,[Jc.Low]:`Low severity finding`};function td({review:e,reviews:t,destination:n,actions:r,badge:i,children:a}){let o=qu(e);return(0,W.jsxs)(`div`,{className:`review`,children:[(0,W.jsxs)(`div`,{className:`review-main`,children:[i,e.securityLevel!==null&&e.securityLevel!==Jc.Low&&(0,W.jsx)(`span`,{className:`level level-${e.securityLevel}`,children:Y[e.securityLevel]}),e.hasReport?(0,W.jsx)(`a`,{className:`review-title`,href:`/reviews/${e.id}/`,children:e.title??e.displayName}):(0,W.jsx)(`span`,{className:`review-title`,children:e.title??e.displayName}),e.status!==dl.Ready&&(0,W.jsx)(`span`,{className:`status status-${e.status}`,children:J[e.status]})]}),e.status===dl.Analyzing&&(0,W.jsx)(rd,{review:e}),(0,W.jsx)(nd,{review:e}),a,e.error!==null&&(0,W.jsxs)(`p`,{className:`problem`,children:[e.error,` `,(0,W.jsx)(`a`,{href:`https://github.com/navasvarela/walkdiff/blob/main/docs/troubleshooting.md`,target:`_blank`,rel:`noreferrer`,children:`How to fix this`})]}),e.stackOffer!==null&&(0,W.jsx)(ed,{review:e,offer:e.stackOffer,reviews:t,destination:n,onAccept:r.acceptStack,onDismiss:r.dismissStack}),(0,W.jsxs)(`div`,{className:`review-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:o,onClick:r.refresh,children:`Refresh`}),e.hasReport&&!o&&(0,W.jsx)(ad,{hasCoverage:e.coverageSource!==null,onAttach:r.attachCoverage}),(0,W.jsx)(`button`,{type:`button`,onClick:r.remove,children:`Remove`})]})]})}function nd({review:e}){return(0,W.jsxs)(`p`,{className:`review-meta`,children:[(0,W.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.displayName}),e.author!==null&&(0,W.jsxs)(W.Fragment,{children:[` by `,e.author]}),e.unitsToReview!==null&&(0,W.jsxs)(W.Fragment,{children:[` · `,e.unitsToReview,` to review`]}),e.untouchedReferences!==null&&e.untouchedReferences>0&&(0,W.jsxs)(W.Fragment,{children:[` · `,e.untouchedReferences,` untouched callers`]}),e.findings!==null&&(0,W.jsxs)(W.Fragment,{children:[` `,`· `,e.findings,` `,e.findings===1?`finding`:`findings`]}),e.ai&&(0,W.jsx)(W.Fragment,{children:` · AI`}),e.hasReport&&(0,W.jsxs)(W.Fragment,{children:[` · `,ju(ku(e))]}),e.hasReport&&(0,W.jsxs)(W.Fragment,{children:[` · `,id(e.coverageSource)]}),(0,W.jsxs)(W.Fragment,{children:[` · updated `,new Date(e.updatedAt).toLocaleString()]})]})}function rd({review:e}){if(e.step===null)return(0,W.jsx)(`div`,{className:`progress progress-starting`,role:`progressbar`,"aria-label":`Starting the analysis`});let{number:t,total:n,label:r}=m(e.step,e.ai);return(0,W.jsxs)(`div`,{className:`analysis-progress`,children:[(0,W.jsxs)(`div`,{className:`progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":t-1,"aria-valuetext":`Step ${t} of ${n}: ${r}`,children:[(0,W.jsx)(`div`,{className:`progress-done`,style:{width:`${(t-1)/n*100}%`}}),(0,W.jsx)(`div`,{className:`progress-current`,style:{left:`${(t-1)/n*100}%`,width:`${100/n}%`}})]}),(0,W.jsxs)(`p`,{className:`progress-label`,children:[`Step `,t,` of `,n,`: `,r,`…`]})]})}function id(e){return e===null?`no coverage found`:`coverage from ${e}`}function ad({hasCoverage:e,onAttach:t}){return(0,W.jsxs)(`label`,{className:`file-button`,title:`An LCOV or Cobertura report from this PR's latest commit. Applies to this PR only.`,children:[e?`Replace coverage`:`Attach coverage`,(0,W.jsx)(`input`,{type:`file`,multiple:!0,accept:`.info,.lcov,.xml`,onChange:e=>{t([...e.target.files??[]]),e.target.value=``}})]})}var od=`http://localhost:11434/v1`;function sd(){let[e,t]=(0,l.useState)(),[n,r]=(0,l.useState)(),[i,a]=(0,l.useState)(),[o,s]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{xu().then(e=>{t(e),r(e.settings)}).catch(e=>a(_d(e)))},[]),e===void 0||n===void 0)return(0,W.jsx)(`main`,{className:`page`,children:i===void 0?(0,W.jsx)(`p`,{className:`empty`,children:`Loading settings…`}):(0,W.jsx)(`p`,{className:`problem`,children:i})});let c=e=>{r(e),s(!1),a(void 0)},u=async()=>{try{let e=await Cu(n);return t(e),s(!0),a(void 0),!0}catch(e){return a(_d(e)),!1}};return(0,W.jsxs)(`main`,{className:`page settings`,children:[(0,W.jsx)(`h1`,{children:`Settings`}),(0,W.jsxs)(`p`,{className:`settings-lede`,children:[`These are your own preferences, saved on this machine. A repository's `,(0,W.jsx)(`code`,{children:`.walkdiff.json`}),` can still forbid AI review or limit where its code goes.`]}),(0,W.jsx)(cd,{checks:e.checks,disabled:n.disabledChecks,onChange:e=>c({...n,disabledChecks:e})}),(0,W.jsx)(ud,{ai:n.ai,view:e,onChange:e=>c({...n,ai:e}),onSave:u}),(0,W.jsx)(pd,{settings:n,checks:e.checks,offline:e.offline,anthropicBaseUrl:e.anthropicBaseUrl??void 0}),(0,W.jsxs)(`div`,{className:`settings-actions`,children:[(0,W.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void u(),children:`Save settings`}),o&&(0,W.jsx)(`span`,{className:`settings-saved`,children:`✓ Saved. New reviews and refreshes will use these.`}),i!==void 0&&(0,W.jsx)(`span`,{className:`problem`,children:i})]})]})}function cd({checks:e,disabled:t,onChange:n}){let r=(e,r)=>n(r?t.filter(t=>t!==e):[...t,e]);return(0,W.jsxs)(`section`,{className:`settings-card`,"aria-labelledby":`settings-checks`,children:[(0,W.jsx)(`h2`,{id:`settings-checks`,children:`Checks`}),(0,W.jsx)(`p`,{className:`settings-hint`,children:`A check you turn off shows in every report as a check that didn't run. Built-in rules for secrets and risky code always run.`}),(0,W.jsx)(`ul`,{className:`check-list`,children:e.map(e=>(0,W.jsx)(ld,{check:e,on:!t.includes(e.id),onToggle:t=>r(e.id,t)},e.id))})]})}function ld({check:e,on:t,onToggle:n}){let r=e.installed===!1;return(0,W.jsxs)(`li`,{className:`check-row`,children:[(0,W.jsxs)(`label`,{className:`check-label`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.name}),(0,W.jsx)(`span`,{className:`check-purpose`,children:e.purpose}),e.sends!==null&&(0,W.jsx)(`span`,{className:`check-sends`,children:`${e.sends.where}: ${e.sends.what}`})]})]}),r&&t&&(0,W.jsxs)(`span`,{className:`check-missing`,children:[`Not installed: `,(0,W.jsx)(`code`,{children:e.install})]}),e.installed===!0&&t&&(0,W.jsx)(`span`,{className:`check-ready`,children:`✓ Ready`})]})}function ud({ai:e,view:t,onChange:n,onSave:r}){let[i,a]=(0,l.useState)(!1),[o,s]=(0,l.useState)(),c=e.provider===_l.OpenAiCompatible,u=Sl.safeParse(e),d=u.success?El(u.data,t.anthropicBaseUrl??void 0):void 0,f=e=>{s(void 0),n(e)},p=async()=>{a(!0),s(void 0);try{await r()&&s(await wu())}catch(e){s({ok:!1,message:_d(e)})}finally{a(!1)}};return(0,W.jsxs)(`section`,{className:`settings-card`,"aria-labelledby":`settings-ai`,children:[(0,W.jsx)(`h2`,{id:`settings-ai`,children:`AI review`}),(0,W.jsx)(`p`,{className:`settings-hint`,children:`AI review is optional. It never runs unless you ask for it on a review or turn it on below.`}),(0,W.jsxs)(`div`,{className:`settings-field`,children:[(0,W.jsx)(`label`,{htmlFor:`ai-provider`,children:`Provider`}),(0,W.jsxs)(`select`,{id:`ai-provider`,value:e.provider,onChange:t=>{let n=t.target.value===_l.OpenAiCompatible?_l.OpenAiCompatible:_l.Anthropic;f({...e,provider:n,model:n===_l.Anthropic?vl:``,baseUrl:n===_l.Anthropic?null:e.baseUrl??``})},children:[(0,W.jsx)(`option`,{value:_l.Anthropic,children:`Anthropic`}),(0,W.jsx)(`option`,{value:_l.OpenAiCompatible,children:`OpenAI-compatible (OpenAI, other services, local models)`})]})]}),c&&(0,W.jsxs)(`div`,{className:`settings-field`,children:[(0,W.jsx)(`label`,{htmlFor:`ai-base-url`,children:`Address`}),(0,W.jsx)(`input`,{id:`ai-base-url`,type:`url`,value:e.baseUrl??``,placeholder:od,onChange:t=>f({...e,baseUrl:t.target.value})})]}),(0,W.jsxs)(`div`,{className:`settings-field`,children:[(0,W.jsx)(`label`,{htmlFor:`ai-model`,children:`Model`}),(0,W.jsx)(`input`,{id:`ai-model`,type:`text`,value:e.model,placeholder:c?`llama3.2`:vl,onChange:t=>f({...e,model:t.target.value})})]}),(0,W.jsxs)(`div`,{className:`settings-field`,children:[(0,W.jsx)(`label`,{htmlFor:`ai-budget`,children:`Prompt limit (tokens)`}),(0,W.jsx)(`input`,{id:`ai-budget`,type:`number`,min:1,step:1e3,value:e.maxInputTokens,onChange:t=>f({...e,maxInputTokens:Number(t.target.value)})})]}),(0,W.jsx)(fd,{compatible:c,keys:t.aiKeys,isLocal:d?.isLocal??!1}),!c&&t.anthropicBaseUrl!==null&&(0,W.jsx)(dd,{address:t.anthropicBaseUrl}),(0,W.jsxs)(`label`,{className:`settings-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.enabledByDefault,onChange:t=>f({...e,enabledByDefault:t.target.checked})}),`Tick AI review by default on new reviews`]}),!u.success&&(0,W.jsx)(`p`,{className:`problem`,children:u.error.issues.at(0)?.message}),(0,W.jsxs)(`div`,{className:`settings-test`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:i||!u.success,onClick:()=>void p(),children:i?`Testing…`:`Save and test connection`}),o!==void 0&&(0,W.jsx)(`span`,{className:o.ok?`settings-saved`:`problem`,children:o.message})]})]})}function dd({address:e}){return(0,W.jsxs)(`p`,{className:`settings-warning`,role:`alert`,children:[(0,W.jsx)(`strong`,{children:`Your code and API key won't go to Anthropic.`}),` `,(0,W.jsx)(`code`,{children:`ANTHROPIC_BASE_URL`}),` in this app's environment sends them to `,(0,W.jsx)(`code`,{children:e}),`. If you didn't mean that, unset it and restart the app.`]})}function fd({compatible:e,keys:t,isLocal:n}){let r=e?`WALKDIFF_AI_API_KEY`:`ANTHROPIC_API_KEY`,i=e?t.openaiCompatible:t.anthropic;return(0,W.jsxs)(`p`,{className:`settings-key`,children:[i?(0,W.jsxs)(W.Fragment,{children:[`✓ `,(0,W.jsx)(`code`,{children:r}),` is set.`]}):e&&n?(0,W.jsxs)(W.Fragment,{children:[`A local model usually needs no key. If yours does, set `,(0,W.jsx)(`code`,{children:r}),`.`]}):e?(0,W.jsxs)(W.Fragment,{children:[`No key found. Set `,(0,W.jsx)(`code`,{children:r}),` and restart the app.`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`code`,{children:r}),` isn't set. Set it and restart the app, or use an `,(0,W.jsx)(`code`,{children:`ant auth login`}),` profile.`]}),` `,`Keys stay in your environment, and aren't saved by Walkdiff.`]})}function pd({settings:e,checks:t,offline:n,anthropicBaseUrl:r}){let i=hd(e,t,n,r);return(0,W.jsxs)(`section`,{className:`settings-card`,"aria-labelledby":`settings-privacy`,children:[(0,W.jsx)(`h2`,{id:`settings-privacy`,children:`What leaves this machine`}),(0,W.jsxs)(`p`,{className:`settings-hint`,children:[`With the settings above.`,n?` The app was started with --offline, so OSV and Semgrep are skipped.`:``,md(e)&&` AI review uses a model on this machine, so it sends nothing out.`]}),(0,W.jsxs)(`table`,{className:`privacy-table`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{scope:`col`,children:`Where`}),(0,W.jsx)(`th`,{scope:`col`,children:`What`}),(0,W.jsx)(`th`,{scope:`col`,children:`When`})]})}),(0,W.jsx)(`tbody`,{children:i.map(e=>(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`td`,{children:e.where}),(0,W.jsx)(`td`,{children:e.what}),(0,W.jsx)(`td`,{children:e.when})]},e.where))})]})]})}function md(e){let t=Sl.safeParse(e.ai);return t.success&&El(t.data).isLocal}function hd(e,t,n,r){let i=t=>!n&&!e.disabledChecks.includes(t.id)&&t.installed!==!1,a=Sl.safeParse(e.ai),o=a.success?El(a.data,r):void 0;return[{where:`The PR's host`,what:`Your token, if the host is trusted, to read the PR and its code`,when:`Every review`},...gd(t.filter(i).flatMap(e=>e.sends===null?[]:[e.sends])),...o!==void 0&&!o.isLocal?[{where:o.label,what:`The changed code, and the PR's title and description, with known credential formats redacted`,when:e.ai.enabledByDefault?`Reviews with AI ticked, which is the default`:`Only reviews with AI ticked`}]:[]]}function gd(e){let t=new Set;return e.filter(e=>{let n=`${e.where}\0${e.what}`;return!t.has(n)&&(t.add(n),!0)})}function _d(e){return e instanceof Error?e.message:String(e)}async function vd(e,t,n){let r=await t.check(e);if(r.kind===_u.Blocked)return{kind:_u.Blocked,blocked:r.blocked.blocked};for(let r of e.members)n.posting(r.reviewId),n.posted(await yd({body:e.body,members:[r]},r.reviewId,t));return{kind:_u.Done}}async function yd(e,t,n){let r=e=>({outcome:Ql.Refused,reviewId:t,error:e});try{let i=await n.approve(e);return i.kind===_u.Blocked?r(i.blocked.blocked.find(e=>e.reviewId===t)?.reason??i.blocked.error):i.result.results.find(e=>e.reviewId===t)??r(`The app didn't say what happened to it.`)}catch(e){return r(e instanceof Error?e.message:String(e))}}var bd=7,X={Confirm:`confirm`,Posting:`posting`,Results:`results`,Blocked:`blocked`};function xd({stackId:e,members:t,view:n,onClose:r,onPosted:i}){let a=(0,l.useRef)(null),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)({phase:X.Confirm}),[d,f]=(0,l.useState)();(0,l.useEffect)(()=>a.current?.showModal(),[]);let p=new Map(t.map(e=>[e.id,Ju(n.members.find(t=>t.reviewId===e.id),ku(e))])),m=c.phase===X.Results?c.results.filter(e=>e.outcome===Ql.Refused).map(e=>e.reviewId):[],h=c.phase===X.Results?t.filter(e=>m.includes(e.id)):t,g=h.some(e=>!(p.get(e.id)?.ready??!1)),_=async()=>{let t=h.flatMap(e=>{let t=p.get(e.id);return t?.ready===!0?[{reviewId:e.id,headSha:t.headSha}]:[]}),n=c,r=(c.phase===X.Results?c.results:[]).filter(e=>!t.some(t=>t.reviewId===e.reviewId));u({phase:X.Posting,results:r,current:void 0}),f(void 0);try{let n=await vd({body:o,members:t},{check:t=>vu(e,t),approve:t=>yu(e,t)},{posting:e=>u({phase:X.Posting,results:r,current:e}),posted:e=>{r=[...r,e],u({phase:X.Posting,results:r,current:void 0})}});if(n.kind===_u.Blocked){u({phase:X.Blocked,blocked:n.blocked});return}u({phase:X.Results,results:r}),i()}catch(e){f(e instanceof Error?e.message:String(e)),u(n)}},v=e=>c.phase===X.Results||c.phase===X.Posting?c.results.find(t=>t.reviewId===e.id):void 0,y=e=>c.phase===X.Blocked?c.blocked.find(t=>t.reviewId===e.id)?.reason:void 0,b=e=>{if(c.phase===X.Posting&&c.current!==void 0&&v(e)===void 0)return e.id===c.current?Cd.Posting:Cd.Waiting};return(0,W.jsxs)(`dialog`,{ref:a,className:`approve-dialog`,"aria-labelledby":`approve-title`,onClose:r,onCancel:e=>c.phase===X.Posting&&e.preventDefault(),children:[(0,W.jsxs)(`h2`,{id:`approve-title`,children:[`Approve `,t.length===1?`this PR`:`all ${t.length} PRs`]}),(0,W.jsx)(`p`,{className:`approve-lede`,children:`Each gets its own approval, for the commit its report shows, posted bottom first.`}),(0,W.jsx)(`ol`,{className:`approve-members`,children:t.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(Td,{member:e,check:p.get(e.id),result:v(e),blockedReason:y(e),step:b(e)})},e.id))}),c.phase===X.Blocked&&(0,W.jsx)(`p`,{className:`problem`,children:`Nothing was posted: some PRs changed since the card last checked. Close this, use Refresh changed, and look again.`}),c.phase!==X.Results&&c.phase!==X.Blocked&&(0,W.jsxs)(`label`,{className:`approve-body`,children:[`Comment to post with each approval (optional)`,(0,W.jsx)(`textarea`,{value:o,rows:3,disabled:c.phase===X.Posting,onChange:e=>s(e.target.value)})]}),d!==void 0&&(0,W.jsx)(`p`,{className:`problem`,children:d}),(0,W.jsxs)(`div`,{className:`review-actions`,children:[(c.phase===X.Confirm||c.phase===X.Posting||m.length>0)&&(0,W.jsx)(`button`,{type:`button`,className:`primary`,disabled:g||c.phase===X.Posting,onClick:()=>void _(),children:c.phase===X.Posting?Sd(c.current):m.length>0?`Retry ${m.length} that failed`:`Approve ${t.length===1?`it`:`all ${t.length}`}`}),(0,W.jsx)(`button`,{type:`button`,disabled:c.phase===X.Posting,onClick:()=>a.current?.close(),children:c.phase===X.Results||c.phase===X.Blocked?`Close`:`Cancel`})]})]})}function Sd(e){return e===void 0?`Checking…`:`Posting…`}var Cd={Posting:`posting`,Waiting:`waiting`},wd={[Cd.Posting]:`Posting…`,[Cd.Waiting]:`Waiting`};function Td({member:e,check:t,result:n,blockedReason:r,step:i}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`approve-member`,children:[Yl(e.host,e.number),` `,e.title??e.displayName,t?.ready===!0&&(0,W.jsx)(`code`,{className:`approve-sha`,children:t.headSha.slice(0,bd)})]}),(0,W.jsx)(Ed,{check:t,result:n,blockedReason:r,step:i})]})}function Ed({check:e,result:t,blockedReason:n,step:r}){return t===void 0?n===void 0?r===void 0?e===void 0?null:e.ready?(0,W.jsx)(W.Fragment,{children:e.warnings.map(e=>(0,W.jsx)(`p`,{className:`member-state-attention`,children:e},e))}):(0,W.jsx)(`p`,{className:`member-state-problem`,children:e.blocker}):(0,W.jsx)(`p`,{className:`member-state-muted`,children:wd[r]}):(0,W.jsx)(`p`,{className:`member-state-problem`,children:n}):(0,W.jsx)(Dd,{result:t})}function Dd({result:e}){return e.outcome===Ql.Refused?(0,W.jsxs)(`p`,{className:`member-state-problem`,children:[`✗ Not approved: `,e.error]}):(0,W.jsxs)(`p`,{className:`member-state-good`,children:[`✓ Approved`,Qu(e.url)&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:`View`})]})]})}function Od({id:e,members:t,reviews:n,destination:r,actionsFor:i,act:a}){let[o,s]=(0,l.useState)(),[c,u]=(0,l.useState)(),[d,f]=(0,l.useState)(!1),[p,m]=(0,l.useState)(!1),h=t.some(qu),g=h?`busy`:t.map(e=>`${e.id}@${e.updatedAt}`).join();(0,l.useEffect)(()=>{if(g===`busy`)return;let t=!0;return mu(e).then(e=>{t&&(s(e),u(void 0))}).catch(e=>t&&u(e instanceof Error?e.message:String(e))),()=>{t=!1}},[e,g]);let _=e=>o?.members.find(t=>t.reviewId===e.id),v=t.filter(e=>!Gu(_(e))),y=t.filter(e=>Gu(_(e))),b=o?.trunk;return(0,W.jsxs)(`section`,{className:`stack-card`,"aria-label":`Stack of ${t.length}`,children:[(0,W.jsxs)(`div`,{className:`stack-header`,children:[(0,W.jsxs)(`h2`,{children:[`Stack`,b!==void 0&&(0,W.jsxs)(W.Fragment,{children:[` into `,(0,W.jsx)(`code`,{children:b})]})]}),(0,W.jsx)(`span`,{className:`stack-headline`,children:Ku(t,o)}),(0,W.jsxs)(`div`,{className:`review-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:o===void 0||h||v.length===0,onClick:()=>m(!0),title:`Posts an approval to each open PR in the stack, after a confirmation`,children:`Approve all…`}),(0,W.jsx)(`button`,{type:`button`,disabled:h||d,onClick:()=>{f(!0),a(async()=>{try{s(await hu(e))}finally{f(!1)}})},title:`Asks the host what changed, and analyzes again only the PRs whose reports are out of date`,children:`Refresh changed`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>a(()=>bu(e)),title:`Keeps the reviews, as separate rows`,children:`Ungroup`})]})]}),c!==void 0&&(0,W.jsx)(`p`,{className:`problem`,children:c}),p&&o!==void 0&&(0,W.jsx)(xd,{stackId:e,members:v,view:o,onClose:()=>m(!1),onPosted:()=>void mu(e).then(s,e=>u(e instanceof Error?e.message:String(e)))}),(0,W.jsx)(`ol`,{className:`stack-members`,children:v.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(td,{review:e,reviews:n,destination:r,actions:i(e),badge:(0,W.jsxs)(`span`,{className:`stack-position`,title:`Its place in the stack, from the bottom`,children:[t.indexOf(e)+1,`/`,t.length]}),children:(0,W.jsx)(kd,{status:_(e),working:qu(e)})})},e.id))}),y.length>0&&(0,W.jsxs)(`p`,{className:`stack-done`,children:[`Done:`,` `,y.map((e,t)=>(0,W.jsxs)(`span`,{children:[t>0&&` · `,(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[Yl(e.host,e.number),` `,e.title??e.displayName]}),` `,`(`,Wu(_(e)),`)`]},e.id))]})]})}function kd({status:e,working:t}){if(e===void 0||t)return null;let n=Vu(e);return n.length===0?null:(0,W.jsx)(`p`,{className:`member-state`,children:n.map(e=>(0,W.jsx)(`span`,{className:`member-state-${e.tone}`,children:e.text},e.text))})}var Ad=`https://github.com/navasvarela/walkdiff/blob/main/docs/README.md`,jd=1500,Md=`#settings`,Nd=`#`;function Pd(){let[e,t]=(0,l.useState)(window.location.hash);(0,l.useEffect)(()=>{let e=()=>t(window.location.hash);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let n=e===Md;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Fd,{onSettings:n}),n?(0,W.jsx)(sd,{}):(0,W.jsx)(Id,{})]})}function Fd({onSettings:e}){return(0,W.jsxs)(`header`,{className:`topbar`,children:[(0,W.jsxs)(`a`,{className:`topbar-brand`,href:Nd,children:[(0,W.jsx)(`img`,{src:Du,alt:``,width:`22`,height:`22`}),`Walkdiff`]}),(0,W.jsxs)(`nav`,{className:`topbar-nav`,"aria-label":`Sections`,children:[(0,W.jsx)(`a`,{href:Nd,"aria-current":e?void 0:`page`,children:`Reviews`}),(0,W.jsx)(`a`,{href:Md,"aria-current":e?`page`:void 0,children:`Settings`})]})]})}function Id(){let[e,t]=(0,l.useState)(),[n,r]=(0,l.useState)(),i=(0,l.useCallback)(async()=>{try{t(await su()),r(void 0)}catch(e){r(e instanceof Error?e.message:String(e))}},[]);(0,l.useEffect)(()=>{i()},[i]);let a=Tu(),o=e?.some(qu)??!1;(0,l.useEffect)(()=>{if(!o)return;let e=window.setInterval(()=>void i(),jd);return()=>window.clearInterval(e)},[o,i]);let s=e=>{e().then(i).catch(e=>r(e instanceof Error?e.message:String(e)))},c=e=>({refresh:()=>s(()=>lu(e.id)),attachCoverage:t=>s(()=>uu(e.id,t)),remove:()=>s(()=>du(e.id)),acceptStack:t=>s(()=>fu(e.id,{ai:t})),dismissStack:()=>s(()=>pu(e.id))});return(0,W.jsxs)(`main`,{className:`page`,children:[(0,W.jsx)(`h1`,{children:`Reviews`}),(0,W.jsx)(Ld,{onAdded:i,destination:a.destination,enabledByDefault:a.enabledByDefault}),a.problem!==void 0&&(0,W.jsx)(`p`,{className:`problem`,children:a.problem}),n!==void 0&&(0,W.jsx)(`p`,{className:`problem`,children:n}),e===void 0?null:e.length===0?(0,W.jsx)(`p`,{className:`empty`,children:`Nothing here yet. Paste a pull request or merge request link above to start a review.`}):(0,W.jsx)(`ul`,{className:`reviews`,children:Iu(e).map(t=>t.kind===Fu.Review?(0,W.jsx)(`li`,{children:(0,W.jsx)(td,{review:t.review,reviews:e,destination:a.destination,actions:c(t.review)})},`review-${t.review.id}`):(0,W.jsx)(`li`,{children:(0,W.jsx)(Od,{id:t.id,members:t.members,reviews:e,destination:a.destination,actionsFor:c,act:s})},`stack-${t.id}`))}),(0,W.jsxs)(`footer`,{className:`page-footer`,children:[(0,W.jsx)(`a`,{href:Ad,target:`_blank`,rel:`noreferrer`,children:`Documentation`}),(0,W.jsx)(`a`,{href:q,target:`_blank`,rel:`noreferrer`,children:`Troubleshooting`})]})]})}function Ld({onAdded:e,destination:t,enabledByDefault:n}){let[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)();return(0,l.useEffect)(()=>o(n),[n]),(0,W.jsxs)(`form`,{className:`add-review`,onSubmit:t=>{t.preventDefault(),cu({url:r,ai:a}).then(()=>(i(``),c(void 0),e())).catch(e=>c(e instanceof Error?e.message:String(e)))},children:[(0,W.jsxs)(`div`,{className:`add-row`,children:[(0,W.jsx)(`input`,{type:`url`,value:r,required:!0,autoFocus:!0,placeholder:`https://github.com/owner/repo/pull/123`,"aria-label":`Pull request or merge request link`,onChange:e=>i(e.target.value)}),(0,W.jsx)(`button`,{type:`submit`,children:`Add review`})]}),(0,W.jsxs)(`label`,{className:`add-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),Eu(t),` `,(0,W.jsx)(`a`,{href:Md,children:`Change`})]}),s!==void 0&&(0,W.jsx)(`p`,{className:`problem`,children:s})]})}var Rd=document.getElementById(`root`);if(Rd===null)throw Error(`index.html is missing the #root element`);(0,u.createRoot)(Rd).render((0,W.jsx)(l.StrictMode,{children:(0,W.jsx)(Pd,{})}));
|
|
63
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function za(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;za(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Ba=new Set([`type`,`properties`,`required`,`additionalProperties`]),Va=[`oneOf`,`anyOf`];function Ha(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ua(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ba.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Ha(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}ne(n,r,e.length===1?e[0]:Ua(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Ha(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Wa(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ba)if(t in e)return;let n=t.filter(e=>Va.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ua(t);else{let e=n[0],i=Va.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ua([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Na(e,r))}function Ga(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Na(i,s),Na(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())za(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Wa(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Na(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,ne(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Ja(t,`input`,e.processors),output:Ja(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ka(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ka(r.element,n);if(r.type===`set`)return Ka(r.valueType,n);if(r.type===`lazy`)return Ka(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Ka(r.innerType,n);if(r.type===`intersection`)return Ka(r.left,n)||Ka(r.right,n);if(r.type===`record`||r.type===`map`)return Ka(r.keyType,n)||Ka(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ka(r.in,n)||Ka(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ka(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ka(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ka(e,n))return!0;return!!(r.rest&&Ka(r.rest,n))}return!1}var qa=(e,t={})=>n=>{let r=Pa({...n,processors:t});return Ia(e,r),Ra(r,e),Ga(r,e)},Ja=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Pa({...i??{},target:a,io:t,processors:n});return Ia(e,o),Ra(o,e),Ga(o,e)},Ya=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Xa=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Za=(e,t)=>{Ya(e,`minimum`,t),Xa(e,`maximum`,t)},Qa=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},$a=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},eo=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},to=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},no=(e,t)=>Ya(e,`minimum`,t.minimum),ro=(e,t)=>Xa(e,`maximum`,t.maximum),io=e=>(t,n)=>{to(t,n.format);let[r,i]=e[n.format];Ya(t,`minimum`,r),Xa(t,`maximum`,i)},ao={greater_than:(e,t)=>Ya(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Xa(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Qa(e,t.value),number_format:io(be),bigint_format:io(xe),min_length:no,max_length:ro,length_equals:(e,t)=>Za(e,t.length),min_size:no,max_size:ro,size_equals:(e,t)=>Za(e,t.size),string_format:(e,t)=>{to(e,t.format),t.pattern&&$a(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>eo(e,t.mime)};function oo(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)ao[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ya(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ya(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Xa(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Xa(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Qa(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&eo(t,i.mime);for(let e of i.patterns??[])$a(t,e);return t}var so={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},co=new Map([[fr,Zt],[mr,Qt]]),lo=e=>co.get(e)??e,uo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=oo(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=so[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(lo);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},fo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=oo(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Fa(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},po=(e,t,n,r)=>{n.type=`boolean`},mo=(e,t,n,r)=>{n.not={}},ho=(e,t,n,r)=>{let i=e._zod.def,a=h(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},go=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Fa(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Fa(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},_o=(e,t,n,r)=>{Fa(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},vo=(e,t,n,r)=>{Fa(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},yo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=oo(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Ia(a.element,t,{...r,path:[...r.path,`items`]})};function bo(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?bo(t.out):t.type===`catch`?bo(t.innerType):e._zod.optin}var xo=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Fa(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)ne(i.properties,e,Ia(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?bo(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Ia(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},So=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ia(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Co=(e,t,n,r)=>{let i=e._zod.def,a=Ia(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ia(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},wo=(e,t,n,r)=>{let i=e._zod.def,a=Ia(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},To=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Eo=Symbol();function Do(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Fa(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Eo):JSON.parse(o)}var Oo=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Do(i.defaultValue,e,t,n,r);o!==Eo&&(n.default=o)},ko=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Do(i.defaultValue,e,t,n,r);o!==Eo&&(n._prefault=o)},Ao=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Fa(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},jo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Ia(o,t,r);let s=t.seen.get(e);s.ref=o},Mo=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},No=(e,t,n,r)=>{let i=e._zod.def;Ia(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Po=new WeakSet([Object.prototype,Error.prototype]);function Fo(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Io=O(`ZodError`,(e,t)=>{dt.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Po.has(n)||(Po.add(n),Fo(n,`format`,e=>t=>mt(e,t)),Fo(n,`flatten`,e=>t=>pt(e,t)),Fo(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,_,2)}),Fo(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,_,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Lo=gt(Io),Ro=_t(Io),zo=vt(Io),Bo=bt(Io),Vo=Et(Io),Ho=Dt(Io),Uo=Ot(Io),Wo=kt(Io),Go=At(Io),Ko=jt(Io),qo=Mt(Io),Jo=Nt(Io);function Yo(){it.localeError||at(Ei())}function Xo(){it.memoizer||at({memoizer:Ci()})}var N=O(`ZodType`,(e,t)=>(Yo(),A.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(se(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return _e(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(cc(e,t))},superRefine(e,t){return this.check(lc(e,t))},overwrite(e){return this.check(Ca(e))},optional(){return Ws(this)},exactOptional(){return Ks(this)},nullable(){return Js(this)},nullish(){return Ws(Js(this))},nonoptional(e){return ec(this,e)},array(){return R(this)},or(e){return Ps([this,e])},and(e){return Rs(this,e)},transform(e){return ic(this,Hs(e))},default(e){return Xs(this,e)},prefault(e){return Qs(this,e)},catch(e){return nc(this,e)},pipe(e){return ic(this,e)},readonly(){return oc(this)},describe(e){let t=this.clone();return Ai.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ai.get(this);let t=this.clone();return Ai.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return He(this,`~standard`,{...Pn(this),jsonSchema:{input:Ja(this,`input`),output:Ja(this,`output`)}})},set"~standard"(e){Ve(this,`~standard`,e)},parse:function e(t,n){return Lo(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ro(this,t,n,{callee:e})},safeParse(e,t){return zo(this,e,t)},async safeParseAsync(e,t){return Bo(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ve(this,`spa`,e)},validate(e,t){return Ct(this,e,t)},validateAsync(e,t){return Tt(this,e,t)},encode:function e(t,n){return Vo(this,t,n,{callee:e})},decode:function e(t,n){return Ho(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Uo(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Wo(this,t,n,{callee:e})},safeEncode(e,t){return Go(this,e,t)},safeDecode(e,t){return Ko(this,e,t)},async safeEncodeAsync(e,t){return qo(this,e,t)},async safeDecodeAsync(e,t){return Jo(this,e,t)},toJSONSchema(e){return qa(this,{})(e)},get description(){return Ai.get(this)?.description},get _def(){return this._zod.def}}),P=O(`_ZodString`,(e,t)=>{Fn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r)},Ue({format:e=>oo(e).format??null,minLength:e=>oo(e).minimum??null,maxLength:e=>oo(e).maximum??null},{regex(...e){return this.check(_a(...e))},includes(...e){return this.check(ba(...e))},startsWith(...e){return this.check(xa(...e))},endsWith(...e){return this.check(Sa(...e))},min(...e){return this.check(ha(...e))},max(...e){return this.check(ma(...e))},length(...e){return this.check(ga(...e))},nonempty(...e){return this.check(ha(1,...e))},lowercase(e){return this.check(va(e))},uppercase(e){return this.check(ya(e))},trim(){return this.check(Ta())},normalize(...e){return this.check(wa(...e))},toLowerCase(){return this.check(Ea())},toUpperCase(){return this.check(Da())},slugify(){return this.check(Oa())}})),Zo=O(`ZodString`,(e,t)=>{Fn.init(e,t),P.init(e,t)},{email(e){return this.check(Ni(ns,e))},url(e){return this.check(zi(as,e))},jwt(e){return this.check(ea(xs,e))},emoji(e){return this.check(Bi(ss,e))},guid(e){return this.check(Pi(rs,e))},uuid(e){return this.check(Fi(is,e))},uuidv4(e){return this.check(Ii(is,e))},uuidv6(e){return this.check(Li(is,e))},uuidv7(e){return this.check(Ri(is,e))},nanoid(e){return this.check(Vi(cs,e))},cuid(e){return this.check(Hi(ls,e))},cuid2(e){return this.check(Ui(us,e))},ulid(e){return this.check(Wi(ds,e))},base64(e){return this.check(Zi(vs,e))},base64url(e){return this.check(Qi(ys,e))},xid(e){return this.check(Gi(fs,e))},ksuid(e){return this.check(Ki(ps,e))},ipv4(e){return this.check(qi(ms,e))},ipv6(e){return this.check(Ji(hs,e))},cidrv4(e){return this.check(Yi(gs,e))},cidrv6(e){return this.check(Xi(_s,e))},e164(e){return this.check($i(bs,e))},datetime(e){return this.check(ta(Qo,e))},date(e){return this.check(na($o,e))},time(e){return this.check(ra(es,e))},duration(e){return this.check(ia(ts,e))}});function F(e){return Mi(Zo,e)}var I=O(`ZodStringFormat`,(e,t)=>{j.init(e,t),P.init(e,t)}),Qo=O(`ZodISODateTime`,(e,t)=>{er.init(e,t),I.init(e,t)}),$o=O(`ZodISODate`,(e,t)=>{tr.init(e,t),I.init(e,t)}),es=O(`ZodISOTime`,(e,t)=>{nr.init(e,t),I.init(e,t)}),ts=O(`ZodISODuration`,(e,t)=>{rr.init(e,t),I.init(e,t)}),ns=O(`ZodEmail`,(e,t)=>{Rn.init(e,t),I.init(e,t)}),rs=O(`ZodGUID`,(e,t)=>{In.init(e,t),I.init(e,t)}),is=O(`ZodUUID`,(e,t)=>{Ln.init(e,t),I.init(e,t)}),as=O(`ZodURL`,(e,t)=>{Kn.init(e,t),I.init(e,t)});function os(e){return zi(as,e)}var ss=O(`ZodEmoji`,(e,t)=>{qn.init(e,t),I.init(e,t)}),cs=O(`ZodNanoID`,(e,t)=>{Jn.init(e,t),I.init(e,t)}),ls=O(`ZodCUID`,(e,t)=>{Yn.init(e,t),I.init(e,t)}),us=O(`ZodCUID2`,(e,t)=>{Xn.init(e,t),I.init(e,t)}),ds=O(`ZodULID`,(e,t)=>{Zn.init(e,t),I.init(e,t)}),fs=O(`ZodXID`,(e,t)=>{Qn.init(e,t),I.init(e,t)}),ps=O(`ZodKSUID`,(e,t)=>{$n.init(e,t),I.init(e,t)}),ms=O(`ZodIPv4`,(e,t)=>{ir.init(e,t),I.init(e,t)}),hs=O(`ZodIPv6`,(e,t)=>{sr.init(e,t),I.init(e,t)}),gs=O(`ZodCIDRv4`,(e,t)=>{cr.init(e,t),I.init(e,t)}),_s=O(`ZodCIDRv6`,(e,t)=>{ur.init(e,t),I.init(e,t)}),vs=O(`ZodBase64`,(e,t)=>{pr.init(e,t),I.init(e,t)}),ys=O(`ZodBase64URL`,(e,t)=>{gr.init(e,t),I.init(e,t)}),bs=O(`ZodE164`,(e,t)=>{_r.init(e,t),I.init(e,t)}),xs=O(`ZodJWT`,(e,t)=>{yr.init(e,t),I.init(e,t)}),Ss=O(`ZodNumber`,(e,t)=>{br.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.isFinite=!0},Ue({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=oo(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=oo(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=oo(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>oo(e).format??null},{gt(e,t){return this.check(fa(e,t))},gte(e,t){return this.check(M(e,t))},min(e,t){return this.check(M(e,t))},lt(e,t){return this.check(ua(e,t))},lte(e,t){return this.check(da(e,t))},max(e,t){return this.check(da(e,t))},int(e){return this.check(ws(e))},safe(e){return this.check(ws(e))},positive(e){return this.check(fa(0,e))},nonnegative(e){return this.check(M(0,e))},negative(e){return this.check(ua(0,e))},nonpositive(e){return this.check(da(0,e))},multipleOf(e,t){return this.check(pa(e,t))},step(e,t){return this.check(pa(e,t))},finite(){return this}}));function L(e){return aa(Ss,e)}var Cs=O(`ZodNumberFormat`,(e,t)=>{xr.init(e,t),Ss.init(e,t)});function ws(e){return oa(Cs,e)}var Ts=O(`ZodBoolean`,(e,t)=>{Sr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r)});function Es(e){return sa(Ts,e)}var Ds=O(`ZodUnknown`,(e,t)=>{Cr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Os(){return ca(Ds)}var ks=O(`ZodNever`,(e,t)=>{wr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r)});function As(e){return la(ks,e)}var js=O(`ZodArray`,(e,t)=>{Xo(),Or.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.element=t.element},{min(e,t){return this.check(ha(e,t))},nonempty(e){return this.check(ha(1,e))},max(e,t){return this.check(ma(e,t))},length(e,t){return this.check(ga(e,t))},unwrap(){return this.element}});function R(e,t){return ka(js,e,t)}var Ms=O(`ZodObject`,(e,t)=>{Xo(),Pr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),Ye(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return B(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(se(this._zod.def,{catchall:e}))},passthrough(){return this.clone(se(this._zod.def,{catchall:Os()}))},loose(){return this.clone(se(this._zod.def,{catchall:Os()}))},strict(){return this.clone(se(this._zod.def,{catchall:As()}))},strip(){return this.clone(se(this._zod.def,{catchall:void 0}))},extend(e){return Te(this,e)},safeExtend(e){return w(this,e)},merge(e){return T(this,e)},pick(e){return Se(this,e)},omit(e){return we(this,e)},partial(...e){return De(Us,this,e[0])},exactPartial(...e){return De(Gs,this,e[0],`exactPartial`)},required(...e){return Oe($s,this,e[0])}});function z(e,t){return new Ms({type:`object`,shape:e??{},...C(t)})}var Ns=O(`ZodUnion`,(e,t)=>{Ir.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.options=t.options});function Ps(e,t){return new Ns({type:`union`,options:e,...C(t)})}var Fs=O(`ZodDiscriminatedUnion`,(e,t)=>{Ns.init(e,t),Rr.init(e,t)});function Is(e,t,n){return new Fs({type:`union`,options:t,discriminator:e,...C(n)})}var Ls=O(`ZodIntersection`,(e,t)=>{zr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r)});function Rs(e,t){return new Ls({type:`intersection`,left:e,right:t})}var zs=O(`ZodEnum`,(e,t)=>{Hr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new zs({...t,checks:[],...C(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new zs({...t,checks:[],...C(r),entries:i})}});function B(e,t){return new zs({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...C(t)})}var Bs=O(`ZodLiteral`,(e,t)=>{Ur.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function V(e,t){return new Bs({type:`literal`,values:Array.isArray(e)?e:[e],...C(t)})}var Vs=O(`ZodTransform`,(e,t)=>{Xo(),Wr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new rt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ze(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(ze(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Hs(e){return new Vs({type:`transform`,transform:e})}var Us=O(`ZodOptional`,(e,t)=>{Kr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ws(e){return new Us({type:`optional`,innerType:e})}var Gs=O(`ZodExactOptional`,(e,t)=>{qr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ks(e){return new Gs({type:`optional`,innerType:e})}var qs=O(`ZodNullable`,(e,t)=>{Jr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Js(e){return new qs({type:`nullable`,innerType:e})}var Ys=O(`ZodDefault`,(e,t)=>{Yr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Xs(e,t){return new Ys({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():me(t)}})}var Zs=O(`ZodPrefault`,(e,t)=>{Zr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qs(e,t){return new Zs({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():me(t)}})}var $s=O(`ZodNonOptional`,(e,t)=>{Qr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ec(e,t){return new $s({type:`nonoptional`,innerType:e,...C(t)})}var tc=O(`ZodCatch`,(e,t)=>{ti.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nc(e,t){return new tc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Ze(t)})}var rc=O(`ZodPipe`,(e,t)=>{ni.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.in=t.in,e.out=t.out});function ic(e,t){return new rc({type:`pipe`,in:e,out:t})}var ac=O(`ZodReadonly`,(e,t)=>{ii.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oc(e){return new ac({type:`readonly`,innerType:e})}var sc=O(`ZodCustom`,(e,t)=>{oi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r)});function cc(e,t={}){return Aa(sc,e,t)}function lc(e,t){return ja(e,t)}function uc(e){return ta(Qo,e)}var dc={Host:`host`,Branches:`branches`},fc=z({number:L().int().positive(),title:F(),author:F(),headRef:F().min(1),baseRef:F().min(1)}),pc=z({source:B(dc),trunk:F().min(1),members:R(fc).min(2).max(20).readonly(),leftOut:R(fc).max(20).readonly()}),mc=z({id:L().int().positive(),position:L().int().positive()}),hc=pc.extend({joining:R(L().int().positive()).min(1).readonly()});z({ai:Es()});var gc={GitHub:`github`,GitLab:`gitlab`},_c=F().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/).brand(),vc={title:F(),description:F(),author:F(),baseRef:F(),headRef:F(),baseSha:_c,headSha:_c,mergeBaseSha:_c},yc=Is(`host`,[z({host:B(gc),url:os(),repositoryWebUrl:os(),number:L().int().positive(),...vc}),z({host:V(`local`),repositoryName:F(),...vc})]),bc=L().int().positive(),xc={Context:`context`,Added:`added`,Removed:`removed`},Sc=Is(`kind`,[z({kind:V(xc.Context),content:F(),oldLine:bc,newLine:bc}),z({kind:V(xc.Added),content:F(),newLine:bc}),z({kind:V(xc.Removed),content:F(),oldLine:bc})]),Cc=z({oldStart:L().int().nonnegative(),oldLines:L().int().nonnegative(),newStart:L().int().nonnegative(),newLines:L().int().nonnegative(),section:F(),lines:R(Sc).readonly()}),wc={Text:`text`,Binary:`binary`},Tc=Is(`kind`,[z({kind:V(wc.Text),hunks:R(Cc).readonly()}),z({kind:V(wc.Binary)})]),Ec={Added:`added`,Modified:`modified`,Deleted:`deleted`,Renamed:`renamed`,Copied:`copied`},Dc={Rust:`rust`,TypeScript:`typescript`,Tsx:`tsx`,Python:`python`,Go:`go`,Java:`java`,C:`c`,Cpp:`cpp`,Kotlin:`kotlin`,CSharp:`csharp`},Oc={Function:`function`,Method:`method`,Class:`class`,Struct:`struct`,Enum:`enum`,Trait:`trait`,Impl:`impl`,Interface:`interface`,TypeAlias:`typeAlias`,Constant:`constant`,Macro:`macro`,Module:`module`,TestSuite:`testSuite`,Test:`test`,TestHook:`testHook`,ModuleScope:`moduleScope`},kc=z({startLine:bc,endLine:bc,text:F(),elidesNestedUnits:Es()}),Ac={Added:`added`,Removed:`removed`,Modified:`modified`,Renamed:`renamed`,MovedIn:`movedIn`,MovedOut:`movedOut`},jc={Semantic:`semantic`,CommentsOnly:`commentsOnly`,FormattingOnly:`formattingOnly`},Mc=z({path:F().min(1),qualifiedName:F()}),Nc=Is(`kind`,[z({kind:V(Ac.Added),after:kc}),z({kind:V(Ac.Removed),before:kc}),z({kind:V(Ac.Modified),weight:B(jc),before:kc,after:kc}),z({kind:V(Ac.Renamed),previousName:F(),before:kc,after:kc}),z({kind:V(Ac.MovedIn),from:Mc,edited:Es().default(!1),before:kc,after:kc}),z({kind:V(Ac.MovedOut),to:Mc,edited:Es().default(!1),before:kc})]),Pc=z({parametersAdded:R(F()).readonly(),parametersRemoved:R(F()).readonly(),parametersChanged:R(F()).readonly(),returnType:z({before:F().nullable(),after:F().nullable()}).nullable(),callsAdded:R(F()).readonly(),callsRemoved:R(F()).readonly(),errorPathsDelta:L().int(),branchesDelta:L().int(),complexity:z({before:L().int(),after:L().int()}).nullable()}),Fc=z({kind:B(Oc),name:F(),qualifiedName:F(),change:Nc,facts:Pc.nullable()}),Ic=z({path:F().min(1),line:bc,callerQualifiedName:F().nullable(),confidence:B({Exact:`exact`,Likely:`likely`,Possible:`possible`}),touchedByPullRequest:Es(),snippet:F()}),Lc={Traced:`traced`,TooCommon:`tooCommon`,Skipped:`skipped`},Rc=Is(`status`,[z({status:V(Lc.Traced),searchedName:F(),references:R(Ic).readonly(),totalReferences:L().int().nonnegative()}),z({status:V(Lc.TooCommon),searchedName:F(),matchingFiles:L().int().positive()}),z({status:V(Lc.Skipped),searchedName:F(),reason:F()})]),zc=Fc.extend({impact:Rc.nullable()}),Bc=z({kind:B({Lockfile:`lockfile`,Generated:`generated`,Vendored:`vendored`}),reason:F()}),Vc={Analyzed:`analyzed`,UnsupportedLanguage:`unsupportedLanguage`,Skipped:`skipped`},Hc=z({kind:B(Oc),qualifiedName:F(),startLine:bc,endLine:bc}),Uc=z({caller:F(),callee:F()}),Wc=Is(`status`,[z({status:V(Vc.Analyzed),language:B(Dc),units:R(zc).readonly(),outline:R(Hc).readonly(),calls:R(Uc).readonly()}),z({status:V(Vc.UnsupportedLanguage)}),z({status:V(Vc.Skipped),reason:F()})]),Gc=z({path:F().min(1),additions:L().int().nonnegative(),deletions:L().int().nonnegative(),content:Tc}),Kc={previousPath:F().min(1),similarity:L().int().min(0).max(100)},qc=z({diff:Is(`status`,[Gc.extend({status:V(Ec.Added)}),Gc.extend({status:V(Ec.Modified)}),Gc.extend({status:V(Ec.Deleted)}),Gc.extend({status:V(Ec.Renamed),...Kc}),Gc.extend({status:V(Ec.Copied),...Kc})]),noise:Bc.nullable(),syntax:Wc}),Jc={High:`high`,Medium:`medium`,Low:`low`},Yc={Secret:`secret`,DangerousApi:`dangerousApi`,SensitivePath:`sensitivePath`,Dependency:`dependency`,Vulnerability:`vulnerability`,CodeScan:`codeScan`,CodeQuality:`codeQuality`,Tests:`tests`,Size:`size`,BrokenReference:`brokenReference`,BreakingChange:`breakingChange`,License:`license`,AttackSurface:`attackSurface`,Infrastructure:`infrastructure`,SupplyChain:`supplyChain`},Xc=z({path:F().min(1),line:bc.nullable()}),Zc={Security:`security`,Review:`review`,Context:`context`},Qc=z({id:F().min(1),label:F().min(1),kind:B(Zc),advice:F()}),$c=z({ruleId:F(),category:F().min(1),severity:B(Jc),title:F(),detail:F(),location:Xc.nullable(),evidence:F().nullable(),unit:F().optional(),check:F().optional()}),el=z({check:F(),reason:F()}),tl=z({name:F(),detail:F(),security:Es().optional()}),nl=z({securityLevel:B(Jc),findings:R($c).readonly(),checksRun:R(tl).readonly(),notChecked:R(el).readonly(),dimensions:R(Qc).readonly().optional()}),rl=z({path:F().min(1),side:B({Before:`before`,After:`after`}),startLine:bc,endLine:bc}),il=z({path:F().min(1),qualifiedName:F()}),al=z({title:F(),summary:F(),units:R(il).readonly()}),ol=z({claim:F(),verdict:B({Matches:`matches`,Contradicts:`contradicts`,Undocumented:`undocumented`,NotFound:`notFound`}),explanation:F(),citations:R(rl).readonly()}),sl=z({question:F(),why:F(),citations:R(rl).min(1).readonly()}),cl={Disabled:`disabled`,Unavailable:`unavailable`,Completed:`completed`},ll=Is(`status`,[z({status:V(cl.Disabled)}),z({status:V(cl.Unavailable),reason:F()}),z({status:V(cl.Completed),model:F(),chapters:R(al).readonly(),intent:R(ol).readonly(),questions:R(sl).readonly(),droppedStatements:L().int().nonnegative(),unitsSummarizedOnly:L().int().nonnegative(),usage:z({inputTokens:L().int().nonnegative(),outputTokens:L().int().nonnegative()}),estimatedCostUsd:L().nonnegative().nullable(),cached:Es()})]),ul=z({source:F(),files:R(z({path:F().min(1),coveredLines:R(bc).readonly(),uncoveredLines:R(bc).readonly()})).readonly()});z({schemaVersion:V(11),generatedAt:uc(),pullRequest:yc,files:R(qc).readonly(),risk:nl,ai:ll,testCoverage:ul.nullable().default(null),feedbackUrl:os({protocol:/^https?$/}).nullable()});var dl={Queued:`queued`,Analyzing:`analyzing`,Ready:`ready`,Failed:`failed`};z({reports:R(z({name:F().min(1),text:F()})).min(1)});var fl=z({headSha:_c,baseRef:F()}),pl=z({id:L().int().positive(),url:os(),host:B(gc),displayName:F(),number:L().int().positive(),status:B(dl),step:B(d).nullable().default(null),error:F().nullable(),hasReport:Es(),ai:Es(),title:F().nullable(),author:F().nullable(),securityLevel:B(Jc).nullable(),unitsToReview:L().int().nonnegative().nullable(),untouchedReferences:L().int().nonnegative().nullable(),findings:L().int().nonnegative().nullable(),coverageSource:F().nullable(),reportHead:fl.nullable(),stack:mc.nullable(),stackOffer:hc.nullable().default(null),createdAt:uc(),updatedAt:uc()});z({url:F().min(1),ai:Es()});function ml(e,t,n,r){return{id:e,label:t,kind:n,advice:r}}var hl=[ml(Yc.Secret,`Possible secret`,Zc.Security,`If it's real, revoke it.`),ml(Yc.AttackSurface,`Attack surface`,Zc.Security,`Check who can reach it and what it trusts.`),ml(Yc.DangerousApi,`Risky API`,Zc.Security,`Check that users can't control the input.`),ml(Yc.SupplyChain,`Supply chain`,Zc.Security,`Check where the package comes from before installing it.`),ml(Yc.Dependency,`Dependency`,Zc.Security,`Check that you trust it.`),ml(Yc.Vulnerability,`Known vulnerability`,Zc.Security,`Upgrade before merging if you can.`),ml(Yc.Infrastructure,`Infrastructure`,Zc.Security,`Check it's intended for this environment.`),ml(Yc.SensitivePath,`Sensitive area`,Zc.Security,`Check this is intended.`),ml(Yc.CodeScan,`Code scan`,Zc.Security,`Check whether it applies here.`),ml(Yc.BreakingChange,`Breaking change`,Zc.Review,`This may break callers or a deployment, so check who depends on it.`),ml(Yc.BrokenReference,`Broken reference`,Zc.Review,`Check that nothing still depends on it.`),ml(Yc.License,`Licence`,Zc.Review,`Check it's acceptable before merging.`),ml(Yc.Tests,`Tests`,Zc.Review,`Ask whether this needs tests.`),ml(Yc.CodeQuality,`Code quality`,Zc.Context,``),ml(Yc.Size,`Size`,Zc.Context,``)];new Map(hl.map(e=>[e.id,e])),Oc.TestSuite,Oc.Test,Oc.TestHook,Oc.Function,Oc.Method,Oc.Class;var gl={Semgrep:`semgrep`,Gitleaks:`gitleaks`,OsvScanner:`osvScanner`,OsvDatabase:`osvDatabase`,DependencyTrust:`dependencyTrust`,NpmReleases:`npmReleases`,Hotspots:`hotspots`,Zizmor:`zizmor`,Poutine:`poutine`,Ruff:`ruff`,Oxlint:`oxlint`,Jscpd:`jscpd`,FunctionMetrics:`functionMetrics`},_l={Anthropic:`anthropic`,OpenAiCompatible:`openaiCompatible`},vl=`claude-opus-5-5`,yl=new Set([`localhost`,`127.0.0.1`,`[::1]`]);function bl(e){return yl.has(e.hostname)}function xl(e){if(!URL.canParse(e))return`Enter a full address, such as https://api.example.com/v1`;let t=new URL(e);if(!(t.protocol===`https:`||t.protocol===`http:`&&bl(t)))return`Use https, because this address receives your code and API key. Plain http only works for a model on this machine`}var Sl=z({provider:B(_l),model:F().trim().min(1,`Enter a model name`),baseUrl:F().nullable(),maxInputTokens:L().int().positive(),enabledByDefault:Es()}).superRefine((e,t)=>{if(e.provider!==_l.OpenAiCompatible)return;let n=e.baseUrl===null?`Enter the provider's address`:xl(e.baseUrl);n!==void 0&&t.addIssue({code:`custom`,path:[`baseUrl`],message:n})}),Cl=z({disabledChecks:R(B(gl)).readonly(),ai:Sl});_l.Anthropic;var wl=`local`,Tl=`ANTHROPIC_BASE_URL`;function El(e,t){if(e.provider===_l.Anthropic||e.baseUrl===null){if(t===void 0)return{label:`Anthropic`,isLocal:!1,ids:[_l.Anthropic]};let{host:e}=new URL(t);return{label:`${e}, set by ${Tl}`,isLocal:!1,ids:[e]}}let n=new URL(e.baseUrl);return bl(n)?{label:`a model on this machine`,isLocal:!0,ids:[n.host,wl]}:{label:n.host,isLocal:!1,ids:[n.host]}}var Dl=z({where:F(),what:F(),when:F()}),Ol=z({id:B(gl),name:F(),purpose:F(),installed:Es().nullable(),install:F().nullable(),sends:Dl.nullable()}),kl=z({settings:Cl,anthropicBaseUrl:F().nullable()}),Al=z({settings:Cl,checks:R(Ol).readonly(),aiKeys:z({anthropic:Es(),openaiCompatible:Es()}),anthropicBaseUrl:F().nullable(),offline:Es()}),jl=z({ok:Es(),message:F()}),Ml={Comment:`comment`,Approve:`approve`,RequestChanges:`requestChanges`},Nl=6e4,Pl=L().int().positive(),Fl={Old:`old`,New:`new`},Il=z({oldLine:Pl.nullable(),newLine:Pl.nullable()}),Ll=z({side:B(Fl),start:Il,end:Il}),Rl=z({path:F().min(1),previousPath:F().min(1),line:Pl.nullable(),label:F(),range:Ll.nullable().default(null),body:F().trim().min(1).max(Nl)});z({event:B(Ml),body:F().trim().max(Nl),headSha:F().min(1),comments:R(Rl).readonly()}).superRefine((e,t)=>{e.event===Ml.RequestChanges&&e.body===``&&e.comments.length===0&&t.addIssue({code:`custom`,path:[`body`],message:`Say what needs to change`}),e.event===Ml.Comment&&e.body===``&&e.comments.length===0&&t.addIssue({code:`custom`,path:[`body`],message:`Add a comment first`})}),z({body:F().trim().min(1).max(Nl)}),z({resolved:Es()});var zl={Approved:`approved`,ChangesRequested:`changesRequested`,Commented:`commented`,Other:`other`},Bl=z({author:F(),body:F(),createdAt:F(),url:F().nullable()}),Vl=z({id:F().min(1),path:F().nullable(),line:Pl.nullable(),side:B(Fl).default(Fl.New),isResolved:Es(),isOutdated:Es(),comments:R(Bl).readonly()}),Hl=z({name:F(),state:B(zl)});z({reviewers:R(Hl).readonly(),threads:R(Vl).readonly(),truncated:Es()}),z({url:F()});var Ul={Open:`open`,Merged:`merged`,Closed:`closed`},Wl=z({state:B(Ul),headSha:_c,baseRef:F()}),Gl={None:`none`,NoReport:`noReport`,NewCommits:`newCommits`,Retargeted:`retargeted`},Kl={Checked:`checked`,Failed:`failed`},ql=Is(`check`,[z({check:V(Kl.Checked),reviewId:L().int().positive(),status:Wl,reportChange:B(Gl),reviewers:R(Hl).readonly()}),z({check:V(Kl.Failed),reviewId:L().int().positive(),error:F()})]),Jl=z({id:L().int().positive(),trunk:F(),members:R(ql).readonly()});function Yl(e,t){return`${e===gc.GitHub?`#`:`!`}${t}`}z({body:F().trim().max(Nl),members:R(z({reviewId:L().int().positive(),headSha:_c})).min(1).max(20)});var Xl=z({reviewId:L().int().positive(),reason:F()}),Zl=z({error:F(),blocked:R(Xl).min(1)}),Ql={Posted:`posted`,Refused:`refused`},$l=z({results:R(Is(`outcome`,[z({outcome:V(Ql.Posted),reviewId:L().int().positive(),url:F()}),z({outcome:V(Ql.Refused),reviewId:L().int().positive(),error:F()})]))}),eu=`walkdiff-progress:`,tu=z({reviewed:L().int().nonnegative(),total:L().int().nonnegative(),drafts:L().int().nonnegative(),head:fl}).refine(e=>e.reviewed<=e.total);function nu(e){return`${eu}${e}`}function ru(e){if(e!==null)try{let t=tu.safeParse(JSON.parse(e));return t.success?t.data:void 0}catch{return}}var iu=`X-Walkdiff-Key`;function au(){return document.querySelector(`meta[name="walkdiff-api-key"]`)?.getAttribute(`content`)??``}async function ou(e,t,n){let r=await fetch(e,{method:t,headers:{[iu]:au(),...n===void 0?{}:{"Content-Type":`application/json`}},...n===void 0?{}:{body:JSON.stringify(n)}});return{status:r.status,payload:await r.json()}}async function H(e,t,n){let{status:r,payload:i}=await ou(e,t,n);if(r>=400)throw Error(U(i)??`The app answered ${r}`);return i}function U(e){return typeof e==`object`&&e&&`error`in e&&typeof e.error==`string`?e.error:void 0}async function su(){return pl.array().parse(await H(`/api/reviews`,`GET`))}async function cu(e){await H(`/api/reviews`,`POST`,e)}async function lu(e){await H(`/api/reviews/${e}/refresh`,`POST`)}async function uu(e,t){let n=await Promise.all(t.map(async e=>({name:e.name,text:await e.text()})));await H(`/api/reviews/${e}/coverage`,`POST`,{reports:n})}async function du(e){await H(`/api/reviews/${e}`,`DELETE`)}async function fu(e,t){await H(`/api/reviews/${e}/stack`,`POST`,t)}async function pu(e){await H(`/api/reviews/${e}/stack`,`DELETE`)}async function mu(e){return Jl.parse(await H(`/api/stacks/${e}`,`GET`))}async function hu(e){return Jl.parse(await H(`/api/stacks/${e}/refresh`,`POST`))}var gu=409,_u={Ready:`ready`,Done:`done`,Blocked:`blocked`};async function vu(e,t){let n=await ou(`/api/stacks/${e}/approve/check`,`POST`,t);if(n.status===gu)return{kind:_u.Blocked,blocked:Zl.parse(n.payload)};if(n.status>=400)throw Error(U(n.payload)??`The app answered ${n.status}`);return{kind:_u.Ready}}async function yu(e,t){let n=await ou(`/api/stacks/${e}/approve`,`POST`,t);if(n.status===gu)return{kind:_u.Blocked,blocked:Zl.parse(n.payload)};if(n.status>=400)throw Error(U(n.payload)??`The app answered ${n.status}`);return{kind:_u.Done,result:$l.parse(n.payload)}}async function bu(e){await H(`/api/stacks/${e}`,`DELETE`)}async function xu(){return Al.parse(await H(`/api/settings`,`GET`))}async function Su(){return kl.parse(await H(`/api/settings/current`,`GET`))}async function Cu(e){return Al.parse(await H(`/api/settings`,`PUT`,e))}async function wu(){return jl.parse(await H(`/api/settings/test-ai`,`POST`))}function Tu(){let[e,t]=(0,l.useState)({destination:void 0,enabledByDefault:!1,problem:void 0});return(0,l.useEffect)(()=>{Su().then(({settings:e,anthropicBaseUrl:n})=>t({destination:El(e.ai,n??void 0),enabledByDefault:e.ai.enabledByDefault,problem:void 0})).catch(e=>t(t=>({...t,problem:e instanceof Error?e.message:String(e)})))},[]),e}function Eu(e){return e===void 0?`Include AI review`:e.isLocal?`Include AI review (uses a model on this machine; your code stays here)`:`Include AI review (sends the changed code to ${e.label}, and may cost money)`}var Du=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2064%2064'%20role='img'%20aria-label='Walkdiff'%3e%3cdefs%3e%3clinearGradient%20id='walk'%20x1='0'%20y1='0'%20x2='1'%20y2='0'%3e%3cstop%20offset='0'%20stop-color='%23f85149'/%3e%3cstop%20offset='1'%20stop-color='%233fb950'/%3e%3c/linearGradient%3e%3c/defs%3e%3crect%20width='64'%20height='64'%20rx='14'%20fill='%230d1117'/%3e%3cpath%20d='M11%2018%20L22%2046%20L32%2026%20L42%2046%20L53%2018'%20fill='none'%20stroke='url(%23walk)'%20stroke-width='6'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3ccircle%20cx='11'%20cy='18'%20r='5.5'%20fill='%23f85149'/%3e%3ccircle%20cx='32'%20cy='26'%20r='4'%20fill='%23e6edf3'/%3e%3ccircle%20cx='53'%20cy='18'%20r='5.5'%20fill='%233fb950'/%3e%3c/svg%3e`,Ou={NotStarted:`notStarted`,Partly:`partly`,Done:`done`,Changed:`changed`,NothingToReview:`nothingToReview`};function ku(e){return Au(Pu(e.url),e.reportHead)}function Au(e,t){if(e===void 0)return{stage:Ou.NotStarted,drafts:0};let{drafts:n,reviewed:r,total:i}=e,a=Nu(e.head,t);return a&&i===0?{stage:Ou.NothingToReview,drafts:n}:r===0?{stage:Ou.NotStarted,drafts:n}:a?r===i?{stage:Ou.Done,drafts:n}:{stage:Ou.Partly,reviewed:r,total:i,drafts:n}:{stage:Ou.Changed,drafts:n}}function ju(e){let t=e.drafts===0?``:`, ${e.drafts} ${e.drafts===1?`comment`:`comments`} not posted`;return`${Mu(e)}${t}`}function Mu(e){switch(e.stage){case Ou.NotStarted:return`not started`;case Ou.Partly:return`${e.reviewed} of ${e.total} reviewed`;case Ou.Done:return`✓ reviewed`;case Ou.Changed:return`changed since you reviewed it`;case Ou.NothingToReview:return`nothing to mark as reviewed`}}function Nu(e,t){return t!==null&&e.headSha===t.headSha&&e.baseRef===t.baseRef}function Pu(e){try{return ru(window.localStorage.getItem(nu(e)))}catch{return}}var Fu={Review:`review`,Stack:`stack`};function Iu(e){let t=[],n=new Set;for(let r of e){if(r.stack===null){t.push({kind:Fu.Review,review:r});continue}let{id:i}=r.stack;if(n.has(i))continue;n.add(i);let a=e.filter(e=>e.stack?.id===i).toSorted((e,t)=>(e.stack?.position??0)-(t.stack?.position??0));t.push({kind:Fu.Stack,id:i,members:a})}return t}function Lu(e,t){return e.url.replace(/\d+$/,String(t))}function Ru(e,t){return`${Yl(e.host,t.number)} ${t.title}`}function zu(e,t,n){let r=new Set(n.map(e=>e.url));return e.joining.filter(e=>!r.has(Lu(t,e)))}var Bu={Good:`good`,Attention:`attention`,Muted:`muted`,Problem:`problem`};function Vu(e){if(e.check===Kl.Failed)return[{text:`Couldn't check: ${e.error}`,tone:Bu.Problem}];if(e.status.state===Ul.Merged)return[{text:`Merged`,tone:Bu.Muted}];if(e.status.state===Ul.Closed)return[{text:`Closed`,tone:Bu.Muted}];let t=[],n=Hu(e.reportChange,e.status.baseRef);n!==void 0&&t.push(n);let r=Uu(e,zl.Approved);r.length>0&&t.push({text:`Approved by ${r.join(`, `)}`,tone:Bu.Good});let i=Uu(e,zl.ChangesRequested);return i.length>0&&t.push({text:`Changes requested by ${i.join(`, `)}`,tone:Bu.Attention}),t}function Hu(e,t){switch(e){case Gl.None:return;case Gl.NoReport:return{text:`No report yet`,tone:Bu.Attention};case Gl.NewCommits:return{text:`New commits`,tone:Bu.Attention};case Gl.Retargeted:return{text:`Retargeted to ${t}`,tone:Bu.Attention}}}function Uu(e,t){return e.check===Kl.Checked?e.reviewers.filter(e=>e.state===t).map(e=>e.name):[]}function Wu(e){if(e?.check===Kl.Checked&&e.status.state!==Ul.Open)return e.status.state}function Gu(e){return Wu(e)!==void 0}function Ku(e,t){let n=t?.members??[],r=e.length-n.filter(Gu).length,i=[`${r} ${r===1?`PR`:`PRs`}`],a=n.filter(e=>!Gu(e)&&Uu(e,zl.Approved).length>0).length;a>0&&i.push(`${a} approved`);let o=n.filter(e=>e.check===Kl.Checked&&e.reportChange!==Gl.None).length;return o>0&&i.push(`${o} ${o===1?`needs`:`need`} a refresh`),i.join(` · `)}function qu(e){return e.status===dl.Queued||e.status===dl.Analyzing}function Ju(e,t){if(e===void 0)return{ready:!1,blocker:`Still checking with the host.`};if(e.check===Kl.Failed)return{ready:!1,blocker:`Couldn't check it: ${e.error}`};switch(e.reportChange){case Gl.NoReport:return{ready:!1,blocker:`It has no report yet.`};case Gl.NewCommits:return{ready:!1,blocker:`It has new commits. Refresh it first.`};case Gl.Retargeted:return{ready:!1,blocker:`It merges into ${e.status.baseRef} now. Refresh it first.`};case Gl.None:return{ready:!0,headSha:e.status.headSha,warnings:Yu(t)}}}function Yu(e){return[Xu(e.drafts),Zu(e)].filter(e=>e!==void 0)}function Xu(e){if(e!==0)return e===1?`It has a comment you haven't posted. Open it to post it, or approve without it.`:`It has ${e} comments you haven't posted. Open it to post them, or approve without them.`}function Zu(e){switch(e.stage){case Ou.NotStarted:return`You haven't started reviewing it.`;case Ou.Partly:return`You've reviewed ${e.reviewed} of ${e.total} changes.`;case Ou.Changed:return`It changed since you reviewed it. Open it to see what's new.`;case Ou.Done:case Ou.NothingToReview:return}}function Qu(e){return/^https?:\/\//i.test(e)}var $u=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),W=e(((e,t)=>{t.exports=$u()}))();function ed({review:e,offer:t,reviews:n,destination:r,onAccept:i,onDismiss:a}){let[o,s]=(0,l.useState)(e.ai),c=e.stack!==null,u=zu(t,e,n).length,d=t.joining.length;return(0,W.jsxs)(`section`,{className:`stack-offer`,"aria-label":`Stack found`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{children:c?`${d} new ${d===1?`PR`:`PRs`} joined this stack`:`Part of a stack of ${t.members.length}`}),` into `,(0,W.jsx)(`code`,{children:t.trunk}),`: `,(0,W.jsx)(G,{review:e,members:t.members})]}),t.leftOut.length>0&&(0,W.jsx)(K,{review:e,offer:t}),u>0?(0,W.jsxs)(`label`,{className:`add-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),Eu(r),`, for the `,u===1?`PR`:`${u} PRs`,` not on your list yet`]}):(0,W.jsxs)(`p`,{className:`stack-offer-note`,children:[d===1?`It's`:`They're all`,` on your list already, and will be grouped without analyzing again.`]}),(0,W.jsxs)(`div`,{className:`review-actions`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>i(o),children:c?`Add to the stack`:`Review the whole stack`}),(0,W.jsx)(`button`,{type:`button`,onClick:a,children:`Not now`})]})]})}function G({review:e,members:t}){return(0,W.jsx)(W.Fragment,{children:t.map((t,n)=>(0,W.jsxs)(l.Fragment,{children:[n>0&&` → `,t.number===e.number?(0,W.jsxs)(`strong`,{children:[Ru(e,t),` (this one)`]}):(0,W.jsx)(`a`,{href:Lu(e,t.number),target:`_blank`,rel:`noreferrer`,children:Ru(e,t)})]},t.number))})}function K({review:e,offer:t}){let n=t.members.at(-1);return n===void 0?null:(0,W.jsxs)(`p`,{className:`stack-offer-note`,children:[t.leftOut.map((n,r)=>(0,W.jsxs)(l.Fragment,{children:[r>0&&(r===t.leftOut.length-1?` and `:`, `),(0,W.jsx)(`a`,{href:Lu(e,n.number),target:`_blank`,rel:`noreferrer`,children:Ru(e,n)})]},n.number)),` `,`also build on `,Ru(e,n),`. Add them on their own if you want to review them.`]})}var q=`https://github.com/navasvarela/walkdiff/blob/main/docs/troubleshooting.md`,J={[dl.Queued]:`Queued`,[dl.Analyzing]:`Analyzing…`,[dl.Ready]:`Ready`,[dl.Failed]:`Failed`},Y={[Jc.High]:`High severity finding`,[Jc.Medium]:`Medium severity finding`,[Jc.Low]:`Low severity finding`};function td({review:e,reviews:t,destination:n,actions:r,badge:i,children:a}){let o=qu(e);return(0,W.jsxs)(`div`,{className:`review`,children:[(0,W.jsxs)(`div`,{className:`review-main`,children:[i,e.securityLevel!==null&&e.securityLevel!==Jc.Low&&(0,W.jsx)(`span`,{className:`level level-${e.securityLevel}`,children:Y[e.securityLevel]}),e.hasReport?(0,W.jsx)(`a`,{className:`review-title`,href:`/reviews/${e.id}/`,children:e.title??e.displayName}):(0,W.jsx)(`span`,{className:`review-title`,children:e.title??e.displayName}),e.status!==dl.Ready&&(0,W.jsx)(`span`,{className:`status status-${e.status}`,children:J[e.status]})]}),e.status===dl.Analyzing&&(0,W.jsx)(rd,{review:e}),(0,W.jsx)(nd,{review:e}),a,e.error!==null&&(0,W.jsxs)(`p`,{className:`problem`,children:[e.error,` `,(0,W.jsx)(`a`,{href:`https://github.com/navasvarela/walkdiff/blob/main/docs/troubleshooting.md`,target:`_blank`,rel:`noreferrer`,children:`How to fix this`})]}),e.stackOffer!==null&&(0,W.jsx)(ed,{review:e,offer:e.stackOffer,reviews:t,destination:n,onAccept:r.acceptStack,onDismiss:r.dismissStack}),(0,W.jsxs)(`div`,{className:`review-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:o,onClick:r.refresh,children:`Refresh`}),e.hasReport&&!o&&(0,W.jsx)(ad,{hasCoverage:e.coverageSource!==null,onAttach:r.attachCoverage}),(0,W.jsx)(`button`,{type:`button`,onClick:r.remove,children:`Remove`})]})]})}function nd({review:e}){return(0,W.jsxs)(`p`,{className:`review-meta`,children:[(0,W.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.displayName}),e.author!==null&&(0,W.jsxs)(W.Fragment,{children:[` by `,e.author]}),e.unitsToReview!==null&&(0,W.jsxs)(W.Fragment,{children:[` · `,e.unitsToReview,` to review`]}),e.untouchedReferences!==null&&e.untouchedReferences>0&&(0,W.jsxs)(W.Fragment,{children:[` · `,e.untouchedReferences,` untouched callers`]}),e.findings!==null&&(0,W.jsxs)(W.Fragment,{children:[` `,`· `,e.findings,` `,e.findings===1?`finding`:`findings`]}),e.ai&&(0,W.jsx)(W.Fragment,{children:` · AI`}),e.hasReport&&(0,W.jsxs)(W.Fragment,{children:[` · `,ju(ku(e))]}),e.hasReport&&(0,W.jsxs)(W.Fragment,{children:[` · `,id(e.coverageSource)]}),(0,W.jsxs)(W.Fragment,{children:[` · updated `,new Date(e.updatedAt).toLocaleString()]})]})}function rd({review:e}){if(e.step===null)return(0,W.jsx)(`div`,{className:`progress progress-starting`,role:`progressbar`,"aria-label":`Starting the analysis`});let{number:t,total:n,label:r}=m(e.step,e.ai);return(0,W.jsxs)(`div`,{className:`analysis-progress`,children:[(0,W.jsxs)(`div`,{className:`progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":t-1,"aria-valuetext":`Step ${t} of ${n}: ${r}`,children:[(0,W.jsx)(`div`,{className:`progress-done`,style:{width:`${(t-1)/n*100}%`}}),(0,W.jsx)(`div`,{className:`progress-current`,style:{left:`${(t-1)/n*100}%`,width:`${100/n}%`}})]}),(0,W.jsxs)(`p`,{className:`progress-label`,children:[`Step `,t,` of `,n,`: `,r,`…`]})]})}function id(e){return e===null?`no coverage found`:`coverage from ${e}`}function ad({hasCoverage:e,onAttach:t}){return(0,W.jsxs)(`label`,{className:`file-button`,title:`An LCOV or Cobertura report from this PR's latest commit. Applies to this PR only.`,children:[e?`Replace coverage`:`Attach coverage`,(0,W.jsx)(`input`,{type:`file`,multiple:!0,accept:`.info,.lcov,.xml`,onChange:e=>{t([...e.target.files??[]]),e.target.value=``}})]})}var od=`http://localhost:11434/v1`;function sd(){let[e,t]=(0,l.useState)(),[n,r]=(0,l.useState)(),[i,a]=(0,l.useState)(),[o,s]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{xu().then(e=>{t(e),r(e.settings)}).catch(e=>a(_d(e)))},[]),e===void 0||n===void 0)return(0,W.jsx)(`main`,{className:`page`,children:i===void 0?(0,W.jsx)(`p`,{className:`empty`,children:`Loading settings…`}):(0,W.jsx)(`p`,{className:`problem`,children:i})});let c=e=>{r(e),s(!1),a(void 0)},u=async()=>{try{let e=await Cu(n);return t(e),s(!0),a(void 0),!0}catch(e){return a(_d(e)),!1}};return(0,W.jsxs)(`main`,{className:`page settings`,children:[(0,W.jsx)(`h1`,{children:`Settings`}),(0,W.jsxs)(`p`,{className:`settings-lede`,children:[`These are your own preferences, saved on this machine. A repository's `,(0,W.jsx)(`code`,{children:`.walkdiff.json`}),` can still forbid AI review or limit where its code goes.`]}),(0,W.jsx)(cd,{checks:e.checks,disabled:n.disabledChecks,onChange:e=>c({...n,disabledChecks:e})}),(0,W.jsx)(ud,{ai:n.ai,view:e,onChange:e=>c({...n,ai:e}),onSave:u}),(0,W.jsx)(pd,{settings:n,checks:e.checks,offline:e.offline,anthropicBaseUrl:e.anthropicBaseUrl??void 0}),(0,W.jsxs)(`div`,{className:`settings-actions`,children:[(0,W.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>void u(),children:`Save settings`}),o&&(0,W.jsx)(`span`,{className:`settings-saved`,children:`✓ Saved. New reviews and refreshes will use these.`}),i!==void 0&&(0,W.jsx)(`span`,{className:`problem`,children:i})]})]})}function cd({checks:e,disabled:t,onChange:n}){let r=(e,r)=>n(r?t.filter(t=>t!==e):[...t,e]);return(0,W.jsxs)(`section`,{className:`settings-card`,"aria-labelledby":`settings-checks`,children:[(0,W.jsx)(`h2`,{id:`settings-checks`,children:`Checks`}),(0,W.jsx)(`p`,{className:`settings-hint`,children:`A check you turn off shows in every report as a check that didn't run. Built-in rules for secrets and risky code always run.`}),(0,W.jsx)(`ul`,{className:`check-list`,children:e.map(e=>(0,W.jsx)(ld,{check:e,on:!t.includes(e.id),onToggle:t=>r(e.id,t)},e.id))})]})}function ld({check:e,on:t,onToggle:n}){let r=e.installed===!1;return(0,W.jsxs)(`li`,{className:`check-row`,children:[(0,W.jsxs)(`label`,{className:`check-label`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.name}),(0,W.jsx)(`span`,{className:`check-purpose`,children:e.purpose}),e.sends!==null&&(0,W.jsx)(`span`,{className:`check-sends`,children:`${e.sends.where}: ${e.sends.what}`})]})]}),r&&t&&(0,W.jsxs)(`span`,{className:`check-missing`,children:[`Not installed: `,(0,W.jsx)(`code`,{children:e.install})]}),e.installed===!0&&t&&(0,W.jsx)(`span`,{className:`check-ready`,children:`✓ Ready`})]})}function ud({ai:e,view:t,onChange:n,onSave:r}){let[i,a]=(0,l.useState)(!1),[o,s]=(0,l.useState)(),c=e.provider===_l.OpenAiCompatible,u=Sl.safeParse(e),d=u.success?El(u.data,t.anthropicBaseUrl??void 0):void 0,f=e=>{s(void 0),n(e)},p=async()=>{a(!0),s(void 0);try{await r()&&s(await wu())}catch(e){s({ok:!1,message:_d(e)})}finally{a(!1)}};return(0,W.jsxs)(`section`,{className:`settings-card`,"aria-labelledby":`settings-ai`,children:[(0,W.jsx)(`h2`,{id:`settings-ai`,children:`AI review`}),(0,W.jsx)(`p`,{className:`settings-hint`,children:`AI review is optional. It never runs unless you ask for it on a review or turn it on below.`}),(0,W.jsxs)(`div`,{className:`settings-field`,children:[(0,W.jsx)(`label`,{htmlFor:`ai-provider`,children:`Provider`}),(0,W.jsxs)(`select`,{id:`ai-provider`,value:e.provider,onChange:t=>{let n=t.target.value===_l.OpenAiCompatible?_l.OpenAiCompatible:_l.Anthropic;f({...e,provider:n,model:n===_l.Anthropic?vl:``,baseUrl:n===_l.Anthropic?null:e.baseUrl??``})},children:[(0,W.jsx)(`option`,{value:_l.Anthropic,children:`Anthropic`}),(0,W.jsx)(`option`,{value:_l.OpenAiCompatible,children:`OpenAI-compatible (OpenAI, other services, local models)`})]})]}),c&&(0,W.jsxs)(`div`,{className:`settings-field`,children:[(0,W.jsx)(`label`,{htmlFor:`ai-base-url`,children:`Address`}),(0,W.jsx)(`input`,{id:`ai-base-url`,type:`url`,value:e.baseUrl??``,placeholder:od,onChange:t=>f({...e,baseUrl:t.target.value})})]}),(0,W.jsxs)(`div`,{className:`settings-field`,children:[(0,W.jsx)(`label`,{htmlFor:`ai-model`,children:`Model`}),(0,W.jsx)(`input`,{id:`ai-model`,type:`text`,value:e.model,placeholder:c?`llama3.2`:vl,onChange:t=>f({...e,model:t.target.value})})]}),(0,W.jsxs)(`div`,{className:`settings-field`,children:[(0,W.jsx)(`label`,{htmlFor:`ai-budget`,children:`Prompt limit (tokens)`}),(0,W.jsx)(`input`,{id:`ai-budget`,type:`number`,min:1,step:1e3,value:e.maxInputTokens,onChange:t=>f({...e,maxInputTokens:Number(t.target.value)})})]}),(0,W.jsx)(fd,{compatible:c,keys:t.aiKeys,isLocal:d?.isLocal??!1}),!c&&t.anthropicBaseUrl!==null&&(0,W.jsx)(dd,{address:t.anthropicBaseUrl}),(0,W.jsxs)(`label`,{className:`settings-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.enabledByDefault,onChange:t=>f({...e,enabledByDefault:t.target.checked})}),`Tick AI review by default on new reviews`]}),!u.success&&(0,W.jsx)(`p`,{className:`problem`,children:u.error.issues.at(0)?.message}),(0,W.jsxs)(`div`,{className:`settings-test`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:i||!u.success,onClick:()=>void p(),children:i?`Testing…`:`Save and test connection`}),o!==void 0&&(0,W.jsx)(`span`,{className:o.ok?`settings-saved`:`problem`,children:o.message})]})]})}function dd({address:e}){return(0,W.jsxs)(`p`,{className:`settings-warning`,role:`alert`,children:[(0,W.jsx)(`strong`,{children:`Your code and API key won't go to Anthropic.`}),` `,(0,W.jsx)(`code`,{children:`ANTHROPIC_BASE_URL`}),` in this app's environment sends them to `,(0,W.jsx)(`code`,{children:e}),`. If you didn't mean that, unset it and restart the app.`]})}function fd({compatible:e,keys:t,isLocal:n}){let r=e?`WALKDIFF_AI_API_KEY`:`ANTHROPIC_API_KEY`,i=e?t.openaiCompatible:t.anthropic;return(0,W.jsxs)(`p`,{className:`settings-key`,children:[i?(0,W.jsxs)(W.Fragment,{children:[`✓ `,(0,W.jsx)(`code`,{children:r}),` is set.`]}):e&&n?(0,W.jsxs)(W.Fragment,{children:[`A local model usually needs no key. If yours does, set `,(0,W.jsx)(`code`,{children:r}),`.`]}):e?(0,W.jsxs)(W.Fragment,{children:[`No key found. Set `,(0,W.jsx)(`code`,{children:r}),` and restart the app.`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`code`,{children:r}),` isn't set. Set it and restart the app, or use an `,(0,W.jsx)(`code`,{children:`ant auth login`}),` profile.`]}),` `,`Keys stay in your environment, and aren't saved by Walkdiff.`]})}function pd({settings:e,checks:t,offline:n,anthropicBaseUrl:r}){let i=hd(e,t,n,r);return(0,W.jsxs)(`section`,{className:`settings-card`,"aria-labelledby":`settings-privacy`,children:[(0,W.jsx)(`h2`,{id:`settings-privacy`,children:`What leaves this machine`}),(0,W.jsxs)(`p`,{className:`settings-hint`,children:[`With the settings above.`,n?` The app was started with --offline, so OSV and Semgrep are skipped.`:``,md(e)&&` AI review uses a model on this machine, so it sends nothing out.`]}),(0,W.jsxs)(`table`,{className:`privacy-table`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{scope:`col`,children:`Where`}),(0,W.jsx)(`th`,{scope:`col`,children:`What`}),(0,W.jsx)(`th`,{scope:`col`,children:`When`})]})}),(0,W.jsx)(`tbody`,{children:i.map(e=>(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`td`,{children:e.where}),(0,W.jsx)(`td`,{children:e.what}),(0,W.jsx)(`td`,{children:e.when})]},e.where))})]})]})}function md(e){let t=Sl.safeParse(e.ai);return t.success&&El(t.data).isLocal}function hd(e,t,n,r){let i=t=>!n&&!e.disabledChecks.includes(t.id)&&t.installed!==!1,a=Sl.safeParse(e.ai),o=a.success?El(a.data,r):void 0;return[{where:`The PR's host`,what:`Your token, if the host is trusted, to read the PR and its code`,when:`Every review`},...gd(t.filter(i).flatMap(e=>e.sends===null?[]:[e.sends])),...o!==void 0&&!o.isLocal?[{where:o.label,what:`The changed code, and the PR's title and description, with known credential formats redacted`,when:e.ai.enabledByDefault?`Reviews with AI ticked, which is the default`:`Only reviews with AI ticked`}]:[]]}function gd(e){let t=new Set;return e.filter(e=>{let n=`${e.where}\0${e.what}`;return!t.has(n)&&(t.add(n),!0)})}function _d(e){return e instanceof Error?e.message:String(e)}async function vd(e,t,n){let r=await t.check(e);if(r.kind===_u.Blocked)return{kind:_u.Blocked,blocked:r.blocked.blocked};for(let r of e.members)n.posting(r.reviewId),n.posted(await yd({body:e.body,members:[r]},r.reviewId,t));return{kind:_u.Done}}async function yd(e,t,n){let r=e=>({outcome:Ql.Refused,reviewId:t,error:e});try{let i=await n.approve(e);return i.kind===_u.Blocked?r(i.blocked.blocked.find(e=>e.reviewId===t)?.reason??i.blocked.error):i.result.results.find(e=>e.reviewId===t)??r(`The app didn't say what happened to it.`)}catch(e){return r(e instanceof Error?e.message:String(e))}}var bd=7,X={Confirm:`confirm`,Posting:`posting`,Results:`results`,Blocked:`blocked`};function xd({stackId:e,members:t,view:n,onClose:r,onPosted:i}){let a=(0,l.useRef)(null),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)({phase:X.Confirm}),[d,f]=(0,l.useState)();(0,l.useEffect)(()=>a.current?.showModal(),[]);let p=new Map(t.map(e=>[e.id,Ju(n.members.find(t=>t.reviewId===e.id),ku(e))])),m=c.phase===X.Results?c.results.filter(e=>e.outcome===Ql.Refused).map(e=>e.reviewId):[],h=c.phase===X.Results?t.filter(e=>m.includes(e.id)):t,g=h.some(e=>!(p.get(e.id)?.ready??!1)),_=async()=>{let t=h.flatMap(e=>{let t=p.get(e.id);return t?.ready===!0?[{reviewId:e.id,headSha:t.headSha}]:[]}),n=c,r=(c.phase===X.Results?c.results:[]).filter(e=>!t.some(t=>t.reviewId===e.reviewId));u({phase:X.Posting,results:r,current:void 0}),f(void 0);try{let n=await vd({body:o,members:t},{check:t=>vu(e,t),approve:t=>yu(e,t)},{posting:e=>u({phase:X.Posting,results:r,current:e}),posted:e=>{r=[...r,e],u({phase:X.Posting,results:r,current:void 0})}});if(n.kind===_u.Blocked){u({phase:X.Blocked,blocked:n.blocked});return}u({phase:X.Results,results:r}),i()}catch(e){f(e instanceof Error?e.message:String(e)),u(n)}},v=e=>c.phase===X.Results||c.phase===X.Posting?c.results.find(t=>t.reviewId===e.id):void 0,y=e=>c.phase===X.Blocked?c.blocked.find(t=>t.reviewId===e.id)?.reason:void 0,b=e=>{if(c.phase===X.Posting&&c.current!==void 0&&v(e)===void 0)return e.id===c.current?Cd.Posting:Cd.Waiting};return(0,W.jsxs)(`dialog`,{ref:a,className:`approve-dialog`,"aria-labelledby":`approve-title`,onClose:r,onCancel:e=>c.phase===X.Posting&&e.preventDefault(),children:[(0,W.jsxs)(`h2`,{id:`approve-title`,children:[`Approve `,t.length===1?`this PR`:`all ${t.length} PRs`]}),(0,W.jsx)(`p`,{className:`approve-lede`,children:`Each gets its own approval, for the commit its report shows, posted bottom first.`}),(0,W.jsx)(`ol`,{className:`approve-members`,children:t.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(Td,{member:e,check:p.get(e.id),result:v(e),blockedReason:y(e),step:b(e)})},e.id))}),c.phase===X.Blocked&&(0,W.jsx)(`p`,{className:`problem`,children:`Nothing was posted: some PRs changed since the card last checked. Close this, use Refresh changed, and look again.`}),c.phase!==X.Results&&c.phase!==X.Blocked&&(0,W.jsxs)(`label`,{className:`approve-body`,children:[`Comment to post with each approval (optional)`,(0,W.jsx)(`textarea`,{value:o,rows:3,disabled:c.phase===X.Posting,onChange:e=>s(e.target.value)})]}),d!==void 0&&(0,W.jsx)(`p`,{className:`problem`,children:d}),(0,W.jsxs)(`div`,{className:`review-actions`,children:[(c.phase===X.Confirm||c.phase===X.Posting||m.length>0)&&(0,W.jsx)(`button`,{type:`button`,className:`primary`,disabled:g||c.phase===X.Posting,onClick:()=>void _(),children:c.phase===X.Posting?Sd(c.current):m.length>0?`Retry ${m.length} that failed`:`Approve ${t.length===1?`it`:`all ${t.length}`}`}),(0,W.jsx)(`button`,{type:`button`,disabled:c.phase===X.Posting,onClick:()=>a.current?.close(),children:c.phase===X.Results||c.phase===X.Blocked?`Close`:`Cancel`})]})]})}function Sd(e){return e===void 0?`Checking…`:`Posting…`}var Cd={Posting:`posting`,Waiting:`waiting`},wd={[Cd.Posting]:`Posting…`,[Cd.Waiting]:`Waiting`};function Td({member:e,check:t,result:n,blockedReason:r,step:i}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`approve-member`,children:[Yl(e.host,e.number),` `,e.title??e.displayName,t?.ready===!0&&(0,W.jsx)(`code`,{className:`approve-sha`,children:t.headSha.slice(0,bd)})]}),(0,W.jsx)(Ed,{check:t,result:n,blockedReason:r,step:i})]})}function Ed({check:e,result:t,blockedReason:n,step:r}){return t===void 0?n===void 0?r===void 0?e===void 0?null:e.ready?(0,W.jsx)(W.Fragment,{children:e.warnings.map(e=>(0,W.jsx)(`p`,{className:`member-state-attention`,children:e},e))}):(0,W.jsx)(`p`,{className:`member-state-problem`,children:e.blocker}):(0,W.jsx)(`p`,{className:`member-state-muted`,children:wd[r]}):(0,W.jsx)(`p`,{className:`member-state-problem`,children:n}):(0,W.jsx)(Dd,{result:t})}function Dd({result:e}){return e.outcome===Ql.Refused?(0,W.jsxs)(`p`,{className:`member-state-problem`,children:[`✗ Not approved: `,e.error]}):(0,W.jsxs)(`p`,{className:`member-state-good`,children:[`✓ Approved`,Qu(e.url)&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:`View`})]})]})}function Od({id:e,members:t,reviews:n,destination:r,actionsFor:i,act:a}){let[o,s]=(0,l.useState)(),[c,u]=(0,l.useState)(),[d,f]=(0,l.useState)(!1),[p,m]=(0,l.useState)(!1),h=t.some(qu),g=h?`busy`:t.map(e=>`${e.id}@${e.updatedAt}`).join();(0,l.useEffect)(()=>{if(g===`busy`)return;let t=!0;return mu(e).then(e=>{t&&(s(e),u(void 0))}).catch(e=>t&&u(e instanceof Error?e.message:String(e))),()=>{t=!1}},[e,g]);let _=e=>o?.members.find(t=>t.reviewId===e.id),v=t.filter(e=>!Gu(_(e))),y=t.filter(e=>Gu(_(e))),b=o?.trunk;return(0,W.jsxs)(`section`,{className:`stack-card`,"aria-label":`Stack of ${t.length}`,children:[(0,W.jsxs)(`div`,{className:`stack-header`,children:[(0,W.jsxs)(`h2`,{children:[`Stack`,b!==void 0&&(0,W.jsxs)(W.Fragment,{children:[` into `,(0,W.jsx)(`code`,{children:b})]})]}),(0,W.jsx)(`span`,{className:`stack-headline`,children:Ku(t,o)}),(0,W.jsxs)(`div`,{className:`review-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:o===void 0||h||v.length===0,onClick:()=>m(!0),title:`Posts an approval to each open PR in the stack, after a confirmation`,children:`Approve all…`}),(0,W.jsx)(`button`,{type:`button`,disabled:h||d,onClick:()=>{f(!0),a(async()=>{try{s(await hu(e))}finally{f(!1)}})},title:`Asks the host what changed, and analyzes again only the PRs whose reports are out of date`,children:`Refresh changed`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>a(()=>bu(e)),title:`Keeps the reviews, as separate rows`,children:`Ungroup`})]})]}),c!==void 0&&(0,W.jsx)(`p`,{className:`problem`,children:c}),p&&o!==void 0&&(0,W.jsx)(xd,{stackId:e,members:v,view:o,onClose:()=>m(!1),onPosted:()=>void mu(e).then(s,e=>u(e instanceof Error?e.message:String(e)))}),(0,W.jsx)(`ol`,{className:`stack-members`,children:v.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(td,{review:e,reviews:n,destination:r,actions:i(e),badge:(0,W.jsxs)(`span`,{className:`stack-position`,title:`Its place in the stack, from the bottom`,children:[t.indexOf(e)+1,`/`,t.length]}),children:(0,W.jsx)(kd,{status:_(e),working:qu(e)})})},e.id))}),y.length>0&&(0,W.jsxs)(`p`,{className:`stack-done`,children:[`Done:`,` `,y.map((e,t)=>(0,W.jsxs)(`span`,{children:[t>0&&` · `,(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[Yl(e.host,e.number),` `,e.title??e.displayName]}),` `,`(`,Wu(_(e)),`)`]},e.id))]})]})}function kd({status:e,working:t}){if(e===void 0||t)return null;let n=Vu(e);return n.length===0?null:(0,W.jsx)(`p`,{className:`member-state`,children:n.map(e=>(0,W.jsx)(`span`,{className:`member-state-${e.tone}`,children:e.text},e.text))})}var Ad=`https://github.com/navasvarela/walkdiff/blob/main/docs/README.md`,jd=1500,Md=`#settings`,Nd=`#`;function Pd(){let[e,t]=(0,l.useState)(window.location.hash);(0,l.useEffect)(()=>{let e=()=>t(window.location.hash);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let n=e===Md;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Fd,{onSettings:n}),n?(0,W.jsx)(sd,{}):(0,W.jsx)(Id,{})]})}function Fd({onSettings:e}){return(0,W.jsxs)(`header`,{className:`topbar`,children:[(0,W.jsxs)(`a`,{className:`topbar-brand`,href:Nd,children:[(0,W.jsx)(`img`,{src:Du,alt:``,width:`22`,height:`22`}),`Walkdiff`]}),(0,W.jsxs)(`nav`,{className:`topbar-nav`,"aria-label":`Sections`,children:[(0,W.jsx)(`a`,{href:Nd,"aria-current":e?void 0:`page`,children:`Reviews`}),(0,W.jsx)(`a`,{href:Md,"aria-current":e?`page`:void 0,children:`Settings`})]})]})}function Id(){let[e,t]=(0,l.useState)(),[n,r]=(0,l.useState)(),i=(0,l.useCallback)(async()=>{try{t(await su()),r(void 0)}catch(e){r(e instanceof Error?e.message:String(e))}},[]);(0,l.useEffect)(()=>{i()},[i]);let a=Tu(),o=e?.some(qu)??!1;(0,l.useEffect)(()=>{if(!o)return;let e=window.setInterval(()=>void i(),jd);return()=>window.clearInterval(e)},[o,i]);let s=e=>{e().then(i).catch(e=>r(e instanceof Error?e.message:String(e)))},c=e=>({refresh:()=>s(()=>lu(e.id)),attachCoverage:t=>s(()=>uu(e.id,t)),remove:()=>s(()=>du(e.id)),acceptStack:t=>s(()=>fu(e.id,{ai:t})),dismissStack:()=>s(()=>pu(e.id))});return(0,W.jsxs)(`main`,{className:`page`,children:[(0,W.jsx)(`h1`,{children:`Reviews`}),(0,W.jsx)(Ld,{onAdded:i,destination:a.destination,enabledByDefault:a.enabledByDefault}),a.problem!==void 0&&(0,W.jsx)(`p`,{className:`problem`,children:a.problem}),n!==void 0&&(0,W.jsx)(`p`,{className:`problem`,children:n}),e===void 0?null:e.length===0?(0,W.jsx)(`p`,{className:`empty`,children:`Nothing here yet. Paste a pull request or merge request link above to start a review.`}):(0,W.jsx)(`ul`,{className:`reviews`,children:Iu(e).map(t=>t.kind===Fu.Review?(0,W.jsx)(`li`,{children:(0,W.jsx)(td,{review:t.review,reviews:e,destination:a.destination,actions:c(t.review)})},`review-${t.review.id}`):(0,W.jsx)(`li`,{children:(0,W.jsx)(Od,{id:t.id,members:t.members,reviews:e,destination:a.destination,actionsFor:c,act:s})},`stack-${t.id}`))}),(0,W.jsxs)(`footer`,{className:`page-footer`,children:[(0,W.jsx)(`a`,{href:Ad,target:`_blank`,rel:`noreferrer`,children:`Documentation`}),(0,W.jsx)(`a`,{href:q,target:`_blank`,rel:`noreferrer`,children:`Troubleshooting`})]})]})}function Ld({onAdded:e,destination:t,enabledByDefault:n}){let[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)();return(0,l.useEffect)(()=>o(n),[n]),(0,W.jsxs)(`form`,{className:`add-review`,onSubmit:t=>{t.preventDefault(),cu({url:r,ai:a}).then(()=>(i(``),c(void 0),e())).catch(e=>c(e instanceof Error?e.message:String(e)))},children:[(0,W.jsxs)(`div`,{className:`add-row`,children:[(0,W.jsx)(`input`,{type:`url`,value:r,required:!0,autoFocus:!0,placeholder:`https://github.com/owner/repo/pull/123`,"aria-label":`Pull request or merge request link`,onChange:e=>i(e.target.value)}),(0,W.jsx)(`button`,{type:`submit`,children:`Add review`})]}),(0,W.jsxs)(`label`,{className:`add-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),Eu(t),` `,(0,W.jsx)(`a`,{href:Md,children:`Change`})]}),s!==void 0&&(0,W.jsx)(`p`,{className:`problem`,children:s})]})}var Rd=document.getElementById(`root`);if(Rd===null)throw Error(`index.html is missing the #root element`);(0,u.createRoot)(Rd).render((0,W.jsx)(l.StrictMode,{children:(0,W.jsx)(Pd,{})}));
|
package/app-ui/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Walkdiff reviews</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-BRMcNFUc.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-tYFZOod2.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "walkdiff",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "A review companion for GitHub pull requests and GitLab merge requests",
|
|
5
5
|
"license": "FSL-1.1-ALv2",
|
|
6
6
|
"type": "module",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"zod": "^4.6.7",
|
|
28
28
|
"@anthropic-ai/sdk": "^1.3.0",
|
|
29
29
|
"@tree-sitter-grammars/tree-sitter-kotlin": "^1.1.0",
|
|
30
|
+
"graphql": "17.0.2",
|
|
30
31
|
"jscpd": "5.4.2",
|
|
31
32
|
"oxlint": "1.92.0",
|
|
32
33
|
"smol-toml": "^1.9.1",
|