gather-vue 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/README.md +64 -0
  2. package/dist/.htaccess +1 -0
  3. package/dist/App-B7KWoHRH.js +160 -0
  4. package/dist/App-B7KWoHRH.js.gz +0 -0
  5. package/dist/App-C03tW0-W.js +405 -0
  6. package/dist/App-C03tW0-W.js.gz +0 -0
  7. package/dist/BannerExample-CRj1iMwh.js +77 -0
  8. package/dist/BannerExample-CRj1iMwh.js.gz +0 -0
  9. package/dist/BannerExample-DLN6d9M0.js +84 -0
  10. package/dist/BannerExample-DLN6d9M0.js.gz +0 -0
  11. package/dist/CallToAction-BbJ-zDFa.js +3493 -0
  12. package/dist/CallToAction-BbJ-zDFa.js.gz +0 -0
  13. package/dist/CallToAction-jAi8aaI-.js +35 -0
  14. package/dist/CallToAction-jAi8aaI-.js.gz +0 -0
  15. package/dist/Card-B1Pdd5BL.js +202 -0
  16. package/dist/Card-B1Pdd5BL.js.gz +0 -0
  17. package/dist/Card-qMo1jrfb.js +699 -0
  18. package/dist/Card-qMo1jrfb.js.gz +0 -0
  19. package/dist/CloseCardButton-CL_3xkAF.js +71 -0
  20. package/dist/CloseCardButton-CL_3xkAF.js.gz +0 -0
  21. package/dist/Editor-DXSZFkEM.js +149 -0
  22. package/dist/Editor-DXSZFkEM.js.gz +0 -0
  23. package/dist/EmailExistsView-CX1ijN0R.js +72 -0
  24. package/dist/EmailExistsView-CX1ijN0R.js.gz +0 -0
  25. package/dist/EmailInvitation-BVFicmrK.js +22 -0
  26. package/dist/EmailView-DdaSnKFq.js +84 -0
  27. package/dist/EmailView-DdaSnKFq.js.gz +0 -0
  28. package/dist/FriendBannerExample-C8QmPZyP.js +76 -0
  29. package/dist/FriendBannerExample-C8QmPZyP.js.gz +0 -0
  30. package/dist/FriendConfirmation-B-RemAoP.js +22 -0
  31. package/dist/FriendForm-CunLFX_H.js +255 -0
  32. package/dist/FriendForm-CunLFX_H.js.gz +0 -0
  33. package/dist/FriendOptIn-bp4udUYv.js +27 -0
  34. package/dist/FriendPending-cFjgyL8g.js +22 -0
  35. package/dist/FriendPitch-BhSs2eLR.js +19 -0
  36. package/dist/FriendPitch-CAS1c3Co.js +33 -0
  37. package/dist/FriendSuccess-uxEdomAY.js +22 -0
  38. package/dist/Invitations-hprUCIvW.js +27 -0
  39. package/dist/InviteRoot-Dima8d2G.js +252 -0
  40. package/dist/InviteRoot-Dima8d2G.js.gz +0 -0
  41. package/dist/LaunchButton-BQw42WVn.js +18 -0
  42. package/dist/MazBtn.1qp5aQ4N-DU0ii1Xr.js +103 -0
  43. package/dist/MazBtn.1qp5aQ4N-DU0ii1Xr.js.gz +0 -0
  44. package/dist/MazCheckbox.UAnkvAoS-pse3PCQf.js +149 -0
  45. package/dist/MazCheckbox.UAnkvAoS-pse3PCQf.js.gz +0 -0
  46. package/dist/MazIcon.B5hPzeLk-C20gse35.js +103 -0
  47. package/dist/MazIcon.B5hPzeLk-C20gse35.js.gz +0 -0
  48. package/dist/MazPhoneNumberInput-Cz50Ts4U.js +4751 -0
  49. package/dist/MazPhoneNumberInput-Cz50Ts4U.js.gz +0 -0
  50. package/dist/MazSpinner.DZT5jj-c-y1IYJMcd.js +34 -0
  51. package/dist/MazSpinner.DZT5jj-c-y1IYJMcd.js.gz +0 -0
  52. package/dist/Menu-BsKr40BO.js +21377 -0
  53. package/dist/Menu-BsKr40BO.js.gz +0 -0
  54. package/dist/Message-D4PAgcHO.js +22 -0
  55. package/dist/MessageCard-CC74qCir.js +74 -0
  56. package/dist/MessageCard-CC74qCir.js.gz +0 -0
  57. package/dist/MessageView-BKAIrwj7.js +88 -0
  58. package/dist/MessageView-BKAIrwj7.js.gz +0 -0
  59. package/dist/PendingApprovalCard-Dzs0UxBO.js +48 -0
  60. package/dist/PendingApprovalCard-Dzs0UxBO.js.gz +0 -0
  61. package/dist/PendingApprovalView-V-OUYSnK.js +33 -0
  62. package/dist/ReferralButton-CEue5qud.js +18 -0
  63. package/dist/ReferralFailedView-3Ua13t4V.js +74 -0
  64. package/dist/ReferralFailedView-3Ua13t4V.js.gz +0 -0
  65. package/dist/ReferredConfirmCard-iwgkcZCm.js +48 -0
  66. package/dist/ReferredConfirmCard-iwgkcZCm.js.gz +0 -0
  67. package/dist/ReferredConfirmView-DS1RNBwP.js +33 -0
  68. package/dist/ReferredSuccessCard-Dg-a4FYr.js +209 -0
  69. package/dist/ReferredSuccessCard-Dg-a4FYr.js.gz +0 -0
  70. package/dist/ReferredSuccessView-ChVztlUr.js +33 -0
  71. package/dist/ReferredView-7HezoVIA.js +98 -0
  72. package/dist/ReferredView-7HezoVIA.js.gz +0 -0
  73. package/dist/RewardCard-CwU2X2Yo.js +197 -0
  74. package/dist/RewardCard-CwU2X2Yo.js.gz +0 -0
  75. package/dist/Rewards-DdyEwCyy.js +27 -0
  76. package/dist/RewardsRoot-CnQfyjC6.js +198 -0
  77. package/dist/RewardsRoot-CnQfyjC6.js.gz +0 -0
  78. package/dist/Root-bUfnZpPP.js +17 -0
  79. package/dist/ShareInvitation-SAgC-8YA.js +22 -0
  80. package/dist/SignIn-CroW3mY6.js +36 -0
  81. package/dist/SignIn-CroW3mY6.js.gz +0 -0
  82. package/dist/SignIn-g32Hg2or.js +17 -0
  83. package/dist/SignInTextArea-DBRk6x09.js +17 -0
  84. package/dist/SignUpFormCard-Cail4V4M.js +287 -0
  85. package/dist/SignUpFormCard-Cail4V4M.js.gz +0 -0
  86. package/dist/SignUpView-a7LPgEeX.js +368 -0
  87. package/dist/SignUpView-a7LPgEeX.js.gz +0 -0
  88. package/dist/SignUpView-uujOX5hN.js +103 -0
  89. package/dist/SignUpView-uujOX5hN.js.gz +0 -0
  90. package/dist/SocialView-CbBZTB7Z.js +87 -0
  91. package/dist/SocialView-CbBZTB7Z.js.gz +0 -0
  92. package/dist/Stats-DtS-GXsI.js +22 -0
  93. package/dist/StatsView-fX-VznRc.js +90 -0
  94. package/dist/StatsView-fX-VznRc.js.gz +0 -0
  95. package/dist/Success-k06CZz0K.js +40 -0
  96. package/dist/Success-k06CZz0K.js.gz +0 -0
  97. package/dist/SuccessCard-C1iF1j2W.js +219 -0
  98. package/dist/SuccessCard-C1iF1j2W.js.gz +0 -0
  99. package/dist/SuccessView-CDUVkpSQ.js +77 -0
  100. package/dist/SuccessView-CDUVkpSQ.js.gz +0 -0
  101. package/dist/TextArea-DFfa9A93.js +17 -0
  102. package/dist/TextAreaCard-D_VfEHME.js +34 -0
  103. package/dist/TextAreaCard-D_VfEHME.js.gz +0 -0
  104. package/dist/UserView-DnD929IT.js +96 -0
  105. package/dist/UserView-DnD929IT.js.gz +0 -0
  106. package/dist/WhatsAppShare-B40Ouvds.js +59 -0
  107. package/dist/WhatsAppShare-B40Ouvds.js.gz +0 -0
  108. package/dist/agent-session-Xh6dZlhc.js +298 -0
  109. package/dist/agent-session-Xh6dZlhc.js.gz +0 -0
  110. package/dist/aggregate-base-C6N8Ymd5.js +830 -0
  111. package/dist/aggregate-base-C6N8Ymd5.js.gz +0 -0
  112. package/dist/bel-serializer-DMbFBZ6U.js +51 -0
  113. package/dist/bel-serializer-DMbFBZ6U.js.gz +0 -0
  114. package/dist/browser-q7cvfJ-2.js +366 -0
  115. package/dist/browser-q7cvfJ-2.js.gz +0 -0
  116. package/dist/cart.js +5 -0
  117. package/dist/cart.js.gz +0 -0
  118. package/dist/check.C9Q_W85g-DmgtOx7Q.js +30 -0
  119. package/dist/chevron-down.BkvtON3b-RNrTKYcy.js +30 -0
  120. package/dist/content-5VAQ1vQ0.js +4 -0
  121. package/dist/event-origin-BSW5uum9.js +13 -0
  122. package/dist/examples.mobile.json.tW3aL0qI-tW3aL0qI.js +4 -0
  123. package/dist/examples.mobile.json.tW3aL0qI-tW3aL0qI.js.gz +0 -0
  124. package/dist/eye-slash.BoO00xzs-CULY_lvM.js +30 -0
  125. package/dist/eye.f8zAUc30-Yr89kafZ.js +43 -0
  126. package/dist/eye.f8zAUc30-Yr89kafZ.js.gz +0 -0
  127. package/dist/favicon.ico +0 -0
  128. package/dist/first-paint-B61SrVKm.js +453 -0
  129. package/dist/first-paint-B61SrVKm.js.gz +0 -0
  130. package/dist/gather-vue.css +5 -0
  131. package/dist/gather-vue.css.gz +0 -0
  132. package/dist/gather-widget.es.js +5 -0
  133. package/dist/gather-widget.umd.js +263 -0
  134. package/dist/gather-widget.umd.js.gz +0 -0
  135. package/dist/gather_widget.css +58 -0
  136. package/dist/gather_widget.css.gz +0 -0
  137. package/dist/gather_widget.js +72 -0
  138. package/dist/gather_widget.js.gz +0 -0
  139. package/dist/iframe-BELrOJ1p.js +6 -0
  140. package/dist/index-3lvNtPTE.js +327 -0
  141. package/dist/index-3lvNtPTE.js.gz +0 -0
  142. package/dist/index-BDyGxL1x.js +255 -0
  143. package/dist/index-BDyGxL1x.js.gz +0 -0
  144. package/dist/index-BF9haAFD.js +343 -0
  145. package/dist/index-BF9haAFD.js.gz +0 -0
  146. package/dist/index-BMIST_QA.js +128 -0
  147. package/dist/index-BMIST_QA.js.gz +0 -0
  148. package/dist/index-BdWnMhAc.js +235 -0
  149. package/dist/index-BdWnMhAc.js.gz +0 -0
  150. package/dist/index-BioZsJbf.js +190 -0
  151. package/dist/index-BioZsJbf.js.gz +0 -0
  152. package/dist/index-BzOcD8v-.js +166 -0
  153. package/dist/index-BzOcD8v-.js.gz +0 -0
  154. package/dist/index-C8pB9mUQ.js +147 -0
  155. package/dist/index-C8pB9mUQ.js.gz +0 -0
  156. package/dist/index-C_ougoWd.js +426 -0
  157. package/dist/index-C_ougoWd.js.gz +0 -0
  158. package/dist/index-CoRlIGDo.js +513 -0
  159. package/dist/index-CoRlIGDo.js.gz +0 -0
  160. package/dist/index-CyWBxUBS.js +291 -0
  161. package/dist/index-CyWBxUBS.js.gz +0 -0
  162. package/dist/index-DijQHge7.js +325 -0
  163. package/dist/index-DijQHge7.js.gz +0 -0
  164. package/dist/magnifying-glass.-nBiyXot-CuA_mltt.js +30 -0
  165. package/dist/main-DPldah1M.js +40243 -0
  166. package/dist/main-DPldah1M.js.gz +0 -0
  167. package/dist/nav-timing-B-TNQpyK.js +31 -0
  168. package/dist/nav-timing-B-TNQpyK.js.gz +0 -0
  169. package/dist/no-photography.BJX8HSus-BJX8HSus.js +4 -0
  170. package/dist/no-symbol.CIgKzsrB-3PuxVsDY.js +30 -0
  171. package/dist/recorder-PHZWRV-S.js +8271 -0
  172. package/dist/recorder-PHZWRV-S.js.gz +0 -0
  173. package/dist/stylesheet-evaluator-B4P289vW.js +86 -0
  174. package/dist/stylesheet-evaluator-B4P289vW.js.gz +0 -0
  175. package/dist/time-to-first-byte-kiwh1xjs.js +29 -0
  176. package/dist/traverse-Bw4y1x4D.js +8 -0
  177. package/dist/type-check-Bp684oBR.js +6 -0
  178. package/package.json +89 -0
@@ -0,0 +1,34 @@
1
+ import { defineComponent as a, resolveComponent as s, createBlock as c, createCommentVNode as i, openBlock as u } from "vue";
2
+ import { a as n, _ } from "./main-DPldah1M.js";
3
+ const m = a({
4
+ name: "PopUpTextAreaCard",
5
+ props: {
6
+ pageType: {
7
+ type: String
8
+ }
9
+ },
10
+ computed: {
11
+ enabled() {
12
+ const e = n();
13
+ return this.$props.pageType === "success" ? e.campaign.config.pop_up.success.text_area.enabled : e.campaign.config.pop_up.sign_up.text_area.enabled;
14
+ },
15
+ textArea() {
16
+ var t, p;
17
+ const e = n();
18
+ return this.$props.pageType === "success" ? (t = e.campaign) == null ? void 0 : t.config.pop_up.success.text_area : (p = e.campaign) == null ? void 0 : p.config.pop_up.sign_up.text_area;
19
+ }
20
+ }
21
+ });
22
+ function d(e, t, p, g, l, f) {
23
+ var r;
24
+ const o = s("v-card-text");
25
+ return e.enabled ? (u(), c(o, {
26
+ key: 0,
27
+ class: "quill-styling",
28
+ innerHTML: (r = e.textArea) == null ? void 0 : r.text
29
+ }, null, 8, ["innerHTML"])) : i("", !0);
30
+ }
31
+ const C = /* @__PURE__ */ _(m, [["render", d], ["__file", "/Users/dominic/Code/gather-vue/src/components/pop_up/TextAreaCard.vue"]]);
32
+ export {
33
+ C as T
34
+ };
Binary file
@@ -0,0 +1,96 @@
1
+ import { defineComponent as R, resolveComponent as o, createBlock as d, openBlock as c, withCtx as t, createElementVNode as h, createVNode as e, createCommentVNode as _ } from "vue";
2
+ import { C as v, P as S, u as m, _ as C } from "./main-DPldah1M.js";
3
+ import { S as V } from "./StatsView-fX-VznRc.js";
4
+ import { I as b } from "./InviteRoot-Dima8d2G.js";
5
+ import { R as g } from "./RewardsRoot-CnQfyjC6.js";
6
+ const k = R({
7
+ name: "UserView",
8
+ components: {
9
+ StatsView: V,
10
+ InviteRoot: b,
11
+ RewardsRoot: g,
12
+ Popup: S,
13
+ CustomTheme: v
14
+ },
15
+ computed: {
16
+ showRewards() {
17
+ var r;
18
+ return m().showRewards && ((r = this.content) == null ? void 0 : r.show_rewards);
19
+ },
20
+ content() {
21
+ var r;
22
+ return (r = m().referralCampaign) == null ? void 0 : r.config.home;
23
+ },
24
+ showStats() {
25
+ return m().displayStats;
26
+ }
27
+ }
28
+ }), x = { id: "submitted-view" };
29
+ function I(n, r, P, U, $, y) {
30
+ const p = o("CustomTheme"), l = o("StatsView"), a = o("v-card"), s = o("v-container"), u = o("InviteRoot"), i = o("v-card-text"), f = o("RewardsRoot"), w = o("Popup");
31
+ return c(), d(w, null, {
32
+ default: t(() => [
33
+ h("div", x, [
34
+ e(p),
35
+ e(s, {
36
+ id: "top-card",
37
+ class: "pa-5"
38
+ }, {
39
+ default: t(() => [
40
+ n.showStats ? (c(), d(a, { key: 0 }, {
41
+ default: t(() => [
42
+ e(l)
43
+ ]),
44
+ _: 1
45
+ })) : _("", !0)
46
+ ]),
47
+ _: 1
48
+ }),
49
+ e(s, {
50
+ id: "invite-container",
51
+ class: "pa-5"
52
+ }, {
53
+ default: t(() => [
54
+ e(a, null, {
55
+ default: t(() => [
56
+ e(i, null, {
57
+ default: t(() => [
58
+ e(u)
59
+ ]),
60
+ _: 1
61
+ })
62
+ ]),
63
+ _: 1
64
+ })
65
+ ]),
66
+ _: 1
67
+ }),
68
+ n.showRewards ? (c(), d(s, {
69
+ key: 0,
70
+ id: "reward-container",
71
+ class: "pa-5"
72
+ }, {
73
+ default: t(() => [
74
+ e(a, { id: "gc-rewards-1" }, {
75
+ default: t(() => [
76
+ e(i, null, {
77
+ default: t(() => [
78
+ e(f)
79
+ ]),
80
+ _: 1
81
+ })
82
+ ]),
83
+ _: 1
84
+ })
85
+ ]),
86
+ _: 1
87
+ })) : _("", !0)
88
+ ])
89
+ ]),
90
+ _: 1
91
+ });
92
+ }
93
+ const q = /* @__PURE__ */ C(k, [["render", I], ["__file", "/Users/dominic/Code/gather-vue/src/components/referral_campaign/user/UserView.vue"]]);
94
+ export {
95
+ q as default
96
+ };
Binary file
@@ -0,0 +1,59 @@
1
+ import { defineComponent as a, resolveComponent as t, createBlock as i, openBlock as c, withCtx as n, createVNode as p, createTextVNode as _ } from "vue";
2
+ import { _ as m } from "./main-DPldah1M.js";
3
+ const u = a({
4
+ name: "SmsShare",
5
+ props: ["link"]
6
+ });
7
+ function v(o, e, l, f, d, h) {
8
+ const r = t("v-icon"), s = t("v-btn");
9
+ return c(), i(s, {
10
+ target: "_parent",
11
+ theme: "dark",
12
+ class: "ma-2 white--text",
13
+ size: "small",
14
+ href: o.link,
15
+ dark: "",
16
+ fab: "",
17
+ icon: ""
18
+ }, {
19
+ default: n(() => [
20
+ p(r, { size: "x-large" }, {
21
+ default: n(() => e[0] || (e[0] = [
22
+ _("mdi-cellphone-text")
23
+ ])),
24
+ _: 1
25
+ })
26
+ ]),
27
+ _: 1
28
+ }, 8, ["href"]);
29
+ }
30
+ const g = /* @__PURE__ */ m(u, [["render", v], ["__file", "/Users/dominic/Code/gather-vue/src/components/referral_campaign/user/invite/social/SmsShare.vue"]]), k = a({
31
+ name: "WhatsAppShare",
32
+ props: ["link"]
33
+ });
34
+ function S(o, e, l, f, d, h) {
35
+ const r = t("v-icon"), s = t("v-btn");
36
+ return c(), i(s, {
37
+ target: "_blank",
38
+ theme: "dark",
39
+ class: "ma-2 white--text",
40
+ size: "small",
41
+ href: o.link,
42
+ icon: ""
43
+ }, {
44
+ default: n(() => [
45
+ p(r, { size: "x-large" }, {
46
+ default: n(() => e[0] || (e[0] = [
47
+ _("mdi-whatsapp")
48
+ ])),
49
+ _: 1
50
+ })
51
+ ]),
52
+ _: 1
53
+ }, 8, ["href"]);
54
+ }
55
+ const b = /* @__PURE__ */ m(k, [["render", S], ["__file", "/Users/dominic/Code/gather-vue/src/components/referral_campaign/user/invite/social/WhatsAppShare.vue"]]);
56
+ export {
57
+ g as S,
58
+ b as W
59
+ };
@@ -0,0 +1,298 @@
1
+ import { i as c, b2 as S, $ as p, H as E, b3 as y, w, m as o, n as u, p as A, aF as l, b4 as T, b5 as b, b6 as M, b7 as d, b8 as v, r as m, t as D, D as I, y as x, S as O, b9 as k, d as f, ay as F } from "./main-DPldah1M.js";
2
+ class g {
3
+ constructor(e, t) {
4
+ if (!e.onEnd) throw new Error("onEnd handler is required");
5
+ if (!t) throw new Error("ms duration is required");
6
+ this.onEnd = e.onEnd, this.initialMs = t, this.startTimestamp = Date.now(), this.timer = this.create(this.onEnd, t);
7
+ }
8
+ create(e, t) {
9
+ return this.timer && this.clear(), setTimeout(() => e ? e() : this.onEnd(), t || this.initialMs);
10
+ }
11
+ clear() {
12
+ clearTimeout(this.timer), this.timer = null;
13
+ }
14
+ end() {
15
+ this.clear(), this.onEnd();
16
+ }
17
+ isValid() {
18
+ return this.initialMs - (Date.now() - this.startTimestamp) > 0;
19
+ }
20
+ }
21
+ class N extends g {
22
+ constructor(e, t) {
23
+ var s;
24
+ super(e, t), this.onPause = typeof e.onPause == "function" ? e.onPause : () => {
25
+ }, this.onRefresh = typeof e.onRefresh == "function" ? e.onRefresh : () => {
26
+ }, this.onResume = typeof e.onResume == "function" ? e.onResume : () => {
27
+ }, this.readStorage = e.readStorage, this.remainingMs = void 0, e.refreshEvents || (e.refreshEvents = ["click", "keydown", "scroll"]);
28
+ try {
29
+ this.abortController = new AbortController();
30
+ } catch {
31
+ }
32
+ if (c && e.ee) {
33
+ if (e.ee) {
34
+ this.ee = e.ee;
35
+ const n = S(this.refresh.bind(this), 500, {
36
+ leading: !0
37
+ });
38
+ this.refreshHandler = (i) => {
39
+ var r;
40
+ e.refreshEvents.includes((r = i == null ? void 0 : i[0]) == null ? void 0 : r.type) && n();
41
+ }, e.ee.on("fn-end", this.refreshHandler);
42
+ }
43
+ p((n) => {
44
+ n === "hidden" ? this.pause() : this.resume();
45
+ }, !1, !1, (s = this.abortController) == null ? void 0 : s.signal);
46
+ }
47
+ }
48
+ abort() {
49
+ var e;
50
+ this.clear(), (e = this.abortController) == null || e.abort(), this.refreshHandler && (this.ee.removeEventListener("fn-end", this.refreshHandler), this.refreshHandler = this.ee = null);
51
+ }
52
+ pause() {
53
+ this.onPause(), clearTimeout(this.timer), this.remainingMs = this.initialMs - (Date.now() - this.startTimestamp);
54
+ }
55
+ resume() {
56
+ try {
57
+ const t = this.readStorage(), s = typeof t == "string" ? JSON.parse(t) : t;
58
+ e(s.expiresAt) || e(s.inactiveAt) ? this.end() : (this.refresh(), this.onResume());
59
+ } catch {
60
+ this.end();
61
+ }
62
+ function e(t) {
63
+ return Date.now() > t;
64
+ }
65
+ }
66
+ refresh(e, t) {
67
+ this.clear(), this.timer = this.create(e, t), this.startTimestamp = Date.now(), this.remainingMs = void 0, this.onRefresh();
68
+ }
69
+ }
70
+ const h = {
71
+ value: "",
72
+ inactiveAt: 0,
73
+ expiresAt: 0,
74
+ updatedAt: Date.now(),
75
+ sessionReplayMode: l.OFF,
76
+ sessionReplaySentFirstChunk: !1,
77
+ sessionTraceMode: l.OFF,
78
+ traceHarvestStarted: !1,
79
+ loggingMode: A.OFF,
80
+ serverTimeDiff: null,
81
+ // set by TimeKeeper; "undefined" value will not be stringified and stored but "null" will
82
+ custom: {},
83
+ numOfResets: 0
84
+ };
85
+ class _ {
86
+ /**
87
+ * Create a self-managing Session Entity. This entity is scoped to the agent identifier which triggered it, allowing for multiple simultaneous session objects to exist.
88
+ * There is one "namespace" an agent can store data in LS -- NRBA_{key}. If there are two agents on one page, and they both use the same key, they could overwrite each other since they would both use the same namespace in LS by default.
89
+ * The value can be overridden in the constructor, but will default to a unique 16 character hex string
90
+ * expiresMs and inactiveMs are used to "expire" the session, but can be overridden in the constructor. Pass 0 to disable expiration timers.
91
+ */
92
+ constructor(e) {
93
+ const {
94
+ agentIdentifier: t,
95
+ key: s,
96
+ storage: n
97
+ } = e;
98
+ if (!t || !s || !n)
99
+ throw new Error("Missing required field(s):".concat(t ? "" : " agentID").concat(s ? "" : " key").concat(n ? "" : " storage"));
100
+ this.agentIdentifier = t, this.storage = n, this.state = {}, this.key = s, this.ee = E.get(t), y(this.ee), this.setup(e), c && w("storage", (i) => {
101
+ if (i.key === this.lookupKey) {
102
+ const r = typeof i.newValue == "string" ? JSON.parse(i.newValue) : i.newValue;
103
+ this.sync(r), this.ee.emit(o.UPDATE, [u.CROSS_TAB, this.state]);
104
+ }
105
+ });
106
+ }
107
+ setup({
108
+ value: e = T(16),
109
+ expiresMs: t = b,
110
+ inactiveMs: s = M,
111
+ numOfResets: n = 0
112
+ }) {
113
+ const i = {
114
+ serverTimeDiff: this.state.serverTimeDiff || h.serverTimeDiff
115
+ };
116
+ this.state = {}, this.sync({
117
+ ...h,
118
+ ...i
119
+ }), this.state.value = e, this.expiresMs = t, this.inactiveMs = s;
120
+ const r = this.read();
121
+ t ? (this.state.expiresAt = (r == null ? void 0 : r.expiresAt) || this.getFutureTimestamp(t), this.state.numOfResets = (r == null ? void 0 : r.numOfResets) || n, this.expiresTimer = new g({
122
+ // When the inactive timer ends, collect a SM and reset the session
123
+ onEnd: () => {
124
+ this.collectSM("expired"), this.collectSM("duration"), this.reset();
125
+ }
126
+ }, this.state.expiresAt - Date.now())) : this.state.expiresAt = 1 / 0, s ? (this.state.inactiveAt = (r == null ? void 0 : r.inactiveAt) || this.getFutureTimestamp(s), this.inactiveTimer = new N({
127
+ // When the inactive timer ends, collect a SM and reset the session
128
+ onEnd: () => {
129
+ this.collectSM("inactive"), this.collectSM("duration"), this.reset();
130
+ },
131
+ // When the inactive timer refreshes, it will update the storage values with an update timestamp
132
+ onRefresh: this.refresh.bind(this),
133
+ onResume: () => {
134
+ this.ee.emit(o.RESUME);
135
+ },
136
+ // When the inactive timer pauses, update the storage values with an update timestamp
137
+ onPause: () => {
138
+ this.initialized && this.ee.emit(o.PAUSE), this.write(d(this.state, h));
139
+ },
140
+ ee: this.ee,
141
+ refreshEvents: ["click", "keydown", "scroll"],
142
+ readStorage: () => this.storage.get(this.lookupKey)
143
+ }, this.state.inactiveAt - Date.now())) : this.state.inactiveAt = 1 / 0, this.isNew || (this.isNew = !Object.keys(r).length), this.isNew ? this.write(d(this.state, h), !0) : this.sync(r), this.initialized = !0, this.ee.emit(o.STARTED, [this.isNew]);
144
+ }
145
+ // This is the actual key appended to the storage API
146
+ get lookupKey() {
147
+ return "".concat(v, "_").concat(this.key);
148
+ }
149
+ sync(e) {
150
+ Object.assign(this.state, e);
151
+ }
152
+ /**
153
+ * Fetch the stored values from the storage API tied to this entity
154
+ * @returns {Object}
155
+ */
156
+ read() {
157
+ try {
158
+ const e = this.storage.get(this.lookupKey);
159
+ if (!e) return {};
160
+ const t = typeof e == "string" ? JSON.parse(e) : e;
161
+ return this.isInvalid(t) ? {} : this.isExpired(t.expiresAt) ? (this.collectSM("expired"), this.collectSM("duration", t, !0), this.reset()) : this.isExpired(t.inactiveAt) ? (this.collectSM("inactive"), this.collectSM("duration", t, !0), this.reset()) : t;
162
+ } catch (e) {
163
+ return m(10, e), {};
164
+ }
165
+ }
166
+ /**
167
+ * Store data to the storage API tied to this entity
168
+ * To preseve existing attributes, the output of ...session.read()
169
+ * should be appended to the data argument
170
+ * @param {Object} data
171
+ * @returns {Object}
172
+ */
173
+ write(e) {
174
+ try {
175
+ return !e || typeof e != "object" ? void 0 : (e.updatedAt = Date.now(), this.sync(e), this.storage.set(this.lookupKey, D(this.state)), this.ee.emit(o.UPDATE, [u.SAME_TAB, this.state]), e);
176
+ } catch (t) {
177
+ return m(11, t), null;
178
+ }
179
+ }
180
+ reset() {
181
+ var e, t, s, n;
182
+ try {
183
+ return this.initialized && (this.ee.emit(o.RESET), this.state.numOfResets++), this.storage.remove(this.lookupKey), (t = (e = this.inactiveTimer) == null ? void 0 : e.abort) == null || t.call(e), (n = (s = this.expiresTimer) == null ? void 0 : s.clear) == null || n.call(s), delete this.isNew, this.setup({
184
+ agentIdentifier: this.agentIdentifier,
185
+ key: this.key,
186
+ storage: this.storage,
187
+ expiresMs: this.expiresMs,
188
+ inactiveMs: this.inactiveMs,
189
+ numOfResets: this.state.numOfResets
190
+ }), this.read();
191
+ } catch {
192
+ return {};
193
+ }
194
+ }
195
+ /**
196
+ * Refresh the inactivity timer data
197
+ */
198
+ refresh() {
199
+ const e = this.read();
200
+ this.write({
201
+ ...e,
202
+ inactiveAt: this.getFutureTimestamp(this.inactiveMs)
203
+ });
204
+ }
205
+ /**
206
+ * @param {number} timestamp
207
+ * @returns {boolean}
208
+ */
209
+ isExpired(e) {
210
+ return Date.now() > e;
211
+ }
212
+ /**
213
+ * @param {Object} data
214
+ * @returns {boolean}
215
+ */
216
+ isInvalid(e) {
217
+ return !Object.keys(h).every((s) => Object.keys(e).includes(s));
218
+ }
219
+ collectSM(e, t, s) {
220
+ let n, i;
221
+ e === "duration" && (n = this.getDuration(t, s), i = "Session/Duration/Ms"), e === "expired" && (i = "Session/Expired/Seen"), e === "inactive" && (i = "Session/Inactive/Seen"), i && I(O, [i, n], void 0, x.metrics, this.ee);
222
+ }
223
+ getDuration(e = this.state, t) {
224
+ const s = e.expiresAt - this.expiresMs;
225
+ return (t ? Date.now() : e.updatedAt) - s;
226
+ }
227
+ /**
228
+ * @param {number} futureMs - The number of ms to use to generate a future timestamp
229
+ * @returns {number}
230
+ */
231
+ getFutureTimestamp(e) {
232
+ return Date.now() + e;
233
+ }
234
+ syncCustomAttribute(e, t) {
235
+ if (c)
236
+ if (t === null) {
237
+ const s = this.read();
238
+ s.custom && (delete s.custom[e], this.write({
239
+ ...s
240
+ }));
241
+ } else {
242
+ const s = this.read();
243
+ this.custom = {
244
+ ...(s == null ? void 0 : s.custom) || {},
245
+ [e]: t
246
+ }, this.write({
247
+ ...s,
248
+ custom: this.custom
249
+ });
250
+ }
251
+ }
252
+ }
253
+ class C {
254
+ get(e) {
255
+ try {
256
+ return localStorage.getItem(e) || void 0;
257
+ } catch {
258
+ return "";
259
+ }
260
+ }
261
+ set(e, t) {
262
+ try {
263
+ return t == null ? this.remove(e) : localStorage.setItem(e, t);
264
+ } catch {
265
+ }
266
+ }
267
+ remove(e) {
268
+ try {
269
+ localStorage.removeItem(e);
270
+ } catch {
271
+ }
272
+ }
273
+ }
274
+ function R(a) {
275
+ if (a.runtime.session) return a.runtime.session;
276
+ const e = a.init.session;
277
+ a.runtime.session = new _({
278
+ agentIdentifier: a.agentIdentifier,
279
+ key: k,
280
+ storage: new C(),
281
+ expiresMs: e == null ? void 0 : e.expiresMs,
282
+ inactiveMs: e == null ? void 0 : e.inactiveMs
283
+ });
284
+ const t = a.runtime.session.state.custom;
285
+ t && (a.info.jsAttributes = {
286
+ ...t,
287
+ ...a.info.jsAttributes
288
+ });
289
+ const s = E.get(a.agentIdentifier);
290
+ return f("api-setCustomAttribute", (n, i, r) => {
291
+ a.runtime.session.syncCustomAttribute(i, r);
292
+ }, "session", s), f("api-setUserId", (n, i, r) => {
293
+ a.runtime.session.syncCustomAttribute(i, r);
294
+ }, "session", s), F(a.agentIdentifier, "session"), a.runtime.session;
295
+ }
296
+ export {
297
+ R as setupAgentSession
298
+ };