@maytes/checkout-button 1.2.0 → 1.2.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,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#39](https://github.com/kttipay/maytes-checkout-button/pull/39) [`73d1f0c`](https://github.com/kttipay/maytes-checkout-button/commit/73d1f0ccb84ec22473e8a0b1ba17e923c254e2ee) Thanks [@kos-maytes](https://github.com/kos-maytes)! - The Split with Maytes button keeps its white label and logo, burgundy background and Maytes focus ring when hovered, focused or pressed on sites whose theme styles every button (for example WooCommerce's Storefront theme, which turned the label dark grey on hover). Host-page transitions no longer fade the logo, and the overlay's "Return to Maytes" link no longer picks up the theme's button background. A mouse click no longer shows the theme's focus outline on the button or the link; keyboard focus shows the Maytes focus ring on both.
8
+
9
+ <!-- @hash-sri-start -->
10
+
11
+ **SRI hashes** (use these in `<script integrity="..." crossorigin="anonymous">`):
12
+
13
+ ```
14
+ checkout-button.js sha384-0n2iIhZMofbJkzlb2mgQmm714yMFWW0079cxvVxCxZKPjjRHTrEBddxLRygUFUA/
15
+ checkout-button.mjs sha384-DvlD7lErx6rl9lPfEtS9tu9Hp+sb+LC8ZXkzCnfRxP2ruuHuE/toGraDj7Hp9KjU
16
+ checkout-button.cjs sha384-2h9J+cURwjqOA8QYBgt1LeulM0IgD6w1hCxdLdieKvuhDb1/ejuXT3rLEy5SXsb9
17
+ checkout-button.element.js sha384-NHwIzALKGM4v3zbs5kbpDmWb52EGQ6+NMh7ARB5UPTCbjwn3orJV1bDnXzgZrwck
18
+ ```
19
+
20
+ **SemVer CDN links** (readable production pins; use with the SRI hashes above):
21
+
22
+ - [checkout-button.js](https://js.maytes.co/v1.2.1/checkout-button.js)
23
+ - [checkout-button.mjs](https://js.maytes.co/v1.2.1/checkout-button.mjs)
24
+ - [checkout-button.cjs](https://js.maytes.co/v1.2.1/checkout-button.cjs)
25
+ - [checkout-button.element.js](https://js.maytes.co/v1.2.1/checkout-button.element.js)
26
+
27
+ **Hashed CDN links** (byte-level production pins; use with the SRI hashes above):
28
+
29
+ - [checkout-button.299a037b.js](https://js.maytes.co/checkout-button.299a037b.js)
30
+ - [checkout-button.67fdb2e1.mjs](https://js.maytes.co/checkout-button.67fdb2e1.mjs)
31
+ - [checkout-button.332d26cc.cjs](https://js.maytes.co/checkout-button.332d26cc.cjs)
32
+ - [checkout-button.element.afe71cd5.js](https://js.maytes.co/checkout-button.element.afe71cd5.js)
33
+
34
+ <!-- @hash-sri-end -->
3
35
  ## 1.2.0
4
36
 
5
37
  ### Minor Changes
@@ -48,6 +80,7 @@ checkout-button.element.js sha384-Y3aDrAucY25r7DzSkYJpsjoazd67oBy4WSxbTXBgpaWaT
48
80
  - [checkout-button.element.6c530c24.js](https://js.maytes.co/checkout-button.element.6c530c24.js)
49
81
 
50
82
  <!-- @hash-sri-end -->
83
+
51
84
  ## 1.1.1
52
85
 
53
86
  ### Patch Changes
package/README.md CHANGED
@@ -31,7 +31,7 @@ When a shopper clicks the button, it asks your server to create a Maytes checkou
31
31
  - **Any stack.** A `<script>` tag or `import { Maytes }`, with [a guide per stack](#choose-your-setup), React components and a web component.
32
32
  - **No dependencies.** ESM and CommonJS builds ship unminified, so your bundler tree-shakes them.
33
33
  - **CSP-safe.** No `eval`, `Function` or string timers; every release is scanned.
34
- - **Evergreen CDN.** `/v1/` always serves the newest `1.x`; [pin a version](#install) with SRI to freeze it.
34
+ - **Evergreen CDN.** `/v1/` always serves the newest `1.x`, so you get fixes without redeploying.
35
35
  - **Signed releases.** Every npm release carries [SLSA](https://slsa.dev) provenance.
36
36
 
37
37
  ## Quickstart
@@ -65,50 +65,25 @@ Your server creates the checkout behind `POST /api/maytes/checkout`; [Your serve
65
65
 
66
66
  ## Install
67
67
 
68
- | | Evergreen (recommended) | Pinned |
69
- |---|---|---|
70
- | **Use when** | Default — always get the newest `1.x` release | You'd rather freeze on a tested build |
71
- | **Guarantee** | Always current; a bad release reaches you immediately | The bytes you tested are the bytes shipped, forever |
72
- | **SRI** | Not possible | Yes |
68
+ **Script tag**
73
69
 
74
70
  ```html
75
71
  <script src="https://js.maytes.co/v1/checkout-button.js"
76
72
  crossorigin="anonymous"></script>
77
73
  ```
78
74
 
79
- <details>
80
- <summary><b>Evergreen: CSP and versions</b></summary>
81
-
82
- No `integrity` attribute is possible here — the bytes change without notice as new `1.x` releases ship. Trust the origin via CSP instead:
83
-
84
- ```
85
- Content-Security-Policy: script-src 'self' https://js.maytes.co;
86
- ```
87
-
88
- `/v1/` tracks the newest `1.x` release only; it won't jump to a future `2.x` (move to `/v2/checkout-button.js` explicitly once that ships). Poll `https://js.maytes.co/integrity.json` if you want to detect changes yourself.
89
-
90
- </details>
75
+ Always serves the newest `1.x` release, so you get fixes without redeploying. It won't jump to a future `2.x`: move to `/v2/checkout-button.js` yourself once that ships.
91
76
 
92
77
  <details>
93
- <summary><b>Pinned: SemVer or content hash, with SRI</b></summary>
78
+ <summary><b>CSP</b></summary>
94
79
 
95
- For a guarantee instead of convenience — freeze on a tested build, update on your own schedule:
80
+ Allow the CDN origin in your Content Security Policy:
96
81
 
97
- <!-- @cdn-example-start -->
98
- ```html
99
- <script src="https://js.maytes.co/v1.2.0/checkout-button.js"
100
- integrity="sha384-…"
101
- crossorigin="anonymous"></script>
102
82
  ```
103
-
104
- ```html
105
- <script src="https://js.maytes.co/checkout-button.c640180e.js"
106
- integrity="sha384-…"
107
- crossorigin="anonymous"></script>
83
+ Content-Security-Policy: script-src 'self' https://js.maytes.co;
108
84
  ```
109
- <!-- @cdn-example-end -->
110
85
 
111
- Both URLs are the same release bytes with the same SRI value — pick either. Full version/hash/SRI history: [`CHANGELOG.md`](./CHANGELOG.md), [releases](https://github.com/kttipay/maytes-checkout-button/releases), `https://js.maytes.co/integrity.json`. Pinned URLs never change once published.
86
+ No `integrity` attribute is possible on this URL, because its bytes change as new `1.x` releases ship. Poll `https://js.maytes.co/integrity.json` if you want to detect changes yourself.
112
87
 
113
88
  </details>
114
89
 
@@ -118,7 +93,7 @@ Both URLs are the same release bytes with the same SRI value — pick either. Fu
118
93
  npm install @maytes/checkout-button
119
94
  ```
120
95
 
121
- ESM (`import`) and CommonJS (`require`) builds ship unminified with type declarations; your bundler minifies them. The reasoning behind the CDN channels is in [`docs/cdn-versioning.md`](./docs/cdn-versioning.md).
96
+ ESM (`import`) and CommonJS (`require`) builds ship unminified with type declarations; your bundler minifies them.
122
97
 
123
98
  ## API
124
99
 
@@ -1,4 +1,4 @@
1
- "use strict";var MaytesCheckoutButton=(()=>{var R=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var Ee=(e,t)=>{for(var o in t)R(e,o,{get:t[o],enumerable:!0})},xe=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ke(t))!Ce.call(e,r)&&r!==o&&R(e,r,{get:()=>t[r],enumerable:!(n=ve(t,r))||n.enumerable});return e};var Me=e=>xe(R({},"__esModule",{value:!0}),e);var at={};Ee(at,{Maytes:()=>F,MaytesError:()=>c,MaytesErrorCode:()=>s,SDK_VERSION:()=>y});var s={Config:"CONFIG"},c=class extends Error{constructor(t,o){super(o),this.code=t,this.name="MaytesError"}};var G=40,z=55,Se=999;function K(e){return typeof e=="number"&&Number.isInteger(e)}function q(e){let{radius:t,height:o}=e,n={};if(o!==void 0){if(!K(o)||o<G||o>z)throw new c(s.Config,`renderButton({ height }) must be a whole number of pixels from ${G} to ${z}`);n.height=o}if(t!==void 0){let r=o===void 0?Se:Math.floor(o/2);if(!K(t)||t<0||t>r)throw new c(s.Config,`renderButton({ radius }) must be a whole number of pixels from 0 to ${r}`);n.radius=t}return n}function Y(e,t){t.radius!==void 0&&e.style.setProperty("--maytes-button-radius",`${t.radius}px`),t.height!==void 0&&(e.style.setProperty("--maytes-button-height",`${t.height}px`),e.classList.add("maytes-checkout-button--sized"))}var l={brand:{primary:"#4A0324",secondary:"#FE572A"},palette:{burgundy:{700:"#3B021D"},base:{white:"#FFFFFF"}},text:{primaryInverse:"#FFFFFF"}};var mt=l.brand.primary,Z=l.brand.secondary,A="http://www.w3.org/2000/svg",_e=["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","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","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","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","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","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"];function f(e,t){let o=document.createElementNS(A,"svg");o.setAttribute("xmlns",A),o.setAttribute("viewBox","0 0 1199.47 289.04"),o.style.height=e,o.style.width="auto",o.style.color=t;for(let n of _e){let r=document.createElementNS(A,"path");r.setAttribute("fill","currentColor"),r.setAttribute("d",n),o.appendChild(r)}return o}function p(e){return typeof e=="object"&&e!==null&&e.name==="SecurityError"}function T(){return window.top!==null&&window.top!==window}function L(){if(!T())return null;let e=window.top;try{return e.document,e}catch(t){if(!p(t))throw t;return null}}function J(){if(!T())return window.innerWidth;let e=L();if(e!==null)return e.innerWidth;let t=window.screen?.width;return typeof t=="number"&&t>0?t:window.innerWidth}function X(e,t,o){o?e.location.replace(t):e.location.href=t}function Ie(e){try{e.opener=null}catch(t){if(!p(t))throw t}}function k(e,t){if(!T())return X(window,e,t),{target:"self"};let o;try{return X(window.top,e,t),{target:"top"}}catch(n){if(!p(n))throw n;o=n}try{let n=window.open(e,"_blank");return n!==null?(Ie(n),{target:"tab"}):{target:null,cause:o}}catch(n){return{target:null,cause:n}}}var Q="maytes-overlay-title",D="data-maytes-checkout-button-overlay-styles",Oe="rgba(0, 0, 0, 0.6)";function Re(){let e=L();if(e===null)return null;let t=e.document;return t.body!==null?t:null}function Ae(){return Re()??document}function Te(e){if(e===document||e.querySelector(`style[${D}]`)!==null)return;let t=document.head.querySelector("style[data-maytes-checkout-button]");if(t===null)return;let o=e.createElement("style");o.setAttribute(D,"");let n=t.getAttribute("nonce");n!==null&&o.setAttribute("nonce",n),o.textContent=t.textContent??"",e.head.appendChild(o)}function Le(e,t,o){let n=e.createElement("dialog");n.className="maytes-checkout-overlay",n.setAttribute("aria-labelledby",Q),n.setAttribute("data-maytes-overlay","");let r=e.createElement("div");r.className="maytes-checkout-overlay__content";let d=e.createElement("div");d.setAttribute("aria-hidden","true"),d.appendChild(f("2.5rem",Z)),r.appendChild(d);let i=e.createElement("div");i.className="maytes-checkout-overlay__spinner",i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-label","Checkout in progress"),r.appendChild(i);let u=e.createElement("p");if(u.id=Q,u.className="maytes-checkout-overlay__text",u.textContent=o==="popup"?"Completing checkout with Maytes\u2026":"Taking you to Maytes\u2026",r.appendChild(u),o==="popup"){let a=e.createElement("button");a.className="maytes-checkout-overlay__link",a.type="button",a.textContent="Return to Maytes",a.addEventListener("click",()=>{if(t.popupWindow!==null&&!t.popupWindow.closed)try{t.popupWindow.focus()}catch(m){if(!p(m))throw m}}),r.appendChild(a)}return n.appendChild(r),n.addEventListener("cancel",a=>{a.preventDefault(),t.popupWindow!==null&&!t.popupWindow.closed&&t.popupWindow.close(),h(t)}),n}function ee(e){e.style.background=Oe}function U(e,t="popup"){if(e.overlayEl!==null)return;let o=Ae();Te(o);let n=Le(o,e,t);if(e.overlayEl=n,o.body.appendChild(n),o!==document&&De(e),typeof n.showModal=="function")try{n.showModal()}catch(r){console.warn("[maytes/checkout-button] dialog.showModal failed; falling back to inline backdrop",r),n.setAttribute("open",""),ee(n)}else n.setAttribute("open",""),ee(n)}function De(e){let t=()=>h(e);window.addEventListener("pagehide",t),e.overlayDetach=()=>window.removeEventListener("pagehide",t)}function h(e){if(e.overlayEl===null)return;e.overlayDetach?.(),e.overlayDetach=null;let t=e.overlayEl,o=t.ownerDocument;typeof t.close=="function"&&t.open&&t.close(),t.remove(),o!==document&&o.head.querySelector(`style[${D}]`)?.remove(),e.overlayEl=null}var Ue={staging:"https://staging-checkout.maytes.co",sandbox:"https://sandbox-checkout.maytes.co",production:"https://checkout.maytes.co"};function te(e){return e==="sandbox"||e==="production"||e==="staging"}function oe(e,t){if(t!==void 0)return t;let o=Ue[e];if(o===void 0)throw new c(s.Config,`Unknown environment: ${String(e)}`);return o}function ne(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="https:"||t.protocol==="http:"}function W(e){let t=e.trim().replace(/\/+$/,""),o;try{o=new URL(t)}catch{throw new c(s.Config,`baseUrl is not a valid URL: ${t}`)}if(o.protocol!=="https:"&&o.protocol!=="http:")throw new c(s.Config,`baseUrl must use http or https; got ${o.protocol}`);return t}function We(e){if(typeof e!="string"||e.trim().length===0)throw new c(s.Config,"checkoutId is required (non-empty string)");return e.trim()}function C(e,t,o){let n=We(o);return`${W(oe(e,t))}/?id=${encodeURIComponent(n)}`}function Ne(e,t){if(typeof window>"u")throw new c(s.Config,"redirectToCheckout requires a browser context (window is undefined)");if(k(e,t).target===null)throw new c(s.Config,"redirectToCheckout could not leave the embedding iframe; call it from a user gesture or from the top-level page")}function re(e,t){return{checkoutUrl(o){return C(e,t,o.checkoutId)},redirectToCheckout(o){let n=C(e,t,o.checkoutId);Ne(n,o.replace===!0)}}}var y="1.2.0";var ie="data-maytes-checkout-button",ae=`style[${ie}="${y}"]`,ce=`__maytes_checkout_button_styles_refs_${y}__`,Pe="#6b8aff",Be=`
1
+ "use strict";var MaytesCheckoutButton=(()=>{var R=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var _e=Object.prototype.hasOwnProperty;var Ee=(e,t)=>{for(var o in t)R(e,o,{get:t[o],enumerable:!0})},xe=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ce(t))!_e.call(e,r)&&r!==o&&R(e,r,{get:()=>t[r],enumerable:!(n=we(t,r))||n.enumerable});return e};var Me=e=>xe(R({},"__esModule",{value:!0}),e);var at={};Ee(at,{Maytes:()=>F,MaytesError:()=>c,MaytesErrorCode:()=>s,SDK_VERSION:()=>f});var s={Config:"CONFIG"},c=class extends Error{constructor(t,o){super(o),this.code=t,this.name="MaytesError"}};var G=40,z=55,Se=999;function K(e){return typeof e=="number"&&Number.isInteger(e)}function q(e){let{radius:t,height:o}=e,n={};if(o!==void 0){if(!K(o)||o<G||o>z)throw new c(s.Config,`renderButton({ height }) must be a whole number of pixels from ${G} to ${z}`);n.height=o}if(t!==void 0){let r=o===void 0?Se:Math.floor(o/2);if(!K(t)||t<0||t>r)throw new c(s.Config,`renderButton({ radius }) must be a whole number of pixels from 0 to ${r}`);n.radius=t}return n}function Y(e,t){t.radius!==void 0&&e.style.setProperty("--maytes-button-radius",`${t.radius}px`),t.height!==void 0&&(e.style.setProperty("--maytes-button-height",`${t.height}px`),e.classList.add("maytes-checkout-button--sized"))}var l={brand:{primary:"#4A0324",secondary:"#FE572A"},palette:{burgundy:{700:"#3B021D"},base:{white:"#FFFFFF"}},text:{primaryInverse:"#FFFFFF"}};var mt=l.brand.primary,Z=l.brand.secondary,A="http://www.w3.org/2000/svg",Ie=["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","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","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","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","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","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"];function h(e,t){let o=document.createElementNS(A,"svg");o.setAttribute("xmlns",A),o.setAttribute("viewBox","0 0 1199.47 289.04"),o.style.height=e,o.style.width="auto",o.style.color=t;for(let n of Ie){let r=document.createElementNS(A,"path");r.setAttribute("fill","currentColor"),r.setAttribute("d",n),o.appendChild(r)}return o}function p(e){return typeof e=="object"&&e!==null&&e.name==="SecurityError"}function T(){return window.top!==null&&window.top!==window}function L(){if(!T())return null;let e=window.top;try{return e.document,e}catch(t){if(!p(t))throw t;return null}}function J(){if(!T())return window.innerWidth;let e=L();if(e!==null)return e.innerWidth;let t=window.screen?.width;return typeof t=="number"&&t>0?t:window.innerWidth}function X(e,t,o){o?e.location.replace(t):e.location.href=t}function Oe(e){try{e.opener=null}catch(t){if(!p(t))throw t}}function w(e,t){if(!T())return X(window,e,t),{target:"self"};let o;try{return X(window.top,e,t),{target:"top"}}catch(n){if(!p(n))throw n;o=n}try{let n=window.open(e,"_blank");return n!==null?(Oe(n),{target:"tab"}):{target:null,cause:o}}catch(n){return{target:null,cause:n}}}var Q="maytes-overlay-title",D="data-maytes-checkout-button-overlay-styles",Re="rgba(0, 0, 0, 0.6)";function Ae(){let e=L();if(e===null)return null;let t=e.document;return t.body!==null?t:null}function Te(){return Ae()??document}function Le(e){if(e===document||e.querySelector(`style[${D}]`)!==null)return;let t=document.head.querySelector("style[data-maytes-checkout-button]");if(t===null)return;let o=e.createElement("style");o.setAttribute(D,"");let n=t.getAttribute("nonce");n!==null&&o.setAttribute("nonce",n),o.textContent=t.textContent??"",e.head.appendChild(o)}function De(e,t,o){let n=e.createElement("dialog");n.className="maytes-checkout-overlay",n.setAttribute("aria-labelledby",Q),n.setAttribute("data-maytes-overlay","");let r=e.createElement("div");r.className="maytes-checkout-overlay__content";let d=e.createElement("div");d.setAttribute("aria-hidden","true"),d.appendChild(h("2.5rem",Z)),r.appendChild(d);let i=e.createElement("div");i.className="maytes-checkout-overlay__spinner",i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-label","Checkout in progress"),r.appendChild(i);let u=e.createElement("p");if(u.id=Q,u.className="maytes-checkout-overlay__text",u.textContent=o==="popup"?"Completing checkout with Maytes\u2026":"Taking you to Maytes\u2026",r.appendChild(u),o==="popup"){let a=e.createElement("button");a.className="maytes-checkout-overlay__link",a.type="button",a.textContent="Return to Maytes",a.addEventListener("click",()=>{if(t.popupWindow!==null&&!t.popupWindow.closed)try{t.popupWindow.focus()}catch(m){if(!p(m))throw m}}),r.appendChild(a)}return n.appendChild(r),n.addEventListener("cancel",a=>{a.preventDefault(),t.popupWindow!==null&&!t.popupWindow.closed&&t.popupWindow.close(),y(t)}),n}function ee(e){e.style.background=Re}function U(e,t="popup"){if(e.overlayEl!==null)return;let o=Te();Le(o);let n=De(o,e,t);if(e.overlayEl=n,o.body.appendChild(n),o!==document&&Ue(e),typeof n.showModal=="function")try{n.showModal()}catch(r){console.warn("[maytes/checkout-button] dialog.showModal failed; falling back to inline backdrop",r),n.setAttribute("open",""),ee(n)}else n.setAttribute("open",""),ee(n)}function Ue(e){let t=()=>y(e);window.addEventListener("pagehide",t),e.overlayDetach=()=>window.removeEventListener("pagehide",t)}function y(e){if(e.overlayEl===null)return;e.overlayDetach?.(),e.overlayDetach=null;let t=e.overlayEl,o=t.ownerDocument;typeof t.close=="function"&&t.open&&t.close(),t.remove(),o!==document&&o.head.querySelector(`style[${D}]`)?.remove(),e.overlayEl=null}var We={staging:"https://staging-checkout.maytes.co",sandbox:"https://sandbox-checkout.maytes.co",production:"https://checkout.maytes.co"};function te(e){return e==="sandbox"||e==="production"||e==="staging"}function oe(e,t){if(t!==void 0)return t;let o=We[e];if(o===void 0)throw new c(s.Config,`Unknown environment: ${String(e)}`);return o}function ne(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="https:"||t.protocol==="http:"}function W(e){let t=e.trim().replace(/\/+$/,""),o;try{o=new URL(t)}catch{throw new c(s.Config,`baseUrl is not a valid URL: ${t}`)}if(o.protocol!=="https:"&&o.protocol!=="http:")throw new c(s.Config,`baseUrl must use http or https; got ${o.protocol}`);return t}function Ne(e){if(typeof e!="string"||e.trim().length===0)throw new c(s.Config,"checkoutId is required (non-empty string)");return e.trim()}function C(e,t,o){let n=Ne(o);return`${W(oe(e,t))}/?id=${encodeURIComponent(n)}`}function Pe(e,t){if(typeof window>"u")throw new c(s.Config,"redirectToCheckout requires a browser context (window is undefined)");if(w(e,t).target===null)throw new c(s.Config,"redirectToCheckout could not leave the embedding iframe; call it from a user gesture or from the top-level page")}function re(e,t){return{checkoutUrl(o){return C(e,t,o.checkoutId)},redirectToCheckout(o){let n=C(e,t,o.checkoutId);Pe(n,o.replace===!0)}}}var f="1.2.1";var ae="data-maytes-checkout-button",ce=`style[${ae}="${f}"]`,se=`__maytes_checkout_button_styles_refs_${f}__`,ie="#6b8aff",Be=`
2
2
  .maytes-checkout-button {
3
3
  display: inline-flex;
4
4
  align-items: center;
@@ -6,27 +6,45 @@
6
6
  gap: 0.57em;
7
7
  min-height: var(--maytes-button-height, auto);
8
8
  padding: 0.71em 1.29em;
9
- border: none;
10
9
  border-radius: var(--maytes-button-radius, 999px);
11
- background: ${l.brand.primary};
12
- color: ${l.text.primaryInverse};
13
10
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
14
11
  font-size: var(--maytes-button-font-size, 14px);
15
12
  font-weight: 600;
16
13
  line-height: 1;
17
- cursor: pointer;
18
14
  user-select: none;
15
+ }
16
+ .maytes-checkout-button.maytes-checkout-button,
17
+ .maytes-checkout-button.maytes-checkout-button:hover,
18
+ .maytes-checkout-button.maytes-checkout-button:focus,
19
+ .maytes-checkout-button.maytes-checkout-button:active {
20
+ background: ${l.brand.primary};
21
+ border: none;
22
+ color: ${l.text.primaryInverse};
23
+ box-shadow: none;
24
+ text-decoration: none;
25
+ text-shadow: none;
26
+ filter: none;
27
+ transform: none;
28
+ opacity: 1;
29
+ cursor: pointer;
19
30
  transition: background-color 120ms ease, opacity 120ms ease;
20
31
  }
21
- .maytes-checkout-button:hover { background: ${l.palette.burgundy[700]}; }
22
- .maytes-checkout-button:focus-visible {
23
- outline: 2px solid ${Pe};
32
+ .maytes-checkout-button.maytes-checkout-button:hover { background: ${l.palette.burgundy[700]}; }
33
+ .maytes-checkout-button.maytes-checkout-button:focus:not(:focus-visible) { outline: none; }
34
+ .maytes-checkout-button.maytes-checkout-button:focus-visible {
35
+ outline: 2px solid ${ie};
24
36
  outline-offset: 2px;
25
37
  }
26
- .maytes-checkout-button[aria-disabled='true'] {
38
+ .maytes-checkout-button.maytes-checkout-button[aria-disabled='true'] {
27
39
  cursor: progress;
28
40
  opacity: 0.7;
29
41
  }
42
+ .maytes-checkout-button.maytes-checkout-button * { transition: none; }
43
+ .maytes-checkout-button.maytes-checkout-button .maytes-checkout-button__logo,
44
+ .maytes-checkout-button.maytes-checkout-button .maytes-checkout-button__logo * {
45
+ animation: none;
46
+ fill: currentColor;
47
+ }
30
48
  .maytes-checkout-button--sized {
31
49
  box-sizing: border-box;
32
50
  white-space: nowrap;
@@ -92,22 +110,36 @@
92
110
  margin: 0;
93
111
  }
94
112
  .maytes-checkout-overlay__link {
95
- color: rgba(255, 255, 255, 0.7);
96
113
  font-size: 0.875rem;
97
- text-decoration: underline;
98
114
  text-underline-offset: 4px;
115
+ font-family: inherit;
116
+ }
117
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link,
118
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:hover,
119
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus,
120
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:active {
99
121
  background: none;
100
122
  border: none;
123
+ color: rgba(255, 255, 255, 0.7);
124
+ box-shadow: none;
125
+ text-decoration: underline;
126
+ text-shadow: none;
127
+ transform: none;
128
+ opacity: 1;
101
129
  cursor: pointer;
102
- font-family: inherit;
103
130
  transition: color 0.15s;
104
131
  }
105
- .maytes-checkout-overlay__link:hover { color: ${l.text.primaryInverse}; }
132
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:hover { color: ${l.text.primaryInverse}; }
133
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus:not(:focus-visible) { outline: none; }
134
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus-visible {
135
+ outline: 2px solid ${ie};
136
+ outline-offset: 2px;
137
+ }
106
138
  @media (prefers-reduced-motion: reduce) {
107
139
  .maytes-checkout-overlay__spinner,
108
140
  .maytes-checkout-button__spinner { animation: none; }
109
141
  }
110
- `,se=`
142
+ `,ue=`
111
143
  :root { color-scheme: light; }
112
144
  html, body { margin: 0; height: 100%; }
113
145
  body.maytes-popup-loading {
@@ -151,6 +183,6 @@ body.maytes-popup-loading {
151
183
  @media (prefers-reduced-motion: reduce) {
152
184
  .maytes-popup-loading__spinner { animation: none; }
153
185
  }
154
- `;function ue(){return window[ce]??0}function le(e){let t=window;t[ce]=e}function de(e){let t=ue()+1;if(le(t),document.head.querySelector(ae)!==null)return;let o=document.createElement("style");o.setAttribute(ie,y),e!==void 0&&e!==""&&o.setAttribute("nonce",e),o.textContent=Be,document.head.appendChild(o)}function pe(){let e=Math.max(0,ue()-1);if(le(e),e>0)return;let t=document.head.querySelector(ae);t!==null&&t.remove()}var N=500,P=800,$e=500,Fe=600,He=8e3;function Ve(e){if(typeof e!="object"||e===null)return!1;let t=e;return!(typeof t.checkoutId!="string"||t.checkoutId.trim().length===0||t.checkoutUrl!==void 0&&(typeof t.checkoutUrl!="string"||t.checkoutUrl.trim().length===0||!ne(t.checkoutUrl)))}function je(e){try{e.focus()}catch(t){if(!p(t))throw t}}function E(e){if(e!==null)try{e.closed||e.close()}catch(t){if(!p(t))throw t}}function Ge(){let e=window.screen?.width??N,t=window.screen?.height??P,o=Math.max(0,Math.round((e-N)/2)),n=Math.max(0,Math.round((t-P)/2));return`popup=yes,width=${N},height=${P},left=${o},top=${n},resizable=yes,scrollbars=yes`}function w(e){e.popupPollHandle!==null&&(clearInterval(e.popupPollHandle),e.popupPollHandle=null)}function ze(e,t){w(e),e.popupPollHandle=setInterval(()=>{let o=e.popupWindow;(o===null||o.closed)&&(w(e),e.popupWindow=null,t())},$e)}function Ke(){return J()<=Fe}function qe(e){return window.open("about:blank",e.popupName,Ge())}function Ye(e,t){e.location.replace(t)}function Ze(e){for(;e.body.firstChild!==null;)e.body.removeChild(e.body.firstChild)}function Xe(e,t){let o=e.document;if(o===null||o.head===null||o.body===null)return;o.title="Maytes checkout",o.documentElement.lang="en";let n=o.createElement("style");t!==void 0&&t!==""&&n.setAttribute("nonce",t),n.textContent=se,o.head.appendChild(n),o.body.classList.add("maytes-popup-loading"),Ze(o);let r=o.createElement("main");r.className="maytes-popup-loading__content",r.setAttribute("role","status"),r.setAttribute("aria-live","polite");let d=f("2.75rem",l.text.primaryInverse);d.setAttribute("class","maytes-popup-loading__logo"),d.setAttribute("aria-hidden","true"),r.appendChild(d);let i=o.createElement("div");i.className="maytes-popup-loading__spinner",i.setAttribute("aria-hidden","true"),r.appendChild(i);let u=o.createElement("p");u.className="maytes-popup-loading__text",u.textContent="Completing checkout with Maytes\u2026",r.appendChild(u);let a=o.createElement("p");a.className="maytes-popup-loading__slow",a.hidden=!0,a.textContent="Still connecting. This can take a moment on slow networks.",r.appendChild(a),o.body.appendChild(r),setTimeout(()=>{a.hidden=!1},He)}function Je(e,t){return{instanceId:e.instanceId,source:t}}function B(e,t,o){let n=o===void 0?{...e,reason:t}:{...e,reason:t,cause:o};document.dispatchEvent(new CustomEvent("maytes:checkout-failed",{detail:n}))}function Qe(e,t,o){let n={...e,url:t,target:o};document.dispatchEvent(new CustomEvent("maytes:checkout-redirected",{detail:n}))}function x(e,t="renderButton"){if(e!=="redirect"&&e!=="popup")throw new c(s.Config,`${t}({ mode }) must be 'redirect' or 'popup'`);return e}function M(e,t="renderButton"){if(e===void 0)return!1;if(typeof e!="boolean")throw new c(s.Config,`${t}({ redirectOverlay }) must be true or false`);return e}function $(e,t){e.busy=t;for(let o of[...e.busyViews])o(t)}function S(e){h(e),$(e,!1)}function me(e,t){E(t),w(e),e.popupWindow===t&&(e.popupWindow=null),S(e)}function et(e){if(e.restoreDetach!==null)return;let t=n=>{n.persisted&&(o(),S(e))},o=()=>{window.removeEventListener("pageshow",t),e.restoreDetach=null};window.addEventListener("pageshow",t),e.restoreDetach=o}function tt(e,t,o,n){let r=k(o,!1);return n&&(r.target==="self"||r.target==="top")?($(e,!1),et(e)):S(e),r.target===null?(console.error("[maytes/checkout-button] could not leave the embedding frame:",r.cause),B(t,"navigation-blocked",r.cause),{outcome:"failed",reason:"navigation-blocked"}):(Qe(t,o,r.target),{outcome:"redirected",target:r.target})}function ot(e,t){let o=qe(e);return o===null?null:(e.popupWindow=o,e.popupNavigated=!1,je(o),Xe(o,e.config.cspNonce),U(e),document.dispatchEvent(new CustomEvent("maytes:checkout-opened",{detail:t})),ze(e,()=>{S(e),document.dispatchEvent(new CustomEvent("maytes:checkout-closed",{detail:t}))}),o)}async function _(e,t,o,n=!1){if(e.busy||e.destroyed)return{outcome:"ignored"};$(e,!0);let r=Je(e,o),d=t==="popup"&&!Ke(),i=d?ot(e,r):null;i===null&&n&&U(e,"redirect");try{let u=await e.config.createCheckout();if(e.destroyed||i!==null&&i.closed)return E(i),{outcome:"closed"};if(!Ve(u)){me(e,i);let m=new c(s.Config,"createCheckout must resolve to { checkoutId: string, checkoutUrl?: http(s) URL }");return console.error(m),B(r,"invalid-shape",m),{outcome:"failed",reason:"invalid-shape"}}let a=u.checkoutUrl??C(e.config.environment,e.config.baseUrl,u.checkoutId);return i!==null?(e.popupNavigated=!0,Ye(i,a),{outcome:"popup"}):(d&&console.warn("[maytes/checkout-button] popup was blocked; redirecting instead"),tt(e,r,a,n))}catch(u){return i!==null&&i.closed?{outcome:"closed"}:(me(e,i),console.error("[maytes/checkout-button] createCheckout failed:",u),B(r,"create-checkout-rejected",u),{outcome:"failed",reason:"create-checkout-rejected"})}}function fe(){let e=f("1em","currentColor");return e.setAttribute("class","maytes-checkout-button__logo"),e.setAttribute("aria-hidden","true"),e}function nt(){let e=document.createElement("span");return e.className="maytes-checkout-button__spinner",e.setAttribute("aria-hidden","true"),e}function he(e,t,o={}){if(e.destroyed)throw new c(s.Config,"renderButton() called on a destroyed Maytes instance");if(!(t instanceof HTMLElement))throw new c(s.Config,"renderButton(container) requires an HTMLElement");let n=q(o),r=M(o.redirectOverlay);de(e.config.cspNonce);let d=o.label??"Split with",i=o.block===!0,u=x(o.mode??"popup"),a=document.createElement("button");a.type="button",a.className=i?"maytes-checkout-button maytes-checkout-button--block":"maytes-checkout-button",Y(a,n),a.setAttribute("aria-label",`${d} Maytes`);let m=document.createTextNode(`${d} `),g=fe();a.appendChild(m),a.appendChild(g);let we=v=>{if(v){a.setAttribute("aria-disabled","true"),a.setAttribute("aria-busy","true");let b=nt();g.replaceWith(b),g=b}else{a.removeAttribute("aria-disabled"),a.removeAttribute("aria-busy");let b=fe();g.replaceWith(b),g=b}},I=!1,H=v=>{I&&(we(v),v||(I=!1))};e.busyViews.add(H);let V=()=>{e.busy||e.destroyed||(I=!0,_(e,u,"button",r))};a.addEventListener("click",V),t.appendChild(a);let j=!1,O=()=>{j||(j=!0,a.removeEventListener("click",V),a.remove(),e.busyViews.delete(H),e.teardowns.delete(O),pe())};return e.teardowns.add(O),O}function ye(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function ge(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")try{return crypto.randomUUID()}catch{return ye()}return ye()}function be(e,t){let o={createCheckout:e.createCheckout,environment:e.environment};return t?.baseUrl!==void 0&&(o.baseUrl=t.baseUrl),t?.cspNonce!==void 0&&(o.cspNonce=t.cspNonce),{config:o,busy:!1,busyViews:new Set,instanceId:ge(),overlayEl:null,overlayDetach:null,restoreDetach:null,popupWindow:null,popupNavigated:!1,popupName:`maytes-checkout-${ge()}`,popupPollHandle:null,destroyed:!1,teardowns:new Set}}function rt(e){if(typeof e!="object"||e===null)throw new c(s.Config,"Maytes() requires an options object");if(typeof e.createCheckout!="function")throw new c(s.Config,"Maytes({ createCheckout }) must be an async function returning { checkoutId }");if(!te(e.environment))throw new c(s.Config,"Maytes({ environment }) must be 'sandbox' or 'production'")}function it(e){e!==void 0&&e.baseUrl!==void 0&&W(e.baseUrl)}var F=(e,t)=>{rt(e),it(t);let o=be(e,t),{checkoutUrl:n,redirectToCheckout:r}=re(o.config.environment,o.config.baseUrl);return{instanceId:o.instanceId,renderButton(i,u){return he(o,i,u)},openCheckout(i){if(o.destroyed)throw new c(s.Config,"openCheckout() called on a destroyed Maytes instance");let u=x(i?.mode??"popup","openCheckout"),a=M(i?.redirectOverlay,"openCheckout");return _(o,u,"api",a)},onBusyChange(i){if(o.destroyed)throw new c(s.Config,"onBusyChange() called on a destroyed Maytes instance");return o.busyViews.add(i),()=>{o.busyViews.delete(i)}},redirectToCheckout(i){r(i)},checkoutUrl(i){return n(i)},destroy(){if(!o.destroyed){o.destroyed=!0,w(o),o.restoreDetach?.(),h(o),o.popupNavigated||E(o.popupWindow),o.popupWindow=null,o.busy=!1;for(let i of[...o.teardowns])i();o.teardowns.clear()}}}};typeof window<"u"&&(window.Maytes=F);return Me(at);})();
186
+ `;function le(){return window[se]??0}function de(e){let t=window;t[se]=e}function pe(e){let t=le()+1;if(de(t),document.head.querySelector(ce)!==null)return;let o=document.createElement("style");o.setAttribute(ae,f),e!==void 0&&e!==""&&o.setAttribute("nonce",e),o.textContent=Be,document.head.appendChild(o)}function me(){let e=Math.max(0,le()-1);if(de(e),e>0)return;let t=document.head.querySelector(ce);t!==null&&t.remove()}var N=500,P=800,$e=500,Fe=600,He=8e3;function Ve(e){if(typeof e!="object"||e===null)return!1;let t=e;return!(typeof t.checkoutId!="string"||t.checkoutId.trim().length===0||t.checkoutUrl!==void 0&&(typeof t.checkoutUrl!="string"||t.checkoutUrl.trim().length===0||!ne(t.checkoutUrl)))}function je(e){try{e.focus()}catch(t){if(!p(t))throw t}}function _(e){if(e!==null)try{e.closed||e.close()}catch(t){if(!p(t))throw t}}function Ge(){let e=window.screen?.width??N,t=window.screen?.height??P,o=Math.max(0,Math.round((e-N)/2)),n=Math.max(0,Math.round((t-P)/2));return`popup=yes,width=${N},height=${P},left=${o},top=${n},resizable=yes,scrollbars=yes`}function v(e){e.popupPollHandle!==null&&(clearInterval(e.popupPollHandle),e.popupPollHandle=null)}function ze(e,t){v(e),e.popupPollHandle=setInterval(()=>{let o=e.popupWindow;(o===null||o.closed)&&(v(e),e.popupWindow=null,t())},$e)}function Ke(){return J()<=Fe}function qe(e){return window.open("about:blank",e.popupName,Ge())}function Ye(e,t){e.location.replace(t)}function Ze(e){for(;e.body.firstChild!==null;)e.body.removeChild(e.body.firstChild)}function Xe(e,t){let o=e.document;if(o===null||o.head===null||o.body===null)return;o.title="Maytes checkout",o.documentElement.lang="en";let n=o.createElement("style");t!==void 0&&t!==""&&n.setAttribute("nonce",t),n.textContent=ue,o.head.appendChild(n),o.body.classList.add("maytes-popup-loading"),Ze(o);let r=o.createElement("main");r.className="maytes-popup-loading__content",r.setAttribute("role","status"),r.setAttribute("aria-live","polite");let d=h("2.75rem",l.text.primaryInverse);d.setAttribute("class","maytes-popup-loading__logo"),d.setAttribute("aria-hidden","true"),r.appendChild(d);let i=o.createElement("div");i.className="maytes-popup-loading__spinner",i.setAttribute("aria-hidden","true"),r.appendChild(i);let u=o.createElement("p");u.className="maytes-popup-loading__text",u.textContent="Completing checkout with Maytes\u2026",r.appendChild(u);let a=o.createElement("p");a.className="maytes-popup-loading__slow",a.hidden=!0,a.textContent="Still connecting. This can take a moment on slow networks.",r.appendChild(a),o.body.appendChild(r),setTimeout(()=>{a.hidden=!1},He)}function Je(e,t){return{instanceId:e.instanceId,source:t}}function B(e,t,o){let n=o===void 0?{...e,reason:t}:{...e,reason:t,cause:o};document.dispatchEvent(new CustomEvent("maytes:checkout-failed",{detail:n}))}function Qe(e,t,o){let n={...e,url:t,target:o};document.dispatchEvent(new CustomEvent("maytes:checkout-redirected",{detail:n}))}function E(e,t="renderButton"){if(e!=="redirect"&&e!=="popup")throw new c(s.Config,`${t}({ mode }) must be 'redirect' or 'popup'`);return e}function x(e,t="renderButton"){if(e===void 0)return!1;if(typeof e!="boolean")throw new c(s.Config,`${t}({ redirectOverlay }) must be true or false`);return e}function $(e,t){e.busy=t;for(let o of[...e.busyViews])o(t)}function M(e){y(e),$(e,!1)}function he(e,t){_(t),v(e),e.popupWindow===t&&(e.popupWindow=null),M(e)}function et(e){if(e.restoreDetach!==null)return;let t=n=>{n.persisted&&(o(),M(e))},o=()=>{window.removeEventListener("pageshow",t),e.restoreDetach=null};window.addEventListener("pageshow",t),e.restoreDetach=o}function tt(e,t,o,n){let r=w(o,!1);return n&&(r.target==="self"||r.target==="top")?($(e,!1),et(e)):M(e),r.target===null?(console.error("[maytes/checkout-button] could not leave the embedding frame:",r.cause),B(t,"navigation-blocked",r.cause),{outcome:"failed",reason:"navigation-blocked"}):(Qe(t,o,r.target),{outcome:"redirected",target:r.target})}function ot(e,t){let o=qe(e);return o===null?null:(e.popupWindow=o,e.popupNavigated=!1,je(o),Xe(o,e.config.cspNonce),U(e),document.dispatchEvent(new CustomEvent("maytes:checkout-opened",{detail:t})),ze(e,()=>{M(e),document.dispatchEvent(new CustomEvent("maytes:checkout-closed",{detail:t}))}),o)}async function S(e,t,o,n=!1){if(e.busy||e.destroyed)return{outcome:"ignored"};$(e,!0);let r=Je(e,o),d=t==="popup"&&!Ke(),i=d?ot(e,r):null;i===null&&n&&U(e,"redirect");try{let u=await e.config.createCheckout();if(e.destroyed||i!==null&&i.closed)return _(i),{outcome:"closed"};if(!Ve(u)){he(e,i);let m=new c(s.Config,"createCheckout must resolve to { checkoutId: string, checkoutUrl?: http(s) URL }");return console.error(m),B(r,"invalid-shape",m),{outcome:"failed",reason:"invalid-shape"}}let a=u.checkoutUrl??C(e.config.environment,e.config.baseUrl,u.checkoutId);return i!==null?(e.popupNavigated=!0,Ye(i,a),{outcome:"popup"}):(d&&console.warn("[maytes/checkout-button] popup was blocked; redirecting instead"),tt(e,r,a,n))}catch(u){return i!==null&&i.closed?{outcome:"closed"}:(he(e,i),console.error("[maytes/checkout-button] createCheckout failed:",u),B(r,"create-checkout-rejected",u),{outcome:"failed",reason:"create-checkout-rejected"})}}function ye(){let e=h("1em","currentColor");return e.setAttribute("class","maytes-checkout-button__logo"),e.setAttribute("aria-hidden","true"),e}function nt(){let e=document.createElement("span");return e.className="maytes-checkout-button__spinner",e.setAttribute("aria-hidden","true"),e}function fe(e,t,o={}){if(e.destroyed)throw new c(s.Config,"renderButton() called on a destroyed Maytes instance");if(!(t instanceof HTMLElement))throw new c(s.Config,"renderButton(container) requires an HTMLElement");let n=q(o),r=x(o.redirectOverlay);pe(e.config.cspNonce);let d=o.label??"Split with",i=o.block===!0,u=E(o.mode??"popup"),a=document.createElement("button");a.type="button",a.className=i?"maytes-checkout-button maytes-checkout-button--block":"maytes-checkout-button",Y(a,n),a.setAttribute("aria-label",`${d} Maytes`);let m=document.createTextNode(`${d} `),b=ye();a.appendChild(m),a.appendChild(b);let ke=k=>{if(k){a.setAttribute("aria-disabled","true"),a.setAttribute("aria-busy","true");let g=nt();b.replaceWith(g),b=g}else{a.removeAttribute("aria-disabled"),a.removeAttribute("aria-busy");let g=ye();b.replaceWith(g),b=g}},I=!1,H=k=>{I&&(ke(k),k||(I=!1))};e.busyViews.add(H);let V=()=>{e.busy||e.destroyed||(I=!0,S(e,u,"button",r))};a.addEventListener("click",V),t.appendChild(a);let j=!1,O=()=>{j||(j=!0,a.removeEventListener("click",V),a.remove(),e.busyViews.delete(H),e.teardowns.delete(O),me())};return e.teardowns.add(O),O}function be(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function ge(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")try{return crypto.randomUUID()}catch{return be()}return be()}function ve(e,t){let o={createCheckout:e.createCheckout,environment:e.environment};return t?.baseUrl!==void 0&&(o.baseUrl=t.baseUrl),t?.cspNonce!==void 0&&(o.cspNonce=t.cspNonce),{config:o,busy:!1,busyViews:new Set,instanceId:ge(),overlayEl:null,overlayDetach:null,restoreDetach:null,popupWindow:null,popupNavigated:!1,popupName:`maytes-checkout-${ge()}`,popupPollHandle:null,destroyed:!1,teardowns:new Set}}function rt(e){if(typeof e!="object"||e===null)throw new c(s.Config,"Maytes() requires an options object");if(typeof e.createCheckout!="function")throw new c(s.Config,"Maytes({ createCheckout }) must be an async function returning { checkoutId }");if(!te(e.environment))throw new c(s.Config,"Maytes({ environment }) must be 'sandbox' or 'production'")}function it(e){e!==void 0&&e.baseUrl!==void 0&&W(e.baseUrl)}var F=(e,t)=>{rt(e),it(t);let o=ve(e,t),{checkoutUrl:n,redirectToCheckout:r}=re(o.config.environment,o.config.baseUrl);return{instanceId:o.instanceId,renderButton(i,u){return fe(o,i,u)},openCheckout(i){if(o.destroyed)throw new c(s.Config,"openCheckout() called on a destroyed Maytes instance");let u=E(i?.mode??"popup","openCheckout"),a=x(i?.redirectOverlay,"openCheckout");return S(o,u,"api",a)},onBusyChange(i){if(o.destroyed)throw new c(s.Config,"onBusyChange() called on a destroyed Maytes instance");return o.busyViews.add(i),()=>{o.busyViews.delete(i)}},redirectToCheckout(i){r(i)},checkoutUrl(i){return n(i)},destroy(){if(!o.destroyed){o.destroyed=!0,v(o),o.restoreDetach?.(),y(o),o.popupNavigated||_(o.popupWindow),o.popupWindow=null,o.busy=!1;for(let i of[...o.teardowns])i();o.teardowns.clear()}}}};typeof window<"u"&&(window.Maytes=F);return Me(at);})();
155
187
  window.Maytes = MaytesCheckoutButton.Maytes;
156
188
  //# sourceMappingURL=checkout-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/appearance.ts","../src/foundation/brand.generated.ts","../src/branding.ts","../src/framing.ts","../src/overlay.ts","../src/env.ts","../src/redirect.ts","../src/version.ts","../src/styles.ts","../src/launch.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 CheckoutClosedDetail,\n CheckoutEventDetail,\n CheckoutFailedDetail,\n CheckoutFailedReason,\n CheckoutOpenedDetail,\n CheckoutRedirectedDetail,\n CheckoutUrlOptions,\n CreateCheckoutFn,\n LaunchSource,\n MaytesEnvironment,\n MaytesFactory,\n MaytesInternalOptions,\n MaytesOptions,\n MaytesSDK,\n OpenCheckoutOptions,\n OpenCheckoutResult,\n RedirectOptions,\n RedirectTarget,\n RenderButtonCleanup,\n RenderButtonMode,\n RenderButtonOptions,\n} from './types.js';\nexport { SDK_VERSION } from './version.js';\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 { MaytesError, MaytesErrorCode } from './errors.js';\nimport type { RenderButtonOptions } from './types.js';\n\nexport const MIN_BUTTON_HEIGHT = 40;\nexport const MAX_BUTTON_HEIGHT = 55;\nexport const MAX_BUTTON_RADIUS = 999;\n\nexport interface ButtonAppearance {\n radius?: number;\n height?: number;\n}\n\nfunction isWholeNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isInteger(value);\n}\n\nexport function assertAppearance(options: Pick<RenderButtonOptions, 'radius' | 'height'>): ButtonAppearance {\n const { radius, height } = options;\n const appearance: ButtonAppearance = {};\n if (height !== undefined) {\n if (!isWholeNumber(height) || height < MIN_BUTTON_HEIGHT || height > MAX_BUTTON_HEIGHT) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n `renderButton({ height }) must be a whole number of pixels from ${MIN_BUTTON_HEIGHT} to ${MAX_BUTTON_HEIGHT}`,\n );\n }\n appearance.height = height;\n }\n if (radius !== undefined) {\n const maxRadius = height === undefined ? MAX_BUTTON_RADIUS : Math.floor(height / 2);\n if (!isWholeNumber(radius) || radius < 0 || radius > maxRadius) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n `renderButton({ radius }) must be a whole number of pixels from 0 to ${maxRadius}`,\n );\n }\n appearance.radius = radius;\n }\n return appearance;\n}\n\nexport function applyAppearance(button: HTMLButtonElement, appearance: ButtonAppearance): void {\n if (appearance.radius !== undefined) button.style.setProperty('--maytes-button-radius', `${appearance.radius}px`);\n if (appearance.height !== undefined) {\n button.style.setProperty('--maytes-button-height', `${appearance.height}px`);\n button.classList.add('maytes-checkout-button--sized');\n }\n}\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","import type { RedirectTarget } from './types.js';\n\nexport interface NavigationOutcome {\n target: RedirectTarget | null;\n cause?: unknown;\n}\n\nexport function isSecurityError(err: unknown): boolean {\n return typeof err === 'object' && err !== null && (err as { name?: unknown }).name === 'SecurityError';\n}\n\nexport function isFramed(): boolean {\n return window.top !== null && window.top !== window;\n}\n\nexport function sameOriginTop(): Window | null {\n if (!isFramed()) return null;\n const top = window.top as Window;\n try {\n void top.document;\n return top;\n } catch (err) {\n if (!isSecurityError(err)) throw err;\n return null;\n }\n}\n\nexport function viewportWidth(): number {\n if (!isFramed()) return window.innerWidth;\n const top = sameOriginTop();\n if (top !== null) return top.innerWidth;\n const screenWidth = window.screen?.width;\n return typeof screenWidth === 'number' && screenWidth > 0 ? screenWidth : window.innerWidth;\n}\n\nfunction navigateWindow(target: Window, url: string, replace: boolean): void {\n if (replace) {\n target.location.replace(url);\n } else {\n target.location.href = url;\n }\n}\n\nfunction severOpener(tab: Window): void {\n try {\n tab.opener = null;\n } catch (err) {\n if (!isSecurityError(err)) throw err;\n }\n}\n\nexport function navigateTopLevel(url: string, replace: boolean): NavigationOutcome {\n if (!isFramed()) {\n navigateWindow(window, url, replace);\n return { target: 'self' };\n }\n let refusal: unknown;\n try {\n navigateWindow(window.top as Window, url, replace);\n return { target: 'top' };\n } catch (err) {\n if (!isSecurityError(err)) throw err;\n refusal = err;\n }\n try {\n const tab = window.open(url, '_blank');\n if (tab !== null) {\n severOpener(tab);\n return { target: 'tab' };\n }\n return { target: null, cause: refusal };\n } catch (err) {\n return { target: null, cause: err };\n }\n}\n","import { buildMaytesLogo, MAYTES_WALLET } from './branding.js';\nimport { isSecurityError, sameOriginTop } from './framing.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 const top = sameOriginTop();\n if (top === null) return null;\n const topDoc = top.document;\n return topDoc.body !== null ? topDoc : null;\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\nexport type OverlayVariant = 'popup' | 'redirect';\n\nfunction buildOverlay(host: Document, state: InstanceState, variant: OverlayVariant): 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 = variant === 'popup' ? 'Completing checkout with Maytes…' : 'Taking you to Maytes…';\n content.appendChild(text);\n\n if (variant === 'popup') {\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 (!isSecurityError(err)) throw err;\n }\n }\n });\n content.appendChild(link);\n }\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, variant: OverlayVariant = 'popup'): void {\n if (state.overlayEl !== null) return;\n const host = resolveOverlayHost();\n ensureOverlayStylesInTopDocument(host);\n const dialog = buildOverlay(host, state, variant);\n state.overlayEl = dialog;\n host.body.appendChild(dialog);\n if (host !== document) detachOverlayWhenThisPageHides(state);\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\nfunction detachOverlayWhenThisPageHides(state: InstanceState): void {\n const onPageHide = () => hideOverlay(state);\n window.addEventListener('pagehide', onPageHide);\n state.overlayDetach = () => window.removeEventListener('pagehide', onPageHide);\n}\n\nexport function hideOverlay(state: InstanceState): void {\n if (state.overlayEl === null) return;\n state.overlayDetach?.();\n state.overlayDetach = null;\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 { navigateTopLevel } from './framing.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 /* v8 ignore next 6 -- unreachable under jsdom; window is always defined in this SDK's browser-only distribution */\n if (typeof window === 'undefined') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'redirectToCheckout requires a browser context (window is undefined)',\n );\n }\n const outcome = navigateTopLevel(url, replace);\n if (outcome.target === null) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'redirectToCheckout could not leave the embedding iframe; call it from a user gesture or from the top-level page',\n );\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.2.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 min-height: var(--maytes-button-height, auto);\n padding: 0.71em 1.29em;\n border-radius: var(--maytes-button-radius, 999px);\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 user-select: none;\n}\n.maytes-checkout-button.maytes-checkout-button,\n.maytes-checkout-button.maytes-checkout-button:hover,\n.maytes-checkout-button.maytes-checkout-button:focus,\n.maytes-checkout-button.maytes-checkout-button:active {\n background: ${foundation.brand.primary};\n border: none;\n color: ${foundation.text.primaryInverse};\n box-shadow: none;\n text-decoration: none;\n text-shadow: none;\n filter: none;\n transform: none;\n opacity: 1;\n cursor: pointer;\n transition: background-color 120ms ease, opacity 120ms ease;\n}\n.maytes-checkout-button.maytes-checkout-button:hover { background: ${foundation.palette.burgundy[700]}; }\n.maytes-checkout-button.maytes-checkout-button:focus:not(:focus-visible) { outline: none; }\n.maytes-checkout-button.maytes-checkout-button:focus-visible {\n outline: 2px solid ${FOCUS_RING};\n outline-offset: 2px;\n}\n.maytes-checkout-button.maytes-checkout-button[aria-disabled='true'] {\n cursor: progress;\n opacity: 0.7;\n}\n.maytes-checkout-button.maytes-checkout-button * { transition: none; }\n.maytes-checkout-button.maytes-checkout-button .maytes-checkout-button__logo,\n.maytes-checkout-button.maytes-checkout-button .maytes-checkout-button__logo * {\n animation: none;\n fill: currentColor;\n}\n.maytes-checkout-button--sized {\n box-sizing: border-box;\n white-space: nowrap;\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 font-size: 0.875rem;\n text-underline-offset: 4px;\n font-family: inherit;\n}\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link,\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:hover,\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus,\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:active {\n background: none;\n border: none;\n color: rgba(255, 255, 255, 0.7);\n box-shadow: none;\n text-decoration: underline;\n text-shadow: none;\n transform: none;\n opacity: 1;\n cursor: pointer;\n transition: color 0.15s;\n}\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:hover { color: ${foundation.text.primaryInverse}; }\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus:not(:focus-visible) { outline: none; }\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus-visible {\n outline: 2px solid ${FOCUS_RING};\n outline-offset: 2px;\n}\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 { isSecurityError, navigateTopLevel, viewportWidth } from './framing.js';\nimport { hideOverlay, showOverlay } from './overlay.js';\nimport { buildCheckoutUrl, isHttpUrl } from './redirect.js';\nimport { POPUP_LOADING_CSS } from './styles.js';\nimport type { InstanceState } from './state.js';\nimport type {\n CheckoutEventDetail,\n CheckoutFailedDetail,\n CheckoutFailedReason,\n CheckoutRedirectedDetail,\n LaunchSource,\n OpenCheckoutResult,\n RedirectTarget,\n RenderButtonMode,\n} 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 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 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 viewportWidth() <= 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\nfunction eventDetail(state: InstanceState, source: LaunchSource): CheckoutEventDetail {\n return { instanceId: state.instanceId, source };\n}\n\nfunction dispatchFailed(origin: CheckoutEventDetail, reason: CheckoutFailedReason, cause?: unknown): void {\n const detail: CheckoutFailedDetail = cause === undefined ? { ...origin, reason } : { ...origin, reason, cause };\n document.dispatchEvent(new CustomEvent('maytes:checkout-failed', { detail }));\n}\n\nfunction dispatchRedirected(origin: CheckoutEventDetail, url: string, target: RedirectTarget): void {\n const detail: CheckoutRedirectedDetail = { ...origin, url, target };\n document.dispatchEvent(new CustomEvent('maytes:checkout-redirected', { detail }));\n}\n\nexport function assertLaunchMode(mode: unknown, caller = 'renderButton'): RenderButtonMode {\n if (mode !== 'redirect' && mode !== 'popup') {\n throw new MaytesError(MaytesErrorCode.Config, `${caller}({ mode }) must be 'redirect' or 'popup'`);\n }\n return mode;\n}\n\nexport function assertRedirectOverlay(value: unknown, caller = 'renderButton'): boolean {\n if (value === undefined) return false;\n if (typeof value !== 'boolean') {\n throw new MaytesError(MaytesErrorCode.Config, `${caller}({ redirectOverlay }) must be true or false`);\n }\n return value;\n}\n\nexport function setInstanceBusy(state: InstanceState, busy: boolean): void {\n state.busy = busy;\n for (const view of [...state.busyViews]) view(busy);\n}\n\nfunction endLaunch(state: InstanceState): void {\n hideOverlay(state);\n setInstanceBusy(state, false);\n}\n\nfunction closeOrphanPopup(state: InstanceState, popup: Window | null): void {\n closePopupWindow(popup);\n stopPopupPoll(state);\n if (state.popupWindow === popup) state.popupWindow = null;\n endLaunch(state);\n}\n\nfunction clearOverlayOnRestore(state: InstanceState): void {\n if (state.restoreDetach !== null) return;\n const onPageShow = (event: PageTransitionEvent): void => {\n if (!event.persisted) return;\n detach();\n endLaunch(state);\n };\n const detach = (): void => {\n window.removeEventListener('pageshow', onPageShow);\n state.restoreDetach = null;\n };\n window.addEventListener('pageshow', onPageShow);\n state.restoreDetach = detach;\n}\n\nfunction navigateAway(\n state: InstanceState,\n origin: CheckoutEventDetail,\n url: string,\n keepOverlay: boolean,\n): OpenCheckoutResult {\n const navigation = navigateTopLevel(url, false);\n if (keepOverlay && (navigation.target === 'self' || navigation.target === 'top')) {\n setInstanceBusy(state, false);\n clearOverlayOnRestore(state);\n } else {\n endLaunch(state);\n }\n if (navigation.target === null) {\n console.error('[maytes/checkout-button] could not leave the embedding frame:', navigation.cause);\n dispatchFailed(origin, 'navigation-blocked', navigation.cause);\n return { outcome: 'failed', reason: 'navigation-blocked' };\n }\n dispatchRedirected(origin, url, navigation.target);\n return { outcome: 'redirected', target: navigation.target };\n}\n\nfunction openPopupLoader(state: InstanceState, origin: CheckoutEventDetail): Window | null {\n const popup = openBlankPopup(state);\n if (popup === null) return 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', { detail: origin }));\n startPopupPoll(state, () => {\n endLaunch(state);\n document.dispatchEvent(new CustomEvent('maytes:checkout-closed', { detail: origin }));\n });\n return popup;\n}\n\nexport async function launchCheckout(\n state: InstanceState,\n mode: RenderButtonMode,\n source: LaunchSource,\n redirectOverlay = false,\n): Promise<OpenCheckoutResult> {\n if (state.busy || state.destroyed) return { outcome: 'ignored' };\n setInstanceBusy(state, true);\n const origin = eventDetail(state, source);\n const shouldUsePopup = mode === 'popup' && !isMobileViewport();\n const popup = shouldUsePopup ? openPopupLoader(state, origin) : null;\n if (popup === null && redirectOverlay) showOverlay(state, 'redirect');\n try {\n const result = await state.config.createCheckout();\n if (state.destroyed || (popup !== null && popup.closed)) {\n closePopupWindow(popup);\n return { outcome: 'closed' };\n }\n if (!isValidCheckoutResult(result)) {\n closeOrphanPopup(state, 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(origin, 'invalid-shape', shapeError);\n return { outcome: 'failed', reason: 'invalid-shape' };\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 return { outcome: 'popup' };\n }\n if (shouldUsePopup) {\n console.warn('[maytes/checkout-button] popup was blocked; redirecting instead');\n }\n return navigateAway(state, origin, url, redirectOverlay);\n } catch (err) {\n if (popup !== null && popup.closed) return { outcome: 'closed' };\n closeOrphanPopup(state, popup);\n console.error('[maytes/checkout-button] createCheckout failed:', err);\n dispatchFailed(origin, 'create-checkout-rejected', err);\n return { outcome: 'failed', reason: 'create-checkout-rejected' };\n }\n}\n","import { applyAppearance, assertAppearance } from './appearance.js';\nimport { buildMaytesLogo } from './branding.js';\nimport { MaytesError, MaytesErrorCode } from './errors.js';\nimport { assertLaunchMode, assertRedirectOverlay, launchCheckout } from './launch.js';\nimport { ensureStylesInjected, releaseStyles } from './styles.js';\nimport type { InstanceState } from './state.js';\nimport type { RenderButtonCleanup, RenderButtonOptions } from './types.js';\n\nexport { closePopupWindow, stopPopupPoll } from './launch.js';\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\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 const appearance = assertAppearance(options);\n const redirectOverlay = assertRedirectOverlay(options.redirectOverlay);\n\n ensureStylesInjected(state.config.cspNonce);\n\n const label = options.label ?? 'Split with';\n const block = options.block === true;\n const mode = assertLaunchMode(options.mode ?? 'popup');\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 applyAppearance(button, appearance);\n button.setAttribute('aria-label', `${label} Maytes`);\n\n const labelNode = document.createTextNode(`${label} `);\n let icon: SVGSVGElement | HTMLSpanElement = buildLogo();\n button.appendChild(labelNode);\n button.appendChild(icon);\n\n const showBusy = (busy: boolean): void => {\n if (busy) {\n button.setAttribute('aria-disabled', 'true');\n button.setAttribute('aria-busy', 'true');\n const spinner = buildSpinner();\n icon.replaceWith(spinner);\n icon = spinner;\n } else {\n button.removeAttribute('aria-disabled');\n button.removeAttribute('aria-busy');\n const nextLogo = buildLogo();\n icon.replaceWith(nextLogo);\n icon = nextLogo;\n }\n };\n let launchedHere = false;\n const followOwnLaunch = (busy: boolean): void => {\n if (!launchedHere) return;\n showBusy(busy);\n if (!busy) launchedHere = false;\n };\n state.busyViews.add(followOwnLaunch);\n\n const handleClick = (): void => {\n if (state.busy || state.destroyed) return;\n launchedHere = true;\n void launchCheckout(state, mode, 'button', redirectOverlay);\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.busyViews.delete(followOwnLaunch);\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 busyViews: Set<(busy: boolean) => void>;\n instanceId: string;\n overlayEl: HTMLDialogElement | null;\n overlayDetach: (() => void) | null;\n restoreDetach: (() => void) | 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 randomSuffix(): string {\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\nfunction randomId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n try {\n return crypto.randomUUID();\n } catch {\n return randomSuffix();\n }\n }\n return randomSuffix();\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 busyViews: new Set(),\n instanceId: randomId(),\n overlayEl: null,\n overlayDetach: null,\n restoreDetach: null,\n popupWindow: null,\n popupNavigated: false,\n popupName: `maytes-checkout-${randomId()}`,\n popupPollHandle: null,\n destroyed: false,\n teardowns: new Set(),\n };\n}\n","import { renderButton } from './button.js';\nimport { assertLaunchMode, assertRedirectOverlay, closePopupWindow, launchCheckout, stopPopupPoll } from './launch.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 instanceId: state.instanceId,\n renderButton(container, opts) {\n return renderButton(state, container, opts);\n },\n openCheckout(opts) {\n if (state.destroyed) {\n throw new MaytesError(MaytesErrorCode.Config, 'openCheckout() called on a destroyed Maytes instance');\n }\n const mode = assertLaunchMode(opts?.mode ?? 'popup', 'openCheckout');\n const redirectOverlay = assertRedirectOverlay(opts?.redirectOverlay, 'openCheckout');\n return launchCheckout(state, mode, 'api', redirectOverlay);\n },\n onBusyChange(listener) {\n if (state.destroyed) {\n throw new MaytesError(MaytesErrorCode.Config, 'onBusyChange() called on a destroyed Maytes instance');\n }\n state.busyViews.add(listener);\n return () => {\n state.busyViews.delete(listener);\n };\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 state.restoreDetach?.();\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":"kdAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,YAAAE,EAAA,gBAAAC,EAAA,oBAAAC,EAAA,gBAAAC,ICAO,IAAMC,EAAkB,CAC7B,OAAQ,QACV,EAIaC,EAAN,cAA0B,KAAM,CAGrC,YAAYC,EAA4BC,EAAiB,CACvD,MAAMA,CAAO,EACb,KAAK,KAAOD,EACZ,KAAK,KAAO,aACd,CACF,ECXO,IAAME,EAAoB,GACpBC,EAAoB,GACpBC,GAAoB,IAOjC,SAASC,EAAcC,EAAiC,CACtD,OAAO,OAAOA,GAAU,UAAY,OAAO,UAAUA,CAAK,CAC5D,CAEO,SAASC,EAAiBC,EAA2E,CAC1G,GAAM,CAAE,OAAAC,EAAQ,OAAAC,CAAO,EAAIF,EACrBG,EAA+B,CAAC,EACtC,GAAID,IAAW,OAAW,CACxB,GAAI,CAACL,EAAcK,CAAM,GAAKA,EAASR,GAAqBQ,EAASP,EACnE,MAAM,IAAIS,EACRC,EAAgB,OAChB,kEAAkEX,CAAiB,OAAOC,CAAiB,EAC7G,EAEFQ,EAAW,OAASD,CACtB,CACA,GAAID,IAAW,OAAW,CACxB,IAAMK,EAAYJ,IAAW,OAAYN,GAAoB,KAAK,MAAMM,EAAS,CAAC,EAClF,GAAI,CAACL,EAAcI,CAAM,GAAKA,E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,EAAM,gBAAgB,EACtBe,EAAYf,CAAK,EACZA,EAAM,gBAAgBgB,EAAiBhB,EAAM,WAAW,EAC7DA,EAAM,YAAc,KACpBA,EAAM,KAAO,GACb,QAAWiB,IAAY,CAAC,GAAGjB,EAAM,SAAS,EAAGiB,EAAS,EACtDjB,EAAM,UAAU,MAAM,EACxB,CACF,CAGF,EdxFI,OAAO,OAAW,MACnB,OAAgD,OAASkB","names":["src_exports","__export","Maytes","MaytesError","MaytesErrorCode","SDK_VERSION","MaytesErrorCode","MaytesError","code","message","MIN_BUTTON_HEIGHT","MAX_BUTTON_HEIGHT","MAX_BUTTON_RADIUS","isWholeNumber","value","assertAppearance","options","radius","height","appearance","MaytesError","MaytesErrorCode","maxRadius","applyAppearance","button","foundation","MAYTES_RICHE","foundation","MAYTES_WALLET","SVG_NS","MAYTES_LOGO_PATHS","buildMaytesLogo","height","color","svg","d","path","isSecurityError","err","isFramed","sameOriginTop","top","viewportWidth","screenWidth","navigateWindow","target","url","replace","severOpener","tab","navigateTopLevel","refusal","TITLE_ID","STYLE_MARKER","NATIVE_BACKDROP_FALLBACK","tryReadTopDocument","top","sameOriginTop","topDoc","resolveOverlayHost","ensureOverlayStylesInTopDocument","host","localStyle","copy","nonce","buildOverlay","state","variant","dialog","content","logoDiv","buildMaytesLogo","MAYTES_WALLET","spinner","text","link","err","isSecurityError","event","hideOverlay","applyNativeBackdropFallback","showOverlay","detachOverlayWhenThisPageHides","onPageHide","ENVIRONMENT_BASE_URLS","isValidEnvironment","value","resolveBaseUrl","environment","override","url","MaytesError","MaytesErrorCode","isHttpUrl","value","parsed","normalizeBaseUrl","rawBaseUrl","candidate","MaytesError","MaytesErrorCode","requireCheckoutId","id","buildCheckoutUrl","environment","baseUrlOverride","checkoutId","resolveBaseUrl","performRedirect","url","replace","navigateTopLevel","makeRedirect","opts","SDK_VERSION","STYLE_ATTR","STYLE_SELECTOR","SDK_VERSION","REFCOUNT_KEY","FOCUS_RING","BUTTON_CSS","foundation","POPUP_LOADING_CSS","getRefCount","setRefCount","value","w","ensureStylesInjected","cspNonce","next","el","releaseStyles","POPUP_WIDTH","POPUP_HEIGHT","POPUP_POLL_INTERVAL_MS","MOBILE_MAX_WIDTH","SLOW_NETWORK_DELAY_MS","isValidCheckoutResult","value","obj","isHttpUrl","refocusPopup","popup","err","isSecurityError","closePopupWindow","popupFeatures","screenWidth","screenHeight","left","top","stopPopupPoll","state","startPopupPoll","onClose","isMobileViewport","viewportWidth","openBlankPopup","navigatePopup","url","removePopupChildren","doc","paintPopupLoadingScreen","cspNonce","style","POPUP_LOADING_CSS","content","logo","buildMaytesLogo","foundation","spinner","text","slow","eventDetail","source","dispatchFailed","origin","reason","cause","detail","dispatchRedirected","target","assertLaunchMode","mode","caller","MaytesError","MaytesErrorCode","assertRedirectOverlay","setInstanceBusy","busy","view","endLaunch","hideOverlay","closeOrphanPopup","clearOverlayOnRestore","onPageShow","event","detach","navigateAway","keepOverlay","navigation","navigateTopLevel","openPopupLoader","showOverlay","launchCheckout","redirectOverlay","shouldUsePopup","result","shapeError","buildCheckoutUrl","buildLogo","svg","buildMaytesLogo","buildSpinner","spinner","renderButton","state","container","options","MaytesError","MaytesErrorCode","appearance","assertAppearance","redirectOverlay","assertRedirectOverlay","ensureStylesInjected","label","block","mode","assertLaunchMode","button","applyAppearance","labelNode","icon","showBusy","busy","nextLogo","launchedHere","followOwnLaunch","handleClick","launchCheckout","cleaned","teardown","releaseStyles","randomSuffix","randomId","createInstanceState","options","internal","config","validateOptions","options","MaytesError","MaytesErrorCode","isValidEnvironment","validateInternalOptions","internal","normalizeBaseUrl","Maytes","state","createInstanceState","checkoutUrl","redirectToCheckout","makeRedirect","container","opts","renderButton","mode","assertLaunchMode","redirectOverlay","assertRedirectOverlay","launchCheckout","listener","stopPopupPoll","hideOverlay","closePopupWindow","teardown","Maytes"]}
@@ -386,7 +386,7 @@ function makeRedirect(environment, baseUrlOverride) {
386
386
  }
387
387
 
388
388
  // src/version.ts
389
- var SDK_VERSION = "1.2.0";
389
+ var SDK_VERSION = "1.2.1";
390
390
 
391
391
  // src/styles.ts
392
392
  var STYLE_ATTR = "data-maytes-checkout-button";
@@ -401,27 +401,45 @@ var BUTTON_CSS = `
401
401
  gap: 0.57em;
402
402
  min-height: var(--maytes-button-height, auto);
403
403
  padding: 0.71em 1.29em;
404
- border: none;
405
404
  border-radius: var(--maytes-button-radius, 999px);
406
- background: ${foundation.brand.primary};
407
- color: ${foundation.text.primaryInverse};
408
405
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
409
406
  font-size: var(--maytes-button-font-size, 14px);
410
407
  font-weight: 600;
411
408
  line-height: 1;
412
- cursor: pointer;
413
409
  user-select: none;
410
+ }
411
+ .maytes-checkout-button.maytes-checkout-button,
412
+ .maytes-checkout-button.maytes-checkout-button:hover,
413
+ .maytes-checkout-button.maytes-checkout-button:focus,
414
+ .maytes-checkout-button.maytes-checkout-button:active {
415
+ background: ${foundation.brand.primary};
416
+ border: none;
417
+ color: ${foundation.text.primaryInverse};
418
+ box-shadow: none;
419
+ text-decoration: none;
420
+ text-shadow: none;
421
+ filter: none;
422
+ transform: none;
423
+ opacity: 1;
424
+ cursor: pointer;
414
425
  transition: background-color 120ms ease, opacity 120ms ease;
415
426
  }
416
- .maytes-checkout-button:hover { background: ${foundation.palette.burgundy[700]}; }
417
- .maytes-checkout-button:focus-visible {
427
+ .maytes-checkout-button.maytes-checkout-button:hover { background: ${foundation.palette.burgundy[700]}; }
428
+ .maytes-checkout-button.maytes-checkout-button:focus:not(:focus-visible) { outline: none; }
429
+ .maytes-checkout-button.maytes-checkout-button:focus-visible {
418
430
  outline: 2px solid ${FOCUS_RING};
419
431
  outline-offset: 2px;
420
432
  }
421
- .maytes-checkout-button[aria-disabled='true'] {
433
+ .maytes-checkout-button.maytes-checkout-button[aria-disabled='true'] {
422
434
  cursor: progress;
423
435
  opacity: 0.7;
424
436
  }
437
+ .maytes-checkout-button.maytes-checkout-button * { transition: none; }
438
+ .maytes-checkout-button.maytes-checkout-button .maytes-checkout-button__logo,
439
+ .maytes-checkout-button.maytes-checkout-button .maytes-checkout-button__logo * {
440
+ animation: none;
441
+ fill: currentColor;
442
+ }
425
443
  .maytes-checkout-button--sized {
426
444
  box-sizing: border-box;
427
445
  white-space: nowrap;
@@ -487,17 +505,31 @@ var BUTTON_CSS = `
487
505
  margin: 0;
488
506
  }
489
507
  .maytes-checkout-overlay__link {
490
- color: rgba(255, 255, 255, 0.7);
491
508
  font-size: 0.875rem;
492
- text-decoration: underline;
493
509
  text-underline-offset: 4px;
510
+ font-family: inherit;
511
+ }
512
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link,
513
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:hover,
514
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus,
515
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:active {
494
516
  background: none;
495
517
  border: none;
518
+ color: rgba(255, 255, 255, 0.7);
519
+ box-shadow: none;
520
+ text-decoration: underline;
521
+ text-shadow: none;
522
+ transform: none;
523
+ opacity: 1;
496
524
  cursor: pointer;
497
- font-family: inherit;
498
525
  transition: color 0.15s;
499
526
  }
500
- .maytes-checkout-overlay__link:hover { color: ${foundation.text.primaryInverse}; }
527
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:hover { color: ${foundation.text.primaryInverse}; }
528
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus:not(:focus-visible) { outline: none; }
529
+ .maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus-visible {
530
+ outline: 2px solid ${FOCUS_RING};
531
+ outline-offset: 2px;
532
+ }
501
533
  @media (prefers-reduced-motion: reduce) {
502
534
  .maytes-checkout-overlay__spinner,
503
535
  .maytes-checkout-button__spinner { animation: none; }