@visulima/email 2.1.9 → 3.0.1
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.
- package/CHANGELOG.md +14 -0
- package/dist/crypto/index.d.ts +50 -47
- package/dist/crypto/index.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/middleware/index.d.ts +19 -6
- package/dist/middleware/index.js +1 -1
- package/dist/packem_chunks/index.js +27 -0
- package/dist/packem_shared/DkimSigner-CCxFKitN.js +4 -0
- package/dist/packem_shared/{DraftMailMessage-Tj3sH8nn.js → DraftMailMessage-B0gwf8n_.js} +1 -1
- package/dist/packem_shared/{Mail-Cm24B3w0.js → Mail-DmYNQ0KK.js} +1 -1
- package/dist/packem_shared/{MailMessage-BtI4qMU1.js → MailMessage-DmmaNHHc.js} +1 -1
- package/dist/packem_shared/{SmimeEncrypter-BjBwjaTg.js → SmimeEncrypter-DnlfpjUX.js} +3 -3
- package/dist/packem_shared/{SmimeSigner-CK5TITxI.js → SmimeSigner-DTvclzLq.js} +2 -2
- package/dist/packem_shared/{address-formatter-CXZ1aWBX.js → address-formatter-w36S9ZYj.js} +1 -1
- package/dist/packem_shared/{ahaSendProvider-DY559XjD.js → ahaSendProvider-C1qvG8Cj.js} +1 -1
- package/dist/packem_shared/arcMessageSignatureBase-su9VTRB7.js +9 -0
- package/dist/packem_shared/{autoSendProvider-BgdWf422.js → autoSendProvider-yxUx3sEj.js} +1 -1
- package/dist/packem_shared/{azureProvider-Bs4BGYR1.js → azureProvider-CLLRKtOf.js} +1 -1
- package/dist/packem_shared/{brevoProvider-xoRTeFIx.js → brevoProvider-CHlodyzV.js} +1 -1
- package/dist/packem_shared/build-mime-message-BCFKPqaW.js +3 -0
- package/dist/packem_shared/canonicalize-BEjQUnUe.js +11 -0
- package/dist/packem_shared/cloudflareEmailProvider-Ckh_u-0D.js +1 -0
- package/dist/packem_shared/{createTestEmail-CPnHNKBT.js → createTestEmail-sB6z8m6Z.js} +1 -1
- package/dist/packem_shared/detectMimeType-BRz3Qjyz.js +1 -0
- package/dist/packem_shared/format-address-Bb7xk8G_.js +1 -0
- package/dist/packem_shared/{infobipProvider-mEYgfWJ7.js → infobipProvider-BEu1ycxS.js} +1 -1
- package/dist/packem_shared/{mail.d-8M9NjOr0.d.ts → mail.d-BdyyyQO5.d.ts} +10 -7
- package/dist/packem_shared/{mailCrabProvider-Cx9rnuyE.js → mailCrabProvider-BQ5ELwPU.js} +1 -1
- package/dist/packem_shared/{mailPaceProvider-DvSlan-v.js → mailPaceProvider-Ca3cz8JU.js} +1 -1
- package/dist/packem_shared/{mailchannelsProvider-Cgb8el7C.js → mailchannelsProvider-BZeuZk3d.js} +1 -1
- package/dist/packem_shared/{mailerSendProvider-BvRIjuVE.js → mailerSendProvider-C_Db652T.js} +1 -1
- package/dist/packem_shared/{mailgunProvider-kNcvF_z6.js → mailgunProvider-CU2b8ie8.js} +1 -1
- package/dist/packem_shared/{mailjetProvider-DqJUhLuH.js → mailjetProvider-VqvqCS7I.js} +1 -1
- package/dist/packem_shared/{mailomatProvider-BBOqRhV_.js → mailomatProvider-FMk4FZZz.js} +1 -1
- package/dist/packem_shared/{mailtrapProvider-CeBW2Gzg.js → mailtrapProvider-Qs0exKiJ.js} +1 -1
- package/dist/packem_shared/{mandrillProvider-Dab8i0gF.js → mandrillProvider-Co_EfMxl.js} +1 -1
- package/dist/packem_shared/{netcoreProvider-DMJsQ8IM.js → netcoreProvider-_kXjZ0bE.js} +1 -1
- package/dist/packem_shared/oauth2Middleware-C0M1w3_2.js +1 -0
- package/dist/packem_shared/{postalProvider-COVY4T94.js → postalProvider-tEBNXL3h.js} +1 -1
- package/dist/packem_shared/{postmarkProvider-Cj64C4dc.js → postmarkProvider-DdavP5x5.js} +1 -1
- package/dist/packem_shared/{resendProvider-Da5r7dMe.js → resendProvider-CMtlyIye.js} +1 -1
- package/dist/packem_shared/{scalewayProvider-CDjpYmJc.js → scalewayProvider-BFA1PQ73.js} +1 -1
- package/dist/packem_shared/{sendGridProvider-C1rp9hpg.js → sendGridProvider-DV80Lg7a.js} +1 -1
- package/dist/packem_shared/smtpProvider-BCEzJmay.js +14 -0
- package/dist/packem_shared/{sparkpostProvider-DKon_hyx.js → sparkpostProvider-C3pATjJX.js} +1 -1
- package/dist/packem_shared/{sweegoProvider-BclZuNBf.js → sweegoProvider-CkFtUAzq.js} +1 -1
- package/dist/packem_shared/{types.d-B0t3PQ3t.d.ts → types.d-Cb5fls_X.d.ts} +1 -1
- package/dist/packem_shared/{zeptomailProvider-D5B3kqFm.js → zeptomailProvider-tqRYpQlv.js} +1 -1
- package/dist/providers/ahasend/index.js +1 -1
- package/dist/providers/autosend/index.js +1 -1
- package/dist/providers/azure/index.js +1 -1
- package/dist/providers/brevo/index.js +1 -1
- package/dist/providers/cloudflare-email/index.d.ts +17 -1
- package/dist/providers/cloudflare-email/index.js +1 -1
- package/dist/providers/infobip/index.js +1 -1
- package/dist/providers/mailchannels/index.js +1 -1
- package/dist/providers/mailcrab/index.js +1 -1
- package/dist/providers/mailersend/index.js +1 -1
- package/dist/providers/mailgun/index.js +1 -1
- package/dist/providers/mailjet/index.js +1 -1
- package/dist/providers/mailomat/index.js +1 -1
- package/dist/providers/mailpace/index.js +1 -1
- package/dist/providers/mailtrap/index.js +1 -1
- package/dist/providers/mandrill/index.js +1 -1
- package/dist/providers/netcore/index.js +1 -1
- package/dist/providers/postal/index.js +1 -1
- package/dist/providers/postmark/index.js +1 -1
- package/dist/providers/resend/index.js +1 -1
- package/dist/providers/scaleway/index.js +1 -1
- package/dist/providers/sendgrid/index.js +1 -1
- package/dist/providers/smtp/index.d.ts +9 -5
- package/dist/providers/smtp/index.js +1 -1
- package/dist/providers/sparkpost/index.js +1 -1
- package/dist/providers/sweego/index.js +1 -1
- package/dist/providers/zeptomail/index.js +1 -1
- package/dist/test/index.d.ts +2 -2
- package/dist/test/index.js +1 -1
- package/dist/utils/format-email-address.js +1 -1
- package/package.json +1 -1
- package/dist/packem_shared/DkimSigner-B_pEwGCS.js +0 -18
- package/dist/packem_shared/arcMessageSignatureBase-B0Qi-724.js +0 -17
- package/dist/packem_shared/build-mime-message-QNCMA6oQ.js +0 -3
- package/dist/packem_shared/cloudflareEmailProvider-BkR-P0YD.js +0 -1
- package/dist/packem_shared/detectMimeType-DVC9Uvy9.js +0 -1
- package/dist/packem_shared/format-address-BDKhXcXV.js +0 -1
- package/dist/packem_shared/index-B8wiKJdh.js +0 -1
- package/dist/packem_shared/oauth2Middleware-DbKGd7Z9.js +0 -1
- package/dist/packem_shared/smtpProvider-Dr2XAFQu.js +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## @visulima/email [3.0.1](https://github.com/visulima/visulima/compare/%40visulima%2Femail%403.0.0...%40visulima%2Femail%403.0.1) (2026-08-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Dependencies
|
|
5
|
+
|
|
6
|
+
* **@visulima/fs:** upgraded to 6.0.3
|
|
7
|
+
|
|
8
|
+
## @visulima/email [3.0.0](https://github.com/visulima/visulima/compare/%40visulima%2Femail%402.1.9...%40visulima%2Femail%403.0.0) (2026-08-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* **@visulima/fs:** upgraded to 6.0.2
|
|
14
|
+
|
|
1
15
|
## @visulima/email [2.1.9](https://github.com/visulima/visulima/compare/%40visulima%2Femail%402.1.8...%40visulima%2Femail%402.1.9) (2026-08-17)
|
|
2
16
|
|
|
3
17
|
|
package/dist/crypto/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KeyObject } from 'node:crypto';
|
|
2
|
+
import { D as DkimOptions, S as SmimeEncryptOptions, E as EmailEncrypter, a as SmimeSignOptions, b as EmailSigner } from "../packem_shared/types.d-Cb5fls_X.js";
|
|
2
3
|
import { E as EmailOptions } from "../packem_shared/types.d-B9295M4_.js";
|
|
3
|
-
import { D as DkimOptions, E as EmailSigner, S as SmimeEncryptOptions, a as EmailEncrypter, b as SmimeSignOptions } from "../packem_shared/types.d-B0t3PQ3t.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* The signature algorithm for the ARC headers. RSA per RFC 8617, Ed25519 per RFC 8463.
|
|
@@ -104,11 +104,12 @@ interface ArcVerifyResult {
|
|
|
104
104
|
* Computes the exact byte string that the ARC-Message-Signature `b=` value signs.
|
|
105
105
|
*
|
|
106
106
|
* Exposed so ARC verifiers (and tests) can re-derive the signing input.
|
|
107
|
-
* @param
|
|
107
|
+
* @param message The serialized MIME message being sealed.
|
|
108
108
|
* @param options The seal options.
|
|
109
109
|
* @returns The AMS header (without the `b=` value) and the data signed.
|
|
110
|
+
* @throws {Error} When `message` has no header/body separator.
|
|
110
111
|
*/
|
|
111
|
-
declare const arcMessageSignatureBase: (
|
|
112
|
+
declare const arcMessageSignatureBase: (message: string, options: ArcSealOptions) => {
|
|
112
113
|
header: string;
|
|
113
114
|
signBase: string;
|
|
114
115
|
};
|
|
@@ -133,57 +134,43 @@ declare const arcSealBase: (aarValue: string, amsValue: string, options: ArcSeal
|
|
|
133
134
|
* your service forwards mail and wants downstream receivers to trust the authentication results you
|
|
134
135
|
* observed. Supports RSA (default) and Ed25519 (`algorithm: "ed25519-sha256"`, RFC 8463) keys.
|
|
135
136
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* @param
|
|
137
|
+
* Takes the serialized message rather than `EmailOptions`, because an ARC seal — like a DKIM
|
|
138
|
+
* signature — commits to the bytes on the wire: `bh=` hashes the transmitted body and `h=` covers
|
|
139
|
+
* the headers a downstream verifier will actually read. Forwarding is where ARC belongs, and there
|
|
140
|
+
* the raw message is what you already have.
|
|
141
|
+
* @param message The serialized MIME message to seal.
|
|
141
142
|
* @param options The seal options. See {@link ArcSealOptions}.
|
|
142
|
-
* @returns The
|
|
143
|
-
* @throws {Error} When the private key cannot be
|
|
143
|
+
* @returns The message with the ARC header set prepended, and the raw {@link ArcHeaderSet}.
|
|
144
|
+
* @throws {Error} When the message is not a complete MIME message, the private key cannot be
|
|
145
|
+
* loaded, or signing fails.
|
|
144
146
|
*/
|
|
145
|
-
declare const signArc: (
|
|
146
|
-
email: EmailOptions;
|
|
147
|
+
declare const signArc: (message: string, options: ArcSealOptions) => Promise<{
|
|
147
148
|
headers: ArcHeaderSet;
|
|
149
|
+
message: string;
|
|
148
150
|
}>;
|
|
149
151
|
/**
|
|
150
152
|
* Verifies an originating (i=1) ARC header set against the signing domain's public key.
|
|
151
153
|
*
|
|
152
|
-
* Re-derives the AMS and ARC-Seal signing inputs from
|
|
153
|
-
* the body hash, and checks all three. The public key must be the one published for the
|
|
154
|
-
* `s=`/`d=` (the DKIM-style `<selector>._domainkey.<domain>` TXT `p=` value).
|
|
155
|
-
* @param
|
|
154
|
+
* Re-derives the AMS and ARC-Seal signing inputs from the message + the supplied ARC headers,
|
|
155
|
+
* recomputes the body hash, and checks all three. The public key must be the one published for the
|
|
156
|
+
* seal's `s=`/`d=` (the DKIM-style `<selector>._domainkey.<domain>` TXT `p=` value).
|
|
157
|
+
* @param message The serialized MIME message that was sealed, without the ARC header set.
|
|
156
158
|
* @param headers The ARC header set (or any record containing the three `ARC-*` headers).
|
|
157
159
|
* @param options Verification options. See {@link ArcVerifyOptions}.
|
|
158
160
|
* @returns The verification result. See {@link ArcVerifyResult}.
|
|
159
161
|
*/
|
|
160
|
-
declare const verifyArc: (
|
|
162
|
+
declare const verifyArc: (message: string, headers: ArcHeaderSet | Record<string, string>, options: ArcVerifyOptions) => ArcVerifyResult;
|
|
161
163
|
/**
|
|
162
|
-
* DKIM signer
|
|
164
|
+
* DKIM signer.
|
|
165
|
+
*
|
|
166
|
+
* DKIM signs the message **as transmitted**: the `bh=` tag is a hash of the canonicalized MIME
|
|
167
|
+
* body, and `h=` covers the headers the recipient's MTA will see. That means signing can only
|
|
168
|
+
* happen after the message has been serialized, so this deliberately does **not** implement
|
|
169
|
+
* `EmailSigner` — `MailMessage.sign()` runs at the `EmailOptions` layer, where the body does not
|
|
170
|
+
* exist yet, and passing a DKIM signer there is a compile error rather than a runtime surprise.
|
|
171
|
+
* Configure DKIM on a transport that emits raw MIME instead.
|
|
163
172
|
*/
|
|
164
|
-
declare class DkimSigner
|
|
165
|
-
/**
|
|
166
|
-
* Sanitizes a display name for use in quoted email headers per RFC 5322.
|
|
167
|
-
* Removes/replaces CR, LF, tabs with space, escapes backslashes and quotes,
|
|
168
|
-
* and strips non-printable control characters.
|
|
169
|
-
* @param name The display name to sanitize.
|
|
170
|
-
* @returns The sanitized display name, or empty string if nothing remains.
|
|
171
|
-
*/
|
|
172
|
-
private static sanitizeDisplayName;
|
|
173
|
-
/**
|
|
174
|
-
* Formats an email address for use in email headers.
|
|
175
|
-
* @param address The email address object to format.
|
|
176
|
-
* @param address.email The email address string.
|
|
177
|
-
* @param address.name Optional display name for the email address.
|
|
178
|
-
* @returns The formatted email address string in RFC 5322 format.
|
|
179
|
-
*/
|
|
180
|
-
private static formatAddress;
|
|
181
|
-
/**
|
|
182
|
-
* Formats email addresses for headers.
|
|
183
|
-
* @param addresses The email address(es) to format (single or array).
|
|
184
|
-
* @returns The formatted email addresses string (comma-separated if multiple).
|
|
185
|
-
*/
|
|
186
|
-
private static formatAddresses;
|
|
173
|
+
declare class DkimSigner {
|
|
187
174
|
private readonly options;
|
|
188
175
|
/**
|
|
189
176
|
* Creates a new DKIM signer.
|
|
@@ -191,12 +178,18 @@ declare class DkimSigner implements EmailSigner {
|
|
|
191
178
|
*/
|
|
192
179
|
constructor(options: DkimOptions);
|
|
193
180
|
/**
|
|
194
|
-
* Signs
|
|
195
|
-
* @param
|
|
196
|
-
* @returns The
|
|
197
|
-
* @throws {Error} When
|
|
181
|
+
* Signs a fully-built MIME message and returns it with a `DKIM-Signature` header prepended.
|
|
182
|
+
* @param message The complete MIME message: headers, a blank line, then the body, CRLF-delimited.
|
|
183
|
+
* @returns The message with the signature prepended.
|
|
184
|
+
* @throws {Error} When the message has no header/body separator, has no signable `From` header,
|
|
185
|
+
* or signing fails (e.g. an unreadable or malformed private key).
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const raw = await buildMimeMessage(emailOptions);
|
|
189
|
+
* const signed = await createDkimSigner({ domainName: "example.com", keySelector: "s1", privateKey }).signMimeMessage(raw);
|
|
190
|
+
* ```
|
|
198
191
|
*/
|
|
199
|
-
|
|
192
|
+
signMimeMessage(message: string): Promise<string>;
|
|
200
193
|
}
|
|
201
194
|
/**
|
|
202
195
|
* Creates a DKIM signer instance.
|
|
@@ -204,6 +197,16 @@ declare class DkimSigner implements EmailSigner {
|
|
|
204
197
|
* @returns A new DkimSigner instance.
|
|
205
198
|
*/
|
|
206
199
|
declare const createDkimSigner: (options: DkimOptions) => DkimSigner;
|
|
200
|
+
/**
|
|
201
|
+
* Builds a signer for a transport that writes the MIME message itself.
|
|
202
|
+
*
|
|
203
|
+
* Canonicalization defaults to relaxed/relaxed rather than the `simple/simple` of
|
|
204
|
+
* {@link DkimOptions}: SMTP hops routinely re-wrap whitespace, which `simple` does not survive.
|
|
205
|
+
* Callers can still override either field.
|
|
206
|
+
* @param options DKIM signing options from the transport config.
|
|
207
|
+
* @returns A signer configured for on-the-wire use.
|
|
208
|
+
*/
|
|
209
|
+
declare const createTransportDkimSigner: (options: DkimOptions) => DkimSigner;
|
|
207
210
|
/**
|
|
208
211
|
* S/MIME encrypter implementation using PKIjs
|
|
209
212
|
* Note: Requires pkijs and asn1js for S/MIME operations
|
|
@@ -301,4 +304,4 @@ declare class SmimeSigner implements EmailSigner {
|
|
|
301
304
|
* @returns A new SmimeSigner instance ready to sign emails.
|
|
302
305
|
*/
|
|
303
306
|
declare const createSmimeSigner: (options: SmimeSignOptions) => SmimeSigner;
|
|
304
|
-
export { type ArcAlgorithm, type ArcHeaderSet, type ArcSealOptions, type ArcVerifyOptions, type ArcVerifyResult, type DkimOptions, DkimSigner, type EmailEncrypter, type EmailSigner, type SmimeEncryptOptions, SmimeEncrypter, type SmimeSignOptions, SmimeSigner, arcMessageSignatureBase, arcSealBase, createDkimSigner, createSmimeEncrypter, createSmimeSigner, signArc, verifyArc };
|
|
307
|
+
export { type ArcAlgorithm, type ArcHeaderSet, type ArcSealOptions, type ArcVerifyOptions, type ArcVerifyResult, type DkimOptions, DkimSigner, type EmailEncrypter, type EmailSigner, type SmimeEncryptOptions, SmimeEncrypter, type SmimeSignOptions, SmimeSigner, arcMessageSignatureBase, arcSealBase, createDkimSigner, createSmimeEncrypter, createSmimeSigner, createTransportDkimSigner, signArc, verifyArc };
|
package/dist/crypto/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{arcMessageSignatureBase as
|
|
1
|
+
import{arcMessageSignatureBase as i,arcSealBase as m,signArc as a,verifyArc as t}from"../packem_shared/arcMessageSignatureBase-su9VTRB7.js";import{DkimSigner as c,createDkimSigner as n,createTransportDkimSigner as o}from"../packem_shared/DkimSigner-CCxFKitN.js";import{SmimeEncrypter as p,createSmimeEncrypter as s}from"../packem_shared/SmimeEncrypter-DnlfpjUX.js";import{SmimeSigner as x,createSmimeSigner as k}from"../packem_shared/SmimeSigner-DTvclzLq.js";export{c as DkimSigner,p as SmimeEncrypter,x as SmimeSigner,i as arcMessageSignatureBase,m as arcSealBase,n as createDkimSigner,s as createSmimeEncrypter,k as createSmimeSigner,o as createTransportDkimSigner,a as signArc,t as verifyArc};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type A as AttachmentDataOptions, type a as AttachmentOptions, type B as BatchBase, type b as BatchRenderer, D as DraftMailMessage, type F as FeatureCheckMode, M as Mail, type c as MailGlobalConfig, d as MailMessage, type e as MailOptions, type P as Personalization, type S as SendBatchOptions, type f as SendableMessage, g as createMail, h as detectMimeType, i as generateContentId, r as readFileAsBuffer } from "./packem_shared/mail.d-
|
|
1
|
+
export { type A as AttachmentDataOptions, type a as AttachmentOptions, type B as BatchBase, type b as BatchRenderer, D as DraftMailMessage, type F as FeatureCheckMode, M as Mail, type c as MailGlobalConfig, d as MailMessage, type e as MailOptions, type P as Personalization, type S as SendBatchOptions, type f as SendableMessage, g as createMail, h as detectMimeType, i as generateContentId, r as readFileAsBuffer } from "./packem_shared/mail.d-BdyyyQO5.js";
|
|
2
2
|
export type { M as Middleware, S as SendFunction } from "./packem_shared/types.d-GKqPNk0I.js";
|
|
3
3
|
export { type a as Provider, type P as ProviderFactory, d as defineProvider } from "./packem_shared/provider.d-Cx5YQJdP.js";
|
|
4
4
|
export type { T as TemplateRenderer } from "./packem_shared/types.d-I-KeZ5w2.js";
|
|
@@ -8,7 +8,7 @@ export { type OkResult, isErr, isOk, mapOk, tryAsync, unwrap, unwrapOr } from ".
|
|
|
8
8
|
export { type FeatureSupportResult, type FeatureViolation, default as checkFeatureSupport } from "./utils/validation/check-feature-support.js";
|
|
9
9
|
import 'ical-generator';
|
|
10
10
|
import 'node:buffer';
|
|
11
|
-
import "./packem_shared/types.d-
|
|
11
|
+
import "./packem_shared/types.d-Cb5fls_X.js";
|
|
12
12
|
interface ErrorProperties {
|
|
13
13
|
cause?: unknown;
|
|
14
14
|
hint?: ErrorHint;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{detectMimeType as a,generateContentId as t,readFileAsBuffer as o}from"./packem_shared/detectMimeType-
|
|
1
|
+
import{detectMimeType as a,generateContentId as t,readFileAsBuffer as o}from"./packem_shared/detectMimeType-BRz3Qjyz.js";import{default as p}from"./packem_shared/DraftMailMessage-B0gwf8n_.js";import{default as m}from"./packem_shared/EmailError-BIaHK1Uw.js";import{default as l}from"./packem_shared/RequiredOptionError-ctDEEB1s.js";import{Mail as u,createMail as x}from"./packem_shared/Mail-DmYNQ0KK.js";import{default as M}from"./packem_shared/MailMessage-DmmaNHHc.js";import{defineProvider as E}from"./packem_shared/defineProvider-C9q-7iwt.js";import{default as g}from"./utils/parse-eml.js";import{isErr as y,isOk as w,mapOk as A,tryAsync as F,unwrap as h,unwrapOr as q}from"./utils/result.js";import{default as B}from"./utils/validation/check-feature-support.js";export{p as DraftMailMessage,m as EmailError,u as Mail,M as MailMessage,l as RequiredOptionError,B as checkFeatureSupport,x as createMail,E as defineProvider,a as detectMimeType,t as generateContentId,y as isErr,w as isOk,A as mapOk,g as parseEml,o as readFileAsBuffer,F as tryAsync,h as unwrap,q as unwrapOr};
|
|
@@ -177,8 +177,16 @@ interface OAuth2MiddlewareOptions {
|
|
|
177
177
|
*/
|
|
178
178
|
fetchToken: () => Promise<OAuth2Token> | OAuth2Token;
|
|
179
179
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
180
|
+
* Inject the credential into this **message** header.
|
|
181
|
+
*
|
|
182
|
+
* `EmailOptions.headers` are MIME headers written onto the outgoing message (see
|
|
183
|
+
* `buildMimeMessage`), so every recipient — and every hop — sees this value. Providers
|
|
184
|
+
* authenticate over their own transport (`apiKey` in the HTTP request, SMTP XOAUTH2), never
|
|
185
|
+
* from here, so there is no legitimate reason to set this to `Authorization`.
|
|
186
|
+
*
|
|
187
|
+
* Leave it unset unless a provider genuinely requires a custom credential header on the
|
|
188
|
+
* message itself. Use {@link OAuth2MiddlewareOptions.onToken} instead.
|
|
189
|
+
* @default undefined — no header is injected
|
|
182
190
|
*/
|
|
183
191
|
headerName?: string;
|
|
184
192
|
/**
|
|
@@ -203,13 +211,18 @@ interface OAuth2MiddlewareOptions {
|
|
|
203
211
|
skewMs?: number;
|
|
204
212
|
}
|
|
205
213
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
214
|
+
* Acquires an OAuth2 credential for each outgoing message, refreshing it on demand and caching it
|
|
215
|
+
* until just before expiry.
|
|
208
216
|
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
217
|
+
* The token is handed to the caller through {@link OAuth2MiddlewareOptions.onToken} — the channel
|
|
218
|
+
* provider clients (Gmail, Microsoft 365, SMTP XOAUTH2) authenticate from. It is **not** written
|
|
219
|
+
* onto the message unless {@link OAuth2MiddlewareOptions.headerName} is set explicitly, because
|
|
220
|
+
* `EmailOptions.headers` are MIME headers the recipient can read.
|
|
211
221
|
* @param options OAuth2 configuration. See {@link OAuth2MiddlewareOptions}.
|
|
212
222
|
* @returns The middleware.
|
|
223
|
+
* @throws {TypeError} If neither `onToken` nor `headerName` is supplied — the token would have
|
|
224
|
+
* nowhere to go and the middleware would silently do nothing but burn token-endpoint calls — or if
|
|
225
|
+
* `headerName` is empty.
|
|
213
226
|
*/
|
|
214
227
|
declare const oauth2Middleware: (options: OAuth2MiddlewareOptions) => Middleware;
|
|
215
228
|
/**
|
package/dist/middleware/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{circuitBreakerMiddleware as o}from"../packem_shared/circuitBreakerMiddleware-DcBN7K6H.js";import{dedupeMiddleware as i}from"../packem_shared/dedupeMiddleware-BTo8Qjje.js";import{withEvents as p}from"../packem_shared/withEvents-BinK2hMw.js";import{loggingMiddleware as f}from"../packem_shared/loggingMiddleware-DNVf8O1B.js";import{withMetrics as w}from"../packem_shared/withMetrics-i3mZVfeE.js";import{oauth2Middleware as l}from"../packem_shared/oauth2Middleware-
|
|
1
|
+
import{circuitBreakerMiddleware as o}from"../packem_shared/circuitBreakerMiddleware-DcBN7K6H.js";import{dedupeMiddleware as i}from"../packem_shared/dedupeMiddleware-BTo8Qjje.js";import{withEvents as p}from"../packem_shared/withEvents-BinK2hMw.js";import{loggingMiddleware as f}from"../packem_shared/loggingMiddleware-DNVf8O1B.js";import{withMetrics as w}from"../packem_shared/withMetrics-i3mZVfeE.js";import{oauth2Middleware as l}from"../packem_shared/oauth2Middleware-C0M1w3_2.js";import{RATE_LIMIT_PRESETS as h,rateLimitMiddleware as s}from"../packem_shared/RATE_LIMIT_PRESETS-BIFmRuh2.js";import{default as c}from"../packem_shared/withRender-Ce6leoYE.js";import{retryMiddleware as E}from"../packem_shared/retryMiddleware-CaTv0UIm.js";import{withSuppression as g}from"../packem_shared/withSuppression-B0eZ2xNQ.js";import{withTelemetry as S}from"../packem_shared/withTelemetry-DEKTis1I.js";import{composeMiddleware as I}from"../packem_shared/composeMiddleware-B3RCDFsy.js";export{h as RATE_LIMIT_PRESETS,o as circuitBreakerMiddleware,I as composeMiddleware,i as dedupeMiddleware,f as loggingMiddleware,l as oauth2Middleware,s as rateLimitMiddleware,E as retryMiddleware,p as withEvents,w as withMetrics,c as withRender,g as withSuppression,S as withTelemetry};
|
|
@@ -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,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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./MailMessage-
|
|
1
|
+
import e from"./MailMessage-DmmaNHHc.js";class t extends e{constructor(){super(),this.header("X-Unsent","1")}}export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import f from"./DraftMailMessage-
|
|
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};
|