@subiz/widget-v4 4.0.99 → 4.1.2

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 (114) hide show
  1. package/compiled_src/call/call.js +3 -3
  2. package/compiled_src/chatbox/AgentsAvatar.js +0 -3
  3. package/compiled_src/chatbox/ButtonAttachments.js +0 -1
  4. package/compiled_src/chatbox/ChatButton.js +0 -5
  5. package/compiled_src/chatbox/DropdownSelect.js +4 -5
  6. package/compiled_src/chatbox/Event.js +0 -2
  7. package/compiled_src/chatbox/Events.js +1 -9
  8. package/compiled_src/chatbox/FormAttachment.js +0 -1
  9. package/compiled_src/chatbox/GenericTemplateAttachments.js +0 -3
  10. package/compiled_src/chatbox/Header.js +5 -2
  11. package/compiled_src/chatbox/InfoMessage.js +0 -1
  12. package/compiled_src/chatbox/MessageInput.js +3 -3
  13. package/compiled_src/chatbox/Order.js +3 -1
  14. package/compiled_src/chatbox/OrderAttachments.js +0 -1
  15. package/compiled_src/chatbox/QuickReplies.js +0 -1
  16. package/compiled_src/chatbox/Rating.js +3 -1
  17. package/compiled_src/chatbox/TextMessage.js +0 -2
  18. package/compiled_src/chatbox/Typing.js +0 -1
  19. package/compiled_src/chatbox/Widget.js +4 -18
  20. package/compiled_src/chatbox/main.js +0 -1
  21. package/compiled_src/chatbox/releaseAnimation.js +0 -1
  22. package/compiled_src/contact/contact.js +3 -7
  23. package/compiled_src/lib.js +7 -18
  24. package/compiled_src/notif/notif.js +3 -3
  25. package/compiled_src/order/address_picker.js +4 -6
  26. package/compiled_src/order/index.js +0 -2
  27. package/compiled_src/order/order.js +4 -7
  28. package/compiled_src/plugin.js +0 -9
  29. package/compiled_src/popup/countdown.js +3 -5
  30. package/compiled_src/popup/popup.js +3 -8
  31. package/compiled_src/popup/tick.core.commonjs.js +16 -158
  32. package/compiled_src/popup/tick.view.flip.commonjs.js +0 -25
  33. package/compiled_src/store/api.js +3 -9
  34. package/compiled_src/store/api_fake.js +3 -3
  35. package/compiled_src/store/store.js +6 -49
  36. package/compiled_src/util/campaign.js +0 -5
  37. package/compiled_src/util/common.js +1 -28
  38. package/compiled_src/util/extractor.js +0 -1
  39. package/compiled_src/util/gate.test.js +0 -1
  40. package/compiled_src/util/index.js +0 -1
  41. package/compiled_src/util/op.js +0 -1
  42. package/compiled_src/util/order.js +0 -4
  43. package/package.json +4 -4
  44. package/src/chatbox/Header.js +9 -3
  45. package/src/lib.js +5 -15
  46. package/src/store/store.js +1 -1
  47. package/src/util/common.js +1 -1
  48. package/dist/132.js +0 -6645
  49. package/dist/178.js +0 -406
  50. package/dist/213.js +0 -2950
  51. package/dist/335.js +0 -376
  52. package/dist/362.js +0 -107
  53. package/dist/441.js +0 -2840
  54. package/dist/605.js +0 -297
  55. package/dist/678.js +0 -107
  56. package/dist/782.js +0 -107
  57. package/dist/HASH +0 -1
  58. package/dist/assets/img/Facebook.64607ec.png +0 -0
  59. package/dist/assets/img/Zalo.6845707.png +0 -0
  60. package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
  61. package/dist/assets/img/caret.998eb8f.svg +0 -1
  62. package/dist/assets/img/convos_empty.2353007.svg +0 -72
  63. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  64. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  65. package/dist/assets/img/done_gray.d7e8203.svg +0 -4
  66. package/dist/assets/img/done_green.b817fd4.svg +0 -4
  67. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  68. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  69. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  70. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  71. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  72. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  73. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  74. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  75. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  76. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  77. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  78. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  79. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  80. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  81. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  82. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  83. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  84. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  85. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  86. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  87. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  88. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  89. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  90. package/dist/assets/img/empty.29bed2d.svg +0 -23
  91. package/dist/assets/img/empty_1.0b98af0.svg +0 -11
  92. package/dist/assets/img/external-link.90577cc.svg +0 -1
  93. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  94. package/dist/assets/img/ghn.070f8e3.svg +0 -17
  95. package/dist/assets/img/ghtk.326eac1.svg +0 -18
  96. package/dist/assets/img/image_default.be0698b.png +0 -0
  97. package/dist/assets/img/info.ebce7ea.svg +0 -1
  98. package/dist/assets/img/loader.37000a7.svg +0 -1
  99. package/dist/assets/img/loading_static.8f403ae.svg +0 -10
  100. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  101. package/dist/assets/img/package.8d37d0f.svg +0 -5
  102. package/dist/assets/img/package_fade.763c001.svg +0 -1
  103. package/dist/assets/img/rating--average.1ea492c.svg +0 -12
  104. package/dist/assets/img/rating--great.e3d712e.svg +0 -16
  105. package/dist/assets/img/rating--poor.2938a25.svg +0 -12
  106. package/dist/assets/img/search.f9705ff.svg +0 -1
  107. package/dist/assets/img/send.6db52a9.svg +0 -3
  108. package/dist/assets/img/shop.f7dc7d8.svg +0 -1
  109. package/dist/assets/img/shop_faded.df7845a.svg +0 -1
  110. package/dist/assets/img/subiz-mono.877e9f5.svg +0 -3
  111. package/dist/assets/img/x.26fdfa3.svg +0 -5
  112. package/dist/malicious-app.js +0 -13
  113. package/dist/screenshoot.html +0 -7
  114. package/dist/screenshoot.js +0 -5689
@@ -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 {
@@ -124,8 +123,7 @@ class Store {
124
123
  return;
125
124
  }
126
125
  this.api.sendContentView(this.device, location.href, document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
127
- }, 1000,
128
- {
126
+ }, 1000, {
129
127
  leading: false
130
128
  }));
131
129
  _defineProperty(this, "now", () => _index.default.Date.now() + this.timeDiff);
@@ -174,21 +172,17 @@ class Store {
174
172
  this.cache = new _storage.default.kv(new _storage.default.lsdb('sbz2020', true), 'kv');
175
173
  this.chain = new _storage.default.chain(new _storage.default.lsdb('cbz2020', true), 'ch');
176
174
  this.getLocaleContent = this.api.getLocaleContent;
177
-
178
175
  this.g_haveSentSeenM = {};
179
176
  window.addEventListener('blur', () => this.sendPresence());
180
177
  window.addEventListener('focus', () => this.sendPresence());
181
-
182
178
  setInterval(() => this.browserVisibility === 'visible' && document.hasFocus() && this.sendPresence(), 20000);
183
179
  setInterval(() => (this.browserVisibility !== 'visible' || document.hasFocus()) && this.sendPresence(), 60000);
184
-
185
180
  onVisibilityChange(val => {
186
181
  this.browserVisibility = val;
187
182
  this.sendPresence();
188
183
  });
189
184
  this.loopTime();
190
185
  this.device = this.getDeviceInfo();
191
-
192
186
  const _gaInterval = setInterval(() => {
193
187
  let user = this.kv.match('user') || {};
194
188
  if (!user.id) return;
@@ -196,7 +190,6 @@ class Store {
196
190
  if (!dev.ga_tracking_ids || !dev.ga_client_id) return;
197
191
  clearInterval(_gaInterval);
198
192
  this.device = dev;
199
-
200
193
  let ga_client_id = dev.ga_client_id;
201
194
  if (ga_client_id !== _index.default.getUserAttr(user, 'ga_client_id', 'text')) {
202
195
  this.setUser({
@@ -218,7 +211,6 @@ class Store {
218
211
  if (p.source_id) this._currentViewingProduct.source_id = (p.source_id + '').trim();
219
212
  if (p.sku) this._currentViewingProduct.sku = (p.sku + '').trim();
220
213
  }
221
-
222
214
  getLinkedProduct() {
223
215
  return _index.default.cloneDeep(this._currentViewingProduct);
224
216
  }
@@ -289,7 +281,6 @@ class Store {
289
281
  disconnect(key) {
290
282
  this.g_sync[key] = 0;
291
283
  }
292
-
293
284
  pageLoaded() {
294
285
  return page_loaded;
295
286
  }
@@ -311,7 +302,6 @@ class Store {
311
302
  await this.readyGate.entry();
312
303
  if (!this.isInsync('account')) this.reconnect();
313
304
  }
314
-
315
305
  async init(accid, mask) {
316
306
  this.readyGate.close();
317
307
  accid = (accid || '').trim();
@@ -326,7 +316,6 @@ class Store {
326
316
  }
327
317
  let localstorageMask = this.kv.match('mask');
328
318
  if (!mask && localstorageMask) mask = localstorageMask;
329
-
330
319
  if (mask && localstorageMask && mask !== localstorageMask) this.clearBrowserData();
331
320
  var userId = '';
332
321
  if (mask) {
@@ -344,7 +333,6 @@ class Store {
344
333
  } else {
345
334
  this.new_visitor = false;
346
335
  }
347
-
348
336
  this.cookie.set('__sbmask', mask);
349
337
  this.kv.put('mask', mask);
350
338
  if (this.realtime) this.realtime.stop();
@@ -372,7 +360,6 @@ class Store {
372
360
  accid = (accid || '').trim();
373
361
  this.g_sync = {};
374
362
  this.new_visitor = false;
375
-
376
363
  if (this.realtime) this.realtime.stop();
377
364
  if (this.fake) this.realtime = new _realtime_fake.default();else this.realtime = new Realtime(this.RealtimeURL, {
378
365
  getAccessToken: () => this.api.token_generator()
@@ -398,18 +385,15 @@ class Store {
398
385
  var events = this.listEvents(id);
399
386
  if (!events) return;
400
387
  if (_index.default.size(events) === 0) return;
401
-
402
388
  events = _index.default.filter(events, ev => ev.type === 'message_sent');
403
389
  var lastmsgsent = events[_index.default.size(events) - 1];
404
390
  if (!lastmsgsent) return;
405
391
  if (this.g_haveSentSeenM[lastmsgsent.id]) return;
406
-
407
392
  if (lastmsgsent.id === _index.default.getMsgField(lastmsgsent, 'idempotency')) return;
408
-
409
393
  this.api.markAsSeen(id, lastmsgsent.id);
410
394
  let convo = this.cache.match('convo_' + id) || {};
411
395
  let mem = _index.default.find(convo.members, m => m.id === user.id);
412
- mem.seen_at = Date.now();
396
+ if (mem) mem.seen_at = Date.now();
413
397
  this._setConvo(convo);
414
398
  this.g_haveSentSeenM[lastmsgsent.id] = true;
415
399
  });
@@ -424,7 +408,6 @@ class Store {
424
408
  }
425
409
  async reconnect() {
426
410
  if (this._die) return;
427
-
428
411
  await this.reconnectGate.entry(undefined, true);
429
412
  if (this.isInsync('account')) return this.reconnectGate.open();
430
413
  this.markSync('account');
@@ -448,7 +431,6 @@ class Store {
448
431
  }
449
432
  return this.reconnectGate.open();
450
433
  }
451
-
452
434
  async setUser(user) {
453
435
  if (!user) return;
454
436
  await this.readyGate.entry();
@@ -460,7 +442,6 @@ class Store {
460
442
  let olduser = this.kv.match('user') || {};
461
443
  var accid = olduser.account_id || user.account_id;
462
444
  var id = olduser.id || user.id;
463
-
464
445
  _index.default.each(user.attributes, newattr => {
465
446
  if (!newattr) return;
466
447
  olduser.attributes = _index.default.filter(olduser.attributes, oldattr => {
@@ -497,17 +478,14 @@ class Store {
497
478
  this.cache.put('account', setting.account);
498
479
  delete setting.account;
499
480
  }
500
-
501
481
  let location = _index.default.get(setting, 'location', []);
502
482
  this.cache.put('location', location);
503
-
504
483
  let bots = _index.default.get(setting, 'bots', []);
505
484
  let botM = {};
506
485
  _index.default.map(bots, bot => {
507
486
  botM[bot.id] = bot;
508
487
  });
509
488
  this.cache.put('bot', botM);
510
-
511
489
  let plugins = _index.default.get(setting, 'plugins', []);
512
490
  let pluginM = {};
513
491
  _index.default.map(plugins, plugin => {
@@ -517,7 +495,6 @@ class Store {
517
495
  pluginM[plugin.id] = plugin;
518
496
  });
519
497
  this.cache.put('plugin', pluginM);
520
-
521
498
  var agents = _index.default.get(setting, 'agents', []);
522
499
  if (_index.default.size(agents) > 0) {
523
500
  let agentM = {};
@@ -527,12 +504,10 @@ class Store {
527
504
  });
528
505
  this.cache.put('agent', agentM);
529
506
  }
530
-
531
507
  let pms = _index.default.get(setting, 'payment_methods', []);
532
508
  this.cache.put('payment_methods', pms);
533
509
  this.pubsub.publish('account');
534
510
  }
535
-
536
511
  async track() {
537
512
  let out = await this.api.sendContentView(this.device, location.href, document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
538
513
  let traffic_source = _index.default.get(out, 'body.by.device.source', '');
@@ -554,7 +529,6 @@ class Store {
554
529
  this._setUser(user);
555
530
  return;
556
531
  }
557
-
558
532
  let user = this.kv.match('user') || {};
559
533
  let cid = _index.default.convoOfEv(ev);
560
534
  let convo;
@@ -573,11 +547,9 @@ class Store {
573
547
  }
574
548
  }
575
549
  if (!convo) return;
576
-
577
550
  let channel = _index.default.get(ev, 'touchpoint.channel', '');
578
551
  if (channel && channel != 'subiz') return;
579
552
  this.pubsub.publish('events', ev);
580
-
581
553
  if (ev.type === 'conversation_joined') {
582
554
  let members = _index.default.get(ev, 'data.conversation.members', []);
583
555
  let me = _index.default.find(members, m => m.id === this.kv.match('user').id);
@@ -647,7 +619,6 @@ class Store {
647
619
  }
648
620
  convo.last_message_sent = ev;
649
621
  }
650
-
651
622
  if (ev.type !== 'message_pong' && ev.type !== 'conversation_typing') {
652
623
  this.chain.put(cid, ev.id, _index.default.getMs(ev.created), ev);
653
624
  }
@@ -666,7 +637,6 @@ class Store {
666
637
  _index.default.each(formSubmits, submit => {
667
638
  let formev = _index.default.get(this.convoEventM, convoKey + '.' + submit.form_message_id);
668
639
  if (!formev) return;
669
-
670
640
  let forms = _index.default.filter(_index.default.get(formev, 'data.message.attachments'), att => {
671
641
  if (!att) return false;
672
642
  if (att.type !== 'form' && att.type !== 'ask_info_form') return false;
@@ -735,7 +705,6 @@ class Store {
735
705
  if (type === 'message_sent') {
736
706
  _index.default.setMsgField(event, 'idempotency', idempotency);
737
707
  event.data.message.conversation_id = cid;
738
-
739
708
  await flow.map(event.data.message.attachments, 2, async (att, i) => {
740
709
  if (att.type !== 'file') return;
741
710
  if (!att._file) return;
@@ -747,7 +716,6 @@ class Store {
747
716
  }
748
717
  this.onWs(event);
749
718
  await this.convoGate.entry();
750
-
751
719
  await flow.map(files, 1, async att => {
752
720
  const {
753
721
  url,
@@ -783,7 +751,6 @@ class Store {
783
751
  }
784
752
  _setConvo(convo) {
785
753
  let count = 0;
786
-
787
754
  let user = this.kv.match('user');
788
755
  let channel = _index.default.get(convo, 'touchpoint.channel', '');
789
756
  if (channel && channel != 'subiz') return;
@@ -879,7 +846,6 @@ class Store {
879
846
  value: event
880
847
  };
881
848
  });
882
-
883
849
  let user = this.kv.match('user') || {};
884
850
  for (let i = 0; i < events.length; i++) {
885
851
  let ev = events[i].value;
@@ -894,7 +860,6 @@ class Store {
894
860
  }
895
861
  async loopTime() {
896
862
  let startms = _index.default.Date.now();
897
-
898
863
  if (!_index.default.get(this.kv.match('user'), 'id')) return setTimeout(() => this.loopTime(), 240000);
899
864
  let {
900
865
  body: t,
@@ -951,17 +916,13 @@ function loadImage(file) {
951
916
  reader.onload = e => {
952
917
  rs(e.target.result);
953
918
  };
954
-
955
919
  reader.readAsDataURL(file);
956
920
  });
957
921
  }
958
922
  const ImageTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml'];
959
923
  function onVisibilityChange(cb) {
960
924
  var hidden = 'hidden';
961
-
962
- 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);
963
- else if ('onfocusin' in document) document.onfocusin = document.onfocusout = onchange;
964
- 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;
965
926
  function onchange(evt) {
966
927
  var v = 'visible';
967
928
  var h = 'hidden';
@@ -976,7 +937,6 @@ function onVisibilityChange(cb) {
976
937
  evt = evt || window.event;
977
938
  if (evt.type in evtMap) cb(evtMap[evt.type]);else cb(this[hidden] ? 'hidden' : 'visible');
978
939
  }
979
-
980
940
  if (document[hidden] !== undefined) onchange({
981
941
  type: document[hidden] ? 'blur' : 'focus'
982
942
  });
@@ -996,7 +956,6 @@ const inmemCookie = {
996
956
  delete this.data[k];
997
957
  }
998
958
  };
999
-
1000
959
  function getGaClientId() {
1001
960
  if (!window.ga) return;
1002
961
  if (!window.ga.getAll) return;
@@ -1007,7 +966,6 @@ function getGaClientId() {
1007
966
  });
1008
967
  return ga_client_id;
1009
968
  }
1010
-
1011
969
  function getGaTrackingIds() {
1012
970
  var trackingIds = [];
1013
971
  if (!(window.ga && window.ga.getAll)) return trackingIds;
@@ -1057,7 +1015,6 @@ function sendEventToThirdParty(category, action, label) {
1057
1015
  event_label: label
1058
1016
  });
1059
1017
  }
1060
-
1061
1018
  let mobileCheck = function (a) {
1062
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));
1063
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 () {