@owlmeans/web-payment 0.1.18-rc.20 → 0.1.18-rc.21

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 (136) hide show
  1. package/README.md +1 -1
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/web-payment/SKILL.md +171 -31
  4. package/build/@/components/ui/checkbox.d.ts +5 -0
  5. package/build/@/components/ui/checkbox.d.ts.map +1 -0
  6. package/build/@/components/ui/checkbox.js +6 -0
  7. package/build/@/components/ui/checkbox.js.map +1 -0
  8. package/build/checkout-limit.d.ts +11 -0
  9. package/build/checkout-limit.d.ts.map +1 -0
  10. package/build/checkout-limit.js +34 -0
  11. package/build/checkout-limit.js.map +1 -0
  12. package/build/consumer/cancellation.d.ts +20 -0
  13. package/build/consumer/cancellation.d.ts.map +1 -0
  14. package/build/consumer/cancellation.js +115 -0
  15. package/build/consumer/cancellation.js.map +1 -0
  16. package/build/consumer/copy.d.ts +23 -0
  17. package/build/consumer/copy.d.ts.map +1 -0
  18. package/build/consumer/copy.js +75 -0
  19. package/build/consumer/copy.js.map +1 -0
  20. package/build/consumer/ensure.d.ts +56 -0
  21. package/build/consumer/ensure.d.ts.map +1 -0
  22. package/build/consumer/ensure.js +71 -0
  23. package/build/consumer/ensure.js.map +1 -0
  24. package/build/consumer/fields.d.ts +43 -0
  25. package/build/consumer/fields.d.ts.map +1 -0
  26. package/build/consumer/fields.js +19 -0
  27. package/build/consumer/fields.js.map +1 -0
  28. package/build/consumer/hooks.d.ts +113 -0
  29. package/build/consumer/hooks.d.ts.map +1 -0
  30. package/build/consumer/hooks.js +225 -0
  31. package/build/consumer/hooks.js.map +1 -0
  32. package/build/consumer/index.d.ts +14 -0
  33. package/build/consumer/index.d.ts.map +1 -0
  34. package/build/consumer/index.js +12 -0
  35. package/build/consumer/index.js.map +1 -0
  36. package/build/consumer/legal.d.ts +53 -0
  37. package/build/consumer/legal.d.ts.map +1 -0
  38. package/build/consumer/legal.js +77 -0
  39. package/build/consumer/legal.js.map +1 -0
  40. package/build/consumer/performance-consent-dialog.d.ts +18 -0
  41. package/build/consumer/performance-consent-dialog.d.ts.map +1 -0
  42. package/build/consumer/performance-consent-dialog.js +71 -0
  43. package/build/consumer/performance-consent-dialog.js.map +1 -0
  44. package/build/consumer/provider.d.ts +33 -0
  45. package/build/consumer/provider.d.ts.map +1 -0
  46. package/build/consumer/provider.js +26 -0
  47. package/build/consumer/provider.js.map +1 -0
  48. package/build/consumer/refusal.d.ts +35 -0
  49. package/build/consumer/refusal.d.ts.map +1 -0
  50. package/build/consumer/refusal.js +98 -0
  51. package/build/consumer/refusal.js.map +1 -0
  52. package/build/consumer/subscription-start-dialog.d.ts +16 -0
  53. package/build/consumer/subscription-start-dialog.d.ts.map +1 -0
  54. package/build/consumer/subscription-start-dialog.js +43 -0
  55. package/build/consumer/subscription-start-dialog.js.map +1 -0
  56. package/build/consumer/types.d.ts +114 -0
  57. package/build/consumer/types.d.ts.map +1 -0
  58. package/build/consumer/types.js +2 -0
  59. package/build/consumer/types.js.map +1 -0
  60. package/build/consumer/withdrawal.d.ts +29 -0
  61. package/build/consumer/withdrawal.d.ts.map +1 -0
  62. package/build/consumer/withdrawal.js +140 -0
  63. package/build/consumer/withdrawal.js.map +1 -0
  64. package/build/dialog.d.ts +1 -1
  65. package/build/dialog.d.ts.map +1 -1
  66. package/build/dialog.js +42 -16
  67. package/build/dialog.js.map +1 -1
  68. package/build/estimate-summary.d.ts +9 -1
  69. package/build/estimate-summary.d.ts.map +1 -1
  70. package/build/estimate-summary.js +10 -7
  71. package/build/estimate-summary.js.map +1 -1
  72. package/build/estimate.d.ts +6 -0
  73. package/build/estimate.d.ts.map +1 -1
  74. package/build/estimate.js +26 -1
  75. package/build/estimate.js.map +1 -1
  76. package/build/format.d.ts +15 -0
  77. package/build/format.d.ts.map +1 -0
  78. package/build/format.js +68 -0
  79. package/build/format.js.map +1 -0
  80. package/build/i18n/be.json +1 -1
  81. package/build/i18n/de.json +1 -1
  82. package/build/i18n/en.json +1 -1
  83. package/build/i18n/es.json +1 -1
  84. package/build/i18n/fr.json +110 -15
  85. package/build/i18n/pl.json +1 -1
  86. package/build/i18n/ru.json +1 -1
  87. package/build/i18n/uk.json +1 -1
  88. package/build/i18n.d.ts +2 -1
  89. package/build/i18n.d.ts.map +1 -1
  90. package/build/i18n.js +10 -8
  91. package/build/i18n.js.map +1 -1
  92. package/build/index.d.ts +2 -0
  93. package/build/index.d.ts.map +1 -1
  94. package/build/index.js +2 -0
  95. package/build/index.js.map +1 -1
  96. package/build/types.d.ts +22 -1
  97. package/build/types.d.ts.map +1 -1
  98. package/package.json +18 -7
  99. package/src/@/components/ui/checkbox.tsx +23 -0
  100. package/src/checkout-limit.tsx +48 -0
  101. package/src/consumer/cancellation.tsx +214 -0
  102. package/src/consumer/copy.ts +93 -0
  103. package/src/consumer/ensure.ts +124 -0
  104. package/src/consumer/fields.tsx +89 -0
  105. package/src/consumer/hooks.ts +358 -0
  106. package/src/consumer/index.ts +13 -0
  107. package/src/consumer/legal.tsx +129 -0
  108. package/src/consumer/performance-consent-dialog.tsx +132 -0
  109. package/src/consumer/provider.tsx +49 -0
  110. package/src/consumer/refusal.ts +110 -0
  111. package/src/consumer/subscription-start-dialog.tsx +87 -0
  112. package/src/consumer/types.ts +121 -0
  113. package/src/consumer/withdrawal.tsx +279 -0
  114. package/src/dialog.tsx +53 -23
  115. package/src/estimate-summary.tsx +21 -11
  116. package/src/estimate.ts +27 -1
  117. package/src/format.ts +71 -0
  118. package/src/i18n/be.json +1 -1
  119. package/src/i18n/de.json +1 -1
  120. package/src/i18n/en.json +1 -1
  121. package/src/i18n/es.json +1 -1
  122. package/src/i18n/fr.json +110 -15
  123. package/src/i18n/pl.json +1 -1
  124. package/src/i18n/ru.json +1 -1
  125. package/src/i18n/uk.json +1 -1
  126. package/src/i18n.ts +11 -8
  127. package/src/index.ts +2 -0
  128. package/src/types.ts +23 -1
  129. package/tests/consent-refusal.spec.ts +83 -0
  130. package/tests/consumer-hooks.spec.ts +205 -0
  131. package/tests/consumer.spec.ts +343 -0
  132. package/tests/context.ts +1 -1
  133. package/tests/harness/consumer-fixtures.ts +105 -0
  134. package/tests/harness/consumer.tsx +197 -0
  135. package/tests/harness/mount.tsx +9 -2
  136. package/tests/i18n.spec.ts +41 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/consumer/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAA;AAEzF,OAAO,EACL,qBAAqB,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,oBAAoB,GACnG,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,SAAS,EAAsB,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAQ/C,gGAAgG;AAChG,MAAM,MAAM,GAAG,CAA+B,OAAe,EAA0B,EAAE,CACvF,CAAC,OAAO,CAAsC,CAAA;AA4BhD;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,IAAsD,EACtD,MAAuE,EACvE,IAAI,GAAiC,EAAE,EACZ,EAAE;IAC7B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;IAC5B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAA;IACtB,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;IAChC,SAAS,CAAC,OAAO,GAAG,MAAM,CAAA;IAC1B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;IAC5B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAA;IAEtB,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAgC,IAAI,CAAC,CAAA;IAC3E,MAAM,CAAC,IAAI,E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AAW,CAAC,MAAM;SAC7B;KACF,CAAA;AACH,CAAC,CAAA;AAYD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAA8C,EAChB,EAAE;IAChC,MAAM,WAAW,GAAG,cAAc,CAAqC,MAAM,CAAC,CAAA;IAE9E,OAAO;QACL,GAAG,WAAW;QACd,IAAI,EAAE;YACJ,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,KAAK,EAAE,WAAW,CAAC,KAAK,IAAI,IAAI;YAChC,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,QAAQ,EAAE,WAAW,CAAC,MAAM;SAC7B;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ import '../i18n.js';
2
+ export type * from './types.js';
3
+ export * from './refusal.js';
4
+ export * from './ensure.js';
5
+ export * from './copy.js';
6
+ export { LanguageToggle, LegalLinks, linksFor, useShownLanguage, useUiLanguage } from './legal.js';
7
+ export type { LanguageToggleProps, LegalLinksProps, ShownLanguage } from './legal.js';
8
+ export * from './performance-consent-dialog.js';
9
+ export * from './subscription-start-dialog.js';
10
+ export * from './withdrawal.js';
11
+ export * from './cancellation.js';
12
+ export * from './hooks.js';
13
+ export * from './provider.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumer/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAA;AACnB,mBAAmB,YAAY,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAClG,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACrF,cAAc,iCAAiC,CAAA;AAC/C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA"}
@@ -0,0 +1,12 @@
1
+ import '../i18n.js';
2
+ export * from './refusal.js';
3
+ export * from './ensure.js';
4
+ export * from './copy.js';
5
+ export { LanguageToggle, LegalLinks, linksFor, useShownLanguage, useUiLanguage } from './legal.js';
6
+ export * from './performance-consent-dialog.js';
7
+ export * from './subscription-start-dialog.js';
8
+ export * from './withdrawal.js';
9
+ export * from './cancellation.js';
10
+ export * from './hooks.js';
11
+ export * from './provider.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/consumer/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAA;AAEnB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAElG,cAAc,iCAAiC,CAAA;AAC/C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA"}
@@ -0,0 +1,53 @@
1
+ import type { ConsumerRightsLinks } from '@owlmeans/payment';
2
+ import { type FixedText } from './copy.js';
3
+ import type { LegalLinksSource, PieceError } from './types.js';
4
+ /** The interface language: the one given, else the active i18n language. */
5
+ export declare const useUiLanguage: (uiLanguage?: string) => string;
6
+ export interface ShownLanguage {
7
+ /** The language the legal copy is shown in now (base code). */
8
+ shown: string;
9
+ /** The contract language (base code). */
10
+ contract: string;
11
+ ui: string;
12
+ /** The contract and interface languages differ, so a toggle is offered. */
13
+ canToggle: boolean;
14
+ toggle: () => void;
15
+ }
16
+ /**
17
+ * Which language a legal text is shown in: the contract language first, with a toggle to the
18
+ * interface language and back. `resetKey` (the dialog's `open`, say) returns it to the contract
19
+ * language.
20
+ */
21
+ export declare const useShownLanguage: (contractLanguage: string, uiLanguage?: string, resetKey?: unknown) => ShownLanguage;
22
+ export interface LanguageToggleProps {
23
+ language: ShownLanguage;
24
+ /** An extra `data-*` hook of the piece that hosts the toggle (`data-consent-language-toggle`). */
25
+ hook?: string;
26
+ className?: string;
27
+ }
28
+ /**
29
+ * Switches a legal text between the contract and the interface language. Phrased in the
30
+ * INTERFACE language ("Show in German") — the reader who needs the toggle reads that one.
31
+ */
32
+ export declare const LanguageToggle: ({ language, hook, className }: LanguageToggleProps) => import("react").JSX.Element | null;
33
+ /** The links of the shown language: the source's, else the view's own. */
34
+ export declare const linksFor: (language: string, own: ConsumerRightsLinks | undefined, source?: LegalLinksSource) => ConsumerRightsLinks | undefined;
35
+ export interface LegalLinksProps {
36
+ links?: ConsumerRightsLinks;
37
+ legal: FixedText;
38
+ onWithdraw?: () => void;
39
+ className?: string;
40
+ }
41
+ /**
42
+ * "Billing Terms · Withdrawal information · Withdraw from contract here", each in the shown
43
+ * language: `[data-legal-link="billing-terms" | "withdrawal-information" | "withdrawal-function"]`.
44
+ * The withdrawal function is a button when the application opens it in-app (`onWithdraw`), else a
45
+ * link to its public page, else absent.
46
+ */
47
+ export declare const LegalLinks: ({ links, legal, onWithdraw, className }: LegalLinksProps) => import("react").JSX.Element | null;
48
+ /** A piece's failure line: the application's own words, or the generic sentence for `true`. */
49
+ export declare const ErrorLine: ({ error, text }: {
50
+ error?: PieceError;
51
+ text: FixedText;
52
+ }) => import("react").JSX.Element | null;
53
+ //# sourceMappingURL=legal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legal.d.ts","sourceRoot":"","sources":["../../src/consumer/legal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAE5D,OAAO,EAAkC,KA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,0 +1,77 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment, useCallback, useEffect, useState } from 'react';
3
+ import { useLanguage } from '@owlmeans/client-i18n';
4
+ import { baseLanguageOf } from '@owlmeans/payment';
5
+ import { cn } from '@/lib/utils';
6
+ import { languageNameOf, usePaymentText } from './copy.js';
7
+ /** The interface language: the one given, else the active i18n language. */
8
+ export const useUiLanguage = (uiLanguage) => {
9
+ const [active] = useLanguage();
10
+ return baseLanguageOf(uiLanguage ?? active) || 'en';
11
+ };
12
+ /**
13
+ * Which language a legal text is shown in: the contract language first, with a toggle to the
14
+ * interface language and back. `resetKey` (the dialog's `open`, say) returns it to the contract
15
+ * language.
16
+ */
17
+ export const useShownLanguage = (contractLanguage, uiLanguage, resetKey) => {
18
+ const ui = useUiLanguage(uiLanguage);
19
+ const contract = baseLanguageOf(contractLanguage) || ui;
20
+ const [showUi, setShowUi] = useState(false);
21
+ useEffect(() => { setShowUi(false); }, [contract, resetKey]);
22
+ const canToggle = contract !== ui;
23
+ const toggle = useCallback(() => setShowUi(value => !value), []);
24
+ return { shown: canToggle && showUi ? ui : contract, contract, ui, canToggle, toggle };
25
+ };
26
+ /**
27
+ * Switches a legal text between the contract and the interface language. Phrased in the
28
+ * INTERFACE language ("Show in German") — the reader who needs the toggle reads that one.
29
+ */
30
+ export const LanguageToggle = ({ language, hook, className }) => {
31
+ const ui = usePaymentText(language.ui);
32
+ if (!language.canToggle) {
33
+ return null;
34
+ }
35
+ const target = language.shown === language.contract ? language.ui : language.contract;
36
+ return _jsx("button", { type: "button", onClick: language.toggle, "data-language-toggle": "", "data-target-language": target, ...(hook != null ? { [hook]: '' } : {}), className: cn('text-primary w-fit cursor-pointer text-xs underline-offset-4 hover:underline', className), children: ui('consumer.show-in', { language: languageNameOf(target, language.ui) }) });
37
+ };
38
+ /** The links of the shown language: the source's, else the view's own. */
39
+ export const linksFor = (language, own, source) => {
40
+ if (source == null) {
41
+ return own;
42
+ }
43
+ const picked = typeof source === 'function'
44
+ ? source(language)
45
+ : source[language] ?? source[baseLanguageOf(language)];
46
+ return picked ?? own;
47
+ };
48
+ /**
49
+ * "Billing Terms · Withdrawal information · Withdraw from contract here", each in the shown
50
+ * language: `[data-legal-link="billing-terms" | "withdrawal-information" | "withdrawal-function"]`.
51
+ * The withdrawal function is a button when the application opens it in-app (`onWithdraw`), else a
52
+ * link to its public page, else absent.
53
+ */
54
+ export const LegalLinks = ({ links, legal, onWithdraw, className }) => {
55
+ const anchor = (key, href, label) => href == null || href === ''
56
+ ? null
57
+ : _jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", "data-legal-link": key, className: "text-primary underline-offset-4 hover:underline", children: label }, key);
58
+ const items = [
59
+ anchor('billing-terms', links?.billingTerms, legal('links.billing-terms')),
60
+ anchor('withdrawal-information', links?.withdrawalInformation, legal('links.withdrawal-information')),
61
+ onWithdraw != null
62
+ ? _jsx("button", { type: "button", onClick: onWithdraw, "data-legal-link": "withdrawal-function", className: "text-primary cursor-pointer underline-offset-4 hover:underline", children: legal('links.withdrawal-function') }, "withdrawal-function")
63
+ : anchor('withdrawal-function', links?.withdrawalFunction, legal('links.withdrawal-function')),
64
+ ].filter(item => item != null);
65
+ if (items.length === 0) {
66
+ return null;
67
+ }
68
+ return _jsx("p", { className: cn('flex flex-wrap items-center gap-x-2 gap-y-1 text-xs', className), "data-legal-links": "", children: items.map((item, index) => _jsxs(Fragment, { children: [index > 0 && _jsx("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u00B7" }), item] }, index)) });
69
+ };
70
+ /** A piece's failure line: the application's own words, or the generic sentence for `true`. */
71
+ export const ErrorLine = ({ error, text }) => {
72
+ if (error == null || error === false) {
73
+ return null;
74
+ }
75
+ return _jsx("p", { role: "alert", className: "text-destructive text-sm", "data-consumer-error": "", children: error === true ? text('consumer.failed') : error });
76
+ };
77
+ //# sourceMappingURL=legal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legal.js","s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,CAAC;QACvB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,YAAG,SAAS,EAAE,EAAE,CAAC,qDAAqD,EAAE,SAAS,CAAC,sBAAmB,EAAE,YAC3G,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,MAAC,QAAQ,eAClC,KAAK,GAAG,CAAC,IAAI,8BAAkB,MAAM,EAAC,SAAS,EAAC,uBAAuB,uBAAS,EAChF,IAAI,KAFoC,KAAK,CAGrC,CAAC,GACV,CAAA;AACN,CAAC,CAAA;AAED,+FAA+F;AAC/F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAA2C,EAAE,EAAE;IACpF,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACrC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,YAAG,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,0BAA0B,yBAAqB,EAAE,YAC/E,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,KAAK,GAC/C,CAAA;AACN,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ import type { PerformanceConsentDialogProps } from './types.js';
2
+ /**
3
+ * The express request to start performing now, asked before credits bought inside their
4
+ * withdrawal window are spent (CRD Art. 16(m), § 356 Abs. 5 BGB, art. 38 UoPK, L221-28).
5
+ *
6
+ * The legal copy is shown in the CONTRACT language (`view.language`) with a toggle to the
7
+ * interface language; the purchases it covers are listed with their deadlines; ONE checkbox
8
+ * carries the whole statement and starts unchecked, and the confirm button stays disabled until
9
+ * it is ticked. Toggling the language unticks it — the statement agreed to is the one on screen —
10
+ * and `onConfirm` records the language actually shown.
11
+ *
12
+ * Selectors: `[data-consent-dialog]` (with `data-language`, `data-contract-language`),
13
+ * `[data-consent-purchase]` (`data-purchase-id`, `data-deadline`), `[data-consent-checkbox]`,
14
+ * `[data-consent-confirm]`, `[data-consent-decline]`, `[data-consent-language-toggle]`,
15
+ * `[data-legal-link]`.
16
+ */
17
+ export declare const PerformanceConsentDialog: ({ open, onOpenChange, view, uiLanguage, pending, error, onConfirm, onDecline, links, onWithdraw, formatAmount, className, }: PerformanceConsentDialogProps) => import("react").JSX.Element | null;
18
+ //# sourceMappingURL=performance-consent-dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performance-consent-dialog.d.ts","sourceRoot":"","sources":["../../src/consumer/performance-consent-dialog.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAA;AAc/D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,gIAGlC,6BAA6B,uCAuF/B,CAAA"}
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { cn } from '@/lib/utils';
4
+ import { Button } from '@/components/ui/button';
5
+ import { Checkbox } from '@/components/ui/checkbox';
6
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog';
7
+ import { Label } from '@/components/ui/label';
8
+ import { lastDayUtc, dayUtc, money } from '../format.js';
9
+ import { useLegalText, usePaymentText } from './copy.js';
10
+ import { ErrorLine, LanguageToggle, LegalLinks, linksFor, useShownLanguage } from './legal.js';
11
+ /** The latest deadline of the view — its own, else the latest of its purchases. */
12
+ const deadlineOf = (view) => {
13
+ if (view.deadline != null) {
14
+ return new Date(view.deadline);
15
+ }
16
+ const times = view.purchases
17
+ .map(purchase => purchase.deadline != null ? new Date(purchase.deadline).getTime() : NaN)
18
+ .filter(time => !Number.isNaN(time));
19
+ return times.length > 0 ? new Date(Math.max(...times)) : undefined;
20
+ };
21
+ /**
22
+ * The express request to start performing now, asked before credits bought inside their
23
+ * withdrawal window are spent (CRD Art. 16(m), § 356 Abs. 5 BGB, art. 38 UoPK, L221-28).
24
+ *
25
+ * The legal copy is shown in the CONTRACT language (`view.language`) with a toggle to the
26
+ * interface language; the purchases it covers are listed with their deadlines; ONE checkbox
27
+ * carries the whole statement and starts unchecked, and the confirm button stays disabled until
28
+ * it is ticked. Toggling the language unticks it — the statement agreed to is the one on screen —
29
+ * and `onConfirm` records the language actually shown.
30
+ *
31
+ * Selectors: `[data-consent-dialog]` (with `data-language`, `data-contract-language`),
32
+ * `[data-consent-purchase]` (`data-purchase-id`, `data-deadline`), `[data-consent-checkbox]`,
33
+ * `[data-consent-confirm]`, `[data-consent-decline]`, `[data-consent-language-toggle]`,
34
+ * `[data-legal-link]`.
35
+ */
36
+ export const PerformanceConsentDialog = ({ open, onOpenChange, view, uiLanguage, pending = false, error, onConfirm, onDecline, links, onWithdraw, formatAmount, className, }) => {
37
+ const language = useShownLanguage(view?.language ?? '', uiLanguage, open);
38
+ const legal = useLegalText(language.shown);
39
+ const text = usePaymentText(language.shown);
40
+ const [ticked, setTicked] = useState(false);
41
+ useEffect(() => { setTicked(false); }, [open, language.shown, view?.textVersion]);
42
+ if (view == null) {
43
+ return null;
44
+ }
45
+ const format = (minor, currency) => formatAmount != null
46
+ ? formatAmount(minor, currency, language.shown) : money(minor, currency, language.shown);
47
+ // The same text `consentStatementOf(lng, 'performance', { trader })` renders on the server.
48
+ const checkbox = legal('performance-consent.checkbox', { trader: view.trader });
49
+ const deadline = deadlineOf(view);
50
+ const shownLinks = linksFor(language.shown, view.links, links);
51
+ const confirm = async () => {
52
+ if (!ticked || pending) {
53
+ return;
54
+ }
55
+ await onConfirm({
56
+ purchaseIds: view.purchases.map(purchase => purchase.purchaseId),
57
+ textVersion: view.textVersion,
58
+ language: language.shown,
59
+ acknowledged: true,
60
+ uiLanguage: language.ui,
61
+ });
62
+ };
63
+ return _jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { closeLabel: text('consumer.close'), "data-consent-dialog": "", "data-performance-consent": "", "data-language": language.shown, "data-contract-language": language.contract, "data-text-version": view.textVersion, className: cn('max-h-[90vh] overflow-y-auto', className), ...(deadline == null ? { 'aria-describedby': undefined } : {}), children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { lang: language.shown, children: legal('performance-consent.title') }), deadline != null && _jsx(DialogDescription, { lang: language.shown, children: legal('performance-consent.intro', { count: view.purchases.length, deadline: lastDayUtc(deadline, language.shown) }) })] }), _jsx(LanguageToggle, { language: language, hook: "data-consent-language-toggle" }), _jsxs("div", { className: "grid gap-4", lang: language.shown, children: [view.purchases.length > 0 && _jsxs("section", { className: "grid gap-2", "aria-label": text('consumer.purchases'), children: [_jsx("h3", { className: "text-sm font-medium", children: text('consumer.purchases') }), _jsx("ul", { className: "grid gap-1.5 text-sm", children: view.purchases.map(purchase => _jsx("li", { "data-consent-purchase": "", "data-purchase-id": purchase.purchaseId, "data-deadline": purchase.deadline != null ? new Date(purchase.deadline).toISOString() : undefined, className: "rounded-md border px-3 py-2", children: purchase.deadline != null
64
+ ? legal('performance-consent.purchase', {
65
+ date: dayUtc(purchase.purchasedAt, language.shown),
66
+ amount: format(purchase.amountTotalMinor, purchase.currency),
67
+ deadline: lastDayUtc(purchase.deadline, language.shown),
68
+ })
69
+ : `${dayUtc(purchase.purchasedAt, language.shown)} (${format(purchase.amountTotalMinor, purchase.currency)})` }, purchase.purchaseId)) })] }), _jsxs("div", { className: "flex items-start gap-3 rounded-md border p-3", children: [_jsx(Checkbox, { id: "performance-consent-checkbox", "data-consent-checkbox": "", checked: ticked, disabled: pending, onCheckedChange: value => setTicked(value === true), className: "mt-0.5" }), _jsx(Label, { htmlFor: "performance-consent-checkbox", className: "block text-sm leading-snug font-normal", "data-consent-statement": "", children: checkbox })] }), _jsx(LegalLinks, { links: shownLinks, legal: legal, onWithdraw: onWithdraw }), _jsx(ErrorLine, { error: error, text: text })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "outline", "data-consent-decline": "", disabled: pending, onClick: () => onDecline != null ? onDecline() : onOpenChange(false), children: legal('performance-consent.decline') }), _jsx(Button, { type: "button", "data-consent-confirm": "", disabled: !ticked || pending, onClick: () => void confirm(), children: pending ? text('consumer.pending') : legal('performance-consent.confirm') })] })] }) });
70
+ };
71
+ //# sourceMappingURL=performance-consent-dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performance-consent-dialog.js","sourceRoot":"","sources":["../../src/consumer/performance-consent-dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EACL,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,GAClF,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAG9F,mFAAmF;AACnF,MAAM,UAAU,GAAG,CAAC,IAA4B,EAAoB,EAAE;IACpE,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;QAC1B,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAChC,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS;SACzB,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,IAAI,IAAI,CAAC,CA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AAC,GAC9B,EACT,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,0BAAsB,EAAE,EAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,EAAE,YACtG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,6BAA6B,CAAC,GACnE,IACI,IACD,GACT,CAAA;AACX,CAAC,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { RegisteredEntrypoint, RequestShape } from '@owlmeans/entrypoint';
3
+ import type { PerformanceConsentBody, PerformanceConsentResponse, PerformanceConsentView } from '@owlmeans/payment';
4
+ import { type ConsentGate } from './ensure.js';
5
+ import { type UsePerformanceConsentOptions } from './hooks.js';
6
+ export interface ConsentGateValue extends ConsentGate {
7
+ /** From the last read of the view; `null` before any, and always outside a provider. */
8
+ required: boolean | null;
9
+ }
10
+ export interface PerformanceConsentProviderProps<RecordRequest extends RequestShape & {
11
+ body: PerformanceConsentBody;
12
+ }> {
13
+ view: RegisteredEntrypoint<{}, PerformanceConsentView>;
14
+ record: RegisteredEntrypoint<RecordRequest, PerformanceConsentResponse>;
15
+ options?: UsePerformanceConsentOptions;
16
+ children?: ReactNode;
17
+ }
18
+ /**
19
+ * ONE spend-consent dialog for the whole application, and the gate every action that may spend
20
+ * credits reads with `useConsentGate()`: however many buttons ask at once, one dialog opens and
21
+ * they all get its answer.
22
+ */
23
+ export declare const PerformanceConsentProvider: <RecordRequest extends RequestShape & {
24
+ body: PerformanceConsentBody;
25
+ }>({ view, record, options, children, }: PerformanceConsentProviderProps<RecordRequest>) => import("react").JSX.Element;
26
+ /**
27
+ * The application's consent gate: `ensure()` asks proactively, `withConsent(action)` runs an
28
+ * action and, when it is refused for the spend consent, asks and retries it exactly once
29
+ * (`ConsentDeclined` on a decline). Outside a `PerformanceConsentProvider` nothing can be asked:
30
+ * `ensure` answers `true` and a refusal propagates unchanged.
31
+ */
32
+ export declare const useConsentGate: () => ConsentGateValue;
33
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/consumer/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AACnH,OAAO,EAAoC,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EAAyB,KAAK,4BAA4B,EAAE,MAAM,YAAY,CAAA;AAGrF,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,wFAAwF;IACxF,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAA;CACzB;AAID,MAAM,WAAW,+BAA+B,CAAC,aAAa,SAAS,YAAY,GAAG;IAAE,IAAI,EAAE,sBAAsB,CAAA;CAAE;IACpH,IAAI,EAAE,oBAAoB,CAAC,EAAE,EAAE,sBAAsB,CAAC,CAAA;IACtD,MAAM,EAAE,oBAAoB,CAAC,aAAa,EAAE,0BAA0B,CAAC,CAAA;IACvE,OAAO,CAAC,EAAE,4BAA4B,CAAA;IACtC,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,aAAa,SAAS,YAAY,GAAG;IAAE,IAAI,EAAE,sBAAsB,CAAA;CAAE,wCAE7G,+BAA+B,CAAC,aAAa,CAAC,gCAShD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAO,gBACc,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from 'react';
3
+ import { makeConsentGate, passThroughGate } from './ensure.js';
4
+ import { usePerformanceConsent } from './hooks.js';
5
+ import { PerformanceConsentDialog } from './performance-consent-dialog.js';
6
+ const ConsentGateContext = createContext(null);
7
+ /**
8
+ * ONE spend-consent dialog for the whole application, and the gate every action that may spend
9
+ * credits reads with `useConsentGate()`: however many buttons ask at once, one dialog opens and
10
+ * they all get its answer.
11
+ */
12
+ export const PerformanceConsentProvider = ({ view, record, options, children, }) => {
13
+ const consent = usePerformanceConsent(view, record, options);
14
+ const { ensure, required } = consent;
15
+ const value = useMemo(() => ({ ...makeConsentGate(ensure), required }), [ensure, required]);
16
+ return _jsxs(ConsentGateContext.Provider, { value: value, children: [children, _jsx(PerformanceConsentDialog, { ...consent.dialog })] });
17
+ };
18
+ /**
19
+ * The application's consent gate: `ensure()` asks proactively, `withConsent(action)` runs an
20
+ * action and, when it is refused for the spend consent, asks and retries it exactly once
21
+ * (`ConsentDeclined` on a decline). Outside a `PerformanceConsentProvider` nothing can be asked:
22
+ * `ensure` answers `true` and a refusal propagates unchanged.
23
+ */
24
+ export const useConsentGate = () => useContext(ConsentGateContext) ?? PASS_THROUGH;
25
+ const PASS_THROUGH = { ...passThroughGate, required: null };
26
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/consumer/provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAA;AAG1E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAoB,MAAM,aAAa,CAAA;AAChF,OAAO,EAAE,qBAAqB,EAAqC,MAAM,YAAY,CAAA;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAA;AAO1E,MAAM,kBAAkB,GAAG,aAAa,CAA0B,IAAI,CAAC,CAAA;AASvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAwE,EAChH,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GACgB,EAAE,EAAE;IACnD,MAAM,OAAO,GAAG,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5D,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IACpC,MAAM,KAAK,GAAG,OAAO,CAAmB,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;IAE7G,OAAO,MAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,aAC7C,QAAQ,EACT,KAAC,wBAAwB,OAAK,OAAO,CAAC,MAAM,GAAI,IACpB,CAAA;AAChC,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAqB,EAAE,CACnD,UAAU,CAAC,kBAAkB,CAAC,IAAI,YAAY,CAAA;AAEhD,MAAM,YAAY,GAAqB,EAAE,GAAG,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { ConsentKind, PaymentError } from '@owlmeans/payment';
2
+ /**
3
+ * Which express request a failure asks for: `performance` (spend consent), `subscription-start`,
4
+ * `unknown` for a bare HTTP 428 that names neither (a production body carries only an incident
5
+ * id), or `null` for anything else.
6
+ *
7
+ * Read on the error itself and on whatever it wraps (`cause`, `error`, `original`, `inner`, an
8
+ * aggregate's `errors`), and on text as well as objects, because a refusal travels in three shapes:
9
+ * the class (a development body, rebuilt by the registry); its marker inside another error's
10
+ * message or a stored string (a planning commit that failed on the refusal answers
11
+ * `planning:commit-failed:<transition>:<the refusal's text>`); and the bare status of a production
12
+ * body (`@owlmeans/api`'s `ApiStatusError`, `api:client:status:428[:<incident>]`).
13
+ */
14
+ export declare const consentRefusalKindOf: (error: unknown) => ConsentKind | 'unknown' | null;
15
+ /**
16
+ * Whether a failure is a consent refusal — the class or its marker (`consentRefusalOf`), or an
17
+ * HTTP 428 (`httpStatusOf`), on the error or anything it wraps. What decides that the consent
18
+ * dialog opens and the action is retried once.
19
+ */
20
+ export declare const isConsentRefusal: (error: unknown) => boolean;
21
+ /** A refusal the performance-consent dialog answers: the spend consent, or a bare 428. */
22
+ export declare const isPerformanceConsentRefusal: (error: unknown) => boolean;
23
+ /**
24
+ * The person declined the express request, so the action that needed it did not run. Raised by
25
+ * `useConsentGate().withConsent` — never by a server, and never a refusal a gate retries.
26
+ */
27
+ export declare class ConsentDeclined extends PaymentError {
28
+ static typeName: string;
29
+ kind: string;
30
+ constructor(kind?: string);
31
+ private applyFields;
32
+ finalizeUnmarshal(): void;
33
+ }
34
+ export declare const isConsentDeclined: (error: unknown) => error is ConsentDeclined;
35
+ //# sourceMappingURL=refusal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../../src/consumer/refusal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAoB,MAAM,mBAAmB,CAAA;AAU/E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,UAAW,OAAO,KAAG,WAAW,GAAG,SAAS,GAAG,IAwC/E,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,UAAW,OAAO,KAAG,OAA8C,CAAA;AAEhG,0FAA0F;AAC1F,eAAO,MAAM,2BAA2B,UAAW,OAAO,KAAG,OAI5D,CAAA;AAID;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,OAAuB,QAAQ,EAAE,MAAM,CAA4C;IAE5E,IAAI,EAAE,MAAM,CAA0B;IAE7C,YAAY,IAAI,GAAE,MAAgC,EAIjD;IAED,OAAO,CAAC,WAAW;IAKV,iBAAiB,IAAI,IAAI,CAEjC;CACF;AAID,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,KAAK,IAAI,eAAmD,CAAA"}
@@ -0,0 +1,98 @@
1
+ import { ResilientError } from '@owlmeans/error';
2
+ import { httpStatusOf } from '@owlmeans/api/status';
3
+ import { ConsentKind, PaymentError, consentRefusalOf } from '@owlmeans/payment';
4
+ /** Where a wrapping error keeps the one it wraps — `cause`, and the fields frameworks use for it. */
5
+ const NESTED_FIELDS = ['cause', 'error', 'original', 'originalError', 'inner', 'reason'];
6
+ /** How deep a wrapped chain is followed — a planning `CommitFailed` inside a transport error is two. */
7
+ const MAX_DEPTH = 5;
8
+ const PRECONDITION_REQUIRED = 428;
9
+ /**
10
+ * Which express request a failure asks for: `performance` (spend consent), `subscription-start`,
11
+ * `unknown` for a bare HTTP 428 that names neither (a production body carries only an incident
12
+ * id), or `null` for anything else.
13
+ *
14
+ * Read on the error itself and on whatever it wraps (`cause`, `error`, `original`, `inner`, an
15
+ * aggregate's `errors`), and on text as well as objects, because a refusal travels in three shapes:
16
+ * the class (a development body, rebuilt by the registry); its marker inside another error's
17
+ * message or a stored string (a planning commit that failed on the refusal answers
18
+ * `planning:commit-failed:<transition>:<the refusal's text>`); and the bare status of a production
19
+ * body (`@owlmeans/api`'s `ApiStatusError`, `api:client:status:428[:<incident>]`).
20
+ */
21
+ export const consentRefusalKindOf = (error) => {
22
+ let status = false;
23
+ const seen = new Set();
24
+ const visit = (value, depth) => {
25
+ if (value == null || depth > MAX_DEPTH) {
26
+ return null;
27
+ }
28
+ if (typeof value === 'string') {
29
+ const holder = { message: value };
30
+ if (httpStatusOf(holder) === PRECONDITION_REQUIRED)
31
+ status = true;
32
+ return consentRefusalOf(holder);
33
+ }
34
+ if (typeof value !== 'object' || seen.has(value)) {
35
+ return null;
36
+ }
37
+ seen.add(value);
38
+ const kind = consentRefusalOf(value);
39
+ if (kind != null) {
40
+ return kind;
41
+ }
42
+ if (httpStatusOf(value) === PRECONDITION_REQUIRED) {
43
+ status = true;
44
+ }
45
+ for (const field of NESTED_FIELDS) {
46
+ const nested = visit(value[field], depth + 1);
47
+ if (nested != null)
48
+ return nested;
49
+ }
50
+ const errors = value.errors;
51
+ if (Array.isArray(errors)) {
52
+ for (const item of errors) {
53
+ const nested = visit(item, depth + 1);
54
+ if (nested != null)
55
+ return nested;
56
+ }
57
+ }
58
+ return null;
59
+ };
60
+ const kind = visit(error, 0);
61
+ return kind ?? (status ? 'unknown' : null);
62
+ };
63
+ /**
64
+ * Whether a failure is a consent refusal — the class or its marker (`consentRefusalOf`), or an
65
+ * HTTP 428 (`httpStatusOf`), on the error or anything it wraps. What decides that the consent
66
+ * dialog opens and the action is retried once.
67
+ */
68
+ export const isConsentRefusal = (error) => consentRefusalKindOf(error) != null;
69
+ /** A refusal the performance-consent dialog answers: the spend consent, or a bare 428. */
70
+ export const isPerformanceConsentRefusal = (error) => {
71
+ const kind = consentRefusalKindOf(error);
72
+ return kind === ConsentKind.Performance || kind === 'unknown';
73
+ };
74
+ const DECLINED_MARKER = 'consent-declined:';
75
+ /**
76
+ * The person declined the express request, so the action that needed it did not run. Raised by
77
+ * `useConsentGate().withConsent` — never by a server, and never a refusal a gate retries.
78
+ */
79
+ export class ConsentDeclined extends PaymentError {
80
+ static typeName = `${PaymentError.typeName}ConsentDeclined`;
81
+ kind = ConsentKind.Performance;
82
+ constructor(kind = ConsentKind.Performance) {
83
+ super(`${DECLINED_MARKER}${kind}`);
84
+ this.type = ConsentDeclined.typeName;
85
+ this.applyFields();
86
+ }
87
+ applyFields() {
88
+ const at = this.message.lastIndexOf(DECLINED_MARKER);
89
+ if (at >= 0)
90
+ this.kind = this.message.slice(at + DECLINED_MARKER.length) || ConsentKind.Performance;
91
+ }
92
+ finalizeUnmarshal() {
93
+ this.applyFields();
94
+ }
95
+ }
96
+ ResilientError.registerErrorClass(ConsentDeclined);
97
+ export const isConsentDeclined = (error) => error instanceof ConsentDeclined;
98
+ //# sourceMappingURL=refusal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusal.js","sourceRoot":"","sources":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AAC,WAAW,IAAI,IAAI,KAAK,SAAS,CAAA;AAC/D,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,mBAAmB,CAAA;AAE3C;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,YAAY;IACxC,MAAM,CAAU,QAAQ,GAAW,GAAG,YAAY,CAAC,QAAQ,iBAAiB,CAAA;IAE5E,IAAI,GAAW,WAAW,CAAC,WAAW,CAAA;IAE7C,YAAY,IAAI,GAAW,WAAW,CAAC,WAAW;QAChD,KAAK,CAAC,GAAG,eAAe,GAAG,IAAI,EAAE,CAAC,CAAA;QAClC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAA;QACpC,IAAI,CAAC,WAAW,EAAE,CAAA;IACpB,CAAC;IAEO,WAAW;QACjB,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QACpD,IAAI,EAAE,IAAI,CAAC;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,WAAW,CAAA;IACrG,CAAC;IAEQ,iBAAiB;QACxB,IAAI,CAAC,WAAW,EAAE,CAAA;IACpB,CAAC;CACF;AAED,cAAc,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAA4B,EAAE,CAAC,KAAK,YAAY,eAAe,CAAA"}
@@ -0,0 +1,16 @@
1
+ import type { SubscriptionStartDialogProps } from './types.js';
2
+ /**
3
+ * The express request to start a subscription's services before its withdrawal period ends,
4
+ * asked BEFORE the subscription checkout (§ 357a Abs. 2 BGB, art. 35 UoPK, L221-25; CJEU C-641/19).
5
+ * Without it a withdrawal owes nothing for the time used.
6
+ *
7
+ * Same shape as the performance consent: the contract language first with a toggle, one
8
+ * unchecked checkbox carrying the whole statement, and the confirm button — "Continue to payment",
9
+ * the step before the paygate's own order button — disabled until it is ticked.
10
+ *
11
+ * Selectors: `[data-start-dialog]` (`data-language`, `data-contract-language`, `data-plan-sku`),
12
+ * `[data-start-checkbox]`, `[data-start-confirm]`, `[data-start-decline]`,
13
+ * `[data-start-language-toggle]`, `[data-legal-link]`.
14
+ */
15
+ export declare const SubscriptionStartDialog: ({ open, onOpenChange, view, planTitle, price, uiLanguage, pending, error, onConfirm, onDecline, links, onWithdraw, className, }: SubscriptionStartDialogProps) => import("react").JSX.Element | null;
16
+ //# sourceMappingURL=subscription-start-dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-start-dialog.d.ts","sourceRoot":"","sources":["../../src/consumer/subscription-start-dialog.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAA;AAE9D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,oIAGjC,4BAA4B,uCA0D9B,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { cn } from '@/lib/utils';
4
+ import { Button } from '@/components/ui/button';
5
+ import { Checkbox } from '@/components/ui/checkbox';
6
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog';
7
+ import { Label } from '@/components/ui/label';
8
+ import { useLegalText, usePaymentText } from './copy.js';
9
+ import { ErrorLine, LanguageToggle, LegalLinks, linksFor, useShownLanguage } from './legal.js';
10
+ /**
11
+ * The express request to start a subscription's services before its withdrawal period ends,
12
+ * asked BEFORE the subscription checkout (§ 357a Abs. 2 BGB, art. 35 UoPK, L221-25; CJEU C-641/19).
13
+ * Without it a withdrawal owes nothing for the time used.
14
+ *
15
+ * Same shape as the performance consent: the contract language first with a toggle, one
16
+ * unchecked checkbox carrying the whole statement, and the confirm button — "Continue to payment",
17
+ * the step before the paygate's own order button — disabled until it is ticked.
18
+ *
19
+ * Selectors: `[data-start-dialog]` (`data-language`, `data-contract-language`, `data-plan-sku`),
20
+ * `[data-start-checkbox]`, `[data-start-confirm]`, `[data-start-decline]`,
21
+ * `[data-start-language-toggle]`, `[data-legal-link]`.
22
+ */
23
+ export const SubscriptionStartDialog = ({ open, onOpenChange, view, planTitle, price, uiLanguage, pending = false, error, onConfirm, onDecline, links, onWithdraw, className, }) => {
24
+ const language = useShownLanguage(view?.language ?? '', uiLanguage, open);
25
+ const legal = useLegalText(language.shown);
26
+ const text = usePaymentText(language.shown);
27
+ const [ticked, setTicked] = useState(false);
28
+ useEffect(() => { setTicked(false); }, [open, language.shown, view?.textVersion, view?.planSku]);
29
+ if (view == null) {
30
+ return null;
31
+ }
32
+ // The same text `consentStatementOf(lng, 'subscription-start', { trader, plan })` renders on the server.
33
+ const checkbox = legal('subscription-start.checkbox', { trader: view.trader, plan: planTitle });
34
+ const shownLinks = linksFor(language.shown, view.links, links);
35
+ const confirm = async () => {
36
+ if (!ticked || pending) {
37
+ return;
38
+ }
39
+ await onConfirm({ planSku: view.planSku, textVersion: view.textVersion, language: language.shown, acknowledged: true });
40
+ };
41
+ return _jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { closeLabel: text('consumer.close'), "data-start-dialog": "", "data-subscription-start": "", "data-language": language.shown, "data-contract-language": language.contract, "data-plan-sku": view.planSku, "data-text-version": view.textVersion, className: cn('max-h-[90vh] overflow-y-auto', className), children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { lang: language.shown, children: legal('subscription-start.title', { plan: planTitle }) }), _jsx(DialogDescription, { lang: language.shown, children: legal('subscription-start.intro') })] }), _jsx(LanguageToggle, { language: language, hook: "data-start-language-toggle" }), _jsxs("div", { className: "grid gap-4", lang: language.shown, children: [price != null && _jsx("div", { className: "text-sm", "data-start-price": "", children: price }), _jsxs("div", { className: "flex items-start gap-3 rounded-md border p-3", children: [_jsx(Checkbox, { id: "subscription-start-checkbox", "data-start-checkbox": "", checked: ticked, disabled: pending, onCheckedChange: value => setTicked(value === true), className: "mt-0.5" }), _jsx(Label, { htmlFor: "subscription-start-checkbox", className: "block text-sm leading-snug font-normal", "data-start-statement": "", children: checkbox })] }), _jsx(LegalLinks, { links: shownLinks, legal: legal, onWithdraw: onWithdraw }), _jsx(ErrorLine, { error: error, text: text })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "outline", "data-start-decline": "", disabled: pending, onClick: () => onDecline != null ? onDecline() : onOpenChange(false), children: legal('subscription-start.decline') }), _jsx(Button, { type: "button", "data-start-confirm": "", disabled: !ticked || pending, onClick: () => void confirm(), children: pending ? text('consumer.pending') : legal('subscription-start.confirm') })] })] }) });
42
+ };
43
+ //# sourceMappingURL=subscription-start-dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-start-dialog.js","sourceRoot":"","sources":["../../src/consumer/subscription-start-dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EACL,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,GAClF,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAG9F;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACtC,IAAI,EAAE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