@subiz/widget-v4 4.1.72 → 4.1.74

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 (94) hide show
  1. package/compiled_src/store/store.js +19 -12
  2. package/package.json +3 -3
  3. package/src/store/store.js +21 -28
  4. package/dist/127.js +0 -273
  5. package/dist/132.js +0 -2796
  6. package/dist/185.js +0 -1885
  7. package/dist/18eaf7ad0c6.127.js +0 -1
  8. package/dist/18eaf7ad0c6.132.js +0 -1
  9. package/dist/18eaf7ad0c6.185.js +0 -1
  10. package/dist/18eaf7ad0c6.27.js +0 -1
  11. package/dist/18eaf7ad0c6.278.js +0 -1
  12. package/dist/18eaf7ad0c6.459.js +0 -1
  13. package/dist/18eaf7ad0c6.490.js +0 -1
  14. package/dist/18eaf7ad0c6.74.js +0 -1
  15. package/dist/18eaf7ad0c6.997.js +0 -1
  16. package/dist/18eaf7ad0c6.app.js +0 -1
  17. package/dist/18eaf7ad0c6.index.html +0 -33
  18. package/dist/18eaf7ad0c6.library.html +0 -33
  19. package/dist/18eaf7ad0c6.library.js +0 -1
  20. package/dist/18eaf7ad0c6.preview.html +0 -759
  21. package/dist/18eaf7ad0c6.preview.js +0 -1
  22. package/dist/18eaf7ad0c6.screenshoot.js +0 -1
  23. package/dist/18eaf7ad0c6.webview.js +0 -1
  24. package/dist/27.js +0 -107
  25. package/dist/278.js +0 -406
  26. package/dist/459.js +0 -107
  27. package/dist/490.js +0 -304
  28. package/dist/74.js +0 -372
  29. package/dist/997.js +0 -107
  30. package/dist/HASH +0 -1
  31. package/dist/assets/img/Facebook.64607ec.png +0 -0
  32. package/dist/assets/img/Zalo.6845707.png +0 -0
  33. package/dist/assets/img/award1a.1a58e10.png +0 -0
  34. package/dist/assets/img/award3a.3b74423.png +0 -0
  35. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  36. package/dist/assets/img/award5.39eb7ae.png +0 -0
  37. package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
  38. package/dist/assets/img/caret.998eb8f.svg +0 -1
  39. package/dist/assets/img/convos_empty.2353007.svg +0 -72
  40. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  41. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  42. package/dist/assets/img/done_gray.d7e8203.svg +0 -4
  43. package/dist/assets/img/done_green.b817fd4.svg +0 -4
  44. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  45. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  46. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  47. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  48. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  49. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  50. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  51. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  52. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  53. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  54. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  55. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  56. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  57. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  58. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  59. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  60. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  61. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  62. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  63. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  64. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  65. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  66. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  67. package/dist/assets/img/empty.29bed2d.svg +0 -23
  68. package/dist/assets/img/empty_1.0b98af0.svg +0 -11
  69. package/dist/assets/img/examplte_logo.f86535f.svg +0 -1
  70. package/dist/assets/img/external-link.90577cc.svg +0 -1
  71. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  72. package/dist/assets/img/ghn.070f8e3.svg +0 -17
  73. package/dist/assets/img/ghtk.326eac1.svg +0 -18
  74. package/dist/assets/img/image_default.be0698b.png +0 -0
  75. package/dist/assets/img/info.ebce7ea.svg +0 -1
  76. package/dist/assets/img/loader.37000a7.svg +0 -1
  77. package/dist/assets/img/loading_static.a27f0ac.svg +0 -10
  78. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  79. package/dist/assets/img/main-service2.9b99549.png +0 -0
  80. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  81. package/dist/assets/img/package.8d37d0f.svg +0 -5
  82. package/dist/assets/img/package_fade.763c001.svg +0 -1
  83. package/dist/assets/img/rating--average.1ea492c.svg +0 -12
  84. package/dist/assets/img/rating--great.e3d712e.svg +0 -16
  85. package/dist/assets/img/rating--poor.2938a25.svg +0 -12
  86. package/dist/assets/img/search.f9705ff.svg +0 -1
  87. package/dist/assets/img/send.6db52a9.svg +0 -3
  88. package/dist/assets/img/shop.f7dc7d8.svg +0 -1
  89. package/dist/assets/img/shop_faded.df7845a.svg +0 -1
  90. package/dist/assets/img/subiz-mono.877e9f5.svg +0 -3
  91. package/dist/assets/img/x.26fdfa3.svg +0 -5
  92. package/dist/malicious-app.js +0 -15
  93. package/dist/screenshoot.html +0 -7
  94. package/dist/screenshoot.js +0 -10467
@@ -175,6 +175,7 @@ class Store {
175
175
  this.fake = fakeapi;
176
176
  this.FileURL = FileURL;
177
177
  this._track_page_view = true;
178
+ this.device_type = 'desktop';
178
179
  if (this.fake) this.api = new _api_fake.default(ApiURL, FileURL);else this.api = new _api.default(ApiURL, FileURL);
179
180
  if (!inmem) {
180
181
  try {
@@ -195,15 +196,27 @@ class Store {
195
196
  this.chain = new _storage.default.chain(new _storage.default.lsdb('cbz2023', true), 'ch');
196
197
  this.getLocaleContent = this.api.getLocaleContent;
197
198
  this.g_haveSentSeenM = {};
198
- window.addEventListener('blur', this.sendPresence);
199
- window.addEventListener('focus', this.sendPresence);
199
+ this.last_focused = _index.default.Date.now();
200
+ window.addEventListener('blur', () => {
201
+ this.last_focused = _index.default.Date.now();
202
+ this.sendPresence();
203
+ });
204
+ window.addEventListener('focus', () => {
205
+ this.last_focused = 0;
206
+ this.sendPresence();
207
+ });
208
+ window.addEventListener('beforeunload', () => this.api.sendLostFocus());
200
209
  this._presenceInterval1 = _index.default.setInterval(() => {
201
210
  if (this._die) return _index.default.clearInterval(this._presenceInterval1);
202
211
  if (this.browserVisibility === 'visible' && document.hasFocus()) this.sendPresence();
203
212
  }, 20000);
204
213
  this._presenceInterval2 = _index.default.setInterval(() => {
205
214
  if (this._die) return _index.default.clearInterval(this._presenceInterval2);
206
- if (this.browserVisibility !== 'visible' || document.hasFocus()) this.sendPresence();
215
+ if (this.browserVisibility === 'visible' && document.hasFocus()) return;
216
+ if (this.last_focused && _index.default.Date.now() - this.last_focused > 30 * 60000) {
217
+ return;
218
+ }
219
+ this.sendPresence();
207
220
  }, 60000);
208
221
  onVisibilityChange(val => {
209
222
  if (this._die) return;
@@ -281,12 +294,9 @@ class Store {
281
294
  }
282
295
  getDeviceInfo() {
283
296
  let device = {
284
- user_agent: window.navigator.userAgent,
285
297
  screen_resolution: window.screen.width + 'x' + window.screen.height,
286
298
  source_referrer: document.referrer,
287
299
  platform: window.navigator.platform,
288
- referrer: document.URL,
289
- type: this.isMobile() ? 'mobile' : 'desktop',
290
300
  language: navigator.language,
291
301
  page_url: document.URL,
292
302
  page_title: document.title
@@ -305,10 +315,10 @@ class Store {
305
315
  this.pubsub.publish('account');
306
316
  }
307
317
  isMobile() {
308
- return this.forceDevice === 'mobile' || mobileCheck;
318
+ return this.forceDevice === 'mobile' || this.device_type == 'mobile';
309
319
  }
310
320
  isTablet() {
311
- return this.forceDevice === 'tablet' || tabletCheck;
321
+ return this.forceDevice === 'tablet' || this.device_type == 'tablet';
312
322
  }
313
323
  isDesktop() {
314
324
  return this.forceDevice === 'desktop' || !this.isMobile() && !this.isTable();
@@ -546,6 +556,7 @@ class Store {
546
556
  botM[bot.id] = bot;
547
557
  });
548
558
  this.cache.put('bot', botM);
559
+ this.device_type = setting.device_type || 'desktop';
549
560
  let plugins = _index.default.get(setting, 'plugins', []);
550
561
  let pluginM = {};
551
562
  _index.default.map(plugins, plugin => {
@@ -1076,10 +1087,6 @@ function sendEventToThirdParty(category, action, label) {
1076
1087
  event_label: label
1077
1088
  });
1078
1089
  }
1079
- let mobileCheck = function (a) {
1080
- 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));
1081
- }(navigator.userAgent || navigator.vendor || window.opera);
1082
- let tabletCheck = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(navigator.userAgent);
1083
1090
  let cleanLocalStorage = () => {
1084
1091
  try {
1085
1092
  localStorage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.72",
3
+ "version": "4.1.74",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -30,9 +30,9 @@
30
30
  "babel-loader": "^9.1.3",
31
31
  "babel-plugin-syntax-jsx": "^6.18.0",
32
32
  "html-webpack-plugin": "^5.6.0",
33
- "puppeteer": "^22.6.3",
33
+ "puppeteer": "^22.6.4",
34
34
  "webpack": "^5.91.0",
35
- "webpack-bundle-analyzer": "^4.10.1",
35
+ "webpack-bundle-analyzer": "^4.10.2",
36
36
  "webpack-cli": "^5.1.4",
37
37
  "webpack-dev-server": "^5.0.4"
38
38
  }
@@ -29,6 +29,7 @@ export default class Store {
29
29
  this.fake = fakeapi
30
30
  this.FileURL = FileURL
31
31
  this._track_page_view = true
32
+ this.device_type = 'desktop'
32
33
  if (this.fake) this.api = new APIFake(ApiURL, FileURL)
33
34
  else this.api = new API(ApiURL, FileURL)
34
35
 
@@ -57,19 +58,31 @@ export default class Store {
57
58
 
58
59
  // dont dupplicate seen
59
60
  this.g_haveSentSeenM = {}
60
-
61
- window.addEventListener('blur', this.sendPresence)
62
- window.addEventListener('focus', this.sendPresence)
61
+ this.last_focused = sb.Date.now() // 0 -> in focus, timestamp -> lost focus at
62
+ window.addEventListener('blur', () => {
63
+ this.last_focused = sb.Date.now()
64
+ this.sendPresence()
65
+ })
66
+ window.addEventListener('focus', () => {
67
+ this.last_focused = 0 //
68
+ this.sendPresence()
69
+ })
70
+ window.addEventListener('beforeunload', () => this.api.sendLostFocus())
63
71
 
64
72
  // faster send rate when has focus
65
73
  this._presenceInterval1 = sb.setInterval(() => {
66
74
  if (this._die) return sb.clearInterval(this._presenceInterval1)
67
75
  if (this.browserVisibility === 'visible' && document.hasFocus()) this.sendPresence()
68
76
  }, 20000) // dont bother delete this
69
- // slower send rate send when no focus
77
+ // slower send rate send when user not focused
70
78
  this._presenceInterval2 = sb.setInterval(() => {
71
79
  if (this._die) return sb.clearInterval(this._presenceInterval2)
72
- if (this.browserVisibility !== 'visible' || document.hasFocus()) this.sendPresence()
80
+ if (this.browserVisibility === 'visible' && document.hasFocus()) return
81
+ if (this.last_focused && sb.Date.now() - this.last_focused > 30 * 60000) {
82
+ // lost focus for more than 30 min
83
+ return // dont send presence
84
+ }
85
+ this.sendPresence()
73
86
  }, 60000) // dont bother delete this
74
87
 
75
88
  onVisibilityChange((val) => {
@@ -162,12 +175,9 @@ export default class Store {
162
175
 
163
176
  getDeviceInfo() {
164
177
  let device = {
165
- user_agent: window.navigator.userAgent,
166
178
  screen_resolution: window.screen.width + 'x' + window.screen.height,
167
179
  source_referrer: document.referrer,
168
180
  platform: window.navigator.platform,
169
- referrer: document.URL,
170
- type: this.isMobile() ? 'mobile' : 'desktop',
171
181
  language: navigator.language,
172
182
  page_url: document.URL,
173
183
  page_title: document.title,
@@ -192,11 +202,11 @@ export default class Store {
192
202
  }
193
203
 
194
204
  isMobile() {
195
- return this.forceDevice === 'mobile' || mobileCheck
205
+ return this.forceDevice === 'mobile' || this.device_type == 'mobile'
196
206
  }
197
207
 
198
208
  isTablet() {
199
- return this.forceDevice === 'tablet' || tabletCheck
209
+ return this.forceDevice === 'tablet' || this.device_type == 'tablet'
200
210
  }
201
211
 
202
212
  isDesktop() {
@@ -647,7 +657,7 @@ export default class Store {
647
657
  botM[bot.id] = bot
648
658
  })
649
659
  this.cache.put('bot', botM)
650
-
660
+ this.device_type = setting.device_type || 'desktop'
651
661
  // web plugin
652
662
  let plugins = sb.get(setting, 'plugins', [])
653
663
  let pluginM = {}
@@ -1259,23 +1269,6 @@ function sendEventToThirdParty(category, action, label) {
1259
1269
  dataLayer.push({event: category, event_action: action, event_label: label})
1260
1270
  }
1261
1271
 
1262
- // from http://detectmobilebrowsers.com/
1263
- let mobileCheck = (function (a) {
1264
- return (
1265
- /(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(
1266
- a,
1267
- ) ||
1268
- /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(
1269
- a.substr(0, 4),
1270
- )
1271
- )
1272
- })(navigator.userAgent || navigator.vendor || window.opera)
1273
-
1274
- let tabletCheck =
1275
- /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(
1276
- navigator.userAgent,
1277
- )
1278
-
1279
1272
  let cleanLocalStorage = () => {
1280
1273
  try {
1281
1274
  localStorage
package/dist/127.js DELETED
@@ -1,273 +0,0 @@
1
- "use strict";
2
- (self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[127],{
3
-
4
- /***/ 6127:
5
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6
-
7
- __webpack_require__.r(__webpack_exports__);
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ "default": () => (/* binding */ ProductAttachments)
10
- /* harmony export */ });
11
- /* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6801);
12
- /* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2840);
13
- /* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(172);
14
-
15
-
16
-
17
- class ProductAttachments extends _common_js__WEBPACK_IMPORTED_MODULE_1__/* .Com */ .Mw {
18
- render() {
19
- let byType = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(this.props.ev, 'by.type');
20
- if (byType === 'user') return null;
21
- let acc = this.props.store.matchAccount();
22
- var attachments = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(this.props.ev, 'data.message.attachments', []);
23
- let orders = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
24
- if (orders.length === 0) return null;
25
- let $orders = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.map(orders, (order, index) => {
26
- calcOrderTotal(order);
27
- let $note = null;
28
- if (order.note) {
29
- $note = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
30
- class: "order_attachment__label"
31
- }, this.props.t('note')), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
32
- class: "order_attachment__note",
33
- title: order.note
34
- }, order.note));
35
- }
36
- let $products = null;
37
- if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.size(order.items) > 0) {
38
- $products = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
39
- class: "order_attachment__label"
40
- }, this.props.t('product')), _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.map(order.items, item => {
41
- let product = item.product || {};
42
- return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
43
- class: "order_attachment__product"
44
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("img", {
45
- class: "order_attachment__product_img",
46
- alt: '' + _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(product, 'id'),
47
- src: _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(product, 'image', __webpack_require__(2876))
48
- }), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
49
- style: "overflow: hidden !important;"
50
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
51
- class: "order_attachment__product_name",
52
- title: this.props.t.i18n(product.i18n_name) || product.name
53
- }, this.props.t.i18n(product.i18n_name) || product.name), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
54
- class: "order_attachment__product_desc"
55
- }, getProductPropName(product, ' / ')), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
56
- class: "order_attachment__product_desc"
57
- }, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(product.price))));
58
- }));
59
- }
60
- let $total = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
61
- class: "order_attachment__footer"
62
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
63
- class: "d-flex align-items-center justify-content-between"
64
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, this.props.t('total')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("b", {
65
- class: "order_attachment__total"
66
- }, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order.total)))));
67
- let phoneattr = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.find(_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'user.attributes', []), attr => attr.key === 'phones') || {
68
- key: 'phones',
69
- text: ''
70
- };
71
- let phone = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'shipping.address.phone', '').trim();
72
- phone = phone || _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.trim(phoneattr.text);
73
- if (phone) phone = this.props.t('phn') + ': ' + phone;
74
- let $shipto = null;
75
- if (displayOrderShippingAddress(order) || phone) {
76
- $shipto = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
77
- class: "order_attachment__label"
78
- }, this.props.t('ship_to')), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, displayOrderShippingAddress(order)), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
79
- class: "order_attachment__text_truncate"
80
- }, phone));
81
- }
82
- let $beforeTax = null;
83
- if (order._discount_before_tax) {
84
- $beforeTax = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
85
- class: "order_attachment__footer"
86
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
87
- class: "d-flex align-items-center justify-content-between"
88
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
89
- class: "order_attachment__label no_margin"
90
- }, this.props.t('subtotal_before_tax')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order._order_value))), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
91
- class: "d-flex align-items-center justify-content-between"
92
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
93
- class: "order_attachment__label no_margin"
94
- }, this.props.t('discount_before_tax')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, "-", _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order._discount_before_tax))));
95
- }
96
- let $subtotal = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
97
- class: "d-flex align-items-center justify-content-between"
98
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
99
- class: "order_attachment__label no_margin"
100
- }, this.props.t('subtotal')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
101
- style: ""
102
- }, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order.subtotal)));
103
- let $tax = null;
104
- if (order.total_tax) {
105
- let taxname = '';
106
- if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.size(order._taxM) === 1) {
107
- let tax = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order._taxM, '0.tax', {});
108
- if (tax.name && tax.percentage) taxname = `(${tax.name} ${Math.round(tax.percentage || 0) / 100}%)`;
109
- }
110
- $tax = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
111
- class: "d-flex align-items-center justify-content-between"
112
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
113
- class: "order_attachment__label no_margin"
114
- }, this.props.t('tax'), " ", taxname), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
115
- style: ""
116
- }, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order.total_tax)));
117
- }
118
- let $discount = null;
119
- if (order.discount_type === 'percentage' && order.discount_percentage) {
120
- $discount = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
121
- class: "d-flex align-items-center justify-content-between"
122
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
123
- class: "order_attachment__label no_margin"
124
- }, this.props.t('discount_after_tax'), " (", Math.round(order.discount_percentage / 100), "%)"), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
125
- style: ""
126
- }, "-", _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order._computed_discount)));
127
- }
128
- if (order.discount_type === 'amount' && order.discount_amount) {
129
- $discount = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
130
- class: "d-flex align-items-center justify-content-between"
131
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
132
- class: "order_attachment__label no_margin"
133
- }, this.props.t('discount_after_tax')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
134
- class: "no-shrink"
135
- }, "-", _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order._computed_discount)));
136
- }
137
- let $shipping = null;
138
- if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'shipping.nominal_fee')) {
139
- $shipping = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
140
- class: "d-flex align-items-center justify-content-between"
141
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
142
- class: "order_attachment__label no_margin"
143
- }, this.props.t('shipping_fee')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
144
- style: ""
145
- }, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'shipping.nominal_fee', 0))));
146
- }
147
- let $adjustment = null;
148
- if (order.adjustment) {
149
- $adjustment = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
150
- class: "d-flex align-items-center justify-content-between"
151
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
152
- class: "order_attachment__label no_margin"
153
- }, order.adjustment_description), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
154
- class: "no-shrink"
155
- }, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order.adjustment)));
156
- }
157
- $subtotal = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
158
- class: "order_attachment__footer"
159
- }, $subtotal, $tax, $shipping, $discount, $adjustment);
160
- if (!$shipping && !$adjustment && !$discount && !$tax) {
161
- $subtotal = null;
162
- }
163
- return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
164
- class: `order_attachment order_attachment__${byType}`
165
- }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
166
- class: "order_attachment__header"
167
- }, this.props.t('order'), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("span", {
168
- class: "order_attachment__text_muted order_attachment__text_sm"
169
- }, getOrderDisplayName(order))), $products, $shipto, $note, $beforeTax, $subtotal, $total);
170
- });
171
- return $orders;
172
- }
173
- }
174
- function getProductPropName(product, seperator = ' - ') {
175
- let options = op.get(product, 'options', []);
176
- let props = op.get(product, 'props', []);
177
- let multiPropsOptions = op.filter(options, option => op.size(option.values) > 1);
178
- let names = [];
179
- op.each(multiPropsOptions, option => {
180
- let prop = op.find(props, prop => prop.key === option.key) || {};
181
- if (prop.value) names.push(prop.value);
182
- });
183
- return names.join(seperator);
184
- }
185
- function getOrderDisplayName(order = {}) {
186
- return order.number || order.id || '';
187
- }
188
- function displayOrderShippingAddress(order, isShorten) {
189
- let addr = op.get(order, 'shipping.address', {});
190
- let fulladdr = [addr.address, addr.ward, addr.district, addr.province].filter(a => a).join(', ').trim();
191
- if (isShorten) fulladdr = shortenAddr(fulladdr);
192
- return fulladdr;
193
- }
194
- function shortenAddr(str) {
195
- str = str || '';
196
- str = str.replace(/Hà Nội/gi, 'HN');
197
- str = str.replace(/Hồ Chí Minh/gi, 'HCM');
198
- str = str.replace(/Thành Phố/gi, 'TP');
199
- return str;
200
- }
201
- function calcOrderTotal(order) {
202
- let subtotal = 0;
203
- let beforeTaxDiscount = 0;
204
- let ordervalue = 0;
205
- op.map(order.items, item => {
206
- if (!item.product) return 0;
207
- let price = op.get(item, 'product.price', 0) * (item.quantity || 0);
208
- ordervalue += price;
209
- if (item.discount_type == 'percentage') {
210
- if (item.discount_percentage > 0) {
211
- beforeTaxDiscount += price * item.discount_percentage / 10000;
212
- price = price * (1 - (item.discount_percentage || 0) / 10000);
213
- }
214
- } else if (item.discount_type == 'amount') {
215
- if (item.discount_amount > 0) {
216
- beforeTaxDiscount += item.discount_amount;
217
- price = price - (item.discount_amount || 0);
218
- if (price <= 0) price = 0;
219
- }
220
- }
221
- item.total = price;
222
- subtotal += price;
223
- });
224
- let taxM = {};
225
- op.map(order.items, (item, i) => {
226
- if (!item.product) return;
227
- let tax = item.product.tax;
228
- if (!tax) return;
229
- if (!tax.id) return;
230
- let taxprice = item.total * tax.percentage / 10000;
231
- item.total_tax = taxprice;
232
- taxM[i] = {
233
- tax: tax,
234
- taxprice: taxprice
235
- };
236
- });
237
- let totaltax = 0;
238
- op.map(taxM, t => totaltax += t.taxprice);
239
- let computed_discount = 0;
240
- if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
241
- computed_discount = (subtotal + totaltax) * order.discount_percentage / 10000;
242
- } else if (order.discount_type == 'amount') {
243
- computed_discount = order.discount_amount || 0;
244
- }
245
- let shippingfee = op.get(order, 'shipping.nominal_fee', 0);
246
- if (shippingfee > 0) {
247
- if (op.get(order, 'shipping.tax.id')) {
248
- let tax = order.shipping.tax;
249
- let taxprice = shippingfee * (tax.percentage / 10000);
250
- taxM['ship'] = {
251
- tax: tax,
252
- taxprice: taxprice
253
- };
254
- order.shipping.total_tax = taxprice;
255
- }
256
- }
257
- totaltax = 0;
258
- op.map(taxM, t => totaltax += t.taxprice);
259
- let total = subtotal + totaltax - computed_discount + shippingfee;
260
- total += order.adjustment || 0;
261
- if (total < 0) total = 0;
262
- order.subtotal = subtotal;
263
- order._computed_discount = computed_discount;
264
- order._taxM = taxM;
265
- order.total = total;
266
- order.total_tax = totaltax;
267
- order._discount_before_tax = beforeTaxDiscount;
268
- order._order_value = ordervalue;
269
- }
270
-
271
- /***/ })
272
-
273
- }]);