@shipstatic/ship 2.5.0-beta.1 → 2.6.0-beta.10

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.
@@ -5,7 +5,7 @@ Their copyright notices travel with that copy, and are reproduced here in
5
5
  full. This file is GENERATED from the build's own metafile — edit the
6
6
  bundle, not this list.
7
7
 
8
- ## @shipstatic/types 2.14.0-beta.1
8
+ ## @shipstatic/types 2.17.0-beta.9
9
9
 
10
10
  License: MIT
11
11
 
package/dist/browser.d.ts CHANGED
@@ -518,11 +518,15 @@ interface TokenDeleteResponse {
518
518
  * account keeps its tier through suspension and into deletion.
519
519
  *
520
520
  * - **Free** — `free`.
521
- * - **Billed** — `pro`. The one plan a customer can buy; the only plan Stripe
522
- * knows about, and the only one the platform never sets by hand — it is
523
- * derived from the Stripe subscription.
521
+ * - **Billed** — `pro`, `team`. The plans a customer buys; the only plans
522
+ * Stripe knows about, and the only ones the platform never sets by hand —
523
+ * each is derived from the Stripe Subscription, which names its plan on the
524
+ * Price it is on. They form a ladder: a dearer tier is a superset of the one
525
+ * below it, and the API says which is next in {@link Account.upgrade}.
524
526
  * - **Granted** — `scale`, `sponsored`. Paid plans the operator confers by
525
- * hand; no Stripe subscription, no Checkout, no Stripe object at all.
527
+ * hand; no Stripe subscription, no Checkout, no Stripe object at all. These
528
+ * and `free` are the only plans an operator can set; a billed plan is only
529
+ * ever Stripe's to confer.
526
530
  *
527
531
  * The numbers each plan confers — caps, sizes — are POLICY and are delivered
528
532
  * by the API (`GET /plans`, `GET /account`, `GET /limits`), never published
@@ -532,23 +536,31 @@ interface TokenDeleteResponse {
532
536
  declare const AccountPlan: {
533
537
  readonly FREE: "free";
534
538
  readonly PRO: "pro";
539
+ readonly TEAM: "team";
535
540
  readonly SCALE: "scale";
536
541
  readonly SPONSORED: "sponsored";
537
542
  };
538
543
  type AccountPlanType = (typeof AccountPlan)[keyof typeof AccountPlan];
539
544
  /**
540
- * The two things an account ACCUMULATES, and therefore the two things a plan
541
- * caps. One word for the count and for the ceiling: `Account.usage` and
545
+ * The three things an account ACCUMULATES, and therefore the three things a
546
+ * plan caps. One word for the count and for the ceiling: `Account.usage` and
542
547
  * `Account.caps` are the same shape, so a surface renders "2 of 3" by
543
548
  * dividing one by the other and can never divide by a different denominator
544
549
  * than the 403 uses.
545
550
  *
546
- * Both are counts paid plans SELL. A platform subdomain (`x.shipstatic.com`)
547
- * is not among them: the platform owns the name, it costs nothing, and no
548
- * plan bounds how many an account may hold.
551
+ * All three are counts plans SELL, and every plan publishes a number for each.
552
+ * A platform subdomain (`my-app.shipstatic.com`) is among them: the namespace
553
+ * is the platform's, so every plan bounds how many names one account may take
554
+ * from it — which is not the address every deployment gets by construction
555
+ * (`happy-cat-abc1234.shipstatic.com`), one per deployment and bounded by
556
+ * `deployments` already.
549
557
  *
550
558
  * Every cap carries a number on every plan — never `null`, never
551
- * "unlimited" — so no consumer needs an "is it bounded?" branch.
559
+ * "unlimited" — so no consumer needs an "is it bounded?" branch. A cap of `0`
560
+ * means the plan does not have the feature at all; a cap of `N` bounds
561
+ * creation, and what an account already holds above a cap stays until a plan
562
+ * TRANSITION fits it (excess paused, newest first — a domain is the only kind
563
+ * that pauses).
552
564
  *
553
565
  * A count is an aggregate over a collection, so it lives on the summary
554
566
  * resource that owns the collection: `GET /account` for one caller, `GET
@@ -562,6 +574,12 @@ interface Caps {
562
574
  * different question asked of a different resource.)
563
575
  */
564
576
  readonly deployments: number;
577
+ /**
578
+ * Names the customer chose under the platform's own suffix
579
+ * (`my-app.shipstatic.com`) — every row, paused ones included, by the same
580
+ * rule as custom domains.
581
+ */
582
+ readonly platformDomains: number;
565
583
  /**
566
584
  * Hostnames the customer owns — every row, paused ones included. A paused
567
585
  * domain still occupies its slot, so deleting one is what frees capacity.
@@ -620,6 +638,47 @@ interface Account {
620
638
  * mirrored on the account row for the operator surface.
621
639
  */
622
640
  readonly pastDue: boolean;
641
+ /**
642
+ * Does Stripe bill this plan — is there a Subscription behind it? True for
643
+ * every billed tier, including one no longer on the menu (a grandfathered
644
+ * row keeps its subscribers), so a console cannot derive it from `/plans`.
645
+ * It is what sends the account to the Customer Portal rather than to
646
+ * Checkout, and what a granted plan (`scale`, `sponsored`) never is.
647
+ */
648
+ readonly billed: boolean;
649
+ /**
650
+ * The next plan up the ladder this account could move to, or `null` when
651
+ * there is none: the top billed tier, every granted plan, and any plan not
652
+ * on the menu answer `null`. One server-side fact so that no surface
653
+ * derives "can this account upgrade, and to what" from the menu — a
654
+ * grandfathered row has no menu price to compare, and a granted account
655
+ * must never be sent to Checkout.
656
+ */
657
+ readonly upgrade: AccountPlanType | null;
658
+ /**
659
+ * The live Subscription's billing interval — Stripe's
660
+ * `Price.recurring.interval`, mirrored — or `null` when no Subscription
661
+ * bills the account (free and granted plans). It is what lets the console
662
+ * offer the current plan's OTHER interval as a switch.
663
+ */
664
+ readonly interval: BillingInterval | null;
665
+ /**
666
+ * The pending plan change, or `null`. *Up is now, down is at period end*:
667
+ * a downgrade is a Stripe Subscription Schedule that applies at `at`, and
668
+ * until then the account keeps everything it paid for. Reversible —
669
+ * `DELETE /billing/change` releases it.
670
+ */
671
+ readonly scheduled: ScheduledChange | null;
672
+ /**
673
+ * When the Subscription is set to END — Stripe's `cancel_at`, mirrored
674
+ * (Unix seconds) — or `null` while it renews. Set by a cancellation in the
675
+ * Customer Portal; the Portal is also where it is resumed. The console
676
+ * needs it to ACT: no "cancel" offered to an account already cancelling,
677
+ * and no plan change offered until it is resumed (the API refuses one).
678
+ * Mirrored on the rule that survives: what the console must act on is
679
+ * mirrored, what it would merely display is not.
680
+ */
681
+ readonly cancelAt: number | null;
623
682
  }
624
683
  /**
625
684
  * Account as returned by `GET /account` — the entity plus how the request
@@ -1164,8 +1223,10 @@ declare const SIGN_IN_RETURN_PARAM = "signing-in";
1164
1223
  * Client populations: `SESSION` (first-party cookie), `API_KEY` (`ship-`
1165
1224
  * key), `TOKEN` (`deploy-` deploy token), `AGENT` (anonymous public deploy —
1166
1225
  * no credential; the platform grants the public-account identity per
1167
- * request), `OAUTH` (delegated access token). Server populations: `WEBHOOK`
1168
- * (signed webhook processing), `SYSTEM` (scheduled/background jobs).
1226
+ * request), `OAUTH` (delegated access token). The one server population:
1227
+ * `SYSTEM` (scheduled/background jobs). Webhook receipt is deliberately not
1228
+ * a population: a signed delivery is verified, never authorized — it acts
1229
+ * as no one and audits as no one.
1169
1230
  */
1170
1231
  declare const AuthMethod: {
1171
1232
  readonly SESSION: "session";
@@ -1173,7 +1234,6 @@ declare const AuthMethod: {
1173
1234
  readonly TOKEN: "token";
1174
1235
  readonly AGENT: "agent";
1175
1236
  readonly OAUTH: "oauth";
1176
- readonly WEBHOOK: "webhook";
1177
1237
  readonly SYSTEM: "system";
1178
1238
  };
1179
1239
  type AuthMethodType = (typeof AuthMethod)[keyof typeof AuthMethod];
@@ -1748,11 +1808,11 @@ interface TokenResource {
1748
1808
  delete: (token: string) => Promise<TokenDeleteResponse>;
1749
1809
  }
1750
1810
  /**
1751
- * How often a subscription renews. The platform sells one plan at two
1752
- * intervals, so this is the only thing a buyer chooses at checkout.
1811
+ * How often a subscription renews. Every billed plan is sold at both
1812
+ * intervals, so a buyer chooses a plan and an interval, and nothing else.
1753
1813
  *
1754
1814
  * It never branches business logic — monthly and yearly confer identical
1755
- * caps. It exists to be displayed and to pick a price at checkout.
1815
+ * caps. It exists to be displayed and to pick a Price at checkout.
1756
1816
  */
1757
1817
  type BillingInterval = 'month' | 'year';
1758
1818
  /**
@@ -1771,13 +1831,20 @@ interface Plan {
1771
1831
  /** Display name, as the marketing site and the console should print it. */
1772
1832
  readonly name: string;
1773
1833
  /**
1774
- * What it costs. A union rather than a nullable number, so "free" and
1775
- * "talk to us" are two different answers instead of two readings of the
1776
- * same `null`. Amounts are integer CENTS in USD, as the API's plan table
1777
- * states them and as Stripe's Prices are provisioned from it — the wire
1778
- * never carries a formatted price, because formatting is the reader's job.
1834
+ * What it costs, per interval integer CENTS in USD, as the API's plan
1835
+ * table states them and as Stripe's Prices are provisioned from it. The wire
1836
+ * never carries a formatted price: formatting is the reader's job.
1837
+ *
1838
+ * **A free plan costs `{ month: 0, year: 0 }`, not a sentinel.** Free IS
1839
+ * zero, so it is a number like any other and every reader formats it with
1840
+ * the same call; a `'free'` member bought one thing — a branch in each
1841
+ * consumer that mapped it straight back to `$0`.
1842
+ *
1843
+ * `'contact'` stays, and the asymmetry is the point: "not sold at a list
1844
+ * price" is genuinely a different KIND of answer, not a different number, so
1845
+ * it is a different shape. Two shapes, and each earns its own.
1779
1846
  */
1780
- readonly price: 'free' | 'contact' | {
1847
+ readonly price: 'contact' | {
1781
1848
  readonly month: number;
1782
1849
  readonly year: number;
1783
1850
  };
@@ -1786,6 +1853,20 @@ interface Plan {
1786
1853
  * nothing (a plan sold by conversation publishes no numbers).
1787
1854
  */
1788
1855
  readonly caps: Caps | null;
1856
+ /**
1857
+ * Why this row cannot be ordered right now — the closed door's own sentence,
1858
+ * verbatim — or absent when the way is open. A menu lists what can be
1859
+ * ordered, and a row that is sold but not yet orderable (its door is closed:
1860
+ * checkout unbuilt, a feature unfinished) SAYS SO on the menu instead of
1861
+ * only at the order.
1862
+ *
1863
+ * Clients branch on PRESENCE and render the sentence unchanged — they know
1864
+ * *that* the row is closed, never *which* door or *when it lifts*; the
1865
+ * vocabulary of doors stays server-side. The same rule the refusal follows:
1866
+ * `POST /billing/change` onto a closed row answers 400 with
1867
+ * `details.closed`, and its `message` is this sentence.
1868
+ */
1869
+ readonly closed?: string;
1789
1870
  }
1790
1871
  /**
1791
1872
  * Response for `GET /plans` — the whole public menu, in display order.
@@ -1801,23 +1882,59 @@ interface PlansResponse {
1801
1882
  readonly plans: readonly Plan[];
1802
1883
  }
1803
1884
  /**
1804
- * The answer of `POST /billing/checkout` — Stripe's `Checkout.Session`,
1805
- * projected to the one field a client needs.
1885
+ * The body of `POST /billing/change` — the one door for "get me onto this
1886
+ * plan". Both fields required: with more than one billed plan there is no
1887
+ * honest default, and the console always knows which card was clicked.
1806
1888
  *
1807
- * There is nothing else to return: the outcome arrives later, as a Stripe
1808
- * webhook. It is its own type rather than a shape shared with
1809
- * {@link BillingPortalSession} because Stripe has two distinct objects here,
1810
- * and naming one of them for both would be the reader's translation to make.
1889
+ * The SERVER decides what the change means — the rule is *up is now, down is
1890
+ * at period end* so the client holds no copy of the ladder: a free account
1891
+ * is sent to Stripe Checkout, a billed account moving up is sent to the
1892
+ * Portal's confirmation page (money moves now, so Stripe's page takes the
1893
+ * consent), and a billed account moving down gets a Stripe Subscription
1894
+ * Schedule that applies the change at period end. The answer says which
1895
+ * happened ({@link PlanChangeResponse}).
1811
1896
  */
1812
- interface CheckoutSession {
1813
- /** Absolute URL to redirect the browser to. Single use, short-lived. */
1897
+ interface PlanChangeRequest {
1898
+ readonly plan: AccountPlanType;
1899
+ readonly interval: BillingInterval;
1900
+ }
1901
+ /**
1902
+ * The pending plan change — a Stripe Subscription Schedule the platform
1903
+ * minted, mirrored onto the account. `at` is when it applies (the current
1904
+ * period's end, Unix seconds). Reversible until then: `DELETE
1905
+ * /billing/change` releases it.
1906
+ */
1907
+ interface ScheduledChange {
1908
+ readonly plan: AccountPlanType;
1909
+ readonly interval: BillingInterval;
1910
+ readonly at: number;
1911
+ }
1912
+ /**
1913
+ * The answer of `POST /billing/change` — exactly one field is set, and the
1914
+ * UNION is what holds that: an answer carrying both, or neither, does not
1915
+ * compile, so "which door was taken" is structural rather than prose.
1916
+ *
1917
+ * `url` means GO: a Stripe page (Checkout, or the Portal's confirmation page)
1918
+ * finishes the change and the browser must be redirected to it. `scheduled`
1919
+ * means DONE: the downgrade is booked for period end, nothing to visit, and
1920
+ * the account's `scheduled` field now carries it.
1921
+ */
1922
+ type PlanChangeResponse =
1923
+ /** GO: a Stripe page finishes the change. Absolute URL, single use, short-lived. */
1924
+ {
1814
1925
  readonly url: string;
1926
+ readonly scheduled?: never;
1815
1927
  }
1928
+ /** DONE: the downgrade is booked for period end; nothing to visit. */
1929
+ | {
1930
+ readonly url?: never;
1931
+ readonly scheduled: ScheduledChange;
1932
+ };
1816
1933
  /**
1817
1934
  * The answer of `POST /billing/portal` — Stripe's `BillingPortal.Session`,
1818
- * projected the same way. Identical in shape to {@link CheckoutSession} and
1819
- * deliberately not merged with it: they are two Stripe objects, and either may
1820
- * gain a field the other never has.
1935
+ * projected to the one field a client needs. The Portal home: cards,
1936
+ * invoices, cancellation. Plan changes have their own door
1937
+ * ({@link PlanChangeRequest}).
1821
1938
  */
1822
1939
  interface BillingPortalSession {
1823
1940
  /** Absolute URL to redirect the browser to. Single use, short-lived. */
@@ -1836,12 +1953,17 @@ interface BillingSyncResponse {
1836
1953
  /**
1837
1954
  * All activity event types logged in the system.
1838
1955
  * Uses dot notation consistently: {resource}.{action}
1956
+ *
1957
+ * Retention: activity rows are permanent — the account's own history and
1958
+ * the platform's audit ledgers are one table, kept for the life of the
1959
+ * account (deletion removes them). Only the personal payload is
1960
+ * time-bounded: past 90 days each row sheds its IP.
1839
1961
  */
1840
- type ActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.paid' | 'account.plan.transition' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'deployment.flagged' | 'deployment.open' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'token.delete' | 'admin.account.plan.update' | 'admin.account.suspended.update' | 'admin.account.ref.update' | 'admin.account.labels.update' | 'admin.deployment.delete' | 'admin.domain.delete' | 'admin.impersonate';
1962
+ type ActivityEvent = 'account.create' | 'account.delete' | 'account.key.generate' | 'account.plan.transition' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'deployment.flagged' | 'deployment.open' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'token.delete' | 'admin.account.plan.update' | 'admin.account.suspended.update' | 'admin.account.ref.update' | 'admin.account.labels.update' | 'admin.deployment.delete' | 'admin.domain.delete' | 'admin.impersonate';
1841
1963
  /**
1842
1964
  * Activity events visible to users in the dashboard
1843
1965
  */
1844
- 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';
1966
+ type UserVisibleActivityEvent = 'account.create' | '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';
1845
1967
  /**
1846
1968
  * Activity record returned from the API
1847
1969
  */
@@ -3016,4 +3138,4 @@ declare class Ship extends Ship$1 {
3016
3138
  protected processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
3017
3139
  }
3018
3140
 
3019
- export { API_KEY, API_PATHS, AUTH_BASE_PATH, type Account, type AccountDeleteResponse, type AccountGetResponse, type AccountKeyResponse, AccountPlan, type AccountPlanType, type AccountResource, type Activity, type ActivityEvent, type ActivityListResponse, type ActivityMeta, type ApiDeployOptions, ApiHttp, type ApiHttpOptions, AuthMethod, type AuthMethodType, type BillingInterval, type BillingPortalSession, type BillingSyncResponse, CALLER, type Caps, type CheckoutSession, DEFAULT_API, DEPLOYMENT_CONFIG_FILENAME, DEPLOY_FIELDS, DEPLOY_TOKEN, type DeployBodyContext, type DeployFile, type DeployInput, type DeployTransport, type Deployment, type DeploymentCreateResponse, type DeploymentDeleteResponse, type DeploymentListResponse, type DeploymentOptions, type DeploymentResource, type DeploymentResourceContext, type DeploymentSetOptions, DeploymentStatus, type DeploymentStatusType, type DeploymentUploadOptions, DeploymentVia, type DeploymentViaType, type DnsLookup, type DnsProvider, type DnsRecord, type DnsRecordType, type Domain, type DomainDeleteResponse, type DomainDnsResponse, type DomainListResponse, type DomainRecordsResponse, type DomainResource, type DomainSetOptions, type DomainSetResult, type DomainShareResponse, DomainStatus, type DomainStatusType, type DomainValidateResponse, type DomainVerifyResponse, type ErrorResponse, ErrorType, type ExecutionEnvironment, FileValidationStatus as FILE_VALIDATION_STATUS, type Fetch, type FileValidationResult, FileValidationStatus, type FileValidationStatusType, IDEMPOTENCY_KEY_CONSTRAINTS, JUNK_DIRECTORIES, LABEL_CONSTRAINTS, LABEL_PATTERN, type LabelsResponse, type ListOptions, type ListResponse, type MD5Result, MY_API_KEY_URL, OAUTH_TOKEN, OAuthScope, type OAuthScopeType, PASSWORD_CONSTRAINTS, PUBLIC_DEPLOYMENT_TTL_SECONDS, type PingResponse, type Plan, type PlansResponse, type PlatformLimits, type RequestResult, type ResourceContext, SHIP_ENV, SIGN_IN_RETURN_PARAM, type SPACheckDebug, type SPACheckRequest, type SPACheckResponse, SPA_CHECK_CONSTRAINTS, SPA_DEFAULT_CONFIG, type SetupInstructionsResponse, Ship, type ShipClientOptions, ShipError, type ShipEvents, type ShipRequestInit, type StaticFile, TTL_CONSTRAINTS, type Token, type TokenCreateOptions, type TokenCreateResponse, type TokenDeleteResponse, TokenKind, type TokenKindType, type TokenListResponse, type TokenProvider, type TokenResource, type Transport, UNBUILT_PROJECT_MARKERS, UNSAFE_FILENAME_CHARS, type UploadedFile, type UserVisibleActivityEvent, type ValidatableFile, type ValidationIssue, WEB_FILE_ACCEPT, __setTestEnvironment, allValidFilesReady, assertShipJsonSyntax, calculateMD5, classifyToken, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, deserializeLabels, extractSubdomain, filterJunk, formatFileSize, generateDeploymentUrl, generateDomainUrl, getENV, getValidFiles, hasUnbuiltMarker, hasUnsafeChars, isBlockedExtension, isCustomDomain, isDeployment, isPlatformDomain, isShipError, normalizeVia, optimizeDeployPaths, pluralize, processFilesForBrowser, readBearerValue, serializeLabels, validateApiKey, validateApiUrl, validateCaller, validateDeployFile, validateDeployPath, validateDeployToken, validateFileName, validateFiles, validateIdempotencyKey, validateOAuthToken, validatePassword, validateToken, validateTtl };
3141
+ export { API_KEY, API_PATHS, AUTH_BASE_PATH, type Account, type AccountDeleteResponse, type AccountGetResponse, type AccountKeyResponse, AccountPlan, type AccountPlanType, type AccountResource, type Activity, type ActivityEvent, type ActivityListResponse, type ActivityMeta, type ApiDeployOptions, ApiHttp, type ApiHttpOptions, AuthMethod, type AuthMethodType, type BillingInterval, type BillingPortalSession, type BillingSyncResponse, CALLER, type Caps, DEFAULT_API, DEPLOYMENT_CONFIG_FILENAME, DEPLOY_FIELDS, DEPLOY_TOKEN, type DeployBodyContext, type DeployFile, type DeployInput, type DeployTransport, type Deployment, type DeploymentCreateResponse, type DeploymentDeleteResponse, type DeploymentListResponse, type DeploymentOptions, type DeploymentResource, type DeploymentResourceContext, type DeploymentSetOptions, DeploymentStatus, type DeploymentStatusType, type DeploymentUploadOptions, DeploymentVia, type DeploymentViaType, type DnsLookup, type DnsProvider, type DnsRecord, type DnsRecordType, type Domain, type DomainDeleteResponse, type DomainDnsResponse, type DomainListResponse, type DomainRecordsResponse, type DomainResource, type DomainSetOptions, type DomainSetResult, type DomainShareResponse, DomainStatus, type DomainStatusType, type DomainValidateResponse, type DomainVerifyResponse, type ErrorResponse, ErrorType, type ExecutionEnvironment, FileValidationStatus as FILE_VALIDATION_STATUS, type Fetch, type FileValidationResult, FileValidationStatus, type FileValidationStatusType, IDEMPOTENCY_KEY_CONSTRAINTS, JUNK_DIRECTORIES, LABEL_CONSTRAINTS, LABEL_PATTERN, type LabelsResponse, type ListOptions, type ListResponse, type MD5Result, MY_API_KEY_URL, OAUTH_TOKEN, OAuthScope, type OAuthScopeType, PASSWORD_CONSTRAINTS, PUBLIC_DEPLOYMENT_TTL_SECONDS, type PingResponse, type Plan, type PlanChangeRequest, type PlanChangeResponse, type PlansResponse, type PlatformLimits, type RequestResult, type ResourceContext, SHIP_ENV, SIGN_IN_RETURN_PARAM, type SPACheckDebug, type SPACheckRequest, type SPACheckResponse, SPA_CHECK_CONSTRAINTS, SPA_DEFAULT_CONFIG, type ScheduledChange, type SetupInstructionsResponse, Ship, type ShipClientOptions, ShipError, type ShipEvents, type ShipRequestInit, type StaticFile, TTL_CONSTRAINTS, type Token, type TokenCreateOptions, type TokenCreateResponse, type TokenDeleteResponse, TokenKind, type TokenKindType, type TokenListResponse, type TokenProvider, type TokenResource, type Transport, UNBUILT_PROJECT_MARKERS, UNSAFE_FILENAME_CHARS, type UploadedFile, type UserVisibleActivityEvent, type ValidatableFile, type ValidationIssue, WEB_FILE_ACCEPT, __setTestEnvironment, allValidFilesReady, assertShipJsonSyntax, calculateMD5, classifyToken, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, deserializeLabels, extractSubdomain, filterJunk, formatFileSize, generateDeploymentUrl, generateDomainUrl, getENV, getValidFiles, hasUnbuiltMarker, hasUnsafeChars, isBlockedExtension, isCustomDomain, isDeployment, isPlatformDomain, isShipError, normalizeVia, optimizeDeployPaths, pluralize, processFilesForBrowser, readBearerValue, serializeLabels, validateApiKey, validateApiUrl, validateCaller, validateDeployFile, validateDeployPath, validateDeployToken, validateFileName, validateFiles, validateIdempotencyKey, validateOAuthToken, validatePassword, validateToken, validateTtl };
package/dist/browser.js CHANGED
@@ -1,2 +1,2 @@
1
- var st=Object.create;var $=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var ct=(e,n,t)=>n in e?$(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var I=(e,n)=>()=>(e&&(n=e(e=0)),n);var Re=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),ft=(e,n)=>{for(var t in n)$(e,t,{get:n[t],enumerable:!0})},dt=(e,n,t,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of lt(n))!ut.call(e,l)&&l!==t&&$(e,l,{get:()=>n[l],enumerable:!(a=at(n,l))||a.enumerable});return e};var H=(e,n,t)=>(t=e!=null?st(pt(e)):{},dt(n||!e||!e.__esModule?$(t,"default",{value:e,enumerable:!0}):t,e));var B=(e,n,t)=>ct(e,typeof n!="symbol"?n+"":n,t);function Qt(e){if(!e||typeof e!="string")return;let n=e.trim().toLowerCase();return Object.values(mt).includes(n)?n:void 0}function De(e){if(e==null)return;if(typeof e!="string")throw m.validation("Idempotency key must be a string.");let n=e.trim();if(!n)throw m.validation("Idempotency key must not be empty.");if(n.length>v.MAX_LENGTH)throw m.validation(`Idempotency key must be at most ${v.MAX_LENGTH} characters.`);return n}function Et(e){let n=e.code;return n==="ERR_INVALID_URL"?!1:typeof n=="string"?!0:e instanceof TypeError?!/\burl\b/i.test(e.message):!1}function be(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function At(e){let n=e.replace(/\\/g,"/").split("/").pop()??"",t=n.lastIndexOf(".");return t<=0||t===n.length-1?null:n.slice(t+1).toLowerCase()}function Ie(e,n){let t=At(e);return t===null?!1:Array.isArray(n)?n.includes(t):n.has(t)}function Le(e){return St.test(e)}function z(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(t=>Rt.has(t))}function Dt(e){return e.startsWith(_e.PREFIX)?x.API_KEY:e.startsWith(we.PREFIX)?x.DEPLOY_TOKEN:e.startsWith(Pe.PREFIX)?x.OAUTH:x.OPAQUE}function rn(e){return e.slice(0,re.length).toLowerCase()!==re?null:e.slice(re.length)||null}function xe(e){let n=e.charCodeAt(0)===65279?e.slice(1):e,t;try{t=JSON.parse(n)}catch(a){throw m.config(`invalid JSON format in config: ${a.message}`,{filePath:P})}if(t===null||typeof t!="object"||Array.isArray(t))throw m.config(`${P} must contain a JSON object`,{filePath:P})}function ie(e,n,t){if(!e.startsWith(n.PREFIX))throw m.validation(`${t} must start with "${n.PREFIX}"`);if(e.length!==n.TOTAL_LENGTH)throw m.validation(`${t} must be ${n.TOTAL_LENGTH} characters total (${n.PREFIX} + ${n.HEX_LENGTH} hex chars)`);let a=e.slice(n.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${n.HEX_LENGTH}}$`,"i").test(a))throw m.validation(`${t} must contain ${n.HEX_LENGTH} hexadecimal characters after "${n.PREFIX}" prefix`)}function bt(e){ie(e,_e,"API key")}function It(e){ie(e,we,"Deploy token")}function Lt(e){ie(e,Pe,"OAuth access token")}function oe(e){switch(Dt(e)){case x.API_KEY:bt(e);return;case x.DEPLOY_TOKEN:It(e);return;case x.OAUTH:Lt(e);return;case x.OPAQUE:if(!e)throw m.validation("Token must be a non-empty string")}}function Oe(e){if(!e||e.length>C.MAX_LENGTH||!C.PATTERN.test(e))throw m.validation(`Caller must be 1-${C.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function sn(e){try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol))throw m.validation("API URL must use http:// or https:// protocol");if(n.pathname!=="/"&&n.pathname!=="")throw m.validation("API URL must not contain a path");if(n.search||n.hash)throw m.validation("API URL must not contain query parameters or fragments")}catch(n){throw be(n)?n:m.validation("API URL must be a valid URL")}}function an(e){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(e)}function se(e){if(e!=null){if(typeof e!="number"||!Number.isFinite(e))throw m.validation("TTL must be a number of seconds");if(!Number.isInteger(e))throw m.validation("TTL must be a whole number of seconds");if(e<G.MIN_SECONDS||e>G.MAX_SECONDS)throw m.validation(`TTL must be between ${G.MIN_SECONDS} and ${G.MAX_SECONDS} seconds`);return e}}function Fe(e,n){return e.endsWith(`.${n}`)}function cn(e,n){return!Fe(e,n)}function fn(e,n){return Fe(e,n)?e.slice(0,-(n.length+1)):null}function dn(e){return`https://${e}`}function mn(e){return`https://${e}`}function hn(e){return!e||e.length===0?null:JSON.stringify(e)}function yn(e){if(!e)return[];try{let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function le(e){if(e==null)return;if(typeof e!="string")throw m.validation("Password must be a string");let n=e.trim();if(n.length<k.MIN_LENGTH||n.length>k.MAX_LENGTH)throw m.validation(`Password must be between ${k.MIN_LENGTH} and ${k.MAX_LENGTH} characters`);return n}var Wt,mt,Jt,v,Zt,T,L,g,ht,te,yt,gt,m,Tt,en,St,Rt,tn,nn,ne,_e,we,Pe,C,x,re,on,P,Ne,K,G,ae,ln,pn,un,D,O,ve,k,R=I(()=>{"use strict";Wt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},mt={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc",CLD:"cld",CRS:"crs",API:"api"},Jt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},v={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};Zt={FREE:"free",PRO:"pro",SCALE:"scale",SPONSORED:"sponsored"},T={DEPLOYMENTS:"/deployments",DEPLOYMENT:e=>`/deployments/${e}`,DEPLOYMENT_CONFIG:e=>`/deployments/${e}/config`,DOMAINS:"/domains",DOMAIN:e=>`/domains/${e}`,DOMAIN_VERIFY:e=>`/domains/${e}/verify`,DOMAIN_DNS:e=>`/domains/${e}/dns`,DOMAIN_RECORDS:e=>`/domains/${e}/records`,DOMAIN_SHARE:e=>`/domains/${e}/share`,DOMAIN_PROPAGATION:e=>`/domains/${e}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:e=>`/tokens/${e}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PLANS:"/plans",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},L={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",TTL:"ttl",BUILD:"build",PRERENDER:"prerender",SPA:"spa",CAPTCHA:"captcha"},g={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Maintenance:"maintenance",Network:"network_error",Timeout:"timeout_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},ht=new Set([g.Network,g.Timeout,g.Cancelled,g.File,g.Config]),te={client:new Set([g.Business,g.Cancelled,g.Config,g.File,g.Forbidden,g.NotFound,g.RateLimit,g.Validation]),network:new Set([g.Network,g.Timeout]),auth:new Set([g.Authentication])},yt=new Set(Object.values(g).filter(e=>!ht.has(e))),gt=200;m=class e extends Error{constructor(t,a,l,c){super(a);B(this,"type");B(this,"status");B(this,"details");this.type=t,this.status=l,this.details=c,this.name="ShipError"}toResponse(){let t=this.details,a=this.type===g.Authentication&&t?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:a}}static async fromHttpResponse(t,a){let l,c,h;try{if(t.headers.get("content-type")?.includes("application/json")){let f=await t.json();if(f&&typeof f=="object"){let A=f;typeof A.message=="string"?l=A.message:typeof A.error=="string"&&(l=A.error),c=A.details,typeof A.error=="string"&&yt.has(A.error)&&(h=A.error)}}else{let f=(await t.text()).trim();f&&!f.startsWith("<")&&f.length<=gt&&(l=f)}}catch{}let y=t.headers.get("retry-after");if(y!==null){let E=y.trim(),f=/^\d+$/.test(E)?Number(E):Math.ceil((Date.parse(E)-Date.now())/1e3);if(Number.isFinite(f)&&f>=0){let A=c&&typeof c=="object"?c:{};A.retryAfter===void 0&&(c={...A,retryAfter:f})}}l=l||`${a||"Request"} failed with status ${t.status}`;let d=h??(t.status===401?g.Authentication:t.status===403?g.Forbidden:t.status===429?g.RateLimit:g.Api);return new e(d,l,t.status,c)}static fromFetchError(t,a){if(be(t))return t;let l=a||"Request",c=t?.name;return c==="AbortError"?e.cancelled(`${l} was cancelled`):c==="TimeoutError"?e.timeout(`${l} timed out`,{cause:t}):t instanceof Error?Et(t)?e.network(`${l} failed: ${t.message}`,{cause:t}):new e(g.Api,`${l} failed: ${t.message}`):new e(g.Api,`${l} failed: Unknown error`)}static validation(t,a){return new e(g.Validation,t,400,a)}static notFound(t,a){let l=a?`${t} ${a} not found`:`${t} not found`;return new e(g.NotFound,l,404)}static forbidden(t,a){return new e(g.Forbidden,t,403,a)}static rateLimit(t="Too many requests",a){return new e(g.RateLimit,t,429,a)}static authentication(t="Authentication required",a){return new e(g.Authentication,t,401,a)}static business(t,a=400,l){return new e(g.Business,t,a,l)}static network(t,a){return new e(g.Network,t,void 0,a)}static timeout(t,a){return new e(g.Timeout,t,void 0,a)}static cancelled(t,a){return new e(g.Cancelled,t,void 0,a)}static file(t,a){return new e(g.File,t,void 0,a)}static config(t,a){return new e(g.Config,t,void 0,a)}static api(t,a=500,l){return new e(g.Api,t,a,l)}static maintenance(t,a){return new e(g.Maintenance,t,503,a)}isClientError(){return te.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return te.network.has(this.type)}isAuthError(){return te.auth.has(this.type)}isType(t){return this.type===t}};Tt=["html","htm","xhtml","xml","txt","md","markdown","pdf","csv","json","jsonc","webmanifest","map","toml","yaml","yml","rss","atom","css","scss","sass","less","js","mjs","cjs","jsx","ts","tsx","wasm","vue","svelte","png","jpg","jpeg","gif","webp","avif","svg","ico","bmp","tif","tiff","heic","heif","woff","woff2","ttf","otf","eot","mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","mp4","webm","ogv","mov","m4v","avi","glb","gltf","usdz","vtt","srt","zip"],en=Tt.map(e=>`.${e}`).join(","),St=/[\x00-\x1f\x7f#?%\\<>"]/;Rt=new Set(["node_modules","package.json"]);tn="/auth",nn="signing-in",ne={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},_e={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},we={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},Pe={PREFIX:"oauth-",HEX_LENGTH:32,TOTAL_LENGTH:38},C={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},x={API_KEY:ne.API_KEY,DEPLOY_TOKEN:ne.TOKEN,OAUTH:ne.OAUTH,OPAQUE:"opaque"};re="bearer ";on={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},P="ship.json",Ne={rewrites:[{source:"/(.*)",destination:"/index.html"}]},K={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};G={MIN_SECONDS:1,MAX_SECONDS:365*24*60*60};ae="https://api.shipstatic.com",ln={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},pn="https://my.shipstatic.com/api-key",un=4320*60,D={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};O={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},ve=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;k={MIN_LENGTH:6,MAX_LENGTH:128}});var He=Re((Ue,$e)=>{"use strict";(function(e){if(typeof Ue=="object")$e.exports=e();else if(typeof define=="function"&&define.amd)define(e);else{var n;try{n=window}catch{n=self}n.SparkMD5=e()}})(function(e){"use strict";var n=function(u,p){return u+p&4294967295},t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(u,p,i,r,s,o){return p=n(n(p,u),n(r,o)),n(p<<s|p>>>32-s,i)}function l(u,p){var i=u[0],r=u[1],s=u[2],o=u[3];i+=(r&s|~r&o)+p[0]-680876936|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[1]-389564586|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[2]+606105819|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[3]-1044525330|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+p[4]-176418897|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[5]+1200080426|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[6]-1473231341|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[7]-45705983|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+p[8]+1770035416|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[9]-1958414417|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[10]-42063|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[11]-1990404162|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+p[12]+1804603682|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[13]-40341101|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[14]-1502002290|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[15]+1236535329|0,r=(r<<22|r>>>10)+s|0,i+=(r&o|s&~o)+p[1]-165796510|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[6]-1069501632|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[11]+643717713|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[0]-373897302|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+p[5]-701558691|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[10]+38016083|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[15]-660478335|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[4]-405537848|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+p[9]+568446438|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[14]-1019803690|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[3]-187363961|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[8]+1163531501|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+p[13]-1444681467|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[2]-51403784|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[7]+1735328473|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[12]-1926607734|0,r=(r<<20|r>>>12)+s|0,i+=(r^s^o)+p[5]-378558|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[8]-2022574463|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[11]+1839030562|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[14]-35309556|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+p[1]-1530992060|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[4]+1272893353|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[7]-155497632|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[10]-1094730640|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+p[13]+681279174|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[0]-358537222|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[3]-722521979|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[6]+76029189|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+p[9]-640364487|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[12]-421815835|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[15]+530742520|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[2]-995338651|0,r=(r<<23|r>>>9)+s|0,i+=(s^(r|~o))+p[0]-198630844|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[7]+1126891415|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[14]-1416354905|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[5]-57434055|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+p[12]+1700485571|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[3]-1894986606|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[10]-1051523|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[1]-2054922799|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+p[8]+1873313359|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[15]-30611744|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[6]-1560198380|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[13]+1309151649|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+p[4]-145523070|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[11]-1120210379|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[2]+718787259|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[9]-343485551|0,r=(r<<21|r>>>11)+s|0,u[0]=i+u[0]|0,u[1]=r+u[1]|0,u[2]=s+u[2]|0,u[3]=o+u[3]|0}function c(u){var p=[],i;for(i=0;i<64;i+=4)p[i>>2]=u.charCodeAt(i)+(u.charCodeAt(i+1)<<8)+(u.charCodeAt(i+2)<<16)+(u.charCodeAt(i+3)<<24);return p}function h(u){var p=[],i;for(i=0;i<64;i+=4)p[i>>2]=u[i]+(u[i+1]<<8)+(u[i+2]<<16)+(u[i+3]<<24);return p}function y(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,s,o,b,w,N;for(r=64;r<=p;r+=64)l(i,c(u.substring(r-64,r)));for(u=u.substring(r-64),s=u.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<s;r+=1)o[r>>2]|=u.charCodeAt(r)<<(r%4<<3);if(o[r>>2]|=128<<(r%4<<3),r>55)for(l(i,o),r=0;r<16;r+=1)o[r]=0;return b=p*8,b=b.toString(16).match(/(.*?)(.{0,8})$/),w=parseInt(b[2],16),N=parseInt(b[1],16)||0,o[14]=w,o[15]=N,l(i,o),i}function d(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,s,o,b,w,N;for(r=64;r<=p;r+=64)l(i,h(u.subarray(r-64,r)));for(u=r-64<p?u.subarray(r-64):new Uint8Array(0),s=u.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<s;r+=1)o[r>>2]|=u[r]<<(r%4<<3);if(o[r>>2]|=128<<(r%4<<3),r>55)for(l(i,o),r=0;r<16;r+=1)o[r]=0;return b=p*8,b=b.toString(16).match(/(.*?)(.{0,8})$/),w=parseInt(b[2],16),N=parseInt(b[1],16)||0,o[14]=w,o[15]=N,l(i,o),i}function E(u){var p="",i;for(i=0;i<4;i+=1)p+=t[u>>i*8+4&15]+t[u>>i*8&15];return p}function f(u){var p;for(p=0;p<u.length;p+=1)u[p]=E(u[p]);return u.join("")}f(y("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(n=function(u,p){var i=(u&65535)+(p&65535),r=(u>>16)+(p>>16)+(i>>16);return r<<16|i&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(p,i){return p=p|0||0,p<0?Math.max(p+i,0):Math.min(p,i)}ArrayBuffer.prototype.slice=function(p,i){var r=this.byteLength,s=u(p,r),o=r,b,w,N,Se;return i!==e&&(o=u(i,r)),s>o?new ArrayBuffer(0):(b=o-s,w=new ArrayBuffer(b),N=new Uint8Array(w),Se=new Uint8Array(this,s,b),N.set(Se),w)}})();function A(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function _(u,p){var i=u.length,r=new ArrayBuffer(i),s=new Uint8Array(r),o;for(o=0;o<i;o+=1)s[o]=u.charCodeAt(o);return p?s:r}function F(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function ot(u,p,i){var r=new Uint8Array(u.byteLength+p.byteLength);return r.set(new Uint8Array(u)),r.set(new Uint8Array(p),u.byteLength),i?r:r.buffer}function U(u){var p=[],i=u.length,r;for(r=0;r<i-1;r+=2)p.push(parseInt(u.substr(r,2),16));return String.fromCharCode.apply(String,p)}function S(){this.reset()}return S.prototype.append=function(u){return this.appendBinary(A(u)),this},S.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var p=this._buff.length,i;for(i=64;i<=p;i+=64)l(this._hash,c(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},S.prototype.end=function(u){var p=this._buff,i=p.length,r,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o;for(r=0;r<i;r+=1)s[r>>2]|=p.charCodeAt(r)<<(r%4<<3);return this._finish(s,i),o=f(this._hash),u&&(o=U(o)),this.reset(),o},S.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},S.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},S.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},S.prototype._finish=function(u,p){var i=p,r,s,o;if(u[i>>2]|=128<<(i%4<<3),i>55)for(l(this._hash,u),i=0;i<16;i+=1)u[i]=0;r=this._length*8,r=r.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(r[2],16),o=parseInt(r[1],16)||0,u[14]=s,u[15]=o,l(this._hash,u)},S.hash=function(u,p){return S.hashBinary(A(u),p)},S.hashBinary=function(u,p){var i=y(u),r=f(i);return p?U(r):r},S.ArrayBuffer=function(){this.reset()},S.ArrayBuffer.prototype.append=function(u){var p=ot(this._buff.buffer,u,!0),i=p.length,r;for(this._length+=u.byteLength,r=64;r<=i;r+=64)l(this._hash,h(p.subarray(r-64,r)));return this._buff=r-64<i?new Uint8Array(p.buffer.slice(r-64)):new Uint8Array(0),this},S.ArrayBuffer.prototype.end=function(u){var p=this._buff,i=p.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s,o;for(s=0;s<i;s+=1)r[s>>2]|=p[s]<<(s%4<<3);return this._finish(r,i),o=f(this._hash),u&&(o=U(o)),this.reset(),o},S.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.ArrayBuffer.prototype.getState=function(){var u=S.prototype.getState.call(this);return u.buff=F(u.buff),u},S.ArrayBuffer.prototype.setState=function(u){return u.buff=_(u.buff,!0),S.prototype.setState.call(this,u)},S.ArrayBuffer.prototype.destroy=S.prototype.destroy,S.ArrayBuffer.prototype._finish=S.prototype._finish,S.ArrayBuffer.hash=function(u,p){var i=d(new Uint8Array(u)),r=f(i);return p?U(r):r},S})});var Y=Re((In,Be)=>{"use strict";Be.exports={}});async function Ct(e){let n=(await Promise.resolve().then(()=>H(He(),1))).default,t=new n.ArrayBuffer,a=2097152;for(let l=0;l<e.size;l+=a){let c=Math.min(l+a,e.size);t.append(await e.slice(l,c).arrayBuffer())}return{md5:t.end()}}async function Mt(e){let{createHash:n}=await Promise.resolve().then(()=>H(Y(),1)),t=n("md5");return t.update(e),{md5:t.digest("hex")}}async function Ut(e){let{createHash:n}=await Promise.resolve().then(()=>H(Y(),1)),{createReadStream:t}=await Promise.resolve().then(()=>H(Y(),1));return new Promise((a,l)=>{let c=n("md5"),h=t(e);h.on("error",y=>l(m.file(`Failed to read file for MD5: ${y.message}`,{filePath:e}))),h.on("data",y=>c.update(y)),h.on("end",()=>a({md5:c.digest("hex")}))})}async function X(e){if(e instanceof Blob)return Ct(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return Mt(e);if(typeof e=="string")return Ut(e);throw m.business("Invalid input for MD5 calculation")}var j=I(()=>{"use strict";R()});function Q(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ye=I(()=>{"use strict"});function Xe(e,n={}){if(n.flatten===!1)return e.map(a=>({path:Q(a),name:ue(a)}));let t=Gt(e);return e.map(a=>{let l=Q(a);if(t){let c=t.endsWith("/")?t:`${t}/`;l.startsWith(c)&&(l=l.substring(c.length))}return l||(l=ue(a)),{path:l,name:ue(a)}})}function Gt(e){if(!e.length)return"";let t=e.map(c=>Q(c)).map(c=>c.split("/")),a=[],l=Math.min(...t.map(c=>c.length));for(let c=0;c<l-1;c++){let h=t[0][c];if(t.every(y=>y[c]===h))a.push(h);else break}return a.join("/")}function ue(e){return e.split(/[/\\]/).pop()||e}var ce=I(()=>{"use strict";Ye()});function Xn(e){fe=e}function kt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function je(){return fe||kt()}var fe,de=I(()=>{"use strict";fe=null});function ee(e,n){return zt.find(t=>t.broken(e,n))}var zt,he=I(()=>{"use strict";R();ye();zt=[{name:"name",broken:({path:e})=>!me(e).valid,sentence:({path:e})=>me(e).reason??"Invalid file name"},{name:"extension",broken:({path:e},n)=>Ie(e,n.blockedExtensions??[]),sentence:({path:e})=>`File extension not allowed: "${e}"`},{name:"fileSize",broken:({size:e},n)=>e>n.maxFileSize,sentence:({path:e},n)=>`File "${e}" too large. Maximum ${Z(n.maxFileSize)} allowed`},{name:"totalSize",broken:({totalSize:e},n)=>e>n.maxTotalSize,sentence:({totalSize:e},n)=>`Total upload size too large. ${Z(e)} exceeds maximum of ${Z(n.maxTotalSize)}`}]});function Z(e,n=1){if(e===0)return"0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],l=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**l).toFixed(n))} ${a[l]}`}function me(e){if(Le(e))return{valid:!1,reason:"File name contains unsafe characters"};if(e.startsWith(" ")||e.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(e.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let n=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,t=e.split("/").pop()||e;return n.test(t)?{valid:!1,reason:"File name uses a reserved system name"}:e.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function tr(e,n){let t=[],a=[],l=[];if(e.length===0){let d={file:"(no files)",message:"At least one file must be provided"};return t.push(d),{files:[],validFiles:[],errors:t,warnings:[],canDeploy:!1}}for(let d of e)if(z(d.name))return t.push({file:d.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:e.map(E=>({...E,status:D.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:t,warnings:[],canDeploy:!1};if(e.length>n.maxFilesCount){let d={file:`(${e.length} files)`,message:`File count (${e.length}) exceeds limit of ${n.maxFilesCount}`};return t.push(d),{files:e.map(E=>({...E,status:D.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:t,warnings:[],canDeploy:!1}}let c=0;for(let d of e){let E=D.READY,f="Ready for upload";if(d.status===D.PROCESSING_ERROR)E=D.VALIDATION_FAILED,f=d.statusMessage||"File failed during processing",t.push({file:d.name,message:f});else if(d.size===0){E=D.EXCLUDED,f="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:d.name,message:f}),l.push({...d,status:E,statusMessage:f});continue}else if(d.size<0)E=D.VALIDATION_FAILED,f="File size must be positive",t.push({file:d.name,message:f});else if(!d.name||d.name.trim().length===0)E=D.VALIDATION_FAILED,f="File name cannot be empty",t.push({file:d.name||"(empty)",message:f});else if(d.name.includes("\0"))E=D.VALIDATION_FAILED,f="File name contains invalid characters (null byte)",t.push({file:d.name,message:f});else{let A={path:d.name,size:d.size,totalSize:c+d.size},_=ee(A,n);_?(E=D.VALIDATION_FAILED,f=_.sentence(A,n),t.push({file:_.name==="totalSize"?`(${e.length} files)`:d.name,message:f})):c=A.totalSize}l.push({...d,status:E,statusMessage:f})}t.length>0&&(l=l.map(d=>d.status===D.EXCLUDED?d:{...d,status:D.VALIDATION_FAILED,statusMessage:d.status===D.VALIDATION_FAILED?d.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=t.length===0?l.filter(d=>d.status===D.READY):[],y=t.length===0;return{files:l,validFiles:h,errors:t,warnings:a,canDeploy:y}}function Kt(e){return e.filter(n=>n.status===D.READY)}function nr(e){return Kt(e).length>0}var ye=I(()=>{"use strict";R();he()});function We(e){return Vt.test(e)}var qt,Vt,Je=I(()=>{"use strict";qt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],Vt=new RegExp(qt.join("|"))});function Qe(e,n){if(!e||e.length===0)return[];if(!n?.allowUnbuilt&&e.find(a=>a&&z(a)))throw m.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return e.filter(t=>{if(!t)return!1;let a=t.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let l=a[a.length-1];if(We(l))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(y=>h.toLowerCase()===y.toLowerCase()))return!1;return!0})}var Yt,ge=I(()=>{"use strict";R();Je();Yt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Ze(e,n){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw m.business(`Security error: Unsafe file path "${e}" for file: ${n}`)}function et(e,n){let t=ee(e,n);if(t)throw m.business(t.sentence(e,n))}var Ee=I(()=>{"use strict";R();he()});async function tt(e,n={},t){let a=!!(n.build||n.prerender),l=Xe(e.map(f=>f.path),{flatten:n.pathDetect!==!1}).map(f=>f.path),c=new Set(Qe(l,{allowUnbuilt:a})),h=e.map((f,A)=>({source:f,deployPath:l[A]})).filter(({deployPath:f})=>c.has(f));if(h.length===0)return[];let y=a?null:Xt(t),d=[],E=0;for(let{source:f,deployPath:A}of h){if(y&&Ze(A,f.origin),f.size===0)continue;y&&(E+=f.size,et({path:A,size:f.size,totalSize:E},y));let _=await f.read(),{md5:F}=await X(_);d.push({path:A,content:_,size:f.size,md5:F})}if(y&&d.length>y.maxFilesCount)throw m.business(`Too many files to deploy. Maximum allowed is ${y.maxFilesCount} files.`);return d}function Xt(e){if(!e)throw m.config("Platform limits not provided. Deploy-mode validation requires the limits argument \u2014 pass `ship.getLimits()` result.");return e}var nt=I(()=>{"use strict";R();ce();ge();j();Ee()});var it={};ft(it,{processFilesForBrowser:()=>rt});async function rt(e,n={},t){if(je()!=="browser")throw m.business("processFilesForBrowser can only be called in a browser environment.");return tt(e.map(a=>({path:a.webkitRelativePath||a.name,origin:a.name,size:a.size,read:async()=>a})),n,t)}var Ae=I(()=>{"use strict";R();nt();de()});R();R();R();var q=class{constructor(){this.handlers=new Map}on(n,t){this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n)?.add(t)}off(n,t){let a=this.handlers.get(n);a&&(a.delete(t),a.size===0&&this.handlers.delete(n))}emit(n,...t){let a=this.handlers.get(n);if(!a)return;let l=Array.from(a);for(let c of l)try{c(...t)}catch(h){a.delete(c),n!=="error"&&setTimeout(()=>{let y=h instanceof Error?h:new Error(String(h));this.emit("error",y,String(n))},0)}}};var _t=3e4,wt=2,Pt=300,Nt=2e3,xt=new Set([500,502,503,504]);function Ot(e,n){return new Promise((t,a)=>{if(n?.aborted){a(n.reason);return}let l=()=>{clearTimeout(h),n?.removeEventListener("abort",c)},c=()=>{l(),a(n?.reason)},h=setTimeout(()=>{l(),t()},e);n?.addEventListener("abort",c)})}var Ce=3e5,Ft=3e5,vt=Ce+Ft,V=class extends q{constructor(t){super();this.globalHeaders={};this.apiUrl=t.apiUrl||ae,this.getAuthHeadersCallback=t.getAuthHeaders,this.session=t.session??!1,this.caller=t.caller,this.timeout=t.timeout??_t,this.maxRetries=Math.max(0,t.maxRetries??wt),this.fetch=t.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:t.deployEndpoint||T.DEPLOYMENTS,timeout:t.timeout??Ce,buildTimeout:t.timeout??vt}}setGlobalHeaders(t){this.globalHeaders=t}async executeRequest(t,a,l,c=this.timeout){for(let h=0;;h++)try{return await this.attemptOnce(t,a,l,c)}catch(y){let d=m.fromFetchError(y,l);if(h>=this.maxRetries||!this.isRetryable(d,a))throw this.emit("error",d,t),d;this.emit("retry",d,t,h+1);let E=Math.min(Nt,Pt*2**h);try{await Ot(Math.random()*E,a.signal)}catch(f){let A=m.fromFetchError(f,l);throw this.emit("error",A,t),A}}}isRetryable(t,a){if(a.signal?.aborted||t.isType(g.Maintenance)||t.isType(g.Cancelled)||!(t.isNetworkError()||t.status!==void 0&&xt.has(t.status)))return!1;let c=(a.method??"GET").toUpperCase();return c==="GET"||c==="HEAD"?!0:c==="PUT"||c==="DELETE"?!1:this.hasIdempotencyKey(a.headers)}hasIdempotencyKey(t){if(!t)return!1;let a=v.HEADER.toLowerCase();return Object.keys(t).some(l=>l.toLowerCase()===a)}async attemptOnce(t,a,l,c=this.timeout){let h=()=>{};try{let y=await this.mergeHeaders(a.headers),d=this.createTimeoutSignal(a.signal,c);h=d.cleanup;let E={...a,headers:y,credentials:this.session&&!y.Authorization?"include":void 0,signal:d.signal};this.emit("request",t,E);let f=await this.fetch(t,E);if(h(),!f.ok)throw await m.fromHttpResponse(f,l);return this.emit("response",this.safeClone(f),t),{data:await this.parseResponse(this.safeClone(f)),status:f.status}}catch(y){throw h(),m.fromFetchError(y,l)}}async request(t,a,l,c){let{data:h}=await this.executeRequest(`${this.apiUrl}${t}`,a,l,c);return h}async requestWithStatus(t,a,l){return this.executeRequest(`${this.apiUrl}${t}`,a,l)}async mergeHeaders(t={}){return{...this.globalHeaders,...this.caller?{[C.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...t}}createTimeoutSignal(t,a=this.timeout){let l=new AbortController,c=setTimeout(()=>l.abort(new DOMException(`Timed out after ${a}ms`,"TimeoutError")),a),h=t?()=>l.abort(t.reason):void 0;return t&&h&&(t.addEventListener("abort",h),t.aborted&&l.abort(t.reason)),{signal:l.signal,cleanup:()=>{clearTimeout(c),t&&h&&t.removeEventListener("abort",h)}}}safeClone(t){try{return t.clone()}catch{return t}}async parseResponse(t){if(!(t.headers.get("Content-Length")==="0"||t.status===204))return t.json()}};R();R();async function Me(e,n={}){let{labels:t,via:a,password:l,ttl:c,flags:h,captcha:y}=n,d=new FormData,E=[];for(let f of e){if(typeof f.content=="string"||f.content===null||f.content===void 0)throw m.file(`Unsupported file.content type: ${f.path}`,{filePath:f.path});if(!f.md5)throw m.file(`File missing md5 checksum: ${f.path}`,{filePath:f.path});d.append(L.FILES,new File([f.content],f.path,{type:"application/octet-stream"})),E.push(f.md5)}return d.append(L.CHECKSUMS,JSON.stringify(E)),t&&t.length>0&&d.append(L.LABELS,JSON.stringify(t)),a&&d.append(L.VIA,a),l&&d.append(L.PASSWORD,l),c!==void 0&&d.append(L.TTL,String(c)),h?.build&&d.append(L.BUILD,"true"),h?.prerender&&d.append(L.PRERENDER,"true"),h?.spa&&d.append(L.SPA,"true"),y&&d.append(L.CAPTCHA,y),d}R();j();async function $t(){let e=JSON.stringify(Ne,null,2),n;typeof Buffer<"u"?n=Buffer.from(e,"utf-8"):n=new Blob([e],{type:"application/json"});let{md5:t}=await X(n);return{path:P,content:n,size:e.length,md5:t}}async function Ht(e,n){let t=e.find(h=>h.path===K.INDEX_FILE||h.path===`/${K.INDEX_FILE}`);if(!t||t.size>K.MAX_INDEX_BYTES)return!1;let a;if(typeof Buffer<"u"&&Buffer.isBuffer(t.content))a=t.content.toString("utf-8");else if(typeof Blob<"u"&&t.content instanceof Blob)a=await t.content.text();else if(typeof File<"u"&&t.content instanceof File)a=await t.content.text();else return!1;let l={files:e.map(h=>h.path),index:a};return(await n.request(T.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"SPA check")).isSPA}async function Ge(e,n,t){if(t.spaDetect===!1||t.spa||t.build||t.prerender||e.some(a=>a.path===P))return e;try{if(await Ht(e,n)){let l=await $t();return[...e,l]}}catch{}return e}R();R();function M(e){if(e==null)return;if(e.length===0)return e;if(e.length>O.MAX_COUNT)throw m.validation(`Maximum ${O.MAX_COUNT} labels allowed`);let n=e.map((a,l)=>{if(typeof a!="string")throw m.validation(`Label at index ${l} must be a string`);let c=a.trim().toLowerCase();if(c.length<O.MIN_LENGTH)throw m.validation(`Labels must be at least ${O.MIN_LENGTH} characters long`);if(c.length>O.MAX_LENGTH)throw m.validation(`Labels must be no more than ${O.MAX_LENGTH} characters long`);if(!ve.test(c))throw m.validation(`Labels must start and end with alphanumeric characters, with optional separators (${O.SEPARATORS}) between segments`);return c}),t=[...new Set(n)];if(t.length!==n.length)throw m.validation("Duplicate labels are not allowed");return t}async function ke(e){let n=e.find(l=>l.path===P||l.path===`/${P}`);if(!n)return;let t=n.content,a=typeof t.text=="function"?await t.text():n.content.toString("utf8");xe(a)}var W={"Content-Type":"application/json"},Bt="sdk";function pe(e){let n=new URLSearchParams;e?.limit!==void 0&&n.set("limit",String(e.limit)),e?.cursor!==void 0&&n.set("cursor",e.cursor);let t=n.toString();return t?`?${t}`:""}function ze(e){let{getApi:n,processInput:t}=e;return{upload:async(a,l={})=>{if(!t)throw m.config("processInput function is not provided.");let c=n(),h=await t(a,l),y=await Ge(h,c,l);if(!y.length)throw m.business("No files to deploy");for(let F of y)if(!F.md5)throw m.file(`MD5 checksum missing for file: ${F.path}`,{filePath:F.path});le(l.password);let d=se(l.ttl),E=De(l.idempotencyKey),f=M(l.labels);await ke(y);let A=l.build||l.prerender||l.spa?{build:l.build,prerender:l.prerender,spa:l.spa}:void 0,_=await Me(y,{labels:f,via:l.via??Bt,password:l.password,ttl:d,flags:A,captcha:l.captcha});return c.request(c.deploy.endpoint,{method:"POST",body:_,...E?{headers:{[v.HEADER]:E}}:{},signal:l.signal||null},"Deploy",l.build||l.prerender?c.deploy.buildTimeout:c.deploy.timeout)},list:async a=>n().request(`${T.DEPLOYMENTS}${pe(a)}`,{method:"GET"},"List deployments"),get:async a=>n().request(T.DEPLOYMENT(encodeURIComponent(a)),{method:"GET"},"Get deployment"),set:async(a,l)=>n().request(T.DEPLOYMENT(encodeURIComponent(a)),{method:"PATCH",headers:W,body:JSON.stringify({labels:M(l.labels)})},"Update deployment labels"),delete:async a=>n().request(T.DEPLOYMENT(encodeURIComponent(a)),{method:"DELETE"},"Delete deployment")}}function Ke(e){let{getApi:n}=e;return{set:async(t,a={})=>{let l=M(a.labels),c={};a.deployment&&(c.deployment=a.deployment),l!==void 0&&(c.labels=l);let{data:h,status:y}=await n().requestWithStatus(T.DOMAIN(encodeURIComponent(t)),{method:"PUT",headers:W,body:JSON.stringify(c)},"Set domain");return{...h,isCreate:y===201}},list:async t=>n().request(`${T.DOMAINS}${pe(t)}`,{method:"GET"},"List domains"),get:async t=>n().request(T.DOMAIN(encodeURIComponent(t)),{method:"GET"},"Get domain"),delete:async t=>n().request(T.DOMAIN(encodeURIComponent(t)),{method:"DELETE"},"Delete domain"),verify:async t=>n().request(T.DOMAIN_VERIFY(encodeURIComponent(t)),{method:"POST"},"Verify domain"),validate:async t=>n().request(T.DOMAINS_VALIDATE,{method:"POST",headers:W,body:JSON.stringify({domain:t})},"Validate domain"),dns:async t=>n().request(T.DOMAIN_DNS(encodeURIComponent(t)),{method:"GET"},"Get domain DNS"),records:async t=>n().request(T.DOMAIN_RECORDS(encodeURIComponent(t)),{method:"GET"},"Get domain records"),share:async t=>n().request(T.DOMAIN_SHARE(encodeURIComponent(t)),{method:"GET"},"Get domain share")}}function qe(e){let{getApi:n}=e;return{get:async()=>n().request(T.ACCOUNT,{method:"GET"},"Get account")}}function Ve(e){let{getApi:n}=e;return{create:async(t={})=>{let a=se(t.ttl),l=M(t.labels),c={};return a!==void 0&&(c.ttl=a),l!==void 0&&(c.labels=l),n().request(T.TOKENS,{method:"POST",headers:W,body:JSON.stringify(c)},"Create token")},list:async t=>n().request(`${T.TOKENS}${pe(t)}`,{method:"GET"},"List tokens"),get:async t=>n().request(T.TOKEN(encodeURIComponent(t)),{method:"GET"},"Get token"),delete:async t=>n().request(T.TOKEN(encodeURIComponent(t)),{method:"DELETE"},"Delete token")}}var J=class{constructor(n={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(n={...n,apiUrl:n.apiUrl||void 0,token:n.token||void 0,caller:n.caller||void 0},this.clientOptions=n,n.caller!==void 0&&Oe(n.caller),n.token&&n.session)throw m.config("Provide either `token` or `session`, not both.");typeof n.token=="string"?(oe(n.token),this.credential=n.token):n.token&&(this.credential=n.token),this.http=new V({...n,getAuthHeaders:()=>this.getAuthHeaders()});let t={getApi:()=>this.http};this.deployments=ze({...t,processInput:async(a,l)=>(await this.ensureInitialized(),this.processInput(a,l))}),this.domains=Ke(t),this.account=qe(t),this.tokens=Ve(t)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.request(T.LIMITS,{method:"GET"},"Get limits")}catch(n){throw this.initPromise=null,n}}async ping(){return this.http.request(T.PING,{method:"GET"},"Ping")}async deploy(n,t){return this.deployments.upload(n,t)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(n,t){this.http.on(n,t)}off(n,t){this.http.off(n,t)}setHeaders(n){this.http.setGlobalHeaders(n)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(n){if(this.clientOptions.session)throw m.config("Provide either `token` or `session`, not both.");if(typeof n=="string"){if(!n)throw m.business("Invalid token provided. Token must be a non-empty string.");oe(n),this.credential=n;return}if(typeof n!="function")throw m.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=n}async getAuthHeaders(){if(this.credential===null)return{};let n=typeof this.credential=="function"?await this.credential():this.credential;if(!n)throw m.authentication("Token provider returned no token.");if(typeof n!="string")throw m.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${n}`}}};R();R();ce();de();ye();ge();j();Ee();function cr(e,n,t,a=!0){let l=e===1?n:t;return a?`${e} ${l}`:l}Ae();var Te=class extends J{async deploy(n,t){return super.deploy(n,t)}async processInput(n,t){if(!Array.isArray(n)||!n.every(l=>l instanceof File))throw m.business("Invalid input type for browser environment. Expected File[].");if(n.length===0)throw m.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(Ae(),it));return a(n,t,this.platformLimits??void 0)}},Ur=Te;export{_e as API_KEY,T as API_PATHS,tn as AUTH_BASE_PATH,Zt as AccountPlan,V as ApiHttp,ne as AuthMethod,C as CALLER,ae as DEFAULT_API,P as DEPLOYMENT_CONFIG_FILENAME,L as DEPLOY_FIELDS,we as DEPLOY_TOKEN,Wt as DeploymentStatus,mt as DeploymentVia,Jt as DomainStatus,g as ErrorType,D as FILE_VALIDATION_STATUS,D as FileValidationStatus,v as IDEMPOTENCY_KEY_CONSTRAINTS,Yt as JUNK_DIRECTORIES,O as LABEL_CONSTRAINTS,ve as LABEL_PATTERN,pn as MY_API_KEY_URL,Pe as OAUTH_TOKEN,on as OAuthScope,k as PASSWORD_CONSTRAINTS,un as PUBLIC_DEPLOYMENT_TTL_SECONDS,ln as SHIP_ENV,nn as SIGN_IN_RETURN_PARAM,K as SPA_CHECK_CONSTRAINTS,Ne as SPA_DEFAULT_CONFIG,Te as Ship,m as ShipError,G as TTL_CONSTRAINTS,x as TokenKind,Rt as UNBUILT_PROJECT_MARKERS,St as UNSAFE_FILENAME_CHARS,en as WEB_FILE_ACCEPT,Xn as __setTestEnvironment,nr as allValidFilesReady,xe as assertShipJsonSyntax,X as calculateMD5,Dt as classifyToken,qe as createAccountResource,ze as createDeploymentResource,Ke as createDomainResource,Ve as createTokenResource,Ur as default,yn as deserializeLabels,fn as extractSubdomain,Qe as filterJunk,Z as formatFileSize,dn as generateDeploymentUrl,mn as generateDomainUrl,je as getENV,Kt as getValidFiles,z as hasUnbuiltMarker,Le as hasUnsafeChars,Ie as isBlockedExtension,cn as isCustomDomain,an as isDeployment,Fe as isPlatformDomain,be as isShipError,Qt as normalizeVia,Xe as optimizeDeployPaths,cr as pluralize,rt as processFilesForBrowser,rn as readBearerValue,hn as serializeLabels,bt as validateApiKey,sn as validateApiUrl,Oe as validateCaller,et as validateDeployFile,Ze as validateDeployPath,It as validateDeployToken,me as validateFileName,tr as validateFiles,De as validateIdempotencyKey,Lt as validateOAuthToken,le as validatePassword,oe as validateToken,se as validateTtl};
1
+ var st=Object.create;var $=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var ct=(e,n,t)=>n in e?$(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var I=(e,n)=>()=>(e&&(n=e(e=0)),n);var Re=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),ft=(e,n)=>{for(var t in n)$(e,t,{get:n[t],enumerable:!0})},dt=(e,n,t,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of lt(n))!ut.call(e,l)&&l!==t&&$(e,l,{get:()=>n[l],enumerable:!(a=at(n,l))||a.enumerable});return e};var H=(e,n,t)=>(t=e!=null?st(pt(e)):{},dt(n||!e||!e.__esModule?$(t,"default",{value:e,enumerable:!0}):t,e));var B=(e,n,t)=>ct(e,typeof n!="symbol"?n+"":n,t);function Qt(e){if(!e||typeof e!="string")return;let n=e.trim().toLowerCase();return Object.values(mt).includes(n)?n:void 0}function De(e){if(e==null)return;if(typeof e!="string")throw m.validation("Idempotency key must be a string.");let n=e.trim();if(!n)throw m.validation("Idempotency key must not be empty.");if(n.length>v.MAX_LENGTH)throw m.validation(`Idempotency key must be at most ${v.MAX_LENGTH} characters.`);return n}function Et(e){let n=e.code;return n==="ERR_INVALID_URL"?!1:typeof n=="string"?!0:e instanceof TypeError?!/\burl\b/i.test(e.message):!1}function be(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function At(e){let n=e.replace(/\\/g,"/").split("/").pop()??"",t=n.lastIndexOf(".");return t<=0||t===n.length-1?null:n.slice(t+1).toLowerCase()}function Ie(e,n){let t=At(e);return t===null?!1:Array.isArray(n)?n.includes(t):n.has(t)}function Le(e){return St.test(e)}function z(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(t=>Rt.has(t))}function Dt(e){return e.startsWith(_e.PREFIX)?x.API_KEY:e.startsWith(we.PREFIX)?x.DEPLOY_TOKEN:e.startsWith(Pe.PREFIX)?x.OAUTH:x.OPAQUE}function rn(e){return e.slice(0,re.length).toLowerCase()!==re?null:e.slice(re.length)||null}function xe(e){let n=e.charCodeAt(0)===65279?e.slice(1):e,t;try{t=JSON.parse(n)}catch(a){throw m.config(`invalid JSON format in config: ${a.message}`,{filePath:P})}if(t===null||typeof t!="object"||Array.isArray(t))throw m.config(`${P} must contain a JSON object`,{filePath:P})}function ie(e,n,t){if(!e.startsWith(n.PREFIX))throw m.validation(`${t} must start with "${n.PREFIX}"`);if(e.length!==n.TOTAL_LENGTH)throw m.validation(`${t} must be ${n.TOTAL_LENGTH} characters total (${n.PREFIX} + ${n.HEX_LENGTH} hex chars)`);let a=e.slice(n.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${n.HEX_LENGTH}}$`,"i").test(a))throw m.validation(`${t} must contain ${n.HEX_LENGTH} hexadecimal characters after "${n.PREFIX}" prefix`)}function bt(e){ie(e,_e,"API key")}function It(e){ie(e,we,"Deploy token")}function Lt(e){ie(e,Pe,"OAuth access token")}function oe(e){switch(Dt(e)){case x.API_KEY:bt(e);return;case x.DEPLOY_TOKEN:It(e);return;case x.OAUTH:Lt(e);return;case x.OPAQUE:if(!e)throw m.validation("Token must be a non-empty string")}}function Oe(e){if(!e||e.length>C.MAX_LENGTH||!C.PATTERN.test(e))throw m.validation(`Caller must be 1-${C.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function sn(e){try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol))throw m.validation("API URL must use http:// or https:// protocol");if(n.pathname!=="/"&&n.pathname!=="")throw m.validation("API URL must not contain a path");if(n.search||n.hash)throw m.validation("API URL must not contain query parameters or fragments")}catch(n){throw be(n)?n:m.validation("API URL must be a valid URL")}}function an(e){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(e)}function se(e){if(e!=null){if(typeof e!="number"||!Number.isFinite(e))throw m.validation("TTL must be a number of seconds");if(!Number.isInteger(e))throw m.validation("TTL must be a whole number of seconds");if(e<G.MIN_SECONDS||e>G.MAX_SECONDS)throw m.validation(`TTL must be between ${G.MIN_SECONDS} and ${G.MAX_SECONDS} seconds`);return e}}function Fe(e,n){return e.endsWith(`.${n}`)}function cn(e,n){return!Fe(e,n)}function fn(e,n){return Fe(e,n)?e.slice(0,-(n.length+1)):null}function dn(e){return`https://${e}`}function mn(e){return`https://${e}`}function hn(e){return!e||e.length===0?null:JSON.stringify(e)}function yn(e){if(!e)return[];try{let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function le(e){if(e==null)return;if(typeof e!="string")throw m.validation("Password must be a string");let n=e.trim();if(n.length<k.MIN_LENGTH||n.length>k.MAX_LENGTH)throw m.validation(`Password must be between ${k.MIN_LENGTH} and ${k.MAX_LENGTH} characters`);return n}var Wt,mt,Jt,v,Zt,T,L,g,ht,te,yt,gt,m,Tt,en,St,Rt,tn,nn,ne,_e,we,Pe,C,x,re,on,P,Ne,K,G,ae,ln,pn,un,D,O,ve,k,R=I(()=>{"use strict";Wt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},mt={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc",CLD:"cld",CRS:"crs",API:"api"},Jt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},v={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};Zt={FREE:"free",PRO:"pro",TEAM:"team",SCALE:"scale",SPONSORED:"sponsored"},T={DEPLOYMENTS:"/deployments",DEPLOYMENT:e=>`/deployments/${e}`,DEPLOYMENT_CONFIG:e=>`/deployments/${e}/config`,DOMAINS:"/domains",DOMAIN:e=>`/domains/${e}`,DOMAIN_VERIFY:e=>`/domains/${e}/verify`,DOMAIN_DNS:e=>`/domains/${e}/dns`,DOMAIN_RECORDS:e=>`/domains/${e}/records`,DOMAIN_SHARE:e=>`/domains/${e}/share`,DOMAIN_PROPAGATION:e=>`/domains/${e}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:e=>`/tokens/${e}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PLANS:"/plans",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},L={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",TTL:"ttl",BUILD:"build",PRERENDER:"prerender",SPA:"spa",CAPTCHA:"captcha"},g={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Maintenance:"maintenance",Network:"network_error",Timeout:"timeout_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},ht=new Set([g.Network,g.Timeout,g.Cancelled,g.File,g.Config]),te={client:new Set([g.Business,g.Cancelled,g.Config,g.File,g.Forbidden,g.NotFound,g.RateLimit,g.Validation]),network:new Set([g.Network,g.Timeout]),auth:new Set([g.Authentication])},yt=new Set(Object.values(g).filter(e=>!ht.has(e))),gt=200;m=class e extends Error{constructor(t,a,l,c){super(a);B(this,"type");B(this,"status");B(this,"details");this.type=t,this.status=l,this.details=c,this.name="ShipError"}toResponse(){let t=this.details,a=this.type===g.Authentication&&t?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:a}}static async fromHttpResponse(t,a){let l,c,h;try{if(t.headers.get("content-type")?.includes("application/json")){let f=await t.json();if(f&&typeof f=="object"){let A=f;typeof A.message=="string"?l=A.message:typeof A.error=="string"&&(l=A.error),c=A.details,typeof A.error=="string"&&yt.has(A.error)&&(h=A.error)}}else{let f=(await t.text()).trim();f&&!f.startsWith("<")&&f.length<=gt&&(l=f)}}catch{}let y=t.headers.get("retry-after");if(y!==null){let E=y.trim(),f=/^\d+$/.test(E)?Number(E):Math.ceil((Date.parse(E)-Date.now())/1e3);if(Number.isFinite(f)&&f>=0){let A=c&&typeof c=="object"?c:{};A.retryAfter===void 0&&(c={...A,retryAfter:f})}}l=l||`${a||"Request"} failed with status ${t.status}`;let d=h??(t.status===401?g.Authentication:t.status===403?g.Forbidden:t.status===429?g.RateLimit:g.Api);return new e(d,l,t.status,c)}static fromFetchError(t,a){if(be(t))return t;let l=a||"Request",c=t?.name;return c==="AbortError"?e.cancelled(`${l} was cancelled`):c==="TimeoutError"?e.timeout(`${l} timed out`,{cause:t}):t instanceof Error?Et(t)?e.network(`${l} failed: ${t.message}`,{cause:t}):new e(g.Api,`${l} failed: ${t.message}`):new e(g.Api,`${l} failed: Unknown error`)}static validation(t,a){return new e(g.Validation,t,400,a)}static notFound(t,a){let l=a?`${t} ${a} not found`:`${t} not found`;return new e(g.NotFound,l,404)}static forbidden(t,a){return new e(g.Forbidden,t,403,a)}static rateLimit(t="Too many requests",a){return new e(g.RateLimit,t,429,a)}static authentication(t="Authentication required",a){return new e(g.Authentication,t,401,a)}static business(t,a=400,l){return new e(g.Business,t,a,l)}static network(t,a){return new e(g.Network,t,void 0,a)}static timeout(t,a){return new e(g.Timeout,t,void 0,a)}static cancelled(t,a){return new e(g.Cancelled,t,void 0,a)}static file(t,a){return new e(g.File,t,void 0,a)}static config(t,a){return new e(g.Config,t,void 0,a)}static api(t,a=500,l){return new e(g.Api,t,a,l)}static maintenance(t,a){return new e(g.Maintenance,t,503,a)}isClientError(){return te.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return te.network.has(this.type)}isAuthError(){return te.auth.has(this.type)}isType(t){return this.type===t}};Tt=["html","htm","xhtml","xml","txt","md","markdown","pdf","csv","json","jsonc","webmanifest","map","toml","yaml","yml","rss","atom","css","scss","sass","less","js","mjs","cjs","jsx","ts","tsx","wasm","vue","svelte","png","jpg","jpeg","gif","webp","avif","svg","ico","bmp","tif","tiff","heic","heif","woff","woff2","ttf","otf","eot","mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","mp4","webm","ogv","mov","m4v","avi","glb","gltf","usdz","vtt","srt","zip"],en=Tt.map(e=>`.${e}`).join(","),St=/[\x00-\x1f\x7f#?%\\<>"]/;Rt=new Set(["node_modules","package.json"]);tn="/auth",nn="signing-in",ne={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",SYSTEM:"system"},_e={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},we={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},Pe={PREFIX:"oauth-",HEX_LENGTH:32,TOTAL_LENGTH:38},C={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},x={API_KEY:ne.API_KEY,DEPLOY_TOKEN:ne.TOKEN,OAUTH:ne.OAUTH,OPAQUE:"opaque"};re="bearer ";on={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},P="ship.json",Ne={rewrites:[{source:"/(.*)",destination:"/index.html"}]},K={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};G={MIN_SECONDS:1,MAX_SECONDS:365*24*60*60};ae="https://api.shipstatic.com",ln={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},pn="https://my.shipstatic.com/api-key",un=4320*60,D={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};O={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},ve=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;k={MIN_LENGTH:6,MAX_LENGTH:128}});var He=Re((Ue,$e)=>{"use strict";(function(e){if(typeof Ue=="object")$e.exports=e();else if(typeof define=="function"&&define.amd)define(e);else{var n;try{n=window}catch{n=self}n.SparkMD5=e()}})(function(e){"use strict";var n=function(u,p){return u+p&4294967295},t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(u,p,i,r,s,o){return p=n(n(p,u),n(r,o)),n(p<<s|p>>>32-s,i)}function l(u,p){var i=u[0],r=u[1],s=u[2],o=u[3];i+=(r&s|~r&o)+p[0]-680876936|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[1]-389564586|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[2]+606105819|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[3]-1044525330|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+p[4]-176418897|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[5]+1200080426|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[6]-1473231341|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[7]-45705983|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+p[8]+1770035416|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[9]-1958414417|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[10]-42063|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[11]-1990404162|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+p[12]+1804603682|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[13]-40341101|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[14]-1502002290|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[15]+1236535329|0,r=(r<<22|r>>>10)+s|0,i+=(r&o|s&~o)+p[1]-165796510|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[6]-1069501632|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[11]+643717713|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[0]-373897302|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+p[5]-701558691|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[10]+38016083|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[15]-660478335|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[4]-405537848|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+p[9]+568446438|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[14]-1019803690|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[3]-187363961|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[8]+1163531501|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+p[13]-1444681467|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[2]-51403784|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[7]+1735328473|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[12]-1926607734|0,r=(r<<20|r>>>12)+s|0,i+=(r^s^o)+p[5]-378558|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[8]-2022574463|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[11]+1839030562|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[14]-35309556|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+p[1]-1530992060|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[4]+1272893353|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[7]-155497632|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[10]-1094730640|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+p[13]+681279174|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[0]-358537222|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[3]-722521979|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[6]+76029189|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+p[9]-640364487|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[12]-421815835|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[15]+530742520|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[2]-995338651|0,r=(r<<23|r>>>9)+s|0,i+=(s^(r|~o))+p[0]-198630844|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[7]+1126891415|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[14]-1416354905|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[5]-57434055|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+p[12]+1700485571|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[3]-1894986606|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[10]-1051523|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[1]-2054922799|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+p[8]+1873313359|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[15]-30611744|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[6]-1560198380|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[13]+1309151649|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+p[4]-145523070|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[11]-1120210379|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[2]+718787259|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[9]-343485551|0,r=(r<<21|r>>>11)+s|0,u[0]=i+u[0]|0,u[1]=r+u[1]|0,u[2]=s+u[2]|0,u[3]=o+u[3]|0}function c(u){var p=[],i;for(i=0;i<64;i+=4)p[i>>2]=u.charCodeAt(i)+(u.charCodeAt(i+1)<<8)+(u.charCodeAt(i+2)<<16)+(u.charCodeAt(i+3)<<24);return p}function h(u){var p=[],i;for(i=0;i<64;i+=4)p[i>>2]=u[i]+(u[i+1]<<8)+(u[i+2]<<16)+(u[i+3]<<24);return p}function y(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,s,o,b,w,N;for(r=64;r<=p;r+=64)l(i,c(u.substring(r-64,r)));for(u=u.substring(r-64),s=u.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<s;r+=1)o[r>>2]|=u.charCodeAt(r)<<(r%4<<3);if(o[r>>2]|=128<<(r%4<<3),r>55)for(l(i,o),r=0;r<16;r+=1)o[r]=0;return b=p*8,b=b.toString(16).match(/(.*?)(.{0,8})$/),w=parseInt(b[2],16),N=parseInt(b[1],16)||0,o[14]=w,o[15]=N,l(i,o),i}function d(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,s,o,b,w,N;for(r=64;r<=p;r+=64)l(i,h(u.subarray(r-64,r)));for(u=r-64<p?u.subarray(r-64):new Uint8Array(0),s=u.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<s;r+=1)o[r>>2]|=u[r]<<(r%4<<3);if(o[r>>2]|=128<<(r%4<<3),r>55)for(l(i,o),r=0;r<16;r+=1)o[r]=0;return b=p*8,b=b.toString(16).match(/(.*?)(.{0,8})$/),w=parseInt(b[2],16),N=parseInt(b[1],16)||0,o[14]=w,o[15]=N,l(i,o),i}function E(u){var p="",i;for(i=0;i<4;i+=1)p+=t[u>>i*8+4&15]+t[u>>i*8&15];return p}function f(u){var p;for(p=0;p<u.length;p+=1)u[p]=E(u[p]);return u.join("")}f(y("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(n=function(u,p){var i=(u&65535)+(p&65535),r=(u>>16)+(p>>16)+(i>>16);return r<<16|i&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(p,i){return p=p|0||0,p<0?Math.max(p+i,0):Math.min(p,i)}ArrayBuffer.prototype.slice=function(p,i){var r=this.byteLength,s=u(p,r),o=r,b,w,N,Se;return i!==e&&(o=u(i,r)),s>o?new ArrayBuffer(0):(b=o-s,w=new ArrayBuffer(b),N=new Uint8Array(w),Se=new Uint8Array(this,s,b),N.set(Se),w)}})();function A(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function _(u,p){var i=u.length,r=new ArrayBuffer(i),s=new Uint8Array(r),o;for(o=0;o<i;o+=1)s[o]=u.charCodeAt(o);return p?s:r}function F(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function ot(u,p,i){var r=new Uint8Array(u.byteLength+p.byteLength);return r.set(new Uint8Array(u)),r.set(new Uint8Array(p),u.byteLength),i?r:r.buffer}function U(u){var p=[],i=u.length,r;for(r=0;r<i-1;r+=2)p.push(parseInt(u.substr(r,2),16));return String.fromCharCode.apply(String,p)}function S(){this.reset()}return S.prototype.append=function(u){return this.appendBinary(A(u)),this},S.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var p=this._buff.length,i;for(i=64;i<=p;i+=64)l(this._hash,c(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},S.prototype.end=function(u){var p=this._buff,i=p.length,r,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o;for(r=0;r<i;r+=1)s[r>>2]|=p.charCodeAt(r)<<(r%4<<3);return this._finish(s,i),o=f(this._hash),u&&(o=U(o)),this.reset(),o},S.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},S.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},S.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},S.prototype._finish=function(u,p){var i=p,r,s,o;if(u[i>>2]|=128<<(i%4<<3),i>55)for(l(this._hash,u),i=0;i<16;i+=1)u[i]=0;r=this._length*8,r=r.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(r[2],16),o=parseInt(r[1],16)||0,u[14]=s,u[15]=o,l(this._hash,u)},S.hash=function(u,p){return S.hashBinary(A(u),p)},S.hashBinary=function(u,p){var i=y(u),r=f(i);return p?U(r):r},S.ArrayBuffer=function(){this.reset()},S.ArrayBuffer.prototype.append=function(u){var p=ot(this._buff.buffer,u,!0),i=p.length,r;for(this._length+=u.byteLength,r=64;r<=i;r+=64)l(this._hash,h(p.subarray(r-64,r)));return this._buff=r-64<i?new Uint8Array(p.buffer.slice(r-64)):new Uint8Array(0),this},S.ArrayBuffer.prototype.end=function(u){var p=this._buff,i=p.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s,o;for(s=0;s<i;s+=1)r[s>>2]|=p[s]<<(s%4<<3);return this._finish(r,i),o=f(this._hash),u&&(o=U(o)),this.reset(),o},S.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.ArrayBuffer.prototype.getState=function(){var u=S.prototype.getState.call(this);return u.buff=F(u.buff),u},S.ArrayBuffer.prototype.setState=function(u){return u.buff=_(u.buff,!0),S.prototype.setState.call(this,u)},S.ArrayBuffer.prototype.destroy=S.prototype.destroy,S.ArrayBuffer.prototype._finish=S.prototype._finish,S.ArrayBuffer.hash=function(u,p){var i=d(new Uint8Array(u)),r=f(i);return p?U(r):r},S})});var Y=Re((In,Be)=>{"use strict";Be.exports={}});async function Ct(e){let n=(await Promise.resolve().then(()=>H(He(),1))).default,t=new n.ArrayBuffer,a=2097152;for(let l=0;l<e.size;l+=a){let c=Math.min(l+a,e.size);t.append(await e.slice(l,c).arrayBuffer())}return{md5:t.end()}}async function Mt(e){let{createHash:n}=await Promise.resolve().then(()=>H(Y(),1)),t=n("md5");return t.update(e),{md5:t.digest("hex")}}async function Ut(e){let{createHash:n}=await Promise.resolve().then(()=>H(Y(),1)),{createReadStream:t}=await Promise.resolve().then(()=>H(Y(),1));return new Promise((a,l)=>{let c=n("md5"),h=t(e);h.on("error",y=>l(m.file(`Failed to read file for MD5: ${y.message}`,{filePath:e}))),h.on("data",y=>c.update(y)),h.on("end",()=>a({md5:c.digest("hex")}))})}async function X(e){if(e instanceof Blob)return Ct(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return Mt(e);if(typeof e=="string")return Ut(e);throw m.business("Invalid input for MD5 calculation")}var j=I(()=>{"use strict";R()});function Q(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ye=I(()=>{"use strict"});function Xe(e,n={}){if(n.flatten===!1)return e.map(a=>({path:Q(a),name:ue(a)}));let t=Gt(e);return e.map(a=>{let l=Q(a);if(t){let c=t.endsWith("/")?t:`${t}/`;l.startsWith(c)&&(l=l.substring(c.length))}return l||(l=ue(a)),{path:l,name:ue(a)}})}function Gt(e){if(!e.length)return"";let t=e.map(c=>Q(c)).map(c=>c.split("/")),a=[],l=Math.min(...t.map(c=>c.length));for(let c=0;c<l-1;c++){let h=t[0][c];if(t.every(y=>y[c]===h))a.push(h);else break}return a.join("/")}function ue(e){return e.split(/[/\\]/).pop()||e}var ce=I(()=>{"use strict";Ye()});function Xn(e){fe=e}function kt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function je(){return fe||kt()}var fe,de=I(()=>{"use strict";fe=null});function ee(e,n){return zt.find(t=>t.broken(e,n))}var zt,he=I(()=>{"use strict";R();ye();zt=[{name:"name",broken:({path:e})=>!me(e).valid,sentence:({path:e})=>me(e).reason??"Invalid file name"},{name:"extension",broken:({path:e},n)=>Ie(e,n.blockedExtensions??[]),sentence:({path:e})=>`File extension not allowed: "${e}"`},{name:"fileSize",broken:({size:e},n)=>e>n.maxFileSize,sentence:({path:e},n)=>`File "${e}" too large. Maximum ${Z(n.maxFileSize)} allowed`},{name:"totalSize",broken:({totalSize:e},n)=>e>n.maxTotalSize,sentence:({totalSize:e},n)=>`Total upload size too large. ${Z(e)} exceeds maximum of ${Z(n.maxTotalSize)}`}]});function Z(e,n=1){if(e===0)return"0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],l=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**l).toFixed(n))} ${a[l]}`}function me(e){if(Le(e))return{valid:!1,reason:"File name contains unsafe characters"};if(e.startsWith(" ")||e.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(e.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let n=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,t=e.split("/").pop()||e;return n.test(t)?{valid:!1,reason:"File name uses a reserved system name"}:e.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function tr(e,n){let t=[],a=[],l=[];if(e.length===0){let d={file:"(no files)",message:"At least one file must be provided"};return t.push(d),{files:[],validFiles:[],errors:t,warnings:[],canDeploy:!1}}for(let d of e)if(z(d.name))return t.push({file:d.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:e.map(E=>({...E,status:D.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:t,warnings:[],canDeploy:!1};if(e.length>n.maxFilesCount){let d={file:`(${e.length} files)`,message:`File count (${e.length}) exceeds limit of ${n.maxFilesCount}`};return t.push(d),{files:e.map(E=>({...E,status:D.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:t,warnings:[],canDeploy:!1}}let c=0;for(let d of e){let E=D.READY,f="Ready for upload";if(d.status===D.PROCESSING_ERROR)E=D.VALIDATION_FAILED,f=d.statusMessage||"File failed during processing",t.push({file:d.name,message:f});else if(d.size===0){E=D.EXCLUDED,f="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:d.name,message:f}),l.push({...d,status:E,statusMessage:f});continue}else if(d.size<0)E=D.VALIDATION_FAILED,f="File size must be positive",t.push({file:d.name,message:f});else if(!d.name||d.name.trim().length===0)E=D.VALIDATION_FAILED,f="File name cannot be empty",t.push({file:d.name||"(empty)",message:f});else if(d.name.includes("\0"))E=D.VALIDATION_FAILED,f="File name contains invalid characters (null byte)",t.push({file:d.name,message:f});else{let A={path:d.name,size:d.size,totalSize:c+d.size},_=ee(A,n);_?(E=D.VALIDATION_FAILED,f=_.sentence(A,n),t.push({file:_.name==="totalSize"?`(${e.length} files)`:d.name,message:f})):c=A.totalSize}l.push({...d,status:E,statusMessage:f})}t.length>0&&(l=l.map(d=>d.status===D.EXCLUDED?d:{...d,status:D.VALIDATION_FAILED,statusMessage:d.status===D.VALIDATION_FAILED?d.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=t.length===0?l.filter(d=>d.status===D.READY):[],y=t.length===0;return{files:l,validFiles:h,errors:t,warnings:a,canDeploy:y}}function Kt(e){return e.filter(n=>n.status===D.READY)}function nr(e){return Kt(e).length>0}var ye=I(()=>{"use strict";R();he()});function We(e){return Vt.test(e)}var qt,Vt,Je=I(()=>{"use strict";qt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],Vt=new RegExp(qt.join("|"))});function Qe(e,n){if(!e||e.length===0)return[];if(!n?.allowUnbuilt&&e.find(a=>a&&z(a)))throw m.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return e.filter(t=>{if(!t)return!1;let a=t.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let l=a[a.length-1];if(We(l))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(y=>h.toLowerCase()===y.toLowerCase()))return!1;return!0})}var Yt,ge=I(()=>{"use strict";R();Je();Yt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Ze(e,n){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw m.business(`Security error: Unsafe file path "${e}" for file: ${n}`)}function et(e,n){let t=ee(e,n);if(t)throw m.business(t.sentence(e,n))}var Ee=I(()=>{"use strict";R();he()});async function tt(e,n={},t){let a=!!(n.build||n.prerender),l=Xe(e.map(f=>f.path),{flatten:n.pathDetect!==!1}).map(f=>f.path),c=new Set(Qe(l,{allowUnbuilt:a})),h=e.map((f,A)=>({source:f,deployPath:l[A]})).filter(({deployPath:f})=>c.has(f));if(h.length===0)return[];let y=a?null:Xt(t),d=[],E=0;for(let{source:f,deployPath:A}of h){if(y&&Ze(A,f.origin),f.size===0)continue;y&&(E+=f.size,et({path:A,size:f.size,totalSize:E},y));let _=await f.read(),{md5:F}=await X(_);d.push({path:A,content:_,size:f.size,md5:F})}if(y&&d.length>y.maxFilesCount)throw m.business(`Too many files to deploy. Maximum allowed is ${y.maxFilesCount} files.`);return d}function Xt(e){if(!e)throw m.config("Platform limits not provided. Deploy-mode validation requires the limits argument \u2014 pass `ship.getLimits()` result.");return e}var nt=I(()=>{"use strict";R();ce();ge();j();Ee()});var it={};ft(it,{processFilesForBrowser:()=>rt});async function rt(e,n={},t){if(je()!=="browser")throw m.business("processFilesForBrowser can only be called in a browser environment.");return tt(e.map(a=>({path:a.webkitRelativePath||a.name,origin:a.name,size:a.size,read:async()=>a})),n,t)}var Ae=I(()=>{"use strict";R();nt();de()});R();R();R();var q=class{constructor(){this.handlers=new Map}on(n,t){this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n)?.add(t)}off(n,t){let a=this.handlers.get(n);a&&(a.delete(t),a.size===0&&this.handlers.delete(n))}emit(n,...t){let a=this.handlers.get(n);if(!a)return;let l=Array.from(a);for(let c of l)try{c(...t)}catch(h){a.delete(c),n!=="error"&&setTimeout(()=>{let y=h instanceof Error?h:new Error(String(h));this.emit("error",y,String(n))},0)}}};var _t=3e4,wt=2,Pt=300,Nt=2e3,xt=new Set([500,502,503,504]);function Ot(e,n){return new Promise((t,a)=>{if(n?.aborted){a(n.reason);return}let l=()=>{clearTimeout(h),n?.removeEventListener("abort",c)},c=()=>{l(),a(n?.reason)},h=setTimeout(()=>{l(),t()},e);n?.addEventListener("abort",c)})}var Ce=3e5,Ft=3e5,vt=Ce+Ft,V=class extends q{constructor(t){super();this.globalHeaders={};this.apiUrl=t.apiUrl||ae,this.getAuthHeadersCallback=t.getAuthHeaders,this.session=t.session??!1,this.caller=t.caller,this.timeout=t.timeout??_t,this.maxRetries=Math.max(0,t.maxRetries??wt),this.fetch=t.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:t.deployEndpoint||T.DEPLOYMENTS,timeout:t.timeout??Ce,buildTimeout:t.timeout??vt}}setGlobalHeaders(t){this.globalHeaders=t}async executeRequest(t,a,l,c=this.timeout){for(let h=0;;h++)try{return await this.attemptOnce(t,a,l,c)}catch(y){let d=m.fromFetchError(y,l);if(h>=this.maxRetries||!this.isRetryable(d,a))throw this.emit("error",d,t),d;this.emit("retry",d,t,h+1);let E=Math.min(Nt,Pt*2**h);try{await Ot(Math.random()*E,a.signal)}catch(f){let A=m.fromFetchError(f,l);throw this.emit("error",A,t),A}}}isRetryable(t,a){if(a.signal?.aborted||t.isType(g.Maintenance)||t.isType(g.Cancelled)||!(t.isNetworkError()||t.status!==void 0&&xt.has(t.status)))return!1;let c=(a.method??"GET").toUpperCase();return c==="GET"||c==="HEAD"?!0:c==="PUT"||c==="DELETE"?!1:this.hasIdempotencyKey(a.headers)}hasIdempotencyKey(t){if(!t)return!1;let a=v.HEADER.toLowerCase();return Object.keys(t).some(l=>l.toLowerCase()===a)}async attemptOnce(t,a,l,c=this.timeout){let h=()=>{};try{let y=await this.mergeHeaders(a.headers),d=this.createTimeoutSignal(a.signal,c);h=d.cleanup;let E={...a,headers:y,credentials:this.session&&!y.Authorization?"include":void 0,signal:d.signal};this.emit("request",t,E);let f=await this.fetch(t,E);if(h(),!f.ok)throw await m.fromHttpResponse(f,l);return this.emit("response",this.safeClone(f),t),{data:await this.parseResponse(this.safeClone(f)),status:f.status}}catch(y){throw h(),m.fromFetchError(y,l)}}async request(t,a,l,c){let{data:h}=await this.executeRequest(`${this.apiUrl}${t}`,a,l,c);return h}async requestWithStatus(t,a,l){return this.executeRequest(`${this.apiUrl}${t}`,a,l)}async mergeHeaders(t={}){return{...this.globalHeaders,...this.caller?{[C.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...t}}createTimeoutSignal(t,a=this.timeout){let l=new AbortController,c=setTimeout(()=>l.abort(new DOMException(`Timed out after ${a}ms`,"TimeoutError")),a),h=t?()=>l.abort(t.reason):void 0;return t&&h&&(t.addEventListener("abort",h),t.aborted&&l.abort(t.reason)),{signal:l.signal,cleanup:()=>{clearTimeout(c),t&&h&&t.removeEventListener("abort",h)}}}safeClone(t){try{return t.clone()}catch{return t}}async parseResponse(t){if(!(t.headers.get("Content-Length")==="0"||t.status===204))return t.json()}};R();R();async function Me(e,n={}){let{labels:t,via:a,password:l,ttl:c,flags:h,captcha:y}=n,d=new FormData,E=[];for(let f of e){if(typeof f.content=="string"||f.content===null||f.content===void 0)throw m.file(`Unsupported file.content type: ${f.path}`,{filePath:f.path});if(!f.md5)throw m.file(`File missing md5 checksum: ${f.path}`,{filePath:f.path});d.append(L.FILES,new File([f.content],f.path,{type:"application/octet-stream"})),E.push(f.md5)}return d.append(L.CHECKSUMS,JSON.stringify(E)),t&&t.length>0&&d.append(L.LABELS,JSON.stringify(t)),a&&d.append(L.VIA,a),l&&d.append(L.PASSWORD,l),c!==void 0&&d.append(L.TTL,String(c)),h?.build&&d.append(L.BUILD,"true"),h?.prerender&&d.append(L.PRERENDER,"true"),h?.spa&&d.append(L.SPA,"true"),y&&d.append(L.CAPTCHA,y),d}R();j();async function $t(){let e=JSON.stringify(Ne,null,2),n;typeof Buffer<"u"?n=Buffer.from(e,"utf-8"):n=new Blob([e],{type:"application/json"});let{md5:t}=await X(n);return{path:P,content:n,size:e.length,md5:t}}async function Ht(e,n){let t=e.find(h=>h.path===K.INDEX_FILE||h.path===`/${K.INDEX_FILE}`);if(!t||t.size>K.MAX_INDEX_BYTES)return!1;let a;if(typeof Buffer<"u"&&Buffer.isBuffer(t.content))a=t.content.toString("utf-8");else if(typeof Blob<"u"&&t.content instanceof Blob)a=await t.content.text();else if(typeof File<"u"&&t.content instanceof File)a=await t.content.text();else return!1;let l={files:e.map(h=>h.path),index:a};return(await n.request(T.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"SPA check")).isSPA}async function Ge(e,n,t){if(t.spaDetect===!1||t.spa||t.build||t.prerender||e.some(a=>a.path===P))return e;try{if(await Ht(e,n)){let l=await $t();return[...e,l]}}catch{}return e}R();R();function M(e){if(e==null)return;if(e.length===0)return e;if(e.length>O.MAX_COUNT)throw m.validation(`Maximum ${O.MAX_COUNT} labels allowed`);let n=e.map((a,l)=>{if(typeof a!="string")throw m.validation(`Label at index ${l} must be a string`);let c=a.trim().toLowerCase();if(c.length<O.MIN_LENGTH)throw m.validation(`Labels must be at least ${O.MIN_LENGTH} characters long`);if(c.length>O.MAX_LENGTH)throw m.validation(`Labels must be no more than ${O.MAX_LENGTH} characters long`);if(!ve.test(c))throw m.validation(`Labels must start and end with alphanumeric characters, with optional separators (${O.SEPARATORS}) between segments`);return c}),t=[...new Set(n)];if(t.length!==n.length)throw m.validation("Duplicate labels are not allowed");return t}async function ke(e){let n=e.find(l=>l.path===P||l.path===`/${P}`);if(!n)return;let t=n.content,a=typeof t.text=="function"?await t.text():n.content.toString("utf8");xe(a)}var W={"Content-Type":"application/json"},Bt="sdk";function pe(e){let n=new URLSearchParams;e?.limit!==void 0&&n.set("limit",String(e.limit)),e?.cursor!==void 0&&n.set("cursor",e.cursor);let t=n.toString();return t?`?${t}`:""}function ze(e){let{getApi:n,processInput:t}=e;return{upload:async(a,l={})=>{if(!t)throw m.config("processInput function is not provided.");let c=n(),h=await t(a,l),y=await Ge(h,c,l);if(!y.length)throw m.business("No files to deploy");for(let F of y)if(!F.md5)throw m.file(`MD5 checksum missing for file: ${F.path}`,{filePath:F.path});le(l.password);let d=se(l.ttl),E=De(l.idempotencyKey),f=M(l.labels);await ke(y);let A=l.build||l.prerender||l.spa?{build:l.build,prerender:l.prerender,spa:l.spa}:void 0,_=await Me(y,{labels:f,via:l.via??Bt,password:l.password,ttl:d,flags:A,captcha:l.captcha});return c.request(c.deploy.endpoint,{method:"POST",body:_,...E?{headers:{[v.HEADER]:E}}:{},signal:l.signal||null},"Deploy",l.build||l.prerender?c.deploy.buildTimeout:c.deploy.timeout)},list:async a=>n().request(`${T.DEPLOYMENTS}${pe(a)}`,{method:"GET"},"List deployments"),get:async a=>n().request(T.DEPLOYMENT(encodeURIComponent(a)),{method:"GET"},"Get deployment"),set:async(a,l)=>n().request(T.DEPLOYMENT(encodeURIComponent(a)),{method:"PATCH",headers:W,body:JSON.stringify({labels:M(l.labels)})},"Update deployment labels"),delete:async a=>n().request(T.DEPLOYMENT(encodeURIComponent(a)),{method:"DELETE"},"Delete deployment")}}function Ke(e){let{getApi:n}=e;return{set:async(t,a={})=>{let l=M(a.labels),c={};a.deployment&&(c.deployment=a.deployment),l!==void 0&&(c.labels=l);let{data:h,status:y}=await n().requestWithStatus(T.DOMAIN(encodeURIComponent(t)),{method:"PUT",headers:W,body:JSON.stringify(c)},"Set domain");return{...h,isCreate:y===201}},list:async t=>n().request(`${T.DOMAINS}${pe(t)}`,{method:"GET"},"List domains"),get:async t=>n().request(T.DOMAIN(encodeURIComponent(t)),{method:"GET"},"Get domain"),delete:async t=>n().request(T.DOMAIN(encodeURIComponent(t)),{method:"DELETE"},"Delete domain"),verify:async t=>n().request(T.DOMAIN_VERIFY(encodeURIComponent(t)),{method:"POST"},"Verify domain"),validate:async t=>n().request(T.DOMAINS_VALIDATE,{method:"POST",headers:W,body:JSON.stringify({domain:t})},"Validate domain"),dns:async t=>n().request(T.DOMAIN_DNS(encodeURIComponent(t)),{method:"GET"},"Get domain DNS"),records:async t=>n().request(T.DOMAIN_RECORDS(encodeURIComponent(t)),{method:"GET"},"Get domain records"),share:async t=>n().request(T.DOMAIN_SHARE(encodeURIComponent(t)),{method:"GET"},"Get domain share")}}function qe(e){let{getApi:n}=e;return{get:async()=>n().request(T.ACCOUNT,{method:"GET"},"Get account")}}function Ve(e){let{getApi:n}=e;return{create:async(t={})=>{let a=se(t.ttl),l=M(t.labels),c={};return a!==void 0&&(c.ttl=a),l!==void 0&&(c.labels=l),n().request(T.TOKENS,{method:"POST",headers:W,body:JSON.stringify(c)},"Create token")},list:async t=>n().request(`${T.TOKENS}${pe(t)}`,{method:"GET"},"List tokens"),get:async t=>n().request(T.TOKEN(encodeURIComponent(t)),{method:"GET"},"Get token"),delete:async t=>n().request(T.TOKEN(encodeURIComponent(t)),{method:"DELETE"},"Delete token")}}var J=class{constructor(n={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(n={...n,apiUrl:n.apiUrl||void 0,token:n.token||void 0,caller:n.caller||void 0},this.clientOptions=n,n.caller!==void 0&&Oe(n.caller),n.token&&n.session)throw m.config("Provide either `token` or `session`, not both.");typeof n.token=="string"?(oe(n.token),this.credential=n.token):n.token&&(this.credential=n.token),this.http=new V({...n,getAuthHeaders:()=>this.getAuthHeaders()});let t={getApi:()=>this.http};this.deployments=ze({...t,processInput:async(a,l)=>(await this.ensureInitialized(),this.processInput(a,l))}),this.domains=Ke(t),this.account=qe(t),this.tokens=Ve(t)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.request(T.LIMITS,{method:"GET"},"Get limits")}catch(n){throw this.initPromise=null,n}}async ping(){return this.http.request(T.PING,{method:"GET"},"Ping")}async deploy(n,t){return this.deployments.upload(n,t)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(n,t){this.http.on(n,t)}off(n,t){this.http.off(n,t)}setHeaders(n){this.http.setGlobalHeaders(n)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(n){if(this.clientOptions.session)throw m.config("Provide either `token` or `session`, not both.");if(typeof n=="string"){if(!n)throw m.business("Invalid token provided. Token must be a non-empty string.");oe(n),this.credential=n;return}if(typeof n!="function")throw m.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=n}async getAuthHeaders(){if(this.credential===null)return{};let n=typeof this.credential=="function"?await this.credential():this.credential;if(!n)throw m.authentication("Token provider returned no token.");if(typeof n!="string")throw m.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${n}`}}};R();R();ce();de();ye();ge();j();Ee();function cr(e,n,t,a=!0){let l=e===1?n:t;return a?`${e} ${l}`:l}Ae();var Te=class extends J{async deploy(n,t){return super.deploy(n,t)}async processInput(n,t){if(!Array.isArray(n)||!n.every(l=>l instanceof File))throw m.business("Invalid input type for browser environment. Expected File[].");if(n.length===0)throw m.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(Ae(),it));return a(n,t,this.platformLimits??void 0)}},Ur=Te;export{_e as API_KEY,T as API_PATHS,tn as AUTH_BASE_PATH,Zt as AccountPlan,V as ApiHttp,ne as AuthMethod,C as CALLER,ae as DEFAULT_API,P as DEPLOYMENT_CONFIG_FILENAME,L as DEPLOY_FIELDS,we as DEPLOY_TOKEN,Wt as DeploymentStatus,mt as DeploymentVia,Jt as DomainStatus,g as ErrorType,D as FILE_VALIDATION_STATUS,D as FileValidationStatus,v as IDEMPOTENCY_KEY_CONSTRAINTS,Yt as JUNK_DIRECTORIES,O as LABEL_CONSTRAINTS,ve as LABEL_PATTERN,pn as MY_API_KEY_URL,Pe as OAUTH_TOKEN,on as OAuthScope,k as PASSWORD_CONSTRAINTS,un as PUBLIC_DEPLOYMENT_TTL_SECONDS,ln as SHIP_ENV,nn as SIGN_IN_RETURN_PARAM,K as SPA_CHECK_CONSTRAINTS,Ne as SPA_DEFAULT_CONFIG,Te as Ship,m as ShipError,G as TTL_CONSTRAINTS,x as TokenKind,Rt as UNBUILT_PROJECT_MARKERS,St as UNSAFE_FILENAME_CHARS,en as WEB_FILE_ACCEPT,Xn as __setTestEnvironment,nr as allValidFilesReady,xe as assertShipJsonSyntax,X as calculateMD5,Dt as classifyToken,qe as createAccountResource,ze as createDeploymentResource,Ke as createDomainResource,Ve as createTokenResource,Ur as default,yn as deserializeLabels,fn as extractSubdomain,Qe as filterJunk,Z as formatFileSize,dn as generateDeploymentUrl,mn as generateDomainUrl,je as getENV,Kt as getValidFiles,z as hasUnbuiltMarker,Le as hasUnsafeChars,Ie as isBlockedExtension,cn as isCustomDomain,an as isDeployment,Fe as isPlatformDomain,be as isShipError,Qt as normalizeVia,Xe as optimizeDeployPaths,cr as pluralize,rt as processFilesForBrowser,rn as readBearerValue,hn as serializeLabels,bt as validateApiKey,sn as validateApiUrl,Oe as validateCaller,et as validateDeployFile,Ze as validateDeployPath,It as validateDeployToken,me as validateFileName,tr as validateFiles,De as validateIdempotencyKey,Lt as validateOAuthToken,le as validatePassword,oe as validateToken,se as validateTtl};
2
2
  //# sourceMappingURL=browser.js.map