okengine 0.2.6 → 0.2.8

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 (584) hide show
  1. package/AGENTS.md +24 -23
  2. package/README.md +52 -346
  3. package/docs/spec/console.md +165 -142
  4. package/docs/spec/example.md +490 -312
  5. package/docs/spec/four-applications.md +495 -314
  6. package/docs/spec/unified-theory.md +184 -175
  7. package/package.json +45 -37
  8. package/spec/manifest.v1.schema.json +40 -9
  9. package/src/auth/api-keys.ts +2 -5
  10. package/src/auth/attenuation.ts +2 -6
  11. package/src/auth/auth.test.ts +53 -31
  12. package/src/auth/invoke-as.ts +1 -3
  13. package/src/auth/operator.ts +8 -26
  14. package/src/auth/planes.ts +2 -7
  15. package/src/auth/plugin.ts +4 -7
  16. package/src/auth/roles.ts +1 -5
  17. package/src/auth/sessions.ts +10 -39
  18. package/src/cli/args.ts +1 -5
  19. package/src/cli/ask-dev-mode.ts +40 -0
  20. package/src/cli/build.ts +1 -2
  21. package/src/cli/client-add.test.ts +8 -15
  22. package/src/cli/client-add.ts +5 -14
  23. package/src/cli/completion.test.ts +1 -5
  24. package/src/cli/completion.ts +4 -17
  25. package/src/cli/db-auto-push.test.ts +64 -0
  26. package/src/cli/db-auto-push.ts +72 -0
  27. package/src/cli/db.test.ts +189 -0
  28. package/src/cli/db.ts +386 -0
  29. package/src/cli/dev-app-runner.ts +2 -8
  30. package/src/cli/dev-db-push.test.ts +163 -0
  31. package/src/cli/dev-mode.test.ts +45 -0
  32. package/src/cli/dev-mode.ts +78 -0
  33. package/src/cli/dev.test.ts +148 -21
  34. package/src/cli/dev.ts +208 -134
  35. package/src/cli/doc-drift.test.ts +3 -2
  36. package/src/cli/doc-drift.ts +21 -50
  37. package/src/cli/doc-staleness.test.ts +69 -0
  38. package/src/cli/docker-cli.test.ts +7 -8
  39. package/src/cli/docker.ts +1 -3
  40. package/src/cli/doctor-diff-examples.ts +1 -3
  41. package/src/cli/doctor-diff.test.ts +1 -5
  42. package/src/cli/doctor-diff.ts +17 -46
  43. package/src/cli/doctor-pii.ts +2 -7
  44. package/src/cli/doctor.test.ts +26 -4
  45. package/src/cli/doctor.ts +35 -11
  46. package/src/cli/eval.ts +4 -14
  47. package/src/cli/gates-list.ts +1 -4
  48. package/src/cli/hero-meta.test.ts +17 -19
  49. package/src/cli/hero-meta.ts +20 -30
  50. package/src/cli/images.ts +3 -8
  51. package/src/cli/index.ts +11 -2
  52. package/src/cli/load-config.images.test.ts +14 -14
  53. package/src/cli/load-config.ts +41 -47
  54. package/src/cli/mcp-from-console.ts +1 -4
  55. package/src/cli/mode.ts +45 -0
  56. package/src/cli/ports.test.ts +4 -13
  57. package/src/cli/ports.ts +1 -3
  58. package/src/cli/privacy-erase.ts +1 -3
  59. package/src/cli/registry.ts +75 -25
  60. package/src/cli/schema.ts +3 -10
  61. package/src/cli/stack.ts +2 -7
  62. package/src/cli/start.ts +4 -15
  63. package/src/cli/upgrade.ts +1 -4
  64. package/src/client/budget-entry.ts +1 -6
  65. package/src/client/create.test.ts +6 -12
  66. package/src/client/create.ts +2 -8
  67. package/src/client/errors.ts +1 -4
  68. package/src/client/index.ts +1 -6
  69. package/src/client/notes-contract.test.ts +4 -13
  70. package/src/client/transport.ts +9 -30
  71. package/src/client/types.ts +8 -29
  72. package/src/compiler/aot.test.ts +2 -9
  73. package/src/compiler/aot.ts +1 -4
  74. package/src/compiler/differential.test.ts +3 -11
  75. package/src/compiler/dynamic.ts +1 -4
  76. package/src/compiler/effects-infer.ts +8 -34
  77. package/src/compiler/emit.ts +1 -3
  78. package/src/compiler/extract.test.ts +96 -30
  79. package/src/compiler/extract.ts +362 -156
  80. package/src/compiler/fixtures/skyport/oke.config.ts +1 -1
  81. package/src/compiler/fixtures/skyport/src/flows/bookings/index.ts +7 -3
  82. package/src/compiler/fixtures/skyport/src/flows/payments/index.ts +1 -3
  83. package/src/compiler/fixtures/skyport/src/flows/support/index.ts +4 -1
  84. package/src/compiler/fixtures/skyport.expected.json +24 -83
  85. package/src/compiler/fixtures/triggers/five-triggers.ts +1 -2
  86. package/src/compiler/http-parse.ts +2 -9
  87. package/src/compiler/index.ts +1 -5
  88. package/src/compiler/response.ts +4 -7
  89. package/src/compiler/sucrose.ts +11 -31
  90. package/src/config/define-config.test.ts +57 -34
  91. package/src/config/index.ts +181 -37
  92. package/src/config/resolve-driver.test.ts +28 -17
  93. package/src/console/budget.test.ts +1 -4
  94. package/src/console/index.ts +1 -4
  95. package/src/console/server/access.test.ts +15 -43
  96. package/src/console/server/access.ts +19 -49
  97. package/src/console/server/ai.test.ts +3 -11
  98. package/src/console/server/ai.ts +23 -46
  99. package/src/console/server/app.ts +14 -45
  100. package/src/console/server/auth-rate.test.ts +4 -12
  101. package/src/console/server/bind.ts +1 -5
  102. package/src/console/server/channels.test.ts +2 -6
  103. package/src/console/server/channels.ts +10 -35
  104. package/src/console/server/claim.ts +2 -8
  105. package/src/console/server/clock.test.ts +2 -6
  106. package/src/console/server/clock.ts +8 -26
  107. package/src/console/server/console.test.ts +1 -3
  108. package/src/console/server/diff.test.ts +5 -17
  109. package/src/console/server/diff.ts +10 -31
  110. package/src/console/server/dry-run.audit.test.ts +2 -8
  111. package/src/console/server/flows.ts +64 -233
  112. package/src/console/server/gates.test.ts +14 -50
  113. package/src/console/server/gates.ts +13 -48
  114. package/src/console/server/index.ts +2 -9
  115. package/src/console/server/live.ts +3 -12
  116. package/src/console/server/operator-db.test.ts +4 -15
  117. package/src/console/server/operator-db.ts +13 -32
  118. package/src/console/server/plugin.ts +50 -53
  119. package/src/console/server/plugins.test.ts +2 -6
  120. package/src/console/server/plugins.ts +17 -56
  121. package/src/console/server/runs-pii.ts +2 -7
  122. package/src/console/server/security.gate.test.ts +18 -40
  123. package/src/console/server/serve.ts +10 -25
  124. package/src/console/server/signals.test.ts +1 -3
  125. package/src/console/server/signals.ts +17 -40
  126. package/src/console/server/state.ts +21 -59
  127. package/src/console/server/store.test.ts +20 -22
  128. package/src/console/server/store.ts +31 -76
  129. package/src/console/server/vault.test.ts +12 -29
  130. package/src/console/server/vault.ts +23 -60
  131. package/src/console/ui/access/AccessA11yView.tsx +6 -21
  132. package/src/console/ui/access/a11y.test.tsx +3 -12
  133. package/src/console/ui/access/acknowledgement.test.ts +1 -4
  134. package/src/console/ui/access/acknowledgement.ts +1 -3
  135. package/src/console/ui/access/blast-radius.ts +1 -3
  136. package/src/console/ui/access/confirmation.test.ts +1 -5
  137. package/src/console/ui/access/confirmation.ts +1 -4
  138. package/src/console/ui/access/fixture.ts +1 -5
  139. package/src/console/ui/access/grantable.test.ts +1 -3
  140. package/src/console/ui/access/grantable.ts +2 -7
  141. package/src/console/ui/access/index.ts +2 -9
  142. package/src/console/ui/access/provenance.test.ts +1 -3
  143. package/src/console/ui/access/provenance.ts +2 -6
  144. package/src/console/ui/access/search.test.ts +1 -5
  145. package/src/console/ui/access/search.ts +2 -6
  146. package/src/console/ui/ai/AiA11yView.tsx +6 -17
  147. package/src/console/ui/ai/a11y.test.tsx +2 -5
  148. package/src/console/ui/ai/fixture.ts +2 -7
  149. package/src/console/ui/ai/format.ts +1 -3
  150. package/src/console/ui/ai/group.test.ts +1 -3
  151. package/src/console/ui/ai/group.ts +4 -12
  152. package/src/console/ui/ai/index.ts +2 -9
  153. package/src/console/ui/ai/promotion.test.ts +2 -7
  154. package/src/console/ui/ai/promotion.ts +4 -13
  155. package/src/console/ui/ai/search.test.ts +2 -11
  156. package/src/console/ui/ai/search.ts +3 -13
  157. package/src/console/ui/ai/types.ts +1 -8
  158. package/src/console/ui/architecture/ArchitectureA11yView.tsx +8 -29
  159. package/src/console/ui/architecture/a11y.test.tsx +1 -2
  160. package/src/console/ui/architecture/declared.ts +1 -5
  161. package/src/console/ui/architecture/index.ts +7 -35
  162. package/src/console/ui/architecture/layout.ts +1 -3
  163. package/src/console/ui/architecture/pathologies.ts +10 -19
  164. package/src/console/ui/architecture/search.ts +6 -15
  165. package/src/console/ui/architecture/traffic.ts +4 -14
  166. package/src/console/ui/architecture/types.ts +2 -10
  167. package/src/console/ui/architecture/view.test.ts +7 -19
  168. package/src/console/ui/architecture/view.ts +9 -36
  169. package/src/console/ui/channels/ChannelsA11yView.tsx +4 -13
  170. package/src/console/ui/channels/a11y.test.tsx +1 -2
  171. package/src/console/ui/channels/confirmation.test.ts +1 -4
  172. package/src/console/ui/channels/confirmation.ts +1 -4
  173. package/src/console/ui/channels/findings.ts +1 -5
  174. package/src/console/ui/channels/index.ts +2 -8
  175. package/src/console/ui/channels/locale.test.ts +1 -3
  176. package/src/console/ui/channels/locale.ts +2 -8
  177. package/src/console/ui/channels/search.ts +4 -13
  178. package/src/console/ui/channels/taxonomy.ts +1 -3
  179. package/src/console/ui/clock/ClockA11yView.tsx +9 -26
  180. package/src/console/ui/clock/a11y.test.tsx +2 -5
  181. package/src/console/ui/clock/confirmation.test.ts +1 -3
  182. package/src/console/ui/clock/confirmation.ts +1 -4
  183. package/src/console/ui/clock/findings.ts +1 -4
  184. package/src/console/ui/clock/health.ts +2 -7
  185. package/src/console/ui/clock/index.ts +2 -10
  186. package/src/console/ui/clock/search.test.ts +1 -3
  187. package/src/console/ui/clock/search.ts +2 -6
  188. package/src/console/ui/clock/timeline.test.ts +1 -3
  189. package/src/console/ui/clock/waiting-on.test.ts +1 -5
  190. package/src/console/ui/clock/waiting-on.ts +2 -7
  191. package/src/console/ui/diff/DiffA11yView.tsx +8 -17
  192. package/src/console/ui/diff/a11y.test.tsx +2 -5
  193. package/src/console/ui/diff/group.test.ts +3 -13
  194. package/src/console/ui/diff/group.ts +2 -8
  195. package/src/console/ui/diff/index.ts +2 -8
  196. package/src/console/ui/diff/search.test.ts +1 -5
  197. package/src/console/ui/diff/search.ts +4 -16
  198. package/src/console/ui/diff/summary.ts +1 -2
  199. package/src/console/ui/dist/assets/{index-Dy4jht9P.js → index-BWo8R7NR.js} +2 -2
  200. package/src/console/ui/dist/assets/{panel-access-Dd37LU2c.js → panel-access-C0J2D-a2.js} +1 -1
  201. package/src/console/ui/dist/assets/{panel-ai-CC7LR6-J.js → panel-ai-D_m6WQI8.js} +1 -1
  202. package/src/console/ui/dist/assets/{panel-architecture-B5b3iKCz.js → panel-architecture-CKnXFyUx.js} +1 -1
  203. package/src/console/ui/dist/assets/{panel-channels-CeNjTKXp.js → panel-channels-BOmQ-onL.js} +1 -1
  204. package/src/console/ui/dist/assets/{panel-clock-DgFTLoHV.js → panel-clock-giAq0Ccv.js} +1 -1
  205. package/src/console/ui/dist/assets/{panel-diff-DxehccqB.js → panel-diff-cdonmH8c.js} +1 -1
  206. package/src/console/ui/dist/assets/{panel-flows-BtrVn-Eg.js → panel-flows-DlCU5zjA.js} +2 -2
  207. package/src/console/ui/dist/assets/{panel-gates-Z9MKRGdH.js → panel-gates-XclZxWD5.js} +1 -1
  208. package/src/console/ui/dist/assets/{panel-overview-Dt_AeXgd.js → panel-overview-BznEOTnb.js} +1 -1
  209. package/src/console/ui/dist/assets/{panel-plugins-DWd0TowH.js → panel-plugins-CcGM1g64.js} +1 -1
  210. package/src/console/ui/dist/assets/{panel-runs-DGstFHeq.js → panel-runs-CGWNHLR4.js} +1 -1
  211. package/src/console/ui/dist/assets/{panel-signals-DzEa2Fnt.js → panel-signals-CNywkdak.js} +1 -1
  212. package/src/console/ui/dist/assets/{panel-store-BJkbNgxx.js → panel-store-KmTbFHMH.js} +1 -1
  213. package/src/console/ui/dist/assets/{panel-traces-BaRVO3gM.js → panel-traces-DBLx2ilD.js} +1 -1
  214. package/src/console/ui/dist/assets/panel-vault-CEnFc0dk.js +1 -0
  215. package/src/console/ui/dist/index.html +1 -1
  216. package/src/console/ui/flows/FlowsA11yView.tsx +7 -22
  217. package/src/console/ui/flows/a11y.test.tsx +2 -8
  218. package/src/console/ui/flows/buffer.test.ts +3 -11
  219. package/src/console/ui/flows/buffer.ts +4 -11
  220. package/src/console/ui/flows/confirmation.ts +1 -3
  221. package/src/console/ui/flows/contract.test.ts +3 -7
  222. package/src/console/ui/flows/contract.ts +12 -36
  223. package/src/console/ui/flows/graph.test.ts +3 -11
  224. package/src/console/ui/flows/graph.ts +5 -15
  225. package/src/console/ui/flows/index.ts +1 -6
  226. package/src/console/ui/flows/save-as-test.ts +1 -3
  227. package/src/console/ui/flows/search.ts +8 -25
  228. package/src/console/ui/flows/tiers.ts +2 -9
  229. package/src/console/ui/gates/GatesA11yView.tsx +4 -13
  230. package/src/console/ui/gates/a11y.test.tsx +2 -5
  231. package/src/console/ui/gates/audit.ts +1 -3
  232. package/src/console/ui/gates/denial.test.ts +1 -3
  233. package/src/console/ui/gates/denial.ts +4 -12
  234. package/src/console/ui/gates/findings.ts +1 -3
  235. package/src/console/ui/gates/group.test.ts +3 -3
  236. package/src/console/ui/gates/group.ts +3 -11
  237. package/src/console/ui/gates/index.ts +2 -10
  238. package/src/console/ui/gates/search.ts +3 -10
  239. package/src/console/ui/overview/OverviewA11yView.tsx +9 -27
  240. package/src/console/ui/overview/a11y.test.tsx +1 -2
  241. package/src/console/ui/overview/busiest.ts +1 -3
  242. package/src/console/ui/overview/compose.ts +1 -13
  243. package/src/console/ui/overview/cost.ts +34 -38
  244. package/src/console/ui/overview/fixture.ts +21 -26
  245. package/src/console/ui/overview/golden.ts +4 -14
  246. package/src/console/ui/overview/index.ts +2 -9
  247. package/src/console/ui/overview/rank.test.ts +3 -10
  248. package/src/console/ui/overview/rank.ts +2 -7
  249. package/src/console/ui/overview/slo.test.ts +5 -9
  250. package/src/console/ui/overview/slo.ts +6 -23
  251. package/src/console/ui/overview/verdict.ts +3 -10
  252. package/src/console/ui/plugins/PluginsA11yView.tsx +8 -18
  253. package/src/console/ui/plugins/a11y.test.tsx +1 -2
  254. package/src/console/ui/plugins/fixture.ts +2 -4
  255. package/src/console/ui/plugins/group.test.ts +1 -3
  256. package/src/console/ui/plugins/group.ts +1 -6
  257. package/src/console/ui/plugins/index.ts +3 -13
  258. package/src/console/ui/plugins/search.ts +7 -19
  259. package/src/console/ui/runs/RunsA11yView.tsx +5 -20
  260. package/src/console/ui/runs/a11y.test.tsx +2 -5
  261. package/src/console/ui/runs/explain.ts +2 -6
  262. package/src/console/ui/runs/group.ts +3 -12
  263. package/src/console/ui/runs/histogram.test.ts +2 -11
  264. package/src/console/ui/runs/histogram.ts +1 -4
  265. package/src/console/ui/runs/index.ts +4 -18
  266. package/src/console/ui/runs/project.ts +2 -6
  267. package/src/console/ui/runs/query.test.ts +1 -3
  268. package/src/console/ui/runs/query.ts +12 -35
  269. package/src/console/ui/runs/search.ts +5 -19
  270. package/src/console/ui/runs/trace-link.test.ts +2 -6
  271. package/src/console/ui/runs/trace-link.ts +4 -16
  272. package/src/console/ui/runs/types.ts +1 -3
  273. package/src/console/ui/shell/App.tsx +2 -10
  274. package/src/console/ui/shell/client.ts +22 -115
  275. package/src/console/ui/shell/components/ui.tsx +1 -4
  276. package/src/console/ui/shell/layout/Shell.tsx +2 -4
  277. package/src/console/ui/shell/main.tsx +31 -96
  278. package/src/console/ui/shell/panels/access/AccessPanel.tsx +34 -98
  279. package/src/console/ui/shell/panels/ai/AiPanel.tsx +35 -106
  280. package/src/console/ui/shell/panels/architecture/ArchitecturePanel.tsx +18 -66
  281. package/src/console/ui/shell/panels/channels/ChannelsPanel.tsx +20 -57
  282. package/src/console/ui/shell/panels/clock/ClockPanel.tsx +22 -54
  283. package/src/console/ui/shell/panels/diff/DiffPanel.tsx +20 -61
  284. package/src/console/ui/shell/panels/flows/ContractEditor.tsx +6 -23
  285. package/src/console/ui/shell/panels/flows/FlowDrawer.tsx +13 -28
  286. package/src/console/ui/shell/panels/flows/FlowsPanel.tsx +9 -29
  287. package/src/console/ui/shell/panels/gates/GatesPanel.tsx +24 -80
  288. package/src/console/ui/shell/panels/overview/OverviewPanel.tsx +20 -58
  289. package/src/console/ui/shell/panels/plugins/PluginsPanel.tsx +16 -41
  290. package/src/console/ui/shell/panels/runs/RunsPanel.tsx +31 -99
  291. package/src/console/ui/shell/panels/signals/SignalsPanel.tsx +38 -101
  292. package/src/console/ui/shell/panels/store/StorePanel.tsx +27 -66
  293. package/src/console/ui/shell/panels/traces/TracesPanel.tsx +28 -89
  294. package/src/console/ui/shell/panels/vault/VaultPanel.tsx +22 -53
  295. package/src/console/ui/shell/setup/Wizard.tsx +3 -5
  296. package/src/console/ui/shell/styles.css +1 -2
  297. package/src/console/ui/signals/SignalsA11yView.tsx +9 -33
  298. package/src/console/ui/signals/a11y.test.tsx +2 -5
  299. package/src/console/ui/signals/confirmation.test.ts +1 -5
  300. package/src/console/ui/signals/confirmation.ts +2 -6
  301. package/src/console/ui/signals/dry-run.ts +1 -3
  302. package/src/console/ui/signals/durable.ts +1 -3
  303. package/src/console/ui/signals/findings.ts +1 -3
  304. package/src/console/ui/signals/group.test.ts +2 -8
  305. package/src/console/ui/signals/group.ts +2 -10
  306. package/src/console/ui/signals/index.ts +1 -4
  307. package/src/console/ui/signals/monitor.ts +2 -7
  308. package/src/console/ui/signals/schema-form.test.ts +3 -14
  309. package/src/console/ui/signals/schema-form.ts +1 -4
  310. package/src/console/ui/signals/search.ts +4 -13
  311. package/src/console/ui/store/StoreA11yView.tsx +3 -9
  312. package/src/console/ui/store/a11y.test.tsx +2 -5
  313. package/src/console/ui/store/confirmation.test.ts +1 -3
  314. package/src/console/ui/store/confirmation.ts +1 -4
  315. package/src/console/ui/store/dry-run.ts +2 -5
  316. package/src/console/ui/store/fixture.ts +1 -2
  317. package/src/console/ui/store/group.test.ts +1 -6
  318. package/src/console/ui/store/group.ts +1 -4
  319. package/src/console/ui/store/index.ts +1 -5
  320. package/src/console/ui/store/search.ts +2 -6
  321. package/src/console/ui/store/will-not-fire.ts +1 -2
  322. package/src/console/ui/traces/TracesA11yView.tsx +10 -29
  323. package/src/console/ui/traces/a11y.test.tsx +1 -2
  324. package/src/console/ui/traces/chain.test.ts +5 -19
  325. package/src/console/ui/traces/chain.ts +1 -3
  326. package/src/console/ui/traces/critical-path.test.ts +1 -3
  327. package/src/console/ui/traces/critical-path.ts +2 -6
  328. package/src/console/ui/traces/filter.test.ts +2 -6
  329. package/src/console/ui/traces/filter.ts +5 -13
  330. package/src/console/ui/traces/fold.test.ts +4 -12
  331. package/src/console/ui/traces/fold.ts +1 -3
  332. package/src/console/ui/traces/mini.ts +1 -3
  333. package/src/console/ui/traces/replay.test.ts +1 -3
  334. package/src/console/ui/traces/replay.ts +1 -3
  335. package/src/console/ui/traces/sampling.ts +1 -4
  336. package/src/console/ui/traces/search.ts +4 -17
  337. package/src/console/ui/traces/tier.ts +1 -3
  338. package/src/console/ui/vault/VaultA11yView.tsx +5 -17
  339. package/src/console/ui/vault/a11y.test.tsx +1 -2
  340. package/src/console/ui/vault/blast-radius.ts +1 -3
  341. package/src/console/ui/vault/confirmation.test.ts +1 -5
  342. package/src/console/ui/vault/confirmation.ts +1 -4
  343. package/src/console/ui/vault/dormant.test.ts +1 -4
  344. package/src/console/ui/vault/export-safe.test.ts +1 -5
  345. package/src/console/ui/vault/export-safe.ts +1 -4
  346. package/src/console/ui/vault/fixture.ts +3 -3
  347. package/src/console/ui/vault/group.ts +1 -2
  348. package/src/console/ui/vault/index.ts +2 -10
  349. package/src/console/ui/vault/search.ts +2 -6
  350. package/src/console/ui/vault/types.ts +1 -1
  351. package/src/console/xss.gate.test.ts +1 -3
  352. package/src/docker/compose.ts +112 -20
  353. package/src/docker/derive.ts +5 -19
  354. package/src/docker/docker.test.ts +15 -15
  355. package/src/docker/dockerfile.integration.test.ts +12 -21
  356. package/src/docker/helpers.ts +5 -4
  357. package/src/docker/index.ts +4 -11
  358. package/src/docker/pin.ts +1 -9
  359. package/src/docker/recipes/index.ts +5 -6
  360. package/src/docker/recipes/mailpit.ts +22 -0
  361. package/src/docker/recipes/postgres.ts +17 -6
  362. package/src/docker/recipes/redis.ts +6 -1
  363. package/src/docker/recipes/rustfs.ts +33 -0
  364. package/src/docker/stack-id.test.ts +33 -0
  365. package/src/docker/stack-id.ts +25 -13
  366. package/src/docker/stack.integration.test.ts +6 -21
  367. package/src/docker/types.ts +13 -4
  368. package/src/drivers/ai-anthropic.ts +5 -14
  369. package/src/drivers/ai-mock.ts +2 -5
  370. package/src/drivers/ai-openai-compatible.ts +4 -10
  371. package/src/drivers/ai-providers.test.ts +6 -13
  372. package/src/drivers/bun-native-completeness.test.ts +6 -15
  373. package/src/drivers/channel-console.ts +6 -7
  374. package/src/drivers/channel-fcm.ts +20 -30
  375. package/src/drivers/channel-resend.ts +1 -3
  376. package/src/drivers/channel-smtp.ts +2 -6
  377. package/src/drivers/channel-types.ts +2 -12
  378. package/src/drivers/channel-unifonic.ts +2 -6
  379. package/src/drivers/channel-wa-cloud.ts +2 -6
  380. package/src/drivers/channel-webpush.ts +21 -60
  381. package/src/drivers/conformance.test.ts +2 -10
  382. package/src/drivers/conformance.ts +8 -21
  383. package/src/drivers/fs.ts +2 -8
  384. package/src/drivers/index.ts +12 -56
  385. package/src/drivers/memory.ts +14 -41
  386. package/src/drivers/pgvector.ts +7 -11
  387. package/src/drivers/postgres.ts +7 -13
  388. package/src/drivers/redis.ts +13 -37
  389. package/src/drivers/s3.ts +5 -17
  390. package/src/drivers/signal-engine.ts +12 -49
  391. package/src/drivers/signal-memory.ts +2 -8
  392. package/src/drivers/signal-nats.ts +4 -9
  393. package/src/drivers/signal-postgres.ts +62 -129
  394. package/src/drivers/signal-redis.ts +7 -21
  395. package/src/drivers/signal-types.ts +1 -4
  396. package/src/drivers/sqlite.ts +3 -12
  397. package/src/drivers/types.ts +4 -23
  398. package/src/drivers/vault-env.ts +2 -6
  399. package/src/drivers/vault-infisical.ts +1 -5
  400. package/src/drivers/vault-managed.ts +1 -5
  401. package/src/drivers/vault-memory.ts +1 -5
  402. package/src/drivers/vault-openbao.ts +1 -5
  403. package/src/drivers/vault-sops.ts +10 -35
  404. package/src/drivers/vault-types.ts +1 -7
  405. package/src/elements/ai/declare.ts +4 -14
  406. package/src/elements/ai/eval.ts +2 -6
  407. package/src/elements/ai/pii.ts +1 -3
  408. package/src/elements/ai/runtime.ts +12 -50
  409. package/src/elements/ai/schema.ts +4 -15
  410. package/src/elements/ai.test.ts +13 -24
  411. package/src/elements/ai.ts +1 -5
  412. package/src/elements/channel/consent.ts +3 -12
  413. package/src/elements/channel/costs.ts +4 -15
  414. package/src/elements/channel/declare.ts +1 -4
  415. package/src/elements/channel/email-auth.ts +1 -4
  416. package/src/elements/channel/locale.ts +2 -10
  417. package/src/elements/channel/mask.ts +1 -3
  418. package/src/elements/channel/mime.ts +2 -12
  419. package/src/elements/channel/outcomes.test.ts +1 -5
  420. package/src/elements/channel/outcomes.ts +5 -15
  421. package/src/elements/channel/receipts.ts +2 -7
  422. package/src/elements/channel/runtime.ts +28 -74
  423. package/src/elements/channel/suppression.ts +8 -14
  424. package/src/elements/channel.test.ts +8 -31
  425. package/src/elements/channel.ts +3 -14
  426. package/src/elements/clock/actions.ts +6 -18
  427. package/src/elements/clock/declare.ts +1 -3
  428. package/src/elements/clock/dst.ts +1 -5
  429. package/src/elements/clock/durable.ts +4 -16
  430. package/src/elements/clock/health.ts +2 -7
  431. package/src/elements/clock/leader.ts +2 -9
  432. package/src/elements/clock/reconcile.ts +4 -15
  433. package/src/elements/clock/runtime.ts +2 -5
  434. package/src/elements/clock/schedule.ts +4 -20
  435. package/src/elements/clock.test.ts +2 -7
  436. package/src/elements/clock.ts +5 -23
  437. package/src/elements/gate/permissions.ts +1 -4
  438. package/src/elements/gate/runtime.ts +7 -28
  439. package/src/elements/gate.ts +1 -5
  440. package/src/elements/index.ts +9 -7
  441. package/src/elements/signal/declare.ts +2 -7
  442. package/src/elements/signal/reconcile.test.ts +1 -4
  443. package/src/elements/signal/runtime.ts +1 -3
  444. package/src/elements/signal.test.ts +3 -15
  445. package/src/elements/signal.ts +2 -8
  446. package/src/elements/store/cache.test.ts +46 -0
  447. package/src/elements/store/cache.ts +3 -11
  448. package/src/elements/store/classify.ts +5 -22
  449. package/src/elements/store/declare.ts +8 -17
  450. package/src/elements/store/domain-ddl.test.ts +86 -0
  451. package/src/elements/store/emit-drizzle.ts +363 -0
  452. package/src/elements/store/files-policy.test.ts +1 -5
  453. package/src/elements/store/files-policy.ts +4 -12
  454. package/src/elements/store/load-plugin-tables.ts +103 -0
  455. package/src/elements/store/missing-relation.test.ts +83 -0
  456. package/src/elements/store/missing-relation.ts +38 -0
  457. package/src/elements/store/replica.ts +1 -4
  458. package/src/elements/store/runtime.ts +25 -28
  459. package/src/elements/store/schema-decl.test.ts +227 -0
  460. package/src/elements/store/schema-decl.ts +516 -0
  461. package/src/elements/store/sql-condition.ts +11 -21
  462. package/src/elements/store/sql-session.test.ts +50 -0
  463. package/src/elements/store/sql-session.ts +60 -63
  464. package/src/elements/store/table.ts +35 -19
  465. package/src/elements/store.test.ts +17 -39
  466. package/src/elements/store.ts +37 -31
  467. package/src/elements/vault/chain.ts +34 -0
  468. package/src/elements/vault/declare.ts +22 -32
  469. package/src/elements/vault/fingerprint.ts +2 -7
  470. package/src/elements/vault/redact.ts +2 -6
  471. package/src/elements/vault/runtime.ts +18 -32
  472. package/src/elements/vault.test.ts +12 -28
  473. package/src/elements/vault.ts +8 -12
  474. package/src/index.ts +5 -2
  475. package/src/kernel/adopt-routes.ts +15 -29
  476. package/src/kernel/app.ts +34 -94
  477. package/src/kernel/auth-resolve.ts +2 -9
  478. package/src/kernel/boot-bind/ai.ts +1 -4
  479. package/src/kernel/boot-bind/channel.ts +2 -8
  480. package/src/kernel/boot-bind/clock.ts +2 -6
  481. package/src/kernel/boot-bind/gate.ts +2 -8
  482. package/src/kernel/boot-bind/runs.ts +1 -3
  483. package/src/kernel/boot-bind/signal.ts +3 -10
  484. package/src/kernel/boot-bind/store.test.ts +17 -17
  485. package/src/kernel/boot-bind/store.ts +44 -50
  486. package/src/kernel/boot-bind/vault.ts +2 -8
  487. package/src/kernel/boot.test.ts +4 -9
  488. package/src/kernel/boot.ts +29 -76
  489. package/src/kernel/budget.test.ts +1 -3
  490. package/src/kernel/capability.ts +3 -10
  491. package/src/kernel/dry-run.test.ts +1 -4
  492. package/src/kernel/dry-run.ts +3 -11
  493. package/src/kernel/effects.test.ts +1 -5
  494. package/src/kernel/effects.ts +4 -11
  495. package/src/kernel/errors.registry.test.ts +2 -8
  496. package/src/kernel/errors.ts +23 -32
  497. package/src/kernel/flow.test.ts +12 -25
  498. package/src/kernel/flow.ts +5 -25
  499. package/src/kernel/fx.test.ts +15 -44
  500. package/src/kernel/fx.ts +27 -79
  501. package/src/kernel/hook-timing.test.ts +3 -6
  502. package/src/kernel/hook-timing.ts +5 -14
  503. package/src/kernel/hooks.test.ts +10 -10
  504. package/src/kernel/hooks.ts +3 -12
  505. package/src/kernel/index.ts +4 -17
  506. package/src/kernel/journal.ts +7 -31
  507. package/src/kernel/on.ts +1 -6
  508. package/src/kernel/pipeline.test.ts +10 -19
  509. package/src/kernel/pipeline.ts +5 -17
  510. package/src/kernel/plug.ts +4 -11
  511. package/src/kernel/plugin/conflicts.test.ts +13 -25
  512. package/src/kernel/plugin/decorate.test.ts +8 -13
  513. package/src/kernel/plugin/scoping.test.ts +4 -11
  514. package/src/kernel/plugin.ts +48 -24
  515. package/src/kernel/registry.ts +80 -29
  516. package/src/kernel/router.test.ts +15 -13
  517. package/src/kernel/router.ts +9 -29
  518. package/src/kernel/routing-budget.test.ts +1 -3
  519. package/src/kernel/run-telemetry.ts +1 -3
  520. package/src/kernel/triggers.ts +4 -21
  521. package/src/manifest/diff.test.ts +26 -91
  522. package/src/manifest/diff.ts +95 -225
  523. package/src/manifest/index.ts +2 -9
  524. package/src/manifest/types.ts +29 -5
  525. package/src/manifest/undeclared.test.ts +4 -12
  526. package/src/manifest/undeclared.ts +1 -2
  527. package/src/manifest/validate.test.ts +2 -6
  528. package/src/manifest/validate.ts +4 -14
  529. package/src/mcp/authorization.ts +8 -27
  530. package/src/mcp/confirmation.ts +3 -10
  531. package/src/mcp/data.ts +2 -6
  532. package/src/mcp/docs-index.ts +4 -7
  533. package/src/mcp/docs-mcp.test.ts +3 -12
  534. package/src/mcp/docs-server.ts +7 -27
  535. package/src/mcp/docs-tools.ts +2 -6
  536. package/src/mcp/index.ts +1 -6
  537. package/src/mcp/injection.gate.test.ts +4 -18
  538. package/src/mcp/mcp.test.ts +18 -49
  539. package/src/mcp/protocol.ts +3 -10
  540. package/src/mcp/server.ts +11 -52
  541. package/src/mcp/session.ts +4 -14
  542. package/src/mcp/tools.ts +14 -50
  543. package/src/plugins/catalogue.test.ts +3 -7
  544. package/src/plugins/catalogue.ts +1 -3
  545. package/src/plugins/node-import-scan.ts +2 -5
  546. package/src/plugins/supply-chain.ts +5 -17
  547. package/src/release/exports.ts +3 -8
  548. package/src/release/measure.exports.test.ts +1 -3
  549. package/src/release/measure.ts +15 -43
  550. package/src/runs/bench.test.ts +1 -3
  551. package/src/runs/collect.ts +8 -25
  552. package/src/runs/drivers/clickhouse.ts +2 -9
  553. package/src/runs/drivers/files.ts +9 -31
  554. package/src/runs/drivers/memory.ts +5 -22
  555. package/src/runs/drivers/postgres.ts +8 -20
  556. package/src/runs/duckdb.ts +2 -8
  557. package/src/runs/index.ts +3 -14
  558. package/src/runs/outlier.ts +3 -10
  559. package/src/runs/parquet.ts +8 -26
  560. package/src/runs/privacy.ts +2 -8
  561. package/src/runs/runs.test.ts +3 -9
  562. package/src/runs/runtime.ts +7 -32
  563. package/src/runs/shred.ts +10 -29
  564. package/src/runs/types.ts +1 -4
  565. package/src/runtime/bun.ts +4 -15
  566. package/src/runtime/cold-start.bench.ts +1 -3
  567. package/src/runtime/dev-request-log.test.ts +1 -4
  568. package/src/runtime/dev-request-log.ts +1 -4
  569. package/src/runtime/index.ts +1 -6
  570. package/src/runtime/primitives.ts +5 -4
  571. package/src/runtime/security.ts +3 -13
  572. package/src/runtime/serve.test.ts +4 -7
  573. package/src/runtime/types.ts +1 -4
  574. package/src/runtime/web-standard.ts +3 -15
  575. package/src/term.test.ts +4 -6
  576. package/src/term.ts +49 -98
  577. package/src/test/create-test-app.test.ts +4 -14
  578. package/src/test/create-test-app.ts +13 -31
  579. package/src/test/provisions.integration.test.ts +3 -11
  580. package/src/upgrade/codemods.test.ts +25 -6
  581. package/src/upgrade/codemods.ts +116 -3
  582. package/src/validation/standard-schema.test.ts +2 -5
  583. package/src/validation/standard-schema.ts +13 -33
  584. package/src/console/ui/dist/assets/panel-vault-BbfWdox0.js +0 -1
@@ -61,4 +61,4 @@ import{a as e,r as t,t as n}from"./rolldown-runtime-CNC7AqOf.js";var r=class{con
61
61
 
62
62
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=nn,s=!Ut.jitless,c=s&&rn.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?xi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function wi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!vn(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Sn(e,r,Wt())))}),t)}var Ti=R(`$ZodUnion`,(e,t)=>{W.init(e,t),z(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),z(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),z(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),z(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Yt(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>wi(t,r,e,i)):wi(o,r,e,i)}}),Ei=R(`$ZodIntersection`,(e,t)=>{W.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Oi(e,t,n)):Oi(e,i,a)}});function Di(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(an(e)&&an(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Di(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Di(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Oi(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),vn(e))return e;let o=Di(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ki=R(`$ZodEnum`,(e,t)=>{W.init(e,t);let n=Gt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>sn.has(typeof e)).map(e=>typeof e==`string`?cn(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ai=R(`$ZodLiteral`,(e,t)=>{if(W.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?cn(e):e?cn(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ji=R(`$ZodTransform`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ht(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Vt;return n.value=i,n.fallback=!0,n}});function Mi(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ni=R(`$ZodOptional`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,z(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),z(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Yt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Mi(e,r)):Mi(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Pi=R(`$ZodExactOptional`,(e,t)=>{Ni.init(e,t),z(e._zod,`values`,()=>t.innerType._zod.values),z(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Fi=R(`$ZodNullable`,(e,t)=>{W.init(e,t),z(e._zod,`optin`,()=>t.innerType._zod.optin),z(e._zod,`optout`,()=>t.innerType._zod.optout),z(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Yt(e.source)}|null)$`):void 0}),z(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ii=R(`$ZodDefault`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,z(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Li(e,t)):Li(r,t)}});function Li(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ri=R(`$ZodPrefault`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,z(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),zi=R(`$ZodNonOptional`,(e,t)=>{W.init(e,t),z(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Bi(t,e)):Bi(i,e)}});function Bi(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 Vi=R(`$ZodCatch`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,z(e._zod,`optout`,()=>t.innerType._zod.optout),z(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Sn(e,n,Wt()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Sn(e,n,Wt()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Hi=R(`$ZodPipe`,(e,t)=>{W.init(e,t),z(e._zod,`values`,()=>t.in._zod.values),z(e._zod,`optin`,()=>t.in._zod.optin),z(e._zod,`optout`,()=>t.out._zod.optout),z(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ui(e,t.in,n)):Ui(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ui(e,t.out,n)):Ui(r,t.out,n)}});function Ui(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Wi=R(`$ZodReadonly`,(e,t)=>{W.init(e,t),z(e._zod,`propValues`,()=>t.innerType._zod.propValues),z(e._zod,`values`,()=>t.innerType._zod.values),z(e._zod,`optin`,()=>t.innerType?._zod?.optin),z(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Gi):Gi(r)}});function Gi(e){return e.value=Object.freeze(e.value),e}var Ki=R(`$ZodCustom`,(e,t)=>{U.init(e,t),W.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>qi(t,n,r,e));qi(i,n,r,e)}});function qi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(wn(e))}}var Ji,Yi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Xi(){return new Yi}(Ji=globalThis).__zod_globalRegistry??(Ji.__zod_globalRegistry=Xi());var Zi=globalThis.__zod_globalRegistry;function Qi(e,t){return new e({type:`string`,...H(t)})}function $i(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...H(t)})}function ea(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...H(t)})}function ta(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...H(t)})}function na(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...H(t)})}function ra(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...H(t)})}function ia(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...H(t)})}function aa(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...H(t)})}function oa(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...H(t)})}function sa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...H(t)})}function ca(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...H(t)})}function la(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...H(t)})}function ua(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...H(t)})}function da(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...H(t)})}function fa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...H(t)})}function pa(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...H(t)})}function ma(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...H(t)})}function ha(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...H(t)})}function ga(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...H(t)})}function _a(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...H(t)})}function va(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...H(t)})}function ya(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...H(t)})}function ba(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...H(t)})}function xa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...H(t)})}function Sa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...H(t)})}function Ca(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...H(t)})}function wa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...H(t)})}function Ta(e,t){return new e({type:`number`,coerce:!0,checks:[],...H(t)})}function Ea(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...H(t)})}function Da(e,t){return new e({type:`boolean`,...H(t)})}function Oa(e){return new e({type:`unknown`})}function ka(e,t){return new e({type:`never`,...H(t)})}function Aa(e,t){return new Sr({check:`less_than`,...H(t),value:e,inclusive:!1})}function ja(e,t){return new Sr({check:`less_than`,...H(t),value:e,inclusive:!0})}function Ma(e,t){return new Cr({check:`greater_than`,...H(t),value:e,inclusive:!1})}function Na(e,t){return new Cr({check:`greater_than`,...H(t),value:e,inclusive:!0})}function Pa(e,t){return new wr({check:`multiple_of`,...H(t),value:e})}function Fa(e,t){return new Er({check:`max_length`,...H(t),maximum:e})}function Ia(e,t){return new Dr({check:`min_length`,...H(t),minimum:e})}function La(e,t){return new Or({check:`length_equals`,...H(t),length:e})}function Ra(e,t){return new Ar({check:`string_format`,format:`regex`,...H(t),pattern:e})}function za(e){return new jr({check:`string_format`,format:`lowercase`,...H(e)})}function Ba(e){return new Mr({check:`string_format`,format:`uppercase`,...H(e)})}function Va(e,t){return new Nr({check:`string_format`,format:`includes`,...H(t),includes:e})}function Ha(e,t){return new Pr({check:`string_format`,format:`starts_with`,...H(t),prefix:e})}function Ua(e,t){return new Fr({check:`string_format`,format:`ends_with`,...H(t),suffix:e})}function Wa(e){return new Ir({check:`overwrite`,tx:e})}function Ga(e){return Wa(t=>t.normalize(e))}function Ka(){return Wa(e=>e.trim())}function qa(){return Wa(e=>e.toLowerCase())}function Ja(){return Wa(e=>e.toUpperCase())}function Ya(){return Wa(e=>en(e))}function Xa(e,t,n){return new e({type:`array`,element:t,...H(n)})}function Za(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...H(n)})}function Qa(e,t){let n=$a(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(wn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(wn(r))}},e(t.value,t)),t);return n}function $a(e,t){let n=new U({check:`custom`,...H(t)});return n._zod.check=e,n}function eo(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??Zi,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function K(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,K(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&q(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function to(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
63
63
 
64
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function no(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:io(t,`input`,e.processors),output:io(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function q(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return q(r.element,n);if(r.type===`set`)return q(r.valueType,n);if(r.type===`lazy`)return q(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return q(r.innerType,n);if(r.type===`intersection`)return q(r.left,n)||q(r.right,n);if(r.type===`record`||r.type===`map`)return q(r.keyType,n)||q(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:q(r.in,n)||q(r.out,n);if(r.type===`object`){for(let e in r.shape)if(q(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(q(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(q(e,n))return!0;return!!(r.rest&&q(r.rest,n))}return!1}var ro=(e,t={})=>n=>{let r=eo({...n,processors:t});return K(e,r),to(r,e),no(r,e)},io=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=eo({...i??{},target:a,io:t,processors:n});return K(e,o),to(o,e),no(o,e)},ao={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},oo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ao[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},so=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},co=(e,t,n,r)=>{n.type=`boolean`},lo=(e,t,n,r)=>{n.not={}},uo=(e,t,n,r)=>{let i=e._zod.def,a=Gt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},fo=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},po=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=K(a.element,t,{...r,path:[...r.path,`items`]})},go=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=K(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=K(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},_o=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>K(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},vo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=K(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},yo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},bo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},So=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Co=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},wo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;K(o,t,r);let s=t.seen.get(e);s.ref=o},To=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Eo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Do=R(`ZodISODateTime`,(e,t)=>{Zr.init(e,t),X.init(e,t)});function Oo(e){return xa(Do,e)}var ko=R(`ZodISODate`,(e,t)=>{Qr.init(e,t),X.init(e,t)});function Ao(e){return Sa(ko,e)}var jo=R(`ZodISOTime`,(e,t)=>{$r.init(e,t),X.init(e,t)});function Mo(e){return Ca(jo,e)}var No=R(`ZodISODuration`,(e,t)=>{ei.init(e,t),X.init(e,t)});function Po(e){return wa(No,e)}var J=R(`ZodError`,(e,t)=>{En.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>kn(e,t)},flatten:{value:t=>On(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Kt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Kt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Fo=An(J),Io=jn(J),Lo=Mn(J),Ro=Pn(J),zo=In(J),Bo=Ln(J),Vo=Rn(J),Ho=zn(J),Uo=Bn(J),Wo=Vn(J),Go=Hn(J),Ko=Un(J),qo=new WeakMap;function Jo(e,t,n){let r=Object.getPrototypeOf(e),i=qo.get(r);if(i||(i=new Set,qo.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Y=R(`ZodType`,(e,t)=>(W.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:io(e,`input`),output:io(e,`output`)}}),e.toJSONSchema=ro(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Fo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Lo(e,t,n),e.parseAsync=async(t,n)=>Io(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ro(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>zo(e,t,n),e.decode=(t,n)=>Bo(e,t,n),e.encodeAsync=async(t,n)=>Vo(e,t,n),e.decodeAsync=async(t,n)=>Ho(e,t,n),e.safeEncode=(t,n)=>Uo(e,t,n),e.safeDecode=(t,n)=>Wo(e,t,n),e.safeEncodeAsync=async(t,n)=>Go(e,t,n),e.safeDecodeAsync=async(t,n)=>Ko(e,t,n),Jo(e,`ZodType`,{check(...e){let t=this.def;return this.clone(B(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return V(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ac(e,t))},superRefine(e,t){return this.check(oc(e,t))},overwrite(e){return this.check(Wa(e))},optional(){return Vs(this)},exactOptional(){return Us(this)},nullable(){return Gs(this)},nullish(){return Vs(Gs(this))},nonoptional(e){return Zs(this,e)},array(){return Ds(this)},or(e){return js([this,e])},and(e){return Ns(this,e)},transform(e){return tc(this,zs(e))},default(e){return qs(this,e)},prefault(e){return Ys(this,e)},catch(e){return $s(this,e)},pipe(e){return tc(this,e)},readonly(){return rc(this)},describe(e){let t=this.clone();return Zi.add(t,{description:e}),t},meta(...e){if(e.length===0)return Zi.get(this);let t=this.clone();return Zi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Zi.get(e)?.description},configurable:!0}),e)),Yo=R(`_ZodString`,(e,t)=>{zr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Jo(e,`_ZodString`,{regex(...e){return this.check(Ra(...e))},includes(...e){return this.check(Va(...e))},startsWith(...e){return this.check(Ha(...e))},endsWith(...e){return this.check(Ua(...e))},min(...e){return this.check(Ia(...e))},max(...e){return this.check(Fa(...e))},length(...e){return this.check(La(...e))},nonempty(...e){return this.check(Ia(1,...e))},lowercase(e){return this.check(za(e))},uppercase(e){return this.check(Ba(e))},trim(){return this.check(Ka())},normalize(...e){return this.check(Ga(...e))},toLowerCase(){return this.check(qa())},toUpperCase(){return this.check(Ja())},slugify(){return this.check(Ya())}})}),Xo=R(`ZodString`,(e,t)=>{zr.init(e,t),Yo.init(e,t),e.email=t=>e.check($i(Qo,t)),e.url=t=>e.check(aa(ts,t)),e.jwt=t=>e.check(ba(gs,t)),e.emoji=t=>e.check(oa(ns,t)),e.guid=t=>e.check(ea($o,t)),e.uuid=t=>e.check(ta(es,t)),e.uuidv4=t=>e.check(na(es,t)),e.uuidv6=t=>e.check(ra(es,t)),e.uuidv7=t=>e.check(ia(es,t)),e.nanoid=t=>e.check(sa(rs,t)),e.guid=t=>e.check(ea($o,t)),e.cuid=t=>e.check(ca(is,t)),e.cuid2=t=>e.check(la(as,t)),e.ulid=t=>e.check(ua(os,t)),e.base64=t=>e.check(_a(ps,t)),e.base64url=t=>e.check(va(ms,t)),e.xid=t=>e.check(da(ss,t)),e.ksuid=t=>e.check(fa(cs,t)),e.ipv4=t=>e.check(pa(ls,t)),e.ipv6=t=>e.check(ma(us,t)),e.cidrv4=t=>e.check(ha(ds,t)),e.cidrv6=t=>e.check(ga(fs,t)),e.e164=t=>e.check(ya(hs,t)),e.datetime=t=>e.check(Oo(t)),e.date=t=>e.check(Ao(t)),e.time=t=>e.check(Mo(t)),e.duration=t=>e.check(Po(t))});function Zo(e){return Qi(Xo,e)}var X=R(`ZodStringFormat`,(e,t)=>{G.init(e,t),Yo.init(e,t)}),Qo=R(`ZodEmail`,(e,t)=>{Hr.init(e,t),X.init(e,t)}),$o=R(`ZodGUID`,(e,t)=>{Br.init(e,t),X.init(e,t)}),es=R(`ZodUUID`,(e,t)=>{Vr.init(e,t),X.init(e,t)}),ts=R(`ZodURL`,(e,t)=>{Ur.init(e,t),X.init(e,t)}),ns=R(`ZodEmoji`,(e,t)=>{Wr.init(e,t),X.init(e,t)}),rs=R(`ZodNanoID`,(e,t)=>{Gr.init(e,t),X.init(e,t)}),is=R(`ZodCUID`,(e,t)=>{Kr.init(e,t),X.init(e,t)}),as=R(`ZodCUID2`,(e,t)=>{qr.init(e,t),X.init(e,t)}),os=R(`ZodULID`,(e,t)=>{Jr.init(e,t),X.init(e,t)}),ss=R(`ZodXID`,(e,t)=>{Yr.init(e,t),X.init(e,t)}),cs=R(`ZodKSUID`,(e,t)=>{Xr.init(e,t),X.init(e,t)}),ls=R(`ZodIPv4`,(e,t)=>{ti.init(e,t),X.init(e,t)}),us=R(`ZodIPv6`,(e,t)=>{ni.init(e,t),X.init(e,t)}),ds=R(`ZodCIDRv4`,(e,t)=>{ri.init(e,t),X.init(e,t)}),fs=R(`ZodCIDRv6`,(e,t)=>{ii.init(e,t),X.init(e,t)}),ps=R(`ZodBase64`,(e,t)=>{oi.init(e,t),X.init(e,t)}),ms=R(`ZodBase64URL`,(e,t)=>{ci.init(e,t),X.init(e,t)}),hs=R(`ZodE164`,(e,t)=>{li.init(e,t),X.init(e,t)}),gs=R(`ZodJWT`,(e,t)=>{di.init(e,t),X.init(e,t)}),_s=R(`ZodNumber`,(e,t)=>{fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r),Jo(e,`ZodNumber`,{gt(e,t){return this.check(Ma(e,t))},gte(e,t){return this.check(Na(e,t))},min(e,t){return this.check(Na(e,t))},lt(e,t){return this.check(Aa(e,t))},lte(e,t){return this.check(ja(e,t))},max(e,t){return this.check(ja(e,t))},int(e){return this.check(ys(e))},safe(e){return this.check(ys(e))},positive(e){return this.check(Ma(0,e))},nonnegative(e){return this.check(Na(0,e))},negative(e){return this.check(Aa(0,e))},nonpositive(e){return this.check(ja(0,e))},multipleOf(e,t){return this.check(Pa(e,t))},step(e,t){return this.check(Pa(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),vs=R(`ZodNumberFormat`,(e,t)=>{pi.init(e,t),_s.init(e,t)});function ys(e){return Ea(vs,e)}var bs=R(`ZodBoolean`,(e,t)=>{mi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r)});function xs(e){return Da(bs,e)}var Ss=R(`ZodUnknown`,(e,t)=>{hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Cs(){return Oa(Ss)}var ws=R(`ZodNever`,(e,t)=>{gi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r)});function Ts(e){return ka(ws,e)}var Es=R(`ZodArray`,(e,t)=>{vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.element=t.element,Jo(e,`ZodArray`,{min(e,t){return this.check(Ia(e,t))},nonempty(e){return this.check(Ia(1,e))},max(e,t){return this.check(Fa(e,t))},length(e,t){return this.check(La(e,t))},unwrap(){return this.element}})});function Ds(e,t){return Xa(Es,e,t)}var Os=R(`ZodObject`,(e,t)=>{Ci.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),z(e,`shape`,()=>t.shape),Jo(e,`ZodObject`,{keyof(){return Fs(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Cs()})},loose(){return this.clone({...this._zod.def,catchall:Cs()})},strict(){return this.clone({...this._zod.def,catchall:Ts()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return pn(this,e)},safeExtend(e){return mn(this,e)},merge(e){return hn(this,e)},pick(e){return dn(this,e)},omit(e){return fn(this,e)},partial(...e){return gn(Bs,this,e[0])},required(...e){return _n(Xs,this,e[0])}})});function ks(e,t){return new Os({type:`object`,shape:e??{},...H(t)})}var As=R(`ZodUnion`,(e,t)=>{Ti.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r),e.options=t.options});function js(e,t){return new As({type:`union`,options:e,...H(t)})}var Ms=R(`ZodIntersection`,(e,t)=>{Ei.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r)});function Ns(e,t){return new Ms({type:`intersection`,left:e,right:t})}var Ps=R(`ZodEnum`,(e,t)=>{ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ps({...t,checks:[],...H(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ps({...t,checks:[],...H(r),entries:i})}});function Fs(e,t){return new Ps({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...H(t)})}var Is=R(`ZodLiteral`,(e,t)=>{Ai.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ls(e,t){return new Is({type:`literal`,values:Array.isArray(e)?e:[e],...H(t)})}var Rs=R(`ZodTransform`,(e,t)=>{ji.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ht(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(wn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(wn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function zs(e){return new Rs({type:`transform`,transform:e})}var Bs=R(`ZodOptional`,(e,t)=>{Ni.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vs(e){return new Bs({type:`optional`,innerType:e})}var Hs=R(`ZodExactOptional`,(e,t)=>{Pi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Us(e){return new Hs({type:`optional`,innerType:e})}var Ws=R(`ZodNullable`,(e,t)=>{Fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gs(e){return new Ws({type:`nullable`,innerType:e})}var Ks=R(`ZodDefault`,(e,t)=>{Ii.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qs(e,t){return new Ks({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():on(t)}})}var Js=R(`ZodPrefault`,(e,t)=>{Ri.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ys(e,t){return new Js({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():on(t)}})}var Xs=R(`ZodNonOptional`,(e,t)=>{zi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zs(e,t){return new Xs({type:`nonoptional`,innerType:e,...H(t)})}var Qs=R(`ZodCatch`,(e,t)=>{Vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $s(e,t){return new Qs({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ec=R(`ZodPipe`,(e,t)=>{Hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.in=t.in,e.out=t.out});function tc(e,t){return new ec({type:`pipe`,in:e,out:t})}var nc=R(`ZodReadonly`,(e,t)=>{Wi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rc(e){return new nc({type:`readonly`,innerType:e})}var ic=R(`ZodCustom`,(e,t)=>{Ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r)});function ac(e,t={}){return Za(ic,e,t)}function oc(e,t){return Qa(e,t)}var sc=ks({q:Zo().optional(),plane:Fs([`operator`,`user`]).optional(),kind:Fs([`operator`,`user`,`role`,`key`,`invite`]).optional(),id:Zo().optional(),view:Fs([`detail`,`effective`,`create-key`,`grant-role`]).optional()});function cc(e){let t=sc.safeParse(e);return t.success?t.data:{}}function lc(e){let t={};return e.q&&(t.q=e.q),e.plane&&(t.plane=e.plane),e.kind&&(t.kind=e.kind),e.id&&(t.id=e.id),e.view&&(t.view=e.view),t}function uc(e,t,n,r){return{...e,plane:t,kind:n,id:r,view:`detail`}}function dc(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis),r=t.retry?.retries??0,i=t.retry?.delay??50,a=t.retry?.backoff??2;return{async call(o,s){let c=!1,l=0,u=i;for(;;)try{let r=await fc(e,o,s,t,n);if(r.status===401&&t.auth?.refresh&&!c){c=!0,await t.auth.refresh();continue}return hc(r)}catch(e){if(!gc(e)||l>=r)return{data:null,error:{code:`TransportError`,data:{message:e instanceof Error?e.message:String(e)}}};await _c(u),u*=a,l+=1}}}}async function fc(e,t,n,r,i){let a=r.routes?.[t.replace(`/`,`.`)],{url:o,method:s,body:c}=a?mc(e,a.method,a.path,n):pc(e,t,n),l=new Headers,u=typeof r.headers==`function`?await r.headers():r.headers;if(Array.isArray(u))for(let[e,t]of u)l.set(e,t);else if(u)for(let[e,t]of Object.entries(u))l.set(e,t);c!==void 0&&!l.has(`content-type`)&&l.set(`content-type`,`application/json`);let d=r.auth?await r.auth.getToken():void 0;d&&!l.has(`authorization`)&&l.set(`authorization`,`Bearer ${d}`);let f=r.timeout===void 0?void 0:new AbortController,p=f&&r.timeout!==void 0?setTimeout(()=>f.abort(),r.timeout):void 0;try{let e=await i(o,{method:s,headers:l,body:c,signal:f?.signal});if(e.status>=500)throw Error(`HTTP ${e.status}`);return e}finally{p!==void 0&&clearTimeout(p)}}function pc(e,t,n){return{url:`${e}/_oke/${t}`,method:`POST`,body:n===void 0?void 0:JSON.stringify(n??{})}}function mc(e,t,n,r){let i=typeof r==`object`&&r?r:{},a=n,o=[],s={};for(let[e,t]of Object.entries(i)){let n=`:${e}`;a.includes(n)?a=a.replaceAll(n,encodeURIComponent(String(t))):s[e]=t}let c=t.toUpperCase(),l;if(c===`GET`||c===`HEAD`)for(let[e,t]of Object.entries(s))t!==void 0&&o.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(t))}`);else(Object.keys(s).length>0||n===a)&&(l=JSON.stringify(Object.keys(s).length>0?s:r??{}));let u=o.length?`?${o.join(`&`)}`:``;return{url:`${e}${a}${u}`,method:c,body:l}}async function hc(e){if(e.status===204)return{data:void 0,error:null};let t=await e.text();if(!t)return e.ok?{data:void 0,error:null}:{data:null,error:{code:`TransportError`,data:{message:`HTTP ${e.status}`,status:e.status}}};let n;try{n=JSON.parse(t)}catch{return{data:null,error:{code:`TransportError`,data:{message:`Invalid JSON (${e.status})`,status:e.status}}}}return typeof n==`object`&&n&&`data`in n&&`error`in n?n:e.ok?{data:n,error:null}:{data:null,error:{code:`TransportError`,data:{message:`HTTP ${e.status}`,status:e.status}}}}function gc(e){return!(!(e instanceof Error)||e.name===`AbortError`)}function _c(e){return new Promise(t=>setTimeout(t,e))}function vc(e,t,n){if(typeof e==`string`)return yc(e,t);let r=typeof t==`string`?t:``,i=typeof t==`string`?n:t;return yc(r,{...i,$routes:i?.$routes??e.$routes})}function yc(e,t={}){let n=e.replace(/\/+$/,``),r=t.routes??bc(t.$routes);return xc(dc(n,{...t,routes:r}),[])}function bc(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(!(!r||typeof r!=`object`))for(let[e,i]of Object.entries(r)){if(!i||typeof i!=`object`)continue;let r=`method`in i?i.method:void 0,a=`path`in i?i.path:void 0;typeof r==`string`&&typeof a==`string`&&(t[`${n}.${e}`]={method:r,path:a})}return Object.keys(t).length>0?t:void 0}function xc(e,t){return new Proxy(n=>{if(t.length<2)return Promise.resolve({data:null,error:{code:`TransportError`,data:{message:`Incomplete path: api.${t.join(`.`)||`?`}(…)`}}});let r=t[0],i=t.slice(1).join(`.`);return e.call(`${r}/${i}`,n)},{get(n,r,i){if(typeof r==`symbol`)return Reflect.get(n,r,i);if(r!==`then`)return xc(e,[...t,r])}})}var Sc=null;function Cc(e){Sc=e,e?sessionStorage.setItem(`oke_console_at`,e):sessionStorage.removeItem(`oke_console_at`)}function wc(){Sc=sessionStorage.getItem(`oke_console_at`)}var Z=vc(globalThis.location===void 0?`http://127.0.0.1:6533`:globalThis.location.origin,{headers:()=>Sc?{Authorization:`Bearer ${Sc}`}:{},routes:{"console.setupStatus":{method:`GET`,path:`/console/setup/status`},"console.setupClaim":{method:`POST`,path:`/console/setup/claim`},"console.sessionLogin":{method:`POST`,path:`/console/session/login`},"console.sessionMe":{method:`GET`,path:`/console/session/me`},"console.sessionLogout":{method:`POST`,path:`/console/session/logout`},"console.manifestGet":{method:`GET`,path:`/console/manifest`},"console.runsList":{method:`GET`,path:`/console/runs`},"console.actionPing":{method:`POST`,path:`/console/action/ping`},"console.structuralPropose":{method:`POST`,path:`/console/structural/propose`},"console.flowsIdentities":{method:`GET`,path:`/console/flows/identities`},"console.flowsInvoke":{method:`POST`,path:`/console/flows/invoke`},"console.tracesReplay":{method:`POST`,path:`/console/traces/replay`},"console.signalsList":{method:`GET`,path:`/console/signals`},"console.signalsReplay":{method:`POST`,path:`/console/signals/replay`},"console.signalsDryRunReplay":{method:`POST`,path:`/console/signals/dry-run-replay`},"console.signalsDiscard":{method:`POST`,path:`/console/signals/discard`},"console.storeList":{method:`GET`,path:`/console/store`},"console.storeQuery":{method:`POST`,path:`/console/store/query`},"console.storeReveal":{method:`POST`,path:`/console/store/reveal`},"console.storeEdit":{method:`POST`,path:`/console/store/edit`},"console.storeDelete":{method:`POST`,path:`/console/store/delete`},"console.storePurgeCache":{method:`POST`,path:`/console/store/purge-cache`},"console.storeSql":{method:`POST`,path:`/console/store/sql`},"console.storePreview":{method:`POST`,path:`/console/store/preview`},"console.vaultList":{method:`GET`,path:`/console/vault`},"console.vaultSet":{method:`POST`,path:`/console/vault/set`},"console.vaultRotate":{method:`POST`,path:`/console/vault/rotate`},"console.aiList":{method:`GET`,path:`/console/ai`},"console.clockList":{method:`GET`,path:`/console/clock`},"console.clockRunNow":{method:`POST`,path:`/console/clock/run-now`},"console.clockPause":{method:`POST`,path:`/console/clock/pause`},"console.clockEditSchedule":{method:`POST`,path:`/console/clock/edit-schedule`},"console.clockWakeEarly":{method:`POST`,path:`/console/clock/wake-early`},"console.channelsList":{method:`GET`,path:`/console/channels`},"console.channelPreview":{method:`POST`,path:`/console/channels/preview`},"console.channelVerifyAuth":{method:`POST`,path:`/console/channels/verify-auth`},"console.channelReveal":{method:`POST`,path:`/console/channels/reveal`},"console.channelSendTest":{method:`POST`,path:`/console/channels/send-test`},"console.gatesList":{method:`GET`,path:`/console/gates`},"console.gatesSimulate":{method:`POST`,path:`/console/gates/simulate`},"console.gatesPowers":{method:`POST`,path:`/console/gates/powers`},"console.accessList":{method:`GET`,path:`/console/access`},"console.accessEffective":{method:`POST`,path:`/console/access/effective`},"console.accessKeyBlast":{method:`POST`,path:`/console/access/key-blast`},"console.accessCreateKey":{method:`POST`,path:`/console/access/keys`},"console.accessRevokeKey":{method:`POST`,path:`/console/access/keys/revoke`},"console.accessRotateKey":{method:`POST`,path:`/console/access/keys/rotate`},"console.accessSetRoleGrants":{method:`POST`,path:`/console/access/roles/grants`},"console.diffList":{method:`GET`,path:`/console/diff`},"console.pluginsList":{method:`GET`,path:`/console/plugins`}}}),Tc={async setupStatus(){return Z.console.setupStatus({})},async setupClaim(e){return Z.console.setupClaim(e)},async sessionLogin(e){return Z.console.sessionLogin(e)},async sessionMe(){return Z.console.sessionMe({})},async actionPing(e){return Z.console.actionPing({note:e})},async runsList(){return Z.console.runsList({})},async manifestGet(){return Z.console.manifestGet({})},async flowsIdentities(){return Z.console.flowsIdentities({})},async flowsInvoke(e){return Z.console.flowsInvoke(e)},async tracesReplay(e){return Z.console.tracesReplay(e)},async signalsList(){return Z.console.signalsList({})},async signalsReplay(e){return Z.console.signalsReplay(e)},async signalsDryRunReplay(e){return Z.console.signalsDryRunReplay(e)},async signalsDiscard(e){return Z.console.signalsDiscard(e)},async storeList(){return Z.console.storeList({})},async storeQuery(e){return Z.console.storeQuery(e)},async storeReveal(e){return Z.console.storeReveal(e)},async storeEdit(e){return Z.console.storeEdit(e)},async storeDelete(e){return Z.console.storeDelete(e)},async storePurgeCache(e){return Z.console.storePurgeCache(e)},async storeSql(e){return Z.console.storeSql(e)},async storePreview(e){return Z.console.storePreview(e)},async vaultList(){return Z.console.vaultList({})},async vaultSet(e){return Z.console.vaultSet(e)},async vaultRotate(e){return Z.console.vaultRotate(e)},async aiList(){return Z.console.aiList({})},async clockList(){return Z.console.clockList({})},async clockRunNow(e){return Z.console.clockRunNow(e)},async clockPause(e){return Z.console.clockPause(e)},async clockEditSchedule(e){return Z.console.clockEditSchedule(e)},async clockWakeEarly(e){return Z.console.clockWakeEarly(e)},async channelsList(){return Z.console.channelsList({})},async channelPreview(e){return Z.console.channelPreview(e)},async channelVerifyAuth(e){return Z.console.channelVerifyAuth(e)},async channelReveal(e){return Z.console.channelReveal(e)},async channelSendTest(e){return Z.console.channelSendTest(e)},async gatesList(){return Z.console.gatesList({})},async gatesSimulate(e){return Z.console.gatesSimulate(e)},async gatesPowers(e){return Z.console.gatesPowers(e)},async accessList(){return Z.console.accessList({})},async accessEffective(e){return Z.console.accessEffective(e)},async accessKeyBlast(e){return Z.console.accessKeyBlast(e)},async accessCreateKey(e){return Z.console.accessCreateKey(e)},async accessRevokeKey(e){return Z.console.accessRevokeKey(e)},async accessRotateKey(e){return Z.console.accessRotateKey(e)},async accessSetRoleGrants(e){return Z.console.accessSetRoleGrants(e)},async diffList(){return Z.console.diffList({})},async pluginsList(){return Z.console.pluginsList({})}};function Ec(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ec(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Dc(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ec(e))&&(r&&(r+=` `),r+=t);return r}function Oc(){return typeof window<`u`}function kc(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ac(e){return Oc()?e instanceof Element||e instanceof kc(e).Element:!1}function jc(e){return Oc()?e instanceof HTMLElement||e instanceof kc(e).HTMLElement:!1}var Mc={...I},Nc={};function Pc(e,t){let n=I.useRef(Nc);return n.current===Nc&&(n.current=e(t)),n}var Fc=Mc.useInsertionEffect,Ic=Fc&&Fc!==Mc.useLayoutEffect?Fc:e=>e();function Lc(e){let t=Pc(Rc).current;return t.next=e,Ic(t.effect),t.trampoline}function Rc(){let e={next:void 0,callback:zc,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function zc(){}var Bc=typeof document<`u`?I.useLayoutEffect:()=>{};function Vc(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}var Hc={};function Uc(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Gc(t);let a=Gc(e);return t&&(a=Kc(a,t)),n&&(a=Kc(a,n)),r&&(a=Kc(a,r)),i&&(a=Kc(a,i)),a}function Wc(e){if(e.length===0)return Hc;if(e.length===1)return Gc(e[0]);let t=Gc(e[0]);for(let n=1;n<e.length;n+=1)t=Kc(t,e[n]);return t}function Gc(e){return Xc(e)?{...Zc(e,Hc)}:qc(e)}function Kc(e,t){return Xc(t)?Zc(t,e):Jc(e,t)}function qc(e){let t={...e};for(let e in t){let n=t[e];Yc(e,n)&&(t[e]=$c(n))}return t}function Jc(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Vc(e.style,r);break;case`className`:e[n]=tl(e.className,r);break;default:Yc(n,r)?e[n]=Qc(e[n],r):e[n]=r}}return e}function Yc(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Xc(e){return typeof e==`function`}function Zc(e,t){return Xc(e)?e(t):e??Hc}function Qc(e,t){return t?e?(...n)=>{let r=n[0];if(nl(r)){let i=r;el(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:$c(t):e}function $c(e){return e&&((...t)=>{let n=t[0];return nl(n)&&el(n),e(...t)})}function el(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function tl(e,t){return t?e?t+` `+e:t:e}function nl(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function rl(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var il=rl(`https://base-ui.com/production-error`,`Base UI`),al=I.createContext(void 0);function ol(e=!1){let t=I.useContext(al);if(t===void 0&&!e)throw Error(il(16));return t}function sl(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:I.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function cl(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=I.useRef(null),s=ol(!0),c=a??s!==void 0,{props:l}=sl({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=I.useCallback(()=>{let e=o.current;ll(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return Bc(u,[u]),{getButtonProps:I.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return Uc({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(el(e),o?.(e),e.baseUIHandlerPrevented))return;let r=e.target===e.currentTarget,a=e.currentTarget,s=ll(a),l=!i&&ul(a),u=r&&(i?s:!l),d=e.key===`Enter`,f=e.key===` `,p=a.getAttribute(`role`),m=p?.startsWith(`menuitem`)||p===`option`||p===`gridcell`;if(r&&c&&f){if(e.defaultPrevented&&m)return;e.preventDefault(),l||i&&s?(a.click(),e.preventBaseUIHandler()):u&&(n?.(e),e.preventBaseUIHandler());return}u&&(!i&&(f||d)&&e.preventDefault(),!i&&d&&n?.(e))},onKeyUp(e){if(!t){if(el(e),a?.(e),e.target===e.currentTarget&&i&&c&&ll(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&e.key===` `&&n?.(e)}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Lc(e=>{o.current=e,u()})}}function ll(e){return jc(e)&&e.tagName===`BUTTON`}function ul(e){return!!(e?.tagName===`A`&&e?.href)}function dl(e,t,n,r){let i=Pc(pl).current;return ml(i,e,t,n,r)&&gl(i,[e,t,n,r]),i.callback}function fl(e){let t=Pc(pl).current;return hl(t,e)&&gl(t,e),t.callback}function pl(){return{callback:null,cleanup:null,refs:[]}}function ml(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function hl(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function gl(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var _l=19;function vl(e){return _l>=e}function yl(e){if(!I.isValidElement(e))return null;let t=e,n=t.props;return(vl(19)?n?.ref:t.ref)??null}function Q(){}Object.freeze([]);var bl=Object.freeze({});function xl(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Sl(e,t){return typeof e==`function`?e(t):e}function Cl(e,t){return typeof e==`function`?e(t):e}function wl(e,t,n={}){let r=t.render,i=Tl(t,n);return n.enabled===!1?null:Ol(e,r,i,n.state??bl)}function Tl(e,t={}){let{className:n,style:r,render:i}=e,{state:a=bl,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Sl(n,a):void 0,d=l?Cl(r,a):void 0,f=l?xl(a,c):bl,p=l&&s?El(s):void 0,m=l?Vc(f,p)??{}:bl;return typeof document<`u`&&(l?Array.isArray(o)?m.ref=fl([m.ref,yl(i),...o]):m.ref=dl(m.ref,yl(i),o):dl(null,null)),l?(u!==void 0&&(m.className=tl(m.className,u)),d!==void 0&&(m.style=Vc(m.style,d)),m):bl}function El(e){return Array.isArray(e)?Wc(e):Uc(void 0,e)}var Dl=Symbol.for(`react.lazy`);function Ol(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Uc(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===Dl&&(i=I.Children.toArray(t)[0]),I.cloneElement(i,e)}if(e&&typeof e==`string`)return kl(e,n);throw Error(il(8))}function kl(e,t){return e===`button`?(0,I.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,I.createElement)(`img`,{alt:``,...t,key:t.key}):I.createElement(e,t)}var Al=I.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=cl({disabled:i,focusableWhenDisabled:a,native:o});return wl(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),jl=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Ml={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Nl={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Pl={disabled:!1,...Nl},Fl={valid(e){return e===null?null:e?{[jl.valid]:``}:{[jl.invalid]:``}}},Il={invalid:void 0,name:void 0,validityData:{state:Ml,errors:[],error:``,value:``,initialValue:null},setValidityData:Q,disabled:void 0,touched:Nl.touched,setTouched:Q,dirty:Nl.dirty,setDirty:Q,filled:Nl.filled,setFilled:Q,focused:Nl.focused,setFocused:Q,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:Pl,markedDirtyRef:{current:!1},registerFieldControl:Q,validation:{getValidationProps:(e,t=bl)=>t,inputRef:{current:null},registerInput:Q,commit:async()=>{},change:Q}},Ll=I.createContext(Il);function Rl(e=!0){let t=I.useContext(Ll);if(t.setValidityData===Q&&!e)throw Error(il(28));return t}var zl=I.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Q,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function Bl(){return I.useContext(zl)}var Vl=0;function Hl(e,t=`mui`){let[n,r]=I.useState(e),i=e||n;return I.useEffect(()=>{n??(Vl+=1,r(`${t}-${Vl}`))},[n,t]),i}var Ul=Mc.useId;function Wl(e,t){if(Ul!==void 0){let n=Ul();return e??(t?`${t}-${n}`:n)}return Hl(e,t)}function Gl(e){return Wl(e,`base-ui`)}var Kl=I.createContext({controlId:void 0,registerControlId:Q,labelId:void 0,setLabelId:Q,messageIds:[],setMessageIds:Q,getDescriptionProps:e=>e});function ql(){return I.useContext(Kl)}function Jl(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=ql(),o=Gl(t),s=n?i:void 0,c=Pc(()=>Symbol(`labelable-control`)),l=I.useRef(!1),u=I.useRef(t!=null),d=Lc(()=>{!l.current||a===Q||(l.current=!1,a(c.current,void 0))});return Bc(()=>{if(a===Q)return;let e;if(n){let n=r?.current;e=Ac(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),I.useEffect(()=>d,[d]),i??o}function Yl(e){return e?.ownerDocument||document}function Xl(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Zl({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=I.useRef(e!==void 0),[a,o]=I.useState(t);return[i?e:a,I.useCallback(e=>{i||o(e)},[])]}function Ql(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Rl(),s=I.useRef(null);s.current||=Symbol(),Bc(()=>{let c=s.current;if(!(!c||!i))return o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}),()=>{o(c,void 0)}},[e,i,r,t,a,o,n])}var $l=`none`;function eu(e,t,n,r){let i=!1,a=!1,o=r??bl;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var tu=I.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=Rl(),{clearErrors:C}=Bl(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=ql(),O=Jl({id:i});Bc(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=I.useRef(null);Bc(()=>{u&&k.current===Xl(Yl(k.current))&&y(!0)},[u,y]);let[A]=Zl({controlled:o,default:l,name:`FieldControl`,state:`value`}),ee=o!==void 0,j=ee?A:void 0,M=Lc(()=>S.inputRef.current?.value);return Ql(S.inputRef,O,j,M,!w,a),wl(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...ee?{value:j}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,eu($l,e.nativeEvent)),_(t!==v.initialValue),b(t!==``),e.nativeEvent.defaultPrevented||(C(T),S.change(t))},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},f,e=>S.getValidationProps(w,e)],stateAttributesMapping:Fl})}),nu=I.forwardRef(function(e,t){return(0,L.jsx)(tu,{ref:t,...e})});function $({variant:e=`primary`,className:t,...n}){return(0,L.jsx)(Al,{className:Dc(`inline-flex min-h-8 min-w-8 items-center justify-center px-3 text-sm font-medium transition-opacity duration-150`,`disabled:opacity-40`,e===`primary`&&`bg-[var(--oke-accent)] text-black`,e===`ghost`&&`bg-transparent text-[var(--oke-fg)] border border-[var(--oke-line)]`,e===`danger`&&`bg-[var(--oke-danger)] text-white`,e===`external`&&`bg-[var(--oke-external)] text-black`,t),...n})}function ru({className:e,...t}){return(0,L.jsx)(nu,{className:Dc(`min-h-8 w-full border border-[var(--oke-line)] bg-transparent px-3 text-sm text-[var(--oke-fg)]`,`placeholder:text-[var(--oke-muted)]`,e),...t})}function iu({label:e,error:t,children:n}){return(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:e}),n,t?(0,L.jsx)(`span`,{role:`alert`,className:`text-xs text-[var(--oke-danger)]`,children:t}):null]})}function au({count:e,onFlush:t}){return e<=0?null:(0,L.jsxs)(`button`,{type:`button`,className:`min-h-8 rounded-sm border border-[var(--oke-line)] px-3 text-xs text-[var(--oke-fg)]`,onClick:t,children:[e,` new`]})}var ou=15e3;function su(e,t={production:!0}){return e===`external`&&t.production?{kind:`typed`,phrase:`INVOKE`,requireReason:!0}:{kind:`undo`,windowMs:ou}}function cu(e){let t={};return e.typed.trim()!==e.phrase&&(t.typed=`Type ${e.phrase} to confirm`),e.reason.trim().length<3&&(t.reason=`Reason is required (min 3 characters)`),Object.keys(t).length>0?t:null}function lu(e={production:!0}){return{kind:`typed`,phrase:`REVOKE`,requireReason:!0}}function uu(e={production:!0}){return{kind:`typed`,phrase:`ROTATE`,requireReason:!0}}function du(e){return e.acknowledged===!0}var fu=`I have copied this secret and understand it will not be shown again`,pu=`This secret is shown exactly once. Store it now — dismissal is permanent.`;function mu(e){return{volume:e.callVolume===0?`No recorded calls from Runs`:`${e.callVolume} call${e.callVolume===1?``:`s`} in Runs`,lastUsed:e.lastUsedAt==null?`Never used`:`Last used ${new Date(e.lastUsedAt).toISOString()}`,sources:e.sourceAddresses.length===0?`No source addresses recorded`:`Source addresses: ${e.sourceAddresses.join(`, `)}`,residual:e.residualAccessNote,warn:e.callVolume>0}}function hu(e){let t=[];return e.unusedKeys.length>0&&t.push({code:`unused-keys`,message:`${e.unusedKeys.length} key${e.unusedKeys.length===1?``:`s`} unused 90d+`}),e.neverSignedInOperators.length>0&&t.push({code:`never-signed-in`,message:`${e.neverSignedInOperators.length} operator${e.neverSignedInOperators.length===1?``:`s`} never signed in`}),e.expiredInvitations.length>0&&t.push({code:`expired-invites`,message:`${e.expiredInvitations.length} expired invitation${e.expiredInvitations.length===1?``:`s`}`}),t}function gu(e){return e.scopes.map(e=>({scope:e.scope,sources:e.sources.map(e=>e.kind===`direct`?`direct (${e.name})`:`role ${e.name}`).join(`, `)}))}function _u(){let e=Rt({from:`/access`}),t=zt({from:`/access`}),n=je(),r=e.plane??`operator`,[i,a]=(0,I.useState)([]),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(null),v=e=>{t({search:lc(e),replace:!0})},y=Ke({queryKey:[`console.access.list`],queryFn:async()=>{let e=await Tc.accessList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}).data,b=r===`operator`?y?.operatorPlane:y?.userPlane,x=b?.grantableScopes??[],S=y?.hygiene,C=(0,I.useMemo)(()=>S?hu(S):[],[S]),w=b?.keys.find(t=>e.kind===`key`&&t.id===e.id),T=b?.roles.find(t=>e.kind===`role`&&t.id===e.id),E=b?.operators?.find(t=>e.kind===`operator`&&t.id===e.id),D=b?.users?.find(t=>e.kind===`user`&&t.id===e.id),O=(e.q??``).toLowerCase(),k=e=>O.length===0||e.toLowerCase().includes(O),A=qe({mutationFn:async()=>{if(!o.trim())throw Error(`Name required`);let e=await Tc.accessCreateKey({plane:r,name:o.trim(),scopes:i});if(e.error)throw Error(e.error.code);return e.data},onSuccess:e=>{p({secret:e.secret,keyId:e.key.id,keyName:e.key.name,acknowledged:!1}),s(``),a([]),n.invalidateQueries({queryKey:[`console.access.list`]})}}),ee=qe({mutationFn:async e=>{let t=await Tc.accessKeyBlast({keyId:e});if(t.error)throw Error(t.error.code);return t.data},onSuccess:h}),j=qe({mutationFn:async()=>{if(!w)throw Error(`Select a key`);let e=lu();if(e.kind===`typed`){let t=cu({typed:c,reason:u,phrase:e.phrase});if(t)throw Error(t.typed??t.reason??`confirm`)}let t=await Tc.accessRevokeKey({keyId:w.id,confirmation:c,reason:u});if(t.error)throw Error(t.error.code);return t.data},onSuccess:e=>{h(e.blastRadius),l(``),d(``),n.invalidateQueries({queryKey:[`console.access.list`]})}}),M=qe({mutationFn:async()=>{if(!w)throw Error(`Select a key`);let e=uu();if(e.kind===`typed`){let t=cu({typed:c,reason:u,phrase:e.phrase});if(t)throw Error(t.typed??t.reason??`confirm`)}let t=await Tc.accessRotateKey({keyId:w.id,confirmation:c,reason:u});if(t.error)throw Error(t.error.code);return t.data},onSuccess:e=>{h(e.blastRadius),p({secret:e.secret,keyId:e.key.id,keyName:e.key.name,acknowledged:!1}),l(``),d(``),n.invalidateQueries({queryKey:[`console.access.list`]})}}),N=qe({mutationFn:async()=>{let t=e.kind===`invite`||!e.kind||!e.id?null:e.kind;if(!t||!e.id)throw Error(`Select a principal`);let n=await Tc.accessEffective({kind:t,id:e.id});if(n.error)throw Error(n.error.code);return n.data},onSuccess:_}),te=qe({mutationFn:async()=>{if(!T)throw Error(`Select a role`);let e=await Tc.accessSetRoleGrants({roleId:T.id,scopes:i});if(e.error)throw Error(e.error.code);return e.data},onSuccess:()=>{n.invalidateQueries({queryKey:[`console.access.list`]})}}),P=m?mu(m):null,ne=g?gu(g):[],F=e=>{a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-3 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-lg font-medium text-[var(--oke-fg)]`,children:`Access`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Identities, roles, API keys — planes never merge`})]}),(0,L.jsxs)(`div`,{role:`group`,"aria-label":`Plane`,className:`flex gap-1`,children:[(0,L.jsx)($,{type:`button`,variant:r===`operator`?`primary`:`ghost`,"aria-pressed":r===`operator`,onClick:()=>v({...e,plane:`operator`,kind:void 0,id:void 0,view:void 0}),children:`Operator plane`}),(0,L.jsx)($,{type:`button`,variant:r===`user`?`primary`:`ghost`,"aria-pressed":r===`user`,onClick:()=>v({...e,plane:`user`,kind:void 0,id:void 0,view:void 0}),children:`User plane`})]}),(0,L.jsxs)(`label`,{className:`ml-auto flex min-w-[12rem] flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter access`}),(0,L.jsx)(ru,{"aria-label":`Filter access`,value:e.q??``,onChange:t=>v({...e,q:t.currentTarget.value||void 0})})]})]}),C.length>0?(0,L.jsxs)(`section`,{"aria-label":`Access hygiene`,className:`border-b border-[var(--oke-line)] px-4 py-2`,role:`status`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Hygiene`}),(0,L.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-[var(--oke-warn,var(--oke-muted))]`,children:C.map(e=>(0,L.jsx)(`li`,{children:e.message},e.code))})]}):null,(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,L.jsxs)(`section`,{"aria-label":`${r} plane list`,className:`w-80 shrink-0 overflow-y-auto border-r border-[var(--oke-line)]`,children:[(0,L.jsx)(`h2`,{className:`px-4 py-2 text-sm font-medium`,children:r===`operator`?`Operator plane`:`User plane`}),b?.operators?(0,L.jsx)(vu,{label:`Operators`,children:b.operators.filter(e=>k(`${e.name} ${e.email}`)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`operator`&&e.id===t.id,onClick:()=>v(uc(e,`operator`,`operator`,t.id)),children:[t.name,t.neverSignedIn?(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · never`}):null]},t.id))}):null,b?.users?(0,L.jsx)(vu,{label:`Users`,children:b.users.filter(e=>k(`${e.name} ${e.email}`)).map(t=>(0,L.jsx)(yu,{selected:e.kind===`user`&&e.id===t.id,onClick:()=>v(uc(e,`user`,`user`,t.id)),children:t.name},t.id))}):null,(0,L.jsx)(vu,{label:`Roles`,children:(b?.roles??[]).filter(e=>k(e.name)).map(t=>(0,L.jsx)(yu,{selected:e.kind===`role`&&e.id===t.id,onClick:()=>{a([...t.scopes]),v(uc(e,r,`role`,t.id))},children:t.name},t.id))}),(0,L.jsx)(vu,{label:`API keys`,children:(b?.keys??[]).filter(e=>k(e.name)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`key`&&e.id===t.id,onClick:()=>{h(null),v(uc(e,r,`key`,t.id)),ee.mutate(t.id)},children:[t.name,t.unused90d?(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · 90d+`}):null,t.revokedAt==null?null:(0,L.jsx)(`span`,{className:`text-[var(--oke-danger)]`,children:` · revoked`})]},t.id))}),b?.invites&&b.invites.length>0?(0,L.jsx)(vu,{label:`Invitations`,children:b.invites.filter(e=>k(e.email)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`invite`&&e.id===t.id,onClick:()=>v(uc(e,`operator`,`invite`,t.id)),children:[t.email,t.expired?(0,L.jsx)(`span`,{className:`text-[var(--oke-danger)]`,children:` · expired`}):null]},t.id))}):null,(0,L.jsx)(`div`,{className:`border-t border-[var(--oke-line)] p-3`,children:(0,L.jsx)($,{type:`button`,variant:`ghost`,className:`w-full`,onClick:()=>{a([]),s(``),v({...e,plane:r,view:`create-key`,kind:void 0,id:void 0})},children:`Create API key`})})]}),(0,L.jsxs)(`section`,{"aria-label":`Access detail`,className:`min-w-0 flex-1 overflow-y-auto px-4 py-3`,"aria-live":`polite`,children:[e.view===`create-key`?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:`Create API key`}),(0,L.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[`Only scopes you hold on the `,r,` plane are shown — impossibility taught by absence. No preview.`]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Name`}),(0,L.jsx)(ru,{"aria-label":`API key name`,value:o,onChange:e=>s(e.currentTarget.value)})]}),(0,L.jsx)(bu,{grantable:x,selected:i,onToggle:F}),(0,L.jsx)($,{type:`button`,disabled:A.isPending||!o.trim(),onClick:()=>A.mutate(),children:`Create key`}),A.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:A.error.message}):null]}):w?(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:w.name}),(0,L.jsx)(`p`,{className:`font-mono text-sm text-[var(--oke-muted)]`,children:w.id}),(0,L.jsx)(`ul`,{className:`mt-2 font-mono text-sm`,children:w.scopes.map(e=>(0,L.jsx)(`li`,{children:e},e))})]}),(0,L.jsxs)(`section`,{"aria-label":`Revocation blast radius`,className:`space-y-1`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Revocation blast radius`}),P?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-sm`,role:P.warn?`alert`:`status`,children:P.volume}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:P.lastUsed}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:P.sources}),(0,L.jsx)(`p`,{className:`text-sm`,role:`status`,children:P.residual})]}):(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`})]}),w.revokedAt==null?(0,L.jsxs)(`section`,{"aria-label":`Revoke or rotate`,className:`space-y-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Revoke / rotate`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Irreversible. Type the phrase and a reason. No dry-run.`}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Type REVOKE or ROTATE`}),(0,L.jsx)(ru,{"aria-label":`Type REVOKE or ROTATE to confirm`,value:c,onChange:e=>l(e.currentTarget.value),autoComplete:`off`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Reason`}),(0,L.jsx)(ru,{"aria-label":`Reason`,value:u,onChange:e=>d(e.currentTarget.value)})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)($,{type:`button`,variant:`danger`,disabled:j.isPending,onClick:()=>j.mutate(),children:`Revoke key`}),(0,L.jsx)($,{type:`button`,variant:`danger`,disabled:M.isPending,onClick:()=>M.mutate(),children:`Rotate key`})]}),j.error||M.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:(j.error??M.error).message}):null]}):(0,L.jsxs)(`p`,{role:`status`,className:`text-sm text-[var(--oke-danger)]`,children:[`Revoked`,` `,w.revokedAt?new Date(w.revokedAt).toISOString():``]}),(0,L.jsx)($,{type:`button`,variant:`ghost`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):T?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:T.name}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:T.description}),(0,L.jsx)(bu,{grantable:x,selected:i,onToggle:F}),(0,L.jsx)($,{type:`button`,disabled:te.isPending,onClick:()=>te.mutate(),children:`Save role grants`}),(0,L.jsx)($,{type:`button`,variant:`ghost`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):E||D?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:E?.name??D?.name}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:E?.email??D?.email}),(0,L.jsx)($,{type:`button`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):e.view===`effective`&&ne.length>0?(0,L.jsx)(xu,{provenance:ne}):(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Choose an identity, role, or key. Planes stay separate; scopes you cannot grant do not appear.`}),e.view===`effective`&&ne.length>0&&(w||T||E||D)?(0,L.jsx)(`div`,{className:`mt-6`,children:(0,L.jsx)(xu,{provenance:ne})}):null]})]}),f?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,role:`presentation`,children:(0,L.jsxs)(`section`,{"aria-label":`New API key secret`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`once-secret-title`,className:`max-w-lg space-y-4 border border-[var(--oke-line)] bg-[var(--oke-bg)] p-6`,children:[(0,L.jsx)(`h2`,{id:`once-secret-title`,className:`text-lg font-medium`,children:`New API key secret`}),(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:pu}),(0,L.jsx)(`p`,{className:`break-all font-mono text-sm`,children:f.secret}),(0,L.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:f.acknowledged,onChange:e=>p({...f,acknowledged:e.currentTarget.checked})}),(0,L.jsx)(`span`,{children:fu})]}),(0,L.jsx)($,{type:`button`,disabled:!du(f),onClick:()=>p(null),children:`Dismiss secret`})]})}):null]})}function vu({label:e,children:t}){return(0,L.jsxs)(`section`,{"aria-label":e,className:`border-t border-[var(--oke-line)]`,children:[(0,L.jsx)(`h3`,{className:`px-4 py-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:e}),(0,L.jsx)(`ul`,{className:`pb-2`,children:t})]})}function yu({selected:e,onClick:t,children:n}){return(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:Dc(`flex min-h-8 w-full items-center px-4 text-left text-sm`,e?`bg-[var(--oke-accent)]/15 text-[var(--oke-fg)]`:`text-[var(--oke-fg)]`),children:n})})}function bu({grantable:e,selected:t,onToggle:n}){return(0,L.jsxs)(`section`,{"aria-label":`Grantable scopes`,className:`space-y-2`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Grantable scopes`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Only scopes you hold appear`}),e.length===0?(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-[var(--oke-muted)]`,children:`No grantable scopes on this plane`}):(0,L.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`label`,{className:`flex min-h-8 items-center gap-2 font-mono text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:t.includes(e),onChange:()=>n(e)}),e]})},e))})]})}function xu({provenance:e}){return(0,L.jsxs)(`section`,{"aria-label":`Effective permissions`,children:[(0,L.jsx)(`h2`,{className:`mb-2 text-lg font-medium`,children:`Effective permissions`}),(0,L.jsx)(`p`,{className:`mb-3 text-sm text-[var(--oke-muted)]`,children:`Every permission with provenance — inverse of the Gates simulator`}),(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`caption`,{className:`sr-only`,children:`Effective permissions with provenance`}),(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-[var(--oke-line)]`,children:[(0,L.jsx)(`th`,{scope:`col`,className:`py-2 pr-4 font-medium`,children:`Scope`}),(0,L.jsx)(`th`,{scope:`col`,className:`py-2 font-medium`,children:`Granted by`})]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-[var(--oke-line)]`,children:[(0,L.jsx)(`td`,{className:`py-2 pr-4 font-mono`,children:e.scope}),(0,L.jsx)(`td`,{className:`py-2 text-[var(--oke-muted)]`,children:e.sources})]},e.scope))})]})]})}var Su=t({default:()=>_u});export{Me as $,Tt as A,bt as B,zt as C,Pt as D,It as E,xt as F,st as G,ht as H,ft as I,Ze as J,Je as K,St as L,yt as M,Ct as N,Dt as O,pt as P,Ke as Q,tt as R,Ta as S,Lt as T,$e as U,mt as V,ot as W,Xe as X,Ye as Y,qe as Z,xs as _,r as _t,cu as a,re as at,Zo as b,ru as c,v as ct,Tc as d,h as dt,je as et,wc as f,l as ft,Fs as g,i as gt,_s as h,A as ht,su as i,fe as it,wt as j,Et as k,au as l,_ as lt,cc as m,p as mt,hu as n,De as nt,$ as o,F as ot,Cc as p,y as pt,Qe as q,ou as r,Ce as rt,iu as s,u as st,Su as t,ke as tt,Dc as u,g as ut,Ls as v,Rt as w,js as x,ks as y,it as z};
64
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function no(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:io(t,`input`,e.processors),output:io(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function q(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return q(r.element,n);if(r.type===`set`)return q(r.valueType,n);if(r.type===`lazy`)return q(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return q(r.innerType,n);if(r.type===`intersection`)return q(r.left,n)||q(r.right,n);if(r.type===`record`||r.type===`map`)return q(r.keyType,n)||q(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:q(r.in,n)||q(r.out,n);if(r.type===`object`){for(let e in r.shape)if(q(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(q(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(q(e,n))return!0;return!!(r.rest&&q(r.rest,n))}return!1}var ro=(e,t={})=>n=>{let r=eo({...n,processors:t});return K(e,r),to(r,e),no(r,e)},io=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=eo({...i??{},target:a,io:t,processors:n});return K(e,o),to(o,e),no(o,e)},ao={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},oo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ao[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},so=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},co=(e,t,n,r)=>{n.type=`boolean`},lo=(e,t,n,r)=>{n.not={}},uo=(e,t,n,r)=>{let i=e._zod.def,a=Gt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},fo=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},po=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=K(a.element,t,{...r,path:[...r.path,`items`]})},go=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=K(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=K(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},_o=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>K(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},vo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=K(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},yo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},bo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},So=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Co=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},wo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;K(o,t,r);let s=t.seen.get(e);s.ref=o},To=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Eo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Do=R(`ZodISODateTime`,(e,t)=>{Zr.init(e,t),X.init(e,t)});function Oo(e){return xa(Do,e)}var ko=R(`ZodISODate`,(e,t)=>{Qr.init(e,t),X.init(e,t)});function Ao(e){return Sa(ko,e)}var jo=R(`ZodISOTime`,(e,t)=>{$r.init(e,t),X.init(e,t)});function Mo(e){return Ca(jo,e)}var No=R(`ZodISODuration`,(e,t)=>{ei.init(e,t),X.init(e,t)});function Po(e){return wa(No,e)}var J=R(`ZodError`,(e,t)=>{En.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>kn(e,t)},flatten:{value:t=>On(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Kt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Kt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Fo=An(J),Io=jn(J),Lo=Mn(J),Ro=Pn(J),zo=In(J),Bo=Ln(J),Vo=Rn(J),Ho=zn(J),Uo=Bn(J),Wo=Vn(J),Go=Hn(J),Ko=Un(J),qo=new WeakMap;function Jo(e,t,n){let r=Object.getPrototypeOf(e),i=qo.get(r);if(i||(i=new Set,qo.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Y=R(`ZodType`,(e,t)=>(W.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:io(e,`input`),output:io(e,`output`)}}),e.toJSONSchema=ro(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Fo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Lo(e,t,n),e.parseAsync=async(t,n)=>Io(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ro(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>zo(e,t,n),e.decode=(t,n)=>Bo(e,t,n),e.encodeAsync=async(t,n)=>Vo(e,t,n),e.decodeAsync=async(t,n)=>Ho(e,t,n),e.safeEncode=(t,n)=>Uo(e,t,n),e.safeDecode=(t,n)=>Wo(e,t,n),e.safeEncodeAsync=async(t,n)=>Go(e,t,n),e.safeDecodeAsync=async(t,n)=>Ko(e,t,n),Jo(e,`ZodType`,{check(...e){let t=this.def;return this.clone(B(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return V(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ac(e,t))},superRefine(e,t){return this.check(oc(e,t))},overwrite(e){return this.check(Wa(e))},optional(){return Vs(this)},exactOptional(){return Us(this)},nullable(){return Gs(this)},nullish(){return Vs(Gs(this))},nonoptional(e){return Zs(this,e)},array(){return Ds(this)},or(e){return js([this,e])},and(e){return Ns(this,e)},transform(e){return tc(this,zs(e))},default(e){return qs(this,e)},prefault(e){return Ys(this,e)},catch(e){return $s(this,e)},pipe(e){return tc(this,e)},readonly(){return rc(this)},describe(e){let t=this.clone();return Zi.add(t,{description:e}),t},meta(...e){if(e.length===0)return Zi.get(this);let t=this.clone();return Zi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Zi.get(e)?.description},configurable:!0}),e)),Yo=R(`_ZodString`,(e,t)=>{zr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Jo(e,`_ZodString`,{regex(...e){return this.check(Ra(...e))},includes(...e){return this.check(Va(...e))},startsWith(...e){return this.check(Ha(...e))},endsWith(...e){return this.check(Ua(...e))},min(...e){return this.check(Ia(...e))},max(...e){return this.check(Fa(...e))},length(...e){return this.check(La(...e))},nonempty(...e){return this.check(Ia(1,...e))},lowercase(e){return this.check(za(e))},uppercase(e){return this.check(Ba(e))},trim(){return this.check(Ka())},normalize(...e){return this.check(Ga(...e))},toLowerCase(){return this.check(qa())},toUpperCase(){return this.check(Ja())},slugify(){return this.check(Ya())}})}),Xo=R(`ZodString`,(e,t)=>{zr.init(e,t),Yo.init(e,t),e.email=t=>e.check($i(Qo,t)),e.url=t=>e.check(aa(ts,t)),e.jwt=t=>e.check(ba(gs,t)),e.emoji=t=>e.check(oa(ns,t)),e.guid=t=>e.check(ea($o,t)),e.uuid=t=>e.check(ta(es,t)),e.uuidv4=t=>e.check(na(es,t)),e.uuidv6=t=>e.check(ra(es,t)),e.uuidv7=t=>e.check(ia(es,t)),e.nanoid=t=>e.check(sa(rs,t)),e.guid=t=>e.check(ea($o,t)),e.cuid=t=>e.check(ca(is,t)),e.cuid2=t=>e.check(la(as,t)),e.ulid=t=>e.check(ua(os,t)),e.base64=t=>e.check(_a(ps,t)),e.base64url=t=>e.check(va(ms,t)),e.xid=t=>e.check(da(ss,t)),e.ksuid=t=>e.check(fa(cs,t)),e.ipv4=t=>e.check(pa(ls,t)),e.ipv6=t=>e.check(ma(us,t)),e.cidrv4=t=>e.check(ha(ds,t)),e.cidrv6=t=>e.check(ga(fs,t)),e.e164=t=>e.check(ya(hs,t)),e.datetime=t=>e.check(Oo(t)),e.date=t=>e.check(Ao(t)),e.time=t=>e.check(Mo(t)),e.duration=t=>e.check(Po(t))});function Zo(e){return Qi(Xo,e)}var X=R(`ZodStringFormat`,(e,t)=>{G.init(e,t),Yo.init(e,t)}),Qo=R(`ZodEmail`,(e,t)=>{Hr.init(e,t),X.init(e,t)}),$o=R(`ZodGUID`,(e,t)=>{Br.init(e,t),X.init(e,t)}),es=R(`ZodUUID`,(e,t)=>{Vr.init(e,t),X.init(e,t)}),ts=R(`ZodURL`,(e,t)=>{Ur.init(e,t),X.init(e,t)}),ns=R(`ZodEmoji`,(e,t)=>{Wr.init(e,t),X.init(e,t)}),rs=R(`ZodNanoID`,(e,t)=>{Gr.init(e,t),X.init(e,t)}),is=R(`ZodCUID`,(e,t)=>{Kr.init(e,t),X.init(e,t)}),as=R(`ZodCUID2`,(e,t)=>{qr.init(e,t),X.init(e,t)}),os=R(`ZodULID`,(e,t)=>{Jr.init(e,t),X.init(e,t)}),ss=R(`ZodXID`,(e,t)=>{Yr.init(e,t),X.init(e,t)}),cs=R(`ZodKSUID`,(e,t)=>{Xr.init(e,t),X.init(e,t)}),ls=R(`ZodIPv4`,(e,t)=>{ti.init(e,t),X.init(e,t)}),us=R(`ZodIPv6`,(e,t)=>{ni.init(e,t),X.init(e,t)}),ds=R(`ZodCIDRv4`,(e,t)=>{ri.init(e,t),X.init(e,t)}),fs=R(`ZodCIDRv6`,(e,t)=>{ii.init(e,t),X.init(e,t)}),ps=R(`ZodBase64`,(e,t)=>{oi.init(e,t),X.init(e,t)}),ms=R(`ZodBase64URL`,(e,t)=>{ci.init(e,t),X.init(e,t)}),hs=R(`ZodE164`,(e,t)=>{li.init(e,t),X.init(e,t)}),gs=R(`ZodJWT`,(e,t)=>{di.init(e,t),X.init(e,t)}),_s=R(`ZodNumber`,(e,t)=>{fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r),Jo(e,`ZodNumber`,{gt(e,t){return this.check(Ma(e,t))},gte(e,t){return this.check(Na(e,t))},min(e,t){return this.check(Na(e,t))},lt(e,t){return this.check(Aa(e,t))},lte(e,t){return this.check(ja(e,t))},max(e,t){return this.check(ja(e,t))},int(e){return this.check(ys(e))},safe(e){return this.check(ys(e))},positive(e){return this.check(Ma(0,e))},nonnegative(e){return this.check(Na(0,e))},negative(e){return this.check(Aa(0,e))},nonpositive(e){return this.check(ja(0,e))},multipleOf(e,t){return this.check(Pa(e,t))},step(e,t){return this.check(Pa(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),vs=R(`ZodNumberFormat`,(e,t)=>{pi.init(e,t),_s.init(e,t)});function ys(e){return Ea(vs,e)}var bs=R(`ZodBoolean`,(e,t)=>{mi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r)});function xs(e){return Da(bs,e)}var Ss=R(`ZodUnknown`,(e,t)=>{hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Cs(){return Oa(Ss)}var ws=R(`ZodNever`,(e,t)=>{gi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r)});function Ts(e){return ka(ws,e)}var Es=R(`ZodArray`,(e,t)=>{vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.element=t.element,Jo(e,`ZodArray`,{min(e,t){return this.check(Ia(e,t))},nonempty(e){return this.check(Ia(1,e))},max(e,t){return this.check(Fa(e,t))},length(e,t){return this.check(La(e,t))},unwrap(){return this.element}})});function Ds(e,t){return Xa(Es,e,t)}var Os=R(`ZodObject`,(e,t)=>{Ci.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),z(e,`shape`,()=>t.shape),Jo(e,`ZodObject`,{keyof(){return Fs(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Cs()})},loose(){return this.clone({...this._zod.def,catchall:Cs()})},strict(){return this.clone({...this._zod.def,catchall:Ts()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return pn(this,e)},safeExtend(e){return mn(this,e)},merge(e){return hn(this,e)},pick(e){return dn(this,e)},omit(e){return fn(this,e)},partial(...e){return gn(Bs,this,e[0])},required(...e){return _n(Xs,this,e[0])}})});function ks(e,t){return new Os({type:`object`,shape:e??{},...H(t)})}var As=R(`ZodUnion`,(e,t)=>{Ti.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r),e.options=t.options});function js(e,t){return new As({type:`union`,options:e,...H(t)})}var Ms=R(`ZodIntersection`,(e,t)=>{Ei.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r)});function Ns(e,t){return new Ms({type:`intersection`,left:e,right:t})}var Ps=R(`ZodEnum`,(e,t)=>{ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ps({...t,checks:[],...H(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ps({...t,checks:[],...H(r),entries:i})}});function Fs(e,t){return new Ps({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...H(t)})}var Is=R(`ZodLiteral`,(e,t)=>{Ai.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ls(e,t){return new Is({type:`literal`,values:Array.isArray(e)?e:[e],...H(t)})}var Rs=R(`ZodTransform`,(e,t)=>{ji.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ht(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(wn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(wn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function zs(e){return new Rs({type:`transform`,transform:e})}var Bs=R(`ZodOptional`,(e,t)=>{Ni.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vs(e){return new Bs({type:`optional`,innerType:e})}var Hs=R(`ZodExactOptional`,(e,t)=>{Pi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Us(e){return new Hs({type:`optional`,innerType:e})}var Ws=R(`ZodNullable`,(e,t)=>{Fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gs(e){return new Ws({type:`nullable`,innerType:e})}var Ks=R(`ZodDefault`,(e,t)=>{Ii.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qs(e,t){return new Ks({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():on(t)}})}var Js=R(`ZodPrefault`,(e,t)=>{Ri.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ys(e,t){return new Js({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():on(t)}})}var Xs=R(`ZodNonOptional`,(e,t)=>{zi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zs(e,t){return new Xs({type:`nonoptional`,innerType:e,...H(t)})}var Qs=R(`ZodCatch`,(e,t)=>{Vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $s(e,t){return new Qs({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ec=R(`ZodPipe`,(e,t)=>{Hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.in=t.in,e.out=t.out});function tc(e,t){return new ec({type:`pipe`,in:e,out:t})}var nc=R(`ZodReadonly`,(e,t)=>{Wi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rc(e){return new nc({type:`readonly`,innerType:e})}var ic=R(`ZodCustom`,(e,t)=>{Ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r)});function ac(e,t={}){return Za(ic,e,t)}function oc(e,t){return Qa(e,t)}var sc=ks({q:Zo().optional(),plane:Fs([`operator`,`user`]).optional(),kind:Fs([`operator`,`user`,`role`,`key`,`invite`]).optional(),id:Zo().optional(),view:Fs([`detail`,`effective`,`create-key`,`grant-role`]).optional()});function cc(e){let t=sc.safeParse(e);return t.success?t.data:{}}function lc(e){let t={};return e.q&&(t.q=e.q),e.plane&&(t.plane=e.plane),e.kind&&(t.kind=e.kind),e.id&&(t.id=e.id),e.view&&(t.view=e.view),t}function uc(e,t,n,r){return{...e,plane:t,kind:n,id:r,view:`detail`}}function dc(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis),r=t.retry?.retries??0,i=t.retry?.delay??50,a=t.retry?.backoff??2;return{async call(o,s){let c=!1,l=0,u=i;for(;;)try{let r=await fc(e,o,s,t,n);if(r.status===401&&t.auth?.refresh&&!c){c=!0,await t.auth.refresh();continue}return hc(r)}catch(e){if(!gc(e)||l>=r)return{data:null,error:{code:`TransportError`,data:{message:e instanceof Error?e.message:String(e)}}};await _c(u),u*=a,l+=1}}}}async function fc(e,t,n,r,i){let a=r.routes?.[t.replace(`/`,`.`)],{url:o,method:s,body:c}=a?mc(e,a.method,a.path,n):pc(e,t,n),l=new Headers,u=typeof r.headers==`function`?await r.headers():r.headers;if(Array.isArray(u))for(let[e,t]of u)l.set(e,t);else if(u)for(let[e,t]of Object.entries(u))l.set(e,t);c!==void 0&&!l.has(`content-type`)&&l.set(`content-type`,`application/json`);let d=r.auth?await r.auth.getToken():void 0;d&&!l.has(`authorization`)&&l.set(`authorization`,`Bearer ${d}`);let f=r.timeout===void 0?void 0:new AbortController,p=f&&r.timeout!==void 0?setTimeout(()=>f.abort(),r.timeout):void 0;try{let e=await i(o,{method:s,headers:l,body:c,signal:f?.signal});if(e.status>=500)throw Error(`HTTP ${e.status}`);return e}finally{p!==void 0&&clearTimeout(p)}}function pc(e,t,n){return{url:`${e}/_oke/${t}`,method:`POST`,body:n===void 0?void 0:JSON.stringify(n??{})}}function mc(e,t,n,r){let i=typeof r==`object`&&r?r:{},a=n,o=[],s={};for(let[e,t]of Object.entries(i)){let n=`:${e}`;a.includes(n)?a=a.replaceAll(n,encodeURIComponent(String(t))):s[e]=t}let c=t.toUpperCase(),l;if(c===`GET`||c===`HEAD`)for(let[e,t]of Object.entries(s))t!==void 0&&o.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(t))}`);else(Object.keys(s).length>0||n===a)&&(l=JSON.stringify(Object.keys(s).length>0?s:r??{}));let u=o.length?`?${o.join(`&`)}`:``;return{url:`${e}${a}${u}`,method:c,body:l}}async function hc(e){if(e.status===204)return{data:void 0,error:null};let t=await e.text();if(!t)return e.ok?{data:void 0,error:null}:{data:null,error:{code:`TransportError`,data:{message:`HTTP ${e.status}`,status:e.status}}};let n;try{n=JSON.parse(t)}catch{return{data:null,error:{code:`TransportError`,data:{message:`Invalid JSON (${e.status})`,status:e.status}}}}return typeof n==`object`&&n&&`data`in n&&`error`in n?n:e.ok?{data:n,error:null}:{data:null,error:{code:`TransportError`,data:{message:`HTTP ${e.status}`,status:e.status}}}}function gc(e){return!(!(e instanceof Error)||e.name===`AbortError`)}function _c(e){return new Promise(t=>setTimeout(t,e))}function vc(e,t,n){if(typeof e==`string`)return yc(e,t);let r=typeof t==`string`?t:``,i=typeof t==`string`?n:t;return yc(r,{...i,$routes:i?.$routes??e.$routes})}function yc(e,t={}){let n=e.replace(/\/+$/,``),r=t.routes??bc(t.$routes);return xc(dc(n,{...t,routes:r}),[])}function bc(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(!(!r||typeof r!=`object`))for(let[e,i]of Object.entries(r)){if(!i||typeof i!=`object`)continue;let r=`method`in i?i.method:void 0,a=`path`in i?i.path:void 0;typeof r==`string`&&typeof a==`string`&&(t[`${n}.${e}`]={method:r,path:a})}return Object.keys(t).length>0?t:void 0}function xc(e,t){return new Proxy(n=>{if(t.length<2)return Promise.resolve({data:null,error:{code:`TransportError`,data:{message:`Incomplete path: api.${t.join(`.`)||`?`}(…)`}}});let r=t[0],i=t.slice(1).join(`.`);return e.call(`${r}/${i}`,n)},{get(n,r,i){if(typeof r==`symbol`)return Reflect.get(n,r,i);if(r!==`then`)return xc(e,[...t,r])}})}var Sc=null;function Cc(e){Sc=e,e?sessionStorage.setItem(`oke_console_at`,e):sessionStorage.removeItem(`oke_console_at`)}function wc(){Sc=sessionStorage.getItem(`oke_console_at`)}var Z=vc(globalThis.location===void 0?`http://127.0.0.1:6533`:globalThis.location.origin,{headers:()=>Sc?{Authorization:`Bearer ${Sc}`}:{},routes:{"console.setupStatus":{method:`GET`,path:`/console/setup/status`},"console.setupClaim":{method:`POST`,path:`/console/setup/claim`},"console.sessionLogin":{method:`POST`,path:`/console/session/login`},"console.sessionMe":{method:`GET`,path:`/console/session/me`},"console.sessionLogout":{method:`POST`,path:`/console/session/logout`},"console.manifestGet":{method:`GET`,path:`/console/manifest`},"console.runsList":{method:`GET`,path:`/console/runs`},"console.actionPing":{method:`POST`,path:`/console/action/ping`},"console.structuralPropose":{method:`POST`,path:`/console/structural/propose`},"console.flowsIdentities":{method:`GET`,path:`/console/flows/identities`},"console.flowsInvoke":{method:`POST`,path:`/console/flows/invoke`},"console.tracesReplay":{method:`POST`,path:`/console/traces/replay`},"console.signalsList":{method:`GET`,path:`/console/signals`},"console.signalsReplay":{method:`POST`,path:`/console/signals/replay`},"console.signalsDryRunReplay":{method:`POST`,path:`/console/signals/dry-run-replay`},"console.signalsDiscard":{method:`POST`,path:`/console/signals/discard`},"console.storeList":{method:`GET`,path:`/console/store`},"console.storeQuery":{method:`POST`,path:`/console/store/query`},"console.storeReveal":{method:`POST`,path:`/console/store/reveal`},"console.storeEdit":{method:`POST`,path:`/console/store/edit`},"console.storeDelete":{method:`POST`,path:`/console/store/delete`},"console.storePurgeCache":{method:`POST`,path:`/console/store/purge-cache`},"console.storeSql":{method:`POST`,path:`/console/store/sql`},"console.storePreview":{method:`POST`,path:`/console/store/preview`},"console.vaultList":{method:`GET`,path:`/console/vault`},"console.vaultSet":{method:`POST`,path:`/console/vault/set`},"console.vaultRotate":{method:`POST`,path:`/console/vault/rotate`},"console.aiList":{method:`GET`,path:`/console/ai`},"console.clockList":{method:`GET`,path:`/console/clock`},"console.clockRunNow":{method:`POST`,path:`/console/clock/run-now`},"console.clockPause":{method:`POST`,path:`/console/clock/pause`},"console.clockEditSchedule":{method:`POST`,path:`/console/clock/edit-schedule`},"console.clockWakeEarly":{method:`POST`,path:`/console/clock/wake-early`},"console.channelsList":{method:`GET`,path:`/console/channels`},"console.channelPreview":{method:`POST`,path:`/console/channels/preview`},"console.channelVerifyAuth":{method:`POST`,path:`/console/channels/verify-auth`},"console.channelReveal":{method:`POST`,path:`/console/channels/reveal`},"console.channelSendTest":{method:`POST`,path:`/console/channels/send-test`},"console.gatesList":{method:`GET`,path:`/console/gates`},"console.gatesSimulate":{method:`POST`,path:`/console/gates/simulate`},"console.gatesPowers":{method:`POST`,path:`/console/gates/powers`},"console.accessList":{method:`GET`,path:`/console/access`},"console.accessEffective":{method:`POST`,path:`/console/access/effective`},"console.accessKeyBlast":{method:`POST`,path:`/console/access/key-blast`},"console.accessCreateKey":{method:`POST`,path:`/console/access/keys`},"console.accessRevokeKey":{method:`POST`,path:`/console/access/keys/revoke`},"console.accessRotateKey":{method:`POST`,path:`/console/access/keys/rotate`},"console.accessSetRoleGrants":{method:`POST`,path:`/console/access/roles/grants`},"console.diffList":{method:`GET`,path:`/console/diff`},"console.pluginsList":{method:`GET`,path:`/console/plugins`}}}),Tc={async setupStatus(){return Z.console.setupStatus({})},async setupClaim(e){return Z.console.setupClaim(e)},async sessionLogin(e){return Z.console.sessionLogin(e)},async sessionMe(){return Z.console.sessionMe({})},async actionPing(e){return Z.console.actionPing({note:e})},async runsList(){return Z.console.runsList({})},async manifestGet(){return Z.console.manifestGet({})},async flowsIdentities(){return Z.console.flowsIdentities({})},async flowsInvoke(e){return Z.console.flowsInvoke(e)},async tracesReplay(e){return Z.console.tracesReplay(e)},async signalsList(){return Z.console.signalsList({})},async signalsReplay(e){return Z.console.signalsReplay(e)},async signalsDryRunReplay(e){return Z.console.signalsDryRunReplay(e)},async signalsDiscard(e){return Z.console.signalsDiscard(e)},async storeList(){return Z.console.storeList({})},async storeQuery(e){return Z.console.storeQuery(e)},async storeReveal(e){return Z.console.storeReveal(e)},async storeEdit(e){return Z.console.storeEdit(e)},async storeDelete(e){return Z.console.storeDelete(e)},async storePurgeCache(e){return Z.console.storePurgeCache(e)},async storeSql(e){return Z.console.storeSql(e)},async storePreview(e){return Z.console.storePreview(e)},async vaultList(){return Z.console.vaultList({})},async vaultSet(e){return Z.console.vaultSet(e)},async vaultRotate(e){return Z.console.vaultRotate(e)},async aiList(){return Z.console.aiList({})},async clockList(){return Z.console.clockList({})},async clockRunNow(e){return Z.console.clockRunNow(e)},async clockPause(e){return Z.console.clockPause(e)},async clockEditSchedule(e){return Z.console.clockEditSchedule(e)},async clockWakeEarly(e){return Z.console.clockWakeEarly(e)},async channelsList(){return Z.console.channelsList({})},async channelPreview(e){return Z.console.channelPreview(e)},async channelVerifyAuth(e){return Z.console.channelVerifyAuth(e)},async channelReveal(e){return Z.console.channelReveal(e)},async channelSendTest(e){return Z.console.channelSendTest(e)},async gatesList(){return Z.console.gatesList({})},async gatesSimulate(e){return Z.console.gatesSimulate(e)},async gatesPowers(e){return Z.console.gatesPowers(e)},async accessList(){return Z.console.accessList({})},async accessEffective(e){return Z.console.accessEffective(e)},async accessKeyBlast(e){return Z.console.accessKeyBlast(e)},async accessCreateKey(e){return Z.console.accessCreateKey(e)},async accessRevokeKey(e){return Z.console.accessRevokeKey(e)},async accessRotateKey(e){return Z.console.accessRotateKey(e)},async accessSetRoleGrants(e){return Z.console.accessSetRoleGrants(e)},async diffList(){return Z.console.diffList({})},async pluginsList(){return Z.console.pluginsList({})}};function Ec(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ec(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Dc(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ec(e))&&(r&&(r+=` `),r+=t);return r}function Oc(){return typeof window<`u`}function kc(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ac(e){return Oc()?e instanceof Element||e instanceof kc(e).Element:!1}function jc(e){return Oc()?e instanceof HTMLElement||e instanceof kc(e).HTMLElement:!1}var Mc={...I},Nc={};function Pc(e,t){let n=I.useRef(Nc);return n.current===Nc&&(n.current=e(t)),n}var Fc=Mc.useInsertionEffect,Ic=Fc&&Fc!==Mc.useLayoutEffect?Fc:e=>e();function Lc(e){let t=Pc(Rc).current;return t.next=e,Ic(t.effect),t.trampoline}function Rc(){let e={next:void 0,callback:zc,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function zc(){}var Bc=typeof document<`u`?I.useLayoutEffect:()=>{};function Vc(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}var Hc={};function Uc(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Gc(t);let a=Gc(e);return t&&(a=Kc(a,t)),n&&(a=Kc(a,n)),r&&(a=Kc(a,r)),i&&(a=Kc(a,i)),a}function Wc(e){if(e.length===0)return Hc;if(e.length===1)return Gc(e[0]);let t=Gc(e[0]);for(let n=1;n<e.length;n+=1)t=Kc(t,e[n]);return t}function Gc(e){return Xc(e)?{...Zc(e,Hc)}:qc(e)}function Kc(e,t){return Xc(t)?Zc(t,e):Jc(e,t)}function qc(e){let t={...e};for(let e in t){let n=t[e];Yc(e,n)&&(t[e]=$c(n))}return t}function Jc(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Vc(e.style,r);break;case`className`:e[n]=tl(e.className,r);break;default:Yc(n,r)?e[n]=Qc(e[n],r):e[n]=r}}return e}function Yc(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Xc(e){return typeof e==`function`}function Zc(e,t){return Xc(e)?e(t):e??Hc}function Qc(e,t){return t?e?(...n)=>{let r=n[0];if(nl(r)){let i=r;el(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:$c(t):e}function $c(e){return e&&((...t)=>{let n=t[0];return nl(n)&&el(n),e(...t)})}function el(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function tl(e,t){return t?e?t+` `+e:t:e}function nl(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function rl(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var il=rl(`https://base-ui.com/production-error`,`Base UI`),al=I.createContext(void 0);function ol(e=!1){let t=I.useContext(al);if(t===void 0&&!e)throw Error(il(16));return t}function sl(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:I.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function cl(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=I.useRef(null),s=ol(!0),c=a??s!==void 0,{props:l}=sl({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=I.useCallback(()=>{let e=o.current;ll(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return Bc(u,[u]),{getButtonProps:I.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return Uc({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(el(e),o?.(e),e.baseUIHandlerPrevented))return;let r=e.target===e.currentTarget,a=e.currentTarget,s=ll(a),l=!i&&ul(a),u=r&&(i?s:!l),d=e.key===`Enter`,f=e.key===` `,p=a.getAttribute(`role`),m=p?.startsWith(`menuitem`)||p===`option`||p===`gridcell`;if(r&&c&&f){if(e.defaultPrevented&&m)return;e.preventDefault(),l||i&&s?(a.click(),e.preventBaseUIHandler()):u&&(n?.(e),e.preventBaseUIHandler());return}u&&(!i&&(f||d)&&e.preventDefault(),!i&&d&&n?.(e))},onKeyUp(e){if(!t){if(el(e),a?.(e),e.target===e.currentTarget&&i&&c&&ll(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&e.key===` `&&n?.(e)}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Lc(e=>{o.current=e,u()})}}function ll(e){return jc(e)&&e.tagName===`BUTTON`}function ul(e){return!!(e?.tagName===`A`&&e?.href)}function dl(e,t,n,r){let i=Pc(pl).current;return ml(i,e,t,n,r)&&gl(i,[e,t,n,r]),i.callback}function fl(e){let t=Pc(pl).current;return hl(t,e)&&gl(t,e),t.callback}function pl(){return{callback:null,cleanup:null,refs:[]}}function ml(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function hl(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function gl(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var _l=19;function vl(e){return _l>=e}function yl(e){if(!I.isValidElement(e))return null;let t=e,n=t.props;return(vl(19)?n?.ref:t.ref)??null}function Q(){}Object.freeze([]);var bl=Object.freeze({});function xl(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Sl(e,t){return typeof e==`function`?e(t):e}function Cl(e,t){return typeof e==`function`?e(t):e}function wl(e,t,n={}){let r=t.render,i=Tl(t,n);return n.enabled===!1?null:Ol(e,r,i,n.state??bl)}function Tl(e,t={}){let{className:n,style:r,render:i}=e,{state:a=bl,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Sl(n,a):void 0,d=l?Cl(r,a):void 0,f=l?xl(a,c):bl,p=l&&s?El(s):void 0,m=l?Vc(f,p)??{}:bl;return typeof document<`u`&&(l?Array.isArray(o)?m.ref=fl([m.ref,yl(i),...o]):m.ref=dl(m.ref,yl(i),o):dl(null,null)),l?(u!==void 0&&(m.className=tl(m.className,u)),d!==void 0&&(m.style=Vc(m.style,d)),m):bl}function El(e){return Array.isArray(e)?Wc(e):Uc(void 0,e)}var Dl=Symbol.for(`react.lazy`);function Ol(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Uc(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===Dl&&(i=I.Children.toArray(t)[0]),I.cloneElement(i,e)}if(e&&typeof e==`string`)return kl(e,n);throw Error(il(8))}function kl(e,t){return e===`button`?(0,I.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,I.createElement)(`img`,{alt:``,...t,key:t.key}):I.createElement(e,t)}var Al=I.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=cl({disabled:i,focusableWhenDisabled:a,native:o});return wl(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),jl=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Ml={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Nl={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Pl={disabled:!1,...Nl},Fl={valid(e){return e===null?null:e?{[jl.valid]:``}:{[jl.invalid]:``}}},Il={invalid:void 0,name:void 0,validityData:{state:Ml,errors:[],error:``,value:``,initialValue:null},setValidityData:Q,disabled:void 0,touched:Nl.touched,setTouched:Q,dirty:Nl.dirty,setDirty:Q,filled:Nl.filled,setFilled:Q,focused:Nl.focused,setFocused:Q,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:Pl,markedDirtyRef:{current:!1},registerFieldControl:Q,validation:{getValidationProps:(e,t=bl)=>t,inputRef:{current:null},registerInput:Q,commit:async()=>{},change:Q}},Ll=I.createContext(Il);function Rl(e=!0){let t=I.useContext(Ll);if(t.setValidityData===Q&&!e)throw Error(il(28));return t}var zl=I.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Q,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function Bl(){return I.useContext(zl)}var Vl=0;function Hl(e,t=`mui`){let[n,r]=I.useState(e),i=e||n;return I.useEffect(()=>{n??(Vl+=1,r(`${t}-${Vl}`))},[n,t]),i}var Ul=Mc.useId;function Wl(e,t){if(Ul!==void 0){let n=Ul();return e??(t?`${t}-${n}`:n)}return Hl(e,t)}function Gl(e){return Wl(e,`base-ui`)}var Kl=I.createContext({controlId:void 0,registerControlId:Q,labelId:void 0,setLabelId:Q,messageIds:[],setMessageIds:Q,getDescriptionProps:e=>e});function ql(){return I.useContext(Kl)}function Jl(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=ql(),o=Gl(t),s=n?i:void 0,c=Pc(()=>Symbol(`labelable-control`)),l=I.useRef(!1),u=I.useRef(t!=null),d=Lc(()=>{!l.current||a===Q||(l.current=!1,a(c.current,void 0))});return Bc(()=>{if(a===Q)return;let e;if(n){let n=r?.current;e=Ac(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),I.useEffect(()=>d,[d]),i??o}function Yl(e){return e?.ownerDocument||document}function Xl(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Zl({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=I.useRef(e!==void 0),[a,o]=I.useState(t);return[i?e:a,I.useCallback(e=>{i||o(e)},[])]}function Ql(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Rl(),s=I.useRef(null);s.current||=Symbol(),Bc(()=>{let c=s.current;if(!(!c||!i))return o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}),()=>{o(c,void 0)}},[e,i,r,t,a,o,n])}var $l=`none`;function eu(e,t,n,r){let i=!1,a=!1,o=r??bl;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var tu=I.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=Rl(),{clearErrors:C}=Bl(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=ql(),O=Jl({id:i});Bc(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=I.useRef(null);Bc(()=>{u&&k.current===Xl(Yl(k.current))&&y(!0)},[u,y]);let[A]=Zl({controlled:o,default:l,name:`FieldControl`,state:`value`}),ee=o!==void 0,j=ee?A:void 0,M=Lc(()=>S.inputRef.current?.value);return Ql(S.inputRef,O,j,M,!w,a),wl(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...ee?{value:j}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,eu($l,e.nativeEvent)),_(t!==v.initialValue),b(t!==``),e.nativeEvent.defaultPrevented||(C(T),S.change(t))},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},f,e=>S.getValidationProps(w,e)],stateAttributesMapping:Fl})}),nu=I.forwardRef(function(e,t){return(0,L.jsx)(tu,{ref:t,...e})});function $({variant:e=`primary`,className:t,...n}){return(0,L.jsx)(Al,{className:Dc(`inline-flex min-h-8 min-w-8 items-center justify-center px-3 text-sm font-medium transition-opacity duration-150`,`disabled:opacity-40`,e===`primary`&&`bg-[var(--oke-accent)] text-black`,e===`ghost`&&`bg-transparent text-[var(--oke-fg)] border border-[var(--oke-line)]`,e===`danger`&&`bg-[var(--oke-danger)] text-white`,e===`external`&&`bg-[var(--oke-external)] text-black`,t),...n})}function ru({className:e,...t}){return(0,L.jsx)(nu,{className:Dc(`min-h-8 w-full border border-[var(--oke-line)] bg-transparent px-3 text-sm text-[var(--oke-fg)]`,`placeholder:text-[var(--oke-muted)]`,e),...t})}function iu({label:e,error:t,children:n}){return(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:e}),n,t?(0,L.jsx)(`span`,{role:`alert`,className:`text-xs text-[var(--oke-danger)]`,children:t}):null]})}function au({count:e,onFlush:t}){return e<=0?null:(0,L.jsxs)(`button`,{type:`button`,className:`min-h-8 rounded-sm border border-[var(--oke-line)] px-3 text-xs text-[var(--oke-fg)]`,onClick:t,children:[e,` new`]})}var ou=15e3;function su(e,t={production:!0}){return e===`external`&&t.production?{kind:`typed`,phrase:`INVOKE`,requireReason:!0}:{kind:`undo`,windowMs:ou}}function cu(e){let t={};return e.typed.trim()!==e.phrase&&(t.typed=`Type ${e.phrase} to confirm`),e.reason.trim().length<3&&(t.reason=`Reason is required (min 3 characters)`),Object.keys(t).length>0?t:null}function lu(e={production:!0}){return{kind:`typed`,phrase:`REVOKE`,requireReason:!0}}function uu(e={production:!0}){return{kind:`typed`,phrase:`ROTATE`,requireReason:!0}}function du(e){return e.acknowledged===!0}var fu=`I have copied this secret and understand it will not be shown again`,pu=`This secret is shown exactly once. Store it now — dismissal is permanent.`;function mu(e){return{volume:e.callVolume===0?`No recorded calls from Runs`:`${e.callVolume} call${e.callVolume===1?``:`s`} in Runs`,lastUsed:e.lastUsedAt==null?`Never used`:`Last used ${new Date(e.lastUsedAt).toISOString()}`,sources:e.sourceAddresses.length===0?`No source addresses recorded`:`Source addresses: ${e.sourceAddresses.join(`, `)}`,residual:e.residualAccessNote,warn:e.callVolume>0}}function hu(e){let t=[];return e.unusedKeys.length>0&&t.push({code:`unused-keys`,message:`${e.unusedKeys.length} key${e.unusedKeys.length===1?``:`s`} unused 90d+`}),e.neverSignedInOperators.length>0&&t.push({code:`never-signed-in`,message:`${e.neverSignedInOperators.length} operator${e.neverSignedInOperators.length===1?``:`s`} never signed in`}),e.expiredInvitations.length>0&&t.push({code:`expired-invites`,message:`${e.expiredInvitations.length} expired invitation${e.expiredInvitations.length===1?``:`s`}`}),t}function gu(e){return e.scopes.map(e=>({scope:e.scope,sources:e.sources.map(e=>e.kind===`direct`?`direct (${e.name})`:`role ${e.name}`).join(`, `)}))}function _u(){let e=Rt({from:`/access`}),t=zt({from:`/access`}),n=je(),r=e.plane??`operator`,[i,a]=(0,I.useState)([]),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(null),v=e=>{t({search:lc(e),replace:!0})},y=Ke({queryKey:[`console.access.list`],queryFn:async()=>{let e=await Tc.accessList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}).data,b=r===`operator`?y?.operatorPlane:y?.userPlane,x=b?.grantableScopes??[],S=y?.hygiene,C=(0,I.useMemo)(()=>S?hu(S):[],[S]),w=b?.keys.find(t=>e.kind===`key`&&t.id===e.id),T=b?.roles.find(t=>e.kind===`role`&&t.id===e.id),E=b?.operators?.find(t=>e.kind===`operator`&&t.id===e.id),D=b?.users?.find(t=>e.kind===`user`&&t.id===e.id),O=(e.q??``).toLowerCase(),k=e=>O.length===0||e.toLowerCase().includes(O),A=qe({mutationFn:async()=>{if(!o.trim())throw Error(`Name required`);let e=await Tc.accessCreateKey({plane:r,name:o.trim(),scopes:i});if(e.error)throw Error(e.error.code);return e.data},onSuccess:e=>{p({secret:e.secret,keyId:e.key.id,keyName:e.key.name,acknowledged:!1}),s(``),a([]),n.invalidateQueries({queryKey:[`console.access.list`]})}}),ee=qe({mutationFn:async e=>{let t=await Tc.accessKeyBlast({keyId:e});if(t.error)throw Error(t.error.code);return t.data},onSuccess:h}),j=qe({mutationFn:async()=>{if(!w)throw Error(`Select a key`);let e=lu();if(e.kind===`typed`){let t=cu({typed:c,reason:u,phrase:e.phrase});if(t)throw Error(t.typed??t.reason??`confirm`)}let t=await Tc.accessRevokeKey({keyId:w.id,confirmation:c,reason:u});if(t.error)throw Error(t.error.code);return t.data},onSuccess:e=>{h(e.blastRadius),l(``),d(``),n.invalidateQueries({queryKey:[`console.access.list`]})}}),M=qe({mutationFn:async()=>{if(!w)throw Error(`Select a key`);let e=uu();if(e.kind===`typed`){let t=cu({typed:c,reason:u,phrase:e.phrase});if(t)throw Error(t.typed??t.reason??`confirm`)}let t=await Tc.accessRotateKey({keyId:w.id,confirmation:c,reason:u});if(t.error)throw Error(t.error.code);return t.data},onSuccess:e=>{h(e.blastRadius),p({secret:e.secret,keyId:e.key.id,keyName:e.key.name,acknowledged:!1}),l(``),d(``),n.invalidateQueries({queryKey:[`console.access.list`]})}}),N=qe({mutationFn:async()=>{let t=e.kind===`invite`||!e.kind||!e.id?null:e.kind;if(!t||!e.id)throw Error(`Select a principal`);let n=await Tc.accessEffective({kind:t,id:e.id});if(n.error)throw Error(n.error.code);return n.data},onSuccess:_}),te=qe({mutationFn:async()=>{if(!T)throw Error(`Select a role`);let e=await Tc.accessSetRoleGrants({roleId:T.id,scopes:i});if(e.error)throw Error(e.error.code);return e.data},onSuccess:()=>{n.invalidateQueries({queryKey:[`console.access.list`]})}}),P=m?mu(m):null,ne=g?gu(g):[],F=e=>{a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-3 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-lg font-medium text-[var(--oke-fg)]`,children:`Access`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Identities, roles, API keys — planes never merge`})]}),(0,L.jsxs)(`div`,{role:`group`,"aria-label":`Plane`,className:`flex gap-1`,children:[(0,L.jsx)($,{type:`button`,variant:r===`operator`?`primary`:`ghost`,"aria-pressed":r===`operator`,onClick:()=>v({...e,plane:`operator`,kind:void 0,id:void 0,view:void 0}),children:`Operator plane`}),(0,L.jsx)($,{type:`button`,variant:r===`user`?`primary`:`ghost`,"aria-pressed":r===`user`,onClick:()=>v({...e,plane:`user`,kind:void 0,id:void 0,view:void 0}),children:`User plane`})]}),(0,L.jsxs)(`label`,{className:`ml-auto flex min-w-[12rem] flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter access`}),(0,L.jsx)(ru,{"aria-label":`Filter access`,value:e.q??``,onChange:t=>v({...e,q:t.currentTarget.value||void 0})})]})]}),C.length>0?(0,L.jsxs)(`section`,{"aria-label":`Access hygiene`,className:`border-b border-[var(--oke-line)] px-4 py-2`,role:`status`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Hygiene`}),(0,L.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-[var(--oke-warn,var(--oke-muted))]`,children:C.map(e=>(0,L.jsx)(`li`,{children:e.message},e.code))})]}):null,(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,L.jsxs)(`section`,{"aria-label":`${r} plane list`,className:`w-80 shrink-0 overflow-y-auto border-r border-[var(--oke-line)]`,children:[(0,L.jsx)(`h2`,{className:`px-4 py-2 text-sm font-medium`,children:r===`operator`?`Operator plane`:`User plane`}),b?.operators?(0,L.jsx)(vu,{label:`Operators`,children:b.operators.filter(e=>k(`${e.name} ${e.email}`)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`operator`&&e.id===t.id,onClick:()=>v(uc(e,`operator`,`operator`,t.id)),children:[t.name,t.neverSignedIn?(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · never`}):null]},t.id))}):null,b?.users?(0,L.jsx)(vu,{label:`Users`,children:b.users.filter(e=>k(`${e.name} ${e.email}`)).map(t=>(0,L.jsx)(yu,{selected:e.kind===`user`&&e.id===t.id,onClick:()=>v(uc(e,`user`,`user`,t.id)),children:t.name},t.id))}):null,(0,L.jsx)(vu,{label:`Roles`,children:(b?.roles??[]).filter(e=>k(e.name)).map(t=>(0,L.jsx)(yu,{selected:e.kind===`role`&&e.id===t.id,onClick:()=>{a([...t.scopes]),v(uc(e,r,`role`,t.id))},children:t.name},t.id))}),(0,L.jsx)(vu,{label:`API keys`,children:(b?.keys??[]).filter(e=>k(e.name)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`key`&&e.id===t.id,onClick:()=>{h(null),v(uc(e,r,`key`,t.id)),ee.mutate(t.id)},children:[t.name,t.unused90d?(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · 90d+`}):null,t.revokedAt==null?null:(0,L.jsx)(`span`,{className:`text-[var(--oke-danger)]`,children:` · revoked`})]},t.id))}),b?.invites&&b.invites.length>0?(0,L.jsx)(vu,{label:`Invitations`,children:b.invites.filter(e=>k(e.email)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`invite`&&e.id===t.id,onClick:()=>v(uc(e,`operator`,`invite`,t.id)),children:[t.email,t.expired?(0,L.jsx)(`span`,{className:`text-[var(--oke-danger)]`,children:` · expired`}):null]},t.id))}):null,(0,L.jsx)(`div`,{className:`border-t border-[var(--oke-line)] p-3`,children:(0,L.jsx)($,{type:`button`,variant:`ghost`,className:`w-full`,onClick:()=>{a([]),s(``),v({...e,plane:r,view:`create-key`,kind:void 0,id:void 0})},children:`Create API key`})})]}),(0,L.jsxs)(`section`,{"aria-label":`Access detail`,className:`min-w-0 flex-1 overflow-y-auto px-4 py-3`,"aria-live":`polite`,children:[e.view===`create-key`?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:`Create API key`}),(0,L.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[`Only scopes you hold on the `,r,` plane are shown — impossibility taught by absence. No preview.`]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Name`}),(0,L.jsx)(ru,{"aria-label":`API key name`,value:o,onChange:e=>s(e.currentTarget.value)})]}),(0,L.jsx)(bu,{grantable:x,selected:i,onToggle:F}),(0,L.jsx)($,{type:`button`,disabled:A.isPending||!o.trim(),onClick:()=>A.mutate(),children:`Create key`}),A.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:A.error.message}):null]}):w?(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:w.name}),(0,L.jsx)(`p`,{className:`font-mono text-sm text-[var(--oke-muted)]`,children:w.id}),(0,L.jsx)(`ul`,{className:`mt-2 font-mono text-sm`,children:w.scopes.map(e=>(0,L.jsx)(`li`,{children:e},e))})]}),(0,L.jsxs)(`section`,{"aria-label":`Revocation blast radius`,className:`space-y-1`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Revocation blast radius`}),P?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-sm`,role:P.warn?`alert`:`status`,children:P.volume}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:P.lastUsed}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:P.sources}),(0,L.jsx)(`p`,{className:`text-sm`,role:`status`,children:P.residual})]}):(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`})]}),w.revokedAt==null?(0,L.jsxs)(`section`,{"aria-label":`Revoke or rotate`,className:`space-y-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Revoke / rotate`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Irreversible. Type the phrase and a reason. No dry-run.`}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Type REVOKE or ROTATE`}),(0,L.jsx)(ru,{"aria-label":`Type REVOKE or ROTATE to confirm`,value:c,onChange:e=>l(e.currentTarget.value),autoComplete:`off`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Reason`}),(0,L.jsx)(ru,{"aria-label":`Reason`,value:u,onChange:e=>d(e.currentTarget.value)})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)($,{type:`button`,variant:`danger`,disabled:j.isPending,onClick:()=>j.mutate(),children:`Revoke key`}),(0,L.jsx)($,{type:`button`,variant:`danger`,disabled:M.isPending,onClick:()=>M.mutate(),children:`Rotate key`})]}),j.error||M.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:(j.error??M.error).message}):null]}):(0,L.jsxs)(`p`,{role:`status`,className:`text-sm text-[var(--oke-danger)]`,children:[`Revoked `,w.revokedAt?new Date(w.revokedAt).toISOString():``]}),(0,L.jsx)($,{type:`button`,variant:`ghost`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):T?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:T.name}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:T.description}),(0,L.jsx)(bu,{grantable:x,selected:i,onToggle:F}),(0,L.jsx)($,{type:`button`,disabled:te.isPending,onClick:()=>te.mutate(),children:`Save role grants`}),(0,L.jsx)($,{type:`button`,variant:`ghost`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):E||D?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:E?.name??D?.name}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:E?.email??D?.email}),(0,L.jsx)($,{type:`button`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):e.view===`effective`&&ne.length>0?(0,L.jsx)(xu,{provenance:ne}):(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Choose an identity, role, or key. Planes stay separate; scopes you cannot grant do not appear.`}),e.view===`effective`&&ne.length>0&&(w||T||E||D)?(0,L.jsx)(`div`,{className:`mt-6`,children:(0,L.jsx)(xu,{provenance:ne})}):null]})]}),f?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,role:`presentation`,children:(0,L.jsxs)(`section`,{"aria-label":`New API key secret`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`once-secret-title`,className:`max-w-lg space-y-4 border border-[var(--oke-line)] bg-[var(--oke-bg)] p-6`,children:[(0,L.jsx)(`h2`,{id:`once-secret-title`,className:`text-lg font-medium`,children:`New API key secret`}),(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:pu}),(0,L.jsx)(`p`,{className:`break-all font-mono text-sm`,children:f.secret}),(0,L.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:f.acknowledged,onChange:e=>p({...f,acknowledged:e.currentTarget.checked})}),(0,L.jsx)(`span`,{children:fu})]}),(0,L.jsx)($,{type:`button`,disabled:!du(f),onClick:()=>p(null),children:`Dismiss secret`})]})}):null]})}function vu({label:e,children:t}){return(0,L.jsxs)(`section`,{"aria-label":e,className:`border-t border-[var(--oke-line)]`,children:[(0,L.jsx)(`h3`,{className:`px-4 py-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:e}),(0,L.jsx)(`ul`,{className:`pb-2`,children:t})]})}function yu({selected:e,onClick:t,children:n}){return(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:Dc(`flex min-h-8 w-full items-center px-4 text-left text-sm`,e?`bg-[var(--oke-accent)]/15 text-[var(--oke-fg)]`:`text-[var(--oke-fg)]`),children:n})})}function bu({grantable:e,selected:t,onToggle:n}){return(0,L.jsxs)(`section`,{"aria-label":`Grantable scopes`,className:`space-y-2`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Grantable scopes`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Only scopes you hold appear`}),e.length===0?(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-[var(--oke-muted)]`,children:`No grantable scopes on this plane`}):(0,L.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`label`,{className:`flex min-h-8 items-center gap-2 font-mono text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:t.includes(e),onChange:()=>n(e)}),e]})},e))})]})}function xu({provenance:e}){return(0,L.jsxs)(`section`,{"aria-label":`Effective permissions`,children:[(0,L.jsx)(`h2`,{className:`mb-2 text-lg font-medium`,children:`Effective permissions`}),(0,L.jsx)(`p`,{className:`mb-3 text-sm text-[var(--oke-muted)]`,children:`Every permission with provenance — inverse of the Gates simulator`}),(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`caption`,{className:`sr-only`,children:`Effective permissions with provenance`}),(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-[var(--oke-line)]`,children:[(0,L.jsx)(`th`,{scope:`col`,className:`py-2 pr-4 font-medium`,children:`Scope`}),(0,L.jsx)(`th`,{scope:`col`,className:`py-2 font-medium`,children:`Granted by`})]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-[var(--oke-line)]`,children:[(0,L.jsx)(`td`,{className:`py-2 pr-4 font-mono`,children:e.scope}),(0,L.jsx)(`td`,{className:`py-2 text-[var(--oke-muted)]`,children:e.sources})]},e.scope))})]})]})}var Su=t({default:()=>_u});export{Me as $,Tt as A,bt as B,zt as C,Pt as D,It as E,xt as F,st as G,ht as H,ft as I,Ze as J,Je as K,St as L,yt as M,Ct as N,Dt as O,pt as P,Ke as Q,tt as R,Ta as S,Lt as T,$e as U,mt as V,ot as W,Xe as X,Ye as Y,qe as Z,xs as _,r as _t,cu as a,re as at,Zo as b,ru as c,v as ct,Tc as d,h as dt,je as et,wc as f,l as ft,Fs as g,i as gt,_s as h,A as ht,su as i,fe as it,wt as j,Et as k,au as l,_ as lt,cc as m,p as mt,hu as n,De as nt,$ as o,F as ot,Cc as p,y as pt,Qe as q,ou as r,Ce as rt,iu as s,u as st,Su as t,ke as tt,Dc as u,g as ut,Ls as v,Rt as w,js as x,ks as y,it as z};
@@ -1 +1 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,S as i,b as a,d as o,h as s,nt as c,tt as l,u,w as d,y as f}from"./panel-access-Dd37LU2c.js";function p(e){return i(s,e)}var m=f({prompt:a().optional(),version:p().int().optional(),agent:a().optional(),run:a().optional(),q:a().optional()});function h(e){let t=m.safeParse(e);return t.success?t.data:{}}function g(e){let t={};return e.prompt&&(t.prompt=e.prompt),e.version!==void 0&&(t.version=e.version),e.agent&&(t.agent=e.agent),e.run&&(t.run=e.run),e.q&&(t.q=e.q),t}function _(e,t,n){return{...e,prompt:t,version:n,agent:void 0,run:void 0}}function v(e,t,n){return{...e,agent:t,run:n}}function y(e){return`/manifest-diff?${new URLSearchParams({path:e}).toString()}`}function b(e,t){if(e.prompt!==t.prompt)throw Error(`promotionDecision: prompt mismatch (${e.prompt} vs ${t.prompt})`);let n={fromEvalMean:e.evalScore.mean,toEvalMean:t.evalScore.mean,fromSchemaInvalidRate:e.schemaInvalidRate,toSchemaInvalidRate:t.schemaInvalidRate,fromOverBudgetRate:e.overBudgetRate,toOverBudgetRate:t.overBudgetRate,fromP95Cost:e.cost.p95,toP95Cost:t.cost.p95,budgetMaxCostPerCall:t.budgetMaxCostPerCall??e.budgetMaxCostPerCall},r=[];t.schemaInvalidRate>e.schemaInvalidRate+1e-12&&r.push(`schema_validity`);let i=n.budgetMaxCostPerCall;(t.overBudgetRate>e.overBudgetRate+1e-12||i!==null&&t.cost.p95>i&&e.cost.p95<=i)&&r.push(`budget`);let a=t.evalScore.mean>e.evalScore.mean+1e-12;return r.length>0?{allowed:!1,from:e,to:t,blockers:r,evalImproved:a,numbers:n}:{allowed:!0,from:e,to:t,evalImproved:a,numbers:n}}function x(e){let t=[],n=e.numbers;if(e.blockers.includes(`schema_validity`)&&t.push(`schema-invalid ${(n.fromSchemaInvalidRate*100).toFixed(1)}% → ${(n.toSchemaInvalidRate*100).toFixed(1)}%`),e.blockers.includes(`budget`)){let e=n.budgetMaxCostPerCall===null?`budget`:`budget $${n.budgetMaxCostPerCall.toFixed(4)}`;t.push(`over-budget ${(n.fromOverBudgetRate*100).toFixed(1)}% → ${(n.toOverBudgetRate*100).toFixed(1)}% · p95 $${n.fromP95Cost.toFixed(4)} → $${n.toP95Cost.toFixed(4)} (${e})`)}return e.evalImproved&&t.push(`eval mean ${(n.fromEvalMean*100).toFixed(1)}% → ${(n.toEvalMean*100).toFixed(1)}% (improved — still blocked)`),t}function S(e,t){let n=t?.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||(e.model?.toLowerCase().includes(n)??!1)):e}function C(e,t){let n=t?.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||e.tools.some(e=>e.toLowerCase().includes(n))):e}function w(e,t){return e.filter(e=>e.prompt===t).sort((e,t)=>e.version-t.version)}function T(e,t){return e.filter(e=>e.agent===t)}function E(e){return e.filter(e=>e.allowPii)}function D(e){return`${(e*100).toFixed(1)}%`}function O(e){return`$${e.toFixed(4)}`}function k(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function A(e){return`${(e*100).toFixed(1)}%`}function j(e,t,n,r,i){return`${e}: mean ${i(t)}, p50 ${i(n)}, p95 ${i(r)}`}function M(e){return e.reduce((e,t)=>Math.max(e,t.count),0)}function N(e){return e===`denied`?`DENIED`:`ok`}function P(e){return e.filter(e=>e.overBudgetRate>0).map(e=>({prompt:e.prompt,version:e.version,overBudgetRate:e.overBudgetRate,budgetMaxCostPerCall:e.budgetMaxCostPerCall,p95Cost:e.cost.p95})).sort((e,t)=>t.overBudgetRate-e.overBudgetRate||e.prompt.localeCompare(t.prompt)||t.version-e.version)}var F=e(c(),1),I=l();function L(){let e=d({from:`/ai`}),t=n({from:`/ai`}),i=e=>{t({search:g(e),replace:!0})},a=r({queryKey:[`console.ai.list`],queryFn:async()=>{let e=await o.aiList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),s=a.data,c=(0,F.useMemo)(()=>S(s?.prompts??[],e.q),[s?.prompts,e.q]),l=(0,F.useMemo)(()=>C(s?.agents??[],e.q),[s?.agents,e.q]),f=e.prompt??c[0]?.name,p=(0,F.useMemo)(()=>f?w(s?.versions??[],f):[],[s?.versions,f]),m=p.find(t=>t.version===e.version)??p[p.length-1],h=p.length>=2?p[p.length-2]:p[0],x=h&&m&&h.version!==m.version?b(h,m):null,D=e.agent??l[0]?.name,k=(0,F.useMemo)(()=>D?T(s?.agentRuns??[],D):[],[s?.agentRuns,D]),A=k.find(t=>t.id===e.run)??k[0],j=E(s?.allowPii??[]),M=c.find(e=>e.name===f);return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,I.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,I.jsx)(`h1`,{className:`text-base font-medium text-[var(--oke-fg)]`,children:`AI`}),(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Distributions per prompt version — cost, latency, eval score. Schema-invalid is its own class.`}),(0,I.jsxs)(`label`,{className:`mt-2 flex max-w-sm flex-col gap-1 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter`}),(0,I.jsx)(`input`,{"aria-label":`Filter prompts and agents`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:e.q??``,onChange:t=>i({...e,q:t.target.value||void 0})})]})]}),(0,I.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[14rem_1fr_18rem]`,children:[(0,I.jsxs)(`aside`,{"aria-label":`Prompts and agents`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] lg:border-b-0 lg:border-r`,children:[(0,I.jsxs)(`section`,{"aria-label":`Prompts`,className:`p-3`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`Prompts`}),(0,I.jsx)(`ul`,{className:`space-y-1`,children:c.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===f,className:u(`flex min-h-8 w-full items-center px-2 text-left text-sm`,t.name===f?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>i(_(e,t.name,t.version??0)),children:[t.name,t.version===void 0?null:(0,I.jsxs)(`span`,{className:`ml-1 font-mono text-xs`,children:[`@`,t.version]})]})},t.name))})]}),(0,I.jsxs)(`section`,{"aria-label":`Agents`,className:`p-3`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`Agents`}),(0,I.jsx)(`ul`,{className:`space-y-1`,children:l.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.name===D,className:u(`flex min-h-8 w-full items-center px-2 text-left text-sm`,t.name===D?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>i({...e,agent:t.name,run:void 0}),children:t.name})},t.name))})]})]}),(0,I.jsxs)(`main`,{id:`ai-main`,className:`min-h-0 overflow-y-auto p-4`,children:[a.isLoading?(0,I.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`Loading…`}):null,a.isError?(0,I.jsx)(`p`,{role:`alert`,children:`Failed to load AI projection`}):null,m?(0,I.jsx)(R,{metrics:m,versions:p,onSelectVersion:t=>i(_(e,m.prompt,t)),catalogueHref:M?y(M.manifestDiffPath):null,decision:x}):(0,I.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`No prompt versions with samples yet.`}),A?(0,I.jsxs)(`section`,{"aria-label":`Agent run trail`,className:`mt-8`,children:[(0,I.jsxs)(`h2`,{className:`mb-2 text-sm font-medium`,children:[`Agent run · `,A.agent]}),(0,I.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:k.map(t=>(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.id===A.id,className:u(`min-h-8 px-2 text-xs font-mono`,t.id===A.id?`bg-[var(--oke-line)]`:`text-[var(--oke-muted)]`),onClick:()=>i(v(e,t.agent,t.id)),children:t.id},t.id))}),(0,I.jsx)(`ol`,{className:`space-y-3 border-l border-[var(--oke-line)] pl-4`,children:A.trail.map((e,t)=>(0,I.jsxs)(`li`,{className:`text-sm`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:u(`font-mono text-xs tracking-wide`,e.status===`denied`?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),children:N(e.status)}),(0,I.jsx)(`span`,{className:`font-mono`,children:e.tool})]}),e.status===`denied`&&e.denial?(0,I.jsxs)(`p`,{role:`status`,className:`mt-1 text-[var(--oke-muted)]`,children:[`DENIED by gate`,` `,(0,I.jsx)(`span`,{className:`font-mono text-[var(--oke-fg)]`,children:e.denial.gate}),`: `,e.denial.reason]}):null,(0,I.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs text-[var(--oke-muted)]`,children:[e.effects.map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,e.resource]},`${e.kind}:${e.resource}`)),e.effects.length===0?(0,I.jsx)(`li`,{children:`no declared effects`}):null]})]},`${e.tool}-${t}`))})]}):null,(0,I.jsxs)(`section`,{"aria-label":`Fallback chains`,className:`mt-8`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Fallback chains`}),(s?.fallbackChains.length??0)===0?(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`No multi-model chains recorded.`}):(0,I.jsx)(`ul`,{className:`space-y-2 text-sm`,children:(s?.fallbackChains??[]).map((e,t)=>(0,I.jsxs)(`li`,{className:`border border-[var(--oke-line)] px-3 py-2`,children:[(0,I.jsxs)(`div`,{className:`font-mono text-xs`,children:[e.prompt,e.version===void 0?``:`@${e.version}`]}),(0,I.jsx)(`div`,{className:`mt-1`,children:e.attempts.map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0?` → `:``,(0,I.jsx)(`span`,{className:e.ok?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)] line-through`,children:e.model}),e.cost===void 0?``:` (${O(e.cost)})`]},`${e.model}-${t}`))}),(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:[`actual `,O(e.actualCost),e.costConsequence===null?``:` · cost consequence ${O(e.costConsequence)}`]})]},`${e.prompt}-${e.at}-${t}`))})]})]}),(0,I.jsxs)(`aside`,{"aria-label":`allowPii security review`,className:`min-h-0 overflow-y-auto border-t border-[var(--oke-line)] p-4 lg:border-l lg:border-t-0`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`allowPii`}),(0,I.jsx)(`p`,{className:`mb-3 text-xs text-[var(--oke-muted)]`,children:`Standing security review — flows that acknowledge PII egress to a model.`}),j.length===0?(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`None declared.`}):(0,I.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,I.jsx)(`caption`,{className:`sr-only`,children:`Standing security review — PII egress acknowledgements`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Flow`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Asks`})]})}),(0,I.jsx)(`tbody`,{children:j.map(e=>(0,I.jsxs)(`tr`,{className:`align-top`,children:[(0,I.jsx)(`td`,{className:`py-1 pr-2 font-mono text-[var(--oke-fg)]`,children:e.flowId}),(0,I.jsx)(`td`,{className:`py-1 font-mono text-[var(--oke-muted)]`,children:e.asks.join(`, `)||`—`})]},e.flowId))})]})]})]})]})}function R(e){let t=e.metrics;return(0,I.jsxs)(`section`,{"aria-label":`Version distributions`,"aria-live":`polite`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-baseline gap-3`,children:[(0,I.jsxs)(`h2`,{className:`text-sm font-medium`,children:[t.prompt,` `,(0,I.jsxs)(`span`,{className:`font-mono text-[var(--oke-muted)]`,children:[`@`,t.version]})]}),e.catalogueHref?(0,I.jsx)(`a`,{href:e.catalogueHref,className:`text-xs text-[var(--oke-muted)] underline`,children:`Manifest Diff — version bump is a deploy`}):null]}),(0,I.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-2`,role:`group`,"aria-label":`Versions`,children:e.versions.map(n=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":n.version===t.version,className:u(`min-h-8 px-2 font-mono text-xs`,n.version===t.version?`bg-[var(--oke-line)]`:`text-[var(--oke-muted)]`),onClick:()=>e.onSelectVersion(n.version),children:[`v`,n.version]},n.version))}),(0,I.jsx)(z,{label:`Cost`,summary:j(`Cost`,t.cost.mean,t.cost.p50,t.cost.p95,O),buckets:t.cost.buckets,formatTick:O}),(0,I.jsx)(z,{label:`Latency`,summary:j(`Latency`,t.latencyMs.mean,t.latencyMs.p50,t.latencyMs.p95,k),buckets:t.latencyMs.buckets,formatTick:k}),(0,I.jsx)(z,{label:`Eval score`,summary:j(`Eval score`,t.evalScore.mean,t.evalScore.p50,t.evalScore.p95,A),buckets:t.evalScore.buckets,formatTick:A}),(0,I.jsxs)(`table`,{className:`mt-4 w-full max-w-md text-left text-sm`,children:[(0,I.jsx)(`caption`,{className:`mb-2 text-left text-xs text-[var(--oke-muted)]`,children:`Outcome classes — schema-invalid ≠ provider-error`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Class`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Rate`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Count`})]})}),(0,I.jsxs)(`tbody`,{children:[(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`schema-invalid`}),(0,I.jsx)(`td`,{children:D(t.schemaInvalidRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.schema_invalid})]}),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`provider-error`}),(0,I.jsx)(`td`,{children:D(t.providerErrorRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.provider_error})]}),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`ok`}),(0,I.jsx)(`td`,{children:D(t.okRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.ok})]})]})]}),e.decision&&!e.decision.allowed?(0,I.jsxs)(`div`,{className:`mt-4 border border-[var(--oke-line)] px-3 py-2`,role:`status`,"aria-label":`Promotion gate`,children:[(0,I.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Promotion v`,e.decision.from.version,` → v`,e.decision.to.version,` blocked`]}),(0,I.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-sm text-[var(--oke-muted)]`,children:x(e.decision).map(e=>(0,I.jsx)(`li`,{children:e},e))})]}):e.decision?.allowed?(0,I.jsxs)(`p`,{className:`mt-4 text-sm text-[var(--oke-muted)]`,role:`status`,children:[`Promotion v`,e.decision.from.version,` → v`,e.decision.to.version,` allowed`,e.decision.evalImproved?` (eval improved)`:``,`.`]}):null]})}function z(e){let t=M(e.buckets);return(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsxs)(`h3`,{className:`text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:[e.label,` distribution`]}),(0,I.jsx)(`p`,{className:`mb-2 text-sm`,children:e.summary}),(0,I.jsx)(`div`,{role:`img`,"aria-label":e.summary,className:`flex h-16 items-end gap-px`,children:e.buckets.map((n,r)=>(0,I.jsx)(`div`,{title:`${e.formatTick(n.min)}–${e.formatTick(n.max)}: ${n.count}`,className:`min-w-[4px] flex-1 bg-[var(--oke-fg)] opacity-70`,style:{height:`${t===0?0:Math.max(4,n.count/t*100)}%`}},r))})]})}var B=t({default:()=>L});export{p as i,P as n,h as r,B as t};
1
+ import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,S as i,b as a,d as o,h as s,nt as c,tt as l,u,w as d,y as f}from"./panel-access-C0J2D-a2.js";function p(e){return i(s,e)}var m=f({prompt:a().optional(),version:p().int().optional(),agent:a().optional(),run:a().optional(),q:a().optional()});function h(e){let t=m.safeParse(e);return t.success?t.data:{}}function g(e){let t={};return e.prompt&&(t.prompt=e.prompt),e.version!==void 0&&(t.version=e.version),e.agent&&(t.agent=e.agent),e.run&&(t.run=e.run),e.q&&(t.q=e.q),t}function _(e,t,n){return{...e,prompt:t,version:n,agent:void 0,run:void 0}}function v(e,t,n){return{...e,agent:t,run:n}}function y(e){return`/manifest-diff?${new URLSearchParams({path:e}).toString()}`}function b(e,t){if(e.prompt!==t.prompt)throw Error(`promotionDecision: prompt mismatch (${e.prompt} vs ${t.prompt})`);let n={fromEvalMean:e.evalScore.mean,toEvalMean:t.evalScore.mean,fromSchemaInvalidRate:e.schemaInvalidRate,toSchemaInvalidRate:t.schemaInvalidRate,fromOverBudgetRate:e.overBudgetRate,toOverBudgetRate:t.overBudgetRate,fromP95Cost:e.cost.p95,toP95Cost:t.cost.p95,budgetMaxCostPerCall:t.budgetMaxCostPerCall??e.budgetMaxCostPerCall},r=[];t.schemaInvalidRate>e.schemaInvalidRate+1e-12&&r.push(`schema_validity`);let i=n.budgetMaxCostPerCall;(t.overBudgetRate>e.overBudgetRate+1e-12||i!==null&&t.cost.p95>i&&e.cost.p95<=i)&&r.push(`budget`);let a=t.evalScore.mean>e.evalScore.mean+1e-12;return r.length>0?{allowed:!1,from:e,to:t,blockers:r,evalImproved:a,numbers:n}:{allowed:!0,from:e,to:t,evalImproved:a,numbers:n}}function x(e){let t=[],n=e.numbers;if(e.blockers.includes(`schema_validity`)&&t.push(`schema-invalid ${(n.fromSchemaInvalidRate*100).toFixed(1)}% → ${(n.toSchemaInvalidRate*100).toFixed(1)}%`),e.blockers.includes(`budget`)){let e=n.budgetMaxCostPerCall===null?`budget`:`budget $${n.budgetMaxCostPerCall.toFixed(4)}`;t.push(`over-budget ${(n.fromOverBudgetRate*100).toFixed(1)}% → ${(n.toOverBudgetRate*100).toFixed(1)}% · p95 $${n.fromP95Cost.toFixed(4)} → $${n.toP95Cost.toFixed(4)} (${e})`)}return e.evalImproved&&t.push(`eval mean ${(n.fromEvalMean*100).toFixed(1)}% → ${(n.toEvalMean*100).toFixed(1)}% (improved — still blocked)`),t}function S(e,t){let n=t?.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||(e.model?.toLowerCase().includes(n)??!1)):e}function C(e,t){let n=t?.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||e.tools.some(e=>e.toLowerCase().includes(n))):e}function w(e,t){return e.filter(e=>e.prompt===t).sort((e,t)=>e.version-t.version)}function T(e,t){return e.filter(e=>e.agent===t)}function E(e){return e.filter(e=>e.allowPii)}function D(e){return`${(e*100).toFixed(1)}%`}function O(e){return`$${e.toFixed(4)}`}function k(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function A(e){return`${(e*100).toFixed(1)}%`}function j(e,t,n,r,i){return`${e}: mean ${i(t)}, p50 ${i(n)}, p95 ${i(r)}`}function M(e){return e.reduce((e,t)=>Math.max(e,t.count),0)}function N(e){return e===`denied`?`DENIED`:`ok`}function P(e){return e.filter(e=>e.overBudgetRate>0).map(e=>({prompt:e.prompt,version:e.version,overBudgetRate:e.overBudgetRate,budgetMaxCostPerCall:e.budgetMaxCostPerCall,p95Cost:e.cost.p95})).sort((e,t)=>t.overBudgetRate-e.overBudgetRate||e.prompt.localeCompare(t.prompt)||t.version-e.version)}var F=e(c(),1),I=l();function L(){let e=d({from:`/ai`}),t=n({from:`/ai`}),i=e=>{t({search:g(e),replace:!0})},a=r({queryKey:[`console.ai.list`],queryFn:async()=>{let e=await o.aiList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),s=a.data,c=(0,F.useMemo)(()=>S(s?.prompts??[],e.q),[s?.prompts,e.q]),l=(0,F.useMemo)(()=>C(s?.agents??[],e.q),[s?.agents,e.q]),f=e.prompt??c[0]?.name,p=(0,F.useMemo)(()=>f?w(s?.versions??[],f):[],[s?.versions,f]),m=p.find(t=>t.version===e.version)??p[p.length-1],h=p.length>=2?p[p.length-2]:p[0],x=h&&m&&h.version!==m.version?b(h,m):null,D=e.agent??l[0]?.name,k=(0,F.useMemo)(()=>D?T(s?.agentRuns??[],D):[],[s?.agentRuns,D]),A=k.find(t=>t.id===e.run)??k[0],j=E(s?.allowPii??[]),M=c.find(e=>e.name===f);return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,I.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,I.jsx)(`h1`,{className:`text-base font-medium text-[var(--oke-fg)]`,children:`AI`}),(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Distributions per prompt version — cost, latency, eval score. Schema-invalid is its own class.`}),(0,I.jsxs)(`label`,{className:`mt-2 flex max-w-sm flex-col gap-1 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter`}),(0,I.jsx)(`input`,{"aria-label":`Filter prompts and agents`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:e.q??``,onChange:t=>i({...e,q:t.target.value||void 0})})]})]}),(0,I.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[14rem_1fr_18rem]`,children:[(0,I.jsxs)(`aside`,{"aria-label":`Prompts and agents`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] lg:border-b-0 lg:border-r`,children:[(0,I.jsxs)(`section`,{"aria-label":`Prompts`,className:`p-3`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`Prompts`}),(0,I.jsx)(`ul`,{className:`space-y-1`,children:c.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===f,className:u(`flex min-h-8 w-full items-center px-2 text-left text-sm`,t.name===f?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>i(_(e,t.name,t.version??0)),children:[t.name,t.version===void 0?null:(0,I.jsxs)(`span`,{className:`ml-1 font-mono text-xs`,children:[`@`,t.version]})]})},t.name))})]}),(0,I.jsxs)(`section`,{"aria-label":`Agents`,className:`p-3`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`Agents`}),(0,I.jsx)(`ul`,{className:`space-y-1`,children:l.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.name===D,className:u(`flex min-h-8 w-full items-center px-2 text-left text-sm`,t.name===D?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>i({...e,agent:t.name,run:void 0}),children:t.name})},t.name))})]})]}),(0,I.jsxs)(`main`,{id:`ai-main`,className:`min-h-0 overflow-y-auto p-4`,children:[a.isLoading?(0,I.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`Loading…`}):null,a.isError?(0,I.jsx)(`p`,{role:`alert`,children:`Failed to load AI projection`}):null,m?(0,I.jsx)(R,{metrics:m,versions:p,onSelectVersion:t=>i(_(e,m.prompt,t)),catalogueHref:M?y(M.manifestDiffPath):null,decision:x}):(0,I.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`No prompt versions with samples yet.`}),A?(0,I.jsxs)(`section`,{"aria-label":`Agent run trail`,className:`mt-8`,children:[(0,I.jsxs)(`h2`,{className:`mb-2 text-sm font-medium`,children:[`Agent run · `,A.agent]}),(0,I.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:k.map(t=>(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.id===A.id,className:u(`min-h-8 px-2 text-xs font-mono`,t.id===A.id?`bg-[var(--oke-line)]`:`text-[var(--oke-muted)]`),onClick:()=>i(v(e,t.agent,t.id)),children:t.id},t.id))}),(0,I.jsx)(`ol`,{className:`space-y-3 border-l border-[var(--oke-line)] pl-4`,children:A.trail.map((e,t)=>(0,I.jsxs)(`li`,{className:`text-sm`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:u(`font-mono text-xs tracking-wide`,e.status===`denied`?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),children:N(e.status)}),(0,I.jsx)(`span`,{className:`font-mono`,children:e.tool})]}),e.status===`denied`&&e.denial?(0,I.jsxs)(`p`,{role:`status`,className:`mt-1 text-[var(--oke-muted)]`,children:[`DENIED by gate`,` `,(0,I.jsx)(`span`,{className:`font-mono text-[var(--oke-fg)]`,children:e.denial.gate}),`:`,` `,e.denial.reason]}):null,(0,I.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs text-[var(--oke-muted)]`,children:[e.effects.map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,e.resource]},`${e.kind}:${e.resource}`)),e.effects.length===0?(0,I.jsx)(`li`,{children:`no declared effects`}):null]})]},`${e.tool}-${t}`))})]}):null,(0,I.jsxs)(`section`,{"aria-label":`Fallback chains`,className:`mt-8`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Fallback chains`}),(s?.fallbackChains.length??0)===0?(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`No multi-model chains recorded.`}):(0,I.jsx)(`ul`,{className:`space-y-2 text-sm`,children:(s?.fallbackChains??[]).map((e,t)=>(0,I.jsxs)(`li`,{className:`border border-[var(--oke-line)] px-3 py-2`,children:[(0,I.jsxs)(`div`,{className:`font-mono text-xs`,children:[e.prompt,e.version===void 0?``:`@${e.version}`]}),(0,I.jsx)(`div`,{className:`mt-1`,children:e.attempts.map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0?` → `:``,(0,I.jsx)(`span`,{className:e.ok?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)] line-through`,children:e.model}),e.cost===void 0?``:` (${O(e.cost)})`]},`${e.model}-${t}`))}),(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:[`actual `,O(e.actualCost),e.costConsequence===null?``:` · cost consequence ${O(e.costConsequence)}`]})]},`${e.prompt}-${e.at}-${t}`))})]})]}),(0,I.jsxs)(`aside`,{"aria-label":`allowPii security review`,className:`min-h-0 overflow-y-auto border-t border-[var(--oke-line)] p-4 lg:border-l lg:border-t-0`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`allowPii`}),(0,I.jsx)(`p`,{className:`mb-3 text-xs text-[var(--oke-muted)]`,children:`Standing security review — flows that acknowledge PII egress to a model.`}),j.length===0?(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`None declared.`}):(0,I.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,I.jsx)(`caption`,{className:`sr-only`,children:`Standing security review — PII egress acknowledgements`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Flow`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Asks`})]})}),(0,I.jsx)(`tbody`,{children:j.map(e=>(0,I.jsxs)(`tr`,{className:`align-top`,children:[(0,I.jsx)(`td`,{className:`py-1 pr-2 font-mono text-[var(--oke-fg)]`,children:e.flowId}),(0,I.jsx)(`td`,{className:`py-1 font-mono text-[var(--oke-muted)]`,children:e.asks.join(`, `)||`—`})]},e.flowId))})]})]})]})]})}function R(e){let t=e.metrics;return(0,I.jsxs)(`section`,{"aria-label":`Version distributions`,"aria-live":`polite`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-baseline gap-3`,children:[(0,I.jsxs)(`h2`,{className:`text-sm font-medium`,children:[t.prompt,` `,(0,I.jsxs)(`span`,{className:`font-mono text-[var(--oke-muted)]`,children:[`@`,t.version]})]}),e.catalogueHref?(0,I.jsx)(`a`,{href:e.catalogueHref,className:`text-xs text-[var(--oke-muted)] underline`,children:`Manifest Diff — version bump is a deploy`}):null]}),(0,I.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-2`,role:`group`,"aria-label":`Versions`,children:e.versions.map(n=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":n.version===t.version,className:u(`min-h-8 px-2 font-mono text-xs`,n.version===t.version?`bg-[var(--oke-line)]`:`text-[var(--oke-muted)]`),onClick:()=>e.onSelectVersion(n.version),children:[`v`,n.version]},n.version))}),(0,I.jsx)(z,{label:`Cost`,summary:j(`Cost`,t.cost.mean,t.cost.p50,t.cost.p95,O),buckets:t.cost.buckets,formatTick:O}),(0,I.jsx)(z,{label:`Latency`,summary:j(`Latency`,t.latencyMs.mean,t.latencyMs.p50,t.latencyMs.p95,k),buckets:t.latencyMs.buckets,formatTick:k}),(0,I.jsx)(z,{label:`Eval score`,summary:j(`Eval score`,t.evalScore.mean,t.evalScore.p50,t.evalScore.p95,A),buckets:t.evalScore.buckets,formatTick:A}),(0,I.jsxs)(`table`,{className:`mt-4 w-full max-w-md text-left text-sm`,children:[(0,I.jsx)(`caption`,{className:`mb-2 text-left text-xs text-[var(--oke-muted)]`,children:`Outcome classes — schema-invalid ≠ provider-error`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Class`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Rate`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Count`})]})}),(0,I.jsxs)(`tbody`,{children:[(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`schema-invalid`}),(0,I.jsx)(`td`,{children:D(t.schemaInvalidRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.schema_invalid})]}),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`provider-error`}),(0,I.jsx)(`td`,{children:D(t.providerErrorRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.provider_error})]}),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`ok`}),(0,I.jsx)(`td`,{children:D(t.okRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.ok})]})]})]}),e.decision&&!e.decision.allowed?(0,I.jsxs)(`div`,{className:`mt-4 border border-[var(--oke-line)] px-3 py-2`,role:`status`,"aria-label":`Promotion gate`,children:[(0,I.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Promotion v`,e.decision.from.version,` → v`,e.decision.to.version,` blocked`]}),(0,I.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-sm text-[var(--oke-muted)]`,children:x(e.decision).map(e=>(0,I.jsx)(`li`,{children:e},e))})]}):e.decision?.allowed?(0,I.jsxs)(`p`,{className:`mt-4 text-sm text-[var(--oke-muted)]`,role:`status`,children:[`Promotion v`,e.decision.from.version,` → v`,e.decision.to.version,` allowed`,e.decision.evalImproved?` (eval improved)`:``,`.`]}):null]})}function z(e){let t=M(e.buckets);return(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsxs)(`h3`,{className:`text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:[e.label,` distribution`]}),(0,I.jsx)(`p`,{className:`mb-2 text-sm`,children:e.summary}),(0,I.jsx)(`div`,{role:`img`,"aria-label":e.summary,className:`flex h-16 items-end gap-px`,children:e.buckets.map((n,r)=>(0,I.jsx)(`div`,{title:`${e.formatTick(n.min)}–${e.formatTick(n.max)}: ${n.count}`,className:`min-w-[4px] flex-1 bg-[var(--oke-fg)] opacity-70`,style:{height:`${t===0?0:Math.max(4,n.count/t*100)}%`}},r))})]})}var B=t({default:()=>L});export{p as i,P as n,h as r,B as t};
@@ -1 +1 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,_ as i,b as a,d as o,nt as s,o as c,tt as l,u,v as d,w as f,x as p,y as m}from"./panel-access-Dd37LU2c.js";var h=[`data`,`messaging`,`time`,`external`],g={data:`Data`,messaging:`Messaging`,time:`Time`,external:`External`},_={data:!0,messaging:!0,time:!0,external:!0},v=p([i(),d(`true`),d(`false`)]).transform(e=>e===!0||e===`true`),ee=m({focus:a().optional(),depth:p([d(1),d(2),d(`1`),d(`2`)]).transform(e=>Number(e)===2?2:1).default(1),data:v.optional(),messaging:v.optional(),time:v.optional(),external:v.optional()});function te(e){let t=ee.safeParse(e);return t.success?t.data:{depth:1}}function ne(e){let t={};e.focus&&(t.focus=e.focus),e.depth===2&&(t.depth=`2`);for(let n of h)e[n]===!1&&(t[n]=`false`);return t}function y(e){return{data:e.data??_.data,messaging:e.messaging??_.messaging,time:e.time??_.time,external:e.external??_.external}}function b(e,t){return{...e,focus:t}}function re(e){let{focus:t,...n}=e;return{...n,depth:e.depth}}function ie(e,t){return{...e,depth:t}}function x(e,t,n){return{...e,[t]:n}}function S(e){return e.startsWith(`sql:`)||e.startsWith(`kv:`)||e.startsWith(`files:`)||e.startsWith(`index:`)?`data`:e.startsWith(`signal:`)?`messaging`:e.startsWith(`channel:`)||e.startsWith(`ai:`)?`external`:null}function ae(e){return e.kind===`signal`?`messaging`:e.kind===`cron`||e.kind===`every`?`time`:null}function C(e){return e.startsWith(`channel:`)||e.startsWith(`ai:`)}function w(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(t+1)}function oe(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return t.size}function se(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return[...t].sort()}function ce(e,t){switch(e){case`emit`:return t.startsWith(`signal:`)?t:`signal:${t}`;case`send`:return t.startsWith(`channel:`)?t:`channel:${t}`;case`ask`:return t.startsWith(`ai:`)?t:`ai:${t}`;case`secret`:return t.startsWith(`secret:`)?t:`secret:${t}`;case`call`:return t.startsWith(`flow:`)?t:`flow:${t}`;default:return t}}function T(e,t){return`${e}\0${t}`}function le(e){let t=new Map;for(let n of e){for(let e of n.effects){let r=ce(e.kind,e.resource),i=T(n.flow,r);t.set(i,(t.get(i)??0)+1)}n.parentId}return t}function E(e,t,n){return e.get(T(t,n))??0}function ue(e,t){if(e<=0)return 1;if(t<=1)return 2;let n=e/t;return Math.max(1,Math.min(8,Math.ceil(n*8)))}function D(e){let t=[],n=pe(e);for(let r of e.flows){for(let n of r.causeIds){let i=e.causeById.get(n);if(!i)continue;let a=ae(i);a&&t.push({from:`cause:${i.id}`,to:`flow:${r.id}`,flowId:r.id,layer:a,fromUnit:r.unit,toUnit:r.unit})}for(let i of r.effectRefs){if(i.startsWith(`flow:`)){let e=i.slice(5),n=O(e);t.push({from:`flow:${r.id}`,to:`flow:${e}`,flowId:r.id,ref:i,layer:`call`,fromUnit:r.unit,toUnit:n});continue}let a=S(i);if(!a)continue;let o=C(i)?`external`:de(i,e);if(t.push({from:`flow:${r.id}`,to:i,flowId:r.id,ref:i,layer:a,fromUnit:r.unit,toUnit:o}),a===`messaging`&&i.startsWith(`signal:`)){let a=i.slice(7);for(let o of n.get(a)??[]){let n=e.flowById.get(o);!n||n.id===r.id||t.push({from:`flow:${r.id}`,to:`flow:${n.id}`,flowId:r.id,ref:i,layer:`messaging`,fromUnit:r.unit,toUnit:n.unit})}}}}return t}function de(e,t){let n=t.effectByRef.get(e);if(!n||n.flowIds.length===0)return`shared`;let r=n.flowIds.filter(n=>{let r=t.flowById.get(n);return r?fe(r,e):!1})[0]??n.flowIds[0];return r?O(r):`shared`}function fe(e,t){let n=e.raw.effects;if(!n)return!1;if(t.startsWith(`signal:`)){let e=t.slice(7);return(n.emits??[]).includes(e)}return!!(n.writes??[]).includes(t)}function pe(e){let t=new Map;for(let n of e.flows){let e=n.raw.trigger?.signal;if(!e)continue;let r=t.get(e)??[];r.push(n.id),t.set(e,r)}return t}function O(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function k(e){let t=[];return t.push(...A(e)),t.push(...j(e)),t.push(...M(e)),t.push(...N(e)),t}function A(e){let t=new Map,n=e=>{let n=t.get(e);return n||(n=new Set,t.set(e,n)),n};for(let t of D(e)){if(!t.from.startsWith(`flow:`)||!t.to.startsWith(`flow:`))continue;let e=t.from.slice(5),r=t.to.slice(5);n(e).add(r)}let r=[],i=new Set,a=[],o=new Set,s=e=>{i.add(e),a.push(e),o.add(e);for(let n of t.get(e)??[])if(!i.has(n))s(n);else if(o.has(n)){let e=a.indexOf(n);e!==-1&&r.push([...a.slice(e),n])}a.pop(),o.delete(e)};for(let t of e.flows.map(e=>e.id))i.has(t)||s(t);let c=new Set,l=[];for(let e of r){let t=P(e.slice(0,-1)),n=t.join(`→`);c.has(n)||(c.add(n),l.push({kind:`cycle`,severity:`critical`,title:`Cycle`,detail:`Causal cycle: ${t.join(` → `)}`,nodeIds:t.map(e=>`flow:${e}`)}))}return l}function j(e){if(e.effects.length===0)return[];let t=[...e.effects].filter(e=>e.touchCount>0).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref)),n=t[0];if(!n||n.touchCount<2)return[];let r=t[1]?.touchCount??0;return n.touchCount===r&&t.filter(e=>e.touchCount===n.touchCount).length>1?t.filter(e=>e.touchCount===n.touchCount).map(e=>({kind:`god-node`,severity:`warning`,title:`God node`,detail:`${e.ref} is touched by ${e.touchCount} flows — the most in the system`,nodeIds:[e.ref]})):[{kind:`god-node`,severity:`warning`,title:`God node`,detail:`${n.ref} is touched by ${n.touchCount} flows — the most in the system`,nodeIds:[n.ref]}]}function M(e){let t=[],n=new Set;for(let t of e.effects)t.ref.startsWith(`signal:`)&&n.add(t.ref.slice(7));for(let t of e.flows){for(let e of t.raw.effects?.emits??[])n.add(e);let e=t.raw.trigger?.signal;e&&n.add(e)}for(let r of[...n].sort()){let n=`signal:${r}`,i=e.flows.filter(e=>(e.raw.effects?.emits??[]).includes(r)),a=e.flows.filter(e=>e.raw.trigger?.signal===r);if(i.length===0&&a.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is declared but has no producers and no consumers`,nodeIds:[n]});continue}if(i.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} has consumers but no producer`,nodeIds:[n,...a.map(e=>`flow:${e.id}`)]});continue}a.length===0&&t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is emitted but has no consumers`,nodeIds:[n,...i.map(e=>`flow:${e.id}`)]})}return t}function N(e){let t=[];for(let n of e.effects){if(n.touchCount<2||n.ref.startsWith(`secret:`)||n.ref.startsWith(`channel:`)||n.ref.startsWith(`ai:`))continue;let r=n.flowIds.filter(t=>{let r=e.flowById.get(t);if(!r?.raw.effects)return!1;if(n.ref.startsWith(`signal:`)){let e=n.ref.slice(7);return(r.raw.effects.emits??[]).includes(e)}return(r.raw.effects.writes??[]).includes(n.ref)});if(r.length!==1)continue;let i=r[0];t.push({kind:`spof`,severity:`critical`,title:`Single point of failure`,detail:`${n.ref} is touched by ${n.touchCount} flows but written/emitted by only ${i}`,nodeIds:[n.ref,`flow:${i}`]})}return t}function P(e){if(e.length===0)return[];let t=[...e],n=t.join(`\0`);for(let r=1;r<e.length;r++){let i=[...e.slice(r),...e.slice(0,r)],a=i.join(`\0`);a<n&&(t=i,n=a)}return t}function F(e,t={}){let n=t.focus??null,r=t.depth===2?2:1,i=t.layers??_,a=le(t.runs??[]),o=D(e),s=k(e),c=oe(e);return n?L({graph:e,declared:o,traffic:a,focus:n,depth:r,layers:i,findings:s,crossings:c}):I({graph:e,declared:o,traffic:a,layers:i,findings:s,crossings:c})}function I(e){let{graph:t,declared:n,traffic:r,layers:i,findings:a,crossings:o}=e,s=[...new Set(t.flows.map(e=>e.unit))].sort().map(e=>({id:`unit:${e}`,kind:`unit`,label:e,unit:e,insideBoundary:!0,flowCount:t.flows.filter(t=>t.unit===e).length}));for(let e of se(t))s.push({id:e,kind:`external`,label:w(e),layer:`external`,insideBoundary:!1});let c=new Map;for(let e of n){if(!V(e.layer,i))continue;let t=`unit:${e.fromUnit}`,n=null;if(e.toUnit===`external`||C(e.to))n=e.ref??e.to;else if(e.fromUnit!==e.toUnit)n=`unit:${e.toUnit}`;else continue;if(t===n)continue;let a=`${t}\0${n}\0${e.layer}`,o=e.ref?E(r,e.flowId,e.ref):0,s=c.get(a);s?s.traversals+=o:c.set(a,{from:t,to:n,layer:e.layer,traversals:o,declared:!0})}let l=H(c,!0);return{nodes:U(s),edges:l,boundaryCrossingCount:o,findings:a,focus:null,depth:1,layers:i}}function L(e){let{graph:t,declared:n,traffic:r,focus:i,depth:a,layers:o,findings:s,crossings:c}=e,l=z(t,n,i,a),u=[];for(let e of l){let r=B(t,n,i,e,a);if(e.startsWith(`unit:`)){let n=e.slice(5);u.push({id:e,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:t.flows.filter(e=>e.unit===n).length,focused:e===i,depth:r});continue}if(e.startsWith(`flow:`)){let n=e.slice(5),a=t.flowById.get(n);u.push({id:e,kind:`flow`,label:n,unit:a?.unit??O(n),insideBoundary:!0,focused:e===i,depth:r});continue}if(e.startsWith(`cause:`)){let n=e.slice(6),a=t.causeById.get(n),s=a?.kind===`cron`||a?.kind===`every`?`time`:a?.kind===`signal`?`messaging`:void 0;if(!s||!o[s])continue;u.push({id:e,kind:`resource`,label:a?.label??n,layer:s,insideBoundary:!0,focused:e===i,depth:r});continue}u.push({id:e,kind:C(e)?`external`:`resource`,label:w(e),layer:C(e)?`external`:e.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(e),focused:e===i,depth:r})}u.some(e=>e.id===i)||u.push(...R(t,i));let d=new Map,f=new Set(u.map(e=>e.id));for(let e of n){if(!V(e.layer,o))continue;let t=e.from,n=e.to;if(!f.has(t)||!f.has(n))continue;let i=`${t}\0${n}\0${e.layer}`,a=e.ref?E(r,e.flowId,e.ref):0,s=d.get(i);s?s.traversals+=a:d.set(i,{from:t,to:n,layer:e.layer,traversals:a,declared:!0})}return{nodes:U(u),edges:H(d,!1),boundaryCrossingCount:c,findings:s,focus:i,depth:a,layers:o}}function R(e,t){if(t.startsWith(`unit:`)){let n=t.slice(5);return[{id:t,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:e.flows.filter(e=>e.unit===n).length,focused:!0,depth:0}]}if(t.startsWith(`flow:`)){let n=t.slice(5);return[{id:t,kind:`flow`,label:n,unit:e.flowById.get(n)?.unit??O(n),insideBoundary:!0,focused:!0,depth:0}]}return[{id:t,kind:C(t)?`external`:`resource`,label:w(t),layer:C(t)?`external`:t.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(t),focused:!0,depth:0}]}function z(e,t,n,r){let i=new Set([n]);if(n.startsWith(`unit:`)){let t=n.slice(5);for(let n of e.flows)n.unit===t&&i.add(`flow:${n.id}`)}let a=new Set(i);for(let e=0;e<r;e++){let e=new Set;for(let n of t){let t=n.from,r=n.to;a.has(t)&&e.add(r),a.has(r)&&e.add(t);for(let n of[t,r]){if(!n.startsWith(`flow:`))continue;let t=`unit:${O(n.slice(5))}`;a.has(n)&&e.add(t),a.has(t)&&e.add(n)}}for(let t of e)i.add(t);a=e}return i}function B(e,t,n,r,i){if(n===r)return 0;let a=new Set([n]),o=new Set([n]);for(let n=1;n<=i;n++){let i=new Set;for(let e of t){let t=e.from,s=e.to;for(let[e,c]of[[t,s],[s,t]])if(o.has(e)){if(c===r)return n;a.has(c)||(a.add(c),i.add(c))}}for(let t of o){if(t.startsWith(`flow:`)){let e=`unit:${O(t.slice(5))}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}if(t.startsWith(`unit:`)){let o=t.slice(5);for(let t of e.flows){if(t.unit!==o)continue;let e=`flow:${t.id}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}}}o=i}return i}function V(e,t){return e===`call`||t[e]}function H(e,t){let n=Math.max(0,...[...e.values()].map(e=>e.traversals));return[...e.values()].map(e=>({id:`${e.from}->${e.to}:${e.layer}`,from:e.from,to:e.to,layer:e.layer,declared:e.declared,traversals:e.traversals,dashed:e.declared&&e.traversals===0,thickness:ue(e.traversals,n),aggregated:t})).sort((e,t)=>e.id.localeCompare(t.id))}function U(e){let t=new Map;for(let n of e)t.has(n.id)||t.set(n.id,n);return[...t.values()].sort((e,t)=>e.id.localeCompare(t.id))}function W(e){let t={...e.dimensions??{}};return t.flow===void 0&&(t.flow=e.flow),t.unit===void 0&&(t.unit=e.unit??null),t.trigger===void 0&&(t.trigger=e.trigger),t.plane===void 0&&(t.plane=e.plane),t.tenant===void 0&&(t.tenant=e.tenant??null),t.principal===void 0&&(t.principal=e.principal??null),t.cache===void 0&&(t.cache=e.cache??`none`),t.duration_ms===void 0&&(t.duration_ms=e.durationMs),t.error_code===void 0&&e.error&&(t.error_code=e.error),{id:e.id,parentId:e.parentId??null,flow:e.flow,unit:e.unit??null,trigger:e.trigger,plane:e.plane,tenant:e.tenant??null,principal:e.principal??null,gates:e.gates??[],cache:e.cache??`none`,replica:e.replica??null,replicaLagMs:e.replicaLagMs??null,cost:e.cost??null,promptVersion:e.promptVersion??null,buildVersion:e.buildVersion??null,startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs,error:e.error??null,effects:e.effects??[],logs:e.logs??[],dimensions:t}}function me(e){return{id:e.id,...e.parentId?{parentId:e.parentId}:{},flow:e.flow,...e.unit?{unit:e.unit}:{},trigger:e.trigger,plane:e.plane,tenant:e.tenant,principal:e.principal,gates:e.gates,cache:e.cache,...e.replica?{replica:e.replica}:{},...e.replicaLagMs==null?{}:{replicaLagMs:e.replicaLagMs},...e.cost==null?{}:{cost:e.cost},...e.promptVersion==null?{}:{promptVersion:e.promptVersion},...e.buildVersion?{buildVersion:e.buildVersion}:{},error:e.error?{code:e.error}:null,effects:e.effects,logs:e.logs,durationMs:e.durationMs,startedAt:e.startedAt,endedAt:e.endedAt,dimensions:{...e.dimensions}}}var G=e(s(),1),K={x:32,y:40,width:440,height:300};function he(e){let t=e.filter(e=>e.insideBoundary),n=e.filter(e=>!e.insideBoundary),r=new Map,i=Math.max(1,Math.ceil(Math.sqrt(t.length))),a=K.width/(i+1),o=Math.max(1,Math.ceil(t.length/i)),s=K.height/(o+1);return t.forEach((e,t)=>{let n=t%i,o=Math.floor(t/i);r.set(e.id,{id:e.id,x:K.x+a*(n+1),y:K.y+s*(o+1)})}),n.forEach((e,t)=>{r.set(e.id,{id:e.id,x:K.x+K.width+96,y:K.y+48+t*56})}),r}var q={read:`none`,write:`reversible`,emit:`deferred`,send:`irreversible`,ask:`irreversible`,secret:`capability`,call:`portal`};function ge(e){return q[e]}Object.entries(q).map(([e,t])=>({kind:e,reversibility:t}));function _e(e,t={}){if(!e)return[];let n=t.touchCounts,r=t.emitFanOut,i=[],a=(e,a,o)=>{for(let s of o??[])i.push({tier:e,kind:a,ref:s,reversibility:ge(a),touchCount:n?.get(s)??1,fanOut:a===`emit`?r?.get(s)??0:void 0,transitive:t.transitive})};return a(`reads`,`read`,e.reads),a(`writes`,`write`,e.writes),a(`emits`,`emit`,e.emits),a(`external`,`send`,e.sends),a(`external`,`ask`,e.asks),a(`capabilities`,`secret`,e.secrets),i}function J(e){return e?(e.sends?.length??0)>0||(e.asks?.length??0)>0?`external`:(e.secrets?.length??0)>0?`capabilities`:(e.emits?.length??0)>0?`emits`:(e.writes?.length??0)>0?`writes`:(e.reads?.length??0)>0?`reads`:`none`:`none`}function Y(e){return ve(J(e))}function ve(e){return e===`external`}var ye=[`reads`,`writes`,`emits`,`external`,`capabilities`],be={reads:`Reads`,writes:`Writes`,emits:`Emits`,external:`External`,capabilities:`Capabilities`};function xe(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function Se(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(t+1)}function Ce(e,t,n){let r=[];if(e?.http){let n=`http:${e.http.method}:${e.http.path}`;r.push({id:n,kind:`http`,label:`${e.http.method} ${e.http.path}`,flowIds:[t]})}if(e?.signal&&r.push({id:`signal:${e.signal}`,kind:`signal`,label:e.signal,flowIds:[t]}),e?.cron&&r.push({id:`cron:${e.cron}`,kind:`cron`,label:e.cron,flowIds:[t]}),e?.every&&r.push({id:`every:${e.every}`,kind:`every`,label:`every ${e.every}`,flowIds:[t]}),e?.cdc){let n=e.cdc.column?`.${e.cdc.column}`:``,i=`cdc:${e.cdc.table}${n}`;r.push({id:i,kind:`cdc`,label:`cdc ${e.cdc.table}${n}`,flowIds:[t]})}if(r.length===0)for(let e of n)r.push({id:`caller:${e}`,kind:`caller`,label:e,flowIds:[t]});return r}function X(e){if(!e)return[];let t=[];for(let n of e.reads??[])t.push(n);for(let n of e.writes??[])t.push(n);for(let n of e.emits??[])t.push(`signal:${n}`);for(let n of e.sends??[])t.push(`channel:${n}`);for(let n of e.asks??[])t.push(`ai:${n}`);for(let n of e.secrets??[])t.push(`secret:${n}`);for(let n of e.calls??[])t.push(`flow:${n}`);return t}function Z(e){return!e||typeof e==`string`?null:e}function we(e){return e.errors?Array.isArray(e.errors)?[...e.errors]:Object.keys(e.errors):[]}function Q(e){let t=e?.flows??{},n=Object.keys(t).sort(),r=new Map;for(let e of n){let n=t[e]?.effects?.calls??[];for(let t of n){let n=r.get(t)??[];n.push(e),r.set(t,n)}}let i=new Map;for(let e of n){let n=t[e]?.trigger?.signal;if(!n)continue;let r=i.get(n)??[];r.push(e),i.set(n,r)}let a=new Map,o=new Map,s=[];for(let e of n){let n=t[e];if(!n)continue;let c=r.get(e)??[],l=Ce(n.trigger,e,c);for(let t of l){let n=a.get(t.id);n?a.set(t.id,{...n,flowIds:[...new Set([...n.flowIds,e])]}):a.set(t.id,t)}let u=new Map,d=new Map;for(let e of n.effects?.emits??[])d.set(e,i.get(e)?.length??0);let f=_e(n.effects,{touchCounts:u,emitFanOut:d}),p=X(n.effects);for(let t of f){let n=t.kind===`emit`?`signal:${t.ref}`:t.kind===`send`?`channel:${t.ref}`:t.kind===`ask`?`ai:${t.ref}`:t.kind===`secret`?`secret:${t.ref}`:t.kind===`call`?`flow:${t.ref}`:t.ref,r=o.get(n);r?(r.flowIds.push(e),r.fanOut=Math.max(r.fanOut,t.fanOut??0)):o.set(n,{tier:t.tier,flowIds:[e],fanOut:t.fanOut??0})}s.push({id:e,unit:xe(e),action:Se(e),plane:n.plane??`user`,causeIds:l.map(e=>e.id),effectRefs:p,effects:f,peakTier:J(n.effects),external:Y(n.effects),flags:{durable:n.durable===!0,live:n.live===!0,cached:n.cache!==void 0&&n.cache!==!1,costsMoney:(n.cost?.estimatePerCall??0)>0,readsSecret:(n.effects?.secrets?.length??0)>0,touchesPii:n.pii!==void 0||n.allowPii===!0,external:Y(n.effects)},inSchema:Z(n.in),outSchema:Z(n.out),errorNames:we(n),source:n.source,deprecated:!!n.deprecated,raw:n})}if(e?.stores){for(let t of Object.values(e.stores))if(t.facet===`sql`&&t.tables)for(let e of Object.keys(t.tables)){let t=`sql:${e}`;o.has(t)||o.set(t,{tier:`reads`,flowIds:[],fanOut:0})}}if(e?.signals)for(let t of Object.keys(e.signals)){let e=`signal:${t}`;o.has(e)||o.set(e,{tier:`emits`,flowIds:[],fanOut:0})}if(e?.channels)for(let t of Object.keys(e.channels)){let e=`channel:${t}`;o.has(e)||o.set(e,{tier:`external`,flowIds:[],fanOut:0})}if(e?.vault)for(let t of Object.keys(e.vault)){let e=`secret:${t}`;o.has(e)||o.set(e,{tier:`capabilities`,flowIds:[],fanOut:0})}let c=[...a.values()].sort((e,t)=>e.label.localeCompare(t.label)),l=[...o.entries()].map(([e,t])=>({ref:e,tier:t.tier,flowIds:[...new Set(t.flowIds)].sort(),touchCount:new Set(t.flowIds).size,fanOut:t.fanOut})).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref));return{causes:c,flows:s,effects:l,causeById:new Map(c.map(e=>[e.id,e])),flowById:new Map(s.map(e=>[e.id,e])),effectByRef:new Map(l.map(e=>[e.ref,e]))}}function Te(e,t){let n=null;if(t.sel===`cause`&&t.cause){let r=e.causeById.get(t.cause);n=new Set(r?.flowIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect);n=new Set(r?.flowIds??[])}else t.sel===`flow`&&t.flow&&(n=new Set([t.flow]));return e.flows.map(e=>{let r=n===null||n.has(e.id),i=Oe(e,t.q),a=!t.unit||e.unit===t.unit,o=r&&i&&a;return{...e,match:o,related:r}})}function Ee(e,t){let n=null;if(t.sel===`flow`&&t.flow){let r=e.flowById.get(t.flow);n=new Set(r?.causeIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect),i=new Set;for(let t of r?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.causeIds??[])i.add(e)}n=i}return e.causes.map(e=>{let r=n===null||n.has(e.id),i=!t.q||e.label.toLowerCase().includes(t.q.toLowerCase())||e.id.toLowerCase().includes(t.q.toLowerCase());return{...e,match:r&&i,related:r}})}function De(e,t,n={}){let r=null;if(t.sel===`flow`&&t.flow){let n=e.flowById.get(t.flow);r=new Set(n?.effectRefs??[])}else if(t.sel===`cause`&&t.cause){let n=e.causeById.get(t.cause),i=new Set;for(let t of n?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.effectRefs??[])i.add(e)}r=i}let i=n.ubiquitousThreshold??8;return e.effects.map(e=>{let a=r===null||r.has(e.ref),o=!t.q||e.ref.toLowerCase().includes(t.q.toLowerCase()),s=!n.hideUbiquitous||e.touchCount<i||r!==null;return{...e,match:a&&o&&s,related:a}})}function Oe(e,t){if(!t?.trim())return!0;let n=t.toLowerCase();return e.id.toLowerCase().includes(n)||e.unit.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)}var $=l();function ke(){let e=f({from:`/architecture`}),t=n({from:`/architecture`}),i=e=>{t({search:ne(e),replace:!0})},a=r({queryKey:[`console.manifest.get`],queryFn:async()=>{let e=await o.manifestGet();if(e.error)throw Error(e.error.code);return e.data.manifest}}),s=r({queryKey:[`console.runs.list`],queryFn:async()=>{let e=await o.runsList();if(e.error)throw Error(e.error.code);return e.data.runs.map(W)},refetchInterval:1e4}),l=(0,G.useMemo)(()=>Q(a.data),[a.data]),d=y(e),p=(0,G.useMemo)(()=>F(l,{focus:e.focus??null,depth:e.depth,layers:y(e),runs:s.data??[]}),[l,e.focus,e.depth,e.data,e.messaging,e.time,e.external,s.data]),m=(0,G.useMemo)(()=>he(p.nodes),[p.nodes]);return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-4 border-b border-[var(--oke-line)] px-6 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`text-xs uppercase tracking-[0.2em] text-[var(--oke-muted)]`,children:`Architecture`}),(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`System shape`}),(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Clustered by unit · typed layers · traffic from Runs`})]}),(0,$.jsxs)(`p`,{className:`ml-auto font-mono text-sm`,role:`status`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Boundary crossings`}),` `,(0,$.jsx)(`span`,{className:`text-lg font-semibold tabular-nums`,children:p.boundaryCrossingCount})]})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0 lg:flex-row`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-4 border-b border-[var(--oke-line)] px-6 py-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Element layers`}),(0,$.jsx)(`span`,{className:`text-xs uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:`Layers`}),h.map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:d[t],onChange:n=>i(x(e,t,n.target.checked)),"aria-label":`${g[t]} layer`}),g[t]]},t))]}),e.focus?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Focus depth`}),(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:`Depth`}),[1,2].map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-1.5 text-sm`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`arch-depth`,checked:e.depth===t,onChange:()=>i(ie(e,t))}),t]},t))]}),(0,$.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>i(re(e)),children:`Clear focus`})]}):(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a unit to focus at depth 1–2`})]}),(0,$.jsxs)(`section`,{"aria-label":`System diagram`,className:`min-h-0 flex-1 overflow-auto px-4 py-4`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`mb-4 overflow-x-auto`,children:(0,$.jsxs)(`svg`,{className:`h-auto w-full max-w-5xl text-[var(--oke-fg)]`,viewBox:`0 0 640 380`,children:[(0,$.jsx)(`rect`,{x:K.x,y:K.y,width:K.width,height:K.height,fill:`color-mix(in oklab, var(--oke-fg) 3%, transparent)`,stroke:`var(--oke-muted)`,strokeDasharray:`8 5`,strokeWidth:1.5,rx:4}),(0,$.jsxs)(`text`,{x:K.x+12,y:K.y+18,className:`fill-[var(--oke-muted)]`,fontSize:11,fontFamily:`var(--oke-mono)`,children:[`System boundary · `,p.boundaryCrossingCount,` crossings`]}),p.edges.map(e=>{let t=m.get(e.from),n=m.get(e.to);return!t||!n?null:(0,$.jsx)(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:e.layer===`external`?`var(--oke-external)`:`var(--oke-muted)`,strokeWidth:e.thickness,strokeDasharray:e.dashed?`6 4`:void 0,opacity:e.dashed?.55:.9},e.id)}),p.nodes.map(e=>{let t=m.get(e.id);if(!t)return null;let n=e.kind===`unit`?28:22;return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`circle`,{cx:t.x,cy:t.y,r:n,fill:e.focused?`var(--oke-accent)`:e.insideBoundary?`var(--oke-bg)`:`color-mix(in oklab, var(--oke-external) 25%, var(--oke-bg))`,stroke:e.insideBoundary?`var(--oke-fg)`:`var(--oke-external)`,strokeWidth:e.focused?2.5:1.25}),(0,$.jsx)(`text`,{x:t.x,y:t.y+4,textAnchor:`middle`,fontSize:10,fontFamily:`var(--oke-mono)`,className:`fill-[var(--oke-fg)]`,children:Ae(e.label,12)})]},e.id)})]})}),(0,$.jsx)(`ul`,{"aria-label":`Nodes`,className:`flex flex-wrap gap-2 border-t border-[var(--oke-line)] pt-4`,children:p.nodes.map(t=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t.focused===!0,className:u(`inline-flex min-h-8 items-center gap-2 border px-3 text-sm`,t.focused?`border-[var(--oke-accent)] text-[var(--oke-fg)]`:`border-[var(--oke-line)] text-[var(--oke-muted)]`),onClick:()=>i(b(e,t.id)),children:[(0,$.jsx)(`span`,{children:t.label}),t.kind===`unit`&&t.flowCount!==void 0?(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:t.flowCount}):null,t.insideBoundary?null:(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-external)]`,children:`external`})]})},t.id))}),(0,$.jsx)(`ul`,{className:`sr-only`,"aria-label":`Edges`,children:p.edges.map(e=>(0,$.jsxs)(`li`,{children:[e.from,` → `,e.to,e.dashed?` (declared, never traversed)`:` · ${e.traversals} traversals`,` · ${e.layer}`]},e.id))})]})]}),(0,$.jsxs)(`aside`,{"aria-label":`Findings`,className:`w-full shrink-0 overflow-auto border-t border-[var(--oke-line)] lg:w-80 lg:border-l lg:border-t-0`,children:[(0,$.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium`,children:`Findings`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:`Pathologies from the graph as data`})]}),p.findings.length===0?(0,$.jsx)(`p`,{className:`px-5 pb-4 text-sm text-[var(--oke-muted)]`,children:`No pathologies detected.`}):(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--oke-line)] border-t border-[var(--oke-line)]`,children:p.findings.map((t,n)=>(0,$.jsxs)(`li`,{className:`px-5 py-3`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(`span`,{className:u(`inline-block size-1.5 rounded-full`,t.severity===`critical`?`bg-[var(--oke-danger)]`:`bg-[var(--oke-external)]`),"aria-hidden":!0}),t.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:t.detail}),t.nodeIds[0]?(0,$.jsx)(`button`,{type:`button`,className:`mt-2 min-h-8 text-sm text-[var(--oke-accent)] underline-offset-2 hover:underline`,onClick:()=>i(b(e,t.nodeIds[0])),children:`Focus`}):null]},`${t.kind}-${n}`))})]})]})]})}function Ae(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}var je=t({default:()=>ke});export{De as a,W as c,te as d,Ee as i,me as l,Q as n,be as o,Te as r,ye as s,je as t,A as u};
1
+ import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,_ as i,b as a,d as o,nt as s,o as c,tt as l,u,v as d,w as f,x as p,y as m}from"./panel-access-C0J2D-a2.js";var h=[`data`,`messaging`,`time`,`external`],g={data:`Data`,messaging:`Messaging`,time:`Time`,external:`External`},_={data:!0,messaging:!0,time:!0,external:!0},v=p([i(),d(`true`),d(`false`)]).transform(e=>e===!0||e===`true`),ee=m({focus:a().optional(),depth:p([d(1),d(2),d(`1`),d(`2`)]).transform(e=>Number(e)===2?2:1).default(1),data:v.optional(),messaging:v.optional(),time:v.optional(),external:v.optional()});function te(e){let t=ee.safeParse(e);return t.success?t.data:{depth:1}}function ne(e){let t={};e.focus&&(t.focus=e.focus),e.depth===2&&(t.depth=`2`);for(let n of h)e[n]===!1&&(t[n]=`false`);return t}function y(e){return{data:e.data??_.data,messaging:e.messaging??_.messaging,time:e.time??_.time,external:e.external??_.external}}function b(e,t){return{...e,focus:t}}function re(e){let{focus:t,...n}=e;return{...n,depth:e.depth}}function ie(e,t){return{...e,depth:t}}function x(e,t,n){return{...e,[t]:n}}function S(e){return e.startsWith(`sql:`)||e.startsWith(`kv:`)||e.startsWith(`files:`)||e.startsWith(`index:`)?`data`:e.startsWith(`signal:`)?`messaging`:e.startsWith(`channel:`)||e.startsWith(`ai:`)?`external`:null}function ae(e){return e.kind===`signal`?`messaging`:e.kind===`cron`||e.kind===`every`?`time`:null}function C(e){return e.startsWith(`channel:`)||e.startsWith(`ai:`)}function w(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(t+1)}function oe(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return t.size}function se(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return[...t].sort()}function ce(e,t){switch(e){case`emit`:return t.startsWith(`signal:`)?t:`signal:${t}`;case`send`:return t.startsWith(`channel:`)?t:`channel:${t}`;case`ask`:return t.startsWith(`ai:`)?t:`ai:${t}`;case`secret`:return t.startsWith(`secret:`)?t:`secret:${t}`;case`call`:return t.startsWith(`flow:`)?t:`flow:${t}`;default:return t}}function T(e,t){return`${e}\0${t}`}function le(e){let t=new Map;for(let n of e){for(let e of n.effects){let r=ce(e.kind,e.resource),i=T(n.flow,r);t.set(i,(t.get(i)??0)+1)}n.parentId}return t}function E(e,t,n){return e.get(T(t,n))??0}function ue(e,t){if(e<=0)return 1;if(t<=1)return 2;let n=e/t;return Math.max(1,Math.min(8,Math.ceil(n*8)))}function D(e){let t=[],n=pe(e);for(let r of e.flows){for(let n of r.causeIds){let i=e.causeById.get(n);if(!i)continue;let a=ae(i);a&&t.push({from:`cause:${i.id}`,to:`flow:${r.id}`,flowId:r.id,layer:a,fromUnit:r.unit,toUnit:r.unit})}for(let i of r.effectRefs){if(i.startsWith(`flow:`)){let e=i.slice(5),n=O(e);t.push({from:`flow:${r.id}`,to:`flow:${e}`,flowId:r.id,ref:i,layer:`call`,fromUnit:r.unit,toUnit:n});continue}let a=S(i);if(!a)continue;let o=C(i)?`external`:de(i,e);if(t.push({from:`flow:${r.id}`,to:i,flowId:r.id,ref:i,layer:a,fromUnit:r.unit,toUnit:o}),a===`messaging`&&i.startsWith(`signal:`)){let a=i.slice(7);for(let o of n.get(a)??[]){let n=e.flowById.get(o);!n||n.id===r.id||t.push({from:`flow:${r.id}`,to:`flow:${n.id}`,flowId:r.id,ref:i,layer:`messaging`,fromUnit:r.unit,toUnit:n.unit})}}}}return t}function de(e,t){let n=t.effectByRef.get(e);if(!n||n.flowIds.length===0)return`shared`;let r=n.flowIds.filter(n=>{let r=t.flowById.get(n);return r?fe(r,e):!1})[0]??n.flowIds[0];return r?O(r):`shared`}function fe(e,t){let n=e.raw.effects;if(!n)return!1;if(t.startsWith(`signal:`)){let e=t.slice(7);return(n.emits??[]).includes(e)}return!!(n.writes??[]).includes(t)}function pe(e){let t=new Map;for(let n of e.flows){let e=n.raw.trigger?.signal;if(!e)continue;let r=t.get(e)??[];r.push(n.id),t.set(e,r)}return t}function O(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function k(e){let t=[];return t.push(...A(e)),t.push(...j(e)),t.push(...M(e)),t.push(...N(e)),t}function A(e){let t=new Map,n=e=>{let n=t.get(e);return n||(n=new Set,t.set(e,n)),n};for(let t of D(e)){if(!t.from.startsWith(`flow:`)||!t.to.startsWith(`flow:`))continue;let e=t.from.slice(5),r=t.to.slice(5);n(e).add(r)}let r=[],i=new Set,a=[],o=new Set,s=e=>{i.add(e),a.push(e),o.add(e);for(let n of t.get(e)??[])if(!i.has(n))s(n);else if(o.has(n)){let e=a.indexOf(n);e!==-1&&r.push([...a.slice(e),n])}a.pop(),o.delete(e)};for(let t of e.flows.map(e=>e.id))i.has(t)||s(t);let c=new Set,l=[];for(let e of r){let t=P(e.slice(0,-1)),n=t.join(`→`);c.has(n)||(c.add(n),l.push({kind:`cycle`,severity:`critical`,title:`Cycle`,detail:`Causal cycle: ${t.join(` → `)}`,nodeIds:t.map(e=>`flow:${e}`)}))}return l}function j(e){if(e.effects.length===0)return[];let t=[...e.effects].filter(e=>e.touchCount>0).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref)),n=t[0];if(!n||n.touchCount<2)return[];let r=t[1]?.touchCount??0;return n.touchCount===r&&t.filter(e=>e.touchCount===n.touchCount).length>1?t.filter(e=>e.touchCount===n.touchCount).map(e=>({kind:`god-node`,severity:`warning`,title:`God node`,detail:`${e.ref} is touched by ${e.touchCount} flows — the most in the system`,nodeIds:[e.ref]})):[{kind:`god-node`,severity:`warning`,title:`God node`,detail:`${n.ref} is touched by ${n.touchCount} flows — the most in the system`,nodeIds:[n.ref]}]}function M(e){let t=[],n=new Set;for(let t of e.effects)t.ref.startsWith(`signal:`)&&n.add(t.ref.slice(7));for(let t of e.flows){for(let e of t.raw.effects?.emits??[])n.add(e);let e=t.raw.trigger?.signal;e&&n.add(e)}for(let r of[...n].sort()){let n=`signal:${r}`,i=e.flows.filter(e=>(e.raw.effects?.emits??[]).includes(r)),a=e.flows.filter(e=>e.raw.trigger?.signal===r);if(i.length===0&&a.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is declared but has no producers and no consumers`,nodeIds:[n]});continue}if(i.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} has consumers but no producer`,nodeIds:[n,...a.map(e=>`flow:${e.id}`)]});continue}a.length===0&&t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is emitted but has no consumers`,nodeIds:[n,...i.map(e=>`flow:${e.id}`)]})}return t}function N(e){let t=[];for(let n of e.effects){if(n.touchCount<2||n.ref.startsWith(`secret:`)||n.ref.startsWith(`channel:`)||n.ref.startsWith(`ai:`))continue;let r=n.flowIds.filter(t=>{let r=e.flowById.get(t);if(!r?.raw.effects)return!1;if(n.ref.startsWith(`signal:`)){let e=n.ref.slice(7);return(r.raw.effects.emits??[]).includes(e)}return(r.raw.effects.writes??[]).includes(n.ref)});if(r.length!==1)continue;let i=r[0];t.push({kind:`spof`,severity:`critical`,title:`Single point of failure`,detail:`${n.ref} is touched by ${n.touchCount} flows but written/emitted by only ${i}`,nodeIds:[n.ref,`flow:${i}`]})}return t}function P(e){if(e.length===0)return[];let t=[...e],n=t.join(`\0`);for(let r=1;r<e.length;r++){let i=[...e.slice(r),...e.slice(0,r)],a=i.join(`\0`);a<n&&(t=i,n=a)}return t}function F(e,t={}){let n=t.focus??null,r=t.depth===2?2:1,i=t.layers??_,a=le(t.runs??[]),o=D(e),s=k(e),c=oe(e);return n?L({graph:e,declared:o,traffic:a,focus:n,depth:r,layers:i,findings:s,crossings:c}):I({graph:e,declared:o,traffic:a,layers:i,findings:s,crossings:c})}function I(e){let{graph:t,declared:n,traffic:r,layers:i,findings:a,crossings:o}=e,s=[...new Set(t.flows.map(e=>e.unit))].sort().map(e=>({id:`unit:${e}`,kind:`unit`,label:e,unit:e,insideBoundary:!0,flowCount:t.flows.filter(t=>t.unit===e).length}));for(let e of se(t))s.push({id:e,kind:`external`,label:w(e),layer:`external`,insideBoundary:!1});let c=new Map;for(let e of n){if(!V(e.layer,i))continue;let t=`unit:${e.fromUnit}`,n=null;if(e.toUnit===`external`||C(e.to))n=e.ref??e.to;else if(e.fromUnit!==e.toUnit)n=`unit:${e.toUnit}`;else continue;if(t===n)continue;let a=`${t}\0${n}\0${e.layer}`,o=e.ref?E(r,e.flowId,e.ref):0,s=c.get(a);s?s.traversals+=o:c.set(a,{from:t,to:n,layer:e.layer,traversals:o,declared:!0})}let l=H(c,!0);return{nodes:U(s),edges:l,boundaryCrossingCount:o,findings:a,focus:null,depth:1,layers:i}}function L(e){let{graph:t,declared:n,traffic:r,focus:i,depth:a,layers:o,findings:s,crossings:c}=e,l=z(t,n,i,a),u=[];for(let e of l){let r=B(t,n,i,e,a);if(e.startsWith(`unit:`)){let n=e.slice(5);u.push({id:e,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:t.flows.filter(e=>e.unit===n).length,focused:e===i,depth:r});continue}if(e.startsWith(`flow:`)){let n=e.slice(5),a=t.flowById.get(n);u.push({id:e,kind:`flow`,label:n,unit:a?.unit??O(n),insideBoundary:!0,focused:e===i,depth:r});continue}if(e.startsWith(`cause:`)){let n=e.slice(6),a=t.causeById.get(n),s=a?.kind===`cron`||a?.kind===`every`?`time`:a?.kind===`signal`?`messaging`:void 0;if(!s||!o[s])continue;u.push({id:e,kind:`resource`,label:a?.label??n,layer:s,insideBoundary:!0,focused:e===i,depth:r});continue}u.push({id:e,kind:C(e)?`external`:`resource`,label:w(e),layer:C(e)?`external`:e.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(e),focused:e===i,depth:r})}u.some(e=>e.id===i)||u.push(...R(t,i));let d=new Map,f=new Set(u.map(e=>e.id));for(let e of n){if(!V(e.layer,o))continue;let t=e.from,n=e.to;if(!f.has(t)||!f.has(n))continue;let i=`${t}\0${n}\0${e.layer}`,a=e.ref?E(r,e.flowId,e.ref):0,s=d.get(i);s?s.traversals+=a:d.set(i,{from:t,to:n,layer:e.layer,traversals:a,declared:!0})}return{nodes:U(u),edges:H(d,!1),boundaryCrossingCount:c,findings:s,focus:i,depth:a,layers:o}}function R(e,t){if(t.startsWith(`unit:`)){let n=t.slice(5);return[{id:t,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:e.flows.filter(e=>e.unit===n).length,focused:!0,depth:0}]}if(t.startsWith(`flow:`)){let n=t.slice(5);return[{id:t,kind:`flow`,label:n,unit:e.flowById.get(n)?.unit??O(n),insideBoundary:!0,focused:!0,depth:0}]}return[{id:t,kind:C(t)?`external`:`resource`,label:w(t),layer:C(t)?`external`:t.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(t),focused:!0,depth:0}]}function z(e,t,n,r){let i=new Set([n]);if(n.startsWith(`unit:`)){let t=n.slice(5);for(let n of e.flows)n.unit===t&&i.add(`flow:${n.id}`)}let a=new Set(i);for(let e=0;e<r;e++){let e=new Set;for(let n of t){let t=n.from,r=n.to;a.has(t)&&e.add(r),a.has(r)&&e.add(t);for(let n of[t,r]){if(!n.startsWith(`flow:`))continue;let t=`unit:${O(n.slice(5))}`;a.has(n)&&e.add(t),a.has(t)&&e.add(n)}}for(let t of e)i.add(t);a=e}return i}function B(e,t,n,r,i){if(n===r)return 0;let a=new Set([n]),o=new Set([n]);for(let n=1;n<=i;n++){let i=new Set;for(let e of t){let t=e.from,s=e.to;for(let[e,c]of[[t,s],[s,t]])if(o.has(e)){if(c===r)return n;a.has(c)||(a.add(c),i.add(c))}}for(let t of o){if(t.startsWith(`flow:`)){let e=`unit:${O(t.slice(5))}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}if(t.startsWith(`unit:`)){let o=t.slice(5);for(let t of e.flows){if(t.unit!==o)continue;let e=`flow:${t.id}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}}}o=i}return i}function V(e,t){return e===`call`||t[e]}function H(e,t){let n=Math.max(0,...[...e.values()].map(e=>e.traversals));return[...e.values()].map(e=>({id:`${e.from}->${e.to}:${e.layer}`,from:e.from,to:e.to,layer:e.layer,declared:e.declared,traversals:e.traversals,dashed:e.declared&&e.traversals===0,thickness:ue(e.traversals,n),aggregated:t})).sort((e,t)=>e.id.localeCompare(t.id))}function U(e){let t=new Map;for(let n of e)t.has(n.id)||t.set(n.id,n);return[...t.values()].sort((e,t)=>e.id.localeCompare(t.id))}function W(e){let t={...e.dimensions??{}};return t.flow===void 0&&(t.flow=e.flow),t.unit===void 0&&(t.unit=e.unit??null),t.trigger===void 0&&(t.trigger=e.trigger),t.plane===void 0&&(t.plane=e.plane),t.tenant===void 0&&(t.tenant=e.tenant??null),t.principal===void 0&&(t.principal=e.principal??null),t.cache===void 0&&(t.cache=e.cache??`none`),t.duration_ms===void 0&&(t.duration_ms=e.durationMs),t.error_code===void 0&&e.error&&(t.error_code=e.error),{id:e.id,parentId:e.parentId??null,flow:e.flow,unit:e.unit??null,trigger:e.trigger,plane:e.plane,tenant:e.tenant??null,principal:e.principal??null,gates:e.gates??[],cache:e.cache??`none`,replica:e.replica??null,replicaLagMs:e.replicaLagMs??null,cost:e.cost??null,promptVersion:e.promptVersion??null,buildVersion:e.buildVersion??null,startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs,error:e.error??null,effects:e.effects??[],logs:e.logs??[],dimensions:t}}function me(e){return{id:e.id,...e.parentId?{parentId:e.parentId}:{},flow:e.flow,...e.unit?{unit:e.unit}:{},trigger:e.trigger,plane:e.plane,tenant:e.tenant,principal:e.principal,gates:e.gates,cache:e.cache,...e.replica?{replica:e.replica}:{},...e.replicaLagMs==null?{}:{replicaLagMs:e.replicaLagMs},...e.cost==null?{}:{cost:e.cost},...e.promptVersion==null?{}:{promptVersion:e.promptVersion},...e.buildVersion?{buildVersion:e.buildVersion}:{},error:e.error?{code:e.error}:null,effects:e.effects,logs:e.logs,durationMs:e.durationMs,startedAt:e.startedAt,endedAt:e.endedAt,dimensions:{...e.dimensions}}}var G=e(s(),1),K={x:32,y:40,width:440,height:300};function he(e){let t=e.filter(e=>e.insideBoundary),n=e.filter(e=>!e.insideBoundary),r=new Map,i=Math.max(1,Math.ceil(Math.sqrt(t.length))),a=K.width/(i+1),o=Math.max(1,Math.ceil(t.length/i)),s=K.height/(o+1);return t.forEach((e,t)=>{let n=t%i,o=Math.floor(t/i);r.set(e.id,{id:e.id,x:K.x+a*(n+1),y:K.y+s*(o+1)})}),n.forEach((e,t)=>{r.set(e.id,{id:e.id,x:K.x+K.width+96,y:K.y+48+t*56})}),r}var q={read:`none`,write:`reversible`,emit:`deferred`,send:`irreversible`,ask:`irreversible`,secret:`capability`,call:`portal`};function ge(e){return q[e]}Object.entries(q).map(([e,t])=>({kind:e,reversibility:t}));function _e(e,t={}){if(!e)return[];let n=t.touchCounts,r=t.emitFanOut,i=[],a=(e,a,o)=>{for(let s of o??[])i.push({tier:e,kind:a,ref:s,reversibility:ge(a),touchCount:n?.get(s)??1,fanOut:a===`emit`?r?.get(s)??0:void 0,transitive:t.transitive})};return a(`reads`,`read`,e.reads),a(`writes`,`write`,e.writes),a(`emits`,`emit`,e.emits),a(`external`,`send`,e.sends),a(`external`,`ask`,e.asks),a(`capabilities`,`secret`,e.secrets),i}function J(e){return e?(e.sends?.length??0)>0||(e.asks?.length??0)>0?`external`:(e.secrets?.length??0)>0?`capabilities`:(e.emits?.length??0)>0?`emits`:(e.writes?.length??0)>0?`writes`:(e.reads?.length??0)>0?`reads`:`none`:`none`}function Y(e){return ve(J(e))}function ve(e){return e===`external`}var ye=[`reads`,`writes`,`emits`,`external`,`capabilities`],be={reads:`Reads`,writes:`Writes`,emits:`Emits`,external:`External`,capabilities:`Capabilities`};function xe(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function Se(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(t+1)}function Ce(e,t,n){let r=[];if(e?.http){let n=`http:${e.http.method}:${e.http.path}`;r.push({id:n,kind:`http`,label:`${e.http.method} ${e.http.path}`,flowIds:[t]})}if(e?.signal&&r.push({id:`signal:${e.signal}`,kind:`signal`,label:e.signal,flowIds:[t]}),e?.cron&&r.push({id:`cron:${e.cron}`,kind:`cron`,label:e.cron,flowIds:[t]}),e?.every&&r.push({id:`every:${e.every}`,kind:`every`,label:`every ${e.every}`,flowIds:[t]}),e?.cdc){let n=e.cdc.column?`.${e.cdc.column}`:``,i=`cdc:${e.cdc.table}${n}`;r.push({id:i,kind:`cdc`,label:`cdc ${e.cdc.table}${n}`,flowIds:[t]})}if(r.length===0)for(let e of n)r.push({id:`caller:${e}`,kind:`caller`,label:e,flowIds:[t]});return r}function X(e){if(!e)return[];let t=[];for(let n of e.reads??[])t.push(n);for(let n of e.writes??[])t.push(n);for(let n of e.emits??[])t.push(`signal:${n}`);for(let n of e.sends??[])t.push(`channel:${n}`);for(let n of e.asks??[])t.push(`ai:${n}`);for(let n of e.secrets??[])t.push(`secret:${n}`);for(let n of e.calls??[])t.push(`flow:${n}`);return t}function Z(e){return!e||typeof e==`string`?null:e}function we(e){return e.errors?Array.isArray(e.errors)?[...e.errors]:Object.keys(e.errors):[]}function Q(e){let t=e?.flows??{},n=Object.keys(t).sort(),r=new Map;for(let e of n){let n=t[e]?.effects?.calls??[];for(let t of n){let n=r.get(t)??[];n.push(e),r.set(t,n)}}let i=new Map;for(let e of n){let n=t[e]?.trigger?.signal;if(!n)continue;let r=i.get(n)??[];r.push(e),i.set(n,r)}let a=new Map,o=new Map,s=[];for(let e of n){let n=t[e];if(!n)continue;let c=r.get(e)??[],l=Ce(n.trigger,e,c);for(let t of l){let n=a.get(t.id);n?a.set(t.id,{...n,flowIds:[...new Set([...n.flowIds,e])]}):a.set(t.id,t)}let u=new Map,d=new Map;for(let e of n.effects?.emits??[])d.set(e,i.get(e)?.length??0);let f=_e(n.effects,{touchCounts:u,emitFanOut:d}),p=X(n.effects);for(let t of f){let n=t.kind===`emit`?`signal:${t.ref}`:t.kind===`send`?`channel:${t.ref}`:t.kind===`ask`?`ai:${t.ref}`:t.kind===`secret`?`secret:${t.ref}`:t.kind===`call`?`flow:${t.ref}`:t.ref,r=o.get(n);r?(r.flowIds.push(e),r.fanOut=Math.max(r.fanOut,t.fanOut??0)):o.set(n,{tier:t.tier,flowIds:[e],fanOut:t.fanOut??0})}s.push({id:e,unit:xe(e),action:Se(e),plane:n.plane??`user`,causeIds:l.map(e=>e.id),effectRefs:p,effects:f,peakTier:J(n.effects),external:Y(n.effects),flags:{durable:n.durable===!0,live:n.live===!0,cached:n.cache!==void 0&&n.cache!==!1,costsMoney:(n.cost?.estimatePerCall??0)>0,readsSecret:(n.effects?.secrets?.length??0)>0,touchesPii:n.pii!==void 0||n.allowPii===!0,external:Y(n.effects)},inSchema:Z(n.in),outSchema:Z(n.out),errorNames:we(n),source:n.source,deprecated:!!n.deprecated,raw:n})}if(e?.stores){for(let t of Object.values(e.stores))if(t.facet===`sql`&&t.tables)for(let e of Object.keys(t.tables)){let t=`sql:${e}`;o.has(t)||o.set(t,{tier:`reads`,flowIds:[],fanOut:0})}}if(e?.signals)for(let t of Object.keys(e.signals)){let e=`signal:${t}`;o.has(e)||o.set(e,{tier:`emits`,flowIds:[],fanOut:0})}if(e?.channels)for(let t of Object.keys(e.channels)){let e=`channel:${t}`;o.has(e)||o.set(e,{tier:`external`,flowIds:[],fanOut:0})}if(e?.vault)for(let t of Object.keys(e.vault)){let e=`secret:${t}`;o.has(e)||o.set(e,{tier:`capabilities`,flowIds:[],fanOut:0})}let c=[...a.values()].sort((e,t)=>e.label.localeCompare(t.label)),l=[...o.entries()].map(([e,t])=>({ref:e,tier:t.tier,flowIds:[...new Set(t.flowIds)].sort(),touchCount:new Set(t.flowIds).size,fanOut:t.fanOut})).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref));return{causes:c,flows:s,effects:l,causeById:new Map(c.map(e=>[e.id,e])),flowById:new Map(s.map(e=>[e.id,e])),effectByRef:new Map(l.map(e=>[e.ref,e]))}}function Te(e,t){let n=null;if(t.sel===`cause`&&t.cause){let r=e.causeById.get(t.cause);n=new Set(r?.flowIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect);n=new Set(r?.flowIds??[])}else t.sel===`flow`&&t.flow&&(n=new Set([t.flow]));return e.flows.map(e=>{let r=n===null||n.has(e.id),i=Oe(e,t.q),a=!t.unit||e.unit===t.unit,o=r&&i&&a;return{...e,match:o,related:r}})}function Ee(e,t){let n=null;if(t.sel===`flow`&&t.flow){let r=e.flowById.get(t.flow);n=new Set(r?.causeIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect),i=new Set;for(let t of r?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.causeIds??[])i.add(e)}n=i}return e.causes.map(e=>{let r=n===null||n.has(e.id),i=!t.q||e.label.toLowerCase().includes(t.q.toLowerCase())||e.id.toLowerCase().includes(t.q.toLowerCase());return{...e,match:r&&i,related:r}})}function De(e,t,n={}){let r=null;if(t.sel===`flow`&&t.flow){let n=e.flowById.get(t.flow);r=new Set(n?.effectRefs??[])}else if(t.sel===`cause`&&t.cause){let n=e.causeById.get(t.cause),i=new Set;for(let t of n?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.effectRefs??[])i.add(e)}r=i}let i=n.ubiquitousThreshold??8;return e.effects.map(e=>{let a=r===null||r.has(e.ref),o=!t.q||e.ref.toLowerCase().includes(t.q.toLowerCase()),s=!n.hideUbiquitous||e.touchCount<i||r!==null;return{...e,match:a&&o&&s,related:a}})}function Oe(e,t){if(!t?.trim())return!0;let n=t.toLowerCase();return e.id.toLowerCase().includes(n)||e.unit.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)}var $=l();function ke(){let e=f({from:`/architecture`}),t=n({from:`/architecture`}),i=e=>{t({search:ne(e),replace:!0})},a=r({queryKey:[`console.manifest.get`],queryFn:async()=>{let e=await o.manifestGet();if(e.error)throw Error(e.error.code);return e.data.manifest}}),s=r({queryKey:[`console.runs.list`],queryFn:async()=>{let e=await o.runsList();if(e.error)throw Error(e.error.code);return e.data.runs.map(W)},refetchInterval:1e4}),l=(0,G.useMemo)(()=>Q(a.data),[a.data]),d=y(e),p=(0,G.useMemo)(()=>F(l,{focus:e.focus??null,depth:e.depth,layers:y(e),runs:s.data??[]}),[l,e.focus,e.depth,e.data,e.messaging,e.time,e.external,s.data]),m=(0,G.useMemo)(()=>he(p.nodes),[p.nodes]);return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-4 border-b border-[var(--oke-line)] px-6 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`text-xs uppercase tracking-[0.2em] text-[var(--oke-muted)]`,children:`Architecture`}),(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`System shape`}),(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Clustered by unit · typed layers · traffic from Runs`})]}),(0,$.jsxs)(`p`,{className:`ml-auto font-mono text-sm`,role:`status`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Boundary crossings`}),` `,(0,$.jsx)(`span`,{className:`text-lg font-semibold tabular-nums`,children:p.boundaryCrossingCount})]})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0 lg:flex-row`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-4 border-b border-[var(--oke-line)] px-6 py-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Element layers`}),(0,$.jsx)(`span`,{className:`text-xs uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:`Layers`}),h.map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:d[t],onChange:n=>i(x(e,t,n.target.checked)),"aria-label":`${g[t]} layer`}),g[t]]},t))]}),e.focus?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Focus depth`}),(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:`Depth`}),[1,2].map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-1.5 text-sm`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`arch-depth`,checked:e.depth===t,onChange:()=>i(ie(e,t))}),t]},t))]}),(0,$.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>i(re(e)),children:`Clear focus`})]}):(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a unit to focus at depth 1–2`})]}),(0,$.jsxs)(`section`,{"aria-label":`System diagram`,className:`min-h-0 flex-1 overflow-auto px-4 py-4`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`mb-4 overflow-x-auto`,children:(0,$.jsxs)(`svg`,{className:`h-auto w-full max-w-5xl text-[var(--oke-fg)]`,viewBox:`0 0 640 380`,children:[(0,$.jsx)(`rect`,{x:K.x,y:K.y,width:K.width,height:K.height,fill:`color-mix(in oklab, var(--oke-fg) 3%, transparent)`,stroke:`var(--oke-muted)`,strokeDasharray:`8 5`,strokeWidth:1.5,rx:4}),(0,$.jsxs)(`text`,{x:K.x+12,y:K.y+18,className:`fill-[var(--oke-muted)]`,fontSize:11,fontFamily:`var(--oke-mono)`,children:[`System boundary · `,p.boundaryCrossingCount,` crossings`]}),p.edges.map(e=>{let t=m.get(e.from),n=m.get(e.to);return!t||!n?null:(0,$.jsx)(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:e.layer===`external`?`var(--oke-external)`:`var(--oke-muted)`,strokeWidth:e.thickness,strokeDasharray:e.dashed?`6 4`:void 0,opacity:e.dashed?.55:.9},e.id)}),p.nodes.map(e=>{let t=m.get(e.id);if(!t)return null;let n=e.kind===`unit`?28:22;return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`circle`,{cx:t.x,cy:t.y,r:n,fill:e.focused?`var(--oke-accent)`:e.insideBoundary?`var(--oke-bg)`:`color-mix(in oklab, var(--oke-external) 25%, var(--oke-bg))`,stroke:e.insideBoundary?`var(--oke-fg)`:`var(--oke-external)`,strokeWidth:e.focused?2.5:1.25}),(0,$.jsx)(`text`,{x:t.x,y:t.y+4,textAnchor:`middle`,fontSize:10,fontFamily:`var(--oke-mono)`,className:`fill-[var(--oke-fg)]`,children:Ae(e.label,12)})]},e.id)})]})}),(0,$.jsx)(`ul`,{"aria-label":`Nodes`,className:`flex flex-wrap gap-2 border-t border-[var(--oke-line)] pt-4`,children:p.nodes.map(t=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t.focused===!0,className:u(`inline-flex min-h-8 items-center gap-2 border px-3 text-sm`,t.focused?`border-[var(--oke-accent)] text-[var(--oke-fg)]`:`border-[var(--oke-line)] text-[var(--oke-muted)]`),onClick:()=>i(b(e,t.id)),children:[(0,$.jsx)(`span`,{children:t.label}),t.kind===`unit`&&t.flowCount!==void 0?(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:t.flowCount}):null,t.insideBoundary?null:(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-external)]`,children:`external`})]})},t.id))}),(0,$.jsx)(`ul`,{className:`sr-only`,"aria-label":`Edges`,children:p.edges.map(e=>(0,$.jsxs)(`li`,{children:[e.from,` → `,e.to,e.dashed?` (declared, never traversed)`:` · ${e.traversals} traversals`,` · ${e.layer}`]},e.id))})]})]}),(0,$.jsxs)(`aside`,{"aria-label":`Findings`,className:`w-full shrink-0 overflow-auto border-t border-[var(--oke-line)] lg:w-80 lg:border-l lg:border-t-0`,children:[(0,$.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium`,children:`Findings`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:`Pathologies from the graph as data`})]}),p.findings.length===0?(0,$.jsx)(`p`,{className:`px-5 pb-4 text-sm text-[var(--oke-muted)]`,children:`No pathologies detected.`}):(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--oke-line)] border-t border-[var(--oke-line)]`,children:p.findings.map((t,n)=>(0,$.jsxs)(`li`,{className:`px-5 py-3`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(`span`,{className:u(`inline-block size-1.5 rounded-full`,t.severity===`critical`?`bg-[var(--oke-danger)]`:`bg-[var(--oke-external)]`),"aria-hidden":!0}),t.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:t.detail}),t.nodeIds[0]?(0,$.jsx)(`button`,{type:`button`,className:`mt-2 min-h-8 text-sm text-[var(--oke-accent)] underline-offset-2 hover:underline`,onClick:()=>i(b(e,t.nodeIds[0])),children:`Focus`}):null]},`${t.kind}-${n}`))})]})]})]})}function Ae(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}var je=t({default:()=>ke});export{De as a,W as c,te as d,Ee as i,me as l,Q as n,be as o,Te as r,ye as s,je as t,A as u};