@saasquatch/mint-components 1.11.1-55 → 1.11.1-58

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.
@@ -432,16 +432,6 @@ const ReferralTableRewardsCell = class {
432
432
  }
433
433
  disconnectedCallback() { }
434
434
  render() {
435
- var _a;
436
- reRender.useRequestRerender([
437
- this.statusText,
438
- this.statusLongText,
439
- this.fuelTankText,
440
- this.rewardReceivedText,
441
- this.expiringText,
442
- this.pendingForText,
443
- this.hideDetails,
444
- ]);
445
435
  global.intl.locale = this.locale;
446
436
  const style = {
447
437
  "@keyframes slideRight": {
@@ -590,54 +580,58 @@ const ReferralTableRewardsCell = class {
590
580
  .replace("in", "")
591
581
  .trim();
592
582
  };
593
- return (_a = this.rewards) === null || _a === void 0 ? void 0 : _a.map((reward) => {
594
- var _a, _b;
595
- const state = getState(reward, this.taxConnection);
596
- const slBadgeType = getSLBadgeType(state);
597
- const badgeText = global.intl.formatMessage({ id: "statusShortMessage", defaultMessage: this.statusText }, {
598
- status: state,
599
- });
600
- console.log({
601
- state,
602
- intl: global.intl,
603
- badgeText,
604
- statusText: this.statusText,
605
- reward,
606
- });
607
- const statusText = global.intl.formatMessage({
608
- id: "statusLongMessage",
609
- defaultMessage: this.statusLongText,
610
- }, {
611
- status: state,
583
+ const rewardMap = stencilHooks_module.useMemo(() => {
584
+ var _a;
585
+ return (_a = this.rewards) === null || _a === void 0 ? void 0 : _a.map((reward) => {
586
+ var _a, _b;
587
+ const state = getState(reward, this.taxConnection);
588
+ const slBadgeType = getSLBadgeType(state);
589
+ const badgeText = global.intl.formatMessage({ id: "statusShortMessage", defaultMessage: this.statusText }, {
590
+ status: state,
591
+ });
592
+ console.log({
593
+ state,
594
+ intl: global.intl,
595
+ badgeText,
596
+ statusText: this.statusText,
597
+ reward,
598
+ });
599
+ const statusText = global.intl.formatMessage({
600
+ id: "statusLongMessage",
601
+ defaultMessage: this.statusLongText,
602
+ }, {
603
+ status: state,
604
+ });
605
+ return (index.h("sl-details", { class: sheet.classes.Details, disabled: this.hideDetails }, index.h("style", { type: "text/css" }, styleString), index.h("div", { slot: "summary", class: sheet.classes.DetailsContainer }, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, index.h("span", { part: "sqm-cell-value", class: sheet.classes.BoldText }, reward.prettyValue)), index.h("div", { class: sheet.classes.BadgeContainer }, state === "PENDING" && reward.dateScheduledFor ? (index.h("sl-badge", { class: slBadgeType === "primary"
606
+ ? sheet.classes.RedeemBadge
607
+ : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, global.intl.formatMessage({
608
+ id: "pendingForText",
609
+ defaultMessage: this.pendingForText,
610
+ }, {
611
+ status: badgeText,
612
+ date: getTimeDiff(reward.dateScheduledFor),
613
+ }))) : (index.h("sl-badge", { class: slBadgeType === "primary"
614
+ ? sheet.classes.RedeemBadge
615
+ : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, badgeText)), reward.dateExpires && state === "AVAILABLE" && (index.h("sl-badge", { class: slBadgeType === "primary"
616
+ ? sheet.classes.RedeemBadge
617
+ : sheet.classes.StatusBadge, type: "info", pill: true }, this.expiringText, ` ${getTimeDiff(reward.dateExpires)}`)))), index.h("div", null, state === "PENDING_REVIEW" && ((_a = reward.referral) === null || _a === void 0 ? void 0 : _a.dateModerated) && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.referral.dateModerated)
618
+ .setLocale(utils.luxonLocale(this.locale))
619
+ .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "PAYOUT_APPROVED" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_FAILED" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_CANCELLED" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_REVIEW" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_NEW_TAX_FORM" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_SUBMISSION" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_PARTNER_CREATION" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "DENIED" && ((_b = reward.referral) === null || _b === void 0 ? void 0 : _b.dateModerated) && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.referral.dateModerated)
620
+ .setLocale(utils.luxonLocale(this.locale))
621
+ .toLocaleString(luxon.luxon.DateTime.DATE_MED)), ".", this.deniedHelpText ? ` ${this.deniedHelpText}` : ``))), reward.dateGiven && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, this.rewardReceivedText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateGiven)
622
+ .setLocale(utils.luxonLocale(this.locale))
623
+ .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "EXPIRED" && reward.dateExpires && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateExpires)
624
+ .setLocale(utils.luxonLocale(this.locale))
625
+ .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "CANCELLED" && reward.dateCancelled && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateCancelled)
626
+ .setLocale(utils.luxonLocale(this.locale))
627
+ .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "PENDING" && reward.dateScheduledFor && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateScheduledFor)
628
+ .setLocale(utils.luxonLocale(this.locale))
629
+ .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), " ", state === "AVAILABLE" && reward.dateExpires && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateExpires)
630
+ .setLocale(utils.luxonLocale(this.locale))
631
+ .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), reward.fuelTankCode && (index.h("div", null, this.fuelTankText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, reward.fuelTankCode))))));
612
632
  });
613
- return (index.h("sl-details", { class: sheet.classes.Details, disabled: this.hideDetails }, index.h("style", { type: "text/css" }, styleString), index.h("div", { slot: "summary", class: sheet.classes.DetailsContainer }, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, index.h("span", { part: "sqm-cell-value", class: sheet.classes.BoldText }, reward.prettyValue)), index.h("div", { class: sheet.classes.BadgeContainer }, state === "PENDING" && reward.dateScheduledFor ? (index.h("sl-badge", { class: slBadgeType === "primary"
614
- ? sheet.classes.RedeemBadge
615
- : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, global.intl.formatMessage({
616
- id: "pendingForText",
617
- defaultMessage: this.pendingForText,
618
- }, {
619
- status: badgeText,
620
- date: getTimeDiff(reward.dateScheduledFor),
621
- }))) : (index.h("sl-badge", { class: slBadgeType === "primary"
622
- ? sheet.classes.RedeemBadge
623
- : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, badgeText)), reward.dateExpires && state === "AVAILABLE" && (index.h("sl-badge", { class: slBadgeType === "primary"
624
- ? sheet.classes.RedeemBadge
625
- : sheet.classes.StatusBadge, type: "info", pill: true }, this.expiringText, ` ${getTimeDiff(reward.dateExpires)}`)))), index.h("div", null, state === "PENDING_REVIEW" && ((_a = reward.referral) === null || _a === void 0 ? void 0 : _a.dateModerated) && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.referral.dateModerated)
626
- .setLocale(utils.luxonLocale(this.locale))
627
- .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "PAYOUT_APPROVED" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_FAILED" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_CANCELLED" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_REVIEW" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_NEW_TAX_FORM" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_SUBMISSION" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_PARTNER_CREATION" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "DENIED" && ((_b = reward.referral) === null || _b === void 0 ? void 0 : _b.dateModerated) && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.referral.dateModerated)
628
- .setLocale(utils.luxonLocale(this.locale))
629
- .toLocaleString(luxon.luxon.DateTime.DATE_MED)), ".", this.deniedHelpText ? ` ${this.deniedHelpText}` : ``))), reward.dateGiven && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, this.rewardReceivedText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateGiven)
630
- .setLocale(utils.luxonLocale(this.locale))
631
- .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "EXPIRED" && reward.dateExpires && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateExpires)
632
- .setLocale(utils.luxonLocale(this.locale))
633
- .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "CANCELLED" && reward.dateCancelled && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateCancelled)
634
- .setLocale(utils.luxonLocale(this.locale))
635
- .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "PENDING" && reward.dateScheduledFor && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateScheduledFor)
636
- .setLocale(utils.luxonLocale(this.locale))
637
- .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), " ", state === "AVAILABLE" && reward.dateExpires && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateExpires)
638
- .setLocale(utils.luxonLocale(this.locale))
639
- .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), reward.fuelTankCode && (index.h("div", null, this.fuelTankText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, reward.fuelTankCode))))));
640
- });
633
+ }, [this.statusText]);
634
+ return rewardMap;
641
635
  }
642
636
  };
643
637
 
@@ -2,10 +2,10 @@ import { Component, h, Prop } from "@stencil/core";
2
2
  import { DateTime } from "luxon";
3
3
  import { intl } from "../../../global/global";
4
4
  import { createStyleSheet } from "../../../styling/JSS";
5
- import { useRequestRerender } from "../../../tables/re-render";
6
5
  import { luxonLocale } from "../../../utils/utils";
7
6
  import { TextSpanView } from "../../sqm-text-span/sqm-text-span-view";
8
7
  import { withHooks } from "@saasquatch/stencil-hooks";
8
+ import { useMemo } from "@saasquatch/universal-hooks";
9
9
  export class ReferralTableRewardsCell {
10
10
  constructor() {
11
11
  this.locale = "en";
@@ -13,16 +13,6 @@ export class ReferralTableRewardsCell {
13
13
  }
14
14
  disconnectedCallback() { }
15
15
  render() {
16
- var _a;
17
- useRequestRerender([
18
- this.statusText,
19
- this.statusLongText,
20
- this.fuelTankText,
21
- this.rewardReceivedText,
22
- this.expiringText,
23
- this.pendingForText,
24
- this.hideDetails,
25
- ]);
26
16
  intl.locale = this.locale;
27
17
  const style = {
28
18
  "@keyframes slideRight": {
@@ -171,7 +161,7 @@ export class ReferralTableRewardsCell {
171
161
  .replace("in", "")
172
162
  .trim();
173
163
  };
174
- return (_a = this.rewards) === null || _a === void 0 ? void 0 : _a.map((reward) => {
164
+ const rewardMap = useMemo(() => { var _a; return (_a = this.rewards) === null || _a === void 0 ? void 0 : _a.map((reward) => {
175
165
  var _a, _b;
176
166
  const state = getState(reward, this.taxConnection);
177
167
  const slBadgeType = getSLBadgeType(state);
@@ -284,7 +274,8 @@ export class ReferralTableRewardsCell {
284
274
  this.fuelTankText,
285
275
  " ",
286
276
  h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, reward.fuelTankCode))))));
287
- });
277
+ }); }, [this.statusText]);
278
+ return rewardMap;
288
279
  }
289
280
  static get is() { return "sqm-referral-table-rewards-cell"; }
290
281
  static get encapsulation() { return "shadow"; }
@@ -428,16 +428,6 @@ const ReferralTableRewardsCell = class {
428
428
  }
429
429
  disconnectedCallback() { }
430
430
  render() {
431
- var _a;
432
- useRequestRerender([
433
- this.statusText,
434
- this.statusLongText,
435
- this.fuelTankText,
436
- this.rewardReceivedText,
437
- this.expiringText,
438
- this.pendingForText,
439
- this.hideDetails,
440
- ]);
441
431
  intl.locale = this.locale;
442
432
  const style = {
443
433
  "@keyframes slideRight": {
@@ -586,54 +576,58 @@ const ReferralTableRewardsCell = class {
586
576
  .replace("in", "")
587
577
  .trim();
588
578
  };
589
- return (_a = this.rewards) === null || _a === void 0 ? void 0 : _a.map((reward) => {
590
- var _a, _b;
591
- const state = getState(reward, this.taxConnection);
592
- const slBadgeType = getSLBadgeType(state);
593
- const badgeText = intl.formatMessage({ id: "statusShortMessage", defaultMessage: this.statusText }, {
594
- status: state,
595
- });
596
- console.log({
597
- state,
598
- intl,
599
- badgeText,
600
- statusText: this.statusText,
601
- reward,
602
- });
603
- const statusText = intl.formatMessage({
604
- id: "statusLongMessage",
605
- defaultMessage: this.statusLongText,
606
- }, {
607
- status: state,
579
+ const rewardMap = useMemo(() => {
580
+ var _a;
581
+ return (_a = this.rewards) === null || _a === void 0 ? void 0 : _a.map((reward) => {
582
+ var _a, _b;
583
+ const state = getState(reward, this.taxConnection);
584
+ const slBadgeType = getSLBadgeType(state);
585
+ const badgeText = intl.formatMessage({ id: "statusShortMessage", defaultMessage: this.statusText }, {
586
+ status: state,
587
+ });
588
+ console.log({
589
+ state,
590
+ intl,
591
+ badgeText,
592
+ statusText: this.statusText,
593
+ reward,
594
+ });
595
+ const statusText = intl.formatMessage({
596
+ id: "statusLongMessage",
597
+ defaultMessage: this.statusLongText,
598
+ }, {
599
+ status: state,
600
+ });
601
+ return (h$1("sl-details", { class: sheet.classes.Details, disabled: this.hideDetails }, h$1("style", { type: "text/css" }, styleString), h$1("div", { slot: "summary", class: sheet.classes.DetailsContainer }, h$1(TextSpanView, { type: "p" }, h$1("span", { part: "sqm-cell-value", class: sheet.classes.BoldText }, reward.prettyValue)), h$1("div", { class: sheet.classes.BadgeContainer }, state === "PENDING" && reward.dateScheduledFor ? (h$1("sl-badge", { class: slBadgeType === "primary"
602
+ ? sheet.classes.RedeemBadge
603
+ : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, intl.formatMessage({
604
+ id: "pendingForText",
605
+ defaultMessage: this.pendingForText,
606
+ }, {
607
+ status: badgeText,
608
+ date: getTimeDiff(reward.dateScheduledFor),
609
+ }))) : (h$1("sl-badge", { class: slBadgeType === "primary"
610
+ ? sheet.classes.RedeemBadge
611
+ : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, badgeText)), reward.dateExpires && state === "AVAILABLE" && (h$1("sl-badge", { class: slBadgeType === "primary"
612
+ ? sheet.classes.RedeemBadge
613
+ : sheet.classes.StatusBadge, type: "info", pill: true }, this.expiringText, ` ${getTimeDiff(reward.dateExpires)}`)))), h$1("div", null, state === "PENDING_REVIEW" && ((_a = reward.referral) === null || _a === void 0 ? void 0 : _a.dateModerated) && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.referral.dateModerated)
614
+ .setLocale(luxonLocale(this.locale))
615
+ .toLocaleString(luxon.DateTime.DATE_MED))))), state === "PAYOUT_APPROVED" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_FAILED" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_CANCELLED" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_REVIEW" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_NEW_TAX_FORM" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_SUBMISSION" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_PARTNER_CREATION" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "DENIED" && ((_b = reward.referral) === null || _b === void 0 ? void 0 : _b.dateModerated) && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.referral.dateModerated)
616
+ .setLocale(luxonLocale(this.locale))
617
+ .toLocaleString(luxon.DateTime.DATE_MED)), ".", this.deniedHelpText ? ` ${this.deniedHelpText}` : ``))), reward.dateGiven && (h$1("div", null, h$1(TextSpanView, { type: "p" }, this.rewardReceivedText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateGiven)
618
+ .setLocale(luxonLocale(this.locale))
619
+ .toLocaleString(luxon.DateTime.DATE_MED))))), state === "EXPIRED" && reward.dateExpires && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateExpires)
620
+ .setLocale(luxonLocale(this.locale))
621
+ .toLocaleString(luxon.DateTime.DATE_MED))))), state === "CANCELLED" && reward.dateCancelled && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateCancelled)
622
+ .setLocale(luxonLocale(this.locale))
623
+ .toLocaleString(luxon.DateTime.DATE_MED))))), state === "PENDING" && reward.dateScheduledFor && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateScheduledFor)
624
+ .setLocale(luxonLocale(this.locale))
625
+ .toLocaleString(luxon.DateTime.DATE_MED))))), " ", state === "AVAILABLE" && reward.dateExpires && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateExpires)
626
+ .setLocale(luxonLocale(this.locale))
627
+ .toLocaleString(luxon.DateTime.DATE_MED))))), reward.fuelTankCode && (h$1("div", null, this.fuelTankText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, reward.fuelTankCode))))));
608
628
  });
609
- return (h$1("sl-details", { class: sheet.classes.Details, disabled: this.hideDetails }, h$1("style", { type: "text/css" }, styleString), h$1("div", { slot: "summary", class: sheet.classes.DetailsContainer }, h$1(TextSpanView, { type: "p" }, h$1("span", { part: "sqm-cell-value", class: sheet.classes.BoldText }, reward.prettyValue)), h$1("div", { class: sheet.classes.BadgeContainer }, state === "PENDING" && reward.dateScheduledFor ? (h$1("sl-badge", { class: slBadgeType === "primary"
610
- ? sheet.classes.RedeemBadge
611
- : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, intl.formatMessage({
612
- id: "pendingForText",
613
- defaultMessage: this.pendingForText,
614
- }, {
615
- status: badgeText,
616
- date: getTimeDiff(reward.dateScheduledFor),
617
- }))) : (h$1("sl-badge", { class: slBadgeType === "primary"
618
- ? sheet.classes.RedeemBadge
619
- : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, badgeText)), reward.dateExpires && state === "AVAILABLE" && (h$1("sl-badge", { class: slBadgeType === "primary"
620
- ? sheet.classes.RedeemBadge
621
- : sheet.classes.StatusBadge, type: "info", pill: true }, this.expiringText, ` ${getTimeDiff(reward.dateExpires)}`)))), h$1("div", null, state === "PENDING_REVIEW" && ((_a = reward.referral) === null || _a === void 0 ? void 0 : _a.dateModerated) && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.referral.dateModerated)
622
- .setLocale(luxonLocale(this.locale))
623
- .toLocaleString(luxon.DateTime.DATE_MED))))), state === "PAYOUT_APPROVED" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_FAILED" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_CANCELLED" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_REVIEW" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_NEW_TAX_FORM" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_SUBMISSION" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_PARTNER_CREATION" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "DENIED" && ((_b = reward.referral) === null || _b === void 0 ? void 0 : _b.dateModerated) && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.referral.dateModerated)
624
- .setLocale(luxonLocale(this.locale))
625
- .toLocaleString(luxon.DateTime.DATE_MED)), ".", this.deniedHelpText ? ` ${this.deniedHelpText}` : ``))), reward.dateGiven && (h$1("div", null, h$1(TextSpanView, { type: "p" }, this.rewardReceivedText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateGiven)
626
- .setLocale(luxonLocale(this.locale))
627
- .toLocaleString(luxon.DateTime.DATE_MED))))), state === "EXPIRED" && reward.dateExpires && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateExpires)
628
- .setLocale(luxonLocale(this.locale))
629
- .toLocaleString(luxon.DateTime.DATE_MED))))), state === "CANCELLED" && reward.dateCancelled && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateCancelled)
630
- .setLocale(luxonLocale(this.locale))
631
- .toLocaleString(luxon.DateTime.DATE_MED))))), state === "PENDING" && reward.dateScheduledFor && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateScheduledFor)
632
- .setLocale(luxonLocale(this.locale))
633
- .toLocaleString(luxon.DateTime.DATE_MED))))), " ", state === "AVAILABLE" && reward.dateExpires && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateExpires)
634
- .setLocale(luxonLocale(this.locale))
635
- .toLocaleString(luxon.DateTime.DATE_MED))))), reward.fuelTankCode && (h$1("div", null, this.fuelTankText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, reward.fuelTankCode))))));
636
- });
629
+ }, [this.statusText]);
630
+ return rewardMap;
637
631
  }
638
632
  };
639
633
 
@@ -1 +1 @@
1
- var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++){t=arguments[r];for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))e[n]=t[n]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,r,a){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,l){function i(e){try{o(a.next(e))}catch(e){l(e)}}function s(e){try{o(a["throw"](e))}catch(e){l(e)}}function o(e){e.done?r(e.value):n(e.value).then(i,s)}o((a=a.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,n,l,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(e){return function(t){return o([e,t])}}function o(i){if(a)throw new TypeError("Generator is already executing.");while(r)try{if(a=1,n&&(l=i[0]&2?n["return"]:i[0]?n["throw"]||((l=n["return"])&&l.call(n),0):n.next)&&!(l=l.call(n,i[1])).done)return l;if(n=0,l)i=[i[0]&2,l.value];switch(i[0]){case 0:case 1:l=i;break;case 4:r.label++;return{value:i[1],done:false};case 5:r.label++;n=i[1];i=[0];continue;case 7:i=r.ops.pop();r.trys.pop();continue;default:if(!(l=r.trys,l=l.length>0&&l[l.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!l||i[1]>l[0]&&i[1]<l[3])){r.label=i[1];break}if(i[0]===6&&r.label<l[1]){r.label=l[1];l=i;break}if(l&&r.label<l[2]){r.label=l[2];r.ops.push(i);break}if(l[2])r.ops.pop();r.trys.pop();continue}i=t.call(e,r)}catch(e){i=[6,e];n=0}finally{a=l=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};var __spreadArrays=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var a=Array(e),n=0,t=0;t<r;t++)for(var l=arguments[t],i=0,s=l.length;i<s;i++,n++)a[n]=l[i];return a};import{r as registerInstance,h as h$1,g as getElement,c as Host}from"./index-17b4da69.js";import{n as h,j as useReducer,u as useMemo,f as useEffect}from"./stencil-hooks.module-ac12ca1c.js";import{i as intl}from"./global-04c7d3b5.js";import{i as isDemo}from"./index.module-def4aec5.js";import{c as cjs}from"./cjs-bdfb4486.js";import"./mixins-f60a614c.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{G as GenericTableView}from"./GenericTableView-d59d8ab4.js";import{a as useRequestRerender,u as useRerenderListener}from"./re-render-12fd274a.js";import{u as useChildElements}from"./useChildElements-32e1bda1.js";import{l as luxon}from"./luxon-7600be8d.js";import{g as getPaypalMeta}from"./mockRewardData-0eb6e778.js";import{u as useReferralTable,t as tryMethod}from"./useReferralTable-f4de0650.js";import{l as luxonLocale}from"./utils-334c1e34.js";import{T as TextSpanView}from"./sqm-text-span-view-8d140661.js";var mockReferralData=function(e){if(e===void 0){e=4}var t=__spreadArrays(Array(e)).map((function(){return getMockData()}));return{totalCount:6,count:e,referredByReferral:{dateConverted:null,dateReferralStarted:1643912659850,referrerUser:{firstName:"John",lastName:"Snow",rewards:[]}},data:t}};var statuses=[["AVAILABLE"],["PENDING"],["CANCELLED"],["EXPIRED"],["REDEEMED"]];var firstNames=["Rajesh","Pierre","Ji-Ho","Chinua","Charleston","Sally","Gael","Jill","Jane","Khadija"];var lastNames=["Smith","Parker","Kent","Chew","Stark","Banner","Jones","Odinson","Pym","Rogers"];var getMockData=function(){return{id:"5cae6b0fcc540e209db45b53",referredUser:{id:"5cae6b0ce4b0d81c67b78e82",accountId:"SPX1MZBIPTFL3E1H",firstName:firstNames[Math.floor(Math.random()*firstNames.length)],lastName:lastNames[Math.floor(Math.random()*lastNames.length)],email:"example.uexwltgh@mailosaur.io",programGoals:[]},shareLinkUsed:null,referralCodeUsed:"JIMBONEUTRON2",moderationStatus:"PENDING",dateConverted:Math.floor(Math.random()*10)>=5?luxon.DateTime.now().minus({days:6}).toMillis():null,dateFraudChecksCompleted:null,dateModerated:1558730033306,dateModified:1554934543447,dateReferralEnded:null,dateReferralPaid:null,dateReferralStarted:luxon.DateTime.now().minus({days:8}).toMillis(),dateUserModified:null,programId:"sam-partner-test-2",program:{id:"sam-partner-test-2",name:"Partner Program 2.0"},rewards:Math.floor(Math.random()*10)>=5?[{id:"5cae6b16cc540e209db45cfa",type:"CREDIT",value:1,unit:"POINT",name:"Partner Reward",dateGiven:1554934550726,dateExpires:null,dateCancelled:null,dateRedeemed:1637004373582,dateScheduledFor:null,fuelTankCode:null,fuelTankType:null,currency:null,prettyValue:"1 Point",statuses:statuses[Math.floor(Math.random()*statuses.length)],globalRewardKey:null,programRewardKey:"partnerReward",meta:__assign({},getPaypalMeta()),rewardRedemptionTransactions:{data:[{exchangedRewards:{data:[{prettyValue:"CAD10.00 Visa* Prepaid Card CAD",type:"INTEGRATION",fuelTankCode:null,globalRewardKey:"gc1"}]}}]}}]:[],childNodes:{data:[{data:{id:"5cae6b16cc540e209db45cb3",statuses:statuses[Math.floor(Math.random()*statuses.length)],type:"PCT_DISCOUNT",value:50},depth:1},{data:{id:"5cae6b16cc540e209db45cfa",statuses:statuses[Math.floor(Math.random()*statuses.length)],type:"CREDIT",value:1},depth:1}]}}};var ReferralTable=function(){function e(e){registerInstance(this,e);this.perPage=4;this.hideLabels=false;this.prevLabel="Prev";this.moreLabel="Next";this.showReferrer=false;this.hiddenColumns="0";this.smBreakpoint=599;this.mdBreakpoint=799;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=h$1(EmptySlot,null);var t=h$1(LoadingSlot,null);var r=isDemo()?useReferralTableDemo(this,e,t):useReferralTable(this,e,t),a=r.states,n=r.data,l=r.callbacks,i=r.elements;useRequestRerender([this.showReferrer,this.perPage]);return h$1(GenericTableView,{states:a,data:n,callbacks:l,elements:i})};return e}();function EmptySlot(){return h$1("slot",{name:"empty"},h$1("sqm-empty",{"empty-state-image":"https://res.cloudinary.com/saasquatch/image/upload/v1644000223/squatch-assets/empty_referral2.png","empty-state-header":"View your referral details","empty-state-text":"Refer a friend to view the status of your referrals and rewards earned"}))}function LoadingSlot(){return h$1("slot",{name:"loading"},h$1(LoadingRow,null),h$1(LoadingRow,null),h$1(LoadingRow,null),h$1(LoadingRow,null))}function LoadingRow(){return h$1("sqm-table-row",null,h$1("sqm-table-cell",{colspan:5},h$1("sl-skeleton",null)))}function useReferralTableDemo(e,t,r){var a=useReducer((function(e,t){return __assign(__assign({},e),t)}),{columns:[],rows:[],loading:false,page:0}),n=a[0],l=a[1];var i=useRerenderListener();var s=useMemo((function(){var t;return((t=e.demoData)===null||t===void 0?void 0:t.mockData)||mockReferralData(e.perPage)}),[e.perPage]);var o=useChildElements();function u(t){return __awaiter(this,void 0,void 0,(function(){var r,a,n,i,o,u,d,c,f,h,p,v,m,T;var _=this;return __generator(this,(function(E){switch(E.label){case 0:n=s===null||s===void 0?void 0:s.referredByReferral;i=e.showReferrer&&!!((r=s===null||s===void 0?void 0:s.referredByReferral)===null||r===void 0?void 0:r.dateReferralStarted);if(i){a=s.data.slice(0,e.perPage-1)}else{a=s.data.slice(0,e.perPage)}o=t.filter((function(e){var t,r;return e.slot!=="loading"&&e.slot!=="empty"&&((t=e===null||e===void 0?void 0:e.firstElementChild)===null||t===void 0?void 0:t.getAttribute("slot"))!=="loading"&&((r=e===null||e===void 0?void 0:e.firstElementChild)===null||r===void 0?void 0:r.getAttribute("slot"))!=="empty"}));u=o===null||o===void 0?void 0:o.map((function(e,t){return __awaiter(_,void 0,void 0,(function(){var r,a,n;return __generator(this,(function(l){a=(r=e===null||e===void 0?void 0:e.firstElementChild)===null||r===void 0?void 0:r.getAttribute("slot");if(e.tagName==="RAISINS-PLOP-TARGET"&&a!=="loading"&&a!=="empty"){e.setAttribute("slot","column-"+t);e.style.position="absolute";n=e.firstElementChild.childNodes[1];n.innerHTML="+";n.style.lineHeight="20px";return[2,tryMethod(e,(function(){return e.renderLabel(t)}))]}return[2,tryMethod(e,(function(){return e.renderLabel()}))]}))}))}));if(!i)return[3,2];c=o===null||o===void 0?void 0:o.map((function(e){return __awaiter(_,void 0,void 0,(function(){return __generator(this,(function(t){return[2,tryMethod(e,(function t(){return e.renderCell(n,e)}))]}))}))}));return[4,Promise.all(c)];case 1:d=E.sent();E.label=2;case 2:f=a===null||a===void 0?void 0:a.map((function(e){return __awaiter(_,void 0,void 0,(function(){var t,r;var a=this;return __generator(this,(function(n){switch(n.label){case 0:t=o===null||o===void 0?void 0:o.map((function(t){return __awaiter(a,void 0,void 0,(function(){return __generator(this,(function(r){return[2,tryMethod(t,(function(){return t.renderCell(e,undefined)}))]}))}))}));return[4,Promise.all(t)];case 1:r=n.sent();return[2,r]}}))}))}));p=f;if(!p)return[3,4];v=[[d]];return[4,Promise.all(f)];case 3:p=__spreadArrays.apply(void 0,v.concat([E.sent()])).filter((function(e){return e}));E.label=4;case 4:h=p;l({rows:h});T=u;if(!T)return[3,6];return[4,Promise.all(u)];case 5:T=E.sent();E.label=6;case 6:m=T;l({columns:m,loading:false,page:0});return[2]}}))}))}useEffect((function(){l({loading:true});(s===null||s===void 0?void 0:s.data)&&u(o)}),[s===null||s===void 0?void 0:s.data,o,i]);var d=cjs({states:{hasPrev:false,hasNext:false,loading:false,show:"rows"},callbacks:{prevPage:function(){return console.log("Prev")},nextPage:function(){return console.log("Next")}},data:{textOverrides:{showLabels:!e.hideLabels,prevLabel:e.prevLabel,moreLabel:e.moreLabel},hiddenColumns:e.hiddenColumns,referralData:[],mdBreakpoint:799,smBreakpoint:599},elements:{columns:n.columns,rows:n.rows,emptyElement:t,loadingElement:r}},e.demoData||{},{arrayMerge:function(e,t){return t}});return d}var ReferralTableCell=function(){function e(e){registerInstance(this,e);this.ignored=true;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){return h$1("div",{innerHTML:this.innerTemplate})};return e}();var ReferralTableGenericColumn=function(){function e(e){registerInstance(this,e);h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,h$1("sqm-referral-table-cell",{"inner-template":getElement(this).innerHTML})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,Promise.resolve(this.columnTitle)]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle]);return h$1(Host,{style:{display:"none"}},h$1("slot",null))};return e}();var ReferralTableDateCell=function(){function e(e){registerInstance(this,e);this.ignored=true;this.locale="en";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e;var t=!this.date?"-":(e=luxon.DateTime.fromMillis(this.date))===null||e===void 0?void 0:e.setLocale(luxonLocale(this.locale)).toLocaleString(luxon.DateTime.DATE_MED);return t};return e}();var ReferralTableDateColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Date converted";this.dateShown="dateConverted";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,h$1("sqm-referral-table-date-cell",{date:e[this.dateShown],locale:t===null||t===void 0?void 0:t.locale})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,h$1("sqm-referral-table-date-cell",{date:e[this.dateShown]})]}))}))};e.prototype.render=function(){useRequestRerender([this.dateShown,this.columnTitle]);return h$1(Host,{style:{display:"none"}})};return e}();var ReferralTableRewardsCell=function(){function e(e){registerInstance(this,e);this.locale="en";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=this;var t;useRequestRerender([this.statusText,this.statusLongText,this.fuelTankText,this.rewardReceivedText,this.expiringText,this.pendingForText,this.hideDetails]);intl.locale=this.locale;var r={"@keyframes slideRight":{from:{opacity:0},to:{opacity:1}},DetailsContainer:{width:"100%",display:"flex","align-items":"center","justify-content":"space-between","margin-right":"var(--sl-spacing-small)","flex-wrap":"wrap"},Details:{"padding-bottom":"var(--sl-spacing-small)","max-width":"500px","&::part(header)":{padding:"var(--sl-spacing-x-small)",cursor:""+(this.hideDetails?"default":"pointer")},"&::part(content)":{padding:"var(--sl-spacing-x-small) var(--sl-spacing-medium)"},"&::part(base)":{opacity:"1"},"&::part(summary-icon)":{display:""+(this.hideDetails?"none":"flex")},"&::part(summary-icon[open])":{transform:"rotate(-90deg)",background:"red"}},BadgeContainer:{"& > :not(:last-child)":{"margin-right":"var(--sl-spacing-x-small)"}},BoldText:{"font-weight":"var(--sl-font-weight-semibold)"},StatusBadge:{paddingLeft:"var(--sl-spacing-xxx-small)","&::part(base)":{textAlign:"center",maxWidth:"170px",whiteSpace:"pre-line"}},RedeemBadge:{paddingLeft:"var(--sl-spacing-xxx-small)","&::part(base)":{background:"var(--sl-color-blue-600)"}}};var a=createStyleSheet(r);var n=a.toString();var l=function(e,t){var r,a,n,l,i,s,o,u,d,c,f,h;var p=["REDEEMED","CANCELLED","EXPIRED","PENDING","AVAILABLE","PENDING_REVIEW","DENIED","PAYOUT_APPROVED","PAYOUT_CANCELLED","PAYOUT_FAILED","PENDING_TAX_REVIEW","PENDING_NEW_TAX_FORM","PENDING_TAX_SUBMISSION","PENDING_PARTNER_CREATION"];if(((a=(r=e.referral)===null||r===void 0?void 0:r.fraudData)===null||a===void 0?void 0:a.moderationStatus)!=="APPROVED"){if(((l=(n=e.referral)===null||n===void 0?void 0:n.fraudData)===null||l===void 0?void 0:l.moderationStatus)==="PENDING")return"PENDING_REVIEW";if(((s=(i=e.referral)===null||i===void 0?void 0:i.fraudData)===null||s===void 0?void 0:s.moderationStatus)==="DENIED")return"DENIED"}var v=(o=e.partnerFundsTransfer)===null||o===void 0?void 0:o.status;if(v==="NOT_YET_DUE"||v==="TRANSFERRED"){return"PAYOUT_APPROVED"}else if(v==="OVERDUE")return"PAYOUT_FAILED";else if(v==="REVERSED")return"PAYOUT_CANCELLED";if((u=e===null||e===void 0?void 0:e.pendingReasons)===null||u===void 0?void 0:u.includes("US_TAX")){if(!(t===null||t===void 0?void 0:t.taxHandlingEnabled))return"PENDING";if(!(t===null||t===void 0?void 0:t.connected))return"PENDING_PARTNER_CREATION";if((d=t===null||t===void 0?void 0:t.publisher)===null||d===void 0?void 0:d.requiredTaxDocumentType){if(!((c=t===null||t===void 0?void 0:t.publisher)===null||c===void 0?void 0:c.currentTaxDocument))return"PENDING_TAX_SUBMISSION";var m=t.publisher.currentTaxDocument.status;if(m==="INACTIVE")return"PENDING_NEW_TAX_FORM";if(m==="NOT_VERIFIED")return"PENDING_TAX_REVIEW"}if(!((f=t===null||t===void 0?void 0:t.publisher)===null||f===void 0?void 0:f.withdrawalSettings))return"PENDING_PARTNER_CREATION"}if((h=e===null||e===void 0?void 0:e.pendingReasons)===null||h===void 0?void 0:h.includes("PAYOUT_CONFIGURATION_MISSING")){return"PENDING_PARTNER_CREATION"}if(e.statuses.length===1)return e.statuses[0];return p.find((function(t){return e.statuses.includes(t)&&t}))};var i=function(e){switch(e){case"REDEEMED":case"PAYOUT_APPROVED":return"primary";case"DENIED":case"EXPIRED":case"CANCELLED":case"PAYOUT_FAILED":case"PAYOUT_CANCELLED":return"danger";case"PENDING":case"PENDING_REVIEW":case"PENDING_TAX_REVIEW":case"PENDING_NEW_TAX_FORM":case"PENDING_TAX_SUBMISSION":case"PENDING_PARTNER_CREATION":return"warning";case"AVAILABLE":return"success"}};var s=function(t){return luxon.DateTime.fromMillis(t).setLocale(luxonLocale(e.locale)).toRelative().replace("in","").trim()};return(t=this.rewards)===null||t===void 0?void 0:t.map((function(t){var r,o;var u=l(t,e.taxConnection);var d=i(u);var c=intl.formatMessage({id:"statusShortMessage",defaultMessage:e.statusText},{status:u});console.log({state:u,intl:intl,badgeText:c,statusText:e.statusText,reward:t});var f=intl.formatMessage({id:"statusLongMessage",defaultMessage:e.statusLongText},{status:u});return h$1("sl-details",{class:a.classes.Details,disabled:e.hideDetails},h$1("style",{type:"text/css"},n),h$1("div",{slot:"summary",class:a.classes.DetailsContainer},h$1(TextSpanView,{type:"p"},h$1("span",{part:"sqm-cell-value",class:a.classes.BoldText},t.prettyValue)),h$1("div",{class:a.classes.BadgeContainer},u==="PENDING"&&t.dateScheduledFor?h$1("sl-badge",{class:d==="primary"?a.classes.RedeemBadge:a.classes.StatusBadge,type:d,pill:true},intl.formatMessage({id:"pendingForText",defaultMessage:e.pendingForText},{status:c,date:s(t.dateScheduledFor)})):h$1("sl-badge",{class:d==="primary"?a.classes.RedeemBadge:a.classes.StatusBadge,type:d,pill:true},c),t.dateExpires&&u==="AVAILABLE"&&h$1("sl-badge",{class:d==="primary"?a.classes.RedeemBadge:a.classes.StatusBadge,type:"info",pill:true},e.expiringText," "+s(t.dateExpires)))),h$1("div",null,u==="PENDING_REVIEW"&&((r=t.referral)===null||r===void 0?void 0:r.dateModerated)&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.referral.dateModerated).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="PAYOUT_APPROVED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PAYOUT_FAILED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PAYOUT_CANCELLED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_TAX_REVIEW"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_NEW_TAX_FORM"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_TAX_SUBMISSION"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_PARTNER_CREATION"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="DENIED"&&((o=t.referral)===null||o===void 0?void 0:o.dateModerated)&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.referral.dateModerated).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)),".",e.deniedHelpText?" "+e.deniedHelpText:"")),t.dateGiven&&h$1("div",null,h$1(TextSpanView,{type:"p"},e.rewardReceivedText," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateGiven).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="EXPIRED"&&t.dateExpires&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateExpires).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="CANCELLED"&&t.dateCancelled&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateCancelled).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="PENDING"&&t.dateScheduledFor&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateScheduledFor).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED))))," ",u==="AVAILABLE"&&t.dateExpires&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateExpires).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),t.fuelTankCode&&h$1("div",null,e.fuelTankText," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},t.fuelTankCode))))}))};return e}();var ReferralTableRewardsColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Rewards";this.statusText="{status, select, AVAILABLE {Available} CANCELLED {Cancelled} PENDING {Pending} PENDING_REVIEW {Pending} PAYOUT_APPROVED {Payout Approved} PAYOUT_FAILED {Payout Failed} PAYOUT_CANCELLED {Payout Cancelled} PENDING_TAX_REVIEW {Pending} PENDING_NEW_TAX_FORM {Pending} PENDING_TAX_SUBMISSION {Pending} PENDING_PARTNER_CREATION {Pending} DENIED {Denied} EXPIRED {Expired} REDEEMED {Redeemed} other {Not available} }";this.statusLongText="{status, select, AVAILABLE {Reward expiring on} CANCELLED {Reward cancelled on} PENDING {Available on} PENDING_REVIEW {Pending since} PAYOUT_APPROVED {Reward approved for payout and was scheduled for payment based on your settings.} PAYOUT_FAILED {Payout failed due to a fulfillment issue and is currently being retried.} PAYOUT_CANCELLED {If you think this is a mistake, contact our Support team.} PENDING_TAX_REVIEW {Awaiting tax form review} PENDING_NEW_TAX_FORM {Invalid tax form. Submit a new form to receive your rewards.} PENDING_TAX_SUBMISSION {Submit your tax documents to receive your rewards} PENDING_PARTNER_CREATION {Complete your tax and cash payout setup to receive your rewards} DENIED {Denied on} EXPIRED {Reward expired on} other {Not available} }";this.fuelTankText="Your code is";this.rewardReceivedText="Reward received on";this.expiringText="Expiring in";this.pendingForText="{status} for {date}";this.deniedHelpText="Contact support if you think this is a mistake.";this.hideDetails=false;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){console.log({statusText:this.statusText});return[2,h$1("sqm-referral-table-rewards-cell",{rewards:e.rewards,"tax-connection":t===null||t===void 0?void 0:t.taxConnection,"status-text":this.statusText,"status-long-text":this.statusLongText,"fuel-tank-text":this.fuelTankText,"reward-received-text":this.rewardReceivedText,"expiring-text":this.expiringText,"pending-for-text":this.pendingForText,"hide-details":this.hideDetails,"denied-help-text":this.deniedHelpText,locale:t===null||t===void 0?void 0:t.locale,exportparts:"sqm-cell-value"})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,h$1("sqm-referral-table-rewards-cell",{rewards:e.rewards,exportparts:"sqm-cell-value"})]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle,this.statusText,this.statusLongText,this.fuelTankText,this.rewardReceivedText,this.expiringText,this.pendingForText,this.hideDetails]);return h$1(Host,{style:{display:"none"}})};return e}();var style={Badge:{"&::part(base)":{fontSize:"var(--sl-font-size-small)",padding:"4px 8px",whiteSpace:"pre-line"}},SubText:{fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)",margin:"0"}};var sheet=createStyleSheet(style);var styleString=sheet.toString();var ReferralTableStatusCell=function(){function e(e){registerInstance(this,e)}e.prototype.render=function(){var e=this;var t=function(t){if(t==="PENDING")return"warning";if(t==="DENIED")return"danger";if(e.converted)return"success";return"warning"};return h$1("div",null,h$1("style",{type:"text/css"},styleString),h$1("sl-badge",{pill:true,type:t(this.fraudStatus),class:sheet.classes.Badge},this.statusText),this.statusSubText?h$1("p",{class:sheet.classes.SubText},this.statusSubText):null)};return e}();var ReferralTableStatusColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Status";this.convertedStatusText="Converted";this.inProgressStatusText="In Progress";this.pendingReviewStatusText="Pending";this.deniedStatusText="Denied";this.pendingReviewStatusSubText="Awaiting review";this.deniedStatusSubText="Detected self-referral";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n;return __generator(this,(function(l){n=(t=e===null||e===void 0?void 0:e.fraudData)===null||t===void 0?void 0:t.moderationStatus;if(n==="DENIED"){r=this.deniedStatusText;a=this.deniedStatusSubText}else if(n==="PENDING"){r=this.pendingReviewStatusText;a=this.pendingReviewStatusSubText}else{r=e.dateConverted?this.convertedStatusText:this.inProgressStatusText}return[2,h$1("sqm-referral-table-status-cell",{"status-text":r,"status-sub-text":a,"fraud-status":n,converted:e.dateConverted?true:false})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){t=e.dateConverted?this.convertedStatusText:this.inProgressStatusText;return[2,h$1("sqm-referral-table-status-cell",{"status-text":t,converted:e.dateConverted?true:false})]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle,this.convertedStatusText,this.inProgressStatusText]);return h$1(Host,{style:{display:"none"}})};return e}();var ReferralTableUserCell=function(){function e(e){registerInstance(this,e)}e.prototype.render=function(){return this.name};return e}();var ReferralTableUserColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Customer";this.anonymousUser="Anonymous User";this.deletedUser="Deleted User";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n,l,i,s,o,u;return __generator(this,(function(d){if(!(e===null||e===void 0?void 0:e.referredUser)&&!(e===null||e===void 0?void 0:e.referrerUser)){u=this.deletedUser}else if(!((t=e===null||e===void 0?void 0:e.referredUser)===null||t===void 0?void 0:t.firstName)&&!((r=e===null||e===void 0?void 0:e.referredUser)===null||r===void 0?void 0:r.lastName)&&!((a=e===null||e===void 0?void 0:e.referrerUser)===null||a===void 0?void 0:a.firstName)&&!((n=e===null||e===void 0?void 0:e.referrerUser)===null||n===void 0?void 0:n.lastName)){u=this.anonymousUser}else if(e===null||e===void 0?void 0:e.referrerUser){u=((l=e===null||e===void 0?void 0:e.referrerUser)===null||l===void 0?void 0:l.firstName)+" "+((i=e===null||e===void 0?void 0:e.referrerUser)===null||i===void 0?void 0:i.lastName)}else{u=((s=e===null||e===void 0?void 0:e.referredUser)===null||s===void 0?void 0:s.firstName)+" "+((o=e===null||e===void 0?void 0:e.referredUser)===null||o===void 0?void 0:o.lastName)}return[2,h$1("sqm-referral-table-user-cell",{name:u})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n,l;return __generator(this,(function(i){if(!e){l=this.deletedUser}else if(!((t=e===null||e===void 0?void 0:e.referrerUser)===null||t===void 0?void 0:t.firstName)&&!((r=e.referrerUser)===null||r===void 0?void 0:r.lastName)){l=this.anonymousUser}else{l=((a=e===null||e===void 0?void 0:e.referrerUser)===null||a===void 0?void 0:a.firstName)+" "+((n=e===null||e===void 0?void 0:e.referrerUser)===null||n===void 0?void 0:n.lastName)}return[2,h$1("sqm-referral-table-user-cell",{name:l})]}))}))};e.prototype.render=function(){useRequestRerender([this.deletedUser,this.anonymousUser,this.columnTitle]);return h$1(Host,{style:{display:"none"}})};return e}();export{ReferralTable as sqm_referral_table,ReferralTableCell as sqm_referral_table_cell,ReferralTableGenericColumn as sqm_referral_table_column,ReferralTableDateCell as sqm_referral_table_date_cell,ReferralTableDateColumn as sqm_referral_table_date_column,ReferralTableRewardsCell as sqm_referral_table_rewards_cell,ReferralTableRewardsColumn as sqm_referral_table_rewards_column,ReferralTableStatusCell as sqm_referral_table_status_cell,ReferralTableStatusColumn as sqm_referral_table_status_column,ReferralTableUserCell as sqm_referral_table_user_cell,ReferralTableUserColumn as sqm_referral_table_user_column};
1
+ var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++){t=arguments[r];for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))e[n]=t[n]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,r,a){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,l){function i(e){try{o(a.next(e))}catch(e){l(e)}}function s(e){try{o(a["throw"](e))}catch(e){l(e)}}function o(e){e.done?r(e.value):n(e.value).then(i,s)}o((a=a.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,n,l,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(e){return function(t){return o([e,t])}}function o(i){if(a)throw new TypeError("Generator is already executing.");while(r)try{if(a=1,n&&(l=i[0]&2?n["return"]:i[0]?n["throw"]||((l=n["return"])&&l.call(n),0):n.next)&&!(l=l.call(n,i[1])).done)return l;if(n=0,l)i=[i[0]&2,l.value];switch(i[0]){case 0:case 1:l=i;break;case 4:r.label++;return{value:i[1],done:false};case 5:r.label++;n=i[1];i=[0];continue;case 7:i=r.ops.pop();r.trys.pop();continue;default:if(!(l=r.trys,l=l.length>0&&l[l.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!l||i[1]>l[0]&&i[1]<l[3])){r.label=i[1];break}if(i[0]===6&&r.label<l[1]){r.label=l[1];l=i;break}if(l&&r.label<l[2]){r.label=l[2];r.ops.push(i);break}if(l[2])r.ops.pop();r.trys.pop();continue}i=t.call(e,r)}catch(e){i=[6,e];n=0}finally{a=l=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};var __spreadArrays=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var a=Array(e),n=0,t=0;t<r;t++)for(var l=arguments[t],i=0,s=l.length;i<s;i++,n++)a[n]=l[i];return a};import{r as registerInstance,h as h$1,g as getElement,c as Host}from"./index-17b4da69.js";import{n as h,j as useReducer,u as useMemo,f as useEffect}from"./stencil-hooks.module-ac12ca1c.js";import{i as intl}from"./global-04c7d3b5.js";import{i as isDemo}from"./index.module-def4aec5.js";import{c as cjs}from"./cjs-bdfb4486.js";import"./mixins-f60a614c.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{G as GenericTableView}from"./GenericTableView-d59d8ab4.js";import{a as useRequestRerender,u as useRerenderListener}from"./re-render-12fd274a.js";import{u as useChildElements}from"./useChildElements-32e1bda1.js";import{l as luxon}from"./luxon-7600be8d.js";import{g as getPaypalMeta}from"./mockRewardData-0eb6e778.js";import{u as useReferralTable,t as tryMethod}from"./useReferralTable-f4de0650.js";import{l as luxonLocale}from"./utils-334c1e34.js";import{T as TextSpanView}from"./sqm-text-span-view-8d140661.js";var mockReferralData=function(e){if(e===void 0){e=4}var t=__spreadArrays(Array(e)).map((function(){return getMockData()}));return{totalCount:6,count:e,referredByReferral:{dateConverted:null,dateReferralStarted:1643912659850,referrerUser:{firstName:"John",lastName:"Snow",rewards:[]}},data:t}};var statuses=[["AVAILABLE"],["PENDING"],["CANCELLED"],["EXPIRED"],["REDEEMED"]];var firstNames=["Rajesh","Pierre","Ji-Ho","Chinua","Charleston","Sally","Gael","Jill","Jane","Khadija"];var lastNames=["Smith","Parker","Kent","Chew","Stark","Banner","Jones","Odinson","Pym","Rogers"];var getMockData=function(){return{id:"5cae6b0fcc540e209db45b53",referredUser:{id:"5cae6b0ce4b0d81c67b78e82",accountId:"SPX1MZBIPTFL3E1H",firstName:firstNames[Math.floor(Math.random()*firstNames.length)],lastName:lastNames[Math.floor(Math.random()*lastNames.length)],email:"example.uexwltgh@mailosaur.io",programGoals:[]},shareLinkUsed:null,referralCodeUsed:"JIMBONEUTRON2",moderationStatus:"PENDING",dateConverted:Math.floor(Math.random()*10)>=5?luxon.DateTime.now().minus({days:6}).toMillis():null,dateFraudChecksCompleted:null,dateModerated:1558730033306,dateModified:1554934543447,dateReferralEnded:null,dateReferralPaid:null,dateReferralStarted:luxon.DateTime.now().minus({days:8}).toMillis(),dateUserModified:null,programId:"sam-partner-test-2",program:{id:"sam-partner-test-2",name:"Partner Program 2.0"},rewards:Math.floor(Math.random()*10)>=5?[{id:"5cae6b16cc540e209db45cfa",type:"CREDIT",value:1,unit:"POINT",name:"Partner Reward",dateGiven:1554934550726,dateExpires:null,dateCancelled:null,dateRedeemed:1637004373582,dateScheduledFor:null,fuelTankCode:null,fuelTankType:null,currency:null,prettyValue:"1 Point",statuses:statuses[Math.floor(Math.random()*statuses.length)],globalRewardKey:null,programRewardKey:"partnerReward",meta:__assign({},getPaypalMeta()),rewardRedemptionTransactions:{data:[{exchangedRewards:{data:[{prettyValue:"CAD10.00 Visa* Prepaid Card CAD",type:"INTEGRATION",fuelTankCode:null,globalRewardKey:"gc1"}]}}]}}]:[],childNodes:{data:[{data:{id:"5cae6b16cc540e209db45cb3",statuses:statuses[Math.floor(Math.random()*statuses.length)],type:"PCT_DISCOUNT",value:50},depth:1},{data:{id:"5cae6b16cc540e209db45cfa",statuses:statuses[Math.floor(Math.random()*statuses.length)],type:"CREDIT",value:1},depth:1}]}}};var ReferralTable=function(){function e(e){registerInstance(this,e);this.perPage=4;this.hideLabels=false;this.prevLabel="Prev";this.moreLabel="Next";this.showReferrer=false;this.hiddenColumns="0";this.smBreakpoint=599;this.mdBreakpoint=799;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=h$1(EmptySlot,null);var t=h$1(LoadingSlot,null);var r=isDemo()?useReferralTableDemo(this,e,t):useReferralTable(this,e,t),a=r.states,n=r.data,l=r.callbacks,i=r.elements;useRequestRerender([this.showReferrer,this.perPage]);return h$1(GenericTableView,{states:a,data:n,callbacks:l,elements:i})};return e}();function EmptySlot(){return h$1("slot",{name:"empty"},h$1("sqm-empty",{"empty-state-image":"https://res.cloudinary.com/saasquatch/image/upload/v1644000223/squatch-assets/empty_referral2.png","empty-state-header":"View your referral details","empty-state-text":"Refer a friend to view the status of your referrals and rewards earned"}))}function LoadingSlot(){return h$1("slot",{name:"loading"},h$1(LoadingRow,null),h$1(LoadingRow,null),h$1(LoadingRow,null),h$1(LoadingRow,null))}function LoadingRow(){return h$1("sqm-table-row",null,h$1("sqm-table-cell",{colspan:5},h$1("sl-skeleton",null)))}function useReferralTableDemo(e,t,r){var a=useReducer((function(e,t){return __assign(__assign({},e),t)}),{columns:[],rows:[],loading:false,page:0}),n=a[0],l=a[1];var i=useRerenderListener();var s=useMemo((function(){var t;return((t=e.demoData)===null||t===void 0?void 0:t.mockData)||mockReferralData(e.perPage)}),[e.perPage]);var o=useChildElements();function u(t){return __awaiter(this,void 0,void 0,(function(){var r,a,n,i,o,u,d,c,f,h,p,v,m,T;var _=this;return __generator(this,(function(E){switch(E.label){case 0:n=s===null||s===void 0?void 0:s.referredByReferral;i=e.showReferrer&&!!((r=s===null||s===void 0?void 0:s.referredByReferral)===null||r===void 0?void 0:r.dateReferralStarted);if(i){a=s.data.slice(0,e.perPage-1)}else{a=s.data.slice(0,e.perPage)}o=t.filter((function(e){var t,r;return e.slot!=="loading"&&e.slot!=="empty"&&((t=e===null||e===void 0?void 0:e.firstElementChild)===null||t===void 0?void 0:t.getAttribute("slot"))!=="loading"&&((r=e===null||e===void 0?void 0:e.firstElementChild)===null||r===void 0?void 0:r.getAttribute("slot"))!=="empty"}));u=o===null||o===void 0?void 0:o.map((function(e,t){return __awaiter(_,void 0,void 0,(function(){var r,a,n;return __generator(this,(function(l){a=(r=e===null||e===void 0?void 0:e.firstElementChild)===null||r===void 0?void 0:r.getAttribute("slot");if(e.tagName==="RAISINS-PLOP-TARGET"&&a!=="loading"&&a!=="empty"){e.setAttribute("slot","column-"+t);e.style.position="absolute";n=e.firstElementChild.childNodes[1];n.innerHTML="+";n.style.lineHeight="20px";return[2,tryMethod(e,(function(){return e.renderLabel(t)}))]}return[2,tryMethod(e,(function(){return e.renderLabel()}))]}))}))}));if(!i)return[3,2];c=o===null||o===void 0?void 0:o.map((function(e){return __awaiter(_,void 0,void 0,(function(){return __generator(this,(function(t){return[2,tryMethod(e,(function t(){return e.renderCell(n,e)}))]}))}))}));return[4,Promise.all(c)];case 1:d=E.sent();E.label=2;case 2:f=a===null||a===void 0?void 0:a.map((function(e){return __awaiter(_,void 0,void 0,(function(){var t,r;var a=this;return __generator(this,(function(n){switch(n.label){case 0:t=o===null||o===void 0?void 0:o.map((function(t){return __awaiter(a,void 0,void 0,(function(){return __generator(this,(function(r){return[2,tryMethod(t,(function(){return t.renderCell(e,undefined)}))]}))}))}));return[4,Promise.all(t)];case 1:r=n.sent();return[2,r]}}))}))}));p=f;if(!p)return[3,4];v=[[d]];return[4,Promise.all(f)];case 3:p=__spreadArrays.apply(void 0,v.concat([E.sent()])).filter((function(e){return e}));E.label=4;case 4:h=p;l({rows:h});T=u;if(!T)return[3,6];return[4,Promise.all(u)];case 5:T=E.sent();E.label=6;case 6:m=T;l({columns:m,loading:false,page:0});return[2]}}))}))}useEffect((function(){l({loading:true});(s===null||s===void 0?void 0:s.data)&&u(o)}),[s===null||s===void 0?void 0:s.data,o,i]);var d=cjs({states:{hasPrev:false,hasNext:false,loading:false,show:"rows"},callbacks:{prevPage:function(){return console.log("Prev")},nextPage:function(){return console.log("Next")}},data:{textOverrides:{showLabels:!e.hideLabels,prevLabel:e.prevLabel,moreLabel:e.moreLabel},hiddenColumns:e.hiddenColumns,referralData:[],mdBreakpoint:799,smBreakpoint:599},elements:{columns:n.columns,rows:n.rows,emptyElement:t,loadingElement:r}},e.demoData||{},{arrayMerge:function(e,t){return t}});return d}var ReferralTableCell=function(){function e(e){registerInstance(this,e);this.ignored=true;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){return h$1("div",{innerHTML:this.innerTemplate})};return e}();var ReferralTableGenericColumn=function(){function e(e){registerInstance(this,e);h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,h$1("sqm-referral-table-cell",{"inner-template":getElement(this).innerHTML})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,Promise.resolve(this.columnTitle)]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle]);return h$1(Host,{style:{display:"none"}},h$1("slot",null))};return e}();var ReferralTableDateCell=function(){function e(e){registerInstance(this,e);this.ignored=true;this.locale="en";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e;var t=!this.date?"-":(e=luxon.DateTime.fromMillis(this.date))===null||e===void 0?void 0:e.setLocale(luxonLocale(this.locale)).toLocaleString(luxon.DateTime.DATE_MED);return t};return e}();var ReferralTableDateColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Date converted";this.dateShown="dateConverted";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,h$1("sqm-referral-table-date-cell",{date:e[this.dateShown],locale:t===null||t===void 0?void 0:t.locale})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,h$1("sqm-referral-table-date-cell",{date:e[this.dateShown]})]}))}))};e.prototype.render=function(){useRequestRerender([this.dateShown,this.columnTitle]);return h$1(Host,{style:{display:"none"}})};return e}();var ReferralTableRewardsCell=function(){function e(e){registerInstance(this,e);this.locale="en";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=this;intl.locale=this.locale;var t={"@keyframes slideRight":{from:{opacity:0},to:{opacity:1}},DetailsContainer:{width:"100%",display:"flex","align-items":"center","justify-content":"space-between","margin-right":"var(--sl-spacing-small)","flex-wrap":"wrap"},Details:{"padding-bottom":"var(--sl-spacing-small)","max-width":"500px","&::part(header)":{padding:"var(--sl-spacing-x-small)",cursor:""+(this.hideDetails?"default":"pointer")},"&::part(content)":{padding:"var(--sl-spacing-x-small) var(--sl-spacing-medium)"},"&::part(base)":{opacity:"1"},"&::part(summary-icon)":{display:""+(this.hideDetails?"none":"flex")},"&::part(summary-icon[open])":{transform:"rotate(-90deg)",background:"red"}},BadgeContainer:{"& > :not(:last-child)":{"margin-right":"var(--sl-spacing-x-small)"}},BoldText:{"font-weight":"var(--sl-font-weight-semibold)"},StatusBadge:{paddingLeft:"var(--sl-spacing-xxx-small)","&::part(base)":{textAlign:"center",maxWidth:"170px",whiteSpace:"pre-line"}},RedeemBadge:{paddingLeft:"var(--sl-spacing-xxx-small)","&::part(base)":{background:"var(--sl-color-blue-600)"}}};var r=createStyleSheet(t);var a=r.toString();var n=function(e,t){var r,a,n,l,i,s,o,u,d,c,f,h;var p=["REDEEMED","CANCELLED","EXPIRED","PENDING","AVAILABLE","PENDING_REVIEW","DENIED","PAYOUT_APPROVED","PAYOUT_CANCELLED","PAYOUT_FAILED","PENDING_TAX_REVIEW","PENDING_NEW_TAX_FORM","PENDING_TAX_SUBMISSION","PENDING_PARTNER_CREATION"];if(((a=(r=e.referral)===null||r===void 0?void 0:r.fraudData)===null||a===void 0?void 0:a.moderationStatus)!=="APPROVED"){if(((l=(n=e.referral)===null||n===void 0?void 0:n.fraudData)===null||l===void 0?void 0:l.moderationStatus)==="PENDING")return"PENDING_REVIEW";if(((s=(i=e.referral)===null||i===void 0?void 0:i.fraudData)===null||s===void 0?void 0:s.moderationStatus)==="DENIED")return"DENIED"}var v=(o=e.partnerFundsTransfer)===null||o===void 0?void 0:o.status;if(v==="NOT_YET_DUE"||v==="TRANSFERRED"){return"PAYOUT_APPROVED"}else if(v==="OVERDUE")return"PAYOUT_FAILED";else if(v==="REVERSED")return"PAYOUT_CANCELLED";if((u=e===null||e===void 0?void 0:e.pendingReasons)===null||u===void 0?void 0:u.includes("US_TAX")){if(!(t===null||t===void 0?void 0:t.taxHandlingEnabled))return"PENDING";if(!(t===null||t===void 0?void 0:t.connected))return"PENDING_PARTNER_CREATION";if((d=t===null||t===void 0?void 0:t.publisher)===null||d===void 0?void 0:d.requiredTaxDocumentType){if(!((c=t===null||t===void 0?void 0:t.publisher)===null||c===void 0?void 0:c.currentTaxDocument))return"PENDING_TAX_SUBMISSION";var m=t.publisher.currentTaxDocument.status;if(m==="INACTIVE")return"PENDING_NEW_TAX_FORM";if(m==="NOT_VERIFIED")return"PENDING_TAX_REVIEW"}if(!((f=t===null||t===void 0?void 0:t.publisher)===null||f===void 0?void 0:f.withdrawalSettings))return"PENDING_PARTNER_CREATION"}if((h=e===null||e===void 0?void 0:e.pendingReasons)===null||h===void 0?void 0:h.includes("PAYOUT_CONFIGURATION_MISSING")){return"PENDING_PARTNER_CREATION"}if(e.statuses.length===1)return e.statuses[0];return p.find((function(t){return e.statuses.includes(t)&&t}))};var l=function(e){switch(e){case"REDEEMED":case"PAYOUT_APPROVED":return"primary";case"DENIED":case"EXPIRED":case"CANCELLED":case"PAYOUT_FAILED":case"PAYOUT_CANCELLED":return"danger";case"PENDING":case"PENDING_REVIEW":case"PENDING_TAX_REVIEW":case"PENDING_NEW_TAX_FORM":case"PENDING_TAX_SUBMISSION":case"PENDING_PARTNER_CREATION":return"warning";case"AVAILABLE":return"success"}};var i=function(t){return luxon.DateTime.fromMillis(t).setLocale(luxonLocale(e.locale)).toRelative().replace("in","").trim()};var s=useMemo((function(){var t;return(t=e.rewards)===null||t===void 0?void 0:t.map((function(t){var s,o;var u=n(t,e.taxConnection);var d=l(u);var c=intl.formatMessage({id:"statusShortMessage",defaultMessage:e.statusText},{status:u});console.log({state:u,intl:intl,badgeText:c,statusText:e.statusText,reward:t});var f=intl.formatMessage({id:"statusLongMessage",defaultMessage:e.statusLongText},{status:u});return h$1("sl-details",{class:r.classes.Details,disabled:e.hideDetails},h$1("style",{type:"text/css"},a),h$1("div",{slot:"summary",class:r.classes.DetailsContainer},h$1(TextSpanView,{type:"p"},h$1("span",{part:"sqm-cell-value",class:r.classes.BoldText},t.prettyValue)),h$1("div",{class:r.classes.BadgeContainer},u==="PENDING"&&t.dateScheduledFor?h$1("sl-badge",{class:d==="primary"?r.classes.RedeemBadge:r.classes.StatusBadge,type:d,pill:true},intl.formatMessage({id:"pendingForText",defaultMessage:e.pendingForText},{status:c,date:i(t.dateScheduledFor)})):h$1("sl-badge",{class:d==="primary"?r.classes.RedeemBadge:r.classes.StatusBadge,type:d,pill:true},c),t.dateExpires&&u==="AVAILABLE"&&h$1("sl-badge",{class:d==="primary"?r.classes.RedeemBadge:r.classes.StatusBadge,type:"info",pill:true},e.expiringText," "+i(t.dateExpires)))),h$1("div",null,u==="PENDING_REVIEW"&&((s=t.referral)===null||s===void 0?void 0:s.dateModerated)&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:r.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.referral.dateModerated).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="PAYOUT_APPROVED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PAYOUT_FAILED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PAYOUT_CANCELLED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_TAX_REVIEW"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_NEW_TAX_FORM"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_TAX_SUBMISSION"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_PARTNER_CREATION"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="DENIED"&&((o=t.referral)===null||o===void 0?void 0:o.dateModerated)&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:r.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.referral.dateModerated).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)),".",e.deniedHelpText?" "+e.deniedHelpText:"")),t.dateGiven&&h$1("div",null,h$1(TextSpanView,{type:"p"},e.rewardReceivedText," ",h$1("span",{class:r.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateGiven).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="EXPIRED"&&t.dateExpires&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:r.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateExpires).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="CANCELLED"&&t.dateCancelled&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:r.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateCancelled).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="PENDING"&&t.dateScheduledFor&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:r.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateScheduledFor).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED))))," ",u==="AVAILABLE"&&t.dateExpires&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:r.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateExpires).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),t.fuelTankCode&&h$1("div",null,e.fuelTankText," ",h$1("span",{class:r.classes.BoldText,part:"sqm-cell-value"},t.fuelTankCode))))}))}),[this.statusText]);return s};return e}();var ReferralTableRewardsColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Rewards";this.statusText="{status, select, AVAILABLE {Available} CANCELLED {Cancelled} PENDING {Pending} PENDING_REVIEW {Pending} PAYOUT_APPROVED {Payout Approved} PAYOUT_FAILED {Payout Failed} PAYOUT_CANCELLED {Payout Cancelled} PENDING_TAX_REVIEW {Pending} PENDING_NEW_TAX_FORM {Pending} PENDING_TAX_SUBMISSION {Pending} PENDING_PARTNER_CREATION {Pending} DENIED {Denied} EXPIRED {Expired} REDEEMED {Redeemed} other {Not available} }";this.statusLongText="{status, select, AVAILABLE {Reward expiring on} CANCELLED {Reward cancelled on} PENDING {Available on} PENDING_REVIEW {Pending since} PAYOUT_APPROVED {Reward approved for payout and was scheduled for payment based on your settings.} PAYOUT_FAILED {Payout failed due to a fulfillment issue and is currently being retried.} PAYOUT_CANCELLED {If you think this is a mistake, contact our Support team.} PENDING_TAX_REVIEW {Awaiting tax form review} PENDING_NEW_TAX_FORM {Invalid tax form. Submit a new form to receive your rewards.} PENDING_TAX_SUBMISSION {Submit your tax documents to receive your rewards} PENDING_PARTNER_CREATION {Complete your tax and cash payout setup to receive your rewards} DENIED {Denied on} EXPIRED {Reward expired on} other {Not available} }";this.fuelTankText="Your code is";this.rewardReceivedText="Reward received on";this.expiringText="Expiring in";this.pendingForText="{status} for {date}";this.deniedHelpText="Contact support if you think this is a mistake.";this.hideDetails=false;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){console.log({statusText:this.statusText});return[2,h$1("sqm-referral-table-rewards-cell",{rewards:e.rewards,"tax-connection":t===null||t===void 0?void 0:t.taxConnection,"status-text":this.statusText,"status-long-text":this.statusLongText,"fuel-tank-text":this.fuelTankText,"reward-received-text":this.rewardReceivedText,"expiring-text":this.expiringText,"pending-for-text":this.pendingForText,"hide-details":this.hideDetails,"denied-help-text":this.deniedHelpText,locale:t===null||t===void 0?void 0:t.locale,exportparts:"sqm-cell-value"})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,h$1("sqm-referral-table-rewards-cell",{rewards:e.rewards,exportparts:"sqm-cell-value"})]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle,this.statusText,this.statusLongText,this.fuelTankText,this.rewardReceivedText,this.expiringText,this.pendingForText,this.hideDetails]);return h$1(Host,{style:{display:"none"}})};return e}();var style={Badge:{"&::part(base)":{fontSize:"var(--sl-font-size-small)",padding:"4px 8px",whiteSpace:"pre-line"}},SubText:{fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)",margin:"0"}};var sheet=createStyleSheet(style);var styleString=sheet.toString();var ReferralTableStatusCell=function(){function e(e){registerInstance(this,e)}e.prototype.render=function(){var e=this;var t=function(t){if(t==="PENDING")return"warning";if(t==="DENIED")return"danger";if(e.converted)return"success";return"warning"};return h$1("div",null,h$1("style",{type:"text/css"},styleString),h$1("sl-badge",{pill:true,type:t(this.fraudStatus),class:sheet.classes.Badge},this.statusText),this.statusSubText?h$1("p",{class:sheet.classes.SubText},this.statusSubText):null)};return e}();var ReferralTableStatusColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Status";this.convertedStatusText="Converted";this.inProgressStatusText="In Progress";this.pendingReviewStatusText="Pending";this.deniedStatusText="Denied";this.pendingReviewStatusSubText="Awaiting review";this.deniedStatusSubText="Detected self-referral";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n;return __generator(this,(function(l){n=(t=e===null||e===void 0?void 0:e.fraudData)===null||t===void 0?void 0:t.moderationStatus;if(n==="DENIED"){r=this.deniedStatusText;a=this.deniedStatusSubText}else if(n==="PENDING"){r=this.pendingReviewStatusText;a=this.pendingReviewStatusSubText}else{r=e.dateConverted?this.convertedStatusText:this.inProgressStatusText}return[2,h$1("sqm-referral-table-status-cell",{"status-text":r,"status-sub-text":a,"fraud-status":n,converted:e.dateConverted?true:false})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){t=e.dateConverted?this.convertedStatusText:this.inProgressStatusText;return[2,h$1("sqm-referral-table-status-cell",{"status-text":t,converted:e.dateConverted?true:false})]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle,this.convertedStatusText,this.inProgressStatusText]);return h$1(Host,{style:{display:"none"}})};return e}();var ReferralTableUserCell=function(){function e(e){registerInstance(this,e)}e.prototype.render=function(){return this.name};return e}();var ReferralTableUserColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Customer";this.anonymousUser="Anonymous User";this.deletedUser="Deleted User";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n,l,i,s,o,u;return __generator(this,(function(d){if(!(e===null||e===void 0?void 0:e.referredUser)&&!(e===null||e===void 0?void 0:e.referrerUser)){u=this.deletedUser}else if(!((t=e===null||e===void 0?void 0:e.referredUser)===null||t===void 0?void 0:t.firstName)&&!((r=e===null||e===void 0?void 0:e.referredUser)===null||r===void 0?void 0:r.lastName)&&!((a=e===null||e===void 0?void 0:e.referrerUser)===null||a===void 0?void 0:a.firstName)&&!((n=e===null||e===void 0?void 0:e.referrerUser)===null||n===void 0?void 0:n.lastName)){u=this.anonymousUser}else if(e===null||e===void 0?void 0:e.referrerUser){u=((l=e===null||e===void 0?void 0:e.referrerUser)===null||l===void 0?void 0:l.firstName)+" "+((i=e===null||e===void 0?void 0:e.referrerUser)===null||i===void 0?void 0:i.lastName)}else{u=((s=e===null||e===void 0?void 0:e.referredUser)===null||s===void 0?void 0:s.firstName)+" "+((o=e===null||e===void 0?void 0:e.referredUser)===null||o===void 0?void 0:o.lastName)}return[2,h$1("sqm-referral-table-user-cell",{name:u})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n,l;return __generator(this,(function(i){if(!e){l=this.deletedUser}else if(!((t=e===null||e===void 0?void 0:e.referrerUser)===null||t===void 0?void 0:t.firstName)&&!((r=e.referrerUser)===null||r===void 0?void 0:r.lastName)){l=this.anonymousUser}else{l=((a=e===null||e===void 0?void 0:e.referrerUser)===null||a===void 0?void 0:a.firstName)+" "+((n=e===null||e===void 0?void 0:e.referrerUser)===null||n===void 0?void 0:n.lastName)}return[2,h$1("sqm-referral-table-user-cell",{name:l})]}))}))};e.prototype.render=function(){useRequestRerender([this.deletedUser,this.anonymousUser,this.columnTitle]);return h$1(Host,{style:{display:"none"}})};return e}();export{ReferralTable as sqm_referral_table,ReferralTableCell as sqm_referral_table_cell,ReferralTableGenericColumn as sqm_referral_table_column,ReferralTableDateCell as sqm_referral_table_date_cell,ReferralTableDateColumn as sqm_referral_table_date_column,ReferralTableRewardsCell as sqm_referral_table_rewards_cell,ReferralTableRewardsColumn as sqm_referral_table_rewards_column,ReferralTableStatusCell as sqm_referral_table_status_cell,ReferralTableStatusColumn as sqm_referral_table_status_column,ReferralTableUserCell as sqm_referral_table_user_cell,ReferralTableUserColumn as sqm_referral_table_user_column};