@maytes/checkout-button 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,37 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2](https://github.com/kttipay/maytes-checkout-button/pull/2) [`e5b8e63`](https://github.com/kttipay/maytes-checkout-button/commit/e5b8e6399dd33e0b3b24131d9f808ebd8eae44ef) Thanks [@kos-maytes](https://github.com/kos-maytes)! - `destroy()` no longer force-closes a popup that has already navigated to the checkout URL. Previously it would close any open popup unconditionally, which could kill an in-progress checkout if the host page called `destroy()` while the popup was still completing (e.g. reacting to its own payment-status polling). A popup is now only auto-closed while it's still on the blank loading screen, before checkout has started.
8
+
9
+ <!-- @hash-sri-start -->
10
+
11
+ **SRI hashes** (use these in `<script integrity="..." crossorigin="anonymous">`):
12
+
13
+ ```
14
+ checkout-button.js sha384-scp0qo7rcOJGuuI+gpadCOUQMn7g7hx3lqY9p7Xr2fd7/9Sb/L79DaHKStTTX7Ko
15
+ checkout-button.mjs sha384-5+TplHKGAk10ajWGdKwpG3pKutLD+v3cOYqtPEvRNLWudyOELPUKuU6sqlAhuy1h
16
+ checkout-button.cjs sha384-+O2S6KfO4Pc0VEvL+kTsFzxU14W4EILV6+U5mAdW8X43Xm8Qk1aV0y/KbM3Fnp9M
17
+ ```
18
+
19
+ **SemVer CDN links** (readable production pins; use with the SRI hashes above):
20
+
21
+ - [checkout-button.js](https://js.maytes.co/v1.0.1/checkout-button.js)
22
+ - [checkout-button.mjs](https://js.maytes.co/v1.0.1/checkout-button.mjs)
23
+ - [checkout-button.cjs](https://js.maytes.co/v1.0.1/checkout-button.cjs)
24
+
25
+ **Hashed CDN links** (byte-level production pins; use with the SRI hashes above):
26
+
27
+ - [checkout-button.8c71493e.js](https://js.maytes.co/checkout-button.8c71493e.js)
28
+ - [checkout-button.81ea2037.mjs](https://js.maytes.co/checkout-button.81ea2037.mjs)
29
+ - [checkout-button.6d259930.cjs](https://js.maytes.co/checkout-button.6d259930.cjs)
30
+
31
+ <!-- @hash-sri-end -->
3
32
  ## 1.0.0
4
33
 
5
- ### Major Changes
34
+ First public release on npm.
6
35
 
7
- - [`c17857f`](https://github.com/kttipay/checkout-button/commit/c17857fcb38bf045ae89fde207a1859ae12214e3) Thanks [@Merkost](https://github.com/Merkost)! - First public release on npm.
36
+ ### Major Changes
8
37
 
9
- The button is now installable as `@maytes/checkout-button` alongside the existing
10
- CDN `<script>` distribution — same package, same API, both fed from this source.
38
+ - **`@maytes/checkout-button` is now installable via npm**, alongside the existing CDN `<script>` distribution — same package, same API, both built from this repo.
11
39
 
12
- Framework apps (React, Angular, Vue, Svelte, plain bundled JS) should import the
13
- factory directly:
40
+ Framework apps (React, Angular, Vue, Svelte, plain bundled JS) should import the factory directly:
14
41
 
15
42
  ```ts
16
43
  import { Maytes } from "@maytes/checkout-button";
17
44
  ```
18
45
 
19
- That removes the script-injection dance those apps previously needed: no
20
- `window.Maytes` global to feature-detect, no polling for the CDN script to
21
- finish loading before mounting, and no hand-written `declare global` typings —
22
- the package ships its own `.d.ts`.
46
+ That removes the script-injection dance those apps previously needed: no `window.Maytes` global to feature-detect, no polling for the CDN script to finish loading before mounting, and no hand-written `declare global` typings — the package ships its own `.d.ts`.
23
47
 
24
- The `<script>` tag remains the right integration for no-build sites and jQuery,
25
- and is unchanged: pin a SemVer or content-hash URL with SRI in every environment,
26
- development included.
48
+ The `<script>` tag remains the right integration for no-build sites and jQuery, and is unchanged: pin a SemVer or content-hash URL with SRI in every environment, development included.
27
49
 
28
50
  ### Minor Changes
29
51
 
30
- - [`c17857f`](https://github.com/kttipay/checkout-button/commit/c17857fcb38bf045ae89fde207a1859ae12214e3) Thanks [@Merkost](https://github.com/Merkost)! - Brand the checkout button with the Maytes wordmark logo and maroon brand color, and make its size auto-scale from a single `--maytes-button-font-size` custom property (default 14px).
52
+ - Branded the checkout button with the Maytes wordmark logo and maroon brand colour, and made its size auto-scale from a single `--maytes-button-font-size` custom property (default 14px).
31
53
 
32
- - [`c17857f`](https://github.com/kttipay/checkout-button/commit/c17857fcb38bf045ae89fde207a1859ae12214e3) Thanks [@Merkost](https://github.com/Merkost)! - Add a launch `mode` to `renderButton` and a branded popup loading screen.
54
+ - Added a launch `mode` to `renderButton` and a branded popup loading screen.
33
55
 
34
- - `renderButton(container, { mode })` accepts `'redirect'` (new default) or `'popup'`. Invalid values throw `MaytesError(CONFIG)`.
56
+ - `renderButton(container, { mode })` accepts `'redirect'` (default) or `'popup'`. Invalid values throw `MaytesError(CONFIG)`.
35
57
  - `mode: 'popup'` opens a blank popup synchronously on click (preserving the user gesture so browsers do not block it), paints a branded Maytes loading screen into it (logo, spinner, `role="status"`/`aria-live`, a slow-network message that appears after ~8s, and a `prefers-reduced-motion` guard), then `popup.location.replace(url)`s once `createCheckout` resolves.
36
58
  - On mobile viewports `mode: 'popup'` behaves as a same-window redirect.
37
59
  - The misleading `maytes:checkout-failed` (`reason: 'popup-blocked'`) is replaced by a new `maytes:checkout-redirected` event (`detail.url`). A same-window redirect is a normal outcome, not a failure. The `failed` event now only carries `'create-checkout-rejected'` | `'invalid-shape'`.
@@ -40,21 +62,21 @@
40
62
 
41
63
  ### Patch Changes
42
64
 
43
- - [`c17857f`](https://github.com/kttipay/checkout-button/commit/c17857fcb38bf045ae89fde207a1859ae12214e3) Thanks [@Merkost](https://github.com/Merkost)! - Harden the checkout button popup lifecycle:
44
-
45
- - Open the hosted checkout URL exactly once (it was navigated twice — `window.open(url)` plus a redundant `location.href` write).
46
- - Give each SDK instance a unique popup window name so concurrent merchant tabs no longer share or steal one popup; this also removes the cross-origin `SecurityError` that could hang the overlay.
47
- - `destroy()` now detaches every button's click listener and is ignored by an in-flight `createCheckout` that resolves after teardown (no late popup).
48
- - Remove the cloned overlay `<style>` from the top document on teardown (same-origin iframe embeds).
49
- - Scope the injected style marker and ref-count by SDK version so two SDK versions on one page don't clash.
50
- - Clear the overlay immediately when the shopper presses Escape (was delayed up to one poll interval).
51
- - Validate that a merchant-supplied `checkoutUrl` is an `http(s)` URL before opening it — matching the protocol guard already applied to the constructed URL, so a buggy backend can't turn the button into a `javascript:`/`data:` popup.
65
+ **Popup lifecycle**
52
66
 
53
- - [`c17857f`](https://github.com/kttipay/checkout-button/commit/c17857fcb38bf045ae89fde207a1859ae12214e3) Thanks [@Merkost](https://github.com/Merkost)! - Take the Maytes brand colours from the design foundation (`kttipay/designsystem` v0.3.0, vendored by `npm run sync:foundation` and pinned in `foundation.lock.json`) instead of hand-written hexes. The only rendered change: the button's hover shade is now the foundation's burgundy/700 `#3B021D` (was `#3A021C`).
67
+ - Open the hosted checkout URL exactly once (it was navigated twice — `window.open(url)` plus a redundant `location.href` write).
68
+ - Give each SDK instance a unique popup window name so concurrent merchant tabs no longer share or steal one popup; this also removes the cross-origin `SecurityError` that could hang the overlay.
69
+ - `destroy()` now detaches every button's click listener and is ignored by an in-flight `createCheckout` that resolves after teardown (no late popup).
70
+ - Remove the cloned overlay `<style>` from the top document on teardown (same-origin iframe embeds).
71
+ - Scope the injected style marker and ref-count by SDK version so two SDK versions on one page don't clash.
72
+ - Clear the overlay immediately when the shopper presses Escape (was delayed up to one poll interval).
73
+ - Validate that a merchant-supplied `checkoutUrl` is an `http(s)` URL before opening it — matching the protocol guard already applied to the constructed URL, so a buggy backend can't turn the button into a `javascript:`/`data:` popup.
74
+ - Fixed a race in `mode: 'popup'`: if the shopper closed the popup while `createCheckout` was still in flight, the SDK would try to navigate (or, on rejection, report a failure for) a window that was already gone once the promise settled — on top of the `maytes:checkout-closed` event the close-poll had already fired. Both the success and rejection paths now check whether the popup is still open before acting, so closing the popup early produces exactly one `checkout-closed` event and nothing else.
54
75
 
55
- - [`c17857f`](https://github.com/kttipay/checkout-button/commit/c17857fcb38bf045ae89fde207a1859ae12214e3) Thanks [@Merkost](https://github.com/Merkost)! - Serve the CDN (IIFE) bundle minified, with a sourcemap. The ESM/CJS npm bundles stay unminified so the consumer's bundler can tree-shake them.
76
+ **Design & build**
56
77
 
57
- - [`c17857f`](https://github.com/kttipay/checkout-button/commit/c17857fcb38bf045ae89fde207a1859ae12214e3) Thanks [@Merkost](https://github.com/Merkost)! - Fix a race in `mode: 'popup'`: if the shopper closed the popup while `createCheckout` was still in flight, the SDK would try to navigate (or, on rejection, report a failure for) a window that was already gone once the promise settled — on top of the `maytes:checkout-closed` event the close-poll had already fired. Both the success and rejection paths now check whether the popup is still open before acting, so closing the popup early produces exactly one `checkout-closed` event and nothing else.
78
+ - Brand colours now come from the design foundation (`kttipay/designsystem` v0.3.0, vendored by `npm run sync:foundation` and pinned in `foundation.lock.json`) instead of hand-written hexes. The only rendered change: the button's hover shade is now the foundation's burgundy/700 `#3B021D` (was `#3A021C`).
79
+ - The CDN (IIFE) bundle now ships minified, with a sourcemap. The ESM/CJS npm bundles stay unminified so the consumer's bundler can tree-shake them.
58
80
 
59
81
  This project follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
60
82
 
package/README.md CHANGED
@@ -1,6 +1,40 @@
1
- # @maytes/checkout-button
1
+ <p align="center">
2
+ <img src=".github/logo.svg" height="32" alt="Maytes">
3
+ </p>
2
4
 
3
- Drop-in **Split with Maytes** button. Renders a button and launches the Maytes-hosted checkout. Default mode is same-window redirect; `mode: 'popup'` opts desktop browsers into a centered popup with a branded loader and redirect fallback on mobile or when blocked.
5
+ <h1 align="center">@maytes/checkout-button</h1>
6
+
7
+ <p align="center">
8
+ Drop-in <strong>Split with Maytes</strong> button — one script or import, and shoppers can split any checkout with friends.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@maytes/checkout-button"><img alt="npm version" src="https://img.shields.io/npm/v/@maytes/checkout-button?color=4A0324&label=npm"></a>
13
+ <a href="https://bundlephobia.com/package/@maytes/checkout-button"><img alt="bundle size" src="https://img.shields.io/bundlephobia/minzip/@maytes/checkout-button?color=FE572A&label=gzip"></a>
14
+ <a href="./CHANGELOG.md"><img alt="provenance" src="https://img.shields.io/badge/npm-provenance-4A0324"></a>
15
+ <a href="./LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-4A0324"></a>
16
+ <a href="https://developers.maytes.co/checkout-button"><img alt="docs" src="https://img.shields.io/badge/docs-developers.maytes.co-FE572A"></a>
17
+ </p>
18
+
19
+ ---
20
+
21
+ Renders a button and launches the Maytes-hosted checkout. Default mode is same-window redirect; `mode: 'popup'` opts desktop browsers into a centered popup with a branded loader and redirect fallback on mobile or when blocked.
22
+
23
+ **📖 Full integration guide:** [developers.maytes.co/checkout-button](https://developers.maytes.co/checkout-button)
24
+
25
+ - **Framework-agnostic** — same factory whether it's a `<script>` tag or `import { Maytes }`; no React/Vue/Angular binding to keep in sync.
26
+ - **Zero runtime dependencies** — a small, dependency-free bundle; ESM/CJS ship unminified so your bundler can tree-shake it.
27
+ - **CSP-safe by construction** — no `eval`, `Function`, or string-form timers; every release is scanned for it before shipping.
28
+ - **SRI-verified CDN** — pin a release by SemVer or content hash, both carrying the same integrity hash, published alongside every release.
29
+ - **Signed provenance** — every npm release carries a [SLSA](https://slsa.dev) provenance attestation back to this repo's build.
30
+
31
+ ## Contents
32
+
33
+ - [Install](#install)
34
+ - [Usage](#usage)
35
+ - [API](#api)
36
+ - [Mobile app](#mobile-app)
37
+ - [Development](#development)
4
38
 
5
39
  ## Install
6
40
 
@@ -20,7 +54,7 @@ For production, pin an exact release. The readable SemVer URL and the content-ha
20
54
  crossorigin="anonymous"></script>
21
55
  ```
22
56
 
23
- `v1.0.0` / `795d508b` are examples. The real version, hash, and SRI for each release live in [`CHANGELOG.md`](./CHANGELOG.md), the matching [release](https://github.com/kttipay/checkout-button/releases), and `https://js.maytes.co/integrity.json`.
57
+ `v1.0.0` / `795d508b` are examples. The real version, hash, and SRI for each release live in [`CHANGELOG.md`](./CHANGELOG.md), the matching [release](https://github.com/kttipay/maytes-checkout-button/releases), and `https://js.maytes.co/integrity.json`.
24
58
 
25
59
  Use a pinned URL in every environment, development included — pinning is what makes the bytes you tested the bytes your shoppers get.
26
60
 
@@ -69,7 +103,7 @@ Via the script tag, the same factory is available as the global `window.Maytes(.
69
103
  | `renderButton(container, options?)` | Render the button into `container`; returns a cleanup function. Options include `label`, `block`, and `mode: 'redirect' \| 'popup'`. |
70
104
  | `redirectToCheckout(options)` | Launch checkout directly (no button). |
71
105
  | `checkoutUrl(options)` | Build the hosted checkout URL. |
72
- | `destroy()` | Tear down the instance and its listeners. |
106
+ | `destroy()` | Tear down the instance and its listeners — call this on unmount or when the instance's config/environment changes, not as a reaction to detecting payment success from your own polling (that can tear down a checkout that's still in progress). To remove a single button, use the cleanup function returned by `renderButton()` or hide/disable the button element instead. |
73
107
 
74
108
  ## Mobile app
75
109
 
@@ -85,22 +119,8 @@ npm run test:run
85
119
  npm run build # bundles + SRI hashes + CSP scan
86
120
  ```
87
121
 
88
- Versioning and changelog are managed with [Changesets](./.changeset/README.md). Run `npm run changeset` with your PR.
89
-
90
- ## Brand colours come from the design foundation
91
-
92
- The Maytes brand colours the button paints (`brand.primary` burgundy, `brand.secondary` orange, the burgundy/700 hover shade, and the inverse text white) are **not hand-written** in this package. They are vendored from the design foundation — `kttipay/designsystem` `web/tokens.ts` — into `src/foundation/brand.generated.ts`, pinned to a release tag recorded in `foundation.lock.json`:
93
-
94
- ```json
95
- { "repo": "kttipay/designsystem", "tag": "v0.3.0", "source": "web/tokens.ts" }
96
- ```
97
-
98
- - `src/branding.ts`, `src/styles.ts` and `src/button.ts` read every brand colour from that generated module. Never type a Maytes hex into `src/`.
99
- - To move to a newer foundation release: `npm run sync:foundation -- --tag vX.Y.Z` (fetches the file at that tag with `gh api`, so you need a logged-in `gh`; `--from ../path/to/designsystem/web/tokens.ts` works offline). The script rewrites the generated module and the lock file. Commit both together.
100
- - A vitest test fails if the generated header's tag drifts from `foundation.lock.json`, so the file can only change through the script.
101
-
102
- The design-system repo does not publish an npm package yet. When it does (`@kttipay/foundation` on GitHub Packages), the upgrade path is to replace the vendored module with that dependency and delete the script and lock file.
122
+ Versioning and changelog are managed with [Changesets](./.changeset/README.md). Run `npm run changeset` with your PR. Brand colours are vendored, not hand-written — see [`RELEASING.md`](./RELEASING.md#brand-colours-come-from-the-design-foundation) for how that works.
103
123
 
104
124
  ## License
105
125
 
106
- MIT
126
+ [MIT](./LICENSE)
@@ -277,7 +277,7 @@ function makeRedirect(environment, baseUrlOverride) {
277
277
  }
278
278
 
279
279
  // src/version.ts
280
- var SDK_VERSION = "1.0.0";
280
+ var SDK_VERSION = "1.0.1";
281
281
 
282
282
  // src/styles.ts
283
283
  var STYLE_ATTR = "data-maytes-checkout-button";
@@ -654,6 +654,7 @@ function renderButton(state, container, options = {}) {
654
654
  const popup = shouldUsePopup ? openBlankPopup(state) : null;
655
655
  if (popup !== null) {
656
656
  state.popupWindow = popup;
657
+ state.popupNavigated = false;
657
658
  refocusPopup(popup);
658
659
  paintPopupLoadingScreen(popup, state.config.cspNonce);
659
660
  showOverlay(state);
@@ -682,6 +683,7 @@ function renderButton(state, container, options = {}) {
682
683
  result.checkoutId
683
684
  );
684
685
  if (popup !== null) {
686
+ state.popupNavigated = true;
685
687
  navigatePopup(popup, url);
686
688
  } else {
687
689
  if (shouldUsePopup) {
@@ -737,6 +739,7 @@ function createInstanceState(options, internal) {
737
739
  busy: false,
738
740
  overlayEl: null,
739
741
  popupWindow: null,
742
+ popupNavigated: false,
740
743
  popupName: generatePopupName(),
741
744
  popupPollHandle: null,
742
745
  destroyed: false,
@@ -789,7 +792,7 @@ var Maytes = (options, internal) => {
789
792
  state.destroyed = true;
790
793
  stopPopupPoll(state);
791
794
  hideOverlay(state);
792
- closePopupWindow(state.popupWindow);
795
+ if (!state.popupNavigated) closePopupWindow(state.popupWindow);
793
796
  state.popupWindow = null;
794
797
  state.busy = false;
795
798
  for (const teardown of [...state.teardowns]) teardown();
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/foundation/brand.generated.ts","../src/branding.ts","../src/errors.ts","../src/overlay.ts","../src/env.ts","../src/redirect.ts","../src/version.ts","../src/styles.ts","../src/button.ts","../src/state.ts","../src/maytes.ts"],"sourcesContent":["import { Maytes } from './maytes.js';\n\nif (typeof window !== 'undefined') {\n (window as unknown as { Maytes: typeof Maytes }).Maytes = Maytes;\n}\n\nexport { Maytes };\nexport { MaytesError, MaytesErrorCode } from './errors.js';\nexport type { MaytesErrorCodeValue } from './errors.js';\nexport type {\n CheckoutUrlOptions,\n CreateCheckoutFn,\n MaytesEnvironment,\n MaytesFactory,\n MaytesInternalOptions,\n MaytesOptions,\n MaytesSDK,\n RedirectOptions,\n RenderButtonCleanup,\n RenderButtonMode,\n RenderButtonOptions,\n} from './types.js';\nexport { SDK_VERSION } from './version.js';\n","// GENERATED by scripts/sync-foundation-tokens.mjs from kttipay/designsystem v0.3.0 web/tokens.ts — DO NOT EDIT. Refresh: npm run sync:foundation -- --tag vX.Y.Z\n\n// Subset of the foundation used by the checkout button and the mock showcase:\n// brand.primary <- colorsLight.brand.primary (burgundy/600)\n// brand.secondary <- colorsLight.brand.secondary (orange/500)\n// palette.burgundy.700 <- palette.burgundy.700 (hover shade for brand.primary)\n// palette.base.white <- palette.base.white\n// text.primaryInverse <- colorsLight.text.primaryInverse (text on brand.primary)\n\nexport const FOUNDATION_TAG = 'v0.3.0';\n\nexport const foundation = {\n brand: {\n primary: '#4A0324',\n secondary: '#FE572A',\n },\n palette: {\n burgundy: {\n 700: '#3B021D',\n },\n base: {\n white: '#FFFFFF',\n },\n },\n text: {\n primaryInverse: '#FFFFFF',\n },\n} as const;\n","import { foundation } from './foundation/brand.generated.js';\n\nexport const MAYTES_RICHE = foundation.brand.primary;\nexport const MAYTES_WALLET = foundation.brand.secondary;\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\nconst MAYTES_LOGO_PATHS: readonly string[] = [\n 'M392,6.11c-.3-1.61-1.72-2.79-3.38-2.79h-99.97c-1.66,0-3.09,1.19-3.38,2.79l-51.14,275.49c-.36,2.07,1.24,4.03,3.38,4.03h71.07c1.72,0,3.15-1.24,3.38-2.97l5.57-42.24c.23-1.72,1.66-2.97,3.38-2.97h32.45c1.72,0,3.15,1.24,3.38,2.97l5.57,42.24c.23,1.72,1.66,2.97,3.38,2.97h74.46c2.14,0,3.8-1.96,3.38-4.03L392,6.11ZM344.42,174.89h-14.59c-2.07,0-3.62-1.84-3.38-3.86l9.55-74.33c.06-.48.48-.83.95-.83s.89.35.95.83l9.91,74.33c.3,2.02-1.31,3.86-3.38,3.86h0Z',\n 'M218.86,3.32h-77.72c-1.48,0-2.85,1.01-3.27,2.44l-25.63,83.65c-.12.35-.41.6-.83.6s-.71-.23-.83-.6L84.9,5.76c-.41-1.42-1.78-2.44-3.27-2.44H3.44c-1.9,0-3.44,1.54-3.44,3.44v275.43c0,1.9,1.54,3.45,3.44,3.45h71.26c1.9,0,3.44-1.54,3.44-3.45v-77.3l-.83-51.44c0-.53.41-.95.95-.95.41,0,.77.3.89.71l14.42,59.62c.35,1.54,1.72,2.61,3.32,2.61h28.42c1.61,0,2.97-1.06,3.32-2.61l14.47-59.79c.12-.3.35-.53.71-.53.41,0,.71.3.71.71l-.42,51.67-.06.06v77.3c0,1.9,1.54,3.44,3.44,3.44h71.37c1.9,0,3.44-1.54,3.44-3.44V6.77c0-1.9-1.54-3.44-3.44-3.44h0Z',\n 'M1179.6,147c-9.73-11.8-20.71-21.12-47.76-38.44-27.06-16.91-31.69-23.26-31.69-31.68,0-6.76,3.8-11.39,10.56-11.39,8.19,0,14.18,10.44,15.43,26.28.18,2.14,2.13,3.74,4.27,3.26l63.66-14.12c1.6-.36,2.73-1.9,2.61-3.56-3.97-49.3-35-77.36-86.44-77.36-27.47,0-50.25,8.07-67.63,24.09-17.39,16.01-25.82,36.72-25.82,62.53,0,16.91,4.22,32.09,13.12,45.62,8.9,13.53,25.75,28.3,51.56,44.38,14.77,9.32,24.09,16.49,27.88,21.12,4.21,4.63,6.35,9.31,6.35,14.36,0,6.35-4.63,10.56-11.81,10.56-10.5,0-18.15-11.87-19.28-29.66-.12-2.25-2.31-3.91-4.51-3.26l-63.6,18.68c-1.55.42-2.55,1.84-2.43,3.44,1.78,22.84,11.03,41.41,26.88,55.65,16.49,14.36,36.77,21.53,64.24,21.53s50.32-7.59,67.64-23.26c17.74-15.66,26.64-36.37,26.64-61.28,0-22.01-6.35-40.58-19.87-57.49v-.02Z',\n 'M1002.33,3.32h-146.18c-1.9,0-3.44,1.54-3.44,3.44v275.49c0,1.9,1.54,3.44,3.44,3.44h146.18c1.9,0,3.44-1.54,3.44-3.44v-62.05c0-1.9-1.54-3.44-3.44-3.44h-63.3c-1.9,0-3.45-1.54-3.45-3.45v-34.58c0-1.9,1.54-3.44,3.45-3.44v.18h53.63c1.9,0,3.45-1.54,3.45-3.44v-57.84c0-1.9-1.55-3.44-3.45-3.44h-53.63c-1.9,0-3.45-1.54-3.45-3.44v-31.61c0-1.9,1.54-3.44,3.45-3.44h63.3c1.9,0,3.44-1.54,3.44-3.44V6.77c0-1.9-1.54-3.44-3.44-3.44Z',\n 'M840.22,6.77c0-1.9-1.54-3.44-3.44-3.44h-175.31c-1.9,0-3.45,1.54-3.45,3.44v62c0,1.9,1.54,3.44,3.45,3.44h41.77c1.9,0,3.44,1.54,3.44,3.44v206.62c0,1.9,1.54,3.45,3.44,3.45h78.14c1.9,0,3.45-1.54,3.45-3.45V75.7c0-1.9,1.54-3.44,3.45-3.44h41.77c1.9,0,3.44-1.54,3.44-3.44h-.12V6.77h-.02Z',\n 'M607.71,3.38l-.06-.06c-23.23,0-32.59,48.08-40.22,80.25-1.38,5.82-4.74,18.31-7.75,27.31-4.44,13.26-10.68,30.43-22.21,31.93-18.85,2.47-7.14-39.43-7.14-39.43l21.67-92.98c.84-3.6-1.92-7.02-5.58-7.02h-85.49c-3.12,0-5.64,2.46-5.71,5.64l-1.68,75.09c-.48,21.25,5.64,42.31,18.37,59.37,12.72,17.05,38.81,28,63.12,25.9,52.48-7.08,65.46-70.49,68.4-71.1,3.06-.64,2.56,9.3.84,22.15-2.2,16.42-8.46,32.1-18.52,45.27-5.3,6.95-11.13,12.9-16.55,16.37-32.96,22.51-95.69,9.48-122.4-2.7-3.66-1.68-7.75,1.02-7.75,5.04l16.39,83.98c0,.84.18,1.68.54,2.4,9.48,17.83,53.31,19.33,74.43,17.77,32.18-2.04,100.37-29.35,115.32-122.33,12.17-103.08-1.14-162.91-38.06-162.84l.02-.02Z',\n];\n\nexport function buildMaytesLogo(height: string, color: string): SVGSVGElement {\n const svg = document.createElementNS(SVG_NS, 'svg');\n svg.setAttribute('xmlns', SVG_NS);\n svg.setAttribute('viewBox', '0 0 1199.47 289.04');\n svg.style.height = height;\n svg.style.width = 'auto';\n svg.style.color = color;\n for (const d of MAYTES_LOGO_PATHS) {\n const path = document.createElementNS(SVG_NS, 'path');\n path.setAttribute('fill', 'currentColor');\n path.setAttribute('d', d);\n svg.appendChild(path);\n }\n return svg;\n}\n","export const MaytesErrorCode = {\n Config: 'CONFIG',\n} as const;\n\nexport type MaytesErrorCodeValue = (typeof MaytesErrorCode)[keyof typeof MaytesErrorCode];\n\nexport class MaytesError extends Error {\n readonly code: MaytesErrorCodeValue;\n\n constructor(code: MaytesErrorCodeValue, message: string) {\n super(message);\n this.code = code;\n this.name = 'MaytesError';\n }\n}\n","import { buildMaytesLogo, MAYTES_WALLET } from './branding.js';\nimport type { InstanceState } from './state.js';\n\nconst TITLE_ID = 'maytes-overlay-title';\nconst STYLE_MARKER = 'data-maytes-checkout-button-overlay-styles';\nconst NATIVE_BACKDROP_FALLBACK = 'rgba(0, 0, 0, 0.6)';\n\nfunction tryReadTopDocument(): Document | null {\n if (window.top === null || window.top === window) return null;\n try {\n const topDoc = window.top.document;\n return topDoc.body !== null ? topDoc : null;\n } catch (err) {\n if (!(err instanceof DOMException && err.name === 'SecurityError')) {\n console.warn('[maytes/checkout-button] unexpected error resolving overlay host', err);\n }\n return null;\n }\n}\n\nfunction resolveOverlayHost(): Document {\n return tryReadTopDocument() ?? document;\n}\n\nfunction ensureOverlayStylesInTopDocument(host: Document): void {\n if (host === document) return;\n if (host.querySelector(`style[${STYLE_MARKER}]`) !== null) return;\n const localStyle = document.head.querySelector('style[data-maytes-checkout-button]');\n if (localStyle === null) return;\n const copy = host.createElement('style');\n copy.setAttribute(STYLE_MARKER, '');\n const nonce = localStyle.getAttribute('nonce');\n if (nonce !== null) copy.setAttribute('nonce', nonce);\n copy.textContent = localStyle.textContent ?? '';\n host.head.appendChild(copy);\n}\n\nfunction buildOverlay(host: Document, state: InstanceState): HTMLDialogElement {\n const dialog = host.createElement('dialog');\n dialog.className = 'maytes-checkout-overlay';\n dialog.setAttribute('aria-labelledby', TITLE_ID);\n dialog.setAttribute('data-maytes-overlay', '');\n\n const content = host.createElement('div');\n content.className = 'maytes-checkout-overlay__content';\n\n const logoDiv = host.createElement('div');\n logoDiv.setAttribute('aria-hidden', 'true');\n logoDiv.appendChild(buildMaytesLogo('2.5rem', MAYTES_WALLET));\n content.appendChild(logoDiv);\n\n const spinner = host.createElement('div');\n spinner.className = 'maytes-checkout-overlay__spinner';\n spinner.setAttribute('role', 'status');\n spinner.setAttribute('aria-live', 'polite');\n spinner.setAttribute('aria-label', 'Checkout in progress');\n content.appendChild(spinner);\n\n const text = host.createElement('p');\n text.id = TITLE_ID;\n text.className = 'maytes-checkout-overlay__text';\n text.textContent = 'Completing checkout with Maytes…';\n content.appendChild(text);\n\n const link = host.createElement('button');\n link.className = 'maytes-checkout-overlay__link';\n link.type = 'button';\n link.textContent = 'Return to Maytes';\n link.addEventListener('click', () => {\n if (state.popupWindow !== null && !state.popupWindow.closed) {\n try { state.popupWindow.focus(); } catch (err) {\n if (!(err instanceof DOMException && err.name === 'SecurityError')) throw err;\n }\n }\n });\n content.appendChild(link);\n\n dialog.appendChild(content);\n\n dialog.addEventListener('cancel', (event) => {\n event.preventDefault();\n if (state.popupWindow !== null && !state.popupWindow.closed) state.popupWindow.close();\n hideOverlay(state);\n });\n\n return dialog;\n}\n\nfunction applyNativeBackdropFallback(dialog: HTMLDialogElement): void {\n dialog.style.background = NATIVE_BACKDROP_FALLBACK;\n}\n\nexport function showOverlay(state: InstanceState): void {\n if (state.overlayEl !== null) return;\n const host = resolveOverlayHost();\n ensureOverlayStylesInTopDocument(host);\n const dialog = buildOverlay(host, state);\n state.overlayEl = dialog;\n host.body.appendChild(dialog);\n if (typeof dialog.showModal === 'function') {\n try {\n dialog.showModal();\n } catch (err) {\n console.warn('[maytes/checkout-button] dialog.showModal failed; falling back to inline backdrop', err);\n dialog.setAttribute('open', '');\n applyNativeBackdropFallback(dialog);\n }\n } else {\n dialog.setAttribute('open', '');\n applyNativeBackdropFallback(dialog);\n }\n}\n\nexport function hideOverlay(state: InstanceState): void {\n if (state.overlayEl === null) return;\n const dialog = state.overlayEl;\n const host = dialog.ownerDocument;\n if (typeof dialog.close === 'function' && dialog.open) dialog.close();\n dialog.remove();\n if (host !== document) {\n host.head.querySelector(`style[${STYLE_MARKER}]`)?.remove();\n }\n state.overlayEl = null;\n}\n","import { MaytesError, MaytesErrorCode } from './errors.js';\nimport type { MaytesEnvironment } from './types.js';\n\nexport type InternalEnvironment = MaytesEnvironment | 'staging';\n\nconst ENVIRONMENT_BASE_URLS: Record<InternalEnvironment, string> = {\n staging: 'https://staging-checkout.maytes.co',\n sandbox: 'https://sandbox-checkout.maytes.co',\n production: 'https://checkout.maytes.co',\n};\n\nexport function isValidEnvironment(value: unknown): value is InternalEnvironment {\n return value === 'sandbox' || value === 'production' || value === 'staging';\n}\n\nexport function resolveBaseUrl(environment: InternalEnvironment, override: string | undefined): string {\n if (override !== undefined) return override;\n const url = ENVIRONMENT_BASE_URLS[environment];\n if (url === undefined) {\n throw new MaytesError(MaytesErrorCode.Config, `Unknown environment: ${String(environment)}`);\n }\n return url;\n}\n","import { MaytesError, MaytesErrorCode } from './errors.js';\nimport { resolveBaseUrl, type InternalEnvironment } from './env.js';\nimport type { CheckoutUrlOptions, RedirectOptions } from './types.js';\n\nexport function isHttpUrl(value: string): boolean {\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch {\n return false;\n }\n return parsed.protocol === 'https:' || parsed.protocol === 'http:';\n}\n\nexport function normalizeBaseUrl(rawBaseUrl: string): string {\n const candidate = rawBaseUrl.trim().replace(/\\/+$/, '');\n let parsed: URL;\n try {\n parsed = new URL(candidate);\n } catch {\n throw new MaytesError(MaytesErrorCode.Config, `baseUrl is not a valid URL: ${candidate}`);\n }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n `baseUrl must use http or https; got ${parsed.protocol}`,\n );\n }\n return candidate;\n}\n\nfunction requireCheckoutId(id: unknown): string {\n if (typeof id !== 'string' || id.trim().length === 0) {\n throw new MaytesError(MaytesErrorCode.Config, 'checkoutId is required (non-empty string)');\n }\n return id.trim();\n}\n\nexport function buildCheckoutUrl(\n environment: InternalEnvironment,\n baseUrlOverride: string | undefined,\n checkoutId: string,\n): string {\n const id = requireCheckoutId(checkoutId);\n const base = normalizeBaseUrl(resolveBaseUrl(environment, baseUrlOverride));\n return `${base}/?id=${encodeURIComponent(id)}`;\n}\n\nexport function performRedirect(url: string, replace: boolean): void {\n if (typeof window === 'undefined') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'redirectToCheckout requires a browser context (window is undefined)',\n );\n }\n if (replace) {\n window.location.replace(url);\n } else {\n window.location.href = url;\n }\n}\n\nexport function makeRedirect(\n environment: InternalEnvironment,\n baseUrlOverride: string | undefined,\n) {\n return {\n checkoutUrl(opts: CheckoutUrlOptions): string {\n return buildCheckoutUrl(environment, baseUrlOverride, opts.checkoutId);\n },\n redirectToCheckout(opts: RedirectOptions): void {\n const url = buildCheckoutUrl(environment, baseUrlOverride, opts.checkoutId);\n performRedirect(url, opts.replace === true);\n },\n };\n}\n","export const SDK_VERSION = '1.0.0';\n","import { foundation } from './foundation/brand.generated.js';\nimport { SDK_VERSION } from './version.js';\n\nconst STYLE_ATTR = 'data-maytes-checkout-button';\nconst STYLE_SELECTOR = `style[${STYLE_ATTR}=\"${SDK_VERSION}\"]`;\nconst REFCOUNT_KEY = `__maytes_checkout_button_styles_refs_${SDK_VERSION}__`;\n\ninterface RefCountWindow extends Window {\n [REFCOUNT_KEY]?: number;\n}\n\n// WEB-LOCAL: no foundation role (a11y focus ring); see MOB-994\nconst FOCUS_RING = '#6b8aff';\n\nconst BUTTON_CSS = `\n.maytes-checkout-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.57em;\n padding: 0.71em 1.29em;\n border: none;\n border-radius: 999px;\n background: ${foundation.brand.primary};\n color: ${foundation.text.primaryInverse};\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n font-size: var(--maytes-button-font-size, 14px);\n font-weight: 600;\n line-height: 1;\n cursor: pointer;\n user-select: none;\n transition: background-color 120ms ease, opacity 120ms ease;\n}\n.maytes-checkout-button:hover { background: ${foundation.palette.burgundy[700]}; }\n.maytes-checkout-button:focus-visible {\n outline: 2px solid ${FOCUS_RING};\n outline-offset: 2px;\n}\n.maytes-checkout-button[aria-disabled='true'] {\n cursor: progress;\n opacity: 0.7;\n}\n.maytes-checkout-button--block {\n display: flex;\n width: 100%;\n}\n.maytes-checkout-button__logo { height: 1em; width: auto; flex: none; }\n.maytes-checkout-button__spinner {\n height: 1em;\n width: 1em;\n border-radius: 50%;\n border: 0.14em solid currentColor;\n border-right-color: transparent;\n animation: maytes-checkout-button-spin 0.7s linear infinite;\n}\n@keyframes maytes-checkout-button-spin {\n to { transform: rotate(360deg); }\n}\n.maytes-checkout-overlay {\n position: fixed;\n inset: 0;\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n margin: 0;\n padding: 0;\n border: none;\n background: transparent;\n z-index: 2147483646;\n font: 500 15px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n}\n.maytes-checkout-overlay[open] {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.maytes-checkout-overlay::backdrop {\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(4px);\n -webkit-backdrop-filter: blur(4px);\n}\n.maytes-checkout-overlay__content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 1.5rem;\n}\n.maytes-checkout-overlay__spinner {\n width: 2.5rem;\n height: 2.5rem;\n border: 4px solid rgba(255, 255, 255, 0.3);\n border-top-color: ${foundation.brand.secondary};\n border-radius: 50%;\n animation: maytes-checkout-button-spin 0.8s linear infinite;\n}\n.maytes-checkout-overlay__text {\n color: ${foundation.text.primaryInverse};\n font-size: 1.125rem;\n font-weight: 500;\n margin: 0;\n}\n.maytes-checkout-overlay__link {\n color: rgba(255, 255, 255, 0.7);\n font-size: 0.875rem;\n text-decoration: underline;\n text-underline-offset: 4px;\n background: none;\n border: none;\n cursor: pointer;\n font-family: inherit;\n transition: color 0.15s;\n}\n.maytes-checkout-overlay__link:hover { color: ${foundation.text.primaryInverse}; }\n@media (prefers-reduced-motion: reduce) {\n .maytes-checkout-overlay__spinner,\n .maytes-checkout-button__spinner { animation: none; }\n}\n`;\n\nexport const POPUP_LOADING_CSS = `\n:root { color-scheme: light; }\nhtml, body { margin: 0; height: 100%; }\nbody.maytes-popup-loading {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: ${foundation.brand.primary};\n color: ${foundation.text.primaryInverse};\n font: 500 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n}\n.maytes-popup-loading__content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 1.5rem;\n padding: 2rem;\n text-align: center;\n}\n.maytes-popup-loading__logo { height: 2.75rem; width: auto; }\n.maytes-popup-loading__spinner {\n width: 2.5rem;\n height: 2.5rem;\n border: 4px solid rgba(255, 255, 255, 0.25);\n border-top-color: ${foundation.brand.secondary};\n border-radius: 50%;\n animation: maytes-checkout-button-spin 0.8s linear infinite;\n}\n@keyframes maytes-checkout-button-spin {\n to { transform: rotate(360deg); }\n}\n.maytes-popup-loading__text { margin: 0; font-size: 1.05rem; font-weight: 500; }\n.maytes-popup-loading__slow {\n margin: 0;\n font-size: 0.9rem;\n font-weight: 400;\n color: rgba(255, 255, 255, 0.75);\n max-width: 22rem;\n}\n.maytes-popup-loading__slow[hidden] { display: none; }\n@media (prefers-reduced-motion: reduce) {\n .maytes-popup-loading__spinner { animation: none; }\n}\n`;\n\nfunction getRefCount(): number {\n const w = window as RefCountWindow;\n return w[REFCOUNT_KEY] ?? 0;\n}\n\nfunction setRefCount(value: number): void {\n const w = window as RefCountWindow;\n w[REFCOUNT_KEY] = value;\n}\n\nexport function ensureStylesInjected(cspNonce: string | undefined): void {\n const next = getRefCount() + 1;\n setRefCount(next);\n if (document.head.querySelector(STYLE_SELECTOR) !== null) return;\n const el = document.createElement('style');\n el.setAttribute(STYLE_ATTR, SDK_VERSION);\n if (cspNonce !== undefined && cspNonce !== '') el.setAttribute('nonce', cspNonce);\n el.textContent = BUTTON_CSS;\n document.head.appendChild(el);\n}\n\nexport function releaseStyles(): void {\n const next = Math.max(0, getRefCount() - 1);\n setRefCount(next);\n if (next > 0) return;\n const el = document.head.querySelector(STYLE_SELECTOR);\n if (el !== null) el.remove();\n}\n\nexport function resetStylesForTests(): void {\n setRefCount(0);\n document.head.querySelectorAll(`style[${STYLE_ATTR}]`).forEach((el) => el.remove());\n}\n","import { buildMaytesLogo } from './branding.js';\nimport { foundation } from './foundation/brand.generated.js';\nimport { MaytesError, MaytesErrorCode } from './errors.js';\nimport { hideOverlay, showOverlay } from './overlay.js';\nimport { buildCheckoutUrl, isHttpUrl } from './redirect.js';\nimport { ensureStylesInjected, POPUP_LOADING_CSS, releaseStyles } from './styles.js';\nimport type { InstanceState } from './state.js';\nimport type { RenderButtonCleanup, RenderButtonMode, RenderButtonOptions } from './types.js';\n\nconst POPUP_WIDTH = 500;\nconst POPUP_HEIGHT = 800;\nconst POPUP_POLL_INTERVAL_MS = 500;\nconst MOBILE_MAX_WIDTH = 600;\nconst SLOW_NETWORK_DELAY_MS = 8000;\n\nfunction buildLogo(): SVGSVGElement {\n const svg = buildMaytesLogo('1em', 'currentColor');\n svg.setAttribute('class', 'maytes-checkout-button__logo');\n svg.setAttribute('aria-hidden', 'true');\n return svg;\n}\n\nfunction buildSpinner(): HTMLSpanElement {\n const spinner = document.createElement('span');\n spinner.className = 'maytes-checkout-button__spinner';\n spinner.setAttribute('aria-hidden', 'true');\n return spinner;\n}\n\nfunction isValidCheckoutResult(value: unknown): value is { checkoutId: string; checkoutUrl?: string } {\n if (typeof value !== 'object' || value === null) return false;\n const obj = value as { checkoutId?: unknown; checkoutUrl?: unknown };\n if (typeof obj.checkoutId !== 'string' || obj.checkoutId.trim().length === 0) return false;\n if (obj.checkoutUrl !== undefined) {\n if (typeof obj.checkoutUrl !== 'string' || obj.checkoutUrl.trim().length === 0) return false;\n if (!isHttpUrl(obj.checkoutUrl)) return false;\n }\n return true;\n}\n\nfunction isSecurityError(err: unknown): boolean {\n return err instanceof DOMException && err.name === 'SecurityError';\n}\n\nfunction refocusPopup(popup: Window): void {\n try { popup.focus(); } catch (err) {\n if (!isSecurityError(err)) throw err;\n }\n}\n\nexport function closePopupWindow(popup: Window | null): void {\n if (popup === null) return;\n try {\n if (!popup.closed) popup.close();\n } catch (err) {\n if (!isSecurityError(err)) throw err;\n }\n}\n\nfunction popupFeatures(): string {\n const screenWidth = window.screen?.width ?? POPUP_WIDTH;\n const screenHeight = window.screen?.height ?? POPUP_HEIGHT;\n const left = Math.max(0, Math.round((screenWidth - POPUP_WIDTH) / 2));\n const top = Math.max(0, Math.round((screenHeight - POPUP_HEIGHT) / 2));\n return `popup=yes,width=${POPUP_WIDTH},height=${POPUP_HEIGHT},left=${left},top=${top},resizable=yes,scrollbars=yes`;\n}\n\nexport function stopPopupPoll(state: InstanceState): void {\n if (state.popupPollHandle !== null) {\n clearInterval(state.popupPollHandle);\n state.popupPollHandle = null;\n }\n}\n\nfunction startPopupPoll(state: InstanceState, onClose: () => void): void {\n stopPopupPoll(state);\n state.popupPollHandle = setInterval(() => {\n const popup = state.popupWindow;\n if (popup === null || popup.closed) {\n stopPopupPoll(state);\n state.popupWindow = null;\n onClose();\n }\n }, POPUP_POLL_INTERVAL_MS);\n}\n\nfunction isMobileViewport(): boolean {\n return window.innerWidth <= MOBILE_MAX_WIDTH;\n}\n\nfunction openBlankPopup(state: InstanceState): Window | null {\n return window.open('about:blank', state.popupName, popupFeatures());\n}\n\nfunction navigatePopup(popup: Window, url: string): void {\n popup.location.replace(url);\n}\n\nfunction removePopupChildren(doc: Document): void {\n while (doc.body.firstChild !== null) doc.body.removeChild(doc.body.firstChild);\n}\n\nfunction paintPopupLoadingScreen(popup: Window, cspNonce: string | undefined): void {\n const doc = popup.document as Document | null;\n if (doc === null || doc.head === null || doc.body === null) return;\n doc.title = 'Maytes checkout';\n doc.documentElement.lang = 'en';\n const style = doc.createElement('style');\n if (cspNonce !== undefined && cspNonce !== '') style.setAttribute('nonce', cspNonce);\n style.textContent = POPUP_LOADING_CSS;\n doc.head.appendChild(style);\n\n doc.body.classList.add('maytes-popup-loading');\n removePopupChildren(doc);\n\n const content = doc.createElement('main');\n content.className = 'maytes-popup-loading__content';\n content.setAttribute('role', 'status');\n content.setAttribute('aria-live', 'polite');\n\n const logo = buildMaytesLogo('2.75rem', foundation.text.primaryInverse);\n logo.setAttribute('class', 'maytes-popup-loading__logo');\n logo.setAttribute('aria-hidden', 'true');\n content.appendChild(logo);\n\n const spinner = doc.createElement('div');\n spinner.className = 'maytes-popup-loading__spinner';\n spinner.setAttribute('aria-hidden', 'true');\n content.appendChild(spinner);\n\n const text = doc.createElement('p');\n text.className = 'maytes-popup-loading__text';\n text.textContent = 'Completing checkout with Maytes…';\n content.appendChild(text);\n\n const slow = doc.createElement('p');\n slow.className = 'maytes-popup-loading__slow';\n slow.hidden = true;\n slow.textContent = 'Still connecting. This can take a moment on slow networks.';\n content.appendChild(slow);\n\n doc.body.appendChild(content);\n setTimeout(() => { slow.hidden = false; }, SLOW_NETWORK_DELAY_MS);\n}\n\nexport function renderButton(\n state: InstanceState,\n container: HTMLElement,\n options: RenderButtonOptions = {},\n): RenderButtonCleanup {\n if (state.destroyed) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'renderButton() called on a destroyed Maytes instance',\n );\n }\n if (!(container instanceof HTMLElement)) {\n throw new MaytesError(MaytesErrorCode.Config, 'renderButton(container) requires an HTMLElement');\n }\n\n ensureStylesInjected(state.config.cspNonce);\n\n const label = options.label ?? 'Split with';\n const block = options.block === true;\n const mode: RenderButtonMode = options.mode ?? 'redirect';\n if (mode !== 'redirect' && mode !== 'popup') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n \"renderButton({ mode }) must be 'redirect' or 'popup'\",\n );\n }\n\n const button = document.createElement('button');\n button.type = 'button';\n button.className = block\n ? 'maytes-checkout-button maytes-checkout-button--block'\n : 'maytes-checkout-button';\n button.setAttribute('aria-label', `${label} Maytes`);\n\n const labelNode = document.createTextNode(`${label} `);\n const logo = buildLogo();\n button.appendChild(labelNode);\n button.appendChild(logo);\n\n const setBusy = (busy: boolean) => {\n state.busy = busy;\n if (busy) {\n button.setAttribute('aria-disabled', 'true');\n button.setAttribute('aria-busy', 'true');\n logo.replaceWith(buildSpinner());\n } else {\n button.removeAttribute('aria-disabled');\n button.removeAttribute('aria-busy');\n const currentIndicator = button.querySelector('.maytes-checkout-button__spinner, .maytes-checkout-button__logo');\n if (currentIndicator !== null) currentIndicator.replaceWith(buildLogo());\n }\n };\n\n const teardownActiveCheckout = () => {\n hideOverlay(state);\n setBusy(false);\n };\n\n const onPopupClosed = () => {\n teardownActiveCheckout();\n document.dispatchEvent(new CustomEvent('maytes:checkout-closed'));\n };\n\n const dispatchFailed = (reason: string, cause?: unknown): void => {\n document.dispatchEvent(new CustomEvent('maytes:checkout-failed', {\n detail: cause === undefined ? { reason } : { reason, cause },\n }));\n };\n\n const dispatchRedirected = (url: string): void => {\n document.dispatchEvent(new CustomEvent('maytes:checkout-redirected', { detail: { url } }));\n };\n\n const redirectSameWindow = (url: string): void => {\n teardownActiveCheckout();\n dispatchRedirected(url);\n window.location.href = url;\n };\n\n const closeOrphanPopup = (popup: Window | null): void => {\n closePopupWindow(popup);\n stopPopupPoll(state);\n if (state.popupWindow === popup) state.popupWindow = null;\n teardownActiveCheckout();\n };\n\n const handleClick = async (): Promise<void> => {\n if (state.busy || state.destroyed) return;\n setBusy(true);\n const shouldUsePopup = mode === 'popup' && !isMobileViewport();\n const popup = shouldUsePopup ? openBlankPopup(state) : null;\n if (popup !== null) {\n state.popupWindow = popup;\n refocusPopup(popup);\n paintPopupLoadingScreen(popup, state.config.cspNonce);\n showOverlay(state);\n document.dispatchEvent(new CustomEvent('maytes:checkout-opened'));\n startPopupPoll(state, onPopupClosed);\n }\n try {\n const result = await state.config.createCheckout();\n if (state.destroyed || (popup !== null && popup.closed)) {\n closePopupWindow(popup);\n return;\n }\n if (!isValidCheckoutResult(result)) {\n closeOrphanPopup(popup);\n const shapeError = new MaytesError(\n MaytesErrorCode.Config,\n 'createCheckout must resolve to { checkoutId: string, checkoutUrl?: http(s) URL }',\n );\n console.error(shapeError);\n dispatchFailed('invalid-shape', shapeError);\n return;\n }\n const url = result.checkoutUrl ?? buildCheckoutUrl(\n state.config.environment,\n state.config.baseUrl,\n result.checkoutId,\n );\n if (popup !== null) {\n navigatePopup(popup, url);\n } else {\n if (shouldUsePopup) {\n console.warn('[maytes/checkout-button] popup was blocked; falling back to same-window redirect');\n }\n redirectSameWindow(url);\n }\n } catch (err) {\n if (popup !== null && popup.closed) return;\n closeOrphanPopup(popup);\n console.error('[maytes/checkout-button] createCheckout failed:', err);\n dispatchFailed('create-checkout-rejected', err);\n }\n };\n\n button.addEventListener('click', handleClick);\n container.appendChild(button);\n\n let cleaned = false;\n const teardown = (): void => {\n if (cleaned) return;\n cleaned = true;\n button.removeEventListener('click', handleClick);\n button.remove();\n state.teardowns.delete(teardown);\n releaseStyles();\n };\n state.teardowns.add(teardown);\n\n return teardown;\n}\n","import type { MaytesOptions, MaytesInternalOptions } from './types.js';\n\nexport interface InstanceState {\n config: MaytesOptions & MaytesInternalOptions;\n busy: boolean;\n overlayEl: HTMLDialogElement | null;\n popupWindow: Window | null;\n popupName: string;\n popupPollHandle: ReturnType<typeof setInterval> | null;\n destroyed: boolean;\n teardowns: Set<() => void>;\n}\n\nfunction popupNameSuffix(): string {\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\nfunction generatePopupName(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n try {\n return `maytes-checkout-${crypto.randomUUID()}`;\n } catch {\n return `maytes-checkout-${popupNameSuffix()}`;\n }\n }\n return `maytes-checkout-${popupNameSuffix()}`;\n}\n\nexport function createInstanceState(\n options: MaytesOptions,\n internal: MaytesInternalOptions | undefined,\n): InstanceState {\n const config: MaytesOptions & MaytesInternalOptions = {\n createCheckout: options.createCheckout,\n environment: options.environment,\n };\n if (internal?.baseUrl !== undefined) config.baseUrl = internal.baseUrl;\n if (internal?.cspNonce !== undefined) config.cspNonce = internal.cspNonce;\n return {\n config,\n busy: false,\n overlayEl: null,\n popupWindow: null,\n popupName: generatePopupName(),\n popupPollHandle: null,\n destroyed: false,\n teardowns: new Set(),\n };\n}\n","import { closePopupWindow, renderButton, stopPopupPoll } from './button.js';\nimport { isValidEnvironment } from './env.js';\nimport { MaytesError, MaytesErrorCode } from './errors.js';\nimport { hideOverlay } from './overlay.js';\nimport { makeRedirect, normalizeBaseUrl } from './redirect.js';\nimport { createInstanceState } from './state.js';\nimport type {\n MaytesFactory,\n MaytesInternalOptions,\n MaytesOptions,\n MaytesSDK,\n} from './types.js';\n\nfunction validateOptions(options: MaytesOptions): void {\n if (typeof options !== 'object' || options === null) {\n throw new MaytesError(MaytesErrorCode.Config, 'Maytes() requires an options object');\n }\n if (typeof options.createCheckout !== 'function') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'Maytes({ createCheckout }) must be an async function returning { checkoutId }',\n );\n }\n if (!isValidEnvironment(options.environment)) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n \"Maytes({ environment }) must be 'sandbox' or 'production'\",\n );\n }\n}\n\nfunction validateInternalOptions(internal: MaytesInternalOptions | undefined): void {\n if (internal === undefined) return;\n if (internal.baseUrl !== undefined) normalizeBaseUrl(internal.baseUrl);\n}\n\nexport const Maytes: MaytesFactory = (options, internal) => {\n validateOptions(options);\n validateInternalOptions(internal);\n\n const state = createInstanceState(options, internal);\n const { checkoutUrl, redirectToCheckout } = makeRedirect(\n state.config.environment,\n state.config.baseUrl,\n );\n\n const sdk: MaytesSDK = {\n renderButton(container, opts) {\n return renderButton(state, container, opts);\n },\n redirectToCheckout(opts) {\n redirectToCheckout(opts);\n },\n checkoutUrl(opts) {\n return checkoutUrl(opts);\n },\n destroy() {\n if (state.destroyed) return;\n state.destroyed = true;\n stopPopupPoll(state);\n hideOverlay(state);\n closePopupWindow(state.popupWindow);\n state.popupWindow = null;\n state.busy = false;\n for (const teardown of [...state.teardowns]) teardown();\n state.teardowns.clear();\n },\n };\n\n return sdk;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,aAAa;AAAA,EACxB,OAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,SAAS;AAAA,IACP,UAAU;AAAA,MACR,KAAK;AAAA,IACP;AAAA,IACA,MAAM;AAAA,MACJ,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,gBAAgB;AAAA,EAClB;AACF;;;ACzBO,IAAM,eAAe,WAAW,MAAM;AACtC,IAAM,gBAAgB,WAAW,MAAM;AAE9C,IAAM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;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACA,MAAI,CAAC,mBAAmB,QAAQ,WAAW,GAAG;AAC5C,UAAM,IAAI;AAAA,MACR,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,wBAAwB,UAAmD;AAClF,MAAI,aAAa,OAAW;AAC5B,MAAI,SAAS,YAAY,OAAW,kBAAiB,SAAS,OAAO;AACvE;AAEO,IAAM,SAAwB,CAAC,SAAS,aAAa;AAC1D,kBAAgB,OAAO;AACvB,0BAAwB,QAAQ;AAEhC,QAAM,QAAQ,oBAAoB,SAAS,QAAQ;AACnD,QAAM,EAAE,aAAa,mBAAmB,IAAI;AAAA,IAC1C,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,EACf;AAEA,QAAM,MAAiB;AAAA,IACrB,aAAa,WAAW,MAAM;AAC5B,aAAO,aAAa,OAAO,WAAW,IAAI;AAAA,IAC5C;AAAA,IACA,mBAAmB,MAAM;AACvB,yBAAmB,IAAI;AAAA,IACzB;AAAA,IACA,YAAY,MAAM;AAChB,aAAO,YAAY,IAAI;AAAA,IACzB;AAAA,IACA,UAAU;AACR,UAAI,MAAM,UAAW;AACrB,YAAM,YAAY;AAClB,oBAAc,KAAK;AACnB,kBAAY,KAAK;AACjB,uBAAiB,MAAM,WAAW;AAClC,YAAM,cAAc;AACpB,YAAM,OAAO;AACb,iBAAW,YAAY,CAAC,GAAG,MAAM,SAAS,EAAG,UAAS;AACtD,YAAM,UAAU,MAAM;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;AXpEA,IAAI,OAAO,WAAW,aAAa;AACjC,EAAC,OAAgD,SAAS;AAC5D;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/foundation/brand.generated.ts","../src/branding.ts","../src/errors.ts","../src/overlay.ts","../src/env.ts","../src/redirect.ts","../src/version.ts","../src/styles.ts","../src/button.ts","../src/state.ts","../src/maytes.ts"],"sourcesContent":["import { Maytes } from './maytes.js';\n\nif (typeof window !== 'undefined') {\n (window as unknown as { Maytes: typeof Maytes }).Maytes = Maytes;\n}\n\nexport { Maytes };\nexport { MaytesError, MaytesErrorCode } from './errors.js';\nexport type { MaytesErrorCodeValue } from './errors.js';\nexport type {\n CheckoutUrlOptions,\n CreateCheckoutFn,\n MaytesEnvironment,\n MaytesFactory,\n MaytesInternalOptions,\n MaytesOptions,\n MaytesSDK,\n RedirectOptions,\n RenderButtonCleanup,\n RenderButtonMode,\n RenderButtonOptions,\n} from './types.js';\nexport { SDK_VERSION } from './version.js';\n","// GENERATED by scripts/sync-foundation-tokens.mjs from kttipay/designsystem v0.3.0 web/tokens.ts — DO NOT EDIT. Refresh: npm run sync:foundation -- --tag vX.Y.Z\n\n// Subset of the foundation used by the checkout button and the mock showcase:\n// brand.primary <- colorsLight.brand.primary (burgundy/600)\n// brand.secondary <- colorsLight.brand.secondary (orange/500)\n// palette.burgundy.700 <- palette.burgundy.700 (hover shade for brand.primary)\n// palette.base.white <- palette.base.white\n// text.primaryInverse <- colorsLight.text.primaryInverse (text on brand.primary)\n\nexport const FOUNDATION_TAG = 'v0.3.0';\n\nexport const foundation = {\n brand: {\n primary: '#4A0324',\n secondary: '#FE572A',\n },\n palette: {\n burgundy: {\n 700: '#3B021D',\n },\n base: {\n white: '#FFFFFF',\n },\n },\n text: {\n primaryInverse: '#FFFFFF',\n },\n} as const;\n","import { foundation } from './foundation/brand.generated.js';\n\nexport const MAYTES_RICHE = foundation.brand.primary;\nexport const MAYTES_WALLET = foundation.brand.secondary;\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\nconst MAYTES_LOGO_PATHS: readonly string[] = [\n 'M392,6.11c-.3-1.61-1.72-2.79-3.38-2.79h-99.97c-1.66,0-3.09,1.19-3.38,2.79l-51.14,275.49c-.36,2.07,1.24,4.03,3.38,4.03h71.07c1.72,0,3.15-1.24,3.38-2.97l5.57-42.24c.23-1.72,1.66-2.97,3.38-2.97h32.45c1.72,0,3.15,1.24,3.38,2.97l5.57,42.24c.23,1.72,1.66,2.97,3.38,2.97h74.46c2.14,0,3.8-1.96,3.38-4.03L392,6.11ZM344.42,174.89h-14.59c-2.07,0-3.62-1.84-3.38-3.86l9.55-74.33c.06-.48.48-.83.95-.83s.89.35.95.83l9.91,74.33c.3,2.02-1.31,3.86-3.38,3.86h0Z',\n 'M218.86,3.32h-77.72c-1.48,0-2.85,1.01-3.27,2.44l-25.63,83.65c-.12.35-.41.6-.83.6s-.71-.23-.83-.6L84.9,5.76c-.41-1.42-1.78-2.44-3.27-2.44H3.44c-1.9,0-3.44,1.54-3.44,3.44v275.43c0,1.9,1.54,3.45,3.44,3.45h71.26c1.9,0,3.44-1.54,3.44-3.45v-77.3l-.83-51.44c0-.53.41-.95.95-.95.41,0,.77.3.89.71l14.42,59.62c.35,1.54,1.72,2.61,3.32,2.61h28.42c1.61,0,2.97-1.06,3.32-2.61l14.47-59.79c.12-.3.35-.53.71-.53.41,0,.71.3.71.71l-.42,51.67-.06.06v77.3c0,1.9,1.54,3.44,3.44,3.44h71.37c1.9,0,3.44-1.54,3.44-3.44V6.77c0-1.9-1.54-3.44-3.44-3.44h0Z',\n 'M1179.6,147c-9.73-11.8-20.71-21.12-47.76-38.44-27.06-16.91-31.69-23.26-31.69-31.68,0-6.76,3.8-11.39,10.56-11.39,8.19,0,14.18,10.44,15.43,26.28.18,2.14,2.13,3.74,4.27,3.26l63.66-14.12c1.6-.36,2.73-1.9,2.61-3.56-3.97-49.3-35-77.36-86.44-77.36-27.47,0-50.25,8.07-67.63,24.09-17.39,16.01-25.82,36.72-25.82,62.53,0,16.91,4.22,32.09,13.12,45.62,8.9,13.53,25.75,28.3,51.56,44.38,14.77,9.32,24.09,16.49,27.88,21.12,4.21,4.63,6.35,9.31,6.35,14.36,0,6.35-4.63,10.56-11.81,10.56-10.5,0-18.15-11.87-19.28-29.66-.12-2.25-2.31-3.91-4.51-3.26l-63.6,18.68c-1.55.42-2.55,1.84-2.43,3.44,1.78,22.84,11.03,41.41,26.88,55.65,16.49,14.36,36.77,21.53,64.24,21.53s50.32-7.59,67.64-23.26c17.74-15.66,26.64-36.37,26.64-61.28,0-22.01-6.35-40.58-19.87-57.49v-.02Z',\n 'M1002.33,3.32h-146.18c-1.9,0-3.44,1.54-3.44,3.44v275.49c0,1.9,1.54,3.44,3.44,3.44h146.18c1.9,0,3.44-1.54,3.44-3.44v-62.05c0-1.9-1.54-3.44-3.44-3.44h-63.3c-1.9,0-3.45-1.54-3.45-3.45v-34.58c0-1.9,1.54-3.44,3.45-3.44v.18h53.63c1.9,0,3.45-1.54,3.45-3.44v-57.84c0-1.9-1.55-3.44-3.45-3.44h-53.63c-1.9,0-3.45-1.54-3.45-3.44v-31.61c0-1.9,1.54-3.44,3.45-3.44h63.3c1.9,0,3.44-1.54,3.44-3.44V6.77c0-1.9-1.54-3.44-3.44-3.44Z',\n 'M840.22,6.77c0-1.9-1.54-3.44-3.44-3.44h-175.31c-1.9,0-3.45,1.54-3.45,3.44v62c0,1.9,1.54,3.44,3.45,3.44h41.77c1.9,0,3.44,1.54,3.44,3.44v206.62c0,1.9,1.54,3.45,3.44,3.45h78.14c1.9,0,3.45-1.54,3.45-3.45V75.7c0-1.9,1.54-3.44,3.45-3.44h41.77c1.9,0,3.44-1.54,3.44-3.44h-.12V6.77h-.02Z',\n 'M607.71,3.38l-.06-.06c-23.23,0-32.59,48.08-40.22,80.25-1.38,5.82-4.74,18.31-7.75,27.31-4.44,13.26-10.68,30.43-22.21,31.93-18.85,2.47-7.14-39.43-7.14-39.43l21.67-92.98c.84-3.6-1.92-7.02-5.58-7.02h-85.49c-3.12,0-5.64,2.46-5.71,5.64l-1.68,75.09c-.48,21.25,5.64,42.31,18.37,59.37,12.72,17.05,38.81,28,63.12,25.9,52.48-7.08,65.46-70.49,68.4-71.1,3.06-.64,2.56,9.3.84,22.15-2.2,16.42-8.46,32.1-18.52,45.27-5.3,6.95-11.13,12.9-16.55,16.37-32.96,22.51-95.69,9.48-122.4-2.7-3.66-1.68-7.75,1.02-7.75,5.04l16.39,83.98c0,.84.18,1.68.54,2.4,9.48,17.83,53.31,19.33,74.43,17.77,32.18-2.04,100.37-29.35,115.32-122.33,12.17-103.08-1.14-162.91-38.06-162.84l.02-.02Z',\n];\n\nexport function buildMaytesLogo(height: string, color: string): SVGSVGElement {\n const svg = document.createElementNS(SVG_NS, 'svg');\n svg.setAttribute('xmlns', SVG_NS);\n svg.setAttribute('viewBox', '0 0 1199.47 289.04');\n svg.style.height = height;\n svg.style.width = 'auto';\n svg.style.color = color;\n for (const d of MAYTES_LOGO_PATHS) {\n const path = document.createElementNS(SVG_NS, 'path');\n path.setAttribute('fill', 'currentColor');\n path.setAttribute('d', d);\n svg.appendChild(path);\n }\n return svg;\n}\n","export const MaytesErrorCode = {\n Config: 'CONFIG',\n} as const;\n\nexport type MaytesErrorCodeValue = (typeof MaytesErrorCode)[keyof typeof MaytesErrorCode];\n\nexport class MaytesError extends Error {\n readonly code: MaytesErrorCodeValue;\n\n constructor(code: MaytesErrorCodeValue, message: string) {\n super(message);\n this.code = code;\n this.name = 'MaytesError';\n }\n}\n","import { buildMaytesLogo, MAYTES_WALLET } from './branding.js';\nimport type { InstanceState } from './state.js';\n\nconst TITLE_ID = 'maytes-overlay-title';\nconst STYLE_MARKER = 'data-maytes-checkout-button-overlay-styles';\nconst NATIVE_BACKDROP_FALLBACK = 'rgba(0, 0, 0, 0.6)';\n\nfunction tryReadTopDocument(): Document | null {\n if (window.top === null || window.top === window) return null;\n try {\n const topDoc = window.top.document;\n return topDoc.body !== null ? topDoc : null;\n } catch (err) {\n if (!(err instanceof DOMException && err.name === 'SecurityError')) {\n console.warn('[maytes/checkout-button] unexpected error resolving overlay host', err);\n }\n return null;\n }\n}\n\nfunction resolveOverlayHost(): Document {\n return tryReadTopDocument() ?? document;\n}\n\nfunction ensureOverlayStylesInTopDocument(host: Document): void {\n if (host === document) return;\n if (host.querySelector(`style[${STYLE_MARKER}]`) !== null) return;\n const localStyle = document.head.querySelector('style[data-maytes-checkout-button]');\n if (localStyle === null) return;\n const copy = host.createElement('style');\n copy.setAttribute(STYLE_MARKER, '');\n const nonce = localStyle.getAttribute('nonce');\n if (nonce !== null) copy.setAttribute('nonce', nonce);\n copy.textContent = localStyle.textContent ?? '';\n host.head.appendChild(copy);\n}\n\nfunction buildOverlay(host: Document, state: InstanceState): HTMLDialogElement {\n const dialog = host.createElement('dialog');\n dialog.className = 'maytes-checkout-overlay';\n dialog.setAttribute('aria-labelledby', TITLE_ID);\n dialog.setAttribute('data-maytes-overlay', '');\n\n const content = host.createElement('div');\n content.className = 'maytes-checkout-overlay__content';\n\n const logoDiv = host.createElement('div');\n logoDiv.setAttribute('aria-hidden', 'true');\n logoDiv.appendChild(buildMaytesLogo('2.5rem', MAYTES_WALLET));\n content.appendChild(logoDiv);\n\n const spinner = host.createElement('div');\n spinner.className = 'maytes-checkout-overlay__spinner';\n spinner.setAttribute('role', 'status');\n spinner.setAttribute('aria-live', 'polite');\n spinner.setAttribute('aria-label', 'Checkout in progress');\n content.appendChild(spinner);\n\n const text = host.createElement('p');\n text.id = TITLE_ID;\n text.className = 'maytes-checkout-overlay__text';\n text.textContent = 'Completing checkout with Maytes…';\n content.appendChild(text);\n\n const link = host.createElement('button');\n link.className = 'maytes-checkout-overlay__link';\n link.type = 'button';\n link.textContent = 'Return to Maytes';\n link.addEventListener('click', () => {\n if (state.popupWindow !== null && !state.popupWindow.closed) {\n try { state.popupWindow.focus(); } catch (err) {\n if (!(err instanceof DOMException && err.name === 'SecurityError')) throw err;\n }\n }\n });\n content.appendChild(link);\n\n dialog.appendChild(content);\n\n dialog.addEventListener('cancel', (event) => {\n event.preventDefault();\n if (state.popupWindow !== null && !state.popupWindow.closed) state.popupWindow.close();\n hideOverlay(state);\n });\n\n return dialog;\n}\n\nfunction applyNativeBackdropFallback(dialog: HTMLDialogElement): void {\n dialog.style.background = NATIVE_BACKDROP_FALLBACK;\n}\n\nexport function showOverlay(state: InstanceState): void {\n if (state.overlayEl !== null) return;\n const host = resolveOverlayHost();\n ensureOverlayStylesInTopDocument(host);\n const dialog = buildOverlay(host, state);\n state.overlayEl = dialog;\n host.body.appendChild(dialog);\n if (typeof dialog.showModal === 'function') {\n try {\n dialog.showModal();\n } catch (err) {\n console.warn('[maytes/checkout-button] dialog.showModal failed; falling back to inline backdrop', err);\n dialog.setAttribute('open', '');\n applyNativeBackdropFallback(dialog);\n }\n } else {\n dialog.setAttribute('open', '');\n applyNativeBackdropFallback(dialog);\n }\n}\n\nexport function hideOverlay(state: InstanceState): void {\n if (state.overlayEl === null) return;\n const dialog = state.overlayEl;\n const host = dialog.ownerDocument;\n if (typeof dialog.close === 'function' && dialog.open) dialog.close();\n dialog.remove();\n if (host !== document) {\n host.head.querySelector(`style[${STYLE_MARKER}]`)?.remove();\n }\n state.overlayEl = null;\n}\n","import { MaytesError, MaytesErrorCode } from './errors.js';\nimport type { MaytesEnvironment } from './types.js';\n\nexport type InternalEnvironment = MaytesEnvironment | 'staging';\n\nconst ENVIRONMENT_BASE_URLS: Record<InternalEnvironment, string> = {\n staging: 'https://staging-checkout.maytes.co',\n sandbox: 'https://sandbox-checkout.maytes.co',\n production: 'https://checkout.maytes.co',\n};\n\nexport function isValidEnvironment(value: unknown): value is InternalEnvironment {\n return value === 'sandbox' || value === 'production' || value === 'staging';\n}\n\nexport function resolveBaseUrl(environment: InternalEnvironment, override: string | undefined): string {\n if (override !== undefined) return override;\n const url = ENVIRONMENT_BASE_URLS[environment];\n if (url === undefined) {\n throw new MaytesError(MaytesErrorCode.Config, `Unknown environment: ${String(environment)}`);\n }\n return url;\n}\n","import { MaytesError, MaytesErrorCode } from './errors.js';\nimport { resolveBaseUrl, type InternalEnvironment } from './env.js';\nimport type { CheckoutUrlOptions, RedirectOptions } from './types.js';\n\nexport function isHttpUrl(value: string): boolean {\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch {\n return false;\n }\n return parsed.protocol === 'https:' || parsed.protocol === 'http:';\n}\n\nexport function normalizeBaseUrl(rawBaseUrl: string): string {\n const candidate = rawBaseUrl.trim().replace(/\\/+$/, '');\n let parsed: URL;\n try {\n parsed = new URL(candidate);\n } catch {\n throw new MaytesError(MaytesErrorCode.Config, `baseUrl is not a valid URL: ${candidate}`);\n }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n `baseUrl must use http or https; got ${parsed.protocol}`,\n );\n }\n return candidate;\n}\n\nfunction requireCheckoutId(id: unknown): string {\n if (typeof id !== 'string' || id.trim().length === 0) {\n throw new MaytesError(MaytesErrorCode.Config, 'checkoutId is required (non-empty string)');\n }\n return id.trim();\n}\n\nexport function buildCheckoutUrl(\n environment: InternalEnvironment,\n baseUrlOverride: string | undefined,\n checkoutId: string,\n): string {\n const id = requireCheckoutId(checkoutId);\n const base = normalizeBaseUrl(resolveBaseUrl(environment, baseUrlOverride));\n return `${base}/?id=${encodeURIComponent(id)}`;\n}\n\nexport function performRedirect(url: string, replace: boolean): void {\n if (typeof window === 'undefined') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'redirectToCheckout requires a browser context (window is undefined)',\n );\n }\n if (replace) {\n window.location.replace(url);\n } else {\n window.location.href = url;\n }\n}\n\nexport function makeRedirect(\n environment: InternalEnvironment,\n baseUrlOverride: string | undefined,\n) {\n return {\n checkoutUrl(opts: CheckoutUrlOptions): string {\n return buildCheckoutUrl(environment, baseUrlOverride, opts.checkoutId);\n },\n redirectToCheckout(opts: RedirectOptions): void {\n const url = buildCheckoutUrl(environment, baseUrlOverride, opts.checkoutId);\n performRedirect(url, opts.replace === true);\n },\n };\n}\n","export const SDK_VERSION = '1.0.1';\n","import { foundation } from './foundation/brand.generated.js';\nimport { SDK_VERSION } from './version.js';\n\nconst STYLE_ATTR = 'data-maytes-checkout-button';\nconst STYLE_SELECTOR = `style[${STYLE_ATTR}=\"${SDK_VERSION}\"]`;\nconst REFCOUNT_KEY = `__maytes_checkout_button_styles_refs_${SDK_VERSION}__`;\n\ninterface RefCountWindow extends Window {\n [REFCOUNT_KEY]?: number;\n}\n\n// WEB-LOCAL: no foundation role (a11y focus ring); see MOB-994\nconst FOCUS_RING = '#6b8aff';\n\nconst BUTTON_CSS = `\n.maytes-checkout-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.57em;\n padding: 0.71em 1.29em;\n border: none;\n border-radius: 999px;\n background: ${foundation.brand.primary};\n color: ${foundation.text.primaryInverse};\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n font-size: var(--maytes-button-font-size, 14px);\n font-weight: 600;\n line-height: 1;\n cursor: pointer;\n user-select: none;\n transition: background-color 120ms ease, opacity 120ms ease;\n}\n.maytes-checkout-button:hover { background: ${foundation.palette.burgundy[700]}; }\n.maytes-checkout-button:focus-visible {\n outline: 2px solid ${FOCUS_RING};\n outline-offset: 2px;\n}\n.maytes-checkout-button[aria-disabled='true'] {\n cursor: progress;\n opacity: 0.7;\n}\n.maytes-checkout-button--block {\n display: flex;\n width: 100%;\n}\n.maytes-checkout-button__logo { height: 1em; width: auto; flex: none; }\n.maytes-checkout-button__spinner {\n height: 1em;\n width: 1em;\n border-radius: 50%;\n border: 0.14em solid currentColor;\n border-right-color: transparent;\n animation: maytes-checkout-button-spin 0.7s linear infinite;\n}\n@keyframes maytes-checkout-button-spin {\n to { transform: rotate(360deg); }\n}\n.maytes-checkout-overlay {\n position: fixed;\n inset: 0;\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n margin: 0;\n padding: 0;\n border: none;\n background: transparent;\n z-index: 2147483646;\n font: 500 15px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n}\n.maytes-checkout-overlay[open] {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.maytes-checkout-overlay::backdrop {\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(4px);\n -webkit-backdrop-filter: blur(4px);\n}\n.maytes-checkout-overlay__content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 1.5rem;\n}\n.maytes-checkout-overlay__spinner {\n width: 2.5rem;\n height: 2.5rem;\n border: 4px solid rgba(255, 255, 255, 0.3);\n border-top-color: ${foundation.brand.secondary};\n border-radius: 50%;\n animation: maytes-checkout-button-spin 0.8s linear infinite;\n}\n.maytes-checkout-overlay__text {\n color: ${foundation.text.primaryInverse};\n font-size: 1.125rem;\n font-weight: 500;\n margin: 0;\n}\n.maytes-checkout-overlay__link {\n color: rgba(255, 255, 255, 0.7);\n font-size: 0.875rem;\n text-decoration: underline;\n text-underline-offset: 4px;\n background: none;\n border: none;\n cursor: pointer;\n font-family: inherit;\n transition: color 0.15s;\n}\n.maytes-checkout-overlay__link:hover { color: ${foundation.text.primaryInverse}; }\n@media (prefers-reduced-motion: reduce) {\n .maytes-checkout-overlay__spinner,\n .maytes-checkout-button__spinner { animation: none; }\n}\n`;\n\nexport const POPUP_LOADING_CSS = `\n:root { color-scheme: light; }\nhtml, body { margin: 0; height: 100%; }\nbody.maytes-popup-loading {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: ${foundation.brand.primary};\n color: ${foundation.text.primaryInverse};\n font: 500 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n}\n.maytes-popup-loading__content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 1.5rem;\n padding: 2rem;\n text-align: center;\n}\n.maytes-popup-loading__logo { height: 2.75rem; width: auto; }\n.maytes-popup-loading__spinner {\n width: 2.5rem;\n height: 2.5rem;\n border: 4px solid rgba(255, 255, 255, 0.25);\n border-top-color: ${foundation.brand.secondary};\n border-radius: 50%;\n animation: maytes-checkout-button-spin 0.8s linear infinite;\n}\n@keyframes maytes-checkout-button-spin {\n to { transform: rotate(360deg); }\n}\n.maytes-popup-loading__text { margin: 0; font-size: 1.05rem; font-weight: 500; }\n.maytes-popup-loading__slow {\n margin: 0;\n font-size: 0.9rem;\n font-weight: 400;\n color: rgba(255, 255, 255, 0.75);\n max-width: 22rem;\n}\n.maytes-popup-loading__slow[hidden] { display: none; }\n@media (prefers-reduced-motion: reduce) {\n .maytes-popup-loading__spinner { animation: none; }\n}\n`;\n\nfunction getRefCount(): number {\n const w = window as RefCountWindow;\n return w[REFCOUNT_KEY] ?? 0;\n}\n\nfunction setRefCount(value: number): void {\n const w = window as RefCountWindow;\n w[REFCOUNT_KEY] = value;\n}\n\nexport function ensureStylesInjected(cspNonce: string | undefined): void {\n const next = getRefCount() + 1;\n setRefCount(next);\n if (document.head.querySelector(STYLE_SELECTOR) !== null) return;\n const el = document.createElement('style');\n el.setAttribute(STYLE_ATTR, SDK_VERSION);\n if (cspNonce !== undefined && cspNonce !== '') el.setAttribute('nonce', cspNonce);\n el.textContent = BUTTON_CSS;\n document.head.appendChild(el);\n}\n\nexport function releaseStyles(): void {\n const next = Math.max(0, getRefCount() - 1);\n setRefCount(next);\n if (next > 0) return;\n const el = document.head.querySelector(STYLE_SELECTOR);\n if (el !== null) el.remove();\n}\n\nexport function resetStylesForTests(): void {\n setRefCount(0);\n document.head.querySelectorAll(`style[${STYLE_ATTR}]`).forEach((el) => el.remove());\n}\n","import { buildMaytesLogo } from './branding.js';\nimport { foundation } from './foundation/brand.generated.js';\nimport { MaytesError, MaytesErrorCode } from './errors.js';\nimport { hideOverlay, showOverlay } from './overlay.js';\nimport { buildCheckoutUrl, isHttpUrl } from './redirect.js';\nimport { ensureStylesInjected, POPUP_LOADING_CSS, releaseStyles } from './styles.js';\nimport type { InstanceState } from './state.js';\nimport type { RenderButtonCleanup, RenderButtonMode, RenderButtonOptions } from './types.js';\n\nconst POPUP_WIDTH = 500;\nconst POPUP_HEIGHT = 800;\nconst POPUP_POLL_INTERVAL_MS = 500;\nconst MOBILE_MAX_WIDTH = 600;\nconst SLOW_NETWORK_DELAY_MS = 8000;\n\nfunction buildLogo(): SVGSVGElement {\n const svg = buildMaytesLogo('1em', 'currentColor');\n svg.setAttribute('class', 'maytes-checkout-button__logo');\n svg.setAttribute('aria-hidden', 'true');\n return svg;\n}\n\nfunction buildSpinner(): HTMLSpanElement {\n const spinner = document.createElement('span');\n spinner.className = 'maytes-checkout-button__spinner';\n spinner.setAttribute('aria-hidden', 'true');\n return spinner;\n}\n\nfunction isValidCheckoutResult(value: unknown): value is { checkoutId: string; checkoutUrl?: string } {\n if (typeof value !== 'object' || value === null) return false;\n const obj = value as { checkoutId?: unknown; checkoutUrl?: unknown };\n if (typeof obj.checkoutId !== 'string' || obj.checkoutId.trim().length === 0) return false;\n if (obj.checkoutUrl !== undefined) {\n if (typeof obj.checkoutUrl !== 'string' || obj.checkoutUrl.trim().length === 0) return false;\n if (!isHttpUrl(obj.checkoutUrl)) return false;\n }\n return true;\n}\n\nfunction isSecurityError(err: unknown): boolean {\n return err instanceof DOMException && err.name === 'SecurityError';\n}\n\nfunction refocusPopup(popup: Window): void {\n try { popup.focus(); } catch (err) {\n if (!isSecurityError(err)) throw err;\n }\n}\n\nexport function closePopupWindow(popup: Window | null): void {\n if (popup === null) return;\n try {\n if (!popup.closed) popup.close();\n } catch (err) {\n if (!isSecurityError(err)) throw err;\n }\n}\n\nfunction popupFeatures(): string {\n const screenWidth = window.screen?.width ?? POPUP_WIDTH;\n const screenHeight = window.screen?.height ?? POPUP_HEIGHT;\n const left = Math.max(0, Math.round((screenWidth - POPUP_WIDTH) / 2));\n const top = Math.max(0, Math.round((screenHeight - POPUP_HEIGHT) / 2));\n return `popup=yes,width=${POPUP_WIDTH},height=${POPUP_HEIGHT},left=${left},top=${top},resizable=yes,scrollbars=yes`;\n}\n\nexport function stopPopupPoll(state: InstanceState): void {\n if (state.popupPollHandle !== null) {\n clearInterval(state.popupPollHandle);\n state.popupPollHandle = null;\n }\n}\n\nfunction startPopupPoll(state: InstanceState, onClose: () => void): void {\n stopPopupPoll(state);\n state.popupPollHandle = setInterval(() => {\n const popup = state.popupWindow;\n if (popup === null || popup.closed) {\n stopPopupPoll(state);\n state.popupWindow = null;\n onClose();\n }\n }, POPUP_POLL_INTERVAL_MS);\n}\n\nfunction isMobileViewport(): boolean {\n return window.innerWidth <= MOBILE_MAX_WIDTH;\n}\n\nfunction openBlankPopup(state: InstanceState): Window | null {\n return window.open('about:blank', state.popupName, popupFeatures());\n}\n\nfunction navigatePopup(popup: Window, url: string): void {\n popup.location.replace(url);\n}\n\nfunction removePopupChildren(doc: Document): void {\n while (doc.body.firstChild !== null) doc.body.removeChild(doc.body.firstChild);\n}\n\nfunction paintPopupLoadingScreen(popup: Window, cspNonce: string | undefined): void {\n const doc = popup.document as Document | null;\n if (doc === null || doc.head === null || doc.body === null) return;\n doc.title = 'Maytes checkout';\n doc.documentElement.lang = 'en';\n const style = doc.createElement('style');\n if (cspNonce !== undefined && cspNonce !== '') style.setAttribute('nonce', cspNonce);\n style.textContent = POPUP_LOADING_CSS;\n doc.head.appendChild(style);\n\n doc.body.classList.add('maytes-popup-loading');\n removePopupChildren(doc);\n\n const content = doc.createElement('main');\n content.className = 'maytes-popup-loading__content';\n content.setAttribute('role', 'status');\n content.setAttribute('aria-live', 'polite');\n\n const logo = buildMaytesLogo('2.75rem', foundation.text.primaryInverse);\n logo.setAttribute('class', 'maytes-popup-loading__logo');\n logo.setAttribute('aria-hidden', 'true');\n content.appendChild(logo);\n\n const spinner = doc.createElement('div');\n spinner.className = 'maytes-popup-loading__spinner';\n spinner.setAttribute('aria-hidden', 'true');\n content.appendChild(spinner);\n\n const text = doc.createElement('p');\n text.className = 'maytes-popup-loading__text';\n text.textContent = 'Completing checkout with Maytes…';\n content.appendChild(text);\n\n const slow = doc.createElement('p');\n slow.className = 'maytes-popup-loading__slow';\n slow.hidden = true;\n slow.textContent = 'Still connecting. This can take a moment on slow networks.';\n content.appendChild(slow);\n\n doc.body.appendChild(content);\n setTimeout(() => { slow.hidden = false; }, SLOW_NETWORK_DELAY_MS);\n}\n\nexport function renderButton(\n state: InstanceState,\n container: HTMLElement,\n options: RenderButtonOptions = {},\n): RenderButtonCleanup {\n if (state.destroyed) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'renderButton() called on a destroyed Maytes instance',\n );\n }\n if (!(container instanceof HTMLElement)) {\n throw new MaytesError(MaytesErrorCode.Config, 'renderButton(container) requires an HTMLElement');\n }\n\n ensureStylesInjected(state.config.cspNonce);\n\n const label = options.label ?? 'Split with';\n const block = options.block === true;\n const mode: RenderButtonMode = options.mode ?? 'redirect';\n if (mode !== 'redirect' && mode !== 'popup') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n \"renderButton({ mode }) must be 'redirect' or 'popup'\",\n );\n }\n\n const button = document.createElement('button');\n button.type = 'button';\n button.className = block\n ? 'maytes-checkout-button maytes-checkout-button--block'\n : 'maytes-checkout-button';\n button.setAttribute('aria-label', `${label} Maytes`);\n\n const labelNode = document.createTextNode(`${label} `);\n const logo = buildLogo();\n button.appendChild(labelNode);\n button.appendChild(logo);\n\n const setBusy = (busy: boolean) => {\n state.busy = busy;\n if (busy) {\n button.setAttribute('aria-disabled', 'true');\n button.setAttribute('aria-busy', 'true');\n logo.replaceWith(buildSpinner());\n } else {\n button.removeAttribute('aria-disabled');\n button.removeAttribute('aria-busy');\n const currentIndicator = button.querySelector('.maytes-checkout-button__spinner, .maytes-checkout-button__logo');\n if (currentIndicator !== null) currentIndicator.replaceWith(buildLogo());\n }\n };\n\n const teardownActiveCheckout = () => {\n hideOverlay(state);\n setBusy(false);\n };\n\n const onPopupClosed = () => {\n teardownActiveCheckout();\n document.dispatchEvent(new CustomEvent('maytes:checkout-closed'));\n };\n\n const dispatchFailed = (reason: string, cause?: unknown): void => {\n document.dispatchEvent(new CustomEvent('maytes:checkout-failed', {\n detail: cause === undefined ? { reason } : { reason, cause },\n }));\n };\n\n const dispatchRedirected = (url: string): void => {\n document.dispatchEvent(new CustomEvent('maytes:checkout-redirected', { detail: { url } }));\n };\n\n const redirectSameWindow = (url: string): void => {\n teardownActiveCheckout();\n dispatchRedirected(url);\n window.location.href = url;\n };\n\n const closeOrphanPopup = (popup: Window | null): void => {\n closePopupWindow(popup);\n stopPopupPoll(state);\n if (state.popupWindow === popup) state.popupWindow = null;\n teardownActiveCheckout();\n };\n\n const handleClick = async (): Promise<void> => {\n if (state.busy || state.destroyed) return;\n setBusy(true);\n const shouldUsePopup = mode === 'popup' && !isMobileViewport();\n const popup = shouldUsePopup ? openBlankPopup(state) : null;\n if (popup !== null) {\n state.popupWindow = popup;\n state.popupNavigated = false;\n refocusPopup(popup);\n paintPopupLoadingScreen(popup, state.config.cspNonce);\n showOverlay(state);\n document.dispatchEvent(new CustomEvent('maytes:checkout-opened'));\n startPopupPoll(state, onPopupClosed);\n }\n try {\n const result = await state.config.createCheckout();\n if (state.destroyed || (popup !== null && popup.closed)) {\n closePopupWindow(popup);\n return;\n }\n if (!isValidCheckoutResult(result)) {\n closeOrphanPopup(popup);\n const shapeError = new MaytesError(\n MaytesErrorCode.Config,\n 'createCheckout must resolve to { checkoutId: string, checkoutUrl?: http(s) URL }',\n );\n console.error(shapeError);\n dispatchFailed('invalid-shape', shapeError);\n return;\n }\n const url = result.checkoutUrl ?? buildCheckoutUrl(\n state.config.environment,\n state.config.baseUrl,\n result.checkoutId,\n );\n if (popup !== null) {\n state.popupNavigated = true;\n navigatePopup(popup, url);\n } else {\n if (shouldUsePopup) {\n console.warn('[maytes/checkout-button] popup was blocked; falling back to same-window redirect');\n }\n redirectSameWindow(url);\n }\n } catch (err) {\n if (popup !== null && popup.closed) return;\n closeOrphanPopup(popup);\n console.error('[maytes/checkout-button] createCheckout failed:', err);\n dispatchFailed('create-checkout-rejected', err);\n }\n };\n\n button.addEventListener('click', handleClick);\n container.appendChild(button);\n\n let cleaned = false;\n const teardown = (): void => {\n if (cleaned) return;\n cleaned = true;\n button.removeEventListener('click', handleClick);\n button.remove();\n state.teardowns.delete(teardown);\n releaseStyles();\n };\n state.teardowns.add(teardown);\n\n return teardown;\n}\n","import type { MaytesOptions, MaytesInternalOptions } from './types.js';\n\nexport interface InstanceState {\n config: MaytesOptions & MaytesInternalOptions;\n busy: boolean;\n overlayEl: HTMLDialogElement | null;\n popupWindow: Window | null;\n popupNavigated: boolean;\n popupName: string;\n popupPollHandle: ReturnType<typeof setInterval> | null;\n destroyed: boolean;\n teardowns: Set<() => void>;\n}\n\nfunction popupNameSuffix(): string {\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\nfunction generatePopupName(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n try {\n return `maytes-checkout-${crypto.randomUUID()}`;\n } catch {\n return `maytes-checkout-${popupNameSuffix()}`;\n }\n }\n return `maytes-checkout-${popupNameSuffix()}`;\n}\n\nexport function createInstanceState(\n options: MaytesOptions,\n internal: MaytesInternalOptions | undefined,\n): InstanceState {\n const config: MaytesOptions & MaytesInternalOptions = {\n createCheckout: options.createCheckout,\n environment: options.environment,\n };\n if (internal?.baseUrl !== undefined) config.baseUrl = internal.baseUrl;\n if (internal?.cspNonce !== undefined) config.cspNonce = internal.cspNonce;\n return {\n config,\n busy: false,\n overlayEl: null,\n popupWindow: null,\n popupNavigated: false,\n popupName: generatePopupName(),\n popupPollHandle: null,\n destroyed: false,\n teardowns: new Set(),\n };\n}\n","import { closePopupWindow, renderButton, stopPopupPoll } from './button.js';\nimport { isValidEnvironment } from './env.js';\nimport { MaytesError, MaytesErrorCode } from './errors.js';\nimport { hideOverlay } from './overlay.js';\nimport { makeRedirect, normalizeBaseUrl } from './redirect.js';\nimport { createInstanceState } from './state.js';\nimport type {\n MaytesFactory,\n MaytesInternalOptions,\n MaytesOptions,\n MaytesSDK,\n} from './types.js';\n\nfunction validateOptions(options: MaytesOptions): void {\n if (typeof options !== 'object' || options === null) {\n throw new MaytesError(MaytesErrorCode.Config, 'Maytes() requires an options object');\n }\n if (typeof options.createCheckout !== 'function') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'Maytes({ createCheckout }) must be an async function returning { checkoutId }',\n );\n }\n if (!isValidEnvironment(options.environment)) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n \"Maytes({ environment }) must be 'sandbox' or 'production'\",\n );\n }\n}\n\nfunction validateInternalOptions(internal: MaytesInternalOptions | undefined): void {\n if (internal === undefined) return;\n if (internal.baseUrl !== undefined) normalizeBaseUrl(internal.baseUrl);\n}\n\nexport const Maytes: MaytesFactory = (options, internal) => {\n validateOptions(options);\n validateInternalOptions(internal);\n\n const state = createInstanceState(options, internal);\n const { checkoutUrl, redirectToCheckout } = makeRedirect(\n state.config.environment,\n state.config.baseUrl,\n );\n\n const sdk: MaytesSDK = {\n renderButton(container, opts) {\n return renderButton(state, container, opts);\n },\n redirectToCheckout(opts) {\n redirectToCheckout(opts);\n },\n checkoutUrl(opts) {\n return checkoutUrl(opts);\n },\n destroy() {\n if (state.destroyed) return;\n state.destroyed = true;\n stopPopupPoll(state);\n hideOverlay(state);\n if (!state.popupNavigated) closePopupWindow(state.popupWindow);\n state.popupWindow = null;\n state.busy = false;\n for (const teardown of [...state.teardowns]) teardown();\n state.teardowns.clear();\n },\n };\n\n return sdk;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,aAAa;AAAA,EACxB,OAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,SAAS;AAAA,IACP,UAAU;AAAA,MACR,KAAK;AAAA,IACP;AAAA,IACA,MAAM;AAAA,MACJ,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,gBAAgB;AAAA,EAClB;AACF;;;ACzBO,IAAM,eAAe,WAAW,MAAM;AACtC,IAAM,gBAAgB,WAAW,MAAM;AAE9C,IAAM,SAAS;AAEf,IAAM,oBAAuC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SA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AAC,mBAAmB,QAAQ,WAAW,GAAG;AAC5C,UAAM,IAAI;AAAA,MACR,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,wBAAwB,UAAmD;AAClF,MAAI,aAAa,OAAW;AAC5B,MAAI,SAAS,YAAY,OAAW,kBAAiB,SAAS,OAAO;AACvE;AAEO,IAAM,SAAwB,CAAC,SAAS,aAAa;AAC1D,kBAAgB,OAAO;AACvB,0BAAwB,QAAQ;AAEhC,QAAM,QAAQ,oBAAoB,SAAS,QAAQ;AACnD,QAAM,EAAE,aAAa,mBAAmB,IAAI;AAAA,IAC1C,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,EACf;AAEA,QAAM,MAAiB;AAAA,IACrB,aAAa,WAAW,MAAM;AAC5B,aAAO,aAAa,OAAO,WAAW,IAAI;AAAA,IAC5C;AAAA,IACA,mBAAmB,MAAM;AACvB,yBAAmB,IAAI;AAAA,IACzB;AAAA,IACA,YAAY,MAAM;AAChB,aAAO,YAAY,IAAI;AAAA,IACzB;AAAA,IACA,UAAU;AACR,UAAI,MAAM,UAAW;AACrB,YAAM,YAAY;AAClB,oBAAc,KAAK;AACnB,kBAAY,KAAK;AACjB,UAAI,CAAC,MAAM,eAAgB,kBAAiB,MAAM,WAAW;AAC7D,YAAM,cAAc;AACpB,YAAM,OAAO;AACb,iBAAW,YAAY,CAAC,GAAG,MAAM,SAAS,EAAG,UAAS;AACtD,YAAM,UAAU,MAAM;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;AXpEA,IAAI,OAAO,WAAW,aAAa;AACjC,EAAC,OAAgD,SAAS;AAC5D;","names":[]}
@@ -248,7 +248,7 @@ function makeRedirect(environment, baseUrlOverride) {
248
248
  }
249
249
 
250
250
  // src/version.ts
251
- var SDK_VERSION = "1.0.0";
251
+ var SDK_VERSION = "1.0.1";
252
252
 
253
253
  // src/styles.ts
254
254
  var STYLE_ATTR = "data-maytes-checkout-button";
@@ -625,6 +625,7 @@ function renderButton(state, container, options = {}) {
625
625
  const popup = shouldUsePopup ? openBlankPopup(state) : null;
626
626
  if (popup !== null) {
627
627
  state.popupWindow = popup;
628
+ state.popupNavigated = false;
628
629
  refocusPopup(popup);
629
630
  paintPopupLoadingScreen(popup, state.config.cspNonce);
630
631
  showOverlay(state);
@@ -653,6 +654,7 @@ function renderButton(state, container, options = {}) {
653
654
  result.checkoutId
654
655
  );
655
656
  if (popup !== null) {
657
+ state.popupNavigated = true;
656
658
  navigatePopup(popup, url);
657
659
  } else {
658
660
  if (shouldUsePopup) {
@@ -708,6 +710,7 @@ function createInstanceState(options, internal) {
708
710
  busy: false,
709
711
  overlayEl: null,
710
712
  popupWindow: null,
713
+ popupNavigated: false,
711
714
  popupName: generatePopupName(),
712
715
  popupPollHandle: null,
713
716
  destroyed: false,
@@ -760,7 +763,7 @@ var Maytes = (options, internal) => {
760
763
  state.destroyed = true;
761
764
  stopPopupPoll(state);
762
765
  hideOverlay(state);
763
- closePopupWindow(state.popupWindow);
766
+ if (!state.popupNavigated) closePopupWindow(state.popupWindow);
764
767
  state.popupWindow = null;
765
768
  state.busy = false;
766
769
  for (const teardown of [...state.teardowns]) teardown();