@shipstatic/ship 2.0.0-beta.1 → 2.0.0-beta.3

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/README.md CHANGED
@@ -49,6 +49,8 @@ const ship = new Ship({ token: 'ship-...' });
49
49
  ship ./dist # Deploy (shortcut)
50
50
  ship ./dist --label production --label v1.0.0 # Deploy with labels
51
51
  ship deployments list
52
+ ship deployments list --limit 20 # Page size; a hint shows the next cursor
53
+ ship deployments list --cursor <cursor> # Continue from a previous page
52
54
  ship deployments get <deployment>
53
55
  ship deployments set <deployment> --label production
54
56
  ship deployments remove <deployment>
@@ -57,7 +59,7 @@ ship deployments remove <deployment>
57
59
  ```typescript
58
60
  ship.deploy(input, options?) // Shortcut for deployments.upload()
59
61
  ship.deployments.upload(input, options?)
60
- ship.deployments.list()
62
+ ship.deployments.list(options?) // { limit?, cursor? } — response carries the next cursor
61
63
  ship.deployments.get(deployment)
62
64
  ship.deployments.set(deployment, { labels })
63
65
  ship.deployments.remove(deployment)
@@ -70,7 +72,7 @@ ship domains set www.example.com # Reserve domain (no deployme
70
72
  ship domains set www.example.com <deployment> # Link domain to deployment
71
73
  ship domains set www.example.com --label prod # Update labels only
72
74
  ship domains get www.example.com
73
- ship domains list
75
+ ship domains list # --limit / --cursor paginate here too
74
76
  ship domains validate www.example.com
75
77
  ship domains verify www.example.com
76
78
  ship domains records www.example.com
@@ -82,7 +84,7 @@ ship domains remove www.example.com
82
84
  ```typescript
83
85
  ship.domains.set(name, { deployment?, labels? }) // Upsert — create, repoint, or label
84
86
  ship.domains.get(name)
85
- ship.domains.list()
87
+ ship.domains.list(options?) // { limit?, cursor? }
86
88
  ship.domains.validate(name)
87
89
  ship.domains.verify(name)
88
90
  ship.domains.records(name)
@@ -164,8 +166,8 @@ Available on every command:
164
166
  | `--json` | Output results in JSON format |
165
167
  | `-q, --quiet` | Output only the resource identifier |
166
168
  | `--no-color` | Disable colored output |
167
- | `--help` | Display help for command |
168
- | `--version` | Show version information |
169
+ | `-h, --help` | Display help for command |
170
+ | `-V, --version` | Show version information |
169
171
 
170
172
  ### Deploy Flags
171
173
 
@@ -219,13 +221,9 @@ ship.setToken('ship-...');
219
221
  ship.deploy(input, {
220
222
  labels?: string[],
221
223
  password?: string, // Password-protect the deployment (6–128 chars)
222
- onProgress?: ({ percent }) => void,
223
- signal?: AbortSignal,
224
- onCancel?: () => void, // Called if signal aborts
224
+ signal?: AbortSignal, // Abort to cancel the deploy
225
225
  pathDetect?: boolean, // Auto-optimize paths (default: true)
226
226
  spaDetect?: boolean, // Auto-detect SPA (default: true)
227
- maxConcurrency?: number, // Concurrent uploads (default: 4)
228
- timeout?: number, // Request timeout in ms
229
227
  via?: string, // Client identifier
230
228
  });
231
229
  ```
@@ -273,6 +271,8 @@ ship.off('request', handler);
273
271
 
274
272
  Pass `fetch` to override the transport function used for every API call. Defaults to `globalThis.fetch`. Useful for wrapping requests with tracing, retries, or request signing, and for injecting a Cloudflare service-binding `Fetcher` from a Worker so calls reach a sibling Worker in-process instead of through the public hostname.
275
273
 
274
+ This is also the seam for corporate proxies: Node's built-in `fetch` ignores `HTTP(S)_PROXY` environment variables, so behind a proxy inject a proxy-aware transport (e.g. [undici](https://github.com/nodejs/undici)'s `EnvHttpProxyAgent` as the dispatcher, or Node 24+'s `NODE_USE_ENV_PROXY=1`).
275
+
276
276
  ```typescript
277
277
  import type { Fetch } from '@shipstatic/ship';
278
278
 
package/dist/browser.d.ts CHANGED
@@ -258,6 +258,13 @@ interface Account {
258
258
  readonly activated: number | null;
259
259
  /** Last 4 characters of the API key for identification, null when no key generated */
260
260
  readonly hint: string | null;
261
+ /**
262
+ * Unix timestamp (seconds) of the API key's last use, null when never
263
+ * used or no key generated. Optional on the type by the additive-evolution
264
+ * law: published SDK versions may predate the field, so consumers read it
265
+ * when present rather than forcing a lockstep SDK release.
266
+ */
267
+ readonly used?: number | null;
261
268
  /** Grace period expiration (unix seconds), null if no grace period active */
262
269
  readonly grace: number | null;
263
270
  }
@@ -515,9 +522,17 @@ declare function hasUnbuiltMarker(filePath: string): boolean;
515
522
  interface PingResponse {
516
523
  /** Always true if service is healthy */
517
524
  success: boolean;
518
- /** Optional timestamp */
525
+ /** Server time in unix seconds — the one wire unit for timestamps. */
519
526
  timestamp?: number;
520
527
  }
528
+ /**
529
+ * Where human identity is mounted on the API host. The API mounts Better
530
+ * Auth at this path (sign-in, sign-out, session reads, admin impersonation)
531
+ * and the web console's auth client posts to it — shared here so the two
532
+ * halves of the auth pair agree by construction, the same way both sides
533
+ * already share the credential prefixes below.
534
+ */
535
+ declare const AUTH_BASE_PATH = "/auth";
521
536
  /**
522
537
  * How a request (or recorded activity) was authorized.
523
538
  *
@@ -712,20 +727,6 @@ interface StaticFile {
712
727
  /** The size of the file in bytes. */
713
728
  size: number;
714
729
  }
715
- /**
716
- * Progress information for deploy/upload operations.
717
- * Provides consistent percentage-based progress with byte-level details.
718
- */
719
- interface ProgressInfo {
720
- /** Progress percentage (0-100) */
721
- percent: number;
722
- /** Number of bytes loaded so far */
723
- loaded: number;
724
- /** Total number of bytes to load. May be 0 if unknown initially */
725
- total: number;
726
- /** Current file being processed (optional) */
727
- file?: string;
728
- }
729
730
  /** Default API URL if not otherwise configured. */
730
731
  declare const DEFAULT_API = "https://api.shipstatic.com";
731
732
  /**
@@ -769,11 +770,28 @@ interface DeploymentUploadOptions {
769
770
  captcha?: string;
770
771
  }
771
772
  /**
772
- * Deployment resource interface - the contract all implementations must follow
773
+ * Pagination options for the paginated list endpoints (`GET /deployments`,
774
+ * `GET /domains`). The response's `cursor` feeds the next request; a `null`
775
+ * cursor on the response means the last page. Omitting both returns the
776
+ * server's default first page.
773
777
  */
774
- interface DeploymentResource {
775
- upload: (input: DeployInput, options?: DeploymentUploadOptions) => Promise<DeploymentCreateResponse>;
776
- list: () => Promise<DeploymentListResponse>;
778
+ interface ListOptions {
779
+ /** Maximum number of items to return in one page. */
780
+ limit?: number;
781
+ /** Opaque cursor from the previous page's response. */
782
+ cursor?: string;
783
+ }
784
+ /**
785
+ * Deployment resource interface - the contract all implementations must follow.
786
+ *
787
+ * The interface defines the minimal wire contract; SDK implementations may
788
+ * extend the upload options with runtime concerns (timeout, signal, progress
789
+ * callbacks) by parameterizing: `DeploymentResource<MyUploadOptions>`. The
790
+ * default keeps plain `DeploymentResource` valid for wire-only consumers.
791
+ */
792
+ interface DeploymentResource<UploadOptions extends DeploymentUploadOptions = DeploymentUploadOptions> {
793
+ upload: (input: DeployInput, options?: UploadOptions) => Promise<DeploymentCreateResponse>;
794
+ list: (options?: ListOptions) => Promise<DeploymentListResponse>;
777
795
  get: (id: string) => Promise<Deployment>;
778
796
  set: (id: string, options: {
779
797
  labels: string[];
@@ -788,7 +806,7 @@ interface DomainResource {
788
806
  deployment?: string;
789
807
  labels?: string[];
790
808
  }) => Promise<DomainSetResult>;
791
- list: () => Promise<DomainListResponse>;
809
+ list: (options?: ListOptions) => Promise<DomainListResponse>;
792
810
  get: (name: string) => Promise<Domain>;
793
811
  remove: (name: string) => Promise<void>;
794
812
  verify: (name: string) => Promise<{
@@ -848,11 +866,11 @@ interface CheckoutSession {
848
866
  * All activity event types logged in the system.
849
867
  * Uses dot notation consistently: {resource}.{action}
850
868
  */
851
- type ActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.paid' | 'account.plan.transition' | 'account.suspended' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'deployment.flagged' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'admin.account.plan.update' | 'admin.account.ref.update' | 'admin.account.billing.update' | 'admin.account.labels.update' | 'admin.deployment.delete' | 'admin.domain.delete' | 'admin.billing.sync' | 'admin.billing.terminated' | 'admin.impersonate' | 'billing.active' | 'billing.canceled' | 'billing.paused' | 'billing.expired' | 'billing.paid' | 'billing.trialing' | 'billing.scheduled_cancel' | 'billing.unpaid' | 'billing.update' | 'billing.past_due' | 'refund.created' | 'dispute.created' | 'billing.sync' | 'billing.stale' | 'billing.race';
869
+ type ActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.paid' | 'account.plan.transition' | 'account.suspended' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'deployment.flagged' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'token.delete' | 'admin.account.plan.update' | 'admin.account.ref.update' | 'admin.account.billing.update' | 'admin.account.labels.update' | 'admin.deployment.delete' | 'admin.domain.delete' | 'admin.billing.sync' | 'admin.billing.terminated' | 'admin.impersonate' | 'billing.active' | 'billing.canceled' | 'billing.paused' | 'billing.expired' | 'billing.paid' | 'billing.trialing' | 'billing.scheduled_cancel' | 'billing.unpaid' | 'billing.update' | 'billing.past_due' | 'refund.created' | 'dispute.created' | 'billing.sync' | 'billing.stale' | 'billing.race';
852
870
  /**
853
871
  * Activity events visible to users in the dashboard
854
872
  */
855
- type UserVisibleActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.transition' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume';
873
+ type UserVisibleActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.transition' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'token.delete';
856
874
  /**
857
875
  * Activity record returned from the API
858
876
  */
@@ -871,6 +889,12 @@ interface Activity {
871
889
  /**
872
890
  * Parsed activity metadata.
873
891
  * Different events populate different fields.
892
+ *
893
+ * Naming convention: meta booleans are event-scoped predicates and carry
894
+ * their prefix (`isUpdate`, `wasVerified`, `hasConfig`, `hasPassword`),
895
+ * while entity booleans are bare nouns (`Deployment.config`,
896
+ * `Deployment.password`). Two vocabularies, each internally consistent —
897
+ * deliberate, not drift.
874
898
  */
875
899
  interface ActivityMeta {
876
900
  /** Number of files in deployment */
@@ -1109,20 +1133,17 @@ declare function validatePassword(value: unknown): string | undefined;
1109
1133
  * Extends the API contract (DeploymentUploadOptions) with SDK-specific options.
1110
1134
  */
1111
1135
  interface DeploymentOptions extends DeploymentUploadOptions {
1112
- /** An AbortSignal to allow cancellation of the deploy operation. */
1136
+ /**
1137
+ * An AbortSignal to allow cancellation of the deploy operation. The one
1138
+ * cancellation mechanism — abort the signal and the request rejects with
1139
+ * a typed `Cancelled` error. Request timeouts are a client concern
1140
+ * (`ShipClientOptions.timeout`), not a per-deploy one.
1141
+ */
1113
1142
  signal?: AbortSignal;
1114
- /** Callback invoked if the deploy is cancelled via the AbortSignal. */
1115
- onCancel?: () => void;
1116
- /** Maximum number of concurrent operations. */
1117
- maxConcurrency?: number;
1118
- /** Timeout in milliseconds for the deploy request. */
1119
- timeout?: number;
1120
1143
  /** Whether to auto-detect and optimize file paths by flattening common directories. Defaults to true. */
1121
1144
  pathDetect?: boolean;
1122
1145
  /** Whether to auto-detect SPAs and generate ship.json configuration. Defaults to true. */
1123
1146
  spaDetect?: boolean;
1124
- /** Callback for deploy progress with detailed statistics. */
1125
- onProgress?: (info: ProgressInfo) => void;
1126
1147
  }
1127
1148
  type ApiDeployOptions = Omit<DeploymentOptions, 'pathDetect'>;
1128
1149
  /**
@@ -1177,7 +1198,7 @@ type Fetch = typeof fetch;
1177
1198
  type TokenProvider = () => string | Promise<string>;
1178
1199
  /**
1179
1200
  * Options for configuring a `Ship` instance.
1180
- * Sets default API host, the client credential, progress callbacks, concurrency, and timeouts for the client.
1201
+ * Sets the API host, the client credential, the request timeout, and the transport.
1181
1202
  */
1182
1203
  interface ShipClientOptions {
1183
1204
  /** Default API URL for the client instance. */
@@ -1198,19 +1219,8 @@ interface ShipClientOptions {
1198
1219
  */
1199
1220
  token?: string | TokenProvider | undefined;
1200
1221
  /**
1201
- * Default callback for deploy progress for deploys made with this client.
1202
- * @param info - Progress information including percentage and byte counts.
1203
- */
1204
- onProgress?: ((info: ProgressInfo) => void) | undefined;
1205
- /**
1206
- * Default for maximum concurrent deploys.
1207
- * Used if an deploy operation doesn't specify its own `maxConcurrency`.
1208
- * Defaults to 4 if not set here or in the specific deploy call.
1209
- */
1210
- maxConcurrency?: number | undefined;
1211
- /**
1212
- * Default timeout in milliseconds for API requests made by this client instance.
1213
- * Used if an deploy operation doesn't specify its own timeout.
1222
+ * Timeout in milliseconds for every API request made by this client
1223
+ * instance. Defaults to 30 seconds.
1214
1224
  */
1215
1225
  timeout?: number | undefined;
1216
1226
  /**
@@ -1277,7 +1287,19 @@ interface ShipEvents {
1277
1287
  request: [url: string, init: RequestInit];
1278
1288
  /** Emitted after successful API response */
1279
1289
  response: [response: Response, url: string];
1280
- /** Emitted when API request fails */
1290
+ /**
1291
+ * Emitted when something fails. TWO populations arrive here, which is why
1292
+ * the type is `Error` and not `ShipError`:
1293
+ *
1294
+ * - a failed request — always a `ShipError` (`executeRequest` normalizes
1295
+ * every failure through `ShipError.fromFetchError` before emitting), so
1296
+ * `isShipError(error)` narrows and `.type` / `.status` are readable;
1297
+ * - a THROWING HANDLER of yours — `SimpleEvents.emit` evicts it and
1298
+ * re-emits the raw failure here, which is a plain `Error`.
1299
+ *
1300
+ * Narrowing this to `ShipError` was tried on 2026-07-27 and reverted: it
1301
+ * made the second population a lie.
1302
+ */
1281
1303
  error: [error: Error, url: string];
1282
1304
  }
1283
1305
 
@@ -1352,12 +1374,12 @@ declare class ApiHttp extends SimpleEvents {
1352
1374
  private safeClone;
1353
1375
  private parseResponse;
1354
1376
  deploy(files: StaticFile[], options?: ApiDeployOptions): Promise<DeploymentCreateResponse>;
1355
- listDeployments(): Promise<DeploymentListResponse>;
1377
+ listDeployments(options?: ListOptions): Promise<DeploymentListResponse>;
1356
1378
  getDeployment(id: string): Promise<Deployment>;
1357
1379
  updateDeploymentLabels(id: string, labels: string[]): Promise<Deployment>;
1358
1380
  removeDeployment(id: string): Promise<void>;
1359
1381
  setDomain(name: string, deployment?: string, labels?: string[]): Promise<DomainSetResult>;
1360
- listDomains(): Promise<DomainListResponse>;
1382
+ listDomains(options?: ListOptions): Promise<DomainListResponse>;
1361
1383
  getDomain(name: string): Promise<Domain>;
1362
1384
  removeDomain(name: string): Promise<void>;
1363
1385
  verifyDomain(name: string): Promise<{
@@ -1395,7 +1417,6 @@ interface ResourceContext {
1395
1417
  */
1396
1418
  interface DeploymentResourceContext extends ResourceContext {
1397
1419
  processInput: (input: DeployInput, options: DeploymentOptions) => Promise<StaticFile[]>;
1398
- clientDefaults?: ShipClientOptions;
1399
1420
  }
1400
1421
  /**
1401
1422
  * Upload deployment resource with all CRUD operations.
@@ -1405,7 +1426,7 @@ interface DeploymentResourceContext extends ResourceContext {
1405
1426
  * public-account agent identity per request (claim URL + expiry on the
1406
1427
  * response). The SDK stays a transparent pipe either way.
1407
1428
  */
1408
- declare function createDeploymentResource(ctx: DeploymentResourceContext): DeploymentResource;
1429
+ declare function createDeploymentResource(ctx: DeploymentResourceContext): DeploymentResource<DeploymentOptions>;
1409
1430
  /**
1410
1431
  * Create domain resource with all CRUD operations.
1411
1432
  *
@@ -1427,7 +1448,7 @@ declare function createTokenResource(ctx: ResourceContext): TokenResource;
1427
1448
  * Abstract base class for Ship SDK implementations.
1428
1449
  */
1429
1450
  declare abstract class Ship$1 {
1430
- readonly deployments: DeploymentResource;
1451
+ readonly deployments: DeploymentResource<DeploymentOptions>;
1431
1452
  readonly domains: DomainResource;
1432
1453
  readonly account: AccountResource;
1433
1454
  readonly tokens: TokenResource;
@@ -1452,7 +1473,7 @@ declare abstract class Ship$1 {
1452
1473
  /**
1453
1474
  * Deploy project (convenience shortcut to `ship.deployments.upload()`).
1454
1475
  */
1455
- deploy(input: DeployInput, options?: DeploymentOptions): Promise<Deployment>;
1476
+ deploy(input: DeployInput, options?: DeploymentOptions): Promise<DeploymentCreateResponse>;
1456
1477
  /**
1457
1478
  * Get current account information (convenience shortcut to `ship.account.get()`).
1458
1479
  */
@@ -1494,30 +1515,6 @@ declare abstract class Ship$1 {
1494
1515
  private getAuthHeaders;
1495
1516
  }
1496
1517
 
1497
- /**
1498
- * @file Cross-platform configuration helpers.
1499
- *
1500
- * One pure helper used by the deployment resource:
1501
- *
1502
- * - `mergeDeployOptions(perCallOptions, clientDefaults)` — overlays
1503
- * instance-level defaults under per-call overrides for a single deploy.
1504
- *
1505
- * Deploy options are pure deploy concerns (progress, timeout, concurrency).
1506
- * Credentials, the API URL, and the caller identifier are client identity —
1507
- * they live on the instance, never per call: one client is one principal
1508
- * speaking for one end user against one API. Callers that need a different
1509
- * identity construct another Ship.
1510
- */
1511
-
1512
- /**
1513
- * Overlay client-level defaults under per-call deploy options.
1514
- *
1515
- * Per-call options always win — they're the explicit override for a single
1516
- * `deployments.upload()`. Defaults fill in only when the per-call option is
1517
- * `undefined` (an explicit `null` / empty value passes through).
1518
- */
1519
- declare function mergeDeployOptions(options: DeploymentOptions, clientDefaults: ShipClientOptions): DeploymentOptions;
1520
-
1521
1518
  /**
1522
1519
  * @file Deploy path optimization - the core logic that makes Ship deployments clean and intuitive.
1523
1520
  * Automatically strips common parent directories to create clean deployment URLs.
@@ -1784,7 +1781,7 @@ declare function pluralize(count: number, singular: string, plural: string, incl
1784
1781
  * @param browserFiles - File[] to process for deploy.
1785
1782
  * @param options - Processing options including pathDetect for automatic path optimization.
1786
1783
  * @param platformLimits - Per-instance platform limits (file-size / count / total-size caps)
1787
- * from the originating Ship's `GET /config` fetch. Passed in rather than read from a
1784
+ * from the originating Ship's `GET /limits` fetch. Passed in rather than read from a
1788
1785
  * module global so concurrent Ships against different API URLs cannot clobber each
1789
1786
  * other's caps.
1790
1787
  * @returns Promise resolving to an array of StaticFile objects.
@@ -1826,9 +1823,9 @@ declare class Ship extends Ship$1 {
1826
1823
  * intentional: the convenience shortcut narrows; the resource-layer
1827
1824
  * contract stays platform-neutral.
1828
1825
  */
1829
- deploy(input: File[], options?: DeploymentOptions): Promise<Deployment>;
1826
+ deploy(input: File[], options?: DeploymentOptions): Promise<DeploymentCreateResponse>;
1830
1827
  protected processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
1831
1828
  protected getDeployBodyCreator(): DeployBodyCreator;
1832
1829
  }
1833
1830
 
1834
- export { API_KEY, type Account, type AccountGetResponse, type AccountOverrides, AccountPlan, type AccountPlanType, type AccountResource, type AccountUsage, type Activity, type ActivityEvent, type ActivityListResponse, type ActivityMeta, type ApiDeployOptions, ApiHttp, type ApiHttpOptions, AuthMethod, type AuthMethodType, BLOCKED_EXTENSIONS, type BillingStatus, CALLER, type CheckoutSession, DEFAULT_API, DEPLOYMENT_CONFIG_FILENAME, DEPLOY_TOKEN, type DeployBody, type DeployBodyContext, type DeployBodyCreator, type DeployFile, type DeployInput, type Deployment, type DeploymentCreateResponse, type DeploymentListResponse, type DeploymentOptions, type DeploymentResource, type DeploymentResourceContext, DeploymentStatus, type DeploymentStatusType, type DeploymentUploadOptions, type DnsProvider, type DnsRecord, type DnsRecordType, type Domain, type DomainDnsResponse, type DomainListResponse, type DomainRecordsResponse, type DomainResource, type DomainSetResult, DomainStatus, type DomainStatusType, type DomainValidateResponse, type ErrorResponse, ErrorType, type ExecutionEnvironment, FileValidationStatus as FILE_VALIDATION_STATUS, type Fetch, type FileValidationResult, FileValidationStatus, type FileValidationStatusType, JUNK_DIRECTORIES, LABEL_CONSTRAINTS, LABEL_PATTERN, type MD5Result, OAuthScope, type OAuthScopeType, PASSWORD_CONSTRAINTS, type PingResponse, type PlatformLimits, type ProgressInfo, type ResourceContext, type SPACheckRequest, type SPACheckResponse, SPA_DEFAULT_CONFIG, Ship, type ShipClientOptions, ShipError, type ShipEvents, type StaticFile, type TokenCreateResponse, TokenKind, type TokenKindType, type TokenListItem, type TokenListResponse, type TokenProvider, type TokenResource, UNBUILT_PROJECT_MARKERS, UNSAFE_FILENAME_CHARS, type UploadedFile, type UserVisibleActivityEvent, type ValidatableFile, type ValidationIssue, __setTestEnvironment, allValidFilesReady, calculateMD5, classifyToken, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, deserializeLabels, extractSubdomain, filterJunk, formatFileSize, generateDeploymentUrl, generateDomainUrl, getENV, getValidFiles, hasUnbuiltMarker, hasUnsafeChars, isBlockedExtension, isCustomDomain, isDeployment, isPlatformDomain, isShipError, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, serializeLabels, validateApiKey, validateApiUrl, validateCaller, validateDeployFile, validateDeployPath, validateDeployToken, validateFileName, validateFiles, validatePassword, validateToken };
1831
+ export { API_KEY, AUTH_BASE_PATH, type Account, type AccountGetResponse, type AccountOverrides, AccountPlan, type AccountPlanType, type AccountResource, type AccountUsage, type Activity, type ActivityEvent, type ActivityListResponse, type ActivityMeta, type ApiDeployOptions, ApiHttp, type ApiHttpOptions, AuthMethod, type AuthMethodType, BLOCKED_EXTENSIONS, type BillingStatus, CALLER, type CheckoutSession, DEFAULT_API, DEPLOYMENT_CONFIG_FILENAME, DEPLOY_TOKEN, type DeployBody, type DeployBodyContext, type DeployBodyCreator, type DeployFile, type DeployInput, type Deployment, type DeploymentCreateResponse, type DeploymentListResponse, type DeploymentOptions, type DeploymentResource, type DeploymentResourceContext, DeploymentStatus, type DeploymentStatusType, type DeploymentUploadOptions, type DnsProvider, type DnsRecord, type DnsRecordType, type Domain, type DomainDnsResponse, type DomainListResponse, type DomainRecordsResponse, type DomainResource, type DomainSetResult, DomainStatus, type DomainStatusType, type DomainValidateResponse, type ErrorResponse, ErrorType, type ExecutionEnvironment, FileValidationStatus as FILE_VALIDATION_STATUS, type Fetch, type FileValidationResult, FileValidationStatus, type FileValidationStatusType, JUNK_DIRECTORIES, LABEL_CONSTRAINTS, LABEL_PATTERN, type ListOptions, type MD5Result, OAuthScope, type OAuthScopeType, PASSWORD_CONSTRAINTS, type PingResponse, type PlatformLimits, type ResourceContext, type SPACheckRequest, type SPACheckResponse, SPA_DEFAULT_CONFIG, Ship, type ShipClientOptions, ShipError, type ShipEvents, type StaticFile, type TokenCreateResponse, TokenKind, type TokenKindType, type TokenListItem, type TokenListResponse, type TokenProvider, type TokenResource, UNBUILT_PROJECT_MARKERS, UNSAFE_FILENAME_CHARS, type UploadedFile, type UserVisibleActivityEvent, type ValidatableFile, type ValidationIssue, __setTestEnvironment, allValidFilesReady, calculateMD5, classifyToken, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, deserializeLabels, extractSubdomain, filterJunk, formatFileSize, generateDeploymentUrl, generateDomainUrl, getENV, getValidFiles, hasUnbuiltMarker, hasUnsafeChars, isBlockedExtension, isCustomDomain, isDeployment, isPlatformDomain, isShipError, optimizeDeployPaths, pluralize, processFilesForBrowser, serializeLabels, validateApiKey, validateApiUrl, validateCaller, validateDeployFile, validateDeployPath, validateDeployToken, validateFileName, validateFiles, validatePassword, validateToken };
package/dist/browser.js CHANGED
@@ -1,2 +1,2 @@
1
- var He=Object.create;var $=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var Ve=(n,i,e)=>i in n?$(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var x=(n,i)=>()=>(n&&(i=n(n=0)),i);var je=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports),Ke=(n,i)=>{for(var e in i)$(n,e,{get:i[e],enumerable:!0})},Xe=(n,i,e,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let p of Ge(i))!qe.call(n,p)&&p!==e&&$(n,p,{get:()=>i[p],enumerable:!(a=ze(i,p))||a.enumerable});return n};var Ye=(n,i,e)=>(e=n!=null?He(ke(n)):{},Xe(i||!n||!n.__esModule?$(e,"default",{value:n,enumerable:!0}):e,n));var U=(n,i,e)=>Ve(n,typeof i!="symbol"?i+"":i,e);function ce(n){return n!==null&&typeof n=="object"&&"name"in n&&n.name==="ShipError"&&"status"in n}function M(n){let i=n.lastIndexOf(".");if(i===-1||i===n.length-1)return!1;let e=n.slice(i+1).toLowerCase();return Qe.has(e)}function de(n){return Ze.test(n)}function H(n){return n.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>et.has(e))}function tt(n){return n.startsWith(fe.PREFIX)?N.API_KEY:n.startsWith(he.PREFIX)?N.DEPLOY_TOKEN:N.OPAQUE}function ye(n,i,e){if(!n.startsWith(i.PREFIX))throw f.validation(`${e} must start with "${i.PREFIX}"`);if(n.length!==i.TOTAL_LENGTH)throw f.validation(`${e} must be ${i.TOTAL_LENGTH} characters total (${i.PREFIX} + ${i.HEX_LENGTH} hex chars)`);let a=n.slice(i.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${i.HEX_LENGTH}}$`,"i").test(a))throw f.validation(`${e} must contain ${i.HEX_LENGTH} hexadecimal characters after "${i.PREFIX}" prefix`)}function nt(n){ye(n,fe,"API key")}function rt(n){ye(n,he,"Deploy token")}function Y(n){switch(tt(n)){case N.API_KEY:nt(n);return;case N.DEPLOY_TOKEN:rt(n);return;case N.OPAQUE:if(!n)throw f.validation("Token must be a non-empty string")}}function ge(n){if(!n||n.length>K.MAX_LENGTH||!K.PATTERN.test(n))throw f.validation(`Caller must be 1-${K.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function Dt(n){try{let i=new URL(n);if(!["http:","https:"].includes(i.protocol))throw f.validation("API URL must use http:// or https:// protocol");if(i.pathname!=="/"&&i.pathname!=="")throw f.validation("API URL must not contain a path");if(i.search||i.hash)throw f.validation("API URL must not contain query parameters or fragments")}catch(i){throw ce(i)?i:f.validation("API URL must be a valid URL")}}function St(n){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(n)}function Ee(n,i){return n.endsWith(`.${i}`)}function Tt(n,i){return!Ee(n,i)}function bt(n,i){return Ee(n,i)?n.slice(0,-(i.length+1)):null}function wt(n){return`https://${n}`}function vt(n){return`https://${n}`}function Rt(n){return!n||n.length===0?null:JSON.stringify(n)}function xt(n){if(!n)return[];try{let i=JSON.parse(n);return Array.isArray(i)?i:[]}catch{return[]}}function J(n){if(n==null)return;if(typeof n!="string")throw f.validation("Password must be a string");let i=n.trim();if(i.length<B.MIN_LENGTH||i.length>B.MAX_LENGTH)throw f.validation(`Password must be between ${B.MIN_LENGTH} and ${B.MAX_LENGTH} characters`);return i}var yt,gt,Et,E,We,j,Je,f,Qe,Ze,et,ue,fe,he,K,N,At,X,me,W,T,F,Ae,B,b=x(()=>{"use strict";yt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},gt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},Et={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},E={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},We=new Set([E.Network,E.Cancelled,E.File,E.Config]),j={client:new Set([E.Business,E.Config,E.File,E.Forbidden,E.Validation]),network:new Set([E.Network]),auth:new Set([E.Authentication])},Je=new Set(Object.values(E).filter(n=>!We.has(n))),f=class n extends Error{constructor(e,a,p,c){super(a);U(this,"type");U(this,"status");U(this,"details");this.type=e,this.status=p,this.details=c,this.name="ShipError"}toResponse(){let e=this.details,a=this.type===E.Authentication&&e?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:a}}static async fromHttpResponse(e,a){let p,c,m;try{if(e.headers.get("content-type")?.includes("application/json")){let h=await e.json();if(h&&typeof h=="object"){let g=h;typeof g.message=="string"?p=g.message:typeof g.error=="string"&&(p=g.error),c=g.details,typeof g.error=="string"&&Je.has(g.error)&&(m=g.error)}}else{let h=await e.text();h&&(p=h)}}catch{}p=p||`${a||"Request"} failed with status ${e.status}`;let y=m??(e.status===401?E.Authentication:e.status===403?E.Forbidden:e.status===429?E.RateLimit:E.Api);return new n(y,p,e.status,c)}static fromFetchError(e,a){if(ce(e))return e;let p=a||"Request";return e instanceof Error?e.name==="AbortError"?n.cancelled(`${p} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?n.network(`${p} failed: ${e.message}`,{cause:e}):new n(E.Api,`${p} failed: ${e.message}`):new n(E.Api,`${p} failed: Unknown error`)}static validation(e,a){return new n(E.Validation,e,400,a)}static notFound(e,a){let p=a?`${e} ${a} not found`:`${e} not found`;return new n(E.NotFound,p,404)}static forbidden(e,a){return new n(E.Forbidden,e,403,a)}static rateLimit(e="Too many requests",a){return new n(E.RateLimit,e,429,a)}static authentication(e="Authentication required",a){return new n(E.Authentication,e,401,a)}static business(e,a=400,p){return new n(E.Business,e,a,p)}static network(e,a){return new n(E.Network,e,void 0,a)}static cancelled(e,a){return new n(E.Cancelled,e,void 0,a)}static file(e,a){return new n(E.File,e,void 0,a)}static config(e,a){return new n(E.Config,e,void 0,a)}static api(e,a=500,p){return new n(E.Api,e,a,p)}isClientError(){return j.client.has(this.type)}isNetworkError(){return j.network.has(this.type)}isAuthError(){return j.auth.has(this.type)}isType(e){return this.type===e}};Qe=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);Ze=/[\x00-\x1f\x7f#?%\\<>"]/;et=new Set(["node_modules","package.json"]);ue={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},fe={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},he={PREFIX:"deploy-",HEX_LENGTH:64,TOTAL_LENGTH:71},K={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},N={API_KEY:ue.API_KEY,DEPLOY_TOKEN:ue.TOKEN,OPAQUE:"opaque"};At={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},X="ship.json",me={rewrites:[{source:"/(.*)",destination:"/index.html"}]};W="https://api.shipstatic.com",T={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};F={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Ae=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;B={MIN_LENGTH:6,MAX_LENGTH:128}});var be=je((Se,Te)=>{"use strict";(function(n){if(typeof Se=="object")Te.exports=n();else if(typeof define=="function"&&define.amd)define(n);else{var i;try{i=window}catch{i=self}i.SparkMD5=n()}})(function(n){"use strict";var i=function(u,l){return u+l&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(u,l,r,t,o,s){return l=i(i(l,u),i(t,s)),i(l<<o|l>>>32-o,r)}function p(u,l){var r=u[0],t=u[1],o=u[2],s=u[3];r+=(t&o|~t&s)+l[0]-680876936|0,r=(r<<7|r>>>25)+t|0,s+=(r&t|~r&o)+l[1]-389564586|0,s=(s<<12|s>>>20)+r|0,o+=(s&r|~s&t)+l[2]+606105819|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&r)+l[3]-1044525330|0,t=(t<<22|t>>>10)+o|0,r+=(t&o|~t&s)+l[4]-176418897|0,r=(r<<7|r>>>25)+t|0,s+=(r&t|~r&o)+l[5]+1200080426|0,s=(s<<12|s>>>20)+r|0,o+=(s&r|~s&t)+l[6]-1473231341|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&r)+l[7]-45705983|0,t=(t<<22|t>>>10)+o|0,r+=(t&o|~t&s)+l[8]+1770035416|0,r=(r<<7|r>>>25)+t|0,s+=(r&t|~r&o)+l[9]-1958414417|0,s=(s<<12|s>>>20)+r|0,o+=(s&r|~s&t)+l[10]-42063|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&r)+l[11]-1990404162|0,t=(t<<22|t>>>10)+o|0,r+=(t&o|~t&s)+l[12]+1804603682|0,r=(r<<7|r>>>25)+t|0,s+=(r&t|~r&o)+l[13]-40341101|0,s=(s<<12|s>>>20)+r|0,o+=(s&r|~s&t)+l[14]-1502002290|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&r)+l[15]+1236535329|0,t=(t<<22|t>>>10)+o|0,r+=(t&s|o&~s)+l[1]-165796510|0,r=(r<<5|r>>>27)+t|0,s+=(r&o|t&~o)+l[6]-1069501632|0,s=(s<<9|s>>>23)+r|0,o+=(s&t|r&~t)+l[11]+643717713|0,o=(o<<14|o>>>18)+s|0,t+=(o&r|s&~r)+l[0]-373897302|0,t=(t<<20|t>>>12)+o|0,r+=(t&s|o&~s)+l[5]-701558691|0,r=(r<<5|r>>>27)+t|0,s+=(r&o|t&~o)+l[10]+38016083|0,s=(s<<9|s>>>23)+r|0,o+=(s&t|r&~t)+l[15]-660478335|0,o=(o<<14|o>>>18)+s|0,t+=(o&r|s&~r)+l[4]-405537848|0,t=(t<<20|t>>>12)+o|0,r+=(t&s|o&~s)+l[9]+568446438|0,r=(r<<5|r>>>27)+t|0,s+=(r&o|t&~o)+l[14]-1019803690|0,s=(s<<9|s>>>23)+r|0,o+=(s&t|r&~t)+l[3]-187363961|0,o=(o<<14|o>>>18)+s|0,t+=(o&r|s&~r)+l[8]+1163531501|0,t=(t<<20|t>>>12)+o|0,r+=(t&s|o&~s)+l[13]-1444681467|0,r=(r<<5|r>>>27)+t|0,s+=(r&o|t&~o)+l[2]-51403784|0,s=(s<<9|s>>>23)+r|0,o+=(s&t|r&~t)+l[7]+1735328473|0,o=(o<<14|o>>>18)+s|0,t+=(o&r|s&~r)+l[12]-1926607734|0,t=(t<<20|t>>>12)+o|0,r+=(t^o^s)+l[5]-378558|0,r=(r<<4|r>>>28)+t|0,s+=(r^t^o)+l[8]-2022574463|0,s=(s<<11|s>>>21)+r|0,o+=(s^r^t)+l[11]+1839030562|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^r)+l[14]-35309556|0,t=(t<<23|t>>>9)+o|0,r+=(t^o^s)+l[1]-1530992060|0,r=(r<<4|r>>>28)+t|0,s+=(r^t^o)+l[4]+1272893353|0,s=(s<<11|s>>>21)+r|0,o+=(s^r^t)+l[7]-155497632|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^r)+l[10]-1094730640|0,t=(t<<23|t>>>9)+o|0,r+=(t^o^s)+l[13]+681279174|0,r=(r<<4|r>>>28)+t|0,s+=(r^t^o)+l[0]-358537222|0,s=(s<<11|s>>>21)+r|0,o+=(s^r^t)+l[3]-722521979|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^r)+l[6]+76029189|0,t=(t<<23|t>>>9)+o|0,r+=(t^o^s)+l[9]-640364487|0,r=(r<<4|r>>>28)+t|0,s+=(r^t^o)+l[12]-421815835|0,s=(s<<11|s>>>21)+r|0,o+=(s^r^t)+l[15]+530742520|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^r)+l[2]-995338651|0,t=(t<<23|t>>>9)+o|0,r+=(o^(t|~s))+l[0]-198630844|0,r=(r<<6|r>>>26)+t|0,s+=(t^(r|~o))+l[7]+1126891415|0,s=(s<<10|s>>>22)+r|0,o+=(r^(s|~t))+l[14]-1416354905|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~r))+l[5]-57434055|0,t=(t<<21|t>>>11)+o|0,r+=(o^(t|~s))+l[12]+1700485571|0,r=(r<<6|r>>>26)+t|0,s+=(t^(r|~o))+l[3]-1894986606|0,s=(s<<10|s>>>22)+r|0,o+=(r^(s|~t))+l[10]-1051523|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~r))+l[1]-2054922799|0,t=(t<<21|t>>>11)+o|0,r+=(o^(t|~s))+l[8]+1873313359|0,r=(r<<6|r>>>26)+t|0,s+=(t^(r|~o))+l[15]-30611744|0,s=(s<<10|s>>>22)+r|0,o+=(r^(s|~t))+l[6]-1560198380|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~r))+l[13]+1309151649|0,t=(t<<21|t>>>11)+o|0,r+=(o^(t|~s))+l[4]-145523070|0,r=(r<<6|r>>>26)+t|0,s+=(t^(r|~o))+l[11]-1120210379|0,s=(s<<10|s>>>22)+r|0,o+=(r^(s|~t))+l[2]+718787259|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~r))+l[9]-343485551|0,t=(t<<21|t>>>11)+o|0,u[0]=r+u[0]|0,u[1]=t+u[1]|0,u[2]=o+u[2]|0,u[3]=s+u[3]|0}function c(u){var l=[],r;for(r=0;r<64;r+=4)l[r>>2]=u.charCodeAt(r)+(u.charCodeAt(r+1)<<8)+(u.charCodeAt(r+2)<<16)+(u.charCodeAt(r+3)<<24);return l}function m(u){var l=[],r;for(r=0;r<64;r+=4)l[r>>2]=u[r]+(u[r+1]<<8)+(u[r+2]<<16)+(u[r+3]<<24);return l}function y(u){var l=u.length,r=[1732584193,-271733879,-1732584194,271733878],t,o,s,v,I,P;for(t=64;t<=l;t+=64)p(r,c(u.substring(t-64,t)));for(u=u.substring(t-64),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)s[t>>2]|=u.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(p(r,s),t=0;t<16;t+=1)s[t]=0;return v=l*8,v=v.toString(16).match(/(.*?)(.{0,8})$/),I=parseInt(v[2],16),P=parseInt(v[1],16)||0,s[14]=I,s[15]=P,p(r,s),r}function d(u){var l=u.length,r=[1732584193,-271733879,-1732584194,271733878],t,o,s,v,I,P;for(t=64;t<=l;t+=64)p(r,m(u.subarray(t-64,t)));for(u=t-64<l?u.subarray(t-64):new Uint8Array(0),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)s[t>>2]|=u[t]<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(p(r,s),t=0;t<16;t+=1)s[t]=0;return v=l*8,v=v.toString(16).match(/(.*?)(.{0,8})$/),I=parseInt(v[2],16),P=parseInt(v[1],16)||0,s[14]=I,s[15]=P,p(r,s),r}function h(u){var l="",r;for(r=0;r<4;r+=1)l+=e[u>>r*8+4&15]+e[u>>r*8&15];return l}function g(u){var l;for(l=0;l<u.length;l+=1)u[l]=h(u[l]);return u.join("")}g(y("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(i=function(u,l){var r=(u&65535)+(l&65535),t=(u>>16)+(l>>16)+(r>>16);return t<<16|r&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(l,r){return l=l|0||0,l<0?Math.max(l+r,0):Math.min(l,r)}ArrayBuffer.prototype.slice=function(l,r){var t=this.byteLength,o=u(l,t),s=t,v,I,P,pe;return r!==n&&(s=u(r,t)),o>s?new ArrayBuffer(0):(v=s-o,I=new ArrayBuffer(v),P=new Uint8Array(I),pe=new Uint8Array(this,o,v),P.set(pe),I)}})();function D(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function w(u,l){var r=u.length,t=new ArrayBuffer(r),o=new Uint8Array(t),s;for(s=0;s<r;s+=1)o[s]=u.charCodeAt(s);return l?o:t}function R(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function O(u,l,r){var t=new Uint8Array(u.byteLength+l.byteLength);return t.set(new Uint8Array(u)),t.set(new Uint8Array(l),u.byteLength),r?t:t.buffer}function L(u){var l=[],r=u.length,t;for(t=0;t<r-1;t+=2)l.push(parseInt(u.substr(t,2),16));return String.fromCharCode.apply(String,l)}function A(){this.reset()}return A.prototype.append=function(u){return this.appendBinary(D(u)),this},A.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var l=this._buff.length,r;for(r=64;r<=l;r+=64)p(this._hash,c(this._buff.substring(r-64,r)));return this._buff=this._buff.substring(r-64),this},A.prototype.end=function(u){var l=this._buff,r=l.length,t,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(t=0;t<r;t+=1)o[t>>2]|=l.charCodeAt(t)<<(t%4<<3);return this._finish(o,r),s=g(this._hash),u&&(s=L(s)),this.reset(),s},A.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},A.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},A.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},A.prototype._finish=function(u,l){var r=l,t,o,s;if(u[r>>2]|=128<<(r%4<<3),r>55)for(p(this._hash,u),r=0;r<16;r+=1)u[r]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(t[2],16),s=parseInt(t[1],16)||0,u[14]=o,u[15]=s,p(this._hash,u)},A.hash=function(u,l){return A.hashBinary(D(u),l)},A.hashBinary=function(u,l){var r=y(u),t=g(r);return l?L(t):t},A.ArrayBuffer=function(){this.reset()},A.ArrayBuffer.prototype.append=function(u){var l=O(this._buff.buffer,u,!0),r=l.length,t;for(this._length+=u.byteLength,t=64;t<=r;t+=64)p(this._hash,m(l.subarray(t-64,t)));return this._buff=t-64<r?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},A.ArrayBuffer.prototype.end=function(u){var l=this._buff,r=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,s;for(o=0;o<r;o+=1)t[o>>2]|=l[o]<<(o%4<<3);return this._finish(t,r),s=g(this._hash),u&&(s=L(s)),this.reset(),s},A.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.ArrayBuffer.prototype.getState=function(){var u=A.prototype.getState.call(this);return u.buff=R(u.buff),u},A.ArrayBuffer.prototype.setState=function(u){return u.buff=w(u.buff,!0),A.prototype.setState.call(this,u)},A.ArrayBuffer.prototype.destroy=A.prototype.destroy,A.ArrayBuffer.prototype._finish=A.prototype._finish,A.ArrayBuffer.hash=function(u,l){var r=d(new Uint8Array(u)),t=g(r);return l?L(t):t},A})});async function st(n){let i=(await Promise.resolve().then(()=>Ye(be(),1))).default,e=new i.ArrayBuffer,a=2097152;for(let p=0;p<n.size;p+=a){let c=Math.min(p+a,n.size);e.append(await n.slice(p,c).arrayBuffer())}return{md5:e.end()}}async function ot(n){let{createHash:i}=await import("crypto"),e=i("md5");return e.update(n),{md5:e.digest("hex")}}async function at(n){let{createHash:i}=await import("crypto"),{createReadStream:e}=await import("fs");return new Promise((a,p)=>{let c=i("md5"),m=e(n);m.on("error",y=>p(f.business(`Failed to read file for MD5: ${y.message}`))),m.on("data",y=>c.update(y)),m.on("end",()=>a({md5:c.digest("hex")}))})}async function _(n){if(n instanceof Blob)return st(n);if(typeof Buffer<"u"&&Buffer.isBuffer(n))return ot(n);if(typeof n=="string")return at(n);throw f.business("Invalid input for MD5 calculation")}var k=x(()=>{"use strict";b()});function V(n){return n.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Fe=x(()=>{"use strict"});function Le(n,i={}){if(i.flatten===!1)return n.map(a=>({path:V(a),name:Q(a)}));let e=pt(n);return n.map(a=>{let p=V(a);if(e){let c=e.endsWith("/")?e:`${e}/`;p.startsWith(c)&&(p=p.substring(c.length))}return p||(p=Q(a)),{path:p,name:Q(a)}})}function pt(n){if(!n.length)return"";let e=n.map(c=>V(c)).map(c=>c.split("/")),a=[],p=Math.min(...e.map(c=>c.length));for(let c=0;c<p-1;c++){let m=e[0][c];if(e.every(y=>y[c]===m))a.push(m);else break}return a.join("/")}function Q(n){return n.split(/[/\\]/).pop()||n}var Z=x(()=>{"use strict";Fe()});function on(n){ee=n}function ut(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function Ne(){return ee||ut()}var ee,te=x(()=>{"use strict";ee=null});function ne(n,i=1){if(n===0)return"0 Bytes";let e=1024,a=["Bytes","KB","MB","GB"],p=Math.floor(Math.log(n)/Math.log(e));return`${parseFloat((n/e**p).toFixed(i))} ${a[p]}`}function re(n){if(de(n))return{valid:!1,reason:"File name contains unsafe characters"};if(n.startsWith(" ")||n.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(n.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let i=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=n.split("/").pop()||n;return i.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:n.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function pn(n,i){let e=[],a=[],p=[];if(n.length===0){let d={file:"(no files)",message:"At least one file must be provided"};return e.push(d),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let d of n)if(H(d.name))return e.push({file:d.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:n.map(h=>({...h,status:T.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(n.length>i.maxFilesCount){let d={file:`(${n.length} files)`,message:`File count (${n.length}) exceeds limit of ${i.maxFilesCount}`};return e.push(d),{files:n.map(h=>({...h,status:T.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let d of n){let h=T.READY,g="Ready for upload",D=d.name?re(d.name):{valid:!1,reason:"File name cannot be empty"};if(d.status===T.PROCESSING_ERROR)h=T.VALIDATION_FAILED,g=d.statusMessage||"File failed during processing",e.push({file:d.name,message:g});else if(d.size===0){h=T.EXCLUDED,g="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:d.name,message:g}),p.push({...d,status:h,statusMessage:g});continue}else d.size<0?(h=T.VALIDATION_FAILED,g="File size must be positive",e.push({file:d.name,message:g})):!d.name||d.name.trim().length===0?(h=T.VALIDATION_FAILED,g="File name cannot be empty",e.push({file:d.name||"(empty)",message:g})):d.name.includes("\0")?(h=T.VALIDATION_FAILED,g="File name contains invalid characters (null byte)",e.push({file:d.name,message:g})):D.valid?M(d.name)?(h=T.VALIDATION_FAILED,g=`File extension not allowed: "${d.name}"`,e.push({file:d.name,message:g})):d.size>i.maxFileSize?(h=T.VALIDATION_FAILED,g=`File size (${ne(d.size)}) exceeds limit of ${ne(i.maxFileSize)}`,e.push({file:d.name,message:g})):(c+=d.size,c>i.maxTotalSize&&(h=T.VALIDATION_FAILED,g=`Total size would exceed limit of ${ne(i.maxTotalSize)}`,e.push({file:d.name,message:g}))):(h=T.VALIDATION_FAILED,g=D.reason||"Invalid file name",e.push({file:d.name,message:g}));p.push({...d,status:h,statusMessage:g})}e.length>0&&(p=p.map(d=>d.status===T.EXCLUDED?d:{...d,status:T.VALIDATION_FAILED,statusMessage:d.status===T.VALIDATION_FAILED?d.statusMessage:"Deployment failed due to validation errors in bundle"}));let m=e.length===0?p.filter(d=>d.status===T.READY):[],y=e.length===0;return{files:p,validFiles:m,errors:e,warnings:a,canDeploy:y}}function ct(n){return n.filter(i=>i.status===T.READY)}function un(n){return ct(n).length>0}var ie=x(()=>{"use strict";b()});function Oe(n){return ft.test(n)}var dt,ft,Ce=x(()=>{"use strict";dt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],ft=new RegExp(dt.join("|"))});function _e(n,i){if(!n||n.length===0)return[];if(!i?.allowUnbuilt&&n.find(a=>a&&H(a)))throw f.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return n.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let p=a[a.length-1];if(Oe(p))return!1;for(let m of a)if(m!==".well-known"&&(m.startsWith(".")||m.length>255))return!1;let c=a.slice(0,-1);for(let m of c)if(ht.some(y=>m.toLowerCase()===y.toLowerCase()))return!1;return!0})}var ht,se=x(()=>{"use strict";b();Ce();ht=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function $e(n,i){if(n.includes("\0")||n.includes("/../")||n.startsWith("../")||n.endsWith("/.."))throw f.business(`Security error: Unsafe file path "${n}" for file: ${i}`)}function Ue(n,i){let e=re(n);if(!e.valid)throw f.business(e.reason||"Invalid file name");if(M(n))throw f.business(`File extension not allowed: "${i}"`)}var oe=x(()=>{"use strict";b();ie()});var Me={};Ke(Me,{processFilesForBrowser:()=>Be});async function Be(n,i={},e){if(Ne()!=="browser")throw f.business("processFilesForBrowser can only be called in a browser environment.");let a=n.map(D=>D.webkitRelativePath||D.name),p=i.build||i.prerender,c=Le(a,{flatten:i.pathDetect!==!1}),m=c.map(D=>D.path),y=new Set(_e(m,{allowUnbuilt:p})),d=[];for(let D=0;D<n.length;D++)y.has(m[D])&&d.push({file:n[D],deployPath:c[D].path});if(d.length===0)return[];if(p){let D=[];for(let w=0;w<d.length;w++){let{file:R,deployPath:O}=d[w];if(R.size===0)continue;let{md5:L}=await _(R);D.push({path:O,content:R,size:R.size,md5:L})}return D}if(!e)throw f.config("Platform limits not provided. processFilesForBrowser requires the limits argument for deploy-mode validation \u2014 pass `ship.getLimits()` result.");let h=[],g=0;for(let D=0;D<d.length;D++){let{file:w,deployPath:R}=d[D];if($e(R,w.name),w.size===0)continue;if(Ue(R,w.name),w.size>e.maxFileSize)throw f.business(`File ${w.name} is too large. Maximum allowed size is ${e.maxFileSize/(1024*1024)}MB.`);if(g+=w.size,g>e.maxTotalSize)throw f.business(`Total deploy size is too large. Maximum allowed is ${e.maxTotalSize/(1024*1024)}MB.`);let{md5:O}=await _(w);h.push({path:R,content:w,size:w.size,md5:O})}if(h.length>e.maxFilesCount)throw f.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return h}var ae=x(()=>{"use strict";b();Z();te();se();k();oe()});b();b();b();var z=class{constructor(){this.handlers=new Map}on(i,e){this.handlers.has(i)||this.handlers.set(i,new Set),this.handlers.get(i)?.add(e)}off(i,e){let a=this.handlers.get(i);a&&(a.delete(e),a.size===0&&this.handlers.delete(i))}emit(i,...e){let a=this.handlers.get(i);if(!a)return;let p=Array.from(a);for(let c of p)try{c(...e)}catch(m){a.delete(c),i!=="error"&&setTimeout(()=>{let y=m instanceof Error?m:new Error(String(m));this.emit("error",y,String(i))},0)}}};b();b();function C(n){if(n==null)return;if(n.length===0)return n;if(n.length>F.MAX_COUNT)throw f.validation(`Maximum ${F.MAX_COUNT} labels allowed`);let i=n.map((a,p)=>{if(typeof a!="string")throw f.validation(`Label at index ${p} must be a string`);let c=a.trim().toLowerCase();if(c.length<F.MIN_LENGTH)throw f.validation(`Labels must be at least ${F.MIN_LENGTH} characters long`);if(c.length>F.MAX_LENGTH)throw f.validation(`Labels must be no more than ${F.MAX_LENGTH} characters long`);if(!Ae.test(c))throw f.validation(`Labels must start and end with alphanumeric characters, with optional separators (${F.SEPARATORS}) between segments`);return c}),e=[...new Set(i)];if(e.length!==i.length)throw f.validation("Duplicate labels are not allowed");return e}var S={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",LIMITS:"/limits",PING:"/ping",SPA_CHECK:"/spa-check"},it=3e4,G=class extends z{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||W,this.getAuthHeadersCallback=e.getAuthHeaders,this.session=e.session??!1,this.caller=e.caller,this.timeout=e.timeout??it,this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||S.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,a,p){let c=()=>{};try{let m=await this.mergeHeaders(a.headers),y=this.createTimeoutSignal(a.signal);c=y.cleanup;let d={...a,headers:m,credentials:this.session&&!m.Authorization?"include":void 0,signal:y.signal};this.emit("request",e,d);let h=await this.fetch(e,d);if(c(),!h.ok)throw await f.fromHttpResponse(h,p);return this.emit("response",this.safeClone(h),e),{data:await this.parseResponse(this.safeClone(h)),status:h.status}}catch(m){c();let y=f.fromFetchError(m,p);throw this.emit("error",y,e),y}}async request(e,a,p){let{data:c}=await this.executeRequest(e,a,p);return c}async requestWithStatus(e,a,p){return this.executeRequest(e,a,p)}async mergeHeaders(e={}){return{...this.globalHeaders,...this.caller?{"X-Caller":this.caller}:{},...await this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e){let a=new AbortController,p=setTimeout(()=>a.abort(),this.timeout);if(e){let c=()=>a.abort();e.addEventListener("abort",c),e.aborted&&a.abort()}return{signal:a.signal,cleanup:()=>clearTimeout(p)}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async deploy(e,a={}){if(!e.length)throw f.business("No files to deploy");for(let d of e)if(!d.md5)throw f.file(`MD5 checksum missing for file: ${d.path}`,{filePath:d.path});J(a.password);let p=C(a.labels),c=a.build||a.prerender||a.spa?{build:a.build,prerender:a.prerender,spa:a.spa}:void 0,{body:m,headers:y}=await this.createDeployBody(e,{labels:p,via:a.via,password:a.password,flags:c,captcha:a.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:m,headers:y,signal:a.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${S.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,a){let p=C(a);return this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:p})},"Update deployment labels")}async removeDeployment(e){await this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,a,p){let c=C(p),m={};a&&(m.deployment=a),c!==void 0&&(m.labels=c);let{data:y,status:d}=await this.requestWithStatus(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)},"Set domain");return{...y,isCreate:d===201}}async listDomains(){return this.request(`${this.apiUrl}${S.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"GET"},"Get domain")}async removeDomain(e){await this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,a){let p=C(a),c={};return e!==void 0&&(c.ttl=e),p!==void 0&&(c.labels=p),this.request(`${this.apiUrl}${S.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${S.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(e){await this.request(`${this.apiUrl}${S.TOKENS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove token")}async getAccount(){return this.request(`${this.apiUrl}${S.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${S.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return(await this.request(`${this.apiUrl}${S.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,a={}){let p=e.find(d=>d.path==="index.html"||d.path==="/index.html");if(!p||p.size>100*1024)return!1;let c;if(typeof Buffer<"u"&&Buffer.isBuffer(p.content))c=p.content.toString("utf-8");else if(typeof Blob<"u"&&p.content instanceof Blob)c=await p.content.text();else if(typeof File<"u"&&p.content instanceof File)c=await p.content.text();else return!1;let m={files:e.map(d=>d.path),index:c};return(await this.request(`${this.apiUrl}${S.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)},"SPA check")).isSPA}};b();function De(n,i){let e={...n};return e.timeout===void 0&&i.timeout!==void 0&&(e.timeout=i.timeout),e.maxConcurrency===void 0&&i.maxConcurrency!==void 0&&(e.maxConcurrency=i.maxConcurrency),e.onProgress===void 0&&i.onProgress!==void 0&&(e.onProgress=i.onProgress),e}b();k();async function lt(){let n=JSON.stringify(me,null,2),i;typeof Buffer<"u"?i=Buffer.from(n,"utf-8"):i=new Blob([n],{type:"application/json"});let{md5:e}=await _(i);return{path:X,content:i,size:n.length,md5:e}}async function we(n,i,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||n.some(a=>a.path===X))return n;try{if(await i.checkSPA(n,e)){let p=await lt();return[...n,p]}}catch{}return n}function ve(n){let{getApi:i,ensureInit:e,processInput:a,clientDefaults:p}=n;return{upload:async(c,m={})=>{await e();let y=p?De(m,p):m;if(!a)throw f.config("processInput function is not provided.");let d=i(),h=await a(c,y);return h=await we(h,d,y),d.deploy(h,y)},list:async()=>(await e(),i().listDeployments()),get:async c=>(await e(),i().getDeployment(c)),set:async(c,m)=>(await e(),i().updateDeploymentLabels(c,m.labels)),remove:async c=>{await e(),await i().removeDeployment(c)}}}function Re(n){let{getApi:i,ensureInit:e}=n;return{set:async(a,p={})=>(await e(),i().setDomain(a,p.deployment,p.labels)),list:async()=>(await e(),i().listDomains()),get:async a=>(await e(),i().getDomain(a)),remove:async a=>{await e(),await i().removeDomain(a)},verify:async a=>(await e(),i().verifyDomain(a)),validate:async a=>(await e(),i().validateDomain(a)),dns:async a=>(await e(),i().getDomainDns(a)),records:async a=>(await e(),i().getDomainRecords(a)),share:async a=>(await e(),i().getDomainShare(a))}}function xe(n){let{getApi:i,ensureInit:e}=n;return{get:async()=>(await e(),i().getAccount())}}function Ie(n){let{getApi:i,ensureInit:e}=n;return{create:async(a={})=>(await e(),i().createToken(a.ttl,a.labels)),list:async()=>(await e(),i().listTokens()),remove:async a=>{await e(),await i().removeToken(a)}}}var q=class{constructor(i={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(i={...i,apiUrl:i.apiUrl||void 0,token:i.token||void 0,caller:i.caller||void 0},this.clientOptions=i,i.caller!==void 0&&ge(i.caller),i.token&&i.session)throw f.config("Provide either `token` or `session`, not both.");typeof i.token=="string"?(Y(i.token),this.credential=i.token):i.token&&(this.credential=i.token),this.http=new G({...i,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=ve({...e,processInput:(a,p)=>this.processInput(a,p),clientDefaults:this.clientOptions}),this.domains=Re(e),this.account=xe(e),this.tokens=Ie(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(i){throw this.initPromise=null,i}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(i,e){return this.deployments.upload(i,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(i,e){this.http.on(i,e)}off(i,e){this.http.off(i,e)}setHeaders(i){this.http.setGlobalHeaders(i)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(i){if(this.clientOptions.session)throw f.config("Provide either `token` or `session`, not both.");if(typeof i=="string"){if(!i)throw f.business("Invalid token provided. Token must be a non-empty string.");Y(i),this.credential=i;return}if(typeof i!="function")throw f.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=i}async getAuthHeaders(){if(this.credential===null)return{};let i=typeof this.credential=="function"?await this.credential():this.credential;if(!i)throw f.authentication("Token provider returned no token.");if(typeof i!="string")throw f.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${i}`}}};b();async function Pe(n,i={}){let{labels:e,via:a,password:p,flags:c,captcha:m}=i,y=new FormData,d=[];for(let h of n){if(!(h.content instanceof File||h.content instanceof Blob))throw f.file(`Unsupported file.content type for browser: ${h.path}`,{filePath:h.path});if(!h.md5)throw f.file(`File missing md5 checksum: ${h.path}`,{filePath:h.path});let g=new File([h.content],h.path,{type:"application/octet-stream"});y.append("files[]",g),d.push(h.md5)}return y.append("checksums",JSON.stringify(d)),e&&e.length>0&&y.append("labels",JSON.stringify(e)),a&&y.append("via",a),p&&y.append("password",p),c?.build&&y.append("build","true"),c?.prerender&&y.append("prerender","true"),c?.spa&&y.append("spa","true"),m&&y.append("captcha",m),{body:y,headers:{}}}b();b();Z();te();ie();se();k();oe();function An(n,i,e,a=!0){let p=n===1?i:e;return a?`${n} ${p}`:p}ae();var le=class extends q{async deploy(i,e){return super.deploy(i,e)}async processInput(i,e){if(!Array.isArray(i)||!i.every(p=>p instanceof File))throw f.business("Invalid input type for browser environment. Expected File[].");if(i.length===0)throw f.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(ae(),Me));return a(i,e,this.platformLimits??void 0)}getDeployBodyCreator(){return Pe}},qn=le;export{fe as API_KEY,Et as AccountPlan,G as ApiHttp,ue as AuthMethod,Qe as BLOCKED_EXTENSIONS,K as CALLER,W as DEFAULT_API,X as DEPLOYMENT_CONFIG_FILENAME,he as DEPLOY_TOKEN,yt as DeploymentStatus,gt as DomainStatus,E as ErrorType,T as FILE_VALIDATION_STATUS,T as FileValidationStatus,ht as JUNK_DIRECTORIES,F as LABEL_CONSTRAINTS,Ae as LABEL_PATTERN,At as OAuthScope,B as PASSWORD_CONSTRAINTS,me as SPA_DEFAULT_CONFIG,le as Ship,f as ShipError,N as TokenKind,et as UNBUILT_PROJECT_MARKERS,Ze as UNSAFE_FILENAME_CHARS,on as __setTestEnvironment,un as allValidFilesReady,_ as calculateMD5,tt as classifyToken,xe as createAccountResource,ve as createDeploymentResource,Re as createDomainResource,Ie as createTokenResource,qn as default,xt as deserializeLabels,bt as extractSubdomain,_e as filterJunk,ne as formatFileSize,wt as generateDeploymentUrl,vt as generateDomainUrl,Ne as getENV,ct as getValidFiles,H as hasUnbuiltMarker,de as hasUnsafeChars,M as isBlockedExtension,Tt as isCustomDomain,St as isDeployment,Ee as isPlatformDomain,ce as isShipError,De as mergeDeployOptions,Le as optimizeDeployPaths,An as pluralize,Be as processFilesForBrowser,Rt as serializeLabels,nt as validateApiKey,Dt as validateApiUrl,ge as validateCaller,Ue as validateDeployFile,$e as validateDeployPath,rt as validateDeployToken,re as validateFileName,pn as validateFiles,J as validatePassword,Y as validateToken};
1
+ var qe=Object.create;var $=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Ke=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Ye=(n,i,e)=>i in n?$(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var x=(n,i)=>()=>(n&&(i=n(n=0)),i);var de=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports),We=(n,i)=>{for(var e in i)$(n,e,{get:i[e],enumerable:!0})},Je=(n,i,e,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let p of je(i))!Xe.call(n,p)&&p!==e&&$(n,p,{get:()=>i[p],enumerable:!(a=Ve(i,p))||a.enumerable});return n};var U=(n,i,e)=>(e=n!=null?qe(Ke(n)):{},Je(i||!n||!n.__esModule?$(e,"default",{value:n,enumerable:!0}):e,n));var B=(n,i,e)=>Ye(n,typeof i!="symbol"?i+"":i,e);function he(n){return n!==null&&typeof n=="object"&&"name"in n&&n.name==="ShipError"&&"status"in n}function H(n){let i=n.lastIndexOf(".");if(i===-1||i===n.length-1)return!1;let e=n.slice(i+1).toLowerCase();return et.has(e)}function me(n){return tt.test(n)}function z(n){return n.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>nt.has(e))}function rt(n){return n.startsWith(ye.PREFIX)?N.API_KEY:n.startsWith(ge.PREFIX)?N.DEPLOY_TOKEN:N.OPAQUE}function Ee(n,i,e){if(!n.startsWith(i.PREFIX))throw f.validation(`${e} must start with "${i.PREFIX}"`);if(n.length!==i.TOTAL_LENGTH)throw f.validation(`${e} must be ${i.TOTAL_LENGTH} characters total (${i.PREFIX} + ${i.HEX_LENGTH} hex chars)`);let a=n.slice(i.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${i.HEX_LENGTH}}$`,"i").test(a))throw f.validation(`${e} must contain ${i.HEX_LENGTH} hexadecimal characters after "${i.PREFIX}" prefix`)}function it(n){Ee(n,ye,"API key")}function st(n){Ee(n,ge,"Deploy token")}function J(n){switch(rt(n)){case N.API_KEY:it(n);return;case N.DEPLOY_TOKEN:st(n);return;case N.OPAQUE:if(!n)throw f.validation("Token must be a non-empty string")}}function De(n){if(!n||n.length>Y.MAX_LENGTH||!Y.PATTERN.test(n))throw f.validation(`Caller must be 1-${Y.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function bt(n){try{let i=new URL(n);if(!["http:","https:"].includes(i.protocol))throw f.validation("API URL must use http:// or https:// protocol");if(i.pathname!=="/"&&i.pathname!=="")throw f.validation("API URL must not contain a path");if(i.search||i.hash)throw f.validation("API URL must not contain query parameters or fragments")}catch(i){throw he(i)?i:f.validation("API URL must be a valid URL")}}function wt(n){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(n)}function Se(n,i){return n.endsWith(`.${i}`)}function Rt(n,i){return!Se(n,i)}function vt(n,i){return Se(n,i)?n.slice(0,-(i.length+1)):null}function xt(n){return`https://${n}`}function It(n){return`https://${n}`}function Pt(n){return!n||n.length===0?null:JSON.stringify(n)}function Ft(n){if(!n)return[];try{let i=JSON.parse(n);return Array.isArray(i)?i:[]}catch{return[]}}function Z(n){if(n==null)return;if(typeof n!="string")throw f.validation("Password must be a string");let i=n.trim();if(i.length<M.MIN_LENGTH||i.length>M.MAX_LENGTH)throw f.validation(`Password must be between ${M.MIN_LENGTH} and ${M.MAX_LENGTH} characters`);return i}var At,Et,Dt,E,Qe,X,Ze,f,et,tt,nt,St,fe,ye,ge,Y,N,Tt,W,Ae,Q,T,F,Te,M,b=x(()=>{"use strict";At={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},Et={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},Dt={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},E={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},Qe=new Set([E.Network,E.Cancelled,E.File,E.Config]),X={client:new Set([E.Business,E.Config,E.File,E.Forbidden,E.Validation]),network:new Set([E.Network]),auth:new Set([E.Authentication])},Ze=new Set(Object.values(E).filter(n=>!Qe.has(n))),f=class n extends Error{constructor(e,a,p,c){super(a);B(this,"type");B(this,"status");B(this,"details");this.type=e,this.status=p,this.details=c,this.name="ShipError"}toResponse(){let e=this.details,a=this.type===E.Authentication&&e?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:a}}static async fromHttpResponse(e,a){let p,c,h;try{if(e.headers.get("content-type")?.includes("application/json")){let g=await e.json();if(g&&typeof g=="object"){let A=g;typeof A.message=="string"?p=A.message:typeof A.error=="string"&&(p=A.error),c=A.details,typeof A.error=="string"&&Ze.has(A.error)&&(h=A.error)}}else{let g=await e.text();g&&(p=g)}}catch{}let m=e.headers.get("retry-after");if(m!==null){let y=m.trim(),g=/^\d+$/.test(y)?Number(y):Math.ceil((Date.parse(y)-Date.now())/1e3);if(Number.isFinite(g)&&g>=0){let A=c&&typeof c=="object"?c:{};A.retryAfter===void 0&&(c={...A,retryAfter:g})}}p=p||`${a||"Request"} failed with status ${e.status}`;let d=h??(e.status===401?E.Authentication:e.status===403?E.Forbidden:e.status===429?E.RateLimit:E.Api);return new n(d,p,e.status,c)}static fromFetchError(e,a){if(he(e))return e;let p=a||"Request";return e instanceof Error?e.name==="AbortError"?n.cancelled(`${p} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?n.network(`${p} failed: ${e.message}`,{cause:e}):new n(E.Api,`${p} failed: ${e.message}`):new n(E.Api,`${p} failed: Unknown error`)}static validation(e,a){return new n(E.Validation,e,400,a)}static notFound(e,a){let p=a?`${e} ${a} not found`:`${e} not found`;return new n(E.NotFound,p,404)}static forbidden(e,a){return new n(E.Forbidden,e,403,a)}static rateLimit(e="Too many requests",a){return new n(E.RateLimit,e,429,a)}static authentication(e="Authentication required",a){return new n(E.Authentication,e,401,a)}static business(e,a=400,p){return new n(E.Business,e,a,p)}static network(e,a){return new n(E.Network,e,void 0,a)}static cancelled(e,a){return new n(E.Cancelled,e,void 0,a)}static file(e,a){return new n(E.File,e,void 0,a)}static config(e,a){return new n(E.Config,e,void 0,a)}static api(e,a=500,p){return new n(E.Api,e,a,p)}isClientError(){return X.client.has(this.type)}isNetworkError(){return X.network.has(this.type)}isAuthError(){return X.auth.has(this.type)}isType(e){return this.type===e}};et=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);tt=/[\x00-\x1f\x7f#?%\\<>"]/;nt=new Set(["node_modules","package.json"]);St="/auth",fe={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},ye={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},ge={PREFIX:"deploy-",HEX_LENGTH:64,TOTAL_LENGTH:71},Y={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},N={API_KEY:fe.API_KEY,DEPLOY_TOKEN:fe.TOKEN,OPAQUE:"opaque"};Tt={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},W="ship.json",Ae={rewrites:[{source:"/(.*)",destination:"/index.html"}]};Q="https://api.shipstatic.com",T={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};F={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Te=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;M={MIN_LENGTH:6,MAX_LENGTH:128}});var ve=de((we,Re)=>{"use strict";(function(n){if(typeof we=="object")Re.exports=n();else if(typeof define=="function"&&define.amd)define(n);else{var i;try{i=window}catch{i=self}i.SparkMD5=n()}})(function(n){"use strict";var i=function(u,l){return u+l&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(u,l,r,t,o,s){return l=i(i(l,u),i(t,s)),i(l<<o|l>>>32-o,r)}function p(u,l){var r=u[0],t=u[1],o=u[2],s=u[3];r+=(t&o|~t&s)+l[0]-680876936|0,r=(r<<7|r>>>25)+t|0,s+=(r&t|~r&o)+l[1]-389564586|0,s=(s<<12|s>>>20)+r|0,o+=(s&r|~s&t)+l[2]+606105819|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&r)+l[3]-1044525330|0,t=(t<<22|t>>>10)+o|0,r+=(t&o|~t&s)+l[4]-176418897|0,r=(r<<7|r>>>25)+t|0,s+=(r&t|~r&o)+l[5]+1200080426|0,s=(s<<12|s>>>20)+r|0,o+=(s&r|~s&t)+l[6]-1473231341|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&r)+l[7]-45705983|0,t=(t<<22|t>>>10)+o|0,r+=(t&o|~t&s)+l[8]+1770035416|0,r=(r<<7|r>>>25)+t|0,s+=(r&t|~r&o)+l[9]-1958414417|0,s=(s<<12|s>>>20)+r|0,o+=(s&r|~s&t)+l[10]-42063|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&r)+l[11]-1990404162|0,t=(t<<22|t>>>10)+o|0,r+=(t&o|~t&s)+l[12]+1804603682|0,r=(r<<7|r>>>25)+t|0,s+=(r&t|~r&o)+l[13]-40341101|0,s=(s<<12|s>>>20)+r|0,o+=(s&r|~s&t)+l[14]-1502002290|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&r)+l[15]+1236535329|0,t=(t<<22|t>>>10)+o|0,r+=(t&s|o&~s)+l[1]-165796510|0,r=(r<<5|r>>>27)+t|0,s+=(r&o|t&~o)+l[6]-1069501632|0,s=(s<<9|s>>>23)+r|0,o+=(s&t|r&~t)+l[11]+643717713|0,o=(o<<14|o>>>18)+s|0,t+=(o&r|s&~r)+l[0]-373897302|0,t=(t<<20|t>>>12)+o|0,r+=(t&s|o&~s)+l[5]-701558691|0,r=(r<<5|r>>>27)+t|0,s+=(r&o|t&~o)+l[10]+38016083|0,s=(s<<9|s>>>23)+r|0,o+=(s&t|r&~t)+l[15]-660478335|0,o=(o<<14|o>>>18)+s|0,t+=(o&r|s&~r)+l[4]-405537848|0,t=(t<<20|t>>>12)+o|0,r+=(t&s|o&~s)+l[9]+568446438|0,r=(r<<5|r>>>27)+t|0,s+=(r&o|t&~o)+l[14]-1019803690|0,s=(s<<9|s>>>23)+r|0,o+=(s&t|r&~t)+l[3]-187363961|0,o=(o<<14|o>>>18)+s|0,t+=(o&r|s&~r)+l[8]+1163531501|0,t=(t<<20|t>>>12)+o|0,r+=(t&s|o&~s)+l[13]-1444681467|0,r=(r<<5|r>>>27)+t|0,s+=(r&o|t&~o)+l[2]-51403784|0,s=(s<<9|s>>>23)+r|0,o+=(s&t|r&~t)+l[7]+1735328473|0,o=(o<<14|o>>>18)+s|0,t+=(o&r|s&~r)+l[12]-1926607734|0,t=(t<<20|t>>>12)+o|0,r+=(t^o^s)+l[5]-378558|0,r=(r<<4|r>>>28)+t|0,s+=(r^t^o)+l[8]-2022574463|0,s=(s<<11|s>>>21)+r|0,o+=(s^r^t)+l[11]+1839030562|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^r)+l[14]-35309556|0,t=(t<<23|t>>>9)+o|0,r+=(t^o^s)+l[1]-1530992060|0,r=(r<<4|r>>>28)+t|0,s+=(r^t^o)+l[4]+1272893353|0,s=(s<<11|s>>>21)+r|0,o+=(s^r^t)+l[7]-155497632|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^r)+l[10]-1094730640|0,t=(t<<23|t>>>9)+o|0,r+=(t^o^s)+l[13]+681279174|0,r=(r<<4|r>>>28)+t|0,s+=(r^t^o)+l[0]-358537222|0,s=(s<<11|s>>>21)+r|0,o+=(s^r^t)+l[3]-722521979|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^r)+l[6]+76029189|0,t=(t<<23|t>>>9)+o|0,r+=(t^o^s)+l[9]-640364487|0,r=(r<<4|r>>>28)+t|0,s+=(r^t^o)+l[12]-421815835|0,s=(s<<11|s>>>21)+r|0,o+=(s^r^t)+l[15]+530742520|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^r)+l[2]-995338651|0,t=(t<<23|t>>>9)+o|0,r+=(o^(t|~s))+l[0]-198630844|0,r=(r<<6|r>>>26)+t|0,s+=(t^(r|~o))+l[7]+1126891415|0,s=(s<<10|s>>>22)+r|0,o+=(r^(s|~t))+l[14]-1416354905|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~r))+l[5]-57434055|0,t=(t<<21|t>>>11)+o|0,r+=(o^(t|~s))+l[12]+1700485571|0,r=(r<<6|r>>>26)+t|0,s+=(t^(r|~o))+l[3]-1894986606|0,s=(s<<10|s>>>22)+r|0,o+=(r^(s|~t))+l[10]-1051523|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~r))+l[1]-2054922799|0,t=(t<<21|t>>>11)+o|0,r+=(o^(t|~s))+l[8]+1873313359|0,r=(r<<6|r>>>26)+t|0,s+=(t^(r|~o))+l[15]-30611744|0,s=(s<<10|s>>>22)+r|0,o+=(r^(s|~t))+l[6]-1560198380|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~r))+l[13]+1309151649|0,t=(t<<21|t>>>11)+o|0,r+=(o^(t|~s))+l[4]-145523070|0,r=(r<<6|r>>>26)+t|0,s+=(t^(r|~o))+l[11]-1120210379|0,s=(s<<10|s>>>22)+r|0,o+=(r^(s|~t))+l[2]+718787259|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~r))+l[9]-343485551|0,t=(t<<21|t>>>11)+o|0,u[0]=r+u[0]|0,u[1]=t+u[1]|0,u[2]=o+u[2]|0,u[3]=s+u[3]|0}function c(u){var l=[],r;for(r=0;r<64;r+=4)l[r>>2]=u.charCodeAt(r)+(u.charCodeAt(r+1)<<8)+(u.charCodeAt(r+2)<<16)+(u.charCodeAt(r+3)<<24);return l}function h(u){var l=[],r;for(r=0;r<64;r+=4)l[r>>2]=u[r]+(u[r+1]<<8)+(u[r+2]<<16)+(u[r+3]<<24);return l}function m(u){var l=u.length,r=[1732584193,-271733879,-1732584194,271733878],t,o,s,R,I,P;for(t=64;t<=l;t+=64)p(r,c(u.substring(t-64,t)));for(u=u.substring(t-64),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)s[t>>2]|=u.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(p(r,s),t=0;t<16;t+=1)s[t]=0;return R=l*8,R=R.toString(16).match(/(.*?)(.{0,8})$/),I=parseInt(R[2],16),P=parseInt(R[1],16)||0,s[14]=I,s[15]=P,p(r,s),r}function d(u){var l=u.length,r=[1732584193,-271733879,-1732584194,271733878],t,o,s,R,I,P;for(t=64;t<=l;t+=64)p(r,h(u.subarray(t-64,t)));for(u=t-64<l?u.subarray(t-64):new Uint8Array(0),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)s[t>>2]|=u[t]<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(p(r,s),t=0;t<16;t+=1)s[t]=0;return R=l*8,R=R.toString(16).match(/(.*?)(.{0,8})$/),I=parseInt(R[2],16),P=parseInt(R[1],16)||0,s[14]=I,s[15]=P,p(r,s),r}function y(u){var l="",r;for(r=0;r<4;r+=1)l+=e[u>>r*8+4&15]+e[u>>r*8&15];return l}function g(u){var l;for(l=0;l<u.length;l+=1)u[l]=y(u[l]);return u.join("")}g(m("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(i=function(u,l){var r=(u&65535)+(l&65535),t=(u>>16)+(l>>16)+(r>>16);return t<<16|r&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(l,r){return l=l|0||0,l<0?Math.max(l+r,0):Math.min(l,r)}ArrayBuffer.prototype.slice=function(l,r){var t=this.byteLength,o=u(l,t),s=t,R,I,P,ce;return r!==n&&(s=u(r,t)),o>s?new ArrayBuffer(0):(R=s-o,I=new ArrayBuffer(R),P=new Uint8Array(I),ce=new Uint8Array(this,o,R),P.set(ce),I)}})();function A(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function w(u,l){var r=u.length,t=new ArrayBuffer(r),o=new Uint8Array(t),s;for(s=0;s<r;s+=1)o[s]=u.charCodeAt(s);return l?o:t}function v(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function O(u,l,r){var t=new Uint8Array(u.byteLength+l.byteLength);return t.set(new Uint8Array(u)),t.set(new Uint8Array(l),u.byteLength),r?t:t.buffer}function L(u){var l=[],r=u.length,t;for(t=0;t<r-1;t+=2)l.push(parseInt(u.substr(t,2),16));return String.fromCharCode.apply(String,l)}function D(){this.reset()}return D.prototype.append=function(u){return this.appendBinary(A(u)),this},D.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var l=this._buff.length,r;for(r=64;r<=l;r+=64)p(this._hash,c(this._buff.substring(r-64,r)));return this._buff=this._buff.substring(r-64),this},D.prototype.end=function(u){var l=this._buff,r=l.length,t,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(t=0;t<r;t+=1)o[t>>2]|=l.charCodeAt(t)<<(t%4<<3);return this._finish(o,r),s=g(this._hash),u&&(s=L(s)),this.reset(),s},D.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},D.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},D.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},D.prototype._finish=function(u,l){var r=l,t,o,s;if(u[r>>2]|=128<<(r%4<<3),r>55)for(p(this._hash,u),r=0;r<16;r+=1)u[r]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(t[2],16),s=parseInt(t[1],16)||0,u[14]=o,u[15]=s,p(this._hash,u)},D.hash=function(u,l){return D.hashBinary(A(u),l)},D.hashBinary=function(u,l){var r=m(u),t=g(r);return l?L(t):t},D.ArrayBuffer=function(){this.reset()},D.ArrayBuffer.prototype.append=function(u){var l=O(this._buff.buffer,u,!0),r=l.length,t;for(this._length+=u.byteLength,t=64;t<=r;t+=64)p(this._hash,h(l.subarray(t-64,t)));return this._buff=t-64<r?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},D.ArrayBuffer.prototype.end=function(u){var l=this._buff,r=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,s;for(o=0;o<r;o+=1)t[o>>2]|=l[o]<<(o%4<<3);return this._finish(t,r),s=g(this._hash),u&&(s=L(s)),this.reset(),s},D.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.ArrayBuffer.prototype.getState=function(){var u=D.prototype.getState.call(this);return u.buff=v(u.buff),u},D.ArrayBuffer.prototype.setState=function(u){return u.buff=w(u.buff,!0),D.prototype.setState.call(this,u)},D.ArrayBuffer.prototype.destroy=D.prototype.destroy,D.ArrayBuffer.prototype._finish=D.prototype._finish,D.ArrayBuffer.hash=function(u,l){var r=d(new Uint8Array(u)),t=g(r);return l?L(t):t},D})});var q=de((zt,xe)=>{"use strict";xe.exports={}});async function at(n){let i=(await Promise.resolve().then(()=>U(ve(),1))).default,e=new i.ArrayBuffer,a=2097152;for(let p=0;p<n.size;p+=a){let c=Math.min(p+a,n.size);e.append(await n.slice(p,c).arrayBuffer())}return{md5:e.end()}}async function lt(n){let{createHash:i}=await Promise.resolve().then(()=>U(q(),1)),e=i("md5");return e.update(n),{md5:e.digest("hex")}}async function pt(n){let{createHash:i}=await Promise.resolve().then(()=>U(q(),1)),{createReadStream:e}=await Promise.resolve().then(()=>U(q(),1));return new Promise((a,p)=>{let c=i("md5"),h=e(n);h.on("error",m=>p(f.business(`Failed to read file for MD5: ${m.message}`))),h.on("data",m=>c.update(m)),h.on("end",()=>a({md5:c.digest("hex")}))})}async function _(n){if(n instanceof Blob)return at(n);if(typeof Buffer<"u"&&Buffer.isBuffer(n))return lt(n);if(typeof n=="string")return pt(n);throw f.business("Invalid input for MD5 calculation")}var V=x(()=>{"use strict";b()});function K(n){return n.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ce=x(()=>{"use strict"});function _e(n,i={}){if(i.flatten===!1)return n.map(a=>({path:K(a),name:ee(a)}));let e=ct(n);return n.map(a=>{let p=K(a);if(e){let c=e.endsWith("/")?e:`${e}/`;p.startsWith(c)&&(p=p.substring(c.length))}return p||(p=ee(a)),{path:p,name:ee(a)}})}function ct(n){if(!n.length)return"";let e=n.map(c=>K(c)).map(c=>c.split("/")),a=[],p=Math.min(...e.map(c=>c.length));for(let c=0;c<p-1;c++){let h=e[0][c];if(e.every(m=>m[c]===h))a.push(h);else break}return a.join("/")}function ee(n){return n.split(/[/\\]/).pop()||n}var te=x(()=>{"use strict";Ce()});function ln(n){ne=n}function dt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function $e(){return ne||dt()}var ne,re=x(()=>{"use strict";ne=null});function ie(n,i=1){if(n===0)return"0 Bytes";let e=1024,a=["Bytes","KB","MB","GB"],p=Math.floor(Math.log(n)/Math.log(e));return`${parseFloat((n/e**p).toFixed(i))} ${a[p]}`}function se(n){if(me(n))return{valid:!1,reason:"File name contains unsafe characters"};if(n.startsWith(" ")||n.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(n.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let i=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=n.split("/").pop()||n;return i.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:n.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function cn(n,i){let e=[],a=[],p=[];if(n.length===0){let d={file:"(no files)",message:"At least one file must be provided"};return e.push(d),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let d of n)if(z(d.name))return e.push({file:d.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:n.map(y=>({...y,status:T.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(n.length>i.maxFilesCount){let d={file:`(${n.length} files)`,message:`File count (${n.length}) exceeds limit of ${i.maxFilesCount}`};return e.push(d),{files:n.map(y=>({...y,status:T.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let d of n){let y=T.READY,g="Ready for upload",A=d.name?se(d.name):{valid:!1,reason:"File name cannot be empty"};if(d.status===T.PROCESSING_ERROR)y=T.VALIDATION_FAILED,g=d.statusMessage||"File failed during processing",e.push({file:d.name,message:g});else if(d.size===0){y=T.EXCLUDED,g="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:d.name,message:g}),p.push({...d,status:y,statusMessage:g});continue}else d.size<0?(y=T.VALIDATION_FAILED,g="File size must be positive",e.push({file:d.name,message:g})):!d.name||d.name.trim().length===0?(y=T.VALIDATION_FAILED,g="File name cannot be empty",e.push({file:d.name||"(empty)",message:g})):d.name.includes("\0")?(y=T.VALIDATION_FAILED,g="File name contains invalid characters (null byte)",e.push({file:d.name,message:g})):A.valid?H(d.name)?(y=T.VALIDATION_FAILED,g=`File extension not allowed: "${d.name}"`,e.push({file:d.name,message:g})):d.size>i.maxFileSize?(y=T.VALIDATION_FAILED,g=`File size (${ie(d.size)}) exceeds limit of ${ie(i.maxFileSize)}`,e.push({file:d.name,message:g})):(c+=d.size,c>i.maxTotalSize&&(y=T.VALIDATION_FAILED,g=`Total size would exceed limit of ${ie(i.maxTotalSize)}`,e.push({file:d.name,message:g}))):(y=T.VALIDATION_FAILED,g=A.reason||"Invalid file name",e.push({file:d.name,message:g}));p.push({...d,status:y,statusMessage:g})}e.length>0&&(p=p.map(d=>d.status===T.EXCLUDED?d:{...d,status:T.VALIDATION_FAILED,statusMessage:d.status===T.VALIDATION_FAILED?d.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=e.length===0?p.filter(d=>d.status===T.READY):[],m=e.length===0;return{files:p,validFiles:h,errors:e,warnings:a,canDeploy:m}}function ft(n){return n.filter(i=>i.status===T.READY)}function dn(n){return ft(n).length>0}var oe=x(()=>{"use strict";b()});function Ue(n){return mt.test(n)}var ht,mt,Be=x(()=>{"use strict";ht=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],mt=new RegExp(ht.join("|"))});function Me(n,i){if(!n||n.length===0)return[];if(!i?.allowUnbuilt&&n.find(a=>a&&z(a)))throw f.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return n.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let p=a[a.length-1];if(Ue(p))return!1;for(let h of a)if(h!==".well-known"&&(h.startsWith(".")||h.length>255))return!1;let c=a.slice(0,-1);for(let h of c)if(yt.some(m=>h.toLowerCase()===m.toLowerCase()))return!1;return!0})}var yt,ae=x(()=>{"use strict";b();Be();yt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function He(n,i){if(n.includes("\0")||n.includes("/../")||n.startsWith("../")||n.endsWith("/.."))throw f.business(`Security error: Unsafe file path "${n}" for file: ${i}`)}function ze(n,i){let e=se(n);if(!e.valid)throw f.business(e.reason||"Invalid file name");if(H(n))throw f.business(`File extension not allowed: "${i}"`)}var le=x(()=>{"use strict";b();oe()});var ke={};We(ke,{processFilesForBrowser:()=>Ge});async function Ge(n,i={},e){if($e()!=="browser")throw f.business("processFilesForBrowser can only be called in a browser environment.");let a=n.map(A=>A.webkitRelativePath||A.name),p=i.build||i.prerender,c=_e(a,{flatten:i.pathDetect!==!1}),h=c.map(A=>A.path),m=new Set(Me(h,{allowUnbuilt:p})),d=[];for(let A=0;A<n.length;A++)m.has(h[A])&&d.push({file:n[A],deployPath:c[A].path});if(d.length===0)return[];if(p){let A=[];for(let w=0;w<d.length;w++){let{file:v,deployPath:O}=d[w];if(v.size===0)continue;let{md5:L}=await _(v);A.push({path:O,content:v,size:v.size,md5:L})}return A}if(!e)throw f.config("Platform limits not provided. processFilesForBrowser requires the limits argument for deploy-mode validation \u2014 pass `ship.getLimits()` result.");let y=[],g=0;for(let A=0;A<d.length;A++){let{file:w,deployPath:v}=d[A];if(He(v,w.name),w.size===0)continue;if(ze(v,w.name),w.size>e.maxFileSize)throw f.business(`File ${w.name} is too large. Maximum allowed size is ${e.maxFileSize/(1024*1024)}MB.`);if(g+=w.size,g>e.maxTotalSize)throw f.business(`Total deploy size is too large. Maximum allowed is ${e.maxTotalSize/(1024*1024)}MB.`);let{md5:O}=await _(w);y.push({path:v,content:w,size:w.size,md5:O})}if(y.length>e.maxFilesCount)throw f.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return y}var pe=x(()=>{"use strict";b();te();re();ae();V();le()});b();b();b();var G=class{constructor(){this.handlers=new Map}on(i,e){this.handlers.has(i)||this.handlers.set(i,new Set),this.handlers.get(i)?.add(e)}off(i,e){let a=this.handlers.get(i);a&&(a.delete(e),a.size===0&&this.handlers.delete(i))}emit(i,...e){let a=this.handlers.get(i);if(!a)return;let p=Array.from(a);for(let c of p)try{c(...e)}catch(h){a.delete(c),i!=="error"&&setTimeout(()=>{let m=h instanceof Error?h:new Error(String(h));this.emit("error",m,String(i))},0)}}};b();b();function C(n){if(n==null)return;if(n.length===0)return n;if(n.length>F.MAX_COUNT)throw f.validation(`Maximum ${F.MAX_COUNT} labels allowed`);let i=n.map((a,p)=>{if(typeof a!="string")throw f.validation(`Label at index ${p} must be a string`);let c=a.trim().toLowerCase();if(c.length<F.MIN_LENGTH)throw f.validation(`Labels must be at least ${F.MIN_LENGTH} characters long`);if(c.length>F.MAX_LENGTH)throw f.validation(`Labels must be no more than ${F.MAX_LENGTH} characters long`);if(!Te.test(c))throw f.validation(`Labels must start and end with alphanumeric characters, with optional separators (${F.SEPARATORS}) between segments`);return c}),e=[...new Set(i)];if(e.length!==i.length)throw f.validation("Duplicate labels are not allowed");return e}var S={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",LIMITS:"/limits",PING:"/ping",SPA_CHECK:"/spa-check"},ot=3e4;function be(n){let i=new URLSearchParams;n?.limit!==void 0&&i.set("limit",String(n.limit)),n?.cursor!==void 0&&i.set("cursor",n.cursor);let e=i.toString();return e?`?${e}`:""}var k=class extends G{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||Q,this.getAuthHeadersCallback=e.getAuthHeaders,this.session=e.session??!1,this.caller=e.caller,this.timeout=e.timeout??ot,this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||S.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,a,p){let c=()=>{};try{let h=await this.mergeHeaders(a.headers),m=this.createTimeoutSignal(a.signal);c=m.cleanup;let d={...a,headers:h,credentials:this.session&&!h.Authorization?"include":void 0,signal:m.signal};this.emit("request",e,d);let y=await this.fetch(e,d);if(c(),!y.ok)throw await f.fromHttpResponse(y,p);return this.emit("response",this.safeClone(y),e),{data:await this.parseResponse(this.safeClone(y)),status:y.status}}catch(h){c();let m=f.fromFetchError(h,p);throw this.emit("error",m,e),m}}async request(e,a,p){let{data:c}=await this.executeRequest(e,a,p);return c}async requestWithStatus(e,a,p){return this.executeRequest(e,a,p)}async mergeHeaders(e={}){return{...this.globalHeaders,...this.caller?{"X-Caller":this.caller}:{},...await this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e){let a=new AbortController,p=setTimeout(()=>a.abort(),this.timeout);if(e){let c=()=>a.abort();e.addEventListener("abort",c),e.aborted&&a.abort()}return{signal:a.signal,cleanup:()=>clearTimeout(p)}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async deploy(e,a={}){if(!e.length)throw f.business("No files to deploy");for(let d of e)if(!d.md5)throw f.file(`MD5 checksum missing for file: ${d.path}`,{filePath:d.path});Z(a.password);let p=C(a.labels),c=a.build||a.prerender||a.spa?{build:a.build,prerender:a.prerender,spa:a.spa}:void 0,{body:h,headers:m}=await this.createDeployBody(e,{labels:p,via:a.via,password:a.password,flags:c,captcha:a.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:h,headers:m,signal:a.signal||null},"Deploy")}async listDeployments(e){return this.request(`${this.apiUrl}${S.DEPLOYMENTS}${be(e)}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,a){let p=C(a);return this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:p})},"Update deployment labels")}async removeDeployment(e){await this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,a,p){let c=C(p),h={};a&&(h.deployment=a),c!==void 0&&(h.labels=c);let{data:m,status:d}=await this.requestWithStatus(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)},"Set domain");return{...m,isCreate:d===201}}async listDomains(e){return this.request(`${this.apiUrl}${S.DOMAINS}${be(e)}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"GET"},"Get domain")}async removeDomain(e){await this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,a){let p=C(a),c={};return e!==void 0&&(c.ttl=e),p!==void 0&&(c.labels=p),this.request(`${this.apiUrl}${S.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${S.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(e){await this.request(`${this.apiUrl}${S.TOKENS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove token")}async getAccount(){return this.request(`${this.apiUrl}${S.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${S.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return(await this.request(`${this.apiUrl}${S.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,a={}){let p=e.find(d=>d.path==="index.html"||d.path==="/index.html");if(!p||p.size>100*1024)return!1;let c;if(typeof Buffer<"u"&&Buffer.isBuffer(p.content))c=p.content.toString("utf-8");else if(typeof Blob<"u"&&p.content instanceof Blob)c=await p.content.text();else if(typeof File<"u"&&p.content instanceof File)c=await p.content.text();else return!1;let h={files:e.map(d=>d.path),index:c};return(await this.request(`${this.apiUrl}${S.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)},"SPA check")).isSPA}};b();b();V();async function ut(){let n=JSON.stringify(Ae,null,2),i;typeof Buffer<"u"?i=Buffer.from(n,"utf-8"):i=new Blob([n],{type:"application/json"});let{md5:e}=await _(i);return{path:W,content:i,size:n.length,md5:e}}async function Ie(n,i,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||n.some(a=>a.path===W))return n;try{if(await i.checkSPA(n,e)){let p=await ut();return[...n,p]}}catch{}return n}function Pe(n){let{getApi:i,ensureInit:e,processInput:a}=n;return{upload:async(p,c={})=>{if(await e(),!a)throw f.config("processInput function is not provided.");let h=i(),m=await a(p,c);return m=await Ie(m,h,c),h.deploy(m,c)},list:async p=>(await e(),i().listDeployments(p)),get:async p=>(await e(),i().getDeployment(p)),set:async(p,c)=>(await e(),i().updateDeploymentLabels(p,c.labels)),remove:async p=>{await e(),await i().removeDeployment(p)}}}function Fe(n){let{getApi:i,ensureInit:e}=n;return{set:async(a,p={})=>(await e(),i().setDomain(a,p.deployment,p.labels)),list:async a=>(await e(),i().listDomains(a)),get:async a=>(await e(),i().getDomain(a)),remove:async a=>{await e(),await i().removeDomain(a)},verify:async a=>(await e(),i().verifyDomain(a)),validate:async a=>(await e(),i().validateDomain(a)),dns:async a=>(await e(),i().getDomainDns(a)),records:async a=>(await e(),i().getDomainRecords(a)),share:async a=>(await e(),i().getDomainShare(a))}}function Le(n){let{getApi:i,ensureInit:e}=n;return{get:async()=>(await e(),i().getAccount())}}function Ne(n){let{getApi:i,ensureInit:e}=n;return{create:async(a={})=>(await e(),i().createToken(a.ttl,a.labels)),list:async()=>(await e(),i().listTokens()),remove:async a=>{await e(),await i().removeToken(a)}}}var j=class{constructor(i={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(i={...i,apiUrl:i.apiUrl||void 0,token:i.token||void 0,caller:i.caller||void 0},this.clientOptions=i,i.caller!==void 0&&De(i.caller),i.token&&i.session)throw f.config("Provide either `token` or `session`, not both.");typeof i.token=="string"?(J(i.token),this.credential=i.token):i.token&&(this.credential=i.token),this.http=new k({...i,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=Pe({...e,processInput:(a,p)=>this.processInput(a,p)}),this.domains=Fe(e),this.account=Le(e),this.tokens=Ne(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(i){throw this.initPromise=null,i}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(i,e){return this.deployments.upload(i,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(i,e){this.http.on(i,e)}off(i,e){this.http.off(i,e)}setHeaders(i){this.http.setGlobalHeaders(i)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(i){if(this.clientOptions.session)throw f.config("Provide either `token` or `session`, not both.");if(typeof i=="string"){if(!i)throw f.business("Invalid token provided. Token must be a non-empty string.");J(i),this.credential=i;return}if(typeof i!="function")throw f.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=i}async getAuthHeaders(){if(this.credential===null)return{};let i=typeof this.credential=="function"?await this.credential():this.credential;if(!i)throw f.authentication("Token provider returned no token.");if(typeof i!="string")throw f.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${i}`}}};b();async function Oe(n,i={}){let{labels:e,via:a,password:p,flags:c,captcha:h}=i,m=new FormData,d=[];for(let y of n){if(!(y.content instanceof File||y.content instanceof Blob))throw f.file(`Unsupported file.content type for browser: ${y.path}`,{filePath:y.path});if(!y.md5)throw f.file(`File missing md5 checksum: ${y.path}`,{filePath:y.path});let g=new File([y.content],y.path,{type:"application/octet-stream"});m.append("files[]",g),d.push(y.md5)}return m.append("checksums",JSON.stringify(d)),e&&e.length>0&&m.append("labels",JSON.stringify(e)),a&&m.append("via",a),p&&m.append("password",p),c?.build&&m.append("build","true"),c?.prerender&&m.append("prerender","true"),c?.spa&&m.append("spa","true"),h&&m.append("captcha",h),{body:m,headers:{}}}b();b();te();re();oe();ae();V();le();function Sn(n,i,e,a=!0){let p=n===1?i:e;return a?`${n} ${p}`:p}pe();var ue=class extends j{async deploy(i,e){return super.deploy(i,e)}async processInput(i,e){if(!Array.isArray(i)||!i.every(p=>p instanceof File))throw f.business("Invalid input type for browser environment. Expected File[].");if(i.length===0)throw f.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(pe(),ke));return a(i,e,this.platformLimits??void 0)}getDeployBodyCreator(){return Oe}},Vn=ue;export{ye as API_KEY,St as AUTH_BASE_PATH,Dt as AccountPlan,k as ApiHttp,fe as AuthMethod,et as BLOCKED_EXTENSIONS,Y as CALLER,Q as DEFAULT_API,W as DEPLOYMENT_CONFIG_FILENAME,ge as DEPLOY_TOKEN,At as DeploymentStatus,Et as DomainStatus,E as ErrorType,T as FILE_VALIDATION_STATUS,T as FileValidationStatus,yt as JUNK_DIRECTORIES,F as LABEL_CONSTRAINTS,Te as LABEL_PATTERN,Tt as OAuthScope,M as PASSWORD_CONSTRAINTS,Ae as SPA_DEFAULT_CONFIG,ue as Ship,f as ShipError,N as TokenKind,nt as UNBUILT_PROJECT_MARKERS,tt as UNSAFE_FILENAME_CHARS,ln as __setTestEnvironment,dn as allValidFilesReady,_ as calculateMD5,rt as classifyToken,Le as createAccountResource,Pe as createDeploymentResource,Fe as createDomainResource,Ne as createTokenResource,Vn as default,Ft as deserializeLabels,vt as extractSubdomain,Me as filterJunk,ie as formatFileSize,xt as generateDeploymentUrl,It as generateDomainUrl,$e as getENV,ft as getValidFiles,z as hasUnbuiltMarker,me as hasUnsafeChars,H as isBlockedExtension,Rt as isCustomDomain,wt as isDeployment,Se as isPlatformDomain,he as isShipError,_e as optimizeDeployPaths,Sn as pluralize,Ge as processFilesForBrowser,Pt as serializeLabels,it as validateApiKey,bt as validateApiUrl,De as validateCaller,ze as validateDeployFile,He as validateDeployPath,st as validateDeployToken,se as validateFileName,cn as validateFiles,Z as validatePassword,J as validateToken};
2
2
  //# sourceMappingURL=browser.js.map