@saasquatch/vanilla-components 1.2.4 → 1.2.5-1

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 (84) hide show
  1. package/dist/cjs/{WidgetHost-d7b870ce.js → WidgetHost-fce29ef5.js} +420 -420
  2. package/dist/cjs/sqh-close-button.cjs.entry.js +25 -25
  3. package/dist/cjs/sqh-copy-button_12.cjs.entry.js +870 -971
  4. package/dist/cjs/sqh-referral-code.cjs.entry.js +22 -22
  5. package/dist/cjs/sqh-rewards-actions.cjs.entry.js +26 -26
  6. package/dist/collection/components/close-button/close-button.js +68 -68
  7. package/dist/collection/components/copy-button/copy-button.js +358 -358
  8. package/dist/collection/components/copy-link-button/copy-link-button.js +215 -215
  9. package/dist/collection/components/global-container/global-container.js +151 -151
  10. package/dist/collection/components/image-component/image-component.js +165 -165
  11. package/dist/collection/components/partner-stat-component/partner-stat-component.js +194 -194
  12. package/dist/collection/components/referral-code/referral-code.js +36 -36
  13. package/dist/collection/components/referral-component/referral-component.js +255 -255
  14. package/dist/collection/components/referral-list/referral-list.js +860 -860
  15. package/dist/collection/components/rewards-actions/rewards-actions.js +105 -105
  16. package/dist/collection/components/share-button/share-button.js +282 -282
  17. package/dist/collection/components/share-button-container/share-button-container.js +2384 -2384
  18. package/dist/collection/components/stat-component/stat-component.js +194 -194
  19. package/dist/collection/components/stats-container/stats-container.js +206 -206
  20. package/dist/collection/components/text-component/text-component.js +291 -291
  21. package/dist/collection/global/global.js +4 -4
  22. package/dist/collection/services/FormatJs.js +15 -15
  23. package/dist/collection/services/WidgetHost.js +426 -426
  24. package/dist/collection/utilities.js +81 -81
  25. package/dist/esm/{WidgetHost-a27e693d.js → WidgetHost-903fb7cc.js} +420 -420
  26. package/dist/esm/polyfills/core-js.js +0 -0
  27. package/dist/esm/polyfills/dom.js +0 -0
  28. package/dist/esm/polyfills/es5-html-element.js +0 -0
  29. package/dist/esm/polyfills/index.js +0 -0
  30. package/dist/esm/polyfills/system.js +0 -0
  31. package/dist/esm/sqh-close-button.entry.js +25 -25
  32. package/dist/esm/sqh-copy-button_12.entry.js +870 -971
  33. package/dist/esm/sqh-referral-code.entry.js +22 -22
  34. package/dist/esm/sqh-rewards-actions.entry.js +26 -26
  35. package/dist/esm-es5/{WidgetHost-a27e693d.js → WidgetHost-903fb7cc.js} +9432 -9432
  36. package/dist/esm-es5/_commonjsHelpers-1d681858.js +17 -17
  37. package/dist/esm-es5/css-shim-a659079f.js +122 -122
  38. package/dist/esm-es5/dom-4061ceba.js +468 -468
  39. package/dist/esm-es5/en-be593af0.js +1471 -1471
  40. package/dist/esm-es5/index-8ea8b6d8.js +1758 -1758
  41. package/dist/esm-es5/loader.mjs +11 -11
  42. package/dist/esm-es5/sqh-close-button.entry.js +35 -35
  43. package/dist/esm-es5/sqh-copy-button_12.entry.js +9535 -9624
  44. package/dist/esm-es5/sqh-referral-code.entry.js +29 -29
  45. package/dist/esm-es5/sqh-rewards-actions.entry.js +31 -31
  46. package/dist/esm-es5/widget-components.mjs +6 -6
  47. package/dist/types/components/close-button/close-button.d.ts +16 -16
  48. package/dist/types/components/copy-button/copy-button.d.ts +90 -90
  49. package/dist/types/components/copy-link-button/copy-link-button.d.ts +53 -53
  50. package/dist/types/components/global-container/global-container.d.ts +39 -39
  51. package/dist/types/components/image-component/image-component.d.ts +45 -45
  52. package/dist/types/components/partner-stat-component/partner-stat-component.d.ts +51 -51
  53. package/dist/types/components/referral-code/referral-code.d.ts +12 -12
  54. package/dist/types/components/referral-component/referral-component.d.ts +46 -46
  55. package/dist/types/components/referral-list/referral-list.d.ts +234 -234
  56. package/dist/types/components/rewards-actions/rewards-actions.d.ts +25 -25
  57. package/dist/types/components/share-button/share-button.d.ts +77 -77
  58. package/dist/types/components/share-button-container/share-button-container.d.ts +593 -593
  59. package/dist/types/components/stat-component/stat-component.d.ts +48 -48
  60. package/dist/types/components/stats-container/stats-container.d.ts +47 -47
  61. package/dist/types/components/text-component/text-component.d.ts +74 -74
  62. package/dist/types/components.d.ts +4 -4
  63. package/dist/types/global/global.d.ts +4 -4
  64. package/dist/types/services/FormatJs.d.ts +7 -7
  65. package/dist/types/services/WidgetHost.d.ts +45 -45
  66. package/dist/types/utilities.d.ts +7 -7
  67. package/dist/widget-components/{p-650d012d.entry.js → p-131a5c4a.entry.js} +1 -1
  68. package/dist/widget-components/p-1b8f2cfc.system.entry.js +8 -0
  69. package/dist/widget-components/p-24fc4ba9.js +1 -1
  70. package/dist/widget-components/p-46109683.js +3 -3
  71. package/dist/widget-components/{p-d4b27c72.entry.js → p-50ae8f2b.entry.js} +1 -1
  72. package/dist/widget-components/p-58be1132.system.js +1 -1
  73. package/dist/widget-components/{p-0bfec452.entry.js → p-8baa34a0.entry.js} +16 -16
  74. package/dist/widget-components/{p-c0cdba77.system.entry.js → p-b9fcb846.system.entry.js} +1 -1
  75. package/dist/widget-components/p-da180bcd.system.entry.js +1 -0
  76. package/dist/widget-components/{p-9adc7c50.system.js → p-e692beaf.system.js} +0 -0
  77. package/dist/widget-components/{p-9525bf4a.js → p-ffeb02d1.js} +0 -0
  78. package/dist/widget-components/widget-components.esm.js +1 -1
  79. package/dist/widget-components/widget-components.js +1 -1
  80. package/docs/raisins.json +1 -1
  81. package/package.json +1 -1
  82. package/CHANGELOG.md +0 -163
  83. package/dist/widget-components/p-796dc228.system.entry.js +0 -8
  84. package/dist/widget-components/p-908068c2.system.entry.js +0 -1
@@ -9910,293 +9910,293 @@ gql.disableExperimentalFragmentVariables = disableExperimentalFragmentVariables;
9910
9910
 
9911
9911
  var src = gql;
9912
9912
 
9913
- if (!window["widgetIdent"]) {
9914
- window["widgetIdent"] = {
9915
- env: "demo",
9916
- };
9917
- }
9918
- function widgetIdent() {
9919
- //@ts-ignore
9920
- return window.widgetIdent;
9921
- }
9922
- const today = new Date();
9923
- const demoUser = {
9924
- shareLink: "http://ssqt.co",
9925
- fueltankCode: "12AS3F",
9926
- referralcode: "RIDDIKULUS",
9927
- locale: "en_US",
9928
- messageLink: {
9929
- EMAIL: "http://short.staging.referralsaasquatch.com/mJjFXu",
9930
- FACEBOOK: "http://short.staging.referralsaasquatch.com/mwjFXu",
9931
- TWITTER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9932
- SMS: "http://short.staging.referralsaasquatch.com/mwjFXu",
9933
- WHATSAPP: "http://short.staging.referralsaasquatch.com/mwjFXu",
9934
- LINKEDIN: "http://short.staging.referralsaasquatch.com/mwjFXu",
9935
- PINTEREST: "http://short.staging.referralsaasquatch.com/mwjFXu",
9936
- FBMESSENGER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9937
- },
9938
- referrals: {
9939
- totalCount: 9,
9940
- data: [
9941
- {
9942
- dateReferralStarted: today.setDate(today.getDate() - 2),
9943
- referredUser: { firstName: "Remus", lastName: "Lupin" },
9944
- rewards: [
9945
- {
9946
- prettyValue: "$20.00",
9947
- dateExpires: today.setDate(today.getDate() + 4),
9948
- statuses: ["EXPIRED"],
9949
- meta: { message: "Applied to Invoice #1234" },
9950
- },
9951
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9952
- { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
9953
- ],
9954
- },
9955
- {
9956
- dateReferralStarted: today.setDate(today.getDate() - 1),
9957
- referredUser: { firstName: "Gellert", lastName: "Grindelwald" },
9958
- rewards: [],
9959
- },
9960
- // Blank string becomes an unknown user, which is editable
9961
- {
9962
- dateReferralStarted: today.setDate(today.getDate() - 1),
9963
- referredUser: { firstName: "", lastName: "" },
9964
- rewards: [
9965
- {
9966
- prettyValue: "$20.00",
9967
- dateExpires: today.setDate(today.getDate() - 2),
9968
- statuses: ["EXPIRED"],
9969
- },
9970
- ],
9971
- },
9972
- {
9973
- dateReferralStarted: today.setDate(today.getDate() - 5),
9974
- referredUser: { firstName: "Lavender", lastName: "Brown" },
9975
- rewards: [{ prettyValue: "$20.00", statuses: ["CANCELLED"] }],
9976
- },
9977
- {
9978
- dateReferralStarted: today.setDate(today.getDate() - 4),
9979
- referredUser: { firstName: "Blaise", lastName: "Zabini" },
9980
- rewards: [
9981
- { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
9982
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9983
- ],
9984
- },
9985
- {
9986
- dateReferralStarted: today.setDate(today.getDate() - 10),
9987
- referredUser: { firstName: "Argus", lastName: "Filch" },
9988
- rewards: [],
9989
- },
9990
- {
9991
- dateReferralStarted: today.setDate(today.getDate() - 15),
9992
- referredUser: { firstName: "Ron", lastName: "Weasley" },
9993
- rewards: [{ prettyValue: "$20.00", statuses: ["AVAILABLE"] }],
9994
- },
9995
- {
9996
- dateReferralStarted: today.setDate(today.getDate() - 2),
9997
- referredUser: { firstName: "Hermione", lastName: "Granger" },
9998
- rewards: [
9999
- { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
10000
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
10001
- { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
10002
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10003
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10004
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10005
- ],
10006
- },
10007
- {
10008
- dateConverted: 1606943971468,
10009
- dateReferralStarted: 1606943971468,
10010
- referredUser: {
10011
- imageUrl: "",
10012
- firstName: "Seamus",
10013
- lastName: "Finnigan",
10014
- },
10015
- rewards: [],
10016
- },
10017
- ],
10018
- },
10019
- referredByReferral: {
10020
- dateReferralStarted: today.setDate(today.getDate() - 2),
10021
- referrerUser: {
10022
- firstName: "Rubeus",
10023
- lastName: "Hagrid",
10024
- referralCode: "RUBEUSHAGRID12",
10025
- },
10026
- rewards: [
10027
- {
10028
- fuelTankCode: "CODE1234",
10029
- prettyValue: "$10.00",
10030
- statuses: ["AVAILABLE"],
10031
- },
10032
- ],
10033
- },
10034
- referralsMonth: { totalCount: 6 },
10035
- referralsWeek: { totalCount: 3 },
10036
- rewardsCount: { totalCount: 14 },
10037
- rewardsMonth: { totalCount: 7 },
10038
- rewardsWeek: { totalCount: 4 },
10039
- rewardBalancesGlobal: [
10040
- {
10041
- type: "CREDIT",
10042
- unit: "CENTS",
10043
- value: 17000,
10044
- prettyValue: "$170.00",
10045
- totalAssignedCredit: "17000",
10046
- totalRedeemedCredit: "1500",
10047
- prettyAssignedCredit: "$1000.00",
10048
- prettyRedeemedCredit: "$15.00",
10049
- },
10050
- { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10051
- {
10052
- type: "CREDIT",
10053
- unit: "CASH/CAD",
10054
- count: 3,
10055
- totalPendingCredit: 20000,
10056
- totalAssignedCredit: 30000,
10057
- totalRedeemedCredit: 10000,
10058
- totalExpiredCredit: 0,
10059
- totalCancelledCredit: 0,
10060
- prettyPendingCredit: "$200.00",
10061
- prettyAssignedCredit: "$300.00",
10062
- prettyRedeemedCredit: "$100.00",
10063
- value: 30000,
10064
- prettyValue: "$300.00",
10065
- },
10066
- {
10067
- type: "CREDIT",
10068
- unit: "CASH/USD",
10069
- count: 6,
10070
- totalPendingCredit: 25000,
10071
- totalAssignedCredit: 40000,
10072
- totalRedeemedCredit: 10000,
10073
- totalExpiredCredit: 15000,
10074
- totalCancelledCredit: 10000,
10075
- prettyPendingCredit: "USD250.00",
10076
- prettyAssignedCredit: "USD400.00",
10077
- prettyRedeemedCredit: "USD150.00",
10078
- value: 40000,
10079
- prettyValue: "USD400.00",
10080
- },
10081
- ],
10082
- rewardBalances: [
10083
- {
10084
- type: "CREDIT",
10085
- unit: "CENTS",
10086
- value: 17000,
10087
- prettyValue: "$170.00",
10088
- totalAssignedCredit: "17000",
10089
- totalRedeemedCredit: "1500",
10090
- prettyAssignedCredit: "$170.00",
10091
- prettyRedeemedCredit: "$15.00",
10092
- },
10093
- { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10094
- {
10095
- type: "CREDIT",
10096
- unit: "CASH/CAD",
10097
- count: 3,
10098
- totalPendingCredit: 20000,
10099
- totalAssignedCredit: 30000,
10100
- totalRedeemedCredit: 10000,
10101
- totalExpiredCredit: 0,
10102
- totalCancelledCredit: 0,
10103
- prettyPendingCredit: "$200.00",
10104
- prettyAssignedCredit: "$300.00",
10105
- prettyRedeemedCredit: "$100.00",
10106
- value: 30000,
10107
- prettyValue: "$300.00",
10108
- },
10109
- {
10110
- type: "CREDIT",
10111
- unit: "CASH/USD",
10112
- count: 6,
10113
- totalPendingCredit: 25000,
10114
- totalAssignedCredit: 40000,
10115
- totalRedeemedCredit: 10000,
10116
- totalExpiredCredit: 15000,
10117
- totalCancelledCredit: 10000,
10118
- prettyPendingCredit: "USD250.00",
10119
- prettyAssignedCredit: "USD400.00",
10120
- prettyRedeemedCredit: "USD150.00",
10121
- value: 40000,
10122
- prettyValue: "USD400.00",
10123
- },
10124
- ],
10125
- rewardBalanceDetails: [
10126
- {
10127
- prettyAvailableValue: "$5.00",
10128
- },
10129
- {
10130
- prettyAvailableValue: "18%",
10131
- },
10132
- ],
10133
- };
10134
- //@ts-ignore
10135
- const squatchJsApi = window.frameElement
10136
- ? window.frameElement.squatchJsApi
10137
- : {};
10138
- const apolloClient = () => {
10139
- const { tenantAlias, appDomain, token } = widgetIdent();
10140
- const uri = appDomain + "/api/v1/" + tenantAlias + "/graphql";
10141
- const headers = {
10142
- Authorization: `Bearer ${token}`,
10143
- };
10144
- const client = new ApolloClient({
10145
- link: new HttpLink({ uri, headers }),
10146
- cache: new InMemoryCache(),
10147
- });
10148
- return client;
10149
- };
10150
- const API = {
10151
- version: "Welcome to widget-host",
10152
- analytics: {
10153
- shareEvent(shareMedium) {
10154
- const widgetId = widgetIdent();
10155
- if (widgetId["env"] === "demo" || !widgetId)
10156
- return Promise.resolve({});
10157
- const { userId, accountId, programId = "classic", engagementMedium, } = widgetId;
10158
- const variables = {
10159
- eventMeta: {
10160
- id: userId,
10161
- accountId,
10162
- programId,
10163
- type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
10164
- meta: {
10165
- engagementMedium,
10166
- shareMedium,
10167
- },
10168
- },
10169
- };
10170
- return apolloClient()
10171
- .mutate({
9913
+ if (!window["widgetIdent"]) {
9914
+ window["widgetIdent"] = {
9915
+ env: "demo",
9916
+ };
9917
+ }
9918
+ function widgetIdent() {
9919
+ //@ts-ignore
9920
+ return window.widgetIdent;
9921
+ }
9922
+ const today = new Date();
9923
+ const demoUser = {
9924
+ shareLink: "http://ssqt.co",
9925
+ fueltankCode: "12AS3F",
9926
+ referralcode: "RIDDIKULUS",
9927
+ locale: "en_US",
9928
+ messageLink: {
9929
+ EMAIL: "http://short.staging.referralsaasquatch.com/mJjFXu",
9930
+ FACEBOOK: "http://short.staging.referralsaasquatch.com/mwjFXu",
9931
+ TWITTER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9932
+ SMS: "http://short.staging.referralsaasquatch.com/mwjFXu",
9933
+ WHATSAPP: "http://short.staging.referralsaasquatch.com/mwjFXu",
9934
+ LINKEDIN: "http://short.staging.referralsaasquatch.com/mwjFXu",
9935
+ PINTEREST: "http://short.staging.referralsaasquatch.com/mwjFXu",
9936
+ FBMESSENGER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9937
+ },
9938
+ referrals: {
9939
+ totalCount: 9,
9940
+ data: [
9941
+ {
9942
+ dateReferralStarted: today.setDate(today.getDate() - 2),
9943
+ referredUser: { firstName: "Remus", lastName: "Lupin" },
9944
+ rewards: [
9945
+ {
9946
+ prettyValue: "$20.00",
9947
+ dateExpires: today.setDate(today.getDate() + 4),
9948
+ statuses: ["EXPIRED"],
9949
+ meta: { message: "Applied to Invoice #1234" },
9950
+ },
9951
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9952
+ { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
9953
+ ],
9954
+ },
9955
+ {
9956
+ dateReferralStarted: today.setDate(today.getDate() - 1),
9957
+ referredUser: { firstName: "Gellert", lastName: "Grindelwald" },
9958
+ rewards: [],
9959
+ },
9960
+ // Blank string becomes an unknown user, which is editable
9961
+ {
9962
+ dateReferralStarted: today.setDate(today.getDate() - 1),
9963
+ referredUser: { firstName: "", lastName: "" },
9964
+ rewards: [
9965
+ {
9966
+ prettyValue: "$20.00",
9967
+ dateExpires: today.setDate(today.getDate() - 2),
9968
+ statuses: ["EXPIRED"],
9969
+ },
9970
+ ],
9971
+ },
9972
+ {
9973
+ dateReferralStarted: today.setDate(today.getDate() - 5),
9974
+ referredUser: { firstName: "Lavender", lastName: "Brown" },
9975
+ rewards: [{ prettyValue: "$20.00", statuses: ["CANCELLED"] }],
9976
+ },
9977
+ {
9978
+ dateReferralStarted: today.setDate(today.getDate() - 4),
9979
+ referredUser: { firstName: "Blaise", lastName: "Zabini" },
9980
+ rewards: [
9981
+ { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
9982
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9983
+ ],
9984
+ },
9985
+ {
9986
+ dateReferralStarted: today.setDate(today.getDate() - 10),
9987
+ referredUser: { firstName: "Argus", lastName: "Filch" },
9988
+ rewards: [],
9989
+ },
9990
+ {
9991
+ dateReferralStarted: today.setDate(today.getDate() - 15),
9992
+ referredUser: { firstName: "Ron", lastName: "Weasley" },
9993
+ rewards: [{ prettyValue: "$20.00", statuses: ["AVAILABLE"] }],
9994
+ },
9995
+ {
9996
+ dateReferralStarted: today.setDate(today.getDate() - 2),
9997
+ referredUser: { firstName: "Hermione", lastName: "Granger" },
9998
+ rewards: [
9999
+ { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
10000
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
10001
+ { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
10002
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10003
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10004
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10005
+ ],
10006
+ },
10007
+ {
10008
+ dateConverted: 1606943971468,
10009
+ dateReferralStarted: 1606943971468,
10010
+ referredUser: {
10011
+ imageUrl: "",
10012
+ firstName: "Seamus",
10013
+ lastName: "Finnigan",
10014
+ },
10015
+ rewards: [],
10016
+ },
10017
+ ],
10018
+ },
10019
+ referredByReferral: {
10020
+ dateReferralStarted: today.setDate(today.getDate() - 2),
10021
+ referrerUser: {
10022
+ firstName: "Rubeus",
10023
+ lastName: "Hagrid",
10024
+ referralCode: "RUBEUSHAGRID12",
10025
+ },
10026
+ rewards: [
10027
+ {
10028
+ fuelTankCode: "CODE1234",
10029
+ prettyValue: "$10.00",
10030
+ statuses: ["AVAILABLE"],
10031
+ },
10032
+ ],
10033
+ },
10034
+ referralsMonth: { totalCount: 6 },
10035
+ referralsWeek: { totalCount: 3 },
10036
+ rewardsCount: { totalCount: 14 },
10037
+ rewardsMonth: { totalCount: 7 },
10038
+ rewardsWeek: { totalCount: 4 },
10039
+ rewardBalancesGlobal: [
10040
+ {
10041
+ type: "CREDIT",
10042
+ unit: "CENTS",
10043
+ value: 17000,
10044
+ prettyValue: "$170.00",
10045
+ totalAssignedCredit: "17000",
10046
+ totalRedeemedCredit: "1500",
10047
+ prettyAssignedCredit: "$1000.00",
10048
+ prettyRedeemedCredit: "$15.00",
10049
+ },
10050
+ { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10051
+ {
10052
+ type: "CREDIT",
10053
+ unit: "CASH/CAD",
10054
+ count: 3,
10055
+ totalPendingCredit: 20000,
10056
+ totalAssignedCredit: 30000,
10057
+ totalRedeemedCredit: 10000,
10058
+ totalExpiredCredit: 0,
10059
+ totalCancelledCredit: 0,
10060
+ prettyPendingCredit: "$200.00",
10061
+ prettyAssignedCredit: "$300.00",
10062
+ prettyRedeemedCredit: "$100.00",
10063
+ value: 30000,
10064
+ prettyValue: "$300.00",
10065
+ },
10066
+ {
10067
+ type: "CREDIT",
10068
+ unit: "CASH/USD",
10069
+ count: 6,
10070
+ totalPendingCredit: 25000,
10071
+ totalAssignedCredit: 40000,
10072
+ totalRedeemedCredit: 10000,
10073
+ totalExpiredCredit: 15000,
10074
+ totalCancelledCredit: 10000,
10075
+ prettyPendingCredit: "USD250.00",
10076
+ prettyAssignedCredit: "USD400.00",
10077
+ prettyRedeemedCredit: "USD150.00",
10078
+ value: 40000,
10079
+ prettyValue: "USD400.00",
10080
+ },
10081
+ ],
10082
+ rewardBalances: [
10083
+ {
10084
+ type: "CREDIT",
10085
+ unit: "CENTS",
10086
+ value: 17000,
10087
+ prettyValue: "$170.00",
10088
+ totalAssignedCredit: "17000",
10089
+ totalRedeemedCredit: "1500",
10090
+ prettyAssignedCredit: "$170.00",
10091
+ prettyRedeemedCredit: "$15.00",
10092
+ },
10093
+ { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10094
+ {
10095
+ type: "CREDIT",
10096
+ unit: "CASH/CAD",
10097
+ count: 3,
10098
+ totalPendingCredit: 20000,
10099
+ totalAssignedCredit: 30000,
10100
+ totalRedeemedCredit: 10000,
10101
+ totalExpiredCredit: 0,
10102
+ totalCancelledCredit: 0,
10103
+ prettyPendingCredit: "$200.00",
10104
+ prettyAssignedCredit: "$300.00",
10105
+ prettyRedeemedCredit: "$100.00",
10106
+ value: 30000,
10107
+ prettyValue: "$300.00",
10108
+ },
10109
+ {
10110
+ type: "CREDIT",
10111
+ unit: "CASH/USD",
10112
+ count: 6,
10113
+ totalPendingCredit: 25000,
10114
+ totalAssignedCredit: 40000,
10115
+ totalRedeemedCredit: 10000,
10116
+ totalExpiredCredit: 15000,
10117
+ totalCancelledCredit: 10000,
10118
+ prettyPendingCredit: "USD250.00",
10119
+ prettyAssignedCredit: "USD400.00",
10120
+ prettyRedeemedCredit: "USD150.00",
10121
+ value: 40000,
10122
+ prettyValue: "USD400.00",
10123
+ },
10124
+ ],
10125
+ rewardBalanceDetails: [
10126
+ {
10127
+ prettyAvailableValue: "$5.00",
10128
+ },
10129
+ {
10130
+ prettyAvailableValue: "18%",
10131
+ },
10132
+ ],
10133
+ };
10134
+ //@ts-ignore
10135
+ const squatchJsApi = window.frameElement
10136
+ ? window.frameElement.squatchJsApi
10137
+ : {};
10138
+ const apolloClient = () => {
10139
+ const { tenantAlias, appDomain, token } = widgetIdent();
10140
+ const uri = appDomain + "/api/v1/" + tenantAlias + "/graphql";
10141
+ const headers = {
10142
+ Authorization: `Bearer ${token}`,
10143
+ };
10144
+ const client = new ApolloClient({
10145
+ link: new HttpLink({ uri, headers }),
10146
+ cache: new InMemoryCache(),
10147
+ });
10148
+ return client;
10149
+ };
10150
+ const API = {
10151
+ version: "Welcome to widget-host",
10152
+ analytics: {
10153
+ shareEvent(shareMedium) {
10154
+ const widgetId = widgetIdent();
10155
+ if (widgetId["env"] === "demo" || !widgetId)
10156
+ return Promise.resolve({});
10157
+ const { userId, accountId, programId = "classic", engagementMedium, } = widgetId;
10158
+ const variables = {
10159
+ eventMeta: {
10160
+ id: userId,
10161
+ accountId,
10162
+ programId,
10163
+ type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
10164
+ meta: {
10165
+ engagementMedium,
10166
+ shareMedium,
10167
+ },
10168
+ },
10169
+ };
10170
+ return apolloClient()
10171
+ .mutate({
10172
10172
  mutation: src `
10173
10173
  mutation ($eventMeta: UserAnalyticsEvent!) {
10174
10174
  createUserAnalyticsEvent(eventMeta: $eventMeta)
10175
10175
  }
10176
- `,
10177
- variables,
10178
- })
10179
- .then((result) => {
10180
- return result.data.createUserAnalyticsEvent;
10181
- });
10182
- },
10183
- loadEvent() {
10184
- return Promise.resolve({ event: "loadEvent" });
10185
- },
10186
- },
10187
- graphql: {
10188
- getClient() {
10189
- return apolloClient();
10190
- },
10191
- getUserFragment(userFragment, fragmentVariables) {
10176
+ `,
10177
+ variables,
10178
+ })
10179
+ .then((result) => {
10180
+ return result.data.createUserAnalyticsEvent;
10181
+ });
10182
+ },
10183
+ loadEvent() {
10184
+ return Promise.resolve({ event: "loadEvent" });
10185
+ },
10186
+ },
10187
+ graphql: {
10188
+ getClient() {
10189
+ return apolloClient();
10190
+ },
10191
+ getUserFragment(userFragment, fragmentVariables) {
10192
10192
  const fragment = src `
10193
10193
  fragment UserFragment on User {
10194
10194
  ${userFragment}
10195
- }`;
10196
- const { userId, accountId } = widgetIdent();
10197
- const variables = Object.assign(Object.assign({}, fragmentVariables), { userId,
10198
- accountId });
10199
- return this.getClient().query({
10195
+ }`;
10196
+ const { userId, accountId } = widgetIdent();
10197
+ const variables = Object.assign(Object.assign({}, fragmentVariables), { userId,
10198
+ accountId });
10199
+ return this.getClient().query({
10200
10200
  query: src `
10201
10201
  query ($userId: String!, $accountId: String!, $offset: Int) {
10202
10202
  user(id: $userId, accountId: $accountId) {
@@ -10204,23 +10204,23 @@ const API = {
10204
10204
  }
10205
10205
  }
10206
10206
  ${fragment}
10207
- `,
10208
- variables,
10209
- });
10210
- },
10211
- getShareLink() {
10212
- const widgetId = widgetIdent();
10213
- if (widgetId["env"] === "demo" || !widgetId)
10214
- return Promise.resolve(demoUser.shareLink);
10215
- const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10216
- const variables = {
10217
- userId,
10218
- accountId,
10219
- programId,
10220
- engagementMedium,
10221
- };
10222
- return this.getClient()
10223
- .query({
10207
+ `,
10208
+ variables,
10209
+ });
10210
+ },
10211
+ getShareLink() {
10212
+ const widgetId = widgetIdent();
10213
+ if (widgetId["env"] === "demo" || !widgetId)
10214
+ return Promise.resolve(demoUser.shareLink);
10215
+ const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10216
+ const variables = {
10217
+ userId,
10218
+ accountId,
10219
+ programId,
10220
+ engagementMedium,
10221
+ };
10222
+ return this.getClient()
10223
+ .query({
10224
10224
  query: src `
10225
10225
  query (
10226
10226
  $userId: String!
@@ -10237,33 +10237,33 @@ const API = {
10237
10237
  )
10238
10238
  }
10239
10239
  }
10240
- `,
10241
- variables,
10242
- })
10243
- .then((res) => res.data.user.shareLink);
10244
- },
10245
- getReferrals(showReferrer, offset = 0, limit = 3) {
10246
- const widgetId = widgetIdent();
10247
- if (widgetId["env"] === "demo" || !widgetId) {
10248
- const { referrals: refs, referredByReferral, locale } = demoUser;
10249
- const referrals = {
10250
- totalCount: refs.totalCount,
10251
- data: refs.data.slice(offset, offset + limit),
10252
- };
10253
- const user = { referrals, referredByReferral, locale };
10254
- return Promise.resolve(user);
10255
- }
10256
- const { userId, accountId, programId = null } = widgetId;
10257
- const variables = {
10258
- limit,
10259
- offset,
10260
- userId,
10261
- accountId,
10262
- programId,
10263
- programId_exists: programId ? true : false,
10264
- };
10265
- return this.getClient()
10266
- .query({
10240
+ `,
10241
+ variables,
10242
+ })
10243
+ .then((res) => res.data.user.shareLink);
10244
+ },
10245
+ getReferrals(showReferrer, offset = 0, limit = 3) {
10246
+ const widgetId = widgetIdent();
10247
+ if (widgetId["env"] === "demo" || !widgetId) {
10248
+ const { referrals: refs, referredByReferral, locale } = demoUser;
10249
+ const referrals = {
10250
+ totalCount: refs.totalCount,
10251
+ data: refs.data.slice(offset, offset + limit),
10252
+ };
10253
+ const user = { referrals, referredByReferral, locale };
10254
+ return Promise.resolve(user);
10255
+ }
10256
+ const { userId, accountId, programId = null } = widgetId;
10257
+ const variables = {
10258
+ limit,
10259
+ offset,
10260
+ userId,
10261
+ accountId,
10262
+ programId,
10263
+ programId_exists: programId ? true : false,
10264
+ };
10265
+ return this.getClient()
10266
+ .query({
10267
10267
  query: src `
10268
10268
  query (
10269
10269
  $userId: String!
@@ -10303,7 +10303,7 @@ const API = {
10303
10303
  }
10304
10304
  }
10305
10305
  }
10306
- ${showReferrer
10306
+ ${showReferrer
10307
10307
  ? `referredByReferral(programId: $programId) {
10308
10308
  referrerUser {
10309
10309
  firstName
@@ -10316,40 +10316,40 @@ const API = {
10316
10316
  prettyValue
10317
10317
  statuses
10318
10318
  }
10319
- }`
10319
+ }`
10320
10320
  : ""}
10321
10321
  }
10322
10322
  }
10323
- `,
10324
- variables,
10325
- })
10326
- .then((res) => res.data.user);
10327
- },
10328
- getStats() {
10329
- const widgetId = widgetIdent();
10330
- if (widgetId["env"] === "demo" || !widgetId) {
10331
- const { referrals: referralsCount, referralsMonth, referralsWeek, rewardsCount, rewardsMonth, rewardsWeek, rewardBalances, rewardBalancesGlobal, } = demoUser;
10332
- const user = {
10333
- referralsCount,
10334
- referralsMonth,
10335
- referralsWeek,
10336
- rewardsCount,
10337
- rewardsMonth,
10338
- rewardsWeek,
10339
- rewardBalances,
10340
- rewardBalancesGlobal,
10341
- };
10342
- return Promise.resolve(user);
10343
- }
10344
- const { userId, accountId, programId = null } = widgetId;
10345
- const variables = {
10346
- userId,
10347
- accountId,
10348
- programId,
10349
- programId_exists: programId ? true : false,
10350
- };
10351
- return this.getClient()
10352
- .query({
10323
+ `,
10324
+ variables,
10325
+ })
10326
+ .then((res) => res.data.user);
10327
+ },
10328
+ getStats() {
10329
+ const widgetId = widgetIdent();
10330
+ if (widgetId["env"] === "demo" || !widgetId) {
10331
+ const { referrals: referralsCount, referralsMonth, referralsWeek, rewardsCount, rewardsMonth, rewardsWeek, rewardBalances, rewardBalancesGlobal, } = demoUser;
10332
+ const user = {
10333
+ referralsCount,
10334
+ referralsMonth,
10335
+ referralsWeek,
10336
+ rewardsCount,
10337
+ rewardsMonth,
10338
+ rewardsWeek,
10339
+ rewardBalances,
10340
+ rewardBalancesGlobal,
10341
+ };
10342
+ return Promise.resolve(user);
10343
+ }
10344
+ const { userId, accountId, programId = null } = widgetId;
10345
+ const variables = {
10346
+ userId,
10347
+ accountId,
10348
+ programId,
10349
+ programId_exists: programId ? true : false,
10350
+ };
10351
+ return this.getClient()
10352
+ .query({
10353
10353
  query: src `
10354
10354
  query (
10355
10355
  $userId: String!
@@ -10414,51 +10414,51 @@ const API = {
10414
10414
  rewardBalancesGlobal: rewardBalances
10415
10415
  }
10416
10416
  }
10417
- `,
10418
- variables,
10419
- })
10420
- .then((res) => res.data.user);
10421
- },
10422
- async getReferralCode() {
10423
- const widgetId = widgetIdent();
10424
- if (widgetId["env"] === "demo" || !widgetId)
10425
- return demoUser.referralcode;
10426
- const { userId, accountId, programId } = widgetId;
10427
- const variables = {
10428
- userId,
10429
- accountId,
10430
- programId,
10431
- };
10432
- return this.getClient()
10433
- .query({
10417
+ `,
10418
+ variables,
10419
+ })
10420
+ .then((res) => res.data.user);
10421
+ },
10422
+ async getReferralCode() {
10423
+ const widgetId = widgetIdent();
10424
+ if (widgetId["env"] === "demo" || !widgetId)
10425
+ return demoUser.referralcode;
10426
+ const { userId, accountId, programId } = widgetId;
10427
+ const variables = {
10428
+ userId,
10429
+ accountId,
10430
+ programId,
10431
+ };
10432
+ return this.getClient()
10433
+ .query({
10434
10434
  query: src `
10435
10435
  query ($userId: String!, $accountId: String!, $programId: ID!) {
10436
10436
  user(id: $userId, accountId: $accountId) {
10437
10437
  referralCode(programId: $programId)
10438
10438
  }
10439
10439
  }
10440
- `,
10441
- variables,
10442
- })
10443
- .then((res) => res.data.user.referralCode);
10444
- },
10445
- async getFueltankCode(rewardKey) {
10446
- const widgetId = widgetIdent();
10447
- if (widgetId["env"] === "demo" || !widgetId) {
10448
- return {
10449
- referredByReferral: demoUser.referredByReferral,
10450
- rewards: { data: demoUser.referredByReferral.rewards },
10451
- };
10452
- }
10453
- const { userId, accountId, programId } = widgetId;
10454
- const variables = {
10455
- userId,
10456
- accountId,
10457
- programId,
10458
- rewardKey,
10459
- };
10460
- return this.getClient()
10461
- .query({
10440
+ `,
10441
+ variables,
10442
+ })
10443
+ .then((res) => res.data.user.referralCode);
10444
+ },
10445
+ async getFueltankCode(rewardKey) {
10446
+ const widgetId = widgetIdent();
10447
+ if (widgetId["env"] === "demo" || !widgetId) {
10448
+ return {
10449
+ referredByReferral: demoUser.referredByReferral,
10450
+ rewards: { data: demoUser.referredByReferral.rewards },
10451
+ };
10452
+ }
10453
+ const { userId, accountId, programId } = widgetId;
10454
+ const variables = {
10455
+ userId,
10456
+ accountId,
10457
+ programId,
10458
+ rewardKey,
10459
+ };
10460
+ return this.getClient()
10461
+ .query({
10462
10462
  query: src `
10463
10463
  query (
10464
10464
  $userId: String!
@@ -10486,24 +10486,24 @@ const API = {
10486
10486
  }
10487
10487
  }
10488
10488
  }
10489
- `,
10490
- variables,
10491
- })
10492
- .then((res) => res.data.user);
10493
- },
10494
- getMessageLinks(mediums) {
10495
- const widgetId = widgetIdent();
10496
- if (widgetId["env"] === "demo" || !widgetId)
10497
- return Promise.resolve(demoUser.messageLink);
10498
- const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10499
- const variables = {
10500
- userId,
10501
- accountId,
10502
- programId,
10503
- engagementMedium,
10504
- };
10505
- return this.getClient()
10506
- .query({
10489
+ `,
10490
+ variables,
10491
+ })
10492
+ .then((res) => res.data.user);
10493
+ },
10494
+ getMessageLinks(mediums) {
10495
+ const widgetId = widgetIdent();
10496
+ if (widgetId["env"] === "demo" || !widgetId)
10497
+ return Promise.resolve(demoUser.messageLink);
10498
+ const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10499
+ const variables = {
10500
+ userId,
10501
+ accountId,
10502
+ programId,
10503
+ engagementMedium,
10504
+ };
10505
+ return this.getClient()
10506
+ .query({
10507
10507
  query: src `
10508
10508
  query($userId: String!, $accountId: String!, $programId: ID, $engagementMedium: UserEngagementMedium!) {
10509
10509
  user(id: $userId, accountId: $accountId) {
@@ -10518,13 +10518,13 @@ const API = {
10518
10518
  ${mediums[8]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[8]})
10519
10519
  }
10520
10520
  }
10521
- `,
10522
- variables,
10523
- })
10524
- .then((res) => res.data.user);
10525
- },
10526
- },
10527
- ui: squatchJsApi,
10521
+ `,
10522
+ variables,
10523
+ })
10524
+ .then((res) => res.data.user);
10525
+ },
10526
+ },
10527
+ ui: squatchJsApi,
10528
10528
  };
10529
10529
 
10530
10530
  exports.API = API;