@codesys/mcp-toolkit 1.5.7 → 2.0.0-alpha.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.
Files changed (109) hide show
  1. package/CHANGELOG.md +153 -183
  2. package/LICENSE +21 -21
  3. package/README.md +224 -107
  4. package/dist/actions.d.ts +28 -0
  5. package/dist/actions.js +98 -0
  6. package/dist/actions.js.map +1 -0
  7. package/dist/bridge/bridge.d.ts +105 -0
  8. package/dist/bridge/bridge.js +400 -0
  9. package/dist/bridge/bridge.js.map +1 -0
  10. package/dist/cli.d.ts +2 -0
  11. package/dist/cli.js +196 -0
  12. package/dist/cli.js.map +1 -0
  13. package/dist/codesys/cache.d.ts +48 -0
  14. package/dist/codesys/cache.js +82 -0
  15. package/dist/codesys/cache.js.map +1 -0
  16. package/dist/codesys/changes.d.ts +57 -0
  17. package/dist/codesys/changes.js +133 -0
  18. package/dist/codesys/changes.js.map +1 -0
  19. package/dist/codesys/decl.d.ts +45 -0
  20. package/dist/codesys/decl.js +251 -0
  21. package/dist/codesys/decl.js.map +1 -0
  22. package/dist/codesys/devices.d.ts +34 -0
  23. package/dist/codesys/devices.js +82 -0
  24. package/dist/codesys/devices.js.map +1 -0
  25. package/dist/codesys/diff.d.ts +13 -0
  26. package/dist/codesys/diff.js +61 -0
  27. package/dist/codesys/diff.js.map +1 -0
  28. package/dist/codesys/install.d.ts +40 -0
  29. package/dist/codesys/install.js +144 -0
  30. package/dist/codesys/install.js.map +1 -0
  31. package/dist/codesys/library-browse.d.ts +19 -0
  32. package/dist/codesys/library-browse.js +57 -0
  33. package/dist/codesys/library-browse.js.map +1 -0
  34. package/dist/codesys/outline.d.ts +32 -0
  35. package/dist/codesys/outline.js +219 -0
  36. package/dist/codesys/outline.js.map +1 -0
  37. package/dist/codesys/simulation.d.ts +34 -0
  38. package/dist/codesys/simulation.js +57 -0
  39. package/dist/codesys/simulation.js.map +1 -0
  40. package/dist/codesys/st.d.ts +36 -0
  41. package/dist/codesys/st.js +69 -0
  42. package/dist/codesys/st.js.map +1 -0
  43. package/dist/daemon.d.ts +46 -0
  44. package/dist/daemon.js +173 -0
  45. package/dist/daemon.js.map +1 -0
  46. package/dist/driver.d.ts +25 -0
  47. package/dist/driver.js +33 -0
  48. package/dist/driver.js.map +1 -0
  49. package/dist/panel/sim-panel.html +357 -0
  50. package/dist/panel/viewer.html +126 -0
  51. package/dist/panel-types.d.ts +20 -0
  52. package/dist/panel-types.js +3 -0
  53. package/dist/panel-types.js.map +1 -0
  54. package/dist/panel.d.ts +27 -0
  55. package/dist/panel.js +208 -0
  56. package/dist/panel.js.map +1 -0
  57. package/dist/server.d.ts +5 -0
  58. package/dist/server.js +33 -941
  59. package/dist/server.js.map +1 -0
  60. package/dist/tools.d.ts +103 -0
  61. package/dist/tools.js +793 -0
  62. package/dist/tools.js.map +1 -0
  63. package/dist/viewer.d.ts +14 -0
  64. package/dist/viewer.js +125 -0
  65. package/dist/viewer.js.map +1 -0
  66. package/package.json +37 -21
  67. package/watcher/mcp_compat.py +147 -0
  68. package/watcher/mcp_ops.py +1178 -0
  69. package/watcher/mcp_sim.py +246 -0
  70. package/watcher/watcher.py +255 -0
  71. package/.claude/settings.local.json +0 -29
  72. package/CLAUDE.md +0 -26
  73. package/CONTRIBUTING.md +0 -72
  74. package/README.md.enhanced +0 -155
  75. package/codesys-mcp-toolkit-1.2.0.tgz +0 -0
  76. package/codesys-mcp-toolkit-1.2.1.tgz +0 -0
  77. package/codesys-mcp-toolkit-1.5.7.tgz +0 -0
  78. package/dist/bin.js +0 -75
  79. package/dist/check_session_paths.js +0 -149
  80. package/dist/codesys_interop.js +0 -435
  81. package/dist/direct_session_command.js +0 -293
  82. package/dist/scriptLoader.js +0 -165
  83. package/dist/scripts/check_status.py +0 -21
  84. package/dist/scripts/compile_project.py +0 -65
  85. package/dist/scripts/create_method.py +0 -80
  86. package/dist/scripts/create_pou.py +0 -102
  87. package/dist/scripts/create_project.py +0 -116
  88. package/dist/scripts/create_property.py +0 -78
  89. package/dist/scripts/ensure_project_open.py +0 -154
  90. package/dist/scripts/find_object_by_path.py +0 -111
  91. package/dist/scripts/get_pou_code.py +0 -91
  92. package/dist/scripts/get_project_structure.py +0 -72
  93. package/dist/scripts/open_project.py +0 -25
  94. package/dist/scripts/save_project.py +0 -29
  95. package/dist/scripts/session_status.py +0 -281
  96. package/dist/scripts/set_pou_code.py +0 -109
  97. package/dist/scripts/start_session.py +0 -809
  98. package/dist/scripts/stop_session.py +0 -324
  99. package/dist/sessionManager.js +0 -798
  100. package/docs/configuration.md +0 -141
  101. package/docs/index.md +0 -26
  102. package/docs/installation.md +0 -84
  103. package/docs/session_management.md +0 -110
  104. package/examples/README.md +0 -78
  105. package/examples/sample_config.json +0 -32
  106. package/replacements_session_status.txt +0 -16
  107. package/scriptDoc.txt +0 -8679
  108. package/scripts/build.js +0 -25
  109. package/scripts/fix_fstrings.py +0 -76
@@ -0,0 +1,357 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>CODESYS workspace</title>
7
+ <style>
8
+ :root {
9
+ --bg: var(--color-background-primary, #ffffff);
10
+ --bg2: var(--color-background-secondary, #f6f5f3);
11
+ --bg3: var(--color-background-tertiary, #efede9);
12
+ --fg: var(--color-text-primary, #1c1917);
13
+ --fg2: var(--color-text-secondary, #6b6560);
14
+ --line: var(--color-border-primary, #e4e1dd);
15
+ --accent: var(--color-text-info, #2563eb);
16
+ --accent-soft: rgba(37, 99, 235, 0.10);
17
+ --ok: #16a34a;
18
+ --warn: #d97706;
19
+ --bad: #dc2626;
20
+ --add: rgba(22, 163, 74, 0.12);
21
+ --del: rgba(220, 38, 38, 0.10);
22
+ --font: var(--font-sans, system-ui, -apple-system, "Segoe UI", sans-serif);
23
+ --mono: var(--font-mono, ui-monospace, "Cascadia Code", Consolas, monospace);
24
+ --radius: var(--border-radius-md, 8px);
25
+ color-scheme: light dark;
26
+ }
27
+ @media (prefers-color-scheme: dark) {
28
+ :root:not([data-theme="light"]) {
29
+ --bg: var(--color-background-primary, #1c1b1a); --bg2: var(--color-background-secondary, #242321); --bg3: var(--color-background-tertiary, #2c2a28);
30
+ --fg: var(--color-text-primary, #f5f5f4); --fg2: var(--color-text-secondary, #a29d98); --line: var(--color-border-primary, #3a3835);
31
+ --accent: var(--color-text-info, #60a5fa); --accent-soft: rgba(96, 165, 250, 0.14);
32
+ }
33
+ }
34
+ :root[data-theme="dark"] {
35
+ --bg: var(--color-background-primary, #1c1b1a); --bg2: var(--color-background-secondary, #242321); --bg3: var(--color-background-tertiary, #2c2a28);
36
+ --fg: var(--color-text-primary, #f5f5f4); --fg2: var(--color-text-secondary, #a29d98); --line: var(--color-border-primary, #3a3835);
37
+ --accent: var(--color-text-info, #60a5fa); --accent-soft: rgba(96, 165, 250, 0.14);
38
+ }
39
+ * { box-sizing: border-box; }
40
+ html, body { margin: 0; background: var(--bg); color: var(--fg); font: 13px/1.4 var(--font); }
41
+ button { font: inherit; color: inherit; }
42
+ .hidden { display: none !important; }
43
+ .muted { color: var(--fg2); }
44
+
45
+ /* shared bits */
46
+ .pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--bg2); font-weight: 600; white-space: nowrap; }
47
+ .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg2); flex: none; }
48
+ .pill.running .dot { background: var(--ok); animation: pulse 1s infinite; }
49
+ .pill.paused .dot { background: var(--warn); }
50
+ @keyframes pulse { 50% { opacity: 0.35; } }
51
+ .btn { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; white-space: nowrap; }
52
+ .btn:hover { background: var(--bg2); }
53
+ .btn.primary { border-color: var(--accent); color: var(--accent); }
54
+ .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
55
+ .empty { color: var(--fg2); padding: 10px 12px; }
56
+ .banner { display: none; padding: 8px 10px; border-radius: var(--radius); background: var(--bg2); color: var(--fg2); margin: 8px; }
57
+ body.superseded .banner { display: block; }
58
+ body.superseded #card, body.superseded #ws { opacity: 0.45; pointer-events: none; }
59
+
60
+ /* ---------------- card (inline in the chat) */
61
+ #card { padding: 10px; }
62
+ #c-hold[aria-pressed="true"] { background: rgba(217, 119, 6, 0.14); border-color: var(--warn); color: var(--warn); }
63
+ .card-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
64
+ .card-top .meta { color: var(--fg2); font-variant-numeric: tabular-nums; }
65
+ .card-top .activity { color: var(--accent); flex: 1 1 160px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
66
+ .facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0; }
67
+ .fact { display: flex; gap: 6px; align-items: baseline; }
68
+ .fact b { font-weight: 600; }
69
+ .good { color: var(--ok); } .bad { color: var(--bad); }
70
+
71
+ /* ---------------- workspace */
72
+ #ws { display: grid; grid-template-rows: auto auto minmax(0, 1fr) var(--bottom-h, 220px); height: var(--ws-h, 100vh); min-height: 520px; }
73
+ .ws-top { grid-row: 1; } #w-held { grid-row: 2; } .ws-main { grid-row: 3; } #ws > .bottom { grid-row: 4; }
74
+ #w-hold[aria-pressed="true"] { background: rgba(217, 119, 6, 0.14); border-color: var(--warn); color: var(--warn); }
75
+ .held { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: rgba(217, 119, 6, 0.12); color: var(--warn); border-bottom: 1px solid var(--line); font-weight: 500; }
76
+ .held .btn { margin-left: auto; }
77
+ .toasts { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 50; max-width: min(420px, 90vw); }
78
+ .toast { padding: 8px 12px; border-radius: 8px; background: var(--fg); color: var(--bg); box-shadow: 0 4px 16px rgba(0,0,0,.18); font-size: 12.5px; animation: toast-in .15s ease-out; }
79
+ .toast.err { background: var(--bad); color: #fff; }
80
+ @keyframes toast-in { from { transform: translateY(6px); opacity: 0; } }
81
+ .review { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--bg2); font: 12px var(--font); position: sticky; left: 0; top: 0; z-index: 2; }
82
+ .review > span:nth-child(2) { flex: 1 1 16ch; }
83
+ .review .btn { height: 24px; }
84
+ .btn.good { border-color: var(--ok); color: var(--ok); }
85
+ .btn.danger { border-color: var(--bad); color: var(--bad); }
86
+ body.inline-expanded #ws { --ws-h: 780px; }
87
+ .ws-top { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--bg2); flex-wrap: wrap; }
88
+ .ws-top .meta { color: var(--fg2); font-variant-numeric: tabular-nums; }
89
+ .ws-top .activity { color: var(--accent); flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
90
+ .ws-main { display: grid; grid-template-columns: var(--tree-w, 250px) minmax(0, 1fr); min-height: 0; }
91
+ @media (max-width: 900px) { .ws-main { grid-template-columns: 200px minmax(0, 1fr); } }
92
+ .pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--line); }
93
+ .pane:last-child { border-right: 0; }
94
+ .pane-head { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--line); background: var(--bg2); min-height: 32px; }
95
+ .scroll { overflow: auto; min-height: 0; flex: 1; }
96
+
97
+ /* tree */
98
+ .filter { flex: 1; min-width: 0; height: 24px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; background: var(--bg); color: var(--fg); font: inherit; }
99
+ .tree { padding: 4px 0; font-size: 12.5px; }
100
+ .tn { display: flex; align-items: center; gap: 5px; height: 24px; padding-right: 8px; cursor: pointer; white-space: nowrap; }
101
+ .tn:hover { background: var(--bg2); }
102
+ .tn.sel { background: var(--accent-soft); }
103
+ .tn .tw { width: 14px; text-align: center; color: var(--fg2); flex: none; font-size: 10px; }
104
+ .tn .ic { width: 20px; height: 16px; border-radius: 4px; display: grid; place-items: center; font: 600 9px var(--mono); flex: none; background: var(--bg3); color: var(--fg2); }
105
+ .ic.k-program { background: rgba(37,99,235,.12); color: #2563eb; }
106
+ .ic.k-function_block { background: rgba(147,51,234,.12); color: #9333ea; }
107
+ .ic.k-function { background: rgba(8,145,178,.12); color: #0891b2; }
108
+ .ic.k-gvl { background: rgba(217,119,6,.12); color: #d97706; }
109
+ .ic.k-dut { background: rgba(22,163,74,.12); color: #16a34a; }
110
+ .ic.k-interface { background: rgba(219,39,119,.12); color: #db2777; }
111
+ .tn .nm { overflow: hidden; text-overflow: ellipsis; }
112
+ .tn.dim .nm { color: var(--fg2); }
113
+ .tn .marks { margin-left: auto; display: flex; gap: 4px; align-items: center; flex: none; }
114
+ .mk { font-size: 10px; font-weight: 700; line-height: 1; }
115
+ .mk.A { color: var(--ok); } .mk.M { color: var(--warn); } .mk.D { color: var(--bad); }
116
+ .mk.err { color: #fff; background: var(--bad); border-radius: 8px; padding: 2px 5px; }
117
+ .mk.claude { color: var(--accent); animation: pulse 1.2s infinite; }
118
+ .removed { padding: 6px 10px; font-size: 12px; color: var(--fg2); border-top: 1px solid var(--line); }
119
+
120
+ /* editor */
121
+ .tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: thin; flex: 1; min-width: 0; }
122
+ .tab { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px 0 10px; border-radius: 6px 6px 0 0; border: 1px solid transparent; border-bottom: 0; cursor: pointer; white-space: nowrap; color: var(--fg2); }
123
+ .tab.active { background: var(--bg); border-color: var(--line); color: var(--fg); }
124
+ .tab .x { border: 0; background: none; cursor: pointer; color: var(--fg2); padding: 0 3px; border-radius: 4px; }
125
+ .tab .x:hover { background: var(--bg3); }
126
+ .editor { font: 12.5px/1.55 var(--mono); padding: 4px 0 20px; }
127
+ .part { font: 600 11px var(--font); color: var(--fg2); padding: 8px 12px 2px 64px; letter-spacing: 0.03em; text-transform: uppercase; }
128
+ .ln { display: grid; grid-template-columns: 16px 40px minmax(0, 1fr); white-space: pre; cursor: default; }
129
+ .ln:hover { background: var(--bg2); }
130
+ .ln .sg { color: var(--fg2); text-align: center; }
131
+ .ln .no { color: var(--fg2); text-align: right; padding-right: 12px; user-select: none; }
132
+ .ln .tx { padding-right: 12px; }
133
+ .ln.sel { box-shadow: inset 3px 0 0 var(--accent); }
134
+ .ln.has-err { box-shadow: inset 3px 0 0 var(--bad); background: rgba(220, 38, 38, 0.08); }
135
+ .ln.has-wrn { box-shadow: inset 3px 0 0 var(--warn); }
136
+ .ln.add { background: var(--add); }
137
+ .ln.del { background: var(--del); }
138
+ .ln.del .tx { text-decoration: line-through; color: var(--fg2); }
139
+ .kw { color: #9333ea; } .ty { color: #0891b2; } .cm { color: var(--fg2); font-style: italic; } .st { color: #16a34a; } .nu { color: #d97706; }
140
+ :root[data-theme="dark"] .kw { color: #c084fc; } :root[data-theme="dark"] .ty { color: #22d3ee; } :root[data-theme="dark"] .st { color: #4ade80; } :root[data-theme="dark"] .nu { color: #fbbf24; }
141
+ .edit-tools { display: flex; gap: 6px; align-items: center; margin-left: auto; }
142
+
143
+ /* bottom */
144
+ .seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--bg3); gap: 2px; overflow-x: auto; max-width: 100%; }
145
+ .seg button { height: 22px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--fg2); cursor: pointer; white-space: nowrap; }
146
+ .seg button[aria-pressed="true"] { background: var(--bg); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
147
+ .bottom { display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--line); }
148
+ .list div.row { padding: 4px 10px; border-bottom: 1px solid var(--line); }
149
+ .list .err { color: var(--bad); font-weight: 600; } .list .wrn { color: var(--warn); font-weight: 600; }
150
+
151
+ /* views */
152
+ .vbar { display: flex; align-items: center; gap: 8px; margin: 10px 0 8px; flex-wrap: wrap; }
153
+ .views button { position: relative; }
154
+ .views button.auto::after { content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
155
+ .views .vc { margin-left: 5px; font-size: 10.5px; padding: 0 5px; border-radius: 8px; background: var(--bg2); color: var(--fg2); font-variant-numeric: tabular-nums; }
156
+ .views .vc.bad { background: rgba(220, 38, 38, 0.14); color: var(--bad); }
157
+ .btn.sm { height: 24px; font-size: 11.5px; padding: 0 8px; }
158
+ .cview { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 120px; }
159
+ .vhead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12.5px; }
160
+ .vhead .cl { margin-left: auto; font-size: 11.5px; } .vhead .cl.bad { color: var(--bad); font-weight: 600; } .vhead .cl.good { color: var(--ok); }
161
+ .code.live { position: relative; max-height: 340px; overflow: auto; font: 12px/1.55 var(--mono); border-radius: 6px; background: var(--bg2); padding: 4px 0; }
162
+ .code.live .part { font: 600 10px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--fg2); padding: 6px 12px 2px 44px; }
163
+ .code.live .ln { display: flex; white-space: pre; } .code.live .no { width: 34px; flex: none; text-align: right; padding-right: 10px; color: var(--fg2); opacity: .7; user-select: none; }
164
+ .code.live .ln.add { background: var(--add); } .code.live .ln.add .no { color: var(--ok); opacity: 1; }
165
+ .problems { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; } .problems li { padding: 2px 0; }
166
+ .problems .err { color: var(--bad); font-weight: 600; } .problems .wrn { color: var(--warn); font-weight: 600; }
167
+ .review-list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
168
+ .review-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); flex-wrap: wrap; } .review-list li:first-child { border-top: 0; }
169
+ .review-list .rp { display: flex; flex-direction: column; flex: 1 1 140px; min-width: 0; } .review-list .rp b { overflow-wrap: anywhere; }
170
+ .review-list .btn { height: 24px; font-size: 11.5px; }
171
+ .review-list .rp .good, .review-list .rp .bad { font: 600 11px var(--mono); }
172
+ .review-list .rd { flex: 1 0 100%; min-width: 0; margin-top: 4px; }
173
+ .code.live.rdiff { max-height: 300px; }
174
+ .code.live .ln .sg { width: 14px; flex: none; text-align: center; user-select: none; }
175
+ .code.live .ln.add .sg { color: var(--ok); } .code.live .ln.del .sg { color: var(--bad); }
176
+ .code.live .ln.del { background: var(--del); } .code.live .ln.del .tx { text-decoration: line-through; color: var(--fg2); }
177
+ .code.live .ln.gap .tx { color: var(--fg2); padding-left: 14px; }
178
+ .rd-obj { font: 600 11.5px var(--mono); padding: 8px 12px 0; } .rd-load { padding: 6px 12px; }
179
+ .lnk { background: none; border: 0; padding: 4px 0 0; color: var(--accent); font: 11.5px var(--font); cursor: pointer; }
180
+ .vpad { padding: 10px 12px; }
181
+ #w-views { margin-left: 4px; }
182
+ </style>
183
+ </head>
184
+ <body>
185
+ <div class="banner">A newer panel is open; this one stopped updating.</div>
186
+
187
+ <section id="card" class="hidden">
188
+ <div class="card-top">
189
+ <span id="c-status" class="pill"><span class="dot"></span><span id="c-statusText">Connecting</span></span>
190
+ <span id="c-meta" class="meta"></span>
191
+ <span id="c-activity" class="activity"></span>
192
+ <button id="c-hold" class="btn" aria-pressed="false" title="Hold Claude's tools that change the project or the simulation">Pause Claude</button>
193
+ <button id="c-open" class="btn primary" title="Open the full workspace">
194
+ <svg width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M9.5 2.5h4v4M6.5 13.5h-4v-4M13.5 2.5 9 7M2.5 13.5 7 9"/></svg>Open workspace</button>
195
+ </div>
196
+ <div id="c-facts" class="facts"></div>
197
+ <div class="vbar"><div id="c-views" class="seg views" role="group" aria-label="View"></div>
198
+ <button id="c-follow" class="btn sm" aria-pressed="true" title="Switch views by what Claude is doing">Follow Claude</button></div>
199
+ <div id="c-view" class="cview"></div>
200
+ </section>
201
+
202
+ <section id="ws" class="hidden">
203
+ <div class="ws-top">
204
+ <span id="w-status" class="pill"><span class="dot"></span><span id="w-statusText">Connecting</span></span>
205
+ <span id="w-meta" class="meta"></span>
206
+ <div id="w-views" class="seg views" role="group" aria-label="View"></div>
207
+ <span id="w-activity" class="activity"></span>
208
+ <button id="w-hold" class="btn" aria-pressed="false" title="Hold Claude's tools that change the project or the simulation">
209
+ <svg width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6"><circle cx="8" cy="8" r="6"/><path d="M6.5 5.5v5M9.5 5.5v5"/></svg><span>Pause Claude</span></button>
210
+ <button id="w-follow" class="btn" aria-pressed="true" title="Open what Claude works on">
211
+ <svg width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6"><circle cx="8" cy="8" r="2.5"/><path d="M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2"/></svg>Follow Claude</button>
212
+ <button id="w-close" class="btn" title="Back to the compact view">
213
+ <svg width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M13.5 6.5h-4v-4M2.5 9.5h4v4M9.5 6.5 14 2M6.5 9.5 2 14"/></svg>Compact</button>
214
+ </div>
215
+ <div id="w-held" class="held hidden">You're driving: Claude's tools that change the project or the simulation are paused. <button class="btn" data-resume>Resume Claude</button></div>
216
+ <div class="ws-main">
217
+ <section class="pane">
218
+ <div class="pane-head"><input id="w-filter" class="filter" placeholder="Filter objects" aria-label="Filter objects"></div>
219
+ <div id="w-tree" class="scroll tree"><div class="empty">Open a project to see its tree.</div></div>
220
+ </section>
221
+ <section class="pane">
222
+ <div class="pane-head">
223
+ <div id="w-tabs" class="tabs"></div>
224
+ <div class="edit-tools"><button id="w-diff" class="btn" aria-pressed="false" title="Show changes since the session started">Diff</button></div>
225
+ </div>
226
+ <div id="w-editor" class="scroll editor"><div class="empty">Select an object in the tree.</div></div>
227
+ </section>
228
+ </div>
229
+ <section class="bottom">
230
+ <div class="pane-head"><div class="seg" id="w-bottom-tabs">
231
+ <button data-t="problems" aria-pressed="true">Problems</button><button data-t="review" aria-pressed="false">Review</button>
232
+ </div><span id="w-bottom-info" class="muted" style="margin-left:auto;font-size:11px"></span></div>
233
+ <div id="w-bottom" class="scroll"></div>
234
+ </section>
235
+ </section>
236
+ <div id="toasts" class="toasts" aria-live="polite"></div>
237
+ <script>"use strict";(()=>{var aR=Object.defineProperty;var er=(e,t)=>{for(var r in t)aR(e,r,{get:t[r],enumerable:!0})};var cR=Object.create,ou=Object.defineProperty,uR=Object.getOwnPropertyDescriptor,lR=Object.getOwnPropertyNames,dR=Object.getPrototypeOf,pR=Object.prototype.hasOwnProperty,S_=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),__=(e,t)=>{let r={};for(var n in e)ou(r,n,{get:e[n],enumerable:!0});return t&&ou(r,Symbol.toStringTag,{value:"Module"}),r},mR=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(var o=lR(t),s=0,i=o.length,a;s<i;s++)a=o[s],!pR.call(e,a)&&a!==r&&ou(e,a,{get:(c=>t[c]).bind(null,a),enumerable:!(n=uR(t,a))||n.enumerable});return e},b_=(e,t,r)=>(r=e!=null?cR(dR(e)):{},mR(t||!e||!e.__esModule?ou(r,"default",{value:e,enumerable:!0}):r,e));var hR=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),y_=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),fR=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),gR=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function v_(e){return typeof e=="string"&&y_.has(e.replace(/#$/,""))}function w_(e,t){if(!("$schema"in e)||typeof e.$schema!="string")return"2020-12";let r=e.$schema.replace(/#$/,"");if(hR.has(r))return"2020-12";if(y_.has(r))return"2019-09";if(fR.has(r)||gR.has(r))return"draft-7";throw new Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var m={};er(m,{$brand:()=>yp,$input:()=>Bh,$output:()=>Hh,INVALID:()=>Ve,NEVER:()=>Gs,TimePrecision:()=>of,ZodAny:()=>Zg,ZodArray:()=>Bg,ZodBase64:()=>ed,ZodBase64URL:()=>td,ZodBigInt:()=>Co,ZodBigIntFormat:()=>od,ZodBoolean:()=>Po,ZodCIDRv4:()=>Ql,ZodCIDRv6:()=>Xl,ZodCUID:()=>Hl,ZodCUID2:()=>Bl,ZodCatch:()=>dS,ZodCodec:()=>Oi,ZodCompileAsyncError:()=>zt,ZodCompileUnsupportedError:()=>oe,ZodCreditCard:()=>Lg,ZodCustom:()=>Ni,ZodCustomStringFormat:()=>gn,ZodDate:()=>Ti,ZodDefault:()=>sS,ZodDiscriminatedUnion:()=>Kg,ZodE164:()=>rd,ZodEmail:()=>Dl,ZodEmoji:()=>Vl,ZodEnum:()=>ko,ZodError:()=>Ex,ZodExactOptional:()=>cd,ZodFile:()=>tS,ZodFirstPartyTypeKind:()=>RS,ZodFunction:()=>yS,ZodGUID:()=>Zl,ZodIBAN:()=>qg,ZodIPv4:()=>Gl,ZodIPv6:()=>Yl,ZodISODate:()=>Er,ZodISODateTime:()=>Tr,ZodISODuration:()=>Cr,ZodISOTime:()=>Pr,ZodInstanceOf:()=>zS,ZodIntersection:()=>Wg,ZodIssueCode:()=>$S,ZodJWT:()=>nd,ZodKSUID:()=>Wl,ZodLazy:()=>_S,ZodLiteral:()=>eS,ZodMAC:()=>Mg,ZodMap:()=>Qg,ZodNaN:()=>mS,ZodNanoID:()=>Fl,ZodNever:()=>Fg,ZodNonOptional:()=>ud,ZodNull:()=>Ug,ZodNullable:()=>oS,ZodNumber:()=>Eo,ZodNumberFormat:()=>Sn,ZodObject:()=>Ei,ZodOptional:()=>Ci,ZodPipe:()=>Ii,ZodPrefault:()=>aS,ZodPreprocess:()=>hS,ZodPromise:()=>bS,ZodReadonly:()=>fS,ZodRealError:()=>tt,ZodRecord:()=>$o,ZodSet:()=>Xg,ZodString:()=>xo,ZodStringFormat:()=>de,ZodSuccess:()=>lS,ZodSymbol:()=>jg,ZodTemplateLiteral:()=>SS,ZodTransform:()=>rS,ZodTuple:()=>Gg,ZodType:()=>te,ZodULID:()=>Jl,ZodURL:()=>xi,ZodUUID:()=>Zt,ZodUndefined:()=>Dg,ZodUnion:()=>Pi,ZodUnknown:()=>Vg,ZodVoid:()=>Hg,ZodXID:()=>Kl,ZodXor:()=>Jg,_ZodString:()=>jl,_default:()=>iS,_function:()=>Jv,any:()=>sd,array:()=>y,base64:()=>uv,base64url:()=>lv,bigint:()=>Rv,boolean:()=>E,catch:()=>pS,check:()=>Kv,cidrv4:()=>av,cidrv6:()=>cv,clone:()=>ce,codec:()=>Vv,coerce:()=>Li,compile:()=>Gh,config:()=>be,core:()=>sr,creditCard:()=>pv,cuid:()=>Xy,cuid2:()=>ev,currencyCode:()=>_v,custom:()=>Wv,date:()=>Pv,decode:()=>Eg,decodeAsync:()=>Cg,deepPartial:()=>aw,describe:()=>Gv,discriminatedUnion:()=>Ir,e164:()=>dv,email:()=>Ul,emoji:()=>Yy,encode:()=>Tg,encodeAsync:()=>Pg,endsWith:()=>ho,enum:()=>Y,exactOptional:()=>nS,file:()=>jv,flattenError:()=>Ys,float32:()=>yv,float64:()=>vv,formatError:()=>Qs,fromJSONSchema:()=>sw,function:()=>Jv,getDiscriminatedOption:()=>bh,getErrorMap:()=>Ox,globalRegistry:()=>Te,gt:()=>Dt,gte:()=>ut,guid:()=>Hy,hash:()=>bv,hex:()=>Sv,hostname:()=>gv,httpUrl:()=>Gy,iban:()=>mv,includes:()=>po,input:()=>uw,instanceof:()=>Qv,int:()=>Ll,int32:()=>wv,int64:()=>$v,intersection:()=>$t,invertCodec:()=>Fv,ipv4:()=>ov,ipv6:()=>iv,iso:()=>_t,json:()=>ew,jwt:()=>hv,keyof:()=>Cv,ksuid:()=>nv,lazy:()=>Or,length:()=>pn,literal:()=>v,locales:()=>Si,looseObject:()=>V,looseRecord:()=>Av,lowercase:()=>uo,lt:()=>jt,lte:()=>ct,mac:()=>sv,map:()=>Mv,maxLength:()=>dn,maxSize:()=>Rr,memoizer:()=>gi,meta:()=>Yv,mime:()=>go,minLength:()=>or,minSize:()=>Ut,multipleOf:()=>zr,nan:()=>Zv,nanoid:()=>Qy,nativeEnum:()=>qv,negative:()=>xl,never:()=>id,nonnegative:()=>El,nonoptional:()=>uS,nonpositive:()=>Tl,normalize:()=>So,null:()=>Vt,nullable:()=>ki,nullish:()=>Dv,number:()=>z,object:()=>g,optional:()=>M,output:()=>lw,overwrite:()=>Rt,parse:()=>$g,parseAsync:()=>kg,partialRecord:()=>Nv,pipe:()=>ql,positive:()=>kl,prefault:()=>cS,preprocess:()=>ir,prettifyError:()=>$p,promise:()=>Bv,properties:()=>fo,property:()=>Pl,readonly:()=>gS,record:()=>T,refine:()=>vS,regex:()=>co,regexes:()=>St,registry:()=>tl,safeDecode:()=>Og,safeDecodeAsync:()=>Ag,safeEncode:()=>Ig,safeEncodeAsync:()=>Ng,safeParse:()=>$i,safeParseAsync:()=>xg,set:()=>Lv,setErrorMap:()=>Ix,size:()=>ln,slugify:()=>vo,startsWith:()=>mo,strictObject:()=>Iv,string:()=>l,stringFormat:()=>fv,stringbool:()=>Xv,success:()=>Uv,superRefine:()=>wS,symbol:()=>xv,templateLiteral:()=>Hv,toJSONSchema:()=>hn,toLowerCase:()=>bo,toUpperCase:()=>yo,toZod:()=>Ds,transform:()=>ad,treeifyError:()=>Rp,trim:()=>_o,tuple:()=>Yg,uint32:()=>zv,uint64:()=>kv,ulid:()=>tv,undefined:()=>Tv,union:()=>P,unknown:()=>j,uppercase:()=>lo,url:()=>To,util:()=>A,uuid:()=>By,uuidv4:()=>Jy,uuidv6:()=>Ky,uuidv7:()=>Wy,validate:()=>Xs,validateAsync:()=>ei,void:()=>Ev,withParser:()=>rl,xid:()=>rv,xor:()=>Ov});var sr={};er(sr,{$ZodAny:()=>lh,$ZodArray:()=>gh,$ZodAsyncError:()=>Xe,$ZodBase64:()=>Qm,$ZodBase64URL:()=>Xm,$ZodBigInt:()=>Vu,$ZodBigIntFormat:()=>ih,$ZodBoolean:()=>li,$ZodCIDRv4:()=>Gm,$ZodCIDRv6:()=>Ym,$ZodCUID:()=>qm,$ZodCUID2:()=>jm,$ZodCatch:()=>Ah,$ZodCheck:()=>pe,$ZodCheckBigIntFormat:()=>dm,$ZodCheckEndsWith:()=>zm,$ZodCheckGreaterThan:()=>xu,$ZodCheckIncludes:()=>vm,$ZodCheckLengthEquals:()=>Sm,$ZodCheckLessThan:()=>ku,$ZodCheckLowerCase:()=>bm,$ZodCheckMaxLength:()=>fm,$ZodCheckMaxSize:()=>pm,$ZodCheckMimeType:()=>km,$ZodCheckMinLength:()=>gm,$ZodCheckMinSize:()=>mm,$ZodCheckMultipleOf:()=>um,$ZodCheckNumberFormat:()=>lm,$ZodCheckOverwrite:()=>xm,$ZodCheckProperties:()=>$m,$ZodCheckProperty:()=>Rm,$ZodCheckRegex:()=>_m,$ZodCheckSizeEquals:()=>hm,$ZodCheckStartsWith:()=>wm,$ZodCheckStringFormat:()=>oo,$ZodCheckUpperCase:()=>ym,$ZodCodec:()=>pi,$ZodCreditCard:()=>th,$ZodCustom:()=>Zh,$ZodCustomStringFormat:()=>oh,$ZodCyclicError:()=>Gu,$ZodDate:()=>hh,$ZodDefault:()=>Ch,$ZodDiscriminatedUnion:()=>yh,$ZodE164:()=>eh,$ZodEmail:()=>Im,$ZodEmoji:()=>Mm,$ZodEncodeError:()=>vr,$ZodEnum:()=>$h,$ZodError:()=>zp,$ZodExactOptional:()=>Eh,$ZodFile:()=>xh,$ZodFunction:()=>Dh,$ZodGUID:()=>Pm,$ZodIBAN:()=>rh,$ZodIPv4:()=>Jm,$ZodIPv6:()=>Km,$ZodISODate:()=>Fm,$ZodISODateTime:()=>Vm,$ZodISODuration:()=>Bm,$ZodISOTime:()=>Hm,$ZodIntersection:()=>vh,$ZodJWT:()=>nh,$ZodKSUID:()=>Zm,$ZodLazy:()=>mi,$ZodLiteral:()=>kh,$ZodMAC:()=>Wm,$ZodMap:()=>zh,$ZodNaN:()=>Mh,$ZodNanoID:()=>Lm,$ZodNever:()=>ph,$ZodNonOptional:()=>Oh,$ZodNull:()=>uh,$ZodNullable:()=>Ph,$ZodNumber:()=>Zu,$ZodNumberFormat:()=>sh,$ZodObject:()=>nb,$ZodObjectJIT:()=>Sh,$ZodOptional:()=>Hu,$ZodPipe:()=>Bu,$ZodPrefault:()=>Ih,$ZodPreprocess:()=>Lh,$ZodPromise:()=>Uh,$ZodReadonly:()=>qh,$ZodRealError:()=>et,$ZodRecord:()=>wh,$ZodRegistry:()=>el,$ZodSet:()=>Rh,$ZodString:()=>sn,$ZodStringFormat:()=>ue,$ZodSuccess:()=>Nh,$ZodSymbol:()=>ah,$ZodTemplateLiteral:()=>jh,$ZodTransform:()=>Th,$ZodTuple:()=>Fu,$ZodType:()=>X,$ZodULID:()=>Dm,$ZodURL:()=>Am,$ZodUUID:()=>Cm,$ZodUndefined:()=>ch,$ZodUnion:()=>di,$ZodUnknown:()=>dh,$ZodVoid:()=>mh,$ZodXID:()=>Um,$ZodXor:()=>_h,$brand:()=>yp,$constructor:()=>b,$input:()=>Bh,$output:()=>Hh,Doc:()=>on,INVALID:()=>Ve,JSONSchema:()=>Zy,JSONSchemaGenerator:()=>Nl,NEVER:()=>Gs,TimePrecision:()=>of,URL_BAD_FORMAT:()=>Om,URL_UNPARSEABLE:()=>si,ZodCompileAsyncError:()=>zt,ZodCompileUnsupportedError:()=>oe,_any:()=>wf,_array:()=>Ef,_base64:()=>wl,_base64url:()=>zl,_bigint:()=>ff,_boolean:()=>mf,_catch:()=>Sx,_check:()=>ky,_cidrv4:()=>yl,_cidrv6:()=>vl,_coercedBigint:()=>gf,_coercedBoolean:()=>hf,_coercedDate:()=>xf,_coercedNumber:()=>af,_coercedString:()=>ef,_creditCard:()=>rf,_cuid:()=>ml,_cuid2:()=>hl,_custom:()=>Cf,_date:()=>kf,_decode:()=>fu,_decodeAsync:()=>Su,_default:()=>hx,_discriminatedUnion:()=>rx,_e164:()=>Rl,_email:()=>sl,_emoji:()=>dl,_encode:()=>hu,_encodeAsync:()=>gu,_endsWith:()=>ho,_enum:()=>cx,_file:()=>Pf,_float32:()=>uf,_float64:()=>lf,_gt:()=>Dt,_gte:()=>ut,_guid:()=>il,_iban:()=>nf,_includes:()=>po,_int:()=>cf,_int32:()=>df,_int64:()=>Sf,_intersection:()=>nx,_ipv4:()=>_l,_ipv6:()=>bl,_isoDate:()=>yi,_isoDateTime:()=>bi,_isoDuration:()=>wi,_isoTime:()=>vi,_jwt:()=>$l,_ksuid:()=>Sl,_lazy:()=>vx,_length:()=>pn,_literal:()=>lx,_lowercase:()=>uo,_lt:()=>jt,_lte:()=>ct,_mac:()=>tf,_map:()=>ix,_max:()=>ct,_maxLength:()=>dn,_maxSize:()=>Rr,_mime:()=>go,_min:()=>ut,_minLength:()=>or,_minSize:()=>Ut,_multipleOf:()=>zr,_nan:()=>Tf,_nanoid:()=>pl,_nativeEnum:()=>ux,_negative:()=>xl,_never:()=>Rf,_nonnegative:()=>El,_nonoptional:()=>fx,_nonpositive:()=>Tl,_normalize:()=>So,_null:()=>vf,_nullable:()=>mx,_number:()=>sf,_optional:()=>px,_overwrite:()=>Rt,_parse:()=>eo,_parseAsync:()=>to,_pipe:()=>_x,_positive:()=>kl,_promise:()=>wx,_properties:()=>fo,_property:()=>Pl,_readonly:()=>bx,_record:()=>sx,_refine:()=>If,_regex:()=>co,_safeDecode:()=>bu,_safeDecodeAsync:()=>vu,_safeEncode:()=>_u,_safeEncodeAsync:()=>yu,_safeParse:()=>ro,_safeParseAsync:()=>no,_set:()=>ax,_size:()=>ln,_slugify:()=>vo,_startsWith:()=>mo,_string:()=>Xh,_stringFormat:()=>mn,_stringbool:()=>Mf,_success:()=>gx,_superRefine:()=>Of,_symbol:()=>bf,_templateLiteral:()=>yx,_toLowerCase:()=>bo,_toUpperCase:()=>yo,_transform:()=>dx,_trim:()=>_o,_tuple:()=>ox,_uint32:()=>pf,_uint64:()=>_f,_ulid:()=>fl,_undefined:()=>yf,_union:()=>ex,_unknown:()=>zf,_uppercase:()=>lo,_url:()=>_i,_uuid:()=>al,_uuidv4:()=>cl,_uuidv6:()=>ul,_uuidv7:()=>ll,_void:()=>$f,_xid:()=>gl,_xor:()=>tx,base64Charset:()=>Lu,base64urlCharset:()=>ui,canParseURL:()=>Nm,clone:()=>ce,compile:()=>Gh,compileFn:()=>nl,config:()=>be,createStandardJSONSchemaMethod:()=>wo,createToJSONSchemaMethod:()=>qf,decode:()=>a$,decodeAsync:()=>u$,describe:()=>Nf,encode:()=>i$,encodeAsync:()=>c$,extractDefs:()=>kr,finalize:()=>xr,flattenError:()=>Ys,formatError:()=>Qs,getDiscriminatedOption:()=>bh,globalConfig:()=>Re,globalRegistry:()=>Te,handleUnrepresentable:()=>we,initializeContext:()=>$r,isBackEdge:()=>Qu,isRecursiveSchema:()=>Yu,isValidBase64:()=>ci,isValidBase64URL:()=>qu,isValidCIDRv6:()=>Mu,isValidCreditCard:()=>ju,isValidIBAN:()=>Du,isValidIPv6:()=>ai,isValidJWT:()=>Uu,locales:()=>Si,memoizer:()=>gi,mergeValues:()=>so,meta:()=>Af,parse:()=>pu,parseAsync:()=>mu,parseURLObject:()=>eb,prettifyError:()=>$p,process:()=>le,processSchema:()=>le,regexes:()=>St,registry:()=>tl,safeDecode:()=>d$,safeDecodeAsync:()=>m$,safeEncode:()=>l$,safeEncodeAsync:()=>p$,safeParse:()=>t$,safeParseAsync:()=>r$,standardProps:()=>Iu,stripTabAndNewline:()=>ii,toDotPath:()=>O_,toJSONSchema:()=>hn,toZod:()=>Ds,treeifyError:()=>Rp,urlHostnameOk:()=>Nu,urlProtocolOk:()=>Au,util:()=>A,validate:()=>Xs,validateAsync:()=>ei,validateURL:()=>Ou,version:()=>Tm,withParser:()=>rl});var A={};er(A,{BIGINT_FORMAT_RANGES:()=>Hs,CONSTANT_CATCH:()=>lu,Class:()=>up,NUMBER_FORMAT_RANGES:()=>Fs,aborted:()=>Ze,allowsEval:()=>pp,assert:()=>vR,assertEqual:()=>SR,assertIs:()=>bR,assertNever:()=>yR,assertNotEqual:()=>_R,assignProp:()=>xe,attachSchema:()=>Bs,base64ToUint8Array:()=>x_,base64urlToUint8Array:()=>DR,cached:()=>Gn,captureStackTrace:()=>au,cleanEnum:()=>jR,cleanRegex:()=>rr,clone:()=>ce,cloneDef:()=>RR,codePointLength:()=>rn,constantCatch:()=>_p,createTransparentProxy:()=>PR,defineLazy:()=>lp,defineLazyInternal:()=>ne,derived:()=>FR,esc:()=>Ue,escapeRegex:()=>gt,explicitlyAborted:()=>fp,extend:()=>OR,finalizeIssue:()=>Qe,floatSafeRemainder:()=>Us,getElementAtPath:()=>$R,getEnumValues:()=>Kn,getLengthableOrigin:()=>Ks,getParsedType:()=>ER,getSizableOrigin:()=>Js,hexToUint8Array:()=>ZR,hide:()=>Ws,installLazyProp:()=>KR,isObject:()=>tn,isPlainObject:()=>ft,issue:()=>Xn,joinValues:()=>su,jsonStringifyReplacer:()=>Wn,members:()=>Sp,merge:()=>AR,mergeDefs:()=>wt,normalizeParams:()=>$,nullish:()=>iu,numKeys:()=>TR,objectClone:()=>wR,omit:()=>IR,optionalKeys:()=>hp,own:()=>yr,parsedType:()=>gp,partial:()=>MR,pick:()=>CR,prefixIssues:()=>Ye,primitiveTypes:()=>mp,promiseAllObject:()=>kR,propertyKeyTypes:()=>Vs,randomString:()=>xR,rawShape:()=>Yn,required:()=>LR,safeExtend:()=>NR,shallowClone:()=>Zs,sizeCaps:()=>Qn,slugify:()=>dp,stringifyPrimitive:()=>cu,toZod:()=>Ds,uint8ArrayToBase64:()=>T_,uint8ArrayToBase64url:()=>UR,uint8ArrayToHex:()=>VR,unwrapMessage:()=>Jn});function SR(e){return e}function _R(e){return e}function Ds(){return e=>e}function bR(e){}function yR(e){throw new Error("Unexpected value in exhaustive check")}function vR(e){}function Kn(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function su(e,t="|"){return e.map(r=>cu(r)).join(t)}function Wn(e,t){return typeof t=="bigint"?t.toString():t}var cp=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Gn(e){return new cp(e)}function iu(e){return e==null}function rr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Us(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var z_=Symbol("evaluating");function lp(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==z_)return n===void 0&&(n=z_,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function wR(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function xe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Yn(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function tr(e){return Yn(e._zod.def)??e._zod.def.shape}function R_(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return xe(this,t,n),n},enumerable:!0,configurable:!0})}function $_(e,t,r){t in e?xe(e,t,r):e[t]=r}function en(e,t,r,n){let o=tr(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?R_(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):$_(e,s,n?n(i.value,s):i.value))}}function zR(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?R_(e,r,()=>t[r]):$_(e,r,n.value))}}function wt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function RR(e){return wt(e._zod.def)}function $R(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function kR(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function xR(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ue(e){return JSON.stringify(e)}function dp(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var au="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function tn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var pp=Gn(()=>{if(Re.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function ft(e){if(tn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(tn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Zs(e){return ft(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function TR(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var ER=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Vs=new Set(["string","number","symbol"]),mp=new Set(["string","number","bigint","boolean","symbol","undefined"]);function gt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function $(e){let 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 PR(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function cu(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function hp(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Fs={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]},Hs={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function CR(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return en(s,e,uu(e,t)),ce(e,wt(r,{shape:s,checks:[]}))}function uu(e,t){let r=tr(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function IR(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(uu(e,t)),i={};return en(i,e,Reflect.ownKeys(tr(e)).filter(a=>!s.has(a))),ce(e,wt(r,{shape:i,checks:[]}))}function OR(e,t){if(!ft(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=tr(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ce(e,wt(e._zod.def,{shape:k_(e,t)}))}function k_(e,t){let r={};return en(r,e,Reflect.ownKeys(tr(e))),zR(r,t),r}function NR(e,t){if(!ft(t))throw new Error("Invalid input to safeExtend: expected a plain object");return ce(e,wt(e._zod.def,{shape:k_(e,t)}))}function AR(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.");let r={};en(r,e,Reflect.ownKeys(tr(e))),en(r,t,Reflect.ownKeys(tr(t)));let n=wt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ce(e,n)}function MR(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(uu(t,r)):void 0,c={};return en(c,t,Reflect.ownKeys(tr(t)),e&&((u,d)=>a&&!a.has(d)?u:new e({type:"optional",innerType:u}))),ce(t,wt(t._zod.def,{shape:c,checks:[]}))}function LR(e,t,r){let n=r?new Set(uu(t,r)):void 0,o={};return en(o,t,Reflect.ownKeys(tr(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),ce(t,wt(t._zod.def,{shape:o}))}function Ze(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function fp(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Ye(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Jn(e){return typeof e=="string"?e:e?.message}function Qn(e){let t=[];for(let r of e??[]){let n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;let o=n.maximum??n.length??n.size;o>=0&&t.push([o,r])}return t}function Bs(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function Qe(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:Jn(e.inst?._zod.def?.error?.(e))??Jn(s?.(e))??Jn(t?.error?.(e))??Jn(r.customError?.(e))??Jn(r.localeError?.(e))??"Invalid input",a={};for(let 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=i,t?.reportInput&&(a.input=e.input),a}function Js(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var qR=/[\uD800-\uDBFF]/;function rn(e){let t=e.length;if(!qR.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function Ks(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function gp(e){let 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";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Xn(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function jR(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function x_(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function T_(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function DR(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return x_(t+r)}function UR(e){return T_(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ZR(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function VR(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var up=class{constructor(...t){}};function Sp(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):HR(e,r,n.value)}}function yr(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Ws(e,t,r){return yr(e,t,r,!1)}function FR(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return yr(this,r,n(this))},set(o){yr(this,r,o)}})}return t}function HR(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:yr(this,t,r.bind(this))},set(n){yr(this,t,n)}})}function BR(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var ap,br=!1,JR={configurable:!0,get(){br=!0}};function ne(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&ap!==e._zod){ap=void 0;return}ap=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,JR);let o=br;br=!1;try{let s=r(this);return br?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),br=br||o,s}catch(s){throw delete this[t],br=br||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function KR(e,t,r,n){let o=BR(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var lu="~constantCatch";function _p(e){let t=()=>e;return t[lu]=!0,t}var E_,Gs=Object.freeze({status:"aborted"}),bp={value:void 0,enumerable:!1},P_="captureStackTrace"in Error?Error:null;function WR(e){let t=P_;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return P_=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function b(e,t,r,n){let o={};function s(h){this.def=h,this.constr=p,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(h,f){if(h._zod){if(h._zod.traits.has(e))return}else{bp.value=new s(f);try{Object.defineProperty(h,"_zod",bp)}finally{bp.value=void 0}}if(h._zod.traits.add(e),t(h,f),a){let _=Object.getPrototypeOf(h),w=h._zod.constr.prototype,x=_;for(;x&&x!==w;)x=Object.getPrototypeOf(x);let R=x??_;a.has(R)||(a.add(R),Sp(R,i))}let S=p.prototype;for(let _ in S)Object.prototype.hasOwnProperty.call(S,_)&&(_ in h||(h[_]=S[_].bind(h)))}let u=n?.Parent??Object;class d extends u{}Object.defineProperty(d,"name",{value:e});function p(h){let f=n?.Parent?WR(d):this;c(f,h);let S=f._zod.deferred;if(S){for(let w of S)w();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;return _&&_(f),f}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:h=>n?.Parent&&h instanceof n.Parent?!0:h?._zod?.traits?.has(e)}),Object.defineProperty(p,"name",{value:e}),p}var yp=Symbol("zod_brand"),Xe=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},vr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(E_=globalThis).__zod_globalConfig??(E_.__zod_globalConfig={});var Re=globalThis.__zod_globalConfig;function be(e){return e&&Object.assign(Re,e),Re}function GR(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Wn,2)),e.message}function YR(e){this._zod.message=e}var QR={get:GR,set:YR,enumerable:!0,configurable:!0},wp={value:void 0,enumerable:!1},C_=new WeakSet([Object.prototype,Error.prototype]),I_=(e,t)=>{e.name="$ZodError",wp.value=t,Object.defineProperty(e,"issues",wp),wp.value=void 0,Object.defineProperty(e,"message",QR);let r=Object.getPrototypeOf(e);C_.has(r)||(C_.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},zp=b("$ZodError",I_),et=b("$ZodError",I_,void 0,{Parent:Error});function XR(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Ys(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?XR(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Qs(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let d=a[u],p=u===a.length-1;if(d==="_errors"){p&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,d)||Object.defineProperty(c,d,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[d];p&&h._errors.push(t(i)),c=h,u++}}}};return n(e),r}function Rp(e,t=r=>r.message){let r={errors:[]},n=(o,s=[])=>{var i;for(let a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(c=>n({issues:c},[...s,...a.path]));else if(a.code==="invalid_key")n({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")n({issues:a.issues},[...s,...a.path]);else{let c=[...s,...a.path];if(c.length===0){r.errors.push(t(a));continue}let u=r,d=0;for(;d<c.length;){let p=c[d],h=d===c.length-1;typeof p=="string"?(u.properties??(u.properties={}),Object.prototype.hasOwnProperty.call(u.properties,p)||Object.defineProperty(u.properties,p,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),u=u.properties[p]):(u.items??(u.items=[]),(i=u.items)[p]??(i[p]={errors:[]}),u=u.items[p]),h&&u.errors.push(t(a)),d++}}};return n(e),r}function O_(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function $p(e){let t=[],r=[...e.issues].sort((n,o)=>(n.path??[]).length-(o.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${O_(n.path)}`);return t.join(`
238
+ `)}function du(e,t){return{callee:t?.callee??e,Err:t?.Err}}var eo=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Xe;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>Qe(u,i,be())));throw au(c,s?.callee??t),c}return a.value};return t},pu=eo(et),to=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>Qe(u,i,be())));throw au(c,s?.callee??t),c}return a.value};return t},mu=to(et),ro=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Xe;return s.issues.length?N_(e,s.issues,o):{success:!0,data:s.value}},t$=ro(et);function N_(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>Qe(o,r,be()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var no=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?N_(e,s.issues,o):{success:!0,data:s.value}},r$=no(et),n$=Symbol.for("zod.compile.invalid"),o$=Symbol.for("zod.compile.fallback"),Xs=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==n$)return!0;if(n.definite===!0&&r===void 0)return!1}return s$(e,t,r)});function s$(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[o$]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new Xe;return s.issues.length===0}var ei=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},hu=e=>{let t=eo(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,du(r,i))};return r},i$=hu(et),fu=e=>{let t=eo(e),r=(n,o,s,i)=>t(n,o,s,du(r,i));return r},a$=fu(et),gu=e=>{let t=to(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,du(r,i))};return r},c$=gu(et),Su=e=>{let t=to(e),r=async(n,o,s,i)=>await t(n,o,s,du(r,i));return r},u$=Su(et),_u=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return ro(e)(t,r,o)},l$=_u(et),bu=e=>(t,r,n)=>ro(e)(t,r,n),d$=bu(et),yu=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return no(e)(t,r,o)},p$=yu(et),vu=e=>async(t,r,n)=>no(e)(t,r,n),m$=vu(et);var St={};er(St,{anyString:()=>Qp,base64:()=>Vp,base64url:()=>Fp,bigint:()=>em,boolean:()=>tm,browserEmail:()=>v$,cidrv4:()=>Up,cidrv6:()=>Zp,creditCard:()=>wu,cuid:()=>xp,cuid2:()=>Tp,currencyCode:()=>Kp,date:()=>Wp,datetime:()=>Yp,domain:()=>Bp,duration:()=>Np,e164:()=>Jp,email:()=>Mp,emoji:()=>Lp,extendedDuration:()=>h$,guid:()=>Ap,hex:()=>im,hostname:()=>Hp,html5Email:()=>_$,httpProtocol:()=>ti,iban:()=>zu,idnEmail:()=>y$,integer:()=>ri,ipv4:()=>qp,ipv6:()=>jp,ksuid:()=>Cp,lowercase:()=>om,mac:()=>Dp,md5_base64:()=>$$,md5_base64url:()=>k$,md5_hex:()=>R$,nanoid:()=>Ip,nanoidOfLength:()=>Op,null:()=>rm,number:()=>nr,rfc5322Email:()=>b$,sha1_base64:()=>T$,sha1_base64url:()=>E$,sha1_hex:()=>x$,sha256_base64:()=>C$,sha256_base64url:()=>I$,sha256_hex:()=>P$,sha384_base64:()=>N$,sha384_base64url:()=>A$,sha384_hex:()=>O$,sha512_base64:()=>L$,sha512_base64url:()=>q$,sha512_hex:()=>M$,string:()=>Xp,time:()=>Gp,ulid:()=>Ep,undefined:()=>nm,unicodeEmail:()=>A_,uppercase:()=>sm,uuid:()=>nn,uuid4:()=>f$,uuid6:()=>g$,uuid7:()=>S$,xid:()=>Pp});var xp=/^[cC][0-9a-z]{6,}$/,Tp=/^[0-9a-z]+$/,Ep=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Pp=/^[0-9a-vA-V]{20}$/,Cp=/^[A-Za-z0-9]{27}$/,Ip=/^[a-zA-Z0-9_-]{21}$/;function Op(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Np=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,h$=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ap=/^([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})$/,nn=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)$/,f$=nn(4),g$=nn(6),S$=nn(7),Mp=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_$=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,b$=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,A_=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,y$=A_,v$=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,w$="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Lp(){return new RegExp(w$,"u")}var qp=/^(?:(?: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])$/,jp=/^(([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}|:))$/,Dp=e=>{let t=gt(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Up=/^((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])$/,Zp=/^(([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])$/,Vp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Fp=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Hp=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Bp=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,ti=/^https?$/,Jp=/^\+[1-9]\d{6,14}$/,wu=/^\d(?:[ -]?\d){11,18}$/,Kp=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,zu=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,M_="(?:(?:\\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 z$(e){return new RegExp(`^${e}$`)}var Wp=z$(M_);function kp(e){let 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 Gp(e){return new RegExp(`^${kp(e)}$`)}function Yp(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${kp({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${kp({precision:e.precision})}`:r;return new RegExp(`^${M_}T(?:${n})$`)}var Qp=/^[\s\S]{0,}$/,Xp=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},em=/^-?\d+n?$/,ri=/^-?\d+$/,nr=/^-?\d+(?:\.\d+)?$/,tm=/^(?:true|false)$/i,rm=/^null$/i;var nm=/^undefined$/i;var om=/^[^A-Z]*$/,sm=/^[^a-z]*$/,im=/^[0-9a-fA-F]*$/;function ni(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function oi(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var R$=/^[0-9a-fA-F]{32}$/,$$=ni(22,"=="),k$=oi(22),x$=/^[0-9a-fA-F]{40}$/,T$=ni(27,"="),E$=oi(27),P$=/^[0-9a-fA-F]{64}$/,C$=ni(43,"="),I$=oi(43),O$=/^[0-9a-fA-F]{96}$/,N$=ni(64,""),A$=oi(64),M$=/^[0-9a-fA-F]{128}$/,L$=ni(86,"=="),q$=oi(86);var pe=b("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),am=e=>{let t=e.value;return!iu(t)&&t.size!==void 0},cm=e=>{let t=e.value;return!iu(t)&&t.length!==void 0},Ru={number:"number",bigint:"bigint",object:"date"},ku=b("$ZodCheckLessThan",(e,t)=>{pe.init(e,t);let r=Ru[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:Ru[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xu=b("$ZodCheckGreaterThan",(e,t)=>{pe.init(e,t);let r=Ru[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:Ru[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),um=b("$ZodCheckMultipleOf",(e,t)=>{pe.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Us(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),lm=b("$ZodCheckNumberFormat",(e,t)=>{pe.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Fs[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),dm=b("$ZodCheckBigIntFormat",(e,t)=>{pe.init(e,t);let[r,n]=Hs[t.format];e._zod.check=o=>{let s=o.value;s<r&&o.issues.push({origin:"bigint",input:s,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),s>n&&o.issues.push({origin:"bigint",input:s,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),pm=b("$ZodCheckMaxSize",(e,t)=>{var r;pe.init(e,t),(r=e._zod.def).when??(r.when=am),e._zod.check=n=>{let o=n.value;o.size<=t.maximum||n.issues.push({origin:Js(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),mm=b("$ZodCheckMinSize",(e,t)=>{var r;pe.init(e,t),(r=e._zod.def).when??(r.when=am),e._zod.check=n=>{let o=n.value;o.size>=t.minimum||n.issues.push({origin:Js(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),hm=b("$ZodCheckSizeEquals",(e,t)=>{var r;pe.init(e,t),(r=e._zod.def).when??(r.when=am),e._zod.check=n=>{let o=n.value,s=o.size;if(s===t.size)return;let i=s>t.size;n.issues.push({origin:Js(o),...i?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),fm=b("$ZodCheckMaxLength",(e,t)=>{var r;pe.init(e,t),(r=e._zod.def).when??(r.when=cm),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?rn(o):s)<=t.maximum)return;let a=Ks(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),gm=b("$ZodCheckMinLength",(e,t)=>{var r;pe.init(e,t),(r=e._zod.def).when??(r.when=cm),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?rn(o):s)>=t.minimum)return;let a=Ks(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Sm=b("$ZodCheckLengthEquals",(e,t)=>{var r;pe.init(e,t),(r=e._zod.def).when??(r.when=cm),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?rn(o):s;if(i===t.length)return;let a=Ks(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),oo=b("$ZodCheckStringFormat",(e,t)=>{var r,n;pe.init(e,t),t.pattern?(r=e._zod).check??(r.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})}):(n=e._zod).check??(n.check=()=>{})}),_m=b("$ZodCheckRegex",(e,t)=>{oo.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),bm=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=om),oo.init(e,t)}),ym=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=sm),oo.init(e,t)}),vm=b("$ZodCheckIncludes",(e,t)=>{pe.init(e,t);let r=gt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,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})}}),wm=b("$ZodCheckStartsWith",(e,t)=>{pe.init(e,t);let r=new RegExp(`^${gt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),zm=b("$ZodCheckEndsWith",(e,t)=>{pe.init(e,t);let r=new RegExp(`.*${gt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function $u(e,t,r){e.issues.length&&t.issues.push(...Ye(r,e.issues))}var Rm=b("$ZodCheckProperty",(e,t)=>{pe.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(o=>$u(o,r,t.property));$u(n,r,t.property)}}),$m=b("$ZodCheckProperties",(e,t)=>{pe.init(e,t),Ws(e,Symbol.iterator,function*(){yield e});let r;e._zod.check=n=>{if(n.value==null){n.issues.push({expected:"object",code:"invalid_type",input:n.value,inst:e});return}r??(r=Reflect.ownKeys(t.shape).map(i=>[i,t.shape[i]]));let o=n.value,s;for(let[i,a]of r){let c=a._zod.run({value:o[i],issues:[]},{});c instanceof Promise?(s??(s=[]),s.push(c.then(u=>$u(u,n,i)))):$u(c,n,i)}if(s)return Promise.all(s).then(()=>{})}}),km=b("$ZodCheckMimeType",(e,t)=>{pe.init(e,t);let r=new Set(t.mime);e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),xm=b("$ZodCheckOverwrite",(e,t)=>{pe.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var on=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}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}let n=t.split(`
239
+ `).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
240
+ ${r.join(`
241
+ `)}
242
+ };`)(...Object.values(this.closed))}};var Tm={major:4,minor:6,patch:7};var X=b("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Tm;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let d=Ze(a),p;for(let h of c){if(h._zod.def.when){if(fp(a)||!h._zod.def.when(a))continue}else if(d)continue;let f=a.issues.length,S=h._zod.check(a);if(S instanceof Promise&&u?.async===!1)throw new Xe;if(p||S instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await S,a.issues.length!==f&&(Bs(a.issues,f,e),d||(d=Ze(a,f)))});else{if(a.issues.length===f)continue;Bs(a.issues,f,e),d||(d=Ze(a,f))}}return p?p.then(()=>a):a},i=(a,c,u)=>{if(Ze(a))return a.aborted=!0,a;let d=s(c,o,u);if(d instanceof Promise){if(u.async===!1)throw new Xe;return d.then(p=>e._zod.parse(p,u))}return e._zod.parse(d,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let d=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(p=>i(p,a,c)):i(d,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Xe;return u.then(d=>s(d,o,c))}return s(u,o,c)}}},{get"~standard"(){return Ws(this,"~standard",Iu(this))},set"~standard"(e){yr(this,"~standard",e)}}),X_=(e,t)=>e.issues.length?{issues:e.issues.map(r=>Qe(r,t,be()))}:{value:e.value};async function j$(e,t){let r={async:!0};return X_(await e._zod.run({value:t,issues:[]},r),r)}function Iu(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return X_(n,r)}catch{}return j$(e,t)},vendor:"zod",version:1}}var sn=b("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=t.pattern??Qp,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ue=b("$ZodStringFormat",(e,t)=>{oo.init(e,t),sn.init(e,t)}),Pm=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ap),ue.init(e,t)}),Cm=b("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=nn(n))}else t.pattern??(t.pattern=nn());ue.init(e,t)}),Im=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Mp),ue.init(e,t)}),Om=1,si=2;function Nm(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Ou(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Nm(e)||si:eb(e,t)}function eb(e,t){if(!t.normalize&&t.protocol?.source===ti.source&&!/^https?:\/\//i.test(e))return Om;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??si}return new URL(e)}catch{return si}}var D$=/[\t\n\r]/g;function ii(e){return e.replace(D$,"")}function Nu(e,t){return t.lastIndex=0,t.test(e.hostname)}function Au(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Am=b("$ZodURL",(e,t)=>{ue.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=Ou(n,t);if(o===Om){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===si){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=ii(n);return}t.hostname&&!Nu(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!Au(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:ii(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Mm=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Lp()),ue.init(e,t)}),Lm=b("$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?Ip:Op(t.length)),ue.init(e,t)}),qm=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xp),ue.init(e,t)}),jm=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Tp),ue.init(e,t)}),Dm=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ep),ue.init(e,t)}),Um=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Pp),ue.init(e,t)}),Zm=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Cp),ue.init(e,t)}),Vm=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Yp(t)),ue.init(e,t)}),Fm=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Wp),ue.init(e,t)}),Hm=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Gp(t)),ue.init(e,t)}),Bm=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Np),ue.init(e,t)}),Jm=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=qp),ue.init(e,t)}),U$=/^[0-9a-fA-F:.]+$/;function ai(e){return U$.test(e)?Nm(`http://[${e}]`):!1}var Km=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=jp),ue.init(e,t),e._zod.check=r=>{ai(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),Wm=b("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Dp(t.delimiter)),ue.init(e,t)}),Gm=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Up),ue.init(e,t)});function Mu(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:ai(r)}var Ym=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Zp),ue.init(e,t),e._zod.check=r=>{Mu(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function ci(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Lu=/^[0-9a-zA-Z+/]*={0,2}$/,Qm=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Lu),ue.init(e,t),e._zod.check=r=>{ci(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),ui=/^[A-Za-z0-9_-]*$/;function qu(e){if(!ui.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return ci(r)}var Xm=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ui),ue.init(e,t),e._zod.check=r=>{qu(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),eh=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Jp),ue.init(e,t)}),Z$=/[- ]/g;function V$(e){let t=e.length,r=1,n=0;for(;t;){let o=e.charCodeAt(--t)-48;r^=1,n+=r?[0,2,4,6,8,1,3,5,7,9][o]:o}return n%10===0}function ju(e){return wu.test(e)?V$(e.replace(Z$,"")):!1}var th=b("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=wu),ue.init(e,t),e._zod.check=r=>{ju(r.value)||r.issues.push({code:"invalid_format",format:"credit_card",input:r.value,inst:e,continue:!t.abort})}});function F$(e){let t=0,r=e.length;for(let n=4;n<r;n++){let o=e.charCodeAt(n);t=(o>=65?t*100+(o-55):t*10+(o-48))%97}for(let n=0;n<4;n++){let o=e.charCodeAt(n);t=(o>=65?t*100+(o-55):t*10+(o-48))%97}return t===1}function Du(e){return zu.test(e)?F$(e):!1}var rh=b("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=zu),ue.init(e,t),e._zod.check=r=>{Du(r.value)||r.issues.push({code:"invalid_format",format:"iban",input:r.value,inst:e,continue:!t.abort})}});function Uu(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var nh=b("$ZodJWT",(e,t)=>{ue.init(e,t),e._zod.check=r=>{Uu(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),oh=b("$ZodCustomStringFormat",(e,t)=>{ue.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),Zu=b("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=nr,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),sh=b("$ZodNumberFormat",(e,t)=>{lm.init(e,t),Zu.init(e,t)}),li=b("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=tm,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),Vu=b("$ZodBigInt",(e,t)=>{X.init(e,t),e._zod.pattern=em,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),ih=b("$ZodBigIntFormat",(e,t)=>{dm.init(e,t),Vu.init(e,t)}),ah=b("$ZodSymbol",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),r}}),ch=b("$ZodUndefined",(e,t)=>{X.init(e,t),e._zod.pattern=nm,e._zod.values=new Set([void 0]),e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),r}}),uh=b("$ZodNull",(e,t)=>{X.init(e,t),e._zod.pattern=rm,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),lh=b("$ZodAny",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),dh=b("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),ph=b("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),mh=b("$ZodVoid",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),r}}),hh=b("$ZodDate",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,s=o instanceof Date;return s&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...s?{received:"Invalid Date"}:{},inst:e}),r}});function fh(e,t){let r=Qn(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map(s=>s[0])),o=e._zod.parse;e._zod.parse=(s,i)=>{let a=t(s.value);if(a>n&&!i?.skipChecks&&i?.direction!=="backward"){for(let[c,u]of Qn(e._zod.def.checks))if(a>c&&u._zod.def.when(s)){let d=s.issues.length;return u._zod.check(s),s.issues[d].continue=!1,Bs(s.issues,d,e),s}}return o(s,i)}}var H$=e=>Array.isArray(e)?e.length:-1,B$=e=>e instanceof Map?e.size:-1,J$=e=>e instanceof Set?e.size:-1;function q_(e,t,r){e.issues.length&&t.issues.push(...Ye(r,e.issues)),t.value[r]=e.value}var gh=b("$ZodArray",(e,t)=>{X.init(e,t);let r=Re.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],d=t.element._zod.run({value:u,issues:[]},o);if(d instanceof Promise)i.push(d.then(p=>q_(p,n,c)));else if(q_(d,n,c),a&&d.issues.length!==0&&Ze(d))break}return i.length?Promise.all(i).then(()=>n):n},fh(e,H$)});function Cu(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...Ye(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var K$=[];function tb(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:K$,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=hp(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function rb(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,d=u.def.type,p=u.optin,h=u.optout,f=0;for(let S in t){if(i&&r.issues.length!==f){if(Ze(r,f))break;f=r.issues.length}if(c.has(S))continue;if(S==="__proto__"){d==="never"&&a.push(S);continue}if(d==="never"){a.push(S);continue}let _=u.run({value:t[S],issues:[]},n);_ instanceof Promise?e.push(_.then(w=>Cu(w,r,S,t,p,h))):Cu(_,r,S,t,p,h)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var nb=b("$ZodObject",(e,t)=>{X.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let d={...n};return Object.defineProperty(t,"shape",{value:d}),u.raw=d,d};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=Gn(()=>tb(t));ne(e,"propValues",u=>{let d=u.def.shape,p={};for(let h in d){let f=d[h]._zod;if(f.values){Object.prototype.hasOwnProperty.call(p,h)||xe(p,h,new Set);for(let S of f.values)p[h].add(S);f.optin!==void 0&&p[h].add(void 0)}}return p});let s=tn,i=t.catchall,a,c=Re.memoizer;c?.attach(e),e._zod.parse=(u,d)=>{a??(a=o.value);let p=u.value;if(!s(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},d):{};let h=[],f=a.shape,S=d?.abortEarly,_=u.issues.length;for(let w of a.allKeys){if(S&&u.issues.length!==_){if(Ze(u,_))break;_=u.issues.length}if(w==="__proto__")continue;let x=f[w],R=x._zod.optin,k=x._zod.optout,J=x._zod.run({value:p[w],issues:[]},d);J instanceof Promise?h.push(J.then(se=>Cu(se,u,w,p,R,k))):Cu(J,u,w,p,R,k)}return i?rb(h,p,u,d,o.value,e,S===!0):h.length?Promise.all(h).then(()=>u):u}}),Sh=b("$ZodObjectJIT",(e,t)=>{nb.init(e,t);let r=e._zod.parse,n=Gn(()=>tb(t)),o=Re.memoizer,s=f=>{let S=n.value,_=S.symbolKeys,w=new on(["payload","ctx"],{shape:f,inst:e,memo:o,syms:_}),x=se=>`shape[${se}]._zod.run({ value: input[${se}], issues: [] }, ctx)`,R=(se,U)=>`
243
+ let ${se}_ab = false;
244
+ for (let i = 0; i < ${se}.issues.length; i++) {
245
+ const iss = ${se}.issues[i];
246
+ iss.path = iss.path ? [${U}, ...iss.path] : [${U}];
247
+ payload.issues.push(iss);
248
+ if (iss.continue !== true) ${se}_ab = true;
249
+ }
250
+ if (${se}_ab && ctx && ctx.abortEarly) {
251
+ payload.value = newResult;
252
+ return payload;
253
+ }`;w.write("const input = payload.value;");let k=Object.create(null),J=0;for(let se of S.allKeys)k[se]=`key_${J++}`;w.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let se of S.allKeys){if(se==="__proto__")continue;let U=k[se],ie=typeof se=="symbol"?`syms[${_.indexOf(se)}]`:Ue(se),Pe=`${ie} in input`,he=f[se],Ce=he?._zod?.optin,Je=Ce!==void 0,Tt=he?._zod?.optout==="optional";if(w.write(`const ${U} = ${x(ie)};`),Je&&Tt){let Et=Ce==="optional"?`${U}_present`:`${U}.value !== undefined || ${U}_present`;w.write(`
254
+ const ${U}_present = ${Pe};
255
+ if (!${U}.issues.length || ${U}_present) {
256
+ if (${U}.issues.length) {${R(U,ie)}
257
+ }
258
+
259
+ if (${Et}) {
260
+ newResult[${ie}] = ${U}.value;
261
+ }
262
+ }
263
+
264
+ `)}else Je?(w.write(`
265
+ if (${U}.issues.length) {${R(U,ie)}
266
+ }
267
+ `),Ce==="defaulted"?w.write(`newResult[${ie}] = ${U}.value;`):w.write(`
268
+ if (${U}.value !== undefined || ${Pe}) {
269
+ newResult[${ie}] = ${U}.value;
270
+ }
271
+ `)):w.write(`
272
+ const ${U}_present = ${Pe};
273
+ if (${U}.issues.length) {${R(U,ie)}
274
+ }
275
+ if (!${U}_present && !${U}.issues.length) {
276
+ payload.issues.push({
277
+ code: "invalid_type",
278
+ expected: "nonoptional",
279
+ input: undefined,
280
+ path: [${ie}]
281
+ });
282
+ if (ctx && ctx.abortEarly) {
283
+ payload.value = newResult;
284
+ return payload;
285
+ }
286
+ }
287
+
288
+ if (${U}_present) {
289
+ newResult[${ie}] = ${U}.value;
290
+ }
291
+
292
+ `)}return w.write("payload.value = newResult;"),w.write("return payload;"),w.compile()},i,a=tn,c=!Re.jitless,d=c&&pp.value,p=t.catchall,h;e._zod.parse=(f,S)=>{h??(h=n.value);let _=f.value;return a(_)?c&&d&&S?.async===!1&&S.jitless!==!0?(i||(i=s(t.shape)),f=i(f,S),p?rb([],_,f,S,h,e,S?.abortEarly===!0):f):r(f,S):(f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f)}});function j_(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!Ze(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>Qe(i,n,be())))}),t)}var di=b("$ZodUnion",(e,t)=>{X.init(e,t),ne(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),ne(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),ne(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),ne(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>rr(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>j_(a,n,e,o)):j_(i,n,e,o)}});function D_(e,t,r,n){let o=[];for(let s=0;s<e.length;s++)e[s].issues.length===0&&o.push(s);return o.length===1?(t.value=e[o[0]].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>Qe(i,n,be())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1,matches:o}),t)}var _h=b("$ZodXor",(e,t)=>{di.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);c instanceof Promise?(i.push(c),s=!0):i.push(c)}return s?Promise.all(i).then(a=>D_(a,n,e,o)):D_(i,n,e,o)}});function bh(e,t){let r=e._zod,n=r.bag.optionsMap;n||(n=ob(r.def),r.bag.optionsMap=n);let o=n.get(t);if(o===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return o}function ob(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var yh=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,di.init(e,t);let r=e._zod.parse;ne(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let 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)&&i++;for(let[u,d]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||xe(s,u,new Set);for(let p of d)s[u].add(p)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=Yn(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=Gn(()=>ob(t));e._zod.parse=(o,s)=>{let i=o.value;if(!tn(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),vh=b("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>U_(r,c,u)):U_(r,s,i)}});function so(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(ft(e)&&ft(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=so(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=so(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function U_(e,t,r){let n=new Map,o,s=new Map,i=(u,d)=>{let p;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),p=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let h=String(u.path[0]);s.has(h)||s.set(h,u),p=[h]}else return!1;for(let h of p)n.has(h)||n.set(h,{}),n.get(h)[d]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(d=>o.keys.includes(d)):[];u.length&&e.issues.push({...o,keys:u});for(let d of a)!u.includes(d)&&s.has(d)&&e.issues.push(s.get(d))}let c=so(t.value,r.value);if(!c.valid){if(Ze(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Fu=b("$ZodTuple",(e,t)=>{X.init(e,t);let r=t.items,n=Re.memoizer;n?.attach(e),e._zod.parse=(o,s)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=n?n.alloc(e,o,[],s):[];let a=[],c=Z_(r,"optin"),u=Z_(r,"optout");if(!t.rest){if(i.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:i,inst:e,origin:"array"}),o;i.length>r.length&&o.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:i,inst:e,origin:"array"})}let d=new Array(r.length),p=t.rest?s?.abortEarly:void 0,h=!1;for(let f=0;f<r.length;f++){let S=r[f]._zod.run({value:i[f],issues:[]},s);S instanceof Promise?a.push(S.then(_=>{d[f]=_})):(d[f]=S,p&&!h&&S.issues.length&&(h=Ze(S)))}if(t.rest&&!h){let f=r.length-1,S=i.slice(r.length),_=o.issues.length;for(let w of S){if(p&&o.issues.length!==_){if(Ze(o,_))break;_=o.issues.length}f++;let x=t.rest._zod.run({value:w,issues:[]},s);x instanceof Promise?a.push(x.then(R=>V_(R,o,f))):V_(x,o,f)}}return a.length?Promise.all(a).then(()=>F_(d,o,r,i,u)):F_(d,o,r,i,u)}});function Z_(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function V_(e,t,r){e.issues.length&&t.issues.push(...Ye(r,e.issues)),t.value[r]=e.value}function F_(e,t,r,n,o){for(let s=0;s<r.length;s++){let i=e[s],a=s<n.length;if(!a&&s>=o&&r[s]._zod.optin==="optional"){t.value.length=s;break}if(i.issues.length){if(!a&&s>=o){t.value.length=s;break}t.issues.push(...Ye(s,i.issues))}t.value[s]=i.value}for(let s=t.value.length-1;s>=n.length&&(r[s]._zod.optout==="optional"&&t.value[s]===void 0);s--)t.value.length=s;return t}var wh=b("$ZodRecord",(e,t)=>{X.init(e,t);let r=Re.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!ft(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let d of a)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){if(c.add(typeof d=="number"?d.toString():d),d==="__proto__")continue;let p=t.keyType._zod.run({value:d,issues:[]},o);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(S=>Qe(S,o,be())),input:d,path:[d],inst:e});continue}let h=p.value;if(h==="__proto__")continue;let f=t.valueType._zod.run({value:s[d],issues:[]},o);f instanceof Promise?i.push(f.then(S=>{S.issues.length&&n.issues.push(...Ye(d,S.issues)),n.value[h]=S.value})):(f.issues.length&&n.issues.push(...Ye(d,f.issues)),n.value[h]=f.value)}let u;for(let d in s)if(!c.has(d))if(t.mode==="loose"){if(d==="__proto__")continue;n.value[d]=s[d]}else u=u??[],u.push(d);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let d=t.keyType._zod.run({value:u,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&nr.test(u)&&d.issues.length){let S=t.keyType._zod.run({value:Number(u),issues:[]},o);if(S instanceof Promise)throw new Error("Async schemas not supported in object keys currently");S.issues.length===0&&(d=S)}if(d.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(S=>Qe(S,o,be())),input:u,path:[u],inst:e});continue}let h=d.value;if(h==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},o);f instanceof Promise?i.push(f.then(S=>{S.issues.length&&n.issues.push(...Ye(u,S.issues)),n.value[h]=S.value})):(f.issues.length&&n.issues.push(...Ye(u,f.issues)),n.value[h]=f.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}}),zh=b("$ZodMap",(e,t)=>{X.init(e,t);let r=Re.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!(s instanceof Map))return n.issues.push({expected:"map",code:"invalid_type",input:s,inst:e}),n;let i=[];n.value=r?r.alloc(e,n,new Map,o):new Map;let a=o?.abortEarly,c=n.issues.length;for(let[u,d]of s){if(a&&n.issues.length!==c){if(Ze(n,c))break;c=n.issues.length}let p=t.keyType._zod.run({value:u,issues:[]},o),h=t.valueType._zod.run({value:d,issues:[]},o);p instanceof Promise||h instanceof Promise?i.push(Promise.all([p,h]).then(([f,S])=>{H_(f,S,n,u,s,e,o)})):H_(p,h,n,u,s,e,o)}return i.length?Promise.all(i).then(()=>n):n},fh(e,B$)});function H_(e,t,r,n,o,s,i){e.issues.length&&(Vs.has(typeof n)?r.issues.push(...Ye(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:o,inst:s,issues:e.issues.map(a=>Qe(a,i,be()))})),t.issues.length&&(Vs.has(typeof n)?r.issues.push(...Ye(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:o,inst:s,key:n,issues:t.issues.map(a=>Qe(a,i,be()))})),r.value.set(e.value,t.value)}var Rh=b("$ZodSet",(e,t)=>{X.init(e,t);let r=Re.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!(s instanceof Set))return n.issues.push({input:s,inst:e,expected:"set",code:"invalid_type"}),n;let i=[];n.value=r?r.alloc(e,n,new Set,o):new Set;let a=o?.abortEarly,c=n.issues.length;for(let u of s){if(a&&n.issues.length!==c){if(Ze(n,c))break;c=n.issues.length}let d=t.valueType._zod.run({value:u,issues:[]},o);d instanceof Promise?i.push(d.then(p=>B_(p,n))):B_(d,n)}return i.length?Promise.all(i).then(()=>n):n},fh(e,J$)});function B_(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var $h=b("$ZodEnum",(e,t)=>{X.init(e,t);let r=Kn(t.entries),n=new Set(r);e._zod.values=n,ne(e,"pattern",o=>{let s=Kn(o.def.entries).filter(i=>Vs.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>gt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),kh=b("$ZodLiteral",(e,t)=>{X.init(e,t);let r=new Set(t.values);e._zod.values=r,ne(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?gt(s):s?gt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}}),xh=b("$ZodFile",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return o instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:o,inst:e}),r}}),Th=b("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.optin="optional",Re.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new vr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new Xe;return r.value=o,r}});function J_(e,t){return e.value=t.issues.length?void 0:t.value,e}var Hu=b("$ZodOptional",(e,t)=>{X.init(e,t),ne(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",ne(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),ne(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${rr(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>J_(r,s)):J_(r,o)}return t.innerType._zod.run(r,n)}}),Eh=b("$ZodExactOptional",(e,t)=>{Hu.init(e,t),ne(e,"values",r=>r.def.innerType._zod.values),ne(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Ph=b("$ZodNullable",(e,t)=>{X.init(e,t),ne(e,"optin",r=>r.def.innerType._zod.optin),ne(e,"optout",r=>r.def.innerType._zod.optout),ne(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${rr(n.source)}|null)$`):void 0}),ne(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Ch=b("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="defaulted",ne(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>K_(s,t)):K_(o,t)}});function K_(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ih=b("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="defaulted",ne(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Oh=b("$ZodNonOptional",(e,t)=>{X.init(e,t),ne(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>W_(s,e)):W_(o,e)}});function W_(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Nh=b("$ZodSuccess",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new vr("ZodSuccess");let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.issues.length===0,r)):(r.value=o.issues.length===0,r)}});function G_(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Qe(o,n,be()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Ah=b("$ZodCatch",(e,t)=>{X.init(e,t),ne(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),ne(e,"optout",r=>r.def.innerType._zod.optout),ne(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>G_(r,s,t,n)):G_(r,o,t,n)}}),Mh=b("$ZodNaN",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),Bu=b("$ZodPipe",(e,t)=>{X.init(e,t),ne(e,"values",r=>r.def.in._zod.values),ne(e,"optin",r=>r.def.in._zod.optin),ne(e,"optout",r=>r.def.out._zod.optout),ne(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Tu(i,t.in,n)):Tu(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Tu(s,t.out,n)):Tu(o,t.out,n)}});function Tu(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var pi=b("$ZodCodec",(e,t)=>{X.init(e,t),ne(e,"values",r=>r.def.in._zod.values),ne(e,"optin",r=>r.def.in._zod.optin),ne(e,"optout",r=>r.def.out._zod.optout),ne(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let s=t.in._zod.run(r,n);return s instanceof Promise?s.then(i=>Eu(i,t,n)):Eu(s,t,n)}else{let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Eu(i,t,n)):Eu(s,t,n)}}});function Eu(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let o=t.transform(e.value,e);return o instanceof Promise?o.then(s=>Pu(e,s,t.out,r)):Pu(e,o,t.out,r)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(s=>Pu(e,s,t.in,r)):Pu(e,o,t.in,r)}}function Pu(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}var Lh=b("$ZodPreprocess",(e,t)=>{Bu.init(e,t)}),qh=b("$ZodReadonly",(e,t)=>{X.init(e,t),ne(e,"propValues",r=>r.def.innerType._zod.propValues),ne(e,"values",r=>r.def.innerType._zod.values),ne(e,"optin",r=>r.def.innerType?._zod?.optin),ne(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Y_):Y_(o)}});function Y_(e){return e.memo||(e.value=Object.freeze(e.value)),e}function W$(e){let t=e._zod.def,r=t.pattern,n=!!t.format?.includes("int"),o,s;for(let a of t.checks??[]){let c=a._zod.def;c.pattern&&(r=c.pattern),n||(n=!!c.format?.includes("int"));let u=c.minimum??c.length,d=c.maximum??c.length;u!==void 0&&(o===void 0||u>o)&&(o=u),d!==void 0&&(s===void 0||d<s)&&(s=d)}if(r)return r.source;if(o!==void 0&&s!==void 0&&o>s)return"(?!)";if(o!==void 0||s!==void 0)return Xp({minimum:o,maximum:s}).source;let i=e._zod.pattern;return(n&&i===nr?ri:i)?.source}function Em(e){let t=e._zod.def,r=e._zod.pattern?.source,n=t.innerType??e._zod.innerType;if(n){let o=n._zod.pattern?.source,s=Em(n);return r&&o&&s&&s!==o?r.replace(rr(o),()=>rr(s)):r}if(t.options){let o=t.options.map(Em);if(o.every(Boolean))return`^(${o.map(s=>rr(s)).join("|")})$`}return W$(e)}var jh=b("$ZodTemplateLiteral",(e,t)=>{X.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){let o=Em(n);if(!o)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);r.push(rr(o))}else if(n===null||mp.has(typeof n))r.push(gt(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,o)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),Dh=b("$ZodFunction",(e,t)=>(X.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...n){let o=e._def.input?pu(e._def.input,n):n,s=Reflect.apply(r,this,o);return e._def.output?pu(e._def.output,s):s},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...n){let o=e._def.input?await mu(e._def.input,n):n,s=await Reflect.apply(r,this,o);return e._def.output?await mu(e._def.output,s):s},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(r,n)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new Fu({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),Uh=b("$ZodPromise",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(o=>t.innerType._zod.run({value:o,issues:[]},n))}),mi=b("$ZodLazy",(e,t)=>{X.init(e,t),lp(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),ne(e,"pattern",r=>r.innerType?._zod?.pattern),ne(e,"propValues",r=>r.innerType?._zod?.propValues),ne(e,"optin",r=>r.innerType?._zod?.optin??void 0),ne(e,"optout",r=>r.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),Zh=b("$ZodCustom",(e,t)=>{pe.init(e,t),X.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Q_(s,r,n,e));Q_(o,r,n,e)}});function Q_(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Xn(o))}}var Gu=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},Fh="~memo",ib=[];function ab(e){return e!==null&&typeof e=="object"}function Vh(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var cb=new WeakMap,io=0,Wu=1,hi=2;function fi(e,t,r){let n=cb.get(e);if(n!==void 0)return n?hi:io;if(t.has(e))return hi;t.add(e);let o=io,s=d=>{if(o!==hi&&d?._zod){let p=fi(d,t,r);p>o&&(o=p)}},i=(d,p)=>{let h=io;for(let f of Reflect.ownKeys(d)){let S=Object.getOwnPropertyDescriptor(d,f);if(p&&!S.enumerable)continue;let _=S.get?Wu:S.value?._zod?fi(S.value,t,r):io;_>h&&(h=_)}return h},a=d=>{d>o&&(o=d)},c=e._zod.def,u=c.type;switch(u){case"object":{let d=Yn(c);a(d?i(d,!0):Wu),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let d of c.items)s(d);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let d of c.options)s(d);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let d=c._cachedInner??(r?e._zod.innerType:void 0);a(d?fi(d,t,!1):Wu);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let d in c){let p=Object.getOwnPropertyDescriptor(c,d);if(!p||p.get)continue;let h=p.value;if(!(!h||typeof h!="object")){if(h._zod)s(h);else if(Array.isArray(h))for(let f of h)s(f)}}}return t.delete(e),G$(e,o)}function G$(e,t){return t!==Wu&&cb.set(e,t===hi),t}function Yu(e){return fi(e,new Set,!0)!==io}function Y$(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var Ju,Ku=[],Q$={alloc(e,t,r){let n=Ju;if(!n)return r;Ju=void 0;let o={value:r,issues:null};return n.set(t.value,o),Ku.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&Qu(s,o.value))throw new Gu;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let x=fi(e,new Set,!1);if(x===io)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);x===hi||n?r=!0:n=!0}let d=c.value;if(!ab(d))return i(c,u);let p=u[Fh];p||(p={buckets:new WeakMap,backEdges:void 0},u[Fh]=p);let h;o===u?h=s:(h=Y$(p,e),o=u,s=h);let f=h.get(d);if(f)return c.value=f.value,f.issues?f.issues.length&&c.issues.push(...Vh(f.issues)):(c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(f.value)),c;Ju=h;let S=Ku.length,_=i(c,u);Ju=void 0;let w=Ku.length>S?Ku.pop():void 0;return _ instanceof Promise?_.then(x=>(w&&(w.issues=x.issues.length?Vh(x.issues):ib),x)):(w&&(w.issues=_.issues.length?Vh(_.issues):ib),_)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function gi(){return Q$}function Qu(e,t){let r=e[Fh]?.backEdges;return r!==void 0&&ab(t)&&r.has(t)}var Si={};er(Si,{ar:()=>ub,az:()=>lb,be:()=>db,bg:()=>pb,bn:()=>mb,ca:()=>hb,ckb:()=>fb,cs:()=>gb,da:()=>Sb,de:()=>_b,el:()=>bb,en:()=>Xu,eo:()=>yb,es:()=>vb,fa:()=>wb,fi:()=>zb,fr:()=>Rb,frCA:()=>$b,gu:()=>kb,he:()=>xb,hi:()=>Tb,hr:()=>Eb,hu:()=>Pb,hy:()=>Cb,id:()=>Ib,is:()=>Ob,it:()=>Nb,ja:()=>Ab,ka:()=>Mb,kh:()=>Lb,km:()=>qb,kn:()=>jb,ko:()=>Db,lt:()=>Ub,mk:()=>Zb,ms:()=>Vb,ne:()=>Fb,nl:()=>Hb,nn:()=>Bb,no:()=>Jb,ota:()=>Kb,pl:()=>Gb,ps:()=>Wb,pt:()=>Yb,ptBR:()=>Qb,ro:()=>Xb,ru:()=>ey,sk:()=>ty,sl:()=>ry,sv:()=>ny,ta:()=>oy,tg:()=>sy,th:()=>iy,tk:()=>ay,tr:()=>cy,ua:()=>uy,uk:()=>ly,ur:()=>dy,uz:()=>py,vi:()=>my,yo:()=>gy,zhCN:()=>hy,zhTW:()=>fy});function ub(){return{localeError:()=>{}}}function lb(){return{localeError:()=>{}}}function db(){return{localeError:()=>{}}}function pb(){return{localeError:()=>{}}}function mb(){return{localeError:()=>{}}}function hb(){return{localeError:()=>{}}}function fb(){return{localeError:()=>{}}}function gb(){return{localeError:()=>{}}}function Sb(){return{localeError:()=>{}}}function _b(){return{localeError:()=>{}}}function bb(){return{localeError:()=>{}}}var X$=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let r={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"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=gp(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${cu(s.values[0])}`:`Invalid option: expected one of ${su(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${su(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Xu(){return{localeError:X$()}}function yb(){return{localeError:()=>{}}}function vb(){return{localeError:()=>{}}}function wb(){return{localeError:()=>{}}}function zb(){return{localeError:()=>{}}}function Rb(){return{localeError:()=>{}}}function $b(){return{localeError:()=>{}}}function kb(){return{localeError:()=>{}}}function xb(){return{localeError:()=>{}}}function Tb(){return{localeError:()=>{}}}function Eb(){return{localeError:()=>{}}}function Pb(){return{localeError:()=>{}}}function Cb(){return{localeError:()=>{}}}function Ib(){return{localeError:()=>{}}}function Ob(){return{localeError:()=>{}}}function Nb(){return{localeError:()=>{}}}function Ab(){return{localeError:()=>{}}}function Mb(){return{localeError:()=>{}}}function Lb(){return{localeError:()=>{}}}function qb(){return{localeError:()=>{}}}function jb(){return{localeError:()=>{}}}function Db(){return{localeError:()=>{}}}function Ub(){return{localeError:()=>{}}}function Zb(){return{localeError:()=>{}}}function Vb(){return{localeError:()=>{}}}function Fb(){return{localeError:()=>{}}}function Hb(){return{localeError:()=>{}}}function Bb(){return{localeError:()=>{}}}function Jb(){return{localeError:()=>{}}}function Kb(){return{localeError:()=>{}}}function Wb(){return{localeError:()=>{}}}function Gb(){return{localeError:()=>{}}}function Yb(){return{localeError:()=>{}}}function Qb(){return{localeError:()=>{}}}function Xb(){return{localeError:()=>{}}}function ey(){return{localeError:()=>{}}}function ty(){return{localeError:()=>{}}}function ry(){return{localeError:()=>{}}}function ny(){return{localeError:()=>{}}}function oy(){return{localeError:()=>{}}}function sy(){return{localeError:()=>{}}}function iy(){return{localeError:()=>{}}}function ay(){return{localeError:()=>{}}}function cy(){return{localeError:()=>{}}}function uy(){return{localeError:()=>{}}}function ly(){return{localeError:()=>{}}}function dy(){return{localeError:()=>{}}}function py(){return{localeError:()=>{}}}function my(){return{localeError:()=>{}}}function hy(){return{localeError:()=>{}}}function fy(){return{localeError:()=>{}}}function gy(){return{localeError:()=>{}}}var Sy,Hh=Symbol("ZodOutput"),Bh=Symbol("ZodInput"),el=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...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 tl(){return new el}(Sy=globalThis).__zod_globalRegistry??(Sy.__zod_globalRegistry=tl());var Te=globalThis.__zod_globalRegistry;var Ve=Symbol.for("zod.compile.invalid"),_y=Symbol.for("zod.compile.fallback"),zt=class extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}},oe=class extends Error{constructor(t,r=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=r}};function tk(e,t){try{return nl(e,{assertOnly:!0})}catch{return t}}function Gh(e,t){try{let r=nl(e),n=rl(e,r);return n._zod.bag.validator=tk(e,r),n}catch(r){if(t?.strict)throw r;return e}}function rl(e,t){if(Yu(e))throw new oe("a schema whose subtree contains a reference cycle");let r=ce(e),n=e._zod.run,o=n.__originalRun??n,s=(i,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[_y]||a&&Qu(a,i.value))return o(i,a);let c=t(i.value);return c!==Ve?(i.value=c,i):(a&&(a[_y]=!0),o(i,a))};return s.__originalRun=o,r._zod.bag.fallbackRun=o,r._zod.bag.validator=t,r._zod.run=s,n.__originalRun||rk(r,e,t),r}function rk(e,t,r){let n=e,o=t;if(typeof o.safeParse=="function"){let s=o.safeParse;n.safeParse=(i,a)=>{let c=r(i);return c!==Ve?{success:!0,data:c}:s(i,a)}}if(typeof o.parse=="function"){let s=o.parse;n.parse=(i,a)=>{let c=r(i);return c!==Ve?c:s(i,a)}}}function nl(e,t){let r=!0;try{r=Yu(e)}catch{}if(r)throw new oe("a schema whose subtree contains a reference cycle");let n={constants:new Map,constantCounter:0,varCounter:0,definite:!0},o=new on(["input"]),s=me(o,n,e,"input",!t?.assertOnly);o.write(s===null?"return true;":`return ${s};`);let i=["INVALID",...n.constants.keys()],a=[Ve,...n.constants.values()],c=o.content.join(`
293
+ `),u=t?.debug?i.length>0?`// Constants: ${i.join(", ")}
294
+ ${c}`:c:"",d=Function,p=`return (input) => {
295
+ ${c}
296
+ }`,h;try{h=new d(...i,p)(...a)}catch(f){throw new oe(`this schema (generated code failed to evaluate: ${f.message})`)}return t?.debug&&(h.code=u),h.definite=n.definite,h}function Q(e,t){for(let[n,o]of e.constants)if(o===t)return n;let r=`c${e.constantCounter++}`;return e.constants.set(r,t),r}function cn(e,t){return e.definite=!1,Q(e,t)}function B(e){return`v${e.varCounter++}`}function nk(e,t){let r=e._zod.run({value:t,issues:[]},{});if(r&&typeof r.then=="function")return Ve;let n=r;return n.issues.length===0?n.value:Ve}function Ae(e,t,r,n,o=!0){let s=e.content.length,i=t.constants.size,a=t.constantCounter,c=t.varCounter;try{return me(e,t,r,n,o)}catch(u){if(!(u instanceof oe)||!u.islandable)throw u;if(e.content.length=s,t.constants.size>i){let d=Array.from(t.constants.keys()).slice(i);for(let p of d)t.constants.delete(p)}return t.constantCounter=a,t.varCounter=c,ok(e,t,r,n)}}function ok(e,t,r,n){t.definite=!1;let o=Q(t,r),s=Q(t,nk),i=B(t);return e.write(`const ${i} = ${s}(${o}, ${n});`),e.write(`if (${i} === INVALID) return INVALID;`),i}var sk=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function ik(e,t,r,n){let o=r._zod.def.checks;if(!o||o.length===0)return n;let s=n;for(let i of o){let a=i._zod.def;if(a.when&&!sk.has(a.check))throw new oe('check with a custom "when" condition');switch(a.check){case"greater_than":ak(e,t,a,s);break;case"less_than":ck(e,t,a,s);break;case"multiple_of":uk(e,t,a,s);break;case"number_format":Ry(e,a,s);break;case"min_length":{let c=wr(a.minimum,"min_length"),u=Jh(e,t,s,`${s}.length >= ${c} && ${s}.length < ${a.minimum*2}`);e.write(`if (${u} < ${c}) return INVALID;`);break}case"max_length":{let c=wr(a.maximum,"max_length"),u=Jh(e,t,s,`${s}.length > ${c}`);e.write(`if (${u} > ${c}) return INVALID;`);break}case"length_equals":{let c=wr(a.length,"length_equals"),u=Jh(e,t,s,`${s}.length >= ${c} && ${s}.length <= ${a.length*2}`);e.write(`if (${u} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${s}.size < ${wr(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${s}.size > ${wr(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${s}.size !== ${wr(a.size,"size_equals")}) return INVALID;`);break;case"string_format":s=$y(e,t,a,s);break;case"custom":s=fk(e,t,i,s);break;case"bigint_format":lk(e,a,s);break;case"mime_type":dk(e,t,a,s);break;case"property":mk(e,t,a,s);break;case"properties":pk(e,t,a,s);break;case"overwrite":{let c=B(t);hk(e,t,i,s,c),s=c;break}default:throw new oe(`check type ${a.check}`)}}return s}function Jh(e,t,r,n){let o=Q(t,rn),s=B(t);return e.write(`const ${s} = typeof ${r} === "string" && ${n} ? ${o}(${r}) : ${r}.length;`),s}function wr(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new oe(`${t} bound of type ${typeof e}`);return`${e}`}function zy(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new oe("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new oe("comparison check with Invalid Date bound");return Q(e,t)}throw new oe(`comparison check bound of type ${typeof t}`)}function ak(e,t,r,n){let o=r.inclusive?"<":"<=";e.write(`if (${n} ${o} ${zy(t,r.value)}) return INVALID;`)}function ck(e,t,r,n){let o=r.inclusive?">":">=";e.write(`if (${n} ${o} ${zy(t,r.value)}) return INVALID;`)}function uk(e,t,r,n){if(typeof r.value=="bigint"){if(r.value===BigInt(0))throw new oe("multiple_of check with a zero divisor");e.write(`if (${n} % ${r.value}n !== 0n) return INVALID;`)}else{let o=Q(t,Us);e.write(`if (${o}(${n}, ${wr(r.value,"multiple_of")}) !== 0) return INVALID;`)}}function Ry(e,t,r){let n=t.format;switch(n){case"safeint":e.write(`if (!Number.isSafeInteger(${r})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${r}) || ${r} < -2147483648 || ${r} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${r}) || ${r} < 0 || ${r} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${r}) || ${r} < -3.4028234663852886e38 || ${r} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${r})) return INVALID;`);break;default:throw new oe(`number format ${n}`)}}function lk(e,t,r){let n=t.format;if(n)switch(n){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break;default:throw new oe(`bigint format ${n}`)}}function dk(e,t,r,n){let o=r.mime;if(o&&o.length>0){let s=Q(t,new Set(o));e.write(`if (!${s}.has(${n}.type)) return INVALID;`)}}function pk(e,t,r,n){if(r.when)throw new oe('check with a custom "when" condition');e.write(`if (${n} == null) return INVALID;`);let o=r.shape;for(let s of Reflect.ownKeys(o)){let i=typeof s=="symbol"?Q(t,s):Ue(s),a=B(t);e.write(`const ${a} = ${n}[${i}];`),Ae(e,t,o[s],a,!1)}}function mk(e,t,r,n){let o=`${n}[${JSON.stringify(r.property)}]`;me(e,t,r.schema,o)}function hk(e,t,r,n,o){let s=r._zod.def.tx;if(!s)throw new oe("overwrite check without a transform function");if(un(s))throw new zt("z.compile: async overwrite transforms are not supported");let i=Q(t,s);e.write(`const ${o} = ${i}(${n});`)}function Kh(){throw new Xe}function Yh(e){this.issues.push(e)}function fk(e,t,r,n){let o=r._zod.def;if(o.fn){if(un(o.fn))throw new zt("z.compile: async .refine() predicates are not supported");let s=cn(t,o.fn),i=Q(t,Kh),a=B(t);return e.write(`const ${a} = ${s}(${n});`),e.write(`if (${a} instanceof Promise) ${i}();`),e.write(`if (!${a}) return INVALID;`),n}if(r._zod.check){if(un(r._zod.check))throw new zt("z.compile: async .superRefine() / check functions are not supported");let s=r._zod.check,a=cn(t,u=>{let d={value:u,issues:[],addIssue:Yh};return s(d)instanceof Promise&&Kh(),d.issues.length===0?d.value:Ve}),c=B(t);return e.write(`const ${c} = ${a}(${n});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new oe("custom check without a predicate or check function")}var gk=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function $y(e,t,r,n,o=!0){let s=r.format;if(s==="base64"){let u=Q(t,ci);return e.write(`if (!${u}(${n})) return INVALID;`),n}if(s==="base64url"){let u=Q(t,qu);return e.write(`if (!${u}(${n})) return INVALID;`),n}if(s==="jwt"){let u=Q(t,Uu),d=Q(t,r.alg??null);return e.write(`if (!${u}(${n}, ${d})) return INVALID;`),n}if(s==="ipv6"){let u=Q(t,ai);return e.write(`if (!${u}(${n})) return INVALID;`),n}if(s==="cidrv6"){let u=Q(t,Mu);return e.write(`if (!${u}(${n})) return INVALID;`),n}if(s==="credit_card"){let u=Q(t,ju);return e.write(`if (!${u}(${n})) return INVALID;`),n}if(s==="iban"){let u=Q(t,Du);return e.write(`if (!${u}(${n})) return INVALID;`),n}let i=r;if(s==="url"||s==="httpurl"||i.normalize||i.hostname!==void 0||i.protocol!==void 0){let u=Q(t,Ou),d=Q(t,r),p=B(t),h=B(t);if(e.write(`const ${p} = ${n}.trim();`),e.write(`const ${h} = ${u}(${p}, ${d});`),e.write(`if (typeof ${h} === "number") return INVALID;`),i.hostname!==void 0){let _=Q(t,Nu);e.write(`if (!${_}(${h}, ${d}.hostname)) return INVALID;`)}if(i.protocol!==void 0){let _=Q(t,Au);e.write(`if (!${_}(${h}, ${d}.protocol)) return INVALID;`)}if(!o)return null;let f=B(t),S=i.normalize?`${h}.href`:`${Q(t,ii)}(${p})`;return e.write(`const ${f} = ${S};`),f}let a=r.fn;if(a){if(un(a))throw new oe(`async string format ${s}`);let u=Q(t,a);return e.write(`if (!${u}(${n})) return INVALID;`),n}if(gk.has(s)&&r.pattern){let u=Q(t,r.pattern);return e.write(`${u}.lastIndex = 0;`),e.write(`if (!${u}.test(${n})) return INVALID;`),n}let c=r.format;switch(c){case"regex":throw new oe("regex format without a pattern");case"lowercase":e.write(`if (${n} !== ${n}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${n} !== ${n}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${n}.includes(${Ue(r.includes)})) return INVALID;`);break;case"starts_with":{let u=r.prefix;e.write(`if (${n}.slice(0, ${u.length}) !== ${Ue(u)}) return INVALID;`);break}case"ends_with":{let u=r.suffix;e.write(`if (${n}.slice(-${u.length}) !== ${Ue(u)}) return INVALID;`);break}default:throw new oe(`string format ${c}`)}return n}function me(e,t,r,n,o=!0){let s=r._zod.def,i=s.type;if(s.coerce)throw new oe(`coercion (z.coerce.${i}())`);let a=o||!!s.checks?.length,c;switch(i){case"string":c=Sk(e,t,r,n,a);break;case"number":c=_k(e,r,n);break;case"boolean":c=bk(e,n);break;case"bigint":c=yk(e,r,n);break;case"symbol":c=vk(e,n);break;case"undefined":c=wk(e,n);break;case"null":c=zk(e,n);break;case"any":case"unknown":c=n;break;case"never":e.write("return INVALID;"),c=n;break;case"void":c=Rk(e,n);break;case"nan":c=$k(e,n);break;case"date":c=kk(e,n);break;case"object":c=xk(e,t,r,n,a);break;case"optional":c=Tk(e,t,r,n,a);break;case"nullable":c=Ck(e,t,r,n,a);break;case"array":c=Ik(e,t,r,n,a);break;case"literal":c=Ok(e,t,r,n);break;case"enum":c=Nk(e,t,r,n);break;case"readonly":{let u=yy(e,t,r,n),d=B(t);e.write(`const ${d} = Object.freeze(${u});`),c=d;break}case"success":yy(e,t,r,n),c="true";break;case"default":case"prefault":c=Ak(e,t,r,n);break;case"nonoptional":c=Mk(e,t,r,n);break;case"tuple":c=Lk(e,t,r,n);break;case"union":c=qk(e,t,r,n);break;case"intersection":c=Uk(e,t,r,n);break;case"record":c=Zk(e,t,r,n);break;case"map":c=Fk(e,t,r,n);break;case"set":c=Hk(e,t,r,n);break;case"file":c=Bk(e,n);break;case"template_literal":c=Jk(e,t,r,n);break;case"lazy":c=Kk(e,t,r,n);break;case"pipe":c=Wk(e,t,r,n);break;case"custom":c=Gk(e,t,r,n);break;case"transform":c=Xk(e,t,r,n);break;case"catch":c=Qk(e,t,r,n);break;default:throw new oe(`schema type ${i}`)}return c===null?null:ik(e,t,r,c)}function Sk(e,t,r,n,o=!0){e.write(`if (typeof ${n} !== "string") return INVALID;`);let s=r._zod.def;return s.format===void 0?n:$y(e,t,s,n,o)}function _k(e,t,r){e.write(`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return INVALID;`);let n=t._zod.def;return n.check==="number_format"&&n.format&&Ry(e,{format:n.format},r),r}function bk(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function yk(e,t,r){e.write(`if (typeof ${r} !== "bigint") return INVALID;`);let n=t._zod.def;if(n.format)switch(n.format){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break}return r}function vk(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function wk(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function zk(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function Rk(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function $k(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function kk(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function xk(e,t,r,n,o=!0){let s=r._zod.def;e.write(`if (typeof ${n} !== "object" || ${n} === null || Array.isArray(${n})) return INVALID;`);let i=s.shape,a=Object.keys(i),c=Object.getOwnPropertySymbols(i),u=c.length?[...a,...c]:a,d=R=>typeof R=="symbol"?Q(t,R):Ue(R),p=R=>typeof R=="symbol"?`[${d(R)}]`:Ue(R),h=i;if(a.includes("__proto__"))throw new oe('object shape key "__proto__"');let f=new Map;for(let R of u){let k=h[R],J=d(R),se=B(t);if(e.write(`const ${se} = ${n}[${J}];`),k._zod.optin!==void 0){let U=B(t);e.write(`let ${U} = (() => {`),e.indented(ie=>{let Pe=Ae(ie,t,k,se);ie.write(`return ${Pe};`)}),e.write("})();"),k._zod.optout==="optional"?(e.write(`if (${U} === INVALID) {`),e.indented(ie=>{ie.write(`if (${J} in ${n}) return INVALID;`),ie.write(`${U} = undefined;`)}),e.write("}")):e.write(`if (${U} === INVALID) return INVALID;`),f.set(R,U)}else{Pk(k)&&e.write(`if (!(${J} in ${n})) return INVALID;`);let U=Ae(e,t,k,se,o);U!==null&&f.set(R,U)}}let S=s.catchall,_="none";if(S){let R=S._zod.def.type;if(R==="never"){let k=a.map(J=>`k !== ${Ue(J)}`).join(" && ")||"true";e.write(`for (const k in ${n}) {`),e.indented(J=>{J.write(`if (${k}) return INVALID;`)}),e.write("}")}else(R==="unknown"||R==="any")&&!S._zod.def.checks?.length?_="passthrough":_="schema"}let w=B(t),x=u.some(R=>by(h[R])||Wh(h[R]));if(!o){if(_==="schema"){let R=a.length>0?Q(t,new Set(a)):null;e.write(`for (const k in ${n}) {`),e.indented(k=>{k.write('if (k === "__proto__") continue;'),R&&k.write(`if (${R}.has(k)) continue;`);let J=B(t);k.write(`const ${J} = ${n}[k];`),Ae(k,t,S,J,!1)}),e.write("}")}return null}if(x){e.write(`const ${w} = {};`);for(let R of u){let k=d(R),J=f.get(R);Wh(h[R])?e.write(`if (${k} in ${n}) ${w}[${k}] = ${J};`):by(h[R])?e.write(`if (${J} !== undefined || ${k} in ${n}) ${w}[${k}] = ${J};`):e.write(`${w}[${k}] = ${J};`)}}else{let R=u.map(k=>`${p(k)}: ${f.get(k)}`).join(", ");e.write(`const ${w} = { ${R} };`)}if(_!=="none"){let R=a.length>0?Q(t,new Set(a)):null;e.write(`for (const k in ${n}) {`),e.indented(k=>{if(k.write('if (k === "__proto__") continue;'),R&&k.write(`if (${R}.has(k)) continue;`),_==="passthrough")k.write(`${w}[k] = ${n}[k];`);else{let J=B(t);k.write(`const ${J} = ${n}[k];`);let se=Ae(k,t,S,J);k.write(`${w}[k] = ${se};`)}}),e.write("}")}return w}function Tk(e,t,r,n,o=!0){let s=r._zod.def;if(Ek(r))return me(e,t,s.innerType,n,o);if(s.innerType._zod.optin==="defaulted"){let a=B(t),c=B(t);return e.write(`let ${a};`),e.write(`if (${n} === undefined) {`),e.indented(u=>{u.write(`const ${c} = (() => {`),u.indented(d=>{let p=me(d,t,s.innerType,n);d.write(`return ${p};`)}),u.write("})();"),u.write(`if (${c} !== INVALID) ${a} = ${c};`)}),e.write("} else {"),e.indented(u=>{let d=me(u,t,s.innerType,n);u.write(`${a} = ${d};`)}),e.write("}"),a}let i=o?B(t):null;return i&&e.write(`let ${i};`),e.write(`if (${n} !== undefined) {`),e.indented(a=>{let c=me(a,t,s.innerType,n,o);i&&c!==null&&a.write(`${i} = ${c};`)}),e.write("}"),i}function Ek(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function Pk(e){return e._zod.optin===void 0&&an(e)}function an(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?an(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?an(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(an):!0;case"intersection":return!t.left||!t.right?!0:an(t.left)&&an(t.right);case"pipe":return t.in?an(t.in):!0;default:return!0}}function Wh(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function by(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&ao(e)}function ao(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?ao(t.innerType):!0;case"union":return t.options?t.options.some(ao):!0;case"intersection":return!t.left||!t.right||ao(t.left)||ao(t.right);case"pipe":return t.out?ao(t.out):!0;default:return!0}}function Ck(e,t,r,n,o=!0){let s=r._zod.def,i=o?B(t):null;return i&&e.write(`let ${i} = null;`),e.write(`if (${n} !== null) {`),e.indented(a=>{let c=me(a,t,s.innerType,n,o);i&&c!==null&&a.write(`${i} = ${c};`)}),e.write("}"),i}function Qh(e,t,r){for(let[n,o]of Qn(t._zod.def.checks))e.write(`if (${r} > ${wr(n,o._zod.def.check)}) return INVALID;`)}function Ik(e,t,r,n,o=!0){let s=r._zod.def;e.write(`if (!Array.isArray(${n})) return INVALID;`),Qh(e,r,`${n}.length`);let i=o?B(t):null,a=B(t),c=B(t);return i&&e.write(`const ${i} = new Array(${n}.length);`),e.write(`for (let ${a} = 0; ${a} < ${n}.length; ${a}++) {`),e.indented(u=>{u.write(`const ${c} = ${n}[${a}];`);let d=Ae(u,t,s.element,c,o);i&&d!==null&&u.write(`${i}[${a}] = ${d};`)}),e.write("}"),i}function Ok(e,t,r,n){let s=r._zod.def.values;if(s.length!==1){let a=Q(t,new Set(s));return e.write(`if (!${a}.has(${n})) return INVALID;`),n}let i=s[0];if(typeof i=="number"&&Number.isNaN(i)){let a=Q(t,new Set(s));return e.write(`if (!${a}.has(${n})) return INVALID;`),n}if(typeof i=="string")e.write(`if (${n} !== ${Ue(i)}) return INVALID;`);else if(typeof i=="number"||typeof i=="boolean")e.write(`if (${n} !== ${i}) return INVALID;`);else if(i===null)e.write(`if (${n} !== null) return INVALID;`);else if(i===void 0)e.write(`if (${n} !== undefined) return INVALID;`);else if(typeof i=="bigint")e.write(`if (${n} !== ${i}n) return INVALID;`);else throw new oe(`literal type ${typeof i}`);return n}function Nk(e,t,r,n){let o=r._zod.values;if(!o)throw new oe("enum schema without enumerated values");let s=Q(t,o);return e.write(`if (!${s}.has(${n})) return INVALID;`),n}function yy(e,t,r,n){let o=r._zod.def;return me(e,t,o.innerType,n)}function Ak(e,t,r,n){let o=r._zod.def,i=Object.getOwnPropertyDescriptor(r._zod.def,"defaultValue")?()=>r._zod.def.defaultValue:void 0;if(r._zod.def.type==="prefault"){if(!i)return me(e,t,o.innerType,n);let c=Q(t,i),u=B(t);return e.write(`let ${u} = ${n};`),e.write(`if (${n} === undefined) ${u} = ${c}();`),me(e,t,o.innerType,u)}let a=B(t);if(i){let c=Q(t,i),u=Q(t,Zs);e.write(`let ${a};`),e.write(`if (${n} === undefined) {`),e.indented(d=>{d.write(`${a} = ${u}(${c}());`)}),e.write("} else {"),e.indented(d=>{let p=me(d,t,o.innerType,n);d.write(`${a} = ${p} === undefined ? ${u}(${c}()) : ${p};`)}),e.write("}")}else e.write(`let ${a};`),e.write(`if (${n} !== undefined) {`),e.indented(c=>{let u=me(c,t,o.innerType,n);c.write(`${a} = ${u};`)}),e.write("}");return a}function Mk(e,t,r,n){let o=r._zod.def,s=me(e,t,o.innerType,n),i=B(t);return e.write(`const ${i} = ${s};`),e.write(`if (${i} === undefined) return INVALID;`),i}function Lk(e,t,r,n){let o=r._zod.def,s=o.items,i=o.rest;e.write(`if (!Array.isArray(${n})) return INVALID;`);let a=vy(s,"optin"),c=vy(s,"optout");i?e.write(`if (${n}.length < ${a}) return INVALID;`):e.write(`if (${n}.length < ${a} || ${n}.length > ${s.length}) return INVALID;`);let u=B(t);e.write(`const ${u} = [];`);for(let d=0;d<s.length;d++){let p=s[d];if(d>=c)e.write(`if (${u}.length === ${d}) {`),e.indented(h=>{h.write(`if (${d} < ${n}.length) {`),h.indented(f=>{let S=B(t);f.write(`const ${S} = ${n}[${d}];`);let _=Ae(f,t,p,S);f.write(`${u}[${d}] = ${_};`)}),h.write("} else {"),h.indented(f=>{if(Wh(p)){f.write(`${u}.length = ${d};`);return}let S=B(t),_=B(t);f.write(`const ${S} = undefined;`),f.write(`const ${_} = (() => {`),f.indented(w=>{let x=Ae(w,t,p,S);w.write(`return ${x};`)}),f.write("})();"),f.write(`if (${_} === INVALID || ${_} === undefined) ${u}.length = ${d};`),f.write(`else ${u}[${d}] = ${_};`)}),h.write("}")}),e.write("}");else{let h=B(t);e.write(`const ${h} = ${n}[${d}];`);let f=Ae(e,t,p,h);e.write(`${u}[${d}] = ${f};`)}}if(i){let d=B(t),p=B(t);e.write(`for (let ${d} = ${s.length}; ${d} < ${n}.length; ${d}++) {`),e.indented(h=>{h.write(`const ${p} = ${n}[${d}];`);let f=Ae(h,t,i,p);h.write(`${u}[${d}] = ${f};`)}),e.write("}")}return u}function vy(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function qk(e,t,r,n){let o=r._zod.def,s=o.options;if(o.discriminator)return jk(e,t,o,n);if(o.inclusive===!1)throw new oe("exclusive unions (z.xor)");if(s.length===0)return e.write("return INVALID;"),n;if(s.length===1)return me(e,t,s[0],n);if(s.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){let c=new Set(s.flatMap(d=>d._zod.def.values)),u=Q(t,c);return e.write(`if (!${u}.has(${n})) return INVALID;`),n}let a=B(t);e.write(`let ${a};`);for(let c=0;c<s.length;c++){let u=s[c];c===0?e.write(`${a} = (() => {`):e.write(`if (${a} === INVALID) ${a} = (() => {`),e.indented(d=>{let p=me(d,t,u,n);d.write(`return ${p};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function jk(e,t,r,n){if(r.unionFallback)throw new oe("discriminated union with unionFallback");if(r.options.length===0)return e.write("return INVALID;"),n;let o=B(t),s=B(t);e.write(`const ${o} = ${n}?.[${Ue(r.discriminator)}];`),e.write(`let ${s};`);let i=!0,a=new Set;for(let c of r.options){let u=c._zod.propValues?.[r.discriminator];if(!u||u.size===0)throw new oe("discriminated union option without static discriminator values");for(let h of u){if(a.has(h))throw new oe(`duplicate discriminator value ${String(h)}`);a.add(h)}let d=Array.from(u,h=>Dk(t,o,h)),p=i?"if":"else if";e.write(`${p} (${d.join(" || ")}) {`),e.indented(h=>{let f=me(h,t,c,n);h.write(`${s} = ${f};`)}),e.write("}"),i=!1}return e.write("else { return INVALID; }"),s}function Dk(e,t,r){if(typeof r=="string")return`${t} === ${Ue(r)}`;if(typeof r=="number")return Number.isNaN(r)?`Number.isNaN(${t})`:`${t} === ${r}`;if(typeof r=="boolean")return`${t} === ${r}`;if(r===null)return`${t} === null`;if(r===void 0)return`${t} === undefined`;if(typeof r=="bigint")return`${t} === ${r}n`;if(typeof r=="symbol"){let n=Q(e,r);return`${t} === ${n}`}throw new oe(`literal discriminator value ${String(r)}`)}function Uk(e,t,r,n){let o=r._zod.def;t.definite=!1;let s=Ae(e,t,o.left,n),i=Ae(e,t,o.right,n),a=Q(t,so),c=B(t);return e.write(`const ${c} = ${a}(${s}, ${i});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function Zk(e,t,r,n){let o=r._zod.def,s=Q(t,ft);e.write(`if (!${s}(${n})) return INVALID;`);let i=B(t),a=B(t),c=B(t);e.write(`const ${i} = {};`);let u=o,d=u.partial?void 0:o.keyType._zod.values;if(d){let f=[];for(let _ of d){if(!(typeof _=="string"||typeof _=="number"||typeof _=="symbol"))throw new oe(`record key value ${String(_)}`);let w=typeof _=="number"?_.toString():_;if(w==="__proto__")throw new oe('record key "__proto__"');f.push(w);let x=Q(t,_),R=me(e,t,o.keyType,x),k=B(t);e.write(`const ${k} = ${n}[${Vk(t,w)}];`);let J=Ae(e,t,o.valueType,k);e.write(`${i}[${R}] = ${J};`)}let S=Q(t,new Set(f));return e.write(`for (const ${a} in ${n}) {`),e.indented(_=>{_.write(`if (${S}.has(${a})) continue;`),u.mode==="loose"?_.write(`if (${a} !== "__proto__") ${i}[${a}] = ${n}[${a}];`):_.write("return INVALID;")}),e.write("}"),i}let p=o.keyType._zod.def;if(!(p.type==="string"&&p.format===void 0&&!p.coerce&&(p.checks?.length??0)===0)){let f=o.mode==="loose",S=nl(o.keyType);S.definite===!1&&(t.definite=!1);let _=Q(t,S),w=Q(t,nr),x=B(t);return wy(e,t,n,a,R=>{R.write(`let ${x} = ${_}(${a});`),R.write(`if (${x} === INVALID && typeof ${a} === "string" && ${w}.test(${a})) ${x} = ${_}(Number(${a}));`),f?R.write(`if (${x} === INVALID) { ${i}[${a}] = ${n}[${a}]; continue; }`):R.write(`if (${x} === INVALID) return INVALID;`),R.write(`if (${x} === "__proto__") continue;`);let k=B(t);R.write(`const ${k} = ${n}[${a}];`);let J=Ae(R,t,o.valueType,k);R.write(`${i}[${x}] = ${J};`)}),i}return wy(e,t,n,a,f=>{f.write(`const ${c} = ${n}[${a}];`);let S=Ae(f,t,o.valueType,c);f.write(`${i}[${a}] = ${S};`)},"return INVALID;"),i}function wy(e,t,r,n,o,s){let i=Q(t,Object.prototype.propertyIsEnumerable),a=B(t),c=B(t),u=B(t);e.write(`const ${a} = Object.getOwnPropertySymbols(${r});`),e.write(`const ${c} = Object.getOwnPropertyNames(${r});`),e.write(`for (let ${u} = 0; ${u} < ${c}.length; ${u}++) {`),e.indented(d=>{d.write(`const ${n} = ${c}[${u}];`),d.write(`if (${n} === "__proto__" || !${i}.call(${r}, ${n})) continue;`),o(d)}),e.write("}"),e.write(`for (let ${u} = 0; ${u} < ${a}.length; ${u}++) {`),e.indented(d=>{d.write(`const ${n} = ${a}[${u}];`),d.write(`if (!${i}.call(${r}, ${n})) continue;`),s?d.write(s):o(d)}),e.write("}")}function Vk(e,t){return typeof t=="string"?Ue(t):Q(e,t)}function Fk(e,t,r,n){let o=r._zod.def;e.write(`if (!(${n} instanceof Map)) return INVALID;`),Qh(e,r,`${n}.size`);let s=B(t),i=B(t),a=B(t);return e.write(`const ${s} = new Map();`),e.write(`for (const [${i}, ${a}] of ${n}) {`),e.indented(c=>{let u=me(c,t,o.keyType,i),d=me(c,t,o.valueType,a);c.write(`${s}.set(${u}, ${d});`)}),e.write("}"),s}function Hk(e,t,r,n){let o=r._zod.def;e.write(`if (!(${n} instanceof Set)) return INVALID;`),Qh(e,r,`${n}.size`);let s=B(t),i=B(t);return e.write(`const ${s} = new Set();`),e.write(`for (const ${i} of ${n}) {`),e.indented(a=>{let c=me(a,t,o.valueType,i);a.write(`${s}.add(${c});`)}),e.write("}"),s}function Bk(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function Jk(e,t,r,n){e.write(`if (typeof ${n} !== "string") return INVALID;`);let o=r._zod.pattern;if(o){let s=Q(t,o);e.write(`${s}.lastIndex = 0;`),e.write(`if (!${s}.test(${n})) return INVALID;`)}return n}function Kk(e,t,r,n){let o=r._zod.def,s=cn(t,o.getter),i=Q(t,{parser:null});e.write(`if (!${i}.parser) {`),e.indented(c=>{c.write(`const inner = ${s}();`),c.write(`${i}.parser = function(input) {`),c.indented(u=>{u.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),u.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");let a=B(t);return e.write(`const ${a} = ${i}.parser(${n});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function Wk(e,t,r,n){let o=r._zod.def,s=me(e,t,o.in,n);if(o.transform){if(un(o.transform))throw new zt("z.compile: async transforms in pipes are not supported");let i=o.transform,c=cn(t,d=>{let p={value:d,issues:[],addIssue:Yh},h=i(d,p);return h instanceof Promise?Ve:p.issues.length===0?h:Ve}),u=B(t);return e.write(`const ${u} = ${c}(${s});`),e.write(`if (${u} === INVALID) return INVALID;`),me(e,t,o.out,u)}else return me(e,t,o.out,s)}function un(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function Gk(e,t,r,n){let o=r._zod.def;if(o.fn){if(un(o.fn))throw new zt("z.compile: async custom predicates are not supported");let s=cn(t,o.fn),i=Q(t,Kh),a=B(t);e.write(`const ${a} = ${s}(${n});`),e.write(`if (${a} instanceof Promise) ${i}();`),e.write(`if (!${a}) return INVALID;`)}else throw new oe("custom schema without a predicate function");return n}function Yk(e,t,r){let n=e._zod.run({value:r,issues:[]},{});if(n&&typeof n.then=="function")return Ve;let o=n;return o.issues.length===0?o.value:t()}function Qk(e,t,r,n){let o=r._zod.def;if(!o.catchValue[lu])throw new oe("catch with a callback (only a constant catch value compiles)",!1);let s=B(t);e.write(`let ${s} = (() => {`),e.indented(u=>{let d=Ae(u,t,o.innerType,n);u.write(`return ${d};`)}),e.write("})();");let i=Q(t,o.innerType),a=cn(t,o.catchValue),c=Q(t,Yk);return e.write(`if (${s} === INVALID) {`),e.indented(u=>{u.write(`${s} = ${c}(${i}, ${a}, ${n});`),u.write(`if (${s} === INVALID) return INVALID;`)}),e.write("}"),s}function Xk(e,t,r,n){let o=r._zod.def;if(o.transform){if(un(o.transform))throw new zt("z.compile: async transforms are not supported");let s=o.transform,a=cn(t,u=>{let d={value:u,issues:[],addIssue:Yh},p=s(u,d);return p instanceof Promise?Ve:d.issues.length===0?p:Ve}),c=B(t);return e.write(`const ${c} = ${a}(${n});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return n}function ol(e){return e.checks&&(e.checks=[...e.checks]),e}function Xh(e,t){return new e(ol({type:"string",...$(t)}))}function ef(e,t){return new e(ol({type:"string",coerce:!0,...$(t)}))}function sl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...$(t)})}function il(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...$(t)})}function al(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...$(t)})}function cl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...$(t)})}function ul(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...$(t)})}function ll(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...$(t)})}function _i(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...$(t)})}function dl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...$(t)})}function pl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...$(t)})}function ml(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...$(t)})}function hl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...$(t)})}function fl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...$(t)})}function gl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...$(t)})}function Sl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...$(t)})}function _l(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...$(t)})}function bl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...$(t)})}function tf(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...$(t)})}function yl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...$(t)})}function vl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...$(t)})}function wl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...$(t)})}function zl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...$(t)})}function Rl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...$(t)})}function rf(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...$(t)})}function nf(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...$(t)})}function $l(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...$(t)})}var of={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function bi(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...$(t)})}function yi(e,t){return new e({type:"string",format:"date",check:"string_format",...$(t)})}function vi(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...$(t)})}function wi(e,t){return new e({type:"string",format:"duration",check:"string_format",...$(t)})}function sf(e,t){return new e(ol({type:"number",checks:[],...$(t)}))}function af(e,t){return new e(ol({type:"number",coerce:!0,checks:[],...$(t)}))}function cf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...$(t)})}function uf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...$(t)})}function lf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...$(t)})}function df(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...$(t)})}function pf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...$(t)})}function mf(e,t){return new e({type:"boolean",...$(t)})}function hf(e,t){return new e({type:"boolean",coerce:!0,...$(t)})}function ff(e,t){return new e({type:"bigint",...$(t)})}function gf(e,t){return new e({type:"bigint",coerce:!0,...$(t)})}function Sf(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...$(t)})}function _f(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...$(t)})}function bf(e,t){return new e({type:"symbol",...$(t)})}function yf(e,t){return new e({type:"undefined",...$(t)})}function vf(e,t){return new e({type:"null",...$(t)})}function wf(e){return new e({type:"any"})}function zf(e){return new e({type:"unknown"})}function Rf(e,t){return new e({type:"never",...$(t)})}function $f(e,t){return new e({type:"void",...$(t)})}function kf(e,t){return new e({type:"date",...$(t)})}function xf(e,t){return new e({type:"date",coerce:!0,...$(t)})}function Tf(e,t){return new e({type:"nan",...$(t)})}function jt(e,t){return new ku({check:"less_than",...$(t),value:e,inclusive:!1})}function ct(e,t){return new ku({check:"less_than",...$(t),value:e,inclusive:!0})}function Dt(e,t){return new xu({check:"greater_than",...$(t),value:e,inclusive:!1})}function ut(e,t){return new xu({check:"greater_than",...$(t),value:e,inclusive:!0})}function kl(e){return Dt(0,e)}function xl(e){return jt(0,e)}function Tl(e){return ct(0,e)}function El(e){return ut(0,e)}function zr(e,t){return new um({check:"multiple_of",...$(t),value:e})}function Rr(e,t){return new pm({check:"max_size",...$(t),maximum:e})}function Ut(e,t){return new mm({check:"min_size",...$(t),minimum:e})}function ln(e,t){return new hm({check:"size_equals",...$(t),size:e})}function dn(e,t){return new fm({check:"max_length",...$(t),maximum:e})}function or(e,t){return new gm({check:"min_length",...$(t),minimum:e})}function pn(e,t){return new Sm({check:"length_equals",...$(t),length:e})}function co(e,t){return new _m({check:"string_format",format:"regex",...$(t),pattern:e})}function uo(e){return new bm({check:"string_format",format:"lowercase",...$(e)})}function lo(e){return new ym({check:"string_format",format:"uppercase",...$(e)})}function po(e,t){return new vm({check:"string_format",format:"includes",...$(t),includes:e})}function mo(e,t){return new wm({check:"string_format",format:"starts_with",...$(t),prefix:e})}function ho(e,t){return new zm({check:"string_format",format:"ends_with",...$(t),suffix:e})}function Pl(e,t,r){return new Rm({check:"property",property:e,schema:t,...$(r)})}function fo(e,t){return new $m({check:"properties",shape:e,...$(t)})}function go(e,t){return new km({check:"mime_type",mime:e,...$(t)})}function Rt(e){return new xm({check:"overwrite",tx:e})}function So(e){return Rt(t=>t.normalize(e))}function _o(){return Rt(e=>e.trim())}function bo(){return Rt(e=>e.toLowerCase())}function yo(){return Rt(e=>e.toUpperCase())}function vo(){return Rt(e=>dp(e))}function Ef(e,t,r){return new e({type:"array",element:t,...$(r)})}function ex(e,t,r){return new e({type:"union",options:t,...$(r)})}function tx(e,t,r){return new e({type:"union",options:t,inclusive:!1,...$(r)})}function rx(e,t,r,n){return new e({type:"union",options:r,discriminator:t,...$(n)})}function nx(e,t,r){return new e({type:"intersection",left:t,right:r})}function ox(e,t,r,n){let o=r instanceof X,s=o?n:r,i=o?r:null;return new e({type:"tuple",items:t,rest:i,...$(s)})}function sx(e,t,r,n){return new e({type:"record",keyType:t,valueType:r,...$(n)})}function ix(e,t,r,n){return new e({type:"map",keyType:t,valueType:r,...$(n)})}function ax(e,t,r){return new e({type:"set",valueType:t,...$(r)})}function cx(e,t,r){let n=Array.isArray(t)?Object.fromEntries(t.map(o=>[o,o])):t;return new e({type:"enum",entries:n,...$(r)})}function ux(e,t,r){return new e({type:"enum",entries:t,...$(r)})}function lx(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...$(r)})}function Pf(e,t){return new e({type:"file",...$(t)})}function dx(e,t){return new e({type:"transform",transform:t})}function px(e,t){return new e({type:"optional",innerType:t})}function mx(e,t){return new e({type:"nullable",innerType:t})}function hx(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Zs(r)}})}function fx(e,t,r){return new e({type:"nonoptional",innerType:t,...$(r)})}function gx(e,t){return new e({type:"success",innerType:t})}function Sx(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:_p(r)})}function _x(e,t,r){return new e({type:"pipe",in:t,out:r})}function bx(e,t){return new e({type:"readonly",innerType:t})}function yx(e,t,r){return new e({type:"template_literal",parts:t,...$(r)})}function vx(e,t){return new e({type:"lazy",getter:t})}function wx(e,t){return new e({type:"promise",innerType:t})}function Cf(e,t,r){let n=$(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function If(e,t,r){return new e({type:"custom",check:"custom",fn:t,...$(r)})}function Of(e,t){let r=ky(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Xn(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Xn(s))}},e(n.value,n)),t);return r}function ky(e,t){let r=new pe({check:"custom",...$(t)});return r._zod.check=e,r}function Nf(e){let t=new pe({check:"describe"});return t._zod.onattach=[r=>{let n=Te.get(r)??{};Te.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function Af(e){let t=new pe({check:"meta"});return t._zod.onattach=[r=>{let n=Te.get(r)??{};Te.add(r,{...n,...e})}],t._zod.check=()=>{},t}function Mf(e,t){let r=$(t),n=r.truthy??["true","1","yes","on","y","enabled"],o=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(f=>typeof f=="string"?f.toLowerCase():f),o=o.map(f=>typeof f=="string"?f.toLowerCase():f));let s=new Set(n),i=new Set(o),a=e.Codec??pi,c=e.Boolean??li,u=e.String??sn,d=new u({type:"string",error:r.error}),p=new c({type:"boolean",error:r.error}),h=new a({type:"pipe",in:d,out:p,transform:((f,S)=>{let _=f;return r.case!=="sensitive"&&(_=_.toLowerCase()),s.has(_)?!0:i.has(_)?!1:(S.issues.push({code:"invalid_value",expected:"stringbool",values:[...s,...i],input:S.value,inst:h,continue:!1}),{})}),reverseTransform:((f,S)=>f===!0?n[0]||"true":o[0]||"false"),error:r.error});return h._zod.bag.truthy=n,h._zod.bag.falsy=o,h._zod.bag.case=r.case??"insensitive",h}function mn(e,t,r,n={}){let o=$(n),s={check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:a=>r.test(a),...o};return r instanceof RegExp&&(s.pattern=r),new e(s)}function zi(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&xe(e,n,r[n]);return e}function $r(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??Te,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 we(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function le(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{let h=i.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,h,d)}let p=e._zod.parent;p&&(i.ref||(i.ref=p),le(p,t,d),t.seen.get(p).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&zi(i.schema,c),t.io==="input"&&Fe(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function xy(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function kr(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(i[0])?.id,h=e.external.uri??(S=>S);if(p)return{ref:h(p)};let f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${xy(f)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+xy(d)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let d=a.schema;for(let p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
297
+
298
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Py(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Py(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Cy=new Set(["type","properties","required","additionalProperties"]),Ty=["oneOf","anyOf"];function Ey(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Lf(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Cy.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let d=u.properties?.[i]??Ey(u);d!=null&&(a.some(p=>JSON.stringify(p)===JSON.stringify(d))||a.push(d))}let c=a.length===1?a[0]:Lf(a)??{allOf:a};xe(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=Ey(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function zx(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Cy)if(o in e)return;let r=t.filter(o=>Ty.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=Lf(t);else{let o=r[0],s=Ty.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>Lf([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,zi(e,n))}function xr(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,d={...u},p=c.ref;if(c.ref=null,p){n(p);let f=e.seen.get(p),S=f.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(S)):zi(u,S),zi(u,d),a._zod.parent===p)for(let w in u)w==="$ref"||w==="allOf"||w in d||delete u[w];if(S.$ref&&f.def)for(let w in u)w==="$ref"||w==="allOf"||w in f.def&&JSON.stringify(u[w])===JSON.stringify(f.def[w])&&delete u[w]}let h=a._zod.parent;if(h&&h!==p){n(h);let f=e.seen.get(h);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let S in u)S==="$ref"||S==="allOf"||S in f.def&&JSON.stringify(u[S])===JSON.stringify(f.def[S])&&delete u[S]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Py(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let d=u?.allOf;if(!Array.isArray(d))continue;let p=a.get(d);p?p.push(u):a.set(d,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])zx(u)}}let 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){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}zi(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,xe(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:wo(t,"input",e.processors),output:wo(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Fe(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Fe(n.element,r);if(n.type==="set")return Fe(n.valueType,r);if(n.type==="lazy")return Fe(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Fe(n.innerType,r);if(n.type==="intersection")return Fe(n.left,r)||Fe(n.right,r);if(n.type==="record"||n.type==="map")return Fe(n.keyType,r)||Fe(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Fe(n.in,r)||Fe(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Fe(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Fe(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Fe(o,r))return!0;return!!(n.rest&&Fe(n.rest,r))}return!1}var qf=(e,t={})=>r=>{let n=$r({...r,processors:t});return le(e,n),kr(n,e),xr(n,e)},wo=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=$r({...o??{},target:s,io:t,processors:r});return le(e,i),kr(i,e),xr(i,e)};var zo=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Ro=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Iy=(e,t)=>{zo(e,"minimum",t),Ro(e,"maximum",t)},My=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Ly=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},qy=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},jy=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Oy=(e,t)=>zo(e,"minimum",t.minimum),Ny=(e,t)=>Ro(e,"maximum",t.maximum),Ay=e=>(t,r)=>{jy(t,r.format);let[n,o]=e[r.format];zo(t,"minimum",n),Ro(t,"maximum",o)},Rx={greater_than:(e,t)=>zo(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ro(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>My(e,t.value),number_format:Ay(Fs),bigint_format:Ay(Hs),min_length:Oy,max_length:Ny,length_equals:(e,t)=>Iy(e,t.length),min_size:Oy,max_size:Ny,size_equals:(e,t)=>Iy(e,t.size),string_format:(e,t)=>{jy(e,t.format),t.pattern&&Ly(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)=>qy(e,t.mime)};function ze(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)Rx[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&zo(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&zo(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Ro(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Ro(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&My(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&qy(t,o.mime);for(let s of o.patterns??[])Ly(t,s);return t}var $x={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},kx=new Map([[Lu,Vp],[ui,Fp]]),Dy=e=>kx.get(e)??e,Uf=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:d}=ze(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=$x[a]??a,o.format===""&&delete o.format,(a==="time"||d)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let p=[...c].map(Dy);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}))])}},Zf=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:d}=ze(e);o.type=d?"integer":"number";let p=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),h=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(p?f?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),h?f?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let S=new Set;for(let x of a)Number.isFinite(x)&&x!==0?S.add(Math.abs(x)):we(e,t,o,n,`A multipleOf divisor of ${x} cannot be represented in JSON Schema`);let[_,...w]=S;_!==void 0&&(o.multipleOf=_),w.length&&(o.allOf=[...o.allOf??[],...w.map(x=>({multipleOf:x}))])}},Vf=(e,t,r,n)=>{r.type="boolean"},Ff=(e,t,r,n)=>{we(e,t,r,n,"BigInt cannot be represented in JSON Schema")},Hf=(e,t,r,n)=>{we(e,t,r,n,"Symbols cannot be represented in JSON Schema")},Bf=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},Jf=(e,t,r,n)=>{we(e,t,r,n,"Undefined cannot be represented in JSON Schema")},Kf=(e,t,r,n)=>{we(e,t,r,n,"Void cannot be represented in JSON Schema")},Wf=(e,t,r,n)=>{r.not={}},Gf=(e,t,r,n)=>{},Yf=(e,t,r,n)=>{},Qf=(e,t,r,n)=>{we(e,t,r,n,"Date cannot be represented in JSON Schema")},Xf=(e,t,r,n)=>{let o=e._zod.def,s=Kn(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},eg=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(we(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(we(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s},tg=(e,t,r,n)=>{we(e,t,r,n,"NaN cannot be represented in JSON Schema")},rg=(e,t,r,n)=>{let o=r,s=e._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=s.source},ng=(e,t,r,n)=>{let o=r;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:s,maximum:i,mime:a}=ze(e);s!==void 0&&(o.minLength=s),i!==void 0&&(o.maxLength=i),a&&(a.length===0?o.not={}:a.length===1?o.contentMediaType=a[0]:o.anyOf=a.map(c=>({contentMediaType:c})))},og=(e,t,r,n)=>{r.type="boolean"},sg=(e,t,r,n)=>{we(e,t,r,n,"Custom types cannot be represented in JSON Schema")},ig=(e,t,r,n)=>{we(e,t,r,n,"Function types cannot be represented in JSON Schema")},ag=(e,t,r,n)=>{we(e,t,r,n,"Transforms cannot be represented in JSON Schema")},cg=(e,t,r,n)=>{we(e,t,r,n,"Map cannot be represented in JSON Schema")},ug=(e,t,r,n)=>{we(e,t,r,n,"Set cannot be represented in JSON Schema")},lg=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=ze(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=le(s.element,t,{...n,path:[...n.path,"items"]})};function Ri(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Ri(t.out):t.type==="catch"?Ri(t.innerType):e._zod.optin}var dg=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&we(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)xe(o.properties,u,le(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let d=s.shape[u];(t.io==="input"?Ri(d)===void 0:d._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=le(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Il=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>le(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},pg=(e,t,r,n)=>{let o=e._zod.def,s=le(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=le(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)},mg=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((_,w)=>le(_,t,{...n,path:[...n.path,i,w]})),u=s.rest?le(s.rest,t,{...n,path:[...n.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,d=s.items.length;for(;d>0;){let _=s.items[d-1];if(!(t.io==="input"?Ri(_)!==void 0:_._zod.optout==="optional"))break;d--}let p=s.items.length,h=!s.rest;t.target==="draft-2020-12"?(o.prefixItems=c,h?o.items=!1:u&&(o.items=u),d>0&&(o.minItems=d),h&&(o.maxItems=p)):t.target==="openapi-3.0"?(o.items={anyOf:c},u&&o.items.anyOf.push(u),d>0&&(o.minItems=d),h&&(o.maxItems=p)):(o.items=c,h?o.additionalItems=!1:u&&(o.additionalItems=u),d>0&&(o.minItems=d),h&&(o.maxItems=p));let{minimum:f,maximum:S}=ze(e);typeof f=="number"&&(o.minItems=f),typeof S=="number"&&(o.maxItems=S)};function jf(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let S=e.get(t)?.def;if(!S)return t;let _=jf(e,S,r);return _===S?t:_}for(let S of["anyOf","oneOf"]){let _=t[S];if(!Array.isArray(_))continue;let w=_.map(x=>jf(e,x,r));w.some((x,R)=>x!==_[R])&&(t={...t,[S]:w})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(S=>S==="number"||S==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(S=>typeof S=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:d,format:p,id:h,...f}=t;return f.enum?f.enum=f.enum.map(S=>typeof S=="number"?String(S):S):typeof f.const=="number"&&(f.const=String(f.const)),o&&(f.type="string",s||(f.pattern=(n.includes("number")?nr:ri).source)),f}var Df=new WeakMap;function xx(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of Df.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=jf(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var hg=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=ze(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let d=le(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)xe(o.patternProperties,Dy(p).source,d)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=le(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let d=Df.get(t);d||(d=[],Df.set(t,d),t.deferred.push(()=>xx(t))),d.push(e)}o.additionalProperties=le(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&Ri(s.valueType)!==void 0;if(c&&!s.partial&&!u){let d=[...c].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(o.required=d.map(String))}},fg=(e,t,r,n)=>{let o=e._zod.def,s=le(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},gg=(e,t,r,n)=>{let o=e._zod.def;le(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Sg=Symbol();function Uy(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(we(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),Sg):JSON.parse(i)}var _g=(e,t,r,n)=>{let o=e._zod.def;le(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=Uy(o.defaultValue,e,t,r,n);i!==Sg&&(r.default=i)},bg=(e,t,r,n)=>{let o=e._zod.def;le(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=Uy(o.defaultValue,e,t,r,n);i!==Sg&&(r._prefault=i)},yg=(e,t,r,n)=>{let o=e._zod.def;le(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{we(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},vg=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;le(i,t,n);let a=t.seen.get(e);a.ref=i},wg=(e,t,r,n)=>{let o=e._zod.def;le(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0},zg=(e,t,r,n)=>{let o=e._zod.def;le(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Ol=(e,t,r,n)=>{let o=e._zod.def;le(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Rg=(e,t,r,n)=>{let o=e._zod.innerType;le(o,t,n);let s=t.seen.get(e);s.ref=o},Cl={string:Uf,number:Zf,boolean:Vf,bigint:Ff,symbol:Hf,null:Bf,undefined:Jf,void:Kf,never:Wf,any:Gf,unknown:Yf,date:Qf,enum:Xf,literal:eg,nan:tg,template_literal:rg,file:ng,success:og,custom:sg,function:ig,transform:ag,map:cg,set:ug,array:lg,object:dg,union:Il,intersection:pg,tuple:mg,record:hg,nullable:fg,nonoptional:gg,default:_g,prefault:bg,catch:yg,pipe:vg,readonly:wg,promise:zg,optional:Ol,lazy:Rg};function hn(e,t){if("_idmap"in e){let n=e,o=$r({...t,processors:Cl}),s={};for(let c of n._idmap.entries()){let[u,d]=c;le(d,o)}let i={},a={registry:n,uri:t?.uri,defs:s};o.external=a;for(let c of n._idmap.entries()){let[u,d]=c;kr(o,d),xe(i,u,xr(o,d))}if(Object.keys(s).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[c]:s}}return{schemas:i}}let r=$r({...t,processors:Cl});return le(e,r),kr(r,e),xr(r,e)}var Nl=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=$r({processors:Cl,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return le(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,kr(this.ctx,t);let n=xr(this.ctx,t),{"~standard":o,...s}=n;return s}};var Zy={};var Io={};er(Io,{ZodAny:()=>Zg,ZodArray:()=>Bg,ZodBase64:()=>ed,ZodBase64URL:()=>td,ZodBigInt:()=>Co,ZodBigIntFormat:()=>od,ZodBoolean:()=>Po,ZodCIDRv4:()=>Ql,ZodCIDRv6:()=>Xl,ZodCUID:()=>Hl,ZodCUID2:()=>Bl,ZodCatch:()=>dS,ZodCodec:()=>Oi,ZodCreditCard:()=>Lg,ZodCustom:()=>Ni,ZodCustomStringFormat:()=>gn,ZodDate:()=>Ti,ZodDefault:()=>sS,ZodDiscriminatedUnion:()=>Kg,ZodE164:()=>rd,ZodEmail:()=>Dl,ZodEmoji:()=>Vl,ZodEnum:()=>ko,ZodExactOptional:()=>cd,ZodFile:()=>tS,ZodFunction:()=>yS,ZodGUID:()=>Zl,ZodIBAN:()=>qg,ZodIPv4:()=>Gl,ZodIPv6:()=>Yl,ZodISODate:()=>Er,ZodISODateTime:()=>Tr,ZodISODuration:()=>Cr,ZodISOTime:()=>Pr,ZodInstanceOf:()=>zS,ZodIntersection:()=>Wg,ZodJWT:()=>nd,ZodKSUID:()=>Wl,ZodLazy:()=>_S,ZodLiteral:()=>eS,ZodMAC:()=>Mg,ZodMap:()=>Qg,ZodNaN:()=>mS,ZodNanoID:()=>Fl,ZodNever:()=>Fg,ZodNonOptional:()=>ud,ZodNull:()=>Ug,ZodNullable:()=>oS,ZodNumber:()=>Eo,ZodNumberFormat:()=>Sn,ZodObject:()=>Ei,ZodOptional:()=>Ci,ZodPipe:()=>Ii,ZodPrefault:()=>aS,ZodPreprocess:()=>hS,ZodPromise:()=>bS,ZodReadonly:()=>fS,ZodRecord:()=>$o,ZodSet:()=>Xg,ZodString:()=>xo,ZodStringFormat:()=>de,ZodSuccess:()=>lS,ZodSymbol:()=>jg,ZodTemplateLiteral:()=>SS,ZodTransform:()=>rS,ZodTuple:()=>Gg,ZodType:()=>te,ZodULID:()=>Jl,ZodURL:()=>xi,ZodUUID:()=>Zt,ZodUndefined:()=>Dg,ZodUnion:()=>Pi,ZodUnknown:()=>Vg,ZodVoid:()=>Hg,ZodXID:()=>Kl,ZodXor:()=>Jg,_ZodString:()=>jl,_default:()=>iS,_function:()=>Jv,any:()=>sd,array:()=>y,base64:()=>uv,base64url:()=>lv,bigint:()=>Rv,boolean:()=>E,catch:()=>pS,check:()=>Kv,cidrv4:()=>av,cidrv6:()=>cv,codec:()=>Vv,creditCard:()=>pv,cuid:()=>Xy,cuid2:()=>ev,currencyCode:()=>_v,custom:()=>Wv,date:()=>Pv,describe:()=>Gv,discriminatedUnion:()=>Ir,e164:()=>dv,email:()=>Ul,emoji:()=>Yy,enum:()=>Y,exactOptional:()=>nS,file:()=>jv,float32:()=>yv,float64:()=>vv,function:()=>Jv,guid:()=>Hy,hash:()=>bv,hex:()=>Sv,hostname:()=>gv,httpUrl:()=>Gy,iban:()=>mv,instanceof:()=>Qv,int:()=>Ll,int32:()=>wv,int64:()=>$v,intersection:()=>$t,invertCodec:()=>Fv,ipv4:()=>ov,ipv6:()=>iv,json:()=>ew,jwt:()=>hv,keyof:()=>Cv,ksuid:()=>nv,lazy:()=>Or,literal:()=>v,looseObject:()=>V,looseRecord:()=>Av,mac:()=>sv,map:()=>Mv,meta:()=>Yv,nan:()=>Zv,nanoid:()=>Qy,nativeEnum:()=>qv,never:()=>id,nonoptional:()=>uS,null:()=>Vt,nullable:()=>ki,nullish:()=>Dv,number:()=>z,object:()=>g,optional:()=>M,partialRecord:()=>Nv,pipe:()=>ql,prefault:()=>cS,preprocess:()=>ir,promise:()=>Bv,readonly:()=>gS,record:()=>T,refine:()=>vS,set:()=>Lv,strictObject:()=>Iv,string:()=>l,stringFormat:()=>fv,stringbool:()=>Xv,success:()=>Uv,superRefine:()=>wS,symbol:()=>xv,templateLiteral:()=>Hv,transform:()=>ad,tuple:()=>Yg,uint32:()=>zv,uint64:()=>kv,ulid:()=>tv,undefined:()=>Tv,union:()=>P,unknown:()=>j,url:()=>To,uuid:()=>By,uuidv4:()=>Jy,uuidv6:()=>Ky,uuidv7:()=>Wy,void:()=>Ev,xid:()=>rv,xor:()=>Ov});var Al={};er(Al,{endsWith:()=>ho,gt:()=>Dt,gte:()=>ut,includes:()=>po,length:()=>pn,lowercase:()=>uo,lt:()=>jt,lte:()=>ct,maxLength:()=>dn,maxSize:()=>Rr,mime:()=>go,minLength:()=>or,minSize:()=>Ut,multipleOf:()=>zr,negative:()=>xl,nonnegative:()=>El,nonpositive:()=>Tl,normalize:()=>So,overwrite:()=>Rt,positive:()=>kl,properties:()=>fo,property:()=>Pl,regex:()=>co,size:()=>ln,slugify:()=>vo,startsWith:()=>mo,toLowerCase:()=>bo,toUpperCase:()=>yo,trim:()=>_o,uppercase:()=>lo});var Vy=new WeakSet([Object.prototype,Error.prototype]);function Ml(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var Fy=(e,t)=>{zp.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);Vy.has(r)||(Vy.add(r),Ml(r,"format",n=>o=>Qs(n,o)),Ml(r,"flatten",n=>o=>Ys(n,o)),Ml(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Wn,2)}),Ml(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Wn,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Ex=b("ZodError",Fy),tt=b("ZodError",Fy,void 0,{Parent:Error});var $g=eo(tt),kg=to(tt),$i=ro(tt),xg=no(tt),Tg=hu(tt),Eg=fu(tt),Pg=gu(tt),Cg=Su(tt),Ig=_u(tt),Og=bu(tt),Ng=yu(tt),Ag=vu(tt);function Cx(){Re.localeError||be(Xu())}function fn(){Re.memoizer||be({memoizer:gi()})}var te=b("ZodType",(e,t)=>(Cx(),X.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(A.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ce(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(vS(e,t))},superRefine(e,t){return this.check(wS(e,t))},overwrite(e){return this.check(Rt(e))},optional(){return M(this)},exactOptional(){return nS(this)},nullable(){return ki(this)},nullish(){return M(ki(this))},nonoptional(e){return uS(this,e)},array(){return y(this)},or(e){return P([this,e])},and(e){return $t(this,e)},transform(e){return ql(this,ad(e))},default(e){return iS(this,e)},prefault(e){return cS(this,e)},catch(e){return pS(this,e)},pipe(e){return ql(this,e)},readonly(){return gS(this)},describe(e){let t=this.clone();return Te.add(t,{description:e}),t},meta(...e){if(e.length===0)return Te.get(this);let t=this.clone();return Te.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 A.hide(this,"~standard",{...Iu(this),jsonSchema:{input:wo(this,"input"),output:wo(this,"output")}})},set"~standard"(e){A.own(this,"~standard",e)},parse:function e(t,r){return $g(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await kg(this,t,r,{callee:e})},safeParse(e,t){return $i(this,e,t)},async safeParseAsync(e,t){return xg(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){A.own(this,"spa",e)},validate(e,t){return Xs(this,e,t)},validateAsync(e,t){return ei(this,e,t)},encode:function e(t,r){return Tg(this,t,r,{callee:e})},decode:function e(t,r){return Eg(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Pg(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Cg(this,t,r,{callee:e})},safeEncode(e,t){return Ig(this,e,t)},safeDecode(e,t){return Og(this,e,t)},async safeEncodeAsync(e,t){return Ng(this,e,t)},async safeDecodeAsync(e,t){return Ag(this,e,t)},toJSONSchema(e){return qf(this,{})(e)},get description(){return Te.get(this)?.description},get _def(){return this._zod.def}}),jl=b("_ZodString",(e,t)=>{sn.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Uf(e,r,n,o)},A.derived({format:e=>ze(e).format??null,minLength:e=>ze(e).minimum??null,maxLength:e=>ze(e).maximum??null},{regex(...e){return this.check(co(...e))},includes(...e){return this.check(po(...e))},startsWith(...e){return this.check(mo(...e))},endsWith(...e){return this.check(ho(...e))},min(...e){return this.check(or(...e))},max(...e){return this.check(dn(...e))},length(...e){return this.check(pn(...e))},nonempty(...e){return this.check(or(1,...e))},lowercase(e){return this.check(uo(e))},uppercase(e){return this.check(lo(e))},trim(){return this.check(_o())},normalize(...e){return this.check(So(...e))},toLowerCase(){return this.check(bo())},toUpperCase(){return this.check(yo())},slugify(){return this.check(vo())}})),xo=b("ZodString",(e,t)=>{sn.init(e,t),jl.init(e,t)},{email(e){return this.check(sl(Dl,e))},url(e){return this.check(_i(xi,e))},jwt(e){return this.check($l(nd,e))},emoji(e){return this.check(dl(Vl,e))},guid(e){return this.check(il(Zl,e))},uuid(e){return this.check(al(Zt,e))},uuidv4(e){return this.check(cl(Zt,e))},uuidv6(e){return this.check(ul(Zt,e))},uuidv7(e){return this.check(ll(Zt,e))},nanoid(e){return this.check(pl(Fl,e))},cuid(e){return this.check(ml(Hl,e))},cuid2(e){return this.check(hl(Bl,e))},ulid(e){return this.check(fl(Jl,e))},base64(e){return this.check(wl(ed,e))},base64url(e){return this.check(zl(td,e))},xid(e){return this.check(gl(Kl,e))},ksuid(e){return this.check(Sl(Wl,e))},ipv4(e){return this.check(_l(Gl,e))},ipv6(e){return this.check(bl(Yl,e))},cidrv4(e){return this.check(yl(Ql,e))},cidrv6(e){return this.check(vl(Xl,e))},e164(e){return this.check(Rl(rd,e))},datetime(e){return this.check(bi(Tr,e))},date(e){return this.check(yi(Er,e))},time(e){return this.check(vi(Pr,e))},duration(e){return this.check(wi(Cr,e))}});function l(e){return Xh(xo,e)}var de=b("ZodStringFormat",(e,t)=>{ue.init(e,t),jl.init(e,t)}),Tr=b("ZodISODateTime",(e,t)=>{Vm.init(e,t),de.init(e,t)}),Er=b("ZodISODate",(e,t)=>{Fm.init(e,t),de.init(e,t)}),Pr=b("ZodISOTime",(e,t)=>{Hm.init(e,t),de.init(e,t)}),Cr=b("ZodISODuration",(e,t)=>{Bm.init(e,t),de.init(e,t)}),Dl=b("ZodEmail",(e,t)=>{Im.init(e,t),de.init(e,t)});function Ul(e){return sl(Dl,e)}var Zl=b("ZodGUID",(e,t)=>{Pm.init(e,t),de.init(e,t)});function Hy(e){return il(Zl,e)}var Zt=b("ZodUUID",(e,t)=>{Cm.init(e,t),de.init(e,t)});function By(e){return al(Zt,e)}function Jy(e){return cl(Zt,e)}function Ky(e){return ul(Zt,e)}function Wy(e){return ll(Zt,e)}var xi=b("ZodURL",(e,t)=>{Am.init(e,t),de.init(e,t)});function To(e){return _i(xi,e)}function Gy(e){return _i(xi,{protocol:ti,hostname:Bp,...A.normalizeParams(e)})}var Vl=b("ZodEmoji",(e,t)=>{Mm.init(e,t),de.init(e,t)});function Yy(e){return dl(Vl,e)}var Fl=b("ZodNanoID",(e,t)=>{Lm.init(e,t),de.init(e,t)});function Qy(e){return pl(Fl,e)}var Hl=b("ZodCUID",(e,t)=>{qm.init(e,t),de.init(e,t)});function Xy(e){return ml(Hl,e)}var Bl=b("ZodCUID2",(e,t)=>{jm.init(e,t),de.init(e,t)});function ev(e){return hl(Bl,e)}var Jl=b("ZodULID",(e,t)=>{Dm.init(e,t),de.init(e,t)});function tv(e){return fl(Jl,e)}var Kl=b("ZodXID",(e,t)=>{Um.init(e,t),de.init(e,t)});function rv(e){return gl(Kl,e)}var Wl=b("ZodKSUID",(e,t)=>{Zm.init(e,t),de.init(e,t)});function nv(e){return Sl(Wl,e)}var Gl=b("ZodIPv4",(e,t)=>{Jm.init(e,t),de.init(e,t)});function ov(e){return _l(Gl,e)}var Mg=b("ZodMAC",(e,t)=>{Wm.init(e,t),de.init(e,t)});function sv(e){return tf(Mg,e)}var Yl=b("ZodIPv6",(e,t)=>{Km.init(e,t),de.init(e,t)});function iv(e){return bl(Yl,e)}var Ql=b("ZodCIDRv4",(e,t)=>{Gm.init(e,t),de.init(e,t)});function av(e){return yl(Ql,e)}var Xl=b("ZodCIDRv6",(e,t)=>{Ym.init(e,t),de.init(e,t)});function cv(e){return vl(Xl,e)}var ed=b("ZodBase64",(e,t)=>{Qm.init(e,t),de.init(e,t)});function uv(e){return wl(ed,e)}var td=b("ZodBase64URL",(e,t)=>{Xm.init(e,t),de.init(e,t)});function lv(e){return zl(td,e)}var rd=b("ZodE164",(e,t)=>{eh.init(e,t),de.init(e,t)});function dv(e){return Rl(rd,e)}var Lg=b("ZodCreditCard",(e,t)=>{th.init(e,t),de.init(e,t)});function pv(e){return rf(Lg,e)}var qg=b("ZodIBAN",(e,t)=>{rh.init(e,t),de.init(e,t)});function mv(e){return nf(qg,e)}var nd=b("ZodJWT",(e,t)=>{nh.init(e,t),de.init(e,t)});function hv(e){return $l(nd,e)}var gn=b("ZodCustomStringFormat",(e,t)=>{oh.init(e,t),de.init(e,t)});function fv(e,t,r={}){return mn(gn,e,t,r)}function gv(e){return mn(gn,"hostname",Hp,e)}function Sv(e){return mn(gn,"hex",im,e)}function _v(e){return mn(gn,"currency_code",Kp,e)}function bv(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,o=St[n];if(!o)throw new Error(`Unrecognized hash format: ${n}`);return mn(gn,n,o,t)}var Eo=b("ZodNumber",(e,t)=>{Zu.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zf(e,r,n,o),e.isFinite=!0},A.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=ze(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=ze(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=ze(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>ze(e).format??null},{gt(e,t){return this.check(Dt(e,t))},gte(e,t){return this.check(ut(e,t))},min(e,t){return this.check(ut(e,t))},lt(e,t){return this.check(jt(e,t))},lte(e,t){return this.check(ct(e,t))},max(e,t){return this.check(ct(e,t))},int(e){return this.check(Ll(e))},safe(e){return this.check(Ll(e))},positive(e){return this.check(Dt(0,e))},nonnegative(e){return this.check(ut(0,e))},negative(e){return this.check(jt(0,e))},nonpositive(e){return this.check(ct(0,e))},multipleOf(e,t){return this.check(zr(e,t))},step(e,t){return this.check(zr(e,t))},finite(){return this}}));function z(e){return sf(Eo,e)}var Sn=b("ZodNumberFormat",(e,t)=>{sh.init(e,t),Eo.init(e,t)});function Ll(e){return cf(Sn,e)}function yv(e){return uf(Sn,e)}function vv(e){return lf(Sn,e)}function wv(e){return df(Sn,e)}function zv(e){return pf(Sn,e)}var Po=b("ZodBoolean",(e,t)=>{li.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vf(e,r,n,o)});function E(e){return mf(Po,e)}var Co=b("ZodBigInt",(e,t)=>{Vu.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ff(e,r,n,o)},A.derived({minValue:e=>ze(e).minimum??null,maxValue:e=>ze(e).maximum??null,format:e=>ze(e).format??null},{gte(e,t){return this.check(ut(e,t))},min(e,t){return this.check(ut(e,t))},gt(e,t){return this.check(Dt(e,t))},lt(e,t){return this.check(jt(e,t))},lte(e,t){return this.check(ct(e,t))},max(e,t){return this.check(ct(e,t))},positive(e){return this.check(Dt(BigInt(0),e))},negative(e){return this.check(jt(BigInt(0),e))},nonpositive(e){return this.check(ct(BigInt(0),e))},nonnegative(e){return this.check(ut(BigInt(0),e))},multipleOf(e,t){return this.check(zr(e,t))}}));function Rv(e){return ff(Co,e)}var od=b("ZodBigIntFormat",(e,t)=>{ih.init(e,t),Co.init(e,t)});function $v(e){return Sf(od,e)}function kv(e){return _f(od,e)}var jg=b("ZodSymbol",(e,t)=>{ah.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hf(e,r,n,o)});function xv(e){return bf(jg,e)}var Dg=b("ZodUndefined",(e,t)=>{ch.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jf(e,r,n,o)});function Tv(e){return yf(Dg,e)}var Ug=b("ZodNull",(e,t)=>{uh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bf(e,r,n,o)});function Vt(e){return vf(Ug,e)}var Zg=b("ZodAny",(e,t)=>{lh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gf(e,r,n,o)});function sd(){return wf(Zg)}var Vg=b("ZodUnknown",(e,t)=>{dh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yf(e,r,n,o)});function j(){return zf(Vg)}var Fg=b("ZodNever",(e,t)=>{ph.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wf(e,r,n,o)});function id(e){return Rf(Fg,e)}var Hg=b("ZodVoid",(e,t)=>{mh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Kf(e,r,n,o)});function Ev(e){return $f(Hg,e)}var Ti=b("ZodDate",(e,t)=>{hh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qf(e,r,n,o),e.min=(r,n)=>e.check(ut(r,n)),e.max=(r,n)=>e.check(ct(r,n))},A.derived({minDate:e=>{let{minimum:t}=ze(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=ze(e);return t?new Date(t):null}},{}));function Pv(e){return kf(Ti,e)}var Bg=b("ZodArray",(e,t)=>{fn(),gh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lg(e,r,n,o),e.element=t.element},{min(e,t){return this.check(or(e,t))},nonempty(e){return this.check(or(1,e))},max(e,t){return this.check(dn(e,t))},length(e,t){return this.check(pn(e,t))},unwrap(){return this.element}});function y(e,t){return Ef(Bg,e,t)}function Cv(e){let t=e._zod.def.shape;return Y(Object.keys(t))}var Ei=b("ZodObject",(e,t)=>{fn(),Sh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dg(e,r,n,o),A.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Y(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(A.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(A.mergeDefs(this._zod.def,{catchall:j()}))},loose(){return this.clone(A.mergeDefs(this._zod.def,{catchall:j()}))},strict(){return this.clone(A.mergeDefs(this._zod.def,{catchall:id()}))},strip(){return this.clone(A.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return A.extend(this,e)},safeExtend(e){return A.safeExtend(this,e)},merge(e){return A.merge(this,e)},pick(e){return A.pick(this,e)},omit(e){return A.omit(this,e)},partial(...e){return A.partial(Ci,this,e[0])},exactPartial(...e){return A.partial(cd,this,e[0],"exactPartial")},required(...e){return A.required(ud,this,e[0])}});function g(e,t){let r={type:"object",shape:e??{},...A.normalizeParams(t)};return new Ei(r)}function Iv(e,t){return new Ei({type:"object",shape:e,catchall:id(),...A.normalizeParams(t)})}function V(e,t){return new Ei({type:"object",shape:e,catchall:j(),...A.normalizeParams(t)})}var Pi=b("ZodUnion",(e,t)=>{di.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Il(e,r,n,o),e.options=t.options});function P(e,t){return new Pi({type:"union",options:e,...A.normalizeParams(t)})}var Jg=b("ZodXor",(e,t)=>{Pi.init(e,t),_h.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Il(e,r,n,o),e.options=t.options});function Ov(e,t){return new Jg({type:"union",options:e,inclusive:!1,...A.normalizeParams(t)})}var Kg=b("ZodDiscriminatedUnion",(e,t)=>{Pi.init(e,t),yh.init(e,t)});function Ir(e,t,r){return new Kg({type:"union",options:t,discriminator:e,...A.normalizeParams(r)})}var Wg=b("ZodIntersection",(e,t)=>{vh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pg(e,r,n,o)});function $t(e,t){return new Wg({type:"intersection",left:e,right:t})}var Gg=b("ZodTuple",(e,t)=>{fn(),Fu.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mg(e,r,n,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Ci({type:"optional",innerType:t}))})}});function Yg(e,t,r){let n=t instanceof X,o=n?r:t,s=n?t:null;return new Gg({type:"tuple",items:e,rest:s,...A.normalizeParams(o)})}var $o=b("ZodRecord",(e,t)=>{fn(),wh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hg(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function T(e,t,r){return!t||!t._zod?new $o({type:"record",keyType:l(),valueType:e,...A.normalizeParams(t)}):new $o({type:"record",keyType:e,valueType:t,...A.normalizeParams(r)})}function Nv(e,t,r){return new $o({type:"record",keyType:e,valueType:t,...A.normalizeParams(r),partial:!0})}function Av(e,t,r){return new $o({type:"record",keyType:e,valueType:t,mode:"loose",...A.normalizeParams(r)})}var Qg=b("ZodMap",(e,t)=>{fn(),zh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cg(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Ut(...r)),e.nonempty=r=>e.check(Ut(1,r)),e.max=(...r)=>e.check(Rr(...r)),e.size=(...r)=>e.check(ln(...r))});function Mv(e,t,r){return new Qg({type:"map",keyType:e,valueType:t,...A.normalizeParams(r)})}var Xg=b("ZodSet",(e,t)=>{fn(),Rh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ug(e,r,n,o),e.min=(...r)=>e.check(Ut(...r)),e.nonempty=r=>e.check(Ut(1,r)),e.max=(...r)=>e.check(Rr(...r)),e.size=(...r)=>e.check(ln(...r))});function Lv(e,t){return new Xg({type:"set",valueType:e,...A.normalizeParams(t)})}var ko=b("ZodEnum",(e,t)=>{$h.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Xf(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ko({...t,checks:[],...A.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ko({...t,checks:[],...A.normalizeParams(o),entries:s})}});function Y(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new ko({type:"enum",entries:r,...A.normalizeParams(t)})}function qv(e,t){return new ko({type:"enum",entries:e,...A.normalizeParams(t)})}var eS=b("ZodLiteral",(e,t)=>{kh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>eg(e,r,n,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 v(e,t){return new eS({type:"literal",values:Array.isArray(e)?e:[e],...A.normalizeParams(t)})}var tS=b("ZodFile",(e,t)=>{xh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ng(e,r,n,o),e.min=(r,n)=>e.check(Ut(r,n)),e.max=(r,n)=>e.check(Rr(r,n)),e.mime=(r,n)=>e.check(go(Array.isArray(r)?r:[r],n))});function jv(e){return Pf(tS,e)}var rS=b("ZodTransform",(e,t)=>{fn(),Th.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ag(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new vr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(A.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(A.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function ad(e){return new rS({type:"transform",transform:e})}var Ci=b("ZodOptional",(e,t)=>{Hu.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ol(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function M(e){return new Ci({type:"optional",innerType:e})}var cd=b("ZodExactOptional",(e,t)=>{Eh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ol(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function nS(e){return new cd({type:"optional",innerType:e})}var oS=b("ZodNullable",(e,t)=>{Ph.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fg(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ki(e){return new oS({type:"nullable",innerType:e})}function Dv(e){return M(ki(e))}var sS=b("ZodDefault",(e,t)=>{Ch.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_g(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function iS(e,t){return new sS({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():A.shallowClone(t)}})}var aS=b("ZodPrefault",(e,t)=>{Ih.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bg(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function cS(e,t){return new aS({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():A.shallowClone(t)}})}var ud=b("ZodNonOptional",(e,t)=>{Oh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gg(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function uS(e,t){return new ud({type:"nonoptional",innerType:e,...A.normalizeParams(t)})}var lS=b("ZodSuccess",(e,t)=>{Nh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>og(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Uv(e){return new lS({type:"success",innerType:e})}var dS=b("ZodCatch",(e,t)=>{Ah.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yg(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pS(e,t){return new dS({type:"catch",innerType:e,catchValue:typeof t=="function"?t:A.constantCatch(t)})}var mS=b("ZodNaN",(e,t)=>{Mh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tg(e,r,n,o)});function Zv(e){return Tf(mS,e)}var Ii=b("ZodPipe",(e,t)=>{Bu.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vg(e,r,n,o),e.in=t.in,e.out=t.out});function ql(e,t){return new Ii({type:"pipe",in:e,out:t})}var Oi=b("ZodCodec",(e,t)=>{Ii.init(e,t),pi.init(e,t)});function Vv(e,t,r){return new Oi({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function Fv(e){let t=e._zod.def;return new Oi({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var hS=b("ZodPreprocess",(e,t)=>{Ii.init(e,t),Lh.init(e,t)}),fS=b("ZodReadonly",(e,t)=>{qh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wg(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function gS(e){return new fS({type:"readonly",innerType:e})}var SS=b("ZodTemplateLiteral",(e,t)=>{jh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rg(e,r,n,o)});function Hv(e,t){return new SS({type:"template_literal",parts:e,...A.normalizeParams(t)})}var _S=b("ZodLazy",(e,t)=>{mi.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rg(e,r,n,o),e.unwrap=()=>e._zod.def.getter()});function Or(e){return new _S({type:"lazy",getter:e})}var bS=b("ZodPromise",(e,t)=>{Uh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>zg(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Bv(e){return new bS({type:"promise",innerType:e})}var yS=b("ZodFunction",(e,t)=>{Dh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ig(e,r,n,o)});function Jv(e){return new yS({type:"function",input:Array.isArray(e?.input)?Yg(e?.input):e?.input??y(j()),output:e?.output??j()})}var Ni=b("ZodCustom",(e,t)=>{Zh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sg(e,r,n,o)});function Kv(e){let t=new pe({check:"custom"});return t._zod.check=e,t}function Wv(e,t){return Cf(Ni,e??(()=>!0),t)}function vS(e,t={}){return If(Ni,e,t)}function wS(e,t){return Of(e,t)}var Gv=Nf,Yv=Af,zS=b("ZodInstanceOf",(e,t)=>{Ni.init(e,t)},{properties(e,t){return this.check(fo(e,t))}});function Qv(e,t={}){let r=new zS({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...A.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Xv=(...e)=>Mf({Codec:Oi,Boolean:Po,String:xo},...e);function ew(e){let t=Or(()=>P([l(e),z(),E(),Vt(),y(t),T(l(),t)]));return t}function ir(e,t){return new hS({type:"pipe",in:ad(e),out:t})}var $S={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Ix(e){be({customError:e})}function Ox(){return be().customError}var RS;RS||(RS={});var _t={};er(_t,{ZodISODate:()=>Er,ZodISODateTime:()=>Tr,ZodISODuration:()=>Cr,ZodISOTime:()=>Pr,date:()=>Ax,datetime:()=>Nx,duration:()=>Lx,time:()=>Mx});function Nx(e){return bi(Tr,e)}function Ax(e){return yi(Er,e)}function Mx(e){return vi(Pr,e)}function Lx(e){return wi(Cr,e)}var I={...Io,...Al,iso:_t},qx=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function jx(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function tw(e,t){return e.map((r,n)=>n<t?r:r.optional())}function Dx(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Ux(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let o=r[1]===void 0?void 0:Dx(r[1]);if(!o||!t.defs[o])throw new Error(`Reference not found: ${e}`);return t.defs[o]}throw new Error(`Reference not found: ${e}`)}function Zx(e,t){return I.transform(n=>n).check(n=>{let o=n.value;if(typeof o!="object"||o===null||Array.isArray(o))return;let s=Object.getOwnPropertyNames(o);if(t.minProperties!==void 0&&s.length<t.minProperties&&n.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:o,inst:e,continue:!0}),t.maxProperties!==void 0&&s.length>t.maxProperties&&n.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:o,inst:e,continue:!0}),t.keySchema)for(let i of s){let a=t.keySchema.safeParse(i);a.success||n.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:i,path:[i],continue:!0})}}).pipe(e)}function kS(e,t){if(e===null)return"z";let r=typeof e;if(r!=="object"){if(r==="number"&&Number.isNaN(e))return null;let n=String(e);return`${r[0]}${n.length}:${n}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let s=[];for(let i of e){let a=kS(i,t);if(a===null)return null;s.push(a)}return`a${s.length}:[${s.join(",")}]`}let n=Object.keys(e).sort(),o=[];for(let s of n){let i=kS(e[s],t);if(i===null)return null;o.push(`${s.length}:${s}=${i}`)}return`o${o.length}:{${o.join(",")}}`}finally{t.delete(e)}}var Vx=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),Fx=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Ai(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Ai):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,r])=>Vx.has(t)?Ai(r):!Fx.has(t)||typeof r!="object"||r===null?!1:Object.values(r).some(Ai))}function rw(e){return e===1?"element":"elements"}function Hx(e,t){return I.transform(n=>n).check(n=>{let o=n.value;if(Array.isArray(o)){if(t.uniqueItems===!0){let s=new Map;for(let i=0;i<o.length;i++){let a=kS(o[i],new Set);if(a===null)continue;let c=s.get(a);if(c===void 0){s.set(a,i);continue}n.issues.push({code:"custom",message:`Array items must be unique: element at index ${i} duplicates the one at index ${c}`,input:o,path:[i],continue:!0})}}if(t.containsSchema){let s=t.minContains??1,i=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,a=0;for(let c of o)if(t.containsSchema.safeParse(c).success&&++a>=i)break;a<s&&n.issues.push({code:"custom",message:`Array must contain at least ${s} matching ${rw(s)}; found ${a}`,input:o,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&n.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${rw(t.maxContains)}`,input:o,continue:!0})}}}).pipe(e)}function nw(e,t){if(e!==!1)return e===void 0||e===!0?I.any():He(e,t)}var Bx=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function ow(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return I.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let o=e.$ref;if(t.refs.has(o))return t.refs.get(o);if(t.processing.has(o))return I.lazy(()=>{if(!t.refs.has(o))throw new Error(`Circular reference not resolved: ${o}`);return t.refs.get(o)});t.processing.add(o);let s=Ux(o,t),i=He(s,t);return t.refs.set(o,i),t.processing.delete(o),i}if(e.enum!==void 0){let o=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&o.length===1&&o[0]===null)return I.null();if(o.length===0)return I.never();if(o.length===1)return I.literal(o[0]);if(o.every(i=>typeof i=="string"))return I.enum(o);let s=o.map(i=>I.literal(i));return s.length<2?s[0]:I.union([s[0],s[1],...s.slice(2)])}if(e.const!==void 0)return I.literal(e.const);let r=e.type;if(Array.isArray(r)){let o=r.map(s=>{let i={...e,type:s};return ow(i,t)});return o.length===0?I.never():o.length===1?o[0]:I.union(o)}if(!r)return I.any();let n;switch(r){case"string":{let o=I.string();if(e.format){let s=e.format;s==="email"?o=o.check(I.email()):s==="uri"||s==="uri-reference"?o=o.check(I.url()):s==="uuid"||s==="guid"?o=o.check(I.uuid()):s==="date-time"?o=o.check(I.iso.datetime({offset:!0})):s==="date"?o=o.check(I.iso.date()):s==="time"?o=o.check(I.regex(Bx)):s==="duration"?o=o.check(I.iso.duration()):s==="hostname"?o=o.check(I.hostname()):s==="ipv4"?o=o.check(I.ipv4()):s==="ipv6"?o=o.check(I.ipv6()):s==="mac"?o=o.check(I.mac()):s==="cidr"?o=o.check(I.cidrv4()):s==="cidr-v6"?o=o.check(I.cidrv6()):s==="base64"?o=o.check(I.base64()):s==="base64url"?o=o.check(I.base64url()):s==="e164"?o=o.check(I.e164()):s==="credit_card"?o=o.check(I.creditCard()):s==="iban"?o=o.check(I.iban()):s==="jwt"?o=o.check(I.jwt()):s==="emoji"?o=o.check(I.emoji()):s==="nanoid"?o=o.check(I.nanoid()):s==="cuid"?o=o.check(I.cuid()):s==="cuid2"?o=o.check(I.cuid2()):s==="ulid"?o=o.check(I.ulid()):s==="xid"?o=o.check(I.xid()):s==="ksuid"&&(o=o.check(I.ksuid()))}typeof e.minLength=="number"&&(o=o.min(e.minLength)),typeof e.maxLength=="number"&&(o=o.max(e.maxLength)),e.pattern&&(o=o.regex(new RegExp(e.pattern))),n=o;break}case"number":case"integer":{let o=r==="integer"?I.number().int():I.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(o=o.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(o=o.max(e.maximum)),typeof e.exclusiveMinimum=="number"?o=o.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(o=o.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?o=o.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(o=o.lt(e.maximum)),typeof e.multipleOf=="number"&&(o=o.multipleOf(e.multipleOf)),n=o;break}case"boolean":{n=I.boolean();break}case"null":{n=I.null();break}case"object":{let o={},s=e.properties||{},i=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?He(e.additionalProperties,t):void 0;for(let[p,h]of Object.entries(s)){let f=He(h,t);xe(o,p,i.has(p)?f:f.optional())}if(e.patternProperties){let p=e.patternProperties,h=Object.keys(p),f=[];for(let _ of h){let w=He(p[_],t),x=I.string().regex(new RegExp(_));f.push(I.looseRecord(x,w))}let S=[];if(Object.keys(o).length>0&&S.push(I.object(o).passthrough()),S.push(...f),S.length===0)n=I.object({}).passthrough();else if(S.length===1)n=S[0];else{let _=I.intersection(S[0],S[1]);for(let w=2;w<S.length;w++)_=I.intersection(_,S[w]);n=_}if(e.additionalProperties===!1){let _=Object.keys(o),w=h.map(R=>new RegExp(R)),x=n;n=n.check(R=>{if(!ft(R.value))return;let k=[];for(let J of Object.keys(R.value))_.includes(J)||w.some(se=>se.test(J))||k.push(J);k.length&&R.issues.push({code:"unrecognized_keys",keys:k,input:R.value,inst:x})})}}else{let p=I.object(o);e.additionalProperties===!1?n=p.strict():a?n=p.catchall(a):n=p.passthrough()}let c=e.propertyNames!==void 0&&e.propertyNames!==!0,u=typeof e.minProperties=="number"?e.minProperties:void 0,d=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||u!==void 0||d!==void 0){let p;if(c){let h=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;p=He(h,t)}n=Zx(n,{keySchema:p,minProperties:u,maxProperties:d})}break}case"array":{let o=e.prefixItems,s=e.items;if(o&&Array.isArray(o)){let i=typeof e.minItems=="number"?e.minItems:0,a=o.map(p=>He(p,t)),c=tw(a,i),u=Array.isArray(s)?void 0:nw(s,t),d=I.tuple(c);n=u?d.rest(u):d,typeof e.minItems=="number"&&(n=n.check(I.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(I.maxLength(e.maxItems)))}else if(Array.isArray(s)){let i=typeof e.minItems=="number"?e.minItems:0,a=s.map(p=>He(p,t)),c=tw(a,i),u=nw(e.additionalItems,t),d=I.tuple(c);n=u?d.rest(u):d,typeof e.minItems=="number"&&(n=n.check(I.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(I.maxLength(e.maxItems)))}else if(s!==void 0){let i=He(s,t),a=I.array(i);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),n=a}else n=I.array(I.any());(e.uniqueItems===!0||e.contains!==void 0)&&(n=Hx(n,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?He(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return n}function He(e,t){if(typeof e=="boolean")return e?I.any():I.never();let r=ow(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(u=>He(u,t)),c=I.union(a);r=n?I.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(u=>He(u,t)),c=I.xor(a);r=n?I.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:I.any();else{let a=n?r:He(e.allOf[0],t),c=n?0:1;for(let u=c;u<e.allOf.length;u++)a=I.intersection(a,He(e.allOf[u],t));r=a}e.nullable===!0&&t.version==="openapi-3.0"&&(r=I.nullable(r)),e.readOnly===!0&&(r=I.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let o={},s=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of s)a in e&&(o[a]=e[a]);let i=["contentEncoding","contentMediaType","contentSchema"];for(let a of i)a in e&&(o[a]=e[a]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!Ai(e.propertyNames)&&(o.propertyNames=e.propertyNames);for(let a of["minProperties","maxProperties"])e[a]!==void 0&&(o[a]=e[a])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!Ai(e.contains)&&(o.contains=e.contains);for(let a of["uniqueItems","minContains","maxContains"])e[a]!==void 0&&(o[a]=e[a])}for(let a of Object.keys(e))qx.has(a)||xe(o,a,e[a]);return Object.keys(o).length>0&&t.registry.add(r,o),e.description&&(r=r.describe(e.description)),r}function sw(e,t){if(typeof e=="boolean")return e?I.any():I.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let n=jx(r,t?.defaultTarget),o=r.$defs||r.definitions||{},s={version:n,defs:o,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Te};return He(r,s)}var iw=Symbol("z.visit/resolving");function Mi(e,t){let r=typeof t=="function"?t:(i,a)=>{let c=t[i._zod.def.type];return c?c(i,a):i},n=new Map;function o(i){let a=n.get(i);if(a===iw)return new mi({type:"lazy",getter:()=>n.get(i)});if(a!==void 0)return a;n.set(i,iw);let c=s(i),u=r(c,c!==i);return n.set(i,u),u}function s(i){let a=i._zod.def,c=a.type;switch(c){case"object":{let u=a.shape,d=Object.keys(u),p=!1,h={};for(let S of d){let _=o(u[S]);_!==u[S]&&(p=!0),h[S]=_}let f=a.catchall;return a.catchall&&(f=o(a.catchall),f!==a.catchall&&(p=!0)),p?ce(i,{...a,shape:h,catchall:f}):i}case"array":{let u=o(a.element);return u===a.element?i:ce(i,{...a,element:u})}case"tuple":{let u=a.items,d=!1,p=[];for(let f of u){let S=o(f);S!==f&&(d=!0),p.push(S)}let h=a.rest;return a.rest&&(h=o(a.rest),h!==a.rest&&(d=!0)),d?ce(i,{...a,items:p,rest:h}):i}case"record":case"map":{let u=o(a.keyType),d=o(a.valueType);return u===a.keyType&&d===a.valueType?i:ce(i,{...a,keyType:u,valueType:d})}case"set":{let u=o(a.valueType);return u===a.valueType?i:ce(i,{...a,valueType:u})}case"union":{let u=a.options,d=!1,p=[];for(let h of u){let f=o(h);f!==h&&(d=!0),p.push(f)}return d?ce(i,{...a,options:p}):i}case"intersection":{let u=o(a.left),d=o(a.right);return u===a.left&&d===a.right?i:ce(i,{...a,left:u,right:d})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let u=o(a.innerType);return u===a.innerType?i:ce(i,{...a,innerType:u})}case"pipe":{let u=o(a.in),d=o(a.out);return u===a.in&&d===a.out?i:ce(i,{...a,in:u,out:d})}case"function":{let u=o(a.input),d=o(a.output);return u===a.input&&d===a.output?i:ce(i,{...a,input:u,output:d})}case"lazy":{let u=a.getter,{_cachedInner:d,...p}=a;return ce(i,{...p,getter:()=>o(u())})}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":return i;default:return i}}return o(e)}function aw(e){return Mi(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:P(r.options)}})}function Jx(e,t){if(!t?.length)return e;let r=e._zod.def;return ce(e,wt(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function cw(e){return Jx(e.out,e.checks)}function Kx(e){return e.in._zod.traits.has("$ZodTransform")?cw(e):e.in}function uw(e){return Mi(e,{pipe:t=>Kx(t._zod.def),default:(t,r)=>r?M(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function lw(e){return Mi(e,{pipe:t=>cw(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var Li={};er(Li,{bigint:()=>Qx,boolean:()=>Yx,date:()=>Xx,number:()=>Gx,string:()=>Wx});function Wx(e){return ef(xo,e)}function Gx(e){return af(Eo,e)}function Yx(e){return hf(Po,e)}function Qx(e){return gf(Co,e)}function Xx(e){return xf(Ti,e)}var qi="2025-11-25";var ld=[qi,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],dd="io.modelcontextprotocol/related-task",_n="io.modelcontextprotocol/protocolVersion",Oo="io.modelcontextprotocol/clientInfo",Ht="io.modelcontextprotocol/serverInfo",bn="io.modelcontextprotocol/clientCapabilities",No="io.modelcontextprotocol/subscriptionId",Ao="io.modelcontextprotocol/logLevel";var yn="2.0";var ar=Or(()=>P([l(),z(),E(),Vt(),T(l(),ar),y(ar)])),fe=T(l(),ar),pd=y(ar),Mo=P([l(),z().int()]),Lo=l(),ji=g({ttl:z().optional()}),Di=g({taskId:l()}),qo=V({progressToken:Mo.optional(),[dd]:Di.optional()}),$e=g({_meta:qo.optional()}),Ar=$e.extend({task:ji.optional()}),ge=g({method:l(),params:$e.loose().optional()}),Me=g({_meta:qo.optional()}),Ee=g({method:l(),params:Me.loose().optional()}),jo=V({get[Ht](){return Bt.optional().catch(void 0)}}),Se=V({_meta:jo.optional()}),kt=P([l(),z().int()]),Do=g({jsonrpc:v(yn),id:kt,...ge.shape}).strict(),Uo=g({jsonrpc:v(yn),...Ee.shape}).strict(),vn=g({jsonrpc:v(yn),id:kt,result:Se}).strict(),wn=g({jsonrpc:v(yn),id:kt.optional(),error:g({code:z().int(),message:l(),data:j().optional()})}).strict(),zn=P([Do,Uo,vn,wn]),md=P([vn,wn]),Mr=Se.strict(),Ui=Me.extend({requestId:kt.optional(),reason:l().optional()}),Zo=Ee.extend({method:v("notifications/cancelled"),params:Ui}),Zi=g({src:l(),mimeType:l().optional(),sizes:y(l()).optional(),theme:Y(["light","dark"]).optional()}),cr=g({icons:y(Zi).optional()}),Ft=g({name:l(),title:l().optional()}),Bt=Ft.extend({...Ft.shape,...cr.shape,version:l(),websiteUrl:l().optional(),description:l().optional()}),eT=$t(g({applyDefaults:E().optional()}),fe),tT=ir(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,$t(g({form:eT.optional(),url:fe.optional()}),fe.optional())),hd=V({list:fe.optional(),cancel:fe.optional(),requests:V({sampling:V({createMessage:fe.optional()}).optional(),elicitation:V({create:fe.optional()}).optional()}).optional()}),fd=V({list:fe.optional(),cancel:fe.optional(),requests:V({tools:V({call:fe.optional()}).optional()}).optional()}),Vi=g({experimental:T(l(),fe).optional(),sampling:g({context:fe.optional(),tools:fe.optional()}).optional(),elicitation:tT.optional(),roots:g({listChanged:E().optional()}).optional(),tasks:hd.optional(),extensions:T(l(),fe).optional()}),Fi=$e.extend({protocolVersion:l(),capabilities:Vi,clientInfo:Bt}),Hi=ge.extend({method:v("initialize"),params:Fi}),Vo=g({experimental:T(l(),fe).optional(),logging:fe.optional(),completions:fe.optional(),prompts:g({listChanged:E().optional()}).optional(),resources:g({subscribe:E().optional(),listChanged:E().optional()}).optional(),tools:g({listChanged:E().optional()}).optional(),tasks:fd.optional(),extensions:T(l(),fe).optional()}),Bi=Se.extend({protocolVersion:l(),capabilities:Vo,serverInfo:Bt,instructions:l().optional()}),Ji=Ee.extend({method:v("notifications/initialized"),params:Me.optional()}),Ki=ge.extend({method:v("server/discover"),params:$e.optional()}),Lr=Se.extend({supportedVersions:y(l()),capabilities:Vo,instructions:l().optional()}),Fo=ge.extend({method:v("ping"),params:$e.optional()}),Wi=g({progress:z(),total:M(z()),message:M(l())}),Gi=g({...Me.shape,...Wi.shape,progressToken:Mo}),Ho=Ee.extend({method:v("notifications/progress"),params:Gi}),Yi=$e.extend({cursor:Lo.optional()}),ur=ge.extend({params:Yi.optional()}),lr=Se.extend({nextCursor:Lo.optional()}),Bo=g({uri:l(),mimeType:M(l()),_meta:T(l(),j()).optional()}),Jo=Bo.extend({text:l()}),xS=l().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ko=Bo.extend({blob:xS}),dr=Y(["user","assistant"]),Jt=g({audience:y(dr).optional(),priority:z().min(0).max(1).optional(),lastModified:_t.datetime({offset:!0}).optional()}),Wo=g({...Ft.shape,...cr.shape,uri:l(),description:M(l()),mimeType:M(l()),size:M(z()),annotations:Jt.optional(),_meta:M(V({}))}),Qi=g({...Ft.shape,...cr.shape,uriTemplate:l(),description:M(l()),mimeType:M(l()),annotations:Jt.optional(),_meta:M(V({}))}),Xi=ur.extend({method:v("resources/list")}),ea=lr.extend({resources:y(Wo)}),ta=ur.extend({method:v("resources/templates/list")}),ra=lr.extend({resourceTemplates:y(Qi)}),Rn=$e.extend({uri:l()}),na=Rn,oa=ge.extend({method:v("resources/read"),params:na}),sa=Se.extend({contents:y(P([Jo,Ko]))}),ia=Ee.extend({method:v("notifications/resources/list_changed"),params:Me.optional()}),aa=Rn,ca=ge.extend({method:v("resources/subscribe"),params:aa}),ua=Rn,la=ge.extend({method:v("resources/unsubscribe"),params:ua}),Go=g({toolsListChanged:E().optional(),promptsListChanged:E().optional(),resourcesListChanged:E().optional(),resourceSubscriptions:y(l()).optional()}),da=$e.extend({notifications:Go}),pa=ge.extend({method:v("subscriptions/listen"),params:da}),ma=Me.extend({notifications:Go}),ha=Ee.extend({method:v("notifications/subscriptions/acknowledged"),params:ma}),fa=jo.extend({[No]:kt}),ga=Se.extend({_meta:fa}),Sa=Me.extend({uri:l()}),_a=Ee.extend({method:v("notifications/resources/updated"),params:Sa}),ba=g({name:l(),description:M(l()),required:M(E())}),ya=g({...Ft.shape,...cr.shape,description:M(l()),arguments:M(y(ba)),_meta:M(V({}))}),va=ur.extend({method:v("prompts/list")}),wa=lr.extend({prompts:y(ya)}),za=$e.extend({name:l(),arguments:T(l(),l()).optional()}),Ra=ge.extend({method:v("prompts/get"),params:za}),$n=g({type:v("text"),text:l(),annotations:Jt.optional(),_meta:T(l(),j()).optional()}),kn=g({type:v("image"),data:xS,mimeType:l(),annotations:Jt.optional(),_meta:T(l(),j()).optional()}),xn=g({type:v("audio"),data:xS,mimeType:l(),annotations:Jt.optional(),_meta:T(l(),j()).optional()}),$a=g({type:v("tool_use"),name:l(),id:l(),input:T(l(),j()),_meta:T(l(),j()).optional()}),Tn=g({type:v("resource"),resource:P([Jo,Ko]),annotations:Jt.optional(),_meta:T(l(),j()).optional()}),En=Wo.extend({type:v("resource_link")}),Kt=P([$n,kn,xn,En,Tn]),ka=g({role:dr,content:Kt}),xa=Se.extend({description:l().optional(),messages:y(ka)}),Ta=Ee.extend({method:v("notifications/prompts/list_changed"),params:Me.optional()}),Ea=g({title:l().optional(),readOnlyHint:E().optional(),destructiveHint:E().optional(),idempotentHint:E().optional(),openWorldHint:E().optional()}),Pa=g({taskSupport:Y(["required","optional","forbidden"]).optional()}),qr=g({...Ft.shape,...cr.shape,description:l().optional(),inputSchema:g({type:v("object"),properties:T(l(),ar).optional(),required:y(l()).optional()}).catchall(j()),outputSchema:V({$schema:l().optional()}).optional(),annotations:Ea.optional(),execution:Pa.optional(),_meta:T(l(),j()).optional()}),Ca=ur.extend({method:v("tools/list")}),Ia=lr.extend({tools:y(qr)}),jr=Se.extend({content:y(Kt).default([]),structuredContent:j().optional(),isError:E().optional()}),gd=jr.or(Se.extend({toolResult:j()})),Oa=Ar.extend({name:l(),arguments:T(l(),j()).optional()}),Na=ge.extend({method:v("tools/call"),params:Oa}),Aa=Ee.extend({method:v("notifications/tools/list_changed"),params:Me.optional()}),Ma=g({autoRefresh:E().default(!0),debounceMs:z().int().nonnegative().default(300)}),Yo=Y(["debug","info","notice","warning","error","critical","alert","emergency"]),La=$e.extend({level:Yo}),qa=ge.extend({method:v("logging/setLevel"),params:La}),ja=Me.extend({level:Yo,logger:l().optional(),data:j()}),Da=Ee.extend({method:v("notifications/message"),params:ja}),Ua=g({name:l().optional()}),Za=g({hints:y(Ua).optional(),costPriority:z().min(0).max(1).optional(),speedPriority:z().min(0).max(1).optional(),intelligencePriority:z().min(0).max(1).optional()}),Va=g({mode:Y(["auto","required","none"]).optional()}),Fa=g({type:v("tool_result"),toolUseId:l().describe("The unique identifier for the corresponding tool call."),content:y(Kt),structuredContent:j().optional(),isError:E().optional(),_meta:T(l(),j()).optional()}),Ha=Ir("type",[$n,kn,xn]),Nr=Ir("type",[$n,kn,xn,$a,Fa]),Ba=g({role:dr,content:P([Nr,y(Nr)]),_meta:T(l(),j()).optional()}),Ja=Ar.extend({messages:y(Ba),modelPreferences:Za.optional(),systemPrompt:l().optional(),includeContext:Y(["none","thisServer","allServers"]).optional(),temperature:z().optional(),maxTokens:z().int(),stopSequences:y(l()).optional(),metadata:fe.optional(),tools:y(qr).optional(),toolChoice:Va.optional()}),Ka=ge.extend({method:v("sampling/createMessage"),params:Ja}),Wa=Se.extend({model:l(),stopReason:M(Y(["endTurn","stopSequence","maxTokens"]).or(l())),role:dr,content:Ha}),Ga=Se.extend({model:l(),stopReason:M(Y(["endTurn","stopSequence","maxTokens","toolUse"]).or(l())),role:dr,content:P([Nr,y(Nr)])}),Qo=g({type:v("boolean"),title:l().optional(),description:l().optional(),default:E().optional()}),Pn=g({type:v("string"),title:l().optional(),description:l().optional(),minLength:z().optional(),maxLength:z().optional(),format:Y(["email","uri","date","date-time"]).optional(),default:l().optional()}),Cn=g({type:Y(["number","integer"]),title:l().optional(),description:l().optional(),minimum:z().optional(),maximum:z().optional(),default:z().optional()}),Xo=g({type:v("string"),title:l().optional(),description:l().optional(),enum:y(l()),default:l().optional()}),es=g({type:v("string"),title:l().optional(),description:l().optional(),oneOf:y(g({const:l(),title:l()})),default:l().optional()}),ts=g({type:v("string"),title:l().optional(),description:l().optional(),enum:y(l()),enumNames:y(l()).optional(),default:l().optional()}),Ya=P([Xo,es]),rs=g({type:v("array"),title:l().optional(),description:l().optional(),minItems:z().optional(),maxItems:z().optional(),items:g({type:v("string"),enum:y(l())}),default:y(l()).optional()}),ns=g({type:v("array"),title:l().optional(),description:l().optional(),minItems:z().optional(),maxItems:z().optional(),items:g({anyOf:y(g({const:l(),title:l()}))}),default:y(l()).optional()}),Qa=P([rs,ns]),Xa=P([ts,Ya,Qa]),os=P([Xa,Qo,Pn,Cn]),In=Ar.extend({mode:v("form").optional(),message:l(),requestedSchema:g({type:v("object"),properties:T(l(),os),required:y(l()).optional()}).catchall(j())}),ec=Ar.extend({mode:v("url"),message:l(),elicitationId:l(),url:l().url()}),tc=P([In,ec]),rc=ge.extend({method:v("elicitation/create"),params:tc}),nc=Me.extend({elicitationId:l()}),oc=Ee.extend({method:v("notifications/elicitation/complete"),params:nc}),sc=Se.extend({action:Y(["accept","decline","cancel"]),content:ir(e=>e===null?void 0:e,T(l(),P([l(),z(),E(),y(l())])).optional())}),ic=g({type:v("ref/resource"),uri:l()}),ac=g({type:v("ref/prompt"),name:l()}),cc=$e.extend({ref:P([ac,ic]),argument:g({name:l(),value:l()}),context:g({arguments:T(l(),l()).optional()}).optional()}),uc=ge.extend({method:v("completion/complete"),params:cc}),lc=Se.extend({completion:V({values:y(l()).max(100),total:M(z().int()),hasMore:M(E())})}),dc=g({uri:l().startsWith("file://"),name:l().optional(),_meta:T(l(),j()).optional()}),pc=ge.extend({method:v("roots/list"),params:$e.optional()}),mc=Se.extend({roots:y(dc)}),hc=Ee.extend({method:v("notifications/roots/list_changed"),params:Me.optional()}),Sd=V({ttl:z().optional(),pollInterval:z().optional()}),fc=Y(["working","input_required","completed","failed","cancelled"]),pr=g({taskId:l(),status:fc,ttl:P([z(),Vt()]),createdAt:l(),lastUpdatedAt:l(),pollInterval:M(z()),statusMessage:M(l())}),_d=Se.extend({task:pr}),gc=Me.merge(pr),bd=Ee.extend({method:v("notifications/tasks/status"),params:gc}),yd=ge.extend({method:v("tasks/get"),params:$e.extend({taskId:l()})}),vd=Se.merge(pr),wd=ge.extend({method:v("tasks/result"),params:$e.extend({taskId:l()})}),zd=Se.loose(),Rd=ur.extend({method:v("tasks/list")}),$d=lr.extend({tasks:y(pr)}),kd=ge.extend({method:v("tasks/cancel"),params:$e.extend({taskId:l()})}),xd=Se.merge(pr),Td=P([Fo,Hi,Ki,uc,qa,Ra,va,Xi,ta,oa,ca,la,pa,Na,Ca]),Ed=P([Zo,Ho,Ji,hc]),Pd=P([Mr,Wa,Ga,sc,mc]),Cd=P([Fo,Ka,rc,pc]),Id=P([Zo,Ho,Da,_a,ia,Aa,Ta,ha,oc]),Od=P([Mr,Bi,Lr,lc,xa,wa,ea,ra,sa,jr,Ia,ga]);var ke=To().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:$S.custom,message:"URL must be parseable",fatal:!0}),Gs}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Sc=V({resource:l().url(),authorization_servers:y(ke).optional(),jwks_uri:l().url().optional(),scopes_supported:y(l()).optional(),bearer_methods_supported:y(l()).optional(),resource_signing_alg_values_supported:y(l()).optional(),resource_name:l().optional(),resource_documentation:l().optional(),resource_policy_uri:l().url().optional(),resource_tos_uri:l().url().optional(),tls_client_certificate_bound_access_tokens:E().optional(),authorization_details_types_supported:y(l()).optional(),dpop_signing_alg_values_supported:y(l()).optional(),dpop_bound_access_tokens_required:E().optional()}),ss=V({issuer:l(),authorization_endpoint:ke,token_endpoint:ke,registration_endpoint:ke.optional(),scopes_supported:y(l()).optional(),response_types_supported:y(l()),response_modes_supported:y(l()).optional(),grant_types_supported:y(l()).optional(),token_endpoint_auth_methods_supported:y(l()).optional(),token_endpoint_auth_signing_alg_values_supported:y(l()).optional(),service_documentation:ke.optional(),revocation_endpoint:ke.optional(),revocation_endpoint_auth_methods_supported:y(l()).optional(),revocation_endpoint_auth_signing_alg_values_supported:y(l()).optional(),introspection_endpoint:l().optional(),introspection_endpoint_auth_methods_supported:y(l()).optional(),introspection_endpoint_auth_signing_alg_values_supported:y(l()).optional(),code_challenge_methods_supported:y(l()).optional(),client_id_metadata_document_supported:E().optional(),authorization_response_iss_parameter_supported:E().optional().catch(void 0),dpop_signing_alg_values_supported:y(l()).optional()}),_c=V({issuer:l(),authorization_endpoint:ke,token_endpoint:ke,userinfo_endpoint:ke.optional(),jwks_uri:ke,registration_endpoint:ke.optional(),scopes_supported:y(l()).optional(),response_types_supported:y(l()),response_modes_supported:y(l()).optional(),grant_types_supported:y(l()).optional(),acr_values_supported:y(l()).optional(),subject_types_supported:y(l()),id_token_signing_alg_values_supported:y(l()),id_token_encryption_alg_values_supported:y(l()).optional(),id_token_encryption_enc_values_supported:y(l()).optional(),userinfo_signing_alg_values_supported:y(l()).optional(),userinfo_encryption_alg_values_supported:y(l()).optional(),userinfo_encryption_enc_values_supported:y(l()).optional(),request_object_signing_alg_values_supported:y(l()).optional(),request_object_encryption_alg_values_supported:y(l()).optional(),request_object_encryption_enc_values_supported:y(l()).optional(),token_endpoint_auth_methods_supported:y(l()).optional(),token_endpoint_auth_signing_alg_values_supported:y(l()).optional(),display_values_supported:y(l()).optional(),claim_types_supported:y(l()).optional(),claims_supported:y(l()).optional(),service_documentation:l().optional(),claims_locales_supported:y(l()).optional(),ui_locales_supported:y(l()).optional(),claims_parameter_supported:E().optional(),request_parameter_supported:E().optional(),request_uri_parameter_supported:E().optional(),require_request_uri_registration:E().optional(),op_policy_uri:ke.optional(),op_tos_uri:ke.optional(),client_id_metadata_document_supported:E().optional(),authorization_response_iss_parameter_supported:E().optional().catch(void 0)}),bc=g({..._c.shape,...ss.pick({code_challenge_methods_supported:!0}).shape}),is=g({access_token:l(),id_token:l().optional(),token_type:l(),expires_in:Li.number().optional(),scope:l().optional(),refresh_token:l().optional(),issuer:l().optional().catch(void 0)}).strip(),yc=g({issued_token_type:v("urn:ietf:params:oauth:token-type:id-jag"),access_token:l(),token_type:l().optional(),expires_in:z().optional(),scope:l().optional()}).strip(),as=g({error:l(),error_description:l().optional(),error_uri:l().optional()}),TS=ke.optional().or(v("").transform(()=>{})),vc=g({redirect_uris:y(ke),token_endpoint_auth_method:l().optional(),grant_types:y(l()).optional(),response_types:y(l()).optional(),application_type:l().optional(),client_name:l().optional(),client_uri:ke.optional(),logo_uri:TS,scope:l().optional(),contacts:y(l()).optional(),tos_uri:TS,policy_uri:l().optional(),jwks_uri:ke.optional(),jwks:sd().optional(),software_id:l().optional(),software_version:l().optional(),software_statement:l().optional()}).strip(),wc=g({client_id:l(),client_secret:l().optional(),client_id_issued_at:z().optional(),client_secret_expires_at:z().optional(),issuer:l().optional().catch(void 0)}).strip(),zc=vc.merge(wc),Nd=g({error:l(),error_description:l().optional()}).strip(),Ad=g({token:l(),token_type_hint:l().optional()}).strip();var OS=Symbol.for("mcp.sdk.errorBrands");function Ur(e,t){let r=new Set,n=t;for(;typeof n=="function";){let o=n.mcpBrand;Object.prototype.hasOwnProperty.call(n,"mcpBrand")&&typeof o=="string"&&r.add(o),n=Object.getPrototypeOf(n)}r.size!==0&&Object.defineProperty(e,OS,{value:r,enumerable:!1,configurable:!0})}function rt(e,t){try{if(typeof t=="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand=="string"&&Object.prototype.hasOwnProperty.call(t,OS)){let r=t[OS];if(r&&typeof r.has=="function"&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var Iw=class Ow extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return rt(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rt(this,t)}constructor(t,r,n){super(r),this.code=t,this.errorUri=n,this.name="OAuthError",Ur(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}static fromResponse(t){return new Ow(t.error,t.error_description??t.error,t.error_uri)}},D=(function(e){return e.NotConnected="NOT_CONNECTED",e.AlreadyConnected="ALREADY_CONNECTED",e.NotInitialized="NOT_INITIALIZED",e.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",e.RequestTimeout="REQUEST_TIMEOUT",e.ConnectionClosed="CONNECTION_CLOSED",e.SendFailed="SEND_FAILED",e.InvalidResult="INVALID_RESULT",e.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",e.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",e.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",e.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",e.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",e.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",e.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",e.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",e.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",e.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",e.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",e})({}),L=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return rt(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rt(this,e)}constructor(e,t,r,n){super(t,n),this.code=e,this.data=r,this.name="SdkError",Ur(this,new.target)}},Ec=class extends L{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,r,n){super(e,t,r,n),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};var Nw="2026-07-28",qS=[Nw];function hr(e){return e>=Nw}function jS(e){return e.filter(t=>!hr(t))}function Pc(e){return e.filter(t=>hr(t))}function Aw(e){let t=e.structuredContent;return t===void 0||!(typeof t!="object"||t===null||Array.isArray(t))||(e.content?.some(r=>r.type==="text")??!1)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var Mw=["task","inputRequests","requestState"];function rT(e){return e===null||typeof e!="object"||Array.isArray(e)||e.content!==void 0||Mw.some(t=>t in e)?e:{...e,content:[]}}function nT(){let e=Or(()=>P([l(),z(),E(),Vt(),T(l(),e),y(e)])),t=T(l(),e),r=P([l(),z().int()]),n=l(),o=g({ttl:z().optional()}),s=g({taskId:l()}),i=V({progressToken:r.optional(),"io.modelcontextprotocol/related-task":s.optional()}),a=g({_meta:i.optional()}),c=a.extend({task:o.optional()}),u=g({method:l(),params:a.loose().optional()}),d=g({_meta:i.optional()}),p=g({method:l(),params:d.loose().optional()}),h=V({_meta:i.optional()}),f=P([l(),z().int()]),S=h.strict(),_=d.extend({requestId:f.optional(),reason:l().optional()}),w=p.extend({method:v("notifications/cancelled"),params:_}),x=g({src:l(),mimeType:l().optional(),sizes:y(l()).optional(),theme:Y(["light","dark"]).optional()}),R=g({icons:y(x).optional()}),k=g({name:l(),title:l().optional()}),J=k.extend({...k.shape,...R.shape,version:l(),websiteUrl:l().optional(),description:l().optional()}),se=$t(g({applyDefaults:E().optional()}),t),U=ir(Ne=>Ne&&typeof Ne=="object"&&!Array.isArray(Ne)&&Object.keys(Ne).length===0?{form:{}}:Ne,$t(g({form:se.optional(),url:t.optional()}),t.optional())),ie=V({list:t.optional(),cancel:t.optional(),requests:V({sampling:V({createMessage:t.optional()}).optional(),elicitation:V({create:t.optional()}).optional()}).optional()}),Pe=V({list:t.optional(),cancel:t.optional(),requests:V({tools:V({call:t.optional()}).optional()}).optional()}),he=g({experimental:T(l(),t).optional(),sampling:g({context:t.optional(),tools:t.optional()}).optional(),elicitation:U.optional(),roots:g({listChanged:E().optional()}).optional(),tasks:ie.optional(),extensions:T(l(),t).optional()}),Ce=a.extend({protocolVersion:l(),capabilities:he,clientInfo:J}),Je=u.extend({method:v("initialize"),params:Ce}),Tt=g({experimental:T(l(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:g({listChanged:E().optional()}).optional(),resources:g({subscribe:E().optional(),listChanged:E().optional()}).optional(),tools:g({listChanged:E().optional()}).optional(),tasks:Pe.optional(),extensions:T(l(),t).optional()}),Et=h.extend({protocolVersion:l(),capabilities:Tt,serverInfo:J,instructions:l().optional()}),Pt=p.extend({method:v("notifications/initialized"),params:d.optional()}),lt=u.extend({method:v("ping"),params:a.optional()}),Ct=g({progress:z(),total:M(z()),message:M(l())}),Ke=g({...d.shape,...Ct.shape,progressToken:r}),dt=p.extend({method:v("notifications/progress"),params:Ke}),It=a.extend({cursor:n.optional()}),nt=u.extend({params:It.optional()}),Le=h.extend({nextCursor:n.optional()}),Qt=g({uri:l(),mimeType:M(l()),_meta:T(l(),j()).optional()}),Xt=Qt.extend({text:l()}),Ot=l().refine(Ne=>{try{return atob(Ne),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ie=Qt.extend({blob:Ot}),qe=Y(["user","assistant"]),je=g({audience:y(qe).optional(),priority:z().min(0).max(1).optional(),lastModified:_t.datetime({offset:!0}).optional()}),yt=g({...k.shape,...R.shape,uri:l(),description:M(l()),mimeType:M(l()),size:M(z()),annotations:je.optional(),_meta:M(V({}))}),Vr=g({...k.shape,...R.shape,uriTemplate:l(),description:M(l()),mimeType:M(l()),annotations:je.optional(),_meta:M(V({}))}),ot=nt.extend({method:v("resources/list")}),st=Le.extend({resources:y(yt)}),We=nt.extend({method:v("resources/templates/list")}),pt=Le.extend({resourceTemplates:y(Vr)}),mt=a.extend({uri:l()}),Nt=mt,At=u.extend({method:v("resources/read"),params:Nt}),fr=h.extend({contents:y(P([Xt,Ie]))}),Mt=p.extend({method:v("notifications/resources/list_changed"),params:d.optional()}),Fr=mt,O=u.extend({method:v("resources/subscribe"),params:Fr}),Lt=mt,H=u.extend({method:v("resources/unsubscribe"),params:Lt}),q=d.extend({uri:l()}),ee=p.extend({method:v("notifications/resources/updated"),params:q}),N=g({name:l(),description:M(l()),required:M(E())}),C=g({...k.shape,...R.shape,description:M(l()),arguments:M(y(N)),_meta:M(V({}))}),G=nt.extend({method:v("prompts/list")}),K=Le.extend({prompts:y(C)}),ve=a.extend({name:l(),arguments:T(l(),l()).optional()}),Hr=u.extend({method:v("prompts/get"),params:ve}),qt=g({type:v("text"),text:l(),annotations:je.optional(),_meta:T(l(),j()).optional()}),Br=g({type:v("image"),data:Ot,mimeType:l(),annotations:je.optional(),_meta:T(l(),j()).optional()}),Jr=g({type:v("audio"),data:Ot,mimeType:l(),annotations:je.optional(),_meta:T(l(),j()).optional()}),ps=g({type:v("tool_use"),name:l(),id:l(),input:T(l(),j()),_meta:T(l(),j()).optional()}),gr=g({type:v("resource"),resource:P([Xt,Ie]),annotations:je.optional(),_meta:T(l(),j()).optional()}),ms=yt.extend({type:v("resource_link")}),ht=P([qt,Br,Jr,ms,gr]),Mn=g({role:qe,content:ht}),Ln=h.extend({description:l().optional(),messages:y(Mn)}),Kr=p.extend({method:v("notifications/prompts/list_changed"),params:d.optional()}),hs=g({title:l().optional(),readOnlyHint:E().optional(),destructiveHint:E().optional(),idempotentHint:E().optional(),openWorldHint:E().optional()}),qn=g({taskSupport:Y(["required","optional","forbidden"]).optional()}),Wr=g({...k.shape,...R.shape,description:l().optional(),inputSchema:g({type:v("object"),properties:T(l(),e).optional(),required:y(l()).optional()}).catchall(j()),outputSchema:g({type:v("object"),properties:T(l(),e).optional(),required:y(l()).optional()}).catchall(j()).optional(),annotations:hs.optional(),execution:qn.optional(),_meta:T(l(),j()).optional()}),jn=nt.extend({method:v("tools/list")}),Dn=Le.extend({tools:y(Wr)}),Un=h.extend({content:y(ht),structuredContent:T(l(),j()).optional(),isError:E().optional()}),Oe=c.extend({name:l(),arguments:T(l(),j()).optional()}),fs=u.extend({method:v("tools/call"),params:Oe}),Zc=p.extend({method:v("notifications/tools/list_changed"),params:d.optional()}),Zn=Y(["debug","info","notice","warning","error","critical","alert","emergency"]),gs=a.extend({level:Zn}),Ss=u.extend({method:v("logging/setLevel"),params:gs}),_s=d.extend({level:Zn,logger:l().optional(),data:j()}),bs=p.extend({method:v("notifications/message"),params:_s}),ys=g({name:l().optional()}),vs=g({hints:y(ys).optional(),costPriority:z().min(0).max(1).optional(),speedPriority:z().min(0).max(1).optional(),intelligencePriority:z().min(0).max(1).optional()}),ws=g({mode:Y(["auto","required","none"]).optional()}),Vc=g({type:v("tool_result"),toolUseId:l().describe("The unique identifier for the corresponding tool call."),content:y(ht),structuredContent:g({}).loose().optional(),isError:E().optional(),_meta:T(l(),j()).optional()}),zs=Ir("type",[qt,Br,Jr]),Sr=Ir("type",[qt,Br,Jr,ps,Vc]),Rs=g({role:qe,content:P([Sr,y(Sr)]),_meta:T(l(),j()).optional()}),$s=c.extend({messages:y(Rs),modelPreferences:vs.optional(),systemPrompt:l().optional(),includeContext:Y(["none","thisServer","allServers"]).optional(),temperature:z().optional(),maxTokens:z().int(),stopSequences:y(l()).optional(),metadata:t.optional(),tools:y(Wr).optional(),toolChoice:ws.optional()}),ks=u.extend({method:v("sampling/createMessage"),params:$s}),xs=h.extend({model:l(),stopReason:M(Y(["endTurn","stopSequence","maxTokens"]).or(l())),role:qe,content:zs}),Ts=h.extend({model:l(),stopReason:M(Y(["endTurn","stopSequence","maxTokens","toolUse"]).or(l())),role:qe,content:P([Sr,y(Sr)])}),Es=g({type:v("boolean"),title:l().optional(),description:l().optional(),default:E().optional()}),Ps=g({type:v("string"),title:l().optional(),description:l().optional(),minLength:z().optional(),maxLength:z().optional(),format:Y(["email","uri","date","date-time"]).optional(),default:l().optional()}),Cs=g({type:Y(["number","integer"]),title:l().optional(),description:l().optional(),minimum:z().optional(),maximum:z().optional(),default:z().optional()}),Is=g({type:v("string"),title:l().optional(),description:l().optional(),enum:y(l()),default:l().optional()}),Os=g({type:v("string"),title:l().optional(),description:l().optional(),oneOf:y(g({const:l(),title:l()})),default:l().optional()}),Ns=g({type:v("string"),title:l().optional(),description:l().optional(),enum:y(l()),enumNames:y(l()).optional(),default:l().optional()}),As=P([Is,Os]),Gr=g({type:v("array"),title:l().optional(),description:l().optional(),minItems:z().optional(),maxItems:z().optional(),items:g({type:v("string"),enum:y(l())}),default:y(l()).optional()}),Yr=g({type:v("array"),title:l().optional(),description:l().optional(),minItems:z().optional(),maxItems:z().optional(),items:g({anyOf:y(g({const:l(),title:l()}))}),default:y(l()).optional()}),Fc=P([Gr,Yr]),Hc=P([Ns,As,Fc]),it=P([Hc,Es,Ps,Cs]),at=c.extend({mode:v("form").optional(),message:l(),requestedSchema:g({type:v("object"),properties:T(l(),it),required:y(l()).optional()}).catchall(j())}),Ms=c.extend({mode:v("url"),message:l(),elicitationId:l(),url:l().url()}),vt=P([at,Ms]),Bc=u.extend({method:v("elicitation/create"),params:vt}),Jc=d.extend({elicitationId:l()}),Kc=p.extend({method:v("notifications/elicitation/complete"),params:Jc}),Wc=h.extend({action:Y(["accept","decline","cancel"]),content:ir(Ne=>Ne===null?void 0:Ne,T(l(),P([l(),z(),E(),y(l())])).optional())}),Gc=g({type:v("ref/resource"),uri:l()}),Yc=g({type:v("ref/prompt"),name:l()}),Qc=a.extend({ref:P([Yc,Gc]),argument:g({name:l(),value:l()}),context:g({arguments:T(l(),l()).optional()}).optional()}),Ls=u.extend({method:v("completion/complete"),params:Qc}),Xc=h.extend({completion:V({values:y(l()).max(100),total:M(z().int()),hasMore:M(E())})}),eu=g({uri:l().startsWith("file://"),name:l().optional(),_meta:T(l(),j()).optional()}),Vn=u.extend({method:v("roots/list"),params:a.optional()}),qs=h.extend({roots:y(eu)}),tu=p.extend({method:v("notifications/roots/list_changed"),params:d.optional()}),ru=V({ttl:z().optional(),pollInterval:z().optional()}),js=Y(["working","input_required","completed","failed","cancelled"]),_r=g({taskId:l(),status:js,ttl:P([z(),Vt()]),createdAt:l(),lastUpdatedAt:l(),pollInterval:M(z()),statusMessage:M(l())}),Ge=h.extend({task:_r}),nu=d.merge(_r),Qr=p.extend({method:v("notifications/tasks/status"),params:nu}),Fn=u.extend({method:v("tasks/get"),params:a.extend({taskId:l()})}),Hn=h.merge(_r),Bn=u.extend({method:v("tasks/result"),params:a.extend({taskId:l()})}),ip=h.loose(),De=nt.extend({method:v("tasks/list")}),ye=Le.extend({tasks:y(_r)}),Xr=u.extend({method:v("tasks/cancel"),params:a.extend({taskId:l()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:n,TaskMetadataSchema:o,RelatedTaskMetadataSchema:s,RequestMetaSchema:i,BaseRequestParamsSchema:a,TaskAugmentedRequestParamsSchema:c,RequestSchema:u,NotificationsParamsSchema:d,NotificationSchema:p,ResultSchema:h,RequestIdSchema:f,EmptyResultSchema:S,CancelledNotificationParamsSchema:_,CancelledNotificationSchema:w,IconSchema:x,IconsSchema:R,BaseMetadataSchema:k,ImplementationSchema:J,ClientTasksCapabilitySchema:ie,ServerTasksCapabilitySchema:Pe,ClientCapabilitiesSchema:he,InitializeRequestParamsSchema:Ce,InitializeRequestSchema:Je,ServerCapabilitiesSchema:Tt,InitializeResultSchema:Et,InitializedNotificationSchema:Pt,PingRequestSchema:lt,ProgressSchema:Ct,ProgressNotificationParamsSchema:Ke,ProgressNotificationSchema:dt,PaginatedRequestParamsSchema:It,PaginatedRequestSchema:nt,PaginatedResultSchema:Le,ResourceContentsSchema:Qt,TextResourceContentsSchema:Xt,BlobResourceContentsSchema:Ie,RoleSchema:qe,AnnotationsSchema:je,ResourceSchema:yt,ResourceTemplateSchema:Vr,ListResourcesRequestSchema:ot,ListResourcesResultSchema:st,ListResourceTemplatesRequestSchema:We,ListResourceTemplatesResultSchema:pt,ResourceRequestParamsSchema:mt,ReadResourceRequestParamsSchema:Nt,ReadResourceRequestSchema:At,ReadResourceResultSchema:fr,ResourceListChangedNotificationSchema:Mt,SubscribeRequestParamsSchema:Fr,SubscribeRequestSchema:O,UnsubscribeRequestParamsSchema:Lt,UnsubscribeRequestSchema:H,ResourceUpdatedNotificationParamsSchema:q,ResourceUpdatedNotificationSchema:ee,PromptArgumentSchema:N,PromptSchema:C,ListPromptsRequestSchema:G,ListPromptsResultSchema:K,GetPromptRequestParamsSchema:ve,GetPromptRequestSchema:Hr,TextContentSchema:qt,ImageContentSchema:Br,AudioContentSchema:Jr,ToolUseContentSchema:ps,EmbeddedResourceSchema:gr,ResourceLinkSchema:ms,ContentBlockSchema:ht,PromptMessageSchema:Mn,GetPromptResultSchema:Ln,PromptListChangedNotificationSchema:Kr,ToolAnnotationsSchema:hs,ToolExecutionSchema:qn,ToolSchema:Wr,ListToolsRequestSchema:jn,ListToolsResultSchema:Dn,CallToolResultSchema:Un,CallToolRequestParamsSchema:Oe,CallToolRequestSchema:fs,ToolListChangedNotificationSchema:Zc,LoggingLevelSchema:Zn,SetLevelRequestParamsSchema:gs,SetLevelRequestSchema:Ss,LoggingMessageNotificationParamsSchema:_s,LoggingMessageNotificationSchema:bs,ModelHintSchema:ys,ModelPreferencesSchema:vs,ToolChoiceSchema:ws,ToolResultContentSchema:Vc,SamplingContentSchema:zs,SamplingMessageContentBlockSchema:Sr,SamplingMessageSchema:Rs,CreateMessageRequestParamsSchema:$s,CreateMessageRequestSchema:ks,CreateMessageResultSchema:xs,CreateMessageResultWithToolsSchema:Ts,BooleanSchemaSchema:Es,StringSchemaSchema:Ps,NumberSchemaSchema:Cs,UntitledSingleSelectEnumSchemaSchema:Is,TitledSingleSelectEnumSchemaSchema:Os,LegacyTitledEnumSchemaSchema:Ns,SingleSelectEnumSchemaSchema:As,UntitledMultiSelectEnumSchemaSchema:Gr,TitledMultiSelectEnumSchemaSchema:Yr,MultiSelectEnumSchemaSchema:Fc,EnumSchemaSchema:Hc,PrimitiveSchemaDefinitionSchema:it,ElicitRequestFormParamsSchema:at,ElicitRequestURLParamsSchema:Ms,ElicitRequestParamsSchema:vt,ElicitRequestSchema:Bc,ElicitationCompleteNotificationParamsSchema:Jc,ElicitationCompleteNotificationSchema:Kc,ElicitResultSchema:Wc,ResourceTemplateReferenceSchema:Gc,PromptReferenceSchema:Yc,CompleteRequestParamsSchema:Qc,CompleteRequestSchema:Ls,CompleteResultSchema:Xc,RootSchema:eu,ListRootsRequestSchema:Vn,ListRootsResultSchema:qs,RootsListChangedNotificationSchema:tu,TaskCreationParamsSchema:ru,TaskStatusSchema:js,TaskSchema:_r,CreateTaskResultSchema:Ge,TaskStatusNotificationParamsSchema:nu,TaskStatusNotificationSchema:Qr,GetTaskRequestSchema:Fn,GetTaskResultSchema:Hn,GetTaskPayloadRequestSchema:Bn,GetTaskPayloadResultSchema:ip,ListTasksRequestSchema:De,ListTasksResultSchema:ye,CancelTaskRequestSchema:Xr,CancelTaskResultSchema:h.merge(_r),ClientRequestSchema:P([lt,Je,Ls,Ss,Hr,G,ot,We,At,O,H,fs,jn,Fn,Bn,De,Xr]),ClientNotificationSchema:P([w,dt,Pt,tu,Qr]),ClientResultSchema:P([S,xs,Ts,Wc,qs,Hn,ye,Ge]),ServerRequestSchema:P([lt,ks,Bc,Vn,Fn,Bn,De,Xr]),ServerNotificationSchema:P([w,dt,bs,ee,Mt,Zc,Kr,Qr,Kc]),ServerResultSchema:P([S,Et,Xc,Ln,K,st,pt,fr,Un,Dn,Hn,ye,Ge]),CallToolResultWireSchema:j().superRefine((Ne,iR)=>{if(!(typeof Ne!="object"||Ne===null||Array.isArray(Ne)||Ne.content!==void 0)){for(let g_ of Mw)if(g_ in Ne){iR.addIssue({code:"custom",message:`content is required when the body carries '${g_}' \u2014 another result family cannot default into an empty tools/call success`});return}}}).transform(rT).pipe(Un)}}var oT;function Lw(){return oT??=nT()}function qw(e){return e.type!=="object"}var sT=new Set(["const","enum","default","examples"]),iT=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function vw(e){return e!==void 0&&!(typeof e=="string"&&e.startsWith("#"))}function aT(e){let t=typeof e.$schema=="string"?e.$schema:void 0;if(vw(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let r=v_(e.$schema)&&e.$recursiveAnchor!==!0,n=(o,s)=>{if(Array.isArray(o))return o.map(c=>n(c,!1));if(o===null||typeof o!="object"||!s&&vw(o.$id))return o;let i={},a=!1;for(let[c,u]of Object.entries(o))s?i[c]=n(u,!1):(c==="$ref"||c==="$dynamicRef")&&typeof u=="string"?i[c]=u==="#"?"#/properties/result":u.startsWith("#/")?`#/properties/result${u.slice(1)}`:u:c==="$recursiveRef"&&u==="#"&&r?a=!0:sT.has(c)?i[c]=u:iT.has(c)?i[c]=n(u,!0):i[c]=n(u,!1);return a&&("$ref"in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:"#/properties/result"}]:i.$ref="#/properties/result"),i};return{...t!==void 0&&{$schema:t},type:"object",properties:{result:n(e,!1)},required:["result"]}}var jw={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Dw={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},cT={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Md;function DS(){if(Md)return Md;let e=Lw();return Md={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Md}function Uw(e){return Object.prototype.hasOwnProperty.call(jw,e)}function Zw(e){return Object.prototype.hasOwnProperty.call(Dw,e)}function uT(e){return Object.prototype.hasOwnProperty.call(cT,e)}function lT(e){return uT(e)?DS().resultSchemas[e]:void 0}function dT(e){return Uw(e)?DS().requestSchemas[e]:void 0}function pT(e){return Zw(e)?DS().notificationSchemas[e]:void 0}var RN=Object.keys(jw),$N=Object.keys(Dw);function NS(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ld(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}var ww={ok:!1,reason:"not-in-era"};function zw(e){return NS(e)&&NS(e.outputSchema)&&qw(e.outputSchema)}var US={era:"2025-11-25",hasRequestMethod:Uw,hasNotificationMethod:Zw,validateRequest:(e,t)=>Ld(dT(e),t),validateResult:(e,t)=>Ld(lT(e),t),validateNotification:(e,t)=>Ld(pT(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>ww,validateInputResponse:()=>ww,samplingResultVariant:((e,t)=>{let r=Lw();return Ld(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)}),outboundEnvelope:e=>{},validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let r=Aw(e),n=r.structuredContent;if(n===void 0)return r;let o=typeof n!="object"||n===null||Array.isArray(n),s=t!==void 0&&qw(t);return!o&&!s?r:{...r,structuredContent:{result:n}}},decodeResult(e,t){if(NS(t)&&"resultType"in t){let r={...t};return delete r.resultType,{kind:"complete",result:r}}return{kind:"complete",result:t}},encodeResult(e,t){if(e!=="tools/list")return t;let r=t.tools;return!Array.isArray(r)||!r.some(n=>zw(n))?t:{...t,tools:r.map(n=>zw(n)?{...n,outputSchema:aT(n.outputSchema)}:n)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>{}};function mT(){let e=Or(()=>P([l(),z(),E(),Vt(),T(l(),e),y(e)])),t=T(l(),e),r=P([l(),z().int()]),n=l(),o=P([l(),z().int()]),s=Y(["user","assistant"]),i=Y(["debug","info","notice","warning","error","critical","alert","emergency"]),a=l().refine(ye=>{try{return atob(ye),!0}catch{return!1}},{message:"Invalid Base64 string"}),c=g({ttl:z().optional()}),u=g({taskId:l()}),d=V({progressToken:r.optional(),"io.modelcontextprotocol/related-task":u.optional()}),p=g({_meta:d.optional()}),h=p.extend({task:c.optional()}),f=g({_meta:d.optional()}),S=g({method:l(),params:f.loose().optional()}),_=g({src:l(),mimeType:l().optional(),sizes:y(l()).optional(),theme:Y(["light","dark"]).optional()}),w=g({icons:y(_).optional()}),x=g({name:l(),title:l().optional()}),R=x.extend({...x.shape,...w.shape,version:l(),websiteUrl:l().optional(),description:l().optional()}),k=$t(g({applyDefaults:E().optional()}),t),J=ir(ye=>ye&&typeof ye=="object"&&!Array.isArray(ye)&&Object.keys(ye).length===0?{form:{}}:ye,$t(g({form:k.optional(),url:t.optional()}),t.optional())),se=V({list:t.optional(),cancel:t.optional(),requests:V({sampling:V({createMessage:t.optional()}).optional(),elicitation:V({create:t.optional()}).optional()}).optional()}),U=V({list:t.optional(),cancel:t.optional(),requests:V({tools:V({call:t.optional()}).optional()}).optional()}),ie=g({experimental:T(l(),t).optional(),sampling:g({context:t.optional(),tools:t.optional()}).optional(),elicitation:J.optional(),roots:g({listChanged:E().optional()}).optional(),tasks:se.optional(),extensions:T(l(),t).optional()}),Pe=g({experimental:T(l(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:g({listChanged:E().optional()}).optional(),resources:g({subscribe:E().optional(),listChanged:E().optional()}).optional(),tools:g({listChanged:E().optional()}).optional(),tasks:U.optional(),extensions:T(l(),t).optional()}),he=g({progress:z(),total:M(z()),message:M(l())}),Ce=g({...f.shape,...he.shape,progressToken:r}),Je=S.extend({method:v("notifications/progress"),params:Ce}),Tt=f.extend({level:i,logger:l().optional(),data:j()}),Et=S.extend({method:v("notifications/message"),params:Tt}),Pt=g({uri:l(),mimeType:M(l()),_meta:T(l(),j()).optional()}),lt=Pt.extend({text:l()}),Ct=Pt.extend({blob:a}),Ke=g({audience:y(s).optional(),priority:z().min(0).max(1).optional(),lastModified:_t.datetime({offset:!0}).optional()}),dt=g({...x.shape,...w.shape,uri:l(),description:M(l()),mimeType:M(l()),size:M(z()),annotations:Ke.optional(),_meta:M(V({}))}),It=g({...x.shape,...w.shape,uriTemplate:l(),description:M(l()),mimeType:M(l()),annotations:Ke.optional(),_meta:M(V({}))}),nt=S.extend({method:v("notifications/resources/list_changed"),params:f.optional()}),Le=f.extend({uri:l()}),Qt=S.extend({method:v("notifications/resources/updated"),params:Le}),Xt=g({name:l(),description:M(l()),required:M(E())}),Ot=g({...x.shape,...w.shape,description:M(l()),arguments:M(y(Xt)),_meta:M(V({}))}),Ie=S.extend({method:v("notifications/prompts/list_changed"),params:f.optional()}),qe=g({type:v("text"),text:l(),annotations:Ke.optional(),_meta:T(l(),j()).optional()}),je=g({type:v("image"),data:a,mimeType:l(),annotations:Ke.optional(),_meta:T(l(),j()).optional()}),yt=g({type:v("audio"),data:a,mimeType:l(),annotations:Ke.optional(),_meta:T(l(),j()).optional()}),Vr=g({type:v("tool_use"),name:l(),id:l(),input:T(l(),j()),_meta:T(l(),j()).optional()}),ot=g({type:v("resource"),resource:P([lt,Ct]),annotations:Ke.optional(),_meta:T(l(),j()).optional()}),st=dt.extend({type:v("resource_link")}),We=P([qe,je,yt,st,ot]),pt=g({role:s,content:We}),mt=g({title:l().optional(),readOnlyHint:E().optional(),destructiveHint:E().optional(),idempotentHint:E().optional(),openWorldHint:E().optional()}),Nt=S.extend({method:v("notifications/tools/list_changed"),params:f.optional()}),At=g({name:l().optional()}),fr=g({hints:y(At).optional(),costPriority:z().min(0).max(1).optional(),speedPriority:z().min(0).max(1).optional(),intelligencePriority:z().min(0).max(1).optional()}),Mt=g({mode:Y(["auto","required","none"]).optional()}),Fr=g({type:v("boolean"),title:l().optional(),description:l().optional(),default:E().optional()}),O=g({type:v("string"),title:l().optional(),description:l().optional(),minLength:z().optional(),maxLength:z().optional(),format:Y(["email","uri","date","date-time"]).optional(),default:l().optional()}),Lt=g({type:Y(["number","integer"]),title:l().optional(),description:l().optional(),minimum:z().optional(),maximum:z().optional(),default:z().optional()}),H=g({type:v("string"),title:l().optional(),description:l().optional(),enum:y(l()),default:l().optional()}),q=g({type:v("string"),title:l().optional(),description:l().optional(),oneOf:y(g({const:l(),title:l()})),default:l().optional()}),ee=g({type:v("string"),title:l().optional(),description:l().optional(),enum:y(l()),enumNames:y(l()).optional(),default:l().optional()}),N=P([H,q]),C=g({type:v("array"),title:l().optional(),description:l().optional(),minItems:z().optional(),maxItems:z().optional(),items:g({type:v("string"),enum:y(l())}),default:y(l()).optional()}),G=g({type:v("array"),title:l().optional(),description:l().optional(),minItems:z().optional(),maxItems:z().optional(),items:g({anyOf:y(g({const:l(),title:l()}))}),default:y(l()).optional()}),K=P([C,G]),ve=P([ee,N,K]),Hr=P([ve,Fr,O,Lt]),qt=h.extend({mode:v("form").optional(),message:l(),requestedSchema:g({type:v("object"),properties:T(l(),Hr),required:y(l()).optional()}).catchall(j())}),Br=g({type:v("ref/resource"),uri:l()}),Jr=g({type:v("ref/prompt"),name:l()}),ps=g({uri:l().startsWith("file://"),name:l().optional(),_meta:T(l(),j()).optional()}),gr=ie.shape,ms=g({experimental:gr.experimental,sampling:gr.sampling,elicitation:gr.elicitation,roots:gr.roots,extensions:gr.extensions}),ht=Pe.shape,Mn=g({experimental:ht.experimental,logging:ht.logging,completions:ht.completions,prompts:ht.prompts,resources:ht.resources,tools:ht.tools,extensions:ht.extensions}),Ln=V({progressToken:r.optional(),[_n]:l(),[Oo]:R.optional(),[bn]:ms,[Ao]:i.optional()}),Kr=g({...x.shape,...w.shape,description:l().optional(),inputSchema:V({$schema:l().optional(),type:v("object")}),outputSchema:V({$schema:l().optional()}).optional(),annotations:mt.optional(),_meta:T(l(),j()).optional()}),hs=g({type:v("tool_result"),toolUseId:l(),content:y(We),structuredContent:j().optional(),isError:E().optional(),_meta:T(l(),j()).optional()}),qn=P([qe,je,yt,Vr,hs]),Wr=g({role:s,content:P([qn,y(qn)]),_meta:T(l(),j()).optional()}),jn=l(),Dn=V({[Ht]:R.optional().catch(void 0)}),Un=Dn.optional();function Oe(ye){return V({_meta:Un,resultType:jn.default("complete"),...ye})}let fs=Oe({}),Zc=Oe({nextCursor:n.optional()}),Zn=Oe({content:y(We),structuredContent:j().optional(),isError:E().optional()}),gs=Oe({ttlMs:z().int().min(0),cacheScope:Y(["public","private"]),tools:y(Kr),nextCursor:n.optional()}),Ss=Oe({ttlMs:z().int().min(0),cacheScope:Y(["public","private"]),prompts:y(Ot),nextCursor:n.optional()}),_s=Oe({description:l().optional(),messages:y(pt)}),bs=Oe({ttlMs:z().int().min(0),cacheScope:Y(["public","private"]),resources:y(dt),nextCursor:n.optional()}),ys=Oe({ttlMs:z().int().min(0),cacheScope:Y(["public","private"]),resourceTemplates:y(It),nextCursor:n.optional()}),vs=Oe({ttlMs:z().int().min(0),cacheScope:Y(["public","private"]),contents:y(P([lt,Ct]))}),ws=Oe({completion:g({values:y(l()).max(100),total:z().int().optional(),hasMore:E().optional()}).loose()}),Vc=Oe({ttlMs:z().int().min(0),cacheScope:Y(["public","private"])}),zs=Oe({ttlMs:z().int().min(0).catch(0),cacheScope:Y(["public","private"]).catch("private"),supportedVersions:y(l()),capabilities:Mn,instructions:l().optional()}),Sr=g({messages:y(Wr),modelPreferences:fr.optional(),systemPrompt:l().optional(),includeContext:Y(["none","thisServer","allServers"]).optional(),temperature:z().optional(),maxTokens:z().int(),stopSequences:y(l()).optional(),metadata:t.optional(),tools:y(Kr).optional(),toolChoice:Mt.optional()}),Rs=g({method:v("sampling/createMessage"),params:Sr}),$s=g({method:v("roots/list"),params:g({_meta:T(l(),j()).optional()}).optional()}),ks=g({...Wr.shape,model:l(),stopReason:l().optional()}),xs=g({roots:y(ps)}),Ts=g({action:Y(["accept","decline","cancel"]),content:T(l(),P([l(),z(),E(),y(l())])).optional()}),Es=g({mode:v("url"),message:l(),url:l().url()}),Ps=P([qt,Es]),Cs=g({method:v("elicitation/create"),params:Ps}),Is=P([Rs,$s,Cs]),Os=P([ks,xs,Ts]),Ns=T(l(),Is),As=T(l(),Os),Gr=Oe({inputRequests:Ns.optional(),requestState:l().optional()}),Yr={inputResponses:As.optional(),requestState:l().optional()},Fc=g({_meta:Ln,...Yr}),Hc=V({progressToken:r.optional()});function it(ye,Xr){return g({method:v(ye),params:g({_meta:Ln,...Xr})})}function at(ye,Xr){return g({method:v(ye),params:g({_meta:Hc.optional(),...Xr}).optional()})}let Ms={name:l(),arguments:T(l(),j()).optional(),...Yr},vt={cursor:n.optional()},Bc=it("tools/call",Ms),Jc=it("tools/list",vt),Kc=it("prompts/list",vt),Wc=it("prompts/get",{name:l(),arguments:T(l(),l()).optional(),...Yr}),Gc=it("resources/list",vt),Yc=it("resources/templates/list",vt),Qc=it("resources/read",{uri:l(),...Yr}),Ls={ref:P([Jr,Br]),argument:g({name:l(),value:l()}),context:g({arguments:T(l(),l()).optional()}).optional()},Xc=it("completion/complete",Ls),eu=it("server/discover",{}),Vn=g({toolsListChanged:E().optional(),promptsListChanged:E().optional(),resourcesListChanged:E().optional(),resourceSubscriptions:y(l()).optional()}),qs={notifications:Vn},tu=it("subscriptions/listen",qs),ru=Dn.extend({"io.modelcontextprotocol/subscriptionId":o}),js=V({_meta:ru,resultType:jn.default("complete")}),_r={"tools/call":at("tools/call",Ms),"tools/list":at("tools/list",vt),"prompts/get":at("prompts/get",{name:l(),arguments:T(l(),l()).optional()}),"prompts/list":at("prompts/list",vt),"resources/list":at("resources/list",vt),"resources/templates/list":at("resources/templates/list",vt),"resources/read":at("resources/read",{uri:l()}),"completion/complete":at("completion/complete",Ls),"server/discover":at("server/discover",{}),"subscriptions/listen":at("subscriptions/listen",qs)};function Ge(ye){return V({_meta:Un,...ye})}let nu={"tools/call":Ge({content:y(We),structuredContent:j().optional(),isError:E().optional()}),"tools/list":Ge({ttlMs:z().int().min(0),cacheScope:Y(["public","private"]),tools:y(Kr),nextCursor:n.optional()}),"prompts/get":Ge({description:l().optional(),messages:y(pt)}),"prompts/list":Ge({ttlMs:z().int().min(0),cacheScope:Y(["public","private"]),prompts:y(Ot),nextCursor:n.optional()}),"resources/list":Ge({ttlMs:z().int().min(0),cacheScope:Y(["public","private"]),resources:y(dt),nextCursor:n.optional()}),"resources/templates/list":Ge({ttlMs:z().int().min(0),cacheScope:Y(["public","private"]),resourceTemplates:y(It),nextCursor:n.optional()}),"resources/read":Ge({ttlMs:z().int().min(0),cacheScope:Y(["public","private"]),contents:y(P([lt,Ct]))}),"completion/complete":Ge({completion:g({values:y(l()).max(100),total:z().int().optional(),hasMore:E().optional()}).loose()}),"server/discover":Ge({ttlMs:z().int().min(0).catch(0),cacheScope:Y(["public","private"]).catch("private"),supportedVersions:y(l()),capabilities:Mn,instructions:l().optional()}),"subscriptions/listen":Ge({})},Qr=V({"io.modelcontextprotocol/subscriptionId":o.optional()}),Fn=g({method:v("notifications/subscriptions/acknowledged"),params:g({_meta:Qr.optional(),notifications:Vn})}),Hn=g({_meta:Qr.optional(),requestId:o,reason:l().optional()}),Bn=g({method:v("notifications/cancelled"),params:Hn}),ip={"notifications/cancelled":Bn,"notifications/progress":Je,"notifications/message":Et,"notifications/resources/updated":Qt,"notifications/resources/list_changed":nt,"notifications/tools/list_changed":Nt,"notifications/prompts/list_changed":Ie,"notifications/subscriptions/acknowledged":Fn},De=ye=>g({jsonrpc:v("2.0"),id:P([l(),z().int()]),result:ye}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:n,RequestIdSchema:o,RoleSchema:s,LoggingLevelSchema:i,TaskMetadataSchema:c,RelatedTaskMetadataSchema:u,RequestMetaSchema:d,BaseRequestParamsSchema:p,TaskAugmentedRequestParamsSchema:h,NotificationsParamsSchema:f,NotificationSchema:S,IconSchema:_,IconsSchema:w,BaseMetadataSchema:x,ImplementationSchema:R,ClientTasksCapabilitySchema:se,ServerTasksCapabilitySchema:U,ClientCapabilitiesSchema:ie,ServerCapabilitiesSchema:Pe,ProgressSchema:he,ProgressNotificationParamsSchema:Ce,ProgressNotificationSchema:Je,LoggingMessageNotificationParamsSchema:Tt,LoggingMessageNotificationSchema:Et,ResourceContentsSchema:Pt,TextResourceContentsSchema:lt,BlobResourceContentsSchema:Ct,AnnotationsSchema:Ke,ResourceSchema:dt,ResourceTemplateSchema:It,ResourceListChangedNotificationSchema:nt,ResourceUpdatedNotificationParamsSchema:Le,ResourceUpdatedNotificationSchema:Qt,PromptArgumentSchema:Xt,PromptSchema:Ot,PromptListChangedNotificationSchema:Ie,TextContentSchema:qe,ImageContentSchema:je,AudioContentSchema:yt,ToolUseContentSchema:Vr,EmbeddedResourceSchema:ot,ResourceLinkSchema:st,ContentBlockSchema:We,PromptMessageSchema:pt,ToolAnnotationsSchema:mt,ToolListChangedNotificationSchema:Nt,ModelHintSchema:At,ModelPreferencesSchema:fr,ToolChoiceSchema:Mt,BooleanSchemaSchema:Fr,StringSchemaSchema:O,NumberSchemaSchema:Lt,UntitledSingleSelectEnumSchemaSchema:H,TitledSingleSelectEnumSchemaSchema:q,LegacyTitledEnumSchemaSchema:ee,SingleSelectEnumSchemaSchema:N,UntitledMultiSelectEnumSchemaSchema:C,TitledMultiSelectEnumSchemaSchema:G,MultiSelectEnumSchemaSchema:K,EnumSchemaSchema:ve,PrimitiveSchemaDefinitionSchema:Hr,ElicitRequestFormParamsSchema:qt,ResourceTemplateReferenceSchema:Br,PromptReferenceSchema:Jr,RootSchema:ps,ClientCapabilities2026Schema:ms,ServerCapabilities2026Schema:Mn,RequestMetaEnvelopeSchema:Ln,ToolSchema:Kr,ToolResultContentSchema:hs,SamplingMessageContentBlockSchema:qn,SamplingMessageSchema:Wr,ResultTypeSchema:jn,ResultMetaSchema:Dn,ResultSchema:fs,PaginatedResultSchema:Zc,CallToolResultSchema:Zn,ListToolsResultSchema:gs,ListPromptsResultSchema:Ss,GetPromptResultSchema:_s,ListResourcesResultSchema:bs,ListResourceTemplatesResultSchema:ys,ReadResourceResultSchema:vs,CompleteResultSchema:ws,CacheableResultSchema:Vc,DiscoverResultSchema:zs,CreateMessageRequestParamsSchema:Sr,CreateMessageRequestSchema:Rs,ListRootsRequestSchema:$s,CreateMessageResultSchema:ks,ListRootsResultSchema:xs,ElicitResultSchema:Ts,ElicitRequestURLParamsSchema:Es,ElicitRequestParamsSchema:Ps,ElicitRequestSchema:Cs,InputRequestSchema:Is,InputResponseSchema:Os,InputRequestsSchema:Ns,InputResponsesSchema:As,InputRequiredResultSchema:Gr,InputResponseRequestParamsSchema:Fc,CallToolRequestSchema:Bc,ListToolsRequestSchema:Jc,ListPromptsRequestSchema:Kc,GetPromptRequestSchema:Wc,ListResourcesRequestSchema:Gc,ListResourceTemplatesRequestSchema:Yc,ReadResourceRequestSchema:Qc,CompleteRequestSchema:Xc,DiscoverRequestSchema:eu,SubscriptionFilterSchema:Vn,SubscriptionsListenRequestSchema:tu,SubscriptionsListenResultMetaSchema:ru,SubscriptionsListenResultSchema:js,dispatchRequestSchemas:_r,dispatchResultSchemas:nu,NotificationMetaSchema:Qr,SubscriptionsAcknowledgedNotificationSchema:Fn,CancelledNotificationParamsSchema:Hn,CancelledNotificationSchema:Bn,notificationSchemas2026:ip,JSONRPCResultResponseSchema:De(fs),CallToolResultResponseSchema:De(P([Zn,Gr])),ListToolsResultResponseSchema:De(gs),ListPromptsResultResponseSchema:De(Ss),GetPromptResultResponseSchema:De(P([_s,Gr])),ListResourcesResultResponseSchema:De(bs),ListResourceTemplatesResultResponseSchema:De(ys),ReadResourceResultResponseSchema:De(P([vs,Gr])),CompleteResultResponseSchema:De(ws),DiscoverResultResponseSchema:De(zs),SubscriptionsListenResultResponseSchema:De(js)}}var hT;function Dr(){return hT??=mT()}var fT=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function gT(e){return fT.includes(e)}var ZS=Symbol("modelcontextprotocol.resultCacheHintFallback");function ST(e){return e[ZS]}function Vw(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function Fw(e){return e==="public"||e==="private"}var W=(function(e){return e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.ResourceNotFound=-32002]="ResourceNotFound",e[e.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",e[e.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired",e})({}),ae=class Hw extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return rt(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rt(this,t)}constructor(t,r,n){super(r),this.code=t,this.data=n,this.name="ProtocolError",Ur(this,new.target)}static fromError(t,r,n){if(t===W.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Jw(o.elicitations,r)}if(t===W.UnsupportedProtocolVersion&&n){let o=n;if(Array.isArray(o.supported)&&typeof o.requested=="string")return new Cc({supported:o.supported,requested:o.requested},r)}if(t===W.InvalidParams||t===W.ResourceNotFound){let o=n;if(typeof o?.uri=="string"&&(t===W.ResourceNotFound||Object.keys(o).length===1))return new Bw(o.uri,r)}if(t===W.MissingRequiredClientCapability&&n){let o=n;if(o.requiredCapabilities!==null&&typeof o.requiredCapabilities=="object"&&!Array.isArray(o.requiredCapabilities))return new Kw({requiredCapabilities:o.requiredCapabilities},r)}return new Hw(t,r,n)}},Bw=class extends ae{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(W.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Jw=class extends ae{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(W.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Cc=class extends ae{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(W.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Kw=class extends ae{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(W.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},_T=0,bT="private",yT=["tools/call","prompts/get","resources/read"];function vT(e,t){let r=t.resultType;if(r===void 0)return{...t,resultType:"complete"};if(r==="complete"||yT.includes(e))return t;throw new ae(W.InternalError,`Handler for ${e} returned resultType '${String(r)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function wT(e,t){let r=ST(t);if(t.resultType!=="complete"||!gT(e))return r===void 0?t:xT(t);let n=t,o=Vw(n.ttlMs)?n.ttlMs:$T(r),s=Fw(n.cacheScope)?n.cacheScope:kT(r),i={...n,ttlMs:o,cacheScope:s};return delete i[ZS],i}function zT(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function RT(e,t){if(t===void 0)return e;let r=e._meta;return r===void 0?{...e,_meta:{[Ht]:t}}:!zT(r)||r[Ht]!==void 0?e:{...e,_meta:{...r,[Ht]:t}}}function $T(e){return e!==void 0&&Vw(e.ttlMs)?e.ttlMs:_T}function kT(e){return e!==void 0&&Fw(e.cacheScope)?e.cacheScope:bT}function xT(e){let t={...e};return delete t[ZS],t}var TT=["elicitation/create","sampling/createMessage","roots/list"],qd;function Ww(){if(qd)return qd;let e=Dr();return qd={request:{"elicitation/create":g({method:v("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":g({method:v("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":g({method:v("roots/list"),params:V({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},qd}function Gw(e){return TT.includes(e)}function ES(e){return Gw(e)?Ww().request[e]:void 0}function ET(e){return Gw(e)?Ww().response[e]:void 0}var VS={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},Yw={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function Qw(e){return Object.prototype.hasOwnProperty.call(VS,e)}function Xw(e){return Object.prototype.hasOwnProperty.call(Yw,e)}function PT(e){return Object.prototype.hasOwnProperty.call(VS,e)}function CT(e){return Qw(e)?Dr().dispatchRequestSchemas[e]:void 0}function IT(e){return PT(e)?Dr().dispatchResultSchemas[e]:void 0}function OT(e){return Xw(e)?Dr().notificationSchemas2026[e]:void 0}var kN=Object.keys(VS),xN=Object.keys(Yw);function kc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Rc(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}var NT={ok:!1,reason:"not-in-era"},AT=[_n,bn];function MT(e,t){let r=t,n=!1,o=()=>(n||(r={...r},n=!0),r),s=t.tools;e==="tools/list"&&Array.isArray(s)&&s.some(a=>kc(a)&&"execution"in a)&&(o().tools=s.map(a=>{if(!kc(a)||!("execution"in a))return a;let c={...a};return delete c.execution,c}));let i=t.capabilities;if(kc(i)&&"tasks"in i){let a={...i};delete a.tasks,o().capabilities=a}return r}var FS={era:"2026-07-28",hasRequestMethod:Qw,hasNotificationMethod:Xw,hasInputRequestMethod:e=>ES(e)!==void 0,validateRequest:(e,t)=>Rc(CT(e),t),validateResult:(e,t)=>Rc(IT(e),t),validateNotification:(e,t)=>Rc(OT(e),t),validateInputRequest:(e,t)=>Rc(ES(e),t),validateInputResponse:(e,t)=>Rc(ET(e),t),samplingResultVariant:()=>NT,outboundEnvelope(e){return{[_n]:e.protocolVersion,[Oo]:e.clientInfo,[bn]:e.clientCapabilities,...e.logLevel!==void 0&&{[Ao]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of AT)n in e||t.push({key:n,problem:"missing"});let r=Dr().RequestMetaEnvelopeSchema.safeParse(e);if(!r.success)for(let n of r.error.issues){let o=n.path.map(String),s=o.length>0?o.join("."):"_meta";o.length===1&&t.some(i=>i.key===s&&i.problem==="missing")||t.push({key:s,problem:n.message})}return t},projectCallToolResult:e=>Aw(e),inputRequestSchema:ES,decodeResult(e,t){if(!kc(t))return{kind:"invalid",error:new L(D.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let r=t.resultType;if(r===void 0)return{kind:"invalid",error:new L(D.InvalidResult,`Invalid result for ${e}: missing required resultType \u2014 servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if(typeof r!="string")return{kind:"invalid",error:new L(D.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:r})};if(r==="input_required"){let i=t.inputRequests,a=kc(i)?i:{},c=t.requestState,u=t._meta===void 0?void 0:Dr().ResultMetaSchema.safeParse(t._meta),d=u?.success?u.data:void 0;return Object.keys(a).length===0&&typeof c!="string"?{kind:"invalid",error:new L(D.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:a,...typeof c=="string"&&{requestState:c},...d!==void 0&&{_meta:d}}}if(r!=="complete")return{kind:"invalid",error:new L(D.UnsupportedResultType,`Unsupported result type '${r}' for ${e}`,{resultType:r,method:e})};let n=LT(),o=Object.hasOwn(n,e)?n[e]:void 0;if(o!==void 0){let i=o.safeParse(t);if(!i.success)return{kind:"invalid",error:new L(D.InvalidResult,`Invalid result for ${e}: ${i.error}`,{method:e})}}let s={...t};return delete s.resultType,{kind:"complete",result:s}},encodeResult(e,t,r){return RT(wT(e,vT(e,MT(e,t))),r)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=Dr().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(r=>r.message).join("; ")}`}},jd;function LT(){if(jd)return jd;let e=Dr();return jd={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},jd}var Zd="2026-07-28";function mr(e){return e!==void 0&&hr(e)?FS:US}function Rw(e){return e.revision!==void 0?mr(e.revision).era:e.era==="modern"?FS.era:US.era}function PS(e){return ez.some(t=>t.hasRequestMethod(e))}function CS(e){return ez.some(t=>t.hasNotificationMethod(e))}function $w(e){return e==="tasks/get"||e==="tasks/cancel"}var ez=[US,FS],qT=__({AnnotationsSchema:()=>Jt,AudioContentSchema:()=>xn,BaseMetadataSchema:()=>Ft,BaseRequestParamsSchema:()=>$e,BlobResourceContentsSchema:()=>Ko,BooleanSchemaSchema:()=>Qo,CallToolRequestParamsSchema:()=>Oa,CallToolRequestSchema:()=>Na,CallToolResultSchema:()=>jr,CancelTaskRequestSchema:()=>kd,CancelTaskResultSchema:()=>xd,CancelledNotificationParamsSchema:()=>Ui,CancelledNotificationSchema:()=>Zo,ClientCapabilitiesSchema:()=>Vi,ClientNotificationSchema:()=>Ed,ClientRequestSchema:()=>Td,ClientResultSchema:()=>Pd,ClientTasksCapabilitySchema:()=>hd,CompatibilityCallToolResultSchema:()=>gd,CompleteRequestParamsSchema:()=>cc,CompleteRequestSchema:()=>uc,CompleteResultSchema:()=>lc,ContentBlockSchema:()=>Kt,CreateMessageRequestParamsSchema:()=>Ja,CreateMessageRequestSchema:()=>Ka,CreateMessageResultSchema:()=>Wa,CreateMessageResultWithToolsSchema:()=>Ga,CreateTaskResultSchema:()=>_d,CursorSchema:()=>Lo,DiscoverRequestSchema:()=>Ki,DiscoverResultSchema:()=>Lr,ElicitRequestFormParamsSchema:()=>In,ElicitRequestParamsSchema:()=>tc,ElicitRequestSchema:()=>rc,ElicitRequestURLParamsSchema:()=>ec,ElicitResultSchema:()=>sc,ElicitationCompleteNotificationParamsSchema:()=>nc,ElicitationCompleteNotificationSchema:()=>oc,EmbeddedResourceSchema:()=>Tn,EmptyResultSchema:()=>Mr,EnumSchemaSchema:()=>Xa,GetPromptRequestParamsSchema:()=>za,GetPromptRequestSchema:()=>Ra,GetPromptResultSchema:()=>xa,GetTaskPayloadRequestSchema:()=>wd,GetTaskPayloadResultSchema:()=>zd,GetTaskRequestSchema:()=>yd,GetTaskResultSchema:()=>vd,IconSchema:()=>Zi,IconsSchema:()=>cr,ImageContentSchema:()=>kn,ImplementationSchema:()=>Bt,InitializeRequestParamsSchema:()=>Fi,InitializeRequestSchema:()=>Hi,InitializeResultSchema:()=>Bi,InitializedNotificationSchema:()=>Ji,JSONArraySchema:()=>pd,JSONObjectSchema:()=>fe,JSONRPCErrorResponseSchema:()=>wn,JSONRPCMessageSchema:()=>zn,JSONRPCNotificationSchema:()=>Uo,JSONRPCRequestSchema:()=>Do,JSONRPCResponseSchema:()=>md,JSONRPCResultResponseSchema:()=>vn,JSONValueSchema:()=>ar,LegacyTitledEnumSchemaSchema:()=>ts,ListChangedOptionsBaseSchema:()=>Ma,ListPromptsRequestSchema:()=>va,ListPromptsResultSchema:()=>wa,ListResourceTemplatesRequestSchema:()=>ta,ListResourceTemplatesResultSchema:()=>ra,ListResourcesRequestSchema:()=>Xi,ListResourcesResultSchema:()=>ea,ListRootsRequestSchema:()=>pc,ListRootsResultSchema:()=>mc,ListTasksRequestSchema:()=>Rd,ListTasksResultSchema:()=>$d,ListToolsRequestSchema:()=>Ca,ListToolsResultSchema:()=>Ia,LoggingLevelSchema:()=>Yo,LoggingMessageNotificationParamsSchema:()=>ja,LoggingMessageNotificationSchema:()=>Da,ModelHintSchema:()=>Ua,ModelPreferencesSchema:()=>Za,MultiSelectEnumSchemaSchema:()=>Qa,NotificationSchema:()=>Ee,NotificationsParamsSchema:()=>Me,NumberSchemaSchema:()=>Cn,PaginatedRequestParamsSchema:()=>Yi,PaginatedRequestSchema:()=>ur,PaginatedResultSchema:()=>lr,PingRequestSchema:()=>Fo,PrimitiveSchemaDefinitionSchema:()=>os,ProgressNotificationParamsSchema:()=>Gi,ProgressNotificationSchema:()=>Ho,ProgressSchema:()=>Wi,ProgressTokenSchema:()=>Mo,PromptArgumentSchema:()=>ba,PromptListChangedNotificationSchema:()=>Ta,PromptMessageSchema:()=>ka,PromptReferenceSchema:()=>ac,PromptSchema:()=>ya,ReadResourceRequestParamsSchema:()=>na,ReadResourceRequestSchema:()=>oa,ReadResourceResultSchema:()=>sa,RelatedTaskMetadataSchema:()=>Di,RequestIdSchema:()=>kt,RequestMetaSchema:()=>qo,RequestSchema:()=>ge,ResourceContentsSchema:()=>Bo,ResourceLinkSchema:()=>En,ResourceListChangedNotificationSchema:()=>ia,ResourceRequestParamsSchema:()=>Rn,ResourceSchema:()=>Wo,ResourceTemplateReferenceSchema:()=>ic,ResourceTemplateSchema:()=>Qi,ResourceUpdatedNotificationParamsSchema:()=>Sa,ResourceUpdatedNotificationSchema:()=>_a,ResultMetaObjectSchema:()=>jo,ResultSchema:()=>Se,RoleSchema:()=>dr,RootSchema:()=>dc,RootsListChangedNotificationSchema:()=>hc,SamplingContentSchema:()=>Ha,SamplingMessageContentBlockSchema:()=>Nr,SamplingMessageSchema:()=>Ba,ServerCapabilitiesSchema:()=>Vo,ServerNotificationSchema:()=>Id,ServerRequestSchema:()=>Cd,ServerResultSchema:()=>Od,ServerTasksCapabilitySchema:()=>fd,SetLevelRequestParamsSchema:()=>La,SetLevelRequestSchema:()=>qa,SingleSelectEnumSchemaSchema:()=>Ya,StringSchemaSchema:()=>Pn,SubscribeRequestParamsSchema:()=>aa,SubscribeRequestSchema:()=>ca,SubscriptionFilterSchema:()=>Go,SubscriptionsAcknowledgedNotificationParamsSchema:()=>ma,SubscriptionsAcknowledgedNotificationSchema:()=>ha,SubscriptionsListenRequestParamsSchema:()=>da,SubscriptionsListenRequestSchema:()=>pa,SubscriptionsListenResultMetaSchema:()=>fa,SubscriptionsListenResultSchema:()=>ga,TaskAugmentedRequestParamsSchema:()=>Ar,TaskCreationParamsSchema:()=>Sd,TaskMetadataSchema:()=>ji,TaskSchema:()=>pr,TaskStatusNotificationParamsSchema:()=>gc,TaskStatusNotificationSchema:()=>bd,TaskStatusSchema:()=>fc,TextContentSchema:()=>$n,TextResourceContentsSchema:()=>Jo,TitledMultiSelectEnumSchemaSchema:()=>ns,TitledSingleSelectEnumSchemaSchema:()=>es,ToolAnnotationsSchema:()=>Ea,ToolChoiceSchema:()=>Va,ToolExecutionSchema:()=>Pa,ToolListChangedNotificationSchema:()=>Aa,ToolResultContentSchema:()=>Fa,ToolSchema:()=>qr,ToolUseContentSchema:()=>$a,UnsubscribeRequestParamsSchema:()=>ua,UnsubscribeRequestSchema:()=>la,UntitledMultiSelectEnumSchemaSchema:()=>rs,UntitledSingleSelectEnumSchemaSchema:()=>Xo});var Vd=e=>Do.safeParse(e).success,tz=e=>Uo.safeParse(e).success,us=e=>vn.safeParse(e).success,Ic=e=>wn.safeParse(e).success;var rz=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var jT="Mcp-Param-",kw="x-mcp-header",DT=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,UT=new Set(["string","integer","boolean"]);function HS(e){let t=[],r=new Map,n,o=(i,a,c)=>{if(i===null||typeof i!="object")return;let u=i;if(kw in u){if(!c||a.length===0)return`${Dd(a)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let p=u[kw];if(typeof p!="string"||p.length===0)return`${Dd(a)}: x-mcp-header MUST be a non-empty string`;if(!DT.test(p))return`${Dd(a)}: x-mcp-header '${p}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let h=typeof u.type=="string"?u.type:void 0;if(h===void 0||!UT.has(h)){let _=`${Dd(a)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${h??"<none>"}`;if(h!=="number")return _;n??=_}let f=p.toLowerCase(),S=r.get(f);if(S!==void 0)return`x-mcp-header '${p}' is not case-insensitively unique (also declared as '${S}')`;r.set(f,p),t.push({path:a,headerName:p,type:h})}let d=u.properties;if(d!==null&&typeof d=="object")for(let[p,h]of Object.entries(d)){let f=o(h,[...a,p],c);if(f!==void 0)return f}for(let p of ZT){let h=u[p];if(h===void 0)continue;let f=Array.isArray(h)?h:h!==null&&typeof h=="object"&&VT.has(p)?Object.values(h):[h];for(let S of f){let _=o(S,[...a,`<${p}>`],!1);if(_!==void 0)return _}}},s=o(e,[],!0);return s!==void 0?{valid:!1,reason:n??s}:n===void 0?{valid:!0,declarations:t}:{valid:!1,reason:n,declarations:t}}var ZT=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],VT=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function Dd(e){return e.length===0?"<root>":e.join(".")}var nz="=?base64?",oz="?=";function FT(e){if(typeof e=="string")return e;if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number")return!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)?void 0:String(e)}function HT(e){if(e.length===0||e.startsWith(nz)&&e.endsWith(oz)||e!==e.trim())return!0;for(let t=0;t<e.length;t++){let r=e.codePointAt(t);if(!(r===9||r>=32&&r<=126))return!0}return!1}function BT(e){let t=new TextEncoder().encode(e),r="";for(let n of t)r+=String.fromCodePoint(n);return btoa(r)}function sz(e){return HT(e)?`${nz}${BT(e)}${oz}`:e}function JT(e,t){let r=e;for(let n of t){if(r===null||typeof r!="object")return;r=r[n]}return r}function iz(e,t){let r={};for(let n of e){let o=JT(t,n.path);if(o==null)continue;let s=FT(o);s!==void 0&&(r[`${jT}${n.headerName}`]=sz(s))}return r}var cs=-32020,TN=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32e3],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[W.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[cs,W.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[W.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope \u2014 and a missing envelope on a request whose protocol-version header names a modern revision \u2014 is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[W.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision\u2019s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[W.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[cs],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half \u2014 including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[W.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced \u2014 pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[cs],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool\u2019s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],EN={[W.ParseError]:400,[W.InvalidRequest]:400,[W.MethodNotFound]:404,[W.UnsupportedProtocolVersion]:400,[W.MissingRequiredClientCapability]:400,[cs]:400};function Fd(e,t){return $i(e,t)}function $c(e){return new Set(e.flatMap(t=>Object.keys(t.shape)))}function AS(e){if(e==null)return!1;let t=typeof e;return t!=="object"&&t!=="function"||!("~standard"in e)?!1:typeof e["~standard"]?.validate=="function"}var xw=!1,MS="draft-2020-12";function KT(e,t="input"){let r=e["~standard"],n;if(r.jsonSchema)n=r.jsonSchema[t]({target:MS});else if(r.vendor==="zod"){if(!("_zod"in e))throw new Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");xw||(xw=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),n=hn(e,{target:MS,io:t})}else throw new Error(`Schema library "${r.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output")return n.type!==void 0?n:az(n)?{type:"object",...n}:n;if(n.type!==void 0&&n.type!=="object")throw new Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(n.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...n}}var WT=/^#\/(\$defs|definitions)\/([^/~%]+)$/;function az(e,t=e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;let r=typeof e.$ref=="string"&&WT.exec(e.$ref);if(r&&t[r[1]]?.[r[2]]?.type==="object")return!0;for(let n of["oneOf","anyOf","allOf"]){let o=e[n];if(Array.isArray(o)&&o.length>0)return o.every(s=>s!==null&&typeof s=="object"&&(s.type==="object"||az(s,"$id"in s?{}:t)))}return!1}function GT(e){return e.path?.length?`${e.path.map(t=>String(typeof t=="object"?t.key:t)).join(".")}: ${e.message}`:e.message}async function IS(e,t){let r=await e["~standard"].validate(t);return r.issues&&r.issues.length>0?{success:!1,error:r.issues.map(n=>GT(n)).join(", ")}:{success:!0,data:r.value}}function YT(e){let t=hn(e,{target:MS,io:"input"});return typeof t.pattern=="string"?t.pattern:void 0}var QT=/\\\.\\d\{(\d+)\}/;function XT(e){let t=QT.exec(e),r=[void 0,-1,0];return t&&r.push(Number(t[1])),[!1,!0].flatMap(n=>[!1,!0].flatMap(o=>r.map(s=>_t.datetime({local:n,offset:o,precision:s}))))}function eE(e,t){let r;switch(e){case"email":r=[Ul()];break;case"uri":r=[To()];break;case"date":r=[_t.date()];break;case"date-time":r=XT(t);break}return new Set(r.map(n=>YT(n)).filter(n=>n!==void 0))}function tE(e,t,r){return r!=="zod"?!0:eE(e,t).has(t)}function Tc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function rE(e){try{return KT(e,"input")}catch(t){let r=t instanceof Error?t.message:String(t);throw new ae(W.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${r}`)}}var nE=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function BS(e){return nE.has(e)||e.startsWith("x-")}var oE=new Set(["$schema",...Object.keys(In.shape.requestedSchema.shape)]),Tw={string:$c([Pn,Xo,es,ts]),number:$c([Cn]),integer:$c([Cn]),boolean:$c([Qo]),array:$c([rs,ns])},sE=new Set(Pn.shape.format.unwrap().options);function iE(e,t,r,n){if(!Tc(e))return e;let o=typeof e.type=="string"&&Object.hasOwn(Tw,e.type)?Tw[e.type]:void 0;if(o===void 0)return e;let s={};for(let[i,a]of Object.entries(e))o.has(i)||BS(i)?s[i]=a:i==="pattern"&&e.type==="string"&&typeof e.format=="string"?sE.has(e.format)?(typeof a!="string"||!tE(e.format,a,r))&&n.push(`${t}.${i}`):s[i]=a:n.push(`${t}.${i}`);return s}function aE(e,t){let r={},n=[];for(let[o,s]of Object.entries(e))o==="properties"&&Tc(s)?r[o]=Object.fromEntries(Object.entries(s).map(([i,a])=>[i,iE(a,`properties.${i}`,t,n)])):oE.has(o)?r[o]=s:BS(o)||n.push(o);if(n.length>0)throw new ae(W.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${n.join(", ")}`);return r}function cE(e,t){if(!Tc(e.properties))return t;let r=Object.entries(e.properties).filter(([,n])=>!Fd(os,n).success).map(([n])=>`properties.${n}`);return r.length>0?r.join(", "):t}function LS(e,t,r=""){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((n,o)=>LS(n,t[o],`${r}[${o}]`)):!Tc(e)||!Tc(t)?[]:Object.entries(e).flatMap(([n,o])=>{let s=r?`${r}.${n}`:n;return Object.prototype.hasOwnProperty.call(t,n)?LS(o,t[n],s):BS(n)?[]:[s]})}function uE(e){if(!AS(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,r=aE(rE(e.requestedSchema),t),n=Fd(In.shape.requestedSchema,r);if(!n.success)throw new ae(W.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${cE(r,n.error.message)}`);let o=LS(r,n.data);if(o.length>0)throw new ae(W.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${o.join(", ")}`);let s=(n.data.required??[]).filter(i=>!Object.prototype.hasOwnProperty.call(n.data.properties,i));if(s.length>0)throw new ae(W.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${s.join(", ")}`);return{...e,mode:"form",requestedSchema:n.data}}function lE(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,r=typeof e.requestState=="string";if(!t&&!r)throw new TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}var PN=Object.assign(lE,{elicit(e){try{return{method:"elicitation/create",params:uE(e)}}catch(t){throw t instanceof ae?new TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var dE=!0,pE=10,mE=250;function cz(e){return{autoFulfill:e?.autoFulfill??dE,maxRounds:e?.maxRounds??pE}}function hE(e,t,r){let n=t!==void 0&&Object.keys(t).length>0;return!n&&r===void 0?e:{...e,...n&&{inputResponses:t},...r!==void 0&&{requestState:r}}}function fE(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function gE(e,t){return new Promise((r,n)=>{if(t?.aborted){n(t.reason instanceof L?t.reason:new L(D.RequestTimeout,String(t.reason)));return}let o=setTimeout(()=>{t?.removeEventListener("abort",s),r()},e),s=()=>{clearTimeout(o),n(t?.reason instanceof L?t.reason:new L(D.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",s,{once:!0})})}function SE(e){let t=new AbortController,r=()=>t.abort(e?.reason);return e?.addEventListener("abort",r,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:n=>t.abort(n),dispose:()=>e?.removeEventListener("abort",r)}}async function _E(e){let{config:t,method:r,originalParams:n,requestOptions:o,hooks:s,signal:i}=e,a=e.flowStartedAt??Date.now(),c=e.firstPayload,u=0;for(;;){if(u+=1,u>t.maxRounds)throw new L(D.InputRequiredRoundsExceeded,fE(r,t.maxRounds),{rounds:t.maxRounds,lastResult:{inputRequests:c.inputRequests,...c.requestState!==void 0&&{requestState:c.requestState}}});o.onprogress?.({progress:u,message:`Fulfilling input required by '${r}' (round ${u})`});let d=Object.entries(c.inputRequests??{}),p;if(d.length>0){let S=SE(i);try{let _=await Promise.all(d.map(async([w,x])=>{try{return[w,await s.dispatchInputRequest(w,x,S.signal)]}catch(R){throw S.abort(R),R}}));p=Object.fromEntries(_)}finally{S.dispose()}}else await gE(mE,i);let h={...o.timeout!==void 0&&{timeout:o.timeout}};if(o.maxTotalTimeout!==void 0){let S=Date.now()-a,_=o.maxTotalTimeout-S;if(_<=0)throw new L(D.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:o.maxTotalTimeout,totalElapsed:S});h.maxTotalTimeout=_}let f=await s.retry(hE(n,p,c.requestState),h);if(rz(f)){c={inputRequests:f.inputRequests??{},...f.requestState!==void 0&&{requestState:f.requestState}};continue}return f}}var bE=["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"],yE={IdJagTokenExchangeResponseSchema:yc,OAuthClientInformationFullSchema:zc,OAuthClientInformationSchema:wc,OAuthClientMetadataSchema:vc,OAuthClientRegistrationErrorSchema:Nd,OAuthErrorResponseSchema:as,OAuthMetadataSchema:ss,OAuthProtectedResourceMetadataSchema:Sc,OAuthTokenRevocationRequestSchema:Ad,OAuthTokensSchema:is,OpenIdProviderDiscoveryMetadataSchema:bc,OpenIdProviderMetadataSchema:_c},uz={},lz={};function dz(e,t){let r=e.slice(0,-6);uz[r]=t,lz[r]=n=>t.safeParse(n).success}for(let e of bE)dz(e,qT[e]);for(let[e,t]of Object.entries(yE))dz(e,t);var vE=Object.freeze(uz),JS=Object.freeze(lz);function wE(e){switch(e){case"initialize":case"notifications/initialized":return mr(void 0);case"server/discover":return mr(Zd);default:return}}var Oc=6e4,zE=[_n,Oo,bn,Ao],RE=["inputResponses","requestState"];function Ew(e,t){let r=e.params;if(!xc(r))return{message:e,lifted:{}};let n=r._meta,o=xc(n)?zE.filter(c=>c in n):[],s=t==="request"?RE.filter(c=>c in r):[];if(o.length===0&&s.length===0)return{message:e,lifted:{}};let i={},a={...r};if(o.length>0&&xc(n)){let c={},u={...n};for(let d of o)c[d]=n[d],delete u[d];i.envelope=c,Object.keys(u).length>0?a._meta=u:delete a._meta}for(let c of s)c==="inputResponses"&&(i.inputResponses=a[c]),c==="requestState"&&(i.requestState=a[c]),delete a[c];return{message:{...e,params:a},lifted:i}}function Pw(e,t){let r=e.validateResult(t,void 0);if(!(!r.ok&&r.reason==="not-in-era"))return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(n){let o=e.validateResult(t,n);return o.ok?{value:o.value}:{issues:[{message:o.reason==="invalid"?o.message:`not-in-era: ${t}`}]}}}}}function KS(e){return()=>e}var $E=KS(void 0),kE,Nc=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{kE=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??ld,this.setNotificationHandler("notifications/cancelled",t=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",t=>{this._onprogress(t)}),this.setRequestHandler("ping",t=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let r=e.params??{};return{...e,params:{...r,_meta:{...t,...r._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new L(D.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,r,n,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:o,onTimeout:n})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new L(D.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let r=this.transport?.onerror;this._transport.onerror=o=>{r?.(o),this._onerror(o)};let n=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{n?.(o,s),us(o)||Ic(o)?this._onresponse(o):Vd(o)?this._onrequest(o,s):tz(o)?this._onnotification(o,s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let r=new L(D.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let n of e.values())n(r);for(let n of t.values())n.abort(r)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:r}=Ew(e,"notification"),n=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let i=Rw(t.classification);if(i!==n.era){this._onerror(new Error(`Era mismatch on inbound notification '${r.method}': classified as ${i} but this instance serves ${n.era}`));return}}if(CS(r.method)&&!n.hasNotificationMethod(r.method))return;let o=this._notificationHandlers.get(r.method),s=this.fallbackNotificationHandler;o===void 0&&s===void 0||Promise.resolve().then(()=>o===void 0?s(r):o(r,n)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e,t){let{message:r,lifted:n}=Ew(e,"request"),o=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(new Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let s=this._transport,i=(_,w,x)=>{let R={jsonrpc:"2.0",id:r.id,error:{code:_,message:w,...x!==void 0&&{data:x}}};s?.send(R).catch(k=>this._onerror(new Error(`Failed to send an error response: ${k}`)))};if(t?.classification!==void 0){let _=Rw(t.classification);if(_!==o.era){this._onerror(new Error(`Era mismatch on inbound request '${r.method}': classified as ${_} but this instance serves ${o.era}`));let w=t.classification.revision??_;i(W.UnsupportedProtocolVersion,`Unsupported protocol version: ${w}`,{supported:this._supportedProtocolVersions,requested:w});return}}if(PS(r.method)&&!o.hasRequestMethod(r.method)&&!($w(r.method)&&this._customSchemaRequestMethods.has(r.method))){i(W.MethodNotFound,"Method not found");return}let a=this._requestHandlers.get(r.method)??this.fallbackRequestHandler;if(a===void 0){i(W.MethodNotFound,"Method not found");return}let c=o.checkInboundEnvelope(n);if(c!==void 0){i(W.InvalidParams,c);return}let u=(_,w)=>this._notificationViaCodec(this._resolveOutboundCodec(_.method),_,{...w,relatedRequestId:r.id}),d=(_,w,x)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(_.method),_,w,{...x,relatedRequestId:r.id}),p=new AbortController;this._requestHandlerAbortControllers.set(r.id,p);let h=n.inputResponses===void 0?void 0:xE(n.inputResponses),f={sessionId:s?.sessionId,mcpReq:{id:r.id,method:r.method,_meta:r.params?._meta,...n.envelope!==void 0&&{envelope:n.envelope},...h!==void 0&&{inputResponses:h.accepted},...h!==void 0&&h.droppedKeys.length>0&&{droppedInputResponseKeys:h.droppedKeys},requestState:n.requestState===void 0?$E:KS(n.requestState),signal:p.signal,send:((_,w,x)=>{let R=this._resolveOutboundCodec(_.method);if(this._assertOutboundRequestInEra(R,_.method),AS(w))return d(_,w,x);let k=Pw(R,_.method);if(k===void 0)throw new TypeError(`'${_.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return d(_,k,w)}),notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},S=this.buildContext(f,t);Promise.resolve().then(()=>a(r,S)).then(async _=>{if(p.signal.aborted)return;let w;try{w=o.encodeResult(r.method,_,this._outboundServerInfo())}catch(R){this._onerror(new Error(`Failed to encode result for ${r.method}: ${R}`)),i(W.InternalError,"Internal error");return}let x={result:w,jsonrpc:"2.0",id:r.id};await s?.send(x)},async _=>{if(p.signal.aborted)return;let w=Number.isSafeInteger(_.code)?_.code:W.InternalError,x={jsonrpc:"2.0",id:r.id,error:{code:o.encodeErrorCode(w),message:_.message??"Internal error",..._.data!==void 0&&{data:_.data}}};await s?.send(x)}).catch(_=>this._onerror(new Error(`Failed to send response: ${_}`))).finally(()=>{this._requestHandlerAbortControllers.get(r.id)===p&&this._requestHandlerAbortControllers.delete(r.id)})}_onprogress(e){let{progressToken:t,...r}=e.params,n=Number(t),o=this._progressHandlers.get(n);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let s=this._responseHandlers.get(n),i=this._timeoutInfo.get(n);if(i&&s&&i.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(a){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),s(a);return}o(r)}_onresponse(e){let t=Number(e.id),r=this._responseHandlers.get(t);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),us(e)?r(e):r(ae.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,r){let n=this._resolveOutboundCodec(e.method);if(AS(t))return $w(e.method)||this._assertOutboundRequestInEra(n,e.method),this._requestWithSchemaViaCodec(n,e,t,r);this._assertOutboundRequestInEra(n,e.method);let o=Pw(n,e.method);if(o===void 0)throw new TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(n,e,o,t)}_negotiatedWireCodec(){return mr(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=wE(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(PS(t)&&!e.hasRequestMethod(t))throw new L(D.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,r){let n=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(n,e.method),this._requestWithSchemaViaCodec(n,e,t,r)}_requestWithSchemaViaCodec(e,t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,headers:a}=n??{},c=Date.now(),u,d;return new Promise((p,h)=>{let f=U=>{h(U)};if(!this._transport){f(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(U){f(U);return}if(n?.signal?.aborted){let U=n.signal.reason;throw U instanceof L?U:new L(D.RequestTimeout,String(U))}let S=e.era===Zd&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,_=this._requestMessageId++;d=_;let w={...t,jsonrpc:"2.0",id:_};n?.onprogress&&(this._progressHandlers.set(_,n.onprogress),w.params={...t.params,_meta:{...t.params?._meta,progressToken:_}});let x=this._envelopeOutbound(w),R=!1,k=U=>{R||(this._progressHandlers.delete(_),S===void 0?t.method!=="initialize"&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:_,reason:String(U)}}),{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(ie=>this._onerror(new Error(`Failed to send cancellation: ${ie}`))):S.abort(),h(U instanceof L?U:new L(D.RequestTimeout,String(U))))};this._responseHandlers.set(_,U=>{if(n?.signal?.aborted)return;if(R=!0,U instanceof Error)return h(U);let ie;try{ie=e.decodeResult(t.method,U.result)}catch(he){return h(he instanceof Error?he:new Error(String(he)))}if(ie.kind==="invalid")return h(ie.error);if(ie.kind==="input_required"){if(n?.allowInputRequired===!0)return p(CE(ie));let he={codec:e,request:t,resultSchema:r,options:n,flowStartedAt:c,retry:(Ce,Je)=>this._requestWithSchemaViaCodec(e,Ce===void 0?{method:t.method}:{method:t.method,params:Ce},r,Je)};return p(this._resolveNonCompleteResult(ie,he))}let Pe=ie.result;IS(r,Pe).then(he=>{he.success?p(he.data):h(new L(D.InvalidResult,`Invalid result for ${t.method}: ${he.error}`))},h)}),u=()=>k(n?.signal?.reason),n?.signal?.addEventListener("abort",u,{once:!0});let J=n?.timeout??Oc,se=()=>k(new L(D.RequestTimeout,"Request timed out",{timeout:J}));this._setupTimeout(_,J,n?.maxTotalTimeout,se,n?.resetTimeoutOnProgress??!1),this._transport.send(x,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,headers:a,requestSignal:S?.signal}).catch(U=>{this._progressHandlers.delete(_),h(U)})}).finally(()=>{u&&n?.signal?.removeEventListener("abort",u),d!==void 0&&(this._responseHandlers.delete(d),this._cleanupTimeout(d))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,r){if(!this._transport)throw new L(D.NotConnected,"Not connected");if(CS(t.method)&&!e.hasNotificationMethod(t.method))throw new L(D.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let n=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&r?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(n,r).catch(o=>this._onerror(o))});return}await this._transport.send(n,r)}setRequestHandler(e,t,r){this.assertRequestHandlerCapability(e);let n;if(typeof t=="function"){if(!PS(e))throw new TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);n=(o,s)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,o);if(!a.ok&&a.reason==="not-in-era"&&(a=i.validateInputRequest(e,o)),!a.ok)throw a.reason==="not-in-era"?new ae(W.InternalError,`No wire schema for ${e} in the resolved era`):new Error(a.message);return Promise.resolve(t(a.value,s))}}else if(r)n=async(o,s)=>{let i=await IS(t.params,{...o.params});if(!i.success)throw new ae(W.InvalidParams,`Invalid params for ${e}: ${i.error}`);return r(i.data,s)};else throw new TypeError("setRequestHandler: handler is required");typeof t=="function"?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,n))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,r){if(typeof t=="function"){if(!CS(e))throw new TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,o)=>{let s=o.validateNotification(e,n);if(!s.ok)throw s.reason==="not-in-era"?new ae(W.InternalError,`No wire schema for ${e} in the resolved era`):new Error(s.message);return Promise.resolve(t(s.value))});return}if(!r)throw new TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async n=>{let o=await IS(t.params,{...n.params});if(!o.success)throw new ae(W.InvalidParams,`Invalid params for notification ${e}: ${o.error}`);await r(o.data,n)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function xc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function WS(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];r[o]=xc(i)&&xc(s)?{...i,...s}:s}return r}function Ud(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xE(e){let t={},r=[];if(!Ud(e))return{accepted:t,droppedKeys:r};for(let[n,o]of Object.entries(e)){if(!Ud(o)||"method"in o||"result"in o){r.push(n);continue}t[n]=o}return{accepted:t,droppedKeys:r}}function Cw(e){throw new L(D.SendFailed,`ctx.mcpReq.${e} is not available while fulfilling an embedded input request: the request is fulfilled locally and has no related peer request`)}function TE(e,t,r,n,o){return{sessionId:o,mcpReq:{id:e,method:t,_meta:r?._meta,requestState:KS(void 0),signal:n,send:(()=>Cw("send")),notify:()=>Cw("notify")}}}async function EE(e,t,r,n,o){if(!Ud(n)||typeof n.method!="string")throw new L(D.InvalidResult,`Invalid input request '${r}': each inputRequests entry must be an embedded request object with a method`,{key:r});let s=n.method;if(!t.hasInputRequestMethod(s))throw new L(D.InvalidResult,`Invalid input request '${r}': '${s}' is not an embedded request the ${t.era} revision defines (expected elicitation/create, sampling/createMessage, or roots/list)`,{key:r,method:s});let i=e.getRequestHandler(s);if(i===void 0)throw new L(D.CapabilityNotSupported,`Cannot fulfil input request '${r}': no handler is registered for '${s}' on this client. Declare the corresponding capability and register a handler, or handle input_required results manually.`,{key:r,method:s});let a=Ud(n.params)?n.params:void 0;return await i({jsonrpc:"2.0",id:r,method:s,...a!==void 0&&{params:a}},e.buildContext(TE(r,s,a,o,e.sessionId)))}function PE(e,t){return{...e?.signal!==void 0&&{signal:e.signal},...e?.onprogress!==void 0&&{onprogress:e.onprogress},...e?.resetTimeoutOnProgress!==void 0&&{resetTimeoutOnProgress:e.resetTimeoutOnProgress},...e?.headers!==void 0&&{headers:e.headers},...t.timeout!==void 0&&{timeout:t.timeout},...t.maxTotalTimeout!==void 0&&{maxTotalTimeout:t.maxTotalTimeout},allowInputRequired:!0}}function pz(e,t,r,n){let{codec:o,request:s,options:i,flowStartedAt:a}=n,c={inputRequests:r.inputRequests,...r.requestState!==void 0&&{requestState:r.requestState}},u={dispatchInputRequest:(d,p,h)=>EE(e,o,d,p,h),retry:(d,p)=>n.retry(d,PE(i,p))};return _E({config:t,method:s.method,originalParams:s.params,firstPayload:c,flowStartedAt:a,signal:i?.signal,requestOptions:{...i?.timeout!==void 0&&{timeout:i.timeout},...i?.maxTotalTimeout!==void 0&&{maxTotalTimeout:i.maxTotalTimeout},...i?.onprogress!==void 0&&{onprogress:i.onprogress}},hooks:u})}function CE(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var IE=S_((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,r=/\\([\u000b\u0020-\u00ff])/g,n=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=o;function o(a){if(!a)throw new TypeError("argument string is required");var c=typeof a=="object"?s(a):a;if(typeof c!="string")throw new TypeError("argument string is required to be a string");var u=c.indexOf(";"),d=u!==-1?c.slice(0,u).trim():c.trim();if(!n.test(d))throw new TypeError("invalid media type");var p=new i(d.toLowerCase());if(u!==-1){var h,f,S;for(t.lastIndex=u;f=t.exec(c);){if(f.index!==u)throw new TypeError("invalid parameter format");u+=f[0].length,h=f[1].toLowerCase(),S=f[2],S.charCodeAt(0)===34&&(S=S.slice(1,-1),S.indexOf("\\")!==-1&&(S=S.replace(r,"$1"))),p.parameters[h]=S}if(u!==c.length)throw new TypeError("invalid parameter format")}return p}function s(a){var c;if(typeof a.getHeader=="function"?c=a.getHeader("content-type"):typeof a.headers=="object"&&(c=a.headers&&a.headers["content-type"]),typeof c!="string")throw new TypeError("content-type header is missing from object");return c}function i(a){this.parameters=Object.create(null),this.type=a}})),CN=b_(IE(),1);var OE=10*1024*1024;function Ac(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let o=0;o<n;o++)if(!Ac(e[o],t[o]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(let s of n)if(!Ac(e[s],t[s]))return!1;return!0}return e===t}function xt(e){return encodeURI(NE(e))}function NE(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var AE={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},ME={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},LE={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},qE=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function On(e,t=Object.create(null),r=qE,n=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let s=e.$id||e.id;if(s){let i=new URL(s,r.href);i.hash.length>1?t[i.href]=e:(i.hash="",n===""?r=i:On(e,t,r))}}else if(e!==!0&&e!==!1)return t;let o=r.href+(n?"#"+n:"");if(t[o]!==void 0)throw new Error(`Duplicate schema URI "${o}".`);if(t[o]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:o}),e.$ref&&e.__absolute_ref__===void 0){let s=new URL(e.$ref,r.href);s.hash=s.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:s.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let s=new URL(e.$recursiveRef,r.href);s.hash=s.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:s.href})}if(e.$anchor){let s=new URL("#"+e.$anchor,r.href);t[s.href]=e}for(let s in e){if(LE[s])continue;let i=`${n}/${xt(s)}`,a=e[s];if(Array.isArray(a)){if(AE[s]){let c=a.length;for(let u=0;u<c;u++)On(a[u],t,r,`${i}/${u}`)}}else if(ME[s])for(let c in a)On(a[c],t,r,`${i}/${xt(c)}`);else On(a,t,r,i)}return t}var jE=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,DE=[0,31,28,31,30,31,30,31,31,30,31,30,31],UE=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,ZE=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,VE=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,FE=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,HE=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,BE=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,JE=/^(?:\/(?:[^~/]|~0|~1)*)*$/,KE=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,WE=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,GE=e=>{if(e[0]==='"')return!1;let[t,r,...n]=e.split("@");return!t||!r||n.length!==0||t.length>64||r.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:r.split(".").every(o=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(o))},YE=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,QE=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,XE=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Wt(e){return e.test.bind(e)}var mz={date:hz,time:fz.bind(void 0,!1),"date-time":rP,duration:XE,uri:sP,"uri-reference":Wt(VE),"uri-template":Wt(FE),url:Wt(HE),email:GE,hostname:Wt(ZE),ipv4:Wt(YE),ipv6:Wt(QE),regex:aP,uuid:Wt(BE),"json-pointer":Wt(JE),"json-pointer-uri-fragment":Wt(KE),"relative-json-pointer":Wt(WE)};function eP(e){return e%4===0&&(e%100!==0||e%400===0)}function hz(e){let t=e.match(jE);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n==2&&eP(r)?29:DE[n])}function fz(e,t){let r=t.match(UE);if(!r)return!1;let n=+r[1],o=+r[2],s=+r[3],i=!!r[5];return(n<=23&&o<=59&&s<=59||n==23&&o==59&&s==60)&&(!e||i)}var tP=/t|\s/i;function rP(e){let t=e.split(tP);return t.length==2&&hz(t[0])&&fz(!0,t[1])}var nP=/\/|:/,oP=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function sP(e){return nP.test(e)&&oP.test(e)}var iP=/[^\\]\\Z/;function aP(e){if(iP.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}function cP(e){let t=0,r=e.length,n=0,o;for(;n<r;)t++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<r&&(o=e.charCodeAt(n),(o&64512)==56320&&n++);return t}function _e(e,t,r="2019-09",n=On(t),o=!0,s=null,i="#",a="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:i,keyword:"false",keywordLocation:i,error:"False boolean schema."}]};let u=typeof e,d;switch(u){case"boolean":case"number":case"string":d=u;break;case"object":e===null?d="null":Array.isArray(e)?d="array":d="object";break;default:throw new Error(`Instances of "${u}" type are not supported.`)}let{$ref:p,$recursiveRef:h,$recursiveAnchor:f,type:S,const:_,enum:w,required:x,not:R,anyOf:k,allOf:J,oneOf:se,if:U,then:ie,else:Pe,format:he,properties:Ce,patternProperties:Je,additionalProperties:Tt,unevaluatedProperties:Et,minProperties:Pt,maxProperties:lt,propertyNames:Ct,dependentRequired:Ke,dependentSchemas:dt,dependencies:It,prefixItems:nt,items:Le,additionalItems:Qt,unevaluatedItems:Xt,contains:Ot,minContains:Ie,maxContains:qe,minItems:je,maxItems:yt,uniqueItems:Vr,minimum:ot,maximum:st,exclusiveMinimum:We,exclusiveMaximum:pt,multipleOf:mt,minLength:Nt,maxLength:At,pattern:fr,__absolute_ref__:Mt,__absolute_recursive_ref__:Fr}=t,O=[];if(f===!0&&s===null&&(s=t),h==="#"){let H=s===null?n[Fr]:s,q=`${a}/$recursiveRef`,ee=_e(e,s===null?t:s,r,n,o,H,i,q,c);ee.valid||O.push({instanceLocation:i,keyword:"$recursiveRef",keywordLocation:q,error:"A subschema had errors."},...ee.errors)}if(p!==void 0){let H=n[Mt||p];if(H===void 0){let N=`Unresolved $ref "${p}".`;throw Mt&&Mt!==p&&(N+=` Absolute URI "${Mt}".`),N+=`
299
+ Known schemas:
300
+ - ${Object.keys(n).join(`
301
+ - `)}`,new Error(N)}let q=`${a}/$ref`,ee=_e(e,H,r,n,o,s,i,q,c);if(ee.valid||O.push({instanceLocation:i,keyword:"$ref",keywordLocation:q,error:"A subschema had errors."},...ee.errors),r==="4"||r==="7")return{valid:O.length===0,errors:O}}if(Array.isArray(S)){let H=S.length,q=!1;for(let ee=0;ee<H;ee++)if(d===S[ee]||S[ee]==="integer"&&d==="number"&&e%1===0&&e===e){q=!0;break}q||O.push({instanceLocation:i,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${d}" is invalid. Expected "${S.join('", "')}".`})}else S==="integer"?(d!=="number"||e%1||e!==e)&&O.push({instanceLocation:i,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${d}" is invalid. Expected "${S}".`}):S!==void 0&&d!==S&&O.push({instanceLocation:i,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${d}" is invalid. Expected "${S}".`});if(_!==void 0&&(d==="object"||d==="array"?Ac(e,_)||O.push({instanceLocation:i,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(_)}.`}):e!==_&&O.push({instanceLocation:i,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(_)}.`})),w!==void 0&&(d==="object"||d==="array"?w.some(H=>Ac(e,H))||O.push({instanceLocation:i,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(w)}.`}):w.some(H=>e===H)||O.push({instanceLocation:i,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(w)}.`})),R!==void 0){let H=`${a}/not`;_e(e,R,r,n,o,s,i,H).valid&&O.push({instanceLocation:i,keyword:"not",keywordLocation:H,error:'Instance matched "not" schema.'})}let Lt=[];if(k!==void 0){let H=`${a}/anyOf`,q=O.length,ee=!1;for(let N=0;N<k.length;N++){let C=k[N],G=Object.create(c),K=_e(e,C,r,n,o,f===!0?s:null,i,`${H}/${N}`,G);O.push(...K.errors),ee=ee||K.valid,K.valid&&Lt.push(G)}ee?O.length=q:O.splice(q,0,{instanceLocation:i,keyword:"anyOf",keywordLocation:H,error:"Instance does not match any subschemas."})}if(J!==void 0){let H=`${a}/allOf`,q=O.length,ee=!0;for(let N=0;N<J.length;N++){let C=J[N],G=Object.create(c),K=_e(e,C,r,n,o,f===!0?s:null,i,`${H}/${N}`,G);O.push(...K.errors),ee=ee&&K.valid,K.valid&&Lt.push(G)}ee?O.length=q:O.splice(q,0,{instanceLocation:i,keyword:"allOf",keywordLocation:H,error:"Instance does not match every subschema."})}if(se!==void 0){let H=`${a}/oneOf`,q=O.length,ee=se.filter((N,C)=>{let G=Object.create(c),K=_e(e,N,r,n,o,f===!0?s:null,i,`${H}/${C}`,G);return O.push(...K.errors),K.valid&&Lt.push(G),K.valid}).length;ee===1?O.length=q:O.splice(q,0,{instanceLocation:i,keyword:"oneOf",keywordLocation:H,error:`Instance does not match exactly one subschema (${ee} matches).`})}if((d==="object"||d==="array")&&Object.assign(c,...Lt),U!==void 0){let H=`${a}/if`;if(_e(e,U,r,n,o,s,i,H,c).valid){if(ie!==void 0){let q=_e(e,ie,r,n,o,s,i,`${a}/then`,c);q.valid||O.push({instanceLocation:i,keyword:"if",keywordLocation:H,error:'Instance does not match "then" schema.'},...q.errors)}}else if(Pe!==void 0){let q=_e(e,Pe,r,n,o,s,i,`${a}/else`,c);q.valid||O.push({instanceLocation:i,keyword:"if",keywordLocation:H,error:'Instance does not match "else" schema.'},...q.errors)}}if(d==="object"){if(x!==void 0)for(let N of x)N in e||O.push({instanceLocation:i,keyword:"required",keywordLocation:`${a}/required`,error:`Instance does not have required property "${N}".`});let H=Object.keys(e);if(Pt!==void 0&&H.length<Pt&&O.push({instanceLocation:i,keyword:"minProperties",keywordLocation:`${a}/minProperties`,error:`Instance does not have at least ${Pt} properties.`}),lt!==void 0&&H.length>lt&&O.push({instanceLocation:i,keyword:"maxProperties",keywordLocation:`${a}/maxProperties`,error:`Instance does not have at least ${lt} properties.`}),Ct!==void 0){let N=`${a}/propertyNames`;for(let C in e){let G=`${i}/${xt(C)}`,K=_e(C,Ct,r,n,o,s,G,N);K.valid||O.push({instanceLocation:i,keyword:"propertyNames",keywordLocation:N,error:`Property name "${C}" does not match schema.`},...K.errors)}}if(Ke!==void 0){let N=`${a}/dependantRequired`;for(let C in Ke)if(C in e){let G=Ke[C];for(let K of G)K in e||O.push({instanceLocation:i,keyword:"dependentRequired",keywordLocation:N,error:`Instance has "${C}" but does not have "${K}".`})}}if(dt!==void 0)for(let N in dt){let C=`${a}/dependentSchemas`;if(N in e){let G=_e(e,dt[N],r,n,o,s,i,`${C}/${xt(N)}`,c);G.valid||O.push({instanceLocation:i,keyword:"dependentSchemas",keywordLocation:C,error:`Instance has "${N}" but does not match dependant schema.`},...G.errors)}}if(It!==void 0){let N=`${a}/dependencies`;for(let C in It)if(C in e){let G=It[C];if(Array.isArray(G))for(let K of G)K in e||O.push({instanceLocation:i,keyword:"dependencies",keywordLocation:N,error:`Instance has "${C}" but does not have "${K}".`});else{let K=_e(e,G,r,n,o,s,i,`${N}/${xt(C)}`);K.valid||O.push({instanceLocation:i,keyword:"dependencies",keywordLocation:N,error:`Instance has "${C}" but does not match dependant schema.`},...K.errors)}}}let q=Object.create(null),ee=!1;if(Ce!==void 0){let N=`${a}/properties`;for(let C in Ce){if(!(C in e))continue;let G=`${i}/${xt(C)}`,K=_e(e[C],Ce[C],r,n,o,s,G,`${N}/${xt(C)}`);if(K.valid)c[C]=q[C]=!0;else if(ee=o,O.push({instanceLocation:i,keyword:"properties",keywordLocation:N,error:`Property "${C}" does not match schema.`},...K.errors),ee)break}}if(!ee&&Je!==void 0){let N=`${a}/patternProperties`;for(let C in Je){let G=new RegExp(C,"u"),K=Je[C];for(let ve in e){if(!G.test(ve))continue;let Hr=`${i}/${xt(ve)}`,qt=_e(e[ve],K,r,n,o,s,Hr,`${N}/${xt(C)}`);qt.valid?c[ve]=q[ve]=!0:(ee=o,O.push({instanceLocation:i,keyword:"patternProperties",keywordLocation:N,error:`Property "${ve}" matches pattern "${C}" but does not match associated schema.`},...qt.errors))}}}if(!ee&&Tt!==void 0){let N=`${a}/additionalProperties`;for(let C in e){if(q[C])continue;let G=`${i}/${xt(C)}`,K=_e(e[C],Tt,r,n,o,s,G,N);K.valid?c[C]=!0:(ee=o,O.push({instanceLocation:i,keyword:"additionalProperties",keywordLocation:N,error:`Property "${C}" does not match additional properties schema.`},...K.errors))}}else if(!ee&&Et!==void 0){let N=`${a}/unevaluatedProperties`;for(let C in e)if(!c[C]){let G=`${i}/${xt(C)}`,K=_e(e[C],Et,r,n,o,s,G,N);K.valid?c[C]=!0:O.push({instanceLocation:i,keyword:"unevaluatedProperties",keywordLocation:N,error:`Property "${C}" does not match unevaluated properties schema.`},...K.errors)}}}else if(d==="array"){yt!==void 0&&e.length>yt&&O.push({instanceLocation:i,keyword:"maxItems",keywordLocation:`${a}/maxItems`,error:`Array has too many items (${e.length} > ${yt}).`}),je!==void 0&&e.length<je&&O.push({instanceLocation:i,keyword:"minItems",keywordLocation:`${a}/minItems`,error:`Array has too few items (${e.length} < ${je}).`});let H=e.length,q=0,ee=!1;if(nt!==void 0){let N=`${a}/prefixItems`,C=Math.min(nt.length,H);for(;q<C;q++){let G=_e(e[q],nt[q],r,n,o,s,`${i}/${q}`,`${N}/${q}`);if(c[q]=!0,!G.valid&&(ee=o,O.push({instanceLocation:i,keyword:"prefixItems",keywordLocation:N,error:"Items did not match schema."},...G.errors),ee))break}}if(Le!==void 0){let N=`${a}/items`;if(Array.isArray(Le)){let C=Math.min(Le.length,H);for(;q<C;q++){let G=_e(e[q],Le[q],r,n,o,s,`${i}/${q}`,`${N}/${q}`);if(c[q]=!0,!G.valid&&(ee=o,O.push({instanceLocation:i,keyword:"items",keywordLocation:N,error:"Items did not match schema."},...G.errors),ee))break}}else for(;q<H;q++){let C=_e(e[q],Le,r,n,o,s,`${i}/${q}`,N);if(c[q]=!0,!C.valid&&(ee=o,O.push({instanceLocation:i,keyword:"items",keywordLocation:N,error:"Items did not match schema."},...C.errors),ee))break}if(!ee&&Qt!==void 0){let C=`${a}/additionalItems`;for(;q<H;q++){let G=_e(e[q],Qt,r,n,o,s,`${i}/${q}`,C);c[q]=!0,G.valid||(ee=o,O.push({instanceLocation:i,keyword:"additionalItems",keywordLocation:C,error:"Items did not match additional items schema."},...G.errors))}}}if(Ot!==void 0)if(H===0&&Ie===void 0)O.push({instanceLocation:i,keyword:"contains",keywordLocation:`${a}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(Ie!==void 0&&H<Ie)O.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array has less items (${H}) than minContains (${Ie}).`});else{let N=`${a}/contains`,C=O.length,G=0;for(let K=0;K<H;K++){let ve=_e(e[K],Ot,r,n,o,s,`${i}/${K}`,N);ve.valid?(c[K]=!0,G++):O.push(...ve.errors)}G>=(Ie||0)&&(O.length=C),Ie===void 0&&qe===void 0&&G===0?O.splice(C,0,{instanceLocation:i,keyword:"contains",keywordLocation:N,error:"Array does not contain item matching schema."}):Ie!==void 0&&G<Ie?O.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array must contain at least ${Ie} items matching schema. Only ${G} items were found.`}):qe!==void 0&&G>qe&&O.push({instanceLocation:i,keyword:"maxContains",keywordLocation:`${a}/maxContains`,error:`Array may contain at most ${qe} items matching schema. ${G} items were found.`})}if(!ee&&Xt!==void 0){let N=`${a}/unevaluatedItems`;for(;q<H;q++){if(c[q])continue;let C=_e(e[q],Xt,r,n,o,s,`${i}/${q}`,N);c[q]=!0,C.valid||O.push({instanceLocation:i,keyword:"unevaluatedItems",keywordLocation:N,error:"Items did not match unevaluated items schema."},...C.errors)}}if(Vr)for(let N=0;N<H;N++){let C=e[N],G=typeof C=="object"&&C!==null;for(let K=0;K<H;K++){if(N===K)continue;let ve=e[K];(C===ve||G&&typeof ve=="object"&&ve!==null&&Ac(C,ve))&&(O.push({instanceLocation:i,keyword:"uniqueItems",keywordLocation:`${a}/uniqueItems`,error:`Duplicate items at indexes ${N} and ${K}.`}),N=Number.MAX_SAFE_INTEGER,K=Number.MAX_SAFE_INTEGER)}}}else if(d==="number"){if(r==="4"?(ot!==void 0&&(We===!0&&e<=ot||e<ot)&&O.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${We?"or equal to ":""} ${ot}.`}),st!==void 0&&(pt===!0&&e>=st||e>st)&&O.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${pt?"or equal to ":""} ${st}.`})):(ot!==void 0&&e<ot&&O.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${ot}.`}),st!==void 0&&e>st&&O.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${st}.`}),We!==void 0&&e<=We&&O.push({instanceLocation:i,keyword:"exclusiveMinimum",keywordLocation:`${a}/exclusiveMinimum`,error:`${e} is less than ${We}.`}),pt!==void 0&&e>=pt&&O.push({instanceLocation:i,keyword:"exclusiveMaximum",keywordLocation:`${a}/exclusiveMaximum`,error:`${e} is greater than or equal to ${pt}.`})),mt!==void 0){let H=e%mt;Math.abs(0-H)>=11920929e-14&&Math.abs(mt-H)>=11920929e-14&&O.push({instanceLocation:i,keyword:"multipleOf",keywordLocation:`${a}/multipleOf`,error:`${e} is not a multiple of ${mt}.`})}}else if(d==="string"){let H=Nt===void 0&&At===void 0?0:cP(e);Nt!==void 0&&H<Nt&&O.push({instanceLocation:i,keyword:"minLength",keywordLocation:`${a}/minLength`,error:`String is too short (${H} < ${Nt}).`}),At!==void 0&&H>At&&O.push({instanceLocation:i,keyword:"maxLength",keywordLocation:`${a}/maxLength`,error:`String is too long (${H} > ${At}).`}),fr!==void 0&&!new RegExp(fr,"u").test(e)&&O.push({instanceLocation:i,keyword:"pattern",keywordLocation:`${a}/pattern`,error:"String does not match pattern."}),he!==void 0&&mz[he]&&!mz[he](e)&&O.push({instanceLocation:i,keyword:"format",keywordLocation:`${a}/format`,error:`String does not match format "${he}".`})}return{valid:O.length===0,errors:O}}var uP=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",r=!0){this.schema=e,this.draft=t,this.shortCircuit=r,this.lookup=On(e)}validate(e){return _e(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),On(e,this.lookup)}},Hd=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=w_(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return t==="draft-7"?"7":t}getValidator(e){let t=new uP(e,this.draft??this._draftFor(e),this.shortcircuit);return r=>{let n=t.validate(r);return n.valid?{valid:!0,data:r,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:n.errors.map(o=>`${o.instanceLocation}: ${o.error}`).join("; ")}}}};var lP;lP=globalThis.crypto;var ls=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return rt(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rt(this,e)}constructor(e){super(e),this.name=new.target.name,Ur(this,new.target)}},gP=class extends ls{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.IssuerMismatchError"})}kind;expected;received;constructor(e,t,r){super(`Issuer mismatch in ${e==="metadata"?"authorization server metadata (RFC 8414 \xA73.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(t)}, received ${JSON.stringify(r)}`),this.kind=e,this.expected=t,this.received=r}},SP=class extends ls{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.RegistrationRejectedError"})}status;body;submittedMetadata;constructor(e){super(`Dynamic Client Registration rejected (HTTP ${e.status}): ${e.body}`),this.status=e.status,this.body=e.body,this.submittedMetadata=e.submittedMetadata}},_P=class extends ls{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsecureTokenEndpointError"})}tokenEndpoint;constructor(e){super(`Refusing to send credentials to non-https token endpoint '${e}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`),this.tokenEndpoint=e}},bP=class extends ls{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.AuthorizationServerMismatchError"})}constructor(e,t){super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(e)} but this call resolved ${JSON.stringify(t)}; refusing to present them to a different authorization server`),this.recordedIssuer=e,this.currentIssuer=t}},yP=class extends ls{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsufficientScopeError"})}requiredScope;resourceMetadataUrl;errorDescription;constructor(e){super(`Insufficient scope${e.requiredScope?`: required "${e.requiredScope}"`:""}`),this.requiredScope=e.requiredScope,this.resourceMetadataUrl=e.resourceMetadataUrl,this.errorDescription=e.errorDescription}};var zz=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return rt(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rt(this,e)}constructor(e){super(e??"Unauthorized"),this.name="UnauthorizedError",Ur(this,new.target)}};var Bd=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","server/discover"]),Rz=class{_entries=new Map;_maxEntries;_stamp=0;_cappedSize=0;constructor(e){this._maxEntries=e?.maxEntries??512}get size(){return this._entries.size}get(e){return this._entries.get(GS(e))}set(e,t){let r=GS(e),n=Bd.has(e.method),o=!this._entries.has(r);if(!n&&o&&this._maxEntries>0&&this._cappedSize>=this._maxEntries){for(let i of this._entries.keys())if(!Bd.has(i.slice(0,i.indexOf("\0")))){this._entries.delete(i),this._cappedSize--;break}}let s=++this._stamp;return this._entries.set(r,{...t,stamp:s}),o&&!n&&this._cappedSize++,s}delete(e){this._entries.delete(GS(e))&&!Bd.has(e.method)&&this._cappedSize--}evict(e){let t=`${e}\0`,r=Bd.has(e);for(let n of this._entries.keys())n.startsWith(t)&&(this._entries.delete(n),r||this._cappedSize--)}clear(){this._entries.clear(),this._cappedSize=0}};function GS(e){return`${e.method}\0${JSON.stringify([e.partition??"",e.params??""])}`}function YS(e,t){return t===void 0?e:`${e}\0${t}`}var $z=864e5,vP=class{_evictionGeneration=new Map;_toolIndex;_toolOutputValidatorIndex;_serverIdentity="";constructor(e,t,r=()=>{},n="",o=Date.now){this._store=e,this._isUserSupplied=t,this._reportError=r,this._cachePartition=n,this._now=o}now(){return this._now()}setServerIdentity(e){this._serverIdentity=e}_partitionFor(e){return JSON.stringify([this._serverIdentity,e==="public"?"":this._cachePartition])}async _probe(e,t){let r={method:e,params:t??""},n=this._partitionFor("private"),o=await this._store.get({...r,partition:n});if(o!==void 0)return o;let s=this._partitionFor("public");if(s===n)return;let i=await this._store.get({...r,partition:s});return i?.scope==="public"?i:void 0}async evict(e){this._evictionGeneration.set(e,(this._evictionGeneration.get(e)??0)+1),await this._deleteBoth(e,"")}async _deleteBoth(e,t){let r=this._partitionFor("private"),n=this._partitionFor("public");try{await this._store.delete({method:e,params:t,partition:r})}catch(o){this._reportError(o)}if(n!==r)try{await this._store.delete({method:e,params:t,partition:n})}catch(o){this._reportError(o)}}async evictKey(e,t){let r=YS(e,t),n=this._evictionGeneration.get(r);n!==void 0&&this._evictionGeneration.set(r,n+1),await this._deleteBoth(e,t)}captureGeneration(e,t){let r=YS(e,t),n=this._evictionGeneration.get(r)??0;return this._evictionGeneration.set(r,n),n}async write(e,t,r,n){if((this._evictionGeneration.get(YS(e,n?.params))??0)!==r)return;let o=n?.params??"",s=this._partitionFor("private"),i=this._partitionFor("public"),a=(n?.scope??"private")==="public"?i:s;try{await this._store.set({method:e,params:o,partition:a},{value:wP(t),expiresAt:n?.expiresAt,scope:n?.scope})}catch(c){this._reportError(c)}if(i!==s)try{await this._store.delete({method:e,params:o,partition:a===s?i:s})}catch(c){this._reportError(c)}}async read(e,t){let r=await this._probe(e,t);if(!(r?.expiresAt===void 0||!(r.expiresAt>this.now())))try{let n=JSON.parse(r.value);if(typeof n!="object"||n===null||Array.isArray(n))throw new TypeError("cached document is not an object");return{value:n}}catch(n){this._reportError(n),await this._deleteBoth(e,t??"");return}}resetForReconnect(){this._isUserSupplied||this._store.clear(),this._evictionGeneration.clear(),this._toolIndex=void 0,this._toolOutputValidatorIndex=void 0,this._serverIdentity=""}async toolDefinition(e){let t=await this._probe("tools/list");if(t===void 0){this._toolIndex=void 0;return}if(this._toolIndex?.stamp!==t.stamp){let r=this._decodeListTools(t),n=new Map;if(r!==void 0)for(let o of r.tools)n.set(o.name,o);this._toolIndex={stamp:t.stamp,byName:n}}return this._toolIndex.byName.get(e)}async outputValidator(e,t){let r=await this._probe("tools/list");if(r===void 0){this._toolOutputValidatorIndex=void 0;return}if(this._toolOutputValidatorIndex?.stamp!==r.stamp){let n=this._decodeListTools(r)??{tools:[]},o=new Map;for(let s of n.tools){let i=t(s);i!==void 0&&o.set(s.name,i)}this._toolOutputValidatorIndex={stamp:r.stamp,byName:o}}return this._toolOutputValidatorIndex.byName.get(e)}_decodeListTools(e){try{let t=JSON.parse(e.value);if(!Array.isArray(t?.tools)||!t.tools.every(r=>r!==null&&typeof r=="object"))throw new TypeError("cached tools/list document has a malformed tools array");return t}catch(t){this._reportError(t);return}}};function wP(e){let t;try{t=JSON.stringify(e)}catch(r){throw new TypeError(`cache value is not JSON-serializable: ${r instanceof Error?r.message:String(r)}`)}if(typeof t!="string")throw new TypeError("cache value is not JSON-serializable: it has no JSON representation");return t}var zP=Symbol.for("mcp.authSeamEscape");function RP(e){return(typeof e=="object"&&e!==null||typeof e=="function")&&e[zP]===!0}var $P=-32022,kP=new Set([-32001,-32020,-32021]);function xP(e,t){switch(e.kind){case"result":return TP(e.result,t);case"rpc-error":return kz(e,t);case"http-error":return EP(e,t);case"network-error":return gz(e.error,t);case"unusable-reply":return{kind:"error",error:new L(D.EraNegotiationFailed,`Version negotiation probe failed: the server answered with an unusable reply (${xz(e.error)})`,{cause:e.error},{cause:e.error})};case"auth-required":return{kind:"error",error:e.error};case"closed":return t.transportKind==="stdio"?{kind:"legacy"}:gz(new Error("Connection closed during the version negotiation probe"),t);case"timeout":return t.transportKind==="stdio"?{kind:"legacy"}:{kind:"error",error:new L(D.RequestTimeout,`Version negotiation probe timed out after ${e.timeoutMs}ms`,{timeout:e.timeoutMs})}}}function TP(e,t){let r=mr(Zd).validateResult("server/discover",e);if(!r.ok)return{kind:"legacy"};let n=r.value.supportedVersions,o=t.clientModernVersions.find(s=>n.includes(s));return o!==void 0?{kind:"modern",version:o,discover:r.value}:t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:new Cc({supported:[...n],requested:t.requestedVersion})}}function kz(e,t){let{code:r,message:n,data:o}=e;if(r===$P){let s=CP(o);if(s===void 0)return{kind:"legacy"};let i=new Cc({supported:s,requested:IP(o)??t.requestedVersion},n),a=Pc(s),c=t.clientModernVersions.find(u=>a.includes(u));return c!==void 0?{kind:"corrective",version:c,error:i}:a.length>0?{kind:"error",error:i}:t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:i}}return kP.has(r)?{kind:"legacy"}:{kind:"legacy"}}function EP(e,t){if(e.status===401||e.status===403){let n=e.status===403;return{kind:"error",error:new Ec(n?D.ClientHttpForbidden:D.ClientHttpAuthentication,`Version negotiation failed: ${n?"the server denied access (HTTP 403)":"the server requires authorization (HTTP 401)"}`,{status:e.status,statusText:e.statusText,text:e.body})}}if(e.status>=500)return{kind:"error",error:new Ec(D.EraNegotiationFailed,`Version negotiation failed: the server answered the probe with HTTP ${e.status}`,{status:e.status,statusText:e.statusText,text:e.body})};let r=OP(e.body);return r!==void 0?kz(r,t):{kind:"legacy"}}function gz(e,t){return t.environment==="browser"&&PP(e)?{kind:"legacy"}:{kind:"error",error:new L(D.EraNegotiationFailed,`Version negotiation probe failed: ${xz(e)}`,{cause:e},{cause:e})}}function PP(e){return e instanceof TypeError||e instanceof Error&&e.name==="TypeError"}function xz(e){return e instanceof Error?e.message:String(e)}function CP(e){if(typeof e!="object"||e===null)return;let t=e.supported;if(!(!Array.isArray(t)||t.length===0||!t.every(r=>typeof r=="string")))return t}function IP(e){if(typeof e!="object"||e===null)return;let t=e.requested;return typeof t=="string"?t:void 0}function OP(e){if(e===void 0||e==="")return;let t;try{t=JSON.parse(e)}catch{return}if(typeof t!="object"||t===null)return;let r=t.error;if(typeof r!="object"||r===null)return;let{code:n,message:o,data:s}=r;if(typeof n=="number")return{code:n,message:typeof o=="string"?o:"",data:s}}var NP="legacy";function AP(e,t){let r=e?.mode??NP;if(r==="legacy")return{kind:"legacy"};let n=e?.probe??{};if(typeof r=="object"){if(!hr(r.pin))throw new TypeError(`versionNegotiation: { pin: '${r.pin}' } is not a modern protocol revision \u2014 pinning is for 2026-07-28 and later; omit versionNegotiation (or use mode: 'legacy') for 2025-era servers.`);return{kind:"pin",version:r.pin,probe:n}}let o=t?Pc(t):[];return{kind:"auto",modernVersions:o.length>0?o:[...qS],fallbackAvailable:t?jS(t).length>0:!0,probe:n}}function Sz(){let e=globalThis;return e.window!==void 0&&e.document!==void 0?"browser":"node"}function _z(e){return"stderr"in e&&"pid"in e?"stdio":"http"}var MP=class Tz{_pending;_probeCounter=0;_savedOnMessage;_savedOnError;_savedOnClose;_closeDelivered=!1;constructor(t){this._transport=t,this._savedOnMessage=t.onmessage,this._savedOnError=t.onerror,this._savedOnClose=t.onclose}static async open(t){let r=new Tz(t);t.onmessage=n=>{let o=r._pending;if(o!==void 0&&(us(n)||Ic(n))&&n.id===o.id){r._pending=void 0,us(n)?o.resolve({kind:"response",result:n.result}):o.resolve({kind:"response",error:n.error});return}},t.onerror=n=>{r._savedOnError?.(n)},t.onclose=()=>{let n=r._pending;n!==void 0&&(r._pending=void 0,n.resolve({kind:"closed"})),r._closeDelivered=!0,r._savedOnClose?.()};try{await t.start()}catch(n){throw r.detach(),n}return r}async exchange(t,r){let n=`server-discover-probe-${++this._probeCounter}`;return new Promise(o=>{let s=!1,i=c=>{s||(s=!0,clearTimeout(a),this._pending?.id===n&&(this._pending=void 0),o(c))},a=setTimeout(()=>i({kind:"timeout"}),r);this._pending={id:n,resolve:i},this._transport.send(t(n)).catch(c=>i({kind:"send-error",error:c}))})}detach(){if(this._pending=void 0,this._transport.onmessage=this._savedOnMessage,this._transport.onerror=this._savedOnError,this._closeDelivered&&this._savedOnClose!==void 0){let t=this._savedOnClose,r=this._transport,n=!1,o=()=>{if(!n){n=!0;return}t()};r.onclose=o,XS.set(r,()=>{r.onclose===o&&(r.onclose=t)})}else this._transport.onclose=this._savedOnClose}release(){this.detach();let t=this._transport,r=t.start,n=!0;t.start=async function(){if(n){n=!1,t.start=r;return}return r.call(t)}}},XS=new WeakMap;function bz(e){let t=XS.get(e);XS.delete(e),t?.()}function LP(e,t,r,n){return{jsonrpc:"2.0",id:e,method:"server/discover",params:{_meta:mr(t).outboundEnvelope({protocolVersion:t,clientInfo:r,clientCapabilities:n})}}}function qP(e){return e instanceof L&&e.code===D.ClientHttpUnexpectedContent?!0:e instanceof Error&&e.name==="SyntaxError"}function jP(e,t){switch(e.kind){case"response":return e.error===void 0?{kind:"result",result:e.result}:{kind:"rpc-error",...e.error};case"send-error":{let r=e.error;if(RP(r)||r instanceof zz||r instanceof Error&&r.name==="UnauthorizedError")return{kind:"auth-required",error:r};if(r instanceof Ec){let n=r.data?.text;return{kind:"http-error",status:r.data.status,body:typeof n=="string"?n:void 0,statusText:r.data.statusText}}return qP(r)?{kind:"unusable-reply",error:r}:{kind:"network-error",error:r}}case"closed":return{kind:"closed"};case"timeout":return{kind:"timeout",timeoutMs:t}}}async function Ez(e,t){let r=e.probe.timeoutMs??t.defaultTimeoutMs,n=Math.max(0,e.probe.maxRetries??0),o=e.kind==="pin"?[e.version]:e.modernVersions,s=e.kind==="auto"&&e.fallbackAvailable,i=await MP.open(t.transport),a=async()=>{let u=o[0],d=!1,p=n;for(;;){let h=await i.exchange(_=>LP(_,u,t.clientInfo,t.capabilities),r);if(h.kind==="timeout"&&p>0){p--;continue}let f=jP(h,r),S=xP(f,{clientModernVersions:o,requestedVersion:u,fallbackAvailable:s,environment:t.environment,transportKind:t.transportKind});switch(S.kind){case"modern":return{era:"modern",version:S.version,discover:S.discover};case"corrective":if(d)throw S.error;d=!0,u=S.version;continue;case"legacy":{let _=f.kind==="closed"?"the connection closed during the server/discover probe":void 0;if(e.kind==="pin")throw new L(D.EraNegotiationFailed,_===void 0?`Version negotiation failed: the server did not offer pinned protocol version ${e.version} via server/discover (no fallback in pin mode)`:`Version negotiation failed: ${_} before the server offered pinned protocol version ${e.version} (no fallback in pin mode)`);if(!e.fallbackAvailable)throw new L(D.EraNegotiationFailed,_===void 0?"Version negotiation failed: the server gave no modern evidence and this client supports no pre-2026-07-28 protocol version to fall back to":`Version negotiation failed: ${_} and this client supports no pre-2026-07-28 protocol version to fall back to`);if(_!==void 0&&t.disposableProbe!==!0)throw new L(D.EraNegotiationFailed,`Version negotiation failed: ${_} (this transport probed in place \u2014 the disposable sibling probe requires the SDK's base StdioClientTransport)`);return{era:"legacy"}}case"error":throw S.error}}},c;try{c=await a()}catch(u){throw i.detach(),u}return i.release(),c}function DP(e){let t=Object.getPrototypeOf(e);if(t===null||!Object.prototype.hasOwnProperty.call(t,"_dispose"))return;let r=e._serverParams;return typeof r=="object"&&r!==null&&typeof r.command=="string"?r:void 0}async function UP(e,t,r,n){let o=t.constructor,s=new o({...r,stderr:"ignore"}),i=t.close,a=!1,c,u=new Promise((p,h)=>{c=()=>h(yz())});t.close=async function(){return a=!0,c?.(),i.call(t)};let d;try{let p=Ez(e,{...n,transport:s,transportKind:"stdio",disposableProbe:!0});p.catch(()=>{}),d=await Promise.race([p,u])}finally{await ZP(s),t.close=i}if(a)throw yz();return d}function yz(){return new L(D.EraNegotiationFailed,"Version negotiation failed: the transport was closed during the server/discover probe")}async function ZP(e){try{let t=e._dispose;await(typeof t=="function"?t.call(e):e.close())}catch{}}function vz(e){let t=e._meta?.[Ht];return JS.Implementation(t)?t:void 0}function Jd(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){let r=t,n=e.properties;for(let o of Object.keys(n)){let s=n[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[o]=s.default),r[o]!==void 0&&Jd(s,r[o])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&Jd(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&Jd(r,t)}}function Pz(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}function VP(e){if(typeof e=="object"&&e!==null&&(e.kind==="legacy"&&!("supportedVersions"in e)&&!("discover"in e)||e.kind==="modern"&&Lr.safeParse(e.discover).success))return e;throw new L(D.EraNegotiationFailed,"connect({ prior }): unrecognized prior \u2014 expected { kind: 'modern', discover } or { kind: 'legacy' }")}var wz={"notifications/tools/list_changed":["tools/list"],"notifications/prompts/list_changed":["prompts/list"],"notifications/resources/list_changed":["resources/list","resources/templates/list"]},FP=64,QS={},HP=class extends Nc{_serverCapabilities;_serverVersion;_capabilities;_instructions;_jsonSchemaValidator;_cache;_defaultCacheTtlMs;_listMaxPages;_listChangedDebounceTimers=new Map;_listChangedConfig;_enforceStrictCapabilities;_versionNegotiation;_supportedProtocolVersionsOption;_inputRequiredDriverConfig;_listenState=new Map;_nextListenId=0;_autoOpenedSubscription;_discoverResult;static{QS.enforceStrictCapabilities=e=>e._enforceStrictCapabilities,QS.walkPages=(e,t,r,n)=>e._walkPages(t,r,n),QS.readResource=(e,t,r)=>e._readResource(t,r)}_resetConnectionState(){if(this._negotiatedProtocolVersion=void 0,this._serverCapabilities=void 0,this._serverVersion=void 0,this._instructions=void 0,this._discoverResult=void 0,this._autoOpenedSubscription=void 0,this._listenState.size>0){let e=new L(D.ConnectionClosed,"subscriptions/listen: client reconnected or closed; subscription state from the previous connection was reset");for(let t of this._listenState.values())t.settle({cause:"remote",error:e})}this._listenState.clear();for(let e of this._listChangedDebounceTimers.values())clearTimeout(e);this._listChangedDebounceTimers.clear(),this._cache.resetForReconnect()}async close(){try{await super.close()}finally{this._resetConnectionState()}}constructor(e,t){super(t),this._clientInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new Hd,this._enforceStrictCapabilities=t?.enforceStrictCapabilities??!1,this._versionNegotiation=t?.versionNegotiation,this._supportedProtocolVersionsOption=t?.supportedProtocolVersions,this._inputRequiredDriverConfig=cz(t?.inputRequired),this._cache=new vP(t?.responseCacheStore??new Rz,t?.responseCacheStore!==void 0,r=>this._reportStoreError(r),t?.cachePartition??""),this._defaultCacheTtlMs=t?.defaultCacheTtlMs??0,this._listMaxPages=t?.listMaxPages??FP,t?.listChanged&&(this._listChangedConfig=t.listChanged)}buildContext(e,t){return e}_shouldDropInbound(e){if(this._negotiatedProtocolVersion!==void 0&&hr(this._negotiatedProtocolVersion)&&Vd(e))return"drop"}_outboundMetaEnvelope(){let e=this._negotiatedProtocolVersion;if(e!==void 0)return this._wireCodec().outboundEnvelope({protocolVersion:e,clientInfo:this._clientInfo,clientCapabilities:this._capabilities})}_resolveNonCompleteResult(e,t){return this._inputRequiredDriverConfig.autoFulfill?pz({getRequestHandler:r=>this._getRequestHandler(r),buildContext:r=>this.buildContext(r,void 0),sessionId:this.transport?.sessionId},this._inputRequiredDriverConfig,e,t):Promise.reject(new L(D.UnsupportedResultType,`Unsupported result type 'input_required' for ${t.request.method}: multi-round-trip auto-fulfilment is not enabled on this instance \u2014 pass allowInputRequired: true to handle it manually, or enable inputRequired.autoFulfill`,{resultType:"input_required",method:t.request.method}))}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools","notifications/tools/list_changed",e.tools,async()=>(await this.listTools(void 0,{cacheMode:"refresh"})).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts","notifications/prompts/list_changed",e.prompts,async()=>(await this.listPrompts(void 0,{cacheMode:"refresh"})).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources","notifications/resources/list_changed",e.resources,async()=>(await this.listResources(void 0,{cacheMode:"refresh"})).resources)}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=WS(this._capabilities,e)}setVersionNegotiation(e){if(this.transport)throw new Error("Cannot configure version negotiation after connecting to transport");this._versionNegotiation=e}_wrapHandler(e,t){return e==="elicitation/create"?async(r,n)=>{let o=mr(this._negotiatedProtocolVersion),s=o.validateRequest("elicitation/create",r);if(!s.ok&&s.reason==="not-in-era"&&(s=o.validateInputRequest("elicitation/create",r)),!s.ok)throw new ae(s.reason==="not-in-era"?W.InternalError:W.InvalidParams,s.reason==="not-in-era"?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation request: ${s.message}`);let{params:i}=s.value;i.mode=i.mode??"form";let{supportsFormMode:a,supportsUrlMode:c}=Pz(this._capabilities.elicitation);if(i.mode==="form"&&!a)throw new ae(W.InvalidParams,"Client does not support form-mode elicitation requests");if(i.mode==="url"&&!c)throw new ae(W.InvalidParams,"Client does not support URL-mode elicitation requests");let u=await t(r,n),d=o.validateResult("elicitation/create",u);if(!d.ok&&d.reason==="not-in-era"&&(d=o.validateInputResponse("elicitation/create",u)),!d.ok)throw new ae(d.reason==="not-in-era"?W.InternalError:W.InvalidParams,d.reason==="not-in-era"?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation result: ${d.message}`);let p=d.value,h=i.mode==="form"?i.requestedSchema:void 0;if(i.mode==="form"&&p.action==="accept"&&p.content&&h&&this._capabilities.elicitation?.form?.applyDefaults)try{Jd(h,p.content)}catch{}return p}:e==="sampling/createMessage"?async(r,n)=>{let o=mr(this._negotiatedProtocolVersion),s=o.validateRequest("sampling/createMessage",r);if(!s.ok&&s.reason==="not-in-era"&&(s=o.validateInputRequest("sampling/createMessage",r)),!s.ok)throw new ae(s.reason==="not-in-era"?W.InternalError:W.InvalidParams,s.reason==="not-in-era"?"No wire schema for sampling/createMessage in the resolved era":`Invalid sampling request: ${s.message}`);let{params:i}=s.value,a=await t(r,n),c=!!(i.tools||i.toolChoice),u=o.samplingResultVariant(c,a);if(!u.ok&&u.reason==="not-in-era"&&(u=o.validateInputResponse("sampling/createMessage",a)),!u.ok)throw new ae(u.reason==="not-in-era"?W.InternalError:W.InvalidParams,u.reason==="not-in-era"?"No result schema for sampling/createMessage in the resolved era":`Invalid sampling result: ${u.message}`);return u.value}:t}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new L(D.CapabilityNotSupported,`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(t?.prior!=null)return this._connectFromPrior(e,VP(t.prior),t);let r=AP(this._versionNegotiation,this._supportedProtocolVersionsOption);return r.kind!=="legacy"?this._connectNegotiated(e,r,t):this._connectPlainLegacy(e,t)}async _connectPlainLegacy(e,t){if(await super.connect(e),e.sessionId!==void 0){let r=this._negotiatedProtocolVersion;r!==void 0&&e.setProtocolVersion?.(r);return}this._resetConnectionState(),await this._legacyHandshake(e,t)}async _legacyHandshake(e,t){let r=jS(this._supportedProtocolVersions);try{let n=r[0];if(n===void 0)throw new L(D.EraNegotiationFailed,"Cannot run the initialize handshake: supportedProtocolVersions contains no pre-2026-07-28 protocol version");let o=await this.request({method:"initialize",params:{protocolVersion:n,capabilities:this._capabilities,clientInfo:this._clientInfo}},t);if(o===void 0)throw new Error(`Server sent invalid initialize result: ${o}`);if(!r.includes(o.protocolVersion))throw new Error(`Server's protocol version is not supported: ${o.protocolVersion}`);this._serverCapabilities=o.capabilities,this._serverVersion=o.serverInfo,this._cache.setServerIdentity(this._deriveServerIdentity(e)),e.setProtocolVersion&&e.setProtocolVersion(o.protocolVersion),this._instructions=o.instructions,await this.notification({method:"notifications/initialized"}),this._negotiatedProtocolVersion=o.protocolVersion,this._listChangedConfig&&this._setupListChangedHandlers(this._listChangedConfig)}catch(n){throw this.close(),n}}async _connectNegotiated(e,t,r){if(e.sessionId!==void 0){await super.connect(e);let o=this._negotiatedProtocolVersion;o!==void 0&&e.setProtocolVersion&&e.setProtocolVersion(o);return}this._resetConnectionState();let n;try{let o=_z(e),s={clientInfo:this._clientInfo,capabilities:this._capabilities,environment:Sz(),defaultTimeoutMs:r?.timeout??Oc},i=o==="stdio"?DP(e):void 0;n=i===void 0?await Ez(t,{...s,transport:e,transportKind:o}):await UP(t,e,i,s)}catch(o){throw await e.close().catch(()=>{}),bz(e),o}if(bz(e),await super.connect(e),n.era==="legacy"){await this._legacyHandshake(e,r);return}if(this._serverCapabilities=n.discover.capabilities,this._serverVersion=vz(n.discover),this._cache.setServerIdentity(this._deriveServerIdentity(e)),this._instructions=n.discover.instructions,this._discoverResult=n.discover,this._negotiatedProtocolVersion=n.version,e.setProtocolVersion&&e.setProtocolVersion(n.version),this._listChangedConfig){let o=this._listChangedConfig,s=this._serverCapabilities,i={...o.tools&&s?.tools?.listChanged&&{tools:o.tools},...o.prompts&&s?.prompts?.listChanged&&{prompts:o.prompts},...o.resources&&s?.resources?.listChanged&&{resources:o.resources}},a=!0;try{this._setupListChangedHandlers(i)}catch(u){a=!1,this.onerror?.(u instanceof Error?u:new Error(String(u)))}let c=a?{...i.tools&&{toolsListChanged:!0},...i.prompts&&{promptsListChanged:!0},...i.resources&&{resourcesListChanged:!0}}:{};if(Object.keys(c).length>0){let u=new AbortController,d=()=>u.abort(r?.signal?.reason);r?.signal?.aborted&&d(),r?.signal?.addEventListener("abort",d);try{this._autoOpenedSubscription=await this.listen(c,{timeout:r?.timeout,signal:u.signal})}catch(p){if(r?.signal?.aborted)throw await this.close().catch(()=>{}),p;this.onerror?.(p instanceof Error?p:new Error(String(p)))}finally{r?.signal?.removeEventListener("abort",d)}}}}async _connectFromPrior(e,t,r){if(t.kind==="legacy")return this._connectPlainLegacy(e,r);let n=t.discover;this._resetConnectionState();let o=this._supportedProtocolVersionsOption,s=(o&&Pc(o).length>0?Pc(o):qS).find(i=>n.supportedVersions.includes(i));if(s===void 0)throw new L(D.EraNegotiationFailed,"connect({ prior }) with a modern verdict requires a 2026-07-28+ mutual protocol version; the supplied DiscoverResult and this client's supportedProtocolVersions have no modern overlap. For a server known to be legacy, pass prior: { kind: 'legacy' } to skip the probe and initialize directly, or use versionNegotiation: { mode: 'auto' } to re-probe with legacy fallback.");if(await super.connect(e),this._discoverResult=n,this._serverCapabilities=n.capabilities,this._serverVersion=vz(n),this._cache.setServerIdentity(this._deriveServerIdentity(e)),this._instructions=n.instructions,this._negotiatedProtocolVersion=s,e.setProtocolVersion?.(s),this._listChangedConfig)try{this._setupListChangedHandlers(this._listChangedConfig)}catch(i){this.onerror?.(i instanceof Error?i:new Error(String(i)))}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}_deriveServerIdentity(e){let t=this._serverVersion;return t!==void 0?`${t.name}@${t.version}`:e.sessionId??`anonymous:${Date.now()}-${Math.random().toString(36).slice(2)}`}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}getProtocolEra(){let e=this._negotiatedProtocolVersion;if(e!==void 0)return hr(e)?"modern":"legacy"}getInstructions(){return this._instructions}getDiscoverResult(){return this._discoverResult}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new L(D.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new L(D.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new L(D.CapabilityNotSupported,`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new L(D.CapabilityNotSupported,`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new L(D.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new L(D.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"initialize":break;case"server/discover":break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new L(D.CapabilityNotSupported,`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new L(D.CapabilityNotSupported,`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new L(D.CapabilityNotSupported,`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new L(D.CapabilityNotSupported,`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},e)}async discover(e){let t=await this._requestWithSchema({method:"server/discover"},Lr,e);return this._discoverResult=t,t}async complete(e,t){return this.request({method:"completion/complete",params:e},t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},t)}async listPrompts(e,t){if(!this._serverCapabilities?.prompts&&!this._enforceStrictCapabilities)return console.debug("Client.listPrompts() called but server does not advertise prompts capability - returning empty list"),{prompts:[]};if(e?.cursor!==void 0)return this.request({method:"prompts/list",params:e},t);let r=await this._serveFromCache("prompts/list",void 0,t);return r!==void 0?r:this._listAllPages("prompts/list",e,t,n=>n.prompts)}async listResources(e,t){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug("Client.listResources() called but server does not advertise resources capability - returning empty list"),{resources:[]};if(e?.cursor!==void 0)return this.request({method:"resources/list",params:e},t);let r=await this._serveFromCache("resources/list",void 0,t);return r!==void 0?r:this._listAllPages("resources/list",e,t,n=>n.resources)}async listResourceTemplates(e,t){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug("Client.listResourceTemplates() called but server does not advertise resources capability - returning empty list"),{resourceTemplates:[]};if(e?.cursor!==void 0)return this.request({method:"resources/templates/list",params:e},t);let r=await this._serveFromCache("resources/templates/list",void 0,t);return r!==void 0?r:this._listAllPages("resources/templates/list",e,t,n=>n.resourceTemplates)}async _listAllPages(e,t,r,n,o){let s=r?.cacheMode==="bypass",i=this._cache.captureGeneration(e),a=u=>{let d=u===void 0?t&&{...t}:{...t,cursor:u};return this.request({method:e,...d&&{params:d}},r)},c=await this._walkPages(e,a,n);return delete c.nextCursor,o?.(c),s||await this._cache.write(e,c,i,this._freshness(c)),c}async _walkPages(e,t,r){let n=await t(void 0),o=n.nextCursor,s=n,i=1;for(;o!==void 0;){if(this._listMaxPages!==0&&i>=this._listMaxPages)throw new L(D.ListPaginationExceeded,`${e}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`,{method:e,listMaxPages:this._listMaxPages});let a=await t(o);if(a.nextCursor===o&&JSON.stringify(r(a))===JSON.stringify(r(s)))break;r(n).push(...r(a)),s=a,o=a.nextCursor,i++}return n}_freshness(e,t){let r=e,n=typeof r.ttlMs=="number"?r.ttlMs:this._defaultCacheTtlMs,o=r.cacheScope==="public"?"public":"private";return{expiresAt:this._cache.now()+Math.min(Math.max(0,n),$z),scope:o,params:t}}async _serveFromCache(e,t,r){if(r?.cacheMode==="bypass"||r?.cacheMode==="refresh")return;let n=await this._cache.read(e,t).catch(o=>{this._reportStoreError(o)});if(n!==void 0){if(r?.signal?.aborted){let o=r.signal.reason;throw o instanceof L?o:new L(D.RequestTimeout,String(o))}return n.value}}_reportStoreError(e){this.onerror?.(e instanceof Error?e:new Error(String(e)))}_compileOutputValidator(e){if(e.outputSchema)try{return{ok:!0,validator:this._jsonSchemaValidator.getValidator(e.outputSchema)}}catch(t){return{ok:!1,compileError:t}}}async _resolveXMcpHeaderScan(e,t){let r=t??await this._cache.toolDefinition(e);return r===void 0?void 0:HS(r.inputSchema)}async readResource(e,t){let{result:r}=await this._readResource(e,t);return r}async _readResource(e,t){let r=await this._serveFromCache("resources/read",e.uri,t);if(r!==void 0)return{result:r,cached:!0};let n=this._cache.captureGeneration("resources/read",e.uri),o=await this.request({method:"resources/read",params:e},t);if(t?.cacheMode!=="bypass"){let s=this._freshness(o,e.uri);s.expiresAt>this._cache.now()?await this._cache.write("resources/read",o,n,s):t?.cacheMode==="refresh"&&await this._cache.evictKey("resources/read",e.uri)}return{result:o,cached:!1}}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},t)}async listen(e,t){if(this.transport===void 0)throw new L(D.NotConnected,"Not connected");let r=this._negotiatedProtocolVersion;if(r===void 0||!hr(r))throw new L(D.MethodNotSupportedByProtocolVersion,`subscriptions/listen requires a 2026-07-28-era connection (negotiated: ${r??"none"}). On a 2025-era connection, change notifications are delivered unsolicited: use ClientOptions.listChanged and resources/subscribe instead.`,{method:"subscriptions/listen",protocolVersion:r});if(t?.signal?.aborted){let k=t.signal.reason;throw k instanceof L?k:new L(D.RequestTimeout,String(k))}let n=new AbortController,o=`listen:${this._nextListenId++}`,s="opening",i,a,c,u,d=new Promise((k,J)=>{c=k,u=J}),p,h=new Promise(k=>{p=k}),f=k=>{if(s==="closed")return;let J=s==="opening";if(i!==void 0&&(clearTimeout(i),i=void 0),"ack"in k){s="open",c(k.ack);return}s="closed",a!==void 0&&t?.signal?.removeEventListener("abort",a),this._listenState.delete(o),n.abort(),p(k.cause),J&&u(k.error??new L(D.ConnectionClosed,"subscriptions/listen closed before the server acknowledged"))},S=async()=>{n.abort(),await this.notification({method:"notifications/cancelled",params:{requestId:o}}).catch(()=>{})},_=async()=>{s!=="closed"&&(f({cause:"local"}),await S())};this._listenState.set(o,{settle:f});let w=t?.timeout??Oc;if(i=setTimeout(()=>{f({cause:"remote",error:new L(D.RequestTimeout,"subscriptions/listen ack timed out",{timeout:w})}),S().catch(()=>{})},w),t?.signal){let k=t.signal;a=()=>{if(s==="closed")return;let J=k.reason;f({cause:"local",error:J instanceof Error?J:new Error(String(J??"Aborted"))}),S().catch(()=>{})},k.addEventListener("abort",a,{once:!0})}let x={jsonrpc:"2.0",id:o,method:"subscriptions/listen",params:{_meta:{...this._outboundMetaEnvelope()},notifications:e}},R=k=>{f({cause:"remote",error:k instanceof Error?k:new Error(String(k))})};try{this.transport.send(x,{requestSignal:n.signal,onRequestStreamEnd:()=>f({cause:"remote",error:new Error("subscriptions/listen: stream ended")})}).catch(R)}catch(k){R(k)}return{honoredFilter:await d,close:_,closed:h}}get autoOpenedSubscription(){return this._autoOpenedSubscription}_onnotification(e,t){let r=Object.hasOwn(wz,e.method)?wz[e.method]:void 0;if(e.method==="notifications/resources/updated"){let n=e.params?.uri;typeof n=="string"&&this._cache.evictKey("resources/read",n)}else if(r!==void 0)for(let n of r)this._cache.evict(n);if(e.method==="notifications/subscriptions/acknowledged"){let n=e.params?._meta?.[No],o=typeof n=="string"?this._listenState.get(n):void 0;if(o!==void 0){let s=this._wireCodec().validateNotification("notifications/subscriptions/acknowledged",e);o.settle({ack:s.ok?s.value.params.notifications:{}});return}}if(e.method==="notifications/cancelled"){let n=e.params?.requestId,o=typeof n=="string"?this._listenState.get(n):void 0;if(o!==void 0){o.settle({cause:"remote",error:new Error("subscriptions/listen: server cancelled the subscription")});return}}super._onnotification(e,t)}_onresponse(e){let t=e.id,r=typeof t=="string"?this._listenState.get(t):void 0;if(r!==void 0){Ic(e)?r.settle({cause:"remote",error:ae.fromError(e.error.code,e.error.message,e.error.data)}):r.settle({cause:"graceful",error:new L(D.ConnectionClosed,"subscriptions/listen: server closed the subscription gracefully before acknowledging")});return}super._onresponse(e)}_onclose(){if(this._listenState.size>0){let e=new L(D.ConnectionClosed,"Connection closed");for(let t of this._listenState.values())t.settle({cause:"remote",error:e});this._listenState.clear()}super._onclose()}async callTool(e,t){let r=this.getProtocolEra()==="modern"&&Sz()!=="browser",n=async()=>{if(!r)return t;let c;try{c=await this._resolveXMcpHeaderScan(e.name,t?.toolDefinition)}catch(d){this._reportStoreError(d)}if(!c?.valid||c.declarations.length===0)return t;let u=iz(c.declarations,e.arguments);return Object.keys(u).length===0?t:{...t,headers:{...t?.headers,...u}}},o=t?.toolDefinition===void 0?await this._cache.outputValidator(e.name,c=>this._compileOutputValidator(c)).catch(c=>{this._reportStoreError(c)}):this._compileOutputValidator(t.toolDefinition),s=()=>{if(o===void 0||o.ok)return;let c=o.compileError,u=(c instanceof Error?c.message:String(c)).slice(0,200);throw new ae(W.InvalidParams,`Tool '${e.name}' has an invalid outputSchema: ${u}`)};s();let i;try{i=await this.request({method:"tools/call",params:e},await n())}catch(c){let u=c instanceof ae&&c.code===cs;if(!r||!u||t?.toolDefinition!==void 0)throw c;let d={signal:t?.signal,timeout:t?.timeout,cacheMode:"refresh"};await this._cache.evict("tools/list"),await this.listTools(void 0,d).catch(p=>this._reportStoreError(p)),o=await this._cache.outputValidator(e.name,p=>this._compileOutputValidator(p)).catch(p=>{this._reportStoreError(p)}),s(),i=await this.request({method:"tools/call",params:e},await n())}let a=o!==void 0&&o.ok?o.validator:void 0;if(a){if(i.structuredContent===void 0&&!i.isError)throw new ae(W.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(i.structuredContent!==void 0&&!i.isError)try{let c=a(i.structuredContent);if(!c.valid)throw new ae(W.InvalidParams,`Structured content does not match the tool's output schema: ${c.errorMessage}`)}catch(c){throw c instanceof ae?c:new ae(W.InvalidParams,`Failed to validate structured content: ${c instanceof Error?c.message:String(c)}`)}}return i}async listTools(e,t){if(!this._serverCapabilities?.tools&&!this._enforceStrictCapabilities)return console.debug("Client.listTools() called but server does not advertise tools capability - returning empty list"),{tools:[]};if(e?.cursor!==void 0){let n=await this.request({method:"tools/list",params:e},t);return this._excludeInvalidXMcpHeaderTools(n),n}let r=await this._serveFromCache("tools/list",void 0,t);return r!==void 0?r:this._listAllPages("tools/list",e,t,n=>n.tools,n=>this._excludeInvalidXMcpHeaderTools(n))}_excludeInvalidXMcpHeaderTools(e){if(this.getProtocolEra()!=="modern"||!this.transport||_z(this.transport)==="stdio")return;let t=e.tools.filter(r=>{let n=HS(r.inputSchema);return n.valid?!0:(console.warn(`[mcp-sdk] excluding tool '${r.name}' from tools/list: invalid x-mcp-header declaration \u2014 ${n.reason}`),!1)});t.length!==e.tools.length&&(e.tools=t)}_setupListChangedHandler(e,t,r,n){let o=Fd(Ma,r);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if(typeof r.onChanged!="function")throw new TypeError(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:s,debounceMs:i}=o.data,{onChanged:a}=r,c=async()=>{if(!s){a(null,null);return}try{a(null,await n())}catch(d){a(d instanceof Error?d:new Error(String(d)),null)}},u=()=>{if(i){let d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);let p=setTimeout(c,i);this._listChangedDebounceTimers.set(e,p)}else c()};this.setNotificationHandler(t,u)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var lM=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return rt(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rt(this,e)}constructor(e,t,r){super(`SSE error: ${t}`),this.code=e,this.event=r,Ur(this,new.target)}};var e_=class{_eventSlots=new Map;setHandler(t,r){let n=this._ensureEventSlot(t);n.onHandler&&r&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", \u2026) to add multiple listeners without replacing.`),n.onHandler=r}getHandler(t){return this._eventSlots.get(t)?.onHandler}addEventListener(t,r){this._ensureEventSlot(t).listeners.push(r)}removeEventListener(t,r){let n=this._eventSlots.get(t);if(!n)return;let o=n.listeners.indexOf(r);o!==-1&&n.listeners.splice(o,1)}dispatch(t,r){let n=this._eventSlots.get(t);if(n){n.onHandler?.(r);for(let o of[...n.listeners])o(r)}}_ensureEventSlot(t){let r=this._eventSlots.get(t);return r||(r={listeners:[]},this._eventSlots.set(t,r)),r}},t_=class{_methods=new Set;claim(t,r){if(this._methods.has(t))throw Error(`Handler for "${t}" already registered (via ${r}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(t)}replace(t){this._methods.add(t)}release(t){this._methods.delete(t)}has(t){return this._methods.has(t)}},Cz=new Set;function Iz(e,t){let[r,n]=t,o=r?.shape;if(typeof o?.method?.value!="string")return;let s=o.method.value,i=e==="request"?"setRequestHandler":"setNotificationHandler";Cz.has(i)||(Cz.add(i),console.warn(`[ext-apps] ${i}(Schema, handler) is deprecated; use ${i}("${s}", { params: Schema.shape.params }, handler).`));let a=n;return[s,{params:o.params},e==="request"?(c,u)=>a({method:s,params:c},BP(u)):c=>a({method:s,params:c})]}function BP(e){return{signal:e.mcpReq.signal,requestId:e.mcpReq.id,sessionId:e.sessionId,_meta:e.mcpReq._meta,sendRequest:e.mcpReq.send,sendNotification:e.mcpReq.notify,authInfo:e.http?.authInfo}}var JP="2026-01-26";var KP="ui/notifications/tool-input-partial";var r_=class{eventTarget;eventSource;messageListener;constructor(t=window.parent,r){this.eventTarget=t,this.eventSource=r,this.messageListener=n=>{if(r&&n.source!==this.eventSource){console.debug("Ignoring message from unknown source",n);return}let o=zn.safeParse(n.data);o.success?(console.debug("Parsed message",o.data),this.onmessage?.(o.data)):n.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",o.error.message,n):(console.error("Failed to parse message",o.error.message,n),this.onerror?.(Error("Invalid JSON-RPC message received: "+o.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,r){t.method!==KP&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion},WP=m.union([m.literal("light"),m.literal("dark")]).describe("Color theme preference for the host environment."),Mc=m.union([m.literal("inline"),m.literal("fullscreen"),m.literal("pip")]).describe("Display mode for UI presentation."),GP=m.union([m.literal("--color-background-primary"),m.literal("--color-background-secondary"),m.literal("--color-background-tertiary"),m.literal("--color-background-inverse"),m.literal("--color-background-ghost"),m.literal("--color-background-info"),m.literal("--color-background-danger"),m.literal("--color-background-success"),m.literal("--color-background-warning"),m.literal("--color-background-disabled"),m.literal("--color-text-primary"),m.literal("--color-text-secondary"),m.literal("--color-text-tertiary"),m.literal("--color-text-inverse"),m.literal("--color-text-ghost"),m.literal("--color-text-info"),m.literal("--color-text-danger"),m.literal("--color-text-success"),m.literal("--color-text-warning"),m.literal("--color-text-disabled"),m.literal("--color-border-primary"),m.literal("--color-border-secondary"),m.literal("--color-border-tertiary"),m.literal("--color-border-inverse"),m.literal("--color-border-ghost"),m.literal("--color-border-info"),m.literal("--color-border-danger"),m.literal("--color-border-success"),m.literal("--color-border-warning"),m.literal("--color-border-disabled"),m.literal("--color-ring-primary"),m.literal("--color-ring-secondary"),m.literal("--color-ring-inverse"),m.literal("--color-ring-info"),m.literal("--color-ring-danger"),m.literal("--color-ring-success"),m.literal("--color-ring-warning"),m.literal("--font-sans"),m.literal("--font-mono"),m.literal("--font-weight-normal"),m.literal("--font-weight-medium"),m.literal("--font-weight-semibold"),m.literal("--font-weight-bold"),m.literal("--font-text-xs-size"),m.literal("--font-text-sm-size"),m.literal("--font-text-md-size"),m.literal("--font-text-lg-size"),m.literal("--font-heading-xs-size"),m.literal("--font-heading-sm-size"),m.literal("--font-heading-md-size"),m.literal("--font-heading-lg-size"),m.literal("--font-heading-xl-size"),m.literal("--font-heading-2xl-size"),m.literal("--font-heading-3xl-size"),m.literal("--font-text-xs-line-height"),m.literal("--font-text-sm-line-height"),m.literal("--font-text-md-line-height"),m.literal("--font-text-lg-line-height"),m.literal("--font-heading-xs-line-height"),m.literal("--font-heading-sm-line-height"),m.literal("--font-heading-md-line-height"),m.literal("--font-heading-lg-line-height"),m.literal("--font-heading-xl-line-height"),m.literal("--font-heading-2xl-line-height"),m.literal("--font-heading-3xl-line-height"),m.literal("--border-radius-xs"),m.literal("--border-radius-sm"),m.literal("--border-radius-md"),m.literal("--border-radius-lg"),m.literal("--border-radius-xl"),m.literal("--border-radius-full"),m.literal("--border-width-regular"),m.literal("--shadow-hairline"),m.literal("--shadow-sm"),m.literal("--shadow-md"),m.literal("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),YP=m.record(GP.describe(`Style variables for theming MCP apps.
302
+
303
+ Individual style keys are optional - hosts may provide any subset of these values.
304
+ Values are strings containing CSS values (colors, sizes, font stacks, etc.).
305
+
306
+ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
307
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),m.union([m.string(),m.undefined()]).describe(`Style variables for theming MCP apps.
308
+
309
+ Individual style keys are optional - hosts may provide any subset of these values.
310
+ Values are strings containing CSS values (colors, sizes, font stacks, etc.).
311
+
312
+ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
313
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
314
+
315
+ Individual style keys are optional - hosts may provide any subset of these values.
316
+ Values are strings containing CSS values (colors, sizes, font stacks, etc.).
317
+
318
+ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
319
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),vM=m.object({method:m.literal("ui/open-link"),params:m.object({url:m.string().describe("URL to open in the host's browser")})}),QP=m.object({isError:m.boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),XP=m.object({isError:m.boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),eC=m.object({isError:m.boolean().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough(),wM=m.object({method:m.literal("ui/notifications/sandbox-proxy-ready"),params:m.object({})}),n_=m.object({connectDomains:m.array(m.string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
320
+
321
+ - Maps to CSP \`connect-src\` directive
322
+ - Empty or omitted \u2192 no network connections (secure default)`),resourceDomains:m.array(m.string()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted \u2192 no network resources (secure default)"),frameDomains:m.array(m.string()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted \u2192 no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:m.array(m.string()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted \u2192 only same origin allowed (`base-uri 'self'`)")}),o_=m.object({camera:m.object({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:m.object({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:m.object({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:m.object({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),zM=m.object({method:m.literal("ui/notifications/size-changed"),params:m.object({width:m.number().optional().describe("New width in pixels."),height:m.number().optional().describe("New height in pixels.")})}),tC=m.object({method:m.literal("ui/notifications/tool-input"),params:m.object({arguments:m.record(m.string(),m.unknown().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),rC=m.object({method:m.literal("ui/notifications/tool-input-partial"),params:m.object({arguments:m.record(m.string(),m.unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),nC=m.object({method:m.literal("ui/notifications/tool-cancelled"),params:m.object({reason:m.string().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),oC=m.object({fonts:m.string().optional()}),sC=m.object({variables:YP.optional().describe("CSS variables for theming the app."),css:oC.optional().describe("CSS blocks that apps can inject.")}),iC=m.object({method:m.literal("ui/resource-teardown"),params:m.object({})}),aC=m.record(m.string(),m.unknown()),Oz=m.object({text:m.object({}).optional().describe("Host supports text content blocks."),image:m.object({}).optional().describe("Host supports image content blocks."),audio:m.object({}).optional().describe("Host supports audio content blocks."),resource:m.object({}).optional().describe("Host supports resource content blocks."),resourceLink:m.object({}).optional().describe("Host supports resource link content blocks."),structuredContent:m.object({}).optional().describe("Host supports structured content.")}),RM=m.object({method:m.literal("ui/notifications/request-teardown"),params:m.object({}).optional()}),cC=m.object({experimental:m.record(m.string(),m.record(m.string(),m.any()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:m.object({}).optional().describe("Host supports opening external URLs."),downloadFile:m.object({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:m.object({listChanged:m.boolean().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:m.object({listChanged:m.boolean().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:m.object({}).optional().describe("Host accepts log messages."),sandbox:m.object({permissions:o_.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:n_.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Oz.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Oz.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:m.object({tools:m.object({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),uC=m.object({experimental:m.record(m.string(),m.record(m.string(),m.any()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:m.object({listChanged:m.boolean().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:m.array(Mc).optional().describe("Display modes the app supports.")}),$M=m.object({method:m.literal("ui/notifications/initialized"),params:m.object({}).optional()}),kM=m.object({csp:n_.optional().describe("Content Security Policy configuration for UI resources."),permissions:o_.optional().describe("Sandbox permissions requested by the UI resource."),domain:m.string().optional().describe(`Dedicated origin for view sandbox.
323
+
324
+ Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
325
+
326
+ **Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:
327
+ - Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
328
+ - URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
329
+
330
+ If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:m.boolean().optional().describe(`Visual boundary preference - true if view prefers a visible border.
331
+
332
+ Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
333
+
334
+ - \`true\`: request visible border + background
335
+ - \`false\`: request no visible border + background
336
+ - omitted: host decides border`)}),xM=m.object({method:m.literal("ui/request-display-mode"),params:m.object({mode:Mc.describe("The display mode being requested.")})}),lC=m.object({mode:Mc.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),dC=m.union([m.literal("model"),m.literal("app")]).describe("Tool visibility scope - who can access the tool."),TM=m.object({resourceUri:m.string().optional(),visibility:m.array(dC).optional().describe(`Who can access this tool. Default: ["model", "app"]
337
+ - "model": Tool visible to and callable by the agent
338
+ - "app": Tool callable by the app from this server only`),csp:m.never().optional(),permissions:m.never().optional()}),EM=m.object({mimeTypes:m.array(m.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),PM=m.object({method:m.literal("ui/download-file"),params:m.object({contents:m.array(m.union([Tn,En])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),CM=m.object({method:m.literal("ui/message"),params:m.object({role:m.literal("user").describe('Message role, currently only "user" is supported.'),content:m.array(Kt).describe("Message content blocks (text, image, etc.).")})}),IM=m.object({method:m.literal("ui/notifications/sandbox-resource-ready"),params:m.object({html:m.string().describe("HTML content to load into the inner iframe."),sandbox:m.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:n_.optional().describe("CSP configuration from resource metadata."),permissions:o_.optional().describe("Sandbox permissions from resource metadata.")})}),pC=m.object({method:m.literal("ui/notifications/tool-result"),params:jr.describe("Standard MCP tool execution result.")}),Mz=m.object({toolInfo:m.object({id:kt.optional().describe("JSON-RPC id of the tools/call request."),tool:qr.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:WP.optional().describe("Current color theme preference."),styles:sC.optional().describe("Style configuration for theming the app."),displayMode:Mc.optional().describe("How the UI is currently displayed."),availableDisplayModes:m.array(Mc).optional().describe("Display modes the host supports."),containerDimensions:m.union([m.object({height:m.number().describe("Fixed container height in pixels.")}),m.object({maxHeight:m.union([m.number(),m.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(m.union([m.object({width:m.number().describe("Fixed container width in pixels.")}),m.object({maxWidth:m.union([m.number(),m.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
339
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:m.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:m.string().optional().describe("User's timezone in IANA format."),userAgent:m.string().optional().describe("Host application identifier."),platform:m.union([m.literal("web"),m.literal("desktop"),m.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:m.object({touch:m.boolean().optional().describe("Whether the device supports touch input."),hover:m.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:m.object({top:m.number().describe("Top safe area inset in pixels."),right:m.number().describe("Right safe area inset in pixels."),bottom:m.number().describe("Bottom safe area inset in pixels."),left:m.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),mC=m.object({method:m.literal("ui/notifications/host-context-changed"),params:Mz.describe("Partial context update containing only changed fields.")}),OM=m.object({method:m.literal("ui/update-model-context"),params:m.object({content:m.array(Kt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:m.record(m.string(),m.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),NM=m.object({method:m.literal("ui/initialize"),params:m.object({appInfo:Bt.describe("App identification (name and version)."),appCapabilities:uC.describe("Features and capabilities this app provides."),protocolVersion:m.string().describe("Protocol version this app supports.")})}),hC=m.object({protocolVersion:m.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Bt.describe("Host application identification and version."),hostCapabilities:cC.describe("Features and capabilities provided by the host."),hostContext:Mz.describe("Rich context about the host environment.")}).passthrough(),fC={target:"draft-2020-12"};async function Nz(e,t){let r=e["~standard"];if(r.jsonSchema)return r.jsonSchema[t](fC);throw Error(`Schema (vendor: ${r.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Az(e,t,r=""){let n=await e["~standard"].validate(t);if(n.issues){let o=n.issues.map(s=>{let i=s.path?.map(a=>typeof a=="object"?a.key:a).join(".");return i?`${i}: ${s.message}`:s.message}).join("; ");throw Error(r+o)}return n.value}function Lz(e){let t=document.documentElement;t.setAttribute("data-theme",e),t.style.colorScheme=e}function qz(e,t=document.documentElement){for(let[r,n]of Object.entries(e))n!==void 0&&t.style.setProperty(r,n)}function jz(e){if(document.getElementById("__mcp-host-fonts"))return;let t=document.createElement("style");t.id="__mcp-host-fonts",t.textContent=e,document.head.appendChild(t)}function gC(e,t){let r={...e,...t};return t.experimental!==void 0&&(r.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(r.tools={...e.tools,...t.tools}),r}var Kd=class e extends Nc{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new e_;_methods=new t_;setRequestHandler=(...t)=>{let[r,...n]=Iz("request",t)??t;this._methods.claim(r,"setRequestHandler"),super.setRequestHandler.call(this,r,...n)};setNotificationHandler=(...t)=>{let[r,...n]=Iz("notification",t)??t;this._methods.claim(r,"setNotificationHandler"),super.setNotificationHandler.call(this,r,...n)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...r)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...r)};_assertInitialized(t){if(this._initializedSent)return;let r=`[ext-apps] App.${t}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(r);console.warn(`${r}. This will throw in a future release.`)}eventSchemas={toolinput:tC,toolinputpartial:rC,toolresult:pC,toolcancelled:nC,hostcontextchanged:mC};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let r=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(r);console.warn(r)}setEventHandler(t,r){r&&this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.setHandler(t,r)}addEventListener(t,r){this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.addEventListener(t,r)}removeEventListener(t,r){this._events.removeEventListener(t,r)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let r=this.eventSchemas[t];if(!r)throw Error(`Unknown event: ${String(t)}`);this.setNotificationHandler(r.shape.method.value,{params:r.shape.params},n=>{let o=n;t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...o}),this._events.dispatch(t,o)}),this._registeredEvents.add(t)}getEventHandler(t){return this._events.getHandler(t)}warnIfRequestHandlerReplaced(t,r,n){r&&n&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,r={},n={autoResize:!0}){super(n),this._appInfo=t,this._appCapabilities=r,this.options=n,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!n.allowUnsafeEval&&m.config({jitless:!0}),this.replaceRequestHandler("ping",o=>(console.log("Received ping:",o.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(t){return t}registerAppCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=gC(this._appCapabilities,t)}registerTool(t,r,n){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let o=this,s=()=>{o._initializedSent&&o._appCapabilities.tools?.listChanged&&o.sendToolListChanged()},i=r.inputSchema!==void 0,a={title:r.title,description:r.description,inputSchema:r.inputSchema,outputSchema:r.outputSchema,annotations:r.annotations,_meta:r._meta,enabled:!0,enable(){this.enabled=!0,s()},disable(){this.enabled=!1,s()},update(c){Object.assign(this,c),s()},remove(){o._registeredTools[t]===a&&(delete o._registeredTools[t],s())},handler:async(c,u)=>{if(!a.enabled)throw Error(`Tool ${t} is disabled`);let d;if(i){let p=a.inputSchema,h=p?await Az(p,c??{},`Invalid input for tool ${t}: `):c??{};d=await n(h,u)}else d=await n(u);return a.outputSchema&&!d.isError&&(d.structuredContent=await Az(a.outputSchema,d.structuredContent,`Invalid output for tool ${t}: `)),d}};return this._registeredTools[t]=a,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),s(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,r)=>{let n=this._registeredTools[t.name];if(!n)throw Error(`Tool ${t.name} not found`);return n.handler(t.arguments,r)},this.onlisttools=async(t,r)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([n,o])=>o.enabled).map(async([n,o])=>{let s={name:n,title:o.title,description:o.description,inputSchema:o.inputSchema?await Nz(o.inputSchema,"input"):{type:"object",properties:{}}};return o.outputSchema&&(s.outputSchema=await Nz(o.outputSchema,"output")),o.annotations&&(s.annotations=o.annotations),o._meta&&(s._meta=o._meta),s}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler("ui/resource-teardown",{params:iC.shape.params,result:aC},(r,n)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(r,n)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",(r,n)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(r.params,n)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler("tools/list",(r,n)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(r.params,n)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;default:return}}assertNotificationCapability(t){}async callServerTool(t,r){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},{onprogress:()=>{},resetTimeoutOnProgress:!0,...r})}async readServerResource(t,r){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},r)}async listServerResources(t,r){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},r)}async createSamplingMessage(t,r){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:t},r)}sendMessage(t,r){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},eC,r)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,r){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},Mr,r)}openLink(t,r){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},QP,r)}sendOpenLink=this.openLink;downloadFile(t,r){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},XP,r)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,r){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},lC,r)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,r=0,n=0,o=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let i=document.documentElement,a=i.style.height;i.style.height="max-content";let c=Math.ceil(i.getBoundingClientRect().height);i.style.height=a;let u=Math.ceil(window.innerWidth);(u!==r||c!==n)&&(r=u,n=c,this.sendSizeChanged({width:u,height:c}))}))};o();let s=new ResizeObserver(o);return s.observe(document.documentElement),s.observe(document.body),()=>s.disconnect()}async connect(t=new r_(window.parent,window.parent),r){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(t);let n=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:JP}},hC,r);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(n){throw this.close(),n}}};var Z={objects:new Map};var F=e=>document.getElementById(e),re=e=>e.replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t]),ds=e=>{let t=Math.max(0,Math.round((Date.now()-Date.parse(e))/1e3));return t<60?`${t} s ago`:t<3600?`${Math.round(t/60)} min ago`:`${Math.round(t/3600)} h ago`};function Dz(e,t){let r=F(e);r.addEventListener("click",n=>{let o=n.target.closest("button");if(o?.dataset.t){for(let s of r.querySelectorAll("button"))s.setAttribute("aria-pressed",String(s===o));t(o.dataset.t)}})}function Lc(e,t){try{let r=localStorage.getItem(e);return r?JSON.parse(r):t}catch{return t}}function Gt(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function qc(e,t){let r=e?e.split(`
340
+ `):[],n=t?t.split(`
341
+ `):[];if(r.length*n.length>4e6)return[...r.map(d=>({op:"-",text:d})),...n.map(d=>({op:"+",text:d}))];let o=r.length,s=n.length,i=Array.from({length:o+1},()=>new Uint32Array(s+1));for(let d=o-1;d>=0;d--)for(let p=s-1;p>=0;p--)i[d][p]=r[d]===n[p]?i[d+1][p+1]+1:Math.max(i[d+1][p],i[d][p+1]);let a=[],c=0,u=0;for(;c<o&&u<s;)r[c]===n[u]?(a.push({op:" ",text:r[c]}),c++,u++):i[c+1][u]>=i[c][u+1]?a.push({op:"-",text:r[c++]}):a.push({op:"+",text:n[u++]});for(;c<o;)a.push({op:"-",text:r[c++]});for(;u<s;)a.push({op:"+",text:n[u++]});return a}var Uz=e=>({plus:e.filter(t=>t.op==="+").length,minus:e.filter(t=>t.op==="-").length});var SC=new Set("PROGRAM END_PROGRAM FUNCTION_BLOCK END_FUNCTION_BLOCK FUNCTION END_FUNCTION METHOD END_METHOD PROPERTY END_PROPERTY INTERFACE END_INTERFACE ACTION END_ACTION TYPE END_TYPE STRUCT END_STRUCT UNION END_UNION VAR VAR_INPUT VAR_OUTPUT VAR_IN_OUT VAR_GLOBAL VAR_TEMP VAR_STAT VAR_INST VAR_EXTERNAL VAR_CONFIG END_VAR CONSTANT RETAIN PERSISTENT AT IF THEN ELSIF ELSE END_IF CASE OF END_CASE FOR TO BY DO END_FOR WHILE END_WHILE REPEAT UNTIL END_REPEAT EXIT CONTINUE RETURN AND OR XOR NOT MOD EXTENDS IMPLEMENTS THIS SUPER PUBLIC PRIVATE PROTECTED INTERNAL ABSTRACT FINAL REF_TO REFERENCE POINTER ARRAY TRUE FALSE NAMESPACE END_NAMESPACE".split(" ")),_C=new Set("BOOL BYTE WORD DWORD LWORD SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL TIME LTIME DATE TIME_OF_DAY TOD DATE_AND_TIME DT STRING WSTRING ANY TON TOF TP R_TRIG F_TRIG CTU CTD CTUD SR RS".split(" "));function Nn(e,t){let r="",n=0;for(;n<e.length;){if(t.inComment){let i=e.indexOf("*)",n),a=i<0?e.length:i+2;r+=`<span class="cm">${re(e.slice(n,a))}</span>`,n=a,i>=0&&(t.inComment=!1);continue}let o=e.slice(n),s;if(o.startsWith("//")){r+=`<span class="cm">${re(o)}</span>`;break}if(o.startsWith("(*")){t.inComment=!0,r+='<span class="cm">(*</span>',n+=2;continue}if(s=/^'(?:\$.|[^'])*'?|^"(?:\$.|[^"])*"?/.exec(o)){r+=`<span class="st">${re(s[0])}</span>`,n+=s[0].length;continue}if((s=/^(?:[A-Za-z_]+#)?\d[\w.#]*/.exec(o))&&!/[A-Za-z_]/.test(e[n-1]??"")){r+=`<span class="nu">${re(s[0])}</span>`,n+=s[0].length;continue}if(s=/^[A-Za-z_][A-Za-z0-9_]*/.exec(o)){let i=s[0],a=i.toUpperCase(),c=e[n-1];c!=="."&&SC.has(a)?r+=`<span class="kw">${re(i)}</span>`:c!=="."&&(_C.has(a)||/^(STRING|WSTRING)$/.test(a))?r+=`<span class="ty">${re(i)}</span>`:r+=re(i),n+=i.length;continue}r+=re(e[n]),n++}return r}var i_=[["code","Code"],["review","Review"]],bC=2e4,Zr={pinned:void 0,expanded:new Set};function s_(){return Z.ws?.changeCount??0}function Vz(){return s_()>0&&(Z.state?.phase?.quietMs??1/0)>bC?"review":"code"}function a_(e){return!e&&Zr.pinned?Zr.pinned:Vz()}function yC(e){return`CODESYS simulation: ${e.state==="run"?"running":"stopped"}${e.forced.length?` \xB7 ${e.forced.length} forced`:""}`}function Wd(){let e=Z.state,t=e?.codesysSim;return t?{cls:`pill ${t.state==="run"?"running":"paused"}`,text:yC(t)}:{cls:"pill",text:e?Z.ws?.project?"Project open":"No project":"Connecting"}}function Gd(e,t){let r=Vz(),n=o=>o==="review"&&s_()?`<span class="vc">${s_()}</span>`:o==="code"&&Z.ws?.compile?.errors?`<span class="vc bad">${Z.ws.compile.errors}</span>`:"";return i_.map(([o,s])=>`<button data-view="${o}" aria-pressed="${o===e}"${t&&o===r?' class="auto" title="Claude is working here"':""}>${s}${n(o)}</button>`).join("")}function jc(){let e=Z.ws?.focus;return e&&e.action!=="delete"&&e.action!=="read"?e.path:Z.ws?.tree?.find(t=>t.change)?.path??(e&&e.action!=="delete"?e.path:void 0)}function Fz(e,t){if(!Z.ws?.tree)return`<div class="empty">Open a project: Claude's code shows up here as it is written.</div>`;if(!e)return'<div class="empty">Waiting for Claude to write code. Each object it creates or changes shows here.</div>';let r=Z.ws.focus,n=r?.path===e?{write:"is writing",create:"created",revert:"reverted",rename:"renamed"}[r.action]??"":"",o=`<div class="vhead"><b>${re(e)}</b>${n?`<span class="muted">Claude ${n} it${r?` \xB7 ${ds(r.at)}`:""}</span>`:""}${vC()}</div>`;if(!t)return`${o}<div class="empty">Loading\u2026</div>`;let s=t.object;if(!s)return`${o}<div class="empty">${re(e)} was removed.</div>`;if(s.st===!1)return`${o}<div class="empty">${re(e)} has a graphical body (SFC, CFC, LD or FBD), which isn't shown as text.</div>`;let i=[o,'<div class="code live">'];for(let a of["decl","impl"]){let c=a==="decl"?s.declaration:s.implementation;if(c===null||a==="impl"&&!c.trim()&&s.kind!=="pou"&&s.kind!=="method"&&s.kind!=="accessor")continue;i.push(`<div class="part">${a==="decl"?"Declaration":"Implementation"}</div>`);let u=c.replace(/\r\n?/g,`
342
+ `).replace(/\n+$/,""),d=t.base?((a==="decl"?t.base.declaration:t.base.implementation)??"").replace(/\r\n?/g,`
343
+ `).replace(/\n+$/,""):"",p={inComment:!1},h=0;for(let f of qc(d,u))f.op!=="-"&&(h++,i.push(`<div class="ln${f.op==="+"?" add":""}"><span class="no">${h}</span><span class="tx">${Nn(f.text,p)||" "}</span></div>`))}return i.push("</div>"),i.join("")}function vC(){let e=Z.ws?.compile;return e?`<span class="cl ${e.errors?"bad":"good"}">${e.errors?`${e.errors} compile error${e.errors>1?"s":""}`:"Compiles"}${e.warnings?`, ${e.warnings} warning${e.warnings>1?"s":""}`:""}</span>`:""}function Hz(e){let t=(Z.ws?.compile?.messages??[]).filter(r=>r.severity!=="info"&&(!e||(r.object??"").toLowerCase().includes(e.toLowerCase().split("/")[0])));return t.length?`<ul class="problems">${t.slice(0,6).map(r=>`<li><span class="${r.severity==="error"?"err":"wrn"}">${r.severity==="error"?"Error":"Warning"}</span> ${re(r.text)}${r.position?` <span class="muted">${re(r.position)}</span>`:""}</li>`).join("")}</ul>`:""}function c_(){let e=Z.ws?.tree??[],t=(s,i)=>s.toLowerCase().startsWith(i.toLowerCase()+"/"),r=e.filter(s=>s.change),n=r.filter(s=>!r.some(i=>t(s.path,i.path))),o=Z.ws?.removed??[];return[...n.map(s=>({path:s.path,mark:s.change,members:[s.path,...r.filter(i=>t(i.path,s.path)).map(i=>i.path)]})),...o.filter(s=>!o.some(i=>t(s,i))).map(s=>({path:s,mark:"D",members:[]}))]}var Zz=e=>(e??"").replace(/\r\n?/g,`
344
+ `).replace(/\n+$/,"");function Bz(e){if(!e.object)return[];let t=[];for(let[r,n,o]of[["Declaration",e.object.declaration,e.base?.declaration],["Implementation",e.object.implementation,e.base?.implementation]])n===null&&!o||t.push({part:r,ops:qc(Zz(o),Zz(n))});return t}function wC(e){let t=0,r=0;for(let n of e){let o=Z.objects.get(n.toLowerCase());if(!o)return;for(let{ops:s}of Bz(o)){let i=Uz(s);t+=i.plus,r+=i.minus}}return{plus:t,minus:r}}function zC(e,t=2){let r=new Set;e.forEach((a,c)=>{if(a.op!==" ")for(let u=-t;u<=t;u++)r.add(c+u)});let n={inComment:!1},o=[],s=0,i=-2;return e.forEach((a,c)=>{if(a.op!=="-"&&s++,!r.has(c)){Nn(a.text,n);return}c!==i+1&&o.length&&o.push('<div class="ln gap"><span class="no"></span><span class="tx">\u22EF</span></div>');let u=a.op==="+"?" add":a.op==="-"?" del":"";o.push(`<div class="ln${u}"><span class="sg">${a.op===" "?"":a.op==="-"?"\u2212":"+"}</span><span class="no">${a.op==="-"?"":s}</span><span class="tx">${Nn(a.text,n)||" "}</span></div>`),i=c}),o.join("")}function RC(e){let t=[];for(let r of e){let n=Z.objects.get(r.toLowerCase());if(!n){t.push(`<div class="muted rd-load">Loading ${re(r)}\u2026</div>`);continue}let o=Bz(n).filter(({ops:s})=>s.some(i=>i.op!==" "));if(o.length){e.length>1&&t.push(`<div class="rd-obj">${re(r)}${n.base?"":' <span class="muted">added</span>'}</div>`);for(let{part:s,ops:i}of o)t.push(`<div class="part">${s}</div>${zC(i)}`)}}return`<div class="code live rdiff">${t.join("")||'<div class="empty">No line changes.</div>'}</div>`}function Yd(e=!1){let t=c_();if(!t.length)return'<div class="empty">Nothing to review: every change Claude made is accepted.</div>';let r=n=>{let o=n.mark==="A"?"added":n.mark==="D"?"removed":"changed",s=n.mark==="D"?void 0:wC(n.members),i=s?` <span class="good">+${s.plus}</span> <span class="bad">\u2212${s.minus}</span>`:"",a=e&&n.mark!=="D"&&Zr.expanded.has(n.path.toLowerCase());return`<li data-path="${re(n.path)}"${a?' class="open"':""}><span class="mk ${n.mark}">${n.mark}</span><span class="rp"><b>${re(n.path)}</b><span class="muted">${o}${i}</span></span>`+(n.mark==="D"?"":`<button class="btn" data-rv="diff" aria-pressed="${a}">${a?"Hide":"Changes"}</button>`)+'<button class="btn good" data-rv="accept">Accept</button><button class="btn danger" data-rv="revert">Revert</button>'+(a?`<div class="rd">${RC(n.members)}<button class="lnk" data-rv="full">Open in full screen</button></div>`:"")+"</li>"};return`<div class="vhead"><b>${t.length} to review</b><span class="muted">since you last accepted</span></div><ul class="review-list">${t.map(r).join("")}</ul>`}var u_,Jz="",Kz="";function Wz(e,t){let r=Z.state,n=Z.ws,o=Wd();F("c-status").className=o.cls,F("c-statusText").textContent=o.text,F("c-meta").textContent=n?.project?.split(/[\\/]/).pop()??"",F("c-meta").title=n?.versions??"",F("c-activity").textContent=r?.held?"You're driving: Claude is paused.":"",F("c-hold").setAttribute("aria-pressed",String(!!r?.held)),F("c-hold").textContent=r?.held?"Resume Claude":"Pause Claude",F("c-follow").setAttribute("aria-pressed",String(t));let s=[],i=n?.focus;i&&s.push(`<span class="fact"><span class="muted">Working on</span><b>${re(i.path)}</b><span class="muted">${i.action} \xB7 ${ds(i.at)}</span></span>`),n?.changeCount!==void 0&&n.tree&&s.push(`<span class="fact"><span class="muted">Changes</span><b>${n.changeCount}</b><span class="muted">to review</span></span>`),F("c-facts").innerHTML=s.join(""),F("c-views").innerHTML=Gd(e,t);let a=F("c-view"),c="";if(e==="code"){let u=jc();c=Fz(u,u?Z.objects.get(u.toLowerCase()):void 0)+Hz(u)}else c=Yd(!0);if(u_!==e||c!==Jz){let u=a.querySelector(".code.live")?.scrollTop??0;a.innerHTML=c,Jz=c;let d=a.querySelector(".code.live");if(d){let p=d.querySelectorAll(".ln.add"),h=`${jc()}|${p.length}|${p[p.length-1]?.textContent??""}`;p.length&&(h!==Kz||u_!==e)?d.scrollTop=Math.max(0,p[p.length-1].offsetTop-d.clientHeight/2):d.scrollTop=u,Kz=h}}u_=e}var Gz={program:"PRG",function_block:"FB",function:"FN",method:"M",interface_method:"M",property:"P",accessor:"\xB7",action:"A",gvl:"GVL",dut:"DUT",interface:"I",task_config:"TSK",task:"T",task_call:"\xB7",library_manager:"LIB",folder:""};function $C(e){let t=new Map;for(let r of Z.ws?.compile?.messages??[]){if((r.object??"").toLowerCase()!==e.toLowerCase())continue;let n=/Line (\d+)(?:, Column (\d+))?\s*\((Impl|Decl)\)/i.exec(r.position??"");if(!n)continue;let o=`${n[3].toLowerCase()==="decl"?"decl":"impl"}:${n[1]}`;t.get(o)?.severity==="error"&&r.severity!=="error"||t.set(o,{severity:r.severity,text:`${r.severity==="error"?"Error":"Warning"}${r.code?` ${r.code}`:""}${n[2]?` (column ${n[2]})`:""}: ${r.text}`})}return t}var Qd=class{constructor(t){this.hooks=t;let r=()=>{t.act("ui_hold",{on:!Z.state?.held},Z.state?.held?"resumed Claude":"paused Claude")};F("w-hold").addEventListener("click",r),F("w-held").addEventListener("click",n=>{n.target.closest("[data-resume]")&&r()}),F("w-filter").addEventListener("input",n=>{this.filter=n.target.value.trim().toLowerCase(),this.renderTree()}),F("w-follow").addEventListener("click",()=>{this.follow=!this.follow,Gt("ws-follow",this.follow),t.followChanged()}),F("w-views").addEventListener("click",n=>{let o=n.target.closest("[data-view]")?.dataset.view;o&&t.pickView(o)}),F("w-diff").addEventListener("click",()=>{this.diff=!this.diff,F("w-diff").setAttribute("aria-pressed",String(this.diff)),this.renderEditor(!0)}),Dz("w-bottom-tabs",n=>{this.bottom=n,this.renderBottom()}),F("w-tree").addEventListener("click",n=>this.onTreeClick(n)),F("w-tabs").addEventListener("click",n=>this.onTabClick(n)),F("w-editor").addEventListener("click",n=>this.onEditorClick(n)),F("w-bottom").addEventListener("click",n=>{let o=n.target,s=o.closest("[data-rv]");if(s){let a=s.closest("[data-path]").dataset.path;return s.dataset.rv==="diff"?(this.diff=!0,F("w-diff").setAttribute("aria-pressed","true"),this.open(a,!0)):this.hooks.review(s.dataset.rv,a,s)}let i=o.closest("[data-open]")?.dataset.open;i&&this.open(i,!0)})}hooks;tabs=Lc("ws-tabs",[]);active=Lc("ws-active",void 0);follow=Lc("ws-follow",!0);diff=!1;bottom="problems";filter="";collapsed=new Set(Lc("ws-collapsed",[]));selected;lastFocusAt;editorHtml="";view="code";open(t,r){let o=Z.ws?.tree?.find(i=>i.path.toLowerCase()===t.toLowerCase())?.path??t;this.tabs.some(i=>i.toLowerCase()===o.toLowerCase())||(this.tabs=[...this.tabs,o].slice(-8)),this.active=o,Gt("ws-tabs",this.tabs),Gt("ws-active",this.active);let s=o.split("/");for(let i=1;i<s.length;i++)this.collapsed.delete(s.slice(0,i).join("/").toLowerCase());this.hooks.needObject(o),r&&this.hooks.context(`The user opened ${o} in the CODESYS workspace panel.`),this.render()}close(t){this.tabs=this.tabs.filter(r=>r!==t),this.active===t&&(this.active=this.tabs.at(-1)),Gt("ws-tabs",this.tabs),Gt("ws-active",this.active),this.render()}autoFollow(){if(!this.follow)return;let t=Z.ws?.focus;t&&t.at!==this.lastFocusAt&&t.action!=="delete"&&(this.lastFocusAt=t.at,Z.ws?.tree?.some(r=>r.path.toLowerCase()===t.path.toLowerCase())&&this.open(t.path,!1))}applyView(t){this.view=t;let r=t==="review"?"review":"problems";this.bottom=r;for(let n of F("w-bottom-tabs").querySelectorAll("button"))n.setAttribute("aria-pressed",String(n.dataset.t===r));if(this.diff=t==="review",F("w-diff").setAttribute("aria-pressed",String(this.diff)),t==="review"){let n=Z.ws?.tree?.find(o=>o.change)?.path;n&&this.open(n,!1)}this.render()}render(){this.renderTop(),this.renderTree(),this.renderTabs(),this.renderEditor(),this.renderBottom()}renderTop(){let t=Z.state,r=Wd();F("w-status").className=r.cls,F("w-statusText").textContent=r.text,F("w-meta").textContent=[Z.ws?.project?.split(/[\\/]/).pop(),Z.ws?.versions].filter(Boolean).join(" \xB7 "),F("w-meta").title=Z.ws?.versions??"";let n=Z.ws?.focus;F("w-activity").textContent=n&&Date.now()-Date.parse(n.at)<6e4?`Claude ${n.action==="read"?"is reading":n.action==="write"?"edited":n.action==="create"?"created":n.action==="delete"?"deleted":n.action==="revert"?"reverted":"renamed"} ${n.path}`:"",F("w-follow").setAttribute("aria-pressed",String(this.follow)),F("w-views").innerHTML=Gd(this.view,this.follow);let o=!!t?.held;F("w-hold").setAttribute("aria-pressed",String(o)),F("w-hold").querySelector("span").textContent=o?"Claude paused":"Pause Claude",F("w-held").classList.toggle("hidden",!o)}visibleNodes(){let t=Z.ws?.tree??[];if(this.filter){let r=new Set;for(let n of t){if(!n.name.toLowerCase().includes(this.filter))continue;let o=n.path.split("/");for(let s=1;s<=o.length;s++)r.add(o.slice(0,s).join("/").toLowerCase())}return t.filter(n=>r.has(n.path.toLowerCase()))}return t.filter(r=>{let n=r.path.split("/");for(let o=1;o<n.length;o++)if(this.collapsed.has(n.slice(0,o).join("/").toLowerCase()))return!1;return!0})}renderTree(){let t=F("w-tree"),r=Z.ws?.tree;if(!r){t.innerHTML=`<div class="empty">${Z.ws?.project===null||!Z.ws?"Open a CODESYS project to see its tree.":"Loading the project\u2026"}</div>`;return}let n=Z.ws?.focus,o=n&&Date.now()-Date.parse(n.at)<3e4?n.path.toLowerCase():void 0,s=new Set;r.forEach((c,u)=>{(r[u+1]?.depth??-1)>c.depth&&s.add(c.path.toLowerCase())});let i=this.visibleNodes().map(c=>{let u=c.path.toLowerCase(),d=c.kind==="pou"?c.sub??"pou":c.kind,p=Gz[d]??Gz[c.kind]??"\xB7",h=s.has(u),f=!this.collapsed.has(u)||!!this.filter,S=[];o===u&&S.push('<span class="mk claude" title="Claude worked here">\u2726</span>'),c.errors&&S.push(`<span class="mk err" title="${c.errors} compile error(s)">${c.errors}</span>`),c.change&&S.push(`<span class="mk ${c.change}" title="${c.change==="A"?"Added":"Modified"} since you last reviewed it">${c.change}</span>`);let _=c.st===!1||["task_config","task","task_call","library_manager","device","other"].includes(c.kind),w=c.kind==="folder"?'<svg width="14" height="12" viewBox="0 0 16 13" fill="none" stroke="currentColor" stroke-width="1.4"><path d="M1.5 2.5h4l1.5 1.5h7.5v7.5h-13z"/></svg>':p;return`<div class="tn${this.active?.toLowerCase()===u?" sel":""}${_?" dim":""}" data-path="${re(c.path)}" style="padding-left:${6+c.depth*14}px" title="${re(c.path)}${c.st===!1?" (graphical, not ST)":""}">
345
+ <span class="tw" data-toggle="${h?re(c.path):""}">${h?f?"\u25BE":"\u25B8":""}</span><span class="ic k-${d}">${w}</span><span class="nm">${re(c.name)}</span><span class="marks">${S.join("")}</span></div>`}),a=Z.ws?.removed??[];t.innerHTML=i.join("")+(a.length?`<div class="removed">Removed since session start: ${a.map(re).join(", ")}</div>`:"")}renderTabs(){F("w-tabs").innerHTML=this.tabs.map(t=>{let r=Z.ws?.tree?.find(n=>n.path===t);return`<span class="tab${t===this.active?" active":""}" data-tab="${re(t)}" title="${re(t)}">${re(t.split("/").slice(-2).join("/"))}${r?.change?` <span class="mk ${r.change}">${r.change}</span>`:""}<button class="x" data-close="${re(t)}" aria-label="Close ${re(t)}">\xD7</button></span>`}).join("")}renderEditor(t=!1){let r=F("w-editor");if(!this.active){this.setEditor(r,'<div class="empty">Select an object in the tree.</div>',t);return}let n=Z.objects.get(this.active.toLowerCase());if(!n){this.setEditor(r,`<div class="empty">Loading ${re(this.active)}\u2026</div>`,t);return}this.setEditor(r,this.editorBody(this.active,n),t)}setEditor(t,r,n){if(!n&&r===this.editorHtml)return;let o=!n&&this.editorHtml!==""&&t.dataset.path===this.active,s=t.scrollTop;this.editorHtml=r,t.innerHTML=r,t.dataset.path=this.active??"",o&&(t.scrollTop=s)}editorBody(t,r){let n=r.object;if(!n)return`<div class="empty">${re(t)} was removed${r.base?" since you last reviewed it":""}.</div>`;if(n.st===!1)return`<div class="empty">${re(t)} has a graphical body (SFC, CFC, LD or FBD), which isn't shown as text.</div>`;let o=[];for(let i of["decl","impl"]){let a=i==="decl"?n.declaration:n.implementation;if(a===null||i==="impl"&&!a.trim()&&n.kind!=="pou"&&n.kind!=="method"&&n.kind!=="action"&&n.kind!=="accessor")continue;o.push(`<div class="part">${i==="decl"?"Declaration":"Implementation"}</div>`);let c=(a??"").replace(/\r\n?/g,`
346
+ `).replace(/\n+$/,"").split(`
347
+ `),u={inComment:!1},d=$C(t);if(this.diff&&r.base){let p=(i==="decl"?r.base.declaration:r.base.implementation)??"",h=qc(p.replace(/\r\n?/g,`
348
+ `).replace(/\n+$/,""),c.join(`
349
+ `)),f=0;for(let S of h){S.op!=="-"&&f++;let _=S.op==="+"?" add":S.op==="-"?" del":"";o.push(`<div class="ln${_}"><span class="sg">${S.op===" "?"":S.op}</span><span class="no">${S.op==="-"?"":f}</span><span class="tx">${Nn(S.text,u)||" "}</span></div>`)}h.every(S=>S.op===" ")&&o.push('<div class="empty">No changes since you last reviewed it.</div>');continue}c.forEach((p,h)=>{let f=h+1,S=this.selected?.path===t&&this.selected.part===i&&this.selected.line===f,_=d.get(`${i}:${f}`);o.push(`<div class="ln ${i}${S?" sel":""}${_?` ${_.severity==="error"?"has-err":"has-wrn"}`:""}" data-part="${i}" data-line="${f}"${_?` title="${re(_.text)}"`:""}><span class="sg"></span><span class="no">${f}</span><span class="tx">${Nn(p,u)||" "}</span></div>`)})}this.diff&&!r.base&&o.unshift(`<div class="empty">${re(t)} was added since you last reviewed it.</div>`);let s=Z.ws?.tree?.find(i=>i.path.toLowerCase()===t.toLowerCase());return s?.change&&o.unshift(`<div class="review"><span class="mk ${s.change}">${s.change}</span><span>${s.change==="A"?"Added":"Changed"} since you last reviewed it.</span><button class="btn" data-review="diff">${this.diff?"Hide changes":"Show changes"}</button><button class="btn good" data-review="accept" title="Mark the current text as reviewed">Accept</button><button class="btn danger" data-review="revert" title="Put the reviewed text back in CODESYS">Revert</button></div>`),o.join("")}async review(t,r){let n=this.active;if(t==="diff")return this.diff=!this.diff,F("w-diff").setAttribute("aria-pressed",String(this.diff)),this.renderEditor(!0);if(t==="accept"){await this.hooks.act("ui_accept_object",{path:n},`accepted Claude's changes to ${n} after reviewing them`);return}if(r.dataset.confirm!=="1"){r.dataset.confirm="1",r.textContent="Click again to revert in CODESYS",setTimeout(()=>{r.dataset.confirm="",r.textContent="Revert"},4e3);return}await this.hooks.act("ui_revert_object",{path:n},`reverted ${n} in CODESYS to the reviewed version`)}renderBottom(){let t=F("w-bottom"),r=F("w-bottom-info");if(r.textContent="",this.bottom==="review"){let s=Yd();t.dataset.html!==s&&(t.innerHTML=`<div class="vpad">${s}</div>`,t.dataset.html=s);return}delete t.dataset.html;let n=Z.ws?.compile,o=[];if(n){r.textContent=`compile ${ds(n.at)}: ${n.errors} error(s), ${n.warnings} warning(s)`;for(let s of n.messages){let i=s.object?.replace(/^\/+/,"");o.push(`<div class="row"><span class="${s.severity==="error"?"err":"wrn"}">${s.severity==="error"?"Error":"Warning"}${s.code?` ${re(s.code)}`:""}</span> ${i?`<a href="#" data-open="${re(i)}">${re(i)}</a>${s.position?` <span class="muted">${re(s.position)}</span>`:""}: `:""}${re(s.text)}</div>`)}}t.innerHTML=o.length?`<div class="list">${o.join("")}</div>`:`<div class="empty">${n?"No problems in the last compile.":"No compile yet in this session."}</div>`}onTreeClick(t){let r=t.target,n=r.closest("[data-toggle]")?.dataset.toggle,o=r.closest(".tn");if(!o)return;let s=o.dataset.path,i=Z.ws?.tree?.find(a=>a.path===s);if(n||i?.kind==="folder"){let a=s.toLowerCase();if(this.collapsed.has(a)?this.collapsed.delete(a):this.collapsed.add(a),Gt("ws-collapsed",[...this.collapsed]),this.renderTree(),n)return}i&&i.kind!=="folder"&&this.open(s,!0)}onTabClick(t){let r=t.target,n=r.closest("[data-close]")?.dataset.close;if(n)return this.close(n);let o=r.closest("[data-tab]")?.dataset.tab;o&&this.open(o,!0)}onEditorClick(t){let r=t.target,n=r.closest("[data-review]")?.dataset.review;if(n&&this.active)return void this.review(n,r.closest("button"));let o=r.closest(".ln[data-line]");if(!o||!this.active)return;let s=o.dataset.part,i=Number(o.dataset.line);this.selected={path:this.active,part:s,line:i};let a=o.querySelector(".tx")?.textContent??"";this.hooks.context(`In the CODESYS workspace the user selected ${this.active} ${s==="decl"?"declaration":"implementation"} line ${i}: ${a.trim()}`),this.renderEditor(!0)}};var Yt=new Kd({name:"codesys-workspace",version:"1.0.0"}),l_,Xz=!1,bt="card",tp=!1,rp,d_=!0;Yt.ontoolresult=e=>{let t=e.structuredContent?.panelId;t&&(l_=t)};function eR(e){e&&(e.theme&&Lz(e.theme),e.styles?.variables&&qz(e.styles.variables),e.styles?.css?.fonts&&jz(e.styles.css.fonts))}function np(){let t=Yt.getHostContext()?.displayMode==="fullscreen";bt=t||tp?"workspace":"card",document.body.classList.toggle("inline-expanded",!t&&tp),F("card").classList.toggle("hidden",bt!=="card"),F("ws").classList.toggle("hidden",bt!=="workspace"),bt==="workspace"&&d_&&rp&&(d_=!1,Be.applyView(rp)),An()}Yt.onhostcontextchanged=e=>{eR({...Yt.getHostContext(),...e}),np()};async function p_(e){if(Yt.getHostContext()?.availableDisplayModes?.includes("fullscreen"))try{let n=await Yt.requestDisplayMode({mode:e?"fullscreen":"inline"});if(tp=!1,n.mode==="fullscreen"===e)return np()}catch{}tp=e,np(),m_(e?"The user opened the CODESYS workspace.":"The user went back to the compact panel.")}F("c-open").addEventListener("click",()=>{p_(!0)});F("w-close").addEventListener("click",()=>{p_(!1)});var Yz,tR="",Dc=[];function rR(){clearTimeout(Yz),Yz=setTimeout(()=>{let e=[tR,Dc.length?`Recent actions by the user in the CODESYS panel (oldest first):
350
+ ${Dc.map(t=>`- ${t}`).join(`
351
+ `)}`:""].filter(Boolean);e.length&&Yt.updateModelContext({content:[{type:"text",text:e.join(`
352
+ `)}]}).catch(()=>{})},400)}function m_(e){tR=e,rR()}function Qz(e,t=!1){let r=document.createElement("div");r.className=`toast${t?" err":""}`,r.textContent=e,F("toasts").append(r),setTimeout(()=>r.remove(),t?7e3:4e3)}async function op(e,t,r){let n=await sp(e,t);if(!n){Qz("No answer from the server.",!0);return}return Qz(n.message.split(`
353
+ `)[0],!n.ok),n.ok&&(Dc.push(`${new Date().toLocaleTimeString()}: ${r}. Result: ${n.message.split(`
354
+ `)[0]}`),Dc.length>8&&Dc.shift(),rR()),h_(),n}var kC=e=>i_.find(([t])=>t===e)[1];function nR(e){Be.follow=!1,Gt("ws-follow",!1),Zr.pinned=e,An(),m_(`The user switched the CODESYS panel to the ${kC(e)} view.`),h_()}function oR(){Be.follow&&(Zr.pinned=void 0),An(),h_()}function sR(e,t,r){if(e==="diff"&&bt==="card"){let n=t.toLowerCase();Zr.expanded.delete(n)||Zr.expanded.add(n),An();return}if(e==="diff"||e==="full"){p_(!0).then(()=>{Be.diff=!0,Be.open(t,!0)});return}if(e==="accept"){op("ui_accept_object",{path:t},`accepted Claude's changes to ${t} after reviewing them`);return}if(r.dataset.confirm!=="1"){r.dataset.confirm="1",r.textContent="Click again to revert",setTimeout(()=>{r.dataset.confirm="",r.textContent="Revert"},4e3);return}op("ui_revert_object",{path:t},`reverted ${t} in CODESYS to the reviewed version`)}var Be=new Qd({needObject:e=>{Xd(e)},context:m_,act:op,pickView:nR,followChanged:oR,review:sR});F("c-views").addEventListener("click",e=>{let t=e.target.closest("[data-view]")?.dataset.view;t&&nR(t)});F("c-follow").addEventListener("click",()=>{Be.follow=!Be.follow,Gt("ws-follow",Be.follow),oR()});F("c-view").addEventListener("click",e=>{let t=e.target.closest("[data-rv]");t&&sR(t.dataset.rv,t.closest("[data-path]").dataset.path,t)});F("c-hold").addEventListener("click",()=>{op("ui_hold",{on:!Z.state?.held},Z.state?.held?"resumed Claude":"paused Claude")});async function sp(e,t={}){try{let r=await Yt.callServerTool({name:e,arguments:t});if(r.isError)return;if(r.structuredContent)return r.structuredContent;let n=r.content?.find(o=>o.type==="text");return n?.text?JSON.parse(n.text):void 0}catch{return}}async function Xd(e){let t=await sp("get_object",{path:e});t&&(Z.objects.set(e.toLowerCase(),{...t,version:Z.ws?.version??0}),An())}var Uc,ep=!1;function h_(){ep||(clearTimeout(Uc),Uc=setTimeout(f_,50))}async function f_(){if(!(Xz||ep)){ep=!0;try{await xC()}finally{ep=!1}clearTimeout(Uc),Uc=setTimeout(f_,1e3)}}async function xC(){let e=await sp("get_sim_state",l_?{panelId:l_}:{});if(e){if(!e.current){Xz=!0,clearTimeout(Uc),document.body.classList.add("superseded");return}Z.state=e}let t=await sp("get_workspace",Z.ws?.tree?{version:Z.ws.version}:{});if(t&&!t.unchanged){let n=Z.ws?.version!==t.version;if(Z.ws=t,n&&bt==="workspace")for(let o of Be.tabs){let s=Z.objects.get(o.toLowerCase());(!s||s.version!==t.version)&&await Xd(o)}}let r=a_(Be.follow);if(r==="code"&&bt==="card"){let n=jc(),o=n?Z.objects.get(n.toLowerCase()):void 0;n&&(!o||o.version!==Z.ws?.version)&&await Xd(n)}if(r==="review"&&bt==="card"){let n=c_().flatMap(o=>o.mark==="D"?[]:o.members).filter(o=>Z.objects.get(o.toLowerCase())?.version!==Z.ws?.version).slice(0,20);for(let o of n)await Xd(o)}bt==="workspace"&&Be.autoFollow(),An()}function An(){let e=a_(Be.follow);e!==rp&&(rp=e,bt==="workspace"?Be.applyView(e):d_=!0,bt==="workspace")||(bt==="card"?Wz(e,Be.follow):Be.render())}window.addEventListener("resize",()=>An());Yt.connect().then(()=>{eR(Yt.getHostContext()),np(),f_()}).catch(e=>{F("card").classList.remove("hidden"),F("c-statusText").textContent="Not connected",F("c-activity").textContent=e.message});})();
355
+ </script>
356
+ </body>
357
+ </html>