@owlmeans/web-marketing-consent 0.1.18-rc.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 (125) hide show
  1. package/README.md +15 -0
  2. package/agent-meta/manifest.json +16 -0
  3. package/agent-meta/skills/web-marketing-consent/SKILL.md +245 -0
  4. package/build/@/components/ui/button.d.ts +11 -0
  5. package/build/@/components/ui/button.d.ts.map +1 -0
  6. package/build/@/components/ui/button.js +32 -0
  7. package/build/@/components/ui/button.js.map +1 -0
  8. package/build/@/components/ui/card.d.ts +10 -0
  9. package/build/@/components/ui/card.d.ts.map +1 -0
  10. package/build/@/components/ui/card.js +25 -0
  11. package/build/@/components/ui/card.js.map +1 -0
  12. package/build/@/components/ui/label.d.ts +5 -0
  13. package/build/@/components/ui/label.d.ts.map +1 -0
  14. package/build/@/components/ui/label.js +8 -0
  15. package/build/@/components/ui/label.js.map +1 -0
  16. package/build/@/lib/utils.d.ts +3 -0
  17. package/build/@/lib/utils.d.ts.map +1 -0
  18. package/build/@/lib/utils.js +6 -0
  19. package/build/@/lib/utils.js.map +1 -0
  20. package/build/append.d.ts +32 -0
  21. package/build/append.d.ts.map +1 -0
  22. package/build/append.js +28 -0
  23. package/build/append.js.map +1 -0
  24. package/build/bridge.d.ts +25 -0
  25. package/build/bridge.d.ts.map +1 -0
  26. package/build/bridge.js +69 -0
  27. package/build/bridge.js.map +1 -0
  28. package/build/components/fields.d.ts +18 -0
  29. package/build/components/fields.d.ts.map +1 -0
  30. package/build/components/fields.js +22 -0
  31. package/build/components/fields.js.map +1 -0
  32. package/build/components/index.d.ts +3 -0
  33. package/build/components/index.d.ts.map +1 -0
  34. package/build/components/index.js +3 -0
  35. package/build/components/index.js.map +1 -0
  36. package/build/components/preferences.d.ts +19 -0
  37. package/build/components/preferences.d.ts.map +1 -0
  38. package/build/components/preferences.js +33 -0
  39. package/build/components/preferences.js.map +1 -0
  40. package/build/components/screen.d.ts +11 -0
  41. package/build/components/screen.d.ts.map +1 -0
  42. package/build/components/screen.js +35 -0
  43. package/build/components/screen.js.map +1 -0
  44. package/build/consts.d.ts +26 -0
  45. package/build/consts.d.ts.map +1 -0
  46. package/build/consts.js +27 -0
  47. package/build/consts.js.map +1 -0
  48. package/build/entrypoints.d.ts +12 -0
  49. package/build/entrypoints.d.ts.map +1 -0
  50. package/build/entrypoints.js +16 -0
  51. package/build/entrypoints.js.map +1 -0
  52. package/build/hooks/use-marketing-consent.d.ts +38 -0
  53. package/build/hooks/use-marketing-consent.d.ts.map +1 -0
  54. package/build/hooks/use-marketing-consent.js +96 -0
  55. package/build/hooks/use-marketing-consent.js.map +1 -0
  56. package/build/i18n/be.json +19 -0
  57. package/build/i18n/de.json +19 -0
  58. package/build/i18n/en.json +19 -0
  59. package/build/i18n/es.json +19 -0
  60. package/build/i18n/fr.json +19 -0
  61. package/build/i18n/pl.json +19 -0
  62. package/build/i18n/ru.json +19 -0
  63. package/build/i18n/uk.json +19 -0
  64. package/build/i18n.d.ts +2 -0
  65. package/build/i18n.d.ts.map +1 -0
  66. package/build/i18n.js +25 -0
  67. package/build/i18n.js.map +1 -0
  68. package/build/index.d.ts +11 -0
  69. package/build/index.d.ts.map +1 -0
  70. package/build/index.js +11 -0
  71. package/build/index.js.map +1 -0
  72. package/build/landing.d.ts +22 -0
  73. package/build/landing.d.ts.map +1 -0
  74. package/build/landing.js +68 -0
  75. package/build/landing.js.map +1 -0
  76. package/build/service.d.ts +40 -0
  77. package/build/service.d.ts.map +1 -0
  78. package/build/service.js +80 -0
  79. package/build/service.js.map +1 -0
  80. package/build/step.d.ts +10 -0
  81. package/build/step.d.ts.map +1 -0
  82. package/build/step.js +16 -0
  83. package/build/step.js.map +1 -0
  84. package/components.json +21 -0
  85. package/package.json +77 -0
  86. package/src/@/components/ui/button.tsx +60 -0
  87. package/src/@/components/ui/card.tsx +93 -0
  88. package/src/@/components/ui/label.tsx +23 -0
  89. package/src/@/globals.css +57 -0
  90. package/src/@/lib/utils.ts +6 -0
  91. package/src/append.ts +62 -0
  92. package/src/bridge.ts +89 -0
  93. package/src/components/fields.tsx +101 -0
  94. package/src/components/index.ts +2 -0
  95. package/src/components/preferences.tsx +69 -0
  96. package/src/components/screen.tsx +90 -0
  97. package/src/consts.ts +31 -0
  98. package/src/entrypoints.ts +17 -0
  99. package/src/hooks/use-marketing-consent.ts +150 -0
  100. package/src/i18n/be.json +19 -0
  101. package/src/i18n/de.json +19 -0
  102. package/src/i18n/en.json +19 -0
  103. package/src/i18n/es.json +19 -0
  104. package/src/i18n/fr.json +19 -0
  105. package/src/i18n/pl.json +19 -0
  106. package/src/i18n/ru.json +19 -0
  107. package/src/i18n/uk.json +19 -0
  108. package/src/i18n.ts +26 -0
  109. package/src/index.ts +10 -0
  110. package/src/landing.ts +80 -0
  111. package/src/service.ts +131 -0
  112. package/src/step.ts +21 -0
  113. package/tests/bridge.spec.ts +100 -0
  114. package/tests/context.ts +48 -0
  115. package/tests/harness/frame.html +16 -0
  116. package/tests/harness/index.html +11 -0
  117. package/tests/harness/mount.tsx +108 -0
  118. package/tests/helpers.ts +88 -0
  119. package/tests/i18n.spec.ts +63 -0
  120. package/tests/package-boundary.spec.ts +19 -0
  121. package/tests/preferences.spec.ts +70 -0
  122. package/tests/screen.spec.ts +146 -0
  123. package/tests/service.spec.ts +80 -0
  124. package/tests/tsconfig.json +12 -0
  125. package/tsconfig.json +14 -0
@@ -0,0 +1,18 @@
1
+ import type { FC } from 'react';
2
+ import type { UseMarketingConsentModel } from '../hooks/use-marketing-consent.js';
3
+ export interface ConsentFieldsProps {
4
+ t: (key: string, defaultValue: string) => string;
5
+ model: UseMarketingConsentModel;
6
+ }
7
+ /**
8
+ * The group/item/select-all body shared by `MarketingConsentScreen` and
9
+ * `MarketingConsentPreferences` — written once so the two never drift.
10
+ *
11
+ * `data-marketing-consent-item`/`data-marketing-consent-all` are the SAME testids in both hosts;
12
+ * the two are never mounted on the same page at once. Checkboxes are bare
13
+ * `<input type="checkbox">`, the same native-control choice `@owlmeans/client-auth`'s own
14
+ * `LoginTerms` makes for a sign-in screen — no checkbox primitive (and its Radix peer) is vendored
15
+ * just to render one.
16
+ */
17
+ export declare const ConsentFields: FC<ConsentFieldsProps>;
18
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/components/fields.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAA;AAEjF,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,CAAA;IAChD,KAAK,EAAE,wBAAwB,CAAA;CAChC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAiFhD,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from 'react';
3
+ /**
4
+ * The group/item/select-all body shared by `MarketingConsentScreen` and
5
+ * `MarketingConsentPreferences` — written once so the two never drift.
6
+ *
7
+ * `data-marketing-consent-item`/`data-marketing-consent-all` are the SAME testids in both hosts;
8
+ * the two are never mounted on the same page at once. Checkboxes are bare
9
+ * `<input type="checkbox">`, the same native-control choice `@owlmeans/client-auth`'s own
10
+ * `LoginTerms` makes for a sign-in screen — no checkbox primitive (and its Radix peer) is vendored
11
+ * just to render one.
12
+ */
13
+ export const ConsentFields = ({ t, model }) => {
14
+ const allRef = useRef(null);
15
+ useEffect(() => {
16
+ if (allRef.current != null) {
17
+ allRef.current.indeterminate = model.allIndeterminate;
18
+ }
19
+ }, [model.allIndeterminate]);
20
+ return (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsxs("label", { className: "flex items-center gap-2 text-sm font-medium cursor-pointer", children: [_jsx("input", { ref: allRef, type: "checkbox", "data-marketing-consent-all": true, className: "size-4 shrink-0 accent-primary", checked: model.allChecked, onChange: event => model.toggleAll(event.target.checked) }), t('screen.all', 'Select all')] }), model.groups.map(group => (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { children: [_jsx("p", { className: "text-sm font-semibold", children: t(group.titleKey, group.key) }), _jsx("p", { className: "text-xs text-muted-foreground", children: t(group.descriptionKey, '') })] }), group.items.map(item => (_jsxs("label", { className: "flex items-start gap-2 text-sm cursor-pointer", children: [_jsx("input", { type: "checkbox", "data-marketing-consent-item": item.definition.key, className: "mt-0.5 size-4 shrink-0 accent-primary", checked: item.granted, onChange: event => model.toggle(item.definition.key, event.target.checked) }), _jsxs("span", { className: "flex flex-col gap-0.5", children: [_jsxs("span", { className: "flex items-center gap-2", children: [t(item.definition.labelKey ?? '', item.definition.key), item.updated && (_jsx("span", { "data-marketing-consent-updated": item.definition.key, className: "text-xs rounded bg-accent px-1.5 py-0.5 text-accent-foreground", children: t('screen.updated', 'Updated') }))] }), item.definition.descriptionKey != null && (_jsx("span", { className: "text-xs text-muted-foreground", children: t(item.definition.descriptionKey, '') })), model.gpc && item.definition.honorGpc === true && (_jsx("span", { className: "text-xs text-muted-foreground", children: t('screen.gpc', "Honored via your browser's Global Privacy Control signal") })), item.definition.links?.[0] != null && (_jsx("a", { href: item.definition.links[0].href, target: "_blank", rel: "noreferrer noopener", className: "text-xs underline underline-offset-2", children: t('link.default', 'Learn more') }))] })] }, item.definition.key)))] }, group.key)))] }));
21
+ };
22
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/components/fields.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AASzC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B,CAAC,EAAE,CAAC,EAAE,KAAK,EA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.js';
2
+ export * from './preferences.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './screen.js';
2
+ export * from './preferences.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { FC } from 'react';
2
+ export interface MarketingConsentPreferencesProps {
3
+ /** `(key, defaultValue) => string`, e.g. an app's own `useI18nApp` translator. Defaults to this
4
+ * package's own bundle (`useI18nLib(MARKETING_CONSENT_I18N)`). */
5
+ translate?: (key: string, defaultValue: string) => string;
6
+ className?: string;
7
+ onSaved?: () => void;
8
+ }
9
+ /**
10
+ * The SAME group/item/select-all body as `MarketingConsentScreen`, without the full-page chrome —
11
+ * for a host's own settings card. `MarketingConsentClientService.preferences()` names the
12
+ * entrypoint alias a "Privacy choices" footer link should point at; that screen renders this.
13
+ *
14
+ * Unlike the sign-in screen, there is no `useContinueLogin` here at all — this is not a step in a
15
+ * login flow, so nothing navigates on save, and there is no "skip" — a settings card is always
16
+ * revisitable.
17
+ */
18
+ export declare const MarketingConsentPreferences: FC<MarketingConsentPreferencesProps>;
19
+ //# sourceMappingURL=preferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.d.ts","sourceRoot":"","sources":["../../src/components/preferences.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAQ/B,MAAM,WAAW,gCAAgC;IAC/C;sEACkE;IAClE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,CAAA;IACzD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAAC,gCAAgC,CA0C5E,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { useI18nLib } from '@owlmeans/client-i18n';
4
+ import { MARKETING_CONSENT_I18N } from '../consts.js';
5
+ import { useMarketingConsent } from '../hooks/use-marketing-consent.js';
6
+ import { Button } from '../@/components/ui/button.js';
7
+ import { cn } from '../@/lib/utils.js';
8
+ import { ConsentFields } from './fields.js';
9
+ /**
10
+ * The SAME group/item/select-all body as `MarketingConsentScreen`, without the full-page chrome —
11
+ * for a host's own settings card. `MarketingConsentClientService.preferences()` names the
12
+ * entrypoint alias a "Privacy choices" footer link should point at; that screen renders this.
13
+ *
14
+ * Unlike the sign-in screen, there is no `useContinueLogin` here at all — this is not a step in a
15
+ * login flow, so nothing navigates on save, and there is no "skip" — a settings card is always
16
+ * revisitable.
17
+ */
18
+ export const MarketingConsentPreferences = ({ translate, className, onSaved, }) => {
19
+ const libT = useI18nLib(MARKETING_CONSENT_I18N);
20
+ const t = translate ?? libT;
21
+ const model = useMarketingConsent({ source: 'settings' });
22
+ const [saved, setSaved] = useState(false);
23
+ const onSave = async () => {
24
+ setSaved(false);
25
+ const ok = await model.save();
26
+ if (ok) {
27
+ setSaved(true);
28
+ onSaved?.();
29
+ }
30
+ };
31
+ return (_jsx("div", { className: cn('flex flex-col gap-6', className), children: model.loading ? (_jsx("p", { children: t('screen.loading', 'Loading…') })) : (_jsxs(_Fragment, { children: [_jsx(ConsentFields, { t: t, model: model }), model.error != null && (_jsx("p", { role: "alert", children: t('preferences.error', "We couldn't save your choices.") })), saved && model.error == null && _jsx("p", { children: t('preferences.saved', 'Saved') }), _jsx(Button, { type: "button", disabled: model.saving, "data-marketing-consent-preferences-save": true, onClick: () => void onSave(), children: model.saving ? t('screen.saving', 'Saving…') : t('preferences.save', 'Save') })] })) }));
32
+ };
33
+ //# sourceMappingURL=preferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.js","sourceRoot":"","sources":["../../src/components/preferences.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAU3C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAyC,CAAC,EAChF,SAAS,EAAE,SAAS,EAAE,OAAO,GAC9B,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAA;IAC/C,MAAM,CAAC,GAAG,SAAS,IAAI,IAAI,CAAA;IAC3B,MAAM,KAAK,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;IACzD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEzC,MAAM,MAAM,GAAG,KAAK,IAAmB,EAAE;QACvC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACf,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAC7B,IAAI,EAAE,EAAE,CAAC;YACP,QAAQ,CAAC,IAAI,CAAC,CAAA;YACd,OAAO,EAAE,EAAE,CAAA;QACb,CAAC;IACH,CAAC,CAAA;IAED,OAAO,CACL,cAAK,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,YACjD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CACf,sBAAI,CAAC,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAK,CACzC,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,aAAa,IAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,GAAI,EAEpC,KAAK,CAAC,KAAK,IAAI,IAAI,IAAI,CACtB,YAAG,IAAI,EAAC,OAAO,YAAE,CAAC,CAAC,mBAAmB,EAAE,gCAAgC,CAAC,GAAK,CAC/E,EACA,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,IAAI,sBAAI,CAAC,CAAC,mBAAmB,EAAE,OAAO,CAAC,GAAK,EAEzE,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,KAAK,CAAC,MAAM,mDAEtB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,MAAM,EAAE,YAE3B,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,MAAM,CAAC,GACtE,IACR,CACJ,GACG,CACP,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { RoutedComponent } from '@owlmeans/client';
2
+ /**
3
+ * The post-sign-in marketing-consent screen. Full page, no application chrome — the same shape
4
+ * `@owlmeans/web-oauth`'s consent screen renders in.
5
+ *
6
+ * UNLIKE that screen, this one renders when framed too: saving a marketing preference is not a
7
+ * token-mint decision a clickjacking overlay could steal, so there is deliberately no
8
+ * framed-refusal branch here.
9
+ */
10
+ export declare const MarketingConsentScreen: RoutedComponent;
11
+ //# sourceMappingURL=screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/components/screen.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAQvD;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,eAwEpC,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useI18nLib } from '@owlmeans/client-i18n';
3
+ import { useContinueLogin } from '@owlmeans/client-auth/login';
4
+ import { MARKETING_CONSENT_I18N, MARKETING_CONSENT_LOGIN_STEP } from '../consts.js';
5
+ import { useMarketingConsent } from '../hooks/use-marketing-consent.js';
6
+ import { Button } from '../@/components/ui/button.js';
7
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../@/components/ui/card.js';
8
+ import { ConsentFields } from './fields.js';
9
+ /**
10
+ * The post-sign-in marketing-consent screen. Full page, no application chrome — the same shape
11
+ * `@owlmeans/web-oauth`'s consent screen renders in.
12
+ *
13
+ * UNLIKE that screen, this one renders when framed too: saving a marketing preference is not a
14
+ * token-mint decision a clickjacking overlay could steal, so there is deliberately no
15
+ * framed-refusal branch here.
16
+ */
17
+ export const MarketingConsentScreen = () => {
18
+ const t = useI18nLib(MARKETING_CONSENT_I18N);
19
+ const model = useMarketingConsent({ source: 'sign-in' });
20
+ const continueLogin = useContinueLogin();
21
+ const onSave = async () => {
22
+ const ok = await model.save();
23
+ if (ok) {
24
+ await continueLogin({ after: MARKETING_CONSENT_LOGIN_STEP });
25
+ }
26
+ };
27
+ // A person who cannot or will not answer must never be permanently trapped on this step — skip
28
+ // clears the error and moves the flow on exactly as a successful save would, just unsaved.
29
+ const onSkip = async () => {
30
+ model.skip();
31
+ await continueLogin({ after: MARKETING_CONSENT_LOGIN_STEP });
32
+ };
33
+ return (_jsx("div", { "data-marketing-consent": true, style: { minHeight: '100dvh', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 16 }, children: _jsxs(Card, { style: { width: '100%', maxWidth: 480 }, children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: t('screen.title', 'Your privacy choices') }), _jsx(CardDescription, { children: t('screen.subtitle', 'Choose what we may use to reach you and personalize your experience.') })] }), _jsx(CardContent, { style: { display: 'flex', flexDirection: 'column', gap: 16 }, children: model.loading ? (_jsx("p", { children: t('screen.loading', 'Loading…') })) : (_jsxs(_Fragment, { children: [_jsx(ConsentFields, { t: t, model: model }), model.error != null && (_jsx("p", { role: "alert", "data-marketing-consent-error": true, children: t('screen.error', "We couldn't save your choices.") })), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 8 }, children: [_jsx(Button, { type: "button", disabled: model.saving, "data-marketing-consent-save": true, onClick: () => void onSave(), children: model.saving ? t('screen.saving', 'Saving…') : t('screen.save', 'Save and continue') }), model.error != null && (_jsx(Button, { type: "button", variant: "link", size: "sm", "data-marketing-consent-skip": true, onClick: () => void onSkip(), children: t('screen.skip', 'Continue without saving') }))] })] })) })] }) }));
34
+ };
35
+ //# sourceMappingURL=screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.js","sourceRoot":"","sources":["../../src/components/screen.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtG,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAoB,GAAG,EAAE;IAC1D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C,GAAK,CACzC,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,aAAa,IAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,GAAI,EAEpC,KAAK,CAAC,KAAK,IAAI,IAAI,IAAI,CACtB,YAAG,IAAI,EAAC,OAAO,kDACZ,CAAC,CAAC,cAAc,EAAE,gCAAgC,CAAC,GAClD,CACL,EAED,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aAC9D,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,KAAK,CAAC,MAAM,uCAEtB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,MAAM,EAAE,YAE3B,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,mBAAmB,CAAC,GAC9E,EAER,KAAK,CAAC,KAAK,IAAI,IAAI,IAAI,CACtB,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,MAAM,EACd,IAAI,EAAC,IAAI,uCAET,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,MAAM,EAAE,YAE3B,CAAC,CAAC,aAAa,EAAE,yBAAyB,CAAC,GACrC,CACV,IACG,IACL,CACJ,GACW,IACT,GACH,CACP,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,26 @@
1
+ /** The client-side marketing-consent service alias (`context.service<MarketingConsentClientService>(...)`). */
2
+ export declare const MARKETING_CONSENT_CLIENT_SERVICE = "marketing-consent-client";
3
+ /** `LoginStep.alias` — the post-sign-in step this package registers with `@owlmeans/client-auth`. */
4
+ export declare const MARKETING_CONSENT_LOGIN_STEP = "marketing-consent";
5
+ /** `LoginLandingHook.alias` — records a fresh terms acceptance once, per landed token. */
6
+ export declare const MARKETING_CONSENT_LANDING_HOOK_TERMS = "marketing-consent:terms";
7
+ /** `LoginLandingHook.alias` — reconciles every registered `MarketingConsentBridge` once, per landed token. */
8
+ export declare const MARKETING_CONSENT_LANDING_HOOK_SYNC = "marketing-consent:bridges";
9
+ /**
10
+ * The i18n resource this package's own screen/preferences strings register under.
11
+ *
12
+ * Deliberately the SAME resource `@owlmeans/marketing-consent` already owns
13
+ * (`MARKETING_CONSENT_I18N`, `'marketing-consent'`) rather than a second one. That domain package
14
+ * ships no UI of its own — only the `group.*`/`consent.*` label and description keys a screen needs
15
+ * — and this package is the ONLY thing that ever renders them, adding its own `screen.*`/
16
+ * `preferences.*` keys alongside them. `addI18nLib` pushes a new resource ENTRY rather than
17
+ * replacing one (`@owlmeans/i18n`'s `_addI18n`/`initI18nResource`), and `client-i18n`'s
18
+ * `useI18nResource` merges every entry for a `(lng, resource, ns)` triple with
19
+ * `i18n.addResourceBundle(lng, ns, data, true, true)` (deep merge) before it is ever read — so two
20
+ * packages contributing DISJOINT top-level keys (`group`/`consent`/`link`/`errors` here vs.
21
+ * `screen`/`preferences` there) combine cleanly into one bundle. A second resource name would only
22
+ * mean a translator has to know "the marketing-consent strings" are split across two files that
23
+ * describe the same feature.
24
+ */
25
+ export declare const MARKETING_CONSENT_I18N = "marketing-consent";
26
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAEA,+GAA+G;AAC/G,eAAO,MAAM,gCAAgC,6BAA6B,CAAA;AAE1E,qGAAqG;AACrG,eAAO,MAAM,4BAA4B,sBAAsB,CAAA;AAE/D,0FAA0F;AAC1F,eAAO,MAAM,oCAAoC,4BAA4B,CAAA;AAE7E,8GAA8G;AAC9G,eAAO,MAAM,mCAAmC,8BAA8B,CAAA;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,sBAAc,CAAA"}
@@ -0,0 +1,27 @@
1
+ import { MARKETING_CONSENT_I18N as DOMAIN_I18N } from '@owlmeans/marketing-consent';
2
+ /** The client-side marketing-consent service alias (`context.service<MarketingConsentClientService>(...)`). */
3
+ export const MARKETING_CONSENT_CLIENT_SERVICE = 'marketing-consent-client';
4
+ /** `LoginStep.alias` — the post-sign-in step this package registers with `@owlmeans/client-auth`. */
5
+ export const MARKETING_CONSENT_LOGIN_STEP = 'marketing-consent';
6
+ /** `LoginLandingHook.alias` — records a fresh terms acceptance once, per landed token. */
7
+ export const MARKETING_CONSENT_LANDING_HOOK_TERMS = 'marketing-consent:terms';
8
+ /** `LoginLandingHook.alias` — reconciles every registered `MarketingConsentBridge` once, per landed token. */
9
+ export const MARKETING_CONSENT_LANDING_HOOK_SYNC = 'marketing-consent:bridges';
10
+ /**
11
+ * The i18n resource this package's own screen/preferences strings register under.
12
+ *
13
+ * Deliberately the SAME resource `@owlmeans/marketing-consent` already owns
14
+ * (`MARKETING_CONSENT_I18N`, `'marketing-consent'`) rather than a second one. That domain package
15
+ * ships no UI of its own — only the `group.*`/`consent.*` label and description keys a screen needs
16
+ * — and this package is the ONLY thing that ever renders them, adding its own `screen.*`/
17
+ * `preferences.*` keys alongside them. `addI18nLib` pushes a new resource ENTRY rather than
18
+ * replacing one (`@owlmeans/i18n`'s `_addI18n`/`initI18nResource`), and `client-i18n`'s
19
+ * `useI18nResource` merges every entry for a `(lng, resource, ns)` triple with
20
+ * `i18n.addResourceBundle(lng, ns, data, true, true)` (deep merge) before it is ever read — so two
21
+ * packages contributing DISJOINT top-level keys (`group`/`consent`/`link`/`errors` here vs.
22
+ * `screen`/`preferences` there) combine cleanly into one bundle. A second resource name would only
23
+ * mean a translator has to know "the marketing-consent strings" are split across two files that
24
+ * describe the same feature.
25
+ */
26
+ export const MARKETING_CONSENT_I18N = DOMAIN_I18N;
27
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,IAAI,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEnF,+GAA+G;AAC/G,MAAM,CAAC,MAAM,gCAAgC,GAAG,0BAA0B,CAAA;AAE1E,qGAAqG;AACrG,MAAM,CAAC,MAAM,4BAA4B,GAAG,mBAAmB,CAAA;AAE/D,0FAA0F;AAC1F,MAAM,CAAC,MAAM,oCAAoC,GAAG,yBAAyB,CAAA;AAE7E,8GAA8G;AAC9G,MAAM,CAAC,MAAM,mCAAmC,GAAG,2BAA2B,CAAA;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { MarketingConsentEntrypoints } from '@owlmeans/marketing-consent';
2
+ /**
3
+ * The marketing-consent screen, bound and ready to spread into an application's entrypoint list —
4
+ * the whole of what a web app has to do beyond calling `appendMarketingConsent`.
5
+ *
6
+ * `status`/`save`/`terms`/`base` are NOT bound here: they are ordinary backend routes, bound by
7
+ * the app's own `bindAll` alongside the matching server handlers
8
+ * (`@owlmeans/server-marketing-consent`'s `serveMarketingConsentEntrypoints`) — the same split
9
+ * `@owlmeans/web-oauth`'s `oauthEntrypoints` draws for its own consent API.
10
+ */
11
+ export declare const marketingConsentEntrypoints: (protocols: MarketingConsentEntrypoints) => import("@owlmeans/client-entrypoint").ClientProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>>[];
12
+ //# sourceMappingURL=entrypoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAG9E;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,cAAe,2BAA2B,8MAEjF,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { handler } from '@owlmeans/client';
2
+ import { bindScreen } from '@owlmeans/client-entrypoint';
3
+ import { MarketingConsentScreen } from './components/screen.js';
4
+ /**
5
+ * The marketing-consent screen, bound and ready to spread into an application's entrypoint list —
6
+ * the whole of what a web app has to do beyond calling `appendMarketingConsent`.
7
+ *
8
+ * `status`/`save`/`terms`/`base` are NOT bound here: they are ordinary backend routes, bound by
9
+ * the app's own `bindAll` alongside the matching server handlers
10
+ * (`@owlmeans/server-marketing-consent`'s `serveMarketingConsentEntrypoints`) — the same split
11
+ * `@owlmeans/web-oauth`'s `oauthEntrypoints` draws for its own consent API.
12
+ */
13
+ export const marketingConsentEntrypoints = (protocols) => [
14
+ bindScreen(protocols.screen, handler(MarketingConsentScreen)),
15
+ ];
16
+ //# sourceMappingURL=entrypoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAE/D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,SAAsC,EAAE,EAAE,CAAC;IACrF,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAC9D,CAAA"}
@@ -0,0 +1,38 @@
1
+ import type { MarketingConsentStatusItem } from '@owlmeans/marketing-consent';
2
+ export interface MarketingConsentGroup {
3
+ key: string;
4
+ titleKey: string;
5
+ descriptionKey: string;
6
+ items: MarketingConsentStatusItem[];
7
+ }
8
+ export interface UseMarketingConsentModel {
9
+ loading: boolean;
10
+ saving: boolean;
11
+ /** Non-null after a failed `save()` — a fixed marker, not the wire text; the screen renders one
12
+ * translated sentence (`screen.error`/`preferences.error`) regardless of its value. */
13
+ error: string | null;
14
+ /** `navigator.globalPrivacyControl === true`, read once at mount. */
15
+ gpc: boolean;
16
+ /** Grouped in the standard order (communications, data, trackers), any other group appended
17
+ * after in first-seen order. Each item's `granted` reflects the CURRENT draft, not the value the
18
+ * status call first loaded — a consumer never reads draft state separately. */
19
+ groups: MarketingConsentGroup[];
20
+ allChecked: boolean;
21
+ allIndeterminate: boolean;
22
+ toggleAll: (checked: boolean) => void;
23
+ toggle: (key: string, checked: boolean) => void;
24
+ /** Posts every item's CURRENT draft value (never only the changed ones — the server upserts by
25
+ * key). Resolves `true` on success, `false` on failure (and sets {@link error}). */
26
+ save: () => Promise<boolean>;
27
+ /** Clears {@link error} — what "Continue without saving" calls before moving the flow on. */
28
+ skip: () => void;
29
+ }
30
+ /**
31
+ * Headless model behind the sign-in screen AND `MarketingConsentPreferences` — the same body,
32
+ * driven the same way, so the two never drift. `opts.source` is what a successful `save()` posts
33
+ * (`'sign-in'` from the screen, `'settings'` from preferences — the default).
34
+ */
35
+ export declare const useMarketingConsent: (opts?: {
36
+ source?: 'sign-in' | 'settings';
37
+ }) => UseMarketingConsentModel;
38
+ //# sourceMappingURL=use-marketing-consent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-marketing-consent.d.ts","sourceRoot":"","sources":["../../src/hooks/use-marketing-consent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AAI7E,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,0BAA0B,EAAE,CAAA;CACpC;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,OAAO,CAAA;IACf;2FACuF;IACvF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,qEAAqE;IACrE,GAAG,EAAE,OAAO,CAAA;IACZ;;mFAE+E;IAC/E,MAAM,EAAE,qBAAqB,EAAE,CAAA;IAC/B,UAAU,EAAE,OAAO,CAAA;IACnB,gBAAgB,EAAE,OAAO,CAAA;IACzB,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC/C;wFACoF;IACpF,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IAC5B,6FAA6F;IAC7F,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAuCD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,UAAW;IAAE,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;CAAE,KAAG,wBAsEhF,CAAA"}
@@ -0,0 +1,96 @@
1
+ import { useCallback, useEffect, useMemo, useState } from 'react';
2
+ import { useContext } from '@owlmeans/client';
3
+ import { MC_GROUP_COMMUNICATIONS, MC_GROUP_DATA, MC_GROUP_TRACKERS } from '@owlmeans/marketing-consent';
4
+ import { MARKETING_CONSENT_CLIENT_SERVICE } from '../consts.js';
5
+ const GROUP_ORDER = [MC_GROUP_COMMUNICATIONS, MC_GROUP_DATA, MC_GROUP_TRACKERS];
6
+ const groupRank = (key) => {
7
+ const index = GROUP_ORDER.indexOf(key);
8
+ return index >= 0 ? index : GROUP_ORDER.length;
9
+ };
10
+ const groupOf = (items) => {
11
+ const order = [];
12
+ const byKey = new Map();
13
+ for (const item of items) {
14
+ const key = item.definition.group;
15
+ if (!byKey.has(key)) {
16
+ order.push(key);
17
+ byKey.set(key, []);
18
+ }
19
+ byKey.get(key).push(item);
20
+ }
21
+ return order
22
+ .sort((a, b) => groupRank(a) - groupRank(b))
23
+ .map(key => ({
24
+ key, titleKey: `group.${key}.title`, descriptionKey: `group.${key}.description`,
25
+ items: byKey.get(key),
26
+ }));
27
+ };
28
+ const readGpc = () => {
29
+ try {
30
+ return typeof navigator !== 'undefined'
31
+ && navigator.globalPrivacyControl === true;
32
+ }
33
+ catch {
34
+ return false;
35
+ }
36
+ };
37
+ /**
38
+ * Headless model behind the sign-in screen AND `MarketingConsentPreferences` — the same body,
39
+ * driven the same way, so the two never drift. `opts.source` is what a successful `save()` posts
40
+ * (`'sign-in'` from the screen, `'settings'` from preferences — the default).
41
+ */
42
+ export const useMarketingConsent = (opts) => {
43
+ const context = useContext();
44
+ const client = context.service(MARKETING_CONSENT_CLIENT_SERVICE);
45
+ const [loading, setLoading] = useState(true);
46
+ const [saving, setSaving] = useState(false);
47
+ const [error, setError] = useState(null);
48
+ const [items, setItems] = useState([]);
49
+ const [draft, setDraft] = useState({});
50
+ const [gpc] = useState(readGpc);
51
+ useEffect(() => {
52
+ let cancelled = false;
53
+ void (async () => {
54
+ const status = await client.status({ fresh: true });
55
+ if (cancelled) {
56
+ return;
57
+ }
58
+ const loaded = status?.items ?? [];
59
+ setItems(loaded);
60
+ setDraft(Object.fromEntries(loaded.map(item => [item.definition.key, item.granted])));
61
+ setLoading(false);
62
+ })();
63
+ return () => { cancelled = true; };
64
+ // eslint-disable-next-line react-hooks/exhaustive-deps
65
+ }, [client]);
66
+ const liveItems = useMemo(() => items.map(item => ({ ...item, granted: draft[item.definition.key] ?? item.granted })), [items, draft]);
67
+ const groups = useMemo(() => groupOf(liveItems), [liveItems]);
68
+ const allChecked = items.length > 0 && items.every(item => draft[item.definition.key] === true);
69
+ const allIndeterminate = !allChecked && items.some(item => draft[item.definition.key] === true);
70
+ const toggle = useCallback((key, checked) => {
71
+ setDraft(current => ({ ...current, [key]: checked }));
72
+ }, []);
73
+ const toggleAll = useCallback((checked) => {
74
+ setDraft(Object.fromEntries(items.map(item => [item.definition.key, checked])));
75
+ }, [items]);
76
+ const save = useCallback(async () => {
77
+ setSaving(true);
78
+ setError(null);
79
+ const result = await client.save({
80
+ decisions: items.map(item => ({ key: item.definition.key, granted: draft[item.definition.key] === true })),
81
+ source: opts?.source ?? 'settings',
82
+ gpc,
83
+ });
84
+ setSaving(false);
85
+ if (result == null) {
86
+ setError('save-failed');
87
+ return false;
88
+ }
89
+ setItems(result.items);
90
+ setDraft(Object.fromEntries(result.items.map(item => [item.definition.key, item.granted])));
91
+ return true;
92
+ }, [client, items, draft, opts?.source, gpc]);
93
+ const skip = useCallback(() => { setError(null); }, []);
94
+ return { loading, saving, error, gpc, groups, allChecked, allIndeterminate, toggleAll, toggle, save, skip };
95
+ };
96
+ //# sourceMappingURL=use-marketing-consent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-marketing-consent.js","sourceRoot":"","sources":["../../src/hooks/use-marketing-consent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAEvG,OAAO,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAA;AAiC/D,MAAM,WAAW,GAAG,CAAC,uBAAuB,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAA;AAE/E,MAAM,SAAS,GAAG,CAAC,GAAW,EAAU,EAAE;IACxC,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAEtC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAA;AAChD,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,CAAC,KAAmC,EAA2B,EAAE;IAC/E,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAwC,CAAA;IAC7D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,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"subtitle": "Выберыце, што мы можам выкарыстоўваць, каб звязвацца з вамі і персаналізаваць ваш досвед.",
5
+ "all": "Абраць усё",
6
+ "updated": "Абноўлена",
7
+ "save": "Захаваць і працягнуць",
8
+ "saving": "Захаванне…",
9
+ "skip": "Працягнуць без захавання",
10
+ "error": "Не ўдалося захаваць ваш выбар.",
11
+ "gpc": "Улічана дзякуючы сігналу Global Privacy Control вашага браўзера",
12
+ "loading": "Загрузка…"
13
+ },
14
+ "preferences": {
15
+ "save": "Захаваць",
16
+ "saved": "Захавана",
17
+ "error": "Не ўдалося захаваць ваш выбар."
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "screen": {
3
+ "title": "Ihre Datenschutzeinstellungen",
4
+ "subtitle": "Wählen Sie, was wir nutzen dürfen, um Sie zu erreichen und Ihre Erfahrung zu personalisieren.",
5
+ "all": "Alle auswählen",
6
+ "updated": "Aktualisiert",
7
+ "save": "Speichern und fortfahren",
8
+ "saving": "Wird gespeichert…",
9
+ "skip": "Ohne Speichern fortfahren",
10
+ "error": "Ihre Auswahl konnte nicht gespeichert werden.",
11
+ "gpc": "Berücksichtigt dank des Global-Privacy-Control-Signals Ihres Browsers",
12
+ "loading": "Wird geladen…"
13
+ },
14
+ "preferences": {
15
+ "save": "Speichern",
16
+ "saved": "Gespeichert",
17
+ "error": "Ihre Auswahl konnte nicht gespeichert werden."
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "screen": {
3
+ "title": "Your privacy choices",
4
+ "subtitle": "Choose what we may use to reach you and personalize your experience.",
5
+ "all": "Select all",
6
+ "updated": "Updated",
7
+ "save": "Save and continue",
8
+ "saving": "Saving…",
9
+ "skip": "Continue without saving",
10
+ "error": "We couldn't save your choices.",
11
+ "gpc": "Honored via your browser's Global Privacy Control signal",
12
+ "loading": "Loading…"
13
+ },
14
+ "preferences": {
15
+ "save": "Save",
16
+ "saved": "Saved",
17
+ "error": "We couldn't save your choices."
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "screen": {
3
+ "title": "Tus opciones de privacidad",
4
+ "subtitle": "Elige qué podemos usar para contactarte y personalizar tu experiencia.",
5
+ "all": "Seleccionar todo",
6
+ "updated": "Actualizado",
7
+ "save": "Guardar y continuar",
8
+ "saving": "Guardando…",
9
+ "skip": "Continuar sin guardar",
10
+ "error": "No pudimos guardar tus elecciones.",
11
+ "gpc": "Respetado gracias a la señal Global Privacy Control de tu navegador",
12
+ "loading": "Cargando…"
13
+ },
14
+ "preferences": {
15
+ "save": "Guardar",
16
+ "saved": "Guardado",
17
+ "error": "No pudimos guardar tus elecciones."
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "screen": {
3
+ "title": "Vos choix de confidentialité",
4
+ "subtitle": "Choisissez ce que nous pouvons utiliser pour vous contacter et personnaliser votre expérience.",
5
+ "all": "Tout sélectionner",
6
+ "updated": "Mis à jour",
7
+ "save": "Enregistrer et continuer",
8
+ "saving": "Enregistrement…",
9
+ "skip": "Continuer sans enregistrer",
10
+ "error": "Nous n'avons pas pu enregistrer vos choix.",
11
+ "gpc": "Respecté grâce au signal Global Privacy Control de votre navigateur",
12
+ "loading": "Chargement…"
13
+ },
14
+ "preferences": {
15
+ "save": "Enregistrer",
16
+ "saved": "Enregistré",
17
+ "error": "Nous n'avons pas pu enregistrer vos choix."
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "screen": {
3
+ "title": "Twoje wybory dotyczące prywatności",
4
+ "subtitle": "Wybierz, czego możemy używać, aby się z Tobą kontaktować i personalizować Twoje doświadczenie.",
5
+ "all": "Zaznacz wszystko",
6
+ "updated": "Zaktualizowano",
7
+ "save": "Zapisz i kontynuuj",
8
+ "saving": "Zapisywanie…",
9
+ "skip": "Kontynuuj bez zapisywania",
10
+ "error": "Nie udało się zapisać Twoich wyborów.",
11
+ "gpc": "Uwzględnione dzięki sygnałowi Global Privacy Control Twojej przeglądarki",
12
+ "loading": "Wczytywanie…"
13
+ },
14
+ "preferences": {
15
+ "save": "Zapisz",
16
+ "saved": "Zapisano",
17
+ "error": "Nie udało się zapisać Twoich wyborów."
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "screen": {
3
+ "title": "Ваши настройки конфиденциальности",
4
+ "subtitle": "Выберите, что мы можем использовать, чтобы связываться с вами и персонализировать ваш опыт.",
5
+ "all": "Выбрать всё",
6
+ "updated": "Обновлено",
7
+ "save": "Сохранить и продолжить",
8
+ "saving": "Сохранение…",
9
+ "skip": "Продолжить без сохранения",
10
+ "error": "Не удалось сохранить ваш выбор.",
11
+ "gpc": "Учитывается благодаря сигналу Global Privacy Control вашего браузера",
12
+ "loading": "Загрузка…"
13
+ },
14
+ "preferences": {
15
+ "save": "Сохранить",
16
+ "saved": "Сохранено",
17
+ "error": "Не удалось сохранить ваш выбор."
18
+ }
19
+ }