opencode-skills-deck 0.2.0-rc.0 → 0.3.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/README.md +70 -56
- package/dist/gui-experimental.cjs +61 -0
- package/dist/index.js +1455 -118
- package/dist/index.js.map +4 -4
- package/dist/rpc.js +19929 -0
- package/dist/rpc.js.map +7 -0
- package/dist/tui.js +151 -37
- package/dist/tui.js.map +3 -3
- package/package.json +27 -7
package/README.md
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
# opencode-skills-deck
|
|
2
2
|
|
|
3
|
-
OpenCode
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
OpenCode Desktop のセッション画面のサイド領域に常駐する「司令塔(Control Tower)」。GitHub Issue を選んで
|
|
4
|
+
専用の git worktree を切り、**アプリ内のタブ**で OpenCode の子セッションを開く。
|
|
5
|
+
子の Alive 状態(Working / Input wait / Closed / Error)を一覧と詳細で見ながら、後片付けまでを 1 か所で行う。
|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> v0.3.0。Desktop GUI 版は **experimental**。TUI 版(v1)は凍結して同梱している。
|
|
8
|
+
> 実機検証は macOS + OpenCode 2.3.0。Windows / Linux の GUI 実機確認は未実施。
|
|
8
9
|
|
|
9
10
|
## インストール
|
|
10
11
|
|
|
12
|
+
Desktop は GUI エントリを**グローバルの `opencode.json(c)` からだけ**読む。
|
|
13
|
+
|
|
11
14
|
```bash
|
|
12
15
|
opencode plugin add opencode-skills-deck
|
|
13
16
|
```
|
|
14
17
|
|
|
15
|
-
`~/.config/opencode/opencode.json`
|
|
18
|
+
`~/.config/opencode/opencode.json`(または `opencode.jsonc`):
|
|
16
19
|
|
|
17
20
|
```json
|
|
18
21
|
{
|
|
@@ -21,71 +24,82 @@ opencode plugin add opencode-skills-deck
|
|
|
21
24
|
}
|
|
22
25
|
```
|
|
23
26
|
|
|
27
|
+
Desktop を再起動するか、Settings › Extensions › Plugins で reload する。server part が起動しないと GUI も載らない。
|
|
28
|
+
|
|
29
|
+
## アップデート
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
opencode plugin check # 更新があるか
|
|
33
|
+
opencode plugin update # 全部(1 つだけなら opencode plugin update opencode-skills-deck)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
更新後は Desktop を再起動するか、Settings › Extensions › Plugins で reload する。設定
|
|
37
|
+
(`~/.config/opencode-skills-deck/config.json`)と編集済みの同梱スキルは残り、同梱スキルは未編集のものだけが
|
|
38
|
+
新しい版に置き換わる。
|
|
39
|
+
|
|
40
|
+
`@next` で入れた場合はタグ付きで指定する(`opencode plugin update opencode-skills-deck@next`)。
|
|
41
|
+
版が上がらないときは `opencode plugin add opencode-skills-deck@latest` で入れ直す。パス指定や tarball で入れた場合は
|
|
42
|
+
`plugin update` の対象外で、手動で入れ替える
|
|
43
|
+
([docs/install.md](https://github.com/ynxnty/opencode-skills-deck/blob/develop/docs/install.md))。
|
|
44
|
+
|
|
45
|
+
> 0.3.0(GUI)は Desktop 2.3.0 以上が必要。0.2.x の TUI だけを使う場合はそのままでよい。
|
|
46
|
+
|
|
47
|
+
## 開き方
|
|
48
|
+
|
|
49
|
+
セッションを開いた状態で、サイド領域の **`+` メニュー**か**コマンドパレット**から
|
|
50
|
+
**Open Control Tower** を選ぶ。pinned タブにはならず、カスタムキーバインドもない。
|
|
51
|
+
`Esc` だけが詳細・検索・ダイアログを閉じる。
|
|
52
|
+
|
|
53
|
+
## できること
|
|
54
|
+
|
|
55
|
+
- 一覧 → 詳細(B)。Issue の Summary / Acceptance criteria / ラベル / 出力プレビュー
|
|
56
|
+
- **New session**: worktree とブランチを用意し、その worktree で動くセッションのタブを開く。送信前のプロンプトは `composer` に入り、送るのは人間。既存タブは再利用
|
|
57
|
+
- **This session**: いまの composer に `issue#<n> を実行 ` を差し込む(worktree もタブも作らない)
|
|
58
|
+
- **Clarify requirements**(`@grill-with-docs`)/ **Find the goal**(`@wayfinder`)の ComposerPill
|
|
59
|
+
- Alive: `WORKING` / `INPUT WAIT`(`idle` / `permission` / `question`)/ `CLOSED` / `ERROR`。
|
|
60
|
+
アプリの session data から導出し、状態ストアを持たない
|
|
61
|
+
- 検索・ラベル絞り込み、Repo の切り替え(混在ボードは作らない)
|
|
62
|
+
- worktree の掃除(未コミット変更は拒否)と孤児 worktree の一覧・掃除
|
|
63
|
+
- 空 / 0 件 / 取得失敗 / オフライン / 初回同期の状態表示
|
|
64
|
+
- light / dark / ユーザーテーマに追従。CSS はパネル内にスコープする
|
|
65
|
+
|
|
24
66
|
## 必要環境
|
|
25
67
|
|
|
26
|
-
- OpenCode 2.3.x
|
|
68
|
+
- OpenCode Desktop 2.3.x(`>=2.3.0 <3.0.0`。`@opencode/plugin` の `./gui` がある版)
|
|
27
69
|
- `gh` CLI(`gh auth login` 済み。Issue の取得に使う)
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
## 起動
|
|
32
|
-
|
|
33
|
-
`/deck` または `Ctrl+Shift+D`(`openKey` で変更可)。
|
|
34
|
-
|
|
35
|
-
| キー | 動作 |
|
|
36
|
-
| -------------------------------- | ---------------------------- |
|
|
37
|
-
| `j` / `k` / `↓` / `↑` | 選択 |
|
|
38
|
-
| `PgUp` / `PgDn` / `Home` / `End` | ページ・先頭・末尾 |
|
|
39
|
-
| `Enter` | 起動 / 再開 |
|
|
40
|
-
| `g` / `w` | 対話セッション(スキル起動) |
|
|
41
|
-
| `c` | worktree を掃除 |
|
|
42
|
-
| `o` | 孤児 worktree を一覧・掃除 |
|
|
43
|
-
| `/` | 検索 |
|
|
44
|
-
| `Shift+L` | ラベル絞り込み |
|
|
45
|
-
| `1` / `2` / `v` | Issues / Board タブ |
|
|
46
|
-
| `R` | リポジトリ切替 |
|
|
47
|
-
| `r` | Issue を再取得 |
|
|
48
|
-
| `Esc` | 絞り込み解除 → 戻る |
|
|
70
|
+
- git 2.30 以上
|
|
71
|
+
- Node.js 22 以上(ビルドと開発時)
|
|
49
72
|
|
|
50
73
|
## 設定
|
|
51
74
|
|
|
52
|
-
`~/.config/opencode-skills-deck/config.json
|
|
75
|
+
`~/.config/opencode-skills-deck/config.json`(無ければ既定値で動く)。GUI で使うのは
|
|
76
|
+
`repos` / `issueLabelFilter` / `baseBranch` / `issueLimit` / `draftPromptIssue` /
|
|
77
|
+
`draftPromptSkill` / `installSkillsOnStart`。`terminal` / `terminalCommand` / `draftMode` /
|
|
78
|
+
`openKey` は v1 TUI 用で、GUI では使わない。
|
|
53
79
|
|
|
54
80
|
```json
|
|
55
81
|
{
|
|
56
|
-
"
|
|
57
|
-
"baseBranch":
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
"issueLabelFilter": null,
|
|
83
|
+
"baseBranch": null,
|
|
84
|
+
"issueLimit": 50,
|
|
85
|
+
"draftPromptIssue": "issue#{number} を実行 ",
|
|
86
|
+
"draftPromptSkill": "@{skill} ",
|
|
87
|
+
"installSkillsOnStart": true,
|
|
88
|
+
"repos": []
|
|
62
89
|
}
|
|
63
90
|
```
|
|
64
91
|
|
|
65
|
-
|
|
66
|
-
| ---------------------- | -------------------------- | ----------------------------------------------------------- |
|
|
67
|
-
| `terminal` | `"auto"` | `ghostty` / `alacritty` / `kitty` / `gnome-terminal` / `wt` |
|
|
68
|
-
| `baseBranch` | リポジトリの既定 | worktree を切る元ブランチ |
|
|
69
|
-
| `issueLabelFilter` | `null` | `gh issue list` の `--label` |
|
|
70
|
-
| `issueLimit` | `50` | 取得件数 |
|
|
71
|
-
| `draftPromptIssue` | `"issue#{number} を実行 "` | 子に渡す下書き |
|
|
72
|
-
| `draftMode` | `"review"` | `review`(送信前レビュー)/ `send` |
|
|
73
|
-
| `openKey` | `"ctrl+shift+d"` | Control Tower を開くキー |
|
|
74
|
-
| `installSkillsOnStart` | `true` | 同梱スキルを `~/.config/opencode/skills/` に配置 |
|
|
75
|
-
|
|
76
|
-
## 状態と後片付け
|
|
92
|
+
## 同梱スキル
|
|
77
93
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
94
|
+
`~/.config/opencode/skills/` に「無いものだけ」配置する。配置先の `.skills-deck.json` のハッシュで
|
|
95
|
+
未編集を確認し、未編集のものだけ同梱版が新しければ更新する。編集済みのものは触らない。
|
|
96
|
+
配置に失敗した環境では Clarify requirements / Find the goal の pill は出ない。
|
|
81
97
|
|
|
82
|
-
##
|
|
98
|
+
## TUI(v1・凍結)
|
|
83
99
|
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
`/deck` / `Ctrl+Shift+D` で開く TUI も同梱している。新機能は追加せず、バグ修正だけを行う。
|
|
101
|
+
状態ファイル、外部ターミナル起動、7 日 GC は v1 の動作で、GUI では使わない。
|
|
86
102
|
|
|
87
|
-
##
|
|
103
|
+
## ライセンス
|
|
88
104
|
|
|
89
|
-
|
|
90
|
-
- インストール: https://github.com/ynxnty/opencode-skills-deck/blob/develop/docs/install.md
|
|
91
|
-
- 検証記録: https://github.com/ynxnty/opencode-skills-deck/blob/develop/docs/verification.md
|
|
105
|
+
MIT
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("solid-js/web"),xe=require("@opencode/plugin/gui"),$=require("solid-js"),Po=require("@opencode/plugin/rpc");function It(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function gn(e,t="|"){return e.map(n=>cr(n)).join(t)}function Pt(e,t){return typeof t=="bigint"?t.toString():t}class Eo{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function pt(e){return new Eo(e)}function To(e){return e==null}function Jt(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ao(e,t){const n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}function ye(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Bt(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function fe(e){return Bt(e._zod.def)??e._zod.def.shape}function or(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return ye(this,t,r),r},enumerable:!0,configurable:!0})}function ir(e,t,n){t in e?ye(e,t,n):e[t]=n}function Ce(e,t,n,r){const o=fe(t);for(const i of n){const s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?or(e,i,()=>{const a=t._zod.def.shape[i];return r?r(a,i):a}):ir(e,i,r?r(s.value,i):s.value))}}function No(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?or(e,n,()=>t[n]):ir(e,n,r.value))}}function Y(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function jo(e){return JSON.stringify(e)}function Do(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const sr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Be(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ro=pt(()=>{if(ue.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ve(e){if(Be(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Be(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ar(e){return Ve(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Mo=new Set(["string","number","symbol"]);function Pe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function we(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function y(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function cr(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Fo(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const ur={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Lo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Uo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i={};return Ce(i,e,ht(e,t)),we(e,Y(n,{shape:i,checks:[]}))}function ht(e,t){const n=fe(e),r=[];for(const o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&r.push(o)}return r}function Jo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=new Set(ht(e,t)),s={};return Ce(s,e,Reflect.ownKeys(fe(e)).filter(a=>!i.has(a))),we(e,Y(n,{shape:s,checks:[]}))}function Bo(e,t){if(!Ve(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=fe(e);for(const i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return we(e,Y(e._zod.def,{shape:lr(e,t)}))}function lr(e,t){const n={};return Ce(n,e,Reflect.ownKeys(fe(e))),No(n,t),n}function Vo(e,t){if(!Ve(t))throw new Error("Invalid input to safeExtend: expected a plain object");return we(e,Y(e._zod.def,{shape:lr(e,t)}))}function Wo(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};Ce(n,e,Reflect.ownKeys(fe(e))),Ce(n,t,Reflect.ownKeys(fe(t)));const r=Y(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return we(e,r)}function vn(e,t,n,r="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set(ht(t,n)):void 0,c={};return Ce(c,t,Reflect.ownKeys(fe(t)),e&&((l,d)=>a&&!a.has(d)?l:new e({type:"optional",innerType:l}))),we(t,Y(t._zod.def,{shape:c,checks:[]}))}function Ko(e,t,n){const r=n?new Set(ht(t,n)):void 0,o={};return Ce(o,t,Reflect.ownKeys(fe(t)),(i,s)=>r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),we(t,Y(t._zod.def,{shape:o}))}function de(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function qo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function dr(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function je(e){return typeof e=="string"?e:e?.message}function bn(e){const t=[];for(const n of e??[]){const r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;const o=r.maximum??r.length??r.size;o>=0&&t.push([o,n])}return t}function Et(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Ae(e,t,n){var r;const o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:je(e.inst?._zod.def?.error?.(e))??je(i?.(e))??je(t?.error?.(e))??je(n.customError?.(e))??je(n.localeError?.(e))??"Invalid input",a={};for(const c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}const Go=/[\uD800-\uDBFF]/;function Vt(e){const t=e.length;if(!Go.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function Wt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ho(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function We(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function Yo(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Xo(e,n,r.value)}}function be(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function fr(e,t,n){return be(e,t,n,!1)}function pr(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return be(this,n,r(this))},set(o){be(this,n,o)}})}return t}function Xo(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:be(this,t,n.bind(this))},set(r){be(this,t,r)}})}function Qo(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let bt,ge=!1;const ei={configurable:!0,get(){ge=!0}};function C(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&bt!==e._zod){bt=void 0;return}bt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,ei);const o=ge;ge=!1;try{const i=n(this);return ge?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ge=ge||o,i}catch(i){throw delete this[t],ge=ge||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function ti(e,t,n,r){const o=Qo(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}const ni="~constantCatch";function ri(e){const t=()=>e;return t[ni]=!0,t}var _n;const _t={value:void 0,enumerable:!1};let yn="captureStackTrace"in Error?Error:null;function oi(e){const t=yn;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return yn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function f(e,t,n,r){const o={};function i(h){this.def=h,this.constr=p,this.traits=new Set}i.prototype=o;const s=n,a=s&&new WeakSet;function c(h,g){if(h._zod){if(h._zod.traits.has(e))return}else{_t.value=new i(g);try{Object.defineProperty(h,"_zod",_t)}finally{_t.value=void 0}}if(h._zod.traits.add(e),t(h,g),a){const m=Object.getPrototypeOf(h),b=h._zod.constr.prototype;let O=m;for(;O&&O!==b;)O=Object.getPrototypeOf(O);const T=O??m;a.has(T)||(a.add(T),Yo(T,s))}const v=p.prototype;for(const m in v)Object.prototype.hasOwnProperty.call(v,m)&&(m in h||(h[m]=v[m].bind(h)))}const l=r?.Parent??Object;class d extends l{}Object.defineProperty(d,"name",{value:e});function p(h){const g=r?.Parent?oi(d):this;c(g,h);const v=g._zod.deferred;if(v){for(const b of v)b();g._zod.deferred=void 0}const m=globalThis.__zod_globalConfig?.postProcessor;return m&&m(g),g}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:h=>r?.Parent&&h instanceof r.Parent?!0:h?._zod?.traits?.has(e)}),Object.defineProperty(p,"name",{value:e}),p}class Oe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class hr extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(_n=globalThis).__zod_globalConfig??(_n.__zod_globalConfig={});const ue=globalThis.__zod_globalConfig;function ke(e){return e&&Object.assign(ue,e),ue}function ii(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Pt,2)),e.message}function si(e){this._zod.message=e}const ai={get:ii,set:si,enumerable:!0,configurable:!0},yt={value:void 0,enumerable:!1},wn=new WeakSet([Object.prototype,Error.prototype]),ci=(e,t)=>{e.name="$ZodError",yt.value=t,Object.defineProperty(e,"issues",yt),yt.value=void 0,Object.defineProperty(e,"message",ai);const n=Object.getPrototypeOf(e);wn.has(n)||(wn.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},ui=f("$ZodError",ci);function li(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function di(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?li(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function fi(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)n._errors.push(t(s));else{let c=n,l=0;for(;l<a.length;){const d=a[l],p=l===a.length-1;if(d==="_errors"){p&&c._errors.push(t(s)),l++;continue}Object.prototype.hasOwnProperty.call(c,d)||Object.defineProperty(c,d,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const h=c[d];p&&h._errors.push(t(s)),c=h,l++}}}};return r(e),n}function mt(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Kt=e=>{const t=(n,r,o,i)=>{const s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Oe;if(a.issues.length){const c=new(i?.Err??e)(a.issues.map(l=>Ae(l,s,ke())));throw sr(c,i?.callee??t),c}return a.value};return t},qt=e=>{const t=async(n,r,o,i)=>{const s=o?{...o,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const c=new(i?.Err??e)(a.issues.map(l=>Ae(l,s,ke())));throw sr(c,i?.callee??t),c}return a.value};return t},Gt=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Oe;return i.issues.length?mr(e,i.issues,o):{success:!0,data:i.value}};function mr(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(o=>Ae(o,n,ke()))),t=void 0,n=void 0),r},set error(o){r=o,t=void 0,n=void 0}}}const Ht=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?mr(e,i.issues,o):{success:!0,data:i.value}},pi=Symbol.for("zod.compile.invalid"),hi=Symbol.for("zod.compile.fallback"),mi=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==pi)return!0;if(r.definite===!0&&n===void 0)return!1}return gi(e,t,n)});function gi(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;let i;if(o?(r[hi]=!0,i=o({value:t,issues:[]},r)):i=e._zod.run({value:t,issues:[]},r),i instanceof Promise)throw new Oe;return i.issues.length===0}const vi=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length===0},bi=e=>{const t=Kt(e),n=(r,o,i,s)=>{const a=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,a,mt(n,s))};return n},_i=e=>{const t=Kt(e),n=(r,o,i,s)=>t(r,o,i,mt(n,s));return n},yi=e=>{const t=qt(e),n=async(r,o,i,s)=>{const a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,a,mt(n,s))};return n},wi=e=>{const t=qt(e),n=async(r,o,i,s)=>await t(r,o,i,mt(n,s));return n},ki=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Gt(e)(t,n,o)},$i=e=>(t,n,r)=>Gt(e)(t,n,r),Si=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ht(e)(t,n,o)},zi=e=>async(t,n,r)=>Ht(e)(t,n,r),xi=/^[cC][0-9a-z]{6,}$/,Oi=/^[0-9a-z]+$/,Ci=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Zi=/^[0-9a-vA-V]{20}$/,Ii=/^[A-Za-z0-9]{27}$/,Pi=/^[a-zA-Z0-9_-]{21}$/;function Ei(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Ti=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ai=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,kn=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ni=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ji="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Di(){return new RegExp(ji,"u")}const Ri=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Mi=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Fi=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Li=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ui=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ji=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Bi=/^https?$/,Vi=/^\+[1-9]\d{6,14}$/,gr="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Wi(e){return new RegExp(`^${e}$`)}const Ki=Wi(gr);function Tt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function qi(e){return new RegExp(`^${Tt(e)}$`)}function Gi(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Tt({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Tt({precision:e.precision})}`:n;return new RegExp(`^${gr}T(?:${r})$`)}const Hi=/^[\s\S]{0,}$/,Yi=/^-?\d+(?:\.\d+)?$/,Xi=/^(?:true|false)$/i,Qi=/^[^A-Z]*$/,es=/^[^a-z]*$/,q=f("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Yt=e=>{const t=e.value;return!To(t)&&t.length!==void 0},at={number:"number",bigint:"bigint",object:"date"},vr=f("$ZodCheckLessThan",(e,t)=>{q.init(e,t);const n=at[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:at[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),br=f("$ZodCheckGreaterThan",(e,t)=>{q.init(e,t);const n=at[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:at[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ts=f("$ZodCheckMultipleOf",(e,t)=>{q.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Ao(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ns=f("$ZodCheckNumberFormat",(e,t)=>{q.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=ur[t.format];e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),rs=f("$ZodCheckMaxLength",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=Yt),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>t.maximum?Vt(o):i)<=t.maximum)return;const a=Wt(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),os=f("$ZodCheckMinLength",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=Yt),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?Vt(o):i)>=t.minimum)return;const a=Wt(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),is=f("$ZodCheckLengthEquals",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=Yt),e._zod.check=r=>{const o=r.value,i=o.length,s=typeof o=="string"&&i>=t.length&&i<=t.length*2?Vt(o):i;if(s===t.length)return;const a=Wt(o),c=s>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),gt=f("$ZodCheckStringFormat",(e,t)=>{var n,r;q.init(e,t),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ss=f("$ZodCheckRegex",(e,t)=>{gt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),as=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Qi),gt.init(e,t)}),cs=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=es),gt.init(e,t)}),us=f("$ZodCheckIncludes",(e,t)=>{q.init(e,t);const n=Pe(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),ls=f("$ZodCheckStartsWith",(e,t)=>{q.init(e,t);const n=new RegExp(`^${Pe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),ds=f("$ZodCheckEndsWith",(e,t)=>{q.init(e,t);const n=new RegExp(`.*${Pe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),fs=f("$ZodCheckOverwrite",(e,t)=>{q.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class ps{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
2
|
+
`).filter(s=>s),o=Math.min(...r.map(s=>s.length-s.trimStart().length)),i=r.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
3
|
+
${n.join(`
|
|
4
|
+
`)}
|
|
5
|
+
};`)(...Object.values(this.closed))}}const hs={major:4,minor:6,patch:7},D=f("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=hs;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const i of o)for(const s of i._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(a,c,l)=>{if(a.memo)return a;let d=de(a),p;for(const h of c){if(h._zod.def.when){if(qo(a)||!h._zod.def.when(a))continue}else if(d)continue;const g=a.issues.length,v=h._zod.check(a);if(v instanceof Promise&&l?.async===!1)throw new Oe;if(p||v instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await v,a.issues.length!==g&&(Et(a.issues,g,e),d||(d=de(a,g)))});else{if(a.issues.length===g)continue;Et(a.issues,g,e),d||(d=de(a,g))}}return p?p.then(()=>a):a},s=(a,c,l)=>{if(de(a))return a.aborted=!0,a;const d=i(c,o,l);if(d instanceof Promise){if(l.async===!1)throw new Oe;return d.then(p=>e._zod.parse(p,l))}return e._zod.parse(d,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const d=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(p=>s(p,a,c)):s(d,a,c)}const l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Oe;return l.then(d=>i(d,o,c))}return i(l,o,c)}}},{get"~standard"(){return fr(this,"~standard",yr(this))},set"~standard"(e){be(this,"~standard",e)}}),_r=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Ae(n,t,ke()))}:{value:e.value};async function ms(e,t){const n={async:!0};return _r(await e._zod.run({value:t,issues:[]},n),n)}function yr(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return _r(r,n)}catch{}return ms(e,t)},vendor:"zod",version:1}}const Xt=f("$ZodString",(e,t)=>{D.init(e,t),e._zod.pattern=t.pattern??Hi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),A=f("$ZodStringFormat",(e,t)=>{gt.init(e,t),Xt.init(e,t)}),gs=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ai),A.init(e,t)}),vs=f("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=kn(r))}else t.pattern??(t.pattern=kn());A.init(e,t)}),bs=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ni),A.init(e,t)}),wr=1,ct=2;function kr(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function _s(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?kr(e)||ct:ys(e,t)}function ys(e,t){if(!t.normalize&&t.protocol?.source===Bi.source&&!/^https?:\/\//i.test(e))return wr;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??ct}return new URL(e)}catch{return ct}}const ws=/[\t\n\r]/g;function $n(e){return e.replace(ws,"")}function ks(e,t){return t.lastIndex=0,t.test(e.hostname)}function $s(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const Ss=f("$ZodURL",(e,t)=>{A.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=_s(r,t);if(o===wr){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===ct){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(o===!0){n.value=$n(r);return}t.hostname&&!ks(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!$s(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:$n(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),zs=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Di()),A.init(e,t)}),xs=f("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Pi:Ei(t.length)),A.init(e,t)}),Os=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xi),A.init(e,t)}),Cs=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Oi),A.init(e,t)}),Zs=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ci),A.init(e,t)}),Is=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Zi),A.init(e,t)}),Ps=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ii),A.init(e,t)}),Es=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Gi(t)),A.init(e,t)}),Ts=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ki),A.init(e,t)}),As=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=qi(t)),A.init(e,t)}),Ns=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ti),A.init(e,t)}),js=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ri),A.init(e,t)}),Ds=/^[0-9a-fA-F:.]+$/;function $r(e){return Ds.test(e)?kr(`http://[${e}]`):!1}const Rs=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Mi),A.init(e,t),e._zod.check=n=>{$r(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Ms=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Fi),A.init(e,t)});function Fs(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`!==r||o<0||o>128?!1:$r(n)}const Ls=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Li),A.init(e,t),e._zod.check=n=>{Fs(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Sr(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const zr=/^[0-9a-zA-Z+/]*={0,2}$/,Us=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=zr),A.init(e,t),e._zod.check=n=>{Sr(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Qt=/^[A-Za-z0-9_-]*$/;function Js(e){if(!Qt.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Sr(n)}const Bs=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Qt),A.init(e,t),e._zod.check=n=>{Js(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Vs=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Vi),A.init(e,t)});function Ws(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Ks=f("$ZodJWT",(e,t)=>{A.init(e,t),e._zod.check=n=>{Ws(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),xr=f("$ZodNumber",(e,t)=>{D.init(e,t),e._zod.pattern=Yi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),qs=f("$ZodNumberFormat",(e,t)=>{ns.init(e,t),xr.init(e,t)}),Gs=f("$ZodBoolean",(e,t)=>{D.init(e,t),e._zod.pattern=Xi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Hs=f("$ZodUnknown",(e,t)=>{D.init(e,t),e._zod.parse=n=>n}),Ys=f("$ZodNever",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Xs(e,t){const n=bn(e._zod.def.checks);if(!n.length)return;const r=Math.min(...n.map(i=>i[0])),o=e._zod.parse;e._zod.parse=(i,s)=>{const a=t(i.value);if(a>r&&!s?.skipChecks&&s?.direction!=="backward"){for(const[c,l]of bn(e._zod.def.checks))if(a>c&&l._zod.def.when(i)){const d=i.issues.length;return l._zod.check(i),i.issues[d].continue=!1,Et(i.issues,d,e),i}}return o(i,s)}}const Qs=e=>Array.isArray(e)?e.length:-1;function Sn(e,t,n){e.issues.length&&t.issues.push(...dr(n,e.issues)),t.value[n]=e.value}const ea=f("$ZodArray",(e,t)=>{D.init(e,t);const n=ue.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){const l=i[c],d=t.element._zod.run({value:l,issues:[]},o);if(d instanceof Promise)s.push(d.then(p=>Sn(p,r,c)));else if(Sn(d,r,c),a&&d.issues.length!==0&&de(d))break}return s.length?Promise.all(s).then(()=>r):r},Xs(e,Qs)});function ut(e,t,n,r,o,i){const s=n in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...dr(n,e.issues))}if(!s&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(s||o==="defaulted"&&!a)&&(t.value[n]=void 0):t.value[n]=e.value}}const ta=[];function Or(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ta,o=r.length?[...t,...r]:t;for(const s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);const i=Fo(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Cr(e,t,n,r,o,i,s){const a=[],c=o.keySet,l=o.catchall._zod,d=l.def.type,p=l.optin,h=l.optout;let g=0;for(const v in t){if(s&&n.issues.length!==g){if(de(n,g))break;g=n.issues.length}if(c.has(v))continue;if(v==="__proto__"){d==="never"&&a.push(v);continue}if(d==="never"){a.push(v);continue}const m=l.run({value:t[v],issues:[]},r);m instanceof Promise?e.push(m.then(b=>ut(b,n,v,t,p,h))):ut(m,n,v,t,p,h)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const na=f("$ZodObject",(e,t)=>{D.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const l=()=>{const d={...r};return Object.defineProperty(t,"shape",{value:d}),l.raw=d,d};l.raw=r,Object.defineProperty(t,"shape",{get:l})}const o=pt(()=>Or(t));C(e,"propValues",l=>{const d=l.def.shape,p={};for(const h in d){const g=d[h]._zod;if(g.values){Object.prototype.hasOwnProperty.call(p,h)||ye(p,h,new Set);for(const v of g.values)p[h].add(v);g.optin!==void 0&&p[h].add(void 0)}}return p});const i=Be,s=t.catchall;let a;const c=ue.memoizer;c?.attach(e),e._zod.parse=(l,d)=>{a??(a=o.value);const p=l.value;if(!i(p))return l.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),l;l.value=c?c.alloc(e,l,{},d):{};const h=[],g=a.shape,v=d?.abortEarly;let m=l.issues.length;for(const b of a.allKeys){if(v&&l.issues.length!==m){if(de(l,m))break;m=l.issues.length}if(b==="__proto__")continue;const O=g[b],T=O._zod.optin,pe=O._zod.optout,he=O._zod.run({value:p[b],issues:[]},d);he instanceof Promise?h.push(he.then(N=>ut(N,l,b,p,T,pe))):ut(he,l,b,p,T,pe)}return s?Cr(h,p,l,d,o.value,e,v===!0):h.length?Promise.all(h).then(()=>l):l}}),ra=f("$ZodObjectJIT",(e,t)=>{na.init(e,t);const n=e._zod.parse,r=pt(()=>Or(t)),o=ue.memoizer,i=g=>{const v=r.value,m=v.symbolKeys,b=new ps(["payload","ctx"],{shape:g,inst:e,memo:o,syms:m}),O=N=>`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`,T=(N,S)=>`
|
|
6
|
+
let ${N}_ab = false;
|
|
7
|
+
for (let i = 0; i < ${N}.issues.length; i++) {
|
|
8
|
+
const iss = ${N}.issues[i];
|
|
9
|
+
iss.path = iss.path ? [${S}, ...iss.path] : [${S}];
|
|
10
|
+
payload.issues.push(iss);
|
|
11
|
+
if (iss.continue !== true) ${N}_ab = true;
|
|
12
|
+
}
|
|
13
|
+
if (${N}_ab && ctx && ctx.abortEarly) {
|
|
14
|
+
payload.value = newResult;
|
|
15
|
+
return payload;
|
|
16
|
+
}`;b.write("const input = payload.value;");const pe=Object.create(null);let he=0;for(const N of v.allKeys)pe[N]=`key_${he++}`;b.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const N of v.allKeys){if(N==="__proto__")continue;const S=pe[N],W=typeof N=="symbol"?`syms[${m.indexOf(N)}]`:jo(N),te=`${W} in input`,le=g[N],oe=le?._zod?.optin,qe=oe!==void 0,Ge=le?._zod?.optout==="optional";if(b.write(`const ${S} = ${O(W)};`),qe&&Ge){const vt=oe==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;b.write(`
|
|
17
|
+
const ${S}_present = ${te};
|
|
18
|
+
if (!${S}.issues.length || ${S}_present) {
|
|
19
|
+
if (${S}.issues.length) {${T(S,W)}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (${vt}) {
|
|
23
|
+
newResult[${W}] = ${S}.value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
`)}else qe?(b.write(`
|
|
28
|
+
if (${S}.issues.length) {${T(S,W)}
|
|
29
|
+
}
|
|
30
|
+
`),oe==="defaulted"?b.write(`newResult[${W}] = ${S}.value;`):b.write(`
|
|
31
|
+
if (${S}.value !== undefined || ${te}) {
|
|
32
|
+
newResult[${W}] = ${S}.value;
|
|
33
|
+
}
|
|
34
|
+
`)):b.write(`
|
|
35
|
+
const ${S}_present = ${te};
|
|
36
|
+
if (${S}.issues.length) {${T(S,W)}
|
|
37
|
+
}
|
|
38
|
+
if (!${S}_present && !${S}.issues.length) {
|
|
39
|
+
payload.issues.push({
|
|
40
|
+
code: "invalid_type",
|
|
41
|
+
expected: "nonoptional",
|
|
42
|
+
input: undefined,
|
|
43
|
+
path: [${W}]
|
|
44
|
+
});
|
|
45
|
+
if (ctx && ctx.abortEarly) {
|
|
46
|
+
payload.value = newResult;
|
|
47
|
+
return payload;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (${S}_present) {
|
|
52
|
+
newResult[${W}] = ${S}.value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
`)}return b.write("payload.value = newResult;"),b.write("return payload;"),b.compile()};let s;const a=Be,c=!ue.jitless,d=c&&Ro.value,p=t.catchall;let h;e._zod.parse=(g,v)=>{h??(h=r.value);const m=g.value;return a(m)?c&&d&&v?.async===!1&&v.jitless!==!0?(s||(s=i(t.shape)),g=s(g,v),p?Cr([],m,g,v,h,e,v?.abortEarly===!0):g):n(g,v):(g.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),g)}});function zn(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!de(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>Ae(s,r,ke())))}),t)}const Zr=f("$ZodUnion",(e,t)=>{D.init(e,t),C(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),C(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),C(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),C(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Jt(i.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>zn(a,r,e,o)):zn(s,r,e,o)}});function oa(e){const t=new Map;for(const n of e.options){const r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(const o of r)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,n)}return t}const ia=f("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Zr.init(e,t);const n=e._zod.parse;C(e,"propValues",o=>{const i={};let s=0;for(const a of o.def.options){const c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&s++;for(const[l,d]of Object.entries(c)){Object.prototype.hasOwnProperty.call(i,l)||ye(i,l,new Set);for(const p of d)i[l].add(p)}}return!o.def.unionFallback&&s>1&&i[o.def.discriminator]?.delete(void 0),i}),t.options.forEach((o,i)=>{const s=Bt(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});const r=pt(()=>oa(t));e._zod.parse=(o,i)=>{const s=o.value;if(!Be(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=s?.[t.discriminator],c=r.value.get(a);return c&&(a!==void 0||i.direction!=="backward")?c._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(l=>r.value.get(l)!==null),input:s,path:[t.discriminator],inst:e}),o)}}),sa=f("$ZodIntersection",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,l])=>xn(n,c,l)):xn(n,i,s)}});function At(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ve(e)&&Ve(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const i of r){if(i==="__proto__")continue;const s=At(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=At(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function xn(e,t,n){const r=new Map;let o;const i=new Map,s=(l,d)=>{let p;if(l.code==="unrecognized_keys"&&!l.path?.length)o??(o=l),p=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){const h=String(l.path[0]);i.has(h)||i.set(h,l),p=[h]}else return!1;for(const h of p)r.has(h)||r.set(h,{}),r.get(h)[d]=!0;return!0};for(const l of t.issues)s(l,"l")||e.issues.push(l);for(const l of n.issues)s(l,"r")||e.issues.push(l);const a=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){const l=o?a.filter(d=>o.keys.includes(d)):[];l.length&&e.issues.push({...o,keys:l});for(const d of a)!l.includes(d)&&i.has(d)&&e.issues.push(i.get(d))}const c=At(t.value,n.value);if(!c.valid){if(de(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const aa=f("$ZodEnum",(e,t)=>{D.init(e,t);const n=It(t.entries),r=new Set(n);e._zod.values=r,C(e,"pattern",o=>{const i=It(o.def.entries).filter(s=>Mo.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>Pe(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),ca=f("$ZodLiteral",(e,t)=>{D.init(e,t);const n=new Set(t.values);e._zod.values=n,C(e,"pattern",r=>{const o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?Pe(i):i?Pe(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),ua=f("$ZodTransform",(e,t)=>{D.init(e,t),e._zod.optin="optional",ue.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new hr(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(n.value=s,n));if(o instanceof Promise)throw new Oe;return n.value=o,n}});function On(e,t){return e.value=t.issues.length?void 0:t.value,e}const Ir=f("$ZodOptional",(e,t)=>{D.init(e,t),C(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",C(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),C(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Jt(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>On(n,i)):On(n,o)}return t.innerType._zod.run(n,r)}}),la=f("$ZodExactOptional",(e,t)=>{Ir.init(e,t),C(e,"values",n=>n.def.innerType._zod.values),C(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),da=f("$ZodNullable",(e,t)=>{D.init(e,t),C(e,"optin",n=>n.def.innerType._zod.optin),C(e,"optout",n=>n.def.innerType._zod.optout),C(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Jt(r.source)}|null)$`):void 0}),C(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),fa=f("$ZodDefault",(e,t)=>{D.init(e,t),e._zod.optin="defaulted",C(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Cn(i,t)):Cn(o,t)}});function Cn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const pa=f("$ZodPrefault",(e,t)=>{D.init(e,t),e._zod.optin="defaulted",C(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),ha=f("$ZodNonOptional",(e,t)=>{D.init(e,t),C(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Zn(i,e)):Zn(o,e)}});function Zn(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 In(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Ae(o,r,ke()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const ma=f("$ZodCatch",(e,t)=>{D.init(e,t),C(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),C(e,"optout",n=>n.def.innerType._zod.optout),C(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>In(n,i,t,r)):In(n,o,t,r)}}),ga=f("$ZodPipe",(e,t)=>{D.init(e,t),C(e,"values",n=>n.def.in._zod.values),C(e,"optin",n=>n.def.in._zod.optin),C(e,"optout",n=>n.def.out._zod.optout),C(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>et(s,t.in,r)):et(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>et(i,t.out,r)):et(o,t.out,r)}});function et(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const va=f("$ZodReadonly",(e,t)=>{D.init(e,t),C(e,"propValues",n=>n.def.innerType._zod.propValues),C(e,"values",n=>n.def.innerType._zod.values),C(e,"optin",n=>n.def.innerType?._zod?.optin),C(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Pn):Pn(o)}});function Pn(e){return e.memo||(e.value=Object.freeze(e.value)),e}const ba=f("$ZodCustom",(e,t)=>{q.init(e,t),D.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>En(i,n,r,e));En(o,n,r,e)}});function En(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(We(o))}}class _a extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Nt="~memo",Tn=[];function Pr(e){return e!==null&&typeof e=="object"}function wt(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Er=new WeakMap,Me=0,it=1,Le=2;function st(e,t,n){const r=Er.get(e);if(r!==void 0)return r?Le:Me;if(t.has(e))return Le;t.add(e);let o=Me;const i=d=>{if(o!==Le&&d?._zod){const p=st(d,t);p>o&&(o=p)}},s=(d,p)=>{let h=Me;for(const g of Reflect.ownKeys(d)){const v=Object.getOwnPropertyDescriptor(d,g);if(!v.enumerable)continue;const m=v.get?it:v.value?._zod?st(v.value,t):Me;m>h&&(h=m)}return h},a=d=>{d>o&&(o=d)},c=e._zod.def;switch(c.type){case"object":{const d=Bt(c);a(d?s(d):it),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(const d of c.items)i(d);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(const d of c.options)i(d);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{const d=c._cachedInner??void 0;a(d?st(d,t):it);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(const d in c){const p=Object.getOwnPropertyDescriptor(c,d);if(!p||p.get)continue;const h=p.value;if(!(!h||typeof h!="object")){if(h._zod)i(h);else if(Array.isArray(h))for(const g of h)i(g)}}}return t.delete(e),ya(e,o)}function ya(e,t){return t!==it&&Er.set(e,t===Le),t}function wa(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let tt;const nt=[],ka={alloc(e,t,n){const r=tt;if(!r)return n;tt=void 0;const o={value:n,issues:null};return r.set(t.value,o),nt.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&Sa(i,o.value))throw new _a;return n(o,i)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(c,l)=>{if(n===void 0){const O=st(e,new Set);if(O===Me)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,l);O===Le||r?n=!0:r=!0}const d=c.value;if(!Pr(d))return s(c,l);let p=l[Nt];p||(p={buckets:new WeakMap,backEdges:void 0},l[Nt]=p);let h;o===l?h=i:(h=wa(p,e),o=l,i=h);const g=h.get(d);if(g)return c.value=g.value,g.issues?g.issues.length&&c.issues.push(...wt(g.issues)):(c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(g.value)),c;tt=h;const v=nt.length,m=s(c,l);tt=void 0;const b=nt.length>v?nt.pop():void 0;return m instanceof Promise?m.then(O=>(b&&(b.issues=O.issues.length?wt(O.issues):Tn),O)):(b&&(b.issues=m.issues.length?wt(m.issues):Tn),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function $a(){return ka}function Sa(e,t){const n=e[Nt]?.backEdges;return n!==void 0&&Pr(t)&&n.has(t)}const za=()=>{const 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(i){return e[i]??null}const 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 o(i,s){return i==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[i]??i}return i=>{switch(i.code){case"invalid_type":{const s=o(i.expected),a=Ho(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${cr(i.values[0])}`:`Invalid option: expected one of ${gn(i.values,"|")}`;case"too_big":{const s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{const s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);return a?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{const s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${n[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${gn(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(a=>`'${a}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function xa(){return{localeError:za()}}var An;class Oa{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Ca(){return new Oa}(An=globalThis).__zod_globalRegistry??(An.__zod_globalRegistry=Ca());const Fe=globalThis.__zod_globalRegistry;function Tr(e){return e.checks&&(e.checks=[...e.checks]),e}function Za(e,t){return new e(Tr({type:"string",...y(t)}))}function Ia(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function Pa(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Ea(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Ta(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Aa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function Na(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function ja(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function Da(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Ra(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function Ma(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function Fa(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function La(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function Ua(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function Ja(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function Ba(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function Va(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function Wa(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function Ka(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function qa(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function Ga(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function Ha(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function Ya(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function Xa(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function Qa(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function ec(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function tc(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function nc(e,t){return new e(Tr({type:"number",checks:[],...y(t)}))}function rc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...y(t)})}function oc(e,t){return new e({type:"boolean",...y(t)})}function ic(e){return new e({type:"unknown"})}function sc(e,t){return new e({type:"never",...y(t)})}function Nn(e,t){return new vr({check:"less_than",...y(t),value:e,inclusive:!1})}function kt(e,t){return new vr({check:"less_than",...y(t),value:e,inclusive:!0})}function jn(e,t){return new br({check:"greater_than",...y(t),value:e,inclusive:!1})}function $t(e,t){return new br({check:"greater_than",...y(t),value:e,inclusive:!0})}function Dn(e,t){return new ts({check:"multiple_of",...y(t),value:e})}function Ar(e,t){return new rs({check:"max_length",...y(t),maximum:e})}function lt(e,t){return new os({check:"min_length",...y(t),minimum:e})}function Nr(e,t){return new is({check:"length_equals",...y(t),length:e})}function ac(e,t){return new ss({check:"string_format",format:"regex",...y(t),pattern:e})}function cc(e){return new as({check:"string_format",format:"lowercase",...y(e)})}function uc(e){return new cs({check:"string_format",format:"uppercase",...y(e)})}function lc(e,t){return new us({check:"string_format",format:"includes",...y(t),includes:e})}function dc(e,t){return new ls({check:"string_format",format:"starts_with",...y(t),prefix:e})}function fc(e,t){return new ds({check:"string_format",format:"ends_with",...y(t),suffix:e})}function Ne(e){return new fs({check:"overwrite",tx:e})}function pc(e){return Ne(t=>t.normalize(e))}function hc(){return Ne(e=>e.trim())}function mc(){return Ne(e=>e.toLowerCase())}function gc(){return Ne(e=>e.toUpperCase())}function vc(){return Ne(e=>Do(e))}function bc(e,t,n){return new e({type:"array",element:t,...y(n)})}function _c(e,t,n){return new e({type:"custom",check:"custom",fn:t,...y(n)})}function yc(e,t){const n=wc(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(We(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(We(i))}},e(r.value,r)),t);return n}function wc(e,t){const n=new q({check:"custom",...y(t)});return n._zod.check=e,n}function Ue(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&ye(e,r,n[r]);return e}function jr(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??Fe,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 _e(e,t,n,r,o){const i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(n,i),!0}function J(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,d);else{const h=s.schema,g=t.processors[o.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);g(e,t,h,d)}const p=e._zod.parent;p&&(s.ref||(s.ref=p),J(p,t,d),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Ue(s.schema,c),t.io==="input"&&V(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Rn(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Dr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=r.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(s[0])?.id,h=e.external.uri??(v=>v);if(p)return{ref:h(p)};const g=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=g,{defId:g,ref:`${h("__shared")}#/${a}/${Rn(g)}`}}const c="#",l=`${c}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:c};const d=s[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+Rn(d)}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:l}=o(s);a.def={...a.schema},l&&(a.defId=l);const d=a.schema;for(const p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
56
|
+
|
|
57
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}a.count>1&&e.reused==="ref"&&i(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Rr(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;Rr(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const i=r.type;for(const s of Array.isArray(i)?i:[i]){if(typeof s!="string")return;n.includes(s)||n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Mr=new Set(["type","properties","required","additionalProperties"]),Mn=["oneOf","anyOf"];function Fn(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function jt(e){const t=[];for(const i of e){if(typeof i!="object"||i.type!=="object")return null;for(const s in i)if(!Mr.has(s))return null;t.push(i)}const n={},r=new Set;for(const i of t){for(const s in i.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;const a=[];for(const l of t){const d=l.properties?.[s]??Fn(l);d!=null&&(a.some(p=>JSON.stringify(p)===JSON.stringify(d))||a.push(d))}const c=a.length===1?a[0]:jt(a)??{allOf:a};ye(n,s,c)}for(const s of i.required??[])r.add(s)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(i=>i.additionalProperties===!1))o.additionalProperties=!1;else{const i=[];for(const s of t){const a=Fn(s);a&&!i.some(c=>JSON.stringify(c)===JSON.stringify(a))&&i.push(a)}i.length===1?o.additionalProperties=i[0]:i.length>1&&(o.additionalProperties={allOf:i})}return o}function kc(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of Mr)if(o in e)return;const n=t.filter(o=>Mn.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=jt(t);else{const o=n[0],i=Mn.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;const s=t.filter(c=>c!==o),a=o[i].map(c=>jt([...s,c]));if(a.some(c=>!c))return;r={[i]:a}}r&&(delete e.allOf,Ue(e,r))}function Fr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const c=e.seen.get(a);if(c.ref===null)return;const l=c.def??c.schema,d={...l},p=c.ref;if(c.ref=null,p){r(p);const g=e.seen.get(p),v=g.schema;if(v.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(v)):Ue(l,v),Ue(l,d),a._zod.parent===p)for(const b in l)b==="$ref"||b==="allOf"||b in d||delete l[b];if(v.$ref&&g.def)for(const b in l)b==="$ref"||b==="allOf"||b in g.def&&JSON.stringify(l[b])===JSON.stringify(g.def[b])&&delete l[b]}const h=a._zod.parent;if(h&&h!==p){r(h);const g=e.seen.get(h);if(g?.schema.$ref&&(l.$ref=g.schema.$ref,g.def))for(const v in l)v==="$ref"||v==="allOf"||v in g.def&&JSON.stringify(l[v])===JSON.stringify(g.def[v])&&delete l[v]}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(const a of e.seen.entries())Rr(a[1].def??a[1].schema);for(const a of e.deferred)a();if(e.intersections.length){const a=new Map;for(const c of e.seen.values())for(const l of[c.schema,c.def]){const d=l?.allOf;if(!Array.isArray(d))continue;const p=a.get(d);p?p.push(l):a.set(d,[l])}for(const c of e.intersections)for(const l of a.get(c)??[])kc(l)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Ue(o,n.defId?n.schema:n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,ye(s,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:dt(t,"input",e.processors),output:dt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function V(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return V(r.element,n);if(r.type==="set")return V(r.valueType,n);if(r.type==="lazy")return V(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 V(r.innerType,n);if(r.type==="intersection")return V(r.left,n)||V(r.right,n);if(r.type==="record"||r.type==="map")return V(r.keyType,n)||V(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:V(r.in,n)||V(r.out,n);if(r.type==="object"){for(const o in r.shape)if(V(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(V(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(V(o,n))return!0;return!!(r.rest&&V(r.rest,n))}return!1}const $c=(e,t={})=>n=>{const r=jr({...n,processors:t});return J(e,r),Dr(r,e),Fr(r,e)},dt=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=jr({...o??{},target:i,io:t,processors:n});return J(e,s),Dr(s,e),Fr(s,e)},Ee=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Te=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Ln=(e,t)=>{Ee(e,"minimum",t),Te(e,"maximum",t)},Lr=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Ur=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Jr=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},Br=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Un=(e,t)=>Ee(e,"minimum",t.minimum),Jn=(e,t)=>Te(e,"maximum",t.maximum),Bn=e=>(t,n)=>{Br(t,n.format);const[r,o]=e[n.format];Ee(t,"minimum",r),Te(t,"maximum",o)},Sc={greater_than:(e,t)=>Ee(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Te(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Lr(e,t.value),number_format:Bn(ur),bigint_format:Bn(Lo),min_length:Un,max_length:Jn,length_equals:(e,t)=>Ln(e,t.length),min_size:Un,max_size:Jn,size_equals:(e,t)=>Ln(e,t.size),string_format:(e,t)=>{Br(e,t.format),t.pattern&&Ur(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)=>Jr(e,t.mime)};function ce(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const i of r)Sc[i._zod.def.check]?.(t,i._zod.def);const o=e._zod.bag;o.minimum!==void 0&&Ee(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&Ee(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Te(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Te(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Lr(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Jr(t,o.mime);for(const i of o.patterns??[])Ur(t,i);return t}const zc={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},xc=new Map([[zr,Ui],[Qt,Ji]]),Oc=e=>xc.get(e)??e,Cc=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:l,laxFormat:d}=ce(e);if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=zc[a]??a,o.format===""&&delete o.format,(a==="time"||d)&&delete o.format),l&&(o.contentEncoding=l),c&&c.size>0){const p=[...c].map(Oc);p.length===1?o.pattern=p[0].source:p.length>1&&(o.allOf=[...p.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Zc=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:d}=ce(e);o.type=d?"integer":"number";const p=typeof l=="number"&&l>=(i??Number.NEGATIVE_INFINITY),h=typeof c=="number"&&c<=(s??Number.POSITIVE_INFINITY),g=t.target==="draft-04"||t.target==="openapi-3.0";if(p?g?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof i=="number"&&(o.minimum=i),h?g?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof s=="number"&&(o.maximum=s),a){const v=new Set;for(const O of a)Number.isFinite(O)&&O!==0?v.add(Math.abs(O)):_e(e,t,o,r,`A multipleOf divisor of ${O} cannot be represented in JSON Schema`);const[m,...b]=v;m!==void 0&&(o.multipleOf=m),b.length&&(o.allOf=[...o.allOf??[],...b.map(O=>({multipleOf:O}))])}},Ic=(e,t,n,r)=>{n.type="boolean"},Pc=(e,t,n,r)=>{n.not={}},Ec=(e,t,n,r)=>{},Tc=(e,t,n,r)=>{const o=e._zod.def,i=It(o.entries);if(i.length===0){n.not={};return}i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},Ac=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const i=[];for(const s of o.values)if(s===void 0){if(_e(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(_e(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){const s=i[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),i.every(s=>typeof s=="boolean")&&(n.type="boolean"),i.every(s=>s===null)&&(n.type="null"),n.enum=i},Nc=(e,t,n,r)=>{_e(e,t,n,r,"Custom types cannot be represented in JSON Schema")},jc=(e,t,n,r)=>{_e(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Dc=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=ce(e);typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=J(i.element,t,{...r,path:[...r.path,"items"]})};function Dt(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Dt(t.out):t.type==="catch"?Dt(t.innerType):e._zod.optin}const Rc=(e,t,n,r)=>{const o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&_e(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const l in s)ye(o.properties,l,J(s[l],t,{...r,path:[...r.path,"properties",l]}));const c=[];for(const l of Object.keys(s)){const d=i.shape[l];(t.io==="input"?Dt(d)===void 0:d._zod.optout===void 0)&&c.push(l)}c.length>0&&(o.required=c),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=J(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Mc=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>J(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},Fc=(e,t,n,r)=>{const o=e._zod.def,i=J(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=J(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)},Lc=(e,t,n,r)=>{const o=e._zod.def,i=J(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Uc=(e,t,n,r)=>{const o=e._zod.def;J(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},en=Symbol();function Vr(e,t,n,r,o){let i=!1;const s=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(i=!0,null));return i?(_e(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),en):JSON.parse(s)}const Jc=(e,t,n,r)=>{const o=e._zod.def;J(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const s=Vr(o.defaultValue,e,t,n,r);s!==en&&(n.default=s)},Bc=(e,t,n,r)=>{const o=e._zod.def;J(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const s=Vr(o.defaultValue,e,t,n,r);s!==en&&(n._prefault=s)},Vc=(e,t,n,r)=>{const o=e._zod.def;J(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{_e(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},Wc=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;J(s,t,r);const a=t.seen.get(e);a.ref=s},Kc=(e,t,n,r)=>{const o=e._zod.def;J(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Wr=(e,t,n,r)=>{const o=e._zod.def;J(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Vn=new WeakSet([Object.prototype,Error.prototype]);function rt(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const qc=(e,t)=>{ui.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Vn.has(n)||(Vn.add(n),rt(n,"format",r=>o=>fi(r,o)),rt(n,"flatten",r=>o=>di(r,o)),rt(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,Pt,2)}),rt(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,Pt,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},ee=f("ZodError",qc,void 0,{Parent:Error}),Gc=Kt(ee),Hc=qt(ee),Yc=Gt(ee),Xc=Ht(ee),Qc=bi(ee),eu=_i(ee),tu=yi(ee),nu=wi(ee),ru=ki(ee),ou=$i(ee),iu=Si(ee),su=zi(ee);function au(){ue.localeError||ke(xa())}function tn(){ue.memoizer||ke({memoizer:$a()})}const R=f("ZodType",(e,t)=>(au(),D.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(Y(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return we(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ol(e,t))},superRefine(e,t){return this.check(il(e,t))},overwrite(e){return this.check(Ne(e))},optional(){return qn(this)},exactOptional(){return Vu(this)},nullable(){return Gn(this)},nullish(){return qn(Gn(this))},nonoptional(e){return Yu(this,e)},array(){return re(this)},or(e){return Ru([this,e])},and(e){return Lu(this,e)},transform(e){return Hn(this,Bu(e))},default(e){return qu(this,e)},prefault(e){return Hu(this,e)},catch(e){return Qu(this,e)},pipe(e){return Hn(this,e)},readonly(){return nl(this)},describe(e){const t=this.clone();return Fe.add(t,{description:e}),t},meta(...e){if(e.length===0)return Fe.get(this);const t=this.clone();return Fe.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 fr(this,"~standard",{...yr(this),jsonSchema:{input:dt(this,"input"),output:dt(this,"output")}})},set"~standard"(e){be(this,"~standard",e)},parse:function e(t,n){return Gc(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Hc(this,t,n,{callee:e})},safeParse(e,t){return Yc(this,e,t)},async safeParseAsync(e,t){return Xc(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){be(this,"spa",e)},validate(e,t){return mi(this,e,t)},validateAsync(e,t){return vi(this,e,t)},encode:function e(t,n){return Qc(this,t,n,{callee:e})},decode:function e(t,n){return eu(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await tu(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await nu(this,t,n,{callee:e})},safeEncode(e,t){return ru(this,e,t)},safeDecode(e,t){return ou(this,e,t)},async safeEncodeAsync(e,t){return iu(this,e,t)},async safeDecodeAsync(e,t){return su(this,e,t)},toJSONSchema(e){return $c(this,{})(e)},get description(){return Fe.get(this)?.description},get _def(){return this._zod.def}}),Kr=f("_ZodString",(e,t)=>{Xt.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cc(e,n,r)},pr({format:e=>ce(e).format??null,minLength:e=>ce(e).minimum??null,maxLength:e=>ce(e).maximum??null},{regex(...e){return this.check(ac(...e))},includes(...e){return this.check(lc(...e))},startsWith(...e){return this.check(dc(...e))},endsWith(...e){return this.check(fc(...e))},min(...e){return this.check(lt(...e))},max(...e){return this.check(Ar(...e))},length(...e){return this.check(Nr(...e))},nonempty(...e){return this.check(lt(1,...e))},lowercase(e){return this.check(cc(e))},uppercase(e){return this.check(uc(e))},trim(){return this.check(hc())},normalize(...e){return this.check(pc(...e))},toLowerCase(){return this.check(mc())},toUpperCase(){return this.check(gc())},slugify(){return this.check(vc())}})),cu=f("ZodString",(e,t)=>{Xt.init(e,t),Kr.init(e,t)},{email(e){return this.check(Ia(pu,e))},url(e){return this.check(ja(mu,e))},jwt(e){return this.check(Ya(Iu,e))},emoji(e){return this.check(Da(gu,e))},guid(e){return this.check(Pa(hu,e))},uuid(e){return this.check(Ea(ot,e))},uuidv4(e){return this.check(Ta(ot,e))},uuidv6(e){return this.check(Aa(ot,e))},uuidv7(e){return this.check(Na(ot,e))},nanoid(e){return this.check(Ra(vu,e))},cuid(e){return this.check(Ma(bu,e))},cuid2(e){return this.check(Fa(_u,e))},ulid(e){return this.check(La(yu,e))},base64(e){return this.check(qa(Ou,e))},base64url(e){return this.check(Ga(Cu,e))},xid(e){return this.check(Ua(wu,e))},ksuid(e){return this.check(Ja(ku,e))},ipv4(e){return this.check(Ba($u,e))},ipv6(e){return this.check(Va(Su,e))},cidrv4(e){return this.check(Wa(zu,e))},cidrv6(e){return this.check(Ka(xu,e))},e164(e){return this.check(Ha(Zu,e))},datetime(e){return this.check(Xa(uu,e))},date(e){return this.check(Qa(lu,e))},time(e){return this.check(ec(du,e))},duration(e){return this.check(tc(fu,e))}});function x(e){return Za(cu,e)}const j=f("ZodStringFormat",(e,t)=>{A.init(e,t),Kr.init(e,t)}),uu=f("ZodISODateTime",(e,t)=>{Es.init(e,t),j.init(e,t)}),lu=f("ZodISODate",(e,t)=>{Ts.init(e,t),j.init(e,t)}),du=f("ZodISOTime",(e,t)=>{As.init(e,t),j.init(e,t)}),fu=f("ZodISODuration",(e,t)=>{Ns.init(e,t),j.init(e,t)}),pu=f("ZodEmail",(e,t)=>{bs.init(e,t),j.init(e,t)}),hu=f("ZodGUID",(e,t)=>{gs.init(e,t),j.init(e,t)}),ot=f("ZodUUID",(e,t)=>{vs.init(e,t),j.init(e,t)}),mu=f("ZodURL",(e,t)=>{Ss.init(e,t),j.init(e,t)}),gu=f("ZodEmoji",(e,t)=>{zs.init(e,t),j.init(e,t)}),vu=f("ZodNanoID",(e,t)=>{xs.init(e,t),j.init(e,t)}),bu=f("ZodCUID",(e,t)=>{Os.init(e,t),j.init(e,t)}),_u=f("ZodCUID2",(e,t)=>{Cs.init(e,t),j.init(e,t)}),yu=f("ZodULID",(e,t)=>{Zs.init(e,t),j.init(e,t)}),wu=f("ZodXID",(e,t)=>{Is.init(e,t),j.init(e,t)}),ku=f("ZodKSUID",(e,t)=>{Ps.init(e,t),j.init(e,t)}),$u=f("ZodIPv4",(e,t)=>{js.init(e,t),j.init(e,t)}),Su=f("ZodIPv6",(e,t)=>{Rs.init(e,t),j.init(e,t)}),zu=f("ZodCIDRv4",(e,t)=>{Ms.init(e,t),j.init(e,t)}),xu=f("ZodCIDRv6",(e,t)=>{Ls.init(e,t),j.init(e,t)}),Ou=f("ZodBase64",(e,t)=>{Us.init(e,t),j.init(e,t)}),Cu=f("ZodBase64URL",(e,t)=>{Bs.init(e,t),j.init(e,t)}),Zu=f("ZodE164",(e,t)=>{Vs.init(e,t),j.init(e,t)}),Iu=f("ZodJWT",(e,t)=>{Ks.init(e,t),j.init(e,t)}),qr=f("ZodNumber",(e,t)=>{xr.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zc(e,n,r,o),e.isFinite=!0},pr({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=ce(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=ce(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=ce(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>ce(e).format??null},{gt(e,t){return this.check(jn(e,t))},gte(e,t){return this.check($t(e,t))},min(e,t){return this.check($t(e,t))},lt(e,t){return this.check(Nn(e,t))},lte(e,t){return this.check(kt(e,t))},max(e,t){return this.check(kt(e,t))},int(e){return this.check(Wn(e))},safe(e){return this.check(Wn(e))},positive(e){return this.check(jn(0,e))},nonnegative(e){return this.check($t(0,e))},negative(e){return this.check(Nn(0,e))},nonpositive(e){return this.check(kt(0,e))},multipleOf(e,t){return this.check(Dn(e,t))},step(e,t){return this.check(Dn(e,t))},finite(){return this}}));function se(e){return nc(qr,e)}const Pu=f("ZodNumberFormat",(e,t)=>{qs.init(e,t),qr.init(e,t)});function Wn(e){return rc(Pu,e)}const Eu=f("ZodBoolean",(e,t)=>{Gs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ic(e,n,r)});function ae(e){return oc(Eu,e)}const Tu=f("ZodUnknown",(e,t)=>{Hs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ec()});function Kn(){return ic(Tu)}const Au=f("ZodNever",(e,t)=>{Ys.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Pc(e,n,r)});function Nu(e){return sc(Au,e)}const ju=f("ZodArray",(e,t)=>{tn(),ea.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dc(e,n,r,o),e.element=t.element},{min(e,t){return this.check(lt(e,t))},nonempty(e){return this.check(lt(1,e))},max(e,t){return this.check(Ar(e,t))},length(e,t){return this.check(Nr(e,t))},unwrap(){return this.element}});function re(e,t){return bc(ju,e,t)}const Du=f("ZodObject",(e,t)=>{tn(),ra.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rc(e,n,r,o),ti(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Ke(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Y(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Y(this._zod.def,{catchall:Kn()}))},loose(){return this.clone(Y(this._zod.def,{catchall:Kn()}))},strict(){return this.clone(Y(this._zod.def,{catchall:Nu()}))},strip(){return this.clone(Y(this._zod.def,{catchall:void 0}))},extend(e){return Bo(this,e)},safeExtend(e){return Vo(this,e)},merge(e){return Wo(this,e)},pick(e){return Uo(this,e)},omit(e){return Jo(this,e)},partial(...e){return vn(Hr,this,e[0])},exactPartial(...e){return vn(Yr,this,e[0],"exactPartial")},required(...e){return Ko(Xr,this,e[0])}});function Z(e,t){const n={type:"object",shape:e??{},...y(t)};return new Du(n)}const Gr=f("ZodUnion",(e,t)=>{Zr.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Mc(e,n,r,o),e.options=t.options});function Ru(e,t){return new Gr({type:"union",options:e,...y(t)})}const Mu=f("ZodDiscriminatedUnion",(e,t)=>{Gr.init(e,t),ia.init(e,t)});function St(e,t,n){return new Mu({type:"union",options:t,discriminator:e,...y(n)})}const Fu=f("ZodIntersection",(e,t)=>{sa.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fc(e,n,r,o)});function Lu(e,t){return new Fu({type:"intersection",left:e,right:t})}const Rt=f("ZodEnum",(e,t)=>{aa.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Tc(e,r,o),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Rt({...t,checks:[],...y(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Rt({...t,checks:[],...y(o),entries:i})}});function Ke(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Rt({type:"enum",entries:n,...y(t)})}const Uu=f("ZodLiteral",(e,t)=>{ca.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ac(e,n,r,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ze(e,t){return new Uu({type:"literal",values:Array.isArray(e)?e:[e],...y(t)})}const Ju=f("ZodTransform",(e,t)=>{tn(),ua.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jc(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new hr(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(We(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=e),n.issues.push(We(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function Bu(e){return new Ju({type:"transform",transform:e})}const Hr=f("ZodOptional",(e,t)=>{Ir.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wr(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function qn(e){return new Hr({type:"optional",innerType:e})}const Yr=f("ZodExactOptional",(e,t)=>{la.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wr(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Vu(e){return new Yr({type:"optional",innerType:e})}const Wu=f("ZodNullable",(e,t)=>{da.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Gn(e){return new Wu({type:"nullable",innerType:e})}const Ku=f("ZodDefault",(e,t)=>{fa.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qu(e,t){return new Ku({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ar(t)}})}const Gu=f("ZodPrefault",(e,t)=>{pa.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Hu(e,t){return new Gu({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ar(t)}})}const Xr=f("ZodNonOptional",(e,t)=>{ha.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Uc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Yu(e,t){return new Xr({type:"nonoptional",innerType:e,...y(t)})}const Xu=f("ZodCatch",(e,t)=>{ma.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Qu(e,t){return new Xu({type:"catch",innerType:e,catchValue:typeof t=="function"?t:ri(t)})}const el=f("ZodPipe",(e,t)=>{ga.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wc(e,n,r,o),e.in=t.in,e.out=t.out});function Hn(e,t){return new el({type:"pipe",in:e,out:t})}const tl=f("ZodReadonly",(e,t)=>{va.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Kc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function nl(e){return new tl({type:"readonly",innerType:e})}const rl=f("ZodCustom",(e,t)=>{ba.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Nc(e,n,r,o)});function ol(e,t={}){return _c(rl,e,t)}function il(e,t){return yc(e,t)}const ft=Z({repo:x(),root:x(),branch:x(),defaultBranch:x(),configured:ae()}),Mt=Z({number:se().int(),title:x(),labels:re(x()),state:x(),updatedAt:x(),summary:x(),criteria:re(x())}),Ie=Z({directory:x(),branch:x().nullable(),issueNumber:se().int().nullable(),registered:ae(),exists:ae(),dirty:ae(),sessions:se().int()}),sl=Z({state:Ke(["fresh","cached","stale","error"]),fetchedAt:se().nullable(),message:x().nullable(),code:Ke(["auth","rate_limit","network","gh","unknown"]).nullable()}),al=Z({app:x().nullable(),supported:ae(),message:x()}),cl=Z({issue:x(),skill:x()}),ul=Z({available:re(x()),installed:re(x())}),Yn=Z({repo:ft.nullable(),repos:re(ft),issues:re(Mt),worktrees:re(Ie),labels:re(x()),sync:sl,prompts:cl,version:al,skills:ul,error:x().nullable()}),De=Z({code:Ke(["repo","issue","gh","git","worktree","session","unknown"]),message:x()}),Qr=Po.Rpc.define({id:"opencode-skills-deck.control-tower",methods:{boardSnapshot:{input:Z({repo:x().optional(),force:ae().optional()}).optional(),output:Yn},issueDetail:{input:Z({repo:x().optional(),number:se().int()}),output:Z({issue:Mt.nullable(),worktree:Ie.nullable(),error:De.nullable()})},repoList:{input:Z({repo:x().optional()}).optional(),output:Z({repos:re(ft),active:ft.nullable()})},repoSwitch:{input:Z({repo:x()}),output:Yn},dispatchPrepare:{input:Z({repo:x().optional(),number:se().int()}),output:St("ok",[Z({ok:Ze(!0),issue:Mt,worktree:Ie,base:x(),created:ae(),draft:x()}),Z({ok:Ze(!1),error:De})])},sessionStart:{input:Z({repo:x().optional(),number:se().int()}),output:St("ok",[Z({ok:Ze(!0),sessionID:x(),directory:x(),worktree:Ie,draft:x()}),Z({ok:Ze(!1),error:De})])},worktreeCleanup:{input:Z({repo:x().optional(),number:se().int().optional(),directory:x().optional(),inUse:ae().optional()}),output:Z({removed:ae(),reason:Ke(["removed","missing","dirty","in_use","outside","unknown"]),message:x().nullable()})},worktreeOrphans:{input:Z({repo:x().optional()}).optional(),output:Z({orphans:re(Ie),error:De.nullable()})},sessionResume:{input:Z({repo:x().optional(),number:se().int()}),output:St("ok",[Z({ok:Ze(!0),worktree:Ie.nullable(),draft:x(),existing:ae()}),Z({ok:Ze(!1),error:De})])}},events:{boardChanged:{schema:Z({repo:x(),fetchedAt:se()})}}}),Ft=[];function ll(e,t){!e||!t||Ft.push({sessionID:e,text:t})}function dl(e){if(!e)return;const t=Ft.findIndex(n=>n.sessionID===e);if(t!==-1)return Ft.splice(t,1)[0]}const fl=3,pl=500;function hl(e,t=fl,n=pl){const r=e.replace(/\r\n?/g,`
|
|
58
|
+
`).trimEnd();if(!r)return"";const o=r.split(`
|
|
59
|
+
`).slice(-t).join(`
|
|
60
|
+
`);return o.length>n?o.slice(o.length-n):o}function Re(e){if(e?.role!=="assistant")return null;const t=hl(e.text);return t||null}function ml(e){const t=e.session;if(!t)return null;const n=e.lastMessage?.error??null;return e.tabOpen?e.permissions>0?{state:"input_wait",reason:"permission",preview:Re(e.lastMessage),error:n}:e.forms>0?{state:"input_wait",reason:"question",preview:Re(e.lastMessage),error:n}:n||t.outcome==="failed"?{state:"error",reason:null,preview:Re(e.lastMessage),error:n??"セッションが失敗しました"}:t.status==="running"?{state:"working",reason:null,preview:Re(e.lastMessage),error:null}:{state:"input_wait",reason:"idle",preview:Re(e.lastMessage),error:null}:{state:"closed",reason:null,preview:null,error:null}}function gl(e){switch(e){case"permission":return"Needs permission";case"question":return"Answer a question";default:return"Waiting"}}function vl(e,t){switch(e){case"working":return"Working";case"input_wait":return gl(t);case"closed":return"Closed";case"error":return"Error"}}function bl(e){const t=e?.error?.message;return typeof t=="string"&&t?t:null}function _l(e){return Array.isArray(e.content)?e.content.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text??"").join(`
|
|
61
|
+
`):typeof e.text=="string"?e.text:""}function yl(e){if(!e)return null;const t=e.type==="assistant"?"assistant":e.type==="user"?"user":"other";return{role:t,text:_l(e),error:t==="assistant"?bl(e):null}}function wl(e){for(let t=e.length-1;t>=0;t-=1)if(e[t]?.type==="assistant")return e[t]}function kl(e){const t=e?.time?.updated;return typeof t=="number"?new Date(t).toISOString():new Date(0).toISOString()}function $l(e){const{data:t,id:n}=e,r=t.session.status(n),o=t.session.get(n),i=t.session.permission.list(n)?.length??0,s=t.session.form.list(n)?.length??0,a=t.session.message.list(n)??[];return{session:{id:n,status:r,outcome:o?.outcome},tabOpen:e.tabOpen,permissions:i,forms:s,lastMessage:yl(wl(a))}}function Sl(e){const t=new Map;for(const i of e.open)t.set(i.id,i.directory);const n=new Set,r=[],o=(i,s,a)=>{if(n.has(s))return;n.add(s);const c=ml($l({data:e.data,id:s,tabOpen:a}));r.push({id:s,directory:t.get(s)??i?.location?.directory??null,tabOpen:a,title:i?.title??s,updatedAt:kl(i),alive:c})};for(const i of e.data.session.list())o(i,i.id,t.has(i.id));for(const i of e.open)o(e.data.session.get(i.id),i.id,!0);return r}async function zl(e,t){await Promise.allSettled(t.flatMap(n=>[e.session.permission.sync?.(n)??Promise.resolve(),e.session.form.sync?.(n)??Promise.resolve(),e.session.message.sync?.(n)??Promise.resolve()]))}function xl(e){return e instanceof Error?e.message:typeof e=="string"?e:e&&typeof e=="object"&&"message"in e?String(e.message):"The Control Tower server did not respond."}class Ol{constructor(t){this.options=t,this.now=t.now??Date.now,this.retryDelayMs=t.retryDelayMs??250,this.snapshotTtlMs=t.snapshotTtlMs??5e3}options;cache=new Map;inflight=new Map;now;retryDelayMs;snapshotTtlMs;callOptions(){const t=this.options.getDirectory?.();return t?{location:{directory:t}}:void 0}async call(t){let n;for(let r=0;r<2;r+=1)try{return{ok:!0,value:await t(this.options.getRpc(),this.callOptions())}}catch(o){n=o,r===0&&this.retryDelayMs>0&&await new Promise(i=>setTimeout(i,this.retryDelayMs))}return{ok:!1,error:xl(n)}}invalidate(t){t?this.cache.delete(t):this.cache.clear()}cached(t){const n=this.cache.get(t);if(n&&!(this.now()-n.at>this.snapshotTtlMs*12))return n.value}snapshot(t={},n={}){const r=t.repo??"",o=t.force??n.force??!1,i=r||"*";if(!o){const a=this.cache.get(i);if(a&&this.now()-a.at<this.snapshotTtlMs)return Promise.resolve({ok:!0,value:a.value});const c=this.inflight.get(i);if(c)return c}const s=this.call((a,c)=>a.boardSnapshot({...t,force:o},c)).then(a=>{if(a.ok)return this.cache.set(i,{at:this.now(),value:a.value}),a;const c=this.cached(i);return c?{...a,fallback:c}:a});return this.inflight.set(i,s),s.finally(()=>{this.inflight.get(i)===s&&this.inflight.delete(i)}),s}repositoryList(t={}){return this.call((n,r)=>n.repoList(t,r))}repoSwitch(t){return this.call((n,r)=>n.repoSwitch({repo:t},r))}detail(t){return this.call(async(n,r)=>{const o=await n.issueDetail(t,r);if(o.error)throw new Error(o.error.message);return o.issue})}prepare(t){return this.call(async(n,r)=>{const o=await n.dispatchPrepare(t,r);if(!o.ok)throw new Error(o.error.message);return{draft:o.draft,created:o.created,worktree:o.worktree}})}start(t){return this.call(async(n,r)=>{const o=await n.sessionStart(t,r);if(!o.ok)throw new Error(o.error.message);return{sessionID:o.sessionID,directory:o.directory,draft:o.draft,worktree:o.worktree}})}cleanup(t){return this.call(async(n,r)=>{const o=await n.worktreeCleanup(t,r);if(!o.removed&&o.reason!=="missing")throw new Error(o.message??"The worktree could not be cleaned.");return o})}orphans(t={}){return this.call(async(n,r)=>{const o=await n.worktreeOrphans(t,r);if(o.error)throw new Error(o.error.message);return o.orphans})}resume(t){return this.call(async(n,r)=>{const o=await n.sessionResume(t,r);if(!o.ok)throw new Error(o.error.message);return{worktree:o.worktree,draft:o.draft,existing:o.existing}})}}function ve(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function Lt(e,t){return!e||!t?!1:ve(e)===ve(t)}function Cl(e,t){return ve(e).startsWith(`${ve(t)}/.worktrees/`)}function Zl(e,t){return e.replace(/\{number\}/g,String(t))}function Il(e,t){return e.replace(/\{skill\}/g,t)}function Pl(e){const t=e.title.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/g,"");return t?`issue/${e.number}-${t}`:`issue/${e.number}`}function eo(e,t){if(!e)return"ready";if(!t)return e.tabOpen?"wait":"closed";switch(t.state){case"working":return"working";case"input_wait":return"wait";case"closed":return"closed";case"error":return"error"}}function to(e,t){if(e==="ready")return"Ready";if(!t)return e==="closed"?"Closed":"Waiting";const n=t.state;return vl(n,t.reason)}function El(e,t,n,r){const o=n?.alive??null,i=eo(n,o);return{key:`issue-${e.number}`,kind:"issue",number:e.number,title:e.title,labels:e.labels,state:i,reason:o?.reason??null,stateLabel:to(i,o),worktree:t,session:n,preview:o?.preview??null,error:o?.error??null,branch:t?.branch??Pl(e),draft:Zl(r,e.number),summary:e.summary,criteria:e.criteria,updatedAt:e.updatedAt}}function Tl(e,t){const n=eo(e,e.alive);return{key:`session-${e.id}`,kind:"dialogue",title:e.title||e.id,labels:[],state:n,reason:e.alive?.reason??null,stateLabel:to(n,e.alive),worktree:null,session:e,preview:e.alive?.preview??null,error:e.alive?.error??null,branch:"",draft:Il(t,""),summary:"",criteria:[],updatedAt:e.updatedAt}}function Al(e,t){const n=t.trim().toLocaleLowerCase();return n?e.title.toLocaleLowerCase().includes(n)||`#${e.number}`.includes(n)||String(e.number).includes(n)||e.labels.some(r=>r.toLocaleLowerCase().includes(n))||e.summary.toLocaleLowerCase().includes(n):!0}function Nl(e,t){switch(t){case"active":return e.state==="working"||e.state==="wait"||e.state==="error";case"ready":return e.state==="ready";case"closed":return e.state==="closed";default:return!0}}function jl(e){const{snapshot:t}=e,n=e.sessions,r=t.repo?.root??"",o=new Set,i=t.issues.map(m=>{const b=t.worktrees.find(T=>T.issueNumber===m.number)??null,O=b?n.find(T=>Lt(T.directory,b.directory))??null:null;return O&&o.add(O),El(m,b,O,t.prompts.issue)});i.sort((m,b)=>(m.number??0)-(b.number??0));const s=new Set(t.worktrees.map(m=>ve(m.directory))),a=n.filter(m=>m.tabOpen).filter(m=>m.id!==e.currentSessionID).filter(m=>!o.has(m)).filter(m=>{if(!m.directory||s.has(ve(m.directory)))return!1;if(!r)return!0;const b=ve(m.directory),O=ve(r);return b===O?!0:b.startsWith(`${O}/`)&&!Cl(b,r)}).map(m=>Tl(m,t.prompts.skill)).sort((m,b)=>b.updatedAt.localeCompare(m.updatedAt)),c={working:i.filter(m=>m.state==="working").length,waiting:i.filter(m=>m.state==="wait").length,ready:i.filter(m=>m.state==="ready").length,closed:i.filter(m=>m.state==="closed").length,error:i.filter(m=>m.state==="error").length,tabs:i.filter(m=>m.session?.tabOpen).length,worktrees:t.worktrees.length},l=e.filter??"all",d=e.query??"",p=e.label?.toLocaleLowerCase()??null,h=i.filter(m=>Nl(m,l)).filter(m=>e.label==null||e.label===""||m.labels.some(b=>b.toLocaleLowerCase()===p)).filter(m=>{const b=t.issues.find(O=>O.number===m.number);return b?Al(b,d):!0});let g=null;t.repo?t.sync.state==="error"&&t.issues.length===0?g="fetch":t.issues.length===0?g="no-issues":h.length===0&&a.length===0&&(g="no-match"):g="repo";const v=[];return t.sync.state==="stale"&&v.push(t.sync.code==="auth"?"Cached issues. gh is not authenticated — run gh auth login.":"Cached issues. Sync failed; showing the last list."),t.sync.state==="cached"&&v.push("Showing the cached issue list."),t.sync.state==="error"&&v.push(t.sync.code==="auth"?"Could not load issues. gh is not authenticated — run gh auth login.":t.sync.message??"Could not load issues."),t.version.supported||v.push(`OpenCode ${t.version.app??"unknown"} is outside the supported range (>=2.3.0 <3.0.0).`),t.error&&v.push(t.error),{rows:h,dialogues:a,stats:c,empty:g,banners:v}}function Xn(e){return e.repo!==null&&(e.sync.state==="fresh"||e.sync.state==="cached")}function Qn(){return{mode:"list",query:"",filter:"all",label:null}}function Dl(e,t){return{...e,mode:"detail",number:t}}function zt(e){return{...e,mode:"list"}}function xt(e,t){return{...e,query:t}}function Rl(e,t){return{...e,filter:t}}function Ml(e,t){if(t.loading)return{id:"loading",title:"Syncing issues…",body:"Reading the GitHub issue list for this repo.",actions:[]};switch(e.empty){case"repo":return{id:"repo",title:"No repo yet",body:"Open a git repository, or add repos to config.json, then sync.",actions:["sync","repos"]};case"fetch":return{id:"fetch",title:"Couldn't load issues",body:e.banners.find(n=>n.includes("gh auth"))??"gh could not read the issue list. Check the network and gh auth, then retry.",detail:e.banners[0],actions:["retry","gh-login","repos"]};case"no-issues":return{id:"no-issues",title:"No issues",body:"This repo has no open issues matching the configured label. Create one or switch repos.",actions:["sync","repos"]};case"no-match":{const n=t.query.trim()!=="";return{id:"no-match",title:"No matches",body:n?`Nothing matches "${t.query.trim()}". Try another search or clear the filter.`:"Nothing matches this filter. Reset it or switch repos.",actions:[n?"clear":"repos"]}}default:return null}}const[Fl,Ut]=$.createSignal(null),Ot="grill-with-docs",Ct="wayfinder";function er(e){return Fl()?.includes(e)??!1}var Ll=u.template("<p class=ct-summary>No orphan worktrees."),Ul=u.template("<span class=dirty>uncommitted"),Jl=u.template("<div class=ct-orphan><code>"),Bl=u.template("<p class=ct-summary>No repos resolved."),Vl=u.template("<div class=ct-toolbar><div class=ct-seg>"),Wl=u.template("<div class=ct-list-sec>Dialogues"),Kl=u.template("<div class=ct-list-sec>Issues"),tr=u.template("<div class=ct-statecard><h4></h4><p>"),ql=u.template("<div class=ct-list role=listbox>"),Gl=u.template("<div class=ct-body>"),Hl=u.template("<div class=ct><header class=ct-head><div class=ct-headline><span class=ct-title>Control Tower</span></div><div class=ct-head-actions></div></header><div class=ct-stats><span>Working <b></b></span><span>Waiting <b></b></span><span>Ready <b></b></span><span>Closed <b></b></span><span>Tabs <b></b></span><span>WT <b></b></span><span class=ct-sync>"),Zt=u.template("<div class=ct-banner>"),Yl=u.template("<div class=ct-statecard><h4>Issue not found</h4><p>The issue left the list. Go back and sync again.</p><div class=actions>"),Xl=u.template("<div class=ct-section><div class=ct-sec-label>Output preview</div><pre class=ct-preview>"),Ql=u.template("<div class=ct-d-note style=color:var(--ct-warn)>Uncommitted changes: Clean is refused until they are committed or discarded."),ed=u.template("<ul class=ct-crit>"),td=u.template("<div class=ct-detail><div class=ct-push-head><span class=t>#<!> </span></div><div class=ct-detail-scroll><div><div class=ct-d-num>#</div><div class=ct-d-title></div><div class=ct-d-meta><span></span></div></div><div class=ct-section><div class=ct-sec-label>Summary</div><p class=ct-summary></p></div><div><div class=ct-dispatch-h><span class=ct-sec-label>Dispatch</span><span></span></div><div class=ct-kv><span>Branch</span><code></code></div><div class=ct-kv><span>Worktree</span><code></code></div><div class=ct-draft><span class=ct-sec-label>Draft</span><code></code></div><div class=ct-d-note>Sending is manual. The model stays idle until you send.</div><div class=ct-d-note>New session uses the worktree. This session inserts here — no worktree.</div></div><div class=ct-section><div class=ct-sec-label>Acceptance criteria</div></div></div><div class=ct-actions>"),nr=u.template("<span class=ct-chip>"),nd=u.template("<p class=ct-summary>No acceptance criteria in this issue."),rd=u.template("<li><span class=box></span><span>"),od=u.template("<button type=button>"),id=u.template("<div class=actions>"),sd=u.template("<div class=ct-statecard><h4></h4><p></p><div class=actions>"),ad=u.template("<div class=mono>"),cd=u.template("<button type=button class=ct-row><span></span><span class=ct-row-main><span class=ct-row-top><span class=ct-row-title></span></span><span class=ct-row-sub><span></span><span class=ct-tab-mark>▸ draft tab</span></span></span><span class=ct-go>›"),ud=u.template("<span class=ct-tab-mark>▸ tab"),ld=u.template("<span class=ct-tab-mark>"),dd=u.template("<button type=button role=option><span></span><span class=ct-row-main><span class=ct-row-top><span class=ct-num>#</span><span class=ct-row-title></span></span><span class=ct-row-sub><span></span></span></span><span class=ct-go>›");function fd(e){const t=e.ctx,[n,r]=$.createSignal(null),[o,i]=$.createSignal(Qn()),[s,a]=$.createSignal(void 0),[c,l]=$.createSignal(!0),[d,p]=$.createSignal(null),[h,g]=$.createSignal(null),[v,m]=$.createSignal(0),b=new Ol({getRpc:()=>t.client.rpc(Qr),getDirectory:()=>e.panel.session.directory});let O=!1;async function T(_=!1){if(O)return;O=!0,l(n()===null);const w=await b.snapshot({repo:s(),force:_});w.ok?(r(w.value),p(null),Ut(w.value.skills.available),!s()&&w.value.repo&&a(w.value.repo.repo)):(p(w.error),w.fallback&&r(w.fallback)),l(!1),O=!1}const pe=$.createMemo(()=>t.servers.get(e.panel.session.server.id)?.data),he=$.createMemo(()=>t.sessions.list().filter(_=>_.server.id===e.panel.session.server.id)),N=$.createMemo(()=>{v();const _=pe();return _?Sl({data:_,open:he().map(w=>({id:w.id,directory:w.location?.directory})),currentSessionID:e.panel.session.id}):[]}),S=$.createMemo(()=>{const _=n();return _?jl({snapshot:_,sessions:N(),filter:o().filter,query:o().query,label:o().label,currentSessionID:e.panel.session.id}):null}),W=$.createMemo(()=>{const _=o();return _.mode!=="detail"?null:S()?.rows.find(w=>w.number===_.number)??null}),te=$.createMemo(()=>{const _=S();return _?Ml(_,{loading:c(),query:o().query}):null});function le(_,w,I="default"){t.toast.show({title:_,description:w,variant:I})}function oe(_){le("Control Tower",_,"error")}function qe(){const _=n()?.repos??[];return _.length===0?[{label:"No repos",disabled:!0,onSelect:()=>{}}]:_.map(w=>({label:`${w.repo} ${w.branch}`,onSelect:()=>{Ge(w.repo)}}))}async function Ge(_){i(Qn()),a(_),l(n()===null);const w=await b.repoSwitch(_);w.ok?(r(w.value),p(null),Ut(w.value.skills.available)):p(w.error),l(!1)}async function vt(_){const w=n();if(!w||_.number===void 0||!Xn(w))return;const I=e.panel.session.server.id,M=N().find(ne=>_.worktree!==null&&ne.directory!==null&&Lt(ne.directory,_.worktree.directory));if(M){t.tabs.open({server:I,id:M.id},{focus:!0}),le("Control Tower","Focused the tab already open for this issue.","success");return}g(`start-${_.number}`);const X=await b.start({repo:s(),number:_.number});if(g(null),!X.ok){oe(X.error);return}try{t.tabs.open({server:I,id:X.value.sessionID},{focus:!0}),ll(X.value.sessionID,X.value.draft),le("Session opened in the worktree","Review the prompt and send it when you are ready.","success")}catch(ne){oe(ne instanceof Error?ne.message:String(ne));return}T(!0)}function no(_){e.panel.screen.composer.insert(_.draft),le("Inserted into the composer","No worktree was created. Review and send it yourself.","success")}async function ro(_){if(_.number===void 0)return;if(_.session?.tabOpen){oe("Close the tab for this worktree before cleaning it.");return}g(`clean-${_.number}`);const w=await b.cleanup({repo:s(),number:_.number,inUse:_.session?.tabOpen??!1});if(g(null),!w.ok){oe(w.error);return}le("Worktree cleaned",_.worktree?.directory??void 0,"success"),T(!0)}function nn(_){return N().some(w=>w.tabOpen&&Lt(w.directory,_.directory))}async function oo(){const _=await b.orphans({repo:s()});if(!_.ok){oe(_.error);return}const w=_.value;t.dialogs.open(I=>u.createComponent(t.ui.Dialog,{title:"Orphan worktrees",description:"Worktrees under .worktrees/ whose issue is no longer open. Dirty worktrees cannot be cleaned.",get footer(){return u.createComponent(t.ui.Button,{get onClick(){return I.close},variant:"neutral",children:"Close"})},get children(){return u.createComponent($.Show,{get when(){return w.length>0},get fallback(){return Ll()},get children(){return u.createComponent($.For,{each:w,children:M=>(()=>{var X=Jl(),ne=X.firstChild;return u.insert(ne,()=>M.directory),u.insert(X,u.createComponent($.Show,{get when(){return M.dirty},get children(){return Ul()}}),null),u.insert(X,u.createComponent(t.ui.Button,{size:"small",variant:"danger",get disabled(){return M.dirty||nn(M)},onClick:()=>{io(M,I)},children:"Clean"}),null),X})()})}})}}))}async function io(_,w){const I=await b.cleanup({repo:s(),directory:_.directory,inUse:nn(_)});if(!I.ok){oe(I.error);return}le("Worktree cleaned",_.directory,"success"),w.close(),T(!0)}function rn(){const _=n()?.repos??[];t.dialogs.open(w=>u.createComponent(t.ui.Dialog,{title:"Switch repo",description:"One repo at a time. The issue list and caches are kept per repo.",get footer(){return u.createComponent(t.ui.Button,{get onClick(){return w.close},variant:"neutral",children:"Close"})},get children(){return u.createComponent($.Show,{get when(){return _.length>0},get fallback(){return Bl()},get children(){return u.createComponent($.For,{each:_,children:I=>u.createComponent(t.ui.Button,{get variant(){return I.repo===s()?"contrast":"neutral"},onClick:()=>{w.close(),Ge(I.repo)},get children(){return[u.memo(()=>I.repo)," · ",u.memo(()=>I.branch)]}})})}})}}))}function so(_){switch(_){case"retry":case"sync":T(!0);return;case"repos":rn();return;case"clear":i(xt(o(),""));return;case"gh-login":t.dialogs.alert({title:"gh auth login",description:"Run gh auth login in a terminal, then press Sync now. Control Tower never handles credentials itself."});return}}function ao(_){const w=n()?.repo?.repo;!w||_.number===void 0||t.system.openExternal(`https://github.com/${w}/issues/${_.number}`)}return $.onMount(()=>{T(!0);const _=setInterval(()=>{m(M=>M+1);const I=pe();I&&zl(I,he().map(M=>M.id)),T(!1)},3e3),w=I=>{if(I.key!=="Escape"||t.dialogs.active())return;const M=o();M.mode==="detail"?(i(zt(M)),I.preventDefault()):M.query&&(i(xt(M,"")),I.preventDefault())};window.addEventListener("keydown",w),$.onCleanup(()=>{clearInterval(_),window.removeEventListener("keydown",w)})}),(()=>{var _=Hl(),w=_.firstChild,I=w.firstChild;I.firstChild;var M=I.nextSibling,X=w.nextSibling,ne=X.firstChild,co=ne.firstChild,uo=co.nextSibling,on=ne.nextSibling,lo=on.firstChild,fo=lo.nextSibling,sn=on.nextSibling,po=sn.firstChild,ho=po.nextSibling,an=sn.nextSibling,mo=an.firstChild,go=mo.nextSibling,cn=an.nextSibling,vo=cn.firstChild,bo=vo.nextSibling,un=cn.nextSibling,_o=un.firstChild,yo=_o.nextSibling,wo=un.nextSibling;return u.insert(I,u.createComponent(t.ui.Menu,{get label(){return n()?.repo?.repo??"No repo"},trigger:"button",icon:"branch",get items(){return qe()}}),null),u.insert(M,u.createComponent(t.ui.IconButton,{icon:"refresh",label:"Sync issues",variant:"ghost-muted",size:"small",get busy(){return c()},onClick:()=>{T(!0)}}),null),u.insert(M,u.createComponent(t.ui.Menu,{label:"More",icon:"outline-dots",items:[{label:"Sync now",onSelect:()=>{T(!0)}},{label:"Switch repo…",onSelect:rn},{label:"Orphan worktrees…",onSelect:()=>{oo()}}]}),null),u.insert(uo,()=>S()?.stats.working??0),u.insert(fo,()=>S()?.stats.waiting??0),u.insert(ho,()=>S()?.stats.ready??0),u.insert(go,()=>S()?.stats.closed??0),u.insert(bo,()=>S()?.stats.tabs??0),u.insert(yo,()=>S()?.stats.worktrees??0),u.insert(wo,(()=>{var k=u.memo(()=>n()?.sync.state==="fresh");return()=>k()?"Synced":u.memo(()=>n()?.sync.state==="cached")()?"Cached":u.memo(()=>n()?.sync.state==="stale")()?"Stale cache":n()?.sync.state==="error"?"Sync failed":"Syncing…"})()),u.insert(_,u.createComponent($.Show,{get when(){return d()},children:k=>(()=>{var E=Zt();return u.insert(E,k),E})()}),null),u.insert(_,u.createComponent($.For,{get each(){return S()?.banners??[]},children:k=>(()=>{var E=Zt();return u.insert(E,k),E})()}),null),u.insert(_,u.createComponent($.Show,{get when(){return o().mode==="list"},get fallback(){return u.createComponent($.Show,{get when(){return W()},get fallback(){return(()=>{var k=Yl(),E=k.firstChild,z=E.nextSibling,P=z.nextSibling;return u.insert(P,u.createComponent(t.ui.Button,{onClick:()=>i(zt(o())),variant:"neutral",children:"Back"})),k})()},children:k=>(()=>{var E=td(),z=E.firstChild,P=z.firstChild,F=P.firstChild,B=F.nextSibling;B.nextSibling;var G=z.nextSibling,me=G.firstChild,$e=me.firstChild;$e.firstChild;var ie=$e.nextSibling,K=ie.nextSibling,L=K.firstChild,H=me.nextSibling,He=H.firstChild,Ye=He.nextSibling,Se=H.nextSibling,ln=Se.firstChild,ko=ln.firstChild,dn=ko.nextSibling,fn=ln.nextSibling,$o=fn.firstChild,So=$o.nextSibling,pn=fn.nextSibling,zo=pn.firstChild,xo=zo.nextSibling,hn=pn.nextSibling,Oo=hn.firstChild,Co=Oo.nextSibling,Zo=hn.nextSibling;Zo.nextSibling;var mn=Se.nextSibling;mn.firstChild;var Xe=G.nextSibling;return u.insert(z,u.createComponent(t.ui.IconButton,{icon:"arrow-left",label:"Back to issues",variant:"ghost",size:"small",onClick:()=>i(zt(o()))}),P),u.insert(P,()=>k().number,B),u.insert(P,()=>k().title,null),u.insert($e,()=>k().number,null),u.insert(ie,()=>k().title),u.insert(L,()=>k().stateLabel),u.insert(K,u.createComponent($.For,{get each(){return k().labels},children:U=>(()=>{var Q=nr();return u.insert(Q,U),Q})()}),null),u.insert(G,u.createComponent($.Show,{get when(){return u.memo(()=>!!k().preview)()&&(k().state==="working"||k().state==="wait"||k().state==="error")},get children(){var U=Xl(),Q=U.firstChild,ze=Q.nextSibling;return u.insert(ze,()=>k().preview),U}}),H),u.insert(G,u.createComponent($.Show,{get when(){return k().error},children:U=>(()=>{var Q=Zt();return u.insert(Q,U),Q})()}),H),u.insert(Ye,()=>k().summary||"No summary in this issue."),u.insert(dn,(()=>{var U=u.memo(()=>!!k().session);return()=>U()?k().session?.tabOpen?"Draft tab open":"Tab closed":"Not dispatched"})()),u.insert(So,()=>k().branch),u.insert(xo,()=>k().worktree?.directory??`.worktrees/issue-${k().number}`),u.insert(Co,()=>k().draft),u.insert(Se,u.createComponent($.Show,{get when(){return k().worktree?.dirty},get children(){return Ql()}}),null),u.insert(mn,u.createComponent($.Show,{get when(){return k().criteria.length>0},get fallback(){return nd()},get children(){var U=ed();return u.insert(U,u.createComponent($.For,{get each(){return k().criteria},children:Q=>(()=>{var ze=rd(),Qe=ze.firstChild,Io=Qe.nextSibling;return u.insert(Io,Q),ze})()})),U}}),null),u.insert(Xe,u.createComponent(t.ui.Button,{class:"grow",variant:"contrast",size:"small",get busy(){return h()===`start-${k().number}`},get disabled(){return n()===null||!Xn(n())},onClick:()=>{vt(k())},get children(){return u.memo(()=>!!k().session)()?k().session?.tabOpen?"Open tab":"Reopen tab":"New session"}}),null),u.insert(Xe,u.createComponent(t.ui.Button,{class:"grow",variant:"neutral",size:"small",onClick:()=>no(k()),children:"This session"}),null),u.insert(Xe,u.createComponent(t.ui.IconButton,{icon:"trash",label:"Clean worktree",variant:"ghost-muted",size:"small",get disabled(){return!k().worktree?.exists||k().session?.tabOpen},onClick:()=>{ro(k())}}),null),u.insert(Xe,u.createComponent(t.ui.IconButton,{icon:"square-arrow-top-right",label:"Open on GitHub",variant:"ghost-muted",size:"small",onClick:()=>ao(k())}),null),u.effect(U=>{var Q=`ct-capsule ${k().state}`,ze=`ct-dispatch ${k().session?"open":""}`,Qe=`ct-draft-tag ${k().session?"open":""}`;return Q!==U.e&&u.className(L,U.e=Q),ze!==U.t&&u.className(Se,U.t=ze),Qe!==U.a&&u.className(dn,U.a=Qe),U},{e:void 0,t:void 0,a:void 0}),E})()})},get children(){return[(()=>{var k=Vl(),E=k.firstChild;return u.insert(E,u.createComponent($.For,{each:[["all","All"],["active","Active"],["ready","Ready"],["closed","Closed"]],children:([z,P])=>(()=>{var F=od();return F.$$click=()=>i(Rl(o(),z)),u.insert(F,P),u.effect(()=>u.className(F,o().filter===z?"on":"")),F})()})),u.insert(k,u.createComponent(t.ui.TextInput,{class:"ct-search",type:"search",label:"Search issues",placeholder:"Search issues…",get value(){return o().query},onInput:z=>i(xt(o(),z))}),null),k})(),(()=>{var k=Gl();return u.insert(k,u.createComponent($.Show,{get when(){return n()},get fallback(){return(()=>{var E=tr(),z=E.firstChild,P=z.nextSibling;return u.insert(z,()=>d()?"Couldn't reach the server":"Syncing issues…"),u.insert(P,()=>d()??"Reading the GitHub issue list for this repo."),u.insert(E,u.createComponent($.Show,{get when(){return d()},get children(){var F=id();return u.insert(F,u.createComponent(t.ui.Button,{variant:"contrast",size:"small",onClick:()=>{T(!0)},children:"Retry"})),F}}),null),E})()},get children(){return u.createComponent($.Show,{get when(){return!te()},get fallback(){return(()=>{var E=sd(),z=E.firstChild,P=z.nextSibling,F=P.nextSibling;return u.insert(z,()=>te()?.title),u.insert(P,()=>te()?.body),u.insert(E,u.createComponent($.Show,{get when(){return te()?.detail},children:B=>(()=>{var G=ad();return u.insert(G,B),G})()}),F),u.insert(F,u.createComponent($.For,{get each(){return te()?.actions??[]},children:B=>u.createComponent(t.ui.Button,{variant:B==="retry"||B==="sync"?"contrast":"neutral",size:"small",onClick:()=>so(B),children:B==="retry"?"Retry":B==="sync"?"Sync now":B==="repos"?"Switch repo":B==="clear"?"Clear search":"gh auth login"})})),E})()},get children(){var E=ql();return u.insert(E,u.createComponent($.Show,{get when(){return(S()?.dialogues.length??0)>0},get children(){return[Wl(),u.createComponent($.For,{get each(){return S()?.dialogues??[]},children:z=>(()=>{var P=cd(),F=P.firstChild,B=F.nextSibling,G=B.firstChild,me=G.firstChild,$e=G.nextSibling,ie=$e.firstChild;return P.$$click=()=>{const K=z.session;K&&t.tabs.open({server:e.panel.session.server.id,id:K.id},{focus:!0})},u.insert(me,()=>z.title),u.insert(ie,()=>z.stateLabel),u.effect(K=>{var L=`ct-dot ${z.state}`,H=`ct-st ${z.state}`;return L!==K.e&&u.className(F,K.e=L),H!==K.t&&u.className(ie,K.t=H),K},{e:void 0,t:void 0}),P})()})]}}),null),u.insert(E,u.createComponent($.Show,{get when(){return(S()?.rows.length??0)>0},get children(){return[u.createComponent($.Show,{get when(){return(S()?.dialogues.length??0)>0},get children(){return Kl()}}),u.createComponent($.For,{get each(){return S()?.rows??[]},children:z=>(()=>{var P=dd(),F=P.firstChild,B=F.nextSibling,G=B.firstChild,me=G.firstChild;me.firstChild;var $e=me.nextSibling,ie=G.nextSibling,K=ie.firstChild;return P.$$click=()=>{z.number!==void 0&&i(Dl(o(),z.number))},u.insert(me,()=>z.number,null),u.insert($e,()=>z.title),u.insert(K,()=>z.stateLabel),u.insert(ie,u.createComponent($.For,{get each(){return z.labels.slice(0,2)},children:L=>(()=>{var H=nr();return u.insert(H,L),H})()}),null),u.insert(ie,u.createComponent($.Show,{get when(){return z.session?.tabOpen},get children(){return ud()}}),null),u.insert(ie,u.createComponent($.Show,{get when(){return u.memo(()=>!!z.worktree)()&&!z.session},get children(){var L=ld();return u.insert(L,()=>z.worktree?.dirty?"WT dirty":"WT ready"),L}}),null),u.effect(L=>{var H=`ct-row ${z.number===W()?.number?"sel":""}`,He=z.number===W()?.number,Ye=`ct-dot ${z.state}`,Se=`ct-st ${z.state}`;return H!==L.e&&u.className(P,L.e=H),He!==L.t&&u.setAttribute(P,"aria-selected",L.t=He),Ye!==L.a&&u.className(F,L.a=Ye),Se!==L.o&&u.className(K,L.o=Se),L},{e:void 0,t:void 0,a:void 0,o:void 0}),P})()})]}}),null),u.insert(E,u.createComponent($.Show,{get when(){return u.memo(()=>(S()?.rows.length??0)===0)()&&(S()?.dialogues.length??0)===0},get children(){var z=tr(),P=z.firstChild,F=P.nextSibling;return u.insert(P,()=>te()?.title??"No issues"),u.insert(F,()=>te()?.body??"Nothing to show."),z}}),null),E}})}})),k})()]}}),null),_})()}u.delegateEvents(["click"]);const pd=".ct{--ct-bg: var(--bg, var(--v2-background-bg-base, #ffffff));--ct-bg-2: var(--bg-2, var(--v2-background-bg-layer-01, #f6f7f9));--ct-bg-3: var(--bg-3, var(--v2-background-bg-layer-02, #eceef2));--ct-line: var(--line, var(--v2-border-border-muted, #e3e6eb));--ct-line-2: var(--line-2, var(--v2-border-border-base, #cfd4dc));--ct-ink: var(--ink, var(--v2-text-text-base, #1b1e24));--ct-ink-2: var(--ink-2, var(--v2-text-text-muted, #565d6b));--ct-ink-3: var(--ink-3, var(--v2-text-text-faint, #8a909c));--ct-accent: var(--accent, var(--v2-text-text-accent, #3f63d8));--ct-accent-ink: var(--accent-ink, var(--v2-text-text-inverse, #ffffff));--ct-ok: var(--ok, var(--v2-state-fg-success, #1c7a3d));--ct-warn: var(--warn, var(--v2-state-fg-warning, #8a5a00));--ct-err: var(--err, var(--v2-state-fg-danger, #c0242c));--ct-info: var(--info, var(--v2-state-fg-info, #0b62c4));display:flex;flex:1;flex-direction:column;min-height:0;min-width:0;color:var(--ct-ink);background:var(--ct-bg);font-size:12px}.ct *{box-sizing:border-box}.ct-head{flex:0 0 auto;display:flex;align-items:center;gap:8px;padding:7px 8px 6px 10px;border-bottom:1px solid var(--ct-line)}.ct-headline{display:flex;align-items:center;gap:7px;min-width:0;flex:1}.ct-title{font-size:12.5px;font-weight:650;white-space:nowrap;flex:0 0 auto}.ct-headline>:last-child,.ct-headline>:last-child *{min-width:0;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ct-headline>:last-child{max-width:58%;justify-content:flex-start;text-align:left}.ct-head-actions{display:flex;gap:2px;flex:0 0 auto}.ct-stats{display:flex;align-items:center;gap:9px;flex-wrap:wrap;padding:4px 10px;border-bottom:1px solid var(--ct-line);font-size:10.5px;color:var(--ct-ink-3)}.ct-stats b{color:var(--ct-ink-2);font-weight:650;font-variant-numeric:tabular-nums}.ct-sync{margin-left:auto}.ct-banner{display:flex;align-items:center;gap:6px;margin:6px 8px 0;padding:5px 7px;border:1px solid color-mix(in srgb,var(--ct-warn) 45%,var(--ct-line));background:color-mix(in srgb,var(--ct-warn) 10%,transparent);border-radius:6px;font-size:10px;color:var(--ct-warn)}.ct-toolbar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:6px 8px;border-bottom:1px solid var(--ct-line)}.ct-seg{display:flex;gap:1px;padding:2px;background:var(--ct-bg-3);border-radius:6px;flex:0 0 auto}.ct-seg button{border:0;background:transparent;color:var(--ct-ink-2);font:10.5px var(--font, ui-sans-serif, system-ui, sans-serif);padding:3px 6px;border-radius:4px;cursor:pointer;white-space:nowrap}.ct-seg button.on{background:var(--ct-bg);color:var(--ct-ink);box-shadow:0 0 0 1px var(--ct-line-2);font-weight:600}.ct-search{flex:1 1 140px;min-width:0}.ct-body{flex:1;min-height:0;min-width:0;display:flex;flex-direction:column;overflow:hidden}.ct-list{flex:1;overflow-y:auto;min-height:0;padding:4px;display:flex;flex-direction:column;gap:1px}.ct-list-sec{padding:5px 8px 2px;font-size:9px;letter-spacing:.1em;text-transform:uppercase;color:var(--ct-ink-3)}.ct-row{display:flex;align-items:flex-start;gap:7px;width:100%;padding:5px 7px 6px;border:0;border-left:2px solid transparent;background:transparent;color:inherit;font:inherit;text-align:left;border-radius:5px;cursor:pointer}.ct-row:hover{background:var(--ct-bg-2)}.ct-row.sel{background:var(--ct-bg-3);border-left-color:var(--ct-accent)}.ct-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;margin-top:5px;background:var(--ct-ink-3)}.ct-dot.working{background:var(--ct-ok);box-shadow:0 0 0 3px color-mix(in srgb,var(--ct-ok) 18%,transparent);animation:ct-pulse 2.2s ease-in-out infinite}.ct-dot.wait{background:var(--ct-warn)}.ct-dot.error{background:var(--ct-err)}.ct-dot.closed{background:var(--ct-ink-3);opacity:.45}@keyframes ct-pulse{0%,to{opacity:1}50%{opacity:.45}}.ct-row-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.ct-row-top{display:flex;align-items:baseline;gap:5px;min-width:0}.ct-num{flex:0 0 auto;font:10.5px / 1.4 var(--mono, ui-monospace, monospace);color:var(--ct-ink-2)}.ct-row-title{min-width:0;font-size:12px;line-height:1.4;color:var(--ct-ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ct-row-sub{display:flex;align-items:center;gap:5px;min-width:0;overflow:hidden;font-size:10px;color:var(--ct-ink-3)}.ct-st{white-space:nowrap}.ct-st.working{color:var(--ct-ok)}.ct-st.wait{color:var(--ct-warn)}.ct-st.error{color:var(--ct-err)}.ct-st.closed{color:var(--ct-ink-3)}.ct-tab-mark{color:var(--ct-info);white-space:nowrap}.ct-go{flex:0 0 auto;color:var(--ct-ink-3);font-size:14px}.ct-chip{display:inline-block;max-width:104px;overflow:hidden;text-overflow:ellipsis;padding:0 4px;border-radius:3px;background:var(--ct-bg-3);color:var(--ct-ink-2);font-size:9.5px;line-height:1.6;white-space:nowrap;flex:0 0 auto}.ct-capsule{display:inline-flex;align-items:center;gap:4px;padding:1px 6px;border-radius:999px;font-size:10px;white-space:nowrap;border:1px solid var(--ct-line-2);color:var(--ct-ink-2);background:var(--ct-bg-2)}.ct-capsule.working{color:var(--ct-ok);border-color:color-mix(in srgb,var(--ct-ok) 45%,var(--ct-line));background:color-mix(in srgb,var(--ct-ok) 10%,transparent)}.ct-capsule.wait{color:var(--ct-warn);border-color:color-mix(in srgb,var(--ct-warn) 45%,var(--ct-line));background:color-mix(in srgb,var(--ct-warn) 10%,transparent)}.ct-capsule.error{color:var(--ct-err);border-color:color-mix(in srgb,var(--ct-err) 45%,var(--ct-line));background:color-mix(in srgb,var(--ct-err) 10%,transparent)}.ct-capsule.closed{color:var(--ct-ink-3)}.ct-detail{flex:1;min-height:0;display:flex;flex-direction:column;background:var(--ct-bg)}.ct-detail-scroll{flex:1;min-height:0;overflow-y:auto;padding:10px;display:flex;flex-direction:column;gap:11px}.ct-d-num{font:10.5px var(--mono, ui-monospace, monospace);color:var(--ct-ink-3)}.ct-d-title{margin-top:2px;font-size:13.5px;font-weight:650;line-height:1.45}.ct-d-meta{display:flex;align-items:center;gap:5px;flex-wrap:wrap;margin-top:6px}.ct-dispatch{border:1px solid var(--ct-line-2);border-radius:8px;padding:7px 8px;display:flex;flex-direction:column;gap:4px;background:var(--ct-bg-2)}.ct-dispatch.open{border-color:color-mix(in srgb,var(--ct-info) 40%,var(--ct-line-2))}.ct-dispatch-h{display:flex;align-items:center;justify-content:space-between;gap:6px}.ct-sec-label{font-size:9.5px;letter-spacing:.09em;text-transform:uppercase;color:var(--ct-ink-3);font-weight:600}.ct-draft-tag{font-size:9.5px;color:var(--ct-ink-3);border:1px solid var(--ct-line);border-radius:999px;padding:1px 6px;white-space:nowrap}.ct-draft-tag.open{color:var(--ct-info);border-color:color-mix(in srgb,var(--ct-info) 38%,var(--ct-line))}.ct-kv{display:grid;grid-template-columns:56px minmax(0,1fr);gap:5px;font-size:10px;align-items:baseline}.ct-kv span{color:var(--ct-ink-3)}.ct-kv code,.ct-draft code{font:10.5px var(--mono, ui-monospace, monospace);color:var(--ct-ink-2);overflow-wrap:anywhere}.ct-draft{border:1px dashed var(--ct-line-2);border-radius:6px;padding:3px 7px;display:flex;flex-direction:row;align-items:baseline;gap:6px;background:var(--ct-bg)}.ct-d-note{font-size:9.5px;color:var(--ct-ink-3);line-height:1.5}.ct-section{display:flex;flex-direction:column;gap:4px}.ct-summary{margin:0;font-size:11px;line-height:1.65;color:var(--ct-ink-2);white-space:pre-wrap}.ct-crit{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:3px}.ct-crit li{display:flex;gap:6px;font-size:10.5px;line-height:1.55;color:var(--ct-ink-2)}.ct-crit .box{flex:0 0 auto;width:13px;height:13px;margin-top:1px;border:1px solid var(--ct-line-2);border-radius:3px}.ct-preview{margin:0;padding:6px 7px;border:1px solid var(--ct-line);border-radius:6px;background:var(--ct-bg-2);font:10px / 1.6 var(--mono, ui-monospace, monospace);color:var(--ct-ink-2);white-space:pre-wrap;overflow-wrap:anywhere}.ct-push-head{flex:0 0 auto;display:flex;align-items:center;gap:6px;padding:5px 7px;border-bottom:1px solid var(--ct-line);background:var(--ct-bg-2)}.ct-push-head .t{font-size:11px;color:var(--ct-ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ct-actions{flex:0 0 auto;display:flex;align-items:center;gap:5px;padding:7px 8px;border-top:1px solid var(--ct-line);background:var(--ct-bg)}.ct-actions .grow{flex:1;min-width:0}.ct-statecard{flex:1;overflow-y:auto;padding:20px 14px;display:flex;flex-direction:column;gap:7px}.ct-statecard h4{margin:0;font-size:12.5px;font-weight:650;color:var(--ct-ink)}.ct-statecard p{margin:0;font-size:11px;line-height:1.65;color:var(--ct-ink-2);max-width:36ch}.ct-statecard .mono{font:10px var(--mono, ui-monospace, monospace);color:var(--ct-ink-3);overflow-wrap:anywhere}.ct-statecard .actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:3px}.ct-orphan{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 7px;margin-bottom:6px;border:1px solid var(--ct-line);border-radius:6px;font:10px var(--mono, ui-monospace, monospace);color:var(--ct-ink-2)}.ct-orphan code{overflow-wrap:anywhere}.ct-orphan .dirty{color:var(--ct-warn);font-family:var(--font, ui-sans-serif, system-ui, sans-serif)}",Je="control-tower";function hd(e){return`${e.id}:${Je}`}const md={en:{title:"Control Tower",open:"Open Control Tower","open.empty":"Open a session first","open.empty.description":"Control Tower lives in a session's side panel.","pill.clarify":"Clarify requirements","pill.clarify.title":"Open a draft with @grill-with-docs","pill.goal":"Find the goal","pill.goal.title":"Open a draft with @wayfinder"}},gd={id:Je,title:"Control Tower",closable:"hover"};function rr(e){const t=e.sessions.current();if(!t){e.toast.show({title:e.t("open.empty"),description:e.t("open.empty.description"),variant:"default"});return}e.layout.open(hd(e),t,e.layout.narrow()?void 0:{tab:"select"})}const vd=xe.Plugin.define({i18n:md,setup(e){e.add(xe.Style,pd),e.add(xe.Panel,{id:Je,region:"side",width:420,mobile:{title:e.t("title"),order:10,kind:"menu",icon:"outline-worktree"},list:t=>t.open.includes(Je)?[gd]:[],render:t=>u.createComponent(fd,{ctx:e,panel:t})}),e.add(xe.MenuItem,{menu:"session.panel",id:Je,title:e.t("title"),icon:"outline-worktree",run:()=>rr(e)}),e.add(xe.Command,{id:"control-tower.open",title:e.t("open"),description:"Issues, worktrees and child sessions for this repo.",keywords:"control tower issues worktree dispatch",run:()=>rr(e)}),e.add(xe.ComposerPill,{id:Ot,order:10,show:t=>er(Ot)?{label:e.t("pill.clarify"),title:e.t("pill.clarify.title"),icon:"bubble-5",run:()=>{e.layout.draft({server:t.session.server.id,directory:t.session.directory,prompt:`@${Ot} `})}}:void 0}),e.add(xe.ComposerPill,{id:Ct,order:11,show:t=>er(Ct)?{label:e.t("pill.goal"),title:e.t("pill.goal.title"),icon:"outline-brain",run:()=>{e.layout.draft({server:t.session.server.id,directory:t.session.directory,prompt:`@${Ct} `})}}:void 0}),$.createEffect(()=>{const t=e.sessions.current(),n=e.screen.current(),r=dl(t?.id);r&&n&&n.composer.setText(r.text)}),(async()=>{try{const t=await e.client.rpc(Qr).boardSnapshot();e.signal.aborted||Ut(t.skills.available)}catch{}})()}});exports.default=vd;
|