@openrails/billing-ui 0.252.1 → 0.254.0

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +15 -4
  3. package/dist/admin/context.d.ts +4 -4
  4. package/dist/admin/lib/api/endpoints.d.ts +2 -2
  5. package/dist/admin/lib/api/index.d.ts +1 -1
  6. package/dist/admin/lib/api/types.d.ts +1 -1
  7. package/dist/admin/lib/mutations.d.ts +1 -1
  8. package/dist/admin/messages.d.ts +10 -0
  9. package/dist/{admin-catalog-Bsxo2gyS.js → admin-catalog-rrFZd5N8.js} +2 -2
  10. package/dist/{admin-catalog-Bsxo2gyS.js.map → admin-catalog-rrFZd5N8.js.map} +1 -1
  11. package/dist/{admin-detail-DG-YaHhS.js → admin-detail-DAOjLNL9.js} +2 -2
  12. package/dist/admin-detail-DAOjLNL9.js.map +1 -0
  13. package/dist/{admin-orders-8XzHf7b-.js → admin-orders-DMSOum9t.js} +2 -2
  14. package/dist/admin-orders-DMSOum9t.js.map +1 -0
  15. package/dist/{admin-price-detail-ByCmrx_W.js → admin-price-detail-Bwk9PXHP.js} +2 -2
  16. package/dist/{admin-price-detail-ByCmrx_W.js.map → admin-price-detail-Bwk9PXHP.js.map} +1 -1
  17. package/dist/{admin-price-wizard-m7Qjhq6W.js → admin-price-wizard-ByD7j8mB.js} +2 -2
  18. package/dist/admin-price-wizard-ByD7j8mB.js.map +1 -0
  19. package/dist/{admin-settings-BIUgvclv.js → admin-settings-D_8L1Hho.js} +101 -76
  20. package/dist/admin-settings-D_8L1Hho.js.map +1 -0
  21. package/dist/admin-utils-DnVY5fYd.js.map +1 -1
  22. package/dist/admin.js +17 -7
  23. package/dist/admin.js.map +1 -1
  24. package/dist/buy-button.d.ts +4 -1
  25. package/dist/cart.d.ts +4 -1
  26. package/dist/client/generated/error-codes.d.ts +1 -1
  27. package/dist/client/generated/routes.d.ts +4 -4
  28. package/dist/client/generated/wire.d.ts +59 -23
  29. package/dist/client/types.d.ts +13 -7
  30. package/dist/{client-imFR1UCe.js → client-B301IAQD.js} +6 -5
  31. package/dist/client-B301IAQD.js.map +1 -0
  32. package/dist/client.js +1 -1
  33. package/dist/components/platform-card-form.d.ts +10 -0
  34. package/dist/create-card-BEILS1VB-DeyyfyFD.js +140 -0
  35. package/dist/create-card-BEILS1VB-DeyyfyFD.js.map +1 -0
  36. package/dist/create-card-display-Dv5pcpzc-BWB6vzo2.js +166 -0
  37. package/dist/create-card-display-Dv5pcpzc-BWB6vzo2.js.map +1 -0
  38. package/dist/create-copy-button-CAYmfugS-qNapojfj.js +125 -0
  39. package/dist/create-copy-button-CAYmfugS-qNapojfj.js.map +1 -0
  40. package/dist/embedded-payment.d.ts +4 -1
  41. package/dist/fallbacks.d.ts +25 -0
  42. package/dist/{hooks-C9JkHcRt.js → hooks-DARbMTwv.js} +69 -59
  43. package/dist/hooks-DARbMTwv.js.map +1 -0
  44. package/dist/index-rGw83t5v-BE6naeQR.js +1801 -0
  45. package/dist/index-rGw83t5v-BE6naeQR.js.map +1 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.js +1160 -975
  48. package/dist/index.js.map +1 -1
  49. package/dist/locales/de.js +1 -0
  50. package/dist/locales/de.js.map +1 -1
  51. package/dist/locales/en.d.ts +1 -0
  52. package/dist/locales/en.js +1 -0
  53. package/dist/locales/en.js.map +1 -1
  54. package/dist/locales/es.js +1 -0
  55. package/dist/locales/es.js.map +1 -1
  56. package/dist/locales/ja.js +1 -0
  57. package/dist/locales/ja.js.map +1 -1
  58. package/dist/locales/ko.js +1 -0
  59. package/dist/locales/ko.js.map +1 -1
  60. package/dist/locales/zh.js +1 -0
  61. package/dist/locales/zh.js.map +1 -1
  62. package/dist/order-payment.d.ts +8 -1
  63. package/dist/product-list.d.ts +4 -1
  64. package/dist/psp.d.ts +1 -1
  65. package/dist/react.js +1 -1
  66. package/package.json +2 -1
  67. package/dist/admin-detail-DG-YaHhS.js.map +0 -1
  68. package/dist/admin-orders-8XzHf7b-.js.map +0 -1
  69. package/dist/admin-price-wizard-m7Qjhq6W.js.map +0 -1
  70. package/dist/admin-settings-BIUgvclv.js.map +0 -1
  71. package/dist/client-imFR1UCe.js.map +0 -1
  72. package/dist/hooks-C9JkHcRt.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-card-display-Dv5pcpzc-BWB6vzo2.js","names":[],"sources":["../node_modules/.pnpm/@basis-theory+web-elements@3.2.0/node_modules/@basis-theory/web-elements/dist/create-card-display-Dv5pcpzc.js"],"sourcesContent":["import { C as ConfigurationError, E as ElementError, c as createIframe, a as createPostMessageClient, b as bindCoordinatorPort, l as log, e as createMounter } from \"./index-rGw83t5v.js\";\nconst SESSION_AUTH_TIMEOUT_MS = 3e4;\nconst createCardDisplayElement = (_apiKey, sdkConfig, options, coordinatorElementId, ensureCoordinatorReady, notifyCoordinatorElementUnmount, coordinatorRequest) => {\n if (!options.tokenId || typeof options.tokenId !== \"string\") {\n throw ConfigurationError(\"tokenId is required for cardDisplay element\");\n }\n if (options.allowClipboard === true && !sdkConfig.allowClipboard) {\n throw ConfigurationError(\n \"cardDisplay clipboard access requires allowClipboard: true on BasisTheory() initialization.\"\n );\n }\n let iframe = null;\n let client = null;\n let mounter = null;\n let isMounted = false;\n let isLoaded = false;\n let container = null;\n let currentTokenId = options.tokenId;\n const eventTarget = new EventTarget();\n const id = coordinatorElementId;\n const type = \"cardDisplay\";\n const dispatchEvent = (eventType, detail) => {\n eventTarget.dispatchEvent(new CustomEvent(eventType, {\n detail: {\n elementType: type,\n elementId: id,\n timestamp: Date.now(),\n ...detail\n }\n }));\n };\n const dispatchLoadError = (code, error) => {\n log(\"Failed to load display token\", {\n error: error.message\n });\n dispatchEvent(\"error\", { code, message: error.message });\n };\n const releaseDisplaySession = async () => {\n try {\n await coordinatorRequest(\"CMD_CLEAR_DISPLAY_SESSION\", { elementId: id });\n } catch (error) {\n log(\"Failed to release display session\", {\n error: error.message\n });\n }\n };\n const loadDisplayToken = async (tokenId) => {\n if (!sdkConfig.sessionAuthorizationUrl) {\n dispatchLoadError(\n \"SESSION_AUTHORIZATION_FAILED\",\n ConfigurationError(\"sessionAuthorizationUrl is required to load cardDisplay data\")\n );\n return;\n }\n let nonce;\n try {\n const result = await coordinatorRequest(\n \"CMD_CREATE_DISPLAY_SESSION\",\n { tokenId, elementId: id }\n );\n if (!(result == null ? void 0 : result.nonce)) {\n return;\n }\n nonce = result.nonce;\n } catch (error) {\n dispatchLoadError(\"SESSION_CREATION_FAILED\", error);\n return;\n }\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), SESSION_AUTH_TIMEOUT_MS);\n let authResponse;\n try {\n authResponse = await fetch(sdkConfig.sessionAuthorizationUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n // No credentials: the request only carries the session nonce, and\n // sending credentials is incompatible with a wildcard CORS origin\n // (Access-Control-Allow-Origin: *), which merchant authorize endpoints\n // commonly use.\n body: JSON.stringify({ nonce }),\n signal: controller.signal\n });\n } catch (error) {\n await releaseDisplaySession();\n dispatchLoadError(\"NETWORK_ERROR\", error);\n return;\n } finally {\n clearTimeout(timeout);\n }\n if (!authResponse.ok) {\n await releaseDisplaySession();\n dispatchLoadError(\n \"SESSION_AUTHORIZATION_FAILED\",\n ElementError(\n `Session authorization failed: ${authResponse.status} ${authResponse.statusText}`,\n id\n )\n );\n return;\n }\n try {\n await coordinatorRequest(\"CMD_RETRIEVE_DISPLAY_TOKEN\", {\n tokenId,\n elementId: id\n });\n } catch (error) {\n dispatchLoadError(\"TOKEN_RETRIEVAL_FAILED\", error);\n }\n };\n const element = {\n id,\n type,\n get mounted() {\n return isMounted;\n },\n get loaded() {\n return isLoaded;\n },\n mount: async (selector) => {\n if (isMounted) {\n throw ElementError(\"Element is already mounted\", id);\n }\n container = typeof selector === \"string\" ? document.querySelector(selector) : selector;\n if (!container) {\n throw ElementError(`Container not found: ${selector}`);\n }\n const parentOrigin = window.location.origin;\n const iframeUrl = new URL(`${sdkConfig.elementsBaseUrl}/card-display.html`);\n iframeUrl.searchParams.set(\"parentOrigin\", parentOrigin);\n iframeUrl.searchParams.set(\"elementId\", id);\n iframeUrl.searchParams.set(\"debug\", String(sdkConfig.debug || false));\n iframe = createIframe({\n src: iframeUrl.toString(),\n sandbox: \"allow-scripts allow-same-origin\",\n allow: options.allowClipboard === true ? \"clipboard-write\" : \"\",\n title: \"Card Display\"\n });\n iframe.setAttribute(\"data-bt-element-id\", id);\n client = createPostMessageClient(iframe, {\n targetOrigin: sdkConfig.iframeOrigin,\n timeout: sdkConfig.timeoutMs,\n retries: sdkConfig.retryConfig.maxRetries,\n debug: sdkConfig.debug\n });\n mounter = createMounter();\n const readyPromise = new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(ElementError(\n `Iframe EVENT_READY not received within ${sdkConfig.timeoutMs}ms`,\n id,\n { elementType: type, timeoutMs: sdkConfig.timeoutMs }\n ));\n }, sdkConfig.timeoutMs);\n const unsubscribe = client.subscribe(\"EVENT_READY\", () => {\n clearTimeout(timeout);\n unsubscribe();\n resolve();\n });\n });\n client.subscribe(\"EVENT_CHANGE\", (payload) => {\n if (payload.loaded) {\n isLoaded = true;\n }\n dispatchEvent(\"change\", payload);\n });\n client.subscribe(\"EVENT_ERROR\", (payload) => {\n dispatchEvent(\"error\", payload);\n });\n client.subscribe(\"EVENT_CONTENT_HEIGHT\", (payload) => {\n const height = payload == null ? void 0 : payload.heightPx;\n if (!iframe || typeof height !== \"number\" || !Number.isFinite(height) || height <= 0) {\n return;\n }\n const roundedHeight = Math.ceil(height);\n iframe.style.height = `${roundedHeight}px`;\n dispatchEvent(\"resize\", { height: roundedHeight });\n });\n mounter.mount(container, iframe, {\n timeoutMs: sdkConfig.timeoutMs\n });\n isMounted = true;\n try {\n await ensureCoordinatorReady();\n await readyPromise;\n await bindCoordinatorPort({\n elementId: id,\n elementType: type,\n client,\n coordinatorRequest\n });\n await client.sendRequest(\"CMD_SET_CONFIG\", {\n elementId: id,\n tokenId: currentTokenId,\n theme: sdkConfig.theme,\n darkTheme: sdkConfig.darkTheme,\n themeMode: sdkConfig.themeMode,\n direction: sdkConfig.direction,\n language: sdkConfig.language,\n number: options.number,\n cvc: options.cvc,\n expiration: options.expiration,\n layout: options.layout,\n fieldOrder: options.fieldOrder,\n showToggle: options.showToggle,\n allowClipboard: options.allowClipboard,\n debug: sdkConfig.debug\n });\n if (iframe) iframe.style.opacity = \"1\";\n dispatchEvent(\"ready\", {});\n if (currentTokenId) {\n void loadDisplayToken(currentTokenId);\n }\n } catch (error) {\n dispatchEvent(\"error\", {\n code: \"MOUNT_ERROR\",\n message: error.message\n });\n isMounted = false;\n if (client) {\n client.destroy();\n client = null;\n }\n if (mounter && iframe) {\n mounter.unmount(iframe);\n iframe = null;\n mounter = null;\n }\n container = null;\n throw error;\n }\n },\n unmount: () => {\n if (!isMounted) {\n throw ElementError(\"Element is not mounted\");\n }\n void releaseDisplaySession();\n notifyCoordinatorElementUnmount(id).catch((error) => {\n log(\"Failed to notify coordinator of element unmount\", {\n error: error.message\n });\n });\n if (client) {\n client.sendRequest(\"CMD_CLEAR\", {}).catch((error) => {\n log(\"Failed to send clear command\", {\n error: error.message\n });\n });\n client.destroy();\n client = null;\n }\n if (mounter && iframe) {\n mounter.unmount(iframe);\n iframe = null;\n mounter = null;\n }\n container = null;\n isMounted = false;\n isLoaded = false;\n },\n update: async (newOptions) => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before updating\", id);\n }\n if (newOptions.allowClipboard === true && !sdkConfig.allowClipboard) {\n throw ConfigurationError(\n \"cardDisplay clipboard access requires allowClipboard: true on BasisTheory() initialization.\"\n );\n }\n if (newOptions.tokenId !== void 0 && newOptions.tokenId !== currentTokenId) {\n currentTokenId = newOptions.tokenId;\n isLoaded = false;\n await client.sendRequest(\"CMD_CLEAR\", {});\n void loadDisplayToken(currentTokenId);\n }\n const updatePayload = {};\n if (newOptions.number !== void 0) {\n updatePayload.number = newOptions.number;\n }\n if (newOptions.cvc !== void 0) {\n updatePayload.cvc = newOptions.cvc;\n }\n if (newOptions.expiration !== void 0) {\n updatePayload.expiration = newOptions.expiration;\n }\n if (newOptions.layout !== void 0) {\n updatePayload.layout = newOptions.layout;\n }\n if (newOptions.fieldOrder !== void 0) {\n updatePayload.fieldOrder = newOptions.fieldOrder;\n }\n if (newOptions.showToggle !== void 0) {\n updatePayload.showToggle = newOptions.showToggle;\n }\n if (newOptions.allowClipboard !== void 0) {\n updatePayload.allowClipboard = newOptions.allowClipboard;\n iframe == null ? void 0 : iframe.setAttribute(\"allow\", newOptions.allowClipboard ? \"clipboard-write\" : \"\");\n }\n if (newOptions.themeMode !== void 0) {\n updatePayload.themeMode = newOptions.themeMode;\n updatePayload.theme = sdkConfig.theme;\n updatePayload.darkTheme = sdkConfig.darkTheme;\n }\n if (Object.keys(updatePayload).length > 0) {\n await client.sendRequest(\"CMD_UPDATE_CONFIG\", updatePayload);\n }\n },\n on: (eventType, listener) => {\n eventTarget.addEventListener(\n eventType,\n listener\n );\n return () => eventTarget.removeEventListener(\n eventType,\n listener\n );\n },\n // No-ops for API compatibility with Element interface\n focus: () => {\n },\n blur: () => {\n },\n clear: () => {\n }\n };\n return element;\n};\nexport {\n createCardDisplayElement\n};\n"],"x_google_ignoreList":[0],"mappings":";;AACA,IAAM,IAA0B,KAC1B,KAA4B,GAAS,GAAW,GAAS,GAAsB,GAAwB,GAAiC,MAAuB;CACnK,IAAI,CAAC,EAAQ,WAAW,OAAO,EAAQ,WAAY,UACjD,MAAM,EAAmB,6CAA6C;CAExE,IAAI,EAAQ,mBAAmB,MAAQ,CAAC,EAAU,gBAChD,MAAM,EACJ,6FACF;CAEF,IAAI,IAAS,MACT,IAAS,MACT,IAAU,MACV,IAAY,IACZ,IAAW,IACX,IAAY,MACZ,IAAiB,EAAQ,SACvB,IAAc,IAAI,YAAY,GAC9B,IAAK,GACL,IAAO,eACP,K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,WACrC,EAAc,QAAQ,EAAU,OAChC,EAAc,YAAY,EAAU,YAElC,OAAO,KAAK,CAAa,CAAC,CAAC,SAAS,KACtC,MAAM,EAAO,YAAY,qBAAqB,CAAa;EAE/D;EACA,KAAK,GAAW,OACd,EAAY,iBACV,GACA,CACF,SACa,EAAY,oBACvB,GACA,CACF;EAGF,aAAa,CACb;EACA,YAAY,CACZ;EACA,aAAa,CACb;CAEW;AACf"}
@@ -0,0 +1,125 @@
1
+ import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s } from "./index-rGw83t5v-BE6naeQR.js";
2
+ //#region node_modules/.pnpm/@basis-theory+web-elements@3.2.0/node_modules/@basis-theory/web-elements/dist/create-copy-button-CAYmfugS.js
3
+ var c = (c, l, u, d, f, p, m) => {
4
+ let h = u;
5
+ if (h?.allowClipboard !== !0) throw i("CopyButton requires allowClipboard: true. Clipboard access for raw card data may not be PCI compliant and must be explicitly enabled.", {
6
+ received: h?.allowClipboard,
7
+ expected: !0,
8
+ elementType: "copyButton"
9
+ });
10
+ if (!l.allowClipboard) throw i("CopyButton also requires allowClipboard: true on BasisTheory() initialization. The coordinator only honors copy references when clipboard access was enabled at init.", {
11
+ received: l.allowClipboard,
12
+ expected: !0,
13
+ elementType: "copyButton"
14
+ });
15
+ let g = null, _ = null, v = null, y = !1, b = null, x = null, S = new EventTarget(), C = d, w = "copyButton", T = () => {
16
+ _ && (x = e({
17
+ elementType: w,
18
+ elementId: C,
19
+ client: _,
20
+ eventTarget: S
21
+ }), x.setupSubscriptions(), _.subscribe("EVENT_COPY", (e) => {
22
+ let t = new CustomEvent("copy", { detail: {
23
+ elementType: w,
24
+ elementId: C,
25
+ timestamp: Date.now(),
26
+ success: e?.success ?? !1,
27
+ error: e?.error
28
+ } });
29
+ S.dispatchEvent(t);
30
+ }));
31
+ };
32
+ return {
33
+ id: C,
34
+ type: w,
35
+ get mounted() {
36
+ return y;
37
+ },
38
+ get loaded() {
39
+ return y;
40
+ },
41
+ mount: async (e) => {
42
+ if (y) throw o("Element is already mounted", C);
43
+ if (b = typeof e == "string" ? document.querySelector(e) : e, !b) throw o(`Container not found: ${e}`);
44
+ let r = window.location.origin, i = new URL(`${l.elementsBaseUrl}/copy-button.html`);
45
+ i.searchParams.set("parentOrigin", r), i.searchParams.set("elementId", C), i.searchParams.set("measurePerformance", String(l.measurePerformance || !1)), i.searchParams.set("debug", String(l.debug || !1)), g = a({
46
+ src: i.toString(),
47
+ sandbox: "allow-scripts allow-same-origin",
48
+ allow: "clipboard-write",
49
+ title: "Copy Button"
50
+ }), g.setAttribute("data-bt-element-id", C), _ = t(g, {
51
+ targetOrigin: l.iframeOrigin,
52
+ timeout: l.timeoutMs,
53
+ retries: l.retryConfig.maxRetries,
54
+ debug: l.debug
55
+ }), v = s(), T();
56
+ let c = new Promise((e, t) => {
57
+ let n = setTimeout(() => {
58
+ t(o(`Iframe EVENT_READY not received within ${l.timeoutMs}ms`, C, {
59
+ elementType: w,
60
+ timeoutMs: l.timeoutMs
61
+ }));
62
+ }, l.timeoutMs);
63
+ S.addEventListener("ready", () => {
64
+ clearTimeout(n), e();
65
+ }, { once: !0 });
66
+ });
67
+ v.mount(b, g, { timeoutMs: l.timeoutMs }), y = !0;
68
+ try {
69
+ await f(), await c, await n({
70
+ elementId: C,
71
+ elementType: w,
72
+ client: _,
73
+ coordinatorRequest: m
74
+ }), await _.sendRequest("CMD_SET_CONFIG", {
75
+ elementId: C,
76
+ theme: l.theme,
77
+ darkTheme: l.darkTheme,
78
+ themeMode: l.themeMode,
79
+ direction: l.direction,
80
+ language: l.language,
81
+ text: h.text || "Copy",
82
+ value: h.value,
83
+ disabled: h.disabled,
84
+ debug: l.debug
85
+ }), g && (g.style.opacity = "1");
86
+ } catch (e) {
87
+ throw x && x.dispatchError("MOUNT_ERROR", e.message, e), y = !1, _ &&= (_.destroy(), null), v && g && (v.unmount(g), g = null, v = null), x = null, b = null, e;
88
+ }
89
+ },
90
+ unmount: () => {
91
+ if (!y) throw o("Element is not mounted");
92
+ p(C).catch((e) => {
93
+ r("Failed to notify coordinator of element unmount", { error: e.message });
94
+ }), _ &&= (_.destroy(), null), v && g && (v.unmount(g), g = null, v = null), x = null, b = null, y = !1;
95
+ },
96
+ update: async (e) => {
97
+ if (!y || !_) throw o("Element must be mounted before updating", C);
98
+ let t = {}, n = e;
99
+ n.text !== void 0 && (t.text = n.text), n.value !== void 0 && (t.value = n.value), n.disabled !== void 0 && (t.disabled = n.disabled), e.themeMode !== void 0 && (t.themeMode = e.themeMode, t.theme = l.theme, t.darkTheme = l.darkTheme), await _.sendRequest("CMD_UPDATE_CONFIG", t);
100
+ },
101
+ focus: () => {
102
+ if (!y || !_) throw o("Element must be mounted before focusing", C);
103
+ _.sendRequest("CMD_FOCUS", {});
104
+ },
105
+ blur: () => {
106
+ if (!y || !_) throw o("Element must be mounted before blurring", C);
107
+ _.sendRequest("CMD_BLUR", {});
108
+ },
109
+ clear: () => {},
110
+ on: (e, t) => (S.addEventListener(e, t), () => S.removeEventListener(e, t)),
111
+ setValueRef: async (e) => {
112
+ if (r("setValueRef called", { refElementId: e?.id }), !e || !e.id) throw o("setValueRef requires a valid Element with an ID", C);
113
+ if (!y || !_) throw o("Element must be mounted before calling setValueRef", C);
114
+ let t = await m("CMD_SET_COPY_REFERENCE", {
115
+ elementId: C,
116
+ referenceElementId: e.id
117
+ });
118
+ if (!t?.success) throw o(`Coordinator rejected the copy reference (${t?.error ?? "UNKNOWN"})`, C);
119
+ }
120
+ };
121
+ };
122
+ //#endregion
123
+ export { c as createCopyButtonElement };
124
+
125
+ //# sourceMappingURL=create-copy-button-CAYmfugS-qNapojfj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-copy-button-CAYmfugS-qNapojfj.js","names":[],"sources":["../node_modules/.pnpm/@basis-theory+web-elements@3.2.0/node_modules/@basis-theory/web-elements/dist/create-copy-button-CAYmfugS.js"],"sourcesContent":["import { C as ConfigurationError, l as log, E as ElementError, c as createIframe, a as createPostMessageClient, b as bindCoordinatorPort, d as createEventDispatcher, e as createMounter } from \"./index-rGw83t5v.js\";\nconst createCopyButtonElement = (_apiKey, sdkConfig, inputOptions, coordinatorElementId, ensureCoordinatorReady, notifyCoordinatorElementUnmount, coordinatorRequest) => {\n const options = inputOptions;\n if ((options == null ? void 0 : options.allowClipboard) !== true) {\n throw ConfigurationError(\n \"CopyButton requires allowClipboard: true. Clipboard access for raw card data may not be PCI compliant and must be explicitly enabled.\",\n {\n received: options == null ? void 0 : options.allowClipboard,\n expected: true,\n elementType: \"copyButton\"\n }\n );\n }\n if (!sdkConfig.allowClipboard) {\n throw ConfigurationError(\n \"CopyButton also requires allowClipboard: true on BasisTheory() initialization. The coordinator only honors copy references when clipboard access was enabled at init.\",\n {\n received: sdkConfig.allowClipboard,\n expected: true,\n elementType: \"copyButton\"\n }\n );\n }\n let iframe = null;\n let client = null;\n let mounter = null;\n let isMounted = false;\n let container = null;\n let eventDispatcher = null;\n const eventTarget = new EventTarget();\n const id = coordinatorElementId;\n const type = \"copyButton\";\n const setupEventListeners = () => {\n if (!client) return;\n eventDispatcher = createEventDispatcher({\n elementType: type,\n elementId: id,\n client,\n eventTarget\n });\n eventDispatcher.setupSubscriptions();\n client.subscribe(\"EVENT_COPY\", (payload) => {\n const event = new CustomEvent(\"copy\", {\n detail: {\n elementType: type,\n elementId: id,\n timestamp: Date.now(),\n success: (payload == null ? void 0 : payload.success) ?? false,\n error: payload == null ? void 0 : payload.error\n }\n });\n eventTarget.dispatchEvent(event);\n });\n };\n const element = {\n id,\n type,\n get mounted() {\n return isMounted;\n },\n get loaded() {\n return isMounted;\n },\n mount: async (selector) => {\n if (isMounted) {\n throw ElementError(\"Element is already mounted\", id);\n }\n container = typeof selector === \"string\" ? document.querySelector(selector) : selector;\n if (!container) {\n throw ElementError(`Container not found: ${selector}`);\n }\n const parentOrigin = window.location.origin;\n const iframeUrl = new URL(`${sdkConfig.elementsBaseUrl}/copy-button.html`);\n iframeUrl.searchParams.set(\"parentOrigin\", parentOrigin);\n iframeUrl.searchParams.set(\"elementId\", id);\n iframeUrl.searchParams.set(\n \"measurePerformance\",\n String(sdkConfig.measurePerformance || false)\n );\n iframeUrl.searchParams.set(\"debug\", String(sdkConfig.debug || false));\n iframe = createIframe({\n src: iframeUrl.toString(),\n sandbox: \"allow-scripts allow-same-origin\",\n // clipboard-write is required for Firefox/Safari clipboard access in iframes\n allow: \"clipboard-write\",\n title: \"Copy Button\"\n });\n iframe.setAttribute(\"data-bt-element-id\", id);\n client = createPostMessageClient(iframe, {\n targetOrigin: sdkConfig.iframeOrigin,\n timeout: sdkConfig.timeoutMs,\n retries: sdkConfig.retryConfig.maxRetries,\n debug: sdkConfig.debug\n });\n mounter = createMounter();\n setupEventListeners();\n const readyPromise = new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(\n ElementError(\n `Iframe EVENT_READY not received within ${sdkConfig.timeoutMs}ms`,\n id,\n { elementType: type, timeoutMs: sdkConfig.timeoutMs }\n )\n );\n }, sdkConfig.timeoutMs);\n const handleReady = () => {\n clearTimeout(timeout);\n resolve();\n };\n eventTarget.addEventListener(\"ready\", handleReady, { once: true });\n });\n mounter.mount(container, iframe, {\n timeoutMs: sdkConfig.timeoutMs\n });\n isMounted = true;\n try {\n await ensureCoordinatorReady();\n await readyPromise;\n await bindCoordinatorPort({\n elementId: id,\n elementType: type,\n client,\n coordinatorRequest\n });\n await client.sendRequest(\"CMD_SET_CONFIG\", {\n elementId: id,\n theme: sdkConfig.theme,\n darkTheme: sdkConfig.darkTheme,\n themeMode: sdkConfig.themeMode,\n direction: sdkConfig.direction,\n language: sdkConfig.language,\n text: options.text || \"Copy\",\n value: options.value,\n disabled: options.disabled,\n debug: sdkConfig.debug\n });\n if (iframe) iframe.style.opacity = \"1\";\n } catch (error) {\n if (eventDispatcher) {\n eventDispatcher.dispatchError(\n \"MOUNT_ERROR\",\n error.message,\n error\n );\n }\n isMounted = false;\n if (client) {\n client.destroy();\n client = null;\n }\n if (mounter && iframe) {\n mounter.unmount(iframe);\n iframe = null;\n mounter = null;\n }\n eventDispatcher = null;\n container = null;\n throw error;\n }\n },\n unmount: () => {\n if (!isMounted) {\n throw ElementError(\"Element is not mounted\");\n }\n notifyCoordinatorElementUnmount(id).catch((error) => {\n log(\"Failed to notify coordinator of element unmount\", {\n error: error.message\n });\n });\n if (client) {\n client.destroy();\n client = null;\n }\n if (mounter && iframe) {\n mounter.unmount(iframe);\n iframe = null;\n mounter = null;\n }\n eventDispatcher = null;\n container = null;\n isMounted = false;\n },\n update: async (newOptions) => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before updating\", id);\n }\n const updatePayload = {};\n const copyButtonOptions = newOptions;\n if (copyButtonOptions.text !== void 0) {\n updatePayload.text = copyButtonOptions.text;\n }\n if (copyButtonOptions.value !== void 0) {\n updatePayload.value = copyButtonOptions.value;\n }\n if (copyButtonOptions.disabled !== void 0) {\n updatePayload.disabled = copyButtonOptions.disabled;\n }\n if (newOptions.themeMode !== void 0) {\n updatePayload.themeMode = newOptions.themeMode;\n updatePayload.theme = sdkConfig.theme;\n updatePayload.darkTheme = sdkConfig.darkTheme;\n }\n await client.sendRequest(\"CMD_UPDATE_CONFIG\", updatePayload);\n },\n focus: () => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before focusing\", id);\n }\n client.sendRequest(\"CMD_FOCUS\", {});\n },\n blur: () => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before blurring\", id);\n }\n client.sendRequest(\"CMD_BLUR\", {});\n },\n // No-op for CopyButton (nothing to clear in a button)\n clear: () => {\n },\n on: (eventType, listener) => {\n eventTarget.addEventListener(\n eventType,\n listener\n );\n return () => eventTarget.removeEventListener(\n eventType,\n listener\n );\n },\n /**\n * Link this copy button to another element's value.\n *\n * Authorized by the coordinator, not the iframe: it checks both ids are ones\n * it registered, then forwards the value over this button's port.\n */\n setValueRef: async (refElement) => {\n log(\"setValueRef called\", {\n refElementId: refElement == null ? void 0 : refElement.id\n });\n if (!refElement || !refElement.id) {\n throw ElementError(\"setValueRef requires a valid Element with an ID\", id);\n }\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before calling setValueRef\", id);\n }\n const result = await coordinatorRequest(\n \"CMD_SET_COPY_REFERENCE\",\n { elementId: id, referenceElementId: refElement.id }\n );\n if (!(result == null ? void 0 : result.success)) {\n throw ElementError(\n `Coordinator rejected the copy reference (${(result == null ? void 0 : result.error) ?? \"UNKNOWN\"})`,\n id\n );\n }\n }\n };\n return element;\n};\nexport {\n createCopyButtonElement\n};\n"],"x_google_ignoreList":[0],"mappings":";;AACA,IAAM,KAA2B,GAAS,GAAW,GAAc,GAAsB,GAAwB,GAAiC,MAAuB;CACvK,IAAM,IAAU;CAChB,IAAK,GAAmC,mBAAoB,IAC1D,MAAM,EACJ,yIACA;EACE,UAAU,GAAmC;EAC7C,UAAU;EACV,aAAa;CACf,CACF;CAEF,IAAI,CAAC,EAAU,gBACb,MAAM,EACJ,yKACA;EACE,UAAU,EAAU;EACpB,UAAU;EACV,aAAa;CACf,CACF;CAEF,IAAI,IAAS,MACT,IAAS,MACT,IAAU,MACV,IAAY,IACZ,IAAY,MACZ,IAAkB,MAChB,IAAc,IAAI,YAAY,GAC9B,IAAK,GACL,IAAO,cACP,UAA4B;EAC3B,MACL,IAAkB,EAAsB;GACtC,aAAa;GACb,WAAW;GACX;GACA;EACF,CAAC,GACD,EAAgB,mBAAmB,GACnC,EAAO,UAAU,eAAe,MAAY;GAC1C,IAAM,IAAQ,IAAI,YAAY,QAAQ,EACpC,QAAQ;IACN,aAAa;IACb,WAAW;IACX,WAAW,KAAK,IAAI;IACpB,SAAU,GAAmC,WAAY;IACzD,OAAO,GAAmC;GAC5C,EACF,CAAC;GACD,EAAY,cAAc,CAAK;EACjC,CAAC;CACH;CA6MA,OAAO;EA3ML;EACA;EACA,IAAI,UAAU;GACZ,OAAO;EACT;EACA,IAAI,SAAS;GACX,OAAO;EACT;EACA,OAAO,OAAO,MAAa;G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Aa,2CAA2C,CAAE;GAElE,EAAO,YAAY,aAAa,CAAC,CAAC;EACpC;EACA,YAAY;GACV,IAAI,CAAC,KAAa,CAAC,GACjB,MAAM,EAAa,2CAA2C,CAAE;GAElE,EAAO,YAAY,YAAY,CAAC,CAAC;EACnC;EAEA,aAAa,CACb;EACA,KAAK,GAAW,OACd,EAAY,iBACV,GACA,CACF,SACa,EAAY,oBACvB,GACA,CACF;EAQF,aAAa,OAAO,MAAe;GAIjC,IAHA,EAAI,sBAAsB,EACxB,cAAc,GAAyC,GACzD,CAAC,GACG,CAAC,KAAc,CAAC,EAAW,IAC7B,MAAM,EAAa,mDAAmD,CAAE;GAE1E,IAAI,CAAC,KAAa,CAAC,GACjB,MAAM,EAAa,sDAAsD,CAAE;GAE7E,IAAM,IAAS,MAAM,EACnB,0BACA;IAAE,WAAW;IAAI,oBAAoB,EAAW;GAAG,CACrD;GACA,IAAI,CAAE,GAAiC,SACrC,MAAM,EACJ,4CAA6C,GAAiC,SAAU,UAAU,IAClG,CACF;EAEJ;CAEW;AACf"}
@@ -1,3 +1,4 @@
1
+ import { PaymentFallbacks } from './fallbacks';
1
2
  import * as React from "react";
2
3
  /** The framed page's message once the order completes. */
3
4
  export declare const PAYMENT_COMPLETE_MESSAGE = "openrails.payment.complete";
@@ -19,7 +20,9 @@ export interface EmbeddedPaymentProps {
19
20
  * order's success_url, if it has one.
20
21
  */
21
22
  onComplete?: (completion: EmbeddedPaymentCompletion) => void;
23
+ /** As OrderPayment's: the framed page keeps these PSPs back the same way. */
24
+ fallbacks?: PaymentFallbacks;
22
25
  title?: string;
23
26
  className?: string;
24
27
  }
25
- export declare function EmbeddedPayment({ url, onComplete, title, className, }: EmbeddedPaymentProps): React.JSX.Element | null;
28
+ export declare function EmbeddedPayment({ url, onComplete, fallbacks, title, className, }: EmbeddedPaymentProps): React.JSX.Element | null;
@@ -0,0 +1,25 @@
1
+ import { Order } from './client/types';
2
+ import { PspConfig } from './psp';
3
+ /** A PSP kept back for others, named by key. */
4
+ export interface PaymentFallback {
5
+ /** The PSP keys it stands in for, e.g. `["mobius"]`. */
6
+ for: string[];
7
+ /** Failed attempts through them on the order, combined, that reveal it. */
8
+ afterFailures: number;
9
+ }
10
+ /** Fallback PSPs by key: `{ ccbill: { for: ["mobius"], afterFailures: 2 } }`. */
11
+ export type PaymentFallbacks = Record<string, PaymentFallback>;
12
+ type Option = Order["payment_options"][number];
13
+ /**
14
+ * The psp_ids of the options a fallback keeps back: one of its `for` PSPs is
15
+ * offered here and they have failed fewer than `afterFailures` times.
16
+ */
17
+ export declare function hiddenFallbacks(fallbacks: PaymentFallbacks | undefined, options: Option[], psps: PspConfig[]): Set<string>;
18
+ /** The pay URL carrying fallbacks to the pay page in its fragment. */
19
+ export declare function withPaymentFallbacks(url: string, fallbacks?: PaymentFallbacks): string;
20
+ /** A pay URL fragment's secret and fallbacks; invalid fallbacks are dropped. */
21
+ export declare function readPaymentFragment(hash: string): {
22
+ secret: string | null;
23
+ fallbacks?: PaymentFallbacks;
24
+ };
25
+ export {};
@@ -1,4 +1,4 @@
1
- import { A as e, O as t, c as n, l as r, o as i, u as a } from "./client-imFR1UCe.js";
1
+ import { A as e, O as t, c as n, l as r, o as i, u as a } from "./client-B301IAQD.js";
2
2
  import { en as o } from "./locales/en.js";
3
3
  import { createContext as s, useCallback as c, useContext as l, useEffect as u, useMemo as d, useRef as f, useState as p, useSyncExternalStore as m } from "react";
4
4
  import { jsx as h } from "react/jsx-runtime";
@@ -39,25 +39,35 @@ function S(e) {
39
39
  if (typeof t == "string") return t;
40
40
  }
41
41
  }
42
- function C(e) {
42
+ var C = /* @__PURE__ */ new WeakSet();
43
+ function w(e) {
44
+ if (!e || typeof e != "object" || S(e) !== "provider_writes_disabled") return;
45
+ let t = e.message;
46
+ if (!(typeof t != "string" || !t)) return C.has(e) || (C.add(e), console.warn(`OpenRails: ${t}`)), T() ? t : void 0;
47
+ }
48
+ function T() {
49
+ let e = globalThis.location?.hostname ?? "";
50
+ return e === "localhost" || e === "127.0.0.1" || e === "[::1]" || e.endsWith(".localhost");
51
+ }
52
+ function E(e) {
43
53
  return e instanceof TypeError && /fetch|network/i.test(e.message);
44
54
  }
45
- function w(e) {
55
+ function D(e) {
46
56
  try {
47
57
  return new Intl.PluralRules(e);
48
58
  } catch {
49
59
  return new Intl.PluralRules("en");
50
60
  }
51
61
  }
52
- function T(e, t) {
62
+ function O(e, t) {
53
63
  try {
54
64
  return new Intl.NumberFormat(t).format(e);
55
65
  } catch {
56
66
  return String(e);
57
67
  }
58
68
  }
59
- function E(e, t, n) {
60
- let r = w(n), i = (n, r) => {
69
+ function k(e, t, n) {
70
+ let r = D(n), i = (n, r) => {
61
71
  let i = t?.(n, r);
62
72
  if (i && i !== n) return i;
63
73
  let a = x(e, n);
@@ -70,7 +80,7 @@ function E(e, t, n) {
70
80
  plural(e, t, a) {
71
81
  let o = {
72
82
  ...a,
73
- count: T(t, n)
83
+ count: O(t, n)
74
84
  };
75
85
  return i(`${e}.${t}`, o) ?? i(`${e}.${r.select(t)}`, o) ?? i(`${e}.other`, o) ?? e;
76
86
  },
@@ -80,23 +90,23 @@ function E(e, t, n) {
80
90
  let e = t && typeof t == "object" && "metadata" in t ? t.metadata : void 0, a = i(`errors.${r}`, {
81
91
  ...e,
82
92
  ...n
83
- });
84
- if (a) return a;
93
+ }), o = w(t);
94
+ if (a) return o ? `${a} ${o}` : a;
85
95
  }
86
- let a = C(t) ? "errors.network" : "errors.generic";
96
+ let a = E(t) ? "errors.network" : "errors.generic";
87
97
  return i(a, n) ?? e.errors.generic;
88
98
  }
89
99
  };
90
100
  }
91
101
  //#endregion
92
102
  //#region src/i18n/context.ts
93
- var D = s(E(_));
94
- function O() {
95
- return l(D);
103
+ var A = s(k(_));
104
+ function j() {
105
+ return l(A);
96
106
  }
97
107
  //#endregion
98
108
  //#region src/appearance.ts
99
- var k = {
109
+ var M = {
100
110
  background: "--background",
101
111
  foreground: "--foreground",
102
112
  card: "--card",
@@ -111,39 +121,39 @@ var k = {
111
121
  radius: "--radius",
112
122
  fontFamily: "--orck-font"
113
123
  };
114
- function A(e, t = "orck") {
124
+ function N(e, t = "orck") {
115
125
  let n = e?.variables;
116
126
  if (!n) return;
117
127
  let r = {};
118
- for (let [e, i] of Object.entries(n)) i && (r[k[e].replace("--orck-", `--${t}-`)] = i);
128
+ for (let [e, i] of Object.entries(n)) i && (r[M[e].replace("--orck-", `--${t}-`)] = i);
119
129
  return r;
120
130
  }
121
- function j(e) {
131
+ function P(e) {
122
132
  return e?.theme ?? "auto";
123
133
  }
124
134
  //#endregion
125
135
  //#region src/scope-context.ts
126
- var M = s({}), N = () => l(M);
127
- function P(e) {
128
- let t = N(), n = e ?? t.appearance;
136
+ var F = s({}), I = () => l(F);
137
+ function L(e) {
138
+ let t = I(), n = e ?? t.appearance;
129
139
  return {
130
140
  className: "orck",
131
- "data-orck-theme": j(n),
132
- style: A(n)
141
+ "data-orck-theme": P(n),
142
+ style: N(n)
133
143
  };
134
144
  }
135
145
  //#endregion
136
146
  //#region src/react/context.ts
137
- var F = s(null);
138
- function I() {
139
- let e = l(F);
147
+ var R = s(null);
148
+ function z() {
149
+ let e = l(R);
140
150
  if (!e) throw Error("billing-ui: wrap the tree in <BillingProvider>");
141
151
  return e;
142
152
  }
143
- var L = () => I().client, R = () => I().refresh, z = () => l(F);
153
+ var B = () => z().client, V = () => z().refresh, H = () => l(R);
144
154
  //#endregion
145
155
  //#region src/react/config.ts
146
- function B(t, n) {
156
+ function U(t, n) {
147
157
  let r = n ?? {
148
158
  config: null,
149
159
  loading: !0,
@@ -182,7 +192,7 @@ function B(t, n) {
182
192
  refetch: c
183
193
  };
184
194
  }
185
- function V(e, n, r) {
195
+ function W(e, n, r) {
186
196
  let i = e.safeParse(r);
187
197
  if (i.success) return {
188
198
  config: i.data,
@@ -196,21 +206,21 @@ function V(e, n, r) {
196
206
  error: t("invalid_config", `${n}: ${a?.path.join(".")} ${a?.message}`)
197
207
  };
198
208
  }
199
- function H(e) {
209
+ function G(e) {
200
210
  let t = m(e.subscribe, e.snapshot, e.snapshot);
201
211
  return u(() => e.ensure(), [e]), {
202
212
  ...t,
203
213
  refetch: e.refetch
204
214
  };
205
215
  }
206
- function U() {
207
- return H(I().config);
216
+ function K() {
217
+ return G(z().config);
208
218
  }
209
- function W() {
210
- return H(I().customerConfig);
219
+ function q() {
220
+ return G(z().customerConfig);
211
221
  }
212
- function G() {
213
- let { client: e } = I(), { config: t } = U();
222
+ function J() {
223
+ let { client: e } = z(), { config: t } = K();
214
224
  return d(() => ({
215
225
  ...Object.fromEntries((t?.currencies ?? []).map((e) => [e.code.toUpperCase(), e.decimals])),
216
226
  ...e.currencies
@@ -218,8 +228,8 @@ function G() {
218
228
  }
219
229
  //#endregion
220
230
  //#region src/react/provider.tsx
221
- function K({ client: e, config: t, customerConfig: n, onChange: r, appearance: i, messages: a, t: o, locale: s, navigate: c, children: l }) {
222
- let u = d(() => E(y(a), o, s), [
231
+ function Y({ client: e, config: t, customerConfig: n, onChange: r, appearance: i, messages: a, t: o, locale: s, navigate: c, children: l }) {
232
+ let u = d(() => k(y(a), o, s), [
223
233
  a,
224
234
  o,
225
235
  s
@@ -232,11 +242,11 @@ function K({ client: e, config: t, customerConfig: n, onChange: r, appearance: i
232
242
  s,
233
243
  c
234
244
  ]);
235
- return /* @__PURE__ */ h(M.Provider, {
245
+ return /* @__PURE__ */ h(F.Provider, {
236
246
  value: f,
237
- children: /* @__PURE__ */ h(D.Provider, {
247
+ children: /* @__PURE__ */ h(A.Provider, {
238
248
  value: u,
239
- children: e ? /* @__PURE__ */ h(q, {
249
+ children: e ? /* @__PURE__ */ h(X, {
240
250
  client: e,
241
251
  config: t,
242
252
  customerConfig: n,
@@ -246,14 +256,14 @@ function K({ client: e, config: t, customerConfig: n, onChange: r, appearance: i
246
256
  })
247
257
  });
248
258
  }
249
- function q({ client: e, config: t, customerConfig: n, onChange: i, children: o }) {
259
+ function X({ client: e, config: t, customerConfig: n, onChange: i, children: o }) {
250
260
  let [s, l] = p(0), m = f(i);
251
261
  u(() => {
252
262
  m.current = i;
253
263
  });
254
264
  let g = c((e) => {
255
265
  l((e) => e + 1), m.current?.(e);
256
- }, []), _ = c(() => l((e) => e + 1), []), v = d(() => B(() => e.getConfig(), t && V(a, "config", t)), [e, t]), y = d(() => B(() => e.getCustomerConfig(), n && V(r, "customerConfig", n)), [e, n]), b = d(() => ({
266
+ }, []), _ = c(() => l((e) => e + 1), []), v = d(() => U(() => e.getConfig(), t && W(a, "config", t)), [e, t]), y = d(() => U(() => e.getCustomerConfig(), n && W(r, "customerConfig", n)), [e, n]), b = d(() => ({
257
267
  client: e,
258
268
  version: s,
259
269
  notify: g,
@@ -268,14 +278,14 @@ function q({ client: e, config: t, customerConfig: n, onChange: i, children: o }
268
278
  v,
269
279
  y
270
280
  ]);
271
- return /* @__PURE__ */ h(F.Provider, {
281
+ return /* @__PURE__ */ h(R.Provider, {
272
282
  value: b,
273
283
  children: o
274
284
  });
275
285
  }
276
286
  //#endregion
277
287
  //#region src/react/remote.ts
278
- function J(t, n) {
288
+ function Z(t, n) {
279
289
  let [r, i] = p(0), a = `${t}|${r}`, [o, s] = p({
280
290
  request: null,
281
291
  data: null,
@@ -311,7 +321,7 @@ function J(t, n) {
311
321
  }
312
322
  //#endregion
313
323
  //#region src/react/hooks.ts
314
- function Y() {
324
+ function Q() {
315
325
  let [e, t] = p({});
316
326
  return [e, c((e, n) => {
317
327
  t((t) => {
@@ -320,13 +330,13 @@ function Y() {
320
330
  });
321
331
  }, [])];
322
332
  }
323
- var X = () => t("wallet_required", "A wallet must sign this action.");
324
- function Z(t = {}) {
325
- let { client: r, version: a, notify: o } = I(), s = t.status ?? "all", l = t.limit ?? 100, u = J(`${s}|${l}|${a}`, (e) => r.listSubscriptions({
333
+ var $ = () => t("wallet_required", "A wallet must sign this action.");
334
+ function ee(t = {}) {
335
+ let { client: r, version: a, notify: o } = z(), s = t.status ?? "all", l = t.limit ?? 100, u = Z(`${s}|${l}|${a}`, (e) => r.listSubscriptions({
326
336
  status: s,
327
337
  limit: l,
328
338
  signal: e
329
- })), [d, f] = Y(), { replace: p } = u, m = c((e) => p((t) => ({
339
+ })), [d, f] = Q(), { replace: p } = u, m = c((e) => p((t) => ({
330
340
  ...t,
331
341
  data: t.data.map((t) => t.id === e.id ? e : t)
332
342
  })), [p]), h = c(async (t, n, r, i) => {
@@ -342,7 +352,7 @@ function Z(t = {}) {
342
352
  }, [f, m]), g = c((e, t, a) => h(e, "cancel", async () => {
343
353
  let o = await r.cancelSubscription(e, { reason: t });
344
354
  if (!o.next_action) return o;
345
- if (!i(o.next_action) || !a) throw X();
355
+ if (!i(o.next_action) || !a) throw $();
346
356
  f(e, "signing");
347
357
  let s = await n(o.next_action, a);
348
358
  return f(e, "confirming"), r.cancelSubscription(e, {
@@ -412,8 +422,8 @@ function Z(t = {}) {
412
422
  changeSubscription: y
413
423
  };
414
424
  }
415
- function Q() {
416
- let { client: t, version: n, notify: r } = I(), i = J(`${n}`, (e) => t.listPaymentMethods({ signal: e })), [a, o] = Y(), [s, l] = p(!1), { replace: u } = i, d = c(async (n) => {
425
+ function te() {
426
+ let { client: t, version: n, notify: r } = z(), i = Z(`${n}`, (e) => t.listPaymentMethods({ signal: e })), [a, o] = Q(), [s, l] = p(!1), { replace: u } = i, d = c(async (n) => {
417
427
  l(!0);
418
428
  try {
419
429
  let e = await t.addPaymentMethod(n);
@@ -497,12 +507,12 @@ function Q() {
497
507
  setDefault: m
498
508
  };
499
509
  }
500
- var $ = {};
501
- function ee(e = {}) {
502
- let { client: t, version: n } = I(), r = e.pageSize ?? 20, i = `${r}|${e.rail ?? ""}`, [a, o] = p({
510
+ var ne = {};
511
+ function re(e = {}) {
512
+ let { client: t, version: n } = z(), r = e.pageSize ?? 20, i = `${r}|${e.rail ?? ""}`, [a, o] = p({
503
513
  filter: i,
504
514
  cursors: [null]
505
- }), s = d(() => a.filter === i ? a.cursors : [null], [a, i]), l = s.length - 1, u = s[l], f = J(`${i}|${u ?? ""}|${n}`, async (n) => {
515
+ }), s = d(() => a.filter === i ? a.cursors : [null], [a, i]), l = s.length - 1, u = s[l], f = Z(`${i}|${u ?? ""}|${n}`, async (n) => {
506
516
  let i = await t.listPayments({
507
517
  limit: r,
508
518
  cursor: u,
@@ -523,7 +533,7 @@ function ee(e = {}) {
523
533
  }), m = f.data, h = m?.next_cursor ?? null;
524
534
  return {
525
535
  payments: m?.data ?? null,
526
- orders: m?.orders ?? $,
536
+ orders: m?.orders ?? ne,
527
537
  page: l,
528
538
  hasMore: h !== null,
529
539
  loading: f.loading,
@@ -548,6 +558,6 @@ function ee(e = {}) {
548
558
  };
549
559
  }
550
560
  //#endregion
551
- export { E as _, U as a, b, L as c, z as d, P as f, O as g, j as h, K as i, I as l, A as m, ee as n, G as o, N as p, Z as r, W as s, Q as t, R as u, _ as v, y as x, g as y };
561
+ export { k as _, K as a, b, B as c, H as d, L as f, j as g, P as h, Y as i, z as l, N as m, re as n, J as o, I as p, ee as r, q as s, te as t, V as u, _ as v, y as x, g as y };
552
562
 
553
- //# sourceMappingURL=hooks-C9JkHcRt.js.map
563
+ //# sourceMappingURL=hooks-DARbMTwv.js.map