@lmvz-ds/components 0.11.4

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 (394) hide show
  1. package/LICENSE.txt +3 -0
  2. package/assets/LMVZ_logo_175.svg +1 -0
  3. package/assets/card-placeholder.svg +4 -0
  4. package/assets/fonts/Router-Bold.woff +0 -0
  5. package/assets/fonts/Router-Book.woff +0 -0
  6. package/assets/fonts/Router-Medium.woff +0 -0
  7. package/assets/icons/Logo.svg +10 -0
  8. package/assets/icons/actions.svg +5 -0
  9. package/assets/icons/adduser.svg +3 -0
  10. package/assets/icons/alert.svg +3 -0
  11. package/assets/icons/apple.svg +3 -0
  12. package/assets/icons/arrow-down.svg +3 -0
  13. package/assets/icons/arrow-left.svg +3 -0
  14. package/assets/icons/arrow-right.svg +3 -0
  15. package/assets/icons/arrow-up.svg +3 -0
  16. package/assets/icons/book.svg +3 -0
  17. package/assets/icons/bookmark.svg +3 -0
  18. package/assets/icons/checkmark.svg +3 -0
  19. package/assets/icons/chevron-down.svg +3 -0
  20. package/assets/icons/chevron-left.svg +3 -0
  21. package/assets/icons/chevron-right.svg +3 -0
  22. package/assets/icons/chevron-up.svg +3 -0
  23. package/assets/icons/close-l.svg +3 -0
  24. package/assets/icons/close-sm.svg +3 -0
  25. package/assets/icons/cog.svg +4 -0
  26. package/assets/icons/computer.svg +3 -0
  27. package/assets/icons/dashboard.svg +6 -0
  28. package/assets/icons/delete.svg +3 -0
  29. package/assets/icons/download.svg +3 -0
  30. package/assets/icons/edit.svg +3 -0
  31. package/assets/icons/external.svg +3 -0
  32. package/assets/icons/facebook.svg +3 -0
  33. package/assets/icons/favorite.svg +3 -0
  34. package/assets/icons/filter.svg +3 -0
  35. package/assets/icons/group.svg +3 -0
  36. package/assets/icons/hide.svg +3 -0
  37. package/assets/icons/home.svg +3 -0
  38. package/assets/icons/info.svg +3 -0
  39. package/assets/icons/instagram.svg +3 -0
  40. package/assets/icons/letter.svg +3 -0
  41. package/assets/icons/linkedin.svg +5 -0
  42. package/assets/icons/logout.svg +3 -0
  43. package/assets/icons/map.svg +3 -0
  44. package/assets/icons/minus.svg +3 -0
  45. package/assets/icons/navigation.svg +3 -0
  46. package/assets/icons/plus.svg +3 -0
  47. package/assets/icons/qr-scan.svg +3 -0
  48. package/assets/icons/question.svg +10 -0
  49. package/assets/icons/reader.svg +3 -0
  50. package/assets/icons/reset.svg +3 -0
  51. package/assets/icons/school.svg +3 -0
  52. package/assets/icons/search.svg +3 -0
  53. package/assets/icons/send.svg +3 -0
  54. package/assets/icons/settings.svg +3 -0
  55. package/assets/icons/share.svg +10 -0
  56. package/assets/icons/shopping-cart.svg +3 -0
  57. package/assets/icons/show.svg +3 -0
  58. package/assets/icons/snapchat.svg +3 -0
  59. package/assets/icons/sort.svg +3 -0
  60. package/assets/icons/speech-bubble.svg +3 -0
  61. package/assets/icons/star.svg +3 -0
  62. package/assets/icons/student.svg +3 -0
  63. package/assets/icons/upload.svg +3 -0
  64. package/assets/icons/user.svg +3 -0
  65. package/assets/icons/warn-circle.svg +3 -0
  66. package/assets/icons/warn-triangle.svg +3 -0
  67. package/assets/icons/whatsapp.svg +4 -0
  68. package/assets/icons/world.svg +10 -0
  69. package/assets/icons/x.svg +3 -0
  70. package/assets/icons/youtube.svg +3 -0
  71. package/assets/zukunftslinie.svg +3 -0
  72. package/dist/cjs/Effect-BIlTHtLK.js +19172 -0
  73. package/dist/cjs/_commonjsHelpers-CFO10eej.js +7 -0
  74. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  75. package/dist/cjs/aria-validation-controller-B7unOPxT.js +2929 -0
  76. package/dist/cjs/axe-BNqwbBGU.js +32834 -0
  77. package/dist/cjs/component-CRc6eHcV.js +138 -0
  78. package/dist/cjs/element-activation-controller-DC_6T0Rt.js +31 -0
  79. package/dist/cjs/icons-DbL3LSmP.js +659 -0
  80. package/dist/cjs/index-9ZJx0550.js +2752 -0
  81. package/dist/cjs/index-CVw4GUo6.js +92 -0
  82. package/dist/cjs/index.cjs.js +96 -0
  83. package/dist/cjs/lmvz-action.cjs.entry.js +22 -0
  84. package/dist/cjs/lmvz-button.cjs.entry.js +72 -0
  85. package/dist/cjs/lmvz-card.cjs.entry.js +33 -0
  86. package/dist/cjs/lmvz-chip.cjs.entry.js +18 -0
  87. package/dist/cjs/lmvz-components.cjs.js +25 -0
  88. package/dist/cjs/lmvz-header.cjs.entry.js +134 -0
  89. package/dist/cjs/lmvz-icon.cjs.entry.js +76 -0
  90. package/dist/cjs/lmvz-input.cjs.entry.js +176 -0
  91. package/dist/cjs/lmvz-menuitem.cjs.entry.js +32 -0
  92. package/dist/cjs/loader.cjs.js +13 -0
  93. package/dist/collection/api/ds.constants.js +73 -0
  94. package/dist/collection/api/index.js +1 -0
  95. package/dist/collection/assets/LMVZ_logo_175.svg +1 -0
  96. package/dist/collection/assets/card-placeholder.svg +4 -0
  97. package/dist/collection/assets/fonts/Router-Bold.woff +0 -0
  98. package/dist/collection/assets/fonts/Router-Book.woff +0 -0
  99. package/dist/collection/assets/fonts/Router-Medium.woff +0 -0
  100. package/dist/collection/assets/icons/Logo.svg +10 -0
  101. package/dist/collection/assets/icons/actions.svg +5 -0
  102. package/dist/collection/assets/icons/adduser.svg +3 -0
  103. package/dist/collection/assets/icons/alert.svg +3 -0
  104. package/dist/collection/assets/icons/apple.svg +3 -0
  105. package/dist/collection/assets/icons/arrow-down.svg +3 -0
  106. package/dist/collection/assets/icons/arrow-left.svg +3 -0
  107. package/dist/collection/assets/icons/arrow-right.svg +3 -0
  108. package/dist/collection/assets/icons/arrow-up.svg +3 -0
  109. package/dist/collection/assets/icons/book.svg +3 -0
  110. package/dist/collection/assets/icons/bookmark.svg +3 -0
  111. package/dist/collection/assets/icons/checkmark.svg +3 -0
  112. package/dist/collection/assets/icons/chevron-down.svg +3 -0
  113. package/dist/collection/assets/icons/chevron-left.svg +3 -0
  114. package/dist/collection/assets/icons/chevron-right.svg +3 -0
  115. package/dist/collection/assets/icons/chevron-up.svg +3 -0
  116. package/dist/collection/assets/icons/close-l.svg +3 -0
  117. package/dist/collection/assets/icons/close-sm.svg +3 -0
  118. package/dist/collection/assets/icons/cog.svg +4 -0
  119. package/dist/collection/assets/icons/computer.svg +3 -0
  120. package/dist/collection/assets/icons/dashboard.svg +6 -0
  121. package/dist/collection/assets/icons/delete.svg +3 -0
  122. package/dist/collection/assets/icons/download.svg +3 -0
  123. package/dist/collection/assets/icons/edit.svg +3 -0
  124. package/dist/collection/assets/icons/external.svg +3 -0
  125. package/dist/collection/assets/icons/facebook.svg +3 -0
  126. package/dist/collection/assets/icons/favorite.svg +3 -0
  127. package/dist/collection/assets/icons/filter.svg +3 -0
  128. package/dist/collection/assets/icons/group.svg +3 -0
  129. package/dist/collection/assets/icons/hide.svg +3 -0
  130. package/dist/collection/assets/icons/home.svg +3 -0
  131. package/dist/collection/assets/icons/info.svg +3 -0
  132. package/dist/collection/assets/icons/instagram.svg +3 -0
  133. package/dist/collection/assets/icons/letter.svg +3 -0
  134. package/dist/collection/assets/icons/linkedin.svg +5 -0
  135. package/dist/collection/assets/icons/logout.svg +3 -0
  136. package/dist/collection/assets/icons/map.svg +3 -0
  137. package/dist/collection/assets/icons/minus.svg +3 -0
  138. package/dist/collection/assets/icons/navigation.svg +3 -0
  139. package/dist/collection/assets/icons/plus.svg +3 -0
  140. package/dist/collection/assets/icons/qr-scan.svg +3 -0
  141. package/dist/collection/assets/icons/question.svg +10 -0
  142. package/dist/collection/assets/icons/reader.svg +3 -0
  143. package/dist/collection/assets/icons/reset.svg +3 -0
  144. package/dist/collection/assets/icons/school.svg +3 -0
  145. package/dist/collection/assets/icons/search.svg +3 -0
  146. package/dist/collection/assets/icons/send.svg +3 -0
  147. package/dist/collection/assets/icons/settings.svg +3 -0
  148. package/dist/collection/assets/icons/share.svg +10 -0
  149. package/dist/collection/assets/icons/shopping-cart.svg +3 -0
  150. package/dist/collection/assets/icons/show.svg +3 -0
  151. package/dist/collection/assets/icons/snapchat.svg +3 -0
  152. package/dist/collection/assets/icons/sort.svg +3 -0
  153. package/dist/collection/assets/icons/speech-bubble.svg +3 -0
  154. package/dist/collection/assets/icons/star.svg +3 -0
  155. package/dist/collection/assets/icons/student.svg +3 -0
  156. package/dist/collection/assets/icons/upload.svg +3 -0
  157. package/dist/collection/assets/icons/user.svg +3 -0
  158. package/dist/collection/assets/icons/warn-circle.svg +3 -0
  159. package/dist/collection/assets/icons/warn-triangle.svg +3 -0
  160. package/dist/collection/assets/icons/whatsapp.svg +4 -0
  161. package/dist/collection/assets/icons/world.svg +10 -0
  162. package/dist/collection/assets/icons/x.svg +3 -0
  163. package/dist/collection/assets/icons/youtube.svg +3 -0
  164. package/dist/collection/assets/zukunftslinie.svg +3 -0
  165. package/dist/collection/collection-manifest.json +21 -0
  166. package/dist/collection/components/lmvz-action/lmvz-action.css +3 -0
  167. package/dist/collection/components/lmvz-action/lmvz-action.js +45 -0
  168. package/dist/collection/components/lmvz-button/lmvz-button.css +199 -0
  169. package/dist/collection/components/lmvz-button/lmvz-button.js +245 -0
  170. package/dist/collection/components/lmvz-card/lmvz-card.css +283 -0
  171. package/dist/collection/components/lmvz-card/lmvz-card.js +137 -0
  172. package/dist/collection/components/lmvz-chip/lmvz-chip.css +3 -0
  173. package/dist/collection/components/lmvz-chip/lmvz-chip.js +42 -0
  174. package/dist/collection/components/lmvz-header/lmvz-header.css +49 -0
  175. package/dist/collection/components/lmvz-header/lmvz-header.js +138 -0
  176. package/dist/collection/components/lmvz-icon/icons.js +36 -0
  177. package/dist/collection/components/lmvz-icon/lmvz-icon.css +82 -0
  178. package/dist/collection/components/lmvz-icon/lmvz-icon.js +191 -0
  179. package/dist/collection/components/lmvz-icon/public.js +1 -0
  180. package/dist/collection/components/lmvz-icon/test/icons.unit.js +89 -0
  181. package/dist/collection/components/lmvz-input/lmvz-input.css +201 -0
  182. package/dist/collection/components/lmvz-input/lmvz-input.js +847 -0
  183. package/dist/collection/components/lmvz-menuitem/lmvz-menuitem.css +89 -0
  184. package/dist/collection/components/lmvz-menuitem/lmvz-menuitem.js +97 -0
  185. package/dist/collection/index.js +3 -0
  186. package/dist/collection/integration/header-integration.js +28 -0
  187. package/dist/collection/styles/buttons.css +1 -0
  188. package/dist/collection/styles/router-font.css +1 -0
  189. package/dist/collection/styles/tokens.css +1 -0
  190. package/dist/collection/styles/typography.css +1 -0
  191. package/dist/collection/themes/all.css +1 -0
  192. package/dist/collection/themes/dark.css +1 -0
  193. package/dist/collection/themes/light.css +1 -0
  194. package/dist/collection/utils/component.js +268 -0
  195. package/dist/collection/utils/effect.js +6 -0
  196. package/dist/collection/utils/element-activation-controller.js +27 -0
  197. package/dist/collection/utils/http.js +24 -0
  198. package/dist/collection/utils/http.test.js +46 -0
  199. package/dist/collection/utils/list-keyboard-controller.js +44 -0
  200. package/dist/collection/utils/public.js +1 -0
  201. package/dist/collection/utils/reactive-controller-host.js +39 -0
  202. package/dist/collection/utils/typing.js +1 -0
  203. package/dist/collection/utils/url.js +7 -0
  204. package/dist/collection/utils/validation/aria-validation-controller.js +124 -0
  205. package/dist/collection/utils/validation/svg.js +24 -0
  206. package/dist/components/index.d.ts +53 -0
  207. package/dist/components/index.js +1 -0
  208. package/dist/components/lmvz-action.d.ts +11 -0
  209. package/dist/components/lmvz-action.js +1 -0
  210. package/dist/components/lmvz-button.d.ts +11 -0
  211. package/dist/components/lmvz-button.js +1 -0
  212. package/dist/components/lmvz-card.d.ts +11 -0
  213. package/dist/components/lmvz-card.js +1 -0
  214. package/dist/components/lmvz-chip.d.ts +11 -0
  215. package/dist/components/lmvz-chip.js +1 -0
  216. package/dist/components/lmvz-header.d.ts +11 -0
  217. package/dist/components/lmvz-header.js +1 -0
  218. package/dist/components/lmvz-icon.d.ts +11 -0
  219. package/dist/components/lmvz-icon.js +1 -0
  220. package/dist/components/lmvz-input.d.ts +11 -0
  221. package/dist/components/lmvz-input.js +1 -0
  222. package/dist/components/lmvz-menuitem.d.ts +11 -0
  223. package/dist/components/lmvz-menuitem.js +1 -0
  224. package/dist/components/p-B3JVFwO1.js +1 -0
  225. package/dist/components/p-B85MJLTf.js +1 -0
  226. package/dist/components/p-BFwzIh71.js +1 -0
  227. package/dist/components/p-BaPwpeMs.js +1 -0
  228. package/dist/components/p-CN0JX9-m.js +1 -0
  229. package/dist/components/p-D1HbKFuh.js +12 -0
  230. package/dist/components/p-DDmjv-N_.js +1 -0
  231. package/dist/components/p-DMLRPGid.js +6 -0
  232. package/dist/esm/Effect-D9S7OTyY.js +18963 -0
  233. package/dist/esm/_commonjsHelpers-B85MJLTf.js +5 -0
  234. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  235. package/dist/esm/aria-validation-controller-C7nQzCCq.js +2926 -0
  236. package/dist/esm/axe-cRQ9Ux1I.js +32832 -0
  237. package/dist/esm/component-B3JVFwO1.js +132 -0
  238. package/dist/esm/element-activation-controller-CN0JX9-m.js +29 -0
  239. package/dist/esm/icons-B71gAZmE.js +655 -0
  240. package/dist/esm/index-Bt32KzDW.js +90 -0
  241. package/dist/esm/index-smGPjoDX.js +2741 -0
  242. package/dist/esm/index.js +85 -0
  243. package/dist/esm/lmvz-action.entry.js +20 -0
  244. package/dist/esm/lmvz-button.entry.js +70 -0
  245. package/dist/esm/lmvz-card.entry.js +31 -0
  246. package/dist/esm/lmvz-chip.entry.js +16 -0
  247. package/dist/esm/lmvz-components.js +21 -0
  248. package/dist/esm/lmvz-header.entry.js +132 -0
  249. package/dist/esm/lmvz-icon.entry.js +74 -0
  250. package/dist/esm/lmvz-input.entry.js +174 -0
  251. package/dist/esm/lmvz-menuitem.entry.js +30 -0
  252. package/dist/esm/loader.js +11 -0
  253. package/dist/index.cjs.js +1 -0
  254. package/dist/index.js +1 -0
  255. package/dist/lmvz-components/assets/LMVZ_logo_175.svg +1 -0
  256. package/dist/lmvz-components/assets/card-placeholder.svg +4 -0
  257. package/dist/lmvz-components/assets/fonts/Router-Bold.woff +0 -0
  258. package/dist/lmvz-components/assets/fonts/Router-Book.woff +0 -0
  259. package/dist/lmvz-components/assets/fonts/Router-Medium.woff +0 -0
  260. package/dist/lmvz-components/assets/icons/Logo.svg +10 -0
  261. package/dist/lmvz-components/assets/icons/actions.svg +5 -0
  262. package/dist/lmvz-components/assets/icons/adduser.svg +3 -0
  263. package/dist/lmvz-components/assets/icons/alert.svg +3 -0
  264. package/dist/lmvz-components/assets/icons/apple.svg +3 -0
  265. package/dist/lmvz-components/assets/icons/arrow-down.svg +3 -0
  266. package/dist/lmvz-components/assets/icons/arrow-left.svg +3 -0
  267. package/dist/lmvz-components/assets/icons/arrow-right.svg +3 -0
  268. package/dist/lmvz-components/assets/icons/arrow-up.svg +3 -0
  269. package/dist/lmvz-components/assets/icons/book.svg +3 -0
  270. package/dist/lmvz-components/assets/icons/bookmark.svg +3 -0
  271. package/dist/lmvz-components/assets/icons/checkmark.svg +3 -0
  272. package/dist/lmvz-components/assets/icons/chevron-down.svg +3 -0
  273. package/dist/lmvz-components/assets/icons/chevron-left.svg +3 -0
  274. package/dist/lmvz-components/assets/icons/chevron-right.svg +3 -0
  275. package/dist/lmvz-components/assets/icons/chevron-up.svg +3 -0
  276. package/dist/lmvz-components/assets/icons/close-l.svg +3 -0
  277. package/dist/lmvz-components/assets/icons/close-sm.svg +3 -0
  278. package/dist/lmvz-components/assets/icons/cog.svg +4 -0
  279. package/dist/lmvz-components/assets/icons/computer.svg +3 -0
  280. package/dist/lmvz-components/assets/icons/dashboard.svg +6 -0
  281. package/dist/lmvz-components/assets/icons/delete.svg +3 -0
  282. package/dist/lmvz-components/assets/icons/download.svg +3 -0
  283. package/dist/lmvz-components/assets/icons/edit.svg +3 -0
  284. package/dist/lmvz-components/assets/icons/external.svg +3 -0
  285. package/dist/lmvz-components/assets/icons/facebook.svg +3 -0
  286. package/dist/lmvz-components/assets/icons/favorite.svg +3 -0
  287. package/dist/lmvz-components/assets/icons/filter.svg +3 -0
  288. package/dist/lmvz-components/assets/icons/group.svg +3 -0
  289. package/dist/lmvz-components/assets/icons/hide.svg +3 -0
  290. package/dist/lmvz-components/assets/icons/home.svg +3 -0
  291. package/dist/lmvz-components/assets/icons/info.svg +3 -0
  292. package/dist/lmvz-components/assets/icons/instagram.svg +3 -0
  293. package/dist/lmvz-components/assets/icons/letter.svg +3 -0
  294. package/dist/lmvz-components/assets/icons/linkedin.svg +5 -0
  295. package/dist/lmvz-components/assets/icons/logout.svg +3 -0
  296. package/dist/lmvz-components/assets/icons/map.svg +3 -0
  297. package/dist/lmvz-components/assets/icons/minus.svg +3 -0
  298. package/dist/lmvz-components/assets/icons/navigation.svg +3 -0
  299. package/dist/lmvz-components/assets/icons/plus.svg +3 -0
  300. package/dist/lmvz-components/assets/icons/qr-scan.svg +3 -0
  301. package/dist/lmvz-components/assets/icons/question.svg +10 -0
  302. package/dist/lmvz-components/assets/icons/reader.svg +3 -0
  303. package/dist/lmvz-components/assets/icons/reset.svg +3 -0
  304. package/dist/lmvz-components/assets/icons/school.svg +3 -0
  305. package/dist/lmvz-components/assets/icons/search.svg +3 -0
  306. package/dist/lmvz-components/assets/icons/send.svg +3 -0
  307. package/dist/lmvz-components/assets/icons/settings.svg +3 -0
  308. package/dist/lmvz-components/assets/icons/share.svg +10 -0
  309. package/dist/lmvz-components/assets/icons/shopping-cart.svg +3 -0
  310. package/dist/lmvz-components/assets/icons/show.svg +3 -0
  311. package/dist/lmvz-components/assets/icons/snapchat.svg +3 -0
  312. package/dist/lmvz-components/assets/icons/sort.svg +3 -0
  313. package/dist/lmvz-components/assets/icons/speech-bubble.svg +3 -0
  314. package/dist/lmvz-components/assets/icons/star.svg +3 -0
  315. package/dist/lmvz-components/assets/icons/student.svg +3 -0
  316. package/dist/lmvz-components/assets/icons/upload.svg +3 -0
  317. package/dist/lmvz-components/assets/icons/user.svg +3 -0
  318. package/dist/lmvz-components/assets/icons/warn-circle.svg +3 -0
  319. package/dist/lmvz-components/assets/icons/warn-triangle.svg +3 -0
  320. package/dist/lmvz-components/assets/icons/whatsapp.svg +4 -0
  321. package/dist/lmvz-components/assets/icons/world.svg +10 -0
  322. package/dist/lmvz-components/assets/icons/x.svg +3 -0
  323. package/dist/lmvz-components/assets/icons/youtube.svg +3 -0
  324. package/dist/lmvz-components/assets/zukunftslinie.svg +3 -0
  325. package/dist/lmvz-components/index.esm.js +1 -0
  326. package/dist/lmvz-components/lmvz-components.esm.js +1 -0
  327. package/dist/lmvz-components/p-87b01940.entry.js +1 -0
  328. package/dist/lmvz-components/p-9faac8f3.entry.js +1 -0
  329. package/dist/lmvz-components/p-B3JVFwO1.js +1 -0
  330. package/dist/lmvz-components/p-B85MJLTf.js +1 -0
  331. package/dist/lmvz-components/p-CN0JX9-m.js +1 -0
  332. package/dist/lmvz-components/p-D1HbKFuh.js +12 -0
  333. package/dist/lmvz-components/p-D9S7OTyY.js +1 -0
  334. package/dist/lmvz-components/p-DMLRPGid.js +6 -0
  335. package/dist/lmvz-components/p-DQuL1Twl.js +1 -0
  336. package/dist/lmvz-components/p-DlIX18fw.js +1 -0
  337. package/dist/lmvz-components/p-DlrjrWsu.js +1 -0
  338. package/dist/lmvz-components/p-a4615e4b.entry.js +1 -0
  339. package/dist/lmvz-components/p-a8c88454.entry.js +1 -0
  340. package/dist/lmvz-components/p-d4b68381.entry.js +1 -0
  341. package/dist/lmvz-components/p-e63e239a.entry.js +1 -0
  342. package/dist/lmvz-components/p-f956a5e7.entry.js +1 -0
  343. package/dist/lmvz-components/p-fefd2fe4.entry.js +1 -0
  344. package/dist/lmvz-components/p-smGPjoDX.js +2 -0
  345. package/dist/lmvz-components/styles/buttons.css +1 -0
  346. package/dist/lmvz-components/styles/router-font.css +1 -0
  347. package/dist/lmvz-components/styles/tokens.css +1 -0
  348. package/dist/lmvz-components/styles/typography.css +1 -0
  349. package/dist/lmvz-components/themes/all.css +1 -0
  350. package/dist/lmvz-components/themes/dark.css +1 -0
  351. package/dist/lmvz-components/themes/light.css +1 -0
  352. package/dist/manifest.d.ts +480 -0
  353. package/dist/manifest.json +5184 -0
  354. package/dist/types/api/aria-types.d.ts +9 -0
  355. package/dist/types/api/ds.constants.d.ts +8 -0
  356. package/dist/types/api/ds.types.d.ts +39 -0
  357. package/dist/types/api/index.d.ts +3 -0
  358. package/dist/types/components/lmvz-action/lmvz-action.d.ts +6 -0
  359. package/dist/types/components/lmvz-button/lmvz-button.d.ts +25 -0
  360. package/dist/types/components/lmvz-card/lmvz-card.d.ts +11 -0
  361. package/dist/types/components/lmvz-chip/lmvz-chip.d.ts +4 -0
  362. package/dist/types/components/lmvz-header/lmvz-header.d.ts +23 -0
  363. package/dist/types/components/lmvz-icon/icons.d.ts +8 -0
  364. package/dist/types/components/lmvz-icon/lmvz-icon.d.ts +20 -0
  365. package/dist/types/components/lmvz-icon/public.d.ts +1 -0
  366. package/dist/types/components/lmvz-icon/test/icons.unit.d.ts +1 -0
  367. package/dist/types/components/lmvz-input/lmvz-input.d.ts +63 -0
  368. package/dist/types/components/lmvz-menuitem/lmvz-menuitem.d.ts +12 -0
  369. package/dist/types/components.d.ts +773 -0
  370. package/dist/types/index.d.ts +5 -0
  371. package/dist/types/stencil-public-runtime.d.ts +1860 -0
  372. package/dist/types/utils/component.d.ts +36 -0
  373. package/dist/types/utils/effect.d.ts +3 -0
  374. package/dist/types/utils/element-activation-controller.d.ts +19 -0
  375. package/dist/types/utils/http.d.ts +24 -0
  376. package/dist/types/utils/http.test.d.ts +1 -0
  377. package/dist/types/utils/list-keyboard-controller.d.ts +13 -0
  378. package/dist/types/utils/public.d.ts +1 -0
  379. package/dist/types/utils/reactive-controller-host.d.ts +26 -0
  380. package/dist/types/utils/typing.d.ts +3 -0
  381. package/dist/types/utils/url.d.ts +8 -0
  382. package/dist/types/utils/validation/aria-validation-controller.d.ts +31 -0
  383. package/dist/types/utils/validation/svg.d.ts +11 -0
  384. package/hydrate/index.d.ts +287 -0
  385. package/hydrate/index.js +78213 -0
  386. package/hydrate/index.mjs +78203 -0
  387. package/hydrate/package.json +12 -0
  388. package/loader/cdn.js +1 -0
  389. package/loader/index.cjs.js +1 -0
  390. package/loader/index.d.ts +24 -0
  391. package/loader/index.es2017.js +1 -0
  392. package/loader/index.js +2 -0
  393. package/package.json +216 -0
  394. package/readme.md +193 -0
@@ -0,0 +1,2929 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-9ZJx0550.js');
4
+ var Effect = require('./Effect-BIlTHtLK.js');
5
+
6
+ /**
7
+ * @since 2.0.0
8
+ * @category constructors
9
+ */
10
+ const make$3 = Effect.make$1;
11
+ /**
12
+ * @since 2.0.0
13
+ * @category getters
14
+ */
15
+ const get = Effect.get$1;
16
+ /**
17
+ * @since 2.0.0
18
+ * @category utils
19
+ */
20
+ const modify = Effect.modify;
21
+ /**
22
+ * @since 2.0.0
23
+ * @category utils
24
+ */
25
+ const update = Effect.update;
26
+
27
+ /**
28
+ * Creates a `Fail` cause from an expected error.
29
+ *
30
+ * **Details**
31
+ *
32
+ * This function constructs a `Cause` carrying an error of type `E`. It's used
33
+ * when you want to represent a known or anticipated failure in your effectful
34
+ * computations.
35
+ *
36
+ * @see {@link isFailure} Check if a `Cause` contains a failure
37
+ *
38
+ * @since 2.0.0
39
+ * @category Constructors
40
+ */
41
+ const fail$1 = Effect.fail;
42
+ /**
43
+ * Creates a `Die` cause from an unexpected error.
44
+ *
45
+ * **Details**
46
+ *
47
+ * This function wraps an unhandled or unknown defect (like a runtime crash)
48
+ * into a `Cause`. It's useful for capturing unforeseen issues in a structured
49
+ * way.
50
+ *
51
+ * @see {@link isDie} Check if a `Cause` contains a defect
52
+ *
53
+ * @since 2.0.0
54
+ * @category Constructors
55
+ */
56
+ const die = Effect.die;
57
+ /**
58
+ * Creates an `Interrupt` cause from a `FiberId`.
59
+ *
60
+ * **Details**
61
+ *
62
+ * This function represents a fiber that has been interrupted. It stores the
63
+ * identifier of the interrupted fiber, enabling precise tracking of concurrent
64
+ * cancellations.
65
+ *
66
+ * @see {@link isInterrupted} Check if a `Cause` contains an interruption
67
+ *
68
+ * @since 2.0.0
69
+ * @category Constructors
70
+ */
71
+ const interrupt$1 = Effect.interrupt$1;
72
+ /**
73
+ * Checks if a `Cause` is a `Die` type.
74
+ *
75
+ * @see {@link die} Create a new `Die` cause
76
+ *
77
+ * @since 2.0.0
78
+ * @category Guards
79
+ */
80
+ const isDieType = Effect.isDieType;
81
+ /**
82
+ * Checks if a `Cause` contains an interruption.
83
+ *
84
+ * **Details**
85
+ *
86
+ * This function returns `true` if the `Cause` includes any fiber interruptions.
87
+ *
88
+ * @since 2.0.0
89
+ * @category Getters
90
+ */
91
+ const isInterrupted = Effect.isInterrupted;
92
+ /**
93
+ * Checks if a `Cause` contains only interruptions.
94
+ *
95
+ * **Details**
96
+ *
97
+ * This function returns `true` if the `Cause` has been interrupted but does not
98
+ * contain any other failures, such as `Fail` or `Die`. It's helpful for
99
+ * verifying purely "cancellation" scenarios.
100
+ *
101
+ * @since 2.0.0
102
+ * @category Getters
103
+ */
104
+ const isInterruptedOnly = Effect.isInterruptedOnly;
105
+ /**
106
+ * Collects all `FiberId`s responsible for interrupting a fiber.
107
+ *
108
+ * **Details**
109
+ *
110
+ * This function returns a set of IDs indicating which fibers caused
111
+ * interruptions within this `Cause`. It's useful for debugging concurrency
112
+ * issues or tracing cancellations.
113
+ *
114
+ * @since 2.0.0
115
+ * @category Getters
116
+ */
117
+ const interruptors = Effect.interruptors;
118
+ /**
119
+ * Splits a `Cause` into either its first `Fail` error or the rest of the cause
120
+ * (which might only contain `Die` or `Interrupt`).
121
+ *
122
+ * **Details**
123
+ *
124
+ * This function either returns the checked error (`E`) or the remaining
125
+ * `Cause<never>` with defects/interruptions. It helps you decide if there's a
126
+ * recoverable path or if only unhandled issues remain.
127
+ *
128
+ * @since 2.0.0
129
+ * @category Getters
130
+ */
131
+ const failureOrCause = Effect.failureOrCause;
132
+ /**
133
+ * Strips out failures with an error of `None` from a `Cause<Option<E>>`.
134
+ *
135
+ * **Details**
136
+ *
137
+ * This function turns a `Cause<Option<E>>` into an `Option<Cause<E>>`. If the
138
+ * cause only contains failures of `None`, it becomes `None`; otherwise, it
139
+ * returns a `Cause` of the remaining errors. It's helpful when working with
140
+ * optional errors and filtering out certain error paths.
141
+ *
142
+ * @since 2.0.0
143
+ * @category Getters
144
+ */
145
+ const flipCauseOption = Effect.flipCauseOption;
146
+ /**
147
+ * Transforms the errors in a `Cause` using a user-provided function.
148
+ *
149
+ * **Details**
150
+ *
151
+ * This function applies `f` to each `Fail` error while leaving defects (`Die`)
152
+ * and interruptions untouched. It's useful for changing or simplifying error
153
+ * types in your effectful workflows.
154
+ *
155
+ * @see {@link as} Replace errors with a single constant
156
+ *
157
+ * @since 2.0.0
158
+ * @category Mapping
159
+ */
160
+ const map$2 = Effect.map$1;
161
+
162
+ const _await = Effect._await$1;
163
+ /**
164
+ * Inherits values from all `FiberRef` instances into current fiber. This
165
+ * will resume immediately.
166
+ *
167
+ * @since 2.0.0
168
+ * @category destructors
169
+ */
170
+ const inheritAll = Effect.inheritAll;
171
+ /**
172
+ * Interrupts the fiber from whichever fiber is calling this method. If the
173
+ * fiber has already exited, the returned effect will resume immediately.
174
+ * Otherwise, the effect will resume when the fiber exits.
175
+ *
176
+ * @since 2.0.0
177
+ * @category interruption
178
+ */
179
+ const interrupt = Effect.interruptFiber;
180
+ /**
181
+ * Interrupts the fiber as if interrupted from the specified fiber. If the
182
+ * fiber has already exited, the returned effect will resume immediately.
183
+ * Otherwise, the effect will resume when the fiber exits.
184
+ *
185
+ * @since 2.0.0
186
+ * @category interruption
187
+ */
188
+ const interruptAs = Effect.interruptAsFiber;
189
+ /**
190
+ * Joins the fiber, which suspends the joining fiber until the result of the
191
+ * fiber has been determined. Attempting to join a fiber that has erred will
192
+ * result in a catchable error. Joining an interrupted fiber will result in an
193
+ * "inner interruption" of this fiber, unlike interruption triggered by
194
+ * another fiber, "inner interruption" can be caught and recovered.
195
+ *
196
+ * @since 2.0.0
197
+ * @category destructors
198
+ */
199
+ const join = Effect.join;
200
+
201
+ /** @internal */
202
+ const EnqueueSymbolKey = "effect/QueueEnqueue";
203
+ /** @internal */
204
+ const EnqueueTypeId = /*#__PURE__*/Symbol.for(EnqueueSymbolKey);
205
+ /** @internal */
206
+ const DequeueSymbolKey = "effect/QueueDequeue";
207
+ /** @internal */
208
+ const DequeueTypeId = /*#__PURE__*/Symbol.for(DequeueSymbolKey);
209
+ /** @internal */
210
+ const QueueStrategySymbolKey = "effect/QueueStrategy";
211
+ /** @internal */
212
+ const QueueStrategyTypeId = /*#__PURE__*/Symbol.for(QueueStrategySymbolKey);
213
+ /** @internal */
214
+ const BackingQueueSymbolKey = "effect/BackingQueue";
215
+ /** @internal */
216
+ const BackingQueueTypeId = /*#__PURE__*/Symbol.for(BackingQueueSymbolKey);
217
+ const queueStrategyVariance = {
218
+ /* c8 ignore next */
219
+ _A: _ => _
220
+ };
221
+ const backingQueueVariance = {
222
+ /* c8 ignore next */
223
+ _A: _ => _
224
+ };
225
+ /** @internal */
226
+ const enqueueVariance = {
227
+ /* c8 ignore next */
228
+ _In: _ => _
229
+ };
230
+ /** @internal */
231
+ const dequeueVariance = {
232
+ /* c8 ignore next */
233
+ _Out: _ => _
234
+ };
235
+ /** @internal */
236
+ class QueueImpl extends Effect.Class {
237
+ queue;
238
+ takers;
239
+ shutdownHook;
240
+ shutdownFlag;
241
+ strategy;
242
+ [EnqueueTypeId] = enqueueVariance;
243
+ [DequeueTypeId] = dequeueVariance;
244
+ constructor(/** @internal */
245
+ queue, /** @internal */
246
+ takers, /** @internal */
247
+ shutdownHook, /** @internal */
248
+ shutdownFlag, /** @internal */
249
+ strategy) {
250
+ super();
251
+ this.queue = queue;
252
+ this.takers = takers;
253
+ this.shutdownHook = shutdownHook;
254
+ this.shutdownFlag = shutdownFlag;
255
+ this.strategy = strategy;
256
+ }
257
+ pipe() {
258
+ return Effect.pipeArguments(this, arguments);
259
+ }
260
+ commit() {
261
+ return this.take;
262
+ }
263
+ capacity() {
264
+ return this.queue.capacity();
265
+ }
266
+ get size() {
267
+ return Effect.suspend(() => Effect.catchAll$1(this.unsafeSize(), () => Effect.interrupt$2));
268
+ }
269
+ unsafeSize() {
270
+ if (Effect.get$2(this.shutdownFlag)) {
271
+ return Effect.none();
272
+ }
273
+ return Effect.some(this.queue.length() - Effect.length(this.takers) + this.strategy.surplusSize());
274
+ }
275
+ get isEmpty() {
276
+ return Effect.map(this.size, size => size <= 0);
277
+ }
278
+ get isFull() {
279
+ return Effect.map(this.size, size => size >= this.capacity());
280
+ }
281
+ get shutdown() {
282
+ return Effect.uninterruptible(Effect.withFiberRuntime(state => {
283
+ Effect.pipe(this.shutdownFlag, Effect.set$1(true));
284
+ return Effect.pipe(Effect.forEachConcurrentDiscard(unsafePollAll(this.takers), d => Effect.deferredInterruptWith(d, state.id()), false, false), Effect.zipRight(this.strategy.shutdown), Effect.whenEffect(Effect.deferredSucceed(this.shutdownHook, void 0)), Effect.asVoid);
285
+ }));
286
+ }
287
+ get isShutdown() {
288
+ return Effect.sync(() => Effect.get$2(this.shutdownFlag));
289
+ }
290
+ get awaitShutdown() {
291
+ return Effect.deferredAwait(this.shutdownHook);
292
+ }
293
+ isActive() {
294
+ return !Effect.get$2(this.shutdownFlag);
295
+ }
296
+ unsafeOffer(value) {
297
+ if (Effect.get$2(this.shutdownFlag)) {
298
+ return false;
299
+ }
300
+ let noRemaining;
301
+ if (this.queue.length() === 0) {
302
+ const taker = Effect.pipe(this.takers, Effect.poll(Effect.EmptyMutableQueue));
303
+ if (taker !== Effect.EmptyMutableQueue) {
304
+ unsafeCompleteDeferred(taker, value);
305
+ noRemaining = true;
306
+ } else {
307
+ noRemaining = false;
308
+ }
309
+ } else {
310
+ noRemaining = false;
311
+ }
312
+ if (noRemaining) {
313
+ return true;
314
+ }
315
+ // Not enough takers, offer to the queue
316
+ const succeeded = this.queue.offer(value);
317
+ unsafeCompleteTakers(this.strategy, this.queue, this.takers);
318
+ return succeeded;
319
+ }
320
+ offer(value) {
321
+ return Effect.suspend(() => {
322
+ if (Effect.get$2(this.shutdownFlag)) {
323
+ return Effect.interrupt$2;
324
+ }
325
+ let noRemaining;
326
+ if (this.queue.length() === 0) {
327
+ const taker = Effect.pipe(this.takers, Effect.poll(Effect.EmptyMutableQueue));
328
+ if (taker !== Effect.EmptyMutableQueue) {
329
+ unsafeCompleteDeferred(taker, value);
330
+ noRemaining = true;
331
+ } else {
332
+ noRemaining = false;
333
+ }
334
+ } else {
335
+ noRemaining = false;
336
+ }
337
+ if (noRemaining) {
338
+ return Effect.succeed$1(true);
339
+ }
340
+ // Not enough takers, offer to the queue
341
+ const succeeded = this.queue.offer(value);
342
+ unsafeCompleteTakers(this.strategy, this.queue, this.takers);
343
+ return succeeded ? Effect.succeed$1(true) : this.strategy.handleSurplus([value], this.queue, this.takers, this.shutdownFlag);
344
+ });
345
+ }
346
+ offerAll(iterable) {
347
+ return Effect.suspend(() => {
348
+ if (Effect.get$2(this.shutdownFlag)) {
349
+ return Effect.interrupt$2;
350
+ }
351
+ const values = Effect.fromIterable(iterable);
352
+ const pTakers = this.queue.length() === 0 ? Effect.fromIterable(unsafePollN(this.takers, values.length)) : Effect.empty$1;
353
+ const [forTakers, remaining] = Effect.pipe(values, Effect.splitAt(pTakers.length));
354
+ for (let i = 0; i < pTakers.length; i++) {
355
+ const taker = pTakers[i];
356
+ const item = forTakers[i];
357
+ unsafeCompleteDeferred(taker, item);
358
+ }
359
+ if (remaining.length === 0) {
360
+ return Effect.succeed$1(true);
361
+ }
362
+ // Not enough takers, offer to the queue
363
+ const surplus = this.queue.offerAll(remaining);
364
+ unsafeCompleteTakers(this.strategy, this.queue, this.takers);
365
+ return Effect.isEmpty(surplus) ? Effect.succeed$1(true) : this.strategy.handleSurplus(surplus, this.queue, this.takers, this.shutdownFlag);
366
+ });
367
+ }
368
+ get take() {
369
+ return Effect.withFiberRuntime(state => {
370
+ if (Effect.get$2(this.shutdownFlag)) {
371
+ return Effect.interrupt$2;
372
+ }
373
+ const item = this.queue.poll(Effect.EmptyMutableQueue);
374
+ if (item !== Effect.EmptyMutableQueue) {
375
+ this.strategy.unsafeOnQueueEmptySpace(this.queue, this.takers);
376
+ return Effect.succeed$1(item);
377
+ } else {
378
+ // Add the deferred to takers, then:
379
+ // - Try to take again in case a value was added since
380
+ // - Wait for the deferred to be completed
381
+ // - Clean up resources in case of interruption
382
+ const deferred = Effect.deferredUnsafeMake(state.id());
383
+ return Effect.pipe(Effect.suspend(() => {
384
+ Effect.pipe(this.takers, Effect.offer(deferred));
385
+ unsafeCompleteTakers(this.strategy, this.queue, this.takers);
386
+ return Effect.get$2(this.shutdownFlag) ? Effect.interrupt$2 : Effect.deferredAwait(deferred);
387
+ }), Effect.onInterrupt(() => {
388
+ return Effect.sync(() => unsafeRemove(this.takers, deferred));
389
+ }));
390
+ }
391
+ });
392
+ }
393
+ get takeAll() {
394
+ return Effect.suspend(() => {
395
+ return Effect.get$2(this.shutdownFlag) ? Effect.interrupt$2 : Effect.sync(() => {
396
+ const values = this.queue.pollUpTo(Number.POSITIVE_INFINITY);
397
+ this.strategy.unsafeOnQueueEmptySpace(this.queue, this.takers);
398
+ return Effect.fromIterable$1(values);
399
+ });
400
+ });
401
+ }
402
+ takeUpTo(max) {
403
+ return Effect.suspend(() => Effect.get$2(this.shutdownFlag) ? Effect.interrupt$2 : Effect.sync(() => {
404
+ const values = this.queue.pollUpTo(max);
405
+ this.strategy.unsafeOnQueueEmptySpace(this.queue, this.takers);
406
+ return Effect.fromIterable$1(values);
407
+ }));
408
+ }
409
+ takeBetween(min, max) {
410
+ return Effect.suspend(() => takeRemainderLoop(this, min, max, Effect.empty$2()));
411
+ }
412
+ }
413
+ /** @internal */
414
+ const takeRemainderLoop = (self, min, max, acc) => {
415
+ if (max < min) {
416
+ return Effect.succeed$1(acc);
417
+ }
418
+ return Effect.pipe(takeUpTo(self, max), Effect.flatMap(bs => {
419
+ const remaining = min - bs.length;
420
+ if (remaining === 1) {
421
+ return Effect.pipe(take$1(self), Effect.map(b => Effect.pipe(acc, Effect.appendAll(bs), Effect.append(b))));
422
+ }
423
+ if (remaining > 1) {
424
+ return Effect.pipe(take$1(self), Effect.flatMap(b => takeRemainderLoop(self, remaining - 1, max - bs.length - 1, Effect.pipe(acc, Effect.appendAll(bs), Effect.append(b)))));
425
+ }
426
+ return Effect.succeed$1(Effect.pipe(acc, Effect.appendAll(bs)));
427
+ }));
428
+ };
429
+ /** @internal */
430
+ const bounded$1 = requestedCapacity => Effect.pipe(Effect.sync(() => Effect.bounded(requestedCapacity)), Effect.flatMap(queue => make$2(backingQueueFromMutableQueue(queue), backPressureStrategy())));
431
+ /** @internal */
432
+ const unbounded$1 = () => Effect.pipe(Effect.sync(() => Effect.unbounded()), Effect.flatMap(queue => make$2(backingQueueFromMutableQueue(queue), droppingStrategy())));
433
+ /** @internal */
434
+ const unsafeMake = (queue, takers, shutdownHook, shutdownFlag, strategy) => {
435
+ return new QueueImpl(queue, takers, shutdownHook, shutdownFlag, strategy);
436
+ };
437
+ /** @internal */
438
+ const make$2 = (queue, strategy) => Effect.pipe(Effect.deferredMake(), Effect.map(deferred => unsafeMake(queue, Effect.unbounded(), deferred, Effect.make(false), strategy)));
439
+ /** @internal */
440
+ class BackingQueueFromMutableQueue {
441
+ mutable;
442
+ [BackingQueueTypeId] = backingQueueVariance;
443
+ constructor(mutable) {
444
+ this.mutable = mutable;
445
+ }
446
+ poll(def) {
447
+ return Effect.poll(this.mutable, def);
448
+ }
449
+ pollUpTo(limit) {
450
+ return Effect.pollUpTo(this.mutable, limit);
451
+ }
452
+ offerAll(elements) {
453
+ return Effect.offerAll(this.mutable, elements);
454
+ }
455
+ offer(element) {
456
+ return Effect.offer(this.mutable, element);
457
+ }
458
+ capacity() {
459
+ return Effect.capacity(this.mutable);
460
+ }
461
+ length() {
462
+ return Effect.length(this.mutable);
463
+ }
464
+ }
465
+ /** @internal */
466
+ const backingQueueFromMutableQueue = mutable => new BackingQueueFromMutableQueue(mutable);
467
+ /** @internal */
468
+ const size$1 = self => self.size;
469
+ /** @internal */
470
+ const isShutdown$1 = self => self.isShutdown;
471
+ /** @internal */
472
+ const shutdown$1 = self => self.shutdown;
473
+ /** @internal */
474
+ const offer$1 = /*#__PURE__*/Effect.dual(2, (self, value) => self.offer(value));
475
+ /** @internal */
476
+ const take$1 = self => self.take;
477
+ /** @internal */
478
+ const takeUpTo = /*#__PURE__*/Effect.dual(2, (self, max) => self.takeUpTo(max));
479
+ /** @internal */
480
+ const takeBetween$1 = /*#__PURE__*/Effect.dual(3, (self, min, max) => self.takeBetween(min, max));
481
+ // -----------------------------------------------------------------------------
482
+ // Strategy
483
+ // -----------------------------------------------------------------------------
484
+ /** @internal */
485
+ const backPressureStrategy = () => new BackPressureStrategy();
486
+ /** @internal */
487
+ const droppingStrategy = () => new DroppingStrategy();
488
+ /** @internal */
489
+ class BackPressureStrategy {
490
+ [QueueStrategyTypeId] = queueStrategyVariance;
491
+ putters = /*#__PURE__*/Effect.unbounded();
492
+ surplusSize() {
493
+ return Effect.length(this.putters);
494
+ }
495
+ onCompleteTakersWithEmptyQueue(takers) {
496
+ while (!Effect.isEmpty$1(this.putters) && !Effect.isEmpty$1(takers)) {
497
+ const taker = Effect.poll(takers, void 0);
498
+ const putter = Effect.poll(this.putters, void 0);
499
+ if (putter[2]) {
500
+ unsafeCompleteDeferred(putter[1], true);
501
+ }
502
+ unsafeCompleteDeferred(taker, putter[0]);
503
+ }
504
+ }
505
+ get shutdown() {
506
+ return Effect.pipe(Effect.fiberId, Effect.flatMap(fiberId => Effect.pipe(Effect.sync(() => unsafePollAll(this.putters)), Effect.flatMap(putters => Effect.forEachConcurrentDiscard(putters, ([_, deferred, isLastItem]) => isLastItem ? Effect.pipe(Effect.deferredInterruptWith(deferred, fiberId), Effect.asVoid) : Effect.void_, false, false)))));
507
+ }
508
+ handleSurplus(iterable, queue, takers, isShutdown) {
509
+ return Effect.withFiberRuntime(state => {
510
+ const deferred = Effect.deferredUnsafeMake(state.id());
511
+ return Effect.pipe(Effect.suspend(() => {
512
+ this.unsafeOffer(iterable, deferred);
513
+ this.unsafeOnQueueEmptySpace(queue, takers);
514
+ unsafeCompleteTakers(this, queue, takers);
515
+ return Effect.get$2(isShutdown) ? Effect.interrupt$2 : Effect.deferredAwait(deferred);
516
+ }), Effect.onInterrupt(() => Effect.sync(() => this.unsafeRemove(deferred))));
517
+ });
518
+ }
519
+ unsafeOnQueueEmptySpace(queue, takers) {
520
+ let keepPolling = true;
521
+ while (keepPolling && (queue.capacity() === Number.POSITIVE_INFINITY || queue.length() < queue.capacity())) {
522
+ const putter = Effect.pipe(this.putters, Effect.poll(Effect.EmptyMutableQueue));
523
+ if (putter === Effect.EmptyMutableQueue) {
524
+ keepPolling = false;
525
+ } else {
526
+ const offered = queue.offer(putter[0]);
527
+ if (offered && putter[2]) {
528
+ unsafeCompleteDeferred(putter[1], true);
529
+ } else if (!offered) {
530
+ unsafeOfferAll(this.putters, Effect.pipe(unsafePollAll(this.putters), Effect.prepend(putter)));
531
+ }
532
+ unsafeCompleteTakers(this, queue, takers);
533
+ }
534
+ }
535
+ }
536
+ unsafeOffer(iterable, deferred) {
537
+ const stuff = Effect.fromIterable(iterable);
538
+ for (let i = 0; i < stuff.length; i++) {
539
+ const value = stuff[i];
540
+ if (i === stuff.length - 1) {
541
+ Effect.pipe(this.putters, Effect.offer([value, deferred, true]));
542
+ } else {
543
+ Effect.pipe(this.putters, Effect.offer([value, deferred, false]));
544
+ }
545
+ }
546
+ }
547
+ unsafeRemove(deferred) {
548
+ unsafeOfferAll(this.putters, Effect.pipe(unsafePollAll(this.putters), Effect.filter(([, _]) => _ !== deferred)));
549
+ }
550
+ }
551
+ /** @internal */
552
+ class DroppingStrategy {
553
+ [QueueStrategyTypeId] = queueStrategyVariance;
554
+ surplusSize() {
555
+ return 0;
556
+ }
557
+ get shutdown() {
558
+ return Effect.void_;
559
+ }
560
+ onCompleteTakersWithEmptyQueue() {}
561
+ handleSurplus(_iterable, _queue, _takers, _isShutdown) {
562
+ return Effect.succeed$1(false);
563
+ }
564
+ unsafeOnQueueEmptySpace(_queue, _takers) {
565
+ //
566
+ }
567
+ }
568
+ /** @internal */
569
+ const unsafeCompleteDeferred = (deferred, a) => {
570
+ return Effect.deferredUnsafeDone(deferred, Effect.succeed$1(a));
571
+ };
572
+ /** @internal */
573
+ const unsafeOfferAll = (queue, as) => {
574
+ return Effect.pipe(queue, Effect.offerAll(as));
575
+ };
576
+ /** @internal */
577
+ const unsafePollAll = queue => {
578
+ return Effect.pipe(queue, Effect.pollUpTo(Number.POSITIVE_INFINITY));
579
+ };
580
+ /** @internal */
581
+ const unsafePollN = (queue, max) => {
582
+ return Effect.pipe(queue, Effect.pollUpTo(max));
583
+ };
584
+ /** @internal */
585
+ const unsafeRemove = (queue, a) => {
586
+ unsafeOfferAll(queue, Effect.pipe(unsafePollAll(queue), Effect.filter(b => a !== b)));
587
+ };
588
+ /** @internal */
589
+ const unsafeCompleteTakers = (strategy, queue, takers) => {
590
+ // Check both a taker and an item are in the queue, starting with the taker
591
+ let keepPolling = true;
592
+ while (keepPolling && queue.length() !== 0) {
593
+ const taker = Effect.pipe(takers, Effect.poll(Effect.EmptyMutableQueue));
594
+ if (taker !== Effect.EmptyMutableQueue) {
595
+ const element = queue.poll(Effect.EmptyMutableQueue);
596
+ if (element !== Effect.EmptyMutableQueue) {
597
+ unsafeCompleteDeferred(taker, element);
598
+ strategy.unsafeOnQueueEmptySpace(queue, takers);
599
+ } else {
600
+ unsafeOfferAll(takers, Effect.pipe(unsafePollAll(takers), Effect.prepend(taker)));
601
+ }
602
+ keepPolling = true;
603
+ } else {
604
+ keepPolling = false;
605
+ }
606
+ }
607
+ if (keepPolling && queue.length() === 0 && !Effect.isEmpty$1(takers)) {
608
+ strategy.onCompleteTakersWithEmptyQueue(takers);
609
+ }
610
+ };
611
+
612
+ /**
613
+ * Makes a new bounded `Queue`. When the capacity of the queue is reached, any
614
+ * additional calls to `offer` will be suspended until there is more room in
615
+ * the queue.
616
+ *
617
+ * **Note**: When possible use only power of 2 capacities; this will provide
618
+ * better performance by utilising an optimised version of the underlying
619
+ * `RingBuffer`.
620
+ *
621
+ * @since 2.0.0
622
+ * @category constructors
623
+ */
624
+ const bounded = bounded$1;
625
+ /**
626
+ * Creates a new unbounded `Queue`.
627
+ *
628
+ * @since 2.0.0
629
+ * @category constructors
630
+ */
631
+ const unbounded = unbounded$1;
632
+ /**
633
+ * Retrieves the size of the queue, which is equal to the number of elements
634
+ * in the queue. This may be negative if fibers are suspended waiting for
635
+ * elements to be added to the queue.
636
+ *
637
+ * @since 2.0.0
638
+ * @category getters
639
+ */
640
+ const size = size$1;
641
+ /**
642
+ * Returns `true` if `shutdown` has been called, otherwise returns `false`.
643
+ *
644
+ * @since 2.0.0
645
+ * @category getters
646
+ */
647
+ const isShutdown = isShutdown$1;
648
+ /**
649
+ * Interrupts any fibers that are suspended on `offer` or `take`. Future calls
650
+ * to `offer*` and `take*` will be interrupted immediately.
651
+ *
652
+ * @since 2.0.0
653
+ * @category utils
654
+ */
655
+ const shutdown = shutdown$1;
656
+ /**
657
+ * Places one value in the queue.
658
+ *
659
+ * @since 2.0.0
660
+ * @category utils
661
+ */
662
+ const offer = offer$1;
663
+ /**
664
+ * Takes the oldest value in the queue. If the queue is empty, this will return
665
+ * a computation that resumes when an item has been added to the queue.
666
+ *
667
+ * @since 2.0.0
668
+ * @category utils
669
+ */
670
+ const take = take$1;
671
+ /**
672
+ * Takes a number of elements from the queue between the specified minimum and
673
+ * maximum. If there are fewer than the minimum number of elements available,
674
+ * suspends until at least the minimum number of elements have been collected.
675
+ *
676
+ * @since 2.0.0
677
+ * @category utils
678
+ */
679
+ const takeBetween = takeBetween$1;
680
+
681
+ /** @internal */
682
+ const OP_CONTINUE = "Continue";
683
+ /** @internal */
684
+ const OP_CLOSE = "Close";
685
+ /** @internal */
686
+ const OP_YIELD = "Yield";
687
+
688
+ /** @internal */
689
+ const ChildExecutorDecisionSymbolKey = "effect/ChannelChildExecutorDecision";
690
+ /** @internal */
691
+ const ChildExecutorDecisionTypeId = /*#__PURE__*/Symbol.for(ChildExecutorDecisionSymbolKey);
692
+ /** @internal */
693
+ const proto$7 = {
694
+ [ChildExecutorDecisionTypeId]: ChildExecutorDecisionTypeId
695
+ };
696
+ /** @internal */
697
+ const Continue = _ => {
698
+ const op = Object.create(proto$7);
699
+ op._tag = OP_CONTINUE;
700
+ return op;
701
+ };
702
+
703
+ /** @internal */
704
+ const OP_CONTINUATION_K = "ContinuationK";
705
+ /** @internal */
706
+ const OP_CONTINUATION_FINALIZER = "ContinuationFinalizer";
707
+
708
+ /** @internal */
709
+ const ContinuationTypeId = /*#__PURE__*/Symbol.for("effect/ChannelContinuation");
710
+ const continuationVariance = {
711
+ /* c8 ignore next */
712
+ _Env: _ => _,
713
+ /* c8 ignore next */
714
+ _InErr: _ => _,
715
+ /* c8 ignore next */
716
+ _InElem: _ => _,
717
+ /* c8 ignore next */
718
+ _InDone: _ => _,
719
+ /* c8 ignore next */
720
+ _OutErr: _ => _,
721
+ /* c8 ignore next */
722
+ _OutDone: _ => _,
723
+ /* c8 ignore next */
724
+ _OutErr2: _ => _,
725
+ /* c8 ignore next */
726
+ _OutElem: _ => _,
727
+ /* c8 ignore next */
728
+ _OutDone2: _ => _
729
+ };
730
+ /** @internal */
731
+ class ContinuationKImpl {
732
+ onSuccess;
733
+ onHalt;
734
+ _tag = OP_CONTINUATION_K;
735
+ [ContinuationTypeId] = continuationVariance;
736
+ constructor(onSuccess, onHalt) {
737
+ this.onSuccess = onSuccess;
738
+ this.onHalt = onHalt;
739
+ }
740
+ onExit(exit) {
741
+ return Effect.isFailure(exit) ? this.onHalt(exit.cause) : this.onSuccess(exit.value);
742
+ }
743
+ }
744
+ /** @internal */
745
+ class ContinuationFinalizerImpl {
746
+ finalizer;
747
+ _tag = OP_CONTINUATION_FINALIZER;
748
+ [ContinuationTypeId] = continuationVariance;
749
+ constructor(finalizer) {
750
+ this.finalizer = finalizer;
751
+ }
752
+ }
753
+
754
+ /** @internal */
755
+ const OP_PULL_AFTER_NEXT = "PullAfterNext";
756
+ /** @internal */
757
+ const OP_PULL_AFTER_ALL_ENQUEUED = "PullAfterAllEnqueued";
758
+
759
+ /** @internal */
760
+ const UpstreamPullStrategySymbolKey = "effect/ChannelUpstreamPullStrategy";
761
+ /** @internal */
762
+ const UpstreamPullStrategyTypeId = /*#__PURE__*/Symbol.for(UpstreamPullStrategySymbolKey);
763
+ const upstreamPullStrategyVariance = {
764
+ /* c8 ignore next */
765
+ _A: _ => _
766
+ };
767
+ /** @internal */
768
+ const proto$6 = {
769
+ [UpstreamPullStrategyTypeId]: upstreamPullStrategyVariance
770
+ };
771
+ /** @internal */
772
+ const PullAfterNext = emitSeparator => {
773
+ const op = Object.create(proto$6);
774
+ op._tag = OP_PULL_AFTER_NEXT;
775
+ op.emitSeparator = emitSeparator;
776
+ return op;
777
+ };
778
+
779
+ /** @internal */
780
+ const OP_BRACKET_OUT = "BracketOut";
781
+ /** @internal */
782
+ const OP_BRIDGE = "Bridge";
783
+ /** @internal */
784
+ const OP_CONCAT_ALL = "ConcatAll";
785
+ /** @internal */
786
+ const OP_EMIT$2 = "Emit";
787
+ /** @internal */
788
+ const OP_ENSURING = "Ensuring";
789
+ /** @internal */
790
+ const OP_FAIL = "Fail";
791
+ /** @internal */
792
+ const OP_FOLD = "Fold";
793
+ /** @internal */
794
+ const OP_FROM_EFFECT$1 = "FromEffect";
795
+ /** @internal */
796
+ const OP_PIPE_TO = "PipeTo";
797
+ /** @internal */
798
+ const OP_PROVIDE = "Provide";
799
+ /** @internal */
800
+ const OP_READ$1 = "Read";
801
+ /** @internal */
802
+ const OP_SUCCEED = "Succeed";
803
+ /** @internal */
804
+ const OP_SUCCEED_NOW = "SucceedNow";
805
+ /** @internal */
806
+ const OP_SUSPEND = "Suspend";
807
+
808
+ /** @internal */
809
+ const ChannelSymbolKey = "effect/Channel";
810
+ /** @internal */
811
+ const ChannelTypeId = /*#__PURE__*/Symbol.for(ChannelSymbolKey);
812
+ const channelVariance = {
813
+ /* c8 ignore next */
814
+ _Env: _ => _,
815
+ /* c8 ignore next */
816
+ _InErr: _ => _,
817
+ /* c8 ignore next */
818
+ _InElem: _ => _,
819
+ /* c8 ignore next */
820
+ _InDone: _ => _,
821
+ /* c8 ignore next */
822
+ _OutErr: _ => _,
823
+ /* c8 ignore next */
824
+ _OutElem: _ => _,
825
+ /* c8 ignore next */
826
+ _OutDone: _ => _
827
+ };
828
+ /** @internal */
829
+ const proto$5 = {
830
+ [ChannelTypeId]: channelVariance,
831
+ pipe() {
832
+ return Effect.pipeArguments(this, arguments);
833
+ }
834
+ };
835
+ /** @internal */
836
+ const isChannel = u => Effect.hasProperty(u, ChannelTypeId) || Effect.isEffect(u);
837
+ /** @internal */
838
+ const acquireReleaseOut = /*#__PURE__*/Effect.dual(2, (self, release) => {
839
+ const op = Object.create(proto$5);
840
+ op._tag = OP_BRACKET_OUT;
841
+ op.acquire = () => self;
842
+ op.finalizer = release;
843
+ return op;
844
+ });
845
+ /** @internal */
846
+ const concatAllWith = (channels, f, g) => {
847
+ const op = Object.create(proto$5);
848
+ op._tag = OP_CONCAT_ALL;
849
+ op.combineInners = f;
850
+ op.combineAll = g;
851
+ op.onPull = () => PullAfterNext(Effect.none());
852
+ op.onEmit = () => Continue;
853
+ op.value = () => channels;
854
+ op.k = Effect.identity;
855
+ return op;
856
+ };
857
+ /** @internal */
858
+ const concatMapWith = /*#__PURE__*/Effect.dual(4, (self, f, g, h) => {
859
+ const op = Object.create(proto$5);
860
+ op._tag = OP_CONCAT_ALL;
861
+ op.combineInners = g;
862
+ op.combineAll = h;
863
+ op.onPull = () => PullAfterNext(Effect.none());
864
+ op.onEmit = () => Continue;
865
+ op.value = () => self;
866
+ op.k = f;
867
+ return op;
868
+ });
869
+ /** @internal */
870
+ const embedInput = /*#__PURE__*/Effect.dual(2, (self, input) => {
871
+ const op = Object.create(proto$5);
872
+ op._tag = OP_BRIDGE;
873
+ op.input = input;
874
+ op.channel = self;
875
+ return op;
876
+ });
877
+ /** @internal */
878
+ const ensuringWith = /*#__PURE__*/Effect.dual(2, (self, finalizer) => {
879
+ const op = Object.create(proto$5);
880
+ op._tag = OP_ENSURING;
881
+ op.channel = self;
882
+ op.finalizer = finalizer;
883
+ return op;
884
+ });
885
+ /** @internal */
886
+ const fail = error => failCause$2(fail$1(error));
887
+ /** @internal */
888
+ const failCause$2 = cause => failCauseSync(() => cause);
889
+ /** @internal */
890
+ const failCauseSync = evaluate => {
891
+ const op = Object.create(proto$5);
892
+ op._tag = OP_FAIL;
893
+ op.error = evaluate;
894
+ return op;
895
+ };
896
+ /** @internal */
897
+ const flatMap$1 = /*#__PURE__*/Effect.dual(2, (self, f) => {
898
+ const op = Object.create(proto$5);
899
+ op._tag = OP_FOLD;
900
+ op.channel = self;
901
+ op.k = new ContinuationKImpl(f, failCause$2);
902
+ return op;
903
+ });
904
+ /** @internal */
905
+ const fromEffect$3 = effect => {
906
+ const op = Object.create(proto$5);
907
+ op._tag = OP_FROM_EFFECT$1;
908
+ op.effect = () => effect;
909
+ return op;
910
+ };
911
+ /** @internal */
912
+ const pipeTo = /*#__PURE__*/Effect.dual(2, (self, that) => {
913
+ const op = Object.create(proto$5);
914
+ op._tag = OP_PIPE_TO;
915
+ op.left = () => self;
916
+ op.right = () => that;
917
+ return op;
918
+ });
919
+ /** @internal */
920
+ const readWith = options => readWithCause({
921
+ onInput: options.onInput,
922
+ onFailure: cause => Effect.match$1(failureOrCause(cause), {
923
+ onLeft: options.onFailure,
924
+ onRight: failCause$2
925
+ }),
926
+ onDone: options.onDone
927
+ });
928
+ /** @internal */
929
+ const readWithCause = options => {
930
+ const op = Object.create(proto$5);
931
+ op._tag = OP_READ$1;
932
+ op.more = options.onInput;
933
+ op.done = new ContinuationKImpl(options.onDone, options.onFailure);
934
+ return op;
935
+ };
936
+ /** @internal */
937
+ const succeed = value => sync(() => value);
938
+ /** @internal */
939
+ const succeedNow = result => {
940
+ const op = Object.create(proto$5);
941
+ op._tag = OP_SUCCEED_NOW;
942
+ op.terminal = result;
943
+ return op;
944
+ };
945
+ /** @internal */
946
+ const suspend$1 = evaluate => {
947
+ const op = Object.create(proto$5);
948
+ op._tag = OP_SUSPEND;
949
+ op.channel = evaluate;
950
+ return op;
951
+ };
952
+ const sync = evaluate => {
953
+ const op = Object.create(proto$5);
954
+ op._tag = OP_SUCCEED;
955
+ op.evaluate = evaluate;
956
+ return op;
957
+ };
958
+ const void_ = /*#__PURE__*/succeedNow(void 0);
959
+ /** @internal */
960
+ const write = out => {
961
+ const op = Object.create(proto$5);
962
+ op._tag = OP_EMIT$2;
963
+ op.out = out;
964
+ return op;
965
+ };
966
+
967
+ /** @internal */
968
+ const OP_DONE$1 = "Done";
969
+ /** @internal */
970
+ const OP_EMIT$1 = "Emit";
971
+ /** @internal */
972
+ const OP_FROM_EFFECT = "FromEffect";
973
+ /** @internal */
974
+ const OP_READ = "Read";
975
+
976
+ /** @internal */
977
+ const ChannelStateTypeId = /*#__PURE__*/Symbol.for("effect/ChannelState");
978
+ const channelStateVariance = {
979
+ /* c8 ignore next */
980
+ _E: _ => _,
981
+ /* c8 ignore next */
982
+ _R: _ => _
983
+ };
984
+ /** @internal */
985
+ const proto$4 = {
986
+ [ChannelStateTypeId]: channelStateVariance
987
+ };
988
+ /** @internal */
989
+ const Done = () => {
990
+ const op = Object.create(proto$4);
991
+ op._tag = OP_DONE$1;
992
+ return op;
993
+ };
994
+ /** @internal */
995
+ const Emit$1 = () => {
996
+ const op = Object.create(proto$4);
997
+ op._tag = OP_EMIT$1;
998
+ return op;
999
+ };
1000
+ /** @internal */
1001
+ const fromEffect$2 = effect => {
1002
+ const op = Object.create(proto$4);
1003
+ op._tag = OP_FROM_EFFECT;
1004
+ op.effect = effect;
1005
+ return op;
1006
+ };
1007
+ /** @internal */
1008
+ const Read = (upstream, onEffect, onEmit, onDone) => {
1009
+ const op = Object.create(proto$4);
1010
+ op._tag = OP_READ;
1011
+ op.upstream = upstream;
1012
+ op.onEffect = onEffect;
1013
+ op.onEmit = onEmit;
1014
+ op.onDone = onDone;
1015
+ return op;
1016
+ };
1017
+ /** @internal */
1018
+ const isFromEffect = self => self._tag === OP_FROM_EFFECT;
1019
+ /** @internal */
1020
+ const effect = self => isFromEffect(self) ? self.effect : Effect._void;
1021
+ /** @internal */
1022
+ const effectOrUndefinedIgnored = self => isFromEffect(self) ? Effect.ignore(self.effect) : undefined;
1023
+
1024
+ /** @internal */
1025
+ const OP_PULL_FROM_CHILD = "PullFromChild";
1026
+ /** @internal */
1027
+ const OP_PULL_FROM_UPSTREAM = "PullFromUpstream";
1028
+ /** @internal */
1029
+ const OP_DRAIN_CHILD_EXECUTORS = "DrainChildExecutors";
1030
+ /** @internal */
1031
+ const OP_EMIT = "Emit";
1032
+ /**
1033
+ * Execute the `childExecutor` and on each emitted value, decide what to do by
1034
+ * `onEmit`.
1035
+ *
1036
+ * @internal
1037
+ */
1038
+ class PullFromChild {
1039
+ childExecutor;
1040
+ parentSubexecutor;
1041
+ onEmit;
1042
+ _tag = OP_PULL_FROM_CHILD;
1043
+ constructor(childExecutor, parentSubexecutor, onEmit) {
1044
+ this.childExecutor = childExecutor;
1045
+ this.parentSubexecutor = parentSubexecutor;
1046
+ this.onEmit = onEmit;
1047
+ }
1048
+ close(exit) {
1049
+ const fin1 = this.childExecutor.close(exit);
1050
+ const fin2 = this.parentSubexecutor.close(exit);
1051
+ if (fin1 !== undefined && fin2 !== undefined) {
1052
+ return Effect.zipWith(Effect.exit$1(fin1), Effect.exit$1(fin2), (exit1, exit2) => Effect.pipe(exit1, Effect.zipRight$1(exit2)));
1053
+ } else if (fin1 !== undefined) {
1054
+ return fin1;
1055
+ } else if (fin2 !== undefined) {
1056
+ return fin2;
1057
+ } else {
1058
+ return undefined;
1059
+ }
1060
+ }
1061
+ enqueuePullFromChild(_child) {
1062
+ return this;
1063
+ }
1064
+ }
1065
+ /**
1066
+ * Execute `upstreamExecutor` and for each emitted element, spawn a child
1067
+ * channel and continue with processing it by `PullFromChild`.
1068
+ *
1069
+ * @internal
1070
+ */
1071
+ class PullFromUpstream {
1072
+ upstreamExecutor;
1073
+ createChild;
1074
+ lastDone;
1075
+ activeChildExecutors;
1076
+ combineChildResults;
1077
+ combineWithChildResult;
1078
+ onPull;
1079
+ onEmit;
1080
+ _tag = OP_PULL_FROM_UPSTREAM;
1081
+ constructor(upstreamExecutor, createChild, lastDone, activeChildExecutors, combineChildResults, combineWithChildResult, onPull, onEmit) {
1082
+ this.upstreamExecutor = upstreamExecutor;
1083
+ this.createChild = createChild;
1084
+ this.lastDone = lastDone;
1085
+ this.activeChildExecutors = activeChildExecutors;
1086
+ this.combineChildResults = combineChildResults;
1087
+ this.combineWithChildResult = combineWithChildResult;
1088
+ this.onPull = onPull;
1089
+ this.onEmit = onEmit;
1090
+ }
1091
+ close(exit) {
1092
+ const fin1 = this.upstreamExecutor.close(exit);
1093
+ const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit) : undefined), fin1];
1094
+ const result = fins.reduce((acc, next) => {
1095
+ if (acc !== undefined && next !== undefined) {
1096
+ return Effect.zipWith(acc, Effect.exit$1(next), (exit1, exit2) => Effect.zipRight$1(exit1, exit2));
1097
+ } else if (acc !== undefined) {
1098
+ return acc;
1099
+ } else if (next !== undefined) {
1100
+ return Effect.exit$1(next);
1101
+ } else {
1102
+ return undefined;
1103
+ }
1104
+ }, undefined);
1105
+ return result === undefined ? result : result;
1106
+ }
1107
+ enqueuePullFromChild(child) {
1108
+ return new PullFromUpstream(this.upstreamExecutor, this.createChild, this.lastDone, [...this.activeChildExecutors, child], this.combineChildResults, this.combineWithChildResult, this.onPull, this.onEmit);
1109
+ }
1110
+ }
1111
+ /**
1112
+ * Transformed from `PullFromUpstream` when upstream has finished but there
1113
+ * are still active child executors.
1114
+ *
1115
+ * @internal
1116
+ */
1117
+ class DrainChildExecutors {
1118
+ upstreamExecutor;
1119
+ lastDone;
1120
+ activeChildExecutors;
1121
+ upstreamDone;
1122
+ combineChildResults;
1123
+ combineWithChildResult;
1124
+ onPull;
1125
+ _tag = OP_DRAIN_CHILD_EXECUTORS;
1126
+ constructor(upstreamExecutor, lastDone, activeChildExecutors, upstreamDone, combineChildResults, combineWithChildResult, onPull) {
1127
+ this.upstreamExecutor = upstreamExecutor;
1128
+ this.lastDone = lastDone;
1129
+ this.activeChildExecutors = activeChildExecutors;
1130
+ this.upstreamDone = upstreamDone;
1131
+ this.combineChildResults = combineChildResults;
1132
+ this.combineWithChildResult = combineWithChildResult;
1133
+ this.onPull = onPull;
1134
+ }
1135
+ close(exit) {
1136
+ const fin1 = this.upstreamExecutor.close(exit);
1137
+ const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit) : undefined), fin1];
1138
+ const result = fins.reduce((acc, next) => {
1139
+ if (acc !== undefined && next !== undefined) {
1140
+ return Effect.zipWith(acc, Effect.exit$1(next), (exit1, exit2) => Effect.zipRight$1(exit1, exit2));
1141
+ } else if (acc !== undefined) {
1142
+ return acc;
1143
+ } else if (next !== undefined) {
1144
+ return Effect.exit$1(next);
1145
+ } else {
1146
+ return undefined;
1147
+ }
1148
+ }, undefined);
1149
+ return result === undefined ? result : result;
1150
+ }
1151
+ enqueuePullFromChild(child) {
1152
+ return new DrainChildExecutors(this.upstreamExecutor, this.lastDone, [...this.activeChildExecutors, child], this.upstreamDone, this.combineChildResults, this.combineWithChildResult, this.onPull);
1153
+ }
1154
+ }
1155
+ /** @internal */
1156
+ class Emit {
1157
+ value;
1158
+ next;
1159
+ _tag = OP_EMIT;
1160
+ constructor(value, next) {
1161
+ this.value = value;
1162
+ this.next = next;
1163
+ }
1164
+ close(exit) {
1165
+ const result = this.next.close(exit);
1166
+ return result === undefined ? result : result;
1167
+ }
1168
+ enqueuePullFromChild(_child) {
1169
+ return this;
1170
+ }
1171
+ }
1172
+
1173
+ /** @internal */
1174
+ const OP_PULLED = "Pulled";
1175
+ /** @internal */
1176
+ const OP_NO_UPSTREAM = "NoUpstream";
1177
+
1178
+ /** @internal */
1179
+ const UpstreamPullRequestSymbolKey = "effect/ChannelUpstreamPullRequest";
1180
+ /** @internal */
1181
+ const UpstreamPullRequestTypeId = /*#__PURE__*/Symbol.for(UpstreamPullRequestSymbolKey);
1182
+ const upstreamPullRequestVariance = {
1183
+ /* c8 ignore next */
1184
+ _A: _ => _
1185
+ };
1186
+ /** @internal */
1187
+ const proto$3 = {
1188
+ [UpstreamPullRequestTypeId]: upstreamPullRequestVariance
1189
+ };
1190
+ /** @internal */
1191
+ const Pulled = value => {
1192
+ const op = Object.create(proto$3);
1193
+ op._tag = OP_PULLED;
1194
+ op.value = value;
1195
+ return op;
1196
+ };
1197
+ /** @internal */
1198
+ const NoUpstream = activeDownstreamCount => {
1199
+ const op = Object.create(proto$3);
1200
+ op._tag = OP_NO_UPSTREAM;
1201
+ op.activeDownstreamCount = activeDownstreamCount;
1202
+ return op;
1203
+ };
1204
+
1205
+ /** @internal */
1206
+ class ChannelExecutor {
1207
+ _activeSubexecutor = undefined;
1208
+ _cancelled = undefined;
1209
+ _closeLastSubstream = undefined;
1210
+ _currentChannel;
1211
+ _done = undefined;
1212
+ _doneStack = [];
1213
+ _emitted = undefined;
1214
+ _executeCloseLastSubstream;
1215
+ _input = undefined;
1216
+ _inProgressFinalizer = undefined;
1217
+ _providedEnv;
1218
+ constructor(initialChannel, providedEnv, executeCloseLastSubstream) {
1219
+ this._currentChannel = initialChannel;
1220
+ this._executeCloseLastSubstream = executeCloseLastSubstream;
1221
+ this._providedEnv = providedEnv;
1222
+ }
1223
+ run() {
1224
+ let result = undefined;
1225
+ while (result === undefined) {
1226
+ if (this._cancelled !== undefined) {
1227
+ result = this.processCancellation();
1228
+ } else if (this._activeSubexecutor !== undefined) {
1229
+ result = this.runSubexecutor();
1230
+ } else {
1231
+ try {
1232
+ if (this._currentChannel === undefined) {
1233
+ result = Done();
1234
+ } else {
1235
+ if (Effect.isEffect(this._currentChannel)) {
1236
+ this._currentChannel = fromEffect$3(this._currentChannel);
1237
+ }
1238
+ switch (this._currentChannel._tag) {
1239
+ case OP_BRACKET_OUT:
1240
+ {
1241
+ result = this.runBracketOut(this._currentChannel);
1242
+ break;
1243
+ }
1244
+ case OP_BRIDGE:
1245
+ {
1246
+ const bridgeInput = this._currentChannel.input;
1247
+ // PipeTo(left, Bridge(queue, channel))
1248
+ // In a fiber: repeatedly run left and push its outputs to the queue
1249
+ // Add a finalizer to interrupt the fiber and close the executor
1250
+ this._currentChannel = this._currentChannel.channel;
1251
+ if (this._input !== undefined) {
1252
+ const inputExecutor = this._input;
1253
+ this._input = undefined;
1254
+ const drainer = () => Effect.flatMap$1(bridgeInput.awaitRead(), () => Effect.suspend$1(() => {
1255
+ const state = inputExecutor.run();
1256
+ switch (state._tag) {
1257
+ case OP_DONE$1:
1258
+ {
1259
+ return Effect.match$2(inputExecutor.getDone(), {
1260
+ onFailure: cause => bridgeInput.error(cause),
1261
+ onSuccess: value => bridgeInput.done(value)
1262
+ });
1263
+ }
1264
+ case OP_EMIT$1:
1265
+ {
1266
+ return Effect.flatMap$1(bridgeInput.emit(inputExecutor.getEmit()), () => drainer());
1267
+ }
1268
+ case OP_FROM_EFFECT:
1269
+ {
1270
+ return Effect.matchCauseEffect(state.effect, {
1271
+ onFailure: cause => bridgeInput.error(cause),
1272
+ onSuccess: () => drainer()
1273
+ });
1274
+ }
1275
+ case OP_READ:
1276
+ {
1277
+ return readUpstream(state, () => drainer(), cause => bridgeInput.error(cause));
1278
+ }
1279
+ }
1280
+ }));
1281
+ result = fromEffect$2(Effect.flatMap$1(Effect.forkDaemon(Effect.interruptible(drainer())), fiber => Effect.sync$1(() => this.addFinalizer(exit => Effect.flatMap$1(interrupt(fiber), () => Effect.suspend$1(() => {
1282
+ const effect = this.restorePipe(exit, inputExecutor);
1283
+ return effect !== undefined ? effect : Effect._void;
1284
+ }))))));
1285
+ }
1286
+ break;
1287
+ }
1288
+ case OP_CONCAT_ALL:
1289
+ {
1290
+ const executor = new ChannelExecutor(this._currentChannel.value(), this._providedEnv, effect => Effect.sync$1(() => {
1291
+ const prevLastClose = this._closeLastSubstream === undefined ? Effect._void : this._closeLastSubstream;
1292
+ this._closeLastSubstream = Effect.pipe(prevLastClose, Effect.zipRight$2(effect));
1293
+ }));
1294
+ executor._input = this._input;
1295
+ const channel = this._currentChannel;
1296
+ this._activeSubexecutor = new PullFromUpstream(executor, value => channel.k(value), undefined, [], (x, y) => channel.combineInners(x, y), (x, y) => channel.combineAll(x, y), request => channel.onPull(request), value => channel.onEmit(value));
1297
+ this._closeLastSubstream = undefined;
1298
+ this._currentChannel = undefined;
1299
+ break;
1300
+ }
1301
+ case OP_EMIT$2:
1302
+ {
1303
+ this._emitted = this._currentChannel.out;
1304
+ this._currentChannel = this._activeSubexecutor !== undefined ? undefined : void_;
1305
+ result = Emit$1();
1306
+ break;
1307
+ }
1308
+ case OP_ENSURING:
1309
+ {
1310
+ this.runEnsuring(this._currentChannel);
1311
+ break;
1312
+ }
1313
+ case OP_FAIL:
1314
+ {
1315
+ result = this.doneHalt(this._currentChannel.error());
1316
+ break;
1317
+ }
1318
+ case OP_FOLD:
1319
+ {
1320
+ this._doneStack.push(this._currentChannel.k);
1321
+ this._currentChannel = this._currentChannel.channel;
1322
+ break;
1323
+ }
1324
+ case OP_FROM_EFFECT$1:
1325
+ {
1326
+ const effect = this._providedEnv === undefined ? this._currentChannel.effect() : Effect.pipe(this._currentChannel.effect(), Effect.provide(this._providedEnv));
1327
+ result = fromEffect$2(Effect.matchCauseEffect(effect, {
1328
+ onFailure: cause => {
1329
+ const state = this.doneHalt(cause);
1330
+ return state !== undefined && isFromEffect(state) ? state.effect : Effect._void;
1331
+ },
1332
+ onSuccess: value => {
1333
+ const state = this.doneSucceed(value);
1334
+ return state !== undefined && isFromEffect(state) ? state.effect : Effect._void;
1335
+ }
1336
+ }));
1337
+ break;
1338
+ }
1339
+ case OP_PIPE_TO:
1340
+ {
1341
+ const previousInput = this._input;
1342
+ const leftExec = new ChannelExecutor(this._currentChannel.left(), this._providedEnv, effect => this._executeCloseLastSubstream(effect));
1343
+ leftExec._input = previousInput;
1344
+ this._input = leftExec;
1345
+ this.addFinalizer(exit => {
1346
+ const effect = this.restorePipe(exit, previousInput);
1347
+ return effect !== undefined ? effect : Effect._void;
1348
+ });
1349
+ this._currentChannel = this._currentChannel.right();
1350
+ break;
1351
+ }
1352
+ case OP_PROVIDE:
1353
+ {
1354
+ const previousEnv = this._providedEnv;
1355
+ this._providedEnv = this._currentChannel.context();
1356
+ this._currentChannel = this._currentChannel.inner;
1357
+ this.addFinalizer(() => Effect.sync$1(() => {
1358
+ this._providedEnv = previousEnv;
1359
+ }));
1360
+ break;
1361
+ }
1362
+ case OP_READ$1:
1363
+ {
1364
+ const read = this._currentChannel;
1365
+ result = Read(this._input, Effect.identity, emitted => {
1366
+ try {
1367
+ this._currentChannel = read.more(emitted);
1368
+ } catch (error) {
1369
+ this._currentChannel = read.done.onExit(Effect.die$1(error));
1370
+ }
1371
+ return undefined;
1372
+ }, exit => {
1373
+ const onExit = exit => {
1374
+ return read.done.onExit(exit);
1375
+ };
1376
+ this._currentChannel = onExit(exit);
1377
+ return undefined;
1378
+ });
1379
+ break;
1380
+ }
1381
+ case OP_SUCCEED:
1382
+ {
1383
+ result = this.doneSucceed(this._currentChannel.evaluate());
1384
+ break;
1385
+ }
1386
+ case OP_SUCCEED_NOW:
1387
+ {
1388
+ result = this.doneSucceed(this._currentChannel.terminal);
1389
+ break;
1390
+ }
1391
+ case OP_SUSPEND:
1392
+ {
1393
+ this._currentChannel = this._currentChannel.channel();
1394
+ break;
1395
+ }
1396
+ }
1397
+ }
1398
+ } catch (error) {
1399
+ this._currentChannel = failCause$2(die(error));
1400
+ }
1401
+ }
1402
+ }
1403
+ return result;
1404
+ }
1405
+ getDone() {
1406
+ return this._done;
1407
+ }
1408
+ getEmit() {
1409
+ return this._emitted;
1410
+ }
1411
+ cancelWith(exit) {
1412
+ this._cancelled = exit;
1413
+ }
1414
+ clearInProgressFinalizer() {
1415
+ this._inProgressFinalizer = undefined;
1416
+ }
1417
+ storeInProgressFinalizer(finalizer) {
1418
+ this._inProgressFinalizer = finalizer;
1419
+ }
1420
+ popAllFinalizers(exit) {
1421
+ const finalizers = [];
1422
+ let next = this._doneStack.pop();
1423
+ while (next) {
1424
+ if (next._tag === "ContinuationFinalizer") {
1425
+ finalizers.push(next.finalizer);
1426
+ }
1427
+ next = this._doneStack.pop();
1428
+ }
1429
+ const effect = finalizers.length === 0 ? Effect._void : runFinalizers(finalizers, exit);
1430
+ this.storeInProgressFinalizer(effect);
1431
+ return effect;
1432
+ }
1433
+ popNextFinalizers() {
1434
+ const builder = [];
1435
+ while (this._doneStack.length !== 0) {
1436
+ const cont = this._doneStack[this._doneStack.length - 1];
1437
+ if (cont._tag === OP_CONTINUATION_K) {
1438
+ return builder;
1439
+ }
1440
+ builder.push(cont);
1441
+ this._doneStack.pop();
1442
+ }
1443
+ return builder;
1444
+ }
1445
+ restorePipe(exit, prev) {
1446
+ const currInput = this._input;
1447
+ this._input = prev;
1448
+ if (currInput !== undefined) {
1449
+ const effect = currInput.close(exit);
1450
+ return effect;
1451
+ }
1452
+ return Effect._void;
1453
+ }
1454
+ close(exit) {
1455
+ let runInProgressFinalizers = undefined;
1456
+ const finalizer = this._inProgressFinalizer;
1457
+ if (finalizer !== undefined) {
1458
+ runInProgressFinalizers = Effect.pipe(finalizer, Effect.ensuring(Effect.sync$1(() => this.clearInProgressFinalizer())));
1459
+ }
1460
+ let closeSelf = undefined;
1461
+ const selfFinalizers = this.popAllFinalizers(exit);
1462
+ if (selfFinalizers !== undefined) {
1463
+ closeSelf = Effect.pipe(selfFinalizers, Effect.ensuring(Effect.sync$1(() => this.clearInProgressFinalizer())));
1464
+ }
1465
+ const closeSubexecutors = this._activeSubexecutor === undefined ? undefined : this._activeSubexecutor.close(exit);
1466
+ if (closeSubexecutors === undefined && runInProgressFinalizers === undefined && closeSelf === undefined) {
1467
+ return undefined;
1468
+ }
1469
+ return Effect.pipe(Effect.exit$1(ifNotNull(closeSubexecutors)), Effect.zip(Effect.exit$1(ifNotNull(runInProgressFinalizers))), Effect.zip(Effect.exit$1(ifNotNull(closeSelf))), Effect.map$2(([[exit1, exit2], exit3]) => Effect.pipe(exit1, Effect.zipRight$1(exit2), Effect.zipRight$1(exit3))), Effect.uninterruptible$1,
1470
+ // TODO: remove
1471
+ Effect.flatMap$1(exit => Effect.suspend$1(() => exit)));
1472
+ }
1473
+ doneSucceed(value) {
1474
+ if (this._doneStack.length === 0) {
1475
+ this._done = Effect.succeed$2(value);
1476
+ this._currentChannel = undefined;
1477
+ return Done();
1478
+ }
1479
+ const head = this._doneStack[this._doneStack.length - 1];
1480
+ if (head._tag === OP_CONTINUATION_K) {
1481
+ this._doneStack.pop();
1482
+ this._currentChannel = head.onSuccess(value);
1483
+ return undefined;
1484
+ }
1485
+ const finalizers = this.popNextFinalizers();
1486
+ if (this._doneStack.length === 0) {
1487
+ this._doneStack = finalizers.reverse();
1488
+ this._done = Effect.succeed$2(value);
1489
+ this._currentChannel = undefined;
1490
+ return Done();
1491
+ }
1492
+ const finalizerEffect = runFinalizers(finalizers.map(f => f.finalizer), Effect.succeed$2(value));
1493
+ this.storeInProgressFinalizer(finalizerEffect);
1494
+ const effect = Effect.pipe(finalizerEffect, Effect.ensuring(Effect.sync$1(() => this.clearInProgressFinalizer())), Effect.uninterruptible$1, Effect.flatMap$1(() => Effect.sync$1(() => this.doneSucceed(value))));
1495
+ return fromEffect$2(effect);
1496
+ }
1497
+ doneHalt(cause) {
1498
+ if (this._doneStack.length === 0) {
1499
+ this._done = Effect.failCause(cause);
1500
+ this._currentChannel = undefined;
1501
+ return Done();
1502
+ }
1503
+ const head = this._doneStack[this._doneStack.length - 1];
1504
+ if (head._tag === OP_CONTINUATION_K) {
1505
+ this._doneStack.pop();
1506
+ try {
1507
+ this._currentChannel = head.onHalt(cause);
1508
+ } catch (error) {
1509
+ this._currentChannel = failCause$2(die(error));
1510
+ }
1511
+ return undefined;
1512
+ }
1513
+ const finalizers = this.popNextFinalizers();
1514
+ if (this._doneStack.length === 0) {
1515
+ this._doneStack = finalizers.reverse();
1516
+ this._done = Effect.failCause(cause);
1517
+ this._currentChannel = undefined;
1518
+ return Done();
1519
+ }
1520
+ const finalizerEffect = runFinalizers(finalizers.map(f => f.finalizer), Effect.failCause(cause));
1521
+ this.storeInProgressFinalizer(finalizerEffect);
1522
+ const effect = Effect.pipe(finalizerEffect, Effect.ensuring(Effect.sync$1(() => this.clearInProgressFinalizer())), Effect.uninterruptible$1, Effect.flatMap$1(() => Effect.sync$1(() => this.doneHalt(cause))));
1523
+ return fromEffect$2(effect);
1524
+ }
1525
+ processCancellation() {
1526
+ this._currentChannel = undefined;
1527
+ this._done = this._cancelled;
1528
+ this._cancelled = undefined;
1529
+ return Done();
1530
+ }
1531
+ runBracketOut(bracketOut) {
1532
+ const effect = Effect.uninterruptible$1(Effect.matchCauseEffect(this.provide(bracketOut.acquire()), {
1533
+ onFailure: cause => Effect.sync$1(() => {
1534
+ this._currentChannel = failCause$2(cause);
1535
+ }),
1536
+ onSuccess: out => Effect.sync$1(() => {
1537
+ this.addFinalizer(exit => this.provide(bracketOut.finalizer(out, exit)));
1538
+ this._currentChannel = write(out);
1539
+ })
1540
+ }));
1541
+ return fromEffect$2(effect);
1542
+ }
1543
+ provide(effect) {
1544
+ if (this._providedEnv === undefined) {
1545
+ return effect;
1546
+ }
1547
+ return Effect.pipe(effect, Effect.provide(this._providedEnv));
1548
+ }
1549
+ runEnsuring(ensuring) {
1550
+ this.addFinalizer(ensuring.finalizer);
1551
+ this._currentChannel = ensuring.channel;
1552
+ }
1553
+ addFinalizer(f) {
1554
+ this._doneStack.push(new ContinuationFinalizerImpl(f));
1555
+ }
1556
+ runSubexecutor() {
1557
+ const subexecutor = this._activeSubexecutor;
1558
+ switch (subexecutor._tag) {
1559
+ case OP_PULL_FROM_CHILD:
1560
+ {
1561
+ return this.pullFromChild(subexecutor.childExecutor, subexecutor.parentSubexecutor, subexecutor.onEmit, subexecutor);
1562
+ }
1563
+ case OP_PULL_FROM_UPSTREAM:
1564
+ {
1565
+ return this.pullFromUpstream(subexecutor);
1566
+ }
1567
+ case OP_DRAIN_CHILD_EXECUTORS:
1568
+ {
1569
+ return this.drainChildExecutors(subexecutor);
1570
+ }
1571
+ case OP_EMIT:
1572
+ {
1573
+ this._emitted = subexecutor.value;
1574
+ this._activeSubexecutor = subexecutor.next;
1575
+ return Emit$1();
1576
+ }
1577
+ }
1578
+ }
1579
+ replaceSubexecutor(nextSubExec) {
1580
+ this._currentChannel = undefined;
1581
+ this._activeSubexecutor = nextSubExec;
1582
+ }
1583
+ finishWithExit(exit) {
1584
+ const state = Effect.match$2(exit, {
1585
+ onFailure: cause => this.doneHalt(cause),
1586
+ onSuccess: value => this.doneSucceed(value)
1587
+ });
1588
+ this._activeSubexecutor = undefined;
1589
+ return state === undefined ? Effect._void : effect(state);
1590
+ }
1591
+ finishSubexecutorWithCloseEffect(subexecutorDone, ...closeFuncs) {
1592
+ this.addFinalizer(() => Effect.pipe(closeFuncs, Effect.forEach(closeFunc => Effect.pipe(Effect.sync$1(() => closeFunc(subexecutorDone)), Effect.flatMap$1(closeEffect => closeEffect !== undefined ? closeEffect : Effect._void)), {
1593
+ discard: true
1594
+ })));
1595
+ const state = Effect.pipe(subexecutorDone, Effect.match$2({
1596
+ onFailure: cause => this.doneHalt(cause),
1597
+ onSuccess: value => this.doneSucceed(value)
1598
+ }));
1599
+ this._activeSubexecutor = undefined;
1600
+ return state;
1601
+ }
1602
+ applyUpstreamPullStrategy(upstreamFinished, queue, strategy) {
1603
+ switch (strategy._tag) {
1604
+ case OP_PULL_AFTER_NEXT:
1605
+ {
1606
+ const shouldPrepend = !upstreamFinished || queue.some(subexecutor => subexecutor !== undefined);
1607
+ return [strategy.emitSeparator, shouldPrepend ? [undefined, ...queue] : queue];
1608
+ }
1609
+ case OP_PULL_AFTER_ALL_ENQUEUED:
1610
+ {
1611
+ const shouldEnqueue = !upstreamFinished || queue.some(subexecutor => subexecutor !== undefined);
1612
+ return [strategy.emitSeparator, shouldEnqueue ? [...queue, undefined] : queue];
1613
+ }
1614
+ }
1615
+ }
1616
+ pullFromChild(childExecutor, parentSubexecutor, onEmitted, subexecutor) {
1617
+ return Read(childExecutor, Effect.identity, emitted => {
1618
+ const childExecutorDecision = onEmitted(emitted);
1619
+ switch (childExecutorDecision._tag) {
1620
+ case OP_CONTINUE:
1621
+ {
1622
+ break;
1623
+ }
1624
+ case OP_CLOSE:
1625
+ {
1626
+ this.finishWithDoneValue(childExecutor, parentSubexecutor, childExecutorDecision.value);
1627
+ break;
1628
+ }
1629
+ case OP_YIELD:
1630
+ {
1631
+ const modifiedParent = parentSubexecutor.enqueuePullFromChild(subexecutor);
1632
+ this.replaceSubexecutor(modifiedParent);
1633
+ break;
1634
+ }
1635
+ }
1636
+ this._activeSubexecutor = new Emit(emitted, this._activeSubexecutor);
1637
+ return undefined;
1638
+ }, Effect.match$2({
1639
+ onFailure: cause => {
1640
+ const state = this.handleSubexecutorFailure(childExecutor, parentSubexecutor, cause);
1641
+ return state === undefined ? undefined : effectOrUndefinedIgnored(state);
1642
+ },
1643
+ onSuccess: doneValue => {
1644
+ this.finishWithDoneValue(childExecutor, parentSubexecutor, doneValue);
1645
+ return undefined;
1646
+ }
1647
+ }));
1648
+ }
1649
+ finishWithDoneValue(childExecutor, parentSubexecutor, doneValue) {
1650
+ const subexecutor = parentSubexecutor;
1651
+ switch (subexecutor._tag) {
1652
+ case OP_PULL_FROM_UPSTREAM:
1653
+ {
1654
+ const modifiedParent = new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone !== undefined ? subexecutor.combineChildResults(subexecutor.lastDone, doneValue) : doneValue, subexecutor.activeChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit);
1655
+ this._closeLastSubstream = childExecutor.close(Effect.succeed$2(doneValue));
1656
+ this.replaceSubexecutor(modifiedParent);
1657
+ break;
1658
+ }
1659
+ case OP_DRAIN_CHILD_EXECUTORS:
1660
+ {
1661
+ const modifiedParent = new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone !== undefined ? subexecutor.combineChildResults(subexecutor.lastDone, doneValue) : doneValue, subexecutor.activeChildExecutors, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
1662
+ this._closeLastSubstream = childExecutor.close(Effect.succeed$2(doneValue));
1663
+ this.replaceSubexecutor(modifiedParent);
1664
+ break;
1665
+ }
1666
+ }
1667
+ }
1668
+ handleSubexecutorFailure(childExecutor, parentSubexecutor, cause) {
1669
+ return this.finishSubexecutorWithCloseEffect(Effect.failCause(cause), exit => parentSubexecutor.close(exit), exit => childExecutor.close(exit));
1670
+ }
1671
+ pullFromUpstream(subexecutor) {
1672
+ if (subexecutor.activeChildExecutors.length === 0) {
1673
+ return this.performPullFromUpstream(subexecutor);
1674
+ }
1675
+ const activeChild = subexecutor.activeChildExecutors[0];
1676
+ const parentSubexecutor = new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, subexecutor.activeChildExecutors.slice(1), subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit);
1677
+ if (activeChild === undefined) {
1678
+ return this.performPullFromUpstream(parentSubexecutor);
1679
+ }
1680
+ this.replaceSubexecutor(new PullFromChild(activeChild.childExecutor, parentSubexecutor, activeChild.onEmit));
1681
+ return undefined;
1682
+ }
1683
+ performPullFromUpstream(subexecutor) {
1684
+ return Read(subexecutor.upstreamExecutor, effect => {
1685
+ const closeLastSubstream = this._closeLastSubstream === undefined ? Effect._void : this._closeLastSubstream;
1686
+ this._closeLastSubstream = undefined;
1687
+ return Effect.pipe(this._executeCloseLastSubstream(closeLastSubstream), Effect.zipRight$2(effect));
1688
+ }, emitted => {
1689
+ if (this._closeLastSubstream !== undefined) {
1690
+ const closeLastSubstream = this._closeLastSubstream;
1691
+ this._closeLastSubstream = undefined;
1692
+ return Effect.pipe(this._executeCloseLastSubstream(closeLastSubstream), Effect.map$2(() => {
1693
+ const childExecutor = new ChannelExecutor(subexecutor.createChild(emitted), this._providedEnv, this._executeCloseLastSubstream);
1694
+ childExecutor._input = this._input;
1695
+ const [emitSeparator, updatedChildExecutors] = this.applyUpstreamPullStrategy(false, subexecutor.activeChildExecutors, subexecutor.onPull(Pulled(emitted)));
1696
+ this._activeSubexecutor = new PullFromChild(childExecutor, new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, updatedChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit), subexecutor.onEmit);
1697
+ if (Effect.isSome(emitSeparator)) {
1698
+ this._activeSubexecutor = new Emit(emitSeparator.value, this._activeSubexecutor);
1699
+ }
1700
+ return undefined;
1701
+ }));
1702
+ }
1703
+ const childExecutor = new ChannelExecutor(subexecutor.createChild(emitted), this._providedEnv, this._executeCloseLastSubstream);
1704
+ childExecutor._input = this._input;
1705
+ const [emitSeparator, updatedChildExecutors] = this.applyUpstreamPullStrategy(false, subexecutor.activeChildExecutors, subexecutor.onPull(Pulled(emitted)));
1706
+ this._activeSubexecutor = new PullFromChild(childExecutor, new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, updatedChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit), subexecutor.onEmit);
1707
+ if (Effect.isSome(emitSeparator)) {
1708
+ this._activeSubexecutor = new Emit(emitSeparator.value, this._activeSubexecutor);
1709
+ }
1710
+ return undefined;
1711
+ }, exit => {
1712
+ if (subexecutor.activeChildExecutors.some(subexecutor => subexecutor !== undefined)) {
1713
+ const drain = new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, [undefined, ...subexecutor.activeChildExecutors], subexecutor.upstreamExecutor.getDone(), subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
1714
+ if (this._closeLastSubstream !== undefined) {
1715
+ const closeLastSubstream = this._closeLastSubstream;
1716
+ this._closeLastSubstream = undefined;
1717
+ return Effect.pipe(this._executeCloseLastSubstream(closeLastSubstream), Effect.map$2(() => this.replaceSubexecutor(drain)));
1718
+ }
1719
+ this.replaceSubexecutor(drain);
1720
+ return undefined;
1721
+ }
1722
+ const closeLastSubstream = this._closeLastSubstream;
1723
+ const state = this.finishSubexecutorWithCloseEffect(Effect.pipe(exit, Effect.map$3(a => subexecutor.combineWithChildResult(subexecutor.lastDone, a))), () => closeLastSubstream, exit => subexecutor.upstreamExecutor.close(exit));
1724
+ return state === undefined ? undefined :
1725
+ // NOTE: assuming finalizers cannot fail
1726
+ effectOrUndefinedIgnored(state);
1727
+ });
1728
+ }
1729
+ drainChildExecutors(subexecutor) {
1730
+ if (subexecutor.activeChildExecutors.length === 0) {
1731
+ const lastClose = this._closeLastSubstream;
1732
+ if (lastClose !== undefined) {
1733
+ this.addFinalizer(() => Effect.succeed(lastClose));
1734
+ }
1735
+ return this.finishSubexecutorWithCloseEffect(subexecutor.upstreamDone, () => lastClose, exit => subexecutor.upstreamExecutor.close(exit));
1736
+ }
1737
+ const activeChild = subexecutor.activeChildExecutors[0];
1738
+ const rest = subexecutor.activeChildExecutors.slice(1);
1739
+ if (activeChild === undefined) {
1740
+ const [emitSeparator, remainingExecutors] = this.applyUpstreamPullStrategy(true, rest, subexecutor.onPull(NoUpstream(rest.reduce((n, curr) => curr !== undefined ? n + 1 : n, 0))));
1741
+ this.replaceSubexecutor(new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, remainingExecutors, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull));
1742
+ if (Effect.isSome(emitSeparator)) {
1743
+ this._emitted = emitSeparator.value;
1744
+ return Emit$1();
1745
+ }
1746
+ return undefined;
1747
+ }
1748
+ const parentSubexecutor = new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, rest, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
1749
+ this.replaceSubexecutor(new PullFromChild(activeChild.childExecutor, parentSubexecutor, activeChild.onEmit));
1750
+ return undefined;
1751
+ }
1752
+ }
1753
+ const ifNotNull = effect => effect !== undefined ? effect : Effect._void;
1754
+ const runFinalizers = (finalizers, exit) => {
1755
+ return Effect.pipe(Effect.forEach(finalizers, fin => Effect.exit$1(fin(exit))), Effect.map$2(exits => Effect.pipe(Effect.all$1(exits), Effect.getOrElse(() => Effect.void_$1))), Effect.flatMap$1(exit => Effect.suspend$1(() => exit)));
1756
+ };
1757
+ /**
1758
+ * @internal
1759
+ */
1760
+ const readUpstream = (r, onSuccess, onFailure) => {
1761
+ const readStack = [r];
1762
+ const read = () => {
1763
+ const current = readStack.pop();
1764
+ if (current === undefined || current.upstream === undefined) {
1765
+ return Effect.dieMessage("Unexpected end of input for channel execution");
1766
+ }
1767
+ const state = current.upstream.run();
1768
+ switch (state._tag) {
1769
+ case OP_EMIT$1:
1770
+ {
1771
+ const emitEffect = current.onEmit(current.upstream.getEmit());
1772
+ if (readStack.length === 0) {
1773
+ if (emitEffect === undefined) {
1774
+ return Effect.suspend$1(onSuccess);
1775
+ }
1776
+ return Effect.pipe(emitEffect, Effect.matchCauseEffect({
1777
+ onFailure,
1778
+ onSuccess
1779
+ }));
1780
+ }
1781
+ if (emitEffect === undefined) {
1782
+ return Effect.suspend$1(() => read());
1783
+ }
1784
+ return Effect.pipe(emitEffect, Effect.matchCauseEffect({
1785
+ onFailure,
1786
+ onSuccess: () => read()
1787
+ }));
1788
+ }
1789
+ case OP_DONE$1:
1790
+ {
1791
+ const doneEffect = current.onDone(current.upstream.getDone());
1792
+ if (readStack.length === 0) {
1793
+ if (doneEffect === undefined) {
1794
+ return Effect.suspend$1(onSuccess);
1795
+ }
1796
+ return Effect.pipe(doneEffect, Effect.matchCauseEffect({
1797
+ onFailure,
1798
+ onSuccess
1799
+ }));
1800
+ }
1801
+ if (doneEffect === undefined) {
1802
+ return Effect.suspend$1(() => read());
1803
+ }
1804
+ return Effect.pipe(doneEffect, Effect.matchCauseEffect({
1805
+ onFailure,
1806
+ onSuccess: () => read()
1807
+ }));
1808
+ }
1809
+ case OP_FROM_EFFECT:
1810
+ {
1811
+ readStack.push(current);
1812
+ return Effect.pipe(current.onEffect(state.effect), Effect.catchAllCause(cause => Effect.suspend$1(() => {
1813
+ const doneEffect = current.onDone(Effect.failCause(cause));
1814
+ return doneEffect === undefined ? Effect._void : doneEffect;
1815
+ })), Effect.matchCauseEffect({
1816
+ onFailure,
1817
+ onSuccess: () => read()
1818
+ }));
1819
+ }
1820
+ case OP_READ:
1821
+ {
1822
+ readStack.push(current);
1823
+ readStack.push(state);
1824
+ return Effect.suspend$1(() => read());
1825
+ }
1826
+ }
1827
+ };
1828
+ return read();
1829
+ };
1830
+ /** @internal */
1831
+ const runIn = /*#__PURE__*/Effect.dual(2, (self, scope) => {
1832
+ const run = (channelDeferred, scopeDeferred, scope) => Effect.acquireUseRelease(Effect.sync$1(() => new ChannelExecutor(self, void 0, Effect.identity)), exec => Effect.suspend$1(() => runScopedInterpret(exec.run(), exec).pipe(Effect.intoDeferred(channelDeferred), Effect.zipRight$2(Effect._await(channelDeferred)), Effect.zipLeft(Effect._await(scopeDeferred)))), (exec, exit) => {
1833
+ const finalize = exec.close(exit);
1834
+ if (finalize === undefined) {
1835
+ return Effect._void;
1836
+ }
1837
+ return Effect.tapErrorCause(finalize, cause => Effect.addFinalizer(scope, Effect.failCause$1(cause)));
1838
+ });
1839
+ return Effect.uninterruptibleMask(restore => Effect.all$2([Effect.fork(scope, Effect.sequential), Effect.make$2(), Effect.make$2()]).pipe(Effect.flatMap$1(([child, channelDeferred, scopeDeferred]) => restore(run(channelDeferred, scopeDeferred, child)).pipe(Effect.forkIn(scope), Effect.flatMap$1(fiber => scope.addFinalizer(exit => {
1840
+ const interruptors$1 = Effect.isFailure(exit) ? interruptors(exit.cause) : undefined;
1841
+ return Effect.isDone(channelDeferred).pipe(Effect.flatMap$1(isDone => isDone ? Effect.succeed$3(scopeDeferred, void 0).pipe(Effect.zipRight$2(_await(fiber)), Effect.zipRight$2(inheritAll(fiber))) : Effect.succeed$3(scopeDeferred, void 0).pipe(Effect.zipRight$2(interruptors$1 && Effect.size$1(interruptors$1) > 0 ? interruptAs(fiber, Effect.combineAll(interruptors$1)) : interrupt(fiber)), Effect.zipRight$2(inheritAll(fiber)))));
1842
+ }).pipe(Effect.zipRight$2(restore(Effect._await(channelDeferred)))))))));
1843
+ });
1844
+ /** @internal */
1845
+ const runScopedInterpret = (channelState, exec) => {
1846
+ const op = channelState;
1847
+ switch (op._tag) {
1848
+ case OP_FROM_EFFECT:
1849
+ {
1850
+ return Effect.pipe(op.effect, Effect.flatMap$1(() => runScopedInterpret(exec.run(), exec)));
1851
+ }
1852
+ case OP_EMIT$1:
1853
+ {
1854
+ // Can't really happen because Out <:< Nothing. So just skip ahead.
1855
+ return runScopedInterpret(exec.run(), exec);
1856
+ }
1857
+ case OP_DONE$1:
1858
+ {
1859
+ return Effect.suspend$1(() => exec.getDone());
1860
+ }
1861
+ case OP_READ:
1862
+ {
1863
+ return readUpstream(op, () => runScopedInterpret(exec.run(), exec), Effect.failCause$1);
1864
+ }
1865
+ }
1866
+ };
1867
+
1868
+ /** @internal */
1869
+ const OP_DONE = "Done";
1870
+ /** @internal */
1871
+ const OP_AWAIT = "Await";
1872
+
1873
+ /** @internal */
1874
+ const MergeDecisionSymbolKey = "effect/ChannelMergeDecision";
1875
+ /** @internal */
1876
+ const MergeDecisionTypeId = /*#__PURE__*/Symbol.for(MergeDecisionSymbolKey);
1877
+ /** @internal */
1878
+ const proto$2 = {
1879
+ [MergeDecisionTypeId]: {
1880
+ _R: _ => _,
1881
+ _E0: _ => _,
1882
+ _Z0: _ => _,
1883
+ _E: _ => _,
1884
+ _Z: _ => _
1885
+ }
1886
+ };
1887
+ /** @internal */
1888
+ const Await = f => {
1889
+ const op = Object.create(proto$2);
1890
+ op._tag = OP_AWAIT;
1891
+ op.f = f;
1892
+ return op;
1893
+ };
1894
+
1895
+ /** @internal */
1896
+ const OP_BOTH_RUNNING = "BothRunning";
1897
+ /** @internal */
1898
+ const OP_LEFT_DONE = "LeftDone";
1899
+ /** @internal */
1900
+ const OP_RIGHT_DONE = "RightDone";
1901
+
1902
+ /** @internal */
1903
+ const MergeStateSymbolKey = "effect/ChannelMergeState";
1904
+ /** @internal */
1905
+ const MergeStateTypeId = /*#__PURE__*/Symbol.for(MergeStateSymbolKey);
1906
+ /** @internal */
1907
+ const proto$1 = {
1908
+ [MergeStateTypeId]: MergeStateTypeId
1909
+ };
1910
+ /** @internal */
1911
+ const BothRunning = (left, right) => {
1912
+ const op = Object.create(proto$1);
1913
+ op._tag = OP_BOTH_RUNNING;
1914
+ op.left = left;
1915
+ op.right = right;
1916
+ return op;
1917
+ };
1918
+ /** @internal */
1919
+ const LeftDone = f => {
1920
+ const op = Object.create(proto$1);
1921
+ op._tag = OP_LEFT_DONE;
1922
+ op.f = f;
1923
+ return op;
1924
+ };
1925
+ /** @internal */
1926
+ const RightDone = f => {
1927
+ const op = Object.create(proto$1);
1928
+ op._tag = OP_RIGHT_DONE;
1929
+ op.f = f;
1930
+ return op;
1931
+ };
1932
+
1933
+ /** @internal */
1934
+ const OP_BACK_PRESSURE = "BackPressure";
1935
+ /** @internal */
1936
+ const OP_BUFFER_SLIDING = "BufferSliding";
1937
+
1938
+ /** @internal */
1939
+ const MergeStrategySymbolKey = "effect/ChannelMergeStrategy";
1940
+ /** @internal */
1941
+ const MergeStrategyTypeId = /*#__PURE__*/Symbol.for(MergeStrategySymbolKey);
1942
+ /** @internal */
1943
+ const proto = {
1944
+ [MergeStrategyTypeId]: MergeStrategyTypeId
1945
+ };
1946
+ /** @internal */
1947
+ const BackPressure = _ => {
1948
+ const op = Object.create(proto);
1949
+ op._tag = OP_BACK_PRESSURE;
1950
+ return op;
1951
+ };
1952
+ /** @internal */
1953
+ const BufferSliding = _ => {
1954
+ const op = Object.create(proto);
1955
+ op._tag = OP_BUFFER_SLIDING;
1956
+ return op;
1957
+ };
1958
+ /** @internal */
1959
+ const match = /*#__PURE__*/Effect.dual(2, (self, {
1960
+ onBackPressure,
1961
+ onBufferSliding
1962
+ }) => {
1963
+ switch (self._tag) {
1964
+ case OP_BACK_PRESSURE:
1965
+ {
1966
+ return onBackPressure();
1967
+ }
1968
+ case OP_BUFFER_SLIDING:
1969
+ {
1970
+ return onBufferSliding();
1971
+ }
1972
+ }
1973
+ });
1974
+
1975
+ /** @internal */
1976
+ const OP_STATE_EMPTY = "Empty";
1977
+ /** @internal */
1978
+ const OP_STATE_EMIT = "Emit";
1979
+ /** @internal */
1980
+ const OP_STATE_ERROR = "Error";
1981
+ /** @internal */
1982
+ const OP_STATE_DONE = "Done";
1983
+ /** @internal */
1984
+ const stateEmpty = notifyProducer => ({
1985
+ _tag: OP_STATE_EMPTY,
1986
+ notifyProducer
1987
+ });
1988
+ /** @internal */
1989
+ const stateEmit = notifyConsumers => ({
1990
+ _tag: OP_STATE_EMIT,
1991
+ notifyConsumers
1992
+ });
1993
+ /** @internal */
1994
+ const stateError = cause => ({
1995
+ _tag: OP_STATE_ERROR,
1996
+ cause
1997
+ });
1998
+ /** @internal */
1999
+ const stateDone = done => ({
2000
+ _tag: OP_STATE_DONE,
2001
+ done
2002
+ });
2003
+ /** @internal */
2004
+ class SingleProducerAsyncInputImpl {
2005
+ ref;
2006
+ constructor(ref) {
2007
+ this.ref = ref;
2008
+ }
2009
+ awaitRead() {
2010
+ return Effect.flatten(modify(this.ref, state => state._tag === OP_STATE_EMPTY ? [Effect._await(state.notifyProducer), state] : [Effect._void, state]));
2011
+ }
2012
+ get close() {
2013
+ return Effect.fiberIdWith(fiberId => this.error(interrupt$1(fiberId)));
2014
+ }
2015
+ done(value) {
2016
+ return Effect.flatten(modify(this.ref, state => {
2017
+ switch (state._tag) {
2018
+ case OP_STATE_EMPTY:
2019
+ {
2020
+ return [Effect._await(state.notifyProducer), state];
2021
+ }
2022
+ case OP_STATE_EMIT:
2023
+ {
2024
+ return [Effect.forEach(state.notifyConsumers, deferred => Effect.succeed$3(deferred, Effect.left(value)), {
2025
+ discard: true
2026
+ }), stateDone(value)];
2027
+ }
2028
+ case OP_STATE_ERROR:
2029
+ {
2030
+ return [Effect.interrupt$3, state];
2031
+ }
2032
+ case OP_STATE_DONE:
2033
+ {
2034
+ return [Effect.interrupt$3, state];
2035
+ }
2036
+ }
2037
+ }));
2038
+ }
2039
+ emit(element) {
2040
+ return Effect.flatMap$1(Effect.make$2(), deferred => Effect.flatten(modify(this.ref, state => {
2041
+ switch (state._tag) {
2042
+ case OP_STATE_EMPTY:
2043
+ {
2044
+ return [Effect._await(state.notifyProducer), state];
2045
+ }
2046
+ case OP_STATE_EMIT:
2047
+ {
2048
+ const notifyConsumer = state.notifyConsumers[0];
2049
+ const notifyConsumers = state.notifyConsumers.slice(1);
2050
+ if (notifyConsumer !== undefined) {
2051
+ return [Effect.succeed$3(notifyConsumer, Effect.right(element)), notifyConsumers.length === 0 ? stateEmpty(deferred) : stateEmit(notifyConsumers)];
2052
+ }
2053
+ throw new Error("Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues");
2054
+ }
2055
+ case OP_STATE_ERROR:
2056
+ {
2057
+ return [Effect.interrupt$3, state];
2058
+ }
2059
+ case OP_STATE_DONE:
2060
+ {
2061
+ return [Effect.interrupt$3, state];
2062
+ }
2063
+ }
2064
+ })));
2065
+ }
2066
+ error(cause) {
2067
+ return Effect.flatten(modify(this.ref, state => {
2068
+ switch (state._tag) {
2069
+ case OP_STATE_EMPTY:
2070
+ {
2071
+ return [Effect._await(state.notifyProducer), state];
2072
+ }
2073
+ case OP_STATE_EMIT:
2074
+ {
2075
+ return [Effect.forEach(state.notifyConsumers, deferred => Effect.failCause$2(deferred, cause), {
2076
+ discard: true
2077
+ }), stateError(cause)];
2078
+ }
2079
+ case OP_STATE_ERROR:
2080
+ {
2081
+ return [Effect.interrupt$3, state];
2082
+ }
2083
+ case OP_STATE_DONE:
2084
+ {
2085
+ return [Effect.interrupt$3, state];
2086
+ }
2087
+ }
2088
+ }));
2089
+ }
2090
+ get take() {
2091
+ return this.takeWith(cause => Effect.failCause(map$2(cause, Effect.left)), elem => Effect.succeed$2(elem), done => Effect.fail$1(Effect.right(done)));
2092
+ }
2093
+ takeWith(onError, onElement, onDone) {
2094
+ return Effect.flatMap$1(Effect.make$2(), deferred => Effect.flatten(modify(this.ref, state => {
2095
+ switch (state._tag) {
2096
+ case OP_STATE_EMPTY:
2097
+ {
2098
+ return [Effect.zipRight$2(Effect.succeed$3(state.notifyProducer, void 0), Effect.matchCause(Effect._await(deferred), {
2099
+ onFailure: onError,
2100
+ onSuccess: Effect.match$1({
2101
+ onLeft: onDone,
2102
+ onRight: onElement
2103
+ })
2104
+ })), stateEmit([deferred])];
2105
+ }
2106
+ case OP_STATE_EMIT:
2107
+ {
2108
+ return [Effect.matchCause(Effect._await(deferred), {
2109
+ onFailure: onError,
2110
+ onSuccess: Effect.match$1({
2111
+ onLeft: onDone,
2112
+ onRight: onElement
2113
+ })
2114
+ }), stateEmit([...state.notifyConsumers, deferred])];
2115
+ }
2116
+ case OP_STATE_ERROR:
2117
+ {
2118
+ return [Effect.succeed(onError(state.cause)), state];
2119
+ }
2120
+ case OP_STATE_DONE:
2121
+ {
2122
+ return [Effect.succeed(onDone(state.done)), state];
2123
+ }
2124
+ }
2125
+ })));
2126
+ }
2127
+ }
2128
+ /** @internal */
2129
+ const make$1 = () => Effect.pipe(Effect.make$2(), Effect.flatMap$1(deferred => make$3(stateEmpty(deferred))), Effect.map$2(ref => new SingleProducerAsyncInputImpl(ref)));
2130
+
2131
+ /** @internal */
2132
+ const concatMap = /*#__PURE__*/Effect.dual(2, (self, f) => concatMapWith(self, f, () => void 0, () => void 0));
2133
+ /** @internal */
2134
+ const drain$1 = self => {
2135
+ const drainer = readWithCause({
2136
+ onInput: () => drainer,
2137
+ onFailure: failCause$2,
2138
+ onDone: succeed
2139
+ });
2140
+ return pipeTo(self, drainer);
2141
+ };
2142
+ /** @internal */
2143
+ const ensuring$1 = /*#__PURE__*/Effect.dual(2, (self, finalizer) => ensuringWith(self, () => finalizer));
2144
+ /** @internal */
2145
+ const flatten$1 = self => flatMap$1(self, Effect.identity);
2146
+ /** @internal */
2147
+ const fromInput = input => unwrap(input.takeWith(failCause$2, elem => flatMap$1(write(elem), () => fromInput(input)), succeed));
2148
+ /** @internal */
2149
+ const identityChannel = () => readWith({
2150
+ onInput: input => flatMap$1(write(input), () => identityChannel()),
2151
+ onFailure: fail,
2152
+ onDone: succeedNow
2153
+ });
2154
+ /** @internal */
2155
+ const map$1 = /*#__PURE__*/Effect.dual(2, (self, f) => flatMap$1(self, a => sync(() => f(a))));
2156
+ /** @internal */
2157
+ const mapOut = /*#__PURE__*/Effect.dual(2, (self, f) => {
2158
+ const reader = readWith({
2159
+ onInput: outElem => flatMap$1(write(f(outElem)), () => reader),
2160
+ onFailure: fail,
2161
+ onDone: succeedNow
2162
+ });
2163
+ return pipeTo(self, reader);
2164
+ });
2165
+ /** @internal */
2166
+ const mapOutEffectPar = /*#__PURE__*/Effect.dual(3, (self, f, n) => unwrapScopedWith$1(scope => Effect.gen(function* () {
2167
+ const input = yield* make$1();
2168
+ const queueReader = fromInput(input);
2169
+ const queue = yield* bounded(n);
2170
+ yield* Effect.addFinalizer(scope, shutdown(queue));
2171
+ const errorSignal = yield* Effect.make$2();
2172
+ const withPermits = n === Number.POSITIVE_INFINITY ? _ => Effect.identity : (yield* Effect.makeSemaphore(n)).withPermits;
2173
+ const pull = yield* queueReader.pipe(pipeTo(self), toPullIn(scope));
2174
+ yield* pull.pipe(Effect.matchCauseEffect({
2175
+ onFailure: cause => offer(queue, Effect.failCause$1(cause)),
2176
+ onSuccess: Effect.match$1({
2177
+ onLeft: outDone => Effect.zipRight$2(Effect.interruptible(withPermits(n)(Effect._void)), Effect.asVoid$1(offer(queue, Effect.succeed(Effect.left(outDone))))),
2178
+ onRight: outElem => Effect.gen(function* () {
2179
+ const deferred = yield* Effect.make$2();
2180
+ const latch = yield* Effect.make$2();
2181
+ yield* offer(queue, Effect.map$2(Effect._await(deferred), Effect.right));
2182
+ yield* Effect.succeed$3(latch, void 0).pipe(Effect.zipRight$2(Effect.uninterruptibleMask(restore => Effect.exit$1(restore(Effect._await(errorSignal))).pipe(Effect.raceFirst(Effect.exit$1(restore(f(outElem)))), Effect.flatMap$1(Effect.identity))).pipe(Effect.tapErrorCause(cause => Effect.failCause$2(errorSignal, cause)), Effect.intoDeferred(deferred))), withPermits(1), Effect.forkIn(scope));
2183
+ yield* Effect._await(latch);
2184
+ })
2185
+ })
2186
+ }), Effect.forever, Effect.interruptible, Effect.forkIn(scope));
2187
+ const consumer = unwrap(Effect.matchCause(Effect.flatten(take(queue)), {
2188
+ onFailure: failCause$2,
2189
+ onSuccess: Effect.match$1({
2190
+ onLeft: succeedNow,
2191
+ onRight: outElem => flatMap$1(write(outElem), () => consumer)
2192
+ })
2193
+ }));
2194
+ return embedInput(consumer, input);
2195
+ })));
2196
+ /** @internal */
2197
+ const mergeAll = options => {
2198
+ return channels => mergeAllWith(options)(channels, Effect.constVoid);
2199
+ };
2200
+ /** @internal */
2201
+ const mergeAllWith = ({
2202
+ bufferSize = 16,
2203
+ concurrency,
2204
+ mergeStrategy = BackPressure()
2205
+ }) => (channels, f) => unwrapScopedWith$1(scope => Effect.gen(function* () {
2206
+ const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : concurrency;
2207
+ const input = yield* make$1();
2208
+ const queueReader = fromInput(input);
2209
+ const queue = yield* bounded(bufferSize);
2210
+ yield* Effect.addFinalizer(scope, shutdown(queue));
2211
+ const cancelers = yield* unbounded();
2212
+ yield* Effect.addFinalizer(scope, shutdown(cancelers));
2213
+ const lastDone = yield* make$3(Effect.none());
2214
+ const errorSignal = yield* Effect.make$2();
2215
+ const withPermits = (yield* Effect.makeSemaphore(concurrencyN)).withPermits;
2216
+ const pull = yield* toPullIn(pipeTo(queueReader, channels), scope);
2217
+ function evaluatePull(pull) {
2218
+ return pull.pipe(Effect.flatMap$1(Effect.match$1({
2219
+ onLeft: done => Effect.succeed(Effect.some(done)),
2220
+ onRight: outElem => Effect.as(offer(queue, Effect.succeed(Effect.right(outElem))), Effect.none())
2221
+ })), Effect.repeat({
2222
+ until: _ => Effect.isSome(_)
2223
+ }), Effect.flatMap$1(outDone => update(lastDone, Effect.match({
2224
+ onNone: () => Effect.some(outDone.value),
2225
+ onSome: lastDone => Effect.some(f(lastDone, outDone.value))
2226
+ }))), Effect.catchAllCause(cause => isInterrupted(cause) ? Effect.failCause$1(cause) : offer(queue, Effect.failCause$1(cause)).pipe(Effect.zipRight$2(Effect.succeed$3(errorSignal, void 0)), Effect.asVoid$1)));
2227
+ }
2228
+ yield* pull.pipe(Effect.matchCauseEffect({
2229
+ onFailure: cause => offer(queue, Effect.failCause$1(cause)).pipe(Effect.zipRight$2(Effect.succeed(false))),
2230
+ onSuccess: Effect.match$1({
2231
+ onLeft: outDone => Effect.raceWith(Effect.interruptible(Effect._await(errorSignal)), Effect.interruptible(withPermits(concurrencyN)(Effect._void)), {
2232
+ onSelfDone: (_, permitAcquisition) => Effect.as(interrupt(permitAcquisition), false),
2233
+ onOtherDone: (_, failureAwait) => Effect.zipRight$2(interrupt(failureAwait), get(lastDone).pipe(Effect.flatMap$1(Effect.match({
2234
+ onNone: () => offer(queue, Effect.succeed(Effect.left(outDone))),
2235
+ onSome: lastDone => offer(queue, Effect.succeed(Effect.left(f(lastDone, outDone))))
2236
+ })), Effect.as(false)))
2237
+ }),
2238
+ onRight: channel => match(mergeStrategy, {
2239
+ onBackPressure: () => Effect.gen(function* () {
2240
+ const latch = yield* Effect.make$2();
2241
+ const raceEffects = Effect.scopedWith(scope => toPullIn(pipeTo(queueReader, channel), scope).pipe(Effect.flatMap$1(pull => Effect.race(Effect.exit$1(evaluatePull(pull)), Effect.exit$1(Effect.interruptible(Effect._await(errorSignal))))), Effect.flatMap$1(Effect.identity)));
2242
+ yield* Effect.succeed$3(latch, void 0).pipe(Effect.zipRight$2(raceEffects), withPermits(1), Effect.forkIn(scope));
2243
+ yield* Effect._await(latch);
2244
+ const errored = yield* Effect.isDone(errorSignal);
2245
+ return !errored;
2246
+ }),
2247
+ onBufferSliding: () => Effect.gen(function* () {
2248
+ const canceler = yield* Effect.make$2();
2249
+ const latch = yield* Effect.make$2();
2250
+ const size$1 = yield* size(cancelers);
2251
+ yield* take(cancelers).pipe(Effect.flatMap$1(canceler => Effect.succeed$3(canceler, void 0)), Effect.when$1(() => size$1 >= concurrencyN));
2252
+ yield* offer(cancelers, canceler);
2253
+ const raceEffects = Effect.scopedWith(scope => toPullIn(pipeTo(queueReader, channel), scope).pipe(Effect.flatMap$1(pull => Effect.exit$1(evaluatePull(pull)).pipe(Effect.race(Effect.exit$1(Effect.interruptible(Effect._await(errorSignal)))), Effect.race(Effect.exit$1(Effect.interruptible(Effect._await(canceler)))))), Effect.flatMap$1(Effect.identity)));
2254
+ yield* Effect.succeed$3(latch, void 0).pipe(Effect.zipRight$2(raceEffects), withPermits(1), Effect.forkIn(scope));
2255
+ yield* Effect._await(latch);
2256
+ const errored = yield* Effect.isDone(errorSignal);
2257
+ return !errored;
2258
+ })
2259
+ })
2260
+ })
2261
+ }), Effect.repeat({
2262
+ while: _ => _
2263
+ }), Effect.forkIn(scope));
2264
+ const consumer = Effect.pipe(take(queue), Effect.flatten, Effect.matchCause({
2265
+ onFailure: failCause$2,
2266
+ onSuccess: Effect.match$1({
2267
+ onLeft: succeedNow,
2268
+ onRight: outElem => flatMap$1(write(outElem), () => consumer)
2269
+ })
2270
+ }), unwrap);
2271
+ return embedInput(consumer, input);
2272
+ }));
2273
+ /** @internal */
2274
+ const mergeMap = /*#__PURE__*/Effect.dual(3, (self, f, options) => mergeAll(options)(mapOut(self, f)));
2275
+ /** @internal */
2276
+ const mergeWith = /*#__PURE__*/Effect.dual(2, (self, options) => {
2277
+ function merge(scope) {
2278
+ return Effect.gen(function* () {
2279
+ const input = yield* make$1();
2280
+ const queueReader = fromInput(input);
2281
+ const pullL = yield* toPullIn(pipeTo(queueReader, self), scope);
2282
+ const pullR = yield* toPullIn(pipeTo(queueReader, options.other), scope);
2283
+ function handleSide(exit, fiber, pull) {
2284
+ return (done, both, single) => {
2285
+ function onDecision(decision) {
2286
+ const op = decision;
2287
+ if (op._tag === OP_DONE) {
2288
+ return Effect.succeed(fromEffect$3(Effect.zipRight$2(interrupt(fiber), op.effect)));
2289
+ }
2290
+ return Effect.map$2(_await(fiber), Effect.match$2({
2291
+ onFailure: cause => fromEffect$3(op.f(Effect.failCause(cause))),
2292
+ onSuccess: Effect.match$1({
2293
+ onLeft: done => fromEffect$3(op.f(Effect.succeed$2(done))),
2294
+ onRight: elem => zipRight(write(elem), go(single(op.f)))
2295
+ })
2296
+ }));
2297
+ }
2298
+ return Effect.match$2(exit, {
2299
+ onFailure: cause => onDecision(done(Effect.failCause(cause))),
2300
+ onSuccess: Effect.match$1({
2301
+ onLeft: z => onDecision(done(Effect.succeed$2(z))),
2302
+ onRight: elem => Effect.succeed(flatMap$1(write(elem), () => flatMap$1(fromEffect$3(Effect.forkIn(Effect.interruptible(pull), scope)), leftFiber => go(both(leftFiber, fiber)))))
2303
+ })
2304
+ });
2305
+ };
2306
+ }
2307
+ function go(state) {
2308
+ switch (state._tag) {
2309
+ case OP_BOTH_RUNNING:
2310
+ {
2311
+ const leftJoin = Effect.interruptible(join(state.left));
2312
+ const rightJoin = Effect.interruptible(join(state.right));
2313
+ return unwrap(Effect.raceWith(leftJoin, rightJoin, {
2314
+ onSelfDone: (leftExit, rf) => Effect.zipRight$2(interrupt(rf), handleSide(leftExit, state.right, pullL)(options.onSelfDone, BothRunning, f => LeftDone(f))),
2315
+ onOtherDone: (rightExit, lf) => Effect.zipRight$2(interrupt(lf), handleSide(rightExit, state.left, pullR)(options.onOtherDone, (left, right) => BothRunning(right, left), f => RightDone(f)))
2316
+ }));
2317
+ }
2318
+ case OP_LEFT_DONE:
2319
+ {
2320
+ return unwrap(Effect.map$2(Effect.exit$1(pullR), Effect.match$2({
2321
+ onFailure: cause => fromEffect$3(state.f(Effect.failCause(cause))),
2322
+ onSuccess: Effect.match$1({
2323
+ onLeft: done => fromEffect$3(state.f(Effect.succeed$2(done))),
2324
+ onRight: elem => flatMap$1(write(elem), () => go(LeftDone(state.f)))
2325
+ })
2326
+ })));
2327
+ }
2328
+ case OP_RIGHT_DONE:
2329
+ {
2330
+ return unwrap(Effect.map$2(Effect.exit$1(pullL), Effect.match$2({
2331
+ onFailure: cause => fromEffect$3(state.f(Effect.failCause(cause))),
2332
+ onSuccess: Effect.match$1({
2333
+ onLeft: done => fromEffect$3(state.f(Effect.succeed$2(done))),
2334
+ onRight: elem => flatMap$1(write(elem), () => go(RightDone(state.f)))
2335
+ })
2336
+ })));
2337
+ }
2338
+ }
2339
+ }
2340
+ return fromEffect$3(Effect.withFiberRuntime$1(parent => {
2341
+ const inherit = Effect.withFiberRuntime$1(state => {
2342
+ state.transferChildren(parent.scope());
2343
+ return Effect._void;
2344
+ });
2345
+ const leftFiber = Effect.interruptible(pullL).pipe(Effect.ensuring(inherit), Effect.forkIn(scope));
2346
+ const rightFiber = Effect.interruptible(pullR).pipe(Effect.ensuring(inherit), Effect.forkIn(scope));
2347
+ return Effect.zipWith(leftFiber, rightFiber, (left, right) => BothRunning(left, right));
2348
+ })).pipe(flatMap$1(go), embedInput(input));
2349
+ });
2350
+ }
2351
+ return unwrapScopedWith$1(merge);
2352
+ });
2353
+ /** @internal */
2354
+ const pipeToOrFail = /*#__PURE__*/Effect.dual(2, (self, that) => suspend$1(() => {
2355
+ let channelException = undefined;
2356
+ const reader = readWith({
2357
+ onInput: outElem => flatMap$1(write(outElem), () => reader),
2358
+ onFailure: outErr => {
2359
+ channelException = ChannelException(outErr);
2360
+ return failCause$2(die(channelException));
2361
+ },
2362
+ onDone: succeedNow
2363
+ });
2364
+ const writer = readWithCause({
2365
+ onInput: outElem => Effect.pipe(write(outElem), flatMap$1(() => writer)),
2366
+ onFailure: cause => isDieType(cause) && isChannelException(cause.defect) && Effect.equals(cause.defect, channelException) ? fail(cause.defect.error) : failCause$2(cause),
2367
+ onDone: succeedNow
2368
+ });
2369
+ return pipeTo(pipeTo(pipeTo(self, reader), that), writer);
2370
+ }));
2371
+ /** @internal */
2372
+ const run$1 = self => Effect.scopedWith(scope => runIn(self, scope));
2373
+ /** @internal */
2374
+ const runDrain$2 = self => run$1(drain$1(self));
2375
+ /** @internal */
2376
+ const scoped = effect => unwrap(Effect.uninterruptibleMask(restore => Effect.map$2(Effect.make$3(), scope => acquireReleaseOut(Effect.tapErrorCause(restore(Effect.extend(effect, scope)), cause => Effect.close(scope, Effect.failCause(cause))), (_, exit) => Effect.close(scope, exit)))));
2377
+ /** @internal */
2378
+ const scopedWith$1 = f => unwrapScoped(Effect.map$2(Effect.scope, scope => flatMap$1(fromEffect$3(f(scope)), write)));
2379
+ /** @internal */
2380
+ const toPullIn = /*#__PURE__*/Effect.dual(2, (self, scope) => Effect.zip(Effect.sync$1(() => new ChannelExecutor(self, void 0, Effect.identity)), Effect.runtime()).pipe(Effect.tap(([executor, runtime]) => Effect.addFinalizerExit(scope, exit => {
2381
+ const finalizer = executor.close(exit);
2382
+ return finalizer !== undefined ? Effect.provide(finalizer, runtime) : Effect._void;
2383
+ })), Effect.uninterruptible$1, Effect.map$2(([executor]) => Effect.suspend$1(() => interpretToPull(executor.run(), executor)))));
2384
+ /** @internal */
2385
+ const interpretToPull = (channelState, exec) => {
2386
+ const state = channelState;
2387
+ switch (state._tag) {
2388
+ case OP_DONE$1:
2389
+ {
2390
+ return Effect.match$2(exec.getDone(), {
2391
+ onFailure: Effect.failCause$1,
2392
+ onSuccess: done => Effect.succeed(Effect.left(done))
2393
+ });
2394
+ }
2395
+ case OP_EMIT$1:
2396
+ {
2397
+ return Effect.succeed(Effect.right(exec.getEmit()));
2398
+ }
2399
+ case OP_FROM_EFFECT:
2400
+ {
2401
+ return Effect.pipe(state.effect, Effect.flatMap$1(() => interpretToPull(exec.run(), exec)));
2402
+ }
2403
+ case OP_READ:
2404
+ {
2405
+ return readUpstream(state, () => interpretToPull(exec.run(), exec), cause => Effect.failCause$1(cause));
2406
+ }
2407
+ }
2408
+ };
2409
+ /** @internal */
2410
+ const unwrap = channel => flatten$1(fromEffect$3(channel));
2411
+ /** @internal */
2412
+ const unwrapScoped = self => concatAllWith(scoped(self), (d, _) => d, (d, _) => d);
2413
+ /** @internal */
2414
+ const unwrapScopedWith$1 = f => concatAllWith(scopedWith$1(f), (d, _) => d, (d, _) => d);
2415
+ /** @internal */
2416
+ const writeChunk = outs => writeChunkWriter(0, outs.length, outs);
2417
+ /** @internal */
2418
+ const writeChunkWriter = (idx, len, chunk) => {
2419
+ return idx === len ? void_ : Effect.pipe(write(Effect.pipe(chunk, Effect.unsafeGet(idx))), flatMap$1(() => writeChunkWriter(idx + 1, len, chunk)));
2420
+ };
2421
+ /** @internal */
2422
+ const zip = /*#__PURE__*/Effect.dual(args => isChannel(args[1]), (self, that, options) => options?.concurrent ? mergeWith(self, {
2423
+ other: that,
2424
+ onSelfDone: exit1 => Await(exit2 => Effect.suspend$1(() => Effect.zip$1(exit1, exit2))),
2425
+ onOtherDone: exit2 => Await(exit1 => Effect.suspend$1(() => Effect.zip$1(exit1, exit2)))
2426
+ }) : flatMap$1(self, a => map$1(that, b => [a, b])));
2427
+ /** @internal */
2428
+ const zipRight = /*#__PURE__*/Effect.dual(args => isChannel(args[1]), (self, that, options) => options?.concurrent ? map$1(zip(self, that, {
2429
+ concurrent: true
2430
+ }), tuple => tuple[1]) : flatMap$1(self, () => that));
2431
+ /** @internal */
2432
+ const ChannelExceptionTypeId = /*#__PURE__*/Symbol.for("effect/Channel/ChannelException");
2433
+ /** @internal */
2434
+ const ChannelException = error => ({
2435
+ _tag: "ChannelException",
2436
+ [ChannelExceptionTypeId]: ChannelExceptionTypeId,
2437
+ error
2438
+ });
2439
+ /** @internal */
2440
+ const isChannelException = u => Effect.hasProperty(u, ChannelExceptionTypeId);
2441
+
2442
+ /** @internal */
2443
+ const SinkTypeId = /*#__PURE__*/Symbol.for("effect/Sink");
2444
+ const sinkVariance = {
2445
+ /* c8 ignore next */
2446
+ _A: _ => _,
2447
+ /* c8 ignore next */
2448
+ _In: _ => _,
2449
+ /* c8 ignore next */
2450
+ _L: _ => _,
2451
+ /* c8 ignore next */
2452
+ _E: _ => _,
2453
+ /* c8 ignore next */
2454
+ _R: _ => _
2455
+ };
2456
+ /** @internal */
2457
+ class SinkImpl {
2458
+ channel;
2459
+ [SinkTypeId] = sinkVariance;
2460
+ constructor(channel) {
2461
+ this.channel = channel;
2462
+ }
2463
+ pipe() {
2464
+ return Effect.pipeArguments(this, arguments);
2465
+ }
2466
+ }
2467
+ /** @internal */
2468
+ const drain = /*#__PURE__*/new SinkImpl(/*#__PURE__*/drain$1(/*#__PURE__*/identityChannel()));
2469
+ /** @internal */
2470
+ const fromEffect$1 = effect => new SinkImpl(fromEffect$3(effect));
2471
+ /** @internal */
2472
+ const toChannel$1 = self => Effect.isEffect(self) ? toChannel$1(fromEffect$1(self)) : self.channel;
2473
+
2474
+ /** @internal */
2475
+ const TakeSymbolKey = "effect/Take";
2476
+ /** @internal */
2477
+ const TakeTypeId = /*#__PURE__*/Symbol.for(TakeSymbolKey);
2478
+ const takeVariance = {
2479
+ /* c8 ignore next */
2480
+ _A: _ => _,
2481
+ /* c8 ignore next */
2482
+ _E: _ => _
2483
+ };
2484
+ /** @internal */
2485
+ class TakeImpl {
2486
+ exit;
2487
+ [TakeTypeId] = takeVariance;
2488
+ constructor(exit) {
2489
+ this.exit = exit;
2490
+ }
2491
+ pipe() {
2492
+ return Effect.pipeArguments(this, arguments);
2493
+ }
2494
+ }
2495
+ /** @internal */
2496
+ const chunk = chunk => new TakeImpl(Effect.succeed$2(chunk));
2497
+ /** @internal */
2498
+ const end$1 = /*#__PURE__*/new TakeImpl(/*#__PURE__*/Effect.fail$1(/*#__PURE__*/Effect.none()));
2499
+ /** @internal */
2500
+ const failCause$1 = cause => new TakeImpl(Effect.failCause(Effect.pipe(cause, map$2(Effect.some))));
2501
+ /** @internal */
2502
+ const of = value => new TakeImpl(Effect.succeed$2(Effect.of(value)));
2503
+
2504
+ /** @internal */
2505
+ const end = () => Effect.fail$2(Effect.none());
2506
+ /** @internal */
2507
+ const failCause = cause => Effect.mapError(Effect.failCause$1(cause), Effect.some);
2508
+
2509
+ /** @internal */
2510
+ const StreamSymbolKey = "effect/Stream";
2511
+ /** @internal */
2512
+ const StreamTypeId = /*#__PURE__*/Symbol.for(StreamSymbolKey);
2513
+ /** @internal */
2514
+ const streamVariance = {
2515
+ _R: _ => _,
2516
+ _E: _ => _,
2517
+ _A: _ => _
2518
+ };
2519
+ /** @internal */
2520
+ class StreamImpl {
2521
+ channel;
2522
+ [StreamTypeId] = streamVariance;
2523
+ constructor(channel) {
2524
+ this.channel = channel;
2525
+ }
2526
+ pipe() {
2527
+ return Effect.pipeArguments(this, arguments);
2528
+ }
2529
+ }
2530
+ /** @internal */
2531
+ const isStream = u => Effect.hasProperty(u, StreamTypeId) || Effect.isEffect(u);
2532
+ /** @internal */
2533
+ const DefaultChunkSize = 4096;
2534
+ /** @internal */
2535
+ const ensuring = /*#__PURE__*/Effect.dual(2, (self, finalizer) => new StreamImpl(Effect.pipe(toChannel(self), ensuring$1(finalizer))));
2536
+ /** @internal */
2537
+ const flatMap = /*#__PURE__*/Effect.dual(args => isStream(args[0]), (self, f, options) => {
2538
+ const bufferSize = options?.bufferSize ?? 16;
2539
+ if (options?.switch) {
2540
+ return matchConcurrency(options?.concurrency, () => flatMapParSwitchBuffer(self, 1, bufferSize, f), n => flatMapParSwitchBuffer(self, n, bufferSize, f));
2541
+ }
2542
+ return matchConcurrency(options?.concurrency, () => new StreamImpl(concatMap(toChannel(self), as => Effect.pipe(as, Effect.map$4(a => toChannel(f(a))), Effect.reduce(void_, (left, right) => Effect.pipe(left, zipRight(right)))))), _ => new StreamImpl(Effect.pipe(toChannel(self), concatMap(writeChunk), mergeMap(out => toChannel(f(out)), options))));
2543
+ });
2544
+ /** @internal */
2545
+ const matchConcurrency = (concurrency, sequential, bounded) => {
2546
+ switch (concurrency) {
2547
+ case undefined:
2548
+ return sequential();
2549
+ case "unbounded":
2550
+ return bounded(Number.MAX_SAFE_INTEGER);
2551
+ default:
2552
+ return concurrency > 1 ? bounded(concurrency) : sequential();
2553
+ }
2554
+ };
2555
+ const flatMapParSwitchBuffer = /*#__PURE__*/Effect.dual(4, (self, n, bufferSize, f) => new StreamImpl(Effect.pipe(toChannel(self), concatMap(writeChunk), mergeMap(out => toChannel(f(out)), {
2556
+ concurrency: n,
2557
+ mergeStrategy: BufferSliding(),
2558
+ bufferSize
2559
+ }))));
2560
+ /** @internal */
2561
+ const flatten = /*#__PURE__*/Effect.dual(args => isStream(args[0]), (self, options) => flatMap(self, Effect.identity, options));
2562
+ /** @internal */
2563
+ const flattenChunks = self => {
2564
+ const flatten = readWithCause({
2565
+ onInput: chunks => flatMap$1(writeChunk(chunks), () => flatten),
2566
+ onFailure: failCause$2,
2567
+ onDone: () => void_
2568
+ });
2569
+ return new StreamImpl(Effect.pipe(toChannel(self), pipeTo(flatten)));
2570
+ };
2571
+ /** @internal */
2572
+ const flattenExitOption = self => {
2573
+ const processChunk = (chunk, cont) => {
2574
+ const [toEmit, rest] = Effect.pipe(chunk, Effect.splitWhere(exit => !Effect.isSuccess(exit)));
2575
+ const next = Effect.pipe(Effect.head(rest), Effect.match({
2576
+ onNone: () => cont,
2577
+ onSome: Effect.match$2({
2578
+ onFailure: cause => Effect.match(flipCauseOption(cause), {
2579
+ onNone: () => void_,
2580
+ onSome: failCause$2
2581
+ }),
2582
+ onSuccess: () => void_
2583
+ })
2584
+ }));
2585
+ return Effect.pipe(write(Effect.pipe(toEmit, Effect.filterMap(exit => Effect.isSuccess(exit) ? Effect.some(exit.value) : Effect.none()))), flatMap$1(() => next));
2586
+ };
2587
+ const process = readWithCause({
2588
+ onInput: chunk => processChunk(chunk, process),
2589
+ onFailure: cause => failCause$2(cause),
2590
+ onDone: () => void_
2591
+ });
2592
+ return new StreamImpl(Effect.pipe(toChannel(self), pipeTo(process)));
2593
+ };
2594
+ /** @internal */
2595
+ const flattenTake = self => flattenChunks(flattenExitOption(Effect.pipe(self, map(take => take.exit))));
2596
+ /** @internal */
2597
+ const toChannel = stream => {
2598
+ if ("channel" in stream) {
2599
+ return stream.channel;
2600
+ } else if (Effect.isEffect(stream)) {
2601
+ return toChannel(fromEffect(stream));
2602
+ } else {
2603
+ throw new TypeError(`Expected a Stream.`);
2604
+ }
2605
+ };
2606
+ /** @internal */
2607
+ const fromEffect = effect => Effect.pipe(effect, Effect.mapError(Effect.some), fromEffectOption);
2608
+ /** @internal */
2609
+ const fromEffectOption = effect => new StreamImpl(unwrap(Effect.match$3(effect, {
2610
+ onFailure: Effect.match({
2611
+ onNone: () => void_,
2612
+ onSome: fail
2613
+ }),
2614
+ onSuccess: a => write(Effect.of(a))
2615
+ })));
2616
+ /** @internal */
2617
+ const fromQueue$1 = (queue, options) => Effect.pipe(takeBetween(queue, 1, options?.maxChunkSize ?? DefaultChunkSize), Effect.catchAllCause(cause => Effect.pipe(isShutdown(queue), Effect.flatMap$1(isShutdown => isShutdown && isInterrupted(cause) ? end() : failCause(cause)))), repeatEffectChunkOption, options?.shutdown ? ensuring(shutdown(queue)) : Effect.identity);
2618
+ /** @internal */
2619
+ const map = /*#__PURE__*/Effect.dual(2, (self, f) => new StreamImpl(Effect.pipe(toChannel(self), mapOut(Effect.map$4(f)))));
2620
+ /** @internal */
2621
+ const mapEffectSequential = /*#__PURE__*/Effect.dual(2, (self, f) => {
2622
+ const loop = iterator => {
2623
+ const next = iterator.next();
2624
+ if (next.done) {
2625
+ return readWithCause({
2626
+ onInput: elem => loop(elem[Symbol.iterator]()),
2627
+ onFailure: failCause$2,
2628
+ onDone: succeed
2629
+ });
2630
+ } else {
2631
+ const value = next.value;
2632
+ return unwrap(Effect.map$2(f(value), a2 => flatMap$1(write(Effect.of(a2)), () => loop(iterator))));
2633
+ }
2634
+ };
2635
+ return new StreamImpl(Effect.pipe(toChannel(self), pipeTo(suspend$1(() => loop(Effect.empty$2()[Symbol.iterator]())))));
2636
+ });
2637
+ /** @internal */
2638
+ const mapEffectPar = /*#__PURE__*/Effect.dual(3, (self, n, f) => new StreamImpl(Effect.pipe(toChannel(self), concatMap(writeChunk), mapOutEffectPar(f, n), mapOut(Effect.of))));
2639
+ /** @internal */
2640
+ const repeatEffectChunkOption = effect => unfoldChunkEffect(effect, effect => Effect.pipe(Effect.map$2(effect, chunk => Effect.some([chunk, effect])), Effect.catchAll(Effect.match({
2641
+ onNone: () => Effect.succeed(Effect.none()),
2642
+ onSome: Effect.fail$2
2643
+ }))));
2644
+ /** @internal */
2645
+ const run = /*#__PURE__*/Effect.dual(2, (self, sink) => toChannel(self).pipe(pipeToOrFail(toChannel$1(sink)), runDrain$2));
2646
+ /** @internal */
2647
+ const runDrain$1 = self => run(self, drain);
2648
+ /** @internal */
2649
+ const scopedWith = f => new StreamImpl(scopedWith$1(scope => f(scope).pipe(Effect.map$2(Effect.of))));
2650
+ /** @internal */
2651
+ const suspend = stream => new StreamImpl(suspend$1(() => toChannel(stream())));
2652
+ /** @internal */
2653
+ const unfoldChunkEffect = (s, f) => suspend(() => {
2654
+ const loop = s => unwrap(Effect.map$2(f(s), Effect.match({
2655
+ onNone: () => void_,
2656
+ onSome: ([chunk, s]) => flatMap$1(write(chunk), () => loop(s))
2657
+ })));
2658
+ return new StreamImpl(loop(s));
2659
+ });
2660
+ /** @internal */
2661
+ const unwrapScopedWith = f => flatten(scopedWith(scope => f(scope)));
2662
+
2663
+ /** @internal */
2664
+ const GroupBySymbolKey = "effect/GroupBy";
2665
+ /** @internal */
2666
+ const GroupByTypeId = /*#__PURE__*/Symbol.for(GroupBySymbolKey);
2667
+ const groupByVariance = {
2668
+ /* c8 ignore next */
2669
+ _R: _ => _,
2670
+ /* c8 ignore next */
2671
+ _E: _ => _,
2672
+ /* c8 ignore next */
2673
+ _K: _ => _,
2674
+ /* c8 ignore next */
2675
+ _V: _ => _
2676
+ };
2677
+ /** @internal */
2678
+ const isGroupBy = u => Effect.hasProperty(u, GroupByTypeId);
2679
+ /** @internal */
2680
+ const evaluate = /*#__PURE__*/Effect.dual(args => isGroupBy(args[0]), (self, f, options) => flatMap(self.grouped, ([key, queue]) => f(key, flattenTake(fromQueue$1(queue, {
2681
+ shutdown: true
2682
+ }))), {
2683
+ concurrency: "unbounded",
2684
+ bufferSize: options?.bufferSize ?? 16
2685
+ }));
2686
+ /** @internal */
2687
+ const make = grouped => ({
2688
+ [GroupByTypeId]: groupByVariance,
2689
+ pipe() {
2690
+ return Effect.pipeArguments(this, arguments);
2691
+ },
2692
+ grouped
2693
+ });
2694
+ /** @internal */
2695
+ const mapEffectOptions = /*#__PURE__*/Effect.dual(args => typeof args[0] !== "function", (self, f, options) => {
2696
+ if (options?.key) {
2697
+ return evaluate(groupByKey(self, options.key, {
2698
+ bufferSize: options.bufferSize
2699
+ }), (_, s) => mapEffectSequential(s, f));
2700
+ }
2701
+ return matchConcurrency(options?.concurrency, () => mapEffectSequential(self, f), n => options?.unordered ? flatMap(self, a => fromEffect(f(a)), {
2702
+ concurrency: n
2703
+ }) : mapEffectPar(self, n, f));
2704
+ });
2705
+ /** @internal */
2706
+ const groupByKey = /*#__PURE__*/Effect.dual(args => typeof args[0] !== "function", (self, f, options) => {
2707
+ const loop = (map, outerQueue) => readWithCause({
2708
+ onInput: input => flatMap$1(fromEffect$3(Effect.forEach(groupByIterable(input, f), ([key, values]) => {
2709
+ const innerQueue = map.get(key);
2710
+ if (innerQueue === undefined) {
2711
+ return Effect.pipe(bounded(options?.bufferSize ?? 16), Effect.flatMap$1(innerQueue => Effect.pipe(Effect.sync$1(() => {
2712
+ map.set(key, innerQueue);
2713
+ }), Effect.zipRight$2(offer(outerQueue, of([key, innerQueue]))), Effect.zipRight$2(Effect.pipe(offer(innerQueue, chunk(values)), Effect.catchSomeCause(cause => isInterruptedOnly(cause) ? Effect.some(Effect._void) : Effect.none()))))));
2714
+ }
2715
+ return Effect.catchSomeCause(offer(innerQueue, chunk(values)), cause => isInterruptedOnly(cause) ? Effect.some(Effect._void) : Effect.none());
2716
+ }, {
2717
+ discard: true
2718
+ })), () => loop(map, outerQueue)),
2719
+ onFailure: cause => fromEffect$3(offer(outerQueue, failCause$1(cause))),
2720
+ onDone: () => fromEffect$3(Effect.pipe(Effect.forEach(map.entries(), ([_, innerQueue]) => Effect.pipe(offer(innerQueue, end$1), Effect.catchSomeCause(cause => isInterruptedOnly(cause) ? Effect.some(Effect._void) : Effect.none())), {
2721
+ discard: true
2722
+ }), Effect.zipRight$2(offer(outerQueue, end$1))))
2723
+ });
2724
+ return make(unwrapScopedWith(scope => Effect.gen(function* () {
2725
+ const map = new Map();
2726
+ const queue = yield* unbounded();
2727
+ yield* Effect.addFinalizer(scope, shutdown(queue));
2728
+ return yield* toChannel(self).pipe(pipeTo(loop(map, queue)), drain$1, runIn(scope), Effect.forkIn(scope), Effect.as(flattenTake(fromQueue$1(queue, {
2729
+ shutdown: true
2730
+ }))));
2731
+ })));
2732
+ });
2733
+ /**
2734
+ * A variant of `groupBy` that retains the insertion order of keys.
2735
+ *
2736
+ * @internal
2737
+ */
2738
+ const groupByIterable = /*#__PURE__*/Effect.dual(2, (iterable, f) => {
2739
+ const builder = [];
2740
+ const iterator = iterable[Symbol.iterator]();
2741
+ const map = new Map();
2742
+ let next;
2743
+ while ((next = iterator.next()) && !next.done) {
2744
+ const value = next.value;
2745
+ const key = f(value);
2746
+ if (map.has(key)) {
2747
+ const innerBuilder = map.get(key);
2748
+ innerBuilder.push(value);
2749
+ } else {
2750
+ const innerBuilder = [value];
2751
+ builder.push([key, innerBuilder]);
2752
+ map.set(key, innerBuilder);
2753
+ }
2754
+ }
2755
+ return Effect.unsafeFromArray(builder.map(tuple => [tuple[0], Effect.unsafeFromArray(tuple[1])]));
2756
+ });
2757
+
2758
+ /**
2759
+ * Creates a stream from a queue of values
2760
+ *
2761
+ * **Options**
2762
+ *
2763
+ * - `maxChunkSize`: The maximum number of queued elements to put in one chunk in the stream
2764
+ * - `shutdown`: If `true`, the queue will be shutdown after the stream is evaluated (defaults to `false`)
2765
+ *
2766
+ * @since 2.0.0
2767
+ * @category constructors
2768
+ */
2769
+ const fromQueue = fromQueue$1;
2770
+ /**
2771
+ * Maps over elements of the stream with the specified effectful function.
2772
+ *
2773
+ * @example
2774
+ * ```ts
2775
+ * import { Effect, Random, Stream } from "effect"
2776
+ *
2777
+ * const stream = Stream.make(10, 20, 30).pipe(
2778
+ * Stream.mapEffect((n) => Random.nextIntBetween(0, n))
2779
+ * )
2780
+ *
2781
+ * Effect.runPromise(Stream.runCollect(stream)).then(console.log)
2782
+ * // Example Output: { _id: 'Chunk', values: [ 7, 19, 8 ] }
2783
+ * ```
2784
+ *
2785
+ * @since 2.0.0
2786
+ * @category mapping
2787
+ */
2788
+ const mapEffect = mapEffectOptions;
2789
+ /**
2790
+ * Runs the stream only for its effects. The emitted elements are discarded.
2791
+ *
2792
+ * @since 2.0.0
2793
+ * @category destructors
2794
+ */
2795
+ const runDrain = runDrain$1;
2796
+
2797
+ class ReactiveControllerHost {
2798
+ controllers = new Set();
2799
+ addController(controller) {
2800
+ this.controllers.add(controller);
2801
+ }
2802
+ removeController(controller) {
2803
+ this.controllers.delete(controller);
2804
+ }
2805
+ get activeControllers() {
2806
+ return Array.from(this.controllers).filter(controller => !controller.disabled);
2807
+ }
2808
+ connectedCallback() {
2809
+ if (!this.controllers.size) {
2810
+ console.warn('ReactiveControllerHost connected with no controllers registered.', this);
2811
+ }
2812
+ this.activeControllers.forEach(controller => controller.hostConnected?.());
2813
+ }
2814
+ disconnectedCallback() {
2815
+ this.activeControllers.forEach(controller => controller.hostDisconnected?.());
2816
+ }
2817
+ componentWillLoad() {
2818
+ this.activeControllers.forEach(controller => controller.hostWillLoad?.());
2819
+ }
2820
+ componentDidLoad() {
2821
+ this.activeControllers.forEach(controller => controller.hostDidLoad?.());
2822
+ }
2823
+ componentWillRender() {
2824
+ this.activeControllers.forEach(controller => controller.hostWillRender?.());
2825
+ }
2826
+ componentDidRender() {
2827
+ this.activeControllers.forEach(controller => controller.hostDidRender?.());
2828
+ }
2829
+ componentWillUpdate() {
2830
+ this.activeControllers.forEach(controller => controller.hostWillUpdate?.());
2831
+ }
2832
+ componentDidUpdate() {
2833
+ this.activeControllers.forEach(controller => controller.hostDidUpdate?.());
2834
+ }
2835
+ }
2836
+
2837
+ class AriaValidationController {
2838
+ host;
2839
+ config;
2840
+ static get globalValidationEnabled() {
2841
+ return index.Build.isDev;
2842
+ }
2843
+ static axe = this.globalValidationEnabled ? Promise.resolve().then(function () { return require('./axe-BNqwbBGU.js'); }).then(function (n) { return n.axe; }) : null;
2844
+ static axeQueue = null;
2845
+ static axeStreamFiber = null;
2846
+ visibilityObserver;
2847
+ elementQueued = false;
2848
+ elementValidated = false;
2849
+ knownValidationErrors = [];
2850
+ get disabled() {
2851
+ return true;
2852
+ }
2853
+ constructor(host, config) {
2854
+ this.host = host;
2855
+ this.config = config;
2856
+ AriaValidationController.initializeAxeStream();
2857
+ }
2858
+ static initializeAxeStream() {
2859
+ if (!this.globalValidationEnabled)
2860
+ return;
2861
+ if (this.axeStreamFiber)
2862
+ return;
2863
+ const program = Effect.gen(function* () {
2864
+ const queue = (AriaValidationController.axeQueue = yield* bounded(100));
2865
+ const axeLib = yield* Effect.promise(() => AriaValidationController.axe);
2866
+ if (!axeLib) {
2867
+ console.error('Axe library not available, ARIA validation will not run.');
2868
+ return;
2869
+ }
2870
+ const stream = fromQueue(queue).pipe(mapEffect(({ context, onComplete }) => Effect.async(resume => {
2871
+ axeLib.run(context, {}, (error, results) => {
2872
+ onComplete(error, results);
2873
+ resume(Effect._void);
2874
+ });
2875
+ })));
2876
+ yield* runDrain(stream);
2877
+ });
2878
+ this.axeStreamFiber = Effect.runFork(program);
2879
+ }
2880
+ hostDidLoad() {
2881
+ if (this.elementQueued || this.elementValidated)
2882
+ return;
2883
+ if (!this.host.el.checkVisibility()) {
2884
+ this.observeVisibilityOnce();
2885
+ return;
2886
+ }
2887
+ this.enqueueValidation();
2888
+ }
2889
+ hostDidUpdate() {
2890
+ this.checkLazyValidation();
2891
+ }
2892
+ hostDisconnected() {
2893
+ this.discardVisibilityObserver();
2894
+ }
2895
+ observeVisibilityOnce() {
2896
+ this.visibilityObserver = new IntersectionObserver(entries => {
2897
+ for (const entry of entries) {
2898
+ if (entry.target !== this.host.el)
2899
+ continue;
2900
+ if (!entry.isIntersecting)
2901
+ continue;
2902
+ this.checkLazyValidation();
2903
+ this.discardVisibilityObserver();
2904
+ }
2905
+ }, {
2906
+ root: this.host.el.parentElement,
2907
+ rootMargin: '0px',
2908
+ threshold: 0.01,
2909
+ });
2910
+ this.visibilityObserver.observe(this.host.el);
2911
+ }
2912
+ checkLazyValidation() {
2913
+ if (!this.config?.reValidateOnPropChanges && (this.elementQueued || this.elementValidated))
2914
+ return;
2915
+ this.enqueueValidation();
2916
+ }
2917
+ enqueueValidation() {
2918
+ return;
2919
+ }
2920
+ discardVisibilityObserver() {
2921
+ if (!this.visibilityObserver)
2922
+ return;
2923
+ this.visibilityObserver.disconnect();
2924
+ this.visibilityObserver = undefined;
2925
+ }
2926
+ }
2927
+
2928
+ exports.AriaValidationController = AriaValidationController;
2929
+ exports.ReactiveControllerHost = ReactiveControllerHost;