@subiz/widget-v4 4.0.98 → 4.1.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 (141) hide show
  1. package/assets/less/chatbox.less +1 -1
  2. package/assets/less/notif.less +1 -1
  3. package/compiled_src/call/call.js +3 -3
  4. package/compiled_src/chatbox/AgentsAvatar.js +0 -3
  5. package/compiled_src/chatbox/ButtonAttachments.js +0 -1
  6. package/compiled_src/chatbox/ChatButton.js +0 -5
  7. package/compiled_src/chatbox/DropdownSelect.js +4 -5
  8. package/compiled_src/chatbox/Event.js +0 -2
  9. package/compiled_src/chatbox/Events.js +1 -9
  10. package/compiled_src/chatbox/FormAttachment.js +0 -1
  11. package/compiled_src/chatbox/GenericTemplateAttachments.js +0 -3
  12. package/compiled_src/chatbox/Header.js +5 -2
  13. package/compiled_src/chatbox/InfoMessage.js +0 -1
  14. package/compiled_src/chatbox/MessageInput.js +3 -3
  15. package/compiled_src/chatbox/Order.js +3 -1
  16. package/compiled_src/chatbox/OrderAttachments.js +0 -1
  17. package/compiled_src/chatbox/QuickReplies.js +0 -1
  18. package/compiled_src/chatbox/Rating.js +3 -1
  19. package/compiled_src/chatbox/ShadowDomRoot.js +1 -1
  20. package/compiled_src/chatbox/TextMessage.js +0 -2
  21. package/compiled_src/chatbox/Typing.js +0 -1
  22. package/compiled_src/chatbox/Widget.js +13 -34
  23. package/compiled_src/chatbox/main.js +0 -1
  24. package/compiled_src/chatbox/releaseAnimation.js +0 -1
  25. package/compiled_src/contact/contact.js +3 -7
  26. package/compiled_src/lib.js +9 -20
  27. package/compiled_src/notif/notif.js +3 -3
  28. package/compiled_src/order/address_picker.js +4 -6
  29. package/compiled_src/order/index.js +0 -2
  30. package/compiled_src/order/order.js +4 -7
  31. package/compiled_src/plugin.js +0 -9
  32. package/compiled_src/popup/countdown.js +3 -5
  33. package/compiled_src/popup/popup.js +3 -8
  34. package/compiled_src/popup/tick.core.commonjs.js +16 -158
  35. package/compiled_src/popup/tick.view.flip.commonjs.js +0 -25
  36. package/compiled_src/store/api.js +3 -9
  37. package/compiled_src/store/api_fake.js +3 -3
  38. package/compiled_src/store/store.js +25 -56
  39. package/compiled_src/util/campaign.js +0 -5
  40. package/compiled_src/util/common.js +0 -27
  41. package/compiled_src/util/extractor.js +0 -1
  42. package/compiled_src/util/gate.test.js +0 -1
  43. package/compiled_src/util/index.js +0 -1
  44. package/compiled_src/util/op.js +0 -1
  45. package/compiled_src/util/order.js +0 -4
  46. package/dist/132.js +6582 -0
  47. package/dist/178.js +406 -0
  48. package/dist/184d8eee275.132.js +1 -0
  49. package/dist/184d8eee275.178.js +1 -0
  50. package/dist/184d8eee275.213.js +1 -0
  51. package/dist/184d8eee275.335.js +1 -0
  52. package/dist/184d8eee275.362.js +1 -0
  53. package/dist/184d8eee275.441.js +1 -0
  54. package/dist/184d8eee275.605.js +1 -0
  55. package/dist/184d8eee275.678.js +1 -0
  56. package/dist/184d8eee275.782.js +1 -0
  57. package/dist/184d8eee275.app.js +1 -0
  58. package/dist/184d8eee275.index.html +26 -0
  59. package/dist/184d8eee275.library.html +26 -0
  60. package/dist/184d8eee275.library.js +1 -0
  61. package/dist/184d8eee275.preview.html +759 -0
  62. package/dist/184d8eee275.preview.js +1 -0
  63. package/dist/184d8eee275.screenshoot.js +1 -0
  64. package/dist/213.js +2774 -0
  65. package/dist/335.js +372 -0
  66. package/dist/362.js +107 -0
  67. package/dist/441.js +2840 -0
  68. package/dist/605.js +297 -0
  69. package/dist/678.js +107 -0
  70. package/dist/782.js +107 -0
  71. package/dist/HASH +1 -0
  72. package/dist/assets/img/Facebook.64607ec.png +0 -0
  73. package/dist/assets/img/Zalo.6845707.png +0 -0
  74. package/dist/assets/img/award1a.1a58e10.png +0 -0
  75. package/dist/assets/img/award3a.3b74423.png +0 -0
  76. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  77. package/dist/assets/img/award5.39eb7ae.png +0 -0
  78. package/dist/assets/img/bubble_default.7d5e4ab.svg +20 -0
  79. package/dist/assets/img/caret.998eb8f.svg +1 -0
  80. package/dist/assets/img/convos_empty.2353007.svg +72 -0
  81. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  82. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  83. package/dist/assets/img/done_gray.d7e8203.svg +4 -0
  84. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  85. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  86. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  87. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  88. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  89. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  90. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  91. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  92. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  93. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  94. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  95. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  96. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  97. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  98. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  99. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  100. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  101. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  102. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  103. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  104. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  105. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  106. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  107. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  108. package/dist/assets/img/empty.29bed2d.svg +23 -0
  109. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  110. package/dist/assets/img/examplte_logo.f86535f.svg +1 -0
  111. package/dist/assets/img/external-link.90577cc.svg +1 -0
  112. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  113. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  114. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  115. package/dist/assets/img/image_default.be0698b.png +0 -0
  116. package/dist/assets/img/info.ebce7ea.svg +1 -0
  117. package/dist/assets/img/loader.37000a7.svg +1 -0
  118. package/dist/assets/img/loading_static.8f403ae.svg +10 -0
  119. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  120. package/dist/assets/img/main-service2.9b99549.png +0 -0
  121. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  122. package/dist/assets/img/package.8d37d0f.svg +5 -0
  123. package/dist/assets/img/package_fade.763c001.svg +1 -0
  124. package/dist/assets/img/rating--average.1ea492c.svg +12 -0
  125. package/dist/assets/img/rating--great.e3d712e.svg +16 -0
  126. package/dist/assets/img/rating--poor.2938a25.svg +12 -0
  127. package/dist/assets/img/search.f9705ff.svg +1 -0
  128. package/dist/assets/img/send.6db52a9.svg +3 -0
  129. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  130. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  131. package/dist/assets/img/subiz-mono.877e9f5.svg +3 -0
  132. package/dist/assets/img/x.26fdfa3.svg +5 -0
  133. package/dist/malicious-app.js +13 -0
  134. package/dist/screenshoot.html +7 -0
  135. package/dist/screenshoot.js +5573 -0
  136. package/package.json +5 -5
  137. package/src/chatbox/Header.js +9 -3
  138. package/src/chatbox/ShadowDomRoot.js +1 -1
  139. package/src/chatbox/Widget.js +6 -10
  140. package/src/lib.js +7 -17
  141. package/src/store/store.js +20 -8
@@ -43,21 +43,16 @@ module.exports = function () {
43
43
  var draw = function draw(state) {
44
44
  if (state.isInitialValue()) {
45
45
  state.root.textContent = '';
46
-
47
46
  state.spacer = DOM.create('span', 'tick-flip-spacer');
48
47
  state.root.appendChild(state.spacer);
49
-
50
48
  var shadowTop = DOM.create('span', 'tick-flip-shadow-top tick-flip-shadow tick-flip-front');
51
49
  var shadowBottom = DOM.create('span', 'tick-flip-shadow-bottom tick-flip-shadow tick-flip-back');
52
50
  state.root.appendChild(shadowTop);
53
51
  state.root.appendChild(shadowBottom);
54
-
55
52
  state.shadowCard = DOM.create('span', 'tick-flip-card-shadow');
56
53
  state.root.appendChild(state.shadowCard);
57
54
  }
58
-
59
55
  state.spacer.textContent = state.value;
60
-
61
56
  if (!state.isInitialValue() && !DOM.visible(state.root)) {
62
57
  state.cards.forEach(function (card) {
63
58
  card.back = state.value;
@@ -65,14 +60,12 @@ module.exports = function () {
65
60
  });
66
61
  return;
67
62
  }
68
-
69
63
  var turningCard = state.cards[state.cards.length - 1];
70
64
  if (turningCard) {
71
65
  turningCard.waiting = false;
72
66
  turningCard.offset = performance();
73
67
  turningCard.back = state.value;
74
68
  }
75
-
76
69
  if (state.isInitialValue()) {
77
70
  var initialBottomCard = new FlipCard();
78
71
  initialBottomCard.back = state.value;
@@ -81,7 +74,6 @@ module.exports = function () {
81
74
  state.root.insertBefore(initialBottomCard.root, state.root.firstChild);
82
75
  state.cards.push(initialBottomCard);
83
76
  }
84
-
85
77
  var topCard = new FlipCard();
86
78
  topCard.offset = null;
87
79
  topCard.progress = 0;
@@ -89,7 +81,6 @@ module.exports = function () {
89
81
  topCard.waiting = true;
90
82
  topCard.front = state.value;
91
83
  topCard.rotate(0);
92
-
93
84
  state.root.insertBefore(topCard.root, state.root.firstChild);
94
85
  state.cards.push(topCard);
95
86
  if (!state.animating) {
@@ -103,7 +94,6 @@ module.exports = function () {
103
94
  state.animating = false;
104
95
  return;
105
96
  }
106
-
107
97
  cardsToAnimate.forEach(function (card) {
108
98
  if (card.offset !== null) {
109
99
  card.progress = (performance() - card.offset) / state.style.flipDuration;
@@ -114,7 +104,6 @@ module.exports = function () {
114
104
  }
115
105
  card.visual_progress = ease(card.progress);
116
106
  });
117
-
118
107
  var cardDistance = 0.01;
119
108
  cardsToAnimate.reverse().forEach(function (card, index) {
120
109
  var previousCard = cardsToAnimate[index - 1];
@@ -123,20 +112,16 @@ module.exports = function () {
123
112
  }
124
113
  });
125
114
  cardsToAnimate.reverse();
126
-
127
115
  state.cards.forEach(function (card, index) {
128
116
  var shadowFrontProgress = 1 - Math.abs(card.visual_progress - 0.5) * 2;
129
117
  var highlightBackProgress = 1 - (card.visual_progress - 0.5) / 0.5;
130
118
  card.shadowFront = shadowFrontProgress;
131
119
  card.highlightBack = highlightBackProgress;
132
-
133
120
  var cardAbove = state.cards[index + 1];
134
-
135
121
  if (cardAbove && card.visual_progress > 0.5 && card.visual_progress > 0) {
136
122
  card.shadowBack = easeOutCubic(cardAbove.visual_progress);
137
123
  }
138
124
  });
139
-
140
125
  cardsToAnimate.forEach(function (card, index) {
141
126
  var p = card.visual_progress;
142
127
  if (p > 0.5 && !card.done) {
@@ -146,7 +131,6 @@ module.exports = function () {
146
131
  }
147
132
  card.rotate(p * -180);
148
133
  });
149
-
150
134
  var shadowProgress = 0;
151
135
  var dist = 1;
152
136
  cardsToAnimate.forEach(function (card) {
@@ -159,15 +143,12 @@ module.exports = function () {
159
143
  var s = shadowProgress < 0.5 ? easeOutSine(shadowProgress / 0.5) : easeOutSine((1 - shadowProgress) / 0.5);
160
144
  state.shadowCard.style.setProperty('opacity', s, 'important');
161
145
  DOM.transform(state.shadowCard, 'scaleY', s);
162
-
163
146
  state.cards.filter(function (card) {
164
147
  return card.done;
165
148
  }).slice(0, -1).forEach(function (card) {
166
-
167
149
  state.cards = state.cards.filter(function (c) {
168
150
  return c !== card;
169
151
  });
170
-
171
152
  if (card.root.parentNode) {
172
153
  state.root.removeChild(card.root);
173
154
  }
@@ -181,7 +162,6 @@ module.exports = function () {
181
162
  function FlipCard() {
182
163
  classCallCheck(this, FlipCard);
183
164
  this._root = DOM.create('span', 'tick-flip-card');
184
-
185
165
  var front = DOM.create('span', 'tick-flip-panel-front tick-flip-front tick-flip-panel');
186
166
  var textFront = DOM.create('span', 'tick-flip-panel-front-text');
187
167
  var textFrontWrapper = DOM.create('span', 'tick-flip-panel-text-wrapper');
@@ -198,19 +178,15 @@ module.exports = function () {
198
178
  back.appendChild(textBack);
199
179
  back.appendChild(highlightBack);
200
180
  back.appendChild(shadowBack);
201
-
202
181
  this._root.appendChild(front);
203
182
  this._root.appendChild(back);
204
-
205
183
  this._front = front;
206
184
  this._back = back;
207
185
  this._shadowFront = shadowFront;
208
186
  this._shadowBack = shadowBack;
209
187
  this._highlightBack = highlightBack;
210
-
211
188
  this._textBack = textBackWrapper;
212
189
  this._textFront = textFrontWrapper;
213
-
214
190
  this._frontValue = null;
215
191
  this._backValue = null;
216
192
  }
@@ -261,7 +237,6 @@ module.exports = function () {
261
237
  }]);
262
238
  return FlipCard;
263
239
  }();
264
-
265
240
  return function (root) {
266
241
  var state = {
267
242
  cards: [],
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _index = _interopRequireDefault(require("../util/index.js"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
12
  const ajax = require('@subiz/ajax/src/ajax.js');
11
13
  ajax.env.XMLHttpRequest = window.XMLHttpRequest;
12
14
  const findAnswer = challenge => challenge.answer;
@@ -79,7 +81,6 @@ class _default {
79
81
  if (error) return {
80
82
  error
81
83
  };
82
-
83
84
  let body;
84
85
  ({
85
86
  body,
@@ -121,7 +122,6 @@ class _default {
121
122
  let user_id = this.profile_id;
122
123
  this.token_generator().then(token => {
123
124
  if (user_id != this.profile_id) return done(true);
124
-
125
125
  if (!token) return done(false);
126
126
  if (token == 'error') return done(false);
127
127
  param.request = param.request.addQuery('x-access-token', token);
@@ -133,7 +133,6 @@ class _default {
133
133
  return done(true);
134
134
  });
135
135
  }
136
-
137
136
  setAgentId(agid) {
138
137
  this.agentid = agid;
139
138
  }
@@ -163,9 +162,7 @@ class _default {
163
162
  this.refreshLock.unlock();
164
163
  return;
165
164
  }
166
-
167
165
  let age = (_index.default.Date.now() - (this.last_token_at || 0)) / 1000;
168
-
169
166
  if (!force && this.last_token && age < 1800) {
170
167
  this.refreshLock.unlock();
171
168
  return this.last_token;
@@ -182,14 +179,12 @@ class _default {
182
179
  this.refreshLock.unlock();
183
180
  return;
184
181
  }
185
-
186
182
  if (err) this.last_token = 'error';else this.last_token = token;
187
183
  this.last_token_at = _index.default.Date.now();
188
184
  this.refreshLock.unlock();
189
185
  });
190
186
  return this.last_token;
191
187
  }
192
-
193
188
  let token;
194
189
  let err;
195
190
  try {
@@ -201,7 +196,6 @@ class _default {
201
196
  this.refreshLock.unlock();
202
197
  return;
203
198
  }
204
-
205
199
  if (err) this.last_token = 'error';else this.last_token = token;
206
200
  this.last_token_at = _index.default.Date.now();
207
201
  this.refreshLock.unlock();
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _index = _interopRequireDefault(require("../util/index.js"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
12
  const ajax = require('@subiz/ajax/src/ajax.js');
11
13
  ajax.env.XMLHttpRequest = window.XMLHttpRequest;
12
14
  const findAnswer = challenge => challenge.answer;
@@ -77,7 +79,6 @@ class _default {
77
79
  this.FileURL = FileURL;
78
80
  this.apireq = ajax.setBaseUrl(ApiURL).setContentType('text/plain').beforeHook(jsonifyTextPlain).setParser('json');
79
81
  }
80
-
81
82
  setAgentId(agid) {
82
83
  this.agentid = agid;
83
84
  }
@@ -90,7 +91,6 @@ class _default {
90
91
  this.uid = obj.uid;
91
92
  }
92
93
  }
93
-
94
94
  exports.default = _default;
95
95
  function makeFakeConvo(accid, convoid, userid, agentid) {
96
96
  let inteid = accid + '.subizv4.subikon';
@@ -10,17 +10,17 @@ var _api = _interopRequireDefault(require("./api.js"));
10
10
  var _api_fake = _interopRequireDefault(require("./api_fake.js"));
11
11
  var _realtime_fake = _interopRequireDefault(require("./realtime_fake.js"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
16
  var flow = require('@subiz/flow');
15
17
  var Realtime = require('@subiz/wsclient/index.js');
16
18
  var cookie = require('cookie_js');
17
19
  cookie.defaults.path = '/';
18
20
  cookie.expiresMultiplier = 60 * 60 * 24;
19
21
  cookie.defaults.expires = 3650;
20
-
21
22
  const MAX_CONVO = 20;
22
23
  const page_loaded = _index.default.Date.now();
23
-
24
24
  class Store {
25
25
  constructor(ApiURL, FileURL, RealtimeURL, inmem, fakeapi) {
26
26
  _defineProperty(this, "inmem", false);
@@ -66,7 +66,6 @@ class Store {
66
66
  _defineProperty(this, "fetchConvo", async cid => {
67
67
  await this.readyGate.entry();
68
68
  await this.reconnectGate.entry(undefined, true);
69
-
70
69
  if (this.isInsync(cid)) return this.reconnectGate.open();
71
70
  this.markSync(cid);
72
71
  let {
@@ -109,6 +108,7 @@ class Store {
109
108
  _defineProperty(this, "readyGate", new _index.default.Gate());
110
109
  _defineProperty(this, "convoGate", new _index.default.Gate(true));
111
110
  _defineProperty(this, "reconnectGate", new _index.default.Gate(true));
111
+ _defineProperty(this, "wsGate", new _index.default.Gate(true));
112
112
  _defineProperty(this, "matchLastview", () => this.kv.match('lastview') || {});
113
113
  _defineProperty(this, "matchIsOpen", () => !!this.kv.match('isopen'));
114
114
  _defineProperty(this, "matchHasManuallyClosed", () => !!this.kv.match('hasManuallyClosed'));
@@ -123,8 +123,7 @@ class Store {
123
123
  return;
124
124
  }
125
125
  this.api.sendContentView(this.device, location.href, document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
126
- }, 1000,
127
- {
126
+ }, 1000, {
128
127
  leading: false
129
128
  }));
130
129
  _defineProperty(this, "now", () => _index.default.Date.now() + this.timeDiff);
@@ -173,21 +172,17 @@ class Store {
173
172
  this.cache = new _storage.default.kv(new _storage.default.lsdb('sbz2020', true), 'kv');
174
173
  this.chain = new _storage.default.chain(new _storage.default.lsdb('cbz2020', true), 'ch');
175
174
  this.getLocaleContent = this.api.getLocaleContent;
176
-
177
175
  this.g_haveSentSeenM = {};
178
176
  window.addEventListener('blur', () => this.sendPresence());
179
177
  window.addEventListener('focus', () => this.sendPresence());
180
-
181
178
  setInterval(() => this.browserVisibility === 'visible' && document.hasFocus() && this.sendPresence(), 20000);
182
179
  setInterval(() => (this.browserVisibility !== 'visible' || document.hasFocus()) && this.sendPresence(), 60000);
183
-
184
180
  onVisibilityChange(val => {
185
181
  this.browserVisibility = val;
186
182
  this.sendPresence();
187
183
  });
188
184
  this.loopTime();
189
185
  this.device = this.getDeviceInfo();
190
-
191
186
  const _gaInterval = setInterval(() => {
192
187
  let user = this.kv.match('user') || {};
193
188
  if (!user.id) return;
@@ -195,7 +190,6 @@ class Store {
195
190
  if (!dev.ga_tracking_ids || !dev.ga_client_id) return;
196
191
  clearInterval(_gaInterval);
197
192
  this.device = dev;
198
-
199
193
  let ga_client_id = dev.ga_client_id;
200
194
  if (ga_client_id !== _index.default.getUserAttr(user, 'ga_client_id', 'text')) {
201
195
  this.setUser({
@@ -217,7 +211,6 @@ class Store {
217
211
  if (p.source_id) this._currentViewingProduct.source_id = (p.source_id + '').trim();
218
212
  if (p.sku) this._currentViewingProduct.sku = (p.sku + '').trim();
219
213
  }
220
-
221
214
  getLinkedProduct() {
222
215
  return _index.default.cloneDeep(this._currentViewingProduct);
223
216
  }
@@ -288,7 +281,6 @@ class Store {
288
281
  disconnect(key) {
289
282
  this.g_sync[key] = 0;
290
283
  }
291
-
292
284
  pageLoaded() {
293
285
  return page_loaded;
294
286
  }
@@ -310,7 +302,6 @@ class Store {
310
302
  await this.readyGate.entry();
311
303
  if (!this.isInsync('account')) this.reconnect();
312
304
  }
313
-
314
305
  async init(accid, mask) {
315
306
  this.readyGate.close();
316
307
  accid = (accid || '').trim();
@@ -325,7 +316,6 @@ class Store {
325
316
  }
326
317
  let localstorageMask = this.kv.match('mask');
327
318
  if (!mask && localstorageMask) mask = localstorageMask;
328
-
329
319
  if (mask && localstorageMask && mask !== localstorageMask) this.clearBrowserData();
330
320
  var userId = '';
331
321
  if (mask) {
@@ -343,7 +333,6 @@ class Store {
343
333
  } else {
344
334
  this.new_visitor = false;
345
335
  }
346
-
347
336
  this.cookie.set('__sbmask', mask);
348
337
  this.kv.put('mask', mask);
349
338
  if (this.realtime) this.realtime.stop();
@@ -371,7 +360,6 @@ class Store {
371
360
  accid = (accid || '').trim();
372
361
  this.g_sync = {};
373
362
  this.new_visitor = false;
374
-
375
363
  if (this.realtime) this.realtime.stop();
376
364
  if (this.fake) this.realtime = new _realtime_fake.default();else this.realtime = new Realtime(this.RealtimeURL, {
377
365
  getAccessToken: () => this.api.token_generator()
@@ -397,14 +385,11 @@ class Store {
397
385
  var events = this.listEvents(id);
398
386
  if (!events) return;
399
387
  if (_index.default.size(events) === 0) return;
400
-
401
388
  events = _index.default.filter(events, ev => ev.type === 'message_sent');
402
389
  var lastmsgsent = events[_index.default.size(events) - 1];
403
390
  if (!lastmsgsent) return;
404
391
  if (this.g_haveSentSeenM[lastmsgsent.id]) return;
405
-
406
392
  if (lastmsgsent.id === _index.default.getMsgField(lastmsgsent, 'idempotency')) return;
407
-
408
393
  this.api.markAsSeen(id, lastmsgsent.id);
409
394
  let convo = this.cache.match('convo_' + id) || {};
410
395
  let mem = _index.default.find(convo.members, m => m.id === user.id);
@@ -423,7 +408,6 @@ class Store {
423
408
  }
424
409
  async reconnect() {
425
410
  if (this._die) return;
426
-
427
411
  await this.reconnectGate.entry(undefined, true);
428
412
  if (this.isInsync('account')) return this.reconnectGate.open();
429
413
  this.markSync('account');
@@ -447,7 +431,6 @@ class Store {
447
431
  }
448
432
  return this.reconnectGate.open();
449
433
  }
450
-
451
434
  async setUser(user) {
452
435
  if (!user) return;
453
436
  await this.readyGate.entry();
@@ -459,7 +442,6 @@ class Store {
459
442
  let olduser = this.kv.match('user') || {};
460
443
  var accid = olduser.account_id || user.account_id;
461
444
  var id = olduser.id || user.id;
462
-
463
445
  _index.default.each(user.attributes, newattr => {
464
446
  if (!newattr) return;
465
447
  olduser.attributes = _index.default.filter(olduser.attributes, oldattr => {
@@ -496,17 +478,14 @@ class Store {
496
478
  this.cache.put('account', setting.account);
497
479
  delete setting.account;
498
480
  }
499
-
500
481
  let location = _index.default.get(setting, 'location', []);
501
482
  this.cache.put('location', location);
502
-
503
483
  let bots = _index.default.get(setting, 'bots', []);
504
484
  let botM = {};
505
485
  _index.default.map(bots, bot => {
506
486
  botM[bot.id] = bot;
507
487
  });
508
488
  this.cache.put('bot', botM);
509
-
510
489
  let plugins = _index.default.get(setting, 'plugins', []);
511
490
  let pluginM = {};
512
491
  _index.default.map(plugins, plugin => {
@@ -516,7 +495,6 @@ class Store {
516
495
  pluginM[plugin.id] = plugin;
517
496
  });
518
497
  this.cache.put('plugin', pluginM);
519
-
520
498
  var agents = _index.default.get(setting, 'agents', []);
521
499
  if (_index.default.size(agents) > 0) {
522
500
  let agentM = {};
@@ -526,18 +504,22 @@ class Store {
526
504
  });
527
505
  this.cache.put('agent', agentM);
528
506
  }
529
-
530
507
  let pms = _index.default.get(setting, 'payment_methods', []);
531
508
  this.cache.put('payment_methods', pms);
532
509
  this.pubsub.publish('account');
533
510
  }
534
-
535
511
  async track() {
536
512
  let out = await this.api.sendContentView(this.device, location.href, document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
537
513
  let traffic_source = _index.default.get(out, 'body.by.device.source', '');
538
514
  if (traffic_source) this.kv.put('traffic_source', traffic_source);
539
515
  }
540
516
  async onWs(ev) {
517
+ await this.wsGate.entry();
518
+ this.wsGate.close();
519
+ await this._onWs(ev);
520
+ this.wsGate.open();
521
+ }
522
+ async _onWs(ev) {
541
523
  if (!ev || !ev.type) return;
542
524
  ev.created = _index.default.getMs(ev.created);
543
525
  if (ev.type === 'user_info_updated') {
@@ -547,12 +529,12 @@ class Store {
547
529
  this._setUser(user);
548
530
  return;
549
531
  }
550
-
551
532
  let user = this.kv.match('user') || {};
552
533
  let cid = _index.default.convoOfEv(ev);
553
534
  let convo;
535
+ let alreadyFetched = false;
554
536
  if (cid) {
555
- convo = this.matchConvo(cid);
537
+ convo = this.cache.match('convo_' + cid);
556
538
  if (!convo || !convo.id) {
557
539
  let {
558
540
  body: apiconvo,
@@ -560,28 +542,30 @@ class Store {
560
542
  } = await this.api.getConversation(cid);
561
543
  if (!apiconvo) return;
562
544
  convo = apiconvo;
545
+ alreadyFetched = true;
546
+ this._setConvo(convo);
563
547
  }
564
548
  }
565
549
  if (!convo) return;
566
-
567
550
  let channel = _index.default.get(ev, 'touchpoint.channel', '');
568
551
  if (channel && channel != 'subiz') return;
569
552
  this.pubsub.publish('events', ev);
570
-
571
553
  if (ev.type === 'conversation_joined') {
572
554
  let members = _index.default.get(ev, 'data.conversation.members', []);
573
555
  let me = _index.default.find(members, m => m.id === this.kv.match('user').id);
574
556
  if (me) {
575
557
  await this.chain.reload(cid, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
576
558
  this.markSync('events' + cid);
577
- let {
578
- body: apiconvo
579
- } = await this.api.getConversation(cid);
580
- if (apiconvo) {
581
- convo = apiconvo;
582
- this._setConvo(convo);
559
+ if (!alreadyFetched) {
560
+ let {
561
+ body: apiconvo
562
+ } = await this.api.getConversation(cid);
563
+ if (apiconvo) {
564
+ convo = apiconvo;
565
+ this._setConvo(convo);
566
+ }
567
+ this.pubsub.publish('account');
583
568
  }
584
- this.pubsub.publish('account');
585
569
  }
586
570
  }
587
571
  if (ev.type === 'message_sent') {
@@ -635,7 +619,6 @@ class Store {
635
619
  }
636
620
  convo.last_message_sent = ev;
637
621
  }
638
-
639
622
  if (ev.type !== 'message_pong' && ev.type !== 'conversation_typing') {
640
623
  this.chain.put(cid, ev.id, _index.default.getMs(ev.created), ev);
641
624
  }
@@ -654,7 +637,6 @@ class Store {
654
637
  _index.default.each(formSubmits, submit => {
655
638
  let formev = _index.default.get(this.convoEventM, convoKey + '.' + submit.form_message_id);
656
639
  if (!formev) return;
657
-
658
640
  let forms = _index.default.filter(_index.default.get(formev, 'data.message.attachments'), att => {
659
641
  if (!att) return false;
660
642
  if (att.type !== 'form' && att.type !== 'ask_info_form') return false;
@@ -723,7 +705,6 @@ class Store {
723
705
  if (type === 'message_sent') {
724
706
  _index.default.setMsgField(event, 'idempotency', idempotency);
725
707
  event.data.message.conversation_id = cid;
726
-
727
708
  await flow.map(event.data.message.attachments, 2, async (att, i) => {
728
709
  if (att.type !== 'file') return;
729
710
  if (!att._file) return;
@@ -735,7 +716,6 @@ class Store {
735
716
  }
736
717
  this.onWs(event);
737
718
  await this.convoGate.entry();
738
-
739
719
  await flow.map(files, 1, async att => {
740
720
  const {
741
721
  url,
@@ -771,7 +751,6 @@ class Store {
771
751
  }
772
752
  _setConvo(convo) {
773
753
  let count = 0;
774
-
775
754
  let user = this.kv.match('user');
776
755
  let channel = _index.default.get(convo, 'touchpoint.channel', '');
777
756
  if (channel && channel != 'subiz') return;
@@ -867,7 +846,6 @@ class Store {
867
846
  value: event
868
847
  };
869
848
  });
870
-
871
849
  let user = this.kv.match('user') || {};
872
850
  for (let i = 0; i < events.length; i++) {
873
851
  let ev = events[i].value;
@@ -882,7 +860,6 @@ class Store {
882
860
  }
883
861
  async loopTime() {
884
862
  let startms = _index.default.Date.now();
885
-
886
863
  if (!_index.default.get(this.kv.match('user'), 'id')) return setTimeout(() => this.loopTime(), 240000);
887
864
  let {
888
865
  body: t,
@@ -939,17 +916,13 @@ function loadImage(file) {
939
916
  reader.onload = e => {
940
917
  rs(e.target.result);
941
918
  };
942
-
943
919
  reader.readAsDataURL(file);
944
920
  });
945
921
  }
946
922
  const ImageTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml'];
947
923
  function onVisibilityChange(cb) {
948
924
  var hidden = 'hidden';
949
-
950
- if (hidden in document) document.addEventListener('visibilitychange', onchange);else if ((hidden = 'mozHidden') in document) document.addEventListener('mozvisibilitychange', onchange);else if ((hidden = 'webkitHidden') in document) document.addEventListener('webkitvisibilitychange', onchange);else if ((hidden = 'msHidden') in document) document.addEventListener('msvisibilitychange', onchange);
951
- else if ('onfocusin' in document) document.onfocusin = document.onfocusout = onchange;
952
- else window.onpageshow = window.onpagehide = window.onfocus = window.onblur = onchange;
925
+ if (hidden in document) document.addEventListener('visibilitychange', onchange);else if ((hidden = 'mozHidden') in document) document.addEventListener('mozvisibilitychange', onchange);else if ((hidden = 'webkitHidden') in document) document.addEventListener('webkitvisibilitychange', onchange);else if ((hidden = 'msHidden') in document) document.addEventListener('msvisibilitychange', onchange);else if ('onfocusin' in document) document.onfocusin = document.onfocusout = onchange;else window.onpageshow = window.onpagehide = window.onfocus = window.onblur = onchange;
953
926
  function onchange(evt) {
954
927
  var v = 'visible';
955
928
  var h = 'hidden';
@@ -964,7 +937,6 @@ function onVisibilityChange(cb) {
964
937
  evt = evt || window.event;
965
938
  if (evt.type in evtMap) cb(evtMap[evt.type]);else cb(this[hidden] ? 'hidden' : 'visible');
966
939
  }
967
-
968
940
  if (document[hidden] !== undefined) onchange({
969
941
  type: document[hidden] ? 'blur' : 'focus'
970
942
  });
@@ -984,7 +956,6 @@ const inmemCookie = {
984
956
  delete this.data[k];
985
957
  }
986
958
  };
987
-
988
959
  function getGaClientId() {
989
960
  if (!window.ga) return;
990
961
  if (!window.ga.getAll) return;
@@ -995,7 +966,6 @@ function getGaClientId() {
995
966
  });
996
967
  return ga_client_id;
997
968
  }
998
-
999
969
  function getGaTrackingIds() {
1000
970
  var trackingIds = [];
1001
971
  if (!(window.ga && window.ga.getAll)) return trackingIds;
@@ -1045,7 +1015,6 @@ function sendEventToThirdParty(category, action, label) {
1045
1015
  event_label: label
1046
1016
  });
1047
1017
  }
1048
-
1049
1018
  let mobileCheck = function (a) {
1050
1019
  return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
1051
1020
  }(navigator.userAgent || navigator.vendor || window.opera);
@@ -9,7 +9,6 @@ exports.trackInactivity = trackInactivity;
9
9
  exports.trackScrollingPercentage = trackScrollingPercentage;
10
10
  exports.trackTimeOnPage = trackTimeOnPage;
11
11
  var common = require('./common.js');
12
-
13
12
  function trackExitIntent(cb) {
14
13
  let handler = e => {
15
14
  if (e.clientY > 10) return;
@@ -18,7 +17,6 @@ function trackExitIntent(cb) {
18
17
  };
19
18
  document.addEventListener('mouseout', handler);
20
19
  }
21
-
22
20
  function trackScrollingPercentage(percent, cb) {
23
21
  let handleScroll = e => {
24
22
  let scrollTop = e.srcElement.scrollingElement ? e.srcElement.scrollingElement.scrollTop : e.srcElement.scrollTop;
@@ -30,7 +28,6 @@ function trackScrollingPercentage(percent, cb) {
30
28
  };
31
29
  window.addEventListener('scroll', handleScroll, false);
32
30
  }
33
-
34
31
  function trackAreaClicked(selector, cb) {
35
32
  if (!selector) return;
36
33
  selector = selector || '';
@@ -47,7 +44,6 @@ function trackAreaClicked(selector, cb) {
47
44
  });
48
45
  });
49
46
  }
50
-
51
47
  function trackInactivity(seconds, cb) {
52
48
  let events = ['scroll', 'keyup', 'keydown', 'mousemove', 'mousewheel', 'mouseenter', 'mouseover', 'mousedown', 'touchstart', 'touchmove', 'touchenter'];
53
49
  let inactiveSeconds = 0;
@@ -71,7 +67,6 @@ let timeOnPage = 0;
71
67
  setInterval(() => {
72
68
  timeOnPage += 5;
73
69
  }, 5000);
74
-
75
70
  function trackTimeOnPage(seconds, cb) {
76
71
  if (seconds < 1) {
77
72
  return setTimeout(function () {