@coinlist-co/react 0.2.0 → 0.4.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 (67) hide show
  1. package/dist/RequirementItem-B-MvcxSr.d.cts +37 -0
  2. package/dist/RequirementItem-DcYot2uC.d.ts +37 -0
  3. package/dist/chunk-EHZ6PIGN.js +414 -0
  4. package/dist/chunk-EHZ6PIGN.js.map +1 -0
  5. package/dist/chunk-NC45IO63.js +777 -0
  6. package/dist/chunk-NC45IO63.js.map +1 -0
  7. package/dist/chunk-RIFATQB5.js +257 -0
  8. package/dist/chunk-RIFATQB5.js.map +1 -0
  9. package/dist/chunk-UGJUTRXC.js +304 -0
  10. package/dist/chunk-UGJUTRXC.js.map +1 -0
  11. package/dist/client/components/index.cjs +473 -10
  12. package/dist/client/components/index.cjs.map +1 -1
  13. package/dist/client/components/index.d.cts +80 -12
  14. package/dist/client/components/index.d.ts +80 -12
  15. package/dist/client/components/index.js +243 -243
  16. package/dist/client/components/index.js.map +1 -1
  17. package/dist/client/core/index.cjs +349 -202
  18. package/dist/client/core/index.cjs.map +1 -1
  19. package/dist/client/core/index.d.cts +4 -4
  20. package/dist/client/core/index.d.ts +4 -4
  21. package/dist/client/core/index.js +16 -14
  22. package/dist/client/hooks/index.cjs +133 -16
  23. package/dist/client/hooks/index.cjs.map +1 -1
  24. package/dist/client/hooks/index.d.cts +102 -8
  25. package/dist/client/hooks/index.d.ts +102 -8
  26. package/dist/client/hooks/index.js +11 -9
  27. package/dist/client/index.cjs +591 -210
  28. package/dist/client/index.cjs.map +1 -1
  29. package/dist/client/index.d.cts +7 -6
  30. package/dist/client/index.d.ts +7 -6
  31. package/dist/client/index.js +41 -17
  32. package/dist/client/styles.css +1 -1
  33. package/dist/coinlist-client-BSxpqylo.d.ts +158 -0
  34. package/dist/coinlist-client-Cah5c_aF.d.cts +158 -0
  35. package/dist/participation-DMMEDxON.d.cts +185 -0
  36. package/dist/participation-E-bT-GXJ.d.ts +185 -0
  37. package/dist/requirement-XWT0T_zO.d.cts +205 -0
  38. package/dist/requirement-XWT0T_zO.d.ts +205 -0
  39. package/dist/server/index.cjs +519 -14
  40. package/dist/server/index.cjs.map +1 -1
  41. package/dist/server/index.d.cts +73 -4
  42. package/dist/server/index.d.ts +73 -4
  43. package/dist/server/index.js +116 -20
  44. package/dist/server/index.js.map +1 -1
  45. package/dist/useCoinListRequirements-B5-ZPOMz.d.ts +80 -0
  46. package/dist/useCoinListRequirements-Cuc32Tqw.d.cts +80 -0
  47. package/package.json +4 -4
  48. package/dist/chunk-32GOUV3L.js +0 -118
  49. package/dist/chunk-32GOUV3L.js.map +0 -1
  50. package/dist/chunk-G3B4RLXP.js +0 -76
  51. package/dist/chunk-G3B4RLXP.js.map +0 -1
  52. package/dist/chunk-GRVV7NLV.js +0 -282
  53. package/dist/chunk-GRVV7NLV.js.map +0 -1
  54. package/dist/chunk-Z5RFQOMS.js +0 -560
  55. package/dist/chunk-Z5RFQOMS.js.map +0 -1
  56. package/dist/coinlist-client-20v7fJSW.d.ts +0 -394
  57. package/dist/coinlist-client-Ds86ycAg.d.cts +0 -394
  58. package/dist/newtype-yKTvFdg_.d.cts +0 -6
  59. package/dist/newtype-yKTvFdg_.d.ts +0 -6
  60. package/dist/oauth-session-DgItaMKN.d.cts +0 -56
  61. package/dist/oauth-session-DnKDI5ou.d.ts +0 -56
  62. package/dist/offer-D6p_Ijme.d.cts +0 -30
  63. package/dist/offer-DnFEFJw9.d.ts +0 -30
  64. package/dist/useCoinListOffers-DIdOb5hB.d.ts +0 -27
  65. package/dist/useCoinListOffers-DvJxu6qj.d.cts +0 -27
  66. package/dist/useCompleteCoinListOAuth-C359mp_k.d.cts +0 -55
  67. package/dist/useCompleteCoinListOAuth-wZX3o8r2.d.ts +0 -55
@@ -21,9 +21,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var components_exports = {};
22
22
  __export(components_exports, {
23
23
  BaseCoinListSignInCard: () => BaseCoinListSignInCard,
24
+ BaseRequirementsChecklist: () => BaseRequirementsChecklist,
25
+ ChecklistStatus: () => ChecklistStatus,
24
26
  CoinListSignInCard: () => CoinListSignInCard,
25
27
  OfferCard: () => OfferCard,
26
- OffersGrid: () => OffersGrid
28
+ OfferCardUi: () => OfferCardUi,
29
+ OffersGrid: () => OffersGrid,
30
+ RequirementItem: () => RequirementItem,
31
+ RequirementItemUi: () => RequirementItemUi,
32
+ RequirementStatus: () => RequirementStatus,
33
+ RequirementVariant: () => RequirementVariant,
34
+ RequirementsChecklist: () => RequirementsChecklist
27
35
  });
28
36
  module.exports = __toCommonJS(components_exports);
29
37
  var import_styles = require("../styles.css");
@@ -456,6 +464,15 @@ var monthYearFormatter = new Intl.DateTimeFormat("en-US", {
456
464
  month: "short",
457
465
  year: "numeric"
458
466
  });
467
+ var OfferCardUi = {
468
+ fromDomain: (offer) => ({
469
+ tagline: offer.tagline,
470
+ bannerUrl: offer.bannerUrl,
471
+ logoUrl: offer.logoUrl,
472
+ formattedStartsAt: monthYearFormatter.format(offer.startsAt),
473
+ formattedEndsAt: monthYearFormatter.format(offer.endsAt)
474
+ })
475
+ };
459
476
  function OfferCard({
460
477
  offer,
461
478
  onClick,
@@ -487,11 +504,11 @@ function OfferCard({
487
504
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "mt-4 grid grid-cols-2 gap-5 border-t border-divider pt-4", children: [
488
505
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col gap-1", children: [
489
506
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: cn(typeClasses.subhead, "text-text-secondary"), children: "Starts" }),
490
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: cn(typeClasses.label, "text-text-primary"), children: monthYearFormatter.format(offer.startsAt) })
507
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: cn(typeClasses.label, "text-text-primary"), children: offer.formattedStartsAt })
491
508
  ] }),
492
509
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col gap-1", children: [
493
510
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: cn(typeClasses.subhead, "text-text-secondary"), children: "Ends" }),
494
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: cn(typeClasses.label, "text-text-primary"), children: monthYearFormatter.format(offer.endsAt) })
511
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: cn(typeClasses.label, "text-text-primary"), children: offer.formattedEndsAt })
495
512
  ] })
496
513
  ] })
497
514
  ] });
@@ -524,13 +541,23 @@ function OfferCard({
524
541
  // src/client/hooks/useCoinListOffers.ts
525
542
  var import_react4 = require("react");
526
543
  var LOADING_STATE = { type: "LOADING" };
527
- function useCoinListOffers() {
544
+ function useCoinListOffers(options = {}) {
528
545
  const { coinlist, isReady } = useCoinList();
529
- const [offersState, setOffersState] = (0, import_react4.useState)(LOADING_STATE);
546
+ const { serverOffers } = options;
547
+ const [offersState, setOffersState] = (0, import_react4.useState)(
548
+ serverOffers !== void 0 ? { type: "CONTENT", offers: serverOffers } : LOADING_STATE
549
+ );
530
550
  (0, import_react4.useEffect)(() => {
531
551
  let isCancelled = false;
532
552
  if (!isReady) {
533
- setOffersState(LOADING_STATE);
553
+ if (serverOffers === void 0) {
554
+ setOffersState(LOADING_STATE);
555
+ }
556
+ return () => {
557
+ isCancelled = true;
558
+ };
559
+ }
560
+ if (serverOffers !== void 0) {
534
561
  return () => {
535
562
  isCancelled = true;
536
563
  };
@@ -549,15 +576,68 @@ function useCoinListOffers() {
549
576
  return () => {
550
577
  isCancelled = true;
551
578
  };
552
- }, [coinlist, isReady]);
579
+ }, [coinlist, isReady, serverOffers]);
553
580
  return { offersState };
554
581
  }
555
582
 
583
+ // src/client/hooks/useCoinListRequirements.ts
584
+ var import_react5 = require("react");
585
+ var LOADING_STATE2 = { type: "LOADING" };
586
+ function useCoinListRequirements(offerId, options = {}) {
587
+ const { coinlist, isReady } = useCoinList();
588
+ const { serverData } = options;
589
+ const [requirementsState, setRequirementsState] = (0, import_react5.useState)(
590
+ serverData !== void 0 ? { type: "CONTENT", ...serverData } : LOADING_STATE2
591
+ );
592
+ const [fetchKey, setFetchKey] = (0, import_react5.useState)(0);
593
+ const refetch = (0, import_react5.useCallback)(() => setFetchKey((k) => k + 1), []);
594
+ (0, import_react5.useEffect)(() => {
595
+ let isCancelled = false;
596
+ if (!isReady) {
597
+ if (serverData === void 0) {
598
+ setRequirementsState(LOADING_STATE2);
599
+ }
600
+ return () => {
601
+ isCancelled = true;
602
+ };
603
+ }
604
+ if (serverData !== void 0 && fetchKey === 0) {
605
+ return () => {
606
+ isCancelled = true;
607
+ };
608
+ }
609
+ setRequirementsState(LOADING_STATE2);
610
+ Promise.all([
611
+ coinlist.fetchOfferRequirements(offerId),
612
+ coinlist.fetchRequirementStatuses(offerId)
613
+ ]).then(([requirementsByOptionId, statuses]) => {
614
+ if (!isCancelled) {
615
+ setRequirementsState({
616
+ type: "CONTENT",
617
+ requirementsByOptionId,
618
+ statuses
619
+ });
620
+ }
621
+ }).catch((error) => {
622
+ if (!isCancelled) {
623
+ const reason = error instanceof NotAuthenticatedError ? "not-authenticated" : "generic-error";
624
+ setRequirementsState({ type: "ERROR", reason });
625
+ }
626
+ });
627
+ return () => {
628
+ isCancelled = true;
629
+ };
630
+ }, [coinlist, isReady, offerId, fetchKey]);
631
+ return { requirementsState, refetch };
632
+ }
633
+
556
634
  // src/client/components/offers/OffersGrid.tsx
557
635
  var import_jsx_runtime11 = require("react/jsx-runtime");
558
636
  var DEFAULT_MAX_COLUMNS = 3;
559
637
  function OffersGrid(props) {
560
- const { offersState } = useCoinListOffers();
638
+ const { offersState } = useCoinListOffers({
639
+ serverOffers: props.serverOffers
640
+ });
561
641
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(BaseOffersGrid, { ...props, offersState });
562
642
  }
563
643
  function BaseOffersGrid({
@@ -627,7 +707,7 @@ function BaseOffersGrid({
627
707
  children: offersState.offers.map((offer) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
628
708
  OfferCard,
629
709
  {
630
- offer,
710
+ offer: OfferCardUi.fromDomain(offer),
631
711
  onClick: onOfferClick ? () => onOfferClick(offer) : void 0
632
712
  },
633
713
  offer.id
@@ -635,11 +715,394 @@ function BaseOffersGrid({
635
715
  }
636
716
  ) });
637
717
  }
718
+
719
+ // src/client/components/requirements/RequirementItem.tsx
720
+ var import_lucide_react4 = require("lucide-react");
721
+
722
+ // src/client/components/design-system/StepStatusIcon.tsx
723
+ var import_lucide_react3 = require("lucide-react");
724
+ var import_jsx_runtime12 = require("react/jsx-runtime");
725
+ var statusConfig = {
726
+ required: {
727
+ Icon: import_lucide_react3.Info,
728
+ colorClass: "text-warning",
729
+ fillClass: "[&_circle]:fill-warning-subtle"
730
+ },
731
+ pending: {
732
+ Icon: import_lucide_react3.Info,
733
+ colorClass: "text-warning",
734
+ fillClass: "[&_circle]:fill-warning-subtle"
735
+ },
736
+ completed: {
737
+ Icon: import_lucide_react3.CircleCheck,
738
+ colorClass: "text-success",
739
+ fillClass: "[&_circle]:fill-success-subtle"
740
+ },
741
+ rejected: {
742
+ Icon: import_lucide_react3.CircleX,
743
+ colorClass: "text-error",
744
+ fillClass: "[&_circle]:fill-error-subtle"
745
+ }
746
+ };
747
+ function StepStatusIcon({ status, className }) {
748
+ const { Icon, colorClass, fillClass } = statusConfig[status];
749
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
750
+ Icon,
751
+ {
752
+ className: cn("h-6 w-6 shrink-0", colorClass, fillClass, className),
753
+ "aria-hidden": "true"
754
+ }
755
+ );
756
+ }
757
+
758
+ // src/client/components/requirements/RequirementItem.tsx
759
+ var import_jsx_runtime13 = require("react/jsx-runtime");
760
+ var RequirementVariant = {
761
+ fromType(type) {
762
+ switch (type) {
763
+ case "external_wallet":
764
+ case "whitelisted_wallet":
765
+ return "wallet";
766
+ default:
767
+ return "verification";
768
+ }
769
+ }
770
+ };
771
+ var RequirementStatus = {
772
+ fromStatusValue(status) {
773
+ switch (status) {
774
+ case "not_started":
775
+ case "action_needed":
776
+ return "required";
777
+ case "in_progress":
778
+ return "pending";
779
+ case "completed":
780
+ return "completed";
781
+ case "rejected":
782
+ return "rejected";
783
+ }
784
+ }
785
+ };
786
+ var ChecklistStatus = {
787
+ derive(statuses) {
788
+ if (statuses.some((s) => s.status === "rejected")) return "ineligible";
789
+ if (statuses.every((s) => s.status === "completed")) return "eligible";
790
+ return "inProgress";
791
+ }
792
+ };
793
+ var RequirementItemUi = {
794
+ fromDomain(req, statusInfo, label, description, walletAddress) {
795
+ return {
796
+ variant: RequirementVariant.fromType(req.type),
797
+ status: statusInfo ? RequirementStatus.fromStatusValue(statusInfo.status) : "required",
798
+ label,
799
+ description,
800
+ walletAddress
801
+ };
802
+ }
803
+ };
804
+ function VerificationActionZone({
805
+ status,
806
+ onAction,
807
+ onContactSupport
808
+ }) {
809
+ switch (status) {
810
+ case "required":
811
+ if (onAction === null) return null;
812
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ClButton, { size: "sm", onClick: onAction, children: "Continue" });
813
+ case "pending":
814
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
815
+ AlertBanner,
816
+ {
817
+ variant: "warning",
818
+ content: "Under review. We'll notify you when complete."
819
+ }
820
+ );
821
+ case "completed":
822
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AlertBanner, { variant: "success", content: "Identity verified." });
823
+ case "rejected":
824
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
825
+ AlertBanner,
826
+ {
827
+ variant: "error",
828
+ content: onContactSupport === null ? "Verification rejected." : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
829
+ "Verification rejected.",
830
+ " ",
831
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
832
+ "button",
833
+ {
834
+ type: "button",
835
+ onClick: onContactSupport,
836
+ className: "underline",
837
+ children: "Contact support"
838
+ }
839
+ ),
840
+ "."
841
+ ] })
842
+ }
843
+ );
844
+ }
845
+ }
846
+ function WalletActionZone({
847
+ status,
848
+ walletAddress,
849
+ onAction
850
+ }) {
851
+ if (status === "completed") {
852
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
853
+ onAction !== null && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ClButton, { size: "sm", variant: "secondary", onClick: onAction, children: "Change wallet" }),
854
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
855
+ AlertBanner,
856
+ {
857
+ variant: "success",
858
+ content: walletAddress ?? "Connected: 0xBa4b...9f2c"
859
+ }
860
+ )
861
+ ] });
862
+ }
863
+ if (status === "rejected") {
864
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
865
+ onAction !== null && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ClButton, { size: "sm", onClick: onAction, children: "Connect wallet" }),
866
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
867
+ AlertBanner,
868
+ {
869
+ variant: "error",
870
+ content: "This wallet is not eligible for this sale."
871
+ }
872
+ )
873
+ ] });
874
+ }
875
+ if (onAction === null) return null;
876
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ClButton, { size: "sm", onClick: onAction, children: "Connect wallet" });
877
+ }
878
+ function RequirementItem({
879
+ ui,
880
+ expanded = false,
881
+ onToggle,
882
+ className,
883
+ onAction,
884
+ onContactSupport
885
+ }) {
886
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: cn("flex w-full flex-col", className), children: [
887
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
888
+ "button",
889
+ {
890
+ type: "button",
891
+ onClick: onToggle,
892
+ "aria-expanded": expanded,
893
+ className: "flex h-14 w-full cursor-pointer items-center justify-between rounded-2xl px-2 transition-colors hover:bg-surface",
894
+ children: [
895
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-3", children: [
896
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StepStatusIcon, { status: ui.status }),
897
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
898
+ "span",
899
+ {
900
+ className: cn(
901
+ typeClasses.body,
902
+ "whitespace-nowrap font-medium text-text-primary"
903
+ ),
904
+ children: ui.label
905
+ }
906
+ )
907
+ ] }),
908
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
909
+ import_lucide_react4.ChevronRight,
910
+ {
911
+ className: cn(
912
+ "h-6 w-6 shrink-0 text-text-secondary transition-transform duration-300",
913
+ expanded && "rotate-90"
914
+ ),
915
+ "aria-hidden": "true"
916
+ }
917
+ )
918
+ ]
919
+ }
920
+ ),
921
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
922
+ "div",
923
+ {
924
+ className: cn(
925
+ "grid transition-[grid-template-rows] duration-300 ease-in-out",
926
+ expanded ? "grid-rows-[1fr]" : "grid-rows-[0fr]"
927
+ ),
928
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-4 px-2 pb-4", children: [
929
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: cn(typeClasses.subhead, "text-text-secondary"), children: ui.description }),
930
+ ui.variant === "verification" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
931
+ VerificationActionZone,
932
+ {
933
+ status: ui.status,
934
+ onAction,
935
+ onContactSupport
936
+ }
937
+ ) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
938
+ WalletActionZone,
939
+ {
940
+ status: ui.status,
941
+ walletAddress: ui.walletAddress,
942
+ onAction
943
+ }
944
+ )
945
+ ] }) })
946
+ }
947
+ )
948
+ ] });
949
+ }
950
+
951
+ // src/client/components/requirements/RequirementsChecklist.tsx
952
+ var import_react6 = require("react");
953
+ var import_jsx_runtime14 = require("react/jsx-runtime");
954
+ var DEFAULT_LABELS = {
955
+ kyc_approved: "KYC Verification",
956
+ identity_verified: "Identity Verification",
957
+ proof_of_address: "Proof of Address",
958
+ source_of_funds: "Source of Funds",
959
+ external_wallet: "External Wallet",
960
+ whitelisted_wallet: "Whitelisted Wallet",
961
+ jurisdiction: "Jurisdiction Check",
962
+ accreditation: "Accreditation"
963
+ };
964
+ var DEFAULT_DESCRIPTIONS = {
965
+ kyc_approved: "Complete Know Your Customer verification.",
966
+ identity_verified: "Verify your identity.",
967
+ proof_of_address: "Provide proof of your residential address.",
968
+ source_of_funds: "Provide documentation for your source of funds.",
969
+ external_wallet: "Connect an external wallet.",
970
+ whitelisted_wallet: "Connect a whitelisted wallet.",
971
+ jurisdiction: "Confirm your jurisdiction eligibility.",
972
+ accreditation: "Verify your accreditation status."
973
+ };
974
+ function RequirementsChecklist(props) {
975
+ const { coinlist } = useCoinList();
976
+ const { requirementsState } = useCoinListRequirements(props.offerId, {
977
+ serverData: props.serverData
978
+ });
979
+ const onRequirementAction = props.onRequirementActionOverride !== void 0 ? props.onRequirementActionOverride : (requirement) => coinlist.handleRequirement(requirement);
980
+ const onContactSupport = props.onContactSupportOverride !== void 0 ? props.onContactSupportOverride : () => coinlist.contactSupport();
981
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
982
+ BaseRequirementsChecklist,
983
+ {
984
+ ...props,
985
+ onRequirementActionOverride: onRequirementAction,
986
+ onContactSupportOverride: onContactSupport,
987
+ requirementsState
988
+ }
989
+ );
990
+ }
991
+ function BaseRequirementsChecklist({
992
+ requirementsState,
993
+ optionId,
994
+ title,
995
+ description,
996
+ onContinue,
997
+ onRequirementActionOverride: onRequirementAction,
998
+ onContactSupportOverride: onContactSupport,
999
+ getLabel,
1000
+ getDescription,
1001
+ loading,
1002
+ error,
1003
+ className
1004
+ }) {
1005
+ const [expandedIndex, setExpandedIndex] = (0, import_react6.useState)(null);
1006
+ if (requirementsState.type === "LOADING") {
1007
+ if (loading) return loading;
1008
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1009
+ "output",
1010
+ {
1011
+ "aria-live": "polite",
1012
+ className: "flex min-h-40 items-center justify-center rounded-2xl border border-border bg-background p-6",
1013
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: cn(typeClasses.body, "text-text-secondary"), children: "Loading requirements..." })
1014
+ }
1015
+ );
1016
+ }
1017
+ if (requirementsState.type === "ERROR") {
1018
+ if (error) return error;
1019
+ const errorMessage = requirementsState.reason === "not-authenticated" ? "Sign in to view requirements." : "Unable to load requirements right now. Please try again.";
1020
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1021
+ AlertBanner,
1022
+ {
1023
+ variant: "error",
1024
+ icon: true,
1025
+ content: errorMessage,
1026
+ className: "w-full max-w-[28rem]"
1027
+ }
1028
+ );
1029
+ }
1030
+ const { requirementsByOptionId, statuses } = requirementsState;
1031
+ const requirements = requirementsByOptionId[optionId] ?? [];
1032
+ const requirementIds = new Set(requirements.map((r) => r.id));
1033
+ const optionStatuses = statuses.filter((s) => requirementIds.has(s.id));
1034
+ const statusByRequirementId = new Map(optionStatuses.map((s) => [s.id, s]));
1035
+ const checklistStatus = ChecklistStatus.derive(optionStatuses);
1036
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: cn("flex w-full flex-col gap-4", className), children: [
1037
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-col gap-2", children: [
1038
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h3", { className: cn(typeClasses.h3, "text-text-primary"), children: title }),
1039
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: cn(typeClasses.body, "text-text-secondary"), children: description })
1040
+ ] }),
1041
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex flex-col divide-y divide-divider", children: requirements.map((req, index) => {
1042
+ const statusInfo = statusByRequirementId.get(req.id);
1043
+ const label = getLabel ? getLabel(req) : DEFAULT_LABELS[req.type];
1044
+ const description2 = (getDescription ? getDescription(req) : null) ?? DEFAULT_DESCRIPTIONS[req.type];
1045
+ let onActionBound;
1046
+ if (onRequirementAction === null) {
1047
+ onActionBound = null;
1048
+ } else if (onRequirementAction) {
1049
+ onActionBound = () => onRequirementAction(req);
1050
+ }
1051
+ let onContactSupportBound;
1052
+ if (onContactSupport === null) {
1053
+ onContactSupportBound = null;
1054
+ } else if (onContactSupport) {
1055
+ onContactSupportBound = () => onContactSupport(req);
1056
+ }
1057
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1058
+ RequirementItem,
1059
+ {
1060
+ ui: RequirementItemUi.fromDomain(
1061
+ req,
1062
+ statusInfo,
1063
+ label,
1064
+ description2
1065
+ ),
1066
+ expanded: expandedIndex === index,
1067
+ onToggle: () => setExpandedIndex((prev) => prev === index ? null : index),
1068
+ onAction: onActionBound,
1069
+ onContactSupport: onContactSupportBound
1070
+ },
1071
+ req.id
1072
+ );
1073
+ }) }),
1074
+ checklistStatus === "ineligible" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1075
+ AlertBanner,
1076
+ {
1077
+ variant: "error",
1078
+ icon: true,
1079
+ content: "You are not eligible to participate."
1080
+ }
1081
+ ),
1082
+ onContinue && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1083
+ ClButton,
1084
+ {
1085
+ fullWidth: true,
1086
+ disabled: checklistStatus !== "eligible",
1087
+ onClick: onContinue,
1088
+ children: "Continue"
1089
+ }
1090
+ )
1091
+ ] });
1092
+ }
638
1093
  // Annotate the CommonJS export names for ESM import in node:
639
1094
  0 && (module.exports = {
640
1095
  BaseCoinListSignInCard,
1096
+ BaseRequirementsChecklist,
1097
+ ChecklistStatus,
641
1098
  CoinListSignInCard,
642
1099
  OfferCard,
643
- OffersGrid
1100
+ OfferCardUi,
1101
+ OffersGrid,
1102
+ RequirementItem,
1103
+ RequirementItemUi,
1104
+ RequirementStatus,
1105
+ RequirementVariant,
1106
+ RequirementsChecklist
644
1107
  });
645
1108
  //# sourceMappingURL=index.cjs.map