@visulima/email 2.1.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE.md +159 -19
  3. package/dist/crypto/index.d.ts +50 -47
  4. package/dist/crypto/index.js +1 -1
  5. package/dist/deliverability/dmarc-report.js +1 -1
  6. package/dist/deliverability/index.js +1 -1
  7. package/dist/events/index.js +1 -1
  8. package/dist/inbound/index.js +1 -1
  9. package/dist/index.d.ts +2 -3
  10. package/dist/index.js +1 -1
  11. package/dist/middleware/index.d.ts +19 -6
  12. package/dist/middleware/index.js +1 -1
  13. package/dist/packem_chunks/index.js +27 -0
  14. package/dist/packem_shared/ALL_EVENTS-CSpGgYbV.js +1 -0
  15. package/dist/packem_shared/DkimSigner-CCxFKitN.js +4 -0
  16. package/dist/packem_shared/DraftMailMessage-B0gwf8n_.js +1 -0
  17. package/dist/packem_shared/EmailError-BIaHK1Uw.js +1 -0
  18. package/dist/packem_shared/Mail-DmYNQ0KK.js +1 -0
  19. package/dist/packem_shared/MailMessage-DmmaNHHc.js +1 -0
  20. package/dist/packem_shared/MemorySuppressionStore-D_bge6rS.js +1 -0
  21. package/dist/packem_shared/RATE_LIMIT_PRESETS-BIFmRuh2.js +1 -0
  22. package/dist/packem_shared/RequiredOptionError-ctDEEB1s.js +1 -0
  23. package/dist/packem_shared/SmimeEncrypter-DnlfpjUX.js +6 -0
  24. package/dist/packem_shared/SmimeSigner-DTvclzLq.js +8 -0
  25. package/dist/packem_shared/address-formatter-w36S9ZYj.js +1 -0
  26. package/dist/packem_shared/aggregate-features-Bst55u8k.js +1 -0
  27. package/dist/packem_shared/ahaSendProvider-C1qvG8Cj.js +1 -0
  28. package/dist/packem_shared/arcMessageSignatureBase-su9VTRB7.js +9 -0
  29. package/dist/packem_shared/attachment-processor-BJFDS343.js +1 -0
  30. package/dist/packem_shared/autoSendProvider-yxUx3sEj.js +1 -0
  31. package/dist/packem_shared/awsSesProvider-DTnLwAbE.js +32 -0
  32. package/dist/packem_shared/azureProvider-CLLRKtOf.js +1 -0
  33. package/dist/packem_shared/brevoProvider-CHlodyzV.js +1 -0
  34. package/dist/packem_shared/build-mime-message-BCFKPqaW.js +3 -0
  35. package/dist/packem_shared/buildListUnsubscribe-g1CoihSv.js +1 -0
  36. package/dist/packem_shared/buildMtaStsPolicy-BA2YXL72.js +6 -0
  37. package/dist/packem_shared/canonicalize-BEjQUnUe.js +11 -0
  38. package/dist/packem_shared/circuitBreakerMiddleware-DcBN7K6H.js +1 -0
  39. package/dist/packem_shared/cloudflareEmailProvider-Ckh_u-0D.js +1 -0
  40. package/dist/packem_shared/composeMiddleware-B3RCDFsy.js +1 -0
  41. package/dist/packem_shared/create-logger-CazqtXcL.js +1 -0
  42. package/dist/packem_shared/create-token-cache-BdMsMzf7.js +1 -0
  43. package/dist/packem_shared/createSuppressionStore-DbocihI8.js +1 -0
  44. package/dist/packem_shared/createTestEmail-sB6z8m6Z.js +1 -0
  45. package/dist/packem_shared/createWorker-ChuTgETP.js +1 -0
  46. package/dist/packem_shared/dedupeMiddleware-BTo8Qjje.js +1 -0
  47. package/dist/packem_shared/defineInboundHandler-CnYn10ex.js +1 -0
  48. package/dist/packem_shared/detectMimeType-BRz3Qjyz.js +1 -0
  49. package/dist/packem_shared/emailMatchers-DpwItmkN.js +1 -0
  50. package/dist/packem_shared/extractReply-CLoWMY97.js +5 -0
  51. package/dist/packem_shared/failoverProvider-DSsuXHYK.js +1 -0
  52. package/dist/packem_shared/format-address-Bb7xk8G_.js +1 -0
  53. package/dist/packem_shared/{generate-boundary-0xGe9GqK.js → generate-boundary-BCSUEi6x.js} +1 -1
  54. package/dist/packem_shared/generate-message-id-B2n2yqR6.js +1 -0
  55. package/dist/packem_shared/headers-to-record-ZOZ7Dubo.js +1 -0
  56. package/dist/packem_shared/httpProvider-CdoJ-tL7.js +1 -0
  57. package/dist/packem_shared/infobipProvider-BEu1ycxS.js +1 -0
  58. package/dist/packem_shared/isValidSigningCertUrl-CK1t2a7x.js +3 -0
  59. package/dist/packem_shared/loggingMiddleware-DNVf8O1B.js +1 -0
  60. package/dist/packem_shared/loopsProvider-CKJ_rzLq.js +1 -0
  61. package/dist/packem_shared/{mail.d-B9JyPxzq.d.ts → mail.d-BdyyyQO5.d.ts} +11 -9
  62. package/dist/packem_shared/mailCrabProvider-BQ5ELwPU.js +1 -0
  63. package/dist/packem_shared/mailPaceProvider-Ca3cz8JU.js +1 -0
  64. package/dist/packem_shared/mailchannelsProvider-BZeuZk3d.js +1 -0
  65. package/dist/packem_shared/mailerSendProvider-C_Db652T.js +1 -0
  66. package/dist/packem_shared/mailgunProvider-CU2b8ie8.js +1 -0
  67. package/dist/packem_shared/mailjetProvider-VqvqCS7I.js +1 -0
  68. package/dist/packem_shared/mailomatProvider-FMk4FZZz.js +1 -0
  69. package/dist/packem_shared/mailtrapProvider-Qs0exKiJ.js +1 -0
  70. package/dist/packem_shared/make-request-Cyz5_yu8.js +1 -0
  71. package/dist/packem_shared/mandrillProvider-Co_EfMxl.js +1 -0
  72. package/dist/packem_shared/mockProvider-Bf5eJ_rl.js +1 -0
  73. package/dist/packem_shared/netcoreProvider-_kXjZ0bE.js +1 -0
  74. package/dist/packem_shared/nodemailerProvider-CJ4zkTPF.js +1 -0
  75. package/dist/packem_shared/normalizeMessageId-0yB1zeyC.js +1 -0
  76. package/dist/packem_shared/oauth2Middleware-C0M1w3_2.js +1 -0
  77. package/dist/packem_shared/opentelemetryProvider-s0gvh05u.js +1 -0
  78. package/dist/packem_shared/outlook365Provider-DKMz0Vvh.js +1 -0
  79. package/dist/packem_shared/parseAddress-DW9suGjV.js +1 -0
  80. package/dist/packem_shared/parseArfReport-VbQeofN4.js +6 -0
  81. package/dist/packem_shared/parseCloudflareInbound-BKZzk0De.js +1 -0
  82. package/dist/packem_shared/parseDmarcRecord-9B3Qhba8.js +1 -0
  83. package/dist/packem_shared/parseMailgunInbound-nY-DXZrK.js +1 -0
  84. package/dist/packem_shared/parsePostmarkInbound-0zG71J7F.js +1 -0
  85. package/dist/packem_shared/parseSendGridInbound-BzEhN-gd.js +4 -0
  86. package/dist/packem_shared/parseSesInbound-C4cRtAUq.js +1 -0
  87. package/dist/packem_shared/parseTlsReport-DSiCaKFH.js +1 -0
  88. package/dist/packem_shared/plunkProvider-B-JtCJQy.js +1 -0
  89. package/dist/packem_shared/postalProvider-tEBNXL3h.js +1 -0
  90. package/dist/packem_shared/postmarkProvider-DdavP5x5.js +1 -0
  91. package/dist/packem_shared/provider-base-BEz00m9R.js +1 -0
  92. package/dist/packem_shared/quoted-printable-BgiHOYdV.js +7 -0
  93. package/dist/packem_shared/resendProvider-CMtlyIye.js +1 -0
  94. package/dist/packem_shared/retry-aghj7y8m.js +1 -0
  95. package/dist/packem_shared/retryMiddleware-CaTv0UIm.js +1 -0
  96. package/dist/packem_shared/roundRobinProvider-Dr1DdT2L.js +1 -0
  97. package/dist/packem_shared/sanitize-header-CW0f3IT7.js +1 -0
  98. package/dist/packem_shared/scalewayProvider-BFA1PQ73.js +1 -0
  99. package/dist/packem_shared/sendGridProvider-DV80Lg7a.js +1 -0
  100. package/dist/packem_shared/smtpProvider-BCEzJmay.js +14 -0
  101. package/dist/packem_shared/sparkpostProvider-C3pATjJX.js +1 -0
  102. package/dist/packem_shared/sweegoProvider-CkFtUAzq.js +1 -0
  103. package/dist/packem_shared/toEmailSnapshot-BOhTn44E.js +1 -0
  104. package/dist/packem_shared/{types.d-B0t3PQ3t.d.ts → types.d-Cb5fls_X.d.ts} +1 -1
  105. package/dist/packem_shared/utils-CDV8xy3e.js +1 -0
  106. package/dist/packem_shared/validate-email-options-DxdAVLlu.js +1 -0
  107. package/dist/packem_shared/{verifyMailgunWebhook-DNk080BF.js → verifyMailgunWebhook-DS4o0kZL.js} +1 -1
  108. package/dist/packem_shared/{verifyPostmarkWebhook-B4OIEHQF.js → verifyPostmarkWebhook-pLwWmeOl.js} +1 -1
  109. package/dist/packem_shared/verifyResendWebhook-D3GuwWjv.js +1 -0
  110. package/dist/packem_shared/verifySendGridWebhook-csuRasH3.js +1 -0
  111. package/dist/packem_shared/withEvents-BinK2hMw.js +1 -0
  112. package/dist/packem_shared/withMetrics-i3mZVfeE.js +1 -0
  113. package/dist/packem_shared/withRender-Ce6leoYE.js +1 -0
  114. package/dist/packem_shared/withSuppression-B0eZ2xNQ.js +1 -0
  115. package/dist/packem_shared/{withTelemetry-DL2qo0Hp.js → withTelemetry-DEKTis1I.js} +1 -1
  116. package/dist/packem_shared/zeptomailProvider-tqRYpQlv.js +1 -0
  117. package/dist/providers/ahasend/index.js +1 -1
  118. package/dist/providers/autosend/index.js +1 -1
  119. package/dist/providers/aws-ses/index.js +1 -1
  120. package/dist/providers/azure/index.js +1 -1
  121. package/dist/providers/brevo/index.js +1 -1
  122. package/dist/providers/cloudflare-email/index.d.ts +17 -1
  123. package/dist/providers/cloudflare-email/index.js +1 -1
  124. package/dist/providers/failover/index.js +1 -1
  125. package/dist/providers/http/index.js +1 -1
  126. package/dist/providers/infobip/index.js +1 -1
  127. package/dist/providers/loops/index.js +1 -1
  128. package/dist/providers/mailchannels/index.js +1 -1
  129. package/dist/providers/mailcrab/index.js +1 -1
  130. package/dist/providers/mailersend/index.js +1 -1
  131. package/dist/providers/mailgun/index.js +1 -1
  132. package/dist/providers/mailjet/index.js +1 -1
  133. package/dist/providers/mailomat/index.js +1 -1
  134. package/dist/providers/mailpace/index.js +1 -1
  135. package/dist/providers/mailtrap/index.js +1 -1
  136. package/dist/providers/mandrill/index.js +1 -1
  137. package/dist/providers/mock/index.js +1 -1
  138. package/dist/providers/netcore/index.js +1 -1
  139. package/dist/providers/nodemailer/index.js +1 -1
  140. package/dist/providers/opentelemetry/index.d.ts +1 -1
  141. package/dist/providers/opentelemetry/index.js +1 -1
  142. package/dist/providers/outlook365/index.js +1 -1
  143. package/dist/providers/plunk/index.js +1 -1
  144. package/dist/providers/postal/index.js +1 -1
  145. package/dist/providers/postmark/index.js +1 -1
  146. package/dist/providers/resend/index.js +1 -1
  147. package/dist/providers/roundrobin/index.js +1 -1
  148. package/dist/providers/scaleway/index.js +1 -1
  149. package/dist/providers/sendgrid/index.js +1 -1
  150. package/dist/providers/smtp/index.d.ts +9 -5
  151. package/dist/providers/smtp/index.js +1 -1
  152. package/dist/providers/sparkpost/index.js +1 -1
  153. package/dist/providers/sweego/index.js +1 -1
  154. package/dist/providers/zeptomail/index.js +1 -1
  155. package/dist/queue/bullmq-queue.js +1 -1
  156. package/dist/queue/index.js +1 -1
  157. package/dist/queue/pg-boss-queue.js +1 -1
  158. package/dist/queue/sqs-queue.js +1 -1
  159. package/dist/queue/unstorage-queue.js +1 -1
  160. package/dist/render/cid.js +1 -1
  161. package/dist/render/css-inline.js +1 -1
  162. package/dist/render/dark-mode.js +1 -1
  163. package/dist/render/preheader.js +1 -1
  164. package/dist/template-engines/handlebars.js +1 -1
  165. package/dist/template-engines/html-to-text.js +1 -1
  166. package/dist/template-engines/i18n.js +1 -1
  167. package/dist/template-engines/jsx-email.js +1 -1
  168. package/dist/template-engines/liquid.js +1 -1
  169. package/dist/template-engines/mjml.js +1 -1
  170. package/dist/template-engines/react-email.js +1 -1
  171. package/dist/template-engines/vue-email.js +1 -1
  172. package/dist/test/index.d.ts +2 -3
  173. package/dist/test/index.js +1 -1
  174. package/dist/utils/cache.js +1 -1
  175. package/dist/utils/format-email-address.js +1 -1
  176. package/dist/utils/parse-address.js +1 -1
  177. package/dist/utils/parse-eml.js +4 -4
  178. package/dist/utils/result.js +1 -1
  179. package/dist/utils/validation/check-feature-support.js +1 -1
  180. package/dist/utils/validation/validate-email.js +1 -1
  181. package/dist/webhooks/index.js +1 -1
  182. package/package.json +6 -6
  183. package/dist/packem_shared/ALL_EVENTS-3kwh5CBE.js +0 -1
  184. package/dist/packem_shared/DkimSigner-udCl3JXO.js +0 -18
  185. package/dist/packem_shared/DraftMailMessage-BgP1OF1G.js +0 -1
  186. package/dist/packem_shared/EmailError-2CCyVX1S.js +0 -1
  187. package/dist/packem_shared/Mail-DduRntbB.js +0 -1
  188. package/dist/packem_shared/MailMessage-BRBT4Jea.js +0 -1
  189. package/dist/packem_shared/MemorySuppressionStore-DZnbz-_B.js +0 -1
  190. package/dist/packem_shared/RATE_LIMIT_PRESETS-BPADLgcA.js +0 -1
  191. package/dist/packem_shared/RequiredOptionError-BmpC5whN.js +0 -1
  192. package/dist/packem_shared/SmimeEncrypter-Dm9McVTQ.js +0 -6
  193. package/dist/packem_shared/SmimeSigner-B6hkacNk.js +0 -8
  194. package/dist/packem_shared/address-formatter-bfmGfQ83.js +0 -1
  195. package/dist/packem_shared/aggregate-features-BqEjPd42.js +0 -1
  196. package/dist/packem_shared/ahaSendProvider-C6nBGCCa.js +0 -1
  197. package/dist/packem_shared/arcMessageSignatureBase-B2uArM48.js +0 -17
  198. package/dist/packem_shared/attachment-processor-DjbjtJ6H.js +0 -1
  199. package/dist/packem_shared/autoSendProvider-Dhig--Zo.js +0 -1
  200. package/dist/packem_shared/awsSesProvider-CMqAmU5N.js +0 -32
  201. package/dist/packem_shared/azureProvider-C-bNOOil.js +0 -1
  202. package/dist/packem_shared/brevoProvider-CkOjDyir.js +0 -1
  203. package/dist/packem_shared/build-mime-message-t8KYiQkO.js +0 -3
  204. package/dist/packem_shared/buildListUnsubscribe-Cdr8MvR_.js +0 -1
  205. package/dist/packem_shared/buildMtaStsPolicy-oEQg8y_C.js +0 -6
  206. package/dist/packem_shared/circuitBreakerMiddleware-BSCPR72q.js +0 -1
  207. package/dist/packem_shared/cloudflareEmailProvider-RCixPWnY.js +0 -1
  208. package/dist/packem_shared/composeMiddleware-BHwLLEzK.js +0 -1
  209. package/dist/packem_shared/create-logger-BQTS3f-I.js +0 -1
  210. package/dist/packem_shared/create-token-cache-D56KQGVQ.js +0 -1
  211. package/dist/packem_shared/createSuppressionStore-CeAZKCbY.js +0 -1
  212. package/dist/packem_shared/createTestEmail-XiF5E8vJ.js +0 -1
  213. package/dist/packem_shared/createWorker-_-yMWcNQ.js +0 -1
  214. package/dist/packem_shared/dedupeMiddleware-CYYI_O7S.js +0 -1
  215. package/dist/packem_shared/defineInboundHandler-CnL2BzlL.js +0 -1
  216. package/dist/packem_shared/detectMimeType-B9_7ujpC.js +0 -1
  217. package/dist/packem_shared/emailMatchers-DZDkrZ_3.js +0 -1
  218. package/dist/packem_shared/extractReply-BUjIBt9A.js +0 -5
  219. package/dist/packem_shared/failoverProvider-BkOOP7pt.js +0 -1
  220. package/dist/packem_shared/format-address-DTl-9O70.js +0 -1
  221. package/dist/packem_shared/generate-message-id-gXAuMz4g.js +0 -1
  222. package/dist/packem_shared/headers-to-record-De1Eg951.js +0 -1
  223. package/dist/packem_shared/httpProvider-6idLfv-f.js +0 -1
  224. package/dist/packem_shared/index-y0s2wQdc.js +0 -11
  225. package/dist/packem_shared/infobipProvider-CHHsqRXy.js +0 -1
  226. package/dist/packem_shared/isValidSigningCertUrl-D7PuiRW4.js +0 -3
  227. package/dist/packem_shared/loggingMiddleware-CZIiVMVp.js +0 -1
  228. package/dist/packem_shared/loopsProvider-Cl-dOuCN.js +0 -1
  229. package/dist/packem_shared/mailCrabProvider-De2YxPlF.js +0 -1
  230. package/dist/packem_shared/mailPaceProvider-DwNTuFb2.js +0 -1
  231. package/dist/packem_shared/mailchannelsProvider-Dwl0Typz.js +0 -1
  232. package/dist/packem_shared/mailerSendProvider-CyMIbqGq.js +0 -1
  233. package/dist/packem_shared/mailgunProvider-DWKJYRKT.js +0 -1
  234. package/dist/packem_shared/mailjetProvider-DXPJQO1G.js +0 -1
  235. package/dist/packem_shared/mailomatProvider-DopZk27y.js +0 -1
  236. package/dist/packem_shared/mailtrapProvider-CTg4z3GN.js +0 -1
  237. package/dist/packem_shared/make-request-CDhxj-9b.js +0 -1
  238. package/dist/packem_shared/mandrillProvider-CAQeMtU_.js +0 -1
  239. package/dist/packem_shared/mockProvider-EcpYlg-_.js +0 -1
  240. package/dist/packem_shared/netcoreProvider-ua1avx07.js +0 -1
  241. package/dist/packem_shared/nodemailerProvider-BZmQfKlM.js +0 -1
  242. package/dist/packem_shared/normalizeMessageId-DAx2pGe2.js +0 -1
  243. package/dist/packem_shared/oauth2Middleware-DQh-hIkv.js +0 -1
  244. package/dist/packem_shared/opentelemetryProvider-CAfWpywa.js +0 -1
  245. package/dist/packem_shared/outlook365Provider-SFYELGDr.js +0 -1
  246. package/dist/packem_shared/parseAddress-DdbViBAJ.js +0 -1
  247. package/dist/packem_shared/parseArfReport-Ds6S3c4J.js +0 -6
  248. package/dist/packem_shared/parseCloudflareInbound-C__j-oNa.js +0 -1
  249. package/dist/packem_shared/parseDmarcRecord-DXZ-_rF0.js +0 -1
  250. package/dist/packem_shared/parseMailgunInbound-BpC6uPNe.js +0 -1
  251. package/dist/packem_shared/parsePostmarkInbound-Co3_c6-9.js +0 -1
  252. package/dist/packem_shared/parseSendGridInbound-DsALoijO.js +0 -4
  253. package/dist/packem_shared/parseSesInbound-CH5tHIjp.js +0 -1
  254. package/dist/packem_shared/parseTlsReport-wPe1lIDs.js +0 -1
  255. package/dist/packem_shared/plunkProvider-9amwuQri.js +0 -1
  256. package/dist/packem_shared/postalProvider-CeF3TOIW.js +0 -1
  257. package/dist/packem_shared/postmarkProvider-BPgKEkgF.js +0 -1
  258. package/dist/packem_shared/provider-base-B-xhQSqE.js +0 -1
  259. package/dist/packem_shared/quoted-printable-nSGDA1tA.js +0 -7
  260. package/dist/packem_shared/resendProvider-C9_sM8bH.js +0 -1
  261. package/dist/packem_shared/retry-D1Rh-6Z4.js +0 -1
  262. package/dist/packem_shared/retryMiddleware-DbViDX4r.js +0 -1
  263. package/dist/packem_shared/roundRobinProvider-BPzLWZf-.js +0 -1
  264. package/dist/packem_shared/sanitize-header-DtQwAnzg.js +0 -1
  265. package/dist/packem_shared/scalewayProvider-DfC7275i.js +0 -1
  266. package/dist/packem_shared/sendGridProvider-CUBBHBzs.js +0 -1
  267. package/dist/packem_shared/smtpProvider-9nBSGtQl.js +0 -27
  268. package/dist/packem_shared/sparkpostProvider-Be_d7S8o.js +0 -1
  269. package/dist/packem_shared/sweegoProvider-CP1cNC-d.js +0 -1
  270. package/dist/packem_shared/toEmailSnapshot-DeRqM5SJ.js +0 -1
  271. package/dist/packem_shared/utils-DjEtR3qT.js +0 -1
  272. package/dist/packem_shared/validate-email-options-mCM9dVug.js +0 -1
  273. package/dist/packem_shared/verifyResendWebhook-C7E32LZ1.js +0 -1
  274. package/dist/packem_shared/verifySendGridWebhook-DtFMgBRP.js +0 -1
  275. package/dist/packem_shared/withEvents-CytsykaK.js +0 -1
  276. package/dist/packem_shared/withMetrics-DWywX_6M.js +0 -1
  277. package/dist/packem_shared/withRender-VP9wE5Yr.js +0 -1
  278. package/dist/packem_shared/withSuppression-wDl4NTb-.js +0 -1
  279. package/dist/packem_shared/zeptomailProvider-BZ0fK0Lk.js +0 -1
@@ -0,0 +1,27 @@
1
+ import{createRequire as wn}from"node:module";let Sn;const xn=t=>(Sn??=wn(import.meta.url))(t),Ct=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,En=t=>{if(typeof Ct<"u"&&Ct.versions&&Ct.versions.node){const[e,s]=Ct.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ct.getBuiltinModule(t)}return xn(t)},{createRequire:H}=En("node:module"),xe=0,Os=4,ba=2,va=1,Ns=Symbol("findUpStop"),An=/^[A-Z]:\//i,Et=(t="")=>t&&t.replaceAll("\\","/").replace(An,e=>e.toUpperCase()),_n=/^[/\\]{2}/,Tn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,We=/^[A-Z]:$/i,Rn=/[^/](\.[^./]+)$/,kn=/^[/\\]|^[a-z]:[/\\]/i,Cn=/\/$/,On=()=>{if(typeof process.cwd=="function")try{const t=process.cwd();if(typeof t=="string")return Et(t)}catch{}return"/"},Ls=(t,e)=>{let s="",n=0,o=-1,r=0,i;for(let c=0;c<=t.length;++c){if(c<t.length)i=t[c];else{if(i==="/")break;i="/"}if(i==="/"){if(!(o===c-1||r===1))if(r===2){if(s.length<2||n!==2||!s.endsWith(".")||s.at(-2)!=="."){if(s.length>2){const u=s.lastIndexOf("/");u===-1?(s="",n=0):(s=s.slice(0,u),n=s.length-1-s.lastIndexOf("/")),o=c,r=0;continue}else if(s.length>0){s="",n=0,o=c,r=0;continue}}e&&(s+=s.length>0?"/..":"..",n=2)}else s.length>0?s+=`/${t.slice(o+1,c)}`:s=t.slice(o+1,c),n=c-o-1;o=c,r=0}else i==="."&&r!==-1?++r:r=-1}return s},St=t=>Tn.test(t),Tt=function(t){if(t.length===0)return".";t=Et(t);const e=_n.exec(t),s=St(t),n=t.at(-1)==="/";return t=Ls(t,!s),t.length===0?s?"/":n?"./":".":(n&&(t+="/"),We.test(t)&&(t+="/"),e?s?`//${t}`:`//./${t}`:s&&!St(t)?`/${t}`:t)},Ee=(...t)=>{let e="";for(const s of t)if(s)if(e.length>0){const n=e.at(-1)==="/",o=s[0]==="/";n&&o?e+=s.slice(1):e+=n||o?s:`/${s}`}else e+=s;return Tt(e)},tt=function(...t){t=t.map(n=>Et(n));let e="",s=!1;for(let n=t.length-1;n>=-1&&!s;n--){const o=n>=0?t[n]:On();!o||o.length===0||(e=`${o}/${e}`,s=St(o))}return e=Ls(e,!s),We.test(e)?`${e}/`:s&&!St(e)?`/${e}`:e.length>0?e:"."},ht=function(t){return Et(t)},Nn=function(t){return Rn.exec(Et(t))?.[1]??""},V=t=>{const e=Et(t).replace(Cn,""),s=e.lastIndexOf("/");if(s===-1)return St(t)?"/":".";const n=e.slice(0,s);return We.test(n)?`${n}/`:n||(St(t)?"/":".")},pe=(t,e)=>{const s=Et(t),n=s.slice(s.lastIndexOf("/")+1);if(e&&n.endsWith(e)){if(e===s)return"";const o=n.slice(0,-e.length);if(o.length>0)return o}return n},Ds=function(t){const e=kn.exec(t)?.[0]?.replaceAll("\\","/")??"",s=pe(t),n=Nn(s);return{base:s,dir:V(t),ext:n,name:s.slice(0,s.length-n.length),root:e}};let Ln;const Dn=t=>(Ln??=H(import.meta.url))(t),Ot=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Fn=t=>{if(typeof Ot<"u"&&Ot.versions&&Ot.versions.node){const[e,s]=Ot.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ot.getBuiltinModule(t)}return Dn(t)},{fileURLToPath:Hn}=Fn("node:url");function In(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ye,Ze;function Bn(){return Ze||(Ze=1,Ye=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Ye}var Mn=Bn();const Pn=In(Mn);new Set(Pn);const F=t=>Et(t instanceof URL?Hn(t):t);let xt=class extends Error{constructor(e){super(`EEXIST: ${e}`)}get code(){return"EEXIST"}set code(e){throw new Error("Cannot overwrite code EEXIST")}get name(){return"AlreadyExistsError"}set name(e){throw new Error("Cannot overwrite name of AlreadyExistsError")}};const P=t=>{if(!t||!(t instanceof URL)&&typeof t!="string")throw new TypeError("Path must be a non-empty string or URL.")};let jn;const Gn=t=>(jn??=H(import.meta.url))(t),Nt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Un=t=>{if(typeof Nt<"u"&&Nt.versions&&Nt.versions.node){const[e,s]=Nt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Nt.getBuiltinModule(t)}return Gn(t)},{cp:qn}=Un("node:fs/promises"),Sa=async(t,e,s={})=>{P(t),P(e);const{dereference:n=!1,errorOnExist:o=!0,filter:r,overwrite:i=!0,preserveTimestamps:c=!1,recursive:u=!0,verbatimSymlinks:y=!1}=s,l=F(t),h=F(e);try{await qn(l,h,{dereference:n,errorOnExist:o,filter:r,force:i,preserveTimestamps:c,recursive:u,verbatimSymlinks:y})}catch($){throw $?.code==="ERR_FS_CP_EEXIST"?new xt(`destination already exists, copy '${h}'`):$}};let zn;const Wn=t=>(zn??=H(import.meta.url))(t),Lt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xn=t=>{if(typeof Lt<"u"&&Lt.versions&&Lt.versions.node){const[e,s]=Lt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Lt.getBuiltinModule(t)}return Wn(t)},{cpSync:Kn}=Xn("node:fs"),xa=(t,e,s={})=>{P(t),P(e);const{dereference:n=!1,errorOnExist:o=!0,filter:r,overwrite:i=!0,preserveTimestamps:c=!1,recursive:u=!0,verbatimSymlinks:y=!1}=s,l=F(t),h=F(e);try{Kn(l,h,{dereference:n,errorOnExist:o,filter:r,force:i,preserveTimestamps:c,recursive:u,verbatimSymlinks:y})}catch($){throw $?.code==="ERR_FS_CP_EEXIST"?new xt(`destination already exists, copy '${h}'`):$}},dt=t=>{if(t.isFile())return"file";if(t.isDirectory())return"dir";if(t.isSymbolicLink())return"symlink"};let Qn;const Vn=t=>(Qn??=H(import.meta.url))(t),Dt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Yn=t=>{if(typeof Dt<"u"&&Dt.versions&&Dt.versions.node){const[e,s]=Dt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Dt.getBuiltinModule(t)}return Vn(t)},{lstat:Je,mkdir:Zn}=Yn("node:fs/promises"),Xe=async t=>{P(t);try{const e=await Je(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await Zn(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const s=await Je(t);if(!s.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(s))}'`,{cause:e})}};let Jn;const tr=t=>(Jn??=H(import.meta.url))(t),Ft=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,er=t=>{if(typeof Ft<"u"&&Ft.versions&&Ft.versions.node){const[e,s]=Ft.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ft.getBuiltinModule(t)}return tr(t)},{lstatSync:ts,mkdirSync:sr}=er("node:fs"),Ke=t=>{P(t);try{const e=ts(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{sr(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const s=ts(t);if(!s.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(s))}'`,{cause:e})}};let nr;const rr=t=>(nr??=H(import.meta.url))(t),Ht=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,or=t=>{if(typeof Ht<"u"&&Ht.versions&&Ht.versions.node){const[e,s]=Ht.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ht.getBuiltinModule(t)}return rr(t)},{lstat:ir,writeFile:cr}=or("node:fs/promises"),Ea=async t=>{P(t);try{const e=await ir(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(dt(e))}'`)}catch(e){if(e.code==="ENOENT"){await Xe(V(F(t))),await cr(t,new Uint8Array);return}throw e}};let ur;const ar=t=>(ur??=H(import.meta.url))(t),It=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,lr=t=>{if(typeof It<"u"&&It.versions&&It.versions.node){const[e,s]=It.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return It.getBuiltinModule(t)}return ar(t)},{lstatSync:pr,writeFileSync:fr}=lr("node:fs"),Aa=t=>{P(t);try{const e=pr(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(dt(e))}'`)}catch(e){if(e.code==="ENOENT"){Ke(V(F(t))),fr(t,new Uint8Array);return}throw e}},ae=(t,e)=>!!e.ino&&!!e.dev&&e.ino===t.ino&&e.dev===t.dev;let hr;const dr=t=>(hr??=H(import.meta.url))(t),Bt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,gr=t=>{if(typeof Bt<"u"&&Bt.versions&&Bt.versions.node){const[e,s]=Bt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Bt.getBuiltinModule(t)}return dr(t)},{lstat:es,link:yr}=gr("node:fs/promises"),_a=async(t,e)=>{P(t),P(e),t=ht(F(t)),e=ht(F(e));let s;try{s=await es(e)}catch{}let n;try{n=await es(t)}catch(o){const r=o;throw r.message=r.message.replace("lstat","ensureLink"),r}s&&ae(n,s)||(await Xe(V(e)),await yr(t,e))};let mr;const $r=t=>(mr??=H(import.meta.url))(t),Mt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,br=t=>{if(typeof Mt<"u"&&Mt.versions&&Mt.versions.node){const[e,s]=Mt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Mt.getBuiltinModule(t)}return $r(t)},{lstatSync:ss,linkSync:vr}=br("node:fs"),Ta=(t,e)=>{P(t),P(e),t=ht(F(t)),e=ht(F(e));let s;try{s=ss(e)}catch{}let n;try{n=ss(t)}catch(o){const r=o;throw r.message=r.message.replace("lstat","ensureLink"),r}s&&ae(n,s)||(Ke(V(e)),vr(t,e))},Fs=(t,e)=>typeof t!="string"?t:t.startsWith("./")?tt(t):typeof e=="string"?tt(V(e),t):new URL(t,e);let wr;const Sr=t=>(wr??=H(import.meta.url))(t),Pt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,xr=t=>{if(typeof Pt<"u"&&Pt.versions&&Pt.versions.node){const[e,s]=Pt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Pt.getBuiltinModule(t)}return Sr(t)},{lstat:Ce,stat:ns,symlink:Er,readlink:Ar}=xr("node:fs/promises"),_r=process.platform==="win32"||/^(?:msys|cygwin)$/.test(process.env.OSTYPE),Ra=async(t,e,s)=>{P(t),P(e);const n=Fs(t,e);e=ht(F(e));try{if((await Ce(e)).isSymbolicLink()){const[c,u]=await Promise.all([ns(n),ns(e)]);if(ae(c,u))return}}catch{}const o=await Ce(n),r=dt(o);await Xe(V(e));let i=s??"file";s||(_r?i="junction":i=r==="dir"?"dir":"file");try{await Er(ht(F(n)),e,i)}catch(c){if(c.code!=="EEXIST")throw c;const u=await Ce(e);if(!u.isSymbolicLink())throw new xt(`A ${String(dt(u))} already exists at the path: ${e}`);const y=await Ar(e),l=ht(tt(y));if(l!==n)throw new xt(`A symlink targeting to an undesired path already exists: ${e} -> ${l}`)}};let Tr;const Rr=t=>(Tr??=H(import.meta.url))(t),jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,kr=t=>{if(typeof jt<"u"&&jt.versions&&jt.versions.node){const[e,s]=jt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return jt.getBuiltinModule(t)}return Rr(t)},{lstatSync:Oe,statSync:$e,symlinkSync:Cr,readlinkSync:Or}=kr("node:fs"),Nr=process.platform==="win32"||/^(?:msys|cygwin)$/.test(process.env.OSTYPE),ka=(t,e,s)=>{P(t),P(e);const n=Fs(t,e);e=ht(F(e));try{if(Oe(e).isSymbolicLink()&&ae($e(n),$e(e))){const c=$e(n),u=$e(e);if(ae(c,u))return}}catch{}const o=Oe(n),r=dt(o);Ke(V(e));let i=s??"file";s||(Nr?i="junction":i=r==="dir"?"dir":"file");try{Cr(ht(F(n)),e,i)}catch(c){if(c.code!=="EEXIST")throw c;const u=Oe(e);if(!u.isSymbolicLink())throw new xt(`A ${String(dt(u))} already exists at the path: ${e}`);const y=Or(e),l=ht(tt(y));if(l!==n)throw new xt(`A symlink targeting to an undesired path already exists: ${e} -> ${l}`)}},Lr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{platform:Dr}=Lr,Hs=/\r?\n/g,Is=`
2
+ `,Ue=`\r
3
+ `,Ca=Dr==="win32"?Ue:Is,Oa=t=>{const e=t.match(Hs);if(!e||e.length===0)return null;const s=e.filter(o=>o===Ue).length,n=e.length-s;return s>n?Ue:Is},Na=(t,e)=>t.replaceAll(Hs,e);let be=class extends Error{root;constructor(e,s){super(`${e instanceof Error?e.message:String(e)} for path "${s}"`),this.cause=e,this.root=s}get name(){return"WalkError"}set name(e){throw new Error("Cannot overwrite name of WalkError")}};const Fr=t=>{const e=[],s=new Set;let n=0;for(const c of t){if(c==="{")e.push(n);else if(c==="}"){const u=e.pop();u!==void 0&&(s.add(u),s.add(n))}n+=1}let o=0,r=0,i="";for(const c of t)c==="{"?s.has(r)?(i+="(",o+=1):i+=String.raw`\{`:c==="}"?s.has(r)?(i+=")",o-=1):i+=String.raw`\}`:c===","&&o>0?i+="|":i+=c,r+=1;return i},ve=t=>{const e=t.replace(/[$()+\\^]/g,String.raw`\$&`).replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,String.raw`\.`),s=Fr(e).replace(/\[!(.*?)\]/g,"[^$1]");try{return new RegExp(`^${s}$`)}catch(n){throw new Error(`Invalid glob pattern: ${t}`,{cause:n})}};let Hr=class{name;path;#t;constructor(e,s,n){this.#t=e,this.name=s,this.path=n}isDirectory(){return this.#t.isDirectory()}isFile(){return this.#t.isFile()}isSymbolicLink(){return this.#t.isSymbolicLink()}};const kt=(t,e,s)=>new Hr(t,e,s),wt=(t,e,s,n)=>{if(Array.isArray(e)&&e.length>0&&!e.some(r=>t.endsWith(r)))return!1;const o=t.includes("\\")?t.replaceAll("\\","/"):t;return s&&!s.some(r=>r.test(o))?!1:!n?.some(r=>r.test(o))};let Ir;const Br=t=>(Ir??=H(import.meta.url))(t),Gt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Mr=t=>{if(typeof Gt<"u"&&Gt.versions&&Gt.versions.node){const[e,s]=Gt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Gt.getBuiltinModule(t)}return Br(t)},{readdir:Pr,realpath:jr,stat:Bs}=Mr("node:fs/promises"),Gr=async t=>{const e=Tt(t),s=pe(e),n=await Bs(e);return kt(n,s,e)};async function*Ms(t,e={}){const{extensions:s,followSymlinks:n=!1,includeDirs:o=!0,includeFiles:r=!0,includeSymlinks:i=!0,match:c,maxDepth:u=Number.POSITIVE_INFINITY,skip:y}=e;if(P(t),u<0)return;const l=e.visited??new Set,h=c?c.map(g=>typeof g=="string"?ve(g):g):void 0,$=y?y.map(g=>typeof g=="string"?ve(g):g):void 0;if(t=tt(F(t)),o&&wt(t,s,h,$)&&(yield await Gr(t)),!(u<1||!wt(t,void 0,void 0,$)))try{const g=await Pr(t,{withFileTypes:!0});for(const b of g){let E=Ee(t,b.name),R=b,{name:C}=b,D=b.isDirectory(),m=b.isFile();if(b.isSymbolicLink())if(n){const v=Tt(await jr(E));if(l.has(v))continue;E=v;const a=await Bs(v);D=a.isDirectory(),m=a.isFile(),R=a,C=pe(v)}else if(i&&wt(E,s,h,$)){yield kt(b,b.name,E);continue}else continue;D?(n&&l.add(E),yield*Ms(E,{extensions:s,followSymlinks:n,includeDirs:o,includeFiles:r,includeSymlinks:i,match:h,maxDepth:u-1,skip:$,visited:l})):m&&r&&wt(E,s,h,$)&&(yield kt(R,C,E))}}catch(g){throw g instanceof be?g:new be(g,t)}}const Fa=async(t,e={})=>{Array.isArray(e.extensions)||(e.extensions=["js","mjs","cjs","ts"]);const s=[];for await(const n of Ms(t,e))s.push(n.path);return s};let Ur;const qr=t=>(Ur??=H(import.meta.url))(t),Ut=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,zr=t=>{if(typeof Ut<"u"&&Ut.versions&&Ut.versions.node){const[e,s]=Ut.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ut.getBuiltinModule(t)}return qr(t)},{readdirSync:Wr,realpathSync:Xr,statSync:Ps}=zr("node:fs"),Kr=t=>{const e=Tt(t),s=Ps(e);return kt(s,pe(e),e)};function*js(t,e={}){const{extensions:s,followSymlinks:n=!1,includeDirs:o=!0,includeFiles:r=!0,includeSymlinks:i=!0,match:c,maxDepth:u=Number.POSITIVE_INFINITY,skip:y}=e;if(P(t),u<0)return;const l=e.visited??new Set,h=c?c.map(g=>typeof g=="string"?ve(g):g):void 0,$=y?y.map(g=>typeof g=="string"?ve(g):g):void 0;if(t=tt(F(t)),o&&wt(t,s,h,$)&&(yield Kr(t)),!(u<1||!wt(t,void 0,void 0,$)))try{const g=Wr(t,{withFileTypes:!0});for(const b of g){let E=Ee(t,b.name),R=b,{name:C}=b,D=b.isDirectory(),m=b.isFile();if(b.isSymbolicLink())if(n){const v=Tt(Xr(E));if(l.has(v))continue;E=v;const a=Ps(v);D=a.isDirectory(),m=a.isFile(),R=a,C=pe(v)}else if(i&&wt(E,s,h,$)){yield kt(b,b.name,Tt(E));continue}else continue;D?(n&&l.add(E),yield*js(E,{extensions:s,followSymlinks:n,includeDirs:o,includeFiles:r,includeSymlinks:i,match:h,maxDepth:u-1,skip:$,visited:l})):m&&r&&wt(E,s,h,$)&&(yield kt(R,C,Tt(E)))}}catch(g){throw g instanceof be?g:new be(g,t)}}const Ha=(t,e={})=>{Array.isArray(e.extensions)||(e.extensions=["js","mjs","cjs","ts"]);const s=[];for(const n of js(t,e))s.push(n.path);return s};let Qr;const Vr=t=>(Qr??=H(import.meta.url))(t),qt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Yr=t=>{if(typeof qt<"u"&&qt.versions&&qt.versions.node){const[e,s]=qt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return qt.getBuiltinModule(t)}return Vr(t)},{stat:Zr,lstat:Jr}=Yr("node:fs/promises"),Ia=async(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");const s=e.cwd?F(e.cwd):process.cwd();let n=tt(s);const{root:o}=Ds(n),r=F(e.stopAt??o),i=tt(n,r),c=e.type??"file",u=async function(l){return typeof t=="function"?[await t(l)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};e.allowSymlinks??=!0;const y=e.allowSymlinks?Zr:Jr;for(;n;){const l=await u(n);for(let h of l){if(h===Ns)return;if(h===void 0)continue;Buffer.isBuffer(h)?h=h.toString():h instanceof URL&&(h=F(h));const $=St(h)?h:tt(n,h);try{const g=await y($);if(c==="file"&&g.isFile()||c==="directory"&&g.isDirectory())return $}catch{}}if(n===i||n===o)break;n=V(n)}};let to;const eo=t=>(to??=H(import.meta.url))(t),zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,so=t=>{if(typeof zt<"u"&&zt.versions&&zt.versions.node){const[e,s]=zt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return zt.getBuiltinModule(t)}return eo(t)},{statSync:no,lstatSync:ro}=so("node:fs"),Ba=(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");const s=e.cwd?F(e.cwd):process.cwd();let n=tt(s);const{root:o}=Ds(n),r=F(e.stopAt??o),i=tt(n,r),c=e.type??"file",u=function(l){return typeof t=="function"?[t(l)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};e.allowSymlinks??=!0;const y=e.allowSymlinks?no:ro;for(;n;){for(let l of u(n)){if(l===Ns)return;if(l===void 0)continue;Buffer.isBuffer(l)?l=l.toString():l instanceof URL&&(l=F(l));const h=St(l)?l:tt(n,l);try{const $=y(h);if(c==="file"&&$.isFile()||c==="directory"&&$.isDirectory())return h}catch{}}if(n===i||n===o)break;n=V(n)}};function Qe(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rs={},Ne,os;function Ae(){if(os)return Ne;os=1;const t="\\\\/",e=`[^${t}]`,s=0,n=Symbol("unignore"),o="\\.",r="\\+",i="\\?",c="\\/",u="(?=.)",y="[^/]",l=`(?:${c}|$)`,h=`(?:^|${c})`,$=`${o}{1,2}${l}`,g=`(?!${o})`,b=`(?!${h}${$})`,E=`(?!${o}{0,1}${l})`,R=`(?!${$})`,C=`[^.${c}]`,D=`${y}*?`,m={DOT_LITERAL:o,PLUS_LITERAL:r,QMARK_LITERAL:i,SLASH_LITERAL:c,ONE_CHAR:u,QMARK:y,END_ANCHOR:l,DOTS_SLASH:$,NO_DOT:g,NO_DOTS:b,NO_DOT_SLASH:E,NO_DOTS_SLASH:R,QMARK_NO_DOT:C,STAR:D,START_ANCHOR:h,SEP:"/"},v={...m,SLASH_LITERAL:`[${t}]`,QMARK:e,STAR:`${e}*?`,DOTS_SLASH:`${o}{1,2}(?:[${t}]|$)`,NO_DOT:`(?!${o})`,NO_DOTS:`(?!(?:^|[${t}])${o}{1,2}(?:[${t}]|$))`,NO_DOT_SLASH:`(?!${o}{0,1}(?:[${t}]|$))`,NO_DOTS_SLASH:`(?!${o}{1,2}(?:[${t}]|$))`,QMARK_NO_DOT:`[^.${t}]`,START_ANCHOR:`(?:^|[${t}])`,END_ANCHOR:`(?:[${t}]|$)`,SEP:"\\"},a={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};return Ne={DEFAULT_MAX_EXTGLOB_RECURSION:s,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:a,UNIGNORE:n,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(A){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${A.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(A){return A===!0?v:m}},Ne}var is;function _e(){return is||(is=1,(function(t){const{REGEX_BACKSLASH:e,REGEX_REMOVE_BACKSLASH:s,REGEX_SPECIAL_CHARS:n,REGEX_SPECIAL_CHARS_GLOBAL:o}=Ae();t.isObject=r=>r!==null&&typeof r=="object"&&!Array.isArray(r),t.hasRegexChars=r=>n.test(r),t.isRegexChar=r=>r.length===1&&t.hasRegexChars(r),t.escapeRegex=r=>r.replace(o,"\\$1"),t.toPosixSlashes=r=>r.replace(e,"/"),t.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){const r=navigator.platform.toLowerCase();return r==="win32"||r==="windows"}return process.platform?process.platform==="win32":!1},t.removeBackslashes=r=>r.replace(s,i=>i==="\\"?"":i),t.escapeLast=(r,i,c)=>{const u=r.lastIndexOf(i,c);return u===-1?r:r[u-1]==="\\"?t.escapeLast(r,i,u-1):`${r.slice(0,u)}\\${r.slice(u)}`},t.removePrefix=(r,i={})=>{let c=r;return c.startsWith("./")&&(c=c.slice(2),i.prefix="./"),c},t.wrapOutput=(r,i={},c={})=>{const u=c.contains?"":"^",y=c.contains?"":"$";let l=`${u}(?:${r})${y}`;return i.negated===!0&&(l=`(?:^(?!${l}).*$)`),l},t.basename=(r,{windows:i}={})=>{const c=r.split(i?/[\\/]/:"/"),u=c[c.length-1];return u===""?c[c.length-2]:u}})(rs)),rs}var Le,cs;function oo(){if(cs)return Le;cs=1;const t=_e(),{CHAR_ASTERISK:e,CHAR_AT:s,CHAR_BACKWARD_SLASH:n,CHAR_COMMA:o,CHAR_DOT:r,CHAR_EXCLAMATION_MARK:i,CHAR_FORWARD_SLASH:c,CHAR_LEFT_CURLY_BRACE:u,CHAR_LEFT_PARENTHESES:y,CHAR_LEFT_SQUARE_BRACKET:l,CHAR_PLUS:h,CHAR_QUESTION_MARK:$,CHAR_RIGHT_CURLY_BRACE:g,CHAR_RIGHT_PARENTHESES:b,CHAR_RIGHT_SQUARE_BRACKET:E}=Ae(),R=D=>D===c||D===n,C=D=>{D.isPrefix!==!0&&(D.depth=D.isGlobstar?1/0:1)};return Le=(D,m)=>{const v=m||{},a=D.length-1,A=v.parts===!0||v.scanToEnd===!0,O=[],_=[],T=[];let x=D,B=-1,U=0,nt=0,gt=!1,rt=!1,K=!1,ot=!1,mt=!1,ut=!1,it=!1,W=!1,at=!1,Z=!1,$t=0,J,k,M={value:"",depth:0,isGlob:!1};const Y=()=>B>=a,d=()=>x.charCodeAt(B+1),q=()=>(J=k,x.charCodeAt(++B));for(;B<a;){k=q();let et;if(k===n){it=M.backslashes=!0,k=q(),k===u&&(ut=!0);continue}if(ut===!0||k===u){for($t++;Y()!==!0&&(k=q());){if(k===n){it=M.backslashes=!0,q();continue}if(k===u){$t++;continue}if(ut!==!0&&k===r&&(k=q())===r){if(gt=M.isBrace=!0,K=M.isGlob=!0,Z=!0,A===!0)continue;break}if(ut!==!0&&k===o){if(gt=M.isBrace=!0,K=M.isGlob=!0,Z=!0,A===!0)continue;break}if(k===g&&($t--,$t===0)){ut=!1,gt=M.isBrace=!0,Z=!0;break}}if(A===!0)continue;break}if(k===c){if(O.push(B),_.push(M),M={value:"",depth:0,isGlob:!1},Z===!0)continue;if(J===r&&B===U+1){U+=2;continue}nt=B+1;continue}if(v.noext!==!0&&(k===h||k===s||k===e||k===$||k===i)&&d()===y){if(K=M.isGlob=!0,ot=M.isExtglob=!0,Z=!0,k===i&&B===U&&(at=!0),A===!0){for(;Y()!==!0&&(k=q());){if(k===n){it=M.backslashes=!0,k=q();continue}if(k===b){K=M.isGlob=!0,Z=!0;break}}continue}break}if(k===e){if(J===e&&(mt=M.isGlobstar=!0),K=M.isGlob=!0,Z=!0,A===!0)continue;break}if(k===$){if(K=M.isGlob=!0,Z=!0,A===!0)continue;break}if(k===l){for(;Y()!==!0&&(et=q());){if(et===n){it=M.backslashes=!0,q();continue}if(et===E){rt=M.isBracket=!0,K=M.isGlob=!0,Z=!0;break}}if(A===!0)continue;break}if(v.nonegate!==!0&&k===i&&B===U){W=M.negated=!0,U++;continue}if(v.noparen!==!0&&k===y){if(K=M.isGlob=!0,A===!0){for(;Y()!==!0&&(k=q());){if(k===y){it=M.backslashes=!0,k=q();continue}if(k===b){Z=!0;break}}continue}break}if(K===!0){if(Z=!0,A===!0)continue;break}}v.noext===!0&&(ot=!1,K=!1);let G=x,bt="",p="";U>0&&(bt=x.slice(0,U),x=x.slice(U),nt-=U),G&&K===!0&&nt>0?(G=x.slice(0,nt),p=x.slice(nt)):K===!0?(G="",p=x):G=x,G&&G!==""&&G!=="/"&&G!==x&&R(G.charCodeAt(G.length-1))&&(G=G.slice(0,-1)),v.unescape===!0&&(p&&(p=t.removeBackslashes(p)),G&&it===!0&&(G=t.removeBackslashes(G)));const f={prefix:bt,input:D,start:U,base:G,glob:p,isBrace:gt,isBracket:rt,isGlob:K,isExtglob:ot,isGlobstar:mt,negated:W,negatedExtglob:at};if(v.tokens===!0&&(f.maxDepth=0,R(k)||_.push(M),f.tokens=_),v.parts===!0||v.tokens===!0){let et;for(let I=0;I<O.length;I++){const ct=et?et+1:U,lt=O[I],st=D.slice(ct,lt);v.tokens&&(I===0&&U!==0?(_[I].isPrefix=!0,_[I].value=bt):_[I].value=st,C(_[I]),f.maxDepth+=_[I].depth),(I!==0||st!=="")&&T.push(st),et=lt}if(et&&et+1<D.length){const I=D.slice(et+1);T.push(I),v.tokens&&(_[_.length-1].value=I,C(_[_.length-1]),f.maxDepth+=_[_.length-1].depth)}f.slashes=O,f.parts=T}return f},Le}var De,us;function io(){if(us)return De;us=1;const t=Ae(),e=_e(),{MAX_LENGTH:s,POSIX_REGEX_SOURCE:n,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:r,REPLACEMENTS:i}=t,c=(m,v)=>{if(typeof v.expandRange=="function")return v.expandRange(...m,v);m.sort();const a=`[${m.join("-")}]`;try{new RegExp(a)}catch{return m.map(A=>e.escapeRegex(A)).join("..")}return a},u=(m,v)=>`Missing ${m}: "${v}" - use "\\\\${v}" to match literal characters`,y=m=>{const v=[];let a=0,A=0,O=0,_="",T=!1;for(const x of m){if(T===!0){_+=x,T=!1;continue}if(x==="\\"){_+=x,T=!0;continue}if(x==='"'){O=O===1?0:1,_+=x;continue}if(O===0){if(x==="[")a++;else if(x==="]"&&a>0)a--;else if(a===0){if(x==="(")A++;else if(x===")"&&A>0)A--;else if(x==="|"&&A===0){v.push(_),_="";continue}}}_+=x}return v.push(_),v},l=m=>{let v=!1;for(const a of m){if(v===!0){v=!1;continue}if(a==="\\"){v=!0;continue}if(/[?*+@!()[\]{}]/.test(a))return!1}return!0},h=m=>{let v=m.trim(),a=!0;for(;a===!0;)a=!1,/^@\([^\\()[\]{}|]+\)$/.test(v)&&(v=v.slice(2,-1),a=!0);if(l(v))return v.replace(/\\(.)/g,"$1")},$=m=>{const v=m.map(h).filter(Boolean);for(let a=0;a<v.length;a++)for(let A=a+1;A<v.length;A++){const O=v[a],_=v[A],T=O[0];if(!(!T||O!==T.repeat(O.length)||_!==T.repeat(_.length))&&(O===_||O.startsWith(_)||_.startsWith(O)))return!0}return!1},g=(m,v=!0)=>{if(m[0]!=="+"&&m[0]!=="*"||m[1]!=="(")return;let a=0,A=0,O=0,_=!1;for(let T=1;T<m.length;T++){const x=m[T];if(_===!0){_=!1;continue}if(x==="\\"){_=!0;continue}if(x==='"'){O=O===1?0:1;continue}if(O!==1){if(x==="["){a++;continue}if(x==="]"&&a>0){a--;continue}if(!(a>0)){if(x==="("){A++;continue}if(x===")"&&(A--,A===0))return v===!0&&T!==m.length-1?void 0:{type:m[0],body:m.slice(2,T),end:T}}}}},b=m=>`${m.length===1?e.escapeRegex(m[0]):`[${m.map(v=>e.escapeRegex(v)).join("")}]`}*`,E=m=>{let v=0;const a=[];for(;v<m.length;){const A=g(m.slice(v),!1);if(!A||A.type!=="*")return;const O=y(A.body).map(T=>T.trim());if(O.length!==1)return;const _=h(O[0]);if(!_||_.length!==1)return;a.push(_),v+=A.end+1}if(!(a.length<1))return a},R=m=>{let v=0,a=m.trim(),A=g(a);for(;A;)v++,a=A.body.trim(),A=g(a);return v},C=(m,v)=>{if(v.maxExtglobRecursion===!1)return{risky:!1};const a=typeof v.maxExtglobRecursion=="number"?v.maxExtglobRecursion:t.DEFAULT_MAX_EXTGLOB_RECURSION,A=y(m).map(x=>x.trim());if(A.length>1&&(A.some(x=>x==="")||A.some(x=>/^[*?]+$/.test(x))||$(A)))return{risky:!0};const O=[];let _=!1,T=!0;for(const x of A){const B=E(x);if(B){_=!0,O.push(...B);continue}const U=h(x);if(U&&U.length===1){O.push(U);continue}if(T=!1,R(x)>a)return{risky:!0}}return _?T?{risky:!0,safeOutput:b([...new Set(O)])}:{risky:!0}:{risky:!1}},D=(m,v)=>{if(typeof m!="string")throw new TypeError("Expected a string");m=i[m]||m;const a={...v},A=typeof a.maxLength=="number"?Math.min(s,a.maxLength):s;let O=m.length;if(O>A)throw new SyntaxError(`Input length: ${O}, exceeds maximum allowed length: ${A}`);const _={type:"bos",value:"",output:a.prepend||""},T=[_],x=a.capture?"":"?:",B=t.globChars(a.windows),U=t.extglobChars(B),{DOT_LITERAL:nt,PLUS_LITERAL:gt,SLASH_LITERAL:rt,ONE_CHAR:K,DOTS_SLASH:ot,NO_DOT:mt,NO_DOT_SLASH:ut,NO_DOTS_SLASH:it,QMARK:W,QMARK_NO_DOT:at,STAR:Z,START_ANCHOR:$t}=B,J=S=>`(${x}(?:(?!${$t}${S.dot?ot:nt}).)*?)`,k=a.dot?"":mt,M=a.dot?W:at;let Y=a.bash===!0?J(a):Z;a.capture&&(Y=`(${Y})`),typeof a.noext=="boolean"&&(a.noextglob=a.noext);const d={input:m,index:-1,start:0,dot:a.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:T};m=e.removePrefix(m,d),O=m.length;const q=[],G=[],bt=[];let p=_,f;const et=()=>d.index===O-1,I=d.peek=(S=1)=>m[d.index+S],ct=d.advance=()=>m[++d.index]||"",lt=()=>m.slice(d.index+1),st=(S="",z=0)=>{d.consumed+=S,d.index+=z},ge=S=>{d.output+=S.output!=null?S.output:S.value,st(S.value)},bn=()=>{let S=1;for(;I()==="!"&&(I(2)!=="("||I(3)==="?");)ct(),d.start++,S++;return S%2===0?!1:(d.negated=!0,d.start++,!0)},ye=S=>{d[S]++,bt.push(S)},vt=S=>{d[S]--,bt.pop()},N=S=>{if(p.type==="globstar"){const z=d.braces>0&&(S.type==="comma"||S.type==="brace"),w=S.extglob===!0||q.length&&(S.type==="pipe"||S.type==="paren");S.type!=="slash"&&S.type!=="paren"&&!z&&!w&&(d.output=d.output.slice(0,-p.output.length),p.type="star",p.value="*",p.output=Y,d.output+=p.output)}if(q.length&&S.type!=="paren"&&(q[q.length-1].inner+=S.value),(S.value||S.output)&&ge(S),p&&p.type==="text"&&S.type==="text"){p.output=(p.output||p.value)+S.value,p.value+=S.value;return}S.prev=p,T.push(S),p=S},me=(S,z)=>{const w={...U[z],conditions:1,inner:""};w.prev=p,w.parens=d.parens,w.output=d.output,w.startIndex=d.index,w.tokensIndex=T.length;const L=(a.capture?"(":"")+w.open;ye("parens"),N({type:S,value:z,output:d.output?"":K}),N({type:"paren",extglob:!0,value:ct(),output:L}),q.push(w)},vn=S=>{const z=m.slice(S.startIndex,d.index+1),w=m.slice(S.startIndex+2,d.index),L=C(w,a);if((S.type==="plus"||S.type==="star")&&L.risky){const j=L.safeOutput?(S.output?"":K)+(a.capture?`(${L.safeOutput})`:L.safeOutput):void 0,pt=T[S.tokensIndex];pt.type="text",pt.value=z,pt.output=j||e.escapeRegex(z);for(let ft=S.tokensIndex+1;ft<T.length;ft++)T[ft].value="",T[ft].output="",delete T[ft].suffix;d.output=S.output+pt.output,d.backtrack=!0,N({type:"paren",extglob:!0,value:f,output:""}),vt("parens");return}let X=S.close+(a.capture?")":""),Q;if(S.type==="negate"){let j=Y;if(S.inner&&S.inner.length>1&&S.inner.includes("/")&&(j=J(a)),(j!==Y||et()||/^\)+$/.test(lt()))&&(X=S.close=`)$))${j}`),S.inner.includes("*")&&(Q=lt())&&/^\.[^\\/.]+$/.test(Q)){const pt=D(Q,{...v,fastpaths:!1}).output;X=S.close=`)${pt})${j})`}S.prev.type==="bos"&&(d.negatedExtglob=!0)}N({type:"paren",extglob:!0,value:f,output:X}),vt("parens")};if(a.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(m)){let S=!1,z=m.replace(r,(w,L,X,Q,j,pt)=>Q==="\\"?(S=!0,w):Q==="?"?L?L+Q+(j?W.repeat(j.length):""):pt===0?M+(j?W.repeat(j.length):""):W.repeat(X.length):Q==="."?nt.repeat(X.length):Q==="*"?L?L+Q+(j?Y:""):Y:L?w:`\\${w}`);return S===!0&&(a.unescape===!0?z=z.replace(/\\/g,""):z=z.replace(/\\+/g,w=>w.length%2===0?"\\\\":w?"\\":"")),z===m&&a.contains===!0?(d.output=m,d):(d.output=e.wrapOutput(z,d,v),d)}for(;!et();){if(f=ct(),f==="\0")continue;if(f==="\\"){const w=I();if(w==="/"&&a.bash!==!0||w==="."||w===";")continue;if(!w){f+="\\",N({type:"text",value:f});continue}const L=/^\\+/.exec(lt());let X=0;if(L&&L[0].length>2&&(X=L[0].length,d.index+=X,X%2!==0&&(f+="\\")),a.unescape===!0?f=ct():f+=ct(),d.brackets===0){N({type:"text",value:f});continue}}if(d.brackets>0&&(f!=="]"||p.value==="["||p.value==="[^")){if(a.posix!==!1&&f===":"){const w=p.value.slice(1);if(w.includes("[")&&(p.posix=!0,w.includes(":"))){const L=p.value.lastIndexOf("["),X=p.value.slice(0,L),Q=p.value.slice(L+2),j=n[Q];if(j){p.value=X+j,d.backtrack=!0,ct(),!_.output&&T.indexOf(p)===1&&(_.output=K);continue}}}(f==="["&&I()!==":"||f==="-"&&I()==="]")&&(f=`\\${f}`),f==="]"&&(p.value==="["||p.value==="[^")&&(f=`\\${f}`),a.posix===!0&&f==="!"&&p.value==="["&&(f="^"),p.value+=f,ge({value:f});continue}if(d.quotes===1&&f!=='"'){f=e.escapeRegex(f),p.value+=f,ge({value:f});continue}if(f==='"'){d.quotes=d.quotes===1?0:1,a.keepQuotes===!0&&N({type:"text",value:f});continue}if(f==="("){ye("parens"),N({type:"paren",value:f});continue}if(f===")"){if(d.parens===0&&a.strictBrackets===!0)throw new SyntaxError(u("opening","("));const w=q[q.length-1];if(w&&d.parens===w.parens+1){vn(q.pop());continue}N({type:"paren",value:f,output:d.parens?")":"\\)"}),vt("parens");continue}if(f==="["){if(a.nobracket===!0||!lt().includes("]")){if(a.nobracket!==!0&&a.strictBrackets===!0)throw new SyntaxError(u("closing","]"));f=`\\${f}`}else ye("brackets");N({type:"bracket",value:f});continue}if(f==="]"){if(a.nobracket===!0||p&&p.type==="bracket"&&p.value.length===1){N({type:"text",value:f,output:`\\${f}`});continue}if(d.brackets===0){if(a.strictBrackets===!0)throw new SyntaxError(u("opening","["));N({type:"text",value:f,output:`\\${f}`});continue}vt("brackets");const w=p.value.slice(1);if(p.posix!==!0&&w[0]==="^"&&!w.includes("/")&&(f=`/${f}`),p.value+=f,ge({value:f}),a.literalBrackets===!1||e.hasRegexChars(w))continue;const L=e.escapeRegex(p.value);if(d.output=d.output.slice(0,-p.value.length),a.literalBrackets===!0){d.output+=L,p.value=L;continue}p.value=`(${x}${L}|${p.value})`,d.output+=p.value;continue}if(f==="{"&&a.nobrace!==!0){ye("braces");const w={type:"brace",value:f,output:"(",outputIndex:d.output.length,tokensIndex:d.tokens.length};G.push(w),N(w);continue}if(f==="}"){const w=G[G.length-1];if(a.nobrace===!0||!w){N({type:"text",value:f,output:f});continue}let L=")";if(w.dots===!0){const X=T.slice(),Q=[];for(let j=X.length-1;j>=0&&(T.pop(),X[j].type!=="brace");j--)X[j].type!=="dots"&&Q.unshift(X[j].value);L=c(Q,a),d.backtrack=!0}if(w.comma!==!0&&w.dots!==!0){const X=d.output.slice(0,w.outputIndex),Q=d.tokens.slice(w.tokensIndex);w.value=w.output="\\{",f=L="\\}",d.output=X;for(const j of Q)d.output+=j.output||j.value}N({type:"brace",value:f,output:L}),vt("braces"),G.pop();continue}if(f==="|"){q.length>0&&q[q.length-1].conditions++,N({type:"text",value:f});continue}if(f===","){let w=f;const L=G[G.length-1];L&&bt[bt.length-1]==="braces"&&(L.comma=!0,w="|"),N({type:"comma",value:f,output:w});continue}if(f==="/"){if(p.type==="dot"&&d.index===d.start+1){d.start=d.index+1,d.consumed="",d.output="",T.pop(),p=_;continue}N({type:"slash",value:f,output:rt});continue}if(f==="."){if(d.braces>0&&p.type==="dot"){p.value==="."&&(p.output=nt);const w=G[G.length-1];p.type="dots",p.output+=f,p.value+=f,w.dots=!0;continue}if(d.braces+d.parens===0&&p.type!=="bos"&&p.type!=="slash"){N({type:"text",value:f,output:nt});continue}N({type:"dot",value:f,output:nt});continue}if(f==="?"){if(!(p&&p.value==="(")&&a.noextglob!==!0&&I()==="("&&I(2)!=="?"){me("qmark",f);continue}if(p&&p.type==="paren"){const w=I();let L=f;(p.value==="("&&!/[!=<:]/.test(w)||w==="<"&&!/<([!=]|\w+>)/.test(lt()))&&(L=`\\${f}`),N({type:"text",value:f,output:L});continue}if(a.dot!==!0&&(p.type==="slash"||p.type==="bos")){N({type:"qmark",value:f,output:at});continue}N({type:"qmark",value:f,output:W});continue}if(f==="!"){if(a.noextglob!==!0&&I()==="("&&(I(2)!=="?"||!/[!=<:]/.test(I(3)))){me("negate",f);continue}if(a.nonegate!==!0&&d.index===0){bn();continue}}if(f==="+"){if(a.noextglob!==!0&&I()==="("&&I(2)!=="?"){me("plus",f);continue}if(p&&p.value==="("||a.regex===!1){N({type:"plus",value:f,output:gt});continue}if(p&&(p.type==="bracket"||p.type==="paren"||p.type==="brace")||d.parens>0){N({type:"plus",value:f});continue}N({type:"plus",value:gt});continue}if(f==="@"){if(a.noextglob!==!0&&I()==="("&&I(2)!=="?"){N({type:"at",extglob:!0,value:f,output:""});continue}N({type:"text",value:f});continue}if(f!=="*"){(f==="$"||f==="^")&&(f=`\\${f}`);const w=o.exec(lt());w&&(f+=w[0],d.index+=w[0].length),N({type:"text",value:f});continue}if(p&&(p.type==="globstar"||p.star===!0)){p.type="star",p.star=!0,p.value+=f,p.output=Y,d.backtrack=!0,d.globstar=!0,st(f);continue}let S=lt();if(a.noextglob!==!0&&/^\([^?]/.test(S)){me("star",f);continue}if(p.type==="star"){if(a.noglobstar===!0){st(f);continue}const w=p.prev,L=w.prev,X=w.type==="slash"||w.type==="bos",Q=L&&(L.type==="star"||L.type==="globstar");if(a.bash===!0&&(!X||S[0]&&S[0]!=="/")){N({type:"star",value:f,output:""});continue}const j=d.braces>0&&(w.type==="comma"||w.type==="brace"),pt=q.length&&(w.type==="pipe"||w.type==="paren");if(!X&&w.type!=="paren"&&!j&&!pt){N({type:"star",value:f,output:""});continue}for(;S.slice(0,3)==="/**";){const ft=m[d.index+4];if(ft&&ft!=="/")break;S=S.slice(3),st("/**",3)}if(w.type==="bos"&&et()){p.type="globstar",p.value+=f,p.output=J(a),d.output=p.output,d.globstar=!0,st(f);continue}if(w.type==="slash"&&w.prev.type!=="bos"&&!Q&&et()){d.output=d.output.slice(0,-(w.output+p.output).length),w.output=`(?:${w.output}`,p.type="globstar",p.output=J(a)+(a.strictSlashes?")":"|$)"),p.value+=f,d.globstar=!0,d.output+=w.output+p.output,st(f);continue}if(w.type==="slash"&&w.prev.type!=="bos"&&S[0]==="/"){const ft=S[1]!==void 0?"|$":"";d.output=d.output.slice(0,-(w.output+p.output).length),w.output=`(?:${w.output}`,p.type="globstar",p.output=`${J(a)}${rt}|${rt}${ft})`,p.value+=f,d.output+=w.output+p.output,d.globstar=!0,st(f+ct()),N({type:"slash",value:"/",output:""});continue}if(w.type==="bos"&&S[0]==="/"){p.type="globstar",p.value+=f,p.output=`(?:^|${rt}|${J(a)}${rt})`,d.output=p.output,d.globstar=!0,st(f+ct()),N({type:"slash",value:"/",output:""});continue}if(j&&S[0]==="/"){p.type="globstar",p.value+=f,p.output=`(?:^|${rt}|${J(a)}${rt})`,d.output+=p.output,d.globstar=!0,st(f+ct()),N({type:"slash",value:"/",output:""});continue}d.output=d.output.slice(0,-p.output.length),p.type="globstar",p.output=J(a),p.value+=f,d.output+=p.output,d.globstar=!0,st(f);continue}const z={type:"star",value:f,output:Y};if(a.bash===!0){z.output=".*?",(p.type==="bos"||p.type==="slash")&&(z.output=k+z.output),N(z);continue}if(p&&(p.type==="bracket"||p.type==="paren")&&a.regex===!0){z.output=f,N(z);continue}(d.index===d.start||p.type==="slash"||p.type==="dot")&&(p.type==="dot"?(d.output+=ut,p.output+=ut):a.dot===!0?(d.output+=it,p.output+=it):(d.output+=k,p.output+=k),I()!=="*"&&(d.output+=K,p.output+=K)),N(z)}for(;d.brackets>0;){if(a.strictBrackets===!0)throw new SyntaxError(u("closing","]"));d.output=e.escapeLast(d.output,"["),vt("brackets")}for(;d.parens>0;){if(a.strictBrackets===!0)throw new SyntaxError(u("closing",")"));d.output=e.escapeLast(d.output,"("),vt("parens")}for(;d.braces>0;){if(a.strictBrackets===!0)throw new SyntaxError(u("closing","}"));d.output=e.escapeLast(d.output,"{"),vt("braces")}if(a.strictSlashes!==!0&&(p.type==="star"||p.type==="bracket")&&N({type:"maybe_slash",value:"",output:`${rt}?`}),d.backtrack===!0){d.output="";for(const S of d.tokens)d.output+=S.output!=null?S.output:S.value,S.suffix&&(d.output+=S.suffix)}return d};return D.fastpaths=(m,v)=>{const a={...v},A=typeof a.maxLength=="number"?Math.min(s,a.maxLength):s,O=m.length;if(O>A)throw new SyntaxError(`Input length: ${O}, exceeds maximum allowed length: ${A}`);m=i[m]||m;const{DOT_LITERAL:_,SLASH_LITERAL:T,ONE_CHAR:x,DOTS_SLASH:B,NO_DOT:U,NO_DOTS:nt,NO_DOTS_SLASH:gt,STAR:rt,START_ANCHOR:K}=t.globChars(a.windows),ot=a.dot?nt:U,mt=a.dot?gt:U,ut=a.capture?"":"?:",it={negated:!1,prefix:""};let W=a.bash===!0?".*?":rt;a.capture&&(W=`(${W})`);const at=k=>k.noglobstar===!0?W:`(${ut}(?:(?!${K}${k.dot?B:_}).)*?)`,Z=k=>{switch(k){case"*":return`${ot}${x}${W}`;case".*":return`${_}${x}${W}`;case"*.*":return`${ot}${W}${_}${x}${W}`;case"*/*":return`${ot}${W}${T}${x}${mt}${W}`;case"**":return ot+at(a);case"**/*":return`(?:${ot}${at(a)}${T})?${mt}${x}${W}`;case"**/*.*":return`(?:${ot}${at(a)}${T})?${mt}${W}${_}${x}${W}`;case"**/.*":return`(?:${ot}${at(a)}${T})?${_}${x}${W}`;default:{const M=/^(.*?)\.(\w+)$/.exec(k);if(!M)return;const Y=Z(M[1]);return Y?Y+_+M[2]:void 0}}},$t=e.removePrefix(m,it);let J=Z($t);return J&&a.strictSlashes!==!0&&(J+=`${T}?`),J},De=D,De}var Fe,as;function co(){if(as)return Fe;as=1;const t=oo(),e=io(),s=_e(),n=Ae(),o=i=>i&&typeof i=="object"&&!Array.isArray(i),r=(i,c,u=!1)=>{if(Array.isArray(i)){const R=i.map(C=>r(C,c,u));return C=>{for(const D of R){const m=D(C);if(m)return m}return!1}}const y=o(i)&&i.tokens&&i.input;if(i===""||typeof i!="string"&&!y)throw new TypeError("Expected pattern to be a non-empty string");const l=c||{},h=l.windows,$=y?r.compileRe(i,c):r.makeRe(i,c,!1,!0),g=$.state;delete $.state;let b=()=>!1;if(l.ignore){const R={...c,ignore:null,onMatch:null,onResult:null};b=r(l.ignore,R,u)}const E=(R,C=!1)=>{const{isMatch:D,match:m,output:v}=r.test(R,$,c,{glob:i,posix:h}),a={glob:i,state:g,regex:$,posix:h,input:R,output:v,match:m,isMatch:D};if(typeof l.onResult=="function"&&l.onResult(a),D===!1)return a.isMatch=!1,C?a:!1;t:if(b(R)){if(typeof l.onIgnore=="function"&&l.onIgnore(a)===n.UNIGNORE){a.isMatch=!0;break t}return a.isMatch=!1,C?a:!1}return typeof l.onMatch=="function"&&l.onMatch(a),C?a:!0};return u&&(E.state=g),E};return r.test=(i,c,u,{glob:y,posix:l}={})=>{if(typeof i!="string")throw new TypeError("Expected input to be a string");if(i==="")return{isMatch:!1,output:""};const h=u||{},$=h.format||(l?s.toPosixSlashes:null);let g=i===y,b=g&&$?$(i):i;return g===!1&&(b=$?$(i):i,g=b===y),(g===!1||h.capture===!0)&&(h.matchBase===!0||h.basename===!0?g=r.matchBase(i,c,u,l):g=c.exec(b)),{isMatch:!!g,match:g,output:b}},r.matchBase=(i,c,u,y=u&&u.windows)=>(c instanceof RegExp?c:r.makeRe(c,u)).test(s.basename(i,{windows:y})),r.isMatch=(i,c,u)=>r(c,u)(i),r.parse=(i,c)=>Array.isArray(i)?i.map(u=>r.parse(u,c)):e(i,{...c,fastpaths:!1}),r.scan=(i,c)=>t(i,c),r.compileRe=(i,c,u=!1,y=!1)=>{if(u===!0)return i.output;const l=c||{},h=l.contains?"":"^",$=l.contains?"":"$";let g=`${h}(?:${i.output})${$}`;i&&i.negated===!0&&(g=`^(?!${g}).*$`);const b=r.toRegex(g,c);return y===!0&&(b.state=i),b},r.makeRe=(i,c={},u=!1,y=!1)=>{if(!i||typeof i!="string")throw new TypeError("Expected a non-empty string");let l={negated:!1,fastpaths:!0};return c.fastpaths!==!1&&(i[0]==="."||i[0]==="*")&&(l.output=e.fastpaths(i,c)),l.output||(l=e(i,c)),r.compileRe(l,c,u,y)},r.toRegex=(i,c)=>{try{const u=c||{};return new RegExp(i,u.flags||(u.nocase?"i":""))}catch(u){if(c&&c.debug===!0)throw u;return/$^/}},r.constants=n,Fe=r,Fe}var He,ls;function uo(){if(ls)return He;ls=1;const t=co(),e=_e();function s(n,o,r=!1){return o&&(o.windows===null||o.windows===void 0)&&(o={...o,windows:e.isWindows()}),t(n,o,r)}return Object.assign(s,t),He=s,He}var ao=uo();const yt=Qe(ao);let lo;const po=t=>(lo??=H(import.meta.url))(t),Wt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,fe=t=>{if(typeof Wt<"u"&&Wt.versions&&Wt.versions.node){const[e,s]=Wt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Wt.getBuiltinModule(t)}return po(t)},ps=fe("fs"),fo={...ps,default:ps},{statSync:ho,stat:go,realpathSync:yo,realpath:mo,readdirSync:$o,readdir:bo}=fe("fs"),{sep:Gs,basename:vo,dirname:qe,resolve:Us,normalize:wo,relative:So,posix:_t,isAbsolute:xo}=fe("path"),{fileURLToPath:Eo}=fe("url"),{createRequire:Ao}=fe("module");var fs=Ao(import.meta.url);function _o(t){let e=wo(t);return e.length>1&&e[e.length-1]===Gs&&(e=e.substring(0,e.length-1)),e}const To=/[\\/]/g;function qs(t,e){return t.replace(To,e)}const Ro=/^[a-z]:[\\/]$/i;function ko(t){return t==="/"||Ro.test(t)}function Ie(t,e){const{resolvePaths:s,normalizePath:n,pathSeparator:o}=e,r=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(s&&(t=Us(t)),(n||r)&&(t=_o(t)),t===".")return"";const i=t[t.length-1]!==o;return qs(i?t+o:t,o)}function zs(t,e){return e+t}function Co(t,e){return function(s,n){return n.startsWith(t)?n.slice(t.length)+s:qs(So(t,n),e.pathSeparator)+e.pathSeparator+s}}function Oo(t){return t}function No(t,e,s){return e+t+s}function Lo(t,e){const{relativePaths:s,includeBasePath:n}=e;return s&&t?Co(t,e):n?zs:Oo}function Do(t){return function(e,s){s.push(e.substring(t.length)||".")}}function Fo(t){return function(e,s,n){const o=e.substring(t.length)||".";n.every(r=>r(o,!0))&&s.push(o)}}const Ho=(t,e)=>{e.push(t||".")},Io=(t,e,s)=>{const n=t||".";s.every(o=>o(n,!0))&&e.push(n)},Bo=()=>{};function Mo(t,e){const{includeDirs:s,filters:n,relativePaths:o}=e;return s?o?n&&n.length?Fo(t):Do(t):n&&n.length?Io:Ho:Bo}const Po=(t,e,s,n)=>{n.every(o=>o(t,!1))&&s.files++},jo=(t,e,s,n)=>{n.every(o=>o(t,!1))&&e.push(t)},Go=(t,e,s,n)=>{s.files++},Uo=(t,e)=>{e.push(t)},qo=()=>{};function zo(t){const{excludeFiles:e,filters:s,onlyCounts:n}=t;return e?qo:s&&s.length?n?Po:jo:n?Go:Uo}const Wo=t=>t,Xo=()=>[""].slice(0,0);function Ko(t){return t.group?Xo:Wo}const Qo=(t,e,s)=>{t.push({directory:e,files:s,dir:e})},Vo=()=>{};function Yo(t){return t.group?Qo:Vo}const Zo=function(t,e,s){const{queue:n,fs:o,options:{suppressErrors:r}}=e;n.enqueue(),o.realpath(t,(i,c)=>{if(i)return n.dequeue(r?null:i,e);o.stat(c,(u,y)=>{if(u)return n.dequeue(r?null:u,e);if(y.isDirectory()&&Ws(t,c,e))return n.dequeue(null,e);s(y,c),n.dequeue(null,e)})})},Jo=function(t,e,s){const{queue:n,fs:o,options:{suppressErrors:r}}=e;n.enqueue();try{const i=o.realpathSync(t),c=o.statSync(i);if(c.isDirectory()&&Ws(t,i,e))return;s(c,i)}catch(i){if(!r)throw i}};function ti(t,e){return!t.resolveSymlinks||t.excludeSymlinks?null:e?Jo:Zo}function Ws(t,e,s){if(s.options.useRealPaths)return ei(e,s);let n=qe(t),o=1;for(;n!==s.root&&o<2;){const r=s.symlinks.get(n);r&&(r===e||r.startsWith(e)||e.startsWith(r))?o++:n=qe(n)}return s.symlinks.set(t,e),o>1}function ei(t,e){return e.visited.includes(t+e.options.pathSeparator)}const si=t=>t.counts,ni=t=>t.groups,ri=t=>t.paths,oi=t=>t.paths.slice(0,t.options.maxFiles),ii=(t,e,s)=>(Te(e,s,t.counts,t.options.suppressErrors),null),ci=(t,e,s)=>(Te(e,s,t.paths,t.options.suppressErrors),null),ui=(t,e,s)=>(Te(e,s,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),ai=(t,e,s)=>(Te(e,s,t.groups,t.options.suppressErrors),null);function Te(t,e,s,n){e(t&&!n?t:null,s)}function li(t,e){const{onlyCounts:s,group:n,maxFiles:o}=t;return s?e?si:ii:n?e?ni:ai:o?e?oi:ui:e?ri:ci}const Xs={withFileTypes:!0},pi=(t,e,s,n,o)=>{if(t.queue.enqueue(),n<0)return t.queue.dequeue(null,t);const{fs:r}=t;t.visited.push(e),t.counts.directories++,r.readdir(e||".",Xs,(i,c=[])=>{o(c,s,n),t.queue.dequeue(t.options.suppressErrors?null:i,t)})},fi=(t,e,s,n,o)=>{const{fs:r}=t;if(n<0)return;t.visited.push(e),t.counts.directories++;let i=[];try{i=r.readdirSync(e||".",Xs)}catch(c){if(!t.options.suppressErrors)throw c}o(i,s,n)};function hi(t){return t?fi:pi}var di=class{count=0;constructor(t){this.onQueueEmpty=t}enqueue(){return this.count++,this.count}dequeue(t,e){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,e),t&&(e.controller.abort(),this.onQueueEmpty=void 0))}},gi=class{_files=0;_directories=0;set files(t){this._files=t}get files(){return this._files}set directories(t){this._directories=t}get directories(){return this._directories}get dirs(){return this._directories}},yi=class{aborted=!1;abort(){this.aborted=!0}},Ks=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(e,s,n){this.isSynchronous=!n,this.callbackInvoker=li(s,this.isSynchronous),this.root=Ie(e,s),this.state={root:ko(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new gi,options:s,queue:new di((o,r)=>this.callbackInvoker(r,o,n)),symlinks:new Map,visited:[""].slice(0,0),controller:new yi,fs:s.fs||fo},this.joinPath=Lo(this.root,s),this.pushDirectory=Mo(this.root,s),this.pushFile=zo(s),this.getArray=Ko(s),this.groupFiles=Yo(s),this.resolveSymlink=ti(s,this.isSynchronous),this.walkDirectory=hi(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(e,s,n)=>{const{paths:o,options:{filters:r,resolveSymlinks:i,excludeSymlinks:c,exclude:u,maxFiles:y,signal:l,useRealPaths:h,pathSeparator:$},controller:g}=this.state;if(g.aborted||l&&l.aborted||y&&o.length>y)return;const b=this.getArray(this.state.paths);for(let E=0;E<e.length;++E){const R=e[E];if(R.isFile()||R.isSymbolicLink()&&!i&&!c){const C=this.joinPath(R.name,s);this.pushFile(C,b,this.state.counts,r)}else if(R.isDirectory()){let C=No(R.name,s,this.state.options.pathSeparator);if(u&&u(R.name,C))continue;this.pushDirectory(C,o,r),this.walkDirectory(this.state,C,C,n-1,this.walk)}else if(this.resolveSymlink&&R.isSymbolicLink()){let C=zs(R.name,s);this.resolveSymlink(C,this.state,(D,m)=>{if(D.isDirectory()){if(m=Ie(m,this.state.options),u&&u(R.name,h?m:C+$))return;this.walkDirectory(this.state,m,h?m:C+$,n-1,this.walk)}else{m=h?m:C;const v=vo(m),a=Ie(qe(m),this.state.options);m=this.joinPath(v,a),this.pushFile(m,b,this.state.counts,r)}})}}this.groupFiles(this.state.groups,s,b)}};function mi(t,e){return new Promise((s,n)=>{Qs(t,e,(o,r)=>{if(o)return n(o);s(r)})})}function Qs(t,e,s){new Ks(t,e,s).start()}function $i(t,e){return new Ks(t,e).start()}var hs=class{constructor(e,s){this.root=e,this.options=s}withPromise(){return mi(this.root,this.options)}withCallback(e){Qs(this.root,this.options,e)}sync(){return $i(this.root,this.options)}};let Vs=null;try{fs.resolve("picomatch"),Vs=fs("picomatch")}catch{}var bi=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:Gs,filters:[]};globFunction;constructor(t){this.options={...this.options,...t},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:t=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=!0,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(t){return new hs(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,e){return this.options={...this.options,...e},new hs(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:!0})}globWithOptions(t,...e){const s=this.globFunction||Vs;if(!s)throw new Error("Please specify a glob function to use glob matching.");var n=this.globCache[t.join("\0")];return n||(n=s(t,...e),this.globCache[t.join("\0")]=n),this.options.filters.push(o=>n(o)),this}};const vi=Array.isArray,Ys=/\\/g,wi=/^[A-Za-z]:$/,Zs=process.platform==="win32",Si=/^(\/?\.\.)+$/;function ds(t,e={}){const s=t.length,n=Array(s),o=Array(s);let r,i;for(r=0;r<s;r++){const c=Js(t[r]);n[r]=c;const u=c.length,y=Array(u);for(i=0;i<u;i++)y[i]=yt(c[i],e);o[r]=y}return c=>{const u=c.split("/");if(u[0]===".."&&Si.test(c))return!0;for(r=0;r<s;r++){const y=n[r],l=o[r],h=u.length,$=Math.min(h,y.length);for(i=0;i<$;){const g=y[i];if(g.includes("/"))return!0;if(!l[i](u[i]))break;if(!e.noglobstar&&g==="**")return!0;i++}if(i===h)return!0}return!1}}const xi=/^[A-Z]:\/$/i,Ei=Zs?t=>xi.test(t):t=>t==="/";function gs(t,e,s){if(t===e||e.startsWith(`${t}/`)){if(s){const o=t.length+ +!Ei(t);return(r,i)=>r.slice(o,i?-1:void 0)||"."}const n=e.slice(t.length+1);return n?(o,r)=>{if(o===".")return n;const i=`${n}/${o}`;return r?i.slice(0,-1):i}:(o,r)=>r&&o!=="."?o.slice(0,-1):o}return s?n=>_t.relative(t,n)||".":n=>_t.relative(t,`${e}/${n}`)||"."}function Ai(t,e){if(e.startsWith(`${t}/`)){const s=e.slice(t.length+1);return n=>`${s}/${n}`}return s=>{const n=_t.relative(t,`${e}/${s}`);return s[s.length-1]==="/"&&n!==""?`${n}/`:n||"."}}function ys(t){return t.replace(wi,e=>`${e}/`)}const _i={parts:!0};function Js(t){var e;const s=yt.scan(t,_i);return!((e=s.parts)===null||e===void 0)&&e.length?s.parts:[t]}const Ti=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,Ri=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,ki=t=>t.replace(Ti,"\\$&"),Ci=t=>t.replace(Ri,"\\$&"),Oi=Zs?Ci:ki;function Ni(t,e){const s=yt.scan(t);return s.isGlob||s.negated}function ue(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t)}function tn(t){return typeof t=="string"?[t]:t??[]}const Li=/^(\/?\.\.)+/,Di=/\\(?=[()[\]{}!*+?@|])/g;function Be(t,e,s,n){var o;const r=e.cwd;let i=t;t[t.length-1]==="/"&&(i=t.slice(0,-1));const c=i.lastIndexOf("/"),u=(c===-1?i:i.slice(c+1)).startsWith("!(");i[i.length-1]!=="*"&&!u&&e.expandDirectories&&(i+="/**");const y=Oi(r);i=xo(i.replace(Di,""))?_t.relative(y,i):_t.normalize(i);const l=(o=Li.exec(i))===null||o===void 0?void 0:o[0],h=Js(i);if(l){const g=(l.length+1)/3;let b=0;const E=y.split("/");for(;b<g&&h[b+g]===E[E.length+b-g];)i=i.slice(0,(g-b-1)*3)+i.slice((g-b)*3+h[b+g].length+1)||".",b++;const R=_t.join(r,l.slice(b*3));R[0]!=="."&&s.root.length>R.length&&(s.root=ys(R),s.depthOffset=-g+b)}if(!n&&s.depthOffset>=0){var $;($=s.commonPath)!==null&&$!==void 0||(s.commonPath=h);const g=[],b=Math.min(s.commonPath.length,h.length);for(let E=0;E<b;E++){const R=h[E];if(R==="**"&&!h[E+1]){g.pop();break}if(E===h.length-1||R!==s.commonPath[E]||Ni(R))break;g.push(R)}s.depthOffset=g.length,s.commonPath=g,s.root=ys(g.length>0?_t.join(r,...g):r)}return i}function Fi(t,e,s){const n=[],o=[],r=[];for(const i of t.ignore)i&&(i[0]!=="!"||i[1]==="("?o.push(Be(i,t,s,!0)):r.push(i.slice(1)));for(const i of e)i&&(i[0]!=="!"||i[1]==="("?n.push(Be(i,t,s,!1)):(i[1]!=="!"||i[2]==="(")&&o.push(Be(i.slice(1),t,s,!0)));return{match:n,ignore:o,unignore:r}}function Hi(t,e){const s=t.cwd,n={root:s,depthOffset:0},o=Fi(t,e,n);t.debug&&ue("internal processing patterns:",o);const{absolute:r,caseSensitiveMatch:i,debug:c,dot:u,followSymbolicLinks:y,onlyDirectories:l}=t,h=n.root.replace(Ys,""),$={dot:u,nobrace:t.braceExpansion===!1,nocase:!i,noextglob:t.extglob===!1,noglobstar:t.globstar===!1,posix:!0},g=o.unignore.length>0,b=g?yt(o.unignore,$):void 0,E=g?ds(o.unignore,$):void 0,R=yt(o.match,{...$,ignore:o.ignore,onIgnore:b?T=>b(T.output)&&yt.constants.UNIGNORE:void 0}),C=yt(o.ignore,$),D=ds(o.match,$),m=gs(s,h,r),v=r?m:gs(s,h,!0),a=o.match.length>0&&o.match.every(T=>T==="**"||T==="**/*"),A=o.ignore.length>0||g||!a?(T,x)=>{const B=v(x,!0);return B==="."||E&&E(B)?!1:!D(B)||C(B)}:void 0;let O;t.deep!==void 0&&(O=Math.round(t.deep-n.depthOffset));const _=new bi({filters:[c?(T,x)=>{const B=m(T,x),U=R(B);return U&&ue(`matched ${B}`),U}:(T,x)=>{const B=m(T,x);return R(B)}],exclude:c&&A?(T,x)=>{const B=A(T,x);return ue(`${B?"skipped":"crawling"} ${x}`),B}:A,fs:t.fs,pathSeparator:"/",relativePaths:!r,resolvePaths:r,includeBasePath:r,resolveSymlinks:y,excludeSymlinks:!y,excludeFiles:l,includeDirs:l||!t.onlyFiles,maxDepth:O,signal:t.signal}).crawl(h);return t.debug&&ue("internal properties:",{...n,root:h}),[_,s!==h&&!r&&Ai(s,h)]}function en(t,e){if(e)for(let s=t.length-1;s>=0;s--)t[s]=e(t[s]);return t}const ms={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function Ii(t){const e=Object.assign({},t);for(const s in ms)e[s]===void 0&&Object.assign(e,{[s]:ms[s]});return e.cwd=(e.cwd instanceof URL?Eo(e.cwd):Us(e.cwd||process.cwd())).replace(Ys,"/"),e.ignore=tn(e.ignore),e.fs&&(e.fs={readdir:e.fs.readdir||bo,readdirSync:e.fs.readdirSync||$o,realpath:e.fs.realpath||mo,realpathSync:e.fs.realpathSync||yo,stat:e.fs.stat||go,statSync:e.fs.statSync||ho}),e.debug&&ue("globbing with options:",e),e}function sn(t,e={}){var s;if(t&&e?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");const n=vi(t)||typeof t=="string",o=tn((s=n?t:t.patterns)!==null&&s!==void 0?s:"**/*"),r=Ii(n?e:t);return o.length>0?Hi(r,o):[]}async function Bi(t,e){const[s,n]=sn(t,e);return s?en(await s.withPromise(),n):[]}function Mi(t,e){const[s,n]=sn(t,e);return s?en(s.sync(),n):[]}const ja=async(t,e)=>await Bi(t,e),Ga=(t,e)=>Mi(t,e);var Me,$s;function Pi(){if($s)return Me;$s=1;/*!
4
+ * is-extglob <https://github.com/jonschlinkert/is-extglob>
5
+ *
6
+ * Copyright (c) 2014-2016, Jon Schlinkert.
7
+ * Licensed under the MIT License.
8
+ */return Me=function(t){if(typeof t!="string"||t==="")return!1;for(var e;e=/(\\).|([@?!+*]\(.*\))/g.exec(t);){if(e[2])return!0;t=t.slice(e.index+e[0].length)}return!1},Me}var Pe,bs;function nn(){if(bs)return Pe;bs=1;/*!
9
+ * is-glob <https://github.com/jonschlinkert/is-glob>
10
+ *
11
+ * Copyright (c) 2014-2017, Jon Schlinkert.
12
+ * Released under the MIT License.
13
+ */var t=Pi(),e={"{":"}","(":")","[":"]"},s=function(o){if(o[0]==="!")return!0;for(var r=0,i=-2,c=-2,u=-2,y=-2,l=-2;r<o.length;){if(o[r]==="*"||o[r+1]==="?"&&/[\].+)]/.test(o[r])||c!==-1&&o[r]==="["&&o[r+1]!=="]"&&(c<r&&(c=o.indexOf("]",r)),c>r&&(l===-1||l>c||(l=o.indexOf("\\",r),l===-1||l>c)))||u!==-1&&o[r]==="{"&&o[r+1]!=="}"&&(u=o.indexOf("}",r),u>r&&(l=o.indexOf("\\",r),l===-1||l>u))||y!==-1&&o[r]==="("&&o[r+1]==="?"&&/[:!=]/.test(o[r+2])&&o[r+3]!==")"&&(y=o.indexOf(")",r),y>r&&(l=o.indexOf("\\",r),l===-1||l>y))||i!==-1&&o[r]==="("&&o[r+1]!=="|"&&(i<r&&(i=o.indexOf("|",r)),i!==-1&&o[i+1]!==")"&&(y=o.indexOf(")",i),y>i&&(l=o.indexOf("\\",i),l===-1||l>y))))return!0;if(o[r]==="\\"){var h=o[r+1];r+=2;var $=e[h];if($){var g=o.indexOf($,r);g!==-1&&(r=g+1)}if(o[r]==="!")return!0}else r++}return!1},n=function(o){if(o[0]==="!")return!0;for(var r=0;r<o.length;){if(/[*?{}()[\]]/.test(o[r]))return!0;if(o[r]==="\\"){var i=o[r+1];r+=2;var c=e[i];if(c){var u=o.indexOf(c,r);u!==-1&&(r=u+1)}if(o[r]==="!")return!0}else r++}return!1};return Pe=function(o,r){if(typeof o!="string"||o==="")return!1;if(t(o))return!0;var i=s;return r&&r.strict===!1&&(i=n),i(o)},Pe}let ji;const Gi=t=>(ji??=H(import.meta.url))(t),Xt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,rn=t=>{if(typeof Xt<"u"&&Xt.versions&&Xt.versions.node){const[e,s]=Xt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Xt.getBuiltinModule(t)}return Gi(t)},Ui=rn("path"),qi=rn("os");var je,vs;function zi(){if(vs)return je;vs=1;var t=nn(),e=Ui.posix.dirname,s=qi.platform()==="win32",n="/",o=/\\/g,r=/\\([!*?|[\](){}])/g;je=function(u,y){var l=Object.assign({flipBackslashes:!0},y);l.flipBackslashes&&s&&u.indexOf(n)<0&&(u=u.replace(o,n)),i(u)&&(u+=n),u+="a";do u=e(u);while(c(u));return u.replace(r,"$1")};function i(u){var y=u.slice(-1),l;switch(y){case"}":l="{";break;case"]":l="[";break;default:return!1}var h=u.indexOf(l);return h<0?!1:u.slice(h+1,-1).includes(n)}function c(u){return/\([^()]+$/.test(u)||u[0]==="{"||u[0]==="["||/[^\\][{[]/.test(u)?!0:t(u)}return je}var Wi=zi();const Xi=Qe(Wi),Ua=(t,e)=>Xi(t,e);let Ki;const Qi=t=>(Ki??=H(import.meta.url))(t),Kt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Vi=t=>{if(typeof Kt<"u"&&Kt.versions&&Kt.versions.node){const[e,s]=Kt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Kt.getBuiltinModule(t)}return Qi(t)},{access:Yi}=Vi("node:fs/promises");async function we(t,e=xe){P(t),t=F(t);try{return await Yi(t,e),!0}catch{return!1}}let Zi;const Ji=t=>(Zi??=H(import.meta.url))(t),Qt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,tc=t=>{if(typeof Qt<"u"&&Qt.versions&&Qt.versions.node){const[e,s]=Qt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Qt.getBuiltinModule(t)}return Ji(t)},{accessSync:ec}=tc("node:fs");function Se(t,e=xe){P(t),t=F(t);try{return ec(t,e),!0}catch{return!1}}var sc=nn();const nc=Qe(sc),qa=(t,e)=>nc(t,e),za=(t,e,s)=>{const n=yt(e,s);return Array.isArray(t)?t.some(o=>n(o)):n(t)},Wa=(t,e)=>{const s=yt(t,e);return n=>s(n)};let rc;const oc=t=>(rc??=H(import.meta.url))(t),Rt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,on=t=>{if(typeof Rt<"u"&&Rt.versions&&Rt.versions.node){const[e,s]=Rt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Rt.getBuiltinModule(t)}return oc(t)},{cwd:Re}=Rt,{mkdir:ic,rename:cc,copyFile:uc,unlink:ac}=on("node:fs/promises"),{mkdirSync:lc,renameSync:pc,copyFileSync:fc,unlinkSync:hc}=on("node:fs");let dc=class extends Error{constructor(e,s){super(`Source directory "${V(e)}" does not match destination directory "${V(s)}"`),this.name="SameDirectoryError"}};const cn=(t,e)=>{if(!t||!e)throw new Error("Source and destination paths must not be empty");if(V(t)!==V(e))throw new dc(t,e)},un=async(t,e,{cwd:s,directoryMode:n,overwrite:o,validateDirectory:r})=>{if(s&&(t=tt(s,t),e=tt(s,e)),r&&cn(t,e),!o&&await we(e))throw new Error(`The destination file exists: ${e}`);await ic(V(e),{mode:n,recursive:!0});try{await cc(t,e)}catch(i){if(i.code==="EXDEV")await uc(t,e),await ac(t);else throw i}},an=(t,e,{cwd:s,directoryMode:n,overwrite:o,validateDirectory:r})=>{if(s&&(t=tt(s,t),e=tt(s,e)),r&&cn(t,e),!o&&Se(e))throw new Error(`The destination file exists: ${e}`);lc(V(e),{mode:n,recursive:!0});try{pc(t,e)}catch(i){if(i.code==="EXDEV")fc(t,e),hc(t);else throw i}},Ka=async(t,e,s={})=>{const n={overwrite:!0,validateDirectory:!1,...s,cwd:s.cwd?F(s.cwd):Re()};await un(t,e,n)},Qa=(t,e,s)=>{const n={overwrite:!0,validateDirectory:!1,...s};n.cwd=n.cwd?F(n.cwd):Re(),an(t,e,n)},Va=async(t,e,s)=>{const n={overwrite:!0,...s,validateDirectory:!0};n.cwd=n.cwd?F(n.cwd):Re(),await un(t,e,n)},Ya=(t,e,s)=>{const n={overwrite:!0,...s,validateDirectory:!0};n.cwd=n.cwd?F(n.cwd):Re(),an(t,e,n)};let gc=class extends Error{constructor(e){super(`ENOENT: ${e}`)}get code(){return"ENOENT"}set code(e){throw new Error("Cannot overwrite code ENOENT")}get name(){return"NotFoundError"}set name(e){throw new Error("Cannot overwrite name of NotFoundError")}},yc=class extends Error{constructor(e){super(`EPERM: Operation not permitted, ${e}`)}get code(){return"EPERM"}set code(e){throw new Error("Cannot overwrite code EPERM")}get name(){return"PermissionError"}set name(e){throw new Error("Cannot overwrite name of PermissionError")}};const ln=(t,e)=>{const s=t?.code;return s==="ENOENT"?new gc(`no such file or directory, open '${e}'`):s==="EACCES"||s==="EPERM"?new yc(`unable to read the non-readable file: ${e}`):t};let mc;const $c=t=>(mc??=H(import.meta.url))(t),Vt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pn=t=>{if(typeof Vt<"u"&&Vt.versions&&Vt.versions.node){const[e,s]=Vt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Vt.getBuiltinModule(t)}return $c(t)},{readFile:bc}=pn("node:fs/promises"),{unzip:vc,brotliDecompress:wc}=pn("node:zlib"),Sc={brotli:wc,gzip:vc,none:(t,e)=>{e(null,t)}},xc=async(t,e)=>{P(t),t=F(t);const{buffer:s,compression:n,encoding:o,flag:r}=e??{};let i;try{i=await bc(t,r?{flag:r}:{})}catch(c){throw ln(c,t)}return await new Promise((c,u)=>{Sc[n??"none"](i,(y,l)=>{y?u(y):c(s?l:l.toString(o??"utf8"))})})};let Ec;const Ac=t=>(Ec??=H(import.meta.url))(t),Yt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,fn=t=>{if(typeof Yt<"u"&&Yt.versions&&Yt.versions.node){const[e,s]=Yt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Yt.getBuiltinModule(t)}return Ac(t)},{readFileSync:_c}=fn("node:fs"),{unzipSync:Tc,brotliDecompressSync:Rc}=fn("node:zlib"),kc={brotli:Rc,gzip:Tc,none:t=>t},Cc=(t,e)=>{P(t),t=F(t);const{buffer:s,compression:n,encoding:o,flag:r}=e??{};let i;try{i=_c(t,r?{flag:r}:{})}catch(y){throw ln(y,t)}const c=kc[n??"none"],u=c(i);return s?u:u.toString(o??"utf8")},Oc=globalThis.process??Object.create(null),ws={versions:{}},Ss=new Proxy(Oc,{get(t,e){if(e in t)return t[e];if(e in ws)return ws[e]}}),Nc=t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
14
+ `),Lc=(t,e,s,n)=>{const o={column:0,line:-1,...t.start},r={...o,...t.end},i=o.line,c=o.column,u=r.line,y=r.column;let l=Math.max(i-(s+1),0),h=Math.min(e.length,u+n);i===-1&&(l=0),u===-1&&(h=e.length);const $=u-i,g={};if($)for(let b=0;b<=$;b++){const E=b+i;if(!c)g[E]=!0;else if(b===0){const R=e[E-1]?.length;g[E]=[c,(R??0)-c+1]}else if(b===$)g[E]=[0,y];else{const R=e[E-b]?.length;g[E]=[0,R]}}else c===y?g[i]=c?[c,0]:!0:g[i]=[c,(y??0)-(c??0)];return{end:h,markerLines:g,start:l}},Dc=Ss.platform==="win32"&&!Ss.env?.WT_SESSION?">":"❯",Fc=(t,e,s)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...s,color:{gutter:b=>b,marker:b=>b,message:b=>b,...s?.color}},o=typeof e.start.column=="number";let r=(t.includes("\r")?Nc(t):t).split(`
15
+ `);typeof n.tabWidth=="number"&&t.includes(" ")&&(r=r.map(b=>b.replaceAll(" "," ".repeat(n.tabWidth))));const{end:i,markerLines:c,start:u}=Lc(e,r,n.linesAbove,n.linesBelow),y=String(i).length,{gutter:l,marker:h,message:$}=n.color;let g=r.slice(u,i).map((b,E)=>{const R=u+1+E,C=c[R],D=String(R).padStart(y),m=!c[R+1],v=` ${D}${n.showGutter?" |":""}`;if(C){let a="";if(Array.isArray(C)){const A=b.replaceAll(/[^\t]/g," ").slice(0,Math.max(C[0]-1,0)),O=C[1]||1;a=[`
16
+ `,n.prefix+l(v.replaceAll(/\d/g," "))," ",A,h("^").repeat(O)].join(""),m&&n.message&&(a+=` ${$(n.message)}`)}return[n.prefix+h(Dc),l(v),b.length>0?` ${b}`:"",a].join("")}return`${n.prefix} ${l(v)}${b.length>0?` ${b}`:""}`}).join(`
17
+ `);return n.message&&!o&&(g=`${n.prefix+" ".repeat(y+1)+n.message}
18
+ ${g}`),g},xs=(t,e)=>{let s=0,n=e.length-2;for(;s<n;){const o=s+(n-s>>1);if(t<e[o])n=o-1;else if(t>=e[o+1])s=o+1;else{s=o;break}}return s},Hc=/\n|\r(?!\n)/,Ic=t=>t.split(Hc).reduce((e,s)=>(e.push(e.at(-1)+s.length+1),e),[0]),Bc=(t,e,s)=>{if(!Array.isArray(t)&&typeof t!="string"||(typeof t=="string"||Array.isArray(t))&&t.length===0)return{column:0,line:0};if(typeof e!="number"||typeof t=="string"&&e>=t.length||Array.isArray(t)&&e+1>=t.at(-1))return{column:0,line:0};if(typeof t=="string"){const o=Ic(t),r=xs(e,o);return{column:e-o[r]+1,line:r+1}}const n=xs(e,t);return{column:e-t[n]+1,line:n+1}};class Mc extends Error{fileName;codeFrame;name="JSONError";#t;constructor(e){super(),this.#t=e}get message(){return`${this.#t}${this.fileName?` in ${this.fileName}`:""}${this.codeFrame?`
19
+
20
+ ${this.codeFrame}
21
+ `:""}`}set message(e){this.#t=e}}const Pc=t=>String.raw`\u{${t.codePointAt(0).toString(16)}}`,jc=(t,e,s)=>Fc(t,{start:e},{tabWidth:!1,...s}),Gc=/in JSON at position (\d+)(?: \(line (\d+) column (\d+)\))?$/,Uc=(t,e)=>{const s=Gc.exec(e);if(!s)return;const[,n,o,r]=s;if(o&&r)return{column:Number(r),line:Number(o)};let i=Number(n);return i===t.length&&(i=t.length-1),Bc(t,i)},qc=/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,zc=t=>t.replace(qc,(e,s,n)=>`"${n}"(${Pc(n)})`);function hn(t,e,s,n){typeof e=="string"&&(typeof s=="object"&&(n=s),s=e,e=void 0);let o;try{return JSON.parse(t,e)}catch(c){o=c.message}let r;t?(r=Uc(t,o),o=zc(o)):o+=" while parsing empty string";const i=new Mc(o);throw i.fileName=s,r&&(i.codeFrame=jc(t,r,n)),i}async function tl(t,e,s){typeof e=="object"&&(s=e,e=void 0);const n=await xc(t,{buffer:!0,encoding:void 0});let o=new TextDecoder().decode(n);const{beforeParse:r,color:i}=s??{};return typeof r=="function"&&(o=r(o)),hn(o,e,F(t),{color:i})}function el(t,e,s){typeof e=="object"&&(s=e,e=void 0);const n=Cc(t,{buffer:!0,encoding:void 0});let o=new TextDecoder().decode(n);const{beforeParse:r,color:i}=s??{};return typeof r=="function"&&(o=r(o)),hn(o,e,F(t),{color:i})}const ke=t=>{const e={force:!0,recursive:!0};return t?.maxRetries!==void 0&&(e.maxRetries=t.maxRetries),t?.retryDelay!==void 0&&(e.retryDelay=t.retryDelay),e};let Wc;const Xc=t=>(Wc??=H(import.meta.url))(t),Zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,dn=t=>{if(typeof Zt<"u"&&Zt.versions&&Zt.versions.node){const[e,s]=Zt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Zt.getBuiltinModule(t)}return Xc(t)},{existsSync:Kc}=dn("node:fs"),{mkdir:Qc,readdir:Vc,rm:Yc}=dn("node:fs/promises"),sl=async(t,e)=>{if(P(t),!Kc(t)){await Qc(t,{recursive:!0});return}const s=await Vc(t),n=ke(e);for(const o of s)await Yc(Ee(F(t),o),n)};let Zc;const Jc=t=>(Zc??=H(import.meta.url))(t),Jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,tu=t=>{if(typeof Jt<"u"&&Jt.versions&&Jt.versions.node){const[e,s]=Jt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Jt.getBuiltinModule(t)}return Jc(t)},{existsSync:eu,mkdirSync:su,readdirSync:nu,rmSync:ru}=tu("node:fs"),nl=(t,e)=>{if(P(t),!eu(t)){su(t,{recursive:!0});return}const s=ke(e);for(const n of nu(t))ru(Ee(F(t),n),s)};let ou;const iu=t=>(ou??=H(import.meta.url))(t),te=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,cu=t=>{if(typeof te<"u"&&te.versions&&te.versions.node){const[e,s]=te.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return te.getBuiltinModule(t)}return iu(t)},{rm:uu}=cu("node:fs/promises"),rl=async(t,e={})=>{P(t),await uu(t,ke(e))};let au;const lu=t=>(au??=H(import.meta.url))(t),ee=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pu=t=>{if(typeof ee<"u"&&ee.versions&&ee.versions.node){const[e,s]=ee.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return ee.getBuiltinModule(t)}return lu(t)},{rmSync:fu}=pu("node:fs"),ol=(t,e={})=>{P(t),fu(t,ke(e))},hu=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{platform:du}=hu,At="unnamed",gu=128,Es={'"':"ˮ","*":"⁎","/":"⁄",":":"꞉","<":"‹",">":"›","?":"ʔ","\\":"∖","|":"ǀ"},yu=/[\u0000-\u001F\u0080-\u009F]/g,mu=/^(?:\.+[/\\]+)+|^\.+$/g,ze=/^(?:con|prn|aux|nul|com\d|lpt\d)$/i,$u=/[<>:"/\\|?*]/g,bu=/\//g,le=new Set([" "," ","."]),he=(t,e)=>e>0&&e<t.length-1,vu=(t,e)=>{const s=t.lastIndexOf(".");if(!he(t,s))return t.slice(0,e);const n=t.slice(0,s),o=t.slice(s),r=e-o.length;return r>0?`${n.slice(0,r)}${o}`:t.slice(0,e)},As=t=>{let e=0,s=t.length;for(;e<s;){const n=t[e];if(n===void 0||!le.has(n))break;e+=1}for(;s>e;){const n=t[s-1];if(n===void 0||!le.has(n))break;s-=1}return t.slice(e,s)},wu=t=>{const e=t.lastIndexOf(".");if(he(t,e)){const n=t.slice(0,e),o=t.slice(e);let r=n;for(;r.length>0;){const i=r.at(-1);if(i===void 0||!le.has(i))break;r=r.slice(0,-1)}return r.length===0?o.slice(1):`${r}${o}`}let s=t;for(;s.length>0;){const n=s.at(-1);if(n===void 0||!le.has(n))break;s=s.slice(0,-1)}return s},Su=t=>{const e=t.lastIndexOf(".");if(he(t,e))return!1;if(ze.test(t))return!0;let s=t;for(;s.length>0;){const n=s.at(-1);if(n===void 0||!le.has(n))break;s=s.slice(0,-1)}return!!(s.length>0&&ze.test(s))},xu=t=>{const e=t.lastIndexOf(".");if(he(t,e)){const o=t.slice(0,e),r=t.slice(e),i=As(o);return i.length===0?void 0:`${i}${r}`}const s=t.trim();if(s.length>0&&s[0]==="."&&s.length<=5&&s.indexOf(".",1)===-1)return;const n=As(t);if(n.length!==0)return n},Eu=t=>{const e=t?.filesystem??"auto";return e==="auto"?du==="win32"?"win32":"unix":e==="darwin"?"unix":e},il=(t,e)=>{if(typeof t!="string"||t.length===0)return At;const s=Eu(e);let n=t;if(n=n.replace(yu,""),n.length===0||(n=n.replace(mu,""),n.length===0))return At;if(s==="win32"||s==="fat32"){const r=n.lastIndexOf(".");if(!he(n,r)&&ze.test(n))return At}if(n=s==="win32"||s==="fat32"?n.replaceAll($u,r=>Es[r]??""):n.replaceAll(bu,Es["/"]),n=n.trim(),(s==="win32"||s==="fat32")&&(Su(n)||s==="win32"&&(n=wu(n),n.length===0)))return At;if(s==="fat32"){const r=xu(n);if(r===void 0)return At;n=r}if(n.length===0)return At;const o=e?.maxLength??gu;return n.length>o&&(n=vu(n,o),n.length===0)?At:n},gn=t=>{if(typeof t!="string"&&!(t instanceof ArrayBuffer)&&!ArrayBuffer.isView(t))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")};let Au;const _u=t=>(Au??=H(import.meta.url))(t),se=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Tu=t=>{if(typeof se<"u"&&se.versions&&se.versions.node){const[e,s]=se.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return se.getBuiltinModule(t)}return _u(t)},{randomBytes:Ru}=Tu("node:crypto"),yn=t=>`${t}.${process.pid.toString(36)}.${Ru(6).toString("hex")}.tmp`,ku=new TextEncoder,mn=t=>{if(t instanceof Uint8Array)return t;if(typeof t=="string")return ku.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t)){const e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")};let Cu;const Ou=t=>(Cu??=H(import.meta.url))(t),ne=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Nu=t=>{if(typeof ne<"u"&&ne.versions&&ne.versions.node){const[e,s]=ne.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return ne.getBuiltinModule(t)}return Ou(t)},{mkdir:Lu,readFile:Du,writeFile:Fu,stat:Hu,rename:_s,chown:Iu,chmod:Bu,unlink:Mu}=Nu("node:fs/promises"),Pu=async(t,e,s)=>{s={backup:!1,encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...s},P(t),gn(e),t=F(t);const n=await we(t,xe),o=s.flag??"w",r=o.includes("a"),i=o.includes("x");if(n&&(!s.overwrite||i))throw new xt(`file already exists, open '${t}'`);const c=yn(t);try{!n&&s.recursive&&await Lu(V(t),{recursive:!0});let u,y=typeof e=="string"?Buffer.from(e,s.encoding??"utf8"):mn(e);if(r&&n&&(y=Buffer.concat([await Du(t),y])),await Fu(c,y,{flag:"wx"}),n&&s.backup&&(u=await Hu(t),s.chown??={gid:u.gid,uid:u.uid},await _s(t,`${t}.bak`)),s.chown)try{await Iu(c,s.chown.uid,s.chown.gid)}catch{}const l=u&&s.mode===void 0?u.mode:s.mode;l!==void 0&&await Bu(c,l),await _s(c,t)}catch(u){throw new Error(`Failed to write file at: ${t} - ${u.message}`,{cause:u})}finally{await we(c)&&await Mu(c)}};let ju;const Gu=t=>(ju??=H(import.meta.url))(t),re=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Uu=t=>{if(typeof re<"u"&&re.versions&&re.versions.node){const[e,s]=re.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return re.getBuiltinModule(t)}return Gu(t)},{mkdirSync:qu,readFileSync:zu,writeFileSync:Wu,statSync:Xu,renameSync:Ts,chownSync:Ku,chmodSync:Qu,unlinkSync:Vu}=Uu("node:fs"),Yu=(t,e,s)=>{s={backup:!1,encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...s},P(t),gn(e),t=F(t);const n=Se(t,xe),o=s.flag??"w",r=o.includes("a"),i=o.includes("x");if(n&&(!s.overwrite||i))throw new xt(`file already exists, open '${t}'`);const c=yn(t);try{!n&&s.recursive&&qu(V(t),{recursive:!0});let u,y=typeof e=="string"?Buffer.from(e,s.encoding??"utf8"):mn(e);if(r&&n&&(y=Buffer.concat([zu(t),y])),Wu(c,y,{flag:"wx"}),n&&s.backup&&(u=Xu(t),s.chown??={gid:u.gid,uid:u.uid},Ts(t,`${t}.bak`)),s.chown)try{Ku(c,s.chown.uid,s.chown.gid)}catch{}const l=u&&s.mode===void 0?u.mode:s.mode;l!==void 0&&Qu(c,l),Ts(c,t)}catch(u){throw new Error(`Failed to write file at: ${t} - ${u.message}`,{cause:u})}finally{Se(c)&&Vu(c)}},Zu=/^(?:( )+|\t+)/,de="space";function Rs(t,e,s){return t&&e===de&&s===1}function ks(t,e){const s=new Map;let n=0,o,r;for(const i of t.split(/\n/g)){if(!i)continue;const c=i.match(Zu);if(c===null)n=0,o="";else{const u=c[0].length,y=c[1]?de:"tab";if(Rs(e,y,u))continue;y!==o&&(n=0),o=y;let l=1,h=0;const $=u-n;if(n=u,$===0)l=0,h=1;else{const b=Math.abs($);if(Rs(e,y,b))continue;r=Ju(y,b)}const g=s.get(r);s.set(r,g===void 0?[1,0]:[g[0]+l,g[1]+h])}}return s}function Ju(t,e){return(t===de?"s":"t")+String(e)}function ta(t){const e=t[0]==="s"?de:"tab",s=Number(t.slice(1));return{type:e,amount:s}}function ea(t){let e,s=0,n=0;for(const[o,[r,i]]of t)(r>s||r===s&&i>n)&&(s=r,n=i,e=o);return e}function sa(t,e){return(t===de?" ":" ").repeat(e)}function $n(t){if(typeof t!="string")throw new TypeError("Expected a string");let e=ks(t,!0);e.size===0&&(e=ks(t,!1));const s=ea(e);let n,o=0,r="";return s!==void 0&&({type:n,amount:o}=ta(s),r=sa(n,o)),{amount:o,type:n,indent:r}}let na;const ra=t=>(na??=H(import.meta.url))(t),oe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,oa=t=>{if(typeof oe<"u"&&oe.versions&&oe.versions.node){const[e,s]=oe.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return oe.getBuiltinModule(t)}return ra(t)},{readFile:ia}=oa("node:fs/promises"),cl=async(t,e,s={})=>{const{detectIndent:n,indent:o,replacer:r,stringify:i=JSON.stringify,...c}={indent:" ",...s};let u=o,y=`
22
+ `;if(await we(t,Os))try{const h=await ia(t,"utf8");if(n){const{indent:$}=$n(h);u=$}y=h.endsWith(`
23
+ `)?`
24
+ `:""}catch(h){if(h.code!=="ENOENT")throw h}const l=i(e,r,u);await Pu(t,`${l}${y}`,c)};let ca;const ua=t=>(ca??=H(import.meta.url))(t),ie=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,aa=t=>{if(typeof ie<"u"&&ie.versions&&ie.versions.node){const[e,s]=ie.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return ie.getBuiltinModule(t)}return ua(t)},{readFileSync:la}=aa("node:fs"),ul=(t,e,s={})=>{const{detectIndent:n,indent:o,replacer:r,stringify:i=JSON.stringify,...c}={indent:" ",...s};let u=o,y=`
25
+ `;if(Se(t,Os))try{const h=la(t,"utf8");if(n){const{indent:$}=$n(h);u=$}y=h.endsWith(`
26
+ `)?`
27
+ `:""}catch(h){if(h.code!=="ENOENT")throw h}const l=i(e,r,u);Yu(t,`${l}${y}`,c)};let pa;const fa=t=>(pa??=H(import.meta.url))(t),ce=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ve=t=>{if(typeof ce<"u"&&ce.versions&&ce.versions.node){const[e,s]=ce.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return ce.getBuiltinModule(t)}return fa(t)},ha=Ve("fs"),da=Ve("os"),ga=Ve("path");var Ge={},Cs;function ya(){if(Cs)return Ge;Cs=1;var t=Object.defineProperty,e=(l,h)=>t(l,"name",{value:h,configurable:!0}),s=ha,n=da,o=ga;const r=e(l=>{let h="";for(let $=0;$<l.length;$+=1){const g=l[$],b=g.toUpperCase();h+=g===b?g.toLowerCase():b}return h},"invertCase"),i=new Map,c=e((l,h)=>{const $=o.join(l,`.is-fs-case-sensitive-test-${process.pid}`);try{return h.writeFileSync($,""),!h.existsSync(r($))}finally{try{h.unlinkSync($)}catch{}}},"checkDirectoryCaseWithWrite"),u=e((l,h,$)=>{try{return c(l,$)}catch(g){if(h===void 0)return c(n.tmpdir(),$);throw g}},"checkDirectoryCaseWithFallback"),y=e((l,h=s,$=!0)=>{const g=l??process.cwd();if($&&i.has(g))return i.get(g);let b;const E=r(g);return E!==g&&h.existsSync(g)?b=!h.existsSync(E):b=u(g,l,h),$&&i.set(g,b),b},"isFsCaseSensitive");return Ge.isFsCaseSensitive=y,Ge}var ma=ya();const al=ma.isFsCaseSensitive;export{Ue as CRLF,Ca as EOL,Ns as FIND_UP_STOP,xe as F_OK,Is as LF,Os as R_OK,ba as W_OK,va as X_OK,Fa as collect,Ha as collectSync,Sa as copy,xa as copySync,Oa as detect,sl as emptyDir,nl as emptyDirSync,Xe as ensureDir,Ke as ensureDirSync,Ea as ensureFile,Aa as ensureFileSync,_a as ensureLink,Ta as ensureLinkSync,Ra as ensureSymlink,ka as ensureSymlinkSync,Ia as findUp,Ba as findUpSync,Na as format,ja as glob,Ua as globParent,Ga as globSync,we as isAccessible,Se as isAccessibleSync,al as isFsCaseSensitive,qa as isGlob,za as match,Wa as matcher,Ka as move,Qa as moveSync,xc as readFile,Cc as readFileSync,tl as readJson,el as readJsonSync,rl as remove,ol as removeSync,Va as rename,Ya as renameSync,il as sanitize,Ms as walk,js as walkSync,Pu as writeFile,Yu as writeFileSync,cl as writeJson,ul as writeJsonSync};
@@ -0,0 +1 @@
1
+ const r="*";class o{listeners=new Map;on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>{this.off(e,t)}}once(e,t){const s=i=>{this.off(e,s),t(i)};return this.on(e,s)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e){const t=s=>{try{s(e)}catch{}};for(const s of this.listeners.get(e.type)??[])t(s);for(const s of this.listeners.get("*")??[])t(s)}clear(e){e===void 0?this.listeners.clear():this.listeners.delete(e)}}export{r as ALL_EVENTS,o as EventBus};
@@ -0,0 +1,4 @@
1
+ import{createRequire as D}from"node:module";import{s as E,c as H,p as I,o as K,a as h}from"./canonicalize-BEjQUnUe.js";let M;const C=t=>(M??=D(import.meta.url))(t),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=t=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[s,o]=r.versions.node.split(".").map(Number);if(s>22||s===22&&o>=3||s===20&&o>=16)return r.getBuiltinModule(t)}return C(t)},{createHash:m,createPrivateKey:j,sign:v,createSign:F}=$("node:crypto"),R=new Set(["cc","content-transfer-encoding","content-type","date","from","in-reply-to","message-id","mime-version","references","reply-to","subject","to"]),k=(t,s,o)=>o==="ed25519-sha256"?v(null,m("sha256").update(t).digest(),s).toString("base64"):F("RSA-SHA256").update(t).sign(s,"base64");class g{options;constructor(s){this.options=s}async signMimeMessage(s){const o=E(s);if(o===void 0)throw new Error("Failed to create DKIM signature: the message has no CRLFCRLF header/body separator, so it is not a complete MIME message.");const{body:l,headersPart:u}=o,a=this.options.headerCanon??"simple",d=this.options.bodyCanon??"simple",f=m("sha256").update(H(l,d)).digest("base64"),y=new Set((this.options.headersToIgnore??[]).map(e=>e.toLowerCase())),b=I(u).filter(e=>{const n=e.name.toLowerCase();return R.has(n)&&!y.has(n)}),i=K(b);if(!i.some(e=>e.name.toLowerCase()==="from"))throw new Error("Failed to create DKIM signature: the message has no signable From header (RFC 6376 §5.4 requires it in h=).");const p=["v=1",`a=${this.options.algorithm??"rsa-sha256"}`,`c=${a}/${d}`,`d=${this.options.domainName}`,`s=${this.options.keySelector}`,`t=${Math.floor(Date.now()/1e3).toString()}`,`bh=${f}`,`h=${i.map(e=>e.name.toLowerCase()).join(":")}`,"b="].join("; "),w=[...i.map(e=>h(e.name,e.value,a)),h("DKIM-Signature",` ${p}`,a)].join(`\r
2
+ `);let c;try{let e=this.options.privateKey;if(e.startsWith("file://")){const{readFile:_}=await import("../packem_chunks/index.js");e=await _(e.slice(7),{encoding:"utf8"})}const n=j({key:e,passphrase:this.options.passphrase});c=k(w,n,this.options.algorithm)}catch(e){throw new Error(`Failed to create DKIM signature: ${e.message}`)}const S=c.match(/.{1,72}/g)?.join(`\r
3
+ `)??c;return`DKIM-Signature: ${p}${S}\r
4
+ ${s}`}}const q=t=>new g(t),A=t=>new g({bodyCanon:"relaxed",headerCanon:"relaxed",...t});export{g as DkimSigner,q as createDkimSigner,A as createTransportDkimSigner};
@@ -0,0 +1 @@
1
+ import e from"./MailMessage-DmmaNHHc.js";class t extends e{constructor(){super(),this.header("X-Unsent","1")}}export{t as default};
@@ -0,0 +1 @@
1
+ class l extends Error{loc;title;hint;type="VisulimaError";constructor({cause:t,hint:e,location:s,message:a,name:c,stack:r,title:h}){super(a,{cause:t}),this.title=h,this.name=c,this.stack=r??this.stack,this.loc=s,this.hint=e}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}class o extends l{component;code;constructor(t,e,s){super({cause:s?.cause,hint:s?.hint,message:`[@visulima/email] [${t}] ${e}`,name:"EmailError",title:`Email ${t} Error`}),this.component=t,this.code=s?.code}}export{o as default};
@@ -0,0 +1 @@
1
+ import f from"./DraftMailMessage-B0gwf8n_.js";import v from"./EmailError-BIaHK1Uw.js";import u from"./MailMessage-DmmaNHHc.js";import{composeMiddleware as w}from"./composeMiddleware-B3RCDFsy.js";import{b as C}from"./build-mime-message-BCFKPqaW.js";import{c as M}from"./create-logger-CazqtXcL.js";import{h as d}from"./headers-to-record-ZOZ7Dubo.js";import T from"../utils/validation/check-feature-support.js";const S=(a,e,r)=>{e.success&&e.data?a&&a.info("Email sent successfully",{messageId:e.data.messageId,provider:e.data.provider}):a&&a.error("Email send failed",{error:e.error,provider:r})},E=async(a,e,r)=>{const t={...a,to:e.to};return e.cc&&(t.cc=e.cc),e.bcc&&(t.bcc=e.bcc),e.replyTo&&(t.replyTo=e.replyTo),e.headers&&(t.headers={...d(a.headers??{}),...d(e.headers)}),t.subject=e.subject??a.subject,r&&e.data&&(t.subject=await r(t.subject,e.data),a.html!==void 0&&(t.html=await r(a.html,e.data)),a.text!==void 0&&(t.text=await r(a.text,e.data))),t};class h{static extractErrorMessages(e){return e instanceof Error?[e.message]:[String(e??"Unknown error")]}provider;logger;loggerInstance;globalConfig;featureCheck;middlewares=[];composedSend;mountedProviders=new Map;constructor(e,r){this.provider=e,this.featureCheck=r?.featureCheck??"error"}setLogger(e){return this.loggerInstance=e,this.logger=M("Mail",e),this}use(e){return this.middlewares.push(e),this.composedSend=void 0,this}mount(e,r){return this.mountedProviders.set(e,r),this}setFrom(e){return this.globalConfig??={},this.globalConfig.from=e,this.logger&&this.logger.debug("Default from address updated",{from:e.email}),this}setReplyTo(e){return this.globalConfig??={},this.globalConfig.replyTo=e,this.logger&&this.logger.debug("Default reply-to address updated",{replyTo:e.email}),this}setHeaders(e){if(this.globalConfig??={},this.globalConfig.headers=e,this.logger){const r=d(e);this.logger.debug("Default headers updated",{count:Object.keys(r).length,headers:Object.keys(r)})}return this}async draft(e){let r=e instanceof u||e instanceof f?await this.buildDraftFromMessage(e):await this.buildDraftFromOptions(e);r=this.applyGlobalConfig(r);const t=r.headers?d(r.headers):{};r.headers={...t,"X-Unsent":"1"};const s=await C(r,{includeBcc:!0});return this.logger&&this.logger.debug("Draft created successfully in EML format",{from:r.from.email,size:s.length,subject:r.subject,to:Array.isArray(r.to)?r.to.length:1}),s}async send(e){if(e instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");let r;if(e instanceof u)this.logger&&this.logger.debug("Sending MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),r=await e.build();else{const o=e;this.logger&&this.logger.debug("Sending email with options",{subject:o.subject,to:Array.isArray(o.to)?o.to.length:1}),r=o}r=this.applyGlobalConfig(r);const t=this.assertFeatureSupport(r,this.resolveProvider(r));if(t)return{error:t,success:!1};const s=await this.dispatch(r);return S(this.logger,s,this.provider.name??"unknown"),s}sendMany(e,r){const t=Math.max(1,Math.floor(r?.concurrency??1));return t===1?this.sendManySerial(e,r?.signal):this.sendManyConcurrent(e,t,r?.signal)}sendBatch(e,r,t){const s=async function*(){const o=e instanceof u?await e.build():e;for(const i of r)yield await E(o,i,t?.render)};return this.sendMany(s(),{concurrency:t?.concurrency,signal:t?.signal})}async sendOneToReceipt(e){const r=this.provider.name;try{const t=await this.send(e);return t.success&&t.data?{messageId:t.data.messageId,provider:t.data.provider??r,response:t.data.response,successful:!0,timestamp:t.data.timestamp}:{errorMessages:h.extractErrorMessages(t.error),provider:r,successful:!1}}catch(t){return{errorMessages:h.extractErrorMessages(t),provider:r,successful:!1}}}async*sendManySerial(e,r){const t=this.provider.name;let s=0,o=0,i=0;this.logger&&this.logger.debug("Starting batch email send",{provider:t});for await(const l of e){if(l instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");if(r?.aborted){this.logger&&this.logger.warn("Batch send operation was aborted",{failed:i,processed:s,successful:o}),yield{errorMessages:["Send operation was aborted"],provider:t,successful:!1};return}s+=1;const n=await this.sendOneToReceipt(l);n.successful?o+=1:i+=1,yield n}this.logger&&this.logger.debug("Batch email send completed",{failureCount:i,processedCount:s,provider:t,successCount:o})}async*sendManyConcurrent(e,r,t){const s=this.provider.name;this.logger&&this.logger.debug("Starting concurrent batch email send",{concurrency:r,provider:s});const o=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator](),i=new Map;let l=0,n=!1,p=!1;const m=async()=>{for(;!n&&!p&&i.size<r;){const g=await o.next();if(g.done){n=!0;break}const c=g.value;if(c instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");const b=l;l+=1,i.set(b,this.sendOneToReceipt(c).then(y=>({id:b,receipt:y})))}};for(await m();i.size>0;){if(t?.aborted){p=!0,yield{errorMessages:["Send operation was aborted"],provider:s,successful:!1};return}const{id:g,receipt:c}=await Promise.race(i.values());i.delete(g),yield c,await m()}this.logger&&this.logger.debug("Concurrent batch email send completed",{processedCount:l,provider:s})}async dispatch(e){return this.middlewares.length===0?await this.resolveProvider(e).sendEmail(e):(this.composedSend??=w(this.middlewares,r=>Promise.resolve(this.resolveProvider(r).sendEmail(r))),await this.composedSend(e))}resolveProvider(e){return e.stream!==void 0?this.mountedProviders.get(e.stream)??this.provider:this.provider}assertFeatureSupport(e,r){if(this.featureCheck==="off")return;const{supported:t,violations:s}=T(e,r.features);if(t)return;const o=r.name??"unknown",i=s.map(n=>n.field),l=s.map(n=>n.message);if(this.featureCheck==="warn"){this.logger&&this.logger.warn("Message uses capabilities the provider does not support",{fields:i,provider:o});return}return this.logger&&this.logger.error("Message rejected by capability guard",{fields:i,provider:o}),new v(o,`Provider does not support the following message fields: ${i.join(", ")}`,{code:"UNSUPPORTED_FEATURES",hint:l})}async buildDraftFromMessage(e){return this.logger&&this.logger.debug("Creating draft from MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),this.applyGlobalConfigToMessage(e),await e.build()}async buildDraftFromOptions(e){return this.logger&&this.logger.debug("Creating draft from email options",{subject:e.subject,to:Array.isArray(e.to)?e.to.length:1}),e}applyGlobalConfigToMessage(e){const r=this.globalConfig?.from;r&&!e.getFrom()&&e.from(r);const t=this.globalConfig?.replyTo;if(t&&!e.getReplyTo()&&e.replyTo(t),this.globalConfig?.headers){const s=d(this.globalConfig.headers);Object.entries(s).forEach(([o,i])=>{e.header(o,i)})}}applyGlobalConfig(e){if(!this.globalConfig)return e;const r={...e};if(!r.from&&this.globalConfig.from&&(r.from=this.globalConfig.from,this.logger&&this.logger.debug("Applied global from address",{from:this.globalConfig.from.email})),!r.replyTo&&this.globalConfig.replyTo&&(r.replyTo=this.globalConfig.replyTo,this.logger&&this.logger.debug("Applied global reply-to address",{replyTo:this.globalConfig.replyTo.email})),this.globalConfig.headers){const t=d(this.globalConfig.headers),s=r.headers?d(r.headers):{};r.headers={...t,...s},this.logger&&this.logger.debug("Merged global headers",{globalCount:Object.keys(t).length,messageCount:Object.keys(s).length})}return r}}const O=(a,e)=>new h(a,e);export{h as Mail,O as createMail};
@@ -0,0 +1 @@
1
+ import{createRequire as p}from"node:module";import{readFileAsBuffer as c,detectMimeType as d,generateContentId as u}from"./detectMimeType-BRz3Qjyz.js";import{c as T}from"./create-logger-CazqtXcL.js";import{h as l}from"./headers-to-record-ZOZ7Dubo.js";let y;const A=n=>(y??=p(import.meta.url))(n),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=n=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,e]=o.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return o.getBuiltinModule(n)}return A(n)},{basename:g}=f("node:path"),{fileURLToPath:b}=f("node:url"),m=async()=>(await import("../template-engines/html-to-text.js")).default,x=async()=>(await import("ical-generator")).default,a=n=>Array.isArray(n)?n.map(t=>typeof t=="string"?{email:t}:t):typeof n=="string"?[{email:n}]:[n];class D{fromAddress;toAddresses=[];ccAddresses=[];bccAddresses=[];subjectText="";textContent;textCharset="utf8";autoTextEnabled=!0;htmlContent;htmlCharset="utf8";dateValue;returnPathAddress;senderAddress;headers={};attachments=[];replyToAddress;priorityValue;tagsValue=[];signer;encrypter;logger;icalEventData;icalEventBuilder;from(t){return this.fromAddress=typeof t=="string"?{email:t}:t,this}to(t){return this.toAddresses.length=0,this.toAddresses.push(...a(t)),this}cc(t){return this.ccAddresses.length=0,this.ccAddresses.push(...a(t)),this}bcc(t){return this.bccAddresses.length=0,this.bccAddresses.push(...a(t)),this}subject(t){return this.subjectText=t,this}text(t,e="utf8"){return this.textContent=t,this.textCharset=e,this}html(t,e="utf8"){return this.htmlContent=t,this.htmlCharset=e,this}header(t,e){return this.headers[t]=e,this}setHeaders(t){const e=l(t);return Object.assign(this.headers,e),this}async attachFromPath(t,e){try{const r=await c(t),i=e?.filename??(g(t)||"attachment"),s=e?.contentType??d(i);this.attachments.push({cid:e?.cid,content:r,contentDisposition:e?.contentDisposition??"attachment",contentType:s,encoding:e?.encoding,filename:i,headers:e?.headers}),this.logger&&this.logger.debug(`Attachment added from path: ${t}`,{contentType:s,filename:i})}catch(r){throw this.logger&&this.logger.error(`Failed to attach file from path: ${t}`,r),r}return this}attachData(t,e){const r=e.contentType??d(e.filename);return this.attachments.push({cid:e.cid,content:t,contentDisposition:e.contentDisposition??"attachment",contentType:r,encoding:e.encoding,filename:e.filename,headers:e.headers}),this.logger&&this.logger.debug("Attachment added from data",{contentType:r,filename:e.filename}),this}async embedFromPath(t,e){try{const r=await c(t),i=e?.filename??(g(t)||"inline"),s=e?.contentType??d(i),h=u(i);return this.attachments.push({cid:h,content:r,contentDisposition:"inline",contentType:s,filename:i}),this.logger&&this.logger.debug(`Inline attachment embedded from path: ${t}`,{cid:h,contentType:s,filename:i}),h}catch(r){throw this.logger&&this.logger.error(`Failed to embed file from path: ${t}`,r),r}}embedData(t,e,r){const i=r?.contentType??d(e),s=u(e);return this.attachments.push({cid:s,content:t,contentDisposition:"inline",contentType:i,filename:e}),this.logger&&this.logger.debug("Inline attachment embedded from data",{cid:s,contentType:i,filename:e}),s}replyTo(t){return this.replyToAddress=typeof t=="string"?{email:t}:t,this}date(t){return this.dateValue=typeof t=="string"?new Date(t):t,this.logger&&this.logger.debug("Date header set",{date:this.dateValue.toISOString()}),this}returnPath(t){return this.returnPathAddress=typeof t=="string"?{email:t}:t,this.logger&&this.logger.debug("Return-path address set",{returnPath:this.returnPathAddress.email}),this}sender(t){return this.senderAddress=typeof t=="string"?{email:t}:t,this.logger&&this.logger.debug("Sender address set",{sender:this.senderAddress.email}),this}addTo(t){return this.toAddresses.push(...a(t)),this}addCc(t){return this.ccAddresses.push(...a(t)),this}addBcc(t){return this.bccAddresses.push(...a(t)),this}addReplyTo(t){const e=Array.isArray(t)?t:[t];if(e.length>0){const r=e[0];this.replyToAddress=typeof r=="string"?{email:r}:r}return this}addFrom(t){const e=Array.isArray(t)?t:[t];if(e.length>0){const r=e[0];this.fromAddress=typeof r=="string"?{email:r}:r}return this}priority(t){return this.priorityValue=t,this}tags(t){return this.tagsValue=Array.isArray(t)?t:[t],this}sign(t){return this.signer=t,this.logger&&this.logger.debug("Email signer configured"),this}encrypt(t){return this.encrypter=t,this.logger&&this.logger.debug("Email encrypter configured"),this}setLogger(t){return this.logger=T("MailMessage",t),this}icalEvent(t,e){return typeof t=="function"?(this.icalEventBuilder={build:t,options:e},this.icalEventData=void 0):(this.icalEventBuilder=void 0,this.icalEventData={content:t,...e}),this.logger&&this.logger.debug("Calendar event attached",{method:e?.method}),this}icalEventFromFile(t,e){const r=typeof t=="string"?t:b(t);return this.icalEventData={path:r,...e},this.logger&&this.logger.debug(`Calendar event attached from file: ${r}`,{method:e?.method}),this}icalEventFromUrl(t,e){return this.icalEventData={href:t,...e},this.logger&&this.logger.debug(`Calendar event attached from URL: ${t}`,{method:e?.method}),this}async view(t,e,r,i){try{const s=i?.autoText!==!1;this.autoTextEnabled=s,this.logger&&this.logger.debug("Rendering template",{autoText:s});const h=await t(e,r,i);this.html(h),s&&h&&await this.tryAutoGenerateText(h),this.logger&&this.logger.debug("Template rendered successfully")}catch(s){throw this.logger&&this.logger.error("Failed to render template",s),new Error(`Failed to render template: ${s.message}`)}return this}async viewText(t,e,r,i){try{this.logger&&this.logger.debug("Rendering text template");const s=await t(e,r,i);if(typeof s=="string")this.text(s),this.logger&&this.logger.debug("Text template rendered successfully");else throw new TypeError("Text renderer must return a string")}catch(s){throw this.logger&&this.logger.error("Failed to render text template",s),new Error(`Failed to render text template: ${s.message}`)}return this}async build(){if(this.logger&&this.logger.debug("Building email message"),this.fromAddress||this.throwAndLogError("From address is required","Build failed: from address is required"),this.toAddresses.length===0&&this.throwAndLogError("At least one recipient is required","Build failed: at least one recipient is required"),this.subjectText||this.throwAndLogError("Subject is required","Build failed: subject is required"),this.htmlContent&&!this.textContent&&this.autoTextEnabled)try{const e=await m();this.textContent=e(this.htmlContent),this.logger&&this.logger.debug("Auto-generated text content from HTML")}catch{this.logger&&this.logger.debug("Failed to convert HTML to text; proceeding without text content.")}!this.textContent&&!this.htmlContent&&this.throwAndLogError("Either text or html content is required","Build failed: either text or html content is required");let t={from:this.fromAddress,html:this.htmlContent,subject:this.subjectText,text:this.textContent,to:this.toAddresses.length===1?this.toAddresses[0]:this.toAddresses};if(this.ccAddresses.length>0&&(t.cc=this.ccAddresses.length===1?this.ccAddresses[0]:this.ccAddresses),this.bccAddresses.length>0&&(t.bcc=this.bccAddresses.length===1?this.bccAddresses[0]:this.bccAddresses),Object.keys(this.headers).length>0&&(t.headers=this.headers),this.attachments.length>0&&(t.attachments=this.attachments,this.logger&&this.logger.debug(`Email includes ${this.attachments.length} attachment(s)`)),this.replyToAddress&&(t.replyTo=this.replyToAddress),this.priorityValue&&(t.priority=this.priorityValue),this.tagsValue.length>0&&(t.tags=this.tagsValue),this.icalEventBuilder){const r=(await x())();this.icalEventBuilder.build(r),this.icalEventData={content:r.toString(),...this.icalEventBuilder.options}}return this.icalEventData&&(t.icalEvent=this.icalEventData,this.logger&&this.logger.debug("Email includes calendar event")),this.dateValue&&(t.headers={...l(t.headers??{}),Date:this.dateValue.toUTCString()}),this.returnPathAddress&&(t.headers={...l(t.headers??{}),"Return-Path":this.returnPathAddress.email}),this.senderAddress&&(t.headers={...l(t.headers??{}),Sender:this.senderAddress.email}),this.signer&&(this.logger&&this.logger.debug("Signing email message"),t=await this.signer.sign(t),this.logger&&this.logger.debug("Email message signed successfully")),this.encrypter&&(this.logger&&this.logger.debug("Encrypting email message"),t=await this.encrypter.encrypt(t),this.logger&&this.logger.debug("Email message encrypted successfully")),this.logger&&this.logger.debug("Email message built successfully",{bcc:this.bccAddresses.length,cc:this.ccAddresses.length,hasHtml:!!this.htmlContent,hasText:!!this.textContent,to:this.toAddresses.length}),t}getSubject(){return this.subjectText}getFrom(){return this.fromAddress}getTo(){return[...this.toAddresses]}getCc(){return[...this.ccAddresses]}getBcc(){return[...this.bccAddresses]}getReplyTo(){return this.replyToAddress}getSender(){return this.senderAddress}getReturnPath(){return this.returnPathAddress}getDate(){return this.dateValue}getPriority(){return this.priorityValue}getTextBody(){return this.textContent}getTextCharset(){return this.textCharset}getHtmlBody(){return this.htmlContent}getHtmlCharset(){return this.htmlCharset}getAttachments(){return[...this.attachments]}async tryAutoGenerateText(t){try{const r=(await m())(t);r&&!this.textContent&&this.text(r),this.logger&&this.logger.debug("Auto-generated text content from HTML template")}catch(e){this.logger&&this.logger.warn("Failed to auto-generate text from HTML template",e)}}throwAndLogError(t,e){const r=new Error(t);throw this.logger&&this.logger.error(e??t),r}}export{D as default};
@@ -0,0 +1 @@
1
+ const s=a=>a.trim().toLowerCase();class i{entries=new Map;constructor(e){if(e)for(const{address:r,metadata:n,reason:t}of e)this.add(r,t,n)}add(e,r,n){const t=s(e);this.entries.set(t,{address:t,createdAt:new Date,metadata:n,reason:r})}get(e){return this.entries.get(s(e))}has(e){return this.entries.has(s(e))}list(){return this.entries.values()}remove(e){return this.entries.delete(s(e))}get size(){return this.entries.size}}export{i as default};
@@ -0,0 +1 @@
1
+ const w=a=>new Promise(n=>{setTimeout(n,a)}),p={"aws-ses":14,mailgun:100,postmark:100,resend:10,sendgrid:100},h=a=>{const{burst:n,now:o=Date.now,rate:t,sleep:d=w}=a;if(t<=0||Number.isNaN(t))throw new TypeError("rateLimitMiddleware: `rate` must be a positive number");const c=n??t;let s=c,l=o(),u=Promise.resolve();const m=async()=>{const i=()=>{const e=o(),r=(e-l)/1e3;s=Math.min(c,s+r*t),l=e};for(i();s<1;){const e=1-s;await d(Math.ceil(e/t*1e3)),i()}s-=1};return async(i,e)=>{const r=u.then(()=>m());return u=r.catch(()=>{}),await r,e(i)}};export{p as RATE_LIMIT_PRESETS,h as rateLimitMiddleware};
@@ -0,0 +1 @@
1
+ import s from"./EmailError-BIaHK1Uw.js";class n extends s{constructor(o,r){const e=Array.isArray(r)?`Missing required options: ${r.map(i=>`'${i}'`).join(", ")}`:`Missing required option: '${r}'`;super(o,e,{hint:Array.isArray(r)?`Please provide the following required options: ${r.map(i=>`'${i}'`).join(", ")}`:`Please provide the required option: '${r}'`}),this.name="RequiredOptionError"}}export{n as default};
@@ -0,0 +1,6 @@
1
+ import{createRequire as O}from"node:module";import{readFile as I}from"../packem_chunks/index.js";import{fromBER as S,OctetString as B}from"asn1js";import{Certificate as P,EnvelopedData as G,EncryptedContentInfo as V,id_ContentType_Data as J,RecipientInfo as Q,KeyTransRecipientInfo as W,IssuerAndSerialNumber as X,AlgorithmIdentifier as $,ContentInfo as Y,id_ContentType_EnvelopedData as Z}from"pkijs";let F;const L=o=>(F??=O(import.meta.url))(o),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=o=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[e,t]=y.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return y.getBuiltinModule(o)}return L(o)},{randomBytes:T,createCipheriv:U,createPublicKey:z,publicEncrypt:H}=q("node:crypto"),g=globalThis.Buffer!==void 0,D=o=>{const e=o.replaceAll(/-----BEGIN[^-]+-----/g,"").replaceAll(/-----END[^-]+-----/g,"").replaceAll(/\s/g,"");if(g)return Buffer.from(e,"base64");const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n+=1)r[n]=t.charCodeAt(n);return r},j=(o,e)=>{let t;if(g)t=Buffer.from(o).toString("base64");else{const n=new Uint8Array(o);let l="";const s=8192;for(let c=0;c<n.length;c+=s){const h=n.subarray(c,Math.min(c+s,n.length));l+=String.fromCharCode(...h)}t=btoa(l)}const r=t.match(/.{1,64}/g)??[];return`-----BEGIN ${e}-----
2
+ ${r.join(`
3
+ `)}
4
+ -----END ${e}-----
5
+ `};class i{static collectRecipients(e){const t=[],r=n=>{if(!n)return;const l=Array.isArray(n)?n:[n];for(const s of l){const c=typeof s=="string"?s:s.email;c&&t.push(c)}};return r(e.to),r(e.cc),r(e.bcc),[...new Set(t)]}static formatAddress(e){return typeof e=="string"?e:e.name?`"${e.name}" <${e.email}>`:e.email}static formatAddresses(e){return(Array.isArray(e)?e:[e]).map(r=>i.formatAddress(r)).join(", ")}options;constructor(e){this.options=e}async encrypt(e){const t=i.collectRecipients(e),r=[];if(typeof this.options.certificates=="string"){const a=await I(this.options.certificates,{encoding:"utf8"}),f=D(a),u=S(f);if(u.offset===-1)throw new Error("Failed to parse certificate: Invalid ASN.1 structure");r.push(new P({schema:u.result}))}else{const a=t.map(async f=>{const u=this.options.certificates[f];if(!u)throw new Error(`No certificate found for recipient: ${f}`);const A=await I(u,{encoding:"utf8"}),E=D(A),p=S(E);if(p.offset===-1)throw new Error(`Failed to parse certificate for ${f}: Invalid ASN.1 structure`);return new P({schema:p.result})});r.push(...await Promise.all(a))}const n=await this.buildMessage(e),l=new TextEncoder().encode(n),s=new G({version:0});s.encryptedContentInfo=new V({contentType:J});const h=(this.options.algorithm??"aes-256-cbc").toLowerCase();if(h==="3des"||h==="des-ede3-cbc")throw new Error("3DES/DES-EDE3-CBC is deprecated and insecure (Sweet32 vulnerability). Please use AES-256-CBC, AES-192-CBC, or AES-128-CBC instead.");let m,d;switch(h){case"aes128":case"aes-128-cbc":{m="2.16.840.1.101.3.4.1.2",d=16;break}case"aes192":case"aes-192-cbc":{m="2.16.840.1.101.3.4.1.22",d=24;break}default:{m="2.16.840.1.101.3.4.1.42",d=32;break}}const w=T(d),k=g?w:new Uint8Array(w),C=T(16),_=g?C:new Uint8Array(C),v=U(`aes-${d*8}-cbc`,w,C),x=Buffer.from(l),N=[v.update(x),v.final()],b=Buffer.concat(N);s.encryptedContentInfo.encryptedContent=new B({valueHex:b.buffer.slice(b.byteOffset,b.byteOffset+b.byteLength)});const R=await Promise.all(r.map(async a=>{const f=a.toSchema().toBER(!1),u=j(f,"CERTIFICATE"),A=z(u),E=Buffer.from(k),p=H({key:A,padding:1},E);return new Q({value:new W({encryptedKey:new B({valueHex:p.buffer.slice(p.byteOffset,p.byteOffset+p.byteLength)}),keyEncryptionAlgorithm:new $({algorithmId:"1.2.840.113549.1.1.1"}),rid:new X({issuer:a.issuer,serialNumber:a.serialNumber}),version:0}),variant:0})}));s.recipientInfos.push(...R),s.encryptedContentInfo.contentEncryptionAlgorithm=new $({algorithmId:m,algorithmParams:new B({valueHex:_.buffer})});const K=new Y({content:s.toSchema(),contentType:Z}).toSchema().toBER(!1),M=j(K,"PKCS7");return{...e,headers:{...e.headers,"Content-Disposition":"attachment; filename=smime.p7m","Content-Transfer-Encoding":"base64","Content-Type":"application/pkcs7-mime; smime-type=enveloped-data; name=smime.p7m"},html:void 0,text:M}}async buildMessage(e){const t=[`From: ${i.formatAddress(e.from)}`,`To: ${i.formatAddresses(e.to)}`,...e.cc?[`Cc: ${i.formatAddresses(e.cc)}`]:[]];if(e.replyTo&&t.push(`Reply-To: ${i.formatAddress(e.replyTo)}`),t.push(`Subject: ${e.subject}`,"MIME-Version: 1.0"),e.headers)for(const[r,n]of Object.entries(e.headers))t.push(`${r}: ${n}`);return e.html?t.push("Content-Type: text/html; charset=utf-8"):e.text&&t.push("Content-Type: text/plain; charset=utf-8"),t.push(""),e.html?t.push(e.html):e.text&&t.push(e.text),t.join(`\r
6
+ `)}}const oe=o=>new i(o);export{i as SmimeEncrypter,oe as createSmimeEncrypter};
@@ -0,0 +1,8 @@
1
+ import{createRequire as q}from"node:module";import{readFile as y}from"../packem_chunks/index.js";import{fromBER as D,ObjectIdentifier as W,OctetString as I,UTCTime as X}from"asn1js";import{Certificate as j,SignedData as Y,EncapsulatedContentInfo as Z,id_ContentType_Data as x,SignerInfo as ee,AlgorithmIdentifier as E,IssuerAndSerialNumber as te,id_sha256 as ne,SignedAndUnsignedAttributes as se,Attribute as b,ContentInfo as re,id_ContentType_SignedData as oe}from"pkijs";import{g as ie}from"./generate-boundary-BCSUEi6x.js";let V;const z=o=>(V??=q(import.meta.url))(o),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=o=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,t]=p.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return p.getBuiltinModule(o)}return z(o)},{createPrivateKey:B,createHash:L,createSign:J,randomBytes:Q}=G("node:crypto"),ae="1.2.840.113549.1.9.3",ce="1.2.840.113549.1.9.4",ue="1.2.840.113549.1.9.5",fe="1.2.840.113549.1.1.1",pe={v1:1},le={v1:1},l=globalThis.Buffer!==void 0,N=o=>{const e=o.replaceAll(/-----BEGIN[^-]+-----/g,"").replaceAll(/-----END[^-]+-----/g,"").replaceAll(/\s/g,"");if(l)return Buffer.from(e,"base64");const t=atob(e),s=new Uint8Array(t.length);for(let n=0;n<t.length;n+=1)s[n]=t.codePointAt(n);return s},de=(o,e)=>{let t;if(l)t=Buffer.from(o).toString("base64");else{const n=new Uint8Array(o);let r="";const a=8192;for(let i=0;i<n.length;i+=a){const h=n.subarray(i,Math.min(i+a,n.length));r+=String.fromCharCode(...h)}t=btoa(r)}const s=t.match(/.{1,64}/g)??[];return`-----BEGIN ${e}-----
2
+ ${s.join(`
3
+ `)}
4
+ -----END ${e}-----
5
+ `};class d{static formatAddress(e){return e.name?`"${e.name.replaceAll("\\","\\\\").replaceAll('"',String.raw`\"`)}" <${e.email}>`:e.email}options;constructor(e){this.options=e}async sign(e){const t=await y(this.options.certificate,{encoding:"utf8"}),s=await y(this.options.privateKey,{encoding:"utf8"}),n=N(t),r=D(n);if(r.offset===-1)throw new Error("Failed to parse certificate: Invalid ASN.1 structure");const a=new j({schema:r.result});let i;try{i=this.options.passphrase?B({key:s,passphrase:this.options.passphrase}):B(s)}catch(c){throw new Error(`Failed to parse private key: ${c.message}`)}const h=[];if(this.options.intermediateCerts){const c=this.options.intermediateCerts.map(async _=>{const F=await y(_,{encoding:"utf8"}),H=N(F),$=D(H);if($.offset===-1)throw new Error(`Failed to parse intermediate certificate ${_}: Invalid ASN.1 structure`);return new j({schema:$.result})});h.push(...await Promise.all(c))}const A=this.buildMessage(e),w=new TextEncoder().encode(A),m=new Y({version:pe.v1});m.encapContentInfo=new Z({eContentType:x});const g=new ee({digestAlgorithm:new E({algorithmId:ne}),sid:new te({issuer:a.issuer,serialNumber:a.serialNumber}),signatureAlgorithm:new E({algorithmId:fe}),version:le.v1}),C=L("sha256");C.update(l?Buffer.from(w):w);const P=C.digest(),M=new Uint8Array(P),T=new se({attributes:[new b({type:ae,values:[new W({value:x})]}),new b({type:ce,values:[new I({valueHex:M.buffer.slice(0)})]}),new b({type:ue,values:[new X({valueDate:new Date})]})]});g.signedAttrs=T;const v=T.toSchema().toBER(!1),R=l?Buffer.from(v):new Uint8Array(v),S=J("RSA-SHA256");S.update(R);const u=S.sign(i),k=l?u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength):u.buffer;g.signature=new I({valueHex:k}),m.signerInfos.push(g),m.certificates=[a,...h];const K=new re({content:m.toSchema(),contentType:oe}).toSchema().toBER(!1),O=de(K,"PKCS7"),f=`----_=_NextPart_${Date.now()}_${Q(8).toString("hex")}`,U=[`Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="${f}"`,"",`--${f}`,A,`--${f}`,"Content-Type: application/pkcs7-signature; name=smime.p7s","Content-Transfer-Encoding: base64","Content-Disposition: attachment; filename=smime.p7s","",O.split(`
6
+ `).filter(c=>c.trim()&&!c.includes("-----")).join(""),`--${f}--`].join(`\r
7
+ `);return{...e,headers:{...e.headers,"Content-Type":`multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="${f}"`},html:void 0,text:U}}buildMessage(e){const t=[`From: ${d.formatAddress(e.from)}`,`To: ${this.formatAddresses(e.to)}`];if(e.cc&&t.push(`Cc: ${this.formatAddresses(e.cc)}`),e.replyTo&&t.push(`Reply-To: ${d.formatAddress(e.replyTo)}`),t.push(`Subject: ${e.subject}`,"MIME-Version: 1.0"),e.headers)for(const[a,i]of Object.entries(e.headers))t.push(`${a}: ${i}`);const s=!!e.text,n=!!e.html;let r;return s&&n?(r=ie(),t.push(`Content-Type: multipart/alternative; boundary="${r}"`)):n?t.push("Content-Type: text/html; charset=utf-8"):t.push("Content-Type: text/plain; charset=utf-8"),t.push(""),s&&n&&r?t.push(`--${r}`,"Content-Type: text/plain; charset=utf-8","",e.text,"",`--${r}`,"Content-Type: text/html; charset=utf-8","",e.html,"",`--${r}--`):s?t.push(e.text):n&&t.push(e.html),t.join(`\r
8
+ `)}formatAddresses(e){return(Array.isArray(e)?e:[e]).map(s=>d.formatAddress(s)).join(", ")}}const we=o=>new d(o);export{d as SmimeSigner,we as createSmimeSigner};
@@ -0,0 +1 @@
1
+ import{f as m}from"./format-address-Bb7xk8G_.js";const e=r=>m(r),o=r=>(Array.isArray(r)?r:[r]).map(t=>e(t)),i=r=>{const a={email:r.email};return r.name&&(a.name=r.name),a},f=r=>(Array.isArray(r)?r:[r]).map(t=>i(t)),u=r=>(Array.isArray(r)?r:[r]).map(t=>t.email),A=r=>({email:r.email,...r.name&&{displayName:r.name}}),y=r=>(Array.isArray(r)?r:[r]).map(t=>A(t)),c=r=>{const a={Email:r.email};return r.name&&(a.Name=r.name),a},L=r=>(Array.isArray(r)?r:[r]).map(t=>c(t)),l=(r,a="to")=>({email:r.email,...r.name&&{name:r.name},type:a}),p=(r,a="to")=>(Array.isArray(r)?r:[r]).map(n=>l(n,a)),s=r=>({address:r.email,...r.name&&{name:r.name}}),M=r=>(Array.isArray(r)?r:[r]).map(t=>s(t)),j=r=>o(r),z=r=>s(r);export{i as a,y as b,A as c,u as d,o as e,f,e as g,L as h,c as i,j,p as k,M as l,s as m,z as n};
@@ -0,0 +1 @@
1
+ const o=["attachments","batchSending","customHeaders","html","replyTo","scheduling","tagging","templates","tracking"],a=e=>typeof e=="function",c=e=>e!==null&&typeof e=="object"&&"initialize"in e&&"isAvailable"in e&&"sendEmail"in e,f=e=>{if(c(e))return e.features;if(a(e))try{return e({}).features}catch{return}};function u(e){const i=e.map(t=>f(t)).filter(t=>t!==void 0),n={};if(i.length===0)return n;for(const t of o){const s=i.map(r=>r[t]);s.every(r=>r===!0)?n[t]=!0:s.every(r=>r===!1)&&(n[t]=!1)}return n}export{u as a};
@@ -0,0 +1 @@
1
+ import c from"./EmailError-BIaHK1Uw.js";import b from"./RequiredOptionError-ctDEEB1s.js";import{g as v}from"./generate-message-id-B2n2yqR6.js";import{h as E}from"./headers-to-record-ZOZ7Dubo.js";import{m as u}from"./make-request-Cyz5_yu8.js";import{r as h}from"./retry-aghj7y8m.js";import{v as w}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{c as T,h as g,P as I}from"./provider-base-BEz00m9R.js";import{f as l,a as P}from"./address-formatter-w36S9ZYj.js";import{p as S}from"./attachment-processor-BJFDS343.js";const t="ahasend",C="https://api.ahasend.com",R=3e4,$=3,N=A((o={})=>{if(!o.apiKey)throw new b(t,"apiKey");const a={apiKey:o.apiKey,debug:o.debug??!1,endpoint:o.endpoint??C,retries:o.retries??$,timeout:o.timeout??R,...o.logger&&{logger:o.logger}},y=new I,s=T(t,o.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(t,"Email ID is required to retrieve email details"),success:!1};await this.initialize();const i={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};s.debug("Retrieving email details",{id:e});const r=await h(async()=>u(`${a.endpoint}/emails/${e}`,{headers:i,method:"GET",timeout:a.timeout}),a.retries);return r.success?(s.debug("Email details retrieved successfully"),{data:r.data?.body,success:!0}):(s.debug("API request failed when retrieving email",r.error),{error:new c(t,`Failed to retrieve email: ${r.error instanceof Error?r.error.message:"Unknown error"}`,{cause:r.error}),success:!1})}catch(i){return{error:g(t,"retrieve email",i,s),success:!1}}},async initialize(){await y.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(t,"AhaSend API not available or invalid API key");s.debug("Provider initialized successfully")},t)},async isAvailable(){try{s.debug("Checking AhaSend API availability");const e=await u(`${a.endpoint}/v2/ping`,{headers:{Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},method:"GET",timeout:a.timeout});if(e.success)return!0;const i=e.data?.statusCode??e.error?.statusCode;return!1}catch(e){return s.debug("Error checking availability:",e),!1}},name:t,options:a,async sendEmail(e){try{const i=w(e);if(i.length>0)return{error:new c(t,`Invalid email options: ${i.join(", ")}`),success:!1};await this.initialize();const r={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:l(e.to)};if(e.html&&(r.html=e.html),e.text&&(r.text=e.text),e.cc&&(r.cc=l(e.cc)),e.bcc&&(r.bcc=l(e.bcc)),e.replyTo&&(r.replyTo=P(e.replyTo)),e.templateId&&(r.templateId=e.templateId,e.templateVariables&&(r.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(r.tags=e.tags),e.headers){const n=E(e.headers);r.headers=n}e.attachments&&e.attachments.length>0&&(r.attachments=await Promise.all(e.attachments.map(async n=>({content:await S(n,t),contentType:n.contentType??"application/octet-stream",filename:n.filename,...n.cid&&{cid:n.cid}})))),s.debug("Sending email via AhaSend API",{subject:r.subject,to:r.to});const p={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},d=await h(async()=>u(`${a.endpoint}/send`,{headers:p,method:"POST",timeout:a.timeout},JSON.stringify(r)),a.retries);if(!d.success)return s.debug("API request failed when sending email",d.error),{error:d.error??new c(t,"Failed to send email"),success:!1};const m=d.data?.body,f=m?.messageId??m?.id??v();return s.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:t,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(i){return{error:g(t,"send email",i,s),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{N as default};
@@ -0,0 +1,9 @@
1
+ import{createRequire as I}from"node:module";import{readFile as W}from"../packem_chunks/index.js";import{s as T,o as J,p as D,c as K,a as y}from"./canonicalize-BEjQUnUe.js";let V;const F=a=>(V??=I(import.meta.url))(a),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=a=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[e,s]=f.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return f.getBuiltinModule(a)}return F(a)},{Buffer:H}=E("node:buffer"),{createHash:b,createPublicKey:O,createPrivateKey:q,sign:G,createSign:U,verify:M}=E("node:crypto"),Q=/^\s*i=(\d+)\s*;/,X=["from","to","cc","subject","date","message-id","mime-version"],m=(a,e)=>y(a,e,"relaxed"),_=a=>{const e={};for(const s of a.split(";")){const t=s.indexOf("=");t!==-1&&(e[s.slice(0,t).trim()]=s.slice(t+1).trim())}return e},j=a=>{const e=a.lastIndexOf("b=");return e===-1?a:a.slice(0,e+2)},B=(a,e,s)=>s==="ed25519-sha256"?G(null,b("sha256").update(a).digest(),e).toString("base64"):U("RSA-SHA256").update(a).sign(e,"base64"),x=(a,e,s,t)=>{const n=H.from(e,"base64");try{return t==="ed25519-sha256"?M(null,b("sha256").update(a).digest(),s,n):M("RSA-SHA256",H.from(a),s,n)}catch{return!1}},Y=(a,e)=>{const s=T(a);if(s===void 0)throw new Error("Failed to seal with ARC: the message has no CRLFCRLF header/body separator, so it is not a complete MIME message.");const t=e.instance??1,n=e.algorithm??"rsa-sha256",l=e.timestamp??Math.floor(Date.now()/1e3),d=new Set(e.headersToSign??X),r=J(D(s.headersPart).filter(c=>d.has(c.name.toLowerCase())&&c.value.trim()!=="")),o=b("sha256").update(K(s.body,"relaxed")).digest("base64"),i=[`i=${String(t)}`,`a=${n}`,"c=relaxed/relaxed",`d=${e.domainName}`,`s=${e.keySelector}`,`t=${String(l)}`,`h=${r.map(c=>c.name.toLowerCase()).join(":")}`,`bh=${o}`,"b="].join("; "),g=`${r.map(c=>y(c.name,c.value,"relaxed")).join(`\r
2
+ `)}\r
3
+ ${m("ARC-Message-Signature",i)}`;return{header:i,signBase:g}},Z=(a,e,s)=>{const t=s.instance??1,n=s.algorithm??"rsa-sha256",l=s.timestamp??Math.floor(Date.now()/1e3),d=s.cv??"none",r=[`i=${String(t)}`,`a=${n}`,`cv=${d}`,`d=${s.domainName}`,`s=${s.keySelector}`,`t=${String(l)}`,"b="].join("; "),o=[m("ARC-Authentication-Results",a),m("ARC-Message-Signature",e),m("ARC-Seal",r)].join(`\r
4
+ `);return{header:r,signBase:o}},ee=async(a,e)=>{let s=a;return s.startsWith("file://")&&(s=await W(s.slice(7),{encoding:"utf8"})),q({key:s,passphrase:e})},re=async(a,e)=>{const s=e.instance??1,t=e.cv??"none";if(s!==1)throw new Error(`signArc only supports an originating sealer (instance 1); received i=${String(s)}`);if(t!=="none")throw new Error(`signArc only supports cv=none for an originating sealer; received cv=${t}`);const n=e.algorithm??"rsa-sha256",l={...e,cv:"none",timestamp:e.timestamp??Math.floor(Date.now()/1e3)},d=await ee(e.privateKey,e.passphrase),r=`i=${String(s)}; ${e.authenticationResults}`,o=Y(a,l),i=`${o.header}${B(o.signBase,d,n)}`,p=Z(r,i,l),g=`${p.header}${B(p.signBase,d,n)}`,c={"ARC-Authentication-Results":r,"ARC-Message-Signature":i,"ARC-Seal":g},h=[`ARC-Seal: ${g}`,`ARC-Message-Signature: ${i}`,`ARC-Authentication-Results: ${r}`].join(`\r
5
+ `);return{headers:c,message:`${h}\r
6
+ ${a}`}},oe=(a,e,s)=>{const t=Object.fromEntries(Object.entries(e).map(([u,v])=>[u.toLowerCase(),v])),n=t["arc-message-signature"],l=t["arc-seal"],d=t["arc-authentication-results"];if(!n||!l||!d)return{components:{ams:!1,bodyHash:!1,seal:!1},reason:"missing-arc-headers",valid:!1};let r;try{r=typeof s.publicKey=="string"?O(s.publicKey):s.publicKey}catch{return{components:{ams:!1,bodyHash:!1,seal:!1},reason:"invalid-public-key",valid:!1}}const o=_(n),i=_(l);if(Q.exec(d)?.[1]!=="1"||o.i!=="1"||i.i!=="1"||i.cv!=="none")return{components:{ams:!1,bodyHash:!1,seal:!1},cv:i.cv,reason:"unsupported-arc-instance",valid:!1};const g=o.a==="ed25519-sha256"?"ed25519-sha256":"rsa-sha256",c=i.a==="ed25519-sha256"?"ed25519-sha256":"rsa-sha256",h=T(a);if(h===void 0)return{components:{ams:!1,bodyHash:!1,seal:!1},reason:"malformed-message",valid:!1};const A=o.bh!==void 0&&o.bh===b("sha256").update(K(h.body,"relaxed")).digest("base64"),L=D(h.headersPart),N=(o.h??"").split(":").map(u=>u.trim().toLowerCase()).filter(Boolean),S=new Map,z=`${N.map(u=>{const v=L.filter(k=>k.name.toLowerCase()===u),w=S.get(u)??0;return S.set(u,w+1),y(u,v[v.length-1-w]?.value??"","relaxed")}).join(`\r
7
+ `)}\r
8
+ ${m("ARC-Message-Signature",j(n))}`,$=x(z,o.b??"",r,g),P=[m("ARC-Authentication-Results",d),m("ARC-Message-Signature",n),m("ARC-Seal",j(l))].join(`\r
9
+ `),R=x(P,i.b??"",r,c),C=$&&R&&A;return{components:{ams:$,bodyHash:A,seal:R},cv:i.cv,reason:C?void 0:"signature-mismatch",valid:C}};export{Y as arcMessageSignatureBase,Z as arcSealBase,re as signArc,oe as verifyArc};
@@ -0,0 +1 @@
1
+ import{createRequire as r}from"node:module";import l from"./EmailError-BIaHK1Uw.js";let c;const p=e=>(c??=r(import.meta.url))(e),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=e=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[n,o]=t.versions.node.split(".").map(Number);if(n>22||n===22&&o>=3||n===20&&o>=16)return t.getBuiltinModule(e)}return p(e)},{Buffer:a}=f("node:buffer"),s=async(e,n)=>{let o;if(e.content)if(typeof e.content=="string")o=e.content;else if(e.content instanceof Promise){const i=await e.content;o=a.from(i).toString("base64")}else o=e.content.toString("base64");else if(e.raw)o=typeof e.raw=="string"?e.raw:e.raw.toString("base64");else throw new l(n,`Attachment ${e.filename} has no content`);return o},y=async(e,n)=>({content:await s(e,n),contentType:e.contentType??"application/octet-stream",disposition:e.contentDisposition??"attachment",filename:e.filename,...e.cid&&{contentId:e.cid}}),_=async(e,n)=>({content:await s(e,n),disposition:e.contentDisposition??"attachment",filename:e.filename,type:e.contentType??"application/octet-stream",...e.cid&&{content_id:e.cid}}),g=async(e,n)=>({Content:await s(e,n),ContentType:e.contentType??"application/octet-stream",Name:e.filename,...e.cid&&{ContentID:e.cid}}),w=async(e,n,o)=>({content:await s(e,n),key:`attachment[${o}]`});export{w as a,g as b,y as c,_ as d,s as p};
@@ -0,0 +1 @@
1
+ import d from"./EmailError-BIaHK1Uw.js";import _ from"./RequiredOptionError-ctDEEB1s.js";import{h as N}from"./headers-to-record-ZOZ7Dubo.js";import{m as k}from"./make-request-Cyz5_yu8.js";import{r as D}from"./retry-aghj7y8m.js";import{s as M,a as j}from"./sanitize-header-CW0f3IT7.js";import{v as C}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as H}from"./defineProvider-C9q-7iwt.js";import{c as P,h as L,P as U}from"./provider-base-BEz00m9R.js";import{a as b,f as y}from"./address-formatter-w36S9ZYj.js";import{c as z}from"./attachment-processor-BJFDS343.js";const n="autosend",G="https://api.autosend.com/v1",x=3e4,B=3,p=50,v=20,T=40*1024*1024,w=20,$=1e3,I=998,F=/^[A-Z0-9-]{1,76}$/i,K="^[A-Za-z0-9-]{1,76}$",X="Either text or html content is required",h=t=>[t].flat(),q=async t=>{const s=await z(t,n);return{content:s.content,contentType:s.contentType,fileName:s.filename}},V=(t,s)=>{const c=h(t.to);if(c.length!==1)return`AutoSend's send endpoint takes exactly one 'to' recipient, but ${String(c.length)} were given — use 'cc'/'bcc', or send one message per recipient`;const o=c.length+(t.cc?h(t.cc).length:0)+(t.bcc?h(t.bcc).length:0);if(o>p)return`AutoSend allows at most ${String(p)} recipients across to/cc/bcc, but ${String(o)} were given`;if(t.attachments&&t.attachments.length>v)return`AutoSend allows at most ${String(v)} attachments, but ${String(t.attachments.length)} were given`;const e=t.attachments?.find(r=>r.cid);if(e)return`AutoSend does not support inline (cid) attachments, but '${e.filename}' sets one — host the image and reference it by URL instead`;if(t.subject.length>I)return`AutoSend allows a subject of at most ${String(I)} characters, but ${String(t.subject.length)} were given`;const a=Object.keys(s);if(a.length>w)return`AutoSend allows at most ${String(w)} custom headers, but ${String(a.length)} were given`;const i=a.find(r=>!F.test(r));if(i!==void 0)return`AutoSend header names must match ${K}, but '${i}' does not`;const l=a.find(r=>s[r].length>$);if(l!==void 0)return`AutoSend allows header values of at most ${String($)} characters, but '${l}' is longer`},J=t=>{if(typeof t!="object"||t===null)return{};const s=t;if(s.success===!0)return{emailId:typeof s.data?.emailId=="string"?s.data.emailId:void 0};const c=[s.message,s.error].find(o=>typeof o=="string");return{reason:typeof c=="string"?c:void 0}},ce=H((t={})=>{if(!t.apiKey)throw new _(n,"apiKey");const s={apiKey:t.apiKey,debug:t.debug??!1,endpoint:t.endpoint??G,logger:t.logger,retries:t.retries??B,timeout:t.timeout??x},c=new U,o=P(n,t.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!0},async initialize(){c.setInitialized()},async isAvailable(){return s.apiKey.length>0},name:n,options:s,async sendEmail(e){try{const a=C(e).filter(u=>!(e.templateId!==void 0&&u===X));if(a.length>0)return{error:new d(n,`Invalid email options: ${a.join(", ")}`),success:!1};const i=e.headers?N(e.headers):{},l=V(e,i);if(l)return{error:new d(n,l),success:!1};const r={from:b(e.from),subject:e.subject,to:b(h(e.to)[0])};if(e.templateId?r.templateId=e.templateId:(e.html&&(r.html=e.html),e.text&&(r.text=e.text)),e.cc&&(r.cc=y(e.cc)),e.bcc&&(r.bcc=y(e.bcc)),e.replyTo&&(r.replyTo=b(e.replyTo)),e.dynamicData&&(r.dynamicData=e.dynamicData),e.unsubscribeGroupId&&(r.unsubscribeGroupId=e.unsubscribeGroupId),e.trackingClick!==void 0&&(r.trackingClick=e.trackingClick),e.trackingOpen!==void 0&&(r.trackingOpen=e.trackingOpen),e.bypassSuppressions!==void 0&&(r.bypassSuppressions=e.bypassSuppressions),Object.keys(i).length>0&&(r.headers=Object.fromEntries(Object.entries(i).map(([u,m])=>[M(u),j(m)]))),e.attachments&&e.attachments.length>0){const u=await Promise.all(e.attachments.map(async A=>q(A))),m=u.reduce((A,R)=>A+R.content.length,0);if(m>T)return{error:new d(n,`AutoSend allows at most ${String(T)} bytes of attachments after Base64 encoding, but this message carries ${String(m)}`),success:!1};r.attachments=u}const g=await D(async()=>k(`${s.endpoint}/mails/send`,{headers:{Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"},method:"POST",timeout:s.timeout},JSON.stringify(r)),s.retries),S=g.data?.body,{emailId:E,reason:f}=J(S);return g.success?f?{error:new d(n,`Failed to send email: ${f}`),success:!1}:E?(o.debug(`Email queued successfully: ${E}`),{data:{messageId:E,provider:n,response:S,sent:!0,timestamp:new Date},success:!0}):{error:new d(n,"AutoSend accepted the message but returned no emailId"),success:!1}:{error:f?new d(n,`Failed to send email: ${f}`):g.error??new d(n,"Failed to send email"),success:!1}}catch(a){return{error:L(n,"send email",a,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{ce as default};
@@ -0,0 +1,32 @@
1
+ import{createRequire as F}from"node:module";import M from"./EmailError-BIaHK1Uw.js";import X from"./RequiredOptionError-ctDEEB1s.js";import{c as J}from"./create-logger-CazqtXcL.js";import p from"../utils/format-email-address.js";import{h as Y}from"./headers-to-record-ZOZ7Dubo.js";import{m as Z}from"./make-request-Cyz5_yu8.js";import{a as _,s as O}from"./sanitize-header-CW0f3IT7.js";import{v as ee}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as re}from"./defineProvider-C9q-7iwt.js";let L;const Q=S=>(L??=F(import.meta.url))(S),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=S=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[a,i]=b.versions.node.split(".").map(Number);if(a>22||a===22&&i>=3||a===20&&i>=16)return b.getBuiltinModule(S)}return Q(S)},{randomUUID:q,createHash:x,createHmac:w}=G("node:crypto"),te=globalThis.Buffer!==void 0,I=()=>{if(!te)throw new Error("Buffer is required for AWS SES provider");return globalThis.Buffer},y="aws-ses",j={apiVersion:"2010-12-01",maxAttempts:3,region:"us-east-1"},he=re((S={})=>{const a={...j,...S},i=J("AWS-SES",S.logger),k=(e,c,r,s,n)=>{const d=Object.keys(r).toSorted().map(u=>{const f=r[u];return f===void 0?"":`${encodeURIComponent(u)}=${encodeURIComponent(f)}`}).filter(Boolean).join("&"),t=`${Object.keys(s).toSorted().map(u=>`${u.toLowerCase()}:${s[u]}`).join(`
2
+ `)}
3
+ `,o=Object.keys(s).toSorted().map(u=>u.toLowerCase()).join(";"),g=x("sha256").update(n).digest("hex");return[e,c,d,t,o,g].join(`
4
+ `)},P=(e,c,r)=>{const s=e.slice(0,8),n=x("sha256").update(r).digest("hex");return["AWS4-HMAC-SHA256",e,`${s}/${c}/ses/aws4_request`,n].join(`
5
+ `)},B=(e,c,r,s)=>{const n=c.slice(0,8),d=w("sha256",`AWS4${e}`).update(n).digest(),t=w("sha256",d).update(r).digest(),o=w("sha256",t).update("ses").digest(),g=w("sha256",o).update("aws4_request").digest();return w("sha256",g).update(s).digest("hex")},W=(e,c,r,s,n)=>{const d=c.slice(0,8),t=Object.keys(s).toSorted().map(o=>o.toLowerCase()).join(";");return[`AWS4-HMAC-SHA256 Credential=${e}/${d}/${r}/ses/aws4_request`,`SignedHeaders=${t}`,`Signature=${n}`].join(", ")},R=async(e,c)=>{if(!a.accessKeyId||!a.secretAccessKey)throw i.debug("Missing required credentials: accessKeyId or secretAccessKey"),new X(y,["accessKeyId","secretAccessKey"]);try{const r=a.region||j.region,s=a.apiVersion||j.apiVersion,n=a.endpoint||`email.${r}.amazonaws.com`,d="/",t="POST";i.debug("Making request to AWS SES:",{action:e,host:n,region:r});const o=new URLSearchParams;o.append("Action",e),o.append("Version",s),Object.entries(c).forEach(([m,l])=>{l!=null&&o.append(m,String(l))});const g=o.toString();i.debug("Request body:",g);const f=new Date().toISOString().replaceAll(/[:-]|\.\d{3}/g,""),h={"Content-Length":I().byteLength(g).toString(),"Content-Type":"application/x-www-form-urlencoded",Host:n,"X-Amz-Date":f};a.sessionToken&&(h["X-Amz-Security-Token"]=a.sessionToken),i.debug("Request headers:",h);const D=k(t,d,{},h,g),z=P(f,r,D),U=B(a.secretAccessKey,f,r,z);h.Authorization=W(a.accessKeyId,f,r,h,U),i.debug("Making HTTPS request to:",`https://${n}${d}`);const N=`https://${n}${d}`,E=await Z(N,{headers:h,method:t},g);if(!E.success)throw E.error??new Error("AWS SES API request failed");const A=E.data?.body;if(!A)throw new Error("No response body from AWS SES");const v=E.data?.statusCode;i.debug("Response status:",v),i.debug("Response data:",A);const T=v;if(T&&T>=200&&T<300){const m={};if(e==="SendRawEmail"){const l=A.match(/<MessageId>(.*?)<\/MessageId>/);if(l){const[,V]=l;m.MessageId=V,i.debug("Extracted MessageId:",m.MessageId)}}else if(e==="GetSendQuota"){const l=A.match(/<Max24HourSend>(.*?)<\/Max24HourSend>/);l?.[1]&&(m.Max24HourSend=Number.parseFloat(l[1]),i.debug("Extracted Max24HourSend:",m.Max24HourSend))}return m}const C=A.match(/<Message>(.*?)<\/Message>/),H=C?C[1]:"Unknown AWS SES error";throw i.debug("AWS SES Error:",H),new Error(`AWS SES API Error: ${H}`)}catch(r){const s=r instanceof Error?r.message:String(r);throw i.debug("makeAwsRequest exception:",s),r instanceof Error?r:new Error(s)}},K=e=>{const c=`----=${q().replaceAll("-","")}`,r=new Date().toUTCString(),s=e.from.email.includes("@")?e.from.email.split("@")[1]:"localhost",n=`<${q().replaceAll("-","")}@${s}>`,d=I();let t="";if(t+=`From: ${p(e.from)}\r
6
+ `,t+=Array.isArray(e.to)?`To: ${e.to.map(o=>p(o)).join(", ")}\r
7
+ `:`To: ${p(e.to)}\r
8
+ `,e.cc&&(t+=Array.isArray(e.cc)?`Cc: ${e.cc.map(o=>p(o)).join(", ")}\r
9
+ `:`Cc: ${p(e.cc)}\r
10
+ `),e.bcc&&(t+=Array.isArray(e.bcc)?`Bcc: ${e.bcc.map(o=>p(o)).join(", ")}\r
11
+ `:`Bcc: ${p(e.bcc)}\r
12
+ `),t+=`Subject: ${_(e.subject)}\r
13
+ `,t+=`Date: ${r}\r
14
+ `,t+=`Message-ID: ${n}\r
15
+ `,t+=`MIME-Version: 1.0\r
16
+ `,e.headers){const o=Y(e.headers);for(const[g,u]of Object.entries(o)){const f=O(g),$=_(u);t+=`${f}: ${$}\r
17
+ `}}return t+=`Content-Type: multipart/alternative; boundary="${c}"\r
18
+ \r
19
+ `,e.text&&(t+=`--${c}\r
20
+ `,t+=`Content-Type: text/plain; charset=UTF-8\r
21
+ `,t+=`Content-Transfer-Encoding: base64\r
22
+ \r
23
+ `,t+=`${d.from(e.text,"utf8").toString("base64")}\r
24
+ \r
25
+ `),e.html&&(t+=`--${c}\r
26
+ `,t+=`Content-Type: text/html; charset=UTF-8\r
27
+ `,t+=`Content-Transfer-Encoding: base64\r
28
+ \r
29
+ `,t+=`${d.from(e.html,"utf8").toString("base64")}\r
30
+ \r
31
+ `),t+=`--${c}--\r
32
+ `,t};return{features:{attachments:!1,batchSending:!1,customHeaders:!0,html:!0,replyTo:!1,scheduling:!1,tagging:!1,templates:!1,tracking:!1},getInstance:()=>{},initialize(){i.debug("Initializing AWS SES provider with options:",{accessKeyId:a.accessKeyId?`***${a.accessKeyId.slice(-4)}`:void 0,endpoint:a.endpoint,region:a.region,secretAccessKey:a.secretAccessKey?"***":void 0})},async isAvailable(){try{return!!(await R("GetSendQuota",{})).Max24HourSend}catch{return!1}},name:y,options:a,async sendEmail(e){const c=r=>{const s=[];return r.attachments&&r.attachments.length>0&&s.push("attachments"),r.priority&&s.push("priority"),r.tags&&r.tags.length>0&&s.push("tags (use messageTags instead)"),r.replyTo&&s.push("replyTo"),s};try{const r=ee(e);if(r.length>0)throw new M(y,`Invalid email options: ${r.join(", ")}`);const s=c(e);if(s.length>0)throw new M(y,`Unsupported fields provided: ${s.join(", ")}. These fields are not supported by AWS SES Raw Email API and would be silently ignored.`);const n={};e.configurationSetName&&(n.ConfigurationSetName=e.configurationSetName),e.sourceArn&&(n.SourceArn=e.sourceArn),e.returnPath&&(n.ReturnPath=e.returnPath),e.returnPathArn&&(n.ReturnPathArn=e.returnPathArn),e.messageTags&&Object.keys(e.messageTags).length>0&&Object.entries(e.messageTags).forEach(([f,$],h)=>{n[`Tags.member.${h+1}.Name`]=f,n[`Tags.member.${h+1}.Value`]=$});const d=K(e),o=I().from(d).toString("base64");n["RawMessage.Data"]=o;const g=await R("SendRawEmail",n),u=g.MessageId;return!u||u.trim()===""?{error:new M(y,"AWS SES API returned a response without a MessageId. The email may not have been sent successfully."),success:!1}:{data:{messageId:u,provider:y,response:g,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:new M(y,`Failed to send email: ${r instanceof Error?r.message:String(r)}`,{cause:r instanceof Error?r:new Error(String(r))}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{he as default};
@@ -0,0 +1 @@
1
+ import{createRequire as A}from"node:module";import u from"./EmailError-BIaHK1Uw.js";import v from"./RequiredOptionError-ctDEEB1s.js";import{g as I}from"./generate-message-id-B2n2yqR6.js";import{h as _}from"./headers-to-record-ZOZ7Dubo.js";import{m as h}from"./make-request-Cyz5_yu8.js";import{r as T}from"./retry-aghj7y8m.js";import{v as P}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";import{c as $,P as B,h as w}from"./provider-base-BEz00m9R.js";import{b as y,c as R}from"./address-formatter-w36S9ZYj.js";let E;const z=s=>(E??=A(import.meta.url))(s),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=s=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[l,r]=m.versions.node.split(".").map(Number);if(l>22||l===22&&r>=3||l===20&&r>=16)return m.getBuiltinModule(s)}return z(s)},{Buffer:p}=k("node:buffer"),o="azure",C=3e4,q=3,Q=j((s={})=>{if(!s.region)throw new v(o,"region");if(!s.connectionString&&!s.accessToken)throw new v(o,"connectionString or accessToken");const l=s.endpoint??`https://${s.region}.communication.azure.com`,r={debug:s.debug??!1,endpoint:l,region:s.region,retries:s.retries??q,timeout:s.timeout??C,...s.connectionString&&{connectionString:s.connectionString},...s.accessToken&&{accessToken:s.accessToken},...s.logger&&{logger:s.logger}},g=new B,a=$(o,s.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!1},async getEmail(e){try{if(!e)return{error:new u(o,"Email ID is required to retrieve email details"),success:!1};await g.ensureInitialized(()=>this.initialize(),o);const i={"Content-Type":"application/json"};if(r.accessToken)i.Authorization=`Bearer ${r.accessToken}`;else if(r.connectionString){const c=r.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);c&&(i.Authorization=`Bearer ${c[2]}`)}a.debug("Retrieving email details",{id:e});const t=await T(async()=>h(`${r.endpoint}/emails/${e}`,{headers:i,method:"GET",timeout:r.timeout}),r.retries);return t.success?(a.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(a.debug("API request failed when retrieving email",t.error),{error:new u(o,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(i){return{error:w(o,"retrieve email",i,a),success:!1}}},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new u(o,"Azure Communication Services API not available or invalid credentials");a.debug("Provider initialized successfully")},o)},async isAvailable(){try{const e={"Content-Type":"application/json"};if(r.accessToken)e.Authorization=`Bearer ${r.accessToken}`;else if(r.connectionString){const c=r.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(c)e.Authorization=`Bearer ${c[2]}`;else return!1}else return!1;a.debug("Checking Azure Communication Services API availability");const i=await h(`${r.endpoint}/emails:send`,{headers:e,method:"POST",timeout:r.timeout},JSON.stringify({}));if(i.success)return!0;const t=i.data?.statusCode;return t===401||t===403?!1:t===400}catch(e){if(a.debug("Error checking availability:",e),e instanceof Error){const i=e.message;if(i.includes("401")||i.includes("403"))return!1}return!1}},name:o,options:r,async sendEmail(e){try{const i=P(e);if(i.length>0)return{error:new u(o,`Invalid email options: ${i.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),o);const t={content:{subject:e.subject},recipients:{to:y(e.to)},senderAddress:e.from.email};if(e.html&&(t.content.html=e.html),e.text&&(t.content.plainText=e.text),e.cc&&(t.recipients.cc=y(e.cc)),e.bcc&&(t.recipients.bcc=y(e.bcc)),e.replyTo&&(t.replyTo=R(e.replyTo).email),e.importance&&(t.importance=e.importance),e.headers){const n=_(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>{let f;if(n.content)if(typeof n.content=="string")f=p.from(n.content,"utf8").toString("base64");else if(n.content&&typeof n.content.then=="function"){const S=await n.content;f=p.from(S).toString("base64")}else f=n.content.toString("base64");else if(n.raw)f=typeof n.raw=="string"?p.from(n.raw,"utf8").toString("base64"):n.raw.toString("base64");else throw new u(o,`Attachment ${n.filename} has no content`);return{contentInBase64:f,contentType:n.contentType??"application/octet-stream",name:n.filename}}))),a.debug("Sending email via Azure Communication Services API",{subject:t.content.subject,to:t.recipients.to});const c={"Content-Type":"application/json"};if(r.accessToken)c.Authorization=`Bearer ${r.accessToken}`;else if(r.connectionString){const n=r.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(n)c.Authorization=`Bearer ${n[2]}`;else return{error:new u(o,"Invalid connection string format"),success:!1}}const d=await T(async()=>h(`${r.endpoint}/emails:send`,{headers:c,method:"POST",timeout:r.timeout},JSON.stringify(t)),r.retries);if(!d.success)return a.debug("API request failed when sending email",d.error),{error:d.error??new u(o,"Failed to send email"),success:!1};const b=d.data?.body?.messageId??I();return a.debug("Email sent successfully",{messageId:b}),{data:{messageId:b,provider:o,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(i){return{error:w(o,"send email",i,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
@@ -0,0 +1 @@
1
+ import c from"./EmailError-BIaHK1Uw.js";import w from"./RequiredOptionError-ctDEEB1s.js";import{g as A}from"./generate-message-id-B2n2yqR6.js";import{h as I}from"./headers-to-record-ZOZ7Dubo.js";import{m as y}from"./make-request-Cyz5_yu8.js";import{r as g}from"./retry-aghj7y8m.js";import{v as E}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{c as C,P as R,h as b}from"./provider-base-BEz00m9R.js";import{f,a as m}from"./address-formatter-w36S9ZYj.js";import{p as S}from"./attachment-processor-BJFDS343.js";const t="brevo",k="https://api.brevo.com/v3",j=3e4,z=3,M=P((d={})=>{if(!d.apiKey)throw new w(t,"apiKey");const v=d.endpoint??k,s={apiKey:d.apiKey,debug:d.debug??!1,endpoint:v,hardValidation:d.hardValidation??!1,retries:d.retries??z,timeout:d.timeout??j,...d.logger&&{logger:d.logger}},l=new R,o=C(t,d.logger);return{endpoint:s.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(t,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),t);const r={"api-key":s.apiKey,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const i=await g(async()=>y(`${s.endpoint}/smtp/emails/${e}`,{headers:r,method:"GET",timeout:s.timeout}),s.retries);return i.success?(o.debug("Email details retrieved successfully"),{data:i.data?.body,success:!0}):(o.debug("API request failed when retrieving email",i.error),{error:new c(t,`Failed to retrieve email: ${i.error instanceof Error?i.error.message:"Unknown error"}`,{cause:i.error}),success:!1})}catch(r){return{error:b(t,"retrieve email",r,o),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(t,"Brevo API not available or invalid API key");o.debug("Provider initialized successfully")},t)},async isAvailable(){try{const e={"api-key":s.apiKey,"Content-Type":"application/json"};o.debug("Checking Brevo API availability");const r=await y(`${s.endpoint}/account`,{headers:e,method:"GET",timeout:s.timeout});return o.debug("Brevo API availability check response:",{error:r.error instanceof Error?r.error.message:void 0,statusCode:r.data?.statusCode,success:r.success}),!!(r.success&&r.data&&typeof r.data=="object"&&"statusCode"in r.data&&typeof r.data.statusCode=="number"&&r.data.statusCode>=200&&r.data.statusCode<300)}catch(e){return o.debug("Error checking availability:",e),!1}},name:t,options:s,async sendEmail(e){try{let r;Array.isArray(e.replyTo)?r=e.replyTo.length>0?e.replyTo[0]:void 0:r=e.replyTo;const i={...e,replyTo:r},h=E(i);if(h.length>0)return{error:new c(t,`Invalid email options: ${h.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),t);const a={sender:m(e.from),subject:e.subject,to:f(e.to)};if(e.html&&(a.htmlContent=e.html),e.text&&(a.textContent=e.text),e.cc&&(a.cc=f(e.cc)),e.bcc&&(a.bcc=f(e.bcc)),e.replyTo)if(Array.isArray(e.replyTo)){if(s.hardValidation)return{error:new c(t,"Only one replyTo address is allowed"),success:!1};if(e.replyTo.length===0)return{error:new c(t,"replyTo array cannot be empty"),success:!1};const n=e.replyTo[0];if(!n)return{error:new c(t,"replyTo array cannot be empty"),success:!1};a.replyTo=m(n)}else a.replyTo=m(e.replyTo);if(e.templateId&&(a.templateId=e.templateId,e.templateParams&&(a.params=e.templateParams)),e.tags&&e.tags.length>0&&(a.tags=e.tags),e.scheduledAt){const n=typeof e.scheduledAt=="number"?new Date(e.scheduledAt*1e3).toISOString():e.scheduledAt;a.scheduledAt=n}if(e.batchId&&(a.batchId=e.batchId),e.headers){const n=I(e.headers);a.headers=n}e.attachments&&e.attachments.length>0&&(a.attachment=await Promise.all(e.attachments.map(async n=>({content:await S(n,t),name:n.filename,...n.contentType&&{type:n.contentType}})))),o.debug("Sending email via Brevo API",{subject:a.subject,to:a.to});const T={"api-key":s.apiKey,"Content-Type":"application/json"},u=await g(async()=>y(`${s.endpoint}/smtp/email`,{headers:T,method:"POST",timeout:s.timeout},JSON.stringify(a)),s.retries);if(!u.success)return o.debug("API request failed when sending email",u.error),{error:u.error??new c(t,"Failed to send email"),success:!1};const p=u.data?.body?.messageId??A();return o.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:t,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:b(t,"send email",r,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{M as default};
@@ -0,0 +1,3 @@
1
+ import M from"./EmailError-BIaHK1Uw.js";import m from"../utils/format-email-address.js";import{g as y}from"./generate-boundary-BCSUEi6x.js";import{h as v}from"./headers-to-record-ZOZ7Dubo.js";import{e as z}from"./quoted-printable-BgiHOYdV.js";import{s as T,a as u}from"./sanitize-header-CW0f3IT7.js";const g=globalThis.Buffer!==void 0,b=e=>{if(typeof e=="string"){if(g)return Buffer.from(e,"utf8").toString("base64");const s=new TextEncoder().encode(e);let r="";const n=8192;for(let o=0;o<s.length;o+=n){const c=s.subarray(o,Math.min(o+n,s.length));r+=String.fromCharCode(...c)}return btoa(r)}if(g&&e instanceof Buffer)return e.toString("base64");const i=e instanceof Uint8Array?e:new Uint8Array(e);if(g)return Buffer.from(i).toString("base64");let l="";const a=8192;for(let t=0;t<i.length;t+=a){const s=i.subarray(t,Math.min(t+a,i.length));l+=String.fromCharCode(...s)}return btoa(l)},I=globalThis.Buffer!==void 0,N=/[^\u0000-\u007F]/,j=e=>!N.test(e),k=e=>{if(j(e))return e;const i=45,l=new TextDecoder,a=I?Buffer.from(e,"utf8"):new TextEncoder().encode(e),t=[];let s=0;for(;s<a.length;){let r=Math.min(s+i,a.length);if(r<a.length)for(;r>s&&(a[r]&192)===128;)r-=1;const n=a.subarray(s,r),o=l.decode(n);t.push(`=?UTF-8?B?${b(o)}?=`),s=r}return t.join(" ")},$=e=>Array.isArray(e)?e.map(i=>m(i)).join(", "):m(e),B=/[^ -~\r\n\t]/,E=e=>k(u(e)),R=globalThis.Buffer!==void 0,C=e=>e.replaceAll(/.{1,76}/g,`$&\r
2
+ `).trimEnd(),_=/\r\n|\r|\n/,w=e=>e.split(_),U=async(e,i={})=>{const{includeBcc:l=!1}=i,a=y(),t=[`From: ${m(e.from)}`,`To: ${$(e.to)}`];if(e.cc&&t.push(`Cc: ${$(e.cc)}`),l&&e.bcc&&t.push(`Bcc: ${$(e.bcc)}`),e.replyTo&&t.push(`Reply-To: ${m(e.replyTo)}`),t.push(`Subject: ${E(e.subject)}`,"MIME-Version: 1.0"),e.headers){const r=v(e.headers);Object.entries(r).forEach(([n,o])=>{const c=T(n),p=u(o);t.push(`${c}: ${p}`)})}t.push(`Content-Type: multipart/mixed; boundary="${a}"`,"");const s=(r,n)=>{const o=B.test(n)?z(n):n,c=B.test(n)?"quoted-printable":"7bit";return[`Content-Type: ${r}; charset=UTF-8`,`Content-Transfer-Encoding: ${c}`,"",...w(o),""]};if(e.text&&e.html){const r=y();t.push(`--${a}`,`Content-Type: multipart/alternative; boundary="${r}"`,"",`--${r}`,...s("text/plain",e.text),`--${r}`,...s("text/html",e.html),`--${r}--`,"")}else e.text?t.push(`--${a}`,...s("text/plain",e.text)):e.html&&t.push(`--${a}`,...s("text/html",e.html));if(e.attachments&&e.attachments.length>0){const r=await Promise.all(e.attachments.map(async n=>{let o;if(n.raw!==void 0)o=n.raw;else{if(n.content===void 0)throw new M("attachment",`Attachment '${n.filename}' must have content, raw, or be resolved from path/href before building MIME message`);o=n.content instanceof Promise?await n.content:n.content}return{...n,resolvedContent:o}}));for(const n of r){t.push(`--${a}`);const o=u(n.contentType??"application/octet-stream"),c=E(n.filename);t.push(`Content-Type: ${o}; name="${c}"`);const p=u(n.contentDisposition??"attachment");t.push(`Content-Disposition: ${p}; filename="${c}"`),n.cid&&t.push(`Content-ID: <${u(n.cid)}>`),n.headers&&Object.entries(n.headers).forEach(([h,x])=>{const A=T(h),S=u(x);t.push(`${A}: ${S}`)});const d=u(n.encoding??"base64");t.push(`Content-Transfer-Encoding: ${d}`,"");const f=n.resolvedContent;if(d==="base64")t.push(C(b(f)));else if(d==="7bit"||d==="8bit"){let h;typeof f=="string"?h=f:R&&f instanceof Buffer?h=f.toString("utf8"):h=new TextDecoder().decode(f),t.push(...w(h))}else t.push(C(b(f)));t.push("")}}return t.push(`--${a}--`),t.join(`\r
3
+ `)};export{U as b};
@@ -0,0 +1 @@
1
+ const u=i=>{const{mailto:s,mailtoSubject:r="unsubscribe",oneClick:o=!1,url:t}=i;if(!t&&!s)throw new TypeError("buildListUnsubscribe requires at least one of `url` or `mailto`");const e=[];t&&e.push(`<${t}>`),s&&(s.startsWith("mailto:")?e.push(`<${s}>`):e.push(`<mailto:${s}?subject=${encodeURIComponent(r)}>`));const n={"List-Unsubscribe":e.join(", ")};if(o){if(!t?.startsWith("https:"))throw new TypeError("One-click unsubscribe (RFC 8058) requires an https `url`");n["List-Unsubscribe-Post"]="List-Unsubscribe=One-Click"}return n},c=i=>{const s=i.match(/<[^<>]+>/g);return s?s.map(r=>r.slice(1,-1).trim()):[]};export{u as buildListUnsubscribe,c as parseListUnsubscribe};
@@ -0,0 +1,6 @@
1
+ const c=new Set(["enforce","none","testing"]),d=o=>{const t=[];let s,e,i;for(const m of o.replaceAll(`\r
2
+ `,`
3
+ `).split(`
4
+ `)){const a=m.indexOf(":");if(a===-1)continue;const r=m.slice(0,a).trim().toLowerCase(),n=m.slice(a+1).trim();if(r==="version")s=n;else if(r==="mode"&&(n==="enforce"||n==="testing"||n==="none"))e=n;else if(r==="max_age"){const l=Number.parseInt(n,10);i=Number.isNaN(l)?void 0:l}else r==="mx"&&n.length>0&&t.push(n)}return{maxAge:i,mode:e,mx:t,valid:s==="STSv1"&&e!==void 0&&i!==void 0,version:s}},g=o=>{if(!c.has(o.mode))throw new TypeError('buildMtaStsPolicy: `mode` must be one of "enforce", "testing", or "none"');if(!Number.isInteger(o.maxAge)||o.maxAge<0)throw new TypeError("buildMtaStsPolicy: `maxAge` must be a non-negative integer");const t=o.mx.map(e=>e.trim());if(t.length===0||t.some(e=>e.length===0))throw new TypeError("buildMtaStsPolicy: `mx` must contain at least one non-empty host");return`${["version: STSv1",`mode: ${o.mode}`,...t.map(e=>`mx: ${e}`),`max_age: ${String(o.maxAge)}`].join(`\r
5
+ `)}\r
6
+ `};export{g as buildMtaStsPolicy,d as parseMtaStsPolicy};
@@ -0,0 +1,11 @@
1
+ const l=/[ \t]+/g,c=t=>{let n=0,e=t.length;for(;n<e&&(t[n]===" "||t[n]===" ");)n+=1;for(;e>n&&(t[e-1]===" "||t[e-1]===" ");)e-=1;return t.slice(n,e)},a=t=>{const n=t.indexOf(`\r
2
+ \r
3
+ `);if(n!==-1)return{body:t.slice(n+4),headersPart:t.slice(0,n)}},p=t=>{const n=[];for(const e of t.split(`\r
4
+ `)){const s=n.at(-1);if(s!==void 0&&(e.startsWith(" ")||e.startsWith(" "))){s.raw+=`\r
5
+ ${e}`,s.value+=`\r
6
+ ${e}`;continue}const r=e.indexOf(":");r!==-1&&n.push({name:e.slice(0,r),raw:e,value:e.slice(r+1)})}return n},d=(t,n)=>{const e=t.split(`\r
7
+ `);if(n==="relaxed")for(const[r,i]of e.entries()){const o=i.replaceAll(l," ");e[r]=o.endsWith(" ")?o.slice(0,-1):o}let s=e.length;for(;s>0&&e[s-1]==="";)s-=1;return s===0?n==="simple"?`\r
8
+ `:"":`${e.slice(0,s).join(`\r
9
+ `)}\r
10
+ `},f=(t,n,e)=>{if(e==="simple")return`${t}:${n}`;const s=n.replaceAll(`\r
11
+ `,"").replaceAll(l," ");return`${c(t.toLowerCase())}:${c(s)}`},h=t=>{const n=new Map;for(const s of t){const r=s.name.toLowerCase();n.set(r,[...n.get(r)??[],s])}const e=new Map;return t.map(s=>{const r=s.name.toLowerCase(),i=n.get(r),o=e.get(r)??0;return e.set(r,o+1),i[i.length-1-o]})};export{f as a,d as c,h as o,p,a as s};
@@ -0,0 +1 @@
1
+ import w from"./EmailError-BIaHK1Uw.js";const C=(u={})=>{const{failureThreshold:c=5,now:s=Date.now,onStateChange:p,resetTimeout:d=3e4}=u;let e="closed",n=0,l=0,t=!1;const i=r=>{e!==r&&(e=r,p?.(r))},a=()=>({error:new w("middleware","Circuit breaker is open",{code:"CIRCUIT_OPEN"}),success:!1});return async(r,h)=>{if(e==="open"&&s()-l>=d&&(i("half-open"),t=!1),e==="open")return a();let f=!1;if(e==="half-open"){if(t)return a();t=!0,f=!0}let o;try{o=await h(r)}finally{f&&(t=!1)}return o.success?(n=0,i("closed"),o):(n+=1,(e==="half-open"||n>=c)&&(l=s(),i("open")),o)}};export{C as circuitBreakerMiddleware};
@@ -0,0 +1 @@
1
+ import{createTransportDkimSigner as l}from"./DkimSigner-CCxFKitN.js";import o from"./EmailError-BIaHK1Uw.js";import m from"./RequiredOptionError-ctDEEB1s.js";import{b as u}from"./build-mime-message-BCFKPqaW.js";import{g as f}from"./generate-message-id-B2n2yqR6.js";import{h as g}from"./headers-to-record-ZOZ7Dubo.js";import{v as p}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as h}from"./defineProvider-C9q-7iwt.js";import{c as v,h as w}from"./provider-base-BEz00m9R.js";const r="cloudflare-email",R=h((s={})=>{if(typeof s.send!="function")throw new m(r,"send");const d=v(r,s.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){await Promise.resolve()},async isAvailable(){return typeof s.send=="function"},name:r,async sendEmail(e){try{const a=p(e);if(a.length>0)return{error:new o(r,`Invalid email options: ${a.join(", ")}`),success:!1};const i=Array.isArray(e.to)?e.to:[e.to];if(i.length!==1||e.cc!==void 0||e.bcc!==void 0)return{error:new o(r,"Cloudflare Email supports exactly one `to` recipient and does not support cc/bcc"),success:!1};const[n]=i;if(!n)return{error:new o(r,"A single `to` recipient is required"),success:!1};const c=f();let t=await u({...e,headers:{...e.headers?g(e.headers):{},"Message-ID":c}});return s.dkim&&e.useDkim!==!1&&(t=await l(s.dkim).signMimeMessage(t)),await s.send(e.from.email,n.email,t),{data:{messageId:c,provider:r,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:w(r,"send email",a,d),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{R as default};
@@ -0,0 +1 @@
1
+ const d=(o,t)=>{let e=t;for(const r of o.toReversed()){const n=e;e=c=>r(c,n)}return e};export{d as composeMiddleware};