@cortex-agent/server 2026.11.17 → 2026.12.5

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 (338) hide show
  1. package/README.md +5 -5
  2. package/THIRD_PARTY_NOTICES.txt +860 -294
  3. package/defaults/hooks/quota-stop.mjs +37 -0
  4. package/defaults/prompts/clean-workspace.md +5 -0
  5. package/dist/agent-adapter/claude/remote-mcp-proxy.js +1 -1
  6. package/dist/chunks/agent-runner-LVZVKBZX.js +4 -0
  7. package/dist/chunks/anthropic-messages-TT6454AA.js +8 -0
  8. package/dist/chunks/azure-openai-responses-52LR2XZD.js +4 -0
  9. package/dist/chunks/bedrock-converse-stream-EOZGYUNY.js +60 -0
  10. package/dist/chunks/child-runner-SMG2VOU5.js +4 -0
  11. package/dist/chunks/chunk-24DH4IR5.js +4 -0
  12. package/dist/chunks/chunk-25XKBRDT.js +70 -0
  13. package/dist/chunks/{chunk-VTL3Z2OP.js → chunk-2ABET62E.js} +1 -1
  14. package/dist/chunks/chunk-2BVUA256.js +4 -0
  15. package/dist/chunks/{chunk-4YLAGSDM.js → chunk-2WFL62UO.js} +1 -1
  16. package/dist/chunks/{chunk-LQTFDC67.js → chunk-335SSANX.js} +1 -1
  17. package/dist/chunks/chunk-377OPTXX.js +17 -0
  18. package/dist/chunks/chunk-3EZNVLBF.js +129 -0
  19. package/dist/chunks/{chunk-V6X7Y62J.js → chunk-3O6ZG5HA.js} +1 -1
  20. package/dist/chunks/{chunk-6AKUD3CF.js → chunk-3XLHL5YT.js} +1 -1
  21. package/dist/chunks/{chunk-2ATTYCRJ.js → chunk-4HRI75GU.js} +1 -1
  22. package/dist/chunks/chunk-4JBYLRPM.js +57 -0
  23. package/dist/chunks/chunk-4KKV7VKE.js +4 -0
  24. package/dist/chunks/chunk-4KQHDDC5.js +4 -0
  25. package/dist/chunks/chunk-4SWD4JMP.js +33 -0
  26. package/dist/chunks/chunk-52VCLZS5.js +4 -0
  27. package/dist/chunks/chunk-54P7TSY3.js +10 -0
  28. package/dist/chunks/chunk-5DVSAXOI.js +7 -0
  29. package/dist/chunks/chunk-5F3A62YS.js +4 -0
  30. package/dist/chunks/{chunk-S3MR37DL.js → chunk-5FHETFZM.js} +1 -1
  31. package/dist/chunks/{chunk-CEGSDGYQ.js → chunk-5LBLRAHS.js} +1 -1
  32. package/dist/chunks/chunk-5UYVNA3W.js +4 -0
  33. package/dist/chunks/chunk-6G3OYMCV.js +21 -0
  34. package/dist/chunks/chunk-7GGPYU5E.js +30 -0
  35. package/dist/chunks/chunk-7TYSMLUV.js +4 -0
  36. package/dist/chunks/chunk-7W7VYUTK.js +5 -0
  37. package/dist/chunks/chunk-AXYAZTTN.js +6 -0
  38. package/dist/chunks/chunk-B3NB243Z.js +4 -0
  39. package/dist/chunks/{chunk-XPPZ6Y3X.js → chunk-BKYP6AGM.js} +1 -1
  40. package/dist/chunks/{chunk-QUXPMNFQ.js → chunk-BVEDNESB.js} +1 -1
  41. package/dist/chunks/chunk-BWDJS6A4.js +12 -0
  42. package/dist/chunks/chunk-C6YVF7EI.js +4 -0
  43. package/dist/chunks/chunk-CEJIYYVE.js +15 -0
  44. package/dist/chunks/{chunk-5PAW3DEU.js → chunk-CI2RHH74.js} +4 -4
  45. package/dist/chunks/{chunk-OFEPDNRB.js → chunk-CMSOOLJB.js} +1 -1
  46. package/dist/chunks/chunk-CSVTYYLP.js +4 -0
  47. package/dist/chunks/chunk-DE5EGVKG.js +6 -0
  48. package/dist/chunks/{chunk-E6BYRULL.js → chunk-DK3RPZOQ.js} +1 -1
  49. package/dist/chunks/{chunk-ROVKOIHF.js → chunk-DK4UCK7L.js} +1 -1
  50. package/dist/chunks/chunk-DYLBVUAU.js +4 -0
  51. package/dist/chunks/{chunk-WBSE3EF3.js → chunk-FDC2GRBK.js} +1 -1
  52. package/dist/chunks/chunk-FE7HH5JS.js +18 -0
  53. package/dist/chunks/chunk-FYD57YRO.js +436 -0
  54. package/dist/chunks/chunk-G264APQN.js +5 -0
  55. package/dist/chunks/chunk-G4JYZFEO.js +11 -0
  56. package/dist/chunks/chunk-GFFM56U2.js +4 -0
  57. package/dist/chunks/chunk-GOS3P7KS.js +132 -0
  58. package/dist/chunks/{chunk-2VVRTJQN.js → chunk-HVN37UXD.js} +1 -1
  59. package/dist/chunks/{chunk-53TQNK7Z.js → chunk-IGZWZP7Z.js} +1 -1
  60. package/dist/chunks/{chunk-AFTBQRPN.js → chunk-IJ7XFQMI.js} +1 -1
  61. package/dist/chunks/{chunk-U23S37TT.js → chunk-IMMGYDAB.js} +1 -1
  62. package/dist/chunks/chunk-IOWBF7UK.js +10 -0
  63. package/dist/chunks/{chunk-MGYYSX7Y.js → chunk-ITGCWQFK.js} +1 -1
  64. package/dist/chunks/{chunk-QEL6CMLE.js → chunk-IVZ7QUEG.js} +1 -1
  65. package/dist/chunks/{chunk-EE3WT25T.js → chunk-IWY2HIFK.js} +1 -1
  66. package/dist/chunks/{chunk-KGJZAYQD.js → chunk-J7OBATRN.js} +1 -1
  67. package/dist/chunks/{chunk-NXZS5PEW.js → chunk-JGUEIW2W.js} +1 -1
  68. package/dist/chunks/chunk-JZ7U7RUK.js +351 -0
  69. package/dist/chunks/{chunk-VIMHSW6J.js → chunk-KJUQCCB5.js} +1 -1
  70. package/dist/chunks/{chunk-BUZQBTV2.js → chunk-KST6OY76.js} +1 -1
  71. package/dist/chunks/{chunk-KDPY2YA3.js → chunk-KZSAFVSY.js} +2 -2
  72. package/dist/chunks/chunk-LD2ZSH3M.js +903 -0
  73. package/dist/chunks/{chunk-RYLSRII6.js → chunk-LE6QPXN6.js} +1 -1
  74. package/dist/chunks/{chunk-TX46YMGI.js → chunk-LIIZI3HY.js} +1 -1
  75. package/dist/chunks/{chunk-3CZPBLB3.js → chunk-MJQ2D2OP.js} +1 -1
  76. package/dist/chunks/{chunk-P7TVR4GY.js → chunk-NHHR4DCF.js} +1 -1
  77. package/dist/chunks/chunk-NW4GW47L.js +4 -0
  78. package/dist/chunks/chunk-OALEJ6FG.js +60 -0
  79. package/dist/chunks/chunk-OIV4DIMB.js +4 -0
  80. package/dist/chunks/{chunk-T73GHMFB.js → chunk-OJ37ZWBG.js} +1 -1
  81. package/dist/chunks/{chunk-7GEBDPTT.js → chunk-OZXMPBUX.js} +1 -1
  82. package/dist/chunks/chunk-PG7452XE.js +4 -0
  83. package/dist/chunks/chunk-PJCUB7YJ.js +4 -0
  84. package/dist/chunks/{chunk-RA2BUYI3.js → chunk-PTS3J4DQ.js} +1 -1
  85. package/dist/chunks/{chunk-2ROGTDM2.js → chunk-PVVEEBUU.js} +1 -1
  86. package/dist/chunks/{chunk-W6AKCEYF.js → chunk-Q7BZLPBU.js} +1 -1
  87. package/dist/chunks/{chunk-SY2HV3V5.js → chunk-QC66ZXPP.js} +1 -1
  88. package/dist/chunks/chunk-QXFWIL4C.js +4 -0
  89. package/dist/chunks/{chunk-NRD57ICT.js → chunk-R2CCD4OF.js} +1 -1
  90. package/dist/chunks/{chunk-R52AVUQB.js → chunk-RG5GP4RB.js} +1 -1
  91. package/dist/chunks/{chunk-IKLTEWA3.js → chunk-RW2F2QNP.js} +1 -1
  92. package/dist/chunks/{chunk-XEBEWR6Y.js → chunk-RWPO3NZ3.js} +1 -1
  93. package/dist/chunks/chunk-SDUS2H3E.js +4 -0
  94. package/dist/chunks/chunk-SIHGKM4E.js +4 -0
  95. package/dist/chunks/{chunk-NNBSSISP.js → chunk-SKHFU5DI.js} +1 -1
  96. package/dist/chunks/{chunk-STUHNKQS.js → chunk-SM45TH22.js} +1 -1
  97. package/dist/chunks/chunk-T54CZKNJ.js +6 -0
  98. package/dist/chunks/chunk-TRXLIL7V.js +4 -0
  99. package/dist/chunks/{chunk-KUDK7GPS.js → chunk-UEEW2R4E.js} +1 -1
  100. package/dist/chunks/chunk-UHXPRU6G.js +10 -0
  101. package/dist/chunks/chunk-UPQVWHZ3.js +4 -0
  102. package/dist/chunks/{chunk-BDLKI2NT.js → chunk-VHX2GHBF.js} +1 -1
  103. package/dist/chunks/chunk-VOAKRJ4R.js +4 -0
  104. package/dist/chunks/{chunk-FP7ML72L.js → chunk-WU7RNAZD.js} +1 -1
  105. package/dist/chunks/chunk-WZC4TDDM.js +6 -0
  106. package/dist/chunks/chunk-X2TKJ7KR.js +11 -0
  107. package/dist/chunks/{chunk-H4QZ2P3Z.js → chunk-X5ND4H4P.js} +1 -1
  108. package/dist/chunks/{chunk-5A6CA5TM.js → chunk-Y3AOGNDT.js} +1 -1
  109. package/dist/chunks/chunk-Y6DGVTKM.js +6 -0
  110. package/dist/chunks/{chunk-LP7T32PW.js → chunk-YAEHSSR4.js} +1 -1
  111. package/dist/chunks/chunk-YWPBE5LP.js +4 -0
  112. package/dist/chunks/chunk-ZAVX7G2M.js +15 -0
  113. package/dist/chunks/chunk-ZD2M73XA.js +19 -0
  114. package/dist/chunks/chunk-ZD4O6NPV.js +4 -0
  115. package/dist/chunks/chunk-ZNAMETPQ.js +4 -0
  116. package/dist/chunks/chunk-ZY6N5LVQ.js +4 -0
  117. package/dist/chunks/chunk-ZYQ4TDTT.js +81 -0
  118. package/dist/chunks/cli-VB2N7HEK.js +55 -0
  119. package/dist/chunks/cloudflare-workers-ai-system-one-YKU742EC.js +4 -0
  120. package/dist/chunks/context-CI2FKEQE.js +4 -0
  121. package/dist/chunks/cost-CZRRSIUF.js +5 -0
  122. package/dist/chunks/dist-QCNQN6DY.js +4 -0
  123. package/dist/chunks/{easter-egg-3d-CZH7AYZ7.js → easter-egg-3d-XR5S2O3T.js} +1 -1
  124. package/dist/chunks/execution-repo-5TLV2NM4.js +4 -0
  125. package/dist/chunks/{executions-BN6OLLVM.js → executions-I3UUIGSL.js} +1 -1
  126. package/dist/chunks/file-Y5G56IUT.js +4 -0
  127. package/dist/chunks/github-copilot-BRU2SRRZ.js +4 -0
  128. package/dist/chunks/google-generative-ai-ZF5QEUZV.js +4 -0
  129. package/dist/chunks/google-vertex-4PJZZI3Y.js +4 -0
  130. package/dist/chunks/init-A6GY656J.js +4 -0
  131. package/dist/chunks/{install-cli-ABBD7DO5.js → install-cli-FALWKQYO.js} +1 -1
  132. package/dist/chunks/{interaction-ask-EE2UPR3Q.js → interaction-ask-O5HGF6CH.js} +1 -1
  133. package/dist/chunks/{interaction-plan-C446T2GZ.js → interaction-plan-JTVDN3BC.js} +1 -1
  134. package/dist/chunks/kimi-coding-ZCIBMDZ6.js +4 -0
  135. package/dist/chunks/{llama-cpp-classify-IA2F2H7A.js → llama-cpp-classify-NRUXAIGQ.js} +3 -3
  136. package/dist/chunks/local-client-stop-RS4AHNF4.js +4 -0
  137. package/dist/chunks/memory-cli-DIT4DQF3.js +11 -0
  138. package/dist/chunks/meta-JQH66YU7.js +4 -0
  139. package/dist/chunks/mistral-conversations-CXHOECUV.js +7 -0
  140. package/dist/chunks/model-resolver-GIBPYRKP.js +4 -0
  141. package/dist/chunks/monitor-Z2HKNY5E.js +4 -0
  142. package/dist/chunks/openai-codex-responses-U6DGMGDK.js +12 -0
  143. package/dist/chunks/openai-completions-PP4XLLOM.js +9 -0
  144. package/dist/chunks/{openai-decisions-P5UX7BWY.js → openai-decisions-JU6QQKEM.js} +1 -1
  145. package/dist/chunks/openai-responses-2SG757TL.js +6 -0
  146. package/dist/chunks/openrouter-images-32M7YZWC.js +4 -0
  147. package/dist/chunks/pi-messages-VSINMXN4.js +10 -0
  148. package/dist/chunks/radius-THYKWV4E.js +4 -0
  149. package/dist/chunks/remote-ops-2WBEFQ3E.js +14 -0
  150. package/dist/chunks/runner-5MKMRTIN.js +4 -0
  151. package/dist/chunks/runtime-DST3H5JP.js +4 -0
  152. package/dist/chunks/schedule-cli-V7Y2BBVY.js +4 -0
  153. package/dist/chunks/slack-R7SEJYMY.js +4 -0
  154. package/dist/chunks/start-ui-http-7K5JOLPU.js +43 -0
  155. package/dist/chunks/subagent-Z5IQ4L54.js +4 -0
  156. package/dist/chunks/tool-shims-YCXZWTST.js +4 -0
  157. package/dist/chunks/typesafe-system-one-M2DABJSZ.js +4 -0
  158. package/dist/chunks/ui-board-HQIE4RZG.js +5 -0
  159. package/dist/chunks/ui-decision-YBZDS4YW.js +4 -0
  160. package/dist/chunks/{ui-file-6PLXHSTB.js → ui-file-SRD4ILBS.js} +1 -1
  161. package/dist/chunks/ui-view-Z25MTZT7.js +4 -0
  162. package/dist/chunks/virtual-modules-H4DXPJZB.js +4 -0
  163. package/dist/chunks/{waitpoint-W5M3BE55.js → waitpoint-M6JZBSLT.js} +1 -1
  164. package/dist/chunks/workers-SQ2R32TK.js +4 -0
  165. package/dist/client-bundle/client.mjs +229 -62
  166. package/dist/client-bundle/manifest.json +2 -2
  167. package/dist/core/pi-sdk.js +1 -1
  168. package/dist/domain/auth/cc-auth-cli.js +1 -1
  169. package/dist/domain/mcp/bundled-server.js +1 -1
  170. package/dist/domain/mcp/feishu/client.js +1 -1
  171. package/dist/entry/app.js +138 -556
  172. package/dist/entry/browser-cli.js +1 -1
  173. package/dist/entry/cli.js +1 -1
  174. package/dist/entry/cortex-cli.js +1 -1
  175. package/dist/entry/daemon.js +3 -3
  176. package/dist/entry/hook-cli.js +1 -1
  177. package/dist/entry/production-app-bootstrap.js +1 -1
  178. package/dist/entry/production-evidence-export-cli.js +1 -1
  179. package/dist/entry/signal-cli.js +1 -1
  180. package/dist/tui/index.js +1 -1
  181. package/package.json +1 -1
  182. package/vendor/pi/CHANGELOG.md +330 -0
  183. package/vendor/pi/dist/codemode-worker.js +2 -0
  184. package/vendor/pi/dist/core/export-html/ansi-to-html.js +57 -20
  185. package/vendor/pi/dist/core/export-html/template.css +9 -0
  186. package/vendor/pi/dist/core/export-html/template.js +166 -46
  187. package/vendor/pi/dist/core/export-html/tool-renderer.js +5 -3
  188. package/vendor/pi/dist/core/extensions/loader.js +1 -1
  189. package/vendor/pi/dist/extensions/codemode/execute.js +15 -13
  190. package/vendor/pi/dist/modes/interactive/theme/theme.js +36 -23
  191. package/vendor/pi/dist/utils/image-resize-worker.js +1 -1
  192. package/vendor/pi/dist/utils/image-resize.js +1 -1
  193. package/vendor/pi/docs/cli.md +35 -12
  194. package/vendor/pi/docs/custom-provider.md +2 -0
  195. package/vendor/pi/docs/environment-variables.md +2 -0
  196. package/vendor/pi/docs/extensions.md +3192 -225
  197. package/vendor/pi/docs/keybindings.md +2 -2
  198. package/vendor/pi/docs/llama-cpp.md +27 -19
  199. package/vendor/pi/docs/mcp.md +6 -4
  200. package/vendor/pi/docs/message-types.md +1 -1
  201. package/vendor/pi/docs/models-configuration.md +9 -3
  202. package/vendor/pi/docs/models.md +2 -1
  203. package/vendor/pi/docs/nvidia-rtx-llama-cpp.md +5 -5
  204. package/vendor/pi/docs/packages.md +24 -0
  205. package/vendor/pi/docs/prompt-templates.md +1 -1
  206. package/vendor/pi/docs/providers.md +4 -2
  207. package/vendor/pi/docs/quickstart.md +7 -3
  208. package/vendor/pi/docs/rpc-commands.md +1 -1
  209. package/vendor/pi/docs/rpc.md +4 -2
  210. package/vendor/pi/docs/sessions.md +17 -3
  211. package/vendor/pi/docs/settings.md +6 -5
  212. package/vendor/pi/docs/slash-commands.md +3 -2
  213. package/vendor/pi/docs/terminal-setup.md +3 -1
  214. package/vendor/pi/docs/tmux.md +6 -0
  215. package/vendor/pi/docs/tui.md +4 -0
  216. package/vendor/pi/docs/windows.md +27 -0
  217. package/vendor/pi/examples/extensions/README.md +2 -1
  218. package/vendor/pi/examples/extensions/custom-provider-anthropic/index.ts +27 -31
  219. package/vendor/pi/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  220. package/vendor/pi/examples/extensions/custom-provider-anthropic/package.json +1 -1
  221. package/vendor/pi/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  222. package/vendor/pi/examples/extensions/debug-provider.ts +2 -2
  223. package/vendor/pi/examples/extensions/gondolin/index.ts +4 -7
  224. package/vendor/pi/examples/extensions/gondolin/package-lock.json +19 -29
  225. package/vendor/pi/examples/extensions/gondolin/package.json +2 -2
  226. package/vendor/pi/examples/extensions/plan-mode/index.ts +23 -13
  227. package/vendor/pi/examples/extensions/plan-mode/utils.ts +42 -16
  228. package/vendor/pi/examples/extensions/preset.ts +2 -0
  229. package/vendor/pi/examples/extensions/reload-runtime.ts +17 -5
  230. package/vendor/pi/examples/extensions/subagent/README.md +14 -11
  231. package/vendor/pi/examples/extensions/subagent/index.ts +392 -171
  232. package/vendor/pi/examples/extensions/todo.ts +7 -0
  233. package/vendor/pi/examples/extensions/tools.ts +2 -0
  234. package/vendor/pi/examples/extensions/with-deps/package-lock.json +2 -2
  235. package/vendor/pi/examples/extensions/with-deps/package.json +1 -1
  236. package/vendor/pi/examples/tsconfig.json +208 -0
  237. package/vendor/pi/package.json +15 -16
  238. package/vendor/pi/schemas/models.schema.json +66 -37
  239. package/vendor/pi/schemas/settings.schema.json +18 -1
  240. package/vendor/pi-ai/bedrock.js +1 -1
  241. package/vendor/pi-ai/oauth-load.js +1 -1
  242. package/web/dist/assets/{board-math-css-BgIyUG-C.js → board-math-css-DKX6FcUS.js} +1 -1
  243. package/web/dist/assets/index-D11wi0uG.js +540 -0
  244. package/web/dist/assets/index-JedYumhY.css +1 -0
  245. package/web/dist/assets/{index-C2eMpcuI.js → index-jl30Gy8P.js} +1 -1
  246. package/web/dist/index.html +2 -2
  247. package/dist/chunks/anthropic-messages-M732OMEE.js +0 -8
  248. package/dist/chunks/azure-openai-responses-RAKTV6JY.js +0 -4
  249. package/dist/chunks/bedrock-converse-stream-WNUGNZ27.js +0 -62
  250. package/dist/chunks/child-runner-MO5RT6FH.js +0 -4
  251. package/dist/chunks/chunk-3CPIMAYX.js +0 -30
  252. package/dist/chunks/chunk-3ORG56I5.js +0 -8
  253. package/dist/chunks/chunk-4EX2JJWB.js +0 -4
  254. package/dist/chunks/chunk-5DF5WJNM.js +0 -60
  255. package/dist/chunks/chunk-7GAYFN52.js +0 -18
  256. package/dist/chunks/chunk-AVXDF7AG.js +0 -4
  257. package/dist/chunks/chunk-BJGYGEZO.js +0 -6
  258. package/dist/chunks/chunk-BZDIAI5M.js +0 -125
  259. package/dist/chunks/chunk-CK3P345X.js +0 -133
  260. package/dist/chunks/chunk-CVC66CFV.js +0 -33
  261. package/dist/chunks/chunk-ETIBCA2S.js +0 -4
  262. package/dist/chunks/chunk-FF7UELTU.js +0 -4
  263. package/dist/chunks/chunk-FX6MOGLR.js +0 -11
  264. package/dist/chunks/chunk-G2V65UBA.js +0 -4
  265. package/dist/chunks/chunk-HGPBHTVD.js +0 -6
  266. package/dist/chunks/chunk-IYVZHGUQ.js +0 -5
  267. package/dist/chunks/chunk-JJDEQ6N2.js +0 -4
  268. package/dist/chunks/chunk-KDYEGGMW.js +0 -4
  269. package/dist/chunks/chunk-L6VCIGWS.js +0 -11
  270. package/dist/chunks/chunk-LACGULCN.js +0 -10
  271. package/dist/chunks/chunk-LAWOWPZX.js +0 -363
  272. package/dist/chunks/chunk-NNTQUHLO.js +0 -877
  273. package/dist/chunks/chunk-OE4KH3NJ.js +0 -4
  274. package/dist/chunks/chunk-OSEIQ7SS.js +0 -4
  275. package/dist/chunks/chunk-PZMGBKUR.js +0 -13
  276. package/dist/chunks/chunk-QBKCAIJG.js +0 -4
  277. package/dist/chunks/chunk-QMSSIDRQ.js +0 -70
  278. package/dist/chunks/chunk-QUUEQRIT.js +0 -4
  279. package/dist/chunks/chunk-RA6HKFBV.js +0 -4
  280. package/dist/chunks/chunk-RDW6FRF5.js +0 -4
  281. package/dist/chunks/chunk-RF4JLYBX.js +0 -6
  282. package/dist/chunks/chunk-SFX7V5O2.js +0 -10
  283. package/dist/chunks/chunk-SKHLZ6XY.js +0 -9
  284. package/dist/chunks/chunk-STCNHXPJ.js +0 -6
  285. package/dist/chunks/chunk-UT6DGZDO.js +0 -4
  286. package/dist/chunks/chunk-VBN2JSER.js +0 -5
  287. package/dist/chunks/chunk-VK5J556O.js +0 -4
  288. package/dist/chunks/chunk-VPVSKJGX.js +0 -6
  289. package/dist/chunks/chunk-VQUPKMDR.js +0 -4
  290. package/dist/chunks/chunk-WEZWKMYU.js +0 -4
  291. package/dist/chunks/chunk-XYSXL3KX.js +0 -4
  292. package/dist/chunks/chunk-Y3GFB5XM.js +0 -8
  293. package/dist/chunks/chunk-YAAKL3QS.js +0 -80
  294. package/dist/chunks/chunk-YB5LUJHS.js +0 -65
  295. package/dist/chunks/chunk-YKKEI5GI.js +0 -4
  296. package/dist/chunks/chunk-Z24SBRJK.js +0 -4
  297. package/dist/chunks/cli-5DBTRMHU.js +0 -53
  298. package/dist/chunks/cloudflare-workers-ai-system-one-32JCFHI3.js +0 -4
  299. package/dist/chunks/context-GQKWKFRM.js +0 -4
  300. package/dist/chunks/cost-OOO32GLC.js +0 -5
  301. package/dist/chunks/dist-V5FRMUFH.js +0 -4
  302. package/dist/chunks/execution-repo-XXL4FXC6.js +0 -4
  303. package/dist/chunks/file-H572PL2Z.js +0 -4
  304. package/dist/chunks/github-copilot-HAI2DA62.js +0 -4
  305. package/dist/chunks/google-generative-ai-2G4ITOZL.js +0 -4
  306. package/dist/chunks/google-vertex-PACHCMRZ.js +0 -4
  307. package/dist/chunks/init-75F4V7SK.js +0 -4
  308. package/dist/chunks/kimi-coding-HMJRKCPA.js +0 -4
  309. package/dist/chunks/local-client-stop-5YOLXGYT.js +0 -4
  310. package/dist/chunks/memory-cli-5SSF6YJM.js +0 -11
  311. package/dist/chunks/meta-KY3LNFV2.js +0 -4
  312. package/dist/chunks/mistral-conversations-VHP63CDS.js +0 -7
  313. package/dist/chunks/model-resolver-FVJNZ6NA.js +0 -4
  314. package/dist/chunks/openai-codex-responses-EHJ4AZBE.js +0 -12
  315. package/dist/chunks/openai-completions-CRAGQFCE.js +0 -9
  316. package/dist/chunks/openai-responses-IZ22NVQ7.js +0 -6
  317. package/dist/chunks/openrouter-images-W2JAMSRH.js +0 -4
  318. package/dist/chunks/pi-messages-MJEEQU2R.js +0 -10
  319. package/dist/chunks/radius-ZM7ZRMXF.js +0 -4
  320. package/dist/chunks/remote-ops-O5CR4RGA.js +0 -14
  321. package/dist/chunks/runner-S6R3US24.js +0 -4
  322. package/dist/chunks/runtime-6YLTA2ZD.js +0 -4
  323. package/dist/chunks/schedule-cli-4T4YC5V5.js +0 -4
  324. package/dist/chunks/slack-2CGM4SMY.js +0 -4
  325. package/dist/chunks/start-ui-http-3D7QNHGB.js +0 -43
  326. package/dist/chunks/subagent-OZGUOV3J.js +0 -4
  327. package/dist/chunks/tool-shims-IA2WELXJ.js +0 -4
  328. package/dist/chunks/typesafe-system-one-6ULACYD4.js +0 -4
  329. package/dist/chunks/ui-board-H4INJD6C.js +0 -5
  330. package/dist/chunks/ui-decision-6HHNROIT.js +0 -4
  331. package/dist/chunks/ui-view-6MDU4GXY.js +0 -4
  332. package/dist/chunks/virtual-modules-OFI7QKYH.js +0 -4
  333. package/dist/chunks/workers-GTFP75MS.js +0 -4
  334. package/vendor/pi/examples/extensions/sandbox/index.ts +0 -321
  335. package/vendor/pi/examples/extensions/sandbox/package-lock.json +0 -92
  336. package/vendor/pi/examples/extensions/sandbox/package.json +0 -19
  337. package/web/dist/assets/index-9lyu2S6W.css +0 -1
  338. package/web/dist/assets/index-C-hpzey7.js +0 -532
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __cortexCreateRequire } from 'node:module';
2
2
  const require = __cortexCreateRequire(import.meta.url);
3
3
  const __cortexPackageRoot = new URL("../../", import.meta.url);
4
- import{b as vt}from"./chunk-BDLKI2NT.js";import{L as yt}from"./chunk-JJDEQ6N2.js";import{a as gt,c as _t}from"./chunk-MGYYSX7Y.js";import{a as Nt}from"./chunk-V35MFAUQ.js";import{a as lt}from"./chunk-Q4UGYGU5.js";import{b as dt,d as ht}from"./chunk-AVXDF7AG.js";import{e as h}from"./chunk-3CPIMAYX.js";import{e as mt}from"./chunk-VBN2JSER.js";import{i as pt,j as ft}from"./chunk-Z24SBRJK.js";import{e as $t}from"./chunk-WHC7AYZD.js";import*as I from"path";import E from"node:fs/promises";var Bt=2160*60*60*1e3,J={daily_usd:300,monthly_usd:8e3,projects:{}};function A(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function qt(t){if(!t||typeof t!="object"||Array.isArray(t))return{};let e={};for(let[r,n]of Object.entries(t)){if(!r||!n||typeof n!="object")continue;let{daily_usd:o,monthly_usd:s}=n;!A(o)||!A(s)||(e[r]={daily_usd:o,monthly_usd:s})}return e}function Kt(t){let e=t&&typeof t=="object"?t:{};return{daily_usd:A(e.daily_usd)?e.daily_usd:J.daily_usd,monthly_usd:A(e.monthly_usd)?e.monthly_usd:J.monthly_usd,projects:qt(e.projects)}}function Lt(){return process.env.CORTEX_COSTS_FILE||I.join(ft,"costs.jsonl")}function Vt(){return process.env.CORTEX_BUDGET_FILE||I.join(pt,"budget.json")}var W=class{costMutex=new lt;_ready=!1;_cache=null;_budgetRepo=null;_costsPath;_budgetPath;constructor(e={}){this._costsPath=e.costsPath??null,this._budgetPath=e.budgetPath??null}get costFilePath(){return this._costsPath??Lt()}get budgetRepo(){return this._budgetRepo||(this._budgetRepo=new _t({filePath:this._budgetPath??Vt(),defaultValue:()=>({...J,projects:{}}),migrate:Kt})),this._budgetRepo}async _ensureReady(){if(this._ready)return;let e=this.costFilePath;await E.mkdir(I.dirname(e),{recursive:!0});let r=await this._readFileEntries(e),n=Date.now()-Bt,o=r.filter(s=>new Date(s.timestamp).getTime()>n);if(o.length<r.length){let s=o.map(a=>JSON.stringify(a)).join(`
4
+ import{e as vt}from"./chunk-VHX2GHBF.js";import{L as yt}from"./chunk-C6YVF7EI.js";import{a as gt,c as _t}from"./chunk-ITGCWQFK.js";import{a as Nt}from"./chunk-V35MFAUQ.js";import{a as lt}from"./chunk-Q4UGYGU5.js";import{b as dt,d as ht}from"./chunk-TRXLIL7V.js";import{e as h}from"./chunk-7GGPYU5E.js";import{e as mt}from"./chunk-7W7VYUTK.js";import{j as pt,k as ft}from"./chunk-T54CZKNJ.js";import{e as $t}from"./chunk-WHC7AYZD.js";import*as I from"path";import E from"node:fs/promises";var Bt=2160*60*60*1e3,J={daily_usd:300,monthly_usd:8e3,projects:{}};function A(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function qt(t){if(!t||typeof t!="object"||Array.isArray(t))return{};let e={};for(let[r,n]of Object.entries(t)){if(!r||!n||typeof n!="object")continue;let{daily_usd:o,monthly_usd:s}=n;!A(o)||!A(s)||(e[r]={daily_usd:o,monthly_usd:s})}return e}function Kt(t){let e=t&&typeof t=="object"?t:{};return{daily_usd:A(e.daily_usd)?e.daily_usd:J.daily_usd,monthly_usd:A(e.monthly_usd)?e.monthly_usd:J.monthly_usd,projects:qt(e.projects)}}function Lt(){return process.env.CORTEX_COSTS_FILE||I.join(ft,"costs.jsonl")}function Vt(){return process.env.CORTEX_BUDGET_FILE||I.join(pt,"budget.json")}var W=class{costMutex=new lt;_ready=!1;_cache=null;_budgetRepo=null;_costsPath;_budgetPath;constructor(e={}){this._costsPath=e.costsPath??null,this._budgetPath=e.budgetPath??null}get costFilePath(){return this._costsPath??Lt()}get budgetRepo(){return this._budgetRepo||(this._budgetRepo=new _t({filePath:this._budgetPath??Vt(),defaultValue:()=>({...J,projects:{}}),migrate:Kt})),this._budgetRepo}async _ensureReady(){if(this._ready)return;let e=this.costFilePath;await E.mkdir(I.dirname(e),{recursive:!0});let r=await this._readFileEntries(e),n=Date.now()-Bt,o=r.filter(s=>new Date(s.timestamp).getTime()>n);if(o.length<r.length){let s=o.map(a=>JSON.stringify(a)).join(`
5
5
  `)+`
6
6
  `;await ht(e,s)}this._ready=!0}async _readEntriesRange(e,r,n){if(n<=r)return{entries:[],consumedTo:r};let o=await E.open(e,"r");try{let s=Buffer.allocUnsafe(n-r),{bytesRead:a}=await o.read(s,0,s.length,r),l=a>0?s.lastIndexOf(10,a-1):-1;return l<0?{entries:[],consumedTo:r}:{entries:s.toString("utf8",0,l+1).split(`
7
7
  `).filter(c=>c.trim()!=="").map(c=>JSON.parse(c)),consumedTo:r+l+1}}finally{await o.close()}}async _readFileEntries(e){try{return(await E.readFile(e,"utf8")).split(`
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{a as de}from"./chunk-B3XBQEFM.js";import{e as pe}from"./chunk-WHC7AYZD.js";import{realpathSync as ge,statSync as he}from"node:fs";import{homedir as M}from"node:os";import{isAbsolute as z,join as xe,resolve as F,posix as be,relative as Pe,sep as G,win32 as q}from"node:path";import{fileURLToPath as ve}from"node:url";var C=pe(de(),1);import{spawn as fe,spawnSync as le}from"node:child_process";var me=100;function ze(e,t,n){return process.platform==="win32"?(0,C.default)(e,t,n):fe(e,t,n)}function v(e,t,n){return process.platform==="win32"?C.default.sync(e,t,n):le(e,t,n)}function Ge(e){return new Promise((t,n)=>{let r=!1,o=!1,i=null,a,d=e.stdout===null,p=e.stderr===null,l=()=>{a&&(clearTimeout(a),a=void 0),e.removeListener("error",O),e.removeListener("exit",j),e.removeListener("close",B),e.stdout?.removeListener("end",L),e.stderr?.removeListener("end",T),e.stdout?.removeListener("data",E),e.stderr?.removeListener("data",E)},P=m=>{r||(r=!0,l(),e.stdout?.destroy(),e.stderr?.destroy(),t(m))},A=()=>{!o||r||d&&p&&P(i)},W=()=>{a&&clearTimeout(a),a=setTimeout(()=>P(i),me)},E=()=>{o&&!r&&W()},L=()=>{d=!0,A()},T=()=>{p=!0,A()},O=m=>{r||(r=!0,l(),n(m))},j=m=>{o=!0,i=m,A(),r||W()},B=m=>{P(m)};e.stdout?.once("end",L),e.stderr?.once("end",T),e.stdout?.on("data",E),e.stderr?.on("data",E),e.once("error",O),e.once("exit",j),e.once("close",B)})}var Se=/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;function Xe(e){try{return ge(e)}catch{return e}}function y(e){let t=R(),n=t.resolve(e);return t===q?n.toLowerCase():n}function R(){return process.platform==="win32"?q:be}function Ye(e,t){return y(e)===y(t)}function _e(e,t){let n=y(e),r=y(t);if(r===n)return!0;let o=R().sep;return r.startsWith(n.endsWith(o)?n:`${n}${o}`)}function Ze(e,t=M()){let n=R();if(!t||!n.isAbsolute(e)||!_e(t,e))return e;let r=n.relative(t,e);return r?`~${n.sep}${r}`:"~"}function et(e){try{let t=he(e,{bigint:!0});return`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`}catch{return}}function tt(e){let t=e.trim();return!(t.startsWith("npm:")||t.startsWith("git:")||t.startsWith("github:")||t.startsWith("http:")||t.startsWith("https:")||t.startsWith("ssh:")||t.startsWith("builtin:"))}function we(e){if(!e.startsWith("/")||e.startsWith("//")||e.includes("\\"))return e;let t=e.match(/^\/(?:mnt\/|cygdrive\/)?([a-z])(?:\/(.*))?$/i);if(!t)return e;let n=t[2]?.replaceAll("/","\\");return`${t[1].toUpperCase()}:\\${n??""}`}function S(e,t={}){let n=t.trim?e.trim():e;if(t.normalizeUnicodeSpaces&&(n=n.replace(Se," ")),t.stripAtPrefix&&n.startsWith("@")&&(n=n.slice(1)),process.platform==="win32"&&(n=we(n)),t.expandTilde??!0){let r=t.homeDir??M();if(n==="~")return r;if(n.startsWith("~/")||process.platform==="win32"&&n.startsWith("~\\"))return xe(r,n.slice(2))}return/^file:\/\//.test(n)?ve(n):n}function U(e,t=process.cwd(),n={}){let r=S(e,n),o=S(t);return z(r)?F(r):F(o,r)}function Ee(e,t){let n=U(t),r=U(e,n),o=Pe(n,r);return o===""||o!==".."&&!o.startsWith(`..${G}`)&&!z(o)?o||".":void 0}function nt(e,t){let n=U(e,t);return(Ee(n,t)??n).split(G).join("/")}function rt(e){let t=process.platform==="darwin"?["com.dropbox.ignored","com.apple.fileprovider.ignore#P"]:process.platform==="linux"?["user.com.dropbox.ignored"]:[];for(let n of t)process.platform==="darwin"?v("xattr",["-w",n,"1",e],{encoding:"utf-8",stdio:"ignore"}):v("setfattr",["-n",n,"-v","1",e],{encoding:"utf-8",stdio:"ignore"})}import{accessSync as J,constants as K,existsSync as g,readFileSync as I,realpathSync as De}from"fs";import{homedir as N}from"os";import{basename as Z,dirname as u,join as s,resolve as _,sep as V,win32 as ke}from"path";import{fileURLToPath as ee}from"url";function ye(e){return e.startsWith("\uFEFF")?{bom:"\uFEFF",text:e.slice(1)}:{bom:"",text:e}}function $(e){return ye(e).text}var Ae=ee(new URL("vendor/pi/dist/config.js",__cortexPackageRoot).href),te=u(Ae),h=new URL("vendor/pi/dist/config.js",__cortexPackageRoot).href.includes("$bunfs")||new URL("vendor/pi/dist/config.js",__cortexPackageRoot).href.includes("~BUN")||new URL("vendor/pi/dist/config.js",__cortexPackageRoot).href.includes("%7EBUN"),Ce=!!process.versions.bun,Ue=!0;function ne(e){return typeof e=="string"?{packageName:e,installSpec:e}:{packageName:e.packageName,installSpec:e.installSpec??e.packageName}}function D(e,t){return t?{...e,display:`${t.display} && ${e.display}`,steps:[t,e]}:e}function f(e,t){return{command:e,args:t,display:[e,...t].map(n=>/\s/.test(n)?`"${n}"`:n).join(" ")}}function re(){if(h)return"bun-binary";let e=`${te}\0${process.execPath||""}`.toLowerCase().replace(/\\/g,"/");return e.includes("/pnpm/")||e.includes("/.pnpm/")?"pnpm":e.includes("/yarn/")||e.includes("/.yarn/")?"yarn":Ce||e.includes("/install/global/node_modules/")?"bun":e.includes("/npm/")||e.includes("/node_modules/")?"npm":"unknown"}function oe(){let e=c(),t=process.platform==="win32"||e.includes("\\")?ke:{basename:Z,dirname:u},n=t.dirname(e),r;if(t.basename(n).startsWith("@")&&t.basename(t.dirname(n))==="node_modules"?r=t.dirname(n):t.basename(n)==="node_modules"&&(r=n),!r)return;let o=t.dirname(r);if(t.basename(o)==="lib")return{root:r,prefix:t.dirname(o)}}function se(e,t,n=t,r){let o=ne(n);switch(e){case"bun-binary":return;case"pnpm":{let i=x("pnpm",["root","-g"])?void 0:/^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(c()),a=i?[`--config.global-bin-dir=${process.env.PNPM_HOME||u(u(i[1]))}`]:[];return D(f("pnpm",["install","-g","--ignore-scripts","--config.minimumReleaseAge=0",...a,o.installSpec]),o.packageName===t?void 0:f("pnpm",["remove","-g",...a,t]))}case"yarn":return D(f("yarn",["global","add","--ignore-scripts",o.installSpec]),o.packageName===t?void 0:f("yarn",["global","remove",t]));case"bun":return D(f("bun",["install","-g","--ignore-scripts","--minimum-release-age=0",o.installSpec]),o.packageName===t?void 0:f("bun",["uninstall","-g",t]));case"npm":{let[i="npm",...a]=r??[],d=r?.length?void 0:oe(),p=[...a,...d?["--prefix",d.prefix]:[]],l=f(i,[...p,"install","-g","--ignore-scripts","--min-release-age=0",o.installSpec]),P=o.packageName===t?void 0:f(i,[...p,"uninstall","-g",t]);return D(l,P)}case"unknown":return}}function x(e,t,n={}){let r=v(e,t,{encoding:"utf-8",stdio:["ignore","pipe","pipe"]});if(r.status===0)return r.stdout.trim()||void 0;if(n.requireSuccess){let o=r.error?.message||r.stderr.trim()||`exit code ${r.status??"unknown"}`;throw new Error(`Failed to run ${[e,...t].join(" ")}: ${o}`)}}function Re(e,t,n){switch(e){case"npm":{let r=!!n?.length,[o="npm",...i]=n??[];if(r&&o==="bun"){let p=x(o,[...i,"pm","bin","-g"],{requireSuccess:!0}),l=[s(N(),".bun","install","global","node_modules")];return p&&l.push(s(u(p),"install","global","node_modules")),l}let a=x(o,[...i,"root","-g"],{requireSuccess:r}),d=r?void 0:oe();return[a,d?.root].filter(p=>!!p)}case"pnpm":{let r=x("pnpm",["root","-g"]);if(r)return[r,u(r)];let o=/^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(c());return o?[o[1]]:[]}case"yarn":{let r=x("yarn",["global","dir"]);return r?[r,s(r,"node_modules")]:[]}case"bun":{let r=x("bun",["pm","bin","-g"]),o=[s(N(),".bun","install","global","node_modules")];return r&&o.push(s(u(r),"install","global","node_modules")),o}case"bun-binary":case"unknown":return[]}}function H(e,t){let n=_(e);if(!g(n))return;let r=n;if(t)try{r=De(n)}catch{return}return process.platform==="win32"&&(r=r.toLowerCase()),r}function Q(e){return Array.from(new Set([H(e,!1),H(e,!0)].filter(t=>!!t)))}function $e(){let e=process.argv[1];if(!e)return;let t=u(e);for(;t!==u(t);){if(g(s(t,"package.json")))return t;t=u(t)}}function ie(){let e=c();try{return J(e,K.W_OK),J(u(e),K.W_OK),!0}catch{return!1}}function ae(e,t,n){let o=[c(),$e()].filter(i=>!!i).flatMap(i=>Q(i));return Re(e,t,n).some(i=>Q(i).some(a=>{let d=a.endsWith(V)?a:`${a}${V}`;return o.some(p=>p.startsWith(d))}))}function lt(e,t,n=e){let r=re(),o=se(r,e,n,t);if(!(!o||!ae(r,e,t)||!ie()))return o}function mt(e){let t=process.env.PI_SELF_UPDATE_COMMAND?.trim().split(/\s+/).filter(Boolean);return t?.length?t:e?.length?e:void 0}function gt(e,t){let n={packageName:t.packageName,version:t.version,installSpec:`${t.packageName}@${t.version}`},[r="",...o]=e.map(i=>i.replace(/\{(packageName|version|installSpec)\}/g,(a,d)=>n[d]));return f(r,o)}function ht(e,t,n=e){let r=re(),o=ne(n);if(r==="bun-binary")return"Download from: https://github.com/earendil-works/pi/releases/latest";let i=se(r,e,o,t);return i&&ae(r,e,t)&&!ie()?`This installation is managed by a global ${r} install, but the install path is not writable. Update it yourself with: ${i.display}`:`Update ${o.installSpec} using the package manager, wrapper, or source checkout that provides this installation.`}function Ne(e){let t=e;for(;t!==u(t);){if(g(s(t,"package.json"))){let n=u(t);return Z(t)==="dist"&&g(s(n,"package.json"))?n:t}t=u(t)}return e}function c(){let e=process.env.PI_PACKAGE_DIR;return e?S(e):h?u(process.execPath):Ne(te)}function xt(){if(h)return s(c(),"theme");let e=c(),t=g(s(e,"src"))?"src":"dist";return s(e,t,"modes","interactive","theme")}function bt(){if(h)return s(c(),"export-html");let e=c(),t=g(s(e,"src"))?"src":"dist";return s(e,t,"core","export-html")}function Ie(){return s(c(),"package.json")}function Pt(){return _(s(c(),"README.md"))}function vt(){return _(s(c(),"docs"))}function St(){return _(s(c(),"examples"))}function _t(){return _(s(c(),"CHANGELOG.md"))}function We(){if(h)return s(c(),"assets");let e=c(),t=g(s(e,"src"))?"src":"dist";return s(e,t,"modes","interactive","assets")}function wt(e){return s(We(),e)}var X;function Et(){return X??=ee(new URL("vendor/quickjs.wasm",__cortexPackageRoot)),X}function Le(e,t){if(e==="bun-binary")return"./src/extensions/codemode/worker.ts";if(e==="bundled-node")return new URL("./codemode-worker.js",t)}var Y;function yt(){let e=h?"bun-binary":Ue?"bundled-node":"unbundled",t=Le(e,new URL("vendor/pi/dist/config.js",__cortexPackageRoot).href);return e!=="bundled-node"||!(t instanceof URL)?t:(Y??=new URL(`data:text/javascript;base64,${I(t).toString("base64")}`),Y)}function Dt(e=ce){if(h||!e)return;let t;try{t=JSON.parse($(I(e,"utf-8")))}catch(n){return n.code==="ENOENT"?{kind:"removed"}:void 0}return t.version&&t.version!==Oe?{kind:"updated",version:t.version}:void 0}var w={},ce;try{let e=Ie();w=JSON.parse($(I(e,"utf-8"))),ce=e}catch(e){if(e.code!=="ENOENT")throw e}var ue=w.piConfig?.name,kt=w.name||"@earendil-works/pi-coding-agent",k=ue||"pi",At=ue?k:"\u03C0",Te=w.piConfig?.configDir||".pi",Oe=w.version||"0.0.0",je=`${k.toUpperCase()}_CODING_AGENT_DIR`,Ct=`${k.toUpperCase()}_CODING_AGENT_SESSION_DIR`;function Be(e){return S(e)}var Fe="https://pi.dev/session/";function Ut(e){return`${process.env.PI_SHARE_VIEWER_URL||Fe}#${e}`}function b(){let e=process.env[je];return e?Be(e):s(N(),Te,"agent")}function Rt(){return s(b(),"themes")}function $t(){return s(b(),"auth.json")}function Nt(){return s(b(),"settings.json")}function It(){return s(b(),"bin")}function Wt(){return s(b(),"sessions")}function Lt(){return s(b(),`${k}-debug.log`)}export{ze as a,v as b,Ge as c,Xe as d,y as e,Ye as f,_e as g,Ze as h,et as i,tt as j,S as k,U as l,Ee as m,nt as n,rt as o,ye as p,$ as q,h as r,Ue as s,re as t,lt as u,mt as v,gt as w,ht as x,c as y,xt as z,bt as A,Pt as B,vt as C,St as D,_t as E,wt as F,Et as G,yt as H,Dt as I,kt as J,k as K,At as L,Te as M,Oe as N,je as O,Ct as P,Be as Q,Ut as R,b as S,Rt as T,$t as U,Nt as V,It as W,Wt as X,Lt as Y};
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __cortexCreateRequire } from 'node:module';
2
2
  const require = __cortexCreateRequire(import.meta.url);
3
3
  const __cortexPackageRoot = new URL("../../", import.meta.url);
4
- import{a as P,c as m}from"./chunk-MGYYSX7Y.js";import{a as T}from"./chunk-Q4UGYGU5.js";import{e as v}from"./chunk-VBN2JSER.js";import{j as h}from"./chunk-Z24SBRJK.js";import*as l from"path";import{readFileSync as O,statSync as N}from"fs";import{appendFile as L,mkdir as U}from"fs/promises";import*as _ from"path";function b(){return{runs:0,turns:0,activeMs:0,cost:0,costSamples:0,subCost:0,subSamples:0}}function E(e,t){return e.runs+=t.runs,e.turns+=t.turns,e.activeMs+=t.activeMs,e.cost+=t.cost,e.costSamples+=t.costSamples,e.subCost+=t.subCost,e.subSamples+=t.subSamples,e}function S(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function R(e){if(e?.thread?.threadId||!e?.runtime?.endedAt)return null;let t=e?.session?.sessionId;if(typeof t=="string"&&t)return{sessionId:t,role:"own"};let s=e?.session?.ownerSessionId;return typeof s=="string"&&s?{sessionId:s,role:"subagent"}:null}function I(e,t,s){let n=R(t);if(!n||s&&(t.runtime?.endedAt??"")<s)return;let r=e.get(n.sessionId);r||e.set(n.sessionId,r=b());let i=S(t.metrics?.costUsd);if(n.role==="subagent"){i!==null&&(r.subCost+=i,r.subSamples++);return}r.runs++;let u=S(t.metrics?.numTurns);u!==null&&(r.turns+=u);let o=S(t.metrics?.durationS);o!==null&&(r.activeMs+=Math.round(o*1e3)),i!==null&&(r.cost+=i,r.costSamples++)}function k(e){if(!e||e.runs===0&&e.subSamples===0)return null;let t=e.costSamples>0||e.subSamples>0;return{runs:e.runs,turns:e.turns,activeMs:e.activeMs,costUsd:t?e.cost+e.subCost:null,subagentCostUsd:e.subSamples>0?e.subCost:null}}function $(){return process.env.CORTEX_SESSION_TOTALS_FILE||_.join(h,"session-totals.json")}function c(e,t){let s=e[t];return typeof s=="number"&&Number.isFinite(s)?s:0}function F(e){let t={carriedThrough:null,sessions:{}};if(!e||typeof e!="object"||Array.isArray(e))return t;let s=e,n=typeof s.carriedThrough=="string"&&s.carriedThrough?s.carriedThrough:null,r=s.sessions;if(!r||typeof r!="object"||Array.isArray(r))return{carriedThrough:n,sessions:{}};let i={};for(let[u,o]of Object.entries(r)){if(!u||!o||typeof o!="object"||Array.isArray(o))continue;let a=o;i[u]={runs:c(a,"runs"),turns:c(a,"turns"),activeMs:c(a,"activeMs"),cost:c(a,"cost"),costSamples:c(a,"costSamples"),subCost:c(a,"subCost"),subSamples:c(a,"subSamples")}}return{carriedThrough:n,sessions:i}}var w=class{repo;constructor(t){this.repo=new m({filePath:t||$(),defaultValue:()=>({carriedThrough:null,sessions:{}}),migrate:F})}async read(){return this.repo.read()}async fold(t,s){if(t.length===0)return;let n=new Map;for(let r of t)I(n,r);await this.repo.mutate(r=>{let i={...r.sessions};for(let[o,a]of n)i[o]=E({...i[o]??b()},a);return{next:{carriedThrough:!r.carriedThrough||r.carriedThrough<s?s:r.carriedThrough,sessions:i},result:void 0}})}async forget(t){if(t.length===0)return;let s=await this.repo.read();t.some(n=>n in s.sessions)&&await this.repo.mutate(n=>{let r={...n.sessions};for(let i of t)delete r[i];return{next:{...n,sessions:r},result:void 0}})}async flush(){await this.repo.flush()}invalidate(){this.repo.invalidate()}},M=new w;var p=v("execution-repo"),j=new Set(["completed","failed","stale","cancelled"]);function C(e){if(!e.session)return e;let t={...e.session};return delete t.sessionName,{...e,session:t}}function D(e){return e||process.env.CORTEX_EXECUTIONS_FILE||l.join(h,"executions.json")}function d(){return new Date().toISOString()}function J(e){let t=Date.now().toString(36),s=Math.random().toString(36).slice(2,6);return`exec_${e}_${t}_${s}`}function q({kind:e,channel:t,project:s,trigger:n,backend:r,billingMode:i,sessionId:u,ownerSessionId:o,label:a,scheduleTaskId:g}){let f=d();return{id:J(e),kind:e,status:"running",channel:t||null,project:s||"general",source:{trigger:n||e},backend:r||"claude",billingMode:i||"api",session:{sessionId:u||null,...o?{ownerSessionId:o}:{}},scheduleTaskId:g||null,runtime:{startedAt:f,updatedAt:f,endedAt:null},metrics:{costUsd:null,numTurns:null,durationS:null},text:{label:a||null,finalOutput:null,error:null}}}function y(e,t,{costUsd:s,numTurns:n,durationS:r,finalOutput:i,error:u}={}){let o=d();return{...e,status:t,runtime:{...e.runtime,updatedAt:o,endedAt:o},metrics:{costUsd:s??e.metrics.costUsd,numTurns:n??e.metrics.numTurns,durationS:r??e.metrics.durationS},text:{...e.text,finalOutput:i??e.text.finalOutput,error:u??e.text.error}}}var A=class{map=new Map;repo;filePath;sessionTotals;mutex=new T;_pendingPersist=Promise.resolve();_persistQueued=!1;followed=null;constructor(t){this.filePath=D(t?.filePath),this.sessionTotals=t?.sessionTotals??M,this.repo=new m({filePath:this.filePath,defaultValue:()=>({}),compact:!0})}load(){try{let t=JSON.parse(O(this.filePath,"utf8"));this.map.clear();for(let[s,n]of Object.entries(t))this.map.set(s,C(n));p.info(`Loaded ${this.map.size} executions`)}catch{this.map.clear()}}follow(){this.followed="",this.refresh()}refresh(){if(this.followed===null)return;let t;try{let s=N(this.filePath);t=`${s.ino}:${s.mtimeMs}:${s.size}`}catch{this.map.clear(),this.followed="missing";return}if(t!==this.followed)try{let s=JSON.parse(O(this.filePath,"utf8"));this.map=new Map(Object.entries(s).map(([n,r])=>[n,C(r)])),this.followed=t}catch(s){p.warn(`Could not re-read ${this.filePath}: ${s.message}`)}}getExecution(t){return this.refresh(),this.map.get(t)||null}getRunningExecutions(){this.refresh();let t=[];for(let s of this.map.values())s.status==="running"&&t.push(s);return t}getAllExecutions(){return this.refresh(),Array.from(this.map.values())}getAll(){return this.refresh(),Array.from(this.map.values()).sort((t,s)=>s.runtime.startedAt.localeCompare(t.runtime.startedAt))}updateRecordInternal(t,s){let n=this.map.get(t);if(!n)return null;if(j.has(n.status))return n;let r=s({...n});return r.runtime={...n.runtime,...r.runtime,updatedAt:d()},this.map.set(t,r),this.queuePersist(),r}startLocalExecution({kind:t="local",channel:s,project:n,trigger:r,backend:i,billingMode:u,sessionId:o,ownerSessionId:a=null,label:g,scheduleTaskId:f}){let x=q({kind:t,channel:s,project:n,trigger:r,backend:i,billingMode:u,sessionId:o,ownerSessionId:a,label:g,scheduleTaskId:f});return this.map.set(x.id,x),this.queuePersist(),x}touchExecution(t,s={}){return this.updateRecordInternal(t,n=>({...n,...s,metrics:{...n.metrics,...s.metrics||{}},text:{...n.text,...s.text||{}},session:s.session?{...n.session,...s.session}:n.session}))}completeExecution(t,s={}){return this.updateRecordInternal(t,n=>y(n,"completed",s))}failExecution(t,s={}){return this.updateRecordInternal(t,n=>y(n,"failed",s))}cancelExecution(t,s={}){return this.updateRecordInternal(t,n=>y(n,"cancelled",s))}set(t,s){this.map.set(t,s),this.queuePersist()}async markMissingRunningExecutionsStale(t){await this._pendingPersist;let s=[];return await this.mutex.run(async()=>{let n=d();for(let r of this.map.values())r.status==="running"&&(t&&t(r)||(r.status="stale",r.runtime.updatedAt=n,r.runtime.endedAt=n,s.push(r.id)));s.length>0&&await this.persist()}),s}defaultArchivePath(){let t=l.basename(this.filePath).replace(/\.json$/,"");return l.join(l.dirname(this.filePath),"archive",`${t}-archive.jsonl`)}selectArchivable(t){let s=[];for(let n of this.map.values()){if(!j.has(n.status))continue;let r=n.runtime?.endedAt||n.runtime?.updatedAt||n.runtime?.startedAt;r&&r<t&&s.push(n)}return s}async archiveTerminal({olderThanMs:t=10080*60*1e3,archivePath:s}={}){return await this._pendingPersist,this.mutex.run(async()=>{let n=new Date(Date.now()-t).toISOString(),r=this.selectArchivable(n);if(r.length===0)return 0;await this.sessionTotals.fold(r,n);let i=s||this.defaultArchivePath();await U(l.dirname(i),{recursive:!0}),await L(i,r.map(u=>JSON.stringify(u)).join(`
4
+ import{a as P,c as m}from"./chunk-ITGCWQFK.js";import{a as T}from"./chunk-Q4UGYGU5.js";import{e as v}from"./chunk-7W7VYUTK.js";import{k as h}from"./chunk-T54CZKNJ.js";import*as l from"path";import{readFileSync as O,statSync as N}from"fs";import{appendFile as L,mkdir as U}from"fs/promises";import*as _ from"path";function b(){return{runs:0,turns:0,activeMs:0,cost:0,costSamples:0,subCost:0,subSamples:0}}function E(e,t){return e.runs+=t.runs,e.turns+=t.turns,e.activeMs+=t.activeMs,e.cost+=t.cost,e.costSamples+=t.costSamples,e.subCost+=t.subCost,e.subSamples+=t.subSamples,e}function S(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function R(e){if(e?.thread?.threadId||!e?.runtime?.endedAt)return null;let t=e?.session?.sessionId;if(typeof t=="string"&&t)return{sessionId:t,role:"own"};let s=e?.session?.ownerSessionId;return typeof s=="string"&&s?{sessionId:s,role:"subagent"}:null}function I(e,t,s){let n=R(t);if(!n||s&&(t.runtime?.endedAt??"")<s)return;let r=e.get(n.sessionId);r||e.set(n.sessionId,r=b());let i=S(t.metrics?.costUsd);if(n.role==="subagent"){i!==null&&(r.subCost+=i,r.subSamples++);return}r.runs++;let u=S(t.metrics?.numTurns);u!==null&&(r.turns+=u);let o=S(t.metrics?.durationS);o!==null&&(r.activeMs+=Math.round(o*1e3)),i!==null&&(r.cost+=i,r.costSamples++)}function k(e){if(!e||e.runs===0&&e.subSamples===0)return null;let t=e.costSamples>0||e.subSamples>0;return{runs:e.runs,turns:e.turns,activeMs:e.activeMs,costUsd:t?e.cost+e.subCost:null,subagentCostUsd:e.subSamples>0?e.subCost:null}}function $(){return process.env.CORTEX_SESSION_TOTALS_FILE||_.join(h,"session-totals.json")}function c(e,t){let s=e[t];return typeof s=="number"&&Number.isFinite(s)?s:0}function F(e){let t={carriedThrough:null,sessions:{}};if(!e||typeof e!="object"||Array.isArray(e))return t;let s=e,n=typeof s.carriedThrough=="string"&&s.carriedThrough?s.carriedThrough:null,r=s.sessions;if(!r||typeof r!="object"||Array.isArray(r))return{carriedThrough:n,sessions:{}};let i={};for(let[u,o]of Object.entries(r)){if(!u||!o||typeof o!="object"||Array.isArray(o))continue;let a=o;i[u]={runs:c(a,"runs"),turns:c(a,"turns"),activeMs:c(a,"activeMs"),cost:c(a,"cost"),costSamples:c(a,"costSamples"),subCost:c(a,"subCost"),subSamples:c(a,"subSamples")}}return{carriedThrough:n,sessions:i}}var w=class{repo;constructor(t){this.repo=new m({filePath:t||$(),defaultValue:()=>({carriedThrough:null,sessions:{}}),migrate:F})}async read(){return this.repo.read()}async fold(t,s){if(t.length===0)return;let n=new Map;for(let r of t)I(n,r);await this.repo.mutate(r=>{let i={...r.sessions};for(let[o,a]of n)i[o]=E({...i[o]??b()},a);return{next:{carriedThrough:!r.carriedThrough||r.carriedThrough<s?s:r.carriedThrough,sessions:i},result:void 0}})}async forget(t){if(t.length===0)return;let s=await this.repo.read();t.some(n=>n in s.sessions)&&await this.repo.mutate(n=>{let r={...n.sessions};for(let i of t)delete r[i];return{next:{...n,sessions:r},result:void 0}})}async flush(){await this.repo.flush()}invalidate(){this.repo.invalidate()}},M=new w;var p=v("execution-repo"),j=new Set(["completed","failed","stale","cancelled"]);function C(e){if(!e.session)return e;let t={...e.session};return delete t.sessionName,{...e,session:t}}function D(e){return e||process.env.CORTEX_EXECUTIONS_FILE||l.join(h,"executions.json")}function d(){return new Date().toISOString()}function J(e){let t=Date.now().toString(36),s=Math.random().toString(36).slice(2,6);return`exec_${e}_${t}_${s}`}function q({kind:e,channel:t,project:s,trigger:n,backend:r,billingMode:i,sessionId:u,ownerSessionId:o,label:a,scheduleTaskId:g}){let f=d();return{id:J(e),kind:e,status:"running",channel:t||null,project:s||"general",source:{trigger:n||e},backend:r||"claude",billingMode:i||"api",session:{sessionId:u||null,...o?{ownerSessionId:o}:{}},scheduleTaskId:g||null,runtime:{startedAt:f,updatedAt:f,endedAt:null},metrics:{costUsd:null,numTurns:null,durationS:null},text:{label:a||null,finalOutput:null,error:null}}}function y(e,t,{costUsd:s,numTurns:n,durationS:r,finalOutput:i,error:u}={}){let o=d();return{...e,status:t,runtime:{...e.runtime,updatedAt:o,endedAt:o},metrics:{costUsd:s??e.metrics.costUsd,numTurns:n??e.metrics.numTurns,durationS:r??e.metrics.durationS},text:{...e.text,finalOutput:i??e.text.finalOutput,error:u??e.text.error}}}var A=class{map=new Map;repo;filePath;sessionTotals;mutex=new T;_pendingPersist=Promise.resolve();_persistQueued=!1;followed=null;constructor(t){this.filePath=D(t?.filePath),this.sessionTotals=t?.sessionTotals??M,this.repo=new m({filePath:this.filePath,defaultValue:()=>({}),compact:!0})}load(){try{let t=JSON.parse(O(this.filePath,"utf8"));this.map.clear();for(let[s,n]of Object.entries(t))this.map.set(s,C(n));p.info(`Loaded ${this.map.size} executions`)}catch{this.map.clear()}}follow(){this.followed="",this.refresh()}refresh(){if(this.followed===null)return;let t;try{let s=N(this.filePath);t=`${s.ino}:${s.mtimeMs}:${s.size}`}catch{this.map.clear(),this.followed="missing";return}if(t!==this.followed)try{let s=JSON.parse(O(this.filePath,"utf8"));this.map=new Map(Object.entries(s).map(([n,r])=>[n,C(r)])),this.followed=t}catch(s){p.warn(`Could not re-read ${this.filePath}: ${s.message}`)}}getExecution(t){return this.refresh(),this.map.get(t)||null}getRunningExecutions(){this.refresh();let t=[];for(let s of this.map.values())s.status==="running"&&t.push(s);return t}getAllExecutions(){return this.refresh(),Array.from(this.map.values())}getAll(){return this.refresh(),Array.from(this.map.values()).sort((t,s)=>s.runtime.startedAt.localeCompare(t.runtime.startedAt))}updateRecordInternal(t,s){let n=this.map.get(t);if(!n)return null;if(j.has(n.status))return n;let r=s({...n});return r.runtime={...n.runtime,...r.runtime,updatedAt:d()},this.map.set(t,r),this.queuePersist(),r}startLocalExecution({kind:t="local",channel:s,project:n,trigger:r,backend:i,billingMode:u,sessionId:o,ownerSessionId:a=null,label:g,scheduleTaskId:f}){let x=q({kind:t,channel:s,project:n,trigger:r,backend:i,billingMode:u,sessionId:o,ownerSessionId:a,label:g,scheduleTaskId:f});return this.map.set(x.id,x),this.queuePersist(),x}touchExecution(t,s={}){return this.updateRecordInternal(t,n=>({...n,...s,metrics:{...n.metrics,...s.metrics||{}},text:{...n.text,...s.text||{}},session:s.session?{...n.session,...s.session}:n.session}))}completeExecution(t,s={}){return this.updateRecordInternal(t,n=>y(n,"completed",s))}failExecution(t,s={}){return this.updateRecordInternal(t,n=>y(n,"failed",s))}cancelExecution(t,s={}){return this.updateRecordInternal(t,n=>y(n,"cancelled",s))}set(t,s){this.map.set(t,s),this.queuePersist()}async markMissingRunningExecutionsStale(t){await this._pendingPersist;let s=[];return await this.mutex.run(async()=>{let n=d();for(let r of this.map.values())r.status==="running"&&(t&&t(r)||(r.status="stale",r.runtime.updatedAt=n,r.runtime.endedAt=n,s.push(r.id)));s.length>0&&await this.persist()}),s}defaultArchivePath(){let t=l.basename(this.filePath).replace(/\.json$/,"");return l.join(l.dirname(this.filePath),"archive",`${t}-archive.jsonl`)}selectArchivable(t){let s=[];for(let n of this.map.values()){if(!j.has(n.status))continue;let r=n.runtime?.endedAt||n.runtime?.updatedAt||n.runtime?.startedAt;r&&r<t&&s.push(n)}return s}async archiveTerminal({olderThanMs:t=10080*60*1e3,archivePath:s}={}){return await this._pendingPersist,this.mutex.run(async()=>{let n=new Date(Date.now()-t).toISOString(),r=this.selectArchivable(n);if(r.length===0)return 0;await this.sessionTotals.fold(r,n);let i=s||this.defaultArchivePath();await U(l.dirname(i),{recursive:!0}),await L(i,r.map(u=>JSON.stringify(u)).join(`
5
5
  `)+`
6
6
  `,"utf8");for(let u of r)this.map.delete(u.id);return await this.persist(),p.info(`Archived ${r.length} terminal execution(s) to ${i}`),r.length})}async flush(){await this._pendingPersist,await this.mutex.run(async()=>{})}queuePersist(){return this._persistQueued?this._pendingPersist:(this._persistQueued=!0,this._pendingPersist=this._pendingPersist.catch(()=>{}).then(()=>this.mutex.run(()=>(this._persistQueued=!1,this.persist()))).catch(t=>{p.error("persist failed:",t)}),this._pendingPersist)}async persist(){let t={};for(let[s,n]of this.map)t[s]=n;await this.repo.write(t)}},Q=new A;P(Q);export{b as a,E as b,I as c,k as d,M as e,j as f,A as g,Q as h};
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __cortexCreateRequire } from 'node:module';
2
2
  const require = __cortexCreateRequire(import.meta.url);
3
3
  const __cortexPackageRoot = new URL("../../", import.meta.url);
4
- import{d as s,j as i}from"./chunk-Z24SBRJK.js";import*as t from"fs";import*as o from"path";var u=o.join(i,"client-pids.json");function x(){return o.join(s,"client","current","client.mjs")}function r(){try{return JSON.parse(t.readFileSync(u,"utf8"))}catch{return{}}}function l(n){t.mkdirSync(i,{recursive:!0}),t.writeFileSync(u,JSON.stringify(n,null,2))}function h(n){return r()[n]}function P(n,e){let c=r();c[n]=e,l(c)}function S(n){let e=r();delete e[n],l(e)}function I(n){return!!n&&!n.ssh&&!n.clientCommand&&n.clientConnection!=="ssh-reverse"}import{readFileSync as p}from"fs";import{execFileSync as m}from"node:child_process";function d(n){return p(`/proc/${n}/cmdline`,"utf8").split("\0").filter(Boolean).join(" ")}function a(n){let e=`[Console]::OutputEncoding = [Text.Encoding]::UTF8; $p = Get-CimInstance Win32_Process -Filter 'ProcessId=${n}'; if ($p) { [Console]::Out.Write($p.CommandLine) }`;return m("powershell.exe",["-NoProfile","-NonInteractive","-Command",e],{encoding:"utf8",timeout:1e4,windowsHide:!0,stdio:["ignore","pipe","ignore"]})}function f(n){return m("ps",["-o","command=","-p",String(n)],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","ignore"]})}var C={linux:d,win32:a};function w(n){if(!Number.isInteger(n)||n<=0)return null;let e=C[process.platform]??f;try{return e(n).trim()||null}catch{return null}}export{x as a,r as b,h as c,P as d,S as e,I as f,w as g};
4
+ import{e as s,k as i}from"./chunk-T54CZKNJ.js";import*as t from"fs";import*as o from"path";var u=o.join(i,"client-pids.json");function x(){return o.join(s,"client","current","client.mjs")}function r(){try{return JSON.parse(t.readFileSync(u,"utf8"))}catch{return{}}}function l(n){t.mkdirSync(i,{recursive:!0}),t.writeFileSync(u,JSON.stringify(n,null,2))}function h(n){return r()[n]}function P(n,e){let c=r();c[n]=e,l(c)}function S(n){let e=r();delete e[n],l(e)}function I(n){return!!n&&!n.ssh&&!n.clientCommand&&n.clientConnection!=="ssh-reverse"}import{readFileSync as p}from"fs";import{execFileSync as m}from"node:child_process";function d(n){return p(`/proc/${n}/cmdline`,"utf8").split("\0").filter(Boolean).join(" ")}function a(n){let e=`[Console]::OutputEncoding = [Text.Encoding]::UTF8; $p = Get-CimInstance Win32_Process -Filter 'ProcessId=${n}'; if ($p) { [Console]::Out.Write($p.CommandLine) }`;return m("powershell.exe",["-NoProfile","-NonInteractive","-Command",e],{encoding:"utf8",timeout:1e4,windowsHide:!0,stdio:["ignore","pipe","ignore"]})}function f(n){return m("ps",["-o","command=","-p",String(n)],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","ignore"]})}var C={linux:d,win32:a};function w(n){if(!Number.isInteger(n)||n<=0)return null;let e=C[process.platform]??f;try{return e(n).trim()||null}catch{return null}}export{x as a,r as b,h as c,P as d,S as e,I as f,w as g};
@@ -0,0 +1,17 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{f as at}from"./chunk-BWDJS6A4.js";import{a as ct}from"./chunk-6R73ICDB.js";import{E as ot,G as ft}from"./chunk-DE5EGVKG.js";import{b as Ce}from"./chunk-X2TKJ7KR.js";import{c as Pe}from"./chunk-CXT5IR5T.js";function os(t,e){return{name:t,login:async n=>{n.signal.throwIfAborted();let r=await n.prompt({type:"secret",message:`Enter ${t}`});return n.signal.throwIfAborted(),{type:"api_key",key:r}},resolve:async({ctx:n,credential:r,signal:i})=>{if(i.throwIfAborted(),r?.key)return{auth:{apiKey:r.key},env:r.env,source:"stored credential"};for(let s of e){let o=await n.env(s);if(i.throwIfAborted(),o)return{auth:{apiKey:o},source:s}}}}}function fs(t){let e,n=()=>(e??=t.load(),e);return{name:t.name,isSubscription:t.isSubscription,loginLabel:t.loginLabel,login:async(r,i)=>(await n()).login(r,i),refresh:async(r,i)=>(await n()).refresh(r,i),toAuth:async r=>(await n()).toAuth(r)}}var ds=60*6e4,ps=30*6e4,gr=.05,xr=.15;function hs(t){if(!(t<=1e4))return Math.max(1,Math.floor(Math.min(t*.9,t-1e4)))}function ls(t,e){let n=e?.cacheRetention??(ct("PI_CACHE_RETENTION",e?.env)==="long"?"long":"short");if(n==="none")return;let r=t.promptCache?.[n];return r===void 0?void 0:r*1e3}function ms(t,e){return!e?.reasoning||t.api!=="anthropic-messages"?!0:t.compat?.forceAdaptiveThinking===!0}function ys(t,e){return{...t,maxTokens:1,disableContinuation:!0,maxRetries:0,signal:e}}function gs(t,e,n){let r=Se(t,{cacheRead:e}),i=Se(t,t.cost.cacheWrite>0?{cacheWrite:e}:{input:e}),s=Se(t,{cacheRead:e,output:1}),o=Math.max(0,i-r),f=n==="idle"?xr:1,c=e>0&&(r>0||i>0),a=f*o-s;return{phase:n,warmCost:s,missCost:o,continuationProbability:f,expectedSavings:a,economicsAvailable:c,action:a>=gr?"warm":"stop"}}function Se(t,e){let n={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},...e};return ft(t,n).total}var ht="faux",lt="faux",mt="faux-1",Ir="Faux Model",Ar="http://localhost:0",br=3,ut=5,ie={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}};function Er(t){return{type:"text",text:t}}function Os(t){return{type:"thinking",thinking:t}}function Rs(t,e,n={}){return{type:"toolCall",id:n.id??Me("tool"),name:t,arguments:e}}function Or(t){return typeof t=="string"?[Er(t)]:Array.isArray(t)?t:[t]}function ks(t,e={}){return{role:"assistant",content:Or(t),api:ht,provider:lt,model:mt,usage:ie,stopReason:e.stopReason??"stop",...e.deferred===void 0?{}:{deferred:e.deferred},...e.errorMessage===void 0?{}:{errorMessage:e.errorMessage},...e.responseId===void 0?{}:{responseId:e.responseId},timestamp:e.timestamp??Date.now()}}function yt(t){return Math.ceil(t.length/4)}function Me(t){return`${t}:${Date.now()}:${Math.random().toString(36).slice(2)}`}function gt(t){return typeof t=="string"?t:t.map(e=>e.type==="text"?e.text:`[image:${e.mimeType}:${e.data.length}]`).join(`
5
+ `)}function xt(t){return t.map(e=>e.type==="text"?e.text:e.type==="thinking"?e.thinking:`${e.name}:${JSON.stringify(e.arguments)}`).join(`
6
+ `)}function Rr(t){return[t.toolName,...t.content.map(e=>gt([e]))].join(`
7
+ `)}function kr(t){return t.role==="system"?[Ce(t),...t.toolsRemoved?.map(e=>`tool-:${JSON.stringify(e)}`)??[],...t.toolsAdded?.map(e=>`tool+:${JSON.stringify(e)}`)??[]].filter(e=>e.length>0).join(`
8
+ `):t.role==="user"?gt(t.content):t.role==="assistant"?xt(t.content):Rr(t)}function It(t,e=t.length){let n=e>0?(e-1)*2:0;for(let r=0;r<e;r++)n+=t[r].length;return n}function _r(t,e){let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;let r=i=>n===i.length?"":(n>0?`
9
+
10
+ `:"")+i.slice(n).join(`
11
+
12
+ `);return It(t,n)+Nr(r(t),r(e))}function Nr(t,e){let n=Math.min(t.length,e.length),r=0;for(;r<n&&t[r]===e[r];)r++;return r}function dt(t,e,n,r){let i=e.messages.map(p=>`${p.role}:${kr(p)}`),s=It(i),o=Math.ceil(s/4),f=yt(xt(t.content)),c=o,a=0,d=0,u=n?.sessionId;if(u&&n?.cacheRetention!=="none"){let p=r.get(u);if(p){let l=_r(p,i);a=Math.ceil(l/4),d=Math.max(0,o-a)}else d=o;c=0,r.set(u,i)}return{...t,usage:{input:c,output:f,cacheRead:a,cacheWrite:d,totalTokens:c+f+a+d,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}}function Te(t,e,n){let r=[],i=0;for(;i<t.length;){let s=e+Math.floor(Math.random()*(n-e+1)),o=Math.max(1,s*4);r.push(t.slice(i,i+o)),i+=o}return r.length>0?r:[""]}function wr(t,e,n,r){let i=structuredClone(t);return{...i,api:e,provider:n,model:r,timestamp:i.timestamp??Date.now(),usage:i.usage??ie}}function pt(t,e){return{role:"assistant",content:[],api:t.api,provider:t.provider,model:t.id,usage:ie,stopReason:"deferred",deferred:e,timestamp:Date.now()}}function ne(t,e,n,r){return{role:"assistant",content:[],api:e,provider:n,model:r,usage:ie,stopReason:"error",errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}function B(t){return{...t,stopReason:"aborted",errorMessage:"Request was aborted",timestamp:Date.now()}}function $e(t,e){if(!e||e<=0)return new Promise(r=>queueMicrotask(r));let n=yt(t)/e*1e3;return new Promise(r=>setTimeout(r,n))}async function re(t,e,n,r,i,s){let o={...e,content:[],stopReason:"pending"};if(s?.aborted){let f=B(o);t.push({type:"error",reason:"aborted",error:f}),t.end(f);return}t.push({type:"start",partial:{...o}});for(let f=0;f<e.content.length;f++){if(s?.aborted){let d=B(o);t.push({type:"error",reason:"aborted",error:d}),t.end(d);return}let c=e.content[f];if(c.type==="thinking"){o.content=[...o.content,{type:"thinking",thinking:""}],t.push({type:"thinking_start",contentIndex:f,partial:{...o}});for(let d of Te(c.thinking,n,r)){if(await $e(d,i),s?.aborted){let u=B(o);t.push({type:"error",reason:"aborted",error:u}),t.end(u);return}o.content[f].thinking+=d,t.push({type:"thinking_delta",contentIndex:f,delta:d,partial:{...o}})}t.push({type:"thinking_end",contentIndex:f,content:c.thinking,partial:{...o}});continue}if(c.type==="text"){o.content=[...o.content,{type:"text",text:""}],t.push({type:"text_start",contentIndex:f,partial:{...o}});for(let d of Te(c.text,n,r)){if(await $e(d,i),s?.aborted){let u=B(o);t.push({type:"error",reason:"aborted",error:u}),t.end(u);return}o.content[f].text+=d,t.push({type:"text_delta",contentIndex:f,delta:d,partial:{...o}})}t.push({type:"text_end",contentIndex:f,content:c.text,partial:{...o}});continue}o.content=[...o.content,{type:"toolCall",id:c.id,name:c.name,arguments:{}}],t.push({type:"toolcall_start",contentIndex:f,partial:{...o}});let a=new at;for(let d of Te(JSON.stringify(c.arguments),n,r)){if(await $e(d,i),s?.aborted){let u=B(o);t.push({type:"error",reason:"aborted",error:u}),t.end(u);return}o.content[f].arguments=a.append(d),t.push({type:"toolcall_delta",contentIndex:f,delta:d,partial:{...o}})}o.content[f].arguments=c.arguments,t.push({type:"toolcall_end",contentIndex:f,toolCall:c,partial:{...o}})}if(e.stopReason==="pending")throw new Error("Faux response ended without a stop reason");if(e.stopReason==="error"||e.stopReason==="aborted"){t.push({type:"error",reason:e.stopReason,error:e}),t.end(e);return}t.push({type:"done",reason:e.stopReason,message:e}),t.end(e)}function Pr(t){let e=t.api??Me(ht),n=t.provider??lt,r=Math.max(1,Math.min(t.tokenSize?.min??br,t.tokenSize?.max??ut)),i=Math.max(r,t.tokenSize?.max??ut),s=[],o=t.tokensPerSecond,f={callCount:0,deferredFetchCount:0,cancelledDeferred:[]},c=new Map,a=new Map,u=(t.models?.length?t.models:[{id:mt,name:Ir,reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384}]).map(m=>({id:m.id,name:m.name??m.id,api:e,provider:n,baseUrl:Ar,reasoning:m.reasoning??!1,input:m.input??["text","image"],inputLimits:m.inputLimits,cost:m.cost??{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:m.contextWindow??128e3,maxTokens:m.maxTokens??16384})),p=async(m,x,A,I)=>{let g=typeof m=="function"?await m(x,A,f,I):m;return dt(wr(g,e,n,I.id),x,A,c)},l=(m,x,A)=>{let I=Pe(),g=s.shift();return f.callCount++,queueMicrotask(async()=>{try{if(await A?.onResponse?.({status:200,headers:{}},m),!g){let E=ne(new Error("No more faux responses queued"),e,n,m.id);E=dt(E,x,A,c),I.push({type:"error",reason:"error",error:E}),I.end(E);return}if(A?.deferred){let E={provider:m.provider,modelId:m.id,api:m.api,id:Me("deferred"),...t.deferred?.pollAfterMs!==void 0?{pollAfterMs:t.deferred.pollAfterMs}:{}};a.set(E.id,{handle:E,step:g,context:x,options:A,model:m,pendingFetches:Math.max(0,Math.floor(t.deferred?.pendingFetches??0)),cancelled:!1}),await re(I,pt(m,E),r,i,o,A.signal);return}let C=await p(g,x,A,m);await re(I,C,r,i,o,A?.signal)}catch(C){let E=ne(C,e,n,m.id);I.push({type:"error",reason:"error",error:E}),I.end(E)}}),I},y=(m,x,A)=>l(m,x,A),N=(m,x,A)=>{let I=Pe();return f.deferredFetchCount++,queueMicrotask(async()=>{try{await A?.onResponse?.({status:200,headers:{}},m);let g=a.get(x.id);if(!g||g.handle.provider!==x.provider||g.handle.modelId!==x.modelId||g.handle.api!==x.api)throw new Error(`Unknown faux deferred response: ${x.id}`);if(g.cancelled)throw new Error(`Faux deferred response was cancelled: ${x.id}`);if(g.pendingFetches>0){g.pendingFetches--,await re(I,pt(m,g.handle),r,i,o,A?.signal);return}if(!g.final){let{deferred:C,signal:E,onResponse:ss,...mr}=g.options??{};try{g.final=await p(g.step,g.context,mr,g.model)}catch(yr){g.final=ne(yr,e,n,g.model.id)}}await re(I,g.final,r,i,o,A?.signal)}catch(g){let C=ne(g,e,n,m.id);I.push({type:"error",reason:"error",error:C}),I.end(C)}}),I},z=async(m,x,A)=>{f.cancelledDeferred.push(structuredClone(x));let I=a.get(x.id);I&&(I.cancelled=!0),await A?.onResponse?.({status:200,headers:{}},m)};function we(m){return m?u.find(x=>x.id===m):u[0]}return{api:e,provider:n,models:u,stream:l,streamSimple:y,fetchDeferred:N,cancelDeferred:z,getModel:we,state:f,setResponses(m){s=[...m]},appendResponses(m){s.push(...m)},getPendingResponseCount(){return s.length}}}function _s(t={}){let e=Pr(t);return{provider:ot({id:e.provider,auth:{apiKey:{name:"Faux",resolve:async()=>({auth:{}})}},models:e.models,api:{stream:e.stream,streamSimple:e.streamSimple,fetchDeferred:e.fetchDeferred,cancelDeferred:e.cancelDeferred}}),api:e.api,models:e.models,getModel:e.getModel,state:e.state,setResponses:e.setResponses,appendResponses:e.appendResponses,getPendingResponseCount:e.getPendingResponseCount}}var At=[/prompt (?:is )?too long/i,/prompt exceeds max length/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,/context window exceeded/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,/model_context_window_exceeded/i,/prompt too long; exceeded (?:max )?context length/i,/range of input length should be/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i,/^(?:[\w -]+ API error \(413\):|413(?:\s|:|$))/i],Cr=/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i,Sr=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i];function ws(t,e){return!!(t.stopReason==="error"&&t.errorMessage&&!Sr.some(r=>r.test(t.errorMessage))&&(At.some(r=>r.test(t.errorMessage))||t.provider==="cerebras"&&Cr.test(t.errorMessage))||e&&t.stopReason==="stop"&&t.usage.input+t.usage.cacheRead>e||e&&t.stopReason==="length"&&t.usage.output===0&&t.usage.input+t.usage.cacheRead>=e*.99)}function Ps(t,e){return t.stopReason==="length"&&e>0&&t.usage.output<e}function Cs(){return[...At]}function Tr(t={}){return{type:"string",...t}}function $r(t={}){return{type:"number",...t}}function Mr(t={}){return{type:"integer",...t}}function Lr(t={}){return{type:"boolean",...t}}function jr(t={}){return{type:"null",...t}}function Ur(t,e={}){return{enum:t,...e}}function Fr(t,e={}){return{anyOf:t,...e}}function Dr(t,e={}){return{type:"array",items:t,...e}}var G=class{schema;constructor(e){this.schema=e}};function zr(t){return new G(t)}function Br(t,e={}){let{open:n,...r}=e,i={},s=[];for(let[o,f]of Object.entries(t))f instanceof G?i[o]=f.schema:(i[o]=f,s.push(o));return{type:"object",properties:i,...s.length>0?{required:s}:{},...n===!0?{}:{additionalProperties:!1},...r}}var S=()=>!0,H=()=>!1,Ot=t=>typeof t=="string",Rt=t=>Number.isFinite(t),kt=t=>Number.isInteger(t),_t=t=>typeof t=="boolean",Nt=t=>t===null,Le=t=>Array.isArray(t),Gr=t=>t instanceof Uint8Array,Wr=t=>typeof t=="bigint",Hr=t=>t===void 0,je=t=>b(t);function b(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof Uint8Array)}var M=new Map([["string",Ot],["number",Rt],["integer",kt],["boolean",_t],["null",Nt],["array",Le],["object",je],["bytes",Gr],["bigint",Wr],["undefined",Hr]]),wt=new WeakMap([[Ot,[1,void 0]],[Rt,[2,void 0]],[kt,[3,void 0]],[_t,[4,void 0]],[Nt,[5,void 0]],[S,[6,void 0]]]);function Ue(t){return wt.get(t)}function T(t,e,n){return wt.set(n,[t,e]),n}var oe=class{min;max;xmin;xmax;constructor(e,n,r,i){this.min=e,this.max=n,this.xmin=r,this.xmax=i}};function Fe(t,e,n){switch(t){case 1:return typeof e=="string";case 2:return Number.isFinite(e);case 3:return Number.isInteger(e);case 4:return typeof e=="boolean";case 5:return e===null;case 7:return e===n;case 8:{let r=n;for(let i=0;i<r.length;i++)if(r[i]===e)return!0;return!1}case 9:return(We(e)&n)!==0;case 10:return Number.isInteger(e)&&bt(e,n);case 11:return Number.isFinite(e)&&bt(e,n);case 12:return typeof e=="string"&&se(e,n.min,n.max);case 13:return typeof e=="string"&&n.test(e);default:return!0}}function bt(t,e){return t>=e.min&&t<=e.max&&t>e.xmin&&t<e.xmax}var Y=0,De=1,L=2,Pt=15,$=16,ze=32;function V(t){switch(t.length){case 0:return S;case 1:return t[0];case 2:{let[e,n]=t;return r=>e(r)&&n(r)}case 3:{let[e,n,r]=t;return i=>e(i)&&n(i)&&r(i)}default:return e=>{for(let n=0;n<t.length;n++)if(!t[n](e))return!1;return!0}}}function Ct(t){return e=>t.check(e)}function Be(t,e,n){return r=>{t.push(e);let i=n(r);return t.pop(),i}}function St(t){return t.length===1?(typeof t[0]=="string"?M.get(t[0]):void 0)??H:Tt(Ge(t))}var Yr=new Map([["string",1],["number",2],["integer",4],["boolean",8],["null",16],["array",32],["object",64],["bytes",128],["bigint",256],["undefined",512]]);function Ge(t){let e=0;for(let n of t)typeof n=="string"&&(e|=Yr.get(n)??0);return e}function We(t){switch(typeof t){case"string":return 1;case"number":return Number.isInteger(t)?6:Number.isFinite(t)?2:0;case"boolean":return 8;case"object":return t===null?16:Array.isArray(t)?32:t instanceof Uint8Array?128:64;case"bigint":return 256;case"undefined":return 512;default:return 0}}function Tt(t){return T(9,t,e=>(We(e)&t)!==0)}function $t(t,e){if(e.length===0)return Tt(t);let n=e.length===1?e[0]:Ve(e);return r=>(We(r)&t)!==0||n(r)}function Mt(t,e){return n=>n instanceof Uint8Array&&n.length>=t&&n.length<=e}function fe(t){let e=0;for(let n=0;n<t.length;n++,e++){let r=t.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<t.length){let i=t.charCodeAt(n+1);i>=56320&&i<=57343&&n++}}return e}function se(t,e,n){let r=t.length;return r<e||r<2*e&&fe(t)<e?!1:r<=n||fe(t)<=n}function Lt(t,e,n,r,i){return r!==void 0&&e===0&&n===Number.POSITIVE_INFINITY&&i===void 0?t?T(13,r,s=>typeof s=="string"&&r.test(s)):s=>typeof s!="string"||r.test(s):r===void 0&&i===void 0?t?T(12,new oe(e,n,0,0),s=>typeof s=="string"&&se(s,e,n)):s=>typeof s!="string"||se(s,e,n):s=>typeof s!="string"?!t:se(s,e,n)&&(r===void 0||r.test(s))&&(i===void 0||i(s))}function jt(t,e,n,r,i,s){let o=c=>typeof c!="number"&&typeof c!="bigint"?t===0:(t===3?typeof c!="bigint":t!==0&&!Number.isFinite(c))||t===2&&!Number.isInteger(c)?!1:c>=e&&c<=n&&c>r&&c<i&&(s===void 0||He(c,s));return t===0||t===3||s!==void 0||!(typeof e=="number"&&typeof n=="number"&&typeof r=="number"&&typeof i=="number")?o:T(t===2?10:11,new oe(e,n,r,i),o)}function He(t,e){if(typeof t=="bigint"||typeof e=="bigint"){if(typeof t=="number"&&!Number.isInteger(t)||typeof e=="number"&&!Number.isInteger(e))return!1;let f=BigInt(e);return f!==0n&&BigInt(t)%f===0n}let n=t/e;if(Number.isInteger(n))return!0;if(!Number.isFinite(n))return t%e===0;let[r,i]=Et(t),[s,o]=Et(e);return i>=o?r*10n**BigInt(i-o)%s===0n:r%(s*10n**BigInt(o-i))===0n}function Et(t){let[e,n="0"]=Math.abs(t).toString().split("e"),r=e.indexOf("."),i=r<0?0:e.length-r-1;return[BigInt(e.replace(".","")),Number(n)-i]}function Ut(t,e){return e?n=>b(n)&&t(n):n=>!b(n)||t(n)}function Ft(t,e){return e?n=>Array.isArray(n)&&t(n):n=>!Array.isArray(n)||t(n)}function Dt(t,e,n,r){let i=t.length;return s=>{if(r!==Y&&!b(s))return r===L;let o=s,f=0,c=0;for(let a in o){let d=c;if(t[d]!==a){for(d=0;d<i&&t[d]!==a;)d+=3;if(d===i){if(n)return!1;continue}}c=d+3;let u=o[a],p=t[d+2];if(u===void 0&&!(p&$))continue;let l=p&Pt;if(l!==0?!Fe(l,u,t[d+1]):!t[d+1](u))return!1;p&$&&f++}return f===e}}function zt(t,e,n,r,i,s){let o=r.length>0||i!==void 0?new Set(e):void 0;return f=>{if(s!==Y&&!b(f))return s===L;let c=f;for(let a=0;a<t.length;a+=3){let d=t[a],u=c[d],p=t[a+2];if(u===void 0&&!(p&$&&Object.hasOwn(c,d))||p&ze&&!Object.hasOwn(c,d)){if(p&$)return!1;continue}let l=p&Pt;if(l!==0?!Fe(l,u,t[a+1]):!t[a+1](u))return!1}for(let a=0;a<n.length;a++)if(!Object.hasOwn(c,n[a]))return!1;if(o===void 0)return!0;for(let a of Object.keys(c)){let d=o.has(a);for(let u=0;u<r.length;u++)if(r[u][0].test(a)&&(d=!0,!r[u][1](c[a])))return!1;if(!d&&i!==void 0&&!i(c[a]))return!1}return!0}}function Bt(t){return e=>{for(let n in e)if(!t(n))return!1;return!0}}function Gt(t,e){return n=>{let r=0;for(let i in n)r++;return r>=t&&r<=e}}function Wt(t){return e=>{let n=e;for(let[r,i]of t)if(Object.hasOwn(n,r)){for(let s of i)if(!Object.hasOwn(n,s))return!1}return!0}}function Ht(t){return e=>{for(let[n,r]of t)if(Object.hasOwn(e,n)&&!r(e))return!1;return!0}}var Vr=[0,void 0];function Ye(t,e,n,r,i){let s=r.length,[o,f]=(i===void 0?void 0:Ue(i))??Vr;return c=>{if(!Array.isArray(c))return t===L;let a=c.length;if(a<e||a>n)return!1;let d=a<s?a:s;for(let u=0;u<d;u++)if(!r[u](c[u]))return!1;if(i===void 0)return!0;if(o!==0){for(let u=s;u<a;u++)if(!Fe(o,c[u],f))return!1;return!0}for(let u=s;u<a;u++)if(!i(c[u]))return!1;return!0}}function Yt(t,e){return Ye(Y,0,Number.POSITIVE_INFINITY,t,e)}function Vt(t,e){return n=>n.length>=t&&n.length<=e}function ce(t,e,n){return r=>{let i=r,s=0;for(let o=0;o<i.length;o++)if(t(i[o])&&++s>n)return!1;return s>=e}}function ae(t){let e=t;for(let n=1;n<e.length;n++)for(let r=0;r<n;r++)if(W(e[n],e[r]))return!1;return!0}function q(t){let e=t.filter(i=>typeof i!="object"||i===null);if(e.length===t.length&&e.length<=8)return T(8,e,i=>{for(let s=0;s<e.length;s++)if(e[s]===i)return!0;return!1});let n=new Set(e),r=t.filter(i=>typeof i=="object"&&i!==null);return i=>n.has(i)||typeof i=="object"&&r.some(s=>W(i,s))}function ue(t){return typeof t!="object"||t===null?T(7,t,e=>e===t):e=>W(e,t)}function Ve(t){return e=>{for(let n=0;n<t.length;n++)if(t[n](e))return!0;return!1}}function qt(t){return e=>{let n=0;for(let r=0;r<t.length;r++)if(t[r](e)&&++n>1)return!1;return n===1}}function Jt(t){return e=>!t(e)}function Kt(t,e,n){return r=>t(r)?e(r):n(r)}function Xt(t,e,n){return r=>{if(!b(r))return!1;let i=r[t];for(let s=0;s<e.length;s++)if(e[s]===i)return n[s](r);return!1}}function W(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null)return!1;let n=Array.isArray(t);if(n!==Array.isArray(e))return!1;if(n){let o=t,f=e;if(o.length!==f.length)return!1;for(let c=0;c<o.length;c++)if(!W(o[c],f[c]))return!1;return!0}let r=t,i=e,s=Object.keys(r);if(s.length!==Object.keys(i).length)return!1;for(let o of s)if(!Object.hasOwn(i,o)||!W(r[o],i[o]))return!1;return!0}var de="https://json-schema.invalid/root.json",pe=class{draft;rootBase=de;baseOf=new Map;dynamicAnchors=new Map;root;options;registry=new Map;rejectUnresolved;unresolved=new Set;resources=new Map;anchors=new Map;indexed=!1;constructor(e,n){this.draft=n.draft==="7"?"7":"2020-12",this.root=e,this.options=n,this.rejectUnresolved=n.unresolvedRefs==="reject"}baseFor(e,n){let r=this.baseOf.get(e);if(r!==void 0)return r;let i=e.$id;return typeof i!="string"?n:!this.indexed&&(this.ensureIndexed(),r=this.baseOf.get(e),r!==void 0)?r:this.draft==="7"&&(typeof e.$ref=="string"||i.startsWith("#"))?n:P(w(i,n))}ensureIndexed(){if(!this.indexed){this.indexed=!0;for(let[e,n]of Object.entries(this.options.schemas??{}))this.registry.set(P(w(e,de)),n);this.resources.set(de,this.root),this.index(this.root,de)}}resolve(e,n){if(this.ensureIndexed(),!this.rejectUnresolved)return this.find(e,n);try{return this.find(e,n)}catch{return this.unresolved.add(w(e,n)),{node:!1,base:n}}}isUnresolved(e,n){return this.unresolved.has(w(e,n))}find(e,n){let r=w(e,n),i=P(r),s=r.length>i.length?decodeURIComponent(r.slice(i.length+1)):"",o=this.resources.has(i)?this.resources.get(i):this.load(i);if(o===void 0)throw new Error(`Unresolved $ref ${e} (no schema registered for ${i})`);if(s==="")return{node:o,base:i};if(s.startsWith("/"))return this.pointer(o,i,s);let f=this.anchors.get(`${i}#${s}`);if(f===void 0)throw new Error(`Unresolved $ref ${e} (no anchor ${s} in ${i})`);return{node:f,base:this.baseOf.get(f)??i}}isResource(e,n){return this.ensureIndexed(),this.resources.get(n)===e}index(e,n){if(!h(e)||this.baseOf.has(e))return;let r=n,i=this.draft==="7"&&typeof e.$ref=="string";if(!i&&typeof e.$id=="string")if(this.draft==="7"&&e.$id.startsWith("#"))this.anchors.set(P(r)+e.$id,e);else{let s=w(e.$id,r);r=P(s),this.resources.set(r,e),s.length>r.length+1&&this.anchors.set(s,e)}if(this.baseOf.set(e,r),!i){this.draft!=="7"&&(typeof e.$anchor=="string"&&this.anchors.set(`${r}#${e.$anchor}`,e),typeof e.$dynamicAnchor=="string"&&(this.anchors.set(`${r}#${e.$dynamicAnchor}`,e),this.dynamicAnchors.set(`${r}#${e.$dynamicAnchor}`,e)));for(let s of qr)this.index(e[s],r);for(let s of Jr){let o=e[s];if(h(o))for(let f of Object.keys(o))this.index(o[f],r)}for(let s of Kr){let o=e[s];if(Array.isArray(o))for(let f of o)this.index(f,r)}}}load(e){let n=this.registry.get(e);if(n!==void 0)return this.resources.set(e,n),this.index(n,e),n}pointer(e,n,r){let i=e,s=n;for(let o of r.split("/").slice(1)){let f=o.replace(/~1/g,"/").replace(/~0/g,"~");if(i=typeof i=="object"&&i!==null&&Object.hasOwn(i,f)?i[f]:void 0,i===void 0)throw new Error(`Unresolved $ref #${r} in ${n}`);typeof i=="object"&&i!==null&&(s=this.baseOf.get(i)??s)}return{node:i,base:s}}},qr=["additionalProperties","propertyNames","contains","not","if","then","else","unevaluatedProperties","unevaluatedItems","additionalItems","contentSchema","items"],Jr=["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"],Kr=["allOf","anyOf","oneOf","prefixItems","items"];function h(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function w(t,e){try{return new URL(t,e).href}catch{return t.startsWith("#")?P(e)+t:t}}function P(t){let e=t.indexOf("#");return e<0?t:t.slice(0,e)}function R(t){let e=he.get(t)?.deref();if(e!==void 0)return e;let n;try{n=new RegExp(t,"u")}catch{n=new RegExp(t)}return he.set(t,new WeakRef(n)),Xr.register(n,t),n}var he=new Map,Xr=new FinalizationRegistry(t=>{he.get(t)?.deref()===void 0&&he.delete(t)});var ye=class{c;schema;entered=[];cuts=0;memo=void 0;constructor(e,n){this.c=e,this.schema=n}coerce(e){let n=this.c.r.rootBase,r=this.dropOptionalNulls(e,this.schema,n);return this.coerceTypes(this.convertOnly(r),this.schema,n)}convertOnly(e){try{return this.convert(this.schema,this.c.r.rootBase,e)}finally{this.memo=void 0,this.cuts=0}}reenter(e,n,r,i){let s=this.entered;for(let a=0;a<s.length;a+=2)if(s[a]===e&&Object.is(s[a+1],r))return this.cuts++,r;let o=i?this.memo?.get(e):void 0;if(o?.has(r))return o.get(r);let f=this.cuts;s.push(e,r);let c;try{c=this.convert(e,n,r)}finally{s.length-=2}if(i&&this.cuts===f){this.memo??=new Map;let a=this.memo.get(e);a===void 0&&(a=new Map,this.memo.set(e,a)),a.set(r,c)}return c}passes(e,n,r){try{return this.c.check(e,this.baseOf(e,n))(r)}catch{return}}baseOf(e,n){return h(e)?this.c.r.baseFor(e,n):n}dropOptionalNulls(e,n,r){if(!h(n))return e;let i=this.baseOf(n,r);if(Array.isArray(e))return le(e,(u,p)=>{let l=Zt(n,p);return l===void 0?u:this.dropOptionalNulls(u,l,i)});if(!me(e))return e;let s=h(n.properties)?n.properties:{},o=h(n.patternProperties)?Object.entries(n.patternProperties).map(([u,p])=>[R(u),p]):[],f=h(n.additionalProperties)?n.additionalProperties:void 0;if(o.length===0&&f===void 0&&!h(n.properties))return e;let c=new Set(Array.isArray(n.required)?n.required:[]),a,d=(u,p)=>{p!==(a??e)[u]&&(a??={...e},a[u]=p)};for(let[u,p]of Object.entries(s)){if(!Object.hasOwn(e,u))continue;let l=h(p)&&typeof p.$ref=="string";if(e[u]===null&&!c.has(u)&&!l&&this.passes(p,i,null)===!1){a??={...e},delete a[u];continue}d(u,this.dropOptionalNulls(e[u],p,i))}if(o.length>0||f!==void 0)for(let u of Object.keys(e)){let p=Object.hasOwn(s,u);for(let[l,y]of o)l.test(u)&&(p=!0,d(u,this.dropOptionalNulls((a??e)[u],y,i)));!p&&f!==void 0&&d(u,this.dropOptionalNulls(e[u],f,i))}return a??e}convert(e,n,r){if(!h(e))return r;let i=this.baseOf(e,n);if(typeof e.$ref=="string"){let s;try{s=this.c.r.resolve(e.$ref,i)}catch{return r}return h(s.node)?this.reenter(s.node,s.base,r,!0):r}return this.convertNode(e,i,r)}convertNode(e,n,r){if(Object.hasOwn(e,"const"))return Qt(e.const,r);if(Array.isArray(e.enum))return this.convertEnum(e,e.enum,n,r);if(Array.isArray(e.anyOf))return this.convertUnion(e,e.anyOf,n,r);if(Array.isArray(e.oneOf))return this.convertUnion(e,e.oneOf,n,r);if(Array.isArray(e.allOf)){let i=r;for(let s of e.allOf)i=this.convert(s,n,i);return this.convertMembers(e,n,i)}switch(e.type){case"string":return j(tn(r),r);case"number":return j(qe(r),r);case"integer":{let i=qe(r);return i===void 0?r:Math.trunc(i.value)}case"boolean":return j(sn(r),r);case"null":return j(Qr(r),r);case"bigint":return j(rn(r),r);case"undefined":return j(Zr(r),r);case"array":return this.convertArray(e,n,r);case"object":return this.convertObject(e,n,r);case void 0:return e.properties!==void 0||e.patternProperties!==void 0?this.convertObject(e,n,r):e.items!==void 0||e.prefixItems!==void 0?this.convertArray(e,n,r):r;default:return r}}convertEnum(e,n,r,i){if(n.some(s=>s===i))return i;for(let s of n){let o=Qt(s,i);if(o!==i&&this.passes(e,r,o)===!0)return o}return i}convertUnion(e,n,r,i){if(n.some(s=>this.passes(s,r,i)===!0))return this.convertMembers(e,r,i);for(let s of n){let o=this.convertMembers(e,r,this.convert(s,r,i));if(this.passes(e,r,o)===!0)return o}return this.convertMembers(e,r,i)}convertMembers(e,n,r){return e.properties!==void 0||e.patternProperties!==void 0||e.additionalProperties!==void 0?this.convertObject(e,n,r):r}convertArray(e,n,r){let i=Array.isArray(e.items)?e.items:Array.isArray(e.prefixItems)?e.prefixItems:void 0;if(i!==void 0){if(!Array.isArray(r))return r;let o=Array.isArray(e.items)?void 0:e.items;return le(r,(f,c)=>{let a=c<i.length?i[c]:o;return a===void 0?f:this.convert(a,n,f)})}if(Array.isArray(r))return e.items===void 0?r:le(r,o=>this.convert(e.items,n,o));let s=e.items;return[h(s)?this.reenter(s,n,r,!1):r]}convertObject(e,n,r){if(!me(r))return r;let i=h(e.properties)?e.properties:{},s=h(e.patternProperties)?Object.entries(e.patternProperties).map(([c,a])=>[R(c),a]):[],o=h(e.additionalProperties)?e.additionalProperties:void 0,f;for(let c of Object.keys(r)){if(r[c]===void 0)continue;let a=r[c],d=Object.hasOwn(i,c);d&&(a=this.convert(i[c],n,a));for(let[u,p]of s)u.test(c)&&(d=!0,a=this.convert(p,n,a));!d&&o!==void 0&&(a=this.convert(o,n,a)),a!==r[c]&&(f??={...r},f[c]=a)}return f??r}coerceTypes(e,n,r){if(!h(n))return e;let i=this.baseOf(n,r),s=e;if(Array.isArray(n.allOf))for(let c of n.allOf)s=this.coerceTypes(s,c,i);Array.isArray(n.anyOf)&&(s=this.coerceUnion(s,n.anyOf,i)),Array.isArray(n.oneOf)&&(s=this.coerceUnion(s,n.oneOf,i));let o=vr(n),f=o.length>1&&o.some(c=>ei(s,c));if(o.length>0&&!f)for(let c of o){let a=ti(s,c);if(a!==s){s=a;break}}return o.includes("object")&&me(s)&&(s=this.coerceProperties(s,n,i)),o.includes("array")&&Array.isArray(s)&&(s=this.coerceItems(s,n,i)),s}coerceUnion(e,n,r){for(let i of n)if(this.passes(i,r,e)===!0)return e;for(let i of n){let s=this.coerceTypes(e,i,r);if(this.passes(i,r,s)===!0)return s}return e}coerceProperties(e,n,r){let i=h(n.properties)?n.properties:{},s=h(n.patternProperties)?Object.entries(n.patternProperties).map(([a,d])=>[R(a),d]):[],o=h(n.additionalProperties)?n.additionalProperties:void 0,f,c=(a,d)=>{d!==(f??e)[a]&&(f??={...e},f[a]=d)};for(let[a,d]of Object.entries(i))a in e&&c(a,this.coerceTypes(e[a],d,r));for(let a of Object.keys(e)){let d=Object.hasOwn(i,a);for(let[u,p]of s)u.test(a)&&(d=!0,c(a,this.coerceTypes((f??e)[a],p,r)));!d&&o!==void 0&&c(a,this.coerceTypes(e[a],o,r))}return f??e}coerceItems(e,n,r){return le(e,(i,s)=>{let o=Zt(n,s);return h(o)?this.coerceTypes(i,o,r):i})}};function Zt(t,e){return Array.isArray(t.items)?t.items[e]:Array.isArray(t.prefixItems)&&e<t.prefixItems.length?t.prefixItems[e]:t.items}function le(t,e){let n;for(let r=0;r<t.length;r++){let i=e(t[r],r);i!==t[r]&&(n??=t.slice(),n[r]=i)}return n??t}function j(t,e){return t===void 0?e:t.value}function Qt(t,e){if(t===e)return e;let n=typeof t=="string"?tn(e):typeof t=="number"?qe(e):typeof t=="boolean"?sn(e):typeof t=="bigint"?rn(e):void 0;return n!==void 0&&n.value===t?n.value:e}function tn(t){if(typeof t=="bigint"||typeof t=="boolean"||J(t))return{value:String(t)};if(t===null)return{value:"null"};if(typeof t=="string")return{value:t};if(t===void 0)return{value:""}}var vt=BigInt(Number.MAX_SAFE_INTEGER),en=BigInt(Number.MIN_SAFE_INTEGER);function qe(t){if(typeof t=="bigint")return t<=vt&&t>=en?{value:Number(t)}:void 0;if(typeof t=="boolean")return{value:t?1:0};if(J(t))return{value:t};if(t==null)return{value:0};if(typeof t!="string")return;let e=+t;if(Number.isFinite(e))return{value:e};let n=t.toLowerCase();if(n==="false")return{value:0};if(n==="true")return{value:1};let r=nn(t);return r!==void 0&&r<=vt&&r>=en?{value:Number(r)}:void 0}function nn(t){if(/^-?(0|[1-9]\d*)n$/.test(t))return BigInt(t.slice(0,-1));if(/^-?(0|[1-9]\d*)\.\d+$/.test(t))return BigInt(t.split(".")[0]);if(/^-?(0|[1-9]\d*)$/.test(t))return BigInt(t)}function rn(t){if(typeof t=="bigint")return{value:t};if(typeof t=="boolean")return{value:t?1n:0n};if(J(t))return{value:BigInt(Math.trunc(t))};if(t==null)return{value:0n};if(typeof t!="string")return;let e=nn(t);if(e!==void 0)return{value:e};let n=t.toLowerCase();return n==="false"?{value:0n}:n==="true"?{value:1n}:void 0}function Zr(t){if(t==null||t===0n||t===!1||t===0)return{value:void 0};if(typeof t!="string")return;let e=t.toLowerCase();return e==="undefined"||e==="null"||t===""||t==="0"?{value:void 0}:void 0}function sn(t){if(typeof t=="bigint")return t===0n?{value:!1}:t===1n?{value:!0}:void 0;if(typeof t=="boolean")return{value:t};if(J(t))return t===0?{value:!1}:t===1?{value:!0}:void 0;if(t==null)return{value:!1};if(typeof t!="string")return;let e=t.toLowerCase();if(e==="false"||t==="0")return{value:!1};if(e==="true"||t==="1")return{value:!0}}function Qr(t){if(typeof t=="bigint")return t===0n?{value:null}:void 0;if(typeof t=="boolean")return t===!1?{value:null}:void 0;if(J(t))return t===0?{value:null}:void 0;if(t==null)return{value:null};if(typeof t!="string")return;let e=t.toLowerCase();return e==="undefined"||e==="null"||t===""||t==="0"?{value:null}:void 0}function J(t){return typeof t=="number"&&Number.isFinite(t)}function vr(t){return typeof t.type=="string"?[t.type]:Array.isArray(t.type)?t.type.filter(e=>typeof e=="string"):[]}function ei(t,e){switch(e){case"number":return Number.isFinite(t);case"integer":return typeof t=="number"&&Number.isInteger(t);case"boolean":return typeof t=="boolean";case"string":return typeof t=="string";case"null":return t===null;case"bigint":return typeof t=="bigint";case"undefined":return t===void 0;case"array":return Array.isArray(t);case"object":return me(t);default:return!1}}function ti(t,e){switch(e){case"number":case"integer":{if(t===null)return 0;if(typeof t=="string"&&t.trim()!==""){let n=Number(t);if(e==="number"?Number.isFinite(n):Number.isInteger(n))return n}return typeof t=="boolean"?t?1:0:t}case"boolean":return t===null?!1:t==="true"||t===1?!0:t==="false"||t===0?!1:t;case"string":return t===null?"":typeof t=="number"||typeof t=="boolean"?String(t):t;case"null":return t===""||t===0||t===!1?null:t;default:return t}}function me(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function U(){return{props:null,allProps:!1,items:0,allItems:!1,indexes:null}}function Je(t,e){if(e.props!==null)for(let n of e.props)on(t,n);if(t.allProps||=e.allProps,e.items>t.items&&(t.items=e.items),t.allItems||=e.allItems,e.indexes!==null)for(let n of e.indexes)fn(t,n)}function on(t,e){t.props===null&&(t.props=new Set),t.props.add(e)}function fn(t,e){t.indexes===null&&(t.indexes=new Set),t.indexes.add(e)}var cn=()=>!0,an=()=>!1;function un(t){return(e,n)=>t.check(e,n)}function dn(t){return e=>t(e)}function pn(t){return e=>t(e,U())}function Ke(t,e,n){return(r,i)=>{t.push(e);let s=n(r,i);return t.pop(),s}}function hn(t){return(e,n)=>{let r=U();return t(e,r)?(Je(n,r),!0):!1}}function ln(t,e){return(n,r)=>{if(!t(n))return!1;for(let i=0;i<e.length;i++)if(!e[i](n,r))return!1;return!0}}function mn(t,e,n){let r=new Set(t.map(([i])=>i));return(i,s)=>{if(!b(i))return!0;let o=[];for(let[f,c]of t)if(Object.hasOwn(i,f)){if(!c(i[f]))return!1;o.push(f)}for(let f of Object.keys(i)){let c=r.has(f);for(let[a,d]of e)if(a.test(f)){if(!d(i[f]))return!1;c=!0,o.push(f)}if(!c&&n!==void 0){if(!n(i[f]))return!1;o.push(f)}}for(let f of o)on(s,f);return!0}}function yn(t,e,n,r,i){return(s,o)=>{if(!Array.isArray(s))return!0;let f=Math.min(s.length,t.length);for(let c=0;c<f;c++)if(!t[c](s[c]))return!1;if(e!==void 0){for(let c=t.length;c<s.length;c++)if(!e(s[c]))return!1;o.allItems=!0}if(f>o.items&&(o.items=f),n!==void 0){let c=0;for(let a=0;a<s.length;a++)n(s[a])&&(c++,fn(o,a));if(c<r||c>i)return!1}return!0}}function Xe(t,e){return(n,r)=>{let i=0;for(let s of t){let o=U();s(n,o)&&(i++,Je(r,o))}return e?i===1:i>0}}function gn(t,e,n){return(r,i)=>{let s=U();return t(r,s)?(Je(i,s),e===void 0||e(r,i)):n===void 0||n(r,i)}}function xn(t,e){return(n,r)=>!b(n)||!Object.hasOwn(n,t)||e(n,r)}function In(t){return(e,n)=>{if(!b(e)||n.allProps)return!0;for(let r of Object.keys(e))if(!(n.props?.has(r)??!1)&&!t(e[r]))return!1;return n.allProps=!0,!0}}function An(t){return(e,n)=>{if(!Array.isArray(e)||n.allItems)return!0;for(let r=n.items;r<e.length;r++)if(!(n.indexes?.has(r)??!1)&&!t(e[r]))return!1;return n.allItems=!0,!0}}var Ze=Symbol("restart"),X=class{r;draft;formats;dynamic;schema;scope;cache=new Map;annotatingCache=new Map;constructor(e,n,r){this.schema=e,this.r=new pe(e,n),this.draft=this.r.draft,this.formats=n.formats,this.dynamic=r,this.scope=[]}root(){return this.check(this.schema,this.r.rootBase)}check(e,n){if(e===!0)return S;if(e===!1)return H;if(!h(e))throw new Error(`A schema must be an object or a boolean, got ${JSON.stringify(e)}`);let r=this.cache.get(e);if(r!==void 0)return r;let i=this.bareType(e);if(i!==void 0)return i;let s={check:void 0};this.cache.set(e,Ct(s));let o=this.build(e,this.r.baseFor(e,n));return s.check=o,this.cache.set(e,o),o}build(e,n){if(this.draft==="7"&&typeof e.$ref=="string")return this.ref(e.$ref,n);if(this.draft!=="7"&&(e.unevaluatedProperties!==void 0||e.unevaluatedItems!==void 0))return pn(this.annotating(e,n));let r=this.plain(e,n);return this.dynamic&&this.r.isResource(e,n)?Be(this.scope,n,r):r}bareType(e){let n;for(let r in e)if(r==="type")n=e.type;else if(!bn.has(r))return;return n===void 0?S:typeof n=="string"?M.get(n):void 0}plain(e,n){let r=[],i=e.type===void 0?void 0:Array.isArray(e.type)?e.type:[e.type],s=i?.length===1?i[0]:void 0,o=!1;if(s==="bytes")r.push(Mt(O(e.minLength)??0,O(e.maxLength)??Number.POSITIVE_INFINITY)),o=!0;else{let f=this.stringGroup(e,s==="string");f!==void 0&&r.push(f);let c=s==="number"||s==="integer"||s==="bigint",a=s==="number"?1:s==="integer"?2:s==="bigint"?3:0,d=this.numberGroup(e,a);d!==void 0&&r.push(d);let u=this.objectGroup(e,n,s==="object");u!==void 0&&r.push(u);let p=this.arrayGroup(e,n,s==="array");p!==void 0&&r.push(p),o=s==="string"&&f!==void 0||c&&d!==void 0||s==="object"&&u!==void 0||s==="array"&&p!==void 0}return i!==void 0&&!o&&r.unshift(St(i)),this.inPlace(e,n,r),V(r)}inPlace(e,n,r){if(Array.isArray(e.enum)&&r.push(q(e.enum)),Object.hasOwn(e,"const")&&r.push(ue(e.const)),Array.isArray(e.allOf)&&r.push(V(e.allOf.map(i=>this.check(i,n)))),Array.isArray(e.anyOf)&&r.push(this.union(e.anyOf,n,!1)),Array.isArray(e.oneOf)&&r.push(this.union(e.oneOf,n,!0)),e.not!==void 0&&r.push(Jt(this.check(e.not,n))),e.if!==void 0&&(e.then!==void 0||e.else!==void 0)){let i=e.then===void 0?S:this.check(e.then,n),s=e.else===void 0?S:this.check(e.else,n);r.push(Kt(this.check(e.if,n),i,s))}typeof e.$ref=="string"&&r.push(this.ref(e.$ref,n)),this.draft!=="7"&&typeof e.$dynamicRef=="string"&&r.push(this.dynamicRef(e.$dynamicRef,n))}union(e,n,r){let i=()=>e.map(s=>this.check(s,n));return ii(e,r)??this.tagged(e,n)??(r?qt(i()):si(i()))}ref(e,n){let r=this.r.resolve(e,n),i=this.check(r.node,r.base);return this.dynamic&&r.base!==n?Be(this.scope,r.base,i):i}dynamicRef(e,n){let r=this.bookended(e,n);if(r===void 0)return this.ref(e,n);let{initial:i,name:s}=r,o=this.check(i.node,i.base),f=this.dynamicLookup(s,(a,d)=>this.check(a,d)),c=this.scope;return a=>{for(let d=0;d<c.length;d++){let u=f(c[d]);if(u!==null)return u(a)}return o(a)}}bookended(e,n){let r=this.r.resolve(e,n),i=w(e,n),s=i.slice(P(i).length+1),o=h(r.node)&&r.node.$dynamicAnchor===s;if(!(s===""||s.startsWith("/")||!o)){if(!this.dynamic)throw Ze;return{initial:r,name:s}}}dynamicLookup(e,n){let r=new Map;return i=>{let s=`${i}#${e}`,o=r.get(s);if(o===void 0){let f=this.r.dynamicAnchors.get(s);o=f===void 0?null:n(f,this.r.baseOf.get(f)??i),r.set(s,o)}return o}}tagged(e,n){if(e.length<2)return;let r=[];for(let s of e){if(!h(s))return;let o=typeof s.$ref=="string"&&Object.keys(s).length===1?s.$ref:void 0,f=o===void 0?s:this.r.resolve(o,this.r.baseFor(s,n)).node;if(!h(f))return;r.push(f)}let i=r[0].properties;if(h(i))for(let s of Object.keys(i)){let o=r.map(f=>fi(f,s));if(!(o.some(f=>f===void 0)||new Set(o).size!==o.length))return Xt(s,o,e.map(f=>this.check(f,n)))}}stringGroup(e,n){let r=O(e.minLength)??0,i=O(e.maxLength)??Number.POSITIVE_INFINITY,s=typeof e.pattern=="string"?R(e.pattern):void 0,o=this.formats!==void 0&&typeof e.format=="string"&&Object.hasOwn(this.formats,e.format)?this.formats[e.format]:void 0;if(!(r===0&&i===Number.POSITIVE_INFINITY&&s===void 0&&o===void 0))return Lt(n,r,i,s,o)}numberGroup(e,n){let r=K(e.minimum),i=K(e.maximum),s=K(e.exclusiveMinimum),o=K(e.exclusiveMaximum),f=K(e.multipleOf);if([r,i,s,o,f].every(a=>a===void 0))return;let c=Number.POSITIVE_INFINITY;return jt(n,r??-c,i??c,s??-c,o??c,f)}objectGroup(e,n,r){let i=ni.every(u=>e[u]===void 0),s=this.objectCore(e,n,i?r?De:L:Y);if(s!==void 0&&i)return s;let o=s===void 0?[]:[s];e.propertyNames!==void 0&&o.push(Bt(this.check(e.propertyNames,n)));let f=O(e.minProperties),c=O(e.maxProperties);(f!==void 0||c!==void 0)&&o.push(Gt(f??0,c??Number.POSITIVE_INFINITY));let a=[],d=[];if(this.draft!=="7"){for(let[u,p]of F(e.dependentRequired))Array.isArray(p)&&a.push([u,p]);for(let[u,p]of F(e.dependentSchemas))d.push([u,this.check(p,n)])}for(let[u,p]of F(e.dependencies))Array.isArray(p)?a.push([u,p]):d.push([u,this.check(p,n)]);return a.length>0&&o.push(Wt(a)),d.length>0&&o.push(Ht(d)),o.length===0?r?je:void 0:Ut(V(o),r)}objectCore(e,n,r){let i=h(e.properties)?e.properties:{},s=Array.isArray(e.required)?e.required.filter(y=>typeof y=="string"):[],o=h(e.patternProperties)?e.patternProperties:{},f=e.additionalProperties,c=Object.keys(i),a=Object.keys(o);if(c.length+s.length+a.length===0&&(f===void 0||f===!0))return;let d=[];for(let y of c){let N=this.check(i[y],n),z=Ue(N),we=(z?.[0]??0)|(s.includes(y)?$:0)|(y in Object.prototype?ze:0);d.push(y,z===void 0?N:z[1],we)}let u=s.filter(y=>!Object.hasOwn(i,y)),p=a.map(y=>[R(y),this.check(o[y],n)]),l=f===void 0||f===!0?void 0:this.check(f,n);if(p.length===0&&u.length===0&&(l===void 0||f===!1)){let y=c.filter(N=>s.includes(N)).length;return Dt(d,y,f===!1,r)}return zt(d,c,u,p,l,r)}arrayGroup(e,n,r){let i=[],s;Array.isArray(e.items)?(i=e.items,s=e.additionalItems):(this.draft!=="7"&&Array.isArray(e.prefixItems)&&(i=e.prefixItems),s=e.items);let o=i.map(u=>this.check(u,n)),f=s===void 0||s===!0?void 0:this.check(s,n),c=O(e.minItems),a=O(e.maxItems);if(e.contains===void 0&&e.uniqueItems!==!0&&(o.length>0||f!==void 0))return Ye(r?De:L,c??0,a??Number.POSITIVE_INFINITY,o,f);let d=[];if((o.length>0||f!==void 0)&&d.push(Yt(o,f)),(c!==void 0||a!==void 0)&&d.push(Vt(c??0,a??Number.POSITIVE_INFINITY)),e.contains!==void 0){let u=this.draft==="7"?1:O(e.minContains)??1,p=this.draft==="7"?Number.POSITIVE_INFINITY:O(e.maxContains)??Number.POSITIVE_INFINITY;d.push(ce(this.check(e.contains,n),u,p))}return e.uniqueItems===!0&&d.push(ae),d.length===0?r?Le:void 0:Ft(V(d),r)}annotating(e,n){if(e===!0)return cn;if(e===!1)return an;if(!h(e))throw new Error(`A schema must be an object or a boolean, got ${JSON.stringify(e)}`);let r=this.annotatingCache.get(e);if(r!==void 0)return r;let i={check:void 0};this.annotatingCache.set(e,un(i));let s=this.buildAnnotating(e,this.r.baseFor(e,n));return i.check=s,this.annotatingCache.set(e,s),s}buildAnnotating(e,n){let r={},i=!1;for(let a of Object.keys(e))ri.has(a)?i=!0:r[a]=e[a];let s=this.plain(r,n),o=[];i&&this.annotatingParts(e,n,o);let f=o.length===0?dn(s):ln(s,o),c=e.unevaluatedProperties!==void 0||e.unevaluatedItems!==void 0?hn(f):f;return this.dynamic&&this.r.isResource(e,n)?Ke(this.scope,n,c):c}annotatingParts(e,n,r){if(e.properties!==void 0||e.patternProperties!==void 0||e.additionalProperties!==void 0){let i=F(e.properties).map(([f,c])=>[f,this.check(c,n)]),s=F(e.patternProperties).map(([f,c])=>[R(f),this.check(c,n)]),o=e.additionalProperties===void 0?void 0:this.check(e.additionalProperties,n);r.push(mn(i,s,o))}if(e.prefixItems!==void 0||e.items!==void 0||e.contains!==void 0){let i=Array.isArray(e.prefixItems)?e.prefixItems:Array.isArray(e.items)?e.items:[],s=Array.isArray(e.items)?e.additionalItems:e.items;r.push(yn(i.map(o=>this.check(o,n)),s===void 0?void 0:this.check(s,n),e.contains===void 0?void 0:this.check(e.contains,n),O(e.minContains)??1,O(e.maxContains)??Number.POSITIVE_INFINITY))}if(Array.isArray(e.allOf))for(let i of e.allOf)r.push(this.annotating(i,n));if(Array.isArray(e.anyOf)&&r.push(Xe(e.anyOf.map(i=>this.annotating(i,n)),!1)),Array.isArray(e.oneOf)&&r.push(Xe(e.oneOf.map(i=>this.annotating(i,n)),!0)),e.if!==void 0){let i=e.then===void 0?void 0:this.annotating(e.then,n),s=e.else===void 0?void 0:this.annotating(e.else,n);r.push(gn(this.annotating(e.if,n),i,s))}typeof e.$ref=="string"&&r.push(this.annotatingRef(e.$ref,n)),typeof e.$dynamicRef=="string"&&r.push(this.annotatingDynamicRef(e.$dynamicRef,n));for(let[i,s]of F(e.dependentSchemas))r.push(xn(i,this.annotating(s,n)));e.unevaluatedProperties!==void 0&&r.push(In(this.check(e.unevaluatedProperties,n))),e.unevaluatedItems!==void 0&&r.push(An(this.check(e.unevaluatedItems,n)))}annotatingRef(e,n){let r=this.r.resolve(e,n),i=this.annotating(r.node,r.base);return this.dynamic&&r.base!==n?Ke(this.scope,r.base,i):i}annotatingDynamicRef(e,n){let r=this.bookended(e,n);if(r===void 0)return this.annotatingRef(e,n);let{initial:i,name:s}=r,o=this.annotating(i.node,i.base),f=this.dynamicLookup(s,(a,d)=>this.annotating(a,d)),c=this.scope;return(a,d)=>{for(let u=0;u<c.length;u++){let p=f(c[u]);if(p!==null)return p(a,d)}return o(a,d)}}},bn=new Set(["$schema","$comment","title","description","default","examples","deprecated","readOnly","writeOnly","$defs","definitions","contentEncoding","contentMediaType","minContains","maxContains","$vocabulary"]),ni=["propertyNames","minProperties","maxProperties","dependentRequired","dependentSchemas","dependencies"],ri=new Set(["properties","patternProperties","additionalProperties","prefixItems","items","additionalItems","contains","minContains","maxContains","allOf","anyOf","oneOf","if","then","else","$ref","$dynamicRef","dependentSchemas","unevaluatedProperties","unevaluatedItems"]);function ii(t,e){let n=[];for(let r of t){if(!h(r)||!Object.hasOwn(r,"const"))return;for(let i of Object.keys(r))if(i!=="const"&&!bn.has(i))return;if(typeof r.const=="object"&&r.const!==null||e&&n.includes(r.const))return;n.push(r.const)}return q(n)}function si(t){let e=[],n=[];for(let r of t){let i=oi.get(r);i===void 0?n.push(r):e.push(i)}return e.length===0?Ve(n):$t(Ge(e),n)}var oi=new Map([...M].map(([t,e])=>[e,t]));function fi(t,e){let n=t.properties;if(t.type!=="object"||!Array.isArray(t.required)||!t.required.includes(e))return;let r=h(n)?n[e]:void 0;if(!(!h(r)||!Object.hasOwn(r,"const")))return typeof r.const=="object"&&r.const!==null?void 0:r.const}function K(t){return typeof t=="number"||typeof t=="bigint"?t:void 0}function O(t){return typeof t=="number"?t:void 0}function F(t){return h(t)?Object.entries(t):[]}var ge=class{c;schema;memo=void 0;constructor(e,n){this.c=e,this.schema=n,e.root()}errors(e){let n=[];try{this.walk(this.schema,this.c.r.rootBase,e,"",n)}finally{this.memo=void 0}return n.length===0&&n.push({path:"",keyword:"schema",message:"invalid"}),n}ok(e,n,r){return this.c.check(e,n)(r)}walk(e,n,r,i,s){if(e===!0)return;if(e===!1){s.push({path:i,keyword:"false",message:"no value is allowed here"});return}if(!h(e))return;let o=this.c.r.baseFor(e,n);if(this.ok(e,o,r))return;let f=s.length,c=(a,d,u=i)=>{s.push({path:u,keyword:a,message:d})};if(this.c.draft==="7"&&typeof e.$ref=="string"){this.walkRef(e.$ref,o,r,i,s);return}if(e.type!==void 0){let a=Array.isArray(e.type)?e.type:[e.type];if(!a.map(u=>(typeof u=="string"?M.get(u):void 0)??H).some(u=>u(r))){c("type",`expected ${a.join(" or ")}, got ${ai(r)}`);return}}if(Array.isArray(e.enum)&&!q(e.enum)(r)&&c("enum",`expected one of ${En(e.enum)}`),Object.hasOwn(e,"const")&&!ue(e.const)(r)&&c("const",`expected ${JSON.stringify(e.const)}`),typeof r=="string"&&e.type!=="bytes"&&this.walkString(e,r,c),r instanceof Uint8Array&&e.type==="bytes"&&this.walkBytes(e,r,c),(typeof r=="number"||typeof r=="bigint")&&this.walkNumber(e,r,c),b(r)&&this.walkObject(e,o,r,i,s,c),Array.isArray(r)&&this.walkArray(e,o,r,i,s,c),Array.isArray(e.allOf))for(let a of e.allOf)this.walk(a,o,r,i,s);if(Array.isArray(e.anyOf)&&this.walkUnion(e.anyOf,o,r,i,s,!1),Array.isArray(e.oneOf)&&this.walkUnion(e.oneOf,o,r,i,s,!0),e.not!==void 0&&this.ok(e.not,o,r)&&c("not","must not match the schema in not"),e.if!==void 0){let a=this.ok(e.if,o,r)?e.then:e.else;a!==void 0&&this.walk(a,o,r,i,s)}typeof e.$ref=="string"&&this.walkRef(e.$ref,o,r,i,s),s.length===f&&(e.unevaluatedProperties!==void 0||e.unevaluatedItems!==void 0)&&this.walkUnevaluated(e,o,r,i,s),s.length===f&&typeof e.$dynamicRef=="string"&&c("$dynamicRef","does not match the dynamically referenced schema")}walkRef(e,n,r,i,s){let o=this.c.r.resolve(e,n);if(o.node===!1&&this.c.r.isUnresolved(e,n)){s.push({path:i,keyword:"$ref",message:`unresolved reference ${e}`});return}if(!h(o.node)||typeof r!="object"||r===null){this.walk(o.node,o.base,r,i,s);return}this.memo??=new Map;let f=this.memo.get(o.node),c=f?.get(r);if(c!==void 0&&c.path===i){s.push(...c.errors);return}let a=[];this.walk(o.node,o.base,r,i,a),f===void 0&&(f=new Map,this.memo.set(o.node,f)),f.set(r,{path:i,errors:a}),s.push(...a)}walkString(e,n,r){let i=fe(n);typeof e.minLength=="number"&&i<e.minLength&&r("minLength",`expected at least ${e.minLength} characters`),typeof e.maxLength=="number"&&i>e.maxLength&&r("maxLength",`expected at most ${e.maxLength} characters`),typeof e.pattern=="string"&&!R(e.pattern).test(n)&&r("pattern",`expected to match ${e.pattern}`);let s=this.c.formats,o=s!==void 0&&typeof e.format=="string"&&Object.hasOwn(s,e.format)?s[e.format]:void 0;o!==void 0&&!o(n)&&r("format",`expected format ${e.format}`)}walkBytes(e,n,r){typeof e.minLength=="number"&&n.length<e.minLength&&r("minLength",`expected at least ${e.minLength} bytes`),typeof e.maxLength=="number"&&n.length>e.maxLength&&r("maxLength",`expected at most ${e.maxLength} bytes`)}walkNumber(e,n,r){let{minimum:i,maximum:s,exclusiveMinimum:o,exclusiveMaximum:f,multipleOf:c}=e;Z(i)&&n<i&&r("minimum",`expected >= ${i}`),Z(s)&&n>s&&r("maximum",`expected <= ${s}`),Z(o)&&n<=o&&r("exclusiveMinimum",`expected > ${o}`),Z(f)&&n>=f&&r("exclusiveMaximum",`expected < ${f}`),Z(c)&&!He(n,c)&&r("multipleOf",`expected a multiple of ${c}`)}walkObject(e,n,r,i,s,o){let f=h(e.properties)?e.properties:{},c=Array.isArray(e.required)?e.required:[];for(let p of c){if(typeof p!="string")continue;let l=r[p]===void 0&&Object.hasOwn(f,p)&&this.ok(f[p],n,void 0);(!Object.hasOwn(r,p)||r[p]===void 0&&!l)&&o("required","missing",_(i,p))}for(let p of Object.keys(f))Object.hasOwn(r,p)&&r[p]!==void 0&&this.walk(f[p],n,r[p],_(i,p),s);let a=h(e.patternProperties)?Object.entries(e.patternProperties):[];for(let p of Object.keys(r)){let l=Object.hasOwn(f,p);for(let[y,N]of a)R(y).test(p)&&(l=!0,this.walk(N,n,r[p],_(i,p),s));!l&&e.additionalProperties!==void 0&&(e.additionalProperties===!1?o("additionalProperties","unknown field",_(i,p)):this.walk(e.additionalProperties,n,r[p],_(i,p),s)),e.propertyNames!==void 0&&!this.ok(e.propertyNames,n,p)&&o("propertyNames","invalid property name",_(i,p))}let d=Object.keys(r).length;typeof e.minProperties=="number"&&d<e.minProperties&&o("minProperties",`expected at least ${e.minProperties} properties`),typeof e.maxProperties=="number"&&d>e.maxProperties&&o("maxProperties",`expected at most ${e.maxProperties} properties`);let u={...this.c.draft==="7"||!h(e.dependentRequired)?{}:e.dependentRequired,...h(e.dependencies)?e.dependencies:{}};for(let[p,l]of Object.entries(u))if(Object.hasOwn(r,p))if(!Array.isArray(l))this.walk(l,n,r,i,s);else for(let y of l)Object.hasOwn(r,y)||o("dependentRequired",`required when ${p} is present`,_(i,y));if(this.c.draft!=="7"&&h(e.dependentSchemas))for(let[p,l]of Object.entries(e.dependentSchemas))Object.hasOwn(r,p)&&this.walk(l,n,r,i,s)}walkArray(e,n,r,i,s,o){let f=[],c;Array.isArray(e.items)?(f=e.items,c=e.additionalItems):(this.c.draft!=="7"&&Array.isArray(e.prefixItems)&&(f=e.prefixItems),c=e.items);for(let a=0;a<r.length;a++){let d=a<f.length?f[a]:c;d!==void 0&&this.walk(d,n,r[a],`${i}/${a}`,s)}if(typeof e.minItems=="number"&&r.length<e.minItems&&o("minItems",`expected at least ${e.minItems} items`),typeof e.maxItems=="number"&&r.length>e.maxItems&&o("maxItems",`expected at most ${e.maxItems} items`),e.uniqueItems===!0&&!ae(r)&&o("uniqueItems","expected unique items"),e.contains!==void 0){let a=this.c.draft==="7",d=a||typeof e.minContains!="number"?1:e.minContains,u=a||typeof e.maxContains!="number"?Number.POSITIVE_INFINITY:e.maxContains;ce(this.c.check(e.contains,n),d,u)(r)||o("contains",ci(d,u))}}walkUnion(e,n,r,i,s,o){let f=e.filter(u=>this.ok(u,n,r)).length;if(f===1||!o&&f>0)return;let c=o?"oneOf":"anyOf";if(f>1){s.push({path:i,keyword:c,message:"matches more than one alternative"});return}let a=this.tagOf(e,n);if(a!==void 0&&b(r)){let u=a.values.indexOf(r[a.key]);u<0?s.push({path:_(i,a.key),keyword:c,message:`expected one of ${En(a.values)}`}):this.walk(e[u],n,r,i,s);return}let d;for(let u of e){let p=[];if(this.walk(u,n,r,i,p),p.length===0)continue;let l=b(r)?this.declaredKeys(u,n,r):0;(d===void 0||l>d.declared||l===d.declared&&p[0].path.length>d.errors[0].path.length)&&(d={errors:p,declared:l})}s.push(...d?.errors??[{path:i,keyword:c,message:"matches no alternative"}])}declaredKeys(e,n,r){let i=h(e)&&typeof e.$ref=="string"?this.c.r.resolve(e.$ref,this.c.r.baseFor(e,n)).node:e,s=h(i)&&h(i.properties)?i.properties:{};return Object.keys(r).filter(o=>Object.hasOwn(s,o)).length}tagOf(e,n){let r=e.map(s=>h(s)&&typeof s.$ref=="string"?this.c.r.resolve(s.$ref,this.c.r.baseFor(s,n)).node:s),i=r[0];if(!(!h(i)||!h(i.properties)))for(let s of Object.keys(i.properties)){let o=r.map(c=>{let a=h(c)&&h(c.properties)?c.properties[s]:void 0;return h(a)?a.const:void 0});if(o.every(c=>c!==void 0&&(typeof c!="object"||c===null))&&new Set(o).size===o.length)return{key:s,values:o}}}walkUnevaluated(e,n,r,i,s){let{unevaluatedProperties:o,unevaluatedItems:f,$id:c,...a}=e,d=U();if(this.c.annotating(a,n)(r,d),b(r)&&o!==void 0&&!d.allProps)for(let u of Object.keys(r))d.props?.has(u)||(o===!1?s.push({path:_(i,u),keyword:"unevaluatedProperties",message:"unknown field"}):this.walk(o,n,r[u],_(i,u),s));if(Array.isArray(r)&&f!==void 0&&!d.allItems)for(let u=d.items;u<r.length;u++)d.indexes?.has(u)||(f===!1?s.push({path:`${i}/${u}`,keyword:"unevaluatedItems",message:"unexpected item"}):this.walk(f,n,r[u],`${i}/${u}`,s))}},Qe=20;function En(t){return t.length<=Qe?JSON.stringify(t):`${JSON.stringify(t.slice(0,Qe)).slice(0,-1)}, ... and ${t.length-Qe} more]`}function ci(t,e){return e===Number.POSITIVE_INFINITY?`expected at least ${t} matching ${t===1?"item":"items"}`:t===0?`expected at most ${e} matching ${e===1?"item":"items"}`:`expected between ${t} and ${e} matching items`}function Z(t){return typeof t=="number"||typeof t=="bigint"}function _(t,e){return`${t}/${String(e).replace(/~/g,"~0").replace(/\//g,"~1")}`}function ai(t){return t===null?"null":Array.isArray(t)?"array":t instanceof Uint8Array?"bytes":typeof t=="bigint"?"bigint":typeof t=="number"&&Number.isInteger(t)?"integer":typeof t=="number"&&!Number.isFinite(t)?String(t):typeof t}function ve(t,e=ui){let n=di(t,e);return e.coerce===!0?new xe(t,e,n):new Q(t,e,n)}var ui=Object.freeze({}),Q=class{check;schema;options;explainer=void 0;constructor(e,n,r){this.check=r,this.schema=e,this.options=n}errors(e){return this.check(e)?[]:(this.explainer??=new ge(et(this.schema,this.options),this.schema),this.explainer.errors(e))}validate(e){return this.check(e)?{ok:!0,value:e}:{ok:!1,errors:this.errors(e)}}},xe=class extends Q{coercer=void 0;coerce(e){return this.coercer??=new ye(et(this.schema,this.options),this.schema),this.coercer.coerce(e)}parse(e){return this.validate(this.coerce(e))}};function di(t,e){return et(t,e).root()}function et(t,e){let n=new X(t,e,!1);try{return n.root(),n}catch(r){if(r!==Ze)throw r;return new X(t,e,!0)}}var pi=[0,31,28,31,30,31,30,31,31,30,31,30,31],hi=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function li(t){return t%4===0&&(t%100!==0||t%400===0)}function Ie(t){let e=hi.exec(t);if(!e)return!1;let n=+e[1],r=+e[2],i=+e[3];return r>=1&&r<=12&&i>=1&&i<=(r===2&&li(n)?29:pi[r])}var mi=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;function Ae(t,e=!0){let n=mi.exec(t);if(!n||e&&!n[4]&&!n[5])return!1;let r=+n[1],i=+n[2],s=+n[3];if(r>23||i>59||s>60)return!1;if(n[5]){let d=+n[6],u=+n[7];if(d>23||u>59)return!1}if(s<60)return!0;let o=n[5]==="-"?-1:1,f=+(n[6]||0),c=+(n[7]||0);return((r*60+i-o*(f*60+c))%1440+1440)%1440===1439}function On(t){let e=t.split(/T/i);return e.length===2&&Ie(e[0])&&Ae(e[1])}var yi=/^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;function Rn(t){return yi.test(t)}var gi=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;function kn(t){return gi.test(t)}var _n=/^(?!-).*(?<!-)$/,Nn=/^(?!..--)/,wn=/^[a-zA-Z0-9-]*$/,bo=new RegExp("^\\p{ASCII}*$","u"),D=/[^\p{ASCII}]/u;var xi=/[0-9]/,Pn=/[\u{0660}-\u{0669}]/u,Ii=/[\u{06f0}-\u{06f9}]/u,Ai=/[\u{002e}\u{002c}\u{003a}\u{002f}]/u,bi=/[\u{002d}\u{002b}]/u,tt=new RegExp("\\p{Mn}","u"),Ei=new RegExp("\\p{Mc}","u"),Eo=new RegExp("\\p{Me}","u"),Cn=/[\p{Mn}\p{Mc}\p{Me}]/u,nt=new RegExp("\\p{L}","u"),Oi=new RegExp("\\p{Nd}","u"),Sn=new RegExp("\\p{Script=Greek}","u"),be=new RegExp("\\p{Script=Hebrew}","u"),Tn=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,$n=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,rt=/[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u,Mn=/[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u,Ri=/[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u,ki=/[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u,Ln=new RegExp([xi,Ii].map(t=>t.source).join("|"),"u"),jn=new RegExp([nt,bi,Ai,Oi,tt,Ei,Ri,ki].map(t=>t.source).join("|"),"u");function Un(t){return _n.test(t)&&Nn.test(t)&&wn.test(t)}var k=36,ee=1,te=26,Ni=38,wi=700,Dn=72,zn=128;function it(){throw null}function Ee(t){return t.toLowerCase().startsWith("xn--")}function Bn(t,e,n){t=n?Math.floor(t/wi):t>>1,t+=Math.floor(t/e);let r=0;for(;t>(k-ee)*te>>1;)t=Math.floor(t/(k-ee)),r+=k;return r+Math.floor((k-ee+1)*t/(t+Ni))}function Oe(t){let e=[],n=zn,r=0,i=Dn,s=t.lastIndexOf("-");if(s>0)for(let f=0;f<s;f++){let c=t.charCodeAt(f);c>=128&&it(),e.push(c)}let o=s<0?0:s+1;for(;o<t.length;){let f=r,c=1,a=k;for(;;){o>=t.length&&it();let u=t.charCodeAt(o++),p;u>=97&&u<=122?p=u-97:u>=48&&u<=57?p=u-48+26:it(),r+=p*c;let l=a<=i?ee:a>=i+te?te:a-i;if(p<l)break;c*=k-l,a+=k}let d=e.length+1;i=Bn(r-f,d,f===0),n+=Math.floor(r/d),r%=d,e.splice(r,0,n),r++}return String.fromCodePoint(...e)}function Fn(t){return t<26?String.fromCharCode(t+97):String.fromCharCode(t-26+48)}var Pi=new RegExp(D.source,"gu");function Gn(t){let e=t.replace(Pi,""),n=e.length,r=n>0?[e,"-"]:[],i=Array.from(t,a=>a.codePointAt(0)),s=zn,o=0,f=Dn,c=n;for(;c<i.length;){let a=1/0;for(let d of i)d>=s&&d<a&&(a=d);o+=(a-s)*(c+1),s=a;for(let d of i)if(d<s&&o++,d===s){let u=o;for(let p=k;;p+=k){let l=p<=f?ee:p>=f+te?te:p-f;if(u<l)break;let y=l+(u-l)%(k-l);r.push(Fn(y)),u=Math.floor((u-l)/(k-l))}r.push(Fn(u)),f=Bn(o,c+1,c===n),o=0,c++}o++,s++}return r.join("")}var Ci=/^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/,Wn=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,Si=/^(?:R|AL|AN)$/;function Hn(t){if(Ee(t))try{return Re(Oe(t.slice(4).toLowerCase()))}catch{return!1}return Re(t)}function Yn(t){let e=String.fromCodePoint(t);return Ln.test(e)?"EN":Pn.test(e)?"AN":tt.test(e)?"NSM":be.test(e)?"R":$n.test(e)?"AL":nt.test(e)?"L":"ON"}function Re(t){for(let e of t)if(Si.test(Yn(e.codePointAt(0))))return!0;return!1}function ke(t){let e=!1,n=Wn,r=!1,i=!1,s=!0;for(let o of t){let f=Yn(o.codePointAt(0));if(s){if(f!=="L"&&f!=="R"&&f!=="AL")return!1;e=f==="R"||f==="AL",n=e?Ci:Wn,s=!1}if(!n.test(f))return!1;f==="EN"?r=!0:f==="AN"&&(i=!0)}return!(e&&r&&i)}function Ti(t){return D.test(t)&&Gn(t).length+4>63}function $i(t){return t[0]==="-"||t[t.length-1]==="-"?!0:t.slice(2).join("").startsWith("--")}function _e(t){if(Ti(t)||Re(t)&&!ke(t))return!1;let e=[...t],n=e.map(s=>s.codePointAt(0)),r=n.length;if($i(e)||Cn.test(e[0]))return!1;let i=!1;for(let s=0;s<r;s++){let o=n[s],f=e[s];if(Mn.test(f)||!jn.test(f))return!1;Tn.test(f)&&(i=!0);let c=n[s-1],a=n[s+1];switch(o){case 183:if(c!==108||a!==108)return!1;break;case 885:if(!a||!Sn.test(e[s+1]))return!1;break;case 1523:case 1524:if(!c||!be.test(e[s-1]))return!1;break;case 8204:if(!c||c<128&&!rt.test(e[s-1]))return!1;break;case 8205:if(!c||!rt.test(e[s-1]))return!1;break;case 12539:break}}return!(t.includes("\u30FB")&&!i)}function Ne(t){if(!Ee(t))return!1;try{let e=t.slice(4).toLowerCase();if(e.lastIndexOf("-")===0)return!1;let n=Oe(e);return D.test(n)?_e(n):!1}catch{return!1}}function Mi(t){return t.length>0&&t.length<=63}function Li(t){return Mi(t)&&(Ne(t)||Un(t))}function Kn(t){return t.length===0||t.length>253||t.charCodeAt(t.length-1)===46?!1:t.split(".").every(e=>Li(e))}function ji(t){return t.length>0&&t.length<=63}function Ui(t){return ji(t)&&(Ne(t)||_e(t))}function Fi(t){return t.replace(/[\uff01-\uff5e]/g,e=>String.fromCharCode(e.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}function Xn(t){if(t.length===0||t.includes(" "))return!1;let e=Fi(t);if(e.length>253)return!1;let n=e.split("."),r=n.some(i=>Hn(i));return n.every(i=>Ui(i)&&(!r||ke(i)))}function Zn(t){return Kn(t)}var zi=/^(?:[A-Za-z0-9!#$%&'*+/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;function Qn(t){return zi.test(t.normalize("NFC"))}function vn(t){return Xn(t)}var Bi=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function er(t){return Bi.test(t)}var Gi=/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;function tr(t){return Gi.test(t)}var Wi=/\[[vV][0-9a-fA-F]+\.[^\]]+\]/,Hi=/[\x00-\x20<>^`{|}\\]/,Yi=/%(?![0-9a-fA-F]{2})/;function Vi(t){return t.length<2048?t.replace(Wi,"[::1]"):t}function nr(t){return Hi.test(t)||Yi.test(t)?!1:URL.canParse(Vi(t))}var qi=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,Ji=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function rr(t){return!qi.test(t)&&!Ji.test(t)&&URL.canParse(t,"http://example.com")}var Ki=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function ir(t){return Ki.test(t)}var Xi=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function sr(t){return Xi.test(t)}function or(t){try{return new RegExp(t,"u"),!0}catch{return!1}}var Zi=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function fr(t){return Zi.test(t)}var Qi=/^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function cr(t){return Qi.test(t)}var vi=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function ar(t){return vi.test(t)}var es=/^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;function ur(t){return es.test(t)}function dr(t){return URL.canParse(t)}var ts=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function pr(t){return ts.test(t)}var hr=Object.freeze({date:Ie,"date-time":On,duration:Rn,email:kn,hostname:Zn,"idn-email":Qn,"idn-hostname":vn,ipv4:er,ipv6:tr,iri:nr,"iri-reference":rr,"json-pointer":ir,"json-pointer-uri-fragment":sr,regex:or,"relative-json-pointer":fr,time:Ae,uri:cr,"uri-reference":ar,"uri-template":ur,url:dr,uuid:pr});var lr=new WeakMap;function ns(t){let e=lr.get(t);if(e)return e;let n=ve(t,{formats:hr,coerce:!0,unresolvedRefs:"reject"});return lr.set(t,n),n}function rs(t){return t===""?"root":t.slice(1).split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~")).join(".")}function pf(t,e){let n=t.find(r=>r.name===e.name);if(!n)throw new Error(`Tool "${e.name}" not found`);return is(n,e)}function is(t,e){if(e.argumentsError)throw new Error(`Invalid arguments for tool "${e.name}": ${e.argumentsError}`);let n=ns(t.parameters).parse(structuredClone(e.arguments));if(n.ok)return n.value;let r=n.errors.map(s=>` - ${rs(s.path)}: ${s.message}`).join(`
13
+ `),i=`Validation failed for tool "${e.name}":
14
+ ${r}
15
+
16
+ Received arguments:
17
+ ${JSON.stringify(e.arguments,null,2)}`;throw new Error(i)}export{os as a,fs as b,ds as c,ps as d,gr as e,xr as f,hs as g,ls as h,ms as i,ys as j,gs as k,Er as l,Os as m,Rs as n,ks as o,Pr as p,_s as q,ws as r,Ps as s,Cs as t,Tr as u,$r as v,Mr as w,Lr as x,jr as y,Ur as z,Fr as A,Dr as B,zr as C,Br as D,pf as E,is as F};