@shivaedev/work-board 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (989) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +11 -11
  3. package/assets/agent.js +27 -31
  4. package/assets/native.js +34 -69
  5. package/assets/react.css +1 -1
  6. package/assets/react.js +39 -34
  7. package/dist/browser/diagnostics/schema.d.ts +49 -0
  8. package/dist/browser/diagnostics/schema.d.ts.map +1 -0
  9. package/dist/browser/diagnostics/schema.js +11 -0
  10. package/dist/browser/diagnostics/schema.js.map +1 -0
  11. package/dist/browser/views/ResultProjection.d.ts +245 -0
  12. package/dist/browser/views/ResultProjection.d.ts.map +1 -0
  13. package/dist/browser/views/ResultProjection.js +32 -0
  14. package/dist/browser/views/ResultProjection.js.map +1 -0
  15. package/dist/browser/views/remaining.d.ts +345 -0
  16. package/dist/browser/views/remaining.d.ts.map +1 -0
  17. package/dist/browser/views/remaining.js +21 -0
  18. package/dist/browser/views/remaining.js.map +1 -0
  19. package/dist/browser/views/schema.d.ts +715 -0
  20. package/dist/browser/views/schema.d.ts.map +1 -0
  21. package/dist/browser/views/schema.js +60 -0
  22. package/dist/browser/views/schema.js.map +1 -0
  23. package/dist/browser/views/state.d.ts +15 -0
  24. package/dist/browser/views/state.d.ts.map +1 -0
  25. package/dist/browser/views/state.js +45 -0
  26. package/dist/browser/views/state.js.map +1 -0
  27. package/dist/client/client.d.ts +5 -5
  28. package/dist/client/client.d.ts.map +1 -1
  29. package/dist/client/client.js +4 -4
  30. package/dist/client/client.js.map +1 -1
  31. package/dist/client/document/Mermaid.d.ts.map +1 -1
  32. package/dist/client/document/Mermaid.js +39 -10
  33. package/dist/client/document/Mermaid.js.map +1 -1
  34. package/dist/client/document/View.d.ts +5 -1
  35. package/dist/client/document/View.d.ts.map +1 -1
  36. package/dist/client/document/View.js +13 -1
  37. package/dist/client/document/View.js.map +1 -1
  38. package/dist/client/document/boardLayout.d.ts +6 -0
  39. package/dist/client/document/boardLayout.d.ts.map +1 -0
  40. package/dist/client/document/boardLayout.js +69 -0
  41. package/dist/client/document/boardLayout.js.map +1 -0
  42. package/dist/client/entry.d.ts +0 -12
  43. package/dist/client/entry.d.ts.map +1 -1
  44. package/dist/client/entry.js +0 -18
  45. package/dist/client/entry.js.map +1 -1
  46. package/dist/client/formDraft.d.ts +3 -0
  47. package/dist/client/formDraft.d.ts.map +1 -0
  48. package/dist/client/formDraft.js +8 -0
  49. package/dist/client/formDraft.js.map +1 -0
  50. package/dist/client/formFocus.d.ts.map +1 -1
  51. package/dist/client/formFocus.js +5 -0
  52. package/dist/client/formFocus.js.map +1 -1
  53. package/dist/client/handoffs/failureStatus.d.ts +2 -0
  54. package/dist/client/handoffs/failureStatus.d.ts.map +1 -0
  55. package/dist/client/handoffs/failureStatus.js +7 -0
  56. package/dist/client/handoffs/failureStatus.js.map +1 -0
  57. package/dist/client/page/routeQuery.d.ts +2 -7
  58. package/dist/client/page/routeQuery.d.ts.map +1 -1
  59. package/dist/client/page/routeQuery.js +0 -3
  60. package/dist/client/page/routeQuery.js.map +1 -1
  61. package/dist/client/react/Age.d.ts +9 -0
  62. package/dist/client/react/Age.d.ts.map +1 -0
  63. package/dist/client/react/Age.js +32 -0
  64. package/dist/client/react/Age.js.map +1 -0
  65. package/dist/client/react/AnswerForm.d.ts +5 -3
  66. package/dist/client/react/AnswerForm.d.ts.map +1 -1
  67. package/dist/client/react/AnswerForm.js +21 -11
  68. package/dist/client/react/AnswerForm.js.map +1 -1
  69. package/dist/client/react/AnswerPrompts.d.ts +10 -2
  70. package/dist/client/react/AnswerPrompts.d.ts.map +1 -1
  71. package/dist/client/react/AnswerPrompts.js +28 -12
  72. package/dist/client/react/AnswerPrompts.js.map +1 -1
  73. package/dist/client/react/BoardMain.d.ts +10 -0
  74. package/dist/client/react/BoardMain.d.ts.map +1 -0
  75. package/dist/client/react/BoardMain.js +19 -0
  76. package/dist/client/react/BoardMain.js.map +1 -0
  77. package/dist/client/react/BoardShell.d.ts +6 -1
  78. package/dist/client/react/BoardShell.d.ts.map +1 -1
  79. package/dist/client/react/BoardShell.js +34 -12
  80. package/dist/client/react/BoardShell.js.map +1 -1
  81. package/dist/client/react/ChangesMain.d.ts +8 -0
  82. package/dist/client/react/ChangesMain.d.ts.map +1 -0
  83. package/dist/client/react/ChangesMain.js +24 -0
  84. package/dist/client/react/ChangesMain.js.map +1 -0
  85. package/dist/client/react/DiagnosticsFleet.d.ts +6 -0
  86. package/dist/client/react/DiagnosticsFleet.d.ts.map +1 -0
  87. package/dist/client/react/DiagnosticsFleet.js +16 -0
  88. package/dist/client/react/DiagnosticsFleet.js.map +1 -0
  89. package/dist/client/react/DiagnosticsMain.d.ts +8 -0
  90. package/dist/client/react/DiagnosticsMain.d.ts.map +1 -0
  91. package/dist/client/react/DiagnosticsMain.js +11 -0
  92. package/dist/client/react/DiagnosticsMain.js.map +1 -0
  93. package/dist/client/react/DiagnosticsPage.d.ts +5 -0
  94. package/dist/client/react/DiagnosticsPage.d.ts.map +1 -0
  95. package/dist/client/react/DiagnosticsPage.js +23 -0
  96. package/dist/client/react/DiagnosticsPage.js.map +1 -0
  97. package/dist/client/react/DocumentContext.d.ts.map +1 -1
  98. package/dist/client/react/DocumentContext.js +23 -3
  99. package/dist/client/react/DocumentContext.js.map +1 -1
  100. package/dist/client/react/DocumentMain.d.ts +2 -3
  101. package/dist/client/react/DocumentMain.d.ts.map +1 -1
  102. package/dist/client/react/DocumentMain.js +8 -4
  103. package/dist/client/react/DocumentMain.js.map +1 -1
  104. package/dist/client/react/Favorite.d.ts +5 -0
  105. package/dist/client/react/Favorite.d.ts.map +1 -0
  106. package/dist/client/react/Favorite.js +10 -0
  107. package/dist/client/react/Favorite.js.map +1 -0
  108. package/dist/client/react/FormField.d.ts +13 -0
  109. package/dist/client/react/FormField.d.ts.map +1 -0
  110. package/dist/client/react/FormField.js +39 -0
  111. package/dist/client/react/FormField.js.map +1 -0
  112. package/dist/client/react/HandoffForm.d.ts +5 -0
  113. package/dist/client/react/HandoffForm.d.ts.map +1 -0
  114. package/dist/client/react/HandoffForm.js +27 -0
  115. package/dist/client/react/HandoffForm.js.map +1 -0
  116. package/dist/client/react/HandoffPage.d.ts +5 -0
  117. package/dist/client/react/HandoffPage.d.ts.map +1 -0
  118. package/dist/client/react/HandoffPage.js +15 -0
  119. package/dist/client/react/HandoffPage.js.map +1 -0
  120. package/dist/client/react/HandoffPrompt.d.ts +6 -0
  121. package/dist/client/react/HandoffPrompt.d.ts.map +1 -0
  122. package/dist/client/react/HandoffPrompt.js +21 -0
  123. package/dist/client/react/HandoffPrompt.js.map +1 -0
  124. package/dist/client/react/Header.d.ts +11 -2
  125. package/dist/client/react/Header.d.ts.map +1 -1
  126. package/dist/client/react/Header.js +2 -2
  127. package/dist/client/react/Header.js.map +1 -1
  128. package/dist/client/react/HistoryComparison.d.ts +5 -0
  129. package/dist/client/react/HistoryComparison.d.ts.map +1 -0
  130. package/dist/client/react/HistoryComparison.js +14 -0
  131. package/dist/client/react/HistoryComparison.js.map +1 -0
  132. package/dist/client/react/HistoryRetention.d.ts +5 -0
  133. package/dist/client/react/HistoryRetention.d.ts.map +1 -0
  134. package/dist/client/react/HistoryRetention.js +28 -0
  135. package/dist/client/react/HistoryRetention.js.map +1 -0
  136. package/dist/client/react/HomeBoard.d.ts +5 -0
  137. package/dist/client/react/HomeBoard.d.ts.map +1 -0
  138. package/dist/client/react/HomeBoard.js +8 -0
  139. package/dist/client/react/HomeBoard.js.map +1 -0
  140. package/dist/client/react/InboxPage.d.ts +5 -0
  141. package/dist/client/react/InboxPage.d.ts.map +1 -0
  142. package/dist/client/react/InboxPage.js +18 -0
  143. package/dist/client/react/InboxPage.js.map +1 -0
  144. package/dist/client/react/LiveControls.d.ts +8 -0
  145. package/dist/client/react/LiveControls.d.ts.map +1 -0
  146. package/dist/client/react/LiveControls.js +51 -0
  147. package/dist/client/react/LiveControls.js.map +1 -0
  148. package/dist/client/react/Modal.d.ts +12 -0
  149. package/dist/client/react/Modal.d.ts.map +1 -0
  150. package/dist/client/react/Modal.js +62 -0
  151. package/dist/client/react/Modal.js.map +1 -0
  152. package/dist/client/react/NavigationTree.d.ts.map +1 -1
  153. package/dist/client/react/NavigationTree.js +2 -1
  154. package/dist/client/react/NavigationTree.js.map +1 -1
  155. package/dist/client/react/OverviewGroups.d.ts +5 -0
  156. package/dist/client/react/OverviewGroups.d.ts.map +1 -0
  157. package/dist/client/react/OverviewGroups.js +18 -0
  158. package/dist/client/react/OverviewGroups.js.map +1 -0
  159. package/dist/client/react/OverviewPage.d.ts +5 -0
  160. package/dist/client/react/OverviewPage.d.ts.map +1 -0
  161. package/dist/client/react/OverviewPage.js +16 -0
  162. package/dist/client/react/OverviewPage.js.map +1 -0
  163. package/dist/client/react/ProjectionFrame.d.ts +19 -0
  164. package/dist/client/react/ProjectionFrame.d.ts.map +1 -0
  165. package/dist/client/react/ProjectionFrame.js +85 -0
  166. package/dist/client/react/ProjectionFrame.js.map +1 -0
  167. package/dist/client/react/ProjectionMain.d.ts +10 -0
  168. package/dist/client/react/ProjectionMain.d.ts.map +1 -0
  169. package/dist/client/react/ProjectionMain.js +22 -0
  170. package/dist/client/react/ProjectionMain.js.map +1 -0
  171. package/dist/client/react/PromptOption.d.ts +12 -0
  172. package/dist/client/react/PromptOption.d.ts.map +1 -0
  173. package/dist/client/react/PromptOption.js +9 -0
  174. package/dist/client/react/PromptOption.js.map +1 -0
  175. package/dist/client/react/ReadingLibrary.d.ts +9 -0
  176. package/dist/client/react/ReadingLibrary.d.ts.map +1 -0
  177. package/dist/client/react/ReadingLibrary.js +78 -0
  178. package/dist/client/react/ReadingLibrary.js.map +1 -0
  179. package/dist/client/react/RemainingMain.d.ts +10 -0
  180. package/dist/client/react/RemainingMain.d.ts.map +1 -0
  181. package/dist/client/react/RemainingMain.js +27 -0
  182. package/dist/client/react/RemainingMain.js.map +1 -0
  183. package/dist/client/react/RespondPage.d.ts +5 -0
  184. package/dist/client/react/RespondPage.d.ts.map +1 -0
  185. package/dist/client/react/RespondPage.js +16 -0
  186. package/dist/client/react/RespondPage.js.map +1 -0
  187. package/dist/client/react/ResponseMarkdown.d.ts.map +1 -1
  188. package/dist/client/react/ResponseMarkdown.js +16 -2
  189. package/dist/client/react/ResponseMarkdown.js.map +1 -1
  190. package/dist/client/react/ResultCriteria.d.ts +5 -0
  191. package/dist/client/react/ResultCriteria.d.ts.map +1 -0
  192. package/dist/client/react/ResultCriteria.js +33 -0
  193. package/dist/client/react/ResultCriteria.js.map +1 -0
  194. package/dist/client/react/ResultFeedback.d.ts +5 -0
  195. package/dist/client/react/ResultFeedback.d.ts.map +1 -0
  196. package/dist/client/react/ResultFeedback.js +12 -0
  197. package/dist/client/react/ResultFeedback.js.map +1 -0
  198. package/dist/client/react/ResultPage.d.ts +5 -0
  199. package/dist/client/react/ResultPage.d.ts.map +1 -0
  200. package/dist/client/react/ResultPage.js +15 -0
  201. package/dist/client/react/ResultPage.js.map +1 -0
  202. package/dist/client/react/SavedViews.d.ts +4 -0
  203. package/dist/client/react/SavedViews.d.ts.map +1 -0
  204. package/dist/client/react/SavedViews.js +16 -0
  205. package/dist/client/react/SavedViews.js.map +1 -0
  206. package/dist/client/react/SearchDialog.d.ts +11 -0
  207. package/dist/client/react/SearchDialog.d.ts.map +1 -0
  208. package/dist/client/react/SearchDialog.js +67 -0
  209. package/dist/client/react/SearchDialog.js.map +1 -0
  210. package/dist/client/react/SearchResults.d.ts +7 -0
  211. package/dist/client/react/SearchResults.d.ts.map +1 -0
  212. package/dist/client/react/SearchResults.js +19 -0
  213. package/dist/client/react/SearchResults.js.map +1 -0
  214. package/dist/client/react/ShellApi.d.ts +11 -1
  215. package/dist/client/react/ShellApi.d.ts.map +1 -1
  216. package/dist/client/react/Sidebar.d.ts +5 -2
  217. package/dist/client/react/Sidebar.d.ts.map +1 -1
  218. package/dist/client/react/Sidebar.js +37 -2
  219. package/dist/client/react/Sidebar.js.map +1 -1
  220. package/dist/client/react/StartPage.d.ts +5 -0
  221. package/dist/client/react/StartPage.d.ts.map +1 -0
  222. package/dist/client/react/StartPage.js +5 -0
  223. package/dist/client/react/StartPage.js.map +1 -0
  224. package/dist/client/react/UpdatesToggle.d.ts +5 -0
  225. package/dist/client/react/UpdatesToggle.d.ts.map +1 -0
  226. package/dist/client/react/UpdatesToggle.js +9 -0
  227. package/dist/client/react/UpdatesToggle.js.map +1 -0
  228. package/dist/client/react/VisualControls.d.ts +17 -0
  229. package/dist/client/react/VisualControls.d.ts.map +1 -0
  230. package/dist/client/react/VisualControls.js +6 -0
  231. package/dist/client/react/VisualControls.js.map +1 -0
  232. package/dist/client/react/VisualInspection.d.ts +2 -0
  233. package/dist/client/react/VisualInspection.d.ts.map +1 -0
  234. package/dist/client/react/VisualInspection.js +26 -0
  235. package/dist/client/react/VisualInspection.js.map +1 -0
  236. package/dist/client/react/VisualViewer.d.ts +6 -0
  237. package/dist/client/react/VisualViewer.d.ts.map +1 -0
  238. package/dist/client/react/VisualViewer.js +106 -0
  239. package/dist/client/react/VisualViewer.js.map +1 -0
  240. package/dist/client/react/WorkCards.d.ts +5 -0
  241. package/dist/client/react/WorkCards.d.ts.map +1 -0
  242. package/dist/client/react/WorkCards.js +13 -0
  243. package/dist/client/react/WorkCards.js.map +1 -0
  244. package/dist/client/react/WorkControls.d.ts +5 -0
  245. package/dist/client/react/WorkControls.d.ts.map +1 -0
  246. package/dist/client/react/WorkControls.js +18 -0
  247. package/dist/client/react/WorkControls.js.map +1 -0
  248. package/dist/client/react/WorkDetail.d.ts +5 -0
  249. package/dist/client/react/WorkDetail.d.ts.map +1 -0
  250. package/dist/client/react/WorkDetail.js +12 -0
  251. package/dist/client/react/WorkDetail.js.map +1 -0
  252. package/dist/client/react/WorkItemTitle.d.ts +7 -0
  253. package/dist/client/react/WorkItemTitle.d.ts.map +1 -0
  254. package/dist/client/react/WorkItemTitle.js +6 -0
  255. package/dist/client/react/WorkItemTitle.js.map +1 -0
  256. package/dist/client/react/WorkPage.d.ts +5 -0
  257. package/dist/client/react/WorkPage.d.ts.map +1 -0
  258. package/dist/client/react/WorkPage.js +17 -0
  259. package/dist/client/react/WorkPage.js.map +1 -0
  260. package/dist/client/react/WorkResults.d.ts +5 -0
  261. package/dist/client/react/WorkResults.d.ts.map +1 -0
  262. package/dist/client/react/WorkResults.js +10 -0
  263. package/dist/client/react/WorkResults.js.map +1 -0
  264. package/dist/client/react/WorkTable.d.ts +5 -0
  265. package/dist/client/react/WorkTable.d.ts.map +1 -0
  266. package/dist/client/react/WorkTable.js +10 -0
  267. package/dist/client/react/WorkTable.js.map +1 -0
  268. package/dist/client/react/WorkTools.d.ts +5 -0
  269. package/dist/client/react/WorkTools.d.ts.map +1 -0
  270. package/dist/client/react/WorkTools.js +7 -0
  271. package/dist/client/react/WorkTools.js.map +1 -0
  272. package/dist/client/react/activeRead.d.ts +7 -0
  273. package/dist/client/react/activeRead.d.ts.map +1 -0
  274. package/dist/client/react/activeRead.js +13 -0
  275. package/dist/client/react/activeRead.js.map +1 -0
  276. package/dist/client/react/createResponse.d.ts +26 -0
  277. package/dist/client/react/createResponse.d.ts.map +1 -0
  278. package/dist/client/react/createResponse.js +29 -0
  279. package/dist/client/react/createResponse.js.map +1 -0
  280. package/dist/client/react/diagnosticsValues.d.ts +13 -0
  281. package/dist/client/react/diagnosticsValues.d.ts.map +1 -0
  282. package/dist/client/react/diagnosticsValues.js +49 -0
  283. package/dist/client/react/diagnosticsValues.js.map +1 -0
  284. package/dist/client/react/entry.js +6 -18
  285. package/dist/client/react/entry.js.map +1 -1
  286. package/dist/client/react/historyStore.d.ts +7 -0
  287. package/dist/client/react/historyStore.d.ts.map +1 -0
  288. package/dist/client/react/historyStore.js +61 -0
  289. package/dist/client/react/historyStore.js.map +1 -0
  290. package/dist/client/react/liveStatus.d.ts +16 -0
  291. package/dist/client/react/liveStatus.d.ts.map +1 -0
  292. package/dist/client/react/liveStatus.js +43 -0
  293. package/dist/client/react/liveStatus.js.map +1 -0
  294. package/dist/client/react/loadBoardPage.d.ts +1 -1
  295. package/dist/client/react/loadBoardPage.d.ts.map +1 -1
  296. package/dist/client/react/loadBoardPage.js +14 -4
  297. package/dist/client/react/loadBoardPage.js.map +1 -1
  298. package/dist/client/react/loadProjection.d.ts +674 -0
  299. package/dist/client/react/loadProjection.d.ts.map +1 -0
  300. package/dist/client/react/loadProjection.js +15 -0
  301. package/dist/client/react/loadProjection.js.map +1 -0
  302. package/dist/client/react/loadRemaining.d.ts +577 -0
  303. package/dist/client/react/loadRemaining.d.ts.map +1 -0
  304. package/dist/client/react/loadRemaining.js +19 -0
  305. package/dist/client/react/loadRemaining.js.map +1 -0
  306. package/dist/client/react/mainLocation.d.ts +6 -0
  307. package/dist/client/react/mainLocation.d.ts.map +1 -0
  308. package/dist/client/react/mainLocation.js +9 -0
  309. package/dist/client/react/mainLocation.js.map +1 -0
  310. package/dist/client/react/navigationLocation.d.ts +33 -0
  311. package/dist/client/react/navigationLocation.d.ts.map +1 -0
  312. package/dist/client/react/navigationLocation.js +22 -0
  313. package/dist/client/react/navigationLocation.js.map +1 -0
  314. package/dist/client/react/pageQuery.d.ts +5 -0
  315. package/dist/client/react/pageQuery.d.ts.map +1 -0
  316. package/dist/client/react/pageQuery.js +35 -0
  317. package/dist/client/react/pageQuery.js.map +1 -0
  318. package/dist/client/react/projectionChanges.d.ts +6 -0
  319. package/dist/client/react/projectionChanges.d.ts.map +1 -0
  320. package/dist/client/react/projectionChanges.js +16 -0
  321. package/dist/client/react/projectionChanges.js.map +1 -0
  322. package/dist/client/react/projectionRoute.d.ts +4 -0
  323. package/dist/client/react/projectionRoute.d.ts.map +1 -0
  324. package/dist/client/react/projectionRoute.js +18 -0
  325. package/dist/client/react/projectionRoute.js.map +1 -0
  326. package/dist/client/react/readerLink.d.ts +2 -0
  327. package/dist/client/react/readerLink.d.ts.map +1 -0
  328. package/dist/client/react/readerLink.js +8 -0
  329. package/dist/client/react/readerLink.js.map +1 -0
  330. package/dist/client/react/readingHistory.d.ts +38 -0
  331. package/dist/client/react/readingHistory.d.ts.map +1 -0
  332. package/dist/client/react/readingHistory.js +33 -0
  333. package/dist/client/react/readingHistory.js.map +1 -0
  334. package/dist/client/react/readingLibrary.d.ts +24 -0
  335. package/dist/client/react/readingLibrary.d.ts.map +1 -0
  336. package/dist/client/react/readingLibrary.js +18 -0
  337. package/dist/client/react/readingLibrary.js.map +1 -0
  338. package/dist/client/react/readingState.d.ts +20 -0
  339. package/dist/client/react/readingState.d.ts.map +1 -0
  340. package/dist/client/react/readingState.js +133 -0
  341. package/dist/client/react/readingState.js.map +1 -0
  342. package/dist/client/react/remainingRoute.d.ts +3 -0
  343. package/dist/client/react/remainingRoute.d.ts.map +1 -0
  344. package/dist/client/react/remainingRoute.js +19 -0
  345. package/dist/client/react/remainingRoute.js.map +1 -0
  346. package/dist/client/react/savedViews.d.ts +14 -0
  347. package/dist/client/react/savedViews.d.ts.map +1 -0
  348. package/dist/client/react/savedViews.js +87 -0
  349. package/dist/client/react/savedViews.js.map +1 -0
  350. package/dist/client/react/scheduleReading.d.ts +3 -0
  351. package/dist/client/react/scheduleReading.d.ts.map +1 -0
  352. package/dist/client/react/scheduleReading.js +36 -0
  353. package/dist/client/react/scheduleReading.js.map +1 -0
  354. package/dist/client/react/searchCommands.d.ts +11 -0
  355. package/dist/client/react/searchCommands.d.ts.map +1 -0
  356. package/dist/client/react/searchCommands.js +7 -0
  357. package/dist/client/react/searchCommands.js.map +1 -0
  358. package/dist/client/react/searchStatus.d.ts +6 -0
  359. package/dist/client/react/searchStatus.d.ts.map +1 -0
  360. package/dist/client/react/searchStatus.js +20 -0
  361. package/dist/client/react/searchStatus.js.map +1 -0
  362. package/dist/client/react/shellIds.d.ts +59 -0
  363. package/dist/client/react/shellIds.d.ts.map +1 -1
  364. package/dist/client/react/shellIds.js +59 -0
  365. package/dist/client/react/shellIds.js.map +1 -1
  366. package/dist/client/react/useAppearance.d.ts +14 -0
  367. package/dist/client/react/useAppearance.d.ts.map +1 -0
  368. package/dist/client/react/useAppearance.js +55 -0
  369. package/dist/client/react/useAppearance.js.map +1 -0
  370. package/dist/client/react/useBoardNavigation.d.ts +3 -0
  371. package/dist/client/react/useBoardNavigation.d.ts.map +1 -0
  372. package/dist/client/react/useBoardNavigation.js +129 -0
  373. package/dist/client/react/useBoardNavigation.js.map +1 -0
  374. package/dist/client/react/useDiagnosticsPolling.d.ts +3 -0
  375. package/dist/client/react/useDiagnosticsPolling.d.ts.map +1 -0
  376. package/dist/client/react/useDiagnosticsPolling.js +23 -0
  377. package/dist/client/react/useDiagnosticsPolling.js.map +1 -0
  378. package/dist/client/react/useDocumentPage.d.ts +1 -1
  379. package/dist/client/react/useDocumentPage.d.ts.map +1 -1
  380. package/dist/client/react/useFormFocus.d.ts +5 -0
  381. package/dist/client/react/useFormFocus.d.ts.map +1 -0
  382. package/dist/client/react/useFormFocus.js +46 -0
  383. package/dist/client/react/useFormFocus.js.map +1 -0
  384. package/dist/client/react/useHandoffForm.d.ts +69 -0
  385. package/dist/client/react/useHandoffForm.d.ts.map +1 -0
  386. package/dist/client/react/useHandoffForm.js +102 -0
  387. package/dist/client/react/useHandoffForm.js.map +1 -0
  388. package/dist/client/react/useHistoryComparison.d.ts +33 -0
  389. package/dist/client/react/useHistoryComparison.d.ts.map +1 -0
  390. package/dist/client/react/useHistoryComparison.js +146 -0
  391. package/dist/client/react/useHistoryComparison.js.map +1 -0
  392. package/dist/client/react/useMedia.d.ts +2 -0
  393. package/dist/client/react/useMedia.d.ts.map +1 -0
  394. package/dist/client/react/useMedia.js +19 -0
  395. package/dist/client/react/useMedia.js.map +1 -0
  396. package/dist/client/react/useResponseForm.d.ts +107 -0
  397. package/dist/client/react/useResponseForm.d.ts.map +1 -0
  398. package/dist/client/react/useResponseForm.js +138 -0
  399. package/dist/client/react/useResponseForm.js.map +1 -0
  400. package/dist/client/react/useSearchDialog.d.ts +7 -0
  401. package/dist/client/react/useSearchDialog.d.ts.map +1 -0
  402. package/dist/client/react/useSearchDialog.js +26 -0
  403. package/dist/client/react/useSearchDialog.js.map +1 -0
  404. package/dist/client/react/useSidebar.d.ts +9 -0
  405. package/dist/client/react/useSidebar.d.ts.map +1 -0
  406. package/dist/client/react/useSidebar.js +77 -0
  407. package/dist/client/react/useSidebar.js.map +1 -0
  408. package/dist/client/react/visualDimensions.d.ts +3 -0
  409. package/dist/client/react/visualDimensions.d.ts.map +1 -0
  410. package/dist/client/react/visualDimensions.js +21 -0
  411. package/dist/client/react/visualDimensions.js.map +1 -0
  412. package/dist/client/react/visualSources.d.ts +13 -0
  413. package/dist/client/react/visualSources.d.ts.map +1 -0
  414. package/dist/client/react/visualSources.js +92 -0
  415. package/dist/client/react/visualSources.js.map +1 -0
  416. package/dist/client/reconcile/normalized.d.ts +3 -0
  417. package/dist/client/reconcile/normalized.d.ts.map +1 -0
  418. package/dist/client/reconcile/{signature.js → normalized.js} +1 -37
  419. package/dist/client/reconcile/normalized.js.map +1 -0
  420. package/dist/client/responses/answerRecovery.d.ts +14 -0
  421. package/dist/client/responses/answerRecovery.d.ts.map +1 -0
  422. package/dist/client/responses/answerRecovery.js +33 -0
  423. package/dist/client/responses/answerRecovery.js.map +1 -0
  424. package/dist/client/responses/authorLabel.d.ts +1 -1
  425. package/dist/client/responses/authorLabel.d.ts.map +1 -1
  426. package/dist/client/responses/authorLabel.js +2 -2
  427. package/dist/client/responses/authorLabel.js.map +1 -1
  428. package/dist/client/responses/failure.d.ts +5 -0
  429. package/dist/client/responses/failure.d.ts.map +1 -0
  430. package/dist/client/responses/failure.js +13 -0
  431. package/dist/client/responses/failure.js.map +1 -0
  432. package/dist/client/responses/formSchema.d.ts +9 -0
  433. package/dist/client/responses/formSchema.d.ts.map +1 -1
  434. package/dist/client/responses/formSchema.js +3 -0
  435. package/dist/client/responses/formSchema.js.map +1 -1
  436. package/dist/client/responses/preview.d.ts +2 -2
  437. package/dist/client/responses/preview.d.ts.map +1 -1
  438. package/dist/client/responses/preview.js.map +1 -1
  439. package/dist/client/responses/retainContext.d.ts +6 -0
  440. package/dist/client/responses/retainContext.d.ts.map +1 -0
  441. package/dist/client/responses/retainContext.js +12 -0
  442. package/dist/client/responses/retainContext.js.map +1 -0
  443. package/dist/client/responses/summary.d.ts +6 -0
  444. package/dist/client/responses/summary.d.ts.map +1 -0
  445. package/dist/client/responses/summary.js +21 -0
  446. package/dist/client/responses/summary.js.map +1 -0
  447. package/dist/client/sourceChanged.d.ts +2 -0
  448. package/dist/client/sourceChanged.d.ts.map +1 -0
  449. package/dist/client/sourceChanged.js +4 -0
  450. package/dist/client/sourceChanged.js.map +1 -0
  451. package/dist/diagnostics/daemonContract.d.ts +1 -1
  452. package/dist/diagnostics/daemonContract.js +1 -1
  453. package/dist/diagnostics/daemonContract.js.map +1 -1
  454. package/dist/diagnostics/source.d.ts +14 -24
  455. package/dist/diagnostics/source.d.ts.map +1 -1
  456. package/dist/diagnostics/source.js +2 -9
  457. package/dist/diagnostics/source.js.map +1 -1
  458. package/dist/history/schema.d.ts +33 -0
  459. package/dist/history/schema.d.ts.map +1 -1
  460. package/dist/history/schema.js +12 -0
  461. package/dist/history/schema.js.map +1 -1
  462. package/dist/rpc/contract.d.ts +4235 -298
  463. package/dist/rpc/contract.d.ts.map +1 -1
  464. package/dist/rpc/contract.js +57 -3
  465. package/dist/rpc/contract.js.map +1 -1
  466. package/dist/rpc/handoffContract.d.ts +3 -3
  467. package/dist/rpc/responseContract.d.ts +5 -5
  468. package/dist/server/board.d.ts +4 -4
  469. package/dist/server/board.d.ts.map +1 -1
  470. package/dist/server/board.js +18 -95
  471. package/dist/server/board.js.map +1 -1
  472. package/dist/server/boardRuntime.d.ts +12 -0
  473. package/dist/server/boardRuntime.d.ts.map +1 -0
  474. package/dist/server/boardRuntime.js +37 -0
  475. package/dist/server/boardRuntime.js.map +1 -0
  476. package/dist/server/diagnostics/daemon.js +3 -3
  477. package/dist/server/diagnostics/daemon.js.map +1 -1
  478. package/dist/server/history/html.d.ts +0 -1
  479. package/dist/server/history/html.d.ts.map +1 -1
  480. package/dist/server/history/html.js +0 -3
  481. package/dist/server/history/html.js.map +1 -1
  482. package/dist/server/history/response.d.ts.map +1 -1
  483. package/dist/server/history/response.js +14 -1
  484. package/dist/server/history/response.js.map +1 -1
  485. package/dist/server/http/assets.d.ts +4 -4
  486. package/dist/server/http/assets.d.ts.map +1 -1
  487. package/dist/server/http/assets.js +1 -35
  488. package/dist/server/http/assets.js.map +1 -1
  489. package/dist/server/http/attachment.d.ts +2 -2
  490. package/dist/server/http/attachment.d.ts.map +1 -1
  491. package/dist/server/http/boardRoutes.d.ts +6 -0
  492. package/dist/server/http/boardRoutes.d.ts.map +1 -0
  493. package/dist/server/http/boardRoutes.js +45 -0
  494. package/dist/server/http/boardRoutes.js.map +1 -0
  495. package/dist/server/http/identity.d.ts +2 -2
  496. package/dist/server/http/identity.d.ts.map +1 -1
  497. package/dist/server/http/inbox.d.ts +1 -1
  498. package/dist/server/http/inbox.d.ts.map +1 -1
  499. package/dist/server/http/overview.d.ts +1 -1
  500. package/dist/server/http/overview.d.ts.map +1 -1
  501. package/dist/server/http/page.d.ts +2 -2
  502. package/dist/server/http/page.d.ts.map +1 -1
  503. package/dist/server/http/page.js +1 -2
  504. package/dist/server/http/page.js.map +1 -1
  505. package/dist/server/http/respond.d.ts +1 -1
  506. package/dist/server/http/respond.d.ts.map +1 -1
  507. package/dist/server/http/respond.js +1 -1
  508. package/dist/server/http/respond.js.map +1 -1
  509. package/dist/server/http/rpcPolicy.d.ts +4 -0
  510. package/dist/server/http/rpcPolicy.d.ts.map +1 -0
  511. package/dist/server/http/rpcPolicy.js +11 -0
  512. package/dist/server/http/rpcPolicy.js.map +1 -0
  513. package/dist/server/http/work.d.ts +2 -2
  514. package/dist/server/http/work.d.ts.map +1 -1
  515. package/dist/server/integration/diagnostics.d.ts +1 -1
  516. package/dist/server/responses/agent.d.ts +1 -1
  517. package/dist/server/responses/agent.d.ts.map +1 -1
  518. package/dist/server/responses/agent.js +2 -2
  519. package/dist/server/responses/agent.js.map +1 -1
  520. package/dist/server/responses/composerHtml.js +1 -1
  521. package/dist/server/responses/composerHtml.js.map +1 -1
  522. package/dist/server/responses/waitFor.d.ts +1 -1
  523. package/dist/server/responses/waitFor.d.ts.map +1 -1
  524. package/dist/server/rpc/HandlerOptions.d.ts +12 -0
  525. package/dist/server/rpc/HandlerOptions.d.ts.map +1 -0
  526. package/dist/server/rpc/HandlerOptions.js +2 -0
  527. package/dist/server/rpc/HandlerOptions.js.map +1 -0
  528. package/dist/server/rpc/handlers.d.ts +2 -2
  529. package/dist/server/rpc/handlers.d.ts.map +1 -1
  530. package/dist/server/rpc/handlers.js +17 -10
  531. package/dist/server/rpc/handlers.js.map +1 -1
  532. package/dist/server/serve-cli.js +8 -8
  533. package/dist/server/serve-cli.js.map +1 -1
  534. package/dist/server/serve.d.ts +2 -3
  535. package/dist/server/serve.d.ts.map +1 -1
  536. package/dist/server/serve.js +20 -9
  537. package/dist/server/serve.js.map +1 -1
  538. package/dist/server/views/projectionQueries.d.ts +681 -0
  539. package/dist/server/views/projectionQueries.d.ts.map +1 -0
  540. package/dist/server/views/projectionQueries.js +70 -0
  541. package/dist/server/views/projectionQueries.js.map +1 -0
  542. package/dist/server/views/remainingQueries.d.ts +679 -0
  543. package/dist/server/views/remainingQueries.d.ts.map +1 -0
  544. package/dist/server/views/remainingQueries.js +58 -0
  545. package/dist/server/views/remainingQueries.js.map +1 -0
  546. package/dist/server/views/resultProjection.d.ts +420 -0
  547. package/dist/server/views/resultProjection.d.ts.map +1 -0
  548. package/dist/server/views/resultProjection.js +35 -0
  549. package/dist/server/views/resultProjection.js.map +1 -0
  550. package/dist/server/views/resultTargets.d.ts +6 -0
  551. package/dist/server/views/resultTargets.d.ts.map +1 -0
  552. package/dist/server/views/resultTargets.js +31 -0
  553. package/dist/server/views/resultTargets.js.map +1 -0
  554. package/dist/server/views/state.d.ts +8 -9
  555. package/dist/server/views/state.d.ts.map +1 -1
  556. package/dist/server/views/state.js +5 -38
  557. package/dist/server/views/state.js.map +1 -1
  558. package/dist/server/views/workStyle.d.ts.map +1 -1
  559. package/dist/server/views/workStyle.js +1 -0
  560. package/dist/server/views/workStyle.js.map +1 -1
  561. package/docs/delivery/decision-write-examples.md +1 -1
  562. package/docs/delivery/handoff-examples.md +1 -1
  563. package/docs/delivery/response-write-examples.md +1 -1
  564. package/docs/delivery/result-review-examples.md +1 -1
  565. package/docs/roadmap.md +7 -7
  566. package/package.json +52 -139
  567. package/src/browser/diagnostics/schema.ts +18 -0
  568. package/src/browser/views/ResultProjection.ts +37 -0
  569. package/src/browser/views/remaining.ts +26 -0
  570. package/src/browser/views/schema.ts +68 -0
  571. package/src/browser/views/state.ts +47 -0
  572. package/src/client/client.ts +8 -8
  573. package/src/client/document/Mermaid.ts +49 -9
  574. package/src/client/document/View.ts +14 -1
  575. package/src/client/document/boardLayout.ts +80 -0
  576. package/src/client/entry.ts +0 -24
  577. package/src/client/formDraft.ts +9 -0
  578. package/src/client/formFocus.ts +5 -0
  579. package/src/client/handoffs/failureStatus.ts +6 -0
  580. package/src/client/page/routeQuery.ts +0 -5
  581. package/src/client/react/Age.tsx +35 -0
  582. package/src/client/react/AnswerForm.tsx +88 -82
  583. package/src/client/react/AnswerPrompts.tsx +67 -54
  584. package/src/client/react/BoardMain.tsx +30 -0
  585. package/src/client/react/BoardShell.tsx +89 -27
  586. package/src/client/react/ChangesMain.tsx +68 -0
  587. package/src/client/react/DiagnosticsFleet.tsx +64 -0
  588. package/src/client/react/DiagnosticsMain.tsx +29 -0
  589. package/src/client/react/DiagnosticsPage.tsx +77 -0
  590. package/src/client/react/DocumentContext.tsx +25 -9
  591. package/src/client/react/DocumentMain.tsx +8 -6
  592. package/src/client/react/Favorite.tsx +17 -0
  593. package/src/client/react/FormField.tsx +68 -0
  594. package/src/client/react/HandoffForm.tsx +78 -0
  595. package/src/client/react/HandoffPage.tsx +78 -0
  596. package/src/client/react/HandoffPrompt.tsx +33 -0
  597. package/src/client/react/Header.tsx +34 -13
  598. package/src/client/react/HistoryComparison.tsx +60 -0
  599. package/src/client/react/HistoryRetention.tsx +29 -0
  600. package/src/client/react/HomeBoard.tsx +15 -0
  601. package/src/client/react/InboxPage.tsx +51 -0
  602. package/src/client/react/LiveControls.tsx +78 -0
  603. package/src/client/react/Modal.tsx +92 -0
  604. package/src/client/react/NavigationTree.tsx +2 -1
  605. package/src/client/react/OverviewGroups.tsx +61 -0
  606. package/src/client/react/OverviewPage.tsx +68 -0
  607. package/src/client/react/ProjectionFrame.tsx +140 -0
  608. package/src/client/react/ProjectionMain.tsx +63 -0
  609. package/src/client/react/PromptOption.tsx +56 -0
  610. package/src/client/react/ReadingLibrary.tsx +147 -0
  611. package/src/client/react/RemainingMain.tsx +66 -0
  612. package/src/client/react/RespondPage.tsx +41 -0
  613. package/src/client/react/ResponseMarkdown.tsx +32 -2
  614. package/src/client/react/ResultCriteria.tsx +78 -0
  615. package/src/client/react/ResultFeedback.tsx +67 -0
  616. package/src/client/react/ResultPage.tsx +50 -0
  617. package/src/client/react/SavedViews.tsx +61 -0
  618. package/src/client/react/SearchDialog.tsx +136 -0
  619. package/src/client/react/SearchResults.tsx +48 -0
  620. package/src/client/react/ShellApi.ts +11 -1
  621. package/src/client/react/Sidebar.tsx +57 -4
  622. package/src/client/react/StartPage.tsx +41 -0
  623. package/src/client/react/UpdatesToggle.tsx +13 -0
  624. package/src/client/react/VisualControls.tsx +59 -0
  625. package/src/client/react/VisualInspection.tsx +35 -0
  626. package/src/client/react/VisualViewer.tsx +147 -0
  627. package/src/client/react/WorkCards.tsx +39 -0
  628. package/src/client/react/WorkControls.tsx +73 -0
  629. package/src/client/react/WorkDetail.tsx +35 -0
  630. package/src/client/react/WorkItemTitle.tsx +9 -0
  631. package/src/client/react/WorkPage.tsx +59 -0
  632. package/src/client/react/WorkResults.tsx +9 -0
  633. package/src/client/react/WorkTable.tsx +39 -0
  634. package/src/client/react/WorkTools.tsx +17 -0
  635. package/src/client/react/activeRead.ts +15 -0
  636. package/src/client/react/createResponse.ts +40 -0
  637. package/src/client/react/diagnosticsValues.tsx +103 -0
  638. package/src/client/react/entry.css +20 -0
  639. package/src/client/react/entry.tsx +6 -19
  640. package/src/client/react/historyStore.ts +56 -0
  641. package/src/client/react/liveStatus.ts +52 -0
  642. package/src/client/react/loadBoardPage.ts +15 -5
  643. package/src/client/react/loadProjection.ts +23 -0
  644. package/src/client/react/loadRemaining.ts +27 -0
  645. package/src/client/react/mainLocation.ts +12 -0
  646. package/src/client/react/navigationLocation.ts +27 -0
  647. package/src/client/react/pageQuery.ts +38 -0
  648. package/src/client/react/projectionChanges.ts +21 -0
  649. package/src/client/react/projectionRoute.ts +21 -0
  650. package/src/client/react/readerLink.ts +9 -0
  651. package/src/client/react/readingHistory.ts +31 -0
  652. package/src/client/react/readingLibrary.ts +22 -0
  653. package/src/client/react/readingState.ts +133 -0
  654. package/src/client/react/remainingRoute.ts +19 -0
  655. package/src/client/react/savedViews.ts +84 -0
  656. package/src/client/react/scheduleReading.ts +41 -0
  657. package/src/client/react/searchCommands.ts +15 -0
  658. package/src/client/react/searchStatus.ts +30 -0
  659. package/src/client/react/shellIds.ts +59 -0
  660. package/src/client/react/useAppearance.ts +54 -0
  661. package/src/client/react/useBoardNavigation.ts +139 -0
  662. package/src/client/react/useDiagnosticsPolling.ts +24 -0
  663. package/src/client/react/useDocumentPage.ts +1 -1
  664. package/src/client/react/useFormFocus.ts +46 -0
  665. package/src/client/react/useHandoffForm.ts +105 -0
  666. package/src/client/react/useHistoryComparison.ts +142 -0
  667. package/src/client/react/useMedia.ts +19 -0
  668. package/src/client/react/useResponseForm.ts +147 -0
  669. package/src/client/react/useSearchDialog.ts +25 -0
  670. package/src/client/react/useSidebar.ts +81 -0
  671. package/src/client/react/visualDimensions.ts +20 -0
  672. package/src/client/react/visualSources.ts +105 -0
  673. package/src/client/reconcile/{signature.ts → normalized.ts} +0 -37
  674. package/src/client/responses/answerRecovery.ts +37 -0
  675. package/src/client/responses/authorLabel.ts +3 -3
  676. package/src/client/responses/failure.ts +13 -0
  677. package/src/client/responses/formSchema.ts +4 -0
  678. package/src/client/responses/preview.ts +2 -2
  679. package/src/client/responses/retainContext.ts +15 -0
  680. package/src/client/responses/summary.ts +25 -0
  681. package/src/client/sourceChanged.ts +3 -0
  682. package/src/diagnostics/daemonContract.ts +1 -1
  683. package/src/diagnostics/source.ts +5 -14
  684. package/src/history/schema.ts +15 -0
  685. package/src/rpc/contract.ts +57 -3
  686. package/src/server/board.ts +24 -126
  687. package/src/server/boardRuntime.ts +54 -0
  688. package/src/server/diagnostics/daemon.ts +3 -3
  689. package/src/server/history/html.ts +0 -3
  690. package/src/server/history/response.ts +15 -1
  691. package/src/server/http/assets.ts +2 -36
  692. package/src/server/http/attachment.ts +1 -1
  693. package/src/server/http/boardRoutes.ts +62 -0
  694. package/src/server/http/identity.ts +1 -1
  695. package/src/server/http/page.ts +2 -3
  696. package/src/server/http/respond.ts +1 -1
  697. package/src/server/http/rpcPolicy.ts +16 -0
  698. package/src/server/http/work.ts +1 -1
  699. package/src/server/responses/agent.ts +2 -2
  700. package/src/server/responses/composerHtml.ts +1 -1
  701. package/src/server/responses/waitFor.ts +1 -1
  702. package/src/server/rpc/HandlerOptions.ts +12 -0
  703. package/src/server/rpc/handlers.ts +18 -15
  704. package/src/server/serve-cli.ts +8 -8
  705. package/src/server/serve.ts +23 -10
  706. package/src/server/views/projectionQueries.ts +78 -0
  707. package/src/server/views/remainingQueries.ts +74 -0
  708. package/src/server/views/resultProjection.ts +45 -0
  709. package/src/server/views/resultTargets.ts +34 -0
  710. package/src/server/views/state.ts +5 -40
  711. package/src/server/views/workStyle.ts +1 -0
  712. package/dist/client/diagnostics/script.d.ts +0 -2
  713. package/dist/client/diagnostics/script.d.ts.map +0 -1
  714. package/dist/client/diagnostics/script.js +0 -31
  715. package/dist/client/diagnostics/script.js.map +0 -1
  716. package/dist/client/fieldFeedback.d.ts +0 -17
  717. package/dist/client/fieldFeedback.d.ts.map +0 -1
  718. package/dist/client/fieldFeedback.js +0 -38
  719. package/dist/client/fieldFeedback.js.map +0 -1
  720. package/dist/client/handoffs/copy.d.ts +0 -3
  721. package/dist/client/handoffs/copy.d.ts.map +0 -1
  722. package/dist/client/handoffs/copy.js +0 -47
  723. package/dist/client/handoffs/copy.js.map +0 -1
  724. package/dist/client/handoffs/fields.d.ts +0 -9
  725. package/dist/client/handoffs/fields.d.ts.map +0 -1
  726. package/dist/client/handoffs/fields.js +0 -34
  727. package/dist/client/handoffs/fields.js.map +0 -1
  728. package/dist/client/handoffs/form.d.ts +0 -36
  729. package/dist/client/handoffs/form.d.ts.map +0 -1
  730. package/dist/client/handoffs/form.js +0 -33
  731. package/dist/client/handoffs/form.js.map +0 -1
  732. package/dist/client/handoffs/setup.d.ts +0 -2
  733. package/dist/client/handoffs/setup.d.ts.map +0 -1
  734. package/dist/client/handoffs/setup.js +0 -125
  735. package/dist/client/handoffs/setup.js.map +0 -1
  736. package/dist/client/history/script.d.ts +0 -2
  737. package/dist/client/history/script.d.ts.map +0 -1
  738. package/dist/client/history/script.js +0 -128
  739. package/dist/client/history/script.js.map +0 -1
  740. package/dist/client/legacyRuntime.d.ts +0 -9
  741. package/dist/client/legacyRuntime.d.ts.map +0 -1
  742. package/dist/client/legacyRuntime.js +0 -15
  743. package/dist/client/legacyRuntime.js.map +0 -1
  744. package/dist/client/page/ageScript.d.ts +0 -2
  745. package/dist/client/page/ageScript.d.ts.map +0 -1
  746. package/dist/client/page/ageScript.js +0 -23
  747. package/dist/client/page/ageScript.js.map +0 -1
  748. package/dist/client/page/formReadingScript.d.ts +0 -2
  749. package/dist/client/page/formReadingScript.d.ts.map +0 -1
  750. package/dist/client/page/formReadingScript.js +0 -26
  751. package/dist/client/page/formReadingScript.js.map +0 -1
  752. package/dist/client/page/itemContextScript.d.ts +0 -2
  753. package/dist/client/page/itemContextScript.d.ts.map +0 -1
  754. package/dist/client/page/itemContextScript.js +0 -21
  755. package/dist/client/page/itemContextScript.js.map +0 -1
  756. package/dist/client/page/libraryScript.d.ts +0 -2
  757. package/dist/client/page/libraryScript.d.ts.map +0 -1
  758. package/dist/client/page/libraryScript.js +0 -85
  759. package/dist/client/page/libraryScript.js.map +0 -1
  760. package/dist/client/page/navigationHistoryScript.d.ts +0 -2
  761. package/dist/client/page/navigationHistoryScript.d.ts.map +0 -1
  762. package/dist/client/page/navigationHistoryScript.js +0 -47
  763. package/dist/client/page/navigationHistoryScript.js.map +0 -1
  764. package/dist/client/page/navigationScript.d.ts +0 -2
  765. package/dist/client/page/navigationScript.d.ts.map +0 -1
  766. package/dist/client/page/navigationScript.js +0 -113
  767. package/dist/client/page/navigationScript.js.map +0 -1
  768. package/dist/client/page/preferencesScript.d.ts +0 -2
  769. package/dist/client/page/preferencesScript.d.ts.map +0 -1
  770. package/dist/client/page/preferencesScript.js +0 -46
  771. package/dist/client/page/preferencesScript.js.map +0 -1
  772. package/dist/client/page/reactNavigationScript.d.ts +0 -2
  773. package/dist/client/page/reactNavigationScript.d.ts.map +0 -1
  774. package/dist/client/page/reactNavigationScript.js +0 -31
  775. package/dist/client/page/reactNavigationScript.js.map +0 -1
  776. package/dist/client/page/readingStateScript.d.ts +0 -2
  777. package/dist/client/page/readingStateScript.d.ts.map +0 -1
  778. package/dist/client/page/readingStateScript.js +0 -65
  779. package/dist/client/page/readingStateScript.js.map +0 -1
  780. package/dist/client/page/runtime.d.ts +0 -3
  781. package/dist/client/page/runtime.d.ts.map +0 -1
  782. package/dist/client/page/runtime.js +0 -111
  783. package/dist/client/page/runtime.js.map +0 -1
  784. package/dist/client/page/scripts.d.ts +0 -3
  785. package/dist/client/page/scripts.d.ts.map +0 -1
  786. package/dist/client/page/scripts.js +0 -91
  787. package/dist/client/page/scripts.js.map +0 -1
  788. package/dist/client/page/searchResultsScript.d.ts +0 -2
  789. package/dist/client/page/searchResultsScript.d.ts.map +0 -1
  790. package/dist/client/page/searchResultsScript.js +0 -64
  791. package/dist/client/page/searchResultsScript.js.map +0 -1
  792. package/dist/client/page/searchScript.d.ts +0 -2
  793. package/dist/client/page/searchScript.d.ts.map +0 -1
  794. package/dist/client/page/searchScript.js +0 -75
  795. package/dist/client/page/searchScript.js.map +0 -1
  796. package/dist/client/page/sidebarScript.d.ts +0 -2
  797. package/dist/client/page/sidebarScript.d.ts.map +0 -1
  798. package/dist/client/page/sidebarScript.js +0 -87
  799. package/dist/client/page/sidebarScript.js.map +0 -1
  800. package/dist/client/page/stateScript.d.ts +0 -2
  801. package/dist/client/page/stateScript.d.ts.map +0 -1
  802. package/dist/client/page/stateScript.js +0 -95
  803. package/dist/client/page/stateScript.js.map +0 -1
  804. package/dist/client/page/visualScript.d.ts +0 -2
  805. package/dist/client/page/visualScript.d.ts.map +0 -1
  806. package/dist/client/page/visualScript.js +0 -42
  807. package/dist/client/page/visualScript.js.map +0 -1
  808. package/dist/client/page/visualViewport.d.ts +0 -2
  809. package/dist/client/page/visualViewport.d.ts.map +0 -1
  810. package/dist/client/page/visualViewport.js +0 -87
  811. package/dist/client/page/visualViewport.js.map +0 -1
  812. package/dist/client/react/AnswerFocus.d.ts +0 -6
  813. package/dist/client/react/AnswerFocus.d.ts.map +0 -1
  814. package/dist/client/react/AnswerFocus.js +0 -12
  815. package/dist/client/react/AnswerFocus.js.map +0 -1
  816. package/dist/client/react/LegacyMain.d.ts +0 -9
  817. package/dist/client/react/LegacyMain.d.ts.map +0 -1
  818. package/dist/client/react/LegacyMain.js +0 -32
  819. package/dist/client/react/LegacyMain.js.map +0 -1
  820. package/dist/client/react/legacyPage.d.ts +0 -7
  821. package/dist/client/react/legacyPage.d.ts.map +0 -1
  822. package/dist/client/react/legacyPage.js +0 -63
  823. package/dist/client/react/legacyPage.js.map +0 -1
  824. package/dist/client/reconcile/patch.d.ts +0 -2
  825. package/dist/client/reconcile/patch.d.ts.map +0 -1
  826. package/dist/client/reconcile/patch.js +0 -64
  827. package/dist/client/reconcile/patch.js.map +0 -1
  828. package/dist/client/reconcile/signature.d.ts +0 -8
  829. package/dist/client/reconcile/signature.d.ts.map +0 -1
  830. package/dist/client/reconcile/signature.js.map +0 -1
  831. package/dist/client/reconcile/swap.d.ts +0 -2
  832. package/dist/client/reconcile/swap.d.ts.map +0 -1
  833. package/dist/client/reconcile/swap.js +0 -36
  834. package/dist/client/reconcile/swap.js.map +0 -1
  835. package/dist/client/responses/attach.d.ts +0 -2
  836. package/dist/client/responses/attach.d.ts.map +0 -1
  837. package/dist/client/responses/attach.js +0 -133
  838. package/dist/client/responses/attach.js.map +0 -1
  839. package/dist/client/responses/binding.d.ts +0 -3
  840. package/dist/client/responses/binding.d.ts.map +0 -1
  841. package/dist/client/responses/binding.js +0 -16
  842. package/dist/client/responses/binding.js.map +0 -1
  843. package/dist/client/responses/draft.d.ts +0 -13
  844. package/dist/client/responses/draft.d.ts.map +0 -1
  845. package/dist/client/responses/draft.js +0 -15
  846. package/dist/client/responses/draft.js.map +0 -1
  847. package/dist/client/responses/draftSession.d.ts +0 -8
  848. package/dist/client/responses/draftSession.d.ts.map +0 -1
  849. package/dist/client/responses/draftSession.js +0 -105
  850. package/dist/client/responses/draftSession.js.map +0 -1
  851. package/dist/client/responses/drafts.d.ts +0 -21
  852. package/dist/client/responses/drafts.d.ts.map +0 -1
  853. package/dist/client/responses/drafts.js +0 -68
  854. package/dist/client/responses/drafts.js.map +0 -1
  855. package/dist/client/responses/feedback.d.ts +0 -6
  856. package/dist/client/responses/feedback.d.ts.map +0 -1
  857. package/dist/client/responses/feedback.js +0 -77
  858. package/dist/client/responses/feedback.js.map +0 -1
  859. package/dist/client/responses/fields.d.ts +0 -12
  860. package/dist/client/responses/fields.d.ts.map +0 -1
  861. package/dist/client/responses/fields.js +0 -23
  862. package/dist/client/responses/fields.js.map +0 -1
  863. package/dist/client/responses/form.d.ts +0 -37
  864. package/dist/client/responses/form.d.ts.map +0 -1
  865. package/dist/client/responses/form.js +0 -43
  866. package/dist/client/responses/form.js.map +0 -1
  867. package/dist/client/responses/questionnaireControls.d.ts +0 -9
  868. package/dist/client/responses/questionnaireControls.d.ts.map +0 -1
  869. package/dist/client/responses/questionnaireControls.js +0 -82
  870. package/dist/client/responses/questionnaireControls.js.map +0 -1
  871. package/dist/client/responses/setup.d.ts +0 -2
  872. package/dist/client/responses/setup.d.ts.map +0 -1
  873. package/dist/client/responses/setup.js +0 -7
  874. package/dist/client/responses/setup.js.map +0 -1
  875. package/dist/client/responses/submit.d.ts +0 -5
  876. package/dist/client/responses/submit.d.ts.map +0 -1
  877. package/dist/client/responses/submit.js +0 -33
  878. package/dist/client/responses/submit.js.map +0 -1
  879. package/dist/client/views/savedScript.d.ts +0 -2
  880. package/dist/client/views/savedScript.d.ts.map +0 -1
  881. package/dist/client/views/savedScript.js +0 -89
  882. package/dist/client/views/savedScript.js.map +0 -1
  883. package/dist/server/diagnostics/html.d.ts +0 -8
  884. package/dist/server/diagnostics/html.d.ts.map +0 -1
  885. package/dist/server/diagnostics/html.js +0 -79
  886. package/dist/server/diagnostics/html.js.map +0 -1
  887. package/dist/server/diagnostics/page.d.ts +0 -55
  888. package/dist/server/diagnostics/page.d.ts.map +0 -1
  889. package/dist/server/diagnostics/page.js +0 -11
  890. package/dist/server/diagnostics/page.js.map +0 -1
  891. package/dist/server/handoffs/html.d.ts +0 -36
  892. package/dist/server/handoffs/html.d.ts.map +0 -1
  893. package/dist/server/handoffs/html.js +0 -31
  894. package/dist/server/handoffs/html.js.map +0 -1
  895. package/dist/server/handoffs/page.d.ts +0 -6
  896. package/dist/server/handoffs/page.d.ts.map +0 -1
  897. package/dist/server/handoffs/page.js +0 -34
  898. package/dist/server/handoffs/page.js.map +0 -1
  899. package/dist/server/http/changesPage.d.ts +0 -5
  900. package/dist/server/http/changesPage.d.ts.map +0 -1
  901. package/dist/server/http/changesPage.js +0 -13
  902. package/dist/server/http/changesPage.js.map +0 -1
  903. package/dist/server/http/readPage.d.ts +0 -4
  904. package/dist/server/http/readPage.d.ts.map +0 -1
  905. package/dist/server/http/readPage.js +0 -9
  906. package/dist/server/http/readPage.js.map +0 -1
  907. package/dist/server/http/start.d.ts +0 -5
  908. package/dist/server/http/start.d.ts.map +0 -1
  909. package/dist/server/http/start.js +0 -13
  910. package/dist/server/http/start.js.map +0 -1
  911. package/dist/server/page/startHtml.d.ts +0 -2
  912. package/dist/server/page/startHtml.d.ts.map +0 -1
  913. package/dist/server/page/startHtml.js +0 -10
  914. package/dist/server/page/startHtml.js.map +0 -1
  915. package/dist/server/responses/page.d.ts +0 -6
  916. package/dist/server/responses/page.d.ts.map +0 -1
  917. package/dist/server/responses/page.js +0 -25
  918. package/dist/server/responses/page.js.map +0 -1
  919. package/dist/server/results/criteria.d.ts +0 -3
  920. package/dist/server/results/criteria.d.ts.map +0 -1
  921. package/dist/server/results/criteria.js +0 -34
  922. package/dist/server/results/criteria.js.map +0 -1
  923. package/dist/server/results/feedback.d.ts +0 -6
  924. package/dist/server/results/feedback.d.ts.map +0 -1
  925. package/dist/server/results/feedback.js +0 -32
  926. package/dist/server/results/feedback.js.map +0 -1
  927. package/dist/server/results/page.d.ts +0 -6
  928. package/dist/server/results/page.d.ts.map +0 -1
  929. package/dist/server/results/page.js +0 -41
  930. package/dist/server/results/page.js.map +0 -1
  931. package/dist/server/rpc/transport.d.ts +0 -14
  932. package/dist/server/rpc/transport.d.ts.map +0 -1
  933. package/dist/server/rpc/transport.js +0 -15
  934. package/dist/server/rpc/transport.js.map +0 -1
  935. package/src/client/diagnostics/script.ts +0 -31
  936. package/src/client/fieldFeedback.ts +0 -53
  937. package/src/client/handoffs/copy.ts +0 -45
  938. package/src/client/handoffs/fields.ts +0 -38
  939. package/src/client/handoffs/form.ts +0 -41
  940. package/src/client/handoffs/setup.ts +0 -142
  941. package/src/client/history/script.ts +0 -127
  942. package/src/client/legacyRuntime.ts +0 -11
  943. package/src/client/page/ageScript.ts +0 -22
  944. package/src/client/page/formReadingScript.ts +0 -25
  945. package/src/client/page/itemContextScript.ts +0 -20
  946. package/src/client/page/libraryScript.ts +0 -84
  947. package/src/client/page/navigationHistoryScript.ts +0 -46
  948. package/src/client/page/navigationScript.ts +0 -113
  949. package/src/client/page/preferencesScript.ts +0 -45
  950. package/src/client/page/reactNavigationScript.ts +0 -30
  951. package/src/client/page/readingStateScript.ts +0 -64
  952. package/src/client/page/runtime.ts +0 -111
  953. package/src/client/page/scripts.ts +0 -91
  954. package/src/client/page/searchResultsScript.ts +0 -63
  955. package/src/client/page/searchScript.ts +0 -74
  956. package/src/client/page/sidebarScript.ts +0 -86
  957. package/src/client/page/stateScript.ts +0 -95
  958. package/src/client/page/visualScript.ts +0 -41
  959. package/src/client/page/visualViewport.ts +0 -86
  960. package/src/client/react/AnswerFocus.tsx +0 -10
  961. package/src/client/react/LegacyMain.tsx +0 -46
  962. package/src/client/react/legacyPage.ts +0 -69
  963. package/src/client/reconcile/patch.ts +0 -71
  964. package/src/client/reconcile/swap.ts +0 -37
  965. package/src/client/responses/attach.ts +0 -150
  966. package/src/client/responses/binding.ts +0 -16
  967. package/src/client/responses/draft.ts +0 -20
  968. package/src/client/responses/draftSession.ts +0 -108
  969. package/src/client/responses/drafts.ts +0 -82
  970. package/src/client/responses/feedback.ts +0 -81
  971. package/src/client/responses/fields.ts +0 -26
  972. package/src/client/responses/form.ts +0 -58
  973. package/src/client/responses/questionnaireControls.ts +0 -94
  974. package/src/client/responses/setup.ts +0 -6
  975. package/src/client/responses/submit.ts +0 -44
  976. package/src/client/views/savedScript.ts +0 -88
  977. package/src/server/diagnostics/html.ts +0 -93
  978. package/src/server/diagnostics/page.ts +0 -31
  979. package/src/server/handoffs/html.ts +0 -42
  980. package/src/server/handoffs/page.ts +0 -51
  981. package/src/server/http/changesPage.ts +0 -15
  982. package/src/server/http/readPage.ts +0 -13
  983. package/src/server/http/start.ts +0 -27
  984. package/src/server/page/startHtml.ts +0 -10
  985. package/src/server/responses/page.ts +0 -37
  986. package/src/server/results/criteria.ts +0 -37
  987. package/src/server/results/feedback.ts +0 -44
  988. package/src/server/results/page.ts +0 -63
  989. package/src/server/rpc/transport.ts +0 -34
package/assets/native.js CHANGED
@@ -1,72 +1,37 @@
1
1
  /* @shivaedev/work-board native browser bundle */
2
- var X4=Object.defineProperty;var dn=(e,t)=>{for(var n in t)X4(e,n,{get:t[n],enumerable:!0})};var eK={"'":"&#39;",'"':"&quot;","&":"&amp;","<":"&lt;",">":"&gt;"};function Hg(e){return e.replaceAll(/[&<>"']/gu,t=>eK[t]??t)}function g_(e){let t=e.current?' aria-current="page"':"",n=`<span class="age short" data-modified="${e.modified}"></span>`;return`<a href="${e.href}"${t}>${Hg(e.name)}</a>${n}`}function x_(e,t){let n=e.files.map(o=>`<li>${g_(o)}</li>`).join(""),r=e.folders.map(o=>{let s=o.active?" open":"";return`<li class="file-folder"><details data-key="folder:${Hg(o.path)}"${s}><summary>${Hg(o.name)}/ (${o.count})</summary>${x_(o)}</details></li>`}).join("");return`<ul${t===void 0?"":` data-inbox-count="${t}"`}>${n}${r}</ul>`}function y_(e){let t=e.records,n=t.active?" open":"",r=t.count===0?"":`<details data-key="fleet-records"${n}><summary>Fleet records (${t.count})</summary><ul>${t.files.map(o=>`<li>${g_(o)}</li>`).join("")}</ul></details>`;return x_(e.tree,String(e.inboxCount??"?"))+r}var ce=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let r=0,o=t.length;r<o;r++)n=t[r](n);return n}}},tK={pipe(){return ce(this,arguments)}},uu=(function(){function e(){}return e.prototype=tK,e})();var d=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):n=>t(n,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(n,r){return arguments.length>=2?t(n,r):function(o){return t(o,n)}};case 3:return function(n,r,o){return arguments.length>=3?t(n,r,o):function(s){return t(s,n,r)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(r){return t(r,...n)}}}};var j=e=>e;var Xe=e=>()=>e,cn=Xe(!0),fu=Xe(!1),zg=Xe(null),qo=Xe(void 0),Cn=qo;function nl(e,...t){return ce(e,t)}function lu(e,t,n,r,o,s,i,a,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return o(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(o(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return i(s(o(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return a(i(s(o(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(a(i(s(o(r(n(t(e.apply(this,arguments)))))))))}}}function bn(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),o}}function du(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),t.set(o,o),o}}var De={};dn(De,{asEquivalence:()=>cl,byReference:()=>LK,byReferenceUnsafe:()=>Ep,equals:()=>ne,isEqual:()=>ow,makeCompareMap:()=>Sp,makeCompareSet:()=>bp,symbol:()=>ke});var Ot={};dn(Ot,{array:()=>ra,combine:()=>Ht,hash:()=>ue,isHash:()=>E_,number:()=>_r,optimize:()=>oa,random:()=>yp,string:()=>st,structure:()=>al,structureKeys:()=>Vg,symbol:()=>Ie});var hp=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let o=Reflect.ownKeys(r);for(let s=0;s<o.length;s++)t.add(o[s]);r=Object.getPrototypeOf(r)}return t.has("constructor")&&typeof e.constructor=="function"&&n===e.constructor.prototype&&t.delete("constructor"),t},rl=new WeakSet;var $t={};dn($t,{Struct:()=>xK,Tuple:()=>gK,and:()=>bK,compose:()=>hK,eqv:()=>wK,every:()=>kK,hasProperty:()=>N,implies:()=>vK,isBigInt:()=>V0,isBoolean:()=>K0,isDate:()=>dK,isError:()=>Q0,isFunction:()=>Ft,isIterable:()=>Es,isMap:()=>aK,isNever:()=>Z0,isNotNull:()=>uK,isNotNullish:()=>xp,isNotUndefined:()=>qn,isNull:()=>cK,isNullish:()=>G0,isNumber:()=>ol,isObject:()=>Wt,isObjectKeyword:()=>il,isObjectOrArray:()=>sl,isPromise:()=>pK,isPromiseLike:()=>mK,isPropertyKey:()=>gp,isReadonlyObject:()=>fK,isRegExp:()=>b_,isSet:()=>iK,isString:()=>Gr,isSymbol:()=>Wg,isTagged:()=>jn,isTruthy:()=>sK,isTupleOf:()=>rK,isTupleOfAtLeast:()=>oK,isUint8Array:()=>lK,isUndefined:()=>J0,isUnknown:()=>Kg,mapInput:()=>nK,nand:()=>IK,nor:()=>TK,not:()=>yK,or:()=>SK,some:()=>AK,xor:()=>EK});var nK=d(2,(e,t)=>n=>e(t(n))),rK=d(2,(e,t)=>e.length===t),oK=d(2,(e,t)=>e.length>=t);function sK(e){return!!e}function iK(e){return e instanceof Set}function aK(e){return e instanceof Map}function Gr(e){return typeof e=="string"}function ol(e){return typeof e=="number"}function K0(e){return typeof e=="boolean"}function V0(e){return typeof e=="bigint"}function Wg(e){return typeof e=="symbol"}function gp(e){return Gr(e)||ol(e)||Wg(e)}function Ft(e){return typeof e=="function"}function J0(e){return e===void 0}function qn(e){return e!==void 0}function cK(e){return e===null}function uK(e){return e!==null}function G0(e){return e==null}function xp(e){return e!=null}function Z0(e){return!1}function Kg(e){return!0}function sl(e){return typeof e=="object"&&e!==null}function Wt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fK(e){return Wt(e)}function il(e){return typeof e=="object"&&e!==null||Ft(e)}var N=d(2,(e,t)=>il(e)&&t in e),jn=d(2,(e,t)=>N(e,"_tag")&&e._tag===t);function Q0(e){return e instanceof Error}function lK(e){return e instanceof Uint8Array}function dK(e){return e instanceof Date}function Es(e){return N(e,Symbol.iterator)||Gr(e)}function pK(e){return N(e,"then")&&"catch"in e&&Ft(e.then)&&Ft(e.catch)}function mK(e){return N(e,"then")&&Ft(e.then)}function b_(e){return e instanceof RegExp}var hK=d(2,(e,t)=>n=>e(n)&&t(n));function gK(e){return t=>{for(let n=0;n<e.length;n++)if(e[n](t[n])===!1)return!1;return!0}}function xK(e){let t=Object.keys(e);return n=>{for(let r of t)if(!e[r](n[r]))return!1;return!0}}function yK(e){return t=>!e(t)}var SK=d(2,(e,t)=>n=>e(n)||t(n)),bK=d(2,(e,t)=>n=>e(n)&&t(n)),EK=d(2,(e,t)=>n=>e(n)!==t(n)),wK=d(2,(e,t)=>n=>e(n)===t(n)),vK=d(2,(e,t)=>n=>e(n)?t(n):!0),TK=d(2,(e,t)=>n=>!(e(n)||t(n))),IK=d(2,(e,t)=>n=>!(e(n)&&t(n)));function kK(e){return t=>{for(let n of e)if(!n(t))return!1;return!0}}function AK(e){return t=>{for(let n of e)if(n(t))return!0;return!1}}var Ie="~effect/interfaces/Hash",ue=e=>{switch(typeof e){case"number":return _r(e);case"bigint":return st(e.toString(10));case"boolean":return st(String(e));case"symbol":return st(String(e));case"string":return st(e);case"undefined":return st("undefined");case"function":case"object":{if(e===null)return st("null");if(e instanceof Date)return Number.isNaN(e.getTime())?st("Invalid Date"):st(e.toISOString());if(e instanceof RegExp)return st(e.toString());{if(rl.has(e))return yp(e);if(X0.has(e))return X0.get(e);let t=OK(e,()=>E_(e)?e[Ie]():typeof e=="function"?yp(e):e instanceof DataView?ra(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):Array.isArray(e)||ArrayBuffer.isView(e)?ra(e):e instanceof Map?RK(e):e instanceof Set?CK(e):al(e));return X0.set(e,t),t}}default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},yp=e=>(Y0.has(e)||Y0.set(e,_r(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),Y0.get(e)),Ht=d(2,(e,t)=>e*53^t),oa=e=>e&3221225471|e>>>1&1073741824,E_=e=>N(e,Ie),_r=e=>{if(e!==e)return st("NaN");if(e===1/0)return st("Infinity");if(e===-1/0)return st("-Infinity");let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return oa(t)},st=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return oa(t)},Vg=(e,t)=>{let n=12289;for(let r of t)n^=Ht(ue(r),ue(e[r]));return oa(n)},al=e=>Vg(e,hp(e)),tw=(e,t)=>n=>{let r=e;for(let o of n)r^=t(o);return oa(r)},ra=tw(6151,ue),RK=tw(st("Map"),([e,t])=>Ht(ue(e),ue(t))),CK=tw(st("Set"),ue),Y0=new WeakMap,X0=new WeakMap,ew=new WeakSet;function OK(e,t){if(ew.has(e))return st("[Circular]");ew.add(e);let n=t();return ew.delete(e),n}var ke="~effect/interfaces/Equal";function ne(){return arguments.length===1?e=>pu(e,arguments[0]):pu(arguments[0],arguments[1])}function pu(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n!==typeof t?!1:n==="number"&&e!==e&&t!==t?!0:n!=="object"&&n!=="function"||rl.has(e)||rl.has(t)?!1:PK(e,t,MK)}function _K(e,t,n){let r=nw.has(e),o=rw.has(t);if(r&&o)return!0;if(r||o)return!1;nw.add(e),rw.add(t);let s=n();return nw.delete(e),rw.delete(t),s}var nw=new WeakSet,rw=new WeakSet;function MK(e,t){if(ue(e)!==ue(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let s=e.getTime(),i=t.getTime();return s===i||Number.isNaN(s)&&Number.isNaN(i)}else if(e instanceof RegExp)return t instanceof RegExp?e.toString()===t.toString():!1;let n=ow(e),r=ow(t);if(n!==r)return!1;let o=n&&r;return typeof e=="function"&&!o?!1:_K(e,t,()=>{if(o)return e[ke](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:FK(e,t);if(ArrayBuffer.isView(e)){let s=e instanceof DataView;if(!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||s!==t instanceof DataView)return!1;if(s){let i=t;return w_(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(i.buffer,i.byteOffset,i.byteLength))}return w_(e,t)}else{if(e instanceof Map)return!(t instanceof Map)||e.size!==t.size?!1:NK(e,t);if(e instanceof Set)return!(t instanceof Set)||e.size!==t.size?!1:DK(e,t)}return UK(e,t)})}function PK(e,t,n){let r=Jg.get(e);if(!r)r=new WeakMap,Jg.set(e,r);else if(r.has(t))return r.get(t);let o=n(e,t);r.set(t,o);let s=Jg.get(t);return s||(s=new WeakMap,Jg.set(t,s)),s.set(e,o),o}var Jg=new WeakMap;function FK(e,t){for(let n=0;n<e.length;n++)if(!pu(e[n],t[n]))return!1;return!0}function w_(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function UK(e,t){let n=hp(e),r=hp(t);if(n.size!==r.size)return!1;for(let o of n)if(!r.has(o)||!pu(e[o],t[o]))return!1;return!0}function Sp(e,t){return function(r,o){let s=Array.from(o);for(let[i,a]of r){let c=!1;for(let u=0;u<s.length;u++){let[f,l]=s[u];if(e(i,f)&&t(a,l)){s[u]=s[s.length-1],s.pop(),c=!0;break}}if(!c)return!1}return!0}}var NK=Sp(pu,pu);function bp(e){return function(n,r){let o=Array.from(r);for(let s of n){let i=!1;for(let a=0;a<o.length;a++){let c=o[a];if(e(s,c)){o[a]=o[o.length-1],o.pop(),i=!0;break}}if(!i)return!1}return!0}}var DK=bp(pu),ow=e=>N(e,ke),cl=()=>ne,LK=e=>Ep(new Proxy(e,{})),Ep=e=>(rl.add(e),e);function jo(e,t,n){return{combine:e,initialValue:t,combineAll:n??(r=>{let o=t;for(let s of r)o=e(o,s);return o})}}var pn=e=>(t,n)=>t===n||e(t,n),qK=(e,t)=>e===t,mu=()=>qK;function v_(e){return pn((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e[r](t[r],n[r]))return!1;return!0})}function Gg(e){return pn((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var sw=e=>e.length>0;var fl=e=>d(3,(t,n,r)=>e(t,o=>({...o,[n]:r(o)}))),ll=e=>d(2,(t,n)=>e(t,r=>({[n]:r}))),dl=(e,t)=>d(3,(n,r,o)=>t(n,s=>e(o(s),i=>({...s,[r]:i}))));function K(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function Zg(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&K(e,n,t[n])}var Pe={};dn(Pe,{Do:()=>_V,all:()=>SV,andThen:()=>hV,as:()=>j_,asVoid:()=>pV,bind:()=>OV,bindTo:()=>RV,composeK:()=>xV,contains:()=>kV,containsWith:()=>K_,exists:()=>AV,filter:()=>fc,filterMap:()=>wV,firstSomeOf:()=>lV,flatMap:()=>Ts,flatMapNullishOr:()=>Sw,flatten:()=>Ru,fromIterable:()=>sV,fromNullOr:()=>xw,fromNullishOr:()=>Au,fromUndefinedOr:()=>gw,gen:()=>MV,getFailure:()=>aV,getOrElse:()=>cc,getOrNull:()=>Cp,getOrThrow:()=>yw,getOrThrowWith:()=>Op,getOrUndefined:()=>Ko,getSuccess:()=>iV,isNone:()=>Se,isOption:()=>hi,isSome:()=>_e,let:()=>CV,lift2:()=>TV,liftNullishOr:()=>dV,liftPredicate:()=>IV,liftThrowable:()=>uc,makeCombinerFailFast:()=>V_,makeEquivalence:()=>bw,makeOrder:()=>vV,makeReducer:()=>PV,makeReducerFailFast:()=>FV,map:()=>Kt,match:()=>mr,none:()=>D,orElse:()=>cV,orElseResult:()=>fV,orElseSome:()=>uV,partitionMap:()=>EV,product:()=>H_,productMany:()=>yV,reduceCompact:()=>bV,some:()=>L,tap:()=>$_,toArray:()=>W_,toRefinement:()=>oV,void:()=>mV,zipLeft:()=>gV,zipRight:()=>B_,zipWith:()=>z_});function Qg(e){return{combine:e}}var hu=Symbol.for("~effect/Redactable"),BK=e=>N(e,hu);function Bo(e){return BK(e)?cw(e):e}function cw(e){return e[hu](globalThis[pl]?.context??$K)}var pl="~effect/Fiber/currentFiber",T_=new Map,$K={"~effect/Context":{},base:T_,depth:0,mapUnsafe:T_,pipe(){return ce(this,arguments)}};function re(e,t){let n=t?.space??0,r=new WeakSet,o=n?typeof n=="number"?" ".repeat(n):n:"",s=u=>o.repeat(u),i=(u,f)=>{let l=u?.constructor;return l&&l!==Object.prototype.constructor&&l.name?`${l.name}(${f})`:f},a=u=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}};function c(u,f=0){if(typeof u=="string")return JSON.stringify(u);if(typeof u=="number"||u==null||typeof u=="boolean"||typeof u=="symbol")return String(u);if(typeof u=="bigint")return String(u)+"n";if(typeof u=="object"||typeof u=="function"){if(r.has(u))return HK;r.add(u);let l;if(hu in u)l=c(cw(u),f);else if(Array.isArray(u))l=!o||u.length<=1?`[${u.map(p=>c(p,f)).join(",")}]`:`[
3
- ${s(f+1)}${u.map(p=>c(p,f+1)).join(`,
4
- `+s(f+1))}
5
- ${s(f)}]`;else if(u instanceof Date)l=uw(u);else if(!t?.ignoreToString&&N(u,"toString")&&typeof u.toString=="function"&&u.toString!==Object.prototype.toString&&u.toString!==Array.prototype.toString){let p=zK(u);l=u instanceof Error&&u.cause?`${p} (cause: ${c(u.cause,f)})`:p}else if(Symbol.iterator in u)l=`${u.constructor.name}(${c(Array.from(u),f)})`;else{let p=a(u);if(!o||p.length<=1){let h=`{${p.map(g=>`${sa(g)}:${c(u[g],f)}`).join(",")}}`;l=i(u,h)}else{let h=`{
6
- ${p.map(g=>`${s(f+1)}${sa(g)}: ${c(u[g],f+1)}`).join(`,
2
+ var hK=Object.defineProperty;var ps=(e,t)=>{for(var r in t)hK(e,r,{get:t[r],enumerable:!0})};var V=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let r=e;for(let n=0,o=t.length;n<o;n++)r=t[n](r);return r}}},tI={pipe(){return V(this,arguments)}},Ra=(function(){function e(){}return e.prototype=tI,e})();var d=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):r=>t(r,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(r,n){return arguments.length>=2?t(r,n):function(o){return t(o,r)}};case 3:return function(r,n,o){return arguments.length>=3?t(r,n,o):function(s){return t(s,r,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(n){return t(n,...r)}}}};var F=e=>e;var qe=e=>()=>e,nr=qe(!0),Oa=qe(!1),rI=qe(null),po=qe(void 0),Rr=po;function Md(e,...t){return V(e,t)}function Lc(e,t,r,n,o,s,i,a,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return r(t(e.apply(this,arguments)))};case 4:return function(){return n(r(t(e.apply(this,arguments))))};case 5:return function(){return o(n(r(t(e.apply(this,arguments)))))};case 6:return function(){return s(o(n(r(t(e.apply(this,arguments))))))};case 7:return function(){return i(s(o(n(r(t(e.apply(this,arguments)))))))};case 8:return function(){return a(i(s(o(n(r(t(e.apply(this,arguments))))))))};case 9:return function(){return c(a(i(s(o(n(r(t(e.apply(this,arguments)))))))))}}}function mo(e){let t=new WeakMap;return r=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r);return t.set(r,o),o}}function Bc(e){let t=new WeakMap;return r=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r);return t.set(r,o),o!==r&&t.set(o,o),o}}var Fd=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let r=Object.getPrototypeOf(e),n=r;for(;n!==null&&n!==Object.prototype;){let o=Reflect.ownKeys(n);for(let s=0;s<o.length;s++)t.add(o[s]);n=Object.getPrototypeOf(n)}return t.has("constructor")&&typeof e.constructor=="function"&&r===e.constructor.prototype&&t.delete("constructor"),t},Tf=new WeakSet,Nd=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);var $c=0,MO=()=>{$c++};function On(e){return typeof e=="string"}function Ud(e){return typeof e=="number"}function ux(e){return typeof e=="boolean"}function FO(e){return typeof e=="bigint"}function nI(e){return typeof e=="symbol"}function fx(e){return On(e)||Ud(e)||nI(e)}function or(e){return typeof e=="function"}function NO(e){return e===void 0}function ei(e){return e!==void 0}function UO(e){return e==null}function lx(e){return e!=null}function DO(e){return!1}function oI(e){return!0}function Dd(e){return typeof e=="object"&&e!==null}function Gt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ld(e){return typeof e=="object"&&e!==null||or(e)}var O=d(2,(e,t)=>Ld(e)&&t in e),Or=d(2,(e,t)=>O(e,"_tag")&&e._tag===t);function LO(e){return e instanceof Error}function ti(e){return O(e,Symbol.iterator)||On(e)}var ie="~effect/Hash",J=e=>{switch(typeof e){case"number":return qt(e);case"bigint":return Be(e.toString(10));case"string":return Be(e);case"function":case"object":{if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?Be("Invalid Date"):Be(e.toISOString());if(e instanceof RegExp)return Be(e.toString());{if(Tf.has(e))return dx(e);let t=$O.get(e);if(t!==void 0)return t;if(aI.has(e))return MO(),Be("[Circular]");aI.add(e);let r=$c,n;try{ie in e?n=e[ie]():typeof e=="function"?n=dx(e):e instanceof DataView?n=ri(Nd(e)):Array.isArray(e)||ArrayBuffer.isView(e)?n=ri(e):e instanceof Map?n=xK(e):e instanceof Set?n=gK(e):n=$d(e)}finally{aI.delete(e)}return r===$c&&$O.set(e,n),n}}}return _r(HO(Be(String(e))))},dx=e=>(iI.has(e)||iI.set(e,_r(Math.random()*4294967296|0)),iI.get(e)),HO=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),he=d(2,(e,t)=>HO(Math.imul(e,2654435761)+Math.imul(t,2246822507))),_r=e=>e&3221225471|e>>>1&1073741824;var sI=new DataView(new ArrayBuffer(8)),qt=e=>{let t=e|0;return t===e?_r(t):(sI.setFloat64(0,e!==e?NaN:e),_r(he(sI.getInt32(0),sI.getInt32(4))))},Be=e=>{let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return _r(t)},Bd=(e,t)=>{let r=12289;for(let n of t)r^=he(J(n),J(e[n]));return _r(r)},$d=e=>Bd(e,Fd(e)),jO=(e,t)=>r=>{let n=e;for(let o of r)n^=t(o);return _r(n)},ri=e=>{let t=6151;for(let r of e)t=he(t,J(r));return _r(t)},xK=jO(Be("Map"),([e,t])=>he(J(e),J(t))),BO=Be("Set"),gK=jO(BO,e=>he(BO,J(e))),iI=new WeakMap,$O=new WeakMap,aI=new WeakSet;var ae="~effect/Equal";function Z(){return arguments.length===1?e=>Hc(e,arguments[0]):Hc(arguments[0],arguments[1])}function Hc(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let r=typeof e;return r!==typeof t?!1:r==="number"&&e!==e&&t!==t?!0:r!=="object"&&r!=="function"||Tf.has(e)||Tf.has(t)?!1:yK(e,t)}function yK(e,t){let r=px.length;for(let s=r;s-- >0;)if(px[s]===e&&cI[s]===t)return!0;if(r)return qO(e,t);let n=zO.get(e);n||zO.set(e,n=new WeakMap);let o=n.get(t);return o===void 0&&n.set(t,o=qO(e,t)),o}function qO(e,t){px.push(e),cI.push(t);try{return SK(e,t)}finally{px.pop(),cI.pop()}}var px=[],cI=[],zO=new WeakMap;function SK(e,t){if(J(e)!==J(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),o=t.getTime();return n===o||Number.isNaN(n)&&Number.isNaN(o)}else if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let r=KO(e);if(r!==KO(t)||typeof e=="function"&&!r)return!1;if(r)return e[ae](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:bK(e,t);if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?WO(Nd(e),Nd(t)):WO(e,t)}else{if(e instanceof Map)return!(t instanceof Map)||e.size!==t.size?!1:uI(e,t,IK,TK);if(e instanceof Set)return!(t instanceof Set)||e.size!==t.size?!1:uI(e,t,J,Hc)}return EK(e,t)}function bK(e,t){for(let r=0;r<e.length;r++)if(!Hc(e[r],t[r]))return!1;return!0}function WO(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function EK(e,t){let r=Fd(e),n=Fd(t);if(r.size!==n.size)return!1;for(let o of r)if(!n.has(o)||!Hc(e[o],t[o]))return!1;return!0}function uI(e,t,r,n){let o=new Map,s=0;for(let i of t){let a=r(i),c=o.get(a);c?c.push(i):o.set(a,[i]),s++}e:for(let i of e){let a=o.get(r(i));if(a){for(let c=0;c<a.length;c++)if(n(i,a[c])){a[c]=a[a.length-1],a.pop(),s--;continue e}}return!1}return s===0}var IK=e=>J(e[0]),TK=(e,t)=>Hc(e[0],t[0])&&Hc(e[1],t[1]),wK=()=>0;function mx(e,t){return Hd((r,n)=>e(r[0],n[0])&&t(r[1],n[1]))}function Hd(e){return function(r,n){return uI(r,n,wK,e)}}var KO=e=>O(e,ae),jd=()=>Z;var VO=e=>(Tf.add(e),e);var jc=Symbol.for("~effect/Redactable"),vK=e=>O(e,jc);function ho(e){return vK(e)?fI(e):e}function fI(e){return e[jc](globalThis[wf]?.context??CK)}var wf="~effect/Fiber/currentFiber",JO=new Map,CK={"~effect/Context":{},base:JO,depth:0,mapUnsafe:JO,pipe(){return V(this,arguments)}};function j(e,t){let r=t?.space??0,n=new WeakSet,o=r?typeof r=="number"?" ".repeat(r):r:"",s=f=>o.repeat(f),i=(f,p)=>{let m=f?.constructor;return m&&m!==Object.prototype.constructor&&m.name?`${m.name}(${p})`:p},a=f=>{try{return Reflect.ownKeys(f)}catch{return["[ownKeys threw]"]}};function c(f,p=0){try{return u(f,p)}catch{return(typeof f=="object"&&f!==null||typeof f=="function")&&n.delete(f),"[inspection threw]"}}function u(f,p=0){if(typeof f=="string")return JSON.stringify(f);if(typeof f=="number"||f==null||typeof f=="boolean"||typeof f=="symbol")return String(f);if(typeof f=="bigint")return String(f)+"n";if(typeof f=="object"||typeof f=="function"){if(n.has(f))return AK;n.add(f);let m;if(jc in f)m=c(fI(f),p);else if(Array.isArray(f))m=!o||f.length<=1?`[${f.map(h=>c(h,p)).join(",")}]`:`[
3
+ ${s(p+1)}${f.map(h=>c(h,p+1)).join(`,
4
+ `+s(p+1))}
5
+ ${s(p)}]`;else if(f instanceof Date)m=lI(f);else if(!t?.ignoreToString&&O(f,"toString")&&typeof f.toString=="function"&&f.toString!==Object.prototype.toString&&f.toString!==Array.prototype.toString){let h=kK(f);m=f instanceof Error&&f.cause!==void 0?`${h} (cause: ${c(f.cause,p)})`:h}else if(Symbol.iterator in f)m=`${f.constructor.name}(${c(Array.from(f),p)})`;else{let h=a(f);if(!o||h.length<=1){let x=`{${h.map(g=>`${ni(g)}:${c(ZO(f,g),p)}`).join(",")}}`;m=i(f,x)}else{let x=`{
6
+ ${h.map(g=>`${s(p+1)}${ni(g)}: ${c(ZO(f,g),p+1)}`).join(`,
7
7
  `)}
8
- ${s(f)}}`;l=i(u,h)}}return r.delete(u),l}return String(u)}return c(e,0)}var HK="[Circular]";function sa(e){return typeof e=="string"?JSON.stringify(e):String(e)}function Yg(e){return e.map(t=>`[${sa(t)}]`).join("")}function uw(e){try{return e.toISOString()}catch{return"Invalid Date"}}function zK(e){try{let t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}function gu(e,t){let n=[];return JSON.stringify(e,function(r,o){let s=Object.getOwnPropertyDescriptor(this,r)?.value,i=N(s,hu)?Bo(s):Bo(o);if(typeof i=="bigint")return re(i);if(typeof i!="object"||i===null)return i;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(!n.includes(i))return n.push(i),i},t?.space)??"null"}var ft=Symbol.for("nodejs.util.inspect.custom"),wn=e=>{try{return e=Bo(e),N(e,"toJSON")&&Ft(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(wn):e}catch{return"[toJSON threw]"}},k_=(e,t=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?gu(e,{space:t}):re(e,{space:t})}catch{return String(e)}},di={toJSON(){return wn(this)},[ft](){return this.toJSON()},toString(){return re(this.toJSON())}},Xg=class{[ft](){return this.toJSON()}toString(){return re(this.toJSON())}};var rc=class e{called=!1;self;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new e(this.self)}},KK=()=>{let e="~effect/Utils/internal",t={[e]:o=>o()},n={[e]:o=>o()};return t[e](()=>new Error().stack)?.includes(e)===!0?t[e]:n[e]},$e=KK();var mi="~effect/Effect",xu="~effect/Exit",JK={_A:j,_E:j,_R:j},R_=`${mi}/identifier`,be=`${mi}/args`,un=`${mi}/evaluate`,Mr=`${mi}/successCont`,$o=`${mi}/failureCont`,oc=`${mi}/ensureCont`,bu=Symbol.for("effect/Effect/Yield"),On={pipe(){return ce(this,arguments)},toJSON(){return{...this}},toString(){return re(this.toJSON(),{ignoreToString:!0,space:2})},[ft](){return this.toJSON()}},C_={[Ie](){return Vg(this,Object.keys(this))},[ke](e){let t=Object.keys(this),n=Object.keys(e);if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==n[r]||!ne(this[t[r]],e[t[r]]))return!1;return!0}},GK={[mi]:JK,...On,[Symbol.iterator](){return new rc(this)},toJSON(){return{_id:"Effect",op:this[R_],...be in this?{args:this[be]}:void 0}}},Ce=e=>N(e,mi),fw=e=>N(e,xu),ml="~effect/Cause",hl="~effect/Cause/Reason",xl=e=>N(e,ml),O_=e=>N(e,hl),pi=class{[ml];reasons;constructor(t){this[ml]=ml,this.reasons=t}pipe(){return ce(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(t=>t.toJSON())}}toString(){return`Cause(${re(this.reasons)})`}[ft](){return this.toJSON()}[ke](t){return xl(t)&&this.reasons.length===t.reasons.length&&this.reasons.every((n,r)=>ne(n,t.reasons[r]))}[Ie](){return ra(this.reasons)}},A_=new WeakMap,gl=class{[hl];annotations;_tag;constructor(t,n,r){if(this[hl]=hl,this._tag=t,n!==Tp&&typeof r=="object"&&r!==null&&n.size>0){let o=A_.get(r);o&&(n=new Map([...o,...n])),A_.set(r,n)}this.annotations=n}annotate(t,n){if(t.mapUnsafe.size===0)return this;let r=new Map(this.annotations);t.mapUnsafe.forEach((s,i)=>{n?.overwrite!==!0&&r.has(i)||r.set(i,s)});let o=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return o.annotations=r,o}pipe(){return ce(this,arguments)}toString(){return re(this)}[ft](){return this.toString()}},Tp=new Map,yu=class extends gl{error;constructor(t,n=Tp){super("Fail",n,t),this.error=t}toString(){return`Fail(${re(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[ke](t){return sc(t)&&ne(this.error,t.error)&&ne(this.annotations,t.annotations)}[Ie](){return Ht(st(this._tag))(Ht(ue(this.error))(ue(this.annotations)))}},ia=e=>new pi(e),ex=new pi([]),yl=e=>new pi([new yu(e)]),wp=class extends gl{defect;constructor(t,n=Tp){super("Die",n,t),this.defect=t}toString(){return`Die(${re(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[ke](t){return Eu(t)&&ne(this.defect,t.defect)&&ne(this.annotations,t.annotations)}[Ie](){return Ht(st(this._tag))(Ht(ue(this.defect))(ue(this.annotations)))}},lw=e=>new pi([new wp(e)]),Sl=d(e=>xl(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new pi(e.reasons.map(r=>r.annotate(t,n)))),sc=e=>e._tag==="Fail",Eu=e=>e._tag==="Die",wu=e=>e._tag==="Interrupt";function ZK(e){return Eo("Effect.evaluate: Not implemented")}var aa=e=>({...GK,[R_]:e.op,[un]:e[un]??ZK,[Mr]:e[Mr],[$o]:e[$o],[oc]:e[oc]}),Ho=e=>{let t=aa(e);return function(){let n=Object.create(t);return n[be]=e.single===!1?arguments:arguments[0],n}},__=e=>{let t={[xu]:xu,_tag:e.op,get[e.prop](){return this[be]},...aa(e),toString(){return`${e.op}(${re(this[be])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[be]}},[ke](n){return fw(n)&&n._tag===this._tag&&ne(this[be],n[be])},[Ie](){return Ht(st(e.op),ue(this[be]))}};return function(n){let r=Object.create(t);return r[be]=n,r}},it=__({op:"Success",prop:"value",[un](e){let t=e.getCont(Mr);return t?t[Mr](this[be],e,this):e.yieldWith(this)}}),tx={key:"effect/Cause/StackTrace"},dw={key:"effect/Cause/InterruptorStackTrace"},Bn=__({op:"Failure",prop:"cause",[un](e){let t=this[be],n=!1;e.currentStackFrame&&(t=Sl(t,{mapUnsafe:new Map([[tx.key,e.currentStackFrame]])}),n=!0);let r=e.getCont($o);for(;e.interruptible&&e._interruptedCause&&r;)r=e.getCont($o);return r?r[$o](t,e,n?void 0:this):e.yieldWith(n?Bn(t):this)}}),bo=e=>Bn(yl(e)),Eo=e=>Bn(lw(e)),me=Ho({op:"WithFiber",[un](e){return this[be](e)}}),QK=(function(){class e extends globalThis.Error{}let t=aa({op:"YieldableError",[un](){return bo(this)}});return delete t.toString,Object.assign(e.prototype,t),e})(),Ip=(function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends QK{constructor(n){super(n?.message,n?.cause?{cause:n.cause}:void 0),n&&(Zg(this,n),Object.defineProperty(this,e,{value:n,enumerable:!1}))}toJSON(){return{...this[e],...this}}}})(),ca=e=>{class t extends Ip{_tag=e}return t.prototype.name=e,t},vp="~effect/Cause/NoSuchElementError",nx=e=>N(e,vp),ws=class extends ca("NoSuchElementError"){[vp]=vp;constructor(t){super({message:t})}},Su="~effect/Cause/Done",kp=e=>N(e,Su),M_={[Su]:Su,_tag:"Done",value:void 0},vu=e=>e===void 0?M_:{[Su]:Su,_tag:"Done",value:e},YK=bo(M_),P_=e=>e===void 0?YK:bo(vu(e));var F_="~effect/data/Option",U_={[F_]:{_A:e=>e},...On,[Symbol.iterator](){return new rc(this)}},XK=Object.defineProperty(Object.assign(Object.create(U_),{_tag:"Some",_op:"Some",[ke](e){return rx(e)&&pw(e)&&ne(this.value,e.value)},[Ie](){return Ht(ue(this._tag))(ue(this.value))},toString(){return`some(${re(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:wn(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),eV=ue("None"),tV=Object.assign(Object.create(U_),{_tag:"None",_op:"None",valueOrUndefined:void 0,[ke](e){return rx(e)&&ic(e)},[Ie](){return eV},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),rx=e=>N(e,F_),ic=e=>e._tag==="None",pw=e=>e._tag==="Some",Tu=Object.create(tV),ua=e=>{let t=Object.create(XK);return t.value=e,t};var N_="~effect/data/Result",D_={[N_]:{_A:e=>e,_E:e=>e},...On,[Symbol.iterator](){return new rc(this)}},nV=Object.assign(Object.create(D_),{_tag:"Success",_op:"Success",[ke](e){return ox(e)&&El(e)&&ne(this.success,e.success)},[Ie](){return Ht(ue(this._tag))(ue(this.success))},toString(){return`success(${re(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:wn(this.success)}}}),rV=Object.assign(Object.create(D_),{_tag:"Failure",_op:"Failure",[ke](e){return ox(e)&&bl(e)&&ne(this.failure,e.failure)},[Ie](){return Ht(ue(this._tag))(ue(this.failure))},toString(){return`failure(${re(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:wn(this.failure)}}}),ox=e=>N(e,N_),bl=e=>e._tag==="Failure",El=e=>e._tag==="Success",Ap=e=>{let t=Object.create(rV);return t.failure=e,t},Rp=e=>{let t=Object.create(nV);return t.success=e,t},sx=e=>El(e)?Tu:ua(e.failure),ix=e=>bl(e)?Tu:ua(e.success),L_=d(2,(e,t)=>ic(e)?Ap(t()):Rp(e.value));function vs(e){return(t,n)=>t===n?0:e(t,n)}var wo=vs((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1);var Wo=vs((e,t)=>e<t?-1:1);var hw=d(2,(e,t)=>vs((n,r)=>e(t(n),t(r)))),Iu=hw(wo,e=>e.getTime());var ku=e=>d(2,(t,n)=>e(t,n)===-1),fa=e=>d(2,(t,n)=>e(t,n)===1),wl=e=>d(2,(t,n)=>e(t,n)!==1),vl=e=>d(2,(t,n)=>e(t,n)!==-1),ax=e=>d(2,(t,n)=>t===n||e(t,n)<1?t:n);var D=()=>Tu,L=ua,hi=rx,Se=ic,_e=pw,mr=d(2,(e,{onNone:t,onSome:n})=>Se(e)?t():n(e.value)),oV=e=>t=>_e(e(t)),sV=e=>{for(let t of e)return L(t);return D()},iV=ix,aV=sx,cc=d(2,(e,t)=>Se(e)?t():e.value),cV=d(2,(e,t)=>Se(e)?t():e),uV=d(2,(e,t)=>Se(e)?L(t()):e),fV=d(2,(e,t)=>Se(e)?Kt(t(),Rp):Kt(e,Ap)),lV=e=>{let t=D();for(t of e)if(_e(t))return t;return t},Au=e=>e==null?D():L(e),gw=e=>e===void 0?D():L(e),xw=e=>e===null?D():L(e),dV=e=>(...t)=>Au(e(...t)),Cp=cc(zg),Ko=cc(qo),uc=e=>(...t)=>{try{return L(e(...t))}catch{return D()}},Op=d(2,(e,t)=>{if(_e(e))return e.value;throw t()}),yw=Op(()=>new Error("getOrThrow called on a None")),Kt=d(2,(e,t)=>Se(e)?D():L(t(e.value))),j_=d(2,(e,t)=>Kt(e,()=>t)),pV=j_(void 0),mV=L(void 0);var Ts=d(2,(e,t)=>Se(e)?D():t(e.value)),hV=d(2,(e,t)=>Ts(e,n=>{let r=Ft(t)?t(n):t;return hi(r)?r:L(r)})),Sw=d(2,(e,t)=>Se(e)?D():Au(t(e.value))),Ru=Ts(j),B_=d(2,(e,t)=>Ts(e,()=>t)),gV=d(2,(e,t)=>$_(e,()=>t)),xV=d(2,(e,t)=>n=>Ts(e(n),t)),$_=d(2,(e,t)=>Ts(e,n=>Kt(t(n),()=>n))),H_=(e,t)=>_e(e)&&_e(t)?L([e.value,t.value]):D(),yV=(e,t)=>{if(Se(e))return D();let n=[e.value];for(let r of t){if(Se(r))return D();n.push(r.value)}return L(n)},SV=e=>{if(Symbol.iterator in e){let n=[];for(let r of e){if(Se(r))return D();n.push(r.value)}return L(n)}let t={};for(let n of Object.keys(e)){let r=e[n];if(Se(r))return D();K(t,n,r.value)}return L(t)},z_=d(3,(e,t,n)=>Kt(H_(e,t),([r,o])=>n(r,o))),bV=d(3,(e,t,n)=>{let r=t;for(let o of e)_e(o)&&(r=n(r,o.value));return r}),W_=e=>Se(e)?[]:[e.value],EV=d(2,(e,t)=>{if(Se(e))return[D(),D()];let n=t(e.value);return bl(n)?[L(n.failure),D()]:[D(),L(n.success)]}),wV=d(2,(e,t)=>{if(Se(e))return D();let n=t(e.value);return El(n)?L(n.success):D()}),fc=d(2,(e,t)=>Se(e)?D():t(e.value)?L(e.value):D()),bw=e=>pn((t,n)=>Se(t)?Se(n):Se(n)?!1:e(t.value,n.value)),vV=e=>vs((t,n)=>_e(t)?_e(n)?e(t.value,n.value):1:-1),TV=e=>d(2,(t,n)=>z_(t,n,e)),IV=d(2,(e,t)=>t(e)?L(e):D()),K_=e=>d(2,(t,n)=>Se(t)?!1:e(t.value,n)),kV=K_(cl()),AV=d(2,(e,t)=>Se(e)?!1:t(e.value)),RV=ll(Kt),CV=fl(Kt);var OV=dl(Kt,Ts),_V=L({}),MV=(...e)=>{let n=(e.length===1?e[0]:e[1].bind(e[0]))(),r=n.next();for(;!r.done;){let o=r.value;if(Se(o))return o;r=n.next(o.value)}return L(r.value)};function PV(e){return jo((t,n)=>Se(t)?n:Se(n)?t:L(e.combine(t.value,n.value)),D())}function V_(e){return Qg((t,n)=>Se(t)||Se(n)?D():L(e.combine(t.value,n.value)))}function FV(e){let t=V_(e).combine,n=L(e.initialValue);return jo(t,n,r=>{let o=n;for(let s of r)if(o=t(o,s),Se(o))return o;return o})}var Ut={};dn(Ut,{Do:()=>XV,all:()=>ZV,andThen:()=>GV,bind:()=>e8,bindTo:()=>t8,fail:()=>ge,failVoid:()=>NV,filterOrFail:()=>HV,flatMap:()=>pc,flip:()=>QV,fromNullishOr:()=>DV,fromOption:()=>LV,gen:()=>YV,getFailure:()=>jV,getOrElse:()=>dc,getOrNull:()=>WV,getOrThrow:()=>VV,getOrThrowWith:()=>J_,getOrUndefined:()=>KV,getSuccess:()=>qV,isFailure:()=>we,isResult:()=>lc,isSuccess:()=>_t,let:()=>n8,liftPredicate:()=>$V,makeEquivalence:()=>Ew,map:()=>vo,mapBoth:()=>BV,mapError:()=>Mp,match:()=>Zr,merge:()=>zV,orElse:()=>JV,succeed:()=>le,succeedNone:()=>ww,succeedSome:()=>s8,tap:()=>i8,transposeMapOption:()=>o8,transposeOption:()=>r8,try:()=>_p,void:()=>UV});var le=Rp,ge=Ap,UV=le(void 0);var NV=ge(void 0),DV=d(2,(e,t)=>e==null?ge(t(e)):le(e)),LV=L_,_p=e=>{if(Ft(e))try{return le(e())}catch(t){return ge(t)}else try{return le(e.try())}catch(t){return ge(e.catch(t))}};var lc=ox,we=bl,_t=El,qV=ix,jV=sx,Ew=(e,t)=>pn((n,r)=>we(n)?we(r)&&t(n.failure,r.failure):_t(r)&&e(n.success,r.success)),BV=d(2,(e,{onFailure:t,onSuccess:n})=>we(e)?ge(t(e.failure)):le(n(e.success))),Mp=d(2,(e,t)=>we(e)?ge(t(e.failure)):e),vo=d(2,(e,t)=>_t(e)?le(t(e.success)):e),Zr=d(2,(e,{onFailure:t,onSuccess:n})=>we(e)?t(e.failure):n(e.success)),$V=d(3,(e,t,n)=>t(e)?le(e):ge(n(e))),HV=d(3,(e,t,n)=>pc(e,r=>t(r)?le(r):ge(n(r)))),zV=Zr({onFailure:j,onSuccess:j}),dc=d(2,(e,t)=>we(e)?t(e.failure):e.success),WV=dc(zg),KV=dc(qo),J_=d(2,(e,t)=>{if(_t(e))return e.success;throw t(e.failure)}),VV=J_(j),JV=d(2,(e,t)=>we(e)?t(e.failure):le(e.success)),pc=d(2,(e,t)=>we(e)?ge(e.failure):t(e.success)),GV=d(2,(e,t)=>pc(e,n=>{let r=Ft(t)?t(n):t;return lc(r)?r:le(r)})),ZV=e=>{if(Symbol.iterator in e){let n=[];for(let r of e){if(we(r))return r;n.push(r.success)}return le(n)}let t={};for(let n of Object.keys(e)){let r=e[n];if(we(r))return r;K(t,n,r.success)}return le(t)},QV=e=>we(e)?le(e.failure):ge(e.success),YV=(...e)=>{let n=(e.length===1?e[0]:e[1].bind(e[0]))(),r=n.next();for(;!r.done;){let o=r.value;if(we(o))return o;r=n.next(o.success)}return le(r.value)},XV=le({}),e8=dl(vo,pc),t8=ll(vo),n8=fl(vo);var r8=e=>ic(e)?ww:vo(e.value,ua),o8=d(2,(e,t)=>ic(e)?ww:vo(t(e.value),ua)),ww=le(Tu),s8=e=>le(ua(e)),i8=d(2,(e,t)=>(_t(e)&&t(e.success),e));var G_=v_;var a8=(e,t)=>{let n=t?.length!==void 0?Math.max(1,Math.floor(t.length)):1/0;return{[Symbol.iterator](){let r=0;return{next(){return r<n?{value:e(r++),done:!1}:{done:!0,value:void 0}}}}}};var c8=d(2,(e,t)=>u8(a8(()=>e,{length:t}))),Q_=e=>c8(e,1/0);var Y_=e=>{let n=e[Symbol.iterator]().next();return n.done?D():L(n.value)},X_=e=>{let n=e[Symbol.iterator]().next();if(n.done)throw new Error("headUnsafe: empty iterable");return n.value};var u8=e=>({[Symbol.iterator](){let t=e[Symbol.iterator](),n;function r(){for(;;){if(n===void 0){let s=t.next();if(s.done)return s;n=s.value[Symbol.iterator]()}let o=n.next();if(!o.done)return o;n=void 0}}return{next:r}}});var cx=d(2,(e,t)=>({[Symbol.iterator](){let n=e[Symbol.iterator](),r=0;return{next(){let o=n.next();for(;!o.done;){if(t(o.value,r++))return{done:!1,value:o.value};o=n.next()}return{done:!0,value:void 0}}}}}));var f8=d(2,(e,t)=>Object.hasOwn(e,t));var ux=d(2,(e,t)=>{let n={...e};for(let r of eM(e))K(n,r,t(e[r],r));return n});var eM=e=>Object.keys(e);var l8=e=>d(2,(t,n)=>{for(let r of eM(t))if(!f8(n,r)||!e(t[r],n[r]))return!1;return!0});var tM=e=>{let t=l8(e);return(n,r)=>t(n,r)&&t(r,n)};var Fp=globalThis.Array;var nM=d(2,(e,t)=>{let n=Math.max(1,Math.floor(e)),r=new Fp(n);for(let o=0;o<n;o++)r[o]=t(o);return r}),vw=(e,t)=>e<=t?nM(t-e+1,n=>e+n):[e];var St=e=>Fp.isArray(e)?e:Fp.from(e),rM=e=>Fp.isArray(e)?e:[e];var lx=d(2,(e,t)=>[...e,t]),Tl=d(2,(e,t)=>St(e).concat(St(t)));var oM=Fp.isArray;var or=sw,et=sw;function d8(e,t){return!Number.isFinite(e)||e<0||e>=t.length}var sM=d(2,(e,t)=>{let n=Math.floor(t);if(d8(n,e))throw new Error(`Index out of bounds: ${n}`);return e[n]});var Il=e=>e[e.length-1];var iM=d(2,(e,t)=>{let n=0,r=[];for(let o of e){if(!t(o,n))break;r.push(o),n++}return r});var p8=(e,t)=>{let n=ue(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let o of r)if(ne(o,t))return!1;return r.push(t),!0};var Tw=d(2,(e,t)=>{let n=St(e),r=St(t);return et(n)?et(r)?px(Tl(n,r)):n:r});var fn=()=>[],je=e=>[e],Is=d(2,(e,t)=>e.map(t));var Iw=e=>{let t=[];for(let n of e)_e(n)&&t.push(n.value);return t};var dx=d(2,(e,t)=>{let n=St(e),r=[];for(let o=0;o<n.length;o++)t(n[o],o)&&r.push(n[o]);return r}),kw=d(2,(e,t)=>{let n=[],r=[],o=0;for(let s of e){let i=t(s,o++);_t(i)?r.push(i.success):n.push(i.failure)}return[n,r]});var aM=Gg;var px=e=>{let t=St(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let o of t)p8(n,o)&&r.push(o);return r};var m8=jo((e,t)=>e.concat(t),[]);function cM(){return m8}var uM=/^[+-]?\d+$/,Aw="~effect/BigDecimal",h8={[Aw]:Aw,[Ie](){let e=Up(this);return Ht(ue(e.value),_r(e.scale))},[ke](e){return hc(e)&&E8(this,e)},toString(){return`BigDecimal(${gi(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[ft](){return this.toJSON()},pipe(){return ce(this,arguments)}},hc=e=>N(e,Aw),gr=(e,t)=>{let n=Object.create(h8);return n.value=e,n.scale=t,n},mM=(e,t)=>{if(e!==To&&e%mx===To)throw new RangeError("Value must be normalized");let n=gr(e,t);return n.normalized=n,n},To=BigInt(0),g8=BigInt(1),x8=BigInt(-1);var mx=BigInt(10),hM=mM(To,0);var Up=e=>{if(e.normalized===void 0)if(e.value===To)e.normalized=hM;else{let t=`${e.value}`,n=0;for(let s=t.length-1;s>=0&&t[s]==="0";s--)n++;n===0&&(e.normalized=e);let r=BigInt(t.substring(0,t.length-n)),o=e.scale-n;e.normalized=mM(r,o)}return e.normalized},mc=d(2,(e,t)=>t>e.scale?gr(e.value*mx**BigInt(t-e.scale),t):t<e.scale?gr(e.value/mx**BigInt(e.scale-t),t):e),gM=d(2,(e,t)=>t.value===To?e:e.value===To?t:e.scale>t.scale?gr(mc(t,e.scale).value+e.value,e.scale):e.scale<t.scale?gr(mc(e,t.scale).value+t.value,t.scale):gr(e.value+t.value,e.scale));var la=vs((e,t)=>{let n=wo(fM(e),fM(t));return n!==0?n:e.scale>t.scale?Wo(e.value,mc(t,e.scale).value):e.scale<t.scale?Wo(mc(e,t.scale).value,t.value):Wo(e.value,t.value)}),y8=ku(la);var S8=fa(la);var fM=e=>e.value===To?0:e.value<To?-1:1,b8=e=>e.value<To?gr(-e.value,e.scale):e;var Rw=pn((e,t)=>e.scale>t.scale?mc(t,e.scale).value===e.value:e.scale<t.scale?mc(e,t.scale).value===t.value:e.value===t.value),E8=d(2,(e,t)=>Rw(e,t));var xM=e=>{if(e==="")return L(hM);let t,n,r=e.search(/[eE]/);if(r!==-1){let c=e.slice(r+1);if(t=e.slice(0,r),n=Number(c),t===""||!Number.isSafeInteger(n)||!uM.test(c))return D()}else t=e,n=0;let o,s,i=t.search(/\./);if(i!==-1){let c=t.slice(0,i),u=t.slice(i+1);o=`${c}${u}`,s=u.length}else o=t,s=0;if(!uM.test(o))return D();let a=s-n;return Number.isSafeInteger(a)?L(gr(BigInt(o),a)):D()};var gi=e=>{let t=Up(e);if(Math.abs(t.scale)>=16)return w8(t);let n=t.value<To,r=n?`${t.value}`.substring(1):`${t.value}`,o,s;if(t.scale>=r.length)o="0",s="0".repeat(t.scale-r.length)+r;else{let a=r.length-t.scale;if(a>r.length){let c=a-r.length;o=`${r}${"0".repeat(c)}`,s=""}else s=r.slice(a),o=r.slice(0,a)}let i=s===""?o:`${o}.${s}`;return n?`-${i}`:i},w8=e=>{if(v8(e))return"0e+0";let t=Up(e),n=`${b8(t).value}`,r=n.slice(0,1),o=n.slice(1),s=`${yM(t)?"-":""}${r}`;o!==""&&(s+=`.${o}`);let i=o.length-t.scale;return`${s}e${i>=0?"+":""}${i}`};var v8=e=>e.value===To,yM=e=>e.value<To,T8=e=>e.value>To,Cw=e=>hc(e[0]);var SM=d(Cw,(e,t=0)=>e.scale<=t?e:gr(e.value/mx**BigInt(e.scale-t),t)),Ow=d(Cw,(e,t=0)=>{let n=SM(e,t);return T8(e)&&y8(n,e)?gM(n,gr(g8,t)):n});var _w=d(Cw,(e,t=0)=>{let n=SM(e,t);return yM(e)&&S8(n,e)?gM(n,gr(x8,t)):n});var ole=globalThis.Boolean;var bM=jo((e,t)=>e||t,!1);var Po={};dn(Po,{Any:()=>fS,Arrays:()=>as,Base:()=>Yt,BigInt:()=>xS,Boolean:()=>hS,Context:()=>Br,Declaration:()=>Pi,Enum:()=>qm,FINITE_PATTERN:()=>zm,Filter:()=>Hm,FilterGroup:()=>Nc,IndexSignature:()=>ud,Json:()=>mf,Link:()=>jt,Literal:()=>jr,MutableJson:()=>yk,Never:()=>uS,Null:()=>iS,Number:()=>mS,ObjectKeyword:()=>dS,Objects:()=>df,PropertySignature:()=>cd,STRING_PATTERN:()=>hk,String:()=>pS,Suspend:()=>$m,Symbol:()=>gS,TemplateLiteral:()=>jm,Undefined:()=>aS,Union:()=>br,UniqueSymbol:()=>Bm,Unknown:()=>lS,Void:()=>cS,annotate:()=>Mo,annotateKey:()=>gf,any:()=>GI,appendChecks:()=>Vs,applyToLastLink:()=>Qm,applyToSelfOrLastLinkEncoding:()=>dQ,applyToSelfOrLastLinkEncodingIdempotent:()=>Ni,bigInt:()=>XI,bigIntString:()=>MS,boolean:()=>QI,brand:()=>ck,collectIssues:()=>cs,collectSentinels:()=>Ma,containsUndefined:()=>pk,decodeTo:()=>Ym,defaultParseOptions:()=>$r,enumsToLiterals:()=>hd,finite:()=>kS,flip:()=>is,getAST:()=>fd,getCandidates:()=>ld,getConstructorDescriptor:()=>xk,getContextOwner:()=>AS,getIndexSignatureKeys:()=>Ui,getLastEncoding:()=>md,isAST:()=>KZ,isAny:()=>QZ,isArrays:()=>SS,isBigInt:()=>tQ,isBoolean:()=>eQ,isDeclaration:()=>Pa,isEnum:()=>oQ,isFinite:()=>IS,isJson:()=>yf,isLiteral:()=>lf,isMutable:()=>dk,isNever:()=>UD,isNull:()=>VZ,isNumber:()=>XZ,isObjectKeyword:()=>rQ,isObjects:()=>ND,isOptional:()=>nn,isPattern:()=>dd,isString:()=>YZ,isStringBigInt:()=>_S,isStringFinite:()=>OS,isStringSymbol:()=>PS,isStringTree:()=>GD,isSuspend:()=>DD,isSymbol:()=>nQ,isTemplateLiteral:()=>sQ,isUndefined:()=>JZ,isUnion:()=>KI,isUniqueSymbol:()=>sS,isUnknown:()=>ZZ,isVoid:()=>GZ,makeFilter:()=>Vm,makeFilterByGuard:()=>Jm,mapLink:()=>Fa,mapOrSame:()=>pf,memoizeThunk:()=>Dc,middlewareDecoding:()=>sk,middlewareEncoding:()=>ik,mutableKey:()=>RS,never:()=>JI,null:()=>bS,number:()=>wS,objectKeyword:()=>ZI,objectKeywordToJson:()=>Sk,optional:()=>uk,optionalKey:()=>xf,parameterFromString:()=>Xm,record:()=>lk,replaceChecks:()=>Zm,replaceContext:()=>pd,replaceContextLastLink:()=>hf,replaceEncoding:()=>ct,resolve:()=>TQ,resolveAt:()=>IQ,resolveDescription:()=>RQ,resolveIdentifier:()=>kQ,resolveTitle:()=>AQ,runChecks:()=>gk,string:()=>Ks,struct:()=>Wm,structWithRest:()=>nk,symbol:()=>YI,symbolString:()=>KD,toEncoded:()=>Nn,toType:()=>hn,tuple:()=>vS,tupleWithRest:()=>rk,undefined:()=>ES,union:()=>Km,unknown:()=>Fi,unknownToJson:()=>FS,unknownToStringTree:()=>US,void:()=>VI,withConstructorDefault:()=>fk});var In={};dn(In,{AsyncFiberError:()=>fJ,AsyncFiberErrorTypeId:()=>cJ,Done:()=>uT,DoneTypeId:()=>tJ,ExceededCapacityError:()=>fT,ExceededCapacityErrorTypeId:()=>aJ,IllegalArgumentError:()=>nm,IllegalArgumentErrorTypeId:()=>oJ,InterruptorStackTrace:()=>tT,NoSuchElementError:()=>Hu,NoSuchElementErrorTypeId:()=>eJ,ReasonTypeId:()=>z6,StackTrace:()=>eT,TimeoutError:()=>rJ,TimeoutErrorTypeId:()=>nJ,TypeId:()=>H6,UnknownError:()=>pJ,UnknownErrorTypeId:()=>lJ,annotate:()=>mJ,annotations:()=>gJ,combine:()=>V6,die:()=>oT,done:()=>he,empty:()=>nT,fail:()=>rT,filterInterruptors:()=>t1,findDefect:()=>e1,findDie:()=>Z6,findError:()=>$u,findErrorOption:()=>XU,findFail:()=>J6,findInterrupt:()=>Q6,fromReasons:()=>Ia,hasDies:()=>G6,hasFails:()=>iT,hasInterrupts:()=>fy,hasInterruptsOnly:()=>uy,interrupt:()=>sT,interruptors:()=>aT,isAsyncFiberError:()=>uJ,isCause:()=>Lu,isDieReason:()=>W6,isDone:()=>Hl,isExceededCapacityError:()=>iJ,isFailReason:()=>tm,isIllegalArgumentError:()=>sJ,isInterruptReason:()=>K6,isNoSuchElementError:()=>X6,isReason:()=>qu,isTimeoutError:()=>n1,isUnknownError:()=>dJ,makeDieReason:()=>Bu,makeFailReason:()=>ju,makeInterruptReason:()=>wc,map:()=>ka,pretty:()=>cT,prettyErrors:()=>Y6,reasonAnnotations:()=>hJ,squash:()=>vc});var wM=e=>aa({op:e.label,[un]:e.evaluate});var TM="~effect/Context/Service",qe=function(){function e(){}let t=e;Object.setPrototypeOf(t,I8);let n=(r,o)=>(t.key=r,o?.defaultValue&&(t[Pw]=Pw,t.defaultValue=o.defaultValue),o?.make&&(t.make=o.make),o?.fiberCached&&IM.add(r),t);return arguments.length>0?n(arguments[0],arguments[1]):n},I8={[TM]:TM,...wM({label:"Service",evaluate(e){return it(ze(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return ks(this,e)},use(e){return me(t=>e(ze(t.context,this)))},useSync(e){return me(t=>it(e(ze(t.context,this))))}},IM=new Set,Pw="~effect/Context/Reference",kM="~effect/Context",k8=8,A8=8,Fw=(e,t,n,r)=>{let o=Object.create(R8);return o.cacheRoot=e??o,o.base=t,o.overlay=n,o.depth=r,o._flat=void 0,o.baseHits=0,o},AM=(e,t)=>{t&&(AM(e,t.parent),e.set(t.key,t.value))},RM=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return AM(t,e.overlay),e._flat=t},CM=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),xr(n)},gx=Symbol(),Uw=(e,t)=>{let n=e;for(let o=n.overlay;o;o=o.parent)if(o.key===t)return o.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?gx:(n.overlay&&++n.baseHits>=A8&&(n.base=RM(n),n.overlay=void 0,n.depth=0),r)},xr=e=>Fw(void 0,e,void 0,0),R8={get mapUnsafe(){return RM(this)},...On,[kM]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[ke](e){if(!Np(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[r,o]of t)if(!n.has(r)||!ne(o,n.get(r)))return!1;return!0},[Ie](){return _r(this.mapUnsafe.size)}},OM=(e,t)=>e.cacheRoot===t.cacheRoot,Np=e=>N(e,kM);var _M=e=>!!e[Pw],Tt=()=>C8,C8=xr(new Map),ks=(e,t)=>xr(new Map([[e.key,t]])),Ge=d(3,(e,t,n)=>O8(e,t.key,n)),O8=(e,t,n)=>{let r=e,o=IM.has(t)?void 0:r.cacheRoot;if(r.depth>=k8){let s=new Map(r.mapUnsafe);return s.set(t,n),Fw(o,s,void 0,0)}return Fw(o,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)};var da=d(2,(e,t)=>pa(e,t.key)),pa=(e,t)=>{let n=Uw(e,t);return n===gx?void 0:n},sr=d(2,(e,t)=>{let n=Uw(e,t.key);if(n===gx){if(_M(t))return MM(t);throw _8(t)}return n}),ze=sr,Mw="~effect/Context/defaultValue",MM=e=>Mw in e?e[Mw]:e[Mw]=e.defaultValue(),_8=e=>{let t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let n=t.stack.split(`
9
- `);n.splice(1,3),t.stack=n.join(`
10
- `)}return t},Nw=d(2,(e,t)=>{let n=Uw(e,t.key);return n!==gx?L(n):_M(t)?L(MM(t)):D()}),ir=d(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:CM(e,n=>t.mapUnsafe.forEach((r,o)=>n.set(o,r)))),PM=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((r,o)=>{t.set(o,r)});return xr(t)};var FM=(...e)=>t=>CM(t,n=>{for(let r=0;r<e.length;r++)n.delete(e[r].key)}),Fe=qe;var xx="~effect/time/Duration",Lw=BigInt(0),LM=BigInt(1),M8=BigInt(2),P8=BigInt(10);var F8=BigInt(1e3);var yx=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),qM=e=>yx(e*1e6),UM=(e,t)=>{let n=e.indexOf(".");if(n===-1)return BigInt(e)*t;let r=e[0]==="-",o=e.slice(n+1),s=P8**BigInt(o.length),i=(BigInt(e.slice(r?1:0,n))*s+BigInt(o))*t,a=i/s+(i%s*M8>=s?LM:Lw);return r?-a:a};var U8=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,pt=e=>{switch(typeof e){case"number":return As(e);case"bigint":return Qr(e);case"string":{if(e==="Infinity")return Io;if(e==="-Infinity")return ha;let t=U8.exec(e);if(!t)break;let[n,r,o]=t;if(o==="nano"||o==="nanos")return Qr(UM(r,LM));if(o==="micro"||o==="micros")return Qr(UM(r,F8));let s=Number(r);switch(o){case"milli":case"millis":return As(s);case"second":case"seconds":return qw(s);case"minute":case"minutes":return q8(s);case"hour":case"hours":return j8(s);case"day":case"days":return B8(s);case"week":case"weeks":return $8(s)}break}case"object":{if(e===null)break;if(xx in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(ol)?NM(e):Number.isNaN(e[0])||Number.isNaN(e[1])?ma:e[0]===-1/0||e[1]===-1/0?ha:e[0]===1/0||e[1]===1/0?Io:Pr(yx(e[0]*1e9+e[1]));let t=e,n=0;return t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds?Pr(n):Pr(yx(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return NM(e)},NM=e=>{throw new Error(`Invalid Input: ${e}`)},jM=uc(pt),DM={_tag:"Millis",millis:0},N8={_tag:"Infinity"},D8={_tag:"NegativeInfinity"},L8={[xx]:xx,[Ie](){switch(this.value._tag){case"Millis":{let e=this.value.millis*1e6;return Number.isFinite(e)?ue(yx(e)):_r(this.value.millis)}case"Nanos":return ue(this.value.nanos);default:return al(this.value)}},[ke](e){return Cu(e)&&W8(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[ft](){return this.toJSON()},pipe(){return ce(this,arguments)}},Pr=e=>{let t=Object.create(L8);return typeof e=="number"?isNaN(e)||e===0||Object.is(e,-0)?t.value=DM:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:qM(e)}:t.value=e>0?N8:D8:e===Lw?t.value=DM:t.value={_tag:"Nanos",nanos:e},t},Cu=e=>N(e,xx),Rs=e=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity",Dp=e=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===Lw;case"Infinity":case"NegativeInfinity":return!1}};var ma=Pr(0),Io=Pr(1/0),ha=Pr(-1/0),Qr=e=>Pr(e);var As=e=>Pr(e),qw=e=>Pr(e*1e3),q8=e=>Pr(e*6e4),j8=e=>Pr(e*36e5),B8=e=>Pr(e*864e5),$8=e=>Pr(e*6048e5),vn=e=>H8(pt(e),{onMillis:j,onNanos:t=>Number(t)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0});var Dw=e=>{let t=pt(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return qM(t.value.millis)}},BM=uc(Dw);var H8=d(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),jw=d(3,(e,t,n)=>e.value._tag==="Infinity"||e.value._tag==="NegativeInfinity"||t.value._tag==="Infinity"||t.value._tag==="NegativeInfinity"?n.onInfinity(e,t):e.value._tag==="Millis"?t.value._tag==="Millis"?n.onMillis(e.value.millis,t.value.millis):n.onNanos(Dw(e),t.value.nanos):n.onNanos(e.value.nanos,Dw(t))),z8=vs((e,t)=>jw(e,t,{onMillis:(n,r)=>n<r?-1:n>r?1:0,onNanos:(n,r)=>n<r?-1:n>r?1:0,onInfinity:(n,r)=>n.value._tag===r.value._tag?0:n.value._tag==="Infinity"?1:n.value._tag==="NegativeInfinity"||r.value._tag==="Infinity"?-1:1}));var Bw=(e,t)=>jw(e,t,{onMillis:(n,r)=>n===r,onNanos:(n,r)=>n===r,onInfinity:(n,r)=>n.value._tag===r.value._tag}),$M=ax(z8);var HM=d(2,(e,t)=>jw(e,t,{onMillis:(n,r)=>Pr(n-r),onNanos:(n,r)=>Pr(n-r),onInfinity:(n,r)=>{let o=n.value._tag,s=r.value._tag;return o==="Infinity"?s==="Infinity"?ma:Io:o==="NegativeInfinity"?s==="NegativeInfinity"?ma:ha:s==="Infinity"?ha:Io}}));var W8=d(2,(e,t)=>Bw(e,t));var zM=e=>t=>{let n=e(t);return we(n)?D():L(n.success)};var gc=Fe("effect/Scheduler",{fiberCached:!0,defaultValue:()=>new xi}),KM="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},K8=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},$w=class{buckets=[];scheduleTask(t,n){let r=this.buckets,o=r.length,s,i=0;for(;i<o&&!(r[i][0]>n);i++)s=r[i];s&&s[0]===n?s[1].push(t):i===o?r.push([n,[t]]):r.splice(i,0,[n,[t]])}drain(){let t=this.buckets;return this.buckets=[],t}},xi=class{executionMode;setImmediate;constructor(t="async",n){this.executionMode=t,this.setImmediate=n??(t==="sync"?K8:KM)}shouldYield(t){return t.currentOpCount>=t.maxOpsBeforeYield}makeDispatcher(){return new Hw(this.setImmediate)}},Hw=class{tasks=new $w;running=void 0;setImmediate;constructor(t=KM){this.setImmediate=t}scheduleTask(t,n){this.tasks.scheduleTask(t,n),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let t=this.tasks.drain();for(let n=0;n<t.length;n++){let r=t[n][1];for(let o=0;o<r.length;o++)r[o]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},VM=Fe("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:()=>2048}),JM=Fe("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:()=>!1});var Vo={};dn(Vo,{Class:()=>bx,Error:()=>zw,TaggedClass:()=>V8,TaggedError:()=>_n,taggedEnum:()=>J8});var bx=class extends uu{constructor(e){super(),e&&Zg(this,e)}},V8=e=>class extends bx{_tag=e},J8=()=>new Proxy({},{get(e,t,n){return t==="$is"?jn:t==="$match"?G8:r=>({...r,_tag:t})}});function G8(){if(arguments.length===1){let n=arguments[0];return function(r){return n[r._tag](r)}}let e=arguments[0];return arguments[1][e._tag](e)}var zw=Ip,_n=ca;var GM="~effect/encoding/EncodingError",xa=class extends _n("EncodingError"){[GM]=GM};var wx=e=>Ww(typeof e=="string"?Gw.encode(e):e),Al=e=>{let t=sP(e),n=t.length;if(n%4!==0)return ge(new xa({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf("=");if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!=="="))return ge(new xa({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let o=t.endsWith("==")?2:t.endsWith("=")?1:0,s=new Uint8Array(3*(n/4)-o);for(let i=0,a=0;i<n;i+=4,a+=3){let c=Ex(t.charCodeAt(i))<<18|Ex(t.charCodeAt(i+1))<<12|Ex(t.charCodeAt(i+2))<<6|Ex(t.charCodeAt(i+3));s[a]=c>>16,s[a+1]=c>>8&255,s[a+2]=c&255}return le(s)}catch(o){return ge(new xa({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},eP=e=>vo(Al(e),t=>Zw.decode(t)),tP=e=>QM(typeof e=="string"?Gw.encode(e):e),Kw=e=>{let t=sP(e),n=t.length;if(n%4===1)return ge(new xa({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${n}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return ge(new xa({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let r=n%4===2?`${t}==`:n%4===3?`${t}=`:t;return r=r.replace(/-/g,"+").replace(/_/g,"/"),Al(r)},nP=e=>vo(Kw(e),t=>Zw.decode(t)),rP=e=>YM(typeof e=="string"?Gw.encode(e):e),Vw=e=>{let t="";for(let n=e>>>3;n>0;n--){let r=Math.random()*4294967296>>>0;t+=kl[r>>>24]+kl[r>>>16&255]+kl[r>>>8&255]+kl[r&255]}return t},Jw=e=>{let t=new TextEncoder().encode(e);if(t.length%2!==0)return ge(new xa({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let n=t.length/2,r=new Uint8Array(n);for(let o=0;o<n;o++){let s=XM(t[o*2]),i=XM(t[o*2+1]);r[o]=s<<4|i}return le(r)}catch(n){return ge(new xa({module:"Hex",kind:"Decode",input:e,message:n instanceof Error?n.message:"Invalid input"}))}},oP=e=>vo(Jw(e),t=>Zw.decode(t)),Gw=new TextEncoder,Zw=new TextDecoder,sP=e=>e.replace(/[\n\r]/g,""),Ww=e=>{let t=e.length,n="",r;for(r=2;r<t;r+=3)n+=ga[e[r-2]>>2],n+=ga[(e[r-2]&3)<<4|e[r-1]>>4],n+=ga[(e[r-1]&15)<<2|e[r]>>6],n+=ga[e[r]&63];return r===t+1&&(n+=ga[e[r-2]>>2],n+=ga[(e[r-2]&3)<<4],n+="=="),r===t&&(n+=ga[e[r-2]>>2],n+=ga[(e[r-2]&3)<<4|e[r-1]>>4],n+=ga[(e[r-1]&15)<<2],n+="="),n};function Ex(e){if(e>=ZM.length)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=ZM[e];if(t===255)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}var ga=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],ZM=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],QM=e=>Ww(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),kl=[];for(let e=0;e<256;e++)kl.push(e.toString(16).padStart(2,"0"));var YM=e=>{let t="";for(let n=0;n<e.length;n++)t+=kl[e[n]];return t},XM=e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw new TypeError("Invalid input")};var Yw="effect/Tracer/ParentSpan",yi=class extends qe()(Yw,{fiberCached:!0}){},Z8=e=>e;var Rl=Fe("effect/Tracer/DisablePropagation",{defaultValue:fu}),iP=Fe("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),aP=Fe("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),Xw="effect/Tracer",Tx=Fe(Xw,{fiberCached:!0,defaultValue:()=>Z8({span:e=>new Qw(e)})}),Qw=class{_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(t){this.name=t.name,this.parent=t.parent,this.annotations=t.annotations,this.links=t.links,this.startTime=t.startTime,this.kind=t.kind,this.sampled=t.sampled,this.status={_tag:"Started",startTime:t.startTime},this.attributes=new Map,this.traceId=Ko(t.parent)?.traceId??Vw(32),this.spanId=Vw(16)}end(t,n){this.status={_tag:"Ended",endTime:t,exit:n,startTime:this.status.startTime}}attribute(t,n){this.attributes.set(t,n)}event(t,n,r){this.events.push([t,n,r??{}])}addLinks(t){this.links.push(...t)}};var cP="effect/observability/Metric/FiberRuntimeMetricsKey";var uP=Fe("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),Cl=Fe("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:qo}),kx=Fe("effect/References/TracerEnabled",{defaultValue:cn}),Ou=Fe("effect/References/TracerTimingEnabled",{defaultValue:cn}),Lp=Fe("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),qp=Fe("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),ya=Fe("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),ev=Fe("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),tv=Fe("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),fP=Fe("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),Ax=Fe("effect/References/CurrentLogSpans",{defaultValue:()=>[]});var X8=()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},e6=X8(),Jo=()=>Error.stackTraceLimit,Mn=e=>{e6&&(Error.stackTraceLimit=e)};var Go=e=>{if(e?.captureStackTrace===!1)return e;if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!="boolean")return e;let t=Jo();Mn(3);let n=new Error;return Mn(t),{...e,captureStackTrace:t6(()=>n.stack)}},nv=e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let o=r.split(`
11
- `);if(o[e]!==void 0)return n=o[e].trim(),n}},t6=nv(3);var Rx=class extends gl{fiberId;constructor(t,n=Tp){super("Interrupt",n,"Interrupted"),this.fiberId=t}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[ke](t){return wu(t)&&this.fiberId===t.fiberId&&this.annotations===t.annotations}[Ie](){return Ht(st(`${this._tag}:${this.fiberId}`))(yp(this.annotations))}},xP=e=>new Rx(e),Sc=e=>new pi([new Rx(e)]),yP=e=>e.reasons.some(sc),dv=e=>{let t=e.reasons.find(sc);return t?le(t):ge(e)},_s=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag==="Fail")return le(n.error)}return ge(e)},SP=zM(_s),pv=e=>e.reasons.some(Eu),bP=e=>{let t=e.reasons.find(Eu);return t?le(t):ge(e)},Px=e=>{let t=e.reasons.find(Eu);return t?le(t.defect):ge(e)},mv=e=>e.reasons.some(wu),EP=e=>{let t=e.reasons.find(wu);return t?le(t):ge(e)},Fx=e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag==="Interrupt"&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?le(t):ge(e)},wP=e=>{let t=Fx(e);return we(t)?r6:t.success},r6=new Set,vP=e=>e.reasons.length>0&&e.reasons.every(wu),TP=e=>xr(e.annotations),IP=e=>{let t=new Map;for(let n of e.reasons)if(n.annotations.size>0)for(let[r,o]of n.annotations)t.set(r,o);return xr(t)},Ux=d(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new pi(Tw(e.reasons,t.reasons));return ne(e,n)?e:n}),kP=d(2,(e,t)=>{let n=!1,r=e.reasons.map(o=>sc(o)?(n=!0,new yu(t(o.error),o.annotations)):o);return n?ia(r):e}),o6=e=>{let t={Fail:[],Die:[],Interrupt:[]};for(let n=0;n<e.reasons.length;n++)t[e.reasons[n]._tag].push(e.reasons[n]);return t},Nx=e=>{let t=o6(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error("All fibers interrupted without error"):new globalThis.Error("Empty cause")},hv=(e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let o=Jo();Mn(1);for(let s of e.reasons){if(s._tag==="Interrupt"){r.push(s);continue}n.push(ov(s._tag==="Die"?s.defect:s.error,s.annotations,t))}if(n.length===0){let s=new Error("The fiber was interrupted by:");s.name="InterruptCause",s.stack=c6(s,r);let i=new globalThis.Error("All fibers interrupted without error",{cause:s});i.name="InterruptError",i.stack=`${i.name}: ${i.message}`,n.push(ov(i,r[0].annotations,t))}return Mn(o),n},ov=(e,t,n)=>{let r=typeof e,o;if(e&&r==="object"){if(o=new globalThis.Error(s6(e),{cause:e.cause?ov(e.cause):void 0}),typeof e.name=="string"&&(o.name=e.name),typeof e.stack=="string")o.stack=a6(e.stack,o,t);else{let s=`${o.name}: ${o.message}`;o.stack=t?AP(s,t):s}n?.includeCauseInStack&&(o.stack=CP(o));for(let s of Object.keys(e))s in o||(o[s]=e[s])}else o=new globalThis.Error(e?r==="string"?e:gu(e):`Unknown error: ${e}`);return o},s6=e=>{if(typeof e.message=="string")return e.message;if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return gu(e)},i6=/\((.*)\)/g,a6=(e,t,n)=>{let r=`${t.name}: ${t.message}`,o=(e.startsWith(r)?e.slice(r.length):e).split(`
12
- `),s=[r];for(let i=1;i<o.length&&!/(?:Generator\.next|~effect\/Effect)/.test(o[i]);i++)s.push(o[i]);return n?AP(s.join(`
13
- `),n):s.join(`
14
- `)},AP=(e,t)=>{let n=t?.get(tx.key);return n&&(e=`${e}
15
- ${RP(n)}`),e},c6=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let r of t){let o=r.fiberId!==void 0?`#${r.fiberId}`:"unknown",s=r.annotations.get(dw.key);n.push(` at fiber (${o})`),s&&n.push(RP(s))}return n.join(`
16
- `)},RP=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let o=n.stack();if(o){let s=o.matchAll(i6),i=!1;for(let[,a]of s)i=!0,t.push(` at ${n.name} (${a})`);i||t.push(` at ${n.name} (${o.replace(/^at /,"")})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
17
- `)},Dx=e=>hv(e).map(CP).join(`
18
- `),CP=e=>e.cause?`${e.stack} {
19
- ${OP(e.cause," ")}
20
- }`:e.stack,OP=(e,t)=>{let n=e.stack.split(`
21
- `),r=`${t}[cause]: ${n[0]}`;for(let o=1,s=n.length;o<s;o++)r+=`
22
- ${t}${n[o]}`;return e.cause&&(r+=` {
23
- ${OP(e.cause,`${t} `)}
24
- ${t}}`),r},Cx="~effect/Fiber",u6={_A:j,_E:j},f6={id:0},Sa=()=>globalThis[pl],Ox=class{constructor(t,n=!0){this[Cx]=u6,this.setContext(t),this.id=++f6.id,this.currentOpCount=0,this.interruptible=n,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this.runtimeMetrics?.recordFiberStart(this.context)}[Cx];id;interruptible;currentOpCount;_stack;_observers;_exit;_children;_interruptedCause;_yielded;_running;_deferredInterrupt;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(t){return ze(this.context,t)}addObserver(t){return this._exit?(t(this._exit),Cn):(this._observers.push(t),()=>{if(this._exit)return;let n=this._observers.indexOf(t);n>=0&&this._observers.splice(n,1)})}interruptUnsafe(t,n){if(this._exit)return;let r=Sc(t);this.currentStackFrame&&(r=Sl(r,ks(tx,this.currentStackFrame))),n&&(r=Sl(r,n)),this._interruptedCause=this._interruptedCause?Ux(this._interruptedCause,r):r,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(at(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(t){if(this._exit)return;if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let n=this.runLoop(t);if(n===bu)return;let r=sv.interruptChildren&&sv.interruptChildren(this);if(r!==void 0)return this.evaluate(oe(r,()=>n));this._exit=n,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let o=0;o<this._observers.length;o++)this._observers[o](n);this._observers.length=0,this._stack.length=0,this._children=void 0,this.context=Tt()}runLoop(t){let n=globalThis[pl];globalThis[pl]=this;let r=this._running;this._running=!0;let o=!1,s=t;this.currentOpCount=0;try{for(;;){if(this._deferredInterrupt&&(this._deferredInterrupt=!1,s=at(this._interruptedCause)),this.currentOpCount++,!o&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){o=!0;let i=s;s=oe(Fl,()=>i)}if(s=this.currentTracerContext?this.currentTracerContext(s,this):s[un](this),s===bu){let i=this._yielded;if(xu in i)return this._deferredInterrupt=!1,this._yielded=void 0,i;if(this._deferredInterrupt){this._yielded=void 0,i();continue}return bu}}}catch(i){return N(s,un)?this.runLoop(Eo(i)):Eo(`Fiber.runLoop: Not a valid effect: ${String(s)}`)}finally{this._running=r,globalThis[pl]=n}}getCont(t){if(this._deferredInterrupt)return this._deferredInterrupt=!1,l6;for(;;){let n=this._stack.pop();if(!n)return;let r=n[oc]&&n[oc](this);if(r)return r[t]=r,r;if(n[t])return n}}yieldWith(t){return this._yielded=t,bu}children(){return this._children??=new Set}pipe(){return ce(this,arguments)}setContext(t){let n=this.context;if(this.context=t,n!==void 0&&OM(n,t))return;let r=this.getRef(gc);r!==this.currentScheduler&&(this.currentScheduler=r,this._dispatcher=void 0),this.currentSpan=pa(t,Yw),this.currentLogLevel=this.getRef(ev),this.minimumLogLevel=this.getRef(tv),this.currentStackFrame=this.getRef(Cl),this.maxOpsBeforeYield=this.getRef(VM),this.currentPreventYield=this.getRef(JM),this.runtimeMetrics=pa(t,cP);let o=pa(t,Xw);this.currentTracerContext=o?o.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}},l6={[Mr](e,t){return at(t._interruptedCause)},[$o](e,t){return at(t._interruptedCause)}},sv={interruptChildren:void 0},Lx=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(dw.key,e.currentStackFrame),xr(t)},d6=e=>{if(!(e._children===void 0||e._children.size===0))return yc(e._children)},gv=e=>{let t=e;return t._exit?G(t._exit):Vt(n=>t._exit?n(G(t._exit)):ye(e.addObserver(r=>n(G(r)))))},qx=e=>Vt(t=>{let n=e[Symbol.iterator](),r=[],o;function s(){let i=n.next();for(;!i.done;){if(i.value._exit){r.push(i.value._exit),i=n.next();continue}o=i.value.addObserver(a=>{r.push(a),s()});return}t(G(r))}return s(),ye(()=>o?.())}),_P=e=>{let t=e;return t._exit?t._exit:Vt(n=>t._exit?n(t._exit):ye(e.addObserver(n)))},MP=e=>Vt(t=>{let n=Array.from(e);if(n.length===0)return t(G(fn()));let r=new Array(n.length),o=fn(),s=0,i=!1;for(let a=0;a<n.length&&!i;a++)o.push(n[a].addObserver(c=>{if(s++,c._tag==="Failure")return i=!0,o.forEach(u=>u()),t(c);r[a]=c.value,s===n.length&&t(G(r))}));return ye(()=>{i=!0,o.forEach(a=>a())})}),jx=e=>me(t=>PP(e,t.id)),PP=d(e=>N(e[0],Cx),(e,t,n)=>me(r=>{let o=Lx(r);return o=o&&n?ir(o,n):o??n,e.interruptUnsafe(t,o),Gp(gv(e))})),yc=e=>me(t=>{let n=Lx(t),r=fn();for(let o of e)o.interruptUnsafe(t.id,n),r.push(o);return Gp(qx(r))});var G=it,at=Bn,It=bo,ye=Ho({op:"Sync",[un](e){let t=this[be](),n=e.getCont(Mr);return n?n[Mr](t,e):e.yieldWith(it(t))}}),xe=Ho({op:"Suspend",[un](e){return this[be]()}}),xv=d(e=>e.length>=2||hi(e[0]),(e,t)=>Se(e)?It(t?t():new ws("Effect.fromOption: Option.none")):G(e.value)),Pl=Zr({onFailure:It,onSuccess:G}),FP=e=>e==null?It(new ws):G(e),yv=Ho({op:"Yield",[un](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Ur)},this[be]??0),e.yieldWith(()=>{t=!0})}}),Fl=yv(0),Sv=e=>G(L(e)),Pu=G(D()),UP=e=>Se(e)?Pu:Be(e.value,L),NP=e=>xe(()=>at($e(e))),ba=e=>Eo(e),Bx=e=>xe(()=>It($e(e))),Ae=G(void 0);var DP=e=>{let t=typeof e=="function"?e:e.try,n=typeof e=="function"?r=>new Ml(r,"An error occurred in Effect.try"):e.catch;return xe(()=>{try{return G($e(t))}catch(r){return It($e(()=>n(r)))}})};var bv=e=>Ev(function(t,n){$e(()=>e(n)).then(r=>t(G(r)),r=>t(ba(r)))},e.length!==0),LP=e=>{let t=typeof e=="function"?e:e.try,n=typeof e=="function"?r=>new Ml(r,"An error occurred in Effect.tryPromise"):e.catch;return Ev(function(r,o){let s=i=>{try{r(It($e(()=>n(i))))}catch(a){r(ba(a))}};try{$e(()=>t(o)).then(i=>r(G(i)),s)}catch(i){s(i)}},t.length!==0)},qP=e=>me(t=>e(t.id)),jP=me(G),BP=qP(G),Ev=Ho({op:"Async",single:!1,[un](e){let t=$e(()=>this[be][0].bind(e.currentScheduler)),n=!1,r=!1,o=this[be][1]?new AbortController:void 0,s=t(i=>{n||(n=!0,r?e.evaluate(i):r=i)},o?.signal);return r!==!1?r:(r=!0,e._yielded=()=>{n=!0},o===void 0&&s===void 0?bu:(e._stack.push(p6(()=>(n=!0,o?.abort(),s??Ur))),bu))}}),p6=Ho({op:"AsyncFinalizer",[oc](e){e.interruptible&&(e.interruptible=!1,e._stack.push(ny))},[$o](e,t){return mv(e)?oe(this[be](),()=>at(e)):at(e)}}),Vt=e=>Ev(e,e.length>=2),Jp=Vt(Cn),$P=(...e)=>xe(()=>Ol(e.length===1?e[0]():e[1].call(e[0].self))),wv=(e,...t)=>{let n=t.length===0?function(){return xe(()=>Ol(e.apply(this,arguments)))}:function(){let r=xe(()=>Ol(e.apply(this,arguments)));for(let o=0;o<t.length;o++)r=t[o](r,...arguments);return r};return vv(e.length,n)},vv=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),lP=nv(2),HP=function(){let e=typeof arguments[0]=="string",t=e?arguments[0]:"Effect.fn",n=e?arguments[1]:void 0,r=Jo();Mn(2);let o=new globalThis.Error;return Mn(r),e?(s,...i)=>dP(t,s,o,i,e,n):dP(t,arguments[0],o,Array.prototype.slice.call(arguments,1),e,n)},dP=(e,t,n,r,o,s)=>{let i=typeof t=="function"?t:r.shift().bind(t.self);return vv(i.length,function(...a){let c=xe(()=>{let l=i.apply(this,arguments);return Ce(l)?l:Ol(l)});for(let l=0;l<r.length;l++)c=r[l](c,...a);if(!Ce(c))return c;let u=Jo();Mn(2);let f=new globalThis.Error;return Mn(u),Ea(o?jp(e,s,l=>fv(c,l)):c,Cl,l=>({name:e,stack:lP(()=>f.stack),parent:{name:`${e} (definition)`,stack:lP(()=>n.stack),parent:l}}))})},zP=(e,...t)=>vv(e.length,t.length===0?function(){return pP(()=>e.apply(this,arguments))}:function(){let n=pP(()=>e.apply(this,arguments));for(let r of t)n=r(n);return n}),pP=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return G(r.value);let o=r.value;if(o&&o._tag==="Success"){n=o.value;continue}else{if(o&&o._tag==="Failure")return r.value;{let s=!0;return xe(()=>s?(s=!1,oe(r.value,i=>Ol(t,i))):xe(()=>Ol(e())))}}}}catch(t){return ba(t)}},Ol=Ho({op:"Iterator",single:!1,[Mr](e,t){let n=this[be][0];for(;;){let r=n.next(e);if(r.done)return G(r.value);if(bt(r.value)){if(r.value._tag==="Failure")return r.value}else return t._stack.push(this),r.value;e=r.value.value}},[un](e){return this[Mr](this[be][1],e)}}),$n=d(2,(e,t)=>{let n=G(t);return oe(e,r=>n)}),Ul=e=>Be(e,L),WP=e=>Fu(e,{onFailure:G,onSuccess:It}),Xr=d(2,(e,t)=>oe(e,n=>Ce(t)?t:$e(()=>t(n)))),Si=d(2,(e,t)=>oe(e,n=>$n(Ce(t)?t:$e(()=>t(n)),n))),Gp=e=>oe(e,t=>Ur),KP=e=>Dr(e,It),Tv=(e,t)=>me(n=>Vt(r=>{let o=St(e),s=o.length,i=0,a=!1,c=new Set,u=[],f=(l,p,h)=>{if(i++,l._tag==="Failure"){u.push(...l.cause.reasons),i>=s&&r(at(ia(u)));return}let g=!a;a=!0,r(c.size===0?l:oe(va(yc(c)),()=>l)),g&&t?.onWinner&&t.onWinner({fiber:p,index:h,parentFiber:n})};for(let l=0;l<s;l++){let p=Nu(n,o[l],!0,!0,!1);if(c.add(p),p.addObserver(h=>{c.delete(p),f(h,p,l)}),a)break}return yc(c)})),Iv=(e,t)=>me(n=>Vt(r=>{let o=!1,s=new Set,i=c=>{o=!0,r(s.size===0?c:oe(va(yc(s)),()=>c))},a=0;for(let c of e){if(o)break;let u=a++,f=Nu(n,c,!0,!0,!1);s.add(f),f.addObserver(l=>{s.delete(f);let p=!o;i(l),p&&t?.onWinner&&t.onWinner({fiber:f,index:u,parentFiber:n})})}return yc(s)})),VP=d(e=>Ce(e[1]),(e,t,n)=>Tv([e,t],n)),$x=d(e=>Ce(e[1]),(e,t,n)=>Iv([e,t],n)),oe=d(2,(e,t)=>{let n=Object.create(m6);return n[be]=e,n[Mr]=t.length!==1?r=>t(r):t,n}),m6=aa({op:"OnSuccess",[un](e){return e._stack.push(this),this[be]}}),JP=d(2,(e,t)=>bt(e)?e._tag==="Success"?t.onSuccess(e.value):t.onFailure(e.cause):Cs(e,t)),bt=e=>xu in e,GP=d(2,(e,t)=>bt(e)?e._tag==="Success"?t(e.value):e:oe(e,t)),ZP=e=>oe(e,j),Be=d(2,(e,t)=>oe(e,n=>G($e(()=>t(n))))),QP=d(2,(e,t)=>bt(e)?rF(e,t):Be(e,t)),YP=d(2,(e,t)=>bt(e)?oF(e,t):_v(e,t)),XP=d(2,(e,t)=>bt(e)?sF(e,t):Mv(e,t)),eF=d(2,(e,t)=>{if(bt(e)){if(e._tag==="Success")return e;let n=_s(e.cause);return we(n)?e:t(n.success)}return Lr(e,t)}),Hx=e=>Bn(Sc(e)),Nl=e=>e._tag==="Success";var tF=e=>e._tag==="Failure";var nF=e=>e._tag==="Failure"?le(e.cause):ge(e);var Ur=it(void 0),rF=d(2,(e,t)=>e._tag==="Success"?it(t(e.value)):e),oF=d(2,(e,t)=>{if(e._tag==="Success")return e;let n=_s(e.cause);return we(n)?e:bo(t(n.success))}),sF=d(2,(e,t)=>{if(e._tag==="Success")return it(t.onSuccess(e.value));let n=_s(e.cause);return we(n)?e:bo(t.onFailure(n.success))});var iF=d(2,(e,t)=>Nl(e)?t:e),aF=d(2,(e,t)=>Nl(e)?t.onSuccess(e.value):t.onFailure(e.cause));var cF=e=>{let t=[];for(let n of e)n._tag==="Failure"&&t.push(...n.cause.reasons);return t.length===0?Ur:Bn(ia(t))};var uF=e=>e,fF=e=>me(t=>G(Nw(t.context,e))),h6=e=>me(t=>xv(Nw(t.context,e))),Dl=d(2,(e,t)=>me(n=>{let r=n.context,o=t(r);return r===o?e:(n.setContext(o),Ps(e,()=>{n.setContext(r)}))})),Ea=d(3,(e,t,n)=>Dl(e,r=>{let o=sr(r,t),s=n(o);return o===s?r:Ge(r,t,s)})),lF=(e,t,n)=>va(me(r=>{let o=sr(r.context,e),s=t(o);return r.setContext(Ge(r.context,e,s)),Ms(sr(r.context,Ec),i=>{let a=sr(r.context,e),c;if(n?.reset===void 0){if(a!==s)return Ae;c=o}else c=n.reset(o,s,a);return r.setContext(Ge(r.context,e,c)),Ae})})),kv=()=>g6,g6=me(e=>G(e.context)),bc=e=>me(t=>e(t.context)),dF=d(2,(e,t)=>Dl(e,Xe(t))),wa=d(2,(e,t)=>bt(e)?e:Dl(e,ir(t))),Nr=function(){return arguments.length===1?d(2,(e,t)=>mP(e,arguments[0],t)):d(3,(e,t,n)=>mP(e,t,n)).apply(this,arguments)},mP=(e,t,n)=>Dl(e,Ge(t,n)),zx=d(3,(e,t,n)=>oe(n,r=>Nr(e,t,r))),pF=d(e=>Ce(e[1]),(e,t,n)=>Av(e,t,(r,o)=>[r,o],n)),Av=d(e=>Ce(e[1]),(e,t,n,r)=>r?.concurrent?Be($l([e,t],{concurrency:2}),([o,s])=>$e(()=>n(o,s))):oe(e,o=>Be(t,s=>$e(()=>n(o,s))))),mF=d(e=>Ce(e[0]),(e,t,n)=>Kv(e,t,n?r=>It(n(r)):()=>It(new ws))),hF=d(2,(e,t)=>oe(t,n=>n?Ul(e):Pu)),Rv=d(2,(e,t)=>Array.from({length:t},()=>e)),gF=d(e=>Ce(e[0]),(e,t,n)=>$l(Rv(e,t),n)),Wx=d(e=>Ce(e[0]),(e,t)=>bi({while:cn,body:Xe(t?.disableYield?e:oe(e,n=>Fl)),step:Cn})),Dr=d(2,(e,t)=>{let n=Object.create(x6);return n[be]=e,n[$o]=t.length!==1?r=>t(r):t,n}),x6=aa({op:"OnFailure",[un](e){return e._stack.push(this),this[be]}}),Cv=d(3,(e,t,n)=>Dr(e,r=>t(r)?$e(()=>n(r)):at(r))),Ll=d(3,(e,t,n)=>Dr(e,r=>{let o=t(r);return we(o)?at(o.failure):$e(()=>n(o.success,r))})),Lr=d(2,(e,t)=>Ll(e,_s,n=>t(n))),xF=e=>Fu(e,{onFailure:t=>nx(t)?Pu:It(t),onSuccess:Sv}),yF=d(2,(e,t)=>Ll(e,Px,t)),SF=d(2,(e,t)=>Dr(e,n=>Xr($e(()=>t(n)),at(n)))),bF=d(3,(e,t,n)=>Cv(e,t,r=>Xr($e(()=>n(r)),at(r)))),Kx=d(3,(e,t,n)=>Dr(e,r=>{let o=t(r);return we(o)?at(r):Xr($e(()=>n(o.success,r)),at(r))})),Ov=d(2,(e,t)=>Kx(e,_s,n=>t(n))),EF=d(3,(e,t,n)=>{let r=Array.isArray(t)?o=>N(o,"_tag")&&t.includes(o._tag):jn(t);return Ov(e,o=>r(o)?n(o):Ae)}),wF=d(2,(e,t)=>Kx(e,Px,n=>t(n))),Zp=d(e=>Ce(e[0]),(e,t,n,r)=>Dr(e,o=>{let s=_s(o);return we(s)?at(s.failure):t(s.success)?$e(()=>n(s.success)):r?$e(()=>r(s.success)):at(o)})),Vx=d(e=>Ce(e[0]),(e,t,n,r)=>Dr(e,o=>{let s=_s(o);if(we(s))return at(s.failure);let i=t(s.success);return we(i)?r?$e(()=>r(i.failure)):at(o):$e(()=>n(i.success))})),Jx=d(e=>Ce(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?s=>N(s,"_tag")&&t.includes(s._tag):jn(t);return Zp(e,o,n,r)}),vF=d(e=>Ce(e[0]),(e,t,n)=>{let r;return Vx(e,o=>(r??=Object.keys(t),N(o,"_tag")&&Gr(o._tag)&&r.includes(o._tag)?le(o):ge(o)),o=>$e(()=>t[o._tag](o)),n)}),TF=d(e=>Ce(e[0]),(e,t,n,r,o)=>Zp(e,s=>jn(s,t)&&N(s,"reason"),s=>{let i=s.reason;return jn(i,n)?r(i,s):o?$e(()=>o(i,s)):It(s)})),IF=d(e=>Ce(e[0]),(e,t,n,r)=>{let o;return Zp(e,s=>jn(s,t)&&N(s,"reason")&&N(s.reason,"_tag")&&Gr(s.reason._tag),s=>{let i=s.reason;return o??=Object.keys(n),o.includes(i._tag)?$e(()=>n[i._tag](i,s)):r?$e(()=>r(i,s)):It(s)})}),kF=d(2,(e,t)=>Vx(e,n=>jn(n,t)&&N(n,"reason")?le(n.reason):ge(n),It)),_v=d(2,(e,t)=>Lr(e,n=>Bx(()=>t(n)))),Mv=d(2,(e,t)=>Fu(e,{onFailure:n=>Bx(()=>t.onFailure(n)),onSuccess:n=>ye(()=>t.onSuccess(n))})),Gx=e=>Lr(e,ba),AF=d(2,(e,t)=>Lr(e,n=>ye(t))),RF=e=>xe(()=>{let t=e[Symbol.iterator](),n=t.next();if(n.done)return ba(new Error("Received an empty collection of effects"));function r(o){let s=t.next();return s.done?o.value:Lr(o.value,i=>r(s))}return r(n)}),Pv=e=>Lr(e,t=>oe(Fl,()=>Pv(e))),CF=d(e=>Ce(e[0]),(e,t)=>{if(!t?.log)return Fu(e,{onFailure:r=>Ae,onSuccess:r=>Ae});let n=Fs(t.log===!0?void 0:t.log);return Cs(e,{onFailure(r){let o=dv(r);return we(o)?at(o.failure):t.message===void 0?n(r):n(t.message,r)},onSuccess:r=>Ae})}),Zx=d(e=>Ce(e[0]),(e,t)=>{if(!t?.log)return Cs(e,{onFailure:r=>Ae,onSuccess:r=>Ae});let n=Fs(t.log===!0?void 0:t.log);return Cs(e,{onFailure:r=>t.message===void 0?n(r):n(t.message,r),onSuccess:r=>Ae})}),OF=e=>Qx(e,{onFailure:D,onSuccess:L}),xc=e=>Qp(e,{onFailure:ge,onSuccess:le}),Cs=d(2,(e,t)=>{let n=Object.create(y6);return n[be]=e,n[Mr]=t.onSuccess.length!==1?r=>t.onSuccess(r):t.onSuccess,n[$o]=t.onFailure.length!==1?r=>t.onFailure(r):t.onFailure,n}),y6=aa({op:"OnSuccessAndFailure",[un](e){return e._stack.push(this),this[be]}}),Fv=d(2,(e,t)=>Cs(e,{onFailure:n=>ye(()=>t.onFailure(n)),onSuccess:n=>ye(()=>t.onSuccess(n))})),Fu=d(2,(e,t)=>Cs(e,{onFailure:n=>{let r=n.reasons.find(sc);return r?$e(()=>t.onFailure(r.error)):at(n)},onSuccess:t.onSuccess})),Qx=d(2,(e,t)=>Fu(e,{onFailure:n=>ye(()=>t.onFailure(n)),onSuccess:n=>ye(()=>t.onSuccess(n))})),Qp=d(2,(e,t)=>{if(bt(e)){if(e._tag==="Success")return it(t.onSuccess(e.value));let n=_s(e.cause);return we(n)?e:it(t.onFailure(n.success))}return Qx(e,t)}),_F=d(2,(e,t)=>bt(e)?e._tag==="Success"?it(t.onSuccess(e.value)):it(t.onFailure(e.cause)):Fv(e,t)),Yp=e=>bt(e)?it(e):S6(e),S6=Ho({op:"Exit",[un](e){return e._stack.push(this),this[be]},[Mr](e,t,n){return G(n??it(e))},[$o](e,t,n){return G(n??Bn(e))}}),MF=Qp({onFailure:()=>!0,onSuccess:()=>!1}),PF=Qp({onFailure:()=>!1,onSuccess:()=>!0}),FF=d(2,(e,t)=>Xr(Du(t),e)),Uv=d(2,(e,t)=>$x(e,oe(Du(t.duration),t.orElse))),UF=d(2,(e,t)=>Uv(e,{duration:t,orElse:()=>It(new $p)})),NF=d(2,(e,t)=>$x(Ul(e),$n(Du(t),D()))),DF=e=>to(t=>{let n=t.monotonicTimeNanosUnsafe();return Be(e,r=>[Qr(t.monotonicTimeNanosUnsafe()-n),r])}),iv="~effect/Scope",av="~effect/Scope/Closeable",Ec=qe("effect/Scope"),Nv=(e,t)=>xe(()=>ql(e,t)??Ae),ql=(e,t)=>{if(e.state._tag==="Closed")return;let n={_tag:"Closed",exit:t};if(e.state._tag==="Empty"){e.state=n;return}let r=e.state;if(e.state=n,r.finalizer!==void 0)return r.finalizer(t);let o=r.finalizers;if(!(o===void 0||o.size===0))return o.size===1?o.values().next().value(t):E6(e,o,t)},b6=(e,t)=>Nl(e)?t:Dr(t,n=>at(Ux(e.cause,n))),E6=wv(function*(e,t,n){let r=[],o=[],s=Array.from(t.values()),i=Sa();for(let a=s.length-1;a>=0;a--){let c=s[a];e.strategy==="sequential"?r.push(yield*Yp(c(n))):o.push(Nu(i,c(n),!0,!0,"inherit"))}return o.length>0&&(r=yield*qx(o)),yield*cF(r)});var LF=(e,t)=>{let n=Uu(t);if(e.state._tag==="Closed")return n.state=e.state,n;let r={};return Mu(e,r,o=>Nv(n,o)),Mu(n,r,o=>ye(()=>Dv(e,r))),n},Ms=(e,t)=>xe(()=>e.state._tag==="Closed"?t(e.state.exit):(Mu(e,{},t),Ae)),qF=(e,t)=>Ms(e,Xe(t)),Mu=(e,t,n)=>{if(e.state._tag==="Empty")e.state={_tag:"Open",finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag==="Open"){let r=e.state;r.finalizer!==void 0?(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n)):r.finalizers===void 0?(r.finalizerKey=t,r.finalizer=n):r.finalizers.set(t,n)}},Dv=(e,t)=>{if(e.state._tag==="Open"){let n=e.state;n.finalizerKey===t?(n.finalizerKey=void 0,n.finalizer=void 0):n.finalizers!==void 0&&n.finalizers.delete(t)}},jF=e=>e.state._tag!=="Open"?0:e.state.finalizer!==void 0?1:e.state.finalizers?.size??0,Uu=(e="sequential")=>({[av]:av,[iv]:iv,strategy:e,state:w6}),w6={_tag:"Empty"};var Xp=Ec,BF=Nr(Ec),Yx=e=>me(t=>{let n=t.context,r=Uu();return t.setContext(Ge(t.context,Ec,r)),Ps(e,o=>(t.setContext(n),ql(r,o)))});var Xx=e=>xe(()=>{let t=Uu();return ar(e(t),n=>xe(()=>ql(t,n)??Ae))}),ey=(e,t,n)=>bc(r=>eo(o=>oe(Xp,s=>Si(n?.interruptible?o(e):e,i=>Ms(s,a=>wa(t(i,a),r)))))),jl=e=>oe(Xp,t=>bc(n=>Ms(t,r=>wa(e(r),n)))),Ps=Ho({op:"OnExit",single:!1,[un](e){return e._stack.push(this),this[be][0]},[oc](e){e.interruptible&&this[be][2]!==!0&&(e._stack.push(ny),e.interruptible=!1)},[Mr](e,t,n){n??=it(e);let r=this[be][1](n);return r?oe(r,o=>n):n},[$o](e,t,n){n??=Bn(e);let r=this[be][1](n);return r?oe(b6(n,r),o=>n):n}}),ar=d(2,Ps),$F=d(2,(e,t)=>ar(e,n=>t)),Lv=d(3,(e,t,n)=>ar(e,r=>t(r)?n(r):Ae)),qv=d(3,(e,t,n)=>ar(e,r=>{let o=t(r);return we(o)?Ae:n(o.success,r)})),jv=d(2,(e,t)=>qv(e,nF,t)),HF=d(3,(e,t,n)=>Lv(e,r=>r._tag!=="Failure"?!1:t(r.cause),r=>n(r.cause))),Bv=d(3,(e,t,n)=>ar(e,r=>{if(r._tag!=="Failure")return Ae;let o=t(r.cause);return we(o)?Ae:n(o.success,r.cause)})),ty=d(2,(e,t)=>Bv(Fx,t)(e)),zF=(e,t,n)=>eo(r=>oe(e,o=>Ps(r(t(o)),s=>n(o,s),!0))),WF=e=>ey(e,t=>N(t,Symbol.asyncDispose)?bv(()=>t[Symbol.asyncDispose]()):ye(()=>t[Symbol.dispose]())),$v=d(2,(e,t)=>ye(()=>{let n=vn(pt(t)),r=Number.isFinite(n),o=sy(!1),s=0,i=!1,a,c=oe(o.await,()=>a);return[me(u=>{let f=u.getRef(ko),l=r?f.currentTimeMillisUnsafe():0;return i||l<s?a??c:(i=!0,o.closeUnsafe(),a=void 0,ar(e,p=>ye(()=>{i=!1,s=f.currentTimeMillisUnsafe()+n,a=p,o.openUnsafe()})))}),ye(()=>{s=0,o.closeUnsafe(),a=void 0})]})),Hv=d(2,(e,t)=>Be($v(e,t),n=>n[0])),KF=e=>Hv(e,Io),Bl=me(e=>at(Sc(e.id))),va=e=>me(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(ny)),e)),VF=Ho({op:"SetInterruptible",[oc](e){if(e.interruptible=this[be],e._interruptedCause&&e.interruptible)return()=>at(e._interruptedCause)}}),ny=VF(!0),v6=VF(!1),JF=e=>{if(e.interruptible=!0,e._stack.push(v6),e._interruptedCause)return at(e._interruptedCause)},zv=e=>me(t=>t.interruptible?e:JF(t)??e),eo=e=>me(t=>t.interruptible?(t.interruptible=!1,t._stack.push(ny),e(zv)):e(j)),GF=e=>me(t=>{if(t.interruptible)return e(j);let n=JF(t),r=e(va);return n??r}),ZF=Be(ey(ye(()=>new AbortController),e=>ye(()=>e.abort())),e=>e.signal),$l=(e,t)=>Es(e)?t?.mode==="result"?Yr(e,xc,t):Yr(e,j,t):t?.discard?t.mode==="result"?Yr(Object.values(e),xc,t):Yr(Object.values(e),j,t):xe(()=>{let n={};return $n(Yr(Object.entries(e),([r,o])=>Be(t?.mode==="result"?xc(o):o,s=>{K(n,r,s)}),{discard:!0,concurrency:t?.concurrency}),n)}),Wv=d(e=>Es(e[0])&&!Ce(e[0]),(e,t,n)=>Be(Yr(e,(r,o)=>xc(t(r,o)),n),r=>kw(r,j))),QF=d(3,(e,t,n)=>{let r=St(e);return r.length===0?ye(t):xe(()=>{let o=0,s=t();return Be(bi({while:()=>o<r.length,body:()=>n(s,r[o],o),step(i){s=i,o++}}),()=>s)})}),YF=d(e=>Es(e[0])&&!Ce(e[0]),(e,t,n)=>oe(Wv(e,t,{concurrency:n?.concurrency}),([r,o])=>or(r)?It(r):n?.discard?Ae:G(o))),XF=d(e=>Es(e[0])&&!Ce(e[0]),(e,t)=>xe(()=>{let n=e[Symbol.iterator](),r=n.next();return r.done?G(D()):eU(n,0,t,r.value)})),eU=(e,t,n,r)=>oe(n(r,t),o=>{if(o)return G(L(r));let s=e.next();return s.done?G(D()):eU(e,t+1,n,s.value)}),tU=d(e=>Es(e[0])&&!Ce(e[0]),(e,t)=>xe(()=>{let n=e[Symbol.iterator](),r=n.next();return r.done?G(D()):nU(n,0,t,r.value)})),nU=(e,t,n,r)=>oe(n(r,t),o=>{if(_t(o))return G(L(o.success));let s=e.next();return s.done?G(D()):nU(e,t+1,n,s.value)}),bi=Ho({op:"While",[Mr](e,t){return this[be].step(e),this[be].while()?(t._stack.push(this),this[be].body()):Ur},[un](e){return this[be].while()?(e._stack.push(this),this[be].body()):Ur}}),Yr=d(e=>typeof e[1]=="function",(e,t,n)=>xe(()=>{let r=n?.concurrency??1,o=r==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,r);if(o===1)return T6(e,t,n);let s=St(e),i=s.length;if(i===0)return n?.discard?Ae:G([]);let a=n?.discard?void 0:new Array(i),c=I6({f:t,out:a},s,{concurrency:o});return c?$n(c,a):G(a)})),rU=e=>oe(e,t=>{let n=t[Symbol.iterator]().next();return n.done?It(new ws):G(n.value)}),T6=(e,t,n)=>xe(()=>{let r=n?.discard?void 0:[],o=e[Symbol.iterator](),s=o.next(),i=0;return $n(bi({while:()=>!s.done,body:()=>t(s.value,i++),step:a=>{r&&r.push(a),s=o.next()}}),r)}),oU=e=>{let t=e.onItem,n=e.step,r=(o,s,i,a)=>{for(;i<a;i++){let c=s[i],u=t(o,c,i);if(!bt(u))return oe(Yp(u),l=>n(o,c,l,i)??r(o,s,i+1,a)??Ae);let f=n(o,c,u,i);if(f)return f._tag==="Failure"?f:void 0}};return(o,s,i)=>{let a=0,c=i?.end??s.length,u=i?.concurrency??1;if(u===1)return r(o,s,0,c);let f=i?.orderedStep===!0,l=!1,p,h,g,x=!1,S,w,E=a,y=f?new Array(c):void 0,v=R=>{let C=Eo(R);return S=C,l=!0,x=!0,h&&h.size>0?oe(va(yc(Array.from(h))),()=>C):C},b=(R,C,P)=>{if(!f)return n(o,R,C,P);if(S)return S;for(y[P]=C;E<c;){let B=y[E];if(B===void 0)return;y[E]=void 0;let F=E++,Z=n(o,s[F],B,F);if(Z)return Z}},T=()=>{let R=!1;for(;!S&&a<c;a++){let C=s[a],P=w??t(o,C,a);if(bt(P)){if(S=b(C,P,a),S)break}else if(p){w=void 0;let B=Nu(p,P,!0,!0,"inherit");if(B._exit){if(S=b(C,B._exit,a),S)break;continue}h.add(B);let F=a;if(B.addObserver(Z=>{h.delete(B);try{if(S){if(!x&&Z._tag==="Failure")for(let z of Z.cause.reasons)z._tag!=="Interrupt"&&(S._tag==="Failure"?S.cause.reasons.push(z):S=Bn(ia([z])))}else{let z=b(C,Z,F);z&&(S=z._tag==="Failure"?Bn(ia(z.cause.reasons.slice())):z,T())}if(R){let z=T();z&&g(z)}else l&&h.size===0&&g(S??Ae)}catch(z){g(v(z))}}),h.size<u)continue;R=!0,a++;return}else return Vt(B=>{p=Sa(),h=new Set,w=P,g=B;let F;try{F=T()}catch(Z){return B(v(Z))}return F?B(F):xe(()=>(S=Ur,x=!0,h?yc(h):Ae))})}if(l=!0,S){if(h&&h.size>0){let C=Lx(p);h.forEach(P=>P.interruptUnsafe(p.id,C));return}if(g||S._tag==="Failure")return S}else if(g)if(h)h.size===0&&g(Ae);else return Ur};return T()}},em=()=>oU,I6=oU({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag==="Failure")return n;e.out&&(e.out[r]=n.value)}}),Kv=d(3,(e,t,n)=>oe(e,r=>t(r)?G(r):n(r))),Vv=d(3,(e,t,n)=>oe(e,r=>{let o=t(r);return we(o)?n(o.failure):G(o.success)})),sU=d(e=>Ce(e[0]),(e,t,n)=>Vv(e,t,n?r=>It(n(r)):()=>It(new ws))),iU=d(e=>Es(e[0])&&!Ce(e[0]),(e,t,n)=>xe(()=>{let r=[];return $n(Yr(e,(o,s)=>{let i=t(o,s);return typeof i=="boolean"?(i&&r.push(o),Ae):Be(i,a=>{a&&r.push(o)})},{discard:!0,concurrency:n?.concurrency}),r)})),aU=d(e=>Es(e[0])&&!Ce(e[0]),(e,t)=>xe(()=>{let n=[];for(let r of e){let o=t(r);_t(o)&&n.push(o.success)}return G(n)})),cU=d(e=>Es(e[0])&&!Ce(e[0]),(e,t,n)=>xe(()=>{let r=[];return $n(Yr(e,o=>Be(t(o),s=>{_t(s)&&r.push(s.success)}),{discard:!0,concurrency:n?.concurrency}),r)})),uU=G({}),fU=ll(Be),lU=dl(Be,oe),dU=fl(Be);var pU=d(e=>Ce(e[0]),(e,t)=>me(n=>(B6(),G(Nu(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),Nu=(e,t,n=!1,r=!1,o=!1)=>{let s=e,i=o==="inherit"?s.interruptible:!o,a=new Ox(s.context,i);return n?a.evaluate(t):s.currentDispatcher.scheduleTask(()=>a.evaluate(t),0),!r&&!a._exit&&(s.children().add(a),a.addObserver(()=>s._children.delete(a))),a},mU=d(e=>Ce(e[0]),(e,t)=>me(n=>G(Nu(n,e,t?.startImmediately,!0,t?.uninterruptible)))),hU=e=>me(t=>{let n=t._children&&new Set(t._children);return ar(e,r=>{let o=t._children;return o===void 0||o.size===0?Ae:(n&&(o=cx(o,s=>!n.has(s))),Gp(qx(o)))})}),Jv=d(e=>Ce(e[0]),(e,t,n)=>me(r=>{let o=Nu(r,e,n?.startImmediately,!0,n?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed"){let s={};Mu(t,s,()=>qP(a=>a===o.id?Ae:jx(o))),o.addObserver(()=>Dv(t,s))}else o.interruptUnsafe(r.id,Lx(r));return G(o)})),gU=d(e=>Ce(e[0]),(e,t)=>oe(Xp,n=>Jv(e,n,t))),Ta=e=>(t,n)=>{let r=new Ox(n?.scheduler?Ge(e,gc,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal)if(n.signal.aborted)r.interruptUnsafe();else{let o=()=>r.interruptUnsafe();n.signal.addEventListener("abort",o,{once:!0}),r.addObserver(()=>n.signal.removeEventListener("abort",o))}return n?.onFiberStart&&n.onFiberStart(r),r},xU=d(2,(e,t)=>{if(e._exit)return e;if(t.state._tag==="Closed")return e.interruptUnsafe(e.id),e;let n={};return Mu(t,n,()=>jx(e)),e.addObserver(()=>Dv(t,n)),e}),yU=Ta(Tt()),Gv=e=>{let t=Ta(e);return(n,r)=>{let o=t(n,r);return r?.onExit&&o.addObserver(r.onExit),s=>o.interruptUnsafe(s)}},SU=Gv(Tt()),ry=e=>{let t=Ta(e);return(n,r)=>{let o=t(n,r);return new Promise(s=>{o.addObserver(i=>s(i))})}},bU=ry(Tt()),Zv=e=>{let t=ry(e);return(n,r)=>t(n,r).then(o=>{if(o._tag==="Failure")throw Nx(o.cause);return o.value})},EU=Zv(Tt()),oy=e=>{let t=Ta(e);return n=>{if(bt(n))return n;let r=new xi("sync"),o=t(n,{scheduler:r});return o._dispatcher?.flush(),o._exit??Eo(new Kp(o))}},wU=oy(Tt()),Qv=e=>{let t=oy(e);return n=>{let r=t(n);if(r._tag==="Failure")throw Nx(r.cause);return r.value}},vU=Qv(Tt()),hP=G(!0),gP=G(!1),cv=class{waiters=[];scheduled=void 0;_isOpen;constructor(t){this._isOpen=t}scheduleUnsafe(t){if(this.waiters.length===0)return hP;if(this.scheduled===void 0)this.scheduled=this.waiters,t.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let n=0;n<this.waiters.length;n++)this.scheduled.push(this.waiters[n]);return this.waiters=[],hP}flushScheduled=()=>{if(this.scheduled===void 0)return;let t=this.scheduled;this.scheduled=void 0;for(let n=0;n<t.length;n++)t[n](Ur)};flushWaiters(){let t=this.waiters;this.waiters=[],this.flushScheduled();for(let n=0;n<t.length;n++)t[n](Ur)}open=me(t=>this._isOpen?gP:(this._isOpen=!0,this.scheduleUnsafe(t)));release=me(t=>this._isOpen?gP:this.scheduleUnsafe(t));openUnsafe(){return this._isOpen?!1:(this._isOpen=!0,this.flushWaiters(),!0)}await=Vt(t=>this._isOpen?t(Ae):(this.waiters.push(t),ye(()=>{let n=this.waiters.indexOf(t);n!==-1?this.waiters.splice(n,1):this.scheduled!==void 0&&(n=this.scheduled.indexOf(t),n!==-1&&this.scheduled.splice(n,1))})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=ye(()=>this.closeUnsafe());whenOpen=t=>oe(this.await,()=>t);isOpen(){return this._isOpen}},sy=e=>new cv(e??!1),TU=e=>ye(()=>sy(e)),IU=me(e=>G(e.getRef(Tx))),kU=d(2,(e,t)=>Nr(e,Tx,t)),AU=Nr(kx),RU=Nr(Ou),uv=BigInt(0),k6={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:uv,endTime:uv,exit:Ur},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},A6=e=>Object.assign(Object.create(k6),e),CU=e=>e?ze(e.annotations,Rl)?e._tag==="Span"?CU(Ko(e.parent)):D():L(e):D(),Yv=(e,t,n)=>{let r=!e.getRef(kx)||n?.annotations&&ze(n.annotations,Rl),o=n?.parent!==void 0?L(n.parent):n?.root?D():CU(e.currentSpan),s;if(r)s=A6({name:t,parent:o,annotations:Ge(n?.annotations??Tt(),Rl,!0)});else{let i=e.getRef(Tx),a=e.getRef(ko),c=e.getRef(Ou),u=e.getRef(Lp),f=e.getRef(qp),l=n?.level??e.getRef(iP),p=n?.links!==void 0?[...f,...n.links]:f.length===0?[]:f.slice();s=i.span({name:t,parent:o,annotations:n?.annotations??Tt(),links:p,startTime:c?a.currentTimeNanosUnsafe():BigInt(0),kind:n?.kind??"internal",root:n?.root??Se(o),sampled:n?.sampled??(_e(o)&&o.value.sampled===!1?!1:!GU(e.getRef(aP),l))});for(let h in u)s.attribute(h,u[h]);if(n?.attributes!==void 0)for(let h in n.attributes)s.attribute(h,n.attributes[h])}return s},OU=(e,t)=>me(n=>G(Yv(n,e,t))),Os=(e,t)=>va(me(n=>{let r=sr(n.context,Ec),o=Yv(n,e,t??{}),s=n.getRef(ko),i=n.getRef(Ou);return $n(Ms(r,a=>iy(o,a,s,i)),o)})),_U=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Go(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return oe(Os(t,n),o=>_l(r,o,n))}return r=>oe(Os(t,n),o=>_l(r,o,n))},R6=(e,t)=>(t=typeof t=="function"?t:qo,Ea(Cl,n=>({name:e,stack:t,parent:n}))),MU=Lp,PU=qp,FU=d(e=>Ce(e[0]),(e,t,n={})=>{let o=(Array.isArray(t)?t:[t]).map(s=>({span:s,attributes:n}));return Ea(e,qp,s=>[...s,...o])}),iy=(e,t,n,r)=>ye(()=>{e.status._tag!=="Ended"&&e.end(r?n.currentTimeNanosUnsafe():uv,t)}),jp=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return me(o=>{let s=Yv(o,e,n),i=o.getRef(ko),a=o.getRef(Ou);return ar($e(()=>r(s)),c=>iy(s,c,i,a))})},fv=Nr(yi),_l=function(){let e=Ce(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=j;return t._tag==="Span"&&(n=Go(n),r=R6(t.name,n?.captureStackTrace)),e?fv(r(arguments[0]),t):o=>fv(r(o),t)},UU=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Go(arguments[2]);if(e){let s=arguments[0];return jp(t,arguments[2],i=>_l(s,i,n))}let r=typeof arguments[1]=="function"?arguments[1]:void 0,o=r?void 0:arguments[1];return(s,...i)=>jp(t,r?r(...i):o,a=>_l(s,a,n))},NU=d(e=>Ce(e[0]),(e,...t)=>Ea(e,Lp,n=>{let r=t.length===1?{...n,...t[0]}:{...n};return t.length===1||K(r,t[0],t[1]),r})),DU=(...e)=>me(t=>{let n=t.currentSpanLocal;if(n)if(e.length===1)for(let[r,o]of Object.entries(e[0]))n.attribute(r,o);else n.attribute(e[0],e[1]);return Ae}),LU=me(e=>{let t=e.currentSpanLocal;return t?G(t):It(new ws)}),qU=h6(yi),ko=Fe("effect/Clock",{defaultValue:()=>new lv}),rv=2**31-1,lv=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=ye(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return C6()}currentTimeNanos=ye(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return BU()}monotonicTimeNanos=ye(()=>this.monotonicTimeNanosUnsafe());sleep(t){return this.sleepMillis(vn(t))}sleepMillis(t){return t<=0?Fl:Number.isFinite(t)?Vt(n=>{let r=t>rv?this.sleepMillis(t-rv):Ae,o=setTimeout(()=>n(r),Math.min(t,rv));return ye(()=>clearTimeout(o))}):Jp}},jU=BigInt(1e6),BU=(function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint=="function")return()=>e.bigint();if(typeof performance<"u"&&typeof performance.now=="function")return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let n=BigInt(Date.now())*jU;return n>t&&(t=n),t}})(),C6=(function(){let e=BigInt(1e9),t;return()=>{let n=BU(),r=BigInt(Date.now())*jU;if(t===void 0)t=r-n;else{let o=t+n;(r>o?r-o:o-r)>e&&(t=r-n)}return t+n}})(),to=e=>me(t=>e(t.getRef(ko))),Du=e=>to(t=>t.sleep(pt(e))),ay=to(e=>e.currentTimeMillis),$U=to(e=>e.currentTimeNanos),HU=to(e=>e.monotonicTimeNanos),Bp="~effect/Cause/TimeoutError",zU=e=>N(e,Bp),$p=class extends ca("TimeoutError"){[Bp]=Bp;constructor(t){super({message:t})}},Hp="~effect/Cause/IllegalArgumentError",WU=e=>N(e,Hp),_x=class extends ca("IllegalArgumentError"){[Hp]=Hp;constructor(t){super({message:t})}},zp="~effect/Cause/ExceededCapacityError",KU=e=>N(e,zp),Mx=class extends ca("ExceededCapacityError"){[zp]=zp;constructor(t){super({message:t})}},Wp="~effect/Cause/AsyncFiberError",VU=e=>N(e,Wp),Kp=class extends ca("AsyncFiberError"){[Wp]=Wp;constructor(t){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:t})}},Vp="~effect/Cause/UnknownError",JU=e=>N(e,Vp),Ml=class extends ca("UnknownError"){[Vp]=Vp;constructor(t,n){super({message:n,cause:t})}},O6=Fe("effect/Console/CurrentConsole",{defaultValue:()=>globalThis.console}),_6=e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 5e4;case"Error":return 4e4;case"Warn":return 3e4;case"Info":return 2e4;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}},M6=hw(wo,_6),GU=fa(M6),Xv=Fe("effect/Loggers/CurrentLoggers",{defaultValue:()=>new Set([q6,j6])}),P6=Fe("effect/Logger/LogToStderr",{defaultValue:fu}),ZU=function(){let e=typeof arguments[0]=="string"?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return va(me(t=>{let n=t.getRef(ya),r={...n};for(let o=0;o<e.length;o++){let[s,i]=e[o];K(r,s,i)}return t.setContext(Ge(t.context,ya,r)),Ms(sr(t.context,Ec),o=>{let s=t.getRef(ya),i={...s};for(let a=0;a<e.length;a++){let[c,u]=e[a];s[c]===u&&(Object.hasOwn(n,c)?K(i,c,n[c]):delete i[c])}return t.setContext(Ge(t.context,ya,i)),Ae})}))},F6="~effect/Logger",U6={[F6]:{_Message:j,_Output:j},pipe(){return ce(this,arguments)}},QU=e=>{let t=Object.create(U6);return t.log=e,t},N6=e=>e.replace(/[\s="]/g,"_"),D6=(e,t)=>`${N6(e[0])}=${t-e[1]}ms`;var Fs=e=>(...t)=>{let n;for(let r=0,o=t.length;r<o;r++){let s=t[r];xl(s)&&(n?t.splice(r,1):t=t.slice(0,r).concat(t.slice(r+1)),n=n?ia(n.reasons.concat(s.reasons)):s,r--)}return n===void 0&&(n=ex),me(r=>{let o=e??r.currentLogLevel;if(GU(r.minimumLogLevel,o))return Ae;let s=r.getRef(ko),i=r.getRef(Xv);if(i.size>0){let a=new Date(s.currentTimeMillisUnsafe());for(let c of i)c.log({cause:n,fiber:r,date:a,logLevel:o,message:t})}return Ae})};var _u={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},_le={None:[],All:[],Trace:[_u.gray],Debug:[_u.blue],Info:[_u.green],Warn:[_u.yellow],Error:[_u.red],Fatal:[_u.bgBrightRed,_u.black]};var L6=e=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`;var q6=QU(({cause:e,date:t,fiber:n,logLevel:r,message:o})=>{let s=Array.isArray(o)?o.slice():[o];e.reasons.length>0&&s.push(Dx(e));let i=t.getTime(),a=n.getRef(Ax),c="";for(let p of a)c+=` ${D6(p,i)}`;let u=n.getRef(ya);Object.keys(u).length>0&&s.push(u);let f=n.getRef(O6);(n.getRef(P6)?f.error:f.log)(`[${L6(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...s)}),j6=QU(({cause:e,fiber:t,logLevel:n,message:r})=>{let o=t.getRef(ko),s=t.getRef(ya),i=t.currentSpan;if(i===void 0||i._tag==="ExternalSpan")return;let a={};for(let[c,u]of Object.entries(s))K(a,c,u);a["effect.fiberId"]=t.id,a["effect.logLevel"]=n.toUpperCase(),e.reasons.length>0&&(a["effect.cause"]=Dx(e)),i.event(k_(Array.isArray(r)&&r.length===1?r[0]:r),o.currentTimeNanosUnsafe(),a)});function B6(){sv.interruptChildren??=d6}var cy=G(void 0);var YU=d(e=>Ce(e[0]),(e,t)=>jv(e,n=>me(r=>($6(r,n,t?.defectsOnly),Ae)))),$6=(e,t,n)=>{let r=e.getRef(uP);if(r.size===0||n&&!pv(t))return;let o={cause:t,fiber:e,timestamp:e.getRef(ko).currentTimeNanosUnsafe()};r.forEach(s=>s.report(o))};var H6=ml,z6=hl,Lu=xl,qu=O_,tm=sc,W6=Eu,K6=wu,Ia=ia,nT=ex,rT=yl,oT=lw,sT=Sc,ju=e=>new yu(e),Bu=e=>new wp(e),wc=xP,uy=vP,ka=kP,V6=Ux,vc=Nx,iT=yP,J6=dv,$u=_s,XU=SP,G6=pv,Z6=bP,e1=Px,fy=mv,Q6=EP,aT=wP,t1=Fx,Y6=hv,cT=Dx,X6=nx,eJ=vp,Hu=ws,Hl=kp,tJ=Su,uT=vu,he=P_,nJ=Bp,n1=zU,rJ=$p,oJ=Hp,sJ=WU,nm=_x,iJ=KU,aJ=zp,fT=Mx,cJ=Wp,uJ=VU,fJ=Kp,lJ=Vp,dJ=JU,pJ=Ml,mJ=Sl,hJ=TP,gJ=IP,eT=class extends qe()("effect/Cause/StackTrace"){},tT=class extends qe()("effect/Cause/InterruptorStackTrace"){};var Y={};dn(Y,{Do:()=>BG,Transaction:()=>Ql,TypeId:()=>PG,abortSignal:()=>B5,acquireDisposable:()=>F5,acquireRelease:()=>Oc,acquireUseRelease:()=>gN,addFinalizer:()=>xN,all:()=>FG,andThen:()=>Wn,annotateCurrentSpan:()=>Z5,annotateLogs:()=>Dy,annotateLogsScoped:()=>bZ,annotateSpans:()=>G5,as:()=>Zt,asSome:()=>Py,asVoid:()=>ns,awaitAllChildren:()=>iZ,bind:()=>zG,bindTo:()=>$G,cached:()=>Ny,cachedInvalidateWithTTL:()=>j5,cachedWithTTL:()=>q5,callback:()=>Bs,catch:()=>Qu,catchCause:()=>ht,catchCauseFilter:()=>i5,catchCauseIf:()=>s5,catchDefect:()=>WT,catchEager:()=>Ly,catchFilter:()=>r5,catchIf:()=>n5,catchNoSuchElement:()=>o5,catchReason:()=>XG,catchReasons:()=>e5,catchTag:()=>fN,catchTags:()=>lN,clockWith:()=>tf,context:()=>Kn,contextWith:()=>yr,currentParentSpan:()=>Y5,currentSpan:()=>Q5,delay:()=>Ra,die:()=>Ao,effectify:()=>MZ,ensuring:()=>Ca,eventually:()=>l5,exit:()=>so,fail:()=>Q,failCause:()=>lt,failCauseSync:()=>Aa,failSync:()=>My,fiber:()=>aZ,fiberId:()=>cZ,filter:()=>QT,filterMap:()=>w5,filterMapEffect:()=>YT,filterMapOrElse:()=>v5,filterMapOrFail:()=>T5,filterOrElse:()=>pN,filterOrFail:()=>mN,findFirst:()=>LG,findFirstFilter:()=>qG,firstSuccessOf:()=>g5,flatMap:()=>_,flatMapEager:()=>Gn,flatten:()=>HT,flip:()=>QG,fn:()=>dZ,fnUntraced:()=>Ee,fnUntracedEager:()=>qy,forEach:()=>es,forever:()=>Qt,forkChild:()=>td,forkDetach:()=>nd,forkIn:()=>zt,forkScoped:()=>$s,fromNullishOr:()=>JG,fromOption:()=>KG,fromResult:()=>$T,gen:()=>Lt,head:()=>jG,ignore:()=>VT,ignoreCause:()=>JT,interrupt:()=>Co,interruptible:()=>Oa,interruptibleMask:()=>oI,isEffect:()=>cr,isFailure:()=>C5,isSuccess:()=>O5,let:()=>HG,linkSpans:()=>tZ,log:()=>pZ,logDebug:()=>xZ,logError:()=>wm,logFatal:()=>mZ,logInfo:()=>gZ,logTrace:()=>yZ,logWarning:()=>hZ,logWithLevel:()=>rd,makeSpan:()=>iI,makeSpanScoped:()=>aI,map:()=>te,mapBoth:()=>a5,mapBothEager:()=>mn,mapEager:()=>_a,mapError:()=>Xl,mapErrorEager:()=>nf,match:()=>XT,matchCause:()=>k5,matchCauseEager:()=>A5,matchCauseEffect:()=>io,matchCauseEffectEager:()=>R5,matchEager:()=>I5,matchEffect:()=>hN,never:()=>oo,onError:()=>Ro,onErrorFilter:()=>N5,onErrorIf:()=>U5,onExit:()=>Sr,onExitFilter:()=>L5,onExitIf:()=>D5,onExitPrimitive:()=>rI,onInterrupt:()=>Ri,option:()=>ZG,orDie:()=>Ai,orElseSucceed:()=>h5,partition:()=>UG,promise:()=>Oy,provide:()=>eI,provideContext:()=>Vn,provideService:()=>rs,provideServiceEffect:()=>P5,race:()=>E5,raceAll:()=>ZT,raceAllFirst:()=>b5,raceFirst:()=>Cc,reduce:()=>NG,repeat:()=>yN,repeatOrElse:()=>$5,replicate:()=>H5,replicateEffect:()=>sI,request:()=>oZ,requestUnsafe:()=>sZ,result:()=>GG,retry:()=>Fy,retryOrElse:()=>KT,runCallback:()=>uZ,runCallbackWith:()=>cI,runFork:()=>bm,runForkWith:()=>Jn,runPromise:()=>uI,runPromiseExit:()=>Em,runPromiseExitWith:()=>fZ,runPromiseWith:()=>fI,runSync:()=>Oi,runSyncExit:()=>_c,runSyncExitWith:()=>lZ,runSyncWith:()=>lI,sandbox:()=>d5,satisfiesErrorType:()=>FZ,satisfiesServicesType:()=>UZ,satisfiesSuccessType:()=>PZ,schedule:()=>z5,scheduleFrom:()=>SN,scope:()=>os,scoped:()=>ef,scopedWith:()=>ym,service:()=>tI,serviceOption:()=>Yu,setContext:()=>_5,sleep:()=>Rc,spanAnnotations:()=>X5,spanLinks:()=>eZ,succeed:()=>k,succeedNone:()=>js,succeedSome:()=>_y,suspend:()=>V,sync:()=>ae,tap:()=>qt,tapCause:()=>xm,tapCauseFilter:()=>f5,tapCauseIf:()=>u5,tapDefect:()=>dN,tapError:()=>gm,tapErrorTag:()=>c5,timed:()=>S5,timeout:()=>GT,timeoutOption:()=>x5,timeoutOrElse:()=>y5,tracer:()=>W5,track:()=>wZ,trackDefects:()=>IZ,trackDuration:()=>kZ,trackErrors:()=>TZ,trackSuccesses:()=>vZ,transposeOption:()=>VG,try:()=>ts,tryPromise:()=>qs,tx:()=>AZ,txRetry:()=>_Z,undefined:()=>Yl,uninterruptible:()=>Ci,uninterruptibleMask:()=>Oo,unwrapReason:()=>t5,updateContext:()=>Xu,updateService:()=>nI,updateServiceScoped:()=>M5,useSpan:()=>Sm,validate:()=>DG,void:()=>W,when:()=>Uy,whileLoop:()=>ur,withErrorReporting:()=>m5,withExecutionPlan:()=>p5,withFiber:()=>kn,withLogSpan:()=>EZ,withLogger:()=>SZ,withParentSpan:()=>ed,withSpan:()=>nZ,withSpanScoped:()=>rZ,withTracer:()=>K5,withTracerEnabled:()=>V5,withTracerTiming:()=>J5,yieldNow:()=>hm,yieldNowWith:()=>WG,zip:()=>zT,zipWith:()=>YG});var Us=fw,Pn=it,Jt=Bn,Zo=bo,ly=Eo,dy=Hx,en=Ur;var Nt=Nl,Ei=tF;var r1=aF;var Un={};dn(Un,{CurrentMemoMap:()=>Ku,build:()=>m1,buildWithMemoMap:()=>vi,buildWithScope:()=>rm,catch:()=>FJ,catchCause:()=>NJ,catchTag:()=>UJ,effect:()=>ro,effectContext:()=>Ic,effectDiscard:()=>RJ,empty:()=>AJ,flatMap:()=>x1,forkMemoMap:()=>kJ,forkMemoMapUnsafe:()=>gT,fresh:()=>DJ,fromBuild:()=>Tc,fromBuildMemo:()=>xy,isLayer:()=>gy,launch:()=>LJ,makeMemoMap:()=>IJ,makeMemoMapUnsafe:()=>wi,merge:()=>OJ,mergeAll:()=>yy,mock:()=>qJ,orDie:()=>Sy,parentSpan:()=>S1,provide:()=>Ds,provideMerge:()=>om,satisfiesErrorType:()=>$J,satisfiesServicesType:()=>HJ,satisfiesSuccessType:()=>BJ,span:()=>zJ,succeed:()=>Ti,succeedContext:()=>Vu,suspend:()=>CJ,sync:()=>xT,syncContext:()=>pT,tap:()=>_J,tapCause:()=>PJ,tapError:()=>MJ,unwrap:()=>mT,updateService:()=>y1,withParentSpan:()=>hT,withSpan:()=>WJ});var xJ="~effect/Deferred";var yJ={[xJ]:{_A:j,_E:j},pipe(){return ce(this,arguments)}},zu=()=>{let e=Object.create(yJ);return e.resumes=void 0,e.effect=void 0,e};var Wu=e=>Vt(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),ye(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)})));var SJ=d(2,(e,t)=>ye(()=>zl(e,t))),lT=SJ;var bJ=d(2,(e,t)=>lT(e,Bn(t)));var dT=d(2,(e,t)=>bJ(e,Sc(t)));var zl=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let r=0;r<n.length;r++)n[r](t)}return!0};var o1=ya;var s1=Ax,i1=Cl;var a1=Ou,c1=fP;var mt=Ec;var no=Uu,Qo=BF,Yo=Ms,Dt=qF;var Fn=LF,Ze=Nv;var p1="~effect/Layer",u1="~effect/Layer/MemoMap",wJ=(e,t)=>(e.observers++,Xr(Ms(t,n=>e.finalizer(n)),e.effect)),gy=e=>N(e,p1),vJ={[p1]:{_ROut:j,_E:j,_RIn:j},pipe(){return ce(this,arguments)}},Ju=e=>{let t=Object.create(vJ);return t.build=e,t},Tc=e=>Ju((t,n)=>{let r=Fn(n);return ar(e(t,r),o=>o._tag==="Failure"?Ze(r,o):Ae)}),xy=e=>{let t=Tc((n,r)=>n.getOrElseMemoize(t,r,e));return t},TJ=(e,t,n,r)=>{let o=no(),s=zu(),i={observers:1,effect:Wu(s),finalizer:a=>xe(()=>(i.observers--,i.observers===0?(e.map.delete(t),Ze(o,a)):Ae))};return e.map.set(t,i),Ms(n,i.finalizer).pipe(oe(()=>r(e,o)),ar(a=>(i.effect=a,lT(s,a))))},hy=class{get[u1](){return u1}parent;constructor(t){this.parent=t}map=new Map;get(t,n){let r=this.map.get(t);return r?wJ(r,n):this.parent?.get(t,n)}getOrElseMemoize(t,n,r){return xe(()=>{let o=this.get(t,n);return o||TJ(this,t,n,r)})}},wi=()=>new hy,gT=e=>new hy(e),IJ=ye(wi),kJ=e=>ye(()=>gT(e)),Ku=class e extends qe()("effect/Layer/CurrentMemoMap"){static forkOrCreate(t){let n=da(t,e);return n?gT(n):wi()}},vi=d(3,(e,t,n)=>Nr(Be(e.build(t,n),Ge(Ku,t)),Ku,t)),m1=e=>me(t=>vi(e,Ku.forkOrCreate(t.context),sr(t.context,mt))),rm=d(2,(e,t)=>me(n=>vi(e,Ku.forkOrCreate(n.context),t))),Ti=function(){return arguments.length===1?e=>Vu(ks(arguments[0],e)):Vu(ks(arguments[0],arguments[1]))},Vu=e=>Ju(Xe(G(e))),AJ=Vu(Tt()),xT=function(){return arguments.length===1?e=>pT(()=>ks(arguments[0],e())):pT(()=>ks(arguments[0],arguments[1]()))},pT=e=>xy(Xe(ye(e))),ro=function(){return arguments.length===1?e=>f1(arguments[0],e):f1(arguments[0],arguments[1])},f1=(e,t)=>Ic(Be(t,n=>ks(e,n))),Ic=e=>xy((t,n)=>Qo(e,n)),RJ=e=>Ic($n(e,Tt())),CJ=e=>xy((t,n)=>xe(()=>e().build(t,n))),mT=e=>{let t=qe("effect/Layer/unwrap");return x1(ro(t)(e),ze(t))},h1=(e,t,n)=>{let r=Fn(n,"parallel");return Yr(e,o=>o.build(t,Fn(r,"sequential")),{concurrency:e.length}).pipe(Be(o=>PM(...o)))},yy=(...e)=>Tc((t,n)=>h1(e,t,n)),OJ=d(2,(e,t)=>yy(e,...Array.isArray(t)?t:[t])),g1=(e,t,n)=>Tc((r,o)=>oe(Array.isArray(t)?h1(t,r,o):t.build(r,o),s=>e.build(r,o).pipe(wa(s),Be(i=>n(i,s))))),Ds=d(2,(e,t)=>g1(e,t,j)),om=d(2,(e,t)=>g1(e,t,(n,r)=>ir(r,n))),x1=d(2,(e,t)=>Tc((n,r)=>oe(e.build(n,r),o=>t(o).build(n,r)))),_J=d(2,(e,t)=>Tc((n,r)=>oe(e.build(n,r),o=>Qo($n(t(o),o),r)))),MJ=d(2,(e,t)=>Tc((n,r)=>Lr(e.build(n,r),o=>Qo(Xr(t(o),It(o)),r)))),PJ=d(2,(e,t)=>Tc((n,r)=>Dr(e.build(n,r),o=>Qo(Xr(t(o),at(o)),r)))),Sy=e=>Ju((t,n)=>Gx(e.build(t,n))),FJ=d(2,(e,t)=>Ju((n,r)=>Lr(e.build(n,r),o=>t(o).build(n,r))));var UJ=d(3,(e,t,n)=>Ju((r,o)=>Jx(e.build(r,o),t,s=>n(s).build(r,o)))),NJ=d(2,(e,t)=>Ju((n,r)=>Dr(e.build(n,r),o=>t(o).build(n,r)))),y1=d(3,(e,t,n)=>Ds(e,ro(t,Be(t,n)))),DJ=e=>Ju((t,n)=>e.build(wi(),n)),LJ=e=>Yx(Xr(m1(e),Jp)),qJ=function(){return arguments.length===1?e=>l1(arguments[0],e):l1(arguments[0],arguments[1])},l1=(e,t)=>Ti(e)(new Proxy({...t},{get(n,r,o){if(r in n)return n[r];let s=Jo();Mn(2);let i=new Error(`${e.key}: Unimplemented method "${r.toString()}"`);return Mn(s),i.name="UnimplementedError",jJ(i)},has:cn})),jJ=e=>{let t=Object.assign(ba(e),{[d1]:d1,channel:{[my]:my,transform:()=>G(t),pipe(){return ce(this,arguments)}},[my]:my,transform:()=>G(t)});function n(){return t}return Object.assign(n,t),Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n},d1="~effect/Stream",my="~effect/Channel",BJ=()=>e=>e,$J=()=>e=>e,HJ=()=>e=>e,zJ=(e,t)=>(t=Go(t),ro(yi,t?.onEnd?Si(Os(e,t),n=>jl(r=>t.onEnd(n,r))):Os(e,t))),S1=e=>Vu(yi.context(e)),WJ=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Go(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return mT(Be(n?.onEnd!==void 0?Si(Os(t,n),o=>jl(s=>n.onEnd(o,s))):Os(t,n),o=>hT(r,o)))}return r=>mT(Be(n?.onEnd!==void 0?Si(Os(t,n),o=>jl(s=>n.onEnd(o,s))):Os(t,n),o=>hT(r,o)))},hT=function(){let e=gy(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=j;t._tag==="Span"&&(n=Go(n),r=KJ(t.name,n?.captureStackTrace));let o=S1(t);return e?Ds(r(arguments[0]),o):s=>Ds(r(s),o)},KJ=(e,t)=>(t=typeof t=="function"?t:qo,y1(i1,n=>({name:e,stack:t,parent:n})));var b1="~effect/ExecutionPlan";var VJ={[b1]:b1,get captureRequirements(){let e=this;return bc(t=>G(JJ(e.steps.map(n=>({...n,provide:gy(n.provide)?Ds(n.provide,Vu(t)):n.provide})))))},pipe(){return ce(this,arguments)}},JJ=e=>{let t=Object.create(VJ);return t.steps=e,t};var by=Fe("effect/ExecutionPlan/CurrentMetadata",{defaultValue:Xe({attempt:0,stepIndex:0})});var Ii={};dn(Ii,{Clock:()=>kc,clockWith:()=>GJ,currentTimeMillis:()=>ZJ,currentTimeNanos:()=>QJ,monotonicTimeNanos:()=>YJ});var kc=ko,GJ=to,ZJ=ay,QJ=$U,YJ=HU;var Ey="~effect/time/DateTime",wy="~effect/time/DateTime/TimeZone",w1={[Ey]:Ey,pipe(){return ce(this,arguments)},[ft](){return this.toString()},toJSON(){return cm(this).toJSON()}},XJ={...w1,_tag:"Utc",[Ie](){return _r(this.epochMilliseconds)},[ke](e){return Wl(e)&&e._tag==="Utc"&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${cm(this).toJSON()})`}},eG={...w1,_tag:"Zoned",[Ie](){return Ht(_r(this.epochMilliseconds))(ue(this.zone))},[ke](e){return Wl(e)&&e._tag==="Zoned"&&this.epochMilliseconds===e.epochMilliseconds&&ne(this.zone,e.zone)},toString(){return`DateTime.Zoned(${OT(this)})`}},v1={[wy]:wy,[ft](){return this.toString()}},tG={...v1,_tag:"Named",[Ie](){return st(`Named:${this.id}`)},[ke](e){return Zu(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},nG={...v1,_tag:"Offset",[Ie](){return st(`Offset:${this.offset}`)},[ke](e){return Zu(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${AT(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},ki=(e,t,n)=>{let r=Object.create(eG);return r.epochMilliseconds=e,r.zone=t,Object.defineProperty(r,"partsUtc",{value:n,enumerable:!1,writable:!0}),Object.defineProperty(r,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(r,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),r},Wl=e=>N(e,Ey);var Zu=e=>N(e,wy),T1=e=>Zu(e)&&e._tag==="Offset",I1=e=>Zu(e)&&e._tag==="Named",k1=e=>e._tag==="Utc",ET=e=>e._tag==="Zoned",A1=pn((e,t)=>e.epochMilliseconds===t.epochMilliseconds),R1=vs((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:e.epochMilliseconds>t.epochMilliseconds?1:0);var C1=e=>{let t=Object.create(XJ);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},Gu=e=>{let t=e.getTime();if(Number.isNaN(t))throw new nm("Invalid date");return C1(t)},vy=e=>{if(Wl(e))return e;if(e instanceof Date)return Gu(e);if(typeof e=="object"){if("epochMilliseconds"in e)return Gu(new Date(e.epochMilliseconds));let t=new Date(0);return fG(t,e),Gu(t)}else if(typeof e=="string"&&!rG(e))return Gu(new Date(e+"Z"));return Gu(new Date(e))},rG=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),oG=-864e13+720*60*1e3,sG=864e13-840*60*1e3,wT=(e,t)=>{let n=t?.timeZone;if(n===void 0&&Wl(e)&&ET(e))return e;let r=vy(e);if(r.epochMilliseconds<oG||r.epochMilliseconds>sG)throw new RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);n===void 0&&typeof e=="object"&&"timeZoneId"in e&&(n=e.timeZoneId);let o;if(n===void 0){let s=new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1e3;o=am(s)}else if(Zu(n))o=n;else if(typeof n=="number")o=am(n);else{let s=IT(n);if(Se(s))throw new nm(`Invalid time zone: ${n}`);o=s.value}return t?.adjustForTimeZone!==!0?ki(r.epochMilliseconds,o,r.partsUtc):lG(r.epochMilliseconds,o,t?.disambiguation??"compatible")},ST=uc(wT),O1=uc(vy),iG=/^(.{17,35})\[(.+)\]$/,_1=e=>{let t=iG.exec(e);if(t===null){let o=CT(e);return o!==null?ST(e,{timeZone:o}):D()}let[,n,r]=t;return ST(n,{timeZone:r})};var M1=e=>C1(e.epochMilliseconds);var im=new Map,aG={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},cG=e=>{let t=e.resolvedOptions().timeZone;if(im.has(t))return im.get(t);let n=Object.create(tG);return n.id=t,n.format=e,im.set(t,n),n},vT=e=>{if(im.has(e))return im.get(e);try{return cG(new Intl.DateTimeFormat("en-US",{...aG,timeZone:e}))}catch{throw new nm(`Invalid time zone: ${e}`)}},am=e=>{let t=Object.create(nG);return t.offset=e,t},TT=uc(vT);var uG=/^(?:GMT|[+-])/,IT=e=>{if(uG.test(e)){let t=CT(e);return t===null?D():L(am(t))}return TT(e)},P1=e=>e._tag==="Offset"?AT(e.offset):e.id;var cm=e=>new Date(e.epochMilliseconds),Ty=e=>{if(e._tag==="Utc")return new Date(e.epochMilliseconds);if(e.zone._tag==="Offset")return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(r=>r.type!=="literal"),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMilliseconds=n.getTime(),n},kT=e=>Ty(e).getTime()-RT(e),AT=e=>{let t=Math.abs(e),n=Math.floor(t/(3600*1e3)),r=Math.round(t%(3600*1e3)/(60*1e3));return r===60&&(n+=1,r=0),`${e<0?"-":"+"}${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`},F1=e=>AT(kT(e)),RT=e=>e.epochMilliseconds;var fG=(e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)};var E1=1440*60*1e3,lG=(e,t,n)=>{if(t._tag==="Offset")return ki(e-t.offset,t);let r=sm(e-E1,e,t),o=sm(e+E1,e,t);if(r===o)return ki(e-r,t);let s=r<o,i=r-o;if(s){if(sm(e-o,e,t)===o)return ki(e-o,t);let u=ki(e-r,t),f=Ty(u).getTime();if(e!==f)switch(n){case"reject":{let l=new Date(e).toISOString();throw new RangeError(`Gap time: ${l} does not exist in time zone ${t.id}`)}case"earlier":return ki(e-o,t);case"compatible":case"later":return u}return u}if(sm(e-r,e,t)===r){if(n==="earlier"||n==="compatible"||sm(e-r+i,e+i,t)===r)return ki(e-r,t);if(n==="reject"){let u=new Date(e).toISOString();throw new RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return ki(e-o,t)},dG=/([+-])(\d{2}):(\d{2})$/,CT=e=>{let t=dG.exec(e);if(t===null)return null;let[,n,r,o]=t;return(n==="+"?1:-1)*(Number(r)*60+Number(o))*60*1e3},sm=(e,t,n)=>{let r=n.format.formatToParts(e).find(s=>s.type==="timeZoneName")?.value??"";if(r==="GMT")return 0;let o=CT(r);return o===null?kT(ki(t,n)):o};var U1=e=>cm(e).toISOString();var bT=e=>{let t=Ty(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${F1(e)}`},OT=e=>e.zone._tag==="Offset"?bT(e):`${bT(e)}[${e.zone.id}]`;var sde=globalThis.Number;var D1=d(2,(e,t)=>{let n=e.toString(),r=t.toString();if(n.includes("e")||r.includes("e"))return!globalThis.Number.isFinite(e)||!globalThis.Number.isFinite(t)||t===0?NaN:mG(e,t);let o=(n.split(".")[1]||"").length,s=(r.split(".")[1]||"").length,i=o>s?o:s,a=parseInt(e.toFixed(i).replace(".","")),c=parseInt(t.toFixed(i).replace(".",""));return a%c/Math.pow(10,i)});function mG(e,t){let[n,r]=N1(e),[o,s]=N1(t),i=Math.min(r,s),a=n*BigInt(10)**BigInt(r-i),c=o*BigInt(10)**BigInt(s-i),u=a%c;if(u===BigInt(0))return e<0||Object.is(e,-0)?-0:0;let f=globalThis.Number(`${u}e${i}`);return f===0?Math.sign(e)*globalThis.Number.MIN_VALUE:f}function N1(e){let t=Math.abs(e).toExponential(),n=t.indexOf("e"),r=t.slice(0,n).replace(".","");return[BigInt(r)*(e<0?-BigInt(1):BigInt(1)),globalThis.Number(t.slice(n+1))-r.length+1]}var L1=e=>{let t=Math.ceil(Math.log(e)/Math.log(2));return Math.max(Math.pow(2,t),2)};var q1=jo((e,t)=>Math.max(e,t),-1/0),j1=jo((e,t)=>Math.min(e,t),1/0);var ide=globalThis.String,Iy=Gr;var $1=e=>e.trim();var Gt=d(2,(e,t)=>Ll(e,hG,n=>t(n))),Xo=e=>e.reasons.some(MT),MT=e=>e._tag==="Fail"&&Hl(e.error),Kl=e=>{let t,n=!1;for(let r of e.reasons)MT(r)?t??=r.error:r._tag!=="Interrupt"&&(n=!0);return t===void 0?ge(e):n?ge(Ia(e.reasons.filter(r=>!MT(r)))):le(t)};var hG=e=>{let t=Kl(e);return we(t)?t:le(t.success.value)},PT=e=>{let t=Kl(e);return we(t)?Jt(t.failure):Pn(t.success.value)},um=d(2,(e,t)=>Cs(e,{onSuccess:t.onSuccess,onFailure:n=>{let r=Kl(n);return we(r)?t.onFailure(r.failure):t.onDone(r.success.value)}}));var H1="~effect/Schedule";var zn=Fe("effect/Schedule/CurrentMetadata",{defaultValue:Xe({input:void 0,output:void 0,duration:ma,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),gG={[H1]:{_Out:j,_In:j,_Env:j},pipe(){return ce(this,arguments)}},FT=e=>N(e,H1),ky=e=>{let t=Object.create(gG);return t.step=e,t},UT=()=>{let e=0,t,n;return(r,o)=>{n===void 0&&(n=r);let s=r-n,i=t===void 0?0:r-t;return t=r,{input:o,attempt:++e,start:n,now:r,elapsed:s,elapsedSincePrevious:i}}},z1=e=>ky(Be(e,t=>{let n=UT();return(r,o)=>t(n(r,o))})),Ay=e=>Dr(e.step,t=>G(()=>at(t))),Ls=e=>to(t=>Be(Ay(e),n=>{let r=UT();return o=>xe(()=>{let s=t.currentTimeMillisUnsafe();return oe(n(s,o),([i,a])=>{let c=r(s,o);return c.output=i,c.duration=a,$n(Du(a),c)})})})),Vl=e=>Be(Ls(e),t=>n=>Be(t(n),r=>r.output));var W1=e=>ky(Be($l(e.map(Ay)),t=>(n,r)=>oe(Yr(t,o=>um(o(n,r),{onSuccess:s=>G(s[1]),onDone:()=>cy,onFailure:at})),o=>{let s=xG(o);return s===void 0?he(ma):G([s,s])}))),xG=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t=t===void 0?r:$M(t,r))}return t},K1=(e,t=2)=>{let n=vn(pt(e));return z1(G(r=>{let o=As(n*Math.pow(t,r.attempt-1));return G([o,o])}))};var NT=e=>ky(Be(Ay(e),t=>(n,r)=>um(t(n,r),{onSuccess:o=>G([r,o[1]]),onFailure:at,onDone:()=>he(r)}))),V1=e=>fm(lm,({attempt:t})=>G(t<=e)),Jl=e=>{let t=pt(e);return z1(G(n=>G([n.attempt-1,t])))};var fm=d(2,(e,t)=>ky(Be(Ay(e),n=>{let r=UT();return(o,s)=>oe(n(o,s),i=>{let[a,c]=i,u=t({...r(o,s),output:a,duration:c});return oe(Ce(u)?u:G(u),f=>f?G(i):he(a))})})));var lm=Jl(ma);var yG=(e,t,n)=>Xx(r=>oe(n?.local?vi(t,wi(),r):rm(t,r),o=>wa(e,o))),Ry=d(e=>Ce(e[0]),(e,t,n)=>Np(t)?wa(e,t):yG(e,Array.isArray(t)?yy(...t):t,n));var DT=d(3,(e,t,n)=>oe(Ls(t),r=>{let o=zn.defaultValue();return Lr(Wx(Si(oe(xe(()=>Nr(e,zn,o)),r),s=>ye(()=>{o=s})),{disableYield:!0}),s=>kp(s)?G(s.value):n(s,o.attempt===0?D():L(o)))})),LT=d(3,(e,t,n)=>oe(Ls(t),r=>{let o=zn.defaultValue(),s,i=Lr(xe(()=>Nr(e,zn,o)),a=>(s=a,oe(r(a),c=>(o=c,i))));return Gt(i,a=>$e(()=>n(s,a)))})),G1=d(2,(e,t)=>{let n=typeof t=="function"?t(j):FT(t)?t:pm(t);return DT(e,n,It)}),dm=d(2,(e,t)=>{let n=typeof t=="function"?t(j):FT(t)?t:pm(t);return LT(e,n,It)}),Z1=d(3,(e,t,n)=>oe(Ls(n),r=>{let o=zn.defaultValue(),s=xe(()=>Nr(e,zn,o));return Lr(oe(r(t),i=>{o=i;let a=Xe(oe(s,r));return bi({while:cn,body:a,step(c){o=c}})}),i=>kp(i)?G(i.value):It(i))})),SG=NT(lm),pm=e=>{let t=e.schedule?NT(e.schedule):SG;return e.while&&(t=fm(t,({input:n})=>{let r=e.while(n);return Ce(r)?r:G(r)})),e.until&&(t=fm(t,({input:n})=>{let r=e.until(n);return Ce(r)?Be(r,o=>!o):G(!r)})),e.times!==void 0&&(t=fm(t,({attempt:n})=>G(n<=e.times))),t};var qT=(e,t)=>{let n=-1,r=0,o=s=>Zx(e(s));return{begin:to(s=>xe(()=>{let i=t();i.stepIndex!==n&&(n=i.stepIndex,r=0),r++;let a={attempt:i.attempt,stepAttempt:r,stepIndex:i.stepIndex,startNanos:s.monotonicTimeNanosUnsafe()};return $n(o({_tag:"AttemptStart",attempt:a.attempt,stepAttempt:a.stepAttempt,stepIndex:a.stepIndex}),a)})),end:(s,i)=>to(a=>{let c=Qr(a.monotonicTimeNanosUnsafe()-s.startNanos);return o(i._tag==="Success"?{_tag:"AttemptSuccess",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c}:{_tag:"AttemptFailure",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c,cause:i.cause})})}},Y1=d(e=>Ce(e[0]),(e,t,n)=>xe(()=>{let r=0,o={attempt:0,stepIndex:0},s=zx(by,ye(()=>(o={attempt:o.attempt+1,stepIndex:r},o))),i=n?.onEvent===void 0?void 0:qT(n.onEvent,()=>o),a=i===void 0?j:u=>eo(f=>oe(i.begin,l=>ar(f(u),p=>i.end(l,p)))),c;return oe(bi({while:()=>r<t.steps.length&&(c===void 0||we(c)),body(){let u=t.steps[r],f=s(a(Ry(e,u.provide)));if(c){let l=!1,p=f;f=xe(()=>l?p:(l=!0,Pl(c))),f=dm(f,mm(u,!1))}else{let l=mm(u,!0);f=l?dm(f,l):f}return xc(f)},step(u){c=u,r++}}),()=>Pl(c))})),mm=(e,t)=>{if(t){if(e.attempts===1||!(e.schedule||e.attempts))return}else return pm({schedule:e.schedule?e.schedule:e.attempts?void 0:bG,times:e.attempts,while:e.while});return pm({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})},bG=V1(1);var EG="~effect/Request",wG=Ep({_E:e=>e,_A:e=>e,_R:e=>e}),Ede={...C_,[EG]:wG};var eN=e=>e;var nN=d(2,(e,t)=>{let n=r=>Vt(o=>{let s=oN(r,e,o,Sa());return TG(r,s)});return Ce(t)?oe(t,n):n(t)}),rN=(e,t)=>{let n=oN(t.resolver,e,t.onExit,{context:t.context,currentScheduler:ze(t.context,gc)});return()=>sN(t.resolver,n)},Cy=[],jT=new WeakMap,oN=(e,t,n,r)=>{let o=jT.get(e);o||(o=new Map,jT.set(e,o));let s,i=!1,a=eN({request:t,context:r.context,uninterruptible:!1,completeUnsafe(u){i||(i=!0,n(u),s?.entrySet.delete(a))}});if(e.preCheck!==void 0&&!e.preCheck(a))return a;let c=e.batchKey(a);if(s=o.get(c),!s){if(Cy.length>0)s=Cy.pop(),s.key=c,s.resolver=e,s.map=o;else{let u={key:c,resolver:e,map:o,entrySet:new Set,entries:new Set,delayEffect:oe(xe(()=>u.resolver.delay),f=>tN(u)),run:ar(xe(()=>u.resolver.runAll(Array.from(u.entries),u.key)),f=>{for(let l of u.entrySet)l.completeUnsafe(f._tag==="Success"?Eo(new Error("Effect.request: RequestResolver did not complete request",{cause:l.request})):f);return u.entries.clear(),Cy.length<128&&(u.entrySet.clear(),u.key=void 0,u.fiber=void 0,u.resolver=void 0,u.map=void 0,Cy.push(u)),Ae})};s=u}o.set(c,s),s.fiber=Ta(r.context)(s.delayEffect,{scheduler:r.currentScheduler})}return s.entrySet.add(a),s.entries.add(a),s.resolver.collectWhile(s.entries)||(s.fiber.interruptUnsafe(r.id),s.fiber=Ta(r.context)(tN(s),{scheduler:r.currentScheduler})),a},sN=(e,t)=>{if(t.uninterruptible)return;let n=jT.get(e);if(!n)return;let r=e.batchKey(t),o=n.get(r);o&&(o.entries.delete(t),o.entrySet.delete(t),o.entries.size===0&&(n.delete(r),o.fiber?.interruptUnsafe()))},TG=(e,t)=>ye(()=>sN(e,t));function tN(e){return e.map.has(e.key)?(e.map.delete(e.key),e.run):Ae}var kG="effect/Metric/CurrentMetricAttributes",AG=Fe(kG,{defaultValue:()=>({})}),RG="~effect/observability/Metric/MetricRegistryKey",CG=Fe(RG,{defaultValue:()=>new Map}),iN="~effect/observability/Metric",aN=class{[iN]=iN;#e=new WeakMap;#t;id;description;attributes;constructor(t,n,r){this.id=t,this.description=n,this.attributes=r}valueUnsafe(t){return this.hook(t).get(t)}modifyUnsafe(t,n){return this.hook(n).modify(t,n)}updateUnsafe(t,n){return this.hook(n).update(t,n)}hook(t){let n=ze(t,AG);if(Object.keys(n).length===0)return qn(this.#t)?this.#t.hooks:(this.#t=this.getOrCreate(t,this.attributes),this.#t.hooks);let r=MG(this.attributes,n),o=this.#e.get(r);return qn(o)||(o=this.getOrCreate(t,r),this.#e.set(r,o)),o.hooks}getOrCreate(t,n){let r=OG(this,n),o=ze(t,CG);if(o.has(r))return o.get(r);let s=this.createHooks(),i={id:this.id,type:this.type,description:this.description,attributes:BT(n),hooks:s};return o.set(r,i),i}pipe(){return ce(this,arguments)}};var Zl=d(2,(e,t)=>bc(n=>ye(()=>e.updateUnsafe(t,n))));function OG(e,t){let n=`${e.type}:${e.id}`;return qn(e.description)&&(n+=`:${e.description}`),qn(t)&&(n+=`:${_G(t)}`),n}function _G(e){return JSON.stringify(Array.isArray(e)?e:Object.entries(e))}function MG(e,t){return{...BT(e),...BT(t)}}function BT(e){return qn(e)&&Array.isArray(e)?e.reduce((t,[n,r])=>(K(t,n,r),t),{}):e}var PG=mi,cr=Ce,FG=$l,UG=Wv,NG=QF,DG=YF,LG=XF,qG=tU,es=Yr,jG=rU,ur=bi,Oy=bv,qs=LP,k=G,js=Pu,_y=Sv,V=xe,ae=ye,W=Ae;var Yl=cy;var Bs=Vt,oo=Jp,BG=uU,$G=fU,HG=dU;var zG=lU,Lt=$P,Q=It,My=Bx,lt=at,Aa=NP,Ao=ba,ts=DP;var hm=Fl,WG=yv,kn=me,$T=Pl,KG=xv,VG=UP,JG=FP,_=oe,HT=ZP,Wn=Xr,qt=Si,GG=xc,ZG=OF,so=Yp,te=Be,Zt=$n,Py=Ul,ns=Gp,QG=WP,zT=pF,YG=Av,Qu=Lr;var fN=Jx,lN=vF,XG=TF,e5=IF,t5=kF,ht=Dr,WT=yF,n5=Zp,r5=Vx,o5=xF,s5=Cv,i5=Ll,Xl=_v,a5=Mv,Ai=Gx,gm=Ov,c5=EF,xm=SF,u5=bF,f5=Kx,dN=wF,l5=Pv,Fy=dm,KT=LT,d5=KP,VT=CF,JT=Zx,p5=Y1,m5=YU,h5=AF,g5=RF,GT=UF,x5=NF,y5=Uv,Ra=FF,Rc=Du,S5=DF,ZT=Tv,b5=Iv,E5=VP,Cc=$x,QT=iU,w5=aU,YT=cU,pN=Kv,v5=Vv,mN=mF,T5=sU,Uy=hF,XT=Qx,I5=Qp,k5=Fv,A5=_F,R5=JP,io=Cs,hN=Fu,C5=MF,O5=PF,Kn=kv,yr=bc,eI=Ry,Vn=wa,_5=dF,tI=uF,Yu=fF,Xu=Dl,nI=Ea,M5=lF,rs=Nr,P5=zx,os=Xp,ef=Yx,ym=Xx,Oc=ey,F5=WF,gN=zF,xN=jl,Ca=$F,Ro=jv,U5=HF,N5=Bv,rI=Ps,Sr=ar,D5=Lv,L5=qv,Ny=KF,q5=Hv,j5=$v,Co=Bl,Oa=zv,Ri=ty,Ci=va,Oo=eo,oI=GF,B5=ZF,Qt=Wx,yN=G1,$5=DT,H5=Rv,sI=gF,z5=d(2,(e,t)=>SN(e,void 0,t)),SN=Z1,W5=IU,K5=kU,V5=AU,J5=RU,G5=NU,Z5=DU,Q5=LU,Y5=qU,X5=MU,eZ=PU,tZ=FU,iI=OU,aI=Os,Sm=jp,nZ=UU,rZ=_U,ed=_l,oZ=nN,sZ=rN,td=pU,zt=Jv,$s=gU,nd=mU,iZ=hU,aZ=jP,cZ=BP,bm=yU,Jn=Ta,cI=Gv,uZ=SU,uI=EU,fI=Zv,Em=bU,fZ=ry,Oi=vU,lI=Qv,_c=wU,lZ=oy,Ee=wv,dZ=HP,tf=to,rd=Fs,pZ=Fs(),mZ=Fs("Fatal"),hZ=Fs("Warn"),wm=Fs("Error"),gZ=Fs("Info"),xZ=Fs("Debug"),yZ=Fs("Trace"),SZ=d(2,(e,t)=>Ea(e,Xv,n=>new Set([...n,t]))),Dy=d(e=>cr(e[0]),(e,...t)=>Ea(e,o1,n=>{let r=t.length===1?{...n,...t[0]}:{...n};return t.length===1||K(r,t[0],t[1]),r})),bZ=ZU,EZ=d(2,(e,t)=>oe(ay,n=>Ea(e,s1,r=>[[t,n],...r]))),wZ=d(e=>cr(e[0]),(e,t,n)=>Sr(e,r=>{let o=n===void 0?r:$e(()=>n(r));return Zl(t,o)})),vZ=d(e=>cr(e[0]),(e,t,n)=>qt(e,r=>{let o=n===void 0?r:n(r);return Zl(t,o)})),TZ=d(e=>cr(e[0]),(e,t,n)=>gm(e,r=>{let o=n===void 0?r:$e(()=>n(r));return Zl(t,o)})),IZ=d(e=>cr(e[0]),(e,t,n)=>dN(e,r=>{let o=n===void 0?r:$e(()=>n(r));return Zl(t,o)})),kZ=d(e=>cr(e[0]),(e,t,n)=>tf(r=>{let o=r.monotonicTimeNanosUnsafe();return Sr(e,()=>{let s=r.monotonicTimeNanosUnsafe(),i=HM(pt(s),pt(o)),a=n===void 0?i:$e(()=>n(i));return Zl(t,a)})})),Ql=class extends qe()("effect/Effect/Transaction"){},AZ=e=>kn(t=>{let n=da(t.context,Ql);if(n)return e;n={journal:new Map,retry:!1};let r;return Oo(o=>_(ur({while:()=>!r,body:Xe(o(e).pipe(rs(Ql,n),xm(()=>n.retry?o(CZ(n)):W),so)),step(s){if(n.retry||!RZ(n))return uN(n);Nt(s)?OZ(t,n):uN(n),r=s}}),()=>r))}),RZ=e=>{for(let[t,{version:n}]of e.journal)if(t.version!==n)return!1;return!0},CZ=e=>V(()=>{let t={},n=Array.from(e.journal.keys()),r=()=>{for(let o of n)o.pending.delete(t)};return Bs(o=>{let s=()=>{r(),o(W)};for(let i of n)i.pending.set(t,s);return ae(r)})});function OZ(e,t){for(let[n,{value:r}]of t.journal){r!==n.value&&(n.version=n.version+1,n.value=r);for(let o of n.pending.values())e.currentDispatcher.scheduleTask(o,0);n.pending.clear()}}function uN(e){e.retry=!1,e.journal.clear()}var _Z=_(Ql,e=>(e.retry=!0,Co)),MZ=(e,t,n)=>(...r)=>Bs(o=>{try{e(...r,(s,i)=>{o(s?Q(t?t(s,r):s):k(i))})}catch(s){o(n?Q(n(s,r)):Ao(s))}}),PZ=()=>e=>e,FZ=()=>e=>e,UZ=()=>e=>e,_a=QP,nf=YP,mn=XP,Gn=GP,Ly=eF,qy=zP;function Hs(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function rf(e){return t=>Hs(t)?.[e]}var ao="~structural",of="~identifier",vm="~sentinels",jy="~constructor",bN=["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],sf=rf("identifier"),dI=rf(of),By=rf("title"),EN=rf("description"),wN=rf("brands"),Tm=bn(e=>{let t=Hs(e)?.identifier;return typeof t=="string"?t:e.getExpected(Tm)});var vN=new Set([vm,ao,"representation","arbitrary","brands","toJsonSchema","toCode","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso"]);var co={};dn(co,{AnyOf:()=>cf,Composite:()=>At,Encoding:()=>Rm,Filter:()=>Am,Forbidden:()=>Pc,InvalidType:()=>tt,InvalidValue:()=>Oe,MissingKey:()=>tn,OneOf:()=>Cm,Pointer:()=>kt,UnexpectedKey:()=>_i,defaultCheckHook:()=>yI,defaultFormatter:()=>wI,defaultLeafHook:()=>xI,hasInput:()=>TN,isIssue:()=>Wy,makeCompositeAtKey:()=>Zn,makeFormatterDefault:()=>IN,makeFormatterStandardSchemaV1:()=>SI,makeSingle:()=>hI,normalizeFilterOutput:()=>gI});var Ke=Symbol();var ss=Pn,zs=ss(Ke),ln=ss(Ke),$y=e=>e===Ke?D():L(e),pI=e=>e._tag==="None"?zs:ss(e.value);var km="~effect/SchemaIssue/Issue";function Wy(e){return N(e,km)&&e[km]===km}function TN(e){return Object.hasOwn(e,"input")}var _o=class{[km]=km;constructor(t,n){n?.reportInput===!0&&t!==Ke&&(this.input=t)}},Am=class extends _o{_tag="Filter";filter;issue;constructor(t,n,r,o){super(r,o),this.filter=t,this.issue=n}},Rm=class extends _o{_tag="Encoding";ast;issue;constructor(t,n,r,o){super(r,o),this.ast=t,this.issue=n}},kt=class extends _o{_tag="Pointer";path;issue;constructor(t,n){super(),this.path=t,this.issue=n}},tn=class extends _o{_tag="MissingKey";annotations;constructor(t){super(),this.annotations=t}},_i=class extends _o{_tag="UnexpectedKey";ast;constructor(t,n,r){super(n,r),this.ast=t}},At=class extends _o{_tag="Composite";ast;issues;constructor(t,n,r,o){super(r,o),this.ast=t,this.issues=n}},tt=class extends _o{_tag="InvalidType";ast;constructor(t,n,r){super(n,r),this.ast=t}},Oe=class extends _o{_tag="InvalidValue";annotations;constructor(t,n,r){super(n,r),this.annotations=t}};function Zn(e,t,n,r,o){return new At(e,[new kt([t],n)],r,o)}var Pc=class extends _o{_tag="Forbidden";annotations;constructor(t,n,r){super(n,r),this.annotations=t}},cf=class extends _o{_tag="AnyOf";ast;issues;constructor(t,n,r,o){super(r,o),this.ast=t,this.issues=n}},Cm=class extends _o{_tag="OneOf";ast;successes;constructor(t,n,r,o){super(r,o),this.ast=t,this.successes=n}};function mI(e,t,n){if(Wy(e))return e;if(typeof e=="string")return new Oe({message:e},t,n);let r=typeof e.issue=="string"?new Oe({message:e.issue},t,n):e.issue;return new kt(e.path,r)}function hI(e,t,n){if(e!==void 0)return typeof e=="boolean"?e?void 0:new Oe(void 0,t,n):mI(e,t,n)}function gI(e,t,n,r){return Array.isArray(t)?et(t)?t.length===1?mI(t[0],n,r):new At(e,Is(t,o=>mI(o,n,r)),n,r):void 0:hI(t,n,r)}var xI=e=>{let t=sd(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return Mc(Tm(e.ast),e);case"InvalidValue":{let n=bI(e);if(n!==void 0)return Mc(n,e);let r=zy(e);return r===void 0?"Expected a valid value":`Invalid data ${r}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let n=zy(e);return n===void 0?"Expected no excess property":`Unexpected key with value ${n}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let n=zy(e);return n===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${n}`}}},yI=e=>sd(e.issue)??sd(e);function SI(e){return t=>({issues:od(t,[],e?.leafHook??xI,e?.checkHook??yI)})}function zy(e){return TN(e)?re(e.input):void 0}function bI(e){let t=e.annotations?.expected;return typeof t=="string"?t:void 0}function Mc(e,t){let n=zy(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function od(e,t,n,r){switch(e._tag){case"Filter":{let o=r(e);if(o!==void 0)return[{path:t,message:o}];if(e.issue._tag!=="InvalidValue")return od(e.issue,t,n,r);let s=bI(e.issue);return[{path:t,message:s===void 0?Mc(EI(e.filter),e):Mc(s,e.issue)}]}case"Encoding":return od(e.issue,t,n,r);case"Pointer":return od(e.issue,[...t,...e.path],n,r);case"Composite":return e.issues.flatMap(o=>od(o,t,n,r));case"AnyOf":return e.issues.length===0?[{path:t,message:sd(e)??Mc(Tm(e.ast),e)}]:e.issues.flatMap(o=>od(o,t,n,r));default:return[{path:t,message:n(e)}]}}function EI(e){let t=e.annotations?.expected;if(typeof t=="string")return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map(n=>EI(n)).join(" & ")}}function IN(){return e=>Im(e,"")}var wI=IN();function Im(e,t){let n;switch(e._tag){case"Filter":{let r=yI(e);if(r!==void 0)n=r;else{if(e.issue._tag!=="InvalidValue")return Im(e.issue,t);let o=bI(e.issue);n=o===void 0?Mc(EI(e.filter),e):Mc(o,e.issue)}break}case"Encoding":return Im(e.issue,t);case"Pointer":return Im(e.issue,t+Yg(e.path));case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map(r=>Im(r,t)).join(`
25
- `);n=sd(e)??Mc(Tm(e.ast),e);break}default:n=xI(e);break}return t?`${n}
26
- at ${t}`:n}function sd(e){if(e._tag==="Pointer")return;if(e._tag==="Encoding")return sd(e.issue);let n=(e._tag==="Filter"?e.filter.annotations:"annotations"in e?e.annotations:e.ast.annotations)?.[e._tag==="MissingKey"?"messageMissingKey":e._tag==="UnexpectedKey"?"messageUnexpectedKey":"message"];if(typeof n=="string")return n}function Om(e){let t;for(let n of e.reasons){if(!tm(n)||!Wy(n.error))return;t??=n.error}return t}function Mi(e,t){let n=Om(e);if(n===void 0)throw new Error(t,{cause:e});return n}var uf=Wl,AN=Zu,RN=T1,CN=I1,ON=k1,_N=ET,vI=A1,TI=R1;var MN=Gu,PN=vy;var Ky=wT;var Vy=O1,FN=_1;var Jy=M1;var II=vT,_m=am,UN=TT;var NN=IT,Fc=P1;var Gy=cm;var DN=RT;var LN=U1;var Zy=OT;var Uc=class e extends uu{run;constructor(t){super(),this.run=t}map(t){return new e((n,r)=>this.run(n,r).pipe(_a(Kt(t))))}compose(t){return qN(this)?t:qN(t)?this:new e((n,r)=>this.run(n,r).pipe(Gn(o=>t.run(o,r))))}};function NZ(e){return new Uc((t,n)=>Q(e(t,n)))}function kI(e){return NZ((t,n)=>{let r={message:e(t)};return _e(t)?new Pc(r,t.value,n):new Pc(r)})}var jN=new Uc(k);function qN(e){return e.run===jN.run}function Ws(){return jN}function AI(e){return new Uc((t,n)=>Se(t)?js:e(t.value,n))}function Le(e){return Qy(Kt(e))}function uo(e){return AI((t,n)=>e(t,n).pipe(_a(L)))}function Qy(e){return new Uc(t=>k(e(t)))}function RI(){return new Uc(()=>js)}function Pm(e){return new Uc(t=>{let n=fc(t,qn);return _e(n)?k(n):_a(e,L)})}function ff(){return Le(globalThis.String)}function Yy(){return Le(globalThis.Number)}function BN(){return Le(globalThis.BigInt)}function CI(){return Le(e=>new globalThis.Date(e))}function $N(){return Le($1)}function HN(e){return AI((t,n)=>ts({try:()=>L(JSON.parse(t,e?.reviver)),catch:()=>new Oe({expected:"a valid JSON string"},t,n)}))}function zN(e){return AI((t,n)=>ts({try:()=>{let r=JSON.stringify(t,e?.replacer,e?.space);if(r===void 0)throw new TypeError("Value cannot be represented as JSON");return L(r)},catch:()=>new Oe({expected:"a JSON-serializable value"},t,n)}))}function OI(){return Le(wx)}function Xy(){return Le(tP)}function eS(){return Le(rP)}function WN(){return uo((e,t)=>nf($T(Al(e)),()=>new Oe({expected:"a valid Base64 string"},e,t)))}function KN(){return uo((e,t)=>Zr(eP(e),{onFailure:()=>Q(new Oe({expected:"a valid Base64 string"},e,t)),onSuccess:k}))}function VN(){return uo((e,t)=>Zr(Kw(e),{onFailure:()=>Q(new Oe({expected:"a valid Base64Url string"},e,t)),onSuccess:k}))}function JN(){return uo((e,t)=>Zr(nP(e),{onFailure:()=>Q(new Oe({expected:"a valid Base64Url string"},e,t)),onSuccess:k}))}function GN(){return uo((e,t)=>Zr(Jw(e),{onFailure:()=>Q(new Oe({expected:"a valid hexadecimal string"},e,t)),onSuccess:k}))}function ZN(){return uo((e,t)=>Zr(oP(e),{onFailure:()=>Q(new Oe({expected:"a valid hexadecimal string"},e,t)),onSuccess:k}))}function QN(){return Le(encodeURIComponent)}function YN(){return uo((e,t)=>{try{return k(globalThis.decodeURIComponent(e))}catch{return Q(new Oe({expected:"a valid URI component"},e,t))}})}function _I(){return uo((e,t)=>mr(Vy(e),{onNone:()=>Q(new Oe({message:"Invalid DateTime input"},e,t)),onSome:n=>k(Jy(n))}))}function XN(){return Le(e=>rD(Array.from(e.entries())))}var DZ=oD(e=>typeof e=="string"||typeof Blob<"u"&&e instanceof Blob);function eD(){return Le(e=>{let t=new FormData;return typeof e=="object"&&e!==null&&DZ(e).forEach(([r,o])=>{t.append(r,o)}),t})}function tD(){return Le(e=>rD(Array.from(e.entries())))}var LZ=oD(Gr);function nD(){return Le(e=>typeof e=="object"&&e!==null?new URLSearchParams(LZ(e)):new URLSearchParams)}var qZ=/^\d+$/;function jZ(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),n=t.split("."),r=t.startsWith(".")?1:0;return n.slice(r).map(o=>qZ.test(o)?globalThis.Number(o):o)}function rD(e){let t={},n=new WeakSet;function r(o,s,i){let a=Object.hasOwn(o,s)?o[s]:void 0;if(n.has(a)&&Array.isArray(a)===i)return a;let c=i?[]:{};return n.add(c),K(o,s,c),c}return e.forEach(([o,s])=>{let i=jZ(o),a=t;i.forEach((c,u)=>{let f=u===i.length-1;if(Array.isArray(a)&&c==="")if(f)a.push(s);else{let l=i[u+1],p=typeof l=="number"||l==="",h=a.length;a=r(a,h,p)}else if(f){let l=Object.hasOwn(a,c);l&&Array.isArray(a[c])?a[c].push(s):l?K(a,c,[a[c],s]):K(a,c,s)}else{let l=i[u+1];a=r(a,c,typeof l=="number"||l==="")}})}),t}function oD(e){return t=>{let n=[];function r(o,s){if(e(s))n.push([o,s]);else if(Array.isArray(s))s.every(e)?s.forEach(a=>{n.push([o,a])}):s.forEach((a,c)=>{r(`${o}[${c}]`,a)});else if(typeof s=="object"&&s!==null)for(let[i,a]of Object.entries(s))r(`${o}[${i}]`,a)}for(let[o,s]of Object.entries(t))r(o,s);return n}}var Um=class e{_tag="Middleware";decode;encode;constructor(t,n){this.decode=t,this.encode=n}flip(){return new e(this.encode,this.decode)}},Fm="~effect/SchemaTransformation/Transformation",nt=class e{[Fm]=Fm;_tag="Transformation";decode;encode;constructor(t,n){this.decode=t,this.encode=n}flip(){return new e(this.encode,this.decode)}compose(t){return new e(this.decode.compose(t.decode),t.encode.compose(this.encode))}};function BZ(e){return N(e,Fm)&&e[Fm]===Fm}var nS=e=>BZ(e)?e:new nt(e.decode,e.encode);function qr(e){return new nt(uo(e.decode),uo(e.encode))}function Rt(e){return new nt(Le(e.decode),Le(e.encode))}function rS(e){return new nt(Qy(e.decode),Qy(e.encode))}function sD(){return new nt($N(),Ws())}var $Z=new nt(Ws(),Ws());function id(){return $Z}var ad=new nt(Yy(),ff()),oS=new nt(BN(),ff()),MI=new nt(CI(),Le(uw)),iD=new nt(CI(),Le(e=>e.getTime())),aD=qr({decode:(e,t)=>mr(jM(e),{onNone:()=>Q(new Oe({expected:"a valid Duration string"},e,t)),onSome:k}),encode:e=>k(globalThis.String(e))}),cD=qr({decode:e=>k(Qr(e)),encode:(e,t)=>mr(BM(e),{onNone:()=>Q(new Oe({expected:"a Duration representable as a bigint"},e,t)),onSome:n=>k(n)})}),uD=Rt({decode:e=>As(e),encode:e=>vn(e)}),HZ=e=>Wt(e)&&typeof e.message=="string",fD=e=>{let n=Object.hasOwn(e,"cause")?new Error(e.message,{cause:dD(e.cause)}):new Error(e.message);return typeof e.name=="string"&&e.name!=="Error"&&(n.name=e.name),typeof e.stack=="string"&&(n.stack=e.stack),n},zZ=e=>{try{let t=gu(e);return t===void 0?re(e):JSON.parse(t)}catch{return re(e)}},WZ=(e,t,n)=>{let r={name:e.name,message:typeof e.message=="string"?e.message:""};return t?.includeStack&&typeof e.stack=="string"&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},lD=e=>{let t=new WeakSet,n=r=>{if(Q0(r)){if(t.has(r))return"[Circular]";t.add(r);let o=WZ(r,e,n);return t.delete(r),o}return zZ(r)};return n},dD=e=>HZ(e)?fD(e):e,pD=e=>Rt({decode:fD,encode:t=>lD(e)(t)}),mD=e=>Rt({decode:dD,encode:lD(e)});function hD(){return Rt({decode:xw,encode:Cp})}function gD(){return Rt({decode:gw,encode:Ko})}function xD(e){return Rt({decode:Au,encode:e?.onNoneEncoding===null?Cp:Ko})}function yD(){return rS({decode:L,encode:Ru})}function SD(){return rS({decode:e=>e.pipe(fc(qn),L),encode:Ru})}var PI=qr({decode:(e,t)=>URL.canParse(e)?k(new URL(e)):Q(new Oe({expected:"a valid URL string"},e,t)),encode:e=>k(e.href)}),FI=qr({decode:(e,t)=>{let n=xM(e);return Se(n)?Q(new Oe({expected:"a valid BigDecimal string"},e,t)):k(n.value)},encode:e=>k(gi(e))}),UI=new nt(WN(),OI()),bD=new nt(KN(),OI()),ED=new nt(JN(),Xy()),wD=new nt(ZN(),eS()),vD=new nt(YN(),QN());function TD(e){return new nt(HN(e??{}),zN(e))}var ID=new nt(XN(),eD()),kD=new nt(tD(),nD()),AD=Rt({decode:e=>_m(e),encode:e=>e.offset}),NI=qr({decode:(e,t)=>mr(UN(e),{onNone:()=>Q(new Oe({expected:"a valid IANA time zone"},e,t)),onSome:k}),encode:e=>k(e.id)}),DI=qr({decode:(e,t)=>mr(NN(e),{onNone:()=>Q(new Oe({expected:"a valid time zone"},e,t)),onSome:k}),encode:e=>k(Fc(e))}),LI=qr({decode:(e,t)=>mr(Vy(e),{onNone:()=>Q(new Oe({expected:"a valid UTC DateTime string"},e,t)),onSome:n=>k(Jy(n))}),encode:e=>k(LN(e))}),qI=qr({decode:(e,t)=>mr(FN(e),{onNone:()=>Q(new Oe({expected:"a valid Zoned DateTime string"},e,t)),onSome:k}),encode:e=>k(Zy(e))});function gn(e){return t=>t._tag===e}function KZ(e){return N(e,Lm)&&e[Lm]===Lm}var Pa=gn("Declaration"),VZ=gn("Null"),JZ=gn("Undefined"),GZ=gn("Void"),UD=gn("Never"),ZZ=gn("Unknown"),QZ=gn("Any"),YZ=gn("String"),XZ=gn("Number"),eQ=gn("Boolean"),tQ=gn("BigInt"),nQ=gn("Symbol"),lf=gn("Literal"),sS=gn("UniqueSymbol"),rQ=gn("ObjectKeyword"),oQ=gn("Enum"),sQ=gn("TemplateLiteral"),SS=gn("Arrays"),ND=gn("Objects"),KI=gn("Union"),DD=gn("Suspend"),jt=class{to;transformation;constructor(t,n){this.to=t,this.transformation=n}},$r={},Br=class{isOptional;isMutable;constructorDefault;annotations;constructor(t,n,r=void 0,o=void 0){this.isOptional=t,this.isMutable=n,this.constructorDefault=r,this.annotations=o}},Lm="~effect/Schema",Yt=class{[Lm]=Lm;annotations;checks;encoding;context;constructor(t=void 0,n=void 0,r=void 0,o=void 0){this.annotations=t,this.checks=n,this.encoding=r,this.context=o}toString(){return`<${this._tag}>`}},Pi=class e extends Yt{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(t,n,r,o,s,i,a,c){super(r,o,s,i),this.typeParameters=t,this.run=n,this.encodingChecks=a,this.encodingRun=c}getParser(){let t;return(n,r)=>n===Ke?zs:(t??=this.run(this.typeParameters))(n,this,r)}_rebuild(t,n,r,o,s){let i=pf(this.typeParameters,t);return i===this.typeParameters&&n===this.checks&&r===this.encodingChecks&&o===this.run&&s===this.encodingRun?this:new e(i,o,this.annotations,n,void 0,this.context,r,s)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let t=this.annotations?.expected;return typeof t=="string"?t:"<Declaration>"}},iS=class extends Yt{_tag="Null";getParser(){return CS(this,null)}getExpected(){return"null"}},bS=new iS;var aS=class extends Yt{_tag="Undefined";getParser(){return CS(this,void 0)}toCodecJson(){return ct(this,[LD])}getExpected(){return"undefined"}},LD=new jt(bS,new nt(Le(()=>{}),Le(()=>null))),ES=new aS;var cS=class extends Yt{_tag="Void";getParser(){let t=ss(void 0);return n=>n===Ke?zs:t}toCodecJson(){return ct(this,[LD])}getExpected(){return"void"}},VI=new cS;var uS=class extends Yt{_tag="Never";getParser(){return Js(this,Z0)}getExpected(){return"never"}},JI=new uS,fS=class extends Yt{_tag="Any";getParser(){return Js(this,Kg)}getExpected(){return"any"}},GI=new fS,lS=class extends Yt{_tag="Unknown";getParser(){return Js(this,Kg)}getExpected(){return"unknown"}},Fi=new lS,dS=class extends Yt{_tag="ObjectKeyword";getParser(){return Js(this,il)}getExpected(){return"object | array | function"}},ZI=new dS,qm=class extends Yt{_tag="Enum";enums;constructor(t,n,r,o,s){super(n,r,o,s),this.enums=t}getParser(){let t=new Set(this.enums.map(([,n])=>n));return Js(this,n=>t.has(n))}toCodecStringTree(){if(this.enums.some(([t,n])=>typeof n=="number")){let t=Object.fromEntries(this.enums.map(([n,r])=>[globalThis.String(r),r]));return ct(this,[new jt(new br(Object.keys(t).map(n=>new jr(n)),"anyOf"),new nt(Le(n=>t[n]),ff()))])}return this}getExpected(){return this.enums.map(([t,n])=>JSON.stringify(n)).join(" | ")}};function qD(e){switch(e._tag){case"String":case"Number":case"BigInt":return!0;case"Literal":case"TemplateLiteral":return!e.checks;case"Union":return!e.checks&&e.types.every(qD);default:return!1}}var jm=class extends Yt{_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(t,n,r,o,s){super(n,r,o,s);let i=[],a=[];for(let u of t){let f=Nn(u);if(qD(f))i.push(f),a.push(f._tag==="Literal"?globalThis.String(f.literal):void 0);else throw new Error(`Invalid TemplateLiteral part ${f._tag}`)}let c=new Array(i.length+1);c[i.length]=0;for(let u=i.length-1;u>=0;u--)c[u]=c[u+1]+(a[u]?.length??0);this.parts=t,this.encodedParts=i,this.literals=a,this.suffixLengths=c}getParser(t){let n=t(this.asTemplateLiteralParser());return(r,o)=>{if(r===Ke)return zs;let s=n(r,o);return s._tag==="Success"?ln:mn(s,{onSuccess:()=>r,onFailure:i=>new At(this,[i],r,o)})}}getExpected(){return"string"}matchPart(t,n){return FD(this,t,n)===void 0?void 0:t}asTemplateLiteralParser(){let t=new as(!1,this.parts.map(zD),[]);return Ym(Ks,t,new nt(uo((n,r)=>{let o=FD(this,n,r);return o?k(o):Q(new Oe({expected:"a string matching template literal parts"},n,r))}),Le(n=>n.join(""))))}},Bm=class extends Yt{_tag="UniqueSymbol";symbol;constructor(t,n,r,o,s){super(n,r,o,s),this.symbol=t}getParser(){return CS(this,this.symbol)}toCodecStringTree(){return ct(this,[VD])}getExpected(){return globalThis.String(this.symbol)}},jr=class extends Yt{_tag="Literal";literal;constructor(t,n,r,o,s){if(super(n,r,o,s),typeof t=="number"&&!globalThis.Number.isFinite(t))throw new Error(`A numeric literal must be finite, got ${re(t)}`);this.literal=t}getParser(){return CS(this,this.literal)}matchPart(t,n){return t===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal=="bigint"?RD(this):this}toCodecStringTree(){return typeof this.literal=="string"?this:RD(this)}getExpected(){return typeof this.literal=="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function RD(e){let t=globalThis.String(e.literal);return ct(e,[new jt(new jr(t),new nt(Le(()=>e.literal),Le(()=>t)))])}var pS=class extends Yt{_tag="String";getParser(){return Js(this,Gr)}matchPart(t,n){let r=this.checks;return r&&!n.disableChecks&&cs(r,t,void 0,this,n)?void 0:t}getExpected(){return"string"}},Ks=new pS,mS=class extends Yt{_tag="Number";getParser(){return Js(this,ol)}matchKey(t,n){return this._match(yQ,t,n)}matchPart(t,n){return this._match(HI,t,n)}_match(t,n,r){if(!t.test(n))return;let o=globalThis.Number(n);return r.disableChecks||!this.checks?o:cs(this.checks,o,void 0,this,r)?void 0:o}toCodecJson(){return this.checks&&(jI(this.checks,"effect/schema/isFinite")||jI(this.checks,"effect/schema/isInt"))?this:ct(this,[lQ])}toCodecStringTree(){return this.toCodecJson()===this?ct(this,[SQ]):ct(this,[bQ])}getExpected(){return"number"}};function jI(e,t){return e.some(n=>n.annotations?.representation?.id===t||n._tag==="FilterGroup"&&jI(n.checks,t))}var wS=new mS,hS=class extends Yt{_tag="Boolean";getParser(){return Js(this,K0)}getExpected(){return"boolean"}},QI=new hS,gS=class extends Yt{_tag="Symbol";getParser(){return Js(this,Wg)}matchKey(t,n){return n.disableChecks||!this.checks?t:cs(this.checks,t,void 0,this,n)?void 0:t}toCodecStringTree(){return ct(this,[VD])}getExpected(){return"symbol"}},YI=new gS,xS=class extends Yt{_tag="BigInt";getParser(){return Js(this,V0)}matchPart(t,n){if(!zI.test(t))return;let r=globalThis.BigInt(t);return n.disableChecks||!this.checks?r:cs(this.checks,r,void 0,this,n)?void 0:r}toCodecStringTree(){return ct(this,[wQ])}getExpected(){return"bigint"}},XI=new xS,as=class e extends Yt{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(t,n,r,o,s,i,a,c){super(o,s,i,a),this.isMutable=t,this.elements=n,this.rest=r,this.encodingChecks=c;let u=!1;for(let f=0;f<n.length;f++)if(nn(n[f]))u=!0;else if(u)throw new Error("A required element cannot follow an optional element. ts(1257)");if(u&&r.length>1)throw new Error("A required element cannot follow an optional element. ts(1257)");for(let f=1;f<r.length;f++)if(nn(r[f]))throw new Error("An optional element cannot follow a rest element. ts(1266)")}getParser(t,n=t){let r=this,o,s,i=r.elements.length,a=Math.max(0,r.rest.length-1);function c(u,f){return f<i?o[f]:f>=u?s[f-u+1]:s[0]}return qy(function*(u,f){if(u===Ke)return Ke;if(!Array.isArray(u))return yield*Q(new tt(r,u,f));o||(o=r.elements.map(x=>({ast:x,parser:n(x)})),s=r.rest.map(x=>({ast:x,parser:n(x)})));let l=u.length,p={ast:r,getParser:c,input:u,len:l,tailThreshold:Math.max(i,l-a),output:new globalThis.Array(l),issues:void 0,options:f},h=ek(f?.concurrency),g=iQ(p,u,{concurrency:h?.concurrency,end:r.rest.length===0?i:Math.max(l,i+a)});if(g&&(yield*g),r.rest.length===0&&l>i)for(let x=i;x<=l-1;x++){let S=new _i(r,u[x],f),w=new kt([x],S);if(f.errors==="all")p.issues?p.issues.push(w):p.issues=[w];else return yield*Q(new At(r,[w],u,f))}return p.issues?yield*Q(new At(r,p.issues,u,f)):p.output})}_rebuild(t,n,r){let o=pf(this.elements,t),s=pf(this.rest,t);return o===this.elements&&s===this.rest&&n===this.checks&&r===this.encodingChecks?this:new e(this.isMutable,o,s,this.annotations,n,void 0,this.context,r)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}getExpected(){return"array"}},iQ=em()({onItem(e,t,n){let r=n<e.len?t:Ke;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step(e,t,n,r){if(n._tag==="Failure")return yS(e,e.ast,r,n);let o=n===ln?t:n[be];if(o!==Ke)e.output[r]=o;else{let s=e.getParser(e.tailThreshold,r);if(nn(s.ast))return;let i=new kt([r],new tn(s.ast.context?.annotations));if(e.options.errors==="all")e.issues?e.issues.push(i):e.issues=[i];else return Zo(new At(e.ast,[i],e.input,e.options))}}}),ek=e=>(e=e==="unbounded"?1/0:e??1,e>1?{concurrency:e}:void 0),yS=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let o=Om(r.cause);if(o===void 0)return Jt(ka(r.cause,i=>new At(t,[new kt([n],i)],e.input,e.options)));let s=new kt([n],o);if(e.options.errors==="all")e.issues?e.issues.push(s):e.issues=[s];else return Zo(new At(t,[s],e.input,e.options))},zm="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function Ui(e,t,n=$r){let r,o;function s(i){switch(i._tag){case"String":case"TemplateLiteral":return(r??=Object.keys(e)).filter(a=>i.matchPart(a,n)!==void 0);case"Number":return(r??=Object.keys(e)).filter(a=>i.matchKey(a,n)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter(a=>i.matchKey(a,n)!==void 0);case"Union":return[...new Set(i.types.flatMap(s))];default:return[]}}return s(mk(Nn(t)))}var cd=class{name;type;constructor(t,n){this.name=t,this.type=n}};function BI(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(BI);default:return!1}}function aQ(e){return BI(e)&&BI(Nn(e))}var ud=class{parameter;type;constructor(t,n){if(!aQ(t))throw new Error(`Invalid index signature parameter ${t._tag}`);if(this.parameter=t,this.type=n,nn(n)&&!pk(n))throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},df=class e extends Yt{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(t,n,r,o,s,i,a){super(r,o,s,i),this.propertySignatures=t,this.indexSignatures=n,this.encodingChecks=a;let c=t.map(u=>u.name).filter((u,f,l)=>l.indexOf(u)!==f);if(c.length>0)throw new Error(`Duplicate identifiers: ${JSON.stringify(c)}. ts(2300)`)}getParser(t,n=t){let r=this,o=[];for(let w of r.propertySignatures)o.push(w.name);let s=o.length,i=r.indexSignatures.length,a=s&&i?new Set(o):void 0;if(!s&&!i)return Js(r,xp);let c,u,f=(w,E,y,v,b)=>{if(b._tag==="Failure")return yS(w,r,E,b)??en;let T=b===ln?v:b[be];if(y!==Ke&&T!==Ke){if(s&&(a.has(E)||a.has(y)))return en;K(w.out,y,T)}return en},l=(w,E,y,v)=>{if(!v){let C=y.parserKey(E,w.options);if(!bt(C))return _(so(C),P=>l(w,E,y,P));v=C}if(v._tag==="Failure")return yS(w,r,E,v)??en;let b=v===ln?E:v[be],T=w.input[E],R=y.parserValue(T,w.options);return bt(R)?f(w,E,b,T,R):_(so(R),C=>f(w,E,b,T,C))},p=(w,E,y)=>{let v=w.input[E],b=y.parserValue(v,w.options);return bt(b)?f(w,E,E,v,b):_(so(b),T=>f(w,E,E,v,T))},h=i?em()({onItem:(w,[E,y])=>l(w,E,y),step:(w,E,y)=>y._tag==="Failure"?y:void 0}):void 0,g=()=>(c||(c=r.propertySignatures.map(w=>({parser:n(w.type),name:w.name,type:w.type})),u=i?r.indexSignatures.map(w=>({is:w,parserKey:t(mk(w.parameter)),parserValue:n(w.type)})):void 0),c),x=qy(function*(w,E){if(w===Ke)return Ke;if(!(typeof w=="object"&&w!==null&&!Array.isArray(w)))return yield*Q(new tt(r,w,E));g();let y=w,v={},b={ast:r,input:y,out:v,issues:void 0,options:E},T=E.errors==="all",R=E.onExcessProperty==="error",C=E.onExcessProperty==="preserve",P;if(!i&&(R||C)){a??=new Set(o),P=Reflect.ownKeys(y);for(let F=0;F<P.length;F++){let Z=P[F];if(!a.has(Z))if(R){let z=new _i(r,y[Z],E),A=new kt([Z],z);if(T){b.issues?b.issues.push(A):b.issues=[A];continue}else return yield*Q(new At(r,[A],w,E))}else K(v,Z,y[Z])}}let B=ek(E?.concurrency);if(s){let F=CD(b,c,B);F&&(yield*F)}if(i&&!B)for(let F=0;F<i;F++){let Z=u[F],z=Z.is.parameter===Ks?p:l,A=Z.is.parameter===Ks?Object.keys(y):Ui(y,Z.is.parameter,E);for(let H=0;H<A.length;H++){let U=z(b,A[H],Z);if(!bt(U))yield*U;else if(U._tag==="Failure")return yield*U}}else if(h){let F=fn();for(let z=0;z<i;z++){let A=u[z],H=Ui(y,A.is.parameter,E);for(let U=0;U<H.length;U++)F.push([H[U],A])}let Z=h(b,F,B);Z&&(yield*Z)}if(b.issues)return yield*Q(new At(r,b.issues,w,E));if(E.propertyOrder==="original"){let F=(P??Reflect.ownKeys(y)).concat(o),Z={};for(let z of F)Object.hasOwn(v,z)&&K(Z,z,v[z]);return Z}return v});if(i)return x;let S=(w,E,y)=>{let v=c[E];return _(so(y),b=>{let T=$I(w,v,b);if(T)return T;let R=()=>ss(w.out),C=CD(w,c.slice(E+1));return C?Gn(C,R):R()})};return(w,E)=>{if(w===Ke)return zs;if(E.errors==="all"||E.onExcessProperty!==void 0||E.propertyOrder==="original"||E.concurrency!==void 0)return x(w,E);if(!(typeof w=="object"&&w!==null&&!Array.isArray(w)))return Q(new tt(r,w,E));let y=g(),v=w,b={},T={ast:r,input:v,out:b,issues:void 0,options:E};try{for(let R=0;R<y.length;R++){let C=y[R],P=C.name,B=Object.hasOwn(v,P),F=B?v[P]:Ke,Z=C.parser(F,E);if(!bt(Z))return S(T,R,Z);if(Z===ln){B&&K(b,P,F);continue}let z=$I(T,C,Z);if(z)return z}}catch(R){return Ao(R)}return ss(b)}}_rebuild(t,n,r,o){let s=pf(this.propertySignatures,a=>{let c=t(a.type);return c===a.type?a:new cd(a.name,c)}),i=pf(this.indexSignatures,a=>{let c=n(a.parameter),u=t(a.type);return c===a.parameter&&u===a.type?a:new ud(c,u)});return s===this.propertySignatures&&i===this.indexSignatures&&r===this.checks&&o===this.encodingChecks?this:new e(s,i,this.annotations,r,void 0,this.context,o)}flip(t){return this._rebuild(t,t,this.encodingChecks,this.checks)}recur(t,n=t){return this._rebuild(t,n,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?"object | array":"object"}};function $I(e,t,n){if(n._tag==="Failure")return yS(e,e.ast,t.name,n);if(n===ln)return;let r=n[be];if(r!==Ke){K(e.out,t.name,r);return}if(delete e.out[t.name],!nn(t.type)){let o=new kt([t.name],new tn(t.type.context?.annotations));if(e.options.errors==="all"){e.issues?e.issues.push(o):e.issues=[o];return}else return Zo(new At(e.ast,[o],e.input,e.options))}}var CD=em()({onItem(e,t){if(!Object.hasOwn(e.input,t.name))return t.parser(Ke,e.options);let n=e.input[t.name];return K(e.out,t.name,n),t.parser(n,e.options)},step:$I});function tk(e,t){return e?t?[...e,...t]:e:t}function Wm(e,t,n){return new df(Reflect.ownKeys(e).map(r=>new cd(r,e[r].ast)),[],n,t)}function fd(e){return e.ast}function vS(e,t=void 0){return new as(!1,e.map(n=>n.ast),[],void 0,t)}function Km(e,t,n){return new br(e.map(fd),t,void 0,n)}function nk(e,t){if(e.encoding||t.some(s=>s.encoding))throw new Error("StructWithRest does not support encodings");let n=e.propertySignatures,r=e.indexSignatures,o=e.checks;for(let s of t)n=n.concat(s.propertySignatures),r=r.concat(s.indexSignatures),o=tk(o,s.checks);return new df(n,r,void 0,o)}function rk(e,t){if(e.encoding)throw new Error("TupleWithRest does not support encodings");return new as(e.isMutable,e.elements,t,void 0,e.checks)}var TS=du(e=>{for(;;){if(DD(e))return Fi;let t=e.encoding;if(!t)return e.recur?.(TS,j)??e;if(t.some(n=>n.transformation._tag==="Middleware"&&n.transformation.decode!==j))return Fi;e=t[t.length-1].to}});function jD(e){switch(e._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return e.propertySignatures.length||e.indexSignatures.length?["object"]:["string","number","boolean","symbol","bigint","object","array","function"];case"Enum":return Array.from(new Set(e.enums.map(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(jD)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function Ma(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[vm];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(t=>{let n=t.type;if(!nn(n)){if(lf(n))return[{key:t.name,literal:n.literal}];if(sS(n))return[{key:t.name,literal:n.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,n)=>{if(!nn(t)){if(lf(t))return[{key:n,literal:t.literal}];if(sS(t))return[{key:n,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map(n=>Ma(TS(n)));return t[0].filter(n=>t.every(r=>r.some(o=>o.key===n.key&&o.literal===n.literal)))}case"Suspend":return Ma(e.thunk())}}var OD=new WeakMap,Dm=Object.freeze([]);function cQ(e){let t=OD.get(e);if(t)return t;let n,r=0,o,s,i=!0;for(let a=0;a<e.length;a++){let c=e[a],u=TS(c);if(UD(u))continue;if(i)if(lf(u)||sS(u)){s??=new Map;let l=lf(u)?u.literal:u.symbol,p=s.get(l);p||s.set(l,p=[]),p.push(c)}else i=!1;let f=Ma(u);if(f.length){n??=new Map,r++;for(let{key:l,literal:p}of f){let h=n.get(l);h||n.set(l,h=[new Map,new Set]),h[1].add(a);let g=h[0].get(p);g||h[0].set(p,g=new Set),g.add(a)}}else{o??={};let l=jD(u);for(let p of l)(o[p]??=[]).push(a)}}if(i&&s)s.forEach(Object.freeze),t=a=>s.get(a)??Dm;else if(n?.size===1&&!o){let[a,[c]]=n.entries().next().value,u=c;for(let[f,l]of c)u.set(f,Object.freeze(Array.from(l,p=>e[p])));t=(f,l)=>{if(il(f)){let p=Object.hasOwn(f,a)?f[a]:void 0;if(p!==void 0)return u.get(p)??Dm;if(l)return e}return Dm}}else if(n){let a;for(let c of n)(!a||c[1][0].size>a[1][0].size)&&c[1][1].size===r&&(a=c);t=(c,u)=>{let f=c===null?"null":Array.isArray(c)?"array":typeof c,l=o?.[f]??Dm;if(!il(c))return l.map(g=>e[g]);let p=new Set(l),h;if(a){let[g,[x]]=a,S=Object.hasOwn(c,g),w=S?c[g]:void 0;if(S&&(!u||w!==void 0)){let E=x.get(w);if(!E)return l.map(y=>e[y]);for(let y of E)p.add(y);h=g}}if(h===void 0)for(let[g,[x,S]]of n){let w=Object.hasOwn(c,g),E=w?c[g]:void 0;if(w&&(!u||E!==void 0)){let y=x.get(E);if(y)for(let v of y)p.add(v)}else if(u)for(let y of S)p.add(y)}for(let[g,[x,S]]of n){if(g===h)continue;let w=Object.hasOwn(c,g),E=w?c[g]:void 0;if(w&&(!u||E!==void 0)){let y=x.get(E);for(let v of p)S.has(v)&&!y?.has(v)&&p.delete(v)}}return Array.from(p).sort((g,x)=>g-x).map(g=>e[g])}}else t=a=>{let c=a===null?"null":Array.isArray(a)?"array":typeof a;return(o?.[c]??Dm).map(u=>e[u]).filter(uQ(a))};return OD.set(e,t),t}function uQ(e){return t=>{let n=TS(t);return n._tag==="Literal"?n.literal===e:n._tag==="UniqueSymbol"?n.symbol===e:!0}}function ld(e,t,n=!1){return cQ(t)(e,n)}var br=class e extends Yt{_tag="Union";types;mode;encodingChecks;constructor(t,n,r,o,s,i,a){super(r,o,s,i),this.types=t,this.mode=n,this.encodingChecks=a}getParser(t,n){let r=this;return(o,s)=>{if(o===Ke)return zs;let i=ld(o,r.types,n!==void 0);if(i.length===1){let f=t(i[0])(o,s);return f._tag==="Success"?f:bt(f)?_D(r,f.cause,o,s):ht(f,l=>_D(r,l,o,s))}let a={ast:r,compile:t,input:o,out:void 0,successes:r.mode==="oneOf"?[]:void 0,issues:void 0,options:s},c=ek(s?.concurrency),u=fQ(a,i,c?{...c,orderedStep:!0}:void 0);return u?Gn(u,f=>a.out===ln?k(o):a.out?a.out:Q(new cf(r,a.issues??[],o,s))):a.out?a.out:Q(new cf(r,a.issues??[],o,s))}}_rebuild(t,n,r){let o=pf(this.types,t);return o===this.types&&n===this.checks&&r===this.encodingChecks?this:new e(o,this.mode,this.annotations,n,void 0,this.context,r)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}matchPart(t,n){for(let r of this.types){let o=r.matchPart(t,n);if(o!==void 0)return o}}getExpected(t){let n=this.annotations?.expected;if(typeof n=="string")return n;if(this.types.length===0)return"never";let r=this.types.map(o=>{let s=Nn(o);switch(s._tag){case"Arrays":{let i=s.elements.filter(lf);if(i.length>0)return`${MD(s.isMutable)}[ ${i.map(a=>t(a)+PD(a.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let i=s.propertySignatures.filter(a=>lf(a.type));if(i.length>0)return`{ ${i.map(a=>`${MD(a.type.context?.isMutable)}${sa(a.name)}${PD(a.type.context?.isOptional)}: ${t(a.type)}`).join(", ")}, ... }`;break}}return t(s)});return Array.from(new Set(r)).join(" | ")}};function _D(e,t,n,r){let o=Om(t);return o?Zo(new cf(e,[o],n,r)):Jt(t)}var fQ=em()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag==="Failure"){let r=Om(n.cause);if(r===void 0)return n;e.issues?e.issues.push(r):e.issues=[r]}else{if(e.out&&e.successes)return e.successes.push(t),Zo(new Cm(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return en}}}),BD=new br([new jr("Infinity"),new jr("-Infinity"),new jr("NaN")],"anyOf");function MD(e){return e?"":"readonly "}function PD(e){return e?"?":""}function Dc(e){let t=!1,n;return()=>(t||(n=e(),t=!0),n)}var $m=class e extends Yt{_tag="Suspend";thunk;constructor(t,n,r,o,s){if(r)throw new Error("Cannot add checks to Suspend");super(n,void 0,o,s),this.thunk=Dc(t)}getParser(t){let n;return(r,o)=>(n??=t(this.thunk()))(r,o)}recur(t){return new e(()=>t(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(t){return t(this.thunk())}},Hm=class e extends uu{_tag="Filter";run;annotations;aborted;constructor(t,n=void 0,r=!1){super(),this.run=t,this.annotations=n,this.aborted=r}annotate(t){return new e(this.run,{...this.annotations,...t},this.aborted)}abort(){return new e(this.run,this.annotations,!0)}and(t,n){return new Nc([this,t],n)}},Nc=class e extends uu{_tag="FilterGroup";checks;annotations;constructor(t,n=void 0){super(),this.checks=t,this.annotations=n}annotate(t){return new e(this.checks,{...this.annotations,...t})}and(t,n){return new e([this,t],n)}};function Vm(e,t,n=!1){return new Hm((r,o,s)=>gI(o,e(r,o,s),r,s),t,n)}function Jm(e,t){return new Hm((n,r,o)=>e(n)?void 0:new Oe(void 0,n,o),t,!0)}function IS(e){return Vm(t=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}var kS=Vs(wS,[IS()]),lQ=new jt(new br([kS,BD],"anyOf"),new nt(Yy(),Le(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function dd(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return Vm(o=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n}`,representation:{id:"effect/schema/isPattern",payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitrary:{constraint:{patterns:[e.source]}},...t})}function Gm(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}var $D=new WeakMap;function AS(e){return $D.get(e)??e}function ct(e,t){return e.encoding===t?e:Gm(e,n=>{n.encoding.value=t})}function pd(e,t){if(e.context===t)return e;let n=AS(e);if(n.context===t)return n;let r=Gm(e,o=>{o.context.value=t});return $D.set(r,n),r}function md(e){return e.encoding?md(e.encoding[e.encoding.length-1].to):e}function Mo(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Zm(e,lx(e.checks.slice(0,-1),n.annotate(t)))}return Gm(e,n=>{n.annotations.value={...n.annotations.value,...t}})}function Zm(e,t){if(e._tag==="Suspend"&&t)throw new Error("Cannot add checks to Suspend");return e.checks===t?e:Gm(e,n=>{n.checks.value=t})}function Vs(e,t){return Zm(e,tk(e.checks,t))}function Fa(e,t){let n=t(e.to);return n===e.to?e:new jt(n,e.transformation)}function ok(e,t){let n=e,r=n[n.length-1],o=Fa(r,t);return o===r?e:lx(e.slice(0,e.length-1),o)}function Qm(e){return t=>t.encoding?ct(t,ok(t.encoding,e)):t}function hf(e,t){return Qm(n=>pd(n,t))(e)}function dQ(e){function t(n){return n.encoding?ct(n,ok(n.encoding,t)):e(n)}return bn(t)}function Ni(e,t){function n(r){if(r.encoding){let o=r.encoding[r.encoding.length-1];return t?.stopAt?.(o)?r:ct(r,ok(r.encoding,n))}return e(r)}return du(n)}function sk(e,t){return ak(e,t,hn(e))}function ik(e,t){return ak(Nn(e),t,e)}function ak(e,t,n){let r=new jt(e,t);return ct(n,n.encoding?[...n.encoding,r]:[r])}function ck(e,t){let n=wN(e),r=n?[...n,t]:[t];return Mo(e,{brands:r})}function pf(e,t){let n=!1,r=new Array(e.length);for(let o=0;o<e.length;o++){let s=e[o],i=t(s);i!==s&&(n=!0),r[o]=i}return n?r:e}function gf(e,t){let n=e.context?new Br(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new Br(!1,!1,void 0,t);return pd(e,n)}var xf=du(e=>{let t=e.context?e.context.isOptional===!1?new Br(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new Br(!0,!1);return pQ(pd(e,t))}),pQ=Qm(xf),uk=bn(e=>xf(new br([e,ES],"anyOf"))),RS=du(e=>{let t=e.context?e.context.isMutable===!1?new Br(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new Br(!1,!0);return mQ(pd(e,t))}),mQ=Qm(RS);function fk(e,t){let n=new nt(Pm(t),Ws()),r=new jt(Fi,n),o=e.context?new Br(e.context.isOptional,e.context.isMutable,r,e.context.annotations):new Br(!1,!1,r);return pd(e,o)}function Ym(e,t,n){return ak(e,n,t)}function hQ(e){let t=[],n=[];function r(o){switch(o._tag){case"Literal":gp(o.literal)&&t.push(o.literal);return;case"UniqueSymbol":t.push(o.symbol);return;case"Never":return;case"Union":for(let s=0;s<o.types.length;s++)r(o.types[s]);return;default:n.push(o)}}return r(e),{literals:t,parameters:n}}function lk(e,t){let{literals:n,parameters:r}=hQ(e);return new df(n.map(o=>new cd(o,t)),r.map(o=>new ud(o,t)))}function nn(e){return e.context?.isOptional??!1}function dk(e){return e.context?.isMutable??!1}function HD(e){return e.annotations?.[ao]===!0||e._tag==="FilterGroup"&&e.checks.every(HD)}function gQ(e){function t(r){return HD(r)?[r]:r._tag==="FilterGroup"?r.checks.flatMap(t):[]}let n=e.flatMap(t);return or(n)?n:void 0}var hn=du(e=>{if(e.encoding)return hn(ct(e,void 0));let t=e,n=t.recur?.(hn)??t,r=n.encodingChecks;if(r){let o=n===e?r:SS(n)||ND(n)||Pa(n)&&n.typeParameters.length>0?gQ(r):void 0;return Gm(n,s=>{s.encodingChecks.value=void 0,s.checks.value=tk(n.checks,o)})}return n}),Nn=du(e=>hn(is(e)));function xQ(e,t){let n=t,r=n.length,o=n[r-1],s=[new jt(is(ct(e,void 0)),n[0].transformation.flip())];for(let a=1;a<r;a++)s.unshift(new jt(is(n[a-1].to),n[a].transformation.flip()));let i=is(o.to);return i.encoding?ct(i,[...i.encoding,...s]):ct(i,s)}var is=bn(e=>{if(e.encoding)return xQ(e,e.encoding);let t=e;return t.flip?.(is)??t.recur?.(is)??t});function pk(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(pk);default:return!1}}function CS(e,t){let n=ss(t);return(r,o)=>r===Ke?zs:r===t?n:Q(new tt(e,r,o))}function Js(e,t){return(n,r)=>n===Ke?zs:t(n)?ln:Q(new tt(e,n,r))}function FD(e,t,n){let r=e.encodedParts,o=e.literals,s=t.length;for(let u=0;u<o.length;u++){let f=o[u];if(f&&!t.includes(f))return}if(e.suffixLengths[0]>s)return;let i=new Array(r.length),a;function c(u,f){if(u===r.length)return f===s;if(a?.has(u*(s+1)+f))return!1;let l=r[u];if(u===r.length-1){let p=t.slice(f);if(l.matchPart(p,n)!==void 0)return i[u]=p,!0}else if(l._tag==="Literal"){let p=o[u];if(t.startsWith(p,f)&&c(u+1,f+p.length))return i[u]=p,!0}else{let p=s-e.suffixLengths[u+1],h=o[u+1],g=h===void 0?p:t.lastIndexOf(h,p);for(;g>=f;){let x=t.slice(f,g);if(l.matchPart(x,n)!==void 0&&c(u+1,g))return i[u]=x,!0;if(g===0)break;g=h===void 0?g-1:t.lastIndexOf(h,g-1)}}return a??=new Set,a.add(u*(s+1)+f),!1}return c(0,0)?i:void 0}var hd=bn(e=>new br(e.enums.map(t=>new jr(t[1],{title:t[0]})),"anyOf")),mk=Ni(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(mk)}}),Xm=Ni(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(Xm)}}),zD=Ni(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(zD)}}),hk="[\\s\\S]*?",HI=new globalThis.RegExp(`^${zm}$`),yQ=new globalThis.RegExp(`^(?:${zm}|Infinity|-Infinity|NaN)$`);function OS(e){return dd(HI,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:HI.source}),...e})}var WD=Vs(Ks,[OS()]),SQ=new jt(WD,ad),bQ=new jt(new br([WD,BD],"anyOf"),ad),EQ="-?\\d+",zI=new globalThis.RegExp(`^${EQ}$`);function _S(e){return dd(zI,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:zI.source}),...e})}var MS=Vs(Ks,[_S({expected:"a string representing a bigint"})]),wQ=new jt(MS,oS),vQ="Symbol\\((.*)\\)",WI=new globalThis.RegExp(`^${vQ}$`),KD=Vs(Ks,[PS()]),VD=new jt(KD,new nt(Le(e=>globalThis.Symbol.for(WI.exec(e)[1])),uo((e,t)=>globalThis.Symbol.keyFor(e)!==void 0?k(globalThis.String(e)):Q(new Pc({message:"cannot serialize to string, Symbol is not registered"},e,t)))));function PS(e){return dd(WI,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:WI.source}),...e})}function cs(e,t,n,r,o){for(let s=0;s<e.length;s++){let i=e[s];if(i._tag==="FilterGroup"){if(n=cs(i.checks,t,n,r,o),n&&(o.errors!=="all"||n[n.length-1].filter.aborted))return n}else{let a=i.run(t,r,o);if(a){let c=new Am(i,a,t,o);if(n?n.push(c):n=[c],o.errors!=="all"||i.aborted)return n}}}return n}function gk(e,t){let n=cs(e,t,void 0,Fi,{errors:"all"});if(n){let r=new At(Fi,n);return ge(r)}return le(t)}function xk(e){if(!Pa(e))return;let t=e.annotations?.[jy];return Ft(t)?t(e.typeParameters):void 0}var TQ=Hs,IQ=rf,kQ=sf,AQ=By,RQ=EN;function CQ(e){return e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&globalThis.Number.isFinite(e)}function OQ(e){return e===void 0||typeof e=="string"}function JD(e,t){let n=new WeakMap,r=[];e:for(;;){if(typeof e!="object"||e===null){if(!t(e))return!1}else{let o=e,s=n.get(o);if(s===!1)return!1;if(s===void 0){let i=Array.isArray(o);if(!i){let a=Object.getPrototypeOf(o);if(a!==null&&a!==Object.prototype&&Object.getPrototypeOf(a)!==null)return!1}n.set(o,!1),r.push({value:o,keys:i?o.length:Object.keys(o),index:0})}}for(;r.length>0;){let o=r[r.length-1],s=o.keys;if(typeof s=="number"){if(o.index<s){e=o.value[o.index++];continue e}}else if(o.index<s.length){e=o.value[s[o.index++]];continue e}n.set(o.value,!0),r.pop()}return!0}}function yf(e){return JD(e,CQ)}var mf=new Pi([],()=>(e,t,n)=>yf(e)?ln:Q(new tt(t,e,n)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{},toCodecStringTree:()=>US,toArbitrary:()=>e=>e.jsonValue()}),yk=Mo(mf,{representation:{id:"effect/schema/MutableJson",payload:null}}),FS=new jt(mf,id()),Sk=new jt(new br([new as(!1,[],[mf]),new df([],[new ud(Ks,mf)])],"anyOf"),id());function GD(e){return JD(e,OQ)}var _Q=new Pi([],()=>(e,t,n)=>GD(e)?ln:Q(new tt(t,e,n)),{expected:"StringTree",toCodecStringTree:()=>{}}),US=new jt(_Q,id());var ZD="~effect/collections/MutableHashMap";var MQ={[ZD]:ZD,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${re(Array.from(this))})`},toJSON(){return{_id:"MutableHashMap",values:wn(Array.from(this))}},[ft](){return this.toJSON()},pipe(){return ce(this,arguments)}},Lc=()=>{let e=Object.create(MQ);return e.backing=new Map,e.buckets=new Map,e};var Gs=d(2,(e,t)=>{if(e.backing.has(t))return L(e.backing.get(t));if(bk(t))return D();let n=eh.get(e);if(n!==void 0)return e.backing.has(n)?L(e.backing.get(n)):D();let r=ue(t),o=e.buckets.get(r);return o===void 0?D():PQ(e,o,t)}),eh=new WeakMap,bk=e=>typeof e!="object"&&typeof e!="function";var PQ=(e,t,n)=>{for(let r=0,o=t.length;r<o;r++)if(ne(n,t[r])){let s=t[r];return eh.set(n,s),L(e.backing.get(s))}return D()},QD=d(2,(e,t)=>_e(Gs(e,t))),qc=d(3,(e,t,n)=>{if(e.backing.has(t)||bk(t))return e.backing.set(t,n),e;let r=eh.get(e);if(r!==void 0&&e.backing.has(r))return e.backing.set(r,n),e;let o=ue(t),s=e.buckets.get(o);return s===void 0?(e.buckets.set(o,[t]),e.backing.set(t,n),e):(r=FQ(s,t),r===void 0&&(s.push(t),r=t),e.backing.set(r,n),e)}),FQ=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(ne(t,e[n]))return eh.set(t,e[n]),e[n]};var Sf=d(2,(e,t)=>{if(bk(t))return e.backing.delete(t),e;let n=eh.get(e)??t,r=ue(n),o=e.buckets.get(r);if(o===void 0)return e;for(let s=0,i=o.length;s<i;s++){let a=o[s];if(a===n||ne(n,a)){e.backing.delete(a),o.splice(s,1);break}}return o.length===0&&e.buckets.delete(r),e}),NS=e=>(e.backing.clear(),e.buckets.clear(),e),YD=e=>e.backing.size;var XD="~effect/collections/Chunk";function LQ(e,t,n,r,o){for(let s=t;s<Math.min(e.length,t+o);s++)n[r+s-t]=e[s];return n}var e2=[],wk=e=>pn((t,n)=>t.length===n.length&&th(t).every((r,o)=>e(r,nh(n,o)))),qQ=wk(ne),jQ={[XD]:{_A:e=>e},toString(){return`Chunk(${re(th(this))})`},toJSON(){return{_id:"Chunk",values:wn(th(this))}},[ft](){return this.toJSON()},[ke](e){return gd(e)&&qQ(this,e)},[Ie](){return ra(th(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return e2[Symbol.iterator]();default:return th(this)[Symbol.iterator]()}},pipe(){return ce(this,arguments)}},vk=e=>{let t=Object.create(jQ);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=Ua,t.right=Ua;break}case"ISingleton":{t.length=1,t.depth=0,t.left=Ua,t.right=Ua;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=Ua,t.right=Ua;break}}return t},gd=e=>N(e,XD),Ua=vk({_tag:"IEmpty"}),BQ=()=>Ua;var $Q=e=>vk({_tag:"ISingleton",a:e}),LS=e=>gd(e)?e:zQ(St(e)),Ek=(e,t,n)=>{switch(e.backing._tag){case"IArray":{LQ(e.backing.array,0,t,n,e.length);break}case"IConcat":{Ek(e.left,t,n),Ek(e.right,t,n+e.left.length);break}case"ISingleton":{t[n]=e.backing.a;break}case"ISlice":{let r=0,o=n;for(;r<e.length;)t[o]=nh(e,r),r+=1,o+=1;break}}};var HQ=e=>{switch(e.backing._tag){case"IEmpty":return e2;case"IArray":return e.backing.array;default:{let t=new Array(e.length);return Ek(e,t,0),e.backing={_tag:"IArray",array:t},e.left=Ua,e.right=Ua,e.depth=0,t}}},th=HQ;var zQ=e=>e.length===0?BQ():e.length===1?$Q(e[0]):vk({_tag:"IArray",array:e});var nh=d(2,(e,t)=>{let n=Math.floor(t);switch(e.backing._tag){case"IEmpty":throw new Error(`Index out of bounds: ${n}`);case"ISingleton":{if(t!==0)throw new Error(`Index out of bounds: ${n}`);return e.backing.a}case"IArray":{if(n>=e.length||n<0)throw new Error(`Index out of bounds: ${n}`);return e.backing.array[n]}case"IConcat":return n<e.left.length?nh(e.left,n):nh(e.right,n-e.left.length);case"ISlice":return nh(e.backing.chunk,n+e.backing.offset)}});var t2=e=>e.length;var n2=gv;var xd=_P,qS=MP,Fo=jx;var Di=Sa,Na=xU;var Er=sy,r2=TU;var o2="~effect/MutableRef",WQ={[o2]:o2,...On,toJSON(){return{_id:"MutableRef",current:wn(this.current)}}},oh=e=>{let t=Object.create(WQ);return t.current=e,t};var s2=e=>e.current;var Ik=d(2,(e,t)=>(e.current=t,e));var Hr=Symbol.for("effect/MutableList/Empty"),qa=()=>({head:void 0,tail:void 0,length:0}),i2=()=>({array:[],mutable:!0,offset:0,next:void 0}),fo=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=i2(),e.tail=e.tail.next):e.head=e.tail=i2(),e.tail.array.push(t),e.length++},Ak=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||(e.tail=e.head),e.length++};var jS=(e,t)=>BS(e,St(t),!Array.isArray(t)),BS=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};return e.head?e.tail=e.tail.next=r:e.head=e.tail=r,e.length+=t.length,t.length},La=e=>{e.head=e.tail=void 0,e.length=0},bf=(e,t)=>{if(t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let s=e.head.array;return La(e),s}let n=new Array(t),r=0,o=e.head;for(;o;){for(;o.offset<o.array.length;)if(n[r++]=o.array[o.offset],o.mutable&&(o.array[o.offset]=void 0),o.offset++,r===t)return e.head=o,e.length-=t,e.length===0&&La(e),n;o=o.next}return La(e),n},sh=(e,t)=>{if(t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){La(e);return}let n=0,r=e.head;for(;r;){let o=r.array.length-r.offset;if(n+o>t){r.offset+=t-n,e.head=r,e.length-=t;return}n+=o,r=r.next}La(e)},Ef=e=>bf(e,e.length),Zs=e=>{if(!e.head)return Hr;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length&&(e.head.next?e.head=e.head.next:La(e)),t},a2=(e,t)=>{if(t<=0)return[];let n=Math.min(t,e.length),r=new Array(n),o=0,s=e.head;for(;s;){for(let i=s.offset;i<s.array.length;i++)if(r[o++]=s.array[i],o===n)return r;s=s.next}return r};var Rk=(e,t)=>{let n=[],r=e.head;for(;r;){for(let o=r.offset;o<r.array.length;o++)t(r.array[o],o)&&n.push(r.array[o]);r=r.next}if(n.length===0){La(e);return}e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length},c2=(e,t)=>Rk(e,n=>n!==t);var KQ="~effect/PubSub",VQ="~effect/PubSub/Subscription",WS=e=>ae(()=>XQ(e.atomicPubSub(),new Map,no(),Er(!1),oh(!1),e.strategy())),KS=e=>WS({atomicPubSub:()=>Bk(e),strategy:()=>new qk}),VS=e=>WS({atomicPubSub:()=>Bk(e),strategy:()=>new HS}),JS=e=>WS({atomicPubSub:()=>Bk(e),strategy:()=>new jk}),ih=e=>WS({atomicPubSub:()=>JQ(e),strategy:()=>new HS}),Bk=e=>{let t=typeof e=="number"?{capacity:e}:e;e7(t.capacity);let n=t.replay&&t.replay>0?new zS(Math.ceil(t.replay)):void 0;return t.capacity===1?new Pk(n):L1(t.capacity)===t.capacity?new _k(t.capacity,n):new Ck(t.capacity,n)},JQ=e=>{let t=e?.replay;return new Uk(t&&t>0?new zS(Math.ceil(t)):void 0)};var ah=e=>Ci(kn(t=>(Ik(e.shutdownFlag,!0),Ze(e.scope,dy(t.id)).pipe(Wn(e.strategy.shutdown),Uy(e.shutdownHook.open),ns))));var Sd=d(2,(e,t)=>V(()=>e.shutdownFlag.current?k(!1):e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),k(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag))),u2=d(2,(e,t)=>e.shutdownFlag.current?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),f2=d(2,(e,t)=>V(()=>{if(e.shutdownFlag.current)return k(!1);let n=e.pubsub.publishAll(t);return e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),n.length===0?k(!0):e.strategy.handleSurplus(e.pubsub,e.subscribers,n,e.shutdownFlag)})),ch=e=>Ci(yr(t=>{let n=ze(t,mt),r=Fn(e.scope),o=YQ(e.pubsub,e.subscribers,e.strategy);return Dt(r,GQ(o)).pipe(Wn(Yo(n,s=>Ze(r,s))),Zt(o))})),GQ=e=>Ci(kn(t=>(Ik(e.shutdownFlag,!0),es(Ef(e.pollers),n=>dT(n,t.id),{discard:!0,concurrency:"unbounded"}).pipe(qt(()=>ae(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),Uy(e.shutdownHook.open),ns)))),GS=e=>V(()=>{if(e.shutdownFlag.current)return Co;if(e.replayWindow.remaining>0){let n=e.replayWindow.take();return k(n)}let t=e.pollers.length===0?e.subscription.poll():Hr;return t===Hr?d2(e):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),k(t))}),l2=e=>V(function t(n){if(e.shutdownFlag.current)return Co;let r=e.pollers.length===0?e.subscription.pollUpTo(Number.POSITIVE_INFINITY):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?k(e.replayWindow.takeAll().concat(r)):or(r)?k(r):_(d2(e),o=>t([o]))}),d2=e=>{let t=zu(),n=e.subscribers.get(e.subscription);return n||(n=new Set,e.subscribers.set(e.subscription,n)),n.add(e.pollers),fo(e.pollers,t),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),Ri(Wu(t),()=>(c2(e.pollers,t),W))};var rn=Symbol.for("effect/PubSub/AbsentValue"),ZQ=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)},QQ=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.delete(n),r.size===0&&e.delete(t)},YQ=(e,t,n)=>new Dk(e,t,e.subscribe(),qa(),Er(!1),oh(!1),n,e.replayWindow()),Ck=class{array;replayIndices;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,n){this.capacity=t,this.replayBuffer=n,this.array=Array.from({length:t}),this.replayIndices=n?Array.from({length:t}):[],this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new yd(this.replayBuffer):ZS}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let n=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let r=this.publisherIndex%this.capacity;this.array[r]=t,n!==void 0&&(this.replayIndices[r]=n),this.subscribers[r]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let n=St(t),r=n.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(r,s);if(i===0)return n;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=n[a++],f=this.publisherIndex%this.capacity;this.array[f]=u;let l=this.replayBuffer?.offer(u);l!==void 0&&(this.replayIndices[f]=l),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return n.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex%this.capacity,n=this.array[t];this.array[t]=rn,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(n,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new Ok(this,this.publisherIndex,!1)}},Ok=class{self;subscriberIndex;unsubscribed;constructor(t,n,r){this.self=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Hr;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex%this.self.capacity,n=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=rn,this.self.subscribersIndex+=1),this.subscriberIndex+=1,n}return Hr}pollUpTo(t){if(this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let n=this.self.publisherIndex-this.subscriberIndex,r=Math.min(t,n);if(r<=0)return[];let o=[],s=this.subscriberIndex+r;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex%this.self.capacity,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=rn,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex%this.self.capacity;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=rn,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},_k=class{array;replayIndices;mask;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,n){this.capacity=t,this.replayBuffer=n,this.array=Array.from({length:t}),this.replayIndices=n?Array.from({length:t}):[],this.mask=t-1,this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new yd(this.replayBuffer):ZS}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let n=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let r=this.publisherIndex&this.mask;this.array[r]=t,n!==void 0&&(this.replayIndices[r]=n),this.subscribers[r]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let n=St(t),r=n.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(r,s);if(i===0)return n;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=n[a++],f=this.publisherIndex&this.mask;this.array[f]=u;let l=this.replayBuffer?.offer(u);l!==void 0&&(this.replayIndices[f]=l),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return n.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex&this.mask,n=this.array[t];this.array[t]=rn,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(n,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new Mk(this,this.publisherIndex,!1)}},Mk=class{self;subscriberIndex;unsubscribed;constructor(t,n,r){this.self=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Hr;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex&this.self.mask,n=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=rn,this.self.subscribersIndex+=1),this.subscriberIndex+=1,n}return Hr}pollUpTo(t){if(this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let n=this.self.publisherIndex-this.subscriberIndex,r=Math.min(t,n);if(r<=0)return[];let o=[],s=this.subscriberIndex+r;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex&this.self.mask,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=rn,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex&this.self.mask;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=rn,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},Pk=class{publisherIndex=0;subscriberCount=0;subscribers=0;value=rn;replayIndex=0;capacity=1;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new yd(this.replayBuffer):ZS}pipe(){return ce(this,arguments)}isEmpty(){return this.subscribers===0}isFull(){return!this.isEmpty()}size(){return this.isEmpty()?0:1}publish(t){if(this.isFull())return!1;let n=this.replayBuffer?.offer(t);return this.subscriberCount!==0&&(this.value=t,n!==void 0&&(this.replayIndex=n),this.subscribers=this.subscriberCount,this.publisherIndex+=1),!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let n=St(t);return n.length===0?n:this.publish(n[0])?n.slice(1):n}slide(){if(this.isFull()){let t=this.value;this.subscribers=0,this.value=rn,this.replayBuffer?.slide(t,this.replayIndex)}}subscribe(){return this.subscriberCount+=1,new Fk(this,this.publisherIndex,!1)}},Fk=class{self;subscriberIndex;unsubscribed;constructor(t,n,r){this.self=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){return this.unsubscribed||this.self.subscribers===0||this.subscriberIndex===this.self.publisherIndex}size(){return this.isEmpty()?0:1}poll(){if(this.isEmpty())return Hr;let t=this.self.value;return this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=rn),this.subscriberIndex+=1,t}pollUpTo(t){if(this.isEmpty()||t<1)return[];let n=this.self.value;return this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=rn),this.subscriberIndex+=1,[n]}unsubscribe(){this.unsubscribed||(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex!==this.self.publisherIndex&&(this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=rn)))}},Uk=class{publisherHead={value:rn,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=Number.MAX_SAFE_INTEGER;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new yd(this.replayBuffer):ZS}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(t){let n=this.replayBuffer?.offer(t),r=this.publisherTail.subscribers;if(r!==0){let o={value:t,replayIndex:n,subscribers:r,next:null};this.publisherTail.next=o,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(t){if(this.publisherTail.subscribers!==0)for(let n of t)this.publish(n);else this.replayBuffer&&this.replayBuffer.offerAll(t);return[]}slide(){if(this.publisherHead!==this.publisherTail){let t=this.publisherHead.next,n=t.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=rn,this.subscribersIndex+=1,this.replayBuffer?.slide(n,t.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new Nk(this,this.publisherTail,this.publisherIndex,!1)}},Nk=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(t,n,r,o){this.self=t,this.subscriberHead=n,this.subscriberIndex=r,this.unsubscribed=o}isEmpty(){if(this.unsubscribed)return!0;let t=!0,n=!0;for(;n;)this.subscriberHead===this.self.publisherTail?n=!1:this.subscriberHead.next.value!==rn?(t=!1,n=!1):(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1);return t}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Hr;let t=!0,n=Hr;for(;t;)if(this.subscriberHead===this.self.publisherTail)t=!1;else{let r=this.subscriberHead.next.value;r!==rn&&(n=r,this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=rn,this.self.subscribersIndex+=1),t=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return n}pollUpTo(t){let n=[],r=0;for(;r!==t;){let o=this.poll();o===Hr?r=t:(n.push(o),r+=1)}return n}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.publisherTail.subscribers-=1;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==rn&&(this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=rn,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},Dk=class{[VQ]={_A:j};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;constructor(t,n,r,o,s,i,a,c){this.pubsub=t,this.subscribers=n,this.subscription=r,this.pollers=o,this.shutdownHook=s,this.shutdownFlag=i,this.strategy=a,this.replayWindow=c}pipe(){return ce(this,arguments)}},Lk=class{[KQ]={_A:j};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;constructor(t,n,r,o,s,i){this.pubsub=t,this.subscribers=n,this.scope=r,this.shutdownHook=o,this.shutdownFlag=s,this.strategy=i}pipe(){return ce(this,arguments)}},XQ=(e,t,n,r,o,s)=>new Lk(e,t,n,r,o,s),e7=e=>{if(e<=0)throw new Error(`Cannot construct PubSub with capacity of ${e}`)},qk=class{publishers=qa();get shutdown(){return kn(t=>es(Ef(this.publishers),([n,r,o])=>o?dT(r,t.id):W,{concurrency:"unbounded",discard:!0}))}handleSurplus(t,n,r,o){return V(()=>{let s=zu();return this.offerUnsafe(r,s),this.onPubSubEmptySpaceUnsafe(t,n),this.completeSubscribersUnsafe(t,n),(s2(o)?Co:Wu(s)).pipe(Ri(()=>(this.removeUnsafe(s),W)))})}onPubSubEmptySpaceUnsafe(t,n){let r=!0;for(;r&&!t.isFull();){let o=Zs(this.publishers);if(o===Hr)r=!1;else{let[s,i]=o,a=t.publish(s);a&&o[2]?zl(i,Pn(!0)):a||Ak(this.publishers,o),this.completeSubscribersUnsafe(t,n)}}}completePollersUnsafe(t,n,r,o){return $k(this,t,n,r,o)}completeSubscribersUnsafe(t,n){return Hk(this,t,n)}offerUnsafe(t,n){let r=t[Symbol.iterator](),o=r.next();if(!o.done)for(;;){let s=o.value;if(o=r.next(),o.done){fo(this.publishers,[s,n,!0]);break}fo(this.publishers,[s,n,!1])}}removeUnsafe(t){Rk(this.publishers,([n,r])=>r!==t)}},HS=class{get shutdown(){return W}handleSurplus(t,n,r,o){return k(!1)}onPubSubEmptySpaceUnsafe(t,n){}completePollersUnsafe(t,n,r,o){return $k(this,t,n,r,o)}completeSubscribersUnsafe(t,n){return Hk(this,t,n)}},jk=class{get shutdown(){return W}handleSurplus(t,n,r,o){return ae(()=>(this.slidingPublishUnsafe(t,r),this.completeSubscribersUnsafe(t,n),!0))}onPubSubEmptySpaceUnsafe(t,n){}completePollersUnsafe(t,n,r,o){return $k(this,t,n,r,o)}completeSubscribersUnsafe(t,n){return Hk(this,t,n)}slidingPublishUnsafe(t,n){let r=n[Symbol.iterator](),o=r.next();if(!o.done&&t.capacity>0){let s=o.value,i=!0;for(;i;){t.slide();let a=t.publish(s);a&&(o=r.next())&&!o.done?s=o.value:a&&(i=!1)}}}},$k=(e,t,n,r,o)=>{let s=!0;for(;s&&!r.isEmpty();){let i=Zs(o);if(i===Hr)QQ(n,r,o),o.length===0?s=!1:ZQ(n,r,o);else{let a=r.poll();a===Hr?Ak(o,i):(zl(i,Pn(a)),e.onPubSubEmptySpaceUnsafe(t,n))}}},Hk=(e,t,n)=>{for(let[r,o]of n)for(let s of o)e.completePollersUnsafe(t,n,r,s)},zS=class{capacity;head={value:rn,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(t){this.capacity=t}slide(t,n){this.slideValues[this.index%this.capacity]={value:t,index:n},this.index++}offer(t){let n=this.publisherIndex++;return this.tail.value=t,this.tail.index=n,this.tail.next={value:rn,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity?this.head=this.head.next:this.size+=1,n}offerAll(t){for(let n of t)this.offer(n)}},yd=class{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(t){this.buffer=t,this.remaining=t.size,this.slideIndex=t.index,this.values=new Array(this.remaining);let n=t.head;for(let r=0;r<this.remaining;r++)this.values[r]=n.value,this.newestIndex=n.index,n=n.next}close(){this.values.length=0,this.remaining=0}sync(){let t=this.buffer.index-this.slideIndex;if(t===0||this.remaining===0)return;let n=Math.min(t,this.buffer.capacity),r=this.buffer.index-n;for(let o=0;o<n;o++){let s=this.buffer.slideValues[(r+o)%this.buffer.capacity];s.index>this.newestIndex&&(this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=s.value,this.newestIndex=s.index)}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let t=this.values[this.index];return this.values[this.index]=rn,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),t}takeN(t){let n=Math.min(t,this.remaining),r=new Array(n);for(let o=0;o<n;o++)r[o]=this.take();return r}takeAll(){return this.takeN(this.remaining)}},ZS={remaining:0,take:()=>{},takeN:()=>[],takeAll:()=>[],close:()=>{}};var t7="~effect/Queue",n7="~effect/Queue/Enqueue",r7="~effect/Queue/Dequeue";var zk={_A:j,_E:j},o7={[t7]:zk,[n7]:zk,[r7]:zk,...On,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:i7(this)}}},lo=e=>me(t=>{let n=Object.create(o7);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??Number.POSITIVE_INFINITY,n.strategy=e?.strategy??"suspend",n.messages=qa(),n.scheduleRunning=!1,n.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},G(n)}),wf=e=>lo({capacity:e});var uh=()=>lo(),fr=(e,t)=>xe(()=>{if(e.state._tag!=="Open")return XS;if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return XS;case"suspend":return e.capacity<=0&&e.state.takers.size>0?(fo(e.messages,t),Wk(e),YS):f7(e,t);case"sliding":return Zs(e.messages),fo(e.messages,t),YS}return fo(e.messages,t),eb(e),YS}),Ed=(e,t)=>e.state._tag!=="Open"?!1:e.messages.length>=e.capacity?e.strategy==="sliding"?(Zs(e.messages),fo(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0?(fo(e.messages,t),Wk(e),!0):!1:(fo(e.messages,t),eb(e),!0),ja=(e,t)=>xe(()=>{if(e.state._tag!=="Open")return G(St(t));let n=tb(e,t);return n.length===0?it([]):e.strategy==="dropping"?G(n):l7(e,n)}),tb=(e,t)=>{if(e.state._tag!=="Open")return St(t);if(e.capacity===Number.POSITIVE_INFINITY||e.strategy==="sliding")return jS(e.messages,t),e.strategy==="sliding"&&bf(e.messages,e.messages.length-e.capacity),eb(e),[];let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return St(t);let r=[],o=0;for(let s of t)o<n?fo(e.messages,s):r.push(s),o++;return eb(e),r};var on=d(2,(e,t)=>ye(()=>Li(e,t))),Li=(e,t)=>{if(e.state._tag!=="Open")return!1;let n=Bn(t),r=iF(n,a7);return e.state.offers.size===0&&e.messages.length===0?(Kk(e,r),!0):(e.state={...e.state,_tag:"Closing",exit:r},!0)},fh=e=>on(e,yl(vu())),p2=e=>Li(e,yl(vu()));var Qs=e=>ye(()=>{if(e.state._tag==="Done")return!0;La(e.messages);let t=e.state.offers;if(Kk(e,e.state._tag==="Open"?c7:e.state.exit),t.size>0){for(let n of t)n._tag==="Single"?n.resume(XS):n.resume(it(n.remaining.slice(n.offset)));t.clear()}return!0});var wd=e=>m2(e,1,Number.POSITIVE_INFINITY);var m2=(e,t,n)=>xe(()=>u7(e,t,n)??Xr(h2(e),m2(e,1,n))),us=e=>xe(()=>s7(e)??Xr(h2(e),us(e)));var s7=e=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=Zs(e.messages);return bd(e),it(t)}else if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,bd(e),e.capacity=0;let t=Zs(e.messages);return bd(e),it(t)}};var i7=e=>e.state._tag==="Done"?0:e.messages.length;var XS=it(!1),YS=it(!0),a7=bo(vu()),c7=Hx(),Wk=e=>{if(e.scheduleRunning=!1,!(e.state._tag==="Done"||e.state.takers.size===0)){for(let t of e.state.takers)if(e.state.takers.delete(t),t(Ur),e.messages.length===0)break}},eb=e=>{e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>Wk(e),0))},u7=(e,t,n)=>{if(e.state._tag==="Done")return e.state.exit;if(n<=0||t<=0)return it([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,bd(e),e.capacity=0;let r=[Zs(e.messages)];return bd(e),it(r)}if(t=Math.min(t,e.capacity||1),t<=e.messages.length){let r=bf(e.messages,n);return bd(e),it(r)}},f7=(e,t)=>Vt(n=>{if(e.state._tag!=="Open")return n(XS);let r={_tag:"Single",message:t,resume:n};return e.state.offers.add(r),ye(()=>{e.state._tag==="Open"&&e.state.offers.delete(r)})}),l7=(e,t)=>Vt(n=>{if(e.state._tag!=="Open")return n(it(t));let r={_tag:"Array",remaining:t,offset:0,resume:n};return e.state.offers.add(r),ye(()=>{e.state._tag==="Open"&&e.state.offers.delete(r)})}),bd=e=>{if(e.state._tag==="Done")return Xo(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag==="Closing"&&e.messages.length===0?(Kk(e,e.state.exit),Xo(e.state.exit.cause)):!1;let t=e.capacity-e.messages.length;for(let n of e.state.offers){if(t===0)break;if(n._tag==="Single")fo(e.messages,n.message),t--,n.resume(YS),e.state.offers.delete(n);else{for(;n.offset<n.remaining.length;n.offset++){if(t===0)return!1;fo(e.messages,n.remaining[n.offset]),t--}n.resume(it([])),e.state.offers.delete(n)}}return!1},h2=e=>Vt(t=>e.state._tag==="Done"?t(e.state.exit):(e.state.takers.add(t),ye(()=>{e.state._tag!=="Done"&&e.state.takers.delete(t)})));var Kk=(e,t)=>{if(e.state._tag==="Done")return;let n=e.state;e.state={_tag:"Done",exit:t};for(let r of n.takers)r(t);n.takers.clear();for(let r of n.awaiters)r(t);n.awaiters.clear()};var Ba=e=>new Vk(e),g2=(e,t,n)=>Vt(r=>{if(e.free>=t)return r(n);let o=()=>{e.free<t||(e.waiters.delete(o),r(n))};return e.waiters.add(o),ye(()=>{e.waiters.delete(o)})}),Vk=class{waiters=new Set;taken=0;permits;constructor(t){this.permits=t}get free(){return this.permits-this.taken}take(t){let n=xe(()=>this.free<t?g2(this,t,n):(this.taken+=t,G(t)));return n}takeIfAvailable(t){return xe(()=>this.free<t?G(!1):(this.taken+=t,G(!0)))}releaseUnsafe(t,n){return this.taken-=n,this.waiters.size>0&&t.currentDispatcher.scheduleTask(()=>{for(let r of this.waiters){if(this.free<=0)break;r()}},0),this.free}resize(t){return me(n=>(this.permits=t,this.free<0?Ae:(this.releaseUnsafe(n,0),Ae)))}release(t){return me(n=>G(this.releaseUnsafe(n,t)))}get releaseAll(){return me(t=>G(this.releaseUnsafe(t,this.taken)))}withPermits(t){return n=>eo(r=>{let o=xe(()=>{if(this.free<t){let s=g2(this,t,Ae);return oe(r(s),()=>o)}return this.taken+=t,Ps(r(n),()=>{this.releaseUnsafe(Sa(),t)},!0)});return o})}withPermit=this.withPermits(1);withPermitsIfAvailable(t){return n=>eo(r=>this.free<t?Pu:(this.taken+=t,Ps(r(Ul(n)),()=>{this.releaseUnsafe(Sa(),t)},!0)))}};var Jk=e=>Us(e)?Nt(e)?he(e.value):e:k(e);var b2="~effect/Channel",lr=e=>N(e,b2),d7={[b2]:{_Env:j,_InErr:j,_InElem:j,_OutErr:j,_OutElem:j},pipe(){return ce(this,arguments)}},Qe=e=>{let t=Object.create(d7);return t.transform=(n,r)=>ht(e(n,r),o=>k(lt(o))),t},Xs=(e,t)=>Qe((n,r)=>_(Ue(e)(n,r),o=>t(o,r))),Qn=e=>Qe((t,n)=>e),ei=e=>Qe(Ee(function*(t,n){let r=Fn(n),o=i=>Ze(r,PT(i)),s=yield*Ro(e(t,n,r),o);return Ro(s,o)})),Ue=e=>e.transform,lh=4096,p7=(e,t,n)=>lo({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(qt(r=>Dt(e,Qs(r))),qt(r=>zt(Qo(t(r),e),e)));var E2=(e,t)=>Qe((n,r)=>te(p7(r,e,t),wd)),rb=e=>Qe((t,n)=>V(()=>Ue(e())(t,n))),m7=(e,t,n)=>ei(Ee(function*(r,o,s){let i=D();yield*Yo(s,c=>_e(i)?n(i.value,c):W);let a=yield*Ci(e);return i=L(a),yield*Ue(t(a))(r,o)}));var Gk=e=>Qn(ae(()=>{let t=0;return V(()=>t>=e.length?he():k(e[t++]))}));var Zk=(e,t=lh)=>Qn(ae(()=>{let n=e(),r=D();return V(()=>{if(r._tag==="Some")return he(r.value);let o=[];for(;o.length<t;){let s=n.next();if(s.done){if(o.length===0)return he(s.value);r=L(s.value);break}o.push(s.value)}return k(o)})}));var w2=(e,t=lh)=>Zk(()=>e[Symbol.iterator](),t),ob=e=>sb(k(e)),h7=e=>Qn(k(he(e)));var v2=e=>sb(ae(e)),vd=Qn(k(he())),T2=Qn(k(oo)),qi=e=>Qn(k(Q(e))),I2=e=>Qn(My(e)),dh=e=>Qn(lt(e)),k2=e=>Qn(Aa(e)),Qk=e=>dh(oT(e)),sb=e=>Qn(ae(()=>{let t=!1;return V(()=>t?he():(t=!0,e))}));var A2=e=>Qn(_(e,()=>he())),Yk=e=>Qn(k(_(e,Jk)));var R2=e=>Qn(k(wd(e)));var Xk=e=>Qn(k(Ri(l2(e),()=>he())));var C2=e=>$a(te(ch(e),Xk)),O2=e=>$a(te(ch(e),t=>Yk(GS(t))));var _2=e=>Qe((t,n)=>g7({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd}));var g7=e=>{let t=e.readable.getReader(),n=e.exit??oh(void 0),r=V(()=>n.current?n.current:io(qs({try:()=>t.read(),catch:e.onError}),{onFailure:o=>n.current??lt(o),onSuccess:({done:o,value:s})=>n.current?n.current:o?he():k(je(s))}));return Zt(Dt(e.scope,e.releaseLockOnEnd?ae(()=>t.releaseLock()):Oy(()=>t.cancel().catch(Cn))),r)},x7=(e,t)=>Qe(Ee(function*(n,r){let o=e[Symbol.asyncIterator]();return o.return&&(yield*Dt(r,Oy(()=>o.return()))),_(qs({try:()=>o.next(),catch:t}),s=>s.done?he(s.value):k(s.value))})),M2=(e,t)=>ti(x7(e,t),je),ti=d(2,(e,t)=>Xs(e,n=>ae(()=>{let r=0;return te(n,o=>t(o,r++))})));var P2=e=>e===void 0||e!=="unbounded"&&e<=1,ib=d(e=>lr(e[0]),(e,t,n)=>P2(n?.concurrency)?F2(e,t):y7(e,t,n)),F2=(e,t)=>Qe((n,r)=>{let o=0;return te(Ue(e)(n,r),_(s=>t(s,o++)))}),y7=(e,t,n)=>ei(Ee(function*(r,o,s){let i=0,a=yield*Ue(e)(r,o),c=n.concurrency==="unbounded"?Number.MAX_SAFE_INTEGER:n.concurrency,u=yield*wf(0);yield*Dt(s,Qs(u));let f=Jn(yield*Kn()),l=Na(s);if(n.unordered){let p=Ba(c),h=Xe(p.release(1)),g=io({onFailure:x=>_(on(u,x),h),onSuccess:x=>_(fr(u,x),h)});yield*p.take(1).pipe(_(()=>a),_(x=>(l(f(g(t(x,i++)))),W)),Qt({disableYield:!0}),ht(x=>p.withPermits(c-1)(on(u,x))),zt(s))}else{let p=yield*wf(c-2);yield*Dt(s,Qs(p)),yield*us(p).pipe(HT,_(x=>fr(u,x)),Qt({disableYield:!0}),ht(x=>on(u,x)),zt(s));let h,g=x=>{x._tag!=="Success"&&(h=x.cause,Li(u,x.cause))};yield*a.pipe(_(x=>{if(h)return lt(h);let S=f(t(x,i++));return l(S),S.addObserver(g),fr(p,xd(S))}),Qt({disableYield:!0}),ht(x=>fr(p,Jt(x)).pipe(Wn(on(p,x)))),zt(s))}return us(u)}));var U2=d(e=>lr(e[0]),(e,t,n)=>P2(n?.concurrency)?S7(e,t):b7(e,t,n)),S7=(e,t)=>Qe((n,r)=>te(Ue(e)(n,r),o=>{let s,i,a=_(o,u=>(i??=Fn(r),Gn(Ue(t(u))(n,i),f=>(s=c(f),s)))),c=Gt(u=>{if(s=void 0,i.state._tag==="Open"&&jF(i)===1)return a;let f=Ze(i,en);return i=void 0,_(f,()=>a)});return V(()=>s??a)})),b7=(e,t,n)=>e.pipe(ti(t),ub(n)),ab=d(2,(e,t)=>Qe((n,r)=>ae(()=>{let o,s=Fn(r),i=_(Ue(e)(n,s),a=>(o=Gt(a,c=>Ze(s,en).pipe(_(()=>Ue(t(c))(n,r)),_(u=>(o=u,u)))),o));return V(()=>o??i)})));var eA=d(4,(e,t,n,r)=>Qe(Ee(function*(o,s){let i=yield*Ue(e)(o,s),a=yield*Ue(t)(o,s),c=n();return V(()=>{let u=r(c,i,a);return te(u,([f,l])=>(c=l,f))})}))),N2=d(2,(e,t)=>Qe((n,r)=>ae(()=>{let o,s=Fn(r),i=_(Ue(e)(n,s),a=>{let c=a.pipe(qt(()=>(o=a,W)),Gt(u=>Ze(s,Pn(u)).pipe(Wn(Ue(t(u))(n,r)),_(f=>(o=f,f)))));return o=c,c});return V(()=>o??i)})));var wr=e=>Xs(e,t=>{let n,r=0,o=V(function s(){if(n===void 0)return _(t,a=>{switch(a.length){case 0:return s();case 1:return k(a[0]);default:return n=a,k(a[r++])}});let i=n[r++];return r>=n.length&&(n=void 0,r=0),k(i)});return k(o)}),D2=e=>F2(e,Jk),L2=e=>Xs(e,t=>k(Qt(t,{disableYield:!0}))),q2=d(2,(e,t)=>Ls(typeof t=="function"?t(j):t).pipe(te(n=>{let r=zn.defaultValue(),o=ab(pb(e,zn,ae(()=>r)),s=>n(s).pipe(te(i=>(r=i,o)),Gt(()=>k(h7(s))),$a));return o}),$a)),tA=e=>ab(e,()=>tA(e)),j2=d(2,(e,t)=>Xs(e,(n,r)=>te(Vl(t),o=>qt(n,o)))),B2=d(2,(e,t)=>Qe((n,r)=>te(Ue(e)(n,r),o=>_(o,function s(i){return t(i)?k(i):_(o,s)}))));var $2=d(2,(e,t)=>Xs(e,n=>k(_(n,function r(o){let s=[];for(let i=0;i<o.length;i++)t(o[i])&&s.push(o[i]);return et(s)?k(s):_(n,r)})))),H2=d(2,(e,t)=>Xs(e,n=>k(_(n,function r(o){let s=[];for(let i=0;i<o.length;i++){let a=t(o[i]);_t(a)&&s.push(a.success)}return et(s)?k(s):_(n,r)})))),z2=d(2,(e,t)=>Xs(e,n=>{let r=_(n,o=>QT(o,t));return k(_(r,function o(s){return et(s)?k(s):_(r,o)}))})),W2=d(2,(e,t)=>Xs(e,n=>k(_(n,function r(o){return _(YT(o,t),s=>et(s)?k(s):_(n,r))})))),Td=d(e=>lr(e[0]),(e,t,n,r)=>Qe((o,s)=>te(Ue(e)(o,s),i=>{let a=t(),c,u=0,f,l=io(i,{onFailure(h){f=h;let g=r?.onHalt&&r.onHalt(a);return g&&g.length>0?k([a,g]):lt(h)},onSuccess(h){let g=n(a,h);return oM(g)?k(g):g}});return V(function h(){if(c===void 0)return f?lt(f):_(l,([x,S])=>(a=x,S.length===0?h():S.length===1?k(S[0]):(c=S,h())));let g=c[u++];return u>=c.length&&(c=void 0,u=0),k(g)})})));var K2=d(3,(e,t,n)=>Qe((r,o)=>te(Ue(e)(r,o),s=>{let i=t,a=!0;return V(()=>a?(a=!1,k(i)):te(_(s,c=>n(i,c)),c=>(i=c,i)))}))),Id=d(2,(e,t)=>Qe((n,r)=>{let o=Fn(r);return te(Ue(e)(n,o),s=>{let i=s.pipe(ht(a=>{if(Xo(a))return lt(a);let c=o;return o=Fn(r),Ze(c,Jt(a)).pipe(Wn(Ue(t(a))(n,o)),_(u=>(i=u,u)))}));return V(()=>i)})})),cb=d(2,(e,t)=>Id(e,n=>A2(_(t(n),r=>lt(n))))),V2=d(3,(e,t,n)=>Id(e,r=>t(r)?n(r):dh(r))),nA=d(3,(e,t,n)=>Id(e,r=>{let o=t(r);return we(o)?dh(o.failure):n(o.success,r)})),Ys=d(2,(e,t)=>nA(e,$u,n=>t(n)));var J2=d(2,(e,t)=>Xs(e,n=>k(gm(n,r=>Hl(r)?W:ns(t(r)))))),G2=d(e=>lr(e[0]),(e,t,n,r)=>Ys(e,o=>t(o)?n(o):r?r(o):qi(o))),Z2=d(e=>lr(e[0]),(e,t,n,r)=>Ys(e,o=>{let s=t(o);return we(s)?r?r(s.failure):qi(s.failure):n(s.success)}));var Q2=d(e=>lr(e[0]),(e,t,n,r,o)=>Ys(e,s=>{if(jn(s,t)&&N(s,"reason")){let i=s.reason;return jn(i,n)?r(i,s):o?o(i,s):qi(s)}return qi(s)})),Y2=d(e=>lr(e[0]),(e,t,n,r)=>{let o;return Ys(e,s=>{if(jn(s,t)&&N(s,"reason")&&N(s.reason,"_tag")&&Iy(s.reason._tag)){let i=s.reason;return o??=new Set(Object.keys(n)),o.has(i._tag)?n[i._tag](i,s):r?r(i,s):qi(s)}return qi(s)})});var X2=d(2,(e,t)=>Ys(e,n=>qi(t(n)))),eL=e=>Ys(e,Qk),tL=d(e=>lr(e[0]),(e,t)=>{if(!t?.log)return Ys(e,()=>vd);let n=rd(t.log===!0?void 0:t.log);return Ys(cb(e,r=>iT(r)?n(r):W),()=>vd)}),y2=e=>Id(e,()=>vd),nL=d(e=>lr(e[0]),(e,t)=>{if(!t?.log)return y2(e);let n=rd(t.log===!0?void 0:t.log);return y2(cb(e,r=>n(r)))}),rL=d(2,(e,t)=>rb(()=>{let n,r=zn.defaultValue(),o=pb(e,zn,ae(()=>r)),s=sA(o,()=>(n=void 0,W)),i=typeof t=="function"?t(j):t,a=Ys(s,Ee(function*(c){return n||(n=yield*Ls(i)),r=yield*n(c),a},(c,u)=>Gt(c,()=>k(qi(u))),$a));return a})),oL=d(e=>lr(e[0]),(e,t,n)=>e.pipe(ti(t),ub({...n,concurrency:n?.concurrency??1,switch:!0}))),ub=d(2,(e,{bufferSize:t=16,concurrency:n,switch:r=!1})=>ei(Ee(function*(o,s,i){let a=n==="unbounded"?Number.MAX_SAFE_INTEGER:Math.max(1,n),c=r?void 0:Ba(a),u=yield*r2(!0),f=new Set,l=yield*wf(t);yield*Dt(i,Qs(l));let p=yield*Ue(e)(o,s);return yield*Lt(function*(){for(;;){let h;c&&(f.size<a?yield*c.take(1):(h=yield*td(p),yield*Cc(c.take(1),Wn(xd(h),oo))));let g=h===void 0?yield*p:yield*xd(h),x=Fn(i),S=yield*Ue(g)(o,x);for(;f.size>=a;){let E=X_(f);f.delete(E),f.size===0&&(yield*u.open),yield*Fo(E)}let w=yield*S.pipe(qt(()=>hm),_(E=>fr(l,E)),Qt({disableYield:!0}),Ro(Ee(function*(E){let y=Kl(E);if(yield*so(Ze(x,we(y)?Jt(y.failure):Pn(y.success.value))),!!f.has(w)&&(f.delete(w),c&&(yield*c.release(1)),f.size===0&&(yield*u.open),!_t(y)))return yield*on(l,E)})),td);u.closeUnsafe(),f.add(w)}}).pipe(ht(h=>{let g=Kl(h);return _t(g)?u.whenOpen(on(l,h)):on(l,h)}),zt(i)),us(l)}))),fb=d(e=>lr(e[0])&&lr(e[1]),(e,t,n)=>ei(Ee(function*(r,o,s){let i=n?.haltStrategy??"both",a=yield*wf(0);yield*Dt(s,Qs(a));let c=0;function u(l,p){if(c++,!Xo(p))return on(a,p);switch(i){case"both":return c===2?on(a,p):W;case"left":case"right":return l===i?on(a,p):W;case"either":return on(a,p)}}let f=(l,p,h)=>Ue(p)(r,h).pipe(_(g=>g.pipe(_(x=>fr(a,x)),Qt)),Ro(g=>Wn(Ze(h,PT(g)),u(l,g))),zt(s));return yield*f("left",e,Fn(s)),yield*f("right",t,Fn(s)),us(a)}))),sL=d(2,(e,t)=>fb(e,A2(t),{haltStrategy:"left"})),iL=()=>Qe((e,t)=>ae(()=>{let n="",r=!1,o=D();function s(c){let u=[];function f(l){n.length===0?u.push(l):(u.push(n+l),n="")}for(let l=0;l<c.length;l++){let p=c[l];if(p.length!==0){let h=0,g=p.indexOf("\r"),x=p.indexOf(`
27
- `);for(r&&(x===0?(f(""),h=1,x=p.indexOf(`
28
- `,h)):f(""),r=!1);g!==-1||x!==-1;)g===-1||x!==-1&&x<g?(f(p.substring(h,x)),h=x+1,x=p.indexOf(`
29
- `,h)):p.length===g+1?(r=!0,g=-1):(f(p.substring(h,g)),h=g+(x===g+1?2:1),g=p.indexOf("\r",h),x=p.indexOf(`
30
- `,h));n=n+p.substring(h,p.length-(r?1:0))}}return et(u)?u:null}let i=V(()=>o._tag==="Some"?he(o.value):um(e,{onSuccess:a,onFailure:lt,onDone:c=>{if(o=L(c),n.length>0||r){let u=n;return n="",r=!1,k([u])}return he(c)}}));function a(c){let u=s(c);return u!==null?k(u):i}return i}));var rA=d(2,(e,t)=>Qe((n,r)=>_(Ue(e)(n,r),o=>Ue(t)(o,r)))),oA=d(2,(e,t)=>Qe((n,r)=>_(Ue(e)(n,r),o=>{let s=ht(o,i=>Xo(i)?lt(i):Ao(uT(i)));return te(Ue(t)(s,r),i=>WT(i,a=>Hl(a)?lt(a.value):Ao(a)))}))),$a=e=>Qe((t,n)=>{let r;return k(V(()=>r||e.pipe(Qo(n),_(o=>Ue(o)(t,n)),_(o=>r=o))))}),aL=e=>ei((t,n,r)=>te(Qo(Ue(e)(t,n),r),Qo(r)));var cL=d(2,(e,t)=>Qe(Ee(function*(n,r){let o=yield*Ue(e)(n,r),s=yield*lo({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*Dt(r,Qs(s)),yield*o.pipe(_(i=>fr(s,i)),Qt({disableYield:!0}),Ro(i=>on(s,i)),zt(r)),us(s)}))),uL=d(2,(e,t)=>Qe(Ee(function*(n,r){let o=yield*Ue(e)(n,r),s=yield*lo({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*Dt(r,Qs(s)),yield*o.pipe(_(i=>ja(s,i)),Qt({disableYield:!0}),Ro(i=>on(s,i)),zt(r)),wd(s)}))),fL=d(2,(e,t)=>fb(e,Qn(k(_(t,he))),{haltStrategy:"either"})),lL=d(2,(e,t)=>ei(Ee(function*(n,r,o){let s=yield*Ue(e)(n,r),i=yield*zt(t,o,{startImmediately:!0});return V(()=>{let a=i.pollUnsafe();return a===void 0?s:r1(a,{onFailure:lt,onSuccess:he})})}))),dL=d(2,(e,t)=>ph(e,n=>Ei(n)?t(n.cause):W)),ph=d(2,(e,t)=>ei((n,r,o)=>Yo(o,t).pipe(Wn(Ue(e)(n,r))))),pL=d(2,(e,t)=>$a(Zt(t,e))),sA=d(2,(e,t)=>Xs(e,n=>ae(()=>{let r=!0,o=qt(n,s=>(r=!1,t(s)));return V(()=>r?o:n)}))),mL=d(2,(e,t)=>Xs(e,n=>k(Gt(n,r=>_(t,()=>he(r)))))),hL=d(2,(e,t)=>ph(e,n=>t)),Tf=(e,t,n)=>V(()=>{let r=no(),o=Ue(e)(he(),r);return Gt(_(o,t),n||k).pipe(Sr(s=>Ze(r,s)))});var lb=d(2,(e,t)=>Qe((n,r)=>te(Vn(Ue(e)(n,r),t),Vn(t)))),db=d(3,(e,t,n)=>Qe((r,o)=>te(rs(Ue(e)(r,o),t,n),rs(t,n)))),pb=d(3,(e,t,n)=>Qe((r,o)=>_(n,s=>Ue(db(e,t,s))(r,o)))),gL=d(e=>lr(e[0]),(e,t,n)=>Np(t)?lb(e,t):Qe((r,o)=>_(n?.local?vi(t,wi(),o):rm(t,o),s=>te(Vn(Ue(e)(r,o),s),Vn(s))))),xL=d(2,(e,t)=>Qe((n,r)=>yr(o=>{let s=t(o);return Ue(lb(e,s))(n,r)})));var iA=function(){let e=lr(arguments[0]),t=e?arguments[1]:arguments[0],n=Go(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return S2(r,t,n)}return r=>S2(r,t,n)},S2=(e,t,n)=>m7(iI(t,n),r=>db(e,yi,r),(r,o)=>kn(s=>{let i=s.getRef(ko),a=s.getRef(a1);return iy(r,o,i,a)}));var yL=e=>Tf(e,t=>Qt(t,{disableYield:!0})),If=d(2,(e,t)=>Tf(e,n=>Qt(_(n,t),{disableYield:!0}))),SL=d(2,(e,t)=>Tf(e,n=>n.pipe(_(t),_(r=>r?W:he()),Qt({disableYield:!0})))),aA=e=>te(kf(e,()=>({bytes:0,arrays:[]}),(t,n)=>{for(let r=0;r<n.length;r++)t.bytes+=n[r].length,t.arrays.push(n[r]);return t}),({arrays:t,bytes:n})=>{let r=new Uint8Array(n),o=0;for(let s=0;s<t.length;s++){let i=t[s];r.set(i,o),o+=i.length}return r});var bL=e=>V(()=>{let t=D();return Tf(e,n=>n.pipe(Py,_(r=>(t=r,he()))),()=>k(t))}),EL=e=>V(()=>{let t=Symbol(),n=t;return Tf(e,r=>Qt(_(r,o=>(n=o,W)),{disableYield:!0}),()=>n===t?js:_y(n))}),kf=d(3,(e,t,n)=>V(()=>{let r=t();return Tf(e,o=>ur({while:cn,body:()=>o,step:s=>{r=n(r,s)}}),()=>k(r))})),wL=d(3,(e,t,n)=>V(()=>{let r=t();return Tf(e,o=>ur({while:cn,body:Xe(o.pipe(_(s=>n(r,s)),te(s=>{r=s}))),step:Cn}),()=>k(r))})),cA=Ee(function*(e){let t=Ba(1),n=yield*Kn(),r=ze(n,mt);return(yield*Ue(e)(he(),r)).pipe(Vn(n),t.withPermits(1))},ht(e=>k(lt(e)))),fs=(e,t)=>Ue(e)(he(),t);var uA=d(e=>lr(e[0]),(e,t)=>Oo(n=>If(e,r=>ja(t,r)).pipe(n,so,_(r=>(Nt(r)?p2(t):Li(t,r.cause),W)))));var vL=d(e=>lr(e[0]),Ee(function*(e,t){let n=yield*os,r=yield*lo({capacity:typeof t.capacity=="number"?t.capacity:void 0,strategy:typeof t.capacity=="number"?t.strategy:void 0});return yield*Dt(n,Qs(r)),yield*zt(uA(e,r),n),r}));var TL=e=>Oc(e.capacity==="unbounded"?ih(e):e.strategy==="dropping"?VS(e):e.strategy==="sliding"?JS(e):KS(e),ah),IL=d(2,Ee(function*(e,t){let n=yield*TL(t);return yield*$s(fA(e,n,{shutdownOnEnd:t.shutdownOnEnd!==!1})),n})),fA=d(e=>lr(e[0]),(e,t,n)=>If(e,r=>f2(t,r)).pipe(n?.shutdownOnEnd===!0?Ca(ah(t)):j)),kL=d(2,Ee(function*(e,t){let n=yield*TL(t);return yield*If(e,r=>Sd(n,r)).pipe(Sr(r=>Sd(n,r)),$s),n}));var m={};dn(m,{Any:()=>CY,Array:()=>Xt,ArrayEnsure:()=>LY,BigDecimal:()=>gR,BigDecimalFromString:()=>Nee,BigDecimalReviver:()=>Uee,BigInt:()=>Bi,BigIntFromString:()=>Kee,Boolean:()=>Kc,BooleanFromBit:()=>Xee,Cause:()=>Dd,CauseReason:()=>zb,CauseReasonReviver:()=>see,CauseReviver:()=>iee,Char:()=>KX,Chunk:()=>qB,ChunkReviver:()=>See,Class:()=>eE,Date:()=>ii,DateFromMillis:()=>Iee,DateFromString:()=>Tee,DateReviver:()=>vee,DateTimeUtc:()=>Hh,DateTimeUtcFromDate:()=>ste,DateTimeUtcFromMillis:()=>ate,DateTimeUtcFromString:()=>ite,DateTimeUtcReviver:()=>ote,DateTimeZoned:()=>wR,DateTimeZonedFromString:()=>mte,DateTimeZonedReviver:()=>pte,Defect:()=>xn,Duration:()=>$h,DurationFromMillis:()=>Oee,DurationFromNanos:()=>Cee,DurationFromString:()=>Ree,DurationReviver:()=>kee,Enum:()=>RY,Error:()=>Yn,ErrorInstance:()=>_B,ErrorInstanceReviver:()=>uee,Exit:()=>Yb,ExitReviver:()=>fee,File:()=>xR,FileReviver:()=>qee,Finite:()=>si,FiniteFromString:()=>Wee,FormData:()=>yR,FormDataReviver:()=>jee,Graph:()=>UB,GraphReviver:()=>hee,HashMap:()=>NB,HashMapReviver:()=>gee,HashSet:()=>LB,HashSetReviver:()=>yee,Int:()=>ai,Json:()=>Wh,JsonObject:()=>Yte,JsonReviver:()=>Xte,Literal:()=>Mt,Literals:()=>Ka,MutableJson:()=>f$,MutableJsonReviver:()=>tne,Natural:()=>dr,Never:()=>$i,NonEmptyArray:()=>Gb,NonEmptyString:()=>WX,Null:()=>rt,NullOr:()=>oR,NullishOr:()=>kj,Number:()=>jd,NumberFromString:()=>zee,ObjectKeyword:()=>OY,Opaque:()=>YY,Option:()=>Hi,OptionFromNullOr:()=>JX,OptionFromNullishOr:()=>ZX,OptionFromOptional:()=>YX,OptionFromOptionalKey:()=>QX,OptionFromOptionalNullOr:()=>XX,OptionFromUndefinedOr:()=>GX,OptionReviver:()=>VX,PropertyKey:()=>ZA,ReadonlyMap:()=>FB,ReadonlyMapReviver:()=>lee,ReadonlySet:()=>DB,ReadonlySetReviver:()=>xee,Record:()=>rR,Redacted:()=>pR,RedactedFromValue:()=>oee,RedactedReviver:()=>ree,RegExp:()=>jB,RegExpReviver:()=>bee,Result:()=>wB,ResultReviver:()=>eee,SchemaError:()=>Wr,StandardSchemaV1FailureResult:()=>Yee,String:()=>de,StringFromBase64:()=>Jee,StringFromBase64Url:()=>Gee,StringFromHex:()=>Zee,StringFromUriComponent:()=>Qee,Struct:()=>ie,StructWithRest:()=>NY,Symbol:()=>vj,TaggedClass:()=>yte,TaggedError:()=>TR,TaggedStruct:()=>Vc,TaggedUnion:()=>QY,TemplateLiteral:()=>kY,TemplateLiteralParser:()=>AY,TimeZone:()=>ER,TimeZoneFromString:()=>dte,TimeZoneNamed:()=>bR,TimeZoneNamedFromString:()=>fte,TimeZoneNamedReviver:()=>ute,TimeZoneOffset:()=>GB,TimeZoneOffsetReviver:()=>cte,TimeZoneReviver:()=>lte,Tree:()=>Qte,Trim:()=>Vee,Trimmed:()=>VB,Tuple:()=>zc,TupleWithRest:()=>DY,URL:()=>mR,URLFromString:()=>wee,URLReviver:()=>Eee,URLSearchParams:()=>SR,URLSearchParamsReviver:()=>$ee,Uint8Array:()=>ps,Uint8ArrayFromBase64:()=>tte,Uint8ArrayFromBase64Url:()=>nte,Uint8ArrayFromHex:()=>rte,Uint8ArrayReviver:()=>ete,Undefined:()=>tR,UndefinedOr:()=>Zb,Union:()=>Ve,UniqueArray:()=>qY,UniqueSymbol:()=>_Y,Unknown:()=>eR,UnknownFromJsonString:()=>Lee,Void:()=>Bd,annotate:()=>sY,annotateEncoded:()=>iY,annotateKey:()=>aY,asserts:()=>lY,brand:()=>Rj,catchDecoding:()=>zY,catchDecodingWithContext:()=>_j,catchEncoding:()=>WY,catchEncodingWithContext:()=>Mj,check:()=>BY,declare:()=>po,declareConstructor:()=>Dn,decode:()=>KY,decodeEffect:()=>dY,decodeExit:()=>hj,decodeOption:()=>mY,decodePromise:()=>gY,decodeResult:()=>hY,decodeSync:()=>Fh,decodeTo:()=>ve,decodeUnknownEffect:()=>Wc,decodeUnknownExit:()=>mj,decodeUnknownOption:()=>pY,decodeUnknownPromise:()=>xj,decodeUnknownResult:()=>gj,decodeUnknownSync:()=>Kb,encode:()=>VY,encodeEffect:()=>Vb,encodeExit:()=>Sj,encodeKeys:()=>FY,encodeOption:()=>yY,encodePromise:()=>bY,encodeResult:()=>SY,encodeSync:()=>XA,encodeTo:()=>sR,encodeUnknownEffect:()=>Uh,encodeUnknownExit:()=>yj,encodeUnknownOption:()=>xY,encodeUnknownPromise:()=>Ej,encodeUnknownResult:()=>bj,encodeUnknownSync:()=>Jb,extendTo:()=>UY,fieldsAssign:()=>MY,flip:()=>JA,fromBrand:()=>HY,fromFormData:()=>Bee,fromJsonString:()=>KB,fromURLSearchParams:()=>Hee,instanceOf:()=>Jc,is:()=>uj,isBase64:()=>cR,isBase64Reviver:()=>fX,isBase64Url:()=>Hj,isBase64UrlReviver:()=>lX,isBetween:()=>Qb,isBetweenBigDecimal:()=>PX,isBetweenBigInt:()=>dB,isBetweenBigIntReviver:()=>Wte,isBetweenDate:()=>aB,isBetweenDateReviver:()=>jte,isBetweenReviver:()=>TX,isCapitalized:()=>Gj,isCapitalizedReviver:()=>xX,isEndsWith:()=>Wj,isEndsWithReviver:()=>pX,isFinite:()=>Qj,isFiniteReviver:()=>SX,isGUID:()=>Bj,isGUIDReviver:()=>cX,isGreaterThan:()=>Xj,isGreaterThanBigDecimal:()=>CX,isGreaterThanBigInt:()=>cB,isGreaterThanBigIntReviver:()=>Bte,isGreaterThanDate:()=>rB,isGreaterThanDateReviver:()=>Nte,isGreaterThanOrEqualTo:()=>uR,isGreaterThanOrEqualToBigDecimal:()=>OX,isGreaterThanOrEqualToBigInt:()=>uB,isGreaterThanOrEqualToBigIntReviver:()=>$te,isGreaterThanOrEqualToDate:()=>oB,isGreaterThanOrEqualToDateReviver:()=>Dte,isGreaterThanOrEqualToReviver:()=>EX,isGreaterThanReviver:()=>bX,isIncludes:()=>Kj,isIncludesReviver:()=>mX,isInt:()=>Bh,isInt32:()=>AX,isIntReviver:()=>kX,isLengthBetween:()=>lR,isLengthBetweenReviver:()=>NX,isLessThan:()=>eB,isLessThanBigDecimal:()=>_X,isLessThanBigInt:()=>fB,isLessThanBigIntReviver:()=>Hte,isLessThanDate:()=>sB,isLessThanDateReviver:()=>Lte,isLessThanOrEqualTo:()=>tB,isLessThanOrEqualToBigDecimal:()=>MX,isLessThanOrEqualToBigInt:()=>lB,isLessThanOrEqualToBigIntReviver:()=>zte,isLessThanOrEqualToDate:()=>iB,isLessThanOrEqualToDateReviver:()=>qte,isLessThanOrEqualToReviver:()=>vX,isLessThanReviver:()=>wX,isLowercased:()=>Jj,isLowercasedReviver:()=>gX,isMaxLength:()=>mB,isMaxLengthReviver:()=>UX,isMaxProperties:()=>SB,isMaxPropertiesReviver:()=>BX,isMaxSize:()=>gB,isMaxSizeReviver:()=>LX,isMinLength:()=>fR,isMinLengthReviver:()=>FX,isMinProperties:()=>yB,isMinPropertiesReviver:()=>jX,isMinSize:()=>hB,isMinSizeReviver:()=>DX,isMultipleOf:()=>nB,isMultipleOfReviver:()=>IX,isNonEmpty:()=>pB,isPattern:()=>Df,isPatternReviver:()=>nX,isPropertiesLengthBetween:()=>bB,isPropertiesLengthBetweenReviver:()=>$X,isPropertyNames:()=>EB,isPropertyNamesReviver:()=>HX,isSchema:()=>Nf,isSchemaError:()=>Ld,isSizeBetween:()=>xB,isSizeBetweenReviver:()=>qX,isStartsWith:()=>zj,isStartsWithReviver:()=>dX,isStringBigInt:()=>Lj,isStringBigIntReviver:()=>oX,isStringFinite:()=>Dj,isStringFiniteReviver:()=>rX,isStringSymbol:()=>qj,isStringSymbolReviver:()=>sX,isTrimmed:()=>aR,isTrimmedReviver:()=>eX,isULID:()=>$j,isULIDReviver:()=>uX,isUUID:()=>jj,isUUIDReviver:()=>aX,isUint32:()=>RX,isUncapitalized:()=>Zj,isUncapitalizedReviver:()=>yX,isUnique:()=>dR,isUniqueReviver:()=>zX,isUppercased:()=>Vj,isUppercasedReviver:()=>hX,link:()=>gt,make:()=>se,makeFilter:()=>Ct,makeFilterGroup:()=>XY,makeIsBetween:()=>jh,makeIsGreaterThan:()=>Nh,makeIsGreaterThanOrEqualTo:()=>Dh,makeIsLessThan:()=>Lh,makeIsLessThanOrEqualTo:()=>qh,makeIsMultipleOf:()=>Yj,middlewareDecoding:()=>Cj,middlewareEncoding:()=>Oj,mutable:()=>jY,mutableKey:()=>vY,optional:()=>Bt,optionalKey:()=>Uf,overrideToCodecIso:()=>Gte,overrideToEquivalence:()=>wte,overrideToFormatter:()=>bte,readonlyKey:()=>TY,refine:()=>$Y,required:()=>wY,requiredKey:()=>EY,resolveAnnotations:()=>nne,resolveAnnotationsKey:()=>rne,revealBottom:()=>oY,revealCodec:()=>cY,suspend:()=>Aj,tag:()=>Ye,tagDefaultOmit:()=>ZY,toArbitrary:()=>Ste,toCodecArrayFromSingle:()=>Rte,toCodecIso:()=>r$,toCodecJson:()=>Gc,toCodecJsonAST:()=>tE,toCodecStringTree:()=>s$,toDifferJsonPatch:()=>Zte,toEncoded:()=>qd,toEncoderXml:()=>Cte,toEquivalence:()=>vte,toFormatter:()=>Ete,toIso:()=>Kte,toIsoFocus:()=>Jte,toIsoSource:()=>Vte,toJsonSchemaDocument:()=>e$,toRepresentation:()=>Tte,toStandardJSONSchemaV1:()=>fY,toStandardSchemaV1:()=>uY,toTaggedUnion:()=>Nj,toType:()=>Kr,withConstructorDefault:()=>Pj,withDecodingDefault:()=>Uj,withDecodingDefaultKey:()=>iR,withDecodingDefaultType:()=>GY,withDecodingDefaultTypeKey:()=>JY});var hb="~effect/collections/Graph",lA=e=>e;var E7=(e,t,n)=>(e==="directed"?t.source===n.source&&t.target===n.target:t.source===n.source&&t.target===n.target||t.source===n.target&&t.target===n.source)&&ne(t.data,n.data),w7=(e,t)=>e==="directed"?ue(t):oa(ue(t.data)^ue(t.source)+ue(t.target)),v7={[hb]:{_N:e=>e,_E:e=>e},[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[ft](){return this.toJSON()},[ke](e){if(N(e,hb)){let t=lA(e);if(this.nodes.size!==t.nodes.size||this.edges.size!==t.edges.size||this.type!==t.type)return!1;for(let[n,r]of this.nodes)if(!t.nodes.has(n)||!ne(r,t.nodes.get(n)))return!1;for(let[n,r]of this.edges){let o=t.edges.get(n);if(o===void 0||!E7(this.type,r,o))return!1}return!0}return!1},[Ie](){let e=st("Graph");e=e^st(this.type),e=e^_r(this.nodes.size),e=e^_r(this.edges.size);for(let[t,n]of this.nodes)e=e^ue(t)+ue(n);for(let[t,n]of this.edges)e=e^ue(t)+w7(this.type,n);return e},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return`Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`},pipe(){return ce(this,arguments)}},AL=(e,t)=>{let n=Object.create(v7);return n.type=e,n.mutable=t,n.transforming=!1,n.nodes=new Map,n.edges=new Map,n.adjacency=new Map,n.reverseAdjacency=new Map,n.nextNodeIndex=0,n.nextEdgeIndex=0,n.acyclic=L(!0),n};var mh=e=>{let t=lA(e);return{type:e.type,nodes:Array.from(t.nodes,([n,r])=>({index:n,data:r})).sort((n,r)=>n.index-r.index),edges:Array.from(t.edges,([n,r])=>({index:n,source:r.source,target:r.target,data:r.data})).sort((n,r)=>n.index-r.index)}},hh=e=>{let t=AL(e.type,!1);for(let n of e.nodes)t.nodes.set(n.index,n.data),t.adjacency.set(n.index,[]),t.reverseAdjacency.set(n.index,[]);for(let n of e.edges)t.edges.set(n.index,{source:n.source,target:n.target,data:n.data}),t.adjacency.get(n.source).push(n.index),t.reverseAdjacency.get(n.target).push(n.index),e.type==="undirected"&&(t.adjacency.get(n.target).push(n.index),t.reverseAdjacency.get(n.source).push(n.index));return t.nextNodeIndex=e.nodes.length===0?0:e.nodes[e.nodes.length-1].index+1,t.nextEdgeIndex=e.edges.length===0?0:e.edges[e.edges.length-1].index+1,t.acyclic=D(),t};var T7=hb;var dA=e=>N(e,T7);var CL=class e{type;source;target;identity;constructor(t,n,r,o){this.type=t,this.source=n,this.target=r,this.identity=o}[ke](t){return!(t instanceof e)||this.type!==t.type||!ne(this.identity,t.identity)?!1:this.type==="directed"?ne(this.source,t.source)&&ne(this.target,t.target):ne(this.source,t.source)&&ne(this.target,t.target)||ne(this.source,t.target)&&ne(this.target,t.source)}[Ie](){let t=ue(this.identity);return this.type==="directed"?Ht(ue(this.target))(Ht(ue(this.source))(t)):oa(t^ue(this.source)+ue(this.target))}};var xb="~effect/collections/HashMap",ni=5,xh=1<<ni,I7=xh/4,_L=xh/2,k7=xh-1,A7=e=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),gh=(e,t)=>e>>>t&k7,jc=(e,t)=>1<<gh(e,t),gb=(e,t)=>A7(e&t-1);function ML(e,t,n,r,o,s){if(t>32)throw new Error("HashMap: max depth exceeded");let i=jc(n,t),a=jc(o,t);if(i===a){let f=ML(e,t+ni,n,r,o,s);return new Cf(e,i,[f])}let c=i|a,u=i>>>0<a>>>0?[r,s]:[s,r];return new Cf(e,c,u)}var Af=class{canEdit(t){return this.edit===t}},pA=class extends Af{_tag="EmptyNode";edit=0;get size(){return 0}get(t,n,r){return D()}has(t,n,r){return!1}set(t,n,r,o,s,i){return i.value=!0,new Rf(t,r,o,s)}remove(t,n,r,o,s){return this}iterator(){return[][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}canEdit(t){return!1}},Rf=class e extends Af{_tag="LeafNode";edit;hash;key;value;constructor(t,n,r,o){super(),this.edit=t,this.hash=n,this.key=r,this.value=o}get size(){return 1}get(t,n,r){return this.hash===n&&ne(this.key,r)?L(this.value):D()}has(t,n,r){return this.hash===n&&ne(this.key,r)}set(t,n,r,o,s,i){if(this.hash===r&&ne(this.key,o))return ne(this.value,s)?this:this.canEdit(t)?(this.value=s,this):new e(t,r,o,s);if(i.value=!0,this.hash===r)return new mA(t,r,[[this.key,this.value],[o,s]]);let a=jc(r,n),c=jc(this.hash,n);if(a===c)return new Cf(t,a,[this.set(t,n+ni,r,o,s,i)]);let u=a|c,f=a>>>0<c>>>0?[new e(t,r,o,s),this]:[this,new e(t,r,o,s)];return new Cf(t,u,f)}remove(t,n,r,o,s){if(this.hash===r&&ne(this.key,o)){s.value=!0;return}return this}iterator(){return[[this.key,this.value]][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}},mA=class e extends Af{_tag="CollisionNode";edit;hash;entries;constructor(t,n,r){super(),this.edit=t,this.hash=n,this.entries=r}get size(){return this.entries.length}get(t,n,r){if(this.hash!==n)return D();for(let[o,s]of this.entries)if(ne(o,r))return L(s);return D()}has(t,n,r){if(this.hash!==n)return!1;for(let[o]of this.entries)if(ne(o,r))return!0;return!1}set(t,n,r,o,s,i){if(this.hash!==r)return i.value=!0,ML(t,n,this.hash,this,r,new Rf(t,r,o,s));for(let a=0;a<this.entries.length;a++)if(ne(this.entries[a][0],o)){if(ne(this.entries[a][1],s))return this;if(this.canEdit(t))return this.entries[a]=[o,s],this;let c=[...this.entries];return c[a]=[o,s],new e(t,this.hash,c)}return i.value=!0,this.canEdit(t)?(this.entries.push([o,s]),this):new e(t,this.hash,[...this.entries,[o,s]])}remove(t,n,r,o,s){if(this.hash!==r)return this;let i=this.entries.findIndex(([c])=>ne(c,o));if(i===-1)return this;if(s.value=!0,this.entries.length===1)return;if(this.entries.length===2){let c=this.entries[i===0?1:0];return new Rf(t,this.hash,c[0],c[1])}if(this.canEdit(t))return this.entries.splice(i,1),this;let a=[...this.entries];return a.splice(i,1),new e(t,this.hash,a)}iterator(){return this.entries[Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}},Cf=class e extends Af{_tag="IndexedNode";edit;_size;bitmap;children;constructor(t,n,r){super(),this.edit=t,this.bitmap=n,this.children=r}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,n)=>t+n.size,0)),this._size}get(t,n,r){let o=jc(n,t);if((this.bitmap&o)===0)return D();let s=gb(this.bitmap,o);return this.children[s].get(t+ni,n,r)}has(t,n,r){let o=jc(n,t);if((this.bitmap&o)===0)return!1;let s=gb(this.bitmap,o);return this.children[s].has(t+ni,n,r)}set(t,n,r,o,s,i){let a=jc(r,n),c=gb(this.bitmap,a);if((this.bitmap&a)!==0){let u=this.children[c],f=u.set(t,n+ni,r,o,s,i);if(u===f)return this;if(this.canEdit(t))return this.children[c]=f,this;let l=[...this.children];return l[c]=f,new e(t,this.bitmap,l)}else{i.value=!0;let u=new Rf(t,r,o,s),f=this.bitmap|a;if(this.canEdit(t))return this.children.splice(c,0,u),this.bitmap=f,this._size=void 0,this.children.length>_L?this.expand(t,f,this.children):this;let l=[...this.children];return l.splice(c,0,u),l.length>_L?this.expand(t,f,l):new e(t,f,l)}}remove(t,n,r,o,s){let i=jc(r,n);if((this.bitmap&i)===0)return this;let a=gb(this.bitmap,i),c=this.children[a],u=c.remove(t,n+ni,r,o,s);if(!s.value)return this;if(u===void 0){let l=this.bitmap^i;if(l===0)return;if(this.children.length===2){let h=this.children[a===0?1:0];if(h._tag==="LeafNode")return h}if(this.canEdit(t))return this.children.splice(a,1),this.bitmap=l,this._size=void 0,this;let p=[...this.children];return p.splice(a,1),new e(t,l,p)}if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.bitmap,f)}expand(t,n,r){let o=new globalThis.Array(xh),s=0;for(let i=0;i<xh;i++)(n&1<<i)!==0&&(o[i]=r[s++]);return new hA(t,r.length,o)}iterator(){let t=0,n;return{next:()=>{for(;t<this.children.length;){n||(n=this.children[t].iterator());let r=n.next();if(!r.done)return r;n=void 0,t++}return{done:!0,value:void 0}}}}[Symbol.iterator](){return this.iterator()}},hA=class e extends Af{_tag="ArrayNode";edit;_size;count;children;constructor(t,n,r){super(),this.edit=t,this.count=n,this.children=r}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,n)=>t+(n?.size??0),0)),this._size}get(t,n,r){let o=gh(n,t),s=this.children[o];return s?s.get(t+ni,n,r):D()}has(t,n,r){let o=gh(n,t),s=this.children[o];return s?s.has(t+ni,n,r):!1}set(t,n,r,o,s,i){let a=gh(r,n),c=this.children[a];if(c){let u=c.set(t,n+ni,r,o,s,i);if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.count,f)}else{i.value=!0;let u=new Rf(t,r,o,s);if(this.canEdit(t))return this.children[a]=u,this.count++,this._size=void 0,this;let f=[...this.children];return f[a]=u,new e(t,this.count+1,f)}}remove(t,n,r,o,s){let i=gh(r,n),a=this.children[i];if(!a)return this;let c=a.remove(t,n+ni,r,o,s);if(!s.value)return this;let u=this.count-(c?0:1);if(u<I7)return this.pack(t,i,c);if(a===c)return this;if(this.canEdit(t))return this.children[i]=c,c||(this.count=u),this._size=void 0,this;let f=[...this.children];return f[i]=c,new e(t,u,f)}pack(t,n,r){let o=[],s=0,i=1;for(let a=0;a<this.children.length;a++){let c=a===n?r:this.children[a];c&&(o.push(c),s|=i),i<<=1}return new Cf(t,s,o)}iterator(){let t=0,n;return{next:()=>{for(;t<this.children.length;){let r=this.children[t];if(!r){t++;continue}n||(n=r.iterator());let o=n.next();if(!o.done)return o;n=void 0,t++}return{done:!0,value:void 0}}}}[Symbol.iterator](){return this.iterator()}},yh=class{[xb]=xb;_editable;_edit;_root;_size;constructor(t,n,r,o){this._editable=t,this._edit=n,this._root=r,this._size=o}get size(){return this._size}[Symbol.iterator](){return this._root.iterator()}[ke](t){if(gA(t)){let n=t;if(this.size!==n.size)return!1;for(let[r,o]of this){let s=nl(t,UL(r));if(Se(s)||!ne(o,s.value))return!1}return!0}return!1}[Ie](){let t=st("HashMap");for(let[n,r]of this)t=t^ue(n)+ue(r);return t}[ft](){return wn(this)}toString(){return`HashMap(${re(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([t,n])=>[wn(t),wn(n)])}}pipe(){return ce(this,arguments)}},PL=new pA,gA=e=>N(e,xb),xA=()=>new yh(!1,0,PL,0);var FL=e=>{let t=PL,n=0,r={value:!1};for(let[o,s]of e){let i=ue(o);r.value=!1,t=t.set(NaN,0,i,o,s,r),r.value&&n++}return new yh(!1,0,t,n)};var UL=d(2,(e,t)=>e._root.get(0,ue(t),t));var yA=d(2,(e,t)=>e._root.has(0,ue(t),t));var R7=(e,t,n,r)=>{let o=e,s={value:!1},i=o._editable?o._edit:NaN,a=o._root.set(i,0,n,t,r,s);return o._editable?(o._root=a,s.value&&o._size++,e):o._root===a?e:new yh(!1,o._edit,a,o._size+(s.value?1:0))},SA=d(3,(e,t,n)=>R7(e,t,ue(t),n)),bA=e=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){let n=t.next();return n.done?{done:!0,value:void 0}:{done:!1,value:n.value[0]}}}};var NL=e=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){return t.next()}}},yb=e=>e.size;var Sb=gA;var bb=FL;var _7=NL,Eb=e=>Array.from(_7(e)),LL=yb;var Sh="~effect/collections/HashSet",M7={[Ie](){return ue(Sh)},[ke](e){return wA(e)&&wb(this)===wb(e)&&BL(this,t=>jL(e,t))},[Symbol.iterator](){return bA(vA(this))},toString(){return`HashSet(${re(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:wn(Array.from(this))}},[ft](){return this.toJSON()},pipe(){return ce(this,arguments)}},P7=e=>{let t=Object.create(M7);return t[Sh]=Sh,t.keyMap=e,t},wA=e=>N(e,Sh),vA=e=>e.keyMap;var qL=e=>{let t=xA();for(let n of e)t=SA(t,n,!0);return P7(t)},jL=(e,t)=>yA(vA(e),t);var wb=e=>yb(vA(e));var BL=(e,t)=>{for(let n of e)if(!t(n))return!1;return!0};var vb=qL,Tb=wA;var $L=wb;var za={};dn(za,{_is:()=>kd,_issue:()=>AA,asOption:()=>MA,asserts:()=>RA,decodeEffect:()=>vh,decodeExit:()=>D7,decodeOption:()=>CA,decodePromise:()=>N7,decodeResult:()=>L7,decodeSync:()=>Rb,decodeUnknownEffect:()=>ut,decodeUnknownExit:()=>Ib,decodeUnknownOption:()=>kb,decodeUnknownPromise:()=>U7,decodeUnknownResult:()=>Ab,decodeUnknownSync:()=>zL,encodeEffect:()=>q7,encodeExit:()=>B7,encodeOption:()=>OA,encodePromise:()=>j7,encodeResult:()=>$7,encodeSync:()=>Mb,encodeUnknownEffect:()=>Ha,encodeUnknownExit:()=>Cb,encodeUnknownOption:()=>Ob,encodeUnknownPromise:()=>WL,encodeUnknownResult:()=>_b,encodeUnknownSync:()=>KL,is:()=>kA,make:()=>IA,makeEffect:()=>Eh,makeOption:()=>wh,run:()=>Ad});function Eh(e){let t=VL(Pb,hn(e.ast));return(n,r)=>t(n,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function wh(e){let t=Eh(e);return(n,r)=>{let o=_c(t(n,r));return Nt(o)?L(o.value):(Mi(o.cause,"Option adapter can only return none for schema issues"),D())}}function IA(e){let t=Eh(e);return(n,r)=>{let o=_c(t(n,r));if(Nt(o))return o.value;let s=Mi(o.cause,"Constructor adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}function kA(e){return kd(e.ast)}function kd(e){let t=Of(Ad(hn(e)));return n=>{let r=t(n,$r);return Nt(r)?!0:(Mi(r.cause,"Type guard adapter can only return false for schema issues"),!1)}}function AA(e){let t=Ad(e);return(n,r)=>{let o=_c(t(n,r));if(!Nt(o))return Mi(o.cause,"Issue adapter can only return schema issues")}}function RA(e,t){let r=Of(Ad(hn(e.ast)))(t,$r);if(Ei(r)){let o=Mi(r.cause,"Assertion adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:o})}}function ut(e,t){let n=Ad(e.ast);return t===void 0?n:(r,o)=>n(r,bh(t,o))}var vh=ut;function U7(e,t){return _A(ut(e,t))}function N7(e,t){return _A(vh(e,t))}function Ib(e,t){return Of(ut(e,t))}var D7=Ib;function kb(e,t){return MA(ut(e,t))}var CA=kb;function Ab(e,t){return JL(ut(e,t))}var L7=Ab;function zL(e,t){return GL(ut(e,t))}var Rb=zL;function Ha(e,t){let n=Ad(is(e.ast));return t===void 0?n:(r,o)=>n(r,bh(t,o))}var q7=Ha,WL=(e,t)=>_A(Ha(e,t)),j7=WL;function Cb(e,t){return Of(Ha(e,t))}var B7=Cb;function Ob(e,t){return MA(Ha(e,t))}var OA=Ob;function _b(e,t){return JL(Ha(e,t))}var $7=_b;function KL(e,t){return GL(Ha(e,t))}var Mb=KL,bh=(e,t)=>t?{...e,...t}:e,HL=e=>e===Ke?Q(new Oe):k(e);function Ad(e){return VL(ZL,e)}function VL(e,t){let n;return(r,o)=>{let s=(n??=e(t))(r,o??$r);return s===ln?k(r):bt(s)?s[be]===Ke?HL(Ke):s:Gn(s,HL)}}function _A(e){return(t,n)=>Em(e(t,n)).then(r=>{if(Nt(r))return r.value;let o=Mi(r.cause,"Promise adapter can only reject schema issues");throw new Error("Schema validation failed",{cause:o})})}function Of(e){return(t,n)=>_c(e(t,n))}function MA(e){let t=Of(e);return(n,r)=>{let o=t(n,r);return Nt(o)?L(o.value):(Mi(o.cause,"Option adapter can only return none for schema issues"),D())}}function JL(e){let t=Of(e);return(n,r)=>{let o=t(n,r);return Nt(o)?le(o.value):ge(Mi(o.cause,"Result adapter can only return schema issues"))}}function GL(e){let t=Of(e);return(n,r)=>{let o=t(n,r);if(Nt(o))return o.value;let s=Mi(o.cause,"Sync adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}var ZL=bn(e=>PA(e,ZL)),Pb=bn(e=>PA(e,Pb,QL)),H7=bn(e=>PA(e,Pb,QL,e.context?.constructorDefault));function QL(e){return e.context?.constructorDefault?H7(e):Pb(e)}function YL(e,t,n,r){let o;if(bt(e)&&e._tag==="Success"){let s=$y(e===ln?t:e[be]);o=n._tag==="Transformation"?n.decode.run(s,r):n.decode(ss(s),r)}else n._tag==="Transformation"?o=Gn(e,s=>n.decode.run($y(s),r)):o=n.decode(_a(e,$y),r);return bt(o)&&o._tag==="Success"?pI(o[be]):Gn(o,pI)}function z7(e,t){let n;return(r,o)=>{if(r===Ke)return zs;if(e.isConstructed(r))return ln;let s=(n??=t(e.link.to))(r,o);return YL(s,r,e.link.transformation,o)}}function PA(e,t,n,r){let o=n?xk(e):void 0,s=o?z7(o,t):e.getParser(t,n),i=e.checks,a=r?e.encoding?[...e.encoding,r]:[r]:e.encoding,c=e.encodingChecks,u=(i?i[i.length-1].annotations:e.annotations)?.parseOptions;if(!a&&!i&&!c)return u?(p,h)=>s(p,bh(h,u)):s;let f,l=(p,h)=>{let g=s(p,h);if(c&&!h.disableChecks)if(bt(g)){if(g._tag==="Success"){let x=g===ln?p:g[be];if(p!==Ke&&x!==Ke){let S=cs(c,p,void 0,e,h);S&&(g=Q(new At(e,S,p,h)))}}}else g=_(g,x=>{if(p!==Ke&&x!==Ke){let S=cs(c,p,void 0,e,h);if(S)return Q(new At(e,S,p,h))}return k(x)});if(i&&!h.disableChecks)if(bt(g)){if(g._tag==="Success"){let x=g===ln?p:g[be];if(x===Ke)return g;let S=cs(i,x,void 0,e,h);S&&(g=Q(new At(e,S,x,h)))}}else g=_(g,x=>{if(x!==Ke){let S=cs(i,x,void 0,e,h);if(S)return Q(new At(e,S,x,h))}return k(x)});return g};return a?(p,h)=>{u&&(h=bh(h,u));let g=f??=a.map(w=>t(w.to)),x=p,S=g[g.length-1](p,h);for(let w=a.length-1;w>=0;w--)if(S=YL(S,x,a[w].transformation,h),w!==0){let E=g[w-1];S._tag==="Success"?(x=S[be],S=E(x,h)):S=Gn(S,y=>{let v=E(y,h);return v===ln?ss(y):v})}if(S._tag==="Success"){let w=S[be],E=l(w,h);return E===ln?S:E}return S=ht(S,w=>Aa(()=>ka(w,E=>new Rm(e,E,p,h)))),Gn(S,w=>{let E=l(w,h);return E===ln?ss(w):E})}:u?(p,h)=>l(p,bh(h,u)):l}var Fb="~effect/Schema/Schema";function zr(e,t,n){return{id:e,payloadSchema:t,revive:n}}function Me(e,t,n){return{id:e,payloadSchema:t,revive:n}}var W7={[Fb]:Fb,pipe(){return ce(this,arguments)},annotate(e){return this.rebuild(Mo(this.ast,e))},annotateKey(e){return this.rebuild(gf(this.ast,e))},check(...e){return this.rebuild(Vs(this.ast,e))}};function Th(e,t){function n(){}let r=Object.defineProperties(Object.setPrototypeOf(n,W7),Object.getOwnPropertyDescriptors({...t}));return r.ast=e,r.rebuild=o=>Th(o,t),r.makeEffect=Eh(r),r.make=IA(r),r.makeOption=wh(r),r}var XL=d(2,(e,t)=>UA(e,(n,r)=>t.includes(n)?[n,r]:void 0)),eq=d(2,(e,t)=>UA(e,(n,r)=>t.includes(n)?void 0:[n,r])),tq=d(2,(e,t)=>({...e,...t}));var FA=d(2,(e,t)=>UA(e,(n,r)=>[Object.hasOwn(t,n)?t[n]:n,r]));var vr=e=>e;function UA(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let o=t(r,e[r]);if(o){let[s,i]=o;K(n,s,i)}}return n}function nq(e,t){let n=t?.omitKeyWhen??(()=>!1);return Qg((r,o)=>{let s=Reflect.ownKeys(e),i={};for(let a of s){let c=e[a].combine(r[a],o[a]);n(c)||K(i,a,c)}return i})}function Ih(e){return jo((t,n)=>t===void 0?n:n===void 0?t:e.combine(t,n),void 0)}function ji(e,t){return t.length>0&&(e+=`
31
- at ${Yg(t)}`),new Error(e)}var oq=new WeakMap,sq=new WeakMap,iq=[];function Wa(e){return new Error(`Unable to derive an arbitrary for ${e}`)}var aq=([e],[t])=>ne(e,t);function V7(e,t,n){return t.reduce((r,o)=>r.filter(s=>o.run(s,e,$r)===void 0),n)}function xq(e,t){if(e?.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength)throw Wa(`${t} constraints`)}function yq(e){return e===void 0||e.minLength===void 0&&e.maxLength===void 0?void 0:{...e.minLength!==void 0?{minLength:e.minLength}:{},...e.maxLength!==void 0?{maxLength:e.maxLength}:{}}}function NA(e,t,n,r){return r?e.uniqueArray(t,{...n,comparator:r}):e.array(t,n)}function cq(e,t,n,r=!1){let o=t.constraint,s=yq(o);return xq(s,"array"),NA(e,n,r?{...s,maxLength:s?.minLength??0}:s,o?.unique?ne:void 0)}function Nb(e,t,n,r){return t.chain(o=>o.length<n?e.constant(o):r.map(s=>[...o,...s]))}function uq(e,t){return e.chain(n=>t.map(r=>({...Object.fromEntries(r),...n})))}var J7=Ih(q1),G7=Ih(j1),Db=Ih(bM),Z7=Ih(cM()),Q7=nq({integer:Db,maxLength:G7,minLength:J7,noInfinity:Db,noNaN:Db,patterns:Z7,unique:Db},{omitKeyWhen:J0});function fq(e,t,n,r,o,s){if(r===void 0||t===void 0)return r===void 0?[t,n]:[r,o];let i=e(t,r);return i===s?[r,o]:i===0?[t,n||o]:[t,n]}function Y7(e,t){if(e===void 0)return t;if(e.order!==t.order)throw new Error("Cannot merge ordered arbitrary constraints with different Order instances");let[n,r]=fq(e.order,e.minimum,e.exclusiveMinimum,t.minimum,t.exclusiveMinimum,-1),[o,s]=fq(e.order,e.maximum,e.exclusiveMaximum,t.maximum,t.exclusiveMaximum,1);return{order:e.order,...n!==void 0?{minimum:n}:{},...r!==void 0?{exclusiveMinimum:r}:{},...o!==void 0?{maximum:o}:{},...s!==void 0?{exclusiveMaximum:s}:{}}}function X7(e,t){let{ordered:n,...r}=e??{},{ordered:o,...s}=t,i=o===void 0?n:Y7(n,o);return{...Q7.combine(r,s),...i===void 0?{}:{ordered:i}}}function lq(e){let t=[],n=[];function r(o){if(o.annotations?.arbitrary&&n.push(o.annotations.arbitrary),o._tag!=="Filter")for(let s of o.checks)r(s);else t.push(o)}return e?.forEach(r),{filters:t,arbitraries:n}}function e9(e){let t=e.map(({constraint:n})=>n).filter(qn);return n=>{let r=t.reduce((o,s)=>X7(o,s),n.constraint);return{...n,constraint:r}}}function kh(e){return{...e,constraint:void 0}}function dq(e,t,n){if(t===void 0||t.minLength===void 0&&t.maxLength===void 0)return;if(t.minLength!==void 0&&e.indexSignatures.length===0&&t.minLength>e.propertySignatures.length)throw Wa("object property constraints");let r={};if(t.minLength!==void 0&&(r.minLength=Math.max(0,t.minLength-n)),t.maxLength!==void 0&&(r.maxLength=t.maxLength-n,r.maxLength<0))throw Wa("object property constraints");return xq(r,"object property"),r}function t9(e,t,n,r,o,s){let i=r.length;if(s.maxLength!==void 0&&s.maxLength<i)throw Wa("object property constraints");let a=s.minLength===void 0?0:Math.max(0,s.minLength-i),c=s.maxLength===void 0?o.length:Math.min(o.length,s.maxLength-i);if(a>c)throw Wa("object property constraints");let u=e.record(t,{requiredKeys:[...r,...o]}),f=e.shuffledSubarray([...o],{minLength:a,maxLength:c});return e.tuple(u,f).map(([l,p])=>{let h=new Set([...r,...p]),g={};for(let x of n)h.has(x)&&K(g,x,l[x]);return g})}function Sq(e,t,n,r){let o={};if(e?.minimum!==void 0&&(o.min=t(e.minimum,e.exclusiveMinimum===!0)),e?.maximum!==void 0&&(o.max=n(e.maximum,e.exclusiveMaximum===!0)),o.min!==void 0&&o.max!==void 0&&o.min>o.max)throw Wa(r);return o}function n9(e){return Sq(e,(t,n)=>n?Math.floor(t)+1:Math.ceil(t),(t,n)=>n?Math.ceil(t)-1:Math.floor(t),"integer constraints")}function r9(e,t){let n={...e?.noInfinity?{noDefaultInfinity:!0}:{},...e?.noNaN?{noNaN:!0}:{},...t?.minimum!==void 0?{min:t.minimum}:{},...t?.exclusiveMinimum!==void 0?{minExcluded:t.exclusiveMinimum}:{},...t?.maximum!==void 0?{max:t.maximum}:{},...t?.exclusiveMaximum!==void 0?{maxExcluded:t.exclusiveMaximum}:{}};if(n.min!==void 0&&n.max!==void 0&&(n.min>n.max||n.min===n.max&&(n.minExcluded||n.maxExcluded)))throw Wa("number constraints");return n}function o9(e){return Sq(e,(t,n)=>n?t+BigInt(1):t,(t,n)=>n?t-BigInt(1):t,"the ordered bigint constraints")}function Rd(e,t){let n=(r,o,s=iq)=>e(r,o,s);return n.terminal=(r,o,s=iq)=>t(r,o,s),n}function ls(e){return Rd(e,e)}function pq(e,t){let n=sq.get(t)??e.createDepthIdentifier();return sq.set(t,n),{maxDepth:2,depthIdentifier:n}}function mq(e,t){return t.length===0?void 0:t.length===1?t[0]:e.oneof(...t)}var s9={noInfinity:!0,noNaN:!0};function i9(e){return{...e,constraint:s9}}function a9(e,t,n,r){let o=r===void 0?[]:[{arbitrary:r,weight:1}];for(let{candidate:s}of n){if(!s)continue;let i=s.make(e,t);if(i===void 0)continue;let a=s.weight??1;if(!globalThis.Number.isInteger(a)||a<=0)throw Wa("a candidate with an invalid weight");o.push({arbitrary:i,weight:a})}return o.length===0?void 0:o.length===1?o[0].arbitrary:e.oneof(...o)}function hq(e,t,n,r,o){let s=a9(n,r,t.arbitraries,o);return s===void 0?void 0:V7(e,t.filters,s)}function c9(e,t){if(!(typeof e=="object"&&e!==null&&"arbitrary"in e))return{arbitrary:e,terminal:t?void 0:e};let n="terminal"in e?e.terminal:t?void 0:e.arbitrary;return{arbitrary:e.arbitrary,terminal:n}}function u9(e,t,n,r,o){return e.map(s=>({arbitrary:o?t.constant(null).chain(()=>s(t,n,r)):s(t,n,r),terminal:s.terminal(t,n,r)}))}function gq(e,t,n,r){let o=e9(t.arbitraries);return Rd((s,i,a)=>{let c=o(i);return hq(e,t,s,c,n(s,i,c,a))},(s,i,a)=>{let c=o(i);return hq(e,t,s,c,r(s,i,c,a))})}var bq=bn(e=>ds(e,[]));function ds(e,t){let n=Hs(e)?.toArbitrary;if(n){let r=Pa(e)?e.typeParameters.map(i=>ds(i,t)):[],o=lq(e.checks),s=i=>(a,c,u,f)=>c9(n(u9(r,a,kh(c),f,i))(a,u),r.length>0)[i?"terminal":"arbitrary"];return gq(e,o,s(!1),s(!0))}if(e.checks){let r=lq(e.checks),o=ds(Zm(e,void 0),t);return gq(e,r,(s,i,a,c)=>o(s,a,c),(s,i,a,c)=>o.terminal(s,a,c))}return f9(e,t)}function f9(e,t){switch(e._tag){case"Never":case"Declaration":throw ji(`Unsupported AST ${e._tag}`,t);case"Null":return ls(n=>n.constant(null));case"Void":case"Undefined":return ls(n=>n.constant(void 0));case"Unknown":case"Any":return ls(n=>n.anything());case"String":return ls((n,r)=>{let o=r.constraint,s=o?.patterns;return s?n.oneof(...s.map(i=>n.stringMatching(new RegExp(i)))):n.string(yq(o))});case"Number":return ls((n,r)=>{let o=r.constraint,s=o?.ordered?.order===wo?o.ordered:void 0;return o?.integer?n.integer(n9(s)):n.float(r9(o,s))});case"Boolean":return ls(n=>n.boolean());case"BigInt":return ls((n,r)=>{let o=r.constraint?.ordered?.order===Wo?r.constraint.ordered:void 0;return n.bigInt(o9(o))});case"Symbol":return ls(n=>n.string().map(Symbol.for));case"Literal":return ls(n=>n.constant(e.literal));case"UniqueSymbol":return ls(n=>n.constant(e.symbol));case"ObjectKeyword":return ls(n=>n.oneof(n.object(),n.array(n.anything())));case"Enum":return ds(hd(e),t);case"TemplateLiteral":{let n=e.parts.map((r,o)=>ds(Nn(r),[...t,o]));return ls((r,o,s)=>r.tuple(...n.map(i=>i(r,i9(o),s))).map(i=>i.map(a=>globalThis.String(a)).join("")))}case"Arrays":{let n=e.elements.map((i,a)=>({ast:i,arbitrary:ds(i,[...t,a])})),r=e.elements.length,o=e.rest.map((i,a)=>({ast:i,arbitrary:ds(i,[...t,r+a])})),s=(i,a,c)=>{let u=kh(a),f=[],l=[],p=0;for(let E of n){let y=E.arbitrary.terminal(i,u,c);if(nn(E.ast)){l.push(y);continue}if(y===void 0)return;p++,f.push(y.map(L))}let h=a.constraint?.minLength??0,x=et(o)&&h>p+l.length?l.length:Math.max(0,h-p),S=0;for(let E of l){if(S>=x||E===void 0){f.push(i.constant(D()));continue}S++,p++,f.push(E.map(L))}if(S<x)return;let w=i.tuple(...f).map(Iw);if(et(o)){let[E,...y]=o,v=e.elements.length===0?a:u,b=Math.max(0,h-p-y.length),T=b===0?void 0:E.arbitrary.terminal(i,u,c);if(b>0&&T===void 0)return;let R=b===0?i.constant([]):cq(i,{...v,constraint:{...v.constraint,minLength:b}},T,!0);if(w=Nb(i,w,r,R),y.length>0){let C=[];for(let B of y){let F=B.arbitrary.terminal(i,u,c);if(F===void 0)return;C.push(F)}let P=i.tuple(...C);w=Nb(i,w,r,P)}}return w};return Rd((i,a,c)=>{let u=kh(a),f=n.map(({ast:p,arbitrary:h})=>{let g=h(i,u,c);return nn(p)?g.chain(x=>i.boolean().map(S=>S?L(x):D())):g.map(L)}),l=i.tuple(...f).map(p=>Iw(iM(p,_e)));if(et(o)){let[p,...h]=o.map(({arbitrary:x})=>x(i,u,c)),g=cq(i,e.elements.length===0?a:u,p);if(l=Nb(i,l,r,g),h.length>0){let x=i.tuple(...h);l=Nb(i,l,r,x)}}if(a.recursion){let p=s(i,a,c);if(p!==void 0)return i.oneof(a.recursion,p,l)}return l},s)}case"Objects":{let n=e.propertySignatures.map(s=>({ps:s,arbitrary:ds(s.type,[...t,s.name])})),r=e.indexSignatures.map(s=>({is:s,parameter:ds(s.parameter,t),type:ds(s.type,t)}));return Rd((s,i,a)=>{let c=kh(i),u={},f=[],l=[],p=[];for(let{ps:S,arbitrary:w}of n){let E=S.name;f.push(E),nn(S.type)?p.push(E):l.push(E),K(u,E,w(s,c,a))}let h=i.constraint;if(p.length>0&&r.length===0&&h!==void 0&&(h.minLength!==void 0||h.maxLength!==void 0))return t9(s,u,f,l,p,h);let g=s.record(u,{requiredKeys:l}),x=dq(e,i.constraint,l.length);for(let{parameter:S,type:w}of r){let E=s.tuple(S(s,c,a),w(s,c,a)),y=NA(s,E,x,aq);g=uq(g,y)}return g},(s,i,a)=>{let c=kh(i),u={},f=[],l=[];for(let{ps:S,arbitrary:w}of n){let E=S.name,y=w.terminal(s,c,a);if(nn(S.type)){y!==void 0&&l.push([E,y]);continue}if(y===void 0)return;f.push(E),K(u,E,y)}let p=Math.max(0,(i.constraint?.minLength??0)-f.length);for(let[S,w]of l){if(p===0)break;p--,f.push(S),K(u,S,w)}if(p>0&&e.indexSignatures.length===0)return;let h=s.record(u,{requiredKeys:f}),g=dq(e,i.constraint,f.length),x=g?.minLength??0;for(let{parameter:S,type:w}of r){let E;if(x===0)E=s.constant([]);else{let y=S.terminal(s,c,a),v=w.terminal(s,c,a);if(y===void 0||v===void 0)return;E=NA(s,s.tuple(y,v),{...g,maxLength:x},aq)}h=uq(h,E)}return h})}case"Union":{let n=e.types.map(o=>ds(o,t)),r=(o,s,i)=>mq(o,n.map(a=>a.terminal(o,s,i)).filter(qn));return Rd((o,s,i)=>{let a=n.map(u=>u(o,s,i));if(s.recursion){let u=r(o,s,i);if(u!==void 0)return o.oneof(s.recursion,u,...a)}let c=mq(o,a);if(c===void 0)throw Wa("a union with no members");return c},r)}case"Suspend":{let n=oq.get(e);if(n)return n;let r=Dc(()=>ds(e.thunk(),t)),o=Rd((s,i,a)=>{let c=pq(s,e),u={...i,recursion:c},f=a.includes(e)?a:[...a,e],l=r().terminal(s,u,f);if(l===void 0)throw ji("Unable to derive an arbitrary for a recursive schema without a finite generation path",t);return s.oneof(c,l,s.constant(null).chain(()=>r()(s,u,f)))},(s,i,a)=>{if(a.includes(e))return;let c=pq(s,e);return r().terminal(s,{...i,recursion:c},[...a,e])});return oq.set(e,o),o}}}var Eq=bn(e=>Bc(e,[]));function Bc(e,t){let n=Hs(e)?.toEquivalence;if(n)return n(Pa(e)?e.typeParameters.map(r=>Bc(r,t)):[]);switch(e._tag){case"Never":return mu();case"Declaration":case"Null":case"Undefined":case"Void":case"Unknown":case"Any":case"String":case"Number":case"Boolean":case"BigInt":case"Symbol":case"Literal":case"UniqueSymbol":case"ObjectKeyword":case"Enum":case"TemplateLiteral":return ne;case"Arrays":{let r=e.elements.map((i,a)=>Bc(i,[...t,a])),o=e.elements.length,s=e.rest.map((i,a)=>Bc(i,[...t,o+a]));return pn((i,a)=>{if(!Array.isArray(i)||!Array.isArray(a))return!1;let c=i.length;if(c!==a.length)return!1;let u=0;for(;u<Math.min(c,e.elements.length);u++)if(!r[u](i[u],a[u]))return!1;if(s.length>0){let[f,...l]=s;for(;u<c-l.length;u++)if(!f(i[u],a[u]))return!1;for(let p=0;p<l.length;p++)if(!l[p](i[u+p],a[u+p]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return ne;let r=e.propertySignatures.map(s=>Bc(s.type,[...t,s.name])),o=e.indexSignatures.map(s=>Bc(s.type,t));return pn((s,i)=>{if(!Wt(s)||!Wt(i))return!1;for(let a=0;a<r.length;a++){let c=e.propertySignatures[a],u=c.name,f=Object.hasOwn(s,u),l=Object.hasOwn(i,u);if(nn(c.type)&&f!==l||f&&l&&!r[a](s[u],i[u]))return!1}for(let a=0;a<o.length;a++){let c=e.indexSignatures[a],u=Ui(s,c.parameter),f=Ui(i,c.parameter);if(u.length!==f.length)return!1;for(let l=0;l<u.length;l++){let p=u[l];if(!Object.hasOwn(i,p)||!o[a](s[p],i[p]))return!1}}return!0})}case"Union":{let r=hn(e).types,o=new Map(r.map((s,i)=>[s,[kd(s),Bc(e.types[i],t)]]));return pn((s,i)=>{let a=ld(s,r);for(let c=0;c<a.length;c++){let[u,f]=o.get(a[c]);if(u(s)&&u(i))return f(s,i)}return!1})}case"Suspend":{let r=Dc(()=>Bc(e.thunk(),t));return pn((o,s)=>r()(o,s))}}}function _f(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Cd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}var m9="http://json-schema.org/draft-07/schema#",wq="https://json-schema.org/draft/2020-12/schema";function vq(e,t){return e===t||e===(t.endsWith("#")?t.slice(0,-1):`${t}#`)}function kq(e){return{dialect:"draft-07",...E9(e,_9)}}function h9(e,t){return n(e,!1,!0);function n(r,o,s=!1){if(!Wt(r))return r;let i=o||!s&&Cq(r.$id),a={};for(let c of Object.keys(r)){let u=r[c],f=u;switch(c){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":f=LA(u,l=>n(l,i))??u;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":f=Array.isArray(u)?u.map(l=>n(l,i)):u;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":f=n(u,i)}K(a,c,f)}return t(a,i),a}}function Aq(e,t){return h9(e,n=>{g9(n,t)})}function g9(e,t){typeof e.$ref=="string"&&K(e,"$ref",t(e.$ref,"$ref")),typeof e.$dynamicRef=="string"&&K(e,"$dynamicRef",t(e.$dynamicRef,"$dynamicRef"))}function LA(e,t){if(!Wt(e))return;let n={};for(let r of Object.keys(e))K(n,r,t(e[r],r));return n}function x9(e,t,n){let r=new Map,o=[],s=DA;function i(p,h=[],g=[]){if(h.length===0&&t?.trackIds){let x=Wt(p)?f(p):void 0;s=Tq(x,DA)??DA}return u(p,h,g,{sourceRoot:[],targetRoot:[],uri:s})}function a(){for(let[p,h,g]of o){let x=h,S=Rq(h,g);if(S!==void 0){let w=y9(S.hash);if(S.hash="",w!==void 0){let E=r.get(Iq(S.href,w));E!==void 0&&(x=S9(h,E))}}K(p,"$ref",x)}}let c=n(i);return a(),c;function u(p,h,g,x){if(typeof p=="boolean")return l(h,g,x),t?.booleanAdapter?.(p)??p;if(!Wt(p))return p;let S=x,w=f(p);if(h.length>0&&t?.trackIds&&Cq(w)){let v=Tq(w,x.uri);v!==void 0&&(S={parent:x,sourceRoot:h,targetRoot:g,uri:v})}l(h,g,S);let E=S.uri,y={isDocumentRoot:h.length===0,schema(v,b,T=b){return u(v,[...h,b],[...g,T],S)},schemaAt(v,b,T){return u(v,[...h,...b],[...g,...T],S)},schemaArray(v,b,T=b){return Array.isArray(v)?v.map((R,C)=>u(R,[...h,b,String(C)],[...g,T,String(C)],S)):v},schemaMap(v,b,T=b){return Wt(v)?LA(v,(R,C)=>u(R,[...h,b,C],[...g,T,C],S)):v},reference(v,b){typeof b=="string"?o.push([v,b,E]):K(v,"$ref",b)}};return e(p,y)}function f(p){return t?.ignoreRefSiblings===!0&&typeof p.$ref=="string"?void 0:p.$id}function l(p,h,g){g.parent!==void 0&&l(p,h,g.parent),r.set(Iq(g.uri,p.slice(g.sourceRoot.length)),h.slice(g.targetRoot.length))}}var DA="https://effect.invalid/.json-schema/";function Rq(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function Tq(e,t){if(typeof e!="string")return;let n=Rq(e,t);if(n!==void 0)return n.hash="",n.href}function y9(e){if(e.length===0)return[];let t;try{t=decodeURIComponent(e.slice(1))}catch{return}if(t.startsWith("/"))return/~(?:[^01]|$)/.test(t)?void 0:t.slice(1).split("/").map(Cd)}function S9(e,t){let n=e.indexOf("#");return n===-1&&t.length===0?e:`${n===-1?e:e.slice(0,n)}${b9(t)}`}function b9(e){return e.length===0?"#":`#/${e.map(t=>encodeURI(_f(t)).replace(/#/g,"%23")).join("/")}`}function Iq(e,t){return`${e}\0${JSON.stringify(t)}`}function Cq(e){return typeof e=="string"&&e.length>0&&e[0]!=="#"}function E9(e,t,n){return x9(t,{...n,trackIds:!0},r=>({schema:r(e.schema),definitions:LA(e.definitions,(o,s)=>r(o,["$defs",s],["definitions",s]))}))}var w9=new Set(["properties","patternProperties"]),v9=new Set(["allOf","anyOf","oneOf"]),T9=new Set(["not","additionalProperties","propertyNames","contains","if","then","else","contentSchema"]);function I9(e,t,n,r,o,s=w9){let i;if(s.has(t))i=r.schemaMap(n,t);else if(v9.has(t))i=r.schemaArray(n,t);else if(o.has(t))i=r.schema(n,t);else return!1;return K(e,t,i),!0}var Oq=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"],Vhe=[...Oq,"deprecated"],Jhe=[...Oq,"$comment","$id","$schema","const","contains","contentEncoding","contentMediaType","else","examples","if","patternProperties","propertyNames","then"],k9=/^[A-Za-z_][-A-Za-z0-9._]*$/,A9=/^[A-Za-z][-A-Za-z0-9._:]*$/;function Mf(e,t,n){throw new Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${n}`)}function R9(e,t,n,r){for(let o of t)Object.hasOwn(e,o)&&Mf(o,n,`it is not active in ${r} but would become active in the target`)}var C9=["additionalItems","definitions","dependencies"];function O9(e,t,n,r,o){n.isDocumentRoot?K(e,"$schema",vq(t,wq)?r:t):vq(t,wq)||Mf("$schema",o,"an embedded resource cannot declare a different dialect")}function _9(e,t){R9(e,C9,"Draft-07","Draft 2020-12");let n={},r,o,s;for(let i of Object.keys(e)){let a=e[i];if(!I9(n,i,a,t,T9))switch(i){case"$ref":r=a;break;case"$schema":O9(n,a,t,m9,"Draft-07");break;case"$id":case"$anchor":break;case"$defs":K(n,"definitions",t.schemaMap(a,i,"definitions"));break;case"prefixItems":o=a;break;case"items":s=a;break;case"dependentRequired":case"dependentSchemas":case"minContains":case"maxContains":break;case"$dynamicRef":case"$dynamicAnchor":case"$vocabulary":case"unevaluatedProperties":case"unevaluatedItems":Mf(i,"Draft-07","the target dialect has no equivalent");case"required":if(Array.isArray(a)&&a.length===0)break;K(n,i,a);break;default:K(n,i,a)}}if(M9(n,o,s,t),Object.hasOwn(e,"contains")){let i=e.minContains,a=e.maxContains;(i!==void 0&&i!==1||a!==void 0)&&Mf("minContains/maxContains","Draft-07","contains cardinality cannot be represented"),Object.hasOwn(e,"minContains")&&K(n,"minContains",i)}else Object.hasOwn(e,"minContains")&&K(n,"minContains",e.minContains),Object.hasOwn(e,"maxContains")&&K(n,"maxContains",e.maxContains);return F9(e,n,t,"draft-07"),N9(e,n,"$id","Draft-07"),P9(n,r,t),n}function M9(e,t,n,r){if(t===void 0){n!==void 0&&K(e,"items",r.schema(n,"items"));return}K(e,"items",r.schemaArray(t,"prefixItems","items")),n!==void 0&&K(e,"additionalItems",r.schema(n,"items","additionalItems"))}function P9(e,t,n){if(t!==void 0)if(typeof t=="string"&&Object.keys(e).length>0){let r={};n.reference(r,t),U9(e,r)}else n.reference(e,t)}function F9(e,t,n,r){let o=Wt(e.dependentRequired)?e.dependentRequired:void 0,s=Wt(e.dependentSchemas)?e.dependentSchemas:void 0;if(o===void 0&&s===void 0)return;let i={},a=new Set([...Object.keys(o??{}),...Object.keys(s??{})]);for(let c of a){let u=o?.[c],f=s?.[c],l=r==="draft-04"&&Array.isArray(u)&&u.length===0;f===void 0?l||K(i,c,u):u===void 0||l?K(i,c,n.schemaAt(f,["dependentSchemas",c],["dependencies",c])):K(i,c,{allOf:[n.schemaAt(f,["dependentSchemas",c],["dependencies",c,"allOf","0"]),{required:u}]})}Object.keys(i).length>0&&K(t,"dependencies",i)}function U9(e,t){Array.isArray(e.allOf)?e.allOf.push(t):K(e,"allOf",[t])}function N9(e,t,n,r){let o=e.$id,s=e.$anchor;if(s===void 0){o!==void 0&&K(t,n,o);return}(typeof s!="string"||!k9.test(s))&&Mf("$anchor",r,"the anchor is not valid"),A9.test(s)||Mf("$anchor",r,"the anchor cannot be represented as a plain-name fragment identifier"),o===void 0?K(t,n,`#${s}`):Mf("$anchor",r,"it cannot be combined with the schema $id")}var Ghe=globalThis.RegExp;var Od=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");var D9=new Set([...vN,of,...bN]);function Ah(e,t){if(e===void 0)return;let n={},r=e.title;typeof r=="string"&&(n.title=r);let o=e.description,s=e.expected;typeof o=="string"?n.description=o:t?.generateDescriptions===!0&&typeof s=="string"&&(n.description=s);let i=e.default;yf(i)&&(n.default=i);let a=e.examples;Array.isArray(a)&&yf(a)&&(n.examples=a);let c=e.readOnly;typeof c=="boolean"&&(n.readOnly=c);let u=e.writeOnly;typeof u=="boolean"&&(n.writeOnly=u);let f=e.format;typeof f=="string"&&(n.format=f);let l=e.contentEncoding;typeof l=="string"&&(n.contentEncoding=l);let p=e.contentMediaType;typeof p=="string"&&(n.contentMediaType=p);let h=e.contentSchema;if(yf(h)&&(n.contentSchema=h),t?.includeAnnotationKey!==void 0)for(let[g,x]of Object.entries(e))D9.has(g)||!t.includeAnnotationKey(g)||yf(x)&&K(n,g,x);return Object.keys(n).length===0?void 0:n}function Pq(e){let t=e.type==="number"||e.type==="integer"?e.type:void 0,n=e;if(t!==void 0&&(n={...e},delete n.type),Array.isArray(n.allOf)){let r=[],o=!1;for(let s of n.allOf){let i=Pq(s);i.type!==void 0&&(o=!0,(t===void 0||i.type==="integer")&&(t=i.type)),Object.keys(i.schema).length>0&&r.push(i.schema)}if(o){let{allOf:s,...i}=n;n=r.length===0?i:{...i,allOf:r}}}return{type:t,schema:n}}function L9(e){return Array.isArray(e.anyOf)&&e.anyOf.length===4&&e.anyOf[0]?.type==="number"&&e.anyOf.slice(1).every(t=>t.type==="string")}var Fq="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";function jA(e,t){return Object.keys(e).every(n=>t.includes(`|${n}|`))}function Mq(e,t){return typeof e.$ref!="string"&&t.every(n=>!Object.hasOwn(e,n))}var BA="|title|description|default|examples|readOnly|writeOnly|",q9=Fq+BA;function Rh(e,t,n){if(Object.keys(e).length===0)return t;let r=Object.keys(t);if(r.length===0)return e;let o=e.type==="number"||e.type==="integer"?e.type:void 0,s=L9(e);if(o!==void 0||s){let a=Pq(t);if(a.type!==void 0){let c=o==="integer"||a.type==="integer"?"integer":"number",u={...e,type:c};s&&delete u.anyOf;let f=Object.keys(a.schema);return f.length===0?u:jA(a.schema,BA)&&Mq(u,f)?{...u,...a.schema}:Rh(u,a.schema,n)}}if(n&&Mq(e,r))return{...e,...t};let i=Array.isArray(t.allOf)&&r.length===1?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...i]}:typeof e.$ref=="string"?{allOf:[e,...i]}:{...e,allOf:i}}function j9(e,t,n,r){let o=new Map,s=new WeakMap,i=new Map,a=!1,c=Object.keys(n);for(let y of c)l(y,["references",y]);let u=Is(e,(y,v)=>p(S(y,t[v]))),f={};for(let y of c){let v=o.get(y);typeof v!="string"&&K(f,y,p(v))}return{dialect:"draft-2020-12",schemas:u,definitions:f};function l(y,v){let b=o.get(y);if(b!==void 0)return typeof b=="string"?b:y;if(!Object.hasOwn(n,y))throw ji(`Invalid reference ${y}`,[...v,"$ref"]);o.set(y,null);let T=n[y],R=S(T,["references",y]),C=h(T);if(C!==void 0){let P=i.get(C),B=P?.find(F=>ne(o.get(F),R));if(B===void 0)P===void 0?i.set(C,[y]):P.push(y);else return a=!0,o.set(y,B),B}return o.set(y,R),y}function p(y){return a?Aq(y,v=>v.replace(/^#\/\$defs\/([^/]*)/,(b,T)=>{let R=o.get(Cd(T));return typeof R=="string"?`#/$defs/${_f(R)}`:b})):y}function h(y){if(y._tag==="Reference")return;let v=y.checks.length===0?y.annotations:y.checks[y.checks.length-1].annotations;return typeof v?.identifier!="string"&&typeof v?.[of]=="string"?v[of]:void 0}function g(y,v){return y?.schemas?.map((b,T)=>S(b,[...v,"schemas",T]))??[]}function x(y,v,b){let T=y.annotations,R=T?.toJsonSchema;if(R!==void 0){let F=g(y.representation,[...b,"representation"]),Z=R({type:v,schemas:F}),z=Ah(T,r),A=z===void 0?Z:{...Z,...z},H=z===void 0?Fq:q9;return y._tag==="Filter"&&jA(A,H)&&(z===void 0||jA(z,BA))?[A,!0]:[A]}if(y._tag==="Filter")return;let C=y.checks.map((F,Z)=>x(F,v,[...b,"checks",Z])).filter(F=>F!==void 0);if(C.length===0)return;let P=Ah(T,r),B=C.map(([F])=>F);return[P===void 0?{allOf:B}:{allOf:B,...P}]}function S(y,v){if(y._tag==="Reference"){let C=l(y.$ref,v);return{$ref:`#/$defs/${_f(C)}`}}let b=s.get(y);if(b!==void 0)return b;let T=w(y,v),R=Ah(y.annotations,r);R!==void 0&&(T={...T,...R});for(let C=0;C<y.checks.length;C++){let P=typeof T.type=="string"&&B9(T.type)?T.type:void 0,B=x(y.checks[C],P,[...v,"checks",C]);B!==void 0&&(T=Rh(T,...B))}return s.set(y,T),T}function w(y,v){switch(y._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":case"UniqueSymbol":return{type:"string",allOf:[{pattern:"^Symbol\\((.*)\\)$"}]};case"Declaration":return{};case"Suspend":return S(y.thunk,[...v,"thunk"]);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN"]},{type:"string",enum:["Infinity"]},{type:"string",enum:["-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let b=y.literal;return typeof b=="bigint"?{type:"string",enum:[globalThis.String(b)]}:{type:typeof b,enum:[b]}}case"Enum":{let b=y.enums.map(([T,R])=>typeof R=="number"&&!globalThis.Number.isFinite(R)?{type:"string",enum:[globalThis.String(R)],title:T}:{type:typeof R,enum:[R],title:T});return b.length===0?{not:{}}:{anyOf:b}}case"TemplateLiteral":return{type:"string",pattern:`^${y.parts.map(Lb).join("")}$`};case"Arrays":{if(y.rest.length>1)throw ji("Invalid schema representation document",[...v,"rest"]);let b={type:"array"},T=y.elements.length,R=y.elements.map((C,P)=>{C.isOptional&&T--;let B=S(C.type,[...v,"elements",P,"type"]),F=Ah(C.annotations,r);return F===void 0?B:Rh(B,F)});if(R.length>0?(b.prefixItems=R,b.maxItems=y.elements.length,T>0&&(b.minItems=T)):b.items=!1,y.rest.length===1){delete b.maxItems;let C=S(y.rest[0],[...v,"rest",0]);Object.keys(C).length>0?b.items=C:delete b.items}return b}case"Objects":{if(y.propertySignatures.length===0&&y.indexSignatures.length===0)return{anyOf:[{type:"object"},{type:"array"}]};let b={type:"object"},T={},R=[];for(let F=0;F<y.propertySignatures.length;F++){let Z=y.propertySignatures[F];if(typeof Z.name!="string")throw ji("Invalid schema representation document",[...v,"propertySignatures",F,"name"]);let z=Z.name,A=S(Z.type,[...v,"propertySignatures",F,"type"]),H=Ah(Z.annotations,r);K(T,z,H===void 0?A:Rh(A,H)),Z.isOptional||R.push(z)}y.propertySignatures.length>0&&(b.properties=T),R.length>0&&(b.required=R);let C={},P=[];for(let F=0;F<y.indexSignatures.length;F++){let Z=y.indexSignatures[F],z=S(Z.type,[...v,"indexSignatures",F,"type"]);Object.keys(z).length===1&&"not"in z&&(z=!1);let A=E(Z.parameter,[...v,"indexSignatures",F,"parameter"],new Set);if(A.length===0)P.push(z);else for(let H of A){let U=C[H];K(C,H,U===void 0?z:U===!1||z===!1?!1:Rh(U,z))}}let B=Object.keys(C).length>0;return B&&(b.patternProperties=C),y.indexSignatures.length===0?b.additionalProperties=r?.additionalProperties??!1:P.length===1&&y.propertySignatures.length===0&&!B?b.additionalProperties=P[0]:P.length>0&&(b.allOf=P.map(F=>({type:"object",additionalProperties:F}))),typeof b.additionalProperties=="object"&&b.additionalProperties!==null&&Object.keys(b.additionalProperties).length===0&&delete b.additionalProperties,b}case"Union":{let b=y.types.map((T,R)=>S(T,[...v,"types",R]));if(b.length===0)return{not:{}};if(y.mode==="anyOf"&&b.length>1){let T=$9(b);if(T!==void 0)return T}return y.mode==="anyOf"?{anyOf:b}:{oneOf:b}}}}function E(y,v,b){switch(y._tag){case"Reference":{if(!Object.hasOwn(n,y.$ref))throw ji(`Invalid reference ${y.$ref}`,[...v,"$ref"]);if(l(y.$ref,v),b.has(y.$ref))return[];let T=new Set(b).add(y.$ref);return E(n[y.$ref],["references",y.$ref],T)}case"String":return Uq(S(y,v));case"TemplateLiteral":return[`^${y.parts.map(Lb).join("")}$`];case"Union":return y.types.flatMap((T,R)=>E(T,[...v,"types",R],b));default:throw ji("Invalid schema representation document",v)}}}function B9(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}function $9(e){let t,n=[];for(let r of e){if(Object.keys(r).length!==2||r.type===void 0||!Array.isArray(r.enum)||r.enum.length===0)return;if(t===void 0)t=r.type;else if(r.type!==t)return;n.push(...r.enum)}return{type:t,enum:n}}function Uq(e){let t=[];typeof e.pattern=="string"&&t.push(e.pattern);for(let n of["allOf","anyOf","oneOf"]){let r=e[n];if(Array.isArray(r))for(let o of r)typeof o=="object"&&o!==null&&!Array.isArray(o)&&t.push(...Uq(o))}return t}function Lb(e){switch(e._tag){case"Literal":return Od(globalThis.String(e.literal));case"String":return hk;case"Number":return zm;case"TemplateLiteral":return e.parts.map(Lb).join("");case"Union":return e.types.map(Lb).join("|");default:throw ji("Invalid schema representation document",[])}}function Nq(e,t){let n=j9([e.representation],[["representation"]],e.references,t);return{dialect:n.dialect,schema:n.schemas[0],definitions:n.definitions}}var z9=({identifier:e})=>e;function ri(e){return e===void 0?void 0:{annotations:e}}function $A(e,t){let{references:n,representations:r}=W9([e],t);return{representation:r[0],references:n}}function W9(e,t){let n={},r=new Map,o=new Set,s=new Map,i=new Set;for(let b of e)h(b);let a=t?.referencePolicy??z9;for(let b of s.values())for(let T of b.values()){let R=a({ast:T.ast,occurrences:T.occurrences,identifier:T.identifier});if(R!==void 0){let C=R===T.identifier||!R.endsWith("_")?"_":"";T.reference=u(R,T,C)}else T.isRecursive&&(T.reference=u(`${T.ast._tag}_`,T,""))}return{representations:Is(e,b=>x(b)),references:n};function u(b,T,R="_"){let C=b,P=0;for(;r.has(C);){if(r.get(C)===T)return C;C=`${b}${R}${++P}`}return r.set(C,T),C}function f(b,T,R){let C=T.fallback;return C!==void 0?dI(b)===C?b:Mo(b,{[of]:C}):R===T.identifier?b:Mo(b,{identifier:R})}function l(b,T){if(!Object.hasOwn(n,b)&&!o.has(b)){o.add(b);let R=S(T);o.delete(b),K(n,b,R)}return{_tag:"Reference",$ref:b}}function p(b){let T=md(b),R=AS(T),C=sf(T),P=C===void 0?(T!==b?sf(b):void 0)??dI(T):void 0;P!==void 0&&(C=`${P}Encoded`);let B=s.get(R);B===void 0&&(B=new Map,s.set(R,B));let F=B.get(C);return F===void 0&&(F={ast:R,identifier:C,fallback:P,occurrences:0,isRecursive:!1,reference:void 0},B.set(C,F)),F}function h(b){let T=p(b),R=T.ast;if(T.occurrences++,i.has(T)){T.isRecursive=!0;return}if(!(T.occurrences>1)){switch(i.add(T),g(R.checks),R._tag){case"Declaration":case"Arrays":case"Objects":case"Union":R.recur(C=>(h(C),C));break;case"TemplateLiteral":R.parts.forEach(h);break;case"Suspend":h(R.thunk());break}i.delete(T)}}function g(b){b?.forEach(T=>{T.annotations?.representation?.schemas?.forEach(R=>h(hn(R))),T._tag==="FilterGroup"&&g(T.checks)})}function x(b){let T=p(b),R=T.ast,C=T.reference;if(C!==void 0){let P=T.identifier===void 0?R:f(R,T,C);return l(C,P)}return S(R)}function S(b){let T=w(b.checks);switch(b._tag){case"Declaration":return{_tag:"Declaration",typeParameters:b.typeParameters.map(R=>x(R)),checks:T,...y(b.annotations)};case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"String":case"Boolean":case"Number":case"BigInt":case"Symbol":case"ObjectKeyword":return{_tag:b._tag,checks:T,...ri(b.annotations)};case"Literal":return{_tag:"Literal",literal:b.literal,checks:T,...ri(b.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:b.symbol,checks:T,...ri(b.annotations)};case"Enum":return{_tag:"Enum",enums:b.enums,checks:T,...ri(b.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:b.parts.map(R=>x(R)),checks:T,...ri(b.annotations)};case"Arrays":return{_tag:"Arrays",elements:b.elements.map(R=>{let C=md(R),P=C.context?.annotations;return{isOptional:nn(C),type:x(R),...ri(P)}}),rest:b.rest.map(R=>x(R)),checks:T,...ri(b.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:b.propertySignatures.map(R=>{let C=md(R.type),P=C.context?.annotations;return{name:R.name,type:x(R.type),isOptional:nn(C),isMutable:dk(C),...ri(P)}}),indexSignatures:b.indexSignatures.map(R=>({parameter:x(R.parameter),type:x(R.type)})),checks:T,...ri(b.annotations)};case"Union":return{_tag:"Union",types:b.types.map(R=>x(R)),mode:b.mode,checks:T,...ri(b.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:x(b.thunk()),...ri(b.annotations)}}}function w(b){return b?.map(E)??[]}function E(b){switch(b._tag){case"Filter":return{_tag:"Filter",aborted:b.aborted,...v(b.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:Is(b.checks,E),...v(b.annotations)}}}function y(b){if(b===void 0)return;let{representation:T,...R}=b;return{...T===void 0?void 0:{representation:T},...Object.keys(R).length===0?void 0:{annotations:R}}}function v(b){if(b===void 0)return;let{representation:T,...R}=b,C=T===void 0?void 0:T.schemas===void 0?T:{...T,schemas:T.schemas.map(P=>x(hn(P)))};return{...C===void 0?void 0:{representation:C},...Object.keys(R).length===0?void 0:{annotations:R}}}}function Lq(e,t){let n=[];return HA(e,t,"",n),n}function HA(e,t,n,r){if(!Object.is(e,t)){if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,s=t.length,i=Math.min(o,s);for(let a=0;a<i;a++)HA(e[a],t[a],`${n}/${a}`,r);for(let a=o-1;a>=s;a--)r.push({op:"remove",path:`${n}/${a}`});for(let a=o;a<s;a++)r.push({op:"add",path:`${n}/${a}`,value:t[a]});return}if(qb(e)&&qb(t)){let o=Object.keys(e),s=Object.keys(t),i=Array.from(new Set([...o,...s])).sort();for(let a of i){let c=`${n}/${_f(a)}`,u=Object.hasOwn(e,a),f=Object.hasOwn(t,a);u&&f?HA(e[a],t[a],c,r):!u&&f?r.push({op:"add",path:c,value:t[a]}):r.push({op:"remove",path:c})}return}r.push({op:"replace",path:n,value:t})}}function qq(e,t){let n=t;for(let r of e)n=J9(n,r);return n}function qb(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function V9(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw new Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(Cd)}function jq(e){if(!/^(0|[1-9]\d*)$/.test(e))throw new Error(`Invalid array index: "${e}"`);return Number(e)}function J9(e,t){if(t.path===""){if(t.op==="remove")throw new Error("Unsupported operation at the root");return t.value}let n=G9(e,t.path);if(n===null)throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:r,parent:o,stack:s}=n;if(Array.isArray(o)){if(r==="-"&&t.op!=="add")throw new Error(`"-" is not valid for ${t.op} at "${t.path}".`);let i=r==="-"?o.length:jq(r),a=t.op==="add"?o.length:o.length-1;if(i>a)throw new Error(`Array index out of bounds at "${t.path}".`);let c=o.slice();return t.op==="add"?c.splice(i,0,t.value):t.op==="remove"?c.splice(i,1):c[i]=t.value,Dq(s,c)}if(qb(o)){if(t.op!=="add"&&!Object.hasOwn(o,r))throw new Error(`Property "${r}" does not exist at "${t.path}".`);let i={...o};return t.op==="remove"?delete i[r]:K(i,r,t.value),Dq(s,i)}throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function G9(e,t){let n=V9(t);if(n.length===0)return null;let r=n[n.length-1],o=[],s=e;for(let i=0;i<n.length-1;i++){let a=n[i];if(Array.isArray(s)){let c=jq(a);if(c>=s.length)return null;o.push({container:s,token:c}),s=s[c];continue}if(qb(s)){if(!Object.hasOwn(s,a))return null;o.push({container:s,token:a}),s=s[a];continue}return null}return{stack:o,parent:s,lastToken:r}}function Dq(e,t){let n=t;for(let r=e.length-1;r>=0;r--){let{container:o,token:s}=e[r];if(Array.isArray(o)){let i=o.slice();i[s]=n,n=i}else{let i={...o};K(i,s,n),n=i}}return n}function zq(e,t){return oi(_d("Iso",e,t))}function $q(e,t){return oi(_d("Lens",e,t))}function _d(e,t,n){return[{_tag:"PrimitiveNode",kind:e,get:t,set:n}]}var Z9={kind:"Iso",get:j,set:j},jb=class{_tag="PathNode";kind="Lens";path;get;set;constructor(t){this.path=t,this.get=n=>{let r=n;for(let o=0;o<t.length;o++)r=r[t[o]];return r},this.set=(n,r)=>{let o=Bb(r),s=o,i=0;for(;i<t.length-1;i++){let a=t[i];K(s,a,Bb(s[a])),s=s[a]}return K(s,t[i],n),o}}},Ch=class{_tag="CheckNode";kind="Prism";checks;get;set=j;constructor(t){this.checks=t,this.get=n=>gk(t,n)}};function Pf(e,t){if(e.length===0)return t;if(t.length===0)return e;let n=e.slice();for(let r=0;r<t.length;r++){let o=t[r],s=n[n.length-1];s._tag==="PathNode"&&o._tag==="PathNode"?n[n.length-1]=new jb([...s.path,...o.path]):s._tag==="CheckNode"&&o._tag==="CheckNode"?n[n.length-1]=new Ch([...s.checks,...o.checks]):n.push(o)}return n}function Q9(e,t){return oi(_d("Optional",e,t))}var Md=class{node;getResult;replaceResult;constructor(t,n,r){this.node=t,this.getResult=n,this.replaceResult=r}replace(t,n){return dc(this.replaceResult(t,n),()=>n)}modify(t){return n=>dc(pc(this.getResult(n),r=>this.replaceResult(t(r),n)),()=>n)}compose(t){return oi(Pf(this.node,t.node))}key(t){return oi(Pf(this.node,[new jb([t])]))}optionalKey(t){return oi(Pf(this.node,_d("Lens",n=>n[t],(n,r)=>{let o=Bb(r);return n===void 0?Array.isArray(o)&&typeof t=="number"?o.splice(t,1):delete o[t]:K(o,t,n),o})))}check(...t){return oi(Pf(this.node,[new Ch(t)]))}refine(t,n){return oi(Pf(this.node,[new Ch([Jm(t,n)])]))}tag(t){let n=ge(new Oe({expected:`${JSON.stringify(t)} tag`}));return oi(Pf(this.node,_d("Prism",r=>r._tag===t?le(r):n,j)))}at(t,...n){let r=ge(new kt([t],new tn(void 0)));return oi(Pf(this.node,_d("Optional",o=>Object.hasOwn(o,t)?le(o[t]):r,(o,s)=>{if(Object.hasOwn(s,t)){let i=Bb(s);return K(i,t,o),le(i)}else return r})))}pick(t){return this.compose($q(XL(t),(n,r)=>({...r,...n})))}omit(t){return this.compose($q(eq(t),(n,r)=>({...r,...n})))}notUndefined(){return this.refine(qn,{expected:"a value other than `undefined`"})}forEach(t){let n=t($b());return Q9(r=>vo(this.getResult(r),o=>{let s=[];for(let i=0;i<o.length;i++){let a=n.getResult(o[i]);_t(a)&&s.push(a.success)}return s}),(r,o)=>pc(this.getResult(o),s=>{let i=[];for(let c=0;c<s.length;c++)_t(n.getResult(s[c]))&&i.push(c);if(r.length!==i.length)return ge(new Oe({message:`each: replacement length mismatch: ${r.length} !== ${i.length}`}));let a=s.slice();for(let c=0;c<i.length;c++){let u=i[c],f=n.replaceResult(r[c],s[u]);if(we(f))return ge(new kt([u],f.failure));a[u]=f.success}return this.replaceResult(a,o)}))}modifyAll(t){return n=>dc(pc(this.getResult(n),r=>this.replaceResult(r.map(t),n)),()=>n)}},zA=class extends Md{get;set;constructor(t,n,r){super(t,o=>le(n(o)),o=>le(r(o))),this.get=n,this.set=r}replace(t,n){return this.set(t)}modify(t){return n=>this.set(t(this.get(n)))}},WA=class extends Md{get;constructor(t,n,r){super(t,o=>le(n(o)),(o,s)=>le(r(o,s))),this.get=n,this.replace=r}modify(t){return n=>this.replace(t(this.get(n)),n)}},KA=class extends Md{set;constructor(t,n,r){super(t,n,(o,s)=>le(r(o))),this.set=r}replace(t,n){return this.set(t)}modify(t){return n=>dc(vo(this.getResult(n),r=>this.set(t(r))),()=>n)}};function oi(e){let t=e[0]??Z9;if(e.length>1){let n=e.reduce((r,o)=>eY(r,o.kind),"Iso");t={kind:n,get:Y9(e,n),set:X9(e,n)}}switch(t.kind){case"Iso":return new zA(e,t.get,t.set);case"Lens":return new WA(e,t.get,t.set);case"Prism":return new KA(e,t.get,t.set);case"Optional":return new Md(e,t.get,t.set)}}function Bb(e){if(Array.isArray(e))return e.slice();if(typeof e=="object"&&e!==null){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}function Y9(e,t){return n=>{for(let r=0;r<e.length;r++){let o=e[r],s=o.get(n);if(VA(o.kind)){if(we(s))return s;n=s.success}else n=s}return VA(t)?le(n):n}}function X9(e,t){return Hq(t)?n=>{for(let r=e.length-1;r>=0;r--)n=e[r].set(n);return n}:(n,r)=>{let o=e.length,s=new Array(o);for(let i=0;i<o;i++){s[i]=r;let a=e[i];if(VA(a.kind)){let c=a.get(r);if(we(c))return c;r=c.success}else r=a.get(r)}for(let i=o-1;i>=0;i--){let a=e[i];if(Hq(a.kind))n=a.set(n);else if(a.kind==="Lens")n=a.set(n,s[i]);else{let c=a.set(n,s[i]);if(we(c))return c;n=c.success}}return t==="Optional"?le(n):n}}function VA(e){return e==="Prism"||e==="Optional"}function Hq(e){return e==="Iso"||e==="Prism"}function eY(e,t){return e==="Iso"?t:t==="Iso"||e===t?e:"Optional"}var tY=oi([]);function $b(){return tY}var Ff=new WeakMap,Kq=e=>{if(Ff.has(e))return Ff.get(e);throw new Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var Vq="~effect/data/Redacted",Oh=e=>N(e,Vq),Hc=(e,t)=>{let n=Object.create(rY);return t?.label&&(n.label=t.label),Ff.set(n,e),n},rY={[Vq]:{_A:e=>e},label:void 0,...On,toJSON(){return this.toString()},toString(){return`<redacted${Gr(this.label)?":"+this.label:""}>`},[Ie](){return ue(Ff.get(this))},[ke](e){return Oh(e)&&ne(Ff.get(this),Ff.get(e))}},$c=Kq;var Jq=e=>pn((t,n)=>e($c(t),$c(n)));var _h=Fb;function Dn(){return(e,t,n)=>se(new Pi(e.map(fd),r=>t(r.map(o=>se(o))),n))}function po(e,t){return Dn()([],()=>(n,r,o)=>e(n)?k(n):Q(new tt(r,n,o)),t)}function oY(e){return e}function sY(e){return t=>t.annotate(e)}function iY(e){return t=>JA(JA(t).annotate(e))}function aY(e){return t=>t.rebuild(gf(t.ast,e))}function cY(e){return e}var Mh="~effect/SchemaError/SchemaError",Wr=class extends _n("SchemaError"){[Mh]=Mh;constructor(t){let n=Jo();Mn(0);try{super({issue:t})}finally{Mn(n)}}get message(){return wI(this.issue)}toString(){return`SchemaError(${this.message})`}};function Ld(e){return N(e,Mh)&&e[Mh]===Mh}function Gq(e){return Nt(e)?e.value:{issues:[{message:cT(e.cause)}]}}function uY(e,t){let n=ut(e),r={errors:"all",...t?.parseOptions},o=SI(t),s=i=>{let a=new xi("sync"),c=bm(XT(n(i,r),{onFailure:o,onSuccess:f=>({value:f})}),{scheduler:a});c.currentDispatcher?.flush();let u=c.pollUnsafe();return u?Gq(u):new Promise(f=>{c.addObserver(l=>{f(Gq(l))})})};if("~standard"in e){let i=e;return"validate"in i["~standard"]||Object.assign(i["~standard"],{validate:s}),i}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}function Zq(e,t){let n=e$(e);if(t==="draft-2020-12"){let r=n.schema;return Object.keys(n.definitions).length>0&&(r.$defs=n.definitions),r}else if(t==="draft-07"){let r=kq(n),o=r.schema;return Object.keys(r.definitions).length>0&&(o.definitions=r.definitions),o}throw new globalThis.Error(`Unsupported target: ${t}`)}function fY(e){let t={input(n){return Zq(e,n.target)},output(n){return Zq(Kr(e),n.target)}};if("~standard"in e){let n=e;return"jsonSchema"in n["~standard"]||Object.assign(n["~standard"],{jsonSchema:t}),n}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}var uj=kA,lY=RA;function Wc(e,t){let n=ut(e,t);return(r,o)=>fj(n(r,o))}function fj(e){return bt(e)?YA(e):ht(e,t=>Aa(()=>ka(t,n=>new Wr(n))))}var dY=Wc;function lj(e,t){let n;for(let r of e.reasons){if(!tm(r)||!Ld(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function dj(e){return Em(e).then(t=>{if(Nt(t))return t.value;throw lj(t.cause,"Promise adapter can only reject schema errors")})}function pj(e){let t=_c(e);if(Nt(t))return t.value;throw lj(t.cause,"Sync adapter can only throw schema errors")}function mj(e,t){let n=Ib(e,t);return(r,o)=>YA(n(r,o))}function YA(e){return Nt(e)?e:Jt(ka(e.cause,t=>new Wr(t)))}var hj=mj,pY=kb,mY=CA;function gj(e,t){let n=Ab(e,t);return(r,o)=>Mp(n(r,o),s=>new Wr(s))}var hY=gj;function xj(e,t){let n=Wc(e,t);return(r,o)=>dj(n(r,o))}var gY=xj;function Kb(e,t){let n=Wc(e,t);return(r,o)=>pj(n(r,o))}var Fh=Kb;function Uh(e,t){let n=Ha(e,t);return(r,o)=>fj(n(r,o))}var Vb=Uh;function yj(e,t){let n=Cb(e,t);return(r,o)=>YA(n(r,o))}var Sj=yj,xY=Ob,yY=OA;function bj(e,t){let n=_b(e,t);return(r,o)=>Mp(n(r,o),s=>new Wr(s))}var SY=bj;function Ej(e,t){let n=Uh(e,t);return(r,o)=>dj(n(r,o))}var bY=Ej;function Jb(e,t){let n=Uh(e,t);return(r,o)=>pj(n(r,o))}var XA=Jb,se=Th;function Nf(e){return N(e,_h)&&e[_h]===_h}var Uf=vr(e=>se(xf(e.ast),{schema:e})),EY=vr(e=>e.schema),Bt=vr(e=>{let t=Zb(e);return se(uk(e.ast),{schema:t})}),wY=vr(e=>e.schema.members[0]),vY=vr(e=>se(RS(e.ast),{schema:e})),TY=vr(e=>e.schema),Kr=vr(e=>se(hn(e.ast),{schema:e})),qd=vr(e=>se(Nn(e.ast),{schema:e})),Ph="~effect/Schema/flip";function IY(e){return N(e,Ph)&&e[Ph]===Ph}function JA(e){return IY(e)?e.schema.rebuild(is(e.ast)):se(is(e.ast),{[Ph]:Ph,schema:e})}function Mt(e){let t=se(new jr(e),{literal:e,transform(n){return t.pipe(ve(Mt(n),{decode:Le(()=>n),encode:Le(()=>e)}))}});return t}function wj(e){return new jm(e.map(t=>Nf(t)?t.ast:new jr(t)))}function kY(e){return se(wj(e),{parts:e})}function AY(e){return se(wj(e).asTemplateLiteralParser(),{parts:e})}function RY(e){return se(new qm(Object.keys(e).filter(t=>typeof e[e[t]]!="number").map(t=>[t,e[t]])),{enums:e})}var $i=se(JI),CY=se(GI),eR=se(Fi),rt=se(bS),tR=se(ES),de=se(Ks),jd=se(wS),Kc=se(QI),vj=se(YI),Bi=se(XI),Bd=se(VI),OY=se(ZI);function _Y(e){return se(new Bm(e))}function nR(e,t){return se(e,{fields:t,mapFields(n,r){let o=n(this.fields);return nR(Wm(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function ie(e){return nR(Wm(e,void 0),e)}function MY(e){return vr(t=>t.mapFields(tq(e)))}var PY=e=>typeof e=="symbol"?e:globalThis.String(e);function FY(e){return function(t){let n={},r=Object.create(null),o=Object.create(null),s=new Set;for(let i of Reflect.ownKeys(t.fields)){let a=qd(t.fields[i]),c=Object.hasOwn(e,i),u=c?e[i]:i,f=PY(u);if(s.has(f))throw new globalThis.Error(`Duplicate encoded keys: ${sa(u)}`);s.add(f),K(n,u,a),c&&(r[i]=u,o[u]=i)}return ie(n).pipe(ve(t,Rt({decode:FA(o),encode:FA(r)})))}}function UY(e,t){return n=>{let r=ux(n.fields,Kr),o=ie({...r,...e});return n.pipe(ve(o,Rt({decode:s=>{let i={...s};for(let a in e){let c=t[a],u=c(s);_e(u)&&K(i,a,u.value)}return i},encode:s=>{let i={...s};for(let a in e)delete i[a];return i}})))}}function rR(e,t){return se(lk(e.ast,t.ast),{key:e,value:t})}function NY(e,t){return se(nk(e.ast,t.map(fd)),{schema:e,records:t})}function Tj(e,t){return se(e,{elements:t,mapElements(n,r){let o=n(this.elements);return Tj(vS(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function zc(e){return Tj(vS(e),e)}function DY(e,t){return se(rk(e.ast,t.map(fd)),{schema:e,rest:t})}var Xt=vr(e=>se(new as(!1,[],[e.ast]),{value:e}));var Gb=vr(e=>se(new as(!1,[e.ast],[e.ast]),{value:e}));function LY(e){return Ve([e,Xt(e)]).pipe(ve(Xt(Kr(e)),Rt({decode:rM,encode:t=>t.length===1?t[0]:t})))}function qY(e){return Xt(e).check(dR())}var jY=vr(e=>se(new as(!0,e.ast.elements,e.ast.rest),{schema:e}));function Ij(e,t){return se(e,{members:t,mapMembers(n,r){let o=n(this.members);return Ij(Km(o,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Ve(e,t){return Ij(Km(e,t?.mode??"anyOf",void 0),e)}function Ka(e){let t=e.map(Mt);return se(Km(t,"anyOf",void 0),{literals:e,members:t,mapMembers(n){return Ve(n(this.members))},pick(n){return Ka(n)},transform(n){return Ve(t.map((r,o)=>r.transform(n[o])))}})}var oR=vr(e=>Ve([e,rt])),Zb=vr(e=>Ve([e,tR])),kj=vr(e=>Ve([e,rt,tR]));function Aj(e){return se(new $m(()=>e().ast))}function BY(...e){return t=>t.check(...e)}function $Y(e,t){return n=>se(Vs(n.ast,[Jm(e,t)]),{schema:n})}function Rj(e){return t=>se(ck(t.ast,e),{schema:t,identifier:e})}function HY(e,t){return n=>(t.checks?n.check(...t.checks):n).pipe(Rj(e))}function Cj(e){return t=>se(sk(t.ast,new Um(e,j)),{schema:t})}function Oj(e){return t=>se(ik(t.ast,new Um(j,e)),{schema:t})}function zY(e){return _j(e)}function _j(e){return t=>Cj(Ly(e))(t)}function WY(e){return Mj(e)}function Mj(e){return t=>Oj(Ly(e))(t)}function ve(e,t){return n=>se(Ym(n.ast,e.ast,t?nS(t):id()),{from:n,to:e})}function KY(e){return t=>ve(Kr(t),e)(t)}function sR(e,t){return n=>t?ve(n,t)(e):ve(n)(e)}function VY(e){return t=>ve(t,e)(qd(t))}function Pj(e){return t=>se(fk(t.ast,e),{schema:t})}function Fj(e){return ht(e,t=>Aa(()=>ka(t,n=>n.issue)))}function iR(e,t){let n=t?.encodingStrategy==="omit"?RI():Ws();return r=>Uf(qd(r)).pipe(ve(r,{decode:Pm(Fj(e)),encode:n}))}function JY(e,t){return n=>Kr(n).pipe(iR(e,t),sR(Uf(n)))}function Uj(e,t){let n=t?.encodingStrategy==="omit"?RI():Ws();return r=>Bt(qd(r)).pipe(ve(r,{decode:Pm(Fj(e)),encode:n}))}function GY(e,t){return n=>Kr(n).pipe(Uj(e,t),sR(Bt(n)))}function Ye(e){return Mt(e).pipe(Pj(k(e)))}function ZY(e){return Ye(e).pipe(iR(k(e),{encodingStrategy:"omit"}))}function Vc(e,t){return ie({_tag:Ye(e),...t})}function Nj(e){return t=>{let n={},r=[],o=new Set,s={},i=f=>l=>f.includes(l[e]);return a(t),Object.assign(t,{cases:n,discriminants:r,isAnyOf:i,guards:s,match:c,matchOrElse:u});function a(f){let l=f.ast;if(KI(l)&&"members"in f&&globalThis.Array.isArray(f.members)&&f.members.every(Nf))return f.members.forEach(a);let p=Ma(l);if(p.length>0){let h=p.find(g=>g.key===e)?.literal;if(gp(h)){let g=typeof h=="number"?globalThis.String(h):h;if(o.has(g))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(h)}`);o.add(g),r.push(h),K(n,h,f),K(s,h,uj(Kr(f)));return}}throw new globalThis.Error("No literal or unique symbol found")}function c(){if(arguments.length===1){let g=arguments[0];return function(x){let S=x[e];return(Object.hasOwn(g,S)?g[S]:void 0)(x)}}let f=arguments[0],l=arguments[1],p=f[e];return(Object.hasOwn(l,p)?l[p]:void 0)(f)}function u(){if(arguments.length===2){let x=arguments[0],S=arguments[1];return function(w){let E=w[e];return(Object.hasOwn(x,E)?x[E]??S:S)(w)}}let f=arguments[0],l=arguments[1],p=arguments[2],h=f[e];return(Object.hasOwn(l,h)?l[h]??p:p)(f)}}}function QY(e){let t={},n=[];for(let c of Object.keys(e)){let u=Vc(c,e[c]);K(t,c,u),n.push(u)}let r=Ve(n),{guards:o,isAnyOf:s,match:i,matchOrElse:a}=Nj("_tag")(r);return se(r.ast,{cases:t,isAnyOf:s,guards:o,match:i,matchOrElse:a})}function YY(){return e=>e}function Jc(e,t){return po(n=>n instanceof e,t)}function gt(){return(e,t)=>new jt(e.ast,nS(t))}var Ct=Vm;function XY(e,t=void 0){return new Nc(e,t)}function Tr(e,t){return zr(e,rt,({annotations:n})=>n===void 0?t:t.annotate(n))}var Qq="^\\S[\\s\\S]*\\S$|^\\S$|^$";function aR(e){let t=new globalThis.RegExp(Qq);return Ct(n=>n.trim()===n,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isTrimmed()"}),arbitrary:{constraint:{patterns:[Qq]}},...e})}var eX=Me("effect/schema/isTrimmed",rt,({annotations:e})=>aR(e));function Df(e,t){let n=e.source,r=e.flags,o=r===""?`new RegExp(${re(n)})`:`new RegExp(${re(n)}, ${re(r)})`;return dd(e,{toCode:()=>({runtime:`Schema.isPattern(${o})`}),...t})}var tX=ie({source:de,flags:de}).check(Ct(e=>{let t=_p(()=>new globalThis.RegExp(e.source,e.flags));return _t(t)&&t.success.source===e.source&&t.success.flags===e.flags})),nX={id:"effect/schema/isPattern",payloadSchema:tX,revive:({annotations:e,payload:t})=>Df(new globalThis.RegExp(t.source,t.flags),e)};function Dj(e){return OS({toCode:()=>({runtime:"Schema.isStringFinite()"}),...e})}var rX=Me("effect/schema/isStringFinite",rt,({annotations:e})=>Dj(e));function Lj(e){return _S({toCode:()=>({runtime:"Schema.isStringBigInt()"}),...e})}var oX=Me("effect/schema/isStringBigInt",rt,({annotations:e})=>Lj(e));function qj(e){return PS({toCode:()=>({runtime:"Schema.isStringSymbol()"}),...e})}var sX=Me("effect/schema/isStringSymbol",rt,({annotations:e})=>qj(e)),iX=e=>e?new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/;function jj(e,t){let n=iX(e);return Df(n,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:n.source,format:"uuid"}),toCode:()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),...t})}var aX=Me("effect/schema/isUUID",ie({version:Ve([Ka([1,2,3,4,5,6,7,8]),rt])}),({annotations:e,payload:t})=>jj(t.version??void 0,e)),Yq=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;function Bj(e){return Df(Yq,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:()=>({pattern:Yq.source}),toCode:()=>({runtime:"Schema.isGUID()"}),...e})}var cX=Me("effect/schema/isGUID",rt,({annotations:e})=>Bj(e));function $j(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return Df(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isULID()"}),...e})}var uX=Me("effect/schema/isULID",rt,({annotations:e})=>$j(e));function cR(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return Df(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64()"}),...e})}var fX=Me("effect/schema/isBase64",rt,({annotations:e})=>cR(e));function Hj(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return Df(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64Url()"}),...e})}var lX=Me("effect/schema/isBase64Url",rt,({annotations:e})=>Hj(e));function zj(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`^${Od(e)}`);return Ct(o=>o.startsWith(e),{expected:`a string starting with ${n}`,representation:{id:"effect/schema/isStartsWith",payload:{startsWith:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isStartsWith(${re(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}var dX=Me("effect/schema/isStartsWith",ie({startsWith:de}),({annotations:e,payload:t})=>zj(t.startsWith,e));function Wj(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`${Od(e)}$`);return Ct(o=>o.endsWith(e),{expected:`a string ending with ${n}`,representation:{id:"effect/schema/isEndsWith",payload:{endsWith:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isEndsWith(${re(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}var pX=Me("effect/schema/isEndsWith",ie({endsWith:de}),({annotations:e,payload:t})=>Wj(t.endsWith,e));function Kj(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(Od(e));return Ct(o=>o.includes(e),{expected:`a string including ${n}`,representation:{id:"effect/schema/isIncludes",payload:{includes:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isIncludes(${re(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}var mX=Me("effect/schema/isIncludes",ie({includes:de}),({annotations:e,payload:t})=>Kj(t.includes,e)),Xq="^[^a-z]*$";function Vj(e){let t=new globalThis.RegExp(Xq);return Ct(n=>n.toUpperCase()===n,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isUppercased()"}),arbitrary:{constraint:{patterns:[Xq]}},...e})}var hX=Me("effect/schema/isUppercased",rt,({annotations:e})=>Vj(e)),ej="^[^A-Z]*$";function Jj(e){let t=new globalThis.RegExp(ej);return Ct(n=>n.toLowerCase()===n,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isLowercased()"}),arbitrary:{constraint:{patterns:[ej]}},...e})}var gX=Me("effect/schema/isLowercased",rt,({annotations:e})=>Jj(e)),tj="^[^a-z]?.*$";function Gj(e){let t=new globalThis.RegExp(tj);return Ct(n=>n.charAt(0).toUpperCase()===n.charAt(0),{expected:"a string with the first character in uppercase",representation:{id:"effect/schema/isCapitalized",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isCapitalized()"}),arbitrary:{constraint:{patterns:[tj]}},...e})}var xX=Me("effect/schema/isCapitalized",rt,({annotations:e})=>Gj(e)),nj="^[^A-Z]?.*$";function Zj(e){let t=new globalThis.RegExp(nj);return Ct(n=>n.charAt(0).toLowerCase()===n.charAt(0),{expected:"a string with the first character in lowercase",representation:{id:"effect/schema/isUncapitalized",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isUncapitalized()"}),arbitrary:{constraint:{patterns:[nj]}},...e})}var yX=Me("effect/schema/isUncapitalized",rt,({annotations:e})=>Zj(e)),si=se(kS),Qj=IS,SX=Me("effect/schema/isFinite",rt,({annotations:e})=>Qj(e));function Nh(e){let t=fa(e.order),n=e.formatter??re;return(r,o)=>Ct(s=>t(s,r),{expected:`a value greater than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r,exclusiveMinimum:!0}}},...e.annotate?.(r),...o})}function Dh(e){let t=vl(e.order),n=e.formatter??re;return(r,o)=>Ct(s=>t(s,r),{expected:`a value greater than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r}}},...e.annotate?.(r),...o})}function Lh(e){let t=ku(e.order),n=e.formatter??re;return(r,o)=>Ct(s=>t(s,r),{expected:`a value less than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r,exclusiveMaximum:!0}}},...e.annotate?.(r),...o})}function qh(e){let t=wl(e.order),n=e.formatter??re;return(r,o)=>Ct(s=>t(s,r),{expected:`a value less than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r}}},...e.annotate?.(r),...o})}function jh(e){let t=vl(e.order),n=fa(e.order),r=wl(e.order),o=ku(e.order),s=e.formatter??re;return(i,a)=>{let c=i.exclusiveMinimum?n:t,u=i.exclusiveMaximum?o:r;return Ct(f=>c(f,i.minimum)&&u(f,i.maximum),{expected:`a value between ${s(i.minimum)}${i.exclusiveMinimum?" (excluded)":""} and ${s(i.maximum)}${i.exclusiveMaximum?" (excluded)":""}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:i.minimum,maximum:i.maximum,...i.exclusiveMinimum&&{exclusiveMinimum:!0},...i.exclusiveMaximum&&{exclusiveMaximum:!0}}}},...e.annotate?.(i),...a})}}function Yj(e){return(t,n)=>{let r=e.formatter??re;return Ct(o=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${r(t)}`,...e.annotate?.(t),...n})}}function Fd(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${re(e)}`);return e}var Xj=Nh({order:wo,annotate:e=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:Fd(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${re(e)})`})})}),bX=Me("effect/schema/isGreaterThan",ie({exclusiveMinimum:si}),({annotations:e,payload:t})=>Xj(t.exclusiveMinimum,e)),uR=Dh({order:wo,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:Fd(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${re(e)})`})})}),EX=Me("effect/schema/isGreaterThanOrEqualTo",ie({minimum:si}),({annotations:e,payload:t})=>uR(t.minimum,e)),eB=Lh({order:wo,annotate:e=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:Fd(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${re(e)})`})})}),wX=Me("effect/schema/isLessThan",ie({exclusiveMaximum:si}),({annotations:e,payload:t})=>eB(t.exclusiveMaximum,e)),tB=qh({order:wo,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:Fd(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${re(e)})`})})}),vX=Me("effect/schema/isLessThanOrEqualTo",ie({maximum:si}),({annotations:e,payload:t})=>tB(t.maximum,e)),Qb=jh({order:wo,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:Fd(e.minimum),maximum:Fd(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[n?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${re(e.minimum)}, maximum: ${re(e.maximum)}, exclusiveMinimum: ${re(t)}, exclusiveMaximum: ${re(n)} })`})}}}),TX=Me("effect/schema/isBetween",ie({minimum:si,maximum:si,exclusiveMinimum:Bt(Mt(!0)),exclusiveMaximum:Bt(Mt(!0))}),({annotations:e,payload:t})=>Qb(t,e)),nB=Yj({remainder:D1,zero:0,annotate:e=>({expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${re(e)})`})})}),IX=Me("effect/schema/isMultipleOf",ie({divisor:si}),({annotations:e,payload:t})=>nB(t.divisor,e));function Bh(e){return Ct(t=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer"}),toCode:()=>({runtime:"Schema.isInt()"}),arbitrary:{constraint:{integer:!0}},...e})}var kX=Me("effect/schema/isInt",rt,({annotations:e})=>Bh(e)),ai=jd.check(Bh()),dr=ai.check(uR(0));function AX(e){return new Nc([Bh(),Qb({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}function RX(e){return new Nc([Bh(),Qb({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}function Ud(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${re(e)}`);return e.toISOString()}function Nd(e){return`new Date(${re(e.getTime())})`}var rB=Nh({order:Iu,annotate:e=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:Ud(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanDate(${Nd(e)})`})})}),oB=Dh({order:Iu,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:Ud(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${Nd(e)})`})})}),sB=Lh({order:Iu,annotate:e=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:Ud(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanDate(${Nd(e)})`})})}),iB=qh({order:Iu,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:Ud(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${Nd(e)})`})})}),aB=jh({order:Iu,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:Ud(e.minimum),maximum:Ud(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${Nd(e.minimum)}, maximum: ${Nd(e.maximum)}, exclusiveMinimum: ${re(t)}, exclusiveMaximum: ${re(n)} })`})}}}),cB=Nh({order:Wo,annotate:e=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${re(e)})`})})}),uB=Dh({order:Wo,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${re(e)})`})})}),fB=Lh({order:Wo,annotate:e=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanBigInt(${re(e)})`})})}),lB=qh({order:Wo,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${re(e)})`})})}),dB=jh({order:Wo,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenBigInt",payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${re(e.minimum)}, maximum: ${re(e.maximum)}, exclusiveMinimum: ${re(t)}, exclusiveMaximum: ${re(n)} })`})}}}),CX=Nh({order:la,formatter:e=>gi(e)}),OX=Dh({order:la,formatter:e=>gi(e)}),_X=Lh({order:la,formatter:e=>gi(e)}),MX=qh({order:la,formatter:e=>gi(e)}),PX=jh({order:la,formatter:e=>gi(e)});function fR(e,t){return e=Math.max(0,Math.floor(e)),Ct(n=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="array"?{minItems:e}:{minLength:e},toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[ao]:!0,arbitrary:{constraint:{minLength:e}},...t})}var FX=Me("effect/schema/isMinLength",ie({minLength:dr}),({annotations:e,payload:t})=>fR(t.minLength,e));function pB(e){return fR(1,e)}function mB(e,t){return e=Math.max(0,Math.floor(e)),Ct(n=>n.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:n})=>n==="array"?{maxItems:e}:{maxLength:e},toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[ao]:!0,arbitrary:{constraint:{maxLength:e}},...t})}var UX=Me("effect/schema/isMaxLength",ie({maxLength:dr}),({annotations:e,payload:t})=>mB(t.maxLength,e));function lR(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Ct(r=>r.length>=e&&r.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:"effect/schema/isLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:({type:r})=>r==="array"?{allOf:[{minItems:e},{maxItems:t}]}:{allOf:[{minLength:e},{maxLength:t}]},toCode:()=>({runtime:`Schema.isLengthBetween(${e}, ${t})`}),[ao]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}var NX=Me("effect/schema/isLengthBetween",ie({minimum:dr,maximum:dr}),({annotations:e,payload:t})=>lR(t.minimum,t.maximum,e));function hB(e,t){return e=Math.max(0,Math.floor(e)),Ct(n=>n.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[ao]:!0,arbitrary:{constraint:{minLength:e}},...t})}var DX=Me("effect/schema/isMinSize",ie({minSize:dr}),({annotations:e,payload:t})=>hB(t.minSize,e));function gB(e,t){return e=Math.max(0,Math.floor(e)),Ct(n=>n.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[ao]:!0,arbitrary:{constraint:{maxLength:e}},...t})}var LX=Me("effect/schema/isMaxSize",ie({maxSize:dr}),({annotations:e,payload:t})=>gB(t.maxSize,e));function xB(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Ct(r=>r.size>=e&&r.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:"effect/schema/isSizeBetween",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isSizeBetween(${e}, ${t})`}),[ao]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}var qX=Me("effect/schema/isSizeBetween",ie({minimum:dr,maximum:dr}),({annotations:e,payload:t})=>xB(t.minimum,t.maximum,e));function yB(e,t){return e=Math.max(0,Math.floor(e)),Ct(n=>Reflect.ownKeys(n).length>=e,{expected:`a value with at least ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMinProperties",payload:{minProperties:e}},toJsonSchema:()=>({minProperties:e}),toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[ao]:!0,arbitrary:{constraint:{minLength:e}},...t})}var jX=Me("effect/schema/isMinProperties",ie({minProperties:dr}),({annotations:e,payload:t})=>yB(t.minProperties,e));function SB(e,t){return e=Math.max(0,Math.floor(e)),Ct(n=>Reflect.ownKeys(n).length<=e,{expected:`a value with at most ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMaxProperties",payload:{maxProperties:e}},toJsonSchema:()=>({maxProperties:e}),toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[ao]:!0,arbitrary:{constraint:{maxLength:e}},...t})}var BX=Me("effect/schema/isMaxProperties",ie({maxProperties:dr}),({annotations:e,payload:t})=>SB(t.maxProperties,e));function bB(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Ct(r=>Reflect.ownKeys(r).length>=e&&Reflect.ownKeys(r).length<=t,{expected:e===t?`a value with exactly ${e===1?"1 entry":`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:"effect/schema/isPropertiesLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({minProperties:e,maxProperties:t}),toCode:()=>({runtime:`Schema.isPropertiesLengthBetween(${e}, ${t})`}),[ao]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}var $X=Me("effect/schema/isPropertiesLengthBetween",ie({minimum:dr,maximum:dr}),({annotations:e,payload:t})=>bB(t.minimum,t.maximum,e));function EB(e,t){let n=qd(e),r=AA(n.ast);return Ct((o,s,i)=>{let a=Reflect.ownKeys(o),c=[];for(let u of a){let f=r(u,i);if(f!==void 0&&(c.push(new kt([u],f)),i.errors==="first"))break}return or(c)?new At(s,c,o,i):!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[n.ast]},toJsonSchema:({schemas:o})=>({propertyNames:o[0]}),toCode:({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),[ao]:!0,...t})}var HX=Me("effect/schema/isPropertyNames",rt,({annotations:e,schemas:t})=>EB(t[0],e));function dR(e){return Ct(t=>px(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:"Schema.isUnique()"}),arbitrary:{constraint:{unique:!0}},...e})}var zX=Me("effect/schema/isUnique",rt,({annotations:e})=>dR(e)),WX=de.check(pB()),KX=de.check(lR(1,1));function Hi(e){let t=Dn()([e],([n])=>(r,o,s)=>hi(r)?Se(r)?js:mn(ut(n)(r.value,s),{onSuccess:L,onFailure:i=>Zn(o,"value",i,r,s)}):Q(new tt(o,r,s)),{representation:{id:"effect/schema/Option",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Option(${n[0].runtime})`,Type:`Option.Option<${n[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),expected:"Option",toCodec:([n])=>gt()(Ve([ie({_tag:Mt("Some"),value:n}),ie({_tag:Mt("None")})]),Rt({decode:r=>r._tag==="None"?D():L(r.value),encode:r=>_e(r)?{_tag:"Some",value:r.value}:{_tag:"None"}})),toArbitrary:([n])=>(r,o)=>{let s=r.constant(D()),i=r.oneof(s,n.arbitrary.map(L));return Lf(r,o,s,i)},toEquivalence:([n])=>bw(n),toFormatter:([n])=>mr({onNone:()=>"none()",onSome:r=>`some(${n(r)})`})});return se(t.ast,{value:e})}var VX=zr("effect/schema/Option",rt,({annotations:e,typeParameters:t})=>{let n=Hi(t[0]);return e===void 0?n:n.annotate(e)});function JX(e){return oR(e).pipe(ve(Hi(Kr(e)),hD()))}function GX(e){return Zb(e).pipe(ve(Hi(Kr(e)),gD()))}function ZX(e,t){return kj(e).pipe(ve(Hi(Kr(e)),xD(t)))}function QX(e){return Uf(e).pipe(ve(Hi(Kr(e)),yD()))}function YX(e){return Bt(e).pipe(ve(Hi(Kr(e)),SD()))}function XX(e,t){let n=t===void 0?"omit":t.onNoneEncoding,r=n===null?null:void 0;return Bt(oR(e)).pipe(ve(Hi(Kr(e)),rS({decode:o=>o.pipe(fc(xp),L),encode:n==="omit"?Ru:o=>L(cc(Ru(o),()=>r))})))}function wB(e,t){let n=Dn()([e,t],([r,o])=>(s,i,a)=>{if(!lc(s))return Q(new tt(i,s,a));switch(s._tag){case"Success":return mn(vh(r)(s.success,a),{onSuccess:le,onFailure:c=>Zn(i,"success",c,s,a)});case"Failure":return mn(vh(o)(s.failure,a),{onSuccess:ge,onFailure:c=>Zn(i,"failure",c,s,a)})}},{representation:{id:"effect/schema/Result",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Result(${r[0].runtime}, ${r[1].runtime})`,Type:`Result.Result<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Result from "effect/Result"']}),expected:"Result",toCodec:([r,o])=>gt()(Ve([ie({_tag:Mt("Success"),success:r}),ie({_tag:Mt("Failure"),failure:o})]),Rt({decode:s=>s._tag==="Success"?le(s.success):ge(s.failure),encode:s=>_t(s)?{_tag:"Success",success:s.success}:{_tag:"Failure",failure:s.failure}})),toArbitrary:([r,o])=>(s,i)=>{let a=MB(s,r.terminal?.map(u=>le(u)),o.terminal?.map(u=>ge(u))),c=s.oneof(r.arbitrary.map(u=>le(u)),o.arbitrary.map(u=>ge(u)));return Lf(s,i,a,c)},toEquivalence:([r,o])=>Ew(r,o),toFormatter:([r,o])=>Zr({onSuccess:s=>`success(${r(s)})`,onFailure:s=>`failure(${o(s)})`})});return se(n.ast,{success:e,failure:t})}var eee=zr("effect/schema/Result",rt,({annotations:e,typeParameters:t})=>{let n=wB(t[0],t[1]);return e===void 0?n:n.annotate(e)}),tee=po(e=>{if(!Wt(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every(n=>{switch(n){case"label":return typeof e[n]=="string";case"disallowJsonEncode":return e[n]===!0;default:return!1}})}),nee=Ve([rt,tee]);function pR(e,t){let n=typeof t?.label=="string"?t.label:void 0,r=t?.disallowJsonEncode===!0,o=n!==void 0?r?{label:n,disallowJsonEncode:!0}:{label:n}:r?{disallowJsonEncode:!0}:void 0,s=n!==void 0?ut(Mt(n)):void 0,i=Dn()([e],([a])=>(c,u,f)=>{if(Oh(c)){let l=s!==void 0?nf(s(c.label,f),p=>new kt(["label"],p)):W;return Gn(l,()=>mn(ut(a)($c(c),f),{onSuccess:()=>c,onFailure:()=>new At(u,[new kt(["value"],new Oe(void 0,c,f))],c,f)}))}return Q(new tt(u,c,f))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:({typeParameters:a})=>({runtime:o!==void 0?`Schema.Redacted(${a[0].runtime}, ${re(o)})`:`Schema.Redacted(${a[0].runtime})`,Type:`Redacted.Redacted<${a[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),expected:"Redacted",toCodecJson:([a])=>gt()(a,{decode:Le(c=>Hc(c,{label:n})),encode:r?kI(c=>"Cannot serialize Redacted"+(_e(c)&&typeof c.value.label=="string"?` with label: "${c.value.label}"`:"")):Le($c)}),toArbitrary:([a])=>()=>({arbitrary:a.arbitrary.map(c=>Hc(c,{label:n})),terminal:a.terminal?.map(c=>Hc(c,{label:n}))}),toFormatter:()=>globalThis.String,toEquivalence:([a])=>Jq(a)});return se(i.ast,{value:e})}var ree=zr("effect/schema/Redacted",nee,({annotations:e,payload:t,typeParameters:n})=>{let r=pR(n[0],t??void 0);return e===void 0?r:r.annotate(e)});function oee(e,t){return ve(pR(Kr(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:Le(n=>Hc(n,{label:t?.label})),encode:t?.disallowEncode?kI(n=>"Cannot encode Redacted"+(_e(n)&&typeof n.value.label=="string"?` with label: "${n.value.label}"`:"")):Le($c)})(e)}function zb(e,t){let n=Dn()([e,t],([r,o])=>(s,i,a)=>{if(!qu(s))return Q(new tt(i,s,a));switch(s._tag){case"Fail":return mn(ut(r)(s.error,a),{onSuccess:ju,onFailure:c=>Zn(i,"error",c,s,a)});case"Die":return mn(ut(o)(s.defect,a),{onSuccess:Bu,onFailure:c=>Zn(i,"defect",c,s,a)});case"Interrupt":return k(s)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.CauseReason(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Failure<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause.Failure",toCodec:([r,o])=>gt()(Ve([ie({_tag:Mt("Fail"),error:r}),ie({_tag:Mt("Die"),defect:o}),ie({_tag:Mt("Interrupt"),fiberId:Zb(si)})]),Rt({decode:s=>{switch(s._tag){case"Fail":return ju(s.error);case"Die":return Bu(s.defect);case"Interrupt":return wc(s.fiberId)}},encode:j})),toArbitrary:([r,o])=>vB(r,o),toEquivalence:([r,o])=>TB(r,o),toFormatter:([r,o])=>IB(r,o)});return se(n.ast,{error:e,defect:t})}var see=zr("effect/schema/CauseReason",rt,({annotations:e,typeParameters:t})=>{let n=zb(t[0],t[1]);return e===void 0?n:n.annotate(e)});function vB(e,t){return(n,r)=>{let o=n.constant(wc()),s=n.oneof(o,n.integer({min:1}).map(wc),e.arbitrary.map(i=>ju(i)),t.arbitrary.map(i=>Bu(i)));return Lf(n,r,o,s)}}function TB(e,t){return(n,r)=>{if(n._tag!==r._tag)return!1;switch(n._tag){case"Fail":return e(n.error,r.error);case"Die":return t(n.defect,r.defect);case"Interrupt":return n.fiberId===r.fiberId}}}function IB(e,t){return n=>{switch(n._tag){case"Fail":return`Fail(${e(n.error)})`;case"Die":return`Die(${t(n.defect)})`;case"Interrupt":return"Interrupt"}}}function Dd(e,t){let n=Dn()([e,t],([r,o])=>{let s=Xt(zb(r,o));return(i,a,c)=>Lu(i)?mn(ut(s)(i.reasons,c),{onSuccess:Ia,onFailure:u=>Zn(a,"failures",u,i,c)}):Q(new tt(a,i,c))},{representation:{id:"effect/schema/Cause",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Cause(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Cause<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause",toCodec:([r,o])=>gt()(Xt(zb(r,o)),Rt({decode:Ia,encode:({reasons:s})=>s})),toArbitrary:([r,o])=>kB(r,o),toEquivalence:([r,o])=>AB(r,o),toFormatter:([r,o])=>RB(r,o)});return se(n.ast,{error:e,defect:t})}var iee=zr("effect/schema/Cause",rt,({annotations:e,typeParameters:t})=>{let n=Dd(t[0],t[1]);return e===void 0?n:n.annotate(e)});function kB(e,t){return(n,r)=>{let o=vB(e,t)(n,r),s=n.constant(nT),i=n.array(o.arbitrary).map(Ia);return Lf(n,r,s,i)}}function AB(e,t){let n=Gg(TB(e,t));return(r,o)=>n(r.reasons,o.reasons)}function RB(e,t){let n=IB(e,t);return r=>`Cause([${r.reasons.map(n).join(", ")}])`}var aee=po(e=>{if(!Wt(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every(n=>(n==="includeStack"||n==="excludeCause")&&e[n]===!0)}),cee=Ve([rt,aee]),CB=e=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),OB=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},rj=[];function _B(e){let t=CB(e),n=rj[t];if(n!==void 0)return n;let r=OB(t),o=Jc(globalThis.Error,{representation:{id:"effect/schema/Error",payload:r??null},toCode:()=>({runtime:r!==void 0?`Schema.ErrorInstance(${re(r)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),expected:"Error",toCodecJson:()=>gt()(ene,pD(r)),toArbitrary:()=>s=>s.string().map(i=>new globalThis.Error(i))});return rj[t]=o,o}var uee=zr("effect/schema/Error",cee,({annotations:e,payload:t})=>{let n=_B(t??void 0);return e===void 0?n:n.annotate(e)}),oj=[];function xn(e){let t=CB(e),n=oj[t];if(n!==void 0)return n;let r=Wh.pipe(ve(eR,mD(OB(t))));return oj[t]=r,r}function Yb(e,t,n){let r=Dn()([e,t,n],([o,s,i])=>{let a=Dd(s,i);return(c,u,f)=>{if(!Us(c))return Q(new tt(u,c,f));switch(c._tag){case"Success":return mn(ut(o)(c.value,f),{onSuccess:Pn,onFailure:l=>Zn(u,"value",l,c,f)});case"Failure":return mn(ut(a)(c.cause,f),{onSuccess:Jt,onFailure:l=>Zn(u,"cause",l,c,f)})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:({typeParameters:o})=>({runtime:`Schema.Exit(${o[0].runtime}, ${o[1].runtime}, ${o[2].runtime})`,Type:`Exit.Exit<${o[0].Type}, ${o[1].Type}, ${o[2].Type}>`,importDeclarations:['import * as Exit from "effect/Exit"']}),expected:"Exit",toCodec:([o,s,i])=>gt()(Ve([ie({_tag:Mt("Success"),value:o}),ie({_tag:Mt("Failure"),cause:Dd(s,i)})]),Rt({decode:a=>a._tag==="Success"?Pn(a.value):Jt(a.cause),encode:a=>Nt(a)?{_tag:"Success",value:a.value}:{_tag:"Failure",cause:a.cause}})),toArbitrary:([o,s,i])=>(a,c)=>{let u=kB(s,i)(a,c),f=MB(a,o.terminal?.map(p=>Pn(p)),u.terminal?.map(p=>Jt(p))),l=a.oneof(o.arbitrary.map(p=>Pn(p)),u.arbitrary.map(p=>Jt(p)));return Lf(a,c,f,l)},toEquivalence:([o,s,i])=>{let a=AB(s,i);return(c,u)=>{if(c._tag!==u._tag)return!1;switch(c._tag){case"Success":return o(c.value,u.value);case"Failure":return a(c.cause,u.cause)}}},toFormatter:([o,s,i])=>{let a=RB(s,i);return c=>{switch(c._tag){case"Success":return`Exit.Success(${o(c.value)})`;case"Failure":return`Exit.Failure(${a(c.cause)})`}}}});return se(r.ast,{value:e,error:t,defect:n})}var fee=zr("effect/schema/Exit",rt,({annotations:e,typeParameters:t})=>{let n=Yb(t[0],t[1],t[2]);return e===void 0?n:n.annotate(e)});function MB(e,t,n){return t===void 0?n:n===void 0?t:e.oneof(t,n)}function Lf(e,t,n,r){return{arbitrary:n===void 0||t.recursion===void 0?r:e.oneof(t.recursion,n,r),terminal:n}}function sj(e,t,n,r){return r===void 0?e.array(t,n):e.uniqueArray(t,{...n,comparator:r})}function Xb(e,t,n,r,o,s){let i=t.constraint,a=i===void 0||i.minLength===void 0&&i.maxLength===void 0?void 0:{...i.minLength!==void 0?{minLength:i.minLength}:{},...i.maxLength!==void 0?{maxLength:i.maxLength}:{}};if(a?.minLength!==void 0&&a.maxLength!==void 0&&a.minLength>a.maxLength)throw new globalThis.Error("Unable to derive an arbitrary for size constraints");let c=a?.minLength??0,u=c===0?e.constant([]):r===void 0?void 0:sj(e,r,{...a,maxLength:c},s),f=Lf(e,t,u,sj(e,n,a,s));return{arbitrary:f.arbitrary.map(o),terminal:f.terminal?.map(o)}}function PB(e,t,n,r,o){return Xb(e,t,e.tuple(n.arbitrary,r.arbitrary),n.terminal===void 0||r.terminal===void 0?void 0:e.tuple(n.terminal,r.terminal),o,([s],[i])=>ne(s,i))}function FB(e,t){let n=Dn()([e,t],([r,o])=>{let s=Xt(zc([r,o]));return(i,a,c)=>i instanceof globalThis.Map?mn(ut(s)([...i],c),{onSuccess:u=>new globalThis.Map(u),onFailure:u=>Zn(a,"entries",u,i,c)}):Q(new tt(a,i,c))},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.ReadonlyMap(${r[0].runtime}, ${r[1].runtime})`,Type:`globalThis.ReadonlyMap<${r[0].Type}, ${r[1].Type}>`}),expected:"ReadonlyMap",toCodec:([r,o])=>gt()(Xt(zc([r,o])),Rt({decode:s=>new globalThis.Map(s),encode:s=>[...s.entries()]})),toArbitrary:([r,o])=>(s,i)=>PB(s,i,r,o,a=>new globalThis.Map(a)),toEquivalence:([r,o])=>Sp(r,o),toFormatter:([r,o])=>s=>{let i=s.size;if(i===0)return"ReadonlyMap(0) {}";let a=globalThis.Array.from(s.entries()).sort().map(([c,u])=>`${r(c)} => ${o(u)}`);return`ReadonlyMap(${i}) { ${a.join(", ")} }`}});return se(n.ast,{key:e,value:t})}var lee=zr("effect/schema/ReadonlyMap",rt,({annotations:e,typeParameters:t})=>{let n=FB(t[0],t[1]);return e===void 0?n:n.annotate(e)});function ij(e,t,n){return ie({type:Mt(e),nodes:Xt(ie({index:dr,data:t})),edges:Xt(ie({index:dr,source:dr,target:dr,data:n}))})}function aj(e,t){let n=-1,r=new Set;for(let o=0;o<e.nodes.length;o++){let s=e.nodes[o].index;if(s<=n)return Q(new kt(["nodes",o,"index"],new Oe({expected:"a strictly increasing node index"},s,t)));n=s,r.add(s)}n=-1;for(let o=0;o<e.edges.length;o++){let s=e.edges[o];if(s.index<=n)return Q(new kt(["edges",o,"index"],new Oe({expected:"a strictly increasing edge index"},s.index,t)));if(n=s.index,!r.has(s.source))return Q(new kt(["edges",o,"source"],new Oe({expected:"an encoded node index"},s.source,t)));if(!r.has(s.target))return Q(new kt(["edges",o,"target"],new Oe({expected:"an encoded node index"},s.target,t)))}return k(hh(e))}function dee(e,t,n){return!dA(e)||e.mutable||e.type!==t?Q(new Oe({expected:`an immutable ${t} Graph`},e,n)):k(mh(e))}function pee(e,t){return(n,r)=>{let o=mh(n),s=mh(r);if(o.type!==s.type||o.nodes.length!==s.nodes.length||o.edges.length!==s.edges.length)return!1;for(let i=0;i<o.nodes.length;i++)if(o.nodes[i].index!==s.nodes[i].index||!e(o.nodes[i].data,s.nodes[i].data))return!1;for(let i=0;i<o.edges.length;i++){let a=o.edges[i],c=s.edges[i],u=o.type==="directed"?a.source===c.source&&a.target===c.target:a.source===c.source&&a.target===c.target||a.source===c.target&&a.target===c.source;if(a.index!==c.index||!u||!t(a.data,c.data))return!1}return!0}}function mee(e,t,n){return(r,o)=>{let s=hh({type:e,nodes:[],edges:[]}),i=r.constant(s),a=r.array(t.arbitrary).chain(c=>{let u=c.map((l,p)=>({index:p,data:l}));if(u.length===0)return i;let f=r.integer({min:0,max:u.length-1});return r.array(r.tuple(f,f,n.arbitrary)).map(l=>hh({type:e,nodes:u,edges:l.map(([p,h,g],x)=>({index:x,source:p,target:h,data:g}))}))});return Lf(r,o,i,a)}}function UB(e,t,n){let r=Dn()([t,n],([o,s])=>{let i=ij(e,o,s);return(a,c,u)=>!dA(a)||a.mutable||a.type!==e?Q(new tt(c,a,u)):_(ut(i)(mh(a),u),f=>aj(f,u))},{representation:{id:"effect/schema/Graph",payload:e},toCode:({typeParameters:o})=>({runtime:`Schema.Graph(${re(e)}, ${o[0].runtime}, ${o[1].runtime})`,Type:`Graph.Graph<${o[0].Type}, ${o[1].Type}, ${re(e)}>`,importDeclarations:['import * as Graph from "effect/Graph"']}),expected:`an immutable ${e} Graph`,toCodec:([o,s])=>gt()(ij(e,o,s),qr({decode:aj,encode:(i,a)=>dee(i,e,a)})),toArbitrary:([o,s])=>mee(e,o,s),toEquivalence:([o,s])=>pee(o,s),toFormatter:()=>globalThis.String});return se(r.ast,{type:e,node:t,edge:n})}var hee=zr("effect/schema/Graph",Ka(["directed","undirected"]),({annotations:e,payload:t,typeParameters:n})=>{let r=UB(t,n[0],n[1]);return e===void 0?r:r.annotate(e)});function NB(e,t){let n=Dn()([e,t],([r,o])=>{let s=Xt(zc([r,o]));return(i,a,c)=>Sb(i)?mn(ut(s)(Eb(i),c),{onSuccess:bb,onFailure:u=>Zn(a,"entries",u,i,c)}):Q(new tt(a,i,c))},{representation:{id:"effect/schema/HashMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.HashMap(${r[0].runtime}, ${r[1].runtime})`,Type:`HashMap.HashMap<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as HashMap from "effect/HashMap"']}),expected:"HashMap",toCodec:([r,o])=>gt()(Xt(zc([r,o])),Rt({decode:bb,encode:Eb})),toArbitrary:([r,o])=>(s,i)=>PB(s,i,r,o,bb),toEquivalence:([r,o])=>Sp(r,o),toFormatter:([r,o])=>s=>{let i=LL(s);if(i===0)return"HashMap(0) {}";let a=Eb(s).sort().map(([c,u])=>`${r(c)} => ${o(u)}`);return`HashMap(${i}) { ${a.join(", ")} }`}});return se(n.ast,{key:e,value:t})}var gee=zr("effect/schema/HashMap",rt,({annotations:e,typeParameters:t})=>{let n=NB(t[0],t[1]);return e===void 0?n:n.annotate(e)});function DB(e){let t=Dn()([e],([n])=>{let r=Xt(n);return(o,s,i)=>o instanceof globalThis.Set?mn(ut(r)([...o],i),{onSuccess:a=>new globalThis.Set(a),onFailure:a=>Zn(s,"values",a,o,i)}):Q(new tt(s,o,i))},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.ReadonlySet(${n[0].runtime})`,Type:`globalThis.ReadonlySet<${n[0].Type}>`}),expected:"ReadonlySet",toCodec:([n])=>gt()(Xt(n),Rt({decode:r=>new globalThis.Set(r),encode:r=>[...r.values()]})),toArbitrary:([n])=>(r,o)=>Xb(r,o,n.arbitrary,n.terminal,s=>new globalThis.Set(s),ne),toEquivalence:([n])=>bp(n),toFormatter:([n])=>r=>{let o=r.size;if(o===0)return"ReadonlySet(0) {}";let s=globalThis.Array.from(r.values()).sort().map(i=>`${n(i)}`);return`ReadonlySet(${o}) { ${s.join(", ")} }`}});return se(t.ast,{value:e})}var xee=zr("effect/schema/ReadonlySet",rt,({annotations:e,typeParameters:t})=>{let n=DB(t[0]);return e===void 0?n:n.annotate(e)});function LB(e){let t=Dn()([e],([n])=>{let r=Xt(n);return(o,s,i)=>Tb(o)?mn(ut(r)(St(o),i),{onSuccess:vb,onFailure:a=>Zn(s,"values",a,o,i)}):Q(new tt(s,o,i))},{representation:{id:"effect/schema/HashSet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.HashSet(${n[0].runtime})`,Type:`HashSet.HashSet<${n[0].Type}>`}),expected:"HashSet",toCodec:([n])=>gt()(Xt(n),Rt({decode:vb,encode:St})),toArbitrary:([n])=>(r,o)=>Xb(r,o,n.arbitrary,n.terminal,vb,ne),toEquivalence:([n])=>bp(n),toFormatter:([n])=>r=>{let o=$L(r);if(o===0)return"HashSet(0) {}";let s=globalThis.Array.from(r).sort().map(i=>`${n(i)}`);return`HashSet(${o}) { ${s.join(", ")} }`}});return se(t.ast,{value:e})}var yee=zr("effect/schema/HashSet",rt,({annotations:e,typeParameters:t})=>{let n=LB(t[0]);return e===void 0?n:n.annotate(e)});function qB(e){let t=Dn()([e],([n])=>{let r=Xt(n);return(o,s,i)=>gd(o)?mn(ut(r)(St(o),i),{onSuccess:LS,onFailure:a=>Zn(s,"values",a,o,i)}):Q(new tt(s,o,i))},{representation:{id:"effect/schema/Chunk",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Chunk(${n[0].runtime})`,Type:`Chunk.Chunk<${n[0].Type}>`}),expected:"Chunk",toCodec:([n])=>gt()(Xt(n),Rt({decode:LS,encode:St})),toArbitrary:([n])=>(r,o)=>Xb(r,o,n.arbitrary,n.terminal,LS),toEquivalence:([n])=>wk(n),toFormatter:([n])=>r=>{let o=t2(r);if(o===0)return"Chunk(0) {}";let s=globalThis.Array.from(r).sort().map(i=>`${n(i)}`);return`Chunk(${o}) { ${s.join(", ")} }`}});return se(t.ast,{value:e})}var See=zr("effect/schema/Chunk",rt,({annotations:e,typeParameters:t})=>{let n=qB(t[0]);return e===void 0?n:n.annotate(e)}),jB=Jc(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),expected:"RegExp",toCodecJson:()=>gt()(ie({source:de,flags:de}),qr({decode:(e,t)=>ts({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new Oe({expected:"valid RegExp source and flags"},e,t)}),encode:e=>k({source:e.source,flags:e.flags})})),toArbitrary:()=>e=>e.tuple(e.constantFrom(".",".*","\\d+","\\w+","[a-z]+","[A-Z]+","[0-9]+","^[a-zA-Z0-9]+$","^\\d{4}-\\d{2}-\\d{2}$"),e.uniqueArray(e.constantFrom("g","i","m","s","u","y"),{minLength:0,maxLength:6}).map(t=>t.join(""))).map(([t,n])=>new globalThis.RegExp(t,n)),toEquivalence:()=>(e,t)=>e.source===t.source&&e.flags===t.flags}),bee=Tr("effect/schema/RegExp",jB),BB=de.annotate({expected:"a string that will be decoded as a URL"}),mR=Jc(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),expected:"URL",toCodecJson:()=>gt()(BB,PI),toArbitrary:()=>e=>e.webUrl().map(t=>new globalThis.URL(t)),toEquivalence:()=>(e,t)=>e.toString()===t.toString()}),Eee=Tr("effect/schema/URL",mR),wee=BB.pipe(ve(mR,PI));function hR(e,t,n){let r={...t};if(e?.minimum!==void 0){let o=n===void 0?e.minimum:n(e.minimum),s=e.exclusiveMinimum?new globalThis.Date(o.getTime()+1):o;(r.min===void 0||s.getTime()>r.min.getTime())&&(r.min=s)}if(e?.maximum!==void 0){let o=n===void 0?e.maximum:n(e.maximum),s=e.exclusiveMaximum?new globalThis.Date(o.getTime()-1):o;(r.max===void 0||s.getTime()<r.max.getTime())&&(r.max=s)}return r}var $B=de.annotate({expected:"a string that will be decoded as a Date"}),ii=po(e=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),expected:"a valid Date",toCodecJson:()=>gt()($B,MI),toArbitrary:()=>(e,t)=>e.date(hR(t?.constraint?.ordered?.order===Iu?t.constraint.ordered:void 0,{noInvalidDate:!0}))}),vee=Tr("effect/schema/Date",ii),Tee=$B.pipe(ve(ii,MI)),Iee=ai.pipe(ve(ii,iD)),$h=po(Cu,{representation:{id:"effect/schema/Duration",payload:null},toCode:()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),expected:"Duration",toCodecJson:()=>gt()(Ve([ie({_tag:Mt("Infinity")}),ie({_tag:Mt("NegativeInfinity")}),ie({_tag:Mt("Nanos"),value:Bi}),ie({_tag:Mt("Millis"),value:ai})]),Rt({decode:e=>{switch(e._tag){case"Infinity":return Io;case"NegativeInfinity":return ha;case"Nanos":return Qr(e.value);case"Millis":return As(e.value)}},encode:e=>{switch(e.value._tag){case"Infinity":return{_tag:"Infinity"};case"NegativeInfinity":return{_tag:"NegativeInfinity"};case"Nanos":return{_tag:"Nanos",value:e.value.nanos};case"Millis":return{_tag:"Millis",value:e.value.millis}}}})),toArbitrary:()=>e=>e.oneof(e.constant(Io),e.constant(ha),e.bigInt().map(Qr),e.maxSafeInteger().map(As)),toFormatter:()=>globalThis.String,toEquivalence:()=>Bw}),kee=Tr("effect/schema/Duration",$h),Aee=de.annotate({expected:"a string that will be decoded as a Duration"}),Ree=Aee.pipe(ve($h,aD)),Cee=Bi.pipe(ve($h,cD)),Oee=jd.pipe(ve($h,uD)),HB=de.annotate({expected:"a string that will be decoded as a BigDecimal"}),zB=20,WB="Unable to derive an arbitrary for the ordered BigDecimal constraints";function Wb(e,t){return mc(e,t).value}function _ee(e,t,n){return n?Wb(_w(e,t),t)+globalThis.BigInt(1):Wb(Ow(e,t),t)}function Mee(e,t,n){return n?Wb(Ow(e,t),t)-globalThis.BigInt(1):Wb(_w(e,t),t)}function Pee(e){return Math.max(zB,e.minimum?.scale??0,e.maximum?.scale??0,e.exclusiveMinimum&&e.minimum!==void 0?e.minimum.scale+1:0,e.exclusiveMaximum&&e.maximum!==void 0?e.maximum.scale+1:0)}function GA(e,t){let n={};if(e.minimum!==void 0&&(n.min=_ee(e.minimum,t,e.exclusiveMinimum===!0)),e.maximum!==void 0&&(n.max=Mee(e.maximum,t,e.exclusiveMaximum===!0)),!(n.min!==void 0&&n.max!==void 0&&n.min>n.max))return n}function Fee(e){let t=Pee(e);if(GA(e,t)===void 0)throw new globalThis.Error(WB);let n=0,r=t;for(;n<r;){let o=n+Math.floor((r-n)/2);GA(e,o)===void 0?n=o+1:r=o}return{min:n,max:t}}var gR=po(hc,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),expected:"BigDecimal",toCodecJson:()=>gt()(HB,FI),toArbitrary:()=>(e,t)=>{let n=t.constraint?.ordered?.order===la?t.constraint.ordered:void 0;return n===void 0?e.tuple(e.bigInt(),e.integer({min:0,max:zB})).map(([r,o])=>gr(r,o)):e.integer(Fee(n)).chain(r=>{let o=GA(n,r);if(o===void 0)throw new globalThis.Error(WB);return e.bigInt(o).map(s=>gr(s,r))})},toFormatter:()=>e=>gi(e),toEquivalence:()=>Rw}),Uee=Tr("effect/schema/BigDecimal",gR),Nee=HB.pipe(ve(gR,FI)),Dee=de.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function KB(e,t){return Dee.pipe(ve(e,TD(t)))}var Lee=KB(eR),xR=Jc(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:()=>({runtime:"Schema.File",Type:"globalThis.File"}),expected:"File",toCodecJson:()=>gt()(ie({data:de.check(cR()),type:de,name:de,lastModified:ai}),qr({decode:(e,t)=>Zr(Al(e.data),{onFailure:()=>Q(new Oe({expected:"a valid Base64 string"},e.data,t)),onSuccess:n=>{let r=new globalThis.Uint8Array(n);return k(new globalThis.File([r],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>qs({try:async()=>{let n=new globalThis.Uint8Array(await e.arrayBuffer());return{data:wx(n),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new Oe({expected:"a readable File"},e,t)})}))}),qee=Tr("effect/schema/File",xR),yR=Jc(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),expected:"FormData",toCodecJson:()=>gt()(Xt(zc([de,Ve([ie({_tag:Ye("String"),value:de}),ie({_tag:Ye("File"),value:xR})])])),qr({decode:e=>{let t=new globalThis.FormData;for(let[n,r]of e)t.append(n,r.value);return k(t)},encode:e=>k(globalThis.Array.from(e.entries()).map(([t,n])=>typeof n=="string"?[t,{_tag:"String",value:n}]:[t,{_tag:"File",value:n}]))}))}),jee=Tr("effect/schema/FormData",yR);function Bee(e){return yR.pipe(ve(e,ID))}var SR=Jc(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),expected:"URLSearchParams",toCodecJson:()=>gt()(de.annotate({expected:"a query string that will be decoded as URLSearchParams"}),Rt({decode:e=>new globalThis.URLSearchParams(e),encode:e=>e.toString()}))}),$ee=Tr("effect/schema/URLSearchParams",SR);function Hee(e){return SR.pipe(ve(e,kD))}var zee=de.annotate({expected:"a string that will be decoded as a number"}).pipe(ve(jd,ad)),Wee=de.annotate({expected:"a string that will be decoded as a finite number"}).pipe(ve(si,ad)),Kee=se(MS).pipe(ve(Bi,oS)),VB=de.check(aR()),Vee=de.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(ve(VB,sD())),Jee=de.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(ve(de,bD)),Gee=de.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(ve(de,ED)),Zee=de.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(ve(de,wD)),Qee=de.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(ve(de,vD)),ZA=Ve([si,vj,de]),Yee=ie({issues:Xt(ie({message:de,path:Bt(Xt(Ve([ZA,ie({key:ZA})])))}))}),Xee=Ka([0,1]).pipe(ve(Kc,Rt({decode:e=>e===1,encode:e=>e?1:0}))),JB=de.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),ps=Jc(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>gt()(JB,UI),toArbitrary:()=>e=>e.uint8Array()}),ete=Tr("effect/schema/Uint8Array",ps),tte=JB.pipe(ve(ps,UI)),nte=de.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(ve(ps,{decode:VN(),encode:Xy()})),rte=de.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(ve(ps,{decode:GN(),encode:eS()})),Hh=po(e=>uf(e)&&ON(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Utc",toCodecJson:()=>gt()(de,LI),toArbitrary:()=>(e,t)=>e.date(hR(t?.constraint?.ordered?.order===TI?t.constraint.ordered:void 0,{noInvalidDate:!0},Gy)).map(n=>MN(n)),toFormatter:()=>e=>e.toString(),toEquivalence:()=>vI}),ote=Tr("effect/schema/DateTimeUtc",Hh),ste=ii.pipe(ve(Hh,{decode:_I(),encode:Le(Gy)})),ite=de.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(ve(Hh,LI)),ate=ai.pipe(ve(Hh,{decode:_I(),encode:Le(DN)})),GB=po(RN,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Offset",toCodecJson:()=>gt()(ai,AD),toArbitrary:()=>e=>e.integer({min:-720*60*1e3,max:840*60*1e3}).map(t=>_m(t)),toFormatter:()=>e=>Fc(e),toEquivalence:()=>(e,t)=>e.offset===t.offset}),cte=Tr("effect/schema/TimeZoneOffset",GB),ZB=de.annotate({expected:"an IANA time zone identifier"}),bR=po(CN,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Named",toCodecJson:()=>gt()(ZB,NI),toArbitrary:()=>e=>e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(II)),toFormatter:()=>e=>Fc(e),toEquivalence:()=>(e,t)=>e.id===t.id}),ute=Tr("effect/schema/TimeZoneNamed",bR),fte=ZB.pipe(ve(bR,NI)),QB=de.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),ER=po(AN,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone",toCodecJson:()=>gt()(QB,DI),toArbitrary:()=>e=>e.oneof(e.integer({min:-720*60*1e3,max:840*60*1e3}).map(t=>_m(t)),e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(II))),toFormatter:()=>e=>Fc(e),toEquivalence:()=>(e,t)=>Fc(e)===Fc(t)}),lte=Tr("effect/schema/TimeZone",ER),dte=QB.pipe(ve(ER,DI)),YB=de.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),wR=po(e=>uf(e)&&_N(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Zoned",toCodecJson:()=>gt()(YB,qI),toArbitrary:()=>(e,t)=>e.tuple(e.date(hR(t?.constraint?.ordered?.order===TI?t.constraint.ordered:void 0,{max:new globalThis.Date(864e13-840*60*1e3),min:new globalThis.Date(-864e13+840*60*1e3),noInvalidDate:!0},Gy)),e.constantFrom("UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney")).map(([n,r])=>Ky(n,{timeZone:r})),toFormatter:()=>e=>Zy(e),toEquivalence:()=>vI}),pte=Tr("effect/schema/DateTimeZoned",wR),mte=YB.pipe(ve(wR,qI)),hte=globalThis.Symbol.for("immer-draftable"),QA={};function vR(e,t,n,r,o){let s=xte(n,t,r),i=XB(t),a=class extends e{constructor(...[c,u]){let l=u?.["~payload"],p=l?.token===QA?l.value:n.make(c??{},u);super(p,{...u,disableChecks:!0,"~payload":{token:QA,value:p}})}static[_h]=_h;get[i](){return i}static[hte]=!0;static identifier=t;static fields=n.fields;static get ast(){return s(this).ast}static pipe(){return ce(this,arguments)}static rebuild(c){return s(this).rebuild(c)}static make(c,u){return new this(c,u)}static makeOption(c,u){return wh(s(this))(c??{},u)}static makeEffect(c,u){return s(this).makeEffect(c??{},u)}static annotate(c){return this.rebuild(Mo(this.ast,c))}static annotateKey(c){return this.rebuild(gf(this.ast,c))}static check(...c){return this.rebuild(Vs(this.ast,c))}static extend(c){return(u,f)=>{let l=zh(u)?u:ie(u),p={...n.fields,...l.fields},h=Wm(p,n.ast.checks,{identifier:c});return vR(this,c,nR(Vs(h,l.ast.checks),p),f,o)}}static mapFields(c,u){return n.mapFields(c,u)}};return o!==void 0&&Object.assign(a.prototype,o(t)),a}function gte(e){return new nt(Le(t=>new e(t,{"~payload":{token:QA,value:t}})),Ws())}function XB(e){return`~effect/Schema/Class/${e}`}function xte(e,t,n){let r;return o=>{if(r!==void 0)return r;let s=XB(t),i=u=>u instanceof o||N(u,s),a=gte(o),c=se(new Pi([e.ast],()=>(u,f,l)=>i(u)?k(u):Q(new tt(f,u,l)),{identifier:t,[jy]:([u])=>({isConstructed:i,link:new jt(u,a)}),toCodec:([u])=>new jt(u.ast,a),toArbitrary:([u])=>()=>({arbitrary:u.arbitrary.map(f=>new o(f)),terminal:u.terminal?.map(f=>new o(f))}),toFormatter:([u])=>f=>`${o.identifier}(${u(f)})`,[vm]:Ma(e.ast),...n}));return r=ve(c,a)(e)}}function zh(e){return Nf(e)}var eE=e=>(t,n)=>{let r=zh(t)?t:ie(t);return vR(bx,e,r,n,o=>({toString(){return`${o}(${re({...this})})`}}))},yte=e=>(t,n,r)=>{let o=zh(n)?n.mapFields(s=>({_tag:Ye(t),...s}),{unsafePreserveChecks:!0}):Vc(t,n);return eE(e??t)(o,r)},Yn=e=>(t,n)=>{let r=zh(t)?t:ie(t);return vR(Ip,e,r,n,s=>({name:s}))},TR=e=>(t,n,r)=>{let o=zh(n)?n.mapFields(s=>({_tag:Ye(t),...s}),{unsafePreserveChecks:!0}):Vc(t,n);return Yn(e??t)(o,r)};function Ste(e){let t=bq(e.ast);return n=>t(n,{})}function bte(e){return t=>t.annotate({toFormatter:e})}function Ete(e,t){return n(e.ast);function n(o){let s=Hs(o)?.toFormatter;if(typeof s=="function")return s(Pa(o)?o.typeParameters.map(n):[]);if(t?.onBefore){let i=t.onBefore(o,n);if(i!==void 0)return i}return r(o)}function r(o){switch(o._tag){default:return re;case"Never":return()=>"never";case"Void":return()=>"void";case"Arrays":{let s=o.elements.map(n),i=o.rest.map(n);return a=>{let c=[],u=0;for(;u<s.length;u++)if(a.length<u+1){if(nn(o.elements[u]))continue}else c.push(s[u](a[u]));if(i.length>0){let[f,...l]=i;for(;u<a.length-l.length;u++)c.push(f(a[u]));for(let p=0;p<l.length;p++)c.push(l[p](a[u+p]))}return"["+c.join(", ")+"]"}}case"Objects":{let s=o.propertySignatures.map(a=>n(a.type)),i=o.indexSignatures.map(a=>n(a.type));return o.propertySignatures.length===0&&o.indexSignatures.length===0?re:a=>{let c=[],u=new Set;for(let f=0;f<s.length;f++){let l=o.propertySignatures[f],p=l.name;u.add(p),!(nn(l.type)&&!Object.hasOwn(a,p))&&c.push(`${sa(p)}: ${s[f](a[p])}`)}for(let f=0;f<i.length;f++){let l=Ui(a,o.indexSignatures[f].parameter);for(let p of l)u.has(p)||(u.add(p),c.push(`${sa(p)}: ${i[f](a[p])}`))}return c.length>0?"{ "+c.join(", ")+" }":"{}"}}case"Union":{let s=hn(o).types,i=c=>ld(c,s),a=new Map(s.map((c,u)=>[c,[kd(c),n(o.types[u])]]));return c=>{let u=i(c);for(let f=0;f<u.length;f++){let[l,p]=a.get(u[f]);if(l(c))return p(c)}return re(c)}}case"Suspend":{let s=Dc(()=>n(o.thunk()));return i=>s()(i)}}}}function wte(e){return t=>t.annotate({toEquivalence:e})}function vte(e){return Eq(e.ast)}function Tte(e,t){return $A(e.ast,t)}function e$(e,t){let n=$A(tE(e.ast),t);return Nq(n,t)}function Gc(e){return se(tE(e.ast),{schema:e})}var tE=Ni(e=>{let t=kte(e,tE),n=e.context;return t===e||n===void 0?t:hf(t,IR(n))});function IR(e){return e.constructorDefault===void 0?e:new Br(e.isOptional,e.isMutable,void 0,e.annotations)}function t$(e){if(e.propertySignatures.some(t=>typeof t.name!="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function n$(e){return t=>{let n=new Map;for(let s=0;s<t.length;s++)n.set(Nn(t[s]),s);let r=[...t].sort((s,i)=>{s=Nn(s),i=Nn(i);let a=e(s),c=e(i);return a!==c?a-c:n.get(s)-n.get(i)});return r.some((s,i)=>s!==t[i])?r:t}}var Ite=n$(e=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function kte(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Ft(n))return ct(e,[FS]);let r=e.typeParameters.map(s=>Th(Nn(s))),o=n(r);return o===void 0?e:ct(e,[Fa(o,t)])}case"Unknown":return ct(e,[FS]);case"ObjectKeyword":return ct(e,[Sk]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return t$(e),e.recur(t,Xm);case"Union":{let n=Ite(e.types);return n!==e.types?new br(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function r$(e){return se(o$(hn(e.ast)))}var o$=bn(e=>{let t=Ate(e,o$);return t!==e&&e.context!==void 0?hf(t,IR(e.context)):t});function Ate(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecIso??e.annotations?.toCodec;if(Ft(n)){let r=n(e.typeParameters.map(o=>Th(o)));return ct(e,[Fa(r,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}function s$(e){return se(c$(e.ast),{schema:e})}function Rte(e){return se(u$(e.ast))}function Cte(e,t){let n=sf(e.ast)??By(e.ast),r=Vb(s$(e));return o=>r(o).pipe(te(s=>Ote(s,{rootName:n,...t})))}function Ote(e,t){let n=t.rootName??"root",r=t.arrayItemName??"item",o=t.pretty??!0,s=t.indent??" ",i=t.sortKeys??!0,a=new Set,c=[];return f(n,e,0),c.join(o?`
32
- `:"");function u(l,p){c.push(o?s.repeat(l)+p:p)}function f(l,p,h,g){let{attrs:x,safe:S}=Pd.tagInfo(l,g);if(p===void 0)u(h,`<${S}${x}/>`);else if(typeof p=="string")u(h,`<${S}${x}>${Pd.escapeText(p)}</${S}>`);else if(typeof p!="object"||p===null)u(h,`<${S}${x}>${Pd.escapeText(re(p))}</${S}>`);else{if(a.has(p))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:p});a.add(p);try{if(globalThis.globalThis.Array.isArray(p)){if(p.length===0){u(h,`<${S}${x}/>`);return}u(h,`<${S}${x}>`);for(let y of p)f(r,y,h+1);u(h,`</${S}>`);return}let w=p,E=Object.keys(w);if(i&&E.sort(),E.length===0){u(h,`<${S}${x}/>`);return}u(h,`<${S}${x}>`);for(let y of E)f(Pd.parseTagName(y).safe,w[y],h+1,y);u(h,`</${S}>`)}finally{a.delete(p)}}}}var Pd={escapeText(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},escapeAttribute(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},parseTagName(e){let t=e,n=e;return/^[A-Za-z_]/.test(n)||(n="_"+n),n=n.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(n)&&(n="_"+n),{safe:n,changed:n!==t}},tagInfo(e,t){let{changed:n,safe:r}=Pd.parseTagName(e),s=n||t&&t!==e?` data-name="${Pd.escapeAttribute(t??e)}"`:"";return{safe:r,attrs:s}}},_te=n$(e=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function Mte(e,t,n){switch(e._tag){case"Declaration":{let r=e.typeParameters.map(u=>se(t(Nn(u)))),o=e.annotations?.toCodecStringTree;if(Ft(o)){let u=o(r);return u===void 0?e:ct(e,[Fa(u,t)])}let s=e.annotations?.toCodecJson,i=Ft(s)?s(r):void 0,a=i===void 0?e.annotations?.toCodec:void 0,c=i??(Ft(a)?a(r):void 0);return c===void 0?n(e):ct(e,[Fa(c,t)])}case"Null":return ct(e,[Pte]);case"Boolean":return ct(e,[Fte]);case"Unknown":case"ObjectKeyword":return ct(e,[US]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return t$(e),e.recur(t,Xm);case"Union":{let r=_te(e.types);return r!==e.types?new br(r,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var Pte=new jt(new jr("null"),new nt(Le(()=>null),Le(()=>"null"))),Fte=new jt(new br([new jr("true"),new jr("false")],"anyOf"),new nt(Le(e=>e==="true"),ff())),i$=new nt(Le(e=>typeof e=="string"?[e]:e),Ws()),a$=e=>e.transformation===i$,c$=Ni(e=>{let t=Mte(e,c$,n=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:n})});return t!==e&&e.context!==void 0?hf(t,IR(e.context)):t},{stopAt:a$}),cj=e=>nn(e)?xf(Fi):Fi,u$=Ni(e=>{let t=Ute(e);if(SS(t)){let n=Ym(new br([new as(t.isMutable,t.elements.map(cj),t.rest.map(cj)),Ks],"anyOf"),t,i$);return nn(e)?xf(n):n}return t},{stopAt:a$});function Ute(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur(u$):e}var Nte=Me("effect/schema/isGreaterThanDate",ie({exclusiveMinimum:ii}),({annotations:e,payload:t})=>rB(t.exclusiveMinimum,e)),Dte=Me("effect/schema/isGreaterThanOrEqualToDate",ie({minimum:ii}),({annotations:e,payload:t})=>oB(t.minimum,e)),Lte=Me("effect/schema/isLessThanDate",ie({exclusiveMaximum:ii}),({annotations:e,payload:t})=>sB(t.exclusiveMaximum,e)),qte=Me("effect/schema/isLessThanOrEqualToDate",ie({maximum:ii}),({annotations:e,payload:t})=>iB(t.maximum,e)),jte=Me("effect/schema/isBetweenDate",ie({minimum:ii,maximum:ii,exclusiveMinimum:Bt(Mt(!0)),exclusiveMaximum:Bt(Mt(!0))}),({annotations:e,payload:t})=>aB(t,e)),Bte=Me("effect/schema/isGreaterThanBigInt",ie({exclusiveMinimum:Bi}),({annotations:e,payload:t})=>cB(t.exclusiveMinimum,e)),$te=Me("effect/schema/isGreaterThanOrEqualToBigInt",ie({minimum:Bi}),({annotations:e,payload:t})=>uB(t.minimum,e)),Hte=Me("effect/schema/isLessThanBigInt",ie({exclusiveMaximum:Bi}),({annotations:e,payload:t})=>fB(t.exclusiveMaximum,e)),zte=Me("effect/schema/isLessThanOrEqualToBigInt",ie({maximum:Bi}),({annotations:e,payload:t})=>lB(t.maximum,e)),Wte=Me("effect/schema/isBetweenBigInt",ie({minimum:Bi,maximum:Bi,exclusiveMinimum:Bt(Mt(!0)),exclusiveMaximum:Bt(Mt(!0))}),({annotations:e,payload:t})=>dB(t,e));function Kte(e){let t=r$(e);return zq(Mb(t),Rb(t))}function Vte(e){return $b()}function Jte(e){return $b()}function Gte(e,t){return n=>se(Mo(n.ast,{toCodecIso:()=>new jt(e.ast,nS(t))}),{schema:n})}function Zte(e){let t=Gc(e),n=Mb(t),r=Rb(t);return{empty:[],diff:(o,s)=>Lq(n(o),n(s)),combine:(o,s)=>[...o,...s],patch:(o,s)=>{let i=n(o),a=qq(s,i);return Object.is(a,i)?o:r(a)}}}function Qte(e){let t=Aj(()=>n),n=Ve([e,Xt(t),rR(de,t)]);return n}var Wh=se(Mo(mf,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})})),Yte=rR(de,Wh),Xte=Tr("effect/schema/Json",Wh),ene=ie({message:de,name:Uf(de),stack:Uf(de),cause:Uf(Wh)}),f$=se(Mo(yk,{toCode:()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"})})),tne=Tr("effect/schema/MutableJson",f$);function nne(e){return Hs(e.ast)}function rne(e){return e.ast.context?.annotations}var one="~effect/Stream",sne={_R:j,_E:j,_A:j},ine={[one]:sne,pipe(){return ce(this,arguments)}},l$=e=>{let t=Object.create(ine);return t.channel=e,t};var cne="~effect/Sink";var une={_A:j,_In:j,_L:j,_E:j,_R:j},fne={[cne]:une,pipe(){return ce(this,arguments)}};var lne=e=>{let t=Object.create(fne);return t.transform=e,t},d$=e=>Qe((t,n)=>k(_(e.transform(t,n),he)));var p$=e=>lne(t=>{let n=[];if(e<=0)return k([n]);let r;return t.pipe(_(o=>{if(n.length+o.length<=e)return n.push(...o),n.length===e?he():W;for(let s=0;s<o.length;s++)if(n.push(o[s]),n.length===e)return s+1<o.length&&(r=o.slice(s+1)),he();return W}),Qt({disableYield:!0}),Gt(()=>k([n,r])))});var pr={};dn(pr,{DefaultChunkSize:()=>I$,Do:()=>$oe,TypeId:()=>T$,accumulate:()=>Roe,aggregate:()=>boe,aggregateWithin:()=>jR,bind:()=>zoe,bindEffect:()=>Woe,bindTo:()=>Koe,broadcast:()=>Q$,broadcastN:()=>Eoe,buffer:()=>Ore,bufferArray:()=>_re,callback:()=>rE,catch:()=>Jh,catchCause:()=>N$,catchCauseFilter:()=>Lre,catchCauseIf:()=>Dre,catchFilter:()=>q$,catchIf:()=>L$,catchReason:()=>Ure,catchReasons:()=>Nre,catchTag:()=>Pre,catchTags:()=>Fre,changes:()=>Y$,changesWith:()=>X$,changesWithEffect:()=>Coe,chunks:()=>K$,collect:()=>Aoe,combine:()=>roe,combineArray:()=>ooe,concat:()=>Kh,cross:()=>fre,crossWith:()=>F$,debounce:()=>foe,decodeText:()=>Ooe,die:()=>kne,drain:()=>Zne,drainFork:()=>Qne,drop:()=>qR,dropRight:()=>eoe,dropUntil:()=>Qre,dropUntilEffect:()=>Yre,dropWhile:()=>z$,dropWhileEffect:()=>W$,dropWhileFilter:()=>Xre,empty:()=>Wi,encodeText:()=>_oe,ensuring:()=>Gh,fail:()=>qf,failCause:()=>R$,failCauseSync:()=>Ane,failSync:()=>Ine,filter:()=>DR,filterEffect:()=>Tre,filterMap:()=>vre,filterMapEffect:()=>Ire,flatMap:()=>Hd,flatten:()=>PR,flattenArray:()=>Gne,flattenEffect:()=>Hne,flattenIterable:()=>rre,flattenTake:()=>ore,forever:()=>nre,fromArray:()=>Vh,fromArrayEffect:()=>_ne,fromArrays:()=>Mne,fromAsyncIterable:()=>Pne,fromChannel:()=>$,fromEffect:()=>nE,fromEffectDrain:()=>k$,fromEffectRepeat:()=>A$,fromEffectSchedule:()=>Ene,fromEventListener:()=>Nne,fromIterable:()=>jf,fromIterableEffect:()=>Cne,fromIterableEffectRepeat:()=>One,fromIteratorSucceed:()=>Rne,fromPubSub:()=>_R,fromPubSubTake:()=>C$,fromPull:()=>ci,fromQueue:()=>zi,fromReadableStream:()=>MR,fromSchedule:()=>Fne,fromSubscription:()=>Une,groupAdjacentBy:()=>yoe,groupBy:()=>goe,groupByKey:()=>xoe,grouped:()=>moe,groupedWithin:()=>hoe,haltWhen:()=>Noe,ignore:()=>$re,ignoreCause:()=>Hre,interleave:()=>Foe,interleaveWith:()=>tH,interruptWhen:()=>Uoe,intersperse:()=>eH,intersperseAffixes:()=>Poe,isStream:()=>Ne,iterate:()=>Lne,let:()=>Hoe,limitBytes:()=>Vre,make:()=>vne,map:()=>Uo,mapAccum:()=>soe,mapAccumArray:()=>$f,mapAccumArrayEffect:()=>aoe,mapAccumEffect:()=>ioe,mapArray:()=>_$,mapArrayEffect:()=>zne,mapBoth:()=>$ne,mapEffect:()=>Bf,mapError:()=>j$,merge:()=>FR,mergeAll:()=>ure,mergeEffect:()=>oE,mergeLeft:()=>are,mergeResult:()=>ire,mergeRight:()=>cre,mkArrayBuffer:()=>nse,mkString:()=>tse,mkUint8Array:()=>rse,never:()=>jne,onEnd:()=>Loe,onError:()=>Doe,onExit:()=>nH,onFirst:()=>oH,onStart:()=>rH,orDie:()=>Bre,orElseIfEmpty:()=>qre,orElseSucceed:()=>jre,paginate:()=>Dne,partition:()=>Are,partitionEffect:()=>kre,partitionQueue:()=>LR,peel:()=>Cre,pipeThrough:()=>koe,pipeThroughChannel:()=>Toe,pipeThroughChannelOrFail:()=>Ioe,prepend:()=>sre,provide:()=>sH,provideContext:()=>BR,provideService:()=>qoe,provideServiceEffect:()=>$R,race:()=>wre,raceAll:()=>U$,range:()=>qne,rechunk:()=>V$,repeat:()=>Yne,repeatElements:()=>tre,result:()=>Wne,retry:()=>zre,run:()=>aH,runCollect:()=>cH,runCount:()=>Voe,runDrain:()=>iE,runFold:()=>Goe,runFoldEffect:()=>Zoe,runForEach:()=>Xoe,runForEachArray:()=>zd,runForEachWhile:()=>ese,runHead:()=>Qoe,runIntoPubSub:()=>ase,runIntoQueue:()=>fse,runLast:()=>Yoe,runSum:()=>Joe,scan:()=>coe,scanEffect:()=>uoe,schedule:()=>Xne,scoped:()=>Bne,service:()=>Sne,serviceOption:()=>bne,share:()=>voe,sliding:()=>toe,slidingSize:()=>J$,split:()=>noe,splitLines:()=>Moe,succeed:()=>$d,suspend:()=>Vr,switchMap:()=>Jne,sync:()=>Tne,take:()=>Kre,takeRight:()=>Jre,takeUntil:()=>B$,takeUntilEffect:()=>$$,takeWhile:()=>H$,takeWhileEffect:()=>Zre,takeWhileFilter:()=>Gre,tap:()=>M$,tapBoth:()=>Kne,tapCause:()=>Mre,tapError:()=>D$,tapSink:()=>Vne,throttle:()=>poe,throttleEffect:()=>G$,tick:()=>wne,timeout:()=>ere,timeoutOrElse:()=>P$,toAsyncIterable:()=>ise,toAsyncIterableEffect:()=>sse,toAsyncIterableWith:()=>KR,toChannel:()=>ms,toPubSub:()=>cse,toPubSubTake:()=>uH,toPull:()=>HR,toQueue:()=>use,toReadableStream:()=>ose,toReadableStreamEffect:()=>WR,toReadableStreamWith:()=>zR,transduce:()=>Soe,transformPull:()=>An,transformPullBracket:()=>OR,unfold:()=>O$,unwrap:()=>Ir,updateContext:()=>iH,updateService:()=>joe,when:()=>Rre,withExecutionPlan:()=>Wre,withSpan:()=>Boe,zip:()=>dre,zipFlatten:()=>hre,zipLatest:()=>bre,zipLatestAll:()=>NR,zipLatestWith:()=>Ere,zipLeft:()=>pre,zipRight:()=>mre,zipWith:()=>UR,zipWithArray:()=>sE,zipWithIndex:()=>gre,zipWithNext:()=>xre,zipWithPrevious:()=>yre,zipWithPreviousAndNext:()=>Sre});var h$="~effect/RcMap",dne=e=>({[h$]:h$,lookup:e.lookup,context:e.context,scope:e.scope,idleTimeToLive:e.idleTimeToLive,capacity:e.capacity,state:{_tag:"Open",map:Lc()},pipe(){return ce(this,arguments)}}),g$=e=>kn(t=>{let n=t.context,r=ze(n,mt),o=dne({lookup:e.lookup,context:n,scope:r,idleTimeToLive:typeof e.idleTimeToLive=="function"?lu(e.idleTimeToLive,pt):Xe(pt(e.idleTimeToLive??ma)),capacity:Math.max(e.capacity??Number.POSITIVE_INFINITY,0)});return Zt(Yo(r,()=>{if(o.state._tag==="Closed")return W;let s=o.state.map;return o.state={_tag:"Closed"},es(s,([,i])=>so(Ze(i.scope,en))).pipe(qt(()=>ae(()=>{NS(s)})))}),o)}),kR=d(2,(e,t)=>Oo(n=>{if(e.state._tag==="Closed")return Co;let r=e.state,o=Di(),s=Gs(r.map,t),i;if(s._tag==="Some")i=s.value,i.refCount++;else{if(Number.isFinite(e.capacity)&&YD(e.state.map)>=e.capacity)return Q(new fT(`RcMap attempted to exceed capacity of ${e.capacity}`));{i={deferred:zu(),scope:no(),idleTimeToLive:e.idleTimeToLive(t),finalizer:void 0,fiber:void 0,expiresAt:0,refCount:1},i.finalizer=pne(e,t,i),qc(r.map,t,i);let c=new Map(e.context.mapUnsafe);o.context.mapUnsafe.forEach((u,f)=>{c.set(f,u)}),c.set(mt.key,i.scope),e.lookup(t).pipe(Jn(xr(c)),Na(i.scope)).addObserver(u=>zl(i.deferred,u))}}let a=sr(o.context,mt);return Dt(a,i.finalizer).pipe(Wn(n(Wu(i.deferred))))}));var pne=(e,t,n)=>kn(r=>{if(n.refCount--,n.refCount>0)return W;if(e.state._tag==="Closed"||!QD(e.state.map,t)||Dp(n.idleTimeToLive))return e.state._tag==="Open"&&Sf(e.state.map,t),Ze(n.scope,en);if(!Rs(n.idleTimeToLive))return W;let o=r.getRef(kc);return n.expiresAt=o.currentTimeMillisUnsafe()+vn(n.idleTimeToLive),n.fiber?W:(n.fiber=oI(function s(i){let a=o.currentTimeMillisUnsafe(),c=n.expiresAt-a;return c<=0?e.state._tag==="Closed"||n.refCount>0?W:(Sf(e.state.map,t),i(Ze(n.scope,en))):_(o.sleep(As(c)),()=>s(i))}).pipe(Ca(ae(()=>{n.fiber=void 0})),Jn(r.context),Na(e.scope)),W)});var AR=d(2,(e,t)=>tf(n=>{if(e.state._tag==="Closed")return W;let r=Gs(e.state.map,t);if(r._tag==="None"||Dp(r.value.idleTimeToLive))return W;let o=r.value;return o.expiresAt=n.currentTimeMillisUnsafe()+vn(o.idleTimeToLive),W}));var mne="~effect/RcRef",RR={_tag:"Empty"},hne={_tag:"Closed"},gne={_A:j,_E:j},CR=class{[mne]=gne;pipe(){return ce(this,arguments)}state=RR;semaphore=Ba(1);acquire;context;scope;idleTimeToLive;constructor(t,n,r,o){this.acquire=t,this.context=n,this.scope=r,this.idleTimeToLive=o}},y$=e=>kn(t=>{let n=t.context,r=ze(n,mt),o=new CR(e.acquire,n,r,e.idleTimeToLive?pt(e.idleTimeToLive):void 0);return Zt(Yo(r,()=>{let s=o.state._tag==="Acquired"?Ze(o.state.scope,en):W;return o.state=hne,s}),o)}),xne=e=>Oo(function t(n){switch(e.state._tag){case"Closed":return Co;case"Acquired":return e.state.refCount++,e.state.fiber?Zt(Fo(e.state.fiber),e.state):k(e.state);case"Empty":{let r=no();return e.semaphore.withPermit(V(()=>e.state._tag!=="Empty"?t(n):n(Vn(e.acquire,Ge(e.context,mt,r))).pipe(te(o=>{let s={_tag:"Acquired",value:o,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=s,s}),Sr(o=>Ei(o)?Ze(r,o):W))))}}}),S$=Ee(function*(e){let t=e,n=yield*xne(t),r=yield*os,o=t.idleTimeToLive!==void 0&&Rs(t.idleTimeToLive);return yield*Yo(r,()=>(n.refCount--,n.refCount>0?W:t.idleTimeToLive===void 0?(t.state=RR,Ze(n.scope,en)):n.invalidated?Ze(n.scope,en):o?(n.fiber=Rc(t.idleTimeToLive).pipe(_(()=>t.state._tag==="Acquired"&&t.state.refCount===0?(t.state=RR,Ze(n.scope,en)):W),Ca(ae(()=>{n.fiber=void 0})),Jn(t.context),Na(t.scope)),W):W)),n.value});var b$=y$,E$=S$;var T$="~effect/Stream",Ne=e=>N(e,T$),I$=lh,$=l$,nE=e=>$(sb(te(e,je))),Sne=e=>nE(tI(e)),bne=e=>nE(Yu(e)),k$=e=>ci(k(_(e,()=>he()))),A$=e=>ci(k(te(e,je))),Ene=(e,t)=>ci(Lt(function*(){let n=yield*Ls(t),r=yield*rs(e,zn,zn.defaultValue()),o=!0,s=V(()=>n(r)).pipe(_(i=>rs(e,zn,i)),te(i=>(r=i,je(i))));return V(()=>o?(o=!1,k(je(r))):s)})),wne=e=>ci(ae(()=>{let t=!0,n=k(je(void 0)),r=Ra(n,e);return V(()=>t?(t=!1,n):r)})),ci=e=>$(Qn(e)),An=(e,t)=>$(Qe((n,r)=>_(fs(e.channel,r),o=>t(o,r)))),OR=(e,t)=>$(ei((n,r,o)=>_(fs(e.channel,r),s=>t(s,r,o)))),ms=e=>e.channel,rE=(e,t)=>$(E2(e,t)),Wi=$(vd),$d=e=>$(ob(je(e))),vne=(...e)=>Vh(e),Tne=e=>$(v2(()=>je(e()))),Vr=e=>$(rb(()=>e().channel)),qf=e=>$(qi(e)),Ine=e=>$(I2(e)),R$=e=>$(dh(e)),kne=e=>$(Qk(e)),Ane=e=>$(k2(e)),Rne=(e,t)=>$(Zk(()=>e,t)),jf=(e,t)=>Array.isArray(e)&&t?.chunkSize===void 0?Vh(e):$(w2(e,t?.chunkSize)),Cne=e=>Ir(te(e,jf)),One=e=>Hd(A$(e),jf),Vh=e=>et(e)?$(ob(e)):Wi,_ne=e=>Ir(te(e,Vh)),Mne=(...e)=>$(Gk(dx(e,et))),zi=e=>$(R2(e)),_R=e=>$(C2(e)),C$=e=>$(O2(e)),MR=e=>$(_2(e)),Pne=(e,t)=>$(M2(e,t)),Fne=e=>ci(te(Vl(e),t=>Gt(te(t(void 0),je),()=>he()))),Une=e=>$(Xk(e)),Nne=(e,t,n)=>rE(r=>{function o(s){Ed(r,s)}return Oc(ae(()=>e.addEventListener(t,o,n)),()=>ae(()=>e.removeEventListener(t,o,n)))},{bufferSize:typeof n=="object"?n.bufferSize:void 0}),O$=(e,t)=>ci(ae(()=>{let n=e;return _(V(()=>t(n)),r=>r===void 0?he():(n=r[1],k(je(r[0]))))})),Dne=(e,t)=>ci(ae(()=>{let n=e,r=!1;return V(function o(){return r?he():_(t(n),([s,i])=>(Se(i)?r=!0:n=i.value,et(s)?k(s):o()))})})),Lne=(e,t)=>O$(e,n=>k([n,t(n)])),qne=(e,t,n=lh)=>e>t?Wi:ci(ae(()=>{let r=Math.max(1,n),o=e,s=!1;return V(()=>{if(s)return he();let i=t-o+1;if(i>r){let c=vw(o,o+r-1);return o+=r,k(c)}let a=vw(o,o+i-1);return s=!0,k(a)})})),jne=$(T2),Ir=e=>$($a(te(e,ms))),Bne=e=>$(aL(e.channel)),Uo=d(2,(e,t)=>Vr(()=>{let n=0;return $(ti(e.channel,Is(r=>t(r,n++))))})),$ne=d(2,(e,t)=>e.pipe(Uo(t.onSuccess),j$(t.onFailure))),_$=d(2,(e,t)=>$(ti(e.channel,t))),Bf=d(e=>Ne(e[0]),(e,t,n)=>e.channel.pipe(wr,ib(t,n),ti(je),$)),Hne=d(e=>Ne(e[0]),(e,t)=>Bf(e,j,t)),zne=d(2,(e,t)=>$(ib(e.channel,t))),Wne=e=>e.pipe(Uo(le),Jh(t=>$d(ge(t)))),M$=d(e=>Ne(e[0]),(e,t,n)=>Bf(e,r=>Zt(t(r),r),n)),Kne=d(2,(e,t)=>e.pipe(D$(t.onError),M$(t.onElement,{concurrency:t.concurrency}))),Vne=d(2,(e,t)=>OR(e,Ee(function*(n,r,o){let s=Er(),i=Er(),a,c,u=!1,f=!1,l=s.whenOpen(V(()=>{if(a){let h=a;return a=void 0,f||s.closeUnsafe(),Zt(i.open,h)}return he()}));yield*V(()=>t.transform(l,o)).pipe(h=>rI(h,g=>(u=!0,Ei(g)&&(c=g.cause),i.open),!0),zt(o));let p=n.pipe(_(h=>(a=h,i.closeUnsafe(),s.openUnsafe(),Zt(i.await,h))),Gt(()=>(f=!0,i.closeUnsafe(),s.openUnsafe(),_(i.await,()=>he()))));return V(()=>c?lt(c):u?n:p)}))),Hd=d(e=>Ne(e[0]),(e,t,n)=>e.channel.pipe(wr,U2(r=>t(r).channel,n),$)),Jne=d(e=>Ne(e[0]),(e,t,n)=>e.channel.pipe(wr,oL(r=>t(r).channel,n),$)),PR=d(e=>Ne(e[0]),(e,t)=>Hd(e,j,t)),Gne=e=>$(wr(e.channel)),Zne=e=>$(L2(e.channel)),Qne=d(2,(e,t)=>oE(e,iE(t))),Yne=d(2,(e,t)=>$(q2(e.channel,t))),Xne=d(2,(e,t)=>e.channel.pipe(wr,j2(t),ti(je),$)),ere=d(2,(e,t)=>P$(e,{duration:t,orElse:()=>Wi})),P$=d(2,(e,t)=>{let n=pt(t.duration);if(!Rs(n))return e;if(Dp(n))return Vr(t.orElse);let r=Symbol();return N$(Vr(()=>{let s=Di().getRef(kc),i=vn(n),a,c=Er(!1);return FR(An(e,(u,f)=>V(()=>(a=s.currentTimeMillisUnsafe()+i,c.openUnsafe(),u)).pipe(te(l=>(c.closeUnsafe(),a=void 0,l)),k)),k$(Lt(function*(){for(;;)if(yield*c.await,!(a===void 0||(yield*Rc(a-s.currentTimeMillisUnsafe()),a===void 0)||a-s.currentTimeMillisUnsafe()>0))return yield*Ao(r)})),{haltStrategy:"left"})}),o=>o.reasons.find(i=>i._tag==="Die"&&i.defect===r)?t.orElse():R$(o))}),tre=d(2,(e,t)=>$(Qe((n,r)=>te(Ue(wr(e.channel))(n,r),o=>{let s,i=Lt(function*(){let a=yield*o,c=je(a);return s=(yield*Vl(t))(a).pipe(Zt(c),Gt(f=>(s=void 0,i))),c});return V(()=>s??i)})))),nre=e=>$(tA(e.channel)),rre=e=>Hd(e,jf),ore=e=>e.channel.pipe(wr,D2,$),Kh=d(2,(e,t)=>PR(Vh([e,t]))),sre=d(2,(e,t)=>Kh(jf(t),e)),FR=d(e=>Ne(e[0])&&Ne(e[1]),(e,t,n)=>$(fb(ms(e),ms(t),n))),oE=d(2,(e,t)=>e.channel.pipe(sL(t),$)),ire=d(2,(e,t)=>FR(Uo(e,le),Uo(t,ge))),are=d(2,(e,t)=>oE(e,iE(t))),cre=d(2,(e,t)=>oE(t,iE(e))),ure=d(2,(e,t)=>PR(jf(e),t)),fre=d(2,(e,t)=>F$(e,t,(n,r)=>[n,r])),F$=d(3,(e,t,n)=>Hd(e,r=>Uo(t,o=>n(r,o)))),UR=d(3,(e,t,n)=>sE(e,t,lre(n))),lre=e=>(t,n)=>{let r=Math.min(t.length,n.length),o=[];for(let s=0;s<r;s++)o.push(e(t[s],n[s]));return[o,t.slice(r),n.slice(r)]},sE=d(3,(e,t,n)=>$(ei(Ee(function*(r,o){let s=yield*fs(e.channel,o),i=yield*fs(t.channel,o),a=Lt(function*(){let f=yield*zt(s,o),l=yield*zt(i,o);return yield*qS([f,l])}),c={_tag:"PullBoth"};return Lt(function*(){let[f,l]=c._tag==="PullBoth"?yield*a:c._tag==="PullLeft"?[yield*s,c.rightArray]:[c.leftArray,yield*i],p=n(f,l);return et(p[1])?c={_tag:"PullRight",leftArray:p[1]}:et(p[2])?c={_tag:"PullLeft",rightArray:p[2]}:c={_tag:"PullBoth"},p[0]})})))),dre=d(2,(e,t)=>UR(e,t,(n,r)=>[n,r])),pre=d(2,(e,t)=>sE(e,t,(n,r)=>{let o=Math.min(n.length,r.length),s=n.slice(0,o),i=n.slice(o),a=r.slice(o);return[s,i,a]})),mre=d(2,(e,t)=>sE(e,t,(n,r)=>{let o=Math.min(n.length,r.length),s=r.slice(0,o),i=n.slice(o),a=r.slice(o);return[s,i,a]})),hre=d(2,(e,t)=>UR(e,t,(n,r)=>[...n,r])),gre=e=>Uo(e,(t,n)=>[t,n]),xre=e=>$f(e,D,(t,n)=>{let r=0;t._tag==="None"&&(r=1,t=L(n[0]));let o=fn();for(;r<n.length;r++){let s=t.value;t=L(n[r]),o.push([s,t])}return[t,o]},{onHalt(t){return t._tag==="Some"?[[t.value,D()]]:[]}}),yre=e=>$f(e,D,(t,n)=>{let r=fn();for(let o=0;o<n.length;o++){let s=n[o];r.push([t,s]),t=L(n[o])}return[t,r]}),Sre=e=>$f(e,()=>({prev:D(),current:D()}),(t,n)=>{let r=0,o;t.current._tag==="None"?(r=1,o=n[0],t.current=L(o)):o=t.current.value;let s=fn();for(;r<n.length;r++){let i=n[r];t.current=L(i),s.push([t.prev,o,t.current]),t.prev=L(o),o=i}return[t,s]},{onHalt(t){return t.current._tag==="Some"?[[t.prev,t.current.value,D()]]:[]}}),NR=(...e)=>$(rb(()=>{let t=[],n=new Set,r=Er();return ub(Gk(e.map((o,s)=>o.channel.pipe(wr,ib(i=>(t[s]=i,n.has(s)?k(je(t.slice())):(n.add(s),n.size<e.length?r.await:Zt(r.open,je(t.slice()))))),B2(qn)))),{concurrency:"unbounded",bufferSize:0})})),bre=d(2,(e,t)=>NR(e,t)),Ere=d(3,(e,t,n)=>Uo(NR(e,t),([r,o])=>n(r,o))),U$=(...e)=>$(Qe((t,n)=>ae(()=>{let r,o=ZT(e.map(s=>{let i=Fn(n);return fs(s.channel,i).pipe(_(a=>zT(k(a),a)),Sr(a=>a._tag==="Success"?r?Ze(i,a):(r=a.value[0],W):Ze(i,a)),te(([,a])=>a))}));return V(()=>r??o)}))),wre=d(2,(e,t)=>U$(e,t)),DR=d(2,(e,t)=>$($2(ms(e),t))),vre=d(2,(e,t)=>$(H2(ms(e),t))),Tre=d(2,(e,t)=>$(z2(ms(e),t))),Ire=d(2,(e,t)=>$(W2(ms(e),t))),LR=d(e=>Ne(e[0]),Ee(function*(e,t,n){let r=yield*os,o=yield*fs(e.channel,r),s=n?.capacity==="unbounded"?void 0:n?.capacity??I$,i=yield*lo({capacity:s}),a=yield*lo({capacity:s});return yield*Lt(function*(){for(;;){let c=yield*o,u=[],f=[];for(let p=0;p<c.length;p++){let h=t(c[p]);we(h)?u.push(h.failure):f.push(h.success)}let l;if(f.length>0){let p=tb(i,f);p.length>0&&(l=yield*td(ja(i,p)))}if(u.length>0){let p=tb(a,u);p.length>0&&(yield*ja(a,p))}l&&(yield*xd(l))}}).pipe(Ro(c=>(Li(i,c),Li(a,c),W)),zt(r)),[i,a]})),kre=d(e=>Ne(e[0]),(e,t,n)=>te(LR(Bf(e,r=>t(r),n),r=>r,n),([r,o])=>[zi(r),zi(o)])),Are=d(e=>Ne(e[0]),(e,t,n)=>te(LR(e,t,{capacity:n?.bufferSize??16}),([r,o])=>[zi(o),zi(r)])),Rre=d(2,(e,t)=>t.pipe(te(n=>n?e:Wi),Ir)),Cre=d(2,Ee(function*(e,t){let n,r=yield*cA(e.channel),o=ht(r,a=>(n=a,lt(a))),s=ci(k(o)),i=yield*aH(s,t);return n?[i,Wi]:(s=ci(k(r)),[i,s])})),Ore=d(2,(e,t)=>$(uL(e.channel,t))),_re=d(2,(e,t)=>$(cL(e.channel,t))),N$=d(2,(e,t)=>e.channel.pipe(Id(n=>t(n).channel),$)),Mre=d(2,(e,t)=>e.channel.pipe(cb(t),$)),Jh=d(2,(e,t)=>$(Ys(e.channel,n=>t(n).channel)));var D$=d(2,(e,t)=>e.channel.pipe(J2(t),$)),L$=d(e=>Ne(e[0]),(e,t,n,r)=>$(G2(ms(e),t,o=>n(o).channel,r&&(o=>r(o).channel)))),q$=d(e=>Ne(e[0]),(e,t,n,r)=>$(Z2(ms(e),t,o=>n(o).channel,r&&(o=>r(o).channel)))),Pre=d(e=>Ne(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?s=>N(s,"_tag")&&t.includes(s._tag):jn(t);return L$(e,o,n,r)}),Fre=d(e=>Ne(e[0]),(e,t,n)=>{let r;return q$(e,o=>(r??=Object.keys(t),N(o,"_tag")&&Iy(o._tag)&&r.includes(o._tag)?le(o):ge(o)),o=>t[o._tag](o),n)}),Ure=d(e=>Ne(e[0]),(e,t,n,r,o)=>$(Q2(ms(e),t,n,(s,i)=>r(s,i).channel,o&&((s,i)=>o(s,i).channel)))),Nre=d(e=>Ne(e[0]),(e,t,n,r)=>{let o=Object.create(null);for(let i of Object.keys(n)){let a=n[i];o[i]=(c,u)=>a(c,u).channel}let s=r&&((i,a)=>r(i,a).channel);return $(Y2(e.channel,t,o,s))}),j$=d(2,(e,t)=>$(X2(e.channel,t))),Dre=d(3,(e,t,n)=>$(V2(e.channel,t,r=>n(r).channel))),Lre=d(3,(e,t,n)=>$(nA(e.channel,t,(r,o)=>n(r,o).channel))),qre=d(2,(e,t)=>$(N2(e.channel,n=>ms(t())))),jre=d(2,(e,t)=>Jh(e,n=>$d(t(n)))),Bre=e=>$(eL(e.channel)),$re=d(e=>Ne(e[0]),(e,t)=>$(tL(e.channel,t))),Hre=d(e=>Ne(e[0]),(e,t)=>$(nL(e.channel,t))),zre=d(2,(e,t)=>$(rL(e.channel,t))),v$=(e,t)=>Ir(te(Ls(t),n=>{let r=zn.defaultValue(),o=()=>Jh($R(e,zn,ae(()=>r)),s=>Ir(Gt(te(n(s),i=>(r=i,Ir(Zt(hm,o())))),()=>k(qf(s)))));return o()})),Wre=d(e=>Ne(e[0]),(e,t,n)=>Vr(()=>{let r=n?.preventFallbackOnPartialStream??!1,o=0,s={attempt:0,stepIndex:0},i=$R(by,ae(()=>(s={attempt:s.attempt+1,stepIndex:o},s))),a=n?.onEvent===void 0?void 0:qT(n.onEvent,()=>s),c,u=a===void 0?j:p=>nH(rH(p,te(a.begin,h=>{c=h})),h=>V(()=>{if(c===void 0)return W;let g=c;return c=void 0,a.end(g,h)})),f=D(),l=Vr(()=>{let p=t.steps[o];if(!p)return qf(yw(f));let h=i(u(sH(e,p.provide))),g=!1;if(_e(f)){let x=f.value,S=!1,w=h;h=Vr(()=>S?w:(S=!0,qf(x))),h=v$(h,mm(p,!1))}else{let x=mm(p,!0);h=x?v$(h,x):h}return Jh(r?oH(h,x=>(g=!0,W)):h,x=>(o++,r&&g?qf(x):(f=L(x),l)))});return l})),Kre=d(2,(e,t)=>t<1?Wi:B$(e,(n,r)=>r===t-1)),Vre=d(3,(e,t,n)=>Vr(()=>{let r=BigInt(t),o=BigInt(0),s=!1;return Kh(H$(e,i=>{let a=o+BigInt(i.length);return a>r?(s=!0,!1):(o=a,!0)}),Vr(()=>s?n():Wi))})),Jre=d(2,(e,t)=>$f(e,qa,(n,r)=>(jS(n,r),n.length>t&&sh(n,n.length-t),[n,Va]),{onHalt(n){return Ef(n)}})),B$=d(e=>Ne(e[0]),(e,t,n)=>An(e,(r,o)=>ae(()=>{let s=0,i=!1;return _(V(()=>i?he():r),c=>{let u=c.findIndex(f=>t(f,s++));if(u>=0){i=!0;let f=c.slice(0,n?.excludeLast?u:u+1);return et(f)?k(f):he()}return k(c)})}))),$$=d(e=>Ne(e[0]),(e,t,n)=>An(e,(r,o)=>ae(()=>{let s=0,i=!1;return Lt(function*(){if(i)return yield*he();let a=yield*r;for(let c=0;c<a.length;c++)if(yield*t(a[c],s++)){i=!0;let u=a.slice(0,n?.excludeLast?c:c+1);return et(u)?u:yield*he()}return a})}))),H$=d(2,(e,t)=>An(e,(n,r)=>ae(()=>{let o=0,s=!1,i=_(V(()=>s?he():n),a=>{let c=[];for(let u=0;u<a.length;u++){if(!t(a[u],o++)){s=!0;break}c.push(a[u])}return et(c)?k(c):s?he():i});return i}))),Gre=d(2,(e,t)=>An(e,(n,r)=>ae(()=>{let o=!1,s=_(V(()=>o?he():n),i=>{let a=[];for(let c=0;c<i.length;c++){let u=t(i[c]);if(we(u)){o=!0;break}a.push(u.success)}return et(a)?k(a):o?he():s});return s}))),Zre=d(2,(e,t)=>$$(e,(n,r)=>te(t(n,r),o=>!o),{excludeLast:!0})),qR=d(2,(e,t)=>An(e,(n,r)=>ae(()=>{let o=0,s=n.pipe(_(i=>o>=t?k(i):(o+=i.length,o<=t?s:k(i.slice(t-o)))));return s}))),Qre=d(2,(e,t)=>qR(z$(e,(n,r)=>!t(n,r)),1)),Yre=d(2,(e,t)=>qR(W$(e,(n,r)=>te(t(n,r),o=>!o)),1)),z$=d(2,(e,t)=>An(e,(n,r)=>ae(()=>{let o=!0,s=0,i=_(n,a=>{let c=a.findIndex(u=>!t(u,s++));return c===-1?i:(o=!1,k(a.slice(c)))});return V(()=>o?i:n)}))),Xre=d(2,(e,t)=>An(e,(n,r)=>ae(()=>{let o=!0,s=_(n,i=>{let a=i.findIndex(c=>we(t(c)));return a===-1?s:(o=!1,k(i.slice(a)))});return V(()=>o?s:n)}))),W$=d(2,(e,t)=>An(e,(n,r)=>ae(()=>{let o=!0,s=0,i=Lt(function*(){for(;;){let a=yield*n;for(let c=0;c<a.length;c++)if(!(yield*t(a[c],s++)))return o=!1,a.slice(c)}});return V(()=>o?i:n)}))),eoe=d(2,(e,t)=>t<=0?e:An(e,(n,r)=>ae(()=>{let o=qa(),s=_(n,i=>{BS(o,i);let a=o.length-t,c=bf(o,a);return or(c)?k(c):s});return s}))),K$=e=>e.channel.pipe(ti(je),$),V$=d(2,(e,t)=>(t=Math.max(1,t),An(e,(n,r)=>ae(()=>{let o=fn(),s=0,i,a=!1;return V(function c(){if(a)return he();if(i===void 0)return _(n,u=>o.length===0&&u.length===t?k(u):o.length+u.length<t?(o.push(...u),c()):(i=u,c()));for(;s<i.length;)if(o.push(i[s++]),o.length===t){let u=o;return o=[],k(u)}return s=0,i=void 0,c()}).pipe(Gt(()=>{if(o.length===0)return he();let c=o;return a=!0,o=[],k(c)}))})))),toe=d(2,(e,t)=>J$(e,t,1)),J$=d(3,(e,t,n)=>An(e,(r,o)=>ae(()=>{let s=null,i=qa(),a=!1,c=0,u=io(r,{onSuccess(f){if(BS(i,f),c>0){let p=i.length;sh(i,c),c=Math.max(0,c-p)}if(i.length<t)return u;a=!0;let l=[];for(;i.length>=t;)if(t===n)l.push(bf(i,t));else if(l.push(a2(i,t)),t===1&&n<=0)Zs(i);else{let p=i.length;sh(i,n),c=Math.max(0,n-p)}return k(l)},onFailure(f){return a&&sh(i,t-n),i.length===0?lt(f):(s=f,k(je(Ef(i))))}});return V(()=>s?lt(s):u)}))),noe=d(2,(e,t)=>$f(e,fn,(n,r)=>{let o=fn();for(let s=0;s<r.length;s++)t(r[s])?or(n)&&(o.push(n),n=[]):n.push(r[s]);return[n,o]},{onHalt(n){return or(n)?je(n):Va}})),roe=d(4,(e,t,n,r)=>eA(wr(e.channel),wr(t.channel),n,r).pipe(ti(je),$)),ooe=d(4,(e,t,n,r)=>$(eA(e.channel,t.channel,n,r))),soe=d(e=>Ne(e[0]),(e,t,n,r)=>$(Td(e.channel,t,(o,s)=>{let i=fn();for(let a=0;a<s.length;a++){let[c,u]=n(o,s[a]);o=c,i.push(...u)}return[o,or(i)?je(i):Va]},r?.onHalt?{onHalt(o){let s=r.onHalt(o);return et(s)?je(s):Va}}:void 0))),$f=d(e=>Ne(e[0]),(e,t,n,r)=>$(Td(e.channel,t,(o,s)=>{let[i,a]=n(o,s);return o=i,[o,et(a)?je(a):Va]},r?.onHalt?{onHalt(o){let s=r.onHalt(o);return et(s)?je(s):Va}}:void 0))),Va=fn(),ioe=d(e=>Ne(e[0]),(e,t,n,r)=>e.channel.pipe(wr,Td(t,(o,s)=>te(n(o,s),([i,a])=>[i,et(a)?je(a):fn()]),r?.onHalt?{onHalt(o){let s=r.onHalt(o);return et(s)?je(s):Va}}:void 0),$)),aoe=d(e=>Ne(e[0]),(e,t,n,r)=>e.channel.pipe(Td(t,(o,s)=>te(n(o,s),([i,a])=>[i,et(a)?je(a):Va]),r?.onHalt?{onHalt(o){let s=r.onHalt(o);return et(s)?je(s):Va}}:void 0),$)),coe=d(3,(e,t,n)=>Vr(()=>{let r=!0;return $(Td(e.channel,Xe(t),(o,s)=>{let i=fn();r&&(r=!1,i.push(o));for(let a=0;a<s.length;a++)o=n(o,s[a]),i.push(o);return[o,je(i)]}))})),uoe=d(3,(e,t,n)=>e.channel.pipe(wr,K2(t,n),ti(je),$)),foe=d(2,(e,t)=>An(e,Ee(function*(n,r){let o=yield*kc,s=vn(pt(t)),i,a,c=1/0,u=Er(),f=Er(),l=Er();yield*n.pipe(u.whenOpen,_(h=>(f.openUnsafe(),i=h,c=o.currentTimeMillisUnsafe()+s,W)),Qt({disableYield:!0}),Ro(h=>(a=h,c=o.currentTimeMillisUnsafe(),f.openUnsafe(),l.openUnsafe(),W)),zt(r));let p=V(function h(){let g=o.currentTimeMillisUnsafe(),x=c<g?s:Math.min(s,c-g);return _(Cc(Rc(x),l.await),()=>{if(o.currentTimeMillisUnsafe()<c)return h();if(i){f.closeUnsafe(),u.closeUnsafe();let w=k(je(Il(i)));return i=void 0,w}else if(a)return lt(a);return h()})});return V(()=>{if(a){if(i){let h=k(je(Il(i)));return i=void 0,h}return lt(a)}return u.openUnsafe(),f.whenOpen(p)})}))),G$=d(2,(e,t)=>{let n=t.burst??0;return t.strategy==="enforce"?loe(e,t.cost,t.units,t.duration,n):doe(e,t.cost,t.units,t.duration,n)}),loe=(e,t,n,r,o)=>An(e,s=>tf(i=>{let a=vn(pt(r)),c=n+o<0?Number.POSITIVE_INFINITY:n+o,u=n,f=i.currentTimeMillisUnsafe();return k(_(s,function l(p){return _(t(p),h=>{let g=i.currentTimeMillisUnsafe(),S=(g-f)/a,w=u+S*n,E=w<0?c:Math.min(w,c);return h<=E?(u=E-h,f=g,k(p)):_(s,l)})}))})),doe=(e,t,n,r,o)=>An(e,s=>tf(i=>{let a=vn(pt(r)),c=n+o<0?Number.POSITIVE_INFINITY:n+o,u=n,f=i.currentTimeMillisUnsafe();return k(_(s,l=>_(t(l),p=>{let h=i.currentTimeMillisUnsafe(),x=(h-f)/a,S=u+x*n,E=(S<0?c:Math.min(S,c))-p;if(E>=0)return u=E,f=h,k(l);let y=-E/n,v=Math.max(0,y*a);return v>0?_(Rc(v),()=>(u=E,f=h,k(l))):(u=E,f=h,k(l))})))})),poe=d(2,(e,t)=>G$(e,{...t,cost:n=>k(t.cost(n))})),moe=d(2,(e,t)=>K$(V$(e,t))),hoe=d(3,(e,t,n)=>jR(e,p$(t),Jl(n))),goe=d(e=>Ne(e[0]),(e,t,n)=>Z$(e,Ee(function*(r,o,s){for(let i=0;i<r.length;i++){let[a,c]=yield*t(r[i]),u=Gs(s,a),f=_e(u)?u.value:yield*ef(kR(o,a));yield*AR(o,a),yield*fr(f,c)}}),n)),xoe=d(e=>Ne(e[0]),(e,t,n)=>Vr(()=>{let r=Lc();return Z$(e,Ee(function*(o,s,i){for(let a=0;a<o.length;a++){let c=t(o[a]),u=Gs(r,c);Se(u)?qc(r,c,[o[a]]):u.value.push(o[a])}for(let[a,c]of r){let u=Gs(i,a),f=_e(u)?u.value:yield*ef(kR(s,a));yield*AR(s,a),yield*ja(f,c)}NS(r)}),n)})),Z$=(e,t,n)=>OR(e,Ee(function*(r,o,s){let i=yield*uh();yield*Dt(o,Qs(i));let a=Lc(),c=yield*g$({lookup:u=>Oc(lo({capacity:n?.bufferSize??4096}).pipe(qt(f=>(qc(a,u,f),fr(i,[u,zi(f)])))),f=>(Sf(a,u),fh(f))),idleTimeToLive:n?.idleTimeToLive??Io}).pipe(Qo(s));return yield*ur({while:cn,body:Xe(_(r,u=>t(u,c,a))),step:Cn}).pipe(ht(u=>on(i,u)),zt(o)),wd(i)})),yoe=d(2,(e,t)=>An(e,(n,r)=>ae(()=>{let o,s,i=fn(),a=n.pipe(_(u=>{for(let f=0;f<u.length;f++){let l=u[f],p=t(l);if(s===void 0){o=p,s=[l];continue}else if(ne(p,o)){s.push(l);continue}i.push([o,s]),o=p,s=[l]}if(or(i)){let f=i;return i=[],k(f)}return a})),c=!1;return Gt(V(()=>c?he():a),()=>{c=!0;let u=s;return s=void 0,u&&or(u)?k(je([o,u])):he()})}))),Soe=d(2,(e,t)=>An(e,(n,r)=>ae(()=>{let o,s,i=V(()=>{if(s!==void 0){let c=s;return s=void 0,k(c)}return n}).pipe(Qu(c=>(o=Zo(c),he()))),a=te(V(()=>t.transform(i,r)),([c,u])=>(s=u,je(c)));return V(()=>o||a)}))),boe=d(2,(e,t)=>jR(e,t,lm)),jR=d(3,(e,t,n)=>$(ei(Ee(function*(r,o,s){let i=yield*fs(e.channel,o),a=Er(!1),c=Symbol(),u=yield*lo({capacity:0});yield*i.pipe(a.whenOpen,_(y=>(a.closeUnsafe(),fr(u,y))),Qt,ht(y=>on(u,y)),zt(s));let f=D(),l,p=!1,h=yield*Vl(n),x=V(function y(){return _(h(f),()=>p?fr(u,c):y())}).pipe(_(()=>oo),Gt(()=>he())),S=us(u).pipe(_(y=>y===c?he():(p=!0,k(y)))),w=V(()=>{if(l!==void 0){let y=l;return l=void 0,p=!0,k(y)}return a.openUnsafe(),S}),E=_(([y,v])=>!p&&u.state._tag==="Done"?he():(f=L(y),l=v,k(je(y))));return V(()=>u.state._tag==="Done"&&l===void 0?u.state.exit:(p=l!==void 0,k(V(()=>t.transform(w,s))))).pipe(_(y=>Cc(E(y),x)))})))),Eoe=d(2,Ee(function*(e,t){let n=yield*woe(t),r=new Array(t.n),o=yield*mt;for(let s=0;s<t.n;s++){let i=Fn(o),a=yield*ch(n).pipe(rs(mt,i));r[s]=Yk(GS(a)).pipe(ph(c=>Ze(i,c)),$)}return yield*If(e.channel,s=>Sd(n,s)).pipe(Sr(s=>Sd(n,s)),$s),r})),woe=e=>Oc(e.capacity==="unbounded"?ih(e):e.strategy==="dropping"?VS(e):e.strategy==="sliding"?JS(e):KS(e),ah),Q$=d(2,(e,t)=>te(uH(e,t),C$)),voe=d(2,(e,t)=>te(b$({acquire:Q$(e,t),idleTimeToLive:t.idleTimeToLive}),n=>Ir(E$(n)))),Toe=d(2,(e,t)=>$(rA(e.channel,t))),Ioe=d(2,(e,t)=>$(oA(e.channel,t))),koe=d(2,(e,t)=>e.channel.pipe(oA(d$(t)),ab(([n,r])=>r?ob(r):vd),$)),Aoe=e=>nE(cH(e)),Roe=e=>$f(e,fn,(t,n)=>{let r=Tl(t,n);return[r,[r]]}),Y$=e=>X$(e,ne),X$=d(2,(e,t)=>An(e,(n,r)=>ae(()=>{let o=!0,s;return _(n,function i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];t(f,s)||(s=f,c.push(f))}return or(c)?k(c):_(n,i)})}))),Coe=d(2,(e,t)=>An(e,(n,r)=>ae(()=>{let o=!0,s;return _(n,Ee(function*i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];(yield*t(f,s))||(s=f,c.push(f))}return or(c)?c:yield*_(n,Ee(i))}))}))),Ooe=d(e=>Ne(e[0]),(e,t)=>Vr(()=>{let n=new TextDecoder(t?.encoding);return Uo(e,r=>n.decode(r,{stream:!0}))})),_oe=e=>Vr(()=>{let t=new TextEncoder;return Uo(e,n=>t.encode(n))}),Moe=e=>e.channel.pipe(rA(iL()),$),eH=d(2,(e,t)=>_$(e,(n,r)=>{let o=r===0?[]:[t],s=n.length-1;for(let i=0;i<n.length;i++)i===s?o.push(n[i]):o.push(n[i],t);return o})),Poe=d(2,(e,t)=>$d(t.start).pipe(Kh(eH(e,t.middle)),Kh($d(t.end)))),Foe=d(2,(e,t)=>tH(e,t,jf(Q_([!0,!1])))),tH=d(3,(e,t,n)=>$(Qe(Ee(function*(r,o){let s=yield*Ue(wr(n.channel))(r,o),i=Symbol(),a=!1,c=!1,u=(yield*Ue(wr(e.channel))(r,o)).pipe(Gt(()=>(a=!0,k(i)))),f=(yield*Ue(wr(t.channel))(r,o)).pipe(Gt(()=>(c=!0,k(i))));return Lt(function*(){for(;;){if(a&&c)return yield*he();let l=yield*s;if(l&&a||!l&&c)continue;let p=yield*l?u:f;if(p!==i)return je(p)}})})))),Uoe=d(2,(e,t)=>$(fL(e.channel,t))),Noe=d(2,(e,t)=>$(lL(e.channel,t))),nH=d(2,(e,t)=>$(ph(e.channel,t))),Doe=d(2,(e,t)=>$(dL(e.channel,t))),rH=d(2,(e,t)=>$(pL(e.channel,t))),oH=d(2,(e,t)=>$(sA(e.channel,n=>t(n[0])))),Loe=d(2,(e,t)=>$(mL(e.channel,t))),Gh=d(2,(e,t)=>$(hL(e.channel,t))),sH=d(e=>Ne(e[0]),(e,t,n)=>$(gL(e.channel,t,n))),BR=d(2,(e,t)=>$(lb(e.channel,t))),qoe=d(3,(e,t,n)=>$(db(e.channel,t,n))),$R=d(3,(e,t,n)=>$(pb(e.channel,t,n))),iH=d(2,(e,t)=>$(xL(e.channel,t))),joe=d(3,(e,t,n)=>iH(e,r=>Ge(r,t,n(ze(r,t))))),Boe=function(){let e=Ne(arguments[0]),t=e?arguments[1]:arguments[0],n=Go(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return $(iA(r.channel,t,n))}return r=>$(iA(r.channel,t,n))},$oe=$d({}),Hoe=d(3,(e,t,n)=>Uo(e,r=>({...r,[t]:n(r)})));var zoe=d(e=>Ne(e[0]),(e,t,n,r)=>Hd(e,o=>Uo(n(o),s=>({...o,[t]:s})),r)),Woe=d(e=>Ne(e[0]),(e,t,n,r)=>Bf(e,o=>te(n(o),s=>({...o,[t]:s})),r)),Koe=d(2,(e,t)=>Uo(e,n=>({[t]:n}))),aH=d(2,(e,t)=>ym(n=>fs(e.channel,n).pipe(_(r=>t.transform(r,n)),te(([r])=>r)))),cH=e=>kf(e.channel,()=>[],(t,n)=>{for(let r=0;r<n.length;r++)t.push(n[r]);return t}),Voe=e=>kf(e.channel,()=>0,(t,n)=>t+n.length),Joe=e=>kf(e.channel,()=>0,(t,n)=>{for(let r=0;r<n.length;r++)t+=n[r];return t}),Goe=d(3,(e,t,n)=>kf(e.channel,t,(r,o)=>{for(let s=0;s<o.length;s++)r=n(r,o[s]);return r})),Zoe=d(3,(e,t,n)=>wL(e.channel,t,(r,o)=>{let s=0,i=r;return te(ur({while:()=>s<o.length,body:()=>n(i,o[s]),step(a){i=a,s++}}),()=>i)})),Qoe=e=>te(bL(e.channel),Kt(sM(0))),Yoe=e=>te(EL(e.channel),Kt(Il)),Xoe=d(2,(e,t)=>If(e.channel,n=>{let r=0;return ur({while:()=>r<n.length,body:()=>t(n[r++]),step:Cn})})),ese=d(2,(e,t)=>SL(e.channel,n=>{let r=!1,o=0;return te(ur({while:()=>!r&&o<n.length,body:()=>t(n[o]),step(s){o++,s||(r=!0)}}),()=>!r)})),zd=d(2,(e,t)=>If(e.channel,t)),iE=e=>yL(e.channel),HR=e=>cA(e.channel),tse=e=>kf(e.channel,()=>"",(t,n)=>t+n.join("")),nse=e=>te(aA(e.channel),t=>t.buffer),rse=e=>aA(e.channel),zR=d(e=>Ne(e[0]),(e,t,n)=>{let r,o,s=Er(!1);return new ReadableStream({start(i){o=bm(Vn(zd(e,a=>s.whenOpen(ae(()=>{s.closeUnsafe();for(let c=0;c<a.length;c++)i.enqueue(a[c]);r(),r=void 0}))),t)),o.addObserver(a=>{a._tag==="Failure"?i.error(vc(a.cause)):i.close()})},pull(){return new Promise(i=>{r=i,s.openUnsafe()})},cancel(){if(o)return uI(ns(Fo(o)))}},n?.strategy)}),ose=d(e=>Ne(e[0]),(e,t)=>zR(e,Tt(),t)),WR=d(e=>Ne(e[0]),(e,t)=>te(Kn(),n=>zR(e,n,t))),KR=d(2,(e,t)=>({[Symbol.asyncIterator](){let n=fI(t),r=Jn(t),o=no(),s,i,a,c,u=l=>{if(c)return c;let p=a;return c=n(Zt(Wn(p?Fo(p):W,Ze(o,l)),{done:!0,value:void 0})),c},f=async l=>{try{await u(l)}catch(p){await n(wm("Suppressed error while closing Stream async iterator",p))}};return{async next(){if(c)return c;if(i){let h=i.next();if(!h.done)return h;i=void 0}let l=r(s??_(fs(e.channel,o),h=>(s=h,h)));a=l;let p=await n(n2(l));if(a===l&&(a=void 0),Nt(p))return i=p.value[Symbol.iterator](),i.next();if(Xo(p.cause))return u(en);if(c&&uy(p.cause))return c;throw await f(p),vc(p.cause)},return(){return u(en)},async throw(l){throw await f(ly(l)),l}}}})),sse=e=>te(Kn(),t=>KR(e,t)),ise=e=>KR(e,Tt()),ase=d(e=>Ne(e[0]),(e,t,n)=>fA(e.channel,t,n)),cse=d(2,(e,t)=>IL(e.channel,t)),uH=d(2,(e,t)=>kL(e.channel,t)),use=d(2,(e,t)=>vL(e.channel,t)),fse=d(2,(e,t)=>uA(e.channel,t));var fH="~effect/interfaces/PrimaryKey";var dH="~effect/Pool",hH=Symbol(),gH=Symbol();var xH=e=>SH({...e,min:e.size,max:e.size,strategy:uE}),yH=e=>_(e.timeToLiveStrategy==="creation"?xse(e.timeToLive):yse(e.timeToLive),t=>SH({...e,strategy:t})),SH=e=>Oo(Ee(function*(t){let n=yield*Kn(),r=ze(n,mt),o=Xu(e.acquire,u=>ir(n,u)),s=e.concurrency??1,i={acquire:o,concurrency:s,isFixed:e.min===e.max,minSize:e.min,maxSize:e.max,strategy:e.strategy,targetUtilization:Math.min(Math.max(e.targetUtilization??1,.1),1)},a={scope:r,isShuttingDown:!1,usage:0,resizeSemaphore:Ba(1),items:new Set,availableHead:void 0,availableTail:void 0,invalidated:new Set,waiters:new Set},c={[dH]:dH,[hH]:e.acquire,[gH]:n,config:i,state:a,pipe(){return ce(this,arguments)}};return yield*Dt(r,lse(c)),i.minSize>0&&(yield*qt(nd(t(QR(c)),{startImmediately:!0}),u=>Dt(r,Fo(u)))),e.strategy!==uE&&(yield*qt(nd(t(e.strategy.run(c))),u=>Dt(r,Fo(u)))),c})),lse=Ee(function*(e){if(e.state.isShuttingDown)return;e.state.isShuttingDown=!0;let t=e.state.items.size,n=Ba(t);for(let r of e.state.items)r.refCount>0?(r.finalizer=qt(r.finalizer,n.release(1)),e.state.invalidated.add(r),yield*n.take(1)):(e.state.items.delete(r),Zh(e,r),e.state.invalidated.delete(r),yield*r.finalizer);if(yield*n.releaseAll,e.state.waiters.size>0){let r=Array.from(e.state.waiters);e.state.waiters.clear();for(let o of r)o()}yield*n.take(t)}),JR=e=>me(t=>{let n=e.state;if(n.isShuttingDown)return Bl;if(n.availableHead!==void 0){if(n.usage++,e.config.isFixed||aE(e)<=cE(e))return bH(e,n.availableHead,t);n.usage--}return dse(e,mse)});var dse=(e,t)=>eo(n=>{let r=e.state;r.usage++;let o=oe(ty(n(gse(e)),()=>ye(()=>{r.usage--})),()=>i),s=me(a=>r.isShuttingDown?(r.usage--,Bl):r.availableHead!==void 0?t(e,r.availableHead,a,n):o),i=xe(()=>r.isShuttingDown?(r.usage--,Bl):aE(e)>cE(e)?oe(r.resizeSemaphore.withPermitsIfAvailable(1)(zt(Oa(QR(e)),r.scope)),()=>s):s);return i}),pse=(e,t)=>{let n=e.state;return t.exit._tag==="Failure"?(n.usage--,n.items.delete(t),n.invalidated.delete(t),Zh(e,t),!1):(t.refCount++,t.refCount>=e.config.concurrency&&Zh(e,t),!0)},bH=(e,t,n)=>{if(!pse(e,t))return t.exit;let r=sr(n.context,mt);return r.state._tag==="Closed"?oe(t.release(t.exit),()=>t.exit):(Mu(r,{},t.release),t.exit)},mse=(e,t,n)=>bH(e,t,n),hse=(e,t)=>me(n=>{let r=e.state;return t.refCount--,r.usage--,r.invalidated.has(t)?ZR(e,t):(t.refCount===e.config.concurrency-1&&(GR(e,t),EH(e,n,1)),Ae)}),gse=e=>Vt(t=>{let n=e.state;if(n.availableHead!==void 0||n.isShuttingDown)return t(Ae);let r=()=>{n.waiters.delete(r),t(Ae)};return n.waiters.add(r),ye(()=>{n.waiters.delete(r)})}),EH=(e,t,n)=>{let r=e.state.waiters;r.size!==0&&t.currentDispatcher.scheduleTask(()=>{let o=n,s=[];for(let i of r){if(o--<=0)break;s.push(i)}for(let i=0;i<s.length;i++)s[i]()},0)},pH=e=>me(t=>(EH(e,t,Number.POSITIVE_INFINITY),Ae)),GR=(e,t)=>{t.isAvailable||(t.isAvailable=!0,t.availablePrevious=e.state.availableTail,t.availableNext=void 0,e.state.availableTail!==void 0?e.state.availableTail.availableNext=t:e.state.availableHead=t,e.state.availableTail=t)},Zh=(e,t)=>{t.isAvailable&&(t.isAvailable=!1,t.availablePrevious!==void 0?t.availablePrevious.availableNext=t.availableNext:e.state.availableHead=t.availableNext,t.availableNext!==void 0?t.availableNext.availablePrevious=t.availablePrevious:e.state.availableTail=t.availablePrevious,t.availablePrevious=void 0,t.availableNext=void 0)};var ZR=(e,t)=>V(()=>{if(e.state.items.has(t)){if(t.refCount===0)return e.state.items.delete(t),Zh(e,t),e.state.invalidated.delete(t),ns(_(t.finalizer,()=>zt(Oa(QR(e)),e.state.scope,{startImmediately:!0})))}else return W;return e.state.invalidated.add(t),Zh(e,t),W}),QR=e=>e.state.resizeSemaphore.withPermits(1)(VR(e)),VR=e=>V(()=>{let t=cE(e),n=aE(e);if(t>=n)return W;let r=n-t,o=e.config.strategy===uE?mH(e):_(e.config.strategy.reclaim(e),i=>i?k(i):mH(e));if(r===1){let i=qt(o,pH(e));return e.config.isFixed?ns(i):_(i,a=>a.exit._tag==="Failure"?W:VR(e))}let s=o.pipe(sI(r,{concurrency:r}),qt(pH(e)));return e.config.isFixed?ns(s):_(s,i=>i.some(a=>a.exit._tag==="Failure")?W:VR(e))}),mH=e=>eo(t=>me(n=>{let r=e,o=Uu(),s=n.context;n.setContext(Ge(r[gH],mt,o));let i=_(so(r[hH]),a=>{let c={exit:a,finalizer:ht(Ze(o,a),Sse),refCount:0,disableReclaim:!1,isAvailable:!1,availablePrevious:void 0,availableNext:void 0,release:void 0};return c.release=Xe(hse(e,c)),e.state.items.add(c),GR(e,c),e.config.strategy===uE?a._tag==="Success"?k(c):Zt(c.finalizer,c):Zt(a._tag==="Success"?e.config.strategy.onAcquire(c):_(c.finalizer,()=>e.config.strategy.onAcquire(c)),c)});return Ps(t(i),a=>(n.setContext(s),a._tag==="Failure"?ql(o,a):void 0),!0)})),aE=e=>{if(e.state.isShuttingDown)return 0;if(e.config.isFixed)return e.config.minSize;let t=e.state.usage/e.config.targetUtilization,n=Math.ceil(t/e.config.concurrency);return Math.min(Math.max(e.config.minSize,n),e.config.maxSize)},cE=e=>e.state.items.size-e.state.invalidated.size,uE={run:e=>W,onAcquire:e=>W,reclaim:e=>Yl},xse=Ee(function*(e){let t=yield*kc,n=yield*uh(),r=vn(pt(e)),o=new WeakMap;return j({run:s=>{let i=a=>V(()=>{if(!s.state.items.has(a)||s.state.invalidated.has(a))return W;let c=t.currentTimeMillisUnsafe(),u=o.get(a),f=r-(c-u);return f>0?Ra(i(a),f):ZR(s,a)});return us(n).pipe(qt(i),Qt({disableYield:!0}))},onAcquire:s=>V(()=>(o.set(s,t.currentTimeMillisUnsafe()),fr(n,s))),reclaim:s=>Yl})}),yse=Ee(function*(e){let t=yield*uh();return j({run:n=>{let r=V(()=>cE(n)-aE(n)<=0?W:us(t).pipe(qt(s=>ZR(n,s)),_(()=>r)));return r.pipe(Ra(e),Qt({disableYield:!0}))},onAcquire:n=>fr(t,n),reclaim(n){return V(()=>{if(n.state.invalidated.size===0)return Yl;let r=Y_(cx(n.state.invalidated,o=>!o.disableReclaim));return r._tag==="None"?Yl:(n.state.invalidated.delete(r.value),r.value.refCount<n.config.concurrency&&GR(n,r.value),Zt(fr(t,r.value),r.value))})}})}),Sse=e=>kn(t=>{let n=t.getRef(c1);return n?rd(n)("Unhandled error in pool finalizer",e):W});var Ki=class extends qe()("effect/reactivity/Reactivity"){},bse=ae(()=>{let e=new Map,t=c=>{YR(c,u=>{let f=e.get(u);f!==void 0&&f.forEach(l=>l())})},n=c=>yr(u=>{let f=da(u,fE);return f?YR(c,l=>{f.add(l)}):t(c),W}),r=(c,u)=>qt(u,n(c)),o=(c,u)=>{let f=[];return YR(c,l=>{f.push(l);let p=e.get(l);p===void 0&&(p=new Set,e.set(l,p)),p.add(u)}),()=>{for(let l=0;l<f.length;l++){let p=e.get(f[l]);p.delete(u),p.size===0&&e.delete(f[l])}}},s=(c,u)=>Lt(function*(){let f=yield*Kn(),l=ze(f,mt),p=yield*lo(),h=lu(Jn(f),Na(l)),g=!1,x=!1,S=y=>{y._tag==="Failure"?Li(p,y.cause):Ed(p,y.value),x?(x=!1,h(u).addObserver(S)):g=!1};function w(){if(g){x=!0;return}g=!0,h(u).addObserver(S)}let E=o(c,w);return yield*Dt(l,ae(E)),w(),p}),i=(c,u)=>s(c,u).pipe(te(zi),Ir),a=c=>V(()=>{let u=new Set;return c.pipe(rs(fE,u),Sr(f=>ae(()=>{u.forEach(l=>{let p=e.get(l);p!==void 0&&p.forEach(h=>h())})})))});return Ki.of({mutation:r,query:s,stream:i,invalidateUnsafe:t,invalidate:n,registerUnsafe:o,withBatch:a})}),fE=class extends qe()("effect/reactivity/Reactivity/PendingInvalidation"){},lE=d(2,(e,t)=>Ki.use(n=>n.mutation(t,e)));var dE=e=>Ki.use(t=>t.invalidate(e)),pE=ro(Ki)(bse);function vH(e){switch(typeof e){case"string":case"number":case"bigint":case"boolean":return String(e);default:return ue(e)}}var YR=(e,t)=>{if(Array.isArray(e)){for(let n=0;n<e.length;n++)t(vH(e[n]));return}for(let n in e){t(n);let r=e[n];for(let o=0;o<r.length;o++)t(`${n}:${vH(r[o])}`)}};var TH="~effect/SubscriptionRef",Qh=e=>N(e,TH),Uge={...On,[TH]:{_A:j},toJSON(){return{_id:"SubscriptionRef",value:this.value}}};var XR=e=>_R(e.pubsub);var IH=e=>ae(()=>e.value);var Ese=(e,t)=>{e.value=t,u2(e.pubsub,t)};var eC=d(2,(e,t)=>e.semaphore.withPermit(ae(()=>Ese(e,t))));var AH="~effect/reactivity/AsyncResult",RH=e=>N(e,AH),hE={[AH]:{E:j,A:j},pipe(){return ce(this,arguments)},[ke](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case"Initial":return!0;case"Success":return ne(this.value,e.value);case"Failure":return ne(this.cause,e.cause)}},[Ie](){let e=st(`${this._tag}:${this.waiting}`);return this._tag==="Initial"?e:Ht(e)(this._tag==="Success"?ue(this.value):ue(this.cause))}},CH=e=>e.waiting;var nC=(e,t)=>e._tag==="Success"?hs(e.value):Wd(e.cause,{previous:t}),gE=e=>e._tag==="None"?Ja(!0):Yh(e.value);var OH=e=>e._tag!=="Initial",Ja=(e=!1)=>{let t=Object.create(hE);return t._tag="Initial",t.waiting=e,t},Zc=e=>e._tag==="Success",hs=(e,t)=>{let n=Object.create(hE);return n._tag="Success",n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},_H=e=>e._tag==="Failure";var tC=(e,t)=>{let n=Object.create(hE);return n._tag="Failure",n.cause=e,n.previousSuccess=t?.previousSuccess??D(),n.waiting=t?.waiting??!1,n},Wd=(e,t)=>tC(e,{previousSuccess:Ts(t.previous,n=>Zc(n)?L(n):_H(n)?n.previousSuccess:D()),waiting:t.waiting});var MH=(e,t)=>Wd(rT(e),t),Yh=(e,t)=>{if(e.waiting)return t?.touch?wse(e):e;let n=Object.assign(Object.create(hE),e);return n.waiting=!0,t?.touch&&Zc(n)&&(n.timestamp=Date.now()),n},wse=e=>Zc(e)?hs(e.value,{waiting:e.waiting}):e,Xh=(e,t)=>e._tag==="Failure"?Wd(e.cause,{previous:t,waiting:e.waiting}):e,Kd=e=>e._tag==="Success"?L(e.value):e._tag==="Failure"?Kt(e.previousSuccess,t=>t.value):D();var rC=e=>Op(Kd(e),()=>new Hu("AsyncResult.getOrThrow: no value found"));var Vd=e=>{switch(e._tag){case"Success":return Pn(e.value);case"Failure":return Jt(e.cause);default:return Zo(new Hu)}};var oC=e=>{let t=e.success??$i,n=e.error??$i,r=Dn()([t,Dd(n,xn())],([o,s])=>(i,a,c)=>{if(!RH(i))return Q(new tt(a,i,c));switch(i._tag){case"Initial":return k(i);case"Success":return mn(ut(o)(i.value,c),{onSuccess:u=>hs(u,i),onFailure:u=>Zn(a,"value",u,i,c)});case"Failure":{let u=i.previousSuccess.pipe(Kt(l=>mn(ut(o)(l.value,c),{onSuccess:p=>L(hs(p,l)),onFailure:p=>new At(a,[new kt(["previousSuccess","value"],p)],i,c)})),cc(()=>js)),f=nf(ut(s)(i.cause,c),l=>Zn(a,"cause",l,i,c));return Gn(u,l=>_a(f,p=>tC(p,{previousSuccess:l,waiting:i.waiting})))}}},{expected:"AsyncResult",toCodec([o,s]){let i=Vc("Success",{value:o,waiting:Kc,timestamp:ai});return gt()(Ve([Vc("Initial",{waiting:Kc}),i,Vc("Failure",{cause:s,previousSuccess:Hi(i),waiting:Kc})]),Rt({decode:a=>{switch(a._tag){case"Initial":return Ja(a.waiting);case"Success":return hs(a.value,{waiting:a.waiting,timestamp:a.timestamp});case"Failure":return tC(a.cause,{previousSuccess:Kt(a.previousSuccess,c=>hs(c.value,c)),waiting:a.waiting})}},encode(a){switch(a._tag){case"Initial":return{_tag:"Initial",waiting:a.waiting};case"Success":return{_tag:"Success",value:a.value,waiting:a.waiting,timestamp:a.timestamp};case"Failure":return{_tag:"Failure",cause:a.cause,previousSuccess:a.previousSuccess,waiting:a.waiting}}}}))},toEquivalence:cl,toFormatter:([o,s])=>i=>{switch(i._tag){case"Success":return`AsyncResult.Success(${o(i.value)}, ${i.waiting}, ${i.timestamp})`;case"Failure":return`AsyncResult.Failure(${s(i.cause)}, ${i.waiting})`;case"Initial":return`AsyncResult.Initial(${i.waiting}, ${i.waiting})`}}});return Object.assign(r,{success:t,error:n})};var ng="~effect/reactivity/AtomRegistry",vse=e=>N(e,ng),xE=e=>new iC(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),yE=qe(ng);var Ga=d(e=>vse(e[0]),(e,t,n)=>{let r=n?.suspendOnWaiting??!1;return Bs(o=>{let s=e.get(t);if(s._tag!=="Initial"&&!(r&&s.waiting))return o(Vd(s));let i=e.subscribe(t,a=>{a._tag!=="Initial"&&!(r&&a.waiting)&&(o(Vd(a)),i())});return ae(i)})});var Tse={immediate:!0},Ise=e=>{e()},sC="~effect-atom/atom/Atom/Serializable",tg=e=>sC in e?e[sC].key:e,iC=class{[ng];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(t,n,r,o){if(this[ng]=ng,this.scheduler=new xi("sync",n),this.schedulerAsync=new xi("async",n),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=o,r===void 0&&o!==void 0?this.timeoutResolution=Math.round(o/2):this.timeoutResolution=r??1e3,t!==void 0)for(let[s,i]of t){let a=s;for(;a.initialValueTarget;)a=a.initialValueTarget;this.ensureNode(a).setInitialValue(i)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(t){return this.ensureNode(t).value()}set(t,n){t.write(this.ensureNode(t).writeContext,n)}setSerializable(t,n){this.preloadedSerializable.set(t,n)}modify(t,n){let r=this.ensureNode(t),o=n(r.value());return t.write(r.writeContext,o[1]),o[0]}update(t,n){let r=this.ensureNode(t);t.write(r.writeContext,n(r.value()))}refresh=t=>{t.refresh!==void 0?t.refresh(this.refresh):this.invalidateAtom(t)};subscribe(t,n,r){let o=this.ensureNode(t);r?.immediate&&n(o.value());let s=o.subscribe(function(){n(o._value)});return()=>{s(),o.canBeRemoved&&this.scheduleNodeRemoval(o)}}mount(t){return this.subscribe(t,Cn,Tse)}atomHasTtl(t){return!t.keepAlive&&t.idleTTL!==0&&(t.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(t){let n=tg(t),r=this.nodes.get(n);if(r===void 0?(r=this.createNode(t),this.nodes.set(n,r),this.onNodeAdded?.(r)):this.atomHasTtl(t)&&this.removeNodeTimeout(r),typeof n=="string"&&this.preloadedSerializable.has(n)){let o=this.preloadedSerializable.get(n);this.preloadedSerializable.delete(n);let s=t[sC].decode(o),i=t;for(;i.initialValueTarget;)i=i.initialValueTarget;i===t?r.setValue(s):this.ensureNode(i).setInitialValue(s)}return r}createNode(t){if(this.disposed)throw new Error(`Cannot access Atom ${t}: registry is disposed`);return t.keepAlive||this.scheduleAtomRemoval(t),new aC(this,t)}invalidateAtom=t=>{this.ensureNode(t).invalidate()};scheduleAtomRemoval(t){this.dispatcher.scheduleTask(()=>{let n=this.nodes.get(tg(t));n!==void 0&&n.canBeRemoved&&this.removeNode(n)},0)}scheduleNodeRemoval(t){this.dispatcher.scheduleTask(()=>{t.canBeRemoved&&this.removeNode(t)},0)}removeNode(t){this.atomHasTtl(t.atom)?this.setNodeTimeout(t):(this.nodes.delete(tg(t.atom)),t.remove(),this.onNodeRemoved?.(t))}setNodeTimeout(t){if(this.nodeTimeoutBucket.has(t))return;let n=t.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(n-=this.#e,n<=0)){this.nodes.delete(tg(t.atom)),t.remove(),this.onNodeRemoved?.(t);return}let r=Math.ceil(n/this.timeoutResolution)*this.timeoutResolution,o=Date.now()+r,s=o-o%this.timeoutResolution+this.timeoutResolution,i=this.timeoutBuckets.get(s);i===void 0&&(i=[new Set,setTimeout(()=>this.sweepBucket(s),s-Date.now())],this.timeoutBuckets.set(s,i)),i[0].add(t),this.nodeTimeoutBucket.set(t,s)}removeNodeTimeout(t){let n=this.nodeTimeoutBucket.get(t);if(n===void 0)return;this.nodeTimeoutBucket.delete(t),this.scheduleNodeRemoval(t);let[r,o]=this.timeoutBuckets.get(n);r.delete(t),r.size===0&&(clearTimeout(o),this.timeoutBuckets.delete(n))}#e=null;sweepBucket(t){let n=this.timeoutBuckets.get(t)[0];this.timeoutBuckets.delete(t),n.forEach(r=>{this.nodeTimeoutBucket.delete(r),r.canBeRemoved&&(this.nodes.delete(tg(r.atom)),this.onNodeRemoved?.(r),this.#e=r.atom.idleTTL??this.defaultIdleTTL,r.remove(),this.#e=null)})}reset(){this.timeoutBuckets.forEach(([,t])=>clearTimeout(t)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear(),this.nodes.forEach(t=>{t.remove(),this.onNodeRemoved?.(t)}),this.nodes.clear()}dispose(){this.disposed=!0,this.reset()}},gs={alive:1,initialized:2,waitingForValue:4},Jr={uninitialized:gs.alive|gs.waitingForValue,stale:gs.alive|gs.initialized|gs.waitingForValue,valid:gs.alive|gs.initialized,removed:0},aC=class{constructor(t,n){this.registry=t,this.atom=n,this.writeContext=new cC(t,this)}registry;atom;state=Jr.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;parents=new Set;previousParents;children=new Set;listeners=new Set;skipInvalidation=!1;building=!1;invalidatedDuringBuild=!1;currentState(){switch(this.state){case Jr.uninitialized:return"uninitialized";case Jr.stale:return"stale";case Jr.valid:return"valid";default:return"removed"}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.size===0&&this.state!==0}_value=void 0;value(){if((this.state&gs.waitingForValue)!==0){this.lifetime=Rse(this),this.building=!0;let t=this.atom.read(this.lifetime);if(this.building=!1,(this.state&gs.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.state=Jr.valid):this.setValue(t)),this.previousParents){let n=this.previousParents;this.previousParents=void 0;for(let r of n)r.removeChild(this),r.canBeRemoved&&this.registry.scheduleNodeRemoval(r)}}return this._value}valueOption(){return(this.state&gs.initialized)===0?D():L(this._value)}setInitialValue(t){if((this.state&gs.initialized)===0){this.preserveInitialValueOnBuild=!0,this.state=Jr.stale,this._value=t,sn.phase===Vi.collect?sn.notify.add(this):this.notify();return}this.setValue(t)}setValue(t){if((this.state&gs.initialized)===0){this.state=Jr.valid,this._value=t,sn.phase===Vi.collect?sn.notify.add(this):this.notify();return}this.state=Jr.valid,!this.atom.equals(this._value,t)&&(this._value=t,this.skipInvalidation?this.skipInvalidation=!1:this.invalidateChildren(),this.listeners.size>0&&(sn.phase===Vi.collect?sn.notify.add(this):this.notify()))}addParent(t){this.parents.add(t),this.previousParents!==void 0&&(this.previousParents.delete(t),this.previousParents.size===0&&(this.previousParents=void 0)),t.children.has(this)||(t.children.add(this),t.skipInvalidation&&(t.skipInvalidation=!1))}removeChild(t){this.children.delete(t)}invalidate(){this.building&&sn.phase===Vi.collect&&(this.invalidatedDuringBuild=!0),this.state===Jr.valid&&(this.state=Jr.stale,this.disposeLifetime()),sn.phase===Vi.collect?sn.stale.push(this):this.atom.lazy&&this.listeners.size===0&&!kse(this.children)?(this.invalidateChildren(),this.skipInvalidation=!0):this.value()}invalidateChildren(){if(this.children.size===0)return;let t=this.children;this.children=new Set;for(let n of t)n.invalidate()}notify(){this.listeners.forEach(Ise),sn.phase===Vi.commit&&sn.notify.delete(this)}disposeLifetime(){this.lifetime!==void 0&&(this.lifetime.dispose(),this.lifetime=void 0),this.parents.size!==0&&(this.previousParents=this.parents,this.parents=new Set)}remove(){if(this.state=Jr.removed,this.listeners.clear(),this.lifetime===void 0||(this.disposeLifetime(),this.previousParents===void 0))return;let t=this.previousParents;this.previousParents=void 0;for(let n of t)n.removeChild(this),n.canBeRemoved&&this.registry.removeNode(n)}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}};function kse(e){if(e.size===0)return!1;let t=e,n,r=0;for(;t!==void 0;){for(let o of t){if(!o.atom.lazy||o.listeners.size>0)return!0;o.children.size>0&&(n===void 0?n=[o.children]:n.push(o.children))}t=n?.[r++]}return!1}var Ase={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){if(this.disposed)return this.node.registry.get(e);let t=this.node.registry.ensureNode(e),n=t.value();return this.node.addParent(t),n},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let n=this.get(e);if(t?.suspendOnWaiting&&n.waiting)return oo;switch(n._tag){case"Initial":return oo;case"Failure":return Jt(n.cause);case"Success":return k(n.value)}},resultOnce(e,t){return Bs(n=>{let r=this.once(e);if(r._tag!=="Initial"&&!(t?.suspendOnWaiting&&r.waiting))return n(Vd(r));let o=this.node.registry.subscribe(e,s=>{s._tag==="Initial"||t?.suspendOnWaiting&&s.waiting||(o(),n(Vd(s)))},{immediate:!1});return ae(o)})},setResult(e,t){return this.disposed?oo:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag==="None"?oo:k(t.value)},someOnce(e){return Bs(t=>{let n=this.once(e);if(_e(n))return t(k(n.value));let r=this.node.registry.subscribe(e,o=>{Se(o)||(r(),t(k(o.value)))},{immediate:!1});return ae(r)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?D():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,n){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,n))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?Wi:rE(n=>ae(()=>{this.subscribe(e,r=>Ed(n,r),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(DR(OH),Bf(n=>n._tag==="Success"?k(n.value):lt(n.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0;for(let t=e.length-1;t>=0;t--)e[t]()}},Rse=e=>{function t(n){if(t.disposed)return e.registry.get(n);if(t.isFn)return e.registry.get(n);let r=e.registry.ensureNode(n),o=r.value();return e.addParent(r),o}return Object.setPrototypeOf(t,Ase),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t},cC=class{constructor(t,n){this.registry=t,this.node=n}registry;node;get(t){return this.registry.get(t)}set(t,n){return this.registry.set(t,n)}setSelf(t){return this.node.setValue(t)}refreshSelf(){return this.node.invalidate()}},Vi={disabled:0,collect:1,commit:2},sn={phase:Vi.disabled,depth:0,stale:[],notify:new Set};function PH(e){sn.phase=Vi.collect,sn.depth++;try{if(e(),sn.depth===1){for(let t=0;t<sn.stale.length;t++)FH(sn.stale[t]);sn.phase=Vi.commit;for(let t of sn.notify)t.notify();sn.notify.clear()}}finally{sn.depth--,sn.depth===0&&(sn.phase=Vi.disabled,sn.stale=[])}}function FH(e){if(e.state===Jr.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=Jr.stale,e.disposeLifetime()}for(let t of e.parents)t.state!==Jr.valid&&FH(t);e.state!==Jr.valid&&e.value()}var Qc={message:m.String},NH={field:m.optionalKey(m.String),message:m.String},og=class extends m.TaggedError()("NotFound",Qc){},SE=class extends m.TaggedError()("Unauthorized",Qc){},Hf=class extends m.TaggedError()("Forbidden",Qc){},bE=class extends m.TaggedError()("BadRequest",NH){},sg=class extends m.TaggedError()("Conflict",NH){},EE=class extends m.TaggedError()("PreconditionFailed",Qc){},UH=class extends m.TaggedError()("TooManyRequests",Qc){},ig=class extends m.TaggedError()("AuthUnavailable",Qc){},kr=class extends m.TaggedError()("InternalServerError",Qc){},ag=class extends m.TaggedError()("ServiceUnavailable",Qc){};function wE(e,t,n,r=[]){let o=n.map(({name:s,control:i})=>t.registry.subscribe(e.error(s),a=>i?.setCustomValidity(a??""),{immediate:!0}));for(let{path:s,control:i}of r)o.push(t.registry.subscribe(e.errorAt(s),a=>i.setCustomValidity(a??""),{immediate:!0}));return t.signal.addEventListener("abort",()=>{for(let s of o)s()},{once:!0}),()=>{for(let{name:s}of n)e.blur(s);return n.every(({name:s})=>t.registry.get(e.error(s))===void 0)}}function vE(e){let t=new AbortController,n=xE();function r(){t.abort(),n.dispose(),delete e.dataset.bound,document.removeEventListener("board-page",o),window.removeEventListener("pagehide",r)}function o(){e.isConnected||r()}return document.addEventListener("board-page",o),window.addEventListener("pagehide",r),{registry:n,release:r,signal:t.signal}}var DH=new WeakSet;function uC(e){for(let t of e.querySelectorAll("[data-handoff-copy]"))DH.has(t)||(DH.add(t),t.addEventListener("click",async()=>{let n=document.getElementById(t.dataset.handoffCopy??""),r=t.parentElement?.querySelector("[data-copy-status]");if(n instanceof HTMLTextAreaElement&&r)try{await navigator.clipboard.writeText(n.value),r.textContent="Prompt copied. Paste it into your existing agent session."}catch{n.focus(),n.select(),r.textContent="Clipboard unavailable. The prompt is selected; copy it manually."}}))}function LH(e,t,n){let r=document.createElement("label");r.textContent="Prompt for your existing agent session";let o=document.createElement("textarea");o.id=`handoff-prompt-${t}`,o.readOnly=!0,o.rows=3,o.value=n,r.append(o);let s=document.createElement("button");s.type="button",s.dataset.handoffCopy=o.id,s.textContent="Copy tiny prompt";let i=document.createElement("p");i.dataset.copyStatus="",i.setAttribute("role","status"),i.textContent="Prepared; receipt not confirmed. Copy the prompt to your agent.",e.replaceChildren(r,s,i),e.hidden=!1,uC(e)}var Cse=m.Struct({constraints:m.String,goal:m.String,nextAction:m.String});function qH(e){let t=e.elements.namedItem("recipient"),n=e.elements.namedItem("goal"),r=e.elements.namedItem("constraints"),o=e.elements.namedItem("nextAction");if(t instanceof HTMLInputElement&&n instanceof HTMLTextAreaElement&&r instanceof HTMLTextAreaElement&&o instanceof HTMLTextAreaElement)return{constraints:r,goal:n,nextAction:o,recipient:t}}function jH(e,t){if(t.body)try{let n=m.decodeUnknownOption(Cse)(JSON.parse(t.body));Pe.isSome(n)&&(e.constraints.value=n.value.constraints,e.goal.value=n.value.goal,e.nextAction.value=n.value.nextAction,e.recipient.value=t.author)}catch{e.goal.value=t.body,e.recipient.value=t.author}}var xt=m.String.check(m.isPattern(/^[a-zA-Z\d][a-zA-Z\d._-]*$/u));var No=m.String.check(m.isPattern(/^[a-f\d]{64}$/u)),TE=m.Literals(["answer","clarify","not_now"]),Ose=m.Struct({prompt:xt.check(m.isMaxLength(128)),selected:m.Array(xt.check(m.isMaxLength(128))).check(m.isMaxLength(32)),text:m.String.check(m.isMaxLength(8192))}),IE=m.Array(Ose).check(m.isMaxLength(32)),fC=m.Struct({deadline:m.Number.check(m.isFinite(),m.isGreaterThanOrEqualTo(0),m.isLessThanOrEqualTo(864e13)),item:xt,reason:m.String,registeredAt:m.Number.check(m.isFinite(),m.isGreaterThanOrEqualTo(0),m.isLessThanOrEqualTo(864e13)),request:xt,reviewedRevision:No,source:m.String}),kE=m.Struct({answers:m.optional(IE),author:m.String.check(m.isPattern(/\S/u),m.isMaxLength(200)),question:xt,recordedAt:m.Number.check(m.isFinite(),m.isGreaterThanOrEqualTo(0),m.isLessThanOrEqualTo(864e13)),reviewedRevision:No,supersedes:m.optional(xt),type:TE}),AE=m.Struct({context:m.String,id:xt,item:xt,reason:m.String,request:xt,reviewedRevision:No,source:m.String}),RE=m.Struct({context:m.String,id:xt,question:fC}),Jd=m.Struct({body:m.String,id:xt,response:kE}),BH=m.Struct({question:RE,responses:m.Array(Jd)}),$H=m.Struct({expired:m.Boolean,question:RE,response:m.optional(Jd)}),Gd=m.Struct({answers:m.optional(IE),author:kE.fields.author,body:m.String.check(m.isMaxLength(32768)),id:xt,question:xt,supersedes:m.optional(xt),type:TE});var HH=2*1024*1024,lC=720*60*60*1e3;function _se(e){return{..."question"in e?{question:m.decodeUnknownSync(xt)(e.question)}:{},..."recovery"in e?{recovery:m.decodeUnknownSync(m.String)(e.recovery)}:{},..."answers"in e?{answers:m.decodeUnknownSync(IE,{onExcessProperty:"error"})(e.answers)}:{},..."supersedes"in e?{supersedes:m.decodeUnknownSync(xt)(e.supersedes)}:{}}}function CE(e,t){if(e===null)return{drafts:{},expired:!1};if(new TextEncoder().encode(e).length>HH)throw new Error("Draft storage exceeds the workspace limit.");let n=JSON.parse(e);if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("Draft storage is malformed.");let r={},o=!1;for(let[s,i]of Object.entries(n)){if(typeof i!="object"||i===null||!("author"in i)||!("body"in i)||!("id"in i)||!("revision"in i)||!("type"in i)||!("updatedAt"in i)||typeof i.author!="string"||typeof i.body!="string"||typeof i.id!="string"||typeof i.revision!="string"||i.type!=="answer"&&i.type!=="clarify"&&i.type!=="not_now"||typeof i.updatedAt!="number"||!Number.isFinite(i.updatedAt))throw new Error("Draft storage is malformed.");if(i.updatedAt>t||t-i.updatedAt>=lC){o=!0;continue}r[s]={..._se(i),author:i.author,body:i.body,id:i.id,revision:i.revision,type:i.type,updatedAt:i.updatedAt}}return{drafts:r,expired:o}}function OE(e){let t=JSON.stringify(e);if(new TextEncoder().encode(t).length>HH)throw new Error("Draft storage is full. Copy this draft before clearing workspace drafts.");return t}var Ji=new Map;function _E(e,t,n,r,o,s="response"){let i=`${JSON.stringify(r)}:${e}`;function a(){if(!n)throw new Error("Draft storage unavailable");return n}let c=!1,u={};try{let x=CE(a().getItem(r),Y.runSync(Ii.currentTimeMillis));u=x.drafts,x.expired&&o("Expired drafts were cleared after 30 days. Saved responses are unaffected."),a().setItem(r,OE(u))}catch{c=!0,o("Draft history is unavailable or malformed. Keep a copy; edits remain in this window.")}let f=Ji.get(i);f&&Y.runSync(Ii.currentTimeMillis)-f.updatedAt>=lC&&(Ji.delete(i),o("A window draft expired after 30 days. Saved responses are unaffected."));let l=Ji.get(i)??u[e]??{author:"",body:"",id:`${s}.${crypto.randomUUID()}`,revision:t,type:"answer",updatedAt:Y.runSync(Ii.currentTimeMillis)};l.revision!==t&&o("Source changed since this draft. Your text is retained; review the new source and preview to bind it to this revision.");function p(x){l={...Ji.get(i)??l,...x,updatedAt:Y.runSync(Ii.currentTimeMillis)},Ji.set(i,l);try{if(c)throw new Error("Unknown draft history");let S=CE(a().getItem(r),Y.runSync(Ii.currentTimeMillis)).drafts;a().setItem(r,OE({...S,[e]:l}))}catch{o("Draft could not be persisted (storage full or unavailable). Keep a copy; your text remains in this window.")}return l}function h(){try{a().removeItem(r),c=!1;for(let x of Ji.keys())x.startsWith(`${JSON.stringify(r)}:`)&&Ji.delete(x);o("Workspace drafts cleared. Saved responses are unchanged; this visible text remains until you navigate away.")}catch{o("Draft storage could not be cleared.")}}function g(x){if(Ji.get(i)!==x)return Ji.get(i)?.id===x.id&&p({id:`${s}.${crypto.randomUUID()}`}),!1;Ji.delete(i);try{let S=CE(a().getItem(r),Y.runSync(Ii.currentTimeMillis)).drafts;S[e]?.id===x.id&&delete S[e],a().setItem(r,OE(S))}catch{o("Saved response confirmed, but its browser draft could not be cleared.")}return l={...l,answers:void 0,body:"",id:`${s}.${crypto.randomUUID()}`,recovery:void 0,supersedes:void 0,updatedAt:Y.runSync(Ii.currentTimeMillis)},!0}return{clear:h,current:()=>l,saved:g,update:p}}var zH="~effect/http/Cookies";var WH="~effect/http/Cookies/Cookie";var KH="~effect/http/Cookies/CookieError",dC=class extends zw{},VH=class e extends _n("CookieError"){static fromReason(t,n){return new e({reason:new dC({_tag:t,cause:n})})}[KH]=KH;get message(){return this.reason._tag}},Mse={[zH]:zH,...di,toJSON(){return{_id:"effect/Cookies",cookies:ux(this.cookies,e=>e.toJSON())}},pipe(){return ce(this,arguments)}},Pse=e=>{let t=Object.create(Mse);return t.cookies=e,t},Fse=e=>{let t={};for(let n of e)K(t,n.name,n);return Pse(t)},GH=e=>{let t=typeof e=="string"?[e]:e,n=[];for(let r of t){let o=Use(r.trim());o&&n.push(o)}return Fse(n)};function Use(e){let t=e.split(";").map(a=>a.trim()).filter(a=>a!=="");if(t.length===0)return;let n=t[0].indexOf("=");if(n===-1)return;let r=t[0].slice(0,n);if(!Nse.test(r))return;let o=t[0].slice(n+1),s=Dse(o);if(t.length===1)return Object.assign(Object.create(JH),{name:r,value:s,valueEncoded:o});let i={};for(let a=1;a<t.length;a++){let c=t[a],u=c.indexOf("="),f=u===-1?c:c.slice(0,u).trim(),l=u===-1?void 0:c.slice(u+1).trim();switch(f.toLowerCase()){case"domain":{if(l===void 0)break;let p=l.trim().replace(/^\./,"");p&&(i.domain=p);break}case"expires":{if(l===void 0)break;let p=new Date(l);isNaN(p.getTime())||(i.expires=p);break}case"max-age":{if(l===void 0)break;let p=parseInt(l,10);isNaN(p)||(i.maxAge=qw(p));break}case"path":{if(l===void 0)break;l[0]==="/"&&(i.path=l);break}case"priority":{if(l===void 0)break;switch(l.toLowerCase()){case"low":i.priority="low";break;case"medium":i.priority="medium";break;case"high":i.priority="high";break}break}case"httponly":{i.httpOnly=!0;break}case"secure":{i.secure=!0;break}case"partitioned":{i.partitioned=!0;break}case"samesite":{if(l===void 0)break;switch(l.toLowerCase()){case"lax":i.sameSite="lax";break;case"strict":i.sameSite="strict";break;case"none":i.sameSite="none";break}break}}}return Object.assign(Object.create(JH),{name:r,value:s,valueEncoded:o,options:Object.keys(i).length>0?i:void 0})}var Nse=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;var JH={[WH]:WH,...di,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var Dse=e=>{try{return decodeURIComponent(e)}catch{return e}};var zE={};dn(zE,{Fetch:()=>Rz,RequestInit:()=>HE,layer:()=>cie});var QH=Symbol.for("~effect/http/Headers");var cg=Object.defineProperties(Object.create(null),{[QH]:{value:QH},[hu]:{value(e){return qse(this,ze(e,mC))}},toJSON:{value(){return Bo(this)}},[ke]:{value(e){return Lse(this,e)}},[Ie]:{value(){return al(this)}},toString:{value:di.toString},[ft]:{value:di[ft]}}),ME=e=>Object.assign(Object.create(cg),e),Lse=tM(mu());var Zd=Object.create(cg),Gi=e=>{if(e===void 0)return Zd;if(Symbol.iterator in e){let n=Object.create(cg);for(let[r,o]of e)n[r.toLowerCase()]=o;return n}let t=Object.create(cg);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(", "):r!==void 0&&(t[n.toLowerCase()]=r);return t},YH=e=>Object.setPrototypeOf(e,cg);var ug=d(3,(e,t,n)=>{let r=ME(e);return r[t.toLowerCase()]=n,r}),XH=d(2,(e,t)=>ME({...e,...Gi(t)})),Qd=d(2,(e,t)=>{let n=ME(e);return Object.assign(n,t),n}),Yc=d(2,(e,t)=>{let n=ME(e);return delete n[t.toLowerCase()],n});var qse=d(2,(e,t)=>{let n={...e},r=o=>{if(typeof o=="string"){let s=o.toLowerCase();s in e&&(n[s]=Hc(e[s]))}else for(let s in e)o.test(s)&&(n[s]=Hc(e[s]))};if(Array.isArray(t))for(let o=0;o<t.length;o++)r(t[o]);else r(t);return n}),pC=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="string"){if(r.toLowerCase()===e)return!0}else if(r.test(e))return!0}return!1},mC=Fe("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var hC="~effect/http/UrlParams",jse=e=>N(e,hC),Bse={...On,[hC]:hC,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:"UrlParams",params:Object.fromEntries(this.params)}},[ke](e){return $se(this,e)},[Ie](){return ra(this.params.flat())}},ez=e=>{let t=Object.create(Bse);return t.params=e,t},fg=e=>{if(jse(e))return e;let t=tz(e),n=[];for(let r=0;r<t.length;r++)if(Array.isArray(t[r][0])){let[o,s]=t[r];n.push([`${o[0]}[${o.slice(1).join("][")}]`,s])}else n.push(t[r]);return ez(n)},tz=e=>{let t=typeof e[Symbol.iterator]=="function"?St(e):Object.entries(e),n=[];for(let[r,o]of t)if(Array.isArray(o))for(let s=0;s<o.length;s++)o[s]!==void 0&&n.push([r,String(o[s])]);else if(typeof o=="object"){let s=tz(o);for(let[i,a]of s)n.push([[r,...typeof i=="string"?[i]:i],a])}else o!==void 0&&n.push([r,String(o)]);return n},$se=pn((e,t)=>Hse(e.params,t.params)),Hse=aM(G_([mu(),mu()]));var nz=ez([]);var rz=d(2,(e,t)=>{let n=fg(t),r=n.params,o=new Set;for(let s=0;s<r.length;s++)o.add(r[s][0]);for(let s=0;s<e.params.length;s++)o.has(e.params[s][0])||r.push(e.params[s]);return n});var xC="~effect/http/HttpBody";var oz="~effect/http/HttpBody/HttpBodyError",sz=class extends _n("HttpBodyError"){[oz]=oz},PE=class{[xC];constructor(){this[xC]=xC}[ft](){return this.toJSON()}toString(){return re(this,{ignoreToString:!0})}},yC=class extends PE{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}},iz=new yC;var SC=class extends PE{_tag="Uint8Array";body;contentType;contentLength;constructor(t,n,r){super(),this.body=t,this.contentType=n,this.contentLength=r}toJSON(){return{_id:"effect/HttpBody",_tag:"Uint8Array",body:this.contentType.startsWith("text/")||this.contentType.endsWith("json")?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},FE=(e,t)=>new SC(e,t??"application/octet-stream",e.length),zse=new TextEncoder,bC=(e,t)=>FE(zse.encode(e),t??"text/plain");var wC="~effect/http/HttpClientError";var Do=class extends _n("HttpClientError"){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[wC]=wC;get request(){return this.reason.request}get response(){return"response"in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},LE=e=>e.endsWith("Error")?e.slice(0,-5):e,qE=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,UE=class extends _n("TransportError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return qE(LE(this._tag),this.description,this.methodAndUrl)}};var NE=class extends _n("InvalidUrlError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return qE(LE(this._tag),this.description,this.methodAndUrl)}};var Xc=class extends _n("DecodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return qE(LE(this._tag),this.description,t)}},DE=class extends _n("EmptyBodyError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return qE(LE(this._tag),this.description,t)}},Yd=class e extends Yn(wC)({_tag:Ye("HttpError"),kind:Ka(["EncodeError","DecodeError","TransportError","InvalidUrlError","StatusCodeError","EmptyBodyError"]),cause:Bt(xn())}){static fromHttpClientError(t){return new e({_tag:"HttpError",kind:t.reason._tag,cause:t.reason})}};var az=[["GET","get"],["POST","post"],["PUT","put"],["DELETE","del"],["PATCH","patch"],["HEAD","head"],["OPTIONS","options"],["TRACE","trace"]];var uz=(e,t)=>t._tag==="Empty"||t._tag==="FormData"?Yc(Yc(e,"content-type"),"content-length"):(e=t.contentType===void 0?Yc(e,"content-type"):ug(e,"content-type",t.contentType),t.contentLength===void 0?Yc(e,"content-length"):ug(e,"content-length",t.contentLength.toString()));var vC=class extends _n("UrlError"){},fz=(e,t,n)=>_p({try:()=>{let r=new URL(e,Kse());for(let o=0;o<t.params.length;o++){let[s,i]=t.params[o];i!==void 0&&r.searchParams.append(s,i)}return n!==void 0&&(r.hash=n),r},catch:r=>new vC({cause:r})}),Kse=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname};var dz="~effect/http/HttpClientRequest";var Vse={[dz]:dz,...di,toJSON(){return{_id:"HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Bo(this.headers),body:this.body.toJSON()}},pipe(){return ce(this,arguments)}};function Zi(e,t,n,r,o,s){let i=Object.create(Vse);return i.method=e,i.url=t,i.urlParams=n,i.hash=r,i.headers=o,i.body=s,i}var Jse=Zi("GET","",nz,D(),Zd,iz),pz=e=>(t,n)=>Gse(Jse,{method:e,url:t,...n??void 0});var Gse=d(2,(e,t)=>{let n=e;return t.method&&(n=mz(n,t.method)),t.url&&(n=xz(n,t.url)),t.headers&&(n=TC(n,t.headers)),t.urlParams&&(n=Yse(n,t.urlParams)),t.hash&&(n=Xse(n,t.hash)),t.body&&(n=Sz(n,t.body)),t.accept&&(n=gz(n,t.accept)),t.acceptJson&&(n=Zse(n)),n}),mz=d(2,(e,t)=>Zi(t,e.url,e.urlParams,e.hash,e.headers,e.body)),hz=d(3,(e,t,n)=>Zi(e.method,e.url,e.urlParams,e.hash,ug(e.headers,t,n),e.body)),TC=d(2,(e,t)=>Zi(e.method,e.url,e.urlParams,e.hash,XH(e.headers,t),e.body));var gz=d(2,(e,t)=>hz(e,"Accept",t)),Zse=gz("application/json"),xz=d(2,(e,t)=>{if(typeof t=="string")return Zi(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=fg(n.searchParams),o=Au(n.hash===""?void 0:n.hash.slice(1));return n.search="",n.hash="",Zi(e.method,n.toString(),r,o,e.headers,e.body)}),yz=d(2,(e,t)=>t===""?e:Zi(e.method,Qse(t,e.url),e.urlParams,e.hash,e.headers,e.body));var Qse=(e,t)=>{let n=e.endsWith("/"),r=t.startsWith("/");return n&&r?e+t.slice(1):!n&&!r?e+"/"+t:e+t};var Yse=d(2,(e,t)=>Zi(e.method,e.url,rz(e.urlParams,t),e.hash,e.headers,e.body));var Xse=d(2,(e,t)=>Zi(e.method,e.url,e.urlParams,L(t),e.headers,e.body));var Sz=d(2,(e,t)=>Zi(e.method,e.url,e.urlParams,e.hash,uz(e.headers,t),t));var zf="~effect/http/HttpIncomingMessage";var bz=(e,t)=>{let n=e.headers["content-type"]??"",r;if(n.includes("application/json"))try{r=Oi(e.json)}catch{}else if(n.includes("text/")||n.includes("urlencoded"))try{r=Oi(e.text)}catch{}let o={...t,headers:Bo(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(o.body=r),o};var Xd="~effect/http/HttpClientResponse",Ez=(e,t)=>new AC(e,t);var AC=class extends Xg{[zf];[Xd];request;source;constructor(t,n){super(),this.request=t,this.source=n,this[zf]=zf,this[Xd]=Xd}toJSON(){return bz(this,{_id:"HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return Gi(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=GH(this.source.headers.getSetCookie())}get remoteAddress(){return D()}get stream(){return this.source.body?MR({evaluate:()=>this.source.body,onError:t=>new Do({reason:new Xc({request:this.request,response:this,cause:t})})}):qf(new Do({reason:new DE({request:this.request,response:this,description:"can not create stream from empty body"})}))}get json(){return _(this.text,t=>ts({try:()=>t===""?null:JSON.parse(t),catch:n=>new Do({reason:new Xc({request:this.request,response:this,cause:n})})}))}textBody;get text(){return this.textBody??=te(this.arrayBuffer,t=>new TextDecoder().decode(t))}get urlParamsBody(){return _(this.text,t=>ts({try:()=>fg(new URLSearchParams(t)),catch:n=>new Do({reason:new Xc({request:this.request,response:this,cause:n})})}))}formDataBody;get formData(){return this.formDataBody??=qs({try:()=>this.source.formData(),catch:t=>new Do({reason:new Xc({request:this.request,response:this,cause:t})})}).pipe(Ny,Oi)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody?this.arrayBufferBody:(this.arrayBufferBody=qs({try:()=>this.source.arrayBuffer(),catch:t=>new Do({reason:new Xc({request:this.request,response:this,cause:t})})}).pipe(Ny,Oi),this.arrayBufferBody)}pipe(){return ce(this,arguments)}};var wz=e=>YH({b3:`${e.traceId}-${e.spanId}-${e.sampled?"1":"0"}${mr(e.parent,{onNone:()=>"",onSome:t=>`-${t.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?"01":"00"}`});var Tz="~effect/http/HttpClient";var CC=qe("effect/HttpClient");var eie=d(2,(e,t)=>OC(n=>t(e.postprocess(n)),e.preprocess));var OC=(e,t)=>{let n=Object.create(tie);return n.preprocess=t,n.postprocess=e,n.execute=function(r){return e(t(r))},n},tie={[Tz]:Tz,pipe(){return ce(this,arguments)},...di,toJSON(){return{_id:"effect/HttpClient"}},...Object.fromEntries(az.map(([e,t])=>[t,function(n,r){return this.execute(pz(e)(n,r))}]))},Iz=e=>OC(t=>_(t,n=>kn(r=>{let o=iie.get(n),s=o??new AbortController,i=fz(n.url,n.urlParams,Ko(n.hash));if(we(i))return Q(new Do({reason:new NE({request:n,cause:i.failure})}));let a=i.success;if(r.getRef(Rl)||r.getRef(nie)(n)){let u=e(n,a,s.signal,r);return o?u:Oo(f=>io(f(u),{onSuccess(l){return BE.register(l,s),k(new $E(l,s))},onFailure(l){return fy(l)&&s.abort(),lt(l)}}))}return Sm(r.getRef(sie)(n),{kind:"client"},u=>{u.attribute("http.request.method",n.method),u.attribute("server.address",a.origin),a.port!==""&&u.attribute("server.port",+a.port),u.attribute("url.full",a.toString()),u.attribute("url.path",a.pathname),u.attribute("url.scheme",a.protocol.slice(0,-1));let f=a.search.slice(1);f!==""&&u.attribute("url.query",f);let l=r.getRef(mC),p=r.getRef(rie);for(let h in n.headers)p(h,"request")&&u.attribute(`http.request.header.${h}`,pC(h,l)?"<redacted>":n.headers[h]);return n=r.getRef(oie)?TC(n,wz(u)):n,Oo(h=>h(e(n,a,s.signal,r)).pipe(ed(u,{captureStackTrace:!1}),io({onSuccess:g=>{u.attribute("http.response.status_code",g.status);for(let x in g.headers)p(x,"response")&&u.attribute(`http.response.header.${x}`,pC(x,l)?"<redacted>":g.headers[x]);return o?k(g):(BE.register(g,s),k(new $E(g,s)))},onFailure(g){return!o&&fy(g)&&s.abort(),lt(g)}})))})})),k),kz=d(2,(e,t)=>OC(e.postprocess,n=>te(e.preprocess(n),t)));var nie=Fe("effect/http/HttpClient/TracerDisabledWhen",{defaultValue:()=>fu}),rie=Fe("effect/http/HttpClient/TracerHeaderFilter",{defaultValue:()=>cn}),oie=Fe("effect/HttpClient/TracerPropagationEnabled",{defaultValue:cn}),sie=Fe("effect/http/HttpClient/SpanNameGenerator",{defaultValue:()=>e=>`http.client ${e.method}`}),Az=e=>ro(CC)(yr(t=>te(e,n=>eie(n,Xu(r=>ir(t,r)))))),BE=(()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){let t=new FinalizationRegistry(n=>{n.abort()});return{register(n,r){t.register(n,r,n)},unregister(n){t.unregister(n)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),iie=new WeakMap,$E=class{original;controller;constructor(t,n){this.original=t,this.controller=n}[Xd]=Xd;[zf]=zf;applyInterrupt(t){return V(()=>(BE.unregister(this.original),Ri(t,()=>ae(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return Vr(()=>(BE.unregister(this.original),Gh(this.original.stream,ae(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[ft](){return this.original[ft]()}pipe(){return ce(this,arguments)}};var Rz=Fe("effect/http/FetchHttpClient/Fetch",{defaultValue:()=>globalThis.fetch}),HE=class extends qe()("effect/http/FetchHttpClient/RequestInit"){},aie=Iz((e,t,n,r)=>{let o=r.getRef(Rz),s=da(r.context,HE)??{},i=s.headers?Qd(Gi(s.headers),e.headers):e.headers;i["content-length"]&&(i=Yc(i,"content-length"));let a=c=>te(qs({try:()=>o(t,{...s,method:e.method,headers:i,body:c,duplex:e.body._tag==="Stream"?"half":void 0,signal:n}),catch:u=>new Do({reason:new UE({request:e,cause:u})})}),u=>Ez(e,u));switch(e.body._tag){case"Raw":case"Uint8Array":return a(e.body.body);case"FormData":return a(e.body.formData);case"Stream":return _(WR(e.body.stream),a)}return a(void 0)}),cie=Az(k(aie));var Oz=qe("effect/socket/Socket");var MC="~effect/socket/Socket/CloseEvent",Cz=class{[MC];code;reason;constructor(t=1e3,n){this[MC]=MC,this.code=t,this.reason=n}toString(){return this.reason?`${this.code}: ${this.reason}`:`${this.code}`}};var WE="~effect/socket/Socket/SocketError",uie=e=>N(e,WE),PC=class extends Yn("effect/socket/Socket/SocketReadError")({_tag:Ye("SocketReadError"),cause:xn()}){message="An error occurred during Read"},FC=class extends Yn("effect/socket/Socket/SocketWriteError")({_tag:Ye("SocketWriteError"),cause:xn()}){message="An error occurred during Write"},lg=class extends Yn("effect/socket/Socket/SocketOpenError")({_tag:Ye("SocketOpenError"),kind:Ka(["Unknown","Timeout"]),cause:xn()}){get message(){return this.kind==="Timeout"?'timeout waiting for "open"':"An error occurred during Open"}},dg=class extends Yn("effect/socket/Socket/SocketCloseError")({_tag:Ye("SocketCloseError"),code:ai,closeReason:Bt(de)}){static filterClean(t){return function(n){return ep.is(n)&&n.reason._tag==="SocketCloseError"&&t(n.reason.code)?le(n.reason):ge(n)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},UC=Ve([PC,FC,lg,dg]),ep=class extends TR(WE)("SocketError",{_tag:Ye("SocketError"),reason:UC}){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[WE]=WE;static is(t){return uie(t)}message=this.reason.message};var Ug={};dn(Ug,{ConnectionHooks:()=>Fg,CurrentHeaders:()=>T0,Protocol:()=>ta,layerProtocolHttp:()=>Bce,layerProtocolSocket:()=>zce,layerProtocolWorker:()=>Wce,make:()=>UO,makeNoSerialization:()=>k3,makeProtocolHttp:()=>A3,makeProtocolSocket:()=>R3,makeProtocolWorker:()=>C3,withHeaders:()=>jce});var pg=class extends qe()("effect/workers/Transferable/Collector"){},_z=()=>{let e=[],t=o=>{e.push(...o)},n=()=>e,r=()=>{let o=e;return e=[],o};return pg.of({addAllUnsafe:t,addAll:o=>ae(()=>t(o)),readUnsafe:n,read:ae(n),clearUnsafe:r,clear:ae(r)})};var NC="~effect/workers/WorkerError";var DC=class extends Yn("effect/workers/WorkerError/WorkerSpawnError")({_tag:Ye("WorkerSpawnError"),message:de,cause:Bt(xn())}){},LC=class extends Yn("effect/workers/WorkerError/WorkerSendError")({_tag:Ye("WorkerSendError"),message:de,cause:Bt(xn())}){},qC=class extends Yn("effect/workers/WorkerError/WorkerReceiveError")({_tag:Ye("WorkerReceiveError"),message:de,cause:Bt(xn())}){},jC=class extends Yn("effect/workers/WorkerError/WorkerUnknownError")({_tag:Ye("WorkerUnknownError"),message:de,cause:Bt(xn())}){},BC=Ve([DC,LC,qC,jC]),Mz=class extends Yn(NC)({_tag:Ye("WorkerError"),reason:BC}){constructor(t){super({...t,cause:t.reason.cause})}[NC]=NC;get message(){return this.reason.message}};var KE=class extends qe()("effect/workers/Worker/WorkerPlatform"){};var np={};dn(np,{ServerClient:()=>WC,custom:()=>gie,exitSchema:()=>KC,fork:()=>Sie,isRpc:()=>mie,isWrapper:()=>tp,make:()=>Fz,uninterruptible:()=>bie,unwrap:()=>xie,wrap:()=>GE,wrapMap:()=>yie});var $C="~effect/rpc/RpcSchema/StreamSchema";function mg(e){return N(e,$C)}function VE(e){return mg(e)?L({success:e.success,error:e.error}):D()}var pie=po(Ne);function Pz(e,t){return se(pie.ast,{[$C]:$C,success:e,error:t})}var zC="~effect/rpc/Rpc",mie=e=>N(e,zC),WC=class{id;annotations;constructor(t){this.id=t,this.annotations=Tt()}annotate(t,n){return this.annotations=Ge(this.annotations,t,n),this}},hie={[zC]:zC,pipe(){return ce(this,arguments)},setSuccess(e){return eu({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return eu({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return eu({_tag:this._tag,payloadSchema:Nf(e)?e:ie(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return eu({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return eu({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return eu({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Ge(this.annotations,e,t)})},annotateMerge(e){return eu({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:ir(this.annotations,e)})}},eu=e=>{function t(){}return Object.setPrototypeOf(t,hie),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},Fz=(e,t)=>{let n=t?.success??Bd,r=t?.error??$i,o=t?.defect??xn(),s;return t?.primaryKey?s=class extends eE(`effect/rpc/Rpc/${e}`)(t.payload){[fH](){return t.primaryKey(this)}}:s=Nf(t?.payload)?t?.payload:t?.payload?ie(t?.payload):Bd,eu({_tag:e,payloadSchema:s,successSchema:t?.stream?Pz(n,r):n,errorSchema:t?.stream?$i:r,defectSchema:o,annotations:Tt(),middlewares:new Set})},gie=e=>(t,n)=>{let r=n?.success??Bd,o=n?.error??$i,s=n?.defect??xn(),i=e({success:r,error:o,defect:s});return Fz(t,{...i,primaryKey:n?.primaryKey,payload:n?.payload,stream:n?.stream})},HC=new WeakMap,KC=e=>{if(HC.has(e))return HC.get(e);let t=e,n=new Set([t.errorSchema]),r=VE(t.successSchema);_e(r)&&n.add(r.value.error);for(let s of t.middlewares)n.add(s.error);let o=Yb(_e(r)?Bd:t.successSchema,Ve([...n]),t.defectSchema);return HC.set(e,o),o},hg="~effect/rpc/Rpc/Wrapper",tp=e=>hg in e,GE=e=>t=>tp(t)?{[hg]:hg,value:t.value,fork:e.fork??t.fork,uninterruptible:e.uninterruptible??t.uninterruptible}:{[hg]:hg,value:t,fork:e.fork??!1,uninterruptible:e.uninterruptible??!1},xie=e=>tp(e)?e.value:e,yie=(e,t)=>tp(e)?GE(e)(t(e.value)):t(e),Sie=GE({fork:!0}),bie=GE({uninterruptible:!0});var VC="~effect/rpc/RpcClientError",tu=class extends Yn("effect/rpc/RpcClientError/RpcClientDefect")({_tag:Ye("RpcClientDefect"),message:de,cause:xn()}){},ui=class extends Yn(VC)({_tag:Ye("RpcClientError"),reason:Ve([BC,UC,Yd,tu])}){[VC]=VC;get message(){return`${this.reason._tag}: ${this.reason.message}`}};var xg=e=>e;var Uz={_tag:"Ping"};var gg=Ve([de,jd]),wie=ie({_tag:Ye("Request"),id:gg,tag:de,payload:ps,headers:Xt(zc([de,de])),isNotification:Bt(Mt(!0)),traceId:Bt(de),spanId:Bt(de),sampled:Bt(Kc)}),JC=Ve([wie,ie({_tag:Ye("Ack"),requestId:gg}),ie({_tag:Ye("Interrupt"),requestId:gg}),ie({_tag:Ye("Ping")}),ie({_tag:Ye("Eof")}),ie({_tag:Ye("Chunk"),requestId:gg,values:ps}),ie({_tag:Ye("Exit"),requestId:gg,exit:ps}),ie({_tag:Ye("Defect"),defect:ps}),ie({_tag:Ye("Pong")})]);var GC=e=>{switch(e._tag){case"Exit":case"Defect":case"ClientProtocolError":return!0;default:return!1}};var Pg={};dn(Pg,{MaxBufferSizeExceeded:()=>_g,RpcSerialization:()=>Rn,json:()=>x3,jsonRpc:()=>S3,layerJson:()=>Ace,layerJsonRpc:()=>Oce,layerMsgPack:()=>Mce,layerMsgPackWith:()=>Pce,layerNdJsonRpc:()=>_ce,layerNdjson:()=>Rce,layerNdjsonWith:()=>Cce,layerSchemaBinary:()=>Fce,makeMsgPack:()=>FO,makeNdjson:()=>w0,msgPack:()=>v3,ndJsonRpc:()=>b3,ndjson:()=>y3});var QC;try{QC=new TextDecoder}catch{}var X,mo,I=0;var Vz=[],YC=Vz,XC=0,yt={},Je,nu,xs=0,Qi=0,er,Qa,ho=[],He,Dz={useRecords:!1,mapsAsObjects:!0},yg=class{},tO=new yg;tO.name="MessagePack 0xC1";var ru=!1,Lz=2;var Yi=class e{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=!1&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,n){if(X)return Yz(()=>(QE(),this?this.unpack(t,n):e.prototype.unpack.call(Dz,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof n=="object"?(mo=n.end||t.length,I=n.start||0):(I=0,mo=n>-1?n:t.length),XC=0,Qi=0,nu=null,YC=Vz,er=null,X=t;try{He=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw X=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof e){if(yt=this,this.structures)return Je=this.structures,ZE(n);(!Je||Je.length>0)&&(Je=[])}else yt=Dz,(!Je||Je.length>0)&&(Je=[]);return ZE(n)}unpackMultiple(t,n){let r,o=0;try{ru=!0;let s=t.length,i=this?this.unpack(t,s):XE.unpack(t,s);if(n){if(n(i,o,I)===!1)return;for(;I<s;)if(o=I,n(ZE(),o,I)===!1)return}else{for(r=[i];I<s;)o=I,r.push(ZE());return r}}catch(s){throw s.lastPosition=o,s.values=r,s}finally{ru=!1,QE()}}_mergeStructures(t,n){this._onLoadedStructures&&(t=this._onLoadedStructures(t)),t=t||[],Object.isFrozen(t)&&(t=t.map(r=>r.slice(0)));for(let r=0,o=t.length;r<o;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in n||[])if(r>=0){let o=t[r],s=n[r];s&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=s)}return this.structures=t}decode(t,n){return this.unpack(t,n)}};function ZE(e){try{if(!yt.trusted&&!ru){let n=Je.sharedLength||0;n<Je.length&&(Je.length=n)}let t;if(yt._readStruct&&X[I]<64&&X[I]>=32?(t=yt._readStruct(X,I,mo),X=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),I=mo):t=yn(),er&&(I=er.postBundlePosition,er=null),ru&&(Je.restoreStructures=null),I==mo)Je&&Je.restoreStructures&&qz(),Je=null,X=null,Qa&&(Qa=null);else{if(I>mo)throw new Error("Unexpected end of MessagePack data");if(!ru){let n;try{n=JSON.stringify(t,(r,o)=>typeof o=="bigint"?`${o}n`:o).slice(0,100)}catch(r){n="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+n)}}return t}catch(t){throw Je&&Je.restoreStructures&&qz(),QE(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||I>mo)&&(t.incomplete=!0),t}}function qz(){for(let e in Je.restoreStructures)Je[e]=Je.restoreStructures[e];Je.restoreStructures=null}function yn(){let e=X[I++];if(e<160)if(e<128){if(e<64)return e;{let t=Je[e&63]||yt.getStructures&&Jz()[e&63];return t?(t.read||(t.read=nO(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,yt.mapsAsObjects){let t={};for(let n=0;n<e;n++){let r=Zz();r==="__proto__"&&(r="__proto_"),t[r]=yn()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(yn(),yn());return t}else{e-=144;let t=new Array(e);for(let n=0;n<e;n++)t[n]=yn();return yt.freezeData?Object.freeze(t):t}else if(e<192){let t=e-160;if(Qi>=I)return nu.slice(I-xs,(I+=t)-xs);if(Qi==0&&mo<140){let n=t<16?oO(t):Gz(t);if(n!=null)return n}return eO(t)}else{let t;switch(e){case 192:return null;case 193:return er?(t=yn(),t>0?er[1].slice(er.position1,er.position1+=t):er[0].slice(er.position0,er.position0-=t)):tO;case 194:return!1;case 195:return!0;case 196:if(t=X[I++],t===void 0)throw new Error("Unexpected end of buffer");return ZC(t);case 197:return t=He.getUint16(I),I+=2,ZC(t);case 198:return t=He.getUint32(I),I+=4,ZC(t);case 199:return Wf(X[I++]);case 200:return t=He.getUint16(I),I+=2,Wf(t);case 201:return t=He.getUint32(I),I+=4,Wf(t);case 202:if(t=He.getFloat32(I),yt.useFloat32>2){let n=YE[(X[I]&127)<<1|X[I+1]>>7];return I+=4,(n*t+(t>0?.5:-.5)>>0)/n}return I+=4,t;case 203:return t=He.getFloat64(I),I+=8,t;case 204:return X[I++];case 205:return t=He.getUint16(I),I+=2,t;case 206:return t=He.getUint32(I),I+=4,t;case 207:return yt.int64AsType==="number"?(t=He.getUint32(I)*4294967296,t+=He.getUint32(I+4)):yt.int64AsType==="string"?t=He.getBigUint64(I).toString():yt.int64AsType==="auto"?(t=He.getBigUint64(I),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=He.getBigUint64(I),I+=8,t;case 208:return He.getInt8(I++);case 209:return t=He.getInt16(I),I+=2,t;case 210:return t=He.getInt32(I),I+=4,t;case 211:return yt.int64AsType==="number"?(t=He.getInt32(I)*4294967296,t+=He.getUint32(I+4)):yt.int64AsType==="string"?t=He.getBigInt64(I).toString():yt.int64AsType==="auto"?(t=He.getBigInt64(I),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=He.getBigInt64(I),I+=8,t;case 212:if(t=X[I++],t==114)return Wz(X[I++]&63);{let n=ho[t];if(n)return n.read?(I++,n.read(yn())):n.noBuffer?(I++,n()):n(X.subarray(I,++I));throw new Error("Unknown extension "+t)}case 213:return t=X[I],t==114?(I++,Wz(X[I++]&63,X[I++])):Wf(2);case 214:return Wf(4);case 215:return Wf(8);case 216:return Wf(16);case 217:return t=X[I++],Qi>=I?nu.slice(I-xs,(I+=t)-xs):Tie(t);case 218:return t=He.getUint16(I),I+=2,Qi>=I?nu.slice(I-xs,(I+=t)-xs):Iie(t);case 219:return t=He.getUint32(I),I+=4,Qi>=I?nu.slice(I-xs,(I+=t)-xs):kie(t);case 220:return t=He.getUint16(I),I+=2,Bz(t);case 221:return t=He.getUint32(I),I+=4,Bz(t);case 222:return t=He.getUint16(I),I+=2,$z(t);case 223:return t=He.getUint32(I),I+=4,$z(t);default:if(e>=224)return e-256;throw e===void 0?rO():new Error("Unknown MessagePack token "+e)}}}var vie=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function nO(e,t){function n(){if(n.count++>Lz){let o;try{o=e.read=new Function("r","return function(){return "+(yt.freezeData?"Object.freeze":"")+"({"+e.map(s=>s==="__proto__"?"__proto_:r()":vie.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"})}")(yn)}catch{return Lz=1/0,n()}return e.read0=o,e.highByte===0&&(e.read=jz(t,e.read)),o()}let r={};for(let o=0,s=e.length;o<s;o++){let i=e[o];i==="__proto__"&&(i="__proto_"),r[i]=yn()}return yt.freezeData?Object.freeze(r):r}return n.count=0,e.read0=n,e.highByte===0?jz(t,n):n}var jz=(e,t)=>function(){let n=X[I++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),o=Je[r]||Jz()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=nO(o,e)),o.read()};function Jz(){let e=Yz(()=>(X=null,yt.getStructures()));return Je=yt._mergeStructures(e,Je)}var eO=Sg,Tie=Sg,Iie=Sg,kie=Sg;function Sg(e){let t;if(e<16&&(t=oO(e)))return t;if(e>64&&QC)return QC.decode(X.subarray(I,I+=e));let n=I+e,r=[];for(t="";I<n;){let o=X[I++];if((o&128)===0)r.push(o);else if((o&224)===192)if(o<194||I>=n||(X[I]&192)!==128)r.push(65533);else{let s=X[I++]&63;r.push((o&31)<<6|s)}else if((o&240)===224){let s=I<n?X[I]:0;if(I>=n||(s&192)!==128||o===224&&s<160||o===237&&s>=160)r.push(65533);else if(I++,I>=n||(X[I]&192)!==128)r.push(65533);else{let i=X[I++]&63;r.push((o&31)<<12|(s&63)<<6|i)}}else if((o&248)===240){let s=I<n?X[I]:0;if(o>244||I>=n||(s&192)!==128||o===240&&s<144||o===244&&s>=144)r.push(65533);else if(I++,I>=n||(X[I]&192)!==128)r.push(65533);else{let i=X[I++]&63;if(I>=n||(X[I]&192)!==128)r.push(65533);else{let a=X[I++]&63,c=(o&7)<<18|(s&63)<<12|i<<6|a;c-=65536,r.push(c>>>10&1023|55296),r.push(56320|c&1023)}}}else r.push(65533);r.length>=4096&&(t+=Xn.apply(String,r),r.length=0)}return r.length>0&&(t+=Xn.apply(String,r)),t}function rO(){let e=new Error("Unexpected end of MessagePack data");return e.incomplete=!0,e}function Bz(e){if(e>mo-I)throw rO();let t=new Array(e);for(let n=0;n<e;n++)t[n]=yn();return yt.freezeData?Object.freeze(t):t}function $z(e){if(e>(mo-I)/2)throw rO();if(yt.mapsAsObjects){let t={};for(let n=0;n<e;n++){let r=Zz();r==="__proto__"&&(r="__proto_"),t[r]=yn()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(yn(),yn());return t}}var Xn=String.fromCharCode;function Gz(e){let t=I,n=new Array(e);for(let r=0;r<e;r++){let o=X[I++];if((o&128)>0){I=t;return}n[r]=o}return Xn.apply(String,n)}function oO(e){if(e<4)if(e<2){if(e===0)return"";{let t=X[I++];if((t&128)>1){I-=1;return}return Xn(t)}}else{let t=X[I++],n=X[I++];if((t&128)>0||(n&128)>0){I-=2;return}if(e<3)return Xn(t,n);let r=X[I++];if((r&128)>0){I-=3;return}return Xn(t,n,r)}else{let t=X[I++],n=X[I++],r=X[I++],o=X[I++];if((t&128)>0||(n&128)>0||(r&128)>0||(o&128)>0){I-=4;return}if(e<6){if(e===4)return Xn(t,n,r,o);{let s=X[I++];if((s&128)>0){I-=5;return}return Xn(t,n,r,o,s)}}else if(e<8){let s=X[I++],i=X[I++];if((s&128)>0||(i&128)>0){I-=6;return}if(e<7)return Xn(t,n,r,o,s,i);let a=X[I++];if((a&128)>0){I-=7;return}return Xn(t,n,r,o,s,i,a)}else{let s=X[I++],i=X[I++],a=X[I++],c=X[I++];if((s&128)>0||(i&128)>0||(a&128)>0||(c&128)>0){I-=8;return}if(e<10){if(e===8)return Xn(t,n,r,o,s,i,a,c);{let u=X[I++];if((u&128)>0){I-=9;return}return Xn(t,n,r,o,s,i,a,c,u)}}else if(e<12){let u=X[I++],f=X[I++];if((u&128)>0||(f&128)>0){I-=10;return}if(e<11)return Xn(t,n,r,o,s,i,a,c,u,f);let l=X[I++];if((l&128)>0){I-=11;return}return Xn(t,n,r,o,s,i,a,c,u,f,l)}else{let u=X[I++],f=X[I++],l=X[I++],p=X[I++];if((u&128)>0||(f&128)>0||(l&128)>0||(p&128)>0){I-=12;return}if(e<14){if(e===12)return Xn(t,n,r,o,s,i,a,c,u,f,l,p);{let h=X[I++];if((h&128)>0){I-=13;return}return Xn(t,n,r,o,s,i,a,c,u,f,l,p,h)}}else{let h=X[I++],g=X[I++];if((h&128)>0||(g&128)>0){I-=14;return}if(e<15)return Xn(t,n,r,o,s,i,a,c,u,f,l,p,h,g);let x=X[I++];if((x&128)>0){I-=15;return}return Xn(t,n,r,o,s,i,a,c,u,f,l,p,h,g,x)}}}}}function Hz(){let e=X[I++],t;if(e<192)t=e-160;else switch(e){case 217:t=X[I++];break;case 218:t=He.getUint16(I),I+=2;break;case 219:t=He.getUint32(I),I+=4;break;default:throw new Error("Expected string")}return Sg(t)}function ZC(e){return yt.copyBuffers?Uint8Array.prototype.slice.call(X,I,I+=e):X.subarray(I,I+=e)}function Wf(e){let t=X[I++];if(ho[t]){let n;return ho[t](X.subarray(I,n=I+=e),r=>{I=r;try{return yn()}finally{I=n}})}else throw new Error("Unknown extension type "+t)}var zz=new Array(4096);function Zz(){let e=X[I++];if(e>=160&&e<192){if(e=e-160,Qi>=I)return nu.slice(I-xs,(I+=e)-xs);if(!(Qi==0&&mo<180))return eO(e)}else return I--,Qz(yn());let t=(e<<5^(e>1?He.getUint16(I):e>0?X[I]:0))&4095,n=zz[t],r=I,o=I+e-3,s,i=0;if(n&&n.bytes==e){for(;r<o;){if(s=He.getUint32(r),s!=n[i++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(s=X[r++],s!=n[i++]){r=1879048192;break}if(r===o)return I=r,n.string;o-=3,r=I}for(n=[],zz[t]=n,n.bytes=e;r<o;)s=He.getUint32(r),n.push(s),r+=4;for(o+=3;r<o;)s=X[r++],n.push(s);let a=e<16?oO(e):Gz(e);return a!=null?n.string=a:n.string=eO(e)}function Qz(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(e==null)return e+"";if(yt.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return e.flat().toString();throw new Error(`Invalid property type for record: ${typeof e}`)}var Wz=(e,t)=>{let n=yn().map(Qz),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let o=Je[e];return o&&(o.isShared||ru)&&((Je.restoreStructures||(Je.restoreStructures=[]))[e]=o),Je[e]=n,n.read=nO(n,r),(n.read0||n.read)()};ho[0]=()=>{};ho[0].noBuffer=!0;ho[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),o=(s,i)=>{let a=i-s;if(a<=40){let l=r.getBigUint64(s);for(let p=s+8;p<i;p+=8)l<<=BigInt(64),l|=r.getBigUint64(p);return l}let c=s+(a>>4<<3),u=o(s,c),f=o(c,i);return u<<BigInt((i-c)*8)|f};n=n<<BigInt((r.byteLength-t)*8)|o(t,r.byteLength)}return n};var Kz={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};ho[101]=()=>{let e=yn();if(!Kz[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return Kz[e[0]](e[1],{cause:e[2]})};ho[105]=e=>{if(yt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=He.getUint32(I-4);Qa||(Qa=new Map);let n=X[I],r;n>=144&&n<160||n==220||n==221?r=[]:n>=128&&n<144||n==222||n==223?r=new Map:(n>=199&&n<=201||n>=212&&n<=216)&&X[I+1]===115?r=new Set:r={};let o={target:r};Qa.set(t,o);let s=yn();if(o.used)Object.assign(r,s);else return o.target=s;if(r instanceof Map)for(let[i,a]of s.entries())r.set(i,a);if(r instanceof Set)for(let i of Array.from(s))r.add(i);return r};ho[112]=e=>{if(yt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=He.getUint32(I-4),n=Qa.get(t);return n.used=!0,n.target};ho[115]=()=>new Set(yn());var sO=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array"),Aie=typeof globalThis=="object"?globalThis:window;ho[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=sO[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw new Error("Could not find typed array for code "+t)}return new Aie[r](n)};ho[120]=()=>{let e=yn();return new RegExp(e[0],e[1])};var Rie=[];ho[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=I;return I+=t-e.length,er=Rie,er=[Hz(),Hz()],er.position0=0,er.position1=0,er.postBundlePosition=I,I=n,yn()};ho[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function Yz(e){yt&&yt._onSaveState&&yt._onSaveState();let t=mo,n=I,r=XC,o=xs,s=Qi,i=nu,a=YC,c=Qa,u=er,f=new Uint8Array(X.slice(0,mo)),l=Je,p=Je.slice(0,Je.length),h=yt,g=ru,x=e();return mo=t,I=n,XC=r,xs=o,Qi=s,nu=i,YC=a,Qa=c,er=u,X=f,ru=g,Je=l,Je.splice(0,Je.length,...p),yt=h,He=new DataView(X.buffer,X.byteOffset,X.byteLength),x}function QE(){X=null,Qa=null,Je=null}var YE=new Array(147);for(let e=0;e<256;e++)YE[e]=+("1e"+Math.floor(45.15-e*.30103));var XE=new Yi({useRecords:!1}),Cie=XE.unpack,Oie=XE.unpackMultiple,_ie=XE.unpack,e0={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Mie=new Float32Array(1),mSe=new Uint8Array(Mie.buffer,0,4);Yi.SUPPORTS_STRUCT_HOOKS=!0;var n0;try{n0=new TextEncoder}catch{}var cO,uO,op=typeof Buffer<"u",t0=op?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,nW=op?Buffer:Uint8Array,Xz=op?4294967296:2144337920,M,bg,Pt,O=0,Ar,an=null,Pie=21760,Fie=/[\u0080-\uFFFF]/,rp=Symbol("record-id"),ou=class extends Yi{constructor(t){super(t),this.offset=0;let n,r,o,s,i,a=nW.prototype.utf8Write?function(A,H){return M.utf8Write(A,H,M.byteLength-H)}:n0&&n0.encodeInto?function(A,H){return n0.encodeInto(A,M.subarray(H)).written}:!1,c=this;t||(t={});let u=t&&t.sequential,f=t.structures||t.saveStructures,l=t.maxSharedStructures;if(l==null&&(l=f?32:0),l>8160)throw new Error("Maximum maxSharedStructure is 8160");t.structuredClone&&t.moreTypes==null&&(this.moreTypes=!0);let p=t.maxOwnStructures;p==null&&(p=f?32:64),!this.structures&&t.useRecords!=!1&&(this.structures=[]);let h=l>32||p+l>64,g=l+64,x=l+p+64;if(x>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let S=[],w=0,E=0;this.pack=this.encode=function(A,H){if(M||(M=new t0(8192),Pt=M.dataView||(M.dataView=new DataView(M.buffer,0,8192)),O=0),Ar=M.length-10,Ar-O<2048?(M=new t0(M.length),Pt=M.dataView||(M.dataView=new DataView(M.buffer,0,M.length)),Ar=M.length-10,O=0):O=O+7&2147483640,r=O,H&iW&&(O+=H&255),i=c.structuredClone?new Map:null,c.bundleStrings&&typeof A!="string"?(an=[],an.size=1/0):an=null,s=c.structures,s){s.uninitialized&&(s=c._mergeStructures(c.getStructures()));let q=s.sharedLength||0;if(q>l)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+s.sharedLength);if(!s.transitions){s.transitions=Object.create(null);for(let J=0;J<q;J++){let Te=s[J];if(!Te)continue;let Re,pe=s.transitions;for(let dt=0,vt=Te.length;dt<vt;dt++){let li=Te[dt];Re=pe[li],Re||(Re=pe[li]=Object.create(null)),pe=Re}pe[rp]=J+64}this.lastNamedStructuresLength=q}u||(s.nextId=q+64)}o&&(o=!1);let U;try{c._writeStruct&&A&&typeof A=="object"?A.constructor===Object?B(A):A.constructor!==Map&&!Array.isArray(A)&&!uO.some(J=>A instanceof J)?B(c.useToJSON!==!1&&A.toJSON?A.toJSON():A):b(A):b(A);let q=an;if(an&&tW(r,b,0),i&&i.idsToInsert){let J=i.idsToInsert.sort((dt,vt)=>dt.offset>vt.offset?1:-1),Te=J.length,Re=-1;for(;q&&Te>0;){let dt=J[--Te].offset+r;dt<q.stringsPosition+r&&Re===-1&&(Re=0),dt>q.position+r?Re>=0&&(Re+=6):(Re>=0&&(Pt.setUint32(q.position+r,Pt.getUint32(q.position+r)+Re),Re=-1),q=q.previous,Te++)}Re>=0&&q&&Pt.setUint32(q.position+r,Pt.getUint32(q.position+r)+Re),O+=J.length*6,O>Ar&&F(O),c.offset=O;let pe=Uie(M.subarray(r,O),J);return i=null,pe}return c.offset=O,H&oW?(M.start=r,M.end=O,M):M.subarray(r,O)}catch(q){throw U=q,q}finally{if(s&&(y(),o&&c.saveStructures)){let q=s.sharedLength||0,J=M.subarray(r,O),Te=(c._prepareStructures||Nie)(s,c);if(!U)return c.saveStructures(Te,Te.isCompatible)===!1?(s.uninitialized=!0,c.pack(A,H)):(c.lastNamedStructuresLength=q,M.length>1073741824&&(M=null),J)}M.length>1073741824&&(M=null),H&sW&&(O=r)}};let y=()=>{E<10&&E++;let A=s.sharedLength||0;if(s.length>A&&!u&&(s.length=A),w>1e4)s.transitions=null,E=0,w=0,S.length>0&&(S=[]);else if(S.length>0&&!u){for(let H=0,U=S.length;H<U;H++)S[H][rp]=0;S=[]}},v=A=>{var H=A.length;H<16?M[O++]=144|H:H<65536?(M[O++]=220,M[O++]=H>>8,M[O++]=H&255):(M[O++]=221,Pt.setUint32(O,H),O+=4);for(let U=0;U<H;U++)b(A[U])},b=A=>{O>Ar&&(M=F(O));var H=typeof A,U;if(H==="string"){let q=A.length;if(an&&q>=4&&q<4096){if((an.size+=q)>Pie){let pe,dt=(an[0]?an[0].length*3+an[1].length:0)+10;O+dt>Ar&&(M=F(O+dt));let vt;an.position?(vt=an,M[O]=200,O+=3,M[O++]=98,pe=O-r,O+=4,tW(r,b,0),Pt.setUint16(pe+r-3,O-r-pe)):(M[O++]=214,M[O++]=98,pe=O-r,O+=4),an=["",""],an.previous=vt,an.size=0,an.position=pe}let Re=Fie.test(A);an[Re?0:1]+=A,M[O++]=193,b(Re?-q:q);return}let J;q<32?J=1:q<256?J=2:q<65536?J=3:J=5;let Te=q*3;if(O+Te>Ar&&(M=F(O+Te)),q<64||!a){let Re,pe,dt,vt=O+J;for(Re=0;Re<q;Re++)pe=A.charCodeAt(Re),pe<128?M[vt++]=pe:pe<2048?(M[vt++]=pe>>6|192,M[vt++]=pe&63|128):(pe&64512)===55296&&((dt=A.charCodeAt(Re+1))&64512)===56320?(pe=65536+((pe&1023)<<10)+(dt&1023),Re++,M[vt++]=pe>>18|240,M[vt++]=pe>>12&63|128,M[vt++]=pe>>6&63|128,M[vt++]=pe&63|128):(M[vt++]=pe>>12|224,M[vt++]=pe>>6&63|128,M[vt++]=pe&63|128);U=vt-O-J}else U=a(A,O+J);U<32?M[O++]=160|U:U<256?(J<2&&M.copyWithin(O+2,O+1,O+1+U),M[O++]=217,M[O++]=U):U<65536?(J<3&&M.copyWithin(O+3,O+2,O+2+U),M[O++]=218,M[O++]=U>>8,M[O++]=U&255):(J<5&&M.copyWithin(O+5,O+3,O+3+U),M[O++]=219,Pt.setUint32(O,U),O+=4),O+=U}else if(H==="number")if(A>>>0===A)A<32||A<128&&this.useRecords===!1||A<64&&!this._writeStruct?M[O++]=A:A<256?(M[O++]=204,M[O++]=A):A<65536?(M[O++]=205,M[O++]=A>>8,M[O++]=A&255):(M[O++]=206,Pt.setUint32(O,A),O+=4);else if(A>>0===A)A>=-32?M[O++]=256+A:A>=-128?(M[O++]=208,M[O++]=A+256):A>=-32768?(M[O++]=209,Pt.setInt16(O,A),O+=2):(M[O++]=210,Pt.setInt32(O,A),O+=4);else{let q;if((q=this.useFloat32)>0&&A<4294967296&&A>=-2147483648){M[O++]=202,Pt.setFloat32(O,A);let J;if(q<4||(J=A*YE[(M[O]&127)<<1|M[O+1]>>7])>>0===J){O+=4;return}else O--}M[O++]=203,Pt.setFloat64(O,A),O+=8}else if(H==="object"||H==="function")if(!A)M[O++]=192;else{if(i){let J=i.get(A);if(J){if(!J.id){let Te=i.idsToInsert||(i.idsToInsert=[]);J.id=Te.push(J)}M[O++]=214,M[O++]=112,Pt.setUint32(O,J.id),O+=4;return}else i.set(A,{offset:O-r})}let q=A.constructor;if(q===Object)P(A);else if(q===Array)v(A);else if(q===Map)if(this.mapAsEmptyObject)M[O++]=128;else{U=A.size,U<16?M[O++]=128|U:U<65536?(M[O++]=222,M[O++]=U>>8,M[O++]=U&255):(M[O++]=223,Pt.setUint32(O,U),O+=4);for(let[J,Te]of A)b(J),b(Te)}else{for(let J=0,Te=cO.length;J<Te;J++){let Re=uO[J];if(A instanceof Re){let pe=cO[J];if(pe.write){pe.type&&(M[O++]=212,M[O++]=pe.type,M[O++]=0);let mp=pe.write.call(this,A);mp===A?Array.isArray(A)?v(A):P(A):b(mp);return}let dt=M,vt=Pt,li=O;M=null;let tc;try{tc=pe.pack.call(this,A,mp=>(M=dt,dt=null,O+=mp,O>Ar&&F(O),{target:M,targetView:Pt,position:O-mp}),b)}finally{dt&&(M=dt,Pt=vt,O=li,Ar=M.length-10)}tc&&(tc.length+O>Ar&&F(tc.length+O),O=eW(tc,M,O,pe.type));return}}if(Array.isArray(A))v(A);else{if(c.useToJSON!==!1&&A.toJSON){let J=A.toJSON();if(J!==A)return b(J)}if(H==="function")return b(this.writeFunction&&this.writeFunction(A));P(A)}}}else if(H==="boolean")M[O++]=A?195:194;else if(H==="bigint"){if(A<9223372036854776e3&&A>=-9223372036854776e3)M[O++]=211,Pt.setBigInt64(O,A);else if(A<18446744073709552e3&&A>0)M[O++]=207,Pt.setBigUint64(O,A);else if(this.largeBigIntToFloat)M[O++]=203,Pt.setFloat64(O,Number(A));else{if(this.largeBigIntToString)return b(A.toString());if(this.useBigIntExtension||this.moreTypes){let q=A<0?BigInt(-1):BigInt(0),J;if(A>>BigInt(65536)===q){let Te=BigInt(18446744073709552e3)-BigInt(1),Re=[];for(;Re.push(A&Te),A>>BigInt(63)!==q;)A>>=BigInt(64);J=new Uint8Array(new BigUint64Array(Re).buffer),J.reverse()}else{let Te=A<0,Re=(Te?~A:A).toString(16);if(Re.length%2?Re="0"+Re:parseInt(Re.charAt(0),16)>=8&&(Re="00"+Re),op)J=Buffer.from(Re,"hex");else{J=new Uint8Array(Re.length/2);for(let pe=0;pe<J.length;pe++)J[pe]=parseInt(Re.slice(pe*2,pe*2+2),16)}if(Te)for(let pe=0;pe<J.length;pe++)J[pe]=~J[pe]}J.length+O>Ar&&F(J.length+O),O=eW(J,M,O,66);return}else throw new RangeError(A+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}O+=8}else if(H==="undefined")this.encodeUndefinedAsNil?M[O++]=192:(M[O++]=212,M[O++]=0,M[O++]=0);else throw new Error("Unknown type: "+H)},T=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?A=>{let H;if(this.skipValues){H=[];for(let J in A)(typeof A.hasOwnProperty!="function"||A.hasOwnProperty(J))&&!this.skipValues.includes(A[J])&&H.push(J)}else H=Object.keys(A);let U=H.length;U<16?M[O++]=128|U:U<65536?(M[O++]=222,M[O++]=U>>8,M[O++]=U&255):(M[O++]=223,Pt.setUint32(O,U),O+=4);let q;if(this.coercibleKeyAsNumber)for(let J=0;J<U;J++){q=H[J];let Te=Number(q);b(isNaN(Te)?q:Te),b(A[q])}else for(let J=0;J<U;J++)b(q=H[J]),b(A[q])}:A=>{M[O++]=222;let H=O-r;O+=2;let U=0;for(let q in A)(typeof A.hasOwnProperty!="function"||A.hasOwnProperty(q))&&(b(q),b(A[q]),U++);if(U>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');M[H+++r]=U>>8,M[H+r]=U&255},R=this.useRecords===!1?T:t.progressiveRecords&&!h?A=>{let H,U=s.transitions||(s.transitions=Object.create(null)),q=O++-r,J;for(let Te in A)if(typeof A.hasOwnProperty!="function"||A.hasOwnProperty(Te)){if(H=U[Te],H)U=H;else{let Re=Object.keys(A),pe=U;U=s.transitions;let dt=0;for(let vt=0,li=Re.length;vt<li;vt++){let tc=Re[vt];H=U[tc],H||(H=U[tc]=Object.create(null),dt++),U=H}q+r+1==O?(O--,Z(U,Re,dt)):z(U,Re,q,dt),J=!0,U=pe[Te]}b(A[Te])}if(!J){let Te=U[rp];Te?M[q+r]=Te:z(U,Object.keys(A),q,0)}}:A=>{let H,U=s.transitions||(s.transitions=Object.create(null)),q=0;for(let Te in A)(typeof A.hasOwnProperty!="function"||A.hasOwnProperty(Te))&&(H=U[Te],H||(H=U[Te]=Object.create(null),q++),U=H);let J=U[rp];J?J>=96&&h?(M[O++]=((J-=96)&31)+96,M[O++]=J>>5):M[O++]=J:Z(U,U.__keys__||Object.keys(A),q);for(let Te in A)(typeof A.hasOwnProperty!="function"||A.hasOwnProperty(Te))&&b(A[Te])},C=typeof this.useRecords=="function"&&this.useRecords,P=C?A=>{C(A)?R(A):T(A)}:R,B=A=>{let H=c._writeStruct(A,M,r,O,s,F,(U,q,J)=>{if(J)return o=!0;O=q;let Te=M;return b(U),y(),Te!==M?{position:O,targetView:Pt,target:M}:O});if(H===0)return P(A);O=H},F=A=>{let H;if(A>16777216){if(A-r>Xz)throw new Error("Packed buffer would be larger than maximum buffer size");H=Math.min(Xz,Math.round(Math.max((A-r)*(A>67108864?1.25:2),4194304)/4096)*4096)}else H=(Math.max(A-r<<2,M.length-1)>>12)+1<<12;let U=new t0(H);return Pt=U.dataView||(U.dataView=new DataView(U.buffer,0,H)),A=Math.min(A,M.length),M.copy?M.copy(U,0,r,A):U.set(M.slice(r,A)),O-=r,r=0,Ar=U.length-10,M=U},Z=(A,H,U)=>{let q=s.nextId;q||(q=64),q<g&&this.shouldShareStructure&&!this.shouldShareStructure(H)?(q=s.nextOwnId,q<x||(q=g),s.nextOwnId=q+1):(q>=x&&(q=g),s.nextId=q+1);let J=H.highByte=q>=96&&h?q-96>>5:-1;A[rp]=q,A.__keys__=H,s[q-64]=H,q<g?(H.isShared=!0,s.sharedLength=q-63,o=!0,J>=0?(M[O++]=(q&31)+96,M[O++]=J):M[O++]=q):(J>=0?(M[O++]=213,M[O++]=114,M[O++]=(q&31)+96,M[O++]=J):(M[O++]=212,M[O++]=114,M[O++]=q),U&&(w+=E*U),S.length>=p&&(S.shift()[rp]=0),S.push(A),b(H))},z=(A,H,U,q)=>{let J=M,Te=O,Re=Ar,pe=r;M=bg,O=0,r=0,M||(bg=M=new t0(8192)),Ar=M.length-10,Z(A,H,q),bg=M;let dt=O;if(M=J,O=Te,Ar=Re,r=pe,dt>1){let vt=O+dt-1;vt>Ar&&F(vt);let li=U+r;M.copyWithin(li+dt,li+1,O),M.set(bg.slice(0,dt),li),O=vt}else M[U+r]=bg[0]}}useBuffer(t){M=t,M.dataView||(M.dataView=new DataView(M.buffer,M.byteOffset,M.byteLength)),Pt=M.dataView,O=0}set position(t){O=t}get position(){return O}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};uO=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,yg];cO=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:s,position:i}=t(6);o[i++]=214,o[i++]=255,s.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:o,targetView:s,position:i}=t(10);o[i++]=215,o[i++]=255,s.setUint32(i,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(i+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:o,targetView:s,position:i}=t(3);o[i++]=212,o[i++]=255,o[i++]=255}else{let{target:o,targetView:s,position:i}=t(15);o[i++]=199,o[i++]=12,o[i++]=255,s.setUint32(i,e.getMilliseconds()*1e6),s.setBigInt64(i+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:o,position:s}=t(this.moreTypes?3:0);this.moreTypes&&(o[s++]=212,o[s++]=115,o[s++]=0),n(r)}},{pack(e,t,n){let{target:r,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(r[o++]=212,r[o++]=101,r[o++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(r[o++]=212,r[o++]=120,r[o++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?iO(e,16,t):aO(op?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==nW&&this.moreTypes?iO(e,sO.indexOf(n.name),t):aO(e,t)}},{pack(e,t){this.moreTypes?iO(e,17,t):aO(op?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function iO(e,t,n,r){let o=e.byteLength;if(o+1<256){var{target:s,position:i}=n(4+o);s[i++]=199,s[i++]=o+1}else if(o+1<65536){var{target:s,position:i}=n(5+o);s[i++]=200,s[i++]=o+1>>8,s[i++]=o+1&255}else{var{target:s,position:i,targetView:a}=n(7+o);s[i++]=201,a.setUint32(i,o+1),i+=4}s[i++]=116,s[i++]=t,e.buffer||(e=new Uint8Array(e)),s.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i)}function aO(e,t){let n=e.byteLength;var r,o;if(n<256){var{target:r,position:o}=t(n+2);r[o++]=196,r[o++]=n}else if(n<65536){var{target:r,position:o}=t(n+3);r[o++]=197,r[o++]=n>>8,r[o++]=n&255}else{var{target:r,position:o,targetView:s}=t(n+5);r[o++]=198,s.setUint32(o,n),o+=4}r.set(e,o)}function eW(e,t,n,r){let o=e.length;switch(o){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:o<256?(t[n++]=199,t[n++]=o):o<65536?(t[n++]=200,t[n++]=o>>8,t[n++]=o&255):(t[n++]=201,t[n++]=o>>24,t[n++]=o>>16&255,t[n++]=o>>8&255,t[n++]=o&255)}return t[n++]=r,t.set(e,n),n+=o,n}function Uie(e,t){let n,r=t.length*6,o=e.length-r;for(;n=t.pop();){let s=n.offset,i=n.id;e.copyWithin(s+r,s,o),r-=6;let a=s+r;e[a++]=214,e[a++]=105,e[a++]=i>>24,e[a++]=i>>16&255,e[a++]=i>>8&255,e[a++]=i&255,o=s}return e}function tW(e,t,n){if(an.length>0){Pt.setUint32(an.position+e,O+n-an.position-e),an.stringsPosition=O-e;let r=an;an=null,t(r[0]),t(r[1])}}function Nie(e,t){return e.isCompatible=n=>{let r=!n||(t.lastNamedStructuresLength||0)===n.length;return r||t._mergeStructures(n),r},e}ou.SUPPORTS_STRUCT_HOOKS=!0;var rW=new ou({useRecords:!1}),Die=rW.pack,Lie=rW.pack;var{NEVER:qie,ALWAYS:jie,DECIMAL_ROUND:Bie,DECIMAL_FIT:$ie}=e0,oW=512,sW=1024,iW=2048;function IW(e,t){let{exact:n,layout:r,recursive:o,target:s}=ap(e),i=Vf(r,t?.fingerprint),a=n?{value:void 0}:void 0;return lO(a===void 0?s:xce(s,a,!o),r,i,a)}function vO(e,t){let{exact:n,exitSuccess:r,layout:o,target:s}=ap(e);if(!n){if(!r)return IW(e,t);let i={value:void 0};return lO(Sce(s,i),o,Vf(o,t?.fingerprint),i,!0)}return lO(bce(s),o,Vf(o,t?.fingerprint),void 0)}function lO(e,t,n,r,o=!1){return ps.pipe(ve(e,mce(t,n,r,o)))}function kW(e,t){let{exact:n,exitSuccess:r,layout:o}=ap(e),s=Vf(o,t?.fingerprint),i=t??$r;if(!n){let a=Jb(IW(e,t),t);return!r||i.onExcessProperty==="error"?a:c=>{if(!b0(c))return a(c);try{return h0(o,c,i,s)}catch(u){throw u instanceof ea?new Wr(u.issue):u}}}return a=>{try{return h0(o,a,i,s)}catch(c){throw c instanceof ea?new Wr(c.issue):c}}}function zie(e,t){let{exact:n,layout:r}=ap(e);if(!n){let i=kW(e,t);return a=>Wie(a.map(i))}let o=Vf(r,t?.fingerprint),s=t??$r;return i=>{try{return r3(r,i,s,o)}catch(a){throw a instanceof ea?new Wr(a.issue):a}}}function Wie(e){if(e.length===1)return e[0];let t=0;for(let o of e)t+=o.length;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.length;return n}function AW(e,t){let{exact:n,exitSuccess:r,layout:o,target:s}=ap(e),i=t??$r,a=n?void 0:Kb(s,i),c=a!==void 0&&r?u=>b0(u)?u:a(u):a;return Kie(o,Vf(o,t?.fingerprint),i,t?.maxFrameSize,c,RW(n,t))}function RW(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw new Error("Binary layout: dictionary needs a schema the binary layer validates on its own");return!0}function CW(e,t){let{exact:n,layout:r}=ap(e),o=RW(n,t),s=kW(e,t),i=zie(e,t);if(!o)return{encode:s,encodeMany:i};let a=Vf(r,t?.fingerprint),c=t??$r,u=qae(),f=l=>{try{return l()}catch(p){throw p instanceof ea?new Wr(p.issue):p}};return{encode:l=>f(()=>h0(r,l,c,a,u)),encodeMany:l=>f(()=>r3(r,l,c,a,u))}}function Kie(e,t,n,r,o,s){let i=s?[]:void 0,a=new Uint8Array(0),c=0,u=0,f,l=!1,p=new vg,h=new wg(n,lae),g=()=>{p.release(),h.clear(),a=gO,c=u=0},x=(y,v)=>{throw new Wr(new Oe({expected:y},v,n))},S=()=>{let y=f;throw f=void 0,y},w=(y,v)=>{let b=y.length-v;b>a.length&&(a=new Uint8Array(Math.max(256,b))),a.set(v===0?y:y.subarray(v),0),c=0,u=b},E={feedSync(y){if(f!==void 0)return S();if(l)return x("parser is spent");let v=u===c,b,T,R;if(v)b=y,T=0,R=y.length;else{if(y.length>0){let F=u-c,Z=F+y.length;if(Z>a.length){let z=new Uint8Array(Math.max(256,a.length*2,Z));z.set(a.subarray(c,u)),a=z,c=0,u=F}else c>0&&(a.copyWithin(0,c,u),c=0,u=F);a.set(y,u),u+=y.length}b=a,T=c,R=u}let C=[],P=()=>(v?T<R&&w(y,T):(c=T,c===u&&(c=u=0)),C),B=(F,Z)=>{l=!0;let z=new Wr(new Oe({expected:F},Z,n));if(g(),C.length===0)throw z;return f=z,C};for(;;){let F=0,Z=-1,z=R-T,A=1;for(let U=0;U<Math.min(6,z);U++){let q=b[T+U];if(F+=(q&127)*A,(q&128)===0){Z=U+1;break}A*=128}if(Z===-1){if(z<6)return P();let U=BigInt(F);for(let q=6;q<Math.min(10,z);q++){let J=b[T+q];if(U|=BigInt(J&127)<<BigInt(q*7),(J&128)===0){if(Z=q+1,U>dO)return B("safe integer length",U);F=Number(U);break}}if(Z===-1)return z>=10?B("uvarint",b.subarray(T,T+10)):P()}if(F===0)return B("nonzero frame length",F);if(r!==void 0&&F>r)return B("frame within maxFrameSize",F);if(Z+F>z)return P();let H=fe;try{fe=0;let U=T+Z;h.beginFrame(),p.reset(b,U,U+F,n,h,t.positional,i);let q=l3(e,p,t);C.push(o===void 0?q:o(q))}catch(U){l=!0,g();let q=U instanceof ea?new Wr(U.issue):Ld(U)?U:(()=>{throw U})();if(C.length===0)throw q;return f=q,C}finally{fe=H}T+=Z+F}},endSync(){if(f!==void 0)return S();if(l)return x("parser is spent");l=!0;let y=c<u?a.subarray(c,u):void 0;if(g(),y!==void 0)return x("complete value",y)},feed:y=>V(()=>{try{return k(E.feedSync(y))}catch(v){if(Ld(v))return Q(v);throw v}}),end:V(()=>{try{return E.endSync(),W}catch(y){if(Ld(y))return Q(y);throw y}})};return E}var Vie="~effect/encoding/SchemaBinary/fieldId",Jie=32,Gie=33,dO=BigInt(Number.MAX_SAFE_INTEGER),u0=BigInt(0),ys=BigInt(1),Zie=BigInt(2),OW=BigInt(7),aW=BigInt(127),Qie=BigInt(1e6),Yie=BigInt(255),cW=BigInt(4294967295),Xie=BigInt(32),Xi=new TextEncoder,eae=new TextDecoder("utf-8",{fatal:!0}),_W=7,uW=0xffffffffffff,tae=0xfffffffffffff,MW=0,PW=1,FW=2,Jf=0,Kf=1,kg=2,Ag=3,Rg=4,Cg=5,nae=6,rae=7,Ss=8;function TO(e){return typeof e=="number"&&Number.isInteger(e)&&e>=-uW&&e<=uW}var g0=8,pO=2199023255551,iu=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function IO(e){for(let t=1;t<=g0;t++){let n=Math.round(e*iu[t]);if(!(n>=-pO&&n<=pO))return 0;if(n/iu[t]===e)return t}return 0}function UW(e){let t=Math.floor(e/2);return e%2===1?-t:t}var wt={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function NW(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}var oae=BigInt("14695981039346656037"),sae=BigInt("1099511628211"),iae=BigInt("18446744073709551615");function fW(e){let t=oae;for(let n=0;n<e.length;n++)t=(t^BigInt(e[n]))*sae&iae;return t}function f0(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function su(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function l0(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function Lo(e,t){for(let n=0;n<8;n++)e.push(Number(t>>BigInt(n*8)&Yie))}function DW(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e[r]-t[r];return e.length-t.length}var ea=class extends Error{issue;constructor(t){super("SchemaBinary failure"),this.issue=t}};function ee(e,t,n){throw Sn(new Oe({expected:e},t,n))}var ot=[],fe=0;function Sn(e){return new ea(fe===0?e:new kt(ot.slice(0,fe),e))}function aae(e){let t=new Uint8Array(LW(e)),n=0;for(;e>127;)t[n++]=e&127|128,e=Math.floor(e/128);return t[n]=e,t}function LW(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var cae=32;function uae(e,t,n,r){let o=n-t;if(o===0)return"";if(o<=cae){let s=fae(e,t,n);if(s!==void 0)return s}try{return eae.decode(e.subarray(t,n))}catch{ee("utf-8",void 0,r)}}function fae(e,t,n){let r="",o=t;for(;o+16<=n;o+=16){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],l=e[o+6],p=e[o+7],h=e[o+8],g=e[o+9],x=e[o+10],S=e[o+11],w=e[o+12],E=e[o+13],y=e[o+14],v=e[o+15];if((s|i|a|c|u|f|l|p|h|g|x|S|w|E|y|v)>127)return;r+=String.fromCharCode(s,i,a,c,u,f,l,p,h,g,x,S,w,E,y,v)}if(o+8<=n){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],l=e[o+6],p=e[o+7];if((s|i|a|c|u|f|l|p)>127)return;r+=String.fromCharCode(s,i,a,c,u,f,l,p),o+=8}switch(n-o){case 0:return r;case 1:{let s=e[o];return s>127?void 0:r+String.fromCharCode(s)}case 2:{let s=e[o],i=e[o+1];return(s|i)>127?void 0:r+String.fromCharCode(s,i)}case 3:{let s=e[o],i=e[o+1],a=e[o+2];return(s|i|a)>127?void 0:r+String.fromCharCode(s,i,a)}case 4:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3];return(s|i|a|c)>127?void 0:r+String.fromCharCode(s,i,a,c)}case 5:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4];return(s|i|a|c|u)>127?void 0:r+String.fromCharCode(s,i,a,c,u)}case 6:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5];return(s|i|a|c|u|f)>127?void 0:r+String.fromCharCode(s,i,a,c,u,f)}default:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],l=e[o+6];return(s|i|a|c|u|f|l)>127?void 0:r+String.fromCharCode(s,i,a,c,u,f,l)}}}var mO=64*1024,lae=256,dae=512,pae=16*1024;function hO(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Eg=hO(mO),d0=class{buf=new Uint8Array(0);view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let t=Eg;(t.writing||t.offset>=t.buf.length)&&(t=Eg=hO(mO)),t.writing=!0,this.arena=t,this.buf=t.buf,this.view=t.view,this.start=t.offset,this.limit=t.buf.length-t.offset,this.len=0}ensure(t){if(this.len+t>this.limit){let n=this.arena,r=this.len+t,o=mO;for(;o<r;)o*=2;let s=hO(o);s.writing=!0,s.buf.set(this.buf.subarray(this.start,this.start+this.len)),n.writing=!1,this.arena=Eg=s,this.buf=s.buf,this.view=s.view,this.start=0,this.limit=s.buf.length}}byte(t){this.ensure(1),this.buf[this.start+this.len++]=t}bytes(t){this.ensure(t.length),this.buf.set(t,this.start+this.len),this.len+=t.length}uvarint(t){this.ensure(10);let n=this.buf,r=this.start+this.len;if(t<128)n[r++]=t;else if(n[r++]=t&127|128,t<16384)n[r++]=t>>>7;else{for(n[r++]=t>>>7&127|128,t=Math.floor(t/16384);t>127;)n[r++]=t&127|128,t=Math.floor(t/128);n[r++]=t}this.len=r-this.start}uvarintBig(t){for(;t>aW;)this.byte(Number(t&aW)|128),t>>=OW;this.byte(Number(t))}zigzag(t){this.uvarintBig(t>=u0?t<<ys:(-t<<ys)-ys)}numberVarint(t){let n=t<0||t===0&&1/t<0,r=n?-t:t;r<=tae?this.uvarint(r*2+(n?1:0)):this.uvarintBig(BigInt(r)*Zie+(n?ys:u0))}f64(t){this.ensure(8),this.view.setFloat64(this.start+this.len,t,!0),this.len+=8}i64(t){this.ensure(8),this.view.setBigInt64(this.start+this.len,t,!0),this.len+=8}u32le(t){this.ensure(4),this.view.setUint32(this.start+this.len,t>>>0,!0),this.len+=4}i32le(t){this.ensure(4),this.view.setInt32(this.start+this.len,t|0,!0),this.len+=4}idAndMark(t){let n=t.length;this.ensure(n+1);let r=this.buf,o=this.start+this.len;for(let i=0;i<n;i++)r[o++]=t[i];let s=o-this.start;return this.len=s+1,s}beginSized(){return this.ensure(1),this.len++}endSized(t){let n=this.len-t-1;n<128?this.buf[this.start+t]=n:this.growSized(t,n)}endSizedRun(t){let n=(this.len-t-1)*2;n<128?this.buf[this.start+t]=n:this.growSized(t,n)}growSized(t,n){let r=LW(n),o=r-1;this.ensure(o);let s=this.start+t;this.buf.copyWithin(s+r,s+1,this.start+this.len),this.len+=o;let i=n,a=s;for(;i>127;)this.buf[a++]=i&127|128,i=Math.floor(i/128);this.buf[a]=i}string(t){let n=t.length;if(n===0)return;this.ensure(n*3);let r=this.buf,o=this.start+this.len,s=0;for(;s+4<=n;s+=4){let i=t.charCodeAt(s),a=t.charCodeAt(s+1),c=t.charCodeAt(s+2),u=t.charCodeAt(s+3);if((i|a|c|u)>127){this.len+=Xi.encodeInto(t,r.subarray(this.start+this.len)).written;return}r[o++]=i,r[o++]=a,r[o++]=c,r[o++]=u}for(;s<n;s++){let i=t.charCodeAt(s);if(i>127){this.len+=Xi.encodeInto(t,r.subarray(this.start+this.len)).written;return}r[o++]=i}this.len=o-this.start}out(){let t=this.arena,n=new Uint8Array(t.buf.buffer,this.start,this.len);return t===Eg&&(t.offset=this.start+this.len),t.writing=!1,this.arena=void 0,n}abort(){let t=this.arena;t!==void 0&&(t===Eg&&(t.offset=this.start),t.writing=!1,this.arena=void 0)}};function mae(e){let t=Nn(e);return t._tag==="String"&&t.checks===void 0}function hae(e,t,n){return e.extra.find(r=>Ui({[t]:null},r.parameter,n).length>0)}var wg=class{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(t,n){this.options=t,this.orderLayouts=n===void 0?void 0:new Array(n),this.orderKeys=n===void 0?void 0:new Array(n)}beginFrame(){this.replace=!0}find(t,n){let r=this.entries.get(t);if(r===void 0&&(r=new Map,this.entries.set(t,r)),r.has(n))return r.get(n);let o=hae(t,n,this.options),s=this.orderLayouts;if(s===void 0)return r.set(n,o),o;let i=this.orderKeys;if(this.size<s.length)s[this.size]=t,i[this.size]=n,this.size++,r.set(n,o);else if(this.replace){this.replace=!1;let a=s[this.next];(a===t?r:this.entries.get(a))?.delete(i[this.next]),s[this.next]=t,i[this.next]=n,this.next=(this.next+1)%s.length,r.set(n,o)}return o}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}},p0=new ArrayBuffer(0),gO=new Uint8Array(p0),lW=new DataView(p0),vg=class{pos=0;buf=gO;view;viewCache=lW;viewBuffer=p0;viewOffset=0;viewLength=0;end=0;options=$r;indexSignatures;positional=!1;intern;dict;reset(t,n,r,o,s,i,a){this.view=void 0,this.buf=t,this.pos=n,this.end=r,this.options=o,this.indexSignatures=s,this.positional=i,this.intern=void 0,this.dict=a}release(){this.pos=this.end=0,this.buf=gO,this.view=void 0,this.viewCache=lW,this.viewBuffer=p0,this.viewOffset=this.viewLength=0,this.options=$r,this.indexSignatures=void 0,this.positional=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let t=this.buf;return(t.buffer!==this.viewBuffer||t.byteOffset!==this.viewOffset||t.byteLength!==this.viewLength)&&(this.viewBuffer=t.buffer,this.viewOffset=t.byteOffset,this.viewLength=t.byteLength,this.viewCache=new DataView(t.buffer,t.byteOffset,t.byteLength)),this.view=this.viewCache}byte(){return this.pos>=this.end&&ee("complete value",void 0,this.options),this.buf[this.pos++]}take(t){this.pos+t>this.end&&ee("complete value",void 0,this.options);let n=this.buf.subarray(this.pos,this.pos+t);return this.pos+=t,n}takeCopy(t){this.pos+t>this.end&&ee("complete value",void 0,this.options);let n=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,n}enter(t){this.pos+t>this.end&&ee("complete value",void 0,this.options);let n=this.end;return this.end=this.pos+t,n}exit(t){this.pos=this.end,this.end=t}readUtf8(t){this.pos+t>this.end&&ee("complete value",void 0,this.options);let n=this.pos;return this.pos+=t,uae(this.buf,n,n+t,this.options)}uvarint(){let t=this.buf,n=this.end,r=this.pos;r>=n&&ee("complete value",void 0,this.options);let o=t[r++];if(o<128)return this.pos=r,o;let s=o&127;if(r>=n&&ee("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<7,o<128)return this.pos=r,s;if(r>=n&&ee("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<14,o<128)return this.pos=r,s;if(r>=n&&ee("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<21,o<128)return this.pos=r,s;let i=268435456;for(let a=4;a<10;a++){r>=n&&(this.pos=r,ee("complete value",void 0,this.options)),o=t[r++];let c=(o&127)*i;if(c>Number.MAX_SAFE_INTEGER-s&&(this.pos=r,ee("safe integer length",void 0,this.options)),s+=c,o<128)return this.pos=r,s;i*=128}this.pos=r,ee("uvarint",void 0,this.options)}fieldTag(){let t=this.buf,n=this.end,r=this.pos;r>=n&&ee("complete value",void 0,this.options);let o=t[r++];if(o<128)return this.pos=r,o;let s=o&127;return r>=n&&ee("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<7,o<128?(this.pos=r,s):(r>=n&&ee("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<14,o<128?(this.pos=r,s):(r>=n&&ee("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<21,o<128?(this.pos=r,s):(r>=n&&ee("complete value",void 0,this.options),o=t[r++],this.pos=r,o>=128&&ee("uvarint",void 0,this.options),s+o*268435456)))}uvarintBig(){let t=u0,n=u0;for(;;){let r=this.byte();if(t|=BigInt(r&127)<<n,(r&128)===0)return t;n+=OW}}numberVarint(){let t=this.buf,n=this.end,r=this.pos,o=0,s=1;for(let c=0;c<_W;c++){r>=n&&(this.pos=r,ee("complete value",void 0,this.options));let u=t[r++];if(o+=(u&127)*s,u<128)return this.pos=r,UW(o);s*=128}let i=this.uvarintBig(),a=Number(i>>ys);return Number.isFinite(a)||ee("safe integer length",void 0,this.options),(i&ys)===ys?-a:a}zigzag(){let t=this.uvarintBig();return(t&ys)===ys?-(t+ys>>ys):t>>ys}f64(){this.pos+8>this.end&&ee("complete value",void 0,this.options);let t=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,t}i64(){this.pos+8>this.end&&ee("complete value",void 0,this.options);let t=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,t}u32le(){this.pos+4>this.end&&ee("complete value",void 0,this.options);let t=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,t}i32le(){this.pos+4>this.end&&ee("complete value",void 0,this.options);let t=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,t}};function dW(e,t){return{_:"literal",leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function Og(e,t){let n=e.values;return e.valueSet!==void 0?e.valueSet.has(t):n.length===1?t===n[0]:n.includes(t)}function x0(e){return e.values.map(t=>typeof t=="string"?JSON.stringify(t):String(t)).join(" | ")}var s0=0,kO=1,qW=2,jW=3,BW=30,i0=1<<BW;function y0(e){return e._==="literal"?y0(e.leaf):e._==="int"}function S0(e){switch(e._){case"literal":return S0(e.leaf);case"bool":return 1;case"int64":return 8;default:return}}function xO(e){return S0(e)!==void 0||y0(e)||e._==="null"||e._==="undefined"}var Tg={"effect/schema/Date":{kind:wt.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:wt.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:wt.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:wt.duration,exact:!0},"effect/schema/BigDecimal":{kind:wt.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:wt.bytes,exact:!0},"effect/schema/Option":{kind:wt.option,exact:"parameters"},"effect/schema/Result":{kind:wt.result,exact:"parameters"},"effect/schema/Exit":{kind:wt.exit,exact:"parameters"},"effect/schema/Cause":{kind:wt.cause,exact:"parameters"},"effect/schema/CauseReason":{kind:wt.causeReason,exact:"parameters"}};function ip(e){let t=e.annotations?.representation;return Wt(t)&&typeof t.id=="string"?t.id:void 0}var a0=Ni(e=>{let t=gae(e),n=e.context;return t===e||n===void 0?t:hf(t,new Br(n.isOptional,n.isMutable,void 0,n.annotations))});function gae(e){switch(e._tag){case"Declaration":{let t=ip(e);if(t!==void 0&&(t in Tg||t==="effect/schema/Json"||t==="effect/schema/MutableJson"))return e.recur(a0);let n=e.annotations?.toCodecJson,r=e.annotations?.toCodec;if(!Ft(n)&&!Ft(r))return e;let o=e.typeParameters.map(i=>se(Nn(i))),s=(Ft(n)?n(o):void 0)??(Ft(r)?r(o):void 0);return s===void 0?e:ct(e,[Fa(s,a0)])}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(a0);default:return e}}function xae(e){let t=[...e].sort((r,o)=>{let s=typeof r.key=="number",i=typeof o.key=="number";return s!==i?s?-1:1:s?r.key-o.key:DW(Xi.encode(r.key),Xi.encode(o.key))}),n=[];for(let r of t){let o=Xi.encode(String(r.key));n.push(typeof r.key=="number"?0:1),l0(n,o.length),f0(n,o);let s=r.literal,i=Xi.encode(HW(s));n.push($W(s)),l0(n,i.length),f0(n,i)}return NW(n)}function $W(e){switch(typeof e){case"string":return 1;case"number":return 2;case"boolean":return 3;case"bigint":return 4;default:return 5}}function HW(e){if(typeof e=="symbol"){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return t}return String(e)}function zW(e){switch(e._tag){case"Symbol":return!0;case"Union":return e.types.some(zW);default:return!1}}function WW(e){let t=ip(e);return t==="effect/schema/Json"||t==="effect/schema/MutableJson"?!0:Ft(e.annotations?.toCodecJson)}function yae(e){let t=e.checks;if(t===void 0)return!1;let n=r=>r.annotations?.representation?.id==="effect/schema/isInt"?!0:r._tag==="FilterGroup"&&r.checks.some(n);return t.some(n)}function KW(e){for(;e._tag==="Suspend";)e=e.thunk();return e}function pW(e){let t=[],n=new Set,r=o=>{let s=KW(o);if(!n.has(s))switch(n.add(s),s._tag){case"Never":return;case"Union":s.types.forEach(r);return;case"Enum":hd(s).types.forEach(r);return;default:t.push(s)}};return e.types.forEach(r),t}function mW(e){switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"bool";default:return"bigint"}}function c0(e){switch(e._tag){case"String":case"TemplateLiteral":case"Symbol":return wt.string;case"UniqueSymbol":if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return wt.string;case"Boolean":return wt.bool;case"Null":return wt.null;case"Undefined":case"Void":return wt.undefined;case"Number":return wt.number;case"BigInt":return wt.bigint;case"Literal":switch(typeof e.literal){case"string":return wt.string;case"number":return wt.number;case"boolean":return wt.bool;default:return wt.bigint}case"Unknown":case"Any":case"ObjectKeyword":return wt.json;case"Objects":return wt.struct;case"Arrays":return wt.array;case"Declaration":{let t=ip(e);if(t!==void 0&&t in Tg)return Tg[t].kind;if(WW(e))return wt.json;throw new Error(`Binary layout: declaration ${t??"<anonymous>"} has no toCodecJson or toCodec`)}case"Suspend":return c0(KW(e));default:throw new Error("Binary layout: union members are not uniquely identifiable")}}function hW(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function Sae(e){let t=VW(e),n=!t&&bae(e);e=Nn(e);let r=new Map,o=!1,s=0,i=g=>({_:g,slot:g==="string"?s++:0});function a(g){let x=r.get(g);if(x!==void 0)return x;let S=c(g);return r.set(g,S),S}function c(g){switch(g._tag){case"String":case"TemplateLiteral":return i("string");case"Symbol":case"UniqueSymbol":return i("symbol");case"Boolean":return i("bool");case"Null":return i("null");case"Undefined":case"Void":return i("undefined");case"Number":return i(yae(g)?"int":"number");case"BigInt":return i("bigint");case"Literal":return dW(i(mW(g.literal)),[g.literal]);case"Unknown":case"Any":case"ObjectKeyword":return i("json");case"Never":return{_:"never",ast:g};case"Enum":return p(g,pW(hd(g)));case"Suspend":{o=!0;let x=a(g.thunk());return r.set(g,x),x}case"Objects":return u(g);case"Arrays":return f(g);case"Union":return p(g,pW(g));case"Declaration":return l(g)}}function u(g){let x=[],S=[],w=new Map;for(let v of g.propertySignatures){if(typeof v.name=="symbol")throw new Error("Binary layout: symbol property names are illegal");let b=String(v.name),T=v.type.context?.annotations,R=T?.[Vie],C=typeof R=="number"?R:NW(Xi.encode(b));if(!Number.isInteger(C)||C<0||C>4294967295)throw new Error(`Binary layout: illegal field id for ${b}`);let P=w.get(C);P===void 0?w.set(C,[b]):P.push(b),x.push({name:b,id:C,tagBytes:aae(C*Ss+Jf),index:0,optional:v.type.context?.isOptional===!0,annotations:T,layout:void 0,wireMask:0,inline:!1}),S.push(v.type)}for(let[v,b]of w)if(v===0||b.length>1)throw new Error(`Binary layout field id collision: ${v} (${b.join(", ")})`);let E=[];for(let v of g.indexSignatures){if(zW(v.parameter))throw new Error("Binary layout: symbol property names are illegal");E.push({parameter:v.parameter,layout:void 0,wireMask:0})}let y={_:"struct",ast:g,fields:x,byId:new Map,extra:E,extraAll:E.length===1&&mae(E[0].parameter)?E[0]:void 0,names:new Set(x.map(v=>v.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};r.set(g,y);for(let v=0;v<x.length;v++){let b=x[v];b.layout=a(S[v]),b.wireMask=EO(b.layout),b.inline=xO(b.layout),b.optional&&y.optionalCount++,y.byId.set(b.id,b)}x.sort((v,b)=>v.id-b.id);for(let v=0;v<x.length;v++)x[v].index=v;hW(y);for(let v=0;v<E.length;v++)E[v].layout=a(g.indexSignatures[v].type),E[v].wireMask=EO(E[v].layout);return y}function f(g){let x=g.rest.length>0||g.elements.some(y=>y.context?.isOptional===!0),S=g.elements.filter(y=>y.context?.isOptional!==!0).length,w=Math.max(0,g.rest.length-1),E={_:"array",ast:g,elements:[],rest:[],hasCount:x,minCount:S+w,uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};r.set(g,E);for(let y of g.elements)E.elements.push({optional:y.context?.isOptional===!0,layout:a(y)});for(let y of g.rest)E.rest.push(a(y));if(E.elements.length===0&&E.rest.length===1){let y=E.rest[0];E.uniform=y,E.uniformPacked=S0(y),E.uniformNumbers=y._==="number",E.uniformInline=xO(y)}return E}function l(g){let x=ip(g);switch(x){case"effect/schema/Date":return{_:"int64",flavor:"date"};case"effect/schema/DateTimeUtc":return{_:"int64",flavor:"utc"};case"effect/schema/DateTimeZoned":return i("dateTimeZoned");case"effect/schema/Duration":return i("duration");case"effect/schema/BigDecimal":return i("bigDecimal");case"effect/schema/Uint8Array":return i("bytes")}let S=g.typeParameters;switch(x){case"effect/schema/Option":{let w={_:"option",value:void 0};return r.set(g,w),w.value=a(S[0]),w}case"effect/schema/Result":{let w={_:"result",success:void 0,failure:void 0};return r.set(g,w),w.success=a(S[0]),w.failure=a(S[1]),w}case"effect/schema/Exit":{let w={_:"cause",error:void 0,defect:void 0},E={_:"exit",value:void 0,cause:w};return r.set(g,E),E.value=a(S[0]),w.error=a(S[1]),w.defect=a(S[2]),E}case"effect/schema/Cause":case"effect/schema/CauseReason":{let w={_:x==="effect/schema/Cause"?"cause":"causeReason",error:void 0,defect:void 0};return r.set(g,w),w.error=a(S[0]),w.defect=a(S[1]),w}}if(x!==void 0&&x in Tg)throw new Error(`Binary layout: native declaration ${x} has no layout constructor`);if(WW(g))return i("json");throw new Error(`Binary layout: declaration ${x??"<anonymous>"} has no toCodecJson or toCodec`)}function p(g,x){if(x.length===0)return{_:"never",ast:g};let S=[],w=[],E=new Map,y=new Map,v=(P,B)=>{let F=E.get(P);if(F!==void 0&&F._!==B._)throw new Error("Binary layout: union members are not uniquely identifiable");E.set(P,B)};for(let P of x){if(P._tag==="Literal"){let B=c0(P),F=y.get(B);F===void 0?y.set(B,[P.literal]):F.includes(P.literal)||F.push(P.literal);continue}if(P._tag==="UniqueSymbol"){c0(P),v(wt.string,i("symbol"));continue}if(P._tag==="Objects"||P._tag==="Arrays"){let B=Ma(P);if(B!==void 0&&B.length>0){for(let F of B)if(typeof F.key=="symbol")throw new Error("Binary layout: symbol property names are illegal");S.push({member:P,sentinels:B});continue}}w.push({member:P,kind:c0(P)})}for(let[P,B]of y)v(P,dW(i(mW(B[0])),B));if(S.length===0&&w.length===0&&E.size===1)return E.values().next().value;let b=new Set(E.keys());for(let{kind:P}of w){if(b.has(P))throw new Error("Binary layout: union members are not uniquely identifiable");b.add(P)}if(S.length===0&&E.size===0&&w.length===1){let P=a(w[0].member);return r.set(g,P),P}let T=new Map,R=[];for(let{sentinels:P}of S){let B=xae(P);if(T.has(B))throw new Error(`Binary layout sentinel collision: ${B}`);T.set(B,P),R.push(B)}let C={_:"union",ast:g,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};r.set(g,C);for(let P=0;P<S.length;P++){let{member:B,sentinels:F}=S[P],Z=R[P],z=a(B),A,H;if(B._tag==="Objects"){let q=z,J=new Set(F.map(pe=>String(pe.key))),Te=q.fields.filter(pe=>!J.has(pe.name)),Re={_:"struct",ast:q.ast,fields:Te,byId:new Map(Te.map(pe=>[pe.id,pe])),extra:q.extra,extraAll:q.extraAll,names:q.names,extraShape:void 0,optionalCount:Te.reduce((pe,dt)=>dt.optional?pe+1:pe,0),requiredMask:0,requiredWide:!1};hW(Re),A=Re,H=!1}else A=z,H=!0;let U={tag:Z,sentinels:F,tuple:H,payload:A,position:0};C.variants.push(U),C.byTag.set(Z,U)}for(let[P,B]of E)C.others.push({kind:P,layout:B,position:0}),C.byKind.set(P,B);for(let{kind:P,member:B}of w){let F=a(B);C.others.push({kind:P,layout:F,position:0}),C.byKind.set(P,F)}for(let P of[...C.variants].sort((B,F)=>B.tag-F.tag))P.position=C.byPos.length,C.byPos.push({variant:P,layout:P.payload});for(let P of[...C.others].sort((B,F)=>B.kind-F.kind))P.position=C.byPos.length,C.byPos.push({variant:void 0,layout:P.layout});return C.others.sort((P,B)=>gW(P.layout)-gW(B.layout)),C.discriminator=Gae(C.variants),C}return{layout:a(e),recursive:o,exact:t,exitSuccess:n}}function VW(e){let t=new Map,n=r=>{if(r.encoding!==void 0||r.checks!==void 0||r.encodingChecks!==void 0||r.annotations?.parseOptions!==void 0)return!1;switch(r._tag){case"String":case"Symbol":case"Boolean":case"Null":case"Undefined":case"Void":case"Number":case"BigInt":case"Literal":return!0;case"Never":return!0;case"Unknown":case"Any":return!0;case"Arrays":return r.elements.every(n)&&r.rest.every(n);case"Objects":return r.propertySignatures.every(o=>n(o.type))&&r.indexSignatures.every(o=>o.parameter._tag==="String"&&n(o.parameter)&&n(o.type));case"Union":return r.mode==="anyOf"&&r.types.every(n);case"Suspend":{let o=t.get(r);if(o!==void 0)return o;t.set(r,!0);let s=n(r.thunk());return t.set(r,s),s}case"Declaration":{let o=ip(r),s=o!==void 0?Tg[o]:void 0;return s===void 0?!1:s.exact===!0||r.typeParameters.every(n)}default:return!1}};return n(e)}function bae(e){return e._tag==="Declaration"&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&e.annotations?.parseOptions===void 0&&ip(e)==="effect/schema/Exit"&&VW(e.typeParameters[0])}var go={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25};function Eae(e){let t=new Map,n=[],r=Number.MAX_SAFE_INTEGER;function o(i){let a=n.lastIndexOf(i);if(a>=0){a<r&&(r=a);let h=[go.backEdge];return su(h,n.length-a),fW(h)}let c=t.get(i);if(c!==void 0)return c;let u=n.length,f=r;r=Number.MAX_SAFE_INTEGER,n.push(i);let l=fW(s(i));n.pop();let p=r>=u;return p&&t.set(i,l),r=p?f:Math.min(f,r),l}function s(i){let a=[];switch(i._){case"bool":case"null":case"undefined":case"number":case"int":case"string":case"symbol":case"bytes":case"bigint":case"json":case"duration":case"bigDecimal":case"dateTimeZoned":return a.push(go[i._]),a;case"literal":{a.push(go.literal),f0(a,s(i.leaf)),su(a,i.values.length);let c=i.values.map(u=>[$W(u),HW(u)]).sort((u,f)=>u[1]<f[1]?-1:u[1]>f[1]?1:u[0]-f[0]);for(let[u,f]of c){a.push(u);let l=Xi.encode(f);su(a,l.length),f0(a,l)}return a}case"int64":return a.push(i.flavor==="date"?go.date:go.dateTimeUtc),a;case"never":return a.push(go.never),a;case"struct":{a.push(go.struct),su(a,i.fields.length);for(let c of i.fields)l0(a,c.id),a.push(c.optional?1:0),Lo(a,o(c.layout));su(a,i.extra.length);for(let c of i.extra)Lo(a,o(c.layout));return a}case"array":{a.push(go.array),su(a,i.elements.length);for(let c of i.elements)a.push(c.optional?1:0),Lo(a,o(c.layout));su(a,i.rest.length);for(let c of i.rest)Lo(a,o(c));return a}case"union":{a.push(go.union),su(a,i.byPos.length);for(let c of i.byPos){let u=c.variant;u===void 0?a.push(0):(a.push(1,u.tuple?1:0),l0(a,u.tag)),Lo(a,o(c.layout))}return a}case"option":return a.push(go.option),Lo(a,o(i.value)),a;case"result":return a.push(go.result),Lo(a,o(i.success)),Lo(a,o(i.failure)),a;case"exit":return a.push(go.exit),Lo(a,o(i.value)),Lo(a,o(i.cause.error)),Lo(a,o(i.cause.defect)),a;case"cause":case"causeReason":return a.push(i._==="cause"?go.cause:go.causeReason),Lo(a,o(i.error)),Lo(a,o(i.defect)),a}}return o(e)}function wae(e,t){let n=new Uint8Array(8);for(let r=0;r<4;r++)n[r]=e>>>r*8&255,n[r+4]=t>>>r*8&255;return n}var vae={positional:!1,envelope:Jie,expectedEnvelope:"version 2 envelope, flags 0",fingerprint:new Uint8Array(8)};function Tae(e){let t=Eae(e);return{positional:!0,envelope:Gie,expectedEnvelope:"version 2 envelope, flags 1",fingerprint:wae(Number(t&cW),Number(t>>Xie&cW))}}function gW(e){switch(e._){case"json":return 2;case"struct":return 1;default:return 0}}function yO(e,t){switch(e._){case"literal":return Og(e,t);case"bool":return typeof t=="boolean";case"null":return t===null;case"undefined":return t===void 0;case"number":case"int":return typeof t=="number";case"string":return typeof t=="string";case"symbol":return typeof t=="symbol";case"bigint":return typeof t=="bigint";case"bytes":return t instanceof Uint8Array;case"int64":return e.flavor==="date"?t instanceof Date:uf(t)&&t._tag==="Utc";case"dateTimeZoned":return uf(t)&&t._tag==="Zoned";case"duration":return Cu(t);case"bigDecimal":return hc(t);case"option":return hi(t);case"result":return lc(t);case"exit":return Us(t);case"cause":return Lu(t);case"causeReason":return qu(t);case"array":return Array.isArray(t);case"struct":return Wt(t)&&!Array.isArray(t);case"json":return!0;case"union":case"never":return!1}}function Et(e,t,n){throw Sn(new Oe({expected:e},t,n))}function Rr(e,t=new Set){if(!sl(e))return!1;let n=Array.isArray(e),r=Object.getPrototypeOf(e);if(n||r===Object.prototype||r===null){if(t.has(e))return!0;t.add(e);try{if(n){for(let o=0;o<e.length;o++)if(Rr(e[o],t))return!0}else for(let o of Object.keys(e))if(Rr(e[o],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||uf(e)||Cu(e)||hc(e))return!1;if(t.has(e))return!0;t.add(e);try{if(hi(e))return _e(e)&&Rr(e.value,t);if(lc(e))return Rr(_t(e)?e.success:e.failure,t);if(Us(e))return Rr(Nt(e)?e.value:e.cause,t);if(Lu(e))return e.reasons.some(o=>Rr(o,t));if(qu(e))switch(e._tag){case"Fail":return Rr(e.error,t);case"Die":return Rr(e.defect,t);case"Interrupt":return!1}if(gd(e)){for(let o of e)if(Rr(o,t))return!0;return!1}if(Sb(e)){for(let[o,s]of e)if(Rr(o,t)||Rr(s,t))return!0;return!1}if(Tb(e)){for(let o of e)if(Rr(o,t))return!0;return!1}if(Oh(e))return Rr($c(e),t);for(let o of Object.keys(e))if(Rr(e[o],t))return!0}finally{t.delete(e)}return!1}function m0(e,t,n,r){let o=r.beginSized();tr(e,t,n,r),r.endSized(o)}function Iae(e,t,n){let r=globalThis.Symbol.keyFor(t);r===void 0&&Et("registered symbol",t,e.options),n.string(r)}function xW(e,t,n,r){let o=n;switch(o._tag){case"Fail":r.byte(0),tr(e,t.error,o.error,r);return;case"Die":r.byte(1),tr(e,t.defect,o.defect,r);return;case"Interrupt":o.fiberId===void 0?r.byte(2):(r.byte(3),r.f64(o.fiberId))}}function kae(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function yW(e,t,n){if(e.layout!==t||e.keys.length!==n.length)return!1;for(let r=0;r<n.length;r++)if(e.keys[r]!==n[r])return!1;return!0}function Aae(e,t){if(e.extraAll===void 0||t.length>dae)return!1;let n=0;for(let r=0;r<t.length;r++)if(n+=t[r].length,n>pae)return!1;return!0}function AO(e,t,n){let r=Object.keys(n),o=t.extraShape;if(o!==void 0&&yW(o,t,r))return o.pairs;let s=Aae(t,r),i=s?void 0:e.extraShape;if(i!==void 0&&yW(i,t,r))return i.pairs;let a=t.names,c=t.extraAll,u=[],f=!0;for(let p of r){if(a.has(p))continue;let h=c??(e.indexSignatures??=new wg(e.options)).find(t,p);h!==void 0&&(f&&!kae(p)&&(f=!1),u.push([p,h,void 0]))}if(f)u.sort((p,h)=>p[0]<h[0]?-1:p[0]>h[0]?1:0);else{for(let p of u)p[2]=Xi.encode(p[0]);u.sort((p,h)=>DW(p[2],h[2]))}if(s)for(let p of u)p[2]??=Xi.encode(p[0]);let l={layout:t,keys:r,pairs:u};return s?t.extraShape=l:e.extraShape=l,u}function RO(e,t,n,r,o){for(let[s,i,a]of t){let c=a===void 0?s.length:a.length,u=n[s],f=CO(i.layout,u,e.options),l=f%Ss;if(o===void 0)r.uvarint(c*Ss+l);else{if(!o.disabled){let p=GW(o,s);if(p!==void 0){r.uvarint(p*16+l*2+1),ot[fe++]=s,SO(e,i.layout,u,f,r),fe--;continue}ZW(o,s)}r.uvarint(c*16+l*2)}a===void 0?r.string(s):r.bytes(a),ot[fe++]=s,SO(e,i.layout,u,f,r),fe--}}function CO(e,t,n){if(e._==="literal")return Og(e,t)||Et(x0(e),t,n),CO(e.leaf,t,n);switch(e._){case"bool":return typeof t!="boolean"&&Et("a boolean",t,n),t?Rg:Ag;case"number":if(typeof t!="number"&&Et("a number",t,n),TO(t))return Kf;{let r=IO(t);return r===0?kg:r*Ss+Cg}case"int":return Number.isSafeInteger(t)||Et("an integer",t,n),Kf;default:return Jf}}function SO(e,t,n,r,o){switch(r%Ss){case Ag:case Rg:return;case Kf:o.numberVarint(n);return;case kg:o.f64(n);return;case Cg:{let i=Math.floor(r/Ss);o.numberVarint(Math.round(n*iu[i])),o.uvarint(i);return}default:m0(e,t,n,o)}}function Rae(e,t,n,r){let o=CO(t.layout,n,e.options),s=o%Ss;if(s===Jf){let i=r.idAndMark(t.tagBytes);tr(e,t.layout,n,r),r.endSized(i);return}r.uvarint(t.id*Ss+s),SO(e,t.layout,n,o,r)}function Cae(e,t){let n=e.byName;if(n===void 0)return;let r=Object.getOwnPropertyNames(t),o=0;for(let i=0;i<r.length;i++){let a=n.get(r[i]);a!==void 0&&(o|=1<<a)}let s=e.struct;if((o&s.requiredMask)!==s.requiredMask){let i=s.fields;for(let a=0;a<i.length;a++){let c=i[a];if(!c.optional&&(o&1<<a)===0)throw ot[fe++]=c.name,Sn(new tn(c.annotations))}}return o}function Oae(e,t,n,r){let o=n;if(t.extra.length>0){let i=e.intern;e.intern=void 0;let a=AO(e,t,o);if(a.length>0){r.uvarint(0);let c=r.beginSized();RO(e,a,o,r,i),r.endSized(c)}}let s=t.fields;for(let i=0;i<s.length;i++){let a=s[i],c=a.name;if(!Object.hasOwn(o,c)){if(a.optional)continue;throw ot[fe++]=c,Sn(new tn(a.annotations))}ot[fe++]=c,Rae(e,a,o[c],r),fe--}}function _ae(e,t,n,r){let o=n,s=e.intern;e.intern=void 0;let i=t.optionalCount+7>>3,a=0;if(i>0){a=r.len;for(let f=0;f<i;f++)r.byte(0)}let c=t.fields,u=0;for(let f=0;f<c.length;f++){let l=c[f],p=l.name,h=Object.hasOwn(o,p);if(l.optional){if(h&&(r.buf[r.start+a+(u>>3)]|=1<<(u&7)),u++,!h)continue}else if(!h)throw ot[fe++]=p,Sn(new tn(l.annotations));ot[fe++]=p,l.inline?tr(e,l.layout,o[p],r):m0(e,l.layout,o[p],r),fe--}if(t.extra.length>0){let f=AO(e,t,o);r.uvarint(f.length),RO(e,f,o,r,s)}}function Mae(e){switch(e._){case"string":return kO;case"array":return e.uniform?._==="string"?qW:s0;case"struct":return e.extra.length>0?jW:s0;default:return s0}}function Pae(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let n of e.elements)if(n.optional||n.layout!==t)return}return t._==="struct"?t:void 0}function JW(e){let t=e.run;if(t!==void 0)return t;let n=Pae(e);if(n===void 0)return e.run=t=null,t;let r=n.fields.map(s=>Mae(s.layout)),o=n.fields.length<=BW;return t={struct:n,intern:r,shapes:o,byName:o&&n.extra.length===0?new Map(n.fields.map((s,i)=>[s.name,i])):void 0},e.run=t,t}var Fae=16,Uae=64;function SW(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function GW(e,t){let n=e.refs;if(n!==void 0){let o=n.get(t);return o!==void 0&&e.hits++,o}let r=e.values;for(let o=0;o<r.length;o++)if(r[o]===t)return e.hits++,o}function ZW(e,t){let n=e.values;if(e.refs!==void 0){if(e.hits===0&&n.length>=Uae){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,n.length)}else if(n.length>=Fae){let r=e.refs=new Map;for(let o=0;o<n.length;o++)r.set(n[o],o);r.set(t,n.length)}n.push(t)}var OO=0,Nae=1,_O=2,Dae=64,Lae=512;function qae(){return{slots:[],marks:[],frame:0}}function QW(e,t){return e[t]??={values:[],refs:new Map,state:OO,stamp:-1}}function YW(e,t){if(e.refs.has(t)){e.state=Nae;return}e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=Dae&&(e.state=_O)}function XW(e,t){let n=e.values;n.length>=Lae||(e.refs.set(t,n.length),n.push(t))}function jae(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function Bae(e){e.marks.length=0,e.frame++}function $ae(e){let t=e.marks;for(let n=t.length-1;n>=0;n--){let{length:r,slot:o,state:s}=t[n],i=o.values;for(let a=r;a<i.length;a++)o.refs.delete(i[a]);i.length=r,o.state=s}t.length=0,e.frame++}function Hae(e,t,n,r){let o=QW(e.slots,t.slot),s=o.state;if(s===_O){r.string(n);return}if(jae(e,o),s===OO){r.string(n),YW(o,n);return}let i=o.refs.get(n);if(i!==void 0){r.uvarint(i*2+1);return}r.byte(0),XW(o,n),r.string(n)}function zae(e,t,n){let r=QW(e,t.slot),o=r.state;if(o===_O)return n.readUtf8(n.end-n.pos);if(o===OO){let a=n.readUtf8(n.end-n.pos);return YW(r,a),a}let s=n.uvarint();if((s&1)===1){let a=(s-1)/2,c=r.values;return a>=c.length&&ee("a dictionary reference",s,n.options),c[a]}s!==0&&ee("a dictionary marker",s,n.options);let i=n.readUtf8(n.end-n.pos);return XW(r,i),i}function e3(e,t,n,r,o){if(!e.disabled){let i=GW(e,r);if(i!==void 0){o.uvarint(i*2+1);return}ZW(e,r)}let s=o.beginSized();tr(t,n,r,o),o.endSizedRun(s)}function Wae(e,t,n,r,o){let s=[],i=[];for(let a=0;a<r;a++){ot[fe++]=a;let c=o.beginSized();Kae(e,t,s,i,n[a],o),o.endSized(c),fe--}}function Kae(e,t,n,r,o,s){let i=t.struct,a=o,c=i.fields,u;if(i.extra.length>0){let S=AO(e,i,a);S.length>0&&(u=S)}let f=!t.shapes,l=u===void 0?0:i0,p=Cae(t,a);if(p!==void 0)l=p;else for(let S=0;S<c.length;S++){let w=c[S];if(Object.hasOwn(a,w.name))f||(l|=1<<S);else if(!w.optional)throw ot[fe++]=w.name,Sn(new tn(w.annotations))}let h=-1;for(let S=0;S<n.length;S++)if(n[S]===l){h=S;break}h>=0?s.uvarint(h+1):(s.uvarint(0),f||n.push(l));let g=h<0,x=e.positional&&!f;if(g&&x&&s.uvarint(l),u!==void 0){g&&!x&&s.uvarint(0);let S=s.beginSized();RO(e,u,a,s),s.endSizedRun(S)}for(let S=0;S<c.length;S++){let w=c[S];if(f?!Object.hasOwn(a,w.name):(l&1<<S)===0)continue;g&&!x&&s.uvarint(w.id),ot[fe++]=w.name;let E=t.intern[S];if(E===kO)e3(SW(r,S),e,w.layout,a[w.name],s);else{E!==s0&&(e.intern=SW(r,S));let y=s.beginSized();tr(e,w.layout,a[w.name],s),s.endSizedRun(y),e.intern=void 0}fe--}}function t3(e,t,n){let r=e.elements.length;if(t<r)return e.elements[t].layout;let o=Math.max(0,e.rest.length-1),s=Math.max(r,n-o);return t>=s?e.rest[t-s+1]:e.rest[0]}function Vae(e,t,n,r){let o=n.length;if(t.rest.length===0&&o>t.elements.length)throw ot[fe++]=t.elements.length,Sn(new _i(t.ast,n[t.elements.length],e.options));if(o<t.minCount)throw ot[fe++]=o,Sn(new tn(void 0));if(t.hasCount&&r.uvarint(o),o>0){let i=JW(t);if(i!==null){Wae(e,i,n,o,r);return}}let s=t.uniform;if(s!==void 0){if(t.uniformNumbers){Jae(n,o,r);return}let i=e.intern;if(e.intern=void 0,i!==void 0){for(let c=0;c<o;c++)ot[fe++]=c,e3(i,e,s,n[c],r),fe--;return}let a=t.uniformInline;for(let c=0;c<o;c++)ot[fe++]=c,a?tr(e,s,n[c],r):m0(e,s,n[c],r),fe--;return}for(let i=0;i<o;i++){let a=t3(t,i,o);ot[fe++]=i,xO(a)?tr(e,a,n[i],r):m0(e,a,n[i],r),fe--}}var bW=[];function Jae(e,t,n){let r=!0,o=!0;for(let s=0;s<t;s++){let i=e[s];if(TO(i))(i<0?-i:i)>pO&&(o=!1);else if(r=!1,typeof i!="number")o=!1;else{let a=IO(i);a===0?o=!1:bW[s]=a}if(!r&&!o)break}if(r){n.byte(PW);for(let s=0;s<t;s++)n.numberVarint(e[s])}else if(o){n.byte(FW);for(let s=0;s<t;s++){let i=e[s],a=Number.isInteger(i)?0:bW[s],c=a===0?i:Math.round(i*iu[a]),u=c<0||c===0&&1/c<0,f=u?-c:c;n.uvarint((f*2+(u?1:0))*16+a)}}else{n.byte(MW);for(let s=0;s<t;s++)n.f64(e[s])}}function Gae(e){if(!(e.length<2||e.some(t=>t.tuple)))for(let t of e[0].sentinels){let n=new Map;for(let r of e){let o=r.sentinels.find(s=>s.key===t.key);if(o===void 0||n.has(o.literal)||Number.isNaN(o.literal))break;n.set(o.literal,r)}if(n.size===e.length)return{key:t.key,rows:n}}}function bO(e,t){let n=e.sentinels;for(let r=0;r<n.length;r++){let{key:o,literal:s}=n[r];if(t[o]!==s||!Object.hasOwn(t,o))return!1}return!0}function Zae(e,t){return e.tuple?Array.isArray(t)&&bO(e,t):Wt(t)&&!Array.isArray(t)&&bO(e,t)}function EW(e,t,n,r){e.positional?r.uvarint(t.position):(r.byte(wt.variant),r.u32le(t.tag)),tr(e,t.payload,n,r)}function Qae(e,t,n,r){let o=t.discriminator;if(o!==void 0){if(Wt(n)&&!Array.isArray(n)){let s=n,i=o.rows.get(s[o.key]);if(i!==void 0&&bO(i,s)){EW(e,i,n,r);return}}}else for(let s of t.variants)if(Zae(s,n)){EW(e,s,n,r);return}for(let s of t.others)if(yO(s.layout,n)){e.positional?r.uvarint(s.position):r.byte(s.kind),tr(e,s.layout,n,r);return}throw Sn(new tt(t.ast,n,e.options))}function tr(e,t,n,r){switch(t._){case"literal":Og(t,n)||Et(x0(t),n,e.options),tr(e,t.leaf,n,r);return;case"bool":typeof n!="boolean"&&Et("a boolean",n,e.options),r.byte(n===!0?1:0);return;case"null":n!==null&&Et("null",n,e.options);return;case"undefined":n!==void 0&&Et("undefined",n,e.options);return;case"number":{if(typeof n!="number"&&Et("a number",n,e.options),TO(n)){r.numberVarint(n);return}let o=IO(n);o>0?(r.numberVarint(Math.round(n*iu[o])),r.byte(o)):r.f64(n);return}case"int":{Number.isSafeInteger(n)||Et("an integer",n,e.options),r.numberVarint(n);return}case"string":{typeof n!="string"&&Et("a string",n,e.options);let o=e.dict;o===void 0?r.string(n):Hae(o,t,n,r);return}case"symbol":typeof n!="symbol"&&Et("a symbol",n,e.options),Iae(e,n,r);return;case"bytes":n instanceof Uint8Array||Et("a Uint8Array",n,e.options),r.bytes(n);return;case"bigint":typeof n!="bigint"&&Et("a bigint",n,e.options),r.zigzag(n);return;case"int64":{yO(t,n)||Et(t.flavor==="date"?"a Date":"a DateTime.Utc",n,e.options);let o=t.flavor==="date"?n.getTime():n.epochMilliseconds;Number.isNaN(o)&&Et("a valid Date",n,e.options),r.i64(BigInt(o));return}case"dateTimeZoned":{yO(t,n)||Et("a DateTime.Zoned",n,e.options);let o=n;r.i64(BigInt(o.epochMilliseconds)),o.zone._tag==="Offset"?(r.byte(0),r.i32le(o.zone.offset)):(r.byte(1),r.string(o.zone.id));return}case"duration":{Cu(n)||Et("a Duration",n,e.options);let o=n.value;switch(o._tag){case"Infinity":r.byte(1);return;case"NegativeInfinity":r.byte(2);return;case"Nanos":r.byte(0),r.zigzag(o.nanos);return;case"Millis":r.byte(0),r.zigzag(BigInt(o.millis)*Qie);return}}case"bigDecimal":{hc(n)||Et("a BigDecimal",n,e.options);let o=Up(n);r.zigzag(o.value),r.zigzag(BigInt(o.scale));return}case"json":{let o;try{o=JSON.stringify(n)}catch{o=void 0}o===void 0&&(Rr(n)&&Et("acyclic value",n,e.options),Et("a JSON-serializable value",n,e.options)),r.string(o);return}case"option":{hi(n)||Et("an Option",n,e.options);let o=n;o._tag==="None"?r.byte(0):(r.byte(1),tr(e,t.value,o.value,r));return}case"result":{lc(n)||Et("a Result",n,e.options);let o=n;o._tag==="Success"?(r.byte(0),tr(e,t.success,o.success,r)):(r.byte(1),tr(e,t.failure,o.failure,r));return}case"exit":{Us(n)||Et("an Exit",n,e.options);let o=n;o._tag==="Success"?(r.byte(0),tr(e,t.value,o.value,r)):(r.byte(1),tr(e,t.cause,o.cause,r));return}case"cause":{Lu(n)||Et("a Cause",n,e.options);let o=n.reasons;r.uvarint(o.length);for(let s of o){let i=r.beginSized();xW(e,t,s,r),r.endSized(i)}return}case"causeReason":{qu(n)||Et("a Cause.Reason",n,e.options),xW(e,t,n,r);return}case"struct":{(!Wt(n)||Array.isArray(n))&&Et("an object",n,e.options),e.positional?_ae(e,t,n,r):Oae(e,t,n,r);return}case"array":{Array.isArray(n)||Et("an array",n,e.options),Vae(e,t,n,r);return}case"union":Qae(e,t,n,r);return;case"never":throw Sn(new tt(t.ast,n,e.options))}}var r0=new d0;function wW(e,t,n,r,o){let s=o.beginSized();o.byte(r.envelope),r.positional&&o.bytes(r.fingerprint),tr(e,t,n,o),o.endSized(s)}function n3(e,t,n,r,o,s){let i={options:r,positional:o.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:s},a=r0??new d0,c=a===r0;c&&(r0=void 0),a.reset();let u=fe,f=!1;try{if(n===void 0)fe=0,wW(i,e,t,o,a);else for(let p=0;p<n.length;p++)fe=0,wW(i,e,n[p],o,a);let l=a.out();return f=!0,l}finally{s!==void 0&&(f?Bae(s):$ae(s)),a.abort(),fe=u,c&&(r0=a)}}function r3(e,t,n,r,o){return n3(e,void 0,t,n,r,o)}function h0(e,t,n,r,o){return n3(e,t,void 0,n,r,o)}function b0(e){return Us(e)&&Nt(e)}var Ln=globalThis.Symbol.for("~effect/encoding/SchemaBinary/absent");function Cr(e,t){let n=Ig(e,t);return n!==Ln&&t.pos!==t.end&&ee("no leftover bytes",void 0,t.options),n}function Yae(e,t){let n=t.enter(t.uvarint()),r=Cr(e,t);return t.exit(n),r}function o3(e,t){if(y0(e))return Ig(e,t);let n=S0(e),r=t.enter(n!==void 0?n:e._==="null"||e._==="undefined"?0:t.uvarint()),o=Cr(e,t);return t.exit(r),o}var Xae=8;function ece(e,t){let n=e.set;if(n!==void 0)return n.has(t)?!0:(n.add(t),!1);let r=e.list;if(r.includes(t))return!0;if(r.length>=Xae){let o=e.set=new Set;for(let s=0;s<r.length;s++)o.add(r[s]);o.add(t)}else r.push(t);return!1}function s3(e,t,n,r,o){let s=t.uvarint(),i=Math.floor(o===void 0?s/Ss:s/16),a=o===void 0?s-i*Ss:Math.floor((s-i*16)/2),c=o===void 0?t.readUtf8(i):tce(o,s,i,t);ece(r,c)&&ee("unique extra keys",void 0,t.options);let u=e.extraAll??(t.indexSignatures??=new wg(t.options)).find(e,c);if(u===void 0){MO(a,t);return}ot[fe++]=c;let f=c3(u.layout,u.wireMask,a,t);fe--,f!==Ln&&K(n,c,f)}function tce(e,t,n,r){if((t&1)===1)return n>=e.length&&ee("a known back-reference",void 0,r.options),e[n];let o=r.readUtf8(n);return e.push(o),o}function i3(e){return new kt([e.name],new tn(e.annotations))}function a3(e,t){throw Sn(new At(e.ast,t))}function fO(e){for(;(e.byte()&128)!==0;);}function MO(e,t){switch(e){case Jf:t.take(t.uvarint());return;case Kf:fO(t);return;case kg:t.take(8);return;case Ag:case Rg:case rae:return;case Cg:fO(t),fO(t);return;case nae:t.take(4);return}}function EO(e){if(e._==="literal")return EO(e.leaf);switch(e._){case"bool":return 1<<Ag|1<<Rg;case"number":return 1<<Kf|1<<kg|1<<Cg;case"int":return 1<<Kf;default:return 1<<Jf}}function nce(e,t){switch(e){case Ag:return!1;case Rg:return!0;case Kf:return t.numberVarint();case kg:return t.f64();case Cg:{let n=t.numberVarint(),r=t.uvarint();return(r===0||r>g0)&&ee("a decimal scale in [1, 8]",r,t.options),n/iu[r]}}return ee("matching field wire kind",void 0,t.options)}function c3(e,t,n,r){if((t&1<<n)===0)return MO(n,r),Ln;if(n!==Jf){let i=nce(n,r);return e._==="literal"&&!Og(e,i)&&ee(x0(e),i,r.options),i}let o=r.enter(r.uvarint()),s=Cr(e,r);return r.exit(o),s}function rce(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},o=0,s=0,i,a,c,u=!1,f=e.fields,l=0;for(;t.pos<t.end;){let p=t.fieldTag(),h=Math.floor(p/Ss),g=p-h*Ss;if(h===0){u&&ee("unique field ids",void 0,t.options),u=!0,g!==Jf&&ee("extra field map",void 0,t.options);let E=t.enter(t.uvarint());f3(e,t,r,n),t.exit(E);continue}let x;if(l<f.length&&f[l].id===h?(x=f[l],l++):(x=e.byId.get(h),x!==void 0&&(l=x.index+1)),x===void 0){c===void 0?c=new Set:c.has(h)&&ee("unique field ids",void 0,t.options),c.add(h),MO(g,t);continue}let S=x.index;if(S<32){let E=1<<S;(o&E)!==0&&ee("unique field ids",void 0,t.options),o|=E}else i===void 0?i=new Set([S]):(i.has(S)&&ee("unique field ids",void 0,t.options),i.add(S));ot[fe++]=x.name;let w=c3(x.layout,x.wireMask,g,t);fe--,w!==Ln&&(K(r,x.name,w),S<32?s|=1<<S:(a??=new Set).add(S))}return u3(e,s,a,t),r}function u3(e,t,n,r){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let o=e.fields,s;for(let i=0;i<o.length;i++){let a=o[i],c=a.index,u=c<32?(t&1<<c)!==0:n?.has(c)===!0;if(!a.optional&&!u&&((s??=[]).push(i3(a)),r.options.errors!=="all"))break}s!==void 0&&a3(e,s)}function oce(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},o=e.optionalCount+7>>3,s=0;o>0&&(t.pos+o>t.end&&ee("complete value",void 0,t.options),s=t.pos,t.pos+=o);let i=t.buf,a=e.fields,c=0,u;for(let f=0;f<a.length;f++){let l=a[f];if(l.optional){let h=(i[s+(c>>3)]&1<<(c&7))!==0;if(c++,!h)continue}ot[fe++]=l.name;let p=l.inline?o3(l.layout,t):Yae(l.layout,t);if(fe--,p!==Ln)K(r,l.name,p);else if(!l.optional&&((u??=[]).push(i3(l)),t.options.errors!=="all"))break}if(u!==void 0&&a3(e,u),e.extra.length>0){let f=t.uvarint();if(f>t.remaining&&ee("complete value",void 0,t.options),f>0){let l={list:[],set:void 0};for(let p=0;p<f;p++)s3(e,t,r,l,n)}}return r}function f3(e,t,n,r){let o={list:[],set:void 0};for(;t.pos<t.end;)s3(e,t,n,o,r)}function sce(e,t,n){let r=n.uvarint();if((r&1)===1){let i=(r-1)/2;return i>=e.length&&ee("a known back-reference",void 0,n.options),e[i]}if(t._==="string"){let i=n.readUtf8(r/2);return e.push(i),i}let o=n.enter(r/2),s=Cr(t,n);return n.exit(o),e.push(s),s}function ice(e,t,n){let r=new Array(t),o=[],s=[];for(let i=0;i<t;i++){ot[fe++]=i;let a=n.enter(n.uvarint());r[i]=cce(e,o,s,n),n.exit(a),fe--}return r}function ace(e,t){let n=t.uvarint(),r=e.fields,o=n&~i0;(n>i0*2-1||o>>>r.length)&&ee("a known row shape",void 0,t.options);let s=[];(n&i0)!==0&&s.push(null);for(let i=0;i<r.length;i++)(o&1<<i)!==0&&s.push(r[i]);return s}function cce(e,t,n,r){let o=e.struct,s={},i=0,a,c=r.uvarint(),u;if(c===0?r.positional&&e.shapes&&(u=ace(o,r),t.push(u)):(u=t[c-1],u===void 0&&ee("a known row shape",void 0,r.options)),u!==void 0){for(let f=0;f<u.length;f++){let l=vW(e,n,u[f],s,r);l>=0&&(l<32?i|=1<<l:(a??=new Set).add(l))}r.pos!==r.end&&ee("no leftover bytes",void 0,r.options)}else{let f=e.shapes?[]:void 0,l=0,p,h,g=!1;for(;r.pos<r.end;){let x=r.uvarint(),S;x===0?(g&&ee("unique field ids",void 0,r.options),g=!0,S=null):(S=o.byId.get(x),S===void 0?h===void 0?h=new Set([x]):h.has(x)?ee("unique field ids",void 0,r.options):h.add(x):S.index<32?((l&1<<S.index)!==0&&ee("unique field ids",void 0,r.options),l|=1<<S.index):p===void 0?p=new Set([S.index]):(p.has(S.index)&&ee("unique field ids",void 0,r.options),p.add(S.index))),f?.push(S);let w=vW(e,n,S,s,r);w>=0&&(w<32?i|=1<<w:(a??=new Set).add(w))}f!==void 0&&t.push(f)}return u3(o,i,a,r),s}function vW(e,t,n,r,o){let s=o.uvarint();if((s&1)===1){if(n==null)return-1;let u=t[n.index],f=(s-1)/2;(u===void 0||f>=u.length)&&ee("a known back-reference",void 0,o.options);let l=u[f];return l===Ln?-1:(K(r,n.name,l),n.index)}let i=o.enter(s/2);if(n===null)return f3(e.struct,o,r),o.exit(i),-1;if(n===void 0)return o.exit(i),-1;let a=e.intern[n.index];(a===qW||a===jW)&&(o.intern=t[n.index]??=[]),ot[fe++]=n.name;let c=Cr(n.layout,o);return fe--,o.intern=void 0,o.exit(i),a===kO&&(t[n.index]??=[]).push(c),c===Ln?-1:(K(r,n.name,c),n.index)}function uce(e,t){let n=e.elements.length,r=e.hasCount?t.uvarint():n;if(e.hasCount&&r>t.remaining+1048576&&ee("array count within allocation limit",r,t.options),e.rest.length===0&&r>n)throw ot[fe++]=n,Sn(new _i(e.ast,void 0,t.options));if(r<e.minCount)throw ot[fe++]=r,Sn(new tn(void 0));if(r>0){let i=JW(e);if(i!==null)return ice(i,r,t)}let o=new Array(r),s=e.uniform;if(s!==void 0){if(e.uniformNumbers)return fce(o,r,t);let i=t.intern;if(t.intern=void 0,i!==void 0){for(let u=0;u<r;u++){ot[fe++]=u;let f=sce(i,s,t);if(f===Ln)throw Sn(new tn(void 0));fe--,o[u]=f}return o}if(y0(s)){for(let u=0;u<r;u++)ot[fe++]=u,o[u]=Ig(s,t),fe--;return o}if(s._==="string"){for(let u=0;u<r;u++)ot[fe++]=u,o[u]=t.readUtf8(t.uvarint()),fe--;return o}let a=e.uniformPacked,c=e.uniformInline;for(let u=0;u<r;u++){ot[fe++]=u;let f=t.enter(c?a??0:t.uvarint()),l=Cr(s,t);if(t.exit(f),l===Ln)throw Sn(new tn(void 0));fe--,o[u]=l}return o}for(let i=0;i<r;i++){let a=t3(e,i,r),c=i<n&&e.elements[i].optional;if(!e.hasCount&&t.remaining===0&&!c&&a._!=="null"&&a._!=="undefined")throw ot[fe++]=i,Sn(new tn(void 0));ot[fe++]=i;let u=o3(a,t);if(u===Ln)throw c&&ee("known union member",void 0,t.options),Sn(new tn(void 0));fe--,o[i]=u}if(!e.hasCount&&t.pos<t.end)throw ot[fe++]=n,Sn(new _i(e.ast,void 0,t.options));return o}function fce(e,t,n){let r=n.byte();if(r===MW){n.remaining!==t*8&&ee("f64",void 0,n.options);for(let o=0;o<t;o++)e[o]=n.f64();return e}if(r===FW){for(let o=0;o<t;o++){ot[fe++]=o;let s=n.uvarint(),i=s%16;i>g0&&ee("decimal",void 0,n.options);let a=UW((s-i)/16);e[o]=i===0?a:a/iu[i],fe--}return e}r!==PW&&ee("f64",void 0,n.options);for(let o=0;o<t;o++)ot[fe++]=o,e[o]=n.numberVarint(),fe--;return e}function lce(e,t){let n=t.byte();if(n===wt.variant){let o=t.u32le(),s=e.byTag.get(o);if(s===void 0)return t.take(t.remaining),Ln;let i=Cr(s.payload,t);if(i===Ln)return Ln;if(!s.tuple)for(let a of s.sentinels)K(i,a.key,a.literal);return i}let r=e.byKind.get(n);return r===void 0?(t.take(t.remaining),Ln):Cr(r,t)}function dce(e,t){let n=e.byPos[t.uvarint()];n===void 0&&ee("known union member",void 0,t.options);let r=Cr(n.layout,t),o=n.variant;if(o!==void 0&&!o.tuple&&r!==Ln)for(let s of o.sentinels)K(r,s.key,s.literal);return r}function TW(e,t){switch(t.byte()){case 0:return ju(sp(Cr(e.error,t)));case 1:return Bu(sp(Cr(e.defect,t)));case 2:return t.remaining!==0&&ee("empty",void 0,t.options),wc();case 3:return t.remaining!==8&&ee("f64",void 0,t.options),wc(t.f64());default:return t.take(t.remaining),Ln}}function sp(e){if(e===Ln)throw Sn(new tn(void 0));return e}function Ig(e,t){switch(e._){case"literal":{let n=Ig(e.leaf,t);return Og(e,n)||ee(x0(e),n,t.options),n}case"bool":{t.remaining!==1&&ee("bool",void 0,t.options);let n=t.byte();return n>1&&ee("bool",void 0,t.options),n===1}case"null":return t.remaining!==0&&ee("empty",void 0,t.options),null;case"undefined":t.remaining!==0&&ee("empty",void 0,t.options);return;case"number":{let n=t.remaining;if(n===8)return t.f64();(n===0||n>_W)&&ee("f64",void 0,t.options);let r=t.numberVarint();if(t.remaining===0)return r;let o=t.byte();return(t.remaining!==0||o===0||o>g0)&&ee("decimal",void 0,t.options),r/iu[o]}case"int":return t.numberVarint();case"string":{let n=t.dict;return n===void 0?t.readUtf8(t.end-t.pos):zae(n,e,t)}case"symbol":return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case"bytes":return t.takeCopy(t.end-t.pos);case"bigint":return t.zigzag();case"int64":{t.remaining!==8&&ee("int64",void 0,t.options);let n=Number(t.i64());if(e.flavor!=="date")return PN(n);let r=new Date(n);return Number.isNaN(r.getTime())&&ee("a valid Date",n,t.options),r}case"dateTimeZoned":{let n=Number(t.i64()),r=t.byte(),o;if(r===0)t.remaining!==4&&ee("time zone",void 0,t.options),o=t.i32le();else if(r===1)o=t.readUtf8(t.end-t.pos);else return ee("time zone",void 0,t.options);try{return Ky(n,{timeZone:o})}catch{return ee("time zone",void 0,t.options)}}case"duration":switch(t.byte()){case 0:return Qr(t.zigzag());case 1:return Io;case 2:return ha;default:return ee("duration",void 0,t.options)}case"bigDecimal":{let n=t.zigzag(),r=t.zigzag();return(r>dO||-r>dO)&&ee("safe integer length",void 0,t.options),gr(n,Number(r))}case"json":{let n=t.readUtf8(t.end-t.pos);try{return JSON.parse(n)}catch{return ee("json",void 0,t.options)}}case"option":{let n=t.byte();return n===0?(t.remaining!==0&&ee("empty",void 0,t.options),D()):(n!==1&&ee("bool",void 0,t.options),L(sp(Cr(e.value,t))))}case"result":{let n=t.byte();return n===0?le(sp(Cr(e.success,t))):(n!==1&&ee("bool",void 0,t.options),ge(sp(Cr(e.failure,t))))}case"exit":{let n=t.byte();if(n===0)return Pn(sp(Cr(e.value,t)));n!==1&&ee("bool",void 0,t.options);let r=Ig(e.cause,t);return Jt(r)}case"cause":{let n=t.uvarint(),r=[];for(let o=0;o<n;o++){ot[fe++]=o;let s=t.enter(t.uvarint()),i=TW(e,t);t.exit(s),fe--,i!==Ln&&r.push(i)}return t.pos!==t.end&&ee("no leftover bytes",void 0,t.options),Ia(r)}case"causeReason":return TW(e,t);case"struct":return t.positional?oce(e,t):rce(e,t);case"array":return uce(e,t);case"union":return t.positional?dce(e,t):lce(e,t);case"never":throw Sn(new tt(e.ast,void 0,t.options))}}function l3(e,t,n){let r=t.byte();if(r!==n.envelope&&ee(n.expectedEnvelope,r,t.options),n.positional){t.remaining<8&&ee("complete value",void 0,t.options);let s=t.buf,i=n.fingerprint,a=t.pos;for(let c=0;c<8;c++)s[a+c]!==i[c]&&ee("matching layout fingerprint",void 0,t.options);t.pos=a+8}let o=Cr(e,t);if(o===Ln)throw Sn(new tn(void 0));return o}var o0=new vg;function pce(e,t,n,r){let o=o0??new vg,s=o===o0;s&&(o0=void 0),o.reset(t,0,t.length,n,void 0,r.positional,void 0);let i=fe;fe=0;try{let a=o.uvarint();a===0&&ee("nonzero frame length",void 0,n);let c=o.enter(a),u=l3(e,o,r);return o.exit(c),o.pos!==t.length&&ee("no leftover bytes",void 0,n),u}finally{fe=i,o.release(),s&&(o0=o)}}function mce(e,t,n,r=!1){return qr({decode:(o,s)=>{try{let i=pce(e,o,s,t);return n!==void 0&&sl(i)&&(!r||b0(i))&&(n.value=i),k(i)}catch(i){return i instanceof ea?Q(i.issue):Ao(i)}},encode:(o,s)=>{try{return k(h0(e,o,s,t))}catch(i){return i instanceof ea?Q(i.issue):Ao(i)}}})}var hce=bn(Tae);function Vf(e,t){return t===!0?hce(e):vae}var gce=bn(e=>{let t=se(a0(e)),{exact:n,exitSuccess:r,layout:o,recursive:s}=Sae(t.ast);return{target:s?Ece(t):t,layout:o,exact:n,exitSuccess:r,recursive:s}});function ap(e){return gce(e.ast)}function d3(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function p3(e,t,n){let r=se(hn(e.ast)),o=ut(r),s=i=>()=>(a,c,u)=>i(a,u)?ln:o(a,u);return se(new Pi([r.ast],s(t),{identifier:"binary value"},void 0,void 0,void 0,void 0,s(n)))}function wO(e,t){return t.onExcessProperty!=="error"}function xce(e,t,n){return p3(e,r=>d3(t,r),n?wO:yce)}function yce(){return!1}function Sce(e,t){return Dn()([e],([n])=>{let r=ut(n);return(o,s,i)=>d3(t,o)||b0(o)&&i.onExcessProperty!=="error"?k(o):r(o,i)},{identifier:"binary exit value"})}function bce(e){return p3(e,wO,wO)}function Ece(e){let t=se(hn(e.ast)),n=new WeakSet,r=Dn()([t],([o])=>(s,i,a)=>sl(s)&&n.delete(s)?k(s):Rr(s)?Q(new tt(i,s,a)):ut(o)(s,a),{identifier:"acyclic value"});return ve(r,Rt({decode:o=>(sl(o)&&n.add(o),o),encode:o=>o}))(e)}var Mg=Gc,Rn=class extends qe()("effect/rpc/RpcSerialization"){},_g=class extends _n("MaxBufferSizeExceeded"){get message(){return`RPC serialization buffer exceeded the maximum size of ${this.maxBufferSize}`}},g3=16*1024*1024,E0=(e,t)=>t!=="unbounded"&&e>t,x3=Rn.of({contentType:"application/json",includesFraming:!1,codecFor:Mg,makeUnsafe:()=>{let e=new TextDecoder;return{decode:t=>{let n=JSON.parse(typeof t=="string"?t:e.decode(t));return Array.isArray(n)?n:[n]},encode:t=>JSON.stringify(t)}}}),w0=e=>{let t=e?.maxBufferSize??g3;return Rn.of({contentType:"application/ndjson",includesFraming:!0,codecFor:Mg,makeUnsafe:()=>{let n=new TextDecoder,r="",o=s=>{throw r="",new _g({maxBufferSize:s})};return{decode:s=>{r+=typeof s=="string"?s:n.decode(s,{stream:!0});let i=0,a=r.indexOf(`
33
- `,i),c=[];for(;a!==-1;){E0(a-i,t)&&o(t);let u=JSON.parse(r.slice(i,a));c.push(u),i=a+1,a=r.indexOf(`
34
- `,i)}return r=r.slice(i),E0(r.length,t)&&o(t),c},encode:s=>{if(Array.isArray(s)){if(s.length===0)return;let i="";for(let a=0;a<s.length;a++)i+=JSON.stringify(s[a])+`
8
+ ${s(p)}}`;m=i(f,x)}}return n.delete(f),m}return String(f)}return c(e,0)}var AK="[Circular]";function ni(e){return typeof e=="string"?JSON.stringify(e):String(e)}function hx(e){return e.map(t=>`[${ni(t)}]`).join("")}function lI(e){try{return e.toISOString()}catch{return"Invalid Date"}}function kK(e){try{let t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}function ZO(e,t){try{return e[t]}catch{return"[property access threw]"}}function qc(e,t){let r=[];return JSON.stringify(e,function(n,o){let s=Object.getOwnPropertyDescriptor(this,n)?.value,i=O(s,jc)?ho(s):ho(o);if(typeof i=="bigint")return j(i);if(typeof i!="object"||i===null)return i;let a=i instanceof Error&&!O(i,"toJSON")?{...i,name:i.name,message:i.message}:i;for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(i))return;if(r.push(i),a!==i&&r.push(a),!RK(a)||OK(a))return a;let c=new Proxy(a,{get(u,f){let p=Reflect.get(u,f,u);return Object.getOwnPropertyDescriptor(u,f)?.get!==void 0?ho(p):p}});return r.push(c),c},t?.space)??"null"}function RK(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function OK(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}var Qe=Symbol.for("nodejs.util.inspect.custom"),pr=e=>{try{return e=ho(e),O(e,"toJSON")&&or(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(pr):e}catch{return"[toJSON threw]"}},QO=(e,t=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?qc(e,{space:t}):j(e,{space:t})}catch{return String(e)}},kt={toJSON(){return pr(this)},[Qe](){return this.toJSON()},toString(){return j(this.toJSON())}},xx=class{[Qe](){return this.toJSON()}toString(){return j(this.toJSON())}};var PK=()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},MK=PK(),Ir=()=>Error.stackTraceLimit,yt=e=>{MK&&(Error.stackTraceLimit=e)};var _a=class{constructor(t){this.value=t,this.done=!1}next(t){return this.done?(this.value=t,this):(this.done=!0,{value:this.value,done:!1})}},FK=()=>{let e="~effect/Utils/internal",t={[e]:s=>s()},r={[e]:s=>s()},n=Ir();if(n===0)return r[e];yt(2);let o=t[e](()=>new Error);return yt(n),o.stack?.includes(e)===!0?t[e]:r[e]},Pa=FK();function B(e,t,r){t==="__proto__"?Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}):e[t]=r}function gx(e,t){for(let r of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,r)&&B(e,r,t[r])}var si="~effect/Effect",zc="~effect/Exit",UK={_A:F,_E:F,_R:F},dI=`${si}/identifier`,Se=`${si}/args`,St=`${si}/evaluate`,mr=`${si}/successCont`,go=`${si}/failureCont`,Wc=`${si}/ensureCont`,Vc=Symbol.for("effect/Effect/Yield"),wr={pipe(){return V(this,arguments)},toJSON(){return{...this}},toString(){return j(this.toJSON(),{ignoreToString:!0,space:2})},[Qe](){return this.toJSON()}},XO={[ie](){return Bd(this,Object.keys(this))},[ae](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n]||!Z(this[t[n]],e[t[n]]))return!1;return!0}},DK={[si]:UK,...wr,[Symbol.iterator](){return new _a(this)},toJSON(){return{_id:"Effect",op:this[dI],...Se in this?{args:this[Se]}:void 0}}},ge=e=>O(e,si),Wd=e=>O(e,zc),yx="~effect/Cause",qd="~effect/Cause/Reason",Af=e=>O(e,yx),e_=e=>O(e,qd),oi=class{constructor(t){this[yx]=yx,this.reasons=t}pipe(){return V(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(t=>t.toJSON())}}toString(){return`Cause(${j(this.reasons)})`}[Qe](){return this.toJSON()}[ae](t){return Af(t)&&this.reasons.length===t.reasons.length&&this.reasons.every((r,n)=>Z(r,t.reasons[n]))}[ie](){return ri(this.reasons)}},YO=new WeakMap,vf=class{[qd];annotations;_tag;constructor(t,r,n){if(this[qd]=qd,this._tag=t,r!==Kd&&typeof n=="object"&&n!==null&&r.size>0){let o=YO.get(n);o&&(r=new Map([...o,...r])),YO.set(n,r)}this.annotations=r}annotate(t,r){if(t.mapUnsafe.size===0)return this;let n=new Map(this.annotations);t.mapUnsafe.forEach((s,i)=>{r?.overwrite!==!0&&n.has(i)||n.set(i,s)});let o=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return o.annotations=n,o}pipe(){return V(this,arguments)}toString(){return j(this)}[Qe](){return this.toString()}},Kd=new Map,Kc=class extends vf{constructor(t,r=Kd){super("Fail",r,t),this.error=t}toString(){return`Fail(${j(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[ae](t){return hs(t)&&Z(this.error,t.error)&&Z(this.annotations,t.annotations)}[ie](){return he(Be(this._tag))(he(J(this.error))(J(this.annotations)))}},zi=e=>new oi(e),LK=(e,t)=>{let r=new Map,n=[];for(let o of e.concat(t)){let s=J(o),i=r.get(s);if(i===void 0)r.set(s,[o]);else{if(i.some(a=>Z(a,o)))continue;i.push(o)}n.push(o)}return n},kf=d(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let r=new oi(LK(e.reasons,t.reasons));return Z(e,r)?e:r}),pI=new oi([]),Rf=e=>new oi([new Kc(e)]),zd=class extends vf{constructor(t,r=Kd){super("Die",r,t),this.defect=t}toString(){return`Die(${j(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[ae](t){return Jd(t)&&Z(this.defect,t.defect)&&Z(this.annotations,t.annotations)}[ie](){return he(Be(this._tag))(he(J(this.defect))(J(this.annotations)))}},mI=e=>new oi([new zd(e)]),Vd=d(e=>Af(e[0]),(e,t,r)=>t.mapUnsafe.size===0?e:new oi(e.reasons.map(n=>n.annotate(t,r)))),hs=e=>e._tag==="Fail",Jd=e=>e._tag==="Die",Gd=e=>e._tag==="Interrupt";function BK(e){return ln("Effect.evaluate: Not implemented")}var yo=e=>({...DK,[dI]:e.op,[St]:e[St]??BK,[mr]:e[mr],[go]:e[go],[Wc]:e[Wc]}),Uo=e=>{let t=yo(e),r=function(n){this[Se]=n};return r.prototype=t,function(n){return new r(n)}},t_=e=>{let t={[zc]:zc,_tag:e.op,get[e.prop](){return this[Se]},...yo(e),toString(){return`${e.op}(${j(this[Se])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[Se]}},[ae](n){return Wd(n)&&n._tag===this._tag&&Z(this[Se],n[Se])},[ie](){return he(Be(e.op),J(this[Se]))}},r=function(n){this[Se]=n};return r.prototype=t,function(n){return new r(n)}},ze=t_({op:"Success",prop:"value",[St](e){let t=e.getCont(mr);return t?t[mr](this[Se],e,this):e.yieldWith(this)}}),bx={key:"effect/Cause/StackTrace"},hI={key:"effect/Cause/InterruptorStackTrace"},Pr=t_({op:"Failure",prop:"cause",[St](e){let t=this[Se],r=!1;e.cache.stackFrame&&(t=Vd(t,{mapUnsafe:new Map([[bx.key,e.cache.stackFrame]])}),r=!0);let n=e.getCont(go),o=e._interruptedCause;if(o&&e.interruptible){let s=!1;for(;n&&e.interruptible;)s||=dI in n,n=e.getCont(go);s&&(t=zi(t.reasons.filter(i=>i._tag!=="Fail"))),t=kf(t,o),r=!0}return n?n[go](t,e,r?void 0:this):e.yieldWith(r?Pr(t):this)}}),So=e=>Pr(Rf(e)),ln=e=>Pr(mI(e)),oe=Uo({op:"WithFiber",[St](e){return this[Se](e)}}),r_=Uo({op:"WithFiberSucceed",[St](e){let t=this[Se](e),r=e.getCont(mr);return r?r[mr](t,e):e.yieldWith(ze(t))}}),$K=(function(){class e extends globalThis.Error{}let t=yo({op:"YieldableError",[St](){return So(this)}});return delete t.toString,Object.assign(e.prototype,t),e})(),Zd=(function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends $K{constructor(r){super(r?.message,r?.cause?{cause:r.cause}:void 0),r&&(gx(this,r),Object.defineProperty(this,e,{value:r,enumerable:!1}))}toJSON(){return{...this[e],...this}}}})(),Wi=e=>{class t extends Zd{_tag=e}return t.prototype.name=e,t},Sx="~effect/Cause/NoSuchElementError",xI=e=>O(e,Sx),ms=class extends Wi("NoSuchElementError"){[Sx]=Sx;constructor(t){super({message:t})}},Cf="~effect/Cause/Done",n_=e=>O(e,Cf),o_={[Cf]:Cf,_tag:"Done",value:void 0},Jc=e=>e===void 0?o_:{[Cf]:Cf,_tag:"Done",value:e},HK=So(o_),s_=e=>e===void 0?HK:So(Jc(e));var i_=e=>yo({op:e.label,[St]:e.evaluate});var ke={};ps(ke,{Do:()=>T3,all:()=>u3,andThen:()=>s3,as:()=>T_,asVoid:()=>n3,bind:()=>I3,bindTo:()=>b3,composeK:()=>a3,contains:()=>y3,containsWith:()=>k_,exists:()=>S3,filter:()=>Fa,filterMap:()=>p3,firstSomeOf:()=>t3,flatMap:()=>gs,flatMapNullishOr:()=>CI,flatten:()=>Yc,fromIterable:()=>GK,fromNullOr:()=>wI,fromNullishOr:()=>Qc,fromUndefinedOr:()=>TI,gen:()=>w3,getFailure:()=>QK,getOrElse:()=>Ma,getOrNull:()=>rp,getOrThrow:()=>vI,getOrThrowWith:()=>Nf,getOrUndefined:()=>_n,getSuccess:()=>ZK,isNone:()=>fe,isOption:()=>ci,isSome:()=>de,let:()=>E3,lift2:()=>x3,liftNullishOr:()=>r3,liftPredicate:()=>g3,liftThrowable:()=>xs,makeCombinerFailFast:()=>R_,makeEquivalence:()=>m3,makeOrder:()=>h3,makeReducer:()=>v3,makeReducerFailFast:()=>C3,map:()=>Ut,match:()=>Zt,none:()=>_,orElse:()=>YK,orElseResult:()=>e3,orElseSome:()=>XK,partitionMap:()=>d3,product:()=>C_,productMany:()=>c3,reduceCompact:()=>f3,some:()=>N,tap:()=>v_,toArray:()=>l3,toRefinement:()=>JK,void:()=>o3,zipLeft:()=>i3,zipRight:()=>w_,zipWith:()=>A_});function c_(e){return{combine:e}}function gI(e,t,r){return{combine:e,initialValue:t,combineAll:r??(n=>{let o=t;for(let s of n)o=e(o,s);return o})}}var Wr=e=>(t,r)=>t===r||e(t,r),jK=(e,t)=>e===t,Gc=()=>jK;function l_(e){return Wr((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e[n](t[n],r[n]))return!1;return!0})}function Ex(e){return Wr((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e(t[n],r[n]))return!1;return!0})}var Ix=e=>d(3,(t,r,n)=>e(t,o=>({...o,[r]:n(o)}))),Tx=e=>d(2,(t,r)=>e(t,n=>({[r]:n}))),wx=(e,t)=>d(3,(r,n,o)=>t(r,s=>e(o(s),i=>({...s,[n]:i}))));var p_="~effect/Option",m_={[p_]:{_A:e=>e},...wr,[Symbol.iterator](){return new _a(this)}},qK=Object.defineProperty(Object.assign(Object.create(m_),{_tag:"Some",_op:"Some",[ae](e){return vx(e)&&yI(e)&&Z(this.value,e.value)},[ie](){return he(J(this._tag))(J(this.value))},toString(){return`some(${j(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:pr(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),zK=J("None"),WK=Object.assign(Object.create(m_),{_tag:"None",_op:"None",valueOrUndefined:void 0,[ae](e){return vx(e)&&Cx(e)},[ie](){return zK},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),vx=e=>O(e,p_),Cx=e=>e._tag==="None",yI=e=>e._tag==="Some",Qd=Object.create(WK),h_=function(e){this.value=e};h_.prototype=qK;var Yd=e=>new h_(e);var g_="~effect/Result",y_={[g_]:{_A:e=>e,_E:e=>e},...wr,[Symbol.iterator](){return new _a(this)}},KK=Object.assign(Object.create(y_),{_tag:"Success",_op:"Success",[ae](e){return Ax(e)&&_f(e)&&Z(this.success,e.success)},[ie](){return he(J(this._tag))(J(this.success))},toString(){return`success(${j(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:pr(this.success)}}}),VK=Object.assign(Object.create(y_),{_tag:"Failure",_op:"Failure",[ae](e){return Ax(e)&&Of(e)&&Z(this.failure,e.failure)},[ie](){return he(J(this._tag))(J(this.failure))},toString(){return`failure(${j(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:pr(this.failure)}}}),Ax=e=>O(e,g_),Of=e=>e._tag==="Failure",_f=e=>e._tag==="Success",S_=function(e){this.failure=e};S_.prototype=VK;var kx=e=>new S_(e),b_=function(e){this.success=e};b_.prototype=KK;var Rx=e=>new b_(e),SI=e=>_f(e)?Qd:Yd(e.failure),bI=e=>Of(e)?Qd:Yd(e.success);function ai(e){return(t,r)=>t===r?0:e(t,r)}var I_=ai((e,t)=>e<t?-1:1),Ki=ai((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1);var Pf=ai((e,t)=>e<t?-1:1);var EI=d(2,(e,t)=>ai((r,n)=>e(t(r),t(n)))),Mf=EI(Ki,e=>e.getTime());var Xd=e=>d(2,(t,r)=>e(t,r)===-1),Zc=e=>d(2,(t,r)=>e(t,r)===1),ep=e=>d(2,(t,r)=>e(t,r)!==1),tp=e=>d(2,(t,r)=>e(t,r)!==-1),II=e=>d(2,(t,r)=>t===r||e(t,r)<1?t:r);var _=()=>Qd,N=Yd,ci=vx,fe=Cx,de=yI,Zt=d(2,(e,{onNone:t,onSome:r})=>fe(e)?t():r(e.value)),JK=e=>t=>de(e(t)),GK=e=>{for(let t of e)return N(t);return _()},ZK=bI,QK=SI,Ma=d(2,(e,t)=>fe(e)?t():e.value),YK=d(2,(e,t)=>fe(e)?t():e),XK=d(2,(e,t)=>fe(e)?N(t()):e),e3=d(2,(e,t)=>fe(e)?Ut(t(),Rx):Ut(e,kx)),t3=e=>{let t=_();for(t of e)if(de(t))return t;return t},Qc=e=>e==null?_():N(e),TI=e=>e===void 0?_():N(e),wI=e=>e===null?_():N(e),r3=e=>(...t)=>Qc(e(...t)),rp=Ma(rI),_n=Ma(po),xs=e=>(...t)=>{try{return N(e(...t))}catch{return _()}},Nf=d(2,(e,t)=>{if(de(e))return e.value;throw t()}),vI=Nf(()=>new Error("getOrThrow called on a None")),Ut=d(2,(e,t)=>fe(e)?_():N(t(e.value))),T_=d(2,(e,t)=>Ut(e,()=>t)),n3=T_(void 0),o3=N(void 0);var gs=d(2,(e,t)=>fe(e)?_():t(e.value)),s3=d(2,(e,t)=>gs(e,r=>{let n=or(t)?t(r):t;return ci(n)?n:N(n)})),CI=d(2,(e,t)=>fe(e)?_():Qc(t(e.value))),Yc=gs(F),w_=d(2,(e,t)=>gs(e,()=>t)),i3=d(2,(e,t)=>v_(e,()=>t)),a3=d(2,(e,t)=>r=>gs(e(r),t)),v_=d(2,(e,t)=>gs(e,r=>Ut(t(r),()=>r))),C_=d(2,(e,t)=>de(e)&&de(t)?N([e.value,t.value]):_()),c3=d(2,(e,t)=>{if(fe(e))return _();let r=[e.value];for(let n of t){if(fe(n))return _();r.push(n.value)}return N(r)}),u3=e=>{if(Symbol.iterator in e){let r=[];for(let n of e){if(fe(n))return _();r.push(n.value)}return N(r)}let t={};for(let r of Object.keys(e)){let n=e[r];if(fe(n))return _();B(t,r,n.value)}return N(t)},A_=d(3,(e,t,r)=>Ut(C_(e,t),([n,o])=>r(n,o))),f3=d(3,(e,t,r)=>{let n=t;for(let o of e)de(o)&&(n=r(n,o.value));return n}),l3=e=>fe(e)?[]:[e.value],d3=d(2,(e,t)=>{if(fe(e))return[_(),_()];let r=t(e.value);return Of(r)?[_(),N(r.failure)]:[N(r.success),_()]}),p3=d(2,(e,t)=>{if(fe(e))return _();let r=t(e.value);return _f(r)?N(r.success):_()}),Fa=d(2,(e,t)=>fe(e)?_():t(e.value)?N(e.value):_()),m3=e=>Wr((t,r)=>fe(t)?fe(r):fe(r)?!1:e(t.value,r.value)),h3=e=>ai((t,r)=>de(t)?de(r)?e(t.value,r.value):1:-1),x3=e=>d(2,(t,r)=>A_(t,r,e)),g3=d(2,(e,t)=>t(e)?N(e):_()),k_=e=>d(2,(t,r)=>fe(t)?!1:e(t.value,r)),y3=k_(jd()),S3=d(2,(e,t)=>fe(e)?!1:t(e.value)),b3=Tx(Ut),E3=Ix(Ut);var I3=wx(Ut,gs),T3=N({}),w3=(...e)=>{let r=(e.length===1?e[0]:e[1].bind(e[0]))(),n=r.next();for(;!n.done;){let o=n.value;if(fe(o))return o;n=r.next(o.value)}return N(n.value)};function v3(e){return gI((t,r)=>fe(t)?r:fe(r)?t:N(e.combine(t.value,r.value)),_())}function R_(e){return c_((t,r)=>fe(t)||fe(r)?_():N(e.combine(t.value,r.value)))}function C3(e){let t=R_(e).combine,r=N(e.initialValue);return gI(t,r,n=>{let o=r;for(let s of n)if(o=t(o,s),fe(o))return o;return o})}var O_="~effect/Context/Service",Ue=function(){function e(){}let t=e;Object.setPrototypeOf(t,A3);let r=(n,o)=>(t.key=n,o?.defaultValue&&(t[kI]=kI,t.defaultValue=o.defaultValue),o?.make&&(t.make=o.make),o?.fiberCached&&__.add(n),t);return arguments.length>0?r(arguments[0],arguments[1]):r},A3={[O_]:O_,...i_({label:"Service",evaluate(e){return ze(Re(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return ys(this,e)},use(e){return oe(t=>e(Re(t.context,this)))},useSync(e){return oe(t=>ze(e(Re(t.context,this))))}},__=new Set,kI="~effect/Context/Reference",P_="~effect/Context",k3=8,R3=8,RI=(e,t,r,n)=>{let o=Object.create(O3);return o.cacheRoot=e??o,o.base=t,o.overlay=r,o.depth=n,o._flat=void 0,o.baseHits=0,o},OI=(e,t)=>{t&&(OI(e,t.parent),e.set(t.key,t.value))},M_=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return OI(t,e.overlay),e._flat=t},F_=(e,t)=>{let r=new Map(e.mapUnsafe);return t(r),qn(r)},Ox=Symbol(),_I=(e,t)=>{let r=e;for(let o=r.overlay;o;o=o.parent)if(o.key===t)return o.value;let n=r.base.get(t);return n===void 0&&!r.base.has(t)?Ox:(r.overlay&&++r.baseHits>=r.base.size&&r.baseHits>=R3&&(r.base=M_(r),r.overlay=void 0,r.depth=0),n)},qn=e=>RI(void 0,e,void 0,0),O3={get mapUnsafe(){return M_(this)},...wr,[P_]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[ae](e){if(!np(e))return!1;let t=this.mapUnsafe,r=e.mapUnsafe;if(t.size!==r.size)return!1;for(let[n,o]of t)if(!r.has(n)||!Z(o,r.get(n)))return!1;return!0},[ie](){return qt(this.mapUnsafe.size)}},N_=(e,t)=>e.cacheRoot===t.cacheRoot,np=e=>O(e,P_);var U_=e=>!!e[kI],pt=()=>_3,_3=qn(new Map),ys=(e,t)=>qn(new Map([[e.key,t]])),We=d(3,(e,t,r)=>P3(e,t.key,r)),P3=(e,t,r)=>{let n=e,o=__.has(t)?void 0:n.cacheRoot;if(n.depth>=k3){let s=new Map(n._flat??n.base);return n._flat||OI(s,n.overlay),s.set(t,r),RI(o,s,void 0,0)}return RI(o,n.base,{key:t,value:r,parent:n.overlay},n.depth+1)};var Vi=d(2,(e,t)=>Ji(e,t.key)),Ji=(e,t)=>{let r=_I(e,t);return r===Ox?void 0:r},dn=d(2,(e,t)=>{let r=_I(e,t.key);if(r===Ox){if(U_(t))return D_(t);throw M3(t)}return r}),Re=dn,AI="~effect/Context/defaultValue",D_=e=>AI in e?e[AI]:e[AI]=e.defaultValue(),M3=e=>{let t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let r=t.stack.split(`
9
+ `);r.splice(1,3),t.stack=r.join(`
10
+ `)}return t},_x=d(2,(e,t)=>{let r=_I(e,t.key);return r!==Ox?N(r):U_(t)?N(D_(t)):_()}),Kr=d(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:F_(e,r=>t.mapUnsafe.forEach((n,o)=>r.set(o,n)))),L_=(...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].mapUnsafe.forEach((n,o)=>{t.set(o,n)});return qn(t)};var B_=(...e)=>t=>F_(t,r=>{for(let n=0;n<e.length;n++)r.delete(e[n].key)}),Ce=Ue;var PI=e=>e.length>0;var Dt=e=>e>0?Math.floor(e):0,Lo=e=>Math.max(1,Dt(e));var X=Rx,re=kx;var Px=e=>{if(or(e))try{return X(e())}catch(t){return re(t)}else try{return X(e.try())}catch(t){return re(e.catch(t))}};var Uf=Ax,be=Of,tt=_f;var MI=d(2,(e,t)=>be(e)?re(t(e.failure)):e),Vr=d(2,(e,t)=>tt(e)?X(t(e.success)):e),zn=d(2,(e,{onFailure:t,onSuccess:r})=>be(e)?t(e.failure):r(e.success));var op=d(2,(e,t)=>be(e)?t(e.failure):e.success);var N3=d(2,(e,t)=>{if(tt(e))return e.success;throw t(e.failure)}),Xc=N3(F);var hr=d(2,(e,t)=>be(e)?re(e.failure):t(e.success));var $_=l_;var U3=(e,t)=>{let r=t?.length!==void 0?Lo(t.length):1/0;return{[Symbol.iterator](){let n=0;return{next(){return n<r?{value:e(n++),done:!1}:{done:!0,value:void 0}}}}}};var D3=d(2,(e,t)=>L3(U3(()=>e,{length:t}))),j_=e=>D3(e,1/0);var q_=e=>{let r=e[Symbol.iterator]().next();if(r.done)throw new Error("headUnsafe: empty iterable");return r.value};var z_=d(2,(e,t)=>{let r=0;for(let n of e){let o=t(n,r);if(ux(o)){if(o)return N(n)}else if(de(o))return o;r++}return _()});var L3=e=>({[Symbol.iterator](){let t=e[Symbol.iterator](),r;function n(){for(;;){if(r===void 0){let s=t.next();if(s.done)return s;r=s.value[Symbol.iterator]()}let o=r.next();if(!o.done)return o;r=void 0}}return{next:n}}});var W_=d(2,(e,t)=>({[Symbol.iterator](){let r=e[Symbol.iterator](),n=0;return{next(){let o=r.next();for(;!o.done;){if(t(o.value,n++))return{done:!1,value:o.value};o=r.next()}return{done:!0,value:void 0}}}}}));var B3=d(2,(e,t)=>Object.hasOwn(e,t));var Mx=d(2,(e,t)=>{let r={...e};for(let n of K_(e))B(r,n,t(e[n],n));return r});var K_=e=>Object.keys(e);var $3=e=>d(2,(t,r)=>{for(let n of K_(t))if(!B3(r,n)||!e(t[n],r[n]))return!1;return!0});var V_=e=>{let t=$3(e);return(r,n)=>t(r,n)&&t(n,r)};var Nx=globalThis.Array;var J_=d(2,(e,t)=>{let r=Lo(e),n=new Nx(r);for(let o=0;o<r;o++)n[o]=t(o);return n}),FI=(e,t)=>e<=t?J_(t-e+1,r=>e+r):[e];var vt=e=>Nx.isArray(e)?e:Nx.from(e);var Ux=d(2,(e,t)=>[...e,t]),ip=d(2,(e,t)=>vt(e).concat(vt(t)));var G_=Nx.isArray;var Jr=PI,bt=PI;function Dx(e){let t=Number(e);return String(t)===e&&Number.isInteger(t)&&t>=0&&t<2**32-1}function H3(e,t){return!Number.isFinite(e)||e<0||e>=t.length}var Z_=d(2,(e,t)=>{let r=Math.floor(t);if(H3(r,e))throw new Error(`Index out of bounds: ${r}`);return e[r]});var Df=e=>e[e.length-1];var NI=z_;var j3=(e,t)=>{let r=J(t),n=e.get(r);if(n===void 0)return e.set(r,[t]),!0;for(let o of n)if(Z(o,t))return!1;return n.push(t),!0};var Qt=()=>[],Me=e=>[e],Bo=d(2,(e,t)=>e.map(t));var Lx=d(2,(e,t)=>{let r=vt(e),n=[];for(let o=0;o<r.length;o++)t(r[o],o)&&n.push(r[o]);return n}),UI=d(2,(e,t)=>{let r=[],n=[],o=0;for(let s of e){let i=t(s,o++);tt(i)?r.push(i.success):n.push(i.failure)}return[r,n]});var Q_=Ex;var Bx=e=>{let t=vt(e);if(t.length<2)return[...t];let r=new Map,n=[];for(let o of t)j3(r,o)&&n.push(o);return n};var Hx="~effect/Duration",Ua=BigInt(0),oP=BigInt(1),K3=BigInt(2),V3=BigInt(10),Y_=BigInt(24),$x=BigInt(60),DI=BigInt(1e3),X_=BigInt(1e6);var LI=e=>BigInt(Math.sign(e)*Math.round(Math.abs(e))),sP=e=>LI(e*1e6),eP=e=>pn(Number.isFinite(e)?LI(e):e),tP=(e,t)=>{let r=e.indexOf(".");if(r===-1)return BigInt(e)*t;let n=e[0]==="-",o=e.slice(r+1),s=V3**BigInt(o.length),i=(BigInt(e.slice(n?1:0,r))*s+BigInt(o))*t;return J3(n?-i:i,s)},J3=(e,t)=>{let r=e<Ua?-e:e,n=r/t+(r%t*K3>=t?oP:Ua);return e<Ua?-n:n};var G3=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,$e=e=>{switch(typeof e){case"number":return Zi(e);case"bigint":return $o(e);case"string":{if(e==="Infinity")return Ss;if(e==="-Infinity")return Da;let t=G3.exec(e);if(!t)break;let[r,n,o]=t;if(o==="nano"||o==="nanos")return $o(tP(n,oP));if(o==="micro"||o==="micros")return $o(tP(n,DI));let s=Number(n);switch(o){case"milli":case"millis":return Zi(s);case"second":case"seconds":return ap(s);case"minute":case"minutes":return tV(s);case"hour":case"hours":return rV(s);case"day":case"days":return nV(s);case"week":case"weeks":return oV(s)}break}case"object":{if(e===null)break;if(Hx in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(Ud)?rP(e):Number.isNaN(e[0])||Number.isNaN(e[1])?Gi:e[0]===-1/0||e[1]===-1/0?Da:e[0]===1/0||e[1]===1/0?Ss:eP(e[0]*1e9+e[1]);let t=e,r=0;return t.weeks&&(r+=t.weeks*6048e5),t.days&&(r+=t.days*864e5),t.hours&&(r+=t.hours*36e5),t.minutes&&(r+=t.minutes*6e4),t.seconds&&(r+=t.seconds*1e3),t.milliseconds&&(r+=t.milliseconds),!t.microseconds&&!t.nanoseconds?pn(r):eP(r*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0))}}return rP(e)},rP=e=>{throw new Error(`Invalid Input: ${e}`)},iP=xs($e),nP={_tag:"Millis",millis:0},Z3={_tag:"Infinity"},Q3={_tag:"NegativeInfinity"},Y3={[Hx]:Hx,[ie](){switch(this.value._tag){case"Millis":{let e=this.value.millis*1e6;return Number.isFinite(e)?J(LI(e)):qt(this.value.millis)}case"Nanos":return J(this.value.nanos);default:return $d(this.value)}},[ae](e){return Qi(e)&&aV(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},pn=e=>{let t=Object.create(Y3);return typeof e=="number"?isNaN(e)||e===0||Object.is(e,-0)?t.value=nP:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:sP(e)}:t.value=e>0?Z3:Q3:e===Ua?t.value=nP:t.value={_tag:"Nanos",nanos:e},t},Qi=e=>O(e,Hx),Wn=e=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity",Lf=e=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===Ua;case"Infinity":case"NegativeInfinity":return!1}},X3=e=>{switch(e.value._tag){case"Millis":return e.value.millis<0;case"Nanos":return e.value.nanos<Ua;case"NegativeInfinity":return!0;case"Infinity":return!1}};var eV=e=>{switch(e.value._tag){case"Infinity":case"NegativeInfinity":return Ss;case"Millis":return e.value.millis<0?pn(-e.value.millis):e;case"Nanos":return e.value.nanos<Ua?pn(-e.value.nanos):e}};var Gi=pn(0),Ss=pn(1/0),Da=pn(-1/0),$o=e=>pn(e);var Zi=e=>pn(e),ap=e=>pn(e*1e3),tV=e=>pn(e*6e4),rV=e=>pn(e*36e5),nV=e=>pn(e*864e5),oV=e=>pn(e*6048e5),zt=e=>cP($e(e),{onMillis:F,onNanos:t=>Number(t)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),ui=e=>cP($e(e),{onMillis:t=>t/1e3,onNanos:t=>Number(t)/1e9,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0});var jx=e=>{let t=$e(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return sP(t.value.millis)}},aP=xs(jx);var cP=d(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),BI=d(3,(e,t,r)=>e.value._tag==="Infinity"||e.value._tag==="NegativeInfinity"||t.value._tag==="Infinity"||t.value._tag==="NegativeInfinity"?r.onInfinity(e,t):e.value._tag==="Millis"?t.value._tag==="Millis"?r.onMillis(e.value.millis,t.value.millis):r.onNanos(jx(e),t.value.nanos):r.onNanos(e.value.nanos,jx(t))),sV=ai((e,t)=>BI(e,t,{onMillis:(r,n)=>r<n?-1:r>n?1:0,onNanos:(r,n)=>r<n?-1:r>n?1:0,onInfinity:(r,n)=>r.value._tag===n.value._tag?0:r.value._tag==="Infinity"?1:r.value._tag==="NegativeInfinity"||n.value._tag==="Infinity"?-1:1}));var iV=(e,t)=>BI(e,t,{onMillis:(r,n)=>r===n,onNanos:(r,n)=>r===n,onInfinity:(r,n)=>r.value._tag===n.value._tag}),uP=II(sV);var fP=d(2,(e,t)=>BI(e,t,{onMillis:(r,n)=>pn(r-n),onNanos:(r,n)=>pn(r-n),onInfinity:(r,n)=>{let o=r.value._tag,s=n.value._tag;return o==="Infinity"?s==="Infinity"?Gi:Ss:o==="NegativeInfinity"?s==="NegativeInfinity"?Gi:Da:s==="Infinity"?Da:Ss}}));var aV=d(2,(e,t)=>iV(e,t)),cV=e=>{if(e.value._tag==="Infinity")return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};if(e.value._tag==="NegativeInfinity")return{days:-1/0,hours:-1/0,minutes:-1/0,seconds:-1/0,millis:-1/0,nanos:-1/0};let t=jx(e),r=t<Ua,n=r?-t:t,o=n/X_,s=o/DI,i=s/$x,a=i/$x,c=a/Y_,u=r?-1:1;return{days:u*Number(c),hours:u*Number(a%Y_),minutes:u*Number(i%$x),seconds:u*Number(s%$x),millis:u*Number(o%DI),nanos:u*Number(n%X_)}},$I=e=>{if(e.value._tag==="Infinity")return"Infinity";if(e.value._tag==="NegativeInfinity")return"-Infinity";if(Lf(e))return"0";if(X3(e))return"-"+$I(eV(e));let t=cV(e),r=[];return t.days!==0&&r.push(`${t.days}d`),t.hours!==0&&r.push(`${t.hours}h`),t.minutes!==0&&r.push(`${t.minutes}m`),t.seconds!==0&&r.push(`${t.seconds}s`),t.millis!==0&&r.push(`${t.millis}ms`),t.nanos!==0&&r.push(`${t.nanos}ns`),r.join(" ")};var La=Ce("effect/Scheduler",{fiberCached:!0,defaultValue:()=>new fi}),lP=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},uV="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},dP=e=>{try{return uV(e)}catch{return lP(e)}},HI=class{buckets=[];scheduleTask(t,r){let n=this.buckets,o=n.length,s,i=0;for(;i<o&&!(n[i][0]>r);i++)s=n[i];s&&s[0]===r?s[1].push(t):i===o?n.push([r,[t]]):n.splice(i,0,[r,[t]])}drain(){let t=this.buckets;return this.buckets=[],t}},fi=class{executionMode;setImmediate;constructor(t="async",r){this.executionMode=t,this.setImmediate=r??(t==="sync"?lP:dP)}shouldYield(t){return t.currentOpCount>=t.cache.maxOpsBeforeYield}makeDispatcher(){return new jI(this.setImmediate)}},jI=class{tasks=new HI;running=void 0;setImmediate;constructor(t=dP){this.setImmediate=t}scheduleTask(t,r){this.tasks.scheduleTask(t,r),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let t=this.tasks.drain();for(let r=0;r<t.length;r++){let n=t[r][1];for(let o=0;o<n.length;o++)n[o]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},pP=Ce("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:()=>2048}),mP=Ce("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:()=>!1});var hP=class extends Ra{constructor(e){super(),e&&gx(this,e)}};var xP=Zd,sr=Wi;var gP="~effect/encoding/EncodingError",Ho=class extends sr("EncodingError"){[gP]=gP};var zx=e=>yP(typeof e=="string"?pV.encode(e):e),qI=e=>{switch(e){case 16:return lV();case 32:return dV();default:{let t="";for(let r=e>>>3;r>0;r--)t+=fV();return t}}},ue=Uint8Array.from("0123456789abcdef",e=>e.charCodeAt(0)),eu=()=>Math.random()*4294967296>>>0,fV=()=>{let e=eu();return String.fromCharCode(ue[e>>>28],ue[e>>>24&15],ue[e>>>20&15],ue[e>>>16&15],ue[e>>>12&15],ue[e>>>8&15],ue[e>>>4&15],ue[e&15])},lV=()=>{let e=eu(),t=eu();return String.fromCharCode(ue[e>>>28],ue[e>>>24&15],ue[e>>>20&15],ue[e>>>16&15],ue[e>>>12&15],ue[e>>>8&15],ue[e>>>4&15],ue[e&15],ue[t>>>28],ue[t>>>24&15],ue[t>>>20&15],ue[t>>>16&15],ue[t>>>12&15],ue[t>>>8&15],ue[t>>>4&15],ue[t&15])},dV=()=>{let e=eu(),t=eu(),r=eu(),n=eu();return String.fromCharCode(ue[e>>>28],ue[e>>>24&15],ue[e>>>20&15],ue[e>>>16&15],ue[e>>>12&15],ue[e>>>8&15],ue[e>>>4&15],ue[e&15],ue[t>>>28],ue[t>>>24&15],ue[t>>>20&15],ue[t>>>16&15],ue[t>>>12&15],ue[t>>>8&15],ue[t>>>4&15],ue[t&15],ue[r>>>28],ue[r>>>24&15],ue[r>>>20&15],ue[r>>>16&15],ue[r>>>12&15],ue[r>>>8&15],ue[r>>>4&15],ue[r&15],ue[n>>>28],ue[n>>>24&15],ue[n>>>20&15],ue[n>>>16&15],ue[n>>>12&15],ue[n>>>8&15],ue[n>>>4&15],ue[n&15])},zI=e=>{let t=new TextEncoder().encode(e);if(t.length%2!==0)return re(new Ho({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let r=t.length/2,n=new Uint8Array(r);for(let o=0;o<r;o++){let s=SP(t[o*2]),i=SP(t[o*2+1]);n[o]=s<<4|i}return X(n)}catch(r){return re(new Ho({module:"Hex",kind:"Decode",input:e,message:r instanceof Error?r.message:"Invalid input"}))}},bP=e=>Vr(zI(e),t=>mV.decode(t)),pV=new TextEncoder,mV=new TextDecoder,hV=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),yP=e=>{let t="";for(let r=0;r<e.length;r++)t+=hV[e[r]];return t},SP=e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw new TypeError("Invalid input")};var VI="effect/Tracer/ParentSpan",li=class extends Ue()(VI,{fiberCached:!0}){},xV=e=>e;var Bf=Ce("effect/Tracer/DisablePropagation",{defaultValue:Oa}),EP=Ce("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),IP=Ce("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),JI="effect/Tracer",GI=Ce(JI,{fiberCached:!0,defaultValue:()=>ZI}),ZI=xV({span:e=>new KI(e)}),KI=class{_tag="Span";sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(t){this.name=t.name,this.parent=t.parent,this.annotations=t.annotations,this.links=t.links,this.startTime=t.startTime,this.kind=t.kind,this.sampled=t.sampled,this.status={_tag:"Started",startTime:t.startTime}}get traceId(){return this._traceId??=_n(this.parent)?.traceId??qI(32)}get spanId(){return this._spanId??=qI(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(t,r){this.status={_tag:"Ended",endTime:t,exit:r,startTime:this.status.startTime}}attribute(t,r){this.attributes.set(t,r)}event(t,r,n){this.events.push([t,r,n??{}])}addLinks(t){this.links.push(...t)}};var TP="effect/Metric/FiberRuntimeMetrics";var wP=Ce("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),$f=Ce("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:po}),Kx=Ce("effect/References/TracerEnabled",{fiberCached:!0,defaultValue:nr}),tu=Ce("effect/References/TracerTimingEnabled",{defaultValue:nr}),cp=Ce("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),up=Ce("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),Xi=Ce("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),QI=Ce("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),YI=Ce("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),vP=Ce("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),Vx=Ce("effect/References/CurrentLogSpans",{defaultValue:()=>[]});var jo=e=>{if(e?.captureStackTrace===!1)return e;if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!="boolean")return e;let t=Ir();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};yt(3);let r=new Error;return yt(t),{...e,captureStackTrace:SV(()=>r.stack)}},XI=e=>t=>{let r;return()=>{if(r!==void 0)return r;let n=t();if(!n)return;let o=n.split(`
11
+ `);if(o[e]!==void 0)return r=o[e].trim(),r}},SV=XI(3);var Jx=class extends vf{constructor(t,r=Kd){super("Interrupt",r,"Interrupted"),this.fiberId=t}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[ae](t){return Gd(t)&&this.fiberId===t.fiberId&&this.annotations===t.annotations}[ie](){return he(Be(`${this._tag}:${this.fiberId}`))(dx(this.annotations))}},MP=e=>new Jx(e),$a=e=>new oi([new Jx(e)]),FP=e=>e.reasons.some(hs),NP=e=>{let t=e.reasons.find(hs);return t?X(t):re(e)},qo=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if(r._tag==="Fail")return X(r.error)}return re(e)};var UP=e=>e.reasons.some(Jd);var ng=e=>{let t=e.reasons.find(Jd);return t?X(t.defect):re(e)},og=e=>e.reasons.some(Gd);var hT=e=>{let t;for(let r=0;r<e.reasons.length;r++){let n=e.reasons[r];n._tag==="Interrupt"&&(t??=new Set,n.fiberId!==void 0&&t.add(n.fiberId))}return t?X(t):re(e)},DP=e=>{let t=hT(e);return be(t)?EV:t.success},EV=new Set,sg=e=>e.reasons.length>0&&e.reasons.every(Gd);var LP=d(2,(e,t)=>{let r=!1,n=e.reasons.map(o=>hs(o)?(r=!0,new Kc(t(o.error),o.annotations)):o);return r?zi(n):e}),ig=e=>{let t;for(let r of e.reasons){if(r._tag==="Fail")return r.error;r._tag==="Die"&&(t??=r)}return t!==void 0?t.defect:e.reasons.length>0?new globalThis.Error("All fibers interrupted without error"):new globalThis.Error("Empty cause")},BP=(e,t)=>{let r=[],n=[];if(e.reasons.length===0)return r;let o=Ir();o!==0&&yt(1);try{for(let s of e.reasons){if(s._tag==="Interrupt"){n.push(s);continue}r.push(tT(s._tag==="Die"?s.defect:s.error,s.annotations,t))}if(r.length===0){let s=new Error("The fiber was interrupted by:");s.name="InterruptCause",s.stack=vV(s,n);let i=new globalThis.Error("All fibers interrupted without error",{cause:s});i.name="InterruptError",i.stack=`${i.name}: ${i.message}`,r.push(tT(i,n[0].annotations,t))}}finally{o!==0&&yt(o)}return r},tT=(e,t,r)=>{let n=typeof e,o;if(e&&n==="object"){if(o=new globalThis.Error(IV(e),{cause:e.cause?tT(e.cause):void 0}),typeof e.name=="string"&&(o.name=e.name),typeof e.stack=="string")o.stack=wV(e.stack,o,t);else{let s=`${o.name}: ${o.message}`;o.stack=t?rT(s,t):s}r?.includeCauseInStack&&(o.stack=HP(o));for(let s of Object.keys(e))s in o||(o[s]=e[s])}else{o=new globalThis.Error(e?n==="string"?e:qc(e):`Unknown error: ${e}`);let s=`${o.name}: ${o.message}`;o.stack=t?rT(s,t):s}return o},IV=e=>{if(typeof e.message=="string")return e.message;if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return qc(e)},TV=/\((.*)\)/g,wV=(e,t,r)=>{let n=`${t.name}: ${t.message}`,o=(e.startsWith(n)?e.slice(n.length):e).split(`
12
+ `),s=[n];for(let i=1;i<o.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(o[i]);i++)s.push(o[i]);return r?rT(s.join(`
13
+ `),r):s.join(`
14
+ `)},rT=(e,t)=>{let r=t?.get(bx.key);return r&&(e=`${e}
15
+ ${$P(r)}`),e},vV=(e,t)=>{let r=[`${e.name}: ${e.message}`];for(let n of t){let o=n.fiberId!==void 0?`#${n.fiberId}`:"unknown",s=n.annotations.get(hI.key);r.push(` at fiber (${o})`),s&&r.push($P(s))}return r.join(`
16
+ `)},$P=e=>{let t=[],r=e,n=0;for(;r&&n<10;){let o=r.stack();if(o){let s=o.matchAll(TV),i=!1;for(let[,a]of s)i=!0,t.push(` at ${r.name} (${a})`);i||t.push(` at ${r.name} (${o.replace(/^at /,"")})`)}else t.push(` at ${r.name}`);r=r.parent,n++}return t.join(`
17
+ `)},ag=e=>BP(e).map(HP).join(`
18
+ `),HP=e=>e.cause?`${e.stack} {
19
+ ${jP(e.cause," ")}
20
+ }`:e.stack,jP=(e,t)=>{let r=e.stack.split(`
21
+ `),n=`${t}[cause]: ${r[0]}`;for(let o=1,s=r.length;o<s;o++)n+=`
22
+ ${t}${r[o]}`;return e.cause&&(n+=` {
23
+ ${jP(e.cause,`${t} `)}
24
+ ${t}}`),n},xT="~effect/Fiber",CV={_A:F,_E:F},AV={id:0},CP=(()=>{try{return globalThis.process?.getBuiltinModule?.("node:async_hooks")?.AsyncResource}catch{return}})(),qP=()=>CP===void 0?void 0:new CP("effect/Fiber"),ea=()=>globalThis[wf],fp=class{constructor(t,r=!0){this.setContext(t),this.id=++AV.id,this.currentOpCount=0,this.interruptible=r,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[xT](){return CV}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(t){return Re(this.context,t)}addObserver(t){return this._exit?(t(this._exit),Rr):(this._observers===void 0?this._observers=[t]:this._observers.push(t),()=>this.removeObserver(t))}removeObserver(t){if(this._exit||this._observers===void 0)return;let r=this._observers.indexOf(t);r>=0&&this._observers.splice(r,1)}interruptUnsafe(t,r){if(this._exit)return;let n=$a(t);this.cache.stackFrame&&(n=Vd(n,ys(bx,this.cache.stackFrame))),r&&(n=Vd(n,r)),this._interruptedCause=this._interruptedCause?kf(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Ye(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(t){if(this._exit)return;if(this._asyncContext!==void 0){let o=this._asyncContext;return this._asyncContext=void 0,o.runInAsyncScope(this.evaluate,this,t)}else if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let r=this.runLoop(t);if(r===Vc){this._asyncContext=qP();return}let n=nT.interruptChildren&&nT.interruptChildren(this);if(n!==void 0)return this.evaluate(Y(n,()=>r));if(this._exit=r,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&(this._parent._children?.delete(this),this._parent=void 0),this._observers!==void 0){let o=this._observers;this._observers=void 0;for(let s=0;s<o.length;s++)o[s](r)}this._stack.length=0,this._children=void 0,this.context=pt()}runLoop(t){let r=globalThis[wf];globalThis[wf]=this;let n=this._running;this._running=!0;let o=!1,s=t;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,s=Ye(this._interruptedCause)),this.currentOpCount++;let i=this.cache;if(!o&&!i.preventYield&&i.scheduler.shouldYield(this)){o=!0;let a=s;s=Y(zf,()=>a)}if(s=i.tracerContext?i.tracerContext(s,this):s[St](this),s===Vc){let a=this._yielded;if(zc in a)return this._deferredInterrupt=!1,this._yielded=void 0,a;if(this._deferredInterrupt){this._yielded=void 0,a();continue}return Vc}}catch(i){if(!O(s,St))return ln(`Fiber.runLoop: Not a valid effect: ${String(s)}`);s=ln(i)}}finally{this._running=n,globalThis[wf]=r}}getCont(t){if(this._deferredInterrupt)return this._deferredInterrupt=!1,RV;for(;;){let r=this._stack.pop();if(!r)return;let n=r[Wc];if(n!==void 0){let o=n.call(r,this);if(o)return o[t]=o,o}if(r[t])return r}}succeedWith(t){if((++this.currentOpCount&OV-1)===0)return ze(t);let r=this.getCont(mr);return r?r[mr](t,this):this.yieldWith(ze(t))}yieldWith(t){return this._yielded=t,Vc}children(){return this._children??=new Set}pipe(){return V(this,arguments)}setContext(t){let r=this.context;if(this.context=t,r!==void 0&&N_(r,t))return;let n=t.cacheRoot,o=n._fiberCache??=kV(t);this.cache?.scheduler!==o.scheduler&&(this._dispatcher=void 0),this.cache=o}get currentSpanLocal(){let t=this.cache.span;return t?._tag==="Span"?t:void 0}},kV=e=>{let t=Ji(e,JI);return{scheduler:Re(e,La),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:Re(e,Kx),span:Ji(e,VI),logLevel:Re(e,QI),minimumLogLevel:Re(e,YI),stackFrame:Re(e,$f),runtimeMetrics:Ji(e,TP),maxOpsBeforeYield:Re(e,pP),preventYield:Re(e,mP)}},RV={[mr](e,t){return Ye(t._interruptedCause)},[go](e,t){return Ye(t._interruptedCause)}},OV=32,nT={interruptChildren:void 0},cg=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(hI.key,e.cache.stackFrame),qn(t)},_V=e=>{if(!(e._children===void 0||e._children.size===0))return Hf(e._children)},gT=e=>{let t=e;return t._exit?q(t._exit):Lt(r=>t._exit?r(q(t._exit)):ye(e.addObserver(n=>r(q(n)))))},ug=e=>Lt(t=>{let r=e[Symbol.iterator](),n=[],o;function s(){let i=r.next();for(;!i.done;){if(i.value._exit){n.push(i.value._exit),i=r.next();continue}o=i.value.addObserver(a=>{n.push(a),s()});return}t(q(n))}return s(),ye(()=>o?.())}),Gx=e=>{let t=e;return t._exit?t._exit:Lt(r=>t._exit?r(t._exit):ye(e.addObserver(r)))},zP=e=>Lt(t=>{let r=Array.from(e);if(r.length===0)return t(q(Qt()));let n=new Array(r.length),o=Qt(),s=()=>{for(let c=0;c<o.length;c++)r[c].removeObserver(o[c])},i=0,a=!1;for(let c=0;c<r.length&&!a;c++){let u=f=>{if(i++,f._tag==="Failure")return a=!0,s(),t(f);n[c]=f.value,i===r.length&&t(q(n))};o.push(u),r[c].addObserver(u)}return ye(()=>{a=!0,s()})}),pp=e=>oe(t=>WP(e,t.id)),WP=d(e=>O(e[0],xT),(e,t,r)=>oe(n=>{let o=cg(n);return o=o&&r?Kr(o,r):o??r,e.interruptUnsafe(t,o),hp(gT(e))})),Hf=e=>oe(t=>{let r=cg(t),n=Qt();for(let o of e)o.interruptUnsafe(t.id,r),n.push(o);return hp(ug(n))});var q=ze,Ye=Pr,Et=So,ye=Uo({op:"Sync",[St](e){let t=this[Se](),r=e.getCont(mr);return r?r[mr](t,e):e.yieldWith(ze(t))}}),ce=Uo({op:"Suspend",[St](e){return this[Se]()}}),yT=d(e=>e.length>=2||ci(e[0]),(e,t)=>fe(e)?Et(t?t():new ms("Effect.fromOption: Option.none")):q(e.value)),qf=zn({onFailure:Et,onSuccess:q}),KP=e=>e==null?Et(new ms):q(e),ST=Uo({op:"Yield",[St](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(hn)},this[Se]??0),e.yieldWith(()=>{t=!0})}}),zf=ST(0),bT=e=>q(N(e)),ou=q(_()),VP=e=>fe(e)?ou:_e(e.value,N),JP=e=>ce(()=>Ye(e())),ta=e=>ln(e),fg=e=>ce(()=>Et(e())),pe=q(void 0);var GP=e=>{let t=typeof e=="function"?e:e.try,r=typeof e=="function"?n=>new dp(n,"An error occurred in Effect.try"):e.catch;return ce(()=>{try{return q(t())}catch(n){return Et(r(n))}})};var ET=e=>IT(function(t,r){e(r).then(n=>t(q(n)),n=>t(ta(n)))},e.length!==0),ZP=e=>{let t=typeof e=="function"?e:e.try,r=typeof e=="function"?n=>new dp(n,"An error occurred in Effect.tryPromise"):e.catch;return IT(function(n,o){let s=i=>ce(()=>{try{return Et(Pa(()=>r(i)))}catch(a){return ta(a)}});try{t(o).then(i=>n(q(i)),i=>n(s(i)))}catch(i){n(s(i))}},t.length!==0)},QP=e=>oe(t=>e(t.id)),YP=oe(q),XP=QP(q),IT=(function(){let e=yo({op:"Async",[St](r){let n=!1,o=!1,s=this.withSignal?new AbortController:void 0,i=this.register.call(r.cache.scheduler,a=>{n||(n=!0,o?r.evaluate(a):o=a)},s?.signal);return o!==!1?o:(o=!0,r._yielded=()=>{n=!0},s===void 0&&i===void 0?Vc:(r._stack.push(PV(()=>(n=!0,s?.abort(),i??hn))),Vc))}}),t=function(r,n){this.register=r,this.withSignal=n};return t.prototype=e,function(r,n){return new t(r,n)}})(),PV=Uo({op:"AsyncFinalizer",[Wc](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Ep))},[go](e,t){return og(e)?Y(XM(Pr(e),this[Se]()),()=>Ye(e)):Ye(e)}}),Lt=e=>IT(e,e.length>=2),mp=Lt(Rr),eM=(...e)=>{if(e.length===1){let n=e[0];return ce(()=>nu(n()))}let[t,r]=e;return ce(()=>nu(r.call(t.self)))},TT=(e,...t)=>{let r=t.length===0?function(){return ce(()=>nu(e.apply(this,arguments)))}:function(){let n=ce(()=>nu(e.apply(this,arguments)));for(let o=0;o<t.length;o++)n=t[o](n,...arguments);return n};return wT(e.length,r)},wT=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),AP=XI(2),tM=function(){let e=typeof arguments[0]=="string",t=e?arguments[0]:"Effect.fn",r=e?arguments[1]:void 0,n=Ir(),o;return n!==0&&(yt(2),o=new globalThis.Error,yt(n)),e?(s,...i)=>kP(t,s,o,i,e,r):kP(t,arguments[0],o,Array.prototype.slice.call(arguments,1),e,r)},kP=(e,t,r,n,o,s)=>{let i=typeof t=="function"?t:n.shift().bind(t.self),a=`${e} (definition)`,c=r?AP(()=>r.stack):po;return wT(i.length,function(...u){let f=ce(()=>{let h=i.apply(this,arguments);return ge(h)?h:nu(h)});for(let h=0;h<n.length;h++)f=n[h](f,...u);if(!ge(f))return f;let p=Ir(),m;return p!==0&&(yt(2),m=new globalThis.Error,yt(p)),na(o?lp(e,s,h=>cT(f,h)):f,$f,h=>({name:e,stack:m?AP(()=>m.stack):po,parent:{name:a,stack:c,parent:h}}))})},rM=(e,...t)=>wT(e.length,t.length===0?function(){return RP(()=>e.apply(this,arguments))}:function(){let r=RP(()=>e.apply(this,arguments));for(let n of t)r=n(r,...arguments);return r}),RP=e=>{try{let t=e(),r;for(;;){let n=t.next(r);if(n.done)return q(n.value);let o=n.value;if(o&&o._tag==="Success"){r=o.value;continue}else{if(o&&o._tag==="Failure")return n.value;{let s=!0;return ce(()=>s?(s=!1,Y(n.value,i=>nu(t,i))):ce(()=>nu(e())))}}}}catch(t){return ta(t)}},nu=(function(){let e=yo({op:"Iterator",[mr](r,n){let o=this.iterator;for(;;){let s=o.next(r);if(s.done)return q(s.value);if(Xe(s.value)){if(s.value._tag==="Failure")return s.value}else return n._stack.push(this),s.value;r=s.value.value}},[St](r){return this[mr](this.initial,r)}}),t=function(r,n){this.iterator=r,this.initial=n};return t.prototype=e,function(r,n){return new t(r,n)}})(),Zr=d(2,(e,t)=>new ra(e,vT,q(t))),lg=function(e){return e._stack.push(this),this[Se]},MV=yo({op:"OnSuccess",[St]:lg}),ra=function(e,t,r){this[Se]=e,this[mr]=t,this.payload=r};ra.prototype=MV;var vT=function(){return this.payload},nM=function(e,t){return t.succeedWith(this.payload)},dg=(()=>{let e=Ir();if(e===0)return!1;let t="~effect/Effect/stackProbe",r={[t]:function(){return new Error}};yt(1);let n=r[t]();return yt(e),n.stack?.includes("[as "+t+"]")===!0})(),FV=function(e,t){let r=this.payload;return t.succeedWith(dg?r(e):Pa(()=>r(e)))},oM=function(e){let t=this.payload;return t(e)},NV=function(e){let t=this.payload;return new ra(t(e),nM,e)},UV=function(e){return new ra(this.payload,nM,e)},Wf=e=>_e(e,N),sM=e=>Gf(e,{onFailure:q,onSuccess:Et}),bo=d(2,(e,t)=>new ra(e,ge(t)?vT:oM,t)),pi=d(2,(e,t)=>new ra(e,ge(t)?UV:NV,t)),hp=e=>new ra(e,vT,hn),iM=e=>Mn(e,Et),CT=(e,t)=>oe(r=>{let n=new Set;return Wa(r,()=>n.size===0?void 0:Hf(n)),Lt(o=>{let s=vt(e),i=s.length,a=0,c=!1,u=[],f=(p,m,h)=>{if(a++,p._tag==="Failure"){u.push(...p.cause.reasons),a>=i&&o(Ye(zi(u)));return}let x=!c;c=!0,o(p),x&&t?.onWinner&&t.onWinner({fiber:m,index:h,parentFiber:r})};for(let p=0;p<i;p++){let m=iu(r,s[p],!0,!0,!1);if(n.add(m),m.addObserver(h=>{n.delete(m),f(h,m,p)}),c)break}})}),AT=(e,t)=>oe(r=>{let n=new Set;return Wa(r,()=>n.size===0?void 0:Hf(n)),Lt(o=>{let s=!1,i=0;for(let a of e){if(s)break;let c=i++,u=iu(r,a,!0,!0,!1);n.add(u),u.addObserver(f=>{n.delete(u);let p=!s;s=!0,o(f),p&&t?.onWinner&&t.onWinner({fiber:u,index:c,parentFiber:r})})}})}),aM=d(e=>ge(e[1]),(e,t,r)=>CT([e,t],r)),kT=d(e=>ge(e[1]),(e,t,r)=>AT([e,t],r)),Y=d(2,(e,t)=>new ra(e,oM,t)),cM=d(2,(e,t)=>Xe(e)?e._tag==="Success"?t.onSuccess(e.value):t.onFailure(e.cause):di(e,t)),Xe=e=>e[zc]!==void 0,uM=d(2,(e,t)=>Xe(e)?e._tag==="Success"?t(e.value):e:Y(e,t)),fM=e=>Y(e,F),_e=d(2,(e,t)=>new ra(e,FV,t)),lM=d(2,(e,t)=>Xe(e)?gM(e,t):_e(e,t)),dM=d(2,(e,t)=>Xe(e)?yM(e,t):UT(e,t)),pM=d(2,(e,t)=>Xe(e)?SM(e,t):DT(e,t)),mM=d(2,(e,t)=>{if(Xe(e)){if(e._tag==="Success")return e;let r=qo(e.cause);return be(r)?e:t(r.success)}return Es(e,t)}),Kf=e=>Pr($a(e)),Vf=e=>e._tag==="Success";var hM=e=>e._tag==="Failure";var xM=e=>e._tag==="Failure"?X(e.cause):re(e);var RT=e=>e._tag==="Failure"&&og(e.cause);var hn=ze(void 0),gM=d(2,(e,t)=>e._tag==="Success"?ze(t(e.value)):e),yM=d(2,(e,t)=>{if(e._tag==="Success")return e;let r=qo(e.cause);return be(r)?e:So(t(r.success))}),SM=d(2,(e,t)=>{if(e._tag==="Success")return ze(t.onSuccess(e.value));let r=qo(e.cause);return be(r)?e:So(t.onFailure(r.success))});var bM=d(2,(e,t)=>Vf(e)?t:e),EM=d(2,(e,t)=>Vf(e)?t.onSuccess(e.value):t.onFailure(e.cause));var OT=e=>{let t=[];for(let r of e)r._tag==="Failure"&&t.push(...r.cause.reasons);return t.length===0?hn:Pr(zi(t))};var IM=e=>e,TM=e=>oe(t=>q(_x(t.context,e))),DV=e=>oe(t=>yT(_x(t.context,e))),Jf=d(2,(e,t)=>oe(r=>{let n=r.context,o=t(n);return n===o||(r.setContext(o),Wa(r,()=>{r.setContext(n)})),e})),na=d(3,(e,t,r)=>Jf(e,n=>{let o=dn(n,t),s=r(o);return o===s?n:We(n,t,s)})),wM=(e,t,r)=>su(oe(n=>{let o=dn(n.context,e),s=t(o);return n.setContext(We(n.context,e,s)),qa(dn(n.context,ja),i=>{let a=_x(n.context,e);if(fe(a))return pe;let c=a.value,u;if(r?.reset===void 0){if(c!==s)return pe;u=o}else u=r.reset(o,s,c);return n.setContext(We(n.context,e,u)),pe})})),_T=()=>LV,LV=oe(e=>q(e.context)),Ha=e=>oe(t=>e(t.context)),vM=d(2,(e,t)=>Jf(e,qe(t))),Eo=d(2,(e,t)=>Xe(e)?e:Jf(e,Kr(t))),Pn=function(){return arguments.length===1?d(2,(e,t)=>OP(e,arguments[0],t)):d(3,(e,t,r)=>OP(e,t,r)).apply(this,arguments)},OP=(e,t,r)=>Jf(e,We(t,r)),pg=d(3,(e,t,r)=>Y(r,n=>Pn(e,t,n))),CM=d(e=>ge(e[1]),(e,t,r)=>PT(e,t,(n,o)=>[n,o],r)),PT=d(e=>ge(e[1]),(e,t,r,n)=>n?.concurrent?_e(el([e,t],{concurrency:2}),([o,s])=>r(o,s)):Y(e,o=>_e(t,s=>r(o,s)))),AM=d(e=>ge(e[0]),(e,t,r)=>JT(e,t,r?n=>Et(r(n)):()=>Et(new ms))),kM=d(2,(e,t)=>Y(t,r=>r?Wf(e):ou)),MT=d(2,(e,t)=>Array.from({length:t},()=>e)),RM=d(e=>ge(e[0]),(e,t,r)=>el(MT(e,t),r)),mg=d(e=>ge(e[0]),(e,t)=>mi({while:nr,body:qe(t?.disableYield?e:Y(e,r=>zf)),step:Rr})),Mn=d(2,(e,t)=>new OM(e,t.length!==1?r=>t(r):t)),BV=yo({op:"OnFailure",[St]:lg}),OM=function(e,t){this[Se]=e,this[go]=t};OM.prototype=BV;var FT=d(3,(e,t,r)=>Mn(e,n=>t(n)?r(n):Ye(n))),oa=d(3,(e,t,r)=>Mn(e,n=>{let o=t(n);return be(o)?Ye(o.failure):r(o.success,n)})),Es=d(2,(e,t)=>oa(e,qo,r=>t(r))),_M=e=>Gf(e,{onFailure:t=>xI(t)?ou:Et(t),onSuccess:bT}),PM=d(2,(e,t)=>oa(e,ng,t)),MM=d(2,(e,t)=>Mn(e,r=>bo(t(r),Ye(r)))),FM=d(3,(e,t,r)=>FT(e,t,n=>bo(r(n),Ye(n)))),hg=d(3,(e,t,r)=>Mn(e,n=>{let o=t(n);return be(o)?Ye(n):bo(r(o.success,n),Ye(n))})),NT=d(2,(e,t)=>hg(e,qo,r=>t(r))),NM=d(3,(e,t,r)=>{let n=Array.isArray(t)?o=>O(o,"_tag")&&t.includes(o._tag):Or(t);return NT(e,o=>n(o)?r(o):pe)}),UM=d(2,(e,t)=>hg(e,ng,r=>t(r))),xp=d(e=>ge(e[0]),(e,t,r,n)=>Mn(e,o=>{let s=qo(o);return be(s)?Ye(s.failure):t(s.success)?r(s.success):n?n(s.success):Ye(o)})),xg=d(e=>ge(e[0]),(e,t,r,n)=>Mn(e,o=>{let s=qo(o);if(be(s))return Ye(s.failure);let i=t(s.success);return be(i)?n?n(i.failure):Ye(o):r(i.success)})),gg=d(e=>ge(e[0]),(e,t,r,n)=>{let o=Array.isArray(t)?s=>O(s,"_tag")&&t.includes(s._tag):Or(t);return xp(e,o,r,n)}),DM=d(e=>ge(e[0]),(e,t,r)=>{let n;return xg(e,o=>(n??=Object.keys(t),O(o,"_tag")&&On(o._tag)&&n.includes(o._tag)?X(o):re(o)),o=>t[o._tag](o),r)}),LM=d(e=>ge(e[0]),(e,t,r,n,o)=>xp(e,s=>Or(s,t)&&O(s,"reason")&&(o!==void 0||Or(s.reason,r)),s=>{let i=s.reason;return Or(i,r)?n(i,s):o?o(i,s):Et(s)})),BM=d(e=>ge(e[0]),(e,t,r,n)=>{let o;return xp(e,s=>Or(s,t)&&O(s,"reason")&&O(s.reason,"_tag")&&On(s.reason._tag)&&(n!==void 0||(o??=Object.keys(r)).includes(s.reason._tag)),s=>{let i=s.reason;return o??=Object.keys(r),o.includes(i._tag)?r[i._tag](i,s):n?n(i,s):Et(s)})}),$M=d(2,(e,t)=>xg(e,r=>Or(r,t)&&O(r,"reason")?X(r.reason):re(r),Et)),UT=d(2,(e,t)=>Es(e,r=>fg(()=>t(r)))),DT=d(2,(e,t)=>Gf(e,{onFailure:r=>fg(()=>t.onFailure(r)),onSuccess:r=>ye(()=>t.onSuccess(r))})),yg=e=>Es(e,ta),HM=d(2,(e,t)=>Es(e,r=>ye(()=>t(r)))),jM=e=>ce(()=>{let t=e[Symbol.iterator](),r=t.next();if(r.done)return ta(new Error("Received an empty collection of effects"));function n(o){let s=t.next();return s.done?o.value:Es(o.value,i=>n(s))}return n(r)}),LT=e=>Es(e,t=>Y(zf,()=>LT(e))),qM=d(e=>ge(e[0]),(e,t)=>{if(!t?.log)return Gf(e,{onFailure:n=>pe,onSuccess:n=>pe});let r=Ts(t.log===!0?void 0:t.log);return di(e,{onFailure(n){let o=NP(n);return be(o)?Ye(o.failure):t.message===void 0?r(n):r(t.message,n)},onSuccess:n=>pe})}),Sg=d(e=>ge(e[0]),(e,t)=>{if(!t?.log)return di(e,{onFailure:n=>pe,onSuccess:n=>pe});let r=Ts(t.log===!0?void 0:t.log);return di(e,{onFailure:n=>t.message===void 0?r(n):r(t.message,n),onSuccess:n=>pe})}),zM=e=>bg(e,{onFailure:_,onSuccess:N}),Ba=e=>gp(e,{onFailure:re,onSuccess:X}),di=d(2,(e,t)=>new WM(e,t.onSuccess.length!==1?r=>t.onSuccess(r):t.onSuccess,t.onFailure.length!==1?r=>t.onFailure(r):t.onFailure)),$V=yo({op:"OnSuccessAndFailure",[St]:lg}),WM=function(e,t,r){this[Se]=e,this[mr]=t,this[go]=r};WM.prototype=$V;var HV=function(e,t){let r=this.payload;return t.succeedWith(dg?r.onSuccess(e):Pa(()=>r.onSuccess(e)))},KM=(e,t)=>{let r=yo({op:e,[St]:lg,[mr]:HV,[go]:t}),n=function(o,s){this[Se]=o,this.payload=s};return n.prototype=r,n},jV=KM("Match",function(e,t){let r=e.reasons.find(hs);if(r===void 0)return Ye(e);let n=this.payload;return t.succeedWith(dg?n.onFailure(r.error):Pa(()=>n.onFailure(r.error)))}),qV=KM("MatchCause",function(e,t){let r=this.payload;return t.succeedWith(dg?r.onFailure(e):Pa(()=>r.onFailure(e)))}),BT=d(2,(e,t)=>new qV(e,t)),Gf=d(2,(e,t)=>di(e,{onFailure:r=>{let n=r.reasons.find(hs);return n?t.onFailure(n.error):Ye(r)},onSuccess:t.onSuccess})),bg=d(2,(e,t)=>new jV(e,t)),gp=d(2,(e,t)=>{if(Xe(e)){if(e._tag==="Success")return ze(t.onSuccess(e.value));let r=qo(e.cause);return be(r)?e:ze(t.onFailure(r.success))}return bg(e,t)}),VM=d(2,(e,t)=>Xe(e)?e._tag==="Success"?ze(t.onSuccess(e.value)):ze(t.onFailure(e.cause)):BT(e,t)),yp=e=>Xe(e)?ze(e):zV(e),zV=Uo({op:"Exit",[St](e){return e._stack.push(this),this[Se]},[mr](e,t,r){return t.succeedWith(r??ze(e))},[go](e,t,r){return t.succeedWith(r??Pr(e))}}),JM=gp({onFailure:()=>!0,onSuccess:()=>!1}),GM=gp({onFailure:()=>!1,onSuccess:()=>!0}),ZM=d(2,(e,t)=>bo(tl(t),e)),$T=d(2,(e,t)=>Y(HT(e,t.duration),r=>fe(r)?t.orElse():q(r.value))),WV=e=>new Xx(`Operation timed out after '${$I(e)}'`),QM=d(2,(e,t)=>{let r=$e(t);return $T(e,{duration:r,orElse:()=>Et(WV(r))})}),HT=d(2,(e,t)=>kT(Wf(e),Zr(tl(t),_()))),YM=e=>Is(t=>{let r=t.monotonicTimeNanosUnsafe();return _e(e,n=>[$o(t.monotonicTimeNanosUnsafe()-r),n])}),oT="~effect/Scope",sT="~effect/Scope/Closeable",ja=Ue("effect/Scope"),jT=(e,t)=>oe(r=>(GV(r),Zf(e,t)??pe)),Zf=(e,t)=>{let r=e.state;if(r._tag==="Closed"||(e.state={_tag:"Closed",exit:t},e.parent!==void 0&&Qx(e.parent,e),r._tag==="Empty"))return;if(r.finalizer!==void 0)return Zx(r.finalizer,t);let n=r.finalizers;return n.size===1?Zx(n.values().next().value,t):KV(e,n,t)},Zx=(e,t)=>{try{return e(t)}catch(r){return ln(r)}},XM=(e,t)=>Vf(e)?t:Mn(t,r=>Ye(kf(e.cause,r))),KV=TT(function*(e,t,r){let n=[],o=[],s=Array.from(t.values()),i=ea();for(let a=s.length-1;a>=0;a--){let c=s[a];e.strategy==="sequential"?n.push(yield*yp(Zx(c,r))):o.push(iu(i,Zx(c,r),!0,!0,"inherit"))}return o.length>0&&(n=yield*ug(o)),yield*OT(n)});var eF=(e,t)=>{let r=rF(t,e);return e.state._tag==="Closed"?(r.state=e.state,r):(za(e,r,n=>jT(r,n)),r)},qa=(e,t)=>ce(()=>e.state._tag==="Closed"?t(e.state.exit):(za(e,{},t),pe)),tF=(e,t)=>qa(e,qe(t)),za=(e,t,r)=>{if(e.state._tag==="Empty")e.state={_tag:"Open",finalizerKey:t,finalizer:r,finalizers:void 0};else if(e.state._tag==="Open"){let n=e.state;n.finalizer!==void 0&&(n.finalizers=new Map([[n.finalizerKey,n.finalizer]]),n.finalizerKey=void 0,n.finalizer=void 0),n.finalizers.set(t,r)}},Qx=(e,t)=>{if(e.state._tag!=="Open")return;let r=e.state;r.finalizerKey===t?e.state=iT:r.finalizers!==void 0&&(r.finalizers.delete(t),r.finalizers.size===0&&(e.state=iT))},Qf=e=>rF(e,void 0),rF=(e="sequential",t)=>({[sT]:sT,[oT]:oT,strategy:e,parent:t,state:iT}),iT={_tag:"Empty"};var Sp=ja,nF=Pn(ja),Eg=e=>oe(t=>{let r=t.context,n=Qf();return t.setContext(We(t.context,ja,n)),Wa(t,o=>(t.setContext(r),Zf(n,o))),e});var Ig=e=>ce(()=>{let t=Qf();return To(e(t),r=>ce(()=>Zf(t,r)??pe))}),Tg=(e,t,r)=>Ha(n=>Jn(o=>Y(Sp,s=>pi(r?.interruptible?o(e):e,i=>qa(s,a=>Eo(t(i,a),n)))))),Yf=e=>Y(Sp,t=>Ha(r=>qa(t,n=>Eo(e(n),r)))),oF=(function(){let e=yo({op:"OnExit",[St](r){return r._stack.push(this),this.effect},[Wc](r){r.interruptible&&this.interruptible!==!0&&(r._stack.push(Ep),r.interruptible=!1)},[mr](r,n,o){o??=ze(r);let s;try{s=this.onExit(o)}catch(i){s=ln(i)}return s?Y(s,i=>o):o},[go](r,n,o){o??=Pr(r);let s;try{s=this.onExit(o)}catch(i){s=ln(i)}return s?Y(XM(o,s),i=>o):o}}),t=function(r,n,o){this.effect=r,this.onExit=n,this.interruptible=o};return t.prototype=e,t})(),Io=(e,t,r)=>new oF(e,t,r),Wa=(e,t)=>{e._stack.push(new oF(void 0,t,void 0))},To=d(2,Io),sF=d(2,(e,t)=>To(e,r=>t)),qT=d(3,(e,t,r)=>To(e,n=>t(n)?r(n):pe)),zT=d(3,(e,t,r)=>To(e,n=>{let o=t(n);return be(o)?pe:r(o.success,n)})),bp=d(2,(e,t)=>zT(e,xM,t)),iF=d(3,(e,t,r)=>qT(e,n=>n._tag!=="Failure"?!1:t(n.cause),n=>r(n.cause))),WT=d(3,(e,t,r)=>To(e,n=>{if(n._tag!=="Failure")return pe;let o=t(n.cause);return be(o)?pe:r(o.success,n.cause)})),aF=d(2,(e,t)=>WT(hT,t)(e)),cF=(e,t,r)=>Jn(n=>Y(e,o=>Io(ce(()=>n(t(o))),s=>r(o,s),!0))),uF=e=>Tg(e,t=>O(t,Symbol.asyncDispose)?ET(()=>t[Symbol.asyncDispose]()):ye(()=>t[Symbol.dispose]())),KT=d(2,(e,t)=>ye(()=>fF(e,typeof t=="function"?r=>zt($e(t(r))):qe(zt($e(t)))))),VV=qe(1/0),fF=(e,t)=>{let r=0,n,o,s=(i,a)=>(a.awaiters++,Wa(i,()=>{if(!(--a.awaiters>0||o!==a))return o=void 0,pp(a.fiber)}),Gx(a.fiber));return[oe(i=>{if(o!==void 0)return i===o.fiber?Gx(o.fiber):s(i,o);if(n!==void 0&&(r===1/0||i.getRef(Vn).currentTimeMillisUnsafe()<r))return n;n=void 0;let a=i.getRef(Vn),c={fiber:new fp(i.context),awaiters:0};o=c;let u=s(i,c);return c.fiber.evaluate(Io(e,f=>{if(o!==c||(o=void 0,RT(f)))return;let p=t(f);r=p===1/0?1/0:a.currentTimeMillisUnsafe()+p,n=f})),c.fiber._exit??u}),ye(()=>{n=void 0})]},lF=d(2,(e,t)=>_e(KT(e,t),r=>r[0])),dF=e=>ye(()=>fF(e,VV)[0]),Xf=oe(e=>Ye($a(e.id))),su=e=>oe(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(Ep)),e)),pF=Uo({op:"SetInterruptible",[Wc](e){if(e.interruptible=this[Se],e._interruptedCause&&e.interruptible)return()=>Ye(e._interruptedCause)}}),Ep=pF(!0),JV=pF(!1),mF=e=>{if(e.interruptible=!0,e._stack.push(JV),e._interruptedCause)return Ye(e._interruptedCause)},GV=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(Ep))};var wg=e=>oe(t=>t.interruptible?e:mF(t)??e),Jn=e=>oe(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Ep),e(wg)):e(F)),hF=e=>oe(t=>{if(t.interruptible)return e(F);let r=mF(t),n=e(su);return r??n}),xF=_e(Tg(ye(()=>new AbortController),e=>ye(()=>e.abort())),e=>e.signal),el=(e,t)=>ti(e)?t?.mode==="result"?Kn(e,Ba,t):Kn(e,F,t):t?.discard?t.mode==="result"?Kn(Object.values(e),Ba,t):Kn(Object.values(e),F,t):ce(()=>{let r={};return Zr(Kn(Object.entries(e),([n,o])=>_e(t?.mode==="result"?Ba(o):o,s=>{B(r,n,s)}),{discard:!0,concurrency:t?.concurrency}),r)}),VT=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>_e(Kn(e,(n,o)=>Ba(t(n,o)),r),n=>UI(n,F))),gF=d(3,(e,t,r)=>{let n=vt(e);return n.length===0?ye(t):ce(()=>{let o=0,s=t();return _e(mi({while:()=>o<n.length,body:()=>r(s,n[o],o),step(i){s=i,o++}}),()=>s)})}),yF=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>Y(VT(e,t,{concurrency:r?.concurrency}),([n,o])=>Jr(o)?Et(o):r?.discard?pe:q(n))),SF=d(e=>ti(e[0])&&!ge(e[0]),(e,t)=>ce(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?q(_()):bF(r,0,t,n.value)})),bF=(e,t,r,n)=>Y(r(n,t),o=>{if(o)return q(N(n));let s=e.next();return s.done?q(_()):bF(e,t+1,r,s.value)}),EF=d(e=>ti(e[0])&&!ge(e[0]),(e,t)=>ce(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?q(_()):IF(r,0,t,n.value)})),IF=(e,t,r,n)=>Y(r(n,t),o=>{if(tt(o))return q(N(o.success));let s=e.next();return s.done?q(_()):IF(e,t+1,r,s.value)}),mi=Uo({op:"While",[mr](e,t){return this[Se].step(e),this[Se].while()?(t._stack.push(this),this[Se].body()):hn},[St](e){return this[Se].while()?(e._stack.push(this),this[Se].body()):hn}}),Kn=d(e=>typeof e[1]=="function",(e,t,r)=>ce(()=>{let n=Ip(r?.concurrency);if(n===1)return ZV(e,t,r);let o=vt(e),s=o.length;if(s===0)return r?.discard?pe:q([]);let i=r?.discard?void 0:new Array(s),a=QV({f:t,out:i},o,{concurrency:n});return a?Zr(a,i):q(i)})),TF=e=>Y(e,t=>{let r=t[Symbol.iterator]().next();return r.done?Et(new ms):q(r.value)}),ZV=(e,t,r)=>ce(()=>{let n=r?.discard?void 0:[],o=e[Symbol.iterator](),s=o.next(),i=0;return Zr(mi({while:()=>!s.done,body:()=>t(s.value,i++),step:a=>{n&&n.push(a),s=o.next()}}),n)}),Ip=e=>e==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,e??1),vg=()=>e=>{let t=e.onItem,r=e.step,n=(s,i,a,c,u)=>Y(yp(u),f=>r(s,i[a],f,a)??o(s,i,a+1,c)??pe),o=(s,i,a=0,c=i.length)=>{for(;a<c;a++){let u=i[a],f=t(s,u,a);if(!Xe(f))return n(s,i,a,c,f);let p=r(s,u,f,a);if(p)return p._tag==="Failure"?p:void 0}};return o},wF=e=>{let t=e.onItem,r=e.step;return(n,o,s)=>{let i=0,a=s.end??o.length,c=s.concurrency,u=!1,f,p,m,h,x,g=E=>{let b=ln(E);return h=b,u=!0,p&&p.size>0?Y(su(Hf(Array.from(p))),()=>h??b):b},y=()=>{let E=!1;for(;!h&&i<a;i++){let b=o[i],v=x??t(n,b,i);if(Xe(v)){if(h=r(n,b,v,i),h)break}else if(f){x=void 0;let T=iu(f,v,!0,!0,"inherit");if(T._exit){if(h=r(n,b,T._exit,i),h)break;continue}p.add(T);let S=i;if(T.addObserver(w=>{p.delete(T);try{if(h){if(w._tag==="Failure"){let k=w.cause.reasons.filter(C=>C._tag!=="Interrupt");if(k.length>0){let C=zi(k);h=Pr(h._tag==="Failure"?kf(h.cause,C):C)}}}else{let k=r(n,b,w,S);k&&(h=k,y())}if(E){let k=y();k&&m(k)}else u&&p.size===0&&m(h??pe)}catch(k){m(g(k))}}),p.size<c)continue;E=!0,i++;return}else return Lt(T=>{f=ea(),p=new Set,x=v,m=T;let S;try{S=y()}catch(w){return T(g(w))}return S?T(S):ce(()=>(h??=hn,Y(p?Hf(p):pe,()=>h?._tag==="Failure"?h:pe)))})}if(u=!0,h){if(p&&p.size>0){let b=cg(f);p.forEach(v=>v.interruptUnsafe(f.id,b));return}if(m||h._tag==="Failure")return h}else if(m)if(p)p.size===0&&m(pe);else return hn};return y()}},Cg=()=>e=>wF(e),QV=wF({onItem(e,t,r){return e.f(t,r)},step(e,t,r,n){if(r._tag==="Failure")return r;e.out&&(e.out[n]=r.value)}}),JT=d(3,(e,t,r)=>Y(e,n=>t(n)?q(n):r(n))),GT=d(3,(e,t,r)=>Y(e,n=>{let o=t(n);return be(o)?r(o.failure):q(o.success)})),vF=d(e=>ge(e[0]),(e,t,r)=>GT(e,t,r?n=>Et(r(n)):()=>Et(new ms))),CF=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>ce(()=>{let n=[];return Zr(Kn(e,(o,s)=>{let i=t(o,s);return typeof i=="boolean"?(i&&n.push(o),pe):_e(i,a=>{a&&n.push(o)})},{discard:!0,concurrency:r?.concurrency}),n)})),AF=d(e=>ti(e[0])&&!ge(e[0]),(e,t)=>ce(()=>{let r=[];for(let n of e){let o=t(n);tt(o)&&r.push(o.success)}return q(r)})),kF=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>ce(()=>{let n=[];return Zr(Kn(e,o=>_e(t(o),s=>{tt(s)&&n.push(s.success)}),{discard:!0,concurrency:r?.concurrency}),n)})),RF=q({}),OF=Tx(_e),_F=wx(_e,Y),PF=Ix(_e);var MF=d(e=>ge(e[0]),(e,t)=>oe(r=>(pJ(),q(iu(r,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),iu=(e,t,r=!1,n=!1,o=!1)=>{let s=e,i=o==="inherit"?s.interruptible:!o,a=new fp(s.context,i);return n||(s.children().add(a),a._parent=s),r?a.evaluate(t):(a._asyncContext=qP(),s.currentDispatcher.scheduleTask(()=>a.evaluate(t),0)),a},FF=d(e=>ge(e[0]),(e,t)=>oe(r=>q(iu(r,e,t?.startImmediately,!0,t?.uninterruptible)))),NF=e=>oe(t=>{let r=t._children&&new Set(t._children),n=t.interruptible;return Io(e,o=>{let s=t._children;if(s===void 0||s.size===0)return pe;r&&(s=W_(s,a=>!r.has(a)));let i=hp(ug(s));return n?wg(i):i})}),ZT=d(e=>ge(e[0]),(e,t,r)=>oe(n=>{let o=iu(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed"){let s={};za(t,s,()=>QP(a=>a===o.id?pe:pp(o))),o.addObserver(()=>Qx(t,s))}else o.interruptUnsafe(n.id,cg(n));return q(o)})),UF=d(e=>ge(e[0]),(e,t)=>Y(Sp,r=>ZT(e,r,t))),sa=e=>(t,r)=>{let n=new fp(r?.scheduler?We(e,La,r.scheduler):e,r?.uninterruptible!==!0);if(n.evaluate(t),n._exit)return n;if(r?.signal)if(r.signal.aborted)n.interruptUnsafe();else{let o=()=>n.interruptUnsafe();r.signal.addEventListener("abort",o,{once:!0}),n.addObserver(()=>r.signal.removeEventListener("abort",o))}return r?.onFiberStart&&r.onFiberStart(n),n},DF=d(2,(e,t)=>e._exit?e:t.state._tag==="Closed"?(e.interruptUnsafe(e.id),e):(Qx(t,e),za(t,e,()=>pp(e)),e.addObserver(()=>Qx(t,e)),e)),LF=sa(pt()),QT=e=>{let t=sa(e);return(r,n)=>{let o=t(r,n);return n?.onExit&&o.addObserver(n.onExit),s=>o.interruptUnsafe(s)}},BF=QT(pt()),Ag=e=>{let t=sa(e);return(r,n)=>{let o=t(r,n);return new Promise(s=>{o.addObserver(i=>s(i))})}},$F=Ag(pt()),YT=e=>{let t=Ag(e);return(r,n)=>t(r,n).then(o=>{if(o._tag==="Failure")throw ig(o.cause);return o.value})},HF=YT(pt()),kg=e=>{let t=sa(e);return r=>{if(Xe(r))return r;let n=new fi("sync"),o=t(r,{scheduler:n});return o._dispatcher?.flush(),o._exit??ln(new rg(o))}},jF=kg(pt()),XT=e=>{let t=kg(e);return r=>{let n=t(r);if(n._tag==="Failure")throw ig(n.cause);return n.value}},qF=XT(pt()),_P=q(!0),PP=q(!1),aT=class{waiters=[];scheduled=void 0;_isOpen;constructor(t){this._isOpen=t}scheduleUnsafe(t){if(this.waiters.length===0)return _P;if(this.scheduled===void 0)this.scheduled=this.waiters,t.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let r=0;r<this.waiters.length;r++)this.scheduled.push(this.waiters[r]);return this.waiters=[],_P}flushScheduled=()=>{if(this.scheduled===void 0)return;let t=this.scheduled;this.scheduled=void 0;for(let r=0;r<t.length;r++)t[r](hn)};flushWaiters(){let t=this.waiters;this.waiters=[],this.flushScheduled();for(let r=0;r<t.length;r++)t[r](hn)}open=oe(t=>this._isOpen?PP:(this._isOpen=!0,this.scheduleUnsafe(t)));release=oe(t=>this._isOpen?PP:this.scheduleUnsafe(t));openUnsafe(){return this._isOpen?!1:(this._isOpen=!0,this.flushWaiters(),!0)}await=Lt(t=>this._isOpen?t(pe):(this.waiters.push(t),ye(()=>{let r=this.waiters.indexOf(t);r!==-1?this.waiters.splice(r,1):this.scheduled!==void 0&&(r=this.scheduled.indexOf(t),r!==-1&&this.scheduled.splice(r,1))})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=ye(()=>this.closeUnsafe());whenOpen=t=>Y(this.await,()=>t);isOpen(){return this._isOpen}},e0=e=>new aT(e??!1),zF=e=>ye(()=>e0(e)),WF=oe(e=>q(e.getRef(GI))),KF=d(2,(e,t)=>Pn(e,GI,t)),VF=Pn(Kx),JF=Pn(tu),Yx=BigInt(0),YV={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:Yx,endTime:Yx,exit:hn},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},XV=e=>Object.assign(Object.create(YV),e),GF=e=>e?Re(e.annotations,Bf)?e._tag==="Span"?GF(_n(e.parent)):_():N(e):_(),t0=(e,t,r)=>{let n=!e.cache.tracerEnabled||r?.annotations&&Re(r.annotations,Bf),o=r?.parent!==void 0?N(r.parent):r?.root?_():GF(e.cache.span),s;if(n)s=XV({name:t,parent:o,annotations:We(r?.annotations??pt(),Bf,!0)});else{let i=e.cache.tracer??ZI,a=e.getRef(Vn),c=e.getRef(tu),u=e.getRef(cp),f=e.getRef(up),p=r?.level??e.getRef(EP),m=r?.links!==void 0?[...f,...r.links]:f.length===0?[]:f.slice();s=i.span({name:t,parent:o,annotations:r?.annotations??pt(),links:m,startTime:c?a.currentTimeNanosUnsafe():Yx,kind:r?.kind??"internal",root:r?.root??!1,sampled:r?.sampled??(de(o)&&o.value.sampled===!1?!1:!cN(e.getRef(IP),p))});for(let h in u)s.attribute(h,u[h]);if(r?.attributes!==void 0)for(let h in r.attributes)s.attribute(h,r.attributes[h])}return s},ZF=(e,t)=>oe(r=>q(t0(r,e,t))),bs=(e,t)=>su(oe(r=>{let n=dn(r.context,ja),o=t0(r,e,t??{}),s=r.getRef(Vn),i=r.getRef(tu);return Zr(qa(n,a=>Rg(o,a,s,i)),o)})),QF=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=jo(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return Y(bs(t,r),o=>jf(n,o,r))}return n=>Y(bs(t,r),o=>jf(n,o,r))},eJ=(e,t)=>(t=typeof t=="function"?t:po,na($f,r=>({name:e,stack:t,parent:r}))),YF=cp,XF=up,eN=d(e=>ge(e[0]),(e,t,r={})=>{let o=(Array.isArray(t)?t:[t]).map(s=>({span:s,attributes:r}));return na(e,up,s=>[...s,...o])}),Rg=(e,t,r,n)=>ye(()=>{e.status._tag!=="Ended"&&e.end(n?r.currentTimeNanosUnsafe():Yx,t)}),lp=(e,...t)=>{let r=t.length===1?void 0:t[0],n=t[t.length-1];return oe(o=>{let s=t0(o,e,r),i=o.getRef(Vn),a=o.getRef(tu);return Wa(o,c=>Rg(s,c,i,a)),n(s)})},cT=Pn(li),jf=function(){let e=ge(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=F;return t._tag==="Span"&&(r=jo(r),n=eJ(t.name,r?.captureStackTrace)),e?cT(n(arguments[0]),t):o=>cT(n(o),t)},tN=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=jo(arguments[2]);if(e){let s=arguments[0];return lp(t,arguments[2],i=>jf(s,i,r))}let n=typeof arguments[1]=="function"?arguments[1]:void 0,o=n?void 0:arguments[1];return(s,...i)=>lp(t,n?n(...i):o,a=>jf(s,a,r))},rN=d(e=>ge(e[0]),(e,...t)=>na(e,cp,r=>{let n=t.length===1?{...r,...t[0]}:{...r};return t.length===1||B(n,t[0],t[1]),n})),nN=(...e)=>oe(t=>{let r=t.currentSpanLocal;if(r)if(e.length===1)for(let[n,o]of Object.entries(e[0]))r.attribute(n,o);else r.attribute(e[0],e[1]);return pe}),oN=oe(e=>{let t=e.currentSpanLocal;return t?q(t):Et(new ms)}),sN=DV(li),Vn=Ce("effect/Clock",{defaultValue:()=>new uT}),eT=2**31-1,uT=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=ye(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return tJ()}currentTimeNanos=ye(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return aN()}monotonicTimeNanos=ye(()=>this.monotonicTimeNanosUnsafe());sleep(t){return this.sleepMillis(zt(t))}sleepMillis(t){return t<=0?zf:Number.isFinite(t)?Lt(r=>{let n=t>eT?this.sleepMillis(t-eT):pe,o=setTimeout(()=>r(n),Math.min(t,eT));return ye(()=>clearTimeout(o))}):mp}},iN=BigInt(1e6),aN=(function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint=="function")return()=>e.bigint();if(typeof performance<"u"&&typeof performance.now=="function")return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let r=BigInt(Date.now())*iN;return r>t&&(t=r),t}})(),tJ=(function(){let e=BigInt(1e9),t;return()=>{let r=aN(),n=BigInt(Date.now())*iN;if(t===void 0)t=n-r;else{let o=t+r;(n>o?n-o:o-n)>e&&(t=n-r)}return t+r}})(),Is=e=>oe(t=>e(t.getRef(Vn))),tl=e=>Is(t=>t.sleep($e(e))),r0=Is(e=>e.currentTimeMillis);var fT="~effect/Cause/TimeoutError";var Xx=class extends Wi("TimeoutError"){[fT]=fT;constructor(t){super({message:t})}},lT="~effect/Cause/IllegalArgumentError";var eg=class extends Wi("IllegalArgumentError"){[lT]=lT;constructor(t){super({message:t})}},dT="~effect/Cause/ExceededCapacityError";var tg=class extends Wi("ExceededCapacityError"){[dT]=dT;constructor(t){super({message:t})}},pT="~effect/Cause/AsyncFiberError";var rg=class extends Wi("AsyncFiberError"){[pT]=pT;constructor(t){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:t})}},mT="~effect/Cause/UnknownError";var dp=class extends Wi("UnknownError"){[mT]=mT;constructor(t,r){super({message:r,cause:t})}},rJ=Ce("effect/Console",{defaultValue:()=>globalThis.console}),nJ=e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 5e4;case"Error":return 4e4;case"Warn":return 3e4;case"Info":return 2e4;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}},oJ=EI(Ki,nJ),cN=Zc(oJ),n0=Ce("effect/Logger/CurrentLoggers",{defaultValue:()=>new Set([lJ,dJ])}),sJ=Ce("effect/Logger/LogToStderr",{defaultValue:Oa}),uN=function(){let e=typeof arguments[0]=="string"?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return su(oe(t=>{let r=t.getRef(Xi),n={...r};for(let o=0;o<e.length;o++){let[s,i]=e[o];B(n,s,i)}return t.setContext(We(t.context,Xi,n)),qa(dn(t.context,ja),o=>{let s=t.getRef(Xi),i={...s};for(let a=0;a<e.length;a++){let[c,u]=e[a];s[c]!==u&&!Object.is(s[c],u)||(Object.hasOwn(r,c)?B(i,c,r[c]):delete i[c])}return t.setContext(We(t.context,Xi,i)),pe})}))},iJ="~effect/Logger",aJ={[iJ]:{_Message:F,_Output:F},pipe(){return V(this,arguments)}},fN=e=>{let t=Object.create(aJ);return t.log=e,t},cJ=e=>e.replace(/[\s="]/g,"_"),uJ=(e,t)=>`${cJ(e[0])}=${t-e[1]}ms`;var Ts=e=>(...t)=>{let r;for(let n=0,o=t.length;n<o;n++){let s=t[n];Af(s)&&(r?t.splice(n,1):t=t.slice(0,n).concat(t.slice(n+1)),r=r?zi(r.reasons.concat(s.reasons)):s,n--)}return r===void 0&&(r=pI),oe(n=>{let o=e??n.cache.logLevel;if(cN(n.cache.minimumLogLevel,o))return pe;let s=n.getRef(Vn),i=n.getRef(n0);if(i.size>0){let a=new Date(s.currentTimeMillisUnsafe());for(let c of i)c.log({cause:r,fiber:n,date:a,logLevel:o,message:t})}return pe})};var ru={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},Ule={None:[],All:[],Trace:[ru.gray],Debug:[ru.blue],Info:[ru.green],Warn:[ru.yellow],Error:[ru.red],Fatal:[ru.bgBrightRed,ru.black]};var fJ=e=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`;var lJ=fN(({cause:e,date:t,fiber:r,logLevel:n,message:o})=>{let s=Array.isArray(o)?o.slice():[o];e.reasons.length>0&&s.push(ag(e));let i=t.getTime(),a=r.getRef(Vx),c="";for(let m of a)c+=` ${uJ(m,i)}`;let u=r.getRef(Xi);Object.keys(u).length>0&&s.push(u);let f=r.getRef(rJ);(r.getRef(sJ)?f.error:f.log)(`[${fJ(t)}] ${n.toUpperCase()} (#${r.id})${c}:`,...s)}),dJ=fN(({cause:e,fiber:t,logLevel:r,message:n})=>{let o=t.getRef(Vn),s=t.getRef(Xi),i=t.cache.span;if(i===void 0||i._tag==="ExternalSpan")return;let a={};for(let[c,u]of Object.entries(s))B(a,c,u);a["effect.fiberId"]=t.id,a["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(a["effect.cause"]=ag(e)),i.event(QO(Array.isArray(n)&&n.length===1?n[0]:n),o.currentTimeNanosUnsafe(),a)});function pJ(){nT.interruptChildren??=_V}var Og=q(void 0);var lN=d(e=>ge(e[0]),(e,t)=>bp(e,r=>oe(n=>(mJ(n,r,t?.defectsOnly),pe)))),mJ=(e,t,r)=>{let n=e.getRef(wP);if(n.size===0||r&&!UP(t))return;let o={cause:t,fiber:e,timestamp:e.getRef(Vn).currentTimeNanosUnsafe()};n.forEach(s=>s.report(o))};var rl=Af,nl=e_,_g=hs;var au=zi;var dN=Rf,ol=mI,pN=$a,Tp=e=>new Kc(e),wp=e=>new zd(e),vp=MP,o0=sg,Ka=LP;var cu=ig,mN=FP;var sl=qo;var Cp=ng,il=og;var hN=DP;var xN=ag;var al=ms,Ap=n_;var gN=Jc,se=s_;var Pg=eg;var yN=tg;var ne={};ps(ne,{Do:()=>DG,Transaction:()=>pl,TypeId:()=>RG,abortSignal:()=>U8,acquireDisposable:()=>k8,acquireRelease:()=>Ti,acquireUseRelease:()=>HU,addFinalizer:()=>jU,all:()=>OG,andThen:()=>Kt,annotateCurrentSpan:()=>W8,annotateLogs:()=>uy,annotateLogsScoped:()=>hZ,annotateSpans:()=>z8,as:()=>Ot,asSome:()=>ry,asVoid:()=>vo,awaitAllChildren:()=>tZ,bind:()=>$G,bindTo:()=>LG,cached:()=>ay,cachedInvalidateWithTTL:()=>F8,cachedWithTTL:()=>M8,callback:()=>Nn,catch:()=>hu,catchCause:()=>rt,catchCauseFilter:()=>NU,catchCauseIf:()=>H0,catchDefect:()=>$0,catchEager:()=>fy,catchFilter:()=>e8,catchIf:()=>XG,catchNoSuchElement:()=>t8,catchReason:()=>ZG,catchReasons:()=>QG,catchTag:()=>MU,catchTags:()=>FU,clockWith:()=>yu,context:()=>Nr,contextWith:()=>yn,currentParentSpan:()=>V8,currentSpan:()=>K8,delay:()=>ca,die:()=>gn,effectify:()=>CZ,ensuring:()=>wi,eventually:()=>i8,exit:()=>eo,fail:()=>D,failCause:()=>He,failCauseSync:()=>aa,failSync:()=>ty,fiber:()=>rZ,fiberId:()=>nZ,filter:()=>W0,filterMap:()=>x8,filterMapEffect:()=>K0,filterMapOrElse:()=>g8,filterMapOrFail:()=>y8,filterOrElse:()=>LU,filterOrFail:()=>BU,findFirst:()=>FG,findFirstFilter:()=>NG,firstSuccessOf:()=>l8,flatMap:()=>A,flatMapEager:()=>ur,flatten:()=>L0,flip:()=>JG,fn:()=>aZ,fnUntraced:()=>me,fnUntracedEager:()=>ow,forEach:()=>Ko,forever:()=>_t,forkChild:()=>gl,forkDetach:()=>yl,forkIn:()=>gt,forkScoped:()=>Rs,fromNullishOr:()=>WG,fromOption:()=>qG,fromResult:()=>D0,gen:()=>xt,head:()=>UG,ignore:()=>oy,ignoreCause:()=>sy,interrupt:()=>Dn,interruptible:()=>vi,interruptibleMask:()=>N8,isEffect:()=>Yr,isFailure:()=>T8,isSuccess:()=>w8,let:()=>BG,linkSpans:()=>Z8,log:()=>cZ,logDebug:()=>dZ,logError:()=>Zp,logFatal:()=>uZ,logInfo:()=>lZ,logTrace:()=>pZ,logWarning:()=>fZ,logWithLevel:()=>Sl,makeSpan:()=>Y0,makeSpanScoped:()=>X0,map:()=>K,mapBoth:()=>r8,mapBothEager:()=>cr,mapEager:()=>Su,mapError:()=>ml,mapErrorEager:()=>bu,match:()=>V0,matchCause:()=>b8,matchCauseEager:()=>E8,matchCauseEffect:()=>Un,matchCauseEffectEager:()=>I8,matchEager:()=>S8,matchEffect:()=>$U,never:()=>Xn,onError:()=>to,onErrorFilter:()=>O8,onErrorIf:()=>R8,onExit:()=>Xr,onExitFilter:()=>P8,onExitIf:()=>_8,onExitPrimitive:()=>Vp,onInterrupt:()=>gu,option:()=>VG,orDie:()=>Ii,orElseSucceed:()=>f8,partition:()=>_G,promise:()=>jp,provide:()=>J0,provideContext:()=>Ur,provideService:()=>Go,provideServiceEffect:()=>A8,race:()=>h8,raceAll:()=>z0,raceAllFirst:()=>m8,raceFirst:()=>Ya,reduce:()=>PG,repeat:()=>qU,repeatOrElse:()=>D8,replicate:()=>L8,replicateEffect:()=>Q0,request:()=>X8,requestUnsafe:()=>eZ,result:()=>KG,retry:()=>ny,retryOrElse:()=>j0,runCallback:()=>oZ,runCallbackWith:()=>ew,runFork:()=>Gp,runForkWith:()=>Sr,runPromise:()=>tw,runPromiseExit:()=>cy,runPromiseExitWith:()=>sZ,runPromiseWith:()=>rw,runSync:()=>Ai,runSyncExit:()=>ki,runSyncExitWith:()=>iZ,runSyncWith:()=>nw,sandbox:()=>a8,satisfiesErrorType:()=>kZ,satisfiesServicesType:()=>RZ,satisfiesSuccessType:()=>AZ,schedule:()=>B8,scheduleFrom:()=>zU,scope:()=>Co,scoped:()=>ec,scopedWith:()=>hl,service:()=>G0,serviceOption:()=>xu,setContext:()=>v8,sleep:()=>ua,spanAnnotations:()=>J8,spanLinks:()=>G8,succeed:()=>I,succeedNone:()=>ia,succeedSome:()=>U0,suspend:()=>L,sync:()=>W,tap:()=>Rt,tapCause:()=>Kp,tapCauseFilter:()=>s8,tapCauseIf:()=>o8,tapDefect:()=>UU,tapError:()=>Wp,tapErrorTag:()=>n8,timed:()=>p8,timeout:()=>q0,timeoutOption:()=>d8,timeoutOrElse:()=>DU,tracer:()=>$8,track:()=>gZ,trackDefects:()=>bZ,trackDuration:()=>EZ,trackErrors:()=>SZ,trackSuccesses:()=>yZ,transposeOption:()=>zG,try:()=>Jo,tryPromise:()=>Vo,tx:()=>IZ,txRetry:()=>vZ,undefined:()=>qp,uninterruptible:()=>Ci,uninterruptibleMask:()=>en,unwrapReason:()=>YG,updateContext:()=>Xa,updateService:()=>Z0,updateServiceScoped:()=>C8,useSpan:()=>Jp,validate:()=>MG,void:()=>P,when:()=>iy,whileLoop:()=>xn,withErrorReporting:()=>u8,withExecutionPlan:()=>c8,withFiber:()=>ar,withFiberSucceed:()=>jG,withLogSpan:()=>xZ,withLogger:()=>mZ,withParentSpan:()=>xl,withSpan:()=>Q8,withSpanScoped:()=>Y8,withTracer:()=>H8,withTracerEnabled:()=>j8,withTracerTiming:()=>q8,yieldNow:()=>zp,yieldNowWith:()=>HG,zip:()=>B0,zipWith:()=>GG});var ws=Wd,Mr=ze,ir=Pr,Gn=So,Mg=ln,Fg=Kf,Wt=hn;var ft=Vf,vs=hM;var SN=RT;var bN=EM;var EN=OT;var Fn={};ps(Fn,{CurrentMemoMap:()=>fu,build:()=>NN,buildWithMemoMap:()=>gi,buildWithScope:()=>kp,catch:()=>_J,catchCause:()=>MJ,catchTag:()=>PJ,effect:()=>Qn,effectContext:()=>Ga,effectDiscard:()=>vJ,empty:()=>wJ,flatMap:()=>LN,forkMemoMap:()=>TJ,forkMemoMapUnsafe:()=>u0,fresh:()=>FJ,fromBuild:()=>Va,fromBuildMemo:()=>Hg,isLayer:()=>$g,launch:()=>NJ,makeMemoMap:()=>IJ,makeMemoMapUnsafe:()=>xi,merge:()=>AJ,mergeAll:()=>jg,mock:()=>UJ,orDie:()=>qg,parentSpan:()=>$N,provide:()=>As,provideMerge:()=>Rp,satisfiesErrorType:()=>BJ,satisfiesServicesType:()=>$J,satisfiesSuccessType:()=>LJ,span:()=>HJ,succeed:()=>Ja,succeedContext:()=>lu,suspend:()=>CJ,sync:()=>f0,syncContext:()=>i0,tap:()=>kJ,tapCause:()=>OJ,tapError:()=>RJ,unwrap:()=>a0,updateService:()=>BN,withParentSpan:()=>c0,withSpan:()=>jJ});var hJ="~effect/Deferred";var xJ={[hJ]:{_A:F,_E:F},pipe(){return V(this,arguments)}},IN=function(){this.resumes=void 0,this.effect=void 0};IN.prototype=xJ;var uu=()=>new IN;var Ng=e=>Lt(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),ye(()=>{let r=e.resumes;if(r===void 0)return;let n=r.indexOf(t);n>=0&&r.splice(n,1)})));var gJ=d(2,(e,t)=>ye(()=>hi(e,t))),yJ=gJ;var SJ=d(2,(e,t)=>yJ(e,Pr(t)));var s0=d(2,(e,t)=>SJ(e,$a(t)));var hi=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let r=e.resumes;e.resumes=void 0;for(let n=0;n<r.length;n++)r[n](t)}return!0};var TN=Xi;var wN=Vx,vN=$f;var Dg=tu,CN=vP;var it=ja;var Zn=Qf,zo=nF,Wo=qa,It=tF;var yr=eF,Ve=jT;var FN="~effect/Layer",kN="~effect/Layer/MemoMap",bJ=(e,t)=>{let r={observers:0,deferred:uu(),scope:Zn(),finalizer:n=>ce(()=>--r.observers>0?pe:(e.map.delete(t),Ve(r.scope,n)))};return r},RN=(e,t)=>t.state._tag==="Closed"?!1:(e.observers++,za(t,{},e.finalizer),!0),$g=e=>O(e,FN),EJ={[FN]:{_ROut:F,_E:F,_RIn:F},pipe(){return V(this,arguments)}},du=e=>{let t=Object.create(EJ);return t.build=e,t},Va=e=>du((t,r)=>{let n=yr(r);return To(e(t,n),o=>o._tag==="Failure"?Ve(n,o):pe)}),Hg=e=>{let t=Va((r,n)=>r.getOrElseMemoize(t,n,e));return t},Bg=class{get[kN](){return kN}parent;constructor(t){this.parent=t}map=new Map;get(t,r){let n=this.map.get(t);return n?(RN(n,r),n.deferred.effect??Ng(n.deferred)):this.parent?.get(t,r)}getOrElseMemoize(t,r,n){return ce(()=>{let o;return Io(ce(()=>{let s=this.get(t,r);if(s)return s;let i=bJ(this,t);return RN(i,r)?(o=i.deferred,this.map.set(t,i),n(this,i.scope)):n(this,r)}),s=>{o&&hi(o,s)})})}},xi=()=>new Bg,u0=e=>new Bg(e),IJ=ye(xi),TJ=e=>ye(()=>u0(e)),fu=class e extends Ue()("effect/Layer/CurrentMemoMap"){static forkOrCreate(t){let r=Vi(t,e);return r?u0(r):xi()}},gi=d(3,(e,t,r)=>Pn(_e(ce(()=>e.build(t,r)),We(fu,t)),fu,t)),NN=e=>oe(t=>gi(e,fu.forkOrCreate(t.context),dn(t.context,it))),kp=d(2,(e,t)=>oe(r=>gi(e,fu.forkOrCreate(r.context),t))),Ja=function(){return arguments.length===1?e=>lu(ys(arguments[0],e)):lu(ys(arguments[0],arguments[1]))},lu=e=>du(qe(q(e))),wJ=lu(pt()),f0=function(){return arguments.length===1?e=>i0(()=>ys(arguments[0],e())):i0(()=>ys(arguments[0],arguments[1]()))},i0=e=>Hg(qe(ye(e))),Qn=function(){return arguments.length===1?e=>ON(arguments[0],e):ON(arguments[0],arguments[1])},ON=(e,t)=>Ga(_e(t,r=>ys(e,r))),Ga=e=>Hg((t,r)=>zo(e,r)),vJ=e=>Ga(Zr(e,pt())),CJ=e=>Hg((t,r)=>ce(()=>e().build(t,r))),_N=Ue("effect/Layer/unwrap"),a0=e=>LN(Qn(_N)(e),Re(_N)),UN=(e,t,r)=>{let n=yr(r,"parallel");return Kn(e,o=>o.build(t,yr(n,"sequential")),{concurrency:e.length}).pipe(_e(o=>L_(...o)))},jg=(...e)=>Va((t,r)=>UN(e,t,r)),AJ=d(2,(e,t)=>jg(e,...Array.isArray(t)?t:[t])),DN=(e,t,r)=>Va((n,o)=>Y(Array.isArray(t)?UN(t,n,o):t.build(n,o),s=>e.build(n,o).pipe(Eo(s),_e(i=>r(i,s))))),As=d(2,(e,t)=>DN(e,t,F)),Rp=d(2,(e,t)=>DN(e,t,(r,n)=>Kr(n,r))),LN=d(2,(e,t)=>Va((r,n)=>Y(e.build(r,n),o=>t(o).build(r,n)))),kJ=d(2,(e,t)=>Va((r,n)=>Y(e.build(r,n),o=>zo(Zr(t(o),o),n)))),RJ=d(2,(e,t)=>Va((r,n)=>Es(e.build(r,n),o=>zo(bo(t(o),Et(o)),n)))),OJ=d(2,(e,t)=>Va((r,n)=>Mn(e.build(r,n),o=>zo(bo(t(o),Ye(o)),n)))),qg=e=>du((t,r)=>yg(e.build(t,r))),_J=d(2,(e,t)=>du((r,n)=>Es(e.build(r,n),o=>t(o).build(r,n))));var PJ=d(3,(e,t,r)=>du((n,o)=>gg(e.build(n,o),t,s=>r(s).build(n,o)))),MJ=d(2,(e,t)=>du((r,n)=>Mn(e.build(r,n),o=>t(o).build(r,n)))),BN=d(3,(e,t,r)=>As(e,Qn(t,_e(t,r)))),FJ=e=>du((t,r)=>e.build(xi(),r)),NJ=e=>Eg(bo(NN(e),mp)),UJ=function(){return arguments.length===1?e=>PN(arguments[0],e):PN(arguments[0],arguments[1])},PN=(e,t)=>Ja(e)(new Proxy({...t},{get(r,n,o){if(n in r)return r[n];let s=Ir();yt(2);let i=new Error(`${e.key}: Unimplemented method "${n.toString()}"`);return yt(s),i.name="UnimplementedError",DJ(i)},has:nr})),DJ=e=>{let t=Object.assign(ta(e),{[MN]:MN,channel:{[Lg]:Lg,transform:()=>q(t),pipe(){return V(this,arguments)}},[Lg]:Lg,transform:()=>q(t)});function r(){return t}return Object.assign(r,t),Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r},MN="~effect/Stream",Lg="~effect/Channel",LJ=()=>e=>e,BJ=()=>e=>e,$J=()=>e=>e,HJ=(e,t)=>(t=jo(t),Qn(li,t?.onEnd?pi(bs(e,t),r=>Yf(n=>t.onEnd(r,n))):bs(e,t))),$N=e=>lu(li.context(e)),jJ=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=jo(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return a0(_e(r?.onEnd!==void 0?pi(bs(t,r),o=>Yf(s=>r.onEnd(o,s))):bs(t,r),o=>c0(n,o,r)))}return n=>a0(_e(r?.onEnd!==void 0?pi(bs(t,r),o=>Yf(s=>r.onEnd(o,s))):bs(t,r),o=>c0(n,o,r)))},c0=function(){let e=$g(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=F;t._tag==="Span"&&(r=jo(r),n=qJ(t.name,r?.captureStackTrace));let o=$N(t);return e?As(n(arguments[0]),o):s=>As(n(s),o)},qJ=(e,t)=>(t=typeof t=="function"?t:po,BN(vN,r=>({name:e,stack:t,parent:r})));var Yn=Vn;var zg="~effect/DateTime",Wg="~effect/DateTime/TimeZone",qN={[zg]:zg,pipe(){return V(this,arguments)},[Qe](){return this.toString()},toJSON(){return Pp(this).toJSON()}},zJ={...qN,_tag:"Utc",[ie](){return qt(this.epochMilliseconds)},[ae](e){return ul(e)&&e._tag==="Utc"&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Pp(this).toJSON()})`}},WJ={...qN,_tag:"Zoned",[ie](){return he(qt(this.epochMilliseconds))(J(this.zone))},[ae](e){return ul(e)&&e._tag==="Zoned"&&this.epochMilliseconds===e.epochMilliseconds&&Z(this.zone,e.zone)},toString(){return`DateTime.Zoned(${I0(this)})`}},zN={[Wg]:Wg,[Qe](){return this.toString()}},KJ={...zN,_tag:"Named",[ie](){return Be(`Named:${this.id}`)},[ae](e){return pu(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},VJ={...zN,_tag:"Offset",[ie](){return Be(`Offset:${this.offset}`)},[ae](e){return pu(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${S0(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},yi=(e,t,r)=>{let n=Object.create(WJ);return n.epochMilliseconds=e,n.zone=t,Object.defineProperty(n,"partsUtc",{value:r,enumerable:!1,writable:!0}),Object.defineProperty(n,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(n,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),n},ul=e=>O(e,zg);var pu=e=>O(e,Wg),WN=e=>pu(e)&&e._tag==="Offset",KN=e=>pu(e)&&e._tag==="Named",VN=e=>e._tag==="Utc",p0=e=>e._tag==="Zoned",JN=Wr((e,t)=>e.epochMilliseconds===t.epochMilliseconds);var GN=e=>{let t=Object.create(zJ);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},cl=e=>{let t=e.getTime();if(Number.isNaN(t))throw new Pg("Invalid date");return GN(t)},Vg=e=>{if(ul(e))return e;if(e instanceof Date)return cl(e);if(typeof e=="object"){if("epochMilliseconds"in e)return cl(new Date(e.epochMilliseconds));let t=new Date(0);return tG(t,e),cl(t)}else if(typeof e=="string"&&!JJ(e))return cl(new Date(e+"Z"));return cl(new Date(e))},JJ=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),GJ=-864e13+720*60*1e3,ZJ=864e13-840*60*1e3,m0=(e,t)=>{let r=t?.timeZone;if(r===void 0&&ul(e)&&p0(e))return e;let n=Vg(e);if(n.epochMilliseconds<GJ||n.epochMilliseconds>ZJ)throw new RangeError(`Epoch millis out of range: ${n.epochMilliseconds}`);r===void 0&&typeof e=="object"&&"timeZoneId"in e&&(r=e.timeZoneId);let o;if(r===void 0){let s=new Date(n.epochMilliseconds).getTimezoneOffset()*-60*1e3;o=_p(s)}else if(pu(r))o=r;else if(typeof r=="number")o=_p(r);else{let s=g0(r);if(fe(s))throw new Pg(`Invalid time zone: ${r}`);o=s.value}return t?.adjustForTimeZone!==!0?yi(n.epochMilliseconds,o,n.partsUtc):rG(n.epochMilliseconds,o,t?.disambiguation??"compatible")},l0=xs(m0),ZN=xs(Vg),QJ=/^(.{17,35})\[(.+)\]$/,QN=e=>{let t=QJ.exec(e);if(t===null){let o=E0(e);return o!==null?l0(e,{timeZone:o}):_()}let[,r,n]=t;return l0(r,{timeZone:n})};var YN=e=>GN(e.epochMilliseconds);var Kg=new Map,YJ={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},XJ=e=>{let t=e.resolvedOptions().timeZone,r=Kg.get(t);if(r!==void 0)return r;let n=Object.create(KJ);return n.id=t,n.format=e,Kg.set(t,n),n},h0=e=>{let t=Kg.get(e);if(t!==void 0)return t;try{let r=XJ(new Intl.DateTimeFormat("en-US",{...YJ,timeZone:e}));return Kg.set(e,r),r}catch{throw new Pg(`Invalid time zone: ${e}`)}},_p=e=>{let t=Object.create(VJ);return t.offset=e,t},x0=xs(h0);var eG=/^(?:GMT|[+-])/,g0=e=>{if(eG.test(e)){let t=E0(e);return t===null?_():N(_p(t))}return x0(e)},XN=e=>e._tag==="Offset"?S0(e.offset):e.id;var Pp=e=>new Date(e.epochMilliseconds),Jg=e=>{if(e._tag==="Utc")return new Date(e.epochMilliseconds);if(e.zone._tag==="Offset")return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(n=>n.type!=="literal"),r=new Date(0);return r.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),r.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),t[6]?.type==="fractionalSecond"?Number(t[6].value):(e.epochMilliseconds%1e3+1e3)%1e3),e.adjustedEpochMilliseconds=r.getTime(),r},y0=e=>Jg(e).getTime()-b0(e),S0=e=>{let t=Math.abs(e),r=Math.floor(t/(3600*1e3)),n=Math.round(t%(3600*1e3)/(60*1e3));return n===60&&(r+=1,n=0),`${e<0?"-":"+"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},eU=e=>S0(y0(e)),b0=e=>e.epochMilliseconds;var tG=(e,t)=>{if((t.year!==void 0||t.month!==void 0||t.day!==void 0)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),t.month!==void 0?t.month-1:e.getUTCMonth(),t.day??e.getUTCDate()),t.weekDay!==void 0){let r=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+r)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)};var jN=1440*60*1e3,rG=(e,t,r)=>{if(t._tag==="Offset")return yi(e-t.offset,t);let n=Op(e-jN,e,t),o=Op(e+jN,e,t);if(n===o)return yi(e-n,t);let s=n<o,i=n-o;if(s){if(Op(e-o,e,t)===o)return yi(e-o,t);let u=yi(e-n,t),f=Jg(u).getTime();if(e!==f)switch(r){case"reject":{let p=new Date(e).toISOString();throw new RangeError(`Gap time: ${p} does not exist in time zone ${t.id}`)}case"earlier":return yi(e-o,t);case"compatible":case"later":return u}return u}if(Op(e-n,e,t)===n){if(r==="earlier"||r==="compatible"||Op(e-n+i,e+i,t)===n)return yi(e-n,t);if(r==="reject"){let u=new Date(e).toISOString();throw new RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return yi(e-o,t)},nG=/([+-])(\d{2}):(\d{2})$/,E0=e=>{let t=nG.exec(e);if(t===null)return null;let[,r,n,o]=t;return(r==="+"?1:-1)*(Number(n)*60+Number(o))*60*1e3},Op=(e,t,r)=>{let n=r.format.formatToParts(e).find(s=>s.type==="timeZoneName")?.value??"";if(n==="GMT")return 0;let o=E0(n);return o===null?y0(yi(t,r)):o};var tU=e=>Pp(e).toISOString();var d0=e=>{let t=Jg(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${eU(e)}`},I0=e=>e.zone._tag==="Offset"?d0(e):`${d0(e)}[${e.zone.id}]`;var Sde=globalThis.Number;var nU=d(2,(e,t)=>{if(!globalThis.Number.isFinite(e)||!globalThis.Number.isFinite(t)||t===0)return NaN;if(globalThis.Number.isInteger(e)&&globalThis.Number.isInteger(t))return e%t;let[r,n]=rU(e),[o,s]=rU(t),i=Math.min(n,s),a=r*BigInt(10)**BigInt(n-i),c=o*BigInt(10)**BigInt(s-i),u=a%c;if(u===BigInt(0))return e<0||Object.is(e,-0)?-0:0;let f=globalThis.Number(`${u}e${i}`);return f===0?Math.sign(e)*globalThis.Number.MIN_VALUE:f});function rU(e){if(globalThis.Number.isInteger(e))return[BigInt(e),0];let t=Math.abs(e).toExponential(),r=t.indexOf("e"),n=t.slice(0,r).replace(".","");return[BigInt(n)*(e<0?-BigInt(1):BigInt(1)),globalThis.Number(t.slice(r+1))-n.length+1]}var oU=e=>{let t=Math.ceil(Math.log(e)/Math.log(2));return Math.max(Math.pow(2,t),2)};var Ede=globalThis.String,Gg=On;var sU=e=>e.trim();var ht=d(2,(e,t)=>oa(e,iG,r=>t(r))),wo=e=>e.reasons.some(w0),w0=e=>e._tag==="Fail"&&Ap(e.error),Mp=e=>{let t,r=!1;for(let n of e.reasons)w0(n)?t??=n.error:n._tag!=="Interrupt"&&(r=!0);return t===void 0?re(e):r?re(au(e.reasons.filter(n=>!w0(n)))):X(t)};var iG=e=>{let t=Mp(e);return be(t)?t:X(t.success.value)},Zg=e=>{let t=Mp(e);return be(t)?ir(t.failure):Mr(t.success.value)},Fp=d(2,(e,t)=>di(e,{onSuccess:t.onSuccess,onFailure:r=>{let n=Mp(r);return be(n)?t.onFailure(n.failure):t.onDone(n.success.value)}}));var iU="~effect/Schedule";var Fr=Ce("effect/Schedule/CurrentMetadata",{defaultValue:qe({input:void 0,output:void 0,duration:Gi,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),aG={[iU]:{_Out:F,_In:F,_Env:F},pipe(){return V(this,arguments)}},v0=e=>O(e,iU),fl=e=>{let t=Object.create(aG);return t.step=e,t},C0=()=>{let e=0,t,r;return(n,o)=>{r===void 0&&(r=n);let s=n-r,i=t===void 0?0:n-t;return t=n,{input:o,attempt:++e,start:r,now:n,elapsed:s,elapsedSincePrevious:i}}},aU=e=>fl(_e(e,t=>{let r=C0();return(n,o)=>t(r(n,o))})),Qa=e=>Mn(e.step,t=>q(()=>Ye(t))),ks=e=>Is(t=>_e(Qa(e),r=>{let n=C0();return o=>ce(()=>{let s=t.currentTimeMillisUnsafe();return Y(r(s,o),([i,a])=>{let c=n(s,o);return c.output=i,c.duration=a,Zr(tl(a),c)})})})),Np=e=>_e(ks(e),t=>r=>_e(t(r),n=>n.output));var cU=e=>fl(_e(el(e.map(Qa)),t=>(r,n)=>Y(Kn(t,o=>Fp(o(r,n),{onSuccess:s=>q(s[1]),onDone:()=>Og,onFailure:Ye})),o=>{let s=cG(o);return s===void 0?se(Gi):q([s,s])}))),cG=e=>{let t;for(let r=0;r<e.length;r++){let n=e[r];n!==void 0&&(t=t===void 0?n:uP(t,n))}return t},uU=(e,t=2)=>{let r=zt($e(e));return aU(q(n=>{let o=Zi(r*Math.pow(t,n.attempt-1));return q([o,o])}))};var A0=e=>fl(_e(Qa(e),t=>(r,n)=>Fp(t(r,n),{onSuccess:o=>q([n,o[1]]),onFailure:Ye,onDone:()=>se(n)}))),fU=e=>Up(Dp,({attempt:t})=>q(t<=e)),ll=e=>{let t=$e(e);return aU(q(r=>q([r.attempt-1,t])))};var Up=d(2,(e,t)=>fl(_e(Qa(e),r=>{let n=C0();return(o,s)=>Y(r(o,s),i=>{let[a,c]=i,u=t({...n(o,s),output:a,duration:c});return Y(ge(u)?u:q(u),f=>f?q(i):se(a))})})));var Dp=ll(Gi);var lU="~effect/ExecutionPlan";var uG={[lU]:lU,get captureRequirements(){let e=this;return Ha(t=>q(fG(e.steps.map(r=>({...r,while:r.while?n=>Eo(r.while(n),t):void 0,schedule:r.schedule?fl(Eo(_e(Qa(r.schedule),n=>(o,s)=>Eo(n(o,s),t)),t)):void 0,provide:$g(r.provide)?As(r.provide,lu(t)):r.provide})))))},pipe(){return V(this,arguments)}},fG=e=>{let t=Object.create(uG);return t.steps=e,t};var Qg=Ce("effect/ExecutionPlan/CurrentMetadata",{defaultValue:qe({attempt:0,stepIndex:0})});var lG=(e,t,r)=>Ig(n=>Y(r?.local?gi(t,xi(),n):kp(t,n),o=>Eo(e,o))),Yg=d(e=>ge(e[0]),(e,t,r)=>np(t)?Eo(e,t):lG(e,Array.isArray(t)?jg(...t):t,r));var pU=e=>e.reasons.every(hs)?qo(e):re(e),R0=d(3,(e,t,r)=>Y(ks(t),n=>{let o=Fr.defaultValue();return oa(ht(mg(pi(Y(ce(()=>Pn(e,Fr,o)),n),s=>ye(()=>{o=s})),{disableYield:!0}),s=>q(s)),pU,s=>r(s,o.attempt===0?_():N(o)))})),O0=d(3,(e,t,r)=>Y(ks(t),n=>{let o=Fr.defaultValue(),s,i=oa(ce(()=>Pn(e,Fr,o)),pU,a=>(s=a,Y(n(a),c=>(o=c,i))));return ht(i,a=>Pa(()=>r(s,a)))})),mU=d(2,(e,t)=>{let r=typeof t=="function"?t(F):v0(t)?t:Bp(t);return R0(e,r,Et)}),Lp=d(2,(e,t)=>{let r=typeof t=="function"?t(F):v0(t)?t:Bp(t);return O0(e,r,Et)}),hU=d(3,(e,t,r)=>Y(ks(r),n=>{let o=Fr.defaultValue(),s=ce(()=>Pn(e,Fr,o));return ht(Y(n(t),i=>{o=i;let a=qe(Y(s,n));return mi({while:nr,body:a,step(c){o=c}})}),i=>q(i))})),dG=A0(Dp),Bp=e=>{let t=e.schedule?A0(e.schedule):dG;return e.while&&(t=Up(t,({input:r})=>{let n=e.while(r);return ge(n)?n:q(n)})),e.until&&(t=Up(t,({input:r})=>{let n=e.until(r);return ge(n)?_e(n,o=>!o):q(!n)})),e.times!==void 0&&(t=Up(t,({attempt:r})=>q(r<=e.times))),t};var _0=(e,t)=>{let r=-1,n=0,o=s=>Sg(e(s));return{begin:Is(s=>ce(()=>{let i=t();i.stepIndex!==r&&(r=i.stepIndex,n=0),n++;let a={attempt:i.attempt,stepAttempt:n,stepIndex:i.stepIndex,startNanos:s.monotonicTimeNanosUnsafe()};return Zr(o({_tag:"AttemptStart",attempt:a.attempt,stepAttempt:a.stepAttempt,stepIndex:a.stepIndex}),a)})),end:(s,i)=>Is(a=>{let c=$o(a.monotonicTimeNanosUnsafe()-s.startNanos);return o(i._tag==="Success"?{_tag:"AttemptSuccess",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c}:{_tag:"AttemptFailure",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c,cause:i.cause})})}},gU=d(e=>ge(e[0]),(e,t,r)=>ce(()=>{let n=0,o={attempt:0,stepIndex:0},s=pg(Qg,ye(()=>(o={attempt:o.attempt+1,stepIndex:n},o))),i=r?.onEvent===void 0?void 0:_0(r.onEvent,()=>o),a=i===void 0?F:u=>Jn(f=>Y(i.begin,p=>To(f(u),m=>i.end(p,m)))),c;return Y(mi({while:()=>n<t.steps.length&&(c===void 0||be(c)),body(){let u=t.steps[n],f=s(a(Yg(e,u.provide)));if(c){let p=!1,m=f;f=ce(()=>p?m:(p=!0,qf(c))),f=Lp(f,$p(u,!1))}else{let p=$p(u,!0);f=p?Lp(f,p):f}return Ba(f)},step(u){c=u,n++}}),()=>qf(c))})),$p=(e,t)=>{if(t){if(e.attempts===1||!(e.schedule||e.attempts))return}else return Bp({schedule:e.schedule?e.schedule:e.attempts?void 0:pG,times:e.attempts,while:e.while});return Bp({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})},pG=fU(1);var SU="~effect/MutableHashMap";var mG={[SU]:SU,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${j(Array.from(this))})`},toJSON(){return{_id:"MutableHashMap",values:pr(Array.from(this))}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},Si=()=>{let e=Object.create(mG);return e.backing=new Map,e.buckets=new Map,e};var Qr=d(2,(e,t)=>{if(e.backing.has(t))return N(e.backing.get(t));if(P0(t))return _();let r=J(t),n=e.buckets.get(r);return n===void 0?_():hG(e,n,t)}),P0=e=>typeof e!="object"&&typeof e!="function";var hG=(e,t,r)=>{for(let n=0,o=t.length;n<o;n++)if(Z(r,t[n])){let s=t[n];return N(e.backing.get(s))}return _()},M0=d(2,(e,t)=>de(Qr(e,t))),bi=d(3,(e,t,r)=>{if(e.backing.has(t)||P0(t))return e.backing.set(t,r),e;let n=J(t),o=e.buckets.get(n);if(o===void 0)return e.buckets.set(n,[t]),e.backing.set(t,r),e;let s=xG(o,t);return s===void 0&&(o.push(t),s=t),e.backing.set(s,r),e}),xG=(e,t)=>{for(let r=0,n=e.length;r<n;r++)if(Z(t,e[r]))return e[r]};var Ei=d(2,(e,t)=>{if(P0(t))return e.backing.delete(t),e;let r=J(t),n=e.buckets.get(r);if(n===void 0)return e;for(let o=0,s=n.length;o<s;o++){let i=n[o];if(i===t||Z(t,i)){e.backing.delete(i),n.splice(o,1);break}}return n.length===0&&e.buckets.delete(r),e}),Xg=e=>(e.backing.clear(),e.buckets.clear(),e),bU=e=>e.backing.size;var gG="~effect/Request",yG=VO({_E:e=>e,_A:e=>e,_R:e=>e}),jde={...XO,[gG]:yG};var EU=e=>e;var TU=d(2,(e,t)=>{let r=n=>Lt(o=>{let s=vU(n,e,o,ea());return IG(n,s)});return ge(t)?Y(t,r):r(t)}),wU=(e,t)=>{let r=vU(t.resolver,e,t.onExit,{context:t.context,cache:{scheduler:Re(t.context,La)}});return()=>CU(t.resolver,r)},bG=new WeakSet,EG=e=>{if(!bG.has(e.batchKey))return new Map;let t=Si();return{get:r=>_n(Qr(t,r)),has:r=>M0(t,r),set:(r,n)=>bi(t,r,n),delete:r=>Ei(t,r)}},ey=[],F0=new WeakMap,vU=(e,t,r,n)=>{let o=F0.get(e);o||(o=EG(e),F0.set(e,o));let s,i=!1,a=EU({request:t,context:n.context,uninterruptible:!1,completeUnsafe(u){i||(i=!0,!(s&&!s.entrySet.delete(a))&&r(u))}});if(e.preCheck!==void 0&&!e.preCheck(a))return a;let c=e.batchKey(a);if(s=o.get(c),!s){if(ey.length>0)s=ey.pop(),s.key=c,s.resolver=e,s.map=o;else{let u={key:c,resolver:e,map:o,entrySet:new Set,entries:new Set,delayEffect:Y(ce(()=>u.resolver.delay),f=>IU(u)),run:To(ce(()=>u.resolver.runAll(Array.from(u.entries),u.key)),f=>{for(let p of u.entrySet)p.completeUnsafe(f._tag==="Success"?ln(new Error("Effect.request: RequestResolver did not complete request",{cause:p.request})):f);return u.entries.clear(),ey.length<128&&(u.entrySet.clear(),u.key=void 0,u.fiber=void 0,u.resolver=void 0,u.map=void 0,ey.push(u)),pe})};s=u}o.set(c,s),s.fiber=sa(n.context)(s.delayEffect,{scheduler:n.cache.scheduler})}return s.entrySet.add(a),s.entries.add(a),s.resolver.collectWhile(s.entries)||(s.fiber.interruptUnsafe(n.id),s.fiber=sa(n.context)(IU(s),{scheduler:n.cache.scheduler})),a},CU=(e,t)=>{if(t.uninterruptible)return;let r=F0.get(e);if(!r)return;let n=e.batchKey(t),o=r.get(n);if(!o||!o.entries.delete(t))return;o.entrySet.delete(t);let s;o.entries.size===0&&(r.delete(n),s=o.fiber),t.completeUnsafe(Kf()),s?.interruptUnsafe()},IG=(e,t)=>ye(()=>CU(e,t));function IU(e){return e.map.has(e.key)?(e.map.delete(e.key),e.run):pe}var wG="effect/Metric/CurrentMetricAttributes",vG=Ce(wG,{defaultValue:()=>({})}),CG="effect/Metric/MetricRegistry",AG=Ce(CG,{defaultValue:()=>new Map}),AU="~effect/Metric",kU=class{[AU]=AU;#e;#t="";id;description;attributes;constructor(t,r,n){this.id=t,this.description=r,this.attributes=n}valueUnsafe(t){return this.hook(t).get(t)}modifyUnsafe(t,r){return this.hook(r).modify(t,r)}updateUnsafe(t,r){return this.hook(r).update(t,r)}hook(t){let r=Re(t,vG);r!==this.#e&&(this.#e=r,this.#t=kG(this,RU(this.attributes,r)));let n=Re(t,AG),o=n.get(this.#t);return NO(o)&&(o={id:this.id,type:this.type,description:this.description,attributes:Object.keys(r).length>0?RU(this.attributes,r):this.attributes,hooks:this.createHooks()},n.set(this.#t,o)),o.hooks}pipe(){return V(this,arguments)}};var dl=d(2,(e,t)=>Ha(r=>ye(()=>e.updateUnsafe(t,r))));function kG(e,t){let r=Object.entries(t).sort((n,o)=>n[0]<o[0]?-1:n[0]>o[0]?1:0);return JSON.stringify([e.type,e.id,e.description,r])}function RU(e,t){return{...OU(e),...OU(t)}}function OU(e){return ei(e)&&Array.isArray(e)?e.reduce((t,[r,n])=>(B(t,r,n),t),{}):e}var RG=si,Yr=ge,OG=el,_G=VT,PG=gF,MG=yF,FG=SF,NG=EF,Ko=Kn,UG=TF,xn=mi,jp=ET,Vo=ZP,I=q,ia=ou,U0=bT,L=ce,W=ye,P=pe;var qp=Og;var Nn=Lt,Xn=mp,DG=RF,LG=OF,BG=PF;var $G=_F,xt=eM,D=Et,ty=fg,He=Ye,aa=JP,gn=ta,Jo=GP;var zp=zf,HG=ST,ar=oe,jG=r_,D0=qf,qG=yT,zG=VP,WG=KP,A=Y,L0=fM,Kt=bo,Rt=pi,KG=Ba,VG=zM,eo=yp,K=_e,Ot=Zr,ry=Wf,vo=hp,JG=sM,B0=CM,GG=PT,hu=Es;var MU=gg,FU=DM,ZG=LM,QG=BM,YG=$M,rt=Mn,$0=PM,XG=xp,e8=xg,t8=_M,H0=FT,NU=oa,ml=UT,r8=DT,Ii=yg,Wp=NT,n8=NM,Kp=MM,o8=FM,s8=hg,UU=UM,i8=LT,ny=Lp,j0=O0,a8=iM,oy=qM,sy=Sg,c8=gU,u8=lN,f8=HM,l8=jM,q0=QM,d8=HT,DU=$T,ca=ZM,ua=tl,p8=YM,z0=CT,m8=AT,h8=aM,Ya=kT,W0=CF,x8=AF,K0=kF,LU=JT,g8=GT,BU=AM,y8=vF,iy=kM,V0=bg,S8=gp,b8=BT,E8=VM,I8=cM,Un=di,$U=Gf,T8=JM,w8=GM,Nr=_T,yn=Ha,J0=Yg,Ur=Eo,v8=vM,G0=IM,xu=TM,Xa=Jf,Z0=na,C8=wM,Go=Pn,A8=pg,Co=Sp,ec=Eg,hl=Ig,Ti=Tg,k8=uF,HU=cF,jU=Yf,wi=sF,to=bp,R8=iF,O8=WT,Vp=Io,Xr=To,_8=qT,P8=zT,ay=dF,M8=lF,F8=KT,Dn=Xf,vi=wg,gu=aF,Ci=su,en=Jn,N8=hF,U8=xF,_t=mg,qU=mU,D8=R0,L8=MT,Q0=RM,B8=d(2,(e,t)=>zU(e,void 0,t)),zU=hU,$8=WF,H8=KF,j8=VF,q8=JF,z8=rN,W8=nN,K8=oN,V8=sN,J8=YF,G8=XF,Z8=eN,Y0=ZF,X0=bs,Jp=lp,Q8=tN,Y8=QF,xl=jf,X8=TU,eZ=wU,gl=MF,gt=ZT,Rs=UF,yl=FF,tZ=NF,rZ=YP,nZ=XP,Gp=LF,Sr=sa,ew=QT,oZ=BF,tw=HF,rw=YT,cy=$F,sZ=Ag,Ai=qF,nw=XT,ki=jF,iZ=kg,me=TT,aZ=tM,yu=Is,Sl=Ts,cZ=Ts(),uZ=Ts("Fatal"),fZ=Ts("Warn"),Zp=Ts("Error"),lZ=Ts("Info"),dZ=Ts("Debug"),pZ=Ts("Trace"),mZ=d(2,(e,t)=>na(e,n0,r=>new Set([...r,t]))),uy=d(e=>Yr(e[0]),(e,...t)=>na(e,TN,r=>{let n=t.length===1?{...r,...t[0]}:{...r};return t.length===1||B(n,t[0],t[1]),n})),hZ=uN,xZ=d(2,(e,t)=>Y(r0,r=>na(e,wN,n=>[[t,r],...n]))),gZ=d(e=>Yr(e[0]),(e,t,r)=>Xr(e,n=>{let o=r===void 0?n:r(n);return dl(t,o)})),yZ=d(e=>Yr(e[0]),(e,t,r)=>Rt(e,n=>{let o=r===void 0?n:r(n);return dl(t,o)})),SZ=d(e=>Yr(e[0]),(e,t,r)=>Wp(e,n=>{let o=r===void 0?n:r(n);return dl(t,o)})),bZ=d(e=>Yr(e[0]),(e,t,r)=>UU(e,n=>{let o=r===void 0?n:r(n);return dl(t,o)})),EZ=d(e=>Yr(e[0]),(e,t,r)=>yu(n=>{let o=n.monotonicTimeNanosUnsafe();return Xr(e,()=>{let s=n.monotonicTimeNanosUnsafe(),i=fP($e(s),$e(o)),a=r===void 0?i:r(i);return dl(t,a)})})),pl=class extends Ue()("effect/Effect/Transaction"){},IZ=e=>ar(t=>{let r=Vi(t.context,pl);if(r&&!PU.has(r))return e;r={journal:new Map,retry:!1};let n;return en(o=>A(xn({while:()=>!n,body:qe(o(e).pipe(Go(pl,r),Kp(s=>r.retry?sg(s)?o(TZ(r)):W(()=>N0(r)):P),eo)),step(s){if(r.retry||!WU(r))return N0(r);ft(s)&&wZ(t,r),N0(r),PU.add(r),n=s}}),()=>n))}),PU=new WeakSet,WU=e=>{for(let[t,{version:r}]of e.journal)if(t.version!==r)return!1;return!0},TZ=e=>Nn(t=>{if(!WU(e))return t(P);let r={},n=Array.from(e.journal.keys()),o=()=>{for(let i of n)i.pending.delete(r)},s=()=>{o(),t(P)};for(let i of n)i.pending.set(r,s);return W(o)});function wZ(e,t){for(let[r,{value:n,written:o}]of t.journal)if(o){Object.is(n,r.value)||(r.version=r.version+1,r.value=n);for(let s of r.pending.values())e.currentDispatcher.scheduleTask(s,0);r.pending.clear()}}function N0(e){e.retry=!1,e.journal.clear()}var vZ=A(pl,e=>(e.retry=!0,Dn)),CZ=(e,t,r)=>(...n)=>Nn(o=>{try{e(...n,(s,i)=>{o(s?t?L(()=>D(t(s,n))):D(s):I(i))})}catch(s){o(r?D(r(s,n)):gn(s))}}),AZ=()=>e=>e,kZ=()=>e=>e,RZ=()=>e=>e,Su=lM,bu=dM,cr=pM,ur=uM,fy=mM,ow=rM;var KU=/^[+-]?\d+$/,iw="~effect/BigDecimal",OZ={[iw]:iw,[ie](){let e=Qp(this);return he(Be(String(e.value)),qt(e.scale))},[ae](e){return Eu(e)&&QU(this,e)===0},toString(){return`BigDecimal(${fa(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},Eu=e=>O(e,iw),ly=(e,t)=>{if(!Number.isSafeInteger(t))throw new RangeError(`Scale must be a safe integer, got ${t}`);let r=Object.create(OZ);return r.value=e,r.scale=t,r},GU=(e,t)=>{let r=ly(e,t);return r.normalized=r,r};var Os=BigInt(0),_Z=BigInt(1);var PZ=BigInt(10),ZU=GU(Os,0);var Qp=e=>{if(e.normalized===void 0)if(e.value===Os)e.normalized=ZU;else{let t=`${e.value}`,r=t.length;for(;t[r-1]==="0";)r--;e.normalized=GU(BigInt(t.slice(0,r)),e.scale-(t.length-r))}return e.normalized};var MZ=100,FZ=[_Z],sw=(e,t)=>e===t?0:e<t?-1:1,VU=(e,t)=>{let r=`${e.value<Os?-e.value:e.value}`,n=`${t.value<Os?-t.value:t.value}`,o=BigInt(r.length-n.length)-BigInt(e.scale)+BigInt(t.scale);if(o!==Os)return o<Os?-1:1;let s=Math.max(r.length,n.length);return I_(r.padEnd(s,"0"),n.padEnd(s,"0"))},QU=(e,t)=>{if(e.scale===t.scale)return sw(e.value,t.value);let r=JU(e),n=JU(t);if(r!==n)return r<n?-1:1;if(r===0)return 0;let o=e.scale-t.scale,s=Math.abs(o);if(s>MZ)return r===-1?VU(t,e):VU(e,t);let i=FZ[s]??=PZ**BigInt(s);return o>0?sw(e.value,t.value*i):sw(e.value*i,t.value)},bl=ai(QU);var JU=e=>e.value===Os?0:e.value<Os?-1:1;var YU=e=>{if(e==="")return N(ZU);let t,r,n=e.search(/[eE]/);if(n!==-1){let c=e.slice(n+1);if(t=e.slice(0,n),r=Number(c),t===""||!Number.isSafeInteger(r)||!KU.test(c))return _()}else t=e,r=0;let o,s,i=t.search(/\./);if(i!==-1){let c=t.slice(0,i),u=t.slice(i+1);o=`${c}${u}`,s=u.length}else o=t,s=0;if(!KU.test(o))return _();let a=s-r;return Number.isSafeInteger(a)?N(ly(BigInt(o),a)):_()};var fa=e=>{let t=Qp(e);if(Math.abs(t.scale)>=16)return NZ(t);let r=t.value<Os,n=`${r?-t.value:t.value}`,o=t.scale>0?n.padStart(t.scale+1,"0"):n.padEnd(n.length-t.scale,"0"),s=o.length-t.scale,i=t.scale>0?`${o.slice(0,s)}.${o.slice(s)}`:o;return r?`-${i}`:i},NZ=e=>{if(UZ(e))return"0e+0";let t=Qp(e),r=`${t.value}`,n=t.value<Os?2:1,o=r.slice(0,n),s=r.slice(n),i=s.length-t.scale;return`${o}${s===""?"":`.${s}`}e${i>=0?"+":""}${i}`};var UZ=e=>e.value===Os;var l={};ps(l,{Any:()=>S7,Array:()=>ct,ArrayEnsure:()=>R7,BigDecimal:()=>tH,BigDecimalFromString:()=>cee,BigInt:()=>cd,BigIntFromString:()=>VX,Boolean:()=>Fi,BooleanFromBit:()=>eee,BooleanLiterals:()=>U7,ByteSize:()=>WS,ByteSizeFromBigInt:()=>fee,ByteSizeFromNumber:()=>lee,ByteSizeFromString:()=>uee,Cause:()=>Km,CauseReason:()=>ZC,Char:()=>MX,Chunk:()=>dee,Class:()=>JS,Cookie:()=>WH,Cookies:()=>KH,Date:()=>zS,DateFromMillis:()=>$X,DateFromString:()=>BX,DateTimeUtc:()=>KS,DateTimeUtcFromDate:()=>yee,DateTimeUtcFromMillis:()=>bee,DateTimeUtcFromString:()=>See,DateTimeZoned:()=>yH,DateTimeZonedFromString:()=>wee,Defect:()=>er,DnsARecord:()=>MH,DnsAaaaRecord:()=>FH,DnsCaaRecord:()=>NH,DnsCnameRecord:()=>UH,DnsMxRecord:()=>DH,DnsNaptrRecord:()=>LH,DnsNsRecord:()=>BH,DnsPtrRecord:()=>$H,DnsRecord:()=>bte,DnsRecordType:()=>Ste,DnsSoaRecord:()=>HH,DnsSrvRecord:()=>jH,DnsTlsaRecord:()=>qH,DnsTxtRecord:()=>zH,DomainName:()=>Sa,DomainNameFromString:()=>kH,Duration:()=>nh,DurationFromMillis:()=>yte,DurationFromNanos:()=>gte,DurationFromString:()=>xte,Enum:()=>y7,Error:()=>Ar,ErrorInstance:()=>FX,Exit:()=>hA,FalseLiterals:()=>k$,File:()=>V$,Finite:()=>jS,FiniteFromString:()=>KX,FormData:()=>J$,Graph:()=>wte,HashMap:()=>vte,HashSet:()=>Cte,Headers:()=>_te,Host:()=>cte,HostFromString:()=>ute,HostPort:()=>OH,HostPortFromString:()=>fte,InetAddress:()=>CH,InetAddressFromString:()=>ste,InetAddressV4:()=>nte,InetAddressV6:()=>ote,Int:()=>In,IpAddress:()=>Sc,IpAddressFromString:()=>Xu,IpInterface:()=>IH,IpInterfaceFromString:()=>Xee,IpLinkLocalAddress:()=>Bee,IpLinkLocalAddressFromString:()=>$ee,IpLoopbackAddress:()=>Dee,IpLoopbackAddressFromString:()=>Lee,IpMulticastAddress:()=>vee,IpMulticastAddressFromString:()=>Cee,IpNetwork:()=>vH,IpNetworkFromString:()=>rte,IpUnicastAddress:()=>Ree,IpUnicastAddressFromString:()=>Oee,IpUnspecifiedAddress:()=>Hee,IpUnspecifiedAddressFromString:()=>jee,Ipv4Address:()=>rh,Ipv4AddressFromString:()=>pA,Ipv4BroadcastAddress:()=>Mee,Ipv4BroadcastAddressFromString:()=>Fee,Ipv4Interface:()=>bH,Ipv4InterfaceFromString:()=>Qee,Ipv4Network:()=>TH,Ipv4NetworkFromString:()=>ete,Ipv4PrivateAddress:()=>qee,Ipv4PrivateAddressFromString:()=>zee,Ipv6Address:()=>VS,Ipv6AddressFromString:()=>SH,Ipv6Interface:()=>EH,Ipv6InterfaceFromString:()=>Yee,Ipv6Network:()=>wH,Ipv6NetworkFromString:()=>tte,Ipv6UniqueLocalAddress:()=>Wee,Ipv6UniqueLocalAddressFromString:()=>Kee,Json:()=>GS,JsonFromUrlParamsField:()=>Pte,JsonObject:()=>sre,Literal:()=>fr,Literals:()=>Fo,MacAddress:()=>Yu,MacAddressFromString:()=>ld,MacBroadcastAddress:()=>Nee,MacBroadcastAddressFromString:()=>Uee,MacLocallyAdministeredAddress:()=>Vee,MacLocallyAdministeredAddressFromString:()=>Jee,MacMulticastAddress:()=>Aee,MacMulticastAddressFromString:()=>kee,MacUnicastAddress:()=>_ee,MacUnicastAddressFromString:()=>Pee,MacUniversallyAdministeredAddress:()=>Gee,MacUniversallyAdministeredAddressFromString:()=>Zee,MutableJson:()=>are,Natural:()=>Wu,Never:()=>Mi,NonEmptyArray:()=>Zu,NonEmptyString:()=>fA,Null:()=>LS,NullOr:()=>nA,NullishOr:()=>b$,Number:()=>Ju,NumberFromString:()=>WX,ObjectKeyword:()=>E7,Opaque:()=>q7,Option:()=>ba,OptionFromNullOr:()=>Ate,OptionFromNullishOr:()=>Rte,OptionFromOptional:()=>Nte,OptionFromOptionalKey:()=>Fte,OptionFromOptionalNullOr:()=>Ute,OptionFromUndefinedOr:()=>kte,Port:()=>lte,PropertyKey:()=>GC,ReadonlyMap:()=>NX,ReadonlySet:()=>UX,Record:()=>Gu,RecordFromCookies:()=>Ote,RecordFromUrlParams:()=>Mte,Redacted:()=>VH,RedactedFromValue:()=>Dte,RegExp:()=>DX,Result:()=>Lte,SchemaError:()=>$n,ScopedIpv6Literal:()=>mA,ScopedIpv6LiteralFromString:()=>RH,SocketAddress:()=>ate,StandardSchemaV1FailureResult:()=>XX,String:()=>z,StringForLiteralAutocomplete:()=>b7,StringFromBase64:()=>GX,StringFromBase64Url:()=>ZX,StringFromHex:()=>QX,StringFromUriComponent:()=>YX,Struct:()=>Te,StructWithRest:()=>A7,Symbol:()=>g$,TaggedClass:()=>jte,TaggedError:()=>yA,TaggedStruct:()=>ya,TaggedUnion:()=>j7,TemplateLiteral:()=>x7,TemplateLiteralParser:()=>g7,TimeZone:()=>xH,TimeZoneFromString:()=>Tee,TimeZoneNamed:()=>mH,TimeZoneNamedFromString:()=>Iee,TimeZoneOffset:()=>Eee,Tree:()=>ore,Trim:()=>JX,Trimmed:()=>Z$,TrueLiterals:()=>A$,Tuple:()=>rs,TupleWithRest:()=>k7,URL:()=>W$,URLFromString:()=>LX,URLSearchParams:()=>G$,Uint8Array:()=>qs,Uint8ArrayFromBase64:()=>tee,Uint8ArrayFromBase64Url:()=>ree,Uint8ArrayFromHex:()=>Y$,Undefined:()=>tA,UndefinedOr:()=>$S,Union:()=>Pe,UniqueArray:()=>O7,UniqueSymbol:()=>I7,UnixPathAddress:()=>AH,UnixPathAddressFromString:()=>ite,Unknown:()=>Zm,UnknownFromJsonString:()=>jX,UrlParams:()=>xA,Void:()=>ud,annotate:()=>JY,annotateEncoded:()=>GY,annotateKey:()=>ZY,asserts:()=>t7,brand:()=>HS,catchDecoding:()=>F7,catchDecodingWithContext:()=>v$,catchEncoding:()=>N7,catchEncodingWithContext:()=>C$,check:()=>P7,declare:()=>Je,declareConstructor:()=>Cr,decode:()=>D7,decodeEffect:()=>r7,decodeExit:()=>u$,decodeOption:()=>o7,decodePromise:()=>i7,decodeResult:()=>s7,decodeSync:()=>Vm,decodeTo:()=>ee,decodeUnknownEffect:()=>xc,decodeUnknownExit:()=>c$,decodeUnknownOption:()=>n7,decodeUnknownPromise:()=>l$,decodeUnknownResult:()=>f$,decodeUnknownSync:()=>DS,encode:()=>L7,encodeEffect:()=>XC,encodeExit:()=>p$,encodeKeys:()=>v7,encodeOption:()=>c7,encodePromise:()=>f7,encodeResult:()=>u7,encodeSync:()=>eA,encodeTo:()=>oA,encodeUnknownEffect:()=>Jm,encodeUnknownExit:()=>d$,encodeUnknownOption:()=>a7,encodeUnknownPromise:()=>h$,encodeUnknownResult:()=>m$,encodeUnknownSync:()=>Gm,extendTo:()=>C7,fieldsAssign:()=>T7,flip:()=>JC,fromBrand:()=>M7,fromFormData:()=>qX,fromJsonString:()=>lA,fromURLSearchParams:()=>zX,instanceOf:()=>gc,is:()=>e7,isBase64:()=>F$,isBase64Url:()=>Y7,isBetween:()=>yc,isBetweenBigDecimal:()=>aee,isBetweenBigInt:()=>IX,isBetweenCodePoints:()=>vX,isBetweenDate:()=>yX,isBetweenLength:()=>aA,isBetweenProperties:()=>_X,isBetweenSize:()=>kX,isCapitalized:()=>oX,isEndingWith:()=>eX,isFinite:()=>iX,isGUID:()=>Z7,isGreaterThan:()=>cX,isGreaterThanBigDecimal:()=>nee,isGreaterThanBigInt:()=>SX,isGreaterThanDate:()=>mX,isGreaterThanOrEqualTo:()=>N$,isGreaterThanOrEqualToBigDecimal:()=>oee,isGreaterThanOrEqualToBigInt:()=>U$,isGreaterThanOrEqualToDate:()=>hX,isIncluding:()=>tX,isInt:()=>qS,isInt32:()=>dX,isLessThan:()=>uX,isLessThanBigDecimal:()=>see,isLessThanBigInt:()=>bX,isLessThanDate:()=>xX,isLessThanOrEqualTo:()=>fX,isLessThanOrEqualToBigDecimal:()=>iee,isLessThanOrEqualToBigInt:()=>EX,isLessThanOrEqualToDate:()=>gX,isLowercased:()=>nX,isMaxCodePoints:()=>wX,isMaxLength:()=>$$,isMaxProperties:()=>OX,isMaxSize:()=>AX,isMinCodePoints:()=>TX,isMinLength:()=>D$,isMinProperties:()=>RX,isMinSize:()=>CX,isMultipleOf:()=>lX,isNonEmpty:()=>B$,isPattern:()=>Qu,isPropertyNames:()=>PX,isSchema:()=>Vu,isSchemaError:()=>id,isStartingWith:()=>X7,isStringBigInt:()=>K7,isStringFinite:()=>W7,isStringSymbol:()=>V7,isTrimmed:()=>M$,isULID:()=>Q7,isUUID:()=>G7,isUint32:()=>pX,isUncapitalized:()=>sX,isUnique:()=>uA,isUniqueKey:()=>H$,isUppercased:()=>rX,link:()=>Ne,linkDecoding:()=>fd,make:()=>G,makeFilter:()=>Ge,makeFilterGroup:()=>z7,makeIsBetween:()=>th,makeIsGreaterThan:()=>Qm,makeIsGreaterThanOrEqualTo:()=>Ym,makeIsLessThan:()=>Xm,makeIsLessThanOrEqualTo:()=>eh,makeIsMultipleOf:()=>aX,middlewareDecoding:()=>T$,middlewareEncoding:()=>w$,mutable:()=>_7,mutableKey:()=>p7,optional:()=>lr,optionalKey:()=>Ku,overrideToCodecIso:()=>rre,overrideToEquivalence:()=>Wte,overrideToFormatter:()=>qte,readonlyKey:()=>m7,refine:()=>I$,required:()=>d7,requiredKey:()=>l7,resolveAnnotations:()=>cre,resolveAnnotationsKey:()=>ure,revealBottom:()=>VY,revealCodec:()=>QY,suspend:()=>E$,tag:()=>je,tagDefaultOmit:()=>H7,toCodecArrayFromSingle:()=>Qte,toCodecIso:()=>Gte,toCodecJson:()=>ef,toCodecStringTree:()=>Zte,toDifferJsonPatch:()=>nre,toEncoded:()=>ad,toEncoderXml:()=>Yte,toEquivalence:()=>Kte,toFormatter:()=>zte,toIso:()=>Xte,toIsoFocus:()=>tre,toIsoSource:()=>ere,toJsonSchemaDocument:()=>Jte,toRepresentation:()=>Vte,toStandardJSONSchemaV1:()=>XY,toStandardSchemaV1:()=>YY,toTaggedUnion:()=>P$,toType:()=>oo,withArrayLengthConstraints:()=>BS,withConstructorDefault:()=>R$,withDecodingDefault:()=>_$,withDecodingDefaultKey:()=>sA,withDecodingDefaultType:()=>$7,withDecodingDefaultTypeKey:()=>B7});var XU=globalThis.BigInt;var eD=e=>e>XU(Number.MAX_SAFE_INTEGER)||e<XU(Number.MIN_SAFE_INTEGER)?_():N(Number(e));var cw=BigInt(0),DZ=BigInt(1),Ri=BigInt(1e3),tc=BigInt(1024),rD=[{symbol:"B",factor:DZ,names:["B","byte","bytes"]},{symbol:"kB",factor:Ri,names:["kB","kilobyte","kilobytes"]},{symbol:"MB",factor:Ri**BigInt(2),names:["MB","megabyte","megabytes"]},{symbol:"GB",factor:Ri**BigInt(3),names:["GB","gigabyte","gigabytes"]},{symbol:"TB",factor:Ri**BigInt(4),names:["TB","terabyte","terabytes"]},{symbol:"PB",factor:Ri**BigInt(5),names:["PB","petabyte","petabytes"]},{symbol:"EB",factor:Ri**BigInt(6),names:["EB","exabyte","exabytes"]},{symbol:"ZB",factor:Ri**BigInt(7),names:["ZB","zettabyte","zettabytes"]},{symbol:"YB",factor:Ri**BigInt(8),names:["YB","yottabyte","yottabytes"]},{symbol:"RB",factor:Ri**BigInt(9),names:["RB","ronnabyte","ronnabytes"]},{symbol:"QB",factor:Ri**BigInt(10),names:["QB","quettabyte","quettabytes"]}],LZ=[rD[0],{symbol:"KiB",factor:tc,names:["KiB","kibibyte","kibibytes"]},{symbol:"MiB",factor:tc**BigInt(2),names:["MiB","mebibyte","mebibytes"]},{symbol:"GiB",factor:tc**BigInt(3),names:["GiB","gibibyte","gibibytes"]},{symbol:"TiB",factor:tc**BigInt(4),names:["TiB","tebibyte","tebibytes"]},{symbol:"PiB",factor:tc**BigInt(5),names:["PiB","pebibyte","pebibytes"]},{symbol:"EiB",factor:tc**BigInt(6),names:["EiB","exbibyte","exbibytes"]},{symbol:"ZiB",factor:tc**BigInt(7),names:["ZiB","zebibyte","zebibytes"]},{symbol:"YiB",factor:tc**BigInt(8),names:["YiB","yobibyte","yobibytes"]}],BZ=[...rD,...LZ.slice(1)],$Z=new Map(BZ.flatMap(e=>e.names.map(t=>[t,e])));var uw=e=>e;var El=e=>{throw new Error(`Invalid ByteSize: ${e}`)},nD=e=>!Number.isSafeInteger(e)||e<0?El(`expected a non-negative safe integer, received ${e}`):uw(BigInt(e));var oD=e=>{let t=/^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(e);if(t===null)return El(`unsupported syntax ${JSON.stringify(e)}`);let r=$Z.get(t[3]);if(r===void 0)return El(`unsupported unit ${JSON.stringify(t[3])}`);let n=t[2]??"",o=BigInt(10)**BigInt(n.length),s=BigInt(t[1]+n)*r.factor;return s%o!==cw?El(`${JSON.stringify(e)} does not represent an integral number of bytes`):uw(s/o)},sD=xs(oD),dy=e=>{switch(typeof e){case"bigint":return e<cw?El(`expected a non-negative bigint, received ${e}`):uw(e);case"number":return nD(e);case"string":return oD(e)}return El(`unsupported input ${e}`)},fw=xs(dy),iD=e=>typeof e=="bigint"?dy(e):nD(e);var aD=e=>typeof e=="bigint"&&e>=cw;var py=e=>e,cD=eD;var fD="~effect/Chunk";function uD(e,t,r,n,o){for(let s=t;s<Math.min(e.length,t+o);s++)r[n+s-t]=e[s];return r}var lD=[],dw=e=>Wr((t,r)=>{if(t.length!==r.length)return!1;let n=Iu(t),o=Iu(r);for(let s=0;s<n.length;s++)if(!e(n[s],o[s]))return!1;return!0}),qZ=dw(Z),zZ={[fD]:{_A:e=>e},toString(){return`Chunk(${j(Iu(this))})`},toJSON(){return{_id:"Chunk",values:pr(Iu(this))}},[Qe](){return this.toJSON()},[ae](e){return Il(e)&&qZ(this,e)},[ie](){return ri(Iu(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return lD[Symbol.iterator]();default:return Iu(this)[Symbol.iterator]()}},pipe(){return V(this,arguments)}},pw=e=>{let t=Object.create(zZ);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=la,t.right=la;break}case"ISingleton":{t.length=1,t.depth=0,t.left=la,t.right=la;break}case"ISlice":{t.length=e.length,t.depth=0,t.left=la,t.right=la;break}}return t},Il=e=>O(e,fD),la=pw({_tag:"IEmpty"}),WZ=()=>la;var KZ=e=>pw({_tag:"ISingleton",a:e}),mw=e=>Il(e)?e:JZ(vt(e)),lw=(e,t,r)=>{switch(e.backing._tag){case"IArray":{uD(e.backing.array,0,t,r,e.length);break}case"IConcat":{lw(e.left,t,r),lw(e.right,t,r+e.left.length);break}case"ISingleton":{t[r]=e.backing.a;break}case"ISlice":{uD(Iu(e.backing.chunk),e.backing.offset,t,r,e.length);break}}};var VZ=e=>{switch(e.backing._tag){case"IEmpty":return lD;case"IArray":return e.backing.array;default:{let t=new Array(e.length);return lw(e,t,0),e.backing={_tag:"IArray",array:t},e.left=la,e.right=la,e.depth=0,t}}},Iu=VZ;var JZ=e=>e.length===0?WZ():e.length===1?KZ(e[0]):pw({_tag:"IArray",array:e});var dD=e=>e.length;var Tu=ul,pD=pu,mD=WN,hD=KN,xD=VN,gD=p0,yD=JN;var xy=Vg;var gy=m0;var hw=ZN,SD=QN;var xw=YN;var gw=h0,yw=_p,bD=x0;var ED=g0,Yp=XN;var ID=Pp;var TD=b0;var wD=tU;var Sw=I0;var Tl=e=>GZ(typeof e=="string"?ZZ.encode(e):e),wu=e=>{let t=YZ(e),r=t.length;if(r%4!==0)return re(new Ho({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let n=t.indexOf("=");if(n!==-1&&(n<r-2||n===r-2&&t[r-1]!=="="))return re(new Ho({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let o=t.endsWith("==")?2:t.endsWith("=")?1:0,s=new Uint8Array(3*(r/4)-o);for(let i=0,a=0;i<r;i+=4,a+=3){let c=yy(t.charCodeAt(i))<<18|yy(t.charCodeAt(i+1))<<12|yy(t.charCodeAt(i+2))<<6|yy(t.charCodeAt(i+3));s[a]=c>>16,s[a+1]=c>>8&255,s[a+2]=c&255}return X(s)}catch(o){return re(new Ho({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},vD=e=>Vr(wu(e),t=>QZ.decode(t)),GZ=e=>{let t=e.length,r="",n;for(n=2;n<t;n+=3)r+=_s[e[n-2]>>2],r+=_s[(e[n-2]&3)<<4|e[n-1]>>4],r+=_s[(e[n-1]&15)<<2|e[n]>>6],r+=_s[e[n]&63];return n===t+1&&(r+=_s[e[n-2]>>2],r+=_s[(e[n-2]&3)<<4],r+="=="),n===t&&(r+=_s[e[n-2]>>2],r+=_s[(e[n-2]&3)<<4|e[n-1]>>4],r+=_s[(e[n-1]&15)<<2],r+="="),r},ZZ=new TextEncoder,QZ=new TextDecoder,YZ=e=>e.replace(/[\n\r]/g,""),_s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Xp=new Uint8Array(123).fill(255);for(let e=0;e<_s.length;e++)Xp[_s.charCodeAt(e)]=e;Xp[61]=0;var yy=e=>{if(e>=Xp.length||Xp[e]===255)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);return Xp[e]};var by="~effect/HashMap",Ps=5,tm=1<<Ps,XZ=tm/4,CD=tm/2,e5=tm-1,t5=e=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),em=(e,t)=>e>>>t&e5,rc=(e,t)=>1<<em(e,t),Sy=(e,t)=>t5(e&t-1);function AD(e,t,r,n,o,s){if(t>32)throw new Error("HashMap: max depth exceeded");let i=rc(r,t),a=rc(o,t);if(i===a){let f=AD(e,t+Ps,r,n,o,s);return new Au(e,i,[f])}let c=i|a,u=i>>>0<a>>>0?[n,s]:[s,n];return new Au(e,c,u)}var r5=Be("HashMap"),kD=(e,t)=>he(J(e),J(t)),RD=e=>{let t=0;for(let r=0;r<e.length;r++){let n=e[r];n&&(t^=n.subtreeHash())}return t},vu=class{canEdit(t){return this.edit===t}subtreeHash(){let t=this._hash;if(t===void 0){let r=$c;t=this.computeHash(),r===$c&&(this._hash=t)}return t}},Iw=class extends vu{_tag="EmptyNode";edit=0;get size(){return 0}get(t,r,n){return _()}has(t,r,n){return!1}set(t,r,n,o,s,i){return i.value=!0,new Cu(t,n,o,s)}remove(t,r,n,o,s){return this}canEdit(t){return!1}computeHash(){return 0}},Cu=class e extends vu{_tag="LeafNode";edit;hash;key;value;constructor(t,r,n,o){super(),this.edit=t,this.hash=r,this.key=n,this.value=o}get size(){return 1}get(t,r,n){return this.hash===r&&Z(this.key,n)?N(this.value):_()}has(t,r,n){return this.hash===r&&Z(this.key,n)}set(t,r,n,o,s,i){if(this.canEdit(t)&&(this._hash=void 0),this.hash===n&&Z(this.key,o))return Z(this.value,s)?this:this.canEdit(t)?(this.value=s,this):new e(t,n,o,s);if(i.value=!0,this.hash===n)return new Tw(t,n,[[this.key,this.value],[o,s]]);let a=rc(n,r),c=rc(this.hash,r);if(a===c)return new Au(t,a,[this.set(t,r+Ps,n,o,s,i)]);let u=a|c,f=a>>>0<c>>>0?[new e(t,n,o,s),this]:[this,new e(t,n,o,s)];return new Au(t,u,f)}remove(t,r,n,o,s){if(this.hash===n&&Z(this.key,o)){s.value=!0;return}return this}computeHash(){return kD(this.key,this.value)}},Tw=class e extends vu{_tag="CollisionNode";edit;hash;entries;constructor(t,r,n){super(),this.edit=t,this.hash=r,this.entries=n}get size(){return this.entries.length}get(t,r,n){if(this.hash!==r)return _();for(let[o,s]of this.entries)if(Z(o,n))return N(s);return _()}has(t,r,n){if(this.hash!==r)return!1;for(let[o]of this.entries)if(Z(o,n))return!0;return!1}set(t,r,n,o,s,i){if(this.canEdit(t)&&(this._hash=void 0),this.hash!==n)return i.value=!0,AD(t,r,this.hash,this,n,new Cu(t,n,o,s));for(let a=0;a<this.entries.length;a++)if(Z(this.entries[a][0],o)){if(Z(this.entries[a][1],s))return this;if(this.canEdit(t))return this.entries[a]=[o,s],this;let c=[...this.entries];return c[a]=[o,s],new e(t,this.hash,c)}return i.value=!0,this.canEdit(t)?(this.entries.push([o,s]),this):new e(t,this.hash,[...this.entries,[o,s]])}remove(t,r,n,o,s){if(this.canEdit(t)&&(this._hash=void 0),this.hash!==n)return this;let i=this.entries.findIndex(([c])=>Z(c,o));if(i===-1)return this;if(s.value=!0,this.entries.length===1)return;if(this.entries.length===2){let c=this.entries[i===0?1:0];return new Cu(t,this.hash,c[0],c[1])}if(this.canEdit(t))return this.entries.splice(i,1),this;let a=[...this.entries];return a.splice(i,1),new e(t,this.hash,a)}computeHash(){let t=0,r=this.entries;for(let n=0;n<r.length;n++)t^=kD(r[n][0],r[n][1]);return t}},Au=class e extends vu{_tag="IndexedNode";edit;_size;bitmap;children;constructor(t,r,n){super(),this.edit=t,this.bitmap=r,this.children=n}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,r)=>t+r.size,0)),this._size}get(t,r,n){let o=rc(r,t);if((this.bitmap&o)===0)return _();let s=Sy(this.bitmap,o);return this.children[s].get(t+Ps,r,n)}has(t,r,n){let o=rc(r,t);if((this.bitmap&o)===0)return!1;let s=Sy(this.bitmap,o);return this.children[s].has(t+Ps,r,n)}set(t,r,n,o,s,i){this.canEdit(t)&&(this._hash=void 0);let a=rc(n,r),c=Sy(this.bitmap,a);if((this.bitmap&a)!==0){let u=this.children[c],f=u.set(t,r+Ps,n,o,s,i);if(u===f)return this;if(this.canEdit(t))return this.children[c]=f,this;let p=[...this.children];return p[c]=f,new e(t,this.bitmap,p)}else{i.value=!0;let u=new Cu(t,n,o,s),f=this.bitmap|a;if(this.canEdit(t))return this.children.splice(c,0,u),this.bitmap=f,this._size=void 0,this.children.length>CD?this.expand(t,f,this.children):this;let p=[...this.children];return p.splice(c,0,u),p.length>CD?this.expand(t,f,p):new e(t,f,p)}}remove(t,r,n,o,s){this.canEdit(t)&&(this._hash=void 0);let i=rc(n,r);if((this.bitmap&i)===0)return this;let a=Sy(this.bitmap,i),c=this.children[a],u=c.remove(t,r+Ps,n,o,s);if(!s.value)return this;if(u===void 0){let p=this.bitmap^i;if(p===0)return;if(this.children.length===2){let h=this.children[a===0?1:0];if(h._tag==="LeafNode")return h}if(this.canEdit(t))return this.children.splice(a,1),this.bitmap=p,this._size=void 0,this;let m=[...this.children];return m.splice(a,1),new e(t,p,m)}if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.bitmap,f)}expand(t,r,n){let o=new globalThis.Array(tm),s=0;for(let i=0;i<tm;i++)(r&1<<i)!==0&&(o[i]=n[s++]);return new ww(t,n.length,o)}computeHash(){return RD(this.children)}},ww=class e extends vu{_tag="ArrayNode";edit;_size;count;children;constructor(t,r,n){super(),this.edit=t,this.count=r,this.children=n}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,r)=>t+(r?.size??0),0)),this._size}get(t,r,n){let o=em(r,t),s=this.children[o];return s?s.get(t+Ps,r,n):_()}has(t,r,n){let o=em(r,t),s=this.children[o];return s?s.has(t+Ps,r,n):!1}set(t,r,n,o,s,i){this.canEdit(t)&&(this._hash=void 0);let a=em(n,r),c=this.children[a];if(c){let u=c.set(t,r+Ps,n,o,s,i);if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.count,f)}else{i.value=!0;let u=new Cu(t,n,o,s);if(this.canEdit(t))return this.children[a]=u,this.count++,this._size=void 0,this;let f=[...this.children];return f[a]=u,new e(t,this.count+1,f)}}remove(t,r,n,o,s){this.canEdit(t)&&(this._hash=void 0);let i=em(n,r),a=this.children[i];if(!a)return this;let c=a.remove(t,r+Ps,n,o,s);if(!s.value)return this;let u=this.count-(c?0:1);if(u<XZ)return this.pack(t,i,c);if(a===c)return this;if(this.canEdit(t))return this.children[i]=c,c||(this.count=u),this._size=void 0,this;let f=[...this.children];return f[i]=c,new e(t,u,f)}pack(t,r,n){let o=[],s=0,i=1;for(let a=0;a<this.children.length;a++){let c=a===r?n:this.children[a];c&&(o.push(c),s|=i),i<<=1}return new Au(t,s,o)}computeHash(){return RD(this.children)}},Ey=class{stack;project;entries=[];index=0;constructor(t,r){this.stack=[t],this.project=r}next(){for(;;){if(this.index<this.entries.length){let r=this.entries[this.index++];return{done:!1,value:this.project(r[0],r[1])}}if(this.stack.length===0)return{done:!0,value:void 0};let t=this.stack.pop();switch(t._tag){case"LeafNode":{let r=t;return{done:!1,value:this.project(r.key,r.value)}}case"CollisionNode":{this.entries=t.entries,this.index=0;break}case"IndexedNode":case"ArrayNode":{let r=t.children;for(let n=r.length-1;n>=0;n--){let o=r[n];o&&this.stack.push(o)}}}}}[Symbol.iterator](){return this}},n5=(e,t)=>[e,t];var rm=class{[by]=by;_editable;_edit;_root;_size;constructor(t,r,n,o){this._editable=t,this._edit=r,this._root=n,this._size=o}get size(){return this._size}[Symbol.iterator](){return new Ey(this._root,n5)}[ae](t){if(vw(t)){let r=t;if(this.size!==r.size)return!1;for(let[n,o]of this){let s=Md(t,PD(n));if(fe(s)||!Z(o,s.value))return!1}return!0}return!1}[ie](){return _r(r5^this._root.subtreeHash())}[Qe](){return pr(this)}toString(){return`HashMap(${j(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([t,r])=>[pr(t),pr(r)])}}pipe(){return V(this,arguments)}},OD=new Iw,vw=e=>O(e,by),Cw=()=>new rm(!1,0,OD,0);var _D=e=>{let t=OD,r=0,n={value:!1};for(let[o,s]of e){let i=J(o);n.value=!1,t=t.set(NaN,0,i,o,s,n),n.value&&r++}return new rm(!1,0,t,r)};var PD=d(2,(e,t)=>e._root.get(0,J(t),t));var Aw=d(2,(e,t)=>e._root.has(0,J(t),t));var o5=(e,t,r,n)=>{let o=e,s={value:!1},i=o._editable?o._edit:NaN,a=o._root.set(i,0,r,t,n,s);return o._editable?(o._root=a,s.value&&o._size++,e):o._root===a?e:new rm(!1,o._edit,a,o._size+(s.value?1:0))},kw=d(3,(e,t,r)=>o5(e,t,J(t),r)),Rw=e=>new Ey(e._root,F);var MD=e=>e[Symbol.iterator](),Iy=e=>e.size;var Ty=vw;var Ow=_D;var a5=MD,nm=e=>Array.from(a5(e)),ND=Iy;var om="~effect/HashSet",c5=Be(om),u5={[ie](){return _r(he(c5,J(vy(this))))},[ae](e){return _w(e)&&Cy(this)===Cy(e)&&LD(this,t=>DD(e,t))},[Symbol.iterator](){return Rw(vy(this))},toString(){return`HashSet(${j(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:pr(Array.from(this))}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},f5=e=>{let t=Object.create(u5);return t[om]=om,t.keyMap=e,t},_w=e=>O(e,om),vy=e=>e.keyMap;var UD=e=>{let t=Cw();for(let r of e)t=kw(t,r,!0);return f5(t)},DD=(e,t)=>Aw(vy(e),t);var Cy=e=>Iy(vy(e));var LD=(e,t)=>{for(let r of e)if(!t(r))return!1;return!0};var Pw=UD,Ay=_w;var BD=Cy;var Mw="~effect/http/Cookies",HD=e=>O(e,Mw),Fw="~effect/http/Cookies/Cookie",jD=e=>O(e,Fw),$D="~effect/http/Cookies/CookieError",Nw=class extends xP{},ku=class e extends sr("CookiesError"){static fromReason(t,r){return new e({reason:new Nw({_tag:t,cause:r})})}[$D]=$D;get message(){return this.reason._tag}};var d5={[Mw]:Mw,...kt,toJSON(){return{_id:"effect/Cookies",cookies:Mx(this.cookies,e=>e.toJSON())}},pipe(){return V(this,arguments)}},Dw=e=>{let t=Object.create(d5);return t.cookies=e,t},Lw=e=>{let t={};for(let r of e)B(t,r.name,r);return Dw(t)},Ry=e=>{let t=typeof e=="string"?[e]:e,r=[];for(let n of t){let o=p5(n.trim());o&&r.push(o)}return Lw(r)};function p5(e){let t=e.split(";").map(a=>a.trim()).filter(a=>a!=="");if(t.length===0)return;let r=t[0].indexOf("=");if(r===-1)return;let n=t[0].slice(0,r);if(!qD.test(n))return;let o=t[0].slice(r+1),s=S5(o);if(t.length===1)return Object.assign(Object.create(Uw),{name:n,value:s,valueEncoded:o});let i={};for(let a=1;a<t.length;a++){let c=t[a],u=c.indexOf("="),f=u===-1?c:c.slice(0,u).trim(),p=u===-1?void 0:c.slice(u+1).trim();switch(f.toLowerCase()){case"domain":{if(p===void 0)break;let m=p.trim().replace(/^\./,"");m&&(i.domain=m);break}case"expires":{if(p===void 0)break;let m=new Date(p);isNaN(m.getTime())||(i.expires=m);break}case"max-age":{if(p===void 0)break;let m=parseInt(p,10);isNaN(m)||(i.maxAge=ap(m));break}case"path":{if(p===void 0)break;p[0]==="/"&&(i.path=p);break}case"priority":{if(p===void 0)break;switch(p.toLowerCase()){case"low":i.priority="low";break;case"medium":i.priority="medium";break;case"high":i.priority="high";break}break}case"httponly":{i.httpOnly=!0;break}case"secure":{i.secure=!0;break}case"partitioned":{i.partitioned=!0;break}case"samesite":{if(p===void 0)break;switch(p.toLowerCase()){case"lax":i.sameSite="lax";break;case"strict":i.sameSite="strict";break;case"none":i.sameSite="none";break}break}}}return Object.assign(Object.create(Uw),{name:n,value:s,valueEncoded:o,options:Object.keys(i).length>0?i:void 0})}var m5=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,qD=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,h5=/^[\u0009\u0020-\u003a\u003c-\u007e\u0080-\u00ff]+$/,x5=/^[\u0020-\u003a\u003c-\u007e]+$/,Uw={[Fw]:Fw,...kt,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};function g5(e,t,r){let n=encodeURIComponent(t),o=zD(e,n,r);return o!==void 0?re(o):X(Object.assign(Object.create(Uw),{name:e,value:t,valueEncoded:n,options:r}))}function zD(e,t,r){if(!qD.test(e))return ku.fromReason("InvalidCookieName");if(t&&!m5.test(t))return ku.fromReason("InvalidCookieValue");if(r?.domain!==void 0&&!h5.test(r.domain))return ku.fromReason("InvalidCookieDomain");if(r?.path!==void 0&&!x5.test(r.path))return ku.fromReason("InvalidCookiePath");if(r?.maxAge!==void 0&&!Wn($e(r.maxAge)))return ku.fromReason("CookieInfinityMaxAge")}var WD=(e,t,r)=>Xc(g5(e,t,r));function y5(e){let t=zD(e.name,e.valueEncoded,e.options);if(t!==void 0)throw t;let r=e.name+"="+e.valueEncoded;if(e.options===void 0)return r;let n=e.options;if(n.maxAge!==void 0){let o=ui($e(n.maxAge));r+="; Max-Age="+Math.trunc(o)}if(n.domain!==void 0&&(r+="; Domain="+n.domain),n.path!==void 0&&(r+="; Path="+n.path),n.priority!==void 0)switch(n.priority){case"low":r+="; Priority=Low";break;case"medium":r+="; Priority=Medium";break;case"high":r+="; Priority=High";break}if(n.expires!==void 0&&(r+="; Expires="+n.expires.toUTCString()),n.httpOnly&&(r+="; HttpOnly"),n.secure&&(r+="; Secure"),n.partitioned&&(r+="; Partitioned"),n.sameSite!==void 0)switch(n.sameSite){case"lax":r+="; SameSite=Lax";break;case"strict":r+="; SameSite=Strict";break;case"none":r+="; SameSite=None";break}return r}var KD=e=>{let t={},r=Object.values(e.cookies);for(let n=0;n<r.length;n++){let o=r[n];B(t,o.name,o.value)}return t},VD=e=>Object.values(e.cookies).map(y5);var S5=e=>{try{return decodeURIComponent(e)}catch{return e}};var Ru=new WeakMap,JD=e=>{if(Ru.has(e))return Ru.get(e);throw new Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var GD="~effect/Redacted",sm=e=>O(e,GD),Ou=(e,t)=>{let r=Object.create(E5);return t?.label&&(r.label=t.label),Ru.set(r,e),r},E5={[GD]:{_A:e=>e},label:void 0,...wr,toJSON(){return this.toString()},toString(){return`<redacted${On(this.label)?":"+this.label:""}>`},[ie](){return J(Ru.get(this))},[ae](e){return sm(e)&&Z(Ru.get(this),Ru.get(e))}},nc=JD;var ZD=e=>Wr((t,r)=>e(nc(t),nc(r)));var $w=Symbol.for("~effect/http/Headers"),QD=e=>O(e,$w),im=Object.defineProperties(Object.create(null),{[$w]:{value:$w},[jc]:{value(e){return I5(this,Re(e,jw))}},toJSON:{value(){return ho(this)}},[ae]:{value(e){return Hw(this,e)}},[ie]:{value(){return $d(this)}},toString:{value:kt.toString},[Qe]:{value:kt[Qe]}}),_y=e=>Object.assign(Object.create(im),e),Hw=V_(Gc()),wl=Object.create(im),Zo=e=>{if(e===void 0)return wl;if(Symbol.iterator in e){let r=Object.create(im);for(let[n,o]of e)r[n.toLowerCase()]=o;return r}let t=Object.create(im);for(let[r,n]of Object.entries(e))Array.isArray(n)?t[r.toLowerCase()]=n.join(", "):n!==void 0&&(t[r.toLowerCase()]=n);return t},YD=e=>Object.setPrototypeOf(e,im);var am=d(3,(e,t,r)=>{let n=_y(e);return n[t.toLowerCase()]=r,n}),XD=d(2,(e,t)=>_y({...e,...Zo(t)})),vl=d(2,(e,t)=>{let r=_y(e);return Object.assign(r,t),r}),oc=d(2,(e,t)=>{let r=_y(e);return delete r[t.toLowerCase()],r});var I5=d(2,(e,t)=>{let r={...e},n=o=>{if(typeof o=="string"){let s=o.toLowerCase();s in e&&(r[s]=Ou(e[s]))}else for(let s in e)s.search(o)!==-1&&(r[s]=Ou(e[s]))};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),e1=(e,t)=>{for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="string"){if(n.toLowerCase()===e.toLowerCase())return!0}else if(e.search(n)!==-1)return!0}return!1},jw=Ce("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key","AWSAccessKeyId","Signature","sig","X-Goog-Signature"]});var qw="~effect/http/UrlParams",zw=e=>O(e,qw),T5={...wr,[qw]:qw,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:"UrlParams",params:Object.fromEntries(this.params)}},[ae](e){return Ww(this,e)},[ie](){return ri(this.params.flat())}},Cl=e=>{let t=Object.create(T5);return t.params=e,t},_u=e=>{if(zw(e))return e;let t=t1(e),r=[];for(let n=0;n<t.length;n++)if(Array.isArray(t[n][0])){let[o,s]=t[n];r.push([`${o[0]}[${o.slice(1).join("][")}]`,s])}else r.push(t[n]);return Cl(r)},t1=e=>{let t=typeof e[Symbol.iterator]=="function"?vt(e):Object.entries(e),r=[];for(let[n,o]of t)if(Array.isArray(o))for(let s=0;s<o.length;s++)o[s]!==void 0&&r.push([n,String(o[s])]);else if(o!==null&&typeof o=="object"){let s=t1(o);for(let[i,a]of s)r.push([[n,...typeof i=="string"?[i]:i],a])}else o!==void 0&&r.push([n,String(o)]);return r},Ww=Wr((e,t)=>w5(e.params,t.params)),w5=Q_($_([Gc(),Gc()])),r1=Cl([]);var n1=d(2,(e,t)=>NI(e.params,([r])=>r===t).pipe(Ut(([,r])=>r)));var o1=d(2,(e,t)=>{let r=_u(t).params.slice(),n=new Set;for(let o=0;o<r.length;o++)n.add(r[o][0]);for(let o=0;o<e.params.length;o++)n.has(e.params[o][0])||r.push(e.params[o]);return Cl(r)});var v5=e=>{let t={};for(let[r,n]of e.params)if(!Object.hasOwn(t,r))B(t,r,n);else{let o=t[r];typeof o=="string"?B(t,r,[o,n]):o.push(n)}return t},s1=v5;var Kw="~effect/Graph",Vw=e=>O(e,Kw),i1=e=>e;var C5=(e,t,r)=>(e==="directed"?t.source===r.source&&t.target===r.target:t.source===r.source&&t.target===r.target||t.source===r.target&&t.target===r.source)&&Z(t.data,r.data),A5=(e,t)=>e==="directed"?J(t):_r(he(J(t.data),k5(t.source,t.target))),k5=(e,t)=>he(0,J(e))+he(0,J(t)),R5=Be("Graph"),O5={[Kw]:{_N:e=>e,_E:e=>e},[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[Qe](){return this.toJSON()},[ae](e){if(O(e,Kw)){let t=i1(e);if(this.nodes.size!==t.nodes.size||this.edges.size!==t.edges.size||this.type!==t.type)return!1;for(let[r,n]of this.nodes)if(!t.nodes.has(r)||!Z(n,t.nodes.get(r)))return!1;for(let[r,n]of this.edges){let o=t.edges.get(r);if(o===void 0||!C5(this.type,n,o))return!1}return!0}return!1},[ie](){let e=R5;e=e^Be(this.type),e=e^qt(this.nodes.size),e=e^qt(this.edges.size);for(let[t,r]of this.nodes)e^=he(J(t),J(r));for(let[t,r]of this.edges)e^=he(J(t),A5(this.type,r));return _r(e)},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return`Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`},pipe(){return V(this,arguments)}},_5=(e,t)=>{let r=Object.create(O5);return r.type=e,r.mutable=t,r.transforming=!1,r.nodes=new Map,r.edges=new Map,r.adjacency=new Map,r.reverseAdjacency=new Map,r.nextNodeIndex=0,r.nextEdgeIndex=0,r.acyclic=N(!0),r};var cm=e=>{let t=i1(e);return{type:e.type,nodes:Array.from(t.nodes,([r,n])=>({index:r,data:n})).sort((r,n)=>r.index-n.index),edges:Array.from(t.edges,([r,n])=>({index:r,source:n.source,target:n.target,data:n.data})).sort((r,n)=>r.index-n.index)}},My=e=>{let t=_5(e.type,!1);for(let r of e.nodes)t.nodes.set(r.index,r.data),t.adjacency.set(r.index,[]),t.reverseAdjacency.set(r.index,[]);for(let r of e.edges)t.edges.set(r.index,{source:r.source,target:r.target,data:r.data}),t.adjacency.get(r.source).push(r.index),t.reverseAdjacency.get(r.target).push(r.index),e.type==="undirected"&&(t.adjacency.get(r.target).push(r.index),t.reverseAdjacency.get(r.source).push(r.index));return t.nextNodeIndex=e.nodes.length===0?0:e.nodes[e.nodes.length-1].index+1,t.nextEdgeIndex=e.edges.length===0?0:e.edges[e.edges.length-1].index+1,t.acyclic=_(),t};function da(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Fy(e){return t=>da(t)?.[e]}var ro="~structural",Pu="~identifier",um="~sentinels",Ny="~constructor",a1=["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],Al=Fy("identifier"),Jw=Fy(Pu),Gw=Fy("title");var fm=mo(e=>{let t=da(e)?.identifier;return typeof t=="string"?t:e.getExpected(fm)}),c1=new Set([um,ro,"representation","arbitraryConstraint","toJsonSchema","toCode","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso","toCodecArbitrary"]);var ve=Symbol();var Dr=Mr,no=Dr(ve),nt=Dr(ve),lm=e=>e===ve?_():N(e),Zw=e=>e._tag==="None"?no:Dr(e.value);var pm="~effect/SchemaIssue/Issue";function Yw(e){return O(e,pm)&&e[pm]===pm}function M5(e){return Object.hasOwn(e,"input")}var Ao=class{[pm]=pm;constructor(t,r){r?.reportInput===!0&&t!==ve&&(this.input=t)}},u1=class extends Ao{_tag="Filter";filter;issue;constructor(e,t,r,n){super(r,n),this.filter=e,this.issue=t}},f1=class extends Ao{_tag="Encoding";ast;issue;constructor(e,t,r,n){super(r,n),this.ast=e,this.issue=t}},Ct=class extends Ao{_tag="Pointer";path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},Yt=class extends Ao{_tag="MissingKey";annotations;constructor(e){super(),this.annotations=e}},Mu=class extends Ao{_tag="UnexpectedKey";ast;constructor(e,t,r){super(t,r),this.ast=e}},Pt=class extends Ao{_tag="Composite";ast;issues;constructor(e,t,r,n){super(r,n),this.ast=e,this.issues=t}},at=class extends Ao{_tag="InvalidType";ast;constructor(e,t,r){super(t,r),this.ast=e}},le=class extends Ao{_tag="InvalidValue";annotations;constructor(e,t,r){super(t,r),this.annotations=e}};function tn(e,t,r,n,o){return new Pt(e,[new Ct([t],r)],n,o)}var mm=class extends Ao{_tag="Forbidden";annotations;constructor(e,t,r){super(t,r),this.annotations=e}},hm=class extends Ao{_tag="AnyOf";ast;issues;constructor(e,t,r,n){super(r,n),this.ast=e,this.issues=t}},l1=class extends Ao{_tag="OneOf";ast;successes;constructor(e,t,r,n){super(r,n),this.ast=e,this.successes=t}};function Qw(e,t,r){if(Yw(e))return e;if(typeof e=="string")return new le({message:e},t,r);let n=typeof e.issue=="string"?new le({message:e.issue},t,r):e.issue;return new Ct(e.path,n)}function d1(e,t,r){if(e!==void 0)return typeof e=="boolean"?e?void 0:new le(void 0,t,r):Qw(e,t,r)}function p1(e,t,r,n){return Array.isArray(t)?bt(t)?t.length===1?Qw(t[0],r,n):new Pt(e,Bo(t,o=>Qw(o,r,n)),r,n):void 0:d1(t,r,n)}var m1=e=>{let t=Ol(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return ic(fm(e.ast),e);case"InvalidValue":{let r=Xw(e);if(r!==void 0)return ic(r,e);let n=Uy(e);return n===void 0?"Expected a valid value":`Invalid data ${n}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let r=Uy(e);return r===void 0?"Expected no excess property":`Unexpected key with value ${r}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let r=Uy(e);return r===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${r}`}}},h1=e=>Ol(e.issue)??Ol(e);function x1(e){return t=>({issues:Rl(t,[],e?.leafHook??m1,e?.checkHook??h1)})}function Uy(e){return M5(e)?j(e.input):void 0}function Xw(e){let t=e.annotations?.expected;return typeof t=="string"?t:void 0}function ic(e,t){let r=Uy(t);return r===void 0?`Expected ${e}`:`Expected ${e}, got ${r}`}function Rl(e,t,r,n){switch(e._tag){case"Filter":{let o=n(e);if(o!==void 0)return[{path:t,message:o}];if(e.issue._tag!=="InvalidValue")return Rl(e.issue,t,r,n);let s=Xw(e.issue);return[{path:t,message:s===void 0?ic(ev(e.filter),e):ic(s,e.issue)}]}case"Encoding":return Rl(e.issue,t,r,n);case"Pointer":return Rl(e.issue,[...t,...e.path],r,n);case"Composite":return e.issues.flatMap(o=>Rl(o,t,r,n));case"AnyOf":return e.issues.length===0?[{path:t,message:Ol(e)??ic(fm(e.ast),e)}]:e.issues.flatMap(o=>Rl(o,t,r,n));default:return[{path:t,message:r(e)}]}}function ev(e){let t=e.annotations?.expected;if(typeof t=="string")return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map(r=>ev(r)).join(" & ")}}function F5(){return e=>dm(e,"")}var g1=F5();function dm(e,t){let r;switch(e._tag){case"Filter":{let n=h1(e);if(n!==void 0)r=n;else{if(e.issue._tag!=="InvalidValue")return dm(e.issue,t);let o=Xw(e.issue);r=o===void 0?ic(ev(e.filter),e):ic(o,e.issue)}break}case"Encoding":return dm(e.issue,t);case"Pointer":return dm(e.issue,t+hx(e.path));case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map(n=>dm(n,t)).join(`
25
+ `);r=Ol(e)??ic(fm(e.ast),e);break}default:r=m1(e);break}return t?`${r}
26
+ at ${t}`:r}function Ol(e){if(e._tag==="Pointer")return;if(e._tag==="Encoding")return Ol(e.issue);let r=(e._tag==="Filter"?e.filter.annotations:"annotations"in e?e.annotations:e.ast.annotations)?.[e._tag==="MissingKey"?"messageMissingKey":e._tag==="UnexpectedKey"?"messageUnexpectedKey":"message"];if(typeof r=="string")return r}function xm(e){let t;for(let r of e.reasons){if(!_g(r)||!Yw(r.error))return;t??=r.error}return t}function ko(e,t){let r=xm(e);if(r===void 0)throw new Error(t,{cause:e});return r}var S1=e=>Tl(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),tv=e=>{let t=e.replace(/[\n\r]/g,""),r=t.length;if(r%4===1)return re(new Ho({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${r}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return re(new Ho({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let n=r%4===2?`${t}==`:r%4===3?`${t}=`:t;return n=n.replace(/-/g,"+").replace(/_/g,"/"),wu(n)},b1=e=>Vr(tv(e),t=>N5.decode(t)),N5=new TextDecoder;var gm=e=>Object.assign(Object.create(tI),e);function D5(e){return I1((t,r)=>D(e(t,r)))}function Dy(e){return D5((t,r)=>{let n={message:e(t)};return de(t)?new mm(n,t.value,r):new mm(n)})}var E1=Dy(()=>"Encoding is not supported"),L5=gm({_tag:"Passthrough"});function Oi(){return L5}function Ie(e){return gm({_tag:"Transform",transform:e})}function rn(e){return gm({_tag:"TransformEffect",transform:e})}function Ly(e){return gm({_tag:"TransformOptional",transform:e})}function I1(e){return gm({_tag:"TransformOptionalEffect",transform:e})}function rv(){return Ly(()=>_())}function nv(e){return I1(t=>{let r=Fa(t,ei);return de(r)?I(r):Su(e,N)})}function Fu(){return Ie(globalThis.String)}function By(){return Ie(globalThis.Number)}function T1(){return Ie(globalThis.BigInt)}function ov(){return Ie(e=>new globalThis.Date(e))}function w1(){return Ie(sU)}function v1(e){return rn((t,r)=>Jo({try:()=>JSON.parse(t,e?.reviver),catch:()=>new le({expected:"a valid JSON string"},t,r)}))}function C1(e){return rn((t,r)=>Jo({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw new TypeError("Value cannot be represented as JSON");return n},catch:()=>new le({expected:"a JSON-serializable value"},t,r)}))}function sv(){return Ie(Tl)}function $y(){return Ie(S1)}function Hy(){return Ie(zx)}function A1(){return rn((e,t)=>bu(D0(wu(e)),()=>new le({expected:"a valid Base64 string"},e,t)))}function k1(){return rn((e,t)=>zn(vD(e),{onFailure:()=>D(new le({expected:"a valid Base64 string"},e,t)),onSuccess:I}))}function R1(){return rn((e,t)=>zn(tv(e),{onFailure:()=>D(new le({expected:"a valid Base64Url string"},e,t)),onSuccess:I}))}function O1(){return rn((e,t)=>zn(b1(e),{onFailure:()=>D(new le({expected:"a valid Base64Url string"},e,t)),onSuccess:I}))}function _1(){return rn((e,t)=>zn(zI(e),{onFailure:()=>D(new le({expected:"a valid hexadecimal string"},e,t)),onSuccess:I}))}function P1(){return rn((e,t)=>zn(bP(e),{onFailure:()=>D(new le({expected:"a valid hexadecimal string"},e,t)),onSuccess:I}))}function M1(){return Ie(encodeURIComponent)}function F1(){return rn((e,t)=>{try{return I(globalThis.decodeURIComponent(e))}catch{return D(new le({expected:"a valid URI component"},e,t))}})}function N1(){return Ie(e=>B1(Array.from(e.entries())))}var B5=$1(e=>typeof e=="string"||typeof Blob<"u"&&e instanceof Blob);function U1(){return Ie(e=>{let t=new FormData;return typeof e=="object"&&e!==null&&B5(e).forEach(([n,o])=>{t.append(n,o)}),t})}function D1(){return Ie(e=>B1(Array.from(e.entries())))}var $5=$1(On);function L1(){return Ie(e=>typeof e=="object"&&e!==null?new URLSearchParams($5(e)):new URLSearchParams)}function H5(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),r=t.split("."),n=t.startsWith(".")?1:0;return r.slice(n).map(o=>Dx(o)?globalThis.Number(o):o)}var j5=20;function B1(e){let t={},r=new WeakSet,n=new WeakSet,o=new Map;e.forEach(([s,i])=>{let a=H5(s),c=t;for(let u=0;u<a.length;u++){let f=o.get(c),p=a[u]===""&&f!==void 0?f.length:a[u];f!==void 0&&typeof p=="number"&&(f.length=Math.max(f.length,p+1));let m=Object.hasOwn(c,p),h=m?c[p]:void 0;if(u===a.length-1){let x=o.get(h);if(x!==void 0)B(h,x.length++,i);else if(n.has(h))h.push(i);else if(m){let g=[h,i];n.add(g),B(c,p,g)}else B(c,p,i)}else{let x=a[u+1],g=typeof x=="number"||x==="";if(r.has(h)&&o.has(h)===g)c=h;else{let y={};r.add(y),g&&o.set(y,{parent:c,key:p,length:0}),B(c,p,y),c=y}}}});for(let[s,{key:i,length:a,parent:c}]of Array.from(o).reverse())c[i]===s&&a-Object.keys(s).length<=j5&&B(c,i,Object.assign(new Array(a),s));return t}function $1(e){return t=>{let r=[];function n(o,s){if(e(s))r.push([o,s]);else if(Array.isArray(s))s.every(e)?s.forEach(a=>{r.push([o,a])}):s.forEach((a,c)=>{n(`${o}[${c}]`,a)});else if(typeof s=="object"&&s!==null)for(let[i,a]of Object.entries(s))n(`${o}[${i}]`,a)}for(let[o,s]of Object.entries(t))n(o,s);return r}}var jy=class extends Ra{_tag="Middleware";decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new jy(this.encode,this.decode)}},Sm="~effect/SchemaTransformation/Transformation",et=class extends Ra{[Sm]=Sm;_tag="Transformation";decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new et(this.encode,this.decode)}};function q5(e){return O(e,Sm)&&e[Sm]===Sm}var qy=e=>q5(e)?e:new et(e.decode,e.encode);function Xt(e){return new et(rn(e.decode),rn(e.encode))}function Fe(e){return new et(Ie(e.decode),Ie(e.encode))}function zy(e){return new et(Ly(e.decode),Ly(e.encode))}function H1(){return new et(w1(),Oi())}var z5=new et(Oi(),Oi());function _l(){return z5}var Pl=new et(By(),Fu()),Wy=new et(T1(),Fu()),iv=new et(ov(),Ie(lI)),j1=new et(ov(),Ie(e=>e.getTime()));var av=Xt({decode:(e,t)=>Zt(sD(e),{onNone:()=>D(new le({expected:"a valid ByteSize string"},e,t)),onSome:I}),encode:e=>I(`${e} ${e===BigInt(1)?"byte":"bytes"}`)}),q1=Xt({decode:(e,t)=>Zt(fw(e),{onNone:()=>D(new le({expected:"a non-negative bigint byte count"},e,t)),onSome:I}),encode:e=>I(py(e))}),z1=Xt({decode:(e,t)=>Zt(fw(e),{onNone:()=>D(new le({expected:"a non-negative safe-integer byte count"},e,t)),onSome:I}),encode:(e,t)=>Zt(cD(e),{onNone:()=>D(new le({expected:"a ByteSize representable as a safe integer"},e,t)),onSome:I})}),W5=e=>Gt(e)&&typeof e.message=="string",W1=e=>{let r=Object.hasOwn(e,"cause")?new Error(e.message,{cause:V1(e.cause)}):new Error(e.message);return typeof e.name=="string"&&e.name!=="Error"&&(r.name=e.name),typeof e.stack=="string"&&(r.stack=e.stack),r},K5=e=>{try{let t=qc(e);return t===void 0?j(e):JSON.parse(t)}catch{return j(e)}},V5=(e,t,r)=>{let n={name:e.name,message:typeof e.message=="string"?e.message:""};return t?.includeStack&&typeof e.stack=="string"&&(n.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(n.cause=r(e.cause)),n},K1=e=>{let t=new WeakSet,r=n=>{if(LO(n)){if(t.has(n))return"[Circular]";t.add(n);let o=V5(n,e,r);return t.delete(n),o}return K5(n)};return r},V1=e=>W5(e)?W1(e):e,J1=e=>Fe({decode:W1,encode:t=>K1(e)(t)}),G1=e=>Fe({decode:V1,encode:K1(e)});function Z1(){return Fe({decode:wI,encode:rp})}function Q1(){return Fe({decode:TI,encode:_n})}function Y1(e){return Fe({decode:Qc,encode:e?.onNoneEncoding===null?rp:_n})}function X1(){return zy({decode:N,encode:Yc})}function e2(){return zy({decode:e=>e.pipe(Fa(ei),N),encode:Yc})}var cv=Xt({decode:(e,t)=>URL.canParse(e)?I(new URL(e)):D(new le({expected:"a valid URL string"},e,t)),encode:e=>I(e.href)});var uv=new et(A1(),sv()),t2=new et(k1(),sv()),r2=new et(O1(),$y()),n2=new et(P1(),Hy()),o2=new et(F1(),M1());function s2(e){return new et(v1(e??{}),C1(e))}var i2=new et(N1(),U1()),a2=new et(D1(),L1());function cc(e){return t=>t._tag===e}var Dl=cc("Declaration");var J5=cc("Never");var Nl=cc("Literal"),lv=cc("UniqueSymbol");var Sv=cc("Arrays"),G5=cc("Objects"),x2=cc("Union"),g2=cc("Suspend"),Bt=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},nn={},Yo=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,r=void 0,n=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=r,this.annotations=n}},c2="~effect/Schema",Vt=class{[c2]=c2;annotations;checks;encoding;context;constructor(t=void 0,r=void 0,n=void 0,o=void 0){this.annotations=t,this.checks=r,this.encoding=n,this.context=o}toString(){return`<${this._tag}>`}},uc=class extends Vt{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,r,n,o,s,i,a){super(r,n,o,s),this.typeParameters=e,this.run=t,this.encodingChecks=i,this.encodingRun=a}getParser(){let e;return(t,r)=>t===ve?no:(e??=this.run(this.typeParameters))(t,this,r)}_rebuild(e,t,r,n,o){let s=Uu(this.typeParameters,e);return s===this.typeParameters&&t===this.checks&&r===this.encodingChecks&&n===this.run&&o===this.encodingRun?this:new uc(s,n,this.annotations,t,void 0,this.context,r,o)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e=="string"?e:"<Declaration>"}},Z5=class extends Vt{_tag="Null";getParser(){return tS(this,null)}getExpected(){return"null"}},bv=new Z5;var Q5=class extends Vt{_tag="Undefined";getParser(){return tS(this,void 0)}toCodecJson(){return lt(this,[y2])}getExpected(){return"undefined"}},y2=new Bt(bv,new et(Ie(()=>{}),Ie(()=>null))),Ev=new Q5;var Y5=class extends Vt{_tag="Void";getParser(){let e=Dr(void 0);return t=>t===ve?no:e}toCodecJson(){return lt(this,[y2])}getExpected(){return"void"}},S2=new Y5;var X5=class extends Vt{_tag="Never";getParser(){return Ns(this,DO)}getExpected(){return"never"}},Iv=new X5,eQ=class extends Vt{_tag="Any";getParser(){return Ns(this,oI)}getExpected(){return"any"}},b2=new eQ,tQ=class extends Vt{_tag="Unknown";getParser(){return Ns(this,oI)}getExpected(){return"unknown"}},pa=new tQ,rQ=class extends Vt{_tag="ObjectKeyword";getParser(){return Ns(this,Ld)}getExpected(){return"object | array | function"}},E2=new rQ,I2=class extends Vt{_tag="Enum";enums;constructor(e,t,r,n,o){super(t,r,n,o);for(let[,s]of e)if(typeof s=="number"&&!globalThis.Number.isFinite(s))throw new Error(`A numeric enum value must be finite, got ${j(s)}`);this.enums=e}getParser(){let e=new Set(this.enums.map(([,t])=>t));return Ns(this,t=>e.has(t))}toCodecStringTree(){if(this.enums.some(([e,t])=>typeof t=="number")){let e=Object.fromEntries(this.enums.map(([t,r])=>[globalThis.String(r),r]));return lt(this,[new Bt(new Sn(Object.keys(e).map(t=>new Ln(t))),new et(Ie(t=>e[t]),Fu()))])}return this}getExpected(){return this.enums.map(([e,t])=>JSON.stringify(t)).join(" | ")}};function fv(e){return typeof e=="number"?`parts[${e}]`:e}function dv(e,t,r){if(r.has(e))return!0;if(e.encoding)throw new Error(`TemplateLiteral parts cannot have an encoding at ${fv(t)}`);let n;switch(e._tag){case"String":case"Number":case"BigInt":n=!0;break;case"Literal":n=!e.checks;break;case"TemplateLiteral":{let o=fv(t);n=!e.checks&&e.parts.every((s,i)=>dv(s,`${o}.parts[${i}]`,r));break}case"Union":{let o=fv(t);n=!e.checks&&e.types.every((s,i)=>dv(s,`${o}.types[${i}]`,r));break}default:return!1}return n&&r.add(e),n}var Tv=class extends Vt{_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(e,t,r,n,o){super(t,r,n,o);let s=[],i=[],a=new Set;for(let u=0;u<e.length;u++){let f=e[u];if(!dv(f,u,a))throw new Error(`Invalid TemplateLiteral part ${f._tag}`);s.push(f),i.push(f._tag==="Literal"?globalThis.String(f.literal):void 0)}let c=new Array(s.length+1);c[s.length]=0;for(let u=s.length-1;u>=0;u--)c[u]=c[u+1]+(i[u]?.length??0);this.parts=e,this.encodedParts=s,this.literals=i,this.suffixLengths=c}getParser(e){let t=new Xo(!1,this.parts.map(Uv),[]),r=e(jl(Ro,t,w2(this)));return(n,o)=>{if(n===ve)return no;let s=r(n,o);return s._tag==="Success"?nt:cr(s,{onSuccess:()=>n,onFailure:i=>new Pt(this,[i],n,o)})}}getExpected(){return"string"}matchPart(e,t){return Z2(this,e,t)===void 0?void 0:e}};function T2(e){let t=mo(o=>{if(o._tag!=="Union")return o;let s=Uu(o.types,t);return(o.options?.mode??"anyOf")==="anyOf"&&s===o.types?o:new Sn(s,o.options===void 0?void 0:{...o.options,mode:"anyOf"},o.annotations,o.checks,void 0,o.context)}),r=new Tv(e.map(o=>t(Bn(o)))),n=new Xo(!1,e.map(Uv),[]);return jl(r,n,w2(r))}function w2(e){return new et(rn((t,r)=>{let n=Z2(e,t,r);return n?I(n):D(new le({expected:"a string matching template literal parts"},t,r))}),Ie(t=>t.join("")))}var v2=class extends Vt{_tag="UniqueSymbol";symbol;constructor(e,t,r,n,o){super(t,r,n,o),this.symbol=e}getParser(){return tS(this,this.symbol)}toCodecStringTree(){let e=globalThis.Symbol.keyFor(this.symbol);return lt(this,[new Bt(e===void 0?Iv:new Ln(globalThis.String(this.symbol)),X2.transformation)])}getExpected(){return globalThis.String(this.symbol)}},Ln=class extends Vt{_tag="Literal";literal;constructor(e,t,r,n,o){if(super(t,r,n,o),typeof e=="number"&&!globalThis.Number.isFinite(e))throw new Error(`A numeric literal must be finite, got ${j(e)}`);this.literal=e}getParser(){return tS(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal=="bigint"?u2(this):this}toCodecStringTree(){return typeof this.literal=="string"?this:u2(this)}getExpected(){return typeof this.literal=="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function u2(e){let t=globalThis.String(e.literal);return lt(e,[new Bt(new Ln(t),new et(Ie(()=>e.literal),Ie(()=>t)))])}var nQ=class extends Vt{_tag="String";getParser(){return Ns(this,On)}matchPart(e,t){let r=this.checks;return r&&!t.disableChecks&&Us(r,e,void 0,this,t)?void 0:e}getExpected(){return"string"}},Ro=new nQ,oQ=class extends Vt{_tag="Number";getParser(){return Ns(this,Ud)}matchKey(e,t){return this._match(IQ,e,t)}matchPart(e,t){return this._match(xv,e,t)}_match(e,t,r){if(!e.test(t))return;let n=globalThis.Number(t);return r.disableChecks||!this.checks?n:Us(this.checks,n,void 0,this,r)?void 0:n}toCodecJson(){return this.checks&&(pv(this.checks,"effect/schema/isFinite")||pv(this.checks,"effect/schema/isInt"))?this:lt(this,[hQ])}toCodecStringTree(){return this.toCodecJson()===this?lt(this,[TQ]):lt(this,[wQ])}getExpected(){return"number"}};function pv(e,t){return e.some(r=>r.annotations?.representation?.id===t||r._tag==="FilterGroup"&&pv(r.checks,t))}var wv=new oQ,sQ=class extends Vt{_tag="Boolean";getParser(){return Ns(this,ux)}getExpected(){return"boolean"}},C2=new sQ,iQ=class extends Vt{_tag="Symbol";getParser(){return Ns(this,nI)}matchKey(e,t){return t.disableChecks||!this.checks?e:Us(this.checks,e,void 0,this,t)?void 0:e}toCodecStringTree(){return lt(this,[X2])}getExpected(){return"symbol"}},A2=new iQ,aQ=class extends Vt{_tag="BigInt";getParser(){return Ns(this,FO)}matchPart(e,t){if(!gv.test(e))return;let r=globalThis.BigInt(e);return t.disableChecks||!this.checks?r:Us(this.checks,r,void 0,this,t)?void 0:r}toCodecStringTree(){return lt(this,[CQ])}getExpected(){return"bigint"}},k2=new aQ,Xo=class extends Vt{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,o,s,i,a){super(n,o,s,i),this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=a;let c=!1;for(let u=0;u<t.length;u++)if(Lr(t[u]))c=!0;else if(c)throw new Error("A required element cannot follow an optional element. ts(1257)");if(c&&r.length>1)throw new Error("A required element cannot follow an optional element. ts(1257)");for(let u=1;u<r.length;u++)if(Lr(r[u]))throw new Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let r=this,n,o,s=r.elements.length,i=Math.max(0,r.rest.length-1);function a(f,p){return p<s?n[p]:p>=f?o[p-f+1]:o[0]}let c=f=>{let{input:p,len:m,options:h}=f;if(r.rest.length===0&&m>s)for(let x=s;x<m;x++){let g=new Mu(r,p[x],h),y=new Ct([x],g);if(h.errors==="all")f.issues?f.issues.push(y):f.issues=[y];else return D(new Pt(r,[y],p,h))}return f.issues?D(new Pt(r,f.issues,p,h)):Dr(f.output)},u=(f,p)=>{let m=f.length,h={ast:r,getParser:a,input:f,len:m,tailThreshold:Math.max(s,m-i),output:new globalThis.Array(m),issues:void 0,options:p},x=r.rest.length===0?s:Math.max(m,s+i),g=p.concurrency===void 0?1:Ip(p.concurrency),y=g===1?uQ(h,f,0,x):fQ(h,f,{concurrency:g,end:x});if(!y)return c(h);if(Xe(y))return ur(y,()=>c(h));let E=!0;return L(()=>E?(E=!1,A(y,()=>c(h))):u(f,p))};return(f,p)=>{if(f===ve)return no;try{return Array.isArray(f)?(n||(n=r.elements.map(m=>({ast:m,parser:t(m)})),o=r.rest.map(m=>({ast:m,parser:t(m)}))),u(f,p)):D(new at(r,f,p))}catch(m){return gn(m)}}}_rebuild(e,t,r){let n=Uu(this.elements,e),o=Uu(this.rest,e);return n===this.elements&&o===this.rest&&t===this.checks&&r===this.encodingChecks?this:new Xo(this.isMutable,n,o,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return"array"}};function cQ(e,t,r,n){if(r._tag==="Failure")return Vy(e,e.ast,n,r);let o=r===nt?t:r[Se];if(o!==ve)e.output[n]=o;else{let s=e.getParser(e.tailThreshold,n);if(Lr(s.ast))return;let i=new Ct([n],new Yt(s.ast.context?.annotations));if(e.options.errors==="all")e.issues?e.issues.push(i):e.issues=[i];else return Gn(new Pt(e.ast,[i],e.input,e.options))}}var R2={onItem(e,t,r){let n=r<e.len?t:ve;return e.getParser(e.tailThreshold,r).parser(n,e.options)},step:cQ},uQ=vg()(R2),fQ=Cg()(R2),Vy=(e,t,r,n)=>{if(n.cause.reasons.length===0)return n;let o=xm(n.cause);if(o===void 0)return ir(Ka(n.cause,i=>new Pt(t,[new Ct([r],i)],e.input,e.options)));let s=new Ct([r],o);if(e.options.errors==="all")e.issues?e.issues.push(s):e.issues=[s];else return Gn(new Pt(t,[s],e.input,e.options))},Gy="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function _i(e,t,r=nn){let n,o;function s(i){switch(i._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter(a=>i.matchPart(a,r)!==void 0);case"Number":return(n??=Object.keys(e)).filter(a=>i.matchKey(a,r)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter(a=>Object.prototype.propertyIsEnumerable.call(e,a)&&i.matchKey(a,r)!==void 0);case"Union":return[...new Set(i.types.flatMap(s))];default:return[]}}return s(Nv(Bn(t)))}var vv=class{name;type;constructor(e,t){this.name=e,this.type=t}};function O2(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(O2);default:return!1}}function _2(e){let t=Bl(e);switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(_2);default:return!1}}function lQ(e){return O2(e)&&_2(e)}var Cv=class{parameter;type;constructor(e,t){if(!lQ(e))throw new Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Lr(t)&&!G2(t))throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},bm=class extends Vt{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,o,s,i){super(r,n,o,s),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=i}getParser(e,t=e){let r=this,n=r.propertySignatures.length,o=r.indexSignatures.length;if(!n&&!o)return Ns(r,lx);let s,i,a=()=>(s||(s=r.propertySignatures.map(p=>({parser:t(p.type),name:p.name,type:p.type})),i=o?r.indexSignatures.map(p=>({is:p,parserKey:e(Nv(p.parameter)),parserValue:t(p.type)})):void 0),s),c=()=>{let p=new Set(r.propertySignatures.map(y=>typeof y.name=="number"?globalThis.String(y.name):y.name)),m=(y,E,b,v,T)=>{if(T._tag==="Failure")return Vy(y,r,E,T)??Wt;let S=T===nt?v:T[Se];if(b!==ve&&S!==ve){if(n&&(p.has(E)||p.has(typeof b=="number"?globalThis.String(b):b)))return Wt;B(y.out,b,S)}return Wt},h=(y,E,b,v)=>{if(!v){let k=b.parserKey(E,y.options);if(!Xe(k))return A(eo(k),C=>h(y,E,b,C));v=k}if(v._tag==="Failure")return Vy(y,r,E,v)??Wt;let T=v===nt?E:v[Se],S=y.input[E],w=b.parserValue(S,y.options);return Xe(w)?m(y,E,T,S,w):A(eo(w),k=>m(y,E,T,S,k))},x=(y,E,b)=>{let v=y.input[E],T=b.parserValue(v,y.options);return Xe(T)?m(y,E,E,v,T):A(eo(T),S=>m(y,E,E,v,S))},g=o?Cg()({onItem:(y,[E,b])=>b.is.parameter===Ro?x(y,E,b):h(y,E,b),step:(y,E,b)=>b._tag==="Failure"?b:void 0}):void 0;return ow(function*(y,E){if(y===ve)return ve;if(!(typeof y=="object"&&y!==null&&!Array.isArray(y)))return yield*D(new at(r,y,E));a();let b=y,v={},T={ast:r,input:b,out:v,issues:void 0,options:E},S=E.errors==="all",w=E.onExcessProperty==="error",k=E.concurrency===void 0?1:Ip(E.concurrency),C=o&&w?r.indexSignatures.map(R=>_i(b,R.parameter,E)):void 0;if(w){let R=C?new Set(p):p;if(C)for(let $ of C)for(let te of $)R.add(te);let M=Reflect.ownKeys(b);for(let $=0;$<M.length;$++){let te=M[$];if(!R.has(te)&&Object.prototype.propertyIsEnumerable.call(b,te)){let xe=new Mu(r,b[te],E),Le=new Ct([te],xe);if(S){T.issues?T.issues.push(Le):T.issues=[Le];continue}else return yield*D(new Pt(r,[Le],y,E))}}}if(n){let R=k===1?f2(T,s):dQ(T,s,{concurrency:k});R&&(yield*R)}if(o&&k===1)for(let R=0;R<o;R++){let M=i[R],$=M.is.parameter===Ro?x:h,te=C?.[R]??(M.is.parameter===Ro?Object.keys(b):_i(b,M.is.parameter,E));for(let xe=0;xe<te.length;xe++){let Le=$(T,te[xe],M);if(!Xe(Le))yield*Le;else if(Le._tag==="Failure")return yield*Le}}else if(g){let R=Qt();for(let $=0;$<o;$++){let te=i[$],xe=C?.[$]??(te.is.parameter===Ro?Object.keys(b):_i(b,te.is.parameter,E));for(let Le=0;Le<xe.length;Le++)R.push([xe[Le],te])}let M=g(T,R,{concurrency:k});M&&(yield*M)}return T.issues?yield*D(new Pt(r,T.issues,y,E)):v})};if(o)return c();let u,f=(p,m,h)=>{let x=s[m];return A(eo(h),g=>{let y=mv(p,x,g);if(y)return y;let E=()=>Dr(p.out),b=f2(p,s.slice(m+1));return b?ur(b,E):E()})};return(p,m)=>{if(p===ve)return no;if(m.errors==="all"||m.onExcessProperty!==void 0||m.concurrency!==void 0&&Ip(m.concurrency)!==1)return(u??=c())(p,m);if(!(typeof p=="object"&&p!==null&&!Array.isArray(p)))return D(new at(r,p,m));let h=a(),x=p,g={},y={ast:r,input:x,out:g,issues:void 0,options:m};try{for(let E=0;E<h.length;E++){let b=h[E],v=b.name,T=Fl(x,v),S=T?x[v]:ve,w=b.parser(S,m);if(!Xe(w))return f(y,E,w);if(w===nt){T&&B(g,v,S);continue}let k=mv(y,b,w);if(k)return k}}catch(E){return gn(E)}return Dr(g)}}_rebuild(e,t,r,n){let o=Uu(this.propertySignatures,i=>{let a=e(i.type);return a===i.type?i:new vv(i.name,a)}),s=Uu(this.indexSignatures,i=>{let a=t(i.parameter),c=e(i.type);return a===i.parameter&&c===i.type?i:new Cv(a,c)});return o===this.propertySignatures&&s===this.indexSignatures&&r===this.checks&&n===this.encodingChecks?this:new bm(o,s,this.annotations,r,void 0,this.context,n)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?"object | array":"object"}};function mv(e,t,r){if(r._tag==="Failure")return Vy(e,e.ast,t.name,r);if(r===nt)return;let n=r[Se];if(n!==ve){B(e.out,t.name,n);return}if(delete e.out[t.name],!Lr(t.type)){let o=new Ct([t.name],new Yt(t.type.context?.annotations));if(e.options.errors==="all"){e.issues?e.issues.push(o):e.issues=[o];return}else return Gn(new Pt(e.ast,[o],e.input,e.options))}}var P2={onItem(e,t){if(!Fl(e.input,t.name))return t.parser(ve,e.options);let r=e.input[t.name];return B(e.out,t.name,r),t.parser(r,e.options)},step:mv},f2=vg()(P2),dQ=Cg()(P2);function Av(e,t){return e?t?[...e,...t]:e:t}function Zy(e,t,r){return new bm(Reflect.ownKeys(e).map(n=>new vv(n,e[n].ast)),[],r,t)}function Em(e){return e.ast}function kv(e,t=void 0){return new Xo(!1,e.map(r=>r.ast),[],void 0,t)}function Qy(e,t,r){return new Sn(e.map(Em),t,void 0,r)}function M2(e,t){if(e.encoding||t.some(s=>s.encoding))throw new Error("StructWithRest does not support encodings");let r=e.propertySignatures,n=e.indexSignatures,o=e.checks;for(let s of t){for(let i of s.propertySignatures)if(r.some(a=>a.name===i.name))throw new Error(`Duplicate identifier: ${JSON.stringify(i.name)}. ts(2300)`);r=r.concat(s.propertySignatures),n=n.concat(s.indexSignatures),o=Av(o,s.checks)}return new bm(r,n,void 0,o)}function F2(e,t){if(e.encoding)throw new Error("TupleWithRest does not support encodings");return new Xo(e.isMutable,e.elements,t,void 0,e.checks)}function N2(e){if(e.encoding)throw new Error("mutable does not support encodings");return new Xo(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var Rv=Bc(e=>{for(;;){if(g2(e))return pa;let t=e.encoding;if(!t)return e.recur?.(Rv,F)??e;if(t.some(r=>r.transformation._tag==="Middleware"&&r.transformation.decode!==F))return pa;e=t[t.length-1].to}});function U2(e){switch(e._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return e.propertySignatures.length||e.indexSignatures.length?["object"]:["string","number","boolean","symbol","bigint","object","array","function"];case"Enum":return Array.from(new Set(e.enums.map(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(U2)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function ac(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[um];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(t=>{let r=t.type;if(!Lr(r)){if(Nl(r))return[{key:t.name,literal:r.literal}];if(lv(r))return[{key:t.name,literal:r.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,r)=>{if(!Lr(t)){if(Nl(t))return[{key:r,literal:t.literal}];if(lv(t))return[{key:r,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map(r=>ac(Rv(r)));return t[0].filter(r=>t.every(n=>n.some(o=>o.key===r.key&&o.literal===r.literal)))}case"Suspend":return ac(e.thunk())}}var l2=new WeakMap,Ky=Object.freeze([]),d2=e=>e===null?"null":Array.isArray(e)?"array":typeof e,Fl=(e,t)=>t==="__proto__"?Object.hasOwn(e,t):t in e;function Im(e){let t=l2.get(e);if(t)return t;let r,n=0,o,s,i=!0,a=[];for(let f=0;f<e.length;f++){let p=e[f],m=Rv(p);if(J5(m))continue;if(Nl(m)||lv(m)){s??=new Map;let x=Nl(m)?m.literal:m.symbol;a[f]=x;let g=s.get(x);g||s.set(x,g=[]),g.push(f)}else i=!1;let h=ac(m);if(h.length){r??=new Map,n++;for(let{key:x,literal:g}of h){let y=r.get(x);y||r.set(x,y=[new Map,new Set]),y[1].add(f);let E=y[0].get(g);E||y[0].set(g,E=new Set),E.add(f)}}else{o??={};let x=U2(m);for(let g of x)(o[g]??=[]).push(f)}}let c={},u=f=>c[f]??=Object.freeze(o?.[f]??Ky);if(i&&s)s.forEach(Object.freeze),t=f=>s.get(f)??Ky;else if(r?.size===1&&!o){let[f,[p]]=r.entries().next().value,m=new Map;for(let[x,g]of p)m.set(x,Object.freeze(Array.from(g)));let h=Object.freeze(e.map((x,g)=>g));t=(x,g)=>{if(Ld(x)){let y=Fl(x,f)?x[f]:void 0;if(y!==void 0)return m.get(y)??Ky;if(g)return h}return Ky}}else if(r){let f;for(let p of r)(!f||p[1][0].size>f[1][0].size)&&p[1][1].size===n&&(f=p);t=(p,m)=>{let h=d2(p);if(!Ld(p))return u(h);let x=new Set(o?.[h]),g;if(f){let[y,[E]]=f,b=Fl(p,y),v=b?p[y]:void 0;if(b&&(!m||v!==void 0)){let T=E.get(v);if(!T)return u(h);for(let S of T)x.add(S);g=y}}if(g===void 0)for(let[y,[E,b]]of r){let v=Fl(p,y),T=v?p[y]:void 0;if(v&&(!m||T!==void 0)){let S=E.get(T);if(S)for(let w of S)x.add(w)}else if(m)for(let S of b)x.add(S)}for(let[y,[E,b]]of r){if(y===g)continue;let v=Fl(p,y),T=v?p[y]:void 0;if(v&&(!m||T!==void 0)){let S=E.get(T);for(let w of x)b.has(w)&&!S?.has(w)&&x.delete(w)}}return Array.from(x).sort((y,E)=>y-E)}}else t=f=>{let p=u(d2(f));return s?p.filter(m=>a[m]===void 0||a[m]===f):p};return l2.set(e,t),t}var Sn=class extends Vt{_tag="Union";types;options;encodingChecks;constructor(e,t,r,n,o,s,i){super(r,n,o,s),this.types=e,this.options=t,this.encodingChecks=i}getParser(e,t){let r=this,n=t!==void 0,o=[],s=a=>o[a]??=e(r.types[a]),i;return(a,c)=>{if(a===ve)return no;let u=(i??=Im(r.types))(a,n);if(u.length===0)return D(new hm(r,[],a,c));if(u.length===1){let f=s(u[0])(a,c);return f._tag==="Success"?f:Xe(f)?D2(r,f.cause,a,c):pQ(r,f,a,c)}return L2(r,s,u,a,c)}}_rebuild(e,t,r){let n=Uu(this.types,e);return n===this.types&&t===this.checks&&r===this.encodingChecks?this:new Sn(n,this.options,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let r of this.types){let n=r.matchPart(e,t);if(n!==void 0)return n}}getExpected(e){let t=this.annotations?.expected;if(typeof t=="string")return t;if(this.types.length===0)return"never";let r=this.types.map(n=>{let o=Bn(n);switch(o._tag){case"Arrays":{let s=o.elements.filter(Nl);if(s.length>0)return`${m2(o.isMutable)}[ ${s.map(i=>e(i)+h2(i.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let s=o.propertySignatures.filter(i=>Nl(i.type));if(s.length>0)return`{ ${s.map(i=>`${m2(i.type.context?.isMutable)}${ni(i.name)}${h2(i.type.context?.isOptional)}: ${e(i.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(r)).join(" | ")}};function D2(e,t,r,n){let o=xm(t);return o?Gn(new hm(e,[o],r,n)):ir(t)}function pQ(e,t,r,n){return rt(t,o=>D2(e,o,r,n))}function L2(e,t,r,n,o){let s={ast:e,parser:t,input:n,out:void 0,successes:e.options?.mode==="oneOf"?[]:void 0,issues:void 0,options:o},i=mQ(s,r);if(!i)return s.out?s.out:D(new hm(e,s.issues??[],n,o));if(Xe(i))return p2(i,s);let a=!0;return L(()=>a?(a=!1,p2(i,s)):L2(e,t,r,n,o))}function p2(e,t){return ur(e,r=>t.out===nt?I(t.input):t.out?t.out:D(new hm(t.ast,t.issues??[],t.input,t.options)))}var mQ=vg()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,r){if(r._tag==="Failure"){let n=xm(r.cause);if(n===void 0)return r;e.issues?e.issues.push(n):e.issues=[n]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),Gn(new l1(e.ast,e.successes,e.input,e.options));if(e.out=r,e.successes)e.successes.push(e.ast.types[t]);else return Wt}}}),B2=new Sn([new Ln("Infinity"),new Ln("-Infinity"),new Ln("NaN")]);function m2(e){return e?"":"readonly "}function h2(e){return e?"?":""}var Ov=class extends Vt{_tag="Suspend";thunk;constructor(e,t,r,n,o){if(r)throw new Error("Cannot add checks to Suspend");super(t,void 0,n,o);let s;this.thunk=()=>s??=e()}getParser(e){let t;return(r,n)=>(t??=e(this.thunk()))(r,n)}recur(e){return new Ov(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},Jy=class extends Ra{_tag="Filter";run;annotations;aborted;constructor(e,t=void 0,r=!1){super(),this.run=e,this.annotations=t,this.aborted=r}annotate(e){return new Jy(this.run,{...this.annotations,...e},this.aborted)}abort(){return new Jy(this.run,this.annotations,!0)}and(e,t){return new Nu([this,e],t)}},Nu=class extends Ra{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Nu(this.checks,{...this.annotations,...e})}and(e,t){return new Nu([this,e],t)}};function Yy(e,t,r=!1){return new Jy((n,o,s)=>p1(o,e(n,o,s),n,s),t,r)}function Xy(e,t){return new Jy((r,n,o)=>e(r)?void 0:new le(void 0,r,o),t,!0)}function _v(e){return Yy(t=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitraryConstraint:{number:"finite"},...e})}var Pv=Pi(wv,[_v()]),hQ=new Bt(new Sn([Pv,B2]),new et(By(),Ie(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Tm(e,t){let r=new globalThis.RegExp(e),n={source:r.source,flags:r.flags};return Yy(o=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n.source}`,representation:{id:"effect/schema/isPattern",payload:n},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[n]},...t})}var hv=new WeakMap;function wm(e,t){let r=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(n=>n==="context"||n==="encoding")&&hv.set(r,Ll(e)),r}function Ll(e){let t=hv.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let r=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return hv.set(e,r),r}function lt(e,t){return e.encoding===t?e:wm(e,{encoding:t})}function Du(e,t){if(e.context===t)return e;let r=Ll(e);return r.context===t&&r.encoding===e.encoding?r:wm(e,{context:t})}function Bl(e){return e.encoding?Bl(e.encoding[e.encoding.length-1].to):e}function Fs(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return $2(e,Ux(e.checks.slice(0,-1),r.annotate(t)))}return wm(e,{annotations:{...e.annotations,...t}})}function $2(e,t){if(e._tag==="Suspend"&&t)throw new Error("Cannot add checks to Suspend");return e.checks===t?e:wm(e,{checks:t})}function Pi(e,t){return $2(e,Av(e.checks,t))}function fc(e,t){let r=t(e.to);return r===e.to?e:new Bt(r,e.transformation)}function H2(e,t){let r=e,n=r[r.length-1],o=fc(n,t);return o===n?e:Ux(e.slice(0,e.length-1),o)}function eS(e){return t=>t.encoding?lt(t,H2(t.encoding,e)):t}function $l(e,t){return eS(r=>Du(r,t))(e)}function ma(e,t){function r(n){if(n.encoding){let o=n.encoding[n.encoding.length-1];return t?.stopAt?.(o)?n:lt(n,H2(n.encoding,r))}return e(n)}return Bc(r)}function j2(e,t){return Mv(e,t,Mt(e))}function q2(e,t){return Mv(Bn(e),t,e)}function Mv(e,t,r){let n=new Bt(e,t);return lt(r,r.encoding?[...r.encoding,n]:[n])}function Uu(e,t){let r;for(let n=0;n<e.length;n++){let o=e[n],s=t(o);if(r)r[n]=s;else if(s!==o){r=new Array(e.length);for(let i=0;i<n;i++)r[i]=e[i];r[n]=s}}return r??e}function Hl(e,t){let r=e.context?new Yo(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new Yo(!1,!1,void 0,t);return Du(e,r)}var Lu=Bc(e=>{let t=e.context?e.context.isOptional===!1?new Yo(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new Yo(!0,!1);return xQ(Du(e,t))}),xQ=eS(Lu),z2=mo(e=>Lu(new Sn([e,Ev]))),Fv=Bc(e=>{let t=e.context?e.context.isMutable===!1?new Yo(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new Yo(!1,!0);return gQ(Du(e,t))}),gQ=eS(Fv);function W2(e,t){let r=e.context?new Yo(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new Yo(!1,!1,t);return Du(e,r)}function jl(e,t,r){return Mv(e,r,t)}function yQ(e){let t=[],r=[];function n(o){switch(o._tag){case"Literal":fx(o.literal)&&!t.includes(o.literal)&&t.push(o.literal);return;case"UniqueSymbol":t.includes(o.symbol)||t.push(o.symbol);return;case"Never":return;case"Union":for(let s=0;s<o.types.length;s++)n(o.types[s]);return;default:r.push(o)}}return n(e),{literals:t,parameters:r}}function K2(e,t){let{literals:r,parameters:n}=yQ(e);return new bm(r.map(o=>new vv(o,t)),n.map(o=>new Cv(o,t)))}function Lr(e){return e.context?.isOptional??!1}function V2(e){return e.context?.isMutable??!1}function J2(e){return e.annotations?.[ro]===!0||e._tag==="FilterGroup"&&e.checks.every(J2)}function SQ(e){function t(n){return J2(n)?[n]:n._tag==="FilterGroup"?n.checks.flatMap(t):[]}let r=e.flatMap(t);return Jr(r)?r:void 0}function bQ(e){let t=!0;function r(n){return t=t&&!n.encoding&&!g2(n),t&&"recur"in n&&n.recur(r),n}return"recur"in e&&e.recur(r),t}var Mt=Bc(e=>{let t=Ll(e);if(t!==e){let n=Mt(t);return n===t&&e.encoding===void 0?e:Du(n,e.context)}let r="recur"in e?e.recur(Mt):e;if("encodingChecks"in r&&r.encodingChecks){let n=bQ(e)?r.encodingChecks:Sv(r)||G5(r)||Dl(r)&&r.typeParameters.length>0?SQ(r.encodingChecks):void 0;return wm(r,{encodingChecks:void 0,checks:Av(r.checks,n)})}return r}),Bn=Bc(e=>Mt(Oo(e)));function EQ(e,t){let r=t,n=r.length,o=r[n-1],s=[new Bt(Oo(lt(e,void 0)),r[0].transformation.flip())];for(let a=1;a<n;a++)s.unshift(new Bt(Oo(r[a-1].to),r[a].transformation.flip()));let i=Oo(o.to);return i.encoding?lt(i,[...i.encoding,...s]):lt(i,s)}var Oo=mo(e=>{if(e.encoding)return EQ(e,e.encoding);let t=Ll(e);if(t!==e){let r=Oo(t);return r===t?e:Du(r,e.context)}return"flip"in e?e.flip(Oo):"recur"in e?e.recur(Oo):e});function G2(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(G2);default:return!1}}function tS(e,t){let r=t===0?nt:Dr(t);return(n,o)=>n===ve?no:n===t?r:D(new at(e,n,o))}function Ns(e,t){return(r,n)=>r===ve?no:t(r)?nt:D(new at(e,r,n))}function Z2(e,t,r){let n=e.encodedParts,o=e.literals,s=t.length;for(let u=0;u<o.length;u++){let f=o[u];if(f&&!t.includes(f))return}if(e.suffixLengths[0]>s)return;let i=new Array(n.length),a;function c(u,f){if(u===n.length)return f===s;if(a?.has(u*(s+1)+f))return!1;let p=n[u];if(u===n.length-1){let m=t.slice(f);if(p.matchPart(m,r)!==void 0)return i[u]=m,!0}else if(p._tag==="Literal"){let m=o[u];if(t.startsWith(m,f)&&c(u+1,f+m.length))return i[u]=m,!0}else{let m=s-e.suffixLengths[u+1],h=o[u+1],x=h===void 0?m:t.lastIndexOf(h,m);for(;x>=f;){let g=t.slice(f,x);if(p.matchPart(g,r)!==void 0&&c(u+1,x))return i[u]=g,!0;if(x===0)break;x=h===void 0?x-1:t.lastIndexOf(h,x-1)}}return a??=new Set,a.add(u*(s+1)+f),!1}return c(0,0)?i:void 0}var Nv=ma(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(Nv)}}),rS=ma(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(rS)}}),Uv=ma(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(Uv)}}),Q2="[\\s\\S]*?",xv=new globalThis.RegExp(`^${Gy}$`),IQ=new globalThis.RegExp(`^(?:${Gy}|Infinity|-Infinity|NaN)$`);function Dv(e){return Tm(xv,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:xv.source}),...e})}var Y2=Pi(Ro,[Dv()]),TQ=new Bt(Y2,Pl),wQ=new Bt(new Sn([Y2,B2]),Pl),vQ="-?\\d+",gv=new globalThis.RegExp(`^${vQ}$`);function Lv(e){return Tm(gv,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:gv.source}),...e})}var Bv=Pi(Ro,[Lv({expected:"a string representing a bigint"})]),CQ=new Bt(Bv,Wy),AQ="Symbol\\(([\\s\\S]*)\\)",yv=new globalThis.RegExp(`^${AQ}$`),kQ=Pi(Ro,[$v()]),X2=new Bt(kQ,new et(Ie(e=>globalThis.Symbol.for(yv.exec(e)[1])),rn((e,t)=>globalThis.Symbol.keyFor(e)!==void 0?I(globalThis.String(e)):D(new mm({message:"cannot serialize to string, Symbol is not registered"},e,t)))));function $v(e){return Tm(yv,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:yv.source}),...e})}function Us(e,t,r,n,o){for(let s=0;s<e.length;s++){let i=e[s];if(i._tag==="FilterGroup"){if(r=Us(i.checks,t,r,n,o),r&&(o.errors!=="all"||r[r.length-1].filter.aborted))return r}else{let a=i.run(t,n,o);if(a){let c=new u1(i,a,t,o);if(r?r.push(c):r=[c],o.errors!=="all"||i.aborted)return r}}}return r}function eL(e,t){let r=Us(e,t,void 0,pa,{errors:"all"});if(r){let n=new Pt(pa,r);return re(n)}return X(t)}function tL(e){if(!Dl(e))return;let t=e.annotations?.[Ny];return or(t)?t(e.typeParameters):void 0}function RQ(e){return e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&globalThis.Number.isFinite(e)}function OQ(e){return e===void 0||typeof e=="string"}function rL(e,t){let r=new WeakMap,n=[];e:for(;;){if(typeof e!="object"||e===null){if(!t(e))return!1}else{let o=e,s=r.get(o);if(s===!1)return!1;if(s===void 0){let i=Array.isArray(o);if(!i){let a=Object.getPrototypeOf(o);if(a!==null&&a!==Object.prototype&&Object.getPrototypeOf(a)!==null)return!1}r.set(o,!1),n.push({value:o,keys:i?o.length:Object.keys(o),index:0})}}for(;n.length>0;){let o=n[n.length-1],s=o.keys;if(typeof s=="number"){if(o.index<s){e=o.value[o.index++];continue e}}else if(o.index<s.length){e=o.value[s[o.index++]];continue e}r.set(o.value,!0),n.pop()}return!0}}function ql(e){return rL(e,RQ)}var Ul=new uc([],()=>(e,t,r)=>ql(e)?nt:D(new at(t,e,r)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{},toCodecStringTree:()=>jv}),nL=Fs(Ul,{representation:{id:"effect/schema/MutableJson",payload:null}}),Hv=new Bt(Ul,_l()),oL=new Bt(new Sn([new Xo(!1,[],[Ul]),new bm([],[new Cv(Ro,Ul)])]),_l());function _Q(e){return rL(e,OQ)}var PQ=new uc([],()=>(e,t,r)=>_Q(e)?nt:D(new at(t,e,r)),{expected:"StringTree",toCodecStringTree:()=>{}}),jv=new Bt(PQ,_l());var nS=(e,t,r)=>e===nt?r(t):ur(e,r);function iL(e){if(e._tag==="Middleware")return(r,n,o)=>{let s=r===nt?e.decode(Dr(lm(n)),o):e.decode(Su(r,lm),o);return sL(s)};let t=e.decode;switch(t._tag){case"Passthrough":return(r,n)=>r===nt?Dr(n):r;case"Transform":{let r=n=>n===ve?no:Dr(t.transform(n));return(n,o)=>nS(n,o,r)}case"TransformOptional":{let r=n=>Zw(t.transform(lm(n)));return(n,o)=>nS(n,o,r)}case"TransformEffect":return(r,n,o)=>nS(r,n,s=>s===ve?no:t.transform(s,o));case"TransformOptionalEffect":return(r,n,o)=>nS(r,n,s=>sL(t.transform(lm(s),o)))}}var sL=e=>ur(e,Zw),aL=(e,t,r,n)=>rt(n,o=>aa(()=>Ka(o,s=>new f1(e,s,t,r))));function MQ(e,t){let r=iL(e.link.transformation),n;return(o,s)=>{if(o===ve)return no;if(e.isConstructed(o))return nt;let i=(n??=t(e.link.to))(o,s);return r(i,o,s)}}function FQ(e,t){let r=e.context.constructorDefault;return(n,o)=>{if(n!==ve&&n!==void 0)return t(n,o);let s=r;if(Xe(s)&&s._tag==="Success"){let i=t(s[Se],o);return i===nt?s:i}return ur(aL(e,n,o,s),i=>{let a=t(i,o);return a===nt?Dr(i):a})}}function qv(e,t){let r=t(e);return e.context?.constructorDefault===void 0?r:FQ(e,r)}function vm(e,t,r,n,o){if(e._tag==="Declaration")for(let x of e.typeParameters)t(x);let s=r?tL(e):void 0,i=s?MQ(s,t):n??e.getParser(t,r),a=e.checks,c=e.encoding,u=c?.map(x=>iL(x.transformation)),f=e.encodingChecks;if(!c&&!a&&!f)return i;let p,m=(x,g)=>{let y=i(x,g);if(f&&!g.disableChecks)if(Xe(y)){if(y._tag==="Success"){let E=y===nt?x:y[Se];if(x!==ve&&E!==ve){let b=Us(f,x,void 0,e,g);b&&(y=D(new Pt(e,b,x,g)))}}}else y=A(y,E=>{if(x!==ve&&E!==ve){let b=Us(f,x,void 0,e,g);if(b)return D(new Pt(e,b,x,g))}return I(E)});if(a&&!g.disableChecks)if(Xe(y)){if(y._tag==="Success"){let E=y===nt?x:y[Se];if(E===ve)return y;let b=Us(a,E,void 0,e,g);b&&(y=D(new Pt(e,b,E,g)))}}else y=A(y,E=>{if(E!==ve){let b=Us(a,E,void 0,e,g);if(b)return D(new Pt(e,b,E,g))}return I(E)});return y},h=o===void 0?m:o(m);return c?(x,g)=>{let y=p??=c.map(v=>t(v.to)),E=x,b=y[y.length-1](x,g);for(let v=c.length-1;v>=0;v--)if(b=u[v](b,E,g),v!==0){let T=y[v-1];b._tag==="Success"?(E=b[Se],b=T(E,g)):b=ur(b,S=>{let w=T(S,g);return w===nt?Dr(S):w})}if(b._tag==="Success"){let v=b[Se],T=h(v,g);return T===nt?b:T}return b=aL(e,x,g,b),ur(b,v=>{let T=h(v,g);return T===nt?Dr(v):T})}:h}var iS=Symbol(),cL=new WeakMap,uL,zl=!1;var UQ=e=>zl?sS(Po,e,"parser"):Po(e).parser,fL=e=>zl?sS(Po,e,"makeEffect"):Po(e).makeEffect,DQ=e=>qv(e,fL),oS=class{ast;constructor(t){this.ast=t}get decodeEffect(){return this.cachedDecodeEffect??=vm(this.ast,UQ)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=vm(this.ast,fL,DQ)}},zv=class extends oS{compiled;resolve;constructor(t,r,n){super(t),this.compiled=r,this.resolve=n}save(t,r){return Object.defineProperty(this,t,{value:r}),r}operation(t){let r=this.compiled;return typeof r=="function"?r(this.ast,this.resolve,t):r?.[t]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??vm(this.ast,t=>sS(this.resolve,t,"parser")))}get parser(){let t=this.decode;return t===void 0?this.decodeEffect:this.save("parser",LQ(t,()=>this.decodeEffect))}get makeEffect(){let t=this.operation("makeEffect");if(t!==void 0)return this.save("makeEffect",t);let r=n=>sS(this.resolve,n,"makeEffect");return this.save("makeEffect",vm(this.ast,r,n=>qv(n,r)))}};function LQ(e,t){let r;return(n,o)=>{if(n!==ve)try{let s=e(n,o);if(s!==iS)return s===n?nt:Dr(s)}catch(s){return gn(s)}return(r??=t())(n,o)}}function sS(e,t,r){let n=e(t);if(n.compiled===void 0||Object.hasOwn(n,r))return n[r];let o;return(s,i)=>(o??=n[r])(s,i)}function Po(e){let t=cL.get(e);if(t!==void 0)return t;let r=uL===void 0?new oS(e):new zv(e,uL(e,Po),Po);return cL.set(e,r),r}function Kv(e){let t=e.ast,r;return(n,o)=>(r??=Xv(VQ,Mt(t)))(n,o?.disableChecks?o?.parseOptions?{...o.parseOptions,disableChecks:!0}:{disableChecks:!0}:o?.parseOptions)}function cS(e){let t=Kv(e);return(r,n)=>{let o=ki(t(r,n));return ft(o)?N(o.value):(ko(o.cause,"Option adapter can only return none for schema issues"),_())}}function uS(e){return WQ(Mt(e.ast))}function Vv(e){return Cm(e.ast)}function $Q(e){if(!zl){let o=Wl(dS(e));return s=>{let i=o(s,nn);return ft(i)?!0:(ko(i.cause,"Type guard adapter can only return false for schema issues"),!1)}}let t=Po(e),r=t.is;if(r!==void 0)return o=>{try{return r(o,nn)}catch(s){return ko(ol(s),"Type guard adapter can only return false for schema issues"),!1}};let n=t.parser;return o=>{let s=ki(Yv(n(o,nn),o));return ft(s)?!0:(ko(s.cause,"Type guard adapter can only return false for schema issues"),!1)}}function Cm(e){let t=Mt(e),r=n=>(r=$Q(t),r(n));return n=>r(n)}function lL(e){let t=dS(e);return(r,n)=>{let o=ki(t(r,n));if(!ft(o))return ko(o.cause,"Issue adapter can only return schema issues")}}function dL(e,t){let r=Mt(e.ast),n=Po(r).parser(t,nn),o=ki(Yv(n,t));if(vs(o)){let s=ko(o.cause,"Assertion adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}function ot(e,t){let r=dS(e.ast);return t===void 0?r:(n,o)=>r(n,Qv(t,o))}var Jv=ot;function pL(e,t){return Wl(ot(e,t))}function Gv(e,t){return bL(ot(e,t))}var mL=Gv;function hL(e,t){return EL(ot(e,t))}function HQ(e,t){return zl?IL(e.ast,t):eC(ot(e,t))}var fS=HQ;function Bu(e,t){let r=dS(Oo(e.ast));return t===void 0?r:(n,o)=>r(n,Qv(t,o))}var xL=Bu;function gL(e,t){return Wl(Bu(e,t))}function Zv(e,t){return bL(Bu(e,t))}var yL=Zv;function SL(e,t){return EL(Bu(e,t))}function jQ(e,t){return zl?IL(Oo(e.ast),t):eC(Bu(e,t))}var lS=jQ,Qv=(e,t)=>t?{...e,...t}:e,aS=e=>e===ve?D(new le):I(e);function dS(e){return Xv(KQ,e)}function Yv(e,t){return e===nt?I(t):Xe(e)?e[Se]===ve?aS(ve):e:ur(e,aS)}function Xv(e,t){let r;return(n,o)=>{let s=(r??=e(t))(n,o??nn);return s===nt?I(n):Xe(s)?s[Se]===ve?aS(ve):s:ur(s,aS)}}function Wl(e){return(t,r)=>ki(e(t,r))}function bL(e){let t=Wl(e);return(r,n)=>{let o=t(r,n);return ft(o)?N(o.value):(ko(o.cause,"Option adapter can only return none for schema issues"),_())}}function EL(e){let t=Wl(e);return(r,n)=>{let o=t(r,n);return ft(o)?X(o.value):re(ko(o.cause,"Result adapter can only return schema issues"))}}function IL(e,t){let r;return(n,o)=>(r??=qQ(Po(e),t))(n,o)}function qQ(e,t){let r=e.decode,n,o=r===void 0?(s,i=nn)=>(n??=Wv(e))(s,i):(s,i=nn)=>{if(s===ve)return(n??=Wv(e))(s,i);let a;try{a=r(s,i)}catch(c){throw ko(ol(c),"Sync adapter can only throw schema issues"),c}return a!==iS?a:(n??=Wv(e))(s,i)};return t===void 0?o:(s,i)=>o(s,Qv(t,i))}function Wv(e){return eC(Xv(()=>e.decodeEffect,e.ast))}function eC(e){let t=Wl(e);return(r,n)=>{let o=t(r,n);if(ft(o))return o.value;let s=ko(o.cause,"Sync adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}function zQ(e,t){let r=ki(e);if(ft(r))return r.value;let n=ko(r.cause,t);throw new Error("Schema validation failed",{cause:n})}function WQ(e){let t,r;return(n,o)=>{t??=Po(e);let s=o?.disableChecks?o.parseOptions?{...o.parseOptions,disableChecks:!0}:{disableChecks:!0}:o?.parseOptions??nn,i=t.make;if(i!==void 0&&n!==ve){let c;try{c=i(n,s)}catch(u){throw ko(ol(u),"Constructor adapter can only throw schema issues"),u}if(c!==iS&&c!==ve)return c}let a=(r??=t.makeEffect)(n,s);return zQ(Yv(a,n),"Constructor adapter can only throw schema issues")}}var KQ=e=>Po(e).parser,VQ=e=>Po(e).makeEffect;var pS="~effect/Schema/Schema",TL=Symbol(),JQ={[pS]:pS,get make(){let e=uS(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Kv(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=cS(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return V(this,arguments)},annotate(e){return this.rebuild(Fs(this.ast,e))},annotateKey(e){return this.rebuild(Hl(this.ast,e))},check(...e){return this.rebuild(Pi(this.ast,e))},rebuild(e){return Ls(e,this[TL])}};function Ls(e,t){function r(){}let n=Object.setPrototypeOf(r,JQ);return t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__"))?Object.defineProperties(n,Object.getOwnPropertyDescriptors({...t})):Object.assign(n,t),n[TL]=t,n.ast=e,n}function tC(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Am(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function rC(e){return encodeURI(tC(e)).replace(/#/g,"%23")}function nC(e){if(e.length===0||e==="#")return"";if(!e.startsWith("#"))return;let t=e.slice(1);try{if(encodeURI(t).replace(/%25/g,"%").replace(/#/g,"%23")!==t)return;let r=decodeURIComponent(t);return r.startsWith("/")&&!/~(?:[^01]|$)/.test(r)?r:void 0}catch{return}}function vL(e){let t=nC(e);return t===void 0?void 0:t.length===0?[]:t.slice(1).split("/").map(Am)}function CL(e){return e.reduce((t,r)=>`${t}/${rC(r)}`,"#")}var ZQ="http://json-schema.org/draft-07/schema#",AL="https://json-schema.org/draft/2020-12/schema";function kL(e,t){return e===t||e===(t.endsWith("#")?t.slice(0,-1):`${t}#`)}function _L(e){return{dialect:"draft-07",...t9(e,l9)}}function QQ(e,t){return r(e,!1,!0);function r(n,o,s=!1){if(!Gt(n))return n;let i=o||!s&&FL(n.$id),a={};for(let c of Object.keys(n)){let u=n[c],f=u;switch(c){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":f=sC(u,p=>r(p,i))??u;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":f=Array.isArray(u)?u.map(p=>r(p,i)):u;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":f=r(u,i)}B(a,c,f)}return t(a,i),a}}function PL(e,t){return QQ(e,r=>{YQ(r,t)})}function YQ(e,t){typeof e.$ref=="string"&&B(e,"$ref",t(e.$ref,"$ref")),typeof e.$dynamicRef=="string"&&B(e,"$dynamicRef",t(e.$dynamicRef,"$dynamicRef"))}function sC(e,t){if(!Gt(e))return;let r={};for(let n of Object.keys(e))B(r,n,t(e[n],n));return r}function XQ(e,t,r){let n=new Map,o=[],s=oC;function i(m,h=[],x=[]){if(h.length===0&&t?.trackIds){let g=Gt(m)?f(m):void 0;s=RL(g,oC)??oC}return u(m,h,x,{sourceRoot:[],targetRoot:[],uri:s})}function a(){for(let[m,h,x]of o){let g=h,y=ML(h,x);if(y!==void 0){let E=vL(y.hash);if(y.hash="",E!==void 0){let b=n.get(OL(y.href,E));b!==void 0&&(g=e9(h,b))}}B(m,"$ref",g)}}let c=r(i);return a(),c;function u(m,h,x,g){if(typeof m=="boolean")return p(h,x,g),t?.booleanAdapter?.(m)??m;if(!Gt(m))return m;let y=g,E=f(m);if(h.length>0&&t?.trackIds&&FL(E)){let T=RL(E,g.uri);T!==void 0&&(y={parent:g,sourceRoot:h,targetRoot:x,uri:T})}p(h,x,y);let b=y.uri,v={isDocumentRoot:h.length===0,schema(T,S,w=S){return u(T,[...h,S],[...x,w],y)},schemaAt(T,S,w){return u(T,[...h,...S],[...x,...w],y)},schemaArray(T,S,w=S){return Array.isArray(T)?T.map((k,C)=>u(k,[...h,S,String(C)],[...x,w,String(C)],y)):T},schemaMap(T,S,w=S){return Gt(T)?sC(T,(k,C)=>u(k,[...h,S,C],[...x,w,C],y)):T},reference(T,S){typeof S=="string"?o.push([T,S,b]):B(T,"$ref",S)}};return e(m,v)}function f(m){return t?.ignoreRefSiblings===!0&&typeof m.$ref=="string"?void 0:m.$id}function p(m,h,x){x.parent!==void 0&&p(m,h,x.parent),n.set(OL(x.uri,m.slice(x.sourceRoot.length)),h.slice(x.targetRoot.length))}}var oC="https://effect.invalid/.json-schema/";function ML(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function RL(e,t){if(typeof e!="string")return;let r=ML(e,t);if(r!==void 0)return r.hash="",r.href}function e9(e,t){let r=e.indexOf("#");return r===-1&&t.length===0?e:`${r===-1?e:e.slice(0,r)}${CL(t)}`}function OL(e,t){return`${e}\0${JSON.stringify(t)}`}function FL(e){return typeof e=="string"&&e.length>0&&e[0]!=="#"}function t9(e,t,r){return XQ(t,{...r,trackIds:!0},n=>({schema:n(e.schema),definitions:sC(e.definitions,(o,s)=>n(o,["$defs",s],["definitions",s]))}))}var r9=new Set(["properties","patternProperties"]),n9=new Set(["allOf","anyOf","oneOf"]),o9=new Set(["not","additionalProperties","propertyNames","contains","if","then","else","contentSchema"]);function s9(e,t,r,n,o,s=r9){let i;if(s.has(t))i=n.schemaMap(r,t);else if(n9.has(t))i=n.schemaArray(r,t);else if(o.has(t))i=n.schema(r,t);else return!1;return B(e,t,i),!0}var NL=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"],tge=[...NL,"deprecated"],rge=[...NL,"$comment","$id","$schema","const","contains","contentEncoding","contentMediaType","else","examples","if","patternProperties","propertyNames","then"],i9=/^[A-Za-z_][-A-Za-z0-9._]*$/,a9=/^[A-Za-z][-A-Za-z0-9._:]*$/;function $u(e,t,r){throw new Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${r}`)}function c9(e,t,r,n){for(let o of t)Object.hasOwn(e,o)&&$u(o,r,`it is not active in ${n} but would become active in the target`)}var u9=["additionalItems","definitions","dependencies"];function f9(e,t,r,n,o){r.isDocumentRoot?B(e,"$schema",kL(t,AL)?n:t):kL(t,AL)||$u("$schema",o,"an embedded resource cannot declare a different dialect")}function l9(e,t){c9(e,u9,"Draft-07","Draft 2020-12");let r={},n,o,s;for(let i of Object.keys(e)){let a=e[i];if(!s9(r,i,a,t,o9))switch(i){case"$ref":n=a;break;case"$schema":f9(r,a,t,ZQ,"Draft-07");break;case"$id":case"$anchor":break;case"$defs":B(r,"definitions",t.schemaMap(a,i,"definitions"));break;case"prefixItems":o=a;break;case"items":s=a;break;case"dependentRequired":case"dependentSchemas":case"minContains":case"maxContains":break;case"$dynamicRef":case"$dynamicAnchor":case"$vocabulary":case"unevaluatedProperties":case"unevaluatedItems":$u(i,"Draft-07","the target dialect has no equivalent");case"required":if(Array.isArray(a)&&a.length===0)break;B(r,i,a);break;default:B(r,i,a)}}if(d9(r,o,s,t),Object.hasOwn(e,"contains")){let i=e.minContains,a=e.maxContains;(i!==void 0&&i!==1||a!==void 0)&&$u("minContains/maxContains","Draft-07","contains cardinality cannot be represented"),Object.hasOwn(e,"minContains")&&B(r,"minContains",i)}else Object.hasOwn(e,"minContains")&&B(r,"minContains",e.minContains),Object.hasOwn(e,"maxContains")&&B(r,"maxContains",e.maxContains);return m9(e,r,t,"draft-07"),x9(e,r,"$id","Draft-07"),p9(r,n,t),r}function d9(e,t,r,n){if(t===void 0){r!==void 0&&B(e,"items",n.schema(r,"items"));return}B(e,"items",n.schemaArray(t,"prefixItems","items")),r!==void 0&&B(e,"additionalItems",n.schema(r,"items","additionalItems"))}function p9(e,t,r){if(t!==void 0)if(typeof t=="string"&&Object.keys(e).length>0){let n={};r.reference(n,t),h9(e,n)}else r.reference(e,t)}function m9(e,t,r,n){let o=Gt(e.dependentRequired)?e.dependentRequired:void 0,s=Gt(e.dependentSchemas)?e.dependentSchemas:void 0;if(o===void 0&&s===void 0)return;let i={},a=new Set([...Object.keys(o??{}),...Object.keys(s??{})]);for(let c of a){let u=o?.[c],f=s?.[c],p=n==="draft-04"&&Array.isArray(u)&&u.length===0;f===void 0?p||B(i,c,u):u===void 0||p?B(i,c,r.schemaAt(f,["dependentSchemas",c],["dependencies",c])):B(i,c,{allOf:[r.schemaAt(f,["dependentSchemas",c],["dependencies",c,"allOf","0"]),{required:u}]})}Object.keys(i).length>0&&B(t,"dependencies",i)}function h9(e,t){Array.isArray(e.allOf)?e.allOf.push(t):B(e,"allOf",[t])}function x9(e,t,r,n){let o=e.$id,s=e.$anchor;if(s===void 0){o!==void 0&&B(t,r,o);return}(typeof s!="string"||!i9.test(s))&&$u("$anchor",n,"the anchor is not valid"),a9.test(s)||$u("$anchor",n,"the anchor cannot be represented as a plain-name fragment identifier"),o===void 0?B(t,r,`#${s}`):$u("$anchor",n,"it cannot be combined with the schema $id")}function mS(e){return Ls(Kl(e.ast),{schema:e})}var Kl=ma(e=>{let t=y9(e,Kl),r=e.context;return t===e||r===void 0?t:$l(t,iC(r))});function iC(e){return e.constructorDefault===void 0?e:new Yo(e.isOptional,e.isMutable,void 0,e.annotations)}function LL(e){if(e.propertySignatures.some(t=>typeof t.name!="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function BL(e){return t=>{let r=[...t].sort((o,s)=>e(Bn(o))-e(Bn(s)));return r.some((o,s)=>o!==t[s])?r:t}}var g9=BL(e=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function y9(e,t){switch(e._tag){case"Declaration":{let r=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!or(r))return lt(e,[Hv]);let n=e.typeParameters.map(s=>Ls(Bn(s))),o=r(n);return o===void 0?e:lt(e,[fc(o,t)])}case"Unknown":return lt(e,[Hv]);case"ObjectKeyword":return lt(e,[oL]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return LL(e),e.recur(t,rS);case"Union":{let r=g9(e.types);return r!==e.types?new Sn(r,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function hS(e){return Ls($L(Mt(e.ast)))}var $L=mo(e=>{let t=S9(e,$L);return t!==e&&e.context!==void 0?$l(t,iC(e.context)):t});function S9(e,t){switch(e._tag){case"Declaration":{let r=e.annotations?.toCodecIso??e.annotations?.toCodec;if(or(r)){let n=r(e.typeParameters.map(o=>Ls(o)));return lt(e,[fc(n,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}function xS(e){return Ls(zL(e.ast),{schema:e})}function HL(e){return Ls(WL(e.ast))}var b9=BL(e=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function E9(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map(u=>Ls(t(Bn(u)))),o=e.annotations?.toCodecStringTree;if(or(o)){let u=o(n);return u===void 0?e:lt(e,[fc(u,t)])}let s=e.annotations?.toCodecJson,i=or(s)?s(n):void 0,a=i===void 0?e.annotations?.toCodec:void 0,c=i??(or(a)?a(n):void 0);return c===void 0?r(e):lt(e,[fc(c,t)])}case"Null":return lt(e,[I9]);case"Boolean":return lt(e,[T9]);case"Unknown":case"ObjectKeyword":return lt(e,[jv]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return LL(e),e.recur(t,rS);case"Union":{let n=b9(e.types);return n!==e.types?new Sn(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var I9=new Bt(new Ln("null"),new et(Ie(()=>null),Ie(()=>"null"))),T9=new Bt(new Sn([new Ln("true"),new Ln("false")]),new et(Ie(e=>e==="true"),Fu())),jL=new et(Ie(e=>typeof e=="string"?[e]:e),Oi()),qL=e=>e.transformation===jL,zL=ma(e=>{let t=E9(e,zL,r=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:r})});return t!==e&&e.context!==void 0?$l(t,iC(e.context)):t},{stopAt:qL}),DL=e=>Lr(e)?Lu(pa):pa,WL=ma(e=>{let t=w9(e);if(Sv(t)){let r=jl(new Sn([new Xo(t.isMutable,t.elements.map(DL),t.rest.map(DL)),Ro],{mode:"anyOf"}),t,jL);return Lr(e)?Lu(r):r}return t},{stopAt:qL});function w9(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur(WL):e}var oge=globalThis.RegExp;var ha=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");function lc(e,t){return t.length>0&&(e+=`
27
+ at ${hx(t)}`),new Error(e)}function KL(e){return`#/$defs/${rC(e)}`}var v9=new Set([...c1,Pu,...a1]);function Rm(e,t){if(e===void 0)return;let r={},n=e.title;typeof n=="string"&&(r.title=n);let o=e.description,s=e.expected;typeof o=="string"?r.description=o:t?.generateDescriptions===!0&&typeof s=="string"&&(r.description=s);let i=e.default;ql(i)&&(r.default=i);let a=e.examples;Array.isArray(a)&&ql(a)&&(r.examples=a);let c=e.readOnly;typeof c=="boolean"&&(r.readOnly=c);let u=e.writeOnly;typeof u=="boolean"&&(r.writeOnly=u);let f=e.format;typeof f=="string"&&(r.format=f);let p=e.contentEncoding;typeof p=="string"&&(r.contentEncoding=p);let m=e.contentMediaType;typeof m=="string"&&(r.contentMediaType=m);let h=e.contentSchema;if(ql(h)&&(r.contentSchema=h),t?.includeAnnotationKey!==void 0)for(let[x,g]of Object.entries(e))v9.has(x)||!t.includeAnnotationKey(x)||ql(g)&&B(r,x,g);return Object.keys(r).length===0?void 0:r}function VL(e){let t=e.type==="number"||e.type==="integer"?e.type:void 0,r=e;if(t!==void 0&&(r={...e},delete r.type),Array.isArray(r.allOf)){let n=[],o=!1;for(let s of r.allOf){let i=VL(s);i.type!==void 0&&(o=!0,(t===void 0||i.type==="integer")&&(t=i.type)),Object.keys(i.schema).length>0&&n.push(i.schema)}if(o){let{allOf:s,...i}=r;r=n.length===0?i:{...i,allOf:n}}}return{type:t,schema:r}}function C9(e){if(!Array.isArray(e.anyOf)||e.anyOf.length!==2||e.anyOf[0]?.type!=="number")return!1;let t=e.anyOf[1];return t?.type==="string"&&Array.isArray(t.enum)&&t.enum.length===3&&t.enum.includes("NaN")&&t.enum.includes("Infinity")&&t.enum.includes("-Infinity")}var JL="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";function gS(e,t){return Object.keys(e).every(r=>t.includes(`|${r}|`))}function A9(e,t){return typeof e.$ref!="string"&&t.every(r=>!Object.hasOwn(e,r))}var k9="|minimum|exclusiveMinimum|minLength|minItems|minProperties|",R9="|maximum|exclusiveMaximum|maxLength|maxItems|maxProperties|";function O9(e,t,r){if(typeof e.$ref=="string")return;let n={...e,...t};for(let o of r){if(!Object.hasOwn(e,o))continue;let s=e[o],i=t[o];if(typeof s!="number"||typeof i!="number")return;if(k9.includes(`|${o}|`))n[o]=Math.max(s,i);else if(R9.includes(`|${o}|`))n[o]=Math.min(s,i);else return}return typeof n.minimum=="number"&&typeof n.exclusiveMinimum=="number"&&delete n[n.exclusiveMinimum>=n.minimum?"minimum":"exclusiveMinimum"],typeof n.maximum=="number"&&typeof n.exclusiveMaximum=="number"&&delete n[n.exclusiveMaximum<=n.maximum?"maximum":"exclusiveMaximum"],n}var uC="|title|description|default|examples|readOnly|writeOnly|",_9=JL+uC;function Om(e,t,r){if(Object.keys(e).length===0)return t;let n=Object.keys(t);if(n.length===0)return e;let o=e.type==="number"||e.type==="integer"?e.type:void 0,s=C9(e);if(o!==void 0||s){let a=VL(t);if(a.type!==void 0){let c=o==="integer"||a.type==="integer"?"integer":"number",u={...e,type:c};s&&delete u.anyOf;let f=Object.keys(a.schema);return f.length===0?u:gS(a.schema,uC)&&A9(u,f)?{...u,...a.schema}:Om(u,a.schema,r)}}if(r){let a=O9(e,t,n);if(a!==void 0)return a}let i=Array.isArray(t.allOf)&&n.length===1?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...i]}:typeof e.$ref=="string"?{allOf:[e,...i]}:{...e,allOf:i}}function cC(e,t=new Set){return typeof e=="boolean"?e:t.has(e)?!0:(t.add(e),e.every(r=>cC(r,t)))}function P9(e){return Array.isArray(e)}function M9(e,t,r,n){let o=new Map,s=new Map,i=new WeakMap,a=new Map,c=new Map,u=Object.keys(r);for(let S of u)x(S,["references",S]);let f=Bo(e,(S,w)=>b(S,t[w],[]));for(let[S,w]of a.values())if(!cC(S))for(let k of w)Array.isArray(k.oneOf)&&(k.anyOf=k.oneOf,delete k.oneOf);for(let S of u){let w=r[S],k=y(w);if(k===void 0)continue;let C=o.get(S)[0],R=c.get(k),M=R?.find($=>Z(o.get($)[0],C));M===void 0?R===void 0?c.set(k,[S]):R.push(S):s.set(S,M)}let p=Bo(f,g),m={};for(let S of u)s.has(S)||B(m,S,g(o.get(S)[0]));return{dialect:"draft-2020-12",schemas:p,definitions:m};function h(S){return Array.isArray(S.oneOf)&&a.get(S.oneOf)?.[1].push(S),S}function x(S,w){if(!Object.hasOwn(r,S))throw lc(`Invalid reference ${S}`,[...w,"$ref"]);let k=o.get(S);if(k!==void 0)return k;let C=[{},[]];return o.set(S,C),C[0]=b(r[S],["references",S],C[1]),C}function g(S){return PL(S,w=>{let k=nC(w);if(k===void 0){if(/^#(?:\/|%2f)/i.test(w))throw new Error(`Invalid JSON Pointer URI fragment ${JSON.stringify(w)}`);return w}if(!k.startsWith("/$defs/"))return w;let C=k.indexOf("/",7),R=s.get(Am(k.slice(7,C<0?void 0:C)));return R===void 0?w:w.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i,KL(R))})}function y(S){if(S._tag==="Reference")return;let w=S.checks.length===0?S.annotations:S.checks[S.checks.length-1].annotations;return typeof w?.identifier!="string"&&typeof w?.[Pu]=="string"?w[Pu]:void 0}function E(S,w,k,C){let R=S.annotations,M=R?.toJsonSchema;if(M!==void 0){let Le=S.representation?.schemas?.map((Rn,eI)=>b(Rn,[...k,"representation","schemas",eI],C))??[],Er=M({type:w,schemas:Le}),Ee=P9(Er);Ee&&C.push(!1);let Oe=Ee?Er[0]:Er,rr=Rm(R,n),lo=rr===void 0?Oe:{...Oe,...rr},Xs=rr===void 0?JL:_9;return[lo,S._tag==="Filter"&&gS(lo,Xs)&&(rr===void 0||gS(rr,uC))?!0:void 0]}if(S._tag==="Filter"){C.push(!1);return}let $=S.checks.flatMap((Le,Er)=>{let Ee=E(Le,w,[...k,"checks",Er],C);return Ee===void 0?[]:[Ee[0]]});if($.length===0)return;let te=Rm(R,n),xe={allOf:$};return[te===void 0?xe:{...xe,...te}]}function b(S,w,k){if(S._tag==="Reference")return k.push(x(S.$ref,w)[1]),{$ref:KL(S.$ref)};let C=i.get(S);if(C!==void 0)return k.push(C[1]),C[0];let R=[];k.push(R);let M=v(S,w,R),$=Rm(S.annotations,n);$!==void 0&&(M={...M,...$});for(let te=0;te<S.checks.length;te++){let xe=typeof M.type=="string"&&F9(M.type)?M.type:void 0,Le=E(S.checks[te],xe,[...w,"checks",te],R);Le!==void 0&&(M=Om(M,...Le))}return i.set(S,[M,R]),h(M)}function v(S,w,k){switch(S._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":return{type:"string",allOf:[{pattern:"^Symbol\\(([\\s\\S]*)\\)$"}]};case"UniqueSymbol":return globalThis.Symbol.keyFor(S.symbol)===void 0?{not:{}}:{type:"string",enum:[globalThis.String(S.symbol)]};case"Declaration":return k.push(!1),{};case"Suspend":return b(S.thunk,[...w,"thunk"],k);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN","Infinity","-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let C=S.literal;return typeof C=="bigint"?{type:"string",enum:[globalThis.String(C)]}:{type:typeof C,enum:[C]}}case"Enum":{let C=S.enums.map(([R,M],$)=>{if(typeof M=="number"&&!globalThis.Number.isFinite(M))throw lc(`Invalid numeric enum value ${globalThis.String(M)}`,[...w,"enums",$,1]);return{type:typeof M,enum:[M],title:R}});return C.length===0?{not:{}}:{anyOf:C}}case"TemplateLiteral":return{type:"string",pattern:`^${S.parts.map(yS).join("")}$`};case"Arrays":{if(S.rest.length>1)throw lc("Invalid schema representation document",[...w,"rest"]);let C={type:"array"},R=S.elements.length,M=S.elements.map(($,te)=>{$.isOptional&&R--;let xe=b($.type,[...w,"elements",te,"type"],k),Le=Rm($.annotations,n);return Le===void 0?xe:h(Om(xe,Le))});if(M.length>0?(C.prefixItems=M,C.maxItems=S.elements.length,R>0&&(C.minItems=R)):C.items=!1,S.rest.length===1){delete C.maxItems;let $=b(S.rest[0],[...w,"rest",0],k);Object.keys($).length>0?C.items=$:delete C.items}return C}case"Objects":{if(S.propertySignatures.length===0&&S.indexSignatures.length===0)return{not:{type:"null"}};let C={type:"object"},R={},M=[];for(let Ee=0;Ee<S.propertySignatures.length;Ee++){let Oe=S.propertySignatures[Ee];if(typeof Oe.name!="string")throw lc("Invalid schema representation document",[...w,"propertySignatures",Ee,"name"]);let rr=Oe.name,lo=b(Oe.type,[...w,"propertySignatures",Ee,"type"],k),Xs=Rm(Oe.annotations,n);B(R,rr,Xs===void 0?lo:h(Om(lo,Xs))),Oe.isOptional||M.push(rr)}S.propertySignatures.length>0&&(C.properties=R),M.length>0&&(C.required=M);let $={},te=[],xe=[],Le=!1;for(let Ee=0;Ee<S.indexSignatures.length;Ee++){let Oe=S.indexSignatures[Ee],rr=b(Oe.type,[...w,"indexSignatures",Ee,"type"],k);Z(rr,{not:{}})&&(rr=!1),xe.push(rr);let lo=T(Oe.parameter,[...w,"indexSignatures",Ee,"parameter"],new Set);if(lo===void 0){Le=!0,k.push(!1);continue}if(lo.length===0)te.push(rr);else for(let Xs of lo){let Rn=$[Xs];B($,Xs,Rn===void 0?rr:Rn===!1||rr===!1?!1:h(Om(Rn,rr)))}}let Er=Object.keys($).length>0;if(Er&&(C.patternProperties=$),Le&&n?.onExcessProperty==="error"){let Ee=[];S.propertySignatures.length>0&&Ee.push({enum:Object.keys(R)});for(let Oe=0;Oe<S.indexSignatures.length;Oe++)Ee.push(b(S.indexSignatures[Oe].parameter,[...w,"indexSignatures",Oe,"parameter"],k));C.propertyNames=Ee.length===1?Ee[0]:{anyOf:Ee},C.additionalProperties=xe.length===1?xe[0]:{anyOf:xe},te.length>0&&(C.allOf=te.map(Oe=>({type:"object",additionalProperties:Oe})))}else te.length===0?C.additionalProperties=Le||n?.onExcessProperty!=="error":te.length===1&&S.propertySignatures.length===0&&!Er?C.additionalProperties=te[0]:te.length>0&&(C.allOf=te.map(Ee=>({type:"object",additionalProperties:Ee})));return typeof C.additionalProperties=="object"&&C.additionalProperties!==null&&Object.keys(C.additionalProperties).length===0&&delete C.additionalProperties,C}case"Union":{let C=[],R=S.types.map(($,te)=>b($,[...w,"types",te],C));if(k.push(C),R.length===0)return{not:{}};let M=S.options?.mode??"anyOf";if(M==="anyOf"&&R.length>1){let $=N9(R);if($!==void 0)return $}return M==="oneOf"&&a.set(R,[C,[]]),{[M]:R}}}}function T(S,w,k){switch(S._tag){case"Reference":{if(!Object.hasOwn(r,S.$ref))throw lc(`Invalid reference ${S.$ref}`,[...w,"$ref"]);if(x(S.$ref,w),k.has(S.$ref))return;let C=new Set(k).add(S.$ref);return T(r[S.$ref],["references",S.$ref],C)}case"String":{if(S.checks.length===0)return[];if(S.checks.length!==1||S.checks[0]._tag!=="Filter"||S.checks[0].annotations?.toJsonSchema===void 0)return;let C=[],R=b(S,w,C);return cC(C)&&R.type==="string"&&typeof R.pattern=="string"&&gS(R,"|type|pattern|title|description|default|examples|readOnly|writeOnly|")?[R.pattern]:void 0}case"TemplateLiteral":return S.checks.length===0?[`^${S.parts.map(yS).join("")}$`]:void 0;case"Union":{if(S.types.length===0||S.checks.length>0||S.options?.mode==="oneOf")return;let C=[];for(let R=0;R<S.types.length;R++){let M=T(S.types[R],[...w,"types",R],k);if(M===void 0)return;if(M.length===0)return[];C.push(...M)}return C}default:throw lc("Invalid schema representation document",w)}}}function F9(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}function N9(e){let t,r=[];for(let n of e){if(Object.keys(n).length!==2||n.type===void 0||!Array.isArray(n.enum)||n.enum.length===0)return;if(t===void 0)t=n.type;else if(n.type!==t)return;for(let s of n.enum){if(r.includes(s))return;r.push(s)}}return{type:t,enum:r}}function yS(e){switch(e._tag){case"Literal":return ha(globalThis.String(e.literal));case"String":return Q2;case"Number":return Gy;case"TemplateLiteral":return e.parts.map(yS).join("");case"Union":return`(?:${e.types.map(yS).join("|")})`;default:throw lc("Invalid schema representation document",[])}}function SS(e,t){let r=M9([e.representation],[["representation"]],e.references,t);return{dialect:r.dialect,schema:r.schemas[0],definitions:r.definitions}}var U9=({identifier:e})=>e;function Bs(e){return e===void 0?void 0:{annotations:e}}function _m(e,t){let{references:r,representations:n}=D9([e],t);return{representation:n[0],references:r}}function D9(e,t){let r={},n=new Map,o=new Set,s=new Map,i=new Set;for(let S of e)h(S);let a=t?.referencePolicy??U9;for(let S of s.values())for(let w of S.values()){let k=a({ast:w.ast,occurrences:w.occurrences,identifier:w.identifier});if(k!==void 0){let C=k===w.identifier||!k.endsWith("_")?"_":"";w.reference=u(k,w,C)}else w.isRecursive&&(w.reference=u(`${w.ast._tag}_`,w,""))}return{representations:Bo(e,S=>g(S)),references:r};function u(S,w,k="_"){let C=S,R=0;for(;n.has(C);){if(n.get(C)===w)return C;C=`${S}${k}${++R}`}return n.set(C,w),C}function f(S,w,k){let C=w.fallback;return C!==void 0?Jw(S)===C?S:Fs(S,{[Pu]:C}):k===w.identifier?S:Fs(S,{identifier:k})}function p(S,w){if(!Object.hasOwn(r,S)&&!o.has(S)){o.add(S);let k=y(w);o.delete(S),B(r,S,k)}return{_tag:"Reference",$ref:S}}function m(S){let w=Bl(S),k=Ll(w),C=Al(w),R=C===void 0?(w!==S?Al(S):void 0)??Jw(w):void 0;R!==void 0&&(C=`${R}Encoded`);let M=s.get(k);M===void 0&&(M=new Map,s.set(k,M));let $=M.get(C);return $===void 0&&($={ast:k,identifier:C,fallback:R,occurrences:0,isRecursive:!1,reference:void 0},M.set(C,$)),$}function h(S){let w=m(S),k=w.ast;if(w.occurrences++,i.has(w)){w.isRecursive=!0;return}if(!(w.occurrences>1)){switch(i.add(w),x(k.checks),k._tag){case"Declaration":case"Arrays":case"Objects":case"Union":k.recur(C=>(h(C),C));break;case"TemplateLiteral":k.parts.forEach(h);break;case"Suspend":h(k.thunk());break}i.delete(w)}}function x(S){S?.forEach(w=>{w.annotations?.representation?.schemas?.forEach(k=>h(Mt(k))),w._tag==="FilterGroup"&&x(w.checks)})}function g(S){let w=m(S),k=w.ast,C=w.reference;if(C!==void 0){let R=w.identifier===void 0?k:f(k,w,C);return p(C,R)}return y(k)}function y(S){let w=E(S.checks);switch(S._tag){case"Declaration":return{_tag:"Declaration",typeParameters:S.typeParameters.map(k=>g(k)),checks:w,...v(S.annotations)};case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"String":case"Boolean":case"Number":case"BigInt":case"Symbol":case"ObjectKeyword":return{_tag:S._tag,checks:w,...Bs(S.annotations)};case"Literal":return{_tag:"Literal",literal:S.literal,checks:w,...Bs(S.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:S.symbol,checks:w,...Bs(S.annotations)};case"Enum":return{_tag:"Enum",enums:S.enums,checks:w,...Bs(S.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:S.parts.map(k=>g(k)),checks:w,...Bs(S.annotations)};case"Arrays":return{_tag:"Arrays",elements:S.elements.map(k=>{let C=Bl(k),R=C.context?.annotations;return{isOptional:Lr(C),type:g(k),...Bs(R)}}),rest:S.rest.map(k=>g(k)),checks:w,...Bs(S.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:S.propertySignatures.map(k=>{let C=Bl(k.type),R=C.context?.annotations;return{name:k.name,type:g(k.type),isOptional:Lr(C),isMutable:V2(C),...Bs(R)}}),indexSignatures:S.indexSignatures.map(k=>({parameter:g(k.parameter),type:g(k.type)})),checks:w,...Bs(S.annotations)};case"Union":return{_tag:"Union",types:S.types.map(k=>g(k)),...S.options===void 0?{}:{options:S.options},checks:w,...Bs(S.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:g(S.thunk()),...Bs(S.annotations)}}}function E(S){return S?.map(b)??[]}function b(S){switch(S._tag){case"Filter":return{_tag:"Filter",aborted:S.aborted,...T(S.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:Bo(S.checks,b),...T(S.annotations)}}}function v(S){if(S===void 0)return;let{representation:w,...k}=S;return{...w===void 0?void 0:{representation:w},...Object.keys(k).length===0?void 0:{annotations:k}}}function T(S){if(S===void 0)return;let{representation:w,...k}=S,C=w===void 0?void 0:w.schemas===void 0?w:{...w,schemas:w.schemas.map(R=>g(Mt(R)))};return{...C===void 0?void 0:{representation:C},...Object.keys(k).length===0?void 0:{annotations:k}}}}function QL(e){return ft(e)?e.value:{issues:[{message:xN(e.cause)}]}}function XL(e,t){let r=ot(e),n={errors:"all",...t?.parseOptions},o=x1(t),s=i=>{let a=new fi("sync"),c=Gp(V0(r(i,n),{onFailure:o,onSuccess:f=>({value:f})}),{scheduler:a});c.currentDispatcher?.flush();let u=c.pollUnsafe();return u?QL(u):new Promise(f=>{c.addObserver(p=>{f(QL(p))})})};if(Object.hasOwn(e,"~standard")){let i=e;return"validate"in i["~standard"]||Object.assign(i["~standard"],{validate:s}),i}return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}function L9(e){let t=_m(Kl(e));return SS(t)}function YL(e,t){let r=L9(e);if(t==="draft-2020-12"){let n=r.schema;return Object.keys(r.definitions).length>0&&(n.$defs=r.definitions),n}else if(t==="draft-07"){let n=_L(r),o=n.schema;return Object.keys(n.definitions).length>0&&(o.definitions=n.definitions),o}throw new globalThis.Error(`Unsupported target: ${t}`)}function eB(e){let t={input(r){return YL(e.ast,r.target)},output(r){return YL(Mt(e.ast),r.target)}};if(Object.hasOwn(e,"~standard")){let r=e;return"jsonSchema"in r["~standard"]||Object.assign(r["~standard"],{jsonSchema:t}),r}return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}function rB(e,t){let r=[];return fC(e,t,"",r),r}function fC(e,t,r,n){if(!Object.is(e,t)){if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,s=t.length,i=Math.min(o,s);for(let a=0;a<i;a++)fC(e[a],t[a],`${r}/${a}`,n);for(let a=o-1;a>=s;a--)n.push({op:"remove",path:`${r}/${a}`});for(let a=o;a<s;a++)n.push({op:"add",path:`${r}/${a}`,value:t[a]});return}if(bS(e)&&bS(t)){let o=Object.keys(e),s=Object.keys(t),i=Array.from(new Set([...o,...s])).sort();for(let a of i){let c=`${r}/${tC(a)}`,u=Object.hasOwn(e,a),f=Object.hasOwn(t,a);u&&f?fC(e[a],t[a],c,n):!u&&f?n.push({op:"add",path:c,value:t[a]}):n.push({op:"remove",path:c})}return}n.push({op:"replace",path:r,value:t})}}function nB(e,t){let r=t;for(let n of e)r=H9(r,n);return r}function bS(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $9(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw new Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(Am)}function oB(e){if(!/^(0|[1-9]\d*)$/.test(e))throw new Error(`Invalid array index: "${e}"`);return Number(e)}function H9(e,t){if(t.path===""){if(t.op==="remove")throw new Error("Unsupported operation at the root");return t.value}let r=j9(e,t.path);if(r===null)throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:n,parent:o,stack:s}=r;if(Array.isArray(o)){if(n==="-"&&t.op!=="add")throw new Error(`"-" is not valid for ${t.op} at "${t.path}".`);let i=n==="-"?o.length:oB(n),a=t.op==="add"?o.length:o.length-1;if(i>a)throw new Error(`Array index out of bounds at "${t.path}".`);let c=o.slice();return t.op==="add"?c.splice(i,0,t.value):t.op==="remove"?c.splice(i,1):c[i]=t.value,tB(s,c)}if(bS(o)){if(t.op!=="add"&&!Object.hasOwn(o,n))throw new Error(`Property "${n}" does not exist at "${t.path}".`);let i={...o};return t.op==="remove"?delete i[n]:B(i,n,t.value),tB(s,i)}throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function j9(e,t){let r=$9(t);if(r.length===0)return null;let n=r[r.length-1],o=[],s=e;for(let i=0;i<r.length-1;i++){let a=r[i];if(Array.isArray(s)){let c=oB(a);if(c>=s.length)return null;o.push({container:s,token:c}),s=s[c];continue}if(bS(s)){if(!Object.hasOwn(s,a))return null;o.push({container:s,token:a}),s=s[a];continue}return null}return{stack:o,parent:s,lastToken:n}}function tB(e,t){let r=t;for(let n=e.length-1;n>=0;n--){let{container:o,token:s}=e[n];if(Array.isArray(o)){let i=o.slice();i[s]=r,r=i}else{let i={...o};B(i,s,r),r=i}}return r}function iB(e){let t=mS(e),r=lS(t),n=fS(t);return{empty:[],diff:(o,s)=>rB(r(o),r(s)),combine:(o,s)=>[...o,...s],patch:(o,s)=>{let i=r(o),a=nB(s,i);return Object.is(a,i)?o:n(a)}}}function aB(e,t){let r=Al(e.ast)??Gw(e.ast),n=xL(xS(e));return o=>n(o).pipe(K(s=>z9(s,{rootName:r,...t})))}function z9(e,t){let r=t.rootName??"root",n=t.arrayItemName??"item",o=t.pretty??!0,s=t.indent??" ",i=t.sortKeys??!0,a=new Set,c=[];return f(r,e,0),c.join(o?`
28
+ `:"");function u(p,m){c.push(o?s.repeat(p)+m:m)}function f(p,m,h,x){let{attrs:g,safe:y}=Vl.tagInfo(p,x);if(m===void 0)u(h,`<${y}${g}/>`);else if(typeof m=="string")u(h,`<${y}${g}>${Vl.escapeText(m)}</${y}>`);else if(typeof m!="object"||m===null)u(h,`<${y}${g}>${Vl.escapeText(j(m))}</${y}>`);else{if(a.has(m))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:m});a.add(m);try{if(globalThis.Array.isArray(m)){if(m.length===0){u(h,`<${y}${g}/>`);return}u(h,`<${y}${g}>`);for(let v of m)f(n,v,h+1);u(h,`</${y}>`);return}let E=m,b=Object.keys(E);if(i&&b.sort(),b.length===0){u(h,`<${y}${g}/>`);return}u(h,`<${y}${g}>`);for(let v of b)f(Vl.parseTagName(v).safe,E[v],h+1,v);u(h,`</${y}>`)}finally{a.delete(m)}}}}var Vl={escapeText(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},escapeAttribute(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},parseTagName(e){let t=e,r=e;return/^[A-Za-z_]/.test(r)||(r="_"+r),r=r.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(r)&&(r="_"+r),{safe:r,changed:r!==t}},tagInfo(e,t){let{changed:r,safe:n}=Vl.parseTagName(e),s=r||t&&t!==e?` data-name="${Vl.escapeAttribute(t??e)}"`:"";return{safe:n,attrs:s}}};var lC=mo(e=>dc(e));function dc(e){let t=da(e)?.toEquivalence;if(t)return t(Dl(e)?e.typeParameters.map(dc):[]);switch(e._tag){case"Never":return Gc();case"Declaration":return K9(e);case"Null":case"Undefined":case"Void":case"Unknown":case"Any":case"String":case"Number":case"Boolean":case"BigInt":case"Symbol":case"Literal":case"UniqueSymbol":case"ObjectKeyword":case"Enum":case"TemplateLiteral":return Z;case"Arrays":{let r=e.elements.map(dc),n=e.rest.map(dc),[o,...s]=n,i=s.length;return Wr((a,c)=>{if(!Array.isArray(a)||!Array.isArray(c))return!1;let u=a.length;if(u!==c.length)return!1;let f=0;for(;f<Math.min(u,e.elements.length);f++)if(!r[f](a[f],c[f]))return!1;if(n.length>0){for(;f<u-i;f++)if(!o(a[f],c[f]))return!1;for(let p=0;p<i;p++)if(!s[p](a[f+p],c[f+p]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return Z;let r=e.propertySignatures.map(o=>dc(o.type)),n=e.indexSignatures.map(o=>dc(o.type));return Wr((o,s)=>{if(!Gt(o)||!Gt(s))return!1;for(let i=0;i<r.length;i++){let a=e.propertySignatures[i],c=a.name,u=Object.hasOwn(o,c),f=Object.hasOwn(s,c);if(Lr(a.type)&&u!==f||u&&f&&!r[i](o[c],s[c]))return!1}for(let i=0;i<n.length;i++){let a=e.indexSignatures[i],c=_i(o,a.parameter),u=_i(s,a.parameter);if(c.length!==u.length)return!1;for(let f=0;f<c.length;f++){let p=c[f];if(!Object.hasOwn(s,p)||!n[i](o[p],s[p]))return!1}}return!0})}case"Union":{let r=Mt(e).types,n=Im(r),o=r.map((s,i)=>[Cm(s),dc(e.types[i])]);return Wr((s,i)=>{let a=n(s,!1);for(let c=0;c<a.length;c++){let[u,f]=o[a[c]];if(u(s)&&u(i))return f(s,i)}return!1})}case"Suspend":{let r;return Wr((n,o)=>(r??=lC(e.thunk()))(n,o))}}}function K9(e){let t=e.annotations?.representation;if(t===void 0)return Z;switch(t.id){case"effect/schema/Option":{let[r]=Hu(e);return(n,o)=>n._tag===o._tag&&(n._tag==="None"||r(n.value,o.value))}case"effect/schema/Result":{let[r,n]=Hu(e);return(o,s)=>o._tag===s._tag&&(o._tag==="Success"?r(o.success,s.success):n(o.failure,s.failure))}case"effect/schema/CauseReason":{let[r,n]=Hu(e);return uB(r,n)}case"effect/schema/Cause":{let[r,n]=Hu(e);return cB(r,n)}case"effect/schema/Exit":{let[r,n,o]=Hu(e),s=cB(n,o);return(i,a)=>i._tag===a._tag&&(i._tag==="Success"?r(i.value,a.value):s(i.cause,a.cause))}case"effect/schema/ReadonlyMap":{let[r,n]=Hu(e);return mx(r,n)}case"effect/schema/ReadonlySet":return Hd(Hu(e)[0]);case"effect/schema/RegExp":return(r,n)=>r.source===n.source&&r.flags===n.flags;case"effect/schema/URL":return(r,n)=>r.toString()===n.toString();default:return Z}}function Hu(e){return e.typeParameters.map(dc)}function uB(e,t){return(r,n)=>{if(r._tag!==n._tag)return!1;switch(r._tag){case"Fail":return e(r.error,n.error);case"Die":return t(r.defect,n.defect);case"Interrupt":return r.fiberId===n.fiberId}}}function cB(e,t){let r=Ex(uB(e,t));return(n,o)=>r(n.reasons,o.reasons)}function lB(e,t){return r=>{switch(r._tag){case"Fail":return`Fail(${e(r.error)})`;case"Die":return`Die(${t(r.defect)})`;case"Interrupt":return"Interrupt"}}}function fB(e,t){let r=lB(e,t);return n=>`Cause([${n.reasons.map(r).join(", ")}])`}function dB(e,t){let r=new Map;return n(e);function n(i){let a=r.get(i);return a===void 0&&(a=o(i),r.set(i,a)),a}function o(i){let a=da(i)?.toFormatter;if(typeof a=="function")return a(Dl(i)?i.typeParameters.map(n):[]);if(t?.onBefore){let c=t.onBefore(i,n);if(c!==void 0)return c}return s(i)}function s(i){switch(i._tag){default:return j;case"Never":return()=>"never";case"Void":return()=>"void";case"Declaration":{let a=i.annotations?.representation;if(a===void 0)return j;let c=i.typeParameters.map(n);switch(a.id){case"effect/schema/Option":{let[u]=c;return Zt({onNone:()=>"none()",onSome:f=>`some(${u(f)})`})}case"effect/schema/Result":{let[u,f]=c;return zn({onSuccess:p=>`success(${u(p)})`,onFailure:p=>`failure(${f(p)})`})}case"effect/schema/CauseReason":return lB(c[0],c[1]);case"effect/schema/Cause":return fB(c[0],c[1]);case"effect/schema/Exit":{let[u,f,p]=c,m=fB(f,p);return h=>{switch(h._tag){case"Success":return`Exit.Success(${u(h.value)})`;case"Failure":return`Exit.Failure(${m(h.cause)})`}}}case"effect/schema/ReadonlyMap":{let[u,f]=c;return p=>{let m=p.size;if(m===0)return"ReadonlyMap(0) {}";let h=globalThis.Array.from(p.entries()).sort().map(([x,g])=>`${u(x)} => ${f(g)}`);return`ReadonlyMap(${m}) { ${h.join(", ")} }`}}case"effect/schema/HashMap":{let[u,f]=c;return p=>{let m=ND(p);if(m===0)return"HashMap(0) {}";let h=nm(p).sort().map(([x,g])=>`${u(x)} => ${f(g)}`);return`HashMap(${m}) { ${h.join(", ")} }`}}case"effect/schema/ReadonlySet":{let[u]=c;return f=>{let p=f.size;if(p===0)return"ReadonlySet(0) {}";let m=globalThis.Array.from(f.values()).sort().map(h=>`${u(h)}`);return`ReadonlySet(${p}) { ${m.join(", ")} }`}}case"effect/schema/HashSet":{let[u]=c;return f=>{let p=BD(f);if(p===0)return"HashSet(0) {}";let m=globalThis.Array.from(f).sort().map(h=>`${u(h)}`);return`HashSet(${p}) { ${m.join(", ")} }`}}case"effect/schema/Chunk":{let[u]=c;return f=>{let p=dD(f);if(p===0)return"Chunk(0) {}";let m=globalThis.Array.from(f).sort().map(h=>`${u(h)}`);return`Chunk(${p}) { ${m.join(", ")} }`}}default:return j}}case"Arrays":{let a=i.elements.map(m=>n(m)),c=i.rest.map(n),[u,...f]=c,p=f.length;return m=>{let h=[],x=0;for(;x<a.length;x++)if(m.length<x+1){if(Lr(i.elements[x]))continue}else h.push(a[x](m[x]));if(c.length>0){for(;x<m.length-p;x++)h.push(u(m[x]));for(let g=0;g<p;g++)h.push(f[g](m[x+g]))}return"["+h.join(", ")+"]"}}case"Objects":{let a=i.propertySignatures.map(u=>n(u.type)),c=i.indexSignatures.map(u=>n(u.type));return i.propertySignatures.length===0&&i.indexSignatures.length===0?j:u=>{let f=[],p=new Set;for(let m=0;m<a.length;m++){let h=i.propertySignatures[m],x=h.name;p.add(x),!(Lr(h.type)&&!Object.hasOwn(u,x))&&f.push(`${ni(x)}: ${a[m](u[x])}`)}for(let m=0;m<c.length;m++){let h=_i(u,i.indexSignatures[m].parameter);for(let x of h)p.has(x)||(p.add(x),f.push(`${ni(x)}: ${c[m](u[x])}`))}return f.length>0?"{ "+f.join(", ")+" }":"{}"}}case"Union":{let a=Mt(i).types,c=Im(a),u=a.map((f,p)=>[Cm(f),n(i.types[p])]);return f=>{let p=c(f,!1);for(let m=0;m<p.length;m++){let[h,x]=u[p[m]];if(h(f))return x(f)}return j(f)}}case"Suspend":{let a;return c=>(a??=n(i.thunk()))(c)}}}}var dC=d(2,(e,t)=>hC(e,(r,n)=>mB(t,r)?[r,n]:void 0)),pC=d(2,(e,t)=>hC(e,(r,n)=>mB(t,r)?void 0:[r,n])),pB=d(2,(e,t)=>({...e,...t}));var mC=d(2,(e,t)=>hC(e,(r,n)=>[Object.hasOwn(t,r)?t[r]:r,n]));var bn=e=>e;function mB(e,t){return e.some(r=>r===t||typeof r=="number"&&String(r)===t)}function hC(e,t){let r={};for(let n of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;let o=t(n,e[n]);if(o){let[s,i]=o;B(r,s,i)}}return r}function gB(e,t){return $s(Jl("Iso",e,t))}function hB(e,t){return $s(Jl("Lens",e,t))}function Jl(e,t,r){return[{_tag:"PrimitiveNode",kind:e,get:t,set:r}]}var G9={kind:"Iso",get:F,set:F},ES=class{_tag="PathNode";kind="Lens";path;get;set;constructor(t){this.path=t,this.get=r=>{let n=r;for(let o=0;o<t.length;o++)n=n[t[o]];return n},this.set=(r,n)=>{let o=IS(n),s=o,i=0;for(;i<t.length-1;i++){let a=t[i];B(s,a,IS(s[a])),s=s[a]}return B(s,t[i],r),o}}},Pm=class{_tag="CheckNode";kind="Prism";checks;get;set=F;constructor(t){this.checks=t,this.get=r=>eL(t,r)}};function ju(e,t){if(e.length===0)return t;if(t.length===0)return e;let r=e.slice();for(let n=0;n<t.length;n++){let o=t[n],s=r[r.length-1];s._tag==="PathNode"&&o._tag==="PathNode"?r[r.length-1]=new ES([...s.path,...o.path]):s._tag==="CheckNode"&&o._tag==="CheckNode"?r[r.length-1]=new Pm([...s.checks,...o.checks]):r.push(o)}return r}function Z9(e,t){return $s(Jl("Optional",e,t))}var Gl=class{node;getResult;replaceResult;constructor(t,r,n){this.node=t,this.getResult=r,this.replaceResult=n}replace(t,r){return op(this.replaceResult(t,r),()=>r)}modify(t){return r=>op(hr(this.getResult(r),n=>this.replaceResult(t(n),r)),()=>r)}compose(t){return $s(ju(this.node,t.node))}key(t){return $s(ju(this.node,[new ES([t])]))}optionalKey(t){return $s(ju(this.node,Jl("Lens",r=>r[t],(r,n)=>{let o=IS(n);return r===void 0?Array.isArray(o)&&(typeof t=="number"||typeof t=="string"&&Dx(t))?o.splice(Number(t),1):delete o[t]:B(o,t,r),o})))}check(...t){return $s(ju(this.node,[new Pm(t)]))}refine(t,r){return $s(ju(this.node,[new Pm([Xy(t,r)])]))}tag(t){let r=re(new le({expected:`${JSON.stringify(t)} tag`}));return $s(ju(this.node,Jl("Prism",n=>n._tag===t?X(n):r,F)))}at(t,...r){let n=re(new Ct([t],new Yt(void 0)));return $s(ju(this.node,Jl("Optional",o=>Object.hasOwn(o,t)?X(o[t]):n,(o,s)=>{if(Object.hasOwn(s,t)){let i=IS(s);return B(i,t,o),X(i)}else return n})))}pick(t){return this.compose(hB(dC(t),(r,n)=>({...pC(n,t),...r})))}omit(t){return this.compose(hB(pC(t),(r,n)=>({...dC(n,t),...r})))}notUndefined(){return this.refine(ei,{expected:"a value other than `undefined`"})}forEach(t){let r=t(TS());return Z9(n=>Vr(this.getResult(n),o=>{let s=[];for(let i=0;i<o.length;i++){let a=r.getResult(o[i]);tt(a)&&s.push(a.success)}return s}),(n,o)=>hr(this.getResult(o),s=>{let i=[];for(let c=0;c<s.length;c++)tt(r.getResult(s[c]))&&i.push(c);if(n.length!==i.length)return re(new le({message:`each: replacement length mismatch: ${n.length} !== ${i.length}`}));let a=s.slice();for(let c=0;c<i.length;c++){let u=i[c],f=r.replaceResult(n[c],s[u]);if(be(f))return re(new Ct([u],f.failure));a[u]=f.success}return this.replaceResult(a,o)}))}modifyAll(t){return r=>op(hr(this.getResult(r),n=>this.replaceResult(n.map(t),r)),()=>r)}},gC=class extends Gl{get;set;constructor(t,r,n){super(t,o=>X(r(o)),o=>X(n(o))),this.get=r,this.set=n}replace(t,r){return this.set(t)}modify(t){return r=>this.set(t(this.get(r)))}},yC=class extends Gl{get;constructor(t,r,n){super(t,o=>X(r(o)),(o,s)=>X(n(o,s))),this.get=r,this.replace=n}modify(t){return r=>this.replace(t(this.get(r)),r)}},SC=class extends Gl{set;constructor(t,r,n){super(t,r,(o,s)=>X(n(o))),this.set=n}replace(t,r){return this.set(t)}modify(t){return r=>op(Vr(this.getResult(r),n=>this.set(t(n))),()=>r)}};function $s(e){let t=e[0]??G9;if(e.length>1){let r=e.reduce((n,o)=>X9(n,o.kind),"Iso");t={kind:r,get:Q9(e,r),set:Y9(e,r)}}switch(t.kind){case"Iso":return new gC(e,t.get,t.set);case"Lens":return new yC(e,t.get,t.set);case"Prism":return new SC(e,t.get,t.set);case"Optional":return new Gl(e,t.get,t.set)}}function IS(e){if(Array.isArray(e))return e.slice();if(typeof e=="object"&&e!==null){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}function Q9(e,t){return r=>{for(let n=0;n<e.length;n++){let o=e[n],s=o.get(r);if(bC(o.kind)){if(be(s))return s;r=s.success}else r=s}return bC(t)?X(r):r}}function Y9(e,t){return xB(t)?r=>{for(let n=e.length-1;n>=0;n--)r=e[n].set(r);return r}:(r,n)=>{let o=e.length,s=new Array(o);for(let i=0;i<o;i++){s[i]=n;let a=e[i];if(bC(a.kind)){let c=a.get(n);if(be(c))return c;n=c.success}else n=a.get(n)}for(let i=o-1;i>=0;i--){let a=e[i];if(xB(a.kind))r=a.set(r);else if(a.kind==="Lens")r=a.set(r,s[i]);else{let c=a.set(r,s[i]);if(be(c))return c;r=c.success}}return t==="Optional"?X(r):r}}function bC(e){return e==="Prism"||e==="Optional"}function xB(e){return e==="Iso"||e==="Prism"}function X9(e,t){return e==="Iso"?t:t==="Iso"||e===t?e:"Optional"}var eY=$s([]);function TS(){return eY}function SB(e){let t=hS(e);return gB(lS(t),fS(t))}function bB(e){return TS()}function EB(e){return TS()}var Zl="~effect/Schema/SchemaError";function IB(e){return O(e,Zl)&&e[Zl]===Zl}var Mo="~effect/net/NetAddress";var Hs=e=>e.value,js=e=>e,xa=e=>e.bytes,es=class extends sr("NetAddressError"){},Ql=e=>O(e,Mo),Br=e=>Ql(e)&&e._tag==="Ipv4Address",ts=e=>Ql(e)&&e._tag==="Ipv6Address",EC=e=>Br(e)||ts(e),Yl=e=>Br(e)?32:128;var Xl=e=>Ql(e)&&e._tag==="MacAddress",Fm=e=>Ql(e)&&e._tag==="InetAddressV4",Nm=e=>Ql(e)&&e._tag==="InetAddressV6",IC=e=>Fm(e)||Nm(e),wS=e=>Ql(e)&&e._tag==="UnixPathAddress",TB=e=>IC(e)||wS(e),rY={...kt,_tag:"Ipv4Address",[Mo]:Mo,[ae](e){return Br(e)&&Hs(this)===Hs(e)},[ie](){return _r(he(iY,Hs(this)|0))},toString(){return $r(this)},toJSON(){return this.toString()}},nY={...kt,_tag:"Ipv6Address",[Mo]:Mo,[ae](e){if(!ts(e))return!1;let t=js(this),r=js(e);return t.w0===r.w0&&t.w1===r.w1&&t.w2===r.w2&&t.w3===r.w3},[ie](){let e=js(this),t=he(aY,e.w0|0);return t=he(t,e.w1|0),t=he(t,e.w2|0),_r(he(t,e.w3|0))},toString(){return $r(this)},toJSON(){return this.toString()}},oY={...kt,_tag:"MacAddress",[Mo]:Mo,[ae](e){return Xl(e)&&sY(xa(this),xa(e))},[ie](){return he(cY,ri(xa(this)))},toString(){return vC(this)},toJSON(){return this.toString()}},sY=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},iY=Be("Ipv4Address"),aY=Be("Ipv6Address"),cY=Be("MacAddress"),uY=e=>{let t=Object.create(rY);return t.value=e>>>0,Object.freeze(t)},fY=(e,t,r,n)=>{let o=Object.create(nY);return o.w0=e>>>0,o.w1=t>>>0,o.w2=r>>>0,o.w3=n>>>0,Object.freeze(o)},lY=(e,t,r,n)=>(e<<24|t<<16|r<<8|n)>>>0;var Mm=e=>[e>>>24,e>>>16&255,e>>>8&255,e&255],dY=e=>{let t=Object.assign(Object.create(oY),{bytes:new Uint8Array(e)});return Object.freeze(t)};var Ft=(e,t)=>re(new es({input:e,message:t})),wB=(e,t)=>{for(let r=0;r<e.length;r++){let n=e[r];if(!Number.isInteger(n)||n<0||n>t)return!1}return!0},pY=e=>wB(e,255)?X(uY(lY(e[0],e[1],e[2],e[3]))):Ft(e,"octets must be integers from 0 through 255"),mY=e=>wB(e,65535)?X(fY(e[0]*65536+e[1],e[2]*65536+e[3],e[4]*65536+e[5],e[6]*65536+e[7])):Ft(e,"segments must be integers from 0 through 65535");var vB=e=>/^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/.test(e)?X(dY(new Uint8Array(e.split(":").map(t=>Number.parseInt(t,16))))):Ft(e,"expected six two-digit hexadecimal octets separated by colons");var qu=e=>{let t=e.split(".");if(t.length!==4||t.some(n=>!/^\d{1,3}$/.test(n)))return Ft(e,"expected exactly four decimal octets");if(t.some(n=>n.length>1&&n[0]==="0"))return Ft(e,"leading zeroes are not allowed");let r=t.map(Number);return r.some(n=>n>255)?Ft(e,"octets must be at most 255"):pY([r[0],r[1],r[2],r[3]])},hY=e=>{if(e.includes("[")||e.includes("]")||e.includes("%"))return Ft(e,"brackets and zone identifiers are not valid in a bare IPv6 address");let t=e.split("::");if(t.length>2)return Ft(e,"only one compression marker is allowed");let r=t[0]===""?[]:t[0].split(":"),n=t.length===2&&t[1]!==""?t[1].split(":"):[];if(r.some(f=>f==="")||n.some(f=>f===""))return Ft(e,"empty segments are only valid in the compression marker");let o=n.length>0?n[n.length-1]:r.length>0?r[r.length-1]:"",s;if(o.includes(".")){if(t.length===2&&n.length===0)return Ft(e,"embedded IPv4 syntax must be trailing");let f=Vr(qu(o),p=>{let m=Hs(p);return[m>>>16,m&65535]});if(be(f))return f;s=f.success,n.length>0?n.pop():r.pop()}let i=r.length+n.length+(s?2:0);if(t.length===1?i!==8:i>=8)return Ft(e,t.length===1?"expected eight segments":"compression must replace at least one segment");let a=f=>/^[0-9a-fA-F]{1,4}$/.test(f)?Number.parseInt(f,16):void 0,c=r.map(a),u=n.map(a);return c.some(f=>f===void 0)||u.some(f=>f===void 0)?Ft(e,"segments must contain one through four hexadecimal digits"):X([...c,...Array(8-i).fill(0),...u,...s??[]])},zu=e=>hr(hY(e),t=>mY(t)),pc=e=>e.includes(":")?zu(e):qu(e);var TC=e=>{if(typeof e!="string"||!e.includes("%"))return!1;let t=Um(e);return tt(t)&&t.success===e},Um=e=>{let t=e.indexOf("%");if(t===-1)return Ft(e,"expected an IPv6 zone");let r=e.slice(t+1);if(r.length===0||/[%[\]/\s\p{Cc}]/u.test(r))return Ft(e,"invalid IPv6 scope identifier");if(/^\d+$/.test(r)){let n=Number(r);if(n>4294967295)return Ft(e,"scope identifier must be an unsigned 32-bit integer");r=String(n)}return Vr(zu(e.slice(0,t)),n=>`${$r(n)}%${r}`)};var vS=e=>Mm(Hs(e)),xY=e=>{let{w0:t,w1:r,w2:n,w3:o}=js(e);return[t>>>16,t&65535,r>>>16,r&65535,n>>>16,n&65535,o>>>16,o&65535]},wC=e=>{let{w0:t,w1:r,w2:n,w3:o}=js(e);return[...Mm(t),...Mm(r),...Mm(n),...Mm(o)]};var vC=e=>Array.from(xa(e),t=>t.toString(16).padStart(2,"0")).join(":"),CS=e=>xa(e).every(t=>t===255),gY=e=>(xa(e)[0]&1)!==0,AS=e=>(xa(e)[0]&1)===0,CC=e=>(xa(e)[0]&2)!==0,AC=e=>(xa(e)[0]&2)===0;var $r=e=>{if(Br(e))return vS(e).join(".");let t=xY(e);if(yY(e))return`::ffff:${t[6]>>8}.${t[6]&255}.${t[7]>>8}.${t[7]&255}`;let r=-1,n=0,o=-1;for(let a=0;a<=8;a++)a<8&&t[a]===0?o===-1&&(o=a):o!==-1&&(a-o>n&&(r=o,n=a-o),o=-1);if(n<2)return t.map(a=>a.toString(16)).join(":");let s=t.slice(0,r).map(a=>a.toString(16)).join(":"),i=t.slice(r+n).map(a=>a.toString(16)).join(":");return`${s}::${i}`},kS=e=>{if(Br(e))return Hs(e)===0;let{w0:t,w1:r,w2:n,w3:o}=js(e);return t===0&&r===0&&n===0&&o===0},kC=e=>{if(Br(e))return Hs(e)>>>24===127;let{w0:t,w1:r,w2:n,w3:o}=js(e);return t===0&&r===0&&n===0&&o===1},ed=e=>Xl(e)?gY(e):Br(e)?Hs(e)>>>28===14:js(e).w0>>>24===255,RS=e=>Xl(e)?CS(e):Hs(e)===4294967295,RC=e=>Xl(e)?AS(e):!ed(e)&&!kS(e)&&(!Br(e)||!RS(e)),OC=e=>Br(e)?Hs(e)>>>16===43518:(js(e).w0>>>16&65472)===65152,_C=e=>{let t=Hs(e);return t>>>24===10||(t>>>16&65520)===44048||t>>>16===49320},PC=e=>(js(e).w0>>>24&254)===252,yY=e=>{let{w0:t,w1:r,w2:n}=js(e);return t===0&&r===0&&n===65535};var SY={...kt,_tag:"InetAddressV4",[Mo]:Mo,[ae](e){return Fm(e)&&this.port===e.port&&Z(this.address,e.address)},[ie](){return he(J(this.address),qt(this.port))},toString(){return OS(this)},toJSON(){return this.toString()}},bY={...kt,_tag:"InetAddressV6",[Mo]:Mo,[ae](e){return Nm(e)&&this.port===e.port&&this.scopeId===e.scopeId&&Z(this.address,e.address)},[ie](){return he(he(J(this.address),qt(this.port)),qt(this.scopeId))},toString(){return OS(this)},toJSON(){return this.toString()}},CB=e=>Number.isInteger(e)&&e>=0&&e<=65535,EY=(e,t)=>{if(!CB(t))return Ft(e,"port must be an integer from 0 through 65535");let r=Object.create(SY);return r.address=e,r.port=t,X(Object.freeze(r))},IY=(e,t,r)=>{if(!CB(t))return Ft(e,"port must be an integer from 0 through 65535");let n=r?.scopeId??0;if(!Number.isInteger(n)||n<0||n>4294967295)return Ft(e,"scopeId must be an unsigned 32-bit integer");let o=Object.create(bY);return o.address=e,o.port=t,o.scopeId=n,X(Object.freeze(o))};var MC=e=>{let t,r,n=0,o=e.startsWith("[");if(o){let s=e.indexOf("]");if(s<0||e[s+1]!==":"||e.indexOf("]",s+1)!==-1)return Ft(e,"expected [IPv6]:port");t=e.slice(1,s),r=e.slice(s+2);let i=t.indexOf("%");if(i!==-1){let a=t.slice(i+1);if(t.indexOf("%",i+1)!==-1||!/^\d+$/.test(a))return Ft(e,"scope identifier must be decimal");if(n=Number(a),!Number.isInteger(n)||n>4294967295)return Ft(e,"scope identifier must be an unsigned 32-bit integer");t=t.slice(0,i)}}else{let s=e.lastIndexOf(":");if(s<0)return Ft(e,"expected host:port or [IPv6]:port");if(e.indexOf(":")!==s)return Ft(e,"IPv6 addresses must be bracketed");t=e.slice(0,s),r=e.slice(s+1)}return/^(0|[1-9]\d*)$/.test(r)?hr(pc(t),s=>o!==ts(s)?Ft(e,"only IPv6 addresses use brackets"):ts(s)?IY(s,Number(r),{scopeId:n}):EY(s,Number(r))):Ft(e,"port must be an unpadded decimal integer")};var TY=e=>$r(e.address)+(Nm(e)&&e.scopeId!==0?`%${e.scopeId}`:"");var OS=e=>{let t=TY(e);return Fm(e)?`${t}:${e.port}`:`[${t}]:${e.port}`};var wY={...kt,_tag:"UnixPathAddress",[Mo]:Mo,[ae](e){return wS(e)&&this.path===e.path},[ie](){return he(Be("UnixPathAddress"),Be(this.path))},toString(){return this.path},toJSON(){return this.toString()}},AB=e=>{let t=Object.create(wY);return t.path=e,Object.freeze(t)};var FC="~effect/net/Host",mc=(e,t)=>re(new es({input:e,message:t})),vY=/^[a-z0-9_.-]$/i,CY=/^[a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9_])?$/,AY=/^(?:\d+|0x[0-9a-f]*)$/,kB=e=>{if(e===".")return;let t=e.endsWith(".")?e.slice(0,-1):e;if(t.length===0)return"domain name must not be empty";if(t.length>253)return"domain name must be at most 253 characters";let r=t.split(".");for(let n of r){if(n.length===0)return"domain name labels must not be empty";if(n.length>63)return"domain name labels must be at most 63 characters";if(!CY.test(n))return"domain name labels must contain only letters, digits, hyphens, or underscores and must not start or end with a hyphen"}if(AY.test(r[r.length-1]))return"the last domain name label must not be numeric"},kY=e=>{let t=!0;for(let r of e)if(r.charCodeAt(0)<128){if(!vY.test(r))return}else t=!1;if(t)return e.toLowerCase();try{return new URL(`http://${e}`).hostname}catch{return}},ga=e=>typeof e=="string"&&/^[a-z0-9_.-]+$/.test(e)&&kB(e)===void 0;var UC=e=>O(e,FC),_S=e=>{let t=kY(e);if(t===void 0)return mc(e,"invalid domain name");let r=kB(t);return r===void 0?X(t):mc(e,r)};var RY=e=>{if(e.includes("%"))return Um(e);if(e.includes(":"))return pc(e);if(/^[\d.]+$/.test(e)){let t=pc(e);if(tt(t))return t}return _S(e)};var OY=e=>typeof e=="string"?e:$r(e);var _Y={...kt,_tag:"HostPort",[FC]:FC,[ae](e){return UC(e)&&this.port===e.port&&Z(this.host,e.host)},[ie](){return he(J(this.host),qt(this.port))},toString(){return DC(this)},toJSON(){return this.toString()}},PY=e=>Number.isInteger(e)&&e>=0&&e<=65535,MY=(e,t)=>{let r=Object.create(_Y);return r.host=e,r.port=t,Object.freeze(r)};var RB=e=>{let t,r;if(e.startsWith("[")){let o=e.indexOf("]");if(o===-1||e[o+1]!==":")return mc(e,"expected [IPv6]:port");if(t=e.slice(1,o),r=e.slice(o+2),!t.includes(":"))return mc(e,"only IPv6 addresses use brackets")}else{let o=e.lastIndexOf(":");if(o===-1)return mc(e,"expected host:port");if(e.indexOf(":")!==o)return mc(e,"IPv6 addresses must be bracketed");t=e.slice(0,o),r=e.slice(o+1)}if(!/^(0|[1-9]\d*)$/.test(r))return mc(e,"port must be an unpadded decimal integer");let n=Number(r);return PY(n)?Vr(RY(t),o=>MY(o,n)):mc(e,"port must be an integer from 0 through 65535")};var DC=e=>{let t=OY(e.host);return t.includes(":")?`[${t}]:${e.port}`:`${t}:${e.port}`};var BC="~effect/net/Dns/DnsRecord",LC=e=>Number.isInteger(e)&&e>=0&&e<=255,td=e=>Number.isInteger(e)&&e>=0&&e<=65535,PB=e=>Number.isInteger(e)&&e>=0&&e<=4294967295,hc=e=>typeof e=="string",PS=e=>Qi(e)&&Wn(e)&&PB(ui(e)),MB={A:{address:Br},AAAA:{address:ts},CAA:{critical:e=>typeof e=="boolean",tag:e=>hc(e)&&/^[a-z0-9]+$/i.test(e),value:hc},CNAME:{target:ga},MX:{exchange:ga,priority:td},NAPTR:{order:td,preference:td,flags:hc,service:hc,regexp:hc,replacement:ga},NS:{host:ga},PTR:{host:e=>hc(e)&&e.length>0},SOA:{primary:ga,admin:e=>hc(e)&&e.length>0,serial:PB,refresh:PS,retry:PS,expire:PS,minimum:PS},SRV:{target:ga,port:td,priority:td,weight:td},TLSA:{certUsage:LC,selector:LC,matchingType:LC,data:e=>e instanceof Uint8Array&&e.length>0},TXT:{chunks:e=>Array.isArray(e)&&e.length>0&&e.every(hc)}},$C=Object.keys(MB),FY=e=>$C.includes(e),HC=e=>O(e,BC),NY={...kt,[BC]:BC,[ae](e){return HC(e)&&e._tag===this._tag&&Object.keys(this).every(t=>Z(this[t],e[t]))},[ie](){return Bd(this,Object.keys(this))},toString(){return DY(this)},toJSON(){return{...this}}},FB=(e,t)=>{if(!FY(e))return re(new es({input:e,message:"unknown DNS record type"}));let r=typeof t=="object"&&t!==null?t:{},n=Object.create(NY);n._tag=e;for(let[o,s]of Object.entries(MB[e])){let i=r[o];if(!s(i))return re(new es({input:t,message:`invalid ${e} record ${o}`}));n[o]=Array.isArray(i)?Object.freeze([...i]):i instanceof Uint8Array?new Uint8Array(i):i}return X(Object.freeze(n))};var NB=new TextEncoder,UB=e=>`\\${e.toString().padStart(3,"0")}`,Lm=e=>{let t='"';for(let r of NB.encode(e))t+=r===34||r===92?`\\${String.fromCharCode(r)}`:r<32||r>126?UB(r):String.fromCharCode(r);return t+'"'},UY=[34,36,40,41,59,64],_B=e=>{let t=NB.encode(e),r="";for(let n=0;n<t.length;n++){let o=t[n];if(o===92){let s=t[n+1];s===46||s===92?(r+=`\\${String.fromCharCode(s)}`,n++):r+="\\\\"}else o<=32||o>126?r+=UB(o):r+=UY.includes(o)?`\\${String.fromCharCode(o)}`:String.fromCharCode(o)}return r},DY=e=>{switch(e._tag){case"A":case"AAAA":return`${e._tag} ${$r(e.address)}`;case"CAA":return`CAA ${e.critical?128:0} ${e.tag} ${Lm(e.value)}`;case"CNAME":return`CNAME ${e.target}`;case"MX":return`MX ${e.priority} ${e.exchange}`;case"NAPTR":return`NAPTR ${e.order} ${e.preference} ${Lm(e.flags)} ${Lm(e.service)} ${Lm(e.regexp)} ${e.replacement}`;case"NS":return`NS ${e.host}`;case"PTR":return`PTR ${_B(e.host)}`;case"SOA":return`SOA ${e.primary} ${_B(e.admin)} ${e.serial} ${ui(e.refresh)} ${ui(e.retry)} ${ui(e.expire)} ${ui(e.minimum)}`;case"SRV":return`SRV ${e.priority} ${e.weight} ${e.port} ${e.target}`;case"TLSA":return`TLSA ${e.certUsage} ${e.selector} ${e.matchingType} ${zx(e.data).toUpperCase()}`;case"TXT":return`TXT ${e.chunks.map(Lm).join(" ")}`}};var jC="~effect/net/IpInterface",DB=e=>Bm(e)&&Br(e.address),LB=e=>Bm(e)&&ts(e.address),Bm=e=>O(e,jC),HY={...kt,_tag:"IpInterface",[jC]:jC,[ae](e){return Bm(e)&&this.prefixLength===e.prefixLength&&Z(this.address,e.address)},[ie](){return he(J(this.address),qt(this.prefixLength))},toString(){return Hm(this)},toJSON(){return this.toString()}},qC=(e,t)=>re(new es({input:e,message:t})),$m=(e,t)=>{let r=Yl(e);if(!Number.isInteger(t)||t<0||t>r)return qC(e,`prefix length must be an integer from 0 through ${r}`);let n=Object.assign(Object.create(HY),{address:e,prefixLength:t});return X(Object.freeze(n))},zC=(e,t)=>{let r=e.indexOf("/");if(r===-1&&t?.prefix!=="required")return X({address:e,prefixLength:void 0});if(r<=0||r!==e.lastIndexOf("/")||r===e.length-1)return qC(e,"expected an address and prefix length separated by one slash");let n=e.slice(r+1);return/^(0|[1-9][0-9]*)$/.test(n)?X({address:e.slice(0,r),prefixLength:Number(n)}):qC(e,"prefix length must be an unpadded ASCII decimal integer")},MS=(e,t)=>hr(zC(e,t),r=>hr(qu(r.address),n=>$m(n,r.prefixLength??Yl(n)))),FS=(e,t)=>hr(zC(e,t),r=>hr(zu(r.address),n=>$m(n,r.prefixLength??Yl(n)))),NS=(e,t)=>hr(zC(e,t),r=>hr(pc(r.address),n=>$m(n,r.prefixLength??Yl(n))));var Hm=e=>`${$r(e.address)}/${e.prefixLength}`;var WC="~effect/net/IpNetwork",$B=e=>jm(e)&&Br(e.address),HB=e=>jm(e)&&ts(e.address),jm=e=>O(e,WC),jY={...kt,_tag:"IpNetwork",[WC]:WC,[ae](e){return jm(e)&&this.prefixLength===e.prefixLength&&Z(this.address,e.address)},[ie](){return he(J(this.address),qt(this.prefixLength))},toString(){return qm(this)},toJSON(){return this.toString()}},qY=e=>{let t=Object.assign(Object.create(jY),{address:e.address,prefixLength:e.prefixLength});return Object.freeze(t)},zY=e=>Br(e)?vS(e):wC(e);var WY=(e,t)=>{let r=Math.floor(t/8),n=t%8;return e.map((o,s)=>s<r?o:s===r&&n!==0?o&(255<<8-n&255):0)},KC=(e,t)=>hr($m(e,t),r=>{let n=zY(e),o=WY(n,t);return n.some((s,i)=>s!==o[i])?re(new es({input:e,message:"address has non-zero host bits"})):X(qY(r))});var jB=e=>hr(MS(e,{prefix:"required"}),t=>KC(t.address,t.prefixLength)),qB=e=>hr(FS(e,{prefix:"required"}),t=>KC(t.address,t.prefixLength)),zB=e=>hr(NS(e,{prefix:"required"}),t=>KC(t.address,t.prefixLength));var qm=e=>`${$r(e.address)}/${e.prefixLength}`;var zm=pS;function Cr(){return(e,t,r)=>G(new uc(e.map(Em),n=>t(n.map(o=>G(o))),r))}function Je(e,t){return Cr()([],()=>(r,n,o)=>e(r)?I(r):D(new at(n,r,o)),t)}function VY(e){return e}function JY(e){return t=>t.annotate(e)}function GY(e){return t=>JC(JC(t).annotate(e))}function ZY(e){return t=>t.rebuild(Hl(t.ast,e))}function QY(e){return e}var $n=class extends sr("SchemaError"){[Zl]=Zl;constructor(t){let r=Ir();yt(0);try{super({issue:t})}finally{yt(r)}}get message(){return g1(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Qe](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function id(e){return IB(e)}function o$(e){return Xe(e)?YC(e):rt(e,t=>aa(()=>Ka(t,r=>new $n(r))))}function YC(e){return ft(e)?e:ir(Ka(e.cause,t=>new $n(t)))}function s$(e,t){let r;for(let n of e.reasons){if(!_g(n)||!id(n.error))throw new globalThis.Error(t,{cause:e});r??=n.error}if(r===void 0)throw new globalThis.Error(t,{cause:e});return r}function i$(e){return cy(e).then(t=>{if(ft(t))return t.value;throw s$(t.cause,"Promise adapter can only reject schema errors")})}function a$(e){let t=ki(e);if(ft(t))return t.value;throw s$(t.cause,"Sync adapter can only throw schema errors")}function YY(e,t){return XL(e,t)}function XY(e){return eB(e)}var e7=Vv,t7=dL;function xc(e,t){let r=ot(e,t);return(n,o)=>o$(r(n,o))}var r7=xc;function c$(e,t){let r=pL(e,t);return(n,o)=>YC(r(n,o))}var u$=c$,n7=Gv,o7=mL;function f$(e,t){let r=hL(e,t);return(n,o)=>MI(r(n,o),s=>new $n(s))}var s7=f$;function l$(e,t){let r=xc(e,t);return(n,o)=>i$(r(n,o))}var i7=l$;function DS(e,t){let r=xc(e,t);return(n,o)=>a$(r(n,o))}var Vm=DS;function Jm(e,t){let r=Bu(e,t);return(n,o)=>o$(r(n,o))}var XC=Jm;function d$(e,t){let r=gL(e,t);return(n,o)=>YC(r(n,o))}var p$=d$,a7=Zv,c7=yL;function m$(e,t){let r=SL(e,t);return(n,o)=>MI(r(n,o),s=>new $n(s))}var u7=m$;function h$(e,t){let r=Jm(e,t);return(n,o)=>i$(r(n,o))}var f7=h$;function Gm(e,t){let r=Jm(e,t);return(n,o)=>a$(r(n,o))}var eA=Gm,G=Ls;function Vu(e){return O(e,zm)&&e[zm]===zm}var Ku=bn(e=>G(Lu(e.ast),{schema:e})),l7=bn(e=>e.schema),lr=bn(e=>{let t=$S(e);return G(z2(e.ast),{schema:t})}),d7=bn(e=>e.schema.members[0]),p7=bn(e=>G(Fv(e.ast),{schema:e})),m7=bn(e=>e.schema),oo=bn(e=>G(Mt(e.ast),{schema:e})),ad=bn(e=>G(Bn(e.ast),{schema:e})),Wm="~effect/Schema/flip";function h7(e){return O(e,Wm)&&e[Wm]===Wm}function JC(e){return h7(e)?e.schema.rebuild(Oo(e.ast)):G(Oo(e.ast),{[Wm]:Wm,schema:e})}function fr(e){let t=G(new Ln(e),{literal:e,transform(r){return t.pipe(ee(fr(r),{decode:Ie(()=>r),encode:Ie(()=>e)}))}});return t}function x$(e){return e.map(t=>Vu(t)?t.ast:new Ln(t))}function x7(e){return G(new Tv(x$(e)),{parts:e})}function g7(e){return G(T2(x$(e)),{parts:e})}function y7(e){return G(new I2(Object.keys(e).filter(t=>typeof e[e[t]]!="number").map(t=>[t,e[t]])),{enums:e})}var Mi=G(Iv),S7=G(b2),Zm=G(pa),LS=G(bv),tA=G(Ev),z=G(Ro),b7=z,Ju=G(wv),Fi=G(C2),g$=G(A2),cd=G(k2),ud=G(S2),E7=G(E2);function I7(e){return G(new v2(e))}function rA(e,t){return G(e,{fields:t,mapFields(r,n){let o=r(this.fields);return rA(Zy(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Te(e){return rA(Zy(e,void 0),e)}function T7(e){return bn(t=>t.mapFields(pB(e)))}var w7=e=>typeof e=="symbol"?e:globalThis.String(e);function v7(e){return function(t){let r={},n=Object.create(null),o=Object.create(null),s=new Set;for(let i of Reflect.ownKeys(t.fields)){let a=ad(t.fields[i]),c=Object.hasOwn(e,i),u=c?e[i]:i,f=w7(u);if(s.has(f))throw new globalThis.Error(`Duplicate encoded keys: ${ni(u)}`);s.add(f),B(r,u,a),c&&(n[i]=u,o[u]=i)}return Te(r).pipe(ee(t,Fe({decode:mC(o),encode:mC(n)})))}}function C7(e,t){return r=>{let n=Mx(r.fields,oo),o=Te({...n,...e});return r.pipe(ee(o,Fe({decode:s=>{let i={...s};for(let a in e){let c=t[a],u=c(s);de(u)&&B(i,a,u.value)}return i},encode:s=>{let i={...s};for(let a in e)delete i[a];return i}})))}}function Gu(e,t){return G(K2(e.ast,t.ast),{key:e,value:t})}function A7(e,t){return G(M2(e.ast,t.map(Em)),{schema:e,records:t})}function y$(e,t){return G(e,{elements:t,mapElements(r,n){let o=r(this.elements);return y$(kv(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function rs(e){return y$(kv(e),e)}function k7(e,t){return G(F2(e.ast,t.map(Em)),{schema:e,rest:t})}var ct=bn(e=>G(new Xo(!1,[],[e.ast]),{value:e}));function BS(e,t,r){return t!==void 0&&r!==void 0?e.check(aA(t,r)):t!==void 0?e.check(D$(t)):r!==void 0?e.check($$(r)):e}var Zu=bn(e=>G(new Xo(!1,[e.ast],[e.ast]),{value:e}));function R7(e){let t=ct(e),r=ct(oo(e)),n=ee(rs([Zm]),Fe({decode:o=>[o],encode:([o])=>o}))(e);return G(Pe([n,t]).pipe(ee(r)).ast,{from:Pe([e,t]),to:r})}function O7(e){return ct(e).check(uA())}var _7=bn(e=>G(N2(e.ast),{schema:e}));function S$(e,t){return G(e,{members:t,mapMembers(r,n){let o=r(this.members);return S$(Qy(o,this.ast.options,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Pe(e,t){return S$(Qy(e,t,void 0),e)}function Fo(e){let t=e.map(fr);return G(Qy(t,void 0,void 0),{literals:e,members:t,mapMembers(r){return Pe(r(this.members))},pick(r){return Fo(r)},transform(r){return Pe(t.map((n,o)=>n.transform(r[o])))}})}var nA=bn(e=>Pe([e,LS])),$S=bn(e=>Pe([e,tA])),b$=bn(e=>Pe([e,LS,tA]));function E$(e){return G(new Ov(()=>e().ast))}function P7(...e){return t=>t.check(...e)}function I$(e,t){return r=>G(Pi(r.ast,[Xy(e,t)]),{schema:r})}function HS(e){return t=>G(t.ast,{schema:t,identifier:e})}function M7(e,t){return r=>(t.checks?r.check(...t.checks):r).pipe(HS(e))}function T$(e){return t=>G(j2(t.ast,new jy(e,F)),{schema:t})}function w$(e){return t=>G(q2(t.ast,new jy(F,e)),{schema:t})}function F7(e){return v$(e)}function v$(e){return t=>T$(fy(e))(t)}function N7(e){return C$(e)}function C$(e){return t=>w$(fy(e))(t)}function ee(e,t){return r=>G(jl(r.ast,e.ast,t?qy(t):_l()),{from:r,to:e})}function fd(){return(e,t)=>Ne()(e,{decode:t,encode:E1})}var A$=Fo(["true","yes","on","1","y"]),k$=Fo(["false","no","off","0","n"]),U7=Fo([...A$.literals,...k$.literals]).pipe(ee(Fi,Fe({decode:e=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:e=>e?"true":"false"})));function D7(e){return t=>ee(oo(t),e)(t)}function oA(e,t){return r=>t?ee(r,t)(e):ee(r)(e)}function L7(e){return t=>ee(t,e)(ad(t))}function R$(e){return t=>G(W2(t.ast,e),{schema:t})}function O$(e){return rt(e,t=>aa(()=>Ka(t,r=>r.issue)))}function sA(e,t){let r=t?.encodingStrategy==="omit"?rv():Oi();return n=>Ku(ad(n)).pipe(ee(n,{decode:nv(O$(e)),encode:r}))}function B7(e,t){return r=>oo(r).pipe(sA(e,t),oA(Ku(r)))}function _$(e,t){let r=t?.encodingStrategy==="omit"?rv():Oi();return n=>lr(ad(n)).pipe(ee(n,{decode:nv(O$(e)),encode:r}))}function $7(e,t){return r=>oo(r).pipe(_$(e,t),oA(lr(r)))}function je(e){return fr(e).pipe(R$(I(e)))}function H7(e){return je(e).pipe(sA(I(e),{encodingStrategy:"omit"}))}function ya(e,t){return Te({_tag:je(e),...t})}function P$(e){return t=>{let r={},n=[],o=new Set,s={},i=f=>p=>f.includes(p[e]);return a(t),Object.assign(t,{tag:e,cases:r,discriminants:n,isAnyOf:i,guards:s,match:c,matchOrElse:u});function a(f){let p=f.ast;if(x2(p)&&"members"in f&&globalThis.Array.isArray(f.members)&&f.members.every(Vu))return f.members.forEach(a);let m=ac(p);if(m.length>0){let h=m.find(x=>x.key===e)?.literal;if(fx(h)){let x=typeof h=="number"?globalThis.String(h):h;if(o.has(x))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(h)}`);o.add(x),n.push(h),B(r,h,f),B(s,h,Vv(oo(f)));return}}throw new globalThis.Error("No literal or unique symbol found")}function c(){if(arguments.length===1){let x=arguments[0];return function(g){let y=g[e];return(Object.hasOwn(x,y)?x[y]:void 0)(g)}}let f=arguments[0],p=arguments[1],m=f[e];return(Object.hasOwn(p,m)?p[m]:void 0)(f)}function u(){if(arguments.length===2){let g=arguments[0],y=arguments[1];return function(E){let b=E[e];return(Object.hasOwn(g,b)?g[b]??y:y)(E)}}let f=arguments[0],p=arguments[1],m=arguments[2],h=f[e];return(Object.hasOwn(p,h)?p[h]??m:m)(f)}}}function j7(e){let t={},r=[];for(let u of Object.keys(e)){let f=ya(u,e[u]);B(t,u,f),r.push(f)}let n=Pe(r),{tag:o,guards:s,isAnyOf:i,match:a,matchOrElse:c}=P$("_tag")(n);return G(n.ast,{tag:o,cases:t,isAnyOf:i,guards:s,match:a,matchOrElse:c})}function q7(){return e=>e}function gc(e,t){return Je(r=>r instanceof e,t)}function Ne(){return(e,t)=>new Bt(e.ast,qy(t))}var Ge=Yy;function z7(e,t=void 0){return new Nu(e,t)}var WB="^\\S[\\s\\S]*\\S$|^\\S$|^$";function M$(e){let t=new globalThis.RegExp(WB);return Ge(r=>r.trim()===r,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isTrimmed()"}),arbitraryConstraint:{patterns:[{source:WB,flags:""}]},...e})}function Qu(e,t){let r=e.source,n=e.flags,o=/^[dg]*uy?$/.test(n),s=n===""?`new RegExp(${j(r)})`:`new RegExp(${j(r)}, ${j(n)})`;return Tm(e,{toJsonSchema:()=>o?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${s})`}),...t})}function W7(e){return Dv({toCode:()=>({runtime:"Schema.isStringFinite()"}),...e})}function K7(e){return Lv({toCode:()=>({runtime:"Schema.isStringBigInt()"}),...e})}function V7(e){return $v({toCode:()=>({runtime:"Schema.isStringSymbol()"}),...e})}var J7=e=>e?new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/;function G7(e,t){let r=J7(e);return Qu(r,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:r.source,format:"uuid"}),toCode:()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),...t})}var KB=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;function Z7(e){return Qu(KB,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:()=>({pattern:KB.source}),toCode:()=>({runtime:"Schema.isGUID()"}),...e})}function Q7(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return Qu(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isULID()"}),...e})}function F$(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return Qu(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64()"}),...e})}function Y7(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return Qu(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64Url()"}),...e})}function iA(e,t,r){if(e.length===0)return t.length===0?{}:[{},!0];let n={pattern:new globalThis.RegExp(r).source};return e===t?n:[n,!0]}function X7(e,t){let r=JSON.stringify(e),n=new globalThis.RegExp(`^${ha(e)}`),o=e.replace(/[\uD800-\uDBFF]$/,"");return Ge(s=>s.startsWith(e),{expected:`a string starting with ${r}`,representation:{id:"effect/schema/isStartingWith",payload:{startsWith:e}},toJsonSchema:()=>iA(o,e,`^${ha(o)}`),toCode:()=>({runtime:`Schema.isStartingWith(${j(e)})`}),arbitraryConstraint:{patterns:[{source:n.source,flags:n.flags}]},...t})}function eX(e,t){let r=JSON.stringify(e),n=new globalThis.RegExp(`${ha(e)}$`),o=e.replace(/^[\uDC00-\uDFFF]/,"");return Ge(s=>s.endsWith(e),{expected:`a string ending with ${r}`,representation:{id:"effect/schema/isEndingWith",payload:{endsWith:e}},toJsonSchema:()=>iA(o,e,`${ha(o)}$`),toCode:()=>({runtime:`Schema.isEndingWith(${j(e)})`}),arbitraryConstraint:{patterns:[{source:n.source,flags:n.flags}]},...t})}function tX(e,t){let r=JSON.stringify(e),n=new globalThis.RegExp(ha(e)),o=e.replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"");return Ge(s=>s.includes(e),{expected:`a string including ${r}`,representation:{id:"effect/schema/isIncluding",payload:{includes:e}},toJsonSchema:()=>iA(o,e,ha(o)),toCode:()=>({runtime:`Schema.isIncluding(${j(e)})`}),arbitraryConstraint:{patterns:[{source:n.source,flags:n.flags}]},...t})}var VB="^[^a-z]*$";function rX(e){let t=new globalThis.RegExp(VB);return Ge(r=>r.toUpperCase()===r,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isUppercased()"}),arbitraryConstraint:{patterns:[{source:VB,flags:""}]},...e})}var JB="^[^A-Z]*$";function nX(e){let t=new globalThis.RegExp(JB);return Ge(r=>r.toLowerCase()===r,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isLowercased()"}),arbitraryConstraint:{patterns:[{source:JB,flags:""}]},...e})}var GB="^(?:[^a-z][\\s\\S]*)?$";function oX(e){let t=new globalThis.RegExp(GB);return Ge(r=>r.charAt(0).toUpperCase()===r.charAt(0),{expected:"a string with the first character in uppercase",representation:{id:"effect/schema/isCapitalized",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isCapitalized()"}),arbitraryConstraint:{patterns:[{source:GB,flags:""}]},...e})}var ZB="^(?:[^A-Z][\\s\\S]*)?$";function sX(e){let t=new globalThis.RegExp(ZB);return Ge(r=>r.charAt(0).toLowerCase()===r.charAt(0),{expected:"a string with the first character in lowercase",representation:{id:"effect/schema/isUncapitalized",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isUncapitalized()"}),arbitraryConstraint:{patterns:[{source:ZB,flags:""}]},...e})}var jS=G(Pv),iX=_v;function Qm(e){let t=Zc(e.order),r=e.formatter??j;return(n,o)=>Ge(s=>t(s,n),{expected:`a value greater than ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n,exclusiveMinimum:!0},...e.annotate?.(n),...o})}function Ym(e){let t=tp(e.order),r=e.formatter??j;return(n,o)=>Ge(s=>t(s,n),{expected:`a value greater than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n},...e.annotate?.(n),...o})}function Xm(e){let t=Xd(e.order),r=e.formatter??j;return(n,o)=>Ge(s=>t(s,n),{expected:`a value less than ${r(n)}`,arbitraryConstraint:{order:e.order,maximum:n,exclusiveMaximum:!0},...e.annotate?.(n),...o})}function eh(e){let t=ep(e.order),r=e.formatter??j;return(n,o)=>Ge(s=>t(s,n),{expected:`a value less than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,maximum:n},...e.annotate?.(n),...o})}function th(e){let t=tp(e.order),r=Zc(e.order),n=ep(e.order),o=Xd(e.order),s=e.formatter??j;return(i,a)=>{let c=i.exclusiveMinimum?r:t,u=i.exclusiveMaximum?o:n;return Ge(f=>c(f,i.minimum)&&u(f,i.maximum),{expected:`a value between ${s(i.minimum)}${i.exclusiveMinimum?" (excluded)":""} and ${s(i.maximum)}${i.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:e.order,minimum:i.minimum,maximum:i.maximum,...i.exclusiveMinimum&&{exclusiveMinimum:!0},...i.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(i),...a})}}function aX(e){return(t,r)=>{let n=e.formatter??j;return Ge(o=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${n(t)}`,...e.annotate?.(t),...r})}}function nd(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${j(e)}`);return e}var cX=Qm({order:Ki,annotate:e=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:nd(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${j(e)})`})})}),N$=Ym({order:Ki,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:nd(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${j(e)})`})})}),uX=Xm({order:Ki,annotate:e=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:nd(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${j(e)})`})})}),fX=eh({order:Ki,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:nd(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${j(e)})`})})}),yc=th({order:Ki,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:nd(e.minimum),maximum:nd(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${j(e.minimum)}, maximum: ${j(e.maximum)}, exclusiveMinimum: ${j(t)}, exclusiveMaximum: ${j(r)} })`})}}});function lX(e,t){if(!globalThis.Number.isFinite(e)||e===0)throw new globalThis.RangeError(`Expected a finite non-zero number, got ${globalThis.String(e)}`);return e=globalThis.Math.abs(e),Ge(r=>nU(r,e)===0,{expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${j(e)})`}),...t})}function qS(e){return Ge(t=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer",minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),toCode:()=>({runtime:"Schema.isInt()"}),arbitraryConstraint:{number:"integer"},...e})}var In=Ju.check(qS()),Wu=In.check(N$(0));function dX(e){return new Nu([qS(),yc({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}function pX(e){return new Nu([qS(),yc({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}function od(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${j(e)}`);return e.toISOString()}function sd(e){return`new Date(${j(e.getTime())})`}var mX=Qm({order:Mf,annotate:e=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:od(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanDate(${sd(e)})`})})}),hX=Ym({order:Mf,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:od(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${sd(e)})`})})}),xX=Xm({order:Mf,annotate:e=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:od(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanDate(${sd(e)})`})})}),gX=eh({order:Mf,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:od(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${sd(e)})`})})}),yX=th({order:Mf,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:od(e.minimum),maximum:od(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${sd(e.minimum)}, maximum: ${sd(e.maximum)}, exclusiveMinimum: ${j(t)}, exclusiveMaximum: ${j(r)} })`})}}}),SX=Qm({order:Pf,annotate:e=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${j(e)})`})})}),U$=Ym({order:Pf,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${j(e)})`})})}),bX=Xm({order:Pf,annotate:e=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanBigInt(${j(e)})`})})}),EX=eh({order:Pf,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${j(e)})`})})}),IX=th({order:Pf,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenBigInt",payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${j(e.minimum)}, maximum: ${j(e.maximum)}, exclusiveMinimum: ${j(t)}, exclusiveMaximum: ${j(r)} })`})}}});function D$(e,t){return e=En(e),L$(e,Math.ceil(e/2),t)}function L$(e,t,r){return Ge(n=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="string"?e<=1?{minLength:t}:[{minLength:t},!0]:n==="array"?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[ro]:!0,arbitraryConstraint:{minLength:e},...r})}function B$(e){return L$(1,1,e)}function $$(e,t){return e=En(e),Ge(r=>r.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:r})=>r==="string"?e===0?{maxLength:e}:[{maxLength:e},!0]:r==="array"?{maxItems:e}:r===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[ro]:!0,arbitraryConstraint:{maxLength:e},...t})}function aA(e,t,r){return e=En(e),t=En(t),Ge(n=>n.length>=e&&n.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:"effect/schema/isBetweenLength",payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n==="string"?t===0||Math.ceil(e/2)>t?{minLength:Math.ceil(e/2),maxLength:t}:[{minLength:Math.ceil(e/2),maxLength:t},!0]:n==="array"?{minItems:e,maxItems:t}:n===void 0?[{minLength:Math.ceil(e/2),maxLength:t,minItems:e,maxItems:t},!0]:[{},!0],toCode:()=>({runtime:`Schema.isBetweenLength(${e}, ${t})`}),[ro]:!0,arbitraryConstraint:{minLength:e,maxLength:t},...r})}function TX(e,t){return e=En(e),Ge(r=>cA(r,e)>=e,{expected:`a string with at least ${e} code points`,representation:{id:"effect/schema/isMinCodePoints",payload:{minCodePoints:e}},toJsonSchema:()=>({minLength:e}),toCode:()=>({runtime:`Schema.isMinCodePoints(${e})`}),arbitraryConstraint:{minCodePoints:e},...t})}function wX(e,t){return e=En(e),Ge(r=>cA(r,e+1)<=e,{expected:`a string with at most ${e} code points`,representation:{id:"effect/schema/isMaxCodePoints",payload:{maxCodePoints:e}},toJsonSchema:()=>({maxLength:e}),toCode:()=>({runtime:`Schema.isMaxCodePoints(${e})`}),arbitraryConstraint:{maxCodePoints:e},...t})}function vX(e,t,r){return e=En(e),t=En(t),Ge(n=>{let o=cA(n,t+1);return o>=e&&o<=t},{expected:e===t?`a string with ${e} code points`:`a string with between ${e} and ${t} code points`,representation:{id:"effect/schema/isBetweenCodePoints",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({allOf:[{minLength:e},{maxLength:t}]}),toCode:()=>({runtime:`Schema.isBetweenCodePoints(${e}, ${t})`}),arbitraryConstraint:{minCodePoints:e,maxCodePoints:t},...r})}function cA(e,t){if(t===0)return 0;let r=0;for(let n of e)if(++r>=t)break;return r}function En(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function CX(e,t){return e=En(e),Ge(r=>r.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[ro]:!0,arbitraryConstraint:{minSize:e},...t})}function AX(e,t){return e=En(e),Ge(r=>r.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[ro]:!0,arbitraryConstraint:{maxSize:e},...t})}function kX(e,t,r){return e=En(e),t=En(t),Ge(n=>n.size>=e&&n.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:"effect/schema/isBetweenSize",payload:{minimum:e,maximum:t}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenSize(${e}, ${t})`}),[ro]:!0,arbitraryConstraint:{minSize:e,maxSize:t},...r})}function RX(e,t){return e=En(e),Ge(r=>Reflect.ownKeys(r).length>=e,{expected:`a value with at least ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMinProperties",payload:{minProperties:e}},toJsonSchema:({type:r})=>r==="object"?{minProperties:e}:[{minProperties:e},!0],toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[ro]:!0,arbitraryConstraint:{minProperties:e},...t})}function OX(e,t){return e=En(e),Ge(r=>Reflect.ownKeys(r).length<=e,{expected:`a value with at most ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMaxProperties",payload:{maxProperties:e}},toJsonSchema:({type:r})=>r==="object"?{maxProperties:e}:[{maxProperties:e},!0],toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[ro]:!0,arbitraryConstraint:{maxProperties:e},...t})}function _X(e,t,r){return e=En(e),t=En(t),Ge(n=>Reflect.ownKeys(n).length>=e&&Reflect.ownKeys(n).length<=t,{expected:e===t?`a value with exactly ${e===1?"1 entry":`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:"effect/schema/isBetweenProperties",payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n==="object"?{minProperties:e,maxProperties:t}:[{minProperties:e,maxProperties:t},!0],toCode:()=>({runtime:`Schema.isBetweenProperties(${e}, ${t})`}),[ro]:!0,arbitraryConstraint:{minProperties:e,maxProperties:t},...r})}function PX(e,t){let r=ad(e),n=lL(r.ast);return Ge((o,s,i)=>{let a=Reflect.ownKeys(o),c=[];for(let u of a){let f=n(u,i);if(f!==void 0&&(c.push(new Ct([u],f)),i.errors==="first"))break}return Jr(c)?new Pt(s,c,o,i):!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[r.ast]},toJsonSchema:({schemas:o,type:s})=>s==="object"?{propertyNames:o[0]}:[{propertyNames:o[0]},!0],toCode:({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),[ro]:!0,...t})}function uA(e){return Ge(t=>Bx(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:"Schema.isUnique()"}),arbitraryConstraint:{uniqueBy:F},...e})}function H$(e){return Ge(t=>Bx(t.map(([r])=>r)).length===t.length,{expected:"an array with unique keys",representation:{id:"effect/schema/isUniqueKey",payload:null},toCode:()=>({runtime:"Schema.isUniqueKey()"}),arbitraryConstraint:{uniqueBy:t=>t[0]},...e})}var fA=z.check(B$()),MX=z.check(aA(1,1)),j$=e=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),q$=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},QB=[];function FX(e){let t=j$(e),r=QB[t];if(r!==void 0)return r;let n=q$(t),o=gc(globalThis.Error,{representation:{id:"effect/schema/Error",payload:n??null},toCode:()=>({runtime:n!==void 0?`Schema.ErrorInstance(${j(n)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),expected:"Error",toCodecJson:()=>Ne()(ire,J1(n))});return QB[t]=o,o}var YB=[];function er(e){let t=j$(e),r=YB[t];if(r!==void 0)return r;let n=GS.pipe(ee(Zm,G1(q$(t))));return YB[t]=n,n}function NX(e,t){let r=Cr()([e,t],([n,o])=>{let s=ct(rs([n,o]));return(i,a,c)=>i instanceof globalThis.Map?cr(ot(s)([...i],c),{onSuccess:u=>new globalThis.Map(u),onFailure:u=>tn(a,"entries",u,i,c)}):D(new at(a,i,c))},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.ReadonlyMap(${n[0].runtime}, ${n[1].runtime})`,Type:`globalThis.ReadonlyMap<${n[0].Type}, ${n[1].Type}>`}),expected:"ReadonlyMap",toCodec:([n,o])=>Ne()(ct(rs([n,o])),Fe({decode:s=>new globalThis.Map(s),encode:s=>[...s.entries()]}))});return G(r.ast,{key:e,value:t})}function UX(e){let t=Cr()([e],([r])=>{let n=ct(r);return(o,s,i)=>o instanceof globalThis.Set?cr(ot(n)([...o],i),{onSuccess:a=>new globalThis.Set(a),onFailure:a=>tn(s,"values",a,o,i)}):D(new at(s,o,i))},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.ReadonlySet(${r[0].runtime})`,Type:`globalThis.ReadonlySet<${r[0].Type}>`}),expected:"ReadonlySet",toCodec:([r])=>Ne()(ct(r),Fe({decode:n=>new globalThis.Set(n),encode:n=>[...n.values()]}))});return G(t.ast,{value:e})}var DX=gc(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),expected:"RegExp",toCodecJson:()=>Ne()(Te({source:z,flags:z}),Xt({decode:(e,t)=>Jo({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new le({expected:"valid RegExp source and flags"},e,t)}),encode:e=>I({source:e.source,flags:e.flags})}))}),z$=z.annotate({expected:"a string that will be decoded as a URL"}),W$=gc(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),expected:"URL",toCodecJson:()=>Ne()(z$,cv)}),LX=z$.pipe(ee(W$,cv)),K$=z.annotate({expected:"a string that will be decoded as a Date"}),zS=Je(e=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),expected:"a valid Date",toCodecJson:()=>Ne()(K$,iv)}),BX=K$.pipe(ee(zS,iv)),$X=In.pipe(ee(zS,j1)),HX=z.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function lA(e,t){return HX.pipe(ee(e,s2(t)))}var jX=lA(Zm),V$=gc(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:()=>({runtime:"Schema.File",Type:"globalThis.File"}),expected:"File",toCodecJson:()=>Ne()(Te({data:z.check(F$()),type:z,name:z,lastModified:In}),Xt({decode:(e,t)=>zn(wu(e.data),{onFailure:()=>D(new le({expected:"a valid Base64 string"},e.data,t)),onSuccess:r=>{let n=new globalThis.Uint8Array(r);return I(new globalThis.File([n],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>Vo({try:async()=>{let r=new globalThis.Uint8Array(await e.arrayBuffer());return{data:Tl(r),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new le({expected:"a readable File"},e,t)})}))}),J$=gc(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),expected:"FormData",toCodecJson:()=>Ne()(ct(rs([z,Pe([Te({_tag:je("String"),value:z}),Te({_tag:je("File"),value:V$})])])),Xt({decode:e=>{let t=new globalThis.FormData;for(let[r,n]of e)t.append(r,n.value);return I(t)},encode:e=>I(globalThis.Array.from(e.entries()).map(([t,r])=>typeof r=="string"?[t,{_tag:"String",value:r}]:[t,{_tag:"File",value:r}]))}))});function qX(e){return J$.pipe(ee(e,i2))}var G$=gc(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),expected:"URLSearchParams",toCodecJson:()=>Ne()(z.annotate({expected:"a query string that will be decoded as URLSearchParams"}),Fe({decode:e=>new globalThis.URLSearchParams(e),encode:e=>e.toString()}))});function zX(e){return G$.pipe(ee(e,a2))}var WX=z.annotate({expected:"a string that will be decoded as a number"}).pipe(ee(Ju,Pl)),KX=z.annotate({expected:"a string that will be decoded as a finite number"}).pipe(ee(jS,Pl)),VX=G(Bv).pipe(ee(cd,Wy)),Z$=z.check(M$()),JX=z.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(ee(Z$,H1())),GX=z.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,t2)),ZX=z.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,r2)),QX=z.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,n2)),YX=z.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,o2)),GC=Pe([jS,g$,z]),XX=Te({issues:ct(Te({message:z,path:lr(ct(Pe([GC,Te({key:GC})])))}))}),eee=Fo([0,1]).pipe(ee(Fi,Fe({decode:e=>e===1,encode:e=>e?1:0}))),Q$=z.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),qs=gc(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>Ne()(Q$,uv)}),tee=Q$.pipe(ee(qs,uv)),ree=z.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(ee(qs,{decode:R1(),encode:$y()})),Y$=z.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(ee(qs,{decode:_1(),encode:Hy()})),X$=Xt({decode:(e,t)=>{let r=YU(e);return fe(r)?D(new le({expected:"a valid BigDecimal string"},e,t)):I(r.value)},encode:e=>I(fa(e))}),nee=Qm({order:bl,formatter:e=>fa(e)}),oee=Ym({order:bl,formatter:e=>fa(e)}),see=Xm({order:bl,formatter:e=>fa(e)}),iee=eh({order:bl,formatter:e=>fa(e)}),aee=th({order:bl,formatter:e=>fa(e)}),eH=z.annotate({expected:"a string that will be decoded as a BigDecimal"}),tH=Je(Eu,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),expected:"BigDecimal",toCodecJson:()=>Ne()(eH,X$),toFormatter:()=>e=>fa(e)}),cee=eH.pipe(ee(tH,X$)),WS=Je(aD,{representation:{id:"effect/schema/ByteSize",payload:null},toCode:()=>({runtime:"Schema.ByteSize",Type:"ByteSize.ByteSize",importDeclarations:['import * as ByteSize from "effect/ByteSize"']}),expected:"ByteSize",toCodecJson:()=>Ne()(cd.check(U$(globalThis.BigInt(0))),Fe({decode:iD,encode:py})),toCodecStringTree:()=>Ne()(rH,av)}),rH=z.annotate({expected:"a string that will be decoded as a ByteSize"}),uee=rH.pipe(ee(WS,av)),fee=cd.pipe(ee(WS,q1)),lee=Ju.pipe(ee(WS,z1));function ZC(e,t){let r=Cr()([e,t],([n,o])=>(s,i,a)=>{if(!nl(s))return D(new at(i,s,a));switch(s._tag){case"Fail":return cr(ot(n)(s.error,a),{onSuccess:Tp,onFailure:c=>tn(i,"error",c,s,a)});case"Die":return cr(ot(o)(s.defect,a),{onSuccess:wp,onFailure:c=>tn(i,"defect",c,s,a)});case"Interrupt":return I(s)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.CauseReason(${n[0].runtime}, ${n[1].runtime})`,Type:`Cause.Failure<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause.Failure",toCodec:([n,o])=>Ne()(Pe([Te({_tag:fr("Fail"),error:n}),Te({_tag:fr("Die"),defect:o}),Te({_tag:fr("Interrupt"),fiberId:$S(jS)})]),Fe({decode:s=>{switch(s._tag){case"Fail":return Tp(s.error);case"Die":return wp(s.defect);case"Interrupt":return vp(s.fiberId)}},encode:s=>{switch(s._tag){case"Fail":return{_tag:"Fail",error:s.error};case"Die":return{_tag:"Die",defect:s.defect};case"Interrupt":return{_tag:"Interrupt",fiberId:s.fiberId}}}}))});return G(r.ast,{error:e,defect:t})}function Km(e,t){let r=Cr()([e,t],([n,o])=>{let s=ct(ZC(n,o));return(i,a,c)=>rl(i)?cr(ot(s)(i.reasons,c),{onSuccess:au,onFailure:u=>tn(a,"failures",u,i,c)}):D(new at(a,i,c))},{representation:{id:"effect/schema/Cause",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Cause(${n[0].runtime}, ${n[1].runtime})`,Type:`Cause.Cause<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause",toCodec:([n,o])=>Ne()(ct(ZC(n,o)),Fe({decode:au,encode:({reasons:s})=>s}))});return G(r.ast,{error:e,defect:t})}function XB(e){return Ne()(e,Fe({decode:mw,encode:vt}))}function dee(e){let t=Cr()([e],([r])=>{let n=ct(r);return(o,s,i)=>Il(o)?cr(ot(n)(vt(o),i),{onSuccess:mw,onFailure:a=>tn(s,"values",a,o,i)}):D(new at(s,o,i))},{representation:{id:"effect/schema/Chunk",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Chunk(${r[0].runtime})`,Type:`Chunk.Chunk<${r[0].Type}>`}),expected:"Chunk",toCodec:([r])=>XB(ct(r)),toCodecArbitrary:({constraint:r,typeParameters:[n]})=>XB(BS(ct(n),r?.minLength,r?.maxLength)),toEquivalence:([r])=>dw(r)});return G(t.ast,{value:e})}function nH(){return rn((e,t)=>Zt(hw(e),{onNone:()=>D(new le({message:"Invalid DateTime input"},e,t)),onSome:r=>I(xw(r))}))}var pee=Fe({decode:e=>yw(e),encode:e=>e.offset}),oH=Xt({decode:(e,t)=>Zt(bD(e),{onNone:()=>D(new le({expected:"a valid IANA time zone"},e,t)),onSome:I}),encode:e=>I(e.id)}),sH=Xt({decode:(e,t)=>Zt(ED(e),{onNone:()=>D(new le({expected:"a valid time zone"},e,t)),onSome:I}),encode:e=>I(Yp(e))}),iH=Xt({decode:(e,t)=>Zt(hw(e),{onNone:()=>D(new le({expected:"a valid UTC DateTime string"},e,t)),onSome:r=>I(xw(r))}),encode:e=>I(wD(e))}),aH=Xt({decode:(e,t)=>Zt(SD(e),{onNone:()=>D(new le({expected:"a valid Zoned DateTime string"},e,t)),onSome:I}),encode:e=>I(Sw(e))}),cH=-864e13,uH=864e13,mee=cH+840*60*1e3,hee=uH-840*60*1e3,xee=-720*60*1e3,gee=840*60*1e3,fH=["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"];function lH(e,t,r){let n=Math.max(t,e?.minimum===void 0?t:e.minimum.epochMilliseconds+(e.exclusiveMinimum===!0?1:0)),o=Math.min(r,e?.maximum===void 0?r:e.maximum.epochMilliseconds-(e.exclusiveMaximum===!0?1:0));return n<=o?[n,o]:[t,r]}function dA(e,t){return In.check(yc({minimum:e,maximum:t}))}function dH(){return Pe([dA(xee,gee),Fo(fH)])}var KS=Je(e=>Tu(e)&&xD(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Utc",toCodecArbitrary:({constraint:e})=>{let[t,r]=lH(e,cH,uH);return fd()(dA(t,r),Ie(xy))},toCodecJson:()=>Ne()(z,iH),toFormatter:()=>e=>e.toString()}),yee=zS.pipe(ee(KS,{decode:nH(),encode:Ie(ID)})),See=z.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(ee(KS,iH)),bee=In.pipe(ee(KS,{decode:nH(),encode:Ie(TD)})),Eee=Je(mD,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Offset",toCodecJson:()=>Ne()(In,pee),toFormatter:()=>e=>Yp(e)}),pH=z.annotate({expected:"an IANA time zone identifier"}),mH=Je(hD,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Named",toCodecArbitrary:()=>fd()(Fo(fH),Ie(gw)),toCodecJson:()=>Ne()(pH,oH),toFormatter:()=>e=>Yp(e)}),Iee=pH.pipe(ee(mH,oH)),hH=z.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),xH=Je(pD,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone",toCodecArbitrary:()=>fd()(dH(),Ie(e=>typeof e=="number"?yw(e):gw(e))),toCodecJson:()=>Ne()(hH,sH),toFormatter:()=>e=>Yp(e)}),Tee=hH.pipe(ee(xH,sH)),gH=z.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),yH=Je(e=>Tu(e)&&gD(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Zoned",toCodecArbitrary:({constraint:e})=>{let[t,r]=lH(e,mee,hee);return fd()(Te({epochMilliseconds:dA(t,r),timeZone:dH()}),Ie(({epochMilliseconds:n,timeZone:o})=>gy(n,{timeZone:o})))},toCodecJson:()=>Ne()(gH,aH),toFormatter:()=>e=>Sw(e),toEquivalence:()=>yD}),wee=gH.pipe(ee(yH,aH)),so=(e,t,r,n)=>z.pipe(ee(e,Xt({decode:(o,s)=>{let i=t(o);return tt(i)?I(i.success):D(new le({message:i.failure.message},o,s))},encode:o=>I(r(o))}))).annotate({identifier:n}),Yu=Je(Xl,{identifier:"MacAddress"}),ld=so(Yu,vB,vC,"MacAddressFromString"),rh=Je(Br,{identifier:"Ipv4Address"}),pA=so(rh,qu,$r,"Ipv4AddressFromString"),VS=Je(ts,{identifier:"Ipv6Address"}),SH=so(VS,zu,$r,"Ipv6AddressFromString"),Sc=Je(EC,{identifier:"IpAddress"}),Xu=so(Sc,pc,$r,"IpAddressFromString"),At=(e,t,r,n)=>I$(t,{expected:r})(e).annotate({identifier:n}),vee=At(Sc,ed,"a multicast address","IpMulticastAddress"),Cee=At(Xu,ed,"a multicast address","IpMulticastAddressFromString"),Aee=At(Yu,ed,"a multicast address","MacMulticastAddress"),kee=At(ld,ed,"a multicast address","MacMulticastAddressFromString"),Ree=At(Sc,RC,"a unicast address","IpUnicastAddress"),Oee=At(Xu,RC,"a unicast address","IpUnicastAddressFromString"),_ee=At(Yu,AS,"a unicast address","MacUnicastAddress"),Pee=At(ld,AS,"a unicast address","MacUnicastAddressFromString"),Mee=At(rh,RS,"a broadcast address","Ipv4BroadcastAddress"),Fee=At(pA,RS,"a broadcast address","Ipv4BroadcastAddressFromString"),Nee=At(Yu,CS,"a broadcast address","MacBroadcastAddress"),Uee=At(ld,CS,"a broadcast address","MacBroadcastAddressFromString"),Dee=At(Sc,kC,"a loopback address","IpLoopbackAddress"),Lee=At(Xu,kC,"a loopback address","IpLoopbackAddressFromString"),Bee=At(Sc,OC,"a link-local address","IpLinkLocalAddress"),$ee=At(Xu,OC,"a link-local address","IpLinkLocalAddressFromString"),Hee=At(Sc,kS,"an unspecified address","IpUnspecifiedAddress"),jee=At(Xu,kS,"an unspecified address","IpUnspecifiedAddressFromString"),qee=At(rh,_C,"a private address","Ipv4PrivateAddress"),zee=At(pA,_C,"a private address","Ipv4PrivateAddressFromString"),Wee=At(VS,PC,"a unique-local address","Ipv6UniqueLocalAddress"),Kee=At(SH,PC,"a unique-local address","Ipv6UniqueLocalAddressFromString"),Vee=At(Yu,CC,"a locally administered address","MacLocallyAdministeredAddress"),Jee=At(ld,CC,"a locally administered address","MacLocallyAdministeredAddressFromString"),Gee=At(Yu,AC,"a universally administered address","MacUniversallyAdministeredAddress"),Zee=At(ld,AC,"a universally administered address","MacUniversallyAdministeredAddressFromString"),bH=Je(DB,{identifier:"Ipv4Interface"}),Qee=so(bH,MS,Hm,"Ipv4InterfaceFromString"),EH=Je(LB,{identifier:"Ipv6Interface"}),Yee=so(EH,FS,Hm,"Ipv6InterfaceFromString"),IH=Je(Bm,{identifier:"IpInterface"}),Xee=so(IH,NS,Hm,"IpInterfaceFromString"),TH=Je($B,{identifier:"Ipv4Network"}),ete=so(TH,jB,qm,"Ipv4NetworkFromString"),wH=Je(HB,{identifier:"Ipv6Network"}),tte=so(wH,qB,qm,"Ipv6NetworkFromString"),vH=Je(jm,{identifier:"IpNetwork"}),rte=so(vH,zB,qm,"IpNetworkFromString"),nte=Je(Fm,{identifier:"InetAddressV4"}),ote=Je(Nm,{identifier:"InetAddressV6"}),CH=Je(IC,{identifier:"InetAddress"}),ste=so(CH,MC,OS,"InetAddressFromString"),AH=Je(wS,{identifier:"UnixPathAddress"}),ite=z.pipe(ee(AH,Fe({decode:AB,encode:e=>e.path}))).annotate({identifier:"UnixPathAddressFromString"}),ate=Je(TB,{identifier:"SocketAddress"}),Sa=z.check(Ge(ga,{expected:"a normalized domain name"})).pipe(HS("~effect/net/Host/DomainName")).annotate({identifier:"DomainName"}),kH=so(Sa,_S,e=>e,"DomainNameFromString"),mA=z.check(Ge(TC,{expected:"a canonical scoped IPv6 literal"})).pipe(HS("~effect/net/NetAddress/ScopedIpv6Literal")).annotate({identifier:"ScopedIpv6Literal"}),RH=so(mA,Um,e=>e,"ScopedIpv6LiteralFromString"),cte=Pe([Sc,mA,Sa]).annotate({identifier:"Host"}),ute=Pe([Xu,RH,kH]).annotate({identifier:"HostFromString"}),OH=Je(UC,{identifier:"HostPort"}),fte=so(OH,RB,DC,"HostPortFromString"),lte=In.check(yc({minimum:0,maximum:65535},{expected:"a port number"})),dte=Xt({decode:(e,t)=>Zt(iP(e),{onNone:()=>D(new le({expected:"a valid Duration string"},e,t)),onSome:I}),encode:e=>I(globalThis.String(e))}),pte=Xt({decode:e=>I($o(e)),encode:(e,t)=>Zt(aP(e),{onNone:()=>D(new le({expected:"a Duration representable as a bigint"},e,t)),onSome:r=>I(r)})}),mte=Fe({decode:e=>Zi(e),encode:e=>zt(e)}),nh=Je(Qi,{representation:{id:"effect/schema/Duration",payload:null},toCode:()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),expected:"Duration",toCodecJson:()=>Ne()(Pe([Te({_tag:fr("Infinity")}),Te({_tag:fr("NegativeInfinity")}),Te({_tag:fr("Nanos"),value:cd}),Te({_tag:fr("Millis"),value:In})]),Fe({decode:e=>{switch(e._tag){case"Infinity":return Ss;case"NegativeInfinity":return Da;case"Nanos":return $o(e.value);case"Millis":return Zi(e.value)}},encode:e=>{switch(e.value._tag){case"Infinity":return{_tag:"Infinity"};case"NegativeInfinity":return{_tag:"NegativeInfinity"};case"Nanos":return{_tag:"Nanos",value:e.value.nanos};case"Millis":return{_tag:"Millis",value:e.value.millis}}}}))}),hte=z.annotate({expected:"a string that will be decoded as a Duration"}),xte=hte.pipe(ee(nh,dte)),gte=cd.pipe(ee(nh,pte)),yte=Ju.pipe(ee(nh,mte)),Ste=Fo($C),_H=(e,t)=>z.pipe(ee(e,Xt({decode:(r,n)=>{let o=t(r);return be(o)?D(new le({message:o.failure.message},r,n)):$r(o.success)===r?I(o.success):D(new le({message:"expected a canonical address"},r,n))},encode:r=>I($r(r))}))),VC=In.check(yc({minimum:0,maximum:255})),rd=In.check(yc({minimum:0,maximum:65535})),PH=In.check(yc({minimum:0,maximum:4294967295})),US=PH.pipe(ee(nh,Fe({decode:ap,encode:ui}))),ns=(e,t)=>Je(r=>HC(r)&&r._tag===e,{identifier:`Dns${e.charAt(0)}${e.slice(1).toLowerCase()}Record`,toCodecJson:()=>{let r=ya(e,t);return Ne()(r,Xt({decode:(n,o)=>{let{_tag:s,...i}=n,a=FB(e,i);return tt(a)?I(a.success):D(new le({message:a.failure.message},n,o))},encode:n=>I({...n})}))}}),MH=ns("A",{address:_H(rh,qu)}),FH=ns("AAAA",{address:_H(VS,zu)}),NH=ns("CAA",{critical:Fi,tag:z.check(Qu(/^[a-z0-9]+$/i)),value:z}),UH=ns("CNAME",{target:Sa}),DH=ns("MX",{exchange:Sa,priority:rd}),LH=ns("NAPTR",{order:rd,preference:rd,flags:z,service:z,regexp:z,replacement:Sa}),BH=ns("NS",{host:Sa}),$H=ns("PTR",{host:fA}),HH=ns("SOA",{primary:Sa,admin:fA,serial:PH,refresh:US,retry:US,expire:US,minimum:US}),jH=ns("SRV",{target:Sa,port:rd,priority:rd,weight:rd}),qH=ns("TLSA",{certUsage:VC,selector:VC,matchingType:VC,data:Y$}),zH=ns("TXT",{chunks:Zu(z)}),bte=Pe([MH,FH,NH,UH,DH,LH,BH,$H,HH,jH,qH,zH]).annotate({identifier:"DnsRecord"});function hA(e,t,r){let n=Cr()([e,t,r],([o,s,i])=>{let a=Km(s,i);return(c,u,f)=>{if(!ws(c))return D(new at(u,c,f));switch(c._tag){case"Success":return cr(ot(o)(c.value,f),{onSuccess:Mr,onFailure:p=>tn(u,"value",p,c,f)});case"Failure":return cr(ot(a)(c.cause,f),{onSuccess:ir,onFailure:p=>tn(u,"cause",p,c,f)})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:({typeParameters:o})=>({runtime:`Schema.Exit(${o[0].runtime}, ${o[1].runtime}, ${o[2].runtime})`,Type:`Exit.Exit<${o[0].Type}, ${o[1].Type}, ${o[2].Type}>`,importDeclarations:['import * as Exit from "effect/Exit"']}),expected:"Exit",toCodec:([o,s,i])=>Ne()(Pe([Te({_tag:fr("Success"),value:o}),Te({_tag:fr("Failure"),cause:Km(s,i)})]),Fe({decode:a=>a._tag==="Success"?Mr(a.value):ir(a.cause),encode:a=>ft(a)?{_tag:"Success",value:a.value}:{_tag:"Failure",cause:a.cause}}))});return G(n.ast,{value:e,error:t,defect:r})}function e$(e,t,r){return Te({type:fr(e),nodes:ct(Te({index:Wu,data:t})),edges:ct(Te({index:Wu,source:Wu,target:Wu,data:r}))})}function t$(e,t){let r=-1,n=new Set;for(let o=0;o<e.nodes.length;o++){let s=e.nodes[o].index;if(s<=r)return D(new Ct(["nodes",o,"index"],new le({expected:"a strictly increasing node index"},s,t)));r=s,n.add(s)}r=-1;for(let o=0;o<e.edges.length;o++){let s=e.edges[o];if(s.index<=r)return D(new Ct(["edges",o,"index"],new le({expected:"a strictly increasing edge index"},s.index,t)));if(r=s.index,!n.has(s.source))return D(new Ct(["edges",o,"source"],new le({expected:"an encoded node index"},s.source,t)));if(!n.has(s.target))return D(new Ct(["edges",o,"target"],new le({expected:"an encoded node index"},s.target,t)))}return I(My(e))}function Ete(e,t,r){return!Vw(e)||e.mutable||e.type!==t?D(new le({expected:`an immutable ${t} Graph`},e,r)):I(cm(e))}function Ite(e,t){return(r,n)=>{let o=cm(r),s=cm(n);if(o.type!==s.type||o.nodes.length!==s.nodes.length||o.edges.length!==s.edges.length)return!1;for(let i=0;i<o.nodes.length;i++)if(o.nodes[i].index!==s.nodes[i].index||!e(o.nodes[i].data,s.nodes[i].data))return!1;for(let i=0;i<o.edges.length;i++){let a=o.edges[i],c=s.edges[i],u=o.type==="directed"?a.source===c.source&&a.target===c.target:a.source===c.source&&a.target===c.target||a.source===c.target&&a.target===c.source;if(a.index!==c.index||!u||!t(a.data,c.data))return!1}return!0}}function Tte(e,t,r){return fd()(Pe([LS,Te({nodes:Zu(t),edges:ct(rs([Wu,Wu,r]))})]),Ie(n=>{if(n===null)return My({type:e,nodes:[],edges:[]});let o=n.nodes.map((s,i)=>({index:i,data:s}));return My({type:e,nodes:o,edges:n.edges.map(([s,i,a],c)=>({index:c,source:s%o.length,target:i%o.length,data:a}))})}))}function wte(e,t,r){let n=Cr()([t,r],([o,s])=>{let i=e$(e,o,s);return(a,c,u)=>!Vw(a)||a.mutable||a.type!==e?D(new at(c,a,u)):A(ot(i)(cm(a),u),f=>t$(f,u))},{representation:{id:"effect/schema/Graph",payload:e},toCode:({typeParameters:o})=>({runtime:`Schema.Graph(${j(e)}, ${o[0].runtime}, ${o[1].runtime})`,Type:`Graph.Graph<${o[0].Type}, ${o[1].Type}, ${j(e)}>`,importDeclarations:['import * as Graph from "effect/Graph"']}),expected:`an immutable ${e} Graph`,toCodec:([o,s])=>Ne()(e$(e,o,s),Xt({decode:t$,encode:(i,a)=>Ete(i,e,a)})),toCodecArbitrary:({typeParameters:[o,s]})=>Tte(e,o,s),toEquivalence:([o,s])=>Ite(o,s)});return G(n.ast,{type:e,node:t,edge:r})}function r$(e){return Ne()(e,Fe({decode:Ow,encode:nm}))}function vte(e,t){let r=Cr()([e,t],([n,o])=>{let s=ct(rs([n,o]));return(i,a,c)=>Ty(i)?cr(ot(s)(nm(i),c),{onSuccess:Ow,onFailure:u=>tn(a,"entries",u,i,c)}):D(new at(a,i,c))},{representation:{id:"effect/schema/HashMap",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.HashMap(${n[0].runtime}, ${n[1].runtime})`,Type:`HashMap.HashMap<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as HashMap from "effect/HashMap"']}),expected:"HashMap",toCodec:([n,o])=>r$(ct(rs([n,o]))),toCodecArbitrary:({constraint:n,typeParameters:[o,s]})=>r$(BS(ct(rs([o,s])).check(H$()),n?.minSize,n?.maxSize)),toEquivalence:([n,o])=>mx(n,o)});return G(r.ast,{key:e,value:t})}function n$(e){return Ne()(e,Fe({decode:Pw,encode:vt}))}function Cte(e){let t=Cr()([e],([r])=>{let n=ct(r);return(o,s,i)=>Ay(o)?cr(ot(n)(vt(o),i),{onSuccess:Pw,onFailure:a=>tn(s,"values",a,o,i)}):D(new at(s,o,i))},{representation:{id:"effect/schema/HashSet",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.HashSet(${r[0].runtime})`,Type:`HashSet.HashSet<${r[0].Type}>`}),expected:"HashSet",toCodec:([r])=>n$(ct(r)),toCodecArbitrary:({constraint:r,typeParameters:[n]})=>n$(BS(ct(n).check(uA()),r?.minSize,r?.maxSize)),toEquivalence:([r])=>Hd(r)});return G(t.ast,{value:e})}function ba(e){let t=Cr()([e],([r])=>(n,o,s)=>ci(n)?fe(n)?ia:cr(ot(r)(n.value,s),{onSuccess:N,onFailure:i=>tn(o,"value",i,n,s)}):D(new at(o,n,s)),{representation:{id:"effect/schema/Option",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Option(${r[0].runtime})`,Type:`Option.Option<${r[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),expected:"Option",toCodec:([r])=>Ne()(Pe([Te({_tag:fr("Some"),value:r}),Te({_tag:fr("None")})]),Fe({decode:n=>n._tag==="None"?_():N(n.value),encode:n=>de(n)?{_tag:"Some",value:n.value}:{_tag:"None"}}))});return G(t.ast,{value:e})}function Ate(e){return nA(e).pipe(ee(ba(oo(e)),Z1()))}function kte(e){return $S(e).pipe(ee(ba(oo(e)),Q1()))}function Rte(e,t){return b$(e).pipe(ee(ba(oo(e)),Y1(t)))}var WH=Je(jD,{representation:{id:"effect/http/Cookie",payload:null},toCode:()=>({runtime:"Schema.Cookie",Type:"Cookies.Cookie",importDeclarations:['import * as Cookies from "effect/http/Cookies"']}),expected:"Cookie"}),KH=Je(HD,{representation:{id:"effect/http/Cookies",payload:null},toCode:()=>({runtime:"Schema.Cookies",Type:"Cookies.Cookies",importDeclarations:['import * as Cookies from "effect/http/Cookies"']}),expected:"Cookies",toCodecJson:()=>Ne()(ct(z),Fe({decode:Ry,encode:VD})),toCodecIso:()=>Ne()(Gu(z,WH),Fe({decode:Dw,encode:e=>e.cookies}))}),Ote=KH.pipe(ee(Gu(z,z),Fe({decode:KD,encode:e=>Lw(globalThis.Object.entries(e).map(([t,r])=>WD(t,r)))}))),_te=Je(QD,{representation:{id:"effect/http/Headers",payload:null},toCode:()=>({runtime:"Schema.Headers",Type:"Headers.Headers",importDeclarations:['import * as Headers from "effect/http/Headers"']}),expected:"Headers",toEquivalence:()=>Hw,toCodec:()=>Ne()(Gu(z,z),Fe({decode:Zo,encode:e=>({...e})}))}),xA=Je(zw,{representation:{id:"effect/http/UrlParams",payload:null},toCode:()=>({runtime:"Schema.UrlParams",Type:"UrlParams.UrlParams",importDeclarations:['import * as UrlParams from "effect/http/UrlParams"']}),expected:"UrlParams",toEquivalence:()=>Ww,toCodec:()=>Ne()(ct(rs([z,z])),Fe({decode:Cl,encode:e=>e.params}))}),Pte=(e,t)=>xA.pipe(ee(lA(Zm,t),Xt({decode:r=>Zt(n1(r,e),{onNone:()=>D(new Ct([e],new Yt(void 0))),onSome:I}),encode:r=>I(Cl([[e,r]]))}))),Mte=xA.pipe(ee(Gu(z,Pe([z,Zu(z)])),Fe({decode:s1,encode:_u})));function Fte(e){return Ku(e).pipe(ee(ba(oo(e)),X1()))}function Nte(e){return lr(e).pipe(ee(ba(oo(e)),e2()))}function Ute(e,t){let r=t===void 0?"omit":t.onNoneEncoding,n=r===null?null:void 0;return lr(nA(e)).pipe(ee(ba(oo(e)),zy({decode:o=>o.pipe(Fa(lx),N),encode:r==="omit"?Yc:o=>N(Ma(Yc(o),()=>n))})))}function VH(e,t){let r=typeof t?.label=="string"?t.label:void 0,n=t?.disallowJsonEncode===!0,o=r!==void 0?n?{label:r,disallowJsonEncode:!0}:{label:r}:n?{disallowJsonEncode:!0}:void 0,s=r!==void 0?ot(fr(r)):void 0,i=Cr()([e],([a])=>(c,u,f)=>{if(sm(c)){let p=s!==void 0?bu(s(c.label,f),m=>new Ct(["label"],m)):P;return ur(p,()=>cr(ot(a)(nc(c),f),{onSuccess:m=>Ou(m,{label:c.label}),onFailure:()=>new Pt(u,[new Ct(["value"],new le(void 0,c,f))],c,f)}))}return D(new at(u,c,f))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:({typeParameters:a})=>({runtime:o!==void 0?`Schema.Redacted(${a[0].runtime}, ${j(o)})`:`Schema.Redacted(${a[0].runtime})`,Type:`Redacted.Redacted<${a[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),expected:"Redacted",toCodecJson:([a])=>Ne()(a,{decode:Ie(c=>Ou(c,{label:r})),encode:n?Dy(c=>"Cannot serialize Redacted"+(de(c)&&typeof c.value.label=="string"?` with label: "${c.value.label}"`:"")):Ie(nc)}),toEquivalence:([a])=>ZD(a)});return G(i.ast,{value:e})}function Dte(e,t){return ee(VH(oo(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:Ie(r=>Ou(r,{label:t?.label})),encode:t?.disallowEncode?Dy(r=>"Cannot encode Redacted"+(de(r)&&typeof r.value.label=="string"?` with label: "${r.value.label}"`:"")):Ie(nc)})(e)}function Lte(e,t){let r=Cr()([e,t],([n,o])=>(s,i,a)=>{if(!Uf(s))return D(new at(i,s,a));switch(s._tag){case"Success":return cr(Jv(n)(s.success,a),{onSuccess:X,onFailure:c=>tn(i,"success",c,s,a)});case"Failure":return cr(Jv(o)(s.failure,a),{onSuccess:re,onFailure:c=>tn(i,"failure",c,s,a)})}},{representation:{id:"effect/schema/Result",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Result(${n[0].runtime}, ${n[1].runtime})`,Type:`Result.Result<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as Result from "effect/Result"']}),expected:"Result",toCodec:([n,o])=>Ne()(Pe([Te({_tag:fr("Success"),success:n}),Te({_tag:fr("Failure"),failure:o})]),Fe({decode:s=>s._tag==="Success"?X(s.success):re(s.failure),encode:s=>tt(s)?{_tag:"Success",success:s.success}:{_tag:"Failure",failure:s.failure}}))});return G(r.ast,{success:e,failure:t})}var Bte=globalThis.Symbol.for("immer-draftable"),QC={};function gA(e,t,r,n,o){let s=Hte(r,t,n),i=JH(t),a=class extends e{constructor(...[c,u]){let p=u?.["~payload"],m=p?.token===QC?p.value:r.make(c??{},u);super(m,{...u,disableChecks:!0,"~payload":{token:QC,value:m}})}static[zm]=zm;get[i](){return i}static[Bte]=!0;static identifier=t;static fields=r.fields;static get ast(){return s(this).ast}static pipe(){return V(this,arguments)}static rebuild(c){return s(this).rebuild(c)}static make(c,u){return uS(s(this))(c??{},u)}static makeOption(c,u){return cS(s(this))(c??{},u)}static makeEffect(c,u){return s(this).makeEffect(c??{},u)}static annotate(c){return this.rebuild(Fs(this.ast,c))}static annotateKey(c){return this.rebuild(Hl(this.ast,c))}static check(...c){return this.rebuild(Pi(this.ast,c))}static extend(c){return(u,f)=>{let p=oh(u)?u:Te(u),m={...r.fields,...p.fields},h=Zy(m,r.ast.checks,{identifier:c});return gA(this,c,rA(Pi(h,p.ast.checks),m),f,o)}}static mapFields(c,u){return r.mapFields(c,u)}};return o!==void 0&&Object.assign(a.prototype,o(t)),a}function $te(e){return new et(Ie(t=>new e(t,{"~payload":{token:QC,value:t}})),Oi())}function JH(e){return`~effect/Schema/Class/${e}`}function Hte(e,t,r){let n;return o=>{if(n!==void 0)return n;let s=JH(t),i=u=>u instanceof o||O(u,s),a=$te(o),c=G(new uc([e.ast],()=>(u,f,p)=>i(u)?I(u):D(new at(f,u,p)),{identifier:t,[Ny]:([u])=>({isConstructed:i,link:new Bt(u,a)}),toCodec:([u])=>new Bt(u.ast,a),toEquivalence:([u])=>u,toFormatter:([u])=>f=>`${o.identifier}(${u(f)})`,[um]:ac(e.ast),...r}));return n=ee(c,a)(e)}}function oh(e){return Vu(e)}var JS=e=>(t,r)=>{let n=oh(t)?t:Te(t);return gA(hP,e,n,r,o=>({toString(){return`${o}(${j({...this})})`}}))},jte=e=>(t,r,n)=>{let o=oh(r)?r.mapFields(s=>({_tag:je(t),...s}),{unsafePreserveChecks:!0}):ya(t,r);return JS(e??t)(o,n)},Ar=e=>(t,r)=>{let n=oh(t)?t:Te(t);return gA(Zd,e,n,r,s=>({name:s}))},yA=e=>(t,r,n)=>{let o=oh(r)?r.mapFields(s=>({_tag:je(t),...s}),{unsafePreserveChecks:!0}):ya(t,r);return Ar(e??t)(o,n)};function qte(e){return t=>t.annotate({toFormatter:e})}function zte(e,t){return dB(e.ast,t)}function Wte(e){return t=>t.annotate({toEquivalence:e})}function Kte(e){return lC(e.ast)}function Vte(e,t){return _m(e.ast,t)}function Jte(e,t){let r=_m(Kl(e.ast),t);return SS(r,t)}var ef=mS,Gte=hS,Zte=xS,Qte=HL;function Yte(e,t){return aB(e,t)}function Xte(e){return SB(e)}function ere(e){return bB(e)}function tre(e){return EB(e)}function rre(e,t){return r=>G(Fs(r.ast,{toCodecIso:()=>new Bt(e.ast,qy(t))}),{schema:r})}function nre(e){return iB(e)}function ore(e){let t=E$(()=>r),r=Pe([e,ct(t),Gu(z,t)]);return r}var GS=G(Fs(Ul,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})})),sre=Gu(z,GS),ire=Te({message:z,name:Ku(z),stack:Ku(z),cause:Ku(GS)}),are=G(Fs(nL,{toCode:()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"})}));function cre(e){return da(e.ast)}function ure(e){return e.ast.context?.annotations}var GH=gT;var bc=Gx,ZS=zP,Tn=pp;var os=ea,Ni=DF;var Hr=e0,ZH=zF;var QH="~effect/MutableRef",fre={[QH]:QH,...wr,toJSON(){return{_id:"MutableRef",current:pr(this.current)}}},dd=e=>{let t=Object.create(fre);return t.current=e,t};var YH=e=>e.current;var QS=d(2,(e,t)=>(e.current=t,e));var jr=Symbol.for("effect/MutableList/Empty"),Ta=()=>({head:void 0,tail:void 0,length:0}),bA=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},XH=()=>({array:[],mutable:!0,offset:0,next:void 0}),zs=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=XH(),e.tail=e.tail.next):e.head=e.tail=XH(),e.tail.array.push(t),e.length++},EA=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||(e.tail=e.head),e.length++};var YS=(e,t)=>XS(e,vt(t),!Array.isArray(t)),XS=(e,t,r=!1)=>{if(t.length===0)return 0;let n={array:t,mutable:r,offset:0,next:void 0};return e.head?e.tail=e.tail.next=n:e.head=e.tail=n,e.length+=t.length,t.length},Ia=e=>{e.head=e.tail=void 0,e.length=0},tf=(e,t)=>{if(t=Dt(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let s=e.head.array;return Ia(e),s}let r=new Array(t),n=0,o=e.head;for(;o;){for(;o.offset<o.array.length;)if(r[n++]=o.array[o.offset],o.mutable&&(o.array[o.offset]=void 0),o.offset++,n===t)return e.head=o.offset===o.array.length&&o.next?o.next:o,e.length-=t,e.length===0?Ia(e):bA(e),r;o=o.next}return Ia(e),r},eb=(e,t)=>{if(t=Dt(t),t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){Ia(e);return}let r=0,n=e.head;for(;n;){let o=n.array.length-n.offset;if(r+o>t){n.offset+=t-r,e.head=n,e.length-=t,bA(e);return}r+=o,n=n.next}Ia(e)},Ec=e=>tf(e,e.length),rf=e=>{if(!e.head)return jr;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:Ia(e):bA(e),t},ej=(e,t)=>{if(t=Dt(t),t<=0)return[];let r=Math.min(t,e.length),n=new Array(r),o=0,s=e.head;for(;s;){for(let i=s.offset;i<s.array.length;i++)if(n[o++]=s.array[i],o===r)return n;s=s.next}return n};var IA=(e,t)=>{let r=[],n=e.head,o=0;for(;n;){for(let s=n.offset;s<n.array.length;s++)t(n.array[s],o++)&&r.push(n.array[s]);n=n.next}if(r.length===0){Ia(e);return}e.head=e.tail={array:r,mutable:!0,offset:0,next:void 0},e.length=r.length},tj=(e,t)=>IA(e,r=>r!==t);var lre="~effect/PubSub";var dre="~effect/PubSub/Subscription",sb=e=>W(()=>yre(e.atomicPubSub(),new Map,Zn(),Hr(!1),dd(!1),e.strategy(),dd(_()))),ib=e=>sb({atomicPubSub:()=>FA(e),strategy:()=>new rb}),ab=e=>sb({atomicPubSub:()=>FA(e),strategy:()=>new nb}),cb=e=>sb({atomicPubSub:()=>FA(e),strategy:()=>new MA}),ih=e=>sb({atomicPubSub:()=>rj(e),strategy:()=>new nb}),FA=e=>{let t=typeof e=="number"?{capacity:e}:e;if(Sre(t.capacity),t.capacity===1/0)return rj(t);let r=t.replay&&t.replay>0?new ob(Math.ceil(t.replay)):void 0;return t.capacity===1?new AA(r):oU(t.capacity)===t.capacity?new vA(t.capacity,r):new TA(t.capacity,r)},rj=e=>{let t=e?.replay;return new RA(t&&t>0?new ob(Math.ceil(t)):void 0)};var ah=e=>Ci(ar(t=>(QS(e.shutdownFlag,!0),Ve(e.scope,Fg(t.id)).pipe(Kt(e.strategy.shutdown),iy(e.shutdownHook.open),vo)))),ub=d(2,(e,t)=>W(()=>pre(e,t))),pre=d(2,(e,t)=>{if(e.shutdownFlag.current||de(e.ended.current))return!1;if(QS(e.ended,N(t)),e.strategy instanceof rb)for(let[n,o,s]of Ec(e.strategy.publishers))s&&hi(o,Mr(!1));let r=Mr(t);for(let n of e.subscribers.values())for(let o of n){let s;for(;(s=rf(o))!==jr;)hi(s,r)}return e.subscribers.clear(),!0});var fb=d(2,(e,t)=>L(()=>e.shutdownFlag.current||de(e.ended.current)?I(!1):e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),I(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag,e.ended))),nj=d(2,(e,t)=>e.shutdownFlag.current||de(e.ended.current)?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),oj=d(2,(e,t)=>L(()=>{if(e.shutdownFlag.current||de(e.ended.current))return I(!1);let r=e.pubsub.publishAll(t);return e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),r.length===0?I(!0):e.strategy.handleSurplus(e.pubsub,e.subscribers,r,e.shutdownFlag,e.ended)})),ch=e=>Ci(yn(t=>{let r=Re(t,it),n=yr(e.scope),o=gre(e.pubsub,e.subscribers,e.strategy,e.ended);return It(n,mre(o)).pipe(Kt(Wo(r,s=>Ve(n,s))),Ot(o))})),mre=e=>Ci(ar(t=>(QS(e.shutdownFlag,!0),Ko(Ec(e.pollers),r=>s0(r,t.id),{discard:!0,concurrency:"unbounded"}).pipe(Rt(()=>W(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),iy(e.shutdownHook.open),vo)))),lb=e=>L(()=>{if(e.shutdownFlag.current)return Dn;if(e.replayWindow.remaining>0){let r=e.replayWindow.take();return I(r)}let t=e.pollers.length===0?e.subscription.poll():jr;return t===jr?ij(e):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),I(t))}),sj=e=>L(function t(r){if(e.shutdownFlag.current)return Dn;let n=e.pollers.length===0?e.subscription.pollUpTo(Number.POSITIVE_INFINITY):[];return r&&(n=r.concat(n)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?I(e.replayWindow.takeAll().concat(n)):Jr(n)?I(n):A(ij(e),o=>t([o]))}),ij=e=>Nn(t=>{if(e.shutdownFlag.current)return t(Dn);if(de(e.ended.current)){let o=e.pollers.length===0?e.subscription.poll():jr;return o!==jr?(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),t(I(o))):t(I(e.ended.current.value))}let r=uu(),n=e.subscribers.get(e.subscription);return n||(n=new Set,e.subscribers.set(e.subscription,n)),n.add(e.pollers),zs(e.pollers,r),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),r.effect?t(r.effect):(r.resumes=[t],W(()=>tj(e.pollers,r)))});var tr=Symbol.for("effect/PubSub/AbsentValue"),hre=(e,t,r)=>{e.has(t)||e.set(t,new Set),e.get(t).add(r)},xre=(e,t,r)=>{if(!e.has(t))return;let n=e.get(t);n.delete(r),n.size===0&&e.delete(t)},gre=(e,t,r,n)=>new _A(e,t,e.subscribe(),Ta(),Hr(!1),dd(!1),r,e.replayWindow(),n),TA=class{array;replayIndices;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,r){this.capacity=t,this.replayBuffer=r,this.array=Array.from({length:t}),this.replayIndices=r?Array.from({length:t}):[],this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new pd(this.replayBuffer):db}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let r=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let n=this.publisherIndex%this.capacity;this.array[n]=t,r!==void 0&&(this.replayIndices[n]=r),this.subscribers[n]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let r=vt(t),n=r.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(n,s);if(i===0)return r;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=r[a++],f=this.publisherIndex%this.capacity;this.array[f]=u;let p=this.replayBuffer?.offer(u);p!==void 0&&(this.replayIndices[f]=p),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return r.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex%this.capacity,r=this.array[t];this.array[t]=tr,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(r,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new wA(this,this.publisherIndex,!1)}},wA=class{self;subscriberIndex;unsubscribed;constructor(t,r,n){this.self=t,this.subscriberIndex=r,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return jr;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex%this.self.capacity,r=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1,r}return jr}pollUpTo(t){if(t=Dt(t),this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let r=this.self.publisherIndex-this.subscriberIndex,n=Math.min(t,r);if(n<=0)return[];let o=[],s=this.subscriberIndex+n;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex%this.self.capacity,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=tr,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex%this.self.capacity;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},vA=class{array;replayIndices;mask;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,r){this.capacity=t,this.replayBuffer=r,this.array=Array.from({length:t}),this.replayIndices=r?Array.from({length:t}):[],this.mask=t-1,this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new pd(this.replayBuffer):db}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let r=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let n=this.publisherIndex&this.mask;this.array[n]=t,r!==void 0&&(this.replayIndices[n]=r),this.subscribers[n]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let r=vt(t),n=r.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(n,s);if(i===0)return r;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=r[a++],f=this.publisherIndex&this.mask;this.array[f]=u;let p=this.replayBuffer?.offer(u);p!==void 0&&(this.replayIndices[f]=p),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return r.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex&this.mask,r=this.array[t];this.array[t]=tr,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(r,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new CA(this,this.publisherIndex,!1)}},CA=class{self;subscriberIndex;unsubscribed;constructor(t,r,n){this.self=t,this.subscriberIndex=r,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return jr;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex&this.self.mask,r=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1,r}return jr}pollUpTo(t){if(t=Dt(t),this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let r=this.self.publisherIndex-this.subscriberIndex,n=Math.min(t,r);if(n<=0)return[];let o=[],s=this.subscriberIndex+n;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex&this.self.mask,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=tr,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex&this.self.mask;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},AA=class{publisherIndex=0;subscriberCount=0;subscribers=0;value=tr;replayIndex=0;capacity=1;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new pd(this.replayBuffer):db}pipe(){return V(this,arguments)}isEmpty(){return this.subscribers===0}isFull(){return!this.isEmpty()}size(){return this.isEmpty()?0:1}publish(t){if(this.isFull())return!1;let r=this.replayBuffer?.offer(t);return this.subscriberCount!==0&&(this.value=t,r!==void 0&&(this.replayIndex=r),this.subscribers=this.subscriberCount,this.publisherIndex+=1),!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let r=vt(t);return r.length===0?r:this.publish(r[0])?r.slice(1):r}slide(){if(this.isFull()){let t=this.value;this.subscribers=0,this.value=tr,this.replayBuffer?.slide(t,this.replayIndex)}}subscribe(){return this.subscriberCount+=1,new kA(this,this.publisherIndex,!1)}},kA=class{self;subscriberIndex;unsubscribed;constructor(t,r,n){this.self=t,this.subscriberIndex=r,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.subscribers===0||this.subscriberIndex===this.self.publisherIndex}size(){return this.isEmpty()?0:1}poll(){if(this.isEmpty())return jr;let t=this.self.value;return this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=tr),this.subscriberIndex=this.self.publisherIndex,t}pollUpTo(t){return Dt(t)<1||this.isEmpty()?[]:[this.poll()]}unsubscribe(){this.unsubscribed||(this.unsubscribed=!0,this.self.subscriberCount-=1,this.self.subscribers!==0&&this.subscriberIndex!==this.self.publisherIndex&&(this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=tr)))}},RA=class{publisherHead={value:tr,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=Number.MAX_SAFE_INTEGER;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new pd(this.replayBuffer):db}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(t){let r=this.replayBuffer?.offer(t),n=this.publisherTail.subscribers;if(n!==0){let o={value:t,replayIndex:r,subscribers:n,next:null};this.publisherTail.next=o,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(t){if(this.publisherTail.subscribers!==0)for(let r of t)this.publish(r);else this.replayBuffer&&this.replayBuffer.offerAll(t);return[]}slide(){if(this.publisherHead!==this.publisherTail){let t=this.publisherHead.next,r=t.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=tr,this.subscribersIndex+=1,this.replayBuffer?.slide(r,t.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new OA(this,this.publisherTail,this.publisherIndex,!1)}},OA=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(t,r,n,o){this.self=t,this.subscriberHead=r,this.subscriberIndex=n,this.unsubscribed=o}isEmpty(){if(this.unsubscribed)return!0;let t=!0,r=!0;for(;r;)this.subscriberHead===this.self.publisherTail?r=!1:this.subscriberHead.next.value!==tr?(t=!1,r=!1):(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1);return t}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return jr;let t=!0,r=jr;for(;t;)if(this.subscriberHead===this.self.publisherTail)t=!1;else{let n=this.subscriberHead.next.value;n!==tr&&(r=n,this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=tr,this.self.subscribersIndex+=1),t=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return r}pollUpTo(t){t=Dt(t);let r=[],n=0;for(;n!==t;){let o=this.poll();o===jr?n=t:(r.push(o),n+=1)}return r}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.publisherTail.subscribers-=1;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==tr&&(this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=tr,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},_A=class{[dre]={_A:F};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;ended;constructor(t,r,n,o,s,i,a,c,u){this.pubsub=t,this.subscribers=r,this.subscription=n,this.pollers=o,this.shutdownHook=s,this.shutdownFlag=i,this.strategy=a,this.replayWindow=c,this.ended=u}pipe(){return V(this,arguments)}},PA=class{[lre]={_A:F};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;ended;constructor(t,r,n,o,s,i,a){this.pubsub=t,this.subscribers=r,this.scope=n,this.shutdownHook=o,this.shutdownFlag=s,this.strategy=i,this.ended=a}pipe(){return V(this,arguments)}},yre=(e,t,r,n,o,s,i)=>new PA(e,t,r,n,o,s,i),Sre=e=>{if(e<=0||e!==1/0&&!Number.isInteger(e))throw new Error(`Cannot construct PubSub with capacity of ${e}`)},rb=class{publishers=Ta();get shutdown(){return ar(t=>Ko(Ec(this.publishers),([r,n,o])=>o?s0(n,t.id):P,{concurrency:"unbounded",discard:!0}))}handleSurplus(t,r,n,o,s){return Nn(i=>{if(de(s.current))return i(I(!1));let a=uu();return this.offerUnsafe(n,a),this.onPubSubEmptySpaceUnsafe(t,r),this.completeSubscribersUnsafe(t,r),YH(o)?(this.removeUnsafe(a),i(Dn)):a.effect?i(a.effect):(a.resumes=[i],W(()=>this.removeUnsafe(a)))})}onPubSubEmptySpaceUnsafe(t,r){let n=!0;for(;n&&!t.isFull();){let o=rf(this.publishers);if(o===jr)n=!1;else{let[s,i]=o,a=t.publish(s);a&&o[2]?hi(i,Mr(!0)):a||EA(this.publishers,o),this.completeSubscribersUnsafe(t,r)}}}completePollersUnsafe(t,r,n,o){return NA(this,t,r,n,o)}completeSubscribersUnsafe(t,r){return UA(this,t,r)}offerUnsafe(t,r){let n=t[Symbol.iterator](),o=n.next();if(!o.done)for(;;){let s=o.value;if(o=n.next(),o.done){zs(this.publishers,[s,r,!0]);break}zs(this.publishers,[s,r,!1])}}removeUnsafe(t){IA(this.publishers,([r,n])=>n!==t)}},nb=class{get shutdown(){return P}handleSurplus(t,r,n,o){return I(!1)}onPubSubEmptySpaceUnsafe(t,r){}completePollersUnsafe(t,r,n,o){return NA(this,t,r,n,o)}completeSubscribersUnsafe(t,r){return UA(this,t,r)}},MA=class{get shutdown(){return P}handleSurplus(t,r,n,o,s){return W(()=>de(s.current)?!1:(this.slidingPublishUnsafe(t,n),this.completeSubscribersUnsafe(t,r),!0))}onPubSubEmptySpaceUnsafe(t,r){}completePollersUnsafe(t,r,n,o){return NA(this,t,r,n,o)}completeSubscribersUnsafe(t,r){return UA(this,t,r)}slidingPublishUnsafe(t,r){let n=r[Symbol.iterator](),o=n.next();if(!o.done&&t.capacity>0){let s=o.value,i=!0;for(;i;){t.slide();let a=t.publish(s);a&&(o=n.next())&&!o.done?s=o.value:a&&(i=!1)}}}},NA=(e,t,r,n,o)=>{let s=!0;for(;s&&!n.isEmpty();){let i=rf(o);if(i===jr)xre(r,n,o),o.length===0?s=!1:hre(r,n,o);else{let a=n.poll();a===jr?EA(o,i):(hi(i,Mr(a)),e.onPubSubEmptySpaceUnsafe(t,r))}}},UA=(e,t,r)=>{for(let[n,o]of r)for(let s of o)e.completePollersUnsafe(t,r,n,s)},ob=class{capacity;head={value:tr,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(t){this.capacity=t}slide(t,r){this.slideValues[this.index%this.capacity]={value:t,index:r},this.index++}offer(t){let r=this.publisherIndex++;return this.tail.value=t,this.tail.index=r,this.tail.next={value:tr,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity?this.head=this.head.next:this.size+=1,r}offerAll(t){for(let r of t)this.offer(r)}},pd=class{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(t){this.buffer=t,this.remaining=t.size,this.slideIndex=t.index,this.values=new Array(this.remaining);let r=t.head;for(let n=0;n<this.remaining;n++)this.values[n]=r.value,this.newestIndex=r.index,r=r.next}close(){this.values.length=0,this.remaining=0}sync(){let t=this.buffer.index-this.slideIndex;if(t===0||this.remaining===0)return;let r=Math.min(t,this.buffer.capacity),n=this.buffer.index-r;for(let o=0;o<r;o++){let s=this.buffer.slideValues[(n+o)%this.buffer.capacity];s.index>this.newestIndex&&(this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=s.value,this.newestIndex=s.index)}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let t=this.values[this.index];return this.values[this.index]=tr,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),t}takeN(t){t=Dt(t);let r=Math.min(t,this.remaining),n=new Array(r);for(let o=0;o<r;o++)n[o]=this.take();return n}takeAll(){return this.takeN(this.remaining)}},db={remaining:0,take:()=>{},takeN:()=>[],takeAll:()=>[],close:()=>{}};var bre="~effect/Queue",Ere="~effect/Queue/Enqueue",Ire="~effect/Queue/Dequeue";var DA={_A:F,_E:F},Tre={[bre]:DA,[Ere]:DA,[Ire]:DA,...wr,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:vre(this)}}},io=e=>oe(t=>{let r=Object.create(Tre);return r.dispatcher=t.currentDispatcher,r.capacity=e?.capacity??Number.POSITIVE_INFINITY,r.strategy=e?.strategy??"suspend",r.messages=Ta(),r.scheduleRunning=!1,r.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},q(r)}),nf=e=>io({capacity:e});var hb=()=>io(),Hn=d(2,(e,t)=>ce(()=>Ic(e,t)?yb:e.state._tag==="Open"&&e.strategy==="suspend"?Rre(e,t):cj)),Ic=(e,t)=>e.state._tag!=="Open"?!1:e.messages.length>=e.capacity?e.strategy==="sliding"?(rf(e.messages),zs(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0?(zs(e.messages,t),uj(e),!0):!1:(zs(e.messages,t),mb(e),!0),wa=d(2,(e,t)=>Lt(r=>{let n=xb(e,t);return n.length===0||e.strategy==="dropping"?r(ze(n)):dj(e,{_tag:"Array",remaining:n,offset:0,resume:r})})),xb=(e,t)=>{if(e.state._tag!=="Open")return vt(t);if(e.capacity===Number.POSITIVE_INFINITY||e.strategy==="sliding")return YS(e.messages,t),e.strategy==="sliding"&&tf(e.messages,e.messages.length-e.capacity),mb(e),[];let r=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(r===0)return vt(t);let n=[],o=0;for(let s of t)o<r?zs(e.messages,s):n.push(s),o++;return mb(e),n};var $t=d(2,(e,t)=>ye(()=>Ui(e,t))),Ui=(e,t)=>{if(e.state._tag!=="Open")return!1;let r=Pr(t),n=bM(r,Cre);return e.state.offers.size===0&&e.messages.length===0?(Sb(e,n),!0):(e.state={...e.state,_tag:"Closing",exit:n},mb(e),!0)},md=e=>$t(e,Rf(Jc())),gb=e=>Ui(e,Rf(Jc()));var ss=e=>ye(()=>BA(e)),BA=e=>{if(e.state._tag==="Done")return!1;Ia(e.messages);let t=e.state.offers;Sb(e,e.state._tag==="Open"?Are:e.state.exit);for(let r of t)pj(r);return!0};var of=e=>aj(e,1,Number.POSITIVE_INFINITY);var aj=d(3,(e,t,r)=>(t=Dt(t),r=Dt(r),fj(()=>kre(e,t,r)??bo(lj(e,()=>$A(e,t)),aj(e,t,r))))),Ws=e=>fj(()=>wre(e)??bo(lj(e,()=>$A(e,1)),Ws(e)));var wre=e=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=rf(e.messages);return LA(e),ze(t)}else if(e.capacity<=0&&e.state.offers.size>0){let t=mj(e.state.offers);return LA(e),ze(t)}};var vre=e=>e.state._tag==="Done"?0:e.messages.length;var cj=ze(!1),yb=ze(!0),Cre=So(Jc()),Are=Kf(),uj=e=>{if(!(e.state._tag==="Done"||e.state.takers.size===0)){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(hn),e.messages.length===0))break}},mb=e=>{e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,uj(e)},0))},kre=(e,t,r)=>{if(e.state._tag==="Done")return e.state.exit;if(r<=0||t<=0)return ze([]);if(!$A(e,t))return;let n=e.messages.length>0?tf(e.messages,r):[mj(e.state.offers)];return LA(e),ze(n)},fj=Uo({op:"QueueTake",[St](e){let t=this[Se]();return Wd(t)?t[St](e):t}}),$A=(e,t)=>e.messages.length>=(e.state._tag==="Closing"?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!=="Done"&&e.state.offers.size>0,lj=(e,t)=>Lt(r=>{if(e.state._tag==="Done")return r(e.state.exit);if(t())return r(hn);let n={ready:t,resume:r};return e.state.takers.add(n),ye(()=>{e.state._tag!=="Done"&&e.state.takers.delete(n)})}),Rre=(e,t)=>Lt(r=>Ic(e,t)?r(yb):dj(e,{_tag:"Single",message:t,resume:r})),dj=(e,t)=>{if(e.state._tag!=="Open")return pj(t);let r=e.state.offers;return r.add(t),ye(()=>{e.state._tag!=="Done"&&(r.delete(t),e.state._tag==="Closing"&&r.size===0&&e.messages.length===0&&Sb(e,e.state.exit))})},pj=e=>e._tag==="Single"?e.resume(cj):e.resume(ze(e.remaining.slice(e.offset))),mj=e=>{let t=e.values().next().value;if(t._tag==="Single")return e.delete(t),t.resume(yb),t.message;let r=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(ze([]))),r},LA=e=>{if(e.state._tag==="Done")return wo(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag==="Closing"&&e.messages.length===0?(Sb(e,e.state.exit),wo(e.state.exit.cause)):!1;for(let t of e.state.offers){let r=e.capacity-e.messages.length;if(r<=0)break;if(t._tag==="Single")zs(e.messages,t.message),e.state.offers.delete(t),t.resume(yb);else{for(;t.offset<t.remaining.length;t.offset++){if(r===0)return!1;zs(e.messages,t.remaining[t.offset]),r--}e.state.offers.delete(t),t.resume(ze([]))}let n=e.state;if(n._tag==="Done")return wo(n.exit.cause)}return!1};var Sb=(e,t)=>{if(e.state._tag==="Done")return;let r=e.state;e.state={_tag:"Done",exit:t};for(let n of r.takers)n.resume(t);r.takers.clear();for(let n of r.awaiters)n(t);r.awaiters.clear()};var af=e=>new HA(e),hj=(e,t,r)=>Lt(n=>{if(e.free>=t)return n(r);let o=()=>{e.free<t||(e.waiters.delete(o),n(r))};return e.waiters.add(o),ye(()=>{e.waiters.delete(o)})}),HA=class{waiters=new Set;taken=0;permits;constructor(t){this.permits=t}get free(){return this.permits-this.taken}take(t){let r=ce(()=>this.free<t?hj(this,t,r):(this.taken+=t,q(t)));return r}takeIfAvailable(t){return ce(()=>this.free<t?q(!1):(this.taken+=t,q(!0)))}releaseUnsafe(t,r){return this.taken-=r,this.waiters.size>0&&t.currentDispatcher.scheduleTask(()=>{for(let n of this.waiters){if(this.free<=0)break;n()}},0),this.free}resize(t){return oe(r=>(this.permits=t,this.free<0?pe:(this.releaseUnsafe(r,0),pe)))}release(t){return oe(r=>q(this.releaseUnsafe(r,t)))}get releaseAll(){return oe(t=>q(this.releaseUnsafe(t,this.taken)))}withPermits(t){return r=>Jn(n=>{let o=ce(()=>{if(this.free<t){let s=hj(this,t,pe);return Y(n(s),()=>o)}return this.taken+=t,Io(n(r),()=>{this.releaseUnsafe(ea(),t)},!0)});return o})}withPermit=this.withPermits(1);withPermitsIfAvailable(t){return r=>Jn(n=>this.free<t?ou:(this.taken+=t,Io(n(Wf(r)),()=>{this.releaseUnsafe(ea(),t)},!0)))}};var qA=e=>ws(e)?ft(e)?se(e.value):e:I(e);var Sj="~effect/Channel",on=e=>O(e,Sj),Ore={[Sj]:{_Env:F,_InErr:F,_InElem:F,_OutErr:F,_OutElem:F},pipe(){return V(this,arguments)}},De=e=>{let t=Object.create(Ore);return t.transform=(r,n)=>rt(e(r,n),o=>I(He(o))),t},is=(e,t)=>De((r,n)=>A(we(e)(r,n),o=>t(o,n))),qr=e=>De((t,r)=>e),Vs=e=>De(me(function*(t,r){let n=yr(r),o=i=>Ve(n,Zg(i)),s=yield*to(e(t,r,n),o);return to(s,o)})),we=e=>e.transform,uh=4096,_re=(e,t,r)=>io({capacity:r?.bufferSize,strategy:r?.strategy}).pipe(Rt(n=>It(e,ss(n))),Rt(n=>zo(t(n),e).pipe(rt(o=>$t(n,o)),gt(e))));var bj=(e,t)=>De((r,n)=>K(_re(n,e,t),of)),bb=e=>De((t,r)=>L(()=>we(e())(t,r))),Pre=(e,t,r)=>Vs(me(function*(n,o,s){let i=_();yield*Wo(s,c=>de(i)?r(i.value,c):P);let a=yield*Ci(K(e,c=>(i=N(c),c)));return yield*we(t(a))(n,o)}));var Ej=e=>qr(W(()=>{let t=e();return L(()=>{let r=t.next();return r.done?se(r.value):I(r.value)})})),zA=e=>qr(W(()=>{let t=0;return L(()=>t>=e.length?se():I(e[t++]))}));var WA=(e,t=uh)=>{let r=Lo(t);return qr(W(()=>{let n=e(),o=_();return L(()=>{if(o._tag==="Some")return se(o.value);let s=[];for(;s.length<r;){let i=n.next();if(i.done){if(s.length===0)return se(i.value);o=N(i.value);break}s.push(i.value)}return I(s)})}))};var Ij=(e,t=uh)=>WA(()=>e[Symbol.iterator](),t),Eb=e=>Ib(I(e));var Tj=e=>Ib(W(e)),hd=qr(I(se())),wj=qr(I(Xn)),Di=e=>qr(I(D(e))),vj=e=>qr(ty(e)),fh=e=>qr(He(e)),Cj=e=>qr(aa(e)),KA=e=>fh(ol(e)),Ib=e=>qr(W(()=>{let t=!1;return L(()=>t?se():(t=!0,e))}));var Aj=e=>qr(A(e,()=>se())),VA=e=>qr(I(A(e,qA)));var kj=e=>qr(I(of(e)));var JA=e=>qr(I(gu(sj(e),()=>se())));var Rj=e=>Tc(K(ch(e),JA)),Oj=e=>Tc(K(ch(e),t=>VA(lb(t))));var _j=e=>De((t,r)=>Mre({scope:r,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd}));var Mre=e=>{let t=e.readable.getReader(),r=e.exit??dd(void 0),n=L(()=>r.current?r.current:Un(Vo({try:()=>t.read(),catch:e.onError}),{onFailure:o=>r.current??He(o),onSuccess:({done:o,value:s})=>r.current?r.current:o?se():I(Me(s))}));return Ot(It(e.scope,e.releaseLockOnEnd?W(()=>t.releaseLock()):jp(()=>t.cancel().catch(Rr))),n)},Fre=(e,t)=>De(me(function*(r,n){let o=e[Symbol.asyncIterator]();return o.return&&(yield*It(n,jp(()=>o.return()))),A(Vo({try:()=>o.next(),catch:t}),s=>s.done?se(s.value):I(s.value))})),Pj=(e,t)=>Js(Fre(e,t),Me),Js=d(2,(e,t)=>is(e,r=>W(()=>{let n=0;return K(r,o=>t(o,n++))})));var Mj=d(2,(e,t)=>is(e,r=>I(ht(r,n=>A(t(n),se))))),Fj=e=>e===void 0||e!=="unbounded"&&e<=1,Tb=d(e=>on(e[0]),(e,t,r)=>Fj(r?.concurrency)?Nj(e,t):Nre(e,t,r)),Nj=(e,t)=>De((r,n)=>{let o=0;return K(we(e)(r,n),A(s=>t(s,o++)))}),Nre=(e,t,r)=>Vs(me(function*(n,o,s){let i=0,a=yield*we(e)(n,o),c=r.concurrency==="unbounded"?Number.MAX_SAFE_INTEGER:r.concurrency,u=yield*nf(0);yield*It(s,ss(u));let f=Sr(yield*Nr()),p=Ni(s);if(r.unordered){let m=af(c),h=qe(m.release(1)),x=Un({onFailure:g=>A($t(u,g),h),onSuccess:g=>A(Hn(u,g),h)});yield*m.take(1).pipe(A(()=>a),A(g=>{let y=i++;return p(f(x(L(()=>t(g,y))))),P}),_t({disableYield:!0}),rt(g=>m.withPermits(c-1)($t(u,g))),gt(s))}else{let m=yield*nf(c-2);yield*It(s,ss(m)),yield*Ws(m).pipe(L0,A(g=>Hn(u,g)),_t({disableYield:!0}),rt(g=>$t(u,g)),gt(s));let h,x=g=>{g._tag!=="Success"&&(h=g.cause,Ui(u,g.cause))};yield*a.pipe(A(g=>{if(h)return He(h);let y=i++,E=f(L(()=>t(g,y)));return p(E),E.addObserver(x),Hn(m,bc(E))}),_t({disableYield:!0}),rt(g=>Hn(m,ir(g)).pipe(Kt($t(m,g)))),gt(s))}return Ws(u)}));var GA=d(e=>on(e[0]),(e,t,r)=>Fj(r?.concurrency)?Ure(e,t):Dre(e,t,r)),Ure=(e,t)=>De((r,n)=>K(we(e)(r,n),o=>{let s,i,a=A(o,u=>(i??=yr(n),ur(we(t(u))(r,i),f=>(s=c(f),s)))),c=ht(u=>{if(s=void 0,i.state._tag==="Empty")return a;let f=Ve(i,Wt);return i=void 0,A(f,()=>a)});return L(()=>s??a)})),Dre=(e,t,r)=>e.pipe(Js(t),Cb(r)),Uj=d(2,(e,t)=>De((r,n)=>W(()=>{let o,s=yr(n),i=A(we(e)(r,s),a=>(o=ht(a,c=>Ve(s,Wt).pipe(A(()=>we(t(c))(r,n)),A(u=>(o=u,u)))),o));return L(()=>o??i)})));var ZA=d(4,(e,t,r,n)=>De(me(function*(o,s){let i=yield*we(e)(o,s),a=yield*we(t)(o,s),c=r();return L(()=>{let u=n(c,i,a);return K(u,([f,p])=>(c=p,f))})}))),Dj=d(2,(e,t)=>De((r,n)=>W(()=>{let o,s=yr(n),i=A(we(e)(r,s),a=>{let c=a.pipe(Rt(()=>(o=a,P)),ht(u=>Ve(s,Mr(u)).pipe(Kt(we(t(u))(r,n)),A(f=>(o=f,f)))));return o=c,c});return L(()=>o??i)}))),Lj=e=>GA(e,F),wn=e=>is(e,t=>{let r,n=0,o=L(function s(){if(r===void 0)return A(t,a=>{switch(a.length){case 0:return s();case 1:return I(a[0]);default:return r=a,I(a[n++])}});let i=r[n++];return n>=r.length&&(r=void 0,n=0),I(i)});return I(o)}),Bj=e=>Nj(e,qA),$j=e=>is(e,t=>I(_t(t,{disableYield:!0}))),Hj=d(2,(e,t)=>ks(typeof t=="function"?t(F):t).pipe(K(r=>{let n=Fr.defaultValue();return jj(Ob(e,Fr,W(()=>n)),o=>r(o).pipe(K(s=>{n=s}),ht(()=>se(o))))}),Tc)),jj=(e,t)=>De((r,n)=>W(()=>{let o,s=()=>{let i=yr(n);return A(we(e)(r,i),a=>(o=ht(a,c=>Ve(i,Wt).pipe(A(()=>t(c)),A(s))),o))};return L(()=>o??s())})),qj=e=>jj(e,()=>P),zj=d(2,(e,t)=>is(e,(r,n)=>K(Np(t),o=>Rt(r,o)))),Wj=d(2,(e,t)=>De((r,n)=>K(we(e)(r,n),o=>A(o,function s(i){return t(i)?I(i):A(o,s)}))));var Kj=d(2,(e,t)=>is(e,r=>I(A(r,function n(o){let s=[];for(let i=0;i<o.length;i++)t(o[i])&&s.push(o[i]);return bt(s)?I(s):A(r,n)})))),Vj=d(2,(e,t)=>is(e,r=>I(A(r,function n(o){let s=[];for(let i=0;i<o.length;i++){let a=t(o[i]);tt(a)&&s.push(a.success)}return bt(s)?I(s):A(r,n)})))),Jj=d(2,(e,t)=>is(e,r=>{let n=A(r,o=>W0(o,t));return I(A(n,function o(s){return bt(s)?I(s):A(n,o)}))})),Gj=d(2,(e,t)=>is(e,r=>I(A(r,function n(o){return A(K0(o,t),s=>bt(s)?I(s):A(r,n))})))),xd=d(e=>on(e[0]),(e,t,r,n)=>De((o,s)=>K(we(e)(o,s),i=>{let a=t(),c,u=0,f,p=Un(i,{onFailure(h){f=h;let x=n?.onHalt&&n.onHalt(a);return x&&x.length>0?I([a,x]):He(h)},onSuccess(h){let x=r(a,h);return G_(x)?I(x):x}});return L(function h(){if(c===void 0)return f?He(f):A(p,([g,y])=>(a=g,y.length===0?h():y.length===1?I(y[0]):(c=y,h())));let x=c[u++];return u>=c.length&&(c=void 0,u=0),I(x)})})));var Zj=d(3,(e,t,r)=>De((n,o)=>K(we(e)(n,o),s=>{let i=t,a=!0;return L(()=>a?(a=!1,I(i)):K(A(s,c=>r(i,c)),c=>(i=c,i)))}))),gd=d(2,(e,t)=>De((r,n)=>{let o=yr(n);return K(we(e)(r,o),s=>{let i=s.pipe(rt(a=>{if(wo(a))return He(a);let c=o;return o=yr(n),Ve(c,ir(a)).pipe(Kt(we(t(a))(r,o)),A(u=>(i=u,u)))}));return L(()=>i)})})),Qj=d(2,(e,t)=>vb(e,Cp,t)),wb=d(2,(e,t)=>gd(e,r=>Aj(A(t(r),n=>He(r))))),Yj=d(3,(e,t,r)=>gd(e,n=>t(n)?r(n):fh(n))),vb=d(3,(e,t,r)=>gd(e,n=>{let o=t(n);return be(o)?fh(o.failure):r(o.success,n)})),Ks=d(2,(e,t)=>vb(e,sl,r=>t(r)));var Xj=d(2,(e,t)=>is(e,r=>I(Wp(r,n=>Ap(n)?P:vo(t(n)))))),eq=d(e=>on(e[0]),(e,t,r,n)=>Ks(e,o=>t(o)?r(o):n?n(o):Di(o))),tq=d(e=>on(e[0]),(e,t,r,n)=>Ks(e,o=>{let s=t(o);return be(s)?n?n(s.failure):Di(s.failure):r(s.success)}));var rq=d(e=>on(e[0]),(e,t,r,n,o)=>Ks(e,s=>{if(Or(s,t)&&O(s,"reason")){let i=s.reason;return Or(i,r)?n(i,s):o?o(i,s):Di(s)}return Di(s)})),nq=d(e=>on(e[0]),(e,t,r,n)=>{let o;return Ks(e,s=>{if(Or(s,t)&&O(s,"reason")&&O(s.reason,"_tag")&&Gg(s.reason._tag)){let i=s.reason;return o??=new Set(Object.keys(r)),o.has(i._tag)?r[i._tag](i,s):n?n(i,s):Di(s)}return Di(s)})});var oq=d(2,(e,t)=>Ks(e,r=>Di(t(r)))),sq=e=>Ks(e,KA),iq=d(e=>on(e[0]),(e,t)=>{if(!t?.log)return Ks(e,()=>hd);let r=Sl(t.log===!0?void 0:t.log);return Ks(wb(e,n=>mN(n)?r(n):P),()=>hd)}),gj=e=>gd(e,()=>hd),aq=d(e=>on(e[0]),(e,t)=>{if(!t?.log)return gj(e);let r=Sl(t.log===!0?void 0:t.log);return gj(wb(e,n=>r(n)))}),cq=d(2,(e,t)=>bb(()=>{let r,n=Fr.defaultValue(),o=Ob(e,Fr,W(()=>n)),s=ek(o,()=>(r=void 0,P)),i=typeof t=="function"?t(F):t,a=Ks(s,me(function*(c){return r||(r=yield*ks(i)),n=yield*r(c),a},(c,u)=>ht(c,()=>I(Di(u))),Tc));return a})),uq=d(e=>on(e[0]),(e,t,r)=>e.pipe(Js(t),Cb({...r,concurrency:r?.concurrency??1,switch:!0}))),Cb=d(2,(e,{bufferSize:t=16,concurrency:r,switch:n=!1})=>Vs(me(function*(o,s,i){let a=r==="unbounded"?Number.MAX_SAFE_INTEGER:Math.max(1,r),c=n?void 0:af(a),u=yield*ZH(!0),f=new Set,p=yield*nf(t);yield*It(i,ss(p));let m=yield*we(e)(o,s);return yield*xt(function*(){for(;;){let h;c&&(f.size<a?yield*c.take(1):(h=yield*gl(m),yield*Ya(c.take(1),Kt(bc(h),Xn))));let x=h===void 0?yield*m:yield*bc(h),g=yr(i),y=yield*we(x)(o,g);for(;f.size>=a;){let b=q_(f);f.delete(b),f.size===0&&(yield*u.open),yield*Tn(b)}let E=yield*y.pipe(Rt(()=>zp),A(b=>Hn(p,b)),_t({disableYield:!0}),to(me(function*(b){let v=Zg(b),T=yield*eo(Ve(g,v));if(!f.has(E))return;let S=EN([v,T]);vs(S)&&(yield*$t(p,S.cause)),f.delete(E),c&&(yield*c.release(1)),f.size===0&&(yield*u.open)})),gl);u.closeUnsafe(),f.add(E)}}).pipe(rt(h=>{let x=Mp(h);return tt(x)?u.whenOpen($t(p,h)):$t(p,h)}),gt(i)),Ws(p)}))),Ab=d(e=>on(e[0])&&on(e[1]),(e,t,r)=>Vs(me(function*(n,o,s){let i=r?.haltStrategy??"both",a=yield*nf(0);yield*It(s,ss(a));let c=0;function u(p,m){if(c++,!wo(m))return $t(a,m);switch(i){case"both":return c===2?$t(a,m):P;case"left":case"right":return p===i?$t(a,m):P;case"either":return $t(a,m)}}let f=(p,m,h)=>we(m)(n,h).pipe(A(x=>x.pipe(A(g=>Hn(a,g)),_t)),to(x=>Vp(Zg(x),g=>Ve(h,g)).pipe(Un({onFailure:g=>u(p,g),onSuccess:()=>u(p,x)}))),gt(s));return yield*f("left",e,yr(s)),yield*f("right",t,yr(s)),Ws(a)}))),fq=d(2,(e,t)=>Ab(e,Aj(t),{haltStrategy:"left"})),lq=()=>De((e,t)=>W(()=>{let r="",n=!1,o=_();function s(c){let u=[];function f(p){r.length===0?u.push(p):(u.push(r+p),r="")}for(let p=0;p<c.length;p++){let m=c[p];if(m.length!==0){let h=0,x=m.indexOf("\r"),g=m.indexOf(`
29
+ `);for(n&&(g===0&&(h=1,g=m.indexOf(`
30
+ `,h)),n=!1);x!==-1||g!==-1;)x===-1||g!==-1&&g<x?(f(m.substring(h,g)),h=g+1,g=m.indexOf(`
31
+ `,h)):(f(m.substring(h,x)),m.length===x+1?(n=!0,h=m.length,x=-1):(h=x+(g===x+1?2:1),x=m.indexOf("\r",h),g=m.indexOf(`
32
+ `,h)));r=r+m.substring(h)}}return bt(u)?u:null}let i=L(()=>o._tag==="Some"?se(o.value):Fp(e,{onSuccess:a,onFailure:He,onDone:c=>{if(o=N(c),r.length>0){let u=r;return r="",n=!1,I([u])}return se(c)}}));function a(c){let u=s(c);return u!==null?I(u):i}return i}));var QA=d(2,(e,t)=>De((r,n)=>A(we(e)(r,n),o=>we(t)(o,n)))),YA=d(2,(e,t)=>De((r,n)=>A(we(e)(r,n),o=>{let s=rt(o,i=>wo(i)?He(i):gn(gN(i)));return K(we(t)(s,n),i=>$0(i,a=>Ap(a)?He(a.value):gn(a)))}))),Tc=e=>De((t,r)=>{let n;return I(L(()=>n||e.pipe(zo(r),A(o=>we(o)(t,r)),A(o=>n=o))))}),dq=e=>Vs((t,r,n)=>K(zo(we(e)(t,r),n),zo(n)));var pq=d(2,(e,t)=>De(me(function*(r,n){let o=yield*we(e)(r,n),s=yield*io({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*It(n,ss(s)),yield*o.pipe(A(i=>Hn(s,i)),_t({disableYield:!0}),to(i=>$t(s,i)),gt(n)),Ws(s)}))),mq=d(2,(e,t)=>De(me(function*(r,n){let o=yield*we(e)(r,n),s=yield*io({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*It(n,ss(s)),yield*o.pipe(A(i=>wa(s,i)),_t({disableYield:!0}),to(i=>$t(s,i)),gt(n)),of(s)}))),XA=d(2,(e,t)=>Ab(e,qr(I(A(t,se))),{haltStrategy:"either"})),hq=d(2,(e,t)=>Vs(me(function*(r,n,o){let s=yield*we(e)(r,n),i=yield*gt(t,o,{startImmediately:!0});return L(()=>{let a=i.pollUnsafe();return a===void 0?s:bN(a,{onFailure:He,onSuccess:se})})}))),xq=d(2,(e,t)=>lh(e,r=>vs(r)?t(r.cause):P)),lh=d(2,(e,t)=>Vs((r,n,o)=>Wo(o,t).pipe(Kt(we(e)(r,n))))),gq=d(2,(e,t)=>Tc(Ot(t,e))),ek=d(2,(e,t)=>is(e,r=>W(()=>{let n=!0,o=Rt(r,s=>(n=!1,t(s)));return L(()=>n?o:r)}))),yq=d(2,(e,t)=>is(e,r=>I(ht(r,n=>A(t,()=>se(n)))))),Sq=d(2,(e,t)=>lh(e,r=>t)),cf=(e,t,r)=>L(()=>{let n=Zn(),o=we(e)(se(),n);return ht(A(o,t),r||I).pipe(Xr(s=>Ve(n,s)))});var kb=d(2,(e,t)=>De((r,n)=>K(Ur(we(e)(r,n),t),Ur(t)))),Rb=d(3,(e,t,r)=>De((n,o)=>K(Go(we(e)(n,o),t,r),Go(t,r)))),Ob=d(3,(e,t,r)=>De((n,o)=>A(r,s=>we(Rb(e,t,s))(n,o)))),bq=d(e=>on(e[0]),(e,t,r)=>np(t)?kb(e,t):De((n,o)=>A(r?.local?gi(t,xi(),o):kp(t,o),s=>K(Ur(we(e)(n,o),s),Ur(s))))),Eq=d(2,(e,t)=>De((r,n)=>yn(o=>{let s=t(o);return we(kb(e,s))(r,n)})));var tk=function(){let e=on(arguments[0]),t=e?arguments[1]:arguments[0],r=jo(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return yj(n,t,r)}return n=>yj(n,t,r)},yj=(e,t,r)=>Pre(Y0(t,r),n=>Rb(e,li,n),(n,o)=>ar(s=>{let i=s.getRef(Vn),a=s.getRef(Dg);return Rg(n,o,i,a)}));var Iq=e=>cf(e,t=>_t(t,{disableYield:!0})),uf=d(2,(e,t)=>cf(e,r=>_t(A(r,t),{disableYield:!0}))),Tq=d(2,(e,t)=>cf(e,r=>r.pipe(A(t),A(n=>n?P:se()),_t({disableYield:!0})))),rk=e=>K(ff(e,()=>({bytes:0,arrays:[]}),(t,r)=>{for(let n=0;n<r.length;n++)t.bytes+=r[n].length,t.arrays.push(r[n]);return t}),({arrays:t,bytes:r})=>{let n=new Uint8Array(r),o=0;for(let s=0;s<t.length;s++){let i=t[s];n.set(i,o),o+=i.length}return n});var wq=e=>L(()=>{let t=_();return cf(e,r=>r.pipe(ry,A(n=>(t=n,se()))),()=>I(t))}),vq=e=>L(()=>{let t=Symbol(),r=t;return cf(e,n=>_t(A(n,o=>(r=o,P)),{disableYield:!0}),()=>r===t?ia:U0(r))}),ff=d(3,(e,t,r)=>L(()=>{let n=t();return cf(e,o=>xn({while:nr,body:()=>o,step:s=>{n=r(n,s)}}),()=>I(n))})),Cq=d(3,(e,t,r)=>L(()=>{let n=t();return cf(e,o=>xn({while:nr,body:qe(o.pipe(A(s=>r(n,s)),K(s=>{n=s}))),step:Rr}),()=>I(n))})),nk=me(function*(e){let t=af(1),r=yield*Nr(),n=Re(r,it);return(yield*we(e)(se(),n)).pipe(Ur(r),t.withPermits(1))},rt(e=>I(He(e)))),as=(e,t)=>we(e)(se(),t);var ok=d(e=>on(e[0]),(e,t)=>en(r=>uf(e,n=>wa(t,n)).pipe(r,eo,A(n=>(ft(n)?gb(t):Ui(t,n.cause),P)))));var Aq=d(e=>on(e[0]),me(function*(e,t){let r=yield*Co,n=yield*io({capacity:typeof t.capacity=="number"?t.capacity:void 0,strategy:typeof t.capacity=="number"?t.strategy:void 0});return yield*It(r,ss(n)),yield*gt(ok(e,n),r),n}));var kq=e=>Ti(e.capacity==="unbounded"?ih(e):e.strategy==="dropping"?ab(e):e.strategy==="sliding"?cb(e):ib(e),ah),Rq=d(2,me(function*(e,t){let r=yield*kq(t);return yield*Rs(sk(e,r,{shutdownOnEnd:t.shutdownOnEnd!==!1})),r})),sk=d(e=>on(e[0]),(e,t,r)=>uf(e,n=>oj(t,n)).pipe(r?.shutdownOnEnd===!0?wi(ah(t)):F)),Oq=d(2,me(function*(e,t){let r=yield*kq(t);return yield*uf(e,n=>fb(r,n)).pipe(Xr(n=>ub(r,n)),Rs),r}));var Lre="~effect/Stream",Bre={_R:F,_E:F,_A:F},_q=function(e){this.channel=e};_q.prototype={[Lre]:Bre,pipe(){return V(this,arguments)}};var Pq=e=>new _q(e);var Hre="~effect/Sink";var jre={_A:F,_In:F,_L:F,_E:F,_R:F},qre={[Hre]:jre,pipe(){return V(this,arguments)}};var zre=e=>{let t=Object.create(qre);return t.transform=e,t},Mq=e=>De((t,r)=>I(A(e.transform(t,r),se)));var Fq=e=>{let t=Dt(e);return zre(r=>{let n=[];if(t===0)return I([n]);let o;return r.pipe(A(s=>{if(n.length+s.length<=t)return n.push(...s),n.length===t?se():P;for(let i=0;i<s.length;i++)if(n.push(s[i]),n.length===t)return i+1<s.length&&(o=s.slice(i+1)),se();return P}),_t({disableYield:!0}),ht(()=>I([n,o])))})};var sn={};ps(sn,{DefaultChunkSize:()=>Jq,Do:()=>Ase,TypeId:()=>Vq,accumulate:()=>pse,aggregate:()=>sse,aggregateWithin:()=>bk,as:()=>Ine,bind:()=>Rse,bindEffect:()=>Ose,bindTo:()=>_se,broadcast:()=>Ez,broadcastN:()=>ise,buffer:()=>doe,bufferArray:()=>poe,callback:()=>Mb,catch:()=>gh,catchCause:()=>az,catchCauseFilter:()=>Toe,catchCauseIf:()=>Ioe,catchDefect:()=>moe,catchFilter:()=>yk,catchIf:()=>uz,catchReason:()=>Soe,catchReasons:()=>boe,catchTag:()=>goe,catchTags:()=>yoe,changes:()=>Iz,changesWith:()=>Tz,changesWithEffect:()=>mse,chunks:()=>xz,collect:()=>dse,combine:()=>joe,combineArray:()=>qoe,concat:()=>df,cross:()=>Kne,crossWith:()=>sz,debounce:()=>Goe,decodeText:()=>hse,die:()=>ine,drain:()=>_ne,drainFork:()=>Pne,drop:()=>Sk,dropRight:()=>Boe,dropUntil:()=>Uoe,dropUntilEffect:()=>Doe,dropWhile:()=>mz,dropWhileEffect:()=>hz,dropWhileFilter:()=>Loe,empty:()=>Gs,encodeText:()=>xse,ensuring:()=>yh,fail:()=>wc,failCause:()=>Qq,failCauseSync:()=>ane,failSync:()=>sne,filter:()=>hk,filterEffect:()=>ioe,filterMap:()=>soe,filterMapEffect:()=>aoe,flatMap:()=>yd,flatten:()=>rz,flattenArray:()=>One,flattenEffect:()=>wne,flattenIterable:()=>Lne,flattenTake:()=>Bne,forever:()=>Dne,fromArray:()=>hh,fromArrayEffect:()=>lne,fromArrays:()=>dne,fromAsyncIterable:()=>pne,fromChannel:()=>U,fromEffect:()=>Pb,fromEffectDrain:()=>Gq,fromEffectRepeat:()=>Zq,fromEffectSchedule:()=>tne,fromEventListener:()=>xne,fromIterable:()=>pf,fromIterableEffect:()=>une,fromIterableEffectRepeat:()=>fne,fromIteratorSucceed:()=>cne,fromPubSub:()=>fk,fromPubSubTake:()=>Yq,fromPull:()=>Li,fromQueue:()=>xh,fromReadableStream:()=>lk,fromSchedule:()=>mne,fromSubscription:()=>hne,groupAdjacentBy:()=>nse,groupBy:()=>tse,groupByKey:()=>rse,grouped:()=>Xoe,groupedWithin:()=>ese,haltWhen:()=>Ese,ignore:()=>Aoe,ignoreCause:()=>koe,interleave:()=>Sse,interleaveWith:()=>vz,interruptWhen:()=>bse,intersperse:()=>wz,intersperseAffixes:()=>yse,isStream:()=>Ae,iterate:()=>yne,let:()=>kse,limitBytes:()=>Poe,make:()=>nne,map:()=>ao,mapAccum:()=>zoe,mapAccumArray:()=>hf,mapAccumArrayEffect:()=>Koe,mapAccumEffect:()=>Woe,mapArray:()=>ez,mapArrayEffect:()=>vne,mapBoth:()=>Tne,mapEffect:()=>mf,mapError:()=>fz,merge:()=>dk,mergeAll:()=>Wne,mergeEffect:()=>Fb,mergeLeft:()=>qne,mergeResult:()=>jne,mergeRight:()=>zne,mkArrayBuffer:()=>jse,mkString:()=>Hse,mkUint8Array:()=>qse,never:()=>bne,onEnd:()=>Tse,onError:()=>Ise,onExit:()=>Cz,onFirst:()=>kz,onStart:()=>Az,orDie:()=>Coe,orElseIfEmpty:()=>woe,orElseSucceed:()=>voe,paginate:()=>gne,partition:()=>uoe,partitionEffect:()=>coe,partitionQueue:()=>xk,peel:()=>loe,pipeThrough:()=>lse,pipeThroughChannel:()=>use,pipeThroughChannelOrFail:()=>fse,prepend:()=>Hne,provide:()=>Rz,provideContext:()=>Ek,provideService:()=>wse,provideServiceEffect:()=>Ik,race:()=>ooe,raceAll:()=>iz,range:()=>Sne,rechunk:()=>gz,repeat:()=>Mne,repeatElements:()=>Une,result:()=>Cne,retry:()=>Roe,run:()=>Pse,runCollect:()=>_z,runCount:()=>Mse,runDrain:()=>Ub,runFold:()=>Nse,runFoldEffect:()=>Use,runForEach:()=>Bse,runForEachArray:()=>Sd,runForEachWhile:()=>$se,runHead:()=>Dse,runIntoPubSub:()=>Vse,runIntoQueue:()=>Zse,runLast:()=>Lse,runSum:()=>Fse,scan:()=>Voe,scanEffect:()=>Joe,schedule:()=>Fne,scoped:()=>Ene,service:()=>Xre,serviceOption:()=>ene,share:()=>cse,sliding:()=>$oe,slidingSize:()=>yz,split:()=>Hoe,splitLines:()=>gse,succeed:()=>lf,suspend:()=>vn,switchMap:()=>Rne,sync:()=>one,take:()=>_oe,takeRight:()=>Moe,takeUntil:()=>lz,takeUntilEffect:()=>dz,takeWhile:()=>pz,takeWhileEffect:()=>Noe,takeWhileFilter:()=>Foe,tap:()=>tz,tapBoth:()=>Ane,tapCause:()=>cz,tapDefect:()=>xoe,tapError:()=>gk,tapErrorTag:()=>hoe,tapSink:()=>kne,throttle:()=>Yoe,throttleEffect:()=>Sz,tick:()=>rne,timeout:()=>Nne,timeoutOrElse:()=>nz,toAsyncIterable:()=>Kse,toAsyncIterableEffect:()=>Wse,toAsyncIterableWith:()=>Ck,toChannel:()=>cs,toPubSub:()=>Jse,toPubSubTake:()=>Pz,toPull:()=>Tk,toQueue:()=>Gse,toReadableStream:()=>zse,toReadableStreamEffect:()=>vk,toReadableStreamWith:()=>wk,transduce:()=>ose,transformPull:()=>br,transformPullBracket:()=>uk,unfold:()=>Xq,unwrap:()=>Cn,unwrapReason:()=>Eoe,updateContext:()=>Oz,updateService:()=>vse,when:()=>foe,withExecutionPlan:()=>Ooe,withSpan:()=>Cse,zip:()=>Jne,zipFlatten:()=>Qne,zipLatest:()=>roe,zipLatestAll:()=>mk,zipLatestWith:()=>noe,zipLeft:()=>Gne,zipRight:()=>Zne,zipWith:()=>pk,zipWithArray:()=>Nb,zipWithIndex:()=>Yne,zipWithNext:()=>Xne,zipWithPrevious:()=>eoe,zipWithPreviousAndNext:()=>toe});var Uq="~effect/RcMap",Wre=e=>({[Uq]:Uq,lookup:e.lookup,context:e.context,scope:e.scope,idleTimeToLive:e.idleTimeToLive,capacity:e.capacity,state:{_tag:"Open",map:Si()},pipe(){return V(this,arguments)}}),Dq=e=>ar(t=>{let r=t.context,n=Re(r,it),o=Wre({lookup:e.lookup,context:r,scope:n,idleTimeToLive:typeof e.idleTimeToLive=="function"?Lc(e.idleTimeToLive,$e):qe($e(e.idleTimeToLive??Gi)),capacity:Math.max(e.capacity??Number.POSITIVE_INFINITY,0)});return Ot(Wo(n,()=>{if(o.state._tag==="Closed")return P;let s=o.state.map;return o.state={_tag:"Closed"},Ko(s,([,i])=>eo(dh(i))).pipe(Rt(()=>W(()=>{Xg(s)})))}),o)}),ik=d(2,(e,t)=>en(r=>{if(e.state._tag==="Closed")return Dn;let n=e.state,o=os(),s=Qr(n.map,t),i;if(s._tag==="Some")i=s.value,i.refCount++;else{if(Number.isFinite(e.capacity)&&bU(e.state.map)>=e.capacity)return D(new yN(`RcMap attempted to exceed capacity of ${e.capacity}`));{i={deferred:uu(),scope:Zn(),idleTimeToLive:e.idleTimeToLive(t),finalizer:void 0,fiber:void 0,expiresAt:0,refCount:1},i.finalizer=Vre(e,t,i),bi(n.map,t,i);let c=new Map(e.context.mapUnsafe);o.context.mapUnsafe.forEach((f,p)=>{c.set(p,f)}),c.set(it.key,i.scope);let u=qn(c);L(()=>e.lookup(t)).pipe(Sr(u),Ni(i.scope)).addObserver(f=>{SN(f)&&Kre(e,t,i,u),hi(i.deferred,f)})}}let a=dn(o.context,it);return It(a,i.finalizer).pipe(Kt(r(Ng(i.deferred))))}));var Kre=(e,t,r,n)=>{if(e.state._tag==="Closed")return;let o=Qr(e.state.map,t);o._tag==="None"||o.value!==r||(Ei(e.state.map,t),!(r.refCount>0)&&dh(r).pipe(Sr(n),Ni(e.scope)))},dh=e=>e.fiber?Tn(e.fiber).pipe(Kt(Ve(e.scope,Wt))):Ve(e.scope,Wt),Vre=(e,t,r)=>ar(n=>{if(r.refCount--,r.refCount>0)return P;if(e.state._tag==="Closed")return dh(r);let o=Qr(e.state.map,t);if(o._tag==="None"||o.value!==r)return dh(r);if(Lf(r.idleTimeToLive))return Ei(e.state.map,t),dh(r);if(!Wn(r.idleTimeToLive))return P;let s=n.getRef(Yn);return r.expiresAt=s.currentTimeMillisUnsafe()+zt(r.idleTimeToLive),r.fiber?P:(r.fiber=en(function i(a){let c=s.currentTimeMillisUnsafe(),u=r.expiresAt-c;if(u<=0){if(e.state._tag==="Closed"||r.refCount>0)return P;let f=Qr(e.state.map,t);return f._tag==="None"||f.value!==r?P:(Ei(e.state.map,t),Ve(r.scope,Wt))}return A(a(s.sleep(Zi(u))),()=>i(a))}).pipe(wi(W(()=>{r.fiber=void 0})),Sr(n.context),Ni(e.scope)),P)});var ak=d(2,(e,t)=>yu(r=>{if(e.state._tag==="Closed")return P;let n=Qr(e.state.map,t);if(n._tag==="None"||Lf(n.value.idleTimeToLive))return P;let o=n.value;return o.expiresAt=r.currentTimeMillisUnsafe()+zt(o.idleTimeToLive),P}));var Jre="~effect/RcRef",ph={_tag:"Empty"},Gre={_tag:"Closed"},Zre={_A:F,_E:F},ck=class{[Jre]=Zre;pipe(){return V(this,arguments)}state=ph;acquire;context;scope;idleTimeToLive;constructor(t,r,n,o){this.acquire=t,this.context=r,this.scope=n,this.idleTimeToLive=o}},$q=e=>ar(t=>{let r=t.context,n=Re(r,it),o=new ck(e.acquire,r,n,e.idleTimeToLive!==void 0?$e(e.idleTimeToLive):void 0);return Ot(Wo(n,()=>{let s=o.state;return o.state=Gre,s._tag==="Acquired"?Ve(s.scope,Wt):s._tag==="Acquiring"?Tn(s.fiber):P}),o)}),Qre=(e,t)=>{switch(e.state._tag){case"Closed":return Dn;case"Acquired":{let r=e.state;return r.refCount++,r.fiber?Ot(Tn(r.fiber),r):I(r)}case"Acquiring":{let r=e.state;return r.awaiters++,Bq(e,r,t)}case"Empty":{let r={_tag:"Acquiring",fiber:void 0,awaiters:1,acquired:void 0};e.state=r;let n=Zn(),o=Ur(e.acquire,We(e.context,it,n)).pipe(A(s=>{if(e.state!==r)return Dn;let i={_tag:"Acquired",value:s,scope:n,fiber:void 0,refCount:r.awaiters,invalidated:!1};return e.state=i,r.acquired=i,I(i)}),Xr(s=>ft(s)?P:(e.state===r&&(e.state=ph),Ve(n,s))));return r.fiber=Sr(os().context)(o),Bq(e,r,t)}}},Bq=(e,t,r)=>Xr(r(bc(t.fiber)),n=>{let o=t.acquired;return o!==void 0?vs(n)?jq(e,o):P:--t.awaiters>0||e.state!==t?P:(e.state=ph,Tn(t.fiber))}),Hq=e=>{let t=e;return en(r=>A(Co,n=>A(Qre(t,r),o=>Ot(Wo(n,()=>jq(t,o)),o.value))))},jq=(e,t)=>{if(t.refCount--,t.refCount>0)return P;let r=e.idleTimeToLive;return r===void 0||t.invalidated?(e.state===t&&(e.state=ph),Ve(t.scope,Wt)):Wn(r)?(t.fiber=en(n=>A(n(ua(r)),()=>e.state===t&&t.refCount===0?(e.state=ph,Ve(t.scope,Wt)):P)).pipe(wi(W(()=>{t.fiber=void 0})),Sr(e.context),Ni(e.scope)),P):P};var qq=$q,zq=Hq;var Vq="~effect/Stream",Ae=e=>O(e,Vq),Jq=uh,U=Pq,Pb=e=>U(Ib(K(e,Me))),Xre=e=>Pb(G0(e)),ene=e=>Pb(xu(e)),Gq=e=>Li(I(A(e,()=>se()))),Zq=e=>Li(I(K(e,Me))),tne=(e,t)=>Li(xt(function*(){let r=yield*ks(t),n=yield*Go(e,Fr,Fr.defaultValue()),o=!0,s=L(()=>r(n)).pipe(A(i=>Go(e,Fr,i)),K(i=>(n=i,Me(i))));return L(()=>o?(o=!1,I(Me(n))):s)})),rne=e=>Li(W(()=>{let t=!0,r=I(Me(void 0)),n=ca(r,e);return L(()=>t?(t=!1,r):n)})),Li=e=>U(qr(e)),br=(e,t)=>U(De((r,n)=>A(as(e.channel,n),o=>t(o,n)))),uk=(e,t)=>U(Vs((r,n,o)=>A(as(e.channel,n),s=>t(s,n,o)))),cs=e=>e.channel,Mb=(e,t)=>U(bj(e,t)),Gs=U(hd),lf=e=>U(Eb(Me(e))),nne=(...e)=>hh(e),one=e=>U(Tj(()=>Me(e()))),vn=e=>U(bb(()=>e().channel)),wc=e=>U(Di(e)),sne=e=>U(vj(e)),Qq=e=>U(fh(e)),ine=e=>U(KA(e)),ane=e=>U(Cj(e)),cne=(e,t)=>U(WA(()=>e,t)),pf=(e,t)=>Array.isArray(e)&&t?.chunkSize===void 0?hh(e):U(Ij(e,t?.chunkSize)),une=e=>Cn(K(e,pf)),fne=e=>yd(Zq(e),pf),hh=e=>bt(e)?U(Eb(e)):Gs,lne=e=>Cn(K(e,hh)),dne=(...e)=>U(zA(Lx(e,bt))),xh=e=>U(kj(e)),fk=e=>U(Rj(e)),Yq=e=>U(Oj(e)),lk=e=>U(_j(e)),pne=(e,t)=>U(Pj(e,t)),mne=e=>Li(K(Np(e),t=>ht(K(t(void 0),Me),()=>se()))),hne=e=>U(JA(e)),xne=(e,t,r)=>Mb(n=>{let o=typeof r=="object"&&r.once;function s(i){Ic(n,i),o&&gb(n)}return Ti(W(()=>e.addEventListener(t,s,r)),()=>W(()=>e.removeEventListener(t,s,r)))},{bufferSize:typeof r=="object"?r.bufferSize:void 0}),Xq=(e,t)=>Li(W(()=>{let r=e;return A(L(()=>t(r)),n=>n===void 0?se():(r=n[1],I(Me(n[0]))))})),gne=(e,t)=>Li(W(()=>{let r=e,n=!1;return L(function o(){return n?se():A(t(r),([s,i])=>(fe(i)?n=!0:r=i.value,bt(s)?I(s):o()))})})),yne=(e,t)=>Xq(e,r=>I([r,t(r)])),Sne=(e,t,r=uh)=>e>t?Gs:Li(W(()=>{let n=Lo(r),o=e,s=!1;return L(()=>{if(s)return se();let i=t-o+1;if(i>n){let c=FI(o,o+n-1);return o+=n,I(c)}let a=FI(o,o+i-1);return s=!0,I(a)})})),bne=U(wj),Cn=e=>U(Tc(K(e,cs))),Ene=e=>U(dq(e.channel)),ao=d(2,(e,t)=>vn(()=>{let r=0;return U(Js(e.channel,Bo(n=>t(n,r++))))})),Ine=d(2,(e,t)=>ao(e,()=>t)),Tne=d(2,(e,t)=>e.pipe(ao(t.onElement),fz(t.onError))),ez=d(2,(e,t)=>U(Js(e.channel,t))),mf=d(e=>Ae(e[0]),(e,t,r)=>e.channel.pipe(wn,Tb(t,r),Js(Me),U)),wne=d(e=>Ae(e[0]),(e,t)=>mf(e,F,t)),vne=d(2,(e,t)=>U(Tb(e.channel,t))),Cne=e=>e.pipe(ao(X),gh(t=>lf(re(t)))),tz=d(e=>Ae(e[0]),(e,t,r)=>mf(e,n=>Ot(t(n),n),r)),Ane=d(2,(e,t)=>e.pipe(gk(t.onError),tz(t.onElement,{concurrency:t.concurrency}))),kne=d(2,(e,t)=>uk(e,me(function*(r,n,o){let s=Hr(),i=Hr(),a,c,u=!1,f=!1,p=s.whenOpen(L(()=>{if(a){let h=a;return a=void 0,f||s.closeUnsafe(),Ot(i.open,h)}return se()}));yield*L(()=>t.transform(p,o)).pipe(h=>Vp(h,x=>(u=!0,vs(x)&&(c=x.cause),i.open),!0),gt(o));let m=r.pipe(A(h=>c?He(c):u?I(h):(a=h,i.closeUnsafe(),s.openUnsafe(),Ot(i.await,h))),ht(()=>c?He(c):u?se():(f=!0,i.closeUnsafe(),s.openUnsafe(),A(i.await,()=>c?He(c):se()))));return L(()=>c?He(c):u?r:m)}))),yd=d(e=>Ae(e[0]),(e,t,r)=>e.channel.pipe(wn,GA(n=>t(n).channel,r),U)),Rne=d(e=>Ae(e[0]),(e,t,r)=>e.channel.pipe(wn,uq(n=>t(n).channel,r),U)),rz=d(e=>Ae(e[0]),(e,t)=>yd(e,F,t)),One=e=>U(wn(e.channel)),_ne=e=>U($j(e.channel)),Pne=d(2,(e,t)=>Fb(e,Ub(t))),Mne=d(2,(e,t)=>U(Hj(e.channel,t))),Fne=d(2,(e,t)=>e.channel.pipe(wn,zj(t),Js(Me),U)),Nne=d(2,(e,t)=>nz(e,{duration:t,orElse:()=>Gs})),nz=d(2,(e,t)=>{let r=$e(t.duration);if(!Wn(r))return e;if(Lf(r))return vn(t.orElse);let n=Symbol();return az(vn(()=>{let s=os().getRef(Yn),i=zt(r),a,c=Hr(!1);return dk(br(e,(u,f)=>L(()=>(a=s.currentTimeMillisUnsafe()+i,c.openUnsafe(),u)).pipe(K(p=>(c.closeUnsafe(),a=void 0,p)),I)),Gq(xt(function*(){for(;;)if(yield*c.await,!(a===void 0||(yield*ua(a-s.currentTimeMillisUnsafe()),a===void 0)||a-s.currentTimeMillisUnsafe()>0))return yield*gn(n)})),{haltStrategy:"left"})}),o=>o.reasons.find(i=>i._tag==="Die"&&i.defect===n)?t.orElse():Qq(o))}),Une=d(2,(e,t)=>U(De((r,n)=>K(we(wn(e.channel))(r,n),o=>{let s,i=xt(function*(){let a=yield*o,c=Me(a);return s=(yield*Np(t))(a).pipe(Ot(c),ht(f=>(s=void 0,i))),c});return L(()=>s??i)})))),Dne=e=>U(qj(e.channel)),Lne=e=>yd(e,pf),Bne=e=>e.channel.pipe(wn,Bj,U),df=d(2,(e,t)=>{let r=U(Lj(Ej(()=>$ne(e,t))));return oz.set(r,[e,t]),r}),oz=new WeakMap;function*$ne(e,t){let r=[t,e];for(;r.length>0;){let n=r.pop(),o=oz.get(n);o===void 0?yield n.channel:r.push(o[1],o[0])}}var Hne=d(2,(e,t)=>df(pf(t),e)),dk=d(e=>Ae(e[0])&&Ae(e[1]),(e,t,r)=>U(Ab(cs(e),cs(t),r))),Fb=d(2,(e,t)=>e.channel.pipe(fq(t),U)),jne=d(2,(e,t)=>dk(ao(e,X),ao(t,re))),qne=d(2,(e,t)=>Fb(e,Ub(t))),zne=d(2,(e,t)=>Fb(t,Ub(e))),Wne=d(2,(e,t)=>rz(pf(e),t)),Kne=d(2,(e,t)=>sz(e,t,(r,n)=>[r,n])),sz=d(3,(e,t,r)=>yd(e,n=>ao(t,o=>r(n,o)))),pk=d(3,(e,t,r)=>Nb(e,t,Vne(r))),Vne=e=>(t,r)=>{let n=Math.min(t.length,r.length),o=[];for(let s=0;s<n;s++)o.push(e(t[s],r[s]));return[o,t.slice(n),r.slice(n)]},Nb=d(3,(e,t,r)=>U(Vs(me(function*(n,o){let s=yield*as(e.channel,o),i=yield*as(t.channel,o),a=xt(function*(){let f=yield*gt(s,o),p=yield*gt(i,o);return yield*ZS([f,p])}),c={_tag:"PullBoth"};return xt(function*(){let[f,p]=c._tag==="PullBoth"?yield*a:c._tag==="PullLeft"?[yield*s,c.rightArray]:[c.leftArray,yield*i],m=r(f,p);return bt(m[1])?c={_tag:"PullRight",leftArray:m[1]}:bt(m[2])?c={_tag:"PullLeft",rightArray:m[2]}:c={_tag:"PullBoth"},m[0]})})))),Jne=d(2,(e,t)=>pk(e,t,(r,n)=>[r,n])),Gne=d(2,(e,t)=>Nb(e,t,(r,n)=>{let o=Math.min(r.length,n.length),s=r.slice(0,o),i=r.slice(o),a=n.slice(o);return[s,i,a]})),Zne=d(2,(e,t)=>Nb(e,t,(r,n)=>{let o=Math.min(r.length,n.length),s=n.slice(0,o),i=r.slice(o),a=n.slice(o);return[s,i,a]})),Qne=d(2,(e,t)=>pk(e,t,(r,n)=>[...r,n])),Yne=e=>ao(e,(t,r)=>[t,r]),Xne=e=>hf(e,_,(t,r)=>{let n=0;t._tag==="None"&&(n=1,t=N(r[0]));let o=Qt();for(;n<r.length;n++){let s=t.value;t=N(r[n]),o.push([s,t])}return[t,o]},{onHalt(t){return t._tag==="Some"?[[t.value,_()]]:[]}}),eoe=e=>hf(e,_,(t,r)=>{let n=Qt();for(let o=0;o<r.length;o++){let s=r[o];n.push([t,s]),t=N(r[o])}return[t,n]}),toe=e=>hf(e,()=>({prev:_(),current:_()}),(t,r)=>{let n=0,o;t.current._tag==="None"?(n=1,o=r[0],t.current=N(o)):o=t.current.value;let s=Qt();for(;n<r.length;n++){let i=r[n];t.current=N(i),s.push([t.prev,o,t.current]),t.prev=N(o),o=i}return[t,s]},{onHalt(t){return t.current._tag==="Some"?[[t.prev,t.current.value,_()]]:[]}}),mk=(...e)=>U(bb(()=>{let t=[],r=new Set,n=Hr(),o=Hr();return Cb(zA(e.map((s,i)=>s.channel.pipe(wn,Tb(a=>(t[i]=a,r.has(i)?I(Me(t.slice())):(r.add(i),r.size<e.length?n.await:Ot(n.open,Me(t.slice()))))),Wj(ei),Mj(()=>r.has(i)?P:o.open)))),{concurrency:"unbounded",bufferSize:0}).pipe(XA(o.await))})),roe=d(2,(e,t)=>mk(e,t)),noe=d(3,(e,t,r)=>ao(mk(e,t),([n,o])=>r(n,o))),iz=(...e)=>U(De((t,r)=>W(()=>{let n,o=z0(e.map(s=>{let i=yr(r);return as(s.channel,i).pipe(A(a=>B0(I(a),a)),Xr(a=>a._tag==="Success"?n?Ve(i,a):(n=a.value[0],P):Ve(i,a)),K(([,a])=>a))}));return L(()=>n??o)}))),ooe=d(2,(e,t)=>iz(e,t)),hk=d(2,(e,t)=>U(Kj(cs(e),t))),soe=d(2,(e,t)=>U(Vj(cs(e),t))),ioe=d(2,(e,t)=>U(Jj(cs(e),t))),aoe=d(2,(e,t)=>U(Gj(cs(e),t))),xk=d(e=>Ae(e[0]),me(function*(e,t,r){let n=yield*Co,o=yield*as(e.channel,n),s=r?.capacity==="unbounded"?void 0:r?.capacity??Jq,i=yield*io({capacity:s}),a=yield*io({capacity:s});return yield*xt(function*(){for(;;){let c=yield*o,u=[],f=[];for(let m=0;m<c.length;m++){let h=t(c[m]);be(h)?u.push(h.failure):f.push(h.success)}let p;if(f.length>0){let m=xb(i,f);m.length>0&&(p=yield*gl(wa(i,m)))}if(u.length>0){let m=xb(a,u);m.length>0&&(yield*wa(a,m))}p&&(yield*bc(p))}}).pipe(to(c=>(Ui(i,c),Ui(a,c),P)),gt(n)),[i,a]})),mh=e=>U(De((t,r)=>Ot(It(r,ss(e)),of(e)))),coe=d(e=>Ae(e[0]),(e,t,r)=>K(xk(mf(e,n=>t(n),r),n=>n,r),([n,o])=>[mh(n),mh(o)])),uoe=d(e=>Ae(e[0]),(e,t,r)=>K(xk(e,t,{capacity:r?.capacity??16}),([n,o])=>[mh(n),mh(o)])),foe=d(2,(e,t)=>t.pipe(K(r=>r?e:Gs),Cn)),loe=d(2,me(function*(e,t){let r,n=yield*nk(e.channel),o=rt(n,c=>(r=c,He(c))),[s,i]=yield*hl(c=>t.transform(o,c)),a=r?Gs:Li(I(n));return i&&(a=df(hh(i),a)),[s,a]})),doe=d(2,(e,t)=>U(mq(e.channel,t))),poe=d(2,(e,t)=>U(pq(e.channel,t))),az=d(2,(e,t)=>e.channel.pipe(gd(r=>t(r).channel),U)),moe=d(2,(e,t)=>e.channel.pipe(Qj(r=>t(r).channel),U)),cz=d(2,(e,t)=>e.channel.pipe(wb(t),U)),gh=d(2,(e,t)=>U(Ks(e.channel,r=>t(r).channel)));var gk=d(2,(e,t)=>e.channel.pipe(Xj(t),U)),hoe=d(3,(e,t,r)=>{let n=Array.isArray(t)?o=>O(o,"_tag")&&t.includes(o._tag):Or(t);return gk(e,o=>n(o)?r(o):P)}),xoe=d(2,(e,t)=>cz(e,r=>{let n=Cp(r);return tt(n)?t(n.success):P})),uz=d(e=>Ae(e[0]),(e,t,r,n)=>U(eq(cs(e),t,o=>r(o).channel,n&&(o=>n(o).channel)))),yk=d(e=>Ae(e[0]),(e,t,r,n)=>U(tq(cs(e),t,o=>r(o).channel,n&&(o=>n(o).channel)))),goe=d(e=>Ae(e[0]),(e,t,r,n)=>{let o=Array.isArray(t)?s=>O(s,"_tag")&&t.includes(s._tag):Or(t);return uz(e,o,r,n)}),yoe=d(e=>Ae(e[0]),(e,t,r)=>{let n;return yk(e,o=>(n??=Object.keys(t),O(o,"_tag")&&Gg(o._tag)&&n.includes(o._tag)?X(o):re(o)),o=>t[o._tag](o),r)}),Soe=d(e=>Ae(e[0]),(e,t,r,n,o)=>U(rq(cs(e),t,r,(s,i)=>n(s,i).channel,o&&((s,i)=>o(s,i).channel)))),boe=d(e=>Ae(e[0]),(e,t,r,n)=>{let o=Object.create(null);for(let i of Object.keys(r)){let a=r[i];o[i]=(c,u)=>a(c,u).channel}let s=n&&((i,a)=>n(i,a).channel);return U(nq(e.channel,t,o,s))}),Eoe=d(2,(e,t)=>yk(e,r=>Or(r,t)&&O(r,"reason")?X(r.reason):re(r),wc)),fz=d(2,(e,t)=>U(oq(e.channel,t))),Ioe=d(3,(e,t,r)=>U(Yj(e.channel,t,n=>r(n).channel))),Toe=d(3,(e,t,r)=>U(vb(e.channel,t,(n,o)=>r(n,o).channel))),woe=d(2,(e,t)=>U(Dj(e.channel,r=>cs(t())))),voe=d(2,(e,t)=>gh(e,r=>lf(t(r)))),Coe=e=>U(sq(e.channel)),Aoe=d(e=>Ae(e[0]),(e,t)=>U(iq(e.channel,t))),koe=d(e=>Ae(e[0]),(e,t)=>U(aq(e.channel,t))),Roe=d(2,(e,t)=>U(cq(e.channel,t))),Kq=(e,t)=>Cn(K(ks(t),r=>{let n=Fr.defaultValue(),o=()=>gh(Ik(e,Fr,W(()=>n)),s=>Cn(ht(K(r(s),i=>(n=i,Cn(Ot(zp,o())))),()=>I(wc(s)))));return o()})),Ooe=d(e=>Ae(e[0]),(e,t,r)=>vn(()=>{let n=r?.preventFallbackOnPartialStream??!1,o=0,s={attempt:0,stepIndex:0},i=Ik(Qg,W(()=>(s={attempt:s.attempt+1,stepIndex:o},s))),a=r?.onEvent===void 0?void 0:_0(r.onEvent,()=>s),c,u=a===void 0?F:m=>Cz(Az(m,K(a.begin,h=>{c=h})),h=>L(()=>{if(c===void 0)return P;let x=c;return c=void 0,a.end(x,h)})),f=_(),p=vn(()=>{let m=t.steps[o];if(!m)return wc(vI(f));let h=i(u(Rz(e,m.provide))),x=!1;if(de(f)){let g=f.value,y=!1,E=h;h=vn(()=>y?E:(y=!0,wc(g))),h=Kq(h,$p(m,!1))}else{let g=$p(m,!0);h=g?Kq(h,g):h}return gh(n?kz(h,g=>(x=!0,P)):h,g=>(o++,n&&x?wc(g):(f=N(g),p)))});return p})),_oe=d(2,(e,t)=>{let r=Dt(t);return r===0?Gs:lz(e,(n,o)=>o===r-1)}),Poe=d(3,(e,t,r)=>vn(()=>{let n=dy(t),o=BigInt(0),s=!1;return df(pz(e,i=>{let a=o+BigInt(i.length);return a>n?(s=!0,!1):(o=a,!0)}),vn(()=>s?r():Gs))})),Moe=d(2,(e,t)=>{let r=Dt(t);return r===0?Gs:hf(e,Ta,(n,o)=>(YS(n,o),n.length>r&&eb(n,n.length-r),[n,va]),{onHalt(n){return Ec(n)}})}),lz=d(e=>Ae(e[0]),(e,t,r)=>br(e,(n,o)=>W(()=>{let s=0,i=!1;return A(L(()=>i?se():n),c=>{let u=c.findIndex(f=>t(f,s++));if(u>=0){i=!0;let f=c.slice(0,r?.excludeLast?u:u+1);return bt(f)?I(f):se()}return I(c)})}))),dz=d(e=>Ae(e[0]),(e,t,r)=>br(e,(n,o)=>W(()=>{let s=0,i=!1;return xt(function*(){if(i)return yield*se();let a=yield*n;for(let c=0;c<a.length;c++)if(yield*t(a[c],s++)){i=!0;let u=a.slice(0,r?.excludeLast?c:c+1);return bt(u)?u:yield*se()}return a})}))),pz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=0,s=!1,i=A(L(()=>s?se():r),a=>{let c=[];for(let u=0;u<a.length;u++){if(!t(a[u],o++)){s=!0;break}c.push(a[u])}return bt(c)?I(c):s?se():i});return i}))),Foe=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!1,s=A(L(()=>o?se():r),i=>{let a=[];for(let c=0;c<i.length;c++){let u=t(i[c]);if(be(u)){o=!0;break}a.push(u.success)}return bt(a)?I(a):o?se():s});return s}))),Noe=d(2,(e,t)=>dz(e,(r,n)=>K(t(r,n),o=>!o),{excludeLast:!0})),Sk=d(2,(e,t)=>{let r=Dt(t);return r===0?e:br(e,(n,o)=>W(()=>{let s=0,i=n.pipe(A(a=>s>=r?I(a):(s+=a.length,s<=r?i:I(a.slice(r-s)))));return i}))}),Uoe=d(2,(e,t)=>Sk(mz(e,(r,n)=>!t(r,n)),1)),Doe=d(2,(e,t)=>Sk(hz(e,(r,n)=>K(t(r,n),o=>!o)),1)),mz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s=0,i=A(r,a=>{let c=a.findIndex(u=>!t(u,s++));return c===-1?i:(o=!1,I(a.slice(c)))});return L(()=>o?i:r)}))),Loe=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s=A(r,i=>{let a=i.findIndex(c=>be(t(c)));return a===-1?s:(o=!1,I(i.slice(a)))});return L(()=>o?s:r)}))),hz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s=0,i=xt(function*(){for(;;){let a=yield*r;for(let c=0;c<a.length;c++)if(!(yield*t(a[c],s++)))return o=!1,a.slice(c)}});return L(()=>o?i:r)}))),Boe=d(2,(e,t)=>{let r=Dt(t);return r===0?e:br(e,(n,o)=>W(()=>{let s=Ta(),i=A(n,a=>{XS(s,a);let c=s.length-r,u=tf(s,c);return Jr(u)?I(u):i});return i}))}),xz=e=>e.channel.pipe(Js(Me),U),gz=d(2,(e,t)=>(t=Lo(t),br(e,(r,n)=>W(()=>{let o=Qt(),s=0,i,a=!1;return L(function c(){if(a)return se();if(i===void 0)return A(r,u=>{if(o.length===0&&u.length===t)return I(u);if(o.length+u.length<t){for(let f=0;f<u.length;f++)o.push(u[f]);return c()}return i=u,c()});for(;s<i.length;)if(o.push(i[s++]),o.length===t){let u=o;return o=[],I(u)}return s=0,i=void 0,c()}).pipe(ht(()=>{if(o.length===0)return se();let c=o;return a=!0,o=[],I(c)}))})))),$oe=d(2,(e,t)=>yz(e,t,1)),yz=d(3,(e,t,r)=>{let n=Lo(t),o=Lo(r);return br(e,(s,i)=>W(()=>{let a=null,c=Ta(),u=!1,f=0,p=Un(s,{onSuccess(m){if(XS(c,m),f>0){let x=c.length;eb(c,f),f=Math.max(0,f-x)}if(c.length<n)return p;u=!0;let h=[];for(;c.length>=n;)if(n===o)h.push(tf(c,n));else{h.push(ej(c,n));let x=c.length;eb(c,o),f=Math.max(0,o-x)}return I(h)},onFailure(m){return c.length===0||u&&c.length<=n-o?He(m):(a=m,I(Me(Ec(c))))}});return L(()=>a?He(a):p)}))}),Hoe=d(2,(e,t)=>hf(e,Qt,(r,n)=>{let o=Qt();for(let s=0;s<n.length;s++)t(n[s])?Jr(r)&&(o.push(r),r=[]):r.push(n[s]);return[r,o]},{onHalt(r){return Jr(r)?Me(r):va}})),joe=d(4,(e,t,r,n)=>ZA(wn(e.channel),wn(t.channel),r,n).pipe(Js(Me),U)),qoe=d(4,(e,t,r,n)=>U(ZA(e.channel,t.channel,r,n))),zoe=d(e=>Ae(e[0]),(e,t,r,n)=>U(xd(e.channel,t,(o,s)=>{let i=Qt();for(let a=0;a<s.length;a++){let[c,u]=r(o,s[a]);o=c,i.push(...u)}return[o,Jr(i)?Me(i):va]},n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0))),hf=d(e=>Ae(e[0]),(e,t,r,n)=>U(xd(e.channel,t,(o,s)=>{let[i,a]=r(o,s);return o=i,[o,bt(a)?Me(a):va]},n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0))),va=Qt(),Woe=d(e=>Ae(e[0]),(e,t,r,n)=>e.channel.pipe(wn,xd(t,(o,s)=>K(r(o,s),([i,a])=>[i,bt(a)?Me(a):Qt()]),n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0),U)),Koe=d(e=>Ae(e[0]),(e,t,r,n)=>e.channel.pipe(xd(t,(o,s)=>K(r(o,s),([i,a])=>[i,bt(a)?Me(a):va]),n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0),U)),Voe=d(3,(e,t,r)=>vn(()=>{let n=t();return df(lf(n),U(xd(e.channel,()=>n,(o,s)=>{let i=Qt();for(let a=0;a<s.length;a++)o=r(o,s[a]),i.push(o);return[o,Me(i)]})))})),Joe=d(3,(e,t,r)=>vn(()=>e.channel.pipe(wn,Zj(t(),r),Js(Me),U))),Goe=d(2,(e,t)=>br(e,me(function*(r,n){let o=yield*Yn,s=zt($e(t)),i,a,c=1/0,u=Hr(),f=Hr(),p=Hr();yield*r.pipe(u.whenOpen,A(h=>(f.openUnsafe(),i=h,c=o.currentTimeMillisUnsafe()+s,P)),_t({disableYield:!0}),to(h=>(a=h,c=o.currentTimeMillisUnsafe(),f.openUnsafe(),p.openUnsafe(),P)),gt(n));let m=L(function h(){let x=o.currentTimeMillisUnsafe(),g=c<x?s:Math.min(s,c-x);return A(Ya(ua(g),p.await),()=>{if(o.currentTimeMillisUnsafe()<c)return h();if(i){f.closeUnsafe(),u.closeUnsafe();let E=I(Me(Df(i)));return i=void 0,E}else if(a)return He(a);return h()})});return L(()=>{if(a){if(i){let h=I(Me(Df(i)));return i=void 0,h}return He(a)}return u.openUnsafe(),f.whenOpen(m)})}))),Sz=d(2,(e,t)=>{let r=t.burst??0;return t.strategy==="enforce"?Zoe(e,t.cost,t.units,t.duration,r):Qoe(e,t.cost,t.units,t.duration,r)}),Zoe=(e,t,r,n,o)=>br(e,s=>yu(i=>{let a=zt($e(n)),c=r+o<0?Number.POSITIVE_INFINITY:r+o,u=r,f=i.currentTimeMillisUnsafe();return I(A(s,function p(m){return A(t(m),h=>{let x=i.currentTimeMillisUnsafe(),y=(x-f)/a,E=u+y*r,b=E<0?c:Math.min(E,c);return h<=b?(u=b-h,f=x,I(m)):A(s,p)})}))})),Qoe=(e,t,r,n,o)=>br(e,s=>yu(i=>{let a=zt($e(n)),c=r+o<0?Number.POSITIVE_INFINITY:r+o,u=r,f=i.monotonicTimeNanosUnsafe();return I(A(s,p=>A(t(p),m=>{let h=i.monotonicTimeNanosUnsafe(),g=Number(h-f)/1e6/a,y=u+g*r,b=Math.min(y,c)-m;if(b>=0)return u=b,f=h,I(p);let v=-b/r,T=Math.max(0,v*a);return T>0?A(ua(T),()=>(u=b,f=h,I(p))):(u=b,f=h,I(p))})))})),Yoe=d(2,(e,t)=>Sz(e,{...t,cost:r=>I(t.cost(r))})),Xoe=d(2,(e,t)=>xz(gz(e,t))),ese=d(3,(e,t,r)=>bk(e,Fq(Lo(t)),ll(r))),tse=d(e=>Ae(e[0]),(e,t,r)=>bz(e,me(function*(n,o,s){for(let i=0;i<n.length;i++){let[a,c]=yield*t(n[i]),u=Qr(s,a),f=de(u)?u.value:yield*ec(ik(o,a));yield*ak(o,a),yield*Hn(f,c)}}),r)),rse=d(e=>Ae(e[0]),(e,t,r)=>vn(()=>{let n=Si();return bz(e,me(function*(o,s,i){for(let a=0;a<o.length;a++){let c=t(o[a]),u=Qr(n,c);fe(u)?bi(n,c,[o[a]]):u.value.push(o[a])}for(let[a,c]of n){let u=Qr(i,a),f=de(u)?u.value:yield*ec(ik(s,a));yield*ak(s,a),yield*wa(f,c)}Xg(n)}),r)})),bz=(e,t,r)=>uk(e,me(function*(n,o,s){let i=yield*hb();yield*It(o,ss(i));let a=Si(),c=yield*Dq({lookup:u=>Ti(io({capacity:r?.bufferSize??4096}).pipe(Rt(f=>(bi(a,u,f),Hn(i,[u,mh(f)])))),f=>(Ei(a,u),md(f))),idleTimeToLive:r?.idleTimeToLive??Ss}).pipe(zo(s));return yield*xn({while:nr,body:qe(A(n,u=>t(u,c,a))),step:Rr}).pipe(rt(u=>$t(i,u)),gt(o)),of(i)})),nse=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o,s,i=Qt(),a=r.pipe(A(u=>{for(let f=0;f<u.length;f++){let p=u[f],m=t(p);if(s===void 0){o=m,s=[p];continue}else if(Z(m,o)){s.push(p);continue}i.push([o,s]),o=m,s=[p]}if(Jr(i)){let f=i;return i=[],I(f)}return a})),c=!1;return ht(L(()=>c?se():a),()=>{c=!0;let u=s;return s=void 0,u&&Jr(u)?I(Me([o,u])):se()})}))),ose=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o,s,i=L(()=>{if(s!==void 0){let c=s;return s=void 0,I(c)}return r}).pipe(hu(c=>(o=Gn(c),se()))),a=K(L(()=>t.transform(i,n)),([c,u])=>(s=u,Me(c)));return L(()=>o||a)}))),sse=d(2,(e,t)=>bk(e,t,Dp)),bk=d(3,(e,t,r)=>U(Vs(me(function*(n,o,s){let i=yield*as(e.channel,o),a=Hr(!1),c=Symbol(),u=yield*io({capacity:0});yield*i.pipe(a.whenOpen,A(S=>(a.closeUnsafe(),Hn(u,S))),_t,rt(S=>$t(u,S)),gt(s));let f=yield*Yn,p=yield*Qa(r),m=Hr(!1),h=f.currentTimeMillisUnsafe(),x=0,g=_(),y,E=S=>(m.openUnsafe()&&(x=f.currentTimeMillisUnsafe()),I(S)),b=m.await.pipe(A(()=>p(h,g)),A(([,S])=>ua(S)),A(()=>Hn(u,c)),ht(()=>md(u)),A(()=>Xn)),v=L(()=>{if(y!==void 0){let S=y;return y=void 0,E(S)}return u.state._tag==="Open"&&a.openUnsafe(),A(Ws(u),S=>S===c?se():E(S))}),T=A(([S,w])=>{if(m.isOpen())h+=f.currentTimeMillisUnsafe()-x;else if(u.state._tag==="Done")return se();return g=N(S),y=w,I(Me(S))});return L(()=>{if(u.state._tag==="Done"&&y===void 0)return u.state.exit;m.closeUnsafe();let S=T(L(()=>t.transform(v,s)));return u.state._tag==="Open"?Ya(S,b):S})})))),ise=d(2,me(function*(e,t){let r=Dt(t.n),n=yield*ase(t),o=new Array(r),s=yield*it;for(let i=0;i<r;i++){let a=yr(s),c=yield*ch(n).pipe(Go(it,a));o[i]=VA(lb(c)).pipe(lh(u=>Ve(a,u)),U)}return yield*uf(e.channel,i=>fb(n,i)).pipe(Xr(i=>ub(n,i)),Rs),o})),ase=e=>Ti(e.capacity==="unbounded"?ih(e):e.strategy==="dropping"?ab(e):e.strategy==="sliding"?cb(e):ib(e),ah),Ez=d(2,(e,t)=>K(Pz(e,t),Yq)),cse=d(2,(e,t)=>K(qq({acquire:Ez(e,t),idleTimeToLive:t.idleTimeToLive}),r=>Cn(zq(r)))),use=d(2,(e,t)=>U(QA(e.channel,t))),fse=d(2,(e,t)=>U(YA(e.channel,t))),lse=d(2,(e,t)=>e.channel.pipe(YA(Mq(t)),Uj(([r,n])=>n?Eb(n):hd),U)),dse=e=>Pb(_z(e)),pse=e=>hf(e,Qt,(t,r)=>{let n=ip(t,r);return[n,[n]]}),Iz=e=>Tz(e,Z),Tz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s;return A(r,function i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];t(f,s)||(s=f,c.push(f))}return Jr(c)?I(c):A(r,i)})}))),mse=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s;return A(r,me(function*i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];(yield*t(f,s))||(s=f,c.push(f))}return Jr(c)?c:yield*A(r,me(i))}))}))),hse=d(e=>Ae(e[0]),(e,t)=>vn(()=>{let r=new TextDecoder(t?.encoding);return ao(e,n=>r.decode(n,{stream:!0}))})),xse=e=>vn(()=>{let t=new TextEncoder;return ao(e,r=>t.encode(r))}),gse=e=>e.channel.pipe(QA(lq()),U),wz=d(2,(e,t)=>ez(e,(r,n)=>{let o=n===0?[]:[t],s=r.length-1;for(let i=0;i<r.length;i++)i===s?o.push(r[i]):o.push(r[i],t);return o})),yse=d(2,(e,t)=>lf(t.start).pipe(df(wz(e,t.middle)),df(lf(t.end)))),Sse=d(2,(e,t)=>vz(e,t,pf(j_([!0,!1])))),vz=d(3,(e,t,r)=>U(De(me(function*(n,o){let s=yield*we(wn(r.channel))(n,o),i=Symbol(),a=!1,c=!1,u=(yield*we(wn(e.channel))(n,o)).pipe(ht(()=>(a=!0,I(i)))),f=(yield*we(wn(t.channel))(n,o)).pipe(ht(()=>(c=!0,I(i))));return xt(function*(){for(;;){if(a&&c)return yield*se();let p=yield*s;if(p&&a||!p&&c)continue;let m=yield*p?u:f;if(m!==i)return Me(m)}})})))),bse=d(2,(e,t)=>U(XA(e.channel,t))),Ese=d(2,(e,t)=>U(hq(e.channel,t))),Cz=d(2,(e,t)=>U(lh(e.channel,t))),Ise=d(2,(e,t)=>U(xq(e.channel,t))),Az=d(2,(e,t)=>U(gq(e.channel,t))),kz=d(2,(e,t)=>U(ek(e.channel,r=>t(r[0])))),Tse=d(2,(e,t)=>U(yq(e.channel,t))),yh=d(2,(e,t)=>U(Sq(e.channel,t))),Rz=d(e=>Ae(e[0]),(e,t,r)=>U(bq(e.channel,t,r))),Ek=d(2,(e,t)=>U(kb(e.channel,t))),wse=d(3,(e,t,r)=>U(Rb(e.channel,t,r))),Ik=d(3,(e,t,r)=>U(Ob(e.channel,t,r))),Oz=d(2,(e,t)=>U(Eq(e.channel,t))),vse=d(3,(e,t,r)=>Oz(e,n=>We(n,t,r(Re(n,t))))),Cse=function(){let e=Ae(arguments[0]),t=e?arguments[1]:arguments[0],r=jo(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return U(tk(n.channel,t,r))}return n=>U(tk(n.channel,t,r))},Ase=lf({}),kse=d(3,(e,t,r)=>ao(e,n=>({...n,[t]:r(n)})));var Rse=d(e=>Ae(e[0]),(e,t,r,n)=>yd(e,o=>ao(r(o),s=>({...o,[t]:s})),n)),Ose=d(e=>Ae(e[0]),(e,t,r,n)=>mf(e,o=>K(r(o),s=>({...o,[t]:s})),n)),_se=d(2,(e,t)=>ao(e,r=>({[t]:r}))),Pse=d(2,(e,t)=>hl(r=>as(e.channel,r).pipe(A(n=>t.transform(n,r)),K(([n])=>n)))),_z=e=>ff(e.channel,()=>[],(t,r)=>{for(let n=0;n<r.length;n++)t.push(r[n]);return t}),Mse=e=>ff(e.channel,()=>0,(t,r)=>t+r.length),Fse=e=>ff(e.channel,()=>0,(t,r)=>{for(let n=0;n<r.length;n++)t+=r[n];return t}),Nse=d(3,(e,t,r)=>ff(e.channel,t,(n,o)=>{for(let s=0;s<o.length;s++)n=r(n,o[s]);return n})),Use=d(3,(e,t,r)=>Cq(e.channel,t,(n,o)=>{let s=0,i=n;return K(xn({while:()=>s<o.length,body:()=>r(i,o[s]),step(a){i=a,s++}}),()=>i)})),Dse=e=>K(wq(e.channel),Ut(Z_(0))),Lse=e=>K(vq(e.channel),Ut(Df)),Bse=d(2,(e,t)=>uf(e.channel,r=>{let n=0;return xn({while:()=>n<r.length,body:()=>t(r[n++]),step:Rr})})),$se=d(2,(e,t)=>Tq(e.channel,r=>{let n=!1,o=0;return K(xn({while:()=>!n&&o<r.length,body:()=>t(r[o]),step(s){o++,s||(n=!0)}}),()=>!n)})),Sd=d(2,(e,t)=>uf(e.channel,t)),Ub=e=>Iq(e.channel),Tk=e=>nk(e.channel),Hse=e=>ff(e.channel,()=>"",(t,r)=>t+r.join("")),jse=e=>K(rk(e.channel),t=>t.buffer),qse=e=>rk(e.channel),wk=d(e=>Ae(e[0]),(e,t,r)=>{let n,o,s=!1,i=Hr(!1),a=r?.signal,c=()=>o.interruptUnsafe();return new ReadableStream({start(u){o=Gp(Ur(Sd(e,f=>i.whenOpen(W(()=>{i.closeUnsafe();for(let p=0;p<f.length;p++)u.enqueue(f[p]);n(),n=void 0}))),t)),o.addObserver(f=>{a?.removeEventListener("abort",c),!s&&(f._tag==="Failure"&&a?.aborted!==!0?u.error(cu(f.cause)):u.close())}),a!==void 0&&o.pollUnsafe()===void 0&&(a.aborted?c():a.addEventListener("abort",c,{once:!0}))},pull(){return new Promise(u=>{n=u,i.openUnsafe()})},cancel(){if(o)return s=!0,tw(vo(Tn(o)))}},r?.strategy)}),zse=d(e=>Ae(e[0]),(e,t)=>wk(e,pt(),t)),vk=d(e=>Ae(e[0]),(e,t)=>K(Nr(),r=>wk(e,r,t))),Ck=d(2,(e,t)=>({[Symbol.asyncIterator](){let r=rw(t),n=Sr(t),o=Zn(),s,i,a,c,u=p=>{if(c)return c;let m=a;return c=r(Ot(Kt(m?Tn(m):P,Ve(o,p)),{done:!0,value:void 0})),c},f=async p=>{try{await u(p)}catch(m){await r(Zp("Suppressed error while closing Stream async iterator",m))}};return{async next(){if(c)return c;if(i){let h=i.next();if(!h.done)return h;i=void 0}let p=n(s??A(as(e.channel,o),h=>(s=h,h)));a=p;let m=await r(GH(p));if(a===p&&(a=void 0),ft(m))return i=m.value[Symbol.iterator](),i.next();if(wo(m.cause))return u(Wt);if(c&&o0(m.cause))return c;throw await f(m),cu(m.cause)},return(){return u(Wt)},async throw(p){throw await f(Mg(p)),p}}}})),Wse=e=>K(Nr(),t=>Ck(e,t)),Kse=e=>Ck(e,pt()),Vse=d(e=>Ae(e[0]),(e,t,r)=>sk(e.channel,t,r)),Jse=d(2,(e,t)=>Rq(e.channel,t)),Pz=d(2,(e,t)=>Oq(e.channel,t)),Gse=d(2,(e,t)=>Aq(e.channel,t)),Zse=d(2,(e,t)=>ok(e.channel,t));var Mz="~effect/PrimaryKey";var Nz="~effect/Pool",Bz=Symbol(),$z=Symbol(),kk=Symbol();var Hz=e=>qz({...e,min:e.size,max:e.size,strategy:Lb}),jz=e=>A(e.timeToLiveStrategy==="creation"?sie(e.timeToLive):iie(e.timeToLive),t=>qz({...e,strategy:t})),qz=e=>en(me(function*(t){let r=yield*Nr(),n=Re(r,it),o=Xa(e.acquire,u=>Kr(r,u)),s=e.concurrency??1,i={acquire:o,concurrency:s,isFixed:e.min===e.max,minSize:e.min,maxSize:e.max,strategy:e.strategy,targetUtilization:Math.min(Math.max(e.targetUtilization??1,.1),1)},a={scope:n,isShuttingDown:!1,usage:0,resizeSemaphore:af(1),items:new Set,availableHead:void 0,availableTail:void 0,invalidated:new Set,waiters:new Set},c={[Nz]:Nz,[Bz]:e.acquire,[$z]:r,[kk]:yield*Yn,config:i,state:a,pipe(){return V(this,arguments)}};return yield*It(n,Qse(c)),i.minSize>0&&(yield*Rt(yl(t(Db(c)),{startImmediately:!0}),u=>It(n,Tn(u)))),e.strategy!==Lb&&(yield*Rt(yl(t(e.strategy.run(c))),u=>It(n,Tn(u)))),c})),Qse=me(function*(e){if(e.state.isShuttingDown)return;e.state.isShuttingDown=!0;let t=e.state.items.size,r=af(t);for(let n of e.state.items)n.refCount>0?(n.finalizer=Rt(n.finalizer,r.release(1)),e.state.invalidated.add(n),yield*r.take(1)):(e.state.items.delete(n),Sh(e,n),e.state.invalidated.delete(n),yield*n.finalizer);if(e.state.waiters.size>0){let n=Array.from(e.state.waiters);e.state.waiters.clear();for(let o of n)o()}yield*r.take(t)}),Rk=e=>oe(t=>{let r=e.state;if(r.isShuttingDown)return Xf;if(r.availableHead?.exit._tag==="Success"){if(r.usage++,e.config.isFixed||bh(e)<=Eh(e))return zz(e,r.availableHead,t);r.usage--}return Yse(e,tie)});var Yse=(e,t)=>Jn(r=>{let n=e.state;n.usage++;let o=Y(bp(r(nie(e)),()=>ye(()=>{n.usage--})),()=>i),s=oe(a=>{if(n.isShuttingDown)return n.usage--,Xf;let c=Ok(e)??(bh(e)<=Eh(e)?n.availableHead:void 0);return c===void 0?o:c.exit._tag==="Failure"?(eie(e,c),i):t(e,c,a,r)}),i=ce(()=>n.isShuttingDown?(n.usage--,Xf):bh(e)>Eh(e)?Y(n.resizeSemaphore.withPermitsIfAvailable(1)(gt(vi(Db(e)),n.scope)),()=>s):s);return i}),Xse=(e,t)=>{t.refCount++,t.refCount>=e.config.concurrency&&Sh(e,t)},eie=(e,t)=>{e.state.items.delete(t),e.state.invalidated.delete(t),Sh(e,t)},zz=(e,t,r)=>{Xse(e,t);let n=dn(r.context,it);return n.state._tag==="Closed"?Wa(r,t.release):za(n,{},t.release),t.exit},tie=(e,t,r)=>zz(e,t,r),rie=(e,t)=>oe(r=>{let n=e.state;return t.refCount--,n.usage--,t.refCount===0&&(t.idleSince=e[kk].currentTimeMillisUnsafe()),n.invalidated.has(t)?Pk(e,t):(t.refCount<e.config.concurrency&&(oie(e,t),Wz(e,r,1)),pe)}),Ok=e=>{let t=e.state.availableHead;for(;t!==void 0&&t.exit._tag==="Failure";)t=t.availableNext;return t},nie=e=>Lt(t=>{let r=e.state;if(Ok(e)!==void 0||r.isShuttingDown)return t(pe);let n=o=>{r.waiters.delete(n),t(o??pe)};return r.waiters.add(n),ye(()=>{r.waiters.delete(n)})}),Wz=(e,t,r)=>{let n=e.state.waiters;n.size!==0&&t.currentDispatcher.scheduleTask(()=>{let o=r,s=[];for(let i of n){if(o--<=0)break;s.push(i)}for(let i=0;i<s.length;i++)s[i]()},0)},Uz=e=>oe(t=>(Wz(e,t,Number.POSITIVE_INFINITY),pe)),_k=new WeakMap,Dz=(e,t)=>{t.isAvailable||_k.has(t)||(t.isAvailable=!0,t.availablePrevious=e.state.availableTail,t.availableNext=void 0,e.state.availableTail!==void 0?e.state.availableTail.availableNext=t:e.state.availableHead=t,e.state.availableTail=t)},oie=(e,t)=>{t.isAvailable||_k.has(t)||(t.isAvailable=!0,t.availablePrevious=void 0,t.availableNext=e.state.availableHead,e.state.availableHead!==void 0?e.state.availableHead.availablePrevious=t:e.state.availableTail=t,e.state.availableHead=t)},Sh=(e,t)=>{t.isAvailable&&(t.isAvailable=!1,t.availablePrevious!==void 0?t.availablePrevious.availableNext=t.availableNext:e.state.availableHead=t.availableNext,t.availableNext!==void 0?t.availableNext.availablePrevious=t.availablePrevious:e.state.availableTail=t.availablePrevious,t.availablePrevious=void 0,t.availableNext=void 0)};var Pk=(e,t)=>L(()=>{if(e.state.items.has(t)){if(t.refCount===0)return e.state.items.delete(t),Sh(e,t),e.state.invalidated.delete(t),vo(A(t.finalizer,()=>gt(vi(Db(e)),e.state.scope,{startImmediately:!0})))}else return P;return e.state.invalidated.add(t),Sh(e,t),vo(gt(vi(Db(e)),e.state.scope,{startImmediately:!0}))}),Db=e=>e.state.resizeSemaphore.withPermits(1)(Ak(e)),Ak=e=>L(()=>{let t=Eh(e),r=bh(e);if(t>=r)return P;let n=r-t,o=e.config.strategy===Lb?Lz(e):A(e.config.strategy.reclaim(e),i=>i?I(i):Lz(e));if(n===1){let i=Rt(o,Uz(e));return e.config.isFixed?vo(i):A(i,a=>a.exit._tag==="Failure"?P:Ak(e))}let s=o.pipe(Q0(n,{concurrency:n}),Rt(Uz(e)));return e.config.isFixed?vo(s):A(s,i=>i.some(a=>a.exit._tag==="Failure")?P:Ak(e))}),Lz=e=>Jn(t=>oe(r=>{let n=e,o=Qf(),s=r.context;r.setContext(We(n[$z],it,o));let i=A(eo(n[Bz]),a=>{let c={exit:a,finalizer:rt(Ve(o,a),aie),refCount:0,idleSince:n[kk].currentTimeMillisUnsafe(),disableReclaim:!1,isAvailable:!1,availablePrevious:void 0,availableNext:void 0,release:void 0};c.release=qe(rie(e,c));let u=L(()=>e.state.items.has(c)?e.config.strategy.onAcquire(c):P);if(a._tag==="Success")return e.state.items.add(c),Dz(e,c),e.config.strategy===Lb?I(c):Ot(u,c);let f=Ok(e)===void 0?e.state.waiters.values().next().value:void 0;return f!==void 0?f(a):(e.state.items.add(c),Dz(e,c)),Ot(gt(Kt(c.finalizer,u),e.state.scope,{startImmediately:!0}),c)});return Io(t(i),a=>(r.setContext(s),a._tag==="Failure"?Zf(o,a):void 0),!0)})),bh=e=>{if(e.state.isShuttingDown)return 0;if(e.config.isFixed)return e.config.minSize;let t=e.state.usage/e.config.targetUtilization,r=Math.ceil(t/e.config.concurrency);return Math.min(Math.max(e.config.minSize,r),e.config.maxSize)},Eh=e=>e.state.items.size-e.state.invalidated.size,Lb={run:e=>P,onAcquire:e=>P,reclaim:e=>qp},sie=me(function*(e){let t=yield*Yn,r=yield*hb(),n=zt($e(e)),o=new WeakMap;return F({run:s=>{let i=a=>L(()=>{if(!s.state.items.has(a)||s.state.invalidated.has(a))return P;let c=t.currentTimeMillisUnsafe(),u=o.get(a),f=n-(c-u);return f>0?ca(i(a),f):Pk(s,a)});return Ws(r).pipe(Rt(i),_t({disableYield:!0}))},onAcquire:s=>L(()=>(o.set(s,t.currentTimeMillisUnsafe()),Hn(r,s))),reclaim:s=>qp})}),iie=me(function*(e){let t=yield*Yn,r=zt($e(e));return F({run:n=>{let o=L(()=>{if(Eh(n)<=bh(n))return P;let s=t.currentTimeMillisUnsafe()-r,i;for(let a of n.state.items)a.refCount>0||a.idleSince>s||n.state.invalidated.has(a)||_k.has(a)||(i===void 0||a.idleSince<i.idleSince)&&(i=a);return i===void 0?P:A(Pk(n,i),()=>o)});return o.pipe(ca(e),_t({disableYield:!0}))},onAcquire:n=>P,reclaim:n=>qp})}),aie=e=>ar(t=>{let r=t.getRef(CN);return r?Sl(r)("Unhandled error in pool finalizer",e):P});var Vz="~effect/reactivity/Reactivity",vc=Ue("effect/reactivity/Reactivity"),cie=W(()=>{let e=new Map,t=c=>{Mk(c,u=>{let f=e.get(u);f!==void 0&&f.forEach(p=>p())})},r=c=>yn(u=>{let f=Vi(u,Bb);return f?Mk(c,p=>{f.add(p)}):t(c),P}),n=(c,u)=>Rt(u,r(c)),o=(c,u)=>{let f=[];return Mk(c,p=>{f.push(p);let m=e.get(p);m===void 0&&(m=new Set,e.set(p,m)),m.add(u)}),()=>{for(let p=0;p<f.length;p++){let m=e.get(f[p]);m!==void 0&&(m.delete(u),m.size===0&&e.delete(f[p]))}}},s=(c,u)=>xt(function*(){let f=yield*Nr(),p=Re(f,it),m=yield*io(),h=Lc(Sr(f),Ni(p)),x=!1,g=!1,y=v=>{v._tag==="Failure"?Ui(m,v.cause):Ic(m,v.value),g?(g=!1,h(u).addObserver(y)):x=!1};function E(){if(x){g=!0;return}x=!0,h(u).addObserver(y)}let b=o(c,E);return yield*It(p,W(b)),E(),m}),i=(c,u)=>s(c,u).pipe(K(xh),Cn),a=c=>L(()=>{let u=new Set;return c.pipe(Go(Bb,u),Xr(f=>W(()=>{u.forEach(p=>{let m=e.get(p);m!==void 0&&m.forEach(h=>h())})})))});return vc.of({[Vz]:Vz,mutation:n,query:s,stream:i,invalidateUnsafe:t,invalidate:r,registerUnsafe:o,withBatch:a})}),Bb=class extends Ue()("effect/reactivity/Reactivity/PendingInvalidation"){},$b=d(2,(e,t)=>vc.use(r=>r.mutation(t,e)));var Hb=e=>vc.use(t=>t.invalidate(e)),jb=Qn(vc)(cie);function Jz(e){switch(typeof e){case"string":case"number":case"bigint":case"boolean":return String(e);default:return J(e)}}var Mk=(e,t)=>{if(Array.isArray(e)){for(let r=0;r<e.length;r++)t(Jz(e[r]));return}for(let r in e){t(r);let n=e[r];for(let o=0;o<n.length;o++)t(`${r}:${Jz(n[o])}`)}};var Gz="~effect/SubscriptionRef",Ih=e=>O(e,Gz),vye={...wr,[Gz]:{_A:F},toJSON(){return{_id:"SubscriptionRef",value:this.value}}};var Fk=e=>fk(e.pubsub);var Zz=e=>W(()=>e.value);var uie=(e,t)=>{e.value=t,nj(e.pubsub,t)};var Nk=d(2,(e,t)=>e.semaphore.withPermit(W(()=>uie(e,t))));var rE={};ps(rE,{Fetch:()=>TW,RequestInit:()=>tE,layer:()=>_ie});var Uk="~effect/http/HttpBody";var Yz="~effect/http/HttpBody/HttpBodyError",Xz=class extends sr("HttpBodyError"){[Yz]=Yz};var zb=class{[Uk];constructor(){this[Uk]=Uk}[Qe](){return this.toJSON()}toString(){return j(this,{ignoreToString:!0})}},Dk=class extends zb{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}},eW=new Dk;var Th=class extends zb{_tag="Uint8Array";contentType;contentLength;text;_body;constructor(t,r,n,o){super(),this._body=t,this.text=o,this.contentType=r,this.contentLength=n}get body(){return this._body??=fie(this.text)}toJSON(){return{_id:"effect/HttpBody",_tag:"Uint8Array",body:this.contentType.startsWith("text/")||this.contentType.endsWith("json")?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},Lk=(e,t)=>new Th(e,t??"application/octet-stream",e.length),tW=new TextEncoder,Wb=globalThis.Buffer,fie=Wb!==void 0?e=>Wb.from(e,"utf8"):e=>tW.encode(e),Bk=(e,t)=>{if(typeof e!="string"&&(e=e===void 0?"":String(e)),Wb!==void 0)return new Th(void 0,t??"text/plain",Wb.byteLength(e,"utf8"),e);let r=tW.encode(e);return new Th(r,t??"text/plain",r.length,e)};var Hk="~effect/http/HttpClientError";var co=class extends sr("HttpClientError"){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[Hk]=Hk;get request(){return this.reason.request}get response(){return"response"in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},vh=e=>e.endsWith("Error")?e.slice(0,-5):e,Ch=(e,t,r)=>t?`${e}: ${t} (${r})`:`${e} error (${r})`,Kb=class extends sr("TransportError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Ch(vh(this._tag),this.description,this.methodAndUrl)}};var Vb=class extends sr("InvalidUrlError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Ch(vh(this._tag),this.description,this.methodAndUrl)}},wh=class extends sr("StatusCodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return Ch(vh(this._tag),this.description,t)}},Cc=class extends sr("DecodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return Ch(vh(this._tag),this.description,t)}},Jb=class extends sr("EmptyBodyError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return Ch(vh(this._tag),this.description,t)}},bd=class e extends Ar(Hk)({_tag:je("HttpError"),kind:Fo(["EncodeError","DecodeError","TransportError","InvalidUrlError","StatusCodeError","EmptyBodyError"]),cause:lr(er())}){static fromHttpClientError(t){return new e({_tag:"HttpError",kind:t.reason._tag,cause:t.reason})}};var rW=[["GET","get"],["POST","post"],["PUT","put"],["DELETE","del"],["PATCH","patch"],["HEAD","head"],["OPTIONS","options"],["TRACE","trace"],["QUERY","query"]];var oW=(e,t)=>t._tag==="Empty"||t._tag==="FormData"?oc(oc(e,"content-type"),"content-length"):(e=t.contentType===void 0?oc(e,"content-type"):am(e,"content-type",t.contentType),t.contentLength===void 0?oc(e,"content-length"):am(e,"content-length",t.contentLength.toString()));var Zb=class extends sr("UrlError"){},Qb=(e,t,r)=>Px({try:()=>{let n=new URL(e,die());for(let o=0;o<t.params.length;o++){let[s,i]=t.params[o];i!==void 0&&n.searchParams.append(s,i)}return r!==void 0&&(n.hash=r),n},catch:n=>new Zb({cause:n})}),die=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname};var sW="~effect/http/HttpClientRequest";var pie={[sW]:sW,...kt,toJSON(){return{_id:"HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:ho(this.headers),body:this.body.toJSON()}},pipe(){return V(this,arguments)}};function Bi(e,t,r,n,o,s){let i=Object.create(pie);return i.method=e,i.url=t,i.urlParams=r,i.hash=n,i.headers=o,i.body=s,i}var mie=Bi("GET","",r1,_(),wl,eW),iW=e=>(t,r)=>hie(mie,{method:e,url:t,...r??void 0});var hie=d(2,(e,t)=>{let r=e;return t.method&&(r=aW(r,t.method)),t.url&&(r=fW(r,t.url)),t.headers&&(r=qk(r,t.headers)),t.urlParams&&(r=yie(r,t.urlParams)),t.hash&&(r=Sie(r,t.hash)),t.body&&(r=dW(r,t.body)),t.accept&&(r=uW(r,t.accept)),t.acceptJson&&(r=xie(r)),r}),aW=d(2,(e,t)=>Bi(t,e.url,e.urlParams,e.hash,e.headers,e.body)),cW=d(3,(e,t,r)=>Bi(e.method,e.url,e.urlParams,e.hash,am(e.headers,t,r),e.body)),qk=d(2,(e,t)=>Bi(e.method,e.url,e.urlParams,e.hash,XD(e.headers,t),e.body));var uW=d(2,(e,t)=>cW(e,"Accept",t)),xie=uW("application/json"),fW=d(2,(e,t)=>{if(typeof t=="string")return Bi(e.method,t,e.urlParams,e.hash,e.headers,e.body);let r=new URL(t.toString()),n=_u(r.searchParams),o=Qc(r.hash===""?void 0:r.hash.slice(1));return r.search="",r.hash="",Bi(e.method,r.toString(),n,o,e.headers,e.body)}),lW=d(2,(e,t)=>t===""?e:Bi(e.method,gie(t,e.url),e.urlParams,e.hash,e.headers,e.body));var gie=(e,t)=>{let r=e.endsWith("/"),n=t.startsWith("/");return r&&n?e+t.slice(1):!r&&!n?e+"/"+t:e+t};var yie=d(2,(e,t)=>Bi(e.method,e.url,o1(e.urlParams,t),e.hash,e.headers,e.body));var Sie=d(2,(e,t)=>Bi(e.method,e.url,e.urlParams,N(t),e.headers,e.body));var dW=d(2,(e,t)=>Bi(e.method,e.url,e.urlParams,e.hash,oW(e.headers,t),t));function pW(e){let t=Qb(e.url,e.urlParams,_n(e.hash));return tt(t)?N(t.success):_()}var xf="~effect/http/HttpIncomingMessage";var mW=(e,t)=>{let r=e.headers["content-type"]??"",n;if(r.includes("application/json"))try{n=Ai(e.json)}catch{}else if(r.includes("text/")||r.includes("urlencoded"))try{n=Ai(e.text)}catch{}let o={...t,headers:ho(e.headers),remoteAddress:e.remoteAddress};return n!==void 0&&(o.body=n),o};var Ed="~effect/http/HttpClientResponse",hW=(e,t)=>new Wk(e,t);var Wk=class extends xx{[xf];[Ed];request;source;constructor(t,r){super(),this.request=t,this.source=r,this[xf]=xf,this[Ed]=Ed}toJSON(){return mW(this,{_id:"HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split("#")[0];let t=pW(this.request);return fe(t)?"":(t.value.hash="",t.value.href)}get headers(){return Zo(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=Ry(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return _()}get stream(){return this.source.body?lk({evaluate:()=>this.source.body,onError:t=>new co({reason:new Cc({request:this.request,response:this,cause:t})})}):wc(new co({reason:new Jb({request:this.request,response:this,description:"can not create stream from empty body"})}))}get json(){return A(this.text,t=>Jo({try:()=>t===""?null:JSON.parse(t),catch:r=>new co({reason:new Cc({request:this.request,response:this,cause:r})})}))}textBody;get text(){return this.textBody??=K(this.arrayBuffer,t=>new TextDecoder().decode(t))}get urlParamsBody(){return A(this.text,t=>Jo({try:()=>_u(new URLSearchParams(t)),catch:r=>new co({reason:new Cc({request:this.request,response:this,cause:r})})}))}formDataBody;get formData(){return this.formDataBody??=Vo({try:()=>this.source.formData(),catch:t=>new co({reason:new Cc({request:this.request,response:this,cause:t})})}).pipe(ay,Ai)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody?this.arrayBufferBody:(this.arrayBufferBody=Vo({try:()=>this.source.arrayBuffer(),catch:t=>new co({reason:new Cc({request:this.request,response:this,cause:t})})}).pipe(ay,Ai),this.arrayBufferBody)}pipe(){return V(this,arguments)}};var xW=e=>YD({b3:`${e.traceId}-${e.spanId}-${e.sampled?"1":"0"}${Zt(e.parent,{onNone:()=>"",onSome:t=>`-${t.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?"01":"00"}`});var bie={"http:":80,"https:":443,"ws:":80,"wss:":443},yW=(e,t)=>{let r=t.search.slice(1);if(e.attribute("url.full",t.toString()),e.attribute("url.path",t.pathname),r!==""&&e.attribute("url.query",r),e.attribute("url.scheme",t.protocol.slice(0,-1)),t.hostname!==""){e.attribute("server.address",t.hostname.startsWith("[")?t.hostname.slice(1,-1):t.hostname);let n=t.port===""?bie[t.protocol]:Number(t.port);n!==void 0&&e.attribute("server.port",n)}},Vk=(e,t,r,n,o)=>{for(let s in r)n(s,t)&&e.attribute(`http.${t}.header.${s}`,e1(s,o)?"<redacted>":r[s])};var SW="~effect/http/HttpClient";var Jk=Ue("effect/HttpClient");var Iie=d(2,(e,t)=>Gk(r=>t(e.postprocess(r)),e.preprocess));var Gk=(e,t)=>{let r=Object.create(Tie);return r.preprocess=t,r.postprocess=e,r.execute=function(n){return e(t(n))},r},Tie={[SW]:SW,pipe(){return V(this,arguments)},...kt,toJSON(){return{_id:"effect/HttpClient"}},...Object.fromEntries(rW.map(([e,t])=>[t,function(r,n){return this.execute(iW(e)(r,n))}]))},bW=e=>Gk(t=>A(t,r=>ar(n=>{let o=Rie.get(r),s=o??new AbortController,i=Qb(r.url,r.urlParams,_n(r.hash));if(be(i))return D(new co({reason:new Vb({request:r,cause:i.failure})}));let a=i.success;if(n.getRef(Bf)||n.getRef(vie)(r)){let u=e(r,a,s.signal,n);return o?u:en(f=>Un(f(u),{onSuccess(p){return Xb.register(p,s),I(new eE(p,s))},onFailure(p){return il(p)&&s.abort(),He(p)}}))}return Jp(n.getRef(kie)(r),{kind:"client"},u=>{u.attribute("http.request.method",r.method);let f=n.getRef(jw);yW(u,a);let p=n.getRef(Cie);return Vk(u,"request",r.headers,p,f),r=n.getRef(Aie)?qk(r,xW(u)):r,en(m=>m(e(r,a,s.signal,n)).pipe(xl(u,{captureStackTrace:!1}),Un({onSuccess:h=>(u.attribute("http.response.status_code",h.status),Vk(u,"response",h.headers,p,f),h.status>=400&&h.status<600&&(u.attribute("error.type",String(h.status)),wie(n,u,r,h)),o?I(h):(Xb.register(h,s),I(new eE(h,s)))),onFailure(h){return!o&&il(h)&&s.abort(),He(h)}})))})})),I),wie=(e,t,r,n)=>{let o=Ir();yt(0);let s;try{s=Gn(new co({reason:new wh({request:r,response:n})}))}finally{yt(o)}t.end(e.getRef(Dg)?e.getRef(Yn).currentTimeNanosUnsafe():BigInt(0),s)},EW=d(2,(e,t)=>Gk(e.postprocess,r=>K(e.preprocess(r),t)));var vie=Ce("effect/http/HttpClient/TracerDisabledWhen",{defaultValue:()=>Oa}),Cie=Ce("effect/http/HttpClient/TracerHeaderFilter",{defaultValue:()=>Oa}),Aie=Ce("effect/http/HttpClient/TracerPropagationEnabled",{defaultValue:nr}),kie=Ce("effect/http/HttpClient/SpanNameGenerator",{defaultValue:()=>e=>e.method}),IW=e=>Qn(Jk)(yn(t=>K(e,r=>Iie(r,Xa(n=>Kr(t,n)))))),Xb=(()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){let t=new FinalizationRegistry(r=>{r.abort()});return{register(r,n){t.register(r,n,r)},unregister(r){t.unregister(r)}}}let e=new WeakMap;return{register(t,r){e.set(t,setTimeout(()=>r.abort(),5e3))},unregister(t){let r=e.get(t);r!==void 0&&(clearTimeout(r),e.delete(t))}}})(),Rie=new WeakMap,eE=class{original;controller;constructor(t,r){this.original=t,this.controller=r}[Ed]=Ed;[xf]=xf;applyInterrupt(t){return L(()=>(Xb.unregister(this.original),gu(t,()=>W(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return vn(()=>(Xb.unregister(this.original),yh(this.original.stream,W(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Qe](){return this.original[Qe]()}pipe(){return V(this,arguments)}};var TW=Ce("effect/http/FetchHttpClient/Fetch",{defaultValue:()=>globalThis.fetch}),tE=class extends Ue()("effect/http/FetchHttpClient/RequestInit"){},Oie=bW((e,t,r,n)=>{let o=n.getRef(TW),s=Vi(n.context,tE)??{},i=s.headers?vl(Zo(s.headers),e.headers):e.headers;i["content-length"]&&(i=oc(i,"content-length"));let a=c=>K(Vo({try:()=>o(t,{...s,method:e.method,headers:i,body:c,duplex:typeof ReadableStream<"u"&&c instanceof ReadableStream?"half":void 0,signal:r}),catch:u=>new co({reason:new Kb({request:e,cause:u})})}),u=>hW(e,u));switch(e.body._tag){case"Raw":case"Uint8Array":return a(e.body.body);case"FormData":return a(e.body.formData);case"Stream":return A(vk(e.body.stream),a)}return a(void 0)}),_ie=IW(I(Oie));var vW=Ue("effect/socket/Socket");var Qk="~effect/socket/Socket/CloseEvent",wW=class{[Qk];code;reason;constructor(t=1e3,r){this[Qk]=Qk,this.code=t,this.reason=r}toString(){return this.reason?`${this.code}: ${this.reason}`:`${this.code}`}};var nE="~effect/socket/Socket/SocketError",Pie=e=>O(e,nE),Ah=class extends Ar("effect/socket/Socket/SocketReadError")({_tag:je("SocketReadError"),cause:er()}){message="An error occurred during Read"},Yk=class extends Ar("effect/socket/Socket/SocketWriteError")({_tag:je("SocketWriteError"),cause:er()}){message="An error occurred during Write"},Xk=class extends Ar("effect/socket/Socket/SocketOpenError")({_tag:je("SocketOpenError"),kind:Fo(["Unknown","Timeout"]),cause:er()}){get message(){return this.kind==="Timeout"?'timeout waiting for "open"':"An error occurred during Open"}},eR=class e extends Ar("effect/socket/Socket/SocketUpgradeError")({_tag:je("SocketUpgradeError"),cause:lr(er())}){static unsupported=()=>D(new kh({reason:new e({})}));get message(){return this.cause===void 0?"Socket does not support TLS upgrade":"An error occurred during TLS upgrade"}},tR=class extends Ar("effect/socket/Socket/SocketCloseError")({_tag:je("SocketCloseError"),code:In,closeReason:lr(z)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},rR=Pe([Ah,Yk,Xk,eR,tR]),kh=class extends yA(nE)("SocketError",{_tag:je("SocketError"),reason:rR}){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[nE]=nE;static is(t){return Pie(t)}message=this.reason.message};var fbe=64*1024;var CW="~effect/reactivity/AsyncResult",oR=e=>O(e,CW),oE={[CW]:{E:F,A:F},pipe(){return V(this,arguments)},[ae](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case"Initial":return!0;case"Success":return Z(this.value,e.value);case"Failure":return Z(this.cause,e.cause)}},[ie](){let e=Be(`${this._tag}:${this.waiting}`);return this._tag==="Initial"?e:he(e)(this._tag==="Success"?J(this.value):J(this.cause))}};var sR=(e,t)=>e._tag==="Success"?us(e.value):Td(e.cause,{previous:t}),sE=e=>e._tag==="None"?Ca(!0):Rh(e.value);var AW=e=>e._tag!=="Initial",Ca=(e=!1)=>{let t=Object.create(oE);return t._tag="Initial",t.waiting=e,t},Id=e=>e._tag==="Success",us=(e,t)=>{let r=Object.create(oE);return r._tag="Success",r.value=e,r.waiting=t?.waiting??!1,r.timestamp=t?.timestamp??Date.now(),r},kW=e=>e._tag==="Failure";var nR=(e,t)=>{let r=Object.create(oE);return r._tag="Failure",r.cause=e,r.previousSuccess=t?.previousSuccess??_(),r.waiting=t?.waiting??!1,r},Td=(e,t)=>nR(e,{previousSuccess:gs(t.previous,r=>Id(r)?N(r):kW(r)?r.previousSuccess:_()),waiting:t.waiting});var RW=(e,t)=>Td(dN(e),t),Rh=d(e=>oR(e[0]),(e,t)=>{if(e.waiting)return t?.touch?Fie(e):e;let r=Object.assign(Object.create(oE),e);return r.waiting=!0,t?.touch&&Id(r)&&(r.timestamp=Date.now()),r}),Fie=e=>Id(e)?us(e.value,{waiting:e.waiting}):e,Oh=d(2,(e,t)=>e._tag==="Failure"?Td(e.cause,{previous:t,waiting:e.waiting}):e),iR=e=>e._tag==="Success"?N(e.value):e._tag==="Failure"?Ut(e.previousSuccess,t=>t.value):_();var aR=e=>Nf(iR(e),()=>new al("AsyncResult.getOrThrow: no value found"));var wd=e=>{switch(e._tag){case"Success":return Mr(e.value);case"Failure":return ir(e.cause);default:return Gn(new al)}};var cR=e=>{let t=e.success??Mi,r=e.error??Mi,n=Cr()([t,Km(r,er())],([o,s])=>(i,a,c)=>{if(!oR(i))return D(new at(a,i,c));switch(i._tag){case"Initial":return I(i);case"Success":return cr(ot(o)(i.value,c),{onSuccess:u=>us(u,i),onFailure:u=>tn(a,"value",u,i,c)});case"Failure":{let u=i.previousSuccess.pipe(Ut(p=>cr(ot(o)(p.value,c),{onSuccess:m=>N(us(m,p)),onFailure:m=>new Pt(a,[new Ct(["previousSuccess","value"],m)],i,c)})),Ma(()=>ia)),f=bu(ot(s)(i.cause,c),p=>tn(a,"cause",p,i,c));return ur(u,p=>Su(f,m=>nR(m,{previousSuccess:p,waiting:i.waiting})))}}},{expected:"AsyncResult",toCodec([o,s]){let i=ya("Success",{value:o,waiting:Fi,timestamp:In});return Ne()(Pe([ya("Initial",{waiting:Fi}),i,ya("Failure",{cause:s,previousSuccess:ba(i),waiting:Fi})]),Fe({decode:a=>{switch(a._tag){case"Initial":return Ca(a.waiting);case"Success":return us(a.value,{waiting:a.waiting,timestamp:a.timestamp});case"Failure":return nR(a.cause,{previousSuccess:Ut(a.previousSuccess,c=>us(c.value,c)),waiting:a.waiting})}},encode(a){switch(a._tag){case"Initial":return{_tag:"Initial",waiting:a.waiting};case"Success":return{_tag:"Success",value:a.value,waiting:a.waiting,timestamp:a.timestamp};case"Failure":return{_tag:"Failure",cause:a.cause,previousSuccess:a.previousSuccess,waiting:a.waiting}}}}))},toEquivalence:jd,toFormatter:([o,s])=>i=>{switch(i._tag){case"Success":return`AsyncResult.Success(${o(i.value)}, ${i.waiting}, ${i.timestamp})`;case"Failure":return`AsyncResult.Failure(${s(i.cause)}, ${i.waiting})`;case"Initial":return`AsyncResult.Initial(${i.waiting}, ${i.waiting})`}}});return Object.assign(n,{success:t,error:r})};var Ph="~effect/reactivity/AtomRegistry",Nie=e=>O(e,Ph),OW=e=>new lR(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),iE=Ue(Ph);var Fh=d(e=>Nie(e[0]),(e,t,r)=>{let n=r?.suspendOnWaiting??!1;return Nn(o=>{let s=e.get(t);if(s._tag!=="Initial"&&!(n&&s.waiting))return o(wd(s));let i=e.subscribe(t,a=>{a._tag!=="Initial"&&!(n&&a.waiting)&&(o(wd(a)),i())});return W(i)})});var Uie={immediate:!0},_W=e=>{e()},An={};function Mh(e,t){let r=An;for(let n of e)try{t(n)}catch(o){r===An&&(r=o)}if(r!==An)throw r}var fR="~effect-atom/atom/Atom/Serializable",_h=e=>fR in e?e[fR].key:e,lR=class{[Ph];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(t,r,n,o){if(this[Ph]=Ph,this.scheduler=new fi("sync",r),this.schedulerAsync=new fi("async",r),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=o,n===void 0&&o!==void 0?this.timeoutResolution=Math.round(o/2):this.timeoutResolution=n??1e3,t!==void 0)for(let[s,i]of t){let a=s;for(;a.initialValueTarget;)a=a.initialValueTarget;this.ensureNode(a).setInitialValue(i)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(t){return this.ensureNode(t).value()}set(t,r){t.write(this.ensureNode(t).writeContext,r)}setSerializable(t,r){this.preloadedSerializable.set(t,r)}modify(t,r){let n=this.ensureNode(t),o=r(n.value());return t.write(n.writeContext,o[1]),o[0]}update(t,r){let n=this.ensureNode(t);t.write(n.writeContext,r(n.value()))}refresh=t=>{t.refresh!==void 0?t.refresh(this.refresh):this.invalidateAtom(t)};subscribe(t,r,n){let o=this.ensureNode(t);n?.immediate?r(o.value()):o.state===an.stale&&o.value();let s=o.subscribe(function(){r(o._value)});return()=>{s(),o.canBeRemoved&&this.scheduleNodeRemoval(o)}}mount(t){return this.subscribe(t,Rr,Uie)}atomHasTtl(t){return!t.keepAlive&&t.idleTTL!==0&&(t.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(t){let r=_h(t),n=this.nodes.get(r);if(n===void 0?(n=this.createNode(t),this.nodes.set(r,n),this.onNodeAdded?.(n)):this.atomHasTtl(t)&&this.removeNodeTimeout(n),typeof r=="string"&&this.preloadedSerializable.has(r)){let o=this.preloadedSerializable.get(r);this.preloadedSerializable.delete(r);let s=t[fR].decode(o),i=t;for(;i.initialValueTarget;)i=i.initialValueTarget;i===t?n.setValue(s):this.ensureNode(i).setInitialValue(s)}return n}createNode(t){if(this.disposed)throw new Error(`Cannot access Atom ${t}: registry is disposed`);return t.keepAlive||this.scheduleAtomRemoval(t),new dR(this,t)}invalidateAtom=t=>{this.ensureNode(t).invalidate()};scheduleAtomRemoval(t){this.dispatcher.scheduleTask(()=>{let r=this.nodes.get(_h(t));r!==void 0&&r.canBeRemoved&&this.removeNode(r)},0)}scheduleNodeRemoval(t){this.dispatcher.scheduleTask(()=>{t.canBeRemoved&&this.removeNode(t)},0)}removeNode(t){this.atomHasTtl(t.atom)?this.setNodeTimeout(t):(this.nodes.delete(_h(t.atom)),t.remove(),this.onNodeRemoved?.(t))}setNodeTimeout(t){if(this.nodeTimeoutBucket.has(t))return;let r=t.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(r-=this.#e,r<=0)){this.nodes.delete(_h(t.atom)),t.remove(),this.onNodeRemoved?.(t);return}let n=Math.ceil(r/this.timeoutResolution)*this.timeoutResolution,o=Date.now()+n,s=o-o%this.timeoutResolution+this.timeoutResolution,i=this.timeoutBuckets.get(s);i===void 0&&(i=[new Set,setTimeout(()=>this.sweepBucket(s),s-Date.now())],this.timeoutBuckets.set(s,i)),i[0].add(t),this.nodeTimeoutBucket.set(t,s)}removeNodeTimeout(t){let r=this.nodeTimeoutBucket.get(t);if(r===void 0)return;this.nodeTimeoutBucket.delete(t),this.scheduleNodeRemoval(t);let[n,o]=this.timeoutBuckets.get(r);n.delete(t),n.size===0&&(clearTimeout(o),this.timeoutBuckets.delete(r))}#e=null;sweepBucket(t){let r=this.timeoutBuckets.get(t)[0];this.timeoutBuckets.delete(t),Mh(r,this.removeIdleNode)}removeIdleNode=t=>{if(this.nodeTimeoutBucket.delete(t),!!t.canBeRemoved){this.nodes.delete(_h(t.atom)),this.onNodeRemoved?.(t),this.#e=t.atom.idleTTL??this.defaultIdleTTL;try{t.remove()}finally{this.#e=null}}};reset(){this.timeoutBuckets.forEach(([,r])=>clearTimeout(r)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear();let t=Array.from(this.nodes.values());this.nodes.clear();for(let r of t)r.state=an.removed;Mh(t,this.destroyNode)}destroyNode=t=>{t.remove(),this.onNodeRemoved?.(t)};dispose(){this.disposed=!0,this.reset()}},fs={alive:1,initialized:2,waitingForValue:4},an={uninitialized:fs.alive|fs.waitingForValue,stale:fs.alive|fs.initialized|fs.waitingForValue,valid:fs.alive|fs.initialized,removed:0},dR=class{constructor(t,r){this.registry=t,this.atom=r,this.writeContext=new pR(t,this)}registry;atom;state=an.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;invalidatedDuringBuild=!1;failed=!1;parents=new Set;children=new Set;listeners=new Set;observedChildren=0;currentState(){switch(this.state){case an.uninitialized:return"uninitialized";case an.stale:return"stale";case an.valid:return"valid";default:return"removed"}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.size===0&&this.state!==0}get building(){return this.lifetime!==void 0&&this.lifetime.reads!==void 0}get isObserved(){return!this.atom.lazy||this.listeners.size>0||this.observedChildren>0}childObserved(t){let r=this.isObserved;this.observedChildren+=t,r!==this.isObserved&&this.observedChanged(t)}observedChanged(t){for(let r of this.parents)r.childObserved(t)}_value=void 0;value(){for(;(this.state&fs.waitingForValue)!==0;)this.build();return this._value}build(){this.disposeLifetime(),this.invalidatedDuringBuild=!1;let t=Lie(this);this.lifetime=t;let r,n=!1;try{r=this.atom.read(t),n=!0}finally{let o=t.reads;t.reads=void 0,this.lifetime===t&&(this.dropUnread(o),n||this.fail())}if(this.lifetime===t&&(this.state&fs.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.failed=!1,this.state=an.valid):this.setValue(r)),t.failure!==An)throw t.failure}fail(){this.failed=!0;try{this.invalidateChildren()}catch{}}readTracked(t,r){let n=this.registry.ensureNode(t);this.parents.has(n)||(this.parents.add(n),n.children.add(this),this.isObserved&&n.childObserved(1));try{return n.value()}catch(o){if(r.reads===void 0||n.state!==an.valid)throw o;return r.failure===An&&(r.failure=o),n._value}finally{r.reads!==void 0&&!r.disposed&&r.reads.add(n)}}dropUnread(t){if(t.size===this.parents.size)return;let r=this.isObserved;for(let n of this.parents)t.has(n)||(this.parents.delete(n),n.children.delete(this),r&&n.childObserved(-1),n.canBeRemoved&&this.registry.scheduleNodeRemoval(n))}valueOption(){return(this.state&fs.initialized)===0?_():N(this._value)}setInitialValue(t){if((this.state&fs.initialized)===0){this.preserveInitialValueOnBuild=!0,this.state=an.stale,this._value=t,this.listeners.size>0&&this.announce();return}this.setValue(t)}setValue(t){let r=this.failed;this.failed=!1;let n=(this.state&fs.initialized)!==0;if(this.state=an.valid,n&&this.atom.equals(this._value,t)){r&&this.invalidateChildren();return}this._value=t;let o=An;try{this.invalidateChildren()}catch(s){o=s}if(this.listeners.size>0)try{this.announce()}catch(s){o===An&&(o=s)}if(o!==An)throw o}announce(){cn.phase===Ac.collect?cn.notify.add(this):this.notify()}invalidate(){if(this.state===an.valid){this.state=an.stale;try{this.disposeLifetime()}finally{this.propagate()}}else this.building&&cn.phase!==Ac.collect?this.build():this.propagate()}propagate(){cn.phase===Ac.collect?(this.building&&(this.invalidatedDuringBuild=!0),cn.stale.push(this)):this.isObserved?this.value():this.invalidateChildren()}invalidateChildren(){if(this.children.size===0)return;let t=An;for(let r of Array.from(this.children))if(r.affectedBy(this))try{r.invalidate()}catch(n){t===An&&(t=n)}if(t!==An)throw t}affectedBy(t){if(this.state===an.valid)return!0;let r=this.lifetime?.reads;return r!==void 0?r.has(t):this.isObserved&&t.state===an.valid}notify(){cn.phase===Ac.commit&&cn.notify.delete(this),Mh(this.listeners,_W)}disposeLifetime(){let t=this.lifetime;t!==void 0&&(this.lifetime=void 0,t.dispose())}remove(){let t=this.isObserved;this.state=an.removed,this.listeners.clear();try{this.disposeLifetime()}finally{let r=Array.from(this.parents);this.parents.clear(),Mh(r,n=>{n.children.delete(this),t&&n.childObserved(-1),n.canBeRemoved&&this.registry.removeNode(n)})}}subscribe(t){let r=this.isObserved;return this.listeners.add(t),r||this.observedChanged(1),()=>{this.listeners.delete(t)&&!this.isObserved&&this.observedChanged(-1)}}},Die={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){return this.disposed?this.node.registry.get(e):this.node.readTracked(e,this)},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let r=this.get(e);if(t?.suspendOnWaiting&&r.waiting)return Xn;switch(r._tag){case"Initial":return Xn;case"Failure":return ir(r.cause);case"Success":return I(r.value)}},resultOnce(e,t){return Nn(r=>{let n=this.once(e);if(n._tag!=="Initial"&&!(t?.suspendOnWaiting&&n.waiting))return r(wd(n));let o=this.node.registry.subscribe(e,s=>{s._tag==="Initial"||t?.suspendOnWaiting&&s.waiting||(o(),r(wd(s)))},{immediate:!1});return W(o)})},setResult(e,t){return this.disposed?Xn:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag==="None"?Xn:I(t.value)},someOnce(e){return Nn(t=>{let r=this.once(e);if(de(r))return t(I(r.value));let n=this.node.registry.subscribe(e,o=>{fe(o)||(n(),t(I(o.value)))},{immediate:!1});return W(n)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?_():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,r){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,r))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?Gs:Mb(r=>W(()=>{this.subscribe(e,n=>Ic(r,n),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(hk(AW),mf(r=>r._tag==="Success"?I(r.value):He(r.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0,Mh(e.reverse(),_W)}},Lie=e=>{function t(r){return t.disposed||t.isFn?e.registry.get(r):e.readTracked(r,t)}return Object.setPrototypeOf(t,Die),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t.reads=new Set,t.failure=An,t},pR=class{constructor(t,r){this.registry=t,this.node=r}registry;node;get(t){return this.registry.get(t)}set(t,r){return this.registry.set(t,r)}setSelf(t){return this.node.setValue(t)}refreshSelf(){return this.node.invalidate()}},Ac={disabled:0,collect:1,commit:2},cn={phase:Ac.disabled,depth:0,stale:[],notify:new Set};function PW(e){let t=cn.phase;cn.phase=Ac.collect,cn.depth++;let r=An;try{e()}catch(n){r=n}if(cn.depth===1){let{notify:n,stale:o}=cn,s=0;do{for(cn.phase=Ac.collect;s<o.length;s++)try{Bie(o[s])}catch(i){r===An&&(r=i)}cn.phase=Ac.commit;for(let i of n)try{i.notify()}catch(a){r===An&&(r=a)}}while(s<o.length);cn.stale=[],n.clear()}if(cn.depth--,cn.phase=t,r!==An)throw r}function Bie(e){if(e.state===an.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=an.stale,e.disposeLifetime()}e.value()}var Qh={};ps(Qh,{ConnectionHooks:()=>Zh,CurrentHeaders:()=>ME,Protocol:()=>ji,layerProtocolHttp:()=>rue,layerProtocolSocket:()=>sue,layerProtocolWorker:()=>iue,make:()=>tO,makeNoSerialization:()=>u6,makeProtocolHttp:()=>f6,makeProtocolSocket:()=>l6,makeProtocolWorker:()=>d6,withHeaders:()=>tue});var Nh=class extends Ue()("effect/workers/Transferable/Collector"){},FW=()=>{let e=[],t=o=>{e.push(...o)},r=()=>e,n=()=>{let o=e;return e=[],o};return Nh.of({addAllUnsafe:t,addAll:o=>W(()=>t(o)),readUnsafe:r,read:W(r),clearUnsafe:n,clear:W(n)})};var mR="~effect/workers/WorkerError";var hR=class extends Ar("effect/workers/WorkerError/WorkerSpawnError")({_tag:je("WorkerSpawnError"),message:z,cause:lr(er())}){},xR=class extends Ar("effect/workers/WorkerError/WorkerSendError")({_tag:je("WorkerSendError"),message:z,cause:lr(er())}){},gR=class extends Ar("effect/workers/WorkerError/WorkerReceiveError")({_tag:je("WorkerReceiveError"),message:z,cause:lr(er())}){},yR=class extends Ar("effect/workers/WorkerError/WorkerUnknownError")({_tag:je("WorkerUnknownError"),message:z,cause:lr(er())}){},SR=Pe([hR,xR,gR,yR]),NW=class extends Ar(mR)({_tag:je("WorkerError"),reason:SR}){constructor(t){super({...t,cause:t.reason.cause})}[mR]=mR;get message(){return this.reason.message}};var aE=class extends Ue()("effect/workers/Worker/WorkerPlatform"){};var bR=(e,t)=>e===void 0?t:`${e}.${t}`,ER=(e,t)=>({"rpc.system.name":"effect_rpc","rpc.method":e,...t});var Cd={};ps(Cd,{ServerClient:()=>vR,custom:()=>Kie,exitSchema:()=>CR,fork:()=>Gie,isRpc:()=>zie,isWrapper:()=>vd,make:()=>DW,uninterruptible:()=>Zie,unwrap:()=>Vie,wrap:()=>fE,wrapMap:()=>Jie});var IR="~effect/rpc/RpcSchema/StreamSchema";function Uh(e){return O(e,IR)}function cE(e){return Uh(e)?N({success:e.success,error:e.error}):_()}var qie=Je(Ae);function UW(e,t){return G(qie.ast,{[IR]:IR,success:e,error:t})}var wR="~effect/rpc/Rpc",zie=e=>O(e,wR),vR=class{id;annotations;constructor(t){this.id=t,this.annotations=pt()}annotate(t,r){return this.annotations=We(this.annotations,t,r),this}},Wie={[wR]:wR,pipe(){return V(this,arguments)},setSuccess(e){return kc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return kc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return kc({_tag:this._tag,payloadSchema:Vu(e)?e:Te(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return kc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return kc({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return kc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:We(this.annotations,e,t)})},annotateMerge(e){return kc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Kr(this.annotations,e)})}},kc=e=>{function t(){}return Object.setPrototypeOf(t,Wie),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},DW=(e,t)=>{let r=t?.success??ud,n=t?.error??Mi,o=t?.defect??er(),s;return t?.primaryKey?s=class extends JS(`effect/rpc/Rpc/${e}`)(t.payload){[Mz](){return t.primaryKey(this)}}:s=Vu(t?.payload)?t?.payload:t?.payload?Te(t?.payload):ud,kc({_tag:e,payloadSchema:s,successSchema:t?.stream?UW(r,n):r,errorSchema:t?.stream?Mi:n,defectSchema:o,annotations:pt(),middlewares:new Set})},Kie=e=>(t,r)=>{let n=r?.success??ud,o=r?.error??Mi,s=r?.defect??er(),i=e({success:n,error:o,defect:s});return DW(t,{...i,primaryKey:r?.primaryKey,payload:r?.payload,stream:r?.stream})},TR=new WeakMap,CR=e=>{if(TR.has(e))return TR.get(e);let t=e,r=new Set([t.errorSchema]),n=cE(t.successSchema);de(n)&&r.add(n.value.error);for(let s of t.middlewares)r.add(s.error);let o=hA(de(n)?ud:t.successSchema,Pe([...r]),t.defectSchema);return TR.set(e,o),o},Dh="~effect/rpc/Rpc/Wrapper",vd=e=>Dh in e,fE=e=>t=>vd(t)?{[Dh]:Dh,value:t.value,fork:e.fork??t.fork,uninterruptible:e.uninterruptible??t.uninterruptible}:{[Dh]:Dh,value:t,fork:e.fork??!1,uninterruptible:e.uninterruptible??!1},Vie=e=>vd(e)?e.value:e,Jie=(e,t)=>vd(e)?fE(e)(t(e.value)):t(e),Gie=fE({fork:!0}),Zie=fE({uninterruptible:!0});var AR="~effect/rpc/RpcClientError",Rc=class extends Ar("effect/rpc/RpcClientError/RpcClientDefect")({_tag:je("RpcClientDefect"),message:z,cause:er()}){},Zs=class extends Ar(AR)({_tag:je("RpcClientError"),reason:Pe([SR,rR,bd,Rc])}){[AR]=AR;get message(){return`${this.reason._tag}: ${this.reason.message}`}};var kR=e=>e;var LW={_tag:"Ping"};var Lh=Pe([z,Ju]),Yie=Te({_tag:je("Request"),id:Lh,tag:z,payload:qs,headers:ct(rs([z,z])),isNotification:lr(fr(!0)),traceId:lr(z),spanId:lr(z),sampled:lr(Fi)}),RR=Pe([Yie,Te({_tag:je("Ack"),requestId:Lh}),Te({_tag:je("Interrupt"),requestId:Lh}),Te({_tag:je("Ping")}),Te({_tag:je("Eof")}),Te({_tag:je("Chunk"),requestId:Lh,values:qs}),Te({_tag:je("Exit"),requestId:Lh,exit:qs}),Te({_tag:je("Defect"),defect:qs}),Te({_tag:je("Pong")})]);var OR=e=>{switch(e._tag){case"Exit":case"Defect":case"ClientProtocolError":return!0;default:return!1}};var Gh={};ps(Gh,{MaxBufferSizeExceeded:()=>RE,RpcSerialization:()=>fn,json:()=>t6,jsonRpc:()=>n6,layerJson:()=>zce,layerJsonRpc:()=>Vce,layerNdJsonRpc:()=>Jce,layerNdjson:()=>Wce,layerNdjsonWith:()=>Kce,layerSchemaBinary:()=>Gce,makeNdjson:()=>_E,ndJsonRpc:()=>o6,ndjson:()=>r6});var Xie=new WeakMap,eae=new WeakMap,tae=new WeakMap,rae=new WeakMap;function s4(e,t){let r=t?.fingerprint===!0?eae:Xie,n=r.get(e);if(n!==void 0)return n;let{exact:o,layout:s,recursive:i,target:a}=Rd(e),c=yf(s,t?.fingerprint),u=o?{value:void 0}:void 0,f=PR(u===void 0?a:Pce(a,u,!i),s,c,u);return r.set(e,f),f}function zR(e,t){let r=t?.fingerprint===!0?rae:tae,n=r.get(e);if(n!==void 0)return n;let{exact:o,exitSuccess:s,layout:i,target:a}=Rd(e);if(!o){if(!s)return s4(e,t);let u={value:void 0},f=PR(Fce(a,u),i,yf(i,t?.fingerprint),u,!0);return r.set(e,f),f}let c=PR(Nce(a),i,yf(i,t?.fingerprint),void 0);return r.set(e,c),c}function PR(e,t,r,n,o=!1){return qs.pipe(ee(e,Rce(t,r,n,o)))}function i4(e,t){let{exact:r,exitSuccess:n,layout:o}=Rd(e),s=yf(o,t?.fingerprint),i=t??nn;if(!r||i.onExcessProperty==="error"){let a=Gm(s4(e,t),t);return!n||i.onExcessProperty==="error"?a:c=>{if(!kE(c))return a(c);try{return TE(o,c,i,s)}catch(u){throw u instanceof Hi?new $n(u.issue):u}}}return a=>{try{return TE(o,a,i,s)}catch(c){throw c instanceof Hi?new $n(c.issue):c}}}function nae(e,t){let{exact:r,layout:n}=Rd(e),o=t??nn;if(!r||o.onExcessProperty==="error"){let i=i4(e,t);return a=>oae(a.map(i))}let s=yf(n,t?.fingerprint);return i=>{try{return B4(n,i,o,s)}catch(a){throw a instanceof Hi?new $n(a.issue):a}}}function oae(e){if(e.length===1)return e[0];let t=0;for(let o of e)t+=o.length;let r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function a4(e,t){let{exact:r,exitSuccess:n,layout:o,target:s}=Rd(e),i=t??nn,a=r?void 0:DS(s,i),c=a!==void 0&&n?u=>kE(u)?u:a(u):a;return sae(o,yf(o,t?.fingerprint),i,t?.maxFrameSize,c,c4(r,t))}function c4(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw new Error("Binary layout: dictionary needs a schema the binary layer validates on its own");return!0}function u4(e,t){let{exact:r,layout:n,target:o}=Rd(e),s=c4(r,t),i=i4(e,t),a=nae(e,t);if(!s)return{encode:i,encodeMany:a};let c=yf(n,t?.fingerprint),u=t??nn,f=u.onExcessProperty==="error"?Gm(o,t):void 0,p=ece(),m=h=>{try{return h()}catch(x){throw x instanceof Hi?new $n(x.issue):x}};return{encode:h=>m(()=>TE(n,f===void 0?h:f(h),u,c,p)),encodeMany:h=>m(()=>B4(n,f===void 0?h:h.map(f),u,c,p))}}function sae(e,t,r,n,o,s){let i=s?[]:void 0,a=new Uint8Array(0),c=0,u=0,f,p=!1,m=new Hh,h=new $h(r,Cae),x=()=>{m.release(),h.clear(),a=DR,c=u=0},g=(v,T)=>{throw new $n(new le({expected:v},T,r))},y=()=>{let v=f;throw f=void 0,v},E=(v,T)=>{let S=v.length-T;S>a.length&&(a=new Uint8Array(Math.max(256,S))),a.set(T===0?v:v.subarray(T),0),c=0,u=S},b={feedSync(v){if(f!==void 0)return y();if(p)return g("parser is spent");let T=u===c,S,w,k;if(T)S=v,w=0,k=v.length;else{if(v.length>0){let $=u-c,te=$+v.length;if(te>a.length){let xe=new Uint8Array(Math.max(256,a.length*2,te));xe.set(a.subarray(c,u)),a=xe,c=0,u=$}else c>0&&(a.copyWithin(0,c,u),c=0,u=$);a.set(v,u),u+=v.length}S=a,w=c,k=u}let C=[],R=()=>(T?w<k&&E(v,w):(c=w,c===u&&(c=u=0)),C),M=($,te)=>{p=!0;let xe=new $n(new le({expected:$},te,r));if(x(),C.length===0)throw xe;return f=xe,C};for(;;){let $=0,te=-1,xe=k-w,Le=1;for(let Ee=0;Ee<Math.min(6,xe);Ee++){let Oe=S[w+Ee];if($+=(Oe&127)*Le,(Oe&128)===0){te=Ee+1;break}Le*=128}if(te===-1){if(xe<6)return R();let Ee=BigInt($);for(let Oe=6;Oe<Math.min(10,xe);Oe++){let rr=S[w+Oe];if(Ee|=BigInt(rr&127)<<BigInt(Oe*7),(rr&128)===0){if(te=Oe+1,Ee>MR)return M("safe integer length",Ee);$=Number(Ee);break}}if(te===-1)return xe>=10?M("uvarint",S.subarray(w,w+10)):R()}if($===0)return M("nonzero frame length",$);if(n!==void 0&&$>n)return M("frame within maxFrameSize",$);if(te+$>xe)return R();let Er=Q;try{Q=0;let Ee=w+te;h.beginFrame(),m.reset(S,Ee,Ee+$,r,h,t.positional,i);let Oe=J4(e,m,t);C.push(o===void 0?Oe:o(Oe))}catch(Ee){p=!0,x();let Oe=Ee instanceof Hi?new $n(Ee.issue):id(Ee)?Ee:(()=>{throw Ee})();if(C.length===0)throw Oe;return f=Oe,C}finally{Q=Er}w+=te+$}},endSync(){if(f!==void 0)return y();if(p)return g("parser is spent");p=!0;let v=c<u?a.subarray(c,u):void 0;if(x(),v!==void 0)return g("complete value",v)},feed:v=>L(()=>{try{return I(b.feedSync(v))}catch(T){if(id(T))return D(T);throw T}}),end:L(()=>{try{return b.endSync(),P}catch(v){if(id(v))return D(v);throw v}})};return b}var iae="~effect/encoding/SchemaBinary/fieldId",aae=32,cae=33,MR=BigInt(Number.MAX_SAFE_INTEGER),gE=BigInt(0),ls=BigInt(1),uae=BigInt(2),f4=BigInt(7),$W=BigInt(127),fae=BigInt(1e6),lae=BigInt(255),HW=BigInt(4294967295),dae=BigInt(32),$i=new TextEncoder,pae=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),l4=7,jW=0xffffffffffff,mae=0xfffffffffffff,d4=0,p4=1,m4=2,qW=512,hae=1048576,xae=4194304,Sf=0,gf=1,zh=2,Wh=3,Kh=4,Vh=5,gae=6,yae=7,ds=8;function WR(e){return typeof e=="number"&&Number.isInteger(e)&&e>=-jW&&e<=jW}var wE=8,FR=2199023255551,_c=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function KR(e){for(let t=1;t<=wE;t++){let r=Math.round(e*_c[t]);if(!(r>=-FR&&r<=FR))return 0;if(r/_c[t]===e)return t}return 0}function h4(e){let t=Math.floor(e/2);return e%2===1?-t:t}var dt={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function x4(e){let t=2166136261;for(let r=0;r<e.length;r++)t=Math.imul(t^e[r],16777619);return t>>>0}var Sae=BigInt("14695981039346656037"),bae=BigInt("1099511628211"),Eae=BigInt("18446744073709551615");function zW(e){let t=Sae;for(let r=0;r<e.length;r++)t=(t^BigInt(e[r]))*bae&Eae;return t}function yE(e,t){for(let r=0;r<t.length;r++)e.push(t[r])}function Oc(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function SE(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function No(e,t){for(let r=0;r<8;r++)e.push(Number(t>>BigInt(r*8)&lae))}function g4(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)if(e[n]!==t[n])return e[n]-t[n];return e.length-t.length}var Hi=class extends Error{issue;constructor(t){super("SchemaBinary failure"),this.issue=t}};function H(e,t,r){throw dr(new le({expected:e},t,r))}var Ze=[],Q=0;function dr(e){return new Hi(Q===0?e:new Ct(Ze.slice(0,Q),e))}function Iae(e){let t=new Uint8Array(y4(e)),r=0;for(;e>127;)t[r++]=e&127|128,e=Math.floor(e/128);return t[r]=e,t}function y4(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var Tae=32;function wae(e,t,r,n){let o=r-t;if(o===0)return"";if(o<=Tae){let s=vae(e,t,r);if(s!==void 0)return s}try{return pae.decode(e.subarray(t,r))}catch{H("utf-8",void 0,n)}}function vae(e,t,r){let n="",o=t;for(;o+16<=r;o+=16){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],p=e[o+6],m=e[o+7],h=e[o+8],x=e[o+9],g=e[o+10],y=e[o+11],E=e[o+12],b=e[o+13],v=e[o+14],T=e[o+15];if((s|i|a|c|u|f|p|m|h|x|g|y|E|b|v|T)>127)return;n+=String.fromCharCode(s,i,a,c,u,f,p,m,h,x,g,y,E,b,v,T)}if(o+8<=r){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],p=e[o+6],m=e[o+7];if((s|i|a|c|u|f|p|m)>127)return;n+=String.fromCharCode(s,i,a,c,u,f,p,m),o+=8}switch(r-o){case 0:return n;case 1:{let s=e[o];return s>127?void 0:n+String.fromCharCode(s)}case 2:{let s=e[o],i=e[o+1];return(s|i)>127?void 0:n+String.fromCharCode(s,i)}case 3:{let s=e[o],i=e[o+1],a=e[o+2];return(s|i|a)>127?void 0:n+String.fromCharCode(s,i,a)}case 4:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3];return(s|i|a|c)>127?void 0:n+String.fromCharCode(s,i,a,c)}case 5:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4];return(s|i|a|c|u)>127?void 0:n+String.fromCharCode(s,i,a,c,u)}case 6:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5];return(s|i|a|c|u|f)>127?void 0:n+String.fromCharCode(s,i,a,c,u,f)}default:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],p=e[o+6];return(s|i|a|c|u|f|p)>127?void 0:n+String.fromCharCode(s,i,a,c,u,f,p)}}}var NR=64*1024,Cae=256,Aae=512,kae=16*1024;function UR(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Bh=UR(NR),bE=class{buf=new Uint8Array(0);view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let t=Bh;(t.writing||t.offset>=t.buf.length)&&(t=Bh=UR(NR)),t.writing=!0,this.arena=t,this.buf=t.buf,this.view=t.view,this.start=t.offset,this.limit=t.buf.length-t.offset,this.len=0}ensure(t){if(this.len+t>this.limit){let r=this.arena,n=this.len+t,o=NR;for(;o<n;)o*=2;let s=UR(o);s.writing=!0,s.buf.set(this.buf.subarray(this.start,this.start+this.len)),r.writing=!1,this.arena=Bh=s,this.buf=s.buf,this.view=s.view,this.start=0,this.limit=s.buf.length}}byte(t){this.ensure(1),this.buf[this.start+this.len++]=t}bytes(t){this.ensure(t.length),this.buf.set(t,this.start+this.len),this.len+=t.length}uvarint(t){this.ensure(10);let r=this.buf,n=this.start+this.len;if(t<128)r[n++]=t;else if(r[n++]=t&127|128,t<16384)r[n++]=t>>>7;else{for(r[n++]=t>>>7&127|128,t=Math.floor(t/16384);t>127;)r[n++]=t&127|128,t=Math.floor(t/128);r[n++]=t}this.len=n-this.start}uvarintBig(t){for(;t>$W;)this.byte(Number(t&$W)|128),t>>=f4;this.byte(Number(t))}zigzag(t){this.uvarintBig(t>=gE?t<<ls:(-t<<ls)-ls)}numberVarint(t){let r=t<0||t===0&&1/t<0,n=r?-t:t;n<=mae?this.uvarint(n*2+(r?1:0)):this.uvarintBig(BigInt(n)*uae+(r?ls:gE))}f64(t){this.ensure(8),this.view.setFloat64(this.start+this.len,t,!0),this.len+=8}i64(t){this.ensure(8),this.view.setBigInt64(this.start+this.len,t,!0),this.len+=8}u32le(t){this.ensure(4),this.view.setUint32(this.start+this.len,t>>>0,!0),this.len+=4}i32le(t){this.ensure(4),this.view.setInt32(this.start+this.len,t|0,!0),this.len+=4}idAndMark(t){let r=t.length;this.ensure(r+1);let n=this.buf,o=this.start+this.len;for(let i=0;i<r;i++)n[o++]=t[i];let s=o-this.start;return this.len=s+1,s}beginSized(){return this.ensure(1),this.len++}endSized(t){let r=this.len-t-1;r<128?this.buf[this.start+t]=r:this.growSized(t,r)}endSizedRun(t){let r=(this.len-t-1)*2;r<128?this.buf[this.start+t]=r:this.growSized(t,r)}growSized(t,r){let n=y4(r),o=n-1;this.ensure(o);let s=this.start+t;this.buf.copyWithin(s+n,s+1,this.start+this.len),this.len+=o;let i=r,a=s;for(;i>127;)this.buf[a++]=i&127|128,i=Math.floor(i/128);this.buf[a]=i}string(t){let r=t.length;if(r===0)return;this.ensure(r*3);let n=this.buf,o=this.start+this.len,s=0;for(;s+4<=r;s+=4){let i=t.charCodeAt(s),a=t.charCodeAt(s+1),c=t.charCodeAt(s+2),u=t.charCodeAt(s+3);if((i|a|c|u)>127){this.len+=$i.encodeInto(t,n.subarray(this.start+this.len)).written;return}n[o++]=i,n[o++]=a,n[o++]=c,n[o++]=u}for(;s<r;s++){let i=t.charCodeAt(s);if(i>127){this.len+=$i.encodeInto(t,n.subarray(this.start+this.len)).written;return}n[o++]=i}this.len=o-this.start}out(){let t=this.arena,r=new Uint8Array(t.buf.buffer,this.start,this.len);return t===Bh&&(t.offset=this.start+this.len),t.writing=!1,this.arena=void 0,r}abort(){let t=this.arena;t!==void 0&&(t===Bh&&(t.offset=this.start),t.writing=!1,this.arena=void 0)}};function Rae(e){let t=Bn(e);return t._tag==="String"&&t.checks===void 0}function Oae(e,t,r){return e.extra.find(n=>_i({[t]:null},n.parameter,r).length>0)}var $h=class{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(t,r){this.options=t,this.orderLayouts=r===void 0?void 0:new Array(r),this.orderKeys=r===void 0?void 0:new Array(r)}beginFrame(){this.replace=!0}find(t,r){let n=this.entries.get(t);if(n===void 0&&(n=new Map,this.entries.set(t,n)),n.has(r))return n.get(r);let o=Oae(t,r,this.options),s=this.orderLayouts;if(s===void 0)return n.set(r,o),o;let i=this.orderKeys;if(this.size<s.length)s[this.size]=t,i[this.size]=r,this.size++,n.set(r,o);else if(this.replace){this.replace=!1;let a=s[this.next];(a===t?n:this.entries.get(a))?.delete(i[this.next]),s[this.next]=t,i[this.next]=r,this.next=(this.next+1)%s.length,n.set(r,o)}return o}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}},EE=new ArrayBuffer(0),DR=new Uint8Array(EE),WW=new DataView(EE),Hh=class{pos=0;nesting=0;buf=DR;view;viewCache=WW;viewBuffer=EE;viewOffset=0;viewLength=0;end=0;options=nn;indexSignatures;positional=!1;intern;dict;reset(t,r,n,o,s,i,a){this.nesting=0,this.view=void 0,this.buf=t,this.pos=r,this.end=n,this.options=o,this.indexSignatures=s,this.positional=i,this.intern=void 0,this.dict=a}release(){this.pos=this.end=this.nesting=0,this.buf=DR,this.view=void 0,this.viewCache=WW,this.viewBuffer=EE,this.viewOffset=this.viewLength=0,this.options=nn,this.indexSignatures=void 0,this.positional=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let t=this.buf;return(t.buffer!==this.viewBuffer||t.byteOffset!==this.viewOffset||t.byteLength!==this.viewLength)&&(this.viewBuffer=t.buffer,this.viewOffset=t.byteOffset,this.viewLength=t.byteLength,this.viewCache=new DataView(t.buffer,t.byteOffset,t.byteLength)),this.view=this.viewCache}byte(){return this.pos>=this.end&&H("complete value",void 0,this.options),this.buf[this.pos++]}take(t){this.pos+t>this.end&&H("complete value",void 0,this.options);let r=this.buf.subarray(this.pos,this.pos+t);return this.pos+=t,r}takeCopy(t){this.pos+t>this.end&&H("complete value",void 0,this.options);let r=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,r}enter(t){this.pos+t>this.end&&H("complete value",void 0,this.options);let r=this.end;return this.end=this.pos+t,r}exit(t){this.pos=this.end,this.end=t}readUtf8(t){this.pos+t>this.end&&H("complete value",void 0,this.options);let r=this.pos;return this.pos+=t,wae(this.buf,r,r+t,this.options)}uvarint(){let t=this.buf,r=this.end,n=this.pos;n>=r&&H("complete value",void 0,this.options);let o=t[n++];if(o<128)return this.pos=n,o;let s=o&127;if(n>=r&&H("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<7,o<128)return this.pos=n,s;if(n>=r&&H("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<14,o<128)return this.pos=n,s;if(n>=r&&H("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<21,o<128)return this.pos=n,s;let i=268435456;for(let a=4;a<10;a++){n>=r&&(this.pos=n,H("complete value",void 0,this.options)),o=t[n++];let c=(o&127)*i;if(c>Number.MAX_SAFE_INTEGER-s&&(this.pos=n,H("safe integer length",void 0,this.options)),s+=c,o<128)return this.pos=n,s;i*=128}this.pos=n,H("uvarint",void 0,this.options)}fieldTag(){let t=this.buf,r=this.end,n=this.pos;n>=r&&H("complete value",void 0,this.options);let o=t[n++];if(o<128)return this.pos=n,o;let s=o&127;return n>=r&&H("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<7,o<128?(this.pos=n,s):(n>=r&&H("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<14,o<128?(this.pos=n,s):(n>=r&&H("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<21,o<128?(this.pos=n,s):(n>=r&&H("complete value",void 0,this.options),o=t[n++],this.pos=n,o>=128&&H("uvarint",void 0,this.options),s+o*268435456)))}uvarintBig(){let t=gE,r=gE;for(;;){let n=this.byte();if(t|=BigInt(n&127)<<r,(n&128)===0)return t;r+=f4}}numberVarint(){let t=this.buf,r=this.end,n=this.pos,o=0,s=1;for(let c=0;c<l4;c++){n>=r&&(this.pos=n,H("complete value",void 0,this.options));let u=t[n++];if(o+=(u&127)*s,u<128)return this.pos=n,h4(o);s*=128}let i=this.uvarintBig(),a=Number(i>>ls);return Number.isFinite(a)||H("safe integer length",void 0,this.options),(i&ls)===ls?-a:a}zigzag(){let t=this.uvarintBig();return(t&ls)===ls?-(t+ls>>ls):t>>ls}f64(){this.pos+8>this.end&&H("complete value",void 0,this.options);let t=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,t}i64(){this.pos+8>this.end&&H("complete value",void 0,this.options);let t=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,t}u32le(){this.pos+4>this.end&&H("complete value",void 0,this.options);let t=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,t}i32le(){this.pos+4>this.end&&H("complete value",void 0,this.options);let t=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,t}};function KW(e,t){return{_:"literal",leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function Jh(e,t){let r=e.values;return e.valueSet!==void 0?e.valueSet.has(t):r.length===1?t===r[0]:r.includes(t)}function vE(e){return e.values.map(t=>typeof t=="string"?JSON.stringify(t):String(t)).join(" | ")}var pE=0,VR=1,S4=2,b4=3,E4=30,mE=1<<E4;function CE(e){return e._==="literal"?CE(e.leaf):e._==="int"}function AE(e){switch(e._){case"literal":return AE(e.leaf);case"bool":return 1;case"int64":return 8;default:return}}function LR(e){return AE(e)!==void 0||CE(e)||e._==="null"||e._==="undefined"}function I4(e){return e._==="literal"?I4(e.leaf):e._==="null"||e._==="undefined"}var jh={"effect/schema/Date":{kind:dt.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:dt.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:dt.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:dt.duration,exact:!0},"effect/schema/BigDecimal":{kind:dt.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:dt.bytes,exact:!0},"effect/schema/Option":{kind:dt.option,exact:"parameters"},"effect/schema/Result":{kind:dt.result,exact:"parameters"},"effect/schema/Exit":{kind:dt.exit,exact:"parameters"},"effect/schema/Cause":{kind:dt.cause,exact:"parameters"},"effect/schema/CauseReason":{kind:dt.causeReason,exact:"parameters"}};function kd(e){let t=e.annotations?.representation;return Gt(t)&&typeof t.id=="string"?t.id:void 0}var hE=ma(e=>{let t=_ae(e),r=e.context;return t===e||r===void 0?t:$l(t,new Yo(r.isOptional,r.isMutable,void 0,r.annotations))});function _ae(e){switch(e._tag){case"Declaration":{let t=kd(e);if(t!==void 0&&(t in jh||t==="effect/schema/Json"||t==="effect/schema/MutableJson"))return e.recur(hE);let r=e.annotations?.toCodecJson,n=e.annotations?.toCodec;if(!or(r)&&!or(n))return e;let o=e.typeParameters.map(i=>G(Bn(i))),s=(or(r)?r(o):void 0)??(or(n)?n(o):void 0);return s===void 0?e:lt(e,[fc(s,hE)])}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(hE);default:return e}}function Pae(e){let t=[...e].sort((n,o)=>{let s=typeof n.key=="number",i=typeof o.key=="number";return s!==i?s?-1:1:s?n.key-o.key:g4($i.encode(n.key),$i.encode(o.key))}),r=[];for(let n of t){let o=$i.encode(String(n.key));r.push(typeof n.key=="number"?0:1),SE(r,o.length),yE(r,o);let s=n.literal,i=$i.encode(w4(s));r.push(T4(s)),SE(r,i.length),yE(r,i)}return x4(r)}function T4(e){switch(typeof e){case"string":return 1;case"number":return 2;case"boolean":return 3;case"bigint":return 4;default:return 5}}function w4(e){if(typeof e=="symbol"){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return t}return String(e)}function v4(e){switch(e._tag){case"Symbol":return!0;case"Union":return e.types.some(v4);default:return!1}}function C4(e){let t=kd(e);return t==="effect/schema/Json"||t==="effect/schema/MutableJson"?!0:or(e.annotations?.toCodecJson)}function Mae(e){let t=e.checks;if(t===void 0)return!1;let r=n=>n.annotations?.representation?.id==="effect/schema/isInt"?!0:n._tag==="FilterGroup"&&n.checks.some(r);return t.some(r)}function A4(e){for(;e._tag==="Suspend";)e=e.thunk();return e}function k4(e){return new Sn(e.enums.map(t=>new Ln(t[1],{title:t[0]})))}function VW(e){let t=[],r=new Set,n=o=>{let s=A4(o);if(!r.has(s))switch(r.add(s),s._tag){case"Never":return;case"Union":s.types.forEach(n);return;case"Enum":k4(s).types.forEach(n);return;default:t.push(s)}};return e.types.forEach(n),t}function JW(e){switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"bool";default:return"bigint"}}function xE(e){switch(e._tag){case"String":case"TemplateLiteral":case"Symbol":return dt.string;case"UniqueSymbol":if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return dt.string;case"Boolean":return dt.bool;case"Null":return dt.null;case"Undefined":case"Void":return dt.undefined;case"Number":return dt.number;case"BigInt":return dt.bigint;case"Literal":switch(typeof e.literal){case"string":return dt.string;case"number":return dt.number;case"boolean":return dt.bool;default:return dt.bigint}case"Unknown":case"Any":case"ObjectKeyword":return dt.json;case"Objects":return dt.struct;case"Arrays":return dt.array;case"Declaration":{let t=kd(e);if(t!==void 0&&t in jh)return jh[t].kind;if(C4(e))return dt.json;throw new Error(`Binary layout: declaration ${t??"<anonymous>"} has no toCodecJson or toCodec`)}case"Suspend":return xE(A4(e));default:throw new Error("Binary layout: union members are not uniquely identifiable")}}function GW(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function Fae(e){let t=R4(e),r=!t&&Nae(e);e=Bn(e);let n=new Map,o=!1,s=0,i=x=>({_:x,slot:x==="string"?s++:0});function a(x){let g=n.get(x);if(g!==void 0)return g;let y=c(x);return n.set(x,y),y}function c(x){switch(x._tag){case"String":case"TemplateLiteral":return i("string");case"Symbol":case"UniqueSymbol":return i("symbol");case"Boolean":return i("bool");case"Null":return i("null");case"Undefined":case"Void":return i("undefined");case"Number":return i(Mae(x)?"int":"number");case"BigInt":return i("bigint");case"Literal":return KW(i(JW(x.literal)),[x.literal]);case"Unknown":case"Any":case"ObjectKeyword":return i("json");case"Never":return{_:"never",ast:x};case"Enum":return m(x,VW(k4(x)));case"Suspend":{o=!0;let g=a(x.thunk());return n.set(x,g),g}case"Objects":return u(x);case"Arrays":return f(x);case"Union":return m(x,VW(x));case"Declaration":return p(x)}}function u(x){let g=[],y=[],E=new Map;for(let T of x.propertySignatures){if(typeof T.name=="symbol")throw new Error("Binary layout: symbol property names are illegal");let S=String(T.name),w=T.type.context?.annotations,k=w?.[iae],C=typeof k=="number"?k:x4($i.encode(S));if(!Number.isInteger(C)||C<0||C>4294967295)throw new Error(`Binary layout: illegal field id for ${S}`);let R=E.get(C);R===void 0?E.set(C,[S]):R.push(S),g.push({name:S,id:C,tagBytes:Iae(C*ds+Sf),index:0,optional:T.type.context?.isOptional===!0,annotations:w,layout:void 0,wireMask:0,inline:!1}),y.push(T.type)}for(let[T,S]of E)if(T===0||S.length>1)throw new Error(`Binary layout field id collision: ${T} (${S.join(", ")})`);let b=[];for(let T of x.indexSignatures){if(v4(T.parameter))throw new Error("Binary layout: symbol property names are illegal");b.push({parameter:T.parameter,layout:void 0,wireMask:0})}let v={_:"struct",ast:x,fields:g,byId:new Map,extra:b,extraAll:b.length===1&&Rae(b[0].parameter)?b[0]:void 0,names:new Set(g.map(T=>T.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};n.set(x,v);for(let T=0;T<g.length;T++){let S=g[T];S.layout=a(y[T]),S.wireMask=jR(S.layout),S.inline=LR(S.layout),S.optional&&v.optionalCount++,v.byId.set(S.id,S)}g.sort((T,S)=>T.id-S.id);for(let T=0;T<g.length;T++)g[T].index=T;GW(v);for(let T=0;T<b.length;T++)b[T].layout=a(x.indexSignatures[T].type),b[T].wireMask=jR(b[T].layout);return v}function f(x){let g=x.rest.length>0||x.elements.some(v=>v.context?.isOptional===!0),y=x.elements.filter(v=>v.context?.isOptional!==!0).length,E=Math.max(0,x.rest.length-1),b={_:"array",ast:x,elements:[],rest:[],hasCount:g,minCount:y+E,uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};n.set(x,b);for(let v of x.elements)b.elements.push({optional:v.context?.isOptional===!0,layout:a(v)});for(let v of x.rest)b.rest.push(a(v));if(b.elements.length===0&&b.rest.length===1){let v=b.rest[0];b.uniform=v,b.uniformPacked=AE(v),b.uniformNumbers=v._==="number",b.uniformInline=LR(v)}return b}function p(x){let g=kd(x);switch(g){case"effect/schema/Date":return{_:"int64",flavor:"date"};case"effect/schema/DateTimeUtc":return{_:"int64",flavor:"utc"};case"effect/schema/DateTimeZoned":return i("dateTimeZoned");case"effect/schema/Duration":return i("duration");case"effect/schema/BigDecimal":return i("bigDecimal");case"effect/schema/Uint8Array":return i("bytes")}let y=x.typeParameters;switch(g){case"effect/schema/Option":{let E={_:"option",value:void 0};return n.set(x,E),E.value=a(y[0]),E}case"effect/schema/Result":{let E={_:"result",success:void 0,failure:void 0};return n.set(x,E),E.success=a(y[0]),E.failure=a(y[1]),E}case"effect/schema/Exit":{let E={_:"cause",error:void 0,defect:void 0},b={_:"exit",value:void 0,cause:E};return n.set(x,b),b.value=a(y[0]),E.error=a(y[1]),E.defect=a(y[2]),b}case"effect/schema/Cause":case"effect/schema/CauseReason":{let E={_:g==="effect/schema/Cause"?"cause":"causeReason",error:void 0,defect:void 0};return n.set(x,E),E.error=a(y[0]),E.defect=a(y[1]),E}}if(g!==void 0&&g in jh)throw new Error(`Binary layout: native declaration ${g} has no layout constructor`);if(C4(x))return i("json");throw new Error(`Binary layout: declaration ${g??"<anonymous>"} has no toCodecJson or toCodec`)}function m(x,g){if(g.length===0)return{_:"never",ast:x};let y=[],E=[],b=new Map,v=new Map,T=(R,M)=>{let $=b.get(R);if($!==void 0&&$._!==M._)throw new Error("Binary layout: union members are not uniquely identifiable");b.set(R,M)};for(let R of g){if(R._tag==="Literal"){let M=xE(R),$=v.get(M);$===void 0?v.set(M,[R.literal]):$.includes(R.literal)||$.push(R.literal);continue}if(R._tag==="UniqueSymbol"){xE(R),T(dt.string,i("symbol"));continue}if(R._tag==="Objects"||R._tag==="Arrays"){let M=ac(R);if(M!==void 0&&M.length>0){for(let $ of M)if(typeof $.key=="symbol")throw new Error("Binary layout: symbol property names are illegal");y.push({member:R,sentinels:M});continue}}E.push({member:R,kind:xE(R)})}for(let[R,M]of v)T(R,KW(i(JW(M[0])),M));if(y.length===0&&E.length===0&&b.size===1)return b.values().next().value;let S=new Set(b.keys());for(let{kind:R}of E){if(S.has(R))throw new Error("Binary layout: union members are not uniquely identifiable");S.add(R)}if(y.length===0&&b.size===0&&E.length===1){let R=a(E[0].member);return n.set(x,R),R}let w=new Map,k=[];for(let{sentinels:R}of y){let M=Pae(R);if(w.has(M))throw new Error(`Binary layout sentinel collision: ${M}`);w.set(M,R),k.push(M)}let C={_:"union",ast:x,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};n.set(x,C);for(let R=0;R<y.length;R++){let{member:M,sentinels:$}=y[R],te=k[R],xe=a(M),Le,Er;if(M._tag==="Objects"){let Oe=xe,rr=new Set($.map(Rn=>String(Rn.key))),lo=Oe.fields.filter(Rn=>!rr.has(Rn.name)),Xs={_:"struct",ast:Oe.ast,fields:lo,byId:new Map(lo.map(Rn=>[Rn.id,Rn])),extra:Oe.extra,extraAll:Oe.extraAll,names:Oe.names,extraShape:void 0,optionalCount:lo.reduce((Rn,eI)=>eI.optional?Rn+1:Rn,0),requiredMask:0,requiredWide:!1};GW(Xs),Le=Xs,Er=!1}else Le=xe,Er=!0;let Ee={tag:te,sentinels:$,tuple:Er,payload:Le,position:0};C.variants.push(Ee),C.byTag.set(te,Ee)}for(let[R,M]of b)C.others.push({kind:R,layout:M,position:0}),C.byKind.set(R,M);for(let{kind:R,member:M}of E){let $=a(M);C.others.push({kind:R,layout:$,position:0}),C.byKind.set(R,$)}for(let R of[...C.variants].sort((M,$)=>M.tag-$.tag))R.position=C.byPos.length,C.byPos.push({variant:R,layout:R.payload});for(let R of[...C.others].sort((M,$)=>M.kind-$.kind))R.position=C.byPos.length,C.byPos.push({variant:void 0,layout:R.layout});return C.others.sort((R,M)=>ZW(R.layout)-ZW(M.layout)),C.discriminator=fce(C.variants),C}return{layout:a(e),recursive:o,exact:t,exitSuccess:r}}function R4(e){let t=new Map,r=n=>{if(n.encoding!==void 0||n.checks!==void 0||n.encodingChecks!==void 0)return!1;switch(n._tag){case"String":case"Symbol":case"Boolean":case"Null":case"Undefined":case"Void":case"Number":case"BigInt":case"Literal":return!0;case"Never":return!0;case"Unknown":case"Any":return!0;case"Arrays":return n.elements.every(r)&&n.rest.every(r);case"Objects":return n.propertySignatures.every(o=>r(o.type))&&n.indexSignatures.every(o=>o.parameter._tag==="String"&&r(o.parameter)&&r(o.type));case"Union":return(n.options?.mode??"anyOf")==="anyOf"&&n.types.every(r);case"Suspend":{let o=t.get(n);if(o!==void 0)return o;t.set(n,!0);let s=r(n.thunk());return t.set(n,s),s}case"Declaration":{let o=kd(n),s=o!==void 0?jh[o]:void 0;return s===void 0?!1:s.exact===!0||n.typeParameters.every(r)}default:return!1}};return r(e)}function Nae(e){return e._tag==="Declaration"&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&kd(e)==="effect/schema/Exit"&&R4(e.typeParameters[0])}var uo={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25};function Uae(e){let t=new Map,r=[],n=Number.MAX_SAFE_INTEGER;function o(i){let a=r.lastIndexOf(i);if(a>=0){a<n&&(n=a);let h=[uo.backEdge];return Oc(h,r.length-a),zW(h)}let c=t.get(i);if(c!==void 0)return c;let u=r.length,f=n;n=Number.MAX_SAFE_INTEGER,r.push(i);let p=zW(s(i));r.pop();let m=n>=u;return m&&t.set(i,p),n=m?f:Math.min(f,n),p}function s(i){let a=[];switch(i._){case"bool":case"null":case"undefined":case"number":case"int":case"string":case"symbol":case"bytes":case"bigint":case"json":case"duration":case"bigDecimal":case"dateTimeZoned":return a.push(uo[i._]),a;case"literal":{a.push(uo.literal),yE(a,s(i.leaf)),Oc(a,i.values.length);let c=i.values.map(u=>[T4(u),w4(u)]).sort((u,f)=>u[1]<f[1]?-1:u[1]>f[1]?1:u[0]-f[0]);for(let[u,f]of c){a.push(u);let p=$i.encode(f);Oc(a,p.length),yE(a,p)}return a}case"int64":return a.push(i.flavor==="date"?uo.date:uo.dateTimeUtc),a;case"never":return a.push(uo.never),a;case"struct":{a.push(uo.struct),Oc(a,i.fields.length);for(let c of i.fields)SE(a,c.id),a.push(c.optional?1:0),No(a,o(c.layout));Oc(a,i.extra.length);for(let c of i.extra)No(a,o(c.layout));return a}case"array":{a.push(uo.array),Oc(a,i.elements.length);for(let c of i.elements)a.push(c.optional?1:0),No(a,o(c.layout));Oc(a,i.rest.length);for(let c of i.rest)No(a,o(c));return a}case"union":{a.push(uo.union),Oc(a,i.byPos.length);for(let c of i.byPos){let u=c.variant;u===void 0?a.push(0):(a.push(1,u.tuple?1:0),SE(a,u.tag)),No(a,o(c.layout))}return a}case"option":return a.push(uo.option),No(a,o(i.value)),a;case"result":return a.push(uo.result),No(a,o(i.success)),No(a,o(i.failure)),a;case"exit":return a.push(uo.exit),No(a,o(i.value)),No(a,o(i.cause.error)),No(a,o(i.cause.defect)),a;case"cause":case"causeReason":return a.push(i._==="cause"?uo.cause:uo.causeReason),No(a,o(i.error)),No(a,o(i.defect)),a}}return o(e)}function Dae(e,t){let r=new Uint8Array(8);for(let n=0;n<4;n++)r[n]=e>>>n*8&255,r[n+4]=t>>>n*8&255;return r}var Lae={positional:!1,envelope:aae,expectedEnvelope:"version 2 envelope, flags 0",fingerprint:new Uint8Array(8)};function Bae(e){let t=Uae(e);return{positional:!0,envelope:cae,expectedEnvelope:"version 2 envelope, flags 1",fingerprint:Dae(Number(t&HW),Number(t>>dae&HW))}}function ZW(e){switch(e._){case"json":return 2;case"struct":return 1;default:return 0}}function BR(e,t){switch(e._){case"literal":return Jh(e,t);case"bool":return typeof t=="boolean";case"null":return t===null;case"undefined":return t===void 0;case"number":case"int":return typeof t=="number";case"string":return typeof t=="string";case"symbol":return typeof t=="symbol";case"bigint":return typeof t=="bigint";case"bytes":return t instanceof Uint8Array;case"int64":return e.flavor==="date"?t instanceof Date:Tu(t)&&t._tag==="Utc";case"dateTimeZoned":return Tu(t)&&t._tag==="Zoned";case"duration":return Qi(t);case"bigDecimal":return Eu(t);case"option":return ci(t);case"result":return Uf(t);case"exit":return ws(t);case"cause":return rl(t);case"causeReason":return nl(t);case"array":return Array.isArray(t);case"struct":return Gt(t)&&!Array.isArray(t);case"json":return!0;case"union":case"never":return!1}}function ut(e,t,r){throw dr(new le({expected:e},t,r))}function kn(e,t=new Set){if(!Dd(e))return!1;let r=Array.isArray(e),n=Object.getPrototypeOf(e);if(r||n===Object.prototype||n===null){if(t.has(e))return!0;t.add(e);try{if(r){for(let o=0;o<e.length;o++)if(kn(e[o],t))return!0}else for(let o of Object.keys(e))if(kn(e[o],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||Tu(e)||Qi(e)||Eu(e))return!1;if(t.has(e))return!0;t.add(e);try{if(ci(e))return de(e)&&kn(e.value,t);if(Uf(e))return kn(tt(e)?e.success:e.failure,t);if(ws(e))return kn(ft(e)?e.value:e.cause,t);if(rl(e))return e.reasons.some(o=>kn(o,t));if(nl(e))switch(e._tag){case"Fail":return kn(e.error,t);case"Die":return kn(e.defect,t);case"Interrupt":return!1}if(Il(e)){for(let o of e)if(kn(o,t))return!0;return!1}if(Ty(e)){for(let[o,s]of e)if(kn(o,t)||kn(s,t))return!0;return!1}if(Ay(e)){for(let o of e)if(kn(o,t))return!0;return!1}if(sm(e))return kn(nc(e),t);for(let o of Object.keys(e))if(kn(e[o],t))return!0}finally{t.delete(e)}return!1}function IE(e,t,r,n){let o=n.beginSized();zr(e,t,r,n),n.endSized(o)}function $ae(e,t,r){let n=globalThis.Symbol.keyFor(t);n===void 0&&ut("registered symbol",t,e.options),r.string(n)}function QW(e,t,r,n){let o=r;switch(o._tag){case"Fail":n.byte(0),zr(e,t.error,o.error,n);return;case"Die":n.byte(1),zr(e,t.defect,o.defect,n);return;case"Interrupt":o.fiberId===void 0?n.byte(2):(n.byte(3),n.f64(o.fiberId))}}function Hae(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function YW(e,t,r){if(e.layout!==t||e.keys.length!==r.length)return!1;for(let n=0;n<r.length;n++)if(e.keys[n]!==r[n])return!1;return!0}function jae(e,t){if(e.extraAll===void 0||t.length>Aae)return!1;let r=0;for(let n=0;n<t.length;n++)if(r+=t[n].length,r>kae)return!1;return!0}function JR(e,t,r){let n=Object.keys(r),o=t.extraShape;if(o!==void 0&&YW(o,t,n))return o.pairs;let s=jae(t,n),i=s?void 0:e.extraShape;if(i!==void 0&&YW(i,t,n))return i.pairs;let a=t.names,c=t.extraAll,u=[],f=!0;for(let m of n){if(a.has(m))continue;let h=c??(e.indexSignatures??=new $h(e.options)).find(t,m);h!==void 0&&(f&&!Hae(m)&&(f=!1),u.push([m,h,void 0]))}if(f)u.sort((m,h)=>m[0]<h[0]?-1:m[0]>h[0]?1:0);else{for(let m of u)m[2]=$i.encode(m[0]);u.sort((m,h)=>g4(m[2],h[2]))}if(s)for(let m of u)m[2]??=$i.encode(m[0]);let p={layout:t,keys:n,pairs:u};return s?t.extraShape=p:e.extraShape=p,u}function GR(e,t,r,n,o){for(let[s,i,a]of t){let c=a===void 0?s.length:a.length,u=r[s],f=ZR(i.layout,u,e.options),p=f%ds;if(o===void 0)n.uvarint(c*ds+p);else{if(!o.disabled){let m=_4(o,s);if(m!==void 0){n.uvarint(m*16+p*2+1),Ze[Q++]=s,$R(e,i.layout,u,f,n),Q--;continue}P4(o,s)}n.uvarint(c*16+p*2)}a===void 0?n.string(s):n.bytes(a),Ze[Q++]=s,$R(e,i.layout,u,f,n),Q--}}function ZR(e,t,r){if(e._==="literal")return Jh(e,t)||ut(vE(e),t,r),ZR(e.leaf,t,r);switch(e._){case"bool":return typeof t!="boolean"&&ut("a boolean",t,r),t?Kh:Wh;case"number":if(typeof t!="number"&&ut("a number",t,r),WR(t))return gf;{let n=KR(t);return n===0?zh:n*ds+Vh}case"int":return Number.isSafeInteger(t)||ut("an integer",t,r),gf;default:return Sf}}function $R(e,t,r,n,o){switch(n%ds){case Wh:case Kh:return;case gf:o.numberVarint(r);return;case zh:o.f64(r);return;case Vh:{let i=Math.floor(n/ds);o.numberVarint(Math.round(r*_c[i])),o.uvarint(i);return}default:IE(e,t,r,o)}}function qae(e,t,r,n){let o=ZR(t.layout,r,e.options),s=o%ds;if(s===Sf){let i=n.idAndMark(t.tagBytes);zr(e,t.layout,r,n),n.endSized(i);return}n.uvarint(t.id*ds+s),$R(e,t.layout,r,o,n)}function zae(e,t){let r=e.byName;if(r===void 0)return;let n=Object.getOwnPropertyNames(t),o=0;for(let i=0;i<n.length;i++){let a=r.get(n[i]);a!==void 0&&(o|=1<<a)}let s=e.struct;if((o&s.requiredMask)!==s.requiredMask){let i=s.fields;for(let a=0;a<i.length;a++){let c=i[a];if(!c.optional&&(o&1<<a)===0)throw Ze[Q++]=c.name,dr(new Yt(c.annotations))}}return o}function Wae(e,t,r,n){let o=r;if(t.extra.length>0){let i=e.intern;e.intern=void 0;let a=JR(e,t,o);if(a.length>0){n.uvarint(0);let c=n.beginSized();GR(e,a,o,n,i),n.endSized(c)}}let s=t.fields;for(let i=0;i<s.length;i++){let a=s[i],c=a.name;if(!Object.hasOwn(o,c)){if(a.optional)continue;throw Ze[Q++]=c,dr(new Yt(a.annotations))}Ze[Q++]=c,qae(e,a,o[c],n),Q--}}function Kae(e,t,r,n){let o=r,s=e.intern;e.intern=void 0;let i=t.optionalCount+7>>3,a=0;if(i>0){a=n.len;for(let f=0;f<i;f++)n.byte(0)}let c=t.fields,u=0;for(let f=0;f<c.length;f++){let p=c[f],m=p.name,h=Object.hasOwn(o,m);if(p.optional){if(h&&(n.buf[n.start+a+(u>>3)]|=1<<(u&7)),u++,!h)continue}else if(!h)throw Ze[Q++]=m,dr(new Yt(p.annotations));Ze[Q++]=m,p.inline?zr(e,p.layout,o[m],n):IE(e,p.layout,o[m],n),Q--}if(t.extra.length>0){let f=JR(e,t,o);n.uvarint(f.length),GR(e,f,o,n,s)}}function Vae(e){switch(e._){case"string":return VR;case"array":return e.uniform?._==="string"?S4:pE;case"struct":return e.extra.length>0?b4:pE;default:return pE}}function Jae(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let r of e.elements)if(r.optional||r.layout!==t)return}return t._==="struct"?t:void 0}function O4(e){let t=e.run;if(t!==void 0)return t;let r=Jae(e);if(r===void 0)return e.run=t=null,t;let n=r.fields.map(s=>Vae(s.layout)),o=r.fields.length<=E4;return t={struct:r,intern:n,shapes:o,byName:o&&r.extra.length===0?new Map(r.fields.map((s,i)=>[s.name,i])):void 0},e.run=t,t}var Gae=16,Zae=64;function XW(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function _4(e,t){let r=e.refs;if(r!==void 0){let o=r.get(t);return o!==void 0&&e.hits++,o}let n=e.values;for(let o=0;o<n.length;o++)if(n[o]===t)return e.hits++,o}function P4(e,t){let r=e.values;if(e.refs!==void 0){if(e.hits===0&&r.length>=Zae){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,r.length)}else if(r.length>=Gae){let n=e.refs=new Map;for(let o=0;o<r.length;o++)n.set(r[o],o);n.set(t,r.length)}r.push(t)}var QR=0,Qae=1,YR=2,Yae=64,Xae=512;function ece(){return{slots:[],marks:[],frame:0}}function M4(e,t){return e[t]??={values:[],refs:new Map,state:QR,stamp:-1}}function F4(e,t){if(e.refs.has(t)){e.state=Qae;return}e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=Yae&&(e.state=YR)}function N4(e,t){let r=e.values;r.length>=Xae||(e.refs.set(t,r.length),r.push(t))}function tce(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function rce(e){e.marks.length=0,e.frame++}function nce(e){let t=e.marks;for(let r=t.length-1;r>=0;r--){let{length:n,slot:o,state:s}=t[r],i=o.values;for(let a=n;a<i.length;a++)o.refs.delete(i[a]);i.length=n,o.state=s}t.length=0,e.frame++}function oce(e,t,r,n){let o=M4(e.slots,t.slot),s=o.state;if(s===YR){n.string(r);return}if(tce(e,o),s===QR){n.string(r),F4(o,r);return}let i=o.refs.get(r);if(i!==void 0){n.uvarint(i*2+1);return}n.byte(0),N4(o,r),n.string(r)}function sce(e,t,r){let n=M4(e,t.slot),o=n.state;if(o===YR)return r.readUtf8(r.end-r.pos);if(o===QR){let a=r.readUtf8(r.end-r.pos);return F4(n,a),a}let s=r.uvarint();if((s&1)===1){let a=(s-1)/2,c=n.values;return a>=c.length&&H("a dictionary reference",s,r.options),c[a]}s!==0&&H("a dictionary marker",s,r.options);let i=r.readUtf8(r.end-r.pos);return N4(n,i),i}function U4(e,t,r,n,o){if(!e.disabled){let i=_4(e,n);if(i!==void 0){o.uvarint(i*2+1);return}P4(e,n)}let s=o.beginSized();zr(t,r,n,o),o.endSizedRun(s)}function ice(e,t,r,n,o){let s=[],i=[];for(let a=0;a<n;a++){Ze[Q++]=a;let c=o.beginSized();ace(e,t,s,i,r[a],o),o.endSized(c),Q--}}function ace(e,t,r,n,o,s){let i=t.struct,a=o,c=i.fields,u;if(i.extra.length>0){let y=JR(e,i,a);y.length>0&&(u=y)}let f=!t.shapes,p=u===void 0?0:mE,m=zae(t,a);if(m!==void 0)p=m;else for(let y=0;y<c.length;y++){let E=c[y];if(Object.hasOwn(a,E.name))f||(p|=1<<y);else if(!E.optional)throw Ze[Q++]=E.name,dr(new Yt(E.annotations))}let h=-1;for(let y=0;y<r.length;y++)if(r[y]===p){h=y;break}h>=0?s.uvarint(h+1):(s.uvarint(0),f||r.push(p));let x=h<0,g=e.positional&&!f;if(x&&g&&s.uvarint(p),u!==void 0){x&&!g&&s.uvarint(0);let y=s.beginSized();GR(e,u,a,s),s.endSizedRun(y)}for(let y=0;y<c.length;y++){let E=c[y];if(f?!Object.hasOwn(a,E.name):(p&1<<y)===0)continue;x&&!g&&s.uvarint(E.id),Ze[Q++]=E.name;let b=t.intern[y];if(b===VR)U4(XW(n,y),e,E.layout,a[E.name],s);else{b!==pE&&(e.intern=XW(n,y));let v=s.beginSized();zr(e,E.layout,a[E.name],s),s.endSizedRun(v),e.intern=void 0}Q--}}function D4(e,t,r){let n=e.elements.length;if(t<n)return e.elements[t].layout;let o=Math.max(0,e.rest.length-1),s=Math.max(n,r-o);return t>=s?e.rest[t-s+1]:e.rest[0]}function cce(e,t,r,n){let o=r.length;if(t.rest.length===0&&o>t.elements.length)throw Ze[Q++]=t.elements.length,dr(new Mu(t.ast,r[t.elements.length],e.options));if(o<t.minCount)throw Ze[Q++]=o,dr(new Yt(void 0));if(t.hasCount&&n.uvarint(o),o>0){let i=O4(t);if(i!==null){ice(e,i,r,o,n);return}}let s=t.uniform;if(s!==void 0){if(t.uniformNumbers){uce(e,r,o,n);return}let i=e.intern;if(e.intern=void 0,i!==void 0){for(let c=0;c<o;c++)Ze[Q++]=c,U4(i,e,s,r[c],n),Q--;return}let a=t.uniformInline;for(let c=0;c<o;c++)Ze[Q++]=c,a?zr(e,s,r[c],n):IE(e,s,r[c],n),Q--;return}for(let i=0;i<o;i++){let a=D4(t,i,o);Ze[Q++]=i,LR(a)?zr(e,a,r[i],n):IE(e,a,r[i],n),Q--}}var e4=[];function uce(e,t,r,n){let o=!0,s=!0;for(let i=0;i<r;i++){let a=t[i];if(typeof a!="number"&&(Ze[Q++]=i,ut("a number",a,e.options)),WR(a))(a<0?-a:a)>FR&&(s=!1);else{o=!1;let c=KR(a);c===0?s=!1:e4[i]=c}if(!o&&!s)break}if(o){n.byte(p4);for(let i=0;i<r;i++)n.numberVarint(t[i])}else if(s){n.byte(m4);for(let i=0;i<r;i++){let a=t[i],c=Number.isInteger(a)?0:e4[i],u=c===0?a:Math.round(a*_c[c]),f=u<0||u===0&&1/u<0,p=f?-u:u;n.uvarint((p*2+(f?1:0))*16+c)}}else{n.byte(d4);for(let i=0;i<r;i++)n.f64(t[i])}}function fce(e){if(!(e.length<2||e.some(t=>t.tuple)))for(let t of e[0].sentinels){let r=new Map;for(let n of e){let o=n.sentinels.find(s=>s.key===t.key);if(o===void 0||r.has(o.literal)||Number.isNaN(o.literal))break;r.set(o.literal,n)}if(r.size===e.length)return{key:t.key,rows:r}}}function HR(e,t){let r=e.sentinels;for(let n=0;n<r.length;n++){let{key:o,literal:s}=r[n];if(t[o]!==s||!Object.hasOwn(t,o))return!1}return!0}function lce(e,t){return e.tuple?Array.isArray(t)&&HR(e,t):Gt(t)&&!Array.isArray(t)&&HR(e,t)}function t4(e,t,r,n){e.positional?n.uvarint(t.position):(n.byte(dt.variant),n.u32le(t.tag)),zr(e,t.payload,r,n)}function dce(e,t,r,n){let o=t.discriminator;if(o!==void 0){if(Gt(r)&&!Array.isArray(r)){let s=r,i=o.rows.get(s[o.key]);if(i!==void 0&&HR(i,s)){t4(e,i,r,n);return}}}else for(let s of t.variants)if(lce(s,r)){t4(e,s,r,n);return}for(let s of t.others)if(BR(s.layout,r)){e.positional?n.uvarint(s.position):n.byte(s.kind),zr(e,s.layout,r,n);return}throw dr(new at(t.ast,r,e.options))}function zr(e,t,r,n){switch(t._){case"literal":Jh(t,r)||ut(vE(t),r,e.options),zr(e,t.leaf,r,n);return;case"bool":typeof r!="boolean"&&ut("a boolean",r,e.options),n.byte(r===!0?1:0);return;case"null":r!==null&&ut("null",r,e.options);return;case"undefined":r!==void 0&&ut("undefined",r,e.options);return;case"number":{if(typeof r!="number"&&ut("a number",r,e.options),WR(r)){n.numberVarint(r);return}let o=KR(r);o>0?(n.numberVarint(Math.round(r*_c[o])),n.byte(o)):n.f64(r);return}case"int":{Number.isSafeInteger(r)||ut("an integer",r,e.options),n.numberVarint(r);return}case"string":{typeof r!="string"&&ut("a string",r,e.options);let o=e.dict;o===void 0?n.string(r):oce(o,t,r,n);return}case"symbol":typeof r!="symbol"&&ut("a symbol",r,e.options),$ae(e,r,n);return;case"bytes":r instanceof Uint8Array||ut("a Uint8Array",r,e.options),n.bytes(r);return;case"bigint":typeof r!="bigint"&&ut("a bigint",r,e.options),n.zigzag(r);return;case"int64":{BR(t,r)||ut(t.flavor==="date"?"a Date":"a DateTime.Utc",r,e.options);let o=t.flavor==="date"?r.getTime():r.epochMilliseconds;Number.isNaN(o)&&ut("a valid Date",r,e.options),n.i64(BigInt(o));return}case"dateTimeZoned":{BR(t,r)||ut("a DateTime.Zoned",r,e.options);let o=r;n.i64(BigInt(o.epochMilliseconds)),o.zone._tag==="Offset"?(n.byte(0),n.i32le(o.zone.offset)):(n.byte(1),n.string(o.zone.id));return}case"duration":{Qi(r)||ut("a Duration",r,e.options);let o=r.value;switch(o._tag){case"Infinity":n.byte(1);return;case"NegativeInfinity":n.byte(2);return;case"Nanos":n.byte(0),n.zigzag(o.nanos);return;case"Millis":n.byte(0),n.zigzag(BigInt(o.millis)*fae);return}}case"bigDecimal":{Eu(r)||ut("a BigDecimal",r,e.options);let o=Qp(r);n.zigzag(o.value),n.zigzag(BigInt(o.scale));return}case"json":{let o;try{o=JSON.stringify(r)}catch{o=void 0}o===void 0&&(kn(r)&&ut("acyclic value",r,e.options),ut("a JSON-serializable value",r,e.options)),n.string(o);return}case"option":{ci(r)||ut("an Option",r,e.options);let o=r;o._tag==="None"?n.byte(0):(n.byte(1),zr(e,t.value,o.value,n));return}case"result":{Uf(r)||ut("a Result",r,e.options);let o=r;o._tag==="Success"?(n.byte(0),zr(e,t.success,o.success,n)):(n.byte(1),zr(e,t.failure,o.failure,n));return}case"exit":{ws(r)||ut("an Exit",r,e.options);let o=r;o._tag==="Success"?(n.byte(0),zr(e,t.value,o.value,n)):(n.byte(1),zr(e,t.cause,o.cause,n));return}case"cause":{rl(r)||ut("a Cause",r,e.options);let o=r.reasons;n.uvarint(o.length);for(let s of o){let i=n.beginSized();QW(e,t,s,n),n.endSized(i)}return}case"causeReason":{nl(r)||ut("a Cause.Reason",r,e.options),QW(e,t,r,n);return}case"struct":{(!Gt(r)||Array.isArray(r))&&ut("an object",r,e.options),e.positional?Kae(e,t,r,n):Wae(e,t,r,n);return}case"array":{Array.isArray(r)||ut("an array",r,e.options),cce(e,t,r,n);return}case"union":dce(e,t,r,n);return;case"never":throw dr(new at(t.ast,r,e.options))}}var lE=new bE;function r4(e,t,r,n,o){let s=o.beginSized();o.byte(n.envelope),n.positional&&o.bytes(n.fingerprint),zr(e,t,r,o),o.endSized(s)}function L4(e,t,r,n,o,s){let i={options:n,positional:o.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:s},a=lE??new bE,c=a===lE;c&&(lE=void 0),a.reset();let u=Q,f=!1;try{if(r===void 0)Q=0,r4(i,e,t,o,a);else for(let m=0;m<r.length;m++)Q=0,r4(i,e,r[m],o,a);let p=a.out();return f=!0,p}finally{s!==void 0&&(f?rce(s):nce(s)),a.abort(),Q=u,c&&(lE=a)}}function B4(e,t,r,n,o){return L4(e,void 0,t,r,n,o)}function TE(e,t,r,n,o){return L4(e,t,void 0,r,n,o)}function kE(e){return ws(e)&&ft(e)}var kr=globalThis.Symbol.for("~effect/encoding/SchemaBinary/absent");function un(e,t){let r=qh(e,t);return r!==kr&&t.pos!==t.end&&H("no leftover bytes",void 0,t.options),r}function $4(e,t){let r=t.enter(t.uvarint()),n=un(e,t);return t.exit(r),n}function H4(e,t){if(CE(e))return qh(e,t);let r=AE(e),n=t.enter(r!==void 0?r:e._==="null"||e._==="undefined"?0:t.uvarint()),o=un(e,t);return t.exit(n),o}var pce=8;function mce(e,t){let r=e.set;if(r!==void 0)return r.has(t)?!0:(r.add(t),!1);let n=e.list;if(n.includes(t))return!0;if(n.length>=pce){let o=e.set=new Set;for(let s=0;s<n.length;s++)o.add(n[s]);o.add(t)}else n.push(t);return!1}function j4(e,t,r,n,o){let s=t.uvarint(),i=Math.floor(o===void 0?s/ds:s/16),a=o===void 0?s-i*ds:Math.floor((s-i*16)/2),c=o===void 0?t.readUtf8(i):hce(o,s,i,t);e.names.has(c)&&H("an extra key distinct from declared fields",c,t.options),mce(n,c)&&H("unique extra keys",void 0,t.options);let u=e.extraAll??(t.indexSignatures??=new $h(t.options)).find(e,c);if(u===void 0){XR(a,t);return}Ze[Q++]=c;let f=W4(u.layout,u.wireMask,a,t);Q--,f!==kr&&B(r,c,f)}function hce(e,t,r,n){if((t&1)===1)return r>=e.length&&H("a known back-reference",void 0,n.options),e[r];let o=n.readUtf8(r);return e.push(o),o}function q4(e){return new Ct([e.name],new Yt(e.annotations))}function z4(e,t){throw dr(new Pt(e.ast,t))}function _R(e){for(;(e.byte()&128)!==0;);}function XR(e,t){switch(e){case Sf:t.take(t.uvarint());return;case gf:_R(t);return;case zh:t.take(8);return;case Wh:case Kh:case yae:return;case Vh:_R(t),_R(t);return;case gae:t.take(4);return}}function jR(e){if(e._==="literal")return jR(e.leaf);switch(e._){case"bool":return 1<<Wh|1<<Kh;case"number":return 1<<gf|1<<zh|1<<Vh;case"int":return 1<<gf;default:return 1<<Sf}}function xce(e,t){switch(e){case Wh:return!1;case Kh:return!0;case gf:return t.numberVarint();case zh:return t.f64();case Vh:{let r=t.numberVarint(),n=t.uvarint();return(n===0||n>wE)&&H("a decimal scale in [1, 8]",n,t.options),r/_c[n]}}return H("matching field wire kind",void 0,t.options)}function W4(e,t,r,n){if((t&1<<r)===0)return XR(r,n),kr;if(r!==Sf){let i=xce(r,n);return e._==="literal"&&!Jh(e,i)&&H(vE(e),i,n.options),i}let o=n.enter(n.uvarint()),s=un(e,n);return n.exit(o),s}function gce(e,t){let r;e.extra.length>0&&(r=t.intern,t.intern=void 0);let n={},o=0,s=0,i,a,c,u=!1,f=e.fields,p=0;for(;t.pos<t.end;){let m=t.fieldTag(),h=Math.floor(m/ds),x=m-h*ds;if(h===0){u&&H("unique field ids",void 0,t.options),u=!0,x!==Sf&&H("extra field map",void 0,t.options);let b=t.enter(t.uvarint());V4(e,t,n,r),t.exit(b);continue}let g;if(p<f.length&&f[p].id===h?(g=f[p],p++):(g=e.byId.get(h),g!==void 0&&(p=g.index+1)),g===void 0){c===void 0?c=new Set:c.has(h)&&H("unique field ids",void 0,t.options),c.add(h),XR(x,t);continue}let y=g.index;if(y<32){let b=1<<y;(o&b)!==0&&H("unique field ids",void 0,t.options),o|=b}else i===void 0?i=new Set([y]):(i.has(y)&&H("unique field ids",void 0,t.options),i.add(y));Ze[Q++]=g.name;let E=W4(g.layout,g.wireMask,x,t);Q--,E!==kr&&(B(n,g.name,E),y<32?s|=1<<y:(a??=new Set).add(y))}return K4(e,s,a,t),n}function K4(e,t,r,n){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let o=e.fields,s;for(let i=0;i<o.length;i++){let a=o[i],c=a.index,u=c<32?(t&1<<c)!==0:r?.has(c)===!0;if(!a.optional&&!u&&((s??=[]).push(q4(a)),n.options.errors!=="all"))break}s!==void 0&&z4(e,s)}function yce(e,t){let r;e.extra.length>0&&(r=t.intern,t.intern=void 0);let n={},o=e.optionalCount+7>>3,s=0;o>0&&(t.pos+o>t.end&&H("complete value",void 0,t.options),s=t.pos,t.pos+=o);let i=t.buf,a=e.fields,c=0,u;for(let f=0;f<a.length;f++){let p=a[f];if(p.optional){let h=(i[s+(c>>3)]&1<<(c&7))!==0;if(c++,!h)continue}Ze[Q++]=p.name;let m=p.inline?H4(p.layout,t):$4(p.layout,t);if(Q--,m!==kr)B(n,p.name,m);else if(!p.optional&&((u??=[]).push(q4(p)),t.options.errors!=="all"))break}if(u!==void 0&&z4(e,u),e.extra.length>0){let f=t.uvarint();if(f>t.remaining&&H("complete value",void 0,t.options),f>0){let p={list:[],set:void 0};for(let m=0;m<f;m++)j4(e,t,n,p,r)}}return n}function V4(e,t,r,n){let o={list:[],set:void 0};for(;t.pos<t.end;)j4(e,t,r,o,n)}function Sce(e,t,r){let n=r.uvarint();if((n&1)===1){let i=(n-1)/2;return i>=e.length&&H("a known back-reference",void 0,r.options),e[i]}if(t._==="string"){if(r.dict!==void 0){let a=r.enter(n/2),c=un(t,r);return r.exit(a),e.push(c),c}let i=r.readUtf8(n/2);return e.push(i),i}let o=r.enter(n/2),s=un(t,r);return r.exit(o),e.push(s),s}function bce(e,t,r){let n=new Array(t),o=[],s=[];for(let i=0;i<t;i++){Ze[Q++]=i;let a=r.enter(r.uvarint());n[i]=Ice(e,o,s,r),r.exit(a),Q--}return n}function Ece(e,t){let r=t.uvarint(),n=e.fields,o=r&~mE;(r>mE*2-1||o>>>n.length)&&H("a known row shape",void 0,t.options);let s=[];(r&mE)!==0&&s.push(null);for(let i=0;i<n.length;i++)(o&1<<i)!==0&&s.push(n[i]);return s}function Ice(e,t,r,n){let o=e.struct,s={},i=0,a,c=n.uvarint(),u;if(c===0?n.positional&&e.shapes&&(u=Ece(o,n),t.push(u)):(u=t[c-1],u===void 0&&H("a known row shape",void 0,n.options)),u!==void 0){for(let f=0;f<u.length;f++){let p=n4(e,r,u[f],s,n);p>=0&&(p<32?i|=1<<p:(a??=new Set).add(p))}n.pos!==n.end&&H("no leftover bytes",void 0,n.options)}else{let f=e.shapes?[]:void 0,p=0,m,h,x=!1;for(;n.pos<n.end;){let g=n.uvarint(),y;g===0?(x&&H("unique field ids",void 0,n.options),x=!0,y=null):(y=o.byId.get(g),y===void 0?h===void 0?h=new Set([g]):h.has(g)?H("unique field ids",void 0,n.options):h.add(g):y.index<32?((p&1<<y.index)!==0&&H("unique field ids",void 0,n.options),p|=1<<y.index):m===void 0?m=new Set([y.index]):(m.has(y.index)&&H("unique field ids",void 0,n.options),m.add(y.index))),f?.push(y);let E=n4(e,r,y,s,n);E>=0&&(E<32?i|=1<<E:(a??=new Set).add(E))}f!==void 0&&t.push(f)}return K4(o,i,a,n),s}function n4(e,t,r,n,o){let s=o.uvarint();if((s&1)===1){if(r==null)return-1;let u=t[r.index],f=(s-1)/2;(u===void 0||f>=u.length)&&H("a known back-reference",void 0,o.options);let p=u[f];return p===kr?-1:(B(n,r.name,p),r.index)}let i=o.enter(s/2);if(r===null)return V4(e.struct,o,n),o.exit(i),-1;if(r===void 0)return o.exit(i),-1;let a=e.intern[r.index];(a===S4||a===b4)&&(o.intern=t[r.index]??=[]),Ze[Q++]=r.name;let c=un(r.layout,o);return Q--,o.intern=void 0,o.exit(i),a===VR&&(t[r.index]??=[]).push(c),c===kr?-1:(B(n,r.name,c),r.index)}function Tce(e,t){let r=e.elements.length,n=e.hasCount?t.uvarint():r;if(e.rest.length===0&&n>r)throw Ze[Q++]=r,dr(new Mu(e.ast,void 0,t.options));if(n<e.minCount)throw Ze[Q++]=n,dr(new Yt(void 0));if(e.hasCount){let i=e.rest.length>0&&I4(e.rest[0])?xae:t.remaining+hae;n>i&&H("array count within allocation limit",n,t.options)}if(n>0){let i=O4(e);if(i!==null)return bce(i,n,t)}let o=new Array(n),s=e.uniform;if(s!==void 0){if(e.uniformNumbers)return wce(o,n,t);let i=t.intern;if(t.intern=void 0,i!==void 0){for(let u=0;u<n;u++){Ze[Q++]=u;let f=Sce(i,s,t);if(f===kr)throw dr(new Yt(void 0));Q--,o[u]=f}return o}if(CE(s)){for(let u=0;u<n;u++)Ze[Q++]=u,o[u]=qh(s,t),Q--;return o}if(s._==="string"){for(let u=0;u<n;u++)Ze[Q++]=u,o[u]=t.dict===void 0?t.readUtf8(t.uvarint()):$4(s,t),Q--;return o}let a=e.uniformPacked,c=e.uniformInline;for(let u=0;u<n;u++){Ze[Q++]=u;let f=t.enter(c?a??0:t.uvarint()),p=un(s,t);if(t.exit(f),p===kr)throw dr(new Yt(void 0));Q--,o[u]=p}return o}for(let i=0;i<n;i++){let a=D4(e,i,n),c=i<r&&e.elements[i].optional;if(!e.hasCount&&t.remaining===0&&!c&&a._!=="null"&&a._!=="undefined")throw Ze[Q++]=i,dr(new Yt(void 0));Ze[Q++]=i;let u=H4(a,t);if(u===kr)throw c&&H("known union member",void 0,t.options),dr(new Yt(void 0));Q--,o[i]=u}if(!e.hasCount&&t.pos<t.end)throw Ze[Q++]=r,dr(new Mu(e.ast,void 0,t.options));return o}function wce(e,t,r){let n=r.byte();if(n===d4){r.remaining!==t*8&&H("f64",void 0,r.options);for(let o=0;o<t;o++)e[o]=r.f64();return e}if(n===m4){for(let o=0;o<t;o++){Ze[Q++]=o;let s=r.uvarint(),i=s%16;i>wE&&H("decimal",void 0,r.options);let a=h4((s-i)/16);e[o]=i===0?a:a/_c[i],Q--}return e}n!==p4&&H("f64",void 0,r.options);for(let o=0;o<t;o++)Ze[Q++]=o,e[o]=r.numberVarint(),Q--;return e}function vce(e,t){let r=t.byte();if(r===dt.variant){let o=t.u32le(),s=e.byTag.get(o);if(s===void 0)return t.take(t.remaining),kr;let i=un(s.payload,t);if(i===kr)return kr;if(!s.tuple)for(let a of s.sentinels)B(i,a.key,a.literal);return i}let n=e.byKind.get(r);return n===void 0?(t.take(t.remaining),kr):un(n,t)}function Cce(e,t){let r=e.byPos[t.uvarint()];r===void 0&&H("known union member",void 0,t.options);let n=un(r.layout,t),o=r.variant;if(o!==void 0&&!o.tuple&&n!==kr)for(let s of o.sentinels)B(n,s.key,s.literal);return n}function o4(e,t){switch(t.byte()){case 0:return Tp(Ad(un(e.error,t)));case 1:return wp(Ad(un(e.defect,t)));case 2:return t.remaining!==0&&H("empty",void 0,t.options),vp();case 3:return t.remaining!==8&&H("f64",void 0,t.options),vp(t.f64());default:return t.take(t.remaining),kr}}function Ad(e){if(e===kr)throw dr(new Yt(void 0));return e}function qh(e,t){t.nesting>=qW&&H(`nesting depth at most ${qW}`,t.nesting+1,t.options),t.nesting++;try{return Ace(e,t)}finally{t.nesting--}}function Ace(e,t){switch(e._){case"literal":{let r=qh(e.leaf,t);return Jh(e,r)||H(vE(e),r,t.options),r}case"bool":{t.remaining!==1&&H("bool",void 0,t.options);let r=t.byte();return r>1&&H("bool",void 0,t.options),r===1}case"null":return t.remaining!==0&&H("empty",void 0,t.options),null;case"undefined":t.remaining!==0&&H("empty",void 0,t.options);return;case"number":{let r=t.remaining;if(r===8)return t.f64();(r===0||r>l4)&&H("f64",void 0,t.options);let n=t.numberVarint();if(t.remaining===0)return n;let o=t.byte();return(t.remaining!==0||o===0||o>wE)&&H("decimal",void 0,t.options),n/_c[o]}case"int":return t.numberVarint();case"string":{let r=t.dict;return r===void 0?t.readUtf8(t.end-t.pos):sce(r,e,t)}case"symbol":return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case"bytes":return t.takeCopy(t.end-t.pos);case"bigint":return t.zigzag();case"int64":{t.remaining!==8&&H("int64",void 0,t.options);let r=Number(t.i64()),n=new Date(r);return Number.isNaN(n.getTime())&&H(e.flavor==="date"?"a valid Date":"a valid DateTime",r,t.options),e.flavor==="date"?n:xy(r)}case"dateTimeZoned":{let r=Number(t.i64()),n=t.byte(),o;if(n===0)t.remaining!==4&&H("time zone",void 0,t.options),o=t.i32le();else if(n===1)o=t.readUtf8(t.end-t.pos);else return H("time zone",void 0,t.options);try{return gy(r,{timeZone:o})}catch{return H("time zone",void 0,t.options)}}case"duration":switch(t.byte()){case 0:return $o(t.zigzag());case 1:return Ss;case 2:return Da;default:return H("duration",void 0,t.options)}case"bigDecimal":{let r=t.zigzag(),n=t.zigzag();return(n>MR||-n>MR)&&H("safe integer length",void 0,t.options),ly(r,Number(n))}case"json":{let r=t.readUtf8(t.end-t.pos);try{return JSON.parse(r)}catch{return H("json",void 0,t.options)}}case"option":{let r=t.byte();return r===0?(t.remaining!==0&&H("empty",void 0,t.options),_()):(r!==1&&H("bool",void 0,t.options),N(Ad(un(e.value,t))))}case"result":{let r=t.byte();return r===0?X(Ad(un(e.success,t))):(r!==1&&H("bool",void 0,t.options),re(Ad(un(e.failure,t))))}case"exit":{let r=t.byte();if(r===0)return Mr(Ad(un(e.value,t)));r!==1&&H("bool",void 0,t.options);let n=qh(e.cause,t);return ir(n)}case"cause":{let r=t.uvarint(),n=[];for(let o=0;o<r;o++){Ze[Q++]=o;let s=t.enter(t.uvarint()),i=o4(e,t);t.exit(s),Q--,i!==kr&&n.push(i)}return t.pos!==t.end&&H("no leftover bytes",void 0,t.options),au(n)}case"causeReason":return o4(e,t);case"struct":return t.positional?yce(e,t):gce(e,t);case"array":return Tce(e,t);case"union":return t.positional?Cce(e,t):vce(e,t);case"never":throw dr(new at(e.ast,void 0,t.options))}}function J4(e,t,r){let n=t.byte();if(n!==r.envelope&&H(r.expectedEnvelope,n,t.options),r.positional){t.remaining<8&&H("complete value",void 0,t.options);let s=t.buf,i=r.fingerprint,a=t.pos;for(let c=0;c<8;c++)s[a+c]!==i[c]&&H("matching layout fingerprint",void 0,t.options);t.pos=a+8}let o=un(e,t);if(o===kr)throw dr(new Yt(void 0));return o}var dE=new Hh;function kce(e,t,r,n){let o=dE??new Hh,s=o===dE;s&&(dE=void 0),o.reset(t,0,t.length,r,void 0,n.positional,void 0);let i=Q;Q=0;try{let a=o.uvarint();a===0&&H("nonzero frame length",void 0,r);let c=o.enter(a),u=J4(e,o,n);return o.exit(c),o.pos!==t.length&&H("no leftover bytes",void 0,r),u}finally{Q=i,o.release(),s&&(dE=o)}}function Rce(e,t,r,n=!1){return Xt({decode:(o,s)=>{try{let i=kce(e,o,s,t);return r!==void 0&&Dd(i)&&(!n||kE(i))&&(r.value=i),I(i)}catch(i){return i instanceof Hi?D(i.issue):gn(i)}},encode:(o,s)=>{try{return I(TE(e,o,s,t))}catch(i){return i instanceof Hi?D(i.issue):gn(i)}}})}var Oce=mo(Bae);function yf(e,t){return t===!0?Oce(e):Lae}var _ce=mo(e=>{let t=G(hE(e)),{exact:r,exitSuccess:n,layout:o,recursive:s}=Fae(t.ast);return{target:s?Uce(t):t,layout:o,exact:r,exitSuccess:n,recursive:s}});function Rd(e){return _ce(e.ast)}function G4(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function Z4(e,t,r){let n=G(Mt(e.ast)),o=ot(n),s=i=>()=>(a,c,u)=>i(a,u)?nt:o(a,u);return G(new uc([n.ast],s(t),{identifier:"binary value"},void 0,void 0,void 0,void 0,s(r)))}function qR(e,t){return t.onExcessProperty!=="error"}function Pce(e,t,r){return Z4(e,n=>G4(t,n),r?qR:Mce)}function Mce(){return!1}function Fce(e,t){return Cr()([e],([r])=>{let n=ot(r);return(o,s,i)=>G4(t,o)||kE(o)&&i.onExcessProperty!=="error"?I(o):n(o,i)},{identifier:"binary exit value"})}function Nce(e){return Z4(e,qR,qR)}function Uce(e){let t=G(Mt(e.ast)),r=new WeakSet,n=Cr()([t],([o])=>(s,i,a)=>Dd(s)&&r.delete(s)?I(s):kn(s)?D(new at(i,s,a)):ot(o)(s,a),{identifier:"acyclic value"});return ee(n,Fe({decode:o=>(Dd(o)&&r.add(o),o),encode:o=>o}))(e)}var OE=ef,Lce,e6=e=>(Lce??=new TextDecoder).decode(e),fn=class extends Ue()("effect/rpc/RpcSerialization"){},RE=class extends sr("MaxBufferSizeExceeded"){get message(){return`RPC serialization buffer exceeded the maximum size of ${this.maxBufferSize}`}},Bce=16*1024*1024,Q4=(e,t)=>t!=="unbounded"&&e>t,t6=fn.of({contentType:"application/json",includesFraming:!1,codecFor:OE,makeUnsafe:()=>({decode:e=>{let t=JSON.parse(typeof e=="string"?e:e6(e));return Array.isArray(t)?t:[t]},encode:e=>JSON.stringify(e)})}),_E=e=>{let t=e?.maxBufferSize??Bce;return fn.of({contentType:"application/ndjson",includesFraming:!0,codecFor:OE,makeUnsafe:()=>{let r,n="",o=s=>{throw n="",new RE({maxBufferSize:s})};return{decode:s=>{n+=typeof s=="string"?s:(r??=new TextDecoder).decode(s,{stream:!0});let i=0,a=n.indexOf(`
33
+ `,i),c=[];for(;a!==-1;){Q4(a-i,t)&&o(t);let u=n.slice(i,a);i=a+1;try{c.push(JSON.parse(u))}catch{}a=n.indexOf(`
34
+ `,i)}return n=n.slice(i),Q4(n.length,t)&&o(t),c},encode:s=>{if(Array.isArray(s)){if(s.length===0)return;let i="";for(let a=0;a<s.length;a++)i+=JSON.stringify(s[a])+`
35
35
  `;return i}return JSON.stringify(s)+`
36
- `}}}})},y3=w0(),S3=e=>Rn.of({contentType:e?.contentType??"application/json",includesFraming:!1,codecFor:Mg,makeUnsafe:()=>{let t=new TextDecoder,n=new Map;return{decode:r=>{let o=JSON.parse(typeof r=="string"?r:t.decode(r));return E3(o,n)},encode:r=>{let o=w3(r,n);return o&&JSON.stringify(o)}}}}),b3=e=>Rn.of({contentType:e?.contentType??"application/json-rpc",includesFraming:!0,codecFor:Mg,makeUnsafe:()=>{let t=w0({maxBufferSize:e?.maxBufferSize}).makeUnsafe(),n=new Map;return{decode:r=>{let o=t.decode(r);if(o.length===0)return[];let s=[];for(let i=0;i<o.length;i++){let a=o[i];s.push(...E3(a,n))}return s},encode:r=>{let o=w3(r,n);return o&&t.encode(o)}}}});function E3(e,t){if(Array.isArray(e)){let n={size:0,responses:new Map},r=[];for(let o=0;o<e.length;o++){let s=m3(e[o]);r.push(s),s._tag==="Request"&&!s.isNotification&&(n.size++,t.set(s.id,n))}return r}return[m3(e)]}function m3(e){if(Object.hasOwn(e,"method")){let r=e;if(G0(r.id)&&r.method.startsWith("@effect/rpc/")){let o=r.method.slice(12),s=r.params?.requestId;return s?{_tag:o,requestId:s}:{_tag:o}}return{_tag:"Request",id:r.id??"",tag:r.method,payload:r.params??null,headers:r.headers??[],...N(r,"id")?{}:{isNotification:!0},...r.spanId?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{}}}let t=e,n=Object.hasOwn(t,"error");return n&&t.error&&t.error._tag==="Defect"?{_tag:"Defect",defect:t.error.data}:Object.hasOwn(t,"chunk")&&t.chunk===!0?{_tag:"Chunk",requestId:t.id??"",values:t.result}:{_tag:"Exit",requestId:t.id??"",exit:n&&t.error!=null?{_tag:"Failure",cause:t.error._tag==="Cause"?t.error.data:[{_tag:"Die",defect:t.error}]}:{_tag:"Success",value:t.result}}}function h3(e,t){if(!("requestId"in e))return PO(e);let n=t.get(e.requestId);return n?(t.delete(e.requestId),n.responses.set(e.requestId,e),n.size===n.responses.size?Array.from(n.responses.values(),PO):void 0):PO(e)}function w3(e,t){if(Array.isArray(e)===!1)return h3(e,t);if(e.length===0)return;let n=[];for(let o=0;o<e.length;o++){let s=h3(e[o],t);s!==void 0&&n.push(s)}if(n.length===0)return;if(n.length===1)return n[0];let r=[];for(let o=0;o<n.length;o++){let s=n[o];Array.isArray(s)?r.push(...s):r.push(s)}return r}function PO(e){switch(e._tag){case"Request":return{jsonrpc:"2.0",method:e.tag,params:e.payload,...e.isNotification?{}:{id:e.id},...e.headers?.length>0?{headers:e.headers}:{},traceId:e.traceId,spanId:e.spanId,sampled:e.sampled};case"Ping":case"Pong":case"Interrupt":case"Ack":case"Eof":return{jsonrpc:"2.0",method:`@effect/rpc/${e._tag}`,params:"requestId"in e?{requestId:e.requestId}:void 0};case"Chunk":return{jsonrpc:"2.0",chunk:!0,id:e.requestId,result:e.values};case"Exit":{if(e.exit._tag==="Success")return{jsonrpc:"2.0",id:e.requestId??void 0,result:e.exit.value};let t=e.exit.cause.find(r=>r._tag==="Fail"),n=t?._tag==="Fail"?t.error:void 0;return{jsonrpc:"2.0",id:e.requestId??void 0,error:e.exit._tag==="Failure"?{_tag:"Cause",code:n&&N(n,"code")?Number(n.code):0,message:n&&N(n,"message")?n.message:JSON.stringify(e.exit.cause),data:e.exit.cause}:void 0}}case"Defect":return{jsonrpc:"2.0",id:vce,error:{_tag:"Defect",code:1,message:"A defect occurred",data:e.defect}};case"ClientProtocolError":return{}}}var vce=-32603,FO=e=>{let{maxBufferSize:t=g3,...n}=e??{};return Rn.of({contentType:"application/msgpack",includesFraming:!0,codecFor:Mg,makeUnsafe:()=>{let r=new Yi(n),o=new ou(n),s=new TextEncoder,i,a=c=>{throw i=void 0,new _g({maxBufferSize:c})};return{decode(c){let u=typeof c=="string"?s.encode(c):c;if(i!==void 0){E0(i.length+u.length,t)&&a(t);let f=u;c=new Uint8Array(i.length+u.length),c.set(i),c.set(f,i.length),u=c,i=void 0}try{return r.unpackMultiple(u)}catch(f){let l=f;if(l.incomplete)return i=u.subarray(l.lastPosition),E0(i.length,t)&&a(t),l.values??[];throw f}},encode:c=>o.pack(c)}}})},v3=FO({useRecords:!0}),Tce=16*1024*1024,Ice=new TextEncoder,kce=e=>{let t=e?.maxFrameSize??Tce,n=e?.fingerprintPayloads===!0?o=>vO(o,{fingerprint:!0}):vO,r={fingerprint:!0,dictionary:!0};return Rn.of({contentType:"application/vnd.effect.rpc+schema-binary",includesFraming:!0,codecFor:n,makeUnsafe:()=>{let o=AW(JC,{...r,maxFrameSize:t}),s=CW(JC,r);return{decode:i=>o.feedSync(typeof i=="string"?Ice.encode(i):i),encode:i=>{if(!Array.isArray(i))return s.encode(i);if(i.length!==0)return s.encodeMany(i)}}}})},Ace=Ti(Rn)(x3),Rce=Ti(Rn)(y3),Cce=e=>Ti(Rn)(w0(e)),Oce=e=>Ti(Rn)(S3(e)),_ce=e=>Ti(Rn)(b3(e)),Mce=Ti(Rn)(v3),Pce=e=>Ti(Rn)(FO(e)),Fce=e=>xT(Rn)(()=>kce(e));var v0=class extends qe()("effect/rpc/RpcWorker/InitialMessage"){};var I3=e=>V(()=>{let t=new Set,n=new Map,r=new Map,o=(s,i)=>yr(a=>{let c=n.get(s);return c||(c=[],n.set(s,c)),c.push([i,a]),W});return te(e((s,i)=>{let a=r.get(s);return a?a(i):o(s,i)},t),s=>({...s,run(i,a){return Lt(function*(){t.add(i),r.set(i,a);let c=n.get(i);if(c){n.delete(i);for(let[u,f]of c)yield*Vn(V(()=>a(u)),f)}return yield*Sr(oo,()=>(t.delete(i),r.delete(i),W))})}}))});var Nce=e=>jn(e,"RpcClientError"),Dce=0,k3=Ee(function*(e,t){let n=t?.spanPrefix??"RpcClient",r=t?.supportsAck??!0,o=t?.disableTracing??!1,s=t?.generateRequestId??(()=>Dce++),i=yield*Kn(),a=ze(i,mt),c=new Map,u=!1;yield*Dt(a,kn(E=>(u=!0,f(dy(E.id)))));let f=Ee(function*(E){for(let[y,v]of c)c.delete(y),v._tag==="Queue"?yield*E._tag==="Success"?fh(v.queue):on(v.queue,E.cause):v.resume(E)}),l=E=>{let y=mg(E.successSchema),v=g(E);return(b,T)=>{let R=T?.headers?Gi(T.headers):Zd,C=T?.context??Tt();if(!y){let B=F=>p(E,v,F,E.payloadSchema.make(b),R,C,T?.discard??!1);return o?B(void 0):Sm(`${n}.${E._tag}`,{attributes:t.spanAttributes},B)}let P=h(E,v,E.payloadSchema.make(b),R,T?.streamBufferSize??16,C);return T?.asQueue?P:Ir(te(P,zi))}},p=(E,y,v,b,T,R,C)=>kn(P=>{if(u)return Co;let B=s(),F=y(z=>t.onFromClient({message:z,context:R,discard:C}),{_tag:"Request",id:B,tag:E._tag,payload:b,...v?{traceId:v.traceId,spanId:v.spanId,sampled:v.sampled}:{},headers:Qd(P.getRef(T0),T)});if(C)return F;let Z;return Ri(Bs(z=>{let A={_tag:"Effect",rpc:E,context:R,resume(H){z(H),Z&&!Z.pollUnsafe()&&P.currentDispatcher.scheduleTask(()=>{Z.interruptUnsafe(P.id)},0)}};c.set(B,A),Z=F.pipe(v?ed(v,{captureStackTrace:!1}):j,Jn(P.context)),Z.addObserver(H=>{if(H._tag==="Failure")return z(H)})}),z=>(c.delete(B),Wn(Fo(Z),x(B,Array.from(z),R))))}),h=Ee(function*(E,y,v,b,T,R){if(u)return yield*Co;let C=o?void 0:yield*aI(`${n}.${E._tag}`,{attributes:t.spanAttributes}),P=Di(),B=s(),F=sr(P.context,mt);yield*Yo(F,z=>c.has(B)?(c.delete(B),x(B,Ei(z)?Array.from(aT(z.cause)):[],R)):W);let Z=yield*wf(T);return c.set(B,{_tag:"Queue",rpc:E,queue:Z,scope:F,context:R}),yield*y(z=>t.onFromClient({message:z,context:R,discard:!1}),{_tag:"Request",id:B,tag:E._tag,payload:v,...C?{traceId:C.traceId,spanId:C.spanId,sampled:C.sampled}:{},headers:Qd(P.getRef(T0),b)}).pipe(C?ed(C,{captureStackTrace:!1}):j,ht(z=>on(Z,z)),Oa,zt(F,{startImmediately:!0})),Z}),g=E=>{let y=[];for(let v of E.middlewares.values()){let b=pa(i,`${v.key}/Client`);b&&y.push(b)}return y.length===0?(v,b)=>v(b):function v(b,T,R=y.length-1){return R===-1?b(T):y[R]({rpc:E,request:T,next(C){return v(b,C,R-1)}})}},x=(E,y,v)=>Bs(b=>{let T=Di();t.onFromClient({message:{_tag:"Interrupt",requestId:E,interruptors:y},context:v,discard:!1}).pipe(GT(1e3),Jn(T.context)).addObserver(()=>{b(W)})}),S=E=>{switch(E._tag){case"Chunk":{let y=E.requestId,v=c.get(y);return!v||v._tag!=="Queue"?W:ja(v.queue,E.values).pipe(r?_(()=>t.onFromClient({message:{_tag:"Ack",requestId:E.requestId},context:v.context,discard:!1})):j,ht(b=>on(v.queue,b)))}case"Exit":{let y=E.requestId,v=c.get(y);return v?(c.delete(y),v._tag==="Effect"?(v.resume(E.exit),W):E.exit._tag==="Success"?fh(v.queue):on(v.queue,E.exit.cause)):W}case"Defect":return f(ly(E.defect));case"ClientEnd":return W}},w;if(t.flatten){let E=new Map;w=function(v,b,T){let R=E.get(v);return R||(R=l(e.requests.get(v)),E.set(v,R)),R(b,T)}}else w={},e.requests.forEach(E=>{K(w,E._tag,l(E))});return{client:w,write:S}}),Lce=0,UO=Ee(function*(e,t){let n=Lce++,{codecFor:r,run:o,send:s,supportsAck:i,supportsTransferables:a}=yield*ta,c=qce(r),u=Fh(r(xn())),f=new Map,{client:l,write:p}=yield*k3(e,{...t,supportsAck:i,onFromClient({message:h}){switch(h._tag){case"Request":{let g=e.requests.get(h.tag),x=a?_z():void 0,S=Di(),w={rpc:g,context:x?Ge(S.context,pg,x):S.context,schemas:c(g)};return f.set(h.id,w),w.schemas.encodePayload(h.payload).pipe(Vn(w.context),Ai,_(E=>s(n,{...h,id:h.id,payload:E,headers:Object.entries(h.headers)},x&&x.readUnsafe())))}case"Ack":return f.get(h.requestId)?s(n,{_tag:"Ack",requestId:h.requestId}):W;case"Interrupt":return f.get(h.requestId)?(f.delete(h.requestId),s(n,{_tag:"Interrupt",requestId:h.requestId})):W;case"Eof":return W}}});return yield*o(n,h=>{switch(h._tag){case"Chunk":{let g=xg(h.requestId),x=f.get(g);return!x||Se(x.schemas.decodeChunk)?W:x.schemas.decodeChunk.value(h.values).pipe(Vn(x.context),Ai,_(S=>p({_tag:"Chunk",clientId:0,requestId:xg(h.requestId),values:S})),Ro(S=>p({_tag:"Exit",clientId:0,requestId:xg(h.requestId),exit:Jt(S)})))}case"Exit":{let g=xg(h.requestId),x=f.get(g);return x?(f.delete(g),x.schemas.decodeExit(h.exit).pipe(Vn(x.context),Ai,io({onSuccess:S=>p({_tag:"Exit",clientId:0,requestId:g,exit:S}),onFailure:S=>p({_tag:"Exit",clientId:0,requestId:g,exit:Jt(S)})}))):W}case"Defect":return p({_tag:"Defect",clientId:0,defect:u(h.defect)});case"ClientProtocolError":{let g=Zo(h.error);return es(f.keys(),x=>p({_tag:"Exit",clientId:0,requestId:x,exit:g}))}default:return W}}).pipe(ht(wm),Oa,$s),l}),qce=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=VE(n.successSchema);return r={decodeChunk:Kt(o,s=>Wc(e(Gb(s.success)))),encodePayload:Vb(e(n.payloadSchema)),decodeExit:Wc(e(KC(n)))},t.set(n,r),r}},T0=Fe("effect/rpc/RpcClient/CurrentHeaders",{defaultValue:()=>Zd}),jce=d(2,(e,t)=>nI(e,T0,Qd(Gi(t)))),ta=class extends qe()("effect/rpc/RpcClient/Protocol"){static make=I3},A3=e=>ta.make(Ee(function*(t){let n=yield*Rn,r=n.includesFraming,o=u=>new ui({reason:Yd.fromHttpClientError(u)}),s=(u,f)=>new ui({reason:new tu({message:u,cause:f})}),i=u=>s("Received empty HTTP response from RPC server",u),a=u=>s("HTTP response ended before RPC request completed",u);return{send:Ee(function*(u,f){if(f._tag!=="Request")return;let l=n.makeUnsafe(),p=l.encode(f),h=typeof p=="string"?bC(p,n.contentType):FE(p,n.contentType),g=yield*e.post("",{body:h}).pipe(Xl(o));if(!r){let w=yield*g.text.pipe(Xl(o)),E=yield*ts({try:()=>l.decode(w),catch:b=>s("Error decoding HTTP response",b)});if(!Array.isArray(E))return yield*s("Expected an array of responses",E);if(E.length===0)return yield*i(f);let y=!1,v=0;return yield*ur({while:()=>v<E.length,body:()=>{let b=E[v++];return GC(b)&&(y=!0),t(u,b)},step:Cn}),y?void 0:yield*a(f)}let x=!1,S=!1;if(yield*zd(g.stream,w=>ts({try:()=>w.flatMap(l.decode),catch:E=>s("Error decoding HTTP response",E)}).pipe(_(E=>{if(E.length===0)return W;x=!0;let y=0;return ur({while:()=>y<E.length,body:()=>{let v=E[y++];return GC(v)&&(S=!0),t(u,v)},step:Cn})}))).pipe(Xl(w=>Nce(w)?w:o(w))),x){if(!S)return yield*a(f)}else return yield*i(f)}),supportsAck:!1,supportsTransferables:!1,codecFor:n.codecFor}})),Bce=e=>ro(ta)(_(CC,t=>(t=kz(t,yz(e.url)),A3(e.transformClient?e.transformClient(t):t)))),R3=e=>ta.make(Ee(function*(t,n){let r=yield*Oz,o=yield*Rn,s=yield*Yu(Fg),i=new Map,a=yield*r.writer,c=o.makeUnsafe(),u=yield*Hce(V(()=>a(c.encode(Uz)))),f,l=V(()=>(f=void 0,_e(s)?s.value.onConnect:W)),p=g=>es(n,x=>t(x,g)),h=g=>(f=g,p({_tag:"ClientProtocolError",error:g}));return yield*V(()=>(c=o.makeUnsafe(),u.reset(),r.runRaw(g=>{try{let x=c.decode(g);if(x.length===0)return;let S=0;return ur({while:()=>S<x.length,body:()=>{let w=x[S++];if(w._tag==="Pong")return u.onPong(),W;if(Object.hasOwn(w,"requestId")){let E=w.requestId,y=i.get(E);if(y!==void 0)return w._tag==="Exit"&&i.delete(E),t(y,w)}return p(w)},step:Cn})}catch(x){return p({_tag:"ClientProtocolError",error:new ui({reason:new tu({message:"Error decoding message",cause:x})})})}},{onOpen:l}).pipe(Cc(_(u.timeout,()=>Q(new ep({reason:new lg({kind:"Timeout",cause:new Error("ping timeout")})}))))))).pipe(_(()=>Q(new ep({reason:new dg({code:1e3})}))),_e(s)?Ca(s.value.onDisconnect):j,xm(g=>{let x=$u(g),S=_t(x),w=new ui({reason:S?x.success.reason:new tu({message:"Unknown socket error",cause:vc(g)})});return e?.retryTransientErrors&&S&&x.success.reason._tag==="SocketOpenError"?(e.onTransientError?.(w)??W).pipe(JT({log:!0,message:"RpcClient onTransientError hook failed"})):h(w)}),KT(e?.retryPolicy??$ce,g=>h(new ui({reason:g.reason}))),Dy({module:"RpcClient",method:"makeProtocolSocket"}),$s),{send(g,x){if(f)return Q(f);x._tag==="Request"&&i.set(x.id,g);let S=c.encode(x);return S===void 0?W:Ai(a(S))},supportsAck:!0,supportsTransferables:!1,codecFor:o.codecFor}})),$ce=W1([K1(500,1.5),Jl(5e3)]),Hce=Ee(function*(e){let t=!0,n=Er(),r=()=>{t=!0,n.closeUnsafe()},o=()=>{t=!0};return yield*V(()=>t?(t=!1,e):n.open).pipe(Ra("5 seconds"),VT,Qt,Oa,$s),{timeout:n.await,reset:r,onPong:o}}),zce=e=>ro(ta)(R3(e)),C3=e=>ta.make(Ee(function*(t,n){let r=yield*KE,o=yield*os,s=0,i=yield*Yu(v0),a=yield*Yu(Fg),c=new Map,u=h=>es(n,g=>t(g,h)),f=Lt(function*(){let h=s++,g=yield*r.spawn(h);return yield*g.run(x=>{if(x._tag==="Exit"){let S=c.get(x.requestId);if(S)return c.delete(x.requestId),S.latch.openUnsafe(),t(S.clientId,x)}else if(x._tag==="Defect"){for(let[S,w]of c)c.delete(S),w.latch.openUnsafe();return u(x)}else if("requestId"in x){let S=c.get(x.requestId);if(S)return t(S.clientId,x)}return u(x)},{onSpawn:_e(i)?_(i.value,([x,S])=>Ai(g.send({_tag:"InitialMessage",value:x},S))):void 0}).pipe(xm(x=>{for(let[w,E]of c)E.worker===g&&(c.delete(w),E.latch.openUnsafe());let S=$u(x);return u({_tag:"ClientProtocolError",error:new ui({reason:_t(S)?S.success.reason:new tu({message:"Error in worker",cause:vc(x)})})})}),Fy(Jl(1e3)),Dy({module:"RpcClient",method:"makeProtocolWorker"}),Oa,$s),g}),l="minSize"in e?yield*yH({acquire:f,min:e.minSize,max:e.maxSize,concurrency:e.concurrency,targetUtilization:e.targetUtilization,timeToLive:e.timeToLive}):yield*xH({acquire:f,size:e.size,concurrency:e.concurrency,targetUtilization:e.targetUtilization});yield*Dt(o,ae(()=>{for(let h of c.values())h.latch.openUnsafe();c.clear()}));let p=(h,g,x)=>{switch(g._tag){case"Request":return JR(l).pipe(_(S=>{let w=Er(!1);return c.set(g.id,{clientId:h,worker:S,latch:w}),_(S.send(g,x),()=>w.await)}),ef,Ai);case"Interrupt":{let S=c.get(g.requestId);return S?(c.delete(g.requestId),S.latch.openUnsafe(),Ai(S.worker.send(g))):W}case"Ack":{let S=c.get(g.requestId);return S?Ai(S.worker.send(g)):W}}return W};return yield*ef(JR(l)),_e(a)&&(yield*a.value.onConnect),{send:p,supportsAck:!0,supportsTransferables:!0,codecFor:Gc}})),Wce=lu(C3,ro(ta)),Fg=class extends qe()("effect/rpc/RpcClient/ConnectionHooks"){};var I0="~effect/reactivity/Atom",M3=e=>N(e,I0),DO="~effect/reactivity/Atom/Writable",Ng=d(2,(e,t)=>{let n=pt(t),r=Rs(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?vn(n):void 0})}),Gf=Ng(0),qO={[I0]:I0,equals:Object.is,...On,toJSON(){return{_id:"Atom",keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},Kce={...qO,atom(e,t){let n=P3(e,t);return nr(r=>{let o=r.self(),s=r(this);return s._tag!=="Success"?Xh(s,o):n(r,s.value)})},fn(e,t){return arguments.length===0?(n,r)=>O3(this,n,r):O3(this,e,t)},pull(e,t){let n=Gf(jO(0)),r=nr(o=>{let s=o.self(),i=o(this);return i._tag!=="Success"?Xh(i,s):k0(o,nue(o,n,e,t),Ja(!0),i.value)});return rue(n,r)},subscriptionRef(e){return Xce(Gf(nr(t=>{let n=t.self(),r=t(this);if(r._tag!=="Success")return Xh(r,n);let o=typeof e=="function"?e(t):e;return Qh(o)?o:k0(t,o,Ja(!0),r.value)})),(t,n)=>{let r=rC(t(this));return Yce(t,n,r)})}},O3=(e,t,n)=>{let[r,o,s]=tue(n?.reactivityKeys?(i,a)=>{let c=t(i,a);return cr(c)?lE(c,n.reactivityKeys):Gh(c,dE(n.reactivityKeys))}:t,n);return Dg(i=>{i.get(s);let a=i.self(),c=i.get(e);return c._tag!=="Success"?Xh(c,a):r(i,c.value)},o)},Vce={...qO,[DO]:DO},Jce=e=>DO in e,nr=(e,t)=>{let n=Object.create(qO);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},Dg=(e,t,n)=>{let r=Object.create(Vce);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function Gce(e,t){e.setSelf(t)}var Zf=(e,t)=>{let n=P3(e,t);return I0 in n?n:nr(n)},P3=(e,t)=>{if(typeof e=="function"&&!cr(e)&&!Ne(e)){let n=e;return function(r,o){let s=n(r);switch(typeof s){case"function":case"object":return s===null?s:F3 in s?LO(r,s,t,o):Zce in s?_3(r,s,t,o):s;default:return s}}}else{if(cr(e))return function(n,r){return LO(n,e,t,r)};if(Ne(e))return function(n,r){return _3(n,e,t,r)}}return jO(e)},F3="~effect/Effect",Zce="~effect/Stream",jO=e=>Dg(function(t){return e},Gce),LO=(e,t,n,r)=>{let o=n?.initialValue!==void 0?hs(n.initialValue):Ja();return k0(e,t,o,r,n?.uninterruptible)};function k0(e,t,n,r=Tt(),o=!1){let s=e.self(),i=no();e.addFinalizer(()=>{Jn(r)(Ze(i,en))});let a,c=!1,u=BO(r.pipe(Ge(mt,i),Ge(yE,e.registry),Ge(gc,e.registry.scheduler)),t,function(f){a=nC(f,s),c&&e.setSelf(a)},o);return c=!0,u!==void 0&&e.addFinalizer(u),a!==void 0?a:s._tag==="Some"?gE(s):Yh(n)}function BO(e,t,n,r=!1){if(Us(t)){n(t);return}let s=Jn(e)(t);s.currentDispatcher?.flush();let i=s.pollUnsafe();if(i){n(i);return}let a=s.addObserver(n);function c(){a(),r||s.interruptUnsafe()}return c}function Qce(e){let t=e?.memoMap??Gf(Zf(()=>wi())),n=i=>M3(t)?i(t):t,r=pE;function o(i){let a=Object.create(Kce);a.keepAlive=!1,a.lazy=!0,a.refresh=void 0,a.factory=o;let c=HO(nr(typeof i=="function"?u=>om(i(u),r):()=>om(i,r)));return a.layer=c,a.read=function(f){let l=f(c),p=_(os,h=>vi(l,n(f),h));return LO(f,p,{uninterruptible:!0})},a}o.memoMap=t,o.addGlobalLayer=i=>{r=om(r,Ds(i,pE))};let s=Gf(Zf(i=>yr(a=>vi(pE,n(i),ze(a,mt))).pipe(te(ze(Ki)))));return o.withReactivity=i=>a=>zO(a,c=>{let u=rC(c(s));return c.addFinalizer(u.registerUnsafe(i,()=>{c.refresh(a)})),c.subscribe(a,f=>c.setSelf(f)),c.once(a)},{initialValueTarget:a}),o}var Qf=Qce(),YSe=Qf.withReactivity,_3=(e,t,n,r)=>{let o=n?.initialValue!==void 0?hs(n.initialValue):Ja();return $O(e,t,o,r)};function $O(e,t,n,r=Tt()){let o=e.self();r=Ge(r,yE,e.registry);let s=ym(a=>_(fs(t.channel,a),c=>ur({while:cn,body:()=>c,step(u){e.setSelf(hs(Il(u),{waiting:!0}))}}))).pipe(ht(a=>(Xo(a)?nl(e.self(),Ts(Kd),mr({onNone:()=>e.setSelf(MH(new Hu,{previous:e.self()})),onSome:c=>e.setSelf(hs(c))})):e.setSelf(Wd(a,{previous:e.self()})),W))),i=BO(r.pipe(Ge(yE,e.registry),Ge(gc,e.registry.scheduler)),s,Cn,!1);return i!==void 0&&e.addFinalizer(i),o._tag==="Some"?gE(o):Yh(n)}var Yce=(e,t,n=Tt())=>Qh(t)?(e.addFinalizer(XR(t).pipe(zd(r=>{for(let o=0;o<r.length;o++)e.setSelf(r[o]);return W}),cI(n))),lI(n)(IH(t))):t._tag!=="Success"?t:$O(e,XR(t.value),Ja(!0),n),Xce=(e,t)=>{function n(r,o){let s=r.get(e);Qh(s)?Oi(eC(s,o)):Zc(s)&&Oi(eC(s.value,o))}return Dg(r=>{let o=r(e);return Qh(o)||Zc(o)?t(r,o):o},n)};var eue=Symbol.for("effect/reactivity/atom/Atom/Reset"),NO=Symbol.for("effect/reactivity/atom/Atom/Interrupt");function tue(e,t){let n=Gf(jO([0,void 0])),r=t?.initialValue!==void 0?hs(t.initialValue):Ja(),o=t?.concurrent?Gf(nr(a=>{let c=new Set;return a.addFinalizer(()=>c.forEach(u=>u.interruptUnsafe())),c})):void 0;function s(a,c){let u=o?a(o):void 0;a.isFn=!0;let[f,l]=a.get(n);if(f===0)return r;if(l===NO)return Wd(sT(),{previous:a.self()});let p=e(l,a);return F3 in p?(u&&(p=_(nd(p,{startImmediately:!0}),g=>(u.add(g),g.addObserver(()=>u.delete(g)),te(qS(u),x=>x[0])))),k0(a,p,r,c,!1)):$O(a,p,r,c)}function i(a,c){sue(()=>{c===eue?a.set(n,[0,void 0]):c===NO?a.set(n,[a.get(n)[0]+1,NO]):a.set(n,[a.get(n)[0]+1,c]),a.refreshSelf()})}return[s,i,n]}var nue=(e,t,n,r)=>_(HR(typeof n=="function"?n(e):n),o=>{let i=Di().context,a=fn(),c=io(o,{onFailure(f){return Xo(f)?et(a)?k({done:!0,items:a}):Q(new Hu("Atom.pull: no items")):lt(f)},onSuccess(f){let l;return r?.disableAccumulation?l=f:(l=Tl(a,f),a=l),k({done:!1,items:l})}}),u=new Set;return e.addFinalizer(()=>{for(let f of u)f()}),e.once(t),e.subscribe(t,()=>{e.setSelf(gE(e.self()));let f;f=BO(i,c,l=>{f&&u.delete(f);let p=nC(l,e.self()),h=u.size>0;e.setSelf(h?Yh(p):p)}),f&&u.add(f)}),c}),rue=(e,t)=>Dg(t.read,function(n,r){n.set(e,n.get(e)+1)}),Ya=typeof WeakRef>"u"||typeof FinalizationRegistry>"u"?e=>{let t=Lc();return function(n){let r=Gs(t,n);if(r._tag==="Some")return r.value;let o=e(n);return qc(t,n,o),o}}:e=>{let t=Lc(),n=new FinalizationRegistry(r=>{Sf(t,r)});return function(r){let o=Gs(t,r).pipe(Sw(i=>i.deref()));if(o._tag==="Some")return o.value;let s=e(r);return qc(t,r,new WeakRef(s)),n.register(s,r),s}};var HO=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0});var zO=d(e=>M3(e[0]),(e,t,n)=>{let r=Gf(Jce(e)?Dg(o=>t(o,e),function(o,s){o.set(e,s)},e.refresh??function(o){o(e)}):nr(o=>t(o,e),e.refresh??function(o){o(e)}));return n?.initialValueTarget&&(r.initialValueTarget=oue(n.initialValueTarget)),r}),oue=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},au=d(2,(e,t)=>zO(e,n=>t(n(e))));var U3=d(2,(e,t)=>{let n=vn(pt(t));return zO(e,function(r){let o,s=r.once(e);function i(){o=void 0,r.setSelf(s)}return r.addFinalizer(function(){o&&clearTimeout(o)}),r.subscribe(e,function(a){s=a,o&&clearTimeout(o),o=setTimeout(i,n)}),s},{initialValueTarget:e})});var sue=PH;var iue="~effect-atom/atom/Atom/Serializable";var WO=d(2,(e,t)=>{let n=Gc(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,new Error().stack?.split(`
37
- `)[5]??""],[iue]:{key:t.key,encode:XA(n),decode:Fh(n)}})});var D3=()=>(e,t)=>{let n=qe()(e),r=ro(n,t.makeEffect??UO(t.group,{...t,flatten:!0})),o=t.runtime??Qf;n.runtime=o(typeof t.protocol=="function"?i=>Ds(r,Sy(t.protocol(i))):Ds(r,Sy(t.protocol))),n.mutation=Ya(i=>{let a=t.group.requests.get(i);return n.runtime.fn()(Ee(function*({headers:c,payload:u,reactivityKeys:f}){let p=(yield*n)(i,u,{headers:c});return yield*f?lE(p,f):p})).pipe(WO({key:`AtomRpc:mutation:${i}`,schema:oC({success:a.successSchema,error:N3(a)})}))});let s=Ya(i=>{let{headers:a,payload:c,reactivityKeys:u,tag:f,timeToLive:l}=i,p=t.group.requests.get(f),h=mg(p.successSchema),g=h?n.runtime.pull(Ir(n.use(x=>k(x(f,c,{headers:a}))))):n.runtime.atom(n.use(x=>x(f,c,{headers:a})));return u&&(g=n.runtime.factory.withReactivity(u)(g)),!h&&i.serializationKey&&(g=WO(g,{key:`AtomRpc:${i.tag}:${i.serializationKey}`,schema:oC({success:p.successSchema,error:N3(p)})})),l&&(g=Rs(l)?Ng(g,l):HO(g)),g});return n.query=(i,a,c)=>{let u={tag:i,payload:a,headers:c?.headers?Gi(c.headers):void 0,reactivityKeys:c?.reactivityKeys,timeToLive:c?.timeToLive?pt(c.timeToLive):void 0,serializationKey:c?.serializationKey};return s(u)},n},N3=e=>Ve([e.errorSchema,...Array.from(e.middlewares,t=>t.error),ui]);var A0={};dn(A0,{make:()=>uue});var cue={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return Xa({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[o,s]of r.requests)t.set(o,s);for(let[o,s]of r.annotations.mapUnsafe)n.set(o,s)}return Xa({requests:t,annotations:xr(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return Xa({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return Xa({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return Lt(function*(){let n=yield*Kn(),r=cr(e)?yield*e:e,o=new Map;return t.requests.forEach((s,i)=>{o.set(s.key,{tag:s._tag,handler:r[i],context:n})}),xr(o)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return Xa({requests:t,annotations:this.annotations})},toLayer(e){return Ic(this.toHandlers(e))},of:j,toLayerHandler(e,t){let n=this;return Ic(Lt(function*(){let r=yield*Kn(),o=cr(t)?yield*t:t,s=new Map,i=n.requests.get(e);return s.set(i.key,{handler:o,context:r}),xr(s)}))},accessHandler(e){return yr(t=>{let n=this.requests.get(e),{handler:r,context:o}=pa(t,n.key);return k((s,i)=>{i.rpc=n;let a=r(s,i),c=tp(a)?a.value:a;return cr(c)?eI(c,o):BR(c,o)})})},annotate(e,t){return Xa({requests:this.requests,annotations:Ge(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(ks(e,t))},annotateMerge(e){return Xa({requests:this.requests,annotations:ir(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(ir(e,r.annotations)));return Xa({requests:t,annotations:this.annotations})}},Xa=e=>Object.assign(function(){},cue,{requests:e.requests,annotations:e.annotations}),uue=(...e)=>Xa({requests:new Map(e.map(t=>[t._tag,t])),annotations:Tt()});var cp={};dn(cp,{Service:()=>fue,TypeId:()=>KO,layerClient:()=>lue});var KO="~effect/rpc/RpcMiddleware",fue=()=>(e,t)=>{let n=globalThis.Error,r=Jo();Mn(2);let o=new n;Mn(r);function s(){}let i=s;return Object.setPrototypeOf(s,Object.getPrototypeOf(qe(e))),s.key=e,Object.defineProperty(s,"stack",{get(){return o.stack}}),i[KO]=KO,i.error=t?.error??$i,i.requiredForClient=t?.requiredForClient??!1,s},lue=(e,t)=>Ic(Lt(function*(){let n=(yield*Kn()).pipe(FM(mt)),r=cr(t)?yield*t:t;return xr(new Map([[`${e.key}/Client`,o=>Xu(r(o),s=>ir(n,s))]]))}));var L3=m.Union([m.Struct({_tag:m.Literal("List"),collection:m.String}),m.Struct({_tag:m.Literal("Item"),collection:m.String,id:m.Union([m.String,m.Number])})]),Yf=(e,t)=>({item:n=>({_tag:"Item",collection:e,id:n}),list:{_tag:"List",collection:e},name:e});function q3(e){return e._tag==="List"?e.collection:`${e.collection}:${e.id}`}var R0=e=>[...new Set(e.map(q3))],C0=e=>[...new Set(e.flatMap(t=>t._tag==="List"?[t.collection]:[q3(t),t.collection]))];var due=Y.fn("EffectContract.invalidateAfter")(function*(e){yield*dE(C0(e))});function pue(e,t,n){function r(o){return R0(n.reads(o))}return{query:(o,s={})=>e.query(t,o,{...s,reactivityKeys:r(o)}),run:o=>e.use(s=>s(t,o))}}function mue(e,t,n){return{run:r=>e.use(o=>o(t,r)).pipe(Y.tap(o=>due(n.invalidates(r,o))))}}function hue(e,t){return{run:n=>pr.unwrap(e.use(r=>Y.succeed(r(t,n))))}}function O0(e,t){let{name:n,queries:r,commands:o,streams:s}=e.declaration;return Object.fromEntries([...r.map(i=>[i.name,pue(t,`${n}.${i.name}`,i)]),...o.map(i=>[i.name,mue(t,`${n}.${i.name}`,i)]),...s.map(i=>[i.name,hue(t,`${n}.${i.name}`)])])}var j3=m.Union([m.Struct({_tag:m.Literal("Changed"),keys:m.Array(L3)}),m.Struct({_tag:m.Literal("Resync")})]),gue=256;function B3(e,t){let n=Zf(!1),r=Zf({connection:"connecting",failure:Pe.none(),needsResync:!0,pending:0});return{connection:e.atom(s=>Y.gen(function*(){s.mount(r);let i=yield*Ki;function a(f){s.set(r,{...s.once(r),...f})}function c(){if(s.once(n)){a({needsResync:!0});return}i.invalidateUnsafe(R0(t.resyncKeys)),a({needsResync:!1,pending:0})}s.subscribe(n,f=>{f||c()}),t.resume!==void 0&&(s.once(t.resume),s.subscribe(t.resume,c));let u=Y.suspend(()=>{let f=!0;function l(p){a({connection:"live",failure:Pe.none()}),s.once(n)?a({needsResync:!0,pending:Math.min(gue,s.once(r).pending+1)}):f||p._tag==="Resync"?c():i.invalidateUnsafe(C0(p.keys)),f=!1}return t.stream.pipe(pr.runForEach(p=>Y.sync(()=>l(p))),Y.scoped,Y.catchCause(p=>Y.sync(()=>a({failure:Pe.some(p)}))),Y.andThen(Y.sync(()=>a({connection:"reconnecting",needsResync:!0}))),Y.andThen(Y.sleep(t.retryDelay??"1 second")))});yield*Y.forever(u)})).pipe(Ng(0)),paused:n,status:r}}function $3(e,t){return n=>{function r(){e.document.visibilityState==="visible"&&n()}return e.addEventListener(t,r),()=>e.removeEventListener(t,r)}}function H3({window:e,native:t}){let n=e===void 0?[]:[$3(e,"visibilitychange"),$3(e,"online")],r=t===void 0?n:[...n,t];return nr(o=>{let s=0;function i(){s+=1,o.setSelf(s)}for(let a of r)o.addFinalizer(a(i));return s})}function xue(e){let t=e.map(({name:n})=>n).filter((n,r,o)=>o.indexOf(n)!==r);if(t.length>0)throw new Error(`Operation names must be unique; duplicated: ${[...new Set(t)].join(", ")}`)}function z3(e,t){let n=e.middleware.bind(e);return Object.assign(e,{declaration:t,middleware:r=>z3(n(r),t)})}function up(e,t){let{queries:n=[],commands:r=[],streams:o=[]}=t;xue([...n,...r,...o]);let s=[...n,...r,...o].map(i=>np.make(`${e}.${i.name}`,{error:i.error,payload:i.payload,stream:i.kind==="stream",success:i.success}));return z3(A0.make(...s),{commands:r,name:e,queries:n,streams:o})}function W3(e){let t=Object.entries(e).map(([n,r])=>[n,m.isSchema(r)?r:m.TaggedError()(n,r)]);return{error:t.length===0?m.Never:m.Union(t.map(([,n])=>n)),Rejection:Object.fromEntries(t),reject:Object.fromEntries(t.map(([n,r])=>[n,(...o)=>Y.fail(Reflect.construct(r,o))]))}}function yue(e){return e===void 0?m.Void:m.isSchema(e)?e:m.Struct(e)}function VO(e,t,n){let{payload:r,success:o,rejections:s={}}=n;return{kind:e,name:t,payload:yue(r),rejections:s,success:o??m.Void,...W3(s)}}function xo(e,t){return{...VO("query",e,t),reads:t.reads}}function Lg(e,t){return{...VO("command",e,t),invalidates:t.invalidates}}function K3(e,t){return{...VO("stream",e,t),reads:t.reads}}var cu=class extends cp.Service()("@shivaedev/platform/rpc/RequestTracing"){},V3=class extends cp.Service()("@shivaedev/platform/rpc/Authenticated",{error:m.Union([SE,ig,Hf])}){},J3=class extends cp.Service()("@shivaedev/platform/rpc/MaybeAuthenticated",{error:m.Union([ig,Hf])}){};var _0=m.Struct({disposition:m.Literals(["applied","superseded"]),question:xt,recordedAt:m.Number.check(m.isFinite(),m.isGreaterThanOrEqualTo(0),m.isLessThanOrEqualTo(864e13)),response:m.optional(xt),reviewedRevision:No});var qg=m.String.check(m.isPattern(/\S/u),m.isMaxLength(8192)),jg=m.Struct({by:m.optional(qg),constraints:m.String.check(m.isMaxLength(8192)),goal:qg,item:xt,nextAction:qg,note:m.optional(qg),preparedAt:m.Number.check(m.isFinite(),m.isGreaterThanOrEqualTo(0),m.isLessThanOrEqualTo(864e13)),recipient:qg.check(m.isMaxLength(200)),reviewedRevision:No,source:m.String,state:m.Literals(["requested","acknowledged","rejected","unavailable"])}),JO=jg.pipe(m.encodeKeys({nextAction:"next_action",preparedAt:"prepared_at",reviewedRevision:"reviewed_revision"})),M0=m.Struct({constraints:jg.fields.constraints,goal:jg.fields.goal,id:xt,item:xt,nextAction:jg.fields.nextAction,recipient:jg.fields.recipient,revision:No,source:m.String}),GO=m.Struct({context:m.String,file:m.String,handoff:JO,id:xt,prompt:m.String}),G3=m.Struct({records:m.Array(GO),unknown:m.Array(m.String)}),Z3=m.Struct({context:m.String,id:xt,item:xt,reviewedRevision:No,source:m.String});var P0=xt,ZO=m.String.check(m.isPattern(/^[a-zA-Z\d][a-zA-Z\d._-]*(?:#[a-zA-Z\d][a-zA-Z\d._-]*)?$/u)),yo=m.String.check(m.isPattern(/\S/u)),Sue=m.Struct({id:P0,kind:m.Literals(["decision","review","blocker"]),managed:m.optional(m.Boolean),reason:yo,responseFrom:m.Array(yo).check(m.isMinLength(1)),state:m.Literals(["open","closed"]),unblocks:m.Array(ZO).check(m.isMinLength(1))}).pipe(m.encodeKeys({responseFrom:"response_from"})),bue=m.Struct({id:P0,text:yo}),Eue=m.Struct({kind:m.Literals(["implements","informs","depends_on","relates_to"]),target:ZO}),wue=m.Struct({checkedRevision:m.optional(m.String.check(m.isPattern(/^(?:[a-f\d]{40}|[a-f\d]{64})$/iu))),criterion:m.optional(ZO),method:m.optional(yo),observedAt:m.optional(yo.check(m.makeFilter(e=>Number.isFinite(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T.*(?:Z|[+-]\d{2}:\d{2})$/u.exec(e)!==null||"Expected an ISO timestamp with timezone"))),outcome:m.optional(yo),source:yo}).pipe(m.encodeKeys({checkedRevision:"checked_revision",observedAt:"observed_at"})),Q3=m.Struct({areas:m.optional(m.Array(yo)),attention:m.optional(m.Array(Sue)),criteria:m.optional(m.Array(bue)),evidence:m.optional(m.Array(wue)),handoff:m.optional(JO),id:m.optional(P0),items:m.optional(m.Array(P0)),kind:m.optional(m.Literals(["task","investigation","decision","result","project","board","question","response","handoff"])),nextAction:m.optional(yo),options:m.optional(m.Array(m.Struct({description:yo.check(m.isMaxLength(8192)),label:yo.check(m.isMaxLength(128))})).check(m.isMaxLength(32))),owner:m.optional(yo),question:m.optional(fC),recommended:m.optional(yo),relationships:m.optional(m.Array(Eue)),requestReceipt:m.optional(_0),response:m.optional(kE),status:m.optional(yo)}).pipe(m.encodeKeys({nextAction:"next_action",requestReceipt:"request_receipt"}));var vue=m.Struct({href:m.optional(m.String),label:m.String}),Y3=m.Struct({backlinks:m.Array(m.Struct({href:m.String,kind:m.String,label:m.String})),board:m.Boolean,claims:m.Record(m.String,m.Array(vue)),evidenceSources:m.Array(m.Struct({href:m.optional(m.String),problem:m.String})),lines:m.Record(m.String,m.Number),proseLine:m.Number,raw:m.optional(m.String),receipts:m.Record(m.String,_0)});var Tue=m.Struct({id:m.String,open:m.Boolean,preview:m.optional(AE),prompts:m.optional(m.Array(m.Struct({id:m.String,mode:m.Literals(["one","many","text"]),options:m.Array(m.Struct({id:m.String,source:m.String})),source:m.String}))),promptUnavailable:m.optional(m.String),responses:m.optional(m.Array(Jd)),unavailable:m.optional(m.String)}),X3=m.Struct({diagnostics:m.Array(m.Struct({field:m.optional(m.String),line:m.Number,message:m.String})),file:m.String,identity:m.optional(m.String),links:m.Record(m.String,m.String),metadata:Q3,modified:m.Number,questionActions:m.Record(m.String,m.String),reading:m.optional(Y3),references:m.Record(m.String,m.String),requests:m.Array(Tue),source:m.String,unavailable:m.Array(m.String),writable:m.Boolean});var e4=m.Struct({current:m.Boolean,href:m.String,modified:m.Number,name:m.String,path:m.String}),QO=class e extends m.Class("NavigationFolder")({active:m.Boolean,count:m.Number,files:m.Array(e4),folders:m.Array(m.suspend(()=>e)),name:m.String,path:m.String}){},t4=m.Struct({home:m.optional(m.Struct({file:m.String,identity:m.optional(m.String)})),inboxCount:m.NullOr(m.Number),records:m.Struct({active:m.Boolean,count:m.Number,files:m.Array(e4)}),tree:QO});function Iue(e){return e.startsWith(".")||e==="node_modules"}function n4(e){return e.endsWith(".md")&&!e.split("/").some(Iue)}var kue=m.String.check(m.makeFilter(e=>n4(e)&&!e.includes("\\")&&!e.includes("\0")&&e.split("/").every(t=>t.length>0&&t!=="..")||"Expected a relative readable Markdown path")),Aue=m.String.check(m.makeFilter(e=>Number.isFinite(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T.*(?:Z|[+-]\d{2}:\d{2})$/u.exec(e)!==null||"Expected an ISO observation time with timezone")),Xbe=m.Struct({documents:m.Array(m.Struct({file:kue,source:m.String})).check(m.makeFilter(e=>new Set(e.map(t=>t.file)).size===e.length||"Duplicate source paths are not a complete observation")),recordedAt:Aue,version:m.Literal(1)}).pipe(m.encodeKeys({recordedAt:"recorded_at"})),r4=m.Struct({action:m.Literals(["check","compare","observe"]),baseline:m.NullOr(m.String)}),o4=m.Struct({discardBaseline:m.Boolean,html:m.String,reason:m.String,snapshot:m.NullOr(m.String)});var rr=Yf("work-board/workspace",m.String),s4=Yf("work-board/documents",m.String),i4=Yf("work-board/identities",m.String),a4=Yf("work-board/navigation",m.String),Or=Yf("work-board/index",m.String),c4=Yf("work-board/watcher",m.String);var Xf=class extends m.TaggedError()("PublicationUncertain",{message:m.String}){},YO=class extends m.TaggedError()("Unanswered",{message:m.String}){},fi={BadRequest:bE,Conflict:sg,Forbidden:Hf,InternalServerError:kr,NotFound:og,PreconditionFailed:EE,PublicationUncertain:Xf,ServiceUnavailable:ag,Unanswered:YO},F0=m.Union(Object.values(fi)),XO={Conflict:sg,InternalServerError:kr,NotFound:og,ServiceUnavailable:ag},iEe=m.Union(Object.values(XO));var Rue=xo("handoffSource",{payload:{item:m.String},reads:()=>[rr.list,Or.list],rejections:fi,success:Z3}),Cue=xo("handoffs",{payload:{item:m.String},reads:()=>[rr.list,Or.list],rejections:fi,success:G3}),Oue=Lg("prepareHandoff",{invalidates:()=>[rr.list,Or.list],payload:M0,rejections:fi,success:GO}),U0=up("work-board",{commands:[Oue],queries:[Rue,Cue]}).middleware(cu);var _ue=xo("question",{payload:{item:m.String,request:m.String},reads:()=>[rr.list,Or.list],rejections:fi,success:AE}),Mue=xo("awaitResponse",{payload:{after:m.optional(m.String),question:m.String},reads:()=>[rr.list,Or.list],rejections:fi,success:$H}),Pue=xo("responses",{payload:{question:m.String},reads:()=>[rr.list,Or.list],rejections:fi,success:BH}),Fue=Lg("registerQuestion",{invalidates:()=>[rr.list,Or.list],payload:{item:m.String,request:m.String,revision:No},rejections:fi,success:RE}),Uue=Lg("recordResponse",{invalidates:()=>[rr.list,Or.list],payload:Gd,rejections:fi,success:Jd}),N0=up("work-board",{commands:[Fue,Uue],queries:[_ue,Pue,Mue]}).middleware(cu);function e_(e){let t=new URL(e,"http://127.0.0.1").pathname,n=/^\/_board\/item\/(?<id>[^/]+)\/$/u.exec(t)?.groups?.id,r=s4.item(decodeURIComponent(t.slice(1)));return n?r=i4.item(decodeURIComponent(n)):t.startsWith("/_board/")&&(r=Or.list),[rr.list,r]}var u4=m.String.check(m.isMaxLength(8192),m.makeFilter(e=>{if(!e.startsWith("/")||e.startsWith("//"))return"Expected a local reading URL";try{let t=new URL(e,"http://127.0.0.1").pathname;return t==="/"||["/_board/inbox","/_board/diagnostics","/_board/work","/_board/overview","/_board/changes","/_board/start","/_board/respond","/_board/handoff","/_board/result"].includes(t)||/^\/_board\/item\/[^/]+\/$/u.exec(t)!==null||/\.md$/iu.exec(t)!==null||"Expected a local reading URL"}catch{return"Expected a local reading URL"}})),Nue=m.Struct({html:m.String,status:m.Number}),Due=m.Struct({file:m.String,href:m.String,kind:m.Literals(["document","heading","passage"]),line:m.optional(m.Number),snippet:m.String,text:m.String,title:m.String}),Lue=xo("page",{payload:{url:u4},reads:({url:e})=>e_(e),rejections:{InternalServerError:kr},success:Nue}),que=xo("document",{payload:{url:u4},reads:({url:e})=>[...e_(e),Or.list],rejections:XO,success:X3}),jue=xo("navigation",{payload:{current:m.String.check(m.isMaxLength(8192))},reads:()=>[rr.list,a4.list],rejections:{InternalServerError:kr},success:t4}),Bue=xo("search",{payload:{query:m.String.check(m.isMaxLength(8192))},reads:()=>[rr.list,Or.list],rejections:{InternalServerError:kr},success:m.Struct({results:m.Array(Due),total:m.Number,unavailable:m.Array(m.String)})}),$ue=xo("history",{payload:r4,reads:()=>[rr.list,Or.list],rejections:{InternalServerError:kr},success:o4}),Hue=xo("watcher",{reads:()=>[rr.list,c4.list],rejections:{InternalServerError:kr},success:m.Struct({watching:m.Boolean})}),t_=K3("subscribe",{reads:()=>[rr.list],rejections:{InternalServerError:kr},success:j3}),n_=up("work-board",{queries:[Lue,que,jue,Bue,$ue,Hue],streams:[t_]}).middleware(cu),f4=n_.merge(N0).merge(U0);function l4(e,t={}){class n extends D3()("WorkBoard/Reader",{group:f4,protocol:Ug.layerProtocolHttp({url:`${e}/_board/rpc`}).pipe(Un.provide([zE.layer,Pg.layerNdjson]))}){}let r=O0(n_,n),o=xE({defaultIdleTTL:0,timeoutResolution:1}),s=B3(n.runtime,{resume:H3(t),resyncKeys:t_.reads(void 0),stream:r.subscribe.run(void 0)});o.mount(s.connection);async function i(f,l){try{return await Y.runPromise(Ga(o,f,{suspendOnWaiting:!0}),{signal:l})}catch(p){if(l?.aborted){let h=new Error("Reading canceled",{cause:p});throw h.name="AbortError",h}throw p}}async function a(f,l){try{return await Y.runPromise(Y.flatMap(Ga(o,n.runtime),p=>Y.provideContext(f,p)),{signal:l})}catch(p){if(l?.aborted){let h=new Error("Reading canceled",{cause:p});throw h.name="AbortError",h}throw p}}async function c(f,l){let p=await Y.runPromise(Y.result(Ga(o,n.runtime.atom(f),{suspendOnWaiting:!0})),{signal:l});if(p._tag==="Failure")throw p.failure;return p.success}let u=O0(N0,n);return{api:r,handoffs:O0(U0,n),mutate:c,read:i,registry:o,responses:u,run:a,updates:s}}var D0=new WeakMap;function fp(e){let t=D0.get(e);if(t===void 0){let o=function(){r.registry.dispose(),D0.get(e)===r&&D0.delete(e),e.removeEventListener("pagehide",o)};var n=o;t=l4(e.location.origin,{window:e}),D0.set(e,t);let r=t;e.addEventListener("pagehide",o)}return t}var bs="~effect/reactivity/AtomRef",q0=e=>new o_(e);var i_={count:0,generate(){return`AtomRef-${this.count++}`}},r_=class{[bs];key=i_.generate();value;constructor(t){this[bs]=bs,this.value=t}[ke](t){return ne(this.value,t.value)}[Ie](){return ue(this.value)}listeners=null;notify(t){let n=this.listeners;for(;n!==null;)n.f(t),n=n.next}subscribe(t){let n={f:t,prev:null,next:this.listeners};return this.listeners&&(this.listeners.prev=n),this.listeners=n,()=>{this.listeners===n&&(this.listeners=n.next),n.prev&&(n.prev.next=n.next),n.next&&(n.next.prev=n.prev)}}map(t){return new L0(this,t)}},o_=class extends r_{prop(t){return new s_(this,t)}set(t){return ne(t,this.value)?this:(this.value=t,this.notify(t),this)}update(t){return this.set(t(this.value))}},L0=class e{[bs];key=i_.generate();parent;transform;constructor(t,n){this[bs]=bs,this.parent=t,this.transform=n}[ke](t){return ne(this.value,t.value)}[Ie](){return ue(this.value)}get value(){return this.transform(this.parent.value)}subscribe(t){let n=this.transform(this.parent.value);return this.parent.subscribe(r=>{let o=this.transform(r);ne(o,n)||(n=o,t(o))})}map(t){return new e(this,t)}},s_=class e{[bs];key=i_.generate();previous;parent;_prop;constructor(t,n){this[bs]=bs,this.parent=t,this._prop=n,this.previous=t.value[n]}[ke](t){return ne(this.value,t.value)}[Ie](){return ue(this.value)}get value(){return this.parent.value&&this._prop in this.parent.value&&(this.previous=this.parent.value[this._prop]),this.previous}subscribe(t){let n=this.value;return this.parent.subscribe(r=>{if(!r||!(this._prop in r))return;let o=r[this._prop];ne(o,n)||(n=o,t(o))})}map(t){return new L0(this,t)}prop(t){return new e(this,t)}set(t){if(Array.isArray(this.parent.value)){let n=this.parent.value.slice();n[this._prop]=t,this.parent.set(n)}else this.parent.set({...this.parent.value,[this._prop]:t});return this}update(t){if(Array.isArray(this.parent.value)){let n=this.parent.value.slice();n[this._prop]=t(this.parent.value[this._prop]),this.parent.set(n)}else this.parent.set({...this.parent.value,[this._prop]:t(this.parent.value[this._prop])});return this}};var j0={};function d4({baseline:e,current:t,settled:n},r){return De.equals(t[r],e[r])||Object.hasOwn(n,r)&&De.equals(t[r],n[r])}function c_(e){return Object.keys({...e.baseline,...e.current}).some(t=>!d4(e,t))}function zue(e,t){let n={};for(let r of Object.keys({...e.current,...t})){let o=d4(e,r)?t:e.current;Object.hasOwn(o,r)&&(n[r]=o[r])}return n}function Wue(e,t){return Object.fromEntries(Object.keys({...e,...t}).filter(n=>De.equals(e[n],t[n])).map(n=>[n,t[n]]))}var p4=e=>{let t=q0({baseline:e,current:e,settled:j0});return{dirty:nr(n=>(n.addFinalizer(t.subscribe(r=>n.setSelf(c_(r)))),c_(t.value))),receive:n=>{t.update(r=>({baseline:n,current:c_(r)?zue(r,n):n,settled:j0}))},revert:()=>{t.update(n=>({...n,current:n.baseline,settled:j0}))},submission:()=>{let{baseline:n,current:r}=t.value;return{accept:()=>{t.update(o=>o.baseline===n?{...o,baseline:r,settled:j0}:{...o,settled:Wue(o.current,r)})},values:r}},values:t.prop("current")}};var m4={},Kue="Required",Vue="effect/schema/isMinLength";function Jue(e){let t=e.annotations?.representation;if(t===void 0||t.id!==Vue)return!1;let n=t.payload;return typeof n!="object"||n===null||!("minLength"in n)?!1:n.minLength===1}var Gue=e=>co.defaultCheckHook(e)??(Jue(e.filter)?Kue:void 0),h4=co.makeFormatterStandardSchemaV1({checkHook:Gue});function Zue(e){return String(typeof e=="object"?e.key:e)}function u_(e){let t=Object.create(null);for(let n of h4(e).issues){let r=n.path?.[0];if(r===void 0)continue;let o=Zue(r);Object.hasOwn(t,o)||(t[o]=n.message)}return t}function Que(e,t){for(let n of h4(e).issues)if(t.every((r,o)=>{let s=n.path?.[o];return s!==void 0&&r===(typeof s=="object"?s.key:s)}))return n.message}function g4(e){let t=Po.toEncoded(e);if(t._tag!=="Union")return;let n=[];for(let r of t.types){if(r._tag!=="Literal")return;n.push(r.literal)}return n}function f_(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function x4(e){let t=au(e,n=>Pe.match(Kd(n),{onNone:()=>m4,onSome:r=>Ut.isFailure(r)?u_(r.failure):m4}));return{at:n=>au(e,r=>{if(!r.waiting)return Pe.match(Kd(r),{onNone:()=>{},onSome:o=>Ut.isFailure(o)?Que(o.failure,n):void 0})}),field:Ya(n=>au(t,r=>f_(r,n)))}}function $0(e){return typeof e=="string"?[e]:e}function B0(e,t){let n=e;for(let[r,o]of t.entries()){if(typeof n!="object"||n===null)return;if(!Object.hasOwn(n,o))return r===t.length-1&&!Array.isArray(n)?{value:void 0}:void 0;n=Reflect.get(n,o)}return{value:n}}function y4(e,t,n){let r=e.flatMap((o,s)=>n(o)===t?[s]:[]);return r.length===1?r[0]:void 0}function H0(e,t,n,r){let o=r.get(e[0]),s=e;if(o!==void 0&&typeof e[1]=="number"){let c=B0(t,[e[0]])?.value,u=B0(n,[e[0]])?.value;if(!(Array.isArray(c)&&Array.isArray(u)&&Object.hasOwn(c,e[1])))return;let f=o(c[e[1]]),l=y4(u,f,o);if(l===void 0||y4(c,f,o)!==e[1])return;s=[e[0],l,...e.slice(2)]}let i=B0(t,e),a=B0(n,s);return i!==void 0&&a!==void 0&&De.equals(i.value,a.value)?s:void 0}function S4(e,t){return e.find(n=>t.every((r,o)=>r===n.path[o]))?.message}var el=e=>nr(t=>(t.addFinalizer(e.subscribe(n=>t.setSelf(n))),e.value)),l_=(e,t)=>{let n=e.map(s=>s[t]),r=e.prop(t),o={[bs]:bs,[De.symbol]:s=>De.equals(n,s),[Ot.symbol]:()=>Ot.hash(n),key:n.key,map:s=>n.map(s),prop:s=>l_(o,s),set:s=>(r.set(s),o),subscribe:s=>n.subscribe(s),update:s=>o.set(s(n.value)),get value(){return n.value}};return o};var lp=class extends Vo.TaggedError("FieldFailure"){},z0=class extends Vo.TaggedError("Invalid"){};var b4=()=>{let e=q0({failures:[],submitted:!1,touched:{}}),t=el(e.prop("failures"));return{attempt:()=>{e.update(n=>({...n,failures:[],submitted:!0}))},failures:au(t,n=>{let r=Object.create(null);for(let{path:o,message:s}of n)Object.hasOwn(r,o[0])||(r[o[0]]=s);return r}),note:(n,r)=>{let o=$0(n);e.update(s=>({...s,failures:[...s.failures.filter(i=>!De.equals(i.path,o)),{message:r,path:o}]}))},paths:t,rebase:(n,r,o)=>{e.update(s=>({...s,failures:s.failures.flatMap(i=>{let a=H0(i.path,n,r,o);return a===void 0?[]:[{...i,path:a}]})}))},submitted:el(e.prop("submitted")),touch:n=>{e.update(r=>r.touched[n]===!0&&!r.failures.some(o=>o.path.length===1&&o.path[0]===n)?r:{...r,failures:r.failures.filter(o=>o.path.length!==1||o.path[0]!==n),touched:{...r.touched,[n]:!0}})},touched:el(e.prop("touched"))}};function E4(e,t,n){let r=new Map(Object.entries(t??{}).map(([s,i])=>[s,i])),o=e.value;return e.subscribe(s=>{n.rebase(o,s,r),o=s}),s=>i=>Y.sync(()=>{if(i instanceof lp){let a=H0(i.segments??$0(i.path),s,e.value,r);a!==void 0&&n.note(a,i.message)}})}var W0=(e,t)=>{let{initialValues:n,onSubmit:r,runtime:o}=t,s=t.debounce??"300 millis",i=new Map(Object.entries(t.checks??{})),a=za.decodeUnknownEffect(e,{errors:"all"}),c=p4(n),{values:u}=c,f=b4(),l=E4(u,t.arrayKeys,f),p=new Map;function h(T){let R=p.get(T);if(R!==void 0)return R;let C=l_(u,T);return p.set(T,C),C}let g=new Map;for(let[T,R]of Object.entries(e.fields)){let C=g4(R.ast);C!==void 0&&g.set(T,C)}let x=el(u),S=o.atom(T=>a(T(x)).pipe(Y.match({onFailure:R=>Ut.fail(R),onSuccess:R=>Ut.succeed(R)}))),w=x4(S),E=Ya(T=>{let R=i.get(T);if(R===void 0)return Zf(()=>{});let C=el(h(T)),P=U3(C,s),B=o.atom(F=>{let Z=F(P);return Y.map(R(Z),z=>({input:Z,message:z}))});return nr(F=>{let Z=F(B),z=F(C);return Zc(Z)&&!Z.waiting&&De.equals(Z.value.input,z)?Z.value.message:void 0})}),y=Ya(T=>nr(R=>{if(!(R(f.touched)[T]!==!0&&!R(f.submitted)))return f_(R(f.failures),T)??R(w.field(T))??R(E(T))})),v={fail:(T,R)=>Y.fail(new lp(typeof T=="string"?{message:R,path:T}:{message:R,path:T[0],segments:T}))},b=o.fn()(()=>Y.gen(function*(){f.attempt();let T=c.submission(),R=T.values,C=yield*a(R).pipe(Y.mapError(P=>new z0({messages:u_(P)})));return yield*r(C,v,R).pipe(Y.tapError(l(R)),Y.tap(()=>Y.sync(T.accept)))}));return{blur:f.touch,change:(T,R)=>{h(T).set(R),f.touch(T)},choices:T=>g.get(T),dirty:c.dirty,error:y,errorAt:Ya(T=>{let R=w.at(T);return nr(C=>C(f.touched)[T[0]]===!0||C(f.submitted)?S4(C(f.paths),T)??C(R):void 0)}),field:T=>h(T),receive:c.receive,revert:c.revert,submit:b,submitting:au(b,CH),values:u}};function w4(e,t,n,r,o){let s=W0(M0,{initialValues:{constraints:t.constraints.value,goal:t.goal.value,id:n.id,item:e.dataset.item??"",nextAction:t.nextAction.value,recipient:t.recipient.value,revision:n.revision,source:e.dataset.source??""},onSubmit:a=>Y.tryPromise({catch:c=>c,try:()=>o(a)}),runtime:Qf(Un.empty)}),i=wE(s,r,[{control:t.constraints,name:"constraints"},{control:t.goal,name:"goal"},{control:t.nextAction,name:"nextAction"},{control:t.recipient,name:"recipient"},{name:"id"},{name:"item"},{name:"revision"},{name:"source"}]);return{model:s,valid:i}}function d_(){let e=document.getElementById("doc");if(e?.dataset.view!=="handoff")return;uC(e);let t=e.querySelector("#handoff-form");if(!t||t.dataset.bound==="true")return;let n=qH(t),r=t.querySelector("#handoff-status"),o=t.querySelector("#handoff-preview-content"),s=t.querySelector("#handoff-preview"),i=t.querySelector("#handoff-submit"),a=t.querySelector("#handoff-clear"),c=t.querySelector("#handoff-prepared");if(!(n&&r&&o&&s&&i&&a&&c))return;let u=n;t.dataset.bound="true";let f=t.dataset.revision??"",l=t.dataset.question??"",p;try{p=window.localStorage}catch{p=void 0}r.textContent?.includes("JavaScript is required")&&(r.textContent="Draft ready. Review and preview before preparing the file.");let h=_E(`handoff:${t.dataset.item}`,f,p,`work-board:drafts:${document.documentElement.dataset.workspace}`,v=>{r.textContent=v},"handoff"),g=h.current();jH(u,g);let x=vE(t),S=g,{model:w,valid:E}=w4(t,u,g,x,async v=>{let b=fp(window),T=await b.mutate(b.handoffs.prepareHandoff.run(v)),R=h.saved(S);return g=h.current(),t.isConnected&&(r.textContent=`Prepared: ${T.file}. Receipt: ${T.handoff.state}; execution and acceptance remain separate.${R?"":" Your newer draft remains unsaved."}`,LH(c,T.id,T.prompt)),T});function y(){w.change("recipient",u.recipient.value),w.change("constraints",u.constraints.value),w.change("goal",u.goal.value),w.change("nextAction",u.nextAction.value);let v=w.values.value;g=h.update({author:v.recipient,body:JSON.stringify({constraints:v.constraints,goal:v.goal,nextAction:v.nextAction})})}t.addEventListener("input",()=>{y(),o.hidden=!0,i.disabled=!0},{signal:x.signal}),s.disabled=!1,a.disabled=!1,a.addEventListener("click",h.clear,{signal:x.signal}),s.addEventListener("click",()=>{y(),g=h.update({id:g.revision===f&&(!g.question||g.question===l)?g.id:`handoff.${crypto.randomUUID()}`,question:l,revision:f}),w.change("id",g.id),w.change("revision",f);let v=w.values.value;o.textContent=`New file: handoffs/${v.id}.md
38
- Prepared time and reviewed snapshot are assigned by the server.
39
-
40
- ---
41
- ${JSON.stringify({handoff:{constraints:v.constraints,goal:v.goal,item:v.item,next_action:v.nextAction,recipient:v.recipient,reviewed_revision:v.revision,source:v.source,state:"requested"},id:v.id,kind:"handoff"},null,2)}
42
- ---
43
- The complete reviewed source is preserved below the frontmatter.`,o.hidden=!1,i.disabled=t.dataset.writable!=="true"||!E()},{signal:x.signal}),t.addEventListener("submit",async v=>{if(v.preventDefault(),!(i.disabled||!E()||!t.reportValidity())){S=g,i.disabled=!0,s.disabled=!0,r.textContent="Pending: preparing the local handoff file\u2026",x.registry.set(w.submit,void 0);try{await Y.runPromise(Ga(x.registry,w.submit,{suspendOnWaiting:!0}))}catch(b){t.isConnected&&(r.textContent=Yue(b))}s.disabled=!1}},{signal:x.signal})}function Yue(e){return`${m.is(F0)(e)&&!(e instanceof Xf)&&!(e instanceof kr)?"Rejected":"Uncertain"}: ${String(e)}. Draft retained; preview and retry.`}function v4(){document.addEventListener("board-page",d_),window.addEventListener("pageshow",d_),d_()}function T4(e){let t=Pe.getOrUndefined(In.findErrorOption(e));return $t.isTagged(t,"NotFound")||$t.isTagged(t,"Conflict")}function I4(e){let t=document.activeElement;if((t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&t.type==="text")&&e.contains(t))return{direction:t.selectionDirection,end:t.selectionEnd,name:t.name,prompt:t.closest("[data-prompt]")?.dataset.prompt,start:t.selectionStart}}function k4(e,t){if(!t)return;let n=[...e.querySelectorAll("input, textarea")].find(r=>r.name===t.name&&r.closest("[data-prompt]")?.dataset.prompt===t.prompt);n?.focus({preventScroll:!0}),t.start!==null&&t.end!==null&&n?.setSelectionRange(t.start,t.end,t.direction??void 0)}var A4=new WeakMap;function R4(e){return`${e.dataset.question}:${e.dataset.revision}`}function C4(e){let t=A4.get(e);return t&&t.context!==R4(e)&&t.release(),I4(e)}function O4(e,t){A4.set(e,{context:R4(e),release:t})}function _4(e,t){let n=`work-board:author:${t??""}`;function r(s){if(s)return s;try{return e?.getItem(n)?.slice(0,200)??""}catch{return""}}function o(s){try{return e?.setItem(n,s.slice(0,200)),!0}catch{return!1}}return{read:r,save:o}}function M4(e,t){let n=document.documentElement.dataset.workspace,r;try{r=window.localStorage}catch{r=void 0}return{drafts:_E(`${e.dataset.item??""}/${e.dataset.request??""}`,e.dataset.revision??"",r,`work-board:drafts:${n}`,t),label:_4(r,n)}}function P4(e){return e.querySelector("legend")?.textContent??"Question"}function Xue(e){return!(e.querySelector("input:checked")||e.querySelector("textarea")?.value.trim())}function efe(e,t,n){if(e===t&&!t.value.trim())return"Add your local author label.";let r=e.closest("fieldset");return r&&n.includes(r)?`Unanswered: ${P4(r)}. Choose an option or answer in your own words.`:e.validationMessage}function tfe(e,t,n){t.textContent=n,t.hidden=!n,e.setAttribute("aria-invalid",String(!!n)),n&&e.closest("details")?.setAttribute("open","")}function nfe(e,t){let n=e.nextElementSibling,r=n instanceof HTMLElement&&n.classList.contains("response-field-error")?n:document.createElement("span");return r.id=`response-error-${t}`,r.className="response-field-error",r.hidden=!0,e.after(r),e.setAttribute("aria-describedby",r.id),{control:e,message:r}}function rfe(e,t){return e?t?"Preview ready. Record this response when you are ready.":"Draft ready. Preview the Markdown before recording it.":"This draft is invalid. Review the response fields before recording."}function F4(e,t,n){let{author:r,body:o,status:s,supersedes:i,type:a}=t,c=[...e.querySelectorAll("fieldset[data-prompt]")],f=[r,o,a,...i instanceof HTMLSelectElement?[i]:[],...c.flatMap(h=>[...h.querySelectorAll("textarea")])].map(nfe);function l(h,g=!1){let x=n(),S=a.value==="answer"?c.filter(Xue):[];for(let{control:y,message:v}of f)tfe(y,v,efe(y,r,S));let w=f.filter(({message:y})=>!y.hidden),E=[r.value.trim()?"":"Add your local author label.",S.length>0?`Unanswered prompts: ${S.map(P4).join("; ")}.`:"",...w.filter(({control:y})=>y!==r&&!y.closest("fieldset")).map(({message:y})=>y.textContent)].filter(Boolean).join(" ");return e.dataset.writable==="true"&&s.dataset.outcome!=="pending"&&(delete s.dataset.outcome,s.textContent=[h,E||rfe(x,g)].filter(Boolean).join(" ")),x&&w.length===0}function p(){f.find(({message:h})=>!h.hidden)?.control.focus()}return{focus:p,show:l}}function U4(e){let t=e.querySelector("#response-status"),n=e.elements.namedItem("author"),r=e.elements.namedItem("body"),o=e.elements.namedItem("type"),s=e.elements.namedItem("supersedes"),i=e.querySelector("#response-submit"),a=e.querySelector("#response-preview-content"),c=e.querySelector("#response-clear"),u=e.querySelector("#response-preview");if(t&&n instanceof HTMLInputElement&&r instanceof HTMLTextAreaElement&&o instanceof HTMLSelectElement&&i&&a&&c&&u)return{author:n,body:r,clear:c,preview:a,previewButton:u,status:t,submit:i,supersedes:s,type:o}}function N4(e){return m.Struct({...Gd.fields,body:e?Gd.fields.body:Gd.fields.body.check(m.isMinLength(1)),revision:No,type:m.String.pipe(m.decodeTo(TE))}).check(m.makeFilter(t=>t.type==="answer"?t.answers?.flatMap((n,r)=>n.selected.length===0&&!n.text.trim()?[{issue:"Choose an option or answer in your own words.",path:["answers",r,"text"]}]:[]):void 0))}function D4(e,t,n,r,o,s){let{author:i,body:a,supersedes:c,type:u}=t,f=e.dataset.question??"",l=W0(N4(r.models.length>0),{initialValues:{answers:r.read(),author:i.value,body:a.value,id:n.id,question:f,revision:n.revision,supersedes:n.supersedes,type:u.value},onSubmit:g=>Y.tryPromise({catch:x=>x,try:()=>s(g)}),runtime:Qf(Un.empty)}),p=wE(l,o,[{control:i,name:"author"},{control:a,name:"body"},{control:u,name:"type"},{control:c instanceof HTMLSelectElement?c:void 0,name:"supersedes"},{name:"answers"},{name:"id"},{name:"question"},{name:"revision"}],[...e.querySelectorAll("[data-answer-text]")].map((g,x)=>({control:g,path:["answers",x,"text"]})));function h(){return l.change("author",t.author.value),l.change("body",t.body.value),l.change("type",t.type.value),l.change("answers",r.read()),l.change("supersedes",c instanceof HTMLSelectElement&&c.value||void 0),l.values.value}return{model:l,sync:h,valid:p}}function L4(e,t,n){return`# Recorded response
44
-
45
- ${e.map((o,s)=>{let i=t[s],a=o.options.filter(c=>i?.selected.includes(c.id));return`## Question: ${o.id}
46
-
47
- ${o.source}
48
-
49
- Selected: ${a.map(c=>c.id).join(", ")||"No supplied option"}
50
-
51
- ${a.map(c=>c.source).join(`
52
-
53
- `)}
54
-
55
- ${i?.text.trim()?`Additional text:
56
-
57
- ${i.text}`:""}`}).join(`
58
-
59
- `)}
60
-
61
- ${n.trim()?`## Overall response
62
-
63
- ${n}`:""}`.trim()}function q4(e,t,n=[]){return`New file: responses/${e.id}.md
64
- Registration (if needed): responses/${t}.md
65
- Recorded time is assigned by the server when saving.
66
-
67
- ---
68
- ${JSON.stringify({id:e.id,kind:"response",response:{answers:e.answers,author:e.author,question:t,reviewedRevision:e.revision,supersedes:e.supersedes,type:e.type}},null,2)}
69
- ---
70
- ${e.answers?L4(n,e.answers,e.body):e.body}`}function ofe(e,t,n){for(let r of e){let o=t.answers?.find(i=>i.prompt===r.dataset.prompt);for(let i of r.querySelectorAll("input"))i.checked=n&&(o?.selected.includes(i.value)??!1);let s=r.querySelector("textarea");s&&(s.value=o?.text??"")}}function j4(e,t){function n(c){return c.dataset.mode==="text"?"text":c.dataset.mode==="many"?"many":"one"}let r=[...e.querySelectorAll("fieldset[data-prompt]")];function o(){for(let c of e.querySelectorAll("button[data-choice]")){let u=e.querySelector(`input[value="${c.dataset.choice}"]`);c.setAttribute("aria-pressed",String(u?.checked??!1))}}e.addEventListener("click",c=>{let u=c.target instanceof Element?c.target.closest("button[data-choice]"):null;if(!u)return;let f=e.querySelector(`input[value="${u.dataset.choice}"]`);f&&(f.checked=!0,o(),f.dispatchEvent(new Event("input",{bubbles:!0})))},{signal:t}),e.addEventListener("input",o,{signal:t});let s=r.map(c=>({id:c.dataset.prompt??"",mode:n(c),options:[...c.querySelectorAll("input[data-option-source]")].map(u=>({id:u.value,source:u.dataset.optionSource??""})),source:c.dataset.source??""}));function i(){return r.length===0?void 0:r.map(c=>({prompt:c.dataset.prompt??"",selected:[...c.querySelectorAll("input:checked")].map(u=>u.value),text:c.querySelector("textarea")?.value??""}))}function a(c,u){let f=c.revision===u&&(c.question===void 0||c.question===e.dataset.question);ofe(r,c,f),o();let l=e.querySelector("#response-draft-recovery"),p=!f&&c.answers?`Earlier template answers (selections cleared; review before choosing again):
71
- ${JSON.stringify(c.answers,null,2)}
72
- ${c.recovery??""}`:c.recovery;return l&&(l.textContent=p??"",l.hidden=!p),p}for(let c of r)c.querySelector("[data-clear-choices]")?.addEventListener("click",()=>{for(let u of c.querySelectorAll("input"))u.checked=!1;e.dispatchEvent(new Event("input",{bubbles:!0}))},{signal:t});return{models:s,read:i,restore:a}}async function B4(e,t,n,r,o){t.dataset.outcome="pending",t.textContent="Pending: registering reviewed context, then recording response\u2026";let s=fp(window);try{let i=await s.mutate(s.responses.registerQuestion.run({item:e.dataset.item??"",request:e.dataset.request??"",revision:o.revision}));await s.mutate(s.responses.recordResponse.run({...o,question:i.id})),e.isConnected&&(t.dataset.outcome="saved",t.textContent=`Saved: responses/${o.id}.md. This records feedback, not acceptance.`);let a=n.saved(r);return!a&&e.isConnected&&(t.textContent+=" Your current draft remains unsaved."),a}catch(i){if(e.isConnected){let a=m.is(F0)(i)&&!(i instanceof Xf)&&!(i instanceof kr)?"rejected":"uncertain";t.dataset.outcome=a,t.textContent=`${a==="rejected"?"Rejected":"Uncertain"}: ${String(i)}. Draft retained. Preview and retry with the same identity; saved content will be reconciled.`}throw i}}function dp(){let e=document.getElementById("doc");if(!e)return;let t=e.querySelector("#response-form");if(!t)return;let n=C4(t);if(!t||t.dataset.bound==="true")return;t.dataset.bound="true";let r=U4(t);if(!r)return;let o=r,{author:s,body:i,clear:a,preview:c,previewButton:u,status:f,submit:l,supersedes:p,type:h}=o;f.textContent?.includes("JavaScript is required")&&(f.textContent="Draft ready. Preview the Markdown before recording it.");let g=t.dataset.revision??"",x=t.dataset.question??"",S="",{drafts:w,label:E}=M4(t,z=>{S=z,f.textContent=z}),y=w.current(),v=vE(t);O4(t,v.release);let b=j4(t,v.signal),T=b.restore(y,g);y.question&&y.question!==x&&y.revision===g&&(S="Source moved since this draft. Text is retained and selections cleared; review the source and preview before responding.",f.textContent=S),p instanceof HTMLSelectElement&&(p.value=y.supersedes??""),s.value=E.read(y.author),i.value=y.body,h.value=y.type;let R=y,{model:C,sync:P,valid:B}=D4(t,o,y,b,v,z=>B4(t,f,w,R,z)),F=F4(t,o,B);F.show(S);function Z(){let z=P();E.save(z.author),y=w.update({answers:z.answers,author:z.author,body:z.body,question:y.question??x,recovery:T,revision:y.revision,supersedes:z.supersedes,type:z.type}),C.change("id",y.id)}t.addEventListener("input",()=>{Z(),c.hidden=!0,l.disabled=!0,F.show(S)},{signal:v.signal}),u.disabled=!1,a.disabled=!1,u.addEventListener("click",()=>{Z(),S.startsWith("Source ")&&(S=""),C.change("id",y.revision===g&&(!y.question||y.question===x)?w.current().id:`response.${crypto.randomUUID()}`),C.change("question",x),C.change("revision",g),y=w.update({...C.values.value,recovery:T}),c.textContent=q4(y,x??"",b.models),c.hidden=!1;let z=F.show(S,!0);l.disabled=t.dataset.writable!=="true"||!z},{signal:v.signal}),a.addEventListener("click",w.clear,{signal:v.signal}),t.addEventListener("submit",async z=>{if(z.preventDefault(),P(),!F.show(S,!0)){F.focus();return}if(l.disabled||y.revision!==g||y.question!==x){f.textContent="Preview the current draft before recording. Your text is retained.";return}l.disabled=!0,u.disabled=!0,R=y,v.registry.set(C.submit,void 0),await Y.runPromise(Ga(v.registry,C.submit,{suspendOnWaiting:!0})).catch(()=>!1)&&(y=w.current(),T=y.recovery,t.isConnected&&(C.receive({...C.values.value,answers:void 0,body:"",id:y.id,supersedes:void 0}),C.revert(),i.value=C.field("body").value,b.restore(y,g),p instanceof HTMLSelectElement&&(p.value=""))),u.disabled=!1},{signal:v.signal}),k4(t,n)}function $4(){document.addEventListener("board-page",dp),window.addEventListener("pageshow",dp),dp()}var z4=new Set(["DIV","SECTION","ARTICLE","HEADER","FOOTER","MAIN","NAV","FORM","SELECT","LABEL","ASIDE","DETAILS"]),Bg=new WeakMap;function p_(e){return[...e.childNodes].every(t=>t.nodeType===1||t.textContent?.trim()==="")}function m_(e){e.matches("[data-modified]")||!e.matches("p, li, pre, blockquote, h1, h2, h3, h4, h5, h6, .item, .notes, .metadata-panel")||(e.setAttribute("data-live-change",""),setTimeout(()=>e.removeAttribute("data-live-change"),2500))}function $g(e){let t=e.cloneNode(!0);if(!(t instanceof Element))throw new Error("Expected an element");for(let n of[t,...t.querySelectorAll("#response-form, #handoff-form")])(n.id==="response-form"||n.id==="handoff-form")&&(n.replaceChildren(),n.removeAttribute("data-bound"));for(let n of t.querySelectorAll("[data-visual-tools], [data-image-error], [data-diagram-error]"))n.remove();for(let n of[t,...t.querySelectorAll("*")])sfe(n);return t.outerHTML}function pp(e){if(Bg.set(e,$g(e)),z4.has(e.tagName))for(let t of e.children)pp(t)}function W4(e){return Bg.has(e)||Bg.set(e,$g(e)),Bg.get(e)}function K4(e,t){Bg.set(e,t)}function H4(e){let t=e.cloneNode(!1);if(!(t instanceof Element))throw new Error("Expected an element");return t.removeAttribute("data-live-change"),t.tagName==="DETAILS"&&t.removeAttribute("open"),t.outerHTML}function V4(e,t){return e.tagName===t.tagName&&z4.has(e.tagName)&&H4(e)===H4(t)}function sfe(e){if(e.removeAttribute("data-live-change"),e.tagName==="DETAILS"&&e.removeAttribute("open"),e.matches("figure.diagram")&&(e.querySelector(".diagram-svg")?.remove(),e.setAttribute("data-state","pending"),e.removeAttribute("data-error")),e.matches("[data-modified]")&&(e.textContent=""),e.matches("img[data-local-image]")){e.setAttribute("src",e.getAttribute("data-local-image")??"");for(let t of["tabindex","role","aria-label"])e.removeAttribute(t)}}function ec(e,t){let n=e[t];if(n===void 0)throw new Error("Invalid reconciliation index");return n}function ife(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let r=0;for(;r<e.length-n&&r<t.length-n&&e.at(-1-r)===t.at(-1-r);)r+=1;return{start:n,tail:r}}function afe(e,t,n,r){let o=e.length-n-r,s=t.length-n-r,i=Array.from({length:o+1},()=>new Uint32Array(s+1));function a(c,u){return ec(ec(i,c),u)}for(let c=o-1;c>=0;c-=1)for(let u=s-1;u>=0;u-=1)ec(i,c)[u]=e[n+c]===t[n+u]?a(c+1,u+1)+1:Math.max(a(c+1,u),a(c,u+1));return{m:s,n:o,score:a}}function J4(e,t){let{start:n,tail:r}=ife(e,t),{m:o,n:s,score:i}=afe(e,t,n,r),a=Array.from({length:n},(f,l)=>[l,l]),c=0,u=0;for(;c<s&&u<o;)e[n+c]===t[n+u]?(a.push([n+c,n+u]),c+=1,u+=1):i(c+1,u)>=i(c,u+1)?c+=1:u+=1;for(let f=r;f>0;f-=1)a.push([e.length-f,t.length-f]);return a.push([e.length,t.length]),a}function G4(e,t){return pp(e),t&&m_(e),e}function cfe(e,t,n,r,o,s,i,a){let c=o,u=s;for(;c<i&&u<a;c+=1,u+=1){let f=ec(t,c),l=ec(n,u);if(V4(f,l)){let p=$g(l);h_(f,l,r),K4(f,p)}else f.replaceWith(G4(l,r))}for(;c<i;c+=1)ec(t,c).remove();for(;u<a;u+=1)e.insertBefore(G4(ec(n,u),r),t[i]??null)}function ufe(e,t,n){let r=[...e.children],o=[...t.children],s=0,i=0;for(let[a,c]of J4(r.map(W4),o.map($g)))cfe(e,r,o,n,s,i,a,c),s=a+1,i=c+1}function h_(e,t,n){let r=e instanceof HTMLSelectElement?e.value:null,o=t instanceof HTMLSelectElement?t.value:"";if(p_(e)&&p_(t))ufe(e,t,n);else{e.replaceChildren(...t.childNodes);for(let s of e.children)pp(s);n&&m_(e);return}e instanceof HTMLSelectElement&&r!==null&&(e.value=[...e.options].some(s=>s.value===r)?r:o)}function Z4(e){let t=new Map;return[...e.querySelectorAll("details")].map(n=>{let r=n.dataset.key??`${n.closest(".item")?.querySelector("h3")?.textContent??""}|${n.querySelector("summary")?.textContent??""}`,o=t.get(r)??0;return t.set(r,o+1),[`${r}#${o}`,n]})}function Q4(e,t,n=!1){let r=Z4(e),o=new Map(r.map(([c,u])=>[c,u.open])),s=new Set(r.map(([,c])=>c)),i=[...e.querySelectorAll("figure.diagram")].map(c=>c.querySelector(".diagram-svg"));h_(e,t,n);let a=[...e.querySelectorAll("figure.diagram")];i.length===a.length&&a.forEach((c,u)=>{let f=i[u];c.dataset.state!=="pending"||!f||f.isConnected||(c.prepend(f),c.dataset.state="redrawing")});for(let[c,u]of Z4(e)){let f=o.get(c);f!==void 0&&!s.has(u)&&(u.open=f)}}async function Y4(){let e="/_board/client.js",t="/_board/navigation.js";return await import(e),import(t)}var Zwe=y_;typeof window<"u"&&typeof document<"u"&&($4(),v4());var Ywe=fp,tve=pp,nve=Q4,ove=Y4,sve=dp,ive=T4;export{sve as attachResponses,ove as legacyRuntime,Zwe as navigationHtml,tve as remember,ive as resolvedDocumentFailure,Ywe as session,nve as swap};
36
+ `}}}})},r6=_E(),n6=e=>fn.of({contentType:e?.contentType??"application/json",includesFraming:!1,codecFor:OE,makeUnsafe:()=>{let t=new Map;return{decode:r=>{let n=JSON.parse(typeof r=="string"?r:e6(r));return s6(n,t)},encode:r=>{let n=i6(r,t);return n&&JSON.stringify(n)}}}}),o6=e=>fn.of({contentType:e?.contentType??"application/json-rpc",includesFraming:!0,codecFor:OE,makeUnsafe:()=>{let t=_E({maxBufferSize:e?.maxBufferSize}).makeUnsafe(),r=new Map;return{decode:n=>{let o=t.decode(n);if(o.length===0)return[];let s=[];for(let i=0;i<o.length;i++)s.push(...s6(o[i],r));return s},encode:n=>{let o=i6(n,r);return o&&t.encode(o)}}}});function s6(e,t){if(Array.isArray(e)){let r={size:0,responses:new Map},n=[];for(let o=0;o<e.length;o++){let s=e[o];if(!Gt(s))continue;let i=Y4(s);n.push(i),i._tag==="Request"&&!i.isNotification&&(r.size++,t.set(i.id,r))}return n}return Gt(e)?[Y4(e)]:[]}function Y4(e){if(Object.hasOwn(e,"method")){let n=e;if(UO(n.id)&&On(n.method)&&n.method.startsWith("@effect/rpc/")){let o=n.method.slice(12),s=n.params?.requestId;return s!==void 0?{_tag:o,requestId:s}:{_tag:o}}return{_tag:"Request",id:n.id??"",tag:n.method,payload:n.params??null,headers:n.headers??[],...O(n,"id")?{}:{isNotification:!0},...n.spanId?{traceId:n.traceId,spanId:n.spanId,sampled:n.sampled}:{}}}let t=e,r=Object.hasOwn(t,"error");return r&&t.error&&t.error._tag==="Defect"?{_tag:"Defect",defect:t.error.data}:Object.hasOwn(t,"chunk")&&t.chunk===!0?{_tag:"Chunk",requestId:t.id??"",values:t.result}:{_tag:"Exit",requestId:t.id??"",exit:r&&t.error!=null?{_tag:"Failure",cause:t.error._tag==="Cause"?t.error.data:[{_tag:"Fail",error:t.error}]}:{_tag:"Success",value:t.result}}}function X4(e,t){if(!("requestId"in e))return eO(e);let r=t.get(e.requestId);return r?(t.delete(e.requestId),r.responses.set(e.requestId,e),r.size===r.responses.size?Array.from(r.responses.values(),eO):void 0):eO(e)}function i6(e,t){if(Array.isArray(e)===!1)return X4(e,t);if(e.length===0)return;let r=[];for(let o=0;o<e.length;o++){let s=X4(e[o],t);s!==void 0&&r.push(s)}if(r.length===0)return;if(r.length===1)return r[0];let n=[];for(let o=0;o<r.length;o++){let s=r[o];Array.isArray(s)?n.push(...s):n.push(s)}return n}function eO(e){switch(e._tag){case"Request":return{jsonrpc:"2.0",method:e.tag,params:e.payload,...e.isNotification?{}:{id:e.id},...e.headers?.length>0?{headers:e.headers}:{},traceId:e.traceId,spanId:e.spanId,sampled:e.sampled};case"Ping":case"Pong":case"Interrupt":case"Ack":case"Eof":return{jsonrpc:"2.0",method:`@effect/rpc/${e._tag}`,params:"requestId"in e?{requestId:e.requestId}:void 0};case"Chunk":return{jsonrpc:"2.0",chunk:!0,id:e.requestId,result:e.values};case"Exit":{if(e.exit._tag==="Success")return{jsonrpc:"2.0",id:e.requestId??void 0,result:e.exit.value};let t=e.exit.cause.find(n=>n._tag==="Fail"),r=t?._tag==="Fail"?t.error:void 0;return{jsonrpc:"2.0",id:e.requestId??void 0,error:e.exit._tag==="Failure"?{_tag:"Cause",code:r&&O(r,"code")?Number(r.code):0,message:r&&O(r,"message")?r.message:JSON.stringify(e.exit.cause),data:e.exit.cause}:void 0}}case"Defect":return{jsonrpc:"2.0",id:$ce,error:{_tag:"Defect",code:1,message:"A defect occurred",data:e.defect}};case"ClientProtocolError":return{}}}var $ce=-32603,Hce=16*1024*1024,jce=new TextEncoder,qce=e=>{let t=e?.maxFrameSize==="unbounded"?void 0:e?.maxFrameSize??Hce,r=e?.fingerprintPayloads===!0?o=>zR(o,{fingerprint:!0}):zR,n={fingerprint:!0};return fn.of({contentType:"application/vnd.effect.rpc+schema-binary",includesFraming:!0,codecFor:r,makeUnsafe:()=>{let o=a4(RR,{...n,maxFrameSize:t}),s=u4(RR,n);return{decode:i=>o.feedSync(typeof i=="string"?jce.encode(i):i),encode:i=>{if(!Array.isArray(i))return s.encode(i);if(i.length!==0)return s.encodeMany(i)}}}})},zce=Ja(fn)(t6),Wce=Ja(fn)(r6),Kce=e=>Ja(fn)(_E(e)),Vce=e=>Ja(fn)(n6(e)),Jce=e=>Ja(fn)(o6(e)),Gce=e=>f0(fn)(()=>qce(e));var PE=class extends Ue()("effect/rpc/RpcWorker/InitialMessage"){};var c6=e=>L(()=>{let t=new Set,r=new Map,n=new Map,o=(s,i)=>yn(a=>{let c=r.get(s);return c||(c=[],r.set(s,c)),c.push([i,a]),P});return K(e((s,i)=>{let a=n.get(s);return a?a(i):o(s,i)},t),s=>({...s,run(i,a){return xt(function*(){t.add(i),n.set(i,a);let c=r.get(i);if(c){r.delete(i);for(let[u,f]of c)yield*Ur(L(()=>a(u)),f)}return yield*Xr(Xn,()=>(t.delete(i),n.delete(i),P))})}}))});var Qce=e=>Or(e,"RpcClientError"),Yce=0,u6=me(function*(e,t){let r=t.spanPrefix,n=t?.supportsAck??!0,o=t?.disableTracing??!1,s=t?.generateRequestId??(()=>Yce++),i=yield*Nr(),a=Re(i,it),c=new Map,u=!1;yield*It(a,ar(b=>(u=!0,f(Fg(b.id)))));let f=me(function*(b){for(let[v,T]of c)c.delete(v),T._tag==="Queue"?yield*b._tag==="Success"?md(T.queue):$t(T.queue,b.cause):T.resume(b)}),p=b=>{let v=Uh(b.successSchema),T=x(b);return(S,w)=>{let k=w?.headers?Zo(w.headers):wl,C=w?.context??pt();if(!v){let M=$=>m(b,T,$,b.payloadSchema.make(S),k,C,w?.discard??!1);return o?M(void 0):Jp(bR(r,b._tag),{kind:"client",attributes:ER(b._tag,t.spanAttributes)},M)}let R=h(b,T,b.payloadSchema.make(S),k,w?.streamBufferSize??16,C);return w?.asQueue?R:Cn(K(R,xh))}},m=(b,v,T,S,w,k,C)=>ar(R=>{if(u)return Dn;let M=s(),$=v(xe=>t.onFromClient({message:xe,context:k,discard:C}),{_tag:"Request",id:M,tag:b._tag,payload:S,...T?{traceId:T.traceId,spanId:T.spanId,sampled:T.sampled}:{},headers:vl(R.getRef(ME),w)});if(C)return $;let te;return gu(Nn(xe=>{let Le={_tag:"Effect",rpc:b,context:k,resume(Er){xe(Er),te&&!te.pollUnsafe()&&R.currentDispatcher.scheduleTask(()=>{te.interruptUnsafe(R.id)},0)}};c.set(M,Le),te=$.pipe(T?xl(T,{captureStackTrace:!1}):F,Sr(R.context)),te.addObserver(Er=>{if(Er._tag==="Failure")return xe(Er)})}),xe=>(c.delete(M),Kt(Tn(te),g(M,Array.from(xe),k))))}),h=me(function*(b,v,T,S,w,k){if(u)return yield*Dn;let C=o?void 0:yield*X0(bR(r,b._tag),{kind:"client",attributes:ER(b._tag,t.spanAttributes)}),R=os(),M=s(),$=dn(R.context,it),te=yield*nf(w);return yield*Wo($,xe=>(BA(te),c.has(M)?(c.delete(M),g(M,vs(xe)?Array.from(hN(xe.cause)):[],k)):P)),c.set(M,{_tag:"Queue",rpc:b,queue:te,scope:$,context:k}),yield*v(xe=>t.onFromClient({message:xe,context:k,discard:!1}),{_tag:"Request",id:M,tag:b._tag,payload:T,...C?{traceId:C.traceId,spanId:C.spanId,sampled:C.sampled}:{},headers:vl(R.getRef(ME),S)}).pipe(C?xl(C,{captureStackTrace:!1}):F,to(xe=>$t(te,xe)),vi,gt($,{startImmediately:!0})),te}),x=b=>{let v=[];for(let T of b.middlewares.values()){let S=Ji(i,`${T.key}/Client`);S&&v.push(S)}return v.length===0?(T,S)=>T(S):function T(S,w,k=v.length-1){return k===-1?S(w):v[k]({rpc:b,request:w,next(C){return T(S,C,k-1)}})}},g=(b,v,T)=>Nn(S=>{let w=os();t.onFromClient({message:{_tag:"Interrupt",requestId:b,interruptors:v},context:T,discard:!1}).pipe(q0(1e3),Sr(w.context)).addObserver(()=>{S(P)})}),y=b=>{switch(b._tag){case"Chunk":{let v=b.requestId,T=c.get(v);return!T||T._tag!=="Queue"?P:wa(T.queue,b.values).pipe(n?A(()=>t.onFromClient({message:{_tag:"Ack",requestId:b.requestId},context:T.context,discard:!1})):F,rt(S=>$t(T.queue,S)))}case"Exit":{let v=b.requestId,T=c.get(v);return T?(c.delete(v),T._tag==="Effect"?(T.resume(b.exit),P):b.exit._tag==="Success"?md(T.queue):$t(T.queue,b.exit.cause)):P}case"Defect":return f(Mg(b.defect));case"ClientEnd":return P}},E;if(t.flatten){let b=new Map;E=function(T,S,w){let k=b.get(T);return k||(k=p(e.requests.get(T)),b.set(T,k)),k(S,w)}}else E={},e.requests.forEach(b=>{B(E,b._tag,p(b))});return{client:E,write:y}}),Xce=0,tO=me(function*(e,t){let r=Xce++,{codecFor:n,run:o,send:s,supportsAck:i,supportsTransferables:a}=yield*ji,c=eue(n),u=Vm(n(er())),f=new Map,p=x=>f.has(x)?(f.delete(x),s(r,{_tag:"Interrupt",requestId:x})):P,{client:m,write:h}=yield*u6(e,{...t,supportsAck:i,onFromClient({message:x}){switch(x._tag){case"Request":{let g=e.requests.get(x.tag),y=a?FW():void 0,E=os(),b={rpc:g,context:y?We(E.context,Nh,y):E.context,schemas:c(g)};return f.set(x.id,b),b.schemas.encodePayload(x.payload).pipe(Ur(b.context),Ii,A(v=>s(r,{...x,id:x.id,payload:v,headers:Object.entries(x.headers)},y&&y.readUnsafe())))}case"Ack":return f.get(x.requestId)?s(r,{_tag:"Ack",requestId:x.requestId}):P;case"Interrupt":return p(x.requestId);case"Eof":return P}}});return yield*o(r,x=>{switch(x._tag){case"Chunk":{let g=kR(x.requestId),y=f.get(g);if(!y||fe(y.schemas.decodeChunk))return P;let E=y.schemas.decodeChunk.value;return en(b=>b(E(x.values).pipe(Ur(y.context),Ii,A(v=>h({_tag:"Chunk",clientId:0,requestId:g,values:v})))).pipe(to(v=>h({_tag:"Exit",clientId:0,requestId:g,exit:ir(v)}).pipe(Kt(il(v)?P:oy(p(g))))),H0(v=>!il(v),()=>P)))}case"Exit":{let g=kR(x.requestId),y=f.get(g);return y?(f.delete(g),y.schemas.decodeExit(x.exit).pipe(Ur(y.context),Ii,Un({onSuccess:E=>h({_tag:"Exit",clientId:0,requestId:g,exit:E}),onFailure:E=>h({_tag:"Exit",clientId:0,requestId:g,exit:ir(E)})}))):P}case"Defect":return h({_tag:"Defect",clientId:0,defect:u(x.defect)});case"ClientProtocolError":{let g=Gn(x.error);return Ko(Array.from(f.keys()),y=>h({_tag:"Exit",clientId:0,requestId:y,exit:g}))}default:return P}}).pipe(rt(Zp),vi,Rs),m}),eue=e=>{let t=new WeakMap;return r=>{let n=t.get(r);if(n!==void 0)return n;let o=cE(r.successSchema);return n={decodeChunk:Ut(o,s=>xc(e(Zu(s.success)))),encodePayload:XC(e(r.payloadSchema)),decodeExit:xc(e(CR(r)))},t.set(r,n),n}},ME=Ce("effect/rpc/RpcClient/CurrentHeaders",{defaultValue:()=>wl}),tue=d(2,(e,t)=>Z0(e,ME,vl(Zo(t)))),ji=class extends Ue()("effect/rpc/RpcClient/Protocol"){static make=c6},f6=e=>ji.make(me(function*(t){let r=yield*fn,n=r.includesFraming,o=u=>new Zs({reason:bd.fromHttpClientError(u)}),s=(u,f)=>new Zs({reason:new Rc({message:u,cause:f})}),i=u=>s("Received empty HTTP response from RPC server",u),a=u=>s("HTTP response ended before RPC request completed",u);return{send:me(function*(u,f){if(f._tag!=="Request")return;let p=r.makeUnsafe(),m=p.encode(f),h=typeof m=="string"?Bk(m,r.contentType):Lk(m,r.contentType),x=yield*e.post("",{body:h}).pipe(ml(o));if(!n){let E=yield*x.text.pipe(ml(o)),b=yield*Jo({try:()=>p.decode(E),catch:T=>s("Error decoding HTTP response",T)});if(!Array.isArray(b))return yield*s("Expected an array of responses",b);if(b.length===0)return yield*i(f);let v=!1;for(let T=0;T<b.length;T++){let S=b[T];OR(S)&&(v=!0),yield*t(u,S)}return v?void 0:yield*a(f)}let g=!1,y=!1;if(yield*Sd(x.stream,E=>Jo({try:()=>E.flatMap(p.decode),catch:b=>s("Error decoding HTTP response",b)}).pipe(A(b=>{if(b.length===0)return P;g=!0;let v=0;return xn({while:()=>v<b.length,body:()=>{let T=b[v++];return OR(T)&&(y=!0),t(u,T)},step:Rr})}))).pipe(ml(E=>Qce(E)?E:o(E))),g){if(!y)return yield*a(f)}else return yield*i(f)}),supportsAck:!1,supportsTransferables:!1,codecFor:r.codecFor}})),rue=e=>Qn(ji)(A(Jk,t=>(t=EW(t,lW(e.url)),f6(e.transformClient?e.transformClient(t):t)))),l6=e=>ji.make(me(function*(t,r){let n=yield*vW,o=yield*fn,s=yield*xu(Zh),i=new Map,a=yield*n.writer,c=o.makeUnsafe(),u=yield*oue(L(()=>a.write(c.encode(LW))),e),f=sy(e?.onPingTimeout??P,{log:!0,message:"RpcClient onPingTimeout hook failed"}),p,m=g=>Ko(r,y=>t(y,g)),h=g=>(p=g,m({_tag:"ClientProtocolError",error:g})),x=g=>{try{let y=c.decode(g);if(y.length===0)return P;u.onFrame();let E=0;return xn({while:()=>E<y.length,body:()=>{let b=y[E++];if(b._tag==="Pong")return P;if(Object.hasOwn(b,"requestId")){let v=b.requestId,T=i.get(v);if(T!==void 0)return b._tag==="Exit"&&i.delete(v),t(T,b)}return m(b)},step:Rr})}catch(y){return m({_tag:"ClientProtocolError",error:new Zs({reason:new Rc({message:"Error decoding message",cause:y})})})}};return yield*L(()=>{c=o.makeUnsafe(),u.reset();let g=!1;return xt(function*(){let{pull:y}=yield*n.reader;for(p=void 0,g=!0,de(s)&&(yield*s.value.onConnect);;){let E=yield*y;for(let b=0;b<E.length;b++)yield*x(E[b])}}).pipe(ec,Ya(u.timeout),Kt(()=>g?f:P),Kt(()=>D(new kh({reason:new Ah({cause:new Error("ping timeout")})}))))}).pipe(de(s)?wi(s.value.onDisconnect):F,Kp(g=>{let y=sl(g),E=tt(y),b=new Zs({reason:E?y.success.reason:new Rc({message:"Unknown socket error",cause:cu(g)})});return e?.retryTransientErrors&&E&&y.success.reason._tag==="SocketOpenError"?(e.onTransientError?.(b)??P).pipe(sy({log:!0,message:"RpcClient onTransientError hook failed"})):h(b)}),j0(e?.retryPolicy??nue,g=>h(new Zs({reason:g.reason}))),uy({module:"RpcClient",method:"makeProtocolSocket"}),Rs),{send(g,y){if(p)return D(p);y._tag==="Request"&&i.set(y.id,g);let E=c.encode(y);return E===void 0?P:Ii(a.write(E))},supportsAck:!0,supportsTransferables:!1,codecFor:o.codecFor}})),nue=cU([uU(500,1.5),ll(5e3)]),oue=me(function*(e,t){let r=yield*Yn,n=t?.pingInterval??"5 seconds",o=zt(t?.pingTimeout??n),s=r.currentTimeMillisUnsafe(),i=Hr(),a=()=>{s=r.currentTimeMillisUnsafe()},c=()=>{a(),i.closeUnsafe()};return yield*L(()=>r.currentTimeMillisUnsafe()-s>o?i.open:e).pipe(ca(n),oy,_t,vi,Rs),{timeout:i.await,reset:c,onFrame:a}}),sue=e=>Qn(ji)(l6(e)),d6=e=>ji.make(me(function*(t,r){let n=yield*aE,o=yield*Co,s=0,i=yield*xu(PE),a=yield*xu(Zh),c=new Map,u=h=>Ko(r,x=>t(x,h)),f=xt(function*(){let h=s++,x=yield*n.spawn(h);return yield*x.run(g=>{if(g._tag==="Exit"){let y=c.get(g.requestId);if(y)return c.delete(g.requestId),y.latch.openUnsafe(),t(y.clientId,g)}else if(g._tag==="Defect"){for(let[y,E]of c)c.delete(y),E.latch.openUnsafe();return u(g)}else if("requestId"in g){let y=c.get(g.requestId);if(y)return t(y.clientId,g)}return u(g)},{onSpawn:de(i)?A(i.value,([g,y])=>Ii(x.send({_tag:"InitialMessage",value:g},y))):void 0}).pipe(Kp(g=>{for(let[E,b]of c)b.worker===x&&(c.delete(E),b.latch.openUnsafe());let y=sl(g);return u({_tag:"ClientProtocolError",error:new Zs({reason:tt(y)?y.success.reason:new Rc({message:"Error in worker",cause:cu(g)})})})}),ny(ll(1e3)),uy({module:"RpcClient",method:"makeProtocolWorker"}),vi,Rs),x}),p="minSize"in e?yield*jz({acquire:f,min:e.minSize,max:e.maxSize,concurrency:e.concurrency,targetUtilization:e.targetUtilization,timeToLive:e.timeToLive}):yield*Hz({acquire:f,size:e.size,concurrency:e.concurrency,targetUtilization:e.targetUtilization});yield*It(o,W(()=>{for(let h of c.values())h.latch.openUnsafe();c.clear()}));let m=(h,x,g)=>{switch(x._tag){case"Request":return Rk(p).pipe(A(y=>{let E=Hr(!1);return c.set(x.id,{clientId:h,worker:y,latch:E}),A(y.send(x,g),()=>E.await)}),ec,Ii);case"Interrupt":{let y=c.get(x.requestId);return y?(c.delete(x.requestId),y.latch.openUnsafe(),Ii(y.worker.send(x))):P}case"Ack":{let y=c.get(x.requestId);return y?Ii(y.worker.send(x)):P}}return P};return yield*ec(Rk(p)),de(a)&&(yield*a.value.onConnect),{send:m,supportsAck:!0,supportsTransferables:!0,codecFor:ef}})),iue=Lc(d6,Qn(ji)),Zh=class extends Ue()("effect/rpc/RpcClient/ConnectionHooks"){};var FE="~effect/reactivity/Atom",h6=e=>O(e,FE),nO="~effect/reactivity/Atom/Writable",Xh=d(2,(e,t)=>{let r=$e(t),n=Wn(r);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!n,idleTTL:n?zt(r):void 0})}),bf=Xh(0),sO={[FE]:FE,equals:Object.is,...wr,toJSON(){return{_id:"Atom",keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},aue={...sO,atom(e,t){let r=x6(e,t);return qi(n=>{let o=n.self(),s=n(this);return s._tag!=="Success"?Oh(s,o):r(n,s.value)})},fn(e,t){return arguments.length===0?(r,n)=>p6(this,r,n):p6(this,e,t)},pull(e,t){let r=bf(iO(0)),n=qi(o=>{let s=o.self(),i=o(this);return i._tag!=="Success"?Oh(i,s):NE(o,gue(o,r,e,t),Ca(!0),i.value)});return yue(r,n)},subscriptionRef(e){return mue(bf(qi(t=>{let r=t.self(),n=t(this);if(n._tag!=="Success")return Oh(n,r);let o=typeof e=="function"?e(t):e;return Ih(o)?o:NE(t,o,Ca(!0),n.value)})),(t,r)=>{let n=aR(t(this));return pue(t,r,n)})}},p6=(e,t,r)=>{let[n,o,s]=xue(r?.reactivityKeys?(i,a)=>{let c=t(i,a);return Yr(c)?$b(c,r.reactivityKeys):yh(c,Hb(r.reactivityKeys))}:t,r);return ex(i=>{i.get(s);let a=i.self(),c=i.get(e);return c._tag!=="Success"?Oh(c,a):n(i,c.value)},o)},cue={...sO,[nO]:nO},uue=e=>nO in e,qi=(e,t)=>{let r=Object.create(sO);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.refresh=t,r},ex=(e,t,r)=>{let n=Object.create(cue);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.write=t,n.refresh=r,n};function fue(e,t){e.setSelf(t)}var Yh=(e,t)=>{let r=x6(e,t);return FE in r?r:qi(r)},x6=(e,t)=>{if(typeof e=="function"&&!Yr(e)&&!Ae(e)){let r=e;return function(n,o){let s=r(n);switch(typeof s){case"function":case"object":return s===null?s:g6 in s?oO(n,s,t,o):lue in s?m6(n,s,t,o):s;default:return s}}}else{if(Yr(e))return function(r,n){return oO(r,e,t,n)};if(Ae(e))return function(r,n){return m6(r,e,t,n)}}return iO(e)},g6="~effect/Effect",lue="~effect/Stream",iO=e=>ex(function(t){return e},fue),oO=(e,t,r,n)=>{let o=r?.initialValue!==void 0?us(r.initialValue):Ca();return NE(e,t,o,n,r?.uninterruptible)};function NE(e,t,r,n=pt(),o=!1){let s=e.self(),i=Zn();e.addFinalizer(()=>{Sr(n)(Ve(i,Wt))});let a,c=!1,u=aO(n.pipe(We(it,i),We(iE,e.registry),We(La,e.registry.scheduler)),t,function(f){a=sR(f,s),c&&e.setSelf(a)},o);return c=!0,u!==void 0&&e.addFinalizer(u),a!==void 0?a:s._tag==="Some"?sE(s):Rh(r)}function aO(e,t,r,n=!1){if(ws(t)){r(t);return}let s=Sr(e)(t);s.currentDispatcher?.flush();let i=s.pollUnsafe();if(i){r(i);return}let a=s.addObserver(r);function c(){a(),n||s.interruptUnsafe()}return c}function due(e){let t=e?.memoMap??bf(Yh(()=>xi())),r=i=>h6(t)?i(t):t,n=jb;function o(i){let a=Object.create(aue);a.keepAlive=!1,a.lazy=!0,a.refresh=void 0,a.factory=o;let c=lO(qi(typeof i=="function"?u=>Rp(i(u),n):()=>Rp(i,n)));return a.layer=c,a.read=function(f){let p=f(c),m=A(Co,h=>gi(p,r(f),h));return oO(f,m,{uninterruptible:!0})},a}o.memoMap=t,o.addGlobalLayer=i=>{n=Rp(n,As(i,jb))};let s=bf(Yh(i=>yn(a=>gi(jb,r(i),Re(a,it))).pipe(K(Re(vc)))));return o.withReactivity=i=>a=>Sue(a,c=>{let u=aR(c(s));return c.addFinalizer(u.registerUnsafe(i,()=>{c.refresh(a)})),c.subscribe(a,f=>c.setSelf(f)),c.once(a)},{initialValueTarget:a}),o}var cO=due(),cEe=cO.withReactivity,m6=(e,t,r,n)=>{let o=r?.initialValue!==void 0?us(r.initialValue):Ca();return uO(e,t,o,n)};function uO(e,t,r,n=pt()){let o=e.self();n=We(n,iE,e.registry);let s=hl(a=>A(as(t.channel,a),c=>xn({while:nr,body:()=>c,step(u){e.setSelf(us(Df(u),{waiting:!0}))}}))).pipe(rt(a=>(wo(a)?Md(e.self(),gs(iR),Zt({onNone:()=>e.setSelf(RW(new al,{previous:e.self()})),onSome:c=>e.setSelf(us(c))})):e.setSelf(Td(a,{previous:e.self()})),P))),i=aO(n.pipe(We(iE,e.registry),We(La,e.registry.scheduler)),s,Rr,!1);return i!==void 0&&e.addFinalizer(i),o._tag==="Some"?sE(o):Rh(r)}var pue=(e,t,r=pt())=>Ih(t)?(e.addFinalizer(Fk(t).pipe(Sd(n=>{for(let o=0;o<n.length;o++)e.setSelf(n[o]);return P}),ew(r))),nw(r)(Zz(t))):t._tag!=="Success"?t:uO(e,Fk(t.value),Ca(!0),r),mue=(e,t)=>{function r(n,o){let s=n.get(e);Ih(s)?Ai(Nk(s,o)):Id(s)&&Ai(Nk(s.value,o))}return ex(n=>{let o=n(e);return Ih(o)||Id(o)?t(n,o):o},r)};var hue=Symbol.for("effect/reactivity/atom/Atom/Reset"),rO=Symbol.for("effect/reactivity/atom/Atom/Interrupt");function xue(e,t){let r=bf(iO([0,void 0])),n=t?.initialValue!==void 0?us(t.initialValue):Ca(),o=t?.concurrent?bf(qi(a=>{let c=new Set;return a.addFinalizer(()=>c.forEach(u=>u.interruptUnsafe())),c})):void 0;function s(a,c){let u=o?a(o):void 0;a.isFn=!0;let[f,p]=a.get(r);if(f===0)return n;if(p===rO)return Td(pN(),{previous:a.self()});let m=e(p,a);return g6 in m?(u&&(m=A(yl(m,{startImmediately:!0}),x=>{u.add(x);let g=Array.from(u);return x.addObserver(()=>u.delete(x)),K(ZS(g),y=>y[0])})),NE(a,m,n,c,!1)):uO(a,m,n,c)}function i(a,c){Eue(()=>{c===hue?a.set(r,[0,void 0]):c===rO?a.set(r,[a.get(r)[0]+1,rO]):a.set(r,[a.get(r)[0]+1,c]),a.refreshSelf()})}return[s,i,r]}var gue=(e,t,r,n)=>A(Tk(typeof r=="function"?r(e):r),o=>{let i=os().context,a=Qt(),c=Un(o,{onFailure(f){return wo(f)?bt(a)?I({done:!0,items:a}):D(new al("Atom.pull: no items")):He(f)},onSuccess(f){let p;return n?.disableAccumulation?p=f:(p=ip(a,f),a=p),I({done:!1,items:p})}}),u=new Set;return e.addFinalizer(()=>{for(let f of u)f()}),e.once(t),e.subscribe(t,()=>{e.setSelf(sE(e.self()));let f;f=aO(i,c,p=>{f&&u.delete(f);let m=sR(p,e.self()),h=u.size>0;e.setSelf(h?Rh(m):m)}),f&&u.add(f)}),c}),yue=(e,t)=>ex(t.read,function(r,n){r.set(e,r.get(e)+1)}),fO=typeof WeakRef>"u"||typeof FinalizationRegistry>"u"?e=>{let t=Si();return function(r){let n=Qr(t,r);if(n._tag==="Some")return n.value;let o=e(r);return bi(t,r,o),o}}:e=>{let t=Si(),r=new FinalizationRegistry(n=>{let o=Qr(t,n);o._tag==="Some"&&o.value.deref()===void 0&&Ei(t,n)});return function(n){let o=Qr(t,n).pipe(CI(i=>i.deref()));if(o._tag==="Some")return o.value;let s=e(n);return bi(t,n,new WeakRef(s)),r.register(s,n),s}};var lO=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0});var Sue=d(e=>h6(e[0]),(e,t,r)=>{let n=bf(uue(e)?ex(o=>t(o,e),function(o,s){o.set(e,s)},e.refresh??function(o){o(e)}):qi(o=>t(o,e),e.refresh??function(o){o(e)}));return r?.initialValueTarget&&(n.initialValueTarget=bue(r.initialValueTarget)),n}),bue=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t};var Eue=PW;var Iue="~effect-atom/atom/Atom/Serializable";var dO=d(2,(e,t)=>{let r=ef(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,Ir()===0?"":new Error().stack?.split(`
37
+ `)[5]??""],[Iue]:{key:t.key,encode:eA(r),decode:Vm(r)}})});var S6=()=>(e,t)=>{let r=Ue()(e),n=Qn(r,t.makeEffect??tO(t.group,{...t,flatten:!0})),o=t.runtime??cO;r.runtime=o(typeof t.protocol=="function"?i=>As(n,qg(t.protocol(i))):As(n,qg(t.protocol))),r.mutation=fO(i=>{let a=t.group.requests.get(i);return r.runtime.fn()(me(function*({headers:c,payload:u,reactivityKeys:f}){let m=(yield*r)(i,u,{headers:c});return yield*f?$b(m,f):m})).pipe(dO({key:`AtomRpc:mutation:${i}`,schema:cR({success:a.successSchema,error:y6(a)})}))});let s=fO(i=>{let{headers:a,payload:c,reactivityKeys:u,tag:f,timeToLive:p}=i,m=t.group.requests.get(f),h=Uh(m.successSchema),x=h?r.runtime.pull(Cn(r.use(g=>I(g(f,c,{headers:a}))))):r.runtime.atom(r.use(g=>g(f,c,{headers:a})));return u&&(x=r.runtime.factory.withReactivity(u)(x)),!h&&i.serializationKey&&(x=dO(x,{key:`AtomRpc:${i.tag}:${i.serializationKey}`,schema:cR({success:m.successSchema,error:y6(m)})})),p&&(x=Wn(p)?Xh(x,p):lO(x)),x});return r.query=(i,a,c)=>{let u={tag:i,payload:a,headers:c?.headers?Zo(c.headers):void 0,reactivityKeys:c?.reactivityKeys,timeToLive:c?.timeToLive!==void 0?$e(c.timeToLive):void 0,serializationKey:c?.serializationKey};return s(u)},r},y6=e=>Pe([e.errorSchema,...Array.from(e.middlewares,t=>t.error),Zs]);var UE={};ps(UE,{make:()=>vue});var wue={add(...e){let t=new Map(this.requests);for(let r of e)t.set(r._tag,r);return Aa({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),r=new Map(this.annotations.mapUnsafe);for(let n of e){for(let[o,s]of n.requests)t.set(o,s);for(let[o,s]of n.annotations.mapUnsafe)r.set(o,s)}return Aa({requests:t,annotations:qn(r)})},omit(...e){let t=new Map(this.requests);for(let r of e)t.delete(r);return Aa({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[r,n]of this.requests)t.set(r,n.middleware(e));return Aa({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return xt(function*(){let r=yield*Nr(),n=Yr(e)?yield*e:e,o=new Map;return t.requests.forEach((s,i)=>{o.set(s.key,{tag:s._tag,handler:n[i],context:r})}),qn(o)})},prefix(e){let t=new Map;for(let r of this.requests.values()){let n=r.prefix(e);t.set(n._tag,n)}return Aa({requests:t,annotations:this.annotations})},toLayer(e){return Ga(this.toHandlers(e))},of:F,toLayerHandler(e,t){let r=this;return Ga(xt(function*(){let n=yield*Nr(),o=Yr(t)?yield*t:t,s=new Map,i=r.requests.get(e);return s.set(i.key,{handler:o,context:n}),qn(s)}))},accessHandler(e){return yn(t=>{let r=this.requests.get(e),{handler:n,context:o}=Ji(t,r.key);return I((s,i)=>{i.rpc=r;let a=n(s,i),c=vd(a)?a.value:a;return Yr(c)?J0(c,o):Ek(c,o)})})},annotate(e,t){return Aa({requests:this.requests,annotations:We(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(ys(e,t))},annotateMerge(e){return Aa({requests:this.requests,annotations:Kr(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[r,n]of this.requests)t.set(r,n.annotateMerge(Kr(e,n.annotations)));return Aa({requests:t,annotations:this.annotations})}},Aa=e=>Object.assign(function(){},wue,{requests:e.requests,annotations:e.annotations}),vue=(...e)=>Aa({requests:new Map(e.map(t=>[t._tag,t])),annotations:pt()});var Od={};ps(Od,{Service:()=>Cue,TypeId:()=>mO,layerClient:()=>Aue});var mO="~effect/rpc/RpcMiddleware",Cue=()=>(e,t)=>{let r=Ir(),n;r!==0&&(yt(2),n=new globalThis.Error,yt(r));function o(){}let s=o;return Object.setPrototypeOf(o,Object.getPrototypeOf(Ue(e))),o.key=e,Object.defineProperty(o,"stack",{get(){return n?.stack}}),s[mO]=mO,s.error=t?.error??Mi,s.requiredForClient=t?.requiredForClient??!1,o},Aue=(e,t)=>Ga(xt(function*(){let r=(yield*Nr()).pipe(B_(it)),n=Yr(t)?yield*t:t;return qn(new Map([[`${e.key}/Client`,o=>Xa(n(o),s=>Kr(r,s))]]))}));var b6=l.Union([l.Struct({_tag:l.Literal("List"),collection:l.String}),l.Struct({_tag:l.Literal("Item"),collection:l.String,id:l.Union([l.String,l.Number])})]),Ef=(e,t)=>({item:r=>({_tag:"Item",collection:e,id:r}),list:{_tag:"List",collection:e},name:e});function E6(e){return e._tag==="List"?e.collection:`${e.collection}:${e.id}`}var DE=e=>[...new Set(e.map(E6))],LE=e=>[...new Set(e.flatMap(t=>t._tag==="List"?[t.collection]:[E6(t),t.collection]))];var kue=ne.fn("EffectContract.invalidateAfter")(function*(e){yield*Hb(LE(e))});function Rue(e,t,r){function n(o){return DE(r.reads(o))}return{query:(o,s={})=>e.query(t,o,{...s,reactivityKeys:n(o)}),run:o=>e.use(s=>s(t,o))}}function Oue(e,t,r){return{run:n=>e.use(o=>o(t,n)).pipe(ne.tap(o=>kue(r.invalidates(n,o))))}}function _ue(e,t){return{run:r=>sn.unwrap(e.use(n=>ne.succeed(n(t,r))))}}function BE(e,t){let{name:r,queries:n,commands:o,streams:s}=e.declaration;return Object.fromEntries([...n.map(i=>[i.name,Rue(t,`${r}.${i.name}`,i)]),...o.map(i=>[i.name,Oue(t,`${r}.${i.name}`,i)]),...s.map(i=>[i.name,_ue(t,`${r}.${i.name}`)])])}var I6=l.Union([l.Struct({_tag:l.Literal("Changed"),keys:l.Array(b6)}),l.Struct({_tag:l.Literal("Resync")})]),Pue=256;function T6(e,t){let r=Yh(!1),n=Yh({connection:"connecting",failure:ke.none(),needsResync:!0,pending:0});return{connection:e.atom(s=>ne.gen(function*(){s.mount(n);let i=yield*vc;function a(f){s.set(n,{...s.once(n),...f})}function c(){if(s.once(r)){a({needsResync:!0});return}i.invalidateUnsafe(DE(t.resyncKeys)),a({needsResync:!1,pending:0})}s.subscribe(r,f=>{f||c()}),t.resume!==void 0&&(s.once(t.resume),s.subscribe(t.resume,c));let u=ne.suspend(()=>{let f=!0;function p(m){a({connection:"live",failure:ke.none()}),s.once(r)?a({needsResync:!0,pending:Math.min(Pue,s.once(n).pending+1)}):f||m._tag==="Resync"?c():i.invalidateUnsafe(LE(m.keys)),f=!1}return t.stream.pipe(sn.runForEach(m=>ne.sync(()=>p(m))),ne.scoped,ne.catchCause(m=>ne.sync(()=>a({failure:ke.some(m)}))),ne.andThen(ne.sync(()=>a({connection:"reconnecting",needsResync:!0}))),ne.andThen(ne.sleep(t.retryDelay??"1 second")))});yield*ne.forever(u)})).pipe(Xh(0)),paused:r,status:n}}function w6(e,t){return r=>{function n(){e.document.visibilityState==="visible"&&r()}return e.addEventListener(t,n),()=>e.removeEventListener(t,n)}}function v6({window:e,native:t}){let r=e===void 0?[]:[w6(e,"visibilitychange"),w6(e,"online")],n=t===void 0?r:[...r,t];return qi(o=>{let s=0;function i(){s+=1,o.setSelf(s)}for(let a of n)o.addFinalizer(a(i));return s})}function Mue(e){let t=e.map(({name:r})=>r).filter((r,n,o)=>o.indexOf(r)!==n);if(t.length>0)throw new Error(`Operation names must be unique; duplicated: ${[...new Set(t)].join(", ")}`)}function C6(e,t){let r=e.middleware.bind(e);return Object.assign(e,{declaration:t,middleware:n=>C6(r(n),t)})}function Pc(e,t){let{queries:r=[],commands:n=[],streams:o=[]}=t;Mue([...r,...n,...o]);let s=[...r,...n,...o].map(i=>Cd.make(`${e}.${i.name}`,{error:i.error,payload:i.payload,stream:i.kind==="stream",success:i.success}));return C6(UE.make(...s),{commands:n,name:e,queries:r,streams:o})}function A6(e){let t=Object.entries(e).map(([r,n])=>[r,l.isSchema(n)?n:l.TaggedError()(r,n)]);return{error:t.length===0?l.Never:l.Union(t.map(([,r])=>r)),Rejection:Object.fromEntries(t),reject:Object.fromEntries(t.map(([r,n])=>[r,(...o)=>ne.fail(Reflect.construct(n,o))]))}}function Fue(e){return e===void 0?l.Void:l.isSchema(e)?e:l.Struct(e)}function hO(e,t,r){let{payload:n,success:o,rejections:s={}}=r;return{kind:e,name:t,payload:Fue(n),rejections:s,success:o??l.Void,...A6(s)}}function Ht(e,t){return{...hO("query",e,t),reads:t.reads}}function tx(e,t){return{...hO("command",e,t),invalidates:t.invalidates}}function k6(e,t){return{...hO("stream",e,t),reads:t.reads}}var Mc={message:l.String},O6={field:l.optionalKey(l.String),message:l.String},rx=class extends l.TaggedError()("NotFound",Mc){},$E=class extends l.TaggedError()("Unauthorized",Mc){},If=class extends l.TaggedError()("Forbidden",Mc){},HE=class extends l.TaggedError()("BadRequest",O6){},nx=class extends l.TaggedError()("Conflict",O6){},jE=class extends l.TaggedError()("PreconditionFailed",Mc){},R6=class extends l.TaggedError()("TooManyRequests",Mc){},ox=class extends l.TaggedError()("AuthUnavailable",Mc){},jn=class extends l.TaggedError()("InternalServerError",Mc){},sx=class extends l.TaggedError()("ServiceUnavailable",Mc){};var Fc=class extends Od.Service()("@shivaedev/platform/rpc/RequestTracing"){},_6=class extends Od.Service()("@shivaedev/platform/rpc/Authenticated",{error:l.Union([$E,ox,If])}){},P6=class extends Od.Service()("@shivaedev/platform/rpc/MaybeAuthenticated",{error:l.Union([ox,If])}){};var Tt=l.String.check(l.isPattern(/^[a-zA-Z\d][a-zA-Z\d._-]*$/u));var Qs=l.String.check(l.isPattern(/^[a-f\d]{64}$/u)),M6=l.Literals(["answer","clarify","not_now"]),Nue=l.Struct({prompt:Tt.check(l.isMaxLength(128)),selected:l.Array(Tt.check(l.isMaxLength(128))).check(l.isMaxLength(32)),text:l.String.check(l.isMaxLength(8192))}),F6=l.Array(Nue).check(l.isMaxLength(32)),xO=l.Struct({deadline:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),item:Tt,reason:l.String,registeredAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),request:Tt,reviewedRevision:Qs,source:l.String}),qE=l.Struct({answers:l.optional(F6),author:l.String.check(l.isPattern(/\S/u),l.isMaxLength(200)),question:Tt,recordedAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),reviewedRevision:Qs,supersedes:l.optional(Tt),type:M6}),zE=l.Struct({context:l.String,id:Tt,item:Tt,reason:l.String,request:Tt,reviewedRevision:Qs,source:l.String}),_d=l.Struct({context:l.String,id:Tt,question:xO}),Nc=l.Struct({body:l.String,id:Tt,response:qE}),N6=l.Struct({question:_d,responses:l.Array(Nc)}),U6=l.Struct({expired:l.Boolean,question:_d,response:l.optional(Nc)}),D6=l.Struct({answers:l.optional(F6),author:qE.fields.author,body:l.String.check(l.isMaxLength(32768)),id:Tt,question:Tt,supersedes:l.optional(Tt),type:M6});var WE=l.Struct({disposition:l.Literals(["applied","superseded"]),question:Tt,recordedAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),response:l.optional(Tt),reviewedRevision:Qs});var ix=l.String.check(l.isPattern(/\S/u),l.isMaxLength(8192)),ax=l.Struct({by:l.optional(ix),constraints:l.String.check(l.isMaxLength(8192)),goal:ix,item:Tt,nextAction:ix,note:l.optional(ix),preparedAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),recipient:ix.check(l.isMaxLength(200)),reviewedRevision:Qs,source:l.String,state:l.Literals(["requested","acknowledged","rejected","unavailable"])}),gO=ax.pipe(l.encodeKeys({nextAction:"next_action",preparedAt:"prepared_at",reviewedRevision:"reviewed_revision"})),L6=l.Struct({constraints:ax.fields.constraints,goal:ax.fields.goal,id:Tt,item:Tt,nextAction:ax.fields.nextAction,recipient:ax.fields.recipient,revision:Qs,source:l.String}),yO=l.Struct({context:l.String,file:l.String,handoff:gO,id:Tt,prompt:l.String}),KE=l.Struct({records:l.Array(yO),unknown:l.Array(l.String)}),VE=l.Struct({context:l.String,id:Tt,item:Tt,reviewedRevision:Qs,source:l.String});var JE=Tt,SO=l.String.check(l.isPattern(/^[a-zA-Z\d][a-zA-Z\d._-]*(?:#[a-zA-Z\d][a-zA-Z\d._-]*)?$/u)),fo=l.String.check(l.isPattern(/\S/u)),Uue=l.Struct({id:JE,kind:l.Literals(["decision","review","blocker"]),managed:l.optional(l.Boolean),reason:fo,responseFrom:l.Array(fo).check(l.isMinLength(1)),state:l.Literals(["open","closed"]),unblocks:l.Array(SO).check(l.isMinLength(1))}).pipe(l.encodeKeys({responseFrom:"response_from"})),Due=l.Struct({id:JE,text:fo}),Lue=l.Struct({kind:l.Literals(["implements","informs","depends_on","relates_to"]),target:SO}),Bue=l.Struct({checkedRevision:l.optional(l.String.check(l.isPattern(/^(?:[a-f\d]{40}|[a-f\d]{64})$/iu))),criterion:l.optional(SO),method:l.optional(fo),observedAt:l.optional(fo.check(l.makeFilter(e=>Number.isFinite(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T.*(?:Z|[+-]\d{2}:\d{2})$/u.exec(e)!==null||"Expected an ISO timestamp with timezone"))),outcome:l.optional(fo),source:fo}).pipe(l.encodeKeys({checkedRevision:"checked_revision",observedAt:"observed_at"})),GE=l.Struct({areas:l.optional(l.Array(fo)),attention:l.optional(l.Array(Uue)),criteria:l.optional(l.Array(Due)),evidence:l.optional(l.Array(Bue)),handoff:l.optional(gO),id:l.optional(JE),items:l.optional(l.Array(JE)),kind:l.optional(l.Literals(["task","investigation","decision","result","project","board","question","response","handoff"])),nextAction:l.optional(fo),options:l.optional(l.Array(l.Struct({description:fo.check(l.isMaxLength(8192)),label:fo.check(l.isMaxLength(128))})).check(l.isMaxLength(32))),owner:l.optional(fo),question:l.optional(xO),recommended:l.optional(fo),relationships:l.optional(l.Array(Lue)),requestReceipt:l.optional(WE),response:l.optional(qE),status:l.optional(fo)}).pipe(l.encodeKeys({nextAction:"next_action",requestReceipt:"request_receipt"}));var $ue=l.Struct({href:l.optional(l.String),label:l.String}),B6=l.Struct({backlinks:l.Array(l.Struct({href:l.String,kind:l.String,label:l.String})),board:l.Boolean,claims:l.Record(l.String,l.Array($ue)),evidenceSources:l.Array(l.Struct({href:l.optional(l.String),problem:l.String})),lines:l.Record(l.String,l.Number),proseLine:l.Number,raw:l.optional(l.String),receipts:l.Record(l.String,WE)});var bO=l.Struct({id:l.String,open:l.Boolean,preview:l.optional(zE),prompts:l.optional(l.Array(l.Struct({id:l.String,mode:l.Literals(["one","many","text"]),options:l.Array(l.Struct({id:l.String,source:l.String})),source:l.String}))),promptUnavailable:l.optional(l.String),responses:l.optional(l.Array(Nc)),unavailable:l.optional(l.String)}),ka=l.Struct({diagnostics:l.Array(l.Struct({field:l.optional(l.String),line:l.Number,message:l.String})),file:l.String,identity:l.optional(l.String),links:l.Record(l.String,l.String),metadata:GE,modified:l.Number,questionActions:l.Record(l.String,l.String),reading:l.optional(B6),references:l.Record(l.String,l.String),requests:l.Array(bO),source:l.String,unavailable:l.Array(l.String),writable:l.Boolean});var $6=l.Struct({current:l.Boolean,href:l.String,modified:l.Number,name:l.String,path:l.String}),EO=class e extends l.Class("NavigationFolder")({active:l.Boolean,count:l.Number,files:l.Array($6),folders:l.Array(l.suspend(()=>e)),name:l.String,path:l.String}){},H6=l.Struct({home:l.optional(l.Struct({file:l.String,identity:l.optional(l.String)})),inboxCount:l.NullOr(l.Number),records:l.Struct({active:l.Boolean,count:l.Number,files:l.Array($6)}),tree:EO});var IO=l.Struct({href:l.optional(l.String),label:l.String}),Hue=l.Struct({checkedRevision:l.optional(l.String),method:l.optional(l.String),observedAt:l.optional(l.String),outcome:l.optional(l.String),problem:l.String,source:IO}),j6=l.Struct({document:ka,feedback:l.Array(l.Struct({matching:l.Boolean,question:_d,questionFile:l.String,response:Nc,responseFile:l.String,supersedesFile:l.optional(l.String)})),feedbackUnknown:l.Boolean,revision:l.String,targets:l.Array(l.Struct({available:l.Boolean,criteria:l.Array(l.Struct({claims:l.Array(Hue),link:IO,text:l.String})),link:IO,status:l.optional(l.String)}))});var q6=l.Struct({resetsAt:l.NullOr(l.Int.check(l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e10))),usedPercent:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0)),windowDurationMins:l.NullOr(l.Int.check(l.isGreaterThan(0)))}),W6=l.Struct({primary:l.NullOr(q6),secondary:l.NullOr(q6)}),TO=l.Int.check(l.isGreaterThanOrEqualTo(0)),z6=l.Struct({limit:TO,remaining:TO,reset:TO.check(l.isLessThanOrEqualTo(864e10))}),K6=l.Struct({core:z6,graphql:z6});var cx=l.Int.check(l.isGreaterThanOrEqualTo(0)),wO=l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),jue=l.Struct({at:wO,cause:l.String.check(l.isMinLength(1),l.isMaxLength(500))}),que="health.json",bIe=`fleet/${que}`,V6=l.Struct({concurrency:l.Int.check(l.isGreaterThan(0)),lastCapacityRejection:l.NullOr(jue),lastSchedulerPass:l.NullOr(wO),observedAt:wO,queued:cx,running:cx,staleAfterMs:l.Int.check(l.isGreaterThan(0)),version:l.Literal(2),waiting:l.Struct({automation:cx,maintainer:cx,orchestrator:cx})});var J6=l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13));function vO(e){return l.Union([l.Struct({observedAt:J6,state:l.Literal("ready"),value:e}),l.Struct({cause:l.String,observedAt:J6,state:l.Literals(["not-configured","error"])})])}var CO=l.Struct({codex:vO(W6),fleet:vO(V6),github:vO(K6)}),AIe=Pc("daemon",{queries:[Ht("diagnostics",{payload:{},reads:()=>[],success:CO})]});var G6=l.Struct({now:l.Number,sources:CO}),Z6=l.Struct({empty:l.Boolean,templates:l.Array(l.Struct({file:l.String,label:l.String,source:l.String}))}),Q6=l.Struct({document:ka,request:bO}),Y6=l.Struct({background:l.String,goal:l.String,item:l.String,nextAction:l.String,reading:KE,source:l.optional(VE),unavailable:l.optional(l.String),writable:l.Boolean});var zue=l.Literals(["board","table"]),Wue=l.Literals(["title","owner","status"]),X6=l.Struct({board:l.String,item:l.String,owner:l.String,query:l.String,sort:Wue,status:l.String,view:zue});var Kue=l.Struct({href:l.optional(l.String),label:l.String}),AO=l.Struct({file:l.String,id:l.String,metadata:GE,title:l.String,waiting:l.optional(l.String)}),eK=l.Struct({boards:l.Array(AO),issues:l.Array(l.String),items:l.Array(AO),rows:l.Array(AO),selected:l.optional(ka),selectedOutside:l.Boolean,selectionProblem:l.optional(l.String),state:X6,title:l.String,validBoard:l.Boolean}),tK=l.Struct({complete:l.Boolean,items:l.Array(l.Struct({file:l.String,href:l.String,id:l.String,modified:l.optional(l.Number),problem:l.optional(l.String),reason:l.String,title:l.String})),sourceIssues:l.Boolean}),rK=l.Struct({complete:l.Boolean,entries:l.Array(l.Struct({file:l.String,href:l.String,id:l.String,itemId:l.String,kind:l.Literals(["decision","review","blocker"]),line:l.Number,reason:l.String,responseFrom:l.Array(l.String),title:l.String,unblocks:l.Array(Kue)})),inboxCount:l.Number,issues:l.Array(l.Struct({file:l.String,line:l.Number,message:l.String})),unavailable:l.Array(l.String)}),nK=l.Struct({counts:l.Array(l.Struct({count:l.Number,title:l.String})),document:ka});function Vue(e){return e.startsWith(".")||e==="node_modules"}function oK(e){return e.endsWith(".md")&&!e.split("/").some(Vue)}var Jue=l.String.check(l.makeFilter(e=>oK(e)&&!e.includes("\\")&&!e.includes("\0")&&e.split("/").every(t=>t.length>0&&t!=="..")||"Expected a relative readable Markdown path")),Gue=l.String.check(l.makeFilter(e=>Number.isFinite(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T.*(?:Z|[+-]\d{2}:\d{2})$/u.exec(e)!==null||"Expected an ISO observation time with timezone")),zIe=l.Struct({documents:l.Array(l.Struct({file:Jue,source:l.String})).check(l.makeFilter(e=>new Set(e.map(t=>t.file)).size===e.length||"Duplicate source paths are not a complete observation")),recordedAt:Gue,version:l.Literal(1)}).pipe(l.encodeKeys({recordedAt:"recorded_at"})),iK=l.Struct({action:l.Literals(["check","compare","observe"]),baseline:l.NullOr(l.String)}),sK=l.Struct({file:l.String,source:l.String}),Zue=l.Struct({changes:l.Array(l.Struct({after:l.optional(sK),before:l.optional(sK),kind:l.Literals(["added","removed","changed"]),reasons:l.Array(l.String)})),issues:l.Array(l.String),recordedAt:l.String}),aK=l.Struct({comparison:l.optional(Zue),discardBaseline:l.Boolean,html:l.String,reason:l.String,snapshot:l.NullOr(l.String)});var Nt=Ef("work-board/workspace",l.String),cK=Ef("work-board/documents",l.String),uK=Ef("work-board/identities",l.String),fK=Ef("work-board/navigation",l.String),Jt=Ef("work-board/index",l.String),lK=Ef("work-board/watcher",l.String);var kO=class extends l.TaggedError()("PublicationUncertain",{message:l.String}){},RO=class extends l.TaggedError()("Unanswered",{message:l.String}){},Ys={BadRequest:HE,Conflict:nx,Forbidden:If,InternalServerError:jn,NotFound:rx,PreconditionFailed:jE,PublicationUncertain:kO,ServiceUnavailable:sx,Unanswered:RO},QIe=l.Union(Object.values(Ys)),Uc={Conflict:nx,InternalServerError:jn,NotFound:rx,ServiceUnavailable:sx},YIe=l.Union(Object.values(Uc));var Que=Ht("handoffSource",{payload:{item:l.String},reads:()=>[Nt.list,Jt.list],rejections:Ys,success:VE}),Yue=Ht("handoffs",{payload:{item:l.String},reads:()=>[Nt.list,Jt.list],rejections:Ys,success:KE}),Xue=tx("prepareHandoff",{invalidates:()=>[Nt.list,Jt.list],payload:L6,rejections:Ys,success:yO}),ZE=Pc("work-board",{commands:[Xue],queries:[Que,Yue]}).middleware(Fc);var efe=Ht("question",{payload:{item:l.String,request:l.String},reads:()=>[Nt.list,Jt.list],rejections:Ys,success:zE}),tfe=Ht("awaitResponse",{payload:{after:l.optional(l.String),question:l.String},reads:()=>[Nt.list,Jt.list],rejections:Ys,success:U6}),rfe=Ht("responses",{payload:{question:l.String},reads:()=>[Nt.list,Jt.list],rejections:Ys,success:N6}),nfe=tx("registerQuestion",{invalidates:()=>[Nt.list,Jt.list],payload:{item:l.String,request:l.String,revision:Qs},rejections:Ys,success:_d}),ofe=tx("recordResponse",{invalidates:()=>[Nt.list,Jt.list],payload:D6,rejections:Ys,success:Nc}),QE=Pc("work-board",{commands:[nfe,ofe],queries:[efe,rfe,tfe]}).middleware(Fc);function YE(e){let t=new URL(e,"http://127.0.0.1").pathname,r=/^\/_board\/item\/(?<id>[^/]+)\/$/u.exec(t)?.groups?.id,n=cK.item(decodeURIComponent(t.slice(1)));return r?n=uK.item(decodeURIComponent(r)):t.startsWith("/_board/")&&(n=Jt.list),[Nt.list,n]}var Pd=l.String.check(l.isMaxLength(8192),l.makeFilter(e=>{if(!e.startsWith("/")||e.startsWith("//"))return"Expected a local reading URL";try{let t=new URL(e,"http://127.0.0.1").pathname;return t==="/"||["/_board/inbox","/_board/diagnostics","/_board/work","/_board/overview","/_board/changes","/_board/start","/_board/respond","/_board/handoff","/_board/result"].includes(t)||/^\/_board\/item\/[^/]+\/$/u.exec(t)!==null||/\.md$/iu.exec(t)!==null||"Expected a local reading URL"}catch{return"Expected a local reading URL"}})),sfe=l.Struct({file:l.String,href:l.String,kind:l.Literals(["document","heading","passage"]),line:l.optional(l.Number),snippet:l.String,text:l.String,title:l.String}),ife=Ht("document",{payload:{url:Pd},reads:({url:e})=>[...YE(e),Jt.list],rejections:Uc,success:ka}),afe=Ht("board",{payload:{url:Pd},reads:({url:e})=>YE(e),rejections:Uc,success:nK}),cfe=Ht("work",{payload:{url:Pd},reads:()=>[Nt.list,Jt.list],rejections:Uc,success:eK}),ufe=Ht("overview",{reads:()=>[Nt.list,Jt.list],rejections:{InternalServerError:jn},success:rK}),ffe=Ht("inbox",{reads:()=>[Nt.list,Jt.list],rejections:{InternalServerError:jn},success:tK}),lfe=Ht("diagnostics",{reads:()=>[Nt.list],rejections:{InternalServerError:jn},success:G6}),dfe=Ht("start",{reads:()=>[Nt.list,Jt.list],rejections:{InternalServerError:jn},success:Z6}),pfe=Ht("respond",{payload:{url:Pd},reads:({url:e})=>[...YE(e),Jt.list],rejections:Uc,success:Q6}),mfe=Ht("handoff",{payload:{url:Pd},reads:()=>[Nt.list,Jt.list],rejections:Uc,success:Y6}),hfe=Ht("result",{payload:{url:Pd},reads:()=>[Nt.list,Jt.list],rejections:Uc,success:j6}),xfe=Ht("navigation",{payload:{current:l.String.check(l.isMaxLength(8192))},reads:()=>[Nt.list,fK.list],rejections:{InternalServerError:jn},success:H6}),gfe=Ht("search",{payload:{query:l.String.check(l.isMaxLength(8192))},reads:()=>[Nt.list,Jt.list],rejections:{InternalServerError:jn},success:l.Struct({results:l.Array(sfe),total:l.Number,unavailable:l.Array(l.String)})}),yfe=Ht("history",{payload:iK,reads:()=>[Nt.list,Jt.list],rejections:{InternalServerError:jn},success:aK}),Sfe=Ht("watcher",{reads:()=>[Nt.list,lK.list],rejections:{InternalServerError:jn},success:l.Struct({watching:l.Boolean})}),OO=k6("subscribe",{reads:()=>[Nt.list],rejections:{InternalServerError:jn},success:I6}),_O=Pc("work-board",{queries:[ife,afe,cfe,ufe,ffe,lfe,dfe,pfe,mfe,hfe,xfe,gfe,yfe,Sfe],streams:[OO]}).middleware(Fc),dK=_O.merge(QE).merge(ZE);function pK(e,t={}){class r extends S6()("WorkBoard/Reader",{group:dK,protocol:Qh.layerProtocolHttp({url:`${e}/_board/rpc`}).pipe(Fn.provide([rE.layer,Gh.layerNdjson]))}){}let n=BE(_O,r),o=OW({defaultIdleTTL:0,timeoutResolution:1}),s=T6(r.runtime,{resume:v6(t),resyncKeys:OO.reads(void 0),stream:n.subscribe.run(void 0)});o.mount(s.connection);async function i(f,p){try{return await ne.runPromise(Fh(o,f,{suspendOnWaiting:!0}),{signal:p})}catch(m){if(p?.aborted){let h=new Error("Reading canceled",{cause:m});throw h.name="AbortError",h}throw m}}async function a(f,p){try{return await ne.runPromise(ne.flatMap(Fh(o,r.runtime),m=>ne.provideContext(f,m)),{signal:p})}catch(m){if(p?.aborted){let h=new Error("Reading canceled",{cause:m});throw h.name="AbortError",h}throw m}}async function c(f,p){let m=await ne.runPromise(ne.result(Fh(o,r.runtime.atom(f),{suspendOnWaiting:!0})),{signal:p});if(m._tag==="Failure")throw m.failure;return m.success}let u=BE(QE,r);return{api:n,handoffs:BE(ZE,r),mutate:c,read:i,registry:o,responses:u,run:a,updates:s}}var XE=new WeakMap;function mK(e){let t=XE.get(e);if(t===void 0){let o=function(){n.registry.dispose(),XE.get(e)===n&&XE.delete(e),e.removeEventListener("pagehide",o)};var r=o;t=pK(e.location.origin,{window:e}),XE.set(e,t);let n=t;e.addEventListener("pagehide",o)}return t}var GTe=mK;export{GTe as session};