@frak-labs/components 1.3.4 → 1.5.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 (50) hide show
  1. package/cdn/Ambassador.CZAN1-jx.js +519 -0
  2. package/cdn/Banner.2WJ4pT6E.js +227 -0
  3. package/cdn/ButtonShare.DSGvJfJ-.js +1 -0
  4. package/cdn/{ButtonWallet.CIesaq0l.js → ButtonWallet.DHpHCl4c.js} +2 -2
  5. package/cdn/GiftIcon.DYg5xgHg.js +1 -0
  6. package/cdn/InstallQr.CHImaq56.js +1 -0
  7. package/cdn/{OpenInAppButton.BtXknsxK.js → OpenInAppButton.CxBzRNKw.js} +1 -1
  8. package/cdn/PostPurchase.CVZlV54f.js +124 -0
  9. package/cdn/RewardReminder.C6o8lgak.js +369 -0
  10. package/cdn/components.js +1 -1
  11. package/cdn/format.D2Ai5cCn.js +1 -0
  12. package/cdn/{GiftIcon.CX0gLPUJ.js → icons.CdzHzZIJ.js} +1 -1
  13. package/cdn/jsxRuntime.module.7FJBZ9bf.js +58 -0
  14. package/cdn/loader.js +20 -16
  15. package/cdn/mountRewardReminder.BlmSRJDe.js +1 -0
  16. package/cdn/previewSummary.DxyobqED.js +1 -0
  17. package/cdn/rewardSummaryStore.DyjI-vPH.js +1 -0
  18. package/cdn/{rewards.F9iOJSNk.js → rewards.CeNLrK54.js} +1 -1
  19. package/cdn/useGlobalComponents.CNnOzerU.js +1 -0
  20. package/cdn/{useLightDomStyles.CpiH8nO2.js → useLightDomStyles.557xWurb.js} +1 -1
  21. package/cdn/usePlacement.DYgmdkfr.js +1 -0
  22. package/cdn/{useReward.B9ibElG0.js → useReward.BzUL3ijd.js} +1 -1
  23. package/dist/GiftIcon-Csu31jtf.js +62 -0
  24. package/dist/InstallQr-kpb44cfg.js +84 -0
  25. package/dist/ambassador.d.ts +16 -1
  26. package/dist/ambassador.js +626 -191
  27. package/dist/banner.d.ts +20 -6
  28. package/dist/banner.js +237 -15
  29. package/dist/buttonShare.js +2 -2
  30. package/dist/buttonWallet.js +1 -1
  31. package/dist/format-zGdbUoX_.js +283 -0
  32. package/dist/i18n/defaults.d.ts +72 -0
  33. package/dist/i18n/defaults.js +108 -6
  34. package/dist/{GiftIcon-B9k_syq6.js → icons-iN3qH_Bv.js} +1 -61
  35. package/dist/postPurchase.d.ts +6 -1
  36. package/dist/postPurchase.js +188 -34
  37. package/dist/previewSummary-CMc6q8vI.js +37 -0
  38. package/dist/rewardReminder.d.ts +50 -0
  39. package/dist/rewardReminder.js +809 -0
  40. package/dist/{rewards-CfGynCt6.js → rewards-BuNthAR2.js} +49 -46
  41. package/dist/{sharedBaseCss.css-nYy9vlzH.js → sharedBaseCss.css-D2HG4Ty8.js} +1 -1
  42. package/dist/{useReward-DmukZKoh.js → useReward-cQ54x8q-.js} +1 -1
  43. package/package.json +17 -11
  44. package/cdn/Ambassador.tWpfYThv.js +0 -392
  45. package/cdn/Banner.RSZt2Kn_.js +0 -208
  46. package/cdn/ButtonShare.Buy6qEfW.js +0 -1
  47. package/cdn/PostPurchase.Btgp2kLc.js +0 -102
  48. package/cdn/jsxRuntime.module.CUZaa90V.js +0 -58
  49. package/cdn/useGlobalComponents.CXuceSQ0.js +0 -1
  50. package/cdn/usePlacement.Cq64cZ9Q.js +0 -1
@@ -1,13 +1,15 @@
1
1
  import { a as useClientReady, o as registerWebComponent, r as useLang, s as openSharingPage } from "./sharedCss-SKmJGZgN.js";
2
- import { i as w } from "./rewards-CfGynCt6.js";
2
+ import { i as w } from "./rewards-BuNthAR2.js";
3
3
  import { t as useGlobalComponents } from "./useGlobalComponents-BF47jsBt.js";
4
4
  import { t as useLightDomStyles } from "./useLightDomStyles-wGaNXHqN.js";
5
- import { t as useReward } from "./useReward-DmukZKoh.js";
5
+ import { t as useReward } from "./useReward-cQ54x8q-.js";
6
6
  import { componentDefaults } from "./i18n/defaults.js";
7
- import { t as cssSource$2 } from "./sharedBaseCss.css-nYy9vlzH.js";
8
- import { trackEvent } from "@frak-labs/core-sdk";
7
+ import { t as cssSource$2 } from "./sharedBaseCss.css-D2HG4Ty8.js";
8
+ import { a as resolveRewardCurrency, c as isClaimable, d as useInlineReminderRegistration, i as pickFiat, l as markClaimStarted, n as formatFiat, o as getRewardCountdown, r as formatRewardDate, s as useRewardSummary, t as fillReminderText } from "./format-zGdbUoX_.js";
9
+ import { n as QrSvg, r as useInstallQr, t as InstallQr } from "./InstallQr-kpb44cfg.js";
10
+ import { getEnvironment, isMobile, trackEvent } from "@frak-labs/core-sdk";
9
11
  import { getInstallUrl } from "@frak-labs/core-sdk/actions";
10
- import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
12
+ import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
11
13
  import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
12
14
  // src/hooks/useHostTheme.ts
13
15
  const QUIET_BORDER_DISTANCE = 120;
@@ -17,6 +19,8 @@ const VISIBLE_CONTRAST = 1.5;
17
19
  const VISIBLE_DISTANCE = 60;
18
20
  const DEFAULT_ACCENT = "rgb(17, 17, 17)";
19
21
  const DEFAULT_TAG_BG = "rgb(255, 255, 255)";
22
+ const WHITE = "rgb(255, 255, 255)";
23
+ const HEX_COLOR = /^#[0-9a-f]{6}$/i;
20
24
  const TAG_TINT = .08;
21
25
  const RESET_HEADING_RATIO = 1.25;
22
26
  const WIDGET_WORDS = /cookie|consent|newsletter|popup|modal|sr-only|visually-hidden|skip-to/i;
@@ -35,6 +39,11 @@ const FONT_KNOBS = [
35
39
  "h2-family",
36
40
  "h2-transform"
37
41
  ];
42
+ const ACCENT_KNOBS = [
43
+ "accent",
44
+ "accent-ink",
45
+ "accent-text"
46
+ ];
38
47
  const REFERENCE_HEADINGS = "[data-frak-amb-ref]";
39
48
  function alphaOf(value) {
40
49
  const slash = /\/\s*([\d.]+)(%?)\s*\)/.exec(value);
@@ -265,7 +274,8 @@ function knobsFrom(source) {
265
274
  ...typographyOf(source.button, "cta", source.buttonBg, false)
266
275
  ];
267
276
  if (source.radius) knobs.push(["radius", source.radius]);
268
- knobs.push(...accentKnobs(source), ...tagKnobs(source));
277
+ knobs.push(...accentKnobs(source));
278
+ knobs.push(...tagKnobs(source));
269
279
  if (source.button) {
270
280
  const from = getComputedStyle(source.button);
271
281
  knobs.push(["cta-radius", from.borderRadius.split(" ")[0]], ["cta-transform", from.textTransform]);
@@ -275,16 +285,62 @@ function knobsFrom(source) {
275
285
  function knobsSignature(knobs) {
276
286
  return knobs.map(([name, value]) => `${name}=${value}`).sort().join("|");
277
287
  }
278
- function writeKnobs(anchor, knobs) {
288
+ /** The `--frak-amb-*` knobs among `names` that already resolve on the anchor: the merchant's own. */
289
+ function merchantKnobs(anchor, names) {
279
290
  const current = getComputedStyle(anchor);
280
- const merchantSet = new Set(knobs.map(([name]) => name).filter((name) => current.getPropertyValue(`--frak-amb-${name}`).trim()));
291
+ return new Set(names.filter((name) => current.getPropertyValue(`--frak-amb-${name}`).trim()));
292
+ }
293
+ function writeKnobs(anchor, knobs) {
294
+ const merchantSet = merchantKnobs(anchor, knobs.map(([name]) => name));
295
+ const written = [];
281
296
  for (const [name, value] of knobs) {
282
297
  if (!value || isTransparent(value)) continue;
283
298
  if (merchantSet.has(name)) continue;
284
299
  if (name === "accent-text" && merchantSet.has("accent")) continue;
285
300
  anchor.style.setProperty(`--frak-amb-${name}`, value);
301
+ written.push(name);
286
302
  }
287
303
  markFontKnobs(anchor);
304
+ return written;
305
+ }
306
+ function rgbFromHex(hex) {
307
+ const channel = (at) => Number.parseInt(hex.slice(at, at + 2), 16);
308
+ return `rgb(${channel(1)}, ${channel(3)}, ${channel(5)})`;
309
+ }
310
+ /**
311
+ * The dashboard accent, its ink and the figures' text. A light accent on a
312
+ * light page (or a dark one on a dark page) sends the text to the page's own
313
+ * colour, the same rule the sampled accent follows.
314
+ */
315
+ function dashboardKnobs(anchor, hex) {
316
+ const fill = rgbFromHex(hex);
317
+ const ink = contrastRatio(fill, WHITE) >= READABLE_CONTRAST ? "#fff" : "#000";
318
+ const knobs = [["accent", hex], ["accent-ink", ink]];
319
+ if (!(contrastRatio(fill, backdropOf(anchor)) >= READABLE_CONTRAST)) knobs.push(["accent-text", "currentColor"]);
320
+ return knobs;
321
+ }
322
+ /**
323
+ * Writes the dashboard accent synchronously, so it neither waits for the
324
+ * sampler nor depends on it. A merchant's CSS accent takes it over entirely.
325
+ */
326
+ function writeDashboardAccent(anchor, hex) {
327
+ if (!HEX_COLOR.test(hex)) return [];
328
+ const knobs = dashboardKnobs(anchor, hex);
329
+ const merchantSet = merchantKnobs(anchor, knobs.map(([name]) => name));
330
+ if (merchantSet.has("accent")) return [];
331
+ const written = [];
332
+ for (const [name, value] of knobs) {
333
+ if (merchantSet.has(name)) continue;
334
+ anchor.style.setProperty(`--frak-amb-${name}`, value);
335
+ written.push(name);
336
+ }
337
+ return written;
338
+ }
339
+ /** The one place that decides who owns the accent: the dashboard, else the sample. */
340
+ function writeAccent(anchor, dashboardHex, sampled) {
341
+ const dashboard = dashboardHex ? writeDashboardAccent(anchor, dashboardHex) : [];
342
+ if (dashboard.includes("accent")) return dashboard;
343
+ return sampled ? writeKnobs(anchor, sampled) : [];
288
344
  }
289
345
  /**
290
346
  * Heading font rules apply only behind this attribute: an unset `var()` in
@@ -305,28 +361,52 @@ async function settled() {
305
361
  if (document.fonts?.ready) await document.fonts.ready;
306
362
  await nextFrame();
307
363
  }
308
- function useHostTheme(target) {
364
+ /**
365
+ * Themes the page from the host. `accentColor` (the dashboard setting) outranks
366
+ * the sampled button colour; the merchant's own `--frak-amb-accent` outranks both.
367
+ */
368
+ function useHostTheme(target, accentColor) {
369
+ const [sampledAccent, setSampledAccent] = useState();
309
370
  useEffect(() => {
310
371
  let cancelled = false;
372
+ const anchor = target.current;
373
+ const written = [];
311
374
  const run = async () => {
312
375
  try {
313
376
  await settled();
314
377
  if (cancelled) return;
315
- const anchor = target.current;
316
- if (!anchor) return;
317
- const first = knobsFrom(sampleTheme(anchor));
378
+ const current = target.current;
379
+ if (!current) return;
380
+ const first = knobsFrom(sampleTheme(current));
318
381
  await nextFrame();
319
382
  if (cancelled) return;
320
- const second = knobsFrom(sampleTheme(anchor));
383
+ const second = knobsFrom(sampleTheme(current));
321
384
  if (knobsSignature(first) !== knobsSignature(second)) return;
322
- writeKnobs(anchor, first);
385
+ const isAccent = ([name]) => ACCENT_KNOBS.includes(name);
386
+ written.push(...writeKnobs(current, first.filter((k) => !isAccent(k))));
387
+ setSampledAccent(first.filter(isAccent));
323
388
  } catch {}
324
389
  };
325
390
  run();
326
391
  return () => {
327
392
  cancelled = true;
393
+ if (!anchor) return;
394
+ for (const name of written) anchor.style.removeProperty(`--frak-amb-${name}`);
395
+ markFontKnobs(anchor);
328
396
  };
329
397
  }, [target]);
398
+ useLayoutEffect(() => {
399
+ const anchor = target.current;
400
+ if (!anchor) return;
401
+ const written = writeAccent(anchor, accentColor, sampledAccent);
402
+ return () => {
403
+ for (const name of written) anchor.style.removeProperty(`--frak-amb-${name}`);
404
+ };
405
+ }, [
406
+ target,
407
+ accentColor,
408
+ sampledAccent
409
+ ]);
330
410
  }
331
411
  // \0ve-inline:src/components/Ambassador/Ambassador.css.ts.vanilla.js
332
412
  const cssSource$1 = `.Ambassador_panel__awpcg00 {
@@ -559,13 +639,140 @@ const cssSource$1 = `.Ambassador_panel__awpcg00 {
559
639
  display: block;
560
640
  }
561
641
 
562
- .Ambassador_stepsGrid__awpcg0r {
642
+ .Ambassador_myRewards__awpcg0r {
643
+ text-align: center;
644
+ justify-items: center;
645
+ gap: 1em;
646
+ padding: 2em 1.75em;
647
+ display: grid;
648
+ }
649
+
650
+ .Ambassador_myRewardsWithStub__awpcg0s {
651
+ text-align: start;
652
+ flex-wrap: wrap;
653
+ align-items: stretch;
654
+ gap: 0;
655
+ padding: 0;
656
+ display: flex;
657
+ overflow: hidden;
658
+ }
659
+
660
+ .Ambassador_myRewardsMain__awpcg0t {
661
+ flex: 999 24em;
662
+ align-content: center;
663
+ justify-items: start;
664
+ gap: .9em;
665
+ min-width: 0;
666
+ padding: 2.25em 2.5em;
667
+ display: grid;
668
+ }
669
+
670
+ .Ambassador_myRewardsStub__awpcg0u {
671
+ color: #111;
672
+ text-align: center;
673
+ background-color: #fff;
674
+ border-left: 2px dashed #11111138;
675
+ flex: 1 0 auto;
676
+ align-content: center;
677
+ justify-items: center;
678
+ gap: .75em;
679
+ padding: 2em 1.75em;
680
+ display: grid;
681
+ -webkit-mask-image: radial-gradient(.75em at 0 0, #0000 97%, #000 100%), radial-gradient(.75em at 0 100%, #0000 97%, #000 100%);
682
+ mask-image: radial-gradient(.75em at 0 0, #0000 97%, #000 100%), radial-gradient(.75em at 0 100%, #0000 97%, #000 100%);
683
+ -webkit-mask-position: top, bottom;
684
+ mask-position: top, bottom;
685
+ -webkit-mask-size: 100% 51%;
686
+ mask-size: 100% 51%;
687
+ -webkit-mask-repeat: no-repeat;
688
+ mask-repeat: no-repeat;
689
+ }
690
+
691
+ .Ambassador_myRewardsStubHeading__awpcg0v {
692
+ margin: 0;
693
+ font-size: 1.05em;
694
+ font-weight: 700;
695
+ }
696
+
697
+ .Ambassador_myRewardsStubQr__awpcg0w {
698
+ display: block;
699
+ }
700
+
701
+ .Ambassador_myRewardsStubQrPlaceholder__awpcg0x {
702
+ background-color: #f3f4f6;
703
+ width: 200px;
704
+ height: 200px;
705
+ }
706
+
707
+ .Ambassador_myRewardsStubCaption__awpcg0y {
708
+ color: #555;
709
+ max-width: 14em;
710
+ margin: 0;
711
+ font-size: .85em;
712
+ }
713
+
714
+ .Ambassador_myRewardsAmount__awpcg0z {
715
+ margin: 0;
716
+ font-size: clamp(3em, 12vw, 5.5em);
717
+ }
718
+
719
+ .Ambassador_myRewardsBreakdown__awpcg010 {
720
+ gap: .4em;
721
+ width: 100%;
722
+ max-width: 26em;
723
+ margin: 0;
724
+ padding: 0;
725
+ list-style: none;
726
+ display: grid;
727
+ }
728
+
729
+ .Ambassador_myRewardsRow__awpcg011 {
730
+ justify-content: space-between;
731
+ gap: 1em;
732
+ margin: 0;
733
+ display: flex;
734
+ }
735
+
736
+ .Ambassador_myRewardsRowValue__awpcg012 {
737
+ font-weight: 700;
738
+ }
739
+
740
+ .Ambassador_myRewardsCountdown__awpcg013 {
741
+ margin: 0;
742
+ font-weight: 700;
743
+ }
744
+
745
+ .Ambassador_myRewardsActions__awpcg014 {
746
+ flex-wrap: wrap;
747
+ justify-content: center;
748
+ align-items: center;
749
+ gap: 1em 1.5em;
750
+ display: flex;
751
+ }
752
+
753
+ .Ambassador_myRewardsActionsStart__awpcg015 {
754
+ justify-content: flex-start;
755
+ gap: .75em;
756
+ }
757
+
758
+ .Ambassador_myRewardsSecondaryCta__awpcg016 {
759
+ color: var(--frak-amb-accent-text, var(--frak-amb-accent, #111));
760
+ border: 1px solid var(--frak-amb-border, #11111126);
761
+ background-color: #0000;
762
+ }
763
+
764
+ .Ambassador_myRewardsSecondaryCta__awpcg016:hover {
765
+ opacity: 1;
766
+ background-color: var(--frak-amb-surface, #1111110a);
767
+ }
768
+
769
+ .Ambassador_stepsGrid__awpcg017 {
563
770
  grid-template-columns: repeat(auto-fit, minmax(min(15em, 100%), 1fr));
564
771
  gap: 1.25em;
565
772
  display: grid;
566
773
  }
567
774
 
568
- .Ambassador_stepNumber__awpcg0s {
775
+ .Ambassador_stepNumber__awpcg018 {
569
776
  border-radius: var(--frak-amb-cta-radius, 999px);
570
777
  background-color: var(--frak-amb-accent, #111);
571
778
  block-size: 1.9em;
@@ -578,19 +785,19 @@ const cssSource$1 = `.Ambassador_panel__awpcg00 {
578
785
  display: grid;
579
786
  }
580
787
 
581
- .Ambassador_stepIcon__awpcg0t {
788
+ .Ambassador_stepIcon__awpcg019 {
582
789
  object-fit: contain;
583
790
  width: 40px;
584
791
  height: 40px;
585
792
  }
586
793
 
587
- .Ambassador_stepTitle__awpcg0u {
794
+ .Ambassador_stepTitle__awpcg01a {
588
795
  margin: 0;
589
796
  font-size: 1.05em;
590
797
  line-height: 1.3;
591
798
  }
592
799
 
593
- .Ambassador_winWinCards__awpcg0v {
800
+ .Ambassador_winWinCards__awpcg01b {
594
801
  grid-template-columns: repeat(auto-fit, minmax(min(15em, 100%), 1fr));
595
802
  gap: 1.25em;
596
803
  width: 100%;
@@ -598,21 +805,21 @@ const cssSource$1 = `.Ambassador_panel__awpcg00 {
598
805
  display: grid;
599
806
  }
600
807
 
601
- .Ambassador_winWinCard__awpcg0w {
808
+ .Ambassador_winWinCard__awpcg01c {
602
809
  text-align: center;
603
810
  justify-items: center;
604
811
  }
605
812
 
606
- .Ambassador_winWinCardAmount__awpcg0x {
813
+ .Ambassador_winWinCardAmount__awpcg01d {
607
814
  margin: 0;
608
815
  font-size: clamp(2em, 6vw, 3em);
609
816
  }
610
817
 
611
- .Ambassador_referralCta__awpcg0y {
818
+ .Ambassador_referralCta__awpcg01e {
612
819
  justify-self: start;
613
820
  }
614
821
 
615
- .Ambassador_store__awpcg0z {
822
+ .Ambassador_store__awpcg01f {
616
823
  grid-template-columns: repeat(auto-fit, minmax(min(14em, 100%), 1fr));
617
824
  align-items: center;
618
825
  gap: 1.75em;
@@ -620,14 +827,14 @@ const cssSource$1 = `.Ambassador_panel__awpcg00 {
620
827
  display: grid;
621
828
  }
622
829
 
623
- .Ambassador_storeBody__awpcg010 {
830
+ .Ambassador_storeBody__awpcg01g {
624
831
  align-content: start;
625
832
  gap: .75em;
626
833
  min-width: 0;
627
834
  display: grid;
628
835
  }
629
836
 
630
- .Ambassador_storeQr__awpcg011 {
837
+ .Ambassador_storeQr__awpcg01h {
631
838
  text-align: center;
632
839
  justify-items: center;
633
840
  gap: .5em;
@@ -635,14 +842,14 @@ const cssSource$1 = `.Ambassador_panel__awpcg00 {
635
842
  display: grid;
636
843
  }
637
844
 
638
- .Ambassador_storeBadges__awpcg012 {
845
+ .Ambassador_storeBadges__awpcg01i {
639
846
  flex-wrap: wrap;
640
847
  align-items: center;
641
848
  gap: .75em;
642
849
  display: flex;
643
850
  }
644
851
 
645
- .Ambassador_storeBadge__awpcg013 {
852
+ .Ambassador_storeBadge__awpcg01j {
646
853
  border-radius: 8px;
647
854
  align-items: center;
648
855
  line-height: 0;
@@ -653,12 +860,12 @@ const cssSource$1 = `.Ambassador_panel__awpcg00 {
653
860
  background-color: #000 !important;
654
861
  }
655
862
 
656
- .Ambassador_storeBadge__awpcg013:focus-visible {
863
+ .Ambassador_storeBadge__awpcg01j:focus-visible {
657
864
  outline-color: #000;
658
865
  box-shadow: 0 0 0 2px #fff;
659
866
  }
660
867
 
661
- .Ambassador_storeBadgeArt__awpcg014 {
868
+ .Ambassador_storeBadgeArt__awpcg01k {
662
869
  display: block;
663
870
  border: 0 !important;
664
871
  border-radius: 0 !important;
@@ -668,22 +875,22 @@ const cssSource$1 = `.Ambassador_panel__awpcg00 {
668
875
  margin: 0 !important;
669
876
  }
670
877
 
671
- .Ambassador_faqItem__awpcg015 {
878
+ .Ambassador_faqItem__awpcg01l {
672
879
  border-bottom: 1px solid var(--frak-amb-border, #11111126);
673
880
  padding: .9em 0;
674
881
  }
675
882
 
676
- .Ambassador_faqQuestion__awpcg016 {
883
+ .Ambassador_faqQuestion__awpcg01m {
677
884
  cursor: pointer;
678
885
  font-weight: 700;
679
886
  list-style: none;
680
887
  }
681
888
 
682
- .Ambassador_faqQuestion__awpcg016::-webkit-details-marker {
889
+ .Ambassador_faqQuestion__awpcg01m::-webkit-details-marker {
683
890
  display: none;
684
891
  }
685
892
 
686
- .Ambassador_faqQuestion__awpcg016:after {
893
+ .Ambassador_faqQuestion__awpcg01m:after {
687
894
  content: "+";
688
895
  float: right;
689
896
  color: var(--frak-amb-accent-text, var(--frak-amb-accent, #111));
@@ -691,20 +898,20 @@ const cssSource$1 = `.Ambassador_panel__awpcg00 {
691
898
  font-weight: 700;
692
899
  }
693
900
 
694
- .Ambassador_faqItem__awpcg015[open] .Ambassador_faqQuestion__awpcg016:after {
901
+ .Ambassador_faqItem__awpcg01l[open] .Ambassador_faqQuestion__awpcg01m:after {
695
902
  content: "–";
696
903
  }
697
904
 
698
- .Ambassador_faqAnswer__awpcg017 {
905
+ .Ambassador_faqAnswer__awpcg01n {
699
906
  opacity: .75;
700
907
  margin: .6em 0 0;
701
908
  }
702
909
 
703
- .Ambassador_faqAttribution__awpcg018 {
910
+ .Ambassador_faqAttribution__awpcg01o {
704
911
  text-align: center;
705
912
  }
706
913
 
707
- .Ambassador_frakLink__awpcg019 {
914
+ .Ambassador_frakLink__awpcg01p {
708
915
  color: inherit;
709
916
  text-underline-offset: .15em;
710
917
  text-decoration: underline;
@@ -716,7 +923,7 @@ const cssSource$1 = `.Ambassador_panel__awpcg00 {
716
923
  border: 1px solid var(--frak-amb-border, color-mix(in srgb, var(--frak-amb-accent, #111) 15%, transparent));
717
924
  }
718
925
 
719
- .Ambassador_faqItem__awpcg015 {
926
+ .Ambassador_faqItem__awpcg01l {
720
927
  border-bottom: 1px solid var(--frak-amb-border, color-mix(in srgb, var(--frak-amb-accent, #111) 15%, transparent));
721
928
  }
722
929
  }
@@ -725,12 +932,12 @@ const cssSource$1 = `.Ambassador_panel__awpcg00 {
725
932
  var amountUnit = "Ambassador_amountUnit__awpcg0a";
726
933
  var amountWords = "Ambassador_amountWords__awpcg0b";
727
934
  var faq = "Ambassador_region__awpcg03";
728
- var faqAnswer = "Ambassador_faqAnswer__awpcg017";
729
- var faqAttribution = "Ambassador_faqAttribution__awpcg018 Ambassador_mutedSmall__awpcg07";
730
- var faqItem = "Ambassador_faqItem__awpcg015";
731
- var faqQuestion = "Ambassador_faqQuestion__awpcg016";
935
+ var faqAnswer = "Ambassador_faqAnswer__awpcg01n";
936
+ var faqAttribution = "Ambassador_faqAttribution__awpcg01o Ambassador_mutedSmall__awpcg07";
937
+ var faqItem = "Ambassador_faqItem__awpcg01l";
938
+ var faqQuestion = "Ambassador_faqQuestion__awpcg01m";
732
939
  var faqTitle = "Ambassador_regionTitle__awpcg05";
733
- var frakLink = "Ambassador_frakLink__awpcg019";
940
+ var frakLink = "Ambassador_frakLink__awpcg01p";
734
941
  var hero = "Ambassador_hero__awpcg0d Ambassador_region__awpcg03";
735
942
  var heroAmount = "Ambassador_heroAmount__awpcg0l";
736
943
  var heroArt = "Ambassador_heroArt__awpcg0g Ambassador_panel__awpcg00";
@@ -746,8 +953,29 @@ var heroRewardCaption = "Ambassador_heroRewardCaption__awpcg0m";
746
953
  var heroTag = "Ambassador_heroTag__awpcg0j";
747
954
  var heroTagMain = "Ambassador_heroTagMain__awpcg0k";
748
955
  var heroTitle = "Ambassador_heroTitle__awpcg0f";
956
+ var myRewards = "Ambassador_myRewards__awpcg0r Ambassador_panel__awpcg00";
957
+ var myRewardsActions = "Ambassador_myRewardsActions__awpcg014";
958
+ var myRewardsActionsStart = "Ambassador_myRewardsActionsStart__awpcg015";
959
+ var myRewardsAmount = "Ambassador_myRewardsAmount__awpcg0z Ambassador_bigFigure__awpcg0c";
960
+ var myRewardsBreakdown = "Ambassador_myRewardsBreakdown__awpcg010";
961
+ var myRewardsCountdown = "Ambassador_myRewardsCountdown__awpcg013";
962
+ var myRewardsCta = "Ambassador_ctaButton__awpcg02 sharedBaseCss_buttonReset__7cswil0";
963
+ var myRewardsEyebrow = "Ambassador_mutedSmall__awpcg07";
964
+ var myRewardsFooter = "Ambassador_mutedSmall__awpcg07";
965
+ var myRewardsHeading = "Ambassador_regionTitle__awpcg05";
966
+ var myRewardsMain = "Ambassador_myRewardsMain__awpcg0t";
967
+ var myRewardsNote = "Ambassador_mutedSmall__awpcg07";
968
+ var myRewardsRow = "Ambassador_myRewardsRow__awpcg011";
969
+ var myRewardsRowValue = "Ambassador_myRewardsRowValue__awpcg012";
970
+ var myRewardsSecondaryCta = "Ambassador_myRewardsSecondaryCta__awpcg016 Ambassador_ctaButton__awpcg02 sharedBaseCss_buttonReset__7cswil0";
971
+ var myRewardsStub = "Ambassador_myRewardsStub__awpcg0u";
972
+ var myRewardsStubCaption = "Ambassador_myRewardsStubCaption__awpcg0y";
973
+ var myRewardsStubHeading = "Ambassador_myRewardsStubHeading__awpcg0v";
974
+ var myRewardsStubQr = "Ambassador_myRewardsStubQr__awpcg0w";
975
+ var myRewardsStubQrPlaceholder = "Ambassador_myRewardsStubQrPlaceholder__awpcg0x";
976
+ var myRewardsWithStub = "Ambassador_myRewardsWithStub__awpcg0s";
749
977
  var referral = "Ambassador_region__awpcg03";
750
- var referralCta = "Ambassador_referralCta__awpcg0y Ambassador_ctaButton__awpcg02 sharedBaseCss_buttonReset__7cswil0";
978
+ var referralCta = "Ambassador_referralCta__awpcg01e Ambassador_ctaButton__awpcg02 sharedBaseCss_buttonReset__7cswil0";
751
979
  var referralLede = "Ambassador_lede__awpcg06";
752
980
  var referralTitle = "Ambassador_regionTitle__awpcg05";
753
981
  var reward = "Ambassador_centeredRegion__awpcg04 Ambassador_region__awpcg03";
@@ -762,97 +990,274 @@ var rewardLede = "Ambassador_lede__awpcg06";
762
990
  var root = "Ambassador_root__awpcg01";
763
991
  var step = "Ambassador_card__awpcg09 Ambassador_panel__awpcg00";
764
992
  var stepDescription = "Ambassador_muted__awpcg08";
765
- var stepIcon = "Ambassador_stepIcon__awpcg0t";
766
- var stepNumber = "Ambassador_stepNumber__awpcg0s";
767
- var stepTitle = "Ambassador_stepTitle__awpcg0u";
993
+ var stepIcon = "Ambassador_stepIcon__awpcg019";
994
+ var stepNumber = "Ambassador_stepNumber__awpcg018";
995
+ var stepTitle = "Ambassador_stepTitle__awpcg01a";
768
996
  var steps = "Ambassador_region__awpcg03";
769
- var stepsGrid = "Ambassador_stepsGrid__awpcg0r";
997
+ var stepsGrid = "Ambassador_stepsGrid__awpcg017";
770
998
  var stepsLede = "Ambassador_lede__awpcg06";
771
999
  var stepsTitle = "Ambassador_regionTitle__awpcg05";
772
- var store = "Ambassador_store__awpcg0z Ambassador_panel__awpcg00";
773
- var storeBadge = "Ambassador_storeBadge__awpcg013 sharedBaseCss_buttonReset__7cswil0";
774
- var storeBadgeArt = "Ambassador_storeBadgeArt__awpcg014";
775
- var storeBadges = "Ambassador_storeBadges__awpcg012";
776
- var storeBody = "Ambassador_storeBody__awpcg010";
1000
+ var store = "Ambassador_store__awpcg01f Ambassador_panel__awpcg00";
1001
+ var storeBadge = "Ambassador_storeBadge__awpcg01j sharedBaseCss_buttonReset__7cswil0";
1002
+ var storeBadgeArt = "Ambassador_storeBadgeArt__awpcg01k";
1003
+ var storeBadges = "Ambassador_storeBadges__awpcg01i";
1004
+ var storeBody = "Ambassador_storeBody__awpcg01g";
777
1005
  var storeLede = "Ambassador_lede__awpcg06";
778
- var storeQr = "Ambassador_storeQr__awpcg011";
1006
+ var storeQr = "Ambassador_storeQr__awpcg01h";
779
1007
  var storeQrCaption = "Ambassador_mutedSmall__awpcg07";
780
1008
  var storeTitle = "Ambassador_regionTitle__awpcg05";
781
1009
  var winWin = "Ambassador_centeredRegion__awpcg04 Ambassador_region__awpcg03";
782
- var winWinCard = "Ambassador_winWinCard__awpcg0w Ambassador_card__awpcg09 Ambassador_panel__awpcg00";
783
- var winWinCardAmount = "Ambassador_winWinCardAmount__awpcg0x Ambassador_bigFigure__awpcg0c";
1010
+ var winWinCard = "Ambassador_winWinCard__awpcg01c Ambassador_card__awpcg09 Ambassador_panel__awpcg00";
1011
+ var winWinCardAmount = "Ambassador_winWinCardAmount__awpcg01d Ambassador_bigFigure__awpcg0c";
784
1012
  var winWinCardDescription = "Ambassador_muted__awpcg08";
785
1013
  var winWinCardLabel = "Ambassador_mutedSmall__awpcg07";
786
- var winWinCards = "Ambassador_winWinCards__awpcg0v";
1014
+ var winWinCards = "Ambassador_winWinCards__awpcg01b";
787
1015
  var winWinLede = "Ambassador_lede__awpcg06";
788
1016
  var winWinTitle = "Ambassador_regionTitle__awpcg05";
789
1017
  const cssSource = cssSource$1;
790
- // src/components/Ambassador/InstallQr.tsx
791
- const WIDE_QUERY = "(min-width: 768px)";
792
- const QUIET_ZONE = 4;
793
- const ECC = "low";
794
- const QR_SIZE = 200;
795
- function InstallQr({ url, label, caption, class: className, captionClass }) {
796
- const [query] = useState(readWideQuery);
797
- const [wide, setWide] = useState(() => query?.matches ?? false);
798
- const [grid, setGrid] = useState(null);
799
- useEffect(() => {
800
- if (!query) return;
801
- const onChange = (event) => setWide(event.matches);
802
- query.addEventListener("change", onChange);
803
- return () => query.removeEventListener("change", onChange);
804
- }, [query]);
1018
+ // src/components/Ambassador/Figure.tsx
1019
+ const FIGURE = /^(\D*?)(\d[\d\s.,\u00A0\u202F]*?)(\D*)$/;
1020
+ /** Draws the currency of a formatted amount smaller; wording without a figure passes through. */
1021
+ function Figure({ amount }) {
1022
+ const parts = FIGURE.exec(amount);
1023
+ if (!parts) return /* @__PURE__ */ jsx("span", {
1024
+ class: `${amountWords} frak-ambassador__amount-words`,
1025
+ children: amount
1026
+ });
1027
+ const [, before, figure, after] = parts;
1028
+ const unit = (text) => text ? /* @__PURE__ */ jsx("small", {
1029
+ class: `${amountUnit} frak-ambassador__amount-unit`,
1030
+ children: text
1031
+ }) : null;
1032
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1033
+ unit(before),
1034
+ figure,
1035
+ unit(after)
1036
+ ] });
1037
+ }
1038
+ // src/components/Ambassador/MyRewards.tsx
1039
+ /** Unlinked visitors with something waiting claim it; linked ones see what this merchant paid or owes. */
1040
+ function resolveMyRewardsView(summary) {
1041
+ if (!summary) return null;
1042
+ if (isClaimable(summary)) return "claim";
1043
+ if (!summary.linked) return null;
1044
+ const hasEarned = !!summary.earned && pickFiat(summary.earned.total, resolveRewardCurrency()) > 0;
1045
+ const hasPending = !!summary.pending && summary.pending.count > 0;
1046
+ return hasEarned || hasPending ? "earned" : null;
1047
+ }
1048
+ function formatDate(iso, lang) {
1049
+ if (!iso || Number.isNaN(Date.parse(iso))) return void 0;
1050
+ return formatRewardDate(new Date(iso), lang);
1051
+ }
1052
+ function countdownText(copy, countdown, lang) {
1053
+ if (!countdown) return void 0;
1054
+ let template = copy.myRewardsCountdown;
1055
+ if (countdown.days === 0) template = copy.myRewardsCountdownToday;
1056
+ else if (countdown.days === 1) template = copy.myRewardsCountdownOneDay;
1057
+ return fillReminderText(template, {
1058
+ days: countdown.days,
1059
+ date: formatRewardDate(countdown.date, lang)
1060
+ });
1061
+ }
1062
+ function ClaimStub({ copy, grid, qrLabel }) {
1063
+ return /* @__PURE__ */ jsxs("div", {
1064
+ class: `${myRewardsStub} frak-ambassador__my-rewards-stub`,
1065
+ children: [
1066
+ /* @__PURE__ */ jsx("p", {
1067
+ class: myRewardsStubHeading,
1068
+ children: copy.myRewardsQrHeading
1069
+ }),
1070
+ grid ? /* @__PURE__ */ jsx(QrSvg, {
1071
+ grid,
1072
+ label: qrLabel,
1073
+ class: myRewardsStubQr
1074
+ }) : /* @__PURE__ */ jsx("span", {
1075
+ class: myRewardsStubQrPlaceholder,
1076
+ "aria-hidden": "true"
1077
+ }),
1078
+ /* @__PURE__ */ jsx("p", {
1079
+ class: myRewardsStubCaption,
1080
+ children: copy.myRewardsQrCaption
1081
+ })
1082
+ ]
1083
+ });
1084
+ }
1085
+ function ClaimRewards({ summary, lang, brand, overrides, installUrl, isClientReady, onShare, footer, qrLabel, isDesktop }) {
1086
+ const { wide, grid } = useInstallQr(isDesktop ? installUrl : void 0);
1087
+ const withStub = isDesktop && wide;
1088
+ const { pending } = summary;
1089
+ const copy = componentDefaults[lang].ambassador;
1090
+ const currency = resolveRewardCurrency();
1091
+ const total = formatFiat(pending.total, currency);
1092
+ const countdown = getRewardCountdown(pending.expiresAt);
1093
+ const locked = pending.lockedCount > 0;
1094
+ const unlockDate = locked ? formatDate(pending.nextUnlockAt, lang) : void 0;
1095
+ const reminder = {
1096
+ surface: "ambassador",
1097
+ days_left: countdown?.days,
1098
+ locked
1099
+ };
1100
+ const allLocked = pending.lockedCount >= pending.count;
1101
+ const impressionTracked = useRef(false);
1102
+ const eyebrowId = useId();
1103
+ const inert = installUrl === void 0;
1104
+ useInlineReminderRegistration(true);
805
1105
  useEffect(() => {
806
- if (!wide || !url) return;
807
- let cancelled = false;
808
- import("qr").then(({ encodeQR }) => {
809
- if (cancelled) return;
810
- setGrid(encodeQR(url, "raw", {
811
- border: QUIET_ZONE,
812
- ecc: ECC
813
- }));
814
- }).catch(() => {});
815
- return () => {
816
- cancelled = true;
817
- };
818
- }, [wide, url]);
819
- if (!wide || !url || !grid) return null;
820
- const edge = grid.length;
821
- return /* @__PURE__ */ jsxs("figure", {
822
- class: className,
823
- children: [/* @__PURE__ */ jsxs("svg", {
824
- width: QR_SIZE,
825
- height: QR_SIZE,
826
- viewBox: `0 0 ${edge} ${edge}`,
827
- xmlns: "http://www.w3.org/2000/svg",
828
- role: "img",
829
- "aria-label": label,
830
- focusable: "false",
831
- children: [/* @__PURE__ */ jsx("rect", {
832
- width: edge,
833
- height: edge,
834
- fill: "#fff"
835
- }), /* @__PURE__ */ jsx("path", {
836
- d: modulesPath(grid),
837
- fill: "#000"
1106
+ if (impressionTracked.current) return;
1107
+ impressionTracked.current = true;
1108
+ trackEvent(window.FrakSetup?.client, "reward_reminder_impression", reminder);
1109
+ }, [reminder]);
1110
+ const rows = [[copy.myRewardsCashbackLabel, pending.cashback], [copy.myRewardsFriendsLabel, pending.fromFriends]];
1111
+ const countdownLine = countdownText(copy, countdown, lang);
1112
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
1113
+ /* @__PURE__ */ jsx("p", {
1114
+ id: eyebrowId,
1115
+ class: `${myRewardsEyebrow} frak-ambassador__my-rewards-eyebrow`,
1116
+ children: overrides.myRewardsEyebrow ?? copy.myRewardsEyebrow
1117
+ }),
1118
+ /* @__PURE__ */ jsx("p", {
1119
+ class: `${myRewardsAmount} frak-ambassador__my-rewards-amount`,
1120
+ children: /* @__PURE__ */ jsx(Figure, { amount: total })
1121
+ }),
1122
+ /* @__PURE__ */ jsx("div", {
1123
+ class: `${myRewardsBreakdown} frak-ambassador__my-rewards-breakdown`,
1124
+ children: rows.filter(([, amounts]) => pickFiat(amounts, currency) > 0).map(([label, amounts]) => /* @__PURE__ */ jsxs("p", {
1125
+ class: `${myRewardsRow} frak-ambassador__my-rewards-row`,
1126
+ children: [/* @__PURE__ */ jsx("span", { children: label }), /* @__PURE__ */ jsx("span", {
1127
+ class: myRewardsRowValue,
1128
+ children: formatFiat(amounts, currency)
1129
+ })]
1130
+ }, label))
1131
+ }),
1132
+ countdownLine ? /* @__PURE__ */ jsx("p", {
1133
+ class: `${myRewardsCountdown} frak-ambassador__my-rewards-countdown`,
1134
+ children: countdownLine
1135
+ }) : null,
1136
+ unlockDate ? /* @__PURE__ */ jsx("p", {
1137
+ class: `${myRewardsNote} frak-ambassador__my-rewards-unlock`,
1138
+ children: fillReminderText(allLocked ? copy.myRewardsUnlockNoteAll : copy.myRewardsUnlockNote, { date: unlockDate })
1139
+ }) : null,
1140
+ /* @__PURE__ */ jsxs("div", {
1141
+ class: `${myRewardsActions}${withStub ? ` ${myRewardsActionsStart}` : ""} frak-ambassador__my-rewards-actions`,
1142
+ children: [/* @__PURE__ */ jsx("a", {
1143
+ class: `${myRewardsCta} frak-ambassador__my-rewards-cta`,
1144
+ href: installUrl,
1145
+ role: inert ? "link" : void 0,
1146
+ tabIndex: inert ? 0 : void 0,
1147
+ "aria-disabled": inert ? "true" : void 0,
1148
+ onClick: (event) => {
1149
+ if (inert) {
1150
+ event.preventDefault();
1151
+ return;
1152
+ }
1153
+ markClaimStarted();
1154
+ trackEvent(window.FrakSetup?.client, "reward_reminder_claim_clicked", reminder);
1155
+ },
1156
+ children: fillReminderText(overrides.myRewardsClaimCtaLabel ?? copy.myRewardsClaimCta, {
1157
+ reward: total,
1158
+ brand
1159
+ })
1160
+ }), /* @__PURE__ */ jsx("button", {
1161
+ type: "button",
1162
+ class: `${myRewardsSecondaryCta} frak-ambassador__my-rewards-share`,
1163
+ disabled: !isClientReady,
1164
+ onClick: onShare,
1165
+ children: fillReminderText(overrides.myRewardsShareCtaLabel ?? copy.myRewardsShareCta, { brand })
838
1166
  })]
839
- }), /* @__PURE__ */ jsx("figcaption", {
840
- class: captionClass,
841
- children: caption
842
- })]
1167
+ }),
1168
+ /* @__PURE__ */ jsx("p", {
1169
+ class: `${myRewardsFooter} frak-ambassador__my-rewards-footer`,
1170
+ children: footer
1171
+ })
1172
+ ] });
1173
+ return /* @__PURE__ */ jsx("section", {
1174
+ "aria-labelledby": eyebrowId,
1175
+ class: `${myRewards}${withStub ? ` ${myRewardsWithStub}` : ""} frak-ambassador__my-rewards frak-ambassador__my-rewards--claim`,
1176
+ children: withStub ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
1177
+ class: `${myRewardsMain} frak-ambassador__my-rewards-main`,
1178
+ children: content
1179
+ }), /* @__PURE__ */ jsx(ClaimStub, {
1180
+ copy,
1181
+ grid,
1182
+ qrLabel
1183
+ })] }) : content
843
1184
  });
844
1185
  }
845
- function readWideQuery() {
846
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") return null;
847
- return window.matchMedia(WIDE_QUERY);
1186
+ function EarnedRewards({ summary, lang, brand, overrides, isClientReady, onShare }) {
1187
+ const copy = componentDefaults[lang].ambassador;
1188
+ const currency = resolveRewardCurrency();
1189
+ const { earned, pending } = summary;
1190
+ const receivedTotal = earned && pickFiat(earned.total, currency) > 0 ? formatFiat(earned.total, currency) : void 0;
1191
+ const unlockDate = pending && pending.lockedCount > 0 ? formatDate(pending.nextUnlockAt, lang) : void 0;
1192
+ const pendingTemplate = unlockDate ? copy.myRewardsOnItsWayUnlock : copy.myRewardsOnItsWay;
1193
+ return /* @__PURE__ */ jsxs("section", {
1194
+ class: `${myRewards} frak-ambassador__my-rewards frak-ambassador__my-rewards--earned`,
1195
+ children: [
1196
+ /* @__PURE__ */ jsx("h2", {
1197
+ class: `${myRewardsHeading} frak-ambassador__my-rewards-heading`,
1198
+ children: fillReminderText(overrides.myRewardsLinkedHeading ?? copy.myRewardsLinkedHeading, { brand })
1199
+ }),
1200
+ /* @__PURE__ */ jsxs("div", {
1201
+ class: `${myRewardsBreakdown} frak-ambassador__my-rewards-breakdown`,
1202
+ children: [receivedTotal ? /* @__PURE__ */ jsx("p", {
1203
+ class: `${myRewardsCountdown} frak-ambassador__my-rewards-earned`,
1204
+ children: fillReminderText(copy.myRewardsReceived, { reward: receivedTotal })
1205
+ }) : null, pending && pending.count > 0 ? /* @__PURE__ */ jsx("p", {
1206
+ class: `${myRewardsCountdown} frak-ambassador__my-rewards-pending`,
1207
+ children: fillReminderText(pendingTemplate, {
1208
+ reward: formatFiat(pending.total, currency),
1209
+ date: unlockDate
1210
+ })
1211
+ }) : null]
1212
+ }),
1213
+ /* @__PURE__ */ jsxs("div", {
1214
+ class: `${myRewardsActions} frak-ambassador__my-rewards-actions`,
1215
+ children: [/* @__PURE__ */ jsx("a", {
1216
+ class: `${myRewardsCta} frak-ambassador__my-rewards-cta`,
1217
+ href: `${getEnvironment().wallet}/wallet`,
1218
+ target: "_blank",
1219
+ rel: "noopener",
1220
+ children: fillReminderText(overrides.myRewardsWalletCtaLabel ?? copy.myRewardsWalletCta, { brand })
1221
+ }), /* @__PURE__ */ jsx("button", {
1222
+ type: "button",
1223
+ class: `${myRewardsSecondaryCta} frak-ambassador__my-rewards-share`,
1224
+ disabled: !isClientReady,
1225
+ onClick: onShare,
1226
+ children: fillReminderText(overrides.myRewardsShareAgainCtaLabel ?? copy.myRewardsShareAgainCta, { brand })
1227
+ })]
1228
+ })
1229
+ ]
1230
+ });
848
1231
  }
849
- function modulesPath(grid) {
850
- let path = "";
851
- for (let row = 0; row < grid.length; row++) {
852
- const cells = grid[row];
853
- for (let col = 0; col < cells.length; col++) if (cells[col]) path += `M${col},${row}h1v1h-1z`;
854
- }
855
- return path;
1232
+ /** The page's reward summary, plus the formatted pending total while it can be claimed. */
1233
+ function useMyRewards(isClientReady) {
1234
+ const { summary } = useRewardSummary(isClientReady);
1235
+ return {
1236
+ summary,
1237
+ claimReward: isClaimable(summary) ? formatFiat(summary.pending.total, resolveRewardCurrency()) : void 0
1238
+ };
1239
+ }
1240
+ /** While a reward waits, the store block sells the claim unless the merchant wrote its own heading. */
1241
+ function claimStoreHeading(defaults, override, claimReward, brand) {
1242
+ if (!claimReward || override !== void 0) return void 0;
1243
+ return fillReminderText(defaults.storeHeadingClaim, {
1244
+ reward: claimReward,
1245
+ brand
1246
+ });
1247
+ }
1248
+ /** The claim prompt sits above the hero, the linked recap below it. */
1249
+ function MyRewardsSlot({ placement, summary, ...props }) {
1250
+ const view = resolveMyRewardsView(summary);
1251
+ if (placement === "above" && view === "claim" && isClaimable(summary)) return /* @__PURE__ */ jsx(ClaimRewards, {
1252
+ ...props,
1253
+ summary,
1254
+ isDesktop: !isMobile()
1255
+ });
1256
+ if (placement === "below" && view === "earned" && summary) return /* @__PURE__ */ jsx(EarnedRewards, {
1257
+ ...props,
1258
+ summary
1259
+ });
1260
+ return null;
856
1261
  }
857
1262
  // src/components/Ambassador/storeBadges.tsx
858
1263
  function AppStoreBadgeArtFr(props) {
@@ -1109,6 +1514,58 @@ function PlayStoreBadgeArt({ lang, ...props }) {
1109
1514
  ...props
1110
1515
  });
1111
1516
  }
1517
+ // src/components/Ambassador/Store.tsx
1518
+ function StoreSection({ lang, installUrl, heading, lede, appBadgeAriaLabel, playBadgeAriaLabel, qrLabel, qrCaption }) {
1519
+ const inert = installUrl === void 0;
1520
+ return /* @__PURE__ */ jsxs("section", {
1521
+ class: `${store} frak-ambassador__store`,
1522
+ children: [/* @__PURE__ */ jsxs("div", {
1523
+ class: `${storeBody} frak-ambassador__store-body`,
1524
+ children: [
1525
+ /* @__PURE__ */ jsx("h2", {
1526
+ class: `${storeTitle} frak-ambassador__store-title`,
1527
+ children: heading
1528
+ }),
1529
+ /* @__PURE__ */ jsx("p", {
1530
+ class: `${storeLede} frak-ambassador__store-lede`,
1531
+ children: lede
1532
+ }),
1533
+ /* @__PURE__ */ jsxs("div", {
1534
+ class: `${storeBadges} frak-ambassador__store-badges`,
1535
+ children: [/* @__PURE__ */ jsx("a", {
1536
+ class: `${storeBadge} frak-ambassador__store-badge frak-ambassador__store-badge--app`,
1537
+ "aria-label": appBadgeAriaLabel,
1538
+ href: installUrl,
1539
+ role: inert ? "link" : void 0,
1540
+ tabIndex: inert ? 0 : void 0,
1541
+ "aria-disabled": inert ? "true" : void 0,
1542
+ children: /* @__PURE__ */ jsx(AppStoreBadgeArt, {
1543
+ lang,
1544
+ class: `${storeBadgeArt} frak-ambassador__store-badge-art`
1545
+ })
1546
+ }), /* @__PURE__ */ jsx("a", {
1547
+ class: `${storeBadge} frak-ambassador__store-badge frak-ambassador__store-badge--play`,
1548
+ "aria-label": playBadgeAriaLabel,
1549
+ href: installUrl,
1550
+ role: inert ? "link" : void 0,
1551
+ tabIndex: inert ? 0 : void 0,
1552
+ "aria-disabled": inert ? "true" : void 0,
1553
+ children: /* @__PURE__ */ jsx(PlayStoreBadgeArt, {
1554
+ lang,
1555
+ class: `${storeBadgeArt} frak-ambassador__store-badge-art`
1556
+ })
1557
+ })]
1558
+ })
1559
+ ]
1560
+ }), /* @__PURE__ */ jsx(InstallQr, {
1561
+ url: installUrl,
1562
+ label: qrLabel,
1563
+ caption: qrCaption,
1564
+ class: `${storeQr} frak-ambassador__store-qr`,
1565
+ captionClass: `${storeQrCaption} frak-ambassador__store-qr-caption`
1566
+ })]
1567
+ });
1568
+ }
1112
1569
  // src/components/Ambassador/Ambassador.tsx
1113
1570
  const FRAK_URL = "https://frak.id";
1114
1571
  /**
@@ -1119,25 +1576,6 @@ const FRAK_URL = "https://frak.id";
1119
1576
  function resolveBrandName() {
1120
1577
  return window.FrakSetup?.config?.metadata?.name || document.querySelector("meta[property=\"og:site_name\"]")?.getAttribute("content") || window.location.hostname.replace(/^www\./, "");
1121
1578
  }
1122
- const FIGURE = /^(\D*?)(\d[\d\s.,\u00A0\u202F]*?)(\D*)$/;
1123
- /** Draws the currency of a formatted amount smaller; wording without a figure passes through. */
1124
- function Figure({ amount }) {
1125
- const parts = FIGURE.exec(amount);
1126
- if (!parts) return /* @__PURE__ */ jsx("span", {
1127
- class: `${amountWords} frak-ambassador__amount-words`,
1128
- children: amount
1129
- });
1130
- const [, before, figure, after] = parts;
1131
- const unit = (text) => text ? /* @__PURE__ */ jsx("small", {
1132
- class: `${amountUnit} frak-ambassador__amount-unit`,
1133
- children: text
1134
- }) : null;
1135
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1136
- unit(before),
1137
- figure,
1138
- unit(after)
1139
- ] });
1140
- }
1141
1579
  function headingText(text) {
1142
1580
  return text ? /* @__PURE__ */ jsx("span", {
1143
1581
  class: `${rewardHeadingText} frak-ambassador__reward-heading-text`,
@@ -1225,19 +1663,29 @@ function Ambassador(props) {
1225
1663
  const dashboard = useGlobalComponents()?.ambassador;
1226
1664
  const merged = {
1227
1665
  ...props,
1228
- faq5Answer: dashboard?.faq5Answer
1666
+ faq5Answer: dashboard?.faq5Answer,
1667
+ accentColor: dashboard?.accentColor
1229
1668
  };
1230
1669
  for (const field of DASHBOARD_FIELDS) merged[field] = props[field] ?? dashboard?.[field];
1231
1670
  return /* @__PURE__ */ jsx(AmbassadorPage, { ...merged });
1232
1671
  }
1233
- function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle: propHeroTitle, heroEyebrow: propHeroEyebrow, heroLede: propHeroLede, heroCtaLabel: propHeroCtaLabel, heroFacesCaption: propHeroFacesCaption, heroImageUrl, heroImageAlt: propHeroImageAlt, heroRewardCaption: propHeroRewardCaption, heroRewardRefereePill: propHeroRewardRefereePill, rewardEyebrow: propRewardEyebrow, rewardHeading: propRewardHeading, rewardEstimateCaption: propRewardEstimateCaption, rewardLede: propRewardLede, rewardCtaLabel: propRewardCtaLabel, rewardFooterCaption: propRewardFooterCaption, rewardNoBankDetails: propRewardNoBankDetails, rewardFallbackLabel: propRewardFallbackLabel, explainerTitle: propExplainerTitle, explainerLede: propExplainerLede, step1Title: propStep1Title, step1Description: propStep1Description, step1ImageUrl, step1ImageAlt: propStep1ImageAlt, step2Title: propStep2Title, step2Description: propStep2Description, step2ImageUrl, step2ImageAlt: propStep2ImageAlt, step3Title: propStep3Title, step3Description: propStep3Description, step3ImageUrl, step3ImageAlt: propStep3ImageAlt, winWinHeading: propWinWinHeading, winWinLede: propWinWinLede, winWinCard1Title: propWinWinCard1Title, winWinCard1Description: propWinWinCard1Description, winWinCard2Title: propWinWinCard2Title, winWinCard2Description: propWinWinCard2Description, referralHeading: propReferralHeading, referralLede: propReferralLede, referralCtaLabel: propReferralCtaLabel, storeHeading: propStoreHeading, storeLede: propStoreLede, storeAppBadgeAriaLabel: propStoreAppBadgeAriaLabel, storePlayBadgeAriaLabel: propStorePlayBadgeAriaLabel, storeQrLabel: propStoreQrLabel, storeQrCaption: propStoreQrCaption, faqHeading: propFaqHeading, faq1Question: propFaq1Question, faq1Answer: propFaq1Answer, faq2Question: propFaq2Question, faq2Answer: propFaq2Answer, faq3Question: propFaq3Question, faq3Answer: propFaq3Answer, faq4Question: propFaq4Question, faq4Answer: propFaq4Answer, faq5Question: propFaq5Question, faq5AnswerBeforeLink: propFaq5AnswerBeforeLink, faq5AnswerLinkText: propFaq5AnswerLinkText, faq5AnswerAfterLink: propFaq5AnswerAfterLink, attributionBeforeLink: propAttributionBeforeLink, attributionLinkText: propAttributionLinkText, faq5Answer: dashboardFaq5Answer }) {
1672
+ function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle: propHeroTitle, heroEyebrow: propHeroEyebrow, heroLede: propHeroLede, heroCtaLabel: propHeroCtaLabel, heroFacesCaption: propHeroFacesCaption, heroImageUrl, heroImageAlt: propHeroImageAlt, heroRewardCaption: propHeroRewardCaption, heroRewardRefereePill: propHeroRewardRefereePill, rewardEyebrow: propRewardEyebrow, rewardHeading: propRewardHeading, rewardEstimateCaption: propRewardEstimateCaption, rewardLede: propRewardLede, rewardCtaLabel: propRewardCtaLabel, rewardFooterCaption: propRewardFooterCaption, rewardNoBankDetails: propRewardNoBankDetails, rewardFallbackLabel: propRewardFallbackLabel, explainerTitle: propExplainerTitle, explainerLede: propExplainerLede, step1Title: propStep1Title, step1Description: propStep1Description, step1ImageUrl, step1ImageAlt: propStep1ImageAlt, step2Title: propStep2Title, step2Description: propStep2Description, step2ImageUrl, step2ImageAlt: propStep2ImageAlt, step3Title: propStep3Title, step3Description: propStep3Description, step3ImageUrl, step3ImageAlt: propStep3ImageAlt, winWinHeading: propWinWinHeading, winWinLede: propWinWinLede, winWinCard1Title: propWinWinCard1Title, winWinCard1Description: propWinWinCard1Description, winWinCard2Title: propWinWinCard2Title, winWinCard2Description: propWinWinCard2Description, referralHeading: propReferralHeading, referralLede: propReferralLede, referralCtaLabel: propReferralCtaLabel, storeHeading: propStoreHeading, storeLede: propStoreLede, storeAppBadgeAriaLabel: propStoreAppBadgeAriaLabel, storePlayBadgeAriaLabel: propStorePlayBadgeAriaLabel, storeQrLabel: propStoreQrLabel, storeQrCaption: propStoreQrCaption, faqHeading: propFaqHeading, faq1Question: propFaq1Question, faq1Answer: propFaq1Answer, faq2Question: propFaq2Question, faq2Answer: propFaq2Answer, faq3Question: propFaq3Question, faq3Answer: propFaq3Answer, faq4Question: propFaq4Question, faq4Answer: propFaq4Answer, faq5Question: propFaq5Question, faq5AnswerBeforeLink: propFaq5AnswerBeforeLink, faq5AnswerLinkText: propFaq5AnswerLinkText, faq5AnswerAfterLink: propFaq5AnswerAfterLink, attributionBeforeLink: propAttributionBeforeLink, attributionLinkText: propAttributionLinkText, myRewardsEyebrow, myRewardsLinkedHeading, myRewardsClaimCtaLabel, myRewardsShareCtaLabel, myRewardsWalletCtaLabel, myRewardsShareAgainCtaLabel, faq5Answer: dashboardFaq5Answer, accentColor }) {
1234
1673
  const { shouldRender, isHidden, isClientReady } = useClientReady();
1235
1674
  const lang = useLang();
1236
1675
  const rootRef = useRef(null);
1237
- useHostTheme(rootRef);
1676
+ useHostTheme(rootRef, isHidden ? void 0 : accentColor);
1238
1677
  useLightDomStyles("frak-ambassador", void 0, void 0, cssSource, cssSource$2);
1239
1678
  const { reward: reward$1 } = useReward(isClientReady, void 0, "referrer");
1240
1679
  const { reward: refereeReward, hasReward: hasRefereeReward } = useReward(isClientReady, void 0, "referee");
1680
+ const { summary, claimReward } = useMyRewards(isClientReady);
1681
+ const myRewardsOverrides = {
1682
+ myRewardsEyebrow,
1683
+ myRewardsLinkedHeading,
1684
+ myRewardsClaimCtaLabel,
1685
+ myRewardsShareCtaLabel,
1686
+ myRewardsWalletCtaLabel,
1687
+ myRewardsShareAgainCtaLabel
1688
+ };
1241
1689
  const [installUrl, setInstallUrl] = useState(void 0);
1242
1690
  const [failedHeroUrl, setFailedHeroUrl] = useState();
1243
1691
  useEffect(() => {
@@ -1265,7 +1713,6 @@ function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle:
1265
1713
  openSharingPage("ambassador");
1266
1714
  }, [isClientReady]);
1267
1715
  const brand = resolveBrandName();
1268
- const inert = installUrl === void 0;
1269
1716
  const texts = useMemo(() => {
1270
1717
  const defaults = componentDefaults[lang].ambassador;
1271
1718
  const brandize = (text) => text.replaceAll("{BRAND}", () => brand);
@@ -1349,7 +1796,7 @@ function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle:
1349
1796
  referralHeading: resolve(propReferralHeading, defaults.referralHeading),
1350
1797
  referralLede: resolve(propReferralLede, defaults.referralLede),
1351
1798
  referralCtaLabel: resolve(propReferralCtaLabel, defaults.referralCtaLabel),
1352
- storeHeading: resolve(propStoreHeading, defaults.storeHeading),
1799
+ storeHeading: claimStoreHeading(defaults, propStoreHeading, claimReward, brand) ?? resolve(propStoreHeading, defaults.storeHeading),
1353
1800
  storeLede: resolve(propStoreLede, defaults.storeLede),
1354
1801
  storeAppBadgeAriaLabel: resolve(propStoreAppBadgeAriaLabel, defaults.storeAppBadgeAriaLabel),
1355
1802
  storePlayBadgeAriaLabel: resolve(propStorePlayBadgeAriaLabel, defaults.storePlayBadgeAriaLabel),
@@ -1375,6 +1822,7 @@ function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle:
1375
1822
  refereeReward,
1376
1823
  hasRefereeReward,
1377
1824
  brand,
1825
+ claimReward,
1378
1826
  propHeroTitle,
1379
1827
  propHeroEyebrow,
1380
1828
  propHeroLede,
@@ -1444,11 +1892,26 @@ function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle:
1444
1892
  "frak-ambassador",
1445
1893
  classname
1446
1894
  ].filter(Boolean).join(" ");
1895
+ const myRewardsProps = {
1896
+ summary,
1897
+ lang,
1898
+ brand,
1899
+ overrides: myRewardsOverrides,
1900
+ isClientReady,
1901
+ onShare: handleShare,
1902
+ installUrl,
1903
+ footer: texts.rewardFooterCaption,
1904
+ qrLabel: texts.storeQrLabel
1905
+ };
1447
1906
  return /* @__PURE__ */ jsxs("div", {
1448
1907
  ref: rootRef,
1449
1908
  class: rootClass,
1450
1909
  lang,
1451
1910
  children: [
1911
+ /* @__PURE__ */ jsx(MyRewardsSlot, {
1912
+ placement: "above",
1913
+ ...myRewardsProps
1914
+ }),
1452
1915
  /* @__PURE__ */ jsxs("section", {
1453
1916
  class: `${hero} frak-ambassador__hero`,
1454
1917
  children: [/* @__PURE__ */ jsxs("div", {
@@ -1507,6 +1970,10 @@ function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle:
1507
1970
  })]
1508
1971
  })]
1509
1972
  }),
1973
+ /* @__PURE__ */ jsx(MyRewardsSlot, {
1974
+ placement: "below",
1975
+ ...myRewardsProps
1976
+ }),
1510
1977
  /* @__PURE__ */ jsxs("section", {
1511
1978
  class: `${reward} frak-ambassador__reward`,
1512
1979
  children: [
@@ -1637,53 +2104,15 @@ function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle:
1637
2104
  })
1638
2105
  ]
1639
2106
  }),
1640
- /* @__PURE__ */ jsxs("section", {
1641
- class: `${store} frak-ambassador__store`,
1642
- children: [/* @__PURE__ */ jsxs("div", {
1643
- class: `${storeBody} frak-ambassador__store-body`,
1644
- children: [
1645
- /* @__PURE__ */ jsx("h2", {
1646
- class: `${storeTitle} frak-ambassador__store-title`,
1647
- children: texts.storeHeading
1648
- }),
1649
- /* @__PURE__ */ jsx("p", {
1650
- class: `${storeLede} frak-ambassador__store-lede`,
1651
- children: texts.storeLede
1652
- }),
1653
- /* @__PURE__ */ jsxs("div", {
1654
- class: `${storeBadges} frak-ambassador__store-badges`,
1655
- children: [/* @__PURE__ */ jsx("a", {
1656
- class: `${storeBadge} frak-ambassador__store-badge frak-ambassador__store-badge--app`,
1657
- "aria-label": texts.storeAppBadgeAriaLabel,
1658
- href: installUrl,
1659
- role: inert ? "link" : void 0,
1660
- tabIndex: inert ? 0 : void 0,
1661
- "aria-disabled": inert ? "true" : void 0,
1662
- children: /* @__PURE__ */ jsx(AppStoreBadgeArt, {
1663
- lang,
1664
- class: `${storeBadgeArt} frak-ambassador__store-badge-art`
1665
- })
1666
- }), /* @__PURE__ */ jsx("a", {
1667
- class: `${storeBadge} frak-ambassador__store-badge frak-ambassador__store-badge--play`,
1668
- "aria-label": texts.storePlayBadgeAriaLabel,
1669
- href: installUrl,
1670
- role: inert ? "link" : void 0,
1671
- tabIndex: inert ? 0 : void 0,
1672
- "aria-disabled": inert ? "true" : void 0,
1673
- children: /* @__PURE__ */ jsx(PlayStoreBadgeArt, {
1674
- lang,
1675
- class: `${storeBadgeArt} frak-ambassador__store-badge-art`
1676
- })
1677
- })]
1678
- })
1679
- ]
1680
- }), /* @__PURE__ */ jsx(InstallQr, {
1681
- url: installUrl,
1682
- label: texts.storeQrLabel,
1683
- caption: texts.storeQrCaption,
1684
- class: `${storeQr} frak-ambassador__store-qr`,
1685
- captionClass: `${storeQrCaption} frak-ambassador__store-qr-caption`
1686
- })]
2107
+ summary?.linked ? null : /* @__PURE__ */ jsx(StoreSection, {
2108
+ lang,
2109
+ installUrl,
2110
+ heading: texts.storeHeading,
2111
+ lede: texts.storeLede,
2112
+ appBadgeAriaLabel: texts.storeAppBadgeAriaLabel,
2113
+ playBadgeAriaLabel: texts.storePlayBadgeAriaLabel,
2114
+ qrLabel: texts.storeQrLabel,
2115
+ qrCaption: texts.storeQrCaption
1687
2116
  }),
1688
2117
  /* @__PURE__ */ jsxs("section", {
1689
2118
  class: `${faq} frak-ambassador__faq`,
@@ -1713,7 +2142,7 @@ function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle:
1713
2142
  children: texts.faq5Answer ?? /* @__PURE__ */ jsxs(Fragment, { children: [
1714
2143
  texts.faq5AnswerBeforeLink,
1715
2144
  /* @__PURE__ */ jsx("a", {
1716
- class: `Ambassador_frakLink__awpcg019 frak-ambassador__faq-answer-link frak-link`,
2145
+ class: `Ambassador_frakLink__awpcg01p frak-ambassador__faq-answer-link frak-link`,
1717
2146
  href: FRAK_URL,
1718
2147
  target: "_blank",
1719
2148
  rel: "noopener",
@@ -1802,6 +2231,12 @@ registerWebComponent(Ambassador, "frak-ambassador", [...[
1802
2231
  "faq5AnswerLinkText",
1803
2232
  "faq5AnswerAfterLink",
1804
2233
  "attributionBeforeLink",
1805
- "attributionLinkText"
2234
+ "attributionLinkText",
2235
+ "myRewardsEyebrow",
2236
+ "myRewardsLinkedHeading",
2237
+ "myRewardsClaimCtaLabel",
2238
+ "myRewardsShareCtaLabel",
2239
+ "myRewardsWalletCtaLabel",
2240
+ "myRewardsShareAgainCtaLabel"
1806
2241
  ]], { shadow: false });
1807
2242
  export { Ambassador };